akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
using namespace std;
long long A[20][20];
int main(){
	int n,d;int ans=0;
	cin>>n>>d;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=d;j++){
			cin>>A[i][j];
		}
	}
	for(int i=1;i<=n;i++)for(int j=i+1;j<=n;j++){
		long long a=0;
		for(int k=1;k<=d;k++){
			a+=(A[i][k]-A[j][k])*(A[i][k]-A[j][k]);
		}
		long long sq=floor(sqrt(a)+0.5);
		ans+=(sq*sq==a);
	}
	cout<<ans<<endl;
}

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

#define int long long

using namespace std;

#ifdef LOCAL 
#include "/media/brayand/7801-B00D/debugger.h"
#else
template<typename... Args>
void db(Args... args){}
#endif

vector<pair<int,int>> vect;

int f(int mid)
{
	int cont = -1;
	for(int i = 0 ; i < vect.size() ; i++)
	{
		if(vect[i].first <= mid)cont++;
	}
	return cont;
}

int f1(int mid)
{
	int cont = -1;
	for(int i = 0 ; i < vect.size() ; i++)
	{
		if(vect[i].second >= mid)cont++;
	}
	return cont;
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int N;
    cin >> N;

    for(int i = 0 ; i < N ; i++)
    {
    	int a, b;
    	cin >> a >> b;
    	vect.push_back({a,b});
    }

    if(N&1)
    {
    	int a = 1, b = 1000000000;

	    int res1 = 1e18;

	    while(a <= b)
	    {
	    	int mid = (a+b)/2;

	    	if(f(mid) >= N/2)
	    	{
	    		res1 = mid;
	    		b = mid-1;
	    	}
	    	else
	    	{
	    		a = mid+1;
	    	}
	    }

	    a = 1, b = 1000000000;

	    int res2 = -1e18;

	    while(a <= b)
	    {
	    	int mid = (a+b)/2;

	    	if(f1(mid) >= N/2)
	    	{
	    		res2 = mid;
	    		a = mid+1;
	    	}
	    	else
	    	{
	    		b = mid-1;
	    	}
	    }

	   	if(res2 >= res1)
	   	{
	   		cout << res2-res1+1 << '\n';
	   	}
	   	else
	   	{
	   		cout << 0 << '\n';
	   	}
    }
    else
    {
    	int a = 1, b = 1000000000;

	    int res1 = 1e18;

	    while(a <= b)
	    {
	    	int mid = (a+b)/2;

	    	if(f(mid) >= N/2-1)
	    	{
	    		res1 = mid;
	    		b = mid-1;
	    	}
	    	else
	    	{
	    		a = mid+1;
	    	}
	    }

	    a = 1, b = 2000000000;

	    int res2 = -1e18;

	    while(a <= b)
	    {
	    	int mid = (a+b)/2;

	    	if(f1(mid) >= N/2-1)
	    	{
	    		res2 = mid;
	    		a = mid+1;
	    	}
	    	else
	    	{
	    		b = mid-1;
	    	}
	    }

	    db(res1);
	    db(res2);

	   	if(res2 >= res1)
	   	{
	    	int a = res1, b = res2;

		    int rt1 = 1e18;

		    while(a <= b)
		    {
		    	int mid = (a+b)/2;

		    	if(f(mid) >= N/2)
		    	{
		    		rt1 = mid;
		    		b = mid-1;
		    	}
		    	else
		    	{
		    		a = mid+1;
		    	}
		    }

		    a = res1, b = res2;

		    int rt2 = -1e18;

		    while(a <= b)
		    {
		    	int mid = (a+b)/2;

		    	if(f1(mid) >= N/2)
		    	{
		    		rt2 = mid;
		    		a = mid+1;
		    	}
		    	else
		    	{
		    		b = mid-1;
		    	}
		    }

		    cout << (res2+rt2)-(res1+rt1)+1 << '\n';
	   	}
	   	else
	   	{
	   		cout << 0 << '\n';
	   	}
    }

    

    return 0;
}

Measured memory_bytes: 7420
N, M = map(int,input().split())

a = [int(input()) for i in range(M)]

judge = (N+1)*[True]
for i in a:
    judge[i]=False

dp = (N+1)*[0]
dp[0]=1


for i in range(1,N+1):
    if judge[i]:
        dp[i] += dp[i-1]
        if i > 1:
            dp[i] += dp[i-2]

#print(judge)
#print(dp)
print(dp[N]%(10**9+7))

Measured memory_bytes: 503576
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reve(a) reverse(a.begin(), a.end())
typedef long long ll;
const ll MOD = 1e9+7;

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

/*ll lcm(ll a, ll b){
  ll g = gcd(a, b);
  b /= g;
  a *= b;
  return a;
}*/
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(){
  int n, k, l, p, q; cin >> n >> k >> l;
  UnionFind road(n);
  UnionFind rail(n);
  vector<int> A(n);
  vector<tuple<int, int, int>> P(n);
  rep(i, k){
    cin >> p >> q;
    road.unite(p-1, q-1);
  }
  rep(i, l){
    cin >> p >> q;
    rail.unite(p-1, q-1);
    /*if(road.same(p-1, q-1)){
      A[p-1]++; A[q-1]++;
    }*/
  }
  rep(i, n) {get<0>(P[i]) = road.root(i); get<1>(P[i])=rail.root(i); get<2>(P[i])=i;}
  Sort(P);
  int j, m, sum=1, t=0;
  for(j=1; j<n; j++){
    if(get<0>(P[j-1])==get<0>(P[j])&&get<1>(P[j-1])==get<1>(P[j])) sum++;
    else {
      for(m=t; m<j; m++) A[get<2>(P[m])] = sum;
      t = j;
      sum = 1;
    }
  }
  for(m=t; m<n; m++) A[get<2>(P[m])] = sum;
  rep(i, n) cout << A[i] << " ";
  cout << endl;
}

Measured memory_bytes: 5376
s = gets.chomp
n = s.length
if n==1
    puts '0'
    exit
elsif n==2
    puts s[0]==s[1] ? '1' : '0'
    exit
end
m1=[]
m2=[]
n.times do |i|
    m1[i]=i%2==0 ? '0' : '1'
    m2[i]=i%2!=0 ? '0' : '1'
end
d1=0
d2=0
n.times do |i|
    d1+=1 if s[i]!=m1[i]
    d2+=1 if s[i]!=m2[i]
end
puts [d1,d2].min

Measured memory_bytes: 17916
#include <iostream>
#include <string>
#include <array>

int main(){
    int N,K,X,Y;
    std::cin >> N >> K >> X >> Y;
    int sum;
    for(int i = 1; i < N+1; i++){
        if(i <= K){
            sum += X;
        }
        else if(i > K){
            sum += Y;
        }
    }
    std::cout << sum;
    return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cassert>
#include <random>
#include <tuple>

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

int n, m, s, t;

const ll INF = 1e18;
const ll MAX = 1e15;

struct edge{int to; ll cost;};

ll dist_s[100100];
ll dist_t[100100];
vector<edge> g_money[100100];
vector<edge> g_snuke[100100];

void dijkstra_s(int v) {
    priority_queue<P, vector<P>, greater<P> > pq;
    fill(dist_s, dist_s + n, INF);
    dist_s[v] = 0;
    pq.push(P (0, v));

    while (!pq.empty()) {
        P p = pq.top(); pq.pop();
        ll dist = p.first;
        int node = p.second;
        if (dist_s[node] < dist) continue;
        for (auto e: g_money[node]) {
            if (dist_s[e.to] > dist + e.cost) {
                dist_s[e.to] = dist + e.cost;
                pq.push(P(dist + e.cost, e.to));
            }
        }
    }
}

void dijkstra_t(int v) {
    priority_queue<P, vector<P>, greater<P> > pq;
    fill(dist_t, dist_t + n, INF);
    dist_t[v] = 0;
    pq.push(P(0, v));

    while (!pq.empty()) {
        P p = pq.top(); pq.pop();
        ll dist = p.first;
        int node = p.second;
        if (dist_t[node] < dist) continue;
        for (auto e: g_snuke[node]) {
            if (dist_t[e.to] > dist + e.cost) {
                dist_t[e.to] = dist + e.cost;
                pq.push(P(dist + e.cost, e.to));
            }
        }
    }
}

int main() {
    cin >> n >> m >> s >> t;
    s--; t--;
    for (int i = 0; i < m; i++) {
        int u, v;
        ll a, b;
        cin >> u >> v >> a >> b;
        u--; v--;
        g_money[u].push_back({v, a});
        g_money[v].push_back({u, a});
        g_snuke[u].push_back({v, b});
        g_snuke[v].push_back({u, b});
    }

    dijkstra_s(s);
    dijkstra_t(t);

    priority_queue<P, vector<P>, greater<P> > q;
    for (int i = 0; i < n; i++) {
        ll pay = dist_s[i] + dist_t[i];
        q.push(P(pay, i));
    }

    for (int i = 0; i < n; i++) {
        P p = q.top();
        ll pay = p.first;
        int index = p.second;
        while (index < i) {
            q.pop();
            P p = q.top();
            pay = p.first;
            index = p.second;
        }
        cout << MAX - pay << endl;
    }

    return 0;
}


Measured memory_bytes: 19900
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <limits>
#include <map>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<long> v(n);
    string ans="YES";
    for(auto &e:v){
        cin >> e;
    }
    sort(v.begin(),v.end());
    for(int i=1;i<n;i++){
        if(v[i-1]==v[i]){ans="NO";break;}
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
use std::io::*;
use std::str::FromStr;

pub 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")
}

use std::cmp::max;

fn main() {
    let n: usize = read();
    let k: i64 = read();
    let mut ans: i64 = 0;

    for i in (k + 1) as usize..n + 1 {
        // println!("{} % {} = {} ... {}", n, i, n / i, n % i);
        if n / i != 0 {
            ans += max((n / i) as i64 * (i as i64 - k), 0);
        }
        // println!("{}", ans);
        if n % i != 0 {
            if k == 0 {
                ans += max((n % i) as i64 - k, 0);
            } else {
                ans += max((n % i) as i64 - k + 1, 0);
            }
        }
        // println!("{}", ans);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
n=int(input())
b=list(map(int,input().split()))
num=[]
cnt=0
while cnt<n:
    flag=0
    i=len(b)-1
    while 0<=i:
        if b[i]==i+1:
            cnt+=1
            num.append(b[i])
            del b[i]
            flag=1
            break
        i-=1
    if flag==0:
        break
if cnt==n:
    for k in range(cnt):
        print(num[n-1-k])
else:
    print(-1)


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

int main(){
  ll a, b, c, k;  cin >> a >> b >> c >> k;
  if(abs(a-b) > 1e18)  {cout << "Unfair"; return 0;}
  cout << (a - b) * (k%2?-1:1);
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
//#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// ----------------------------------------------------------------------------

int main(){
  string S;
  cin >> S;
  int N;
  N = S.size();
  ll ans=0;
  for(int bit=0; bit<(1<<N-1); bit++){
    ll sum=0;
    ll num=0;
    for(int i=0; i<N; i++){
      num += S[i] - '0';
      if(bit & (1<<i)){
        sum += num;
        num = 0;
      }
      num *= 10;
    }
    sum += num/10;
    ans += sum;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <string>
#define inf 1e9

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

int n;
map<string, int> mp;
int w[45];
vector<string> adj[45];
vector<int> G[45];
vector<P> vec, vec2;
int mask[45];
int dp[1<<20], dp2[1<<20];

void make(int p, int sel, int sum, int b, int n, vector<P> &vec)
{
	if(p >= b+n){
		vec.push_back(make_pair(sel, sum));
		return;
	}
	make(p+1, sel, sum, b, n, vec);
	if(mask[p] & sel) return;
	make(p+1, sel | (1<<(p-b)), sum + w[p], b, n, vec);
}

int main(void)
{
	while(1){
		cin >> n;
		if(n == 0) break;
		
		for(int i = 0; i < n; i++) adj[i].clear();
		mp.clear();
		
		string s; int c;
		for(int i = 0; i < n; i++){
			cin >> s >> w[i] >> c;
			mp[s] = i;
			for(int j = 0; j < c; j++){
				cin >> s;
				adj[i].push_back(s);
			}
		}
		for(int i = 0; i < n; i++){
			G[i].clear();
			for(int j = 0; j < adj[i].size(); j++){
				G[i].push_back(mp[adj[i][j]]);
			}
		}
		
		if(n == 1){
			cout << w[0] << endl;
			continue;
		}
		
		for(int i = 0; i < n/2; i++){
			mask[i] = 0;
			for(int j = 0; j < G[i].size(); j++){
				int v = G[i][j];
				if(v >= 0 && v < n/2) mask[i] |= 1<<v;
			}
		}
		for(int i = n/2; i < n; i++){
			mask[i] = 0;
			for(int j = 0; j < G[i].size(); j++){
				int v = G[i][j];
				if(v >= n/2 && v < n) mask[i] |= 1<<(v-n/2);
			}
		}
		
		vec.clear(), make(0, 0, 0, 0, n/2, vec);
		vec2.clear(), make(n/2, 0, 0, n/2, n-n/2, vec2);
		
		//for(int i = 0; i < vec.size(); i++) cout << vec[i].first << " " << vec[i].second << endl;
		
		int S = 1<<(n/2);
		for(int i = 0; i < S; i++) dp[i] = -inf;
		for(int i = 0; i < vec.size(); i++){
			if((vec[i].first & 1) == 0) continue;
			dp[vec[i].first] = vec[i].second;
		}
		int S2 = 1<<(n-n/2);
		for(int i = 0; i < S2; i++) dp2[i] = -inf;
		for(int i = 0; i < vec2.size(); i++) dp2[vec2[i].first] = vec2[i].second;
		for(int i = 0; i < S2; i++){
			for(int j = 0; j < n-n/2; j++){
				if(i & (1<<j)) dp2[i] = max(dp2[i], dp2[i & ~(1<<j)]);
			}
		}
		
		//for(int i = 0; i < S2; i++) cout << dp2[i] << " "; cout << endl;
		
		int adj2[25];
		for(int i = 0; i < n/2; i++){
			adj2[i] = 0;
			for(int j = 0; j < G[i].size(); j++){
				int v = G[i][j];
				if(v >= n/2 && v < n) adj2[i] |= 1<<(v-n/2);
			}
		}
		
		int ans = 0;
		for(int i = 0; i < S; i++){
			if(dp[i] < 0) continue;
			int mask = 0;
			for(int j = 0; j < n/2; j++) if((i & (1<<j))) mask |= adj2[j];
			ans = max(ans, dp[i] + dp2[(S2-1)-mask]);
		}
		cout << ans << endl;
	}
	
	return 0;
}


Measured memory_bytes: 27668
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#include <set>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define F first
#define S second
#define SHN 1e9
#define lSHN 1e18
using namespace std;
int n;
ll a[200010];
ll res=1e18;
int main()
{
	cin >>n;
	for (int i=0;i<n;i++) cin >>a[i];
	for (int i=1;i<n;i++) a[i]+=a[i-1];
	for (int i=0;i<n-1;i++)
	{
		ll x=a[i];
		ll y=a[n-1]-a[i];
		res=min(res,abs(x-y));
	} 
	cout <<res;
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define NN 1000
int main()
{
    int N, T, A;
    int H[NN];
    double min, tmp;
    int i, mini;
    scanf("%d", &N);
    scanf("%d %d", &T, &A);
    for (i = 0; i < N; i++)
        scanf("%d", &H[i]);
    min = fabs(T - H[0] * 0.006 - A);
    mini = 0;
    for (i = 1; i < N; i++)
    {
        tmp = fabs(T - H[i] * 0.006 - A);
        min = (min < tmp) ? min : tmp;
        if (min == tmp)
            mini = i;
    }
    printf("%d\n", mini + 1);
    return 0;
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
   int n, q;
   cin >> n;
   vector<int> v(n);
   for(int i = 0; i < n; i++){
	   int x;
	   cin >> x;
	   v.push_back(x);  
	}	
  sort(all(v));
  cin >> q;
  int cnt = 0;
  for(int i = 0; i < q; i++){
	  int val;
	  cin >> val;
	  if (binary_search(all(v), val)){
		   cnt++;
		 }  
	}
  cout << cnt << endl;
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}



Measured memory_bytes: 4516
#include <bits/stdc++.h>
using namespace std;
int main() {
	char C[6];
	for(int i = 0; i < 6; i++) {
		cin >> C[i];
	}
	if(C[0] == C[5] && C[1] == C[4] && C[2] == C[3]) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    int v[N];
    rep(i,N){
        cin >> v[i];
    }
    sort(v,v+N);
    double ans=v[0];
    rep(i,N-1){
        ans=(ans+v[i+1])/2;
    }
    cout << ans << endl;
}

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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,x,t;
	cin >> n >> x >> t;
	int count = 1;
	while(count*x < n)
		count++;
	cout << count*t << endl;
}




Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
  string n;
  int i;
  cin>>n;
  for(i=0;i<3;i++){
    if(n.at(i)=='1') cout<<'9';
    else if(n.at(i)=='9') cout<<'1';
  }
  cout<<endl;
}

Measured memory_bytes: 3592
N = gets.split.map(&:to_i)
hoge = gets.split.map(&:to_i)
hoge.sort!
hoge.reverse!
s = 0
Alice = 0
Bobs = 0
while s < N.first
  if(s%2==0)
    Alice += hoge[s]
  else
    Bobs += hoge[s]
  end
  s+=1
end
puts Alice - Bobs

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

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP0(i,n) for (ll i = 0; i <= (ll)(n); ++i)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}

signed main() 
{
  int n,k; cin>>n>>k;
  ll ans=1;
  rep(i,n)
  {
    if(i==0) ans*=k;
    else ans*=(k-1);
  }
  print(ans);

  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits.h>
#include <climits>
#include <map>
#include <unordered_map>
#include <cmath>
#include <set>
#include <iterator>
#include <deque>
#include <assert.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
ull min(ull x, ull y){ if (x<y) return x; return y;}
ull max(ull x, ull y){ if (x<y) return y; return x;}
ll min(ll x, ll y){ if (x<y) return x; return y;}
ll max(ll x, ll y){ if (x<y) return y; return x;}
double min(double x, double y){ if (x<y) return x; return y;}
double max(double x, double y){ if (x<y) return y; return x;}
ull gcd(ull x, ull y){
    if (!x) return y;
    if (!y) return x;
    if (x>y) swap(x,y);
    return gcd(x, y%x);
}
ull inv(ull a, ull c){ // a,c are coprime and a<c
    if (a==1){
        return 1;
    }
    return ((c-(c/a))*inv(c%a,c))%c;
}


ll n, s, a[3005] = {0}, dp[3005][3005] = {0}, ans = 0, m = 998244353;


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

    cin>>n>>s;

    for (int i = 1; i <= n; i++){
        cin>>a[i];
    }

    for (int i = 0; i <= n; i++){
        dp[i][0]++;
    }

    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= s; j++){
            dp[i][j] = dp[i-1][j];
            if (a[i]<=j){
                if (a[i]==j) dp[i][j] = (dp[i][j] + (ll)i)%m;
                else dp[i][j] = (dp[i][j] + dp[i-1][j-a[i]])%m;
            }
        }
        ans = (ans + ((dp[i][s] - dp[i-1][s] + m)*(n-i+1))%m)%m;
    }
    cout<<ans<<"\n";
    return 0;
    
}



Measured memory_bytes: 70784
s = input()
res = 0
rez = 0
if len(s) %2 ==0:
    hs = len(s) // 2
    for i in range(0,hs):
        if s[2*i] == "0":
            res += 1
        else:
            rez += 1
        if s[2*i+1] =="1":
            res += 1
        else:
            rez += 1
else:
    hs = len(s) // 2
    if s[0] == "0":
        res += 1
    else:
        rez += 1
    for i in range(0,hs):
        if s[2*i+2] == "0":
            res += 1
        else:
            rez += 1
        if s[2*i+1] =="1":
            res += 1
        else:
            rez += 1


print(min(res,rez))

Measured memory_bytes: 3316
data = input().split(" ")
n = int(data[0])
z = int(data[1])
w = int(data[2])
a = input().split(" ")
if n != 1:
	b = int(a[n-2])
	c = int(a[n-1])
	ans = abs(w-c)
	if ans <= abs(b-c):
		ans = abs(b-c)
	print(ans)
else:
	print(abs(w-int(a[0])))

Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
#include <vector>

using namespace std;

int main(){
	
	string str;
	
	int a, b;
	
	while(true){
		cin >> str;
		if(str.size() == 1){
			break;
		}
		a = 0;
		b = 0;
		for(int i = 1; i < str.size(); i++){
			if(str[i] == 'A'){
				a++;
			}else if(str[i] == 'B'){
				b++;
			}
		}
		if(a > b){
			a++;
		}else{
			b++;
		}
		printf("%d %d\n", a, b);
	}
	
	return 0;
}

Measured memory_bytes: 1176
#include<iostream>
using namespace std;
int main(){
int t,n,s,f,a,i;
while(cin>>t,t){
cin>>n;
for(a=i=0;i<n;i++){
cin>>s>>f;
a+=f-s;
}
if(a>=t)cout<<"OK"<<endl;
else cout<<t-a<<endl;
}
return 0;
}

Measured memory_bytes: 1160
a,b= list(map(int,input().split()))
if a==0 or b==0:
    print("Zero")
elif a>0 and b>0:
    print("Positive")
elif a<0 and b>0:
    print("Zero")
else:
    c = abs(b-a)
    if c%2 == 0:
        print("Negative")
    else:
        print("Positive")


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

int TYPE_NUM = 3;
vector<vector<int> > happiness;
vector<vector<int> > table;

int choose(int days){

    for(int type = 0; type < TYPE_NUM; type++)
        table[0][type] = 0;

    for(int day = 1; day <= days; day++){
        for(int type = 0; type < TYPE_NUM; type++){
            int max = 0, value;
            for(int pre = 0; pre < TYPE_NUM; pre++){
                if(pre != type){
                    value = table[day-1][pre];
                    if(value > max)
                        max = value;
                }
            }
            table[day][type] = max + happiness[day][type];
        }
    }
   
    int max = 0;
    for(int type = 0; type < TYPE_NUM; type++)
        if(table[days][type] > max)
            max = table[days][type];

    return max; 
}

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

    happiness = vector<vector<int> >(n+1, vector<int>(3));
    table = vector<vector<int>>(n+1, vector<int>(3, 0));
    for(int i = 1; i <= n; i++)
        cin >> happiness[i][0] >> happiness[i][1] >> happiness[i][2];

    int result = choose(n);


    cout << result << "\n";

    return 0;
}


Measured memory_bytes: 11136
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#include <functional>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<ll, ll, ll, ll> tlglglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
typedef unsigned int uint;
typedef unsigned long long ull;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> using VVV = V<VV<T>>;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;
void yesno(bool ok, string yes = "Yes", string no = "No") {
    if (ok) {
        cout << yes << endl;
    } else {
        cout << no << endl;
    }
}

ll bo[20][20];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    string A[N];
    REP(i, 0, N) {
        cin >> A[i];
    }
    ll dot[N];
    fill(dot, dot + N, 0);
    ll two[N], five[N];
    REP(i, 0, N) {
        string s = A[i];
        ll len = s.size();
        REP(j, 0, len) {
            if (s[j] == '.') {
                dot[i] = len - 1 - j;
                s.erase(j, 1);
            }
        }
        ll num = stoll(s);
        ll tmptwo = 0;
        ll tmpfive = 0;
        while (num % 2 == 0) {
            num /= 2;
            tmptwo++;
        }
        while (num % 5 == 0) {
            num /= 5;
            tmpfive++;
        }
        ll t = min(tmptwo - dot[i], 9LL);
        ll f = min(tmpfive - dot[i], 9LL);
        two[i] = t;
        five[i] = f;
        bo[t + 10][f + 10]++;
        // cout << num << " " << two[i] << " " << five[i] << endl;
    }
    ll ans = 0;
    REP(i, 0, N) {
        ll t = two[i];
        ll f = five[i];
        REP(i, -t + 10, 20) {
            REP(j, -f + 10, 20) {
                ans += bo[i][j];
            }
        }
        if (t >= 0 && f >= 0) {
            ans--;
        }
        // cout << ans << endl;
    }
    ans /= 2;
    cout << ans << endl;
}


Measured memory_bytes: 14552
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
using namespace std;
using ll = long long;
int main() {
	int H, W; cin >> H >> W;
	string s[100];
	for (int i = 0; i < H; i++)
		cin >> s[i];

	for (int i = 0; i < H; i++) {
		cout << s[i] << endl;
		cout << s[i] << endl;
	}
	//system("pause");
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int isprime(int n){
    for(int i = 2; i * i <= n; i++) {
        if(n % i == 0) return 0;  //素数でない
    }
    return 1; //素数である
}

int main() {
    int n;
    int ans[2] = {};
    while(1) {
        scanf("%d", &n);
        if(n == 0) break;
        for(int i = n; i >= 5; i--) {
            if(isprime(i) == 1) {
                ans[1] = i;
                if(isprime(i - 2) == 1) {
                    ans[0] = i - 2;
                    break;
                }
            }
        }
        printf("%d %d\n", ans[0], ans[1]);
    }
}

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

using namespace std;

int main(void){
  int k, a, b;
  cin >> k >> a >> b;
  bool can = false;
  for(int i = a; i <= b; ++i){
    if(i % k == 0) can = true;
  }
  if(can){
    cout << "OK" << endl;
  }else{
    cout << "NG" << endl;
  }
  return 0;
}


Measured memory_bytes: 3556
#include<bits/stdc++.h>
const int maxn = 300100;
const int mod = 1e9 + 7;
int trans[][2] = {
	{2, 1}, {4, 3}, {6, 5}, {3, 3}, {7, 1}, {2, 1}, {2, 2}, {4, 4}
};
void reduce(int & x){
	x += x >> 31 & mod;
}
char buf[maxn];
int dp[maxn][8];
int main(){
	std::ios::sync_with_stdio(false),std::cin.tie(0);
	std::cin >> buf; dp[0][0] = 1;
	const int n = strlen(buf);
	for(int i = 0; i < n;++i){
		for(int j = 0;j < 8;++j){
			if(buf[i] != '0') reduce(dp[i + 1][trans[j][1]] += dp[i][j] - mod);
			if(buf[i] != '1') reduce(dp[i + 1][trans[j][0]] += dp[i][j] - mod);
		}
	}
	printf("%d\n",(dp[n][1] + dp[n][3]) % mod);
}


Measured memory_bytes: 9984
t=Hash.new 0
$<.map{a,b=_1.split.map &:to_r;b&&t[a*b==0?1[a]-1[b]:a/b]+=1}
M=10**9+7
z=1
t.map{w=t[_1==0?0:-1/_1]
w>0&&_1<=0||z=z*(2.pow(_2,M)+2.pow(w,M)-1)%M}
p (t[0]-1+z)%M

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int a, b, c, d; cin >> a >> b >> c >> d;
    cout << max(a * b, c * d) << endl;
    return 0;
}


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



int main()
{
	int a;
	int b;
	cin >> a >> b;
	if (a < b) { cout << "a < b" << endl;
	}
	else if (a > b) { cout << "a > b" << endl;
	}
	else if (a == b) { cout << "a == b" << endl;
	}
    return 0;
}

Measured memory_bytes: 3076
import math

n, m = (int(x) for x in input().split())

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

ans = 0
ans_n = 0
ans_m = 0

if 1 < n :
    ans_n = combinations_count(n, 2)

if 1 < m :
    ans_m = combinations_count(m, 2)

ans = ans_n + ans_m

print(ans)

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

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

    ll cnt = 0;
    for (int i = 0; i < N; i++) {
        if (a[i] < b[i]) {
            cnt += (b[i] - a[i]) / 2;
        } else {
            cnt -= a[i] - b[i];
        }
    }

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


Measured memory_bytes: 384
import sys
sys.setrecursionlimit(100000000)
def dfs(s,n,m,subs):
  if len(subs)==n:
    print(subs)
    return
  
  k = len(set(list(subs)))+1

  for i in range(k):
    t = "".join((subs,s[i]))
    dfs(s,n,k,t)

s = "abcdefghij"

n = int(input())
s = list(s[:n])
dfs(s,n,1,"a")

Measured memory_bytes: 4340
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a, b, k;
    cin >> a >> b >> k;
    vector<int> d;
    for(int i = 100; i >= 1; i--){
        if(a % i == 0 && b % i == 0){
            d.push_back(i);
        }
    }
    cout << d[k - 1] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int c(long long n)
{
    int s=0;while(n>0)
    {
    s+=n%10;n/=10;
    }
    return s;
}
main()
{
long long n,temp,cnt=1;
scanf("%lld",&n);
int ans=c(n);
temp=n;
while(temp>=10)
{
temp/=10,cnt*=10;
}
ans=max(ans,c(n/cnt*cnt-1));
printf("%d\n",ans);
return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long
#define lld long double
#define MOD 1000000007
#define inf 1000000000000000000ll
#define pii pair<int,int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll power(ll x,ll y, ll md=inf){ll res = 1;x%=md;while(y){if(y&1)res = (res*x)%md;x *= x; if(x>=md) x %= md; y >>= 1;}return res;}
 
using namespace std;


#define endl '\n'
#define int ll

signed main() {
	fast;

	int h,w;
	cin>>h>>w;

	vector<pii> v(h);
	for(int i=0;i<h;i++) cin>>v[i].f>>v[i].s;

	map<int,int> mp;
	for(int i=1;i<=w;i++) mp[i] = 0;

	map<int, int> mini = {{0,w}};

	for(int i=0;i<h;i++) {
		int l = v[i].f;
		int r = v[i].s;

		auto it = mp.lower_bound(l);
		int mn = inf;

		while(it!=mp.end() && it->f <= r) {
			auto it1 = it++;
			mn = min(mn, r+1-(it1->f)+(it1->s));
			mini[it1->s]--;
			if(mini[it1->s]==0) mini.erase(it1->s);
			mp.erase(it1);
		}

		if(r+1<=w && mn<inf) {
			if(mp.count(r+1) && mp[r+1] > mn) {
				mini[mp[r+1]]--;
				if(mini[mp[r+1]]==0) mini.erase(mp[r+1]);
				mini[mn]++;
				mp[r+1] = mn;
			}
			else if(!mp.count(r+1)){
				mp[r+1] = mn;
				mini[mn]++;
			}
		}

		if(mini.size()) cout<<mini.begin()->f+i+1<<endl;
		else cout<<-1<<endl;

	}
}

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

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

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


using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0; i<ll(n); i++)
#define FOR(i,m,n) for(int i=ll(m); i<ll(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }

const int  INF = (1 << 30) - 1;
const ll INFL = 1LL << 60;
const ll mod = 998244353;




struct UnionFind {
	vector<int> par;
	int cnt;
	UnionFind(int size_) : par(size_, -1), cnt(size_) { }
	bool unite(int x, int y) {
		x = find(x); y = find(y);
		if (x != y) {
			if (par[y] < par[x]) swap(x, y);
			par[x] += par[y]; par[y] = x;
			cnt--;
		}
		return x != y;
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
	int find(int x) {
		return par[x] < 0 ? x : par[x] = find(par[x]);
	}
	int size(int x) {
		return -par[find(x)];
	}
	int size() {
		return cnt;
	}
};



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

	UnionFind uf(n);
	
	REP(i, m) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		uf.unite(a, b);
	}
	cout << uf.size() - 1 << endl;



}

Measured memory_bytes: 3788
#include <bits/stdc++.h> 
using namespace std; 
int gi() { 
	int res = 0, w = 1; 
	char ch = getchar(); 
	while (ch != '-' && !isdigit(ch)) ch = getchar(); 
	if (ch == '-') w = -1, ch = getchar(); 
	while (isdigit(ch)) res = res * 10 + ch - '0', ch = getchar(); 
	return res * w; 
} 
const int MAX_N = 3e3 + 5; 
struct Graph { int to, next; } e[MAX_N << 1]; 
int fir[MAX_N], e_cnt; 
void clearGraph() { memset(fir, -1, sizeof(fir)); e_cnt = 0; } 
void Add_Edge(int u, int v) { e[e_cnt] = (Graph){v, fir[u]}, fir[u] = e_cnt++; } 
int N, a[MAX_N], f[MAX_N]; 
void dfs(int x, int fa) { 
	f[x] = 0; 
	for (int i = fir[x]; ~i; i = e[i].next) {
		int v = e[i].to; if (v == fa || a[x] <= a[v]) continue; 
		dfs(v, x); 
		if (!f[v]) f[x] = 1; 
	} 
} 
int main () { 
#ifndef ONLINE_JUDGE 
    freopen("cpp.in", "r", stdin); 
#endif
	clearGraph(); 
	N = gi(); 
	for (int i = 1; i <= N; i++) a[i] = gi(); 
	for (int i = 1; i < N; i++) {
		int u = gi(), v = gi(); 
		Add_Edge(u, v), Add_Edge(v, u); 
	} 
	for (int i = 1; i <= N; i++) { 
		dfs(i, 0); 
		if (f[i]) printf("%d ", i); 
	} 
	putchar('\n'); 
    return 0; 
} 

Measured memory_bytes: 3852
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<stack>
#include<map>
#include<list>
#include<string>
#include<algorithm>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back

#define ll __int64
#define P pair<ll,ll>
//#define __int64 long long

int a,b,c,k,ans;

int main(){	
	cin>>a>>b;
	int ans=a;
	if(b<a)ans--;
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 256
//created by missever

#include<bits/stdc++.h>
#define MAX 1000000007
using namespace std;
typedef long long LL;

const int maxn = 1e5 + 5;
int g[maxn];

int main(){
    int n,m,i,u,v;
    scanf("%d%d",&n,&m);
    for(i = 0;i < m; i++)
    {
        scanf("%d%d",&u,&v);
        g[u]++;
        g[v]++;
    }
    for(i = 1;i <= n; i++)
    {
        if(g[i] & 1)
        {
            printf("NO\n");
            return 0;
        }
    }
    printf("YES\n");
    return 0;
}


Measured memory_bytes: 640
'use strict';
(function(stdin) {
  // define function
  var compare = function(a, b) {
    if (a < b) {
      return 'a < b';
    } else if (a > b) {
      return 'a > b';
    } else {
      return 'a == b';
    }
  };
  // declare variable
  var inputs = stdin.toString().trim().split('\n');
  var cols = inputs[0].split(' ');
  var a = parseInt(cols[0], 10);
  var b = parseInt(cols[1], 10);
  // main

  console.log(compare(a, b));
  // display

}(require('fs').readFileSync('/dev/stdin', 'utf8')));
//

Measured memory_bytes: 15496
import numpy as np
h,w = map(int,input().split())
a_list = [list(input()) for _ in range(h)]
res = []
for a in a_list:
    if set(a) != set('.'):
        res.append(a)
res = list(np.array(res).T)
resT = []
for a in res:
    if set(a) != set('.'):
        resT.append(a)
for a in list(np.array(resT).T):
    print(''.join(a))

Measured memory_bytes: 12596
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <tuple>
#include <algorithm>
using namespace std;
typedef tuple<double, int, int> T;

struct UF {
	int par[100];
	void init() { for (int i = 0; i < 100; i++) par[i] = i; }
	int root(int x) { if (par[x] == x) return x; return par[x] = root(par[x]); }
	void unit(int x, int y) { x = root(x); y = root(y); par[x] = y; }
	bool same(int x, int y) { return root(x) == root(y); }
};

int n;
double x[100], y[100], z[100], r[100];
vector<T> edges;
UF uf;

double dist(int a, int b) {
	double dx = x[a] - x[b];
	double dy = y[a] - y[b];
	double dz = z[a] - z[b];
	return sqrt(dx * dx + dy * dy + dz * dz);
}

int main() {
	while (cin >> n) {
		if (!n) break;
		
		//don't forget to initialize!!!
		edges.clear();
		uf.init();
		
		int i, j;
		for (i = 0; i < n; i++) cin >> x[i] >> y[i] >> z[i] >> r[i];
		for (i = 0; i < n; i++) {
			for (j = i + 1; j < n; j++) {
				double length = dist(i, j) - r[i] - r[j];
				if (length < 0) length = 0;
				edges.push_back(T(length, i, j));
			}
		}
		sort(edges.begin(), edges.end());
		
		double ans = 0;
		for (i = 0; i < edges.size(); i++) {
			double l = get<0>(edges[i]);
			int u = get<1>(edges[i]);
			int v = get<2>(edges[i]);
			if (!uf.same(u, v)) {
				uf.unit(u, v);
				ans += l;
			}
		}
		printf("%.3f\n", ans);
	}
	return 0;
}


Measured memory_bytes: 3220
#N = int(input())
#J,K = map(int,input().split())
#A = list(map(int,input().split()))
#A = [list(map(int,input().split())) for _ in range(N)]
#for i in range():

N = input()

hon = ["2","4","5","7","9"]

if N[-1] in hon:
    print("hon")
    exit()
if N[-1] == str(3):
    print("bon")
    exit()
print("pon")

Measured memory_bytes: 61600
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double pi = acos(-1);
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) {
	for (auto &e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

//↑template↑


int n, k[25], ans;
int main() {

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

	for (int i = 2; i < n; ++i) {
		//int mon[] = { k[i],k[i - 1],k[i - 2] };
		//sort(mon, mon + 2);
		if ((k[i] > k[i - 1] && k[i - 1] > k[i - 2]) || (k[i] < k[i - 1] && k[i - 1] < k[i - 2])) { ++ans; }
	}
	cout << ans << endl;

}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int l = sc.nextInt();
    int taste = 0;
    int sum =0;
    if(l+n-1 < 0){
      taste = l+n-1;
    } else if(l > 0){
      taste = l;
    } else {
      taste = 0; 
    }
    for(int i=1;i<=n;i++){
      sum +=l+i-1;
    }
    System.out.println(sum-taste);
  }
}


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

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    h,w,k = LI()
    t = [1, 1, 2, 3, 5, 8, 13, 21]
    a = [0] * w
    a[0] = 1
    for i in range(h):
        n = [0] * w
        for j in range(w):
            n[j] = a[j] * t[j] * t[w-j-1] % mod
        for j in range(w-1):
            lr = t[j] * t[w-j-2]
            n[j] += a[j+1] * lr % mod
            n[j+1] += a[j] * lr % mod
        a = n

    return a[k-1] % mod


print(main())


Measured memory_bytes: 6096
//       Author: Mostafa Mounir Shehab
 
#include <bits/stdc++.h>
using namespace std;
 
#define PI  3.14159265  // PI = acos(-1)
#define EPS (1e-10)
#define endl "\n"
#define SZ(v) (int)(v.size())
typedef long long ll;
typedef long double ld;
//template <class Type>
 
 
void Fast(){
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL);
}
 
inline int D(){
	int t;
	scanf("%d",&t);
	return t;
}
inline ll llD(){
	ll t;
	scanf("%lld",&t);
	return t;
}
 
 
ll MOD=1e9 + 7; 
const int N=1e5 + 5,M=50 + 1;
int arr[N];
ll dp[N];
ll OO=1e12; 
 
ll n,m,k,cnt,SU,idx,len,MN,MX;
ll l,r,mid;
ll a,b,c,d;

ll Solve(int idx){
	
		
	if(idx >= n)
		return (idx == n) ? 0 : OO;
	
	ll &ret = dp[idx];
	if(~ret)
		return ret;
	
	ret = OO;
	
	for(int i=1;i<=k;++i)
		ret = min(ret,abs(arr[idx] - arr[idx+i]) + Solve(idx+i));
	
	return ret;
}



 
 
int main(){
	
	memset(dp, -1 ,sizeof dp);
	cin>>n>>k;
	for(int i=1;i<=n;++i)
		cin>>arr[i];

	cout<<Solve(1)<<endl;
	

	


}

Measured memory_bytes: 6144
#include<iostream>
#include<vector> 
#include<algorithm>
#include<string>
#include<tuple>
using namespace std;
int main() {
  int N;
  cin >> N;
  string s;
  cin >> s;
  int cnt = 0;
  for (int i=0; i<N; i++){
    if(s[i]=='A'&& s[i+1]=='B' && s[i+2]=='C'){
      cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<vector>
#include<queue>
#include<set>
#include<utility>
#define INF 0x3f3f3f3f
#define PI acos(-1)
#define ll long long
using namespace std;
int main() {
	std::ios::sync_with_stdio(false);
	string s;
	cin >> s;
	bool flag = false;
	for (int i = 0; i < s.length()-1;i++) {
		if (s[i]-s[i+1]==1||s[i]-s[i+1]==-1) {
			flag = true;
			break;
		}
	}
	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 200010
#define int long long
int h[N],v[N],nxt[N],ok=1,ec,w[N],c[N],vi[N],s,e,ans;
void add(int x,int y,int z){
	v[++ec]=y;
	w[ec]=z;
	nxt[ec]=h[x];
	h[x]=ec;
}
void dfs(int x,int d){
	vi[x]=d;
	c[d]++;
	s++;
	for(int i=h[x];i;i=nxt[i]){
		if(w[i]==1)e++;
		if(vi[v[i]]==-1)dfs(v[i],(d+w[i])%3);
		else if(vi[v[i]]!=(d+w[i])%3)ok=0;
	}
}
signed main(){
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		int x,y;
		scanf("%lld%lld",&x,&y);
		add(x,y,1);
		add(y,x,2);
	}
	memset(vi,-1,sizeof(vi));
	for(int i=1;i<=n;i++)
		if(vi[i]==-1){
			ok=1;
			c[0]=c[1]=c[2]=0;
			s=e=0;
			dfs(i,0);
			if(ok){
				if(min(c[0],min(c[1],c[2]))==0)ans+=e;
				else ans+=c[0]*c[1]+c[1]*c[2]+c[2]*c[0];
			}
			else ans+=s*s;
		}
	cout<<ans;
}

Measured memory_bytes: 11520