akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main()
{
    int A, B;
    cin >> A >> B;
    int number;
    int reverse = 0;
    int ans = 0;
    for(int i = A; i <= B; ++i)
    {
        number = i;
        reverse = 0;
        while (number > 0)
        {
            reverse = reverse * 10 + number % 10;
            number /= 10;
        }
        if(i == reverse) ++ans;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

char pattern[8][8];

void rotate_270() {
    printf("270\n");
    for (int i = 7; i >= 0; i--) {
        for (int j = 0; j < 8; j++) {
            putchar(pattern[j][i]);
        }
        putchar('\n');
    }
}

void rotate_180() {
    printf("180\n");
    for (int i = 7; i >= 0; i--) {
        for (int j = 7; j >= 0; j--) {
            putchar(pattern[i][j]);
        }
        putchar('\n');
    }
}

void rotate_90() {
    printf("90\n");
    for (int i = 0; i < 8; i++) {
        for (int j = 7; j >= 0; j--) {
            putchar(pattern[j][i]);
        }
        putchar('\n');
    }
}

int main() {
    for (int i = 0; i < 8; i++) {
        for (int j = 0; j < 8; j++) {
            pattern[i][j] = getchar();
        }
        getchar();
    }
//    for (int i = 0; i < 8; i++) {
//        for (int j = 0; j < 8; j++) {
//            cout << pattern[i][j];
//        }
//        cout << endl;
//    }
    rotate_90();
    rotate_180();
    rotate_270();
    return 0;
}

Measured memory_bytes: 0
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>

    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    using ll = long long;

    int main(){
      int n,t;
      cin>>n>>t;
      VEC(int,a,n);
      int ans = 0;
      REP(i,1,n-1){
        ans += min(t,a[i]-a[i-1]);
      }
      ans += t;
      cout<<ans<<endl;
    }


Measured memory_bytes: 1024
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 1000000007; //10^9+7

int main() {
    string s;
    cin >> s;
    int cnt = 0;
    REP(i, s.size()){
        if(s[i] == 'o')cnt++;
    }
    print(700 + cnt * 100);
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))  

H = list(reversed(H)) 
ans='Yes'
if N==1:
    ans='Yes'
else:         
    for i in range(1, N):
        if H[i] - H[i-1] >= 2: #
            ans='No'
            break   
        elif H[i] - H[i-1] == 1: # 1 smaller
            H[i] -= 1
print(ans)   

Measured memory_bytes: 14396
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.AGC_Challenge
{
    class _019_B
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            string a = Read();
            long noNeed = 0;
            var dict = new Dictionary<char, long>();
            for(int i = 0; i < a.Length; i++)
            {
                if (dict.ContainsKey(a[i]))
                {
                    noNeed += dict[a[i]];
                }
                else
                {
                    dict.Add(a[i], 0);
                }
                dict[a[i]]++;
            }
            long length = a.Length;
            long all = length * (length - 1) / 2;
            Console.WriteLine(all - noNeed + 1);
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11872
using System;
using System.Collections.Generic;
using System.Linq;

public class Solution
{
    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var N = vals[0];
        var M = vals[1];
        var H = new long[1].Concat(Console.ReadLine().Split(' ').Select(long.Parse)).ToArray();

        var link = Enumerable.Range(0, N + 1).Select(_ => new List<int>()).ToArray();
        for (int i = 0; i < M; i++)
        {
            vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            link[vals[0]].Add(vals[1]);
            link[vals[1]].Add(vals[0]);
        }

        var count = 0;
        for (int i = 1; i <= N; i++)
        {
            if (link[i].Count == 0)
            {
                count++;
            }
            else
            {
                var highest = link[i].Select(v => H[v]).Max();
                if (highest < H[i])
                {
                    count++;
                }
            }
        }

        Console.WriteLine(count);
    }
}

Measured memory_bytes: 56564
#include <algorithm>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  int N; cin >> N;
  vector<int> x(N), y(N), idx(N);
  for (int i = 0; i < N; ++i) {
    cin >> x[i] >> y[i];
    idx[i] = i;
  }

  double sum = 0;
  int count = 0;
  do {
    double length = 0;
    for (int i = 0; i < N-1; ++i) {
      int a = idx[i], b = idx[i+1];
      length += hypot(x[b]-x[a], y[b]-y[a]);
    }
    sum += length;
    ++count;
  } while(next_permutation(idx.begin(), idx.end()));
  printf("%.10f\n", sum/count);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solve(void)
{
 
  int A,B,C;
  cin>>A>>B>>C;
  if(B - A == C - B)
  {
    cout<<"YES"<<endl;
  }
  else
  {
    cout<<"NO"<<endl;
  }
  return; 
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  ll n;
  cin >> n;
  
  vll a(n);
  REP(i, n){
    cin >> a[i];
    a[i] *= -1;
  }
  
  
  ll ans = 0;
  sort(a.begin(), a.end());
  REP(i, n){
    if(i%2==0)
      ans += a[i]*(-1);
    else
      ans -= a[i]*(-1);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
a = list(map(int,input().split()))
balls = {}

for b in a:
    if b in balls:
        balls[b] += 1
    else:
        balls[b] = 1

ballcnts = list(balls.values())
ballcnts.sort()

req_delete = len(ballcnts) - k
if req_delete <= 0: print(0)
else: print(sum(ballcnts[:req_delete]))


Measured memory_bytes: 34804
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
using namespace std;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }


char s[330][330];
ll d[330];
ll ans[330][330];
int main(){
    ll h,w,k;
    cin>>h>>w>>k;
    bool ch;
    rep(i,1,h+1){
        ch=false;
        rep(j,1,w+1){
            cin>>s[i][j];
            if(s[i][j]=='#')ch=true;
        }
        if(ch)d[i]=1;
    }
    ll cnt=1,pos=0,st=0;
    vector<ll> cake;

    rep(i,0,320){
        cake.clear();
        st=i;
        while(d[i]==0&&i<320)i++;
        if(i==320)break;
        rep(x,0,330)if(s[i][x]=='#')cake.pb(x);
        cake.pb(310);
        rep(o,0,cake[1]){
            rep(p,st,i+1)ans[p][o]=cnt;
        }
        cnt++;
        rep(x,1,cake.size()-1){
            rep(o,cake[x],cake[x+1]){
                rep(p,st,i+1){
                    ans[p][o]=cnt;
                }
            }
            cnt++;
        }
    }
    ll res;
    irep(i,330,0)if(d[i]==1){res=i;break;}
    rep(i,res+1,330){
        rep(j,0,330){
            ans[i][j]=ans[res][j];
        }
    }

    rep(i,1,h+1){
        rep(j,1,w+1){
            cout<<ans[i][j]<<" ";
        }
        cout<<endl;
    }
}


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

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

  int t = 1000 - (n % 1000);
  if(n % 1000 == 0){
    cout << 0 << endl;
  }
  else{
    cout << t << endl;
  }
}

Measured memory_bytes: 3608
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define INF (1e9)

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

    int N = S.length();

    ll ans = 0;
    for (int i = 0; i < 1 << (N - 1); i++) {
        ll sum = 0;
        ll x = S[0] - '0';
        for (int j = 0; j < N - 1; j++) {
            if (i & (1 << j)) {
                sum += x;
                x = 0;
            }
            x = x * 10 + S[j + 1] - '0';
        }
        sum += x;
        ans += sum;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
def task(a, b, c, k):
    pluses = min(a, k)
    zeros = min(b, k - pluses)
    minuses = min(c, k - pluses - zeros)

    total = pluses - minuses
    print(total)


a, b, c, k = map(int, input().split())
task(a, b, c, k)


Measured memory_bytes: 9180
import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

void main() {
    int[] ans = new int[4];
    int f(int a, int b, int c) {
        int x = a * a + b * b;
        int y = c * c;
        if (x == y) return 1;
        if (x > y) return 2;
        else return 3;
    }
    while (true) {
        int[] a = readln.chomp.split(" ").map!(to!int).array.sort.array;
        if (a[0] + a[1] <= a[2]) break;
        ans[f(a[0], a[1], a[2])]++;
        ans[0]++;
    }
    ans.map!(to!string).join(" ").writeln;
}

Measured memory_bytes: 1144
from collections import Counter
n,m=map(int,input().split())
d=Counter(list(map(int,input().split())))
for i in range(m):
    b,c=map(int,input().split())
    if c in d.keys():
        d[c]+=b
    else:
        d[c]=b
d=sorted(d.items(),reverse=True)
check=n
ans=0
for i in d:
    if i[1]<check:
        check-=i[1]
        ans+=(i[0]*i[1])
    else:
        ans+=(i[0]*check)
        print(ans)
        break

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

import sys

DEBUG = False

def read(t):
    return t(sys.stdin.readline().rstrip())


def read_list(t, sep = " "):
    return [t(s) for s in sys.stdin.readline().rstrip().split(sep)]


def dprint(*args, **kwargs):
    if DEBUG:
        print(*args, **kwargs)
    return


def main():
    n, k = read_list(int)
    snukes = [0] * n
    for _ in range(k):
        read(int)
        for a in read_list(int):
            snukes[a - 1] += 1
    
    print(len([0 for s in range(n) if snukes[s] == 0]))


if __name__ == "__main__":
    main()


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll))n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF (1LL<<25)     //33554432
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

signed main(void)
{
  int n;
  cin >> n;
  cout << (n*800)-(n/15*200) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
int H,W;
char map[21][21];
int dist[21][21];
using namespace std;

void solve(){
  int nx,ny,sx,sy;
  const int dx[] = {1,0,-1,0};
  const int dy[] = {0,1,0,-1};
  for(int height = 0; height < H; height++){
    for(int width = 0; width < W ; width++){
      dist[height][width] = 0;
      if(map[height][width] == '@'){
        sx = width;
        sy = height;
      }
    }
  }

  dist[sy][sx] = 1;
  for(int d = 1; d < H * W; d++){
    for(int height = 0; height < H; height++){
      for(int width = 0; width < W ; width++){
        if(d == dist[height][width]){
          for(int dir = 0 ; dir < 4; dir++){
            nx = width + dx[dir];
            ny = height + dy[dir];
            if(nx >= 0 && nx < W && ny >= 0 && ny < H &&
               map[ny][nx] != '#' && dist[ny][nx] == 0){

              dist[ny][nx] = dist[height][width] + 1;

            }
          }
        }
      }
    }
  }
  int res = 0;
  for(int height = 0; height < H; height++){
    for(int width = 0; width < W ; width++){
      //cout << dist[height][width] ;
      if(dist[height][width] != 0) res++;
    }
    //cout << endl;
  }
  cout << res << endl;
}

int main(){
  while(true){
    cin >> W >> H ;
    if(W + H == 0) break;
    for(int height = 0; height < H; height++){
      for(int width = 0; width < W ; width++){
        cin >> map[height][width];
      }
    }
    solve();
  }
  return 0;
}



Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,X,Y;
  cin >> N >> X >> Y;
  
  vector<int> ans(N);
  for(int i = 1; i < N; i++){
    for(int j = i+1; j < N+1; j++){
      int a = 0;
      int honest = 0;
      int twist = 0;
      honest = j - i;
      twist = (abs(X - i) + 1 + abs(Y - j));
//      cout << abs(X - i) << " " << abs(Y-j) << endl;
      a = min(honest, twist);
//      cout << a << " ";
      ans.at(a)++;
    }
//    cout << endl;
  }
 
  for(int i = 1; i < N; i++){
    cout << ans.at(i) << endl;
  }

}

Measured memory_bytes: 256
import collections

def main():
    n,m = map(int,input().split())
    g = [[] for _ in range(n+1)]
    for _ in range(m):
        a,b=map(int,input().split())
        g[a].append(b)
        g[b].append(a)

    check = [0]*(n+1)
    ans = [0]*(n+1)
    q = collections.deque()
    q.append(1)
    check[1] = 1

    while len(q) != 0:
        v = q.popleft()
        for u in g[v]:
            #print(u)
            if check[u] == 0:
                check[u] = 1
                ans[u] = v
                q.append(u)

    for i in range(2,n+1):
        if ans[i] == 0:
            print('No')
            return

    print('Yes')
    for i in range(2,n+1):
        print(ans[i])

main()


Measured memory_bytes: 35036
#include <bits/stdc++.h>
using namespace std;
int calc(int y,int m,int d) {
    int uruu=(y-1)/3;
    int days=uruu*200+(y-1-uruu)*195;
    if(y%3) {
        int small=(m-1)/2;
        days+=small*19+(m-1-small)*20;
    }else {
        days+=(m-1)*20;
    }
    days+=d-1;
    return days;
}
int main() {
    int poyo=calc(1000,1,1);
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++) {
        int y,m,d;
        scanf("%d %d %d",&y,&m,&d);
        printf("%d\n",poyo-calc(y,m,d));
    }
}

Measured memory_bytes: 3176
//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <numeric>
#include<bitset>
#include <iomanip>

using namespace std;
#define modd 1000000007


typedef pair<long long, long long> pl;



#define ll long long




/*
class UnionFind {
public:
	vector <ll> par;
	vector <ll> siz;
	vector <ll> gr;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) ,gr(sz_){
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};*/


long long N, M, K, a, b, c, d, e, H, W, L;
long long A[200005] = {};
long long B[5005][5] = {};
long long C[205][205] = {};
long long D[200005] = {};
long long E[200005] = {};
bool f, ff;
string S[2];
set <long long>sll;
pl bufpl;
vector <long long>vl[3];
vector <pl>vpl;
vector <string> vs;
set<ll> llset;

/*struct ST
{
	long long Kati;
	int bangou;

	bool operator<(const ST& another) const
	{
		return Kati < another.Kati;//比較
	};

};



vector <ST> vst;
ST st[200005];
ST bufst;
bitset<5000> bits;*/


long long modinv(long long aa, long long mm) {
	long long bb = mm, uu = 1, vv = 0;
	while (bb) {
		long long tt = aa / bb;
		aa -= tt * bb; swap(aa, bb);
		uu -= tt * vv; swap(uu, vv);
	}
	uu %= mm;
	if (uu < 0) uu += mm;
	return uu;
}


bool fs[2005][2005] = {};

double aa[5005];
double bb = 0;

int main() {


	cin >> N;
	c = N;
	a = 0;
	f = false;

	while (N > 0) {
		a++;
		if (N < 10) {
			b = N;
		}
		else if(N%10!=9){
			f = true;
		}
		N /= 10;
	}

	if (c < 10) {
		cout << c << endl;
	}
	else if (f == true) {
		cout << a * 9 + b - 10 << endl;
	}
	else {
		cout << a * 9 + b - 9 << endl;
	}

	return 0;

}


Measured memory_bytes: 2304
n = gets.to_i

edges = []
g = Array.new(n+1){ [] }
(n-1).times do |i|
  a, b = gets.split.map(&:to_i)
  a, b = b, a if a > b # 辺は頂点 i < j の形で入れる。
  g[a] << b # 隣接リストに
  g[b] << a # 反対向きにも隣接リストに.無向グラフなので
  # gに隣接頂点だけでなく、何番目の辺の情報をいれることもある。
  edges << a+b*100_000 # 辺リストにいれる。辺が識別されてて、最後に辺リストから辺を回して色をとりだす。
end

colors = Hash.new() # Esge => color # 辺についてO(1)で使った色を見れる。O(1)はホントに?
colors_used = Array.new(n+1){Hash.new} # 頂点と色についてO(1)で使ったか確かめられる。
used = Array.new(n){false} # 頂点について探索済みかどうかO(1)でわかる。
que = [1] # 頂点1から見ていくので0が入っている # 探索待ちの未探索の頂点リスト

k = 0 # 答えとなる色の数
while v = que.shift # queにある頂点を取り出す. 破壊的メソッドなので先頭は削除される。なければnilを返す
  k = g[v].size if k < g[v].size  # 隣接する頂点数より色数が小さければ色数を更新
  cur = 1 # 使ってない色がわからないので、とりあず色1から見ていく。
  g[v].each do |w| # vの隣接頂点wを見ていく。
    next if used[w] #trueで、探索済みの頂点なら見ない。
    v<w ? (i,j = v,w) : (i,j = w,v) # i < jの並びで頂点を捉える。
    cur += 1 while colors_used[v][cur] == true # v周りの頂点で色をつかっていれば次の色に更新していく。塗る前に使ってない色にする。
    colors_used[v][cur] = true # vに色を使ったので記録する。
    colors_used[w][cur] = true # wに色を使ったので記録する。
    colors[i+j*100_000] = cur # 辺に使った色をいれる。
    que.push(w) #探索待ちの未探索頂点リストに頂点wを入れる。
  end
  used[v] = true # 頂点vを探索済みにする。
end

puts k
edges.each{ |e| puts colors[e] }

Measured memory_bytes: 48380
/*
 * “The difference between a master and a novice - is that the master has failed more times,
 *  than the novice has tried.”
 */
#include <bits/stdc++.h>
#define pvar(x) clog<<"["<<#x<<":"<<x<<"]\n"
using namespace std;
using ll = long long int;
void solve(){
	int n,x,t;
	cin>>n>>x>>t;
	int cnt = 0;
	while(n > 0){
		n -= x;
		cnt += t;
	}
	cout<<cnt<<endl;
}
int main(){
	ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  t = 1;
  while(t--){
		solve();
	}
}
 


Measured memory_bytes: 3648
#include <iostream>

using namespace std;

int main() {
  int cnt = 0, res = 0;
  for (int i = 0; i < 3; ++i) {
    char c;
    cin >> c;
    if (c == 'R') cnt++;
    else cnt = 0;
    res = max(cnt, res);
  }
  cout << res << endl;
}


Measured memory_bytes: 3520
/*
ID: 
TASK: Ruined Square
LANG: C++                 
*/
#define usingfile1
#include <iostream>
#include <cstdio>
int file_reopen(){
	freopen("square.in","r",stdin);
	freopen("square.out","w",stdout);
}
using namespace std;
struct vct{
	int x,y;
	vct operator + (vct t){
		vct r;
		r.x=x+t.x;
		r.y=y+t.y;
		return r;
	}
	vct operator - (vct t){
		vct r;
		r.x=x-t.x;
		r.y=y-t.y;
		return r;
	}
};
vct a,b,c,d,v1,v2;
void main_program(){
	cin>>a.x>>a.y>>b.x>>b.y;
	v1=b-a;
	v2.x=-v1.y;v2.y=v1.x;
	c=b+v2;
	d=c-v1;
	printf("%d %d %d %d\n",c.x,c.y,d.x,d.y);
}
int main(){
	ios::sync_with_stdio(0);
	#ifdef usingfile
	file_reopen();
	main_program();
	fclose(stdin);fclose(stdout);
	#else
	main_program();
	#endif
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int a[200000]={0},A[200000]={0},N,f=0;
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>A[i];
        a[i]=A[i];
    }
    sort(a,a+N);
    if(a[N-2]==a[N-1]){
        f=1;
    }
    for(int i=0;i<N;i++){
        if(A[i]==a[N-1]){
            if(f==0){
                cout<<a[N-2]<<endl;
                continue;
            }
        }
        cout<<a[N-1]<<endl;
    }
    return 0;
}



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

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

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

struct SegTree {
  ll n;
  vector<ll> v;

  SegTree(int size) {
    n = 1;
    while (n < size) n *= 2;
    v = vector<ll>(2 * n - 1);
  }

  void add(int i, ll x) {
    i += n - 1;
    v[i] += x;
    while (i > 0) {
      i = (i - 1) / 2;
      v[i] = v[2 * i + 1] + v[2 * i + 2];
    }
  }

  ll query(int a, int b, int k, int l, int r) {
    if (b <= l || r <= a) return 0;
    if (a <= l && r <= b) return v[k];
    ll c1 = query(a, b, 2 * k + 1, l, (l + r) / 2);
    ll c2 = query(a, b, 2 * k + 2, (l + r) / 2, r);
    return c1 + c2;
  }

  ll query(int a, int b) { return query(a, b, 0, 0, n); }
};

int main() {
  int n, d, a;
  cin >> n >> d >> a;
  vector<P> w(n);
  rep(i, n) cin >> w[i].first >> w[i].second;

  sort(w.begin(), w.end());
  ll ans = 0;
  ll sum = 0;
  queue<P> q;
  rep(i, n) {
    ll x = w[i].first;
    ll h = w[i].second;
    while (!q.empty() && q.front().first < x) {
      sum -= q.front().second;
      q.pop();
    }
    h -= sum;
    if (h <= 0) continue;
    int cnt = (h + a - 1) / a;
    ans += cnt;

    ll dmg = (ll)a * cnt;
    sum += dmg;
    q.push({x + (ll)2 * d, dmg});
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 7924
// Ho-kago Tea Time

#include <bits/stdc++.h>

using namespace std;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getchar());
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getchar()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

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

const int MAXN = (int) 2e3;

int n;

int a[MAXN + 5];

inline void input()
{
	n = read<int>();
	for(int i = 1; i <= n; ++i) a[i] = read<int>();
}

vector<int> adj[MAXN + 5];

int vis[MAXN + 5], size[MAXN + 5];
vector<int> son[MAXN + 5];
deque<int> s[MAXN + 5];

inline void dfs(int u)
{
	vis[u] = 1;
	size[u] = 1;
	for(auto v : adj[u]) if(!vis[v])
	{
		son[u].push_back(v);
		dfs(v);
		size[u] += size[v];
	}

	s[u].push_back(a[u]);
	for(int i = 2; i <= size[u]; ++i)
	{
		int t = -1;
		for(auto j : son[u]) if(!s[j].empty() && (t == -1 || s[j].front() > s[t].front())) t = j;
		s[u].push_back(s[t].front()), s[t].pop_front();
	}
}

inline void solve()
{
	for(int i = 1; i <= n; ++i) adj[0].push_back(i);
	for(int i = 1; i <= n; ++i)
		for(int j = i + 1; j <= n; ++j) if(__gcd(a[i], a[j]) > 1)
		{
			adj[i].push_back(j);
			adj[j].push_back(i);
		}
	for(int i = 0; i <= n; ++i) sort(ALL(adj[i]), [&](int x, int y) { return a[x] < a[y]; });

	dfs(0), s[0].pop_front();
	for(auto i : s[0]) printf("%d ", i);
	puts("");
}

int main()
{
#ifdef K_ON // K-ON!
	freopen("E.in", "r", stdin);
	freopen("E.out", "w", stdout);
#endif

	input();
	solve();

	return 0;
}



Measured memory_bytes: 19072
def solve(pos, a):
    for l in a:
        if l[pos-1]:
            pos -= 1
        elif l[pos]:
            pos += 1
    return pos

while True:
    n = int(input())
    if not n:
        break
    m, atari, d = (int(input()) for _ in [0]*3)
    a = [[0]+list(map(int, input()))+[0] for _ in [0]*d]
    if solve(m, a) == atari:
        print(0)
        continue
    for i, (l, (j, current), r) in ((i, _) for i, l in enumerate(a) for _ in zip(l, enumerate(l[1:], start=1), l[2:])):
        if not (l | current | r):
            a[i][j] = 1
            if solve(m, a) == atari:
                print(i+1, j)
                break
            a[i][j] = 0
    else:
        print(1)


Measured memory_bytes: 5612
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const double PI = 3.1415926535897932;
const int MOD = 1e9 + 7;

//cin.tie(0);ios::sync_with_stdio(false);
int main() {
  int n, m;
  cin >> n >> m;
  cout << (100 * (n - m) + 1900 * m) * pow(2, m) << endl;
  
  return 0;
}


Measured memory_bytes: 4056
chomp($s=<>);
($k,$s) = split/ /,$s;

for($x=0;$x<=$k;$x++){
	for($y=0;$y<=$k;$y++){
    	$z=$s-$x-$y;
        if($z >= 0 && $z <= $k){
        	$cnt++;
        }
    }
}
print $cnt;

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define X real()
#define Y imag()
#define value(x,y,w,h) (x >= 0 && x < w && y >= 0 && y < h)
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using comd = complex<double>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 10000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

int N,W,H,S;
vector<vector<int>> maps;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  char c;
  int n = 0;
  cin >> W >> H >> N;
  char area[H][W];
  maps = vector<vector<int>>(H,vector<int>(W,-1));
  pii pos;
  rep(i,W){
    rep(j,H){
      cin >> c ;
      area[j][i] = c;
      if(c == 'S'){
        pos = make_pair(j,i);
        ++n;
      }
    }
  }
  queue<pii> q;
  q.push(pos);
  maps[pos.fi][pos.se] = 0;
  n = 1;
  int ans = 0;
  for(n = 1; n < N+1;++n){
    maps = vector<vector<int>>(H,vector<int>(W,-1));
    q = queue<pii>();
    q.push(pos);
    maps[pos.fi][pos.se] = 0;
    while(!q.empty()){
      pii p = q.front();q.pop();
      rep(i,4){
        int x = p.fi + dx[i],y = p.se+dy[i];
        if(value(x,y,H,W)){
          if(area[x][y] - '0' == n){
            ans += maps[p.fi][p.se] + 1;
            pos = make_pair(x,y);
            q = queue<pii>();
            break;
          }
          else if(area[x][y] != 'X' && ( maps[x][y] == -1)){
            q.push(make_pair(x,y));
            maps[x][y] = maps[p.fi][p.se] +1 ;
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
    int K, A, B;
    cin >> K >> A >> B;
    int x = A / K;
    int y = K * x;
    int z = K * (x + 1);

    if (y >= A or z <= B) cout << "OK" << endl;
    else cout << "NG" << endl;
    return 0;
}

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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define sz(x) ((int) x.size())
#define all(x) (x).begin(), (x).end()
#define re return
#define mp make_pair
#define makeunique(x) sort(all(x)), x.resize(unique(all(x)) - x.begin())
#define endl '\n'

typedef pair<int, int> ii;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<string> vs;

template <class T> T abs (T x) { re x > 0 ? x : -x; }
template <class T> T sqr (T x) { re x * x; }

const double pi = acos(-1.);
const ll inf = 1e18 + 7;
const int N = 3e5 + 17;

int n, m;
ll x[N];
ll dp[N][2];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int a, b;
	cin >> n >> a >> b;
	for (int i = 0; i < n; i++) cin >> x[i];
	dp[0][1] = inf;

	set<ll> cur;
	for (int i = 1; i < n; i++) {
		if (i > 1)		
			cur.insert(dp[i - 2][0] - a * x[i - 1]);		
		dp[i][0] = min(dp[i - 1][0] + a * (x[i] - x[i - 1]), min(dp[i - 1][0], dp[i - 1][1]) + b);		
		if (sz(cur))
			dp[i][1] = a * x[i] + b + *cur.begin();
		else dp[i][1] = inf;
//		cout << i + 1 << " " << dp[i][0] << " " << dp[i][1] << endl;
	}

	cout << min(dp[n - 1][0], dp[n - 1][1]);
}

Measured memory_bytes: 10660
n = int(input())


def dfs(s):
    if int(s) > n:
        return 0
    for i in '753':
        if s.count(i) == 0:
            res = 0
            break
    else:
        res = 1
    for i in '753':
        res += dfs(s + i)

    return res


print(dfs('0'))


Measured memory_bytes: 2940
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Main {
	public static void main(String[] args) {
		// code to read values
		// code to call required method
		// code to display the result
		// System.out.println(Math.ceil(2.5));
		Scanner sc = new Scanner(System.in);
		String letter = sc.next();
		if(letter.equals(letter.toUpperCase())){
			System.out.println("A");
		}else{
			System.out.println("a");
		}
	}
}

Measured memory_bytes: 26904
def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end  
def copy(a) Marshal.load(Marshal.dump(a)) end
def kaizyo(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end
def na(n,d=0) Array.new(n,d)end
def na2(m,n,d=0) Array.new(n){Array.new(m,d)}end
def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def bit(n) n.to_s(2).split("").map(&:to_i) end
def inp() a=gets.chomp.split(" ").map(&:to_i)end
n = inp[0]
a = inp
c = 1
j = 0
mae = a[0]
a.delete_at(0)
a.each do |d| 
  if(j == 0)
    if(d > mae)
      j = 1
    elsif(d < mae)
      j = 2
    end
  elsif(j == 1)
    if(d < mae)
      c += 1
      j = 0
    end
  else
    if(d > mae)
      c += 1
      j = 0
    end
  end
  mae = d
end
p c


Measured memory_bytes: 11540
package main

import (
	"fmt"
)

func main() {
	var a, b, c int
	var flag bool
	fmt.Scanf("%d %d %d", &a, &b, &c)
	if a == b && a != c {
		flag = true
	}
	if b == c && b != a {
		flag = true
	}
	if c == a && c != b {
		flag = true
	}

	if flag {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

using ll = long long;
#define debug(x) cerr << #x << ": " << x << endl;
#define line() cerr << "---------------" << endl;

int main() {
   ll N, H;
   cin >> N >> H;
   vector<ll> b(N);
   ll Max = -1;

   for (ll i = 0; i < N; i++) {
      ll a;
      cin >> a >> b[i];
      Max = max(Max, a);
   }
   sort(b.begin(), b.end(), greater<int>());

   int cnt = 0;
   for (ll x : b) {
      if (x > Max) {
         H -= x;
         cnt++;
      } else {
         break;
      }
      if (H <= 0) {
         break;
      }
   }
   
   if (H > 0) {
      // cnt += H / Max;
      cnt += H%Max ? H/Max+1 : H/Max;
   }
   cout << cnt << endl;

   return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <unordered_map>
#include <stack>
#include <queue>
#include <map>

using namespace std;

long long MOD = 1e9 + 7;

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

    double n;
    cin >> n;

    map<int, int> a;
    int res = 0;
    for (int i = 1; i <= n; i++)
    {
        int t;
        cin >> t;
        a.insert(std::make_pair(t, i));
    }

    for (auto&& e : a) {
        cout << e.second << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 5504
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <utility>
#define maxn 100005
using namespace std;
typedef long long ll;

inline int getint(){
  char c; int res = 0, sig = 1;
  for(c = getchar();c < '0' || c > '9';c = getchar()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = getchar()) res = res * 10 + (c - '0');
  return res * sig;
}
int n,a[maxn],sum;

int main(){
  n = getint();
  for(int i = 1;i <= n;i++){
    a[i] = getint();
    sum += abs(a[i]);
  }
  sort(a + 1,a + n + 1);
  int st = lower_bound(a + 1,a + n + 1,0) - a;
  if(st == 1){
    printf("%d\n",sum - 2 * a[1]);
    swap(a[1],a[2]);
    int res = a[2];
    for(int i = 3;i <= n;i++){
      printf("%d %d\n",res,a[i]);
      res -= a[i];
    }
    printf("%d %d\n",a[1],res);
  }else if(st == n + 1){
    printf("%d\n",sum + 2 * a[n]);
    int res = a[n];
    for(int i = n - 1;i >= 1;i--){
      printf("%d %d\n",res,a[i]);
      res -= a[i];
    }
  }else{
    printf("%d\n",sum);
    swap(a[st],a[1]);
    int res1 = a[1], res2 = a[st];
    for(int i = 2;i < st;i++){
      printf("%d %d\n",res1,a[i]);
      res1 -= a[i];
    }
    for(int i = st + 1;i <= n;i++){
      printf("%d %d\n",res2,a[i]);
      res2 -= a[i];
    }
    printf("%d %d\n",res1,res2);
  }
  return 0;
}


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

int main()
{
  string s, t;
  while (cin >> s >> t) {
    short int ans = 0;
    vector<vector<short int> > dp(s.size()+1, vector<short int>(t.size()+1, 0));
    for (unsigned int i = 0; i < s.size(); ++i) {
      for (unsigned int j = 0; j < t.size(); ++j) {
	if (s[i] == t[j]) {
	  dp[i+1][j+1] = dp[i][j]+1;
	  ans = max(ans, dp[i+1][j+1]);
	}
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 31000
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <iostream>
using namespace std;

bool judge(const int w[], int n, int k, int p);

int main(void)
{
	int n, k;
	cin >> n >> k;

	int w[100000], sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> w[i];
		sum += w[i];
	}
	int p = sum / k;

	while (!judge(w, n, k, p)) p++;

	cout << p << endl;

	return 0;
}

bool judge(const int w[], int n, int k, int p)
{
	int t[100000] = { 0 };
	int j = 0;
	for (int i = 0; i < n; i++) {
		while (p - t[j] < w[i]) j++;
		if (j >= k) return false;
		t[j] += w[i];
	}
	return true;
}

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

using namespace std;
typedef long long LL;
using Graph = vector<vector<LL>>;
static LL INF = (1LL<<62);
using LLPair = pair<LL, LL>;

void WarshallFloyd(LL N, Graph &G, vector<vector<LL>> &D){
	D.assign(N, vector<LL>(N, INF));
	for(int i=0; i<N; i++){
		for(int j=0; j<N; j++){ D[i][j] = G[i][j]; }
	}

	for(int k=0; k<N; k++){
		for(int i=0; i<N; i++){
			for(int j=0; j<N; j++){
				if(D[i][k] != INF && D[k][j] != INF){
					D[i][j] = min(D[i][j], D[i][k]+D[k][j]);
				}
			}
		}
	}
	return;
}

LL canReduce(int i, int j, vector<vector<LL>> &v){
	LL ret = 0;
	if(v[i][j] == 0) return 0;
	for(int k=0; k<v.size(); k++){
		if(k == i || k == j) continue;
		if(v[i][k] == 0 || v[k][j] == 0) continue;
		if(v[i][j] == v[i][k] + v[k][j]){
			ret = v[i][j];
			v[i][j] = 0;
			return ret;
		}
	}
	return ret;
}

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

	cin >> N;

	Graph G;
	G.assign(N, vector<LL>(N, INF));

	for(int i=0; i<N; i++){
		for(int j=0; j<N; j++){
			LL c; cin >> c;
			G[i][j] = min(G[i][j], c);
			G[j][i] = min(G[j][i], c);
		}
	}
	
	vector<vector<LL>> D;
	WarshallFloyd(N, G, D);

	LL ans = 0;
	for(int i=0; i<N; i++){
		for(int j=i+1; j<N; j++){
			ans += D[i][j];
			if(G[i][j] != D[i][j]){
				printf("-1\n");
				return 0;
			}
		}
	}

	vector<tuple<LL, int ,int>> T;
	for(int i=0; i<N; i++){
		for(int j=i+1; j<N; j++){
			T.push_back(tie(D[i][j], i, j));
		}
	}
	sort(T.begin(), T.end(), std::greater<tuple<LL, int, int>>());
	while(true){
		LL pans = ans;
		for(int k=0; k<T.size(); k++){
			LL  d = get<0>(T[k]);
			int i = get<1>(T[k]);
			int j = get<2>(T[k]);
			LL red = canReduce(i, j, D);
			pans -= red;
		}
		if(pans == ans) break;
		ans = pans;
	}
	printf("%lld\n", ans);
	return 0;
}



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

int calcCount(int n,int cnt){
  if(n<=5){
    return cnt+n;
  }else{
    int six = 999999;
    int nine = 999999;
    if(n>=46656){
      six=calcCount(n-46656,cnt+1);
    }else if(n>=7776){
      six=calcCount(n-7776,cnt+1);
    }else if(n>=1296){
      six=calcCount(n-1296,cnt+1);
    }else if(n>=216){
      six=calcCount(n-216,cnt+1);
    }else if(n>=36){
      six=calcCount(n-36,cnt+1);
    }else if(n>=6){
      six=calcCount(n-6,cnt+1);
    }
    if(n>=59049){
      nine = calcCount(n-59049,cnt+1);
    }else if(n>=6561) nine = calcCount(n-6561,cnt+1);
    else if(n>=729)nine = calcCount(n-729,cnt+1);
    else if(n>=81)nine = calcCount(n-81,cnt+1);
    else if(n>=9)nine = calcCount(n-9,cnt+1);

    return min(six,nine);
    
  }
}



int main(){
  int n;
  cin >> n;
  cout << calcCount(n,0);
}

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

using namespace std;

#define vit vector<int>::iterator
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fr first
#define sc second
#define skip continue
#define PI 3.14159265

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned int ui;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;

const int INF = 1e9 + 5;
const int MAXN = 3e6 + 123;

void faster(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

bool cmp(const string& a, const string& b) {
	return (a + b) < (b + a);
}

vector<int> Reversed(const vector<int>& s){
   vector<int> d = s;
   reverse(all(d));
   return d;
}

void solve(){
    int a,b,c;
    cin >> a >> b >> c;
    set<int> ms;
    ms.insert(a);
    ms.insert(b);
    ms.insert(c);
    cout << ms.size();
}
int main(){
    //freopen("lepus.in","r",stdin);
   // freopen("lepus.out","w",stdout);
    //faster();
    int n=1;
    //cin>>n;
    while(n--){
        solve();
        //cout << endl;
    }
    //fclose(stdout);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=800005;
vector<int> bel[N];
int cur[N],from[N],S,T,ne[N],a[N],b[N],dis[N],flag[N],x,y,n,m,fi[N],tot,zz[N],sl[N];
queue<int>Q;
void jb(int x,int y,int z){
	ne[++tot]=fi[x];
	fi[x]=tot;
	zz[tot]=y;
	sl[tot]=z;
	ne[++tot]=fi[y];
	fi[y]=tot;
	zz[tot]=x;
	sl[tot]=0;
}
int bfs(){
	Q.push(S);
	memset(dis,-1,sizeof dis);
	dis[S]=0;
	while (!Q.empty()){
		int now=Q.front();Q.pop();
		for (int i=fi[now];i;i=ne[i])
			if (sl[i]&&dis[zz[i]]==-1){
				dis[zz[i]]=dis[now]+1;
				Q.push(zz[i]);
			}
	}
	return dis[T]!=-1;
}
int dfs(int x,int y){
	if (x==T)return y;
	int s=0,b;
	for (int &i=cur[x];i;i=ne[i])
		if (sl[i]&&dis[zz[i]]==dis[x]+1&&(b=min(sl[i],dfs(zz[i],min(sl[i],y))))){
			sl[i]-=b;
			sl[i^1]+=b;
			y-=b;
			s+=b;
			if (!y)return s;
		}
	return s;
}
int main(){
	scanf("%d",&n);
	S=0;T=2*n;
	tot=1;
	for (int i=1;i<n;i++){
		scanf("%d",&x);
		jb(S,i+n,1);
		while (x--){
			scanf("%d",&y);
			jb(i+n,y,1);
			bel[y].push_back(i);
		}
	}
	for (int i=1;i<=n;i++)jb(i,T,1);
	int ans=0;
	while (bfs()){
		for (int i=S;i<=T;i++)cur[i]=fi[i];
		ans+=dfs(S,1e9);
	}
	if (ans!=n-1){
		puts("-1");
		return 0;
	}
	for (int i=1;i<n;i++)
		for (int j=fi[i+n];j;j=ne[j])
			if (zz[j]&&!sl[j]){
				flag[zz[j]]=1;
				b[i]=zz[j];
			}
	for (int i=1;i<=n;i++)
		if (!flag[i])Q.push(i);
	ans=0;
	memset(flag,0,sizeof flag);
	while (!Q.empty()){
		int now=Q.front();Q.pop();
		ans++;
		for (int i=0;i<bel[now].size();i++)
			if (!flag[bel[now][i]]){
				flag[bel[now][i]]=1;
				a[bel[now][i]]=now;
				Q.push(b[bel[now][i]]);
			}
	}
	if (ans!=n){
		puts("-1");
		return 0;
	}
	for (int i=1;i<n;i++)printf("%d %d\n",a[i],b[i]);
}


Measured memory_bytes: 53248
#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)

using namespace std;

typedef pair<int, int> P;

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

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

    int one = 0;
    char next;
    rep(i, (int)s.length()){
        if(s[i] != '1'){
            next = s[i];
            break;
        }
        one++;
    }

    if(k <= one){
        cout << 1 << endl;
    }else{
        cout << next << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
using namespace std;

int main(){
	int n, t, a, h, index = 0;
	double temp, dif = 1000;
	cin >> n >> t >> a;
	for (int i = 1; i <= n; ++i) {
		cin >> h;
		temp = abs(a - (t - h * 0.006));
		if (temp < dif) {
			dif = temp;
			index = i;
		}
	}
	cout << index << endl;
}

Measured memory_bytes: 256
from collections import Counter

n = int(input())
a_list = list(map(int, input().split(" ")))
c = Counter(a_list)

ans = 0
for k in c.keys():
    tmp = c[k]
    if k + 1 in c.keys():
        tmp += c[k + 1]
    if k - 1 in c.keys():
        tmp += c[k - 1]
    ans = max(ans, tmp)
print(ans)

Measured memory_bytes: 14564
N, D = map(int, input().split())
X = [0]*N
Y = [0]*N
for i in range(N):
  X[i], Y[i] = map(int, input().split())

ans = 0
for i in range(N):
  if X[i]**2+Y[i]**2<=D**2:
    ans += 1
print(ans)


Measured memory_bytes: 24628
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int mod =  998244353;
int main() {
	ll n;
	cin>>n;
	ll cnt = n-1;
	for(auto i =2;i<n;i++){
	    ll num =  n/i;
	    if(num*i == n){
	        num--;
	    }
	    cnt += num;
	}
	cout<<cnt;
	return 0;
}


Measured memory_bytes: 3632
H,W=map(int,input().split())
dp=[[0 for i in range(W)] for k in range(H)]
ALL=[]
for i in range(H):
  S=input()
  ALL+=[S]
  for k in range(W):
    if i==0 and k==0:
      if S[k]=="#":
        dp[i][k]=1
      else:
        dp[i][k]=0
    elif i==0:
      if S[k]=="#" and S[k-1]=="#":
        dp[i][k]=dp[i][k-1]
      elif S[k]=="." and S[k-1]==".":
        dp[i][k]=dp[i][k-1]
      elif S[k]=="." and S[k-1]=="#":
        dp[i][k]=dp[i][k-1]
      else:
        dp[i][k]=dp[i][k-1]+1
    elif k==0:
      if S[k]=="#" and ALL[i-1][k]=="#":
        dp[i][k]=dp[i-1][k]
      elif S[k]=="." and ALL[i-1][k]==".":
        dp[i][k]=dp[i-1][k]
      elif S[k]=="." and ALL[i-1][k]=="#":  
        dp[i][k]=dp[i-1][k]
      else:
        dp[i][k]=dp[i-1][k]+1
    else:
      if S[k]=="#":
        if S[k-1]=="#" and ALL[i-1][k]=="#":
          dp[i][k]=min(dp[i][k-1],dp[i-1][k])
        elif S[k-1]=="#" and ALL[i-1][k]==".":
          dp[i][k]=min(dp[i][k-1],dp[i-1][k]+1)
        elif S[k-1]=="." and ALL[i-1][k]=="#":
          dp[i][k]=min(dp[i][k-1]+1,dp[i-1][k])
        else:
          dp[i][k]=min(dp[i][k-1],dp[i-1][k])+1
      else:
        dp[i][k]=min(dp[i][k-1],dp[i-1][k])        
ans=dp[H-1][W-1]
print(ans)

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

int main()
{
	int a, b;
	char op;
	while (1){
		cin >> a >> op >> b;
		if (op == '?') {
			break;
		}
		if (op == '+') {
			cout << a + b << endl;
		}
		else if (op == '*') {
			cout << a * b << endl;
		}
		else if (op == '-') {
			cout << a - b << endl;
		}
		else if (op == '/') {
			cout << setprecision (10) << a / b << endl;
		}
	}
}


Measured memory_bytes: 3104