akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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

const int mod = 1000000007;
struct mint {
  ll x;
  // コンストラクタ。引数のxが負でもxは正になるようにしている
  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 {
    return mint(*this) += a;
  }
  mint operator-(const mint a) const {
    return mint(*this) -= a;
  }
  mint operator*(const mint a) const {
    return mint(*this) *= 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 {
    return mint(*this) /= a;
  }
};
istream& operator>>(istream& is, const mint& a) {
  return is >> a.x;
}
ostream& operator<<(ostream& os, const mint& a) {
  return os << a.x;
}

signed main() {
  ll N, M;
  cin >> N >> M;

  map<ll, ll> m;
  rep(i, M) {
    ll a;
    cin >> a;
    m[a] = 1;
  }

  vector<mint> dp(N + 1);
  rep(i, N + 1) {
    dp[i] = INF;
  }

  rep(i, N + 1) {
    if (m[i] == 1) {
      dp[i] = 0;
      continue;
    }

    if (i == 0) {
      dp[i] = 1;
      continue;
    }

    if (i == 1) {
      dp[i] = dp[i - 1];
      continue;
    }
    dp[i] = dp[i - 1] + dp[i - 2];
  }

  mint ans = dp[N];
  COUT(ans);

  return 0;
}

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

int main(){
  string A,B;
  int ans=0;
  cin >> A >> B;
  for(int i=0;i<3;i++){
    if(A.at(i)==B.at(i)){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3584
#include <cstdio>
#include <algorithm>
using namespace std;

const int maxn=1e5+5;

int n,tot,ans;
int bit[maxn];
int now[maxn],pre[maxn*2],son[maxn*2];

int read() {
	int x=0,f=1;char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
	for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-'0';
	return x*f;
}

void add(int a,int b) {
	pre[++tot]=now[a];
	now[a]=tot,son[tot]=b;
}

void dfs(int fa,int u) {
	int limit=0;
	for(int p=now[u],v=son[p];p;p=pre[p],v=son[p])
		if(v!=fa) {
			dfs(u,v);
			limit|=bit[u]&bit[v];
			bit[u]|=bit[v];
		}
	int mx=20;
	while(mx>=0&&(!(limit&(1<<mx))))mx--;
	mx++;
	while(bit[u]&(1<<mx))mx++;
	bit[u]|=1<<mx;
	ans=max(ans,mx),bit[u]=bit[u]>>mx<<mx;
}

int main() {
	n=read();
	for(int i=1;i<n;i++) {
		int a=read(),b=read();
		add(a,b),add(b,a);
	}
	dfs(0,1);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 7040
n, m = [int(item) for item in input().split()]
ab = [[int(item) for item in input().split()] for _ in range(m)]

way = [0] * (n + 1)
for a, b in ab:
    if a == 1:
        way[b] += 1
    if b == 1:
        way[a] += 1
    if a == n:
        way[b] += 1
    if b == n:
        way[a] += 1
if 2 in way:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 40856
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

signed main(){
	string S;
	cin>>S;
	REP(i,S.size()-1){
		if(S[i]==S[i+1]){
			cout<<"Bad"<<endl;
			return 0;
		}
	}
	cout<<"Good"<<endl;
	return 0;
}


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

int main(){
    int r;
    cin >> r;
    string s;
    if(0<=r&&r<1200) s="ABC";
    else if(1200<=r&&r<2800) s="ARC";
    else s="AGC";
    cout << s << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define Max 500000
#define term 1000000000

int Left[(Max/2)+2], Right[(Max/2)+2];
int c=0;


void merge(int e[], int n, int left, int mid, int right){
  int i,j,k;

  int x = (mid-left);
  int y = (right-mid);

  for ( i=0; i<x; i++ )
   Left[i] = e[left+i];
  for ( i=0; i<y; i++ )
   Right[i] = e[mid+i];

  Left[x]= Right[y] = term;
  i = j = 0;
  for ( k=left; k<right; k++){
    c++;
    if ( Left[i]<=Right[j] ){
      e[k] = Left[i++];
    } else {
      e[k] = Right[j++];
    }
  }
}

void mergeSort(int e[], int n, int left, int right ){
  int mid;
  if ( left+1<right ){
    mid=(left + right)/2;
    mergeSort(e, n, left, mid);
    mergeSort(e, n, mid, right);
    merge(e, n, left, mid, right);
  }
}

int main(){
  int e[Max], n, i;
  scanf("%d", &n);
  for ( i=0; i<n; i++) {
    scanf("%d", &e[i]);
    if (e[i]>=term ){
      return 1;
    }
  }
  mergeSort(e,n,0,n);

  for ( i=0; i<n; i++) {
    if ( i !=0 ) 
    printf(" ");

    printf("%d", e[i]);
    }
  printf("\n");

  printf("%d\n", c);


  return 0;
}




Measured memory_bytes: 5760
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int t = 1; 
    // cin >> t; 
    while (t--) {
        long double a, b;
        cin >> a >> b;

        int x = a;
        int y = round(b * 100);

        cout << x * y / 100 << '\n';
    }
    
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    return 0;
}



Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;
int a[200007];
int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);
	int n; cin>>n;
	int mx1=0;
	int mx2=0;
	for(int i=1; i<=n; i++) {
		cin>>a[i];
		if(mx1<a[i]) {
			mx2=mx1;
			mx1=a[i];
		}
		else if(mx2<a[i]) {
			mx2=a[i];
		}
	}
	for(int i=1; i<=n; i++) {
		if(mx1==a[i]) {
			cout<<mx2<<endl;
		}
		else{
			cout<<mx1<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 2432
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)

template<typename T>
void remove(vector<T>& vector, unsigned int index){
vector.erase(vector.begin() + index);
}

typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
long long dp[31] = {1,1,2};
void func(int n){
	for(int i = 3; i <= 30; i++){
		dp[i] = dp[i-1]+dp[i-2]+dp[i-3];
	}
}


int main(void){
	func(30);
	int n;
	while(cin >> n, n){
		cout << dp[n]/10/365+1 << endl;
	}

	return 0;
}



int StrToInt(string s){
	stringstream ss;
	ss << s;
	int val;
	ss >> val;
	return val;
}
string IntToStr(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long lli;
#define int long long

const int NMAX = 2*1e2 + 50; 
int color[NMAX];
int visited[NMAX];
bool adj[NMAX][NMAX];

signed main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	for(int i=1; i<=n; i++){
		string s;
		cin >> s;
		for(int j=1; j<=n; j++)
			adj[i][j] = s[j-1]-'0';
	}

	fill(color, color+NMAX, -1);
	queue <pii> q;
	q.push(mp(1,0));
	color[1] = 0;

	/*while(!q.empty()){
		pii t = q.front();
		q.pop();

		for(int i=1; i<=n; i++){
			if(i == t.fi) continue;
			if(adj[t.fi][i]){
				if(color[i] == -1){
					color[i] = 1-t.sc;
					q.push(mp(i, 1-t.sc));
				}else if(color[i] == color[t.fi]){
					cout << -1;
					return 0;
				}
			}
		}
	}*/

	int res = 0;
	
	for(int i=1; i<=n; i++){
		queue <pii> q2;
		q2.push(mp(i, 1));
		fill(visited, visited+NMAX, 0);
		visited[i] = 1;
		while(!q2.empty()){
			pii t = q2.front();
			q2.pop();
			res = max(res, t.sc);

			for(int i=1; i<=n; i++){
				if(i == t.fi) continue;
				if(adj[i][t.fi]){
					if(visited[i]){
						if(visited[i] != t.sc-1 and visited[i] != t.sc+1){
							cout << -1;
							return 0;
						}
						continue;
					}
					visited[i] = t.sc+1;
					q2.push(mp(i, t.sc+1));
				}
			}
		}
	
	}
	

	cout << res;

	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<set>
#include<tuple>
#include<ctime>
#include<functional>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> p; 
#define rep(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))

int main(){
  int s;
  cin>>s;
  int first,sec;
  first=s/100;
  sec=s%100;
  if(first>=1 && first<=12 && sec<=12 && sec>=1) p("AMBIGUOUS");
  else if(first>=1 && first<=12 && (sec==0 || sec>12)) p("MMYY");
  else if(sec>=1 && sec<=12 && (first==0 || first>12)) p("YYMM");
  else p("NA");
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;
ll arr[maxn], prefix[maxn];
ll check(ll val, ll n) {
    ll cnt = 0;
    for (int i = 1; i <= n; ++i) {
        int pos = lower_bound(arr + 1, arr + 1 + n, val - arr[i]) - arr;
        cnt += n + 1 - pos;
    }
    return cnt;
}
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    ll n, m; cin >> n >> m;
    for (int i = 1; i <= n; ++i) cin >> arr[i];
    sort(arr + 1, arr + 1 + n);
    for (int i = 1; i <= n; ++i) prefix[i] = prefix[i - 1] + arr[i];
    ll left = 0, right = 2 * maxn, res = 0;
    while (left <= right) {
        ll mid = (left + right) / 2; ll cnt;
        if ((cnt = check(mid, n)) < m)
            right = mid - 1;
        else {
            left = mid + 1, res = 0;
            for (int i = 1; i <= n; ++i) {
                int pos = lower_bound(arr + 1, arr + 1 + n, mid - arr[i]) - arr;
                res += (ll)(n + 1 - pos) * arr[i] + prefix[n] - prefix[pos - 1];
            }
            if (cnt > m) res -= (cnt - m) * mid;
        }
    }
    cout << res << '\n';
}

Measured memory_bytes: 1920
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*                                                    
      I LOVE CLARICE STARLING...                                                               
        EXPLAINATION BELOW->
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
void solve()
{
  int n;cin>>n;
  set<string>A;
  while(n--)
  {
      string s;cin>>s;
      A.insert(s);
  }
  cout<<sz(A)<<"\n";
}
int main()
{
   fastio
   solve();
  return 0;
}
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
// Syntax to create a min heap for priority queue priority_queue <int, vector<int>, greater<int>>; 
/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/


Measured memory_bytes: 19252
bin = []
for i in range(3):
  bin.append(list(map(int, input().split())))
bin = sum(bin, [])
N = int(input())
bingo = [False for _ in range(9)]
for _ in range(N):
  b = int(input())
  if b in bin:
    bingo[bin.index(b)] = True
if (bingo[0] and bingo[1] and bingo[2]) or (bingo[3] and bingo[4] and bingo[5]) or \
   (bingo[6] and bingo[7] and bingo[8]) or (bingo[0] and bingo[3] and bingo[6]) or \
   (bingo[1] and bingo[4] and bingo[7]) or (bingo[2] and bingo[5] and bingo[8]) or \
   (bingo[0] and bingo[4] and bingo[8]) or (bingo[2] and bingo[4] and bingo[6]):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9176
package main

import (
	"fmt"
)

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)
	var from, to int
	if a < c {
		from = c
	} else {
		from = a
	}
	if b < d {
		to = b
	} else {
		to = d
	}
	if to - from >= 0 {
		fmt.Println(to - from)
	} else {
		fmt.Println(0)
	}
}

Measured memory_bytes: 512
import math

z = 10**9 + 7

n, a, b = [int(i) for i in input().split()]

r = pow(2, n, z) - 1

def c(m):
  x = 1
  for i in range(n-m+1, n+1):
    x = x*i % z
  
  return (x * pow(math.factorial(m), z-2, z)) % z

r = (r - c(a) - c(b)) % z

print(r)

Measured memory_bytes: 5464
// https://atcoder.jp/contests/abc150/tasks/abc150_d

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

ll get_two_ct(ll n) {
  ll res = 0;

  while (n % 2 == 0) {
    res++;
    n /= 2;
  }

  return res;
}

void solve() {
  ll N, M;
  cin >> N >> M;

  VL as(N);
  rep(i, N) cin >> as[i];

  {
    ll twoCt = get_two_ct(as[0]);

    rep(i, N) {
      if (get_two_ct(as[i]) != twoCt) {
        drop(0);
      }
    }
  }

  ll lc = 1;
  ll h_lc = 1;

  rep(i, N) {
    lc = lcm(lc, as[i]);
    h_lc = lcm(h_lc, as[i] / 2);
  }

  ll res = M / h_lc - M / lc;
  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 1024
N,M=list(map(int,input().split()))
if M-N>2018 or (N%2019>M%2019):
    print(0)
else:


    ans=2018
    for i in range(N,M+1):
        for j in range(i+1,M+1):
            ans=min(ans,(i*j)%2019)
    print(ans)

Measured memory_bytes: 3060
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type Abbreviation ---------- */
using ll = long long;

/* ---------- Constants  */
const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* ---------- Short Functions ---------- */
template <typename T>
T gcd(T a, T b) {
    if (a > b) return gcd(b, a);
    return a == 0 ? b : gcd(b % a, a);
}

template <typename T, typename U>
T mypow(T b, U n) {
    if (n == 0) return 1;
    if (n == 1) return b /* % MOD */;
    if (n % 2 == 0) {
        return mypow(b * b /* % MOD */, n / 2);
    } else {
        return mypow(b, n - 1) * b /* % MOD */;
    }
}

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

int c[10][10];

int main() {
    int H, W;
    cin >> H >> W;

    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> c[i][j];
        }
    }

    int A[H][W];
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> A[i][j];
        }
    }

    for (int k = 0; k < 10; k++) {
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }

    int ret = 0;

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (A[i][j] == -1) continue;
            ret += c[A[i][j]][1];
        }
    }

    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#define min(X, Y) ((X) < (Y) ? (X) : (Y))

int dsum(int a);

int main()
{
	int n;
	int i, j;
	int ans = 1 << 27;

	scanf("%d", &n);

	for (i = 1; i < n; i++) {
		j = n - i;

		ans = min(ans, dsum(i) + dsum(j));
	}

	printf("%d\n", ans);

	return 0;
}

int dsum(int a)
{
	int res = 0;

	while (a) {
		res = res + (a % 10);

		a = a / 10;
	}

	return res;
}


Measured memory_bytes: 128
/*
*          Name : chaitanya
*
*     Institute : ANITS,Visakhapatnam
*
*/
#include<cstdio>
#include<iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include<cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define inf  1000000000
#define all(x) begin(x),end(x)
#define ll long long int
#define ff first
#define ss second
#define pb push_back
const ll mod = 1000000007;
#pragma GCC optimization ("O3")
const int N = 100005;
using namespace std;

int main()
{
 
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  string s;
  cin >> s;
  int f = 0;
  for (int i = 0; i < (int)s.size() ; ++i)
  {
    if((i % 2 != 0 && s[i] == 'R') || (i % 2 == 0 && s[i] == 'L'))
    {
     f =1;
     break;
    }
  }
  if (f == 0)
  {
     cout << "Yes\n";
  }
  else
    cout << "No\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
	
	int n; cin >> n;
	vector<ll> a(n + 1, 0);
	vector<ll> accum(n + 1, 0);
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = 1; i <= n; i++) {
		accum[i] += a[i];
		accum[i] += accum[i - 1];
	}
	ll thresholdValue = 9223372036854775807LL;
	for (int i = 1; i <= n; i++) {
		ll tmp = abs(accum[i] - (accum[n] - accum[i]));
		chmin(thresholdValue, tmp);
	}
	cout << thresholdValue << endl;
	return 0;
}

Measured memory_bytes: 6408
#include <iostream>
using namespace std;
int main(){
  string s; cin >> s;
  const int n=4;
  bool flag=true;
  for(int i=0; i<n-1; i++){
    if(s[i+1]==s[i]) flag=false;
  }
  cout << (flag ? "Good\n" : "Bad\n");
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func oneInt() int {
	var a int
	fmt.Scan(&a)
	return a
}
func oneStr() string {
	var a string
	fmt.Scan(&a)
	return a
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func scanNums() (nums []int) {
	s := nextLine()
	numStr := strings.Split(s, " ")

	for _, n := range numStr {
		i, _ := strconv.Atoi(n)
		nums = append(nums, i)
	}
	return nums
}

func scanStrings() (strs []string) {
	s := nextLine()
	list := strings.Split(s, " ")
	strs = append(strs, list...)
	return strs
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}


func main() {
	r := oneInt()
	D := oneInt()
	x := oneInt()
	var temp = x
	for index := 0; index < 10; index++ {
		temp = r*temp - D
		fmt.Println(temp)
	}
}


Measured memory_bytes: 640
#include <iostream>
//#include <stdio.h>
using namespace std;

int main(){
	int A[101][101],b[101];
	int n, m;
	int sum;
	cin >> n >> m;
	
	for (int i=1;i<=n;i++){
		for (int j=1;j<=m;j++){
			cin >> A[i][j];
		}
	}
	for (int i=1;i<=m;i++){
		cin >> b[i];
	}
	
	for (int i=1;i<=n;i++){
		sum = 0;
		for (int j=1;j<=m;j++){
			sum += A[i][j] * b[j];
		}
		cout << sum << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1200
N, M = map(int, input().split())
a = []
maxn = 0
for i in range(N):
    a.append([int(i) for i in input().split()])


maxn = 0
for i in range(8):
    A = []
    tm = [1, 1, 1]
    for j in range(N):
        for k in range(3): # x, y, zの符号決定
            if i & (1 << k):
                tm[k] = a[j][k]
            else:
                tm[k] = -1 * a[j][k]
        A.append(sum(tm))
    A.sort(reverse=True)
    tmp = sum(A[:M])
    maxn = max(maxn, tmp)
print(maxn)

Measured memory_bytes: 45532
package main

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

func main() {
	nextReader = newScanner()
	s, t := nextString(), nextString()
	fmt.Println(t + s)
}

// ---------------------------------------------------------------
// I/O
// ---------------------------------------------------------------
var nextReader func() string

func newScanner() func() string {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 1024), int(1e11))
	sc.Split(bufio.ScanWords)
	return func() string {
		sc.Scan()
		return sc.Text()
	}
}

func nextString() string { return nextReader() }

func nextInt() int { n, _ := strconv.Atoi(nextReader()); return n }

func nextInts(size int) []int {
	ns := make([]int, size)
	for i := 0; i < size; i++ {
		ns[i] = nextInt()
	}
	return ns
}


Measured memory_bytes: 640
#include <iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
const int inf   = 1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};


int main(){
  int a,n;
  cin>>n>>a;
  n%=500;
  if(n<=a)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
  }

  
    


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

int N;
int A[210];

int main(){
	cin>>N;
    for (int i = 0; i < N; ++i) cin >> A[i];

	int res = 0;


    while (true){
        bool exist_odd = false;
        for (int i = 0; i<N; ++i){
            if (A[i] % 2 != 0) exist_odd = true;
        }

    if (exist_odd) break;

    for (int i = 0; i < N; ++i){
        A[i] /= 2;
    }
    ++res;
    }
    cout<<res<<endl;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int rever(int n)
{

int t=n,r,num=0;

while(t>=1)

{

r=t%10;

t=t/10;

num=num*10+r;

}

return num;

}
int isPalindrome(int num) // //check whether number is palindrome or not
{
int n=rever(num);

if(n==num)

return 1;

else

return 0;

}


int main()
{

int a,b;
cin>>a>>b;
int Count=0;

int n=a;

while(n<=b)
{

if(isPalindrome(n))//if number is palindrome then increment Counter
{

Count++;

}

n++;

}

printf("%d",Count);

return 0;

}



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

int main(){
	
	string s;cin>>s;
	s[3]='8';cout<<s<<endl;
	
	return 0;
}

//cout << ans?"Yes":"No" << endl;

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>
#define true false
#define false true
#define endl "\n"
#define c0 ios_base :: sync_with_stdio(0); cin.tie (0);
#define s second
#define f first
#define ll long long
#define ull unsigned ll
using namespace std;

const int MaxN = 1e5 + 17;
//const ll INF = 1e19 + 17;
const int MOD = 1e9 + 7;
//const double eps = 1e-8;
//const double pi = 3.14159265359;

ll d[MaxN];
int n, m;

int main()
{
    #ifdef DEBUG
        freopen (".in", "r", stdin);
        freopen (".out", "w", stdout);
    #endif
    cin >> n >> m;
    int w = max (n, m);
    n = min (n, m);
    m = w;
    if (n < m - 1)
        cout << 0, exit (0);
    d[1] = 1;
    for (int i = 2; i <= m; ++ i)
        d[i] = d[i - 1] * i, d[i] %= MOD;
    if (n == m)
        cout << ((d[m] * d[n]) % MOD * 2) % MOD;
    else
        cout << ((d[m] * d[n]) % MOD) % MOD;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
      ll n;
      cin>>n;
      ll A[n+5];
      ll sum=0;
     map<ll,ll> m;
     for(int i=0;i<n;i++){
       cin>>A[i];
       sum+=A[i];
       m[A[i]]++;
        }
  ll q;
  cin>>q;
  while(q--)
  {
    ll b,c;
    cin>>b>>c;
    ll ans=sum-m[b]*b+c*m[b];
    m[c]+=m[b];
    m[b]=0;
    cout<<ans<<endl;
    sum=ans;
     
    
  }
}

Measured memory_bytes: 10244
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(
        &mut std::io::stdin(),
        &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!(usize);
    let m = get!(usize);
    let mut ws = vec![vec![]; m];
    for _ in 0 .. n {
        let a = get!(usize);
        let b = get!();
        if a <= m {
            ws[a-1].push(b);
        }
    }
    let mut pq = std::collections::BinaryHeap::new();
    let mut ans = 0;
    for i in 0 .. ws.len() {
        for &w in ws[i].iter() {
            pq.push(w);
        }
        if let Some(w) = pq.pop() {
            ans += w;
        }
    }
    println!("{}", ans);
}

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

priority_queue<long long> q;
long long a[1010], b[1010], c[1010];
vector<long long> v;

signed main() {

    int x, y, z, k;
    scanf("%d %d %d %d", &x, &y, &z, &k);
    for ( int i = 0; i < x; i++ ) scanf("%lld", &a[i]);
    for ( int i = 0; i < y; i++ ) scanf("%lld", &b[i]);
    for ( int i = 0; i < z; i++ ) scanf("%lld", &c[i]);
    for ( int i = 0; i < x; i++ ) {
        for ( int j = 0; j < y; j++ ) {
            v.push_back ( a[i] + b[j] );
        }
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    for ( int i = 0; i < min(k, x*y); i++ ) {
        for ( int j = 0; j < z; j++ ) {
            q.push ( v[i] + c[j] );
        }
    }
    for ( int i = 0; i < k; i++ ) {
        printf("%lld\n", q.top());
        q.pop();
    }

    return 0;
}

Measured memory_bytes: 43108
n,m,*a=map(int,open(0).read().split());d=[0]*n*9
for i in range(n):
 for j in a:
  if d[i]or i<1:c=i+int("0255456376"[j]);d[c]=max(d[c],d[i]*10+j)
print(d[n])

Measured memory_bytes: 15348
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mod = 1000000007;
int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll n,x;
  cin>>n;
  ll sum1=0,sum2=0;
  for(ll i=0; i<n; i++){
        cin>>x;
    sum1=(sum1+sum2*x)%mod;
    sum2=(sum2+x)%mod;
  }
  cout<<(sum1)%mod;



    return 0;
}

Measured memory_bytes: 3680
#include <cstdio>

const int N = 200000;
int n;
char s[N + 1];

int main() 
{
	scanf("%d%s", &n, s);
	int r = 0;
	for (int i = 0; i < n; ++i) if (s[i] == 'R') ++r;
	int t = r;
	for (int i = 0; i < r; ++i) if (s[i] == 'R') --t;
	printf("%d\n", t);
	return 0;
}


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

/**
 * vector<int>ar(3);
 * for(auto&e:ar){
 *     scanf("%d",&e);
 * }
 * sort(ar.begin(),ar.end())
 * int sum=accumulate(ar.begin(),ar.end(),0);
 ***/

int main(){
    double pai=3.141592653589;
    int n;
    scanf("%d",&n);
    vector<int>ar(n);
    for(auto&e:ar){
        scanf("%d",&e);
    }
    for(int i=n-1;i>0;i--){
        printf("%d ",ar[i]);
    }
    printf("%d\n",ar[0]);
    return 0;
}

Measured memory_bytes: 1172
#include <iostream>

using namespace std;

int main(){
  int a, b, c, x, cnt=0;
  cin >> a >> b >> c >> x;

  for (int i=0; i<=a; i++) {
    for (int j=0; j<=b; j++) {
      for (int k=0; k<=c; k++) {
        if ((i*500)+(j*100)+(k*50)==x) cnt++;
      }
    }
  }

  printf("%d\n", cnt);
  return 0;
}

Measured memory_bytes: 256
// 2分木みたいになるらしい
#include <bits/stdc++.h>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    sort(A.rbegin(), A.rend());
    long long res = 0LL;
    for (int i = 1; i <= N - 1; ++i) {
        res += A[i / 2];
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4032
package main

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

const maxBuf = 300100

var buf []byte = make([]byte, maxBuf)
var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Buffer(buf, maxBuf)
	sc.Split(bufio.ScanWords)
	a := make([]int, 3)
	ma := 0
	sum := 0
	for i := 0; i < 3; i++ {
		sc.Scan()
		a[i], _ = strconv.Atoi(sc.Text())
		if ma < a[i] {
			ma = a[i]
		}
		sum += a[i]
	}

	sum -= ma

	sc.Scan()
	k, _ := strconv.Atoi(sc.Text())

	for ; k > 0; k-- {
		ma *= 2
	}
	fmt.Println(sum + ma)
}


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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

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

struct Edge {
  int to;
  int cost;
};

class Graph {
  private:
    int vertex;
    std::vector<long long> dist;
    std::vector<int> prev;

  public:
    long long inf = LLONG_MAX / 3;
    std::vector<std::vector<Edge> > list;

    Graph(int v);

    
    virtual void push(int from, int to, int cost) = 0;

    void dijkstra(int s);

    std::vector<long long> get_dist();
    std::vector<int> get_path(int s, int d);
};

Graph::Graph(int v) {
  vertex = v;
  list.resize(vertex);
  dist.resize(vertex);
  prev.resize(vertex);
  for (int i = 0; i < vertex; ++i) {
    dist[i] = inf;
    prev[i] = -1;
  }
}

void Graph::dijkstra(int s) {
  dist[s] = 0;

  std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int> >, std::greater<std::pair<int, int> > > pq;
  pq.push(std::make_pair(0, s));

  while (!pq.empty()) {
    int cost = pq.top().first;
    int v = pq.top().second;
    pq.pop();

    for (int i = 0; i < (int)list[v].size(); ++i) {
      Edge e = list[v][i];
      if (cost + e.cost < dist[e.to] ) {
        prev[e.to] = v;
        dist[e.to] = cost + e.cost;
        pq.push(std::make_pair(dist[e.to], e.to));
      }
    }
  }
}

std::vector<long long> Graph::get_dist() {
  return dist;
}

class DirectedGraph : public Graph {
  using Graph::Graph;

  public:
    void push(int from, int to, int cost) {
      Edge e;
      e.to = to;
      e.cost = cost;
      list[from].push_back(e);
    }
};

int main() {
  
  int v;
  int e0;
  int s;

  scanf("%d %d %d", &v, &e0, &s);

  std::vector<std::vector<Edge> > vec(v);

  DirectedGraph g = DirectedGraph(v);

  int from, to, cost;

  for (int i = 0; i <  e0; i++) {
    scanf("%d %d %d", &from, &to, &cost);
    g.push(from, to, cost);
  }

  g.dijkstra(s);
  std::vector<long long> dist = g.get_dist();
  for (long long a: dist) {
    if (a == g.inf) printf("INF\n");
    else printf("%lld\n", a);
  }
}



Measured memory_bytes: 15964
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    vector<int> ans(0);
    bool p[999999]; for (int i=0; i<999999; i++) p[i]=true;
    p[1]=false;
    int sum=0, n;
    for (int i=2; i<998; i++)
    {
        for (int j=i+i; j<=999999; j+=i) p[j]=false;
    }
    while (cin>>n)
    {
        for (int i=1; i<=n; i++) if (p[i]) sum++;
        ans.push_back(sum);
        sum=0;
    }
    for (int i=0; i<ans.size(); i++) cout<<ans[i]<<'\n';
    return 0;
}



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

const int MAXN = 20000200;

char s[MAXN];

signed main() {
	scanf("%s", s);
	int n = (int) strlen(s);
	long long cur = 0, ans = 0;
	for(int i = 0; i < n; i++) {
		if(s[i] == 'B') cur++;
		else ans += cur;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 384
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int[] a = new int[5];
		int idx = -1;
		int mm = 10;
		for (int i = 0; i < 5; i++) {
			a[i] = sc.nextInt();
		}

		for (int i = 0; i < 5; i++) {
			int m = a[i] % 10;
			if (m != 0 && m < mm) {
				idx = i;
				mm = m;
			}
		}

		int ans = 0;
		for (int i = 0; i < 5; i++) {
			if (i == idx) {
				ans += a[i];
			} else {
				ans += (int) (Math.ceil(a[i] / 10.0) * 10);
			}
		}

		out.println(ans);

		sc.close();

	}

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

}


Measured memory_bytes: 23764
import std.stdio, std.string, std.conv;

void main()
{
	auto u = readln.chomp, A = u[0], B = u[1], C = u[2];
	auto s = readln.chomp, D = s[0], E = s[1], F = s[2];
	if(A == F && B == E && C == D){
		writeln("YES");
	} else {
		writeln("NO");
	}
}

Measured memory_bytes: 256
def main():
    N = int(input())
    A = list(map(int, input().split()))
    flag = True
    for a in A:
        if a % 2 == 0:
            if a % 3 == 0 or a % 5 == 0:
                continue
            else:
                flag = False

    if flag:
        print('APPROVED')
    else:
        print('DENIED')


if __name__ == "__main__":
    main()

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

int main() {
	vector<char>even(0);
	vector<char>odd(0);
	for (int i=0;i<50;i++){
		char e,o;
		cin >>o>>e;
		odd.push_back(o);
		even.push_back(e);
	}
	bool jud;
	jud=true;
	
	for (int i=0;i<even.size();i++){
		if(even.at(i) == 'R'){
			jud=false;
			break;
		}
	}
	for (int i=0;i<odd.size();i++){
		if (odd.at(i) == 'L'){
			jud=false;
			break;
		}
	}
	
	if(jud){
		cout <<"Yes"<<endl;
	}
	else{
		cout << "No"<<endl;
	}
	
	
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
typedef long long LL;
LL A, B, C, k;
int main() {
	scanf("%lld%lld%lld%lld", &A, &B, &C, &k);
	if(k & 1)printf("%lld\n", B - A);
	else printf("%lld\n", A - B);
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
	
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int h = sc.nextInt();
		int n = sc.nextInt();
		boolean[][] fields = new boolean[h][w];
		for (int v = 0; v < n; v++) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			int a = sc.nextInt();
			switch (a) {
				case 1:
				for (int i = 0; i < x; i++) {
					for (int j = 0; j < h; j++) {
						fields[j][i] = true;
					}
				}
				break;
				case 2:
				for (int i = x; i < w; i++) {
					for (int j = 0; j < h; j++) {
						fields[j][i] = true;
					}
				}
				break;
				case 3:
				for (int i = 0; i < w; i++) {
					for (int j = 0; j < y; j++) {
						fields[j][i] = true;
					}
				}
				break;
				case 4:
				for (int i = 0; i < w; i++) {
					for (int j = y; j < h; j++) {
						fields[j][i] = true;
					}
				}
				break;
			}
		}
		int cnt = 0;
		for (int i = 0; i < w; i++) {
			for (int j = 0; j < h; j++) {
				if (!fields[j][i]) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 24788
N = int(input())
a = list(map(int,input().split()))
now = 1
check = 1
count = 0
if 1 not in a:
    print(-1)
else:
    for i in range(N):
        if a[i] != check:
            count += 1
        else:
            check += 1
    print(count)

Measured memory_bytes: 26268
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(void) {
	int n, sum = 0;
	cin >> n;
	n *= 2;
	std::vector<int> v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	for (int i = 0; i < n; i += 2)
		sum += v[i];
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF LLONG_MAX 
#define dd double 
#define fi first
#define se second
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define dll deque<long long>
#define qll queue<long long>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define vvll vector<vector<ll>>
#define vpll vector<pair<long long,long long>>
#define vpcl vector<pair<char,long long>>
#define vpsl vector<pair<string,long long>>
#define stll stack<long long>
#define stc stack<char>
#define mll map<long long,long long>
#define pll pair<long long,long long>
#define psl pair<string,long long>
#define mcl map<char,long long>
#define msl map<string,long long>
#define pcl pair<char,long long>
#define mmll multimap<long long,long long> 
#define mmcl multimap<char,long long>
#define mmsl multimap<string,long long>
#define sll set<long long>
#define sc  set<char>
#define ss  set<string>
#define msll multiset<long long>
#define msc  multiset<char>
#define mss  multiset<string>
#define lb lower_bound
#define up upper_bound
#define lt length
#define clr clear
#define ap append
#define sz size
#define sub substr
#define ull unsigned long long int
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
//#include <boost/multiprecision/cpp_int.hpp> 
//using boost::multiprecision::cpp_int; 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

ll modexp(ll x,ll n,ll p){    //modular exponential function
  if(n==0){return 1;}
  ll u = modexp(x,n/2,p);
  u = u*u%p;
  if(n%2==1){u=(u*x)%p;}
  return u;
}

ll gcd (ll a, ll b) {     //Eulers algorithm
    if (b == 0)
        return a;
    else
        return gcd (b, a % b);
}

int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll t; 
    // cin>>t;
    t=1;
    while(t--){
     ll n; cin>>n;
     ll x=1;
     while(x*1000<n){
         x++;
     }
     cout<<(x*1000-n);
    }
}


Measured memory_bytes: 3648
import queue
n, m = map(int, input().split())
g = [[] for _ in range(n+1)]

for i in range(m):
    a, b = map(int, input().split())
    g[a].append(b)
    g[b].append(a)

#print(g)

root = [0] * n
count = 0
q = queue.Queue()
q.put(0)
root[0] = 1
count += 1
while not q.empty():
    p = q.get()
    for i in g[p+1]:
        if root[i-1] <= 0:
            q.put(i-1)
            root[i-1] = p + 1
            count += 1
            #print(p,i,count,root)
            if count >= n:
                break


if count < n:
    print('No')
    exit()
else:
    print('Yes')
    for i in range(1,n):
        print(root[i])




Measured memory_bytes: 37576
import java.util.Scanner;
public class Main {
@SuppressWarnings("resource")
public static void main(String[] args) {
	Scanner sc =new Scanner(System.in);
	int N=sc.nextInt();
	String S=sc.next();
	String[] S2=S.split("");
	if(N%2==1) {
		System.out.println("No");
		System.exit(0);
	}
	for(int i=N/2;i<N;i++) {
		if(!S2[i].equals(S2[i-N/2])) {
			System.out.println("No");
			System.exit(0);
		}
	}
	System.out.println("Yes");


}
}

Measured memory_bytes: 22608
//People only find me interesting because they can't tell whether I'm serious or not
//#include <boost/multiprecision/cpp_int.hpp> 
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
typedef long long int ll;
typedef double db;
typedef __int128 s128;
typedef __uint128_t u128;
typedef unsigned long long u64;
#define int long long int
#define P 1000000007
#define Q 1000000006
#define sz(a) (ll)a.size()
#define lt(a) (ll)a.length()
#define pll pair<ll,ll>
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define bac(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define umll unordered_map<ll,ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define teevra_gati ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define N 105
#define PI 3.14159265359
#define inf LLONG_MAX
//using namespace boost::multiprecision; 
using namespace __gnu_pbds;
using namespace std;
ll v[N], w[N], dp[N][100005]; 
void solve(){
    ll n,W;
    cin>>n>>W;
    f(i,1,n+1) cin>>w[i]>>v[i];
    f(i,1,n+1){
        f(j,1,W+1){
            dp[i][j] = dp[i-1][j];
            if(j-w[i]>=0) dp[i][j] = max(v[i] + dp[i-1][j-w[i]], dp[i][j]);
        }
    }
    cout<<dp[n][W];
}
signed main() {
    teevra_gati
    
    solve();

    return 0;
}

Measured memory_bytes: 79360
#include<bits/stdc++.h>
#define re register
#define int long long
using namespace std;
inline int read(){
	re int t=0;
	re char v=getchar();
	while(v<'0')v=getchar();
	while(v>='0'){
	t=(t<<3)+(t<<1)+v-48;
	v=getchar();}
	return t;
}
inline int ksm(re int x,re int y){
	int ans=1;
	while(y){
		if(y&1)ans*=x;
		x*=x;
		y>>=1;
	}
	return ans;
}
long long n,k,ans;
signed main(){
	n=read();k=read();
	while(n>=ksm(k,ans))++ans;
	printf("%lld",ans);
}


Measured memory_bytes: 256
# unionfind
class Uf:
    def __init__(self, N):
        self.p = list(range(N))
        self.rank = [0] * N
        self.size = [1] * N

    def root(self, x):
        if self.p[x] != x:
            self.p[x] = self.root(self.p[x])

        return self.p[x]

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

    def unite(self, x, y):
        u = self.root(x)
        v = self.root(y)

        if u == v: return False

        if self.rank[u] < self.rank[v]:
            self.p[u] = v
            self.size[v] += self.size[u]
            self.size[u] = 0
        else:
            self.p[v] = u
            self.size[u] += self.size[v]
            self.size[v] = 0

            if self.rank[u] == self.rank[v]:
                self.rank[u] += 1

        return True

    def count(self, x):
        return self.size[self.root(x)]

N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]
uf = Uf(N+1)
ans = N * (N-1) // 2
Ans = []
for a, b in AB[::-1]:
    Ans.append(ans)
    c1, c2 = uf.count(a), uf.count(b)
    if uf.unite(a, b):
        ans -= c1 * c2
Ans.reverse()
print("\n".join(map(str, Ans)))


Measured memory_bytes: 43580