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

long long A[200], B[200];

long long _log2(long long b){
    long long ans = 0;
    while(b > 0){
        ans++;
        b /= 2;
    }
    return ans-1;
}

long long _pow2(long long b){
    long long ans = 1;
    for(int i = 0; i < b; i++)
        ans *= 2;
    return ans;
}

int main(){
    long long a, b;
    cin >> a >> b;
    long long ans = 0;
    if(a > b) swap(a, b);
    a = max(a-1, 0LL);
    long long addA = 0, addB = 0;
    while(a > 0){
        long long right = a ^ (a & (a-1));
        a = (a & (a-1));
        for(int i = 0; i < _log2(right); i++){
            A[i] += right/2;
        }
        A[_log2(right)] += 1;
        A[_log2(right)] += addA;
        addA += right;

    }
    while(b > 0){
        long long right = b ^ (b & (b-1));
        b = (b & (b-1));
        for(int i = 0; i < _log2(right); i++){
            B[i] += right/2;
        }
        B[_log2(right)] += 1;
        B[_log2(right)] += addB;
        addB += right;
    }

    for(int i = 0; i < 50; i++){
        if( (B[i]-A[i]) % 2 == 1)
            ans = ans | _pow2(i);
    }
    cout << ans << "\n";
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

using namespace std;

int vs[200000+10];
int ans[200000+10];

int main(void) {
  int n;
  scanf("%d", &n);
  REP(i, n) {
    scanf("%d", &vs[i+1]);
  }
  for(int i = n; i >= 1; --i) {
    int cur = 0;
    for(int j = i+i; j <= n; j += i) {
      cur += ans[j];
    }
    if(cur % 2 != vs[i]) {
      ans[i] = 1;
    }
  }
  vector<int> res;
  REP(i, n) {
    if(ans[i+1]) {
      res.push_back(i+1);
    }
  }
  printf("%d\n", (int)res.size());
  REP(i, res.size()) {
    printf("%d%c", res[i], i == (int)res.size()-1 ? '\n' : ' ');
  }
  
  return 0;
}


Measured memory_bytes: 2936
# ＤＦＳ, グラフ, 全探索, 親の情報を自身に加算
 # ※ 要削除

n, q = map(int,input().split())

pic = [[] for _ in range(n+1)] # ダミーのノード '0' を含む
for _ in range(n-1): # 絵の取り込み
    x, y = map(int, input().split())
    pic[x].append(y)
    pic[y].append(x)
    
cnts = [0] * (n+1)
for _ in range(q):
    x, y = map(int, input().split())
    cnts[x] += y

visited = [0] * (n+1) # 訪問の記録、初期化
visited[0], visited[1] = 1, 1

stack = []
stack.append(1)

#print(n, q) # ※
#print(pic) # ※
#print(cnts)
#print(visited) # ※

while stack:
    tmp = stack.pop() # 探索候補を pop して...
    for i in pic[tmp]: # 次の探索候補を探索
        if visited[i] != 0: # 未訪問かどうかを確認...
            continue
        else: # 未訪問の場合...
            visited[i] = 1 # 現在地の訪問を記録
            cnts[i] += cnts[tmp] # 親の 'cnt' を自身の 'cnt' に加える
            stack.append(i) # 現在地を探索候補に積む

print(*cnts[1:])


Measured memory_bytes: 55828
#include <bits/stdc++.h>
#include <iostream>
#include <string>

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;

#define REP(idx, N) for (u64 idx = 0; idx < N; idx++)

int main() {
  i64 n, m;
  cin >> n >> m;

  vector<u32> a(m);

  REP(i, m) {
    u32 ai;
    cin >> ai;
    n -= ai;
  }

  if (n >= 0)
    cout << n;
  else
    cout << -1;

  return 0;
}


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

int main()
{
    int n,m;
    cin >> n >> m;
    if(n == 1)
    {
        if(m == 1)
        {
            cout << "1\n";
        }
        else
         cout <<  m - 2 << "\n";
         return 0;
    }
    if(m == 1)
    {
        cout << n - 2 << "\n";
        return 0;
    }
    long long int fans =  n * 1ll * m - 2ll * (n - 2) - 2ll * (m - 2) - 4;
    cout << fans << "\n";
    return 0;
}


Measured memory_bytes: 256
N = int(input())
X = list(map(int, input().split()))
Y = sorted(X)
midg = Y[(N + 1) // 2]
midl = Y[(N + 1) // 2 - 1]
for i in range(N):
    if X[i] < midg:
        print(midg)
    elif X[i] >= midl:
        print(midl)


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

using namespace std;
typedef long long ll;
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; }
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const int INF = 1000000;
const double PI=3.14159265359;
// const ll k=998244353;

const ll MAX = 510000;
const ll MOD =998244353;



int main(){

  int n;cin>>n;
  double x[n+10],y[n+10];rep(i,0,n)cin>>x[i]>>y[i];

  vector<int> k(n);
  rep(i,0,n)k[i]=i;

  double ans=0;
  do{
    rep(i,0,n-1){
      ans+=sqrt((x[k[i]]-x[k[i+1]])*(x[k[i]]-x[k[i+1]])+(y[k[i]]-y[k[i+1]])*(y[k[i]]-y[k[i+1]]));
    }

  }while(next_permutation(k.begin(),k.end()));


  ll num=1;
  rep(i,1,n+1){
    num*=i;
  }

  cout<<setprecision(10)<<ans/num<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
#define int ll
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
int mod=1e9+7;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename A,typename B> istream& operator>>(istream&,pair<A,B>&);
template<typename A> istream& operator>>(istream&,vector<A>&);
void add(int&,int);
int mul(int,int);
int powz(int,int);

template<typename A> ostream& operator<<(ostream&,vector<A>&);
 
const int N=1000002;

void solve(){
	int n;
	cin>>n;
	vi a(n);
	cin>>a;
	sort(all(a));
	long double ans=a[0];
	for(int i=1;i<n;i++){
		ans+=a[i];
		ans=ans/2;
	}
	cout<<ans;
}

 
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int tc=1;
	//~ cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}
 
int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}
 
void add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
}
 
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)res=mul(res,a);
		b/=2;
		a=mul(a,a);
	}
	return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
	    output<<i<<' ';
	return output;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const ll inf = 1 << 30;
const ll mod = 1000000000 + 7;

int main()
{
	string s;
	cin >> s;

	bool ok = true;
	int cc = 0;
	for (int i = 0; i < s.length(); i++)
	{
		if (i == 0)
		{
			if (s.at(0) != 'A')
			{
				ok = false;
			}
		}
		else
		{
			if (1 < i && i < s.length() - 1 && s.at(i) == 'C')
			{
				cc++;
			}
			else if (!('a' <= s.at(i) && s.at(i) <= 'z'))
			{
				ok = false;
			}
		}
	}

	if (cc != 1)
	{
		ok = false;
	}

	cout << (ok ? "AC" : "WA") << endl;
}


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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<Edge>>;

int main()
{
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<pii> a(m);
    REP(i, m) cin >> a[i].second >> a[i].first;
    sort(a.begin(), a.end());

    int cut = 1e9;
    int ans = 0;
    REP(i, m) {
        if(!(a[i].first >= cut && a[i].second < cut)) {
            cut = a[i].first;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
 
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

void pre(){


}
 
void solve(){
 
 
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	pre();

    ll l;cin>>l;
    ld a=l/3.0;
    
    cout<<fixed<<setprecision(12)<<endl;
    cout<<a*a*a<<endl;

	return 0;
}
 



Measured memory_bytes: 384
fun main(args: Array<String>) {
    abc085c()
}

fun abc085c() {
    val (n, y) = readLine()!!.split(" ").map { it.toInt() }

    for (y10000 in 0..n) {
        for (y5000 in 0..n - y10000) {
            val y1000 = n - y5000 - y10000
            if (y10000 * 10000 + y5000 * 5000 + y1000 * 1000 == y) return println("$y10000 $y5000 $y1000")
        }
    }

    println("-1 -1 -1")
}


Measured memory_bytes: 37864
n, k = list(map(int, input().split()))

p = int((n - 2) / 11)
c = p * 5
for i in range(2 + p * 11 , n):
    for j in range(2, 7):
        if (7 * i + j - 7) * 9 % 11 == k:
            c += 1

print(c)

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

using namespace std;

using ll = long long;
using ld = long double;
using D = double;
using uint = unsigned int;
template<typename T>
using pair2 = pair<T, T>;

#ifdef WIN32
    #define LLD "%I64d"
#else
    #define LLD "%lld"
#endif

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

const int maxn = 100005;

pair2<int> a[maxn];
int n;

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a[i].se);
        a[i].fi = 1;
    }
    int answer = 0;
    while (true)
    {
        bool open = false;
        bool was = false;
        for (int i = 0; i < n; i++)
        {
            if (a[i].fi >= a[i].se)
            {
                open = false;
            } else if (a[i].fi * 2 <= a[i].se)
            {
                if (!open)
                {
                    was = true;
                    open = true;
                    answer++;
                }
                a[i].fi *= 2;
            } else
            {
                if (!open)
                {
                    was = true;
                    open = true;
                    answer++;
                } else open = false;
                a[i].fi *= 2;
            }
        }
        if (!was) break;
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 1152
n=int(input())
W=[input() for i in range(n)]
W_s=set(W)

if len(W) !=  len(W_s):
  print('No')
  exit()

for i in range (1, len(W)):
  if W[i][0] == W[i-1][-1]:
    continue
  else:
    print('No')
    exit()
print('Yes')


Measured memory_bytes: 3060
#include <iostream>
#include <string>

using namespace std;

int main()
{
    int P, Q, R;
    cin >> P >> Q >> R;

    int PQ = P + Q;
    int QR = Q + R;
    int RP = R + P;

    cout << min(min(PQ, QR), RP) << endl;

    return 0;
}

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

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

    vector<string> str(n);
    for(int i=0; i<n; i++){
        cin >> str[i];
    }
    sort(str.begin(), str.end());

    for(int i=0; i<n; i++){
        cout << str[i] ;
    }
    cout<<endl;

}


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

const ll INF = 1LL<<60;

template<typename T> struct SegmentTree {
    int size;
    vector<T> data;
    const function<T(T, T)> func;
    const T unit;
    // u: unit (+ => 0, xor => 0, min => INF, max => -INF)
    SegmentTree(int sz, const T& u, const function<T(T, T)> f) : unit(u), func(f) {
        size = 1;
        while ( size < sz ) size *= 2;
        data.assign(size * 2, unit);
    }
    SegmentTree(vector<T>& v) : SegmentTree<T>((int)v.size(), -INF, [](ll a, ll b) {return max(a,b);}) {
        for ( int i = 0; i < v.size(); i++ ) InitSet(i, v[i]);
        InitBuild();
    }
    void InitSet(int i, const T& a) {
        data.at(i + size - 1) = a;
    }
    void InitBuild() {
        for ( int i = size - 2; i >= 0; i-- ) {
            data.at(i) = func( data.at(i * 2 + 1), data.at(i * 2 + 2) );
        }
    }
    void Update(int i, const T& a) {
        i += size - 1;
        data.at(i) = a;
        while ( i > 0 ) {
            i = (i - 1) / 2;
            data.at(i) = func( data.at(i * 2 + 1), data.at(i * 2 + 2) );
        }
    }
    // [a, b)の値を取得
    T Query(int a, int b) {
        return query(a, b, 0, 0, size);
    }
private:
    // [a, b)の値を取得
    T query(int a, int b, int k, int l, int r) {
        if ( r <= a || b <= l ) {
            return unit;
        } else if ( a <= l && r <= b ) {
            return data[k];
        } else {
            T x1 = query( a, b, k * 2 + 1, l, ( l + r ) / 2 );
            T x2 = query( a, b, k * 2 + 2, ( l + r ) / 2, r );
            return func(x1, x2);
        }
    }
};


ll solve() {
    ll N;
    cin >> N;
    vector<ll> H(N), A(N);
    for ( int i = 0; i < N; i++ ) cin >> H[i];
    for ( int i = 0; i < N; i++ ) cin >> A[i];
    
    SegmentTree<ll> seg(N+1, 0, [](ll a, ll b) {return max(a,b);});
    seg.InitBuild();
    
    for ( int i = 0; i < N; i++ ) {
        ll m = seg.Query(0, H[i]);
        seg.Update(H[i], m + A[i]);
    }
    ll ans = seg.Query(0,N+1);
    return ans;
}

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

Measured memory_bytes: 7424
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <iomanip>
//#include <unordered_map>
//#include <unordered_set>
using namespace std;
#define fi first
#define se second
#define ll long long
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define mem(a,b) memset(a,b,sizeof(a))
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
const int INF = 0x3f3f3f3f;



int main() {
	
	char a;
	scanf("%c",&a);
	printf("%c",a+1);







	return 0;
}


Measured memory_bytes: 256
void main()
{
    long n = readln.chomp.to!long;
    long[] a = readln.split.to!(long[]);

    long[] b = new long[n+2];
    foreach (i; 1 .. n+1)
    {
        b[i] = a[i-1];
    }

    long total;
    foreach (i; 1 .. n+2)
    {
        total += abs(b[i] - b[i-1]);
    }

    foreach (i; 1 .. n+1)
    {
        writeln(total - abs(b[i]-b[i-1]) - abs(b[i+1]-b[i]) + abs(b[i+1]-b[i-1]));
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 5112
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int gcd(int a,int b){//a<=b
	if(a>b)swap(a,b);
	b=b%a;
	if(b==0)return a;
	return gcd(b,a);
}

int a[100007];
int main(){
	int n,m;
	int b,c;
	int g=0;
	int i,j,k;
	cin>>n>>m;
	for(i=0;i<n;i++){
		cin>>a[i];
		if(g==0)g=a[i];
		else g=gcd(g,a[i]);
	}
	b=m%g,c=0;
	for(i=0;i<n;i++){
		if(b==a[i]%g && a[i]>=m){
			c=1;
			break;
		}
	}
	if(c==1)cout<<"POSSIBLE"<<endl;
	else cout<<"IMPOSSIBLE"<<endl;
	return 0;
}


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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define debug if(true)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int main(){
	int a,b,i;
	cin>>a>>b;
	string satu, dua;
	char a1 = a+'0', a2 = b+'0';
	// cout<<a1<<" "<<a2<<endl;
	for(i=0;i<a;i++){
		dua.pb(a2);
	}
	for(i=0;i<b;i++){
		satu.pb(a1);
	}
	if(satu < dua){
		cout<<satu<<endl;
	}else{
		cout<<dua<<endl;
	}
	return 0;
};

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;

const ll MAX = 510000;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
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;}

int main()
{
    int n;
    cin >> n;
    ll maxtasu=-2000000000;ll mintasu=2000000000;
    ll maxhiku=-2000000000;ll minhiku=2000000000;
    REP(i,n){
        ll x,y;
        cin >> x >> y;
        chmax(maxtasu,x+y);chmin(mintasu,x+y);
        chmax(maxhiku,x-y);chmin(minhiku,x-y);
    }
    ll ans=maxtasu-mintasu;
    if(ans<maxhiku-minhiku){
        ans=maxhiku-minhiku;
    }
    cout << ans << endl;
}


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

//FILE *fin = freopen("c.in", "r", stdin);

int h, w;

ll ans;

void check(int h, int w)
{
    for (int i = 1; i <= h / 3 + 1 && i < h; ++ i)
    {
        ll p1 = 1LL * (h - i) / 2 * w, p2 = 1LL * (h - i + 1) / 2 * w;
        ans = min(ans, max(p2 - p1, max(abs(w * i - p1), abs(w * i - p2))));

        p1 = 1LL * (h - i) * (w / 2);
        p2 = 1LL * (h - i) * ((w + 1) / 2);
        ans = min(ans, max(p2 - p1, max(abs(1LL * w * i - p1), abs(1LL * w * i - p2))));
    }
}

int main()
{
    scanf("%d %d", &h, &w);
    if (h % 3 == 0 || w % 3 == 0)
        printf("0\n");
    else
    {
        ans = 1LL * h * w;
        check(h, w);
        check(w, h);
        printf("%lld\n", ans);
    }
    return 0;
}


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

int main(void){
    int n,d,x; cin >> n >> d >> x;
    vector<int>a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    int cnt = x;
    for(int i=0;i<n;i++){
        int day = 1;
        while(day<=d){
            cnt++;
            day += a[i]; 
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
void ABC120(void);
void ABC121(void);
void ABC122(void);
void ABC123(void);
void ABC124(void);
void ABC125(void);
void ABC126(void);
void ABC127(void);
void ABC128(void);
void ABC129(void);

int main(void){
    ABC121();
}

void ABC121(){
    int H,W,h,w;
    cin>>H>>W>>h>>w;
    cout<<(H-h)*(W-w)<<endl;
}

Measured memory_bytes: 256
from collections import Counter
n = int(input())
A = tuple(map(int, input().split()))
C = Counter(A)
A = list(set(A))
ok = [True] * (10**6+1)

for a in A:
    temp = a+a
    while temp < 10**6+1:
        ok[temp] = False
        temp += a

c = 0
for a in A:
    if C[a] == 1 and ok[a] == True:
        c += 1
print(c)


Measured memory_bytes: 45116
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 29;
 
int main() {
	char maze[102][102];
	int h, w;
	cin >> h >> w;
	rep(i, h) rep(j, w) cin >> maze[i][j];

	rep(i, w+2) cout << '#';
	cout << endl;
	rep(i, h) {
		cout << '#';
		rep(j, w) {
			cout << maze[i][j];
		}
		cout << '#' << endl;
	}
	rep(i, w+2) cout << '#';
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

import java.lang.*;

import java.math.*;



public class Main {

	Scanner sc = new Scanner(System.in);



	void run() {

		for (;;) {

			int n = sc.nextInt();

			if (n == 0) {

				break;

			}



			int l[] = new int[n+1];

			for (int i = 1; i < n+1; i++) {

				l[i] = sc.nextInt();

			}



			int res = 0;

			int rea = 0;

			int rec = 0;

			double max = -Double.MAX_VALUE;

			BigInteger min = null;

			for (int s = 0; s <= 15; s++) {

				for (int a = 0; a <= 15; a++) {

					for (int c = 0; c <= 15; c++) {

						boolean spd = false;

						if(s == 8 && a==7 && c == 14){

					//		spd = true;

						}

						if(s == 1 &&a == 7 &&c==12){

					//		spd = true;

						}



						int hash[] = new int[256];



						int[] r = new int[n + 1];

						r[0] = s;

						for (int i = 0; i < n; i++) {

							if(spd){

								System.out.println((r[i]+l[i])&255);

							}

							r[i + 1] = (a * r[i] + c) & (255);

							hash[(r[i+1]+l[i+1])&255 ]++;

						}



						BigInteger bi = BigInteger.ONE;

						for (int i = 0; i < 256; i++) {

							if (hash[i] != 0) {

								bi = bi.multiply(BigInteger.valueOf(hash[i]).pow(hash[i]));

							}

						}

						if(min == null){

							min = bi;

						}

						if(spd){

							System.out.println(bi);

						}

						if(min.compareTo(bi)<0){

							min = bi;

							res = s;

							rea = a;

							rec = c;

						}

					}

				}

			}

			System.out.println(res+" "+rea+" "+rec);

		}



	}



	public static void main(String[] args) {

		Main m = new Main();

		m.run();

	}

}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1e9 + 7;

int dp[100010];

signed main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];
    sort(a.begin(), a.end());
    dp[0] = 1;
    rep(i, 1, n){
        int idx = lower_bound(a.begin(), a.end(), a[i] - k) - a.begin();
        dp[i] = (dp[i - 1] * (i - idx + 1)) % mod;
    }
    cout << dp[n - 1] << endl;
}


Measured memory_bytes: 4416
//
//  frog1.cpp
//  
//
//  Created by David Sarpong on 4/24/20.
//

#include <stdio.h>
#include <iostream>
#include <climits>
using namespace std;
typedef long long int ll;



int main(int argc, char** argv) {
    int N;
    cin >> N;
    
    int h[N + 2];
    for(int i = 1; i <= N; i++) {
        cin >> h[i];
    }
        
    int stone[N + 2];
    stone[N] = 0;
    stone[N + 1] = 1000000000;
    
    for(int i = N - 1; i >= 0; i--) {
        stone[i] = min(stone[i+1] + abs(h[i+1] - h[i]), stone[i+2] + abs(h[i+2] - h[i]));
    }
    
    cout << stone[1] << endl;
    return 0;
}
    



Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <cmath>
#define REP(i, n) for(int i = 0; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define RSORT(x) sort(x.begin(), x.end(), std::greater<int>())
#define swap(a, b) \
  do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0)
#define vi vector<int>
using namespace std;

const double EPS = 1e-10;
const double PI  = acos(-1.0);

int main() {

  int n;
  cin >> n;
  vi v;
  REP(i,n) {
    int a;
    cin >> a;
    v.push_back(a);
  }
    
  RSORT(v);

  unsigned long long diff = 0;
  REP(i, v.size()) {
    if(i % 2 == 0) {
      diff += v[i];
    } else {
      diff -= v[i];
    }
  }
  cout << diff << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;

const i64 mod = 1e9 + 7;
i64 ipow(i64 a, i64 b) {
    i64 x = a, y = 1;
    for (; b > 0; b >>= 1) {
        if (b & 1) (y *= x) %= mod;
        (x *= x) %= mod;
    }
    return y;
}
i64 inv(i64 x) {
    return ipow(x, mod - 2);
}
i64 fact(i64 x) {
    static vector<i64> f;
    i64 i = f.size();
    if (x >= i) {
        f.resize(x + 1);
        for (; i <= x; ++i) {
            f[i] = i == 0 ? 1 : i * f[i - 1] % mod;
        }
    }
    return f[x];
}
i64 perm(i64 n, i64 k) {
    return k <= n ? fact(n) * inv(fact(n - k)) % mod : 0;
}
i64 comb(i64 n, i64 k) {
    return k <= n ? fact(n) * inv(fact(k) * fact(n - k) % mod) % mod : 0;
}
int main() {
    i64 n, k;
    cin >> n >> k;
    cout << comb(k, n) << endl;
    return 0;
}


Measured memory_bytes: 3112
N,M=map(int,input().split())
if N==1 and M==1:
    print(1)
if N==1 and M!=1:
    print(M-2)
if M==1 and N!=1:
    print(N-2)
if N!=1 and M!=1:
    print((M-2)*(N-2))

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

#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int

const int maxr = 1e5 + 5;

int arr[maxr];
int32_t main()
{
	GO;
	int n;
	cin >> n;
	map<int, int> mp;
	int sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
		mp[arr[i]]++;
		sum += arr[i];
	}
	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		int b, c;
		cin >> b >> c;
		sum -= mp[b] * b;
		sum += mp[b] * c;
		mp[c] += mp[b];
		mp[b] = 0;
		cout << sum << endl;
	}
	return 0;
}

//!

Measured memory_bytes: 10344
N, k, l = map(int, input().split())

# UF木
class Uf:
    def __init__(self):
        self.Par = list(range(N + 1))

    def root(self, x):
        if self.Par[x] == x:
            return x
        else:
            self.Par[x] = self.root(self.Par[x])
            return self.Par[x]

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x != y:
            self.Par[x] = y


K = Uf()
L = Uf()
for i in range(k):
    K.unite(*map(int, input().split()))
for i in range(l):
    L.unite(*map(int, input().split()))
U = [[i, K.root(i), L.root(i)] for i in range(1, N+1)]
from operator import itemgetter
U.sort(key=itemgetter(1, 2))
i = 0
while i < N:
    n = 1
    while i+n < N:
        if U[i+n][1:3] == U[i][1:3]:
            n += 1
        else:
            break
    for j in range(n):
        U[i+j].append(n)
    i += n
U.sort(key=itemgetter(0))
A = [u[3] for u in U]
print(" ".join(map(str, A)))


Measured memory_bytes: 63688
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    double n;cin>>n;
    vector<vector<vector<double> > >dp(910,vector<vector<double> >(310,vector<double>(310)));
    dp[0][0][0]=1.0;
    ll x=0,y=0,z=0;
    rep(i,n){
        ll a;cin>>a;
        if(a==1)x++;
        if(a==2)y++;
        if(a==3)z++;
    }
    double ans=0.0;
    rep(i,x+y*2+z*3){
        rep(j,310){
            rep(k,310){
                if(dp[i][j][k]==0.0)continue;
                double l=i-j-k;
                //cout<<i<<' '<<j<<' '<<k<<':'<<dp[i][j][k];
                if(l<0)continue;
                double f3=z-j;
                double f2=y+j-k;
                double f1=x+k-l;
                double f0=l;
                dp[i+1][j+1][k]+=dp[i][j][k]*(f3/(n-f0));
                dp[i+1][j][k+1]+=dp[i][j][k]*(f2/(n-f0));
                dp[i+1][j][k]+=dp[i][j][k]*(f1/(n-f0));
            }
        }
        //cout<<endl;
        rep(j,310){
            rep(k,310){
                if(dp[i][j][k]==0.0)continue;
                double l=i-j-k;
                if(l<0)continue;
                double f3=z-j;
                double f2=y+j-k;
                double f1=x+k-l;
                double f0=l;
                double b=f1+f2+f3;
                if(b==0)continue;
                ans+=dp[i][j][k]*n/b;
            }
        }
    }
    cout<<setprecision(16)<<ans<<endl;
}

Measured memory_bytes: 695296
X = int(input())

if X >= 400 and X <= 599:
  print(8)
elif X >= 600 and X <= 799:
  print(7)
elif X >= 800 and X <= 999:
  print(6)
elif X >= 1000 and X <= 1199:
  print(5)
elif X >= 1200 and X <= 1399:
  print(4)
elif X >= 1400 and X <= 1599:
  print(3)
elif X >= 1600 and X <= 1799:
  print(2)
elif X >= 1800 and X <= 1999:
  print(1)

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

template <class T> using V = vector<T>;
template <class S, class T> using P = pair<S, T>;
template <class... T> using TP = tuple<T...>;

using ll = long long;
using db = double;
using ldb = long db;
using str = string;
using vll = V<ll>;
using vvll = V<V<ll>>;
using pll = P<ll,ll>;
using tpll = TP<ll,ll,ll>;
using vpll =V<pll>;
using vst = V<str>;
using vch = V<char>;

#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl
#define ci(a) cin>>a
#define pb(a) push_back(a)
#define pob pop_back()
#define mp make_pair
#define mt make_tuple
#define pbmp(a,b) push_back(mp(a,b))
#define subs(a,b) substr(a,b)
#define cfs(a) cout<<fixed<<setprecision(a)
#define INF 1e16
#define mod 1e9+7
//vvll v(n,vll(m)) n行m列
//A.erase(A.begin()+i) 配列Aのi番目を消せる
//std::binary_search(v.bgn,v.en,a);
//abs(a,b)   pow(a,n)  to_string  stoll
//auto Iter=lower_bound(v.bgn,v.en,a);
//lower//upper  co(*Iter)co(Iter-v.bgn);

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
#define comuse Comuse()
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  ll n;
  cin>>n;
  vst s(n);
  FOR(i,0,n){
    cin>>s[i];
  }
 /* vll v(26);
  vst st(n);
  vll count(n);
  ll m=0;
  str tst;
  FOR(i,0,n){
    m=s[i].sz;
    FOR(j,0,m){
      v[s[i]-'a']++;
    }
    FOR(j,0,26){
    }
    */
  ll count=1;
  ll ans=0;
  FOR(i,0,n){
    SORT(s[i]);
  }
  SORT(s);
  FOR(i,0,n-1){
    if(s[i]==s[i+1]){
      FOR(j,i,n-1){
        if(s[j]==s[j+1]){
          count++;
          i++;
        }
        if(s[j]!=s[j+1]||j+1==n-1){
          ans+=count*(count-1)/2;
          count=1;
          break;
        }
        //co(count);
      }
    }
   // co(count);
    //co(ans);
  }
  co(ans);
}


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


auto solve(std::string s){
    auto bi = find(begin(s), end(s), 'A');
    auto ei = find(rbegin(s), rend(s), 'Z');
    return s.size() - distance(begin(s), bi) - distance(rbegin(s), ei);
}

int main(){
    std::string s;
    std::cin >> s;
    auto result = solve(s);
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 772
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    int n, m, q;
    cin >> n >> m >> q;
    int dp[n + 1][n + 1];
    memset(dp, 0x00, sizeof(dp));
    int l, r;
    rep (i, m)
    {
        cin >> l >> r;
        dp[l][r] += 1;
    }

    rep (i, n + 1) rep (j, n) dp[i][j + 1] += dp[i][j];
    for (int i = n - 1; i >= 0; --i) rep (j, n + 1) dp[i][j] += dp[i + 1][j];

    rep (i, q)
    {
        cin >> l >> r;
        cout << dp[l][r] << "\n";
    }

    return 0;
}



Measured memory_bytes: 1920
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <string>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <iomanip> // setprecisionを使用するのに必要 cout << fixed << setprecision(15) << p でpを小数点以下15桁表示
using namespace std;
#define REPD(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) REPD(i, 0, n)
typedef long long ll;
#define fin(ans) cout << (ans) << '\n'
/*

*/
int main()
{
    int N;
    cin >> N;
    ll a[N];
    ll sums = 0,suma = 0;
    ll ans = 100000000000000000;
    REP(i,N){
        cin >> a[i];
        suma += a[i];
    }
    //sumaが全部の輪。sumsに足しながら引いていく。最低でも1つ選ばなくてはならないのでそうする。
    sums += a[0];
    suma -= a[0];
    ans = min(ans,abs(sums-suma));

    REPD(i,1,N-1){
        sums += a[i];
        suma -= a[i];
        ans = min(ans,abs(sums-suma));
    }
    fin(ans);
    return 0;
}

Measured memory_bytes: 1792
H, W, M = map(int, input().split())

HL, WL = [0]*H, [0]*W
B = []

for _ in range(M):
  h, w = map(lambda x:int(x)-1, input().split())
  B.append((h, w))
  HL[h] += 1
  WL[w] += 1

HM, WM = max(HL), max(WL)
K = HL.count(HM) * WL.count(WM)

cnt = 0
for h, w in B:
  if HL[h] == HM and WL[w] == WM:
    cnt += 1

if K > cnt:
  print(HM+WM)
else:
  print(HM+WM-1)


Measured memory_bytes: 54276
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 87, MOD = 1e9 + 7;
vector<int> g[N];
long long dp[N][2];
void dfs(int u,int p)
{
    dp[u][0] = dp[u][1] = 1;
    for (int v : g[u])
        if (v != p) {
            dfs(v, u);
            (dp[u][0] *= (dp[v][0] + dp[v][1])) %= MOD;
            (dp[u][1] *= dp[v][0]) %= MOD;
        }
}
int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n - 1; ++i) {
        int x, y;
        cin >> x >> y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    dfs(1, 1);
    cout << (dp[1][0] + dp[1][1]) % MOD << endl;
}


Measured memory_bytes: 14208
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";


int main() {
    cin>>A>>B;
    cout<<max({A*2-1,B*2-1,A+B})<<endl;
}

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

int main() {
  int c[9];
  rep(i, 9) cin >> c[i];
  if (c[0]-c[1] != c[3]-c[4] || c[0]-c[1] != c[6]-c[7]) cout << "No" << endl;
  else if (c[0]-c[2] != c[3]-c[5] || c[0]-c[2] != c[6]-c[8]) cout << "No" << endl;
  else if (c[0]-c[3] != c[1]-c[4] || c[0]-c[3] != c[2]-c[5]) cout << "No" << endl;
  else if (c[0]-c[6] != c[1]-c[7] || c[0]-c[6] != c[2]-c[8]) cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
// ConsoleApplication72.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

// ConsoleApplication71.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include<algorithm>
#include<iomanip>
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<set>
using namespace std;
int a[10];
int main()
{
	int n,lala=0;
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 1; i < n - 1; i++)
	{
		if (((a[i] < a[i + 1]) && (a[i] > a[i - 1])) || ((a[i] > a[i + 1]) && (a[i] < a[i - 1])))
		{
			lala++;
		}
	}
	cout << lala << "\n";
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
  int HP,Extrakind;
  
  cin >>HP >> Extrakind;
  int Extra[Extrakind];
  
  for(int i = 0;Extrakind > i;i++){
    cin >> Extra[i];
  }
  
  int ans = 0;
  int used = 0;
  int n1,n2,sum;
  sum = 0;
  n1 = 0;
  n2 =0;
  for(int i = 0;Extrakind > i;i++){
    sum+=Extra[i];
  }

  if(HP <=sum){
  	cout << "Yes";
  }else if(HP > sum){
    cout << "No";
  }
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef long long ll;

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

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

	int n;

	while(1){
		scanf("%d", &n);
		if(n==0)	break;

		int Dice[3]={1, 2, 3};
		char str[10];
		int sum=1;

		while(n--){
			scanf("%s", str);
			int temp = Dice[0];

			switch (str[0]) {
				case 'N':{
					Dice[0]=Dice[1];
					Dice[1]=7-temp;
					break;
				}
				case 'S':{
					Dice[0]=7-Dice[1];
					Dice[1]=temp;
					break;
				}
				case 'E':{
					Dice[0]=7- Dice[2];
					Dice[2]=temp;
					break;
				}
				case 'W':{
					Dice[0]=Dice[2];
					Dice[2]=7-temp;
					break;
				}
				case 'R':{
					temp=Dice[1];
					Dice[1]=Dice[2];
					Dice[2]=7-temp;
					break;
				}
				case 'L':{
					temp=Dice[1];
					Dice[1]=7-Dice[2];
					Dice[2]=temp;
					break;
				}
				default: break;
			}

			sum+=Dice[0];
		}
		printf("%d\n", sum);
	}

}

Measured memory_bytes: 3156
#include<bits/stdc++.h>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/assoc_container.hpp>
#include<chrono>
using namespace std;
using namespace std::chrono;
//using namespace __gnu_pbds;
#define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fi         first
#define se         second
#define int         long long
#define pb         push_back
#define emp        emplace_back
#define vv(x)      vector<x>
#define mp(x,y)    map<x,y>
#define dq(x)      deque<x>
#define pql(x)     priority_queue<x>
#define pqs(x)     priority_queue<x,vv(x),greater<x> >
#define mod         1000000007
#define forf(i,a,b) for(int i=a;i<b;i++)
#define it(x)      x::iterator
#define ll         long long
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
#define vii        vector<int>
#define big        3e18
#define sm         -2e9
#define mkr        make_pair
#define vpi        vector<pair<int,int> >
#define pii        pair<int,int>
#define rng        500005
#define sz(x)      (int)x.size()
#define rv(x)      reverse(x.begin(),x.end())
#define out(x)     cout<<x.fi<<" "<<x.se<<endl;
 
//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
 
void pr_init()
{
 
#ifndef ONLINE_JUDGE
  freopen("gin.txt", "r", stdin);
  //freopen("gout.txt", "w", stdout);
#endif
}


char roll(char x,int y)
{
  if(('Z'-x) >= y) return (x+y);
  else return('A'+y-('Z'-x) - 1);
}
void solve()
{
  
  int n;
  cin >> n;
  string s;
  cin >> s;

  for(int i=0;i<sz(s);i++)
  {
    s[i] = roll(s[i],n);
  }

  cout<<s;
}
 
 
int32_t main()
{
  pr_init();
  fastio;
   
  
  solve();
   
}
 


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

int main() {
  int N;
  cin >> N;
  vector<pair<int, int>> X(N);
  for (int i = 0; i < N; i++) {
    cin >> X[i].first;
    X[i].second = i;
  }
  sort(X.begin(), X.end());
  set<int> mid_left;
  for (int i = 0; i < N/2; i++) mid_left.insert(X[i].second);
  for (int i = 0; i < N; i++) {
    if (mid_left.count(i)) cout << X[N/2].first << endl;
    else cout << X[N/2-1].first << endl;
  }
}


Measured memory_bytes: 9448
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>

using namespace std;

long GCD(long a, long b){
    long c=a%b;
    if(c == 0){return b;}
    return GCD(b,c);
}


int main(){
    long A, B;
    cin >> A>>B;
    if(A < B){
        long tmp = B;
        B=A;
        A=tmp;
    }
    long gcd = GCD(A,B);
    int cnt=1;
    long i=2;
    while(gcd >= i*i){
        if(gcd % i == 0){
            while(gcd % i == 0){
                gcd /= i;
            }
            cnt++;
        }
        i++;
    }
    if(gcd != 1){cnt++;}
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
 

N=int(input())
p=list(map(int,input().split()))
cnt=0

m=10**6
for k in range(N):
	m=min(m,p[k])
	if m==p[k]:
		cnt+=1

print(cnt)

Measured memory_bytes: 24744
package main

import(
  "fmt"
  "os"
  "bufio"
  "strconv"
)

func main() {
  var n int
  fmt.Scan(&n)
  a := readLineNums(n)
  b := make([]bool, n)
  b[0] = true
  k := 0
  ok := false
  ans := 0
  for {
    ans += 1
    k = a[k] - 1
    if k == 1 {
      ok = true
      break
    }
    if b[k] {
      break
    }
    b[k] = true
  }
  if ok {
    fmt.Print(ans)
  } else {
    fmt.Print(-1)
  }
}

var sc = bufio.NewScanner(os.Stdin)
func nextLine() string {
    sc.Scan()
    return sc.Text()
}

func readLineNums(len int) (nums []int){
    for i:=0; i<len; i++{
        tmp,_ := strconv.Atoi(nextLine())
        nums = append(nums,tmp)
    }
    return
}


Measured memory_bytes: 6016
N, M = gets.chomp.split(' ').map(&:to_i)
input = Array.new(N) { gets.chomp.split(' ').map(&:to_i) }
ans = 0
(1..M).each do |i|
  count = 0
  input.each do |j|
    count += 1 if j[1..-1].include?(i)
  end
  ans += 1 if count == N
end
puts ans


Measured memory_bytes: 1788
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

import java.util.*;

public class Main {
    long MOD = (long) 1e9 + 7;

    InputStream in;
    OutputStream out;

    public Main() {
        this(System.in, System.out);
    }

    public Main(InputStream in, OutputStream out) {
        this.in = in;
        this.out = out;
    }

    void run() {
        Scanner sc = new Scanner(this.in);
        PrintWriter out = new PrintWriter(this.out);

        // write your code
        int n = sc.nextInt();
        int[] xs = new int[n], ys = new int[n];
        for (int i = 0; i < n; i++) {
            xs[i] = sc.nextInt();
            ys[i] = sc.nextInt();
        }

        Permutation per = new Permutation(n);

        int cnt = 0;
        double len = 0;
        while (per.hasNext()) {
            int[] cur = per.next();
            for (int i = 0; i < n - 1; i++) {
                len += dist(xs[cur[i]], ys[cur[i]], xs[cur[i + 1]], ys[cur[i + 1]]);
            }
            cnt++;
        }

        out.println(len / cnt);
        out.flush();
    }

    double dist(int x1, int y1, int x2, int y2) {
        double dx = x1 - x2;
        double dy = y1 - y2;
        return Math.sqrt(dx * dx + dy * dy);
    }

    public class Permutation implements Iterator<int[]> {
        private final int size;

        public Permutation(int size) {
            if (size <= 0) throw new IllegalArgumentException();
            this.size = size;
            source = new int[size];
            for (int i = 0; i < size; i++) {
                source[i] = i;
            }
        }

        public Permutation(int size, int[] source) {
            this(size);
            this.source = source;
        }

        int[] source;
        boolean isFirst = true;

        public boolean hasNext() {
            if (isFirst) {
                isFirst = false;
                return true;
            }

            int n = source.length;
            for (int i = n - 1; i > 0; i--) {
                if (source[i - 1] < source[i]) {
                    int j = n;
                    while (source[i - 1] >= source[--j]);
                    swap(source, i - 1, j);
                    reverse(source, i, n);
                    return true;
                }
            }
            reverse(source, 0, n);
            return false;
        }

        public int[] next() {
            return source;
        }

        private void swap(int[] is, int i, int j) {
            int t = is[i];
            is[i] = is[j];
            is[j] = t;
        }

        private void reverse(int[] is, int s, int t) {
            while (s < --t) swap(is, s++, t);
        }
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

Measured memory_bytes: 22480
#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 s[25][25];

int bfs(int v, int h, int w) {
  int n = h * w;
  vector<int> d(n, INF);
  d[v] = 0;

  queue<int> q;
  q.push(v);

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

    int i = u / w, j = u % w;
    auto f = [w](int a, int b) { return a * w + b; };

    vector<int> to;
    if (i - 1 >= 0) to.push_back(f(i - 1, j));
    if (j + 1 < w) to.push_back(f(i, j + 1));
    if (i + 1 < h) to.push_back(f(i + 1, j));
    if (j - 1 >= 0) to.push_back(f(i, j - 1));

    for (auto t : to) {
      int a = t / w, b = t % w;
      if (s[a][b]) continue;
      if (d[t] != INF) continue;
      d[t] = d[u] + 1;
      q.push(t);
    }
  }

  int mx = 0;
  rep(i, n) {
    if (d[i] == INF) continue;
    mx = max(mx, d[i]);
  }
  return mx;
}

int main() {
  int h, w;
  cin >> h >> w;
  rep(i, h) rep(j, w) {
    char a;
    cin >> a;
    if (a == '.')
      s[i][j] = 0;
    else
      s[i][j] = 1;
  }

  int ans = 0;
  rep(i, h) {
    rep(j, w) {
      if (s[i][j]) continue;
      int v = i * w + j;
      int mx = bfs(v, h, w);
      ans = max(ans, mx);
    }
  }

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


Measured memory_bytes: 384