akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <tuple>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <bitset>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int cnt[13];
int p[25];

int ans = 0;

void rec(int d) {
    if (d == 13) {
        int t = 100;
        forn(i, 25) forn(j, i) if (p[i] && p[j]) uin(t, min(i - j, 24 - (i - j)));
        uax(ans, t);
        return;
    }
    if (cnt[d] > 2) return;
    if ((d == 0 || d == 12) && cnt[d] > 1) return;
    if (cnt[d] == 0) {
        rec(d + 1);
        return;
    }
    if (cnt[d] == 1) {
        p[12 + d] = 1;
        rec(d + 1);
        p[12 + d] = 0;

        p[12 - d] = 1;
        rec(d + 1);
        p[12 - d] = 0;
        return;
    }
    p[12 - d] = p[12 + d] = 1;
    rec(d + 1);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    int n;
    cin >> n;
    cnt[0] = 1;
    forn(i, n) {
        int x;  
        cin >> x;
        ++cnt[x];
    }

    rec(0);
    cout << ans << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
typedef pair<P,long double> Pi;
typedef pair <long double,int> Pd;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
const long double dinf=10000000000000.0;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
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 (a>b) { a=b; return 1; } return 0; }
ll dp[305][305],dp2[305][305];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n,m,l;
cin>>n>>m>>l;
for(int i=0;i<n;i++)for(int j=0;j<n;j++)if(i!=j){dp[i][j]=inf;dp2[i][j]=inf;}
for(int i=0;i<m;i++){
    ll a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    dp[a][b]=c;
    dp[b][a]=c;
}
int V=n;
for(int k=0;k<V;k++)
                for(int i=0;i<V;i++)
                   for(int j=0;j<V;j++)
                      dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
for(int i=0;i<V;i++)for(int j=0;j<V;j++)if(dp[i][j]<=l)dp2[i][j]=min(dp2[i][j],1ll);
for(int k=0;k<V;k++)
                for(int i=0;i<V;i++)
                   for(int j=0;j<V;j++)
                      dp2[i][j]=min(dp2[i][j],dp2[i][k]+dp2[k][j]);
int q;
cin>>q;
while(q--){
    int s,t;
    cin>>s>>t;
    s--;t--;
    bool ok=false;
    if(dp2[s][t]>=inf)cout<<-1<<endl;
    else cout<<dp2[s][t]-1<<endl;
 }
}



Measured memory_bytes: 2048
<?php
$s = strrev(trim(fgets(STDIN)));

$a = strrev("dream");
$b = strrev("dreamer");
$c = strrev("erase");
$d = strrev("eraser");
$arr = array($a, $b, $c, $d);

$z = str_split($s);
$check = "";

for($i=0; $i<strlen($s); $i++){
    $check .= $z[$i];
    if(in_array($check, $arr)){
        $check = "";
    }
}

if(!$check){
    echo "YES";
}else{
    echo "NO";
}

?>

Measured memory_bytes: 21132
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    ll n,m,d;
    cin >> n >> m >> d;
    double ans;
    if(d == 0) ans = ((1.0/n)*(m-1));
    else ans = ((2.0*(n-d)/((double)n*n))*(m-1));

    printf("%.10f\n", ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,ans=9;
map< vector<int> ,int > d;
map< vector<int> ,int > d2;

int main(){
  cin>>n;
  vector<int> a(n),b(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
    a[i]--;
    b[i]=i;
  }
  for(int i=0;i<n;i++){

  }

  queue< vector<int> > Q;
  Q.push(a);
  d[a]=0;

  while(!Q.empty()){
    vector<int> p=Q.front();Q.pop();
    int cost=d[p];
    if(cost==4)continue;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	reverse(p.begin()+i,p.begin()+j+1);
	if( d.count(p) == 0 ){
	  d[p]=cost+1;
	  Q.push(p);
	}
	reverse(p.begin()+i,p.begin()+j+1);
      }
    }
  }

  Q.push(b);
  d2[b]=0;

  while(!Q.empty()){
    vector<int> p=Q.front();Q.pop();
    int cost=d2[p];

    if(d.count(p)>0) ans = min (ans, d[p]+cost);
    if(cost==4)continue;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	reverse(p.begin()+i,p.begin()+j+1);
	if( d2.count(p) == 0 ){
	  d2[p]=cost+1;
	  Q.push(p);
	}
	reverse(p.begin()+i,p.begin()+j+1);
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 81268
S = input()
N = len(S)
B = [0] * N
for i in range(0, N):
    B[i] = int(S[i] == 'B')
    if i > 0:
        B[i] += B[i - 1]
P = 0
for i in range(1, N):
    if S[i] == 'W':
        P += B[i]
print(P)


Measured memory_bytes: 11240
/* Atcoder panasonic2020a
 * See tasks at: https://atcoder.jp/contests/panasonic2020/tasks/panasonic2020_a
 */
#include <bits/stdc++.h>

#define until(symbol, max) for (int symbol = 0; (symbol) < (max); (symbol)++)

using namespace std;
using ll = long long;
int main()
{
    array<int, 32> seq = { 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 };
    
    int k;
    cin >> k;

    cout << seq.at(k - 1);

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<functional>

using namespace std;

struct NodeData {
    vector<int> edge;
    int parent=-1;
    int point = 0;
};

int main() {
    int N, Q, a, b, p, x;
    cin >> N >> Q;
    vector<NodeData> tree(N);
    for(int i = 0; i < N - 1;  i++) {
        cin >> a >> b;
        tree[a-1].edge.push_back(b-1);
        tree[b-1].edge.push_back(a-1);
    }
    for(int q = 0; q < Q; q++) {
        cin >> p >> x;
        tree[p - 1].point += x;
    }
    function<void(int)> updatePoint = [&tree, &updatePoint](int i) {
        for(int j : tree[i].edge) {
            if(tree[i].parent != j) {
                tree[j].parent = i;
                tree[j].point += tree[i].point;
                updatePoint(j);
            }
        }
    };

    updatePoint(0);
    for(const auto& node : tree) {
        cout << node.point << " ";
    }
}


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

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

  vector<int> vec;

  for(int i = 0; i < N; i++) {
    int v;
    cin >> v;
    vec.push_back(v);
  }

  int flag = 0;

  for(int i = 0; i < N; i++) {
    if(vec.at(i) % 2 == 0) {
      if(vec.at(i) % 3 != 0 && vec.at(i) % 5 != 0) {
        flag = 1;
        break;
      }
    }
  }

  if(flag == 0) {
    cout << "APPROVED" << endl;
  } else if (flag == 1) {
    cout << "DENIED" << endl;
  }

}


Measured memory_bytes: 256
local n=io.read("n")
local t={3,5,7}
local i=1
while t[#t]<=n do
    for j=3,7,2 do
        t[#t+1]=t[i]*10+j
    end
    i=i+1
end
local counter=0
for i=1,#t do
    local three=false
    local five=false
    local seven=false
    local copy=t[i]
    while copy>0 do
        if copy%10==3 then three=true
        elseif copy%10==5 then five=true
        elseif copy%10==7 then seven=true
        end
        copy=math.floor(copy/10)
    end
    if three and five and seven and t[i]<=n then
        counter=counter+1
    end
end
print(counter)

Measured memory_bytes: 2920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e9;
const ll MOD = 998244353;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define repb(bit, n, init) for (ll bit = init; bit < (1 << n); ++bit)

ll modpower(ll x, ll n, ll mod)
{
    ll res = 1;
    while (n)
    {
        if (n & 1)
            res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
ll inv(ll n)
{
    return modpower(n, MOD - 2, MOD);
}
void COMinit(vector<ll> &fact, vector<ll> &invfact, ll k)
{ //空っぽの配列を二つ
    fact.resize(k, 0);
    invfact.resize(k, 0);
    fact[0] = 1;
    repi(i, k, 1)
    {
        fact[i] = fact[i - 1] * i % MOD;
    }
    invfact[k - 1] = inv(fact[k - 1]);
    repd(i, k - 2, 0)
    {
        invfact[i] = invfact[i + 1] * (i + 1) % MOD;

    }
    return;
}
ll nCk(vector<ll> &fact, vector<ll> &invfact, ll n, ll k)
{ //この関数を使う前にCOMinit
    if (k < 0 || n < k)
        return 0LL;
    return fact[n] * invfact[k]%MOD * invfact[n - k] % MOD;
}

//---------main function----------

int main()
{
    ll n, m, k;
    cin >> n >> m >> k;
    vector<ll> fact, invfact;
    COMinit(fact, invfact, 200000);
    ll ans = 0;
    repi(i, k + 1, 0)
    {
        ans += nCk(fact,invfact,n-1,i) * m % MOD * modpower(m-1,n-i-1,MOD)%MOD;
    }
    // while(ans < 0)ans += MOD;
    cout << ans % MOD << endl;
    return 0;
}

Measured memory_bytes: 6428
#include <algorithm>
#include <cassert>
const int MaxNode = 100;

struct UnionFind {
    int node_num;
    int parent[MaxNode];
    int weight = 0;
    
    UnionFind(int node_num) : node_num(node_num) {
        std::fill(parent, parent + node_num, -1);
    }
    
    int root(int u) {
        return parent[u] < 0 ? u : parent[u] = root(parent[u]);
    }
    
    bool find(int u, int v) {
        return root(u) == root(v);
    }
    
    bool unite(int u, int v, int cost) {
        if ((u = root(u)) == (v = root(v))) {
            return false;
        } else {
            if(parent[u] > parent[v]) {
                std::swap(u, v);
            }
            parent[u] += parent[v];
            parent[v] = u;
            weight += cost;
            return true;
        }
    }
};
template <typename T>
struct Edge {
    
    Edge() = default;
    Edge(int from, int to, int cost) : from(from), to(to), cost(cost) {}
    
    Edge(const Edge&) = default;
    Edge& operator=(const Edge&) = default;
    Edge& operator=(Edge&&) = default;
    
    
    int from;
    int to;
    T cost;
};

#include <iostream>
using namespace std;

int main() {
	int n;
	cin >> n;
	UnionFind uf(n);
	
	std::vector<Edge<int>> edges(n);
	
	for(int i = 0; i < n; ++i) {
		for(int j = 0; j < n; ++j) {
			int dist;
			cin >> dist;
			
			if(i != j && dist != -1) {
				edges.emplace_back(i, j, dist);
			}
		}
	}
	
	std::sort(edges.begin(), edges.end(), [](Edge<int> a, Edge<int> b){return a.cost < b.cost;});

	for (auto& e : edges) {
        if (!uf.find(e.from, e.to)) {
            uf.unite(e.from, e.to, e.cost);
        }
    }
    
    cout << uf.weight << endl;
	return 0;
}

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

int main()
{

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

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

    cout << A[N - 1] - A[0] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <climits>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << 0; return;}
#define mkp make_pair
#define mkt make_tuple
#define cerr if(0) cerr

void solve() {
    string s, t;
    cin >> s >> t;
    cout << t << s;
}

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


Measured memory_bytes: 3616
/*Bismillahir Rahmanir Rahim*///{
#include <bits/stdc++.h>
#include <ext/numeric>
using namespace std; using __gnu_cxx::power;
using ll = long long; using ull = unsigned long long; using ld = long double;
const ll llinf = (1ll<<61)-1; const double eps = 1e-6, ldeps = 1e-9;
struct Dbg { static constexpr auto &os = cout;   // replace by cerr in interactive.
template<class C> static auto o(C *x)->decltype(os << *x, 0);
template<class C> static char o(...);
template<class C> typename enable_if<sizeof o<C>(0)!=1,Dbg&>::type operator<<(const C &x) {os<<x; return *this;}
template<class C> Dbg &dump(C b, C e) {
    for (struct{C i;int j;} i={(*this<<"\n[",b),0}; i.i!=e and i.j<26; i.i++, i.j++) *this<<", "+2*(i.i==b)<<*i.i;
    return *this << ']';
}
template<class C> typename enable_if<sizeof o<C>(0)==1, Dbg&>::type operator<<(const C &x) {
    return dump(begin(x), end(x));
}
template<class C, size_t X> typename enable_if<!is_same<C, const char>::value, Dbg&>::type operator<<(C (&x)[X]) {
    return dump(begin(x), end(x));
}
template<class B, class C> Dbg &operator<<(const pair<B, C> &x) {return *this<<'{'<<x.first<<", "<<x.second<<'}';}
Dbg &operator<<(ostream&(*x)(std::ostream&)) { os << x; return *this; }
} dbg;
void err(istringstream *iss) { delete iss; }
template<class C, class... Args> void err(istringstream *iss, const C &val, const Args &... args) {
    string name; *iss >> name; if (name.back()==',') name.pop_back();
    dbg << name << " = " << val << "; ", err(iss, args...);
}
#define bug(args...) dbg << __LINE__ << ": ", err(new istringstream(#args), args), dbg << endl
#define cbug(a, args...) if (a) bug(args);
#define ASSERT(a, o, b, args...) if (!((a)o(b))) bug(a, b, ##args), assert((a)o(b));
#define sl(a) int(strlen(a))
#define sz(a) int(a.size())
int T, Q, cn;//}
const int inf = 1000000007, mxn = 10000005;

const int mxnd = mxn;

int cntDiv[mxnd];
void preCntDiv(int nd) {
    for (int i = 1; i <= nd; ++i)
        for (int j = i; j <= nd; j += i)
            ++cntDiv[j];
}

signed main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); cout.precision(11), cout.setf(ios::fixed);
    preCntDiv(mxn-1);
    int n;
    cin >> n;
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        ans += i*ll(cntDiv[i]);
    }
    cout << ans << '\n';
}

Measured memory_bytes: 42660
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdio>
#include <list>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define vec vector<int>
#define vecll vector<ll>
#define vecstr vector<string>
#define vecch vector<char>
#define vecpii vector<pii>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}
int main(){
    int n=in(),x=0,a=0;
    string s=stin();
    rep(i,n)a=max(a,x=s.at(i)=='I'?x+1:x-1);
    cout<<a<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<math.h>
#include <string>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;
vector<ll> v[100];
string s;
long long solve(){
	for(int i=0;i<100;i++){
		v[i].clear();
	}
	int depth=0;
	int val=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='[')depth++;
		else if(s[i]==']'){
			if(val){
				v[depth].push_back((val+1)/2);
			}
			val=0;
			sort(v[depth].begin(),v[depth].end());
			ll sum=0;
			for(int j=0;j*2<v[depth].size();j++){
				sum+=v[depth][j];
			}
			v[depth-1].push_back(sum);
			v[depth].clear();
			--depth;
		}
		else{
			val*=10;
			int c=(int)(s[i]-'0');
			val+=c;
		}
	}
	return v[0][0];
}

int main(){
	int n; cin >>n;
	for(int i=0;i<n;i++){
		cin >>s;
		cout << solve() << endl;
	}
}



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

using namespace std;
using ll = long long;
using P = pair<int, int>;

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

// const int mod = 1000000007;
const int mod = 1e9 + 7;

const int MAX = 1000005;

struct Sieve {
  int n;
  vector<int> f, primes;

  Sieve(int n = 1) : n(n), f(n + 1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i * i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }

  bool isPrime(int x) { return f[x] == x; }

  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }

  vector<P> factor(int x) {
    auto fl = factorList(x);

    map<int, int> mp;
    for (auto p : fl) ++mp[p];

    vector<P> res;
    for (auto p : mp) res.push_back(p);

    return res;
  }
};

ll modpow(ll k, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * k % mod;
    k = k * k % mod;
    n /= 2;
  }

  return res;
}

int main() {
  int n;
  cin >> n;
  int a[n];
  rep(i, n) cin >> a[i];

  Sieve s(MAX);

  map<int, int> mp;
  rep(i, n) {
    auto v = s.factor(a[i]);
    for (auto p : v) {
      mp[p.first] = max(mp[p.first], p.second);
    }
  }

  ll lcm = 1;
  for (auto p : mp) {
    rep(i, p.second) { lcm = lcm * p.first % mod; }
  }

  ll ans = 0;
  rep(i, n) {
    ans += lcm * modpow(a[i], mod - 2);
    ans %= mod;
  }

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


Measured memory_bytes: 4984
#define watch5(a,b,c,d,e) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d << " | "<<#e<<": "<<e<<endl;
#define watch4(a,b,c,d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define watch3(a,b,c) cerr <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<endl;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define sharingan cerr << "\n-------------------------------------------\n\n";
#define watch2(a,b) cerr <<#a<<": "<<a<<" | "<<#b<<": "<<b<< endl;
#define Yup ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define watch(a) cerr <<#a<<": "<<a<<endl;
#define __gcd(a, b) __algo_gcd(a, b)
#define PI 3.14159265358979323846
#define mod 1000000007
#include "bits/stdc++.h"
using namespace std;
#define int long long

vector<int> adj[300000];
int vis[1000001];

int go( int i ){
    int cnt = 1;
    vis[i] = 1;
    for( auto it : adj[i] ){
        if( !vis[it] ){
            cnt += go(it);
        }
    }
    return cnt;
}

int32_t main(){
    int n, m;
    cin >> n >> m;
    for( int i = 0; i < m; i++ ){
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    int ans = 0;
    for( int i = 1; i <= n; i++ ){
        if( !vis[i] ){
            ans = max(go(i), ans);
        }
    }
    cout << ans;
}

Measured memory_bytes: 27840
#include<stdio.h>
#define MAX 999999
int main(void){
  int n,i,a[MAX],j;
  scanf("%d",&n);
  for(i=0;i<MAX;i++){
    a[i]=0;
  }
  a[0]=1;
  for(i=2;i<MAX/2;i++){
    for(j=2;i*j<=MAX;j++){
      if(a[i*j-1]==0) a[i*j-1]=1;
    }
  }
  for(i=1;i<MAX;i++){
    if(a[i]==0&&i+1>=n){
      printf("%d",i+1); 
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 4096
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
int n;
int main(){
	scanf("%d",&n);
	if(n==3)return puts("2 5 63"),0;
	fp(i,1,n)if(i%3!=1&&((n-i)&1^1)&&((n-i)<<1)*3<=30000){
		fp(k,1,i)printf("%d ",k<<1);
		fp(k,1,n-i)printf("%d ",((k<<1)-1)*3);
		return 0;
	}
	puts("QAQ");
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  string s;
  cin>>s;
  int N=s.size();
  vector<int>ans(N);
  int cnt=0;
  for(int i=0;i<N;i++){
    if(s[i]=='R'){cnt++;}
    else{
      ans[i]+=cnt/2;
      ans[i-1]+=(cnt+1)/2;
      cnt=0;
    }
  }
  
  reverse(s.begin(),s.end());
  reverse(ans.begin(),ans.end());

  cnt=0;
  for(int i=0;i<N;i++){
    if(s[i]=='L'){cnt++;}
    else{
      ans[i]+=cnt/2;
      ans[i-1]+=(cnt+1)/2;
      cnt=0;
    }
  }
  reverse(ans.begin(),ans.end());
  for(int i=0;i<N;i++){
    cout<<ans[i];
    if(i<N-1){cout<<' ';}
  }cout<<endl;
  return 0;
}

Measured memory_bytes: 3812
#include <stdio.h>
#include <math.h>
main(){
  int i,j,n,code;
  char com[7], op, dictionary[262145];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",com);
    j=0; code=0;
    while(j<=8){
      scanf("%c",&op);
      if(op=='\n') break;
      else if(op=='A') code+=1*pow(4,j);
      else if(op=='C') code+=2*pow(4,j);
      else if(op=='G') code+=3*pow(4,j);
      else if(op=='T') code+=4*pow(4,j);
      else j--;
      j++;
    }
    if(com[0] == 'i')
      dictionary[code] = 1;
    if(com[0] == 'f')
      if(dictionary[code] == 1) printf("yes\n"); else printf("no\n");
  }
  return 0;
}

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

int main() {
	int A, B;
	cin >> A >> B;
	if ((A + B) % 2 == 0) {
		cout << (A + B) / 2 << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}
}


Measured memory_bytes: 256
# coding: utf-8


def main():
    n = int(input())
    count = 0

    for num in range(1, n + 1, 2):
        d_count = 0
        for divnum in range(1, num + 1):
            if num % divnum == 0:
                d_count += 1

        if d_count == 8:
            count += 1

    print(count)


if __name__ == '__main__':
    main()


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

int main(){
    int m, d;
    cin >> m >> d;
    int ans = 0;
    for(int i = 1; i <= d; i++){
        for(int j = 1; j <= m; j++){
            if(i % 10 < 2 || i / 10 < 2)
                continue;
            if((i % 10) * (i / 10) == j)
                ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

// -------------------------------------------------------------------------------------



int main() {
  int h, w;
  cin >> h >> w;
  vector<string> f(h);
  rep(i, h) {
    cin >> f[i];
  }

  int dx[] = {1, 1, 1, 0, -1, -1, -1, 0};
  int dy[] = {1, 0, -1, 1, 1, 0, -1, -1};
  rep(i, h) {
    rep(j, w) {
      if(f[i][j] == '.') {
        int cnt = 0;
        rep(k, 8) {
          int ni = i + dx[k], nj = j + dy[k];
          if(ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
          if(f[ni][nj] == '#') cnt++;
        }
        f[i][j] = cnt + '0';
      }
    }
  }

  rep(i, h) {
    cout << f[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 256
import math

n = int(input())
lst = []
for i in range(n):
    s = sorted(str(input()))
    lst.append(s)
list.sort(lst)

cnt_1 = 0
x = lst[0]
i = 1
cnt_2 = 1
while i < n:

    if x == lst[i]:
        cnt_2 += 1

    else:
        x = lst[i]
        if cnt_2 != 1:        
            cnt_1 += int(math.factorial(cnt_2) / math.factorial(cnt_2 - 2) / 2)
        cnt_2 = 1
    i += 1

if cnt_2 != 1:
    cnt_1 += int(math.factorial(cnt_2) / math.factorial(cnt_2 - 2) / 2)


print(cnt_1)
    


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

long long go(int n)
{
	long long cnt=1;
	bool app[1000005]; fill(app,app+1000005,false);
	app[n]=true;
	while(true)
	{
		cnt++;
		if(n%2) n=3*n+1;
		else n=n/2;
		if(app[n]) return cnt;
		app[n]=true;
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n; cin>>n;
	cout<<go(n)<<"\n";
	return 0;
}

Measured memory_bytes: 1280
import sys
import math

#https://atcoder.jp/contests/agc008/submissions/15248942
sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N = ini()
A = inl()

ans = 0
for i in range(N-1):
    if A[i] > A[i+1]:
        ans += A[i] - A[i+1]
        A[i+1] = A[i]

print(ans)



Measured memory_bytes: 32308
def main():
    n = int(input())
    hs = map(int, input().rstrip().split(' '))
    highest = 0
    visible_count = 0
    for h in hs:
        if h >= highest:
            visible_count += 1
            highest = h
    print(visible_count)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <cstring>
#include <iostream>
#include <queue>
#include <vector>

int main() {
  int n, m;
  std::cin >> n >> m;

  // 経路
  std::vector<std::vector<int>> path(n);

  for (int i = 0; i < m; ++i) {
    int u, v;
    std::cin >> u >> v;
    --u, --v;
    // 順経
    path[u].push_back(v);
  }

  int s, t;
  std::cin >> s >> t;
  --s, --t;

  const int goal = 3 * t;

  // 到着タグ
  std::vector<int> visited(3 * n);
  std::memset(&visited[0], -1, sizeof(int) * visited.size());

  visited[3 * s] = 0;

  std::queue<int> order;
  order.push(3 * s);

  while (!order.empty() && (visited[goal] == -1)) {
    int now = order.front();
    order.pop();

    int step = visited[now] + 1;

    auto &next_list = path[now / 3];
    const auto kenpa = step % 3;
    for (auto next : next_list) {
      int next_pos = 3 * next + kenpa;
      auto &v = visited[next_pos];
      if (v == -1) {
        v = step;
        order.push(next_pos);
      }
    }
  }

  if (visited[goal] != -1) {
    std::cout << visited[goal] / 3 << std::endl;
  } else {
    std::cout << -1 << std::endl;
  }

  // // debug
  // std::cout << "=====" << std::endl;
  // for (int i = 0; i < visited.size(); i += 3) {
  //   printf("%5d %5d %5d\n", visited[i], visited[i + 1], visited[i + 2]);
  // }
}

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

#define N 10

int main() {
	static char s[N + 1];
	int n, n_, i, j;
	long long ans, x;

	scanf("%s", s);
	n = strlen(s);
	ans = 0;
	for (i = 0; i < n; i++) {
		x = 0;
		for (j = i; j < n; j++) {
			x = x * 10 + s[j] - '0';
			n_ = n - 1 - (j - i);
			if (i > 0)
				n_--;
			if (j + 1 < n)
				n_--;
			ans += x << n_;
		}
	}
	printf("%lld\n", ans);
	return 0;
}


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

#define ll long long

int main(){
  using namespace std;
  ll n,k;
  ll ans;
  cin >> n >> k;
  ans = n-k*(n/k);
  if(abs(ans-k)<ans) ans=abs(ans-k);
  cout << ans << endl;
  return 0;
}


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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
const ll mod = 1000000007;
const ll INF = 10010010010010010;

int main() {
    int n,k; cin >> n >> k;
    string s; cin >> s;
    int cnt = 0;
    rep(i,n-1) {
        if (s[i] == s[i+1]) cnt++;
    }
    cout << min(2*k+cnt,n-1) << endl;
    return 0;
}


Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
#define mod 998244353
#define ll long long int
#define N 200100
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin>>s;
	int cnt1=0,cnt2=0;
	for(auto c:s){
		if(c=='A')
			cnt1++;
		else
			cnt2++;
	}
	if(cnt1>0 && cnt2>0)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};

vector<int> par(0);
vector<int> depth(0);
vector<int> heavy(0);
void init(int n){
   par.resize(n);
   depth.resize(n,0);
   heavy.resize(n,0);
   rep(i,n) par[i]=i;
}

int find(int x){
   if(par[x]==x) return x;
   int parent =find(par[x]);
   heavy[x]+=heavy[par[x]];
   return par[x]=parent;
}

int wei(int x){
   find(x);
   return heavy[x];
}

void unite(int x,int y,int z){//yはxよりz重い
   z +=wei(x)-wei(y);
   x=find(x);
   y=find(y);
   if(par[x]==par[y]) return;
   if(depth[x]<depth[y]){
      par[x]=y;
      heavy[x]=-z;
   }
   else{
      par[y]=x;
      heavy[y]=z;
   if(depth[x]==depth[y]) depth[x] ++;
   }
}

bool same(int x,int y){
   return find(x)==find(y);
}

int diff(int x,int y){//w[y]-w[x],比較不可なら-1
   if(!same(x,y)) return -1;
   return wei(y)-wei(x);
}

int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n,m,l,r,d;
    cin>>n>>m;
    init(n);
    rep(i,m){
        cin>>l>>r>>d;
        r --;
        l --;
        if(diff(l,r)==d) continue;
        else if(same(l,r)){
            cout<<"No"<<endl;
            return 0;
        }
        else unite(l,r,d);
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
   int n,k;cin>>n>>k;
   map<int,int> mp;
   rep(i,n){
       int a;cin>>a;
       mp[a]++;
   }
   int x=mp.size();
   priority_queue<int, vector<int>, greater<int> > que;
   for(auto& p:mp){
       que.push(p.second);
   }
   int res=0;
   rep(i,x-k){
       int a=que.top();que.pop();
       res+=a;
   }
   cout<<res<<endl;
}

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

#define fori(i,k,n) for(int i = k; i<n; i++)
#define ll long long
#define all(k) k.begin(),k.end()
#define ff first
#define ss second
#define pb push_back

const ll mod = 998244353;

const int mxn = 1e5+1;
ll n;
vector<int> a(n);

ll power(ll x,ll y,ll p){
    ll res = 1;
    x%=p;
    while(y>0){
        if(y&1)res = (res*x)%p;
        y>>=1;
        x = (x*x)%p;
    }
    return res;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	bool ok = 1,turn = 1;
	while(true){
		if(turn){
			if(c<=0){
				ok&=1;
				break;
			}
			c-=b;
			turn = 0;
			if(c<=0){
				ok&=1;
				break;
			}
		}
		else{
			if(a<=0){
				ok&=0;
				break;
			}
			a-=d;
			turn = 1;
			if(a<=0){
				ok&=0;
				break;
			}
		}
	}
	if(ok)cout<<"Yes\n";
	else cout<<"No\n";
}

Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cstdlib>
#include <ctime>
#include <cstdint>
#include <cmath>

#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define EACH(i,x)   for(auto & i : x)
#define ALL(x)      begin(x),end(x)

using namespace std;

typedef vector<int> vecint;
const int INF=1000000;

int main()
{
  while(true){
    int n,m,l,k,a,h;cin>>n>>m>>l>>k>>a>>h;
    if(!n)break;
    vecint fz(l+2);
    REP(i,l)cin>>fz[i+1];
    fz[0]=a;
    fz[l+1]=h;
    vector<vecint> mat(n,vecint(n,INF));
    REP(i,k){
      int x,y,t;cin>>x>>y>>t;
      mat[x][y]=t;
      mat[y][x]=t;
    }
    REP(i,n)REP(j,n)REP(k,n)
      mat[j][k]=min(mat[j][k],mat[j][i]+mat[i][k]);
    vector<vecint> fmat(l+2,vecint(l+2,INF));
    REP(i,l+2)REP(j,l+2){
      fmat[i][j] = mat[fz[i]][fz[j]];
    }
    priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> q;
    vecint dist(l+2,INF);
    dist[0]=0;
    q.push(make_pair(0,0));
    while(!q.empty()){
      auto p=q.top();q.pop();
      if(dist[p.second] < p.first)continue;
      REP(i,l+2){
        if(fmat[p.second][i] <= m){
          if(dist[i] > dist[p.second] + fmat[p.second][i]){
            dist[i]=dist[p.second]+fmat[p.second][i];
            q.push(make_pair(dist[i],i));
          }
        }
      }
    }
    if(dist[l+1] >= INF)
      cout<<"Help!"<<endl;
    else if(dist[l+1] > m)
      cout<<(dist[l+1]*2-m)<<endl;
    else
      cout<<dist[l+1]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1304
N,M = map(int,input().split(" "))
ab = []
for i in range(N):
    a,b = map(int,input().split(" "))
    ab.append((a,b))

ab.sort()
ans = 0
for i in range(N):
    if M <= ab[i][1]:
        ans += (M * ab[i][0])
        break
    else:
        ans += (ab[i][0] * ab[i][1])
        M -= ab[i][1]

print(ans)




Measured memory_bytes: 53276
h,w = map(int,input().split())
s = [0] * h
for i in range(h):
    s[i] = str(input())

def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(w*h):
        for i in range(w*h):
            for j in range(w*h):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d


d = [[float("inf")] * (h * w) for i in range((h * w))]
#d[u][v] : 辺uvのコスト(存在しないときはinf)
for i in range(h):
    for j in range(w):
        if s[i][j] == '.':
            a = i * w + j
            d[a][a] = 0
            for m, n in [(1, 0), (0, 1), (-1, 0), (0, -1)]:
                ss = i + m
                t = j + n
                if 0 <= ss <= h-1 and 0 <= t <= w-1 and s[ss][t] == '.':
                    b = ss * w + t
                    d[a][b] = 1
                    d[b][a] = 1
     #自身のところに行くコストは０
ans = 0
box = warshall_floyd(d)
for i in range(h * w):
    for j in range(h*w):
        if box[j][i] > 1000000:
            box[j][i] = 0
        ans = max(ans,box[j][i])

print(ans)


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

class Program
{
    static void Main(string[] args)
    {
        string[] str = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
        int A = int.Parse(str[0]);
        int B = int.Parse(str[1]);

        //string[] strHeight = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
        //string[] results = new string[N];

        if ( 1 > A || A >= 10 )
        {
            Console.WriteLine("-1");
            return;
        }

        if (1 > B || B >= 10)
        {
            Console.WriteLine("-1");
            return;
        }

        int result = A * B;

        Console.WriteLine(result.ToString());
    }
}

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

long long n, cnt;

long long sumAS(long long x, long long y, long long d) {
	int n = (y - x) / d + 1;
	return (x + y) * n / 2;
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n;
	for (long long i = 1; i <= n; i++) {
		cnt += sumAS(i, n / i * i, i);
// cout << cnt << endl;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

void solve()
{   int n;
cin>>n;
bool ok = false;
int cnt = 0;
while(n--){
    int a,b;
    cin>>a>>b;
    if(a==b){
        cnt++;
    }
    else{
        cnt = 0;
    }
    if(cnt==3){
        ok = true;
    }
}
if(ok){
    cout<<"Yes\n";
}
else cout<<"No\n";
    
   
}
int main(){
    IOS;
    int tt;
    tt = 1;
    // cin>>tt;
    int i = 1;
    while(tt--){
        // cout<<"tc "<<i<<" ";
        solve();
        i++;
    }
    return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>
#include<functional>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265358979

using namespace std;
typedef pair<int, int> P;

int main(void) {
	int n;
	double x[101], y[101];
	double max = 0;
	double m1 = 0, m2 = 0, m3 = 0, mi = 0;

	cin >> n;
	FOR(i, 1, n) {
		cin >> x[i];
	}
	FOR(i, 1, n) {
		cin >> y[i];
	}
	FOR(i, 1, n) {
		m1 += pow(abs(x[i] - y[i]), 1);
		m2 += pow(abs(x[i] - y[i]), 2);
		m3 += pow(abs(x[i] - y[i]), 3);
		if (abs(x[i] - y[i]) > max) {
			max = abs(x[i] - y[i]);
		}
	}
	m2 = sqrt(m2);
	m3 = cbrt(m3);
	mi = max;

	printf("%.10lf\n", m1);
	printf("%.10lf\n", m2);
	printf("%.10lf\n", m3);
	printf("%.10lf\n", mi);
	return 0;
}


Measured memory_bytes: 3396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll mod=1e9+7,INF=mod*mod*3;//M_PI
#define rep(i,N) for(ll i=0; i<(N); i++)
#define rep1(i,N) for(ll i=1; i<(N); i++)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define si(x) x.size()

ll N;
ll ans;
ll A[200005];
ll S[200005];
ll cnt[200005];
map<ll,ll> MP;

int main(){

cin.tie(0);
ios::sync_with_stdio(false);

cin>>N;
rep(i,N) cin>>A[i];
S[0]=A[0];
rep1(i,N) S[i]=S[i-1]+A[i];
rep(i,N){
	cnt[i]=MP[S[i]];
	if(S[i]==0) cnt[i]++;
	MP[S[i]]++;
}
rep(i,N) ans+=cnt[i];
cout<<ans<<endl;

}
	

Measured memory_bytes: 20712
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int x[] = new int[n];
		Arrays.fill(x, -1);

		boolean can = true;
		for (int i = 0; i < m; i++) {
			int s = sc.nextInt();
			int c = sc.nextInt();
			if (x[s - 1] != -1 && x[s - 1] != c) can = false;
			x[s - 1] = c;
		}

		if (n == 1 && (x[0] == 0 || x[0] == -1)) {
			System.out.println(0);
			return;
		}

		if (x[0] == 0 || !can) {
			System.out.println(-1);
		} else if (x[0] == -1) {
			x[0] = 1;
			System.out.println(Arrays.toString(x).replace("-1", "0").replace("[", "").replace("]", "").replace(", ", ""));
		} else {
			System.out.println(Arrays.toString(x).replace("-1", "0").replace("[", "").replace("]", "").replace(", ", ""));
		}

		sc.close();

	}

}

Measured memory_bytes: 35776
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define ull unsigned ll
#define f first
#define s second
#define FOR(i,a,b) for (int i=(a); i<(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for (int i=(n-1); i>=0; --i)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
#define SQ(x) (x)*(x)
#define MN(a,b) a = min(a,(__typeof__(a))(b))
#define MX(a,b) a = max(a,(__typeof__(a))(b))
#define pb push_back
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#ifdef BALBIT
#define IOS()
#define bug(...) fprintf(stderr,"#%d (%s) = ",__LINE__,#__VA_ARGS__),_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define bug(...)
#endif

const int iinf = 1<<29;
const ll inf = 1ll<<60;
const ll mod = 1e9+7;


void GG(){cout<<"-1\n"; exit(0);}

ll mpow(ll a, ll n, ll mo = mod){ // a^n % mod
    ll re=1;
    while (n>0){
        if (n&1) re = re*a %mo;
        a = a*a %mo;
        n>>=1;
    }
    return re;
}

ll inv (ll b, ll mo = mod){
    if (b==1) return b;
    return (mo-mo/b) * inv(mo%b) % mo;
}

const int maxn = 1e5+5;


main(){
    IOS();
    ll n, a, b;  cin>>n>>a>>b;
    if (a%2==b%2) {
        cout<<abs(a-b)/2<<endl;
    }else{
        cout<<min((a-1+b-1+1)/2, (n-a+n-b+1)/2)<<endl;
    }
}


Measured memory_bytes: 256
import java.lang.Math.min
import java.lang.Math.sqrt

fun main(args: Array<String>) {
    val s = readLine()!!.toLong()
    var a: Int = 0
    var b: Int = 0

    val cx = min(sqrt((s - 1).toDouble()).toInt() + 1, 1000000000)
    val d = (cx.toLong() * cx.toLong() - s)
    val cy = cx - d / cx
    val d2 = cx.toLong() * cy - s
    if(d2 != 0L){
        for(i in min(sqrt(d2.toDouble()).toInt(), cx) downTo 1){
            if(d2 % i == 0L){
                a = i
                b = (d2 / i).toInt()
                break
            }
        }
    }
    print("0 ${cy-b} ${cx-a} 0 $cx $cy")
}

Measured memory_bytes: 33776
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main() {
    string s;
    int ans = 0;

    cin >> s;

    for (int i = 0; i < s.length(); i++) {
        if ((i+1) % 2 == 1 && s[i] == 'L') ans = 1;
        if ((i+1) % 2 == 0 && s[i] == 'R') ans = 1;        
    }
    
    (ans == 0) ? (cout << "Yes" << endl) : (cout << "No" << endl);
}



Measured memory_bytes: 256
use strict;
use warnings;

my ($n, $m) = split /\s/, <>;

my @a = ();
foreach (1 .. $m) {
	chomp(my $a = <>);
	push @a, $a;
}

if ($n == 1) {
	print 1, "\n";
	exit;
} elsif ($n == 2) {
	if (@a == 0) {
		print 2, "\n";
	} else {
		print 1, "\n";
	}
	exit;
}
push @a, 999999;

my $a = shift @a;
my $b = -1;
my $p1 = 1;
my $p2 = 1;
if ($a == 1) {
	$p2 = 0;
	$b = $a;
	$a = shift @a;
}

foreach my $i (2 .. $n) {
	if ($a == $i) {
		$p1 = $p2;
		$p2 = 0;
		$b = $a;
		$a = shift @a;
		if ($a - $b == 1) {
			last;
		}
	} else {
		($p1, $p2) = ($p2, $p1 + $p2);
	}
	
	$p2 = $p2 % 1000000007;
}

print $p2, "\n";


Measured memory_bytes: 8576
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

const LL mod = 100000;
LL w, h;
LL memo[11234][5];

LL f(std::pair<LL, LL> p, int c)
{
	LL res = 0;
	if (memo[p.first + p.second*w][c] != -1) { return memo[p.first + p.second*w][c]; }
	if (p.first > w || p.second > h) { return memo[p.first + p.second*w][c] = 0; }
	if (p.first == w && p.second == h) { return memo[p.first + p.second*w][c] = 1; }
	if (c == 0)
	{
		res += f(std::make_pair(p.first + 1, p.second), 3) % mod;
		res += f(std::make_pair(p.first, p.second + 1), 4) % mod;
	}
	if (c != 0 && c >= 3)
	{
		if (c == 4)
		{
			res += f(std::make_pair(p.first + 1, p.second), 1) % mod;
			res += f(std::make_pair(p.first, p.second + 1), 4) % mod;
		}
		if (c == 3)
		{
			res += f(std::make_pair(p.first, p.second + 1), 2) % mod;
			res += f(std::make_pair(p.first + 1, p.second), 3) % mod;
		}
	}
	if (c == 2) { res += f(std::make_pair(p.first, p.second + 1), 4) % mod; }
	if (c == 1) { res += f(std::make_pair(p.first + 1, p.second), 3) % mod; }
	return memo[p.first + p.second*w][c] = res % mod;
}

int main()
{
	while (true)
	{
		memset(memo, -1, sizeof(memo));
		in >> w >> h;
		if (w == 0 && h == 0) { break; }
		out << f(std::make_pair(1, 1), 0) << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3516
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		
		int inputNum = sc.nextInt();
		
		for(int i = 0;i < inputNum;i++) {

		double x1 = sc.nextDouble();
		double y1 = sc.nextDouble();
		double x2 = sc.nextDouble();
		double y2 = sc.nextDouble();
		double x3 = sc.nextDouble();
		double y3 = sc.nextDouble();
		
		calc(x1,y1,x2,y2,x3,y3);
		}

	}

	public static void calc(double x1, double y1, double x2, double y2,
			double x3, double y3) {
		double a1 = (x2 - x1) *2;
		double b1 = (y2 - y1) *2;
		double c1 = x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2;
		double a2 = (x3 - x1) *2;
		double b2 = (y3 - y1) *2;
		double c2 = x1 * x1 - x3 * x3 + y1 * y1 - y3 * y3;
		
		double x = (b1 * c2 -b2 * c1 ) / (a1 * b2 - a2 * b1);
		double y = (c1 * a2 -c2 * a1 ) / (a1 * b2 - a2 * b1);
		
		double a= x - x1;
		double b = y -y1;
		
		double en = Math.sqrt((a * a) + (b * b));
		
		BigDecimal enn = new BigDecimal(en);
		
		BigDecimal solutionX = enn.setScale(3, BigDecimal.ROUND_HALF_UP);
		System.out.printf("%.3f %.3f %.3f\n",x,y,solutionX);
	}

}

Measured memory_bytes: 29068
#include <iostream>
#include <cmath>
#include <map>
#include <utility>
#include <list>
#include <string>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

#define LL long long

int main() {
    int a[4];

    for (int i=0; i < 4; i++){
        a[i] = 0;
    }

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

    for (int i=0; i < 4; i++){
        if (a[i] >= 3){
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;

    return 0;
}


Measured memory_bytes: 256