akhauriyash/Code-Regression huggingface dataset:
//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include<ext/rope>
using namespace __gnu_cxx;
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef complex<int> C;
#define X real()
#define Y imag()
//typedef unordered_set<ll> usll;
//typedef unordered_multiset<ll> umsll;
typedef multiset<ll> msll;
typedef set<ll> sll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef vector<pair<ll,ll> > vpll;
typedef priority_queue<ll> pqll;
typedef vector<int> vi;
typedef set<int> si;
typedef multiset<int> msi;
//typedef unordered_multiset<int> umsi;
//typedef unordered_set<int> usi;
typedef pair<int,int> pi;
typedef vector<pair<int,int> > vpi;
typedef vector<pair<double,double> > vpd;
typedef pair<double,double> pd;
typedef priority_queue<int> pqi;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ind_set;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ind_setll;
#define in insert
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define be begin
#define en end
#define itr iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mo 998244353
#define inf 1000000000000000001
#define ninf -1000000000000000001
#define ima INT_MAX
#define imi INT_MIN
#define oncnt __builtin_popcount
#define zerobegin __builtin_clz
#define zeroend __builtin_ctz
#define parity __builtin_parity
const ld pii=3.14159265359;
inline ll modpow(ll x,ll n){if(n==0)return 1;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){    if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return((a-b+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}


int main()
{
//io
int testcases=1;//cin>>testcases;
while(testcases--)
{	
string a,b;
cin>>a>>b;
int n=a.length();
int m=b.length();
int mov[n+1][m+1];
int dp[n+1][m+1];
for(int i=0;i<=n;i++)
{
	for(int j=0;j<=m;j++)
	{
		if(i==0||j==0)
		{dp[i][j]=0;
	mov[i][j]=0;
	}
		else
		{
			if(a[i-1]==b[j-1])
			{dp[i][j]=1+dp[i-1][j-1];
			mov[i][j]=1;		
		}
			else
			{
				if(dp[i-1][j]>dp[i][j-1])
				{
					dp[i][j]=dp[i-1][j];
					mov[i][j]=2;
				}
				else
				{
					dp[i][j]=dp[i][j-1];
					mov[i][j]=3;
				}
			}
		}
	}
}

string ans;


int l=n,r=m;
while(true)
{if(mov[l][r]==0)
break;
	if(mov[l][r]==1)
	{ans+=a[l-1];
l--;
r--;	
}
	else if(mov[l][r]==2)
	l--;
	else
	r--;
	
}

reverse(ans.begin(),ans.en());
cout<<ans;
}return 0;}







Measured memory_bytes: 70656
#include <cstddef>
#include <complex>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale> 

using ll = long long;
using ull = unsigned long long;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

int main()
{
    using namespace std;

    constexpr ll mod = 998244353;

    int a, b;
    cin >> a >> b;
    cout << a + b / 2 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define MAX 200000
using namespace std;

int main(void)
{
    int N, A[MAX], B[MAX];
    int i;
    int large_1 = 1, large_2 = 1;
    cin >> N;
    for(i=0;i<N;i++)cin >> A[i];
    for(i=0;i<N;i++){
        if(large_1<A[i]){
            large_2 = large_1;
            large_1 = A[i];
        }else if(large_2<A[i]){
            large_2 = A[i];
        }
    }
    for(i=0;i<N;i++){
        if(A[i]==large_1)B[i]=large_2;
        else B[i]=large_1;
    }
    for(i=0;i<N;i++)cout<<B[i]<<endl;

    return 0;
}


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

#define pb push_back
#define mp make_pair
#define taskname "A"

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef double ld;
typedef pair<int,int> ii;
typedef tree <int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;
int n, m;
vector<int> adj[maxn],adj1[maxn];
int lab[maxn];
int FindLab(int u){return lab[u] < 0 ? u : lab[u] = FindLab(lab[u]);}
int a[maxn],b[maxn];
ll dp[maxn] , sum[maxn];
void dfs(int u){
    sum[u] = b[u];
    ll mi = a[u];
    for(auto c : adj1[u]){
        dfs(c);
        sum[u] += sum[c];
        dp[c] = max(dp[c] , (ll)a[u]);
        mi = min(mi , -sum[c] + dp[c]);
    }
    dp[u] = sum[u] + mi;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP","r")){
		freopen(taskname".INP", "r",stdin);
		freopen(taskname".OUT", "w",stdout);
    }
    fill_n(lab,maxn,-1);
    cin >> n >> m;
    for(int i = 1 ; i <= n ; ++i){
        cin >> a[i] >> b[i];
        a[i] = max(0 , a[i] - b[i]);
    }
    for(int i = 1 ; i <= m ; ++i){
        int u , v;cin >> u >> v;
        adj[u].pb(v);adj[v].pb(u);
    }
    vector<int> order(n);iota(order.begin(),order.end(),1);
    vector<int> id(n + 1);
    sort(order.begin(),order.end(),[&](const int x , const int y){
         return a[x] < a[y];
         });
    for(int i = 0 ; i < n ; ++i){
        id[order[i]] = i;
    }
    for(auto u : order){
        for(auto c : adj[u]){
            c = FindLab(c);
            if(id[c] < id[u] && c != u){
                lab[c] = u;
                adj1[u].pb(c);
//                cout << u << " " << c << endl;

            }
        }
    }
    dfs(order.back());
    cout << dp[order.back()];
}



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

int main() {
    i64 N, K;
    cin >> N >> K;
    vector<i64> A(N + 1);
    for (int i = 1; i <= N; i++) cin >> A[i];
    vector<i64> kaisa(N + 1);
    for (int i = 2; i <= N; i++) {
        kaisa[i] = A[i] - A[i - 1];
    }
    set<i64> st;
    i64 res = 0;
    i64 onaji = 0;
    i64 minuscnt = 0;
    for (int i = 1; i <= K; i++) {
        st.insert(A[i]);
        if (kaisa[i] < 0) minuscnt++;
    }
    if (minuscnt > 0) res++;
    else onaji = 1;
    
    for (int i = K + 1; i <= N; i++) {
        if (kaisa[i - K + 1] < 0) minuscnt--;
        if (kaisa[i] < 0) minuscnt++;
        if (kaisa[i] < 0) {
            res++;
            st.erase(A[i - K]);
            st.insert(A[i]);
            //cerr << A[i - K] << " " << A[i] << " " << res << endl;
        } else {
            st.erase(A[i - K]);
            auto itr = st.end();
            itr--;
            if (minuscnt == 0) {
                onaji = max(onaji, 1LL);
            }
            else if (A[i - K] < *st.begin() && A[i] > *itr) {
                res += 0;
            } else {
                res++;
            }
            if (A[i] == 9) cerr<<minuscnt<<"\n";
            //cerr << A[i - K] << " " << *st.begin() << " " << A[i] << " " << *itr << " " << res << endl;
            st.insert(A[i]);
        }
    }
    cout << res + onaji << "\n";
    return 0;
}

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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
constexpr int MOD = 1e9 + 7;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vec>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) {
    assert(v.size() == w.size());
    rep (i, v.size())
        cin >> v[i] >> w[i];
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vec a(n - 1), b(n - 1);
    init(a, b);
    vec c(n);
    init(c);
    sort(all(c));

    vector<multiset<int>> tree(n + 1);
    rep (i, n - 1) {
        tree[a[i]].insert(b[i]);
        tree[b[i]].insert(a[i]);
    }

    int val = 0;

    vec d(n + 1);

    rep (itr, n) {
        int mi = INF, midx = -1;
        For(i, 1, n) {
            int now = tree[i].size();
            if (now > 0 and now < mi) {
                mi = tree[i].size();
                midx = i;
            }
        }
        if (midx == -1) break;
        d[midx] = c[itr];
        val += c[itr] * mi;
        // sakujo
        repall (aite, tree[midx]) { tree[aite].erase(midx); }
        tree[midx] = multiset<int>();
    }

    print(val);
    rep (i, n) {
        if (i == 0) continue;
        cout << (d[i] > 0 ? d[i] : c[n - 1]) << " ";
    }
    cout << (d[n] > 0 ? d[n] : c[n - 1]) << endl;

    return 0;
}


Measured memory_bytes: 2048
#include <cstring>
#include <algorithm>
#include <math.h>
#include <iostream>
#include <map>
#include <unordered_set>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<ll, int> P;

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

  P td[n];
  for (int i = 0; i < n; ++i) {
    int t; ll d;
    cin >> t >> d;
    td[i] = P(d, t);
  }

  sort(td, td + n, greater<P>());

  int cnts[n + 1];
  memset(cnts, 0, sizeof(cnts));
  ll ans = 0, cnt = 0, tmp = 0;
  priority_queue<P, vector<P>, greater<P> > q;
  for (int i = 0; i < k; ++i) {
    tmp += td[i].first;
    if (!cnts[td[i].second])  {
      cnt++;
    } else {
      q.push(td[i]);
    }
    cnts[td[i].second]++;
  }

  ans = tmp + cnt * cnt;
  for (int i = k; i < n; ++i) {
    if (q.empty()) break;
    if (cnts[td[i].second]) continue;
    P c = q.top(); q.pop();
    ll d = c.first;
    int idx = c.second;
    tmp = tmp - d + td[i].first;
    cnt++;
    cnts[idx]--;
    cnts[td[i].second]++;
    ans = max(ans, tmp + cnt * cnt);
  }

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


Measured memory_bytes: 3320
n = int(input())
l = list(map(int, input().split()))
l = list(reversed(sorted(l)))
ans = 0
for i in range(1,n):
    start = 0
    for j in range(i+1,n):
        l2 = l[i]+l[j]
        for k in range(start, i):
            if l[k] < l2:
                start = k
                ans += i - k
                break
print(ans)

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int a,b,c,d; cin >> a >> b >> c >> d;
  int ans = max(a,c)<min(b,d) ? min(b,d)-max(a,c):0;
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3620
#include<stdio.h>
#include<string.h>
int main(void){
    int i,u,y=0,e=0,g,m=0,q,z=0,de,r[3][6]={0},f[2][6]={0},as=0;
	    for(i=0;i<6;i++){
	    	scanf("%d",&r[0][i]);
	    }
	     for(i=0;i<6;i++){
	    	scanf("%d",&r[1][i]);
	    }
    for(de=0;de<2;de++){
	    memcpy(f[de],r[de],6);
    }
   de=0;
	    for(g=0;g<1000;g++){
	    	m=0;
	    	while(r[de][0]!=r[1][0]||r[de][5]!=r[1][5]){
		    	r[3][1]=r[de][0];
		    	r[de][0]=r[de][4];
		    	r[de][4]=r[de][5];
		    	r[de][5]=r[de][1];
		    	r[de][1]=r[3][1];
		    	m++;
		    	if(m==7){
		    		break;
		    	}
	    	}
	    	y=0;
	  	  while(r[de][1]!=r[1][1]||r[de][5]!=r[1][5]){
		    	r[3][1]=r[de][1];
		    	r[de][1]=r[de][2];
		    	r[de][2]=r[de][4];
		    	r[de][4]=r[de][3];
		    	r[de][3]=r[3][1];
		    	y++;
		    	if(y==20)break;
		    	if(m==7||y==7){
		    		as=0;
		    		while(r[de][0]!=r[1][0]&&r[de][5]!=r[1][5]){
		    	r[3][1]=r[de][0];
		    	r[de][0]=r[de][4];
		    	r[de][4]=r[de][5];
		    	r[de][5]=r[de][1];
		    	r[de][1]=r[3][1];
		    	if(as==20)break;
		    		}
		    		if(as==20)break;
		    	}
	   	 }
	   	 	y=0;
	  	  while(r[de][1]!=r[1][1]&&r[de][5]!=r[1][5]){
		    	r[3][1]=r[de][1];
		    	r[de][1]=r[de][2];
		    	r[de][2]=r[de][4];
		    	r[de][4]=r[de][3];
		    	r[de][3]=r[3][1];
		    	y++;
		    	if(y==20)break;
		    	if(m==7||y==7){
		    		as=0;
		    		while(r[de][0]!=r[1][0]&&r[de][5]!=r[1][5]){
		    	r[3][1]=r[de][0];
		    	r[de][0]=r[de][4];
		    	r[de][4]=r[de][5];
		    	r[de][5]=r[de][1];
		    	r[de][1]=r[3][1];
		    	if(as==20)break;
		    		}if(as==20)break;
		    	}
	   	 }
	    }
   
	if(r[0][0]==r[1][0]&&r[0][1]==r[1][1]&&r[0][2]==r[1][2]&&r[0][3]==r[1][3]&&r[0][4]==r[1][4]&&r[0][5]==r[1][5])
	{
		printf("Yes\n");
	}else{
		printf("No\n");
	}
    return 0;
}

Measured memory_bytes: 580
import sys
sys.setrecursionlimit(200000000)
p = 10**9+7
n, a, b = map(int, input().split())
fact=[0,1]
for i in range(2,max(a,b)+1):
  fact.append(fact[-1]*i % p)

def exp(y,x):
  xbin=str(bin(x))[2:]
  ans=1
  yl=[0]*(len(xbin)+1)
  yl[0]=y
  yl[1]=y**2
  for d,i in enumerate(xbin[::-1],start=0):
    if d > 1:
      yl[d]=yl[d-1]**2%p
    if i == "1":
      ans=(ans*yl[d])%p
  return ans%p

def ff(n,ca):
  if ca == 1:
    return n
  return n*ff(n-1,ca-1)%p
ssum=exp(2,n)-1
asum=ff(n,a)*exp(fact[a],p-2)%p
bsum=ff(n,b)*exp(fact[b],p-2)%p
print((ssum-asum-bsum)%p)

Measured memory_bytes: 189228
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
    b: char,
    }
    let ans = match b {
        'A' => 'T',
        'T' => 'A',
        'G' => 'C',
        _ => 'G',
    };
    println!("{}", ans);
}


Measured memory_bytes: 2116
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  int a,b,e=0,f=0;
  cin>>a>>b;
  int d[b];
  rep(i,b){
   cin>>d[i];
  }
  rep(i,b-1){
    f=max(f,d[i+1]-d[i]);
  }
  f=max(a-d[b-1]+d[0],f);
  cout<<a-f;
}

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

int m, d, c;

int f(int p, int q, int r) {
	if (p < 2 || q < 2) return 0;
	if (p * q == r) return 1;
	return 0;
}

int main()
{
	int i, j;
	cin >> m >> d;
	for (i = 1; i <= m; i++) {
		for (j = 22; j <= d; j++) {
			c += f(j / 10, j % 10, i);
		}
	}
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const int INF = 1001001001;
const int MOD = 1000000007;

template <typename T>
void print(const T &v);

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> ws(n, 0);
    int ac = 0, wa = 0;

    rep(i, m)
    {
        int p;
        string s;
        cin >> p >> s;
        if (s == "WA")
        {
            if (ws[p - 1] != -1)
            {
                ws[p - 1]++;
            }
        }
        else if (s == "AC")
        {
            if (ws[p - 1] != -1)
            {
                wa += ws[p - 1];
                ws[p - 1] = -1;
                ac++;
            }
        }
    }
    cout << ac << ' ' << wa << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}


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

int main() {
    int N, Q;
    cin >> N >> Q;
    vector<vector<int>> tree(N+1, vector<int>());
    for (int i = 0; i < N-1; i++) {
        int a, b;
        cin >> a >> b;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    vector<int> counter(N+1, 0);
    for (int i = 0; i < Q; i++) {
        int p, x;
        cin >> p >> x;
        counter[p] += x;
    }
    queue<int> q;
    q.push(1);
    vector<bool> check(N+1, false);
    int now;
    while (!q.empty()) {
        now = q.front();
        q.pop();
        check[now] = true;
        for(int nxt : tree[now]) {
            if (!check[nxt]) {
                q.push(nxt);
                counter[nxt] += counter[now];
            }
        }       
    }
    for (int i = 1; i <= N; i++) {
        cout << counter[i] << " ";
    }
}


Measured memory_bytes: 15604
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val a = IntArray(n + 1) { -1 }

    var error = false

    repeat(m) {
        val (s, c) = readLine()!!.split(' ').map { it.toInt() }
        if (a[s] == -1) a[s] = c
        if (a[s] != c) {
            error = true
            return@repeat
        }
    }

    if (n == 1) {
        if (a[1] == -1) a[1] = 0
    } else {
        for (i in 1..n) {
            if (a[i] == -1) {
                a[i] = if (i == 1) 1 else 0
            }
        }
        if (a[1] == 0) {
            error = true
        }
    }

    println(if (error) -1 else a.slice(1..n).joinToString(""))
}


Measured memory_bytes: 38264
using System;
using System.Collections.Generic;

class Program
{
      public static int CountChar(string s, char c) {
    return s.Length - s.Replace(c.ToString(), "").Length;
  }
	static void Main(string[] args)
	{
        /*
		// 整数の入力
		int a = int.Parse(Console.ReadLine());
		// スペース区切りの整数の入力
		string[] input = Console.ReadLine().Split(' ');
		int b = int.Parse(input[0]);
		int c = int.Parse(input[1]);
		// 文字列の入力
		string s = Console.ReadLine();
		//出力
		Console.WriteLine((a+b+c) + " " + s);
        */

        //System.Console.WriteLine(CountChar(Console.ReadLine(), '1'));

/* 
        int n = int.Parse(Console.ReadLine());
        SortedList<int, int> data = new SortedList<int, int>();
        for (int i = 0; i < n; i++){
            string[] d = Console.ReadLine().Split(' ');
            int r = int.Parse(d[0]);
            int p = int.Parse(d[1]);
            data.Add(r, p);
        }

        var num = 0;
        var index = 0;
        var point = 10000000000;
        KeyValuePair<int, int> pre = new KeyValuePair<int, int>();
        foreach (var d in data)
        {
            num += d.Key - index;
            index = d.Key;
            pre = d;
        }

        Console.WriteLine(num + pre.Value);
        */
        int max = 3500;
        int n= int.Parse(Console.ReadLine());
        for (int i = 1; i <= max; i++){
            for (int j = 1; j <= max; j++){
                /*for (int k = j; k < max; k++){
                    if (4*i*j*k == (i*j + j*k + k*i)*n){
                        System.Console.WriteLine(i + " " + j + " " + k);
                        return;
                    }
                }*/
                int k = (int)(1.0 / (4.0/n - 1.0/i - 1.0/j));
                if (k <= 0) continue;
                if (4*i*j*k == (i*j + j*k + k*i)*n){
                    System.Console.WriteLine(i + " " + j + " " + k);
                    return;
                }
            }
        }
	}
}

Measured memory_bytes: 13268
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>



void swap (int *x, int *y) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;

  return;
}


int gcd(int a, int b){
  int c;

  while (b > 0){
    c = a % b;
    a = b;
    b = c;
  }

  return a;
}

long int modpow(long int a,long int n,long int mod){
  long int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

long int modinv(long int a,long int mod){
  return modpow(a,mod-2,mod);
}

int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}

int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}

int main(void){
  int n,a;
  scanf("%d%d",&n,&a);
  int mod=n%500;
  if(mod<=a){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 1608
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;

int ans[100001];
vector<int> edge[100001];
int main(){
   int N,M;
   cin >> N >> M;
   for(int i = 0 ; i < M; i++){
      int A,B;
      cin >> A >> B;
      A--;B--;
      edge[A].emplace_back(B);
      edge[B].emplace_back(A);
   }
   memset(ans,-1,sizeof(ans));
   queue<pair<int,int>> q;
   q.push(make_pair(0,0));
   ans[0]=0;
   while(!q.empty()){
      pair<int,int> p = q.front();
      q.pop();
      int cur = p.first;
      for(int i = 0 ; i < (int)edge[cur].size(); i++){
         int nxt = edge[cur][i];
         if(ans[nxt]==-1){
            ans[nxt]=cur;
            q.push(make_pair(nxt,cur));
         }
      }
   }
   cout << "Yes" << endl;
   for(int i = 1 ; i < N ; i ++){
      cout << ans[i]+1 << endl;
   }



   return 0;
}


Measured memory_bytes: 10696
#include <algorithm>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <thread>
#include <tuple>
#include <type_traits>
#include <vector>


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

using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    ll ans = 0;
    int n;

    cin >> n;
    ans = (1000 - (n % 1000)) % 1000;

    cout << ans << endl;
}


Measured memory_bytes: 3188
object Main extends App {
  val scanner = new java.util.Scanner(System.in)
  val W = scanner.nextInt
  val H = scanner.nextInt
  val x = scanner.nextInt
  val y = scanner.nextInt
  val r = scanner.nextInt

  val result =
    !(x - r < 0 ||
      y + r > H ||
      x + r > W ||
      y - r < 0)

  println(if(result) "Yes" else "No")
}

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

int main() {
    int m, nmin, nmax;
    while (cin >> m >> nmin >> nmax, m | nmin | nmax) {
        vector<int> P(m);
        for (int i = 0; i < m; i++) {
            cin >> P[i];
        }

        int cost = 0, ans = 0;
        for (int i = 0; i < m; i++) {
            if (i + 1 < nmin || i + 1 > nmax) continue;
            if (i + 1 >= m) continue;
            if (P[i] - P[i + 1] >= cost) {
                cost = P[i] - P[i + 1];
                ans = i + 1;
            }
        }
        cout << ans << endl;
    }

    return 0;
}

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

using namespace std;

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

int main() 
{
    int n = read(), m = read();
    int l = 1, r = n;
    while(m--) 
	{
        int u = read(), v = read();
        l = max(l, u);
		r = min(r, v);
    }
    int ans;
    if(l > r) 
		ans = 0;
    else 
		ans = r - l + 1;
    cout << ans;
    return 0;
}

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

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

#define INF 1e9

int main(){
  ll N, P;
  cin >> N >> P;
  if(N==1){
    cout << P << endl;
    return 0;
  }
  ll ans = 1;
  for(ll i = 2; i * i <= P; i++){
    int cnt = 0;
    while(P % i == 0){
      P /= i;
      cnt++;
      if(cnt == N){
        ans *= i;
        cnt = 0;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  int N, M, K;
  cin >> N >> M >> K;
  vector<int>A(N);
  for(int i=0; i<N; i++)cin >> A.at(i);
  vector<int>B(M);
  for(int i=0; i<M; i++)cin >>B.at(i);
  
  int a=0;
  int b=0;
  int jikan=0;
  for(int i=0; i<N; i++){
    if(jikan + A.at(i) > K)break;
    jikan += A.at(i);
    a++;
  }
  for(int i=0; i<M; i++){
    if(jikan + B.at(i)>K)break;
    jikan += B.at(i);
    b++;
  }
  
  int wa = a+b;
  while(a>0){
    jikan -= A.at(a-1);
    while(b<M){
      if(jikan + B.at(b)>K)break;
      jikan += B.at(b);
      b++;
    }
    a--;
    wa = max(wa, a+b);
    if(b==M)break;
  }
  
  cout << wa <<endl;
}

Measured memory_bytes: 4752
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll h,w;
  cin >> h >> w;
  mat a(h,vec(w));
  for(ll i=0;i<h;i++) {
    for(ll j=0;j<w;j++) {
      cin >> a[i][j];
    }
  }
  vector<vector<ll>> ans;
  for(ll i=0;i<h;i++) {
    for(ll j=0;j<w;j++) {
      if(a[i][j]%2&&(i+1<h||j+1<w)) {
        a[i][j]--;
        vector<ll> tans(4);
        tans[0]=i+1;
        tans[1]=j+1;
        if(j+1<w) {
          a[i][j+1]++;
          tans[2]=i+1;
          tans[3]=j+2;
        }
        else {
          a[i+1][j]++;
          tans[2]=i+2;
          tans[3]=j+1;
        }
        ans.push_back(tans);
      }
    }
  }
  cout << ans.size() << endl;
  for(ll i=0;i<ans.size();i++) {
    for(ll j=0;j<4;j++) {
      if(j!=0) cout << " ";
      cout << ans[i][j];
    }
    cout << endl;
  }
}

Measured memory_bytes: 12976
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <vector>

typedef long long ll;
using namespace std;

int main()
{
    int n;
    ll x[100], y[100], h[100];
    cin >> n;
    for (ll i=0;i<n;i++) {
        cin >> x[i] >> y[i] >> h[i];
    }
    for (ll i=0;i<=100;i++) {
        for (ll j=0;j<=100;j++) {
            ll H;
            for (ll k=0;k<n;k++) {
                if (h[k]!=0) {
                    H = h[k] + abs(x[k]-i) + abs(y[k]-j);
                    break;
                }
            }
            bool check = true;
            for (ll k=0;k<n;k++) {
                if (max(H-abs(x[k]-i)-abs(y[k]-j),(ll)0)!=h[k]) {check=false;break;}
            }
            if (check) {
                cout << i << ' ' << j << ' ' << H << endl;
                return 0;
            }
        }
    }
    return 0;
}

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

#define int long long
const int mod=1e9+7;



int N,R;
int str[100000];
int s[50],t[50];

int table[100001];

int bit[100001];

void init_bit(){
    for(int i=0;i<N;i++)bit[i+1]=0;
}

void add(int k,int x){
    k++;
    while(k<=N){
        bit[k]+=x;
        k+=k&-k;
    }
}

int sum(int k){
    k++;
    int ret=0;
    while(k){
        ret+=bit[k];
        k-=k&-k;
    }
    return ret;
}

void solve(){
    init_bit();
    for(int i=0;i<N;i++)str[i]=i;
    for(int i=0;i<R;i++){
        swap(str[--s[i]],str[--t[i]]);
    }
    int ans=0;
    for(int i=0;i<N-1;i++){
        ans+=(str[i]-sum(str[i]-1))*table[N-i-1];
        ans%=mod;
        add(str[i],1);
    }

    cout<<ans<<endl;
}

void init(){
    table[1]=1;
    for(int i=1;i<=100000;i++){
        table[i+1]=(table[i]*(i+1))%mod;
    }
}

signed main(){
    init();

    while(cin>>N,N){
        cin>>R;
        for(int i=0;i<R;i++)cin>>s[i]>>t[i];
        solve();
    }
}

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

int main(){
  string s;
  map<char, int> mp;
  bool flag = true;
  cin >> s;
  for(int i = 0; i < s.size(); i++) mp[s[i]]++;
  if((mp['N'] != 0 && mp['S'] == 0) || (mp['N'] == 0 && mp['S'] != 0)) flag = false;
  if((mp['E'] != 0 && mp['W'] == 0) || (mp['E'] == 0 && mp['W'] != 0)) flag = false;
  cout << (flag ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
    string a, b;
    cin >> a >> b;
    if (a == b) {
        puts("EQUAL");
        return 0;
    }
    if (a.length() > b.length()) {
        puts("GREATER");
    }
    else if (b.length() > a.length()) {
        puts("LESS");
    }
    else {
        for (int i = 0; i < a.length(); i++) {
            if (a[i] > b[i]) {
                puts("GREATER");
                return 0;
            }
            if (a[i] < b[i]) {
                puts("LESS");
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;
int main(){
    const long double PI =acos(-1.L);
    double r;
    cin>>r;
    cout<<fixed<<setprecision(5)<<PI*r*r<<" "<<2*PI*r<<"\n";
    return 0;
}



Measured memory_bytes: 3268
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
using namespace std;
 
#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
  string S,T;
  cin>>S>>T;
  int N=S.size();
  int count=0;
  for(int i=0;i<N;i++){
    if(S[i]!=T[i]) count++;
  }
  cout<<count;
return 0;}

Measured memory_bytes: 3860
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>
#include <cassert>

using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

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

signed main(void) {
	int n;
	cin >> n;
	vi a(n);
	rep(i,n)cin >> a[i];
	int ans[2005] = {};
	rep(bit,1<<n){
		int sum = 0;
		rep(i,n)if(bit & (1<<i))sum += a[i];
		ans[sum]++;
	}
	int q;
	cin >> q;
	while(q--){
		int in;
		cin >> in;
		if(ans[in])cout << "yes" << endl;
		else cout << "no" << endl;
	}
}



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

#define eps 1e-9
#define PI acos(-1)

template<typename p_type>
struct Point {
	p_type x, y;
	Point(p_type _x = -1, p_type _y = -1) : x(_x), y(_y) {}
};

template<typename v_type>
struct Vec {
	v_type x, y;
	
	Vec(v_type _x = -1, v_type _y = -1) : x(_x), y(_y) {}
	Vec(Point<v_type> a, Point<v_type> b) {
		x = b.x - a.x;
		y = b.y - a.y;
	}
	
	Vec operator +(const Vec& rhs) const { return Vec(x + rhs.x, y + rhs.y); }
	Vec operator -(const Vec& rhs) const { return Vec(x - rhs.x, y - rhs.y); }
	
	Vec& scale(v_type s) { return *this = Vec(x * s, y * s); }
	Vec& rot(double theta) {
		v_type new_x = x * cos(theta) - y * sin(theta);
		v_type new_y = x * sin(theta) + y * cos(theta);
		return *this = Vec(new_x, new_y);
	}
	
	v_type dot(const Vec& rhs) const { return x * rhs.x + y * rhs.y; }
	v_type cross(const Vec& rhs) const { return x * rhs.y - y * rhs.x; }
	double mag() const { return sqrt(x*x + y*y); }
};

using P = Point<double>;
using V = Vec<double>;

double dist(P a, P b) {
	return sqrt((a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y));
}

struct Circle {
	P center;
	double r;
	Circle(P _center, double _r) : center(_center), r(_r) {}
};

// returns true if c1 and c2 intersect, their points of intersection stored in ans
bool intersect(Circle c1, Circle c2, vector<P>& ans) {
	P p = c1.center, q = c2.center;
	double r1 = c1.r, r2 = c2.r;
	double d = dist(p, q);
	if(d > r1 + r2 || d < fabs(r1 - r2)) return false;
	
	double a = (r1*r1 - r2*r2 + d*d) / (2*d);
	double h = sqrt(r1 * r1 - a * a);

	V u(p, q), v(p, q);
	u.scale(h/u.mag());
	u.rot(PI/2);
	v.scale(a/v.mag());

	ans.push_back(P(p.x + u.x + v.x, p.y + u.y + v.y));
	u.rot(PI);
	ans.push_back(P(p.x + u.x + v.x, p.y + u.y + v.y));
	return true;
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	vector<P> points(n);
	for(P& p : points) {
		cin >> p.x >> p.y;
	}
	
	double lo = 0, hi = 2000;
	double mid;
	for(int rep = 0; rep < 100; rep++) {
		mid = lo + (hi - lo)/2;
		bool ok = false;
		
		for(int i = 0; i < n; i++) {
			for(int j = i+1; j < n; j++) {
				Circle c1(points[i], mid), c2(points[j], mid);
				vector<P> ans;
				if(intersect(c1, c2, ans)) {
					for(P p : ans) {
						bool now = true;
						for(int k = 0; k < n; k++) {
							if(dist(p, points[k]) > mid + eps) {
								now = false;
							}
							
						}
						
						ok = ok || now;
					}
				} 
			}
		}

		if(ok) {
			hi = mid;
		} else {
			lo = mid;
		}
	}
	
	cout << fixed << setprecision(10) << mid << endl;
}


Measured memory_bytes: 256
//author:luckYrat(twitter:@luckYrat_)
//<ここに一言>

//せんげん！
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <bitset>

#include <cctype>
#include <utility>
#include <climits>


//なまえくーかん！
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

//てーすう！
const int mod = 1000000007;
const int inf = (1<<30)-1;
const ll linf = (1LL<<62LL)-1;
const double EPS = (1e-10);

//でふぁいん！
#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)

//みじかく！
#define pb push_back
#define fir first
#define scn second
#define ednl endl

//いぇすのー！
#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")

//きんぼーnほーこー！！
P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる

計算量は変わらないが楽できるシリーズ
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる
*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  int n;cin>>n;
  long long ans =0 ;
  for(int i = 1; n >= i; i++){
    if(i%3 && i%5){
      ans += i;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3608
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<cstring>
#include<bitset>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<numeric>
#include<set>
#include<math.h>
using namespace std;

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

#define rep(i,x) for(int i=0;i<x;i++)
#define re(i,x,y) for(int i=x;i<y;i++)

long long INF=1e9;
const int mod=10007;
#define ll long long

int main(){
	ll n;
	cin>>n;
	ll a=sqrt(n),b,c;
	for(int i=1;i<=a;i++){
		if(n%i==0){
			b=i;
		}
	}	
	c=n/b;
	cout<<c+b-2<<endl;
	return 0;
}


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

int main() {
	int r,g, b, c, d, ans;
	cin >> r >> g >> b;
	r *= 100;
	g *= 10;
	c = r + g + b;
	cout << (c % 4 == 0 ? "YES" : "NO") << endl;
	return 0;
}

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

#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = n - 1; i < (int)n; --i)
#define FOR(i, l, r) for (int i = (int)(l); i < (int)(r); ++i)
#define RFOR(i, l, r) for (int i = (int)(r); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;

// set<pair<int, int>> s;
map<int, set<int>> mx, my;

int rec(set<pair<int, int>>& s, set<int>& sx, set<int>& sy, int x, int y) {
    int ret = 0;
    auto it = s.find({x, y});
    if (it != s.end()) {
        ret++;
        s.erase(it);
        sx.emplace(x);
        sy.emplace(y);
        for (auto& e: mx[x]) {
            ret += rec(s, sx, sy, x, e);
        }
        for (auto& e: my[y]) {
            ret += rec(s, sx, sy, e, y);
        }
    }
    return ret;
}


int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n;
    cin >> n;

    set<pair<int, int>> s;
    // map<int, set<int>> mx, my;

    REP(i, n) {
        int x, y;
        cin >> x >> y;
        s.emplace(x, y);
        mx[x].emplace(y);
        my[y].emplace(x);
    }

    ll ans = 0;
    while (!s.empty()) {
        int x, y;
        tie(x, y) = *(s.begin());
        set<int> sx, sy;
        ans -= rec(s, sx, sy, x, y);
        ans += sx.size() * sy.size();
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 30592
#include <iostream>
#include <string>
using namespace std;
int d[100005];
int main() {
  ios::sync_with_stdio(false);
  int N, Q, l, r;
  string S;
  cin >> N >> Q;
  cin >> S;
  int state = 0;
  for (int i=0; i<N; i++) {
    d[i+1] = d[i];
    if (S[i] == 'A') {
      state = 1;
    } else if (state == 1 && S[i] == 'C') {
      state = 0;
      d[i+1]++;
    } else {
      state = 0;
    }
  }
  for (int i=0; i<Q; i++) {
    cin >> l >> r;
    cout << d[r] - d[l] << endl;
  }
}

Measured memory_bytes: 1488
#include <cstdio>
#include <cctype>
#include <utility>
#include <vector>
#include <queue>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;while(isspace(c)){c=gcu();}if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m?-n:n;}
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

using v = vector<int>;
using vv = vector<v>;

constexpr int d[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};

struct boad {
	vv b;
	int sx, sy, c = 1;
	boad(int w, int h) {
		b = vv(h, v(w));
		for (auto &y: b)
			for (int &x: y) {
				x = in();
				if (x == 2) {
					x = 0;
					sx = &x - &y[0];
					sy = &y - &b[0];
				}
			}
	}

	void dump() {
		outl("{", sx, ",", sy ,"}");
		for (auto y: b) {
			for (int x: y)
				out(x);
			outl();
		}
	}

};

int bfs (int w, int h) {
	queue<boad> q;
	q.push(boad(w, h));
	while (!q.empty()) {
		boad t = q.front();
		q.pop();
		for (int r = 0; r < 4; r++) {
			for (int i = 0, tx = t.sx, ty = t.sy;; i++) {
				tx += d[r][0]; ty += d[r][1];
				if(tx < 0 || tx >= w || ty < 0 || ty >= h)
					break;
				if (t.b[ty][tx] == 3)
					return t.c;
				else if (t.b[ty][tx] == 1) {
					if (t.c < 10 && i) {
						boad tt = t;
						tt.b[ty][tx] = 0;
						tt.sx = tx - d[r][0];
						tt.sy = ty - d[r][1];
						tt.c++;
						q.push(tt);
					}
					break;
				}
			}
		}
	}
	return -1;
}

int main() {
	for (int w, h; w = in(), h = in();)
		outl(bfs(w, h));
}


Measured memory_bytes: 64816
import java.util.Scanner;
public class Main{
	int x;
	public void solve(){
		Scanner sc = new Scanner(System.in);
		x = sc.nextInt();
		System.out.println(x*x*x);
	}
	public static void main(String[] args){
		Main obj = new Main();
		obj.solve();
	}
}

		

Measured memory_bytes: 17316
def solve(s1,s2):
    rows=len(s1)
    cols=len(s2)
    dp=[[0]*(cols+1) for i in range(rows+1)]
    for i in range(1,rows+1):
        for j in range(1,cols+1):
            if s1[i-1]==s2[j-1]:
                dp[i][j]=dp[i-1][j-1]+1
            else:
                dp[i][j]=max(dp[i-1][j],dp[i][j-1])
                
    max_len=dp[rows][cols]
    result=[""]*(max_len+1)
    result[max_len]=""
    i=rows
    j=cols
    while i>0 and j>0:
        if s1[i-1]==s2[j-1]:
            result[max_len-1]=s1[i-1]
            max_len -=1
            i -=1
            j -=1
        elif dp[i-1][j]>dp[i][j-1]:
            i -=1
        else:
            j -=1
    return "".join(result)
            
                
#     if i==n or j==m:
#         return result
#     if s1[i]==s2[j]:
#         result +=s1[i]
#         return result+solve(s1,s2,n,m,i+1,j+1,result)
#     else:
#         left=solve(s1,s2,n,m,i+1,j,result)
#         right=solve(s1,s2,n,m,i,j+1,result)
#         if left:
#             result
        
        ##return max(solve(s1,s2,n,m,i+1,j,result),solve(s1,s2,n,m,i,j+1,result))
s1=input()
s2=input()
n=len(s1)
m=len(s2)
result=""
print(solve(s1,s2))

Measured memory_bytes: 111580
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	char S[110];
	ll K,N,dNum=0,num=0;
	cin>>S>>K;
	for(N=0;S[N]!='\0';N++);
	ll tmp=1;
	rep(i,N){
		if(S[i]==S[i+1]){
			tmp++;
		}else{
			if(tmp==N){
				cout<<N*K/2;
				return 0;	
			}
			num+=tmp/2;
			tmp=1;
		}
	}
	ll R=0,L=0;
	if(S[0]==S[N-1]){
		rep(i,N){
			if(S[i]==S[i+1]){
				tmp++;
			}else{
				R+=tmp;
				tmp=1;
				break;
			}
		}
		rep(i,N){
			if(S[N-1-i]==S[N-1-i-1]){
				tmp++;
			}else{
				L+=tmp;
				tmp=1;
				break;
			}
		}
	}
	dNum=(L+R)/2-L/2-R/2;
	/*
	cout<<num<<endl;
	cout<<R<<endl;
	cout<<L<<endl;
	cout<<dNum<<endl;
	*/
	cout<<num*K+dNum*(K-1)<<endl;
	return 0;
}

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

int main() {
	string s, t;
	cin >> s >> t;
	string store = s;
	int k = s.size() - t.size();
	if (k < 0) {
		cout << "UNRESTORABLE" << endl;
		return 0;
	}
	bool flag=false;
	vector<string>ans;
	for (int i = 0; i <= k; ++i) {
		if (s[i] == t[0] || s[i] == '?') {
			flag = true;
			if (i + t.size() > s.size()) {
				flag = false;
				continue;
			}
			for (int j = 0; j < t.size(); ++j) {
				if (s[i + j] != t[j] && s[i + j] != '?') {
					flag = false;
					break;
				}
			}
			if(flag)for (int j = 0; j < t.size(); ++j) {
				s[i + j] = t[j];
			}
			if(flag)for (int j = 0; j < s.size(); ++j) {
				if (s[j] == '?')s[j] = 'a';
			}
			if(flag)ans.push_back(s);
		}
		s = store;
	}
	if (ans.size()!=0) {
		sort(ans.begin(), ans.end());
		cout << ans[0] << endl;
	}
	else cout << "UNRESTORABLE" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
using namespace std;

long string_comp(string s1, string s2) {
	if (s1 == s2) {
		return 1;
	}
	else {
		return 0;
	}
}

int main() {

	long N;
	cin >> N;

	vector<string> s(N, "");
	for (long i = 0; i < N; i++) {
		cin >> s[i];
		sort(s[i].begin(), s[i].end());
	}

	sort(s.begin(), s.end());

	auto itr = s.begin();
	long long ans = 0;
	string str = "";
	long long val = 0;
	while (itr != s.end()) {
		str = *itr;
		val = 0;
		while (str == *itr) {
			itr += 1;
			val += 1;
			if (itr == s.end()) {
				break;
			}
		}
		ans += val * (val - 1) / 2;
	}

	cout << ans << endl;

	return 0;
}



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

signed main()
{
	string a;
	string b;
	cin>>a>>b;
	int q=0,w=0;
	cin>>q>>w;
	string c;
	cin>>c;
	if(c==a){
		q--;
	}
	else if(c==b){
		w--;
	}
	printf("%lld %lld\n",q,w);
	return 0;
}


Measured memory_bytes: 256