akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<bits/stdc++.h>
#include<stack>
#include<queue>
#include<list>
#include<vector>
#include<bitset> 
#include<unordered_map> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #include "boost/algorithm/string.hpp"
// RAJJI KI MEHER 
#define fio ios_base::sync_with_stdio(false)
//#define mod 1000000007
#define mod1 mod
#define mod2 100000009
#define li long long int
#define ll int
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define readi(x) scanf("%d",&x)
#define  reads(x)  scanf("%s", x)
#define readl(x) scanf("%lld",&x)
#define rep(i,n) for(i=0;i<n;i++)
#define revp(i,n) for(i=(n-1);i>=0;i--)
#define myrep1(i,a,b) for(i=a;i<=b;i++)
#define myrep2(i,a,b) for(i=b;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define MAXN 100000000000000005
#define MINN -10000000000000000
#define INTMAX 1000001000
#define pii pair<li,li>
#define pdd pair<double,double>
#define pic pair<int,char>
//#define N 5005
#define lgn 20
#define ddouble long double
#define minus minu
#define PI 3.1415926535
#define lgn 20
using namespace std;
li a[25][25];li n,n1=0,n2=0,n3=0,k,mod=1000000007;
li AA[22][1<<21];
li ff(li i1,li i2){
    if(i1==n) {//cout<<n<<" "<<i2<<endl;
        return(1);}
    //if(i==0) return(0);
    if(AA[i1][i2]!=-1) return(AA[i1][i2]);    
    li ans=0;
for(li i=0;i<n;i++){if(((i2>>i)&1)==0 && a[i1][i]){
    //cout<<i2<<" "<<i<<" "<<(i2|(1<<i))<<endl;
    ans=(ans+ff(i1+1,i2|(1<<i)))%mod;}}
AA[i1][i2]=ans;return(ans);
}
int main(){readl(n);memset(AA,-1,sizeof(AA));li i,j;
for(i=0;i<n;i++) {for(j=0;j<n;j++) cin>>a[i][j];}
li ans=ff(0,0);
cout<<ans;
}


Measured memory_bytes: 360832
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N,M; cin >> N >> M;
    cout << N*(N-1)/2+M*(M-1)/2 << endl;
}

Measured memory_bytes: 256
S=input()
if S=='zyxwvutsrqponmlkjihgfedcba':
  print(-1)
  exit()
alp='abcdefghijklmnopqrstuvwxyz'
N=len(S)
if N<26:
  T=S+alp
  i=0
  while T.index(alp[i])<N:
    i+=1
  print(S+alp[i])
  exit()
  
i=-1
nums=[alp.index(S[i])]
while max(nums)==nums[-1]:
  i-=1
  nums.append(alp.index(S[i]))

out=S[:-len(nums)]
tmp=26
for i in nums[:-1]:
  if i>nums[-1] and tmp>i:
    tmp=i
    
print(out+alp[tmp])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s1,s2,s3;
  int i=0;
  int flag=1;
  int a,b,c;

  cin>>s1>>s2>>s3;

  while(1){
    if(flag==1){
      if(s1[i]=='\0') break;
      if(s1[i]=='a'){
	s1.erase(0,1);
	flag=1;
      }else if(s1[i]=='b'){
	s1.erase(0,1);
	flag=2;
      }else if(s1[i]=='c'){
	s1.erase(0,1);
	flag=3;
      }
    }else if(flag==2){
      if(s2[i]=='\0') break;
      if(s2[i]=='a'){
	s2.erase(0,1);
	flag=1;
      }else if(s2[i]=='b'){
	s2.erase(0,1);
	flag=2;
      }else if(s2[i]=='c'){
	s2.erase(0,1);
	flag=3;
      }
    }else  if(flag==3){
      if(s3[i]=='\0') break;
      if(s3[i]=='a'){
	s3.erase(0,1);
	flag=1;
      }else if(s3[i]=='b'){
	s3.erase(0,1);
	flag=2;
      }else if(s3[i]=='c'){
	s3.erase(0,1);
	flag=3;
      }
    }
  }

  if(flag==1) cout<<'A'<<endl;
  if(flag==2) cout<<'B'<<endl;
  if(flag==3) cout<<'C'<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

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

int INF = 1e9+7;

int main(){

  int N;
  cin >> N;

  string S;
  cin >> S;

  vector<int> e_cnt(N+1, 0);
  vector<int> w_cnt(N+1, 0);

  rep(i, N){
    if(S[i] == 'E'){
      e_cnt[i+1] = e_cnt[i] + 1;
      w_cnt[i+1] = w_cnt[i];
    }else{
      e_cnt[i+1] = e_cnt[i];
      w_cnt[i+1] = w_cnt[i] + 1;
    }
  }

  int ans = INF;
  for(int i=1; i<=N; i++){
    int left = w_cnt[i-1];
    int right = e_cnt[N] - e_cnt[i];

    ans = min(ans, left + right);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll a, b;
    cin >> a >> b;

    if(a%2 == 0 || b%2 == 0) {
        out("Even");
    }
    else {
        out("Odd");
    }

    re0;
}

Measured memory_bytes: 256
A,B,C,X,Y=map(int,input().split())
key=A/2+B/2
if C>=key:
  print(A*X+B*Y)
else:
  if X>=Y:
    Key=X-Y
    if Key*C*2<=Key*A:
      print(C*2*X)
    else:
      print(C*2*Y+A*Key)
  else:
    Key=Y-X
    if Key*C*2<=Key*B:
      print(C*2*Y)
    else:
      print(C*2*X+B*Key)

Measured memory_bytes: 3064
N=input()

ans=0
r_a_cnt=0
l_b_cnt=0
both=0

for _ in range(N):
	s=raw_input()
	if s[0]=="B" and s[-1]=="A": both+=1
	elif s[0]=="B": l_b_cnt+=1
	elif s[-1]=="A": r_a_cnt+=1

	len_s=len(s)
	for i in range(len_s-1):
		if s[i:i+2]=="AB":
			ans+=1

if l_b_cnt==r_a_cnt==0 and both>0:
	ans+=both-1
else:
	ans+=min( l_b_cnt+both , r_a_cnt+both)

print ans


Measured memory_bytes: 33004
//Bismillahir Rahmanir Rahim 
#include<bits/stdc++.h>

using namespace std;

#define ll long long 
#define gcd(a,b) __gcd(a,b)
#define endl '\n'
const int N=2e5+10;
const int inf=1e9;
const int mod=1e9+7;

int  main(int argc, char const *argv[])
{
	/*#ifndef ONLINE_JUDGE
      freopen("input.txt","r",stdin);
      freopen("output.txt","w",stdout);
    #endif*/
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);

	int n;
	cin >> n;

	map<string,int>m;

	for(int i=0; i<n; i++)
	{
		string s;
		cin >> s;

		sort(s.begin(), s.end());
		m[s]++;
	}

	ll ans=0;

	for(auto it: m)
	{
		ll val=it.second;
		val--;
		val*=(val+1);
		val/=2;
		ans+=val;
	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 11264
#include <iostream>
#include <algorithm>

using namespace std;

int main(){

  int n,a,b,count=0,i,j;
  
  cin >> n >> a >> b;
  while(n!=0){
    count = n;
    if(a<b) swap(a,b);
    int ar[1000010]={};
    ar[a]=1;
    ar[b]=1;
    for(i=1;i<=n;i++){
      if(i-a>0)
	if(ar[i-a]==1) ar[i] = 1;
      if(i-b>0)
	if(ar[i-b]==1) ar[i] = 1;
      count -= ar[i];
    }
    cout << count << endl;
    cin >> n >> a >> b;
  }
  
  return 0;
}

Measured memory_bytes: 5072
N = int(input())
H = list(map(int, input().split()))

count = 0
c_max = 0
for i in range(N-1):
    if H[i] >= H[i+1]:
        count += 1
    else:
        if c_max < count:
            c_max = count
        count = 0

print(max(c_max, count))

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

int main(){
	int A, B, C, D;
	int N;
  int res;
	string out="";
	cin >> N;
	A = N / 1000;
	B = (N / 100) % 10;
	C = (N / 10) % 10;
	D = N % 10;
  
	for(int i=0;i<2;i++){
		for(int j=0;j<2;j++){
			for(int k=0;k<2;k++){
				res = A;
    		out = to_string(A);
				if(i==0){
		  		res += B;
				  out += "+";
				}else{
					res -= B;	
			    out += "-";	
				}
				out += to_string(B);
        
				if(j==0){
			    res += C;
				  out += "+";
				}else{
			    res -= C;
			    out += "-";
		    }
				out += to_string(C);
				
				if(k==0){
  		    res += D;
	  	    out += "+";
	  	  }else{
	  		  res -= D;	
	        out += "-";	
		    }
				out += to_string(D);
				if(res==7){
					cout << out << "=7" << endl;
					return 0;
				}
			}
		}
	}

}


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

int main() {
  int a, b;
  string s, ans;
  cin >> a >> b;
  cin >> s;
  ans = "Yes";
  rep (i, a + b) {
    if (i == a) {
      if (s.at(i) != '-') {
        ans = "No";
        break;
      }
    }else{
      if (s.at(i) < '0' || '9' < s.at(i)) {
        ans = "No";
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int h, a, s,s2;
            string[] i = Console.ReadLine().Split(' ');
            h = int.Parse(i[0]);
            a = int.Parse(i[1]);

            s = h / a;
            s2 = h % a;

            if(s2!=0)
            {
                s++;
            }

            Console.WriteLine(s);

        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

struct UnionFind {
	vector<int> par, rank;
	vector<int> cnt;
	
	UnionFind(int n) {
		par.resize(n);
		rank.resize(n);
		cnt.resize(n);
		REP(i, n) {
		 par[i] = i;
		 rank[i] = 0;
		 cnt[i] = 1;
		}
	}
	
	int operator[] (int x) {
		return find(x);
	}
	
	int find(int x) {
		if (x == par[x]) return x;
		return par[x] = find(par[x]);
	}
	
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return;
		
		if (rank[x] < rank[y]) swap(x, y);
		
		par[y] = x;
		cnt[x] += cnt[y];
		if (rank[x] == rank[y]) rank[x]++;
	}
	
	bool same(int x, int y) {
		return find(x) == find(y);
	}
	
	int size(int x) {
		return cnt[find(x)];
	}
	
};

int N;
vector<int> point[112345];

int main() {
	cin >> N;
	
	REP(i, N) {
		int x, y;
		scanf("%d %d", &x, &y);
		point[x].push_back(y);
	}
	
	UnionFind uf(112345);
	ll ans = 0;
	REP(x, 112345) {
		if (point[x].empty()) continue;
		FOR(i, 1, point[x].size()) {
			uf.unite(point[x][i], point[x][i - 1]);
		}
	}
	
	REP(x, 112345) {
		if (point[x].empty()) continue;
		ll plus = uf.size(point[x][0]) - point[x].size();
		ans += plus;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 5760
import sys

S = input()
len_S = len(S)

if S == S[::-1]:
    if S[:(len_S - 1) // 2] == S[:(len_S - 1) // 2][::-1]:
        if S[(len_S + 3) // 2 - 1:] == S[(len_S + 3) // 2 - 1:][::-1]:
            print('Yes')
            sys.exit(0)
print('No')


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


int main(){


    int n, i;

    int m = 0;


    cin >> n;


    vector<int> a(n + 1);

    vector<int> l(n + 2);

    vector<int> r(n + 2);


    for( i = 1 ; i < n + 1 ; i = i + 1 ){

         cin >> a.at(i);

         }


    for( i = 1 ; i < n + 1 ; i = i + 1 ){

         l.at(i) = max( m, a.at(i) );

         m = max( m, a.at(i) );

         }


    m = 0;


    for( i = n ; i > 0 ; i = i - 1 ){

         r.at(i) = max( m, a.at(i) );

         m = max( m, a.at(i) );

         }


    for( i = 1 ; i < n + 1 ; i = i + 1 ){

         cout << max( l.at(i - 1), r.at(i + 1) ) << endl;

         }

    
    return 0;


    }

Measured memory_bytes: 3968
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX 110
#define NUM 20
#define XY 10

vector<pair<int,int>> G[MAX];

int d[MAX][MAX][NUM];

int can[MAX][MAX];

int ini;
int N, M, E, S, T, R;

int dijkstra(int s, int g){
	priority_queue<pair<pair<int,int>,pair<int,int>>,vector<pair<pair<int,int>,pair<int,int>>>,greater<pair<pair<int,int>,pair<int,int>>>> q;
	
	
	if(!R) return -1;
	
	for(int i = 0; i <= N; i++){
		for(int j = 0; j <= R; j++){
			for(int k = (1<<E); k >= 0; k--){
				d[i][j][k] = INF;
			}
		}
	}
	
	d[s][0][ini] = 0;
	q.push(make_pair(make_pair(0ll,0ll),make_pair(s,ini)));
	
	while(!q.empty()){
		pair<pair<int,int>,pair<int,int>> p = q.top();q.pop();
		int v = p.second.first, r = p.first.second;
		
		
		if(d[v][r][p.second.second] < p.first.first) continue;
		// cout<<"----------------------   r "<<r<<endl;
		// cout<<"v = "<<v<<" COST "<<p.first.first<<" "<<p.second.second<<endl;
		if(v == g) return p.first.first;
		
		if(r <= R){
			if(d[s][0][p.second.second | ini]  > d[v][r][p.second.second] + 1){
				d[s][0][p.second.second | ini]  = d[v][r][p.second.second] + 1;		
				q.push(make_pair(make_pair(d[s][0][p.second.second | ini],0),make_pair(s,p.second.second | ini)));
		}
		if(r == R) continue;
		
		for(pair<int,int> e : G[v]){
			// cout<<v<<" -- "<<e.first<<" f s "<<e.second<<endl;
			
				// cout<<v<<" <> "<<e.first<<" "<<can[v][e.first]<<" "<<p.second.second<<endl;
			if(can[v][e.first] && !(can[v][e.first] & p.second.second)) {
				// cout<<v<<" () "<<e.first<<" "<<can[v][e.first]<<" "<<p.second.second<<endl;
				continue;
			}
			e.second |= p.second.second;
			// cout<<d[e.first][r+1][e.second]<<" > "<< d[v][r][p.second.second] + 1<<endl;
			if( d[e.first][r+1][e.second]  > d[v][r][p.second.second] + 1){
					d[e.first][r+1][e.second]  = d[v][r][p.second.second] + 1;
					q.push(make_pair(make_pair(d[e.first][r+1][e.second],r+1),make_pair(e.first,e.second)));
				}
			}
		}
	}
	return -1;
}


signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int a, b, c;
	vector<int> tx;
	cin>>N>>M>>E>>S>>T>>R;
	
	for(int i = 0; i < M; i++){
		cin>>a>>b;
		G[a].push_back(make_pair(b,0));
		G[b].push_back(make_pair(a,0));
	}
	
	for(int i = 0; i < E; i++){
		cin>>a>>b>>c;
		if(c == S) ini = (1<<i);
		
		G[a].push_back(make_pair(b,0));
		G[b].push_back(make_pair(a,0));
		
		can[a][b] = (1<<i);
		can[b][a] = (1<<i);
		
		tx.push_back(c);
		// cout<<"C = "<<c<<endl;
		
		
	}
	
	for(int i = 0; i < E; i++){
		for(int j = 0; j < N; j++){
			for(int k = 0; k < G[j].size(); k++){
				if(G[j][k].first == tx[i]) {
					G[j][k].second = (1<<i);
				}
			}
		}
	}
	
	cout<<dijkstra(S,T)<<endl;
	
	return 0;
}


Measured memory_bytes: 4776
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const ll INF=1e+18;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

int main(){
    ll N;
    cin>>N;
    vector<ll> L(N);
    REP(i,N) cin>>L[i];
    sort(ALL(L));
    ll ans=0;
    REP(i,N){
        REP(j,i+1){
            REP(k,j+1){
                ll l1=L[i];
                ll l2=L[j];
                ll l3=L[k];
                if(l1==l2||l2==l3||l3==l1) continue;
                if((l1+l2>l3)&&(l2+l3>l1)&&(l3+l1>l2)) ans++;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

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

int main() {
	int n,k;
	cin >> n >> k;
	vector<long> h(n);
	rep(i,n) {
		cin >> h[i];
	}
	vector<long> dp(n);
	dp[0] = 0;
	for(int i=1; i<n; i++) {
		for(int j=1; j<=min(i,k); j++) {
			if(j==1) dp[i] = abs(h[i]-h[i-j]) + dp[i-j];
			else dp[i] = min(dp[i], abs(h[i] - h[i - j]) + dp[i - j]);
		}
	}
	cout << dp[n-1] << endl;
  return 0;
}


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

int main() {

    int n, k;

    cin >> n >> k;

    vector<long long int> hp;

    for(int i = 0; i < n; ++i) {
        long long int a;
        cin >> a;

        hp.push_back(a);
    }

    sort(hp.begin(), hp.end(), greater<int>());

    long long int sum = 0;

    for(int i = k; i < n; ++i) {

        sum += hp[i];
    }

    cout << sum << endl;

    return 0;


}

Measured memory_bytes: 2420
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;

namespace AtCoder
{
    class Point
    {
        public readonly int x;
        public readonly int y;
        public Point(int[] args)
        {
            x = args[0];
            y = args[1];
        }
    }
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        private static double[] Solve(int N, Point[] points)
        {
            var probs = new double[N];
            for (int i = 0; i < N; ++i)
            {
                var a = new List<double>();
                var b = new List<double>();
                for (int j = 0; j < N; ++j)
                {
                    if (i != j)
                    {
                        Point p1 = points[i];
                        Point p2 = points[j];
                        double rad = Math.Atan2(p2.y - p1.y, p2.x - p1.x);
                        a.Add(rad);
                        b.Add((rad < 0) ? rad + Math.PI * 2 : rad);
                    }
                }
                a.Sort();
                b.Sort();
                double theta = Math.Min(a.Last() - a.First(), b.Last() - b.First());
                probs[i] = Math.Max((Math.PI - theta) / (Math.PI * 2), 0);
            }
            return probs;
        }

        static void Main(string[] args)
        {
            int N = ReadInt();
            var points = new Point[N];
            for (int i = 0; i < N; ++i)
            {
                points[i] = new Point(ReadInts());
            }
            foreach (double prob in Solve(N, points))
            {
                Console.WriteLine(prob);
            }
        }
    }
}


Measured memory_bytes: 13396
from sys import stdin

n, k, q = map(int, input().split())
a = []
for i in range(q):
    a.append(int(input()))


p = [0]*n

for i in range(q):
    p[a[i]-1] +=1

s = sum(p)

for i in range(n):
    if k - s + p[i]  >0:
        print("Yes")

    else :
        print("No")

Measured memory_bytes: 8592
n,m,*X=map(int,open(0).read().split())
E=[0]*(max(X)+1)
P=[0]*m
M=[0]*m
for x in X:E[x]+=1;M[x%m]+=1
for i,e in enumerate(E):P[i%m]+=e//2
ans=0
min=lambda a,b: a if a<b else b
for i in range(m//2+1):
	if i==0 or i*2==m:
		ans+=M[i]//2
	else:
		l=min(M[i],M[(m-i)%m])
		ans+=l+min((M[i]-l)//2,P[i])+min((M[(m-i)%m]-l)//2,P[(m-i)%m])
print(ans)

Measured memory_bytes: 14324
#include <vector>
#include <cstdio>
#include <algorithm>
using namespace std;

int main() {
  int H, W, D; scanf("%d %d %d", &H, &W, &D);
  int px[90001], py[90001];
  int d[90001]={0};
  long long ans;
  for(int i = 0; i < H; ++i) {
    for(int j = 0; j < W; ++j) {
      int A; scanf("%d", &A);
      px[A] = i;
      py[A] = j;
    }
  }
  for(int i =D+1; i <= H*W; ++i) {
    d[i] = d[i-D] + abs(px[i] - px[i-D]) + abs(py[i] - py[i-D]);
  }
  int Q; scanf("%d", &Q);
  for(int i = 0; i < Q; ++i) {
    int L, R; scanf("%d %d", &L, &R);
    printf("%d\n", d[R] - d[L]);
  }

  return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

signed main(){

  vector<int> a(5);
  for(int i = 0; i < 5; i++){
    cin >> a[i];
    if(a[i] == 0){
      cout << i+1 << endl;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <stdio.h>
#include <complex.h>
#include <algorithm>
using namespace std;

int main()
{
    long long n, a[200001];
    long long ans = 10000000;

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

    sort(a, a+n);
    long long b = a[n / 2];
    long long sum = 0;
    for(int j = 0; j < n; j++)
      sum += abs(a[j] - b);

    cout << sum <<endl;

    return 0;
}


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

int main() {
  int N,M;
  cin >> N >> M;
 
 vector<vector<char>> data(N,vector<char>(M,'.'));
 
 for (int i=0;i<N;i++){
     for (int j=0; j<M;j++){
        cin >> data[i][j];
     }
 }
 
 
  for (int i=0;i<N;i++){
      int x=0;
     for (int j=0; j<M;j++){
        if(data[i][j]=='#') x++;
     }
     if (x==0){
         for (int j=0;j<M;j++){
             data[i][j]='-';
         }
     }
  }
  
  for (int j=0;j<M;j++){
      int x=0;
      for (int i=0;i<N;i++){
          if(data[i][j]=='#') x++;
      }
      if(x==0){
          for(int i=0;i<N;i++){
              data[i][j]='-';
          }
      }
  }
  
  for(int i=0;i<N;i++){
      int x=0;
      for(int j=0;j<M;j++){
          if(data[i][j]!='-') {
              cout << data[i][j];
              x++;
          }
      }
      if(x!=0) cout <<endl;
  }
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def main():
    n = int(input())
    h_list = list(map(int, input().split()))

    dp = [0] + [9999999999] * (n - 1)

    for i in range(n):
        for j in range(1, 3):
            if i - j >= 0:
                dp[i] = min(dp[i], dp[i - j] + abs(h_list[i] - h_list[i - j]))

    print(dp[-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 13924
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let a: Vec<usize> = sc.vec(n);
    if a.into_iter()
        .filter(|&a| a % 2 == 0)
        .all(|a| a % 3 == 0 || a % 5 == 0)
    {
        println!("APPROVED");
    } else {
        println!("DENIED");
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

#define rep(a,b) for(ll ii=a;ii<b;ii++)
#define ll long long int
#define test() int tt; cin>>tt; while(tt--) 
#define fst_io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl '\n'

int main()
{
  int t,c=0;
  float calc,n,x;
  cin>>n>>x>>t;

  calc = ceil(n/x);
  cout<<std::fixed<<std::setprecision(0)<<calc*t;
  return 0;
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
#define ll long long
//#define fr(i,j,k) for(int i=j;i<k;i++)
//#define f(n) fr(i,0,n)
//#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
const ll mod = 998244353;
const int maxn = 1e5+5;
#include<atcoder/all>
using namespace atcoder;
ll pre[maxn];
ll inv[maxn];
ll prei[maxn];
ll inv2[maxn];
void build(int n){
    pre[1] = pre[0] = 1, inv[1] = inv[0] = 1, prei[1] = prei[0] = 1;
    for(int i = 2 ; i <= n ; i++){
        pre[i] = pre[i-1] * i % mod;
        inv[i] = (mod - mod / i * inv[mod % i] % mod) % mod;
        prei[i] = prei[i-1] * inv[i] % mod;
    }
}
ll C(int n, int k){
   return pre[n] * prei[k] % mod * prei[n-k] % mod;
}
ll P(int n, int k) {
    return pre[n] * prei[n - k] % mod;
}
ll pm(int n,int p){
    ll ret = 1;
    ll now = n;
    while(p){
        if(p & 1){
            ret *= now;
            ret %= mod;
        }
        now *= now;
        now %= mod;
        p >>= 1;
    }
    return ret;
}
vector<ll>get(int x) {
    vector<ll>ret{1};
    for (int  i = 1 ; i <= x / 2 ; i++) {
        //cout << P(x, 2 * i) << '\n';
        //cout << inv2[i] << '\n';
        //cout << prei[i] << '\n';
        ret.pb(P(x,2*i) * inv2[i] % mod * prei[i] % mod);
    }
    /*for (auto &i:  ret) {
        cout << i <<' ';
    }
    cout << endl;*/
    return ret;
}
void solve() {
    int x;
    int n;
    cin >> n;
  n *= 2;
    map<int,int>mp;
    for(int i = 0 ; i < n ; i++) {
        int x;
        cin >> x;
        mp[x]++;
    }
    priority_queue<pair<int,vector<ll>>,vector<pair<int,vector<ll>>>,greater<pair<int,vector<ll>>>>pq;
    for (auto &i : mp) {
        auto x = get(i.S);
        pq.push({x.size(),x});
      /*for (auto &i : x) 
        cout <<i <<' ';
      cout << endl;*/
    }
    while (pq.size() > 1) {
        auto A = pq.top().S;
        pq.pop();
        auto B = pq.top().S;
        pq.pop();
        auto C =convolution<998244353>(A,B);
        pq.push({C.size(),C});
      /*for (auto &i :C) 
        cout << i <<' ';
      cout << endl;*/
    }
    ll ans = 0;
    x = 0;
    auto C = pq.top().S;
    for (int i = 0 ; i < C.size() ; i++) {
        if (!x) {
            int j = (n - i * 2) / 2;
            ans += C[i] * P(j*2,j*2) % mod* inv2[j] % mod * prei[j] % mod;
            ans %= mod;
        }
        else {
          int j = (n - i * 2) / 2;
            ans -= C[i] * P(j*2,j*2) % mod* inv2[j] % mod * prei[j] % mod;
            ans += mod;
            ans %= mod;
        }
        x ^= 1;
    }
    cout << ans << '\n';
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    inv2[0] = 1;
    for(int i = 1 ; i<= 100000 ; i++) {
        inv2[i] = inv2[i - 1] * 499122177 % mod;
    }
    build(100000);
    int c = 0;
    int t;
    if (!c) {
        t = 1;
    }
    else {
        cin >> t;
    }
    while (t--) {
        solve();
    }
    
}

Measured memory_bytes: 17392
using DataStructures
parseline(str) = parse.(Int, split(str))
function Teleporter()
    N, K = parseline(readline())
    A = parseline(readline())
    route = zeros(Int, N)
    visited = zeros(Int, N)
    route[1] = A[1]
    visited[A[1]] = 1 
    pre = 0
    for k in 2:K
        a = A[route[k-1]]
        visited[a]==1 && (i=findfirst(route.==a);pre=length(route[1:i-1]);route = route[i:k-1]; break)
        visited[a] = 1
        route[k] = a
    end
    println(route[(K-pre-1)%length(route)+1])
end
Teleporter()

Measured memory_bytes: 217728
#include <iostream>

using namespace std;
using ll = long long;

#define IN_LL(v) ll v;cin>>v;
#define OUT(v) cout<<v<<endl

int main() {
  IN_LL(x);

  ll sum = x / 11 * 11;
  ll ans = x / 11 * 2;
  int i = 0;
  while (sum < x) {
    sum += 5 + ((i+1) % 2);
    i = (i+1) % 2;
    ++ans;
  }
  OUT(ans);

  return 0;
}


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

int main() {
    int64_t N, count = 0, ans = 0;
    cin >> N;
    vector<int> S(N);
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        if (a < 0) {
            count++;
            a *= -1;
        }
        S.at(i) = a;
    }
    if (count % 2 == 1) {
        sort(S.begin(), S.end());
        S.at(0) *= -1;
    }
    for (int i = 0; i < N; i++) {
        ans += S.at(i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
import sys
import math
from collections import deque
import itertools
import copy
import bisect

MOD = 10 ** 9 + 7
INF = 10 ** 18 + 7
input = lambda: sys.stdin.readline().strip()

n = int(input())
A = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))

p = set(sum(t) for i in range(n) for t in itertools.combinations(A, i+1))

for i in m:
    if i in p:
        print("yes")
    else:
        print("no")



Measured memory_bytes: 6416
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S,T;
  cin >> S >> T;
  int n;
  n = S.length();

  for (int i = 0; i < n; i++) {
    if(S[i]!=T[i]){
        cout << "No" <<endl;
        n = 100;
        break;
    }
  }
  
    if (n != 100){
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 3512
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>
    #include<cstdint>
using namespace std;

bool seen[55][55];
vector<vector<int>> s(55, vector<int>(55));
int w, h;
void dfs(int y, int x){
    seen[y][x] = true;

    for(int i = -1; i <= 1; i++){
        for(int j = -1; j <= 1; j++){
            if(i == 0 && j == 0)continue;
            int ny = y + i, nx = x + j;
            
            if(ny < 0 || ny >= h || nx < 0 || nx >= w)continue;
            if(seen[ny][nx])continue;
            if(s[ny][nx] != 1)continue;
            dfs(ny, nx);
        }
    }
}
int main(){
    while(cin >> w >> h){
    if(w == 0 && h == 0)return 0;
    for(int i = 0; i < h; i++)for(int j = 0; j < w; j++){cin >> s[i][j];seen[i][j] = false;}
    int cnt = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(seen[i][j])continue;
            if(s[i][j] == 0)continue;
            cnt++;
            dfs(i, j);
        }
    }
    cout << cnt << endl;
    }
}


Measured memory_bytes: 3352
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define F first
#define S second
//#define biGinf 9e+18
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define inpv(v) for(auto &x:v) cin>>x
#define otpv(v) for(auto &x:v) cout<<x<<nwl
#define otpv2(v) for(auto &x:v) cout<<x<<" "
#define CASES int tt;cin>>tt; while(tt--)
#define for0(i,n) for(int i=0; i<n; i++)
#define for1(i,n) for(int i=1; i<=n; i++)
#define sz(v) (int)(v).size()
#define vec(x) vector < x >
using vi = vector < int >;
using vvi = vector < vi >;
using pii = pair < int , int >;
using vpii = vector < pii >;
using int64 = long long;
//const int64 biGinf = 9e+18;
//const string yo = "YES", no = "NO";
const int inf = 2e9 + 7;
const char nwl = '\n';

int main() {
// #ifndef ONLINE_JUDGE
// 	if (fopen("input.txt", "r")) {
// 		freopen("input.txt", "r", stdin);
// 		freopen("output.txt", "w", stdout);
// 	}
// #endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//ur code
	int n;
	cin >> n;
	if (n % 1000) {
		cout << (1000 - n % 1000);
	} else {
		cout << 0;
	}


	return 0;
}

Measured memory_bytes: 3648
#pragma GCC optimize("O3")
/*{{{*/
#include <bits/stdc++.h>
#ifdef LOCAL
int c_ = 0;
#define cout (c_?cerr:cout)
#define debug(...) \
{if(!c_++)cerr<<"\033[96;1m"; \
__VA_ARGS__; \
if(!--c_)cerr<<"\033[0m";}
#else
#define debug(...) {}
#endif
#define assrt(...) debug(\
if (not (__VA_ARGS__)) \
    exit((cerr << __LINE__ << ": " << #__VA_ARGS__ << '\n', 0));\
)
#define st first
#define nd second
#define all(...) (__VA_ARGS__).begin(), (__VA_ARGS__).end()
using namespace std; using ll = long long;
template < typename t > using V = vector< t >;
template < typename t, size_t s > using A = array< t, s >;
void print() {cout << '\n';}
template< typename t, typename... v >
void print(const t& a, const v&... b)
{cout << a << (sizeof...(b)?" ":""); print(b...);}
template< typename t > void print_range(t a, const t& b)
{ while (a != b) cout << (*a++) << ' '; cout << '\n';}
#define dump(...) debug(print(#__VA_ARGS__,'=',__VA_ARGS__))
#define dump_range(...) debug(cerr<<#__VA_ARGS__ << ": "; print_range(__VA_ARGS__))
/*}}}*/



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

    ll n; cin >> n;

    ll a = 1e18;
    for (int i = 0; i < 5; ++i)
    {   
        ll v; cin >> v;
        a = min(a, v);
    }

    cout << (4 + (n + a - 1) / a) << '\n';

}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	
	// a < b
	public static int gcv(int a, int b){
		if(b % a == 0){
			return a;
		}
		
		int mod = b % a;
		
		return gcv(mod, a);
	}
	
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		LinkedList<Integer> monsters = new LinkedList<>();
		
		// input
		int num = scan.nextInt();
		for(int i = 0; i < num; i++){
			monsters.add(scan.nextInt());
		}
		
		// check
		Collections.sort(monsters);
		while(monsters.size() > 1){
			monsters.push(gcv( monsters.pop(), monsters.pop()));
		}
		
		// answer
		System.out.println(monsters.pop());
	}
}

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

#define ll long long int
#define db double
#define fl float
#define endl '\n'

#define mod (ll)(1000000007)
#define mod1 (ll)998242353
#define mod2 (ll)998244353
#define PI 3.1415926535897932384626433832795

#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp(x,y) make_pair(x,y)
#define pb push_back
#define pob pop_back

#define Sort(v) sort(v.begin(),v.end())
#define Sortd(v) sort(v.begin(),v.end(),greater<>())

#define f(i,n) for(int i=0;i<n;i++)
#define f1(i,n) for(int i=1;i<n;i++)
#define rf(i,n) for(int i=n-1;i>=0;--i)
#define rf1(i,n) for(int i=n-1;i>=1;--i)
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repn(i,a,b) for(int i=a;i<=b;++i)

#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<vi> vvi;
typedef priority_queue<int> pqi;
typedef priority_queue<ll> pql;

//nC2
ll C2(ll n){
    ll ans= max(((n*(n-1))/2),(ll)0);
    return ans;
}
//square
ll sq(ll n){
    return n*n;
}

//GCD
ll gcd(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    if(b==0){
        return a;
    }    
    else{
        return gcd(b,a%b);
    }
}

//sort pair by second values
bool sortsec(const pair<ll,ll> &a, const pair<ll,ll> &b){ 
    return (a.second < b.second); 
}


//Binary Exponentiation
ll BinExp(ll a, ll b, ll m){
    a%=m;
    ll res =1;
    while(b>0){
        if(b&1){
            res = (res * a)%m;
        }
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}


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

    string s;
    cin>>s;
    if(s.back()!='s'){
        s+='s';
    }
    else{
        s+="es";
    }
    cout<<s<<endl;
    

    


    return 0;
}



Measured memory_bytes: 3664
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>

using namespace std;

typedef long long int ll;
typedef long int li;


int main(void){
    int ans1=0;
    int ans2=0;
    int n,a,b;
    cin >> n >> a >> b;
    ans2=a+b-n;
    ans2=max(0,ans2);
    ans1=min(a,b);
    
    cout << ans1 << " " << ans2 << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
signed main(){
  int n,dp[100005][4],ans;
  cin>>n;
  for(int j=0;j<3;j++){
    dp[0][j]=0;
  }
  
  for(int i=1;i<n+1;i++){
    cin>>dp[i][0]>>dp[i][1]>>dp[i][2];
  }
  
  for(int i=1;i<n+1;i++){
    dp[i][0]+=max(dp[i-1][1],dp[i-1][2]);
    dp[i][1]+=max(dp[i-1][0],dp[i-1][2]);
    dp[i][2]+=max(dp[i-1][0],dp[i-1][1]);
  }

  ans = max(dp[n][0] , max(dp[n][1],dp[n][2]) );
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 1792
/*
AizuOnline A0515
Title school road
13/02/02 WA
*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
//#include <string.h>
//#include <float.h>
//#include <math.h>
//#include <limits.h>
#define DEBUG 1
//Global data section
int a,b,n;
int kx[500],ky[500];  //kojichuu
int ways[500][500];
//
int isTukoDome(int x,int y)
{
  int i;
  for(i=0;i<n;i++)
    if(x==kx[i] && y == ky[i])
      return(1);
  return(0);
}
void print()
{
  int i,j;

  for(j=b;j>=1;j--)
    {
      for(i=1;i<=a;i++)
	printf("%d",ways[i][j] % 10);
      printf("\n");
    }
}

main()
{
  int i,j;

  while(EOF != scanf("%d %d",&a,&b) &&( a || b))
    {
      scanf("%d",&n);
      for(i=0;i<n;i++)
	{
	  scanf("%d %d",&kx[i],&ky[i]);
	}
 
      for(i=1;i<=a;i++)
	  for(j=1;j<=b;j++)
	    if(isTukoDome(i,j))
	      {
		//printf("KJ %d %d %d\n",kx[0],ky[0],isTukoDome(1,1));
	      	      ways[i][j]=0;

	      }
	    else if (i==1 && j==1)
	      {
		//printf("OP\n");
		ways[i][j]=1;
	      }
	    else if (i==1)
	      ways[i][j]=ways[i][j-1];
	    else if (j ==1)
	      ways[i][j]=ways[i-1][j];
            else
	      ways[i][j]=ways[i][j-1]+ways[i-1][j];
#ifdef DEBUG
      //print();
#endif	
      printf("%d\n",ways[a][b]);
    }
return(0);
}

Measured memory_bytes: 636
N,D = gets.split.map(&:to_i)
X = N.times.map{gets.split.map(&:to_i)}

count = 0
(N-1).times {|i|
  (i+1).upto(N-1) {|j|
    d = D.times.map{|n| (X[i][n] - X[j][n])**2}.inject(:+)
    count += 1 if (d**0.5) % 1 == 0
  }
}

p count

Measured memory_bytes: 1916
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <limits.h>
#include <math.h>

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

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
const int INF = INT_MAX;
const ll MOD = 998244353;

ll extgcd(ll a, ll b, ll &x, ll &y) {
    ll g = a; x = 1; y = 0;
    if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
    return g;
}

int main() {
    // insert code here...    return 0;
    //////
    // input from txt
    /*
     std::ifstream in("input.txt");
     std::cin.rdbuf(in.rdbuf());
     std::ofstream out("output.txt");
     std::cout.rdbuf(out.rdbuf());
     ////
     */
    int N;
    cin >> N;
    vector<Pii> L(N),R(N);
    
    repeat(i, N){
        cin >> L[i].first >> R[i].first;
        L[i].second = R[i].second=i;
        L[i].first *= -1;
    }
    sort(L.begin(), L.end());
    sort(R.begin(), R.end());
    
    vector<Pii> idxlr(N);
    repeat(i, N){
        idxlr[L[i].second].first = i;
        idxlr[R[i].second].second = i;
    }
    
    vint used(N,0);
    ll K=0;
    int li=0,ri=0;
    int e = 1;
    int cur = 0;
    repeat(i, N){
        int next = 0;
        if(e == 1){
            while(used[L[li].second]){
                li++;
            }
            next = -L[li].first;
            used[L[li].second] = 1;
            int idx = L[li].second;
            if(-L[idxlr[idx].first].first <= cur && cur <= R[idxlr[idx].second].first){
                next = cur;
            }
        }else{
            while(used[R[ri].second]){
                ri++;
            }
            next = R[ri].first;
            used[R[ri].second] = 1;
            int idx = R[ri].second;
            if(-L[idxlr[idx].first].first <= cur && cur <= R[idxlr[idx].second].first){
                next = cur;
            }
        }
        K += abs(next-cur);
        e *= -1;
        cur = next;
        //cout << cur << endl;
    }
    K += abs(cur);
    ll ans = K;
    used.assign(N, 0);
    K = 0;
    li = 0;
    ri = 0;
    e = -1;
    cur = 0;
    repeat(i, N){
        int next = 0;
        if(e == 1){
            while(used[L[li].second]){
                li++;
            }
            next = -L[li].first;
            used[L[li].second] = 1;
            int idx = L[li].second;
            if(-L[idxlr[idx].first].first <= cur && cur <= R[idxlr[idx].second].first){
                next = cur;
            }
        }else{
            while(used[R[ri].second]){
                ri++;
            }
            next = R[ri].first;
            used[R[ri].second] = 1;
            int idx = R[ri].second;
            if(-L[idxlr[idx].first].first <= cur && cur <= R[idxlr[idx].second].first){
                next = cur;
            }
        }
        K += abs(next-cur);
        e *= -1;
        cur = next;
    }
    K += abs(cur);
    ans = max(ans,K);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 2944
N,Q = map(int,input().split())
S = str(input())
ans = [0]*(N+1)
ans[0] = 0
for i in range (N):
    if (S[i:i+2]) == 'AC':
        ans[i+1] = ans[i] + 1
    else:
        ans[i+1] = ans[i]

for k in range(Q):
    l,r = map(int,input().split())
    print(ans[r-1]-ans[l-1])


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    ll sufix[n+1];
    sufix[n] = 0;
    for(int i=n-1;i>=0;i--){
        sufix[i] = sufix[i+1] + a[i];
    }
    ll dif = 1e17, sum = 0;
    for(int i=0;i<n-1;i++){
        sum += a[i];
        dif = min(dif,abs(sum-sufix[i+1]));
    }
    cout<<dif<<"\n";
    return 0;
}




Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef vector< pii > vii;

#define ll          long long
#define ff          first
#define ss          second
#define pb          push_back
#define mkp         make_pair
#define sz          size()

#define forf(a,b,c)    for(int i=a;i<=b;i+=c)
#define forr(a,b,c)    for(int i=a;i>=b;i-=c)
#define all(a)      a.begin(),a.end()
#define mem(a,b)    memset(a,b,sizeof(a))
#define pi          2*acos(0.0)
#define End         return 0;
#define nl endl

#define scan1(a)    scanf("%d",&a)
#define scan2(a,b)  scanf("%d %d",&a,&b)
#define scan3(a,b,c)  scanf("%d %d %d",&a,&b,&c)
#define scanl(a)    scanf("%lld",&a)
#define scanll(a,b) scanf("%lld %lld",&a,&b)
#define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)

#define print1(a)    printf("%d",a)
#define print2(a,b)  printf("%d %d",a,b)
#define print3(a,b,c)  printf("%d %d %d",a,b,c)
#define printl(a)    printf("%lld",a)
#define printll(a,b) printf("%lld %lld",a,b)
#define printlll(a,b,c) printf("%lld %lld %lld",a,b,c)

#define MAXN        100000007
#define INF 0x3f3f3f3f
bool mark[100005];vi prime;
void seive(ll N){for(int i=2;i<=N;i++){if(mark[i]==false){prime.pb(i);for(int j=i+i;j<N;j+=i)mark[j]=true;}}}
//freopen("input.txt", "r", stdin);

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

   int n,a,b,mn,mx;
   cin>>n>>a>>b;
   mn=min(a,b);
   mn=n*mn;
   cout<<min(mn,b)<<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<queue>
#include <algorithm> 
#include<vector>
#include<unordered_map>
#include<string.h> 
#include<math.h>
#include <bits/stdc++.h> 
#define ll long long

#define  Int long long int 


 


ll arr[100004];
ll dp[100004];
int main()
{	
	ll n,k;
	cin>>n>>k;
	for(ll i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	dp[0]=0;

	for(ll i=1;i<n;i++)
	{
		dp[i]=dp[i-1]+abs(arr[i]-arr[i-1]);
		for(ll j=2;j<=k;j++)
		{
			if(i-j>=0)
			{
				dp[i]=min(dp[i-j]+abs(arr[i]-arr[i-j]),dp[i]);
			}
		}
	}
	cout<<dp[n-1]<<endl;

}



Measured memory_bytes: 1792
n,m = map(int, input().split())
mod = (10**9) + 7

if abs(n-m) > 1:
    print(0)
    exit()

li = sorted([n,m])

num = 1
for i in range(1,li[0]+1):
    num = (num * i) % mod
    
if li[1] - li[0] == 1:
    print((((num * li[1]) % mod) * num) % mod)
else:
    print((((num * num) % mod) * 2) % mod)

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

int main () {
  int a , b ;
  cin >> a >> b ;
  if(a==b){
    cout << a * 2 << endl ;
  } else {
    int pre = max(a,b) ;
    cout << 2 * pre - 1 << endl ;
  }
}

Measured memory_bytes: 256
def main():
    N = int(input())
    H = [int(x) for x in input().split()]
    if N == 1:
        print('Yes')
        return
    elif N == 2:
        if H[0] - H[1] > 1:
            print('No')
        else:
            print('Yes')
        return
    for idx in range(len(H)-2):
        #print(H[idx:idx+3])
        if H[idx] - H[idx+1] > 1 or H[idx] - H[idx+2] > 1:
            print('No')
            return
        if H[idx] - H[idx+1] == 1:
            H[idx+1] += 1
    print('Yes')


if __name__ == "__main__":
    main()


Measured memory_bytes: 63984
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String red = sc.next();
		String bule = sc.next();
		int A = sc.nextInt();
		int B = sc.nextInt();
		String ans = sc.next();
		
		if (ans.equals(red)){
			--A;
		}else{
			--B;
		}
		System.out.println(A + " " + B);
	
	}
}	

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    // Your code here!
    ll n,sum=0;
    cin>>n;
    vector<pair<string,ll>>a(n);
    rep(0,i,n){
        cin>>a[i].first>>a[i].second;
        sum+=a[i].second;
    }
    ll tmp=0;
    string x;
    cin>>x;
    rep(0,i,n){
        tmp+=a[i].second;
        if(a[i].first==x){
            cout<<sum-tmp;
            return 0;
        }
    }
}

Measured memory_bytes: 3580
using System;
using System.Linq;
public class Hello{
    public static void Main(){
        int [] n = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        if(n[0] < n[1] && n[1] < n[2]){
            System.Console.WriteLine("Yes");
        }else{
            System.Console.WriteLine("No");
        }
    }
}



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

int main(){
  int N, T;
  cin >> N >> T;
  
  int c[N];
  int t[N];
  int x = 1000;
  int h = 0;
  
  for(int i=0;i<N;i++){
    cin >> c[i] >> t[i];
    if(T >= t[i] && x >= c[i]){
      x = c[i];
      h++;
    }
  }
  
  if(h == 0){
    cout << "TLE";
  }
  else{
    cout << x;
  }
  
  return 0;
}
      





Measured memory_bytes: 256