akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<iostream>
#include<cstring>
#include<math.h>
#include<stdlib.h>
#include<time.h>
#define ll long long
#define maxn 405
using namespace std;
const int mod=1e9+7;
ll dp[maxn][maxn];
int a[maxn],b[maxn],n,m;
ll sum[maxn][maxn];

inline int read()
{
	int num,sign=1;
	char c;
	while((c=getchar())<'0'||c>'9')
		if(c=='-')sign=-1;
	num=c-'0';
	while((c=getchar())>='0'&&c<='9')
		num=(num<<1)+(num<<3)+c-'0';
	return num*sign;
}

inline ll fast(ll a,ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1)ans=ans*a%mod;
		b>>=1;
		a=a*a%mod;
	}
	return ans;
}

inline void pre()
{
	for(register int i=1;i<=n;++i)sum[i][0]=b[i]-a[i]+1;
	for(register int i=1;i<=n;++i)
		for(register int k=1;k<=m;++k)
			for(register int j=a[i];j<=b[i];++j)
				sum[i][k]=(sum[i][k]+fast(j,k))%mod;
}

signed main(void)
{
	n=read(),m=read();
	for(register int i=1;i<=n;++i)a[i]=read();
	for(register int i=1;i<=n;++i)b[i]=read();
	pre();
	dp[0][0]=1;
	for(register int i=1;i<=n;++i)dp[i][0]=(dp[i-1][0]*sum[i][0])%mod;
	for(register int i=1;i<=n;++i)
		for(register int j=1;j<=m;++j)
			for(register int k=0;k<=j;++k)
				dp[i][j]=(dp[i][j]+(dp[i-1][j-k]*sum[i][k])%mod)%mod;
	printf("%lld",dp[n][m]);
	return 0;
}

Measured memory_bytes: 2816
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>

using namespace std;

#define INF 1010001000
#define EPS 1e-10
#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef pair<int, int> i_i;
typedef long long int llong;
typedef pair<llong, llong> ll_ll;
typedef struct edge {int f, t;}Edge;

void sieve();

vector<bool> prime(1299710, true);
int n = 1299710;


int main()
{
    sieve();
    int a;
    while (cin >> a, a) {
        int bef, aft, ptr = a;
        while (1) {
            if (prime[ptr]) {
                bef = ptr;
                break;
            } else {
                ptr--;
            }
        }
        ptr = a;
        while (1) {
            if (prime[ptr]) {
                aft = ptr;
                break;
            } else {
                ptr++;
            }
        }
        cout << aft - bef << endl;
    }
    return 0;
}


void sieve()
{
    prime[0] = prime[1] = false;
    for (int i = 2; i * i < n; i++) {
        if (prime[i]) {
            for (int j = 2; j * i < n; j++) {
                prime[i*j] = false;
            }
        }
    }
}

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

/*
,,,,
　　　　　　　　　　　　　　　　　　　　　　　　　　,.斗*''“i:i:{
　　　　　　　　　　　　　,.　｡. . . * : : : ''' : : : :” :”“ ''ｰ - 弋,,_
　　　　　 　 　 ,.斗*''“ : : : : : : : : : : : : : ' ' ' ' ' ' : : : : : : : : : : :”: '':* ｡ ,
　　　 ,.斗*''“ ” ＼：　　 ”・・． ' ' ' '　　　　　　　　 ' ' ' ' : : : : : : : : : : : : ”ミ*｡,,,,,,　　　　　　 　 　 　 ＿
　　く.　 ◎　 ﾞ:.ﾞ:..　ﾟ:,　:　───────────　　　--　　,,,,,,__ ' ' ' :.:.:.:.:.”≧s｡.　　＿,,,｡s*i:i:i:i:<
　　ﾏ*s｡ :,　 }　ﾟ:,　 :}　　　　　　　　　　　　　　　　　　　　　　　　　　　　”　''　-　”””：：”：：`*｡i:i:i:i:i:i:i;:’
　　　` .｡`　 ,　,ノ ／｡ ,,,_　　　　　　　　　　　　　　　　　　　　　　　　　　　　　＿＿`　　} }　　ﾉi:i:i:i:i:ﾂ
　　　　　 `　*　｡　　`*｡i:i:i::*=-　　　　　　　　　　　＿＿　　　　　　,,,....｡s*'i,:’　　　”`*｡＿,*’i:i:i:i:r’
　　　　　　　　　　　”　─ --　　　　｡｡｡｡｡　　 -　－`''''''''ヽ ─ '''”　　　｀ｰ“　　　　　　　`*｡i:i:i:i:i:i:
　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　`*｡i:i:::
　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　`*ﾟ:,
         fozubaoyou    no BUGs alive!
*/

typedef long long ll;
//{
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define dumo dump
//}

#define debug_interval ','
#define dump_interval endl
#define debug_toggle 0

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cout<<endl;}
template<class...A> inline void debug_rest() {cout<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cout<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cout<<first,debug_rest(rest...);}
//}

int a,b,c,d,ans;
string s,t,u;

int main(){
  cin>>a>>b;
  c=1;
  for(int i=0;i<a;i++){
    c*=100;
  }
  if(b==100){
    dump((b+1)*c);
    return 0;
  }
  dump(b*c);
}

Measured memory_bytes: 768
#include<iostream>
#include<cstdio>
#define MAX 1001

//入力
int n,m;
char field[MAX][MAX]={};//庭

//プロトタイプ宣言
void bfs(int x,int y,char f);
void slove();

int main(){
  int i,j;
  
  while(1){
    scanf("%d %d",&n,&m);
    if(n==0 && m==0) break;
    for(i=0;i<n;i++){
      scanf("%s",field[i]);
    }
    slove();
  }

  return 0;
}

void slove(){
  int res=0; char f=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){

      if(field[i][j]=='@'){
	f='@';
	bfs(i,j,f);
	res++;
      }
      else if(field[i][j]=='#'){
	f='#';
	bfs(i,j,f);
	res++;
      }
      else if(field[i][j]=='*'){
	f='*';
	bfs(i,j,f);
	res++;
      }

    }
  }
  printf("%d\n",res);
}

void bfs(int x,int y,char f){
  int nx,ny;
  //今いるところを、.に置き換える
  field[x][y]='.';

      //x方向にdx y方向にdy 移動した場所を(nx,ny)とする
      nx=x-1,ny=y;
      //nxとnyが庭の範囲内かどうかとfield[nx][ny]が水たまりかどうかを判定
      if(0<=nx && nx<n && 0<=ny && ny<m && field[nx][ny]==f) bfs(nx,ny,f);//水たまりだったら再起
      nx=x; ny=y-1;
      if(0<=nx && nx<n && 0<=ny && ny<m && field[nx][ny]==f) bfs(nx,ny,f);//水たまりだったら再起
      nx=x; ny=y+1;
      if(0<=nx && nx<n && 0<=ny && ny<m && field[nx][ny]==f) bfs(nx,ny,f);//水たまりだったら再起
      nx=x+1; ny=y;
      if(0<=nx && nx<n && 0<=ny && ny<m && field[nx][ny]==f) bfs(nx,ny,f);//水たまりだったら再起

  return ;
}

Measured memory_bytes: 1752
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
typedef long long lint;
const int N=1e5+5;
int n,dgr[N];

namespace utils{
	template <class T> inline void apn(T &x,const T y){x=x<y?x:y;}
	template <class T> inline void apx(T &x,const T y){x=x<y?y:x;}
	inline int nxi(){
		int x=0;
		char c;
		while(((c=getchar())>'9'||c<'0')&&c!='-');
		const bool f=(c=='-')&&(c=getchar());
		while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
		return f?-x:x;
	}
}
using namespace utils;

int main(){
	n=nxi();
	for(int i=nxi(); i; --i){
		++dgr[nxi()];
		++dgr[nxi()];
	}
	for(int i=1; i<=n; ++i){
		if(dgr[i]&1){
			puts("NO");
			return 0;
		}
	}
	puts("YES");
	return 0;
}


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

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

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

  unordered_map<ll, ll> mp;
  for (int i = 0; i < n + 1; ++i)
  {
    mp[a[i] % m]++;
  }

  ll sum = 0;
  for (auto &e : mp)
  {
    sum += e.second * (e.second - 1) / 2;
  }
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 4492
object Main {
  def main(args:Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    var n, r = sc.nextInt
    while(n != 0 || r != 0) {
      var cards = (1 to n).toList.reverse
      for(_ <- 1 to r) {
        val p, c = sc.nextInt
        cards = cards.take(c + p - 1).drop(p - 1) ::: cards.take(p - 1) ::: cards.drop(c + p - 1)
      }
      println(cards.head)
      n = sc.nextInt; r = sc.nextInt
    }
  }
}

Measured memory_bytes: 60164
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,a,b,min=1e6,tmp,tmp1,tmp2,sum1,sum2;
    cin >> n;
    tmp = n;
    for(int i=1;i<n;i++){
        int j = n-i;
        tmp1=i;
        tmp2=j;
        sum1=0;
        sum2=0;
//            if(n==i+j){
            while(tmp1>0){
                sum1+=tmp1%10;
                tmp1/=10;
            }
            while(tmp2>0){
                sum2+=tmp2%10;
                tmp2/=10;
            }
            if(sum1+sum2<min)
                min = sum1+sum2;
//            }
        }
    cout << min << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

#define N 2000000
#define INFTY 2000000010

void maxHeapify(int);
int extractMax(void);
void increaseKey(int,int);
void insert(int);
int parent(int);
int left(int);
int right(int);

int size,A[N];

int main(){
  int key;
  char com[10];
   
  while(1){
    scanf("%s",com);
    if(com[0]=='e' && com[1]=='n'){
      break;
    }else if(com[0]=='i'){
      scanf("%d",&key);
      insert(key);
    }else if(com[0]=='e' && com[1]=='x'){
      printf("%d\n",extractMax());
    }
  }
   
  return 0;
}

void maxHeapify(int i){
        
  int l,r,largest,temp;
     
  l = left(i);
  r = right(i);
    
  if (l <= size && A[l] > A[i]) largest = l;
  else largest = i;
    
  if(r <= size && A[r] > A[largest]) largest = r;

  if(largest != i){
    temp=A[i];
    A[i]=A[largest];
    A[largest]=temp;
    maxHeapify(largest);
  }

}

int extractMax(){
  int maxkey;
  if(size<1) return -INFTY;
  maxkey=A[1];
  A[1]=A[size];
  size=size-1;

  maxHeapify(1);
  return maxkey;
}

void increaseKey(int i, int key){
  int temp;
  if(key<A[i])  return;
  A[i]=key;
  while(i>1 && A[parent(i)]<A[i]){
    temp=A[i];
    A[i]=A[parent(i)];
    A[parent(i)]=temp;
    i=parent(i);
  }
}

void insert(int key){
  size=size+1;
  A[size]=-INFTY;
  increaseKey(size,key);
}

int parent(int i){
  int pid;
  pid=i/2;

  return pid;
}

int left(int i){
  int lid;
  lid=2*i;
  return lid;
}

int right(int i){
  int rid;
  rid=2*i+1;
  return rid;
}



Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int lim = 2e5;

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

	int n,k;
	cin>>n>>k;
	vector<int> vals(n);
	for(auto& v:vals)
		cin>>v;

	int ans = 0;
	for(int l=0;l<=n;l++)
		for(int r=0;l+r<=n;r++)
		{
			int cmvs = l+r,cans = 0;
			priority_queue<int,vector<int>,greater<int>> del;
			for(int i=0;i<l;i++)
			{
				cans += vals[i];
				del.push(vals[i]);
			}
			for(int i=0;i<r;i++)
			{
				cans += vals[n-1-i];
				del.push(vals[n-1-i]);
			}

			while(cmvs<=k && del.empty()==0)
			{
				ans = max(ans,cans);
				cans -= del.top();
				del.pop();
				cmvs++;
			}
		}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1000000007
#define MAX 3000
using namespace std;
long long dp[MAX+1];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	for(int i=3;i<=n;++i)
	{
		dp[i] = 1;
		for(int j=i-1;j>=3;--j)
		{
			dp[i] += dp[i-j];
			dp[i] %= MOD;
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define int long long
#define N 100010
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
int n;
int a=0,b=0,c=0;
bool check(){return 4 * a * b * c == n * (b * c + a * c + a * b);}


signed main(){
  cin>>n;
  for(int i=1;i<=3500;i++)
    for(int j=1;j<=3500;j++){
      a = i;
      b = j;
      if((4*a*b-n*b-n*a)==0) continue;
      c = n * a * b / (4*a*b-n*b-n*a);
      if(c > 0 && check()) {i=j=3500;break;}
      c++;
      if(c > 0 && check()) {i=j=3500;break;}
      c-=2;
      if(c > 0 && check()) {i=j=3500;break;}
    }
  cout<<a<<" "<<b<<" "<<c<<endl;
  
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer[] v = new Integer[n];
        for (int i = 0; i < n; i++) {
            v[i] = sc.nextInt();
        }

        Arrays.sort(v);
        double result = v[0];
        for (int i = 1; i < n; i++) {
            result = (result + v[i]) / 2.0;
        }

        System.out.println(result);
    }
}


Measured memory_bytes: 23124
using System;

namespace ConsoleApp7
{
    class Info : IComparable
    {
        public int name;
        public int age;

        public Info(int name, int age)
        {
            this.name = name;
            this.age = age;
        }

        public int CompareTo(object obj)
        {
            Info i = obj as Info;
            return this.name.CompareTo(i.name);
        }
    }

    class Program
    {
        static void Main(string[] args)
        {

            bool Ans = true;


            int N = int.Parse(Console.ReadLine());

            Info[] A = new Info[N];
            for(int i = 0;i < N ;i++)
            {
                string[] S = Console.ReadLine().Split(' ');
                A[i] = new Info(int.Parse(S[1]),int.Parse(S[0]));

            }
            Array.Sort(A);

            int TimeLimit = 0;
            int Worktime = 0;
            for (int i = 0; i < N; i++)
            {
                TimeLimit = A[i].name;
                Worktime += A[i].age;
                
                if(TimeLimit < Worktime)
                {
                    Ans = false;
                    break;
                }


            }

            if(Ans == true)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

        }
    }
}


Measured memory_bytes: 23336
a, b, x = map(int, input().split())

import math
r = 180/math.pi

c = x / (a * b * 0.5)
if c <= a:
    print(math.atan(b/c) * r)
else:
    c = ((a**2)*b - x) * 2 / (a**2)
    print(math.atan(c/a) * r)

Measured memory_bytes: 9356
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
  int i,a,*entity,cnt,n,j,b;
  scanf("%d",&n);
  cnt=n;
  entity=(int*)malloc(sizeof(int)*n);
  for(i=0;i<=n-1;i++)
      scanf("%d",entity+i);
  for(i=0;i<=n-1;i++)
  {
    b=sqrt(entity[i]);
    for(j=2;j<=b;j++)
    {

      if(entity[i]%j==0)
      {
        cnt--;
        break;
      }
    }
  }
  printf("%d\n",cnt);
  free(entity);
  return 0;
}



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

int main() {
  int N;
  cin >> N;
  int n = N%10;
  if( (N%1000)%111==0 ){
    cout << "Yes";
  }else if( (N-n)%1110==0 ){
    cout << "Yes";
  }else{
    cout << "No";
  }
  
}


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

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

  sort(s.begin(), s.end());                   // ratcode -> acdeort
  sort(t.begin(), t.end(), greater<char>());  // atlas -> tslaa

  if (s < t) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3636
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) {

		new Main().run();
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = Integer.parseInt(scanner.nextLine());
			if (n == 0)
				break;
			Map<String, Integer> map = new LinkedHashMap<String, Integer>();
			StringTokenizer[] tokenizers = new StringTokenizer[n];
			for (int i = 0; i < n; i++) {
				tokenizers[i] = new StringTokenizer(scanner.nextLine());
			}
			String a = scanner.nextLine();
			for (StringTokenizer to : tokenizers) {
				while (to.hasMoreTokens()) {
					String st = to.nextToken();
					if (!st.startsWith(a))
						continue;
					int sum = 1;
					if (map.containsKey(st)) {
						sum = map.get(st) + 1;
					}
					map.put(st, sum);
				}
			}
			Map<String, Integer> sortMap = new TreeMap<String,Integer>(new MapComp(map));
			sortMap.putAll(map);
			int count =0;
			boolean flag = true;
			for(String ans: sortMap.keySet()){
				if(count ==0){
					System.out.print(ans);
					flag = false;
				}else
					System.out.print(" "+ ans);
				if(count==4)
					break;
				count++;
			}
			if(flag)
				System.out.println("NA");
			else
				System.out.println();
		}
	}

	class MapComp implements Comparator<String> {
		Map<String, Integer> map;

		public MapComp(Map<String, Integer> map) {
			super();
			this.map = map;
		}

		@Override
		public int compare(String a, String b) {
			int v1 = map.get(a);
			int v2 = map.get(b);
			if (v1 == v2)
				return a.compareTo(b);
			return v2 - v1;
		}

	}
}

Measured memory_bytes: 28468
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<string.h>
#include<queue>
#include<limits.h>
#define int long long
#define P pair<int,int>
using namespace std;

int mincost[1000];
vector<P>rin[1000];
signed main() {
	int a, b; cin >> a >> b;
	for (int c = 0; c < b; c++) {
		int d, e, f; cin >> d >> e >> f;
		rin[d - 1].push_back({ -f,e - 1 });
	}
	for (int i = 0; i < a; i++) {
		mincost[i] = LLONG_MAX/3;
	}
	mincost[0] = 0;
	int K = 0;
	int N = 0;
	while (1) {
		K++;
		bool U = false;
		for (int i = 0; i < a; i++) {
			for (P S : rin[i]) {
				if (mincost[i] != LLONG_MAX/3&&mincost[i] + S.first < mincost[S.second]) {
					mincost[S.second] = mincost[i] + S.first;
					U = true;
				}
			}
		}
		if (!U)break;
		if (K == 1500)N = mincost[a - 1];
		if (K == 10000) {
			if (N == mincost[a - 1]) {
				break;
		}
			else {
				puts("inf"); return 0;
			}
		}
	}
	cout << -mincost[a - 1]<< endl;
}

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define int ll

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

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

signed main() {
  string S,T; cin >> S >> T;
  int ans = 0;
  rep(i, S.length()) {
    if(S[i] != T[i]){
      ans ++;
    }
  }
  cout << ans << endl;
}

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

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

    int sum = 0;
    for (int i = 0; i < N; i++) {
        int l, r;
        cin >> l >> r;
        sum += (r - l + 1);
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner scan = new Scanner(System.in);

		int num=scan.nextInt();
		System.out.println(num*num*num);

	}
}



Measured memory_bytes: 26132
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
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;}
ll mod(ll n){return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll aa , bb;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->aa - ((fr*)q)->aa;}

/*----------------------priorityqueue(max)-----------------------------------------------------------*/
// top:min popHeap heap[0]=INF;
ll heap[MAX_N];
void pushHeap(ll val, ll len){
    ll i=len; heap[i]=val;
    while(i!=0){
        if( heap[i]<heap[(i-1)/2] ) swap(&heap[i],&heap[(i-1)/2]);
        i--;i/=2;
    }
}
void popHeap(ll *val, ll len){
    ll i=0; *val=heap[0]; heap[0]=INF;
    swap(&heap[0],&heap[len-1]);
    while(len>i*2+1){
        if(i*2+2<len && heap[i]> heap[i*2+2] && heap[i*2+1]>heap[i*2+2] ){
            swap(&heap[i],&heap[i*2+2]);
            i*=2;i+=2;
        }else{
            if(heap[i]>heap[i*2+1]){
                swap(&heap[i],&heap[i*2+1]);
                i*=2;i++;
            }else break;
        }
    }
}
/*---------------------------------------------------------------------------------*/


int main(void){
    // char ;
    ll n,k;
    scanf("%lld%lld",&n,&k);
    ll v[n];
    rep(i,0,n){
        scanf("%lld",&v[i]);
    }
    ll sum,max=0;
    rep(a,0,k+1){
        rep(b,0,k+1){
            if(a+b>k || a+b>n) break;
            sum=0;
            rep(i,0,a){
                sum+=v[i];
                pushHeap(v[i],i);
            }
            rep(i,0,b){
                sum+=v[n-1-i];
                pushHeap(v[n-1-i],a+i);
            }
            rep(i,0,k-a-b){
                if(heap[0]>=0) break;
                ll c;
                popHeap(&c,a+b);
                sum+=ABS(c);
                // printf("%lld ",c);
            }
            if(max<sum) max=sum;
            // printf("%lld %lld   ",sum,max);
        }
        // PN;
    }
    printf("%lld\n",max);
    return 0;
}


Measured memory_bytes: 128
let _ =
  let rec range s t d f = if s > t then [] else (f s) :: range (s + d) t d f in
  let area d f = List.fold_left (+) 0 (range d (600 - d) d (fun x -> d * (f x))) in
  try
    while true do
      Scanf.scanf "%d\n" (fun d -> Printf.printf "%d\n" @@ area d (fun x -> x * x))
    done
  with
    End_of_file -> ()

Measured memory_bytes: 2280
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>

#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)

typedef long long int64;

using namespace std;

int64 mod = 998244353;

int64 powmod(int64 a, int64 n) {
	if (n == 0) return 1;
	if (n % 2 == 1) return a * powmod(a, n - 1) % mod;
	int64 x = powmod(a, n / 2);
	return x * x % mod;
}

int main() {
	ios_base::sync_with_stdio(0);
    int n;
	cin >> n;
	unordered_map<int, int> a;
	for (int i = 0; i < n; ++i) {
	    int x;
		cin >> x;
		if (i == 0 && x != 0) {
	    	cout << 0 << endl;
		    return 0;
		}
		++a[x];
	}
	if (a[0] != 1) {
		cout << 0 << endl;
		return 0;
	}
	int64 ans = 1;
	for (int i = 1; i + 1 <= n; ++i) {
		ans *= powmod(a[i - 1], a[i]);
		ans %= mod;
	}
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4388
#include <bits/stdc++.h>
#include <string>
//#include <boost/multiprecision/cpp_int.hpp>
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll  long long
#define fp cout<<fixed<<setprecision(9);
#define ifor(j,n) for(int i=j ;i<n;i++)
#define jfor(k,n) for(ll j=k ;j<n;j++)
#define pb push_back
#define mod 1000000007
using namespace std;
//using namespace boost::multiprecision;

//Compiler version g++ 6.3.0
struct node
{
 float p;
};
int search (vector <long long> v,long long m,int n) 
{ 

    int start = 0;
    int ans = -1; 
    while (start <=n) 
    { 
     int mid = (start + n) / 2;
     if (v[mid] <= m) 
         start = mid + 1;
     else
   { 
   ans = mid; 
   n = mid - 1; 

       } 

    } 
    return ans; 
} 

int main()
{
 FAST 
   int r,g,b,k;
   cin>>r>>g>>b>>k;
  while(k--)
  {
    if(r>=g)
      g*=2;
    else if(g>=b)
      b*=2;
  }
   if(r<g && g<b)
      cout<<"Yes"<<endl;
   else
     cout<<"No"<<endl;
   
     }
     


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/















int N;
//---------------------------------------------------------------------------------------------------
string buf = "";
void dfs(int cu) {
	if (cu == N) {
		printf("%s\n", buf.c_str());
		return;
	}

	char biggest = 'a';
	while (buf.find(biggest) != string::npos) biggest++;
	biggest--;

	for (char c = 'a'; c <= biggest; c++) {
		buf.push_back(c);
		dfs(cu + 1);
		buf.pop_back();
	}

	biggest++;
	buf.push_back(biggest);
	dfs(cu + 1);
	buf.pop_back();
}
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;

	dfs(0);
}







Measured memory_bytes: 1536
import sys
from math import factorial

rl = sys.stdin.readline


def mod_div(x, y, mod=10 ** 9 + 7):
    return x * pow(y, mod - 2, mod) % mod


def solve():
    N = int(rl())
    x = list(map(int, rl().split()))
    MOD = 10 ** 9 + 7
    
    acc = [0] * N
    k = factorial(N - 1)
    for i in range(1, N):
        acc[i] = (acc[i - 1] + k) % MOD
        k = k * mod_div(i, i + 1) % MOD
    
    ans = 0
    for i in range(N - 1):
        ans = (ans + (x[i + 1] - x[i]) * acc[i + 1]) % MOD
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 14252
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int s[4];
    int a,b,c;
    while(cin>>s[0]>>s[1]>>s[2]){
        sort(s,s+3);
        a=s[0];
        b=s[1];
        c=s[2];
        int ans=0;
        //cout<<a<<b<<c<<endl;
        while(1){
            if(b==c)break;
            a++;
            b++;
            ans++;
        }
        //cout<<ans<<endl;
        while(a<b){
            a+=2;
            ans++;
        }
        //cout<<ans<<endl;
        if(a==b){
            cout<<ans<<endl;
        }
        else{
            cout<<ans+1<<endl;
        }
    }
    return 0;
}


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

int main() {
  int N;
  
  
  cin>>N;
  
 vector<int> p(N);
for (int i = 0; i < N; i++) {
  cin >> p.at(i);
}
  
  
  
/*  int a=-100;
  int b;
  int d=-100;
  int e;
  if(N==2){
    a=max(p.at(1),p.at(0));
  }
  else{
    for (int i = 1; i < N; i++) {
      e=max(p.at(i),d);
      b=max(p.at(i),p.at(i-1));
      d=b;
    }
  }
  
 
  
  int c=0;
  for (int i = 0; i < N; i++) {
  c+=p.at(i);
}
  if(N==2){
    cout<<c-a/2<<endl;
  }else{
    
  cout<<c-e/2<<endl;
  }*/
  
  int max = *std::max_element(p.begin(), p.end());
  //cout<<max;
  int d=max/2;
  int c=0;
  for (int i = 0; i < N; i++) {
  c+=p.at(i);
}
  
  cout<<c-d<<endl;
  
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
int main(){
    ll A, B = 0, X;
    cin >> X;
    while(1){
        ll num_p = X + B * B * B * B * B;
        ll num_m = X - B * B * B * B * B;
        A = 0;
        while(A * A * A * A * A < num_p){
            A++;
        }
        if(A * A * A * A * A == num_p){
            cout << A << " " << B << endl;
            break;
        }
        A = 0;
        while(A * A * A * A * A  < num_m){
            A++;
        }
        if(A * A * A * A * A == num_m){
            cout << A << " " << -B << endl;
            break;
        }
        B++;
    }
    return 0;
}

Measured memory_bytes: 3648
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())
num=0
for i in range(N):
    if x[i]**2+y[i]**2<=D**2:
        num+=1
print(num)

Measured memory_bytes: 24700
#include<bits/stdc++.h>
using namespace std;
using p = pair<int,long long>;
using ll = long long;
int main(){
  ll d,n;
  cin >> d >> n;
  
  ll c = 0;
  ll i = 0;
  while(c!=n){
    i++;
    ll s = i;
    ll num = 0;
    while(s%100==0&&num!=d){
        s/=100;
        num++;
    }
    if(num==d&&s%100!=0){
      c++;
    }
  }

  cout << i;
}

Measured memory_bytes: 256
/*

Coded and Decoded by : Yash Kapoor

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

// s.find_by_order(index);
// s.order_of_key(value);

#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair
#define pll pair<ll, ll>
#define vl vector<ll>
#define sl set<ll>
#define vll vector<pll>
#define ml map<ll, ll>
#define mll map<pll, ll>
#define all(a) a.begin(), a.end()
#define x first
#define y second
#define sz(x) (ll) x.size()
#define dl '\n'
#define why (ll)1000000007
//#define why (ll)998244353
#define lp(i, a, b) for (ll i = a; i < b; ++i)
#define lpr(i, a, b) for (ll i = a; i >= b; i--)
#define lpd(i, x) for (auto i : x)
#define ios                                                                                                            \
  ios_base::sync_with_stdio(false);                                                                                    \
  cin.tie(0);                                                                                                          \
  cout.tie(0);

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

ll inf = 1e18;
ld pi = 3.141592653589;
ll mod = why;
ll fast_power(ll base, ll power, ll mod)
{
  ll result = 1;
  while (power) {
    if (power % 2)
      result = (result * base) % mod;
    base = (base * base) % mod;
    power /= 2;
  }
  return result;
}

ll inverse(ll base, ll mod) { return fast_power(base, mod - 2, mod); }
int test = 1;
void solve() 
{
  ll n; cin >> n;
  vl a(n); lp(i,0,n) cin >> a[i];
  ll ans = 0;
  ll mx = a[0];
  lp(i,1,n){
    mx = max(mx,a[i]);
    if(mx > a[i]){
      ans += mx - a[i];
    }
  }
  cout << ans << dl;
} 

int main()
{
  // #ifndef ONLINE_JUDGE 
  //   freopen("input.txt", "r", stdin);
  //   freopen("output.txt", "w", stdout);
  // #endif
  ios 
  ll t = 1;
  //cin >> t;
  while (t--) 
  {
    //cout << "Case #" << test++ << ": ";
    solve();
  }
}

Measured memory_bytes: 4744
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;//でかい整数

int main(){
  int a,b;
  cin >>a>>b;
  if(a<10&&b<10) cout << a*b << endl;
  else cout << -1<< endl;

}



Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	int n; cin >> n;
	string s, t; cin >> s >> t;
	int i = 0, j = 0;
	string ans;
	while (i < n and j < n) {
		ans.push_back(s[i++]);
		ans.push_back(t[j++]);
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL);

int main() {
  FAST;
  int64_t X;
  cin >> X;
  int64_t happiness = 1000 * (X / 500) + 5 * (X % 500 / 5);
  cout << happiness << endl;
}

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

/*{
  }*/

using vi = vector<int>;
using vvi = vector<vi>;
using P = pair<int,int>;

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

  vi p(n), q(n);
  rep(i, 0, n) cin >> p[i];
  rep(i, 0, n) cin >> q[i];

  vi v(n);
  iota(all(v), 1);

  int a, b, i = 1;
  do{
    int cnt = 0;
    rep(i, 0, n) if(v[i] == p[i]) cnt++;
    if(cnt == n) a = i;
    cnt = 0;
    rep(i, 0, n) if(v[i] == q[i]) cnt++;
    if(cnt == n) b = i;
    i++;
  }while(next_permutation(all(v)));
  
  cout << (int)abs(a-b) << endl;

  return 0;
}



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

int main(){
    int N;
    cin >> N;
    double A[N];
    double ans = 0;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        ans += 1/A[i];
    }
    
    cout << 1/ans << "\n";
    return 0;
}


Measured memory_bytes: 256
import sys
import math
import fractions
import bisect
import queue
import heapq
import collections
import itertools
sys.setrecursionlimit(4100000)

MOD = int(1e9+7)
PI = 3.14159265358979323846264338327950288
INF = 1e18

'''
1行のint=====================================
N, K = map(int, input().split())
N, M = map(int, input().split())
A, B = map(int, input().split())

H, W = map(int, input().split())

L, R = map(int, input().split())

1行のstring=================================
S, T = input().split()

1行の整数配列================================
P = list(map(int,input().split()))

A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
D = list(map(int,input().split()))

L = list(map(int,input().split()))
R = list(map(int,input().split()))

T = list(map(int,input().split()))

改行あり整数==================================
X = []
Y = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    X.append(x1)
    Y.append(y1)

A = []
for i in range(N):
    a=int(input())
    A.append(a)

Pair = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    Pair.append((x1, y1))
    
2次元整数配列=====================================
A = []
for i in range(N):
    tmp = list(map(int,input().split()))
    A.append(tmp)


N行M列の初期化====================================
dp = [[VAL] * RETU for i in range(GYO)]

'''


N, K = map(int, input().split())

ans = 0

for i in range(K, N+2):

    lim = ((N  + N + 1 - i) * i) // 2 
    m = ((i - 1)         * i) // 2 

    ans += lim - m + 1
    ans %= MOD

print(ans)



Measured memory_bytes: 10716
N,K = map(int,input().split())
h = [int(i) for i in input().split()]

def chmin(a,b):
    if a > b:
        return b
    else:
        return a

dp = [float("inf") for _ in range(N)]
dp[0] = 0

for i in range(N-1):
    for k in range(1,chmin(K+1,N-i)):
        dp[i+k] = chmin(dp[i+k],dp[i]+abs(h[i]-h[i+k]))

print(dp[N-1])

Measured memory_bytes: 56928
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(a) (a).begin(), (a).end()
typedef vector<int> vi;
const int INF = 1LL << 60; //10e18+10e17ちょっとくらい
const int MOD = 1000000007;
const int MAX_N = 200100;

signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    double A, B, H, M;
    cin >> A >> B >> H >> M;

    double jit = 30. / 60.;
    double hunt = 6.;

    double tmp = 30. * H;
    H = tmp + jit * M;
    M = hunt * M;

    H = fmod(H, 360);
    M = fmod(M, 360);
    tmp = abs(H - M);
    tmp = min(tmp, 360. - tmp);
    tmp = cos(tmp * acos(-1) / 180.);

    double ans = sqrt(A * A + B * B - 2. * A * B * tmp);
    cout << setprecision(20) << ans << endl;
    return 0;
}

Measured memory_bytes: 4216
#include <cstdio>
using namespace std;
int mp[10][10],h,w,t,ans=0;
void floyd(){
	for(int k=0;k<10;k++)
		for(int i=0;i<10;i++)
			for(int j=0;j<10;j++)
				if(mp[i][k]+mp[k][j]<mp[i][j])
					mp[i][j]=mp[i][k]+mp[k][j];
}
int main()
{
	scanf("%d%d",&h,&w);
	for(int i=0;i<10;i++)
		for(int j=0;j<10;j++)
			scanf("%d",&mp[i][j]);
	floyd();
	while(w--){
		for(int i=0;i<h;i++){
			scanf("%d",&t);
			if(t==-1||t==1) continue;
			ans+=mp[t][1];
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
/*
* @Author Silviase(@silviasetitech)
* For ProCon
*/

import java.util.*;
import java.lang.*;
import java.math.*;

public class Main{

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = sc.nextInt();
        int itr = 0;
        int cnt = 0;
        long ans = 0;
        PriorityQueue<Integer> card = new PriorityQueue<>(Comparator.reverseOrder());
        for (int i = 0; i < n; i++) {
            card.add(sc.nextInt());
        }
        Pair[] pair = new Pair[m];
        for (int i = 0; i < m; i++) {
            pair[i] = new Pair(sc.nextInt(), sc.nextInt());
        }
        Arrays.sort(pair,Comparator.comparing(v -> -v.y)); // good

        while (cnt < n) {
            if (itr == m || (!card.isEmpty() && card.peek() >= pair[itr].y)) {
                /**
                 * not to change
                 */
                cnt++;
                long tmp = card.poll();
                /*
                System.out.println("tmp:" + tmp);
                */
                ans += tmp;
            }else{
                /**
                 * use Math.min(n-cnt, pair[itr].x) - cards
                 * if n-cnt > pair[itr].x, use all x - cards.
                 */
                int used = Math.min(n-cnt, pair[itr].x);
                cnt += used;
                ans += (long)pair[itr].y*(long)used;
                itr++;
            }
            /*
            System.out.println("Nowans:" + ans);
            */
        }
        System.out.println(ans);

        sc.close();
    }

    /**
     * Pair_int
     */
    public static class Pair {
        public int x;
        public int y;

        /**
         * Constructor 
         * Sample Code
         * 
         *      Pair[] pair = new Pair[5];
                for (int i = 0; i < 5; i++) {
                    pair[i] = new Pair(sc.nextInt(), sc.nextInt());
                }
                for (int i = 0; i < 5; i++) {
                    System.out.println(pair[i].x + " " + pair[i].y);
                }
         *
         */
        public Pair(int x, int y){
            this.x = x;
            this.y = y;
        }
        
        public String toString() {
            return "(" + x + ", " + y + ")";
        }


    }
}




Measured memory_bytes: 102920
// AOJ 2352 Divisor
// 2018.4.10 bal4u

#include <stdio.h>
#include <string.h>

#define MAX 202
int   hi[MAX],  to[MAX][MAX];
char seen[MAX];
int  match[MAX];

int bpm(int u);
int bipartiteMatching(int m, int n)
{
    int u, max;

    memset(match, -1, (m+n)*sizeof(int));
    max = 0;
    for (u = 0; u < m; u++) {
        memset(seen, 0, m+n);
        if (bpm(u)) max++;
    }
    return max;
}

int bpm(int u)
{
    int i, v;

    for (i = 0; i < hi[u]; i++) {
        v = to[u][i];
        if (seen[v]) continue;
        seen[v] = 1;
        if (match[v] < 0 || bpm(match[v])) {
            match[u] = v, match[v] = u;
            return 1;
        }
    }
    return 0;
}

//#define getchar_unlocked()  getchar()
int in()
{
    int n = 0, c = getchar_unlocked();
    do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
    return n;
}

int  x[102]; int N;
char f[102];
int  assign[102]; int sz;
int  a[102];

int calc(int n, int *a)
{
    int i, j;

    memset(hi, 0, (sizeof(int)*n)<<1);
    for (i = 0; i < n; i++) {
        for (j = 0; j < n; j++) if (j != i) {
            if (a[i] % a[j] == 0) to[i][hi[i]++] = n+j;
        }
    }
#if 0
for (i = 0; i < n; i++) {
    printf("[%d] hi %d: ", i, hi[i]);
    for (j = 0; j < hi[i]; j++) printf("%d ", to[i][j]);
    printf("\n");
}
#endif
    return n-bipartiteMatching(n, n);
}

int main()
{
    int i, j, k, ans;

    N = in();
    for (i = 0; i < N; i++) x[i] = in();

    // 課題文の条件を満たす集合Sの大きさを確定させる
    ans = calc(N, x);

    if (ans == 1) { puts("1"); return 0; }      // Sの大きさは1の場合、無条件にx[0]が答え

    memset(f, 1, N);    // f[i]=1：答えかその候補者、0：除外すべきx[i]

    sz = 0;             // 先頭x1から一つずつ確定していく。確定したx[i]の個数はsz
    for (i = 0; i < N; i++) {

        // x[i] を答えの集合Sに入れることができるか
        for (j = 0; j < i; j++) if (f[j]) {
            if (!(x[i] % x[j]) || !(x[j] % x[i])) break;
        }
        if (j < i) { f[i] = 0; continue; }      // 確定した集合Sの他メンバーと衝突するので不適合

        // x[i] を集合Sのメンバーにする
        k = 0; for (j = i+1; j < N; j++) if (f[j]) {
            if (x[i] % x[j] && x[j] % x[i]) {   // 残りのx[j]からx[i]と衝突しないものを選ぶ
                a[k++] = x[j];
            } else f[j] = 2;
        }
        
                                                // calc(k, a) は残りのx[j]で作れる集合の大きさ
        if (calc(k, a) + sz + 1 == ans) {       // 確定した集合Sの大きさ（=ans）と同じ
            // 結論として、x[i]を集合Sに入れるべきだ
            if (++sz == ans) break;
            for (j = i+1; j < N; j++) if (f[j] == 2) f[j] = 0;
        } else {
            // 結論として、x[i] は不適切で除外すべきだ
            f[i] = 0;
            for (j = i+1; j < N; j++) if (f[j] == 2) f[j] = 1;
        }
    }
    memset(f+i+1, 0, N-(i+1));                  // 残りのx[i]をすべて除外

    // 確定したx[i]を出力して終了
    k = 0; for (i = 0; i < N; i++) if (f[i]) {
        if (k) putchar(' '); else k = 1;
        printf("%d", i+1);
    }
    putchar('\n');
    return 0;
}



Measured memory_bytes: 2100
#include<stdio.h>
#include<stdlib.h>

int main(){
	int Vetor[10];
	
	
	for(int i = 0; i <6;i++){
		
		scanf("%d",&Vetor[i]);
	}
	int Maior = Vetor[0];
	int Minimo = Vetor[0];
	for(int i = 0; i <5;i++){
			
			if(Vetor[i] >= Maior ){
				Maior= Vetor[i];
			}
			if(Vetor[i] <= Minimo ){
				Minimo= Vetor[i];
			}
			
		
		
	}

	int Soma;
	Soma= Maior-Minimo;
	if(Soma <= Vetor[5])
	{
		printf("Yay!\n");
	}
	else
	{
		printf(":(\n");
	}
	
	
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>

#define MAX 2000001
#define VMAX 10000

int main(void)
{
  unsigned short *A, *B;
  
  int C[VMAX+1];
  int n, i, j;
  scanf("%d",&n);
  
  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);
  
  for(i=0;i<=VMAX;i++) C[i] = 0;
  
  for(i=0;i<n;i++) {
    scanf("%hu",&A[i+1]);
    C[A[i+1]]++;
  }
  
  for(i=1;i<=VMAX;i++) C[i] = C[i] + C[i-1];
  
  for(j=1;j<=n;j++) {
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
  
  for(i=1;i<=n;i++) {
    if(i>1) printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");
  
  return 0;
}


Measured memory_bytes: 9712
s = [list(map(int,input().split())) for i in range(2)]
nums = s[0][0]

a = 0
check = True
while check:
  for i in range(nums):
    if s[1][i] % 2 != 0:
      check = False
      break
  if check:
    for l in range(len(s[1])):
      s[1][l] /= 2
    a += 1
print(a)

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

int		main(void)
{
	char	a, tmp;
	for (int i = 0; i < 4; i++)
	{
		cin >> a;
		if (a == tmp)
		{
			cout << "Bad" << endl;
			return 0;
		}
		tmp = a;
	}
	cout << "Good" << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	    
		try {
			int lim = Integer.parseInt(in.readLine());
			
			int[] a = new int[lim];
			for (int i = 0; i < lim; i++) {
				a[i] = Integer.parseInt(in.readLine());
			}

			int max = -1000000000;
			int mini = a[0];
			for (int i = 0; i < lim; i++) {
				if (mini < a[i]) continue;
				else mini = a[i];
				for (int j = (i + 1); j < lim; j++) {
					int tmp = a[j] - a[i];
					if (max < tmp) max = tmp;
				}
			}
			System.out.println(max);
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 43488
m,k=map(int,input().split())
if m==0 and k==0:
  print(0,0)
elif m==1 and k==1:
  print(-1)
elif k>2**m-1:
  print(-1)
elif k==2**m-1:
  Ans=[]
  for i in range(2**m-1):
    Ans.append(2**m-2-i)
  Ans.append(2**m-1)
  for i in range(2**m):
    Ans.append(i)
  print(*Ans)
else:
  if k==0:
    Ans=[]
    for i in range(2**m):
      Ans.append(i)
      Ans.append(i)
    print(*Ans)
  else:
    Ans=[k]
    for i in range(2**m):
      if i!=k:
        Ans.append(i)
    Ans.append(k)
    for i in range(2**m):
      if i!=2**m-1-k:
        Ans.append(2**m-1-i)
    print(*Ans)

Measured memory_bytes: 19448