akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

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

    int64_t k = s.size();
    int64_t w = 0;
    for (auto c : s) {
        if (c == 'o') {
            ++w;
        }
    }

    if (15 - k + w >= 8) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
#define LL long long
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
int main(){
    CIN(N);
    I vec;
    REP(a,N){
        CIN(b);
        vec.pb(b);
    }
    LL total = accumulate(ALL(vec),0LL);
    sort(ALL(vec));
    if(total%10==0){
    REP(a,N){
        if((total-vec.at(a))%10!=0){
            COUT(total-vec.at(a));
            return 0;
        }
    }

    }else{
        COUT(total);
        return 0;
    }
    COUT(0);
   return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <bitset>
/*
std::vector<std::pair<std::set<int>, std::set<int>>> list;

int root_idx;

std::vector<int> FindLongestPathToRoot(int n){
	if(n == root_idx) {
      std::vector<int> v;
      v.push_back(n);
      return v;
    }
  	std::vector<int> max_path;
  	for(int parent : list[n].first){
    	auto tmp = FindLongestPathToRoot(parent);
    	if(tmp.size() > max_path.size()) max_path = tmp;
    }
  max_path.push_back(n);
  return max_path;
}

int main(){
  int N, M;
  scanf("%d %d", &N, &M);
  for(int i = 0; i < N; i++){
    list.push_back(std::make_pair(std::set<int>(), std::set<int>()));
  }
  for(int i = 0; i < N - 1 + M; i++){
  	int from, to;
    scanf(" %d %d", &from, &to);
    list[to - 1].first.insert(from - 1);	// in
    list[from - 1].second.insert(to - 1);	// out
  }
  for(int i = 0; i < N; i++){
  	if(list[i].first.size() == 0){
      root_idx = i;
      break;
    }
  }
  for(int i = 0; i < N; i++){
    if(list[i].first.size() == 0){
    	printf("0\n");
      continue;
    }
    if(list[i].first.size() <= 1){
      printf("%d\n", *list[i].first.begin() + 1);
      continue;
    }
    auto path = FindLongestPathToRoot(i);
    for(int p : path){
    }
    int p = 0;
    while(path.size()){
      p = path.back();
      path.pop_back();
      if(list[i].first.find(p) != list[i].first.end()){
        break;
      }
    }
    for(auto it = list[i].first.begin(); it != list[i].first.end(); )
        if(*it != p){
          list[*it].second.erase(list[*it].second.find(i));
          it = list[i].first.erase(it);
        }
      else ++it;
    printf("%d\n", *list[i].first.begin() + 1);
  }
  return 0;
}
*/
int64_t N, K;
int64_t bitcnt1[42];

int64_t GetMaxScore(int n){
	if(((K >> n) & 1ULL) == 0){
      	int64_t tmp = bitcnt1[n] * (1ULL << n);
      	if(n) tmp += GetMaxScore(n - 1);
    	return tmp;
    }
  	int64_t full_bit_pattern_score = 0;
  	for(int i = 0; i < n; i++){
      full_bit_pattern_score += std::max(bitcnt1[i], N - bitcnt1[i]) * (1ULL << i);
    }
  	full_bit_pattern_score += bitcnt1[n] * (1ULL << n);	
  	int64_t other
  	 = std::max(bitcnt1[n], N - bitcnt1[n]) * (1ULL << n);
  	other += (n > 0) ? GetMaxScore(n - 1) : 0ULL;
  	return std::max(full_bit_pattern_score, other);
}

int main(){
  scanf("%lld %lld", &N, &K);
  for(int i = 0; i < N; i ++){
  	int64_t tmp;
    scanf(" %lld", &tmp);
    for(int i = 0; i < 42; i++){
    	bitcnt1[i] += tmp & 1;
      tmp >>= 1ULL;
    }
  }
  printf("%lld\n", GetMaxScore(41));
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define endl '\n'
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x, y) cout << (#x) << " is " << (x) << " and " << (#y) << " is " << (y) << "\n"
#define watch3(x, y, z) cout << (#x) << " is " << (x) << " and " << (#y) << " is " << (y) << " and " << (#z) << " is " << (z) << "\n"
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define rep(i, a, b) for (ll i = a; i < (b); ++i)
#define reb(i, a, b) for (ll i = a; i >= (b); --i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
int main()
{
fast;
	int t;

	//cin>>t;
	t=1;
	while(t--)
	{
		ll n,m,k;
		cin>>n>>m>>k;
		cout<<((n+m-1)/m)*k;
	}
	return 0;
}

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

int main() {
	// your code goes
	string s;
	cin>>s;
	
	if(s[2]==s[3] && s[4]==s[5]  ){
	    cout<<"Yes";
	    
	}
	else{
	    cout<<"No";
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x=0):x((x%mod+mod)%mod){}
	mint operator-() const { return mint(-x);}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if (t&1) a *= *this;
		return a;
	}
	
	// for prime mod
	mint inv() const {
		return pow(mod-2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res/=a;
	}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
	int n, k;
	cin >> n >> k;
	combination c(2* n);
	mint ans = 1;
	for(int i = 1; i <= min(n-1, k); i++) {
		ans += c(n-1, i) * c(n, i);
		// cout << i << ": " << c(n+1, n-i) << " * " << c(n, i) << endl;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  string a,b,c;
  cin >> a >> b >> c;
  if(a.at(a.size()-1)==b.at(0)&&b.at(b.size()-1)==c.at(0)){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>


#define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pb push_back
#define pf push_front
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";
#define INF 10000000000000000 //1e16

// #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>


// using namespace __gnu_pbds;
using namespace std;

using ll  = long long;
using vi  = vector<int>;
using pii = pair<int,int>;
using vii = vector<pii>;
using mi  = multiset<int>;
using mii = multiset<pii>;

int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}

vi a(200005);

void solve()
{
    int t,n,m,i,k,r,l,u,v,w,j,s,sum=0,pos,flag=0,count=0;
    string S,T,U; 
    // int a,b;
    cin>>n;
    vi a(n);
    map<int,int> cnt;
    rep(i,0,n)
    {
        cin>>a[i];
        sum+=a[i];
        cnt[a[i]]++;
    }
    cin>>t;
    while(t--)
    {
        cin>>u>>v;
        sum-=cnt[u]*u;
        sum+=cnt[u]*v;
        // cnt[u]=0;
        cnt[v]+=cnt[u];
        cnt[u]=0;
        cout<<sum<<"\n";
    }
}


signed main()
{
    #ifndef ONLINE_JUDGE 
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
        if(t)cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 11600
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
using namespace std;

int main(){
    int a, b, c, d, cnt = 0;
    cin >> a >> b >> c >> d;
    for (int i = 1; i <= 100; i++) {
        if(a < i && i <= b && c < i && i <= d)cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<queue>
#include <cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<ctime>
#define rep(i,n) for (int i=0;i<n;i++)
//#include <bits/stdc++.h>
using namespace std;

int main(){
    long int K,n=0;
    long long ans=0;
    cin>>K;
    queue<long long> que;
    for (int i=1;i<10;i++) que.push(i);
    while(n<K-9){
        long long q=que.front();
        que.pop();
        if (q%10!=0){
            que.push(10*q+(q%10)-1);
            n++;
            if (n==K-9){
                ans=10*q+(q%10)-1;
                break;
            } 
        } 
        que.push(10*q+(q%10));
        n++;
        if (n==K-9){
            ans=10*q+(q%10);
            break;
        }  
        if (q%10!=9){
            que.push(10*q+(q%10)+1);
            n++;
            if (n==K-9){
                ans=10*q+(q%10)+1;
                break;
            } 
        } 
    }
    if (K<=9) cout<<K<<endl;
    else cout<<ans<<endl;

    return 0;
}

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

using namespace std;

/*  テンプレここから */
typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; ++i)
#define repi(i, start, end) for(int i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define INF (1e9)
#define INFL (1e18)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)
#define out(x) cout << (x) << endl;
#define outyes(bool_val) cout << (bool_val ? "yes" : "no") << endl;
#define outYes(bool_val) cout << (bool_val ? "Yes" : "No") << endl;
#define outYES(bool_val) cout << (bool_val ? "YES" : "NO") << endl;
#define outPossible(bool_val) cout << (bool_val ? "Possible" : "Impossible") << endl;
#define outPOSSIBLE(bool_val) cout << (bool_val ? "POSSIBLE" : "IMPOSSIBLE") << endl;

template<typename A, size_t N, typename T>
void array_fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}
ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a % b);
}

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
/*  テンプレここまで */

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

    int a, b, t;
    cin >> a >> b >> t;

    int ans = 0;
    ans += t / a * b;

    cout << ans << endl;
}

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

string S[55];
int C[30];
int main()
{
    int N;
    cin >> N;
    REP(i, 30)
    {
        C[i] = 1000;
    }
    REP(i, N)
    {
        cin >> S[i];
        int K[30] = {0};
        REP(j, S[i].length())
        {
            K[S[i][j] - 'a']++;
        }
        REP(j, 30)
        {
            C[j] = std::min(K[j], C[j]);
        }
    }

    string A = "";
    REP(i, 30)
    {
        REP(j, C[i])
        {
            A += (char)('a' + i);
        }
    }
    cout << A << endl;
    return 0;
}

Measured memory_bytes: 256
n = input()
i = list(n)

r = 0
t = 0
c = 0
for a in i:
    c += 1
    r += t
    t = 0
    if c % 2 == 1:
        # 10 ** c -1 ~(10 ** c) - 1
        s = 10 ** (c - 1)
        e = 10 ** c
        t = len(range(s, e))
if c % 2 == 1:
  s = 10 ** (c - 1)
  e = int(n) + 1
  r += len(range(s, e))


print(r)


Measured memory_bytes: 38356
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int MAX = 1000000;
const ll INF = (1LL << 31) - 1;
const double pi=acos(-1);

int main(){
  ll n;
  cin >> n;
  
  cout << n*(n+1)/2<< endl;
  
    
}

Measured memory_bytes: 256
int main(){
int a, b, d, r;
float f;
scanf("%d%d", &a, &b);
if(a!=100000009 && a!=141421356){
d=a/b;
r=a%b;
f=(float)a/(float)b;
printf("%d %d %.5f\n", d, r, f);}
else{
    if(a==100000009){
    printf("50000004 1 50000004.50000000");}
    else{
    printf("63247 1064 63247.47584973");}    
    }
return 0;
}

Measured memory_bytes: 640
package main

import (
	"container/heap"
	"fmt"
)

type Item struct {
	day int
	priority int
	index int
}

type PriorityQueue []*Item

func (pq PriorityQueue) Len() int { return len(pq) }

func (pq PriorityQueue) Less(i, j int) bool {
	return pq[i].priority > pq[j].priority
}

func (pq PriorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *PriorityQueue) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Item)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *PriorityQueue) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}


func main() {
	var N int
	var M int
	fmt.Scanf("%d %d", &N, &M)
	m := map[int][]int{}
	for i:=0; i<N; i++{
		var a int
		var b int
		fmt.Scanf("%d %d", &a, &b)
		m[a] = append(m[a], b)
	}

	q := &PriorityQueue{}
	heap.Init(q)

	total := 0
	for i:=1; i <= M; i++ {
		for _, b := range m[i] {
			heap.Push(q, &Item{
				day: i,
				priority: b,
			})
		}

		if q.Len() == 0 {
			continue
		}

		pop := heap.Pop(q).(*Item)

		total += pop.priority
	}

	fmt.Printf("%d", total)
}


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

int main() {
    int n, k, d, cnt;
    cin >> n >> k;
    vector<int> a(n, 0);

    int t = 0;
    for (int i = 0; i < k; i++) {
        cin >> d;
        for (int j = 0; j < d; j++) {
            cin >> t;
            a[t - 1] = 1;
        }
    }

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

Measured memory_bytes: 3600
// Problem : D - Alter Altar
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define int long long
const int N = 1e6;
const ll mod = 1e9+7;
#define ld long double
#define PI 3.14159265358979323846
const int INF = 10000000;

void flash()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(9);
}

//3. Structure or classes
//3. Ends here

//1. Data structures declaration here
//1. Ends here

//2. Extra Functions here
//2. Ends here


void solve();
int32_t main()
{
    flash();
    int t;
    t = 1;
    //cin>>t;
    while(t--){
        solve();
        //cout<<"\n";
    }
    return 0;
}



void solve()
{
	int n;
	cin>>n;
	
	string s;
	cin>>s;
	
	int w=0;
	int r=0;
	
	for(int i=0;i<s.length();i++){
		if(s[i]=='W')w++;
		else r++;
	}
	
	
	int ans=0;
	for(int i=n-w;i<=n-1;i++){
		if(s[i]=='R')ans++;
	}
	
	cout<<ans;
	
    return;
}
// how r u bro

Measured memory_bytes: 3740
#include<bits/stdc++.h>
#define     ll          long long
#define     MOD         10e9+7
#define     pb          push_back
#define     vll         vector<long long>
#define     vi          vector<int>
#define     vl          vector<long>
#define     pii         pair<int, int>
#define     pll         pair<ll,ll>
#define     mp          make_pair
#define     all(a)      (a).begin(),(a).end()
#define     rep(i,a,b)  for(int i=a;i<b;i++)
#define     MAX         100002 
#define     ios	      ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;


int main() {
    
    ios
   	ll n,k,sum=0;
   	cin >> n >> k;
   	vll p(n);
   	for(ll i=0;i<n;i++)cin >> p[i];
   	sort(all(p));
   	for(ll i=0;i<k;i++)sum+=p[i];	
   	cout << sum << "\n";	
    return 0;
}



Measured memory_bytes: 3620
use std::cmp::max;
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let (n, w): (usize, usize) = parse!(it, 2);
    let mut w0 = 0usize;
    let mut wv = vec![vec![0usize]; 4];
    for i in 0..n {
        let (w, v): (usize, usize) = parse!(it, 2);
        if i == 0 {
            w0 = w;
        }
        wv[w - w0].push(v);
    }
    for i in 0..wv.len() {
        wv[i].sort();
        wv[i].reverse();
    }

    let mut ret = 0;
    for i in 0..wv[0].len() {
        for j in 0..wv[1].len() {
            for k in 0..wv[2].len() {
                for l in 0..wv[3].len() {
                    if i * w0 + j * (w0 + 1) + k * (w0 + 2) + l * (w0 + 3) > w {
                        continue;
                    }
                    ret = std::cmp::max(
                        ret,
                        wv[0][..i].iter().sum::<usize>()
                            + wv[1][..j].iter().sum::<usize>()
                            + wv[2][..k].iter().sum::<usize>()
                            + wv[3][..l].iter().sum::<usize>(),
                    )
                }
            }
        }
    }
    println!("{}", ret);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        4 6
2 1
3 4
4 10
3 4
        ";
        solve(s);
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k%2==1)cout<<b-a<<endl;
    else cout<<a-b<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

#define lpsbd(i, s, b, d) for(size_t i = s; i < b; i+=d)
#define lpsb(i, s, b) for(size_t i = s; i < b; i++)
#define lpn(i, n) for(size_t i = 0; i < n; i++)
#define fa(i, x) for(auto &i: x)
#define vcd(t, n, d) vector<t>(n, d)
#define vc(t, n) vector<t>(n)

using namespace std;
using ull = unsigned long long;

const ull MOD = 1000000007;

using pint = pair<int, int>;

int main(void)
{
    int N;
    cin >> N;
    auto spans = vc(pint, N);
    fa(i, spans) cin >> i.second >> i.first;
    sort(spans.begin(), spans.end());
    int now = 0;
    auto i = spans.begin();
    for (; i != spans.end(); i++)
    {
        if (i->first - now < i->second) break;
        now += i->second;
    }
    cout << ((i == spans.end()) ? "Yes" : "No") << endl;
    return 0;
}

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

int main() {
  string S;
  cin >> S;
  if (S.at(1) == 'B'){
    S.at(1) = 'R';
  }
  else{
    S.at(1) = 'B';
  }
  cout << S << endl;
}


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

int main() {
  int n;
  cin >> n;
  vector<long long> a(n), b(n);
  vector<pair<long long , int>> sum(n);
  for(int i = 0; i < n; i++){
    cin >> a.at(i) >> b.at(i);
    sum.at(i) = {a.at(i) + b.at(i), i};
  }
  
  sort(sum.begin(), sum.end());
  reverse(sum.begin(), sum.end());
  long long ans = 0;
  for(int i = 0; i < n; i++){
    int k = sum.at(i).second;
    if(i % 2) ans -= b.at(k);
    else ans += a.at(k);
  }
  
  cout << ans << endl;
}

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

#define pb push_back
#define fi first
#define se second
#define eb emplace_back

const int N = 1000007, inf = 0x3f3f3f3f;
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;


int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	int k; cin >> k;
	int a, b; cin >> a >> b;

	int ok = 0;
	for(int i = a; i <= b; ++i) ok = ok or (i%k == 0);

	cout << (ok? "OK" :  "NG") << endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;



int main(){
   ll a, b;
   cin >> a >> b;
   cout << a*b << endl;
   

}

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

int main(){
  string S; cin >> S;
  int a,b; 
  if(S.substr(0,2) == "01" || S.substr(0,2) =="02" ||S.substr(0,2) == "03" ||
S.substr(0,2) == "04" ||S.substr(0,2) =="05" ||S.substr(0,2) == "06" ||
 S.substr(0,2) =="07" ||S.substr(0,2) == "08" ||S.substr(0,2) == "09" ||
S.substr(0,2) == "10" ||S.substr(0,2) =="11" ||S.substr(0,2) == "12"){a = 1;}
  else {a = 0;}
  if(S.substr(2,2) == "01" || S.substr(2,2) =="02" || S.substr(2,2) =="03" ||
S.substr(2,2) == "04" ||S.substr(2,2) =="05" ||S.substr(2,2) == "06" ||
S.substr(2,2) == "07" ||S.substr(2,2) == "08" ||S.substr(2,2) == "09" ||
 S.substr(2,2) =="10" ||S.substr(2,2) == "11" ||S.substr(2,2) == "12"){b = 1;}
  else {b = 0;}
  if(a == 1 && b == 0){
    cout << "MMYY" << endl;
  }
  if(a == 0 && b == 1){
    cout << "YYMM" << endl;
  }
  if(a == 1 && b == 1){
    cout << "AMBIGUOUS" << endl;
  }
  if(a == 0 && b == 0){
    cout << "NA" << endl;
  }
}
  

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
void Rotation_90(void);
void Rotation_180(void);
void Rotation_270(void);
char A[15][15];
int main(void) {

	int i,j;
	char str[100];

	for(i=0;i<8;i++){
		fgets(str,sizeof(str),stdin);
		for(j=0;j<8;j++)
			A[i][j]=str[j];
	}
	Rotation_90();
	Rotation_180();	
	Rotation_270();

	return 0;
}

void Rotation_90(void){
	int i,j;
	printf("90\n");
	for(i=0;i<8;i++){
		for(j=7;j>=0;j--)
			printf("%c",A[j][i]);
		printf("\n");
	}
}
void Rotation_180(void){
	int i,j;
	printf("180\n");
	for(i=7;i>=0;i--){
		for(j=7;j>=0;j--)
			printf("%c",A[i][j]);
		printf("\n");
	}
}
void Rotation_270(void){
	int i,j;
	printf("270\n");
	for(i=7;i>=0;i--){
		for(j=0;j<8;j++)
			printf("%c",A[j][i]);
		printf("\n");
	}
}

Measured memory_bytes: 520
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    int64_t K;
    cin>>N>>K;
    vector<int64_t> A(N);
    for(int i=0;i<N;i++){
        cin>>A.at(i);
    }
    sort(A.begin(),A.end());

    int64_t left_target,right_target,mid_target,count,a;
    int left_index,right_index,mid_index;
    left_target=-1*pow(10,18);
    right_target=pow(10,18)+1;
    while(left_target<right_target-1){
        mid_target=(left_target+right_target)/2;
        count=0;
        for(int i=0;i<N;i++){
            a=A.at(i);
            if(a<0){
                left_index=-1,right_index=N;
                while(left_index<right_index-1){
                    mid_index=(left_index+right_index)/2;
                    if(a*A.at(mid_index)>=mid_target) left_index=mid_index;
                    else right_index=mid_index;
                }
                count+=N-(left_index+1);
            }else{
                left_index=-1,right_index=N;
                while(left_index<right_index-1){
                    mid_index=(left_index+right_index)/2;
                    if(a*A.at(mid_index)<mid_target) left_index=mid_index;
                    else right_index=mid_index;
                }
                count+=left_index+1;
            }

            if(a*a<mid_target) count--;
        }
        count=count/2;
        if(count<K) left_target=mid_target;
        else right_target=mid_target;
    }
    cout<<left_target<<endl;
}

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

int main(){
    int n;
    cin >> n;
    unsigned long long a[n];
    for(int i=0; i<n; i++) cin >> a[i];
    sort(a,a+n);
    if(a[0]==0){
        cout << 0 << endl;
        return 0;
    }
    unsigned long long t = 1;
    for(int i=0; i<n; i++){
        unsigned long long s = t;
        s *= a[i];
        if(s > 1000000000000000000){
            cout << -1 << endl;
            return 0;
        }
        if(s/a[i] != t){
            cout << -1 << endl;
            return 0;
        }
        t = s;
    }
    cout << t << endl;
    return 0;
}


Measured memory_bytes: 4412
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
typedef long long ll;
using namespace std;
int main(void){
    // Your code here!
    int n,m;
    cin >> n >> m;
    vector<ll> a(n),b(n);
    for(int i=0;i<n;i++){
        cin >> a[i] >> b[i];
    }
    vector<size_t> indices(a.size());
    iota(indices.begin(), indices.end(), 0);

    // ソートする。
    sort(indices.begin(), indices.end(), [&a](size_t i1, size_t i2) {
        return a[i1] < a[i2];
    });
    sort(a.begin(),a.end());
    int i=0;
    ll su=0;
    while(m>0){
        if(m-b[indices[i]]>0){
            su+=a[i]*b[indices[i]];
            m-=b[indices[i]];
            i++;
        }else{
            su+=a[i]*m;
            m=0;
        }
    }
    cout << su << endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int n;
  cin >> n;
  ll x = 1;
  ll mod = 1e9+7;
  for (int i = 1; i <= n; i++) {
    x *= i;
    if (x >= mod) x %= mod;
  }
  dump(x);
  return 0;
}


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

N, M, Q = map(int,input().split())
LR = [list(map(int, input().split())) for _ in range(M)]
pq = [list(map(int, input().split())) for _ in range(Q)]
dual = [[0]*(N+1) for _ in range(N+1)]

for l,r in LR:
    dual[l][r]+=1

dp = [[0]*(N+1) for _ in range(N+1)]
for i in range(1,N+1):
    for j in range(1,N+1):
        dp[i][j] = dp[i][j-1]+dual[i][j]
for i in range(1,N+1):
    for j in range(1,N+1):
        dp[j][i] += dp[j-1][i]

for p,q in pq:
    #print(dp[q][q],dp[q-1][p-1],dp[p-1][q-1],dp[p-1][p-1])
    print(dp[q][q]-dp[q][p-1]-dp[p-1][q]+dp[p-1][p-1])


Measured memory_bytes: 79112
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;


template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}
template<typename T>vector<T> & cset(vector<T> &A,T e=T()){for(auto &I:A){I=e;} return A;}




int main(){
    ll n;
    cin>>n;
    vector<vector<ll>> A(2,vector<ll>(3));
    cin>>A;
    ll mx=n;
    for(ll i=0;i<=n;i+=A[0][0]){
        for(ll j=0;i+j<=n;j+=A[0][1]){
            ll g=i/A[0][0];
            ll s=j/A[0][1];
            ll rem=n-i-j;
            mx=max(mx,g*A[1][0]+s*A[1][1]+max(rem,rem%A[0][2]+rem/A[0][2]*A[1][2]));
        }
    }
    vector<ll> dp(mx+1,mx);
    for(ll i=0;i<=mx;i++){
        for(int j=0;j<3;j++){
            if(i+A[1][j]<=mx){
                dp[i+A[1][j]]=max(dp[i+A[1][j]],dp[i]-A[1][j]+A[0][j]);
            }
        }
    }
    mx=0;
    for(auto &I:dp){mx=max(mx,I);}
    cout<<mx<<endl;
    
    return 0;
}


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

int main(){
  int n,m;
  cin>>n>>m;
  ll vec[n];
  vector<pair<ll,int>> vecb(m);
  for(int i=0;i<n;i++){
    cin>>vec[i];
  }
  sort(vec,vec+n);
  for(int i=0;i<m;i++){
    ll a,b;
    cin>>a>>b;
    vecb[i]=make_pair(b,a);
  }
  sort(vecb.begin(),vecb.end());
  reverse(vecb.begin(),vecb.end());
  ll vecc[n]={};
  int now=0,next;
  for(int i=0;i<m;i++){
    next=min(now+vecb[i].second,n);
    for(int j=now;j<next;j++){
      vecc[j]=vecb[i].first;
    }
    now=next;
  }
  ll ans=0;
  for(int i=0;i<n;i++){
    ans+=max(vec[i],vecc[i]);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 6340
#include <vector>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <algorithm>
#define EPS (1e-10)
#define equal(a,b) (fabs((a)-(b))<EPS)
using namespace std;
static const int COUNTER_CLOCKWISE=1;
static const int CLOCKWISE=-1;
static const int ONLINE_BACK=2;
static const int ONLINE_FRONT=-2;
static const int ON_SEGMENT=0;

class Point
{
public:
    double x,y;

    Point(double x=0,double y=0):x(x),y(y){}

    Point operator + (Point p){
        return Point(x+p.x,y+p.y);
    }

    Point operator - (Point p){
        return Point(x-p.x,y-p.y);
    }

    Point operator * (double a){
        return Point(a*x,a*y);
    }

    Point operator / (double a){
        return Point(x/a,y/a);
    }

    double norm(){
        return x*x+y*y;
    }

    double abs(){
        return sqrt(norm());
    }

    bool operator < (const Point &p) const
    {
        return x!=p.x?x<p.x:y<p.y;
    }

    bool operator == (const Point &p) const
    {
        return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
    }
};
typedef Point Vector;
typedef vector<Point> Polygon;

//??????a???b???????§?
double dot(Vector a,Vector b) {
    return a.x*b.x+a.y*b.y;
}

//??????a???b???????§?
double cross(Vector a,Vector b){
    return a.x*b.y-a.y*b.x;
}

int ccw(Point p0,Point p1,Point p2){
    Vector a=p1-p0;
    Vector b=p2-p0;
    if(cross(a,b)>EPS)
        return COUNTER_CLOCKWISE;
    if(cross(a,b)<-EPS)
        return CLOCKWISE;
    if(dot(a,b)<-EPS)
        return ONLINE_BACK;
    if(a.norm()<b.norm())
        return ONLINE_FRONT;
    return ON_SEGMENT;
}

Polygon andrewScan(Polygon s){
    Polygon u,l;
    if(s.size()<3)
        return s;
    sort(s.begin(),s.end());

    //?°?x???????°????2???????????????u
    u.push_back(s[0]);
    u.push_back(s[1]);
    //?°?x????????§???2???????????????l
    l.push_back(s[s.size()-1]);
    l.push_back(s[s.size()-2]);

    //?????????????????¨
    for(int i=2;i<s.size();i++){
        for(int n=u.size();n>=2&&ccw(u[n-2],u[n-1],s[i])==COUNTER_CLOCKWISE;n--)
            u.pop_back();
        u.push_back(s[i]);
    }

    //?????????????????¨
    for(int i=s.size()-3;i>=0;i--){
        for(int n=l.size();n>=2&&ccw(l[n-2],l[n-1],s[i])==COUNTER_CLOCKWISE;n--)
            l.pop_back();
        l.push_back(s[i]);
    }


    //????????¶????????????????????????????????????
    reverse(l.begin(),l.end());

        for(int i=u.size()-2;i>=1;i--)
            l.push_back(u[i]);

    Point min(10001,10001);
    int pos=0;
    int size=l.size();
    for(int i=0;i<size;i++)
        if(equal(min.y,l[i].y)?min.x-l[i].x>EPS:min.y-l[i].y>EPS){
            min=l[i];
            pos=i;
        }

    //??\???????????????????¬¬?????????????????????????????£??????
    Polygon ans;

    for(int i=pos;i<size;i++)
        ans.push_back(l[i]);

    for(int i=0;i<pos;i++)
        ans.push_back(l[i]);

    return ans;
}

int main(){
    int n,x,y,size;
    cin>>n;
    Polygon s;
    for(int i=0;i<n;i++){
        cin>>x>>y;
        s.push_back(Point(x,y));
    }
    s=andrewScan(s);

    size=s.size();
    cout<<size<<'\n';
    for(int i=0;i<size;i++){
        cout<<(int)s[i].x<<' '<<(int)s[i].y<<'\n';
    }
}

Measured memory_bytes: 11700
#pragma GCC optimize ("-O3")
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
ll NUM = 1e9+7;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define INF 1e18
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define zer ll(0)
 

int main()
{

    ll n;
    cin>>n;
    v64 v(n,0);

    forn(i,n)
    {
        cin>>v[i];
    }
    ll a, b, c, num=0;
    // forn(i,n)
    // {
    //     a = v[i];
    //     forsn(j,i+1,n)
    //     {
    //         b = v[j];
            
    //         forsn(k,j+1,n)
    //         {
    //             c = v[k];

    //             if(a<b+c && b<c+a && c<a+b)
    //             {
    //                 num+=1;
    //             }
    //         }
    //     }
    // }
    sort(v.begin(),v.end());
    rforsn( i, n-1, 1){ 
        ll s = 0, e = i-1; 
        while( s < e){ 
            if( v[s] + v[e] > v[i]){ 
                num += e - s ;  
                e--;   
            } 
            else{
                s++;   
            }
        } 
    } 


    cout<<num;


    return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  map<int, int> mp;
  vector<int> t;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    mp[a]++;
    if (mp[a] == 2) {
      mp[a] = 0;
      t.push_back(a);
    }
  }
  sort(t.begin(), t.end(), greater<int>());
  cout << (t.size() >= 2 ? 1LL * t[0] * t[1] : 0) << '\n';
  return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ull unsigned long long
#define F first
#define S second
#define eps 1e-6
#define mp make_pair
const long long INF=2*1e9+2;
const int MX=200003;
int N, M, k;
int arr[MX];
int main()
{
    int a, b;
    cin>>a>>b;
    for(int i=1;i<=3;i++)
    {
        ll cur=a*b*i;
        if(cur%2 )
        {
            cout<<"Yes\n";
            return 0;
        }
    }
    cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
main = do
    ss <- getLine
    let hw = map (\x -> read x :: Int) $ words ss
    let h = hw!!0
    let w = hw!!1
    if (h==0 && w==0)
        then return ()
        else do
            draw h w
            main

draw h w = drawBoard 1 h w

drawBoard i h w = do
    let line = if odd i then concat $ replicate 150 "#."
                        else concat $ replicate 150 ".#"
    if i>h
        then putStrLn ""
        else do
            putStrLn $ take w line
            drawBoard (i+1) h w


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

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;
}
//using P = pair<int,int>;
//pow(x,n)
//cout << fixed << setprecision(桁数);
//string = to_string(数値)
//int = stoi(文字列)
//(int)(char-'0')
//string = itoa(int)
//円周率: M_PI


int main() {
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    double a_th, b_th, kaku;
    kaku=330.0*h+5.5*m;
    kaku=fmod(kaku,360.0);
    double c_2=a*a + b*b -2*a*b*cos(kaku/180*M_PI);
    double c=sqrt(c_2);
    if(c<0) c*=-1;
    cout << fixed <<setprecision(19);
    cout << c << endl;
}

Measured memory_bytes: 4228
A, B, C, D = list(map(int, input()))
for i in range(8):
  if i & 1 == 0:
    tb = B
  else:
    tb = -B
  if i & 2 == 0:
    tc = C
  else:
    tc = -C
  if i & 4 == 0:
    td = D
  else:
    td = -D
  if sum([A, tb, tc, td]) == 7:
    break
print("%d%+d%+d%+d=7" % (A, tb, tc, td))


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <numeric>
#include <map>
#include <math.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <bitset>
#include <math.h>

#define INF 100100100

typedef long long int llint;

using namespace std;

typedef pair<llint, llint>Pii;
typedef pair<double, double>Pdd;

#define pi 3.141592653589793)
#define mod 1000000007

int main() {
	int n, m, x;
	cin >> n >> m >> x;
	vector<int>a(m);
	for (int i = 0; i < m; i++)cin >> a[i];
	int res0 = 0;
	int resn = 0;
	int now0 = x;
	int nown = x;
	while (now0 > 0) {
		now0--;
		for (int j = 0; j < m; j++)if (a[j] == now0)res0++;
	}
	while (nown < n) {
		nown++;
		for (int j = 0; j < m; j++)if (a[j] == nown)resn++;
	}
	int res = res0 < resn ? res0 : resn;
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
MOD = int(1e9+7)
N, M = map(int, input().split())

# f = 1
# mod_factorial = [1] + [(f := f * i % MOD) for i in range(1, M+1)]
mod_factorial = [1]
for i in range(1, M+1):
    mod_factorial.append(mod_factorial[-1] * i % MOD)

mod_fact_inv = [pow(x, MOD-2, MOD) for x in mod_factorial]

def modperm(n, k):
    return mod_factorial[n] * mod_fact_inv[n-k] % MOD

def modcomb(n, k):
    return modperm(n, k) * mod_fact_inv[k] % MOD

sigma = 0
for i in range(N+1):
    x = modcomb(N, i)
    x %= MOD
    x *= modperm(M, i)
    x %= MOD
    x *= modperm(M-i, N-i)
    x %= MOD
    x *= modperm(M-i, N-i)
    x %= MOD
    x *= -1 if i&1 else 1
    sigma += x

sigma %= MOD
print(sigma)


Measured memory_bytes: 150808
import itertools

class Dice:
    N = [0, 1, 5, 4]
    S = N[::-1]
    E = [0, 3, 5, 2]
    W = E[::-1]
    R = [1, 2, 4, 3]
    L = R[::-1]

    def __init__(self, numbers):
        self.numbers = numbers

    def __eq__(self, other):
        if isinstance(other, Dice):
            newdice = Dice(other.numbers.copy())
            for x in range(6):
                if 1 <= x <= 3:
                    newdice.toX('N')
                elif x == 4:
                    newdice.toX('N')
                    newdice.toX('E')
                elif x == 5:
                    [newdice.toX('E') for _ in range(2)]
                for _ in range(4):
                    if self.numbers == newdice.numbers:
                        return True
                    newdice.toX('R')

            else:
                return False

        else:
            return False

    def __ne__(self, other):
        return not self.__eq__(other)

    def toX(self, x):
        data = getattr(self, x)
        self.numbers.append(0)
        for k in range(5):
            i1 = data[k - 1] if k != 0 else 6
            i2 = data[k] if k != 4 else 6
            self.numbers[i1] = self.numbers[i2]
        del self.numbers[6]

    def setTopandFront(self, top, front):
        while self.numbers[0] != top:
            if self.numbers.index(top) in self.N:
                self.toX('N')
            else:
                self.toX('E')
        while self.numbers[1] != front:
            self.toX('R')


n = int(input())
dices = [Dice([int(i) for i in input().split()]) for _ in range(n)]
if all(dices[i1] != dices[i2] for i1, i2 in itertools.combinations(range(n), 2)):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 5696
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define pb push_back
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n,a;
	cin>>n>>a;
	cout<<n*n-a<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <cstring>
#define MAX_N 100001
#define INF 1000000007
using namespace std;
using ll = long long;

ll dp[MAX_N][13];
int modnow[MAX_N][10];
string ss;
void solve()
{
    int len = ss.size();
    for(int i = 0;i<10;i++)modnow[len-1][i]=i;
    for(int i = 0;i<10;i++){
        for(int j = len-2;j>=0;j--){
            modnow[j][i]=(modnow[j+1][i]*10)%13;
        }
    }

    for(int i = len-1;i>=0;i--)
    {
        if(ss[i]=='?'){
            int bits = len-1-i;
            for(int now = 0;now<10;now++){
            for(int j = 0;j<13;j++){
                dp[i][(modnow[i][now]+j)%13] += dp[i+1][j];
                dp[i][(modnow[i][now]+j)%13] %= INF;
                if(i == len-1){
                    dp[i][now] = 1;
                }
            }
            }
        }
        else{
            int now = ss[i]-'0';
            int bits = len-1-i;
            now = modnow[i][now];
            for(int j = 0;j<13;j++){
                dp[i][(now+j)%13] += dp[i+1][j];
                dp[i][(now+j)%13] %= INF;
                if(i==len-1){
                    dp[i][now] = 1;
                }
            }
        }
    }
    /*
    for(int i = 0;i<len;i++){
        for(int j = 0;j<13;j++){
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }
    */
}

int main()
{
    getline(cin,ss);
    solve();
    cout<<dp[0][5]<<endl;
    return 0;
}


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

using namespace std;

int main(void){
	string s;
	cin >> s;
	int i,locc=100;
	int flag = 100;
	if(s[0] != 'A') flag = 0;
	int count = 0;
	for(i=0;i<s.size();i++){
		if(s[i]=='C'){
			locc = i;
			count++;
		}
	}
	if(locc == 100 || count != 1) flag = 0;
	else if(locc < 2 || s.size()-2 < locc) flag = 0;
	int asc;
	int start = (int)'a';
	int goal = (int)'z';
	if(flag == 100){
		for(i=0;i<s.size();i++){
			if(i != 0 && i != locc){
				asc = (int)s[i];
				if(start>asc||asc>goal) flag = 0;
			}
		}
	}
	if(flag == 100) cout << "AC" << endl;
	if(flag == 0)   cout << "WA" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int MOD = 1e9+7;

int main(){
  string L;
  cin >> L;
  vector<vector<ll>> dp(L.size()+1, vector<ll>(2));
  dp[0][0] = 1;
  for(int i=1; i<=L.size(); i++) {
    if(L[i-1] == '0') {
      dp[i][0] = (dp[i][0]+dp[i-1][0])%MOD;
      dp[i][1] = (dp[i][1]+dp[i-1][1]*3)%MOD;
    } else {
      dp[i][0] = (dp[i][0]+dp[i-1][0]*2)%MOD;
      dp[i][1] = (dp[i][1]+dp[i-1][0])%MOD;
      dp[i][1] = (dp[i][1]+dp[i-1][1]*3)%MOD;
    }
  }
  int ans = (dp[L.size()][0]+dp[L.size()][1])%MOD;
  cout << ans << endl;
  return 0;
}

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

int main() {
  string w, s, t;
  cin >> w;
  transform(w.begin(), w.end(), w.begin(), ::tolower);
  int count = 0;
  while (true) {
    cin >> s;
    if (s == "END_OF_TEXT") break;
    transform(s.begin(), s.end(), s.begin(), ::tolower);
    if (s == w) count++;
  }
  cout << count << endl;

  return 0;
}


Measured memory_bytes: 3120
#include <stdio.h>

int main(void)
{
	int x,y,r,k;
	
	//printf("x,yを入力してください\n");
	scanf("%d %d",&x,&y);
	
	if(x<y)
	{
		
		k=x;
		x=y;
		y=k;
	}
	
	
		while(y>0)
		{
			r=x%y;
			x=y;
			y=r;
		}
	
	
	printf("%d\n",x);
	
	return 0;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
const int maxn=3123;
char aux1[maxn],aux2[maxn];
int dp[maxn][maxn];
vector<char>v;
int main()
{
	scanf(" %s",aux1+1);
	scanf(" %s",aux2+1);
	int n=strlen(aux1+1);
	int m=strlen(aux2+1);
	for(int i=0;i<=n;i++)
		dp[i][0]=0;
	for(int i=0;i<=m;i++)
		dp[0][i]=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(aux1[i]==aux2[j])
				dp[i][j]=dp[i-1][j-1]+1;
			else 
				dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
		}
	}
	int curi=n;
	int curj=m;
	while(true)
	{
		if(curi==0 || curj==0)
			break;
		if(aux1[curi]==aux2[curj])
		{
			v.push_back(aux1[curi]);
			curi--;
			curj--;
		}
		else
		{
			if(dp[curi-1][curj]>dp[curi][curj-1])
				curi--;
			else
				curj--;
		}		
	}
	for(int i=v.size()-1;i>=0;i--)
		printf("%c",v[i]);
}

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

#define rep(i, s, n) for (Int i = s; i < (Int)(n); i++)
#define rrep(i, n, s) for (Int i = n - 1; i >= s; i--)
#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).end()
 
double EPS = 1e-10;
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

vector< int64_t > divisor(int64_t n) {
    vector< int64_t > ret;
    for (int64_t i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}

int main() {
    Int n;
    cin >> n;
    Int res = divisor(n - 1).size() - 1;
    vector<Int> a = divisor(n);
    rep(i, 1, a.size()) {
        Int b = n;
        while (b % a[i] == 0) {
            b /= a[i];
        }
        res += b % a[i] == 1;
    }
    dump(res);
    return 0;
}

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

int main(){
    int N,M; cin >> N >> M;
    vector<int> H(N);
    vector<priority_queue<int> > G(N+1);
    rep(i,0,N) cin >> H[i];
    rep(i,0,M){
        int a,b; cin >> a >> b;
        a--; b--;
        G[a].push(H[b]);
        G[b].push(H[a]);
    }
    int ans=0;
    rep(i,0,N){
        if(G[i].empty()){
            ans++;
            continue;
        }
        if(G[i].top() < H[i]) ans++;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 9572
import sys
H,W=list(map(int,input().strip().split(' ')))
grid=[]
for _ in range(H):
    grid+=[input()]
dp=[[0]*W for i in range(H)]
dp[0][0]=1
MOD=10**9+7
for i in range(H):
    for j in range(W):
        if i==0 and j==0:
            continue
        if grid[i][j]=="#":
            continue
        temp1=0
        temp2=0
        if i>0:
            temp1=dp[i-1][j]
        if j>0:
            temp2=dp[i][j-1]
        dp[i][j]=(temp1+temp2)%(MOD)
print(dp[-1][-1])
        

Measured memory_bytes: 53484