akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in))) {

			String in = br.readLine();
			String chr[] = in.split(" ");
			int n = Integer.parseInt(chr[0]);
			int k = Integer.parseInt(chr[1]);
			 System.out.println(n%k==0?0:1);
		}
	}
}

Measured memory_bytes: 25364
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>
#include <queue>

using namespace std;



int main()
{
	int N;
	map<string ,map<int,int> > db;

	cin >> N;

	string s;
	int p;
	for(int ni = 0; ni < N; ni++){
		cin >> s >> p;
		//if (db.count(s) > 0){
			db[s][p] = ni + 1;
		//}
	}

	vector<int> As(N,0);
	int ni = 0;
	for (pair<string,map<int, int>> ms : db){
		//for (pair< int, int> p : ms.second) {
		for (auto it = ms.second.rbegin(); it != ms.second.rend(); it++){
			As[ni] = it->second;
			ni++;
			printf("%d\n", it->second);
		}
	}

	//printf("%d",ans);

	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin>>S;
  long N = (long)(S.length());
  for(long i=0;i<(N+1)/2;i++){
      if(S[i]!=S[N-1-i]){
          cout<<"No";
          exit(0);
      }
  }
  for(long i=0;i<(N-1)/2;i++){
      if(S[i]!=S[(N-1)/2-1-i]){
          cout<<"No";
          exit(0);
      }
  }
  for(long i=(N+3)/2-1;i<(N-1);i++){
      if(S[i]!=S[N-1-i+((N+3)/2-1)]){
          cout<<"No";
          exit(0);
      }
  }
  cout<<"Yes";
}

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

using namespace std;

#define int long long
#define PB push_back
#define PPB pop_back
typedef pair<int, int> pii;
static const int INF = 1LL<<61;

static const int MAX_N = 3005;

int d[MAX_N], n, m, k;
bool shop[MAX_N];
vector<pii> G[MAX_N];

void dijkstra() {
  fill(d, d + MAX_N, INF);

  priority_queue<pii, vector<pii>, greater<pii>> q;

  for (int i = 0; i < k; ++i) {
    int s;
    cin >> s;
    shop[s] = true;
    d[s] = 0;
    q.push(pii(0, s));
  }

  while (q.size()) {
    pii p = q.top();
    int v = p.second;
    q.pop();
    if (d[v] < p.first) continue;

    for (int i = 0; i < G[v].size(); ++i) {
      pii e = G[v][i];
      if (d[e.first] < p.first + e.second) continue;

      d[e.first] = p.first + e.second;
      q.push(pii(d[e.first], e.first));
    }
  }
}

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

  cin >> n >> m >> k;
  for (int i = 0; i < m; ++i) {
    int a, b, l;
    cin >> a >> b >> l;
    G[a].PB(pii(b, l));
    G[b].PB(pii(a, l));
  }

  dijkstra();

  double ans = 0;
  for (int i = 1; i < n; ++i) {
    for (int j = 0; j < G[i].size(); ++j) {
      pii e = G[i][j];
      ans = max(ans, (d[i] + d[e.first] + e.second) / 2.0);
    }
  }

  cout << (int)(ans + 0.5000001) << endl;

  return 0;
}

Measured memory_bytes: 8828
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define mod 1000000007
using namespace std;

vector<int> a;

void rev(int i){
    i++;
    for(int j=1;j*j<=i;++j){
        if(i % j == 0){
            a[j-1] = a[j-1] == 1 ? 0 : 1;
            if(j*j!=i)a[(i/j)-1] = a[(i/j)-1] == 1 ? 0 : 1;
        }
    }
}


int main(){
    int n,m=0;
    cin >> n;
    a.resize(n);
    vector<int> b;
    rep(i,0,n-1)cin >> a[i];

    drep(i,n-1,0){
        if(a[i]==1){
            rev(i);
            ++m;
            b.push_back(i+1);
        }
        // rep(j,0,n-1){
        //     cout << a[j] << " ";
        // }
        // cout << i << endl;
    }
    if(m==0){
        cout << 0 << endl;
    }else{
        cout << m << endl;
        rep(i,0,m-1){
            cout << b[i] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 2424
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>

typedef long long LL;
#define re register
#define ud unsigned

#define gc() getchar()
#define digit(x) (x>='0' && x<='9')

LL read()
{
    LL x=0, f=1; char c=gc();
    while(!digit(c)){if(c=='-') f=-f; c=gc();}
    while(digit(c))x=(x<<3)+(x<<1)+c-'0', c=gc();
    return x*f;
}

#undef gc
#undef digit

using namespace std;

const int N = 100005;
const LL mod = 998244353;

int n, Mx;
int a[N];
int cnt[N];

int main()
{
    n=read();
    for(re int i=1; i<=n; i++)
    {
		cnt[a[i]=read()]++;
		Mx = max(Mx, a[i]);
	}
	if(a[1] || cnt[0] > 1)
	{
		printf("0\n");
		return 0;
	}
    LL ans=1;
    for(re int i=0; i<=Mx; i++)
    	if(!cnt[i])
    	{
    		printf("0\n");
    		return 0;
    	}
    
    for(re int i=1; i<=Mx; i++)
    	for(re int j=1; j<=cnt[i]; j++)
    		ans = ans * cnt[i-1] % mod;
	printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
typedef long long ll;

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

const long long INF = 1LL << 60;

int main(){
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  x--, y--;
  vector<int> p(a);
  vector<int> q(b);
  vector<int> r(c);
  rep(i, a) cin >> p[i];
  rep(i, b) cin >> q[i];
  rep(i, c) cin >> r[i];
  sort(rall(p));
  sort(rall(q));
  sort(rall(r));

  int z = 0;
  while(z != c && ((x >= 0 && p[x] < r[z]) || (y >= 0 && q[y] < r[z]))){
    if(x < 0){
      y--;
      z++;
    }
    else if(y < 0){
      x--;
      z++;
    }
    else{
      if(p[x] < r[z] && r[z] <= q[y]){
        x--;
        z++;
      }
      else if(q[y] < r[z] && r[z] <= p[x]){
        y--;
        z++;
      }
      else{
        if(p[x] < q[y]) x--, z++;
        else y--, z++;
      }
    }
  }

  ll sum = 0;
  rep(i, x+1) sum += (ll)p[i];
  rep(i, y+1) sum += (ll)q[i];
  rep(i, z) sum += (ll)r[i];

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 1408
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {

	var former string
	var i int
	sc.Split(bufio.ScanWords)
	sc.Scan()

	for sc.Scan() {
		v := sc.Text()
		if i == 0 {
			fmt.Printf("%s", v)
		} else if former != v {
			fmt.Printf(" %s", v)
		}
		former = v
		i++
	}
	fmt.Print("\n")
}



Measured memory_bytes: 4244
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;




int main(){

	double x,y,theta,omega;

	scanf("%lf %lf %lf %lf",&x,&y,&theta,&omega);

	double run_theta;
	double NUM = M_PI/180.0;

	if(x == 0){

		if(y > 0){

			run_theta = 90;

		}else{

			run_theta = 270;
		}
	}else if(y == 0){

		if(x > 0){

			run_theta = 0;

		}else{

			run_theta = 180;
		}

	}else{

		run_theta = (atan(fabs(y)/fabs(x)))/NUM;

		if(x < 0 && y > 0){

			run_theta = 180-run_theta;
		}else if(x < 0 && y < 0){

			run_theta = 180+run_theta;
		}else if(x > 0 && y < 0){

			run_theta = 360-run_theta;
		}
	}

	if(theta >= run_theta){

		theta = min(theta-run_theta,run_theta+(360-theta));

	}else{

		theta = min(run_theta-theta,theta+(360-run_theta));
	}

	double DIST = sqrt(x*x+y*y),pow_DIST = x*x+y*y;
	double left = 0,right = DIST*(omega/NUM),mid = (left+right)/2;
	double ans = 0;


	double run_time,snip_time;

	for(int loop = 0; loop < 100; loop++){

		run_time = sqrt(pow_DIST-mid*mid)/(mid*omega*NUM);
		snip_time = (theta+(acos(mid/DIST)/NUM))/omega;

		if(run_time > snip_time){

			ans = mid;
			left = mid;
		}else{

			right = mid;
		}
		mid = (left+right)/2;
	}

	printf("%.10lf\n",ans*(omega*NUM));

	return 0;
}



Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
using namespace std;
#define SENTINEL 2000000000
#define MAX 500000
int cnt;
void out(int a[], int n) {
	int i;
	cout << a[0];
	for (i = 1; i < n; i++) {
		cout << " " << a[i];
	}
	cout << endl;

}


int merge(int a[],int left,int mid,int right) {
	int i,j,n1,n2,k;
	n1 = mid - left;
	n2 = right - mid;
	int L[MAX/2+2], R[MAX/2+2];
	for (i = 0; i < n1; i++) {
		L[i] = a[left + i];
	}
	for (i = 0; i < n2; i++) {
		R[i] = a[mid + i];
	}
	L[n1] = R[n2] = SENTINEL;
	i = 0; j = 0;
	for (k = left; k < right; k++) {
		cnt++;
		if (L[i] <= R[j]) {
			a[k] = L[i++];
		
		}
		else {
			a[k] = R[j++];
			
		}
	}
	//out(a, sizeof(a));
	return 0;
}
int mergeSort(int a[],int left,int right) {
	int mid;
	if (left + 1 < right) {
		mid = (left + right) / 2;
		mergeSort(a, left, mid);
		mergeSort(a, mid, right);
		merge(a,left, mid, right);
	}
	return 0;
}

int main() {
	int n,i,a[MAX+4];
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	
	mergeSort(a, 0, n);
	out(a, n);
	cout << cnt << endl;
	return 0;

}

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

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

  vector<int> X(N, 0);
  vector<int> Y(N, 0);
  rep(i, N) cin >> X[i];
  Y = X;
  sort(Y.begin(), Y.end());

  int B1 = Y[N / 2 - 1];
  int B2 = Y[N / 2];

  rep(i, N) {
    if (X[i] <= B1) {
      cout << B2 << endl;
    } else {
      cout << B1 << endl;
    }
  }
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  vll v(3);
  REP(i,3)cin>>v[i];
  SORT_UNIQUE(v);
  if(v.size()==2)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
    int a=0, b=0;
    string N;
    cin >> N;
    for (int i=0;i<N.size();i++){
        N[i]=='0' ? a++ : b++;
    }
    a>b ? cout << b*2 : cout << a*2;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define eps 1e-9
#define maxp 1004
#define mod 998244353
#define sin(s) scanf("%lld",&s);
#define sout(s) printf("%lld\n",s);
#define in(s) cin>>s
#define in2(a,b) cin>>a>>b
#define in3(a,b,c) cin>>a>>b>>c
#define vll vector<ll>
#define out(s) cout<<s
#define outs(s,a) cout<<s<<a
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define gear_change ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define nfl(i,n) for(i=0;i<n;i++)
#define sfl(i,s,e) for(i=s;i<e;i++)
#define ufl(i,n) for(i=n-1;i>=0;i--)
void solve(){
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5]){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }
}
int main(){
    clock_t t1=clock();
    gear_change;
    ll test=1;
    // in(test);
    while(test--){
        solve();
    }
    clock_t t2=clock();
    cerr<<"Time elapsed:- "<<(double)(t2-t1)/CLOCKS_PER_SEC<<'\n';
}    

Measured memory_bytes: 256
n = int(input())
h = list(map(int,input().split()))

cst = [0 for i in range(n+10)]
cst[0] = 0
cst[1] = abs(h[0]-h[1])

for i in range(2,n):
    cst[i] = min(cst[i-2]+abs(h[i-2]-h[i]) , cst[i-1]+abs(h[i-1]-h[i]))

print(cst[n-1])

Measured memory_bytes: 13980
#include <bits/stdc++.h>
using namespace std;
#define INF 255

int main()
{
	int n;
	cin >> n;
	string a;
	for(int i=0;i<n;i++)
    {
        int num;
        cin >> num;
        char cc=(char)(num+'0');
        a.push_back(cc);
    }
    string b;
	for(int i=0;i<n;i++)
    {
        int num;
        cin >> num;
        char cc=(char)(num+'0');
        b.push_back(cc);
    }
    if(a>b)
    {
        swap(a,b);
    }
    int counter=0;
    do
    {
        if(a==b)
        {
            break;
        }else
        {
            counter++;
        }
    }while(next_permutation(a.begin(),a.end()));
    cout << counter << endl;
}


Measured memory_bytes: 256
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        self.sizes = [1] * (n+1)
        self.root = [1] * (n+1)
 
    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
 
    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.root[x] = -1
            self.sizes[y] += self.sizes[x]
        else:
            self.par[y] = x
            self.root[y] = -1
            self.sizes[x] += self.sizes[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
        
 
    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)
    
    def size(self, x):
        return self.sizes[find(x)]
    
 
n, m = map(int, input().split())
lst = [list(map(int, input().split())) for _ in range(m)]
 
all_comb = n*(n-1)/2
 
a = UnionFind(n)
 
ans = [all_comb]
for pair in reversed(lst):
    if a.same_check(pair[0], pair[1]):
        ans.append(ans[-1])
        pass
    else:
        ans.append(ans[-1] - a.sizes[a.find(pair[0])]*a.sizes[a.find(pair[1])])
        a.union(pair[0], pair[1])
    
for i in reversed(ans[:-1]):
    print(int(i))

Measured memory_bytes: 38584
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

typedef pair<int, int> P;

int u[33][33];
P memo[33][33][33][33];
int h, w, s, ming;

struct group{
	int bx, by, ex, ey;
	group(int x, int y, int _x, int _y){
		bx = x;
		by = y;
		ex = _x;
		ey = _y;
	}
};

int calc(int bx, int by, int ex, int ey){
	int sum=0;
	if( bx > ex ) swap( bx, ex );
	if( by > ey ) swap( by, ey );
	for(int y=by; y<ey; y++){
		for(int x=bx; x<ex; x++){
			sum += u[y][x];
		}
	}
	return sum;
}

P solve(int bx, int by, int ex, int ey){
	if( memo[bx][by][ex][ey].first ){
		return memo[bx][by][ex][ey];
	}
	P result(1, calc(bx,by,ex,ey)-ming), tmp;
//	cout << "calc: " << calc(bx,by,ex,ey) << endl;
//	result = max(result, tmp);
	for(int y=by+1; y<ey; y++){
		if( calc(bx,by,ex,y) >= ming &&
			calc(bx,y,ex,ey) >= ming ){
			P t1 = solve(bx,by,ex,y);
			P t2 = solve(bx,y,ex,ey);
			tmp.first = t1.first + t2.first;
			tmp.second = min(t1.second, t2.second);
			result = max(result, tmp);
//	cout << "calc2y: " << calc(bx,by,ex,y)+calc(bx,y,ex,ey) << endl;
//	cout << tmp.first << "  " << tmp.second << endl; 
		}
	}
	for(int x=bx+1; x<ex; x++){
		if( calc(bx,by,x,ey) >= ming &&
			calc(x,by,ex,ey) >= ming ){
			P t1 = solve(bx,by,x,ey);
			P t2 = solve(x,by,ex,ey);
			tmp.first = t1.first + t2.first;
			tmp.second = min(t1.second, t2.second);
			result = max(result, tmp);
//	cout << "calc2x: " << calc(bx,by,x,ey)+calc(x,by,ex,ey) << endl;
//	cout << tmp.first << "  " << tmp.second << endl; 
		}
	}
//	cout << result.first << "  " << result.second << endl; 
	memo[bx][by][ex][ey] = result;
	return result;
}

int main(){
	while(cin >> h >> w >> s, h|w|s){
		int sume=0;//, ans=0;
		fill( memo[0][0][0], memo[0][0][0]+33*33*33*33, P(0,0) );
		for(int y=0; y<h; y++){
			for(int x=0; x<w; x++){
				cin >> u[y][x];
				sume += u[y][x];
			}
		}
		ming = sume - s;
//		cout << "ming: " << ming << endl;
		P ans = solve(0,0,w,h);
//		queue< vector<group> > que;
//		vector<group> grs;
//		grs.push_back( group(0,0,w,h) );
//		que.push( group(0,0,w,h) );
//		while( !que.empty() ){
//			vector<group> grs = que.front();
//			que.pop();
//			for(int i=0; i<grs.size(); i++ ){
//			}
//		}
		cout << ans.first << " " << ans.second << endl;
	}
	return 0;
}

Measured memory_bytes: 10440
local n=io.read("n")
local a={}
for i=1,n do
    a[i]=io.read("n")
end

local box={}
for i=n,1,-1 do
    local ball=0
    for j=2*i,n,i do
        ball=ball+(box[j] or 0)
    end
    if ball%2~=a[i] then
        box[i]=1
    end
end

local counter=0
for i=1,n do
    if box[i]==1 then
        counter=counter+1
    end
end
print(counter)
for i=1,n do
    if box[i]==1 then
        print(i)
    end
end

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

int dfs(const vector<vector<int>> &g, int color, int now, map<pair<int,int>,int> &ans){
	int used{1}, mcolor{color};
	for(int i=0; i<g.at(now).size(); i++){
		int to = g.at(now).at(i);
		if(ans[{now,g.at(now).at(i)}]==0){
			if(used==color) used++;
			ans[{now,to}] = used;
			ans[{to,now}] = used;
			mcolor = max(mcolor,dfs(g, used, to, ans));
			used++;
		}
	}
	return mcolor;
}

int main(){
	
	int n; cin>>n;
	vector<int> a(n-1), b(n-1);
	vector<vector<int>> g(n);
	map<pair<int,int>,int> ans;
	for(int i=0; i<n-1; i++){
		cin >> a.at(i) >> b.at(i);
		g.at(--a.at(i)).push_back(--b.at(i));
		g.at(b.at(i)).push_back(a.at(i));
	}
	cout << dfs(g, 0, 0, ans) << endl;
	for(int i=0; i<n-1; i++){
		cout << ans.at({a.at(i),b.at(i)}) << endl;
	}
	
}

Measured memory_bytes: 19456
H,W=map(int,input().split())
li=[]

for h in range(H):
  s=list(input())
  li.append(s)

for h in range(H):
  for w in range(W):
    if li[h][w]=='.':
      li[h][w]=0

for h in range(H):
  for w in range(W):
    if li[h][w]=='#':
      if h!=0 and li[h-1][w]!='#':
        li[h-1][w]+=1
      if h!=H-1 and li[h+1][w]!='#':
        li[h+1][w]+=1
      if w!=0 and li[h][w-1]!='#':
        li[h][w-1]+=1
      if w!=W-1 and li[h][w+1]!='#':
        li[h][w+1]+=1
      if h!=0 and w!=0 and li[h-1][w-1]!='#':
        li[h-1][w-1]+=1
      if h!=0 and w!=W-1 and li[h-1][w+1]!='#':
        li[h-1][w+1]+=1
      if h!=H-1 and w!=0 and li[h+1][w-1]!='#':
        li[h+1][w-1]+=1
      if h!=H-1 and w!=W-1 and li[h+1][w+1]!='#':
        li[h+1][w+1]+=1

for h in range(H):
  for w in range(W):
    if li[h][w]!='#':
      li[h][w]=str(li[h][w])

for h in range(H):
  print(''.join(li[h]))


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

using namespace std;

typedef long long ll;
const int INF = 1<<28;

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

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

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

int g[110][110];
int g_new[110][110];

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

  int N, M;
  cin >> N >> M;

  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      g[i][j] = INF;
      g_new[i][j] = INF;
    }
  }

  int a, b, c;
  for(int i = 0; i < M; i++){
    cin >> a >> b >> c;
    a--;
    b--;
    g[a][b] = c;
    g[b][a] = c;
    g_new[a][b] = c;
    g_new[b][a] = c;
  }

  for (int i = 0; i < N; i++)      // 経由する頂点
      for (int j = 0; j < N; j++)    // 開始頂点
        for (int k = 0; k < N; k++)  // 終端
          g_new[j][k] = min(g_new[j][k], g_new[j][i] + g_new[i][k]);


  int ans = 0;
  for(int i = 0; i < N-1; i++){
    for(int j = i+1; j < N; j++){
      if(g[i][j] < INF && g[i][j] > g_new[i][j]){
        ans++;
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
N=int(input())
S=input()
indexs=[[] for i in range(10)]
for i in range(N):
  indexs[int(S[i])].append(i)

counter=0
for i in range(0, 1000):
  a=i//100
  b=(i%100)//10
  c=i%10

  if len(indexs[a])>0 and len(indexs[b])>0 and len(indexs[c])>0:
    x=min(indexs[a])
    z=max(indexs[c])
    n=len(indexs[b])
    j=0
    for i in range(n):
      if indexs[b][i]>x and indexs[b][i]<z:
        j=1
    counter+=j

print(counter)

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

//#include "rubo.h"
//#define mp make_pair
//#define pb push_back
#define in int
#define ll long long
#define vc vector
#define SQ(j) (j)*(j)
//#define x first
//#define y second

//#define ld long double
#define dbl  long double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define all(j) j.begin(), j.end()
#define loop(xxx, yyy) for(int xxx = 0; xxx < yyy; xxx++)
//#define printf(fmt, ...) (0)
//#define HOME
//#define y0 ngacaleiebinvoaeu
//#define y1 gnarpipipaigare
#define j1 adsfndnasfafoasp

#define db(x) cout << #x << " = " << x << endl
#define dbCont(x) cout << #x << ": "; for(auto shun: x) cout << shun << ' '; cout << endl;

typedef long double ld;

using namespace std;


const int N = 20+3;
const int MOD = 1000 * 1000 * 1000 + 7;

int n;
int g[N][N];

int dp[N][1<<N];

int ones(int msk){
    int res = 0;
    loop(i,32){
        res += ((msk >> i) & 1);
    }
    return res;
}

int main() {

    cin >> n;
    loop(i,n){
        loop(j,n){
            cin >> g[i][j];
        }
    }

    for(int j = 0 ;j < n; j++){
        if(g[0][j]){
            dp[0][1<<j] = 1;
        }
    }

    for(int i = 1; i < n; i++){
        for(int msk = 0; msk < (1<<n); msk++){
            if(ones(msk) != i+1) continue;

            for(int pi = 0; pi < n; pi++){
                if(((msk >> pi) & 1) && g[i][pi]){
                    dp[i][msk] += dp[i-1][msk^(1<<pi)];

                    dp[i][msk] %= MOD;
                }
            }
        }
    }


    int res = dp[n-1][(1<<n)-1];
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 176384
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
  
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
 
const int MAX=510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
   
  COMinit();
  int n,k;
  cin >> n >> k;
  vector<int>a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(),a.end());
  
  ll ans = 0;
  rep(i,n-k+1){
    ans -= a[i]*COM(n-i-1,k-1);
    ans %= MOD;
  }
  for(int i = k-1;i<n;i++){
    ans += a[i]*COM(i,k-1);
    ans %= MOD;
  }
  while(ans<0)ans+=MOD;
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 15572
//C
#include <cassert>
//#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// 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>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//ここまで標準include

using namespace std;

long aCb(long a, long b) {
	long out = 1;
	for (long i = 1; i <= b; i++) {
		out = out * (a + 1 - i) / i;
	}
	return out;
}

long long gcd(long long a, long long b) {
	long long r = -1;
	if (a < b) {
		swap(a, b);
	}
	while (r != 0) {
		r = a % b;
		if (r == 0) {
			return b;
		}
		else {
			a = b;
			b = r;
		}
	}
}

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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (b - a == c - b) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}


Measured memory_bytes: 384
from collections import deque

h, w = map(int, input().split())

ans = 0
c = []

for i in range(h):
    ci = list(input())
    ans += ci.count(".")
    c.append(ci)

sy = 0
sx = 0
gy = h-1
gx = w-1

dx = [1, 0,-1, 0]
dy = [0, 1, 0,-1]

que = deque([(sy,sx)])
c[sy][sx] = 1
while bool(que):
    y, x = que.popleft()
    if y == gy and x == gx:
        break
    for i in range(4):
        yi = y + dy[i]
        xi = x + dx[i]
        if 0 <= yi < h and 0 <= xi < w and c[yi][xi] == ".":
            que.append((yi,xi))
            c[yi][xi] = c[y][x] + 1

if c[gy][gx] == ".":
    print(-1)
else:
    print(ans - c[gy][gx])

Measured memory_bytes: 3444
#include <iostream>
#include <string>
#include <list>
#include <cassert>


struct Proc{
	std::string meirei;
	int value;
};
typedef std::list<int> IList;

void input(IList& ilist);
int output(const IList& vec);
void calc(IList&ilist, Proc& command);
 
int main()
{
    std::cin.tie(0);//??\??????????????????
    std::ios::sync_with_stdio(false);
    IList result;
    input(result);
    output(result);
    return 0;
}
///--------------------------------------------
void input(IList& ilist)
{
    int n;
    std::cin >> n;
    for(int i = 0; i < n; i++){
        Proc command;
        std::cin >> command.meirei;
        if((command.meirei == "insert")||( command.meirei == "delete")){
        	std::cin >> command.value;
		}
		calc(ilist, command);
    }
}
        
void calc(IList&ilist, Proc& command)
{

    if( command.meirei == "deleteFirst"){
        ilist.pop_front();
        // ilist.erase(ilist.begin());
    }else if(command.meirei == "deleteLast"){
        ilist.pop_back();
    }else if(command.meirei =="insert"){
            //???????????????
            ilist.insert(ilist.begin(), command.value);
    }else{//??????
        for(auto itr = ilist.begin(); itr != ilist.end(); ++itr){
            if(*itr == command.value){
	            ilist.erase(itr);
                break;
            }
        }
    }

}
///--------------------------------------------
int output(const IList& intlist)
{
    for(auto itr = intlist.begin(); itr != intlist.end(); ++itr){
        if(itr != (intlist.begin())){
            std::cout << " "  ;
        }
        std::cout << *itr;
    }
    std::cout << std::endl;
    return 0;
}

Measured memory_bytes: 34488
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    string s;
    cin >> s;
    int n = s.length();
    string sr = s;
    reverse(ALL(sr));
    if (s == sr){
        cout << 0 << endl;
        return 0;
    }

    string t;
    VI p;
    p.push_back(-1);
    REP(i,n){
        char c = s[i];
        if (c != 'x'){
            t += c;
            p.push_back(i);
        }
    }
    p.push_back(n);
    string tr = t;
    reverse(ALL(tr));
    if (t != tr){
        cout << -1 << endl;
        return 0;
    }


    ll ans = 0;
    int m = p.size();
    REP(i,(m+1)/2-1){
        int x = p[i+1] - p[i];
        int y = p[m-1-i] - p[m-2-i];
        ans += abs(x-y);
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 1148
#include<iostream>
#include<math.h>
#include<algorithm>
#include<unordered_map>
using namespace std;
int main(){
    int A, B, K;
    cin >> A >> B >> K;
    for(int i = A;i <= B;i++){
        if(i < A + K || B - K < i)cout << i << "\n";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)

vector<bool> visited(105);
vector<vector<int>> edge(105);
bool dfs(int cur, int par) {
    // if a cycle doesn't exist, return true
    visited[cur] = true;
    bool ic = false;
    if (edge[cur].size() == 0) {
        return true;
    } else {
        for (int i = 0; i < edge[cur].size(); i++) {
            if (edge[cur][i] == par) {
                continue;
            }
            if (visited[edge[cur][i]]) {
                ic = true;
                break;
            } else {
                visited[edge[cur][i]] = true;
            }
            if (!dfs(edge[cur][i], cur)) {
                ic = true;
            }
        }
        if (ic) {
            return false;
        } else {
            return true;
        }
    }
}
int main() {
    long long n, mi = 1e16;
    cin >> n;
    REP(i, 5) {
        long long a;
        cin >> a;
        mi = min(mi, a);
    }
    cout << 4 + (n + mi - 1) / mi << endl;
}

Measured memory_bytes: 256
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    a,b=INTM()
    print(max(0,a-2*b))
if __name__ == '__main__':
    do()

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

int main(){
	double x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	double distance = sqrt( pow(x2 - x1, 2) + pow(y2-y1, 2));
	cout << fixed << setprecision(10) << distance;
}

Measured memory_bytes: 3260
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lpin(a,i,n) for(int i=0;i<n;i++){cin>>a[i];}

int  main(){
  list<int> l[1001];
  list<int>::iterator it;
  int n,q;
  cin>>n>>q;
  lp(i,q){
    int x,y,z;
    cin>>x>>y;
    if(x==0){
      cin>>z;
      l[y].push_back(z);
    }
    if(x==1){
      for(it=l[y].begin();it!=l[y].end();it++){
	if(it!=l[y].begin()) cout<<" ";
	cout<<*it;
      }
      cout<<endl;
      
    }
    if(x==2){
      cin>>z;
      l[z].splice(l[z].end(),std::move(l[y]));
    }
  }

		  
      
  return 0;
}



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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

int main() {
  map<int, int> counter;
  FOR(i, 1, 182) {
    counter[i*i]++;
    FOR(j, i, 182) {
      if (i*i+j*j > 1<<15) break;
      counter[i*i+j*j]++;
      FOR(k, j, 182) {
        if (i*i+j*j+k*k > 1<<15) break;
        counter[i*i+j*j+k*k]++;
        FOR(l, k, 182) {
          if (i*i+j*j+k*k+l*l > 1<<15) break;
          counter[i*i+j*j+k*k+l*l]++;
        }
      }
    }
  }

  while (1) {
    int n; cin >> n;
    if (not n) break;
    cout << counter[n] << endl;
  }
  return 0;
}

Measured memory_bytes: 4604
#include <stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){

  int n; 
  int i,j;
  int A[N+1];
  
  scanf("%d",&n);
  
  for( i=1 ; i <= n ; i++ ) scanf("%d",&A[i]);

 
  for( i=1 ; i <= n ; i++ ){
    
    if(A[i]<A[i-1]){
      //switch
      int a;
      a = A[i];
      A[i]=A[i-1];
      A[i-1]=a;
    }
    for( j=i-1 ; j>0 ; j-- ){
      if(A[j]<A[j-1]){
	//switch
	int b;
	b = A[j];
	A[j]=A[j-1];
	A[j-1]=b;
      }
    }
    trace(A, n);      
  }
  
  return 0;
  
}

Measured memory_bytes: 608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  string s;
  cin >> s;
  if(s.size()>3&&s.substr(0,4)=="YAKI") cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String w = sc.next();

        System.out.println(solve(w) ? "Yes" : "No");

        sc.close();
    }

    static boolean solve(String w) {
        int[] counts = new int[26];
        w.chars().forEach(ch -> ++counts[ch - 'a']);

        return Arrays.stream(counts).allMatch(count -> count % 2 == 0);
    }
}

Measured memory_bytes: 29012
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
typedef long long ll;
typedef multiset<ll> S;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=998244353;
bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}

int main(){
    int n;cin>>n;
    int d;cin>>d;
    if(d!=0){
        cout<<0<<endl;
        return 0;
    }
    vi v(n-1);
    rep(i,n-1)cin>>v[i];
    sort(all(v));
    vi num(n);
    ll ans=1;
    num[0]=1;
    rep(i,n-1){
        if(v[i]==0){
            cout<<0<<endl;
            return 0;
        }
        ans*=num[v[i]-1];
        ans%=mod;
        num[v[i]]++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
constexpr int INF = 1e9;
constexpr long long INFLL = 1LL<<60;


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

  int n;
  cin >> n;
  vector<pair<int, int>> xy;
  rep(i, n) {
    int x, y;
    cin >> x >> y;
    xy.emplace_back(x, y);
  }

  double sum = 0;
  int num = 0;

  vector<int> v;
  rep(i, n) v.push_back(i);

  do {
    num++;
    for (int i = 0; i < v.size(); i++) {
      if (i >= v.size() - 1) continue;
      int idx = v[i];
      int idx2 = v[i+1];
      int d1 = xy[idx].first - xy[idx2].first;
      int d2 = xy[idx].second - xy[idx2].second;
      sum += sqrt(d1 * d1 + d2 * d2);
    }
  } while (next_permutation(v.begin(), v.end()));

  printf("%.10lf\n", sum / num);

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int n,a[10000+5],sum,aaa,bbb,m;
int main()
{
    cin>>n;
    for (int i=1;i<=n;i++) scanf("%d",&a[i]),sum=sum+a[i];
    cin>>m;
    for (int i=1;i<=m;i++)
    {
    	scanf("%d%d",&aaa,&bbb);
    	printf("%d\n",sum-a[aaa]+bbb);
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
template<typename T> inline T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }





int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    // youtube解説の解
    // とりあえず書いてみる
    
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<int> b(n);
    rep(i, n) {
        b[i] = i - a[i];
    }
    // rep(i, n) cout << b[i] << " "; cout << endl;
    ll cnt = 0;
    int m = b[n - 1] + 1;
    int flg = 0;
    for (int i = n - 1; i >= 0; --i) {
        if (m == b[i]) continue;
        if (m < b[i]) flg = 1;
        m = b[i];
        if (m < 0|| i < m) flg = 1;
        cnt += i - m;
        // cout << i << " " << m << endl;
    }
    if (flg) { cout << -1 << endl; return 0; }
    cout << cnt << endl;
}


Measured memory_bytes: 1792
import java.util.StringTokenizer;
import java.io.*;

public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try{
			String input = br.readLine();
			StringTokenizer token;
			while(input != null){
				token = new StringTokenizer(input);
				int num = Integer.parseInt(token.nextToken()) + Integer.parseInt(token.nextToken());
				
				System.out.println((int)Math.log10(num) + 1);
				input = br.readLine();
			}
		}catch(Exception ex){
			System.exit(0);
		}
	}
}

Measured memory_bytes: 24016
N,M=[int(i) for i in input().split()]
H=[int(i) for i in input().split()]
isGood=[1]*N
for m in range(M):
    A,B=[int(i) for i in input().split()]
    if isGood[A-1]==1:
        if H[A-1]<=H[B-1]:
            isGood[A-1]=0
    if isGood[B-1]==1:
        if H[B-1]<=H[A-1]:
            isGood[B-1]=0
print(sum(isGood))


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

int main()
{
   int a;
    cin >> a;
   int b,c,d,e;
    cin >> b ;
    c=a+b;
    d=a-b;
    e=a*b;
    if(c>=d&&c>=e){
        cout<<c;
        return 0;
    }
    if(d>=c&&d>=e){
        cout<<d;
        return 0;
    }
    if(e>=d&&e>=c){
        cout<<e;
        return 0;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
  string ibe;
  int n;
  int score=0,out=0;
  int hit=0;
  cin >> n;
  for(int i=0;i<n;i++){
    while(1){
      if(out >= 3)break;
      cin >> ibe;
      if(ibe=="HIT"){
	hit++;
	if(hit==4){
	  score++;
	  hit--;
	}
      }
      else if(ibe=="HOMERUN"){
	score=hit+1+score;
	hit=0;
      }
      else if(ibe=="OUT"){
	out++;
      }
    }
    cout << score << endl;
    out=0;
    hit=0;
    score=0;
  }
}

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);

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

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

  int sum = 0;

  for (int i = N-1; i >= 0; i--){
    sum += a[i];
    i--;
    sum -= a[i];
  }

  cout << sum << endl;
  

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int a, b;
  cin >> a >> b;
  if(((a + b) % 3 == 0) || (a % 3 == 0) || (b % 3 == 0))
    cout << "Possible";
  else cout << "Impossible";
  return 0;
}

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

using namespace std;
using ll = long long;

ll solve(int N, const vector<int>& xs)
{
    ll ans = 0;
    auto L = 0, R = 0, x = 0;

    while (L < N)
    {
        x |= xs[L];
        R = max(R, L + 1);
        
        while (R < N and (x & xs[R]) == 0)
        {
            x |= xs[R];
            ++R;
        }

        ans += (R - L);

        x &= ~xs[L];
        ++L;
    }

    return ans;
}

int main()
{
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    vector<int> xs(N);

    for (int i = 0; i < N; ++i)
        cin >> xs[i];

    auto ans = solve(N, xs);

    cout << ans << endl;

    return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
#define all(x) x.begin(), x.end()

template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 & y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 & y) {if (x < y) x = y;}

#define int ll
int n;

void read() {
	cin >> n;
}

vector<int> factor(int x) {
	vector<int> p;
	for (int i = 1; i * i <= x; i++) {
		if (x % i == 0) {
			p.push_back(i);
			p.push_back(x / i);
		}
	}
	sort(all(p));
	p.resize(unique(all(p)) - p.begin());
	return p;
}

bool check(int x) {
	// /cout << x << endl;
	int N = n;
	if (x < 2 || x > N) return false;
	while (N % x == 0) {
		N /= x;
	}
	if (N == 1) return true;
	if (N < x) return false;
	if ((N - 1) % x == 0) return true;
	return false;
}

int ans;

void run() {
	auto fans = factor(n);
	ans = 0;
	for (auto i : fans) {
		ans += check(i);
		//cout << i << " " << check(i) << endl;
	}
	fans = factor(n - 1);
	for (auto i : fans) {
		ans += check(i);
		//cout << i << " " << check(i) << endl; 
	}
}

void write() {
	cout << ans << endl;
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	read();
	run();
	write();
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void){
    int A,B,C,D;
    cin>>A>>B>>C>>D;
    
    while(1){
        C=C-B;
        if(C<=0){
            cout<<"Yes"<<endl;
            break;
        }
        A=A-D;
        if(A<=0){
            cout<<"No"<<endl;
            break;
        }
    }
}


Measured memory_bytes: 3596
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        Integer[] ary = new Integer[n];
        for(int i = 0; i < n; ++i) {
            int tmp = Integer.parseInt(sc.next());
            ary[i] = tmp;
        }

        double ans = 0d;
        double sum = 0d;
        for(int i = 0; i < n; ++i) {
            sum += (double)1 / (double)ary[i];
        }

        ans =  (double)1 / sum;

        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (h, _) = get!(usize, usize);
    let mut cs = Vec::new();
    for _ in 0..10 {
        cs.push(get!(String).split_whitespace().map(|c| c.parse::<i64>().unwrap()).collect::<Vec<_>>());
    }

    for k in 0..10 {
        for i in 0..10 {
            for j in 0..10 {
                if cs[i][j] > cs[i][k] + cs[k][j] {
                    cs[i][j] = cs[i][k] + cs[k][j];
                }
            }
        }
    }

    let mut r = 0;
    for _ in 0..h {
        for a in get!(String).split_whitespace() {
            if a == "-1" { continue; }
            r += cs[a.parse::<usize>().unwrap()][1];
        }
    }
    println!("{}", r);
}

Measured memory_bytes: 2144
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <sstream>
#include <algorithm>
#include <queue>
#include <stack>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <map>
#include <iomanip>
#include <cctype>
#include <climits>

using namespace std;

using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;

using ll = long long int;

#define mp(a,b) make_pair(a,b)

const int MOD = 1000 * 1000 * 1000 + 7;

bool res() {
	ll n;
	cin >> n;
	if (!cin) return false;

	vector<ll> digits(62);

	for (int i = 0; i < n; ++i) {
		ll num;
		cin >> num;
		int cont = 0;
		while (num > 0) {
			if (num % 2 == 1)
				++digits[cont];
			num /= 2;
			++cont;
		}
	}

	ll tot = 0;
	for (int i = 0; i < digits.size(); ++i) {
		ll pot = (1LL << i) % MOD;
		ll aux1 = (n - digits[i]) % MOD;
		ll aux2 = (digits[i] * aux1) % MOD;
		ll aux3 = (pot * aux2) % MOD;
		tot = (tot + aux3) % MOD;
	}

	cout << tot << '\n';

	return true;
}

int main() {
	while (res()) {}
	return 0;
}

Measured memory_bytes: 256
solver a b = 
    if a `mod` 3 == 0 || b `mod` 3 == 0 || (a+b) `mod` 3 == 0
        then "Possible"
        else "Impossible"

main :: IO ()
main = do
    [a, b] <- map (read :: String -> Int) . words <$> getLine
    putStr $ (solver a b) ++ "\n"


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

using namespace std;

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

typedef pair<int, int> P;
const int INF = 1e9;
const int dx[] = {1, 0};
const int dy[] = {0, 1};
int ans[111][111];

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> s(h, vector<char>(w));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> s[i][j];
      ans[i][j] = INF;
    }
  }
  ans[0][0] = 0;
  if (s[0][0] == '#') ans[0][0] = 1;
  queue<P> que;
  que.emplace(0, 0);
  while (!que.empty()) {
    P p = que.front();
    que.pop();
    for (int i = 0; i < 2; i++) {
      int nx = p.first + dx[i];
      int ny = p.second + dy[i];
      if (nx < 0 || ny < 0 || w <= nx || h <= ny) continue;
      if (ans[ny][nx] < ans[p.second][p.first] + 1) continue;
      if (s[p.second][p.first] == '.' && s[ny][nx] == '#') {
        chmin(ans[ny][nx], ans[p.second][p.first] + 1);
      } else {
        chmin(ans[ny][nx], ans[p.second][p.first]);
      }
      que.emplace(nx, ny);
    }
  }
  cout << ans[h - 1][w - 1] << endl;

  return 0;
}

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


int main(void){
    // Your code here!
    int n;
    cin>>n;
    vector<int> l(n);
    
    for(int i=0; i<n; i++){
        cin>>l[i];
    }
    
    sort(l.begin(), l.end());
    
    int sum=0;
    for(int i=0; i<n-1; i++){
        sum+=l[i];
    }
    
    if(sum>l[n-1]){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256