akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int w,a,b;
    cin >> w >> a >> b;
    if(min(a+w,b+w)-max(a,b) >= 0){
        cout << 0 << endl;
    }else{
        cout << abs(min(a+w,b+w)-max(a,b)) << endl;
    }
}

Measured memory_bytes: 256
// 難さんすう すーぱーさんすうと呼ぼう
// Mを素因数分解しといて例えばM=12としてM=(2^2) * (3^1)なるが、それぞれの因数をそれぞれの乗数ぶん振り分ける感じにした組み合わせが答え
// N = 3なら [1, 1, 1]の3つのどれかに振り分ける つまり以下
// 因数2を2つ,因数3を1つ を振り分けて、
//			[2^1, 2^1, 2^0], [3^1, 3^0, 3^0]
// 				-> [1*(2^1 * 3^1)] * [1*(2^1 * 3^0)] * [1*(2^0 * 3^0)] = 6*2*1 = 12
// あるいは
//			[2^2, 2^0, 2^0], [3^0, 3^0, 3^1] ならば
//				-> [1*(2^2 * 3^0)] * [1*(2^0 * 3^0)] * [1*(2^0 * 3^1)] = 4*1*3 = 12
// あるいは
//			[2^1, 2^1, 2^0], [3^0, 3^0, 3^1] ならば
//				-> [1*(2^1 * 3^0)] * [1*(2^1 * 3^0)] * [1*(2^0 * 3^1)] = 2*2*3 = 12
//
// 解説の""計算量はNに依らない""が意味不明だけど、説明してくれないので無視
// すーぱーさんすうの世界ではこれを重複組合せと呼ばうらしい 漢字だね 画数が多い
// n種類のものから重複を許してr個選ぶ場合の数 = nHr = (n+r-1)Cr に帰着できるらしい

// nCr mod Pなので気をつける
package main

import (
	"fmt"
	"math"
)

var MOD int

func main() {
	var N, M int
	fmt.Scan(&N, &M)
	arr := factorization(M)
	ans := 1
	MOD = int(math.Pow10(9)) + 7
	for _, v := range arr {
		// ans *= ncrMod(v+N-1, v, MOD)
		// ans *= comb(v+N-1, v, MOD)
		ans = ans * comb(v+N-1, v) % MOD
	}
	fmt.Println(ans % MOD)
}

func factorization(n int) map[int]int {
	a := make(map[int]int)
	for i := 2; i*i <= n; {
		if n%i == 0 {
			a[i]++
			n /= i
		} else {
			i++
		}
	}
	if n > 1 {
		a[n]++
	}
	return a
}

func primeFactorization(x int) map[int]int {
	ret := make(map[int]int)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			x /= i
			if _, ok := ret[i]; ok {
				ret[i] += 1
			} else {
				ret[i] = 1
			}
		}
	}
	if x > 1 {
		ret[x] = 1
	}
	return ret
}

func ncrMod(n, r, mod int) int {
	// 呼び出すたびにテーブルを作るのは愚
	_n := 1000000
	g1 := make([]int, _n+1)
	g1[0], g1[1] = 1, 1
	g2 := make([]int, _n+1)
	g2[0], g2[1] = 1, 1
	inverse := make([]int, _n+1)
	inverse[0], inverse[1] = 0, 1
	for i := 2; i <= _n; i++ {
		g1[i] = (g1[i-1] * i) % mod
		inverse[i] = mod - inverse[mod%i]*(mod/i)%mod
		g2[i] = (g2[i-1] * inverse[i]) % mod
	}

	return g1[n] * (g2[r] * g2[n-r] % mod) % mod
}

func comb(n, m int) int {
	return factorial(n, n-m+1) * pow(factorial(m, 2), MOD-2) % MOD
}

func pow(x, n int) int {
	r := 1
	for ; n > 0; n /= 2 {
		if n%2 == 1 {
			r = r * x % MOD
		}
		x = x * x % MOD
	}
	return r
}

func factorial(n, m int) int {
	r := 1
	for i := m; i <= n; i++ {
		r = r * i % MOD
	}
	return r
}


Measured memory_bytes: 512
def inpl(): return [int(i) for i in input().split()]
N = int(input())
A = [0]+inpl()+[0]
sumtr = 0
for i in range(N+1):
    sumtr += abs(A[i+1]-A[i])
for i in range(1,N+1):
    print(sumtr +abs(A[i+1]-A[i-1]) -abs(A[i]-A[i-1]) -abs(A[i+1]-A[i]))    

Measured memory_bytes: 14048
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define dbg(x) cout<<#x<<"="<<x
#define nl cout<<"\n"
#define frn(i,n) for(int i = 0;i < n;i++)
#define fr(i,a,b) for(int i = a;i < b;i++)
#define pb push_back
#define trav(x,c) for(auto &x:c)
using namespace std;
const int mod = 1e9+7;
int toint(string s) {
  int ans = 0;
  for(char x: s) ans = ans*10 + (x - '0');
  return ans;
}

int lcs(string a, string b) {
  int n = a.size(), m = b.size();
  int dp[2][m+1];
  for(int i = 0;i <= n;i++) {
    for(int j = 0;j <= m;j++) {
      if(i==0||j==0) dp[i%2][j] = 0;
      else {
        if(a[i-1] == b[j-1]) dp[i%2][j] = 1 + dp[1-i%2][j-1];
        else dp[i%2][j] = max(dp[i%2][j-1], dp[1-i%2][j]);
      }
    }
  }
  return dp[n%2][m];
}

int sum(int x) {
  int s = 0;
  while(x) {
    s += x%10;
    x /= 10;
  }
  return s;
} 

bool equal(string s) {
  for(int i = 0,j = s.size()/2;j < s.size();i++,j++) {
    if(s[i] != s[j]) return false;
  }
  return true;
}

ll fact(int n) {
  ll ans = 1;
  fr(i,2,n+1) ans = (ans*i)%mod;
  return ans;
}

ull f(ll a, ll x) {
  if(a < 0) return 0;
  return (a/x+1);
}

int main() {
  int n,k;
  cin>>n>>k;
  ll ans = k*pow(k-1,n-1);
  cout<<ans;
}



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

using ll = long long int;
const int MAX = 51;
ll com[MAX][MAX], v[MAX];

void COMinit(){
    memset(com, 0, sizeof(com));
    com[0][0] = 1;
    for(int i = 1; i < MAX; i++){
        com[i][0] = 1LL;
        for(int j = 1; j < MAX; j++){
            com[i][j] = com[i-1][j-1] + com[i-1][j];
        }
    }
}

int main(){
    COMinit();
    cout.precision(10);
    int n, a, b;
    cin >> n >> a >> b;
    for(int i = 0; i < n; i++) cin >> v[i];
    sort(v, v + n);
    reverse(v, v + n);
    double avg = 0.0;
    for(int i = 0; i < a; i++) avg += v[i];
    avg /= a;

    ll sum = 0LL;
    int idx = 0, pos = 0;
    for(int i = 0; i < n; i++){
        if(v[i] == v[a-1]){
            idx++;
            if(i < a) pos++;
        }
    }
    if(pos == a){
        for(int i = a; i <= b; i++) sum += com[idx][i];
    }else{
        sum += com[idx][pos];
    }
    cout << fixed << avg << endl;
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<bits/stdc++.h>
using namespace std;
int n,m;
int a[108];
int b[108];
int c[108];
int main()
{
    int i,j;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
        scanf("%d",&a[i]);
    b[1]=a[1];
    for(i=2;i<=n;i++)
            b[i]=a[i]+b[i-1];
    c[1]=a[n];
    for(i=2;i<=n;i++)
        c[i]=a[n-i+1]+c[i-1];
    int minn=abs(b[1]-c[n-1]);
    for(i=2;i<=n;i++)
    {
        if(minn>abs(b[i]-c[n-i]))
            minn=abs(b[i]-c[n-i]);
    }
    printf("%d\n",minn);
    return 0;
}

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

int main() {
  long long rec = 100,x;
  int year = 0;
  cin >> x;
  
  for(;;){
    rec=rec*1.01;
    year++;
    if(rec>=x)
      break;
  }
  
  cout << year;
}

Measured memory_bytes: 3600
solver::Int->Int -> Int -> Int
solver a b h = div ((a+b)*h) 2

main::IO()
main =do
  ac<-getLine
  let a= read ac::Int
  bc<-getLine
  let b= read bc::Int
  hc<-getLine
  let h= read hc::Int
  print (solver a b h)


Measured memory_bytes: 508
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,b,a) for (ll i = b - 1; i >= a; i--)
#define all(v) v.begin(), v.end()
#define maxe(v) *max_element(v.begin(), v.end())
#define mine(v) *min_element(v.begin(), v.end())
#define pb push_back
#define pf push_front
#define rem 1000000007
#define cont continue
//#define minn 999999999
//#define maxx 0
ll gcd(ll a, ll b);

ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b%a, a);
}
ll modulo(ll a, ll b)
{
    ll r = a % b;
    return r < 0 ? r + b : r;
}
//ncr
ull ncr(ull n, ull r)
{
    if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
    ull ans = 1;
    ull i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}
///////////////////////////////////////////////////////
class abc
{
    public:
    ll x;
    ll y;
};
bool fun1(abc xx,abc yy)
{
    return (abs(xx.x) + abs(xx.y) ) < ( abs(yy.x) + abs(yy.y) ) ;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    /*ll tc;
    cin>>tc;
    while(tc--)
    {}*/
    ll n;
    cin>>n;
    ll a= n/500;
    a*=1000;
    ll b=n%500;
    b=b/5;
    b*=5;
    cout<<a+b<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int sum = 0;
		for(int i = 0; i < s.length(); i++) {
			if(s.charAt(i) == '+') sum++;
			else sum--;
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int a[100021];
int main()
{
	int n;
	cin>>n;
	a[0]=-1;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i]; 
	}
	for(int i=1;i<=n;i++)
	{
		if(a[i-1]>a[i])
		{
			cout<<"No"<<endl;
			return 0;
		} 
		if(a[i]-1>=a[i-1])
		{
			a[i]-=1;
		}
	}
	cout<<"Yes"<<endl; 
} 

Measured memory_bytes: 640
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ld long double
#define ll long long
#define int ll
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
int32_t main(){
	boost;
	//freopen(".in","r",stdin);
	string n;
	cin>>n;
	if(n.back()=='2'||n.back()=='4'||n.back()=='5'||n.back()=='7'||n.back()=='9')
		cout<<"hon\n";
	else if(n.back()=='0'||n.back()=='1'||n.back()=='6'||n.back()=='8')
		cout<<"pon\n";
	else if(n.back()=='3')
		cout<<"bon\n";
	return 0;
}

//do smth instead of nothing and stay organized
//long long
//array bounds
//special cases
//binary search

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll dp[2000][2000];
ll a[2000][2000];
ll e=1000000007;
int main()
{
  ll n,m;
  cin>>n>>m;
  ll i,j;
  i=1;
  while(i<=n)
  {
    j=1;
    while(j<=m)
    {
      char b;
      cin>>b;
      if(b=='#')
      {
        a[i][j]=0;
      }
      else
      {
       a[i][j]=1; 
      }
      
     j++; 
    }
    
   i++; 
  }
 i=1;
  while(i<=n)
  {
    j=1;
    while(j<=m)
    {
      if(i==1 && j==1)
      {
        dp[i][j]=1;
      }
      else if(a[i][j]==0)
      {
       dp[i][j]=0; 
      }
      else
      {
       dp[i][j]=(dp[i-1][j]%e+dp[i][j-1]%e)%e; 
      }
      
  j++;    
    }
   i++; 
  }
  
  
  
  cout<<dp[n][m];
  
 return 0; 
}














Measured memory_bytes: 32512
#include <stdio.h>
#define N 100000
#define NIL -1

typedef struct node{
  int parent;
  int left;
  int right;
}Node;

Node T[N];

int n;

int Calc_depth(int x){
  if(T[x].parent == NIL) return 0;
  return Calc_depth(T[x].parent) + 1;
}

void type_pri(int y){
  if(T[y].parent == NIL) printf("root");
  else if((T[y].left == NIL) && (T[y].right == NIL)) printf("leaf");
  else printf("internal node");
}

int calc_deg(int z){
  int cnt = 0;
  if(T[z].left != NIL) cnt++;
  if(T[z].right != NIL) cnt++;
  return cnt;
}

int get_height(int i){
  int x = 0,y = 0;
  if(T[i].left == NIL && T[i].right == NIL) return 0;
  if(T[i].left != NIL) x = get_height(T[i].left) + 1;
  if(T[i].right != NIL) y = get_height(T[i].right) + 1;
  if(x > y) return x;
  else return y;
}

int get_sib(int i){
  if(T[i].parent == NIL) return NIL;
  if((T[T[i].parent].right != NIL) && (T[T[i].parent].right != i))  return T[T[i].parent].right;
  else if((T[T[i].parent].left != NIL) && (T[T[i].parent].left != i)) return T[T[i].parent].left;
  else return -1;
}

void print(void){
  int i;
  for(i = 0; i < n; i++){
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,T[i].parent,get_sib(i),calc_deg(i),Calc_depth(i),get_height(i));
    type_pri(i);
    printf("\n");
  }
}

int main()
{
  int i,id,n1,n2;
  scanf("%d",&n);
  for(i = 0; i < n;i++){
    T[i].parent = NIL;
    T[i].left = NIL;
    T[i].right = NIL;
  }
  for(i = 0; i < n;i++){
    scanf("%d%d%d",&id,&n1,&n2);
    T[id].left = n1;
    T[id].right = n2;
    if(n1 != NIL && n2 != NIL){
      T[n1].parent = id;
      T[n2].parent = id;
    }
    else if(n1 == NIL && n2 != NIL) T[n2].parent = id;
    else if(n1 != NIL && n2 == NIL) T[n1].parent = id;
  }
  print();
  return 0;    
}



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

using namespace std;

//int N,M,K,L,R,H,W;
long long int N,M,K,L,R,H,W;

//constexpr long long int MOD=1000000007;
//constexpr  int MOD=1000000007;
constexpr int MOD=998244353;
//constexpr long long int MOD=998244353;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin>>N>>L>>R>>H>>W;
	cout<<N-max((L+H-1)/H,(R+W-1)/W)<<endl;
	
	return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
#define FOR(i,s,e) for(ll i = s; i <= (ll)e; ++i)
#define DEC(i,s,e) for(ll i = s; i >= (ll)e; --i)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << "\n"
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << "\n"
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<"\n"
#define dbv(v) cerr << #v << ":"; for (auto ite : v) cerr << ite << ' '; cerr <<"\n"
#define dbvp(v) cerr << #v << ":"; for (auto ite : v) cerr << "{"  << ite.f << ',' << ite.s << "} "; cerr << "\n"
#define dba(a,ss,ee) cerr << #a << ":"; FOR(ite,ss,ee) cerr << a[ite] << ' '; cerr << "\n"
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "LINE: " << __LINE__ << "\n";
typedef pair <ll, ll> pi;
typedef tuple<ll,ll,ll> ti3;
string cts(char x) {string t(1,x); return t;}
ll rand(ll a, ll b) { return a + rng() % (b-a+1); }
const int MOD = 1e9 + 7;
const int inf = (int)1e9 + 500;
const long long oo = (ll)1e18 + 500;
template <typename T> void chmax(T& a, T b) { a = max(a, b); }
template <typename T> void chmin(T& a, T b) { a = min(a, b); }
const int MAXN = 2e5+5;
#ifndef LOCAL
#define cerr if(0)cout
#endif
int A[MAXN];
int sum[MAXN];
int32_t main() 
{
	IAMSPEED
	int n,k; cin >> n >> k;
	FOR(i,1,n){
		cin>>A[i];
	}
	bool cont = 1;
	while(cont&&k--) {
		bool alln = 1;
		memset(sum,0,sizeof sum);
		FOR(i,1,n) {
			int st = max(i-A[i],1ll);
			int en = min(i+A[i],(ll)n);
			if(en != n || st != 1) alln=0;
			sum[st]++;
			sum[en+1]--;
		}
		FOR(i,1,n) {
			sum[i]+=sum[i-1];
			A[i]=sum[i];
		}
		if(alln)cont=0;
	}
	FOR(i,1,n)cout<<A[i]<<' ';
	
		
			
}


Measured memory_bytes: 5224
// JSでのIO処理準備
var lines     = [];
var readline  = require('readline').createInterface(process.stdin, process.stdout);

// 入力値の数値化
var parseInt10 = function(elem) {
  return parseInt(elem, 10);
}
var toInt = function(line) {
  var intArray = line.split(' ').map(parseInt10);
  if(intArray.length === 1) {
    return intArray[0];
  } else {
    return intArray;
  }
};

// 設定情報
var settings = {};
var defineRule = function(index, data, vars) {
  settings[index] = {};
  for(var i = 0; i < vars.length; i += 1) {
    settings[index][vars[i]] = data[i];
  }
};


// 入力値の加工
var calculate = function(data) {
  var v = Math.pow(data, 3);
  console.log(v);
};

// main
readline.on('line', function(line) {
  line = toInt(line); // 入力値の数値化
  lines.push(line);

  calculate(line);

});


Measured memory_bytes: 16544
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, C;
    cin >> A >> B >> C;
    cout << min(B / A, C) << endl;
    return 0;
}

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

typedef long long W;

const W INF = 1LL << 50;

struct edge {
	int to;
	W cost;
};
typedef pair<W, int> P;
typedef vector<vector <edge > > Graph;

void dijkstra(int s, const Graph& G, vector<W>& d) {
	priority_queue< P, vector<P>, greater<P> > que;
	fill(d.begin(), d.end(), INF);
	d[s] = 0;
	que.push(P(0, s));
	while(!que.empty()) {
		P p = que.top();
		que.pop();
		int v = p.second;
		if(d[v] < p.first) continue;
		for(int i = 0; i < G[v].size(); i++) {
			edge e = G[v][i];
			if(d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

ll d[100][100];

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

	int n, m;

	while(cin >> n >> m, n) {
		fill((ll*)begin(d), (ll*)end(d), INF);
		for(int i = 0; i < n; i++) {
			d[i][i] = 0;
		}

		Graph g(n);

		while(m--) {
			int type, a, b, c;
			cin >> type;
			if(type == 0) {
				cin >> a >> b;
				a--, b--;
				if(d[a][b] == INF) cout << -1 << endl;
				else cout << d[a][b] << endl;
			}
			else {
				cin >> a >> b >> c;
				a--, b--;

				g[a].push_back({ b, c });
				g[b].push_back({ a, c });

				vector<W> d1(n), d2(n);
				dijkstra(a, g, d1);
				dijkstra(b, g, d2);

				for(int i = 0; i < n; i++) {
					for(int j = 0; j < n; j++) {
						d[i][j] = min({ d[i][j], d1[i] + c + d2[j], d2[i] + c + d1[j] });
					}
				}
			}
		}
	}
}

Measured memory_bytes: 3300
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s1,s2;
  cin >> s1 >> s2 ;
  int a,b;
  cin >> a >> b;
  string s;
  cin >> s;
  if(s==s1)a--;
  if(s==s2)b--;
  cout << a << " " << b << endl;
}


Measured memory_bytes: 3656
#include <iostream>//数据输入输出流
#include <cstring>//字符串操作函数
#include <cstdio>//C的输入输出
#include <cstdlib>//定义杂项函数及内存分配函数
#include <cmath>//C中的数学函数
#include <string>//c++中的string类 他不能用strcpy等c函数去操作
#include <vector>//STL vetor
#include <list>//STL list
#include <map>// STL map
#include <queue>// STL queue
#include <stack>//sTL stack
#include <bitset>//bitset可按位定义串
//比如：bitset <1000> all;定义一个1000位的串
#include <algorithm>//STL各种算法 比如 swap sort merge max min 比较
#include <numeric>//常用数字操作 一般和algorithm搭配使用
#include <functional>//STL定义运算函数（代替运算符）
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
#define LOCAL
#define zeros(a,n) memset(a,0,(n)*sizeof(a[0]))
const int modn = 1e9+7;
int mod(int x) { return x<0?x+modn:x<modn?x:x-modn; }
//inv [ i ] = (modn - modn/i)*inv[ modn%i ] %modn;
int sum;
int main()
{
    int n, m;
    scanf("%d%d", &n,&m);
    VI a(m);
    for(int i = 0; i < m; ++i) {
        scanf("%d", &a[i]);
        sum += a[i];
    }
    if(sum > n) puts("-1");
    else{
        printf("%d\n", n - sum);
    }
    return 0;
}



Measured memory_bytes: 3264
import java.text.DecimalFormat;
import java.util.Scanner;


public class Main {


	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		 double r = scan.nextDouble();
		DecimalFormat df = new DecimalFormat("0.000000");
		double s = r*r*Math.PI;
		double a = r*2*Math.PI;
		System.out.println(df.format(s)+" "+df.format(a));

	}

}

Measured memory_bytes: 27896
#include <stdio.h>
int main(void){
  char a[2];
  scanf("%c",a);
  if(a[0] >= 65 && a[0] <= 90){
    printf("A\n");
  }else if(a[0] >= 97 && a[0] <= 122){
    printf("a\n");
  }
  return 0;
}

Measured memory_bytes: 1560
#include <iostream>
#include <cstdio>
using namespace std;
int n, m, k, res;
int p[11], l[11], check[11], a[11][11], id[1025][11];
void inp() {
    cin >> n >> m;
    for(int i=1; i<=m; ++i) {
        cin >> l[i];
        for(int j=1; j<=l[i]; ++j) cin >> a[i][j];
    }
    for(int i=1; i<=m; ++i) cin >> p[i];
}
void prep() {
    k = 1 << n;
    for(int i=2; i<=k; ++i) {
        for(int j=1; j<=n; ++j) id[i][j] = id[i-1][j];
        id[i][n]++;
        for(int j=n; j>0; --j) {
            if(id[i][j] > 1) {
                id[i][j-1]++;
                id[i][j]-=2; } } }
}
void pc() {
    prep();
    int tmp = res = 0;
    for(int i=1; i<=k; ++i) {
        tmp = 0;
        for(int j=1; j<=n; ++j) check[j] = id[i][j];
        for(int j=1; j<=m; ++j) {
            int d = 0;
            for(int t=1; t<=l[j]; ++t)
                if(check[a[j][t]]) d++;
            if(d%2 == p[j]) tmp++;
                else break;
        }
        if(tmp == m) res++;
    }
    cout << res;
}
int main()
{
    inp();
    pc();
    return 0;
}


Measured memory_bytes: 256
class Array
  def sum
    result =  0
    self.each {|x| result += x}
    result
  end
end

n = gets.to_i
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
c = gets.split.map(&:to_i)
bonus = []
a.each_with_index { |v, i| bonus << v - 1 if a[i + 1] == v + 1}
ans = b.sum
bonus.each {|i| ans += c[i]}
puts ans


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define int_Max 2147483647
#define ll_Max 9223372036854775807
#define REP(i,f,n) for(int i=f; i<(n); i++)

int main()
{
  int ans = 0, n;
  int t=0, x=0, y=0;
  int t2, x2, y2;
  cin >> n;
  REP(i,0,n){
    cin >> t2 >> x2 >> y2;
    t = t2 - t;
    int sa = abs(x - x2) + abs(y -y2);
    if(sa<=t){
      int sa2 = abs(t- sa);
      if(sa2%2 == 1){
        ans=1;
      }else{
      }
    }else{
      ans = 1;
    }
    t = t2;
    x = x2;
    y = y2;
  }

  if(ans == 0)cout << "Yes" << endl;
  else cout << "No" << endl;

  //--debug : end_stoper
  //string end_stoper; cin >> end_stoper;

  return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define INF 1000000007
using namespace std;

int main(void) {
	int n,temp;
	cin >> n;
	vector<int> prime(55555);
	for(int i=0; i<55555; i++)prime[i]=1;
	for(int i=2; i<55555; i++){
		if(prime[i]==0)continue;
		temp=i;
		while(temp+i<55555){
			prime[temp+=i]=0;
		}
	}
	for(int i=6; i<55555; i+=5){
		if(prime[i]){
			cout << i;
			n--;
			if(n==0)break;
			else cout << " ";
		}
	}
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
template <class T>
inline void chmin(T &a, const T &b) { a = min(a, b); }
template <class T>
inline void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
inline bool kbit(const T &x, const int &k) { return ((x >> k) & 1LL); }
inline int popcount(const int &n) { return __builtin_popcount(n); }
inline ll popcountll(const ll &n) { return __builtin_popcountll(n); }
inline ll mask(const ll &k) { return (1LL << k) - 1LL; }
template <class T>
void zip(V<T> &v) {
    sort(all(v));
    v.erase(unique(all(v)), v.end());
}
template <class T>
int lwb(V<T> &v, const T &x) { return lower_bound(all(v), x) - v.begin(); }
template <class T>
int upb(V<T> &v, const T &x) { return upper_bound(all(v), x) - v.begin(); }
void dump() {
    cerr << '\n';
}
template <class Head, class... Tail>
void dump(Head &&head, Tail &&... tail) {
    cerr << head << (sizeof...(Tail) == 0 ? " " : ", ");
    dump(std::move(tail)...);
}
template <class T>
void print(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void read(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
constexpr char sp = ' ', newl = '\n';
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
constexpr ll INF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
//@docs Docs/UnionFind.md
struct UnionFind {
    vector<int> par, sz;
    UnionFind(int n) : par(n), sz(n, 1) {
        iota(par.begin(), par.end(), 0);
    }
    inline int find(int x) {
        if (x == par[x]) return x;
        return par[x] = find(par[x]);
    }
    bool unite(int u, int v) {
        u = find(u), v = find(v);
        if (u == v) return false;
        if (sz[u] < sz[v]) swap(u, v);
        par[v] = u;
        sz[u] += sz[v];
        return true;
    }
    inline int size(int x) {
        return sz[find(x)];
    }
    inline bool same(int u, int v) {
        return find(u) == find(v);
    }
};

//////////////////////////////////////////////INSERT ABOVE HERE
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        uf.unite(a, b);
    }
    int res = 0;
    for (int i = 0; i < n; i++) {
        chmax(res, uf.size(i));
    }
    cout << res << newl;
}

Measured memory_bytes: 4748
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

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

int main() {
    int n;
    cin >> n;
    cout << 1 - (n / 2) / (double)n << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N = int(input())
A =list(map(int,input().split()))
ans = 1
if 0 in A:
    ans=0
else:
    for i in range(N):
        ans *= A[i]
        if ans >= 10**18:
            break
    
print(-1 if ans>10**18 else ans)


Measured memory_bytes: 21808
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();
		for (int i = 0; i < n; i++) {
			System.out.println(solve(sc.nextLine(), sc.nextLine()));
		}
	}
	
	public static int solve(String x, String y) {
		int[][] dp = new int[x.length() + 1][y.length() + 1];
		for (int i = 1; i <= x.length(); i++) {
			for (int j = 1; j <= y.length(); j++) {
				dp[i][j] = Math.max(dp[i][j-1], dp[i-1][j]);
				if (x.charAt(i-1) == y.charAt(j-1)) {
					dp[i][j] = Math.max(dp[i][j], dp[i-1][j-1] + 1);
				}
			}
		}
		return dp[x.length()][y.length()];
	}
}

Measured memory_bytes: 60824
S=input()
R={}
L={}
curR = 0
for idx in range(len(S)):
	ch=S[idx]
	if(ch=='R'):
		curR+=1
	elif curR > 0:
		R[idx-1] = curR
		curR=0

curL = 0
for idx in range(len(S)-1,-1,-1):
	ch=S[idx]
	if(ch=='L'):
		curL+=1
	elif curL > 0:
		L[idx+1] = curL
		curL=0

ans = []
for idx in range(len(S)):
	if(idx in L):
		continue
	if(idx in R):
		rnum = R[idx]
		lnum = L[idx+1]
		ans.append((rnum + 1)//2 + lnum//2)
		ans.append((rnum)//2 + (lnum+1)//2)
	else:
		ans.append(0)

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

Measured memory_bytes: 20024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace B
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int n = RInt();
            int[] ls = RIntAr();
            ls = ls.OrderByDescending(x => x).ToArray();

            int max = ls.First();
            int others = ls.Sum() - max;

            Console.WriteLine(max < others ? "Yes" : "No");
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}


Measured memory_bytes: 13396
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<map>

using namespace std;

typedef long long ll;
const int Max = 1e5 + 5;
ll n, m, t, k, i, j, p, q, flag, ans;

int main(){
	while(scanf("%lld %lld", &n, &m) == 2){
		ans = 0;
		int a[Max] = {0};
		for(i = 0; i < n; i++){
			cin >> t;
			for(j = 0; j < t; j++) { cin >> k; a[k]++; }
		}
		for(i = 0; i <= m; i++)
			if(a[i] == n) ans++;
		cout << ans << endl;
	}
	return 0;
}

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

int main() {
  for(int i=0;i<9;i++) {
    if(i==0 || i==4 || i==8) {
      char a;
      cin >> a;
      cout << a;
    } else {
      char a;
      cin >> a;
    }
  }
  cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b && b==c)
        cout<<"No"<<endl;
    else if(a==b || b==c || c==a )
    {
        cout<<"Yes"<<endl;
    }
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() 
{
    long long int N;
    cin >> N;
    int minimum = 1 << 20;
    for(int i = 1;i <= sqrt(N) + 1;i++)
    {
        if(N % i == 0)
            minimum = min(minimum,max((int)(log10(i) + 1),(int)(log10(N/i) + 1)));
    }
    cout << minimum << endl;
}

Measured memory_bytes: 512
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=1e18;
typedef pair<int,int> P;
int h,w,dist[1005][1005]={},ans=0;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  cin >> h >> w;
  int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
  char c[1005][1005]={};
  queue<P> q;
  for(int i=0; i<h; i++) {
    for(int j=0; j<w; j++) {
      dist[i][j]=inf;
    }
  }
  for(int i=0; i<h; i++) {
    for(int j=0; j<w; j++) {
      cin >> c[i][j];
      if(c[i][j]=='#') {
        dist[i][j]=0,q.push({i,j});
      }
    }
  }
  while(!q.empty()) {
    P p=q.front();
    q.pop();
    for(int i=0; i<4; i++) {
      int nx=p.first+dx[i],ny=p.second+dy[i];
      if(0<=nx&&nx<h&&0<=ny&&ny<w) {
        if(dist[nx][ny]>dist[p.first][p.second]+1) {
          dist[nx][ny]=dist[p.first][p.second]+1;
          q.push({nx,ny});
        }
      }
    }
  }
  for(int i=0; i<h; i++) {
    for(int j=0; j<w; j++) {
      ans=max(ans,dist[i][j]);
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 13328
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,0,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  int N,ans=0,cnt=0;
  cin>>N;
  ll H[N];
  REP(i,N) cin>>H[i];
  
  REP(i,N){
    if(i!=N-1){
      if(H[i]>=H[i+1]) cnt++;
    }
    if(H[i]<H[i+1] || i==N-1){
      ans=max(ans,cnt);
      cnt=0;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(a>b &&b!=1 ||a==1 && b!=a)
        printf("Alice");
    else if (b>a && a!=1 ||b==1 && a!=b)
        printf("Bob");
    else
        printf("Draw");
    return 0;

}


Measured memory_bytes: 128
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

int gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int A;cin >> A;
    cout << A+pow(A,2)+pow(A,3) << endl;
}


Measured memory_bytes: 4204
#include<iostream>
#include<set>

using namespace std;

int main(){
	int N;
	cin >> N;
	int angka[N];
	for(int i = 0; i < N; i++){
		cin >> angka[i];
	}
	
	int deleted = 0;
	int idx = 1;
	for(int i : angka){
		if(i != idx){
			deleted++;
			continue;
		}
		idx++;
	}
	
	if(deleted == N)
		cout << "-1";
	else
		cout << deleted;
	
	cout << endl;
	return 0;
}

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

int main(){
  int a,b,x;
  cin >> a >> b >> x ;
  if ( x<a ){
    cout << "NO" << endl;
  }

  else if ( x <=(a+b) ){
    cout << "YES" << endl;
  }

  else {
    cout << "NO" << endl;
  }
}
        

Measured memory_bytes: 256
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(ll i=ini;i<(int)n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N = 1e8+7;


void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)
 
  
int main()
{
    int n;
    scf(n);
 
    
    ll sum=0;
    
    ll a[n];
    
    rep(i,0,n)
    lscf(a[i]);
    
    ll v=a[0]^a[1];
    
    rep(i,2,n)
    v^=a[i];
    
    ll b[n];
    
    rep(i,0,n)
    {
        b[i]=a[i]^v;
    }
    
    rep(i,0,n)
    lpri(b[i]);
    

}

Measured memory_bytes: 6764
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

Graph g;
void bfs(vec &dist, vec &par, ll s)
{
    queue<ll> que;
    dist[s] = 0;
    que.push(s);
    while (!que.empty())
    {
        ll v = que.front();
        que.pop();
        for (auto next_v : g[v])
        {
            if (dist[next_v] != -1)
                continue;
            par[next_v] = v;
            dist[next_v] = dist[v] + 1;
            que.push(next_v);
        }
    }
}
int main()
{
    cout << fixed << setprecision(30);
    ll n, m;
    cin >> n >> m;
    g.resize(n);
    loop(i, m)
    {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<ll> dist(n, -1);
    vector<ll> par(n, 0);
    bfs(dist, par, 0);
    putout("Yes");
    Loop(i, 1, n)
    {
        putout(par[i] + 1);
    }
    return 0;
}


Measured memory_bytes: 13748
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;
int INF=1<<30;


int main(void) {

    int N,P; cin>>N>>P;
    string S; cin>>S;
    ll ans = 0;
    map<int,int> mp;

    ll cur=0;
    ll keta=1;
    if(P==2||P==5){
        for (int i = 0; i < N; ++i) {
            if((S[i]-'0')%P == 0) ans += i+1;
        }
    }else{
        mp[0]=1;
        reverse(S.begin(),S.end());

        for (int i = 0; i < N; ++i) {
            cur += (S[i]-'0')*keta;
            cur %= P;
            ans += mp[cur]++;
            keta *= 10;
            keta %= P;
        }

    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 900
H, W = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())
A = [[i for i in input()] for _ in range(H)]

visited = [[-1] * W for i in range(H)]
visited[Ch - 1][Cw - 1] = 0
h = [(Ch - 1, Cw - 1)]
c = 0
while True :
  done = []
  while h :
    cy, cx = h.pop()
    done.append((cy, cx))
    visited[cy][cx] = c
    for dy, dx in ((0, 1), (0, -1), (1, 0), (-1, 0)) :
      ny, nx = cy + dy, cx + dx
      if 0 <= ny < H and 0 <= nx < W and A[ny][nx] == '.' and visited[ny][nx] == -1 :
        h.append((ny, nx))
        visited[ny][nx] = c

  h = []
  for cy, cx in done :
    for dy in range(-2, 3) :
      for dx in range(-2, 3) :
        ny, nx = cy + dy, cx + dx
        if 0 <= ny < H and 0 <= nx < W and A[ny][nx] == '.' and visited[ny][nx] == -1 :
          h.append((ny, nx))
  if not h :
    break
  c += 1  
  
print(visited[Dh - 1][Dw - 1])

Measured memory_bytes: 170084
//
//  main.swift
//  Atcoder
//
//  Created by Louis Joe Shen on 2020/7/17.
//  Copyright © 2020 Louise Joe Shen. All rights reserved.
//

import Foundation

var input = readLine()
var input2 = readLine()
var inputs = input!.components(separatedBy: " ")
var inputs2 = input2!.components(separatedBy: " ")

var N = Int(inputs[0])!
var K = Int(inputs[1])!

var D : [Int] = [Int]()

for i in 0 ..< K {
    D.append(Int(inputs2[i])!)
}

for i in N ... 666666 {
    if(isLike(number: i)){
        print(i)
        break;
    }
}
func isLike(number: Int) -> Bool {
    let delta = String(number)
    for c in delta {
        for dig in D {
            if(Int(String(c))! == dig){
                return false
            }
        }
    }
    return true;
}


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

int main()
{

    int x, n, a[100], i, w = 0, q = 0; //wは距離
    scanf("%d %d", &x, &n);

    w = x;

    if (n == 0)
    {
        printf("%d", x);
        return 0;
    }

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

    int mode = 0;
    int j;

    for (j = x; j < 200; j++)
    {
        for (i = 0; i < n; i++)
        {
            if (j == a[i])
                mode = 1;
        }
        if (mode == 0)
            break;
        mode = 0;
    }

    int k;

    for (k = x; k > -50; k--)
    {
        for (i = 0; i < n; i++)
        {

            if (k == a[i])
            {
                mode = 1;
            }
        }
        if (mode == 0)
            break;
        mode = 0;
    }

    

    int y = 0, u = 0;
    y = j - x;
    u = x - k;

    if (w < y && w < u)
    {
        
        printf("%d", w);
        return 0;
    }

    else if (y < u)
    {
        printf("%d", j);

        return 0;
    }
    else
    {
        
        printf("%d", k);

        return 0;
    }

    printf("%d", w);

    return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main(){
  long long i,ans;
  string s;
  cin >> i;
  ans = i;
  while(true){
    cin >> s;
    if(s == "="){
       cout << ans << endl;
       break;
    }
    cin >> i;
    if(s == "+") ans += i;
    if(s == "-") ans -= i;
    if(s == "*") ans *= i;
    if(s == "/") ans /= i;
  }
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
bool isValid(int value, int a, int b){
    int sum = 0;
    while(value>0){
        sum+=value%10;
        value/=10;
    }
    if( (sum>=a) &&
        (sum<=b)){
            return true;
    }else{
        return false;
    }
}
int main(){
    int n,a,b;
    cin >> n >> a >> b;
    long ans = 0;
    for(int i = 1; i <= n; i++){
       if(isValid(i,a,b)){
           ans += (long)i;
       } 
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int A[5][5];
bool F[5][5];
int N;
int B[11];

signed main(){
	REP(i,3){
		REP(j,3){
			cin>>A[i][j];
		}
	}
	cin>>N;
	REP(i,N){
		cin>>B[i];
	}
	REP(i,N){
		REP(j,3){
			REP(k,3){
				if(B[i]==A[j][k]){
					F[j][k]=true;
				}
			}
		}
		bool flag=false;
		REP(i,3){
			if(F[i][0]==true&&F[i][1]==true&&F[i][2]==true){
				flag=true;
			}
		}
		REP(i,3){
			if(F[0][i]==true&&F[1][i]==true&&F[2][i]==true){
				flag=true;
			}
		}
		if(F[0][0]==true&&F[1][1]==true&&F[2][2]==true){
			flag=true;
		}
		if(F[2][0]==true&&F[1][1]==true&&F[0][2]==true){
			flag=true;
		}
		if(flag==true){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}


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

#define ll long long

using namespace std;

const int MOD = 1e9+7;
const int N = 1e6+10;

int record[2*N];

inline ll pow(ll a,ll b){
	ll res = 1;
	while(b){
		if(b&1)
			res = (res * a) % MOD;
		a = (a * a) % MOD;
		b >>= 1;
	}
	return res;
}

inline ll A(ll a){
	return record[a];
}

inline ll C(ll a,ll b){
	ll res = (A(a) * pow((A(a-b)*A(b))%MOD,MOD-2))%MOD;
	return res;
}

int main(){
	//freopen("in","r",stdin);
	ios_base::sync_with_stdio(false); cin.tie(0);
	record[0] = 1;
	int a,b,c,d; cin >> a >> b >> c >> d;
	for(ll i = 1;i <= 2*N;i++) record[i] = (record[i-1]*i)%MOD; 
	ll res = 0;
	for(int i = a;i <= c;i++){
		res = (res + C(d+i+1,i+1) - C(b+i,i+1) + MOD)%MOD;	
	}	
	cout << res << endl;
}

Measured memory_bytes: 8064
from scipy.sparse import*
f=csgraph.floyd_warshall
I=9e9
n,m,l,*t=map(int,open(0).read().split())
d=eval('[I]*-~n,'*-~n)
for a,b,c in zip(*[iter(t[:m*3])]*3):d[a][b]=d[b][a]=c
d=f(d)
d[d>l]=I
d[d<I]=1
d=f(d)
for i in zip(*[iter(t[m*3+1:])]*2):print((I>d[i])*int(d[i])-1)

Measured memory_bytes: 40856
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
  int n;
  cin>>n;
  ll sum = 0;
  for(int i=1;i<n+1; i++){
    if(i%3==0||i%5 == 0)continue;
    sum+=i;
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 3596
#include <iostream>

using namespace std;

int main(void)
{
    int a, b, c, d, ans=0;

    cin >> a >> b >> c >> d;

    if(a<b){
        ans += a;
    }
    else{
        ans += b;
    }

    if(c<d){
        ans += c;
    }
    else{
        ans += d;
    }

    cout << ans << endl;

    return 0;
}

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

priority_queue<ll, vector<ll>, less<ll> >que;

int main()
{
	int n,m;cin>>n>>m;
	ll a;
	for(int i=0;i<n;i++){
		cin>>a;
		que.push(a);
	} 
	ll now;
	while(m>0)
	{
		now=que.top();que.pop();
		now/=2;
		m--;
		que.push(now);
	}
	ll ans=0;
	while(!que.empty()){
		ans=ans+que.top();
//		cout<<que.top()<<endl;
		que.pop();
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

#define int long long



int32_t main()
{
        int n,t;
        cin>>n>>t;

        int ans=t;
        vector < int > a(n);
        for(int i=0;i<n;i++)
        {
                cin>>a[i];
                if(i>0)
                {
                        if(a[i]-a[i-1]>=t)
                                ans+=t;
                        else
                                ans+=a[i]-a[i-1];
                }
        }
        cout<<ans<<endl;

        return 0;
}



Measured memory_bytes: 1792