akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<vector>
#include<iostream>
#include<algorithm>
#include<iterator>
#include<queue>

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

class Graph{
    public:
    typedef struct Edge{
        ll from, to, cost;
        Edge(ll f, ll t, ll c): from(f),to(t),cost(c){}
    } Edge;

    bool isDirected;
    ll INF = 1LL << 62;
    ll v; // 頂点数
    std::vector<Edge> edges;  // 辺のリスト
    std::vector<std::vector<std::pair<ll,ll>>> list;  // 隣接リスト
    //std::vector<std::vector<ll>> matrix; // 隣接行列

    Graph(ll n, bool isDirected=false) : isDirected(isDirected) { init(n); }
    void init(ll n){
        v=n;
        edges.clear();
        list.assign(n, std::vector<std::pair<ll,ll>>());
        //matrix.assign(n, std::vector<ll>(n, INF));
    }
    void connect(ll from, ll to){
        con(from, to, 1);
        if(!isDirected) con(to, from, 1);
    }
    void connect(ll from, ll to, ll cost){
        con(from, to, cost);
        if(!isDirected) con(to, from, cost);
    }
    void con(ll from, ll to, ll cost){
        edges.push_back(Edge(from,to,cost));
        list[from].push_back(std::make_pair(to, cost));
        //matrix[from][to] = cost;
    }
};

class lowlink{
    public:
    Graph G; // 無向グラフ
    std::vector<ll> used, ord, low;
    std::vector<ll> articulation; // 連結点
    std::vector<Graph::Edge> bridge; // 橋

    lowlink(Graph G) : G(G){
        used.assign(G.v, 0);
        ord.assign(G.v, 0);
        low.assign(G.v, 0);
    }

    ll dfs(ll idx, ll k, ll parent){
        used[idx] = true;
        ord[idx] = k++;
        low[idx] = ord[idx];
        bool isArticulation = false;
        int child_num = 0;
        for(auto to : G.list[idx]){
            if(!used[to.first]){
                child_num++;
                k = dfs(to.first, k, idx);
                low[idx] = min(low[idx], low[to.first]);
                isArticulation |= (parent != -1 && low[to.first] >= ord[idx]);
                if(ord[idx] < low[to.first]){
                    if(idx < to.first)bridge.push_back(Graph::Edge(idx, to.first, to.second));
                    else bridge.push_back(Graph::Edge(to.first, idx, to.second));
                }
            }
            else if(to.first != parent){
                low[idx] = std::min(low[idx], ord[to.first]);
            }
        }
        isArticulation |= (parent==-1 && child_num>1);
        if(isArticulation) articulation.push_back(idx);
        return k;
    }
    void build(){
        ll k=0;
        for(ll i=0; i<G.v; i++){
            if(!used[i]) k = dfs(i, k, -1);
        }
        std::sort(articulation.begin(), articulation.end());
        std::sort(bridge.begin(), bridge.end(), [](Graph::Edge a, Graph::Edge b){return (a.from==b.from) ? a.to>b.to : a.from>b.from; });
    }
};

int main(){
    ll v,e,s,t;
    cin >> v >> e;
    Graph G(v);
    REP(i,e){
        cin >> s >> t;
        G.connect(s,t);
    }
    lowlink low(G);
    low.build();
    for(auto i : low.articulation){
        cout << i << endl;
    }
}


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

int main() {
  int N; cin >> N;
  vector<int> b(N);
  for (int i{}; i < N; ++i) {
    cin >> b[i];
  }
  deque<int> a;
  while (b.size()) {
    bool picked{};
    for (int i = b.size()-1; i >= 0; --i) {
      if (b[i] == i+1) {
        a.push_front(i+1);
        b.erase(b.begin() + i);
        picked = true;
        break;
      }
    }
    if (!picked)
      break;
  }

  if (b.size()) {
    cout << -1 << endl;
  } else {
    for (const auto& i : a)
      cout << i << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;
void insertionSort(int A[],int n,int g){
	for(int i=g;i<n;i++){
	int v=A[i];
	int j=i-g;
	while(j>=0&&A[j]>v){
		A[j+g]=A[j];
		j-=g;
		cnt++;
	}
	A[j+g]=v;
    }
}
void shellSort(int A[],int n){
	for(int h=1; ; ){
		if(h>n) break;
		G.push_back(h);
		h=3*h+1;
	}
	for(int i=G.size()-1;i>=0;i--){
		insertionSort(A,n,G[i]);
	}
}
int main()
{
	cin>>n;
	for(int i=0;i<n;i++) scanf("%d",&A[i]);
	cnt =0;
	shellSort(A,n);
	cout<<G.size()<<endl;
	for(int i=G.size()-1;i>=0;i--){
		printf("%d",G[i]);
		if(i) printf(" ");
	}
	printf("\n");
	printf("%d\n",cnt);
	for(int i=0;i<n;i++) printf("%d\n",A[i]);
	return 0;
	}

Measured memory_bytes: 7160
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <utility>
#include <random>
#include <chrono>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

using namespace std;

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PIL = pair<int, LL>;
using PLL = pair<LL, LL>;
// const int mod = 1e9 + 7;
// const int mod = 998244353;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

unordered_map<int, vector<int>> edges;
int indeg[100010], f[100010];
int n, m, x, y;

inline void work() {
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        cin >> x >> y;
        edges[x].push_back(y);
        ++indeg[y];
    }

    queue<int> q;
    for (int i = 1; i <= n; ++i) {
        if (!indeg[i]) {
            q.push(i);
        }
    }

    int ans = 0;
    while (!q.empty()) {
        int u = q.front();
        q.pop();
        if (edges.count(u)) {
            for (int v: edges[u]) {
                ans = max(ans, f[v] = max(f[v], f[u] + 1));
                if (--indeg[v] == 0) {
                    q.push(v);
                }
            }
        }
    }
    cout << ans << "\n";
}

int main() {
    // freopen("input.txt", "r", stdin);
    quickread();
    work();
    return 0;
}

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

typedef long long ll;
const int N = 2e5 + 7;

ll n, m, k;
ll mod = 998244353;
ll fn[200007];

ll ksm(ll a, int n){
    ll base = 1;
    while(n){
        if(n & 1)base = base * a % mod;
        a = a * a % mod;
        n = n / 2;
    }
    return base;
}



int main(){
    
    scanf("%lld %lld %lld", &n, &m, &k);
    ll ans = 0;
    fn[0] = 1;
    ll base = 1;
    ll cnt = 1;
    for(int i = 1; i < n ; i++){
        base = base * (n - i);
        base %= mod;
        cnt = cnt * (i);
        cnt %= mod;
        fn[i] = base * ksm(cnt, mod - 2);
        fn[i] %= mod;
        
    }
    for(int i = 0; i <= k; i++){
        ans += (m % mod * ksm(m - 1, n - i - 1)) % mod * fn[i];
        ans %= mod;
    }    
    cout << ans << endl;

}



Measured memory_bytes: 5208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, N) for (int i = 0; i < (int)N; i++)

int res[50];

int main () {
  int n, m, a, b;
  cin >> n >> m;
  REP(i,n) res[i] = 0;
  REP(i,m) {
    cin >> a >> b;
    res[a-1]++;
    res[b-1]++;
  }
  REP(i,n) cout << res[i] << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define fast_cin() ios_base::sync_with_stdio(false)
using namespace std;
const int N = 1e5+7;

int main(){
    fast_cin();
    int a,b;
    cin >> a >> b;
    cout <<max(max(a+b,a-b),a*b);
    return (0);
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
char s[110][110];
int dp[110][110];
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;++i)
        for(int j=1;j<=m;++j)
            cin>>s[i][j];
    memset(dp,0x3f,sizeof(dp));
    dp[1][1]=(s[1][1]=='#');
    for(int i=1;i<=n;++i)
        for(int j=1;j<=m;++j)
        {
           if(i>1)dp[i][j]=min(dp[i][j],dp[i-1][j]+(s[i][j]=='#'&&s[i-1][j]=='.'));
           if(j>1)dp[i][j]=min(dp[i][j],dp[i][j-1]+(s[i][j]=='#'&&s[i][j-1]=='.')); 
        }
    cout<<dp[n][m];
	return 0;
} 


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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

const int INF = 0x3f3f3f3f;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
//int in() { int x; scanf("%d", &x); return x; }
//ll lin() { ll x; scanf("%lld", &x); return x; }
//void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }

int main(void){
    ll n, k, q;
    cin >> n >> k >> q;

    VL v;
    v.assign(n, k);

    int val = 0, subs = 0;
    FOR(i, q){
        cin >> val;

        v[val-1]++;
        subs++;
        // FOR(j, n){
        //     if(j != val-1){
        //         a[j]--;
        //     }
        // }
    }

    // FOR(i, n){
    //     cout << a[i] << " ";
    // }
    // cout << endl;

    FOR(i, n){
        if(v[i] - subs <= 0){
            cout << "No" << endl;
        } else {
            cout << "Yes" << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 1408
#define _USE_MATH_DEFINES 
#include <iomanip> 
#include <cmath>  
#include<iostream>
#include <fstream>
#include<vector>
#include<algorithm>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl

const string str1 = "dream";
const string str2 = "dreamer";
const string str3 = "erase";
const string str4 = "eraser";

int main() {
	string str;
	rd(str);
	int r_index = str.length();
	while (true)
	{
		if (r_index == 0) {
			wrln("YES");
			break;
		}
		if (r_index >= str1.length() && r_index - str1.length() == str.rfind(str1, r_index - 1)) {
			r_index = r_index - str1.length();
			continue;
		}
		if (r_index >= str2.length() && r_index - str2.length() == str.rfind(str2, r_index - 1)) {
			r_index = r_index - str2.length();
			continue;
		}
		if (r_index >= str3.length() && r_index - str3.length() == str.rfind(str3, r_index - 1)) {
			r_index = r_index - str3.length();
			continue;
		}
		if (r_index >= str4.length() && r_index - str4.length() == str.rfind(str4, r_index - 1)) {
			r_index = r_index - str4.length();
			continue;
		}
		wrln("NO");
		break;
	}
	return 0;
}

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

int main()
{
  int k, a, b;
  cin >> k >> a >> b;
  for(int i = k; i <= b; i += k)
  {
    if(i >= a && i <= b)
    {
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
  
  return 0;
}

Measured memory_bytes: 3576
const main = (input) => {
  const X = BigInt(input.trim())
  let saving = 100n
  let ans = 0

  while (saving < X) {
    saving = saving * 101n / 100n
    ans++
  }

  return console.log(ans)
}

process.env.MYTEST ? test() : main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 30424
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	int n, m;
	cin >> n >>m;
	map<long long, int> ma;
	for (int i = 0; i < n; i++) {
		long long a;
		cin >> a;
		ma[a]++;
	}
	priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> q;
	for (auto e : ma) {
		q.push(make_pair(e.first, e.second));
	}
	for (int i = 0; i < m; i++) {
		int b;
		long long c;
		cin >> b >> c;
		int s = q.size();
		vector<pair<long long, int>> todo;
		long long csum = 0;
		long long porig, porigsum = 0;
		for (int j = 0; j < s; j++) {
			auto p = q.top();
			if (p.first > c)
				break;
			q.pop();

			if (p.second <= b) {
				csum += p.second;
				b -= p.second;
				if (b == 0)
					break;
			} else {
				porig = p.first;
				porigsum = p.second-b;
				csum += b;
				//auto newp0 = make_pair(p.first, p.second-b);
				//auto newp1 = make_pair(c, b);
				break;
			}
		}
		if (csum != 0)
			q.push(make_pair(c, csum));
		if (porigsum != 0)
			q.push(make_pair(porig, porigsum));
	}

	long long ans = 0;
	while (!q.empty()) {
		auto p = q.top();
		ans += p.first * p.second;
		q.pop();
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 11608
#include <bits/stdc++.h>
using namespace std;
const int INF = numeric_limits<int>::max();

template <typename T>
vector<T> dijkstra(int s, vector<vector<pair<int, T>>> &G) {
    using P = pair<T, int>;

    vector<T> d(G.size(), INF);
    d[s] = 0;

    priority_queue<P, vector<P>, greater<P> > que;
    que.push(P(0, s));

    while(!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if(d[v] < p.first) continue;
        for(auto e : G[v]) {
            if(d[e.first] > d[v] + e.second) {
                d[e.first] = d[v] + e.second;
                que.push(P(d[e.first], e.first));
            }
        }
    }

    return d;
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<pair<int, int>>> G(3 * N);
    for(int i=0; i<M; ++i) {
        int u,v;
        cin >> u >> v;
        --u; --v;
        G[u * 3].push_back({v * 3 + 1, 1});
        G[u * 3 + 1].push_back({v * 3 + 2, 1});
        G[u * 3 + 2].push_back({v * 3, 1});
    }
    
    int S, T;
    cin >> S >> T;
    --S; --T;
    auto d = dijkstra<int>(3 * S, G);
    if(d[3 * T] != INF) cout << d[3 * T] / 3 << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 17792
#include<bits/stdc++.h>
#include<stdio.h>
#include<queue>

using namespace std;


int main()
{

    string st;

    int siz,i,cnt=0;


    cin>>st;

    siz= st.size();

    for(i=0; i<siz; i++)
    {

        if(i%2==0 && st[i]!='L')
        {


        }
        else if(i%2!=0 && st[i]!='R')
        {


        }
        else
            cnt++;


    }

    if(cnt>0)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;

    cnt=0;


    return 0;
}


Measured memory_bytes: 256
#![allow(dead_code, unused_variables, unused_macros, unused_imports)]

// 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)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

fn main() {
    input! {
        a: i32,
        b: i32,
        t: i32,
    }

    println!("{}", b * (t / a));
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF = (1 << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    vector< tuple<int,int,int> > v;
    rep(i,0,N){
        int a,b,c;
        cin >> a >> b >> c;
        //if(c == 0)continue;
        v.push_back(make_tuple(a,b,c));
    }
    //N = v.size();
    int maxh = 0,maxx,maxy;
    rep(x,0,101)rep(y,0,101){
        int dif,high;
        rep(i,0,N){
            if(get<2>(v[i]) == 0)continue;
            dif = abs(x - get<0>(v[i])) + abs(y - get<1>(v[i]));
            high = get<2>(v[i]);
            break;
        }
        bool flag = 0;
        rep(i,0,N){
            int dd = abs(x - get<0>(v[i])) + abs(y - get<1>(v[i]));
            int hh = get<2>(v[i]);

            //cout << dd << " " << hh << endl;

            if(hh != max(high + dif - dd, 0)){
                flag = 1;
                break;
            }
        }
        if(flag)continue;
        int h = high + dif;
        if(maxh < h){
            maxh = h;
            maxx = x;
            maxy = y;
            //cout << x << " " << y << " " << h << endl;
        }
    }
    cout << maxx << " " << maxy << " " << maxh << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<tuple>
#include<string>
typedef long long int ll;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define F first
#define S second
using namespace std;
const ll INF = 10000000000000;

int main() {
  int A,B;
  cin>>A>>B;
  cout<<max({A-B,A+B,A*B})<<endl;
}

Measured memory_bytes: 256
T = [int(t) for t in input().split()]
A = [int(t) for t in input().split()]
B = [int(t) for t in input().split()]

d1 = T[0]*(A[0]-B[0])
d2 = d1 + T[1]*(A[1]-B[1])

if d2 == 0:
    ans = "infinity"
elif d1 > 0 and d2 > 0:
    ans = 0
elif d1 < 0 and d2 < 0:
    ans = 0
else:
    d1 = abs(d1)
    d2 = abs(d2)
    ans = d1 // d2 * 2
    if d1%d2 != 0:
        ans += 1 
    
    
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll a, b, q;
    cin >> a >> b >> q;
    vector<ll> s(a), t(b), x(q);
    rep(i, 0, a) cin >> s[i];
    rep(i, 0, b) cin >> t[i];
    rep(i, 0, q) cin >> x[i];
    rep(i, 0, q){
        auto pos = x[i];
        auto sitr = lower_bound(s.begin(), s.end(), pos);
        auto titr = lower_bound(t.begin(), t.end(), pos);
        ll s_l, s_r, t_l, t_r;
        if(sitr == s.begin()) {
            s_r = *sitr - pos;
            s_l = 1e18;
        }else if(sitr == s.end()){
            s_r = 1e18;
            s_l = pos - (*(sitr-1));
        }else{
            s_r = *sitr - pos;
            s_l = pos - *(sitr - 1);
        }
        if(titr == t.begin()) {
            t_r = *titr - pos;
            t_l = 1e18;
        }else if(titr == t.end()){
            t_r = 1e18;
            t_l = pos - (*(titr-1));
        }else{
            t_r = *titr - pos;
            t_l = pos - *(titr-1);
        }
        ll c1 = max(s_l, t_l);
        ll c2 = max(s_r, t_r);
        ll c3 = 2 * min(s_l, t_r) + max(s_l, t_r);
        ll c4 = 2 * min(s_r, t_l) + max(s_r, t_l);
        cout << min({c1, c2, c3, c4}) << endl;
    }
    return 0;
}

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

using namespace std;

typedef pair<double,double> pdd;
const double INF=1e18;

int main()
{
    int n;
    vector<pdd> pos;

    while(cin>>n)
    {
        pos.clear();
        for(int i=0;i<n;i++)
        {
            double x,y;
            cin>>x>>y;
            pos.emplace_back(x,y);
        }

        vector<vector<double> > dp(n+1,vector<double>(n+1));
        vector<vector<double> > dist(n+1,vector<double>(n+1));
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=n;j++)
            {
                dist[i][j]=sqrt((pos[i-1].first-pos[j-1].first)*(pos[i-1].first-pos[j-1].first)+(pos[i-1].second-pos[j-1].second)*(pos[i-1].second-pos[j-1].second));
            }
        }
        dp[1][1]=0;
        for(int i=2;i<=n;i++)
        {
            for(int j=1;j<=i;j++)
            {
                if(i>j+1)
                {
                    dp[i][j]=dist[i-1][i]+dp[i-1][j];
                }else if(i==j)
                {
                    dp[i][j]=dp[i][i-1]+dist[i][i-1];
                }else
                {
                    dp[i][j]=INF;
                    for(int k=1;k<=j;k++)
                    {
                        dp[i][j]=min(dp[i][j],dp[k][j]+dist[k][i]);
                    }
                }
                dp[j][i]=dp[i][j];

            }
        }
        cout<<fixed<<setprecision(7)<<dp[n][n]<<endl;
    }

    return 0;
}



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

// templates -------------------------------------

#define ULL unsigned long long
#define LL long long
#define LLD long long double
#define REP(i, n) for(LL i = 0; i < n; i++)
#define INV_REP(i, n) for(LL i = n; 0 <= i; i--)

LL combination(LL n, LL m)
{
  LL nume = 1;
  REP(i, m) nume *= (n-i);
  LL demo = 1;
  for(int i = 1; i <= m; i++) demo *= i;
  return nume / demo;
}

template<class T>
class UnionFind
{
private:
  vector<T> par;
  vector<T> rank;
  vector<T> size;

public:
  UnionFind(T N) :
    par(N, T()), rank(N, T()), size(N, T())
  {
    REP(i, N)
    {
      par[i] = i;
      rank[i] = 0;
      size[i] = 1;
    }
  }

  inline T root(T x)
  {
    return par[x] == x ? x : par[x] = root(par[x]);
  }

  inline bool same(T x, T y)
  {
    return root(x) == root(y);
  }

  inline T getSize(T x)
  {
    return size[root(x)];
  }

  void unite(T x, T y)
  {
    T r1 = root(x);
    T r2 = root(y);
    if(r1 == r2) return;

    if(rank[r1] < rank[r2]) swap(r1, r2);
    if(rank[r1] == rank[r2]) rank[r1]++;
    par[r2] = r1;
    size[r1] += size[r2];
  }
};

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

int n;
vector<int> h;

void input()
{
  cin >> n;
  h.resize(n);
  REP(i, n)
  {
    cin >> h[i];
  }
}

void solve()
{
  int cnt = 1;
  int maxH = h[0];
  for(int i = 1; i < n; i++)
  {
    maxH = max(h[i], maxH);
    if(maxH == h[i]) cnt++;
  }
  cout << cnt << endl;
}

int main()
{
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
LL a[7];
int main() {
	for (int i = 0; i < 7; i++) cin >> a[i];
	LL ans = (a[0] / 2) * 4 + (a[3] / 2) * 4 + (a[4] / 2) * 4;
	if (a[0] > 0 && a[3] > 0 && a[4] > 0) {
		a[0]--; a[3]--; a[4]--;
		ans = max(ans, 6 + (a[0] / 2) * 4 + (a[3] / 2) * 4 + (a[4] / 2) * 4);
	}
	ans += a[1] * 2;
	cout << ans / 2 << endl;
}

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

int main() {
	
	int edge1, edge2, diag;
	char a, b;
	int Rcount = 0, Hcount = 0;
	while(cin >> edge1 >> a >> edge2 >> b >> diag){
		if(pow(edge1, 2.0) + pow(edge2, 2.0) == pow(diag, 2.0))
			Rcount++;
		
		if(edge1 == edge2)
			Hcount++;
	}
	
	cout << Rcount << endl;
	cout << Hcount << endl;
	return 0;
}

Measured memory_bytes: 1160
use proconio::marker::*;
use proconio::*;
use std::cmp::max;

fn main() {
    input! {
        x: i64,
        k: i64,
        d: i64,
    };
    let x = x.abs();

    let ans;
    if x / d >= k {
        ans = x - d * k;
    } else {
        ans = if (k - x / d) % 2 == 0 {
            x - x / d * d
        } else {
            (x - x / d * d - d).abs()
        };
    }
    println!("{}", ans);
}


Measured memory_bytes: 2180
a1=list(map(int, input().split()))
a2=list(map(int, input().split()))
a3=list(map(int, input().split()))
n=int(input())
b=[0]*n
for i in range(n):
    b[i]=int(input())
for i in range(n):
    for j in range(3):
        if a1[j]==b[i]:
            a1[j]=-1
        if a2[j]==b[i]:
            a2[j]=-1
        if a3[j]==b[i]:
            a3[j]=-1
if sum(a1)==-3 \
    or sum(a2)==-3 \
    or sum(a3)==-3 \
    or (a1[0],a2[0],a3[0])==(-1,-1,-1) \
    or (a1[1],a2[1],a3[1])==(-1,-1,-1) \
    or (a1[2],a2[2],a3[2])==(-1,-1,-1) \
    or (a1[0], a2[1], a3[2]) == (-1, -1, -1) \
    or (a1[2], a2[1], a3[0]) == (-1, -1, -1) :
    print("Yes")

else:
    print("No")
    #print(a1)
    #print(a2)
    #print(a3)

Measured memory_bytes: 38384
import bisect as b

N = int(input())
L = [int(i) for i in input().split()]
L.sort()
ans = 0
for i in range(N):
    for j in range(i + 1, N):
        ans += b.bisect_left(L, L[i] + L[j]) - j - 1
print(ans)


Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <deque>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
#include <string>
#include <iostream>
using namespace std;
int main() {
	int a,b,c;
	cin >> a >> b;
	if (a >= 10 ) {
		
		cout << b << endl;
	}
else {
		c = b+100*(10-a);
		cout << c << endl;
}
	return 0;
}

  

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

int f[500][500];
int dict[500];
int n,m;

void solve(int a,int d){
if (d==3)return;
dict[a]=1;
for(int i=0;i<n;++i){if(f[a][i])solve(i,d+1);}}

int main() {
while (cin >> n >> m, n && m) {
for(int i=0;i<m;++i){int a,b;cin>>a>>b;a--;b--;f[a][b]=f[b][a]=1;}
solve(0,0);
int ans=-1;for(int i=0;i<n;i++)if(dict[i])ans++;
cout<<ans<<endl;
for(int i=0;i<500;i++){
dict[i]=0;
for(int j=0;j<500;++j){
f[i][j]=0;
}}
}
	return 0;
}

Measured memory_bytes: 2136
#include<bits/stdc++.h>
using namespace std;
int n,k;
int x[10000],y[10000],cnt;
int r[105];

int main(){
	cin>>n>>k;
	if(k>(n-1)*(n-2)/2){
		cout<<"-1";
		return 0;
	}
	for(int i=1;i<n;i++){
		x[++cnt]=1,y[cnt]=i+1;
	}
	int h=2;
	for(int i=1;i<=(n-1)*(n-2)/2-k;i++){
		if(r[h]==n-h) h++;
		r[h]++;
		x[++cnt]=h,y[cnt]=h+r[h];
	}
	cout<<cnt<<endl;
	for(int i=1;i<=cnt;i++){
		cout<<x[i]<<" "<<y[i]<<endl;
	}
	
	return 0;	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}


const int M = 20;
double p[M];
double pp[M];

const int N = 100010;
double dp[N];
bool vis[N];

int n;
double dfs(int d){
    if(vis[d]) return dp[d];
    if(d==n) return 0;

    double ret = 0;
    for(int j=1; j<M-1; ++j){
        if(d+j+1<=n) ret += p[j]*(1-pp[j+1])*(j + dfs(d+j+1));
        if(d+j==n) ret += p[j]*(j+ dfs(d+j));
    }

    vis[d] = true;
    return dp[d] = ret;
}

int main(){
    p[1] = 1;
    pp[1] = 1;
    for(int i=2; i<M; ++i){
        pp[i] = pp[i-1]/2;
        p[i] = p[i-1]*pp[i];
    }

    while(cin >>n,n){
        fill(vis,vis+N,false);
        printf("%.10f\n", dfs(0));
    }
    return 0;
}



Measured memory_bytes: 8716
"use strict";

const input = require("fs").readFileSync("/dev/stdin", "utf8");

const inputs = input.split(" ");
const K = Number(inputs[0]);
const X = Number(inputs[1]);

const main = (K, X) => {
    const min = -1000000;
    const max = 1000000;

    // X - K と X + K の値を調べる
    // もし、min max を超えていたらそこでCAP
    // 間にある個数を調べて、出力する
    let right = X + K - 1;
    let left  = X - K + 1;
    if (max < right) {
        right = max;
    }
    if (min > left) {
        left = min;
    }

    let arr = Array.apply(null, Array(Math.abs(right -left) + 1)).map((v, i) => {return left + i});


    return arr.join(" ");
};

console.log(main(K, X));

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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;

ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S=in<string>();
    int r;r=0;

    int l;l=0;
    REP(i,S.size()){
        if(S[i]=='R'){
            if(l>0){
                REP(j,r-1){
                    cout<<0<<" ";
                }
                cout<<r/2+r%2+l/2<<" "<<r/2+l/2+l%2<<" ";
                REP(j,l-1){
                    cout<<0<<" ";
                }
                r=0;
                l=0;
            }
            r++;
        }else{
            l++;
        }
    }
    REP(j,r-1){
        cout<<0<<" ";
    }
    cout<<r/2+r%2+l/2<<" "<<r/2+l/2+l%2;
    REP(j,l-1){
        cout<<" "<<0;
    }
    cout<<endl;
    //cout<<fixed;
    return 0;
}

Measured memory_bytes: 720
#[macro_use]
extern crate proconio;
use std::collections::*;

fn main() {
    input! {
        a: i32
    };

    println!(
        "{}",
        if a % 10 == 7 || (a / 10) % 10 == 7 || a / 100 == 7 {
            "Yes"
        } else {
            "No"
        }
    );
}

/*
* 提出前確認
* - オーバーフローしないようにi64またはu64を使っているか
* - usizeやu64を使っている際は減算で負数になりえないか
* - 剰余算の結果が負になっていないか
**/

use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


Measured memory_bytes: 2176
#include <cstdio>
#include <cstring>
#include <algorithm>

const int N = 1000 + 5;
const int INF = 0x3f3f3f3f;

char s[N], t[N];

int main() {
	std::scanf("%s%s", s, t);
	int lens = std::strlen(s), lent = std::strlen(t);
	int ans = INF;
	for(int i = 0; i <= lens - lent; i++) {
		int cnt = 0;
		for(int j = 0; j < lent; j++)
			if(s[i + j] != t[j]) cnt++;
		ans = std::min(ans, cnt);
	}
	std::printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n=200005;
int n,a[max_n];
queue<int> que[max_n];
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",a+i),que[a[i]].push(i);
    int pre=0;
    for(int i=1;i<=n;i++){
        while(!que[i].empty()&&que[i].front()<=pre)que[i].pop();
        if(que[i].empty()){
            if(i!=1)printf("%d\n",n-(i-1));
            else printf("-1\n");
            return 0;
        }
        else pre=que[i].front(),que[i].pop();
    }
    printf("0\n");
    return 0;
}

Measured memory_bytes: 136192
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

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;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    ll x; cin >> x;
    const ll n = 1000;
    vector<ll> convert(2 * n + 1);
    for (ll num = -n; num <= n; num++) {
        convert[n + num] = num * num * num * num * num;
    }
    for (ll i = -n; i <= n; i++) {
        for (ll j = -n; j <= n; j++) {
            if (convert[n + i] - convert[n + j] == x) {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3640
#include<cstdio>
#include<vector>
#include<algorithm>

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

using namespace std;

typedef	vector<int>	vi;

int main(){
	const int Ne=1299910;
	static bool er[Ne]; er[0]=er[1]=true;
	for(int i=2;i*i<Ne;i++) if(!er[i]) for(int j=i*i;j<Ne;j+=i) er[j]=true;
	vi p; rep(i,Ne) if(!er[i]) p.pb(i);

	for(int n;scanf("%d",&n),n;){
		vi::iterator itl=lower_bound(p.begin(),p.end(),n),itu=upper_bound(p.begin(),p.end(),n);
		printf("%d\n",*itl-*(itu-1));
	}

	return 0;
}

Measured memory_bytes: 0
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

N = ri()
L = rl()

L.sort()

def search(d):
	l, r = 0, len(L)
	while r-l > 1:
		c = (r+l)//2
		if d <= L[c]:
			r = c
		else:
			l = c
	return r

ans = 0
for i in range(N):
	for j in range(i+1, N):
		d = L[i]+L[j]
		k = search(d)
		c = max(k-j-1,0)
		ans += c
print(ans)


Measured memory_bytes: 43868
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N,M;
//i->jにコストcで行けるならば、集合adj[i]は要素(j,c)を含む
vector<vector<pair<LL,LL>>> adj;
//i->jにコストcで行けるならば、集合adj_rev[j]は要素(i,c)を含む
vector<vector<pair<LL,LL>>> adj_rev;

LL ans = 0;

//点startからiに行けるかどうかを、隣接行列adを使ってもとめ、dist[i]として返す
vector<LL> dfs(LL start,vector<vector<pair<LL,LL>>>& ad){
	vector<LL> dist(N+1,0);
	dist[start] = 0;
	queue<LL> q;
	q.push(start);
	while(!q.empty()){
		LL now = q.front();
		q.pop();
		dist[now] = 1;
		for(auto next_node:ad[now]){
			LL next = next_node.first;
			if(dist[next]==0){
				dist[next] = 1;
				q.push(next);
			}
		}
	}
	return dist;
}

void solve(){
	//点1から点iに行けるかどうかを計算
	vector<LL> to = dfs(1,adj);
	//点iから点Nに行けるかどうかを計算
	vector<LL> from = dfs(N,adj_rev);

	//ベルマンフォード法
	//点1から点iまでの距離をdist[i]とおく
	vector<LL> dist(N+1,INF);
	//点1から1への距離は0
	dist[1] = 0;
	bool update = true;
	int step = 0;//何ループかかったか
	while(update){
		update = false;
		for(int now=1;now<=N;now++){
			for(auto next_pair:adj[now]){
				LL next = next_pair.first;
				LL cost = next_pair.second;
				if(to[next] && from[next] && to[now] && from[now]){
					LL new_dist = dist[now] + cost;
					if(dist[next]>new_dist){
						dist[next] = new_dist;
						update = true;
					}
				}
			}
		}
		step++;
		if(step>N){
			ans = -1;
			return;
		}
	}
	ans = -dist[N];
}

int main(){
    cin >> N >> M;
    adj = vector<vector<pair<LL,LL>>>(N+1);
    adj_rev = vector<vector<pair<LL,LL>>>(N+1);
    for(int i=0;i<M;i++){
    	LL a,b,c; cin >> a >> b >> c;
    	adj[a].push_back(pair<LL,LL>(b,-c));
    	adj_rev[b].push_back(pair<LL,LL>(a,-c));
    }

    solve();

    if(ans==-1) cout << "inf" << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3320
#include <bits/stdc++.h>
using namespace std;
int main() {
    string S;
    cin >> S;
    int a=S.size();
    if (S.at(a-1) == 's'){
        cout << S << "es" << endl;
    }// Your code here!
    else {
        cout << S << "s" << endl;
    }
}


Measured memory_bytes: 3592
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"

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

const long long MOD = 1e9+7;

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter) { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

int main() {
    int n;
    ll m;
    cin >> n >> m;
    vector<ll> a(n);
    cin >> a;
    sort(a.begin(), a.end());
    
    auto is_ok = [&](ll x){
        ll cnt = 0;
        rep(i, n) {
            auto l = lower_bound(a.begin(), a.end(), x - a[i]);
            cnt += a.end() - l;
        }
        return m <= cnt;
    };
    
    ll ng = 1000000;
    ll ok = -1;

    while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;

        if (is_ok(mid)) ok = mid;
        else ng = mid;
    }
    
    vector<ll> sum(n + 1);
    rep(i, n) sum[i + 1] = sum[i] + a[i];
    
    ll ans = 0;
    ll cnt = 0;
    rep(i, n) {
        ll u = upper_bound(a.begin(), a.end(), ok - a[i]) - a.begin();
        cnt += n - u;
        ans += sum[n] - sum[u];
        ans += a[i] * (n - u);
    }
    ans += (m - cnt) * ok;
    cout << ans << endl;
}

Measured memory_bytes: 1792
LMWB = 4280

def sumwb(wb, wa)
  if wa > 30
    wb += 160 * (wa-30)
    wa = 30
  elsif wa > 20
    wb += 140 * (wa-20)
    wa = 20
  elsif wa > 10
    wb += 125 * (wa-10)
    wa = 10
  else
    wb += 1150
    wa = 0
  end

  if wa.zero?
    return wb
  else
    sumwb(wb, wa)
  end
end

while wa = gets.to_i
  break if wa == -1
  puts LMWB - sumwb(0, wa)
end

Measured memory_bytes: 6092
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
#include<stack>
using namespace std;
const int maxn = 1000000 + 10;
#define INF 0x7fffffff
#define clr(x,y) memset(x,y,sizeof(x))
typedef long long ll;
#define eps 10e-10
const ll Mod = 1000000007;
char s[100000 + 10];
int n;

int main()
{
    while( ~ scanf("%s",s))
    {
        int len = strlen(s);
        int a = -1,b = -1;
        for(int i = 0; i < len - 1; i ++)
        {
            if(s[i] == s[i + 1] )
            {
                a = i + 1,b = i + 2;break;
            }
            if(s[i] == s[i + 2])
            {
                a = i + 1;b = i + 3;break;
            }
        }
        cout << a << " " << b << endl;
    }

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define MAX_N 10000

int par[MAX_N];
int rank_[MAX_N];

void init(int n) {
	for (int i = 0; i < n; i++) {
		par[i] = i;
		rank_[i] = 0;
	}
}

int find_(int x) {
	if (par[x] == x)
		return x;
	else
		return par[x] = find_(par[x]);
}

void unite(int x, int y) {
	x = find_(x);
	y = find_(y);
	if (x == y) return;

	if (rank_[x] < rank_[y]) {
		par[x] = y;
	} else {
		par[y] = x;
		if (rank_[x] == rank_[y])
			rank_[x]++;
	}
}

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

int main() {
	int n, q;
	cin >> n >> q;
	init(n);
	int com, x, y;
	while (q-->0) {
		cin >> com >> x >> y;
		if (com == 0)
			unite(x, y);
		else
			cout << same(x, y) << endl;
	}
	return 0;
}

Measured memory_bytes: 1240
def main():
    A,V=map(int,input().split())
    B,W=map(int,input().split())
    T=int(input())

    distance=abs(A-B)
    speed_d=V-W

    if (distance==0):
        print("YES")

    if speed_d<=0:
        print("NO")
    else:
        if (distance%speed_d)!=0:
            if ((distance//speed_d)+1)<=T:
                print("YES")
            else:
                print("NO")
        else:
            if ((distance//speed_d))<=T:
                print("YES")
            else:
                print("NO")




if __name__=="__main__":
    main()


Measured memory_bytes: 61920
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int c = sc.nextInt();
    int[] a = new int[m];
    int[] b = new int[m];
    int sum =0;
    int count = 0;
    for(int i=0;i<m;i++){
      b[i] = sc.nextInt();
    }
    for(int j=0;j<n;j++){
      sum = 0;
      for(int k=0;k<m;k++){
        a[k] = sc.nextInt();
        sum += a[k]*b[k];
      }
      if(sum + c > 0){
        count++;
      }
    }
    System.out.println(count);
  }
}
      

Measured memory_bytes: 23764
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

def LI(): return list(map(int, stdin.readline().split()))
def LS(): return list(stdin.readline())

import collections

n = int(input())
s = [input() for i in range(n)]
c = collections.Counter(s)
print(f'AC x {c["AC"]}')
print(f'WA x {c["WA"]}')
print(f'TLE x {c["TLE"]}')
print(f'RE x {c["RE"]}')

Measured memory_bytes: 16544
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

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


	int X;
	cin >> X;

	for (int i = X; i < 1e9; i++) {
		int sq = sqrt(X);
		
		int OK = 1;
		for (int j = 2; j <= sq; j++) {
			if (i % j == 0) {
				OK = 0;
				break;
			}
		}
		if (OK) {
			co(i);
			return 0;
		}
	}



	Would you please return 0;
}

Measured memory_bytes: 256
from __future__ import division, print_function
# import threading
# threading.stack_size(2**27)
# import sys
# sys.setrecursionlimit(10**7)
# sys.stdin = open('inpy.txt', 'r')
# sys.stdout = open('outpy.txt', 'w')
from sys import stdin, stdout
import bisect            #c++ upperbound
import math
import heapq
i_m=9223372036854775807
def inin():
    return int(input())
def stin():
    return input()
def spin():
    return map(int,stin().split())
def lin():                           #takes array as input
    return list(map(int,stin().split()))
def matrix(n):
    #matrix input
    return [list(map(int,input().split()))for i in range(n)]

################################################
def calculate_sum(a, N): #sum of a to N
    # Number of multiples 
    m = N / a 
    # sum of first m natural numbers 
    sum = m * (m + 1) / 2
    # sum of multiples 
    ans = a * sum
    return ans
def series(N):
    return (N*(N+1))//2

def count2Dmatrix(i,list):
    return sum(c.count(i) for c in list)

def modinv(n,p):
    return pow(n,p-2,p)

def GCD(x, y): 
    x=abs(x)
    y=abs(y)
    if(min(x,y)==0):
        return max(x,y)
    while(y): 
        x, y = y, x % y 
    return x
def LCM (x, y):
    return (x * y) // GCD(x, y)
    
def Divisors(n) : 
    l = []  
    for i in range(1, int(math.sqrt(n) + 1)) :
        if (n % i == 0) : 
            if (n // i == i) : 
                l.append(i) 
            else : 
                l.append(i)
                l.append(n//i)
    return l
def isprime(n):
    for i in range(2, int(math.sqrt(n))+1):
        if n%i==0:
            return False
    return True
prime=[]
def SieveOfEratosthenes(n): 
    global prime
    prime = [True for i in range(n+1)] 
    p = 2
    while (p * p <= n): 
        if (prime[p] == True): 
            for i in range(p * p, n+1, p): 
                prime[i] = False
        p += 1
    f=[]
    for p in range(2, n): 
        if prime[p]: 
            f.append(p)
    return f
q=[]       
def dfs(n,d,v,c):
    global q
    v[n]=1
    x=d[n]
    q.append(n)
    j=c
    for i in x:
        if i not in v:
            f=dfs(i,d,v,c+1)
            j=max(j,f)
            # print(f)
    return j
# d = {}
 
"""*******************************************************"""
n = (list(input()))
n = map(int, n)
# print(list(n))
print("Yes") if sum(n)%9==0 else print("No")



Measured memory_bytes: 10780
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();
		//Integer[] array = new Integer[m];
		String s = sc.next();
		List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		List<String> list_big= new ArrayList<String>(Arrays.asList(s.split("")));
		if(!list.get(0).equals("A")) {
			System.out.println("WA");
			System.exit(0);
		}
		int count=0;
		for(int i=2;list.size()-1>i;i++) {
			if(list.get(i).equals("C"))
				count++;
		}
		if(count==1) {
			int two =0;
			for(int i=0;list.size()>i;i++) {
				String x = list_big.get(i).toUpperCase(Locale.getDefault());
				list_big.set(i, x);
			}
			for(int i=0;list.size()>i;i++) {
				if(list.get(i).equals(list_big.get(i)))
					two++;
			}
			if(two==2)
				System.out.println("AC");
			else
				System.out.println("WA");
		}
		else {
			System.out.println("WA");
		}
	}
}

Measured memory_bytes: 21844