akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <unordered_map>
#define int long long int
#define double long double
#define endl "\n"
#define PI 3.141592653589793238462643383279502884
#define sp(x)   setprecision(x)
#define ceil(a,b)   (a+(b-1))/b
#define LCM(a,b)    (a*b)/__gcd(a,b)
#define all(v)  v.begin(),v.end()
#define alls(s,v)  s.begin(),s.end(),v
#define gena(arr,n,nxt)  generate(arr,arr+n, nxt)
#define genv(v,nxt)  generate(v.begin(),v.end(), nxt)
#define base ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define exit return 0;
using namespace std;
const int N=1000000;
bool prime[N];
void sieve()
{
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<100000000; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<100000; i += p)
                prime[i] = false;
        }
    }
}
int power(int x, int y)
{
    int res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = res * x;
        y = y >> 1;
        x = x*x;
    }
    return res;
}
int nxt()
{
    int x;
    cin >> x;
    return x;
}
int findTileCount(int x, int y, int l, int r)
{
    int lcm = (x * y) / __gcd(x, y);
    int countl = (l - 1) / lcm;
    int countr = r / lcm;
    return countr - countl;
}
int32_t main()
{
    base
    int n=nxt();
    int arr[n];
    int Max=0,Min=INT_MAX;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        Min=min(Min,arr[i]);
        Max=max(Max,arr[i]);
    }
    int mn=INT_MAX;
    for(int i=Min;i<=Max;i++){
        int cnt=0;
        for(int j=0;j<n;j++){
            cnt+=abs(i-arr[j])*abs(i-arr[j]);
        }
        mn=min(mn,cnt);
    }
    cout<<mn;
    exit
}



Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int a[3];
	for (int i = 0; i < 3; ++i)
	{
		scanf("%d", &a[i]);
	}

	if (a[0] + a[1] + a[2] != 17)
		printf("NO");

	else if (a[0] == 7 || a[1] == 7 || a[2] == 7)
	{
		if (a[0] == 5 || a[1] == 5 || a[2] == 5)
			printf("YES");
		else
			printf("NO");
	}
	else
		printf("NO");

	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define print(n) cout<<n<<endl
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
const int M=100111;
const int inf=1000000007;
const long long INF=1e18;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};

int main(){
	while(1){
		int w,d,h;
		int ans=0;
		vi vw={},vd={};
		cin>>w>>d;
		if(w==0&&d==0)break;
		rep(i,0,w){
			cin>>h;
			vw.push_back(h);
		}
		rep(i,0,d){
			cin>>h;
			vd.push_back(h);
		}
		vi v_ans={};
		rep(i,0,w){
			if(vd.size()==0)v_ans.push_back(vw[i]);
			rep(j,0,vd.size()){
				if(vw[i]==vd[j]){
					v_ans.push_back(vw[i]);
					vd.erase(vd.begin()+j);
					break;
				}
				if(j==vd.size()-1)v_ans.push_back(vw[i]);
			}
		}
		for(auto v:vd)v_ans.push_back(v);
		rep(i,0,v_ans.size())
			ans+=v_ans[i];
		print(ans);
	}
}


Measured memory_bytes: 3024
n, m = map(int , input().split())
ans  = 1
mod = 10**9+7
for i in range(1, n+1):
	ans = (ans%mod)*(i%mod)
	ans = ans%mod
for i in range(1, m+1):
	ans = (ans%mod)*(i%mod)
	ans = ans%mod
if abs(n-m)>1:
	print(0)
elif abs(n-m)==0:
	ans = ans*2
	ans = ans%mod
	print(ans)
else:
	print(ans)

Measured memory_bytes: 64088
(function(stdin){
	var lines = stdin.toString().split('\n')[0].split(' ').map(Number);
	var resolt = (function(a,b){
		return [~~(a / b),(a % b),(a/b).toFixed(5)];
	}(lines[0],lines[1])).join(' ');
	console.log(resolt);
}(require('fs').readFileSync('/dev/stdin','utf8')));

Measured memory_bytes: 7648
import sys

def sameside(x1, y1, x2, y2, ax, ay, bx, by):
    if x1 != x2:
        aupper = (ay > (y1-y2)/(x1-x2) * (ax-x1) + y1)
        bupper = (by > (y1-y2)/(x1-x2) * (bx-x1) + y1)
    else:
        aupper = ax < x1
        bupper = bx < x1
    return aupper == bupper

for line in sys.stdin:
    x1, y1, x2, y2, x3, y3, xp, yp = list(map(float, line.split()))
    if sameside(x1, y1, x2, y2, x3, y3, xp, yp) and sameside(x2, y2, x3, y3, x1, y1, xp, yp) and sameside(x3, y3, x1, y1, x2, y2, xp, yp):
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 7396
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()

typedef long long int ll;

//stack<char> stk;
//set<ll> sll;
//map<string,ll> mp,mp1;
//map<string,ll>::iterator iter;
//map<ll,ll> mp;
//deque<char> deq;
//priority_queue<double> pq;
ll num[ten52],g[ten52],g2[ten52];


ll gcd(ll n,ll m)
{
    while(n>0 && m>0)
    {
        if(n>m)
            n%=m;
        else
            m%=n;
    }
    return n+m;
}

int main(void)
{
    long long int m,n,i,j,k=1;
    string s;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>num[i];
        g[i]=gcd(g[i-1],num[i]);
    }
    for(i=n;i>0;i--)
    {
        g2[i]=gcd(g2[i+1],num[i]);
        k=max(k,gcd(g2[i+1],g[i-1]));
    }
    cout<<k;
    return 0;
}


Measured memory_bytes: 5924
x, y = [int(i) for i in input().split()]
if (2*x - y)%3 != 0:
    print(0)
elif (2*x - y < 0) or ((2*y - x) < 0):
    print(0)
else:
    LIM = 2*(10**6 + 5)
    fct = [1]*LIM
    inv = [1]*LIM
    MOD = 10**9 + 7
    for i in range(1, LIM):
        fct[i] = ((i%MOD)*(fct[i-1]%MOD))%MOD

    for i in range(1, LIM):
        inv[i] = (((inv[i-1])%MOD)*(pow(i, MOD-2, MOD)%MOD)%MOD)
    
    B = (2*x - y)//3
    A = x - (2*B)
    num = fct[A+B]
    den = ((inv[A]%MOD)*(inv[B])%MOD)%MOD
    print((((num)%MOD)*((den)%MOD))%MOD)


Measured memory_bytes: 73308
#include<iostream>

using namespace std;


int main(){

  int in, data[4];

  while(1){

    cin >> in;

    if(in == -1) break;

    int w = 1150;

    for(int i = 0; i < 3; i++){
      if(in >= 10) data[i] = 10;
      else data[i] = in;
      in -= 10;
    }
    data[3] = in;

    for(int i = 0; i < 4; i++){
      if(data[i] < 0) data[i] = 0;
    }

    w += 125 * data[1];
    w += 140 * data[2];
    w += 160 * data[3];
    w = 4280 - w;
    cout << w << endl;
  }

  return 0; 
}

Measured memory_bytes: 0
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)

	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}

	b := make([]int, 0, n)
	for _, v := range a {
		x := sort.Search(len(b), func(i int) bool {
			return b[i] < v
		})
		if x == len(b) {
			b = append(b, v)
		} else {
			b[x] = v
		}
	}

	fmt.Println(len(b))
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
const ll Mod = 998244353;
const ll Inf = 1e15;
const ll Log = 20;
const int Maxn = 1e5 + 10;
const int sig = 27;

const int Base = 101;

pll in[Maxn];

pll a[Maxn];

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n;
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> in[i].S;
	for(int i = 1; i <= n; i++) cin >> in[i].F;
	sort(in + 1, in + n + 1);
	for(int i = 1; i <= n; i++) a[i] = {in[i].S, i};
	sort(a + 1, a + n + 1);
	//for(int i = 1; i <= n; i++) cerr << in[i].F << ' ';
	//cerr << 'S' << '\n';
	for(int i = 1; i <= n; i++){
		//cerr << a[i].F << '\n';
		if(a[i].F > in[i].F) return cout << "No\n", 0;
	}
	for(int i = 1; i < n; i++){
		if(a[i + 1].F <= in[i].F) return cout << "Yes\n", 0;
	}
	
	ll nw = 1;
	ll cnt = 1;
	while(true){
		nw = a[nw].S;
		if(nw == 1) break;
		cnt ++;
	}
	//cerr << cnt << '\n';
	cout << (cnt == n ? "No" : "Yes");
	return 0;
}
/*
abacabacca

*/


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

using ll = long long;

const int N = 200005;

int n, a[N], c[26], d[26], e[26][N], q;
char s[N];
ll r;

struct BIT{
    int d[N];    
    void u(int x){ for(; x <= n; x += x & -x) d[x]++; }
    int g(int x){ int r = 0; for(; x; x &= x - 1) r += d[x]; return r; }
} B;

int main(){
    scanf("%s", s + 1);
    n = strlen(s + 1);
    for(int i = 1; i <= n; i++) c[s[i] - 'a']++;
    if(count_if(c, c + 26, [](int x){ return x & 1; }) != (n & 1)){
        puts("-1"); return 0;
    }
    for(int i = 1, x, v; i <= n; i++){
        v = s[i] - 'a';
        if(d[v] < c[v] / 2) x = e[v][d[v]] = ++q;
        else if((c[v] & 1) && (d[v] == c[v] / 2)) x = (n + 1) / 2;
        else x = n + 1 - e[v][c[v] - d[v] - 1];
        d[v]++;
        r += B.g(n) - B.g(x);
        B.u(x);
    }
    printf("%lld\n", r);
}

Measured memory_bytes: 19712
#include<bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define rep(i,n) for(ll i=0;i<n;i++)
#define vec vector<ll>
#define mat vector<vector<ll>>

using namespace std;
// using namespace atcoder;

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

int main(){

  string s;
  cin >> s;
  ll n=s.size();
  if(s[n-1]=='s')s=s+"es";
  else s=s+'s';

  cout << s << endl;

  return 0;
}

Measured memory_bytes: 3608
import kotlin.math.max

fun main(args: Array<String>) {
    val (n, m, k) = readIntList()
    val a = readLongList()
    val b = readLongList()

    val aa = mutableListOf(0L)
    val bb = mutableListOf(0L)
    for (i in 0 until n) {
        aa.add(aa[i] + a[i])
    }
    for (i in 0 until m) {
        bb.add(bb[i] + b[i])
    }

    var ans = 0
    var j = m
    for (i in 0..n) {
        if (aa[i] > k) break
        while (bb[j] > k - aa[i]) {
            j--
        }
        ans = max(ans, i + j)
    }
    println(ans)
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

Measured memory_bytes: 93916
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

int main() {
	int N, M;
	cin >> N >> M;
	cout << (N==M ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

int main() {
	long long int n=0,m,a,b,c,d,e;
	long double z,w;
	string str,str2,str3;
	char ch;
	long long int x[130]={};
	cout << fixed << setprecision(10);
	cin>>a>>b>>c;
	if(abs(a-b)<abs(a-c)){
		cout<<"A";
	}else{cout<<"B";}






	cout<<endl;
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int h, w; cin >> h >> w;
  vector<string> c(h);
  for (int i=0; i < h; i++) {
    cin >> c.at(i);
  }
  for (int i=0; i < h; i++) {
    cout << c.at(i) << endl;
    cout << c.at(i) << endl;
  }
}  


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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

int n,a,b,c,d;
string s;

bool sim(int a, int c) {
  for (int i = a; i <= c;) {
    if (i + 1 <= c && s[i+1] == '.') i++;
    else if (i + 2 <= c && s[i+2] == '.') i+= 2;
    else return false;
    if (i == c) break;
  }
  return true;
}

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  cin >> n >> a >> b >> c >> d >> s;
  a--,b--,c--,d--;

  if (!sim(a,c) || !sim(b,d)) {
    cout << "No" << endl;
    return 0;
  }

  if (c < d) {
    cout << "Yes" << endl;
    return 0;
  }

  int c = 0;
  for (int i = b-1; i <= d+1; i++) {
    if (s[i] == '.') c++;
    else c = 0;
    if (c == 3) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
int main()
{
  int a, b, c=0;
  scanf("%d%d%d",&a,&b,&c);
  if(a <= b && b <= c)
    printf("%d %d %d\n",a ,b ,c);
  else if(a >= b && b >= c)
	   printf("%d %d %d\n",c,b,a);
  else if(a <= c && c <= b)
	   printf("%d %d %d\n",a,c,b);
  else if (a >= c && c >= b)
	   printf("%d %d %d\n",b,c,a);
  else if(b <= a && a <= c)
	   printf("%d %d %d\n",b,a,c);
  else if(b >= a && a >= c)
	   printf("%d %d %d\n",c,a,b);
  return 0;
}

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

int main() {
	int N;
	cin>>N;
	int count=0;
	for(int i=1; i<=N; i++){
		if(i%2==1) count++;
	}
	double P=count/(double)N;
	cout<<P<<endl;
}

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

#define int long long
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vii vector<pi>
#define ps(x,y) fixed<<setprecision(y)<<x
#define w(t) int t;cin>>t;while(t--)solve()
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
//debug("Total Time: %.3f\n", (double)(clock() - z) / CLOCKS_PER_SEC);

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

void solve(){
	
}

int32_t main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	//clock_t z = clock();
	string s;
	cin>>s;
	int count=0;
	for (auto x : s)count+=x-'0';
	if (count%9)cout<<"No";
	else cout<<"Yes";

}


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

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

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#pragma region include

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
//////////////

void solve() {
	LL H, W;
	cin >> H >> W;
	if (H == 1 || W == 1) {
		cout << 1 << endl;
	}
	else {
		cout << (H * W + 1) / 2 << endl;
	}
}

#pragma region main
signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 256
(r, c) = [int(i) for i in input().split()]

table = []
for rc in range(r):
    table.append([int(i) for i in input().split()])

table.append([0 for _ in range(c + 1)])

for rc in range(r):
    row_total = 0
    for cc in range(c):
        table[r][cc] += table[rc][cc]
        row_total += table[rc][cc]

    table[rc].append(row_total)
    table[r][c] += row_total

for row in table:
    print(' '.join([str(column) for column in row]))

Measured memory_bytes: 6728
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int N; cin>>N;
	vector<int> a(N), b(N);
	ll sum_a = 0, sum_b = 0;
	rep(i,N){cin>>a[i]; sum_a += a[i];}
	rep(i,N){cin>>b[i]; sum_b += b[i];}
	if(sum_a<sum_b){cout<<-1<<endl; return 0;}
	vector<int> excess;
	int ans = 0;
	ll s = 0;
	rep(i,N){
		if(a[i] < b[i]){++ans; s += (ll)(b[i]-a[i]);}
		else {excess.push_back(a[i]-b[i]);}
	}
	sort(all(excess), greater<int>());
	for(auto x:excess){
		if(s<=0)break;
		s -= x;
		ans ++;
	}
	cout<<ans<<endl;
	return 0;
}

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

bool judgeLeapYear( int* a, int x, int n )
{
    for( int i = 0; i < n; i++ )
        if( x % a[i] == 0 )
        {
            if( ( i + 1 ) % 2 != 0 )
                return true;
            else
                return false;
        }
    if( n % 2 == 0 )
        return true;
    else
        return false;
}

int main()
{
    int a[50], n, x, y;

    while( cin >> n >> x >> y )
    {
        if( n + x + y == 0 )
            break;

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

        int cnt = 0;
        for( int i = x; i <= y; i++ )
            if( judgeLeapYear( a, i, n ) )
                cnt++;

        cout << cnt << endl;

    }
    return 0;
}


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

struct Node{
  int k;
  struct Node *right;
  struct Node *left;
  struct Node *parent;
};

struct Node *root, *NIL;

void Insert(int);
void Inorder(struct Node *);
void Preorder(struct Node *);
struct Node * Find(struct Node *, int);
void Delete(struct Node *);
struct Node * Minimum(struct Node *);
struct Node * Successor(struct Node *);

int main(){
  int i,n,value,findnum;
  char C1[10];

  scanf("%d",&n);

for(i=0;i<n;i++)

  for(i = 0 ; i < n ; i++){
    scanf("%s",C1);

    if(strcmp(C1,"insert") == 0){
      scanf("%d",&value);
      Insert(value);
    }
    else if(strcmp(C1,"print") == 0){
      Inorder(root);
      printf("\n");
      Preorder(root);
      printf("\n");
    }
    else if(strcmp(C1,"find") == 0){
      scanf("%d",&value);
      struct Node *F = Find(root,value);
      if(F != NIL) printf("yes\n");
      else printf("no\n");
    }
    else if(strcmp(C1,"delete") == 0){
      scanf("%d",&value);
      Delete(Find(root,value));
    }
  }

    return 0;
}

void Insert(int n){
struct  Node *p = root;
struct  Node *q = NIL;
struct  Node *r;

r = (struct Node *)malloc(sizeof(struct Node));
r -> k = n;
r -> left = NIL;
r -> right = NIL;

while(p != NIL){
   q = p;
   if(r->k < p->k){
     p = p -> left;
   }
   else{
     p = p -> right;
   }
}

r -> parent = q;
  if(q == NIL){
    root = r;
  }
  else{
    if(r->k < q->k){
      q -> left = r;
    }
    else{
      q -> right = r;
    }
  }
}

void Inorder(struct Node *x){
  if(x == NIL) return;
  Inorder(x -> left);
  printf(" %d",x -> k);
  Inorder(x -> right);
}

void Preorder(struct Node *x){
  if(x == NIL) return;
  printf(" %d",x -> k);
  Preorder(x -> left);
  Preorder(x -> right);
}

struct Node * Find(struct Node *x, int n){
  while(x != NIL && n != x -> k){
    if(n < x -> k ) x = x -> left;
    else x = x -> right;
  }
  return x;
}

void Delete(struct Node *x){
  struct Node *y;
  struct Node *z;

  if(x -> left == NIL || x -> right == NIL) y = x;
  else y = Successor(x);

  if(y -> left != NIL) z = y -> left;
  else z = y -> right;

  if(z != NIL) z -> parent = y -> parent;

  if(y -> parent == NIL){
    root = y;
  }
  else {
    if(y == y -> parent -> left) y -> parent -> left = z;
    else y -> parent -> right = z;
  }

  if(y != x) x -> k = y -> k;

  free(y);
}

struct Node * Minimum(struct Node *x){
  while(x -> left != NIL) x = x -> left;
  return x;
}

struct Node * Successor(struct Node *x){
  struct Node *y;

  if(x -> right != NIL) return Minimum(x -> right);

  y = x -> parent;
  while(y != NIL && x == y -> right){
    x = y;
    y = y -> parent;
  }
  return y;
}



Measured memory_bytes: 20476
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	s := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&s[i])
	}

	ans := exec(n, s)
	fmt.Println(ans)
}

func exec(n int, s []int) int {
	sort.Ints(s)

	bef := 0
	cnt := 0
	for _, n := range s {
		if n > bef {
			cnt++
		}
		bef = n
	}
	return cnt
}


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

int main() {
  int n;
  string s;
  cin >> n >> s;
  int red = 0;
  int blue = 0;
  for(int i=0;i<s.size();i++) {
    if(s[i] == 'R') red++;
    else blue++;
  }

  cout << ((red > blue) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

struct card
{
	int rank;
	char suit;
};

int main(void)
{
	char trump;
	char led;
	string s;
	card c[4][13];
	int maxx,maxS;
	int NS,EW;
	int i1,i2;

	while(1){
		cin>>trump;
		if(trump=='#') break;

		for(i1=0;i1<4;i1++){
			for(i2=0;i2<13;i2++){
				cin>>s;
				if('2'<=s[0] && s[0]<='9') c[i1][i2].rank=s[0]-48;
				else if(s[0]=='A') c[i1][i2].rank=14;
				else if(s[0]=='T') c[i1][i2].rank=10;
				else if(s[0]=='J') c[i1][i2].rank=11;
				else if(s[0]=='Q') c[i1][i2].rank=12;
				else c[i1][i2].rank=13;

				c[i1][i2].suit=s[1];
			}
		}

		NS=-6;
		EW=-6;
		for(i1=0;i1<13;i1++){
			maxx=0;
			if(i1==0) led=c[0][0].suit;
			else led=c[maxS][i1].suit;
			for(i2=0;i2<4;i2++){
				if(trump==c[i2][i1].suit) c[i2][i1].rank+=26;
				else if(led==c[i2][i1].suit) c[i2][i1].rank+=13;
				
				if(maxx<c[i2][i1].rank){
					maxx=c[i2][i1].rank;
					maxS=i2;
				}
			}
			if(maxS%2==0) NS++;
			else EW++;
		}

		if(NS>EW) cout<<"NS "<<NS<<endl;
		else cout<<"EW "<<EW<<endl;
	}
	return 0;
}

Measured memory_bytes: 1184
import sys
N = int(input())
L = [i for i in range(1, N+1) if i % 2 != 0]
ans = 0
if N < 105:
    print(0)
    sys.exit(0)
for num in L:
    counter = 1
    for i in range(1, num//2):
        if num % i == 0:
            counter += 1
    if counter == 8:
        ans += 1
print(ans)

Measured memory_bytes: 9096
#include<iostream>
#include<set>
using namespace std;
int main(){
  
  int n,a,b;
  set<int> se;

  cin >> n;
  while(n--){
    cin >> a >> b;
    if(a == 0){
      se.insert(b);
      cout << se.size() << endl;
    }
    if(a == 1){
      if(se.find(b) != se.end()) cout << 1 << endl;
      else cout << 0 << endl;
    }
    if(a == 2){
      se.erase(b);
    }
  }
  
  return(0);
}



Measured memory_bytes: 12480
#include <iostream>

using namespace std;

int main(){
	int x;

	cin >> x;

	if (x % 7 == 2){
		cout << "sat" << endl;
	}else if (x % 7 == 1){
		cout << "fri" << endl;
	}else if (x % 7 == 3){
		cout << "sun" << endl;
	}else if (x % 7 == 4){
		cout << "mon" << endl;
	}else if (x % 7 == 5){
		cout << "tue" << endl;
	}else if (x % 7 == 6){
		cout << "wed" << endl;
	}else {
		cout << "thu" << endl;
	}
}

Measured memory_bytes: 3100
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    int a,b,q;
    string str,ord,c;
    cin >> str;
    cin >> q;
    for(int i=0;i<q;i++){
        cin >> ord >> a >> b;
        if(ord == "print"){
            cout << str.substr(a,b-a+1) << endl;
        }else if(ord == "reverse"){
            string tmp = str.substr(a, b-a+1);
            reverse(tmp.begin(), tmp.end());
            str = str.replace(a, b-a+1, tmp); 
        }else{
            cin >> c;
            str = str.replace(a, b-a+1, c);
        }
        
    }
    
}


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

using namespace std;

const int INF = 0x0fffffff;

typedef long long ll;

int N;
int T;

ll A[100005];
ll B[100005];

void slove() {
}

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

    cin >> N >> T;

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

    fill(B, B+N, 0);

    //for (int i = 0; i < N; ++i) {
    //    for (int j = i; j < N; ++j) {
    //        B[i] = max(B[i], A[j] - A[i]);
    //    }
    //}
    
    ll mv = A[N-1];

    for (int i = N-1; i >= 0; --i) {
        mv = max(mv, A[i]);
        B[i] = mv - A[i];
    }

    //for (int i = 0; i < N; ++i) {
    //    cout << A[i] << " " << B[i] << endl;
    //}

    sort(B, B+N);
    reverse(B, B+N);

    int rv = 1;

    for (int i = 1; i < N; ++i) {
        if (B[i] == B[0]) {
            rv++;
        } else {
            break;
        }
    }

    cout << rv << endl;

    return 0;
}


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

int64_t MOD = 1000000007;
int64_t MAX = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    int64_t A, B, C;
    cin >> A >> B >> C;
    if (4 * A * B < (C - A - B) * (C - A - B) && C - A - B > 0)
        cout << "Yes";
    else
        cout << "No";
}

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

const int MAX = 210000;
const int MOD = 998244353;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    int N,M,K;
    cin >> N >> M >> K;
    COMinit();
    ll ans = 0;
    ll Mminus1[N];
    Mminus1[0] = 1;
    for (int i = 1; i < N; i++)
    {
        Mminus1[i]=Mminus1[i-1]*(M-1)%MOD;
    }
    for (int k = 0; k <= K; k++)
    {
        ans += M*COM(N-1,k)%MOD*Mminus1[N-1-k]%MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 10100
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 998244353;
using ll = int64_t;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T>
T pow_ (T x, T n, T M){
    uint64_t u = 1, xx = x;
    while (n > 0){
        if (n&1) u = u * xx % M;
        xx = xx * xx % M;
        n >>= 1;
    }
    return static_cast<T>(u);
};

template <class T> class Factorial {
    T mod;
    vector<uint64_t> facts, factinv;

public:
    Factorial(int n, T mod) : facts(static_cast<u32>(n+1)), factinv(static_cast<u32>(n+1)), mod(mod) {
        facts[0] = 1;
        for (int i = 1; i < n+1; ++i) facts[i] = facts[i-1]*i % mod;
        factinv[n] = pow_(facts[n], static_cast<uint64_t>(mod - 2), static_cast<uint64_t>(mod));
        for (int i = n-1; i >= 0; --i) factinv[i] = factinv[i+1] * (i+1) % mod;
    }

    T fact(int k) const {
        if(k >= 0) return static_cast<T>(facts[k]);
        else return static_cast<T>(factinv[-k]);
    }

    T operator[](const int &k) const {
        if(k >= 0) return static_cast<T>(facts[k]);
        else return static_cast<T>(factinv[-k]);
    }

    T C(int p, int q) const {
        if(q < 0 || p < q) return 0;
        return static_cast<T>(facts[p]*  factinv[q] % mod * factinv[p-q] % mod);
    }

    T P(int p, int q) const {
        if(q < 0 || p < q) return 0;
        return static_cast<T>((facts[p] * factinv[p-q]) % mod);
    }

    T H(int p, int q) const {
        if(p < 0 || q < 0) return 0;
        return static_cast<T>(q == 0 ? 1 : C(p+q-1, q));
    }
};


int main() {
    Factorial<ll> f(10000, MOD);
    int k, n;
    cin >> k >> n;
    vector<int> cnt(2*k+1);
    vector<int> d(k+1, 1);
    for (int i = 0; i < k; ++i) {
        d[i+1] = d[i]*2%MOD;
    }
    for (int i = 1; i <= k; ++i) {
        for (int j = i+1; j <= k; ++j) {
            cnt[i+j]++;
        }
    }
    for (int i = 2; i <= 2*k; ++i) {
        ll ans = 0;
        int p = cnt[i];
        for (int q = 0; q <= p; ++q) {
            if(i%2){
                (ans += (f.C(p, q)*d[q])%MOD*f.H(k-2*p+q, n-q)) %= MOD;
            }else {
                (ans += (f.C(p, q)*d[q])%MOD*f.H(k-2*p+q-1, n-q)) %= MOD;
                (ans += (f.C(p, q)*d[q])%MOD*f.H(k-2*p+q-1, n-q-1)) %= MOD;
            }
        }
        cout << ans << "\n";
    }
    return 0;
}


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

int main(){
	int n,ba,a[10];
	string s;
	while(cin >> n,n){
		cin >> s;
		ba = 0;
		for(int i = 0;i < 10;i++) a[i] = 0;
		for(int i = 0;i < 100;i++){
			if(s[i] == 'S'){
				ba += a[i % n] + 1;
				a[i % n] = 0;
			}
			else if(s[i] == 'L'){
				a[i % n] += ba + 1;
				ba = 0;
			}else a[i % n]++;
		}
		sort(a,a + n);
		cout << a[0];
		for(int i = 1;i < n;i++) cout << " " << a[i];
		cout << " " << ba << endl;
	}
	return 0;
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
    
    string S;
    cin >> S;

    bool ok = (S[2] == S[3] && S[4] == S[5]);
    cout << (ok?"Yes\n":"No\n");
    
    return 0;
}

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

using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;



    for (int i = 1; i <= 1300; i++)
    {
        if( floor(i*0.08) == a and floor(i*0.1) == b)
        {
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long a = sc.nextLong();
		long b = sc.nextLong();
		long ans ;
		if((b-a)%2==0) {
			ans = (b-a)/2;
		}
		else {
			ans = Math.min(a-1, n-b)+(b-a)/2+1;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23764
#include <stdio.h>
#define N 200000
int main()
{
    int max,min,n,i,a[N];
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&a[i]);
    min=a[0];
    max=-100000000000;
    for (i=1;i<n;i++){
            if (max<a[i]-min)max=a[i]-min;
            if (min>a[i])min=a[i];
        }   
    printf("%d\n",max); 
    return 0;
}

Measured memory_bytes: 1376
import java.util.*;
class Main{
    static Scanner sc=new Scanner(System.in);
    public static void main(String[] args){
        int X = sc.nextInt();
        int Y = sc.nextInt();
        int Z = sc.nextInt();
        int x,y,z;
        x=Z;
        y=X;
        z=Y;
        System.out.println(x+" "+y+" "+z);
    }
}

Measured memory_bytes: 21844
ar = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

K = int(input())
print(ar[K-1])

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define flash ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)
 
int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;
int help(int x,int y,int k)
{
	int res=1;
	while(y>0)
	{
		if(y&1)
		{
			(res*=x)%=k;
		}
		(x*=x)%=k;
		y/=2;
	}
	res%=k;
	//return res;
	int xxx = (res-1+k)%k;
	return (xxx==0);
}		
signed main()
{
    flash
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		int k;
		cin>>k;
		if(k%2==0)
		{
			cout<<-1;
		}
		else
		{
			if(k%7==0)
			k/=7;
			int res = 1;
			for(int i=1;i<=k;++i)
			{
				(res*=10)%=(9*k);
				int temp = (res-1+(9*k))%(9*k);
				if(temp==0)
				{
					cout<<i;
					return 0;
				}
			}
			cout<<-1;
		}
		cout<<"\n";
		//cout<<help(2,5,mod);		
    }
    return 0;
}

Measured memory_bytes: 3656
import java.io.IOException;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		int n = sc.nextInt();
		boolean flag = false;
		for(int i = 0; i < n; i++) {
			int s = sc.nextInt();
			int f = sc.nextInt();
			
			if(s <a && a < f || a <= s && s < b) {
				flag = true;
			}
		}
		
		int ans = flag? 1 : 0;
		System.out.println(ans);
	}
}


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

int score(int x)
{
    if (x == 1)
    {
        return 300000;
    }
    if (x == 2)
    {
        return 200000;
    }
    if (x == 3)
    {
        return 100000;
    }
    return 0;
}

int main()
{
    int X, Y;
    cin >> X >> Y;

    int ans = score(X) + score(Y);
    if (X == 1 && Y == 1)
    {
        ans += 400000;
    }
    cout << ans << endl;
}


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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int N;
    cin>>N;
    vector<int> A(N);
    REP(i,N) cin >> A[i];
    sort(ALL(A));
    vector<ll> sum(N+1,0);
    REP(i,N) {
        sum[i+1] = sum[i] + A[i];
    }

    int ok = N;
    int ng = -1;

    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        bool flag = true;
        ll big = sum[mid + 1];
        for (int i = mid + 1; i < N; i++) {
            if (big*2 >= A[i]) {
                big += A[i];
            }
            else {
                flag = false;
                break;
            }
        }
        if (flag) {
            ok = mid;
        }
        else {
            ng = mid;
        }
    }
    
    cout << N - ok << endl;
    return 0;
}

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

#define int long long

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

int N;
int A[100000], appear[100000] = {};

signed main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        appear[A[i]]++;
    }
    int sum = 0, extra = 0;
    for (int i = 0; i < 100000; i++) {
        if (appear[i] != 0) {
            sum++;
            extra += appear[i] - 1;
        }
    }
    cout << sum - extra % 2 << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/


int main(){
    int H, W; cin >> H >> W;
    vector<vector<char>> fi(H+5, vector<char>(W+5, '#'));
    for(int i=1; i<=H; i++) for(int j=1; j<=W; j++) cin >> fi[i][j];

    vector<vector<int>> dpL(H+5, vector<int>(W+5, 0)), dpR(H+5, vector<int>(W+5, 0)), dpU(H+5, vector<int>(W+5, 0)), dpD(H+5, vector<int>(W+5, 0));

    for(int i=1; i<=H; i++){
        for(int j=1; j<=W; j++){
            if(fi[i][j] == '#') dpL[i][j] = 0;
            else{
                dpL[i][j] = dpL[i][j-1]+1;
            }
        }
    }

    for(int i=1; i<=H; i++){
        for(int j=W; j>=1; j--){
            if(fi[i][j] == '#') dpR[i][j] = 0;
            else dpR[i][j] = dpR[i][j+1]+1;
        }
    }

    for(int j=1; j<=W; j++){
        for(int i=1; i<=H; i++){
            if(fi[i][j] == '#') dpU[i][j] = 0;
            else dpU[i][j] = dpU[i-1][j]+1;
        }
    }

    for(int j=1; j<=W; j++){
        for(int i=H; i>=1; i--){
            if(fi[i][j] == '#') dpD[i][j] = 0;
            else dpD[i][j] = dpD[i+1][j]+1;
        }
    }

    ll ans = 0;
    for(int i=1; i<=H; i++){
        for(int j=1; j<=W; j++){
            if(fi[i][j] == '#') continue;
            else {
                ll tmp = (dpU[i][j]-1)+(dpD[i][j]-1)+(dpR[i][j]-1)+(dpL[i][j]-1)+1;
                ans = max(ans, tmp);
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 67328
#include <stdio.h>

int main(void)
{
	int A, B, C, D;

	scanf("%d %d %d %d", &A, &B, &C, &D);

	for(int count=0 ;A>0 && C>0; count++)
	{
		
		if(count%2 == 1)
		{
			A = A - D;
		}
		else
		{
			C = C - B;
		}
		
	}
	
	if(A<=0)
	{
		printf("No\n");
	}
	
	if(C<=0)
	{
		printf("Yes\n");
	}
	
	return 0;
}

Measured memory_bytes: 1664
/*Coded by::
    **Avinash Tiwary**
    **BE/10298/2015**
    **Production Engineer**
    **Producing <code>**
*/
#include<bits/stdc++.h>
#define buf ios_base::sync_with_stdio (0), cin.tie (0)
typedef long long ll;
typedef double dob;
#define MAX 50010
#define M5 200009
#define M6 2000009
#define M 1000000007
#define inf LLONG_MAX
using namespace std;
typedef vector<ll> V;
typedef queue<ll > Q;
typedef stack<ll> S;
typedef pair<ll,ll> P;
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
ll fac[M6],not_prime[M6];
ll power(ll x,ll n){
    if(x==0) return 0;
    if(n==0) return 1;
    /*while(n){
        if(n%2) x=(((x*x)%M)*x)%M; 
        else x=(x*x)%M;
        n/=2;
    }*/
    if(n%2 == 0) return power((x*x),n/2);
    else return (x*power((x*x),(n-1)/2));
}
void fact(){
    fac[0]=1;
    for(ll i=1;i<M6;i++) fac[i]=(i*fac[i-1])%M;
}
void sieve(){
    not_prime[1]=1; not_prime[0]=1;
    for(ll p=2;p*p<M6;p++){
        if(!not_prime[p]){
            for(ll i=p*2;i<=M6;i+=p) not_prime[i]=1;
        }
    }
}
ll modi(ll a, ll m){
    ll m0 = m, t, q; ll x0 = 0, x1 = 1;
    if (m == 1) return 0;
    while (a > 1){  q = a / m; t = m; m = a % m, a = t;t = x0;x0 = x1 - q * x0; x1 = t;}
    if (x1 < 0) x1 += m0;return x1;
}
ll n,m,cost[10][10];
int main(){
    buf; 
    //sieve(); 
    //fact();
    ll i,j,k,test,flag,h,w,ans; string s;
    //cin>>test;
    test=1;
    while(test--){
    	cin>>h>>w;
    	for(i=0;i<10;i++){
    		for(j=0;j<10;j++) cin>>cost[i][j];
    	}
    	for(k=0;k<10;k++)
    	for(i=0;i<10;i++){
    		for(j=0;j<10;j++){
    			cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j]);
    		}
    	}
    	ans=0;
    	for(i=1;i<=h;i++){
    		for(j=1;j<=w;j++) {cin>>k; if(k!=-1) ans+=cost[k][1];}
    	}
    	cout<<ans;
    }
    return 0;
}


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

int main() {
  int a, b, c, d, e, k;
  std::cin >> a >> b >> c >> d >> e >> k;

  if(e - a > k) {
    std::cout << ":(" << std::endl;
  } else {
    std::cout << "Yay!" << std::endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repi(i,x,n) for(ll i=x;i<(ll)(n);i++)
#define lb lower_bound
#define ub upper_bound
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
//cin.tie(0);ios::sync_with_stdio(false);



signed main(){
  ll a,b;cin>>a>>b;
  
  if(a*b<=0){
    cout<<"Zero"<<endl;
  }else{
    if(b<0 && (b-a)%2==0){
      cout<<"Negative"<<endl;
    }else{
      cout<<"Positive"<<endl;
    }
  }
}

Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <typeinfo>
#include <queue>

using namespace std;

//typedef long long ll;
int main(){
	int n;
	int result = 0;
	string s;
	cin >> s;
	int g_num = 0;
	n = s.size();
	for(int i =0; i < n; i++){
		if(g_num>0){
			if(s[i]=='g'){
				result++;
			}
			g_num--;
			//cout << i << "p" << result << endl;
		}
		else{
			g_num++;
			if(s[i]=='p'){
				result--;
			}
			//cout << i << "g" << result << endl;
		}
	}
	cout << result << endl;
	return 0;
}


Measured memory_bytes: 512
N = int(input())
A = list(map(int,input().split()))

li1 = [i+1-A[i] for i in range(N)]
li2 = [A[i]+i+1 for i in range(N)]

cnt = [0 for i in range(2*N+1)]
for i in li2:
    if i<len(cnt)-1:
        cnt[i] += 1

ans = 0
for i in li1:
    if i>=0:
        ans += cnt[i]
print(ans)



Measured memory_bytes: 37736
S = input()
ret = [0] * len(S)
cont_R = 0
idx_R = 0
cont_L = 0

for i,s in enumerate(S):
    if s == 'R':
        cont_L = 0
        cont_R += 1
        idx_R = i
        idx_L = i+1
    elif s == 'L':
        if idx_L == i:
            q = cont_R//2
            r = cont_R%2
            ret[idx_R] = q+r
            ret[idx_L] = q
            # print(ret,idx_R,idx_L)
        cont_R = 0
        cont_L += 1
        if cont_L % 2 == 1:
            ret[idx_L] += 1
        else:
            ret[idx_R] += 1

print(' '.join(map(str, ret)))

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

#define INF_LL (ll)1e18
#define INF (int)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}
string s;
ll dp[20][2] = {};

ll dfs(int dig, int tight){
	if(~dp[dig][tight]) return dp[dig][tight];
	if(dig == s.size()) return 0;
	int next = tight ? s[dig]+1 : 10;

	ll ret = 0;
	REP(i, next){
		ret = max(ret, dfs(dig+1, tight && i == next-1)+i);
	}
	return dp[dig][tight] = ret;
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> s;
	memset(dp, -1, sizeof dp);
	REP(i, s.size())
		s[i] -= '0';

	cout << dfs(0, 1) << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  int r, g, b;
  cin >> r >> g >> b;
  if ((r*100+g*10+b)%4==0) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 3632
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
from decimal import *

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	N = inputInt()
	ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
	soezi = [i for i in range(26)]
	soezi = [26] + soezi

	ans = ""
	tmp = N
	while True:
		if tmp == 0:
			break
		tmp2 = tmp % 26
		ans = ascii_lowercase[tmp2-1] + ans

		tmp = tmp - soezi[tmp2]
		tmp = tmp // 26

	print(ans)



#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()


Measured memory_bytes: 77244
#include <stdio.h>
#define N 1000000000000001
#define inverse(a,n) for(int i = 0; i < (n) >> 1; i++) {int t = a[i]; a[i] = a[n - i - 1]; a[n - i - 1 ] = t;}
typedef long long ll;

int top;
char s[100000] = {0};
int main()
{
    ll n;
    char dict[] = "abcdefghijklmnopqrstuvwxyz";

    scanf("%lld", &n);

    while(n > 0)
    {
        s[top++] = dict[(n - 1) % 26];
        n--;
        n /= 26;
    }
    inverse(s,top);
    for(int i = 0; i < top; i++) printf("%c", s[i]);

    return 0;
}

Measured memory_bytes: 1664
a, b, c, d, e, f= (int(i) for i in input().split()) 

waterlist=[]
for i in range(0,int(f/100/a)+1):
  for j in range(0,int(f/100/b)+1):
    if 100*a*i+100*b*j <=f:
      waterlist+=[100*a*i+100*b*j]
waterlist=list(set(waterlist))
#print(x)

sugarlist=[]
for i in range(int(f/c)+1):
  for j in range(int(f/d)+1):
    if c*i+d*j <=f:
      sugarlist+=[c*i+d*j]
sugarlist=list(set(sugarlist))
#print(y)

density=0

for i in range(len(waterlist)):
  for j in range(len(sugarlist)):
    if 0 < waterlist[i]+sugarlist[j] <= f and sugarlist[j]<=waterlist[i]/100*e:
      tmp=sugarlist[j]/(waterlist[i]+sugarlist[j])
      if density <= tmp:
        density = tmp
        ans1=waterlist[i]+sugarlist[j]
        ans2=sugarlist[j]
        
print(ans1,ans2)


Measured memory_bytes: 12456
#include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 5;
int a[N];
int main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  cout << endl;
  long long ans = 0;
  for (int i = 0; i + 2 < n; i++) {
    for (int j = i + 1; j + 1 < n; j++) {
      ans += lower_bound(a + j + 1, a + n, a[i] + a[j]) - (a + j + 1);
    }
  }
  cout << ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}       
////////////////////////////////////////////////////////////////////
int x[10],y[10];
int n;
double dist(int i, int j) 
{
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return pow(dx * dx + dy * dy, 0.5);
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  int t=1;
  while(t--)
  {
      cin>>n;
      FOR(i,1,n)
      {
          cin>>x[i]>>y[i];
      }
      double ans=0.0;
      for(int i=1;i<=n;i++)
      {
          for(int j=i+1;j<=n;j++)
          {
              ans+=dist(i,j)*2/n;
          }
      }
      cout<<fixed<<setprecision(10)<<ans<<"\n";
  }
  return 0;
}

Measured memory_bytes: 512