akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define sc(a) scanf("%d",&a)
#define scm(a,b) scanf("%d%d",&a,&b)
#define fl(c,i,n) for(int i=c;i<n;i++)
#define f(i,n) for(int i=0;i<n;i++)
#define mem(a) memset(a,0,sizeof(a))
#define ll long long int
#define ull unsigned long long int
#define inf INT_MAX
#define linf LLONG_MAX
#define pb push_back
#define pp pop_back()
#define aov(a) a.begin(),a.end()
//#define mp make_pair
#define nl printf("\n")
#define PI 2.0*acos(0.0) //#define PI acos(-1.0)
#define xx first
#define yy second
#define mxv(a) *max_element(aov(a))
#define mnv(a) *min_element(aov(a))
#define LB(a,x) (lower_bound(aov(a),x)-a.begin())
#define UB(a,x) (upper_bound(aov(a),x)-a.begin())
#define to_c_string(a) a.c_str()
#define strtoint(c) atoi(&c[0])
#define pii pair<int,int>
#define MAXN 500005
#define MOD 1000000007

template <class T> inline T bigmod(T p,T e,T M){
    ll ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}
/*int fact[MAXN];
int invfact[MAXN];
int inv(int a, int b){
    if(b==0)
        return 1;
    if(b&1)
        return (long long)a*inv(a, b-1)%MOD;
    else{
        int res = inv(a, b>>1);
        return (long long)res*res%MOD;
    }
}
void init(){
    fact[0] = 1;
    for(int i=1;i<MAXN;i++){
        fact[i] = (long long)fact[i-1]*i%MOD;
    }
    invfact[MAXN-1] = inv(fact[MAXN-1], MOD-2);
    for(int i=MAXN-1;i>0;i--){
        invfact[i-1] = (long long)invfact[i]*i%MOD;
    }
}
int C(int n, int r){
    if(r>n || r<0)
        return 0;
    return (long long)((long long)fact[n]*invfact[r]%MOD)*invfact[n-r]%MOD;
}*/
string a, b, ans;
void solve(){
    cin>>a>>b;
    int l = a.length()+b.length();
    for(int i=0;i<l;i++){
        if(i%2==0)  ans+=a[i/2];
        else    ans+=b[i/2];
    }
    cout<<ans;
}
int main(){
    /*FILE *fin = freopen("C-small-attempt0.in", "r", stdin);
	assert( fin!=NULL );
	FILE *fout = freopen("C-small.out", "w", stdout);*/
	//init();
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
main(){int n,v[5000],m;while(std::cin>>n,m=n){for(;m--;)std::cin>>v[m];m=*v;for(int i=0;i<n;i++)for(int j=i,k=v[i];j<n;j++,k+=v[j])m=k>m?k:m;std::cout<<m<<'\n';}}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll int64_t
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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


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

int n,k;
ll T[101010];

int check(ll P){
    int i = 0;
    REP(j,k){
        ll s = 0;
        while(s+T[i]<=P){
            s += T[i];
            i++;
            if(i==n) return n;
        }
    }
    return i;
}

int solve(){
    ll l = 0;
    ll r = 101010*10101;
    while(r-l>1){
        ll mid = (r+l)/2;
        int v = check(mid);
        if(v>=n) r=mid;
        else l = mid;
    }
    return r;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n>>k;
    REP(i,n) cin>>T[i];
    ll ans = solve();
    cout<<ans<<endl;
}


Measured memory_bytes: 4004
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <cstring>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define vi vector <int>
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))
#define fname "searching"

const int inf = (int)1e9;
const ll INF = (ll)1e18;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int mod = (int)1e9 + 7;

int n;
int a[1100];
int ok[10];

void check(int x){
	if(x >= 1 && x <= 399){
		ok[0] = 1;
	}else if(x >= 400 && x <= 799){
		ok[1] = 1;
	}else if(x >= 800 && x <= 1199){
		ok[2] = 1;
	}else if(x >= 1200 && x <= 1599){
		ok[3] = 1;
	}else if(x >= 1600 && x <= 1999){
		ok[4] = 1;
	}else if(x >= 2000 && x <= 2399){
		ok[5] = 1;
	}else if(x >= 2400 && x <= 2799){
		ok[6] = 1;
	}else if(x >= 2800 && x <= 3199){
		ok[7] = 1;
	}else{
		ok[8]++;
	}
}

int main(){
	// freopen("input.txt", "r", stdin);
	// freopen(fname".in", "r", stdin);
	// freopen(fname".out", "w", stdout);
	scanf("%d", &n);
	for(int i = 0; i < n; ++i)
		scanf("%d", &a[i]);
	for(int i = 0; i < n; ++i){
		check(a[i]);
	}
	int xa = 0, xb = 0;
	for(int i = 0; i < 8; ++i){
		if(ok[i])
			xa++;
	}
	xb = xa + ok[8];
	if(xa == 0){
		if(xb == 0){
			printf("0 0 \n");
		}else{
			printf("1 %d\n", xb);
		}
		return 0;
	}
	printf("%d %d\n", xa, xb);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/math/common_factor_rt.hpp>
using namespace boost::multiprecision;
using namespace std;
using LL = long long;
int main()
{
    LL X,Y;
    cin >>X >> Y;
    if(X==Y){
        cout<<-1<<endl;
        return 0;
    }
    set<int> s;
    for(unsigned long long a = X;a < 100000000000000000;a += X){
        if(a%Y!=0){
            cout<<a<<endl;
            return 0;
        }
        int c =s.size();
        s.insert(a%Y);
        if(c==s.size()){
            break;
        }
    }
    cout<<-1<<endl;
   return 0;
}


Measured memory_bytes: 256
#N = int(input())
A,B,K= map(int,input().split())
#v =list(map(int,input().split()))
# [list(map(int,input().split())) for i in range(N)]

if A<=K:
    print('0',max(B-K+A,0))
else:
    print(A-K,B)


Measured memory_bytes: 38256
#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(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#include<algorithm>

using namespace std;
typedef long long ll;

int main(){
    ll n, m, x;
    cin >> n >> m >> x;

    vector<vector<ll>> a(n, vector<ll>(m, 0));
    vector<ll> c(n, 0);

    REP(i, n) REP(j, m) {
        if (j == 0) cin >> c[i];
        cin >> a[i][j];
    }

    ll mincost = INF;
    ll currcost = 0; 

    for (int bit = 0; bit < (1<<n); ++bit){
        vector<ll> ans(m, 0);
        currcost = 0;
        /* bit で表される集合の処理を書く */
        vector<int> S;
        for (int i = 0; i < n; ++i) {
            if (bit & (1<<i)) { // i が bit に入るかどうか
                S.push_back(i);
            }
        }

        // bit の表す集合の出力
        for (ll i = 0; i < S.size(); ++i) {
            REP(j, m){
                ans[j] += a[S[i]][j];
            }
            currcost += c[S[i]];
            // cout << S[i];
        }
        // cout << endl;
        // cout << ' ' << currcost << endl;
        int flag = 1;
        REP(k, m){
            if (ans[k] < x){
                flag = 0;
            }
        }

        if (flag && currcost < mincost) mincost = currcost; 
    }
    if (mincost == INF) cout << "-1" << endl;
    else cout << mincost << endl;
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n,c;
void dfs(ll d){
  ll d3=d*10+3,d5=d*10+5,d7=d*10+7;
  if(d3<=n){
    ll dd=d3;
    bool b3=false,b5=false,b7=false;
    while(dd!=0){
      if(dd%10==3) b3=true;
      else if(dd%10==5) b5=true;
      else if(dd%10==7) b7=true;
      dd/=10;
    }
    if(b3&&b5&&b7) c++;
    dfs(d3);
  }
  if(d5<=n){
    ll dd=d5;
    bool b3=false,b5=false,b7=false;
    while(dd!=0){
      if(dd%10==3) b3=true;
      else if(dd%10==5) b5=true;
      else if(dd%10==7) b7=true;
      dd/=10;
    }
    if(b3&&b5&&b7) c++;
    dfs(d5);
  }
  if(d7<=n){
    ll dd=d7;
    bool b3=false,b5=false,b7=false;
    while(dd!=0){
      if(dd%10==3) b3=true;
      else if(dd%10==5) b5=true;
      else if(dd%10==7) b7=true;
      dd/=10;
    }
    if(b3&&b5&&b7) c++;
    dfs(d7);
  }
}
int main(){
  cin>>n;
  dfs(0);
  cout<<c;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<unordered_map>
#include<iterator>
using namespace std;

int main()
{
    int N, ans;
    cin>>N;
    ans = (N%1000);
    if(ans!=0)
    {
        ans = 1000-(N%1000);   
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
L = sorted(list(map(int,input().split())))
ans = 0
while L[0] != L[1] or L[1] != L[2]:
    ans += 1
    if L[0]+2 <= L[2]:
        L[0] += 2
    else:
        L[0] += 1
        L[1] += 1
    L = sorted(L)
print(ans)


Measured memory_bytes: 38256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n, x;
  cin >> n >> x;

  vll as(n);
  rep(i, n) cin >> as[i];
  Sort(as);

  ll ans = 0;
  rep(i, n) {
    if (as[i] > x) break;
    if (i == n - 1 && as[i] != x) break;
    ans++;
    x -= as[i];
  }

  cout << ans << endl;

  return 0;
}


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

int main(){
  int n;
  cin >> n;
  map<int,int> mp;
  for(int i=1; i<n; ++i){
    int x;
    cin >> x;
    ++mp[x];
  }
  for(int i=1; i<=n; ++i){
    cout << mp[i] << endl;
  }
}

Measured memory_bytes: 13008
#include "bits/stdc++.h"

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

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

	int c = A + B;
	if (c % 2 == 0) {
		cout << c / 2 << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}

	return 0;
}


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


int main(){

    ll L,R; cin>>L>>R;

    ll ans = 2019;

    int count = 0;
    

    for(ll i=L; i<=R; i++){
        for(ll j=i+1; j<=R; j++){

            if(count > 2019) break;

            ans = min(ans,(i*j)%2019);
            
            if(ans == 0) break;

        }

        count++;
    }

    cout<<ans<<endl;

    return 0;
}

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

#define pb push_back
#define F first
#define S second

#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define int long long
#define ll long long


	
void solve(){
	int x, y;
	cin >> x >> y;
	if(y >= 2 * x && y <= 4 * x && y % 2 == 0)
		cout << "Yes";
	else
		cout << "No";	

}

signed main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t = 1;
	//cin >> t;
	while(t--)
		solve();
	return 0;
}


Measured memory_bytes: 3648
function  parse_int(x)
    parse(Int, x)
end
function  MAP()
    map(parse_int, split(readline(), " "))
end

function solve()
    N, K = MAP()
    p = MAP()
    sort!(p)
    ans = 0
    for i = 1 : K
        ans += p[i]
    end
    ans
end

ans = solve()
println("$(ans)")

Measured memory_bytes: 162136
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
using namespace std;
// type alias
typedef long long LL;
typedef vector < int > VI;
typedef unordered_map < int, int > MAPII;
typedef unordered_set < int > SETI;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// minmax
#define SMAX(a,b) a = max(a,b)
#define SMIN(a,b) a = min(a,b)
// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }

/*
 
 8/23/2018
 
 20:55-
 
 */

// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG x.cpp && ./a.out
LL N,X;

LL f(LL x, LL y) {
  if(x>y) swap(x,y);
  LL p=y/x;
  LL res=x*2LL*p;
  if(y%x==0) return res-x;
  res+=f(y%x,x);
  return res;
}

LL solve() {
  X=min(X,N-X);
  return X+(N-X)+f(X,N-X);
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  cin>>N>>X;
  cout<<solve()<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}

int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

int main(){
	vector<vector<int> > v(3);
	rep(i,3)rep(j,3){
		int a; cin >> a;
		v[i].push_back(a);
	}
	vector<int > x(3), y(3);
	for(int i = 0; i < 3 ; i++){
		x[i] = v[0][i];
		y[i] = v[i][0] - x[0];
	}
	rep(i,3)rep(j,3){
		if (v[i][j]!=y[i] + x[j]){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define pb push_back
#define F first
#define S second
#define M (ll)(1e9+7)
#define mp make_pair
  
using namespace std; 
typedef long long ll;
bool isPrime(int a)
{
    if(a<2)
    return false;
    for(int i=2;i*i<=a;i++)
    if(a%i==0)
    return false;
    return true;
}
void solve()
{
    int x;
    cin>>x;
    while(true)
    {
        if(isPrime(x))
        {
            cout<<x<<endl;
            return;
        }
        x++;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#define INF 10000000000000000
#define MOD 1000000007
using namespace std;


int main(){
    int n;
    cin >> n;
    
    long long a[n];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    
    sort(a,a+n);
    
    long long ai,aj;
    
    ai=a[n-1];
    
    long long temp=-1;
    for(int i=0; i<n-1; i++){
        if(temp<min(a[i],ai-a[i])){
            aj=a[i];
            temp=min(a[i],ai-a[i]);
        }
    }
    
    cout << ai << " " << aj <<endl;
    
    return 0;
}


Measured memory_bytes: 1024
import math
a, b, C = map(float, input().split())
S = a*b*math.sin(math.radians(C))/2
L = a + b + math.sqrt(a*a + b*b - 2*a*b*math.cos(math.radians(C)))
h = 2 * S / a
print(f"{S} {L} {h}")


Measured memory_bytes: 5708
kaijo = [1]
for i in range(1, 9):
  kaijo.append(kaijo[i-1]*i)

def numberof(n, p):
  rtn = 0
  order = list(range(1,n+1))
  for i, x in enumerate(p[:-1]):
    idx = order.index(x)
    order.pop(idx)
    rtn += kaijo[len(order)]*idx
  return rtn+1

N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
print(abs(numberof(N, Q)-numberof(N, P)))

Measured memory_bytes: 3064
from collections import deque
N = int(input())
A = tuple(map(int, input().split()))
B = deque([])
for i in range(N):
    if i & 1:
        B.appendleft(A[i])
    else:
        B.append(A[i])
if N & 1:
    print(*reversed(B))
else:
    print(*B)


Measured memory_bytes: 25668
#include<iostream>
#include<vector>
#include<map>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<bitset>
#include<iomanip>
#define BUG puts("no bug")
#define sci(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define ll long long
#define ull unsigned long long
#define REP(a,b,c) for(ll a=b;a<=c;a++)
#define PER(a,b,c) for(ll a=b;a>=c;a--)
#define lb(a) (a&(-a))
#define pp (p<<1)
#define ppp (p<<1|1)
#define pi pair<ll,ll>
#define pii pair<pair<ll,ll>,ll>
using namespace std;
const ll MAXN=1e6+5;
ll n,m,t;
ll v[MAXN];
ll A[MAXN],B[MAXN],C[MAXN];
struct NODE{
    ll v;
    bool operator < (NODE x)const {
        return v>x.v;
    }
};
int main(){
    ll a,b,c;
    cin>>n>>m>>a>>b>>c;
    priority_queue<NODE>qu1,qu2;
    REP(i,1,a)cin>>A[i];
    REP(i,1,b)cin>>B[i];
    REP(i,1,c)cin>>C[i];
    sort(A+1,A+1+a);
    sort(B+1,B+1+b);
    sort(C+1,C+1+c);
    PER(i,a,a-n+1)qu1.push({A[i]});
    PER(i,b,b-m+1)qu2.push({B[i]});
    PER(i,c,1){
        if(qu1.top().v<qu2.top().v){
            if(C[i]>qu1.top().v){
                qu1.pop();
                qu1.push({C[i]});
            }
        }
        else {
            if(C[i]>qu2.top().v){
                qu2.pop();
                qu2.push({C[i]});
            }
        }
    }
    ll ans=0;
    REP(i,1,n){
        ans+=qu1.top().v;
        qu1.pop();
    }
    REP(i,1,m){
        ans+=qu2.top().v;
        qu2.pop();
    }
    cout<<ans;
}

Measured memory_bytes: 11508
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1e9 + 7
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

int main() {
    int n;
    cin >> n;
    double x;
    string u;
    double sum = 0;
    rep(i, n) {
        cin >> x >> u;
        if (u == "BTC") {
            sum += x * 380000.0;
        }
        else {
            sum += x;
        }
    }
    cout <<fixed<< setprecision(7)<<sum << endl;
}

Measured memory_bytes: 256
a, b = map(int, input().split())
ma = 0
mi = 10 ** 9
for i in range(b):
    c, d = map(int, input().split())
    ma = max(ma, c)
    mi = min(mi, d)
if ma > mi:
    print(0)
else:
    print(abs(ma - mi) + 1)


Measured memory_bytes: 3060
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n, m = map(int, input().split())
s = input() #sys.stdin.readlineは最後が改行
t = input() #sys.stdin.readlineは最後が改行

from fractions import gcd

gcdnm = gcd(n, m)
L = (n * m) // gcdnm

gcdd = gcd(L//n, L//m)
l = (L//n *L//m) // gcdd


if s[0]!=t[0]:
    print(-1)
    exit()

i = 1


while l//(L//n)*i < n and l//(L//m)*i <m:
    if s[l//(L//n)*i] != t[l//(L//m)*i]:
        print(-1)
        exit()
    i+=1

print(L)





Measured memory_bytes: 5360
N, K = map(int, input().split())

h = []
for _ in range(N):
    h.append(int(input()))

h.sort()

iter = len(h) - K

c_hmin = 99999999999999999999999999999999

for i in range(iter+1):

    hmin = h[K+i-1] - h[i]
    if c_hmin > hmin:
        c_hmin = hmin

print(c_hmin)

Measured memory_bytes: 7384
#include <stdio.h>

int main(){
    int inD;
    int c[27] = {0};
    int s[366][27] = {0};
    int t[366] = {0};
    long long int manzoku=0;
    int last[366] = {0};

    scanf("%d", &inD);
    for(int i=1; i<=26; ++i){
        scanf("%d", &c[i]);
    }
    
    // // Test
    // for(int i=1; i<=26; ++i){
    //     printf("%d ", c[i]);
    // }
    // printf("\n\n");

    for(int i=1; i<=inD; ++i){
        for(int j=1; j<=26; ++j){
            scanf("%d", &s[i][j]);
        }
    }
    
    // // Test
    // for(int i=1; i<=inD; ++i){
    //     for(int j=1; j<=26; ++j){
    //         printf("%d ", s[i][j]);
    //     }
    //     printf("\n");
    // }
    // printf("\n\n");

    // 問題B入力
    for(int i=1; i<=inD; ++i){
        scanf("%d", &t[i]);
    }

    // // Test
    // for(int i=1; i<=inD; ++i){
    //     printf("%d ", t[i]);
    // }
    // printf("\n\n");

    for(int day=1; day<=inD; ++day){
        long long int down = 0;
        last[t[day]] = day;
        for(int i=1; i<=26; ++i){
            down += c[i]*(day - last[i]);
            // printf("down %d %lld %d %d\n", day, down, c[i], last[i]);
        }

        manzoku = manzoku + s[day][t[day]] - down;
        // printf("manzoku %d %d %lld %d %lld\n", day, t[day], manzoku, s[day][t[day]], down);
        // printf("last %d %d\n", t[day], last[t[day]]);

        printf("%lld\n", manzoku);
    }

}

Measured memory_bytes: 1724
#include<iostream>
#include <cstdio>
#include<cstring>
#include<string>
#include <cstdlib>  
#include<cmath>   
#include <cctype>
#include<string>
#include<set>
#include <iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<list>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility>
#define LEN 100005
using namespace std;
using ll = long long;
double pi() { return 3.14; }
int sum(int a, int b) { return a + b; }
int mul(int a, int b) { return a * b; }
ll LGCD(ll x, ll y) { if (x % y == 0) return y;else return LGCD(y, x % y); }
ll LLCM(ll x, ll y) { return x * y / LGCD(x, y); }

int GCD(int x, int y) { if (x % y == 0) return y;else return GCD(y, x % y); }
int LCM(int x, int y) { return x * y / GCD(x, y); }
ll dpc[10000][10000];

//void nCr(ll n, ll r) {
//	ll ans = 1;
//	for (int i = n; i > n - r; --i) {
//		ans = ans * i;
//	}
//	for (int i = 1; i < r + 1; ++i) {
//		ans = ans / i;
//	}
//	printf("%d",ans);
//}

ll combination(ll n, ll r) {
	if (n == r) { return dpc[n][n] = 1; }
	else if (r == 0) { return dpc[n][0] = 1; }
	else if (r == 1) { return dpc[n][1] = n; }
	else if (dpc[n][r]) { return dpc[n][r]; }
	else { return dpc[n][r] = combination(n - 1, r - 1) + combination(n - 1, r); }
}

//cout << fixed << setprecision(10);

int main() {
	int n;
	string s;
	cin >> n >> s;
	int  ans = 0;
	for (int i = 0;i < 10;i++) {
		for (int j = 0;j < 10;j++) {
			for (int k = 0;k < 10;k++) {
				int count = 0;
				for (int l = 0;l < s.size();l++) {
					if (s[l] - '0' == i&&count==0) count++;
					else if (s[l] - '0' == j && count == 1)count++;
					else if (s[l] - '0' == k && count == 2) {
						count++;break;
					}
				}if (count == 3)ans++;

			}
		}
	}

	cout << ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int n;
    cin >> n;
    vector<int> arr(n, 0);
    for(int i = 0; i < n; i++)
        cin >> arr[i];
    auto it = max_element(arr.begin(), arr.end());
    int idx = distance(arr.begin(), it);
    int M = *it;
    for(int i = idx; i < n-1; i++) {
        arr[i] = arr[i+1];
    }
    int M2 = *max_element(arr.begin(), arr.begin()+(n-1));
    for(int i = 0; i < n; i++) {
        if (i == idx)
            cout << M2 << endl;
        else
            cout << M << endl;
    }
}





Measured memory_bytes: 2432
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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; }


int main(){
    ll a, b, c, k; cin >> a >> b >> c >> k;
    k = k%2+2;
    rep(i, k){
        ll x=b+c, y=a+c, z=a+b;
        a=x, b=y, c=z;
    }
    cout << a-b << ln;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main(){
    int n,m,k;
    cin >> n >> m >> k;
    int l[m],r[m],p[k],q[k];
    vector <int> a;
    map <vector<int>,int> mp;
    rep(i,n+2){
        rep(j,n+2){
            a = {i,j};
            mp[a] = 0;
        }
    }
    rep(i,m){
        cin >> l[i] >> r[i];
        a = {l[i],r[i]};
        mp[a]++;
    }
    rep(i,k){
        cin >> p[i] >> q[i];
    }
    int b[n+2][n+2];
    b[0][1] = 0;
    for(int j = 1;j<n+1;j++){
        for(int i = 1;i<n+2;i++){
            a = {i,j};
            b[i][j] = b[i-1][j] + mp[a];
        }
        b[0][j+1] = b[n+1][j];
    }
    int ans = 0;
    rep(i,k){
        ans = 0;
        for(int j = p[i];j<=q[i];j++){
            ans+= b[q[i]][j] - b[p[i]-1][j];
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 31872
A=[]
for i in range(3):
    A.append(list(map(int,input().split())))
N=int(input())
B=list(int(input()) for i in range(N))

for i in range(N):
    for j in range(3):
        for k in range(3):
            if B[i] == A[j][k]:
                A[j][k] = 0             
if( ((A[0][0]==0) and (A[1][1]==0) and (A[2][2]==0)) or
   ((A[2][0]==0) and (A[1][1]==0) and (A[0][2]==0)) ):
    print('Yes');exit(0)


for j in range(len(A[0])): 
    if( ((A[j][0]==0) and (A[j][1]==0) and (A[j][2]==0)) or
       ((A[0][j]==0) and (A[1][j]==0) and (A[2][j]==0))    ):    
        print('Yes');
        exit(0)

print('No')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

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

const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};

const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

vector< vector<int> > Graph;
vector< int > value;



int main(int argc, const char * argv[]) {
    
   

    cin.tie(0);
    ios::sync_with_stdio(false);
   
    int n; cin >> n;
    if(n%2==0) cout << setprecision(10) << (double)1/2 << endl;
    else cout << setprecision(10) << double(n/2 + 1)/n << endl;
    
    
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main()
{
    int n;
    cin >> n;
    int s = 0;
    vector<int>a(n);
    vector<int>b(n);
    for(int i = 0; i < n; ++i)
    {
        cin >> a[i];
        s += (i % 2 == 1 ? -1 : 1) * a[i];
    }
    b[0] = s;
    for(int i = 1; i < n; ++i)
    {
        b[i] = 2 * a[i - 1] - b[i - 1];
    }
    for(int i = 0; i < n; ++i)
        cout << b[i] << " ";
    return 0;
}


Measured memory_bytes: 2816
from sys import stdin


def fetch_one_line():
    return stdin.readline().rstrip()


def fetch_int_input():
    return [int(s) for s in fetch_one_line().split()]


def fetch_inputs(times):
    return [fetch_one_line() for _ in range(times)]


def fetch_int_inputs(times):
    return [[int(s) for s in fetch_one_line()] for _ in range(times)]


def fetch_ints_inputs(times):
    return [fetch_int_input() for _ in range(times)]


string = fetch_one_line()

print(("").join(["x" for _ in string]))


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define ll long long
#define p1 19260817
#define p2 19491001
#define m1 666623333
#define m2 1004535809
using namespace std;
int head[1048577],nxt[500005],tot=0;
int w1[500005],w2[500005],w[500005];
int a1[250005],b1[250005];
int a2[250005],b2[250005];
char s[250005];
ll ans=0;
inline int qpow(int a,int b,int mod)
{int res=1,tp=a;
while (b)
{if (b&1) res=1ll*res*tp%mod;
tp=1ll*tp*tp%mod;b>>=1;
}
return res;
}
inline void add(int v1,int v2)
{int bel=((v1&1023)<<10)|(v2&1023),i;
for (i=head[bel];i;i=nxt[i])
{if (w1[i]==v1&&w2[i]==v2) {w[i]++;return;}
}
tot++;nxt[tot]=head[bel];head[bel]=tot;
w1[tot]=v1;w2[tot]=v2;w[tot]=1;
}
inline int ask(int v1,int v2)
{int bel=((v1&1023)<<10)|(v2&1023),i;
for (i=head[bel];i;i=nxt[i])
{if (w1[i]==v1&&w2[i]==v2) return w[i];
}
return 0;
}
inline int sub1(int a,int b)
{return (a-b<0?a-b+m1:a-b);}
inline int sub2(int a,int b)
{return (a-b<0?a-b+m2:a-b);}
inline int add1(int a,int b)
{return (a+b>=m1?a+b-m1:a+b);}
inline int add2(int a,int b)
{return (a+b>=m2?a+b-m2:a+b);}
int main (){
	int i,n,x1=0,x2=0;
	scanf ("%d",&n);
	scanf ("%s",s+1);
	a1[n+1]=1;b1[n+1]=0;
	a2[n+1]=1;b2[n+1]=0;
	int inv1=qpow(p1,m1-2,m1);
	int inv2=qpow(p2,m2-2,m2);
	for (i=n;i>=1;i--)
	{if (s[i]=='<') 
	{a1[i]=1ll*a1[i+1]*p1%m1;
	a2[i]=1ll*a2[i+1]*p2%m2;
	b1[i]=b1[i+1];b2[i]=b2[i+1];
	continue;
	}
	if (s[i]=='>')
	{a1[i]=1ll*a1[i+1]*inv1%m1;
	a2[i]=1ll*a2[i+1]*inv2%m2;
	b1[i]=b1[i+1];b2[i]=b2[i+1];
	continue;
	}
	if (s[i]=='+')
	{b1[i]=sub1(b1[i+1],a1[i+1]);
	b2[i]=sub2(b2[i+1],a2[i+1]);
	a1[i]=a1[i+1];a2[i]=a2[i+1];
	continue;
	}
	b1[i]=add1(b1[i+1],a1[i+1]);
	b2[i]=add2(b2[i+1],a2[i+1]);
	a1[i]=a1[i+1];a2[i]=a2[i+1];
	}
	for (i=n;i>=1;i--)
	{if (s[i]=='+') {x1=add1(x1,1);x2=add2(x2,1);continue;}
	if (s[i]=='-') {x1=sub1(x1,1);x2=sub2(x2,1);continue;}
	if (s[i]=='<') {x1=1ll*x1*inv1%m1;x2=1ll*x2*inv2%m2;continue;}
	x1=1ll*x1*p1%m1;x2=1ll*x2*p2%m2;
	}
	add(0,0);
	for (i=n;i>=1;i--)
	{int r1=(1ll*a1[i]*x1+b1[i])%m1;
	int r2=(1ll*a2[i]*x2+b2[i])%m2;
	ans+=ask(r1,r2);
	add(b1[i],b2[i]);
	}
	printf ("%lld\n",ans);
	return 0;
}

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

int main() {
 	int a,b,k;cin>>a>>b>>k;
  	if((b-a+1)>k*2){
    	for(int i=0;i<k;i++){
        	cout<<a+i<<endl;
        }
    	for(int i=k-1;0<=i;i--){
        	cout<<b-i<<endl;
        }
    }else{
    	for(int i=0;i<b-a+1;i++){
        	cout<<a+i<<endl;
        }
    
    }
}

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

int main() {
  int a, b;
  
  scanf("%d %d", &a, &b);
  if (a > b) {
    for (int i = 0; i < a; i++) {
      printf("%d", b);
    }
  } else {
    for (int i = 0; i < b; i++) {
      printf("%d", a);
    }
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 760
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		Map<String, Long> map = new HashMap<>();
		long cnt = 0;

		for ( int i = 0; i < n; i++ ) {
			char[] s = in.next().toCharArray();
			Arrays.sort(s);
			String key = new String(s);

			if(map.containsKey(key)) {
				cnt += map.get(key);
				map.put(key, map.get(key) + 1);
			}else {
				map.put(key, (long) 1);
			}
		}

		System.out.println(cnt);
		in.close();
	}
}

Measured memory_bytes: 53972
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(input){
    var line = input.trim().split("\n");
    var i = 0;
    while(line[i] !== '0')
    {
        var N = parseInt(line[i++].trim());
        {
            var found, len, k, res;
            var qualified = [], amount = [];
            for(--N;N>=0;--N){
                var dataset = line[i++].trim().split(" ");
                res = parseInt(dataset[1]) * parseInt(dataset[2]);
                
                found = 0;
                for(k=0;k<qualified.length;++k){
                    if(qualified[k] == dataset[0]){
                        found = 1;
                        amount[k] = amount[k] + res;
                        break;
                    }
                }
                
                if( !found ){
                    qualified.push(dataset[0]);
                    amount.push(res);
                }
            }
            
            found = 0;
            len = qualified.length;
            for(k=0;k<len;++k){
                if( amount[k] >= 1000000 ){
                    console.log(qualified[k]);
                    found = 1;
                }
            }
            if( !found ){
                console.log("NA");
            }
        }
    }
});

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

int main() {
  string S;
  cin >> S;
  int n = S.length();
  long long ans = 0;
  for (int i = 0; i < (1<<n-1); i++) {
    long long tmp = 0;
    for (int j = 0; j < n; j++) {
      tmp = tmp * 10 + S[j] - '0';
      if (i & (1<<j)) {
        ans += tmp;
        tmp = 0;
      }
    }
    ans += tmp;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

def ri():
    return int(input())

def rl():
    return list(map(int, input().split()))


def solve():
    s = input()
    t = input()
    if len(s) == len(t) - 1 and s == t[:-1]:
        print ("Yes")
    else:
        print ("No")





mode = 's'

if mode == 'T':
    t = ri()
    for i in range(t):
        solve()
else:
    solve()


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

int main() {
       ll A;
       double B;
       cin >> A >> B;
       ll C = B*100 + 0.5;
       cout << A*C/100 << endl;
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

using namespace std;

#define li long long int
#define ld long double
const int MX1=1e5+5;
const int MX2=1e6+5;
const li inf=4e18;
const li mod=1e9+7;

li power(li a,li b){li res=1;while(b){if(b%2)res=(res*a)%mod;
a=(a*a)%mod;b/=2;}return res;}

li mmi(li a){return power(a,mod-2);}

li cntbit(li n){li cnt=0;while(n){n&=(n-1);cnt++;}return cnt;}

li x,y;

bool chk(li mid){
	li res=0;
	for(li i=max(mid/2-100,1ll);i<=min(mid/2+100,mid);i++){
		li a=i;
		li b=mid-i+1;
		if(a>=x) ++a;
		if(b>=y) ++b;
		res=max(res,a*b);
	}
	return res<x*y;
}

void solve(){
	cin>>x>>y;
	// if(x>y) swap(x,y);
	li lo=1;
	li hi=3e9;
	li ans=0;
	while(lo<=hi){
		li mid=lo+hi>>1;
		if(chk(mid)){
			ans=mid;
			lo=mid+1;
		}else{
			hi=mid-1;
		}
	}
	cout<<ans<<"\n";
}

int main(){
	ios_base::sync_with_stdio(NULL);
	cin.tie(NULL);
	int t=1;
	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
import itertools

N = int(input())
P = tuple(map(int,input().split()))
Q = tuple(map(int,input().split()))

a = -1
b = -1
cnt = 0
for perm in itertools.permutations(range(1, N + 1), N):
  cnt += 1
  if P == perm:
    a = cnt
  if Q == perm:
    b = cnt
    
print(abs(a - b))

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

int main(){

    int K;
    string S;
    cin >> K >> S;
    if(S.length() > K){
        cout << S.substr(0,K) + "..." << endl;
    }else{
        cout << S << endl;
    }




}

Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	char s;
	cin >> s;
	cout << (char)(s + 1) << endl;
}


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

int main() {
  string s; cin >> s;
  int a=0;
  for(char& ch : s) {
    if(ch=='+') a++;
    else a--;
  }
  cout << a << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		double H = sc.nextInt();
		double A = sc.nextInt();
		double Answer;

		Answer = Math.ceil(H/A);

		int D = (int) Answer;
		System.out.println(D);
	}
}


Measured memory_bytes: 21844
N, L = map(int, input().split())
A = list(map(int, input().split()))
flg = False
for i in range(N - 1):
    if A[i] + A[i+1] >= L:
        flg = True
        break
if not flg:
    print("Impossible")
    exit()
else:
    print("Possible")
# 0, 1, ..., i - 1, [i], [i+1], i + 2, ..., N - 1
for j in range(i):
    print(j + 1)
for j in range(N - 1, i + 1, -1):
    print(j)
print(i + 1)


Measured memory_bytes: 14136
package main

import "fmt"
import "math"

func main() {
	var A, B, H, M float64
	var theta float64 = 0
	var temp float64
	fmt.Scan(&A,&B,&H,&M)
	temp = 60*H+M
	theta = temp/720 - M/60

	fmt.Println(math.Sqrt(A*A+B*B-2*A*B*(math.Cos(2*math.Pi*theta))))
}

Measured memory_bytes: 1824
#include <iostream>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <utility>
#include <numeric>
using namespace std;

int main() {
    string S; cin >> S;
	int N = S.size();

	vector<int> s(N);

	for(int i = 0; i < N; i++){
		s[i] = S[i] - '0';
	}

	int ans = 99999999;
	const int num = 753;

	for(int i = 0; i < N-2; i++){
		int tmp = 100 * s[i] + 10 * s[i+1] + s[i+2];
		if(abs(tmp-num) < abs(ans-num)) ans = tmp;
	}

	cout << abs(ans - num) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using P = pair<int,int>;
using ll = long long;
static const int INF = 1000000000;
static const ll MOD = 1000000007;

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int main(){
	int h, w;
	cin >> h >> w;
	vector<vector<char>> s(h, vector<char>(w));
	rep(i, h){
		rep(j, w){
			cin >> s[i][j];
		}
	}
	
	vector<vector<int>> hor(h, vector<int>(w, 0));
	vector<vector<int>> ver(h, vector<int>(w, 0));
	for(int i = 0; i < h; ++i){
		int count = 0;
		for(int j = 0; j < w; ++j){
			if(s[i][j] == '.'){
				count++;
				hor[i][j] = count;
			}
			else{
				count = 0;
			}
		}
	}
	
	for(int j = 0; j < w; ++j){
		int count = 0;
		for(int i = 0; i < h; ++i){
			if(s[i][j] == '.'){
				count++;
				ver[i][j] = count;
			}
			else{
				count = 0;
			}
		}
	}
	
	for(int i = 0; i < h; ++i){
		bool hold = false;
		int hold_v = 0;
		for(int j = w - 1; j >= 0; --j){
			if(hold){
				if(hor[i][j] == 0){
					hold = false;
				}
				else{
					hor[i][j] = hold_v;
				}
			}
			else{
				if(hor[i][j] != 0){
					hold = true;
					hold_v = hor[i][j];
				}
			}
		}
	}
	
	for(int j = 0; j < w; ++j){
		bool hold = false;
		int hold_v = 0;
		for(int i = h - 1; i >= 0; --i){
			if(hold){
				if(ver[i][j] == 0){
					hold = false;
				}
				else{
					ver[i][j] = hold_v;
				}
			}
			else{
				if(ver[i][j] != 0){
					hold = true;
					hold_v = ver[i][j];
				}
			}
		}
	}
	
	int ans = 0;
	for(int i = 0; i < h; ++i){
		for(int j = 0; j < w; ++j){
			ans = max(ans, hor[i][j] + ver[i][j] - 1);
		}
	}
	
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 35584
#include <stdio.h>

int main(void) {
	int R0, W0, C, R;
	while (scanf("%d%d%d%d", &R0, &W0, &C, &R) == 4 && (R0 | W0 | C | R) != 0) {
		int fusoku = R0 < C * W0 ? C * W0 - R0 : 0;
		printf("%d\n", (fusoku + R - 1) / R);
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

string s;
int x;

int ct;
char c;

int idx;

string now;

void num();
void read();

void num(){
    int n = 0;
    while(idx<s.size() && isdigit(s[idx])){
        n = n*10 + s[idx]-'0';
        ++idx;
    }

    if(s[idx]=='('){
        ++idx;
        int start = idx;

        rep(i,n){
            idx = start;
            read();
            if(c != '0') return;
        }

        assert(s[idx]==')');
        ++idx;
    }
    else{
        rep(i,n){
            now += s[idx];
            if(ct == x){
                c = s[idx];
                return;
            }
            ++ct;
        }
        ++idx;
    }
}

void read(){
    if(c != '0') return;
    if(idx >= s.size()) return;

    if(isdigit(s[idx])) num();
    if(isupper(s[idx])){
        now += s[idx];
        if(ct == x){
            c = s[idx];
            return;
        }

        // dbg(ct);
        ++ct;
        ++idx;
    }
    if(s[idx]==')') return;

    read();
}

int main(){
    while(cin >>s >>x,(s!="0")){
        c = '0';
        idx = 0;
        ct = 0;

        now = "";

        read();
        // dbg(now);
        cout << c << endl;
    }
    return 0;
}



Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vl = vector<ll>; using vvl = vector<vl>;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
const ll INF = 9223372036854775807;

int main() {
    ll n;cin >> n;
    string ans = "";
    while(n){
        n--;
        ans += 'a' + n%26;
        n /= 26;
    }
    reverse(ans.begin(),ans.end());
    cout << ans << endl;
}

Measured memory_bytes: 3600
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TriangularRelationship solver = new TriangularRelationship();
        solver.solve(1, in, out);
        out.close();
    }

    static class TriangularRelationship {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();

            long[] num = new long[k];
            for (int i = 1; i <= n; i++) {
                num[i % k]++;
            }

            long result = 0;
            for (int a = 0; a < k; a++) {
                int b = (k - a) % k;
                int c = (k - a) % k;
                if ((b + c) % k != 0) {
                    continue;
                }
                result += (num[a] * num[b] * num[c]);
            }
            out.print(result);

        }

    }
}



Measured memory_bytes: 37404
N, L =map(int,input().split())

N_list = list(range(L,L+N))

if L<=0 and L+N-1 >= 0:
    ans = sum(N_list)
if L > 0:
    ans = sum(N_list)-L
if L+N-1 < 0:
    ans = sum(N_list)-(L+N-1)

print(ans) 

Measured memory_bytes: 3060
<?php
// Nがハージャッド数ならばYes
// ハージャッド数：整数を十進法で表したときの各和で整数自体が割り切れる整数
$n = trim(fgets(STDIN));
$res = $n % sumEachDigit($n) === 0 ? 'Yes' : 'No';
print "$res\n";

function sumEachDigit(int $number)
{
    $sum = 0;
    while ($number !== 0) {
        $sum    += $number % 10;
        $number = intdiv($number, 10);
    }
    return $sum;
}


Measured memory_bytes: 4728