akhauriyash/Code-Regression huggingface dataset:
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::HashMap;

fn main() {
    input!(n: usize, ss: [chars; n]);

    let mut head_b = 0;
    let mut tail_a = 0;
    let mut tot = 0;
    let mut ba = 0;
    for i in 0..n {
        let s = &ss[i];
        for j in 0..s.len() - 1 {
            if s[j] == 'A' && s[j + 1] == 'B' {
                tot += 1;
            }
        }
        if s[0] == 'B' && s.last().unwrap() == &'A' {
            ba += 1;
        } else if s[0] == 'B' && s.last().unwrap() != &'A' {
            head_b += 1;
        } else if s[0] != 'B' && s.last().unwrap() == &'A' {
            tail_a += 1;
        }
    }
    // println!(
    //     "tot:{}, ba:{}, head_b:{}, tail_a:{}",
    //     tot, ba, head_b, tail_a
    // );
    let mut ans = tot;
    if ba == 0 {
        ans += min(tail_a, head_b);
    } else if ba > 0 {
        if head_b + tail_a == 0 {
            ans += ba - 1;
        } else {
            ans += ba + min(tail_a, head_b);
        }
    }
    println!("{}", ans);
}


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

#define ll long long int
#define mp make_pair
#define ff first
#define ss second
#define fr(i,l,r) for (long long int i = l; i < r; ++i)
#define frr(i,l,r) for (long long int i = r; i >= l; --i) 
#define sortarr sort(arr,arr+n) //sorts array in asc order
#define sortarr_r sort(arr, arr+n, greater<long long int>()) //sorts array in desc order
#define make_set set<long long int>s //Set arranges in asc order
#define make_set_r set<long long int, greater <long long int>>s ////Set arranges in desc order
#define make_vector vector<long long int>v; 
#define pb push_back


// string size = str.size()

// stack <int> s; 
// queue <int> gquiz; 
// __gcd(m, n) 

// ll arr[10e5 + 5];
// char arr[10e5 + 5];


bool compare(string &s1,string &s2) 
{ 
    return s1.size() < s2.size(); 
} 
void yes()
{
    cout << "YES" << endl;
}
void no()
{
    cout << "NO" << endl;
}


int main(void)
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    std::cout << std::fixed;
    std::cout << std::setprecision(12);
    ll l;
    cin >> l;
    double rem = (double)l/3;
    cout << rem*rem*rem << endl;
    return 0;
}   

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	ld r;
	cin >> r;
	cout << fixed << setprecision(10) << (ld)(6.28318530717958623200 * r) << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 3804
#include <cassert>
#include <iomanip>
#include <iostream>
#include <queue>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

void dijkstra(vector<vector<pair<int64_t, int64_t>>>& G, vector<int64_t>& dist,
              int s) {
  dist[s] = 0;
  priority_queue<pair<int64_t, int64_t>, vector<pair<int64_t, int64_t>>,
                 greater<pair<int64_t, int64_t>>>
      que;
  que.emplace(0, s);
  while (!que.empty()) {
    int64_t cost, u;
    tie(cost, u) = que.top();
    que.pop();
    for (auto& v : G[u]) {
      int64_t ncost = cost + v.first;
      if (dist[v.second] == -1 || (ncost < dist[v.second])) {
        dist[v.second] = ncost;
        que.emplace(ncost, v.second);
      }
    }
  }
}

int main(void) {
  ios::sync_with_stdio(false);
  int N, M, S, T;
  cin >> N >> M >> S >> T;
  S--, T--;
  vector<vector<pair<int64_t, int64_t>>> Ga(N);
  vector<vector<pair<int64_t, int64_t>>> Gb(N);
  rep(i, M) {
    int64_t u, v, a, b;
    cin >> u >> v >> a >> b;
    u--, v--;
    Ga[u].emplace_back(a, v);
    Ga[v].emplace_back(a, u);
    Gb[u].emplace_back(b, v);
    Gb[v].emplace_back(b, u);
  }

  vector<int64_t> distA(N, -1);
  dijkstra(Ga, distA, S);
  vector<int64_t> distB(N, -1);
  dijkstra(Gb, distB, T);

  vector<int64_t> answer(N, 0);
  int64_t max_money = 0;
  for (int i = N - 1; i >= 0; --i) {
    int64_t current = 1e15 - (distA[i] + distB[i]);
    max_money = max(max_money, current);
    answer[i] = max_money;
  }
  rep(i, N) { cout << answer[i] << endl; }
  return 0;
}


Measured memory_bytes: 21024
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(long long i=0;i<n;i++)
#define REP1(i,n) for(long long i=1;i<=n;i++)
#define REP2D(i,j,h,w) for(long long i=0;i<h;i++) for(long long j=0;j<w;j++)
#define REP2D1(i,j,h,w) for(long long i=1;i<=h;i++) for(long long j=1;j<=w;j++)
#define PER(i,n) for(long long i=((n)-1);i>=0;i--)
#define PER1(i,n) for(long long i=(n);i>0;i--)
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define FORE(i,a,b) for(long long i=(a);i<=(b);i++)
#define ITE(arr) for(auto ite=(arr).begin();ite!=(arr).end();++ite)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define YNPRT(b) cout<<((b)?"Yes":"No")<<endl
#define REV(arr) reverse(ALL(arr))
#define PRT(a) cout<<a<<endl;
#define PRTLST(arr,num) REP(_i,num) cout<<_i<<" - "<<arr[_i]<<endl;
#define PRTLST2(arr2,d1,d2) REP(_i,d1) REP(_j,d2) cout<<_i<<","<<_j<<" : "<<arr2[_i][_j]<<endl;
#define PRTLST2D(arr2,d1,d2) do{cout<<"L\t";REP(_i,d2) cout<<_i<<"\t"; cout<<endl; REP(_i,d1){cout<<_i<<"\t";REP(_j,d2){cout<<arr2[_i][_j]<<"\t";}cout<<endl;}}while(0);
#define fst first
#define scd second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF_INT = 2147483647;
const ll INF_LL = 9223372036854775807LL;
const ull INF_ULL = 18446744073709551615Ull;
const ll P = 92540646808111039LL;
const int Move[4][2] = {-1,0,1,0,0,1,0,-1};
const int Move_[8][2] = {-1,-1,-1,0,-1,1,0,-1,0,1,1,-1,1,0,1,1};

//---------------------
#define MAXN 100000
//---------------------

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {ITE(v) os << *ite << " ";return os;}

ll n,l;

int main(){
	cin>>n>>l;
	ll maxn=l+n-1;
	ll minn=l;
	ll ret=0;
	if(minn>0){
		ret=(maxn+minn)*n/2-minn;
	}else{ //minn <= 0
		if(maxn>=0){
			ret=(maxn+minn)*n/2;
		}else{
			ret=(maxn+minn)*n/2-maxn;
		}
	}
	cout<<ret<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC114_B solver = new ABC114_B();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC114_B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String str = in.next();
            int ans = Integer.MAX_VALUE;
            for (int i = 0; i < str.length() - 2; i++) {
                int split = Integer.parseInt(str.substring(i, i + 3));
                int abs = Math.abs(753 - split);
                ans = ans < abs ? ans : abs;
            }

            out.print(ans);

        }

    }
}



Measured memory_bytes: 23764
#include <stdio.h>
#include <iostream>
#include <vector>
#include <assert.h>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <sstream>
#include <memory.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <functional>
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{
	int n, k;
	scanf("%d%d", &n, &k);
	vector<int> v(n);
	for (int i = 0; i < n; ++i)
		scanf("%d", &v[i]);
	const int M = 1000000007;
	vector<vector<int> > dp(n + 1, vector<int>(k + 1));
	fill(dp[n].begin(), dp[n].end(), 1);
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j <= k; ++j) {
			int l = max(0, j - v[i]);
			int r = j;
            int &ret = dp[i][j];
			ret = dp[i + 1][r];
			if (l) {
				ret += M - dp[i + 1][l - 1];
				if (ret >= M)
					ret %= M;
			}
			if (j) {
				ret += dp[i][j - 1];
				if (ret >= M)
					ret %= M;
			}
		}
	}
	printf("%d\n", (dp[0][k] - (k ? dp[0][k - 1] : 0) + M) % M);
	return 0;
}


Measured memory_bytes: 40192
from itertools import accumulate

N=int(input())
S=input()

black=[0]*N
white=[0]*N

for i,s in enumerate(S):
    if s=='#':
        black[i]=1
    else:
        white[i]=1

black=[0]+black
black=list(accumulate(black))
white=[0]+white[::-1]
white=list(accumulate(white))[::-1]

ans=[]

for i in range(N+1):
    ans.append(black[i]+white[i])

print(min(ans))

Measured memory_bytes: 29176
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(25);

  int n;
  cin >> n;

	vector<pair<int, int>> ans;
  if (n % 2 == 0) {
    FOR(i, 1, n + 1) {
      FOR(j, i + 1, n + 1) {
        if (i + j != n + 1) {
          ans.push_back({i, j});
        }
      }
    }
  }
	else {
	  FOR(i, 1, n + 1) {
		  FOR(j, i + 1, n + 1) {
				if (i + j != n) {
					ans.push_back({i, j});
				}
			}
		}
	}
	int m = ans.size();
	cout << m << '\n';
	rep(i, m) cout << ans[i].first << ' ' << ans[i].second << '\n';




  
  return 0;
}

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

#ifdef LOCAL
#include <debug.hpp>
#else
#define debug(...) void()
#endif

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  cout << (n == 0 ? 1 : 0);
  return 0;
}

Measured memory_bytes: 3636
n = int(input())
lis = []
for i in range(n):
    s,p = list(input().split())
    lis.append([i+1,s,int(p)])
t = sorted(lis, key=lambda x: -x[2])
s = sorted(t, key=lambda x: x[1])


for i in s:
    print(i[0])

Measured memory_bytes: 3060
import scala.io.StdIn._

object Main  {
  def main(args: Array[String]): Unit = {
    val K = readToInts()(1)
    val dice = readToVectorInts()
    println(solve(K, dice))
  }

  def solve(K: Int, dice: Vector[Int]): Double = {
    val diceAvg = dice.map(Dice.avg)    

    val initial = Iterator.iterate(0)(n => n + 1)
      .takeWhile(n => n < K)
      .map(n => diceAvg(n))
      .toList
      .foldLeft(0d)((total, next) => total + next)

    Iterator.iterate(Dice(0, initial))(d => d.getNewDice(diceAvg, K))
      .takeWhile(d => d.index <= dice.length - K)
      .map(d => d.total)
      .max
  }

  def readToInts(): Array[Int] = readLine.split(" ").map(_.toInt)
  def readToListInts(): List[Int] = readLine.split(" ").map(_.toInt).toList
  def readToVectorInts(): Vector[Int] = readLine.split(" ").map(_.toInt).toVector

}

case class Dice(index: Int, total: Double) {
  def getNewDice(vec: Vector[Double], K: Int): Dice = {
    if (index + K >= vec.length) {
      Dice(index + 1, 0.0)
    } else {
      Dice(index + 1, total + vec(index + K) - vec(index))
    }
  }
  override def toString: String = s"$index - $total"
}

object Dice {
  def avg(v: Int): Double = (v + 1.0) / 2.0
}

Measured memory_bytes: 82104
#include "bits/stdc++.h"
using namespace std;

int n,a,b,arr[100001],ans = 0;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	for(int i=1;i<=100000;i++){
		int temp = i, sum = 0;
		while(temp != 0){
			sum += temp%10;
			temp /= 10;
		}
		arr[i] = sum;
	}
	cin>>n>>a>>b;
	for(int i=1;i<=n;i++){
		if(arr[i] <= b && arr[i] >= a)
			ans += i;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define mn(a,b) (a < b ? a : b)
#define mx(a,b) (a > b ? a : b)
#define f first
#define s second
#define mp make_pair
#define all(v) (v).begin(),(v).end()

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a, b, c;
    cin>>a>>b>>c;
    if(a == b)
        cout<<c;
    else if(a == c)
        cout<<b;
    else
        cout<<a;
    return 0;
}


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

typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int T;

int main() {
	cin >> T;
	while (T--) {
		int N, D;
		int ans = 0;
		cin >> N >> D;

		rep(i, 7) {
			int num = N-(((D>>i)&1)!=(N&1));
			ans += num * (1<<i);
		}
		cout<<ans<<endl;
	} 
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = input().split()
B = input().split()
count = 0
a = []
b = []
c = []
e = 0
for i in range(N):
  a.append(float(A[i]))
  b.append(float(B[i]))
su=sum(a)-sum(b)
if su <0:
  print(-1)
  exit()
else:
  for i in range(N):
    C=a[i]-b[i]
    if C >=0:
      c.append(C)
    else:
      e+=C
      count += 1
c.sort(reverse=True)
if e == 0:
  print(0)
  exit()
else:
  for i in range(len(c)):
    e=c[i]+e
    count += 1
    if e >= 0:
      print(count)
      exit()
    else:
      continue

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


int main() {

    string a, b;
    cin >> a >> b;
    int l = a.length() + b.length();
    int x = 0, y = 0;
    for (int i = 0; i < l; ++i) {
        if (i % 2 == 0) {
            cout << a[x];
            ++x;
        }
        else {
            cout << b[y];
            ++y;
        }
    }
    cout << endl;
    return 0;
}

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

int main() {
  int N, a, b;
  cin >> N;
  a = N % 10;
  b = N / 1000;
  if(((N - a)% 111 == 0) || ((N - b*1000)%111 == 0)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
static const int MAX = 200000;
 
int main(){
    int n,a[MAX];
    cin >> n;

    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int maxv = a[1]-a[0],minv = a[0];
    for(int j = 1; j < n;  j++){
        maxv = max(maxv,a[j] - minv);
        minv = min(minv,a[j]);
    }
    cout << maxv << endl;
    return 0;
}

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

#define     fast()              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define     ll                  long long int
#define     test()              ll t; cin>>t; while(t--) 
#define     lp0(i,begin,end)    for(ll i=begin;i<end;i++)
#define     lp1(i,begin,end)    for(ll i=begin;i<=end;i++)
#define     rlp(i,begin,end)    for(ll i=end;i>=begin;i--)
#define     prec(n)             fixed<<setprecision(n)
#define     initial(a,i)        memset(a,i,sizeof(a))
#define     pb                  push_back
#define     PI                  3.1415926535897932384626433832795
#define     MOD                 1000000007
#define     F                   first
#define     S                   second
#define     all(a)              (a).begin(),(a).end()
#define     BPC(x)              __builtin_popcountll(x)
#define     gcd(a,b)            __gcd(a,b)

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

ll power(ll x,ll n)
{
    ll result = 1;
    while (n)
    {
        if (n & 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}


// Solution Function
void solution(ll compte)
{
    // cout<<compte<<"\n";
    ll a,b,c;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b;
}
// Driver Function
int main()
{
    ll compte = 1;
    //test()
    //{
        solution(compte);
        compte++;
    //}
    return 0;
}


Measured memory_bytes: 3604
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

def main():
    a=list(map(int, input().split()))
    a.sort()
    ans=a[2]-a[1]
    a[0]+=ans
    a[1]+=ans
    d=a[1]-a[0]
    ans+=d//2
    ans+=(d%2)*2
    print(ans)

main()

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;

// Inserted snippets: io, root
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
// End snippets

int f[105][10], p[105][11];

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

  int n; read(n);
  rep(i, 0, n) rep(j, 0, 10) read(f[i][j]);
  rep(i, 0, n) rep(j, 0, 11) read(p[i][j]);

  ll ans = -0x3f3f3f3f3f3f3f3fll;
  rep(b, 1, 1 << 10) {
    ll val = 0;
    rep(i, 0, n) {
      int cnt = 0;
      rep(j, 0, 10) if (b & (1 << j) && f[i][j]) cnt++;
      val += p[i][cnt];
    }
    chmax(ans, val);
  }
  write(ans);
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll a,b;
  cin >> a >> b;
  string s;
  cin >> s;
  ll f=1;
  for(ll i=0;i<a;i++) {
    if(s[i]<'0'||'9'<s[i]) f=0;
  }
  if(s[a]!='-') f=0;
  for(ll i=a+1;i<a+b+1;i++) {
    if(s[i]<'0'||'9'<s[i]) f=0;
  }
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
from math import log2
n,k = map(int,input().split())
a = list(map(int,input().split()))
b = [0]*n

if(k > 10*log2(n) + 1):
    for i in range(n):
        print(n,end=" ")

else:
    for j in range(k):
        b = [0]*n
        for i in range(n):
            l = max(0,i-a[i])
            r = min(n-1,a[i]+i)
            b[l] += 1
            if(r+1<n):
                b[r+1] -= 1
        for i in range(1,n):
            b[i] += b[i-1]
        a = b


    for i in a:
        print(i,end=" ")


Measured memory_bytes: 141204
#include <iostream>
#include <string.h>

using namespace std;

int main(void)
{
 string S,T;
  int A,B;
  string U;
  cin >> S >> T;
  cin >> A >> B;
  cin >> U;
  if(S == U)
  {
    cout << A-1 << " " << B << endl;
  }
  else
  {
    cout << A << " " << B-1 << endl;
  }
  
}

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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

void solve() {
    int N;
    cin >> N;
    int dp[N];
    REP(i, N) dp[i] = 0;
    vector<int> h(N);
    REP(i, N) cin >> h[i];
  
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for (int i = 2; i < N; i++) {
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
    }
    print(dp[N-1]);

}

signed main() {
    solve();
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define N 100006
using namespace std;
map<int,int>g;
int n,x,m,tot,cnt,ma,p,a[N],d[N],ls[20*N],rs[20*N],w[20*N],t[N];long long ans[N],s[20*N];
inline int read()
{
	int x=0,c=getchar();while(c<48)c=getchar();
	while(c>47)x=x*10+c-48,c=getchar();return x;
}
void print(long long x)
{
	if(x>9LL)print(x/10LL);putchar(x%10LL+48LL);
}
int build(int l,int r)
{
	int mid=(l+r)>>1,rt=++tot;
	if(l==r)return rt;
	ls[rt]=build(l,mid);
	rs[rt]=build(mid+1,r);
	return rt;
}
void add(int rt,int nrt,int l,int r,int x,int k)
{
	s[nrt]=s[rt]+1LL*k;w[nrt]=w[rt]+1;
	int mid=(l+r)>>1;
	if(l==r)return;
	if(x<=mid){
		ls[nrt]=++tot;
		rs[nrt]=rs[rt];
		add(ls[rt],ls[nrt],l,mid,x,k);
	}else{
		rs[nrt]=++tot;
		ls[nrt]=ls[rt];
		add(rs[rt],rs[nrt],mid+1,r,x,k);
	}
}
long long query(int lrt,int rrt,int l,int r,int x,int y)
{
	if(y<x)return 0;
	if(x<=l&&r<=y)return s[rrt]-s[lrt];
	int mid=(l+r)>>1;long long tmp=0;
	if(x<=mid)tmp=query(ls[lrt],ls[rrt],l,mid,x,y);
	if(y>mid)tmp+=query(rs[lrt],rs[rrt],mid+1,r,x,y);
	return tmp;
}
long long query2(int lrt,int rrt,int l,int r,int x,int y)
{
	if(y<x)return 0;
	if(x<=l&&r<=y)return 1LL*(w[rrt]-w[lrt]);
	int mid=(l+r)>>1;long long tmp=0;
	if(x<=mid)tmp=query2(ls[lrt],ls[rrt],l,mid,x,y);
	if(y>mid)tmp+=query2(rs[lrt],rs[rrt],mid+1,r,x,y);
	return tmp;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)d[i]=a[i]=read();
	sort(d+1,d+n+1);
	g[0]=++cnt;
	for(int i=1;i<=n;i++)if(d[i]!=d[i-1])g[d[i]]=++cnt;
	t[0]=build(1,n);
	for(int i=1;i<=n;i++)t[i]=++tot,add(t[i-1],t[i],1,cnt,g[a[i]],a[i]);
	for(int i=1;i<=n;i++)if(a[i]>ma){
		ans[i]=query(t[0],t[n],1,cnt,g[ma]+1,g[a[i]]-1)-1LL*ma*query2(t[0],t[n],1,cnt,g[ma]+1,g[a[i]]-1)+1LL*(a[i]-ma)*query2(t[0],t[n],1,cnt,g[a[i]],cnt);
		ma=a[i];print(ans[i]);puts("");
	}else puts("0");
}

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

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

    int p2 = -1, p4 = 0;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        if (a % 4 == 0)
        {
            p4 += 2;
        }
        else
        {
            if (a % 2 == 0)
            {
                p2 += 1;
            }
        }
    }
    p2 = max(0, p2);
    int max_len = p2 + p4;
    if (max_len >= n - 1)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string.h>
#include <cmath>
#include <cstdlib>
#include <map>
using namespace std;

const int INF = 1 << 30;
const int maxn = 100000 + 10;
char arr[maxn];
int book[maxn];

int main()
{
    //freopen("in", "r", stdin);
    scanf("%s", arr);
    int len = strlen(arr), cnt = 0;
    for (int i = 1; i < len - 1; i++)
        if (arr[i] == arr[i - 1]);
            cnt++;
    if (arr[len - 1] == arr[0])
        len -= 3;
    else
        len -= 2;

    //printf("%d\n", cnt);
    if (len % 2 == 0)
        printf("Second\n");
    else
        printf("First\n");

    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<ctime>
#include<cstdlib>
#include<cctype>
#include<climits>
#include<cstddef>
#include<typeinfo>

using namespace std;

int main()
{

	while (1) {
		string s;
		int m;

		cin >> s;
		if (s.size() == 1 && s[0] == '-') break;
		cin >> m;
		
		int ch;

		for (int i = 0; i < m; i++) {
			cin >> ch;

			string s1 = s.substr(0, ch);
			string s2 = s.substr(ch, s.size());

			s = s2 + s1;
		}
		cout << s <<endl;
	}
	return 0;
}


Measured memory_bytes: 1212
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    static PrintWriter out = new PrintWriter(System.out);
    static Scanner sc = new Scanner(System.in);
    static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    public static void main(String[] args) throws IOException {
        Main main = new Main();
        main.solve();
//        System.out.println(main.solve());
    }
    void solve() throws IOException {
        int n = sc.nextInt();
        HashMap<String,Integer> map = new HashMap<>();
        for(int i=0;i<n;i++){
            String s = sc.next();
            map.put(s,map.getOrDefault(s,0)+1);
        }
        int maxi = 1;
        ArrayList<String> res = new ArrayList<>();
        for(String s:map.keySet()){
            int val = map.get(s);
            if(val<maxi) continue;
            if(val==maxi) res.add(s);
            else{
                maxi = val;
                res.clear(); res.add(s);
            }
        }
        Collections.sort(res);
        for(String s:res) System.out.println(s);
    }
}



Measured memory_bytes: 83336
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

int main(){
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  for(int i = 0; i < H; i++){
    cin >> S.at(i);
  }
  vi dx = {1, -1, 0, 0};
  vi dy = {0, 0, 1, -1};
  int result = 0;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(S.at(i).at(j) == '#') continue;
      //S.at(i).at(j)スタートでBFS
      vvi way(H, vi(W, INT_INF));
      way.at(i).at(j) = 0;
      vector<vector<bool>> flag(H, vector<bool>(W, false));
      flag.at(i).at(j) = true;
      queue<P> que;
      que.push(P(i, j));
      while(!que.empty()){
        int y = que.front().first;
        int x = que.front().second;
        que.pop();
        for(int k = 0; k < 4; k++){
          int xx = x + dx.at(k);
          int yy = y + dy.at(k);
          if(xx < 0 || xx >= W || yy < 0 || yy >= H) continue;
          if(S.at(yy).at(xx) == '#' || flag.at(yy).at(xx)) continue;
          way.at(yy).at(xx) = way.at(y).at(x) + 1;
          flag.at(yy).at(xx) = true;
          chmax(result, way.at(yy).at(xx));
          que.push(P(yy, xx));
        }
      }
    }
  }
  cout << result << endl;
}

Measured memory_bytes: 256
import java.util.*;
 
 
import java.io.*;
 
 
 
public class Main 
{   
	
	
	public static void main(String[] args) throws IOException 
	{ 
		 
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw=new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		
		StringTokenizer s=new StringTokenizer(br.readLine());
		int n=Integer.parseInt(s.nextToken());
		s=new StringTokenizer(br.readLine());
		long ar[]=new long[n];
		for(int i=0;i<n;i++) {
			ar[i]=Integer.parseInt(s.nextToken());
		}
		
		long sum[][]=new long[n][n];
		sum[0][0]=ar[0];
		for(int i=1;i<n;i++) {
			sum[0][i]=sum[0][i-1]+ar[i];
		}
		for(int i=1;i<n;i++) {
			for(int j=i;j<n;j++) {
				sum[i][j]=sum[i-1][j]-sum[i-1][i-1];
			}
		}
		
//		for(int i=0;i<n;i++) {
//			for(int j=0;j<n;j++)
//				pw.print(sum[i][j]+" ");
//			pw.println();
//		}
			
		long dp[][]=new long[n][n];
		for(int i=n-1; i>=0; i--)
	    {
	        for(int j=i; j<n; j++)
	        {
	            if(i == j)
	            {
	                continue;
	            }
	 
	            else
	            {
	                dp[i][j] = (long) 1e18;
	 
	                for(int k=i; k<j; k++)
	                {
	                    dp[i][j] = Math.min(dp[i][j], dp[i][k] + dp[k+1][j] + sum[i][j]);
	                }
	            }
	        }
	    }
		
		pw.print(dp[0][n-1]);
		
		pw.close();
		
	}
	
	
	
}

Measured memory_bytes: 35892
import sys

def comb(n, r):
    if r > n or r < 0: return 0
    r = min(r, n - r)
    if r == 0: return 1
    if r == 1: return n
    numerator = list(range(n-r+1, n+1))
    denominator = list(range(1, r+1))
    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])
    return result

n, k = map(int, sys.stdin.read().split())

def solve(n, k):
    p = int(str(n)[0])
    l = len(str(n))

    if k == 1:
        return 9 * (l - 1) + p
    
    elif k == 2:
        if l <= 1:
            return 0
        res = 0
        for i in range(1, l-1):
            res += comb(i, 1) * 9 * 9
        res += comb(l-1, 1) * 9 * (p - 1)
        res += solve(int(str(n)[1:]), 1)
        return res
    
    elif k == 3:
        if l <= 2:
            return 0
        res = 0
        for i in range(2, l-1):
            res += comb(i, 2) * 9 ** 2 * 9
        res += comb(l-1, 2) * 9 ** 2 * (p - 1)
        res += solve(int(str(n)[1:]), 2)
        return res

def main():
    return solve(n, k)

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3192
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main()
{
    ll n,i,p,x;
    scanf("%lld",&n);
    ll a[n];
    for(i=0;i<n;i++)
        scanf("%lld",&a[i]);
    p=1;
    x=a[0];
    for(i=1;i<n;i++)
    {
        if(x>=a[i])
            p++;
        x=min(x,a[i]);
    }
    printf("%lld\n",p);

}


Measured memory_bytes: 5388
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int t[] = new int[N];
    int x[] = new int[N];
    int y[] = new int[N];
    if(N==1){
      if(x[0]+y[0]!=t[0]){
        System.out.println("No");
        return;
      }
    }
    for(int i=0;i<N;i++){
      t[i]=sc.nextInt();
      x[i]=sc.nextInt();
      y[i]=sc.nextInt();
    }
    if(N==1){
      if(x[0]+y[0]!=t[0]){
        System.out.println("No");
        return;
      }
    }
    for(int i=0;i<N-1;i++){
      if(!isVisit(i,t,x,y)){
        System.out.println("No");
        return;
      }
    }
    System.out.println("Yes");
  }
  
  public static boolean isVisit(int i,int[] t,int[] x,int[] y){
    int time =t[i+1]-t[i];
    int xs=Math.abs(x[i+1]-x[i]);
    int ys=Math.abs(y[i+1]-y[i]);
    if(xs+ys>time){
      return false;
    }else if(xs+ys==time){
      return true;
    }else{
      if((xs+ys)%2==time%2){
        return true;
      }
    }
    return false;
  }
    
    
  

  
}


Measured memory_bytes: 91540
#include<cstdio>
#include<algorithm>
int cnt[100001]={};
int main(){
    int n,a,sum=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a);
        cnt[a]++;
    }
    for(int i=1;i<100000;i++){
        sum=std::max(sum,cnt[i-1]+cnt[i]+cnt[i+1]);
    }
    printf("%d",sum);
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> array(n);

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

    for (int i = 0; i < n; ++i) {
        if (i == 0) {
            cout << array[i];
        } else {
            cout << " " << array[i];
        }
    }
    cout << endl;

    for (int i = 1; i < n; ++i) {
        int var = array[i];
        int j = i - 1;
        for (; j >= 0 && array[j] > var ; --j) {
            array[j + 1] = array[j];
        }

        array[j + 1] = var;

        for (int k = 0; k < n; ++k) {
            if (k == 0) {
                cout << array[k];
            } else {
                cout << " " << + array[k];
            }
        }
        cout << endl;
    }
}



Measured memory_bytes: 3124
class priorityQueue {
  constructor() {
    this.keys = [];
    Number.prototype.parentIdx = function() { return Math.ceil(this/2 - 1); };
    Number.prototype.leftIdx = function() { return (this<<1) + 1; };
    Number.prototype.rightIdx = function() { return (this<<1) + 2; };
  }

  insert(key) { this.heapIncrease(this.keys.push(key) - 1); }

  heapIncrease(idx) {
    const keys = this.keys;
    for (let i=idx, p=idx.parentIdx(); i > 0 && keys[i] > keys[p]; i=p, p=i.parentIdx()) {
      keys[p] = [keys[i], keys[i] = keys[p]][0];
    }
  }

  extract() {
    const res = this.keys[0];
    this.keys[0] = this.keys.pop();
    this.maxHeapify(0);
    return res;
  }

  maxHeapify(idx) {
    const keys = this.keys, n = keys.length;
    const innerMaxHeapify = (i) => {
      let left, right, largest = i;
      left = i.leftIdx();
      right = i.rightIdx();
      if (left < n && keys[left] > keys[largest]) largest = left;
      if (right < n && keys[right] > keys[largest]) largest = right;
      if (largest != i) {
        keys[largest] = [keys[i], keys[i] = keys[largest]][0];
        innerMaxHeapify(largest);
      }
    };
    innerMaxHeapify(idx);
  }
}

(function main() {
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n').slice(0, -1);
  const queue = new priorityQueue();
  let str = '';
  lines.forEach(function(cmd) {
    switch(cmd.charAt(0)) {
      case 'i': queue.insert(Number(cmd.split(' ')[1])); break;
      case 'e': str += `${queue.extract()}\n`; break;
    }
  });
  process.stdout.write(str);
})();




Measured memory_bytes: 203984
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, Y) for (int(X) = 0; (X) < (Y); ++(X))
#define rrep(X, Y) for (int(X) = (Y)-1; (X) >= 0; --(X))
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

void solve(long long N, std::vector<std::vector<long long>> A) {
  vector<vb> need(N, vb(N, true));
  rep(k, N) {
    rep(i, N) {
      rep(j, N) {
        if (A[i][k] + A[k][j] < A[i][j]) {
          print(-1);
          return;
        } else if (A[i][k] + A[k][j] == A[i][j] && i != k && k != j) {
          need[i][j] = false;
        }
      }
    }
  }

  ll ans = 0;
  rep(i, N) {
    rep(j, N) {
      if (need[i][j]) {
        ans += A[i][j];
      }
    }
  }
  print(ans / 2);
}

int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<std::vector<long long>> A(N, std::vector<long long>(N));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      scanf("%lld", &A[i][j]);
    }
  }
  solve(N, std::move(A));
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
#define mp make_pair
#define pb push_back
#define f first
#define s second


//var 
int c1[200005], n, ar[200005], p2[200005][2], t1c = 0, vl[2];
char cc;

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

	cin >> n;
	for(int i = 1; i<=n; i++){
		int tmp = i;
		while(tmp){
			if(tmp&1) c1[i]++;
			tmp>>=1;
			//cout << c1[i] << endl;
		}
		cin >> cc;
		if(cc == '1'){ar[i] = 1; t1c++;}
	}

	p2[0][0] = 1; p2[0][1] = 1;
	for(int i = 1; i<=n; i++){
		p2[i][0] = p2[i-1][0];
		p2[i][1] = p2[i-1][1];
		if((t1c+1) != 0){p2[i][0] *= 2; p2[i][0] %= (t1c+1);}
		if((t1c-1) != 0){p2[i][1] *= 2; p2[i][1] %= (t1c-1);}
	}

	for(int i = 1; i<=n; i++){
		if(ar[i]){
			vl[0] += p2[n-i][0];
			if((t1c+1) != 0)vl[0] %= (t1c+1);
			vl[1] += p2[n-i][1];
			if((t1c-1) != 0)vl[1] %= (t1c-1);
		}
	}

	for(int i = 1; i<=n; i++){
		int tmp = vl[ar[i]];
		if(ar[i]){ 
			if(t1c == 1){
				cout << 0 << endl;
				continue;
			}
			tmp -= p2[n-i][1];
		}
		else {
			if(t1c == 0){
				cout << 1 << endl;
				continue;
			}
			tmp += p2[n-i][0];
		}
		tmp += (t1c + (ar[i] ? -1 : 1)); tmp %= (t1c + (ar[i] ? -1 : 1));
		int cnt = 1;
		while(tmp != 0){
			tmp %= c1[tmp];
			cnt++;
		}
		cout << cnt << endl;
	}

	cout.flush();
	return 0;
}

Measured memory_bytes: 6728
#include<stdio.h>
int main()
{
  int n , R[200005];
  int R_max, R_min;
  int i;

  scanf("%d", &n);

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

  scanf("%d", &R[i]);

  if(i==0){
  R_min=R[i];
  continue;
}

  if(i==1) R_max = R[1]-R[0];

  if(R_max <= (R[i]-R_min)) R_max = R[i]-R_min;
  if(R_min >= R[i]) R_min = R[i];
}

  printf("%d\n", R_max);

  return 0;
}

Measured memory_bytes: 1376
K=int(input())
from collections import deque
def bfs(k):
    queue = deque()
    for i in range(1, 10):
        queue.append(i)
    cnt = 1
    while queue:
        x = queue.popleft()
        if cnt == k:
            return x
        cnt += 1
        last = x%10
        if last > 0:
            queue.append(x*10+last-1)
        queue.append(x*10+last)
        if last < 9:
            queue.append(x*10+last+1)
print(bfs(K))

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

struct UnionFind {
  vector<int> par; //親の番号
  UnionFind(int n) : par(n, -1) { }
  int find(int x){ //親の番号を求める
    if(par[x] < 0) return x; //負なら親
    return find(par[x]); //xの親を参照
  }
  bool unite(int x, int y){
    int px = find(x); //xの親
    int py = find(y); //yの親
    if( px == py) return false; //すでに繋がっている
    if(par[px] > par[py]) swap(px, py); //xの方が小さくしたい
    par[px] += par[py];
    par[py] = px;
    return true;
  }
  bool same(int x, int y){
    return find(x) == find(y);
  }
  int size(int x){
    return -par[find(x)];
  }
};

int main(){
  int N,M, K;
  cin >> N >> M >> K;
  int i, j;
  UnionFind tree(N);
  vector<set<int> > dame(N);

  rep(i, M){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    dame[a].insert(b);
    dame[b].insert(a);
    tree.unite(a, b);
  }
  rep(i, K){
    int c, d;
    cin >> c >> d;
    d--;
    c--;
    if(!tree.same(c, d)) continue; //同じグループにあるもののみ
    dame[c].insert(d);
    dame[d].insert(c);
  }
  rep(i, N){
    int num = tree.size(i) - 1;
    num -= dame[i].size();
    cout << num << " ";
  }
  cout << endl;
}


Measured memory_bytes: 24704
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <numeric>
using namespace std;

#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rept(i,k,n) for(long long i = (k); i < (long long)(n); i++)
#define All(v) v.begin(), v.end()
#define Sort(v) sort(v.begin(),v.end())
#define Rsort(v) sort(v.begin(),v.end(),[](auto a, auto b) { return a > b; })
#define Reverse(v) reverse(v.begin(),v.end())
#define MAX 1000000007
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<long long,long long> Pll;
typedef tuple<int,int,int> Tii;

template <typename T>
ostream& operator<<(ostream& s, const vector<T> &vec){
    for(int i=0;i<vec.size();i++){
        if(i) s << ',';
        else s << '{';
        s <<setw(2)<< vec[i];
    }
    s << '}' << endl;
    return s;
}


struct UnionFind {
    vector<int> par;
    vector<int> siz;

    UnionFind(int N) : par(N), siz(N,1) { 
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        if (siz[rx] < siz[ry]) swap(rx, ry);
        siz[rx] += siz[ry];
        par[ry] = rx;
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int size(int x){
        return siz[root(x)];
    }
};

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

    UnionFind uf(n);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        uf.unite(a-1,b-1);
    }
    vector<bool> rt(n,false);
    int cnt = 0;
    rep(i,n){
        if(!rt[uf.root(i)]){
            cnt++;
            rt[uf.root(i)]=true;
        }
    }
    cout<<cnt-1<<endl;
    return 0;
}

Measured memory_bytes: 4052
#include<stdio.h>
#include<math.h>
#include<string.h>
int main(void)
{
    double a, b, c, d, e, f;
    while (scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != EOF) {
        double x, y;
        x = (c * e - b * f) / (a * e - b * d);
        y = (a * f - c * d) / (a * e - b * d);
        if (x == 0) {
            x = 0;
        }
        if (y == 0) {
            y = 0;
        }
        printf("%.3f %.3f\n", x, y);
    }

    return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int main(){
	fast;
	ll n,ans=0;
	cin>>n;
	ll arr[n];
	map<int,int> mp;
	for(int i=0;i<n;i++){
		cin>>arr[i];
		mp[arr[i]]++;
	}
	for(auto i:mp)
		if(i.second%2==1)
			ans++;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 8948
import sys
import math
from collections import defaultdict, deque
from copy import deepcopy
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
def end_of_loop():raise StopIteration
    
    
def main():
    temp = input().rstrip()
    result = 0
    result2 = 0
    for i in range(3):
        if temp[i] == "R":
            result+=1
        else:
            result2 = max(result2, result)
            result=0
    result2 = max(result2, result)
    print(result2)
if __name__ == "__main__":
    main()

Measured memory_bytes: 68020
N = int(input())


def query(idx):
    print(idx)
    s = input()
    if s == "Vacant":
        exit()
    
    return s

base = query(0)

def is_ok(mid):
    s = query(mid)
    # 最初にクエリを投げた場所との差が偶数なので、0~mid間で空席がなければ、midの位置の人は同じ性別になるはず
    if mid % 2 == 0:
        return s == base
    # 偶数の差でないので、midの位置には異なる性別の人が座っているはず、
    else:
        return s != base

lo = 0
hi = N
while hi - lo > 1:
    mid = (hi + lo) // 2
    if is_ok(mid):
        lo = mid
    else:
        hi = mid


Measured memory_bytes: 3784
#include<stdio.h>

int main(void){

  int a[1000000] = {0};
  scanf("%d", &a[0]);       //入力のsは初項にあたる

  int ans = 0;                  //答え

  for(int i = 0 ; i < 1000000 ; i++){

    if( a[i] % 2 == 0 ){      //nが偶数の時
      a[i + 1] = a[i] / 2;     
    }else{                       //nが奇数の時
      a[i + 1] = 3 * a[i] + 1;
    }

    for(int j = 0 ; j < i ; j++){

      if(a[i + 1] == a[j]){
	ans = i + 2;
	break;
      }
      
    }

    if(ans != 0)     break;   //もう答えが出たなら先をやらない

    
  }


  printf("%d", ans);
	
  
  return 0;
}

Measured memory_bytes: 4096
//#include"pch.h"
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<math.h>
#include<string.h>
#include<algorithm>

int main() {
	char S[30];
	scanf("%s", S);

	int SL = strlen(S);
	int MIN = 1000, tmp;

	for (int i = 0; i < SL - 2; i++) {
		tmp = (S[i] - '0') * 100 + (S[i + 1] - '0') * 10 + (S[i + 2] - '0') * 1;
		tmp -= 753;
		if (tmp < 0)tmp *= -1;
		if (MIN > tmp)MIN = tmp;
	}
	printf("%d", MIN);

	return(0);
}

Measured memory_bytes: 128
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<list>
#include<map>
#include<vector>

using namespace std;


#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long

#define IMIN INT_MIN;
#define IMAX INT_MAX;


int main(){
	int N, M, C;
	cin >> N >> M >> C;
	vector<int> B(M);
	rep(i, M) cin >> B[i];
	int A[N][M];
	int cnt = 0;
	int rowsum;
	rep(i, N) {
		rowsum = 0;
		rep(j, M) {
			cin >> A[i][j];
			rowsum += A[i][j]*B[j];
		}
		if (rowsum + C > 0) cnt++;
	}
	cout << cnt << endl;




	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <limits>
#include <algorithm>
using namespace std;
int a[3];
int main()
{
    for(int i=0;i<=2;i++) scanf("%d",&a[i]);
    sort(a,a+3);
    if(a[0]==5&&a[1]==5&&a[2]==7) printf("YES\n");
    else printf("NO\n");
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
long long  T = 1e9;
long long A[10100], B[10100], C[100][100];
int n;
long long gcd(long long a, long long b){
    return b?gcd(b,a%b):a;
}
int main(){
    int i, j, k, l;
    long long res=0, c = 0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        double t;
        scanf("%lf",&t);
        long long a = t*1e9+0.5, b = T;
        long long g = gcd(a,b);
        a/=g,b/=g;
        int c1=0,c2=0;
        while(a%2==0){
            c1++;
            a/=2;
        }
        while(a%5==0){
            c2++;
            a/=5;
        }
        while(b%2==0){
            c1--;
            b/=2;
        }
        while(b%5==0){
            c2--;
            b/=5;
        }
        C[c1+50][c2+50]++;
    }
    for(i=0;i<=80;i++){
        for(j=0;j<=80;j++){
            for(k=0;k<=80;k++){
                for(l=0;l<=80;l++){
                    if(i+k>=100 && j+l>=100){
                        res+=1ll*C[i][j]*C[k][l];
                        if(i==k && j==l){
                            res-=C[i][j];
                        }
                    }
                }
            }           
        }
    }
    printf("%lld",res/2);
}

Measured memory_bytes: 1728