akhauriyash/Code-Regression huggingface dataset:
n = int(input())
a = []
x = [[] for i in range(n)]
y = [[] for i in range(n)]
for i in range(n):
    a.append(int(input()))
    for j in range(a[i]):
        xx, yy = (int(i) for i in input().split())
        x[i].append(xx)
        y[i].append(yy)

hoge = [[2]*n for i in range(n)]

for i in range(n):
    for j in range(a[i]):
        if(y[i][j] == 1):
            hoge[i][x[i][j]-1] = 1
        elif(y[i][j] == 0):
            hoge[i][x[i][j]-1] = 0

ans = 0
b_list = []
for i in range(2**n):
    bit_list = []
    for j in range(n):
        if ((i >> j) & 1):
            bit_list.append(1)
        else:
            bit_list.append(0)
    b_list.append(bit_list)
    flag = 1
    for k in range(n):
        if(bit_list[k] == 1):
            tmp = 0
            for l in range(n):
                if(hoge[k][l] != 2):
                    if(hoge[k][l] != bit_list[l]):
                        flag = 0
                        break
    if(flag == 1):
        tmp = 0
        for l in range(n):
            if(bit_list[l] == 1):
                tmp += 1
        if(tmp > ans):
            ans = tmp
print(ans)


Measured memory_bytes: 9972
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define db(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<'\n'
const int N = 1e6;

int main() {
    ios_base::sync_with_stdio(0);
    int a,b,n,T,cas=0;
    string s;
    cin>>s;
    map<int, int> mp;
    mp[0]=1;
    int r=0, pow10=1;
    ll res=0;
    for(int i=s.size()-1;~i;--i) {
        r = (r + (s[i]-'0')*pow10)%2019;
        res += mp[r];
        mp[r]++;
        pow10 = (pow10*10)%2019;
    }
    cout<<res<<endl;
    return 0;
}

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

bool solve() {
    ll N, A, B, C, X;
    cin >> N >> A >> B >> C >> X;

    if(!(N + A + B + C + X)) return false;

    vector<ll> Y(N);
    for(auto &&e : Y) cin >> e;

    map<ll, ll> mp;
    ll initx = X;
    mp[X] = 0;
    ll loops = 0;
    for(ll i = 1; ; i++) {
        ll NX = (A * X + B) % C;
        if(mp.find(NX) != mp.end()) {
            loops = NX;
            break;
        }
        mp[NX] = i;
        X = NX;
    }

    ll now = 0;
    ll ans = 0;
    for(ll i = initx == Y[0]; i < Y.size(); i++) {
        ll y = Y[i];
        if(mp.find(y) == mp.end()) {
            ans = -1;
            break;
        }
        auto tmp = mp[y];
        if(now < tmp) {
            ans += tmp - now;
        } else {
            if(tmp < mp[loops]) {
                ans = -1;
                break;
            }
            ans += (mp.size() - now) + (tmp - mp[loops]);
        }
        now = tmp;
    }

    cout << (ans <= 10000 ? ans : -1) << endl;
    return true;
}

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



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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int a,p;cin>>a>>p;
  p += a*3;
  cout<<p/2<<endl;

  return 0;
}


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

using namespace std;

int cost[100][100];

int main()
{
	for(;;){
		int t,tt,ttt,tttt;
		int time[100][100];
		
		//n:f[^Ì m:wÌ
		int n, m;
		
		//k:â¢í¹Ì
		int k;
		
		cin >> n >> m;
		
		if(n == 0 && m == 0){
			break;
		}
		
		for(int i = 0; i < 100; i++){
			for(int j = 0; j < 100; j++){
				if(i!=j)
				{
					time[i][j] = 10000000;
					cost[i][j] = 10000000;
				}
				else{
					cost[i][j]=time[i][j]=0;
				}
			}
		}
		
		for(int i = 0; i < n; i++){
			cin >> t >> tt >> ttt >> tttt;
			t--;
			tt--;
			cost[t][tt]=ttt;
			time[t][tt]=tttt;
			cost[tt][t]=ttt;
			time[tt][t]=tttt;
		}
		
		cin >> k;
		
		
		
			for(int f = 0; f < m; f++){
				for(int fd = 0; fd < m; fd++){
					for(int fds = 0; fds < m; fds++){
							cost[fd][fds] = min(cost[fd][fds] , cost[fd][f] + cost[f][fds]);
							time[fd][fds] = min(time[fd][fds] , time[fd][f] + time[f][fds]);
					}
				}
			}
		
		for(int i = 0; i < k; i++){
			cin >> t >> tt >> ttt;
			

			if(ttt == 0){
				cout << cost[t-1][tt-1] << endl;
			}
			else{
				cout << time[t-1][tt-1] << endl;
			}
		}
	}
	
}

Measured memory_bytes: 936
import sys
import numpy as np

n = int(input())
aaa = list(map(int, sys.stdin))
MOD = 998244353

s = sum(aaa)
dp1 = np.zeros(s + 1, dtype=np.uint32)
dp2 = np.zeros(s + 1, dtype=np.uint32)
dp1[0] = 1
dp2[0] = 1
for a in aaa:
    dp1 = (dp1 * 2 + np.roll(dp1, a)) % MOD
    dp2 = (dp2 + np.roll(dp2, a)) % MOD

h = (s + 1) // 2
ans = (pow(3, n, MOD) - dp1[h:].sum() * 3) % MOD
if s % 2 == 0:
    ans = (ans + dp2[h] * 3) % MOD
print(int(ans))


Measured memory_bytes: 15268
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
       _n: usize,
       ss: chars
    }
    let mut es: Vec<u32> = ss.iter().rev().scan(0, |a, c| {
        *a = *a + if *c == 'E' {1} else {0};
        Some(*a)
    }).collect();
    es.reverse();
    let ws: Vec<u32> = ss.iter().scan(0, |a, c| {
        *a = *a + if *c == 'W' {1} else {0};
        Some(*a)
    }).collect();
    let mn = es.iter().zip(ws.iter())
             .map(|(e,w)| e + w).min().unwrap();
    println!("{}", mn - 1);
}


Measured memory_bytes: 13620
k, n = map(int, input().split())
A = list(map(int, input().split()))

max_dist = 0
for i in range(n - 1):
    max_dist = max(max_dist, A[i + 1] - A[i])
max_dist = max(max_dist, A[0] + k - A[i + 1])

print(k - max_dist)


Measured memory_bytes: 26460
import java.util.*;
import java.io.*;

import static java.lang.Character.isUpperCase;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        int K  =  in.nextInt();
        int A  =  in.nextInt();
        int B  =  in.nextInt();

        boolean x =false;
        for(int i = A; i <= B; i ++) {
            if (i % K == 0) {
                x = true;
            }
        }
            if (x == true) {
                System.out.println("OK");
            } else {
                System.out.println("NG");
            }

    }




    }






Measured memory_bytes: 35660
# include "bits/stdc++.h"
 
using namespace std;
 
#define endl "\n"
typedef long long int ll;
#define f first
#define s second
 
inline void fastio(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
inline void setPrecision(int n){cout.precision(n);}
 
//DEBUG
#define dbg(x) cerr<<(#x)<<": "<<x<<endl
#define dbgV(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<it<<" "; cerr<<endl;
#define dbgS(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<it<<" "; cerr<<endl;
#define dbgM(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<"["<<it.f<<", "<<it.s<<"] "; cerr<<endl;
#define dbg2D(x) cerr<<(#x)<<": \n"; for(auto y: x) { for(auto it: y) cerr<<it<<" "; cerr<<endl; } cerr<<endl;
#define dbgA(x, n) cerr<<(#x)<<": "; for(int i=0;i<n;++i) cerr<<x[i]<<" "; cerr<<endl;
#define dbgVP(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<"["<<it.f<<", "<<it.s<<"] "; cerr<<endl;
 
ll INF = 1e10;
int MOD = 1e9+7;

int main(){
    fastio();

    int n, h;
    cin >> h >> n;

    int a[n], b[n];
    int mx = 0;
    for(int i = 0; i < n; ++i){
    	cin >> a[i] >> b[i];
    	mx = max(mx, a[i]);
    }

    vector<int> dp(h + mx + 1, 1e9);
    for(int i = h; i <= h + mx; ++i)
    	dp[i] = 0;

    for(int i = 0; i < n; ++i){
    	for(int j = h + mx; j >= 0; --j){
    		if(j + a[i] <= h + mx){
    			dp[j] = min(dp[j], b[i] + dp[j + a[i]]);
    		}
    	}
    }

    cout << dp[0];
    return 0;
}

/*

*/

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#define ll long long
#define pb push_back
#define f(i,k) for(int i = 0;i<k;i++)
using namespace std;

void solve(){
    string s;
    cin>>s;
    char c = s[0];
    for(int i=1;i<s.length();i++){
        if(s[i]!=c){
            cout<<"Yes";
            return ;
        }
    }
    cout<<"No";
    return ;

}

int main()
{
solve();
return 0;
    
}
/*const int maxSize = 1e5;
    long long n, a, b;
    cin >> n >> a >> b;
    long long multi = n/b;
    long long rem = n % b;
    if(multi > maxSize){
        cout << "NO\n";
        return 0;
    }
    vector<long long> ans(multi, b);
    if(rem != 0) {
        for(int i = 0; i < multi; i++) {
            long long d = max(0ll, min(a - rem, b - a));
            rem += d;
            ans[i] -= d;
        }
        if(rem < a) {
            cout << "NO\n";
            return 0;
        }
    }
    
    cout <<"YES\n";
    if(rem != 0)
        cout << rem << ' ';
    for(auto&v : ans)
        cout << v << ' ';*/

/**/


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

//二次元累積和
struct cumulative_sum_2d {
    using lint = long long int;
    int sz;
    vector<vector<lint>> data;
    vector<vector<lint>> sum;
    cumulative_sum_2d(const int _sz) : sz(_sz) {
        data.assign(sz, vector<lint>(sz));
        sum.assign(sz + 1, vector<lint>(sz + 1));
    }
    vector<lint> &operator[](const int k) {
        return data[k];
    }
    void build() {
        for (int i = 0; i < sz; i++)
            for (int j = 0; j < sz; j++)
                sum[i + 1][j + 1] = sum[i + 1][j] + sum[i][j + 1] - sum[i][j] + data[i][j];
    }
    //[a,b)×[c,d)の和を計算
    lint query(const int a, const int b, const int c, const int d) const {
        return sum[b][d] - sum[b][c] - sum[a][d] + sum[a][c];
    }
};

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

lint n, k;

int main() {
    cin >> n >> k;
    int num_b = 0, num_w = 0;
    cumulative_sum_2d black(2 * k), white(2 * k);
    for (int i = 0; i < n; i++) {
        int x, y;
        char c;
        cin >> x >> y >> c;
        x %= 2 * k, y %= 2 * k;
        if (c == 'B') {
            black[x][y]++;
            num_b++;
        } else {
            white[x][y]++;
            num_w++;
        }
    }
    black.build();
    white.build();
    int ans = 0;
    for (int i = 0; i < k; i++) {
        for (int j = 0; j < k; j++) {
            int b_ok = black.query(0, i, 0, j) + black.query(i + k, 2 * k, 0, j) +
                       black.query(i, i + k, j, j + k) + black.query(0, i, j + k, 2 * k) +
                       black.query(i + k, 2 * k, j + k, 2 * k);
            int w_ok = white.query(i, i + k, 0, j) + white.query(0, i, j, j + k) +
                       white.query(i + k, 2 * k, j, j + k) + white.query(i, i + k, j + k, 2 * k);
            chmax(ans, b_ok + w_ok);
            chmax(ans, num_b - b_ok + num_w - w_ok);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 125568
using System;
using System.Text;

namespace ABC148B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var ST = Console.ReadLine().Split();
            var S = ST[0];
            var T = ST[1];

            var sb = new StringBuilder(N * 2);
            for (var i = 0; i < N; i++)
            {
                sb.Append(S[i]);
                sb.Append(T[i]);
            }
            Console.WriteLine(sb.ToString());
        }
    }
}

Measured memory_bytes: 13140
#include "bits/stdc++.h"

#define REP(i,n) for(int i=0;i<n;++i)
#define RREP(i,n) for(int i=n-1;i>=0;--i)
#define FOR(i,m,n) for(int i=m;i<n;++i)
#define RFOR(i,m,n) for(int i=m-1;i>=n;--i)
#define ALL(v) v.begin(),v.end()
#define PB(a) push_back(a)
#define INF 1000000001
#define MOD 1000000007

using namespace std;


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	while (cin >> n&&n != 0) {
		vector<int>  v(n);
		int cmin = INF;
		REP(i, n) {
			cin >> v[i];
		}
		REP(i, n) {
			REP(j, n) {
				if(i!=j)
				cmin = min(cmin, abs(v[i] - v[j]));
			}
		}
		cout << cmin << endl;
	}

	return 0;
}

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

int main(){
    int A, B, C, count=0;
    cin >> A >> B >> C;
    string ans;

    if(A==B){
        count++;
    }
    if(B==C){
        count++;
    }
    if(C==A){
        count++;
    }

    if(count==1){
        ans="Yes";
    }else{
        ans="No";
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
 
int main() {
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    for (int i = 0; i < n; i++) cin >> x[i] >> y[i];
    map<pii, int> cnts;
 
    for(int i=0; i<n; i++) {
        map<pii, int> temp;
        for(int j = 0; j < n; j++) {
            pii tmp = pii(x[i]-x[j], y[i]-y[j]);
            if(i != j) temp[tmp]++;
        }
        for(auto& p: temp) {
            cnts[p.first]++;
        }
    }
 
    int mx = 0;
    for(auto& p: cnts) {
        mx = max(mx, p.S);
    }
 
    cout << n - mx << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repeq(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define rep1eq(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using Int = long long;

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
typedef pair<int,int> P;
typedef std::priority_queue<int> IntPrioQueue;
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue;

//少数点表示
//cout << std::fixed << std::setprecision(14) << 値

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    int a,b;
    cin >> a >> b;
    int cnt = 0;
    int c = 1;
    while(c<b){
        c--;
        c += a;
        cnt++;
    } 
    
    cout << cnt << 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++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



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

  ll a, b, c;
  cin >> a >> b >> c;
  ll x, y;
  cin >> x >> y;
  ll ans = infll;
  for(ll i = 0; i <= max(x,y)*2; i += 2) {
    ll tmp = 0;
    tmp += i*c;
    if(x-i/2 > 0) tmp += (x-i/2) * a;
    if(y-i/2 > 0) tmp += (y-i/2) * b;
    chmin(ans, tmp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
s = [input() for _ in range(H)]
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
def solve():
    for x in range(H):
        for y in range(W):
            if s[x][y] == '#':
                flag = True
                for k in range(4):
                    nx = x + dx[k]
                    ny = y + dy[k]
                    if 0 <= nx and nx < H and 0 <= ny and ny < W and s[nx][ny] == '#':
                        flag = False
                if flag:
                    return False
    return True
print("Yes" if solve() else "No")

Measured memory_bytes: 3064
{-
 - `chebyshev n' returns the number of primes between n+1 and 2n.
 - e.g.:
 -   chebyshev 10 == 4    -- 11, 13, 17, 19
 -   chebyshev 13 == 3    -- 17, 19, 23
 -}

import Control.Monad  -- when

chebyshev :: Int -> Int
chebyshev n = length [x | x<-[n + 1 .. 2 * n], prime x]
 
prime :: Int -> Bool
prime n = [x | x<-fs, n`mod`x == 0] == []
  where fs = takeWhile (\d->d*d <= n) ([2] ++ [3,5..])

main :: IO ()
main = do n <- readLn
          when (n /= 0) $ do
            print (chebyshev n)
            main

Measured memory_bytes: 4184
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define lli long long int
#define tc int t;cin>>t;while(t--)
#define all(x) x.begin(),x.end()
#define f first
#define s second
#define pb push_back
#define vi vector<int>
#define vll vector<lli>
#define maxn 250005



int main() {
    fastio;
    lli a;
    string b;
    cin>>a>>b;
    lli mul=(b[0]-'0')*100+(b[2]-'0')*10+(b[3]-'0');
    cout<<(a*mul)/100<<"\n";
    return 0;
}


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

int main()
{
	string s;
	cin >> s;
	if (s[0] == s[1] && s[1] == s[2] && s[2] == 'R')
	{
		cout << 3 << endl;
	}
	else if ((s[0] == s[1] || s[1] == s[2]) && s[1] == 'R')
	{
		cout << 2 << endl;
	}
	else if (s[0] == 'R' || s[1] == 'R' || s[2] == 'R')
	{
		cout << 1 << endl;
	}
	else
	{
		cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 3620
import numpy as np
def resolve():
    N,K = map(int,input().split())
    A = list(input().split())
    current_p = 0
    loop_length = 0
    loop_start = 0
    Nlist = - np.ones(N, dtype = int)
    Nlist[0] = 0
    for i in range(1, min(N + 1,K + 1)):
        next_p = int(A[current_p]) - 1
        if Nlist[next_p] == -1:
            current_p = next_p
            Nlist[next_p] = i
        else:
            loop_start = Nlist[next_p]
            loop_length = i - loop_start
            break
    if loop_length != 0:
        ans =  loop_start + (K - loop_start) % loop_length
    else:
        ans = K 
    print(np.where(Nlist == ans)[0][0] + 1)
resolve()

Measured memory_bytes: 43660
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
char al[] = {'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'};
int main(){
  int n;
  cin >> n;
  vector<vector<int>> cnt(n,vector<int>(26,0));
  rep(i,n) {
    string s;
    cin >> s;
    rep(j,sz(s)) cnt[i][s[j] - 'a']++;
  }
  vector<int> res(26,100);
  rep(i,26) {
    rep(j,n) {
      res[i] = min(res[i],cnt[j][i]);
    }
  }
  string ans = "";
  rep(i,26) rep(j,res[i]) ans += al[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n, m = [int(x) for x in input().split()]
s_list = [[int(x) for x in input().split()] for _ in range(n)]
c_list = [[int(x) for x in input().split()] for _ in range(m)]
for i in range(n):
    d = 10 ** 9
    p = 0
    for j in range(m):
        temp_d = abs(s_list[i][0] - c_list[j][0]) + abs(s_list[i][1] - c_list[j][1])
        if temp_d < d:
            d = temp_d
            p = j + 1
    print(p)

Measured memory_bytes: 9152
from math import sqrt
N,D = map(int,input().split())
X = []
for i in range(N):
    X.append(list(map(int,input().split())))

ans = 0
for i in range(N):
    for j in range(i+1,N):
        tmp = 0
        for k in range(D):
            tmp += (X[i][k]-X[j][k])**2
        if int(sqrt(tmp))**2  == tmp:
            ans += 1
print(ans)

Measured memory_bytes: 3064
from collections import defaultdict
while 1:
    n = int(raw_input())
    if n == 0: break
    L = [0]*n
    T = [0]*n
    for man in xrange(n):
        m,l = map(int,raw_input().split())
        L[man] = l
        t = 0
        for date in xrange(m):
            s,e = map(int,raw_input().split())
            t |= 2**(e-6)-2**(s-6)
        T[man] = t

    dp = defaultdict(int)
    dp[T[0]] = L[0]
    for i in xrange(1,n):
        for bit in dp.keys():
            if bit&T[i] == 0:
                dp[bit|T[i]] = max(dp[bit|T[i]], dp[bit]+L[i])
        dp[T[i]] = max(dp[T[i]], L[i])
        
    print max(dp.values())

Measured memory_bytes: 11468
#include<iostream>
#include<map>
using namespace std;
int H[200005];
map<int,int> mym;
int main(){
  int N;
  cin>>N;
  long long int res=0;
  for(int i=1; i<=N; i++){
    cin>>H[i];
    if(mym.find(i-H[i])!=mym.end()) res+=mym[i-H[i]];
    mym[i+H[i]]++;
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 13568
X, N = gets.split.map(&:to_i)
PS = gets.split.map(&:to_i)
x = X
i = 0
loop do
  if !PS.include?(x+i)
    puts x+i
    exit
  end
  if i >= 0
    i = (-i)-1
  else
    i = (-i)
  end
end


Measured memory_bytes: 14228
#include <stdio.h>

int a[100000];
int cnt=0;
int main(void)
{
	while(1){
		scanf("%d",&a[cnt]);
		if(a[cnt]==0) break;
		cnt++;
	}//配列添字maxとcnt同じ
	int p;
	for(p=0;p<cnt;p++){
		int q=p+1;
		printf("Case %d: %d\n",q,a[p]);
	}
	
	
	
	return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <cstdio>
#define MN 55
#define mod 1000000007
#define T 50

int f[MN][2 * MN];
int C[MN][MN];

int inc(int a, int b) {return (a += b) >= mod ? a - mod : a;}

int main()
{
	int n; scanf("%d", &n);
	for(int i = 0; i <= n; i++) C[i][i] = C[i][0] = 1;
	for(int i = 1; i <= n; i++)
		for(int j = 1; j < i; j++)
			C[i][j] = inc(C[i - 1][j - 1], C[i - 1][j]);
			
	f[0][1 + T] = 1;
	for(int i = 1; i <= n; i++)
	{
		for(int j = -n; j <= n; j++)
		{
			for(int k = -n; k <= n; k++)
			{
				for(int w = 0; w <= n; w++)
				{
					if(k == 0 && w == 0 || k + w < 0 || k + w + w > i) continue;
					int a, b;
					a = k + w - j, b = w + j;
					if(a < 0 || b < 0) continue;
					if(i - a - b == 0 && w > 0) continue; 
					f[i][j + T] = inc(f[i][j + T], 1ll * f[i - a - b][k + T] * C[i - b][a] % mod * C[i][b] % mod);
				}
			}
		}
	}
	printf("%d\n", f[n][0 + T]);
}

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

const int nmax = 123456;
int n, sosu[nmax * 2 + 1], c = 0;

void set() {
	for (int i = 2; i <= nmax; i++) {
		if (sosu[i] == 0) {
			for (int j = 2; i*j <= nmax * 2; j++) {
				sosu[i*j] = 1;
			}
		}
	}
}

int main() {
	set();

	while (true) {
		cin >> n;
		if (n == 0)break;
		for (int i = n + 1; i <= n * 2; i++) {
			if (sosu[i] == 0)c++;
		}

		cout << c << endl;
		c = 0;
	}
}

Measured memory_bytes: 4072
/*
    YES PAIN YES GAIN
*/

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;
template<class T> using rbTree=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long int
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define unmap unordered_map
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pair<int,int>>
#define mem(u,v) memset(u,v,sizeof(u))
#define all(x) x.begin(),x.end()
#define r_all(x) x.rbegin(),x.rend()
#define vvi vector<vector<int>>
#define bug1 cout<<"hi1"<<endl
#define bug2 cout<<"hi2"<<endl
#define bug3 cout<<"hi3"<<endl

const int N=1e5;
const int M=2e5;
const int mod=1e9+7;

void solve()
{
    int n,ans=0;
    cin>>n;
    for(int i=1;i<=n;i++) if(i%3!=0 && i%5!=0) ans+=i;
    cout<<ans;
}

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

    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    int t=1;
    //cin>>t;

    while(t--)
    {
        solve();
    }

    #ifndef ONLINE_JUDGE
    cout << "\n\ntime: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms";
    #endif

    return 0;
}

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

int main(void) {
	char a, b;
	scanf("%c %c", &a, &b);
	if (a == 'H') {
		printf("%c\n", b);
	} else {
		if (b == 'H') printf("D\n");
		else printf("H\n");
	}

	return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#include<iostream>
#include<stdio.h>
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
#define ll  long long
#define mod 998244353
#define ve vector
#define pi pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define all(v) v.begin(),v.end()
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int inf=1e9+5;


ll power(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b/=2;
	}
	return res;
}





void solve()
{   
   int n;
    cin>>n;
    n=n%1000;
    n=(1000-n)%1000;
    cout<<n<<endl;
}

signed main()
{
//#ifndef ONLINE_JUDGE
    //  freopen("input.txt","r",stdin);
    //  freopen("output.txt","w",stdout);
//#endif
    FAST;

     int t=1;
    // cin>>t;
     while(t--)
    	solve();
    return 0;
}



Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define db(a) cout << fixed << #a << " = " << a << endl;

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	ll ans = 0;
	for (int a = 1; a <= n; a++) {
		for (int b = 1; b <= n; b++) {
			if (a*b < n) {
				ans++;
			} else {
				break;
			}
		}
	}
	cout << ans << "\n";
}



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


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


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


N, M = LI()
P, Y = [], []
for i in range(M):
    j, k = LI()
    P.append(j)
    Y.append(k)

#  N = 10**5
#  M = 10**5
#  P, Y = [], []
#  for i in range(M):
#      P.append(10)
#      Y.append(i*100)

city_records = [[]for i in range(10**6)]
for p, y in zip(P, Y):
    #  print('p,y', p, y)
    #  print('city_records[p]', city_records[p])
    city_records[p].append(y)

#  print(city_records)

for i in range(len(city_records)):
    if city_records[i] == []:
        continue
    city_records[i].sort()

#  print(city_records)

for p, y in zip(P, Y):
    #  order = (city_records[p].index(y)) + 1
    order = bisect.bisect_left(city_records[p], y) + 1
    print(str(p).zfill(6) + str(order).zfill(6))


Measured memory_bytes: 130644
N = int(input())
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))

ans = 0
tmp1 = 0
for i in range(N):
    tmp1 = sum(A1[:(i+1)]) 
    tmp2 = sum(A2[i:N])
    
    ans = max(ans, tmp1+tmp2)
print(ans)

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

int main(void){

    int a,b,c,rectangular = 0,diamond = 0;
    char c1,c2;


    while(cin >> a >> c1 >> b >> c2 >> c){

        if(a * a + b * b == c * c){
            rectangular++;
        }
        if(a == b){
            diamond++;
        }

    }

    cout << rectangular << endl << diamond << endl;

    return 0;
}

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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define MAXN 11111

const int INF = 1 << 29 ;
typedef long long ll ;
typedef pair < int , int > pii ;

int main() {
    string s;
    cin >> s ;
    s[3] = '8' ;
    cout << s << endl ;
    return 0 ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
template<class T> bool chmax(T &a, const T &b) { if(a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if(a > b) { a = b; return true; } return false; }
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int A,B;
int main() {
  cin >> A>>B;
  if (B%A==0) {
    cout << A+ B << endl;
  }
  else cout << B-A << endl;
  
  return 0;
}

Measured memory_bytes: 3636
package main

import (
	"fmt"
	"strings"
)

func main() {
	a := 0
	b := 0
	fmt.Scan(&a)
	fmt.Scan(&b)
	if a < b {
		fmt.Println(strings.Repeat(fmt.Sprint(a), b))
		return
	}
	fmt.Println(strings.Repeat(fmt.Sprint(b), a))
}


Measured memory_bytes: 640
#import sys
#input = sys.stdin.readline
def main():
    n = int( input())
    P = list( map( int, input().split()))
    ans = 0
    for i in range(1, n-1):
        if P[i-1] < P[i] and P[i] < P[i+1]:
            ans += 1
        elif P[i-1] > P[i] and P[i] > P[i+1]:
            ans += 1
    print(ans)
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include <iostream>
#include <cstdio>
#include <algorithm>
 
using namespace std;
 
typedef long long ll;
const ll mod=998244353;
const int N = 2e5 + 10;
int n,q;
#define lson rt << 1	  // == rt * 2	 左儿子
#define rson rt << 1 | 1  // == rt * 2 + 1 右儿子
#define int_mid int mid = tree[rt].l + tree[rt].r >> 1
 
ll ten[N]; // 初始值
ll sum[N]; 
struct node {
	int l, r;
	ll val, lazy;
} tree[N * 4];
 
void push_up(int rt) {
	//tree[rt].val = min(tree[lson].val, tree[rson].val);
	//tree[rt].val = max(tree[lson].val, tree[rson].val);
	tree[rt].val = (tree[lson].val%mod + tree[rson].val%mod)%mod;
}
 
void push_down(int rt) {
	if (tree[rt].lazy) {
		tree[lson].lazy = tree[rt].lazy;
		tree[rson].lazy = tree[rt].lazy;
		//{ // 维护最大最小值
		//	tree[lson].val += tree[rt].lazy;
		//	tree[rson].val += tree[rt].lazy;
		//}
		{ // 维护和
			int l = tree[rt].l, r = tree[rt].r;
			int mid = l + r >> 1;
			tree[lson].val = 1ll * (sum[l]-sum[mid+1]+mod)%mod*tree[rt].lazy%mod;
			tree[rson].val = 1ll * (sum[mid+1]-sum[r+1]+mod)%mod*tree[rt].lazy%mod;
		}
		tree[rt].lazy = 0;
	}
}
 
void build(int rt, int l, int r) { // 建树
	tree[rt].l = l, tree[rt].r = r;
	tree[rt].lazy = 0;
	if (l == r) {
		tree[rt].val = ten[l]; // 给定一个初始值
		return;
	} else {
		int mid = l + r >> 1; // (l + r) / 2
		build(lson, l, mid);
		build(rson, mid + 1, r);
		push_up(rt);
	}
}
void update_interval(int rt, int l, int r, ll val) { // 区间更新
	if (l <= tree[rt].l && r >= tree[rt].r) {
		tree[rt].lazy=val;
		//tree[rt].val += val; // 维护最大最小值
		tree[rt].val=1ll*(sum[tree[rt].l]%mod-sum[tree[rt].r+1]%mod+mod)%mod*val%mod; // 维护和 
		return;
	}
	push_down(rt);
	int_mid;
	if (l <= mid) update_interval(lson, l, r, val);
	if (r > mid) update_interval(rson, l, r, val);
	push_up(rt);
}
ll query_interval(int rt, int l, int r) { // 区间查询
	if (l <= tree[rt].l && r >= tree[rt].r)
		return tree[rt].val;
	push_down(rt);
	int_mid;
	if (r <= mid) return query_interval(lson, l, r)%mod;
	else if (l > mid) return query_interval(rson, l, r)%mod;
	else {
		//return min(query_interval(lson, l, mid), query_interval(rson, mid + 1, r));
		//return max(query_interval(lson, l, mid), query_interval(rson, mid + 1, r));
		return (query_interval(lson, l, mid)%mod+query_interval(rson, mid + 1, r)%mod)%mod;
	}
}

int main()
{
	scanf("%d%d",&n,&q);
	ten[n]=sum[n]=1;
	for(int i=n;i>1;i--)
	{
		ten[i-1] = ten[i]*10%mod;
		sum[i-1]=(sum[i]+ten[i-1])%mod;
		//cout<<ten[i]<<" "<<sum[i]<<endl;
	}
	build(1,1,n);
	for(int i=1;i<=q;i++)
	{
		int l,r,d;
		scanf("%d%d%d",&l,&r,&d);
		update_interval(1,l,r,d);
		ll t=query_interval(1,1,n);
		printf("%lld\n",t);
	}
	return 0;
}

Measured memory_bytes: 19212
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())

m=min(a,b,c,d,e)
M=max(a,b,c,d,e)

if M-m<=k:
  print("Yay!")
else:
  print(":(")

Measured memory_bytes: 3064
import java.util.Scanner;

/**
 * http://abc068.contest.atcoder.jp/tasks/abc068_a
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		sc.close();
		
		System.out.println(String.format("ABC%03d", N));

	}

}

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

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  priority_queue<int> q;
  int x;
  for (int i = 0; i < n; i++) {
    cin >> x;
    q.push(x);
  }
  for (int i = 0; i < m; i++) {
    x = q.top();
    q.pop();
    q.push(x / 2);
  }
  long long res = 0;
  for (int i = 0; i < n; i++) {
    res += q.top();
    q.pop();
  }
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
typedef long long int ll;

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;

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;
}
ll gcd(ll a, ll b) { ll x, y; return extgcd(a, b, x, y);}

class llm{
	ll n;
public:
	llm(){n = 0;}
	llm(ll n){this->n = (n >= 0) ? (n % MOD) : (MOD - 1 - (-n-1 % MOD));}
	operator ll() const {return n;}
	llm operator+(const llm &y) const{ return llm((ll)*this + (ll)y);}
	llm operator+=(const llm &y) { *this = *this + y; return *this;}
	llm operator-(const llm &y) const{ return llm((ll)*this - (ll)y);}
	llm operator-=(const llm &y) { *this = *this - y; return *this;}
	llm operator-() const{ return llm(0) - *this;}
	llm operator*(const llm &y) const{ return llm((ll)*this * (ll)y);}
	llm operator*=(const llm &y) { *this = *this * y; return *this;}
	llm operator/(const llm &y) const{ return *this * y.inv();}
	llm operator/=(const llm &y) { *this = *this / y; return *this;}
	llm inv() const{
		ll x, y;
		if (extgcd(n, MOD, x, y) == 1) return llm(x);
  		return llm(0); // unsolvable
	}
	friend istream& operator >> (istream& os, llm& x);
	friend ostream& operator << (ostream& os, const llm& x);
};
istream& operator >> (istream& is, llm& x){ll n; is >> n; x = llm(n); return is;}
ostream& operator << (ostream& os, const llm& x){os << (ll)x; return os;}

template<typename T> T comb(ll n, ll k){
	T ret = 1;
	for(ll i=1;i<=k;i++) ret = ret * T(n - k + i) / T(i);
	return ret;
}

ll h, w, a, b;

int main(void){
	cin >> h >> w >> a >> b;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cout << ((i<b)+(j<a))%2;
		}
		cout << endl;
	}
    return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)
using Graph = vector<vector<int>>;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll N,M;
  cin>>N>>M;
  Graph G(N);
  for (int i = 0; i < M; ++i) {
    int a, b;
    cin >> a >> b;
    G[a-1].push_back(b-1);
    G[b-1].push_back(a-1);
  }
  vector<int> dist(N,-1); // 全頂点を「未訪問」に初期化
  queue<int> que;
  dist[0] = 0;
  que.push(0); 
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない
            dist[nv] = v;
            que.push(nv);
        }
    }
  cout<<"Yes"<<"\n";
  Fr(i,N-1){
    cout<<dist[i]+1<<"\n";
  }
}

Measured memory_bytes: 10288
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    AB = []
    for _ in range(N):
        a, b = map(int, input().split())
        AB.append((a, b))
    AB.sort(key=lambda x: x[0])
    print(AB[-1][0] + AB[-1][1])


if __name__ == '__main__':
    main()


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

using Graph = vector<vector<int>>;

void bfs(const Graph& friends, vector<int>& numbering, int* unit, bool* seen, int number, int n, int i) {
    // bool seen[n];
    // for(int j=0; j<n; j++) seen[j]=false;
    seen[i] = true;
    unit[i] = number;
    queue<int> todo;
    todo.push(i);
    int count = 1;

    while(!todo.empty()) {
        int v = todo.front();
        todo.pop();
        for(int next_v : friends[v]) {
            if(seen[next_v]) continue;
            seen[next_v] = true;
            unit[next_v] = number;
            todo.push(next_v);
            count++;
        }
    }
    numbering.push_back(count);
}

int main() {
    int n,m,k;
    cin>>n>>m>>k;
    Graph friends(n);
    //Graph block(n);
    int fri[n];
    for(int i=0; i<n; i++) fri[i]=0;

    for(int i=0; i<m; i++) {
        int a,b;
        cin>>a>>b;
        friends[a-1].push_back(b-1);
        friends[b-1].push_back(a-1);
        fri[a-1]++;
        fri[b-1]++;
    }
    // for(int i=0; i<k; i++) {
    //     int c,d;
    //     cin>>c>>d;
    //     block[c-1].push_back(d-1);
    //     block[d-1].push_back(c-1);
    // }

    int unit[n];
    bool seen[n];
    for(int i=0; i<n; i++) {
        unit[i] = -1;
        seen[i] = false;
    }

    int number = 0;
    vector<int> numbering;
    for(int i=0; i<n; i++) {
        if(unit[i]==-1) {
            bfs(friends,numbering,unit,seen,number,n,i);
            number++;
        }
    }

    int ans[n];
    // for(int i=0; i<n; i++) {
    //     int fri = friends[i].size();
    //     int blo = 0;
    //     for(int j : block[i]) {
    //         if(unit[i]==unit[j]) blo++;
    //     }
    //     ans[i] = numbering[unit[i]] - (fri+blo+1);
    // }

    for(int i=0; i<n; i++) {
        //int fri = friends[i].size();
        ans[i] = numbering[unit[i]] - fri[i] -1;
    }

    for(int i=0; i<k; i++) {
        int c,d;
        cin>>c>>d;
        if(unit[c-1]==unit[d-1]) {
            ans[c-1]--;
            ans[d-1]--;
        }
    }

    for(int i=0; i<n-1; i++) cout<<ans[i]<<' ';
    cout<<ans[n-1]<<endl;

    return 0;
}

Measured memory_bytes: 8312
n = gets.chomp.to_s[-1,1]
#puts n
#puts n[-1,1]
if n=="3"
    puts "bon"
else
    if  n== "0"
    puts "pon"
    else
        if n== "1"
        puts "pon"
        else
            if n== "6"
            puts "pon"
            else
            if n=="8"
            puts "pon"
            else
            puts "hon"
            end
            end
        end
    end
end



Measured memory_bytes: 14292
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7 #998244353
dir = [(-1,0),(0,-1),(1,0),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"

#UnionFindのクラス,0-indexed
class UnionFind():
    def __init__(self, n):
        self.n = n
        # parents = [-1,0,-4,1,1,1]のように、親の添字かマイナス要素数を表す
        self.parents = [-1] * n
    # find: xの親がすべてrootになる。これにより計算量削減(O(N) for all (not each))
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    def group_count(self):
        return len(self.roots())
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def main():
    n,m = map(int,ipt().split())
    uf = UnionFind(n)
    for i in range(m):
        a,b = map(int,ipt().split())
        uf.union(a-1,b-1)

    print(-min(uf.parents))

    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 94044
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <cmath>
#include <cstdlib>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int p[N];
    int count = 0;
    for(int i = 0; i < N; i++){
        cin >> p[i];
        if(p[i] != i+1){
            count++;
        }
    }

    if(count <= 2){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

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

#define MX 25
int A[MX], B[MX], C[MX];

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

    for(int i = 0; i < n; i++)
    {
        int x;
        cin>>x;
        x--;
        A[i] = x;
    }
    int ans = 0;
    for(int i = 0; i < n; i++ )
    {
        cin>>B[i];
        ans += B[i];
    }
    for(int i = 0; i < n-1; i++)cin>>C[i];
    int res = 0;
    for(int i = 1; i < n; i++)
    {
        if(A[i-1]+1 == A[i])res += C[A[i-1]];
    }
    cout<<res+ans<<endl;

}


Measured memory_bytes: 256
# solution

import io
import sys

data=int(input())

array=[list(map(int,input().split())) for i in range(data) ]

are=[list(map(int,input().split()))  for i in range(data) ]

array.sort(key=lambda x:x[1],reverse=1)

are.sort()

result=0

for b in are:
    for r in array:
        if b[1]>r[1] and b[0]>r[0]:
            result+=1
            array.remove(r)
            break
print(result)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;

int main(){
    int n,k;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n);
  int b[n]={0};
  int flag=0;
  for(int i=0;i<n;i++){
   if(a[i]==a[i-1]){
     b[flag]++;
   }else{
     flag++;
     b[flag]++;
   }
  }
  flag++;
  for(int i=flag;i<n;i++){
  b[i]=n+1;
  }
  sort(b,b+n);
  int ans=0;
  for(int i=0;i<flag-k;i++){
  ans=ans+b[i];
  }
  cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
n , y = map(int,input().split())
for i in range(n+1):
    for l in range(n-i+1):
        k = n-i-l
        if i*10000 + l*5000 + k*1000==y:
            print(i,l,k)
            exit()
print(-1,-1,-1)
    


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

template <typename T>
class MergeTree {
	const int n;
	vector<vector<T>> data;
	int size(int n) {
		int res;
		for (res = 1; res < n; res <<= 1);
		return res;
	}
public:
	MergeTree(const vector<T>& data_) : n(size(data_.size())), data(n * 2)
	{
		for (int i = 0; i < (int)data_.size(); i++) {
			data[i + n].push_back(data_[i]);
		}
		for (int i = n - 1; i >= 0; i--) {
			merge(data[i * 2].begin(), data[i * 2].end(), data[i * 2 + 1].begin(), data[i * 2 + 1].end(), back_inserter(data[i]));
		}
	}
	void for_each(int l, int r, function<void(const vector<T>&)> que) {
		l += n; r += n + 1;
		while (l < r) {
			if (l & 1) que(data[l++]);
			if (r & 1) que(data[--r]);
			l >>= 1; r >>= 1;
		}
	}
};

int main()
{
	int N, Q;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	MergeTree<int> mt(a);
	cin >> Q;
	for (int i = 0, l, r, D; i < Q; i++) {
		cin >> l >> r >> D;
		int mi = -1e7, ma = 1e7;
		mt.for_each(l, r, [&](const vector<int>& v) {
			int mait = lower_bound(v.begin(), v.end(), D) - v.begin();
			if (mait < (int)v.size()) ma = min(ma, v[mait]);
			int miit = upper_bound(v.begin(), v.end(), D) - v.begin() - 1;
			if (miit >= 0) mi = max(mi, v[miit]);
		});
		printf("%d\n", min(abs(mi - D), abs(ma - D)));
	}
	return 0;
}


Measured memory_bytes: 21900
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int two(int n){
	ll ans=1;
	rep(i,n){
		ans*=2;
	}
	return ans;
}
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);



    string s,t;
    cin >> s >>t;
    rep(i,s.size())for(int j=i+1;j<(int)s.size();j++){
        if(s[i]>s[j])swap(s[i],s[j]);
    }
 rep(i,t.size())for(int j=i+1;j<(int)t.size();j++){
        if(t[i]<t[j])swap(t[i],t[j]);
    }
//cout<<s<<" "<<t<<endl;
    if(s<t)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

const ll INF = (1LL<<59);

int main(void){
    int A, B, Q; cin >> A >> B >> Q;
    vector<ll> s(A+2);
    vector<ll> t(B+2);
    for(int i=1; i<=A; i++) cin >> s[i];
    for(int i=1; i<=B; i++) cin >> t[i];
    s[0] = -INF;
    s[A+1] = INF;
    t[0] = -INF;
    t[B+1] = INF;

    vector<ll> ans;
    for(int i=0; i<Q; i++){
        ll x; cin >> x;
        auto itr = lower_bound(s.begin(), s.end(), x);
        ll right1 = *itr;
        itr--;
        ll left1 = *itr;

        itr = lower_bound(t.begin(), t.end(), x);
        ll right2 = *itr;
        itr--;
        ll left2 = *itr;

        ll a = max(right1, right2) - x;
        ll b = x - min(left1, left2);
        ll c = (right1-left2) + min(right1-x, x-left2);
        ll d = (right2-left1) + min(right2-x, x-left1);
        ll res = min(min(a,b), min(c,d));
        ans.push_back(res);
    }

    for(int i=0; i<ans.size(); i++) cout << ans[i] << endl;


}

Measured memory_bytes: 3828