akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> //__gnu_pbds::gp_hash_table<int, int> table;
//priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;  //min heap

typedef int OwO;
typedef double UwU;

#define int long long
#define double long double
#define INF 1000000000
#define PI 3.14159265358979323846
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pii pair<int, int>
#define vpii vector<pair<int, int>>
#define vvi vector<vector<int>>
#define vi vector<int>

using namespace std;

OwO main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N,M;
  cin >> N >> M;
  multiset<int> t;
  for(int x = 0; x<N; x++){
    int tt;
    cin >> tt;
    t.insert(tt);
  }
  vpii ab(M);
  for(int x = 0; x<M; x++){
    int A,B;
    cin >> A >> B;
    ab[x]={B,A};
  }
  sort(ab.rbegin(), ab.rend());
  int idx = 0;
  while(*t.begin()<ab[idx].first){
    ab[idx].second--;
    t.erase(t.begin());
    t.insert(ab[idx].first);
    if(ab[idx].second == 0)
      idx++;
  }
  cout << accumulate(t.begin(), t.end(), (int)0) << endl;

  return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;


void A()
{
    int N;
    cin >> N;
    cout << (N+1) / 2;
}


void B()
{
    int A[3][3];
    int N;
    int b[100];
    
    for( int i = 0; i < 3; ++i )
        for( int j = 0; j < 3; ++j )
            cin >> A[i][j];
    
    cin >> N;
    
    for( int i = 0; i < N; ++i )
        cin >> b[i];
    
    
    for( int i = 0; i < N; ++i )
        for( int j = 0; j < 3; ++j )
            for( int k = 0; k < 3; ++k )
                if( A[j][k] == b[i] )
                    A[j][k] = -1;
    
    
    if( A[0][0]+A[1][1]+A[2][2] == -3 ||
        A[0][2]+A[1][1]+A[2][0] == -3 ){
        cout << "Yes" << endl;
        return;
    }
    
    for( int i = 0; i < 3; ++i )
        if( A[i][0]+A[i][1]+A[i][2] == -3 ||
            A[0][i]+A[1][i]+A[2][i] == -3 ){
            cout << "Yes" << endl;
            return;
        }
    
    cout << "No" << endl;
}


void C()
{
    int N;
    int M;
    int s[6];
    int c[6];
    
    cin >> N >> M;
    
    for( int i = 0; i < M; ++i )
        cin >> s[i] >> c[i];
    
    
    int ans[3] = { -1, -1, -1 };
    
    for( int i = 0; i < M; ++i ){
        // 同じ桁に違う数字を入れない
        if( ans[s[i]-1] != -1 && ans[s[i]-1] != c[i] ){
            cout << -1 << endl;
            return;
        }
    
        ans[s[i]-1] = c[i];
    }
    
    // 2桁以上の数字で、いちばん左の桁が0と指定された
    if( 1 < N && ans[0] == 0 ){
        cout << -1 << endl;
        return;
    }

    if( N == 1 ){
        if( ans[0] == -1 ) ans[0] = 0;
        cout << ans[0] << endl;
    } else if( N == 2 ){
        if( ans[0] == -1 ) ans[0] = 1;
        if( ans[1] == -1 ) ans[1] = 0;
        cout << ans[0]*10 + ans[1] << endl;
    } else if( N == 3 ){
        if( ans[0] == -1 ) ans[0] = 1;
        if( ans[1] == -1 ) ans[1] = 0;
        if( ans[2] == -1 ) ans[2] = 0;
        cout << ans[0]*100 + ans[1]*10 + ans[2] << endl;
    }
}

int main()
{
    //A();
    //B();
    C();
    
    return 0;
}


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

int main(){
  string str;
  int n, h;
  while(cin >> str){
    if(str=="-") 
    break;
    cin >> n;
    for(int i=0;i<n;i++){
      cin >> h;
      string cat = str.substr(0,h);
      str.erase(0,h);
      str+=cat;
    }
    cout << str << endl;
  }
}



Measured memory_bytes: 3236
#include <cstdio>
#include <cstring>

using namespace std;
int main()
{
	char a[105];
	char b[105];
	scanf("%s", a);
	scanf("%s", b);
	int k = 3;
    if(a[0] == b[2] && a[2] == b[0] && a[1] == b[1])
    	printf("YES\n");
    else
    	printf("NO\n");

}

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


struct point{
    
    ll p; //point
    ll s; //silver
    
    bool operator < (const point rhs) const {
        if(p!=rhs.p){
            return p<rhs.p;
        }else{
            return s<rhs.s;
        }
    }
};

int main() {
    ll n,m,s;
    std::cin >> n>>m>>s;
    
    vector<ll> u(m),v(m),a(m),b(m),c(n),d(n);
    vector<vector<pair<point,ll>>> edges(2500*53);

    ll amx = 0;
    for (int i = 0; i < m; i++) {
        std::cin >> u[i]>>v[i]>>a[i]>>b[i];
        u[i]--;v[i]--;
        amx = max(amx,a[i]);
        for (int j = 0; j <= 2500; j++) {
            if(j-a[i]<0)continue;
            edges[u[i]+50*j].push_back({{v[i],j-a[i]},b[i]});
            edges[v[i]+50*j].push_back({{u[i],j-a[i]},b[i]});
        }
    }

    for (int i = 0; i < n; i++) {
        std::cin >> c[i]>>d[i];
        for (int j = 0; j <= 2500; j++) {
            // std::cout << j << std::endl;
            edges[i+50*j].push_back({{i,j+c[i]},d[i]});
            if( (j+c[i])>=2500 ) break;
        }
    }
    s = min(s,amx*n);
    
    typedef pair<ll,point> P;
    // map<point,ll> dd;
    vector<vector<ll>> dd(n,vector<ll>(2510,1e18));
    priority_queue<P,vector<P>,greater<P> >que;
    que.push({0,{0,s}});
    for (int i = 0; i <= s; i++) {
        dd[0][i]=0;
    }

    while(!que.empty()){
        P p = que.top();que.pop();
        point v = p.second;
        if(dd[v.p][min(2500ll,v.s)] < p.first)continue;

        for (auto e : edges[v.p+50*min(2500ll,v.s)]) {
            auto [po,co] = e;
            if(dd[po.p][min(2500ll,po.s)]>dd[v.p][min(2500ll,v.s)]+co){
                dd[po.p][min(2500ll,po.s)]=dd[v.p][min(2500ll,v.s)]+co;
                que.push({dd[po.p][min(2500ll,po.s)],po});
            }
        }
    }
    
    for (int i = 1; i < n; i++) {
        ll tmp = 1e18;
        for (int j = 0; j <= amx*n; j++) {
            tmp = min(tmp,dd[i][j]);
        }
        std::cout << tmp << std::endl;
    }
}



Measured memory_bytes: 31184
#include <bits/stdc++.h>
using namespace std;
typedef long long int l1;
typedef vector <int> vi;
typedef vector <long long int> v1;
#define pb push_back
#define mp make_pair
#define iter(i,a,b) for(i=a;i<b;i++)

int main()
{
    ios_base::sync_with_stdio(false);      //for fast cin and cout streams
    cin.tie(NULL);
    cout.tie(NULL);
    
    //THINK..THINK..THINK..nope..EVEN THOSE CORNER CASES
    //DONE ??..NO.!...GO BACK AGAIN NOW..bro
    //ALL RIGHT..GOOD TO GO..
    //MAKE IT SYNTACTICALLY CORRECT..though
    
    /*l1 t;
    cin>>t;
    while(t--)
    {
        l1 n,i;
        cin>>n;
        v1 vec(n);
        iter(i,0,n)
        cin>>vec[i];
    }*/
    
    
    /*l1 n,i;
    cin>>n;
    v1 vec(n);
    iter(i,0,n)
    cin>>vec[i];*/
    
    
    /*l1 t;
    cin>>t;
    while(t--)
    {
        
        
    }*/
  
    int k;
    cin>>k;
    while(k--)
    cout<<"ACL";
    
    
    
    
return 0;
}






Measured memory_bytes: 3608
using System;

public class hello
{

    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var w = int.Parse(line[0]);
            var h = int.Parse(line[1]);
            if (w == 0 && h == 0) break;
            var map = new string[h, w];
            for (int i = 0; i < h; i++)
            {
                var s = Console.ReadLine().Trim();
                for (int j = 0; j < w; j++)
                {
                    int t;
                    map[i, j] = int.TryParse(s[j].ToString(), out t) ? s[j].ToString() : "#";
                }
            }
            var dp = new string[h, w];
            goDp(map, h, w, dp);
        }
    }
    static void goDp(string[,] map, int h, int w, string[,] dp)
    {
        var ans = "0";
        for (int i = 0; i < h; i++)
        {
            for (int j = 0; j < w; j++)
            {
                if (map[i, j] != "#")
                {
                    string t;
                    if ((i - 1 < 0) || (map[i - 1, j] == "#")) t = map[i, j];
                    else t = dp[i - 1, j] + map[i, j];
                    if (t[0] == '0')  t  = delete0(t);
                    string t2;
                    if ((j - 1 < 0) || (map[i, j - 1] == "#")) t2 =  map[i, j];
                    else t2 = dp[i, j - 1] + map[i, j];
                    if (t2[0] == '0') t2 = delete0(t2);
                    dp[i, j] = checkAB(t, t2) ? t : t2;
                    if (((i + 1 >= h) || (map[i + 1, j] == "#")) &&( (j + 1 >= w) || map[i, j + 1] == "#"))
                        ans = checkAB(ans, dp[i, j]) ? ans : dp[i, j];
                }
            }
        }
        Console.WriteLine(ans);
    }
    static string delete0 (string s)
    {
        if (s.Replace("0", "").Length == 0) return "0";
        var ans = "";
        var p = 0;
        var first = true;
        while (p < s.Length)
        {
            if (first && s[p] != '0') { ans += s[p]; first = false; }
            else if (!first) ans += s[p];
            p++;
        }
        return ans;

    }
    static bool checkAB(string s, string t)
    {
        if (s == "") s = "0";
        if (t == "") t = "0";
        if (s.Length > t.Length) return true;
        else if (s.Length < t.Length) return false;
        return s.CompareTo(t) > 0;
    }
}



Measured memory_bytes: 30400
import java.util.*;

class Main {
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		String a,b,c;
		a = scan.next();
		b = scan.next();
		c = scan.next();
		
		List<String> list = new ArrayList<String>();
		list.add (a);
		list.add (b);
		list.add (c);
		
		Collections.sort(list);
		
		System.out.println(list.get(0) + " " + list.get(1) + " " + list.get(2));
		
	}
}

Measured memory_bytes: 26252
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

int N, Q, A[100001];
ll S[100001], Sdiv[100001];
pair<int, int> X[100000];
ll ans[100000];

int main() {
    cin >> N >> Q;
    for (int i = 1; i <= N; i++) {
        cin >> A[i];
        S[i] = S[i - 1] + A[i];
        Sdiv[i] = A[i];
        if (i - 2 > 0) Sdiv[i] += Sdiv[i - 2];
    }

    for (int i = 0; i < Q; i++) {
        int x;
        cin >> x;
        X[i] = {x, i};
    }

    sort(X, X + Q);

    int y = 1;
    for (int q = 0; q < Q; q++) {
        int x = X[q].first;
        while (y <= N && A[y] < x) y++;
        while (y <= N) {
            // 高橋
            int upper = N - y + 1;
            // 青木
            int lower = y - (lower_bound(A, A + N + 1, max(1, 2 * x - A[y])) - A) + 1;
            if (upper > lower) {
                y++;
            } else {
                break;
            }
        }

        ll result = S[N] - S[y - 1];
        int t_first = N - (N - y + 1) * 2;
        if (t_first > 0) result += Sdiv[t_first];
        ans[X[q].second] = result;
    }

    for (int i = 0; i < Q; i++) {
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 5248
#include<stdio.h>
int main()
{
    long long int n,k,res1,res2;
    scanf("%lld%lld",&n,&k);
    res1=n%k;
    res2=(n%k)-k;
    res2=res2*-1;
    if(res1<res2)
    {
        printf("%lld\n",res1);
    }
    else
    {
        printf("%lld\n",res2);
    }
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;

using llong = long long;
int main(){
  int N,K;
  cin >> N >> K;
  vector<llong> X(N);
  for(auto &x:X) cin >> x;
  llong minT = 1'000'000'000;
  for(int i=0;i+K-1<N;++i){
    if( X[i] <= 0 && X[i+K-1] <= 0 ){
      minT = min( minT , -X[i] );
    }else if( X[i] >= 0 && X[i+K-1] >= 0 ){
      minT = min( minT , X[i+K-1] );
    }else{
      minT = min( minT , min( 2*X[i+K-1] - X[i] , X[i+K-1] -  2*X[i] ) );
    }
  }
  cout << minT << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;

int main(){
    DRIII(A,B,C);int v=0;
    while(A%2==0&&B%2==0&&C%2==0){
        if(A==B&&B==C)return 0*puts("-1");
        v++;
        int d[3]={(A+B)/2,(B+C)/2,(C+A)/2};
        A=d[0];B=d[1],C=d[2];
    }
    printf("%d\n",v);
    return 0;
}


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


int main(){

  string S;
  
  cin >> S;
  
  for(int i = 0; i < S.size() - 1; i++){
    if(S.at(i) ==  S.at(i + 1)){
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import Counter

n = int(input())
a = list(map(int,input().split()))
o = Counter(a).most_common()

if len(o) >=4:
    print('No')
    exit()
if len(o) == 3:
    if o[0][1]==o[1][1] and o[1][1] == o[2][1]:
        if o[0][0]^o[1][0] == o[2][0] and o[1][0]^o[2][0] == o[0][0] and o[2][0]^o[0][0] == o[1][0]:
            print('Yes')
            exit()
    print('No')
    exit()
if len(o) == 2:
    if n%3 == 0:
        if o[1][0] == 0 and o[1][1] == n//3:
            print('Yes')
            exit()
    print('No')
    exit()

if len(o) == 1:
    if o[0][0] == 0:
        print('Yes')
        exit()
    else:
        print('No')
        exit()

Measured memory_bytes: 60784
n = int(input())
input_list = list(map(int, input().split()))

tmp_list = []
tmp_list.append(input_list[n-2])
tmp_list.extend(input_list[::-1])

output_list = [ min(tmp_list[i:i+2]) for i in range(len(tmp_list) - 1) ]
output_list.append(input_list[0])

print(sum(output_list))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#define ll long long
#define faltu ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define binary(x) std::string binary = std::bitset<25>(x).to_string(); //to binary
#define inf 1000000007
#define mod 1000000007
#define pi pair<int,int>
#define lpi pair<int,int>
#define mp make_pair
#define pb push_back
#define vi vector<int>
#define lvi vector<long long int>
#define pie 3.14159265358979323846
ll int MMM=inf;
int pw(ll int a, ll int b) {
    if (b == 0) return 1;
    ll int t = pw(a, b / 2);
    if (b % 2 == 0) return (t * t)%mod;
    else return ((t * t)%mod * a)%mod;
}
using namespace std;
vi pm;
void prm(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
              prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p]) pm.pb(p);
}
bool sortbysecdesc(const pair<ll int,ll int> &a,const pair<ll int,ll int> &b)
{
    return a.first>b.first;
}
bool cmp(int x,int y){return x>y;}
int gcd(int a,int b)
{
    if(a<b)
        swap(a,b);
    return (b==0)?a:gcd(b,a%b);
}
int main()
{
	faltu;
	int n,m,q,qq=0;
	cin>>n>>m>>q;
	map<int,int>mp;
	qq=q;
	while(q--)
	{
		int x;
		cin>>x;
		mp[x]++;
	}
	for(int i=1;i<=n;i++)
	{
		if(mp[i]+m-qq>0)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}

}










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

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

    int max_d = 0;
    int time = 0;
    while (max_d < x)
    {
        time++;
        max_d += time;
    }
    cout << time << endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np
N = int(input())
a = list(map(int, input().split()))
a_np = np.array(a)
b = []
for i in range(a_np.min(), a_np.max()+1):
  c = a_np - i
  d = [j*j for j in c]
  b.append(sum(d))
print(min(b))

Measured memory_bytes: 12388
#include<bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
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; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;

bool solve(){
  int ans=0;
  string s;cin>>s; 
  if(s=="RRR")ans=3;
  else if(s=="RRS")ans=2;
  else if(s=="RSR")ans=1;
  else if(s=="RSS")ans=1;
  else if(s=="SRR")ans=2;
  else if(s=="SRS")ans=1;
  else if(s=="SSR")ans=1;
  else if(s=="SSS")ans=0;
  cout<<ans<<endl;
  return false;
}

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout<<fixed<<setprecision(30);
  solve();
}


Measured memory_bytes: 3596
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {

	int n;
	cin >> n;
	int ans = 0;
	if (n <= 111)
		ans = 111;
	else if (n <= 222)
		ans = 222;
	else if (n <= 333)
		ans = 333;
	else if (n <= 444)
		ans = 444;
	else if (n <= 555)
		ans = 555;
	else if (n <= 666)
		ans = 666;
	else if (n <= 777)
		ans = 777;
	else if (n <= 888)
		ans = 888;
	else if (n <= 999)
		ans = 999;

	cout << ans << endl;


	return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

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

inline bool LT(double a,double b) { return !equals(a,b) && a < b; }
inline bool LTE(double a,double b) { return equals(a,b) || a < b; }

void compute() {

}

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  rep(i,n) cin >> vec[i];
  int cnt = 0;
  rep(i,n) {
    if( i + 1 < n && vec[i] == ( i + 1 ) && vec[i+1] == ( i + 2 ) ) {
      ++cnt;
      i++;
      continue;
    }
    if( vec[i] == ( i + 1 ) ) {
      ++cnt;
    }
  }


  cout << cnt << endl;
  compute();
  return 0;
}


Measured memory_bytes: 640
/* ****Ragnar7 -SHINIGAMI- _Lawliet_**** */
/* First, solve the problem.Then write the code. */
#include<bits/stdc++.h>
#define ll          long long
#define ld 			long double
#define hell        1000000007
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifndef ONLINE_JUDGE
	freopen ("input.txt","r",stdin);
	// freopen ("output.txt","w",stdout);
	#endif
	ll t = 1;
	// cin>>t;
	while(t--)
	{
		ll n,m;
		cin>>n>>m;
		char a[n+1][m+1];
		ll dp[n+1][m+1];
		for(ll i=0;i<=n;i++)
			for(ll j=0;j<=m;j++)
				a[i][j] = '#';
		for(ll i=1;i<=n;i++)
			for(ll j=1;j<=m;j++)
				cin>>a[i][j];
		memset(dp,0,sizeof(dp));
		dp[1][1] = 1;
		for(ll i=1;i<=n;i++)
		{
			for(ll j=1;j<=m;j++)
			{
				if(a[i-1][j]=='.')
					dp[i][j]+=dp[i-1][j];
				if(a[i][j-1]=='.')
					dp[i][j]+=dp[i][j-1];
				dp[i][j]%=hell;
				// cout<<dp[i][j]<<" ";
			}
			// cout<<endl;
		}
		cout<<dp[n][m];

		
	}

	
	time
	return 0;
}

Measured memory_bytes: 12396
/* {{{ */
use std::io::*;
use std::str::FromStr;

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

impl<R: Read> Scanner<R> {
    fn new(r: R) -> Scanner<R> {
        Scanner { reader: r }
    }
    fn read<T: FromStr>(&mut self) -> T {
        let token = self
            .reader
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok().unwrap()
    }
}
/* }}} */

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let n: usize = sc.read();
    let mut g = vec![vec![false;n];n];
    for _ in 0..n {
        let u: usize = sc.read();
        let m: usize = sc.read();
        for _ in 0..m {
            let v: usize = sc.read();
            g[u-1][v-1] = true;
        }
    }

    use std::collections::VecDeque;
    let mut queue = VecDeque::new();
    let mut d = vec![-1;n];
    queue.push_back(0);
    d[0] = 0;
    while let Some(&u) = queue.front() {
        for v in 0..n {
            if !g[u][v] || d[v] != -1 { continue; }
            queue.push_back(v);
            d[v] = d[u] + 1;
        }
        queue.pop_front();
    }
    for i in 0..n {
        println!("{} {}", i+1, d[i]);
    }
}
/* vim:set foldmethod=marker: */



Measured memory_bytes: 5028
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int N, A, B;
    cin >> N;
    if (N == 1) {
        cout << "Hello World" << endl;
    } else {
        cin >> A >> B;
        cout << A + B << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <random>
#include <fstream>
#include <time.h>
// #define int long long
#define debug(x) cerr << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 998244353;
const ll LINF = 1e18;
const double EPS = 1e-9;


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

  ll n;
  cin>>n;
  ll a[n];
  rep(i,n) {
    cin>>a[i];
  }
  rep(i,n-1) {
    if(a[i] < 0) {
      a[i] *= -1;
      a[i+1] *= -1; 
    }
  }
  bool minus = false;
  if(a[n-1] < 0) {
    minus = true;
  }
  ll ans = 0;
  if(minus) {
    rep(i,n) {
      ans += abs(a[i]);
    }
    ll mi = abs(a[0]);
    rep(i,n) {
      if(mi > abs(a[i])) {
        mi = abs(a[i]);
      }
    }
    debug(mi);
    ans = ans - 2LL * mi;
  } else {
    rep(i,n) {
      ans += abs(a[i]);
    }
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  ll N;
  cin >> N;
  set<ll> st;
  for (ll i = 1; i * i <= N; ++i)
  {
    if (N % i == 0)
    {
      st.insert(i);
      st.insert(N / i);
    }
  }
  ll ans = 0;
  for (auto a : st)
  {
    ll m = a - 1;
    if (0 < m && N / m == N % m)
      ans += m;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int N;
vector<vector<int> > box;
int getnum(int);
void output(int,int);
int main(){
    cin>>N;
    box.resize(N);
    for(int i=0;i<N;++i){
        box[i].resize(26);
        for(int j=0;j<26;++j){
            box[i][j]=0;
        }
    }
    string str;
    for(int i=0;i<N;++i){
        cin>>str;
        for(int j=0;j<str.size();++j){
            ++box[i][str[j]-'a'];            
        }
    }
    for(int i=0;i<26;++i){
        output(getnum(i),i);
    }
    cout<<endl;    
return 0;
}

int getnum(int key){
    int res=1<<20;
    for(int i=0;i<N;++i){
        res=min(res,box[i][key]);
    }
    return res;
}

void output(int num,int key){
    for(int i=0;i<num;++i){
    cout<<(char)(key+'a');
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#define M 100000000
int main(){
  int D,n,i,j,k,l,exp,d[101][3];
  while(scanf("%d %d",&D,&n),D||n){
    for(i=0;i<n;i++)scanf("%d %d %d",&d[i][0],&d[i][1],&d[i][2]);
    int dp[101][102]={0};
    for(i=0;i<D;i++){
      for(j=0;j<102;j++)dp[i+1][j]=M;
    }
    for(i=1;i<=D;i++){
      for(j=101;j>=0;j--){
	for(k=0;k<n;k++){
	  if(j<d[k][2])continue;//exp husoku
	  exp=j+d[k][1];
	  if(exp>101)exp=101;
	  l=i-d[k][0];
	  if(l<0)l=0;
	  if(dp[i][j]>dp[l][exp]+1)dp[i][j]=dp[l][exp]+1;
	}
      }
    }
    /*for(i=0;i<D;i++){
      for(j=0;j<20;j++)printf("%d ",dp[i][j]);printf("\n");
      }//*/
    if(M-dp[D][0])printf("%d\n",dp[D][0]);
    else          printf("NA\n");
  }
  return 0;
}

Measured memory_bytes: 660
#include <iostream>

using namespace std;

string str, ring;
int N, ans;

int main() {
    cin >> str >> N;
    while (N--) {
        cin >> ring;
        ring += ring.substr(0, str.length() - 1);
        if (ring.find(str, 0) != string::npos) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3180
#include <stdio.h>

int main(){

  int array[124] = {};
  int i,j,v = 0,n,k;
  scanf("%d",&n);
  
  for(i = 0;i < n;i++){
    scanf("%d",&array[i]);
  }

  for(i = 1;i <= n;i++){
    v = array[i];
    j = i - 1;
    for(k = 0;k < n;k++){
      if (k != n - 1) printf("%d ",array[k]);
      else printf("%d",array[k]);
    }
    printf("\n");
    
    while(j >= 0 && array[j] > v){
      array[j + 1] = array[j];
      j--;
      array[j + 1] = v;
    }
  }

  return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acosl(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
#define MXN 200005
int main(){
    char c[1005];
    scanf("%s",c);
    int ok=1;
    if(strlen(c)%2)ok=0;
    for(int i = 0;c[i]!=0;i++){
        if(i%2){
            if(c[i]!='i')ok=0;
        }
        else{
            if(c[i]!='h')ok=0;
        }
    }
    if(ok)printf("Yes\n");
    else printf("No\n");
}
/*
[1,2,4,3,5,6]
concat(sorted([4,2,1]),sorted([5,3,6]))
concat(shuffle([2,1]),shuffle([2,3]))
concat(shuffle([2,1,3]),shuffle([3]))
*/

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

//qsort
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

//比較
int max(int a, int b){
	if (a>b) return a;
	else return b;
}

int min(int a,int b) {
	if(a>b) return b;
	else return a;
}


//main関数
int main() {
	double A,B,H,M;
	scanf("%lf %lf %lf %lf",&A,&B,&H,&M);
	double Ano,Bno;
	Ano = (H*30 + M/2);
	Bno = M*6;
	double kakudo = fabsl(Ano-Bno)*3.14159265358979323846164338/180 ;
	
	double ans = sqrt( pow((double)A,2.0) + pow((double)B,2.0) - 2*(double)A*(double)B*cos(kakudo));
	
	printf("%.11lf",ans);
	return 0;
	
	
}

Measured memory_bytes: 2656
#include <iostream>
#include<string>
using namespace std;
#define NIL  -1
struct node
{
	int key;//键值
	struct node *parent, *left, *right;
};
struct node *head=NULL,*movepoint;
void includeConnectNode()//链接结点
{
	struct node *moveparent = NULL, *movehead;
	if (head == movepoint)//根
		return;

	else
	{
		movehead = head;
		while(movehead!=NULL)
		{
			moveparent = movehead;
			if (movehead->key > movepoint->key ) //左子树键值比父的小
				movehead = movehead->left;
			else //右子树键值比父大,这里要注意:left,right可以为NULL，即跳出循环的条件;
				movehead =movehead->right;
		}
		movepoint->parent = moveparent;//父节点
		if (movepoint->key < moveparent->key)
			moveparent->left = movepoint;
		else
			moveparent->right = movepoint;
		
	}
		
	

}
void includeCreatNode()//建立结点
{
	movepoint = new  node;
	movepoint->parent = NULL;
	movepoint->left = NULL;
	movepoint->right = NULL;
	if (head == NULL)
		head = movepoint;
	cin >> movepoint->key;
	includeConnectNode();
}
void includePrintInorderData(struct node *next)//中序打印;
{
	if (next == NULL)
		return;
	includePrintInorderData(next->left);
	cout <<" "<< next->key;
	//cout<< " ";
	includePrintInorderData(next->right);
}
void includePrintPreorderData(struct node *next)
{
	if (next == NULL)
		return;
	cout << " "<<next->key;
	//cout << " ";
	includePrintPreorderData(next->left);
	includePrintPreorderData(next->right);

}
int main()
{
	int total;
	string order;
	cin >> total;
	for (int i = 0; i < total; i++)
	{
		cin >> order;
		if("insert"==order)
			includeCreatNode();
		else if("print"==order)
		{
			includePrintInorderData(head);
			cout << endl;
			includePrintPreorderData(head);
		   cout<<endl;
		    
		}
	}
	if(head!=NULL)
		delete head;
 
	return 0;
}


Measured memory_bytes: 26588
#include <stdio.h>

#define MAX 100000

int Partition(int[], int, int);
void swap(int[], int, int);

int main()
{
  int A[MAX], n;
  int pivot;
  int i;

  scanf("%d", &n);
  for (i = 0; i < n; i++)
    scanf("%d", &A[i]);

  pivot = Partition(A, 0, n - 1);

  for (i = 0; i < n; i++)
  {
    if (i)
      printf(" ");

    if (i == pivot)
      printf("[");

    printf("%d", A[i]);

    if (i == pivot)
      printf("]");
  }

  printf("\n");

  return 0;
}

int Partition(int A[], int p, int r)
{
  int x;
  int i, j;

  x = A[r];
  i = p - 1;

  for (j = p; j < r; j++)
    if (A[j] <= x)
    {
      i++;
      swap(A, i, j);
    }

  swap(A, i + 1, r);

  return i + 1;
}

void swap(int A[],int a,int b){
  int temp;

  temp = A[a];
  A[a] = A[b];
  A[b] = temp;
}


Measured memory_bytes: 2148
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;

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

ll lcm(ll a,ll b){
    a / gcd(a,b) * b;
}
const ll mod = 1e9 + 7;

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

const ll INF = 1e9;
/////////////////////////////////////////////////////////////////////////////////////////

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> c(m);
    for (int i = 0;i < m;i++) cin >> c[i];
    int dp[n+1];
    for (int i = 0;i <= n;i++){
        dp[i] = i;
    }

    for (int i = 0;i < m;i++){
        for (int j = 0;j <= n;j++){
            if (j - c[i] >= 0) dp[j] = min(dp[j],dp[j-c[i]] + 1);
        }
    }

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


Measured memory_bytes: 3312
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int n, k;
    cin >> n >> k;

    if(n >= 2 * k - 1){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}


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

using namespace std;

typedef long long ll;

int main(){
  ll W,H,n;
  ll area;
  cin>>W>>H>>n;
  area=W*H;
  
  ll x,y,a;
  ll mx[4];
  for(int i=0;i<4;i++){
    mx[i]=-1;
  }
  for(int i=0;i<n;i++){
    cin>>x>>y>>a;
    if(a==1){
      if(x>mx[a-1]||mx[a-1]==-1){
        mx[a-1]=x;
      }
    }
    if(a==2){
      if(x<mx[a-1]||mx[a-1]==-1){
        mx[a-1]=x;
      }
    }
    if(a==3){
      if(y>mx[a-1]||mx[a-1]==-1){
        mx[a-1]=y;
      }
    }
    if(a==4){
      if(y<mx[a-1]||mx[a-1]==-1){
        mx[a-1]=y;
      }
    }
  }
  
  if(mx[0]>mx[1]&&mx[0]!=-1&&mx[1]!=-1){
    area=0;
  }else{
    if(mx[2]>mx[3]&&mx[0]!=-1&&mx[1]!=-1){
      area=0; 
    }else{
      for(int i=0;i<4;i++){
          if(mx[i]==-1){
            mx[i]=0;
          }
      }
      area=(W-(mx[0]+(mx[1]==0?0:W-mx[1])))*(H-(mx[2]+(mx[3]==0?0:H-mx[3])));
    }
  }
  cout<<area<<endl;
  return 0;
}

Measured memory_bytes: 3632
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define st first
#define sc second
#define arr array
#define yes cout << "Yes" <<"\n"
#define no cout << "No" <<"\n"
#define lb lower_bound
#define ub upper_bound
#define fast ios_base::sync_with_stdio(false)
#define out cin.tie(nullptr)
#define task "A"
#define open(task)  if(fopen(task".inp", "r")){freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout);}
#define open_to_check(task)  if(fopen(task".inp", "r")){freopen(task".inp", "r", stdin);}
#define int64 long long

const int maxn = 1e5 + 2;
const int maxN = 1e5 + 5;
const ll mod = 998244353;

using namespace std;

/// Count : 1


int main()
{
    //if(fopen(task".inp", "r")){
        //freopen(task".inp", "r", stdin);
        //freopen(task".out", "w", stdout);
    //}
    string s, t;
    cin >> s >>t ;
    int n = s.size();
    int m = t.size();
    int ans = 1e9;
    int dem = 0;
    s = ' ' + s;
    t = ' ' + t;
    for(int i=1; i<=n; i++){
        if(i + m - 1 <= n){
            dem = 0;
            for(int j=i; j<= i + m - 1; j++){
                //cout << s[j] <<" "<<t[j - i + 1] <<"\n";
                if(s[j] != t[j - i + 1]){
                    dem ++;
                }
            }
            //cout <<"\n";
            ans = min(ans, dem);
        }
    }
    cout << ans;
}


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

#define foreach(i, v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define BETWEEN(a, x, b) (a<=x&&x<b)

using namespace std;
typedef long long ll;

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

  ll n,m;cin>>n>>m;
  if(n==1&&m==1){cout<<1<<endl;}
  else if(m==1) {cout<<(n-2)<<endl;}
  else if(n==1) {cout<<(m-2)<<endl;}
  else {cout<<(n-2)*(m-2)<<endl;}

  return 0;
}


Measured memory_bytes: 256
M, D = map(int, input().split())
count = 0
for month in range(1, M+1):
    for date in range(1, D+1):
        d1 = date%10
        if d1 < 2: continue
        d10 = int(date/10)
        if d10 < 2: continue
        if d1 * d10 == month:
            count += 1
print(count)

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};


signed main(){
    gearup;
    ll n,m; cin >> n >> m;
    vl num(n,1),red(n,0);
    red[0] = 1;
    rep(i,m){
        int x,y;
        cin >> x >> y;
        x--;y--;
        
        if(red[x])red[y] = 1;
        if(num[x] == 1)red[x] = 0;
        num[x]--;
        num[y]++;
    }
    ll res = 0;
    rep(i,n) if(num[i] && red[i])res++;
    out(res);
}



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

#define ll long long int
#define All(a) (a).begin(),(a).end()

void solve(){
  int n,m;
  
  scanf("%d",&n);
  int A[n];
  ll dp[n+2]={};
  for(int i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  for (int i = 1; i < n+2; i++)
  {
    dp[i]=INT_MAX;
  }
  dp[0]=0;
  dp[1]=abs(A[1]-A[0]);
  for(int i=2;i<n;i++){
      dp[i]=min(dp[i-1]+abs(A[i]-A[i-1]),dp[i-2]+abs(A[i]-A[i-2]));
   }
  


  printf("%lld\n",dp[n-1]);
}
int main(){
  /*
  int q;
  scanf("%d",&q);
  while(--q)solve();
  */
  solve();

  return 0;
}

Measured memory_bytes: 4972
//Created by Kira

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

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    



int main(){
   IOS

       int n, x; cin>>n>>x;

    vi a(n);
    for(int &i : a)cin>>i;

    int d = 0;
    int cnt = 1;

    for(int i = 0; i < n; i++){
        d += a[i];
        if(d <= x)cnt++;
    }   

    cout<<cnt<<"\n";



   

    







}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1)
        res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



Measured memory_bytes: 256
R, G, B, N = map(int, input().split())

import numpy as np

r = np.arange(0, N+1, R, dtype=np.int64)
g = np.arange(0, N+1, G, dtype=np.int64)
r, g = np.meshgrid(r, g)
b = N - r - g

print(np.sum(((b%B)==0) & (b>=0)))



Measured memory_bytes: 302500
import math


def kyori(list_a,list_b):
    return math.sqrt((list_a[0] - list_b[0]) ** 2 + (list_a[1] - list_b[1]) ** 2)


def sum_kyori(n,n_paths):
    result = 0
    for i in range(n):
        for j in range(n):
            if j>i:
                result = result+kyori(n_paths[i],n_paths[j])
    return result


n = int(input())
paths = []
for i in range(n):
    paths.append(list(map(lambda x:int(x),input().split(" "))))


print(sum_kyori(n,paths)*2/n)



Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)





int main() {
    ll n;
    string a, b, c;
    cin >> n >> a >> b >> c;
    ll ans = 0;
    REP(i, n){
        if(a[i] == b[i] && b[i] == c[i]){
            continue;
        }
        else if(a[i] == b[i] || b[i] == c[i] || c[i] == a[i]){
            ans++;
        }
        else{
            ans += 2;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main(void){
  int i,j,s,n,m;
  static int a[100][100],b[100],c[100];
 
  scanf("%d%d",&n,&m);
 
  for(i=0;i<n;i++)
    for(j=0;j<m;j++)
      scanf("%d",&a[i][j]);
 
  for(i=0;i<m;i++)
    scanf("%d",&c[i]);
 
  for(i=0;i<n;i++){
    s = 0;
    for(j=0;j<m;j++)
      s += a[i][j] * c[j];
    printf("%d\n",s);
  }
   
  return 0;
}


Measured memory_bytes: 2128
#include <stdio.h>
#include <string.h>
 
char a[22][22];
 
int main()
{
    int n, x, y, m, s;
    int i;
    char d[3];
 
    while (1) {
        scanf("%d", &n); if (!n) break;
        memset(a, 0, sizeof(a));
        for (i = 0; i < n; i++) scanf("%d%d", &x, &y), a[x][y] = 1;
        scanf("%d", &m);
        x = 10, y = 10;
        while (m-- > 0) {
            scanf("%s%d", d, &s);
            while (s-- > 0) {
                if      (d[0] == 'E') x++;
                else if (d[0] == 'S') y--;
                else if (d[0] == 'W') x--;
                else if (d[0] == 'N') y++;
                if (a[x][y]) n--, a[x][y] = 0;
            }
        }
        puts(!n ? "Yes" : "No");
    }
    return 0;
}


Measured memory_bytes: 2100
#pragma GCC optimize("03")
#include<bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int ll;
typedef vector<ll> vec;
typedef vector<vector<ll> > matrix;
typedef pair<ll,ll> pi;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,c1=0,c2=0,c3=0,c4=0;
	cin>>n;
	string st1="AC",st2="WA",st3="TLE",st4="RE",st;
	for(ll i=1;i<=n;i++)
	{
		cin>>st;
		if(st == st1)
			c1+=1;
		else if(st == st2)
			c2+=1;
		else if(st == st3)
			c3+=1;
		else
			c4+=1;
	}
	cout<<st1<<" x "<<c1<<endl;
	cout<<st2<<" x "<<c2<<endl;
	cout<<st3<<" x "<<c3<<endl;
	cout<<st4<<" x "<<c4<<endl;
	return 0;
}

Measured memory_bytes: 3624
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  int n;
  cin >> n;
  int sum = 0;
  int longest = 0;
  REP(i,n){
    int l;
    cin >> l;
    longest = max(longest,l);
    sum += l;
  }
  if(longest < sum - longest){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long;
#define dbg(x) cout<<#x<<"--------------"<<x<<endl;
#define dl cout<<"LINE"<<__LINE__<<endl;
using namespace std;
int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int n;
	cin>>n;
	if(n>=30)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	
	
	
		
	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;
 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
 
double eps = .000000001;
int top[80][80][12801];
bool memoo[12801];
int n, m;
int red[80][80];
int blue[80][80];
int maxsteps = 0;
int func(int i, int j, int sum){
    if (i >= n || j >= m){
        return 1;
    }
    if (top[i][j][sum]){
        
        return 1;
    }
    // choose red
    int sum1 = sum;
    sum1 += red[i][j];
    sum1 -= blue[i][j];
    // go down
    sum1 = abs(sum1);
    func(i+1, j, sum1);
    // go right
    func(i, j+1, sum1);
    
    // choose blue
    int sum2 = sum;
    sum2 -= red[i][j];
    sum2 += blue[i][j];
    sum2 = abs(sum2);
    // go down
    func(i+1, j, sum2);
    // go right
    func(i, j+1, sum2);
    if (i == n-1 && j == m-1){
        memoo[sum2] = true;
    }
    top[i][j][sum] = 1;
    if (i == n-1 && j == m-1){
        memoo[sum1] = true;
        memoo[sum2] = true;
    }
    return 1; 
}

int main(){
  prep();
 
  cin >> n >> m;
  
  for (int i=0; i<n; i++){
      for (int j=0;j <m; j++){
          cin >> red[i][j];
      }
  }
  for (int i=0; i<n; i++){
      for (int j=0;j <m; j++){
          cin >> blue[i][j];
      }
  }
  func(0, 0, 0);
  int minnest = 1000000000;
  for (int i=0; i<=12800; i++){
      if (memoo[i]){
          minnest = i;
          break;
      }
      
  }
  cout << minnest;
  return 0; 
}


Measured memory_bytes: 318848
#include <bits/stdc++.h>
#define H 128
#define W 17
#define INF 1e4
using namespace std;
int h,w;
string str[H];

/*
  short mem[H][W][1<<W];
  bool used[H][W][1<<W];
  int dfs(int y,int x,int bit,int p,int u){
  if( y == h ) return 0;
  if(p+(w-x) < str[y].size()) return -INF;
  if( x == w ) {
  if(p < (int)str[y].size()) return -INF;
  return dfs(y+1,0,bit,0,0);
  }

  if(used[y][x][bit]) return mem[y][x][bit];
  used[y][x][bit] = 1;
  int a=0,b=0;

  //?????????????????????
  int abit = bit & (~(1<<x));
  a = dfs(y,x+1,abit,p,u+(bit>>x&1));
  
  //???????????????
  int bbit = bit | (1<<x);
  if(p<(int)str[y].size()){
  int score = 0;
  score += 2*((bit>>x&1)&&(str[y][p]==str[y-1][u]));
  score += 2*(x>=1&&(bit>>(x-1)&1)&&str[y][p]==str[y][p-1]);
  b = score+dfs(y,x+1,bbit,p+1,u+(bit>>x&1));
  }
  return mem[y][x][bit]=max(a,b);
  }
*/


int Max(int &a,int b){return a=max(a,b);}

int dp[2][W][1<<W];
int A[W][1<<W],B[W][1<<W];
void mkAB(int x,int bit){
  int sum = __builtin_popcount(bit);
  int cnt = 0;
  for(int i=0;i<x;i++)cnt+=(bit>>i&1);
  A[x][bit] = cnt;
  B[x][bit] = sum - cnt;
}

int DP(){
  for(int i=0;i<W;i++)
    for(int j=0;j<(1<<W);j++)mkAB(i,j);

  memset(dp,-1,sizeof(dp));
  dp[0][0][0] = 0;
  int res = 0;
  for(int i=0;i<h;i++){
    int idx = i%2;
    for(int j=0;j<w;j++){
      for(int bit=0;bit<(1<<w);bit++){
        if(dp[idx][j][bit]==-1)continue;
        int p = A[j][bit];
        int u = i? str[i-1].size()-B[j][bit]:0;
        
        //use space
        int abit = bit & (~(1<<j));
        Max(dp[idx][j+1][abit],dp[idx][j][bit]);
        

        //use character
        if(p>=(int)str[i].size())continue;
        int bbit = bit | (1<<j);
        int score = 0;
        score += 2*((bit>>j&1)&&(str[i][p]==str[i-1][u]));
        score += 2*(j>=1&&(bit>>(j-1)&1)&&str[i][p]==str[i][p-1]);
        Max(dp[idx][j+1][bbit],dp[idx][j][bit]+score);
      }
    }
    for(int bit=0;bit<(1<<w);bit++){
      if(__builtin_popcount(bit) != str[i].size())continue;
      Max(dp[!idx][0][bit],dp[idx][w][bit]);
      Max(res,dp[idx][w][bit]);
    }
  }
  return res;
}

int main(){
  cin>>h>>w;
  for(int i=0;i<h;i++) cin>>str[i];
  //  cout<<dfs(0,0,0,0,0)<<endl;
  cout<<DP()<<endl;
  return 0;
}

Measured memory_bytes: 37980
func readArrayInt() -> [Int] {
    readLine()!.split(separator: " ").map({Int($0)!})
}

let line = readArrayInt()
let (A, B, N) = (line[0], line[1], line[2])
let x = min(B - 1, N)
print(A * x / B - A * (x / B))


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

int main() {
	int N;
  cin>>N;
  vector<string> vec(N);
  
  
  for(int i=0;i<N;i++){
  	cin >> vec.at(i);
  }
  
  
  bool bo=1;
  for(int i=1;i<N;i++){
  	if(vec.at(i).at(0)!=vec.at(i-1).at(vec.at(i-1).size()-1)){
    	bo=0;   
    }
  }

  for(int i=0;i<N-1;i++){
    for(int j=i+1;j<N;j++){
    	if(vec.at(i)==vec.at(j)){
        	bo =0;
        }
    }
  }
  
  
  if(bo)
  cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;


return 0;
}

Measured memory_bytes: 256