akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(void){
	int a,i,z,iti,ni,san;
	iti=0;
	ni=0;
	san=0;
	for(z=1;z<=10;z++){
		scanf("%d",&a);
		if(iti<=a){
			san=ni;
			ni=iti;
			iti=a;
			goto a;
		}
		if(ni<=a){
			san=ni;
			ni=a;
			goto a;
		}
		if(san<=a){
			san=a;
			goto a;
		}
		a:;
	}
	printf("%d\n",iti);
	printf("%d\n",ni);
	printf("%d\n",san);
	return 0;
}


Measured memory_bytes: 2040
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

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

    cout << (a + b + 1) / 2 << endl;

    return 0;
}

Measured memory_bytes: 256
function myout(text){console.log(text);}//standard output
function Main(input) {
	//input = parseInt(input);
	//input = input.trim().split(" ");
	input = input.trim().split("\n");
	//input = input.trim().split(" ").map((a)=>Number(a));
	//input = input.trim().split("\n").map((a)=>Number(a));
  var N = parseInt(input[0].split(" ")[0]);
  var M = parseInt(input[0].split(" ")[1]);
  input.shift();
  var ngList = input.map((a)=>Number(a));
  var list = new Array(N+1);
  for(var i = 0; i < M; i++){
    list[ngList[i]] = 0;
  }
  list[N] = 1;
  for(var i = N - 1; i >= 0; i--){
    if(list[i] == 0){
       continue;
    }else if(i == N - 1){
       list[i] = 1;
      continue;
    }
    
    var mae = list[i+2];
    var ato = list[i+1];
    if(mae != 0 || ato != 0){
     	list[i] = (mae + ato) % 1000000007;
    }else{
        myout("0");
        return;
    }
  }
  myout(list[0]);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


Measured memory_bytes: 16844
#include <iostream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <cmath>
#include <climits>
using namespace std;

#define rep(i,end)          rep2(i,0,(end))
#define rep2(i,beg,end)   for (int i=(beg);i<(end);i++)
#define all(cont)           begin(cont), end(cont)
#define inf                   LLONG_MAX
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef list<ll> li;
typedef pair<ll, ll> pii;
typedef pair<ll, string> pis;
typedef pair<string, ll> psi;

string gets(bool skipnewline);
vi get_n_array(int n);

ll f(ll n)
{
    if (n == 0) return 0;
    ll s = 1;
    rep2(i, 2, n + 1)
    {
        s += i;
    }
    return s;
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, d;
    cin >> n >> d;
    typedef vector<vi> vv;
    vv v;
    rep(i, n)
    {
        v.push_back(get_n_array(d));
    }
    ll cnt = 0;
    rep(i, n - 1)
    {
        rep2(j, i + 1, n)
        {
            double sum = 0;
            rep(k, d)
            {
                double x = v[i][k] - v[j][k];
                sum += x*x;
            }
            double t = sqrt(sum);
            if (t == floor(t)) {
                cnt++;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

string gets(bool skipToNextline)
{
    if (skipToNextline) gets(false);
    const int BUFF_MAX = 1024;
    char buf[BUFF_MAX];
    cin.getline(buf, sizeof(buf));
    return buf;
}

vi get_n_array(int n)
{
    vi v;
    while (n-- > 0) {
        int x;
        cin >> x;
        v.push_back(x);
    }
    return v;
}

Measured memory_bytes: 256
from collections import deque
def tree(edges, n, q):
    distance = [0]*(n+1)
    visited = [0]*(n+1)
    for _ in range(0, q):
        p, x = map(int, input().split())
        distance[p] += x
    Q = deque([])
    Q.append(1)
    visited[1] = 1
    while Q:
        xx = Q.popleft()
        for i in range(0, len(edges[xx])):
            if visited[edges[xx][i]]:
                continue
            distance[edges[xx][i]] += distance[xx]
            Q.append(edges[xx][i])
            visited[edges[xx][i]] = 1
    return distance[1:]
def addEdge(edges, u, v):
    edges[u].append(v)
    edges[v].append(u)
n, q = map(int, input().split())
edges = [[] for i in range(n + 1)]
for _ in range(0, n - 1):
    u, v = map(int, input().split())
    addEdge(edges, u, v)
print(*tree(edges, n, q))

Measured memory_bytes: 53032
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
#include <climits>
#include <complex>
#include <numeric>
using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RREP(i,n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();++i)
#define ALL(c) (c).begin(), (c).end()

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

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

int gdp[2010][2010];
int n, k;
int ans = INF;

void gdfs(int p, int v, vector<vi> &g){
  FOR(e, g[v]){
    if((*e) == p) continue;
    gdfs(v, (*e), g);
  }
  gdp[v][0] = 1;
  REP(i, n){
    if(!i){
      FOR(e, g[v]){
        if((*e) == p) continue;
        gdp[v][0] += gdp[(*e)][0];
      }
    }
    else if(i - 1 <= k / 2){
      FOR(e, g[v]){
        if((*e) == p) continue;
        gdp[v][i] += gdp[(*e)][i-1];
      }
    } else {
      int l = 0;
      FOR(e, g[v]){
        if((*e) == p) continue;
        gdp[v][i] += gdp[(*e)][max(0, (k-(i-1)))];
        l = min(l, gdp[(*e)][i-1] - gdp[(*e)][max(0, (k-(i-1)))]);
      }
      gdp[v][i] += l;
    }
  }
  // min_cost
  int m = g[v].size();
  for(int x = 0; x <= (k / 2); x++){
    int cost = n - gdp[v][0];
    FOR(e, g[v]){
      if((*e) == p) continue;
      cost += gdp[(*e)][x];
    }
    int y = k - x;
    //cout << "cost" << v << " " << x << " " << cost << endl;
    FOR(e, g[v]){
      if((*e) == p) continue;
      cost -= gdp[(*e)][x];
      //check
      int ncost = cost + gdp[(*e)][y];
      ans = min(ans, ncost);
      //cout << "¥tupdate" << (*e) << " " << ncost << endl;

      cost += gdp[(*e)][x];
    }
  }
}

int main(void){
  cin >> n >> k;
  vector<vi> g(n);
  REP(i, n-1){
    int a, b;
    cin >> a >> b;
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  gdfs(-1, 0, g);
  cout << ans << endl;
/*
  cout << endl << endl;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      cout << gdp[i][j] << " ";
    }
    cout << endl;
  }
  cout << endl;
  */
}


Measured memory_bytes: 16256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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;}

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  int N; cin >> N;
  vector<int> v(N);
  rep(i, N) cin >> v[i];
  vector<int> c(N);
  rep(i, N) cin >> c[i];

  int ans = 0;
  rep(i, N){
    if (v[i] > c[i]) ans += v[i] - c[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
N,X = map(int,input().split(' '))
L = list(map(int,input().split(' ')))

def algGCF(a,b):
  if a % b == 0:
    return b
  else:
    return algGCF(b,a%b)
GCF = abs(X-L[0])
for i in range(1,N):
  GCF = algGCF(GCF,abs(X-L[i]))
print(GCF)  
  
  

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

int main (void) {
  int H, W;
  cin >> H >> W;
  long long ans = 0;
  if (W == 1 || H == 1) {cout << 1 << endl; return 0;}
  for (int h = 0; h < H; h++) {
    if (W % 2 == 0) ans += W/2;
    else if (h % 2 == 0) ans += W/2+1;
    else ans += W/2;
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        ArrayList<War> li = new ArrayList<>();
        for(int i = 0; i < m; i++){
            int a = sc.nextInt();
            int b = sc.nextInt();
            li.add(new War(a,b));
        }
        Collections.sort(li);
        int ans = 0;
        int right = -Integer.MAX_VALUE;
        for(War a : li){
            if(right <= a.l){
                ans++;
                right = a.r;
            }else if(right > a.r){
                right = a.r;
            }
        }
        System.out.println(ans);
    }
}

class War implements Comparable<War>{
    int l,r;
    public War(int l, int r){
        this.l = l;
        this.r = r;
    }
    
    public int compareTo(War a){
        if(this.l < a.l){
            return -1;
        }else if(this.l > a.l){
            return 1;
        }else{
            if(this.r < a.r){
                return -1;
            }else if(this.r > a.r){
                return 1;
            }else{
                return 0;
            }
        }
    }
}
class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }
    
    public void close() throws Exception{
        this.reader.close();
        return;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}

Measured memory_bytes: 45012
#include <iostream>
using namespace std;
int main(){
    long n,k,q;
    cin >> n >> k >> q;
    long ans[n];
    fill_n(ans,n,0);
    int a;
    for(int i = 0;i<q;i++){
        cin >> a;
        ans[a-1]++;
    }
    for(int i = 0;i<n;i++){
        if(q-ans[i]>=k) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define LL long long
#define pii pair<int,int>
#define pll pair<LL,LL>
#define ALL(V) V.begin(),V.end()
#define f1(a,b) for(int a=1;a<=b;a++)
#define f0(a,b) for(int a=0;a<b;a++)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
#define de(x) cout<<#x<<": "<<x<<endl
using namespace std;
const LL N=1e6+69, base=1024*1024,mod=1e9+7;
int32_t main(void) {
    boost;
    int a;
    cin>>a;
    if(a<1200) cout<<"ABC";
    else if(a<2800) cout<<"ARC";
    else cout<<"AGC";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fort(i,n) for (int i = 1; i <= n; i++)
#define ll long long
#define pi pair<int,int>
#define sz size()
#define er erase
#define fr first
#define sc second
using namespace std;

string s;

int32_t main()
{
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> s;
    fort(i,3)
    {
        if (s[i-1]=='1') s[i-1]='9';
        else s[i-1]='1';
    }
    cout << s;
}


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

#define INF 100
#define TRUE 1
#define FALSE 0

void Show(int N, int* m)
{
	for (int r = 0; r < N; r++)
	{
		for (int c = 0; c < N; c++)
		{
			printf("%4d", m[r * N + c]);
		}
		printf("\n");
	}
}

int Set(int p, int v, int *m, int * t)
{
	if (m[p] < v)
	{
		return FALSE;
	}
	else
	{
		t[m[p]]--;
		m[p] = v;
		t[m[p]]++;
		return TRUE;
	}
}

void calc(int N, int X, int Y)
{
	int* m = (int*)malloc(sizeof(int) * N * N);
	int* t = (int*)malloc(sizeof(int) * N);
	memset(t, 0, sizeof(int) * N);

	for (int r = 0; r < N * N; r++) m[r] = 0;
	for (int r = 0; r < N - 1; r++)
	{
		for (int c = r+1; c < N; c++)
		{
			m[r * N + c] = c - r;
			m[c * N + r] = m[r * N + c];
			t[m[r * N + c]]++;
		}
	}

	//Show(N, m);
	for (int r = 0; r < N; r++)
	{
		if (FALSE ==Set(r * N + Y, m[r * N+X]+1, m, t))
		{
			continue;
		}
		for (int c = Y + 1; c < N; c++)
		{
			if (FALSE ==Set(r * N + c, m[r * N + (c - 1)]+1, m, t))
			{
				break;
			}
		}
		for (int c = Y - 1; c > X; c--)
		{
			if (FALSE ==Set(r * N + c, m[r * N + (c + 1)]+1, m, t))
			{
				break;
			}
		}
	}
	//Show(N, m);

	for (int i = 1; i < N; i++)
	{
		printf("%d\n", t[i]);
	}

	if (m != NULL)   free(m);
	if (t != NULL)   free(t);
}

int main(void) {
	int i, n;
	char buf[1000];
	int N, X, Y;
	gets(buf, sizeof(buf));
	sscanf(buf, "%d %d %d\n", &N, &X, &Y);
	calc(N, X-1, Y-1);
	return 0;
}


Measured memory_bytes: 15744
n,d=map(int,input().split())
x=[list(map(int,input().split())) for _ in range(n)]
c=0
for i in range(n-1):
    for j in range(i+1,n):
        c += (sum((a-b)**2 for a,b in zip(x[i],x[j]))**0.5).is_integer()

print(c)

Measured memory_bytes: 3060
import java.util.*;
import java.lang.*;
import java.io.*;
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
	int a, b;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        String[] str1Ary = str.split(" ");
        a = Integer.parseInt(str1Ary[0]);
        b = Integer.parseInt(str1Ary[1]);
        System.out.print(a * b + " ");
        System.out.println((a + b) * 2);
	}
}

Measured memory_bytes: 24132
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
using namespace std;

int main() {
	int r, g, b;
	cin >> r >> g >> b;
	int n;
	n = r * 100 + g * 10 + b;
	if (n % 4 == 0)
		cout << "YES";
	else
		cout << "NO";
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

ll dp[3010][3010];

int main(){
  int n; cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  for(int len=1;len<=n;len++){
    for(int i=0;i+len<=n;i++){
      int j=i+len;
      if((n-len)%2==0) dp[i][j]=max(a[i]+dp[i+1][j],dp[i][j-1]+a[j-1]);
      else dp[i][j]=min(-a[i]+dp[i+1][j],dp[i][j-1]-a[j-1]);
    }
  }
  cout << dp[0][n] << endl;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

void ABC153A()
{
	int H, A;
	cin >> H >> A;
	int x = H / A;
	if (H % A != 0)
		++x;
	cout << x << endl;
}

int main()
{
	ABC153A();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N ;
  cin >> N;
  
  long long int L0 = 2;
  long long int L1 = 1;
  long long int L = 1;
  for(int i = 2; i < N + 1; i++){
    L = L1 + L0;
    L0 = L1;
    L1 = L;
  }
  
  cout << L << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

ll keta_sum(ll a){
    ll ret = 0;
    while(a > 0){
        ret += a%10;
        a /= 10;
    }
    return ret;
}

int main(){
    ll N;
    cin >> N;
    if(N % keta_sum(N) == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
s=input()
wr=s.count("W")
er=s.count("E")
wl=0
el=0
cur=None
ans=len(s)
for i in range(n):
  if cur=="W":
    wl+=1
  elif cur=="E":
    el+=1
  cur=s[i]
  if cur=="W":
    wr-=1
  else:
    er-=1
    
  ans=min(ans,wl+er)
print(ans)


Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a, b;
    cin >> a >> b;

    int ans = -1;
    int temp = -1;

    for(int i = 0; i < 10; i++){
        temp = 10 * b + i;
        int temp2 = temp * 8 / 100;

        if(a == temp2){

            ans = temp;
            break;
            }
    }

    cout << ans << endl;
} 


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int u32;
typedef pair<int, int> p;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int Inf = (1<<30);
ll inf = (1LL<<60);
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main() {
	int n;
	cin >> n;
	int i;
	int a[110000][3];
	for (i = 0; i < n; i++) {
		cin >> a[i][0] >> a[i][1] >> a[i][2];
	}
	int dp[110000][3];
	for (i = 0; i < n; i++) {
		for (int j = 0; j <= 2; j++) {
				dp[i][j] = 0;
		}
	}
	for (i = 0; i < n; i++) { // 何日目？
		for (int j = 0; j <= 2; j++) { // 今日は何をした？
			for (int k = 0; k <= 2; k++) { // 昨日は何をした？
				if (j == k) continue;
				dp[i + 1][j] = max(dp[i + 1][j], dp[i][k]+a[i][j]);
			}
		}
	}
	int ans = 0;
	for (i = 0; i <= 2; i++) {
		ans = max(ans, dp[n][i]);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 2816
#include <iostream>
 
int main() {
	int n,m,l,t;
    long long int ta=0;
    std::cin >> n >> m >> l;
    int lista[n][m]={0};
    int listb[m][l]={0};
    for(int a=0;a<n;a++){
     for(int b=0;b<m;b++){
      std::cin >> lista[a][b];
     }
    }
    for(int c=0;c<m;c++){
     for(int d=0;d<l;d++){
      std::cin >> listb[c][d];
     }
    }
 
    for(int e=0;e<n;e++){
     for(int f=0;f<l;f++){
      for(int g=0;g<m;g++){
      ta=ta+lista[e][g]*listb[g][f];
      }
      std::cout << ta;
      if(f!=l-1)std::cout << " ";
      ta=0;
     }
     std::cout << std::endl;
    }
	return 0;
}

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

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b, a % b);
}
const ll P =  1000000007;
ll factorial(ll n){
   ll ans = 1;
   for(int i = n;i>=1;i--){
     ans *= i;
     ans %= P;
   }
   return ans;
}
using Graph = vector<vector<int>>;

ll kzyou(ll a,ll k){//aのk乗を返す
    ll zyou = 1;
    for(ll i = 1;i<=k;i++){
        zyou *= a;
    }
    return zyou;
}

int main(){
  ll N,K;
  cin >> N >> K;
  vector<ll> ans;

  while(N > 1){
    ans.push_back(N%K);
    N /= K;
  }
  if(N != 0) ans.push_back(N);
  reverse(ans.begin(),ans.end());

 cout << ans.size() << endl;

}

Measured memory_bytes: 256
n=int(input())
l=[*map(int,input().split())]
f=lambda p: exit(print(['pairwise','setwise','not'][p]+' coprime'))
from math import *
g=l[0]
for x in l: g=gcd(g,x)
if g>1: f(2)
from collections import *
C=Counter()
b=0
for x in l:
  if x%2<1:
    if C[2]: f(1)
    C[2]=1
  while x%2<1: x//=2
  for i in range(3,int(x**0.5)+1,2):
    if x%i<1:
      if C[i]: f(1)
      C[i]=1
    while x%i<1: x//=i
    if x<2: break
  if x>1:
    if C[x]: f(1)
    C[x]=1
f(0)

Measured memory_bytes: 197860
N,M = map(int,input().split())
dict = {}
for i in range(M):
    a,b = input().split()
    if a not in dict:
        dict[a] = [0, 0]

    if b == "AC" :
        if dict[a][0] != 1 :
            dict[a][0] += 1
        else :
            pass
    else:
        if dict[a][0] == 1 :
            pass
        else:
            dict[a][1] += 1
ans1 = 0
ans2 = 0
for i , j in dict.items() :
    if j[0] == 1 :
        ans1 += 1
        ans2 += j[1]
    else:
        pass
print(ans1,ans2)

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

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int):
    print(YES if N in list(set([x*y for x in range(1, 10) for y in range(1, 10)])) else NO)
    return


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
MOD = int(1e9+7)


def main():
    N = int(input())
    A = list(map(int, input().split()))
    sm = 0
    for a in A:
        sm = (sm + a) % MOD
    ans = 0
    for a in A:
        ans += ((sm-a) % MOD)*a
        ans %= MOD
    if ans % 2 == 0:
        ans //= 2
    else:
        ans = (ans + MOD) // 2
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 105112
#include<iostream>
#include<vector>
#include<deque>
using namespace std;

long gcd(long a, long b) {

    if ( a < b ) {
        long t = b;
        b = a;
        a = t;
    }

    if ( a % b == 0 ) {
        return b;
    } else {
        return gcd(a % b, b);
    }

}

int main() {

    long a, b;
    
    while (cin >> a >> b) {

        long g = gcd(a, b);
        cout << g << " " << (a / g * b) << endl;
    }
     
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()

using namespace std;

int H, A;

int main(void) {
    scanf("%d %d", &H, &A);
   

  
    printf("%d\n", (H+A-1)/A);

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;

#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 

#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
#define len length
#define ret0 return 0
#define ret return 

#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)

#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>

// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;

#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)1e5+5

string s;
ll dp[MAXN][14];
ll n;
ll f(ll idx, ll rem){
    if(idx==n){
        if(rem == 5) ret 1;
        else ret 0;
    }
    else if(dp[idx][rem] != -1){
        return dp[idx][rem];
    }
    else {
        if(s[idx]=='?') {
            ll ans = 0;
            loop(i,0, 10){
                ll new_rem = ((rem*10)%13 + i%13)%13;
                ans = (ans%mod + f(idx+1, new_rem)%mod)%mod;
            }
            return dp[idx][rem] = ans;
        }
        else if(s[idx]!='?'){
            ll new_rem = ((rem*10)%13 + (s[idx]-'0')%13)%13;
            return dp[idx][rem] = f(idx+1, new_rem)%mod;
        }
    }
    ret0;
}

void solve(){
    cin>>s;
    n = s.length();
    loop(i,0,MAXN) loop(j,0,14) dp[i][j]=-1;

    print(f(0, 0)%mod);
}

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

    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
   
}



Measured memory_bytes: 17616
#include<stdio.h>

int main(void){
    int N,M;
    char *blue[100],*red[100];
    char str[100][10],str2[100][10];

    scanf("%d",&N);
    int i;
    for(i=0;i<N;i++){
        blue[i]=str[i];
    }
    for(i=0;i<N;i++){
        scanf("%s",blue[i]);
    }
    scanf("%d",&M);
    for(i=0;i<M;i++){
        red[i]=str2[i];
    }
    for(i=0;i<M;i++){
        scanf("%s",red[i]);
    }
    int cnt,tmp=0;
    int j;
    for(j=0;j<N;j++){
        cnt=0;
        for(i=0;i<N;i++){
            if(strcmp(blue[j],blue[i])==0) cnt++;
        }
        for(i=0;i<M;i++){
            if(strcmp(blue[j],red[i])==0) cnt--;
        }
        if(cnt<tmp)    cnt=tmp;
        tmp=cnt;
    }
    printf("%d",cnt);

    return 0;
    
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(int, n);
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(all(a));
  int ans = a[0];
  rep(i, n - 1) ans = gcd(ans, a[i + 1]);
  out(ans);
}


Measured memory_bytes: 3768
n,m=map(int,input().split())
g=[[] for _  in range(n)]
for _ in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    g[a].append(b)
    g[b].append(a)
def dfs(g,res):
    for i in range(n):
        if len(g[i])==1:
            g[g[i][0]].remove(i)
            g[i]=[]
            res=dfs(g,res+1)
    return res
print(dfs(g,0))

Measured memory_bytes: 3064
N = int(input())
X = [[] for i in range(N)]
for i in range(N-1):
    x, y = map(int, input().split())
    X[x-1].append(y-1)
    X[y-1].append(x-1)

P = [-1] * N
DE = [0] * N
Q = [0]
while Q:
    i = Q.pop()
    for a in X[i][::-1]:
        if a != P[i]:
            P[a] = i
            DE[a] = DE[i] + 1
            X[a].remove(i)
            Q.append(a)

def lp(u, v):
    t = 0
    while u != v:
        if DE[u] > DE[v]:
            t += 1 << u-1
            u = P[u]
        elif DE[u] < DE[v]:
            t += 1 << v-1
            v = P[v]
        else:
            t += 1 << u-1
            t += 1 << v-1
            u = P[u]
            v = P[v]
    
    return t

Y = []
M = int(input())
for _ in range(M):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    Y.append(lp(a, b))

D = {1<<i: i for i in range(50)}
Z = [0] * (1<<M)
ans = 0
CC = [0] * N
BC = [0] * (1<<M)
for m in range(1, 1<<M):
    a = m & (-m)
    BC[m] = BC[m^a] + 1
for m in range(1<<M):
    a = m & (-m)
    if a == m:
        if a == 0:
            Z[m] = 0
        else:
            Z[m] = Y[D[a]]
    else:
        Z[m] = Z[m^a] | Y[D[a]]
    
    CC[N - 1 - bin(Z[m]).count("1")] += (1 if BC[m] % 2 == 0 else -1)

print(sum([2 ** i * CC[i] for i in range(N)]))

Measured memory_bytes: 58844
import Control.Applicative
import Data.List (sortBy)
import qualified Data.IntSet as Set

getDiffs :: [(Int,Int)] -> (Int,[Int]) -> [(Int,(Int,[Int]))]
getDiffs [] _ = []
getDiffs ((i,a):as) (m,js) = (a-m,(i,js)):getDiffs as nm
  where nm | a < m = (a, [i])
           | m == a = (m, i:js)
           | otherwise = (m, js)

main = do
  [n,t] <- map read.words <$> getLine :: IO [Int]
  as <- map read.words <$> getLine :: IO [Int]
  let diffs = sortBy (flip compare) $ getDiffs (zip [1..] (tail as)) (head as,[0])
      maxDiff = fst $ head diffs
      maxDiffs = takeWhile ((==maxDiff).fst) diffs
      maxDiffLargeLength = length maxDiffs
      maxDiffSmallLength = length $ Set.toList $ Set.fromList $ concatMap (snd.snd) maxDiffs
  print $ min maxDiffLargeLength maxDiffSmallLength


Measured memory_bytes: 54652
#include <stdio.h>

#define MAX 2000000

int n, a[MAX+1];

void maxHeapify(int i)
{
  int l, r, largest, tmp;
  l = 2*i;
  r = 2*i+1;

  if(l <= n && a[l] > a[i])
    largest = l;
  else
    largest = i;
  if(r <= n && a[r] >  a[largest])
    largest = r;

  if(largest != i) {
    tmp = a[i];
    a[i] = a[largest];
    a[largest] = tmp;
    maxHeapify(largest);
  }
}

int main()
{
  int i;

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

  for(i=n/2; i>=1; i--)
    maxHeapify(i);
  for(i=1; i<=n; i++)
    printf(" %d", a[i]);
  printf("\n");
  return 0;
}

Measured memory_bytes: 2548
#include<iostream>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
using namespace std;

int main(){    
  string N;   
    cin >> N;
  
    if(N == "Sunny"){
 cout << "Cloudy" << endl;
    }
    if(N == "Cloudy"){
      cout << "Rainy" << endl;
    }
    if(N == "Rainy"){
      cout<< "Sunny" <<endl;
    }
}


Measured memory_bytes: 256
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    L, R = MAP()
    LL = L % 2019
    RR = R % 2019
    if (R - L) >= 2019:
        print(0)
    else:
        minv = 2019
        for l in range(LL, RR):
            for r in range(l + 1, RR + 1):
                minv = min(minv, (l * r) % 2019)
        print(minv)

if __name__ == '__main__':
    main()


Measured memory_bytes: 39024
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::prelude::BufRead;
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufReader, BufWriter, Write};
#[allow(unused_imports)]
use std::mem::swap;
#[allow(unused_imports)]
use std::str::FromStr;
 
 
fn main() {
    let line = read_vector::<usize>();
    let (a, b, k) = (line[0], line[1], line[2]);
    let mut count = 0;
    for i in (1..101).rev() {
        if a % i == 0 && b % i == 0 {
            count += 1;
        }
        if count == k {
            println!("{}", i);
            break;
        }
    }
}
 
#[allow(dead_code)]
fn read<T>() -> T
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    return buf.trim().parse().unwrap();
}
 
#[allow(dead_code)]
fn read_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut buf = String::with_capacity(100);
    stdin().read_line(&mut buf).unwrap();
    return buf.split_whitespace().map(|s| s.parse().unwrap()).collect();
}
 
#[allow(dead_code)]
fn read_matrix<T>() -> Vec<Vec<T>>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    use std::io::prelude::*;
    let stdin = stdin();
    let mut reader = BufReader::with_capacity(100 * 1024, stdin);
    let mut line = String::with_capacity(100);
    let mut matrix: Vec<Vec<T>> = Vec::new();
 
    while reader.read_line(&mut line).unwrap() > 0 {
        matrix.push(
            line.trim()
                .split_whitespace()
                .map(|s| s.parse().unwrap())
                .collect(),
        );
        line.clear();
    }
 
    return matrix;
}
 
#[allow(dead_code)]
fn read_chars() -> Vec<char> {
    let stdin = stdin();
    let mut buf = String::new();
    let _bytes = stdin.read_line(&mut buf).unwrap();
    return buf.trim().chars().collect();
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define long long long
const int MOD=1e9+7;

long mp(long x, long n){
  long ans=1;
  for(int i=1; i<=n; i++){
    ans = (ans*x)%MOD;
  }
  return ans;
}

int main(){
  long N;
  cin >> N;
  vector<long> C(N);
  for(int i=0; i<N; i++){
    cin >> C[i];
  }
  sort(C.begin(), C.end(), greater<long>());
  long ans =0;
  for(int i=1; i<=N; i++){
    ans=(ans+C[i-1]*(i+1)%MOD)%MOD;
  }
  ans = (ans * (mp(4,N-1)%MOD))%MOD;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
string a;
int ans,l,maxx=-1*0x7fffffff;
int main(){
	cin>>l>>a;
	for(int i=0;i<l;i++){
		ans+=(a[i]=='I')?1:-1;
		maxx=max(ans,maxx);
	}
	if(maxx==-1)maxx=0;
	cout<<maxx<<endl;
	return 0;
}

Measured memory_bytes: 256
N = gets.chomp.to_i
x = []
y = []
h = []

def max(a,b)
  a > b ? a : b
end

N.times do
  a,b,c = gets.chomp.split.map(&:to_i)
  x << a
  y << b
  h << c
end


# h[i] == 0でないのが1つしかないときをカバーできていない？
if h.count(0) == N-1
  N.times do |i|
    if h[i] != 0
      puts [x[i], y[i], h[i]].join(' ')
      exit
    end
  end
end

0.upto(100) do |c_x|
  0.upto(100) do |c_y|
    flag = true
    h_tmp = -10000

    N.times do |i|
      next if h[i] == 0

      if h_tmp == -10000
        # 登録されていなかったら登録する
        h_tmp = h[i] + (x[i]-c_x).abs + (y[i]-c_y).abs
      else
        if h_tmp != h[i] + (x[i]-c_x).abs + (y[i]-c_y).abs
          flag = false
        end
      end
    end

    if flag == true
      puts [c_x, c_y, h_tmp].join(' ')
      exit
    end
  end
end


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

int main()
{
    int n, d;
    cin >> n >> d;
    int c = 0;

    vector<int> x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];

    rep(i, n){
        if (sqrt(pow(x[i], 2) + pow(y[i], 2)) <= d) c++;
    }

    cout << c << endl;

    return 0;
}

Measured memory_bytes: 4904
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
const int MAXN = 100010 ;
int n, m;
int in[MAXN];
bool vis[MAXN];
vector<int> edge[MAXN];
queue<int> q;
int main()
{
	memset(vis, false, sizeof(vis));
	cin >> n >> m;
	for (int i = 1, s, t; i <= m; ++i)
	{
		cin >> s >> t;
		edge[s].push_back(t);
		in[t] ++;
	}
	for (int i = 0; i < n; ++i)
		if (in[i] == 0 && ! vis[i])
		{
			vis[i] = true;
			q.push(i);
		}
	while (! q.empty())
	{
		int cur = q.front();
		q.pop();
		cout << cur << endl;
		for (int i = 0; i < edge[cur].size(); ++i)
		{
			int v = edge[cur][i];
			in[v] -- ;
			if (in[v] == 0 && ! vis[v])
			{
				vis[v] = true;
				q.push(v);
			}
		}
	}
	return 0;
}



Measured memory_bytes: 6048
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll> 
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  lvector A(n,0),B(n-1,0);rep(i,n-1) cin>>B[i];
  A[n-1]=B[n-2];A[0]=B[0];
  for(ll pos=1;pos<n-1;pos++) A[pos]=min(B[pos],B[pos-1]);  
  ll ans=accumulate(ALL(A),0);
  print(ans);
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	int cnt(int s,int g,int cnt,int xy[][],int n){
		int result = 0;
		int c[] = new int [n+1];
		int d[] = new int [n+1];
		c[s] = 1;
		if(s == g && cnt > 0)result = 1;
		for(int i = 1;i < cnt;i++){
			for(int j = 1;j < n+1;j++){
				for(int k = 1;k < n+1;k++){
					if(xy[j][k] == 1 && c[j] == i){
						d[k] = i + 1;
					}
				}
			}
			for(int j = 1;j < n+1;j++){
				c[j] = d[j];
			}
			if(c[g] > 0){
				result = c[g];
				break;
			}
			if(i == 101){
				break;
			}
		}
		return result;
	}
	void doIt() { 
		int n = sc.nextInt();
		int xy[][] = new int [n+1][n+1];
		for(int i = 0;i < n;i++){
			int r1 = sc.nextInt();
			int k1 = sc.nextInt();
			for(int j = 0;j < k1;j++){
				int t = sc.nextInt();
				xy[r1][t] = 1;
			}
    	 }
		int p = sc.nextInt();
		for(int i = 0;i < p;i++){
			int s = sc.nextInt();
			int d = sc.nextInt();
			int TTL = sc.nextInt();
			int ans = cnt(s,d,TTL,xy,n);
			if(ans == 0){
				System.out.println("NA");
			}else{
				System.out.println(ans);
			}
		}
		/*
		//中身
		for(int i = 1;i <= n;i++){
			for(int j = 1;j <= n;j++){
				System.out.print(xy[i][j]);
			}
			System.out.println();
		}
		*/
     }
    public static void main(String[] args) {
    	// TODO Auto-generated method stub
    	new Main().doIt();
    }
}

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

using namespace std;

struct Edge
{
  int to, cost;
};

int main()
{
  int N, M;
  cin >> N >> M;
  vector<Edge> edge[N];
  for (int i = 0; i < M; i++)
  {
    int L, R, D;
    cin >> L >> R >> D;
    L--;
    R--;
    edge[L].push_back({R, D});
    edge[R].push_back({L, -D});
  }
  bool ok = true;
  vector<long long> cost(N, 1e18);
  for (int i = 0; i < N; i++)
    if (cost[i] == 1e18)
    {
      queue<int> que;
      que.push(i);
      cost[i] = 0;
      while (que.size())
      {
        int now = que.front();
        que.pop();
        for (Edge t : edge[now])
          if (cost[t.to] == 1e18)
          {
            cost[t.to] = cost[now] + t.cost;
            que.push(t.to);
          }
          else if (cost[t.to] != cost[now] + t.cost)
            ok = false;
      }
    }
  if (ok)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 9728
N, A, B, K = map(int, input().split())
mod = 998244353

# 階乗 & 逆元計算
factorial = [1]
inverse = [1]
for i in range(1, N+2):
    factorial.append(factorial[-1] * i % mod)
    inverse.append(pow(factorial[-1], mod-2, mod))


# 組み合わせ計算
def nCr(n, r):
    if n < r or r < 0:
        return 0
    elif r == 0:
        return 1
    return factorial[n] * inverse[r] * inverse[n - r] % mod


ans = 0
for x in range(N+1):
    y = (K-A*x)/B
    if y.is_integer():
        ans += nCr(N, x) * nCr(N, int(y)) % mod

print(ans % mod)


Measured memory_bytes: 26880
#pragma GCC optimize("Ofast")  
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define int long long 
#define endl "\n"
#define all(x) (x).begin(),(x).end()
const int MOD = 1e9+7;
const int mxN = 2e5+3;

void solve(){
	int c;
	cin >> c;
	if(c >= 30){
		cout << "Yes\n";
	}else cout << "No\n";
}

int32_t main(){
	IO;
	
	int nT = 1;
	//cin >> nT;
	for(int i = 1; i <= nT; ++i)
		solve();
	return 0;
}


Measured memory_bytes: 3648
fun main(args: Array<String>) {
    abc079d()
}

fun abc079d() {
    val (h, w) = readLine()!!.split(" ").map { it.toInt() }
    val costs = (0..9).map { readLine()!!.split(" ").map { it.toInt() }.toIntArray() }
    val walls = (1..h).map { readLine()!!.split(" ").map { it.toInt() } }
        .flatten().filterNot { it == -1 }

    // k 中継点
    for (k in 0..9) {
        for (i in 0..9) {
            for (j in 0..9) {
                costs[i][j] = Math.min(costs[i][j], costs[i][k] + costs[k][j])
            }
        }
    }

    val answer = walls.map { costs[it][1] }.sum()

    println(answer)
}


Measured memory_bytes: 42124
from math import factorial
n, m = map(int, input().split())
mod = 10**9 + 7

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(n**0.5//1+1)):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    # if arr==[]:
    #     arr.append([n, 1])

    return arr

arr = factorization(m)
if not arr:
    print(1)
    exit()
ans = 1
for a, b in arr:
    pattern = factorial(b+n-1) // (factorial(b) * factorial(n-1))
    ans = (ans * pattern)%mod

print(ans)

Measured memory_bytes: 134916
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <random>
#include <utility>
#include <map>
#include <vector>
#include <queue>
#include <bitset>
#include <sstream>
#define REP(i,x) for(int i=0; i<(x); i++)
typedef long long ll;
 
using namespace std;
 
int main(int argc, const char * argv[]) {
    string n;
	cin >> n;
	int dig[16];
	int ma = 0;
	REP(i,n.length()){
		dig[i] = n[i] - '0';
		ma += dig[i];
	}
	int kouho = dig[0]-1+(9*(n.length()-1));
	ma = max(ma,kouho);
	
	cout << ma << endl;
    
    return 0;
}

Measured memory_bytes: 888
n = int(input())
*h, = map(int, input().split())

for i in range(n-1, 0, -1):
    if h[i] >= h[i-1]:
        continue
    elif h[i-1]-h[i] == 1:
        h[i-1] -= 1
    else:
        print('No')
        break
else:
    print('Yes')





Measured memory_bytes: 14224
#include <iostream>


char classdiv(int pm, int pe, int pj)
{
	double ave = (pm + pe + pj) / 3;
	if (pm == 100 || pe == 100 || pj == 100) {
		return 'A';
	} else if ((pm + pe) / 2 >= 90 || ave >= 80) {
		return 'A';
    } else if ( ave >= 70) {
		return 'B';
	} else if (ave >= 50 && (pm >= 80 || pe >= 80)) {
		return 'B';
	} else {
		return 'C';
	}
}
int main()
{
	int n;
	while (true) {
		std::cin >> n;
		if (n == 0) {
			break;
		} else {
	        for (int i = 0; i < n; i++) {
		        int pm;
		        int pe;
		        int pj;
		        std::cin >> pm >> pe >> pj;
				std::cout << classdiv(pm, pe, pj) << std::endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 10;
set<int> a[2][30];
char s[N], t[N];

int main() {
	cin >> s >> t;
	for(int i = 0 ; s[i] ; ++ i) a[0][s[i] - 'a'].insert(t[i] - 'a'),
		a[1][t[i] - 'a'].insert(s[i] - 'a');
	for(int i = 0 ; i < 26 ; ++ i)
		if(a[0][i].size() > 1 || a[1][i].size() > 1)
			return puts("No"), 0;
	puts("Yes"); 
}

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

int main()
{
    int n; cin >> n;
    vector<int> b(n-1);
    for(int i=0; i<n-1; i++)
        cin >> b[i];

    vector<int> a(n);

    a[0] = b[0];

    for(int i=0; i<n-2; i++){
        if(b[i] >= b[i+1])
            a[i+1] = b[i+1];
        else 
            a[i+1] = b[i];
    }

    a[n-1] = b[n-2];

    int sum = 0;

    for(int i=0; i<n; i++)
        sum += a[i];

    cout << sum << endl;

    return 0;
     

}

Measured memory_bytes: 256
K = int(input())

if 7%K==0:
    print(1)
else:
    ans = 1
    b = 7%K
    while ans < 10**7+1000:
        b = (b*10+7)%K
        if b == 0:
            print(ans+1)
            break
        else:
            ans += 1
    else:
        print(-1)

Measured memory_bytes: 9116
def heapPermutation(a, size, n,all_perms): 
	if (size == 1): 
		all_perms.append(a[:])
		return

	for i in range(size): 
		heapPermutation(a,size-1,n,all_perms)
		if size&1: 
			a[0], a[size-1] = a[size-1],a[0] 
		else: 
			a[i], a[size-1] = a[size-1],a[i] 
		

def main():
    n = int(input())
    p = list(map(int,input().split()))
    q = list(map(int,input().split()))
    arr = [i for i in range(1,n+1)]
    all_perms = []
    heapPermutation(arr,n,n,all_perms)
    all_perms.sort()
    a = -1
    b = -1
    for i in range(len(all_perms)):
        if all_perms[i] == p:
            a = i
        elif all_perms[i] == q:
            b = i

    if a == -1 or b == -1:
        print(0)
        return

    print(abs(a-b))


main()


Measured memory_bytes: 9204
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
typedef unsigned int UINT;
using namespace std;

//紙に書かれたことを守って, E869120 君と square1001 君両方が, 食べたい数のケーキを取ることができるならば Yay!, そうでなければ :(と出力しなさい.
int main(void) {
    int A, B;
    cin >> A >> B;

    if (A < 9 && B < 9) {
        cout << "Yay!" << endl;
    }
    else
        cout << ":(" << endl;



    return 0;
}

Measured memory_bytes: 256
s=[int(x) for x in list(input())]
for c in range(len(s)-1,-1,-1):
    if c==len(s)-1:
        continue
    s[c]=(pow(10,len(s)-c-1,2019)*s[c]+s[c+1])%2019
s.append(0)
s.sort()
h=[1]
d=s[0]
for c in range(1,len(s)):
    if s[c]!=d:
        h.append(1)
        d=s[c]
    else:
        h[-1]+=1
k=[(x*(x-1))//2 for x in h]
print(sum(k))

Measured memory_bytes: 16732
import Prelude

cut = 1000000007

factorial :: Int->Int
factorial 0 = 1
factorial n = n `seq` (n*factorial (n-1) `mod` cut)

inusaru :: Int->Int->Int
inusaru a b 	|a==b = (2*(factorial a)*(factorial b)) `mod` cut
		|(a-b)==1 = ( (factorial a)*(factorial b)) `mod` cut
		|(b-a)==1 = ( (factorial a)*(factorial b)) `mod` cut
		|otherwise = 0


main :: IO ()
main = do
    -- スペース区切り整数の入力
    [a, b] <- map read . words <$> getLine
    putStrLn $ show $ inusaru a b



Measured memory_bytes: 3068
# vim: set fileencoding=utf-8 :
n = int(raw_input())
flag1 = 0
flag2 = 0

if n % 4 == 0 or n % 7 == 0:
    print("Yes")
    exit()

for i in range(n / 4):
    if (n - i * 4) % 7 == 0:
        flag1 = 1

for i in range(n / 7):
    if (n - i * 7) % 4 == 0:
        flag2 = 1

if flag1 == 1 or flag2 == 1:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2568
#include<bits/stdc++.h>
#include<numeric>
using namespace std;
#define ll long long
#define Graph vector<vector<long long>>
#define all(v) v.begin(),v.end()
#define PI acos(-1)
#define inf 1000000321

int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll ans = 0;
    ans = max({a*c,b*d,b*c,a*d});
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <cstdlib>
#include <iterator>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cctype>
#include <functional>
using namespace std;

int main() {
    vector<vector<char>> v(3, vector<char>(3));
    for(int i = 0; i < 3; i++) {
        for(int j = 0; j < 3; j++) {
            cin >> v[i][j];
        }
    }

    for(int i = 0; i < 3; i++) cout << v[i][i];
    cout << endl;
}


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

int main() {
	string S;
	cin >> S;
	string Y;
	for (int i = 0; i < 4; i++) {
		Y.push_back(S[i]);
	}
	string M;
	for (int i = 5; i < 7; i++) {
		M.push_back(S[i]);
	}
	string D;
	for (int i = 8; i < 10; i++) {
		D.push_back(S[i]);
	}
	
	int y = atoi(Y.c_str());

	int m = atoi(M.c_str());

	int d = atoi(D.c_str());

	if (y < 2019) {
		cout << "Heisei";
	}
	else if (2019 < y) {
		cout << "TBD";
	}
	else {
		if (m <=4) {
			cout << "Heisei";
		}
		else{
			cout << "TBD";
		}

	}
	system("pause");
		return 0;
}

Measured memory_bytes: 504
#include<stdio.h>
#include<math.h>

int main(void){
  int num=0;
  long H,sum=0;
  scanf("%ld\n",&H );
  while(H > 0){
    H /= 2;
    sum += pow(2,num);
    num++;
  }
  printf("%ld\n",sum );
  return 0;
}


Measured memory_bytes: 256