akhauriyash/Code-Regression huggingface dataset:
a,b = map(int,input().split())
c=[]
d=[]
for i in range(a):
    c.append(list(map(int,input().split())))
for j in range(b):
    d.append(list(map(int,input().split())))
#length = len(d[1][0])

ff=[]
for i in range(a):
    f=0
    for j in range(b):
       f += (int(c[i][j])*int(d[j][0]))
    ff.append(f)
    
for i in range(len(ff)):
    print(ff[i])


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

#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)

using namespace std;

typedef long long LL;

const int N = 65;

LL L, R;

int main(){
	scanf("%lld%lld", &L, &R);

	if(L == R){
		puts("1");
		return 0;
	}

	int x = 0;
	Forr(i, 60, 0) 
		if((L & (1ll << i)) ^ (R & (1ll << i))){
			x = i;
			For(j, i + 1, 60) if(L & (1ll << j)) L ^= 1ll << j, R ^= 1ll << j;
			break;
		}

	int y = -1;
	For(i, 0, x - 1) if(R & (1ll << i)) y = i;

	LL l = L, r = ((1ll << x) + (1ll << (y + 1))) - 1;
	LL l2 = (1ll << x) + L, r2 = (1ll << (x + 1)) - 1;

	if(l2 <= r) printf("%lld\n", r2 - l + 1);
	else printf("%lld\n", r2 - l2 + 1 + r - l + 1);
	return 0;
}

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

int main()
{
    int n = 0, m = 0;
    cin >> n >> m;

    // Nから二個取る: 和は偶数
    int pickFromN = (n * (n - 1)) / 2;
    // Mから二個取る: 和は偶数
    int pickFromM = (m * (m - 1)) / 2;

    // NとMから一個ずつ取る: 和は奇数。考えなくていい
    cout << pickFromN + pickFromM;

    return 0;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

using i64=int64_t;

void solve(){
    int n;
    string s;
    cin >> n >> s;
    vector<int> ans(n);
    rep(i,0,2){
        rep(j,0,2){
            ans[0]=i;
            ans[1]=j;
            rep(k,1,n-1){
                if(s[k]=='o') ans[k+1]=ans[k-1];
                if(s[k]=='x') ans[k+1]=1-ans[k-1];
                if(ans[k]==1) ans[k+1]=1-ans[k+1];
            }

            auto ok=[&](int k){
                bool ok_;
                if(s[k]=='o') ok_=ans[(k+1)%n]==ans[(k-1+n)%n];
                if(s[k]=='x') ok_=ans[(k+1)%n]!=ans[(k-1+n)%n];
                if(ans[k]==1) ok_=!ok_;
                return ok_;
            };
            if(ok(0) and ok(n-1)){         
                rep(k,0,n) cout << (ans[k]==0?'S':'W');
                cout << endl;
                return;
            }
        }
    }
    cout << -1 << endl;
}

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


Measured memory_bytes: 976
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=100010;
const ll mod=1e9+7;



int main(){
  int n,m;
  cin >> n>>m;
  if(n>m){swap(n,m);}
  string ans="";
  while(m>0){ans += (char)(n+'0'); m--;}
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define rep(i,a,b) for (int i = a; i < b; i++)
#define repn(i,a,b) for (int i = a; i >=b ;i--)
#define MOD 1000000007


int main(){
ios::sync_with_stdio(0);
cin.tie(0);
    ll n;cin>>n;
    ll arr[n];
    map<ll,ll> mp;
    rep(i,0,n){
        cin>>arr[i];
        mp[arr[i]]++;
    }
    ll sum=0;
    for(auto x: mp){
       sum+= x.second*(x.second-1)/2;
    }
    ll ans;
    rep(i,0,n){
        ans=sum-mp[arr[i]]+1;
        cout<<ans<<"\n";

    }
    
return 0;
}

Measured memory_bytes: 11136
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  int N;
  cin>>N;
  VS S(N);
  rep(i,N) cin>>S[i];
  set<string> X;
  rep(i,N) X.insert(S[i]);
  cout<<X.size()<<endl;
}


Measured memory_bytes: 25012
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;



int main(int argc, char* argv[])
{
    long a,b;
    scanf("%ld%ld", &a, &b);
    char str[20]={0};
    scanf("%s", str);
    long len=strlen(str);

    if(len==a+b+1) {
        long i;
        for(i=0; i<len; i++) {
            if(i==a) {
                if(str[i]!='-') {
                    printf("No\n"); return 0;
                }
            }
            else {
                if(str[i]<'0' || str[i]>'9') {
                    printf("No\n"); return 0;
                }
            }
        }
        printf("Yes\n"); return 0;
    }
    printf("No\n"); return 0;

    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n,m,p;
  while(cin >>n>>m>>p,n||m||p){
    int all = 0;
    vector<int> card;
    for(int i=0,a; i<n; i++){
      cin >>a;
      all+=a;
      card.push_back(a);
    }
    all = all*(100-p);
    if(card[m-1] == 0) cout <<"0"<<endl;
    else cout <<all/card[m-1]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1220
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A: Product
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  if ((a * b) & 1) puts("Odd");
  else puts("Even");

  return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

void solve()
{
    int64_t N;
    std::cin >> N;
    int64_t AC = 0, WA = 0, TLE = 0, RE = 0;

    for (int64_t i = 0; i < N; i++)
    {
        std::string status;
        std::cin >> status;
        if (status == "AC") AC++;
        if (status == "WA") WA++;
        if (status == "TLE") TLE++;
        if (status == "RE") RE++;
    }

    std::cout << "AC x " << AC << std::endl;
    std::cout << "WA x " << WA << std::endl;
    std::cout << "TLE x " << TLE << std::endl;
    std::cout << "RE x " << RE << std::endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    solve();
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#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);
 
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 vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  char a,b;cin>>a>>b;
  char ans=b;
  if(a=='D'){
      if(b=='H')ans='D';
      else ans='H';
  }
  
  cout(ans);
  
  return 0;
}

Measured memory_bytes: 125568
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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;
}

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int X, Y;
  cin >> X >> Y;

  if (X % Y == 0) {
    cout << -1 << '\n';
  } else {
    cout << (X * Y - X) << endl;
  }
}

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

int main(){
  int n;
  cin >> n;
  pair<pair<string, int>, int> p[n]; 
  for (int i = 0; i < n; i++){
    string city;
    int score;
    cin >> city >> score;
    // cityは辞書順, scoreは降順-> -1*scoreに変換
    p[i] = make_pair(make_pair(city, -score), i+1);
  }
  sort(p, p+n);
  for (int i = 0; i < n; i++)  cout << p[i].second << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())

dp = [[10**10 for _ in range(2**n)] for j in range(m)]
dp[0][0] = 0
a, b = map(int, input().split())
c = list(map(int, input().split()))
idx = 0
for cc in c:
  idx += 2**(cc-1)
for j in range(1, 2**n):
  if ~idx & j == 0:
    dp[0][j] = a

for i in range(1, m):
  a, b = map(int, input().split())
  c = list(map(int, input().split()))
  idx = 0
  for cc in c:
    idx += 2**(cc-1)
  for j in range(2**n):
    dp[i][j] = min(dp[i-1][j], dp[i-1][(j|idx)^idx]+a)

if dp[-1][-1] != 10**10:
  print(dp[-1][-1])
else:
  print(-1)

Measured memory_bytes: 81756
num_list = list(map(int, input().split()))
num = num_list[0]
distance = num_list[1]
res = 0

for i in range(num):
    nmb_list = list(map(int, input().split()))
    if(nmb_list[0]*nmb_list[0]+nmb_list[1]*nmb_list[1] <= distance*distance):
        res += 1
        
print(res)

Measured memory_bytes: 9132
#include<cstdio>
#define N 200005
int n, a[N];
int s;
int main(){
  scanf("%d", &n);
  for(int i=1;i<=n;++i){
    scanf("%d", &a[i]);
    s ^= a[i];
  }
  for(int i=1;i<=n;++i){
    printf("%d ", s^a[i]);
  }
}


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

int main(){
  ll n;
  cin >> n;
  vector<ll> a(n+10);
  rep(i,n) cin >> a[i];
  ll ans = 0;
  rep(i,n-1){
    if(a[i] < a[i+1]){
      --a[i+1];
      ++ans;
    }
    else if(a[i] == a[i+1]){
      ++ans;
    }
  }
  if(ans == n-1) puts("Yes");
  else puts("No");
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
const long double eps = 1e-10;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int n;
vector<VI> a;
vector<VL> memo;
ll solve(int bit, int k) {
    if (k == n)return 1LL;
    if (memo[bit][k] != -1)return memo[bit][k];

    ll ret = 0;
    FOR(i, 0, n) {
        if (bit & (1 << i))continue;
        if (a[k][i] == 0)continue;
        (ret += solve(bit | (1 << i), k + 1)) %= mod;
    }

    return memo[bit][k] = ret;
}

int main() {
    init();

    cin >> n;
    a = vec<int>(n, n); cin >> a;
    memo = defvec<ll>(-1, 1 << n, n);
    cout << solve(0, 0) << "\n";
}


Measured memory_bytes: 409856
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
#define mp make_pair
#define pb push_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pii pair<int, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stout);
//head

int main() {
	fio;
	int n;
	cin >> n;
	if(n >= 1000) printf("ABD\n");
	else printf("ABC\n");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <iomanip>
using namespace std;

typedef long long ll;

ll euclidean_gcd(ll a, ll b)
{
    if(a<b) swap(a, b);
    ll r;
    while((r=a%b)!=0){
        a=b;
        b=r;
    }

    return b;
}

int main()
{
    ll N,M;
    cin >> N >> M;
    string S,T;
    cin >> S >> T;
    ll gcd=euclidean_gcd(N, M);
    bool flag=true;
    for(int i=0; i<N; i++){
        if(i*M%N==0){
            int j=i*M/N;
            if(S[i]!=T[j]) flag=false;
        }
    }
    if(flag) cout << N*M/gcd << endl;
    else cout << -1 << endl;



    return 0;
}


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

int main(){
  char c;
  cin >> c;
  if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}

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

int main() {
  int64_t K,b;
  int64_t a;
  cin>>K;
  a=7LL;
  b=0;
  for(int64_t i=0; i<100000000; i++){
    if(a%K==0){
      b=i+1;
      break;
    }
    else
      a=a%K*10+7;
  }
  if(b!=0)
    cout<<b<<endl;
  else
    cout<<"-1"<<endl;
}

Measured memory_bytes: 3600
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        final int K = sc.nextInt();
        Queue<Long> queue = new ArrayDeque<>();
        for(long i=1;i<10;i++){
            queue.add(i);
        }
        long x = 0;
        for(int i=0;i<K;i++){
            x = queue.poll();
            if(x % 10 != 0){
                queue.add(x * 10 + x % 10 - 1);
            }
            queue.add(x * 10 + x % 10);
            if(x % 10 != 9){
                queue.add(x * 10 + x % 10 + 1);
            }
        }
        System.out.println(x);
    }
}


Measured memory_bytes: 35932
EPS = 1e-9
class Point
  attr_reader :x, :y, :z
  def initialize(x, y, z)
    @x, @y, @z = [x, y, z].map(&:to_f)
  end
  def -(p)
    Point.new(@x - p.x, @y - p.y, @z - p.z)
  end
  def dot(p)
    @x * p.x + @y * p.y + @z * p.z
  end
  def cross(p)
    Point.new(@y * p.z - @z * p.y, @z * p.x - @x * p.z, @x * p.y - @y * p.x)
  end
  def ==(p)
    (@x - p.x).abs < EPS && (@y - p.y).abs < EPS && (@z - p.z).abs < EPS
  end
  def abs
    Math::sqrt(@x * @x + @y * @y + @z * @z)
  end
  def normalize
    Point.new(@x / abs, @y / abs, @z / abs)
  end
end
def parallel?(a, b, c, d)
  (b - a).normalize == (d - c).normalize || (b - a).normalize == (c - d).normalize
end

def blocked
  d, e, a, b, c = 5.times.map{Point.new(*gets.split)}
  abde = (e - d).dot((b - a).cross(d - a)).abs
  bcde = (e - d).dot((c - b).cross(d - b)).abs
  cade = (e - d).dot((a - c).cross(d - c)).abs
  abcd = (d - c).dot((b - a).cross(c - a)).abs
  abce = (e - c).dot((b - a).cross(c - a)).abs
  return false if parallel?(a, b, d, e) || parallel?(b, c, d, e) || parallel?(c, a, d, e)
  abde + bcde + cade == abcd + abce
end

puts (blocked ? "MISS" : "HIT")

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

int main() {
	char b;
	cin >> b;
	if(b=='A'){
	cout << 'T';
	}
	else if(b=='T'){
	cout << 'A';
	}
	else if(b=='C'){
	cout << 'G';
	}
	else if(b=='G'){
	cout << 'C';
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a,b,c,d;
 
int main() {
  cin>>a>>b>>c>>d;
  if(a+b==c+d){
    cout << "Balanced" << endl;
  } else if(a+b>c+d){
    cout << "Left" << endl;
  }else if(a+b<c+d){
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
using System;

namespace Dice
{
    class Program
    {
        private static bool Eql(string[] x, string[] y)
        {
            var g = true;
            for (int o = 0; o < x.Length; o++)
              if (x[o] != y[o]) g = false;
            return g;
        }

        private static bool Check(string[] x, string[] y)
        {
            if (Eql(x, y)) return true;
            for (int p = 0; p < 2; p++)
            {
                for(int q = 0; q < 4; q++)
                {
                    var a = x[0]; var b = x[1]; var c = x[2];
                    var d = x[3]; var e = x[4]; var f = x[5];
                    x = p == 0 ? new string[] { e, a, c, d, f, b }:
                                 new string[] { d, b, a, f, e, c };
                    if (Eql(x, y)) return true;
                    var h = x;
                    for(int r = 0; r < 4; r++)
                    {
                        var i = h[0]; var j = h[1]; var k = h[2];
                        var l = h[3]; var m = h[4]; var n = h[5];
                        h = new string[] { i, k, m, j, l, n };
                        if (Eql(h, y)) return true;
                    }
                }
            }
            return false;
        }

        static void Main()
        {
            int s = int.Parse(Console.ReadLine());
            var t = new string[s][];
            for(int u = 0; u < s; u++)
                t[u] = Console.ReadLine().Split(' ');
            for (int v = 0; v < s; v++)
                for (int w = v + 1; w < s; w++)
                    if (Check(t[v], t[w]))
                    {
                        Console.WriteLine("No");
                        return;
                    }
            Console.WriteLine("Yes");
        }
    }
}

Measured memory_bytes: 9368
package main
  
import (
    "fmt"
)

const mod = 1000000007

func main() {
    var n int
    var s []byte
    fmt.Scan(&n)
    fmt.Scan(&s)

    cnt := make([]int, 26)
    for _, b := range s {
        idx := b - 97
        cnt[idx]++
    }
    sum := 1
    for _, c := range cnt {
        sum *= c + 1
        sum %= mod
    }
    sum -= 1
    if sum < 0 {
        sum += mod
    }
    fmt.Println(sum)
}


Measured memory_bytes: 1408
S = $stdin.gets.chomp
X,Y = $stdin.gets.chomp.split(" ").map{ |a| a.to_i }

mx = []
my = []
S.split(/T/).map{ |s| s.length }.each_with_index{ |f,i|
  #$stderr.puts f
  if i % 2 == 0
    mx << f
  else
    my << f
  end
}

#$stderr.puts "#{mx}"
#$stderr.puts "#{my}"

def verdict(t, ops)
  #$stderr.puts "target: #{t}"
  #$stderr.puts "ops: #{ops}"
  n = ops.inject(:+) || 0
  return false if t.abs > n
  m = ops.size
  dpv = (0...(2*n+1)).map{ [-1,-1] }
  dpv[n][0] = 0
  #$stderr.puts "#{dpv.map{ |a| a[0] }}"
  ops.each_with_index { |t,i|
    ii = i%2; iii = (i+1)%2; ni = i+1
    (-n..n).each{ |k|
      j = k+n
      next if dpv[j][ii] < i
      if j+t < dpv.size
        dpv[j+t][iii] = ni
      end
      if 0 <= j-t
        dpv[j-t][iii] = ni
      end
    }
    #$stderr.puts "#{dpv.map{ |a| a[(i+1)%2] }}"
  }
  #$stderr.puts "dpv[#{t+n}][#{m%2}] == #{ops.size} -> #{dpv[t+n][m%2] == ops.size}"
  dpv[t+n][m%2] == m
end

puts (verdict(X-(mx[0] || 0), mx[1..-1] || []) && verdict(Y, my)) ? "Yes" : "No"



Measured memory_bytes: 2556
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    int b[3] {0};
    for(int i = 0; i < n; i++) b[s[i] - 'a']++;
    sort(b, b + 3);
    if(b[2] - b[0] <= 1) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define tll tuple<ll, ll, ll>
#define all(c) c.begin(),c.end()

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
 
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;

//fill(score, score+202020, 0);

#define NN 3010
#define MM 5010

bool is_reach[NN];
bool used[NN];
vl G[NN];
ll D[NN];
struct edge { ll from, to, cost; };
vector<edge> E(MM);

void dfs(int now) {
  is_reach[now] = true;
  used[now] = true;
  for(int i=0; i<G[now].size();i++){
    ll ch = G[now][i];
    if (used[ch]) {
      continue;
    }
    else {
      dfs(ch);
    }
  }
}

int main(){
  ll n, m, p;
  cin >> n >> m >> p;
  ll a, b, c;
  for (int i=0;i<m;i++){
    cin >> a >> b >> c;
    E[i].from = a-1;
    E[i].to = b-1;
    E[i].cost = -(c-p);
    G[b-1].push_back(a-1);
  }

  for(int i=0;i<NN;i++) is_reach[i] = false;
  for(int i=0;i<NN;i++) used[i] = false;
  dfs(n-1);

  fill(D, D+n, INF);
  D[0] = 0;
  ll count = 0;
  while(true){
    bool update = false;
    for (int i=0;i<m;i++){
      if (!is_reach[E[i].to]) continue;
      if (D[E[i].from] != INF && D[E[i].to] > D[E[i].from] + E[i].cost){
        D[E[i].to] = D[E[i].from] + E[i].cost;
        update = true;
      }
    }
    if (!update) break;
    count += 1;
    if (count >= n){
      cout << -1 << endl;
      exit(0);
    }
  }

  cout << max(0LL, -D[n-1]) << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#include<chrono>
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define MAX(a,b) (a>b)?a:b
#define MIN(a,b) (a>b)?b:a
#define MIN3(a,b,c)         MIN(a,MIN(b,c))
#define MAX3(a,b,c)         MAX(a,MAX(b,c))
#define MIN4(a,b,c,d)       MIN(a,MIN(b,MIN(c,d)))
#define MAX4(a,b,c,d)       MAX(a,MAX(b,MAX(c,d)))
#define MAX5(a,b,c,d,e)     MAX(MAX3(a,b,c),MAX(d,e))
#define MIN5(a,b,c,d,e)     MIN(MIN3(a,b,c),MIN(d,e))
typedef pair<int, int>  pii;
typedef pair<ll, ll>  pl;
typedef vector<int>   vi;
typedef vector<ll>    vl;
typedef vector<pii>   vpii;
typedef vector<pl>    vpl;
typedef vector<vi>    vvi;
typedef vector<vl>    vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void DFS(int n);
bool isprime(ll n);
ll gcd(ll a,ll b);
void rstgraph(int n);

const int mod = 1'000'000'007;
const int N = 3e5, M = N;
//=======================================================================================
vector<vector<int>> list;
vi g[N];
int vis[N];
int nodes=0;
void iluzn() {
 int n;
 cin>>n;
 int k=n/1000;
 if(n%1000==0)
  cout<<0;
else
 cout<<1000*(k+1)-n;
 }

 
  
int main() {
  #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t = 1;
    // cin >> t;
    while(t--) {
      iluzn();
      }
    return 0;
}
int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}
bool isprime(ll n){
    if(n<=1)
        return false;
    if(n==2)
        return true;
    if(n%2==0)
        return false;
    ll rt = sqrt(n);
    for(ll i=3;i<rt;i+=2){
        if(n%i==0)
            return false;
    }
    return true;
}
ll gcd(ll a,ll b){
    if(a%b){
        return gcd(b,a%b);
    }
    else{
        return b;
    }
}
void ipgraph(int m){
  int u, v;
  while(m--){
    cin>>u>>v;
    g[u].pb(v);
    g[v].pb(u);
  }
}

void DFS(int n)
{  ++nodes;
    vis[n] = 1;
    for(vector<int>::iterator i = g[n].begin(); i != g[n].end() ; i++)
    {
        if(!vis[*i])
            DFS(*i);
    }
}
void rstgraph(int n){
  int i;
  fo(i,n+1){
    g[i].clear();
    vis[i]=0;
  }
  nodes=0;
}

Measured memory_bytes: 10656
#include <cstdio>
#include <cstring>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
//#include <bits/stdc++.h>
#define pb push_back
#define FOR(x,st,n) for(int x = (st); x < (n); ++ x)

using namespace std;


typedef long long unsigned ll;
typedef pair<int,int> P;
//typedef vector<P> vp;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main(){


    ll n,m,ret=0;
    cin>>n;
    
    ll i;
    for(i=1;;i++){
        if( ((i+1 )*i) / 2  < n) continue;
        else break;
    }
    

    cout<<i<<endl;


    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int n,A[50];
int solve(int i,int m){
  if(m==0)return 1;
  if(i>=n)return 0;
  int res = solve(i+1,m) || solve(i+1,m-A[i]);
  return res;
}
int main(){
  int q,M,i;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&M);
    if(solve(0,M))printf("yes\n");
    else printf("no\n");
  }
  return 0;
}


Measured memory_bytes: 2108
N = int(input())
Hn = list(map(int,input().split()))
check = True
kijyun = Hn[0]
for i in range(1,N):
    if Hn[i]-Hn[i-1]<-1:
        check=False
        break
    elif Hn[i]-kijyun<-1:
        check=False
        break
    kijyun = max(kijyun,Hn[i])
if check:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 15020
#include <bits/stdc++.h>
#define FOR(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define FORUL(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define FORULE(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define FOREACH(it, X) for(__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#if defined(_MSC_VER) || __cplusplus > 199711L
#define AUTOVAR(newvar,v) auto newvar = (v)
#else
#define AUTOVAR(newvar,v) __typeof(newvar) r = (v)
#endif
#define PB(x) push_back(x)
#define MP(x,y) make_pair((x),(y))
#define MEMSET(m,v) memset(m,v,sizeof(m))

typedef long long				 ll;
typedef unsigned long long		ull;

#define DEBUG 1

#if DEBUG
#define DOUT cout<<"["<<__LINE__<<"]:"
#else
#define DOUT 0 && cout
#endif

using namespace std;

int N;
int v[55];

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false);
	cin >> N;
	FOR(n,N) {
		cin >> v[n];
	}
	sort(&v[0], &v[N]);
	// FOR(n,N) {
	// 	cout << v[n];
	// }
	double sum=v[0];
	FOR(n,N-1) {
		sum = (sum + (double)v[n+1])/(double)2.0;
	}
	cout << std::setprecision(10);
	cout << sum << endl;

	return 0;
}




Measured memory_bytes: 256
# inlist = input().split()
# a = (int(x) for x in inlist)

a = input()
a = int(a)
h = int(a/60/60)
m = int((a-60*60*h)/60)
s = a %60

time1 = str(h) +":"+str(m)+":" +str(s)
print(time1)



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

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

   if(n * 10000 < y){
      printf("%d %d %d\n",-1,-1,-1);
      return 0;
   }

   rep(i,n + 1) for(int j = 0; j <= n -i; j++){
     int sum = y - i* 10000 - j * 5000;
     int rem = n - i - j;
     sum -= rem * 1000;
     if(sum == 0){
         printf("%d %d %d\n",i,j,rem);
         return 0;
     }
   }
   printf("%d %d %d\n",-1,-1,-1);
   return 0;

}

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

int main(void)
{
    string s;
    cin >> s;
    int maxs = -1;
    for (int i = 0; i < s.length(); i++){
        int cnt = 0;
        for (int j = i; j < s.length(); j++){
            if(s.at(j)=='A'||s.at(j)=='C'||s.at(j)=='G'||s.at(j)=='T')
                cnt++;
            else
                break;
        }
        if (cnt > maxs)
            maxs = cnt;
    }
    cout << maxs << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const ll MOD = 1e9 + 7;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

bool f(vector<string> a, string s){
    rep(i,a.size()){
        if(a[i] == s) return true;
    }
    return false;
}
int main() {

    string s; cin >> s;
    int k; cin >> k;
    vector<string> v(k,"}");

    rep(i,s.length()){
        for(int j = 1; j <= k; j ++){
            if(i+j <= s.length()){
                if(!f(v,s.substr(i,j)) && v[k-1] > s.substr(i,j)){
                    v[k-1] = s.substr(i,j);
                    sort(v.begin(),v.end());
                }
            }
        }
    }
    cout << v[k-1] << endl;

}


Measured memory_bytes: 3588
n = int(input())
f = list(map(int,input().split()))
Garden = [0] * len(f)
Count = 0
cflag = False

while(1):
    for index,item in enumerate(f):
        if item != Garden[index]:
            Garden[index] += 1
            cflag = True
        else:
            if cflag == True:
                Count += 1
            cflag = False
            
    if cflag == True:
        Count += 1
        cflag = False
        
    if f == Garden:
        break

print(Count,end="")

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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n;
  cin >> n;
  vector<int32> l(n);
  REP(i,n)cin >> l[i];
  sort(all(l));
  int32 ans = 0;
  REP(i,n)REP(j,i)REP(k,j){
    if(l[i] != l[j] && l[j] != l[k] && l[i] < l[j] + l[k]){
      ++ans;
      // cout << l[i] << " " << l[j] << " " << l[k] << endl;
    }
  }
  ANS(ans);
  return 0;
}

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

ll solve() {
    ll N, M;
    cin >> N >> M;
    vector<ll> A(M);
    vector<int> odd;
    for ( int i = 0; i < M; i++ ) {
        cin >> A[i];
        if ( A[i] & 1 ) odd.push_back(i);
    }
    if ( odd.size() > 2 ) return -1;
    int o1 = -1, o2 = -1;
    if ( odd.size() > 0 ) o1 = odd[0];
    if ( odd.size() > 1 ) o2 = odd[1];
    vector<ll> na, nb;
    if ( o1 != -1 ) {
        na.push_back(A[o1]);
    }
    for ( int i = 0; i < M; i++ ) {
        if ( i == o1 || i == o2 ) continue;
        na.push_back(A[i]);
    }
    if ( o2 != -1 ) {
        na.push_back(A[o2]);
    }
    if ( na[0] != 1 ) {
        nb.push_back(na[0]-1);
    }
    for ( int i = 1; i < na.size()-1; i++ ) {
        nb.push_back(na[i]);
    }
    if ( o2 != -1 ) {
        nb.push_back(na[na.size()-1] + 1);
    } else {
        if ( na.size() > 1 ) {
            nb.push_back(na[na.size()-1]);
        }
        nb.push_back(1);
    }

    for ( int i = 0; i < na.size(); i++ ) {
        cout << (i != 0 ? " " : "") << na[i];
    }
    cout << "\n";
    cout << nb.size() << "\n";
    for ( int i = 0; i < nb.size(); i++ ) {
        cout << (i != 0 ? " " : "") << nb[i];
    }
    cout << "\n";
    return 0;
}

int main() {
    auto ans = solve();
    if ( ans < 0 ) {
        cout << "Impossible" << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
use std::cmp;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.read();
    let k: usize = sc.read();

    let ab: Vec<(usize, usize)> = (0..n).map(|_| (sc.read(), sc.read())).collect();

    let mut ans = 0;
    for pos in 0..32 {
        if (1 << pos) & k == 0 {
            continue;
        }
        let m = (k >> (pos + 1)) << (pos + 1);
        let t = (1 << pos) - 1;
        let k = m + t;
        assert_eq!((1 << pos) & k, 0);

        let mut sum = 0;
        for &(a, b) in &ab {
            if (k | a) <= k {
                sum += b;
            }
        }

        ans = cmp::max(ans, sum);
    }

    let mut sum = 0;
    for &(a, b) in &ab {
        if (k | a) <= k {
            sum += b;
        }
    }
    ans = cmp::max(ans, sum);

    println!("{}", ans);
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner {
            ptr: 0,
            length: 0,
            buf: vec![0; 1024],
            small_cache: vec![0; 1024],
        }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool {
        b == b'\n' || b == b'\r' || b == b'\t' || b == b' '
    }

    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)])
                    .parse()
                    .unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}


Measured memory_bytes: 6396
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <ios>
#include <iomanip>
#include <cstdlib>
using namespace std;
int main(void){
  long r,d,x;
  cin >> r >> d >> x;
  
  long a = x;
  for(int i=0;i<10;i++){
    a = r * a - d;
    cout << a << endl;
  }
  
  return 0;
}

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

struct Card { char suit, value;};

void bubble(struct Card A[], int N){
    for (int i = 0; i < N; i++){
        for (int j = N-1; j >= i+1; j--){
            if (A[j].value < A[j-1].value){
                Card t = A[j]; A[j] = A[j-1]; A[j-1] = t;
            }
        }
    }
}

void Selection(struct Card A[], int N){
    for (int i = 0; i < N; i++){
        int minj = i;
        for (int j = i; j < N; j++){
            if (A[j].value < A[minj].value) minj = j;
        }
        Card t = A[i]; A[i] = A[minj]; A[minj] = t;
    }
}

void print(struct Card A[], int N){
    for (int i = 0; i < N; i++){
        if (i > 0) cout << " ";
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}

bool isStable(struct Card c1[], struct Card c2[], int N){
    for (int i = 0; i < N; i++){
        if (c1[i].suit != c2[i].suit) return false;
    }
    return true;
}

int main(){
    Card c1[100], c2[100];
    int N;
    char ch;

    cin >> N;
    for (int i = 0; i < N; i++){
        cin >> c1[i].suit >> c1[i].value;
    }
    for (int i = 0; i < N; i++){
        c2[i] = c1[i];
    }

    bubble(c1, N);
    Selection(c2, N);
    print(c1, N);
    cout << "Stable" << endl;
    print(c2, N);
    if (isStable(c1, c2, N)){
        cout << "Stable" << endl;
    }else{
        cout << "Not stable" << endl;
    }

    return 0;
}


Measured memory_bytes: 3100
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		int c = a * b;
		
		if(c % 2 == 0) System.out.println("Even");
		else System.out.println("Odd");
	}
}

Measured memory_bytes: 21716
#include<iostream>
using namespace std;
int n,m=0,a[40],b[40],c[41];
void solve(int l,int r){
  if(l>r)return;
  int x=a[m++];
  solve(l,c[x]-1);
  solve(c[x]+1,r);
  cout<<x<<(x==a[0]?"\n":" ");
}
int main(){
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<n;i++)cin>>b[i],c[b[i]]=i;
  solve(0,n-1);
  return 0;
}

Measured memory_bytes: 1164
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import fractions
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

from itertools import permutations
from math import factorial, hypot

N, M = getNM()
total = 1900 * M + 100 * (N - M)
print(total * (2 ** M))

Measured memory_bytes: 63980
import sys
from heapq import heappush, heappushpop

Q = int(input())
high = []
low = []
sum_dh, sum_dl = 0, 0
sum_b = 0
MIN_X = -(10 ** 9)
buf = []

for qi, line in enumerate(sys.stdin):
    q = list(map(int, line.split()))
    if len(q) == 1:
        x = -low[0]
        dx = x - MIN_X
        ans_l = dx * len(low) - sum_dl
        ans_h = sum_dh - dx * len(high)
        buf.append('{} {}\n'.format(x, ans_l + ans_h + sum_b))
    else:
        _, a, b = q
        da = a - MIN_X
        sum_b += b
        if len(low) == len(high):
            h = heappushpop(high, a)
            heappush(low, -h)
            dh = h - MIN_X
            sum_dh += da - dh
            sum_dl += dh
        else:
            l = -heappushpop(low, -a)
            heappush(high, l)
            dl = l - MIN_X
            sum_dl += da - dl
            sum_dh += dl

print(''.join(buf))


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

// --------------------------------------------------------------------------------
#define fastio	ios_base::sync_with_stio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long 
#define mset(arr,val) memset(arr,val,sizeof(arr))
#define deb(name,value) cout <<"->>  "<<name<< "= " <<value<<" "
#define frepi(a,b,k) for(int i=a;i<=b;i+=k)
#define frepj(a,b,k) for(int j=a;j<=b;j+=k)
// --------------------------------------------------------------------------------


void solve_main()
{
    int n,m;cin>>n>>m;
    ll ans = 0;
    frepi(1,m,1)
    {
    	int x;cin>>x;
    	ans+=x;
    }
    if(ans>n)
    	cout<<"-1\n";
    else
    	cout<<n-ans<<"\n";
}

int main()
{
	#ifndef ONLINE_JUDGE
    	freopen("/home/suryakant/input.txt","r",stdin);
        freopen("/home/suryakant/output.txt","w",stdout);
    #endif
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve_main();
    }
    
}

Measured memory_bytes: 3628
main(p,q,l){for(;~scanf("%d%d",&p,&q);){int r[1000000]={l=1};for(;!r[p%=q];putchar(p/q+48))r[p]=l++,p*=10;for(puts("");p&&l;)putchar(--l?--r[p]>0?32:94:10);}}

Measured memory_bytes: 4288
#include <bits/stdc++.h>
using namespace std;
int h, w, ans=0;
int c[10][10];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> h >> w;
    for (int i=0; i<=9; i++)
        for (int j=0; j<=9; j++)
            cin >> c[i][j];
    for (int i=0; i<=9; i++)
        for (int j=0; j<=9; j++)
            for (int k=0; k<=9; k++)
                if (c[j][i]+c[i][k] < c[j][k])
                    c[j][k] = c[j][i]+c[i][k];
    for (int i=0; i<h; i++)
        for (int j=0; j<w; j++) {
            int t; cin >> t;
            if (t != -1)
                ans += c[t][1];
        }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>

typedef long long ll;
using namespace std;

int main()
{
    string S, T;
    int s[26]={0}, t[26]={0};
    cin >> S >> T;

    for(int i=0; i<S.length(); i++){
        s[S[i]-'a']++;
        t[T[i]-'a']++;
    }
    sort(s, s+26);
    sort(t, t+26);

    for(int i=0; i<26; i++){
        if(s[i] != t[i]){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 776
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]

ans = 0
for i in range(n):
    if a[i] <= b[i]:
        if a[i]+a[i+1] > b[i]:
            all_enemy = a[i] + a[i + 1]
            ans += b[i]
            a[i+1] = a[i]+a[i+1] - b[i]
        else:
            all_enemy = a[i] + a[i + 1]
            ans += all_enemy
            a[i+1] = 0
    else:
        ans += b[i]

print(ans)

Measured memory_bytes: 18624
#include<cstdio>
#include<algorithm>
int main(){
    int n,l[100];
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",&l[i]);
    std::sort(l,l+n);
    for(int i=1;i<n-1;i++)l[0]+=l[i];
    if(l[0]>l[n-1])printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 128
import math

A, B, H, M = map(int, input().split())

dh = ((((60 * H) + M) / 720) * 360 - 90) * -1
dm = ((6 * M) - 90) * -1
h = math.radians(dh)
m = math.radians(dm)

ans = ((A * math.sin(h) - B * math.sin(m)) ** 2 + (A * math.cos(h) - B * math.cos(m)) ** 2) ** 0.5

print(ans)

Measured memory_bytes: 9588
import java.io.*;
import java.util.PriorityQueue;
import java.util.Comparator;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] line = br.readLine().split(" ");
        int x = Integer.parseInt(line[0]);
        int y = Integer.parseInt(line[1]);
        int a = Integer.parseInt(line[2]);
        int b = Integer.parseInt(line[3]);
        int c = Integer.parseInt(line[4]);
        PriorityQueue<Integer> p = new PriorityQueue<Integer>(a);
        PriorityQueue<Integer> q = new PriorityQueue<Integer>(b);
        PriorityQueue<Integer> r = new PriorityQueue<Integer>(c, (v1, v2)->v2-v1);
        line = br.readLine().split(" ");
        for(int i = 0; i < a; i++)  p.add(Integer.parseInt(line[i]));
        line = br.readLine().split(" ");
        for(int i = 0; i < b; i++)  q.add(Integer.parseInt(line[i]));
        line = br.readLine().split(" ");
        for(int i = 0; i < c; i++)  r.add(Integer.parseInt(line[i]));
        while(p.size() > x) p.poll();
        while(q.size() > y) q.poll();
        while(!r.isEmpty() && (p.peek() < r.peek() || q.peek() < r.peek())){
            if(p.peek() < q.peek()){
                p.poll();
                p.add(r.poll());
            }else{
                q.poll();
                q.add(r.poll());
            }
        }
        long ans = 0;
        for(int val : p)    ans += val;
        for(int val : q)    ans += val;
        System.out.println(ans);
    }
}


Measured memory_bytes: 66492