akhauriyash/Code-Regression huggingface dataset:
import itertools
import math
n=int(input())
cal=[[0 for _ in range(n)] for _ in range(n)]
p=[list(map(int,input().split())) for _ in range(n)]
for i in range(n):
    for j in range(n):
        if i==j:
            continue
        d=math.sqrt((p[i][0]-p[j][0])**2+(p[i][1]-p[j][1])**2)
        cal[i][j]=d
    
kumi=list(itertools.permutations([i for i in range(n)]))
total=0
l=len(kumi)
for each in kumi:
    tmp=0
    for i in range(len(each)-1):
        tmp+=cal[each[i]][each[i+1]]
    tmp/=l
    total+=tmp
print(total)

Measured memory_bytes: 7972
/* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 
                                                           
*/
/* }}} */
/* include {{{ */
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
using namespace std;
/* }}} */

// #define int long long

/* cpp template {{{ */
/* short */
#define pb push_back
#define mp make_pair
#define print(x) cout << x << '\n'
#define Fi first
#define Se second

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define DEPS(i, a, n) for (int i = (a); i >= n; i--)
#define DEP(i, n) for (int i = (n); i >= 0; i--)

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;

/* const */
const int INF = 999999999;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool is_uruu(int y) {return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));}
inline bool inside(int y, int x, int H, int W) {return (y >= 0 && x >= 0 && y < H && x < W);}

/* }}} */

int field[9][9];
const int p[] = {0, 3, 6};

char check(int y, int x)
{
  REPS(i, x, 9) if (x != i && field[y][x] == field[y][i]) return '*';
  REPS(i, y, 9) if (y != i && field[y][x] == field[i][x]) return '*';
  DEP(i, x) if (x != i && field[y][x] == field[y][i]) return '*';
  DEP(i, y) if (y != i && field[y][x] == field[i][x]) return '*';

  REPS(i, p[y / 3], p[y / 3] + 3){
    REPS(j, p[x / 3], p[x / 3] + 3){
      if (i == y && j == x) continue;
      if (field[y][x] == field[i][j]) return '*';
    }
  }

  return ' ';
}

signed main()
{
  //cin.tie(0);
  //ios::sync_with_stdio(false);
  int n;
  scanf("%d", &n);

  while (n--){
    char table[9][9];
        
    REP(i, 9) REP(j, 9) scanf("%d", &field[i][j]);
    
    REP(i, 9){
      REP(j, 9){
        table[i][j] = check(i, j);
      }
    }
    REP(i, 9){
      REP(j, 9){
        printf("%c%d", table[i][j], field[i][j]);
      }
      puts("");
    }
    if (n != 0) puts("");
  }

  return (0);
}

Measured memory_bytes: 1196
import collections

n=int(input())
d=list(map(int,input().split()))
d=collections.Counter(d)
m=int(input())
t=list(map(int,input().split()))
t=collections.Counter(t)


for i in t:
    if t[i]>d[i]:
        print("NO")
        exit()
print("YES")

Measured memory_bytes: 55256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
int n;
void solve() {
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    int x, ans = 0;
    for (int i = 0; i < n; i++) {
        x = min(x, h[i]);
        ans += (h[i] - x);
        x = h[i];
    }
    cout << ans << endl;
    return;
}
//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}
int main(int args, char* argv[]) {
    solve();
}

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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

void solve() {
  ll x, ans = 0, count = 0;
  cin >> x;
  ans += x / 11 * 2;
  count = (x / 11) * 11;
  if (x % 11 != 0) {
    ans += 1;
    count += 6;
    if (6 < x % 11) {
      ans += 1;
      count += 5;
    }
  }
  cout << ans << endl;
}

signed main() {
  solve();

  return 0;
}


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

int main(){
  int n,k;
  cin>>n>>k;
  if(n%k==0)cout<<0<<endl;
  else cout<<1<<endl;
  
  return 0;
}

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

#define int long long
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vii vector<pi>
#define ps(x,y) fixed<<setprecision(y)<<x
#define w(t) int t;cin>>t;while(t--)solve()

void solve(){
	
}

int32_t main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int x;
	cin>>x;
	if (x>=30)cout<<"Yes";
	else cout<<"No";

}


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

int main(void) {
    int N;
    cin >> N;
    int cnt[2] = {};
    for (int i = 0; i < N; i++) {
        int A;
        cin >> A;
        cnt[A%2]++;
    }
    if (cnt[0] == N || cnt[1] == N) {
        cout << 0 << endl;
        return 0;
    }
    if (cnt[1] % 2) {
        cout << N-1 << endl;
    } else {
        cout << N-2 << endl;
    }
}


Measured memory_bytes: 3092
n = int(input())
rom = []
for _ in range(n):
    x, l = map(int, input().split())
    rom.append([x + l, x - l])
    
rom.sort()
ans = 0
pos = -10 ** 10
for end, start in rom:
    if start >= pos:
        ans += 1
        pos = end
print(ans)

Measured memory_bytes: 24384
#include <cstdio>
#include <cstdlib>
#define FOR(i, l, r) for(int i = l; i <= r; ++i)

using namespace std;

int a[110], n, mx, tot;

int main()
{
    scanf("%d", &n);
    FOR(i, 1, n)
    {
        scanf("%d", &a[i]);
        if (abs(a[i]) > abs(a[mx])) mx = i;
    }
    if (a[mx] > 0)
    {
        FOR(i, 1, n) if (a[i] < 0) ++tot;
        printf("%d\n", tot + n - 1);
        FOR(i, 1, n) if (a[i] < 0) printf("%d %d\n", mx, i);
        FOR(i, 2, n) printf("%d %d\n", i - 1, i);
    }
    else
    {
        FOR(i, 1, n) if (a[i] > 0) ++tot;
        printf("%d\n", tot + n - 1);
        FOR(i, 1, n) if (a[i] > 0) printf("%d %d\n", mx, i);
        for(int i = n - 1; i; --i) printf("%d %d\n", i + 1, i);
    }
    return 0;
}


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

int main() {
  int n;
  cin>>n;
  vector<int64_t> a(n),b(n+1,0);
  for(int i=0;i<n;i++){
    cin>>a[i];
    b[a[i]]++;
  }
  int64_t all=0;
  for(int i=1;i<=n;i++){
    all+=b[i]*(b[i]-1)/2;
//    cout<<b[i]<<" ";
  }
//  cout<<endl;
  int64_t ans;
  for(int i=0;i<n;i++){
    ans=all-b[a[i]]*(b[a[i]]-1)/2;
    if(b[a[i]]>1){
      ans+=(b[a[i]]-1)*(b[a[i]]-2)/2;
    }
    cout<<ans<<endl;
  }
}


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

using ll = long long;
const ll MOD = 1e9 + 7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<int> c(n);
  for (int i = 0; i < n; i++) cin >> c.at(i);
  
  vector<ll> dp(n), now(2e5 + 1);
  dp.at(0) = 1;
  now.at(c.at(0)) = 1;
  for (int i = 1; i < n; i++) {
    dp.at(i) = dp.at(i - 1);
    if (c.at(i) != c.at(i - 1)) dp.at(i) += now.at(c.at(i));
    dp.at(i) %= MOD;
    now.at(c.at(i)) = dp.at(i);
  }
  
  cout << dp.at(n - 1) << '\n';
}

Measured memory_bytes: 4224
#include<iostream>
#include<cctype>
#include<queue>

using namespace std;

struct State{
  int y,x,t,b,s;
};

int main(){
  int W,H;
  cin>>W>>H;
  char M[50][51];
  int sy,sx;
  for(int i=0;i<H;i++){
    cin>>M[i];
    for(int j=0;j<W;j++){
      if(M[i][j]=='%'){
	sy=i;
	sx=j;
      }
    }
  }
  int S;
  cin>>S;
  char MS[10][50][51];
  for(int i=0;i<S;i++){
    for(int j=0;j<H;j++){
      cin>>MS[i][j];
    }
  }
  queue<State> que;
  que.push({sy,sx,0,0,0});
  static bool p[50][50][1<<10][2];
  while(!que.empty()){
    State cs=que.front();
    if(M[cs.y][cs.x]=='&')break;
    que.pop();
    if(p[cs.y][cs.x][cs.b][cs.s]++)continue;
    for(int i=0;i<4;i++){
      static int d[]={0,-1,0,1,0};
      int ny=cs.y+d[i];
      int nx=cs.x+d[i+1];
      if(M[ny][nx]=='#')continue;
      int is=isupper(M[ny][nx])||M[ny][nx]=='^';
      for(int j=0;j<S;j++){
	is^=cs.b>>j&1&&MS[j][ny][nx]=='*';
      }
      if(is==cs.s||M[ny][nx]=='|'){
	que.push({ny,nx,cs.t+1,cs.b,cs.s});
      }
    }
    if(M[cs.y][cs.x]=='|'){
      que.push({cs.y,cs.x,cs.t+1,cs.b,cs.s^1});
    }
    if(isalpha(M[cs.y][cs.x])){
      int nb=M[cs.y][cs.x]-(isupper(M[cs.y][cs.x])?'A':'a');
      que.push({cs.y,cs.x,cs.t+1,cs.b^1<<nb,cs.s^MS[nb][cs.y][cs.x]=='*'});
    }
  }
  cout<<(que.empty()?-1:que.front().t)<<endl;
}

Measured memory_bytes: 9260
#include <stdio.h>
#include <string.h>
int main(void)
{
 int i,m,j,k,h;
 char alpha[250],xx[250];
 
 while(1){
 scanf("%s",alpha);
 if(alpha[0]=='-')break;
 
    j=strlen(alpha);
    scanf("%d",&m);
    for(k=0;k<m;k++){
        scanf("%d",&h);
        strncpy(xx,alpha,h);
        xx[h]='\0';             //strncpyの後にはヌル文字を代入しないと謎の文字が入る
        for(i=0;i<j;i++){
            alpha[i]=alpha[i+h];
            if(i>=j-h)alpha[i]='\0';
        }
        strcat(alpha,xx);
    }
    printf("%s\n",alpha);
 }
 return 0;
}


Measured memory_bytes: 2084
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back
typedef pair<int,int> P;
typedef pair<P,int> Q;
#define fi first
#define sc second

int n;

int main(){
	while(1){
		cin >> n;if(n==0) return 0;
		int ans1 = -1, ans2 = -1;
		for(int i=1;i<=100000;i++){
			//a+...a+i-1
			//i * (2a+i-1) = 2n
			if(2*n%i != 0) continue;
			int x = 2*n/i;
			int y = x+1-i;
			if(y >= 1 && y%2 == 0){
				y /= 2;
				ans1 = y;
				ans2 = i;
			}
		}
		cout << ans1 <<" "  << ans2 << endl;
	}
}



Measured memory_bytes: 3072
#全探索-->len(s) = 50程度までしか通らない
s = list(input())
K = int(input())

lst = []
for i in range(len(s)):
    for j in range(i+1, min(len(s)+1, i+1+K)):
#        print ('i, j=', i, j)
        lst += [s[i:j]]

lst.sort()
#print (lst)
k = 0
flag = 0
ans = str()
check = True
while check:
    if ans != lst[flag]:
        #print ('k', k)
        k += 1
    ans = lst[flag]
    #print ('ans=', ans)
    flag += 1
    if k == K:
        ans = ''.join(ans)
        print(ans)
        check = not check


Measured memory_bytes: 5748
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

string solve(string A, int x, string B, int y, string C, int z) {
	if (x == 0)
		return solve(B, y, C, z, "", 0);
	if (y == 0 && z == 0) {
		string res = "";
		while(x--) res += A;
		return res;
	}
	if (y == 0)
		return solve(A, x, C, z, "", 0);
	int sum = y + z;
	int p = x / sum;
	int q = x % sum;
	
	string As = "";
	for (int i = 0; i < p; i++)
		As += A;
	string Ab = As + A;

	if (q == 0) {
		return solve(As + B, y, As + C, z, "", 0);
	}

	p = sum - q;

	if (z < q) {
		return solve(Ab + B, q - z, Ab + C, z, As + B, p);
	}
	if (z == q) {
		return solve(Ab + C, q, As + B, p, "", 0);
	}
	return solve(Ab + C, q, As + B, y, As + C, z - q);
}

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	int x, y, z;
	cin >> x >> y >> z;
	cout << solve("a", x, "b", y, "c", z) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
#include <cstring>
using namespace std;
//typedef
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
//define
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)

int main(){
    int n,m = 0;
    cin >> n ;
    vi a(n),b(n),c(n-1);
    rep(i,n) cin >> a.at(i);
    rep(i,n) cin >> b.at(i);
    rep(i,n-1) cin >> c.at(i);

    FOR(i,0,n){
        m += b.at(a.at(i)-1);
        if(i > 0 && a.at(i) == a.at(i-1)+1) m += c.at(a.at(i-1)-1);
    }
    cout << m << endl;
 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
const int N = 10010;

int main()
{
//	freopen("in.txt", "r", stdin);
	int n;
	while (~scanf("%d", &n))
	{
		ll x, y, z;
		for (int i = 1; i <= 3500; i++)
		{
			bool f = false;
			for (int j = 1; j <= 3500; j++)
			{
				ll l = (ll)i*j*4 - (ll)n*i - (ll)n*j;
				if (l <= 0)
					continue;
				if ((ll)i*j*n % l == 0)
				{
					f = true;
					x = i, y = j, z = (ll)i*j*n / l;
					break;
				}

			}
			if (f)
				break;
		}
			
		printf("%lld %lld %lld\n", x, y, z);

	}
	return 0;
}


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

using namespace std;
long long cnt;
int A[1000000];
vector<int> G;
void is(int n,int g){
    for(int i=g;i<n;i++){
        int v = A[i];
        int j = i - g;
        while(j>=0 && A[j]>v){
            A[j+g] = A[j];
            j = j-g;
            cnt++;
        }
        A[j+g] = v;
    }
}
void ss(int n){
    int h = 1;
    while(h<=n){
        G.push_back(h);
        h = 3*h+1;
    }
    for(int i=G.size()-1;i>=0;i--)
        is(n,G[i]);
}
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>A[i];
    cnt = 0;
    ss(n);
    cout<<G.size()<<endl;
    for(int i=G.size()-1;i>=0;i--)
        if(i==0) cout<<G[i]<<endl;
        else cout<<G[i]<<' ';
    cout<<cnt<<endl;
    for(int i=0;i<n;i++)
        cout<<A[i]<<endl;
    return 0;
}



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

#define fi first
#define se second
#define FO(x, n) for (int x = 0; x < n; ++x)
#define FOR(x, a, b) for (int x = a; x < b; ++x)
#define RFO(x, n) for (int x = n - 1; x >= 0; --x)
#define RFOR(x, a, b) for (int x = b - 1; x >= a; --x)
#define FOR_ITER(x, a) for(auto x = a.begin(); x != a.end(); ++x)

using namespace std;

typedef unsigned char byte;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;
typedef pair<ll, ll> pll;
inline bool feq(const double& a, const double& b) { return fabs(a - b) < 1e-10; }



int n, m;

int main(){
//    int n, l;
//    cin >> n >> k;
//    vector<bool> dislike(10, false);
//
//    FOR(i, 0, k) {
//        int t;
//        cin >> t;
//        dislike[t] = true;
//    }


    int n, m;

    cin >> n >> m;

    vector<int> nums(n, 0);

    FO(i, m) {
        int a, b;
        cin >>a>>b;
        nums.at(a - 1)++;
        nums.at(b - 1)++;
    }
    FO(i, n) {
        cout << nums.at(i) << endl;
    }

    return 0;
}


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

using namespace std;

struct INIT{
    INIT(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout<<fixed;
	cout<<setprecision(10);
    }
}init;


#define rep(i,n) for(auto i=(n)*0;i<n;i++)
#define range(it,v) for(auto &it:v)
typedef vector<int> V;

int dfs(const V& now,map<V,int>& memo,const V& goal){
    if(memo.count(now))return memo[now];
    memo[now]=114514;
    int k=now.size();
    int L=0,R=k-1;
    for(;L<k&&now[L]==goal[L];L++);
    for(;R>0&&now[R]==goal[R];R--);
    int res=114514;
    for(int i=L;i<=R;i++){
	V nxt=now;
	int d=(goal[L]-now[L]+10)%10;
	for(int j=L;j<=i;j++)(nxt[j]+=d)%=10;
	res=min(res,1+dfs(nxt,memo,goal));
    }
    for(int i=L;i<=R;i++){
	V nxt=now;
	int d=(goal[R]-now[R]+10)%10;
	for(int j=i;j<=R;j++)(nxt[j]+=d)%=10;
	res=min(res,1+dfs(nxt,memo,goal));
    }
    return memo[now]=res;
}
int main(){
    for(int k;cin>>k,k;){
	string s,t;
	cin>>s>>t;
	V a(k),b(k);
	rep(i,k)a[i]=s[i]-'0';
	rep(i,k)b[i]=t[i]-'0';
	map<V,int> memo;
	memo[b]=0;
	cout<<dfs(a,memo,b)<<endl;
    }
};

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

int main()
{
  string s;
  cin>>s;

  string hitachi = "";
  for(int i=0; i<5; i++){
    hitachi += "hi";
    if(hitachi==s){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
s = 0

while n != 0:
    a = [int(input()) for i in range(n)]
    b = sorted(a)
    for i in range(1,n-1):
        s += b[i]
    c = s//(n-2)
    print('{:.0f}'.format(c))
    n = int(input())
    s = 0


Measured memory_bytes: 5624
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String security_code = scanner.nextLine();

        int before = 0;
        before = security_code.codePointAt(0);
        for(int p = 1; p < 4; p++) {
          if (before == security_code.codePointAt(p)) {
            System.out.println("Bad");
            return;
            }
          before = security_code.codePointAt(p);
          }
        System.out.println("Good");
    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<cstdio>
using namespace std;
#define N 524289
#define mod 998244353
const int val=1000000000000000000%mod;
inline int M(int x){return (x>=mod)?(x-mod):x;}
inline int M1(int x){return (x<0)?(x+mod):x;}
inline int ksm(int p,int k){int res=1;while(k){if(k&1)res=1ll*res*p%mod;k>>=1;p=1ll*p*p%mod;}return res;}
int n,m,all,len,s[N],f[N],g[N],h[N],cnt=0;
struct Edge{int to,next;}e[N<<1];
inline void AddEdge(int x,int y){e[++cnt]=(Edge){y,h[x]};h[x]=cnt;}
inline void FWT(int f[],int len)
{
	int i,j,x,y;
	for(int j=1;j<len;j<<=1)
	for(int i=0;i<len;i++)if(i&j){x=f[i^j];y=f[i];f[i^j]=M(x+y);f[i]=M1(x-y);}
}
inline void IFWT(int f[],int len)
{
	int i,j,x,y,inv;
	for(int j=1;j<len;j<<=1)
	for(int i=0;i<len;i++)if(i&j){x=f[i^j];y=f[i];f[i^j]=M(x+y);f[i]=M1(x-y);}
	inv=ksm(len,mod-2);for(i=0;i<len;i++)f[i]=1ll*f[i]*inv%mod;
}
int tmp[N],P[N];
inline void solve()
{
	scanf("%d",&m);int i,x,y;
	for(i=1;i<=m;i++){scanf("%d%d",&x,&y);AddEdge(x,y);AddEdge(y,x);}
	s[n]=0;
	for(x=n-1;x>=1;x--)
	{
		for(i=h[x];i;i=e[i].next)if((y=e[i].to)>=x)tmp[s[y]]=1;
		s[x]=0;while(tmp[s[x]])++s[x];
		for(i=h[x];i;i=e[i].next)if((y=e[i].to)>=x)tmp[s[y]]=0;
	}
	for(i=1;i<=n;i++)f[s[i]]=M(f[s[i]]+P[i]);FWT(f,len);
	for(i=0;i<len;i++)g[i]=1ll*g[i]*f[i]%mod;
	for(i=1;i<=n;i++)s[i]=h[i]=0;cnt=0;
	for(i=0;i<len;i++)f[i]=0;
}
int main(){
	P[0]=1;for(int i=1;i<N;i++)P[i]=1ll*P[i-1]*val%mod;
	scanf("%d",&n);all=3*n;len=1;while(len<all)len<<=1;
	g[0]=1;FWT(g,len);solve();solve();solve();IFWT(g,len);printf("%d",g[0]);return 0;
}

Measured memory_bytes: 14592
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    a, b, c = s_map()

    print('YES' if a[-1] == b[0] and b[-1] == c[0] else 'NO')

if __name__ == '__main__':
    main()



Measured memory_bytes: 76912
//(UNCOMMENT WHEN SUBMITTING)
//#pragma GCC optimize("O3")

//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
// #pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN NEEDED)
// #pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>

// clang-format off
#define range(i) for (int _ = 0; _ < i; _++)
#define vprnt(v) for (auto vi : v) cout << vi << " "; cout << endl;
#define fastio() ios::sync_with_stdio(false); cin.tie(0)
#define ll long long
#define all(x) (x).begin(), (x).end()
using namespace ::std;
int nxt() {int x;cin >> x;return x;}
ll nxtll() {ll x;cin >> x;return x;}
// clang-format on

int main() {
    fastio();
    ll N = nxtll(), D = nxtll();
    int res = 0;
    for (int i = 0; i < N; i++) {
        ll X = nxtll(), Y = nxtll();
        if (X * X + Y * Y <= D * D) {
            res++;
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
vector<ll> adj[10000];
int main()
{
    ll n,i,j,k,l,m,o,p,q,r,s,t,x,y;
    cin>>x>>y>>n>>m>>p;
    vector<ll> a;
    vector<ll> b;
    vector<ll> c;
    for(i=1;i<=n;i++)
    {
       cin>>j;
       a.push_back(j);
    }
    for(i=1;i<=m;i++)
    {
       cin>>j;
       b.push_back(j);
    }
    for(i=1;i<=p;i++)
    {
       cin>>j;
       c.push_back(j);
    }
    sort(a.begin(),a.end(),greater<ll>());
    sort(b.begin(),b.end(),greater<ll>());
    sort(c.begin(),c.end(),greater<ll>());
    vector<ll> v;
    ll ans=0;
    for(i=0;i<min(x,(ll)a.size());i++)
    {
        v.push_back(a[i]);
    }
    for(i=0;i<min(y,(ll)b.size());i++)
    v.push_back(b[i]);
    for(i=0;i<min(x+y,(ll)c.size());i++)
    {
        v.push_back(c[i]);
    }
    sort(v.begin(),v.end(),greater<ll>());
    for(i=0;i<x+y;i++)
    ans+=v[i];
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 9072
#include<bits/stdc++.h>
//#define GYD
using namespace std;
const int maxn = 10 + 5;

int main()
{
    #ifdef GYD
    freopen("..//out.txt", "w", stdout);
    #endif // GYD
    int n, ans = 1;
    scanf("%d", &n);
    while(n >= ans)
    {
        ans *= 2;
    }
    ans /= 2;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  int d[110];
  int res=0;
  cin >>n;
  for(int i=0;i<n;++i)cin >> d[i];
  for(int i=0;i<n-1;++i){
    for(int l=i+1;l<n;++l){
      res +=d[i]*d[l];
    }
  }
  cout << res;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
      	int a = 0;
      	int b = 0;
      	int num = 0;
      	int min = -1;
		for(int i=1; i<=n/2; i++){
          a = i;
          b = n-i;
          int sum = 0;
          while(a>0){
            sum +=a%10;
            a/=10;
          }
          a = sum;
          sum = 0;
          while(b>0){
            sum +=b%10;
            b/=10;
          }
          b = sum;
          num = a + b;
          if(num<min || min==-1) min = num;
        }
      	System.out.println(min);
	}
}


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

ll ans = 0;
ll n, m, k;

int main(){
    cin >> n >> m >> k;
    ll a[n + 5], b[m + 5];
    rep(i,n) cin >> a[i];
    ll sum = 0;
    rep(i,m){
        cin >> b[i];
        sum += b[i];
    }
    int ans=0;
    int j = m;
    rep(i,n+1){
        while (j>0&&sum>k){
            j--;
            sum-=b[j];
        }
        if(sum>k) break;

        ans = max(ans, j + i);

        if(i==n)break;

        sum+=a[i];
    }

        cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6624
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
#define int long long int

signed main(){
    int r,g,b;
    cin >> r >> g >> b;
    int num = r*100 + g*10 + b;
    cout << ((num%4==0) ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
import sys
import numpy

n,k=map(int,input().split())
a=list(map(int,input().split()))
b=numpy.zeros(n,dtype=int)

city=1
count=0
while b[city-1]==0:
    count+=1
    b[city-1]=1
    
    city=a[city-1]

#arrive at city in count, len(cl)=count
if k<count:
    cc=1
    for i in range(k):
        cc=a[cc-1]
    print(cc)
    sys.exit()

c=1
cnt=0
while c!=city:
    cnt+=1
    c=a[c-1]

loop=count-cnt

d=(k-count)%loop

for i in range(d):
    city=a[city-1]

print(city)

Measured memory_bytes: 51076
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<sstream>
#include<complex>
#include<functional>
#include<vector>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<set>

using namespace std;
#define endl '\n'
#define eb emplace_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

constexpr int MOD = 1000000007;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;

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

struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

// value
int N;
ll ans[10010];
ll c[10010];
vector<vi> g;
int cur = 0;

void dfs(int t, int par) {
	ans[t] = c[cur];
	cur++;
	if (g[t].size() == 1 && g[t][0] == par) return;
	for (int i = 0; i < g[t].size(); i++) {
		if (g[t][i] == par) continue;
		dfs(g[t][i], t);
	}
	return;
}

void solve() {

	cin >> N;
	vi a(N - 1), b(N - 1);
	g.resize(N);
	
	UnionFind uf(N);

	for (int i = 0; i < N - 1; i++) {
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
		g[a[i]].eb(b[i]);
		g[b[i]].eb(a[i]);
		uf.unite(a[i], b[i]);
	}
	for (int i = 0; i < N; i++) {
		cin >> c[i];
	}
	sort(c, c + N, greater<int>());

	dfs(uf.root(0), -1);
	
	ll sum = 0;
	for (int i = 1; i < N; i++) {
		sum += c[i];
	}

	cout << sum << endl;
	for (int i = 0; i < N; i++) {
		cout << ans[i] << ((i == N - 1) ? "\n" : " ");
	}

	return;

}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	solve();

	return 0;

}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;

void solve()
{
    int A, B; cin >> A >> B;
    string S; cin >> S;
    if(S[A] != '-') 
    {
        cout << "No" << endl;
        return;
    }
    REP(i, S.length())
    {
        if(i == A) continue;
        if('0' <= S[i] && S[i] <= '9');
        else
        {
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

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

#define ran 3033

struct modular_arithmetic{
	int mod;

	modular_arithmetic(){
		mod = 998244353;
	}
	//No specific settings.
	int add(int x,int y){return (x+=y)<mod?x:x-mod;}
	int mul(int x,int y){return (int)((long long int)x*y%mod);}
};
modular_arithmetic ma;

int n, s;
int a[ran];
int f[ran][ran], g[ran];

int main() {
	scanf("%d%d", &n, &s);
	for(int i=1;i<=n;i++) scanf("%d", &a[i]);
	
	memset(f, 0, sizeof f);
	int ans = 0;
	for(int i=1;i<=n;i++) {
		for(int j=s;j>a[i];j--)
			f[i][j] = ma.add(f[i][j], g[j-a[i]]);
		f[i][a[i]] = i;
		
		ans = ma.add(ans, ma.mul(n-i+1, f[i][s]));
		
		for(int j=0;j<=s;j++)
			g[j] = ma.add(g[j], f[i][j]);
	}
	printf("%d\n", ans);	
	
	return 0;
}

Measured memory_bytes: 36224
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cctype>
#include <queue>
#include <map>
#include <set> 
#include <bitset>
#include <cmath>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)

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

    int res = 0;
    for (int i = 0; i < n-1; i++) {
        set<char> count;
        for (int j = 0; j <= i; j++) {
            char c = s[j];
            for (int k = i+1; k < n; k++) {
                if(s[k] == c) {
                    count.insert(c);
                } 
            }
        }
        res = max(res, (int)count.size());
    }
    
    cout << res << endl;

    return 0;
}


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

int main(){
    int N;
    cin >> N;
    int A[100000];
    int ans = 0;

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

    for (int i = 0; i < N; ++i) {
        if (A[i] % 2 == 1) ans++;
    }

    if (ans % 2 == 1) cout << "NO" << endl;
    else cout << "YES" << endl;

}

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

using namespace std;

#define db(x) cout << (x) << '\n';
#define all(x) x.begin(),x.end()
#define UNIQUE(x) sort(all(x)),x.resize(unique(all(x))-x.begin())
#define LB(v,x) lower_bound(all(v),x)
#define UB(v,x) upper_bound(all(v),x)
#define endl "\n"
#define F first
#define S second
#define PB push_back
#define PF push_front
#define int long long
#define double long double
#define trick int m = (l+r)>>1,lc=n<<1,rc=lc|1

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

int dy[]={0,1,1,1,0,-1,-1,-1};
int dx[]={-1,-1,0,1,1,1,0,-1};
const int maxn = 1e5;
const int OO = 1e18;
const int mod = 1e9 + 7;
const double PI = acos(-1);

void maxself(int &a,int b)
{a=max(a,b);}
void minself(int &a,int b)
{a=min(a,b);}

vector<vi> g(maxn);


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

//	freopen("name.in","r",stdin);
//	freopen("name.out","w",stdout);

	int n,m,k;
	cin >> n >> m >> k;
	char ma[n][m];
	
	for(int i=0;i<n;i++)
	for(int j=0;j<m;j++)
	{
		cin >> ma[i][j];
		
	}
	int sol = 0;
	
	for(int i=0;i<(1LL<<n);i++)
	{
		char aux[n][m],aux2[n][m];
		for(int z=0;z<n;z++)
		for(int j=0;j<m;j++)
		{
			aux[z][j] = ma[z][j];
			aux2[z][j] = ma[z][j];
		}
		for(int j=0;j<n;j++)
		{
			if(i&(1LL<<j))
			{
				for(int x=0;x<m;x++)
				{
					aux[j][x] = '*';
					aux2[j][x] = '*';
				}
			}
		}
		
		for(int j=0;j<(1LL<<m);j++)
		{
			
			for(int z=0;z<n;z++)
			for(int K=0;K<m;K++)
			{
				aux[z][K] = aux2[z][K];
			}
		
			for(int z=0;z<m;z++)
			{
				if(j&(1LL<<z))
				{
					for(int x=0;x<n;x++)
					{
						aux[x][z] = '*';
					}
				}
			}
		
		
		int ans = 0;
		for(int d=0;d<n;d++)
		for(int a=0;a<m;a++)
		{
		
			if(aux[d][a]=='#')
			ans++;
		
		}
		
		if(ans == k)
		sol++;
		}
		
		
	}
	
	cout << sol;
	
	return 0;
}



Measured memory_bytes: 5416
#include<bits/stdc++.h>
const int maxn = 100035;

int a[maxn],n,l,t,x,cnt;

int main()
{
    scanf("%d%d%d",&n,&l,&t);
    for (int i=1; i<=n; i++)
    {
        scanf("%d%d",&a[i],&x);
        a[i] += x==1?t:-t;
        cnt += a[i]/l;
        if (a[i]%l<0) cnt--;
        ((a[i]%=l)+=l)%=l;
    }
    std::sort(a+1, a+n+1);
    ((cnt%=n)+=n)%=n;
    for (int i=cnt+1; i<=n; i++) printf("%d\n",a[i]);
    for (int i=1; i<=cnt; i++) printf("%d\n",a[i]);
    return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define mat vector<vec>

using namespace std;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

int main(){

  string s,t;
  cin >> s >> t;
  ll ans=inf,n=s.size(),m=t.size();
  for(ll i=0;i<n-m+1;i++){
    ll c=0;
    for(ll j=0;j<m;j++){
      if(s[i+j]!=t[j])c++;
    }
    ans=min(ans,c);
  }
  cout << ans << endl;

}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
#ifdef LOCAL_TEST
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    int n, a;
    cin >> n >> a;
    cout << n * n - a << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	Scanner sc = new Scanner(System.in);
	int n,q;
	int[] S,T;
	int C=0;
	int key;
	
	public void input(){
		n = sc.nextInt();
		S = new int[n];
		for(int i=0; i<n; i++){
			S[i] = sc.nextInt();
		}
		q = sc.nextInt();
		T = new int[q];
		for(int i=0; i<q; i++){
			T[i] = sc.nextInt();
		}
	}
	
	public void search(){
		for(int i=0; i<q; i++){
			for(int j=0; j<n; j++){
				if(T[i] == S[j]){
					C++;
					break;
				}
			}
		}
		System.out.println(C);
	}
	
	public static void main(String[] args){
		Main obj = new Main();
		obj.input();
		obj.search();
	}
}



Measured memory_bytes: 40612
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

int INF=1e3;
int dist[15][15];

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int n;
  while(cin>>n,n){
    fill(dist[0],dist[0]+15*15,INF);
    int m=0,a,b,d;
    rep(i,n){
      cin>>a>>b>>d;
      dist[a][b]=dist[b][a]=min(dist[a][b],d);
      m=max({m,a,b});
    }
    ++m;
    rep(i,m) dist[i][i]=0;
    rep(k,m) rep(i,m) rep(j,m)
      dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);

    pii re=pii(INF,-1);
    rep(i,m){
      int sum=0;
      rep(j,m) sum+=dist[i][j];
      re=min(re,pii(sum,i));
    }
    //rep(i,m){rep(j,m)cout<<dist[i][j]<<",";cout<<endl;}
    cout<<re.Y<<" "<<re.X<<endl;
  }
  return 0;
}

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

int main()
{
	string s;
	cin >> s;
	int n = s.size();
	ll sum = 0;
	for(int i = 0;i<n;i++)
	{
		sum += s[i]-'0';
	}
	if(sum %9==0)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


Measured memory_bytes: 3724
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String[] split;
        
        int size = Integer.parseInt(line);
        
        ArrayList<Restaurant> data = new ArrayList<>();
        
        for (int i = 0; i < size; i++) {
			line = sc.nextLine();
	        split = line.split(" ");
	        
	        data.add(new Restaurant(i+1, split[0], Integer.parseInt(split[1])));
		}
        
        calculate(data);
        for (int i = 0; i < data.size(); i++) {
			System.out.println(data.get(i).id);
		}
	}
	
	public static ArrayList<Restaurant> calculate(ArrayList<Restaurant> list) {
		list.sort((p1, p2) -> p2.point - p1.point);
		list.sort((p1, p2) -> p1.city.compareTo(p2.city));
		return list;
	}

}

class Restaurant {
	int id;
	String city;
	int point;
	
	public Restaurant(int id, String city, int point) {
		this.id = id;
		this.city = city;
		this.point = point;
	}
	
	@Override
	public String toString() {
		return id + city + point;
	}
}

Measured memory_bytes: 27092
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;

const int MAX=2e6+1; //nCrのnのMAX+1
ll fac[MAX],finv[MAX],inv[MAX],sinv[MAX];

void cominit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  sinv[0]=0,sinv[1]=1;
  for (int i=2;i<MAX;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
    sinv[i]=(sinv[i-1]+inv[i]%mod)%mod;
  }
}
ll com(int n,int k){ //1≦k≦n≦10^7
  if (n<k) return 0;
  if (n<0||k<0) return 0;
  return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
ll per(int n,int k){ //1≦k≦n≦10^7
  if (n<k) return 0;
  if (n<0||k<0) return 0;
  return fac[n]*finv[n-k]%mod;
}
//Add cominit(); in main function.

ll dp[500010];

int main(){
  cominit();
  ll n,m; cin >> n >> m;
  dp[0]=1;
  dp[1]=m-n;
  dp[2]=(1+(m-n)*2+(m-n)*(m-n-1))%mod;
  for(ll i=3;i<=n;i++){
    dp[i]=((m-n+i-1)*dp[i-1]+(i-1)*dp[i-2])%mod;
  }
  ll ans=dp[n]*per(m,n)%mod;
  cout << ans << endl;
}

Measured memory_bytes: 69940
import itertools
n = int(input())
list_march = ["M", "A", "R", "C", "H"]
num_march = [0 for i in range(5)]
for i in range(n):
  s = input()
  if s[0] in list_march:
    num_march[list_march.index(s[0])] += 1

if num_march.count(0) >= 3:
  print(0)
else:
  cand = list(itertools.combinations([0, 1, 2, 3, 4], 3))
  result = 0
  for a, b, c in cand:
    result += num_march[a] * num_march[b] * num_march[c]
  print(result)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		int u, k, v;
		int n = sc.nextInt();
		int[][] M = new int[n][n];
		for(int i = 0; i < n; i++) {
			u = sc.nextInt();
			k = sc.nextInt();
			u--;
			for(int j = 0; j < k; j++) {
				v = sc.nextInt();
				v--;
				M[u][v] = 1;
			}
		}

		for(int i = 0; i < n; i++) {
			for(int j = 0; j < n; j++) {
				if(j != 0) {
					System.out.print(" ");
				}
				System.out.print(M[i][j]);
			}

			System.out.println("");
		}
		sc.close();
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 34348
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#define ll long long int

using namespace std;

string s;
int a[30];

int main()
{
    ///freopen("INA.txt","r",stdin);
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>> s;
    int ln = s.length();
    for(int i=0;i<ln;i++){
        a[s[i]-96]++;
    }
    for(int i=1;i<=26;i++){
        if(a[i]%2){
            cout<< "No" << endl;
            return 0;
        }
    }
    cout<< "Yes" << endl;

    return 0;
}



Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>

using namespace std;

int main() {
    double a, b, p, q, r;
    cin >> a >> b >> p >> q >> r;

    double x = b * p;
    x -= (b - a) * q;

    cout << fixed << setprecision(10) << b + x / (q + r) << endl;
    return 0;
}



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

int main()
{
  int n,k;
  cin>>n>>k;
  deque<int> V;
  for (int i = 0; i < n; ++i)
  {
    int tmp;
    cin>>tmp;
    V.emplace_back(tmp);
  }
  std::vector<int> ans={0};
  
  for (int a = 0; a <= min(n,k); ++a)
  {
    for (int b = 0; a + b <= min(n,k); ++b)
    {
      deque<int> v=V; 
      std::vector<int> vec;
      for (int i = 0; i < a; ++i)
      {
        vec.emplace_back(v.front());
        v.pop_front();
      }
      for (int i = 0; i < b; ++i)
      {
        vec.emplace_back(v.back());
        v.pop_back();
      }
      sort(vec.begin(), vec.end(),greater<int>());
      
      int cnt=0;
      for (int i = 0; i < a+b; ++i)
      {
        if(vec[i]<0) cnt++;
      }
      for (int i = 0; i < min(cnt,k-a-b); ++i)
      {
        vec.pop_back();
      }
      int sum=0;
      for(auto &e: vec) {
        sum+=e;
      }
      ans.emplace_back(sum);
      
    }
  }
  cout<<*max_element(ans.begin(),ans.end());
  
}

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

using ll    = long long;
using ull   = unsigned long long;
using veci  = vector<int>;
using vecll = vector<ll>;
#define EPS (1e-7)
#define INF (1e9)
#define PI  (acos(-1))
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define REP(i,n) for(int i= 0;i<(int)(n);++i)
#define pb push_back

veci enum_div(int n){
	veci ret;
	ret.pb(1);
	for(int i=1;i*i<n;i++){
		if(n%i==0){
			ret.pb(i);
			if(i != n/i){ret.pb(n/i);}
		}
	}
	ret.pb(n);
	return ret;
}
int gcb(int a,int b){return ((b == 0)? a : gcb(b,a%b));}
int gcd(int a,int b){return (a*b) / gcb(a,b);}

int main(){
    int a,b;
    cin >> a >> b;
    if(a+b >= 10){
        cout << "error" << endl;
    }else{
        cout << a+b << endl;
    }
	return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    String a = sc.next();
    String b = sc.next();
    String s = a + b;
    int ab = new Integer(s).intValue();
    double k = Math.sqrt(ab);
    int l = (int)Math.sqrt(ab);
    if(k == l){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <iomanip>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
#define int ll

using namespace std;
using Graph = vector<vector<int> >;


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


  vector<long double> Weight(N);
  
  for (int i = 0; i < N; i++) {
    cin >> Weight[i];
  }

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


  for (int i = 1; i < N; i++) {
    Weight[i] = (Weight[i-1] + Weight[i]) / 2;
  }


  cout << Weight[N-1] << endl;
}


Measured memory_bytes: 256
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<vector<P> > Graph;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n;
  cin >> n;

  vector<int> a(n);
  REP(i,n) cin >> a[i];
  
  int ans = 0;
  FOR(i,1,n-1){
    if(a[i] > a[i-1] && a[i] < a[i+1]) ans++;
    if(a[i] < a[i-1] && a[i] > a[i+1]) ans++;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 764