akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <assert.h>
#include <cstdio>

// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

inline bool chmin(ll &a, ll b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

inline bool chmax(ll &a, ll b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

//桁数取得
template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}
//整数乗
ll llpow(ll a, ll n)
{
    if (n == 0)
    {
        return 1;
    }
    else
    {
        ll rep = a;
        for (ll i = 1; i < n; i++)
        {
            rep *= a;
        }
        return rep;
    }
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

template <typename T>
T amarinasi(T a, T b)
{
    if (a % b == 0)
    {
        return a / b;
    }
    else if (a % b > 0)
    {
        return a / b + 1;
    }
    else
    {
        return a / b - 1;
    }
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------
const double pi = 3.14159265358979323846264;
vector<vector<ll>> ruiseki;
vector<pair<ll, ll>> ichi(90010);
ll h, w, d;
void dfs(ll num, ll nv, ll cnt)
{
    if (nv + d > h * w)
    {
        return;
    }
    ruiseki[num][cnt + 1] = ruiseki[num][cnt] + llabs(ichi[nv].first - ichi[nv + d].first) + llabs(ichi[nv].second - ichi[nv + d].second);
    dfs(num, nv + d, cnt + 1);
}
int main()
{
    cin >> h >> w >> d;
    if (d <= 300)
    {
        ruiseki.resize(310);
        for (ll i = 0; i < ruiseki.size(); i++)
        {
            ruiseki[i].resize(90010);
        }
    }
    else
    {
        ruiseki.resize(90010);
        for (ll i = 0; i < ruiseki.size(); i++)
        {
            ruiseki[i].resize(310);
        }
    }
    for (ll i = 0; i < h; i++)
    {
        for (ll j = 0; j < w; j++)
        {
            ll a;
            cin >> a;
            ichi[a] = make_pair(i + 1, j + 1);
        }
    }
    for (ll i = 1; i <= d; i++)
    {
        dfs(i, i, 0);
    }
    ll q;
    cin >> q;
    for (ll i = 0; i < q; i++)
    {
        ll l, r;
        cin >> l >> r;
        ll tmp_num = l % d;
        if (tmp_num == 0)
        {
            tmp_num = d;
        }
        ll tmp_l = l / d;
        if (l % d == 0)
        {
            tmp_l--;
        }
        ll tmp_r = r / d;
        if (r % d == 0)
        {
            tmp_r--;
        }
        cout << ruiseki[tmp_num][tmp_r] - ruiseki[tmp_num][tmp_l] << endl;
    }
}

Measured memory_bytes: 225984
H,W=[int(x) for x in input().split()]
matrix=[]
for _ in [0]*H:
    matrix.append(input())
import sys
for h in range(H):
    for w in range(W):
        if matrix[h][w]==".":
            continue
        elif h>0 and matrix[h-1][w]=="#":
            continue
        elif h<H-1 and matrix[h+1][w]=="#":
            continue
        elif w>0 and matrix[h][w-1]=="#":
            continue
        elif w<W-1 and matrix[h][w+1]=="#":
            continue
        else:
            print("No")
            sys.exit()
print("Yes")

Measured memory_bytes: 39152
/**
 *    author:  FromDihPout
 *    created: 2020-07-29
**/

#include <bits/stdc++.h>
using namespace std;


const int MOD = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;
    if (n < m) {
        swap(n, m);
    }
    if (n - m >= 2) {
        cout << 0 << '\n';
        return 0;
    }
    
    long long ans = 1;
    int dec = 0;
    for (int i = 0; i < n + m; i++) {
        if (i % 2 == 0) {
            ans *= n - dec;
        }
        else {
            ans *= m - dec;
            dec++;
        }
        ans %= MOD;
    }
    
    if (n == m) {
        cout << (2 * ans) % MOD << '\n';
    }
    else {
        cout << ans << '\n';
    }
    return 0;
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
// template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
// template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
#define popcount __builtin_popcount
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}



int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    ll ma=A[0];
    ll sum=0;
    for (long long i = 1; i < N; i++) {
        if(A[i]<ma) sum+=(ma-A[i]);
        chmax(ma, A[i]);
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 4848
fn main() {
    let v = read_vec::<String>();
    let s = v[0].clone();
    let t = v[1].clone();
    let v2 = read_vec::<u32>();
    let a = v2[0];
    let b = v2[1];
    let u = read::<String>();

    if u == s {
        println!("{} {}", a - 1, b);
    } else {
        println!("{} {}", a, b - 1);
    }
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

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

const int mod = INF+7;
int main(){
    int h,w;cin>>h>>w;
    vector<string>s(h);
    rep(i,h)cin>>s[i];

    int score[h][w];
    rep(i,h)rep(j,w)score[i][j] = 0;
    rep(i,h){
        int cnt = 0;
        rep(j,w){
            if(s[i][j]=='#' || j==w-1){
                if(j==w-1 && s[i][j]!='#')cnt++;
                score[i][j] = cnt;
                cnt = 0;
                continue;
            }
            cnt++;
        }
    }
    vector<vector<int>>res(h,vector<int>(w,0));
    rep(i,h){
        int now = score[i][w-1];
        for(int j=w-1;j>=0;j--){
            if(s[i][j]=='#'){
                now = score[i][j];
                continue;
            }
            res[i][j] = now;
        }
    }
  //rep(i,h){rep(j,w)cout<<res[i][j]<<" ";cout<<endl;}
    vector<vector<int>>score2(h,vector<int>(w,0));
    rep(i,w){
        int cnt = 0;
        rep(j,h){
            if(s[j][i]=='#' || j==h-1){
                if(j==h-1 && s[j][i]!='#')cnt++;
                score2[j][i] = cnt;
                cnt = 0;
                continue;
            }
            cnt++;
        }
    }
    rep(i,w){
      int now = score2[h-1][i];
        for(int j=h-1;j>=0;j--){
            if(s[j][i]=='#'){
                now = score2[j][i];
                continue;
            }
            res[j][i] += now;
        }
    }
    int MAX = 0;
    rep(i,h){rep(j,w)MAX = max(MAX,res[i][j]);}
    cout<<MAX-1<<endl;
}



Measured memory_bytes: 51456
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  int a, b;
  cin >> a >> b;

  if (a <= 8 && b <= 8) cout << "Yay!" << endl;
  else cout << ":(" << endl;

  return 0;
}


Measured memory_bytes: 256
n = gets.to_i
arr = gets.split.map(&:to_i)
flag = true
i = 0
swap_count = 0

while flag
  flag = false
  j = n-1
  while j >= (i+1)
    if arr[j] < arr[j-1]
      arr[j], arr[j-1] = arr[j-1], arr[j]
      flag = true
      swap_count += 1
    end
    j -= 1
  end

  i += 1
end
s = ""
arr.each{|a| s += a.to_s; s += " "}
puts s.chop
puts swap_count

Measured memory_bytes: 8856
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
#include <iomanip>
#include <limits>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
typedef priority_queue<ll> PQ_HIGH;
typedef priority_queue<ll,VL,greater<ll>> PQ_LOW;//昇順

int main(){
  ll x;cin>>x;
  for(ll a=-1000;a<1000;a++){
    for(ll b=-1000;b<1000;b++){
      ll tmp=pow(a,5)-pow(b,5);
      if(tmp==x){
        cout<<a<<" "<<b<<endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 3588
n,m=map(int,input().split())
h=[0]*n
a=[0]*m
b=[0]*m
h=list(map(int,input().split()))
List=[1]*n
for i in range(m):
    a[i],b[i]=map(int,input().split())
    if (h[a[i]-1]>h[b[i]-1]):
        List[b[i]-1]=0
    elif (h[a[i]-1]<h[b[i]-1]):
        List[a[i]-1]=0
    else:
        List[a[i]-1]=0
        List[b[i]-1]=0
print(sum(List))

Measured memory_bytes: 22456
#include<bits/stdc++.h>
using namespace std;
using LL=long long;
#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n; i++)
#define all(a) (a).begin(),(a).end();

using uLL=unsigned long long;
map<int,int>M;
set<uLL>S[700];
int n;
string s[1<<17];
LL dp[1<<17],mod=1e9+7;
uLL gethash(string a)
{
  uLL B=mod;
  uLL now=0;
  for(int i=0;i<a.size();i++)now=now*B+a[i];
  return now;
}
vector<uLL>h(1);
vector<uLL>make(1);
vector<int>le(1);

int main(){
  cin>>n;
  int sz=0;
  for(int i=0;i<n;i++)
  {
    cin>>s[i];
    int l=s[i].length();
    int id;
    if(M[l]==0)
    {
      id=M[l]=++sz;
      uLL now=1;
      uLL B=mod;
      for(int j=0;j<l;j++)now=now*B;
      make.push_back(now);
      h.push_back(0);
      le.push_back(l);
    }
    else id=M[l];
    S[id].insert(gethash(s[i]));
  }
  string t;cin>>t;
  dp[0]=1;
  for(int i=0;i<t.size();i++)
  {
    for(int j=1;j<=sz;j++)
    {
      h[j]=h[j]*(uLL)mod+t[i];
      if(i>=le[j])h[j]=h[j]-make[j]*t[i-le[j]];
      if(i>=le[j]-1&&S[j].find(h[j])!=S[j].end())
      {
        dp[i+1]=(dp[i+1]+dp[i+1-le[j]])%mod;
      }
    }
  }
  cout<<dp[t.size()]<<endl;
}



Measured memory_bytes: 7336
A['   '];
M;
B, X, Y;
W, J, I;
main() {
  scanf("%d%d", &I, &M);
  for (; ~scanf("%d%d", &X, &Y);) {
    B = Y + 1;
    for (J = 1; J * J <= M; J++) {
      I = (X + J - 1) / J, W = Y / J + 1, A[I]++, A[W < B ? W : B]--,
      B = I;
    }
    for (I = 1; I < B; I++)
      if ((X - 1) / I < Y / I)
        A[I]++, A[I + 1]--;
  }
  for (I = 1; I <= M; I++) {
    A[I] += A[I - 1];
    printf("%d\n", A[I]);
  }
}

Measured memory_bytes: 1280
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include <map>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
#include"time.h"
using namespace std;

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define dump(x)  cerr << #x << " = " << (x) << endl
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
const int INF = (1 << 30);

//毎回変える場所
#define N_MAX 200


//問題文のとおり
string s;
int ans = 0;
int main() {
	cin >> s;
	int left = 0;
	int right = s.size() - 1;

	while (left < right) {
		if (s[left] == s[right]) {
			left++;
			right--;
			continue;
		}
		if (s[left] == 'x') {
			left++;
			ans++;
			continue;
		}
		if (s[right] == 'x') {
			right--;
			ans++;
			continue;
		}
		cout << "-1" << endl;
		cin >> ans;
		return 0;
	}
	cout << ans << endl;
	cin >> ans;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int n;
struct node
{
    int x,y;
    bool operator<(const node&o)const
    {
        return y<o.y;
    }
}a[N];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d%d",&a[i].x,&a[i].y);
    sort(a+1,a+1+n);
    bool flag=true;
    int now=0;
    for(int i=1;i<=n;i++)
    {
        if(now+a[i].x>a[i].y) {flag=false;break;}
        now+=a[i].x;
    }
    printf(flag?"Yes":"No");
}


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

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

  long long n, ans=0;
  cin >> n;
  vector<ll> d(n);
  for(int i=0;i<n;i++){
    cin >> d[i];
  }
  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      ans+=d[i]*d[j];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int a[12];
int main() {
	int x,top=0;
	cin>>x;
	while (x) {
		int temp=x%10;
		a[++top]=temp;
		x/=10;
	}
	puts(a[1]==a[2]&&a[2]==a[3]||a[2]==a[3]&&a[3]==a[4]?"Yes":"No");
	return 0;
}

Measured memory_bytes: 256
N, Q = map(int, input().split())
S = input()

counts = [0]
c = 0
for i, s in enumerate(S[1:]):
    if (S[i] == 'A') and (s == 'C'):
        c += 1
    counts.append(c)

ans = []
for _ in range(Q):
    l, r = map(int, input().split())
    ans.append(counts[r-1] - counts[l-1])
    #ans.append(S[l-1:r].count('AC'))

for a in ans:
    print(a)

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


int main()
{
    // ios::sync_with_stdio(0);
	// cin.tie(0);
    
    string s;
    cin >> s;

    if(s[0] == s[1] && s[1] == s[2])
    {
        cout << "No\n";
    }
    else
    {
        cout << "Yes\n";
    }
    
    

    return 0;    

}


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

int main(void) {
    int x,y;
    unordered_set<int> b{4,6,9,11};

    cin >> x >> y;
    if((x == 2) || (y == 2)) {
        // x != yなので
        cout << "No\n";
    } else if(b.find(x) != b.end()) {
        if(b.find(y) != b.end()) {
            cout << "Yes\n";
        } else {
            cout << "No\n";
        }
    } else {
        if(b.find(y) == b.end()) {
            cout << "Yes\n";
        } else {
            cout << "No\n";
        }
    }
    return 0;
}


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

int main() {
    string S, T;
    cin >> S;
    cin >> T;
    int sum = 0;
   
    int min = 10000;
    for(int i = 0; i < S.size() - T.size() + 1; i++) {
        sum = 0;
        int a = i;
        for(int j = 0; j < T.size(); j++) {
            if(i == S.size()) break;
            if(S[i] != T[j]) sum++;
            i++;
        }
        i = a; 
        if(min > sum) min = sum;
        }
    

    cout << min;
    return 0;
}

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

int main(){
	int n,k; cin>>n>>k;
	ll r=1;
	rep(i,n-1) r*=k-1;
	cout<<(ll)k*r<<endl;
}

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

int main(){
    int n;
    long min = 10000000000;
    long max_profit = -1000000000;

    cin >> n;
    int r[n];

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

    for (int i = 0; i < n; i++){
        if(r[i] - min > max_profit){
            max_profit = r[i] - min;
        }
        if(r[i] < min){
            min = r[i];
        }
    }

    cout << max_profit << endl;

    return 0;
}


Measured memory_bytes: 3892
# coding: utf-8


def dijkstra(costs, s, t, INF=10**10):
    """
    2020/04/11
    https://atcoder.jp/contests/abc079/tasks/abc079_d

    Parameters
    ----------
    costs: list of list of int
    e.g. [[-1,  4,  1, -1],
          [ 4, -1,  5, -1],
          [ 1,  5, -1,  6],
          [-1, -1,  6, -1]]
    """

    costs = [[c if c >= 0 else INF for c in row] for row in costs]
    n_node = len(costs)

    # adjacents = {}
    # for i in range(n_node):
    #     adjacents[i] = set([j for j in range(n_node) if 0 < costs[i][j] < INF])

    dist_from_s = [INF] * n_node
    dist_from_s[s] = 0
    checked = []  # nodes having fixed shortest distance

    while True:
        print(dist_from_s)
        # not checked nodes (not fixed nodes)
        nodes = [node for node in range(n_node) if node not in checked]

        # find the node having minimum cost from s
        # initialize
        shortest_node, shortest_dist = nodes[0], dist_from_s[nodes[0]]

        for node in nodes:
            if dist_from_s[node] < shortest_dist:
                shortest_node, shortest_dist = node, dist_from_s[node]

        if shortest_node == t:
            return dist_from_s[t]

        checked.append(shortest_node)  # fix

        # not checked nodes (not fixed nodes)
        nodes = [node for node in range(n_node) if node not in checked]

        # update
        for node in nodes:
            dist_from_s[node] = min(
                dist_from_s[shortest_node] + costs[shortest_node][node],
                dist_from_s[node]
            )


def main():
    N, M = map(int, input().split())
    A = [None] * M
    B = [None] * M
    for i in range(M):
        A[i], B[i] = map(int, input().split())
        A[i] -= 1
        B[i] -= 1

    edge_info = {i: [] for i in range(N)}
    for i in range(M):
        edge_info[A[i]].append(B[i])
        edge_info[B[i]].append(A[i])

    # dists = [None] * N
    # dists[0] = 0
    prenodes = [None] * N
    prenodes[0] = 0
    queue = [0]
    queue_size = 1
    queue_idx = 0
    while True:
        # 貪欲に
        if queue_idx == queue_size:
            break

        x = queue[queue_idx]
        queue_idx += 1
        nexts = [y for y in edge_info[x] if prenodes[y] is None]
        for node in nexts:
            prenodes[node] = x
            queue.append(node)
            queue_size += 1

    print("Yes")
    for i in range(1, N):
        print(prenodes[i]+1)


main()
# print(main())


Measured memory_bytes: 45256
h,w = map(int,input().split())
maps = [ input() for _ in range(h)]
ans = 0

U = [[0 for _ in range(w)] for _  in range(h)]
D = [[0 for _ in range(w)] for _  in range(h)]
L = [[0 for _ in range(w)] for _  in range(h)]
R = [[0 for _ in range(w)] for _  in range(h)]

for y in range(h):
    for x in range(w):
        if maps[y][x] == "#":
            U[y][x],L[y][x] = 0,0
        else:
            if y == 0 and x >= 1:
                U[0][x] = 1
                L[y][x] += 1 + L[y][x-1]
            elif x == 0 and y >= 1: 
                U[y][x] += 1 + U[y-1][x]
                L[y][0] = 1
            elif x == 0 and y == 0:
                U[y][x] = 1
                L[y][x] = 1
            else:
                U[y][x] += 1 + U[y-1][x]
                L[y][x] += 1 + L[y][x-1]

for y in range(h-1,-1,-1):
    for x in range(w-1,-1,-1):
        if maps[y][x] == "#":
            D[y][x],R[y][x] = 0,0
        else:
            if y == h-1 and x < w-1:
                D[y][x] = 1
                R[y][x] += 1 + R[y][x+1]
            elif x == w-1 and y < h-1:
                D[y][x] += 1 + D[y+1][x]
                R[y][x] = 1
            elif  x == w-1 and y == h-1:
                D[y][x] = 1
                R[y][x] = 1
            else:
                D[y][x] += 1 + D[y+1][x]
                R[y][x] += 1 + R[y][x+1]

ans = 0
for i in range(h):
    for j in range(w):
        ans = max(ans,L[i][j]+R[i][j]+U[i][j]+D[i][j] - 3)
print(ans)

Measured memory_bytes: 183684
import numpy as np

N = int(input())
x = np.zeros((N, 1))
y = np.zeros((N, 1))
for n in range(N):
    x[n], y[n] = map(int, input().split())
dist_mat = np.sqrt((x - x.T) ** 2 + (y - y.T) ** 2)
print(np.mean(dist_mat * N))

Measured memory_bytes: 12424
#include <bits/stdc++.h>
// #include "ane.cpp"

const int INF  = 1e9;
const long long INFLL = 1e18;
const int NMAX = 100005;
const int MMAX = 100005;
const int KMAX = 1005;
const int MOD  = 1e9 + 7;
using namespace std;

// comment to disable debug functions
#define DEBUG

// frequently used macros

#if __cplusplus >= 201103L
#define ALL(v) begin(v),end(v)
#define SORT(v) sort(begin(v), end(v))
#define FIND(v,x) find(begin(v), end(v), (x))
#else
#define ALL(v) (v).begin(),(v).end()
#define SORT(v) sort(v.begin(), v.end())
#define FIND(v,x) find(v.begin(), v.end(), (x))
#endif

#define MEMNEXT(from, to) do{ memmove((to), (from), sizeof(from)); \
memset((from), 0, sizeof(from)); } while(0)
#ifdef DEBUG
#define DUMP(x) do{ std::cerr << (#x) << ": " << x << std::endl; }while(0)
#else
#define DUMP(x) do{}while(0)
#endif

// frequent used aliases
typedef long long ll;
typedef pair<int, int> p;
typedef pair<ll, int> lp;
typedef pair<ll, ll> llp;
typedef vector<int> vec;
typedef vector<ll> vecll;
typedef vector<vec> mat;
typedef vector<vecll> matll;

// frequently used constants
static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

// frequently used structs
struct edge{
  int to,cost;
};

// printf for debug
#ifndef DEBUG
void debug(const char* format, ...){}
#else
void debug(const char* format, ...){
  va_list arg;
  va_start(arg, format);
  vprintf(format, arg);
  va_end(arg);
}
#endif

// dump vector
#ifdef DEBUG
#define DUMPV(v, c) do{       \
  printf("%s: ", #v);         \
  for (int i = 0; i < (c); ++i) \
  {                           \
  cout << (v)[i] << " ";      \
  }                           \
  cout << endl;               \
} while(0)
#else
#define DUMPV(v,c)
#endif

// std::fill of multi dimensions
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
  std::fill( (T*)array, (T*)(array+N), val );
}

// binary search
ll BSearch(ll _begin, ll _end, bool (*f)(int)){
  ll mid;
  while(_end - _begin > 1LL) {
  mid = (_begin + _end) / 2LL;
  if(f(mid)) {
    debug("BSearch: f(%d) == true\n", mid);
    _end = mid;
  }
  else
  {
    debug("BSearch: f(%d) == false\n", mid);
    _begin = mid;
  }
  }
  return _end;
}


ll N,M,K,A,B,C,D,E;
int dp[NMAX] = {};

string S;
vec v;

ll ans = {};

void solve(){
  // main algorithm

}
void debug(){
  // output debug information
  if(N == M) {
    ans = K;
  }
  else if(N == K) {
    ans = M;
  }
  else {
    ans = N;
  }
}
void answer(){
  // output answer
  cout << ans << endl;
}
int main(int argc, char const *argv[])
{
  // operate inputs

  // Fill(dp, -1);
  cin >> N >> M >> K;
  solve();
  #ifdef DEBUG
  debug();
  #endif
  answer();

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(){
   int n,m,sum=0;
   scanf("%d %d",&n ,&m);
   int arr[m];
   for(int i=0;i<m;i++){
    scanf("%d",&arr[i]);
    sum += arr[i];
   }
   n =n-sum;
   if(n<0){
    printf("-1");
   }
   else{
     printf("%d",n);
   }
}


Measured memory_bytes: 1756
import re
import numpy as np


N = int(input())
ps= [int(i) for i in input().split()] 

flag=0
for i in range(N-2):
  p0=ps[i]
  p1=ps[i+1]
  p2=ps[i+2]
  
  if np.sort(np.array([p0,p1,p2]))[1]==p1:
    flag+=1
print(flag)

Measured memory_bytes: 21376
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <vector>

using namespace std;
typedef long long ll;

int main()
{

    ll a;
    cin >> a;

    ll b;
    cin >> b;

    if(a <= b * 2){
        cout << 0 << endl;
    }else{
        cout << a - b*2 << endl;
    }
}


Measured memory_bytes: 256
solve :: Integer -> Integer -> Integer -> Double
solve n k i = 1.0 / (fromIntegral m * fromIntegral n)
    where m = head [ (2 ^ x) | x <- [0 ..], i * (2 ^ x) >= k ] :: Integer

main :: IO ()
main = do
    [n, k] <- map read . words <$> getLine :: IO [Integer]
    print $ sum $ map (solve n k) [1 .. n]


Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n, k;
    cin >> n >> k;
    n -= k;
    cout << (k == 1 ? 0 : n) << endl;
}

Measured memory_bytes: 256
// This code wrote by chtholly_micromaker(MicroMaker)
#include <bits/stdc++.h>
#define reg register
#define int long long
using namespace std;
template <class t> inline void read(t &s)
{
	s=0;
	reg int f=1;
	reg char c=getchar();
	while(!isdigit(c))
	{
		if(c=='-')
			f=-1;
		c=getchar();
	}
	while(isdigit(c))
		s=(s<<3)+(s<<1)+(c^48),c=getchar();
	s*=f;
	return;
}
signed main(void)
{
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	reg int ans=0;
	if(k>=a)
		ans+=a;
	else
		ans+=k;
	k-=a;
	k-=b;
	if(k>=c)
		ans-=c;
	else if(k>0)
		ans-=k;
	cout<<ans<<endl;
	return 0;
}




Measured memory_bytes: 3632
#include<cstdio>
#include<algorithm>
#include<string.h>
#include<string>
using namespace std;
typedef long long LL;
int n,r[65];
LL dp[65][3][3][2];
const int mod = 1e9 + 7;
int cmp(int a,int b){return a<b?0:(a==b?1:2);}
LL solve(LL a){
    if(a==0) return 1;
    memset(dp,0,sizeof(dp));
    n=0;
    LL tmp=a;
    while(tmp) {r[++n]=tmp%2;tmp/=2;}
    LL ret=0;
    dp[0][1][1][0]=1;
    for(int i=1;i<=n;i++){
        for(int j=0;j<3;j++)
            for(int k=0;k<3;k++)
                for(int l=0;l<2;l++)
                for(int a=0;a<2;a++)
                for(int b=0;b<=a;b++){
                    int tj=cmp(a^b,r[i]);
                    int tk=cmp((a+b+l)%2,r[i]);
                    int tl=(a+b+l)/2;
                    tj=(tj==1?j:tj);
                    tk=(tk==1?k:tk);
                    dp[i][tj][tk][tl]=(dp[i][tj][tk][tl]+dp[i-1][j][k][l])%mod;
                }
    }
    for(int j=0;j<2;j++)
        for(int k=0;k<2;k++)
            ret=(ret+dp[n][j][k][0])%mod;
    return ret;
}
int main(){
    LL T;
  //  freopen("in.txt","r",stdin);
    while(~scanf("%lld",&T)){
        printf("%lld\n",solve(T));
    }
    return 0;

}


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

int div(int num) {
    if (num % 2 == 1) {
        return 0;
    }
    return div(num / 2) + 1;
}
int main() {
    int N;
    cin >> N;
    int max = 0;
    int ans = 0;
    for (int i = 1; i <= N; i++) {
        if (max <= div(i)) {
            max = div(i);
            ans = i;
        }
    }
    cout << ans << endl;

    return 0;
}


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

typedef long long LL;

const int N=100000;

int n,a[N+9],deg[N+9];

void into(){
  scanf("%d",&n);
  for (int i=1;i<=n;++i){
	scanf("%d",&a[i]);
	++deg[a[i]];
  }
}


int tmp[N+9],ct;
int vis[N+9];
int ans[N+9];

bool Dfs_ans(int k,int last){
  if (k>n) return 1;
  for (int i=1;i<=ct;++i)
	if (!vis[i]&&a[last]^tmp[i]){
	  vis[i]=1;
	  ans[k]=tmp[i];
	  if (Dfs_ans(k+1,tmp[i])) return 1;
	  vis[i]=0;
	}
  return 0;
}

struct state{
  int x,v;
  state(int X=0,int V=0){x=X;v=V;}
  bool operator < (const state &p)const{return v>p.v||v==p.v&&x<p.x;}
};
set<state>sdeg;
set<int>sid;

void Get_ans(){
  if (n==2) return;
  for (int i=1;i<=n;++i){
	sdeg.insert(state(i,deg[i]));
	sid.insert(i);
  }
  for (int i=1;i<=n-5;++i){
	int t=a[ans[i-1]]==*sid.begin()?*++sid.begin():*sid.begin();
	if (sdeg.begin()->v==n-i) t=sdeg.begin()->x;
	ans[i]=t;
	sdeg.erase(state(t,deg[t]));
	sid.erase(t);
	if (sid.find(a[t])!=sid.end()){
	  sdeg.erase(state(a[t],deg[a[t]]));
	  sdeg.insert(state(a[t],--deg[a[t]]));
	}
  }
  for (set<int>::iterator it=sid.begin();it!=sid.end();++it) tmp[++ct]=*it;
  Dfs_ans(max(n-4,1),ans[max(n-5,0)]);
  ans[0]=1;
}

void work(){
  Get_ans();
}

void outo(){
  if (!ans[0]) puts("-1");
  else{
	for (int i=1;i<=n;++i)
	  printf("%d ",ans[i]);
    puts("");
  }
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 14300
#include<iostream>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
#include<cmath>
# include <set>
# include <iomanip>
# include <functional>
# include <queue>
#include<map>
#define INF 1000000009;
using namespace std;
int gcd(int a, int b) {
	while (a % b != 0) {
		int c = 0;
		c = a % b;
		a = b;
		b = c;
	}
	return  b;
}


int main() {
	string A, B;
	cin >> A >> B;
	int moziA[28] = { 0 }, moziB[28]{0};
	for (int i = 0; i < A.size(); i++) {
		moziA[A[i]-'a']++;
		moziB[B[i]-'a']++;
	}
	sort(moziA, moziA + 28,greater<int>());
	sort(moziB, moziB + 28, greater<int>());
	for (int i = 0; i < 28; i++) {
		if (moziA[i] != moziB[i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" <<  endl;
	return 0;
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005
ll dp[3100][3100][4];
int main() {
    ll a[3100][3100];
    
    int h, w, K;
    cin >> h >> w >> K;
    
    rep(i,h)rep(j,w)a[i][j] = 0;
    rep(i,K){
        int x, y, v;
        cin >> x >> y >> v;
        x--; y--;
        a[x][y] = v;
    }
    
    rep(i,h)rep(j,w)rep(k,4)dp[i][j][k] = 0;
    dp[0][0][1] = a[0][0];
    rep(i,h){
        rep(j,w){
            if(i > 0){
                rep(k,4){
                    dp[i][j][0] = max(dp[i][j][0], dp[i-1][j][k]);
                    dp[i][j][1] = max(dp[i][j][1], dp[i-1][j][k] + a[i][j]);
                }
            }
            if(j > 0){
                rep(k,4){
                    dp[i][j][k] = max(dp[i][j][k], dp[i][j-1][k]);
                    if(k>0) dp[i][j][k] = max(dp[i][j][k], dp[i][j-1][k-1] + a[i][j]);
                }
            }
        }
    }
    ll ans = 0;
    rep(k,4)ans = max(ans,dp[h-1][w-1][k]);
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 366716
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

int n;
vector<int> v;

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

	sort(ALL(v));

	int n_a = n / 2;
	if (v[n_a-1] == v[n_a]) cout << 0 << endl;
	else cout << v[n_a] - v[n_a-1] << endl;

	return 0;
}


Measured memory_bytes: 892
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#include <cassert>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using namespace std;

int main() {
    vector<string> cand = {
        "dream", "dreamer", "erase", "eraser",
    };
    for(auto &s: cand) {
        reverse(s.begin(), s.end());
    }

    string S;
    cin >> S;
    reverse(S.begin(), S.end());

    int pos = 0;
    while(!S.empty()) {
        int newpos;
        for(auto ca: cand) {
            newpos = S.rfind(ca, 0);
            if(newpos != -1) {
                newpos += ca.size();
                break;
            }
        }
        if(newpos == -1) {
            cout << "NO" << endl;
            return 0;
        } else {
            pos = newpos;
            S = S.substr(pos);
        }
    }

    cout << "YES" << endl;
    return 0;
}



Measured memory_bytes: 3228
#include<iostream>
#include<string>
#include<regex>

#define rep(i,n) for(int i = 0;i < n;++i)

using namespace std;

int main()
{
    long long k,n,tmp,sum=0,max = 0;
    cin >> k >> n;
    long long a[n+1];
    a[n] = k;
    rep(i,n){
        cin >> a[i];
    }
    if(a[0]!=0){
        a[n] += a[0];
    }
    rep(i,n){
        a[i] = a[i+1]-a[i];
        if(max < a[i]){
            max = a[i];
            tmp = i;
        }
    }
    a[tmp] = 0;
    rep(i,n){
        sum += a[i];
    }
    cout << sum << endl;
    cout << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

void insertionsort(int A[], int n)
{
  int j, i, v;
  for(i = 2 ; i <= n ; i++)
    {
      v = A[i];
      j = i - 1;
      while(j >= 0 && A[j] > v)
        {
          A[j + 1] = A[j];
          j--;
        }

      A[j + 1] = v;
      trace(A, n);
    }
}

int main(){
  int n, i, j;
  int A[N+1];
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
  
  trace(A, n);
  /*

    your code

   */
  insertionsort(A, n);
  return 0;
}

Measured memory_bytes: 604
#include <stdio.h>

int main(void){
	int a,b,c;
	int ans,max,min;
	scanf("%d%d%d",&a,&b,&c);

	if(a >= b && a >= c){
		max=a;
	}
	else if(b >= a && b >= c){
		max=b;
	}
	else{
		max=c;
	}
	if(a <= b && a <= c){
		min=a;
	}
	else if(b <= a && b<=c){
		min=b;
	}
	else{
		min=c;
	}
	ans=max-min;
	printf("%d\n",ans);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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 MAX_H=2e4+10;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H,N; cin >> H >> N;
    vector<ll> A(N),B(N);
    rep(i,N) cin >> A[i] >> B[i];
    vector<ll> dp(MAX_H,IINF);
    dp[0]=0;
    rep(i,N) for (int j=A[i];j<MAX_H;++j){
        chmin(dp[j],dp[j-A[i]]+B[i]);
    }
    ll ans=IINF;
    rep2(i,H,MAX_H) chmin(ans,dp[i]);
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
using namespace std;
using ll = int64_t;
using ld = long double;
using ull = uint64_t;

#define cerr if (false) cerr

int n;
vector<vector<ll>> v;

vector<ll> bitsOf(ll x) {
  vector<ll> rv(25);
  ll p = 0;
  while(x > 0) {
    rv[p] = x%2;
    x /= 2;
    p++;
  }
  return rv;
}

vector<ll> pplus(vector<ll> a, vector<ll> b) {
  assert(a.size() == b.size());
  vector<ll> c(a.size());
  for (int i = 0; i < c.size(); i++) {
    c[i] = a[i] + b[i];
  }
  return c;
}

vector<ll> mminus(vector<ll> a, vector<ll> b) {
  assert(a.size() == b.size());
  vector<ll> c(a.size());
  for (int i = 0; i < c.size(); i++) {
    c[i] = a[i] - b[i];
  }
  return c;
}

bool small(vector<ll> v) {
  for (auto x: v) if (x > 1) return false;
  return true;
}

bool check(ll from, ll to) {
  if (from == 0) {
    return small(v[to]);
  }
  return small(mminus(v[to], v[from-1]));
}

int main() {
  ios::sync_with_stdio(0);
  cout.precision(10);

  cin >> n;
  v.resize(n);
  for (int i = 0; i < n; i++) {
    ll x;
    cin >> x;
    v[i] = bitsOf(x);
  }

  for (int i = 1; i < n; i++) {
    v[i] = pplus(v[i-1], v[i]);
  }

  for (auto x: v) {
    for (auto y: x) cerr << y << ' '; cerr << endl;
  }

  ll anw = 0;
  for (int i = 0; i < n; i++) {
    cerr << "STEP " << i << endl;
    ll l = i, r = n;
    while(r-l>1) {
      ll m = (r+l)/2;
      cerr << " for  " << m << " ";
      if (check(i, m)) {
        l = m;
        cerr << "YES" << endl;
      } else {
        r = m;
        cerr << "NO" << endl;
      }
    }
    anw += l-i+1;
    cerr << "after " << i << " anw is " << anw << endl;
  }

  cout << anw << endl;

}

Measured memory_bytes: 47616
# -*- coding: utf-8 -*-
from sys import stdin
import math
import numpy as np

s_in = lambda: stdin.readline()[:-1]  # s = s_in()
d_in = lambda: int(stdin.readline())  # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split()))  # List = ds_in()


times = []
for _ in range(5):
    times.append(d_in())


min_val = 10
ans = 0
for i, t in enumerate(times):
    if t % 10 > 0 and t % 10 < min_val:
        min_val = t % 10
    ans += math.ceil(t / 10) * 10

if min_val == 10:
    print(ans)
else:
    print(ans - 10 + min_val)


Measured memory_bytes: 21548
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b, c = IR(3)
    a -= b
    print(a % c)
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


Measured memory_bytes: 39152
package main

import (
	"fmt"
	"bytes"
)

func main() {
	var n, k int
	var r, s, p int
	var t string
	fmt.Scanf("%d %d", &n, &k)
	fmt.Scanf("%d %d %d", &r, &s, &p)
	fmt.Scanf("%s", &t)
	grouped := splitToGroups(t, k)
	max := 0
	for i := 0; i < k; i++ {
		max += calcMaxPoint(r, s, p, grouped[i])
	}
	answer := max
	fmt.Println(answer)
}

func splitToGroups(t string, k int) []string {
	builders := make([]bytes.Buffer, k)
	for i, v := range t {
		index := i % k
		builders[index].WriteRune(v)
	}

	groups := make([]string, k)
	for i := 0; i < k; i++ {
		groups[i] = builders[i].String()
	}
	return groups
}

const R = 0
const S = 1
const P = 2

var AllHands = [...]int{R, S, P}

func nextHand(hand int) int {
	if hand != P {
		return hand + 1
	}
	return R
}

func calcMaxPoint(r, s, p int, grouped string) int {
	dp := make([][]int, len(grouped)+1) //i 回目まで j:1回前の手, 値 利得の最大値
	dp[0] = make([]int, 3)              // r, s, p
	for i, v := range grouped {
		dp[i+1] = make([]int, 3) // r, s, p
		setMaxPoint(int(v), i, r, s, p, &dp)
	}
	return max(max(dp[len(grouped)][R], dp[len(grouped)][S]), dp[len(grouped)][P])
}

func setMaxPoint(hand, i, r, s, p int, dpPointer *[][]int) {
	dp := *dpPointer
	for _, h := range AllHands {
		dp[i+1][h] = max(dp[i][nextHand(h)], dp[i][nextHand(nextHand(h))])
	}
	switch hand {
	case 'r':
		dp[i+1][P] = max(dp[i][S], dp[i][R]) + p
	case 's':
		dp[i+1][R] = max(dp[i][S], dp[i][P]) + r
	case 'p':
		dp[i+1][S] = max(dp[i][P], dp[i][R]) + s
	}
}

func max(x, y int) int {
	if x < y {
		return y
	}
	return x
}


Measured memory_bytes: 17920
#include <iostream>
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define LL long long
#define rep(i,a,n) for(int i=a;i<n;++i)
#define per(i,a,n) for(int i=n-1;i>=a;--i)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define sz(v) ((int)sizeof(v))
#define N 100005

int main()
{
    int a,b;
    double ans,tmp;
    cin>>a>>b;
    tmp=1.0/a+1.0/b;
    ans=1.0/tmp;
    printf("%.9f\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

const int N = 4234567;

const int bits = 30;
// 😂 😂
int main() {
  int a, b; 
  scanf("%d %d",&a, &b);
  
  for(int i = 1; i <= N; i ++) {
    int left = i * (i + 1) / 2;
    int right = (i + 1) * (i + 2) / 2;
    if(left - a == right - b) {
      cout << left - a << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int vis[101010];
priority_queue< pair<int,int> >q1,q2;
int main()
{
	int i,n,num,x,y;
	pair<int,int>tmp,tmp2;
	long long sum=0,summ,sum2,ans=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d%d",&x,&y);
		q1.push(make_pair(-x,i));
		q2.push(make_pair(y,i));
		sum+=y;
		ans+=x;
	}
	summ=0,num=0,sum2=0;
	ans=min(ans,sum);
//	printf("%lld\n",sum);
	for(i=1;i<n;i++)
	{
		tmp=q1.top();
		summ+=-tmp.first;
		if(vis[tmp.second]==0)
			vis[tmp.second]=1,num++;
		tmp2=q2.top();
		sum2+=tmp2.first;
		if(vis[tmp2.second]==0)
			vis[tmp2.second]=1,num++;
		q1.pop(),q2.pop();
//		printf("%d %d %lld %lld\n",i,num,summ,sum2);
		if(num>i)
			ans=min(ans,sum-sum2+summ);
		else
		{
			if(!q1.empty())
				ans=min(ans,sum-sum2+summ-q1.top().first+tmp.first);
			if(!q2.empty())
				ans=min(ans,sum-sum2+summ-q2.top().first+tmp2.first);
		}
	}
	printf("%lld\n",ans);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
 	return 0;
}


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

using namespace std;

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

	string s;
	cin >> s;

	bool flag = false;

	for(int i = 0; i < s.length() - 1; i++) {
		if(s[i] == s[i + 1]) {
			flag = true;
			break;
		}
	}

	if(flag) cout << "Bad";
	else cout << "Good";

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,ac=0,tle=0,wa=0,re=0;
string str;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>str;
		if(str=="AC") ac++;
		else if(str=="TLE") tle++;
		else if(str=="WA") wa++;
		else re++;
	}
	cout<<"AC x "<<ac<<endl;
	cout<<"WA x "<<wa<<endl;
	cout<<"TLE x "<<tle<<endl;
	cout<<"RE x "<<re<<endl;
}

Measured memory_bytes: 3632
import java.io.*;

class Main {
	public static void main(String[] args){
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			int n = Integer.parseInt(br.readLine());
			String buf = br.readLine();
			String[] line = buf.split(" ");
			int a = Integer.parseInt(line[0]);
			long max = a;
			long min = a;
			long total = a;
			for(int i = 1;i < n;i++){
				int b = Integer.parseInt(line[i]);
				if(max<b) max = b;
				if(min>b) min = b;
				total = total + b;
			}
			System.out.print(min+" "+max+" "+total);
			System.out.print("\n");
		} catch(Exception e){
		}
	}
}

Measured memory_bytes: 28560
<?php

$line = fgets(STDIN); // 標準入力からの入力値を変数に代入
$array = explode(" ", $line); // 取得した入力値を半角スペースで分解

$l=1;
foreach($array as $value){
    if ($l==1){
        $N = $value;
    }else {
        $i = $value;
    }
    $l++;
}

$x = $N - $i + 1;
echo $x;

?>

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

typedef long long int ll;

int main() {
    ll n = 0, q = 0;
    ll a[100000], b[100000], c[100000];
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    cin >> q;
    for (int i = 0; i < q; i++) cin >> b[i] >> c[i];

    ll s[100001];
    for (int i = 0; i <= n; i++) s[i] = 0;
    for (int i = 0; i < n; i++) s[0] += a[i];

    ll num[100001];
    for (int i = 0; i <= 100000; i++) num[i] = 0;
    for (int i = 0; i < n; i++) num[a[i]]++;

    for (int i = 0; i < q; i++) {
        s[i + 1] = s[i] + num[b[i]] * (c[i] - b[i]);
        num[c[i]] += num[b[i]];
        num[b[i]] = 0;
        cout << s[i + 1] << endl; 
    }
}

Measured memory_bytes: 7532