akhauriyash/Code-Regression huggingface dataset:
// 2020-07-25 21:07:19
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  REP(i, k, n) {
    int j = i-k;
    if(a[j] < a[i]) {
      cout << "Yes" << '\n';
    } else {
      cout << "No" << '\n';
    }
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3972
import Data.List
main = do
    s <- readLn :: IO Int
    print $ solve [s]
        
solve :: [Int] -> Int
--solve path@(x:xs) = if next `elem` path then findIndex (==next) path else solve (next:path) 
solve path@(x:xs) = if next `elem` path then length path + 1 else solve (next:path) 
    where
        isEven = even x
        next = if isEven then x `div` 2 else 3*x + 1

Measured memory_bytes: 508
n = int(input())
s = input()

# print(n)
# print(s)

t1 = s[: (n // 2)]

# print(t1)

t2 = s[(n // 2) :]

# print(t2)

# print(t1)
# print(t2)

if t1 == t2:
    print('Yes')
else:
    print('No')

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

int main()
{
    string str;
    cin >> str;
    if (str.at(3) == str.at(2) && str.at(5) == str.at(4)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define LONG_LONG_MAX    9223372036854775807LL
#define LONG_LONG_MIN    (-LONG_LONG_MAX-1)



vector<vector<bool> >v;
vector<vector<int> >dp;
int n;

int ways(int men,int women){
    if(dp[men][women]!=-1){
        return dp[men][women];
    }
    int w=0;
   for(int i=0;i<n;i++){
        if((women&(1<<i)) && v[men][i]==1){
            w += ways(men+1,(women&(~(1<<i))));
            w %=mod;
        }
   }
   return dp[men][women] = w;
}

void solve(){
   cin>>n;
   v.resize(n,vector<bool>(n,0));
   for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
        int x;cin>>x;
        v[i][j]=x;
    }
   }
   int women = (1<<n)-1;
   dp.resize(n+1,vector<int>(women+1,-1));
   dp[n][0]=1;
   cout<<ways(0,women)<<"\n";

}

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

    cout.precision(10);
    int t=1;//cin>>t;
    while(t--){

        solve();
    }
    return 0;
}


Measured memory_bytes: 188800
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		if(n < 1200)System.out.println("ABC");
		else if(n < 2800)System.out.println("ARC");
		else System.out.println("AGC");
	}
}


Measured memory_bytes: 21844
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use itertools::Itertools;
use std::process::exit;
use std::cmp::*;
use num::*;
use num::integer::Roots;

fn main() {
    input! {
    a:usize,
    b:usize,
    c:[[String;b];a]
    }
    let mut v=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
    for i in 0..a{
        for j in 0..b {
            if c[i][j]=="snuke"{
                println!("{}{}",v[j],i+1)
            }
        }
    }
}

Measured memory_bytes: 2160
n, k = map(int, input().split())
w = [int(input()) for _ in range(n)]

def n_loads(P):
  num = 0
  for _ in range(k):
    w_sum = 0
    while num < n and w_sum + w[num] <= P:
      w_sum += w[num]
      num += 1
  return num

P_lb, P_min = 0, max(w)*(n//k + 1)
while P_min - P_lb > 1:
  P_mid = (P_lb + P_min) // 2
  if n_loads(P_mid) < n:
    P_lb = P_mid
  else:
    P_min = P_mid
print(P_min)


Measured memory_bytes: 9564
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b))<EPS)

const double PI=4*atan(1.0);

int main(){

    double r;
    while(cin>>r&&!EQ(r,0)){
        bool f=false;
        for(int i = 1; ; i++){
            int d[3];
            int j=(int)(i*PI+EPS);
            d[0]=j;d[1]=j+1;d[2]=j-1;
            for(int k = 0; k < 3; k++){
                j=d[k];
                if(EQ(abs(((double)j/i)-PI),r)||abs(((double)j/i)-PI)<r){
                    cout<<j<<"/"<<i<<endl;
                    f=true;
                    break;
                }
            }
            if(f)
                break;
        }
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    Int N, M; cin >> N >> M;
    vector<Int> A(N); for (auto &a : A) cin >> a;
    sort(begin(A), end(A), greater<int>());
    auto f = [&](int x, Int& sum) -> Int {
        int j = N - 1;
        Int ans = 0, s = 0;
        sum = 0;
        for (int i = 0; i < N; i++) s += A[i];
        for (int i = 0; i < N; i++) {
            while (j >= 0 && A[i] + A[j] < x) s -= A[j], j--;
            ans += j + 1;
            sum += s + (j + 1) * A[i];
        }
        return ans;
    };
    Int n = 0, sum = 0;
    int ok = 1, ng = 300000;
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        n = f(mid, sum);
        (n >= M ? ok : ng) = mid;
    }
    n = f(ok, sum);
    cout << sum - (n - M) * ok << endl;
    return 0;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

namespace
{
	void Func(string x, vector<int>& dst)
	{
		if (x.size() >= 9)
			return;
		string y1 = x + '3';
		set<char> z1;
		for (int i = 0; i < y1.size(); ++i)
		{
			z1.insert(y1[i]);
		}
		if(z1.size() == 3)
			dst.push_back(stoi(y1));

		string y2 = x + '5';
		set<char> z2;
		for (int i = 0; i < y2.size(); ++i)
		{
			z2.insert(y2[i]);
		}
		if (z2.size() == 3)
			dst.push_back(stoi(y2));
		string y3 = x + '7';
		set<char> z3;
		for (int i = 0; i < y3.size(); ++i)
		{
			z3.insert(y3[i]);
		}
		if (z3.size() == 3)
			dst.push_back(stoi(y3));
		Func(y1, dst);
		Func(y2, dst);
		Func(y3, dst);
	}
}
void ABC114C()
{
	vector<int> tmp;
	Func("", tmp);
	sort(tmp.begin(), tmp.end());

	int N;
	cin >> N;

	auto n = distance(tmp.begin(), upper_bound(tmp.begin(), tmp.end(), N));
	cout << n << endl;
}


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

Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <algorithm>
#include <unordered_map>
#include <vector>
#include <set>
#include <stack>
#include <numeric>
#include <chrono>
#include <bitset>
#include <tuple>
#include <queue>
#include <map>
#include <cstring>
#include <cassert>
#include <math.h>
using namespace std;

const int N = 1e6 + 10, mod = 1e9 + 7;

int trie[N][26];
int Cnt[N][26];
int sz = 1;

char buf[N];

int main() {
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int tc = 1;
    // scanf("%d", &tc);
    for(int cn = 1; cn <= tc; cn++) {
        int n; scanf("%d", &n);
        vector<string> s(n);
        vector<int> cnt(26, 0);
        for(int i = 0; i < n; i++) {
            scanf("%s", &buf);
            s[i] = buf;
            if(s[i].size() == 1) {
                cnt[s[i][0] - 'a']++;
                continue;
            }
            int u = 0;
            for(int j = (int)s[i].size() - 1; j > 0; j--) {
                int c = s[i][j] - 'a';
                if(!trie[u][c]) trie[u][c] = sz++;
                u = trie[u][c];
            }
            Cnt[u][s[i][0] - 'a']++;
        }
        long long ans = 0;
        for(int i = 0; i < n; i++) {
            if(s[i].size() == 1) continue;
            vector<int> mask(s[i].size(), 0);
            mask[0] = (1 << (s[i][0] - 'a'));
            for(int j = 1; j < s[i].size(); j++) mask[j] = (mask[j - 1] | (1 << (s[i][j] - 'a')));
            int u = 0;
            for(int j = s[i].size() - 1; j > 1; j--) {
                u = trie[u][s[i][j] - 'a'];
                for(int c = 0; c < 26; c++) {
                    if((mask[j - 1] >> c) & 1) ans += Cnt[u][c];
                }
            }
            for(int c = 0; c < 26; c++) {
                if((mask[s[i].size() - 1] >> c) & 1) ans += cnt[c];
            }
        }
        printf("%lld\n", ans);
    }
    return 0;
}

Measured memory_bytes: 154292
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <iomanip>
#include <functional>
#include <cassert>

using namespace std;

typedef long long ll;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  int x;
  cin >> x;
  vector <int> bounds = {400, 600, 800, 1000, 1200, 1400, 1600, 1800};
  for (int i = 0; i < (int)bounds.size(); ++i) {
    if (x >= bounds[(int)bounds.size() - i - 1]) {
      cout << i + 1 << '\n';
      return 0;
    }
  }   
}



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

int main() {
  int N;
  cin >> N;
  bool flag = false; 
  if(N%10 == 7) flag = true;
  N /= 10;
  if(N%10 == 7) flag = true;
  N /= 10;
  if(N%10 == 7) flag = true;
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3608
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
int main(){
	string s;
	cin>>s;
	long long num=0,sum=0;
	for(int i=0;i<s.length();i++){
		if(s[i]=='W'){
			num++;
			sum=sum+i+1-num; 
		}
		
	}
	cout<<sum<<endl;
} 

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main () {
    int n;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
        if (i) {
            if (h[i-1] > h[i]) {
                puts("No");
                return 0;
            }
            else if (h[i-1] < h[i]) {
                h[i]--;
            }
        }
      	else h[0]--;
    }
    puts("Yes");
}

Measured memory_bytes: 640
#include <iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
const int inf   = 1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

int h,w,d[51][51];
string s[51];
void bfs(){
  queue<pint> q;
  d[0][0]=0;
  q.push(pint(0,0));
  while(!q.empty()){
    pint p=q.front();q.pop();
    int x=p.first,y=p.second;
    int nx,ny;
    rep(i,4){
      nx=x+dx[i];ny=y+dy[i];
      if(0<=nx&&nx<h&&0<=ny&&ny<w){
        if(s[nx][ny]=='.'&&d[nx][ny]==inf){
          d[nx][ny]=d[x][y]+1;
          q.push(pint(nx,ny));
          }
        }
      }
    }
  }

int main(){
  cin>>h>>w;
  int cnt=0;
  rep(i,h){
    cin>>s[i];
    rep(j,w)
      if(s[i][j]=='#')cnt++;
    }
  rep(i,h)rep(j,w)d[i][j]=inf;
  bfs();
  if(d[h-1][w-1]==inf)cout<<-1<<endl;
  else cout<<h*w-d[h-1][w-1]-1-cnt<<endl;
  return 0;
  }

  
    


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int m;
    int n;
    int l;
    cin >>m>>n>>l;
    
    while (m!=-1||n!=-1){
        if(m==-1||n==-1){
            cout << "F"<<endl;
        }
        else if (m+n>=80){
            cout << "A"<<endl;
        }else if(m+n>=65){
            cout<< "B"<<endl;
        }else if(m+n>=50||l>=50){
            cout<< "C"<<endl;
        }else if(m+n>=30){
            cout<< "D"<<endl;
        }else{
            cout<<"F"<<endl;
        }
        cin >>m>>n>>l;
    }
    
   
    return 0;
}



Measured memory_bytes: 3064
#include <iostream>
#include <fstream>

using namespace std;

int solve(int *w, int w_size, int k){
    int sum=0;
    int max_w = w[0];
    for(int i=0;i<w_size;i++){
        sum += w[i];
        if(max_w < w[i]){
            max_w = w[i];
        }
    }
    int avg = sum / k;
    int min_P = (avg > max_w) ? avg : max_w;
    int max_P = sum;
    for(int i= min_P;i<=max_P;i++){
        int p=0,counter=0;
        for(int j=0;j<w_size;j++){
            p += w[j];
            if(p > i){
                p = w[j];
                counter++;
            }
        }
        if(p>0){counter++;}
        if(counter <= k){
            return i;
        }
    }
    return 0;
}

int main(){

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

    int ans = solve(w,n,k);
    cout << ans << endl;


    delete [] w;

    return 0;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout<<#x<<"="<<x<<endl;
#define endl '\n'
#define M 1000000007
#define int long long
#define max_n 1000000

using namespace std;

void solve()
{
	ll x[5];
	for (int i = 0; i < 5; ++i)
	{
		cin>>x[i];
		if(x[i]==0){cout<<i+1<<endl;return;}
	}
}

int32_t main() 
{
	IOS	
	ll T=1;
	// cin>>T;
	for(ll i=1;i<=T;++i)
	{		
		// cout<<"Case #"<<i<<": ";
    	solve();
	}
	return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N, A, B;
    cin >> N >> A >> B;
    cout << min(N * A, B) << endl;
    return 0;
}


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

int main()
{	
	int t=1;
	//cin>>t;
	while(t--){
        string str;
		int count=1,n;
		cin>>n;
		cin>>str;
		for(int i=0;i<str.size()-1;i++){
			if(str[i]!=str[i+1]){
				count++;
			}
		}
		cout<<count<<endl;
	}
	//chrono::high_resolution_clock::time_point t1 = chrono::high_resolution_clock::now();
	//chrono::high_resolution_clock::time_point t2 = chrono::high_resolution_clock::now();
	//chrono::duration<double> time_span = (t2 - t1);
	//cout<<time_span.count()<<" Seconds"<<endl;
	return 0;
}


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

bool isPalindrome(string s){
	for(int i=0; i<s.length()/2; i++){
		if(s[i] != s[s.length()-1-i])
			return false;
	}
	return true;
}

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

	string str;
	cin >> str;

	int n = str.length()-1;
	string str1 = str.substr(0,(n-1)/2+1);
	string str2 = str.substr((n+3)/2);
	if(isPalindrome(str) and isPalindrome(str1) and isPalindrome(str2)) cout << "Yes";
	else cout << "No";
	return 0;
}

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

#define pb push_back
#define ff first
#define ss second

using namespace std;

const int MAXN = 1e5 + 10, inf = 1e9 + 21;

int n;
string s;

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n >> s;
    for (int i = 0; i < s.size(); i++) 
        s[i] = (s[i] - 'A' + n) % 26 + 'A';
    cout << s<< '\n';
    return 0;
}

Measured memory_bytes: 256
#include<stdlib.h>
p(int*a,int*b){return*a-*b;}
c,V,i,d,f[1001];
main(){for(;~scanf("%d%d",&V,&d);printf("%d\n",c)){
for(f[1]=3,f[0]=i=2;i<V;i++)f[i]=(f[i-1]+f[i-2])%1001;
qsort(f,V,4,p);
for(i=c=1;i<V;f[i]-f[i++-1]<d?:c++);}
return 0;}

Measured memory_bytes: 636
# include <iostream>
# include <cstring>
# include <string>
# include <vector>
# include <cmath>
# include <sstream>
# include <iomanip>
# include <algorithm>
using namespace std;

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

int main(){
	string str;
	/*for(int i=0;i < 100000;i++){
		str.push_back('z');
	}*/
	ll k;// = 1000000000;
	cin >> str >> k;

	for(ll i=0;i<str.size();i++){
		if(str[i] != 'a'){
			int dif = 'z' - str[i];
			if(k > dif){
				str[i] = 'a';
				k -= (dif + 1);
			}
		}
	}
	str[str.size()-1] = (str[str.size()-1] + k%26); 
	cout << str << endl;
	return 0;
}

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

int main(){

    int n;
    cin >> n;
    if(n % 2 == 0) cout << n << endl;
    else cout << n * 2 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cmath>

using namespace std;

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

int main() {
	string S, T;
	cin >> S >> T;

	cout << T << S << endl;
}

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

int main(){
  int n;
  cin >> n;
  vector<long long> a(n);
  long long all = 0;
  for(int i = 0; i < n; i++){
    cin >> a.at(i);
    all += a.at(i);
  }
  
  long long left = 0, cen;
  for(int i = 0; i < n; i++){
    left += a.at(i);
    cen = a.at(i);
    if(left >= all/2) break;
  }
  
  if(left == all/2) cout << 0 << endl;
  else cout << -abs(all-2*left+cen) + cen << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
using namespace std;
int main(){
	int a,b;
	while(true){
	cin>>a>>b;
	if(a==0&&b==0)
		break;
	b-=a;
	cout<<b%500/100<<" "<<b%1000/500<<" "<<b/1000<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;

int main(){
  int N, M;
  cin >> N >> M;
  int H[N];
  rep(i, N)
    cin >> H[i];
  int A[M], B[M];
  rep(i, M)
    cin >> A[i] >> B[i];
  //

  vector<vector<int> > G(N+1);
  rep(i, M){
    G[A[i]].push_back(B[i]);
    G[B[i]].push_back(A[i]);
  }

  int ans = 0;
  int i, j;
    for(i=1; i<=N; i++){
      for(j=0; j<G[i].size(); j++){
	if(H[i-1] <= H[ G[i][j]-1 ])
	  break;
      }
      if(j == G[i].size()){
	ans++;
      }
    }
    
  cout << ans << endl;

  return 0;
}


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

int main() {
	int a, b, c, d, e, time, min, i,count,k;
	int s[5];
	cin >> a >> b >> c >> d >> e;
	min = 9, count = 0, time = 0;
	s[0] = a % 10, s[1] = b % 10, s[2] = c % 10, s[3] = d % 10, s[4] = e % 10;
	for (i = 0; i < 5; i++) {

		if (s[i] < min&&s[i]!=0) {
			min = s[i];
			k = i;
		}
	}
	for (i = 0; i < 5; i++) {
		if (i == k) {
			continue;
		}
		else {
			while (s[i]>0&&s[i]<10) {
				count++;
				s[i] += 1;
			}
			if (i == 0) {
				a += count;
				count = 0;
			}
			else if (i == 1) {
				b += count;
				count = 0;
			}
			else if (i == 2) {
				c += count;
				count = 0;
			}
			else if (i == 3) {
				d += count;
				count = 0;
			}
			else if (i == 4) {
				e += count;
				count = 0;
			}

		}
	}
	time = a + b + c + d + e;
	cout << time << endl;
	return 0;
}

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

int main()
{
	int a, b, c, d, e, count[4][3][10] = {};
	cin >> a;
	for (int i = 0; i < a; i++) {
		cin >> b >> c >> d >> e;
		count[b-1][c-1][d-1] += e;
	}

	for (int x = 0; x < 4; x++) {
		for (int y = 0; y < 3; y++) {
			for (int z = 0; z < 10; z++) {
                              if (z != 10)cout<<" ";				
                              cout << count[x][y][z];
                               
			}
			cout << endl;
		}

		if(x != 3)cout << "####################" << endl;
	}

}


Measured memory_bytes: 3108
#include <cstdio>
#include <string>
#include <iostream>
#include <math.h>
#include <map>
#include <vector>

using namespace std;
#define ASCII 48

int main() {
	int year, cost = 0;
	cin >> year >> cost;

	if (year < 6) {
		cout << 0 << endl;
	}
	else if (year < 13) {
		cout << cost / 2 << endl;
	}
	else {
		cout << cost;
	}
}


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

using namespace std;
//next 保留字 
int u[400005];
int v[400005];
int w[400005];
int nextt[400005];
int head[100005];
int dis[100005];
bool vis[100005];
int cnt=0;
int f;
void add(int u1,int v1,int w1)
{
	cnt++;
	u[cnt]=u1;
	v[cnt]=v1;
	w[cnt]=w1;
	nextt[cnt]=head[u1];
	head[u1]=cnt;
}
//非void型尽量要有返回值 
void find(int x)
{
	int j=head[x];
	while(j!=-1)
	{
		if(!vis[v[j]])
		{
			vis[v[j]]=true;
			dis[v[j]]=dis[x]+w[j];
			find(v[j]); 
		}
		else
		{
			if(dis[v[j]]!=dis[x]+w[j])
			{
				f=0;
				return;
			}
		}
		j=nextt[j];
	}
}
int main()
{
	memset(dis,0,sizeof(dis));
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=2*n;i++) head[i]=-1;
	for(int i=1;i<=m;i++)
	{
		int l,r,d;
		cin>>l>>r>>d;
		add(l,r,-d);
		add(r,l,d);
	}
	for(int i=1;i<=n;i++)
	{
		if(!vis[i])
		{
			f=1;
			vis[i]=true;
			find(i);
			if(!f||dis[i]!=0)
			{
				cout<<"No"<<endl;
				return 0; 
			}
		}
	}
	cout<<"Yes"<<endl;
	return 0;
} 

Measured memory_bytes: 9216
#include<stdio.h>

int main(void){
  long int N, D, X[200005], Y[200005], i,count=0;
  
  scanf("%ld %ld",&N,&D);
  
  for(i=0; i<N; i++){
    scanf("%ld%ld",&X[i],&Y[i]);
    if(X[i]*X[i]+Y[i]*Y[i]<=D*D){
      count=count+1;
    }
  }
  
  printf("%ld",count);
  
}


Measured memory_bytes: 4844
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static Tuple<int, int, int, int>[] abcd;

    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        int m = sc.NextInt();
        int q = sc.NextInt();

        abcd = new Tuple<int, int, int, int>[q];
        for (int i = 0; i < q; i++)
        {
            abcd[i] = Tuple.Create(sc.NextInt(), sc.NextInt(), sc.NextInt(), sc.NextInt());
        }

        long answer = dfs(new List<int>(), n, m);

        Console.WriteLine(answer);
    }

    private static long dfs(List<int> current, int n, int m)
    {
        if (current.Count() == n)
        {
            return score(current);
        }
        int last = current.Count == 0 ? 1 : current.Last();
        long answer = 0;
        for (int i = last; i <= m; i++)
        {
            List<int> newCurrent = current.ToArray().ToList();
            newCurrent.Add(i);
            long tmpAnswer = dfs(newCurrent, n, m);
            answer = Math.Max(answer, tmpAnswer);
        }
        return answer;
    }

    private static long score(List<int> current)
    {
        long answer = 0;
        foreach (var q in abcd)
        {
            if (current[q.Item2 - 1] - current[q.Item1 - 1] == q.Item3)
            {
                answer += q.Item4;
            }
        }
        return answer;
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 46952
/*-------------------------------"ANJAN AGARWALA"-----------------------------

         _/_/_/_/    _/_/    _/   _/_/_/_/   _/_/_/_/    _/_/    _/   
        _/    _/    _/ _/   _/         _/   _/    _/    _/ _/   _/        
       _/_/_/_/    _/   _/ _/         _/   _/_/_/_/    _/  _/  _/   	  
      _/    _/    _/    _/_/   _/    _/   _/    _/    _/    _/_/  
     _/    _/    _/      _/   _/_/_/_/   _/    _/    _/      _/   

-------------------------------------@anjn98---------------------------------*/

//#define opti
#ifdef opti
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#endif

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

typedef long long int ll;
typedef long long int LL;
typedef unsigned long long int ull;
ll power(ll x,ll y,ll p){ll r=1; x=x%p; while(y){ if(y&1) r= r*x%p; y=y>>1; x=x*x%p; } return r; }
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;*/

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int csrand(int l=0, int r=1e9){
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}

#define IO              ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define FILEIO          freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define all(v)          v.begin(),v.end()
#define PR(a)           cout<<"("<<a<<")";
#define ED              cout<<'\n';
#define endl            '\n'
#define loop(j,a,n)     for(int j=a;j<=n;j++)
#define loop1(j,a,n)    for(int j=a;j>=n;j--)
#define fr1(j,n)        for(int j=0;j<n;j++)
#define fr(n)           for(int i=0;i<n;i++)
#define trav(x,s)       for(auto x:s)
#define SC(n)           scanf("%d",&n)
#define PB              push_back
#define MP              make_pair
#define pii             pair<int,int>
#define pll             pair<long long int,long long int>
#define F               first
#define S               second 
#define binf            2000000000000000001
#define mod             1000000007

const int N=1e3+99;

char tab[N][N];
int dp[N][N];

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

	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)cin>>tab[i][j];
	dp[1][0]=1;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			if(tab[i][j]=='.') dp[i][j]= (dp[i-1][j]+dp[i][j-1])%mod;	

	cout<<dp[n][m]<<endl;
}




 

Measured memory_bytes: 5632
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

const long long MOD = 1000000007;

vector<int> memo(100001);

void create_memo()
{
  memo[0] = 1;
  memo[1] = 1;

  for (int i = 2; i < memo.size(); i++)
  {
    memo[i] = memo[i - 1] + memo[i - 2];
    memo[i] %= MOD;
  }
}

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

  create_memo();

  vector<long long> group;
  int before = 0;
  rep(i, M)
  {
    int a;
    cin >> a;
    group.emplace_back(a - before);
    before = a + 1;
    if (i == M - 1)
    {
      group.emplace_back(N - a);
    }
  }

  if (M == 0)
  {
    group.emplace_back(N + 1);
  }

  long long result = 1;
  rep(i, group.size())
  {
    if (group[i] == 0)
    {
      cout << 0 << endl;
      return 0;
    }
    else
    {
      result *= memo[group[i] - 1];
      result %= MOD;
    }
  }

  cout << result << endl;

  return 0;
}


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

int main(){
  ll a,b,c;
  cin >> a >> b >> c;
  if(c-a-b>0 && 4*a*b<(c-a-b)*(c-a-b)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
def 解():
    iN = int(input())
    m2_2 = 0 #複数あるものの二つ目
    m2 = 0 #複数あるもので最大
    m3 = 0 #3個あるもので最大
    m4 = 0 #4個あるもので最大
    d = set()
    for a in [int(_) for _ in input().split()]:
        if a in d:
            if  m2 < a :
                m2_2 = m2
                m2 = a
            elif m2 == a :
                if m3 < a :
                    m3 = a
                elif m3 == a:
                    if m4 < a:
                        m4 = a
            elif m2_2 < a:
                    m2_2 = a
        else:
            d.add(a)
    print(max(m2*m2_2,m4**2))
解()


Measured memory_bytes: 14480
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int Cin()
{
    int n;
    cin >> n;
    return n;
}

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


Measured memory_bytes: 256
def main():
    length = int(input())
    string = input()
    count = [0] * length
    min_value = 0
    for i in range(length):
        if i == 0:
            if string[i] == "(":
                count[i] = 1
            else:
                count[i] = -1
        elif string[i] == "(":
            count[i] = count[i - 1] + 1
        else:
            count[i] = count[i - 1] - 1
        min_value = min(min_value, count[i])
    print("(" * (-min_value) + string + ")" * (count[-1] - min_value))


if __name__ == '__main__':
    main()



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

// #define ONLINE_JUDGE

#define V vector
#define P pair

using LL = long long;
#define FOR(i, x, y) \
    for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) \
    for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)
#ifndef ONLINE_JUDGE
#define dbg(x...)                             \
    do {                                      \
        cerr << "\033[32;1m" << #x << " -> "; \
        err(x);                               \
    } while (0)
void err() { cerr << "\033[39;0m" << endl; }
template <template <typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) {
    for (auto v : a) cerr << v << ' ';
    err(x...);
}
template <typename T, typename... A>
void err(T a, A... x) {
    cerr << a << ' ';
    err(x...);
}
#else
#define dbg(...)
#endif
#define sz(x) (int)x.size()

LL bin(LL a, LL b, LL p) {
    LL res = 1;
    a = (a % p + p) % p;
    for (; b; b >>= 1, a = a * a % p)
        if (b & 1) res = res * a % p;

    return res;
}

const int N = 3e3+50, M = 4;

LL dp[M][N][N];

int a[N][N];

int r, c, k;

inline void update(LL &a, LL b) {
    a = max(a, b);
}

void solve() {
    scanf("%d%d%d", &r, &c, &k);
    for (int i=0; i<k; ++i) {
        int x, y, v;
        scanf("%d%d%d", &x, &y, &v);
        a[x][y] = v;
    }

    memset(dp, -1, sizeof dp);
    dp[0][1][1] = 0;

    for (int i=1; i<=r; ++i) {
        for (int j=1; j<=c; ++j) {
            for (int k=0; k<=3; ++k) {
                if (dp[k][i][j] == -1)
                    continue;
                update(dp[0][i+1][j], dp[k][i][j] + (k < 3 ? a[i][j] : 0));
                update(dp[k][i][j+1], dp[k][i][j]);
                if (k < 3 && a[i][j])
                    update(dp[k+1][i][j+1], dp[k][i][j] + a[i][j]);
                // dbg(i, j, k, dp[k][i][j]);
            }
        }
    }
    LL Ans = max(max(dp[0][r][c+1], dp[1][r][c+1]), max(dp[2][r][c+1], dp[3][r][c+1]));
    printf("%lld\n", Ans);
}

int main() {

    // int t;
    // cin >> t;
    // while (t--) solve();

    solve();

    return 0;
}

Measured memory_bytes: 330148
/*input
4
cabaacba

*/

#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define mx 22
int MOD = 902014037;

ll pw[mx];
int prm = 103;
int n;
char str[mx*2];

bool isprime(int n)
{
	for(int i = 2; 1ll*i*i<=n; i++)
		if(n % i == 0) return 0;
	return 1;
}

map<pair<int, int>, int> mp, mp2;

void rec(int pos, int hash1, int len1, int hash2)
{
	if(pos == n){
		mp[{hash1, hash2}] ++;
		return;
	}
	int tmp = hash1;
	hash1 = hash1 + pw[len1] * str[pos] % MOD;
	hash1 %= MOD;
	rec(pos+1, hash1, len1+1, hash2);
	hash2 = (1ll * hash2 * prm + str[pos]) % MOD;
	rec(pos+1, tmp, len1, hash2);
}

void rec2(int pos, int hash1, int len1, int hash2)
{
	if(pos == n*2){
		mp2[{hash2, hash1}] ++;
		return;
	}
	int tmp = hash1;
	hash1 = hash1 + pw[len1] * str[pos] % MOD;
	hash1 %= MOD;
	rec2(pos+1, hash1, len1+1, hash2);
	hash2 = (1ll * hash2 * prm + str[pos]) % MOD;
	rec2(pos+1, tmp, len1, hash2);
}

int main()
{
	for(int i = 8; i>=0; i--)
		while(isprime(MOD)==0) MOD--;

	scanf("%d", &n);
	scanf("%s", str);

	pw[0] = 1;
	for(int i = 1; i<mx; i++){
		pw[i] = pw[i-1] * prm % MOD;
	}
	rec(0, 0, 0, 0);
	rec2(n, 0, 0, 0);
	ll ans = 0;
	for(auto p : mp){
		ans += 1ll * mp2[p.first] * p.second;

	}
	printf("%lld\n", ans);

	return 0;
}


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

const int N=5000005;
int n,m,k,a[N],dis[N],xs,ys,xt,yt;
int xy[4][2]={0,1,1,0,0,-1,-1,0};
char str[N];

void bfs()
{
	memset(dis,-1,sizeof(dis));
	queue<pair<int,int> >q;
	q.push(make_pair(xs,ys));
	dis[xs*m-m+ys]=0;
	while(!q.empty())
	{
		int xu=q.front().first;
		int yu=q.front().second;
		int u=xu*m-m+yu;
		q.pop();
//		cout<<xu<<' '<<yu<<' '<<dis[u]<<endl;
		for(int i=0;i<4;i++)
		{
			for(int j=1;j<=k;j++)
			{
				
				int xv=xu+xy[i][0]*j;
				int yv=yu+xy[i][1]*j;
				int v=xv*m-m+yv;
//				cout<<xv<<' '<<yv<<' '<<v<<endl;
				if(xv<1||xv>n||yv<1||yv>m) break;
				if(!a[v]||dis[v]<=dis[u]&&dis[v]>-1) break;
				if(dis[v]>-1) continue;
				dis[v]=dis[u]+1,q.push(make_pair(xv,yv));
			}
		}
	}
}

int main()
{
	scanf("%d%d%d",&n,&m,&k);
	scanf("%d%d%d%d",&xs,&ys,&xt,&yt);
	for(int i=1;i<=n;i++)
	{
		scanf("%s",str+1);
		for(int j=1;j<=m;j++)
		{
			a[i*m-m+j]=(str[j]=='.');
		}
	}
	bfs();
	printf("%d\n",dis[xt*m-m+yt]);
}

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

#[allow(unused_macros)]
macro_rules! scan {
  ($e:expr; $t:ty) => {
    $e.get::<$t>()
  };
  ($e:expr; $($t:ty), *) => {
    ($($e.get::<$t>(),)*)
  }
}

struct Scanner<R: Read> {
  reader: R
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
  fn new(reader: R) -> Scanner<R> {
    Scanner { reader: reader }
  }
  fn safe_get<T: FromStr>(&mut self) -> Option<T> {
    let token = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
      .skip_while(|c| c.is_whitespace())
      .take_while(|c| !c.is_whitespace())
      .collect::<String>();
    if token.is_empty() { None } else { token.parse().ok() }
  }
  fn get<T: FromStr>(&mut self) -> T {
    if let Some(v) = self.safe_get() { v } else {
      writeln!(stderr(), "Terminated with EOF").unwrap();
      std::process::exit(0);
    }
  }
}

macro_rules! min {
  ($v1:expr, $v2:expr) => {
    if $v1 < $v2 { $v1 } else { $v2 }
  };
  ($v1:expr, $v2:expr, $($vals:expr), *) => {
    min!(min!($v1, $v2), $($vals), *)
  }
}

fn main() {
  let cin = stdin();
  let cin = cin.lock();
  let mut sc = Scanner::new(cin);
  let (_, s) = scan!(sc; i64, String);
  let mut ans = std::usize::MAX;
  if s.chars().all(|c| c == '.') || s.chars().all(|c| c == '#') {
    println!("0");
    return;
  }
  let mut wr = s.chars().filter(|&c| c == '.').collect::<String>().len();
  let bn     = s.chars().filter(|&c| c == '#').collect::<String>().len();
  let wn = wr;
  let mut bl = 0;
  for c in s.chars() {
    match c {
      '.' => wr -= 1,
      '#' => bl += 1,
      _   => {}
    }
    ans = min!(ans, bl + wr);
  }
  ans = min!(ans, wn, bn);
  println!("{}", ans);
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int a, b;	
    cin >> a >> b;
    for (int i = 0; i <= 10000; ++i) {
        int t8 = 0.08 * i;
        int t10 = 0.10 * i;
        if (t8 == a && t10 == b) {
            cout << i << "\n";
            return 0;
        }
    }
    cout << "-1\n";
    return 0;
}



Measured memory_bytes: 384
"""
キューのデータ構造の定義
"""

class Queue:
    def __init__(self):
        self.queue = []

    def enqueue(self, num):
        self.queue.append(num)

    def dequeue(self):
        return self.queue.pop(0)

    def exist(self):
        if len(self.queue) > 0:
            return True
        else:
            return False

class Process():
    def __init__(self, name, time):
        self.name = name
        self.time = time
    
    def execute(self, q):
        self.time -= q
        if self.time <= 0:
            return True, self.time+q
        else:
            return False, q

if __name__=="__main__":
    n, q = [int(i) for i in input().split()]
    queue = Queue()
    for i in range(n):
        name, time = [s for s in input().split()]
        queue.enqueue(Process(name, int(time)))

    total_execute_time = 0
    while queue.exist():
        p = queue.dequeue()
        is_finish, execute_time = p.execute(q)
        total_execute_time += execute_time
        if is_finish:
            print("{} {}".format(p.name, total_execute_time))
        else:
            queue.enqueue(p)



Measured memory_bytes: 17264
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) (x).begin(), (x).end()
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cerr << #x " => " << x << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int    INF  = 1 << 30;
constexpr lint   INFL = 1LL << 62;
constexpr int    MOD  = (int)1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int n, d;
  cin >> n >> d;
  vector<vector<int>> x(n, vector<int>(d));
  rep (i, n) {
    rep (j, d) cin >> x[i][j];
  }
  int cnt = 0;
  rep (i, n) {
    rep (j, i + 1, n) {
      lint sum = 0;
      rep (k, d) sum += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
      lint root = sqrt(sum);
      if (root * root == sum) ++cnt;
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [[0] + [int(i) for i in input().split()] for _ in range(2)]

for i in range(N):
    A[0][i+1] += A[0][i]
    A[1][i+1] += A[1][i]

ans = 0
for i in range(1,N+1):
    ans = max(ans, A[0][i] + (A[1][-1] -A[1][i-1]))

print(ans)

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n; cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll sum = 0;
  rep(i, n) sum ^= a[i];
  vector<ll> ans(n);
  rep(i, n) ans[i] = (sum^a[i]);
  line_out(ans);
}

Measured memory_bytes: 7932
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = (int)1e9 + 7;
const int INF = (int)100100100;

int main() {
    ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    vector<ll> a(N);
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    vector<ll> b(N);
    b=a;
    sort(b.begin(), b.end());
    reverse(b.begin(), b.end());
    for(int i=0;i<N;i++){
        if(a[i]==b[0])cout << b[1] << endl;
        else cout << b[0] << endl;
    }   


}

/*



 */



Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

// O(log max{a, b})
long long gcd(long long a, long long b) {
    while (b) {
        long long c = a % b;
        a = b;
        b = c;
    }
    return a;
}

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

void _main() {
    int N;
    cin >> N;
    int ans = 1;
    REP (i, N) {
        int T;
        cin >> T;
        ans = lcm(ans, T);
    }
    cout << ans << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char a[100005];
int x=0,y=0,ans=0;
int main()
{
    cin>>a;
    for(int i=0;i<sizeof(a);i++)
     if(x==y){x++;if(a[i]=='p')ans--;}
     else{y++;if(a[i]=='g')ans++;}
    printf("%d\n",ans);
    return 0;
}

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

using namespace std;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int start = max(a, c);
    int end = min(b, d);

    if (start < end) {
        cout << end - start << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import collections
import queue
Q = collections.deque()
ans = 0
base = 0
#print(ans)
line = input()
#print(line)
a = line.split()
#print(a)
n,q = map(int,a)

def work(listed):
    global ans
    global base
    v = int(listed[1])
    if v <= q:
        ans += v
        print(listed[0],ans)
        base += 1
    else:
        #print(q)
        #print(ans)
        ans += q
        v -= q
        listed[1] = str(v)
        Q.append(listed)

for i in range (n):
    listed = list(input().strip().split())
    #print(ans)
    work(listed)

#for i in Q:
while base < n:
    listed = Q.popleft()
    work(listed)
    #print(Q)



Measured memory_bytes: 10796
N, M, X, Y = (int(i) for i in input().split())
l_x = [int(x) for x in input().split()]
l_y = [int(y) for y in input().split()]

l_x.append(X)
l_y.append(Y)
if max(l_x) >= min(l_y):
    print('War')
else:
    print('No War')

Measured memory_bytes: 3060
value, all_money, max_num = [int(i) for i in input().split()]



"""
value を最大max_numまでかける
・途中でall_moneyを上回ったら終了
・全てかけてもmax_numかけても上回らなかった時はmax_numで終了
"""

num = 0
money = 0

for i in range(1, max_num + 1):
    money = value * i
    num = i
    if money > all_money:
        num = num - 1
        break


print(num)




Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(void)
{
	int dp[4][100][100]; //0:ツ凝按つェツづァツつクツづ可湘」 1:ツ凝按つェツづづ湘」 2:ツ凝按つェツづァツつクツづ可右 3:ツ凝按つェツづづ右
	int x, y;
	
	for (int i = 0; i < 100; i++){
		for (int j = 0; j < 100; j++){
			for (int k = 0; k < 4; k++){
				dp[k][j][i] = 0;
			}
		}
	}
	
	dp[0][0][0] = dp[2][0][0] = 1;
	for (int i = 0; i < 100; i++){
		dp[0][0][i] = 1;
		dp[3][0][i] = 1;
		dp[2][i][0] = 1;
		dp[1][i][0] = 1;
	}
	
	for (int x = 1; x < 100; x++){
		for (int y = 1; y < 100; y++){
			dp[0][x][y] = (dp[0][x][y - 1] + dp[1][x][y - 1]) % 100000;
			dp[1][x][y] = dp[2][x - 1][y];
			dp[2][x][y] = (dp[2][x - 1][y] + dp[3][x - 1][y]) % 100000;
			dp[3][x][y] = dp[0][x][y - 1];
		}
	}
	while (1){
		cin >> x >> y;
		if (x == 0 && y == 0){
			break;
		}
		if (x == 1 || y== 1){
			cout << 1 << endl;
		}
		else {
			cout << (dp[0][x - 1][y - 2] + dp[1][x - 1][y - 2] + dp[2][x - 2][y - 1] + dp[3][x - 2][y - 1]) % 100000 << endl;
		}
	}
	
	
	return (0);
}

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

#define ll              long long int
#define scan(any)       for(auto &i:any) cin>>i;
#define print(any)      for(auto i:any) cout<<i<<" "; 
#define endl            '\n'
#define pb              push_back
#define vll             vector<ll> 
#define f(i,x,y)        for(i=x;i<y;i++)
#define INF             LLONG_MAX
#define fast            ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define s(x)            sort(x.begin(),x.end())
#define all(v)          v.begin(),v.end()
#define p2(n,x)         cout << fixed << setprecision(x) <<n<<endl; 
#define pll             pair<ll,ll> 
#define ff              first
#define ss              second
#define blt(x)          __builtin_popcount(x)

void solve()
{
    string s;
    cin>>s;
    if(s[(int)s.size()-1]=='s')
    {
        cout<<s<<"es";

    }
    else
    {
        cout<<s<<"s";
    }
}

int main()
{
    
    fast
    ll t = 1;

    while(t--)
    solve();
    
    return 0;
}

Measured memory_bytes: 3660