akhauriyash/Code-Regression huggingface dataset:
'''
ITP-1_9-B
 ?????£?????????
???????????¢????????????????????????????????? n ???????????????????±±????????£?????????????????????
1???????????£???????????§??????????????? h ???????????????????????¨???????????????????????????????????£????????????????±±??????????????????????????????
?????????????±±?????\???????????????????????????????????§?????????????????????
abcdeefab
?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
????????°???????????? h ??? 4 ??§?????£?????????????????¨????????????4?????? abcd ????????????????????? eefab ???????°??????£?????????????????§??\??????????????????????????????
eefababcd
???????????£???????????????????????°??????????????????
?????????????±±???????????????????????????????????¨ h ????????????????????????????????????????????????????????????????????????????????°?????????????????????????????????
 Constraints
?????????????????????200????¶??????????
?????£?????????????????°???100????¶??????????
???Input
?????°??????????????????????????\?????¨?????????????????????????????????????????????????????\????????¢?????§?????????????????????
????????????????????¨????????????
?????£??????????????° m
h1
h2
  .
  .
hm
????????????????????¨??????????????? "-" ?????¨?????\?????????????????¨????????????
???Output
??????????????????????????????????????????????????????????????????????????????????????????????????????
'''
while(True):
    # inputData
    cards = input()

    # endCheck
    if cards == '-':
        break
 
    # shuffleCnt
    shufflCnt = int(input())
 
    for i in range(shufflCnt):
        # shuffleData
        shuffleData = int(input())
        cards = cards[shuffleData:] + cards[0:shuffleData]
 
    # outputData 
    print(cards)

Measured memory_bytes: 7692
#include <bits/stdc++.h>
#define foi(i,k,n) for(int i = (int)k; i < (int)n; ++i)

using namespace std;
using ll = unsigned long long;
using ii = pair<int,int>;

int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  ll x;
  cin >> x;
  ll v = 100;
  int ans = 0;
  while (v < x) {
    ll low = 1+v, high = 1e18, b = -1;
    while (low <= high) {
      ll mid = low + ((high - low) >> 1);
      if (mid >= v + (v/100)) {
        b = mid;
        high = mid - 1;
      } else {
        low = 1 + mid;
      }
    }
    v = b;
    ans++;
  }
  cout << ans << '\n';
  return 0;
}


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

int main() {
	int N;
	cin >> N;
	int Odd = 0;
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		if (A % 2 == 1) Odd++;
	}
	if (Odd % 2 == 0) cout << "YES";
	else cout << "NO";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

int main()
{
  ll A, B, C;
  cin >> A >> B >> C;

  if (A == B && B == C)
    FINALANS("No");
  else if (A  == B||B==C||C==A)
    FINALANS("Yes");
  else
    FINALANS("No");
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const double pi=acos(-1);
const double eps=1e-10;
const vi emp;

struct point{
	int x,y;
	point operator+(point p){
		return point{x+p.x,y+p.y};
	}
	point operator-(point p){
		return point{x-p.x,y-p.y};
	}
	point operator*(int p){
		return point{x*p,y*p};
	}
	point operator/(int p){
		if(!p) return point{0,0}; 
		return point{x/p,y/p};
	}
	bool operator==(point p)const{
		return x==p.x&&y==p.y;
	}
	bool operator<(point p)const{
		if(x!=p.x) return x<p.x;
		return y<p.y;
	}
};

typedef pair<point,point> pp;
typedef vector<point> VP;
const point O{0,0};

void Point_in(point& p){
	cin>>p.x>>p.y;
}

void Point_out(point p){
	cout<<p.x<<' '<<p.y<<endl;
}

int n,m;

int main(){
	while(1){
		cin>>n;
		if(!n) break;
		VP p(n);
		set<point> st;
		for(auto i=p.begin();i!=p.end();i++) Point_in(*i);
		cin>>m;
		VP q(m);
		for(auto i=q.begin();i!=q.end();i++){
			Point_in(*i);
			st.insert(*i);
		}
		for(auto i=q.begin();i!=q.end();i++){
			point r=*i-p[0];
			bool flag=1;
			for(auto j=p.begin()+1;j!=p.end();j++){
				if(st.find(*j+r)==st.end()){
					flag=0;
					break;
				}
			}
			if(flag){
				Point_out(r);
				break;
			}
		}
	}
}

Measured memory_bytes: 3064
#!/usr/bin/env python3

from typing import *

YES = 'Yes'
NO = 'No'

# def solve(n: int, dlist: List[List[int]]) -> bool:
def solve(n, dlist):
    flag=False
    c = 0
    for d in dlist:
        if d[0]==d[1]:
            c = c+1
        else:
            if c>=3:
                return True
            c=0

    return c>=3

def main():
    n = int(input())
    dlist = []
    for i in range(n):
        dlist.append(list(map(int, input().split())))
    print(YES if solve(n, dlist) else NO)

if __name__ == '__main__':
    main()


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

char x[200];
int i,fl;

using namespace std;
int main(){
	gets(x);
	for(i=0;i<=strlen(x)-1;i++){
		if(x[i]=='C'){
			fl++;
			break;
		}
	}
	for(i=i+1;i<=strlen(x)-1;i++){
		if(x[i]=='F'){
			fl++;
			break;
		}
	}
	if(fl==2)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
	}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


i64 d[3][3];


int main() {
  i64 P, Q, R;
  cin >> P >> Q >> R;

  d[0][1] = P;
  d[0][2] = R;
  d[1][0] = P;
  d[1][2] = Q;
  d[2][0] = R;
  d[2][1] = Q;

  i64 minv = 100000;
  REP(i, 3) {
    REP(j, 3) {
      if (i == j) continue;
      REP(k, 3) {
        if (j == k) continue;
        if (i == k) continue;
        i64 v = d[i][j] + d[j][k];
        if (v < minv)
          minv = v;
      }
    }
  }
  cout << minv << endl;


  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner (System.in);
        int x = in.nextInt();
        int z,y,a,m;
        z = x/500;
        y = z * 1000;
        z = z * 500;
        z = (x-z)/5;
        a = z * 5;
        m = a + y;
        System.out.println(m);
    }
}


Measured memory_bytes: 35636
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const int MOD = 1000000007;

int main() {
  string s;
  int i, len, flag = true;
  cin >> s;
  len = s.length();
  for (i = 0; i < len; i++)
    if (s[i] != s[len - i - 1]) flag = false;
  for (i = 0; i < (len - 1) / 2; i++)
    if (s[i] != s[(len - 1) / 2 - i - 1]) flag = false;
  for (i = (len + 3) / 2; i < len; i++)
    if (s[i] != s[len - i - 1]) flag = false;
  cout << ((flag) ? "Yes" : "No") << endl;
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    int N; cin >> N;
    vector<pair<int,int>> X(N); REP(i,N){cin >> X[i].first; X[i].second=i;}
    SORT(X);
    VI ans(N);
    int med1 = X[N/2-1].first, med2 = X[N/2].first;
    REP(i,N){
        if(X[i].first <= med1) ans[X[i].second] = med2;
        else ans[X[i].second] = med1;
    }
    REP(i,N) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 4480
import sys
input = sys.stdin.readline

n = int(input())
h = list(map(int, input().split()))
ans = 0
temp = 0
pri = h[0]
for i in range(1, n):
    if pri >= h[i]:
        temp += 1
    else:
        ans = max(ans, temp)
        temp = 0
    pri = h[i]
ans = max(ans, temp)
print(ans)

Measured memory_bytes: 14252
#include<bits/stdc++.h>
#define mp make_pair
#define F first
#define S second
using namespace std;

typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<int> vi;

int main(){
//	freopen(".in", "r", stdin);
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	ll n, x, b, a, s;

	cin >> n >> x;

	s = n;
	b = n - x;
	a = x;
	while(a != 0){
		s += 2 * (b / a) * a;
		x = b % a;
		b = a;
		a = x;
	}

	s -= b;

	cout << s << '\n';

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int r, g, b, n;
  cin >> r >> g >> b >> n;
  int ans = 0;
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= n; ++j) {
      int k = n - (r * i) - (g * j);
      if (k < 0 || k % b) continue;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

#define ll long long
#define mod 1000000007
#define f(i, a, b) for (long long i = a; i < b; i++)
#define rep(i, a, b) for (long long i = a; i <= b; i++)
#define fm(i, a, b, c) for (long long i = a; i > b; i--)
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define t   \
  ll t;     \
  cin >> t; \
  while (t--)
#define pb(i) push_back(i)
#define mp(i, j) make_pair(i, j)
#define fast                   \
  ios::sync_with_stdio(false); \
  cin.tie(NULL)

int main()
{
  fast;
  ll n;
  cin >> n;
  ll sum = 0;
  rep(i, 1, n)
  {
    if (i % 3 == 0 || i % 5 == 0)
    {
      continue;
    }
    sum += i;
  }
  cout << sum << "\n";
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;




int main(){
      //memset( par, -1, sizeof par );
    int n;
    cin>>n;
     int a[n];
     for(int i=0;i<n;i++)cin>>a[i];
     sort(a,a+n);
     int ans=0;
     for(int i=0;i<n;i++){
         for(int j=0;j<i;j++){
              int k=a[i]+a[j];
              int s=lower_bound(a,a+n,k)-a;
              int y=i+1;
              ans+=max(0,s-y);
         }
     }
     cout<<ans;
}

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

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)x.size()
#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i, k , n) for(int i = k; i <= n; i++)
typedef long long ll;

const char nl = '\n' ;
const ll MOD = 1e9 + 7;


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

   int n; cin >> n;
   map<char, int> m;
   rep(i, n)
   {
      char x; cin >> x;
      m[x]++;
   }
   string res = m.size() == 3 ? "Three" : "Four";
   cout << res << nl;
   return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <string>
using namespace std;
 
int main() {
  //input
  int n; cin >> n;
  long T; cin >> T;
  long sum;
  long ans;
  sum = 0;
  ans = 0;
  vector<long> t(n);
  for(int i = 0; i < n; i++)  cin >> t[i];
  
  //compute
  for(int i = 0; i < n - 1; i++) {
    if(t[i + 1] > t[i] + T){
          sum += t[i + 1] - t[i] - T;
      }
  }

  ans = t[n -1] + T - sum;

  //output
  cout << ans << endl;
 
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  map<ll,ll> m;
  rep(i,n){
    ll a; cin>>a;
    m[a]++;
    m[a-1]++;
    m[a+1]++;
  }
  ll ans=0;
  for(auto e: m){
    chmax(ans,e.second);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 6144
#include <iostream>
#include<algorithm>
using namespace std;
int main(void){
    int A,B,N;
    cin>>N>>A>>B;
   if(N>=A+B){
       
       cout<<min(A,B)<<endl;
       cout<<0<<endl;
       
   } else{
       
       cout<<min(A,B)<<endl;
       cout<<abs(N-A-B)<<endl;
   }
  
    
}

Measured memory_bytes: 256
#include<stdio.h>

int solve(int,int);

int n,A[50];

int main(){
  int q,M,i;

  scanf("%d",&n);
  for(i = 0;i <= n-1;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i = 0;i <= q-1;i++){
    scanf("%d",&M);
    if(solve(0,M)){
      printf("yes\n");
    }
    else{
      printf("no\n");
    }
  }
    return 0;
}

int solve(int i,int m){
  if(m == 0){
    return 1;
  }
  if(i >= n){
    return 0;
  }
  int res = solve(i + 1,m) || solve(i + 1,m - A[i]);
  return res;
}




Measured memory_bytes: 2104
#!/usr/bin/env python3
import sys


def solve(N: int):
    l = len(str(N))
    k = {}
    for i in range(1,10):
        for j in range(1,10):
            k[str(i)+str(j)] = 0
    for x in range(1, N+1):
        s = str(x)
        if s[-1] != "0":
            k[s[0]+s[-1]] += 1

    k_new = {}
    for i in range(1,10):
        k_new[str(i)+str(i)] = k[str(i)+str(i)]**2
        for j in range(i+1,10):
            n = k[str(i)+str(j)] * k[str(j)+str(i)]
            k_new[str(i)+str(j)] = n * 2

    # print(k_new)
    print(sum([t for t in k_new.values()]))

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


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

int main()
{
	int n, k; cin >> n >> k;
	
	vector<char> d(k); for (int i = 0; i < k; i++) cin >> d[i];
	
	int ans;
	for (int i = n; i <= 100000; i++) {

		string i_string = to_string(i);
		bool can = true;
		for (int j = 0; j < i_string.size(); j++) {
			for (int x = 0; x < k; x++) {				
				if (i_string[j] == d[x]) {
					can = false;
				}
			}
		}
		if (can) {
			ans = i;
			break;
		}

	}

	cout << ans << endl;	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int count(int d);
int N = 0;
int M = 0;

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

  if(N == 2){
    if(M ==1){
      std::cout << "YES" << std::endl;
    }else{
      std::cout << "NO" << std::endl;
    }
   }else{
       std::cout << "NO" << std::endl;
   }
    return 0;
}

int count (int d){
    if(d == 5){
      N++;
    }else if(d==7){
      M++;
    }
    return 0;
}

Measured memory_bytes: 256
import sys
t='X'
for e in sys.stdin:
 for i in'0123456789'[(e[0]==t)*(e[1]!='+')or('+X'in e)*('+X='not in e):]:
  l,r=e.replace(t,i).split('=')
  if eval(l)==int(r):print(i);break
 else:print('NA')


Measured memory_bytes: 5616
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVSORT(v) sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){

  int n,d;cin>>n>>d;

  int x[n][d];
  REP(i,n){
    REP(j,d){
      cin>>x[i][j];
    }
  }
  int ans = 0;

  REP(i,n){
    for(int j = i+1;j<n;j++){
      int sum = 0;
      REP(k,d){
        sum += pow(x[i][k]-x[j][k],2);
      }
      if(sum == pow((int)sqrt(sum),2)){
        ans++;
      }
    }
  }

  cout<<ans<<endl;

 

  return 0;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as C
import           Data.Maybe ( fromJust )
import           Data.List ( sortBy )
import qualified Data.Vector.Unboxed as U

getParm :: IO [Int]
getParm = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

main :: IO ()
main = do
  n <- readLn :: IO Int
  ass <- getParm
  print $ f n ass

sort' :: [Int] -> [Int]
sort' = sortBy (flip compare)

f :: Int -> [Int] -> Int
f n = U.sum . U.map snd . U.take n . U.filter (odd . fst) . U.indexed . U.fromList . sort'

Measured memory_bytes: 51580
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int MAX = 510000;
const ll MOD = 10000000007;
ll fac[MAX], finv[MAX], inv[MAX];

int main(){
  ll v,e,r,cnt=0;cin>>v>>e>>r;
  vvll g(e,vll(3));vll dis(v,MOD);
  rep(i,0,e){
    ll s,t,d;cin>>s>>t>>d;
    
    g[i][0]=s; g[i][1]=t; g[i][2]=d;
  }
  dis[r]=0;
  
  while(cnt<v){
    bool end=true;
    for(vll u:g){
      if(dis[u[0]]!=MOD&&dis[u[0]]+u[2]<dis[u[1]]){
        dis[u[1]]=dis[u[0]]+u[2];
        end=false;
      }
    }
    if(end)break;
    cnt++;
  }
  if(cnt==v){out("NEGATIVE CYCLE");}
  else{
    rep(i,0,v){
      if(dis[i]!=MOD){out(dis[i]);}
      else{out("INF");}
    }
  }
  return 0;
}





Measured memory_bytes: 3272
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N ;
    cin >> N;
    int A[N];
    int check = 0;
    for(int i=0;i<N;i++){
        cin >> A[i];
        if(A[i] %2 == 0 ){
            if(A[i] %3!=0 && A[i]%5 != 0){
                cout << "DENIED" << endl;
                check = 1;
                break;
                }
        }
    }
    if(check ==0){
        cout << "APPROVED" << endl;
    }
    
}


Measured memory_bytes: 256
A, B, C = map(int, input().split())

D = sorted([A,B,C])

count = int((D[2] - D[0])/2) + int((D[2] - D[1])/2)
E = (D[2] - D[0])%2 + (D[2] - D[1])%2

if E == 2:
    count += 1
elif E == 1:
    count += 2

print(count)


Measured memory_bytes: 3060
n, k, q = map(int, input().split())
a = [int(input()) - 1 for _ in range(q)]

answer = [0] * n

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

for i in range(n) :
    if answer[i] > q - k :
        print('Yes')
    else :
        print('No')


Measured memory_bytes: 8636
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int t,n,i,j,cn=0;
    string s,ss;
    cin>>s>>ss;
    for(i=0;i<s.size();i++)
    {
        if(s[i]!=ss[i])cn++;
    }
    cout<<cn<<endl;
    return 0;
}


Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;

int main(int argc, char *argv[]){
	ios::sync_with_stdio(false);
	cin >> n;
	vector<ll> v(n);
	REP(i, n) cin >> v[i];
	ll ans = 0;
	for(ll x = 1ll << 56; x > 0; x >>= 1){
		while(1){
			sort(ALL(v));
			if(v.back() < n * x) break;
			ans += x;
			v.back() -= n * x;
			REP(i, n-1) v[i] += x;
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
  bool cards[4][14];
  int n, rank;
  char suit;
  for(int s =0; s<4; s++)
    for(int r=1; r<=13; r++)
      cards[s][r]=0;
  cin >> n;
  for(int i = 0;i<n; i++){
    cin>>suit>>rank;
    if(suit =='S')cards[0][rank]=1;
    if(suit =='H')cards[1][rank]=1;
    if(suit =='C')cards[2][rank]=1;
    if(suit =='D')cards[3][rank]=1;
  }
  for(int s = 0; s<4; s++){
    for(int r=1; r <=13; r++){
      if(cards[s][r])continue;
      if(s==0)suit = 'S';
      if(s==1)suit = 'H';
      if(s==2)suit = 'C';
      if(s==3)suit = 'D';
      cout<<suit<<" "<<r<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3096
#include <iostream>

using namespace std;

int main() {
  int x1,x2,x3,x4,y1,y2,y3,y4;
  cin >> x1 >> y1 >> x2 >> y2;

  int a = x2-x1;
  int b = y2-y1;
  
  x3 = x2-b;
  y3 = y2+a;
  x4 = x3-a;
  y4 = y3-b;

  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>

using namespace std;

bool cmp(const pair<string, int>& a, const pair<string, int>& b)
{   
    if (a.first != b.first)
        return a.first < b.first;
    else
        return a.second >= b.second;
}

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

    vector<pair<string, int>> p(N), q(N);

    for (auto i = 0; i < N; i++) {
        cin >> p[i].first >> p[i].second;
        q[i] = p[i];
    }
    sort(p.begin(), p.end(),cmp);
    for (auto i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (p[i] == q[j]) {
                cout << j + 1 << endl;
                break;
            }
        }
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
// #define int long long
#define mod (int)(1e9 + 7)
#define pb push_back
#define ll long long int
using namespace std;
typedef pair<int,int> pii;

ll gcd(ll a, ll b){
  return b ? gcd(b, a % b) : a;
}

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

  int t,res;
  cin>>res;
  res=fabs(res-X);

  for(int i=1;i<N;i++){
    cin>>t;
    res=gcd(res,fabs(t-X));
  }
  cout<<res<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string a;
int main(void){
	getline(cin,a);
	int b=a.size();
	for(int i=0;i<b;++i){
		if(a[i]=='C'){
			for(int j=i;j<b;++j){
				if(a[j]=='F'){
					cout<<"Yes"<<endl;
					return 0;
				}
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <ctype.h>
#include <cstdlib>
#include <cmath>
#include <stack>
#define _GLIBCXX_DEBUG
using namespace std;

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

Measured memory_bytes: 3592
#include <iostream>

using namespace std;

int main()
{
    string s;
    int k;
    cin>>k;
    cin>>s;
    if(k>=s.length())
        cout<<s<<endl;
    else
    {
        for(int i=0;i<k;i++)
            cout<<s[i];
        cout<<"..."<<endl;
    }

}


Measured memory_bytes: 3624
n = int(input())
A = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))

ans = [0] * (2 ** n)
for i in range(2 ** n):
    p = 1
    for j in range(n):
        if i & p:
            ans[i] += A[j]
        p *= 2

for i in range(q):
    if m[i] in ans:
        print("yes")
    else:
        print("no")



Measured memory_bytes: 42964
a=input()
b=input()
c=input()
s="a"
for i in range(len(a)+len(b)+len(c)):
  if s=="a" and len(a)>0:
    s=a[0]
    a=a[1:]
  elif s=="a" and len(a)==0:
    print("A")
    exit()
  elif s=="b" and len(b)>0:
    s=b[0]
    b=b[1:]
  elif s=="b" and len(b)==0:
    print("B")
    exit()
  elif s=="c" and len(c)>0:
    s=c[0]
    c=c[1:]
  else:
    print("C")
    exit()

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

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

    long long a[n];

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

    int bit[n][60];
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < 60; j++)
        {
            bit[i][j] = a[i] % 2;
            a[i] = a[i] >> 1;
        }
    }


    int count[60] = {};
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < 60; j ++)
        {
            if (bit[i][j] == 1)
            {
                count[j]++;
            }
        }
    }
    // calc
    const long long DIV = 1000000007;
    long long ans = 0;
    long long base = 1;
    for (int i = 0; i < 60; i++)
    {
        //cout << i << ": " << count[i] << ", " << n- count[i] << endl;
        long long temp = (count[i] * base) % DIV;
        ans += (temp * (n - count[i])) % DIV;
        base = (base * 2) % DIV;
    }
    ans = ans % DIV;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 72960
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

int main(){
	int N;
	cin >> N;
	vector<int> a(N);
	for(int i=0; i<N; ++i) cin >> a[i];
	int ans = 0;
	for(int i=0; i<N; ++i){
		if(i%2==0 && a[i]%2==1) ++ans;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int n;
    double ans;
    cin >> n;
    vector<int> v(n);
    for (int i=0; i<n; i++) {
        cin >> v.at(i);
    }
    sort(v.begin(), v.end());
    for (int i=0; i<n; i++) {
        if (i==0) {
            ans = v.at(i);
        } else {
            ans = ((double)ans + v.at(i)) / 2;
        }
    }
    cout << ans << endl;
    return 0;
}


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

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

  int ans = 0;
  while (a <= b) {
    if (c % a == 0) {
      ans++;
      //cout << ans <<"ふやしたよ" << endl;
    }
    /*
    else {
      cout << "なにもしてないよ" << endl;
    }
    */
    a++;
    //cout << a << " ふやした！" << endl;
  }
  cout << ans << endl;
}



Measured memory_bytes: 3104
def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x%y)


N = int(input())
a = list(map(int, input().split()))
max_gcd = 0
L = [0] * (N + 2)
R = [0] * (N + 2)

for i in range(N):
    L[i+2] = gcd(L[i+1], a[i])
for i in range(N):
    R[-3-i] = gcd(R[-2-i], a[-1-i])

for i in range(N+1):
    max_gcd = max(max_gcd, gcd(R[i],L[i]))
print(max_gcd)

Measured memory_bytes: 63856
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a;
  cin >> a;
  int key = 0;
  for(int i = 0;i<26;i++){
    for(int j = 0;j<15;j++){
      if(a == 4*i+7*j){
        cout << "Yes" << endl;
        key = 1;
        break;
      }
    }
    if(key == 1)
        break;
  }
  if(key == 0)
    cout << "No" << endl;
}

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

const int N = 2510;
const int INF = 1e9;

int n, m, pp;

vector<pair<int, int>> G[N]; // {to, cost}
vector<int> To[N];
vector<int> Ot[N];
vector<int> D(N);

vector<bool> isIn(N); // isIn[i]: 頂点iが1からNまでのルートに含まれているか（経路長問わず）
vector<bool> isInNegativeCycle(N);
vector<bool> from1(N);
vector<bool> fromN(N);

// 頂点1からたどり着ける頂点を探索
void dfs1(int now){
    from1[now] = true;
    if(now == n - 1) return;
    for(int i = 0; i < To[now].size(); i++){
        int to = To[now][i];
        if(from1[to]) continue;
        dfs1(to);
    }
}

// 頂点Nからたどり着ける頂点を探索
void dfsN(int now){
    fromN[now] = true;
    if(now == 0) return;
    for(int i = 0; i < Ot[now].size(); i++){
        int to = Ot[now][i];
        if(fromN[to]) continue;
        dfsN(to);
    }
}


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

    cin >> n >> m >> pp;
    for(int i = 0; i < m; i++){
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        c -= pp;
        G[a].push_back({b, -c});
        To[a].push_back(b);
        Ot[b].push_back(a);

    }

    isIn.resize(n);
    isInNegativeCycle.resize(n);
    from1.resize(n);
    fromN.resize(n);

    dfs1(0);
    dfsN(n - 1);

    for(int i = 0; i < n; i++){
        isIn[i] = from1[i] & fromN[i];
    }

    // ベルマンフォード
    D.resize(n);
    for(int i = 0; i < n; i++){
        D[i] = INF;
    }
    D[0] = 0;

    for(int oi = 0; oi < n; oi++){
        for(int i = 0; i < n; i++){
            for(int j = 0; j < G[i].size(); j++){
                pair<int, int> p = G[i][j];
                int to = p.first;
                int cost = p.second;
                if(D[to] > D[i] + cost){
                    D[to] = D[i] + cost;
                }
            }
        }
    }

   for(int oi = 0; oi < n; oi++){
        for(int i = 0; i < n; i++){
            for(int j = 0; j < G[i].size(); j++){
                pair<int, int> p = G[i][j];
                int to = p.first;
                int cost = p.second;
                if(D[to] > D[i] + cost){
                    D[to] = D[i] + cost;
                    isInNegativeCycle[to] = true;
                }
            }
        }
    }

    bool nc = false; // 負のサイクルが1からNまでの経路に含まれるか
    for(int i = 0; i < n; i++){
        if(isIn[i] & isInNegativeCycle[i]){
            nc = true;
            break;
        }
    }

    if(nc){
        cout << -1 << endl;
    }else{
        cout << max(0, -1 * D[n - 1]) << endl;
    }

    return 0;
}

Measured memory_bytes: 768
n = int(input())
mod = (10**9)+7
n_all = 10**(n) % mod
bad_0 = 9**(n)%mod
bad_9 = 9**(n)%mod
bad_18 = 8**(n)%mod

print((n_all-bad_0-bad_9+bad_18)%mod)

Measured memory_bytes: 10600
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

using namespace std;

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

	map<long long, int> m;
	set<long long> s;
	for (int i = 0; i < N; ++i) {
		int x;
		cin >> x;
		if (++m[x] >= 2) {
			s.insert(x);
		}
	}
	vector<long long> v(s.rbegin(), s.rend());
	if (v.size() >= 1 && m[v[0]] >= 4) {
		cout << v[0] * v[0] << endl;
	}
	else if (v.size() >= 2 && m[v[0]] >= 2 && m[v[1]] >= 2) {
		cout << v[0] * v[1] << endl;
	}
	else {
		cout << 0 << endl;
	}
}


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

int main(){
  int sn,tn,c;
  cin >> sn >> tn >> c;
  vector<int>b(tn);
  for(int i=0;i<tn;i++)
    cin >> b.at(i);
  int ans=0,su,x;
  for(int i=0;i<sn;i++){
    su=0;
    for(int j=0;j<tn;j++){
      cin >> x;
      su+=x*b.at(j);
    }
    if(su+c>0)
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	A := sc.nextStr()
	B := sc.nextStr()
	C := sc.nextStr()

	fmt.Fprintln(wtr, string(A[0])+string(B[1])+string(C[2]))
	wtr.Flush()
}


Measured memory_bytes: 640
#include<iostream>
#include<fstream>
#include<sstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdlib>
#include<climits>
#include<utility>
#include<cctype>
using namespace std;

#define ull unsigned long long
#define stt(it,order) sort(it.begin(),it.end(),order)
#define st(it) sort(it.begin(),it.end())
#define ll long long
#define rep(i,j) for(int i=0;i<j;++i)
#define loop(i,a,j) for(int i=a;i<j;++i)
#define mpi(it,table,T,E) for(map<T,E>::iterator it = table.begin();it!=table.end();++it)
#define PI 3.141592654
/*
ifstream fin("input.txt");
ofstream fout("output.txt");
#define cin fin
#define cout fout
*/

struct data{
	int i;
	double t;
};

bool order(data a,data b){
	return a.t < b.t;
}

vector<data> a;
vector<data> b;
vector<data> c;
vector<data> e;

int main(){
	data tmp;
	while(scanf("%d %lf",&tmp.i,&tmp.t) != EOF){
		a.clear();b.clear();c.clear();e.clear();
		a.push_back(tmp);
		rep(i,7){
			scanf("%d %lf",&tmp.i,&tmp.t);
			a.push_back(tmp);
		}
		rep(i,8){
			scanf("%d %lf",&tmp.i,&tmp.t);
			b.push_back(tmp);
		}
		rep(i,8){
			scanf("%d %lf",&tmp.i,&tmp.t);
			c.push_back(tmp);
		}
		stt(a,order);
		stt(b,order);
		stt(c,order);
		printf("%d %.2f\n",a[0].i,a[0].t);
		printf("%d %.2f\n",a[1].i,a[1].t);
		printf("%d %.2f\n",b[0].i,b[0].t);
		printf("%d %.2f\n",b[1].i,b[1].t);
		printf("%d %.2f\n",c[0].i,c[0].t);
		printf("%d %.2f\n",c[1].i,c[1].t);
		
		e.push_back(a[2]);
		e.push_back(b[2]);
		e.push_back(c[2]);
		stt(e,order);
		printf("%d %.2f\n",e[0].i,e[0].t);
		printf("%d %.2f\n",e[1].i,e[1].t);
		
	}
	return 0;
}

Measured memory_bytes: 1252
N=int(input())
G = [[] for i in range(N)]
ans = 0
for i in range(1,N+1):
    ans += (N-i+1)*(N-i+2)//2
for i in range(N-1):
    a, b = map(int, input().split())
    a, b = min(a,b),max(a,b)
    #print(a,b)
    ans -= a * (N-b+1)
print(ans)

Measured memory_bytes: 83060
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval<newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int N = in();
  vi H(N);
  rep(i,N) cin >> H[i];
  int ok=1;
  int m=H[0];
  rep(i,1,N){
    if(m<=H[i]){
      m = H[i];
      ok++;
    }
  }
  cout << ok << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int N;
    int i, j;
    unsigned char flag = 0;
    
    scanf("%d%*c", &N);
    for(i = 0; i * 4 <= N; i++){
        for(j = 0; j * 7 <= N; j++){
            if(i * 4 + j * 7 == N){
                flag = 1;
                break;
            }
        }
    }
    
    if(flag == 1){
        printf("Yes\n");
    }else{
        printf("No");
    }
    
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

int main(){
    int n;
    cin >> n;
    vector<int> ans(n);
    rep(i,1,n-1){
        int a;
        cin >> a;
        a--;
        ans[a]++;
    }
    rep(i,0,n-1)cout << ans[i] << endl;


    // cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	int k;
	cin>>k;
	long double a=k/3.00;
	long double b=a;
	long double h=(k-a-b);
	long double ans=a*b*h;
	cout<<setprecision(12)<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

int main()
{
       int x, a, b, i, result;

       scanf("%d%d%d", &x, &a, &b);

       for( i = 0; x >= a+b*i; i++ )
       {
              result = x - (a + b * i);
              if( result >= x ) break;
       }
       printf("%d\n", result );
       return 0;
}

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

int main(void)
{
	string str0, str1, str2, c;
	int N, T, F;
	bool rFlag = false;
	cin >> str1 >> N;
	rep(i, N)
	{
		cin >> T;
		if (T == 1)
		{
			rFlag = !rFlag;
		}else
		{
			cin >> F >> c;
			if (F == 1 && rFlag == false ||
				F == 2 && rFlag == true)
			{
				str0.append(c);
			}
			else 
			{
				str2.append(c);
			}
		}
	}


	if (rFlag == true)
	{
		swap(str0, str2);
		reverse(str1.begin(), str1.end());
	}
	reverse(str0.begin(), str0.end());

	cout << str0 + str1 + str2 << endl;
}


Measured memory_bytes: 1348
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll   long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f
#define pi 3.1415926535898
using namespace std;
const int N=2e5+10;
const int mod=1e9+7;
int a[N];
int main()
{
    int n;
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    int t=a[n]/2;
    int mins=mod;
    int p;
    for(int i=1; i<=n; i++)
    {
        if(abs(a[i]-t)<=mins)
        {
            mins=abs(a[i]-t);
            p=a[i];
        }
    }
    if(n == 2)
        printf("%d %d\n", a[2], a[1]);
    else
        printf("%d %d\n", a[n], p);
    return 0;
}


Measured memory_bytes: 4112
package main

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

func main() {
	var n int
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	n, _ = strconv.Atoi(sc.Text())

	set := make(map[string]struct{})
	for i := 0; i < n; i++ {
		sc.Scan()
		set[sc.Text()] = struct{}{}
	}

	fmt.Println(len(set))
}


Measured memory_bytes: 13928
#include<stdio.h>
#define N 100000

int BinarySearch(int, int, int[]);

int main(){
  int len=0,key=0,s[N],t,i,count=0;

  scanf("%d",&len);
  for( i = 0 ; i < len ; i++ ){
    scanf("%d",&s[i]);
  }

  scanf("%d",&key);
  for( i = 0 ; i < key ; i++ ){
    scanf("%d",&t);
    count += BinarySearch(len,t,s);
  }
  printf("%d\n",count);

  return 0;
}

int BinarySearch(int r,int k,int data[]){
  int l=0,mid=0;

  while( l < r ){
    mid = (l + r) / 2;

    if( k == data[mid] ) return 1;

    if( k < data[mid] ) r = mid;
    else if( k > data[mid] ) l = mid+1;
  }

  return 0;
}



Measured memory_bytes: 2084
n, k = map(int, input().split())
dp = [list(map(int, input().split())) for i in range(n)]
MOD = 10**9 + 7

def _mul(A, B, MOD):
    C = [[0] * len(B[0]) for i in range(len(A))]
    for i in range(len(A)):
        for k in range(len(B)):
            for j in range(len(B[0])):
                C[i][j] = (C[i][j] + A[i][k]*B[k][j]) % MOD
    return C

#A**n
def pow(A, n, MOD):
    B = [[0] * len(A) for i in range(len(A))]
    for i in range(len(A)):
        B[i][i] = 1
    while n > 0:
        if n & 1:
            B = _mul(A, B, MOD)
        A = _mul(A, A, MOD)
        n  = n // 2
    return B

ans_matrix = pow(dp, k, MOD)
ans = 0
for i in range(n):
    ans += sum(ans_matrix[i])
    ans %= MOD
print(ans)


Measured memory_bytes: 41452
<?php
    for($i=0;$i<5;$i++){
        $x[$i] = intval(trim(fgets(STDIN)));
    }
    $k = intval(trim(fgets(STDIN)));
    
    for($i=0;$i<4;$i++){
        for($j=$i+1;$j<5;$j++){
            if($x[$j]-$x[$i]>$k){
                echo ":(";
                exit;
            }
        }
    }
    echo "Yay!";
?>

Measured memory_bytes: 16064