akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
vvl G;
vl dp(MAX_N);
 
void dfs(ll v) {
    vl a;
    dp[v] = G[v].size();
    for(auto u : G[v]) {
        dfs(u);
        a.pb(dp[u]);
    }
    sort(all(a));
    rep(i, a.size()) {
        chmax(dp[v], a[i] + (ll)a.size() - i);
    }
}
 
int main() {
    ll n;
    cin >> n;
 
    G.resize(n);
    exrep(i, 1, n-1) {
        ll v;
        cin >> v;
        v--;
        G[v].pb(i);
    }

    dfs(0);
    
    out(dp[0]);
    re0;
}

Measured memory_bytes: 14336
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp;
	int n, k;
	cin >> n >> k;
	while (n > 0)
	{
		n/=k;
		ans ++;
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a==5 && b==7 && c==5){
		printf("YES\n");
	}
	else if(a==5 && b==5 && c==7){
		printf("YES\n");
	}
	else if(a==7 && b==5 && c==5){
		printf("YES\n");
	}
	else{
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES // for C++  
#include "bits/stdc++.h"
#define LL long long
#define NUM 1000000007

using namespace std;

int main() {
    char a, b, c;
    cin >> a >> b >> c;
    if (100*a+10*b+c==100*c+10*b+a)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

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

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

void solve() {
    // 8lines
    vector<vector<int>> eight_lines(8);
    // create yoko
    REP(i,3) {
        vector<int> line(3);
        REP(j,3) {
            int A;
            cin >> A;
            line[j] = A;
        }
        eight_lines[i] = line;
    }
    // 4,5,6 create
    REP(i,3) {
        vector<int> line(3);
        REP(j,3) {
            line[j] = eight_lines[j][i];
        }
        eight_lines[3+i] = line;
    }
    // 7,8 create
    vector<int> seven_line(3);
    seven_line[0] = eight_lines[0][0];
    seven_line[1] = eight_lines[1][1];
    seven_line[2] = eight_lines[2][2];

    eight_lines[6] = seven_line;

    vector<int> eight_line(3);
    eight_line[0] = eight_lines[2][0];
    eight_line[1] = eight_lines[1][1];
    eight_line[2] = eight_lines[0][2];

    eight_lines[7] = eight_line;

    // test
    for(const auto &lns: eight_lines) {
        for (const auto &l: lns) {
            cerr << l << " ";
        }
        cerr << endl;
    }

    vector<vector<bool>> is_opened(8,vector<bool>(3,false));

    int N;
    cin >> N;
    REP(i,N) {
        int b;
        cin >> b;
        REP(j,8) {
            REP(k,3) {
                if (eight_lines[j][k] == b) is_opened[j][k] = true;
            }
        }
    }

    REP(i,8) {
        if (all_of(ALL(is_opened[i]),[](bool x){ return x; })) {
            cerr << "opened " << i << endl;
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
    return;

}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  
  sort(S.begin(),S.end());

if(S.at(0)==S.at(1)&&S.at(2)!=S.at(0)&&S.at(2)==S.at(3)){
  cout<<"Yes"<<endl;
}
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string N;
    cin >> N;
    int L;
    L = N.length();
    int f = 0;
    for (int i = 0; i < L; i++){
        f += N[i] - 48;
    }
    int x;
    x = stoi(N);
    if (x%f == 0){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
//omajinai c++ atcoder
#include <iostream> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<cmath>
#include<iomanip>
#include<type_traits>
//#include<numbers>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define itn int
#define yes() printf("Yes\n")
#define no() printf("No\n")
typedef long long ll;
constexpr auto mod = 1000000007;
using namespace std;

int main() {
int a,b,k;
cin>>k>>a>>b;
int f=0;
for(int i=a;i<=b;i++){
    if(i%k==0){
        f=1;
        break;
    }
}

if(f==0){
    cout<<"NG";
}
    else{
       cout<<"OK";
    }
}



Measured memory_bytes: 3636
s = gets.chomp
# a = input.split(" ").map(&:to_i);
t = gets.chomp
sum = 0
flg = false
for i in 0..s.size-1 do
    pos = s.size-1
    w = s.slice(pos)
    s.slice!(pos);
    s = w + s;
    if(s == t) 
        flg = true
        break
    end
end

if flg
    puts "Yes"
else
    puts "No"
end

Measured memory_bytes: 3836
N, M = map(int, input().split())
l_max = 1
r_min = N + 1
for _ in range(M):
    L, R = map(int, input().split())
    if l_max < L:
        l_max = L
    if r_min > R:
        r_min = R
if r_min + 1 > l_max:
    print(r_min - l_max + 1)
else:
    print(0)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream> 
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <ctime>
#include <cassert>
using namespace std;
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define SZ(x) ((int)(x.size()))
#define fi first
#define se second
#define FOR(i,n) for(int (i)=0;(i)<(n);++(i))
#define FORI(i,n) for(int (i)=1;(i)<=(n);++(i))
#define IN(x,y) ((y).find((x))!=(y).end())
#define ALL(t) t.begin(),t.end()
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define REP(i,a,b) for(int (i)=(a);(i)<=(b);++i)
#define REPD(i,a,b) for(int (i)=(a); (i)>=(b);--i)
#define REMAX(a,b) (a)=max((a),(b));
#define REMIN(a,b) (a)=min((a),(b));
#define DBG cerr << "debug here" << endl;
#define DBGV(vari) cerr << #vari<< " = "<< (vari) <<endl;

typedef long long ll;
const int INF = 1e9;

int main()
{
    ios_base::sync_with_stdio(0);
    int t = 1;
    //int t;
    //cin >> t;
    while (t--) {
    map<int, int> mem;
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        auto it = mem.find(a);
        if (it == mem.end()) {
            mem[a] = 1;
        } else {
            it->se++;
        }
    }
    if (mem.size() == 1) {
        int val = mem.begin()->fi;
        int sz = mem.begin()->se;
        if (val == sz-1 || val <= sz/2) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else if (mem.size() > 2) {
        cout << "No" << endl;
    } else {
        auto it1 = mem.begin();
        auto it2 = it1;
        it2++;

        int v1 = it1->fi;
        int s1 = it1->se;

        int v2 = it2->fi;
        int s2 = it2->se;


        if (s2 < 2 || v1 < v2-1) {
            cout << "No" << endl;
        } else if (v2-s1 >= 1 && v2-s1 <= s2/2) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    }
}


Measured memory_bytes: 4992
n,m = gets.split.map(&:to_i)
xs = gets.split.map(&:to_i).sort
ys = (m-1).times.map{|i| xs[i+1] - xs[i]}.sort.reverse
if n >= m
  p 0
else
  p ys[n-1..-1].inject(:+)
end

Measured memory_bytes: 11248
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(void) {
    unsigned int n;
    cin >> n;
    vector<unsigned int> A(3 * n);
    for (auto &a: A) cin >> a;
    sort(A.begin(), A.end(), greater<unsigned int>());

    long long int ans = 0;
    for (int i = 0; i < n; ++i) {
        ans += A[2 * i + 1];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1408
#include <cstdio>
using namespace std;
int main()
{
    int n;
    int one=0, two=0, four=0;
    scanf("%d", &n);
    for(int i=0;i<n;i++){
        int a; scanf("%d", &a);
        if(a%4==0) four++;
        else if(a%2 == 0) two++;
        else one++;
    }
    if(two == 0){
        if(one >four + 1) puts("No");
        else puts("Yes");
    }
    else {
        if(one >four) puts("No");
        else puts("Yes");
    }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)

using namespace std;

int main(void) {

	long long a;
	long long b;

	string str;

	vector<string>vec;
	cin >> a;

	for (int i = 0; i < a; i++) {
		cin >> str;
		sort(str.begin(), str.end());
		vec.push_back(str);
	}

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

	str = vec.front();
	long long count = 0;
	long long ans = 0;
	for (int i = 0; i < a; i++) {
		if (vec[i] == str) {
			count++;
		}
		else {
			if (count > 1) { ans += count * (count - 1) / 2; }
			count = 1;
			str = vec[i];
		}
	}


	if (count > 1) { ans += count * (count - 1) / 2; }

	cout << ans;


}




Measured memory_bytes: 5748
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
#mod = 10**9 + 7
mod = 998244353
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
flag = False
n = I()
D = readInts()
dic = defaultdict(int)
for i in range(n):
    dic[D[i]] += 1
# 後ろから見る
for i in range(n-1,0,-1):
    if dic[i] != 0:
        flag = True
    if flag and dic[i] == 0:
        print(0)
        exit()
if dic[0] != 1: # 距離が0(頂点が1)が絶対に存在しないと駄目
    print(0)
    exit()
if D[0] != 0: # 頂点1が絶対に存在 距離が 0
    print(0)
    exit()
ans = 1
#print(dic)
for i in range(1,n):
    ans *= pow(dic[i-1],dic[i],mod)
    ans %= mod
print(ans)


Measured memory_bytes: 21660
#include<iostream>
#include<vector>

struct union_find{
  // parにsizeの情報も持たせる
  std::vector<int> par;
  union_find(){}
  union_find(int n):par(n,-1){}
  int root(int k){
    if(par[k]<0)return k;
    return par[k] = root(par[k]);
  }
  int size(int k){
    return -par[root(k)];
  }
  void unite(int u,int v){
    u = root(u);
    v = root(v);
    if(u==v)return;
    if(size(u)<size(v))std::swap(u,v);
    par[u] += par[v];
    par[v] = u;
  }
};

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

  union_find uni(n);
  for(int i=0;i<m;++i){
    int a,b;
    std::cin>>a>>b;
    a--;b--;
    uni.unite(a,b);
  }

  int ans = 0;
  for(int v=0;v<n;++v){
    ans = std::max(ans,uni.size(v));
  }
  
  std::cout << ans << std::endl;
}

Measured memory_bytes: 4028
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
const ll INF=1e18+7;
const ll MOD=1e9+7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll a,b,x;
	cin >> a >> b >> x;
	ll ans = b/x - a/x;
	if(a%x==0)ans++;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REPZ(i, z, n) for(decltype(n) i = (z); i < (n); i++)
#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(all(v)))
#define MIN(v) (*min_element(all(v)))
#define INF 1000000000000 //1E+12
#define MOD 1000000007    //合同式の法

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<

typedef long long ll;
typedef unsigned long long ul;
// 1s間で可能なループ回数2E+8回
// intの最大値2147483647~2E+9
// long longの最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<> push_back
// 連想配列map<key,value> insert,
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 setprecision()
// to_string<->stoi
// stoll(longlong)
// stod(double)
// 大文字65-90(-32)
// 小文字97-122(+32)
using namespace std;
vector<ll> A;
void dfs(int d, ll v, int digit) {
    A.push_back(v);
    // 数列の長さが N に達したら打ち切り
    if (d>=9) {
        return;
    }
    for(int i=-1;i<=1;i++){
      ll next_d=digit+i;
      if(next_d<0 or next_d>9) continue;
      dfs(d+1, v*10+next_d, next_d);
    }
}
int main(){
  A.reserve(200000); 
  // faster
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll k; cin >> k;
  for(int i=1;i<=9;i++){
    dfs(0, i, i);
  }
  sort(ALL(A));
  cout << A[k-1] << endl; 
  return 0;
}


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

#define maxPN 1000000
#define PNs  1000100
int countPN = 0, countPNs = 0;
int PrimeNum[maxPN], temp;
bool PN[PNs];

bool IsPrimeNumber(int x);

void PrimeN(){
	int i, j;
	PrimeNum[0] = 2;
	PN[2] = true;PrimeNum[countPN++] = 2;
	PN[3] = true;PrimeNum[countPN++] = 3;
//	PN[5] = true;PrimeNum[countPN++] = 5;
	
	for(i = 6; i  < PNs;i+=6){
		if(IsPrimeNumber(i-1)){
			PrimeNum[countPN++] = i-1;
			PN[i-1] = true;//cout<<i-1<<endl;
		}
		if(IsPrimeNumber(i+1)){
			PrimeNum[countPN++] = i+1;
			PN[i+1] = true;//cout<<i+1<<endl;
		}
		countPNs = i+1;//cout<<i-1<<" "<<PN[i-1]<<endl;
	}
}

bool IsPrimeNumber(int x){
	//if(x == 2 || x == 3) return true;
	//if(x <= 4 || x%2 == 0 || x%3 == 0)   return false;
	//if(x < countPNs) return PN[x];
	for(int i = 0; PrimeNum[i] * PrimeNum[i] <= x; i++)
		if(x%PrimeNum[i] == 0)return false;
	return true;
}


int main(){
//	clock_t start, end;
	int n = true, counta;
//	start = clock();
	PrimeN();
//	cout<<PrimeNum[countPN-1]<<" "<<countPNs<<endl;
//	cout<<clock()-start<<"ms"<<endl;
	
	while(cin>>n){
		counta = 1;
		
		
		//cout<<(IsPrimeNumber(n)?"yes":"no")<<endl;
	//	start = clock();
		//cout<<IsPrimeNumber(n)<<endl;
		for(int i = 1; i <= n; i+=2){
			if(PN[i])counta++;
		//	cout<<i<<" "<<PN[i]<<endl;
		}
		if(n == 1) counta = 0;
		cout<<counta<<endl;
	//	cout<<clock()-start<<"ms"<<endl;
	}
	return 0;
}


Measured memory_bytes: 4300
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
using namespace std;

typedef long long ll;
typedef pair<int, int> p;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9



int main() {
	int N; cin >> N;
	int L[N];
	for (int i = 0; i < N; i++) cin >> L[i];
	sort(L, L + N);
	int sumL = 0;
	for (int i = 0; i < N - 1; i++) sumL += L[i];
	if (sumL > L[N - 1]) cout << "Yes" << endl;
	else cout << "No" << endl;


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, m, r, a, b, c, dst[1008][1008];
bool pass[1008][1008];
 
void warshall_floid(){
	for(ll k = 1; k <= n; k++)
		for(ll i = 1; i <= n; i++)
			for(ll j = 1; j <= n; j++)
				if(pass[i][k] && pass[k][j]){
					if(pass[i][j]){dst[i][j] = min(dst[i][k]+dst[k][j], dst[i][j]);}
					else{pass[i][j] = true; dst[i][j] = dst[i][k]+dst[k][j];}
				}
}
 
int main() {
	cin >> n >> m;
	for(ll i = 1; i <= n; i++){for(ll j = 1; j <= n; j++){pass[i][j] = false;}}
	for(ll i = 1; i <= n; i++){pass[i][i] = true; dst[i][i] = 0;}
	for(ll i = 1; i <= m; i++){
		cin >> a >> b >> c;
		pass[a][b] = true;
		dst[a][b] = -c;
	}
	
	warshall_floid();
	
	//for(ll i = 1; i <= n; i++){for(ll j = 1; j <= n; j++){cout << dst[i][j];}cout << endl;}
	bool roop = false;
	for(ll i = 1; i <= n; i++){if(dst[i][i] < 0 && pass[1][i] && pass[i][n]){roop = true;}}
	if(roop){cout << "inf" << endl;}
	else{cout << -dst[1][n] << endl;}
	
	return 0;
}


Measured memory_bytes: 9088
#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
// ------ Classes ------ //
class Point {
public:
	long double px, py;
	Point() : px(0), py(0) {};
	Point(long double px_, long double py_) : px(px_), py(py_) {};
	friend bool operator==(const Point& p1, const Point& p2) { return p1.px == p2.px && p1.py == p2.py; }
	friend bool operator!=(const Point& p1, const Point& p2) { return p1.px != p2.px || p1.py != p2.py; }
	friend bool operator<(const Point& p1, const Point& p2) { return p1.px < p2.px ? true : (p1.px == p2.px && p1.py < p2.py); }
	friend bool operator>(const Point& p1, const Point& p2) { return p1.px > p2.px ? true : (p1.px == p2.px && p1.py > p2.py); }
	friend bool operator<=(const Point& p1, const Point& p2) { return !(p1 > p2); }
	friend bool operator>=(const Point& p1, const Point& p2) { return !(p1 < p2); }
	friend Point operator+(const Point& p1, const Point& p2) { return Point(p1.px + p2.px, p1.py + p2.py); }
	friend Point operator-(const Point& p1, const Point& p2) { return Point(p1.px - p2.px, p1.py - p2.py); }
	friend Point operator*(const Point& p1, long double d) { return Point(p1.px * d, p1.py + d); }
	friend Point operator*(long double d, const Point& p1) { return p1 * d; }
	friend Point operator/(const Point& p1, long double d) { return Point(p1.px / d, p1.py / d); }
	Point& operator+=(const Point& p1) { px += p1.px; py += p1.py; return *this; }
	Point& operator-=(const Point& p1) { px -= p1.px; py -= p1.py; return *this; }
	Point& operator*=(long double d) { px *= d; py *= d; return *this; }
	Point& operator/=(long double d) { px /= d; py /= d; return *this; }
};
// ------ Functions ------ //
long double norm(const Point& a) { return a.px * a.px + a.py * a.py; }
long double abs(const Point& a) { return sqrtl(norm(a)); }
long double dot(const Point& a, const Point& b) { return a.px * b.px + a.py * b.py; }
long double crs(const Point& a, const Point& b) { return a.px * b.py - a.py * b.px; }
int contain(vector<Point> v, Point p) {
	bool in = false;
	for (int i = 0; i < v.size(); ++i) {
		Point a = v[i] - p, b = v[(i + 1) % v.size()] - p;
		if (a.py > b.py) swap(a, b);
		if (a.py <= 0 && 0 < b.py)
			if (crs(a, b) < 0) in = !in;
		if (crs(a, b) == 0 && dot(a, b) <= 0) return 1;
	}
	return in ? 2 : 0;
}
// ------ Main ------ //
vector<Point> v; Point r;
int main() {
	v.resize(3);
	while (cin >> v[0].px >> v[0].py >> v[1].px >> v[1].py >> v[2].px >> v[2].py >> r.px >> r.py) {
		cout << (contain(v, r) == 2 ? "YES" : "NO") << endl;
	}
	return 0;
}

Measured memory_bytes: 3140
// 5_abc143_e
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
#define MOD (1000000007)
typedef long long ll;

int n, m, l;
vector<vector<ll>> dist;
vector<vector<ll>> g;

void warshall_floyd(){//globalでN * N距離行列 distが存在する前提
    rep(k, n){
        rep(i, n){
            rep(j, n){
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
                dist[j][i] = dist[i][j];
            }
        }
    }
}

void warshall_floyd_g(){//globalでN * N距離行列 distが存在する前提
    rep(k, n){
        rep(i, n){
            rep(j, n){
                g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
                g[j][i] = g[i][j];
            }
        }
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m >> l;
    dist.resize(n, vector<ll> (n));
    g.resize(n, vector<ll> (n));
    rep(i ,n){
        rep(j, n){
            dist[i][j] = INF;
            g[i][j] = INF;
        }
    }

    rep(k, m){
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        dist[a][b] = c;
        dist[b][a] = c;
    }
    warshall_floyd();

    rep(i, n){
        rep(j, n){
            if(dist[i][j] <= l) g[i][j] = 1;
        }
    }

    warshall_floyd_g();

    int q;
    cin >> q;
    rep(i, q){
        int s, t;
        cin >> s >> t;
        s--; t--;

        if(g[s][t] < INF) cout << g[s][t] - 1 << endl;
        else cout << -1 << endl;
    }

    return 0;
}


Measured memory_bytes: 1920
import java.util.*;


	public class Main {
	public static void main( String[] args) {			
					
					Scanner in = new Scanner(System.in);
					long a = in.nextLong();
					long b = in.nextLong();
					long c = in.nextLong();
					long num = c-a-b;
					
					if(num<0) {
						System.out.println("No");
					}
					else {
					 
						if(num*num > 4*a*b) {
							System.out.println("Yes");
						}
						else {
							System.out.println("No");
						}
					}
		
					
			}}

Measured memory_bytes: 22868
def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = [0] * N
    cnt = 0
    for i in range(N):
        if A[i] < 0:
            cnt += 1
        B[i] = abs(A[i])

    if cnt % 2 == 0:
        print(sum(B))
    else:
        print(sum(B) - 2 * min(B))

main()

Measured memory_bytes: 64752
from collections import deque
import sys
import math
sys.setrecursionlimit(10**6)
from collections import defaultdict
from collections import Counter
from collections import deque

n,m=map(int,input().split())
par=[i for i in range(n+1)]

def root(x):
    if x==par[x]:
        return x
    else:
        par[x]=root(par[x])
        return par[x]
def connect(x,y):
    rx=root(x)
    ry=root(y)
    if rx==ry:
        0
    else:
        par[rx]=ry
    return

for i in range(m):
    a,b,z=map(int,input().split())
    connect(a,b)

st=set()
for i in range(1,n+1):
    st.add(root(i))
print(len(st))





Measured memory_bytes: 111648
using System;
using System.Text.RegularExpressions;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using System.Numerics;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });

            var n = Int32.Parse(Console.ReadLine());
            var a = new List<Int64>();
            var dictIdx = new Dictionary<Int64, int>();
            for (int i = 0; i < n; i++)
            {
                a.Add(Int64.Parse(Console.ReadLine()));
                dictIdx.Add(a[i], i);
            }

            var wk = a.OrderBy(v => v).ToList();
            var indices = new Int64[n];
            for (int i = 0; i < wk.Count; i++)
            {
                indices[dictIdx[wk[i]]] = i;
            }

            Int64 ret = 0;
            for (int i = 0; i < a.Count(); i++)
            {
                if (i % 2 == 0 && indices[i] % 2 == 1) ret++;
            }

            Console.WriteLine(ret);
            Console.Out.Flush();
        }
    }
}

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

int main()
{
  string s;
  cin >> s;
  int sum = 0;

  if(s[0] == '1') sum++;
  if(s[1] == '1') sum++;
  if(s[2] == '1') sum++;

  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 256
N,K,*L=map(int,open(0).read().split());L=L[::-1]
I=set();X=0;U=[];D=[]
for d,t in sorted(zip(*[iter(L)]*2))[::-1]:
	if t in I:D+=d,
	elif X<K:I|={t};U+=d,;X+=1
D+=0,;i=K-X
while X and U[-1]+2*X-1<=D[i]:U.pop();X-=1;i+=1
print(sum(U+D[:i])+X**2)

Measured memory_bytes: 25940
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

ll dp[1010][1010];

ll dfs(Graph& g, ll now, ll pre) {
	ll ans = 0;
	for (auto e : g[now]) {
		if (e.to != pre) {
			ans ^= dfs(g, e.to, now) + 1;
		}
	}
	return ans;
}

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

	ll n;
	cin >> n;
	Graph g(n);

	REP(i, n - 1) {
		ll x, y;
		cin >> x >> y;
		x--; y--;
		add_edge(g, x, y, 1, true, 1);
	}

	if (dfs(g,0,-1) == 0) {
		cout << "Bob" << endl;
	}
	else {
		cout << "Alice" << endl;
	}

	return 0;
}


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

const double PI = 3.14159265358979323846;
//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

bool check(vector<int> &bingo, int i, int j, int k) {
    return bingo[i] == -1 && bingo[j] == -1 && bingo[k] == -1;
}

int main() {

    int n, m;
    cin >> n >> m;
    vector<int> number(n, -1);

    if (n == 1 && m == 0) {
        cout << 0 << endl;
        ret();
    }

    rep(i, m) {
        int s, c;
        cin >> s >> c;
        s--;

        if (s == 0 && c == 0 && n != 1) {
            cout << -1 << endl;
            ret();
        }

        if (number[s] == -1) {
            number[s] = c;
        } else if (number[s] == c) {
            continue;
        } else {
            cout << -1 << endl;
            ret();
        }
    }

    if (number[0] == -1) number[0] = 1;
    for (int i = 1; i < n; i++) {
        if (number[i] == -1) number[i] = 0;
    }

    for (int num : number) cout << num;
    cout << endl;

}


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

using namespace std;

int main(void) {
  string s;
  cin >> s;
  bool a = false, b = false, c = false;
  for(int i = 0; i < 3; i++) {
    if(s[i] == 'a') {
      a = true;
    }
    else if(s[i] == 'b') {
      b = true;
    }
    else if(s[i] == 'c') {
      c = true;
    }
  }
  if(a && b && c) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int main()
{
    int a, b, c, min;
    int j = 0;
    int d[100];

    cin >> a >> b >> c;

    if(a > b)
        min = b;
    else
        min = a;
    
    for(int i=min; i > 0; i--)
    {
        if(a%i == 0 && b%i == 0)
        {
            d[j] = i;
            j++;
        }
    }

    cout << d[c-1] << endl;

    return 0;

}

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

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

int h,w;
int a[30][30];

int count(int y,int x){
	int ret = 0;
	for (int i = 0;i < h;i++){
		for (int j = 0;j < w;j++){
			ret += min(abs(y-i),abs(x-j)) * a[i][j];
		}
	}
	return ret;
}

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

	cin >> h >> w;

	for (int i = 0;i < h;i++){
		for (int j = 0;j < w;j++){
			cin >> a[i][j];
		}
	}

	int ans = INT_MAX;
	for (int i = 0;i < h;i++){
		for (int j = 0;j < w;j++){
			ans = min(ans,count(i,j));
		}
	}

	cout << ans << endl;

	return 0;

}



Measured memory_bytes: 3184
#include<bits/stdc++.h>
#define range(i,a,b) for(long long i = (a); i < (b); i++)
#define rep(i,b) for(long long i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;
 
template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}
template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}
template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

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

	vector<vector<bool>> g(n, vector<bool>(n, true));
	rep(i,n){
		g[i][i] = false;
	}

	int l = 0, r = n - 1;
	if(n % 2) r--;

	while(l < r){
		g[l][r] = false;
		l++; r--;
	}

	vector<pair<int, int>> ans;
	rep(i,n){
		range(j,i,n){
			if(g[i][j]){
				ans.emplace_back(i + 1, j + 1);
			}
		}
	}

	cout << ans.size() << endl;
	for(auto p : ans){
		cout << p.first << ' ' << p.second << endl;
	}
}


Measured memory_bytes: 384
import sys

n, W = map(int, input().split())
V = n * 1000
dp = {0: 0}
for line in sys.stdin.readlines():
    w, v = map(int, line.split())
    ndp = dp.copy()
    for i, x in dp.items():
        if i + v in dp:
            ndp[i + v] = min(dp[i + v], x + w)
        else:
            ndp[i + v] = x + w
    dp = ndp

print(max(i for i, x in dp.items() if x <= W))


Measured memory_bytes: 117268
#include<bits/stdc++.h>
using namespace std;
int calc(int x){
	int ans=0;
	while(x){
		ans+=x%10;
		x/=10;
	}
	return ans;
}
int main(){
	int n;
	scanf("%d",&n);
	int res=n;
	for (int i=1;i<n;i++){
		res=min(res,calc(i)+calc(n-i));
	}
	printf("%d\n",res);
}

Measured memory_bytes: 256
//
// Created by hide on 2020/05/15.
//

//参考：http://ehafib.hatenablog.com/entry/2015/12/23/164517
//インクルード(アルファベット順,bits/stdc++.hは使わない派閥)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

using P = pair<int,int>;

int main() {
    int n;
    cin >> n;
    map<int,int> v1,v2;
    REP(i,n/2) {
        int a,b;
        cin >> a >> b;
        v1[a]++; v2[b]++;
    }
    priority_queue<P> q1,q2;
    for(auto i:v1) q1.emplace(i.second,i.first);
    for(auto i:v2) q2.emplace(i.second,i.first);
    vector<P> p1(2,P(n/2,0)),p2(2,P(n/2,0));
    REP(i,2) if(!q1.empty()){ P p = q1.top(); q1.pop(); p1[i] = p;}
    REP(i,2) if(!q2.empty()){ P p = q2.top(); q2.pop(); p2[i] = p;}
    int ans = n;
    REP(i,2)REP(j,2) {
        if(p1[i].second == p2[j].second) continue;
        int res = n;
        if(p1[i].second!=0) res -= p2[j].first;
        if(p2[j].second!=0) res -= p1[i].first;
        ans = min(ans,res);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6136
#include <bits/stdc++.h>
#define rep(i,n) for (ll i=1 ; i<=(n) ; ++i)
typedef long long ll;
using namespace std;
const ll MAX = 2500LL;
typedef pair <ll, ll> P;
const double PI=3.14159265358979323846;

int main(){
  int n,m;
  cin >> n >> m;
  cout << n*(n-1)/2+m*(m-1)/2 << endl;
  return 0;
}


Measured memory_bytes: 256
_,*s=open(0)
b,q='.'*101,range(101)
for i,s in enumerate(s):
  a=[i]
  for x,y,z,c in zip(b,'.'+s,s,q):a+=min(c+(x=='.'>z),a[-1]+(y=='.'>z)),
  b,q=s,a[1:]
print(a[-2])

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

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int s = in.nextInt();
        int total = 0;
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = in.nextInt();
        }
        Arrays.sort(arr);
        for (int i = 0; i < s; i++) {
            total += arr[i];
        }
        System.out.println(total);
    }
}

Measured memory_bytes: 38440
#include <bits/stdc++.h>
using namespace std;
int main(void){
    vector< int > dif,map;
    int n,m,x,j,t=0;
    cin >> n >> m;
    for(int i=0;i<m;i++){
        cin >> x;
        map.push_back(x);
    }
    sort(map.begin(),map.end());
    for(int i=0;i<map.size()-1;i++){
    //    cout << map[i+1]-map[i] << endl;
        dif.push_back(map[i+1]-map[i]);
    }
    //cout << m << endl;
    sort(dif.begin(),dif.end());
    //cout << dif.size()-m << endl;
    j=dif.size()-n+1;
    if(j<0) j=0;
    for(int i=0;i<j;i++){
    //    cout << dif[i] << endl;
        t+=dif[i];
    }
    cout << t << endl;
    return 0;
}

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

int a[3], ans = 1e9;

void solve (int I) {
	int b[4], c = 0;
	for(int i=0;i<3;i++) b[i] = a[i];
	for(int i=0;i<3;i++) {
		if((1<<i)&I) {
			for(int j=0;j<3;j++) b[j]++;
			b[i]--; c++;
		}
	}
	if(!(b[0]%2 == b[1]%2 && b[1]%2 == b[2]%2)) return;
	ans = min(ans, c+(3*max(b[0], max(b[1], b[2]))-b[0]-b[1]-b[2])/2);
}

int main ()
{
	scanf("%d%d%d",&a[0],&a[1],&a[2]);
	for(int i=0;i<8;i++) solve(i);
	printf("%d\n",ans);
}


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

int main(){
  int N;
  cin >> N;
  int max2 = 100;
  int x, y;
  
  for (int i = 0; i < N; i++){
    int counter = -1;
    cin >> x;
    y = 0;
    while (y == 0){
      y = x - (x / 2) * 2;
      counter += 1;
      x /= 2;
    }
    if (counter < max2){
      max2 = counter;
    }
  }
  
  cout << max2 <<endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
const ll mod = 1000000007;
const ll INF = 1e+14;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define _GLIBCXX_DEBUG

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

Measured memory_bytes: 3628
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <assert.h>
     
using namespace std;
     
typedef long long ll;
     
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
     
#define MOD 1000000007


int main(){
  ll n;
  cin>>n;
  vector<ll> v;
  rep(i,0,n){
    ll a;
    cin>>a;
    v.pb(a);
  }
  sort(all(v));
  ll ans = 0;
  rep(i,0,n){
    rep(j,i+1,n){
      rep(k,j+1,n){
        if(v[i]!=v[j]&&v[j]!=v[k]&&v[i]+v[j]>v[k]){
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

#define max 999999 + 1

int main(void){

	vector< bool > table( max, true );
	vector< int > p( max, 0 );
	table[0] = false;
	table[1] = false;

	for( int i = 2; i < max; i++ ) {
		if( table[i] == false ) continue;
		for( int j = 2 * i; j < max; j+=i ) {
			table[j] = false;
		}
	}

	for( int i = 1; i < max; i++ ) {
		p[i] = p[i - 1] + table[i];
	}

	int n;
	
	while( scanf("%d", &n ) != EOF ) {
		cout << p[n] << endl;
	}

    return 0;
}

Measured memory_bytes: 5164
#include <bits/stdc++.h>                                           
 
//#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb; 
typedef long long ll;  
typedef double db;                         
 
 
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const int inf = 1e9, N = 1e4 + 48, mod = 1e9 + 7, maxn = 102;
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;


string s;
int d, dp[N][maxn][2];


void add (int &x, int y) {
	x += y;
	if (x >= mod)
		x -= mod;
}       

int rec (int i, int rest, int ok) {
   	if (i == sz(s)) {
   		if (!rest)
   			return 1;
   		return 0;
   	}
   		
    int &res = dp[i][rest][ok];
	if (res != -1)
		return res;

	res = 0;
	if (ok) {
		forn (x, 0, s[i] - '0' - 1)	
			add(res, rec(i + 1, (rest + x) % d, 0));
		add(res, rec(i + 1, (rest + s[i] - '0') % d, 1));			
	} else {
		forn (x, 0, 9)
			add(res, rec(i + 1, (rest + x) % d, 0));
	}
	return res;
}


main () {
	memset(dp, -1, sizeof(dp));
	cin >> s >> d;
	cout << (rec(0, 0, 1) + mod - 1) % mod << endl;	
} 

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
int main(){
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
       ios_base::sync_with_stdio(false);
       cin.tie(0);
 int n  , cnt =0;   
 cin>>n;
 string s;  
 cin>>s;
 for(int i =0; i< s.size(); i++){  
 	if(s[i] != s[i+1]){
 		cnt++;
 	}
 } 
 cout<<cnt<<endl;  
 return 0;
}

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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main ()
{
    fastio
    lli num1 , num2 ;
    cin >> num1 >> num2 ;
    forr(num2 - (num1 - 1 ) , num2 + num1)
        cout << i << ' ' ;

    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



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

using namespace std;

#define LL           long long
#define ULL          long long unsigned
#define LD           long double
#define FOR(i,n)     for(int i=0;i<n;i++)
#define FLR(i,n)     for(LL i=0;i<n;i++)
#define RFOR(i,n)    for(int i=n-1;i>=0;i--)
#define RFLR(i,n)    for(LL i=n-1;i>=0;i--)
#define rep(i,a,b)   for(int i=a;i<=b;i++)
#define repl(i,a,b)  for(LL i=a;i<=b;i++)
#define fast         ios_base::sync_with_stdio(0);cin.tie(0);
#define all(a)       a.begin(),a.end()
#define ABS(x)       ((x)<0?-(x):(x))
#define NL           "\n"
#define pb           push_back
#define pi           acos(-1.0)
#define prec(n)      fixed << setprecision(n)
int main()
{
    fast;
    int a,b,ans,i,j,k,x;
    cin>>k>>x;
    set<int>s;
    s.insert(x);
    for(i=x+1;i<x+k;i++){
        s.insert(i);
    }
    for(i=x-1;i>x-k;i--){
        s.insert(i);
    }
    auto it=s.begin();
    FOR(i,s.size()){
        cout<<*it<<" ";
        it++;
    }


}



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

class Vtx {
public:
	int id;
	int color=-1;
	vector<int> vtxs;
	void add(int x){
		vtxs.push_back(x);
	}
};

void dfs(int color,int id, Vtx vtxs[]){
	stack<int> stack;
	stack.push(id);
	while(!stack.empty()){
		id=stack.top(); stack.pop();
		if(vtxs[id].color==-1){
			vtxs[id].color=color;
		}
		int size=vtxs[id].vtxs.size();
		for(int i=0;i<size;i++){
			int nId=vtxs[id].vtxs[i];
			if(vtxs[nId].color==-1){
				stack.push(nId);
			}
		}
	}
}

void assignColor(int n, Vtx vtxs[]){
	int color=0;
	for(int i=0;i<n;i++){
		if(vtxs[i].color==-1){
			dfs(color,i,vtxs);
			color++;
		}
	}
}

int main(){
	int n,m;
	cin >> n >> m;
	Vtx vtxs[n];
	for(int i=0;i<m;i++){
		int id1, id2;
		cin >> id1 >> id2;
		vtxs[id1].add(id2);
		vtxs[id2].add(id1);
	}
	
	assignColor(n,vtxs);

	int q;
	cin >> q;
	for(int i=0;i<q;i++){
		int id1, id2;
		cin >> id1 >> id2;
		int c1 = vtxs[id1].color;
		int c2 = vtxs[id2].color;
		if(c1==c2 && c1!=-1){
			cout << "yes" << endl;
		} else {
			cout << "no" << endl;
		}
	}
   return 0;
}



Measured memory_bytes: 9388
def main() -> None:
    n, m = map(int, input().split())
    heights = tuple(map(int, input().split()))

    good = [1] * n
    for _ in range(m):
        a, b = map(int, input().split())
        height_a, height_b = heights[a-1], heights[b-1]
        if height_a == height_b:
            good[a-1], good[b-1] = 0, 0
        elif height_a < height_b:
            good[a-1] = 0
        else:
            good[b-1] = 0
    print(good.count(1))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 20076
#include <stdio.h>
int c(char *p,int d){return ((26+*p-*(p+1))%26==d);}
int a(char *p){return((*p>'`')&&(*p<'{'));}
char *decode (char *inbuf, int s) {
  char *p=inbuf-1;
  while (*++p){
    if(a(p)){
      int t = *p + s;

      if (t > 'z')      *p = (char)(t - 26);
      else if (t < 'a') *p = (char)(t + 26);
      else              *p = (char)t;
    }
  }
  return (inbuf);
}

main(s){
  char b[82];
  while(fgets(b,80,stdin)){
    char *p=b-1;s=0;
    while(*++p){
      if((c(p,12))&&((c(p+1,3)&&!a(p+3))||(c(p+1,7)&&c(p+2,7)&&!a(p+4))||(c(p+1\
,25)&&c(p+2,16)&&!a(p+4)))){s='t'-*p;p+=3;break;}
      else
        for(;a(p);p++);
    }
    printf("%s",decode(b, s));
  }
}

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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  int n;
  vector<LL> a;
  Solver(LL n) : n(n), a(n){};

  void solve() {
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
      if (a[i] % 2) {
        cout << "first" << endl;
        return;
      }
    }
    cout << "second" << endl;
    }
};

}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0;
  std::cin >> n;

  Problem::Solver sol(n);
  sol.solve();
  return 0;
}


Measured memory_bytes: 1152