akhauriyash/Code-Regression huggingface dataset:
<?php
list($N, $G) = ints();
for($i = 0; $i < $N; $i++){
    list($C[], $B[]) = ints();
}
$min = 10**10;
for($i = 0; $i < 2**$N; $i++){
    $c = 0;
    $score = 0;
    $bits = sprintf("%0{$N}b", $i);
    for($j = 0; $j < $N; $j++){
        if($bits[$j]){
            $c+=$C[$j];
            $score+=$C[$j]*($j+1)*100+$B[$j];
        }
    }
    for($j = $N-1; $j >= 0; $j--){
        if($bits[$j] == 0){
            for($k = 0; $k < $C[$j]-1; $k++){
                if($score < $G){
                    $c++;
                    $score+=($j+1)*100;
                }
            }
        }
    }
    if($score>=$G){
        chmin($min, $c);
    }
}
echo $min,"\n";

function str(){return trim(fgets(STDIN));}
function ints(){return array_map('intval',explode(' ',trim(fgets(STDIN))));}
function int(){return intval(trim(fgets(STDIN)));}
function chmax(&$a,$b){if($a<$b){$a=$b;return 1;}return 0;}
function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}
function popcount($x){$c=0;while($x){$x&=$x-1;++$c;}return$c;}
function o(...$val){
    if(count($val)==1)$val=array_shift($val);
    echo debug_backtrace()[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0)echo "empty array";
        elseif(!is_array(current($val)))echo "array: ",implode(" ", addIndex($val)),"\n";
        else{
            echo "array:array\n";
            if(isCleanArray($val))foreach($val as $row)echo implode(" ", addIndex($row)),"\n";
            else foreach($val as $i => $row)echo "[".$i."] ".implode(" ", addIndex($row)),"\n";
        }
    }else echo $val."\n";
}
function addIndex($val){if(!isCleanArray($val)){$val = array_map(function($k, $v){return $k.":".$v;}, array_keys($val), $val);}return $val;}
function isCleanArray($array){$clean=true;$i = 0;foreach($array as $k=>$v){if($k != $i++)$clean = false;}return $clean;}
// 座圧対象の配列 -> [圧縮された配列,復元用のMap,圧縮用のMap]
function atsu($array){$a = array_flip($array);$fuku=array_flip($a);sort($fuku);$atsu = array_flip($fuku);foreach($array as $i=>$val)$array[$i]=$atsu[$val];return [$array, $fuku, $atsu];}
function gcdAll($array){$gcd=$array[0];for($i=1,$I=count($array);$i<$I;++$i){$gcd=gcd($gcd,$array[$i]);}return $gcd;}
function gcd($m, $n){if(!$n)return $m;return gcd($n, $m % $n);}
function lcmAll($array){$lcm=$array[0];for($i=1,$I=count($array);$i<$I;++$i){$lcm=lcm($lcm,$array[$i]);}return $lcm;}
function lcm($a, $b) {return $a / gcd($a, $b) * $b;}

function dfs($current, $from = -1, $d = 0){
  global $G, $distance;
  $distance[$current] = $d;
  foreach($G[$current] as $to){
    if($from != $to){
      dfs($to, $current, $d + 1);
    }
  }
}

function loadTree($N = false){
  if($N === false)$N = $GLOBALS['N'];
  return loadGraph($N, $N-1);
}
function loadGraph($N = false, $M = false, $both = true){
  if($N === false)$N = $GLOBALS['N'];
  if($M === false)$N = $GLOBALS['M'];
  $G = array_fill(1, $N, []);
  for($i = 0; $i < $M; $i++){
    $values = ints();
    if(count($values) == 2){
      list($a, $b) = $values;
      $G[$a][] = $b;
      if($both)$G[$b][] = $a;
    }else{
      list($a, $b, $d) = $values;
      $G[$a][] = [$b, $d];
      if($both)$G[$b][] = [$a, $d];
    }
  }
  return $G;
}


Measured memory_bytes: 4728
#include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#define FOR(i, a, b)  for(int i=a; i<b; ++i)
#define rFOR(i, a, b) for(int i=a-1; i>=b; --i)
#define REP(i, n) for(int i=0; i<n; ++i)
#define rREP(i, n) for(int i=n-1; i>=0; --i)
#define all(a)  a.begin(), a.end()
using namespace std;

int main(){
  int a, b; cin >> a >> b;
  int towerLen[1000];
  towerLen[0] = 0;
  FOR(i, 1, 1000){
    towerLen[i] = i + towerLen[i-1];
  }
  FOR(i, 1, 999){
    if(towerLen[i]-a == towerLen[i+1]-b){
      cout << towerLen[i]-a << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
/* vim:set foldmethod=marker: */
#include <bits/stdc++.h>
using namespace std;

//{{{
#define all(x) (x).begin(),(x).end()
#define REP(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define RREP(i,a,b) for(int i=(int)(a); i>=b; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,n,0)
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vp;

#define dump(x) (cerr << #x << "=" << x << endl)
template<class T> ostream& osContainer(ostream& os,T c) { os<<'[';for(decltype(c.begin()) it=c.begin();it!=c.end();it++)os<<*it<<',';os<<']';return os; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { return osContainer(os,v); }
template<class T> ostream& operator<<(ostream& os,const set<T>& s) { return osContainer(os,s); }
template<class T> ostream& operator<<(ostream& os,const multiset<T>& s) { return osContainer(os,s); }
template<class T,class S> ostream& operator<<(ostream& os,const map<T,S>& m) { return osContainer(os,m); }
template<class T,class S> ostream& operator<<(ostream& os,const multimap<T,S>& m) { return osContainer(os,m); }
template<class T1,class T2>
ostream& operator<<(ostream& os, const pair<T1,T2>& p){ os << '(' << p.first << ',' << p.second << ')'; return os; }

const int dx[] = {0,1,0,-1};
const int dy[] = {1,0,-1,0};
//}}}
//
vector<int> r[51];

void solve(){
    int n,m;
    cin >> n >> m;


    rep(i,m) {
        int a,b;
        cin >> a >> b;
        r[a].push_back(b);
        r[b].push_back(a);
    }

    REP(i,1, n+1){
        cout << r[i].size() << endl;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(12);
    solve();
}


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

int n, m, h[100001];
vector<int> adj[100001];

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

    cin >> n >> m;
    for(int i = 1; i <= n; i++) cin >> h[i];
    for(int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    int ans = 0;
    for(int i = 1; i <= n; i++) {
        bool ok = true;
        for(int j = 0; j < adj[i].size(); j++) {
            if(h[i] <= h[adj[i][j]]) ok = false;
        }
        if(ok) ans++;
    }

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 9172
from itertools import combinations

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

result = 0
for lines in combinations(L, 3):
    if len(set(lines)) != 3:
        continue

    a, b, c = lines
    if a + b > c and b + c > a and c + a > b:
        result += 1

print(result)


Measured memory_bytes: 9180
#include<bits/stdc++.h>
#define LL long long
using namespace std;
long long x,n,T;
int main(){
	cin>>n>>T;
	long long last=0,ans=0;
	for(int i=1;i<=n;i++){
		cin>>x;
		if(last<=x){
			last=x+T;
			ans+=T;
		}
		else if(last>(x+T)){
			ans+=(last-(x+T));
		}
		else{
			ans+=(x+T-last);
			last=x+T;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
import math

def isprime(x):
  if x == 2:
    return True
  if x < 2 or x % 2 == 0:
    return False

  i = 3
  while i <= math.sqrt(x):
    if x % i == 0:
      return False
    i += 2

  return True


n = int(input())
prime_count = 0

for i in range(n):
  x = int(input())
  if isprime(x):
    prime_count += 1

print(prime_count)



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

using namespace std;

typedef long long ll;
typedef double dd;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

#define FOR(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
#define DOW(i,b,a) for (int i = (b); i >= (a); i--)
#define pb(a) push_back(a)
#define ALL(a) (a).begin(),(a).end()
#define fi first
#define se second

template<typename T>
void print_array(T* arr, int num) {
   FOR(i, 0, num) cout << arr[i] << ' ';
   cout << endl;
}

template<typename T> 
void print_vector(vector<T> vec) {
   FOR(i,0,vec.size()) cout << vec[i] << ' ';
   cout << endl;
}

string a,b,c;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    //freopen("test.txt", "r", stdin);
    cin >> a >> b >> c;
    cout << ((a[a.length() - 1] == b[0] && b[b.length() - 1] == c[0]) ? "YES" : "NO");
}

Measured memory_bytes: 256
a, b, c = map(int, input().split())


A = []

for i in range(c):
    A.append(a+i) if a <= a+i <= b else a
j = 0
for _ in range(c):
    A.append(b - j) if a <= b - j <= b else a
    j += 1
A = list(sorted(set(A)))

for i in A:
    print(i)

Measured memory_bytes: 38452
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>Pa;
const long long INF = 1ll<<62;
const int maxn = 2e6+10;
ll n,m,cnt;
map<ll,ll>Ma[maxn];//±ê¼Ç
vector<Pa>V[maxn];//´æ·Åpair¹ØÏµ
int vis[maxn];
ll dist[maxn];
struct node{
	ll dist;
	int id;
	bool operator < (const node& b) const
	{
		return dist > b.dist;
	}
};
int getid(int u,int v)//·µ»Ø±àºÅ 
{
	if(Ma[u][v]==0)
		Ma[u][v]=++cnt;
	return Ma[u][v];
} 
void spfa()
{
	for(int i=0;i<=cnt;i++)
	{
		vis[i]=0;
		dist[i]=INF;
	}
	node temp;
	temp.dist=0;
	temp.id=1;
	priority_queue<node> q;
	q.push(temp);
	dist[1]=0;
	while(!q.empty())
	{
		node u=q.top();
		q.pop();
		if(vis[u.id]==1)
			continue;
		vis[u.id]=1;
		for(int i=0;i<V[u.id].size();i++)
		{
			int v=V[u.id][i].first;
			int Valu=V[u.id][i].second;
			if(dist[v] > dist[u.id]+Valu)
			{
				dist[v]=dist[u.id]+Valu;
				node Temp;
				Temp.dist=dist[v];
				Temp.id=v;
				q.push(Temp);
			}	
		}		
	}
	if(dist[n]==INF)
		cout<<"-1"<<endl;
	else
		cout<<dist[n]/2<<endl;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	while(cin>>n>>m)
	{ 
		for(int i=0;i<=n;i++)
			Ma[i].clear(); 
		for(int i=0;i<=n;i++)
			V[i].clear();
		cnt=n;//´Ón+1¿ªÊ¼¼ÇÂ¼±àºÅ
		for(int i=0;i<m;i++)
		{
			int u,v,id;
			cin>>u>>v>>id;
			int uid=getid(u,id);
			int vid=getid(v,id);
			V[u].push_back(Pa(uid,1));
			V[uid].push_back(Pa(u,1));
			
			V[v].push_back(Pa(vid,1));
			V[vid].push_back(Pa(v,1));
			
			V[vid].push_back(Pa(uid,0));
			V[uid].push_back(Pa(vid,0));
		} 
		spfa();
	} 
	return 0;
}
 

Measured memory_bytes: 206192
n = gets.chomp.to_i
t, a = gets.chomp.split(" ").map(&:to_i)
h = gets.chomp.split(" ").map(&:to_i)

ans = Array.new
ans[0] = -1
ans[1] = 10 ** 6 * 0.006

for i in 0...h.size
    if (t - h[i] * 0.006 - a).abs < (ans[1] - a).abs
        ans[0] = i + 1
        ans[1] = t - h[i] * 0.006
    end
end

puts ans[0]

Measured memory_bytes: 1788
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// Nの桁数
ll dig(ll N) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= 10;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}



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

	int d = b - a;
	int h = 0;
	for (int i = 1; i <= d; i++) h += i;
	cout << h - b << endl;
}

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

struct Edge {
  int to, id;
};

vector<vector<Edge>> tree;
vector<int> ans;

void dfs(int v, int c = -1, int p = -1) {
  int k = 1;
  rep(i, tree[v].size()) {
    int u = tree[v][i].to, ei = tree[v][i].id;
    if(u == p) continue;
    if(k == c) ++k;
    ans[ei] = k; ++k;
    dfs(u, ans[ei], v);
  }
}

int main() {
  int n;
  cin >> n;
  tree.resize(n);
  ans.resize(n-1);

  rep(i, n - 1) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    tree[a].push_back((Edge){b, i});
    tree[b].push_back((Edge){a, i});
  }

  dfs(0);

  int mx = 0;
  rep(i,n) mx = max(mx, int(tree[i].size()));
  cout << mx << endl;
  rep(i,n-1) {
    cout << ans[i] << endl;
  }
  return 0;
}


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


int main() 
{

	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	
	int a,b,k;
	cin>>a>>b>>k;

	set<int>w;

	for(int i=a,j=b;i<k+a&&j>b-k;i++,j--)
	{
		if(i>0&&i<=b)
		w.insert(i);
	if(j>0&&j>=a)
		w.insert(j);
	}

	set<int>::iterator result, it;
	
	for(it=w.begin(); it!=w.end(); ++it)
      cout << *it<< ' ';

	return 0;
}

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

using namespace std;
typedef long long LL;
int _max(int x, int y) {return x > y ? x : y;}
LL _min(LL x, LL y) {return x < y ? x : y;}
const int N = 502;
int read() {
	int s = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
	return s * f;
}
void put(LL x) {
	if(x < 0) x = -x, putchar('-');
	if(x >= 10) put(x / 10);
	putchar(x % 10 + '0');
}

LL f[N][N], s[N][N], ss[N][N];
int n, v[N][N];

LL S(int x1, int x2, int y1, int y2) {
	if(x1 > x2 || y1 > y2) return 0;
	return ss[x2][y2] - ss[x2][y1 - 1] - ss[x1 - 1][y2] + ss[x1 - 1][y1 - 1];
}

int main() {
	n = read();
	for(int i = 1; i <= n + 1; i++) {
		for(int j = 1; j <= n + 1; j++) {
			if(i != j && j <= n && i <= n) v[i][j] = read();
			ss[i][j] = v[i][j] + ss[i - 1][j] + ss[i][j - 1] - ss[i - 1][j - 1];
			if(j >= i) s[i][j] = s[i][j - 1] + v[i][j];
		} for(int j = i; j <= n + 1; j++) s[i][j] += s[i - 1][j];
	} memset(f, -1, sizeof(f)); f[0][0] = 0;
	for(int i = 0; i <= n; i++) for(int j = i; j <= n; j++) if(f[i][j] != -1){
		for(int k = j + 1; k <= n + 1; k++) {
			if(f[j][k] == -1) f[j][k] = f[i][j] + S(k + 1, n, i + 1, j) + s[k][k] - s[j][k];
			else f[j][k] = _min(f[j][k], f[i][j] + S(k + 1, n, i + 1, j) + s[k][k] - s[j][k]);
		}
	} LL ans = f[0][n + 1];
	for(int i = 1; i <= n; i++) ans = _min(ans, f[i][n + 1]);
	put(ans), puts("");
	return 0;
}



Measured memory_bytes: 7168
#include <stdio.h>

int N, A[100010], B[100010], tot;

int main()
{
	int tmp;
	
	scanf("%d", &N);
	for(int i=1; i<=N; i++)
		scanf("%d", &A[i]);

	for(int i=1; i<=N; i++)
	{
		tmp = A[i];
		if(A[tmp] == i)
		{
			tot++;
			A[i] = -1;
		}
	}
	
	printf("%d", tot);
	
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
using namespace std;
int a,b,c;

int main()
{
    cin>>a>>b>>c;
    cout<<min(c,(b/a))<<endl;
    return 0;
}



Measured memory_bytes: 256
use proconio::marker::Chars;
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        _: usize,
        c: Chars,
    }
    let mut rc = 0;
    for &ch in &c {
        if ch == 'R' {
            rc += 1;
        }
    }
    let mut cou = 0;
    for i in 0..rc {
        if c[i] == 'R' {
            cou += 1;
        }
    }
    println!("{}", rc - cou);
}


Measured memory_bytes: 3112
/*input
3
1000000000 1000000000 1000000000
*/
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define input(str) freopen(str,"r",stdin);
#define output(str) freopen(str,"w",stdout);
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define INF  3e16+1
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld\n",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define modd 1000000007
#define len(x) x.size()
#define all(v) (v.begin(),v.end())
#define ll int
#define pi 3.1415926535897932384626
#define ld double
const int N =405;
int  a[N];
int pref[N];
int dp[N][N];
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
int  fun(int l,int r)
{
	if (dp[l][r]!=-1)
	{
		return dp[l][r];
	}
	if (l==r) {dp[l][r]=0; return 0;}
	if (l==r-1) {dp[l][r]=a[l]+a[r];
	return dp[l][r];}
	int temp=INF;
	for (int i=l;i<=r;i++)
	{
		// cout<<i<<endl;
		if (i==l)
		{
			temp=min(temp,fun(l+1,r)+pref[r]-pref[l]+a[l]);
		}
		else if (i==r)
		{
			temp=min(temp,fun(l,r-1)+pref[r-1]-pref[l]+a[l]+a[r]);
		}
		else
		{
			int x=fun(l,i-1);
			if (i-1==l) x=a[l];
			int y=fun(i,r);
			temp=min(temp,x+y+pref[i-1]-pref[l]+a[l]+pref[r]-pref[i]+a[i]);
		}
		// cout<<temp<<" "<<i<<" "<<l<<" "<<r<<endl;
	}
	// cout<<l<<" "<<r<<" "<<temp<<endl;
	dp[l][r]=temp;
	return temp;
}
int powmod(int base,int exp,int mod)
{
	int res=1LL;
	while(exp>0)
	{
		if(exp&1LL)
			res=(res*base)%mod;
		exp/=2LL;
		base=(base*base)%mod;
	}
	return res%mod;
}
signed main()
{
	int n;
	cin>>n;
	for (int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	pref[0]=a[0];
	for (int i=1;i<n;i++)
	{
		pref[i]=(pref[i-1]+a[i]);
	}
	for (int  i=0;i<N;i++)
	{
		for (int  j=0;j<N;j++)
		{
			dp[i][j]=-1;
		}
	}

	cout<<fun(0,n-1)<<endl;
	// for (int i=0;i<n;i++)

	// {
	// 	for (int j=0;j<n;j++)
	// 	{
	// 		cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
	// 	}
	// }
}

Measured memory_bytes: 1536
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<unordered_set>
#include<set>
typedef long long ll;
using namespace std;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll a, b;
	cin >> a >> b;
	cout << a * b;
}


Measured memory_bytes: 3624
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    // 条件を同じにするため一度Vecに貯める
    let v = buf.split_whitespace()
        .map(|x| x.parse::<u32>().unwrap())
        .collect::<Vec<_>>();
  
  
  	let mut result = "NO";
    let mut count5 = 0;
  	let mut count7 = 0;

  	for x in v.into_iter() {
  		if x == 5 {
          count5 += 1;
        }
        if x == 7 {
          count7 += 1;
        }
      
        if count7 == 1 && count5 == 2 {
          result = "YES"
        }
  	}

    println!("{}", result);
}

Measured memory_bytes: 2148
package main
 
import "fmt"
 
func main() {
  var a,b,c int
  
  fmt.Scan(&a)
  fmt.Scan(&b)
  fmt.Scan(&c)
  
  if b == 0 {
    fmt.Println("0")
    return
  }
  
  if c*a <= b {
    fmt.Println(c)
  } else {
    d := b/a
    fmt.Println(d)
  }
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;
const ll maxn=1e5+1;
ll n,a[maxn],dp[maxn][2];
int main()
{
	cin>>n;
	for(ll i=0;i<n;i++)cin>>a[i];
	dp[0][0]=a[0];
	dp[0][1]=-a[0];
	for(ll i=1;i<n-1;i++)
	{
		dp[i][0]=max(dp[i-1][1]-a[i],dp[i-1][0]+a[i]);
		dp[i][1]=max(dp[i-1][1]+a[i],dp[i-1][0]-a[i]);
	}
	cout<<max(dp[n-2][0]+a[n-1],dp[n-2][1]-a[n-1])<<endl;
	return 0;
}

Measured memory_bytes: 2560
N = input()
a = []
for i in range(int(N)):
    content = input()
    if a.count(content) != 0:
        print("No")
        exit()
    elif len(a) > 0 and a[-1][-1] != content[0]:
        print("No")
        exit()
    else:
        a.append(content)

print("Yes")

Measured memory_bytes: 3060
#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 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
const int MAX = 100010;

int main() {
    string s; cin >> s;
    for (int i = 0; i < 3; i++) {
        if (s[i] == '1') {
            s[i] = '9';
        } else if (s[i] == '9') {
            s[i] = '1';
        }
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll ,ll>;
using T = tuple<ll, ll, ll>;
const ll INF = 1LL<<61LL;
const ll MOD = 1e9+7;

int main(){
	ll N, Q;
	cin >> N >> Q;
	vector<T> stop(N);
	for(int i=0;i<N;i++){
		ll s, t, x;
		cin >> s >> t >> x;
		t--;
		stop[i] = T(x, s, t);
	}
	sort(stop.begin(), stop.end());
	set<P> st;
	for(int i=0;i<Q;i++){
		ll q;
		cin >> q;
		st.insert(P(q, i));
	}
	vector<ll> ans(Q, -1);
	for(auto &&quit : stop){
		ll x, s, t;
		tie(x, s, t) = quit;
		auto ite = st.lower_bound(P(s-x, -10));
		while(ite != st.end() && ite->first <= t-x){
			auto tmp = ite;
			ans[ite->second] = x;
			ite++;
			st.erase(tmp);
		}
	}
	for(int i=0;i<Q;i++)
		cout << ans[i] << endl;
	return 0;
}


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

int main()
{
   ll a,b;
   cin >> a >> b;
   if((a+b)&1)
   {
      cout<<"IMPOSSIBLE"<<endl;
   }
   else
   {
      cout<<(a+b)/2<<endl;
   }
}

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

using namespace std;

static const int maxn = 1e5 + 5;

long long Tree[maxn];
int N = 100000;

void update(int pos, int val)
{
      while (pos <= N)
      {
            Tree[pos] += val;
            pos += (pos & -pos);
      }
}

void range_update(int l, int r, int val)
{
      update(l, val);
      update(r + 1, -val);
}

long long query(int pos)
{
      long long sum = 0;
      while (pos > 0)
      {
            sum += Tree[pos];
            pos -= (pos & -pos);
      }
      return sum;
}

int main()
{
      ios_base::sync_with_stdio(false);
      cin.tie(nullptr);
      cout.tie(nullptr);

 
      int n, k, q;
      cin >> n >> k >> q;
      range_update(1, n, k);
      for (int i = 1; i <= q; i++)
      {
            int x;
            cin >> x;
            int l = 1;
            int r = x - 1;
            if (l <= r) range_update(l, r, -1);
            l = x + 1;
            r = n;
            if (l <= r) range_update(l, r, -1);
      }
      for (int i = 1; i <= n; i++)
      {
            long long sum = query(i);
            cout << (sum > 0 ? "Yes" : "No") << '\n';
      }
}


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

using ll=long long;



void solve(){
    int h,w;
    cin>>h>>w;
    vector<vector<string >> s(h,vector<string>(w));
    for(auto& e:s){
        for(auto& c:e){
            cin>>c;
        }
    }
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(s[i][j]=="snuke"){
                cout<<char('A'+j)<<i+1<<endl;
                return;
            }
        }
    }
}

signed main(){
    //while(1)
    solve();
}

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

int main()
{
    string s;
    cin >> s;
    int p, q;

    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'A'){
            p = i;
            break;
        }
    }
    
    for(int i = s.size() -1 ; i >= 0; i--){
        if(s[i] == 'Z'){
            q = i;
            break;
        }
    }

    cout << q - p + 1 << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll MOD = 1000000007;
const double PI = 3.141592653589793238463;
const ll N=2e5+9;
map<int,int>m;
bool ans[3][3];
int main()
{
    FASTINOUT;
    int y[3][3],l;

    for (int i=0; i<3; i++)
    {
        for (int j=0; j<3; j++)
        {
            cin>>y[i][j];
            m[y[i][j]]=1;
        }
    }
    int c=0;
    int q;
    cin>>q;
    for (int i=0; i<q; i++)
    {
        cin>>l;
        for (int j=0; j<3; j++)
        {
            for (int k=0; k<3; k++)
            {
                if (l==y[j][k]){
                    ans[j][k]=true;
                }
            }
        }
    }
    int row[3]={0,0,0},col[3]={0,0,0};
    for (int i=0; i<3; i++)
    {
        int c=0;
        for (int j=0; j<3; j++)
        {
            if (ans[i][j])
                {
                    row[i]++;
                    col[j]++;
                }
        }
    }
    if (row[0]==3 ||row[1]==3 ||row[2]==3 ||col[1]==3||col[2]==3||col[0]==3)
        cout<<"Yes\n";
    else if (ans[0][0]&&ans[1][1]&&ans[2][2])
        cout<<"Yes\n";
    else if (ans[0][2]&&ans[1][1]&&ans[2][0])
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
}


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

int main(void)
{
  long long int i, n, a[1000000], b = 1000000000000000000, result = 1;
  
  scanf("%lld", &n);
  
  for( i = 0; i < n; i++ ){
      scanf("%lld ", &a[i]);
  }
  
  for( i = 0; i < n; i++ ){
      if( a[i] == 0 ){
          printf("0\n");
          return 0;
      }
  }
  
  for( i = 0; i < n; i++ ){
      b /= a[i] ;
      if( b == 0 ){
          printf("-1\n");
          return 0;
      }
  }
  
  
  for( i = 0; i < n; i++ ){
    result *= a[i];
    if( result > 1000000000000000000 ){
        printf("-1\n");
        return 0;
    }
    if( result < 0){
      printf("-1\n");
      return 0;
    }
  }
  printf("%lld\n", result);
  return 0;
}

Measured memory_bytes: 2520
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define mem(x,y) memset(x,y,sizeof(x)) //memset array
#define fo(i,r,k)  for((i) = r; (i) < (k); i=i+1)
#define fok(i,k,n) for((i) = k; (i) > n; i=i-1)
#define deb(x) cout << #x << " = " << x << endl
#define deb2(x, y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define deb3(x, y, z) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl
#define bug puts("Hello");
#define mp make_pair
#define pb push_back
#define pi pair<int,int>
#define pl pair<long long,long long>
#define vi vector<int>
#define vl vector<long long>
#define vpl vector<pair<long long,long long>>
#define vpi vector<pair<int,int>>
#define all(x) x.begin(),x.end()
#define f first
#define s second
#define br cout<<"\n";
#define sortall(x) sort(x.begin(),x.end())
#define modexpo poww
ll modexpo(ll x,ll y,ll m){x=x%m;if(y==0){return 1;}if(y%2==0){return modexpo(x*x,y/2,m); }else{return (x*modexpo(x*x,y/2,m))%m; }}
void io();
const int mod  = 1e9+7;
const int maxn = 1e5 + 10;

ll dp[102][maxn]; 
ll n,cap,w[maxn],p[maxn]; 

ll rec(ll n,ll cap)
{   
    if(n==0 || cap==0) return 0; 
    
    if(dp[n][cap] != -1) return dp[n][cap]; 
    
    ll ans=0; 
    if(w[n]<=cap){
        ans = p[n] + rec(n-1,cap-w[n]); 
    }
    ans = max(ans, rec(n-1,cap)); 
    
    return dp[n][cap] = ans; 
}

int main()
{
int i,j;
cin>>n>>cap;
fo(i,1,n+1) cin>>w[i]>>p[i]; 
mem(dp,-1); 
rec(n,cap); 

cout<<dp[n][cap] ;
return 0;
}

void io()
{
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
}


Measured memory_bytes: 83284
#include "bits/stdc++.h"

using namespace std;

typedef long long LL;
typedef long double LD;





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

  vector<LL> A(5);
  for (LL i = 0; i < 5; ++i) {
    cin >> A[i];
  }
  
  LL min_num = *min_element(A.begin(), A.end());

  LL val = (LL)ceil((LD)N / (LD)min_num) - 1;
  cout << 5 + val;

  return 0;
}

Measured memory_bytes: 384
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
print(N*(N-1)//2 + M*(M-1)//2)

Measured memory_bytes: 5140
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,ans=0,i,j,k;
    cin>>n;
    long long int a[n+1][n+1];
    bool p[n+1][n+1];
    memset(p,0,sizeof(p));
    for(i=1;i<=n;i++)
    for(j=1;j<=n;j++)
    cin>>a[i][j];
    for(k=1;k<=n;k++)      
	for(i=1;i<=n;i++)
    for(j=1;j<=n;j++){
    if(k!=j&&k!=i&&i!=j){
        if(a[i][j]==a[i][k]+a[k][j])
        p[i][j]=1; 
        if(a[i][j]>a[i][k]+a[k][j]){
            cout<<"-1"<<endl; 
            return 0;
        	}
    	}
    }
    for(i=1;i<=n;i++)
    for(j=1;j<=n;j++)
	if(p[i][j]==0)
	ans+=a[i][j];
    cout<<ans/2<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#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 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;}
//from here
vector<lli> primes,tot;
vector<bool> iscomposite;
int precalc(int n)
{
	primes=vector<lli>();
	tot=vector<lli>(n+1);
	tot[1]=0;
	iscomposite=vector<bool>(n+1,false);
	for(int i=2;i<=n;i++)
	{
		if(!iscomposite[i])
		{
			tot[i]=i-1;
			primes.push_back(i);
		}
		for(int j=0;primes[j]*i<n;j++)
		{
			iscomposite[primes[j]*i]=true;
			if(i%primes[j]==0)
				{tot[i*primes[j]]=primes[j]*tot[i];break;}
			tot[i*primes[j]]=tot[primes[j]]*tot[i];
		}

	}
	return 0;
}
//to here
lli sum(lli n)
{
	return (n*(n+1))/2LL;
}
lli bin_search(lli su)
{
	lli l=1,r=100;
	lli mid=(l+r)/2LL;
	while(l<r)
	{
		if(sum(mid)>su)
			r=mid;
		else
			l=mid+1LL;
		mid=(l+r)/2LL;
	}
	if(sum(mid)>su)
		mid--;
	return mid;
}
vector<lli> vec;
int main()
{
	precalc(1000001);
	lli n;
	cin>>n;
	lli ans=0;
	for(auto j: primes)
	{
		if(n%j==0)
			vec.push_back(0);
		while(n%j==0)
		{
			vec[vec.size()-1]++;
			n/=j;
		}
	}
	if(n!=1)
		ans++;
	for(int i=0;i<(int)vec.size();i++)
	{
		//cout<<vec[i];
		ans+=bin_search(vec[i]);
	}
	cout<<ans;
}




Measured memory_bytes: 12144
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,m = inpl()
print('Yes' if n==m else 'No')

Measured memory_bytes: 65644
x_list = [int(x) for x in input().split()]
temp_list = [[], []]
for i in range(3):
    temp_list[x_list[i] % 2].append(i)
temp = len(temp_list[0])
ans = 0
if temp == 1:
    x_list[temp_list[1][0]] += 1
    x_list[temp_list[1][1]] += 1
    ans += 1
elif temp == 2:
    x_list[temp_list[0][0]] += 1
    x_list[temp_list[0][1]] += 1
    ans += 1
x_max = max(x_list)
ans += sum([gap // 2 for gap in [x_max - x for x in x_list]])
print(ans)

Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		// 文字列の入力
		String[] sList = sc.next().split("");
      
        String last = "";
        String ans = "Good";
        for(String s : sList) {
          if (s.equals(last)) {
            ans = "Bad";
            break;
          } else {
            last = s;
          }
        }
    
		// 出力
		System.out.println(ans);
	}
}

Measured memory_bytes: 25044
#[allow(unused_imports)]
use std::cmp;
use std::collections::BTreeMap;

fn run() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let a = sc.read_vec::<usize>(n);
    let q: usize = sc.read();
    let bc = sc.read_pairs::<usize>(q);

    let mut sum = a.iter().sum::<usize>();
    let mut bmap = BTreeMap::new();
    for a in a.into_iter() {
        bmap.entry(a).and_modify(|x| *x += 1).or_insert(1);
    }

    for (b, c) in bc.into_iter() {
        if bmap.contains_key(&b) {
            let v = bmap[&b];
            bmap.remove(&b);
            bmap.entry(c).and_modify(|x| *x += v).or_insert(v);
            sum -= b * v;
            sum += c * v;
        }
        println!("{}", sum);
    }
}

fn main() {
    std::thread::Builder::new()
        .name("run".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn read_pairs<T: std::str::FromStr>(&mut self, n: usize) -> Vec<(T, T)> {
        (0..n).map(|_| (self.read(), self.read())).collect()
    }
    pub fn read_pairs_1_indexed(&mut self, n: usize) -> Vec<(usize, usize)> {
        (0..n)
            .map(|_| (self.read::<usize>() - 1, self.read::<usize>() - 1))
            .collect()
    }
    pub fn read_chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    pub fn read_char_grid(&mut self, n: usize) -> Vec<Vec<char>> {
        (0..n).map(|_| self.read_chars()).collect()
    }
    pub fn read_matrix<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n)
            .map(|_| (0..m).map(|_| self.read()).collect())
            .collect()
    }
}


Measured memory_bytes: 5076
#include <algorithm>
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <cmath>

#define rep(i, x, n) for (int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;

int main()
{
    long long N;
    cin >> N;
    int res[1000];
    int i = 0;
    if (N == 0)
    {
        res[0] = 0;
        i++;
    }
    while (N != 0)
    {
        int amari = N % 2;
        if (amari < 0)
        {
            amari += 2;
        }
        res[i] = amari;
        i++;
        N = (N - amari) / (-2);
    }
    rep(r, 0, i)
    {
        cout << res[i - 1 - r];
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int l[N], r[N], c[N], d[N];
ll a[N];
int n, m, q;
ll f(int id,  int pre)
{
	if(id == n + 1)
	{
		ll res = 0;
		for(int i = 1; i <= q; i ++)
		{
			if(a[r[i]] - a[l[i]] == c[i])
				res += d[i];
		}
		return res;
	}
	ll ans = 0;
	for(int i = pre; i <= m; i ++)
	{
		a[id] = i;
		ans = max(ans, f(id + 1, i));
	}
	return ans;
}
int main()
{
	cin >> n >> m >> q;
	for(int i = 1; i <= q; i ++)
		cin >> l[i] >> r[i] >> c[i] >> d[i];
	cout << f(1, 1);




	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 3640
#include<stdio.h>

int main()
{
    int N, X, i, min=1001, sum=0;
    int m;

    scanf("%d%d\n", &N, &X);

    for(i=0;i<N;i++){
        scanf("%d", &m);
        sum+=m;
        if(m<min){
            min=m;
        }
    }

    printf("%d", N+(X-sum)/min);

    return 0;
}

Measured memory_bytes: 128
#include <math.h>
#include <string>
#include <iostream>
using namespace std;

int routine (int a) {
  int b[5];
  int a_ = a;
  for (int i=0; i<5; i++) {
    b[i] = a_ % 10; // 1桁目～5桁目
    a_ = a_ / 10;  // aのi桁目を引いた値
    //cout << b[i] << " " << a_ << endl;
  }
  if (b[0]==b[4] && b[1]==b[3]) {
    return 1;
  } else {
    return 0;
  }
}

int main () {
  int a, b;
  cin >> a >> b;
  int count = 0;
  for (int i=a; i<=b; i++) {
    if (routine(i) == 1) {
      count++;
    }
  }
  cout << count << endl;
}
  
  
  

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

    using namespace std;

    int main() {
        string s;
        cin>>s;
        for(int i=0;i<4;i++) cout<<s[i];cout<<" ";
        for(int i=4;i<12;i++) cout<<s[i];cout<<"\n";
       return 0;
    }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp[100010];
int fun(int k,int ar[],int n,int val)
{
	if(k<ar[0])
		return dp[k]=0;
	if(dp[k]>=0)
		return dp[k];
	for(int j=0;j<n && k>=ar[j];j++)
		val = val & fun(k-ar[j],ar,n,1);
	if(val==0)
		dp[k]=1;
	else
		dp[k]=0;
	return dp[k];
}
int main()
{
	int n,k,i;
	scanf("%d%d",&n,&k);
	int ar[n+1];
	memset(dp,-1,sizeof(dp));
	for(i=0;i<n;i++)
		scanf("%d",ar+i);
	fun(k,ar,n,1);
	if(dp[k]==1)
		printf("First\n");
	else
		printf("Second\n");
}


Measured memory_bytes: 8448
N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
cnt = 0
 
def dist(A, B):
    sums = 0
    for i in range(len(A)):
        sums += (abs(A[i] - B[i])) ** 2
    sums = sums ** 0.5
    return sums
 
for i in range(N-1):
    for j in range(i+1, N):
#            if isinstance(dist(X[i], X[j]), int):
        if dist(X[i], X[j]).is_integer():
            cnt += 1
print(cnt)

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

int main()
{
    ll r, d, x;
    cin >> r >> d >> x;
    for (int i = 0; i < 10; i++)
    {
        ll ans = 0;
        ans = r * x - d;
        x = ans;
        cout << ans << "\n";
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
int solve(int x) {
    int ans=0;
    while(x) ans+=x%10,x/=10;
    return ans;
}
int main() {
    int n;scanf("%d",&n);
    int l=1,r=n-1;
    int ans=1e5;
    while(l<=r) {
        ans=std::min(ans,solve(l)+solve(r));
        l++;r--;
    }
    printf("%d\n",ans);
    return 0;
}


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

int h, w;

int calc(int x, int y, vector < vector < bool > >&v,
         vector < vector < int > >&vh, vector < vector < int > >&vw)
{
        int ans = 1;
        if (v[y][x] == false)
                return 0;

        if (vh[y][x] == -1) {
                int bufans = 0;
                int high=y, low=y;
                for (int i = y + 1; i < h; i++) {
                        if (v[i][x] == true) {
                                high = i;
                                bufans++;
                        } else {
                                break;
                        }
                }
                for (int i = y - 1; i >= 0; i--) {
                        if (v[i][x] == true) {
                                bufans++;
                                low = i;
                        } else
                                break;
                }
                for (int z = low; z <= high; z++) {
                        vh[z][x] = bufans;

                }
                ans += bufans;
        } else {
                ans += vh[y][x];
        }
        if (vw[y][x] == -1) {
                int bufans = 0;
                int high=x, low=x;
                for (int i = x + 1; i < w; i++) {
                        if (v[y][i] == true) {
                                bufans++;
                                high = i;
                        } else
                                break;
                }
                for (int i = x - 1; i >= 0; i--) {
                        if (v[y][i] == true) {
                                low = i;
                                bufans++;
                        } else
                                break;
                }
                for (int z = low; z <= high; z++) {
                        vw[y][z] = bufans;
                }
                ans += bufans;
        } else {
                ans += vw[y][x];
        }
        return ans;
}

int main()
{
        int ans = 0;
        cin >> h >> w;
        vector < vector < bool > >v(h, vector < bool > (w));
        vector < vector < int >>vh(h, vector < int >(w, -1));
        vector < vector < int >>vw(h, vector < int >(w, -1));
        for (int i = 0; i < h; i++) {
                string s;
                int j = 0;
                cin >> s;
 for (auto c:   s) {
                        v[i][j++] = (c == '#') ? false : true;
                }
        }

        for (int i = 0; i < h; i++)
                for (int j = 0; j < w; j++) {
                        int buf = calc(j, i, v, vh, vw);
                        if (buf > ans)
                                ans = buf;
                }
        cout << ans << endl;

        return 0;
}

Measured memory_bytes: 32256
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
#define FI(i, a, b) for (int i = (a); i <= (b); ++i)
#define FD(i, b, a) for (int i = (b); i >= (a); --i)
#define DEBUG(x) cerr << #x << ": " << (x) << endl;

int main() {
  int a, b;
  cin >> a >> b;
  cout << max({a + b, a - b, a * b}) << endl;
}


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

f = True
ans = 0

while f:
    f = False
    for i in range(1, len(a)):
        if a[i] < a[i - 1]:
            ans += 1
            a[i], a[i - 1] = a[i - 1], a[i]
            f = True

print(*a)
print(ans)


Measured memory_bytes: 5608
#include <iostream>
#include <string>

using namespace std;

int N;

int main(void)
{
	cin >> N;
	
	string rep;
	string sex;
	
	cout << 0 << endl;;
	cin >> sex;
	if(sex == "Vacant") return 0;
	
	int prev = -1;
	
	int lb = 0, ub = N-1, mid = 0;
	while(1){
		mid = (lb + ub) / 2;
		if(mid == prev) mid++;
		prev = mid;
		cout << mid << endl;;
		cin >> rep;
		if(rep == "Vacant") break;
		if(rep == sex){
			if((mid - lb) % 2){
				ub = mid;
			}else{
				lb = mid;
				sex = rep;
			}
		}
		else{
			if((mid - lb) % 2 == 0){
				ub = mid;
			}else{
				lb = mid;
				sex = rep;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 852
n,*a=map(int,open(0).read().split())

gray=0
brown=0
green=0
water=0
blue=0
yellow=0
orange=0
red=0
overred=0

for i in a:
  if 1<=i<400:
    gray=1
  elif 400<=i<800:
    brown=1
  elif 800<=i<1200:
    green=1
  elif 1200<=i<1600:
    water=1
  elif 1600<=i<2000:
    blue=1
  elif 2000<=i<2400:
    yellow=1
  elif 2400<=i<2800:
    orange=1
  elif 2800<=i<3200:
    red=1
  else:
    overred+=1
    
ans=gray+brown+green+water+blue+yellow+orange+red

if ans==0:
  print(1,overred)
else:
  print(ans,ans+overred)

  


Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"
	"strconv"
)

func main() {
	n := readInt()
	ans := make([]int, n)
	for range ans[:n-1] {
		ans[readInt()-1]++
	}

	for i := range ans {
		fmt.Println(ans[i])
	}
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 6208
// includes, macros {{{
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <list>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <climits>
#include <cassert>
#include <functional>
#include <numeric>
#include <limits>
using namespace std;

#define eps (1e-10)
#define equals(a, b) (fabs((a)-(b)) < eps)

#define rep(i, s, e)    for (int i = (s); i < (int)(e); i++)
//#define pb(e) push_back(e)
//#define mp(a, b) make_pair(a, b)

// for debug
#define kita            cout << "kita\n"
#define print2(i, n)    cout << (i) << ": " << (n) << endl
#define print3(i, j, n)     cout << "(" << (i) << ", " << (j) << ") : " << (n) << endl
#define print4(i, j, n, m)  cout << "(" << (i) << ", " << (j) << ") : " << (n) << ", " << (m) << endl
#define print_mat(mat, h, w) for(int i=0;i<(h);i++){for(int j=0;j<(w);j++){cout << mat[i][j] << " ";}cout << endl;}
 
typedef long long ll;
typedef unsigned long long ull; // }}}

int main() {
    int n;
    vector<int> a;
    list<int> b;

    cin >> n;

    for(int i=0;i<n;i++){
        int aa;
        cin >> aa;
        a.push_back(aa);
    }

    for(int i=0;i<n;i++){
        if(i%2 == 0){
            b.push_back(a[i]);
        }else{
            b.push_front(a[i]);
        }
    }


    if(n%2 != 0){
        reverse(b.begin(), b.end());
    }

    // bool flag = true;
    for(auto bb : b){
        // if(!flag){
        //     cout << " ";
        // }
        // flag = false;
        // cout << bb;
        cout << bb << " ";
    }

    cout << endl;

    return 0;
}


Measured memory_bytes: 9332
if __name__ == '__main__':
    n = int(input())
    a_input = list(map(int, input().split()))
    b_input = list(map(int, input().split()))
    c_input = list(map(int, input().split()))

    score = 0
    pre_a = -1
    for i in range(n):
        score += b_input[a_input[i] - 1]
        if pre_a == a_input[i] - 1:
            score += c_input[pre_a - 1]
        pre_a = a_input[i]
    print(score)

Measured memory_bytes: 3064