akhauriyash/Code-Regression huggingface dataset:
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes = "Yes", T no = "No") { cout << (val ? yes : no) << endl; }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}


#line 2 "tmp.cpp"

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

  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(n);
  vector<int> in(n, 0);
  REP(i, n - 1 + m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    in[b]++;
  }

  int root = 0;
  REP(i, n) {
    if (in[i] == 0) {
      root = i;
      break;
    }
  }

  vector<int> ans(n);
  queue<int> q;
  ans[root] = -1;
  q.push(root);
  while (!q.empty()) {
    int rt = q.front();
    q.pop();
    for (const auto v : g[rt]) {
      in[v]--;
      if (in[v] == 0) {
        ans[v] = rt;
        q.push(v);
      }
    }
  }
  REP(i, n) { cout << ans[i] + 1 << endl; }
  return 0;
}


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

template<typename T, typename E, typename F, typename G, typename H>
class LazySegmentTree {
  int n, height;
  F f; G g; H h; const T ti; const E ei;
  vector<T> dat; vector<E> laz; vector<int> highest;

  void propagate(int k) {
    if(laz[k] != ei) {
      laz[2*k] = h(laz[2*k],laz[k]); laz[2*k+1] = h(laz[2*k+1],laz[k]);
      dat[k] = g(dat[k],laz[k],n/highest[k]);
      laz[k] = ei;
    }
  }
  inline void recalc(int k) {
    while(k >>= 1) dat[k] = f(g(dat[2*k],laz[2*k],n/highest[2*k]),g(dat[2*k+1],laz[2*k+1],n/highest[2*k+1]));
  }
  inline void thrust(int k) {
    for(int i = height; i > 0; i--) propagate(k >> i);
  }
public:
  LazySegmentTree(int _n, F f, G g, H h, T ti, E ei): f(f), g(g), h(h), ti(ti), ei(ei) {
    n = 1; height = 0;
    while(n < _n) n <<= 1, height++;
    dat.assign(2*n,ti); laz.assign(2*n,ei); highest.assign(2*n,0);
    int c = 1;
    for(int i = 1; i < 2*n; i++) {
      if(c*2 <= i) c <<= 1;
      highest[i] = c;
    }
  }
  void set(int k, T x) {
    dat[k+n] = x;
  }
  void build() {
    for(int i = n-1; i >= 0; i--) {
      dat[i] = f(dat[2*i],dat[2*i+1]);
    }
  }
  void update(int a, int b, const E x) {
    thrust(a += n); thrust(b += n-1);
    for(int l = a, r = b + 1; l < r; l >>= 1, r >>= 1) {
      if(l & 1) laz[l] = h(laz[l],x), ++l;
      if(r & 1) --r, laz[r] = h(laz[r],x);
    }
    recalc(a); recalc(b);
  }
  T query(int a, int b) {
    thrust(a += n); thrust(b += n-1);
    T l = ti, r = ti; b++;
    while(a < b) {
      if(a & 1) l = f(l,g(dat[a],laz[a],n/highest[a])), a++;
      if(b & 1) b--, r = f(g(dat[b],laz[b],n/highest[b]),r);
      a >>= 1; b >>= 1;
    }
    return f(l,r);
  }
};


int main(){
  ll n, d, a;
  cin >> n >> d >> a;
  P x[n];
  ll y[n];
  rep(i,n) {
    cin >> x[i].first >> x[i].second;
    y[i] = x[i].first;
  }
  sort(x,x+n); sort(y,y+n);
  auto f = [](ll a, ll b){return a+b;};
  auto g = [](ll a, ll b, int l){return a+b*l;};
  LazySegmentTree<ll,ll,decltype(f),decltype(g),decltype(f)> lst(n,f,g,f,0,0);
  rep(i,n) lst.set(i,x[i].second);
  lst.build();
  int p = 0;
  ll ans = 0;
  while(p < n) {
    ll q = lst.query(p,p+1);
    if(q > 0) {
      ll s = (q+a-1)/a;
      ans += s;
      int u = upper_bound(y,y+n,y[p]+2*d) - y;
      lst.update(p,u,-s*a);
    }
    p++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 15232
#include<iostream>
#include<cmath>

int main() {
  int N;
  int T;
  int A;
  std::cin >> N >> T >> A;
  double out_t;
  int out_n;
  for (int i=0; i<N; i++) {
    double temp_t;
    std::cin >> temp_t;
    temp_t = T-0.006*temp_t;
    if (i==0) {
      out_t = std::abs(A - temp_t);
      out_n = i;
    }
    else {
      if (out_t > std::abs(A-temp_t)) {
        out_t = std::abs(A-temp_t);
        out_n = i;
      }
    }
  }
  std::cout << out_n+1 << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

template<typename T>
istream& operator>> (istream& is, vector<T> &vec){
    for(T& x: vec) is >> x;
    return is;
}

int main(){
    string s; cin >> s;
    ll r = 0, l = 0;
    vector<pair<ll, ll>> rl; //l, r
    rep(i, s.length()){
        if(s[i] == 'R'){
            if(l > 0){
                rl.push_back(make_pair(r/2+r%2+l/2, r/2+l/2+l%2));
                l = 0;
                r = 0;
            }
            r++;
        }else{
            l++;
        }
    }
    rl.push_back(make_pair(r/2+r%2+l/2, r/2+l/2+l%2));
    for(ll i = 0, index = 0; i < s.length(); ++i){
        if(i > 0) cout << " ";
        if(s[i] == 'R' && s[i+1] == 'L'){
            cout << rl[index].first << " " << rl[index].second;
            i++; index++;
        }else{
            cout << "0";
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1528
#include <iostream>
#include <algorithm>
#include <vector>
#include <climits>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
using ll = long long;

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    ll N,K,x[50],y[50]; cin >> N >> K;
    ll ans = LLONG_MAX;
    REP(i,N) cin >> x[i] >> y[i];

    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < N; ++j) { // x[i] < x[j]
            if(x[i] >= x[j]) continue;

            for(int k = 0; k < N; ++k) { 
                for(int l = 0; l < N; ++l) { // y[k] < y[l]
                    if(y[k] >= y[l]) continue;
                    // check
                    int cnt = 0;
                    for(int m = 0; m < N; ++m) {
                        if(x[i]<=x[m] && x[m]<=x[j] && y[k]<=y[m] && y[m]<=y[l]) ++cnt;
                    }
                    if(cnt < K) continue;
                    ans = min(ans, (x[j] - x[i]) * abs(y[l] - y[k]));
                }
            }
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

const int MOD = 998244353;
int N, S;
int A[3000];
int dp[3010];

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

    cin >> N >> S;
    REP (i, N) cin >> A[i];
    dp[0] = 0;
    int ans = 0;
    REP (i, N) {
        for (int j = S; j - A[i] >= 0; --j) {
            if (j == A[i]) (dp[j] += i + 1) %= MOD;
            else (dp[j] += dp[j - A[i]]) %= MOD;
        }
        (ans += dp[S]) %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Code author: Saurabh Singhal
Code copy karne vaale tera muh kaala
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/

#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ppb pop_back

using namespace std;
typedef long long int ll;
typedef vector<int> vi_t;
typedef vector<ll> vll_t;
int t=1;
vll_t a,b;
int  main(){
	// #ifndef ONLINE_JUDGE
 //    // for getting input from input.txt
 //    freopen("input.txt", "r", stdin);
 //    // for writing output to output.txt
 //    freopen("output.txt", "w", stdout);
	// #endif
	string s,t;
	cin>>s>>t;
	vector<int>v1(26),v2(26);
	for(int i=0;i<s.size();i++){
		v1[s[i]-'a']++;
	}
	for(int i=0;i<t.size();i++){
		v2[t[i]-'a']++;
	}
	sort(v1.begin(),v1.end());
	sort(v2.begin(),v2.end());
	if(v1==v2){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 776
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    string x;
    cin >> x;
    string::iterator last_t = x.begin();
    int queue_ = 0;
    int stack_ = 0;
    repi(i, x){
        if(*i == 'S'){
            stack_++;
        }else if(stack_ == 0){
            queue_++;
        }else{
            stack_--;
        }
    }
    cout << queue_ + stack_ << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
 
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 
   Graph g(100005);
   priority_queue<lint> que;
   lint ans[100005];
   void dfs(lint to,lint from=-1){
        ans[to]=que.top();
        que.pop();
        for(lint f:g[to]){
            if(f==from)continue;
            dfs(f,to);
        }
   }
  int main(){
     lint n;
     cin>>n;
     rep(i,n-1){
            lint a,b;
            cin>>a>>b;
            --a;--b;
            g[a].push_back(b);
            g[b].push_back(a);
     }
     lint sum=0;
     lint ma=-INF;
     rep(i,n){
         lint c;
         cin>>c;
         sum+=c;
         ma=max(ma,c);
         que.emplace(c);
     }
     dfs(0);
     cout<<sum-ma<<endl;
     rep(i,n)cout<<ans[i]<<" ";
  }
  
     


Measured memory_bytes: 3712
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(){

    const int BILDING=4,FLOOR=3,ROOM=10;
    int n;
    int list[BILDING][FLOOR][ROOM]; //棟階部屋

    

    for(int i=0;i<BILDING;i++){
        for(int j=0;j<FLOOR;j++){
            for(int k=0;k<ROOM;k++){
                list[i][j][k]=0;
            }
        }
    }

    scanf(" %d",&n);
    for(int i=0;i<n;i++){
        int Resident[3],INOUT;
        scanf(" %d %d %d",&Resident[0],&Resident[1],&Resident[2]);
        scanf(" %d",&INOUT);
        list[Resident[0]-1][Resident[1]-1][Resident[2]-1] += INOUT; 
    }

    for(int i=0;i<BILDING;i++){
        for(int j=0;j<FLOOR;j++){
            for(int k=0;k<ROOM;k++){
                printf(" %d",list[i][j][k]);
            }
            printf("\n");
        }
        if(i != BILDING-1){
            printf("####################\n");
        }
    }
    
    

    return 0;
}



Measured memory_bytes: 2724
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

ll n, m, q;
vl a, b, c, d;

ll f(vl v) {
  ll res = 0;
  rep(i, q) if(v[b[i] - 1] - v[a[i] - 1] == c[i]) res += d[i];
  return res;
}

ll dfs(vl v) {
  if(v.size() == n) return f(v);
  ll x = v.back();
  ll res = 0;
  rep2(i, x, m + 1) {
    vl nv = v;
    nv.push_back(i);
    res = max(res, dfs(nv));
  }
  return res;
}

int main() {
  cin >> n >> m >> q;
  a = vl(q);
  b = vl(q);
  c = vl(q);
  d = vl(q);
  rep(i, q) cin >> a[i] >> b[i] >> c[i] >> d[i];
  ll ans = 0;
  rep2(i, 1, m + 1) ans = max(ans, dfs({i}));
  cout << ans << endl;
}

Measured memory_bytes: 3632
import fractions
from functools import reduce
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

a = int(input())

b = list(map(int,input().split()))

print(gcd_list(b))

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

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

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    string s;
    cin >> s;

    for (int i = 0; i < s.size();i++)
    if (i%2==0)
        cout << s[i];
    cout << endl;
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define ASSERT(expr...) assert((expr))

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ll = long long;
constexpr i64 INF = 1010000000000000017LL;
constexpr i64 MOD = 1000000007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) xmax = x; return true;
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) xmin = x; return true;
    return false;
}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr); ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH) cout << unitbuf;
    }
} PROCON_INIT;
ll mod_pow(ll x, ll n) {
    if (n == 0) return 1;
    if (n % 2 == 0) return mod_pow(x * x % MOD, n / 2) % MOD;
    else return x * mod_pow(x, (n - 1)) % MOD;
}
ll mod_pow_r(ll x, ll n) {
    if (x == 0) return 0;
    if (n == 0) return 1;
    ll ret = 1;
    while (n) if (n & 1) ret = ret * x % MOD; x = x * x % MOD; n /= 2;
    return ret;
}
ll factorial(ll n) {
    ll ret = 1;
    REP(i, n) ret *= (i + 1); ret %= MOD;
    return ret;
}
ll combination(ll n, ll r) {
    if (n < 0 || n < r || r < 0) return 0;
    ll fn = factorial(n);
    ll fr = factorial(r);
    ll fn_r = factorial(n-r);
    ll d = (mod_pow(fr, MOD - 2) * mod_pow(fn_r, MOD - 2)) % MOD;
    ll u = fn % MOD;
    return u * d % MOD;
}

void solve() {
    int n, a, b; cin >> n >> a >> b;
    string s; cin >> s;
    bool ret = false;
    int a_c=0; int b_c = 0;
    FOR(i, 0, n)
    {
        if (s[i] != 'c')
        {
            if (s[i] == 'a')
            {
                if (a_c + b_c < a+b) {
                    ret = true; 
                    a_c++;
                }                
            } else
            {
                if (a_c + b_c < a+b && b_c+1 <= b) {
                    ret = true;
                    b_c++;
                }
            }
        }
        if (ret) cout << "Yes" << endl;
        else cout << "No" << endl;
        ret = false;
    }
}

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

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

ll mod = 1e9+7;

ll gcd(ll a,ll b){
	if(b==0)return a;return gcd(b,a%b);
}
ll expo(ll base,ll pow){
    ll ans = 1;
    while(pow!=0){
        if(pow&1==1){ans = ans*base;}
        base *= base;pow/=2;}return ans;
}
ll inv(ll x){return expo(x,mod-2);}

int vis[123456], col[123456];
int nex[26], prev1[26];

int main(){
    //freopen("ip.txt", "rt", stdin);
    //freopen("op.txt", "wt", stdout);
    int n, m, k;
    cin >> n >> m >> k;
    if(k%m == 0 || k %n == 0){
       cout << "Yes";
       return 0;
    }
   for(int i = 1; i <= m; i++){
       for(int j = 1; j <= n; j++){
           if(i*n + j*(m-2*i) == k){
              cout << "Yes";
              return 0;
           }
       }
   }

   for(int i = 1; i <= n; i++){
       for(int j = 1; j <= m; j++){
           if(i*m + j*(n-2*i) == k){
              cout << "Yes";
              return 0;
           }
       }
   }

   cout << "No";
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int x,y;
    int small,big,a;
    x = scan.nextInt();
    y = scan.nextInt();
    scan.close();
    if(x < y) {
        small = x;
        big = y;
    }
    else {
        big =x;
        small = y;
    }
    while(true){
        a = big%small;
        big = small;
        small = a;
        if(a==0)break;
    }
    System.out.println(big);
    }
}


Measured memory_bytes: 26308
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
int main() {
	/*
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);  
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(a,b)<<" "<<max(0,a+b-n);    
}

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

int main(){
    int n;
    std::cin >> n;

    std::vector<int> s(n), t;
    for(int i = 0; i < n; ++i){
        std::cin >> s.at(i);
        if(0 != s.at(i) % 10){
            t.push_back(s.at(i));
        }
    }

    int ans = std::accumulate(s.begin(), s.end(), 0);
    if(0 == t.size()){
        ans = 0;
    }else if(0 == ans % 10){
        ans -= *std::min_element(t.begin(), t.end());
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
const ll INF=1e9+7;
const ll N = 17;

ll n,m,ans;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>m;
	if(n<=m)ans=n;
	else ans=n-1;
	pri(ans);
	return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#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++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};

//a^n (mod)
in modpow(in a, in n, in mod) {
    in res = 1ll;
    while (n > 0ll) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    in n,m;
    cin>>n>>m;
    in ans =modpow(n,m,MOD);
    cout<<ans<<endl;    
}


Measured memory_bytes: 3220
fun main(args: Array<String>) {
    val (a, b) = readLine()!!.split(' ').map { it.toLong() }
    println(f(a - 1) xor f(b))
}

private fun f(x: Long): Long {
    if (x % 2 == 0L) {
        return x xor x / 2 % 2
    }
    return (x + 1) / 2 % 2
}


Measured memory_bytes: 37996
#include <iostream>

int main()
{
    int a_500, b_100, c_50;
    int x;

    std::cin >> a_500;
    std::cin >> b_100;
    std::cin >> c_50;
    std::cin >> x;

    int counter = 0;

    for (int a = 0; a <= a_500; a++)
    {
        for (int b = 0; b <= b_100; b++){
            for (int c=0; c <=c_50; c++){
                if(a*500+b*100+c*50 == x){
                    counter++;
                }
            }
        }
    }

    std::cout << counter << std::endl;

    return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
import numpy as np
def main():
    k = int(input())

    k2 = np.arange(1, k+1)
    k2gcd = np.gcd.outer(k2, np.gcd.outer(k2, k2))
    print(k2gcd.sum())

if __name__ == '__main__':
    main()

Measured memory_bytes: 89564
#include<bits/stdc++.h>
using namespace std;
int main(){
  string x,y;
  cin >> x >> y;
  bool ans=true;
  for(int i=0; i<x.size(); i++){
    if(x.at(i) != y.at(i)){
      ans =false;
    }
  }
  if(ans){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

long long const MOD = 1000000007LL;

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

    vector<pair<string, pair<int, int> > > vec;
    for (int i = 0; i < n; i++) {
        string str;
        int p;
        cin >> str >> p;
        vec.push_back(make_pair(str, make_pair(-p, i + 1)));
    }

    sort(vec.begin(), vec.end());
    
    for (int i = 0; i < n; i++) {
        cout << vec[i].second.second << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
unsigned long long p[100000001],n,a,b,t,s=0; 
int main()
{
	cin>>n>>a>>b;
	for(int i=1;i<=n;i++)
		cin>>p[i];
	for(int i=1;i<=n-1;i++)
	{
			t=(p[i+1]-p[i])*a;
		if(t<=b)
			s=s+t;
		else
			s=s+b;
	}
	cout<<s;
	return 0; 
} 

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr> void dump(Itr begin, Itr end) { for (;begin != end; ++begin) clog << *begin << LF; }

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

  int a,b;
  cin >>a >> b;
  a+=b;

  if (a > 9) {
    cout << "error\n";
  } else cout << a << LF;

  return 0;
}



Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class C755 {
        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            int n = in.ints();
            out.println(f(n, 0, 0));
        }

        public int f(int n, long base, int mask) {
            base *= 10;
            int ans = 0;
            if (base + 3 <= n) {
                if ((mask | 1) == 7) {
                    ans++;
                }
                ans += f(n, base + 3, mask | 1);
            }
            if (base + 5 <= n) {
                if ((mask | 2) == 7) {
                    ans++;
                }
                ans += f(n, base + 5, mask | 2);
            }
            if (base + 7 <= n) {
                if ((mask | 4) == 7) {
                    ans++;
                }
                ans += f(n, base + 7, mask | 4);
            }
            return ans;
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public String string() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ints() {
            return Integer.parseInt(string());
        }

    }
}



Measured memory_bytes: 22356
# -*- coding: utf-8 -*-
N = int(input())

x =[]
y =[]
for i in range(N):
    x1, y1 = map(int,input().split())
    x.append(x1)
    y.append(y1)
    

NN = [[0] * N for _ in range(N) ]
ans = 0
for i in range(N):
    for j in range(i,N):
        ans += (((x[i] - x[j]) ** 2 +(y[i] - y[j]) ** 2) ** (1/2)) * 2 
ans = ans / N

print(ans)  

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int mn = 0x3f3f3f3f, res = -1;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    if (a < mn) {
      mn = a;
      res = i;
    }
  }
  cout << res + 1 << '\n';
}



Measured memory_bytes: 3124
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#define ll long long
#define ull unsigned long long
#define ci const int&
#define cl const long long&
#define cul const unsigned long long&
#define io_f std::ios::sync_with_stdio(false)
using namespace std;

int k;

int main() {
    cin >> k;
    cout << (k+1)/2 * (k/2);
    return 0;
}

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

using namespace std;

int n,d[100001];

int shortestDistance(int k,int l,int r)
{
	if(l>r)	return min(abs(d[l]-k),abs(d[r]-k));

	int m=(l+r)/2;
	if     (d[m]<k)	return shortestDistance(k,m+1,r);
	else if(d[m]>k)	return shortestDistance(k,l,m-1);
	else	return 0;
}

int main()
{
	for(int len,m;scanf("%d%d%d",&len,&n,&m),len;){
		d[0]=0;
		for(int i=1;i<n;i++)	scanf("%d",d+i);
		d[n++]=len;
		sort(d,d+n);

		int sum=0;
		while(m--){
			int k;	scanf("%d",&k);
			sum+=shortestDistance(k,0,n);
		}
		printf("%d\n",sum);
	}

	return 0;
}

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

using namespace std;
typedef long long ll;

int main(void) {
    int n, t, T, prev;
    ll ans = 0; 
    scanf("%d%d", &n, &T);
    cin >> t;
    for(int i=0; i<n-1; i++) {
        prev = t;
        scanf("%d", &t);
        if(t - prev <= T) ans += t -prev;
        else              ans += T;
    }

    return !printf("%lld\n", ans + T);
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
	int n,ac=0,wa=0,tle=0,re=0;
	cin>>n;
	string a[n];
	for(int i=0;i<n;i++)
	{
	cin>>a[i];
	if(a[i]=="AC")
	ac++;
	if(a[i]=="WA")
	wa++;
	if(a[i]=="TLE")
	tle++;
	if(a[i]=="RE")
	re++;
    }
    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tle<<endl;
    cout<<"RE x "<<re<<endl;

}


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

#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n'
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef tuple<ll,ll> Pll;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/10;
const ll MOD = 1e9+7;



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;cin>>N;
  cout<<180*(N-2)<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
class Main
{
  public static void main(String args[])
  {
    Scanner sc=new Scanner(System.in);
    String s=sc.next();
    char ch=s.charAt(0);
    if(ch>='A' && ch<='Z')
      System.out.println("A");
    else
      System.out.println("a");
  }
}


Measured memory_bytes: 35736
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

const int INF = 1<<29;

int N;
vector<int> L;
vector<int> A; // A, B, C


// 再帰する
// sums[0] = A に選んだ竹の長さの総和、nums[0] = A に選んだ竹の数
// sums[1] = B に選んだ竹の長さの総和、nums[1] = B に選んだ竹の数
// sums[2] = C に選んだ竹の長さの総和、nums[2] = C に選んだ竹の数
long long rec(vector<int> sums, vector<int> nums, int id) {
    // n 個全部考えたら集計
    if (id == N) {

        // A, B, C いずれも竹は 1 本は必ず使ってないとダメ (これをしないと example 3 は通らない)
        for (int i = 0; i < 3; ++i) {
            if (nums[i] == 0) return INF;
        }
        
        long long score = 0;
        for (int i = 0; i < 3; ++i) {
            score += abs(sums[i] - A[i]); // +1 したり -1 したりする分
            score += (nums[i] - 1) * 10; // 合体した回数
        }
        return score;
    }

    long long res = 1LL<<60; // 無限

    // 今ある竹を採用しない場合
    res = min(res, rec(sums, nums, id+1));

    for (int i = 0; i < 3; ++i) {
        // i = 0: A に採用する場合
        // i = 1: B に採用する場合
        // i = 2: C に採用する場合
        sums[i] += L[id], nums[i]++;
        res = min(res, rec(sums, nums, id+1));
        sums[i] -= L[id], nums[i]--; // 一旦元に戻す (こういうのをバックトラックと呼ぶ)
    }
    
    return res;
}

int main() {
    // 入力
    cin >> N;
    A.resize(3);
    for (int i = 0; i < 3; ++i) cin >> A[i];
    L.resize(N);
    for (int i = 0; i< N; ++i) cin >> L[i];

    // 再帰する
    vector<int> sums(3, 0), nums(3, 0);
    cout << rec(sums, nums, 0) << endl;
}


Measured memory_bytes: 256
N = int(input())
n = N

#桁数
digit_cnt = len(str(N))

Sn = 0
#last桁目から1桁目まで
for d in range(digit_cnt, 0, -1):
  Sn += n // (10**(d-1)) #10の桁-1乗で割り、切り捨てて足す
  n -= (n // (10**(d-1))) * (10**(d-1)) #桁を減らす

if N % Sn == 0:
  print('Yes')
else: print('No')

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

int main() {
  int N;
  cin >> N;
  vector<int> p(N);
  vector<int> q(N);
  for(int i=0;i<N;i++){
    cin >> p[i];
    q[i] = p[i];
    }
  sort(q.begin(),q.end());

  int count =0;
  for(int i=0;i<N;i++){
      if(p[i]==q[i]) count++;
    }

  if(count>=N-2) cout << "YES" << endl;
  else cout << "NO" << endl;
  }


Measured memory_bytes: 256
H,W = map(int,input().split())
board = ["."*(W+2)]
for i in range(H):
    board.append("." + input() + ".")
board.append("."*(W+2))

for i in range(1,H+1):
    for j in range(1,W+1):
        if board[i][j] == "#":
            if board[i-1][j] == board[i+1][j] == board[i][j-1] == board[i][j+1] == ".":
                print("No")
                break
    else:
        continue
    break
else:
    print("Yes")


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

int main() {
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;

    if(e - a > k){
      cout << ":(" << endl;
    }
  
  else{
    cout << "Yay!" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define es cout<<" "
#define dump(x) cout<<" "<<#x<<"="<<x
#define pdump(p) cout<<" "<<#p<<"=("<<p.fst<<","<<p.snd<<")"
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std; using lint = long long; using ld = long double;
using pii = pair<int, int>; using pll = pair<lint, lint>;
template<class T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<class T, class... Ts> 
auto make_vec(size_t a, Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));}

int main(void) {
    int n; cin >> n;
    vector<bool> b(n + 1, false);
    int m; cin >> m;
    repeat (i, m) {
        int t; cin >> t;
        b[t] = true;
    }
    vector<int> dp(n + 1, 0);
    const int MOD = 1e9 + 7;
    dp[0] = dp[1] = 1;
    if (n == 1) {cout << 1 << endl; return 0;}
    if (b[1]) dp[1] = 0;
    repeat_from_to (i, 2, n) {
        dp[i] = dp[i-1] + dp[i-2];
        dp[i] %= MOD;
        if (b[i]) dp[i] = 0;
    }
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>


char dividing(int math, int english, int japanese)
{
    if (math == 100 || english == 100 || japanese == 100) {
        return 'A';
    } else if ((math + english) / 2 >= 90) {
        return 'A';
    } else if ((math + english + japanese) / 3 >= 80) {
        return 'A';
    } else if ((math + english + japanese) / 3 >= 70) {
        return 'B';
    } else if ((math + english + japanese) / 3 >= 50) {
        if (math >= 80 || english >= 80) {
            return 'B';
        } else {
            return 'C';
        }
    } else {
        return 'C';
    }
}


int main()
{
    int math, english, japanese, n;  //n:size of dataset
    std::cin >> n;
    while (n != 0) {
        for (int i = 0; i < n; i++) {
            std::cin >> math >> english >> japanese;
            std::cout << dividing(math, english, japanese) << std::endl;
        }
        std::cin >> n;
    }
    return 0;
}

Measured memory_bytes: 3016
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define inf 1e9
#define mod 1000000007
#define ff first
#define ss second

void solve()
{
	int n;
	cin >> n;
	int x = n % 10;
	if (x == 2 or x == 4 or x == 5 or x == 7 or x == 9)
		cout << "hon";
	else if (x == 0 or x == 1 or x == 6 or x == 8)
		cout << "pon";
	else
		cout << "bon";
}

signed main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	solve();
	return 0;
}


Measured memory_bytes: 3648
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
sys.setrecursionlimit(10**7)
from pprint import pprint as pp
from pprint import pformat as pf
# @pysnooper.snoop()
#import pysnooper # debug

import math
#from sortedcontainers import SortedList, SortedDict, SortedSet # no in atcoder
import bisect
from fractions import Fraction
from collections import defaultdict

def is_same_sign(a, b):
    if a > 0 and b > 0:
        return True
    if a < 0 and b < 0:
        return True
    return False

def fraction_taple(a, b):
    g = math.gcd(a, b)
    if is_same_sign(a, b):
        s = 1
    else:
        s = -1
    a = abs(a) // g
    b = abs(b) // g
    return (s, a, b)

def mode(a, b):
    # retrun dict_key, arr_key
    if a == 0 and b == 0:
        return 0, 0
    if a == 0:
        return 'ab', 0
    if b == 0:
        return 'ab', 1
    x = fraction_taple(a, b)
    y = fraction_taple(-1 * b, a)
    if x > y:
        return x, 0
    else:
        return y, 1

MOD = 1000000007

if __name__ == '__main__':

    n = int(input())

    d = defaultdict(lambda: [0, 0])
    zero = 0
    for _ in range(n):
        a, b = list(map(int, input().split()))
        dkey, akey = mode(a, b)
        if dkey == 0:
            zero += 1
        else:
            d[dkey][akey] += 1
    #print('d') # debug
    #pp(d) # debug

    ans = 1
    for pair in d.values():
        tmp = pow(2, pair[0], MOD) - 1 + pow(2, pair[1], MOD) - 1 + 1
        ans *= tmp
    ans += zero - 1
    ans %= MOD
    #print('ans') # debug
    print(ans)

    #print('\33[32m' + 'end' + '\033[0m') # debug


Measured memory_bytes: 158572
import java.io.*;
import java.math.BigInteger;
import java.util.*;

 
public class Main{
	/*
	 * use Integer for sorting
	 * avoid object comparison
	 * NEVER APPEND A STRING -> APPEND char by char
	 * Always use TreeSet instead of HashSet
	 * 
	 */
	public static class FastReader {
		BufferedReader br;
		StringTokenizer root;
		
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (root == null || !root.hasMoreTokens()) {
				try {
					root = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return root.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	static long mod = (long) (1e9+7);
	static long cf = 998244353;
    static final long MAX = (long) 1e8;
    public static List<Integer>[] edges;
    public static int[][] parent;
    public static long[] fac;
    public static int N = 400000+200;
    public static int x = 0;
    public static boolean[] visited;
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		
		long n = sc.nextLong();
		long ans = 0;
		if(n%2 != 0) out.println(0);
		else {
			while(n > 0) {
				ans+=(n/5)/2;
				n/=5;
			}
			out.println(ans);
		}
	  
		
		out.close();
	}
	
}

Measured memory_bytes: 22484
#if 0

#endif

#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
using namespace std;
template<class A>void p(A a){cout << (a) << endl;}
template<class A,class B>void p(A a,B b){cout << a << " "  ;p(b);}
template<class A,class B,class C>void p(A a,B b,C c){cout << a << " " ;p(b,c);}
template<class A,class B,class C,class D>void p(A a,B b,C c,D d){cout << a << " " ;p(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for copy
// for(int i=0;i<N;++i) {

int main(void) {
  int n;cin>>n;
  string s;cin>>s;
  // char alpha[27] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  REP(i,s.length()) {
    s[i]=(s[i]+n-65)%26+65;
    // int a = s[i];
  }
  p(s);
  return 0;
}



Measured memory_bytes: 256
#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++)
#define int long long
#define P pair<int,int>
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define all(v) v.begin(),v.end()
template<class T>inline void chmin(T &a,T b){a=min(a,b);}
template<class T>inline void chmax(T &a,T b){a=max(a,b);}

struct matrix{
	int m;
	vector<vector<int>>mat;
	matrix(int x,int y,int z){
		m=z;
		mat.resize(x);
		rep(i,x)mat[i].resize(y);
		rep(i,x)rep(j,y)mat[i][j]=0;
	}
	matrix operator*(matrix a){
		assert(mat[0].size()==a.mat.size());
		matrix res(mat.size(),a.mat[0].size(),m);
		rep(i,mat.size()){
			rep(j,a.mat[0].size()){
				rep(k,a.mat.size()){
					res.mat[i][j]+=mat[i][k]*a.mat[k][j]%m;
					res.mat[i][j]%=m;
				}
			}
		}
		return res;
	}
	matrix pow(int x){
		assert(mat.size()==mat[0].size());
		matrix res(mat.size(),mat.size(),m),me(mat.size(),mat.size(),m);
		rep(i,mat.size())res.mat[i][i]=1;
		me.mat=mat;
		while(x>0){
			if(x&1)res=res*me;
			me=me*me;
			x>>=1;
		}
		return res;
	}
};
int N,K;
signed main(){
	cin>>N>>K;
	matrix mat(N,N,mod);
	rep(i,N)rep(j,N)cin>>mat.mat[i][j];
	matrix ans=mat.pow(K);
	int sum=0;
	rep(i,N)rep(j,N)sum+=ans.mat[i][j];
	cout<<sum%mod<<endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define tii tuple<int,int,int>
signed main(){
  int N,ans=0;
  cin>>N;
  vi A(N);
  rep(i,0,N){
    cin>>A[i];
    ans+=A[i];
    }
  sort(ALL(A));
  ans-=A[N-1]/2;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
using System;

namespace ABC_C_Grid_Repainting_2
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			string[] input = Console.ReadLine().Split(' ');
			int h = int.Parse(input[0]);
			int w = int.Parse(input[1]);
			
			string[,] grids = new string[h, w];
			for (int i = 0; i < h; i++)
			{
				string GridInputs = Console.ReadLine();
				for (int j = 0; j < w; j++)
				{
					grids[i, j] = GridInputs.Substring(j, 1);
				}
			}

			bool isNotPaintedGrid = false;
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					if (grids[i, j] == "#")
					{
						if (i >= 1 && grids[i - 1, j] == "#")
						{
						}
						else if(i <= h - 2 && grids[i + 1, j] == "#")
						{
						}else if (j >= 1 && grids[i, j - 1] == "#")
						{	
						}else if (j <= w - 2 && grids[i, j + 1] == "#")
						{
						}
						else
						{
							isNotPaintedGrid = true;
							break;
						}
					}
				}

				if (isNotPaintedGrid)
				{
					break;
				}
			}

			if (isNotPaintedGrid)
			{
				Console.WriteLine("No");
			}
			else
			{
				Console.WriteLine("Yes");
			}
		}
	}
}

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

int main() {
    int N;
    cin>>N;
    string S;
    cin>>S;
    int ans = 1;
    char tmp;
    tmp = S[0];
    for(int i=1;i<N;++i){
        if(tmp!=S[i]){
            ans++;
            tmp = S[i];
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] h = new int[n];
		for (int i = 0; i < h.length; i++) {
			h[i] = sc.nextInt();
		}
		sc.close();

		int ans = 0;
		for (int i = 0; i < h.length; i++) {
			if (h[i] >= k) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 50224
// g++ -std=c++11 -O2 -Wall -Wl,--stack=268435456

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

typedef long long          ll;
typedef vector<int>        vi;
typedef vector< vi >       vvi;
typedef pair<int, int>     pi;
typedef vector< pi >       vpi;

#define LARGE_INT     1000000007
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = (int)(a); i < (int)(b); i++)


// string line;
// getline(cin, line);
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int  n;
    cin >> n;
    vector<double> p(n);
    REP(i, 0, n) { cin >> p[i]; }

    vector<double> dp(n+1, 0.0);
    dp[0] = 1.0;
    REP(i, 0, n) {  // dp[j]   Using first i coins, prob of getting j head
        double onp = dp[0] * (1 - p[i]);
        REP(j, 1, i+2) {
            double np = dp[j-1] * p[i] + dp[j] * (1 - p[i]);
            dp[j-1] = onp;
            onp = np;
        }
        dp[i+1] = onp;
    }
    double ans = 0.0;
    REP(j, n/2+1, n+1) { ans += dp[j]; }
    cout << setprecision(10) << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const ll INF=1e18;
const int MOD=1e9+7;
const double pi=acos(-1);

int main(){
  char a,b;
  cin >> a >> b;
  string s="";
  if(a<=b){
    rep(i,b-'0'){
      s+=a;
    }
  }
  else{
    rep(i,a-'0'){
      s+=b;
    }
  }
  cout << s << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+100;
typedef long long ll;
typedef struct Edge {
    ll x,y;
}Edge;
Edge e[N];
ll pre[N],sum[N],Cnt[N],a[N];
ll Find(ll fa){
    return fa==pre[fa]? fa : pre[fa] = Find (pre[fa]);
}
void Union(ll x,ll y,int No){
    a[No]=Cnt[x]*Cnt[y];
    Cnt[x]+=Cnt[y];
    pre[y]=x;
}
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
        pre[i]=i,Cnt[i]=1;
    ll cnt=1;
    for(ll i=0,x,y;i<m;i++){
        scanf("%lld%lld",&x,&y);
        e[cnt++]=Edge{x,y};
    }
    ll fx,fy;
    for(int i=cnt;i>=1;i--){
        fx=Find(e[i].x);
        fy=Find(e[i].y);
        if(fx!=fy){
            Union(fx,fy,i);
        }
    }
    for(int i=1;i<=m;i++){
        sum[i]=sum[i-1]+a[i];
    }
    for(int i=1;i<=m;i++){
        printf("%lld\n",sum[i]);
    }
    return 0;
}



Measured memory_bytes: 6016
#include <iostream>
using namespace std;
int main() {
    int n;
    while (cin >> n && n) {
        int cnt = 0;
        for (int i=2; i<n; ++i) {
            int sq = (n - (i - 1) * i / 2);
            if (0 < sq && sq % i == 0) {
                cnt ++;
            }
        }
        cout << cnt << endl;
    }
    return 0;
}

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

int main()
{
  vector<int> a(3);
  cin>>a[0]>>a[1]>>a[2];
  sort(a.begin(),a.end());
  cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<endl;
  return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <string>
#include <array>
#include <deque>
#include <iomanip>
#include <bitset>
#include <complex>
#include <sstream>
#include <algorithm>
#include <limits>
#include <cmath>
#include <utility>
#include <tuple>
#include <numeric>
#include <cassert>
using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;

template <typename T>
constexpr T INF = "Undefined";
template <>
constexpr int INF<int> = 1e9;
template <>
constexpr ll INF<ll> = 1e18;
template <>
constexpr ld INF<ld> = 1e30;

constexpr int mod = 1e9+7;
constexpr ld eps = 1e-10;
constexpr ld pi = acos(-1.0);

#define DUMP(a) cout << #a << ": " << (a) << endl


int main() {
    int N;
    cin >> N;
    vector<int> res;
    for(int i=1; i<=N; ++i) {
        int n = i*(i+1)/2;
        if(n >= N) {
            int a = n - N;
            for(int j=1; j<=i; ++j) {
                if(j == a) {
                    continue;
                }
                res.push_back(j);
            }
            break;
        }
    }
    for(auto x : res) {
        cout << x << endl;
    }
}



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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

int main() {
  llong K;
  cin >> K;

  llong ans = 0;
  for (int i = 1; i <= K; ++i) {
    for (int j = 1; j <= K; ++j) {
      for (int k = 1; k <= K; ++k) {
        ans += gcd(gcd(i,j),k);
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>

int main()
{
    int x,a,b,c,d;
    scanf("%d",&x);
    a=x%10;
    x=x/10;
    b=x%10;
    x=x/10;
    c=x%10;
    x=x/10;
    d=x%10;
    if(a == b && a==c){
        printf("Yes\n");
    }
    else if(d == c && d == b){
        printf("Yes\n");
    }
    else
        printf("No\n");
    return 0;

}


Measured memory_bytes: 128