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

typedef long long ll;

const int mod = 1000000007;
const int Maxn = 100005;

int fac[Maxn], inv[Maxn];
int use1[Maxn], use2[Maxn];
int n;
int a[Maxn], sum[Maxn];
int res;

int toPower(int a, int p)
{
    int res = 1;
    while (p) {
        if (p & 1) res = ll(res) * a % mod;
        p >>= 1; a = ll(a) * a % mod;
    }
    return res;
}

int Inv(int a) { return toPower(a, mod - 2); }

int main()
{
    fac[0] = 1;
    for (int i = 1; i < Maxn; i++) {
        fac[i] = ll(fac[i - 1]) * i % mod;
        inv[i] = Inv(i);
    }
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        use1[i] = ll(fac[n]) * inv[i + 1] % mod;
        use2[i] = (use2[i - 1] + ll(fac[n]) * 2 % mod * inv[i + 1] % mod * inv[i + 2]) % mod;
    }
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        sum[i] = (sum[i - 1] + a[i]) % mod;
        if (i < n) {
            res = (res - ll(sum[i]) * use2[n - 1 - i] % mod + mod) % mod;
            res = (res - ll(sum[i]) * use1[n - i] % mod + mod) % mod;
        }
        if (i == n) {
            res = (res + ll(fac[n]) * sum[n]) % mod;
            for (int j = 1; j < n; j++)
                res = (res + ll(sum[n]) * use1[j]) % mod;
        } else {
            res = (res + ll(sum[i]) * use2[i - 1]) % mod;
            res = (res + ll(sum[i]) * use1[i]) % mod;
        }
    }
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 2560
n = gets.chomp.to_i
x = gets.chomp.split.map(&:to_i)


ans = Float::INFINITY

x.min.upto(x.max) do |val|
  tmp_sum = 0
  x.each do |elm|
    tmp_sum += (val-elm)**2
  end

  ans = tmp_sum if tmp_sum < ans
end

p ans


Measured memory_bytes: 1916
while True:
    n = int(input())
    if n == 0:
        break
    d = dict()
    sep = []
    for _ in range(n):
        i, p, q = map(int, input().split())
        if i in d:
            d[i] += p*q
        else:
            d[i] = p*q
            sep.append(i)
    tmp = list(filter(lambda x: x[1] >= 1000000, d.items()))
    if len(tmp):
        tmp = {t[0]: t[1] for t in tmp}
        for s in sep:
            if s in tmp:
                print(s)
    else:
        print("NA")

Measured memory_bytes: 7916
import math
a,b,x = map(int,input().split())

if x >= a**2*b/2:
  y = 2*(a**2*b-x)/(a**2)
  ans = math.degrees(math.atan(y/a))
else:
  y = 2*x/(a*b)
  ans = math.degrees(math.atan(b/y))
print(ans)

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

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

Measured memory_bytes: 256
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	ll h,w;
	cin >> h >> w;
	if(w==1 || h==1) cout << "1\n";
	else cout << (h/2)*w + (h%2==1 ? (w+1)/2 : 0LL) << '\n';
	return 0;
}



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

int main() {
  int n;
  cin >> n;
  vector<int> a(n + 1);
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }

  vector<bool> pushed(n + 1);
  int res = 0;
  int state = 1;
  while (true) {
    pushed[state] = true;
    state = a[state];
    res++;
    if (state == 2) {
      break;
    }

    if (pushed[state]) {
      res = -1;
      break;
    }
  }

  cout << res << endl;
}


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


int main() {
  int n;
  cin >> n;
  vector<string> S(n);
  for(int i = 0;i<n;i++){
    cin >> S[i];
  }
  vector<char> C;
  for(char c = 'a';c<='z';c++){
   int x = 0;//ある文字がS[i]に含まれているか
   for(int i = 0;i<n;i++){
      for(int j = 0;j<S[i].size();j++){
      if(S[i][j] == c){
        x++;
        break;
      }
     }
     if(x == n){//ある文字がすべてのS[i]に含まれていればその文字をCに追加
      C.push_back(c);
   }
  }
 }   

  vector<pair<char,int>> p(C.size());
   for(int i = 0;i<C.size();i++){
     p[i].first = C[i];
   }
  
 if(p.size()>=1){ 
  for(int i = 0;i<p.size();i++){
   vector<int> min(n);//共通文字の個数の配列
   int count = 0;//共通文字の個数
   for(int j = 0;j<n;j++){
    for(int k = 0;k<S[j].size();k++){
      if(S[j][k] == p[i].first) count++;
    }
     min[j] = count;
     count = 0;
   }
    sort(min.begin(),min.end());
    p[i].second = min[0];
  }

  string ANS;
  for(int i = 0;i<p.size();i++){
    for(int j = 0;j<p[i].second;j++){
      ANS = ANS +p[i].first;
    }
  }
  cout << ANS << endl;
 }
  else return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include<set>
#include<iomanip>
using namespace std;

int main()
{
	long long int a[90],n;
  	cin>>n;
	a[0]=2;a[1]=1;
	for(int i=1;i<n;i++)
	{
		a[i+1]=a[i]+a[i-1];
	}
	cout<<a[n]<<endl;
	return 0;
}

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;

/// Tip : If a and b are positive integers ; we may say - ceil (a/b) = 1 + floor ( (a-1)/b ) .

void solve ( int test_case )
{
    string s ;
    cin >> s ;

    int n = s.size() ;

    while ( n -- )
        cout << "x" ;

    line ;
}

int main()
{
    int t = 1;
    // cin >> t;

    for ( int i=0 ; i < t ; i++ ) solve(i);
    return 0;
}


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

int main(){
 int N;
 cin >> N;
 
  bool flag = false;
  
  for (int i=0;i<3;i++) {
    if (N%10==7) {
      flag = true;
      break;
    }
    N=N/10;
  }
  
  if (flag)
  	cout << "Yes" << endl;
  else
  	cout << "No" << endl;
  
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
    ll A[4];
    rep(i,1){
        cin >> A[i];
    }
    //sort(A,A+3);
    cout << (A[0]/10==9 || A[0]%10==9 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>
#include <stack>
#include <tuple>

#define ll long long int

using namespace std;

const int INF = (1<<30) - 1;

//d, node, velocity, parent
typedef tuple<double, int, int, int> State;

class Edge{
public:
    int to, cost, limit;
    Edge(int to, int cost, int limit): to(to), cost(cost), limit(limit){};
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N, M;
    while (cin>>N>>M, N|M) {
        int S, G; cin >> S >> G; S--; G--;
       
        vector<vector<Edge>> Glaph(N);
        for(int i=0; i<M; i++){
            int x, y, d, c;
            cin >> x >> y >> d >> c; x--; y--;
            Glaph[x].push_back(Edge(y, d, c));
            Glaph[y].push_back(Edge(x, d, c));
        }
        
        vector<vector<vector<double>>> dp(N, vector<vector<double>>(30, vector<double>(N, INF)));
        priority_queue<State, vector<State>, greater<State>> que;
        
        for(Edge &e: Glaph[S]){
            dp[e.to][0][S] = e.cost;
            que.push(State(e.cost, e.to, 0, S));
        }
        while (!que.empty()) {
            double d; int node, velocity, parent;
            tie(d, node, velocity, parent) = que.top(); que.pop();
            if(dp[node][velocity][parent] < d)
                continue;
            
            for(Edge &e: Glaph[node]) if(e.to != parent){
                for(int i=-1; i<=1; i++){
                    int nv = velocity + i;
                    if(nv < 0 || 30 <= nv || e.limit <= nv)
                        continue;
                    if(dp[e.to][nv][node] > d + e.cost / double(nv+1)){
                        dp[e.to][nv][node] = d + e.cost / double(nv+1);
                        que.push(State(dp[e.to][nv][node], e.to, nv, node));
                    }
                }
            }
        }
        double ans = INF;
        int p = -1;
        for(int i=0; i<N; i++){
            if(dp[G][0][i] < ans){
                ans = dp[G][0][i];
                p = i;
            }
        }
        if(ans == INF)
            cout << "unreachable" << endl;
        else
            cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 2140
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int A;
int B;
char S[13];
int main(){
  int i;
  rd(A);
  rd(B);
  rd(S);
  for(i=0;i<A+B+1;i++){
    if(i==A && S[i]!='-'){
      break;
    }
    if(i!=A && S[i]=='-'){
      break;
    }
  }
  if(i==A+B+1){
    wt_L("Yes");
    wt_L('\n');
  }
  else{
    wt_L("No");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// int A, B;
// char S[13];
// {
//   int i;
//   rd(A,B,S);
//   rep(i,A+B+1){
//     if(i==A && S[i]!='-') break;
//     if(i!=A && S[i]=='-') break;
//   }
//   wt( if[i==A+B+1, "Yes", "No"] );
// }


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define one 1.0
#define inf 1000000000000000000
#define ret return
#define all(vl) vl.begin(),vl.end()
#define sor sort 
#define cl clear
#define m_p make_pair 
#define sz(a) a.size()
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;
typedef map<string,ll> mapstl;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll a;
	cin>>a;
	cout<<a+a*a+a*a*a<<endl;
	return 0;
}

Measured memory_bytes: 3612
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N, K;
  cin >> N >> K;
  ll X = N % K;
  if (K - X > X) {
    cout << X << endl;
  } else {
    cout << K - X << endl;
  }

  return 0;
}


Measured memory_bytes: 256
use std::io::stdin;

fn main() {
    let mo = 1000000000+7;
    let mut st = String::new();
    stdin().read_line(&mut st).unwrap();
    let (n, k) = {
        let mut nk:Vec<i64> = st.trim().split(" ").map(|x| x.parse().unwrap()).collect();
        (nk[0], nk[1])
    };
    let mut r:i64 = 0;
    for i in k..(n+2) {
        let s:i64 = i*(i+1)/2;
        let e:i64 = i*(n+1+(n+2-i))/2;
        r += e-s+1;
        r %= mo;
    };
    println!("{}", r);
}


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

int main() {
  int N, T, A;
  cin >> N >> T >> A;

  vector<int> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H.at(i);
  }
  
  int minIndex = -1;
  double diff = pow(10, 9);
  for (int i = 0; i < N; i++) {
    auto j = T - H.at(i) * 0.006;
    auto k = abs(A - j);
    if (k < diff) {
      diff = k;
      minIndex = i + 1;
    }
  }
  
  cout << minIndex << endl;
}


Measured memory_bytes: 3640
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

    int N;
    long[] T;

    public long lcm(long x,long y){
        return x / gcd(x,y) * y;
    }

    public long gcd(long x,long y){
        return y == 0 ? x : gcd(y,x%y);
    }

    public void solve() {
        N = nextInt();

        T = new long[N];
        for(int i = 0;i < N;i++){
            T[i] = nextLong();
        }

        long ans = T[0];
        for(int i = 1;i < N;i++){
            ans = lcm(ans,T[i]);
        }

        out.println(ans);

    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[2048];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 21328
#include<iostream>
using namespace std;
#include<stdio.h>

class union_find  // union find.
{
    int* U;
public:
    union_find(int n){ U = new int [n + 1]; for(int i = 1; i <= n; i++) U[i] = i; }
    int root(int a){ if(U[a] == a){ return a; } U[a] = root(U[a]); return U[a]; }
    bool same(int a, int b){ return root(a) == root(b); }
    void join(int a, int b){ int x = root(a), y = root(b); U[x] = y; }
    ~union_find(){ delete [] U; }
};

struct edge{ int v1, v2; int weight; };  // edge.

edge init(){
    edge e;
    e.v1 = 0; e.v2 = 0; e.weight = -1;
    return e;
}

edge init(int a, int b, int w){
    edge e;
    e.v1 = a; e.v2 = b; e.weight = w;
    return e;
}

void swap_e(edge e1, edge e2)
{
    swap(e1.v1, e2.v1); swap(e1.v2, e2.v2); swap(e1.weight, e2.weight);
}

class edge_heap  // heap.
{
    edge* E;
    int edge_n;
public:
    edge_heap(int n){ E = new edge [n + 1]; edge_n = 0; }
    void min_heap(int i);
    void insert_heap(edge e);   // sorting.
    void insert_nl(edge e);     // no sorting.
    edge delete_min();
    bool isEmpty(){ return edge_n == 0; }
    int total_weight();
    ~edge_heap(){ delete [] E; }
};

void edge_heap::min_heap(int i)
{
    int l = 2 * i, r = 2 * i + 1;
    if(l > edge_n && r > edge_n) return;
    int minid = i;
    if(l <= edge_n){ if(E[l].weight < E[minid].weight) minid = l; }
    if(r <= edge_n){ if(E[r].weight < E[minid].weight) minid = r; }
    if(minid == i) return;
    swap(E[minid], E[i]);
    min_heap(minid);
}

void edge_heap::insert_heap(edge e)
{
    edge_n++;
    int w = e.weight;
    int i = edge_n;
    while(i > 1){
        if(w < E[i / 2].weight){
        E[i] = E[i / 2];
        }else{ break; }
        i /= 2;
    };
    E[i] = e;
}
void edge_heap::insert_nl(edge e){ edge_n++; E[edge_n] = e; }

edge edge_heap::delete_min()
{
    edge e = E[1];
    E[1] = E[edge_n]; edge_n--;
    min_heap(1);
    return e;
}

int edge_heap::total_weight()
{
    int tw = 0;
    for(int i = 1; i <= edge_n; i++) tw += E[i].weight;
    return tw;
}

int main()
{
    int n, i, j, w;
    scanf("%d", &n);
    edge_heap EH(n * (n + 1) / 2); // All Edge heap.
    edge e;

    for(i = 1; i <= n; i++){
        for(j = 1; j <= n; j++){
            scanf("%d", &w);
            if(j <= i || w < 0) continue;
            e = init(i, j, w);
            EH.insert_heap(e);
        }
    }

    edge_heap TH(n);   // Tree heap.

    union_find VG(n);  // vertex group.

    while(!EH.isEmpty()){
        e = EH.delete_min();
        if(!VG.same(e.v1, e.v2)){
            VG.join(e.v1, e.v2);
            TH.insert_nl(e);
        };
    };

    printf("%d\n", TH.total_weight());

    return 0;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
    #include <filesystem>
    namespace fs = std::filesystem;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

ll n ,a, b;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path __p = __FILE__;
        fs::path __input, __output;
        __input = __output = __p.parent_path();
        __input += string("/input/") + string(__p.stem()) + string(".txt");
        __output += string("/output/") + string(__p.stem()) + string(".txt");
        freopen(__input.c_str(), "r", stdin);
        freopen(__output.c_str(), "w", stdout);
    #endif
    cin >> n >> a >> b;
}

int solve(){
    if(n==1) {cout << (a==b) << endl; return 0;}
    if(a>b) {cout << (a==b) << endl; return 0;}
    ll M = a+b*(n-1);
    ll m = a*(n-1)+b;
    cout << (M-m+1) << endl;
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REPR(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define FOR(i, n, m) for (ll i = (n); i < (m); ++i)
#define FORR(i, n, m) for (ll i = (m) - 1; i >= (n); --i) 
#define FORE(x, xs) for (auto &x: (xs))
#define ALL(v) v.begin(), v.end()
#define ZERO(a) memset(a,0,sizeof(a))

const int INF = 1000000009;
const int MOD = 1000000007;
const double EPS = 1e-14;
const double PI = acos(-1);

const int MAX = 2e5;

ll K;
ll A[100001];

int check(ll x) {
  REP (i, K) {
    x -= x%A[i];
  }
  if (x == 2) return 0;
  if (x > 2) return 1;
  else return -1;
}

int main() {
  cin >> K;
  REP (i, K) cin >> A[i];

  ll hi = 1e14+1, lo = 1; /// 探索の最大と最小
  ll ph = -1, pl = -1; /// 2人が勝ち残る範囲の最大と最小
  while (hi-lo > 1) {
    ll mid = (hi+lo)/2;
    int res = check(mid);
    if (res == 0) {
      ph = pl = mid;
      break;
    }
    if (res == 1) hi = mid;
    else lo = mid;
  }
  if (ph == -1) {
    cout << -1 << endl;
    return 0;
  }

  while (pl-lo > 1) {
    ll mid = (pl+lo)/2;
    if (check(mid) >= 0) pl = mid;
    else lo = mid;
  }
  while (hi-ph > 1) {
    ll mid = (hi+ph)/2;
    if (check(mid) <= 0) ph = mid;
    else hi = mid;
  }

  cout << pl << " " << ph << endl;

  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> p;
const int inf = 1e9;
const ll mod = 1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint choose(int n, int a) {
  mint x = 1, y = 1;
  rep(i,a) {
    x *= n - i;
    y *= i + 1;
  }
  return x / y;
}

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  mint ans = mint(2).pow(n);
  ans -= 1;
  ans -= choose(n,a);
  ans -= choose(n,b);
  cout << ans << endl;
  return 0;
}


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

int main(){
  string S, T;
  cin >> S;
  cin >> T;
  int l = S.size();
  
  for (int i = 0; i < l; i++){
    if (S.at(i) != T.at(i)){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3632
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<functional>
#include<cmath>
#include<vector>
#include<assert.h>
//using namespace std;
using std::min;
using std::max;
using std::swap;
using std::sort;
using std::reverse;
using std::random_shuffle;
using std::lower_bound;
using std::upper_bound;
using std::unique;
using std::vector;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef std::pair<int,int> pii;
typedef std::pair<ll,ll> pll;
void open(const char *s){
#ifndef ONLINE_JUDGE
	char str[100];sprintf(str,"%s.in",s);freopen(str,"r",stdin);sprintf(str,"%s.out",s);freopen(str,"w",stdout);
#endif
}
void open2(const char *s){
#ifdef DEBUG
	char str[100];sprintf(str,"%s.in",s);freopen(str,"r",stdin);sprintf(str,"%s.out",s);freopen(str,"w",stdout);
#endif
}
int rd(){int s=0,c,b=0;while(((c=getchar())<'0'||c>'9')&&c!='-');if(c=='-'){c=getchar();b=1;}do{s=s*10+c-'0';}while((c=getchar())>='0'&&c<='9');return b?-s:s;}
void put(int x){if(!x){putchar('0');return;}static int c[20];int t=0;while(x){c[++t]=x%10;x/=10;}while(t)putchar(c[t--]+'0');}
int upmin(int &a,int b){if(b<a){a=b;return 1;}return 0;}
int upmax(int &a,int b){if(b>a){a=b;return 1;}return 0;}
char str[200010];
int main()
{
	scanf("%s",str+1);
	int n=strlen(str+1);
	ll ans=0;
	int cnt=0;
	for(int i=1;i<=n;i++)
		if(str[i]=='W')
		{
			cnt++;
			ans+=i-cnt;
		}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#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 pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef pair<int,int> ii;
const ll mod = 1000000007;
const int maxn = (int) 1e5 + 5;

int n, c, k;
int t[maxn];

int main() {
    //freopen("test.txt", "r", stdin);
    cin >> n >> c >> k;
    rep(i, 0, n) cin >> t[i];
    sort(t, t + n);
    int tm = -mod, cnt = 0, res = 0;
    rep(i, 0, n) {
        if(tm + k >= t[i] && cnt < c) {
            cnt ++;
            continue;
        }
        res ++;
        tm = t[i];
        cnt = 1;
    }
    cout << res << endl;
}



Measured memory_bytes: 640
#include <iostream>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int n, q;
    string s;
    vector<set<int>> is(26);

    cin >> n >> s >> q;
    for (int i = 0; i < n; i++) {
        is[s[i]-'a'].insert(i);   // a: 0, b: 1, ..., z: 25
    }

    for (int qi = 0; qi < q; qi++) {
        int ty;
        cin >> ty;
        if (ty == 1) {
            int i; char c;
            cin >> i >> c;
            --i;
            is[s[i]-'a'].erase(i);
            s[i] = c;
            is[s[i]-'a'].insert(i);
        } else {
            int l, r;
            cin >> l >> r;
            --l;
            int ans = 0;
            for (int i = 0; i < 26; i++) {
                set<int>::iterator it = is[i].lower_bound(l);
                if (it != is[i].end() && *it < r) ++ans;
            }
            cout << ans << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 24196
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int siz=2e5;
const int inf=1e9;
int main(){
	string s,t; cin>>s>>t;
	int cnt = 0;
	rep(i,0,s.size()){
		if(s[i] != t[i]) cnt++;
	}cout<<cnt<<endl;
}

Measured memory_bytes: 3836
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>
#include <queue>
#define _USE_MATH_DEFINES
#include <math.h>

typedef long long ll;

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(x) : x;
}

//最大・最小
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;
}

//xのn乗
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//xの逆元
ll mod_inv(ll x, ll mod) {//O(log(mod))
    return mod_pow(x, mod - 2, mod);
}

//nCr
ll ncr(ll n, ll r, ll mod){
	ll res=1;
	ll num=1,den=1;
	for(ll i=n;i>=n-r+1;i--){
		(den*=i)%=mod;
	}
	for(ll i=1;i<=r;i++){
		(num*=i)%=mod;
	}
	
	res=den*mod_inv(num,mod);

	return res%mod;
}


//二分探索
bool isOk(ll index, ll key,vector<ll> &a){
	
	if(a[index]>key){
		return true;
	}
	
	return false;
}

ll bin_search(ll key, vector<ll> &a){
	
	ll l=-1;
	ll r=a.size();

	while(abs(r-l)>1){
		ll mid = (l+r)/2;
		if(isOk(mid, key, a)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	return r;
}

/*
//深さ優先探索
void dfs(vector<vector<ll>> &gra,vector<bool> &seen, ll v){

	seen[v]=true;

	for(auto next : gra[v]){
		if(seen[next]){
			continue;
		}

		dfs(gra,seen,next);
	}
	
}
*/
const ll MOD=1000000007;

void solve(){
	string s,t;
	cin>>s>>t;

	bool ans=true;
	for(ll i=0;i<s.size();i++){
		if(s[i]!=t[i]){
			ans=false;
		}
	}

	if(ans){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}

}


int main(){
	
	solve();
	
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define endl    '\n'

using namespace std;

typedef long long ll;

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

    int n, ans;
    int x, y, b, p;
    int nb, np;

    cin >> n;

    for (int i = 0; i < n; ++i) {
        cin >> x >> y >> b >> p;

        nb = (b >= 5) ? b : 5;
        np = (p >= 2) ? p : 2;

        if (b >= 5 && p >= 2) {
            ans = (x * b + y * p) * 0.8;
        } else {
            if ((x * b + y * p)  > (x * nb + y * np) * 0.8) {
                ans = (x * nb + y * np) * 0.8;
            } else {
                ans = (x * b + y * p);
            }
        }

        cout << ans << endl;
    }

    return 0;
}




Measured memory_bytes: 3184
def is_leq_S(A, lim, K):
    S = [0] * K

    ai = 0
    si = 0

    while ai < len(A):
        if S[si] + A[ai] <= lim:
            S[si] += A[ai]
            ai += 1
        else:
            si += 1

            if si == K:
                return False
    
    return True


def main():
    N, K = [int(_) for _ in input().split()] 
    A = []
    
    for _ in range(N):
        A.append(int(input()))

    l = 0
    r = 100000 * 100000

    while l + 1 < r:
        m = (l + r) // 2

        if is_leq_S(A, m, K):
            S = m
            r = m
        else:
            l = m

    print(S)
    

main()


Measured memory_bytes: 9564
package main
import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)

func Solve() {
  var N int
  var A []int
  NextInt(&N)
  NextIntVec(&A)
  S := make([]int, 0)
  M := MaxInt(A...)
  if M <= 0 {
    Write(M)
    Write(N - 1)
    i := N - 1
    for ; A[i] < M; i-- { S = append(S, i + 1) }
    for j := 0; j < i; j++ { S = append(S, 1) }
    for _, s := range S { Write(s) }
    return
  }
  O, E := 0, 0
  for i := 0; i < N; i += 2 { O += MaxInt(A[i], 0) }
  for i := 1; i < N; i += 2 { E += MaxInt(A[i], 0) }
  F := func (k int) {
    for ; k >= 0; k -= 2 {
      if A[k] >= 0 { continue }
      j := k
      for ; j >= 0 && A[j] < 0; j -= 2 {
        S = append(S, j + 1);
        N--
        if j != 0 && j != N { N-- }
      }
      if j >= 0 {
        S = append(S, j + 2)
        N--
        if j != N - 1 { N-- }
      } else {
        S = append(S, 1)
        N--
      }
      k = j
    }
    if k % 2 != 0 && (len(S) == 0 || S[len(S) - 1] != 1) {
      S = append(S, 1)
      N--
    }
  }
  if O >= E {
    F(((N - 1) / 2) * 2)
  } else {
    F((N / 2) * 2 - 1)
  }
  for i := 0; i < N / 2; i++ { S = append(S, 2) }
  Write(MaxInt(O, E))
  Write(len(S))
  for _, s := range S { Write(s) }
}

func main() {
  Solve()
  Output()
}

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntVec(A *[]int) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatVec(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func WriteIntVec(A []int) {
  S := make([]string, len(A))
  for i, a := range A {
    S[i] = strconv.Itoa(a)
  }
  Write(strings.Join(S, " "))
}
func Output() {
  _ = writer.Flush()
}
func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}
func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}
func AbsInt(x int) int {
  if x < 0 { x = -x }
  return x
}

Measured memory_bytes: 768
// In the name of God

#include <bits/stdc++.h>

using namespace std;

#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define debug(x) cout << #x ": " << x << endl;

vector<int> adj[(int)1e5+5];
long long dp[(int)1e5+5];
int par[(int)1e5+5];

long long dfs(int u) {
	if(dp[u]!=0) return dp[u];
	dp[u] = 0;
	for(auto v : adj[u]) {
		dp[u] = max(dp[u], dfs(v)+1);
	}
	return dp[u];
}

int main() {
	IOS
	int n, m;
	cin >> n >> m;
	for(int i=0; i<m; i++) {
		int u, v;
		cin >> u >> v;
		u--;
		v--;
		adj[u].push_back(v);
		par[v]++;
	}
	for(int i=0; i<n; i++) {
		if(par[i]) continue;
		dfs(i);
	}
	long long dst = 0;
	for(int i=0; i<n; i++) dst = max(dst, dp[i]);
	cout << dst;
 	return 0;
}


Measured memory_bytes: 9984
import sys
lines = [s.rstrip("\n") for s in sys.stdin.readlines()]
n, m, x = [int(num) for num in lines.pop(0).split(" ")]
a_list = [int(num) for num in lines.pop(0).split(" ")]

for i in range(m):
    if a_list[i] > x:
        break

ans = min(i, m - i)
print(ans)


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

int main(void){
  long x;
  cin >> x;
  long ope_num = (x / 11)*2;
  ope_num += (x % 11 > 6) ? 2 : (x%11 == 0) ? 0 : 1;
  cout << ope_num << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] kab = scanner.nextLine().split(" ", 3);
        long k = Long.parseLong(kab[0]);
        long a = Long.parseLong(kab[1]);
        long b = Long.parseLong(kab[2]);

        if (a >= b - 1) {
            System.out.println(1 + k);
            return;
        }

        // now, a + 2 <= b

        long biske = 1;
        while (k > 0) {
            if (biske < a || k == 1) {
                biske++;
                k--;
                continue;
            }

            // now, biske >= a and k > 2

            biske += b - a;
            k -= 2;
        }
        System.out.println(biske);
    }
}


Measured memory_bytes: 22612
import itertools

n, m = map(int, input().split())
edge = zeros = [ [0]*n for _ in range(n) ]

for i in range(m):
    s, e = map(int, input().split())
    s -= 1
    e -= 1
    edge[s][e] = 1
    edge[e][s] = 1
    
result = 0

cands= list(itertools.permutations(range(1, n)))

def search(cand):
    cand = [0].extend(cand)
    for i in range(1, n):
        if edge[i-1][i] == 0:
            return False
    return True
for cand in cands:
    result += search(cand)
    
result = 0

cands= list(itertools.permutations(range(1, n)))

def search(cand):
    cand = list(cand)
    cand.insert(0, 0)
    for i in range(1, n):
        if edge[cand[i-1]][cand[i]] == 0:
            return False
    return True
for cand in cands:
    result += search(cand)
    
print(result)

Measured memory_bytes: 4084
N, K = map(int, input().split())

div = 10**9 + 7

ans = 0

top = (2*N-K+2)*(K-1) / 2
bottom = (K-1)*(K-2) / 2

for i in range(N-K+2):
    # print(top, bottom)
    top += (N-K+1-i)
    bottom += (K-1+i)

    ans = (ans + top-bottom+1) % div

print(int(ans))


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

using namespace std;

#define fastio cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(0)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> matrix;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(c) c.begin(),c.end()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define endl '\n'
const int MAX = 1e6+1;
const int INF = 0x3f3f3f3f;

const double PI = acos(-1);
const double DEG = 180.0/acos(-1);

int n;

int main(){
	fastio;
	double a, b, x;

	cin>> a>> b>> x;

	double vol = a*a*b;

	if(2*x <= vol){
		cout<< fixed<< setprecision(8)<< 90 - atan(2*x/(a*b*b))*DEG << endl;
	}
	else{
		cout<< fixed << setprecision(8)<< atan(2*(x - a*a*b)/(-a*a*a))*DEG<< endl;
	}
	return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String buf=sc.next();
		String pre="";
		int cnt=1;
		for(int i=0;i<buf.length();i++){
			if(buf.substring(i, i+1).equals(pre)){
				cnt++;
				//System.out.println(cnt);
				if(cnt==3){
					System.out.println("Yes");
					return;
				}
			}else{
				cnt=1;
			}
			pre=buf.substring(i,i+1);
			//System.out.println(pre);
		}
		System.out.println("No");
	}

}


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

int main(){
	ll n,a,b,c,d,e;
	cin >> n >> a >> b >> c >> d >> e;
	ll m = min({a,b,c,d,e});
	ll ans = 5 + (n-1)/m;
	cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
h,w=map(int,input().split())
l=[]
for i in range(h):
    l.append(list(input()))
dp=[[10**10 for j in range(w)] for i in range(h)]
if l[0][0]=='.':
    dp[0][0]=0
else:
    dp[0][0]=1
for i in range(h-1):
    if l[i][0]=='.' and l[i+1][0]=='#':
        dp[i+1][0]=dp[i][0]+1
    else:
        dp[i+1][0]=dp[i][0]
for i in range(w-1):
    if l[0][i]=='.' and l[0][i+1]=='#':
        dp[0][i+1]=dp[0][i]+1
    else:
        dp[0][i+1]=dp[0][i]       
for i in range(1,h):
    for j in range(1,w):
        a=dp[i-1][j]
        if l[i-1][j]+l[i][j]=='.#':
            a+=1
        b=dp[i][j-1]
        if l[i][j-1]+l[i][j]=='.#':
            b+=1
        dp[i][j]=min(a,b)
print(dp[h-1][w-1])

Measured memory_bytes: 41456
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn run() {
    input! {
        n: usize,
        a: [u32; n],
    }
    let mut min = 1;
    let mut prev = a[0];
    for a in a[1..].iter() {
        if *a <= prev {
            min += 1;
        }
        prev = *a;
    }
    println!("{}\n{}", min, n);
}

fn main() {
    run();
}



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

using namespace std;

int main()
{
    int k,x,a;
    cin>>k>>x;
    a=k*500;
    if(a>=x)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 100
#define INF 100000000

int G[N+1][N+1], vis[N+1], n, size[N+1];

void dfs(int p, int t){
  int i;
  vis[p] = t;
  for(i=1;i<=size[p];i++) if(t + 1 < vis[G[p][i]]) dfs(G[p][i], t + 1);
}

main(){
  int i, j, u;
  scanf("%d", &n);

  for(i=1;i<=n;i++){
    if(i<=n)break;
  }
  
  for(i=1;i<=n;i++){
    vis[i] = INF;
    scanf("%d", &u);
    scanf("%d", &size[u]);
    for(j=1;j<=size[u];j++) scanf("%d", &G[u][j]);
  }
  dfs(1, 0);
  for(i=1;i<=n;i++) printf("%d %d\n", i, (vis[i] == INF) ? -1 : vis[i]);
  return 0;
}



Measured memory_bytes: 2128
from heapq import heappop, heappush
import sys

N, M, X = map(int, input().split())
tree_height = [0]+[int(sys.stdin.readline()) for _ in [0]*N]
edges = [[] for _ in [0]*(N+1)]
for a, b, t in (map(int, l.split()) for l in sys.stdin):
    edges[a].append((b, t))
    edges[b].append((a, t))

vertices = [float("inf")]*(N+1)
pq = [(0, 1, X)]
while pq:
    time, v, height = heappop(pq)
    if v == N:
        print(time+(tree_height[v]-height))
        exit()
    if time > vertices[v]:
        continue

    max_height = tree_height[v]
    for to, dist in edges[v]:
        if max_height - dist < 0:
            continue
        new_height = height - dist
        new_time = time + dist
        if new_height < 0:
            new_time, new_height = new_time-new_height, 0
        elif new_height > tree_height[to]:
            new_time, new_height = new_time+(new_height-tree_height[to]), tree_height[to]

        if vertices[to] > new_time:
            vertices[to] = new_time
            heappush(pq, (new_time, to, new_height))
        
print(-1)


Measured memory_bytes: 91708
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> S(N);
  vector<vector<int>> I(3);
  vector<vector<int>> cnt(N,vector<int>(3));
  {
    string s;
    cin >> s;
    map<char,int> R;
    R['R'] = 0;
    R['G'] = 1;
    R['Y'] = 2;
    for(int i = 0; i < N; ++i){
      S[i] = R[s[i]];
      I[S[i]].push_back(i);
      ++cnt[i][S[i]];
    }
    for(int i = 1; i < N; ++i){
      for(int j = 0; j < 3; ++j)
        cnt[i][j] += cnt[i-1][j];
    }
  }
  int r = I[0].size(), g = I[1].size(), b = I[2].size();
  int sz[] = {r,g,b};
  for(int i = 0; i < 3; ++i)
    I[i].push_back(N);
  const int INF = 1e9;
  vector<vector<vector<vector<int>>>> dp(r+1,vector<vector<vector<int>>>(g+1,vector<vector<int>>(b+1,vector<int>(3,INF))));
  for(int i = 0; i < 3; ++i)
    dp[0][0][0][i] = 0;

  for(int i = 0; i <= r; ++i){
    for(int j = 0; j <= g; ++j){
      for(int k = 0; k <= b; ++k){
        for(int l = 0; l < 3; ++l){
          if(dp[i][j][k][l] >= INF) continue;
          for(int m = 0; m < 3; ++m){
            vector<int> tmp = {i,j,k};
            if(tmp[m] >= sz[m]) continue;
            if(l == m) continue;
            int idx = I[m][tmp[m]];
            int c = 0;
            for(int n = 0; n < 3; ++n){
              if(n == m) continue;
              c += max(0,cnt[idx][n] - tmp[n]);
            }
            ++tmp[m];
            auto& lv = dp[tmp[0]][tmp[1]][tmp[2]][m];
            lv = min(lv,dp[i][j][k][l]+c);
          }
        }
      }
    }
  }
  int ans = INF;
  for(int i = 0; i < 3; ++i)
    ans = min(ans,dp[r][g][b][i]);
  if(ans >= INF) ans = -1;
  cout << ans << endl;
}



Measured memory_bytes: 137180
from collections import deque


def main():
    N, M = map(int, input().split())
    xy = [list(map(int, input().split())) for _ in range(M)]

    G = [[] for _ in range(N)]
    ins = [0] * N
    for x, y in xy:
        G[x - 1].append(y - 1)
        ins[y - 1] += 1

    DP = [0] * N
    queue = deque()
    for i in range(N):
        if ins[i] == 0:
            queue.append(i)

    while queue:
        v = queue.popleft()
        for i in G[v]:
            ins[i] -= 1
            if ins[i] == 0:
                DP[i] = max(DP[i], DP[v] + 1)
                queue.append(i)

    print(max(DP))


if __name__ == '__main__':
    main()

exit()


Measured memory_bytes: 45368
n,x,y=map(int,input().split())

def min_dis(i,j):
    return min(abs(j-i),min(abs(j-x)+abs(y-i)+1,abs(x-i)+abs(j-y)+1))
discount = [0]*n 

for i in range(1,n+1):
    for j in range(1,n+1):
        if i<j:
            discount[min_dis(i,j)]+=1

for i in range(1,n):
    print(discount[i])

Measured memory_bytes: 50524