akhauriyash/Code-Regression huggingface dataset:
// =====================================================================================
//
//       Filename:  res.cpp
//
//        Version:  1.0
//       Revision:  none
//       Compiler:  g++
//
//         Author:  Priyank Kumar Singh (), priyankkumar179@gmail.com
//   Organization:  RVCE Bangalore
//
// =====================================================================================


#include<bits/stdc++.h>
using namespace std;

#define ll long long 
#define pb push_back
#define mp make_pair
#define F first
#define S second 
#define pl pair<long ,long >
#define pi pair<int ,int >
#define ct(i) cout<< i << "\n";
#define mod 1000000007
#define M 100005

/*
void dfs(int n,int p){
    vis[n]=1; 
    if(adj[n].size()!=2) f1=1;
    for(int i=0;i<adj[n].size();i++){
        if(vis[adj[n][i]]==0 ) dfs(adj[n][i],n);
        else if(adj[n][i]!=p){ f=1; }
    }
}*/
int c1=0;
void answer(){
    ll n,l,r,f=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            for(int k=1;k<=n;k++) f += __gcd(i,__gcd(k,j));
        }
    }
    cout<<f;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); 
    int q;
    //cin>>q; while(q--)
        answer();

    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) {sort(all(a));a.erase(unique(all(a)),a.end());}
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vvvvi=vector<vvvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const ll INF=1001001001;
const ll mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){ll res=1;a%=mod;while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}
vi parent,rankk,sz;
void init(ll n){
    parent=vi(n);
    rankk=vi(n);
    sz=vi(n,1);
    rep(i,n)parent[i]=i;
}
ll root(ll i){if(parent[i]==i)return i;return root(parent[i]);}
ll getsize(ll i){return sz[root(i)];}
bool same(ll a,ll b){return root(a)==root(b);}
bool heigou(ll x,ll y){
    x=root(x);y=root(y);
    if(x==y)return false;
    if(rankk[x]<rankk[y]){parent[x]=y;sz[y]+=sz[x];}
    else{parent[y]=x;sz[x]+=sz[y];}
    if(rankk[x]==rankk[y])rankk[x]++;
    return true;
}
int main(){
    ll n,m;cin>>n>>m;
    init(n);
    rep(i,m){
        ll a,b;cin>>a>>b;heigou(a-1,b-1);
    }
    ll ans=0;
    rep(i,n)chmax(ans,getsize(i));
    out(ans);
}

Measured memory_bytes: 7988
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000
#define bpc(x) __builtin_parityll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

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

using namespace std;

int main()
{
   FAST/**/
   
   ll a,b,m;
   cin>>a>>b>>m;
   
   ll arr[a], arr1[b];
   rep(a)
        cin>>arr[i];
   rep(b)
        cin>>arr1[i];
   ll ans = inf;
   rep(m)
   {
       ll x,y,c;
       cin>>x>>y>>c;
       x--,y--;
       ans = min(ans, arr[x] + arr1[y] - c);
   }
   
   sort(arr,arr+a);
   sort(arr1,arr1+b);
   ans = min(ans, arr[0] + arr1[0]);
   cout<<ans;
   
   
   return 0;        
}  
   

Measured memory_bytes: 1792
function Main(input) {
  var inputs = input.split('\n')
  var number = inputs[0]

  if (number === 0) {
    console.log(inputs[1])
    return
  }
  var strings = inputs[1].split('')
  var c = 'A'.charCodeAt(0)
  var alphabet = Array.apply(null, new Array(26)).map((v, i) => {
    return String.fromCharCode(c + i);
  })

  var alpToNum = {}
  var numToalp = alphabet
  for (i = 0; i < alphabet.length; i++) {
    alpToNum[alphabet[i]] = i
  }

  var result = []

  for(j=0; j < strings.length; j++) {
    var num = (alpToNum[strings[j]] + parseInt(number)) % 26
    result[j] = numToalp[num]
  }
  result = result.join('')
  console.log(result)
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
import sys
from collections import namedtuple


def next_str() -> str:
    result = ""
    while True:
        tmp = sys.stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != "\r":
            break
    return result


def next_int() -> int:
    return int(next_str())


query = namedtuple('qry', ('l', 'r'))
Q = next_int()
queries = [query(next_int(), next_int()) for i in range(Q)]
right = -sys.maxsize
left = sys.maxsize


def is_prime(n: int) -> bool:
    if n < 2:
        return False
    i = 2
    while i ** 2 <= n:
        if n % i == 0:
            return False
        i += 1
    return True


def main() -> None:
    global left, right
    for q in queries:
        left = min(left, q.l)
        right = max(right, q.r)

    dp = [0] * ((right - left) // 2 + 1)

    for i in range(left, right + 1, 2):
        j = (i - left) // 2
        if j != 0:
            dp[j] = dp[j - 1]
        if is_prime(i) and is_prime((i + 1) // 2):
            dp[j] += 1

    for q in queries:
        ans = 0
        ans += dp[(q.r - left) // 2]
        if q.l != left:
            ans -= dp[(q.l - left) // 2 - 1]

        print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 68824
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x); i<=(y); i++)
#define ll long long
#define ld long double
#define inf 1000000000
#define N 100005
int n,s; ll a[N],b[N],ans;
int main(){
	scanf("%d%d",&n,&s);
	rep (i,1,n) scanf("%d%d",&a[i],&b[i]);
	int l=1,r=n; ans=0;
	while (l<=r){
		if (s<=a[l]){ ans+=a[r]-s; break; }
		if (s>=a[r]){ ans+=s-a[l]; break; }
		if (b[l]>=b[r]){
			ans+=a[r]-a[l];
			while (l<r && b[l]>=b[r]) b[l]+=b[r--];
		} else{
			ans+=a[r]-a[l];
			while (l<r && b[l]<b[r]) b[r]+=b[l++];
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1792
// #include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <tuple>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repd(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define repdm(i, a, b) for (ll i = (ll)(a); i > (ll)(b); i--)
const ll INF = 1LL << 60;
const ll MOD = 1000000007;

template <class T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}

int main()
{

  ll N, M;
  cin >> N >> M;
  ll a[M];
  ll dp[N + 1] = {0};
  rep(i, M) cin >> a[i];
  dp[0] = 1;

  ll num = 0;

  rep(i, N)
  {
    if (i + 1 == a[num])
    {
      dp[i + 1] = 0;
      num++;
      num = min(num, M - 1);
      continue;
    }

    if (i == 0)
    {
      dp[i + 1] = dp[i] % MOD;
      continue;
    }
    dp[i + 1] = (dp[i] + dp[i - 1]) % MOD;
  }

  cout << dp[N] << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const int Maxn=105,mod=1e9+7;
int h[Maxn];
int ksm(int x,int k){
	int ret=1,tmp=x;
	while(k){
		if(k&1)ret=1ll*ret*tmp%mod;
		tmp=1ll*tmp*tmp%mod;k>>=1;
	}
	return ret;
}
pair<int,int>solve(int l,int r,int lim){
	int Min=*min_element(h+l,h+r+1);
	int cnt=count(h+l,h+r+1,Min);
	pair<int,int>ans=make_pair(1,1);
	if(cnt==r-l+1){
		ans.first=ksm(2,Min-lim);
		ans.second=(ans.first+ksm(2,cnt)-2)%mod;
		return ans;
	}
	vector<pair<int,int>>vec;
	for(int i=l;i<=r;i++){
		if(h[i]==Min)continue;
		int L=i;
		while(i<=r&&h[i]>Min)i++;
		vec.emplace_back(solve(L,i-1,Min));
	}
	int f=1,g=1;
	for(auto&i:vec){
		f=1ll*f*i.first%mod;
		g=1ll*g*(i.first+i.second)%mod;
	}
	ans.second=(1ll*(g-1ll*ksm(2,vec.size())*f)%mod*ksm(2,cnt)+1ll*f*(ksm(2,vec.size()+cnt)-2))%mod;
	ans.first=1ll*f*ksm(2,Min-lim)%mod;
	ans.second=(ans.second+ans.first)%mod;
	return ans;
}
int main(){
	int n;scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&h[i]);
	cout<<(solve(1,n,0).second+mod)%mod<<"\n";
	return 0;
}

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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

const int MAX_K = 100000;
int K;
int cost[MAX_K];

template<typename... Args>
void debug(Args... args) {
    for (auto arg:{args...})cerr << arg << " ";
    cerr << endl;
}

int bfs01() {
    deque<pii> deq;
    deq.push_back(pii(1, 1));
    cost[1] = 1;
    while (!deq.empty()) {
        pii p = deq.front();
        deq.pop_front();
        int v = p.first;
        int c = p.second;
        int v1 = (10 * v) % K;
        if (cost[v1] == 0 || cost[v1] > c) {
            cost[v1] = c;
            deq.push_front(pii(v1, c));
        }
        int v2 = (v + 1) % K;
        if (cost[v2] == 0) {
            cost[v2] = c + 1;
            deq.push_back(pii(v2, c + 1));
        }
    }
    return cost[0];
}

signed main() {
    cin >> K;
    cout << bfs01() << endl;
    return 0;
}


Measured memory_bytes: 1792
n, k = map(int, input().split())
a = [0] + list(map(int, input().split()))

seen = [False] * (n+1)
visited = []
nxt = 1
cnt = 0
while not seen[nxt] and cnt != k:
    seen[nxt] = True
    visited.append(nxt)
    nxt = a[nxt]
    cnt += 1

if cnt == k:
    print(nxt)
    exit()
    
idx = visited.index(nxt)
print(visited[idx:][(k-idx)%(len(visited)-idx)])


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

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

    map<int,int> nums;
    rep(i,n){
        int v;
        cin >> v;
        // countのためにキーを値にする（？？？）
        nums[v] = i;
    }

    cin >> q;
    int ans = 0;
    rep(i,q){
        int v;
        cin >> v;
        // キーが存在していたら
        if(nums.count(v)){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  
  long long total=0;
  
  vector<int>a(n);
  for(int i=0; i<n; i++){
    cin >> a[i];
    total+=a[i];
  }
  
  if(total%10==0){
    int Min=100;
   for(int i=0; i<n; i++){ 
     if(a[i]%10!=0) Min=min(Min,a[i]);
   }
    total-=Min;
    if(Min==100){
     cout << 0 << endl;
      return 0;
    }
  }
  
  cout << total << endl;
  
  return 0;
  
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1000000007;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

vector<ll> used(100010), tp;
vector<vector<ll>> G(100010), H(100010);
/*
void dfs(ll v){
    if(used[v]) return;
    used[v] = 1;
    for(auto& u:G[v]){
        dfs(u);
    }
    tp.push_back(v);
}*/

int main(){
    ll N,M;
    cin >> N >> M;
    vector<ll> rc(N),deg(N);
    ll a,b;
    rep(i,N-1+M){
        cin >> a >> b;
        a--;b--;
        rc[b]++;
        G[a].push_back(b); 
        deg[b]++;
        H[b].push_back(a);
    }
    ll root;
    rep(i,N){
        if(rc[i] == 0){
            root = i;
            break;
        }
    }
    queue<ll> que;
    //vector<ll> par(N,-1);
    vector<ll> tv, ids(N);
    tv.push_back(root);
    que.push(root);
    while(!que.empty()){
        ll v = que.front();
        que.pop();
        for(auto& u:G[v]){
            deg[u]--;
            if(deg[u] == 0){
                //par[u] = v;
                tv.push_back(u);
                que.push(u);
            }
        }
    }
    rep(i,N){
        ids[tv[i]] = i;
    }
    //PR(tv,N);
    rep(i,N){
        ll tmp_id = -1;
        ll tmp_v = -1;
        for(auto&v:H[i]){
            if(tmp_id < ids[v]){
                tmp_id = ids[v];
                tmp_v = v;
            }
            //cout << tmp_v+1 << endl;
        }
        cout << tmp_v+1 << endl;
    }
    /*dfs(root);
    vector<ll> v(N);
    rep(i,N){
        v[tp[i]] = i;
    }
    //PR(v,N);
    vector<ll> ans(N,-1);
    rep(i,N){
        for(auto& u:G[i]){
            if(v[i] > v[u]){
                //cout << u+ << endl;
                ans[i] = u;
                break;
            }
        }
    }
    rep(i,N){
        cout << ans[i]+1 << endl;
    }
    /*queue<ll> que;
    que.push(root);
    prev[root] = -1;
    used[root] = 1;*/
    /*
    while(!que.empty()){
        ll v = que.front();
        que.pop();
        for(auto& u:G[v]){
            if(used[u] != 0){
                G[prev[u]].erase(lower_bound(G[prev[u]].begin(),G[prev[u]].end(),u));
                prev[u] = v;
                que.push(u);
                continue;
            }
            used[u] = 1;
            prev[u] = v;
            que.push(u);
        }
    }*/
    /*rep(i,N){
        cout << prev[i]+1 << endl;
    }*/
}

Measured memory_bytes: 18228
#include<stdio.h>
#include<stdlib.h>
int sum(int);
void add(int);
int comp( const void *c1, const void *c2 );
int a[101],b[101],bit[101];
int n;

int main(void){
  int j,ans;

  while(scanf("%d",&n),n){
    for(j=0;j<101;j++){
      a[j]=b[j]=bit[j]=0;
    }
    for(j=0;j<n;j++){
      scanf("%d",&a[j]);
      b[j]=a[j];
    }

    qsort(b,n,sizeof(int),comp);

    for(j=0;j<n;j++)
      a[j]=(int *)bsearch(&a[j],b,n,sizeof(int),comp)-b;

    ans=0;
    for(j=0;j<n;j++){
      ans += j - sum(a[j]);  //iツつゥツづァツ催古」ツづ個１ツづ個ビツッツトツづーツ個クツ算ツつオツづ按つェツづァ
      add(a[j]);             //ツ湘ェツ渉格ツづ個値ツづーツ嘉算
    }
    printf("%d\n",ans);
  }
  return 0;
}

int sum(int i){
  int s=0;i++;
  while(i>0){
    s+=bit[i];    //bitツづ個湘ェツ渉蛎[j]ツづ可１ツ嘉算
    i -= i & -i;  //i & -i ツィ iツづ個催古」ツづ個１ツづ個ビツッツト
}
  return s;
}

void add(int i){
  i++;
  while(i<=n){
    bit[i]++;
    i += i & -i;
}
}

int comp( const void *c1, const void *c2 )
{
  int tmp1 = *(int *)c1;
  int tmp2 = *(int *)c2;

  if( tmp1 < tmp2 )  return -1;
  if( tmp1 == tmp2 ) return  0;
  if( tmp1 > tmp2 )  return  1;
}

Measured memory_bytes: 0
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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 ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int a[100010];
int len[100010];
int sum[21][100010];
int dp[1<<20];

int main() {
   int N, M;
   cin >> N >> M;
   
   for (int i = 0; i < N; i++) {
      cin >> a[i];
      a[i]--;
      len[a[i]]++;
      sum[a[i]][i + 1]++;
   }
   for (int i = 0; i < M; i++) {
      for (int j = 0; j < N; j++) {
         sum[i][j + 1] += sum[i][j];
      }
   }

   for (int i = 0; i < (1<<M); i++) dp[i] = 999999999;
   dp[0] = 0;
   for (int i = 0; i < (1<<M); i++) {
      int pos = 0;
      for (int j = 0; j < M; j++) {
         if (i & (1<<j)) pos += len[j];
      }
      for (int j = 0; j < M; j++) {
         if (i & (1<<j)) continue;
         dp[i + (1<<j)] = min(dp[i + (1<<j)], dp[i] + len[j] - (sum[j][pos + len[j]] - sum[j][pos]));
      }
   }
   cout << dp[(1<<M) - 1] << endl;
   return 0;
}



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

int main(){
    int a,b;
    char op;
    while(1){
        cin >> a >> op >> b;
        if( op == '?')break;
        else if ( op == '-' ){
            cout << a - b << endl;
            
        } else if ( op == '*' ){
            cout << a * b <<endl;
            
        } else if ( op == '/' ){
            cout << a / b << endl;
            
        } else if ( op == '+' ){
            cout << a + b <<endl;
    }
    }
    return 0;
}




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

const int N = 1e5+5;
const int INF = 1e9;
int dist[N][3];
int main(){
	int n,m,s,t;
	cin>>n>>m;

	vector<int> G[n];
	for(int i = 0; i < n; i++){
		dist[i][0] = dist[i][1] = dist[i][2] = INF;
	}

	for(int i = 0; i < m; i++){
		int x,y;
		cin >> x >> y;
		--x,--y;
		G[x].push_back(y);
	}
	cin>>s>>t;
	--s,--t;
	dist[s][0] = 0;
	queue<pair<int,int>> q;
	q.push({s,0});
	while(!q.empty()){
		int u = q.front().first;
		int l = q.front().second;
		//cout<<u<<" "<<l<<endl;
		q.pop();
		for(int v : G[u]){
			 int nl = (l+1)%3;
			if(dist[v][nl]!=INF) continue;
			dist[v][nl]=dist[u][l]+1;
			q.push({v,nl});
		}
	}

	int ans = dist[t][0];
	if(ans == INF) cout<<-1;
	else cout<<(ans/3);	
}

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

int main() {
  int N, A;
  cin >> N >> A;

if (N >= 500) {
    int temp = N / 500;
    int last = N - 500 * temp;
    if (last <= A) {
         cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
} else {
    if (N <= A) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
  

}

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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

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

const int MAX = 1e5 + 5;
int n, m;
vector<int> adj[MAX];
bool visited[MAX];

int main() {
	scanf("%d %d", &n, &m);
	fori(i, 0, m) {
		int u, v;
		scanf("%d %d", &u, &v);
		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	deque<int> path {1, adj[1][0]};
	visited[1] = visited[adj[1][0]] = true;
	bool good = false;
	while(!good) {
		int x = path.front();
		good = true;
		for(auto &each : adj[x]) {
			if(!visited[each]) {
				good = false;
				path.push_front(each);
				visited[each] = true;
				break;
			}
		}
	}
	good = false;
	while(!good) {
		int x = path.back();
		good = true;
		for(auto &each : adj[x]) {
			if(!visited[each]) {
				good = false;
				path.push_back(each);
				visited[each] = true;
				break;
			}
		}
	}

	printf("%d\n", (int) path.size());
	for(auto &each : path) {
		printf("%d ", each);
	}
	puts("");

	return 0;
}



Measured memory_bytes: 6784
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;

const static UInt MOD = 1e9 + 7;

int main(void) {
    Int n, m;
    cin >> n >> m;
    VI stairs(n + 1);
    for (Int i = 0; i <= n; ++i) {
        stairs[i] = 0;
    }
    Int broken;
    for (Int i = 0; i < m; ++i) {
        cin >> broken;
        stairs[broken] = -1;
    }
    if (n == 1) {
        if (m == 1) {
            cout << 0 << endl;
        } else {
            cout << 1 << endl;
        }
    } else {
        stairs[0] = 0;
        if (stairs[1] != -1) {
            stairs[1] = 1;
        } else {
            stairs[1] = 0;
        }
        if (stairs[2] != -1) {
            stairs[2] = stairs[1] + 1;
        } else {
            stairs[2] = 0;
        }
        for (Int i = 3; i <= n; ++i) {
            if (stairs[i] == -1) {
                stairs[i] = 0;
            } else {
                stairs[i] = ((stairs[i - 1] + stairs[i - 2]) % MOD);
            }
        }
        cout << stairs[n] << endl;
    }
    return 0;
}


Measured memory_bytes: 4024
# 11

n, m = map(int, input().split())
ks_l = [[int(x) for x in input().split()] for y in range(m)]
p_l = [int(x) for x in input().split()]

ans = 0

for i in range(2**n):
    for j in range(m):
        _tmp = 0
        for k in range(ks_l[j][0]):
            if((i >> (ks_l[j][k+1] - 1)) & 1):
                _tmp += 1
        if (_tmp % 2) != p_l[j]:
            break
    else:
        ans += 1

print(ans)

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

int main(){
    string s;
    cin >> s;
    ll cnt=0;
    for(int i=0; i<s.size(); i++){
        cnt += s.at(i)-'0';
    }
    //cout << cnt << endl;
    if(cnt %9==0){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}


Measured memory_bytes: 3724
#include<bits/stdc++.h>
#define int long long int
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 200005
#define MOD2 998244353
#define MOD1 1e9+7
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define piii pair<pii,int>
#define precise(i) cout<<fixed<<setprecision(i)
using namespace std;
const double PI = atan(1.0)*4;
const int64_t INF=100000000000000003;
const int32_t LOG=21;
const int MOD=MOD1;
int cnt[10][10];
int first_digit(int x)
{
	while(x>=10)x/=10;
	return x;
}
int last_digit(int x)
{
	return x%10;
}
int32_t main()
{
     int n;
     cin>>n;
     rep(i,1,n+1)
     {
     	 cnt[first_digit(i)][last_digit(i)]++;
     }
     int ans=0;
     rep(i,1,10)rep(j,1,10)
     {
         if(i==j)
         {
         	 int t=(cnt[i][i]*(cnt[i][i]));
         	 ans+=t;
         }
         else
         {
         	 int t=cnt[i][j]*cnt[j][i];
         	 ans+=t;
         }	
     }
     cout<<ans<<endl;
     return 0;     
}

Measured memory_bytes: 256
using System;

class A
{
	static void Main() => Console.WriteLine("1 1 1 2 1 2 1 5 2 2 1 5 1 2 1 14 1 5 1 5 2 2 1 15 2 2 5 4 1 4 1 51".Split()[int.Parse(Console.ReadLine()) - 1]);
}


Measured memory_bytes: 27160
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        String[] S = str.split("");
        String str2 = sc.nextLine();
        String[] T = str2.split("");
        int c = 0;
        for (int i = 0; i < S.length; i++) {
            if ( S[i].equals(T[i]) ) {
                c = c;
            } else {
                c = c+1;
            }
        }
        System.out.println(c);
    }
}

Measured memory_bytes: 66384
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	int a, b, c; cin >> a >> b >> c;
	if(a - b <= c){
		c -= (a - b);
		cout << c << endl;
		return 0;
	}
	else{
		cout << 0 << endl;

	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(){
	
	char name [55] ;
	int Fs, Sn ;
	
	scanf ("%d %d", &Fs, &Sn);
	scanf ("%s", &name);
	
	int Th = Sn-1 ;
	
	int X = name[Th] + 32;
	name[Th]= X;
	
	printf ("%s", name);
	
	return 0 ;
}

//  \N JANGAN LUPA!!!!!

Measured memory_bytes: 1704
#include<stdio.h>

int main(){
	int N,M,C;
	scanf("%d %d %d", &N, &M, &C);
int B[M];
	for(int i = 0; i < M; i++){
		scanf("%d",&B[i]);
	}
	int A[N][M];
	for(int i = 0; i < N; i++){
		for(int j = 0; j < M; j++){
			scanf("%d",&A[i][j]);
		}
	}
	int count = 0;
	int ans[N];
	for(int i = 0; i < N; i++){
		ans[i] = 0;
	}
	for(int i = 0; i < N; i++){
		for(int j = 0; j < M; j++){
			ans[i] += A[i][j] * B[j];
		}
		ans[i] += C;
		if(ans[i] > 0){
			count++;
		}
	}
	printf("%d\n", count);
	return 0;
}

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

int main(){
    int N,A,B,C,l[10] ;
    cin >> N >> A >> B >> C ;
    int MP[66666] ;
    int a=0,b=0,c=0 ;
    int pattern=1,keta;
  
    for(int i=0 ; i<N ; i++) {
        cin >> l[i] ;
        pattern*=4;
    }
  
    for(int i=0 ; i<pattern ; i++){
        int j=i;
        keta=0;
        a=0;
        b=0;
        c=0;
        MP[i]=-30;
        while(j!=0){
            switch(j%4){
                case 1:
                a += l[keta] ;
                MP[i] += 10 ;
                break;

                case 2:
                b += l[keta] ;
                MP[i] += 10 ;
                break;

                case 3:
                c += l[keta] ;
                MP[i] += 10 ;
                break;

            }
            keta++;
            j/=4;
        }
        if(a<=0 || b<=0 || c<=0) MP[i]=1000000000 ;
        else MP[i] += abs(A-a)+abs(B-b)+abs(C-c) ;
    }

    sort(MP,MP+pattern) ;

    cout << MP[0] << endl;

}


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

int main(){
    int n;
    cin >> n;
    vector<pair<double, double>> xy(n);
    vector<int> town;
    rep(i, n) {
        double x, y;
        cin >> x >> y;
        xy[i] = {x, y};
        town.push_back(i);
    }
    double sum = 0.0;
    int num = 0;
    do {
        rep(i, n-1) {
            double x_diff = (double)xy[town[i+1]].first - (double)xy[town[i]].first;
            double y_diff = (double)xy[town[i+1]].second - (double)xy[town[i]].second;
            double x_diff_sqare = x_diff * x_diff;
            double y_diff_sqare = y_diff * y_diff;
            sum = (double)sum + (double)sqrt(x_diff_sqare + y_diff_sqare);
        }
        ++num;
    } while ( next_permutation(town.begin(), town.end()));

//    cout << num << endl;
    printf("%.7lf\n", sum / (double)num );

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int k, s, cnt;
int main()
{
    cin >> k >> s;
    for(int i = 0; i <= k; i++){
        for(int j = 0; j <= k; j++){
            if(s - (i + j) <= k && s - (i + j) >= 0){
                cnt++;
            }
        }
    }
    cout << cnt;
    return 0;
}


Measured memory_bytes: 256
/*
	Created by Faisal Ahmed
*/
 
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef long double ld;

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

    int n, k, arr[200010];
	
	cin >> k >> n;
	for(int i = 0; i < n; i++){
		cin >> arr[i];
	}
	
	int mx = 0;
	for(int i = 0; i < n - 1; i++){
		mx = max(mx, arr[i + 1] - arr[i]);
	}
	
	mx = max(mx, k - arr[n - 1] + arr[0]);
	
	cout << k - mx << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll         = long long;
constexpr ll MOD = 1000000007;
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REP2(i, x, n) for (ll i = x; i < (n); i++)
#define PR(x) cout << (x) << "\n"
#define PS(x) cout << (x) << " "
const long long INF = numeric_limits<long long>::max();
int main() {
    ll N;
    cin >> N;
    vector<ll> nums(N);
    REP(i, N) {
        cin >> nums[i];
    }
    sort(nums.begin(), nums.end());

    ll ans = 0;
    ll sum = nums[N - 1];
    for (ll i = N - 2; i >= 0; --i) {
        ans += (nums[i] * sum) % MOD;
        ans %= MOD;
        sum += nums[i];
        sum %= MOD;
    }
    PR(ans);

    return 0;
}

Measured memory_bytes: 4836
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

// ===============================================================

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;
using ld = long double;

// ========================================================================

//ライブラリ(*'▽')

ll gcd(ll a, ll b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}
//最大公約数
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
//最小公倍数
ll box(double a)
{
	ll b = a;
	return b;
}
//切り捨て
ll fff(double a)
{
	ll b = a + 0.5;
	return b;
}
//四捨五入
ll sum(ll n) {
	return (1 + n) * n / 2;
}
//1から整数nまでの合計を出す
bool prime(ll a)//素数判定、primeならtrue,違うならfalse
{
	if (a < 2) return false;
	else if (a == 2) return true;
	else if (a % 2 == 0) return false;
	double m = sqrt(a);
	for (int i = 3; i <= m; i += 2)
	{
		if (a % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}
//素数判定
ll modpow(ll a, ll n, ll mod) {
	ll hi = 1;
	while (n > 0) {
		if (n & 1) hi = hi * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return hi;
}
//いろいろやります（ただの前座）
ll mg(ll a, ll mod) {
	return modpow(a, mod - 2, mod);
}
//割り算の10^9+7等対策で逆元を出します



// ========================================================================


vl e(250000);
vl f(250000, 100000000000);

int main() {
	ll n; cin >> n;
	if (n >= 30) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 7008
#include <iostream>
#include <cmath>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long int ll;

int N;
int A[200010];

int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A, A + N);
  bool isDiff = true;
  for (int i = 1; i < N; i++) {
    if (A[i] == A[i-1]) isDiff = false;
  }
  if (isDiff) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
string S; cin >>S;
int ctp = 0;int ctm = 0;
for(int i =0;i < 4; i++){
    if(S.at(i) == '+'){
        ctp++;
    }
    else if(S.at(i) == '-'){
        ctm--;
    }
    }
cout << ctp + ctm << endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define MAX 10001
#define B 100
#define dmp make_pair
#define dpb push_back
#define fi first
#define se second
#define P pair<int,int>
typedef long long ll;
const int inf = 1e9;
const ll INF = 1e18;
using namespace std;
//__gcd(a,b), __builtin_popcount(a);

chrono::system_clock::time_point  start;
void timerstart(){start = chrono::system_clock::now();}
void timerend(){
	auto end = chrono::system_clock::now();
	int elapsed = chrono::duration_cast<chrono::milliseconds>(end-start).count();
	printf("%d[ms]\n", elapsed);
}


int main(){
	int n;
	scanf("%d", &n);
	printf("%d\n", 24+24-n);
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  int ans=0;
  for(int i=0; i<N; i++){
    cin >> a.at(i);
    ans+=a.at(i)-1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int n;
	scanf("%d",&n);
	int a[n],b[n];
	int i,same=0;
	for (i=0;i<n;i++) scanf("%d",&a[i]);
	for (i=n-1;i>=0;i--) scanf("%d",&b[i]);
	int left=0, right=n-1;		
	i=0;
	//находим левую и правую границу одинаковых значений
	while ((a[i]!=b[i])&&(i<n)) i++;
	left=i;
	i=n-1;
	while ((a[i]!=b[i])&&(i>=0)) i--;
	right=i;
//	printf("left=%d right=%d\n", left,right);
	//если нет пересечений то форму пролетают и сразу печатаем массив
	int k,j;
	for (i=0,j=0;(i<left)&&(left+j<=right); i++) { 
		if((b[i]!=b[left+j])&&(a[i]!=b[left+j])){
			k=b[i]; 
			b[i]=b[left+j];
			b[left+j]=k;
			j++;
		}
	}
	i=j+left;
//	printf("i=%d\n",i);
//	for (i=0;i<n;i++) printf("%d ", b[i]);
	for (j=0;(i<=right)&&(right+j+1<n);j++) { 
		if ((b[i]!=b[right+j+1])&&(a[right+j+1]!=b[i])){
			k=b[i];
			b[i]=b[right+j+1];
			b[right+j+1]=k;
			i++;
		}
	}
	if (i<=right) printf("No\n");
	else {
		printf("Yes\n");
		for (i=0;i<n;i++) printf("%d ", b[i]);
	}
	return 0;
}
	


Measured memory_bytes: 3264
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;


int main()
{
	unsigned long long a, b;
	int k;
	

	cin >> a >> b >> k;

	for (int i = 0; i < k; i++)
	{
		if (i % 2 == 0)
		{
			if (a % 2U != 0)
			{
				a--;
			}
			b += a / 2;
			a = a / 2;
		}
		else
		{
			if (b % 2U != 0)
			{
				b--;
			}
			a += b / 2;
			b = b / 2;
		}
	}

	cout << a << " " << b;

	return 0;
}

Measured memory_bytes: 256
#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 <iomanip>
using namespace std;
#define INF 1e9
#define PI acos(-1)
typedef long long ll;




int main() {

	ll n;
	cin >> n;
	ll fn = n;
	ll sum = 0;

	for (int i = 0; i < 10; i++) {
		if (n == 0)break;
		sum += n % 10;
		n /= 10;
	}
	
	if (sum == 0) {
		cout << "No" << endl;
		return 0;
	}

	bool flag = false;
	if (fn%sum == 0)flag = true;
	cout << ((flag) ? "Yes" : "No") << endl;

	return 0;
}

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

typedef long long ll;

const int maxn = 110, maxk = 1e5 + 5, mod = 1e9 + 7;
int N, K, a[maxn];
ll dp[maxn][maxk];

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

    cin >> N >> K;
    for (int i = 1; i <= N; i++) {
        cin >> a[i];
    }
    dp[0][0] = 1;
    for (int i = 1; i <= N; i++) {
        ll pref[K + 1];
        pref[0] = dp[i - 1][0];
        for (int j = 1; j <= K; j++) {
            pref[j] = (pref[j - 1] + dp[i - 1][j]) % mod;
        }
        for (int j = 0; j <= K; j++) {
            dp[i][j] = pref[j];
            int t = j - a[i] - 1;
            if (t >= 0) {
                dp[i][j] = (dp[i][j] - pref[t] + mod) % mod;
            }
        }
    }
    cout << dp[N][K];

    return 0;
}

Measured memory_bytes: 82548
#include <stdio.h>
#include <vector>
#include <string>
#include <algorithm>
#include <iostream>
#include <cmath>
using namespace std;

static const int MAX = 1e5;
static const int INF = 1e9;
int n, A[MAX], ans;

int GreatestCommonDivisor(int x, int y) {
    int r = x;
    
    if ( x < y ) {
        x = y;
        y = r; 
    }
    
    while ( r > 0 ) {
        r = x % y;
        x = y;
        y = r;
    }

    return x;
}

int main() {
    scanf("%d", &n);
    ans = 0;

    for ( int i = 0; i < n; i++ ) {
        scanf("%d", &A[i]);
        ans = GreatestCommonDivisor(ans, A[i]);
    }

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


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#define MAX_N 100010
const int MOD = 1e9 + 7;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
using namespace std;
typedef long long ll;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int t[MAX_N], x[MAX_N], y[MAX_N];
	t[0] = x[0] = y[0] = 0;
	bool flag = true;
	for(int i = 1; i <= n; i++)
	{
		cin >> t[i] >> x[i] >> y[i];
		int dt = t[i] - t[i - 1];
		int d = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
		if(d > dt)
			flag = false;
		if(dt % 2 != d % 2)
			flag = false;
	}
	cout << (flag ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 1536
N = int(input())
D = list(map(int, input().split()))
if D[0] != 0:
    print(0)
    exit()
import collections
cnt = collections.Counter(D[1:])
if 0 in cnt:
    print(0)
    exit()
maxs = 998244353
res = 1
flag = True
scnt = sorted(cnt.items(), key=lambda x: x[0])
if scnt[0][0] != 1:
    print(0)
else:
    for i in range(1, len(scnt)):
        if scnt[i][0] != scnt[i-1][0] + 1:
            flag = False
            break
        # pre = res
        res = (res * (scnt[i-1][1] ** scnt[i][1])) % maxs
        # print(res)
    print(res) if flag else print(0)


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

int main(){
  string s;
  cin >> s;
  for(int i = 0; i < s.size(); i++){
  	if(i % 2 == 0 && s[i] == 'L'){
      cout<<"No"<<endl;
    	return 0;
    }else if(i % 2 != 0 && s[i] == 'R'){
    	cout<<"No"<<endl;
      	return 0;
    }
  }
  
  cout<<"Yes"<<endl;
  return 0;
}

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

#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

signed main(){
	char a;
	cin >> a;
	if(a == toupper(a)){
		cout << "A" << endl;
	}else{
		cout << "a" << endl;
	}

	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <complex>
#include <cstdio>
#include <utility>
using namespace std;
typedef complex<double> P;
typedef pair<P,P> L;
#define X real()
#define Y imag()

double dot(P a, P b){
  return (a.X * b.X + a.Y * b.Y);
}

P projection(P a, P b){
  //a???????????????b??????????????????????????£?°???±?????????????????????
  return dot(a,b)/abs(b)/abs(b)*b;
}

P line_symmetry(L l, P p){
  return p + (l.first - p + projection(p-l.first,P(l.second-l.first)))*2.0;
}

int main(){
  P p1, p2;
  double x1, x2, y1, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  p1 = P(x1,y1);
  p2 = P(x2,y2);
  int q;
  cin >> q;
  for(int i = 0; i < q; ++i){
    P p;
    cin >> x1 >> y1;
    p = line_symmetry(L(p1,p2),P(x1,y1));
    printf("%.9lf %.8lf\n",p.X,p.Y);
  }
  return 0;
}

Measured memory_bytes: 3352
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};

vector<long long> calc_divisor(long long n) {
    vector<long long> res;
    for (long long i = 1LL; i*i <= n; ++i) {
        if (n % i == 0) {
            res.push_back(i);
            long long j = n / i;
            if (j != i) res.push_back(j);
        }
    }
    sort(res.begin(), res.end());
    return res;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int n;
  cin >> n;
  vector<int>vec(n);
  rep(i,n) cin >> vec[i];
  vector<int>mp(1e6+1,0);
  rep(i,n)mp[vec[i]]++;
  int ans = 0;
  rep(i,n){
    vector<ll>div=calc_divisor(vec[i]);
    bool ok = true;
    for(auto d:div){
      if(mp[d]>0){
        if(d==vec[i] && mp[d]==1)continue;
        ok = false;
      }
    }
    if(ok){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 7956
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c==' '||c=='\n')c=_buff.get();return c;}
int n;
pair<int,int> a[200111];
pair<int,int> seg[200111];
int tab[200111];
void add(int x,int v)
{
	for(int i=x;i<=200005;i+=i&(-i))tab[i]=tab[i]+v>=mod?tab[i]+v-mod:tab[i]+v;
}
int query(int x)
{
	ll ret=0;
	for(int i=x;i;i-=i&(-i))ret+=tab[i];
	return ret%mod;
}
ll dp[200111];
int v[200111],vn;
int getid(int x){return lower_bound(v,v+vn,x)-v+1;}
int main()
{
	geti(n);
	for(int i=1;i<=n;i++)
	{
		getii(a[i].FF,a[i].SS);
		v[vn++]=a[i].SS;
	}
	sort(v,v+vn);
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)a[i].SS=getid(a[i].SS);
	int mx=a[1].SS;
	for(int i=1;i<=n;i++)
	{
		mx=max(mx,a[i].SS);
		seg[i].FF=mx;
	}
	int mn=a[n].SS;
	for(int i=n;i>=1;i--)
	{
		mn=min(mn,a[i].SS);
		seg[i].SS=mn;
	}
	sort(seg+1,seg+n+1);
	add(1,1);
	for(int i=1;i<=n;i++)
	{
		ll cur=(query(seg[i].FF+1)-query(seg[i].SS-1)+mod)%mod;
		add(seg[i].FF+1,cur);
	}
	ll ans=(query(mx+1)-query(mx)+mod)%mod;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vs = vector<string>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  yn(a)    cout << ( (a)?"Yes\n":"No\n" );
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
const ll INF = 1e9+9, LINF = 1e18;


int main()
{
    ll M,ans=1;
    cin>>M;
    bool P[M+10]={0};
    P[0]=P[1]=1;
    for(int i=2;i*i<M+7;i++) if(!P[i]) for(int j=i+i;j<M+7;j+=i) P[j]=1;
    
    map<ll,ll> x;
    rep(i,M+1)if(P[i]==0) for(ll j=i;j<=M;j*=i)x[i]+=M/j;
    for(auto z:x)ans*=z.second+1,ans%=INF-2;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
        long long nb=0, c=0;
        string s;
        cin>>s;
        for(long long i=0;i<s.size();i++){
                if(s[i]=='B')   nb += 1;
                else c += nb;
        }
        cout<<c<<endl;
        return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define INF (int)1e9
#define endl "\n"
#define ll long long
#define ull unsigned long long

using namespace std;

ull solve(ull n)
{
    if (n == 1)
        return 1;

    return 1 + 2 * solve(n / 2);
}

int main()
{
    ll n;
    cin >> n;

    ll ans = solve(n);
    cout << ans << endl;
}

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

int main() {
  int h,w;
  cin>>h>>w;
  string map[h];
  for(int i=0;i<h;i++){
      cin>>map[i];
  }
  for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
          if(map[i].at(j)=='.'){
              int c=0;
              if(i-1>=0&&map[i-1].at(j)=='#')c++;
              if(i+1<h&&map[i+1].at(j)=='#')c++;
              if(j-1>=0&&map[i].at(j-1)=='#')c++;
              if(j+1<w&&map[i].at(j+1)=='#')c++;
              if(i-1>=0){
                if(j-1>=0&&map[i-1].at(j-1)=='#')c++;
                if(j+1<w&&map[i-1].at(j+1)=='#')c++;
              }
              if(i+1<h){
                  if(j-1>=0&&map[i+1].at(j-1)=='#')c++;
                  if(j+1<w&&map[i+1].at(j+1)=='#')c++;
              }
              map[i].at(j)='0';
              map[i].at(j)+=c;
          }
      }
  }
  for(int i=0;i<h;i++){
      cout<<map[i]<<endl;
  }
}


Measured memory_bytes: 256