akhauriyash/Code-Regression huggingface dataset:
#line 2 "header.hpp"

//%snippet.set('header')%
//%snippet.fold()%
#ifndef HEADER_H
#define HEADER_H

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

// varibable settings
const long long INF = 1e18;
template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rrep(i, n) rrepi(i, 0, n)
#define rrepi(i, a, b) for (ll i = (ll)((b)-1); i >= (ll)(a); --i)
#define r_rep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(i, a) for (auto &&i : a)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
#define ub upper_bound
#define lb lower_bound
#define lpos(A, x) (lower_bound(all(A), x) - A.begin())
#define upos(A, x) (upper_bound(all(A), x) - A.begin())
template <class T, class U> inline void chmax(T &a, const U &b) { if ((a) < (b)) (a) = (b); }
template <class T, class U> inline void chmin(T &a, const U &b) { if ((a) > (b)) (a) = (b); }
template <typename X, typename T> auto make_table(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto make_table(X x, Y y, Z z, Zs... zs) { auto cont = make_table(y, z, zs...); return vector<decltype(cont)>(x, cont); }

#define cdiv(a, b) (((a) + (b)-1) / (b))
#define is_in(x, a, b) ((a) <= (x) && (x) < (b))
#define uni(x) sort(all(x)); x.erase(unique(all(x)), x.end())
#define slice(l, r) substr(l, r - l)

typedef long long ll;
typedef long double ld;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;

template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
void check_input() { assert(cin.eof() == 0); int tmp; cin >> tmp; assert(cin.eof() == 1); }

#if defined(PCM) || defined(LOCAL)
#else
#define dump(...) ;
#define dump_1d(...) ;
#define dump_2d(...) ;
#define cerrendl ;
#endif

#endif /* HEADER_H */
//%snippet.end()%
#line 2 "solve.cpp"
template<class T=ll> using vec = vector<T>;
struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast;


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

    ll ans = 0;
    ll con = 0;
    rep(i, n){
        ll x,y;cin>>x>>y;
        if (x == y){
            con++;
            chmax(ans, con);
        }
        else{
            con = 0;
        }
    }
    cout << (ans >= 3 ? "Yes" : "No") << endl;

    return 0; 
}


int main(){/*{{{*/
    solve();
    check_input();
    return 0;
}/*}}}*/


Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
  string s,t;
  cin >> s >> t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  if(s < t){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define RFOR(i,k,n) for (int (i)=(n)-1; (i)>=(k); --(i))
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define debug(x) cerr << #x <<": "<<(x)<<endl
#define debug2(x,y) cerr << #x <<": "<< (x) <<", "<< #y <<": "<< (y) << endl
#define answer(x) cout << (x) <<endl
#define answer_fixed(x, p) cout << fixed << setprecision(p) << (x) << endl
using namespace std;
//static const int INF = 1e9;
//static const double PI = acos(-1.0);
//static const double EPS = 1e-10;
//static const int dx[8] = { 1, 1, 0,-1,-1,-1, 0, 1};
//static const int dy[8] = { 0, 1, 1, 1, 0,-1,-1,-1};
typedef long long int LL;
typedef unsigned long long int ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<double> VD;
typedef vector<VD> VVD;
typedef vector<char> VC;
typedef vector<VC> VVC;
typedef vector<bool> VB;
typedef vector<VB> VVB;
typedef pair<int, int> PII;

int main() {
  VI N(4);
  REP(i, 4) cin >> N[i];
  sort(all(N));
  if(N[0] == 1 && N[1] == 4 && N[2] == 7 && N[3] == 9) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef pair<l_l,ll> lll;
typedef vector<string> vs;
const ll dx[4]={1,-1,0,0};
const ll dy[4]={0,0,1,-1};
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#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)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;cin>>n;
    ll V=0,E=0;
    for(ll i=1;i<=n;i++)V+=i*(n-i+1);
    rep(i,n-1){
        ll u,v;cin>>u>>v;
        if(u>v)swap(u,v);
        E+=u*(n-v+1);
    }
    ll ans=V-E;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3612
class WarshallFloyd:
    def __init__(self,n):
        self.v = n
        self.d = [[1e100]*n for _ in range(n)]
        for i in range(n):
            self.d[i][i] = 0

    def path(self,x,y,c):
        if x == y:
            return False
        self.d[x][y] = c
        self.d[y][x] = c
        return True

    def build(self):
        for k in range(self.v):
            for i in range(self.v):
                for j in range(self.v):
                    self.d[i][j] = min(self.d[i][j], self.d[i][k] + self.d[k][j])
        return self.d

class UnionFind:
    def __init__(self, n):
        '木の初期化をする'
        self.p = [-1] * n
        self.rank = [1]*n
    def find(self, x):
        'x の親を返す'
        if self.p[x] == -1:
            return x
        else:
            self.p[x] = self.find(self.p[x])
            return self.p[x]

    def unite(self, x, y):
        'rankの低い親を高い方のの親にする'
        if not self.same(x,y):
            x = self.find(x)
            y = self.find(y)
            if self.rank[x] > self.rank[y]:
                x,y = y,x
            elif self.rank[x] == self.rank[y]:
                self.rank[y] += 1
            self.p[x] = y
            return True
        else:
            return False

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

n = int(input())
wf = WarshallFloyd(n*2)
uf = UnionFind(n*2)
for i in range(n):
    s = input()
    for j in range(i):
        if s[j] == '1':
            wf.path(i,j,1)
            uf.unite(i,j+n)
            uf.unite(i+n,j)
for i in range(n):
    if uf.same(i,i+n):
        print(-1)
        exit(0)
d = wf.build()
ans = 0
for i in range(n):
    for dist in d[i][:i]:
        ans = max(ans,dist)
print(ans+1)


Measured memory_bytes: 129368
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb push_back
#define ub upper_bound
#define lb upper_bound
#define mp make_pair
#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 ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define ve vector
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
 
typedef long long ll;
const ll INF = LLONG_MAX - 100;
const ll mod = 1e9 + 7;
const int MAX_N = 2e5 + 5;
int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
vector<ll> prime;
 
int fac[MAX_N], inv[MAX_N];
 
template <class T = ll> T in() {T x; cin >> x; return (x);}
void DEBUG(vector<int> a) {for(int i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;}
ll GCD(ll a, ll b) {ll c; while (b != 0) {c = a % b; a = b; b = c;}return a;}
ll LCM(ll a, ll b) {return a * b / GCD(a, b);}
ll POW(ll a, ll b, bool usemod = true) {ll c = 1LL; while (b > 0) {if (b & 1LL) {if(!usemod)c*=a;else c = a * c%mod;}if (!usemod) a*=a;else a = a * a%mod; b >>= 1LL;}return c;}
void _nCr() {fac[0] = 1LL; for (int i = 1LL; i < MAX_N; i++) {fac[i] = fac[i - 1LL] * i%mod;}for (int i = 0; i < MAX_N; i++) {inv[i] = POW(fac[i], mod - 2);}}
ll nCr(ll n, ll r) {return (fac[n] * inv[r] % mod)*inv[n - r] % mod;}
void PRI(ll n) {bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) {a[i] = 1LL;}for (int i = 2; i < n + 1LL; i++) {if (a[i]) {prime.pb(i); ll b = i; while (b <= n) {a[b] = 0; b += i;}}}}
template <typename T> T chmin(T& a, T b) {if(a>b)a=b;return a;}
template <typename T> T chmax(T& a, T b) {if(a<b)a=b;return b;}

class UnionFind {
private:
	vector<int> par;
public:
	vector<set<int>> X;
	vector<set<int>> Y;
	UnionFind(int N) {par = vector<int>(N, -1);}
	int find(int x);
	ll size(int x);
	void unite(int x, int y);
	bool same(int x, int y);
};

int UnionFind::find(int x) {
	if (par[x] < 0) return x;
	else return par[x] = find(par[x]);
}
 
ll UnionFind::size(int x) {
	return -par[find(x)];
}
 
void UnionFind::unite(int x, int y) {
	x = find(x);
	y = find(y);
 	if (x == y) return;
	//大きい方に小さい方をくっ付ける
	if (size(x) < size(y)) swap(x, y);
	par[x] += par[y];
	par[y] = x;
}
 
bool UnionFind::same(int x, int y) {
	x = find(x);
	y = find(y);
	return x == y;
}

bool solve() {
	int n;cin >> n;
	map<int,unordered_set<int>> X;
	map<int,unordered_set<int>> Y;
	UnionFind uf(n);
	int px[n],py[n];
	REP (i,n) {
		//その点は必ず初出
		int x,y;cin>>x>>y;
		px[i] = x, py[i] = y;
		X[x].insert(i);
		Y[y].insert(i);
		if (X[x].size() > 1) {
			for (auto a : X[x]) {
				if (a != i) {uf.unite(a,i);break;}
			}
		}
		if (Y[y].size() > 1) {
			for (auto a : Y[y]) {
				if (a != i) {uf.unite(a,i);break;}
			}
		}
	}
	int ans = 0;
	map<int,pair<set<int>,set<int>>> XY;
	REP (i,n) {
		XY[uf.find(i)].first.insert(px[i]);
		XY[uf.find(i)].second.insert(py[i]);
	}
	for (auto e : XY) {
		ans += (ll)e.second.first.size() * (ll)e.second.second.size();
	}
	ans -= n;
	cout << ans << endl;
}

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

Measured memory_bytes: 33792
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

template <class T>
inline bool chmax(T& a, T b) {
    return a = (a < b) ? b : a;
}
template <class T>
inline bool chmin(T& a, T b) {
    return a = (a > b) ? b : a;
}

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
    INIT;

    string N;
    cin >> N;

    ll L = SZ(N);

    vector<vector<ll>> dp(L + 5, vector<ll>(2, 0));
    dp[0][1] = 1;

    rep(i, L) {
        ll n = N[i] - '0';
        dp[i + 1][0] = min(dp[i][0] + n, dp[i][1] + (10 - n));
        dp[i + 1][1] = min(dp[i][0] + n + 1, dp[i][1] + (10 - n - 1));
    }

    // rep(i, L + 2) { cout << dp[i][1] << " "; }
    // cout << endl;
    // rep(i, L + 2) { cout << dp[i][0] << " "; }
    // cout << endl;

    cout << dp[L][0] << endl;

    return 0;
}


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

void solve()
{
	int n;
	cin >> n;
	ll a[n];
	
	for(int i = 0; i<n; i++) cin >> a[i];
	
	ll ans = 0;
	for(int i = 1; i<n; i++)
	{
		int c = a[i-1]-a[i];
		if(c>0)
		{
			ans += c;
			a[i] += c;
		}
	}
	cout << ans << endl;
}

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


Measured memory_bytes: 5172
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
use proconio::{fastout, input};
use std::cmp::min;
#[fastout]
fn main() {
    input! {
        n: usize,
        a: [isize; n],
    }
    let mut ans = std::isize::MAX;
    let mut an = vec![0; n];
    let mut sum = 0;
    an[0] = a[0];
    sum += a[n - 1];
    for i in 0..n - 1 {
        an[i + 1] = an[i] + a[i + 1];
        sum += a[i];
    }
    for i in 0..n - 1 {
        let diff = (sum - 2 * an[i]).abs();
        ans = min(ans, diff);
    }
    println!("{}", ans);
}


Measured memory_bytes: 6332
# coding: utf-8
# Your code here!
a=list(map(int,input().split()))
s=[a[0],a[1]]
t=[a[2],a[3]]
ans=a[0]*a[2]
for i in s:
    for j in t:
        if ans<i*j:
            ans=i*j
print(ans)

Measured memory_bytes: 61644
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

int main(){
    ll a,b,c;cin>>a>>b>>c;
    vector<ll> v={a,b,c};
    sort(all(v));
    ll cnt = 3;
    if(v[0] == v[1]) cnt--;
    if(v[1] == v[2]) cnt--;
    cout << cnt<< ednl;
}



Measured memory_bytes: 256
n = int(input())
line = list(map(int, input().split()))
min_dist = 10**9
for i in range(max(line)+1):
  sum_dist = 0
  for j in range(n):
    sum_dist += (line[j] - i)**2
  if sum_dist < min_dist:
    min_dist = sum_dist
print(min_dist)

Measured memory_bytes: 9168
def solve(data):
    result = []
    for d in data:
        temp = list(d)
        min_val = int(''.join(sorted(temp)))
        max_val = int(''.join(sorted(temp, reverse=True)))
        result.append(max_val - min_val)
    return result


if __name__ == '__main__':
    # ??????????????\???1
    24241
    num_of_set = int(input().strip())
    data = [input() for _ in range(num_of_set)]

    # ????????¨???????????¨???
    result = solve(data)
    for r in result:
        print(r)

Measured memory_bytes: 7656
#include<bits/stdc++.h>
using namespace std;
int main(){
    short a,b;
    cin>>a>>b;
    if(a==1)a+=13;
    if(b==1)b+=13;
    if(a>b)cout<<"Alice"<<endl;
    if(b>a)cout<<"Bob"<<endl;
    if(a==b)cout<<"Draw"<<endl;
}

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

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,l; string ans="";
	cin >> n >> l;
	vector<string> v(n);
	for(auto &x:v) cin >> x;
	sort(v.begin(), v.end());
	for(int i=0;i<n;i++) ans += v[i];
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
using namespace std;
typedef long long ll;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>

typedef struct point {
    double x, y;
} pt;

double area(vector<pt> p) {
    double val = 0;
    for (int i = 0; i < p.size(); i++) {
        pt p1 = p[i], p2 = p[(i + 1) % p.size()];
        val += (p1.x * p2.y - p1.y * p2.x) / 2;
    }
    return abs(val);
}

int main() {
    int n;
    cin >> n;
    vector<pt> p(n);
    for (int i = 0; i < n; i++) {
        double x, y;
        cin >> x >> y;
        p[i].x = x;
        p[i].y = y;
    }
    cout << fixed << setprecision(1) << area(p) << endl;

}



Measured memory_bytes: 3300
#include<bits/stdc++.h>
using namespace std;
int main()
{  
    int a,b,c,x,ans=0;  //定义不多说 
    cin>>a>>b>>c>>x;
    for(int i=0;i<=a;i++)   //一层一层的去枚举 
    for(int j=0;j<=b;j++)
    for(int r=0;r<=c;r++)
    {
	if(i*500+j*100+r*50==x)
    ans++;
    if(ans>x)
	break; }
    cout<<ans<<"\n";//输出加上换行保险 
	return 0;  //~完美结束 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn = 200005;
int n; ll D;
int main(){
	scanf("%d%lld\n",&n,&D);
	D = D*D; int ans = 0;
	for(int i(1);i <= n;++i){
		ll X,Y;
		scanf("%lld%lld",&X,&Y);
		if(X*X+Y*Y <= D)	++ans;	
	}
	printf("%d\n",ans);
	return 0;
}

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

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

	int cost[n];
	cost[0] = 0;
	cost[1] = abs(h[1] - h[0]);

	for(int i = 2; i < n; i++)
		cost[i] = min(cost[i-1] + abs(h[i] - h[i-1]), cost[i-2] + abs(h[i] - h[i-2]));

	cout << cost[n-1] << "\n";

	return 0;
}


Measured memory_bytes: 1024
MOD = 998244353

fact = [0] * 220000
invfact = [0] * 220000

fact[0] = 1
for i in range(1, 220000):
    fact[i] = fact[i-1] * i % MOD

invfact[220000 - 1] = pow(fact[220000 - 1], MOD-2, MOD)

for i in range(220000 - 2, -1, -1):
    invfact[i] = invfact[i+1] * (i+1) % MOD

def nCk(n, k):
    if k < 0 or n < k:return 0
    return fact[n] * invfact[k] * invfact[n-k] % MOD



n, m, k = map(int, input().split())
ans = 0

for i in range(0, k+1):
    ans += m * pow(m-1, n-i-1, MOD) * nCk(n-1, i) % MOD
    
print(ans % MOD)

Measured memory_bytes: 26204
#include<bits/stdc++.h>
using namespace std;
vector<int> L[2000];int N,M,E,C[2000],x[2000],y[2000];bool U[2000];
bool DFS(int V){
    U[V]=true;
    for(int i=0;i<L[V].size();i++){
        int u=L[V][i],w=C[u];
        if(w<0||!U[w]&&DFS(w)){
            C[V]=u;
            C[u]=V;
            return 1;
        }
    }
    return 0;
}
int SM(){
    int r=0;
    memset(C,-1,8000);
    for(int j=0;j<N+M;j++){
        if(C[j]<0){
            memset(U,0,8000);
            if(DFS(j)){r++;}
        }
    }
    return r;
}
int main(){
    while(1){
        for(int i=0;i<2000;i++){L[i].clear();}
        cin>>N>>M;if(!N){break;}
        for(int i=0;i<N;i++){
            cin>>x[i];
        }
        for(int i=0;i<M;i++){
            cin>>y[i];
        }
        for(int i=0;i<N;i++){
            for(int j=0;j<M;j++){
                if(__gcd(x[i],y[j])>1){
                    L[i].push_back(j+N);
                }
            }
        }
        cout<<SM()<<endl;
    }
    return 0;
}

Measured memory_bytes: 4156
#include<stdio.h>


int main(){
  int w,h,i,x,y;
  char room[101][101];
  do{
    scanf("%d %d",&h,&w);
    if(h==0&&w==0) break;
    for(i=0;i<h;i++) scanf("%s",room+i);
    x=y=0;
    while(1){
      if(room[y][x]=='>'){
	room[y][x]='s';
	x++;
      }else if(room[y][x]=='<'){
	room[y][x]='s';
	x--;
      }else if(room[y][x]=='v'){
	room[y][x]='s';
	y++;
      }else if(room[y][x]=='^'){
	room[y][x]='s';
	y--;
      }else if(room[y][x]=='s'){
	printf("LOOP\n");
	break;
      }else{
	printf("%d %d\n",x,y);
	break;
      }
    }
  }while(1);      
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

char upper(char c){
	return c-0x20;
}

char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//ユークリッドの互除法
//最大公約数
ll gcd(ll x, ll y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

//最小公倍数
ll lcm(ll x, ll y){
	ll g = gcd(x,y);
	return x/g*y;
}

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

int main() {
	ll a,b,c;cin>>a>>b>>c;
	if(a%2==0 || b%2==0 || c%2==0){
		cout << 0 << endl;
	}else{
		ll d = min(a,min(b,c));
		ll e = max(a,max(b,c));
		cout << d*(a+b+c-d-e) << endl;
	}
}



Measured memory_bytes: 256
#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;
	}

	return 0;
}



Measured memory_bytes: 256
## coding: UTF-8
N = int(input())

p = N % 10
if(p == 2 or p ==4 or p == 5 or p == 7 or p == 9):
    print('hon')
elif(p == 0 or p == 1 or p == 6 or p == 8):
    print('pon')
else:
    print('bon')

Measured memory_bytes: 9176
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

public class Program
{

    public static void Main()
    {
        int[] n = Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        int city = n[0];
        int bridge_num = n[1];
        string[] bridge = new string[bridge_num];
        int[] count = new int[city];
        
        for (int i = 0; i < bridge_num; i++) bridge[i] = Console.ReadLine();
        for (int i = 0; i < bridge_num; i++) {
            int[]num = bridge[i].Split(' ').Select(a => int.Parse(a)).ToArray();
            count[num[0] - 1]++;
            count[num[1] - 1]++;
        }
        for (int i = 0; i < city; i++) Console.WriteLine(count[i]);
    }

    static int[] s_to_i(string[] s)
    {
        int[] ret = Array.ConvertAll<string, int>(s, delegate (string value) { return int.Parse(value); });
        return ret;
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <list>
#include <iterator>
#include <vector>

void dump(std::list<int> L)
{
    if (L.empty())
    {
        std::cout << std::endl;
        return;
    }
    auto it = L.begin();
    std::cout << *it;
    it++;
    for (; it != L.end(); it++)
    {
        std::cout << ' ' << *it;
    }
    std::cout << std::endl;
}

int main()
{
    using namespace std;
    int n, q, query, x, t, s;
    std::cin >> n >> q;
    vector<std::list<int>> L(n);
    for (int i = 0; i < q; ++i)
    {
        std::cin >> query;
        switch (query)
        {
        case 0:
            std::cin >> t >> x;
            L[t].insert(L[t].end(), x);
            break;
        case 1:
            std::cin >> t;
            dump(L[t]);
            break;
        case 2:
            std::cin >> s >> t;
            L[t].splice(L[t].end(), L[s]);
            break;
        }
    }
}


Measured memory_bytes: 34364
import java.util.*;
public class Main{
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    String space = sc.nextLine();
    String s = sc.nextLine();
    int k = sc.nextInt();
    char a = s.charAt(k-1); 
    char index[] = new char[n];

    for(int i=0;i<n;i++){
      index[i] = s.charAt(i);
      if(index[i] == a){
        System.out.print(index[i]);
      }else{
        index[i] = '*';
        System.out.print(index[i]);
      }
    }
  }
}   

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long n,k,ans;
  ans=0;
  cin>>n>>k;
  
  ans=(n*(n+1)*(n+2)+(k-1)*k*(2*k-3*n-4))/6+n-k+2;
  ans=ans%1000000007;
  
  cout<<ans<<endl;
}

Measured memory_bytes: 3644
# coding: utf-8

N, M, C = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]

collect = 0

for i in range(N):
    A = [int(i) for i in input().split()]
    if sum(i * j for i, j in zip(A, B)) + C > 0:
        collect += 1

print(collect)

Measured memory_bytes: 3060
#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 push_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);
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 vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const int INF=1001001001;
const int 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){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
vi dep,par;
vvi g;
void dfs0(int i,int p,int d){
    par[i]=p;
    dep[i]=d;
    for(ll x:g[i])if(x!=p)dfs0(x,i,d+1);
}
void init(ll n){
    g=vvi(n);
    dep=vi(n);
    par=vi(n);
    rep(i,n-1){
        ll a,b;cin>>a>>b;a--;b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    dfs0(0,-1,0);
}
vvi dp;
ll dfs(int i,int c){
    if(dp[i][c]!=-1)return dp[i][c];
    dp[i][c]=1;
    for(ll x:g[i])if(x!=par[i]){
        if(c)dp[i][c]*=dfs(x,0);
        else{
            dp[i][c]*=dfs(x,0)+dfs(x,1);
        }
        dp[i][c]%=mod;
    }
    return dp[i][c];
}
int main(){
    ll n;cin>>n;
    init(n);
    dp=vvi(n,vi(2,-1));
    out((dfs(0,1)+dfs(0,0))%mod);
}

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REP1(i,n) for(ll i=1;i<=(ll)(n);i++)

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

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

ll power(ll a, ll n)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2);
    p = (p * p);
    if (n % 2)
        return (p * a);
    else
        return p;
}

int main() {
    ios_base::sync_with_stdio(false);    //for fast I/O operation
    cin.tie(NULL);
	ll n;
    cin >> n;
    string s;
    cin >> s;
    ll r=0;
    ll g=0;
    ll b=0;
    REP(i,n){
        if(s[i] == 'R'){
            r++;
        }
    }
    REP(i,n){
        if(s[i] == 'G'){
            g++;
        }
    }
    REP(i,n){
        if(s[i] == 'B'){
            b++;
        }
    }

    ll sum = r*g*b;

    REP(i,n-2){
        for(int j = i+1; j < n-1; j++ ){
            ll k = 2*j-i;
            if ( k < n){
                if(s[i]!=s[j]&&s[j]!=s[k]&&s[i]!=s[k]){
                sum--;
                }
            }
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;cin >> N;
    list<int> vec,T;
    for(int a = 0;a < N;a++){
        int b;cin >>b;
        vec.push_back(b);
    }
    int M;cin >> M;
    for(int a = 0;a < M;a++){
        int n;cin >> n;
        T.push_back(n);
    }
    bool result = true;
    map<int,int> A,B;
    for(int s:vec){
        auto itr= A.find(s);
        if(itr == A.end()){
            A[s] = 1;
        }else{
            A[s]++;
        }
    }
    for(int s:T){
        auto itr= B.find(s);
        if(itr == B.end()){
            B[s] = 1;
        }else{
            B[s]++;
        }
    }
    for(pair<int,int> s:B){
        auto itr = A.find(s.first);
        if(itr == A.end()){
            result = false;
            break;
        }else{
            //cout<<s.second<<" "<<A[s.first]<<endl;
            if(s.second > A[s.first]){
                result = false;
                break;
            }
        }
    }

    cout<<(result?"YES":"NO")<<endl;
    return 0;
}


Measured memory_bytes: 31488
// *
// *
// *  Created By : Pritish Thakkar 
// *  Hackerrank : ma5terdrag0n
// *  CodeChef : solo_loser
// *  Hackerearth : pritish9
// *------------------------------------
// *  OS : Ubuntu 16.04
// *  Language : CPP14
// *  Editor : Sublime Text 3
// *  C++ compiler : g++
// *
// *
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define inf 1000000007
#define fr first
#define sc second
#define eps 1e-9
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define sni(x) scanf("%d",&x)
#define snl(x) scanf("%lld", &x)
#define snc(x) scanf("%c", &c);
#define rep(n) for(int i = 0 ; i < n ;i ++)
#define repc(i, n) for(int i = 0 ; i < n ; i ++)
#define FOR(i, x, y) for(int i = x ; i < y ; i ++)
#define DEC(i, x, y) for(int i = x ; i >= y ; i --)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b,c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a+n
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

bool isUpper(char c) {return (c >= 'A' && c <= 'Z');}
bool isLower(char c) {return (c >= 'a' && c <= 'z');}
bool iplpha(char c) {return (c >= 'A' && c <= 'Z')||(c >= 'a' && c <= 'z');}
bool isnum(char c){return (c >= '0' and c <= '9');}
bool isalnum(char c) {return (c >= 'A' && c <= 'Z')||(c >= 'a' && c <= 'z')||(c >= '0' && c <= '9');}
char toUpper(char c){return isUpper(c)?c:c-'a'+'A';}
char toLower(char c){return isLower(c)?c:c+'a'-'A';}
bool isvowel(char c){c = toLower(c); return (c == 'a' or c == 'e' or c == 'i' or c == 'i' or c == 'o' or c == 'u');}
template<typename t> t gcd(t a, t b){return ((b == 0) ? a : gcd(b, a%b));} 
template<typename t> t lcm(t a, t b){return (a * (b / gcd(a, b)));}
template <typename T> T modpow(T base, T exp, T modulus) {base %= modulus;T result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
string toLowerCase(string s){rep(s.size()){if(!isLower(s[i])){s[i] = toLower(s[i]);}}return s;}
string toUpperCase(string s){rep(s.size()){s[i] = toUpper(s[i]);}return s;}
template<typename T> void cumulative(T *a, T *b, T n){rep(n){i ? b[i] = b[i-1] + a[i] : b[i] = a[i];}}
bool ispal(string s){ll lo, hi;lo = 0;hi = s.length()-1;while(lo <= hi){if(s[lo] != s[hi]){return 0;}lo++;--hi;}return 1;}
template<class T >string toString(T n){string v = "";while(n){v.pb(n % 10 + '0');n /= 10;}reverse(all(v));return v;}

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

void solve(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    if(a+ b > c + d){
        cout << "Left";
    }  else if(a+b == c + d){
        cout << "Balanced";
    }else{
        cout << "Right";
    }
}

int main(){
    std::ios::sync_with_stdio(0);
    // int start = clock();
    #ifdef ONLINE_JUDGE
    #else
   //   freopen("input.in" , "r" , stdin);
      // freopen("output.txt", "w", stdout);
    #endif
    solve();
    // cout << n;
    // int stop = clock();
    // cout << (stop - start) / 1000.0000<< endl;
}












Measured memory_bytes: 256
//in the name of god
//if you read this code please search about imam hussain
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define pb push_back;
#define X first;
#define Y second;
#define pii pair<int,int>;
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define read freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);

const int maxn=1e5+5;
const int mod=1e9+7;
const int inf=1e9;
const int del=728729;

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}
int dp[maxn][2];
int main(){
	migmig;
	string s;
	cin>>s;
	if(s[0]=='0'){
		dp[0][0]=0;
		dp[0][1]=1;
	}else{
		dp[0][1]=0;
		dp[0][0]=1;
	}
	int n=s.size();
	for(int i=1;i<n;i++){
		if(s[i]=='0'){
			dp[i][0]=dp[i-1][1];
			dp[i][1]=dp[i-1][0]+1;
		}else{
			dp[i][1]=dp[i-1][0];
			dp[i][0]=dp[i-1][1]+1;
		}
	}
	cout<<min(dp[n-1][1] , dp[n-1][0]);
	return 0;
}



Measured memory_bytes: 1232
n, l = map(int, input().split())

app = []
for i in range(n):
    app.append(l+i)

if 0 in app:
    print(sum(app))
elif all(app[i] > 0 for i in range(n)):
    print(sum(app[1:]))
else:
    print(sum(app[:n-1]))

Measured memory_bytes: 3064
#include"bits/stdc++.h"
using namespace std;

int main()
{
  long long n, k, count=0, ans=0;
  cin >> n >> k;
  vector<long long > h(n);
  for(int i=0; i<n; i++){
    cin >> h[i];
  }
  sort(h.begin(), h.end(), greater<long long>());

  if(n<=k){
    ans = 0;
  }
  else{
    for(int i=k; i<n; i++){
      ans += h[i];
    }
  }

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


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <vector>
#include <iostream>
typedef long long ll;
typedef int64_t in;
using namespace std;
#define INF 1000000007


int main() {
	ll n;
    ll r[5];
    ll m = 10000000000000003;

    cin >> n;
    for(int i=0; i<5; i++){
        cin >> r[i];
        m = min(m, r[i]);
    }
    if(n % m != 0) n = n / m + 5;
    else n = n / m + 4;

    cout << n << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<math.h>
using namespace std;



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

	int h[100010];
	int c = 0;
	for (int i = 0; i < n; i++) {
		cin >> h[i];

		if(h[i] >= k)c++;

	}

	 cout << c<< endl;
}

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

using namespace std;

int main()
{
	int N;//特定时间个数 
	int x=0,y=0,t=0,flag=0;
	int tt,tx,ty;
	cin>>N;
	
	int i;
	for(i=0;i<N;i++)
	{
		//依次输入特点坐标并判断该坐标是否能在指定时间到达 
		cin>>tt>>tx>>ty;
		if((abs(tx-x)+abs(ty-y))%2!=abs(tt-t)%2||abs(tx-x)+abs(ty-y)>abs(tt-t))
			//两点需要的步数与实际走的步数奇偶性不同或者实际走的步数比需要走的步数多(超时) 
			flag=1;
		t=tt,x=tx,y=ty;//进行下一个点的判断 
	}
	
	if(!flag)cout<<"Yes";
	else cout<<"No";
	
	return 0;
}

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

int main(int argc, char const *argv[]) {
  int h, w;

  cin >> h >> w;

  while (!(h == 0 && w == 0)) {
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        cout << "#";
      }
      cout << endl;
    }
    cout << endl;
    cin >> h >> w;
  }

  return 0;
}



Measured memory_bytes: 3088
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, a, b = na()
if a == 0:
    print(0)
else:
    print((n//(a+b))*a + min(n%(a+b), a))

Measured memory_bytes: 10820
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,x,smx,emx;
    cin>>x;
    smx=x/100;
    emx=x-smx*100;
    if(emx<=smx*5)
    cout<<"1";
    else 
    cout<<"0";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
using P = pair<int,int>;
using ivec = vector<int>;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }


const int MOD=1000000007;
int INF=100100100100100;
int a[200010];
int ans[200010];
signed main(){
  int n;cin>>n;
  int cnt=0;
  for(int i=1;i<=n;i++){
    cin>>a[i];
  }
  for(int i=n;i>=1;i--){
    int sum=0;
    for(int j=2*i;j<=n;j+=i){
      sum+=ans[j];
    }
    ans[i]=(sum+a[i])%2;
    if(ans[i])cnt++;
  }
  cout<<cnt<<endl;
  for(int i=1;i<=n;i++){
    if(ans[i])cout<<i<<endl;
  }
  return 0;
}


Measured memory_bytes: 6644
#include <bits/stdc++.h>
using namespace std;
int main(){
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	string a,b;
	int c,d;
	string e;
	cin>>a>>b>>c>>d>>e;
	if(e==a){
		cout<<c-1<<" "<<d;
	}
	else{
		cout<<c<<" "<<d-1;
	}

}


Measured memory_bytes: 256
#include <climits>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#define int long long
using namespace std;
int read() { int x; scanf("%lld", &x); return x; }
const int _ = 2e5 + 100;
int A[_], n, q;

struct edges{ int u, v, w; edges(){} edges(int a, int b, int c) { u = a; v = b; w = c; } };
vector<edges> E;


int fa[_];
void         init(int n) { for(int i = 0; i <= n; i++) fa[i] = i; }
int          find(int x)  { return fa[x] == x ? x : fa[x] = find(fa[x]); }
inline bool   ask(int x, int y) { return find(x) == find(y); } 
inline void merge(int x, int y) { x = find(x); y = find(y); fa[x] = y; }



bool CMP(const edges & A, const edges & B) { return A.w < B.w; }
signed main(){
    n = read(), q = read();
    fill(A, A + n, LLONG_MAX - 100);
    for(int i = 1; i <= q; i++){
        int a = read(), b = read(), c = read();
        A[a] = min(A[a], c + 1);
        A[b] = min(A[b], c + 2);
        E.push_back(edges(a, b, c));
    }
    // for(int i = 0; i < n; i++) printf("% 20lld", A[i]); printf("\n");
    for(int i = 0; i < (n << 1) + 3; i++){
        int nxt = A[i % n] + 2;
        A[(i + 1) % n] = min(A[(i + 1) % n], nxt);
    }
    // for(int i = 0; i < n; i++) printf("% 20lld", A[i]); printf("\n");
    for(int i = 0; i < n; i++) {
        E.push_back(edges(i, (i + 1) % n, A[i]));
    }
    sort(E.begin(), E.end(), CMP);
    init(n);
    int ans = 0;
    for(int i = 0; i < E.size(); i++){
        edges &now = E[i];
        if(ask(now.u, now.v)) continue;
        ans += now.w;
        merge(now.u, now.v);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 22064
from bisect import bisect_left, bisect_right, insort_left
dict = {}
li = []
count = 0
q = int(input())
for i in range(q):
    a = input().split()
    t = int(a[1])
    if a[0] == "0":
        if t not in dict:
            dict[t] = 1
            insort_left(li, t)
        else:
            dict[t] += 1
        count += 1
        print(count)
    elif a[0] == "1":
        print(dict[t] if t in dict else 0)
    elif a[0] == "2":
        if t in dict:
            count -= dict[t]
            dict[t] = 0
    else:
        l = bisect_left(li, int(a[1]))
        r = bisect_right(li, int(a[2]))
        lis = []
        for i in range(l, r):
            lis += [li[i]] * dict[li[i]]
        if lis != []:
            print(*lis, sep="\n")


Measured memory_bytes: 18072
//  ROAD TO GREEN
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <queue>
#include <set>
#include <bitset>

#define ll long long
#define uint unsigned int
#define ull unsigned ll
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define do(x) for(int i = 1; i <= x; i++){ solve(); }
#define s(x) x.size()

using namespace std;
const ll MAXN = 2e9+2;
const ll SIZE = 1e5+2;
const ll mod = 1e9+7;
vector<bool> used(SIZE,false);
map<int,int> mapp;



void solve(){
	int n,m;
	cin >> n >> m;
	cout << ((n*3)+m)/2 << endl;
}

int main(){ 
	speedhack()
	// int it; cin >> it;
	int it = 1;
	do(it);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
bool judge(int a){
    if(a>=1 && a<=9) return true;
    return false;
}
int main(){
    int a,b;
    cin >> a >> b;
    if(judge(a)&&judge(b)) cout << a*b << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <stdio.h>
using namespace std;
int fbs(int x)
{
    if(x>=0) return x;
    else return -x;
}
bool judge(int t,int x,int y,int post,int posx,int posy)
{
    int _t=t-post;
    int mt=fbs(x-posx)+fbs(y-posy);
    if(_t==mt) return 1;
    else if(_t>mt)
    {
        if((_t-mt)%2==0) return 1;
        else return 0;
    }
    else return 0;
}
int main()
{
    int n;
    cin>>n;
    int x,y,t;
    int posx=0,posy=0,post=0;
    bool f=0;
    while(n--)
    {
        scanf("%d%d%d",&t,&x,&y);
        if(judge(t,x,y,post,posx,posy))
        {
            post=t,posx=x,posy=y;
        }
        else
        {
            f=1;break;
        }
    }
    if(f) cout<<"No";
    else cout<<"Yes";
    return 0;
}


Measured memory_bytes: 256
def solve(items, n, w):
    f = [[0] * (w + 1) for _ in range(n + 1)]
    for i in range(1, n + 1):
        wi, vi = items[i-1]
        for j in range(w + 1):
            f[i][j] = f[i-1][j]
            if j >= wi:
                f[i][j] = max(f[i][j], f[i-1][j-wi] + vi)
    return f[n][w]


def main():
    inp = lambda: [int(x) for x in input().split()]
    n, w = inp()
    items = [inp() for _ in range(n)]
    print(solve(items, n, w))


if __name__ == '__main__':
    main()


Measured memory_bytes: 119408
n = int(input())
slimes = list(map(int, input().split()))
change = 0
color = 0
cont = 0
for s in slimes:
  if (color != s):
    color = s
    change += cont // 2
    cont = 1
  else:
    cont += 1
change += cont // 2
print(change)

Measured memory_bytes: 3060
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,len;
    string str;
    cin>>str;
    len=str.length();

     if(str[len-4]==str[len-3] && str[len-2]==str[len-1])
     {
         cout<<"Yes"<<endl;
     }
    else
    {
        cout<<"No"<<endl;
    }

 return 0;
}


Measured memory_bytes: 3632
#![allow(unused_macros)]

// cf. [Rustで競技プログラミングの入力をスッキリ記述するマクロ - Qiita](https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8)
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input! {
        x: i64,
    }
    println!("{}", (x / 500) * 1000 + ((x % 500) / 5) * 5);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int *arr=new int[n+1];
  memset(arr,0,sizeof(int)*n+1);
  for(int i=0; i<n-1; ++i)
  {
    int x;
    cin>>x;
    ++arr[x];
  }
  for(int i=1; i<=n; ++i)
  {
    cout<<arr[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 4424
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
	string S; cin >> S;
	long long white = 0;
	vector<long long>pos;
	rep(i, S.size()) {
		if (S.at(i) == 'W') {
			white++;
			pos.push_back(i);
		}
	}
	long long ans = 0;
	rep(i, white) {
		ans += pos.at(i) - i;
	}
	cout << ans << endl;
}


Measured memory_bytes: 2680
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

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

using namespace std;

const int INF = 1 << 30;
const int MOD = 1000000007;
const int MAX = 500000;
const int N = 100;

int A[MAX+1];
int H;

void maxHeapify(int A[], int i) {
	int l = 2*i;
	int r = 2*i+1;
	int largest = i;
	if (l <= H && A[l] > A[largest]) largest = l;
	if (r <= H && A[r] > A[largest]) largest = r;
	if (largest != i) {
		swap(A[i], A[largest]);
		maxHeapify(A, largest);
	}
}

int main() {
	cin >> H;
	rep(i, H) cin >> A[i+1];
	for (int i=H/2; i>=1; i--) maxHeapify(A, i);
	rep(i, H) cout << ' ' << A[i+1];
	cout << endl;
}



Measured memory_bytes: 4948
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())
if(V <= W):
  print('NO')
else:
  D = abs(A-B)
  X = V-W
  if(T*X < D):
    print('NO')
  else:
    print('YES')

Measured memory_bytes: 9180