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

typedef long long ll;
typedef int64_t i6;
typedef std::vector<std::vector<int64_t> > Graph;

#define rep(i, n) for (int64_t i = 0; i < n; ++i)
#define rep2(i, n) for (int64_t i = 1; i <= n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))
#define Push_back(p, a, b) (p).push_back( make_pair( (a), (b) ) )

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;  } return 0;  }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;  } return 0;  }
template<typename V,typename T> bool find_num(V v, T num) { if ( find(ALL(v), num) == v.end() ) { return false; } return true; }

// π M_PI
// deg = rad*180/M_PI

vector<pair<int64_t, int64_t> > prime_factorize(int64_t  N) {
    vector<pair<int64_t, int64_t> > res;
    for (int64_t a = 2; a * a <= N; ++a) {
        if (N%a != 0) continue;
        int64_t ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        // res.push_back({a, ex});
        Push_back(res, a, ex);
    }

    // 最後に残った数について
    if (N != 1) Push_back(res, N, 1);
    return res;
}

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

    /*
    std::vector<int64_t> v(100);
    v[0] = 3;
    for (int64_t i = 2; i <= v.size(); ++i) {
        v[i-1] = v[i-2]+i+1;
    }*/
    // rep(i, v.size()) cout << i << " " << v[i] << endl;


    int64_t ans = 0;
    vector<pair<int64_t, int64_t> > res = prime_factorize(n);
    rep(i, res.size()) {
        int64_t num = res[i].second;
        if ( num <= 2 ) {
            ans++;
            continue;
        }
        int64_t j = 1;
        while (1) {
            if ( num > 2*j ) {
                num -= j;
                ans++;
                ++j;
            } else {
                break;
            }
        }
        ans++;
        /*
        int64_t num = 0;
        rep(j, v.size()) {
            if ( res[i].second == v[j] ) {
                num = 1;
                ans += j+2;
                break;
            }
            if ( res[i].second < v[j] ) break;
        }
        if (!num) ans++;*/
    }
    cout << ans << endl;
    ///////////////////////////////////
    /*
    vector<pair<int64_t, int64_t> > res = prime_factorize(n);
    // cout << n << ":";
    rep(i, res.size()) {
        /*
        rep(j, res[i].second) {
            cout << " " << res[i].first;
        }*//*
        cout << res[i].first << "^" << res[i].second << endl;
    }
    cout << endl;*/
    return 0;
}


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

const int N=3005;
const int mod=998244353;
int n,s,a[N],dp[N][N];

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>n>>s;
    for(int i=1;i<=n;i++) cin>>a[i];
    int res=0;
    for(int i=1;i<=n;i++)
    {
        dp[i][a[i]]=i;
        for(int j=0;j<=s;j++)
        {
            dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
            if(j>=a[i]) dp[i][j]=(dp[i][j]+dp[i-1][j-a[i]])%mod;
        }
        res=(res+dp[i][s]*(n-i+1))%mod;
        dp[i][s]=0;
    }
    cout<<res;
}


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

template<typename T>
istream& operator >> (istream& istr, vector<T>& v){
    for(T& x: v) istr >> x;
    return istr;
}

template<typename T, typename U>
istream& operator >> (istream& istr, pair<T,U>& p){
    istr >> p.first >> p.second;
    return istr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<T>& v){
    if(!v.empty()){
        ostr << v.front();
        for(auto itr = ++v.begin(); itr != v.end(); itr++)
            // ostr << *itr;
            ostr << " " << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, pair<T,U>& p){
    // ostr << p.first << p.second;
    // ostr << p.first << ", " << p.second;
    ostr << "(" << p.first << ", " << p.second << ")";
    return ostr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<vector<T>>& vv){
    if(!vv.empty()){
        ostr << vv.front();
        for(auto itr = ++vv.begin(); itr != vv.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, vector<pair<T,U>>& vp){
    if(!vp.empty()){
        ostr << vp.front();
        for(auto itr = ++vp.begin(); itr != vp.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

typedef long long ll;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<double> vd;
// vll v(n); v[i]=x;
typedef vector<vll> vvll;
typedef vector<vc> vvc;
typedef vector<vd> vvd;
// vvll v(m,vll(n)); v[i][j]=x;
typedef pair<ll,ll> pll;
typedef pair<double,double> pd;
typedef vector<pll> vpll;
typedef vector<pd> vpd;
// vpll v(n); v[i]=make_pair(x,y); v[i].first/second;
// v.front() : v[0]
// v.back()  : v[v.size()-1]

#define PI 3.1415926535897932
#define EPS 1e-12
#define INF ((ll)1e+12)
#define REP(i,n) for(ll i=0; i<(n); i++)
#define RREP(i,n) for(ll i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(ll i=(a); i<=(b); i++)
#define FORR(i,a,b) for(ll i=(b); i>=(a); i--)
#define fix(x) cout << fixed << setprecision(x)
#define dump(x) cout << #x << " = " << (x) << endl
#define all(x) (x).begin(),(x).end()

template<typename T> T sum(vector<T>& v){return accumulate(all(v), (T)0);}
template<typename T> inline void sort(vector<T>& v){sort(all(v));}
template<typename T> inline void rsort(vector<T>& v){sort(all(v), greater<T>());}
template<typename T> inline void chmin(T& a, T b){if(a>b) a=b;}
template<typename T> inline void chmax(T& a, T b){if(a<b) a=b;}

int main(){
    ll n, ans = 0;
    cin >> n;
    vll a(n);
    map<ll, ll> l;

    cin >> a;
    REP(i,n) l[i+1+a[i]]++;
    // for(auto& [key, val] : l) cout << key << "=>" << val << endl;
    REP(i,n) ans += l[i+1-a[i]];
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main() {
    int n; cin>>n;
    vector<long long> A(n, 0);
    for(int i = 0; i < n; i++) cin>>A[i];
    sort(A.begin(), A.end());
    int count = 0;
    for(int i = 0; i < n; i++) {
        for(int j = i+1; j < n; j++) {
            for(int k = j+1; k < n; k++) {
                if(A[i] != A[j] && A[j] != A[k] && A[i] != A[k] && A[i] + A[j] > A[k] ) count++;
            }
        }
    }
    cout<<count<<endl;
    return 0;
}

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

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

  ll K; cin >> K;
  ll A; cin >> A;
  ll B; cin >> B;
  if (A + 1 >= B) {
    cout << K + 1;
    return 0;
  }
  if (K <= A) {
    cout << K + 1;
    return 0;
  }
  ll temp = (K - A + 1) / 2;
  ll ans = A + temp * (B - A);
  if (K > A - 1 + temp * 2) ans++;
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
int col[1001][101];
int main() {
    int n, m, a;
    while (scanf("%d%d%d",&n,&m,&a)) {
        if (!n&&!m&&!a) break;
        for (int i=0; i<=1000; i++) for (int j=0; j<=100; j++) col[i][j]=0;
        for (int i=0; i<m; i++) {
            int h, p, q; scanf("%d%d%d",&h,&p,&q);
            col[h][p]=q;
            col[h][q]=p;
        }
        int pos=a;
        for (int i=1000; i>0; i--) {
            if (col[i][pos]!=0) {
                pos=col[i][pos];
            }
        }
        printf("%d\n",pos);
    }
}

Measured memory_bytes: 1148
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i++; i<N)
#define RVROOP(i, N) for(int i=N; i--; i>=0)
#define ALL(v) v.begin(), v.end()
const int INF = 1e9;
const int MAX = 510000;
const int MOD = 1000000007;
using namespace std;
typedef long long ll;

/*DP使ったほうがよくない？？WOWWOW*/

int main(){
  int A,B,ans=-1; cin>>A>>B;
  for(int i=B*10; i<(A+1)*25/2+1; i++){
    if(i*2/25==A && i/10==B){
      ans=i;
      break;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define arep(a,i,n) for(ll i=(a);i<(n);i++)
#define rep(i,n) for(ll i=0;i<(n);i++)
#define cinf(x,n) for(ll i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(ll i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int cnt;

int main(){
	int n;
	cin >> n;
	int d1[n];
	int d2[n];
	rep(i,n){
		cin >> d1[i] >> d2[i];
	}
	rep(i,n){
		if(d1[i]==d2[i]){
			cnt++;
			if(cnt==3){
				cout << "Yes" << endl;
				return 0;
			}
		}
		else
			cnt=0;
	}
	cout << "No" << endl;
}

Measured memory_bytes: 3632
def resolve():
    N, K = list(map(int, input().split()))
    S = input()
    seq = []
    cnt = 0
    for i in range(len(S)):
        if i == N-1 or S[i] != S[i+1]:
            seq.append([cnt+1, S[i]])
            cnt = 0
        else:
            cnt += 1
    #print(seq)
    left = 0
    right = 0
    maxlen = 0
    val = 0
    n_rev = 0
    for left in range(0, len(seq)):
        while (right < len(seq) and (n_rev < K or seq[right][1]=="1")):
            #print("left={}, right={}, n_rev={}".format(left, right, n_rev))
            cnt, state = seq[right]
            val += cnt
            if state == "0":
                n_rev += 1
            right += 1
        maxlen = max(maxlen, val)
        cnt, state = seq[left]
        val -= cnt
        if state == "0":
            n_rev -= 1
        if left == right:
            right += 1
    print(maxlen)
    

if '__main__' == __name__:
    resolve()

Measured memory_bytes: 61552
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        long d = sc.nextLong();

        long result = -1000000000000000001L;
        long[] resultArray = new long[4];
        resultArray[0] = a * c;
        resultArray[1] = a * d;
        resultArray[2] = b * c;
        resultArray[3] = b * d;
        for (int i =0; i < resultArray.length; i++) {
            long temp = resultArray[i];
            if (temp > result) {
                result = temp;
            }
        }
        System.out.println(result);
    }
}

Measured memory_bytes: 35788
import java.util.Scanner;


public class Main {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long [] a = new long[n + 1];
        long [] b = new long[n];
        for (int i = 0; i < n + 1; ++i) {
            a[i] = scanner.nextLong();
        }
        for (int i = 0; i < n; ++i) {
            b[i] = scanner.nextLong();
        }
        long count = 0;
        for (int i = 0; i < n; ++i) {
            long current = Math.min(a[i] + a[i + 1], b[i]);
            long tmp1 = a[i];
            long tmp2 = a[i + 1];
            a[i] = b[i] >= a[i] ? 0 : a[i] - b[i];
            long remainB = b[i] >= tmp1 ? b[i] - tmp1 : 0;
            a[i + 1] = remainB >= a[i + 1] ? 0 : a[i + 1] - remainB;
            b[i] = tmp1 + tmp2 >= b[i] ? 0 : b[i] - tmp1 - tmp2;
            count += current;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 84544
#include <stdio.h>
signed main(){
    int x[5];
    int i;
    for(i=0;i<5;i++){
        scanf("%d",&x[i]);
    }
    for(i=0;i<5;i++){
        if(x[i]==0){
            printf("%d\n",i+1);
        }
    }
}

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

#define LL long long
#define Dl double
#define Pb push_back
#define Po pop_back
#define Mp make_pair
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)

using namespace std;

typedef vector<LL> Vl;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef vector<Pll> Vpl;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
#define X first
#define Y second
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

bool vis[mx5];
LL a[mx5];

int main()
{
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

    LL n;
    cin >> n;


    for(LL i = 1; i <= n; i++){
        cin >> a[i];
    }

    LL cp = 1, cnt = 0;
    vis[cp] = 1;

    while(1){

        cnt++;
        if(vis[a[cp]])
            return cout << -1 << '\n', 0;
        if(a[cp] == 2)
            break;
        vis[a[cp]] = 1;
        cp = a[cp];
    }

    cout << cnt << '\n';
    return 0;
}



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

inline int read(){
  int x = 0; char c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)) x = x * 10 + c - '0', c = getchar();
  return x;
}

const int inf = ~0u >> 1;
const int maxn = 1e3;
int n;
int x[maxn], y[maxn], h[maxn];

int dist(int a, int b, int x, int y){
  return abs(a - x) + abs(b - y);
}
int check(int a, int b){
  int H;
  for(int i = 0; i < n; i++)
    if(h[i]){
      H = h[i] + dist(a, b, x[i], y[i]);
      break;
    }
  for(int i = 0; i < n; i++){
    int res = h[i] + dist(a, b, x[i], y[i]);
    if(!h[i] && H > res) return -1;
    if(h[i] && res != H) return -1;
  }
  return H;
}

int main(){
  n = read();
  int minx = inf, maxx = -inf, miny = inf, maxy = -inf;
  for(int i = 0; i < n; i++){
    x[i] = read(), y[i] = read(), h[i] = read();
    minx = min(minx, x[i]), maxx = max(maxx, x[i]);
    miny = min(miny, y[i]), maxy = max(maxy, y[i]);
  }
  for(int i = minx; i <= maxx; i++)
    for(int j = miny; j <= maxy; j++){
      int res = check(i, j);
      if(res >= 0){
        printf("%d %d %d", i, j, res);
        return 0;
      }
    }
}


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

using ll = long long;
using vll = vector<ll>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll (x);cin >>(x);
#define stin(x) str (x);cin >>(x);
#define FOR(i,a,b) for(ll i = a ; i <= b ; i++)
#define rFOR(i,b,a) for(ll i = a; i >= b ; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout<<(x);
#define sal(x) cout<<(x)<<endl;
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl;
#define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<endl;

ll MOD=1000000007;

signed main() {
	llin(n);
	stin(a);
	stin(b);
	stin(c);
	ll k=0;
	FOR(i,0,n-1){
		if(a[i]!=b[i]&&a[i]!=c[i]&&b[i]!=c[i]){
			k+=2;
		}else if(a[i]!=b[i]||a[i]!=c[i]||b[i]!=c[i]){
			k++;
		}
	}
	sal(k);
}

Measured memory_bytes: 256
/*
lakshaygpt28
Lakshay Gupta
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
using vll = vector < ll >;

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;


#ifndef ONLINE_JUDGE
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define debug(...)
#endif

#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 1e5 + 10;

ll dp[N][14], n;
string s;

ll solve(ll i, ll md);

int main() {
    fast_io();
    cin >> s;
    n = s.size();
    for (ll i = 0; i < N; i++) {
        for (ll j = 0; j < 14; j++) {
            dp[i][j] = -1;
        }
    }
    // debug("hi\n");
    cout << solve(0, 0) << "\n";
    return 0;
}

ll solve(ll i, ll md) {
    auto &ans = dp[i][md];
    // debug(i, md);
    if (ans != -1) {
        return ans;
    }
    ans = 0;
    if (i == n and md == 5) {
        ans = 1;
        return ans;
    } else if (i == n) {
        ans = 0;
        return ans;
    }
    if (s[i] == '?') {
        for (ll j = 0; j <= 9; j++) {
            ans += (solve(i + 1, ((md * 10) + j) % 13)) % MOD;
            ans %= MOD;
        }
    } else {
        ans += solve(i + 1, ((md * 10) + s[i] - 48) % 13);
        ans %= MOD;
    }
    return ans;
}


Measured memory_bytes: 17616
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
import Data.Ord

main :: IO ()
main = getLine >> readLine >>= main'
    where
        main' [t, a] = readLine >>= print . solve t a

solve :: Int -> Int -> [Int] -> Int
solve t a = fst . minimumBy (comparing snd) . map (\(n, x) -> (n, abs $ fromIntegral t - fromIntegral x * 0.006 - fromIntegral a)) . zip [1..]

readLine :: IO [Int]
readLine = unfoldr (\s -> second (maybe B.empty snd . B.uncons) <$> B.readInt s) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

Measured memory_bytes: 764
# Input
x = input()

# Input x length
x_len = len(x)

# Init min_val
min_val = 9999

# Search
for idx in range(0 , x_len - 2):
    search_val = int(x[idx] + x[idx + 1] + x[idx + 2])
    
    calc_val = abs(753 - search_val)
    
    if min_val > calc_val:
        min_val = calc_val

# Output
print(min_val)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second


int main() {
	int n;
	cin >> n;
	vector<int> h(n);
	forn(i, n) cin >> h[i];
	int dp[n];
	dp[0] = 0;
	dp[1] = abs(h[0]-h[1]);
	for(int i = 2; i < n; i++)
		dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
	cout << dp[n-1] << endl;
	return 0;

}



Measured memory_bytes: 1024
#include <iostream>
#include <cmath>

using namespace std;

int n, mem_index = 0, fight_strength[20] = {0}; //登録者数、何番目の登録か、登録者の戦闘力

int my_min(int now, int a_sum, int b_sum)
{
	if(now == n) return abs(a_sum - b_sum);

	int min_a = my_min(now + 1, a_sum + fight_strength[now], b_sum),
	    min_b = my_min(now + 1, a_sum, b_sum + fight_strength[now]);

	if(min_a > min_b)
		return min_b;
	else if(min_a < min_b)
		return min_a;
	else
		return min_a;
}

int main(void)
{
	while(true)
	{
		cin >> n;
		if(n == 0) break;
		while(mem_index < n)
		{
			cin >> fight_strength[mem_index];
			mem_index++;
		}

		cout << my_min(0, 0, 0) << endl;
		mem_index = 0;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back


void solve(string s,int dice[6]){
    int ans[6]={};
    rep(i,6)ans[i]=dice[i];
    if(s=="North"){
        ans[0]=dice[1];
        ans[1]=dice[5];
        ans[4]=dice[0];
        ans[5]=dice[4];
    }
    if(s=="East"){
        ans[0]=dice[3];
        ans[2]=dice[0];
        ans[3]=dice[5];
        ans[5]=dice[2];
    }
    if(s=="West"){
        ans[0]=dice[2];
        ans[2]=dice[5];
        ans[3]=dice[0];
        ans[5]=dice[3];
    }
    if(s=="South"){
        ans[0]=dice[4];
        ans[1]=dice[0];
        ans[4]=dice[5];
        ans[5]=dice[1];
    }
    if(s=="Right"){
        ans[1]=dice[2];
        ans[2]=dice[4];
        ans[3]=dice[1];
        ans[4]=dice[3];
    }
    if(s=="Left"){
        ans[1]=dice[3];
        ans[2]=dice[1];
        ans[3]=dice[4];
        ans[4]=dice[2];
    }
    
    rep(i,6){
        dice[i]=ans[i];
    }
}

int main() {
    int n;
    while(cin>>n){
        if(n==0)break;
        
        int dice[6]={};
        rep(i,6)dice[i]=i+1;

        int sum=1;
        rep(i,n){
            string s;
            cin>>s;
            solve(s,dice);

            sum+=dice[0];
        }//
        cout<<sum<<endl;
    
    }
    return 0;
}

Measured memory_bytes: 1220
#include <stdio.h>

int main(void)
{
	int n, m;
	int i, j;
	int a[100][100]={};
	int b[100]={};
	int c[100]={};
	
	scanf("%d%d", &n, &m);
	
	for(i=0; i<n; i++) {
		for(j=0; j<m; j++)
			scanf("%d", &a[i][j]);
	}
	for(j=0; j<m; j++)
		scanf("%d", &b[j]);
	
	for(i=0; i<n; i++) {
		for(j=0; j<m; j++)
			c[i]+=a[i][j]*b[j];
		printf("%d\n", c[i]);
	}
	
	return 0;
}


Measured memory_bytes: 648
#include <bits/stdc++.h>
using namespace std;
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#define int long long
#define pi pair<int,int>
#define ff first
#define ss second


int32_t main(){
	boost;
	int n;
	cin>>n;
	int vertex = 0,edge = 0;
	for(int i=1;i<=n;i++)
		vertex += (n - i + 1)*i;
	
	for(int i=1,u,v;i<n;i++){
		cin>>u>>v;
		if(u > v)
			swap(u,v);
		edge += u*(n - v +1);
	}
	cout<<vertex - edge <<endl;
}



Measured memory_bytes: 3620
n=int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

ans = 0
for i in range(len(a)):
  ans += b[a[i] - 1]
  if i < len(a) - 1:
    if a[i] + 1 == a[i + 1]:
      ans += c[a[i] - 1]
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int a,b,x,y,b2[110][110];
int main()
{ 
	scanf("%d%d",&a,&b); 
	a--;
	b--;
	for(int i=1;i<=50;i++)
	{
		for(int j=1;j<=100;j++)
		{
			b2[i][j]=1;
		}
	}
	x=1;
	y=1;
    while(a!=0)
    {
        b2[x][y]=0;       
        a--;       
     	y+=2;
       	if(y>=100)
        {
            x+=2;
            y=1;
        }
    }    
    x=100;
	y=1;    
	while(b!=0)
	{
        b2[x][y]=1;
        y+=2;        
        b--;
        if(y>=100)
        {
            x-=2;
            y=1;
        }
    }
    cout<<100<<' '<<100<<endl;
    for(int i=1;i<=100;i++)
    {
        for(int j=1;j<=100;j++)
        {
        	if(b2[i][j]) 
			{
				cout<<"#";
			}
            else 
			{
				cout<<".";
			}
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 3772
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;


int main() {
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    if(e - a > k) puts(":(");
    else puts("Yay!");
}

Measured memory_bytes: 256
import Control.Monad
import Data.Array.IArray

solve :: Int -> Int -> Array (Int,Int) Char -> Array (Int,Int) Char -> Bool
solve n m a b = go (1,1)
  where
    go ix@(i,j)
      | all (check ix) (range ((1,1),(m,m))) = True
      | otherwise = maybe False go (next ix)
    check (i,j) bix@(bi,bj) =
      let aix = (i+bi-1,j+bj-1)
       in (a!aix) == (b!bix)
    next (i,j)
      | i == (n-m+1) = Just (1,j+1)
      | j == (n-m+1) = Nothing
      | otherwise = Just (i+1,j)

main :: IO ()
main = do
    [n,m] <- map read . words <$> getLine :: IO [Int]
    a <- listArray ((1,1),(n,n)) . concat
      <$> replicateM n getLine :: IO (Array (Int,Int) Char)
    b <- listArray ((1,1),(m,m)) . concat
      <$> replicateM m getLine :: IO (Array (Int,Int) Char)
    putStrLn $ if solve n m a b then "Yes" else "No"

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

#define ll long long

ll cake[4010];
int n;

ll dp[4010][4010];

ll dfs(int l, int r){
	if(dp[l][r]>-1)return dp[l][r];
	if(l==r){
		dp[l][r]=0;
		return dp[l][r];
	}
	if(l+1==r){
		dp[l][r]=min(cake[l],cake[r]);
		return dp[l][r];
	}
	if(cake[l]==cake[r]){
		dp[l][r] = cake[l+1] + dfs(l+2,r);
		dp[l][r] = max(dp[l][r], cake[r] + dfs(l+1,r-1));
		dp[l][r] = max(dp[l][r], cake[l] + dfs(l+1,r-1));
		dp[l][r] = max(dp[l][r], cake[r-1] + dfs(l,r-2));
		return dp[l][r];
	}
	if(cake[l]>cake[r]){
		dp[l][r] = cake[l+1] + dfs(l+2,r);
		dp[l][r] = max(dp[l][r], cake[r] + dfs(l+1,r-1));
		return dp[l][r];
	}
	if(cake[l]<cake[r]){
		dp[l][r] = cake[l] + dfs(l+1,r-1);
		dp[l][r] = max(dp[l][r], cake[r-1] + dfs(l,r-2));
		return dp[l][r];
	}
}

int main(){
	
	ll ans=0;
	
	for(int i=0;i<4010;i++){
		for(int j=0;j<4010;j++){
			dp[i][j]=-1;
		}
	}
	
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>cake[i];
		cake[n+i]=cake[i];
	}
	
	for(int i=0;i<n;i++){
		ll tmp=0;
		tmp = cake[i] + dfs(i+1,i+n-1);
		ans=max(ans,tmp);
	}
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 126896
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int (input())
 
print(l[k-1])

Measured memory_bytes: 3060
#include <queue>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MP make_pair
#define ll long long
#define fi first
#define se second
using namespace std;

template <typename T>
void read(T &x) {
    x = 0; bool f = 0;
    char c = getchar();
    for (;!isdigit(c);c=getchar()) if (c=='-') f=1;
    for (;isdigit(c);c=getchar()) x=x*10+(c^48);
    if (f) x=-x;
}

template<typename F>
inline void write(F x)
{
	static short st[30];short tp=0;
	if(x<0) putchar('-'),x=-x;
	do st[++tp]=x%10,x/=10; while(x);
	while(tp) putchar('0'|st[tp--]);
	putchar('\n');
}

template <typename T>
inline void Mx(T &x, T y) { x < y && (x = y); }

template <typename T>
inline void Mn(T &x, T y) { x > y && (x = y); }

const int P = 998244353;
ll fpw(ll x, ll mi) {
	ll res = 1;
	for (; mi; mi >>= 1, x = x * x % P) 
		if (mi & 1) res = res * x % P;
	return res;
}

const int N = 1005000;
ll jie[N], inv[N];
inline ll C (ll n, ll m) {
	return jie[n] * inv[m] % P * inv[n-m] % P;
}

int m, n;
int main() {
	read(n), read(m);
	int lim = n + m; jie[0] = inv[0] = inv[1] = 1;
	for (int i = 2;i <= lim; i++)
		inv[i] = (ll)(P - P / i) * inv[P % i] % P;
	for (int i = 1; i <= lim; i++)
		inv[i] = inv[i - 1] * inv[i] % P, jie[i] = jie[i-1] * i % P;
	ll ans = 0;
	for (int i = 1;i <= min(n, m); i++)
		ans = (ans + C(2 * i, i) * C(n + m - 2 * i, n - i)) % P;
	ans = ans * fpw(C(n + m, n) * 2 % P, P - 2);
	write((max(n, m) + ans) % P);
	return 0;
}

Measured memory_bytes: 18684
def main():
    n, k = map(int, input().split())

    res = 0
    for i in range(1,n+1):
        cnt = 0
        while i < k:
            i *= 2
            cnt += 1
        res += 1 / (n*(2**cnt))
    print(res)
    
if __name__ == '__main__':
    main()
                

Measured memory_bytes: 39152
#include<bits/stdc++.h>
#define MAXN 100005
using namespace std;
typedef long long ll;
ll n,a[MAXN],b[MAXN];
int main()
{
	scanf("%lld",&n);
	for(ll i=0;i<n;i++)
		scanf("%lld",&a[i]);
	for(ll i=0;i<n;i++)
		scanf("%lld",&b[i]);
	ll aop=0,bop=0,ans=0;
	for(ll i=0;i<n;i++)
	{
		aop+=max(0LL,(b[i]-a[i]+1)/2);
		if(b[i]>a[i]&&((b[i]-a[i])&1)) bop++;
		bop+=max(0LL,a[i]-b[i]);
		ans=ans+b[i]-a[i];
	}
	if(ans<aop||ans<bop) puts("No"); else puts("Yes");
	return 0;
}

Measured memory_bytes: 384
import math


def isPrime(n):
    if n <= 2:
        return n == 2
    if (n % 2 == 0):
        return False
    for i in range(3, int(math.sqrt(n)) + 2, 2):
        if n % i == 0:
            return False
    return True


N = int(input())
print(len(list(filter(isPrime, [int(input()) for i in range(N)]))))



Measured memory_bytes: 6068
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <functional>
#include <algorithm>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <typeinfo>
#include <functional>
#include <iomanip>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
typedef long long ll;

ll N, A[100000], B[100000];

vector<pair<ll, int>> data;

int main()
{

	cin >> N;

	for (int i = 0; i < N; i++)
	{
		cin >> A[i] >> B[i];
		data.push_back(make_pair(A[i] + B[i], i));
	}

	std::sort(data.begin(), data.end());

	int id = 1;
	ll eater[2];
	ll eat = 0;
	for (int i = 0; i < N; i++)
	{
		//cout << data.at(i).first << endl;
		if (id == 1)
		{
			//eat += data.at(N - i - 1).first * id;
			eat += A[data.at(N - i - 1).second];
		}
		else
		{
			eat -= B[data.at(N - i - 1).second];
		}
		id *= -1;
	}
	cout << eat << endl;
	return 0;
}

Measured memory_bytes: 3444
def onp(dzialanie):
    stos = []
    kolejka = dzialanie.split(" ")

    while len(kolejka) > 0:
        item = kolejka.pop(0)
        if item == "+":
            stos.append(stos.pop() + stos.pop())
        elif item == "-":
            odjemnik = stos.pop()
            stos.append(stos.pop() - odjemnik)
        elif item == "*":
            stos.append(stos.pop() * stos.pop())
        elif item == "/":
            dzielnik = stos.pop()
            stos.append(stos.pop() / dzielnik)
        else:
            try:
                stos.append(float(item))
            except ValueError:
                return "ERROR: Niedozwolony element: "+item

    return str(int(stos.pop()))

print(onp(input()))


Measured memory_bytes: 5576
#include <iostream>
#include <set>

using namespace std;

int main(){
    int N;
    cin >> N;
    long s[100000];
    long ans = 0;
    for(int i = 0; i < N; i++) cin >> s[i];
    for(int i = 1; i < (N/2); i++){
        long tmp = 0;
        long sum = 0;
        set<int> st;
        for(int j = 1; j*i < N; j++){
            sum += s[i*j];
            st.insert(i*j);
            sum += s[N-i*j-1];
            if(st.count(N-i*j-1) != 0) break;
            if(N-i*j-1 < i) break;
            ans = max(sum, ans);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
def solve():
    N, Y = map(int, input().split())
    
    for x in range(N+1):
        for y in range(N+1):
            if Y - x * 10000 - y * 5000 == (N-x-y) * 1000 and 0 <= N-x-y:
                print(x, y, N-x-y)
                return 1
    return 0

if solve() == 0:
    print("-1 -1 -1")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
void read(int &x)
{
    int f=1;
    x=0;
    char s=getchar();
    while(s<'0'||s>'9')
    {
        if(s=='-')
            f=-1;
        s=getchar();
    }
    while(s>='0'&&s<='9')
    {
        x=x*10+s-'0';
        s=getchar();
    }
    x*=f;
}
#define N 100005
int n,m,t;
int a[N],b[N];
int main(){
    cin>>n>>m>>t;
    for (int i = 1; i <= n; i++)
    {
        cin>>a[i];
    }
    for (int i = 1; i <= m; i++)
    {
        cin>>b[i];
    }
    int ans=1e9;
    for (int i = 0; i < t; i++)
    {
        int x,y,c;
        cin>>x>>y>>c;
        ans= min(a[x]+b[y]-c,ans);
    }
    sort(a+1,a+n+1);
    sort(b+1,b+m+1);
    cout<<min(ans,a[1]+b[1]);
    
    
    return 0;
}

Measured memory_bytes: 1024
/* Author: Rennan Rocha
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll, ll>
#define vpi vector<pi>
#define vpll vector<pll>

#define INF 1e18
#define MOD 1e9 + 7

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//*find_by_order(); order_of_key();

int main() {
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

    if(n%10 == 7 || (n%100)/10 == 7 || n/100 == 7) cout << "Yes\n";
    else cout << "No\n";
}


Measured memory_bytes: 3628
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e5 + 10;
vector<tuple<int, int, int>> v[N];
vector<pair<int, int>> s[N];
int fa[N][20];
int clr[N];
int depth[N];
int len[N];
int ans[N];
struct Node
{
	int lca, x, y, pos;
	Node(int lca = 0, int x = 0, int y = 0, int pos = 0)
	{
		this->lca = lca;
		this->x = x;
		this->y = y;
		this->pos = pos;
	}
	void getans()
	{
		auto iter = upper_bound(s[x].begin(), s[x].end(), make_pair(depth[lca], int(INF)));
		int sz = s[x].end() - iter;
		iter--;
		ans[pos] += sz * y - (s[x].back().second - iter->second);
	}
};
vector<Node> qr[N];
void dfs1(int x, int p = 0)
{
	fa[x][0] = p;
	depth[x] = depth[p] + 1;
	for (int o = 1; o < 20; o++)
	{
		fa[x][o] = fa[fa[x][o - 1]][o - 1];
	}
	for (auto& pp : v[x])
	{
		int y, w, c;
		tie(y, w, c) = pp;
		if (y == p) continue;
		len[y] = len[x] + w;
		clr[y] = c;
		dfs1(y, x);
	}
}
void dfs2(int x, int c = 0, int w = 0, int p = 0)
{
	auto iter = make_pair(depth[x], s[c].back().second + w);
	s[c].emplace_back(iter);
	for (auto& node : qr[x])
	{
		node.getans();
	}
	for (auto& pp : v[x])
	{
		int y, w, c;
		tie(y, w, c) = pp;
		if (y == p) continue;
		dfs2(y, c, w, x);
	}
	s[c].pop_back();
}
int moveup(int x, int d)
{
	for (int i = 0; d >> i; i++)
	{
		if (d >> i & 1)
			x = fa[x][i];
	}
	return x;
}
int getlca(int x, int y)
{
	if (depth[x] < depth[y])
		swap(x, y);
	x = moveup(x, depth[x] - depth[y]);
	if (x == y) return x;
	for (int i = 19; i >= 0; i--)
	{
		if (fa[x][i] != fa[y][i])
			x = fa[x][i], y = fa[y][i];
	}
	return fa[x][0];
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, q;
	cin >> n >> q;
	for (int i = 1; i < n; i++)
	{
		int x, y, w, c;
		cin >> x >> y >> c >> w;
		v[x].emplace_back(y, w, c);
		v[y].emplace_back(x, w, c);
	}
	dfs1(1);
	for (int i = 1; i <= q; i++)
	{
		int x, y, u, v;
		cin >> x >> y >> u >> v;
		int lca = getlca(u, v);
		ans[i] = len[u] + len[v] - 2 * len[lca];
		if(lca != u) qr[u].emplace_back(lca, x, y, i);
		if(lca != v) qr[v].emplace_back(lca, x, y, i);
	}
	for (int i = 0; i < N; i++) s[i].emplace_back(0, 0);
	dfs2(1);
	for (int i = 1; i <= q; i++)
		printf("%d\n", ans[i]);
	return 0;
}

Measured memory_bytes: 32504
import           Control.Monad (replicateM)

main :: IO ()
main = do
    n <- readLn :: IO Int
    ts <- replicateM n $ do
        [t, x, y] <- getInts
        return (t, (x, y))
  --  print ts
    putStrLn $ if solve ts then "Yes" else "No"

getInts :: IO [Int]
getInts = map read . words <$> getLine

solve ts = go ts 0 (0, 0)
    where
      go [] _ _ = True
      go (l:s) n (x, y) = let (t, (x', y')) = l
                              r = t - n
                              d = abs (x-x') + abs (y-y') in
                              if r >= d && (r - d) `mod` 2 == 0
                              then go s t (x', y')
                              else False



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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

struct UnionFind
{
	// par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
	vector<LL> par;
	// sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
	vector<LL> sizes;

	UnionFind(LL n) : par(n), sizes(n, 1) {
		// 最初は全てのデータiがグループiに存在するものとして初期化
		for(LL i = 0;i < n;i++) par[i] = i;
	}

	// データxが属する木の根を得る
	LL find(LL x) {
		if (x == par[x]) return x;
		return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
	}

	// 2つのデータx, yが属する木をマージする
	void unite(LL x, LL y) {
		// データの根ノードを得る
		x = find(x);
		y = find(y);

		// 既に同じ木に属しているならマージしない
		if (x == y) return;

		// xの木がyの木より大きくなるようにする
		if (sizes[x] < sizes[y]) swap(x, y);

		// xがyの親になるように連結する
		par[y] = x;
		sizes[x] += sizes[y];
		// sizes[y] = 0;  // sizes[y]は無意味な値となるので0を入れておいてもよい
	}

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

	// データxが含まれる木の大きさを返す
	LL size(LL x) {
		return sizes[find(x)];
	}
};

int main(int argc, char const* argv[])
{
	LL n,m;
	cin >> n >> m;
	VL a(m), b(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i] >> b[i];
		a[i]--;
		b[i]--;
	}
	VL ans(m,0);
	ans[m-1] = n * (n-1) / 2;
	UnionFind uf(n);
	for (int i = m-1; i >= 1; i--) {
		if (uf.same(a[i],b[i])) {
			ans[i-1] = ans[i];
			continue;
		}
		ans[i-1] = ans[i] - (uf.size(a[i]) * uf.size(b[i]));
		uf.unite(a[i],b[i]);
	}

	for (int i = 0; i < m; i++) {
		cout << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 5248
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
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; }


using namespace std;

const double inf = 1e10;

struct D {
    vector<double> l, r;
    D():l(3, inf),r(3,-inf) {}
    void add(double x, int v) {
        ++v;
        chmin(l[v], x);
        chmax(r[v], x);
    }
    double get(double t) {
        double nl = inf, nr = -inf;
        rep(i, 3) {
            chmin(nl, l[i]+i*t);
            chmax(nr, r[i]+i*t);
        }
        return nr - nl;
    }
    vector<double> events() {
        vector<double> ts;
        rep(i, 3) {
            rep(j, i) {
                double t = (l[j]-l[i])/(i-j);
                if (t > 0) ts.push_back(t);
                t = (r[j]-r[i])/(i-j);
                if (t > 0) ts.push_back(t);

            }

        }
        return ts;
    }

};

int main(){
    int n;
    cin >> n;
    D xd, yd;
    rep(i, n) {
        int x, y;
        char d;
        cin >> x >> y >> d;
        if (d == 'L') xd.add(x, -1), yd.add(y, 0);
        if (d == 'R') xd.add(x, 1), yd.add(y, 0);
        if (d == 'U') xd.add(x, 0), yd.add(y, 1);
        if (d == 'D') xd.add(x, 0), yd.add(y, -1);
    }
    vector<double> ts;
    ts.push_back(0);
    ts.push_back(inf);
    {
        auto nts = xd.events();
        ts.insert(ts.end(), nts.begin(), nts.end());
    }
    {
        auto nts = yd.events();
        ts.insert(ts.end(), nts.begin(), nts.end());
    }
    sort(ts.begin(), ts.end());
    double ans = 1e18;
    for(double t:ts) {
        double now = xd.get(t)*yd.get(t);
        chmin(ans, now);
    }
    printf("%.10f\n", ans);

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
#define fore(i,a) for(auto &i:a)
#define all(a) (a).begin(),(a).end()
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
using ll = long long; constexpr int inf = INT_MAX / 2; constexpr ll infl = 1LL << 60;
template<class T>void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T>void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T>void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T>void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<class T>T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }

void _main() {
  ll N;
  vector<ll> a(5);
  cin >> N;
  rep(i, 0, 5) cin >> a[i];

  ll min = *std::min_element(all(a));
  ll ans = 4 + (N / min) + ((N%min==0)?0:1);
  cout << ans << endl;
}

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

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int s, w;
    cin >> s >> w;

    if(w >= s) cout << "unsafe" << endl;
    else cout << "safe" << endl;

    return 0;
}

Measured memory_bytes: 3624
def main():
    param = input()
    param = input().split(" ")
    seq = [ int(a) for a in param]

    n = int(input())

    for _ in range(n):

        param = input().split(" ")

        if param[0] == "0":
            print(min(seq[int(param[1]):int(param[2])]))
        elif param[0] == "1":
            print(max(seq[int(param[1]):int(param[2])]))

main()



Measured memory_bytes: 5636
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  [a, b, c, d] <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    m = pred c `div` b
    n = pred a `div` d
  putStrLn $ if m <= n then "Yes" else "No"

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 3696
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <set>
 
using namespace std;
 
int var[11];
 
int solve();
int getVal(int &itr, const string &form);
 
int main(void) {
 
	while (solve()){}
 
	return 0;
 
}
 
int solve() {
 
	//	input
	string eq,exp[2];
	cin >> eq;
 
	//	the end of dataset
	if (eq == "#") { return 0; }
 
	int sep = eq.find("=");
 
		//	lfs
		exp[0] = eq.substr(0, sep);
		//	rhs
		exp[1] = eq.substr(sep+1, string::npos);
 
	//	brute force
	bool isEqual = true;
	for (int i = 0; i < (1 << 12); i++) {
 
		for (int j = 0; j < 11; j++) {
			if (i & (1 << j)) {
				var[j] = 1;
			}
			else {
				var[j] = 0;
			}
		}
 
		int itr[2] = { -1, -1};
 
		int rhs, lhs;
		lhs = getVal(itr[0], exp[0]);
		rhs = getVal(itr[1], exp[1]);
		/*
		bitset<20> b(i);
		cout << b << endl;
		cout << lhs << " " << rhs << endl;
		cout << endl;
		*/
		isEqual &= ( lhs == rhs );
 
	}
 
	//	output
 
	if (isEqual) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
 
 
	return 1;
}
 
int getVal(int &itr, const string &form) {
 
	//	formula????§£???
	++itr;
	if (form[itr] == 'T') { return 1; }
	if (form[itr] == 'F') { return 0; }
	if ('a' <= form[itr] && form[itr] <= 'k') { return var[form[itr]-'a']; }
 
	// operator -
	if (form[itr] == '-' && form[itr+1] != '>' ) {
		return 1 - getVal(itr, form);
	}
 
	if (form[itr] == '(') {
 
		//	binary operator
		int lhs, rhs;
		char ope;
 
		lhs = getVal(itr, form);
 
		itr++;
		ope = form[itr];
		if (ope == '-') { itr++; }
 
 
		rhs = getVal(itr, form);
 
		//	')'
		itr++;
 
		if (ope == '+') {
			return max(lhs, rhs);
		}
		else if (ope == '*') {
			return min(lhs, rhs);
		}
		else if (ope == '-') {
			if (lhs == 1 && rhs == 0) { return 0; }
			else return 1;
		}
 
	}
 
	return 0;
}

Measured memory_bytes: 3144
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N, K, P[200000], c, a[200000];
set<int>st;
bool f;
int main() {
	cin >> N >> K;
	for (int i = 0; i < N; ++i) {
		cin >> P[i];
	}
	for (int i = 1; i < N; ++i) {
		if (P[i - 1] < P[i]) {
			a[i] = a[i - 1] + 1;
		}
	}
	for (int i = 0; i < K; ++i) {
		st.insert(P[i]);
	}
	c = 1;
	if (a[K - 1] >= K - 1) {
		f = true;
	}
	for (int i = K; i < N; ++i) {
		auto it = st.end();
		--it;
		auto it2 = st.begin();
		if (!(*it < P[i] && *it2 == P[i - K])) {
			++c;
			if (a[i] >= K - 1) {
				if (!f)f = true;
				else --c;
			}
		}
		st.erase(P[i - K]);
		st.insert(P[i]);
	}
	cout << c << endl;
}

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

int main() {
  int a, b;
  std::cin >> a >> b;
  int d = a / b;
  int r = a % b;
  double f = (double)a/b;
  std::cout << d << " " << r << " ";
  printf("%.5lf\n", f);
  return 0;
}



Measured memory_bytes: 3232
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

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

	int ans = b;
	if( 13 <= a ){
		ans = b;
	}
	else if( 6 <= a ){
		ans = b / 2;
	}
	else {
		ans = 0;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import sys
import copy
input = sys.stdin.readline

n, k = map(int,input().split())
a = list(map(int,input().split()))

min_c = 10**11

for i in range(2**n):
    c = 0
    r_a = copy.copy(a)
    bit = 2
    max_a = r_a[0]
    for j in range(1,n):
        if i & bit and r_a[j] <= max_a:
            c += max_a - r_a[j] + 1
            r_a[j] = max_a + 1
        if r_a[j] > max_a:
            max_a = r_a[j]
        bit *= 2
    cl = 1
    max_a = r_a[0]
    for j in range(1,n):
        if r_a[j] > max_a:
            cl += 1
            max_a = r_a[j]
    if cl >= k:
        min_c = min(min_c,c)

print (min_c)

Measured memory_bytes: 45932
#define _USE_MATH_DEFINES
 
#include <bits/stdc++.h> 
 
using namespace std;
 
#define len(x) (int)((x).size())
#define endl '\n'
#define x first
#define y second
#define int long long
#define double long double
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define vi vector<int> 
#define vvi vector<vector<int>>
#define pb push_back
 
#ifdef LOCAL
    #define dbg(x) cout << #x << " = " << x << endl;
#else 
    #define dbg(x)
#endif 
 
void solve(); signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);                                       
    freopen("output.txt", "w", stdout);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(10);
    solve();    
}
 
const int INF = 1e18, MAXN = 2e5 + 10, MOD = 1e9 + 7;

void solve() {
	int n, m;
	cin >> n >> m;

	int d = 1, ans = 1;
	while (d * d <= m) {
		if (m % d == 0) {
			if (m / d >= n) {
				ans = max(ans, d);
			}
			if (d >= n) {
				ans = max(ans, m / d);
			}
		}
		d++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256