akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <boost/range.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/algorithm_ext.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>
#include <boost/math/constants/constants.hpp>
using namespace std;
namespace rng {
    using namespace boost::range;
    using namespace boost::adaptors;
}

struct init_ { init_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } init_;

using boost::irange;
using boost::math::double_constants::pi;
using i64 = int64_t;
constexpr char nl = '\n';
auto yesno(bool b) { return b ? "Yes" : "No"; }

template<class T> istream& operator>>(istream& in, vector<T>& vs) { for (T& v :vs) in >> v; return in; }
template<class T> ostream& operator<<(ostream& out, const vector<T>& vs) { for (size_t i = 0; i < vs.size(); ++i) { if(i) { out << ' '; } out << vs[i]; } return out; }
template<size_t N, class T, class R> using when_last = typename enable_if<N == tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N, class T, class R> using when_init = typename enable_if<N != tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_last<N, T, istream&> { return in >> get<N>(t); }
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_init<N, T, istream&> { return operator>><N + 1>(in >> get<N>(t), forward<T>(t)); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_last<N, T, ostream&> { return out << get<N>(t); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_init<N, T, ostream&> { return operator<<<N + 1>(out << get<N>(t) << ' ', t); }

#ifdef LOCAL
template<class T> void trace_(const T& v) { cout << v; }
template<class T> void trace_(const vector<vector<T>>& m) { cout << nl; for (const auto& v : m) { trace_(v); cout << nl; } }
template<class T> void trace_(const char* s, const T& v) { cout << s << "="; trace_(v); cout << nl; }
template<class T, class... Ts> void trace_(const char* s, const T& v, const Ts&... vs) { for (; *s != ','; ++s) { cout << *s; } cout << "="; trace_(v); trace_(s, vs...); }
#define TRACE(...) trace_(#__VA_ARGS__, __VA_ARGS__)
#else
#define TRACE(...)
#endif

int main() {
    i64 N;
    cin >> N;
    i64 ans = numeric_limits<i64>::max();
    for (i64 i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            i64 j = N / i, ij = (i - 1) + (j - 1);
            if (ij < ans) ans = ij;
        }
    }
    cout << ans << nl;
}


Measured memory_bytes: 256
cooking_time = []
5.times do
    cooking_time.push(gets.chomp.to_i)
end

last = 10
last_order = 0
5.times do |i|
    if cooking_time[i] % 10 < last and cooking_time[i] % 10 != 0
        last = cooking_time[i] % 10
        last_order = i
    end
end

ans = 0
5.times do |i|
    if i == last_order
        next
    end
    ans += cooking_time[i]
    if ans % 10 != 0
        ans += (10 - ans % 10)
    end
end

ans += cooking_time[last_order]

puts ans


Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#define int long long
#define double long double
using namespace std;

signed main() {
	int n, t, a;
	cin >> n >> t >> a;
	vector<int> h;
	for (int i = 0; i < n; i++) {
		int in;
		cin >> in;
		h.push_back(in);
	}
	int ans = 0;
	double p = abs(t - h[0]*0.006 - a);
	for (int i = 1; i < n; i++) {
		double q = abs(t - h[i]*0.006 - a);
		if (q < p) {
			p = q;
			ans = i;
		}
	}
	cout << ans + 1 << endl;
}


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

int main() {
    int n, cl, x=8;
    cin >> cl;

    for (int i = 400; i < 2000; i += 200) {
        if (i <= cl && cl < i + 200)
            cout << x << endl;
        else x--;
    }

    
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define rep(i, from, to) for (int i = from; i < to; i++)
typedef long long ll;
int main()
{
  string s;
  cin >> s;
  ll ans = stoll(s);
  for (int i = 0; i + 3 <= s.size(); i++)
  {
    string t = s.substr(i, 3);
    ll tnum = stoll(t);
    ll dif = abs(tnum - 753);
    ans = min(ans, dif);
  }
  cout << ans << endl;
  return 0;
}


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

cnt=[0]*60
p=10**9+7
for m in a:
    #b=bin(m)
    #l=len(b)-2
    #print(b)
    for i in range(60):
        if((m>>i) & 1):
            cnt[i]+=1
    #for i in range(l):
    #    cnt[i]+=int(b[-i-1])
    #kei=m
    #for i in range(100):
    #    cnt[i]+=kei%2
    #    kei//=2
    #    if(kei==0):
    #        break

#print(cnt)

lis=[]
jou=1
for i in range(60):
    lis.append(jou)
    jou*=2
    jou%=p

ans=0

for i in range(60):
    ans+=(lis[i]%p)*(cnt[i]%p)*((n-cnt[i])%p)
    ans%=p

print(ans)

Measured memory_bytes: 122808
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define PI (acos(-1))
#define ct cout<<
#define cn cin>>
#define spc <<" "<<
#define nl puts("")
#define _fl(x) puts("FLAG " #x);
#define  _(x)  cout<< #x <<" is "<< x <<endl;
#define fs first
#define sc second
#define pb push_back
#define all(v)  (v).begin(), (v).end()
#define _109 (1000000000)
#define _0(arr) memset(arr,0,sizeof ( arr ) )
#define _1(arr) memset(arr,-1,sizeof ( arr ) )
#define _ninp(n,arr) for(int i=0; i<n;i++)cin>>arr[i];
#define _nout(n,arr) for(int i=0; i<n;i++)cout<<arr[i]<<" \n"[i==n-1];
double _eps = 1e-6;
long long gcd(long long a, long long b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

int main()
{

    vector<string>v;

    for (int i = '0'; i <= '9' ; ++i)
    {
        for (int j = '0'; j <= '9'; ++j)
        {
            for (int k = '0'; k <= '9' ; ++k)
            {
                string s;
                s.pb(i);
                s.pb(j);
                s.pb(k);
                v.pb(s);
            }
        }
    }

    int n;
    cn n;
    string s;
    getchar();
    cn s;
    vector<int>arr[11];

    for (int i = 0; i < s.size() ; ++i)
    {
        arr[s[i] - '0'].pb(i);
    }

    int cnt = 0;

    for(auto x : v)
    {
        int fst = x[0] - '0', scd = x[1] - '0', thr = x[2] - '0';
        int fsi, sci, thi;



        if(!arr[fst].empty())
        {

            fsi = arr[fst][0];

            if(!arr[scd].empty())
            {

                auto it = upper_bound(all(arr[scd]), fsi);
                if( it!=arr[scd].end() && *it > fsi && !arr[thr].empty())
                {
                    sci = *it;
                    auto it2 = upper_bound(all(arr[thr]), sci);
                    thi = *it2;
                    if( it2!=arr[thr].end() && thi > sci){
                    	cnt++;
                    	// ct x;nl;
                    	// ct fsi<<" "<<sci<<" "<<thi;nl;
                    	// nl;
                    }

                }

            }

        }





    }







ct cnt;nl;




    return 0;
}


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

int main(){
	int n;
	while(scanf("%d", &n) != EOF){
		int *arr = new int[n + 1];
		int loop = (int)sqrt(n);
		
		for(int i = 2; i <= loop; i++){
			if(arr[i] == 0){
				for(int j = 2*i; j <= n; j += i){
					arr[j] = 1;
				}
			}
		}
		
		int cnt = 0;
		for(int i = 2; i <= n; i++){
			if(arr[i] == 0){
				cnt++;
			}
		}
		delete [] arr;
		
		printf("%d\n", cnt);
	}
	return 0;
}

Measured memory_bytes: 5188
S = input()
ans = "Yes"
for i in range(len(S)):
    if i%2 == 0:
        if S[i] != "R" and  S[i] !="U" and S[i] !="D":
            ans ="No"
    if i%2 != 0:
        if S[i] != "L" and  S[i] !="U" and S[i] !="D":
            ans ="No"
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>

int main(int argc, char const *argv[]) {
    int a, b;
    scanf("%d %d", &a, &b);

    if (a < b) {
        printf("a < b\n");
    } else if (a > b) {
        printf("a > b\n");
    } else {
        printf("a == b\n");
    }

    return 0;
}


Measured memory_bytes: 2084
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <math.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
typedef long long ll;

int main() {
  string O, E, out="";
  cin >> O >> E;

  rep(i, O.size())
  {
    if(i+1==O.size() && O.size()>E.size()) {out += O.at(i);}
    else
    {
      out += O.at(i);
      out+= E.at(i);
    }
  }

  cout << out << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    char a[3];
    int i,bill,count=0;
    scanf("%s",a);
    for(i=0;i<3;i++){
       if(a[i]=='o'){
         count++;
       }

    }
    bill=700+count*100;
    printf("%d\n",bill);
    return 0;
}


Measured memory_bytes: 128
#include<string>
#include<algorithm>
#include<iostream>
using namespace std;
struct res
{
	string name;
	int value;
	int seq;
};
bool comp(res a, res b)
{
	if(a.name != b.name)
		return a.name < b.name;
	else
		return a.value > b.value;
}
int main()
{
	int a;
	scanf("%d",&a);
	res arr[a];
	for(int i=0; i<a; i++)
	{
		cin >> arr[i].name >> arr[i].value;
		arr[i].seq = i + 1;
	}
	sort(arr, arr+a, comp);
	for(int i=0; i<a; i++)
		printf("%d\n",arr[i].seq);
	return 0;
}

Measured memory_bytes: 256
import math
X = int(input())


def is_prime(n):
    if n == 1:
        return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True


for i in range(X, 10**7):
    if is_prime(i):
        print(i)
        break


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

#define rp(i, k, n) for (int i = k; i < n; i++)
using ll = long long;
using ld = double;

template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7ll;
// const ll MOD = 998244353;
const double PI=3.14159265358979323846;

int main() {
    int n; cin >> n;
    set<int> A;
    rp(i, 0, n) {
        int a; cin >> a;
        A.insert(a);
    }
    int d = n - (int)A.size();
    cout << n - d - (d%2) << endl;
    return 0;
}


Measured memory_bytes: 8120
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
int main(){
long n,a[10001],sum=0;
cin>>n;
for(int i=0;i<n;i++){cin>>a[i];sum+=a[i];}
sort(a,a+n);
printf("%ld %ld %ld\n",a[0],a[n-1],sum);
return 0;
}

Measured memory_bytes: 1240
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string S;
    cin >> S;
    string ans = "Yes";
    for(int i = 0; i < S.length();i++){
        if(i%2==1){
            if(S[i]=='R')ans ="No";
        }else{
            
            if(S[i]=='L')ans ="No";
        }
        
        
    }
    

    cout << ans << endl;
}


Measured memory_bytes: 256
import sys
import random

def test(K, N, A):
    ans = []
    maxp = N-1
    minp = 0
    for i in range(len(A)):
        ans.append(A[maxp] - A[minp])
        A[i] += K
        maxp = (maxp + 1) % (N)
        minp = (minp + 1) % (N)
    print(min(ans))

if __name__ == "__main__":
    if "random" in sys.argv:
        K = int(random.random() * 20000)
        N = int(random.random() * 65536)
        A = sorted([int(random.random() * K) for _ in range(N)])
    else:
        K, N = [int(x) for x in input().split()]
        A = [int(x) for x in input().split()]
    test(K,N,A)
    pass


Measured memory_bytes: 26828
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vdo=vector<double>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vvdo=vector<vector<double>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using pqin=priority_queue<int>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
int main()
{
    ll n;
    cin>>n;
    ll sum=0;
    for(ll i=1;i<n+1;i++){
        if(i%3!=0&&i%5!=0)sum+=i;
    }
    cout<<sum<<endl;
}

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

int main() {
    int n;
    cin >> n;
    ll sum=0,p=1000000007;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    ll ans=0;
    for(int i = 0; i < n; i++) {
        sum -= a[i];
        ll q=sum % p;
        q *= a[i];
        q %= p;
        ans += q;
        ans %= p;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4764
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-04-05 12:30:48
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n; cin >> n;
  vector<int> a(n + 1);
  for (int i = 1; i <= n; ++i) cin >> a[i];

  vector<int> ans(n + 1, 0);

  for (int i = n; i >= 1; --i) {
    int t = 0;
    for (int j = 0; j < n + 1; j += i) {
      t ^= ans[j];
    }
    if (t != a[i]) ans[i] = 1;
  }

  cout << accumulate(all(ans), int()) << '\n';
  for (int i = 1; i <= n; ++i) {
    if (ans[i]) cout << i << " ";
  }
  cout << '\n';

  return 0;
}

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

//dp[i][j][k] :=???(?????????????????????i(mod2)??§A???????????????j????????§?¬???????k??????????????????????????????
//?????????????????????????§???°???????°??????????) (k==0:A k==1:B)
int dp[2][5010][2];
int main(void){
	int n; cin >> n;
	vector<int> v(n);
	rep(i, n - 1) cin >> v[i];
	rep(i, 2)rep(j, 5010)rep(k, 2)dp[i][j][k] = INF;

	dp[0][0][0] = 0;
	dp[0][0][1] = 0;
	//??????dp
	for (int i = 0; i < n; ++i){
		rep(j, 5010)rep(k, 2)dp[(i + 1) % 2][j][k] = INF;
		for (int j = 0; j <= n / 2; ++j){
			// dp[(i + 1) % 2][j + 1][0] = dp[(i + 1) % 2][j + 1][1] = INF;//????????¨????????????????????????
			// dp[(i + 1) % 2][j][0] = dp[(i + 1) % 2][j][1] = INF;
			for (int k = 0; k < 2; ++k){
				if(dp[i % 2][j][k] == INF) continue;
				//???????????????????????????
				if(k == 0){
					dp[(i + 1) % 2][j + 1][k] = min(dp[(i + 1) % 2][j + 1][k], dp[i % 2][j][k]);
				}else{
					dp[(i + 1) % 2][j][k] = min(dp[(i + 1) % 2][j][k], dp[i % 2][j][k]);
				}
				//?????????????????????
				if(k == 0){
					dp[(i + 1) % 2][j + 1][1] = min(dp[(i + 1) % 2][j + 1][1], dp[i % 2][j][k] + v[i]);
				}else{
					dp[(i + 1) % 2][j][0] = min(dp[(i + 1) % 2][j][0], dp[i % 2][j][k] + v[i]);
				}
			}
		}
	}

	int ans = INF;
	rep(k, 2){
		ans = min(ans, dp[n % 2][n / 2][k]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1312
#include <algorithm>
#include <iostream>
#include <cassert>
#include <vector>

using namespace std;

#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define per(i, a, b) for (auto i = (b) - 1; i >= (a); --i)
#define trav(x, v) for (auto &x : v)

#define sz(x) int((x).size())
#define eb(x...) emplace_back(x)
#define all(x) begin(x), end(x)
#define ff first
#define ss second

using ll = int64_t;

template<class T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

using vi = vector<int>;

constexpr int N = 1 << 17;
int M;
int f[N], h[N];
vi g[N];

void down(int u, int p) {
	f[u] = 1;
	if (p != u) g[u].erase(find(all(g[u]), p));
	trav(v, g[u]) {
		down(v, u);
		f[u] = 1ll * f[u] * (1 + f[v]) % M;
	}
}

void up(int u, int p) {
	int c = sz(g[u]);
	vi s(c + 1, 1); int x = 1;
	per(i, 0, c) s[i] = 1ll * s[i + 1] * (1 + f[g[u][i]]) % M;
	rep(i, 0, c) {
		int v = g[u][i];
		h[v] = 1ll * x * s[i + 1] % M * (1 + h[u]) % M;
		x = 1ll * x * (1 + f[v]) % M;
		up(v, u);
	}
}

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

	int n; cin >> n >> M;
	rep(i, 1, n) {
		int u, v; cin >> u >> v; --u; --v;
		g[u].eb(v); g[v].eb(u);
	}
	down(0, 0);
	up(0, 0);
	rep(u, 0, n) cout << 1ll * f[u] * (1 + h[u]) % M << '\n';
}

Measured memory_bytes: 16384
import java.util.Scanner;

/**
 * Created by yufeng.fyf on 16/10/10.
 */
public class Main {
    private static String temple = "CODEFESTIVAL2016";
    public static void main(String[] args){
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int a = input.nextInt();
        int b = input.nextInt();
        input.nextLine();
        String s = input.nextLine();
        int a_i = 0,b_i = 0;
        for(int i=0;i<n;i++){
            char p = s.charAt(i);
            if(a_i+b_i<a+b){
                if(p=='a'){
                    System.out.println("Yes");
                    a_i++;
                }
                else if(p=='b'){
                    if(b_i<b){
                        System.out.println("Yes");
                        b_i++;
                    }
                    else
                        System.out.println("No");

                }
                else
                    System.out.println("No");
            }
            else
                System.out.println("No");

        }

    }
}


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

using namespace std;
int main(){
    int A,B,C,D;cin>>A>>B>>C>>D;                                                                                     
    int i=1;
    while(true){
        if(i%2==1){
         C -= B;
        }else{
         A -= D;
        }
        if(A<1){ cout << "No" <<endl; break;}
        else if(C < 1){cout << "Yes" <<endl; break;}
        i++;
    }

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n;
ll a[100005];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;
  ll sum = 0;
  ll x_sum = 0;
  REP(i, n) {
    cin >> a[i];
    sum += a[i];
    if(i % 2 == 1) x_sum += a[i] * 2;
  }

  ll x = sum - x_sum;
  cout << x << " ";
  REP(i, n - 1) {
    cout << ((a[i] * 2) - x) << " ";
    x = (a[i] * 2) - x;
  }
  cout << endl;
}


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

int main(){
 int r,g,b;
 cin >> r >> g >> b;
 int rgb;
 rgb = 100*r + 10*g + b;
 if(rgb%4 == 0){
   cout << "YES" << endl;
 }
 else {
   cout << "NO" << endl;
 }

 return 0;

}

Measured memory_bytes: 3592
N,X=map(int,input().split())
p=[1]
a=[1]
for i in range(1,1+N):
    b=2*p[i-1]+1
    p.append(b)
    c=2*a[i-1]+3
    a.append(c)

ans=[]
if X==1:
    print(0)
    exit()
def f(n,x):
    #print(n)
    if n==0:
        return 0 if x<=0 else 1
    elif x<=(1+a[n-1]):
        return f(n-1,x-1)
    else:
        return p[n-1]+1+f(n-1,x-2-a[n-1])
print(f(N,X))

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define int long long int
#define endl '\n'
using namespace std;

void solve(){
   int n,ans = 0; cin >> n;

   for(int i = 1; i <= n; ++i){
       for(int j = 1; j <= n; ++j){
           for(int k = 1 ; k <= n; ++k){
               ans += __gcd(__gcd(i,j),k);
           }
       }
   }
   cout << ans;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}

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

using namespace std;

int main(void) {
	double min = 0.0, max = 0.0, dif, height;
	int count = 0;
	while( scanf("%lf", &height) != EOF ) {
		
		if(count == 0) {
			max = height;
			min = height;
		} else {
			if(height > max) {
				max = height;
			}
			if(height < min) {
				min = height;
			}
		}
		dif = max - min;
		count++;
	}
	cout << dif << endl;
	
	return 0;
}

Measured memory_bytes: 1284
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
/*

0
1
01 <- A
11

001 <- B
101
011
111 <- B

0001
1001
0101
1101

0011
1011
0111
1111

 */
int main() {
  ll A,B;
  cin >> A >> B;
  v(ll) num;
  if(B-A <= 4) {
    for(ll k = A;k <=B;k++) {
      num.push_back(k);
    }
  } else {
    ll a = (A / 4) * 4;
    ll b = (B / 4) * 4;
    for(ll k = a;k < a+4;k++) {
      if(k >= A) {
        num.push_back(k);
      }
    }
    for(ll k = b;k < b+4;k++) {
      if(k <= B) {
        num.push_back(k);
      }
    }
  }
  
  ll ans = 0;
  
  rep(i,sz(num)){
    ans ^= num[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
vector<int>g[110000];
int vis[110000];
int dist[110000];
bool bin=true;
int ad=0;
void dfs(int a){
	ad++;
	vis[a]=1;
	for(int i=0;i<g[a].size();i++){
		if(vis[g[a][i]]==1){
			if(dist[g[a][i]]%2==dist[a]%2){
				bin=false;
			}
			continue;
		}
		dist[g[a][i]]=dist[a]+1;
		dfs(g[a][i]);
	}
}
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<b;i++){
		int p,q;scanf("%d%d",&p,&q);p--;q--;
		g[p].push_back(q);
		g[q].push_back(p);
	}
	int sg=0;
	int bi=0;
	int ot=0;
	for(int i=0;i<a;i++){
		if(vis[i])continue;
		bin=true;ad=0;
		dfs(i);
		if(ad==1)sg++;
		else if(bin)bi++;
		else ot++;
	}
	long long ret=0;
	ret+=(long long)sg*a*2-(long long)sg*sg;
	ret+=(long long)(bi+ot)*(bi+ot)+(long long)bi*bi;
	printf("%lld\n",ret);
}

Measured memory_bytes: 10624
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ggdem=b;i<ggdem;++i)
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define mset(a,v) memset((a),(v),sizeof(a))
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;

vector<ll> g[100005];

ll vis[100005];
vector<ll> t;

void dfs(ll v){
	if(vis[v])return;
	vis[v]=1;
	for(auto i:g[v])dfs(i);
	t.pb(v);
}

ll dp[100005];

ll f(ll x){
	ll &r=dp[x];
	if(r>=0)return r;
	if(SZ(g[x])==0){
		r=0; return r;
	}
	r=0;
	for(auto i:g[x]){
		r=max(r,f(i)+1);
	}
	return r;
}

int main(){FIN;
	ll n,m; cin>>n>>m;
	ll u,v;
	fore(i,0,m){
		cin>>u>>v; u--; v--;
		g[u].pb(v);
	}
	fore(i,0,n)dfs(i);
	reverse(ALL(t));
	mset(dp,-1);
	ll res=0;
	fore(i,0,n)res=max(f(t[i]),res);
	cout<<res;
	return 0;
}

Measured memory_bytes: 11380
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#include<ctype.h>
#define PI 3.141592653589
#define N_MAX 1500

int main()
{
  char buf[N_MAX];
  char c;
  int i = 0, j;
  while((c = getchar()) != '\n')
    {
      buf[i] = c;
      i++;
    }
  for(j = 0; j < i; j++)
    {
      if(islower(buf[j])) buf[j] = toupper(buf[j]);
      else if(isupper(buf[j])) buf[j] = tolower(buf[j]);
      printf("%c",buf[j]);
    }
  printf("\n");
  return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
//#include <unordered_map>
//#include <unordered_set>
using namespace std;
typedef long long ll;
int main() {
    int n;
    ll a, b;
    cin >> n;
    cin >> a >> b;
    if(a > b){cout << 0 << endl; return 0;}
    if(n == 1 && a != b){cout << 0 << endl;return 0;}
    cout << (a + (n - 1) * b) - (b + (n - 1) * a) + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#![allow(unused)]

use std::cmp::{max, min};
use std::io::stdin;
use std::str::FromStr;

fn input<T: FromStr>() -> Result<T, T::Err> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim().parse()
}

fn input_vec<T: FromStr>() -> Result<Vec<T>, T::Err> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim().split_whitespace().map(|x| x.parse()).collect()
}

fn main() {
    let (n, m): (usize, usize) = {
        let tmp = input_vec().unwrap();
        (tmp[0], tmp[1])
    };

    let mut stu: Vec<(i64, i64)> = Vec::with_capacity(n);
    for _i in 0..n {
        let tmp = {
            let t = input_vec().unwrap();
            (t[0], t[1])
        };
        stu.push(tmp);
    }

    let mut chk: Vec<(i64, i64)> = Vec::with_capacity(m);
    for _i in 0..m {
        let tmp = {
            let t = input_vec().unwrap();
            (t[0], t[1])
        };
        chk.push(tmp);
    }

    for &(a, b) in stu.iter() {
        let mut closest = m + 1;
        let mut ord = std::usize::MAX;

        for (i, &(c, d)) in chk.iter().enumerate().rev() {
            if ord
                >= ((a as i64) - (c as i64)).abs() as usize
                    + ((b as i64) - (d as i64)).abs() as usize
            {
                closest = i;
                ord = ((a as i64) - (c as i64)).abs() as usize
                    + ((b as i64) - (d as i64)).abs() as usize;
            }
        }

        println!("{}", closest + 1);
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s, t;
    cin >> s;
    cin >> t;
    
    int ans = t.length();
    
    for(int i=0; i<s.length()-t.length()+1; i++)
    {
        int cnt = 0;
        for(int j=0; j<t.length(); j++)
        {
            if(s[i+j] != t[j])
            {
                cnt++;
            }
        }

        ans = min(ans, cnt);
    }
    
    
    cout << ans << endl;
    
}


Measured memory_bytes: 3632
#include <iostream>
using namespace std;
const int M = 998244353;

int main() {
    string s; cin >> s;
    int r[4001] = {}, b[4001] = {};
    for (int i = 0; i < s.size(); i++) {
        if (i > 0) { r[i] = r[i-1]; b[i] = b[i-1]; }
        switch(s[i]) {
        case '0': r[i] += 2; break;
        case '1': r[i]++; b[i]++; break;
        case '2': b[i] += 2;
        }
    }
    for (int i = s.size(); i < 2*s.size(); i++) r[i] = r[i-1], b[i] = b[i-1];
    long long dp[4001][4001] = {};
    if (r[0] > 0) dp[0][1] = 1;
    if (b[0] > 0) dp[0][0] = 1;
    for (int i = 1; i < 2*s.size(); i++) {
        if (b[i] >= i+1) dp[i][0] = dp[i-1][0];
        for (int j = 1; j <= min(i+1, r[i]); j++) {
            if (r[i] >= j) dp[i][j] += dp[i-1][j-1];
            if (b[i] >= i+1-j) dp[i][j] += dp[i-1][j];
            if (dp[i][j] >= M) dp[i][j] -= M;
        }
    }
    cout << dp[2*s.size()-1][r[s.size()]] << endl;
}


Measured memory_bytes: 125312
def create_decrement_list(num):
    decrement_list = []
    while(num >= 0):
        decrement_list.append(num)
        num -=2
    return decrement_list

def check_route(num_list, offset):
    is_path_possible = False
    for num in num_list:
        if offset == num:
            is_path_possible = True
            break
    return is_path_possible

def route_checker(N, list_t, list_x, list_y):
    for n in range(N):
        if n == 0:
            offset_x = abs(list_x[n])
            offset_y = abs(list_y[n])
        else:
            offset_x = abs (list_x[n] - list_x[n-1])
            offset_y = abs (list_y[n] - list_y[n-1])
        offset_total = offset_x + offset_y
        time_offset = list_t[n] if n==0 else list_t[n] - list_t[n-1]
        time_offset_list = create_decrement_list(time_offset)
        if check_route(time_offset_list, offset_total)==False:
            print("No")
            break
    else:
        print("Yes")

N = int(input())
t = []
x = []
y = []
# 要素を配列に格納
for i in range(N):
    a_list = list(map(int, input().split()))
    t.append(a_list[0])
    x.append(a_list[1])
    y.append(a_list[2])

route_checker(N, t, x, y)

Measured memory_bytes: 11872
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define max(a,b) a>b?a:b
void bubbleSort(int numbers[], int array_size)
{
  int i, j, temp;

  for (i = 0; i < (array_size - 1); i++) {
    for (j = (array_size - 1); j > i; j--) {
      if (numbers[j-1] > numbers[j]) {
        temp = numbers[j-1];
        numbers[j-1] = numbers[j];
        numbers[j] = temp;
      }
    }
  }
}
int main()
{   int j,m,n,i,y,x,a[101],b[101];

    scanf("%d%d%d%d",&n,&m,&x,&y);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(j=0;j<m;j++){
        scanf("%d",&b[j]);
    }
    bubbleSort(a,n);
    bubbleSort(b,m);
    if(a[n-1]<b[0]&&a[n-1]<y&&b[0]>x){
        printf("No War");
    }else{
        printf("War");
    }

    return 0;
}


Measured memory_bytes: 128
def lcm(m, n):
    return m//gcd(m, n)*n


def gcd(m, n):
    r = m % n
    return gcd(n, r) if r else n


n = int(input())
arr = [int(input()) for _ in range(n)]
ans = 1
for i in arr:
    ans = lcm(ans, i)

print(ans)

Measured memory_bytes: 9076
#include <iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;
int inf = (1e9);

bool c(string s){
  int n = s.size();
  for(int i=0; i<n; i++){
    if( s[i] != s[n-1-i] ) return false;
  }
  return true;
}

string func(string s){
  string t = "";
  for(int i=0; i<s.size(); i++){
    if( s[i] != 'x' ) t += s[i];
  }
  return t;
}

int main() {

  string s;
  cin >> s;
  if( c(s) ){
    cout << 0 << endl;
    return 0;
  }

  if( !c( func(s) ) ){
    cout << -1 << endl;
    return 0;
  }

  string t = func(s);
  if( t.size() % 2 == 0 ){
    int tmp = t.size()/2-1;
    int j = 0;
    int a = -1;
    for(int i=0; i<s.size(); i++){
      if( j == tmp && s[i] == t[j] ){
        a = i;
        break;
      }
      if( s[i] == t[j] ){
        j++;
      }
    }
    int b = 0;
    for(int i=a+1; i<s.size(); i++){
      if( s[i] == 'x' ) b++;
      else break;
    }
    int cnt = 0;
    // int cnt = b%2;

    int l = a;
    int r = a + b + 1;
    int lx = 0; int rx = 0;
    while( true ){
      if( l < 0 && r > s.size()-1 ) break;

      if( s[l] == s[r] ){
        l--;
        r++;
        cnt += abs(lx-rx);
        lx=0; rx=0;
      }
      if( s[l] == 'x' ){
        lx++;
        l--;
      }
      if( s[r] == 'x' ){
        r++;
        rx++;
      }
    }
    cnt += abs(lx-rx);
    cout << cnt << endl;

  }else{
    int tmp = t.size()/2;
    int j = 0;
    int a = -1;
    for(int i=0; i<s.size(); i++){
      if( j == tmp && s[i] == t[j] ){
        a = i;
        break;
      }
      if( s[i] == t[j] ){
        j++;
      }
    }
    int l = a; int r = a; int lx = 0; int rx = 0;
    int cnt = 0;
    while( true ){
      if( l < 0 && r > s.size()-1 ) break;

      if( s[l] == s[r] ){
        cerr << lx << " " << rx << endl;
        cerr << l << " " << r << " " << cnt << endl;
        l--;
        r++;
        cnt += abs(lx-rx);
        lx=0; rx=0;
      }
      if( s[l] == 'x' ){
        lx++;
        l--;
      }
      if( s[r] == 'x' ){
        r++;
        rx++;
      }
    }
    cnt += abs(lx-rx);
    cout << cnt << endl;
  }



  return 0;
}


Measured memory_bytes: 712
/**
 * Created by hiramekun at 11:23 on 2020-06-07.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue <T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector <T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector <T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector <vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n, r;
    cin >> n >> r;

    if (n >= 10) cout << r << '\n';
    else {
        cout << r + 100 * (10 - n) << '\n';
    }
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
    solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

typedef long long ll;
typedef long double ld;

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

  string s;
  cin >> s;
  if (s[2] == s[3] && s[4] == s[5]) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}


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

void Output(const vector<int>& Heap)
{
	int Size = Heap.size() - 1;
	for(int i = 0; i < Size; i++){
		int MyId     = i + 1;
		int ParentId = MyId / 2;
		int LChildId = 2 * MyId;
		int RChildId = 2 * MyId + 1;
		cout << "node "  << MyId       << ": ";
		cout << "key = " << Heap[MyId] << ", ";
		if(ParentId >= 1){
			cout << "parent key = " << Heap[ParentId] << ", ";
		}
		if(LChildId <= Size){
			cout << "left key = "   << Heap[LChildId] << ", ";
		}
		if(RChildId <= Size){
			cout << "right key = "  << Heap[RChildId] << ", ";
		}
		cout << endl;
	}
}

int main()
{
	int H;
	cin >> H;
	vector<int> Heap(H+1);
	for(int i = 0; i < H; i++){
		cin >> Heap[i+1];
	}
	Output(Heap);
	return 0;
}

Measured memory_bytes: 3100
def palindromeJ(string):
    if string == string[::-1]:
        return True
    else: 
        return False

s = input()
n = len(s)
s_left = s[0:int((n-1)/2)]
s_right = s[int((n+1)/2):]

if palindromeJ(s) and palindromeJ(s_left) and palindromeJ(s_right):
    print("Yes")
else:           
    print("No")

Measured memory_bytes: 3060
#include<iostream>
#include<numeric>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<map>
#include<utility>
#include<cmath>
#include<tuple>
#include<string>
#include<bitset>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
typedef long long ll;

int main(){
    string s,t;
    cin>>s>>t;
    int ans=0;
    for(int i=0;i<(int)s.length();i++){
        if(s[i]!=t[i]) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3924
#include<stdio.h>

int n,A[20];

int solve(int,int);

int main(){
  int i,m,q,judge;

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m);
    judge=solve(0,m);
    if(judge==1) printf("yes\n");
    else printf("no\n");
  }
  
  return 0;
}

int solve(int i,int m){
  int result;
  
  if(m==0) return 1;
  if(i>=n) return 0;
  
  if(solve(i+1,m)==1)return 1;
  if(solve(i+1,m-A[i])==1)return 1;
  return 0;

}



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

int main() {
    string s;
    cin>>s;
    int a;
    int mini=1000;
    for(int i=0;i<s.size()-2;i++) {
        a=((s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0'));
        mini=min(mini, abs(753-a));
    }
    cout<<mini<<endl;
}

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

using namespace std;

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

	int N, M;
	cin >> N >> M;
	int a[50], b[50], c[50], d[50];

	for (int i = 0; i < N; i++) {
		cin >> a[i] >> b[i];
	}
	for (int i = 0; i < M; i++) {
		cin >> c[i] >> d[i];
	}

	for (int i = 0; i < N; i++) {
		int ans;
		int cnt = 1e9;
		for (int j = M - 1; j >= 0; j--) {
			if (cnt >= abs(a[i] - c[j]) + abs(b[i] - d[j])) {
				ans = j + 1;
				cnt = abs(a[i] - c[j]) + abs(b[i] - d[j]);
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
def main():
    n, m = map(int, input().split())
    p = 2**n
    inf = 10**7
    dp = [inf]*p
    dp[0] = 0
    for _ in range(m):
        a, _ = map(int, input().split())
        c = sum([1<<(int(i)-1) for i in input().split()])
        def k(s):
            if dp[s|c] > dp[s] + a:
                dp[s|c] = dp[s] + a
        [k(s) for s in range(p)]
    ans = dp[-1]
    if ans == inf:
        ans = -1
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
class Dice():
    
    def __init__(self):
        self.number = [i for i in range(6)]
        self.work = [i for i in range(6)]
        
    def setNumber(self,n0,n1,n2,n3,n4,n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5
        
    def roll(self,loc):
        for i in range(6):
            self.work[i] = self.number[i]
            
        if loc == "E":
            self.setNumber(self.work[3],self.work[1],self.work[0],self.work[5],self.work[4],self.work[2])
            
        elif loc == "N":
            self.setNumber(self.work[1],self.work[5],self.work[2],self.work[3],self.work[0],self.work[4])
        
        elif loc == "S":
            self.setNumber(self.work[4],self.work[0],self.work[2],self.work[3],self.work[5],self.work[1])
        else:
            self.setNumber(self.work[2],self.work[1],self.work[5],self.work[0],self.work[4],self.work[3])
            
    def get_Top(self):
        return self.number[0]
        
dice = Dice()
table = list(map(int,input().split()))
dice.setNumber(table[0],table[1],table[2],table[3],table[4],table[5])

loc_array = str(input())
for tmp_loc in loc_array:
    dice.roll(tmp_loc)
print("%d"%(dice.get_Top()))


Measured memory_bytes: 5616
#include <stdio.h>
#include <stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while( x->left != NIL){
    x = x->left;
  }
  return x;

}

Node treeMaximum(Node x){


}

Node treeSearch(Node u, int k){
  while( u != NIL && k != u->key ){
    if (k < u->key ) u = u->left;
    else u = u->right;
  }
  return u;

}

Node treeSuccessor(Node x){
  if( x->right != NIL){
    return treeMinimum(x->right);
  }
  Node y = x->parent;
  while( y != NIL && x == y->right ){
    x = y;
    y = y->parent;
  }
  return y;

}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if( z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);

  if( y->left != NIL){
    x = y->left;
  }
  else x = y->right;

  if(x != NIL ){
    x->parent = y->parent;
  }

  if( y->parent == NIL ){
    root = x;
  }
  else {
    if(y == y->parent->left){
      y->parent->left = x;
    } else {
      y->parent->right = x;
    }
  }

  if( y != z ){
    z->key = y->key;
  }

  free(y);

}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = (Node)malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while ( x != NIL ){
    y = x;
    if ( z->key < x->key ){
      x = x->left;
    } else {
      x = x->right;
    }
  }

  z->parent = y;
  if ( y == NIL ){
    root = z;
  } else {
    if ( z->key < y->key ){
      y->left = z;
    }else {
      y->right = z;
    }
  }

}

void inorder(Node u){
  if (u == NIL) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}
void preorder(Node u){
  if( u == NIL ) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 25172
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int n = sc.nextInt();

		Map<Long, Integer> map1 = new TreeMap<>();
		for(int i = 0; i < n; i++) {
			long x = sc.nextLong();
			if(map1.containsKey(x)) {
				map1.put(x, map1.get(x)+1);
			}else {
				map1.put(x, 1);
			}
		}
		int m = sc.nextInt();
		Map<Long, Integer> map2 = new TreeMap<>();
		for(int i = 0; i < m; i++) {
			long x = sc.nextLong();
			if(map2.containsKey(x)) {
				map2.put(x, map2.get(x)+1);
			}else {
				map2.put(x, 1);
			}
		}
		boolean check = true;
		for(Long d : map2.keySet()) {
			if(!map1.containsKey(d) || (map1.get(d) < map2.get(d))) {
				check = false;
				break;
			}
		}
		if(check) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}

	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

	    public int nextInt() {
	        return Integer.parseInt(next());
	    }

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


Measured memory_bytes: 84024
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

int main() {

  int W, a, b;
  cin>>W>>a>>b;

  if(a + W < b){
    cout<<b - (a+W)<<endl;
  }else if(b + W < a){
    cout<<a - (b+W)<<endl;
  }else{
    cout<<0<<endl;
  }

  return 0;
}


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

using namespace std;

int main(){
  int l,r,d,cnt=0;
  cin >> l >> r >> d;
  for(int i=l;i<=r;i++){
    if(i % d ==0)
      cnt++;
  }
  cout << cnt;
  return 0;
}


Measured memory_bytes: 3628