akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rrep(i, n) for(ll i = n - 1; i > -1; i--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define fi first
const ll INF = (1LL << 61) - 1;
const ll MOD = 1000000007 /*998244353*/;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, h, x, y, z, p, q, n, t, r, k, w, l, ans, i, j, u, v;
string S, T;
vl A, B;
#include <cstdint>
template <std::uint_fast64_t Modulus> class modint {
    using u64 = std::uint_fast64_t;

  public:
    u64 a;
    constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
    constexpr u64 &value() noexcept { return a; }
    constexpr const u64 &value() const noexcept { return a; }
    constexpr modint operator+(const modint rhs) const noexcept { return modint(*this) += rhs; }
    constexpr modint operator-(const modint rhs) const noexcept { return modint(*this) -= rhs; }
    constexpr modint operator*(const modint rhs) const noexcept { return modint(*this) *= rhs; }
    constexpr modint operator/(const modint rhs) const noexcept { return modint(*this) /= rhs; }
    constexpr modint &operator+=(const modint rhs) noexcept {
        a += rhs.a;
        if(a >= Modulus) {
            a -= Modulus;
        }
        return *this;
    }
    constexpr modint &operator-=(const modint rhs) noexcept {
        if(a < rhs.a) {
            a += Modulus;
        }
        a -= rhs.a;
        return *this;
    }
    constexpr modint &operator*=(const modint rhs) noexcept {
        a = a * rhs.a % Modulus;
        return *this;
    }
    constexpr modint &operator/=(modint rhs) noexcept {
        u64 exp = Modulus - 2;
        while(exp) {
            if(exp % 2) {
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }
};
using mint = modint<MOD>;
void input() { cin >> n >> k; }
void solve() {
    vector<mint> kaijo;
    kaijo.pb(1);
    rep(i, k) { kaijo.pb(kaijo.back() * (i + 1)); }
    mint ans = kaijo[k] / kaijo[k - n];
    mint era = 0;
    rep(i, n + 1) {
        if(i % 2) {
            era -= kaijo[n] / (kaijo[i] * kaijo[n - i]) * (kaijo[k - i] / kaijo[k - n]);
            // cout << (kaijo[n] / (kaijo[i] * kaijo[n - i])).a << " " << (kaijo[k - i] / kaijo[k - n]).a << endl;
        } else {
            era += kaijo[n] / (kaijo[i] * kaijo[n - i]) * (kaijo[k - i] / kaijo[k - n]);
        }
        // cout << era.a << endl;
    }

    cout << (ans * era).a << endl;
}
int main() {
    // cout<<fixed<<setprecision(15);
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
}

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define int long long
int mod = 1e9+7;
int power(int x, int y, int p)  
{  
    int res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  

int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,k;
    cin>>n>>k;
    int gcd[k+1]={0};
    int ans = 0;
    for(int i=k; i>=1; i--){
        int aa = k/i;
        aa = power(aa, n, mod);
        for(int j=2*i; j<=k; j+=i){
            aa -= gcd[j];
        }
        aa %= mod;
        if(aa < 0)aa+=mod;
        gcd[i] = aa;
        ans = ans + aa*i;
        ans %= mod;
    }
    cout<<ans;
    return 0;
}

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

int main(){
  //ifstream in("input.txt");
  //cin.rdbuf(in.rdbuf());

  int N;
  cin >> N;

  vector<int> card(N);
  for(int i=0;i<N;i++) cin>>card.at(i);
  //for(int x:card) cout<<x<<' '<<endl;

  sort(card.begin(), card.end(), greater<int>());
  //for(int i=0;i<N;i++) cout<<card.at(i)<<' '<<endl;

  int Alice = 0;
  int Bob = 0;

  for(int i=0;i<N;i++){
    if(i%2==0) Alice += card.at(i);
    else Bob += card.at(i);
  }

  cout << Alice-Bob <<endl;

}


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

int main() {
    string a, b, c;
    cin >> a >> b >> c;
    int num = 0;
    int ca = 0, cb = 0, cc = 0;
    while(1){
        if(num == 0)
        {
            if(a[ca] == 'a')
            {
                ca++;
                num = 0;
            }
            else if(a[ca] == 'b')
            {
                ca++;
                num = 1;
            }
            else if(a[ca] == 'c')
            {
                ca++;
                num = 2;
            }
        }
        else if (num == 1)
        {
            if (b[cb] == 'a')
            {
                cb++;
                num = 0;
            }
            else if (b[cb] == 'b')
            {
                cb++;
                num = 1;
            }
            else if (b[cb] == 'c')
            {
                cb++;
                num = 2;
            }
        }
        else if (num == 2)
        {
            if (c[cc] == 'a')
            {
                cc++;
                num = 0;
            }
            else if (c[cc] == 'b')
            {
                cc++;
                num = 1;
            }
            else if (c[cc] == 'c')
            {
                cc++;
                num = 2;
            }
        }
        //cout << ca << cb << cc << endl;
        if(ca == a.size() && num == 0) {
            cout << 'A' << endl;
            return 0;
        }
        if(cb == b.size() && num == 1) {
            cout << 'B' << endl;
            return 0;
        }
        if(cc == c.size() && num == 2) {
            cout << 'C' << endl;
            return 0;
        } 
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb          emplace_back
#define ll          long long
#define fi          first
#define se          second
#define mp          make_pair

using namespace std;

const int N = 41;
const int NState = 1 << 18;
const int mod = (int)1e9 + 7;

void add(int& x, int y) {if((x += y) >= mod) x -= mod;}

int f[N][NState][2], n, s, sum, nj, nk, x, y, z, xyz;

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    #define Task        "test"
    if(fopen(Task".inp", "r")) {
        freopen(Task".inp", "r", stdin);
        freopen(Task".out", "w", stdout);
    }
    cin >> n >> x >> y >> z;
    xyz = (1 << x) + (1 << (x + y)) + (1 << (x + y + z));
    f[0][1][0] = 1;
    for(int i = 0; i < n; ++i) {
        for(int j = 1; j < NState; ++j) {
            for(int k = 0; k < 2; ++k) {
               if(f[i][j][k] == 0) continue;
               for(int d = 1; d <= 10; ++d) {
                   nj = ((j << d) + 1) & (NState - 1);
                   nk = k | ((xyz & nj) == xyz);
                   add(f[i + 1][nj][nk], f[i][j][k]);
               }
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < NState; ++i) add(ans, f[n][i][1]);
    cout << ans;
}


Measured memory_bytes: 82176
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    //https://atcoder.jp/contests/abc141/tasks/abc141_a
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            string s = Console.ReadLine();

            if(s[2] == s[3] && s[4] == s[5]) {

                Console.WriteLine("Yes");

            } else {

                Console.WriteLine("No");

            }

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 11092
/*
(1)for binary shift operator always use 'LL' 1LL<<63

*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set_pair tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_multiset tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define Luv(...) [&] (auto &&u, auto &&v) { return __VA_ARGS__; }
  
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll a,b,c,k;cin>>a>>b>>c>>k;
	//while(k){
	ll sum=0;
	sum+=min(k,a);
		k-=(min(k,a));
		
		k-=min(k,b);
		sum-=min(k,c);
		k-=(min(k,c));
		cout<<sum<<endl;
		
	//}
	return 0;
} 

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define SORT(V) sort((V).begin(),(V).end())

int main(){
  string S;
  cin >> S;
  char previous;
  for(auto c:S) {
    if(c==previous) {
      cout << "Bad" << endl;
      return 0;
    } else {
      previous = c;
    }
  }
  cout << "Good" << endl;

  return 0;
}


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

int main(){
    int N,K;
    long long ans=0;
    cin>>N>>K;
    //b    
    for(int i=1;i<=N;i++){
        int p,q;
        p=N/i;
        q=N%i;
        
        ans+=p*max(0,i-K)+max(q-K+1,0);
    }
    if(K==0){ans-=N;}
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
X = int(input())

def is_prim(n):
    i = 2
    while i*i <= n:
        if n%i == 0:
            return False
        i += 1
    return n != 1

for i in range(X, 10**9+1):
    if is_prim(i):
        print(i)
        break


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

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#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 f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#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(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

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;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

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;
#pragma endregion

signed solve()
{
	int n;
	cin >> n;
	vector<int> t(n);
	REP(i, n) { cin >> t[i]; }
	int sum_t = accumulate(t.begin(), t.end(), 0);

	int m;
	cin >> m;
	int p, x;
	REP(i, m)
	{
		cin >> p >> x;
		p--;
		print(sum_t - t[p] + x);
	}
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
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;
}
void print() { std::cout << '\n'; }
void vprint() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
template <class H, class... T> void vprint(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << '\n';
    vprint(std::forward<T>(args)...);
}
template <class T> void vprint(std::vector<T> &v) {
    for (auto &&i : v) {
        std::cout << i << '\n';
    }
}
template <class T> void mprint(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << "";
        }
    }
}

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

    ll H, W;
    cin >> H >> W;

    ll ans = INF64;

    auto yoko = [&ans](ll H, ll W) {
        REP(i, H) {
            ll a = (i + 1) * W;
            ll h = (H - i - 1) / 2;
            ll b = h * W;
            ll c = (H - i - 1 - h) * W;
            if (0 < min({a, b, c}))
                chmin(ans, max({a, b, c}) - min({a, b, c}));
        }
    };
    auto tate = [&ans](ll H, ll W) {
        REP(i, H) {
            ll a = (i + 1) * W;
            ll h = (H - i - 1);
            ll b = h * (W / 2);
            ll c = h * (W - W / 2);
            if (0 < min({a, b, c}))
                chmin(ans, max({a, b, c}) - min({a, b, c}));
        }
    };
    yoko(H, W);
    yoko(W, H);
    tate(H, W);
    tate(W, H);

    print(ans);

    return 0;
}

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

using ll = long long;
#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 INF 1e9

int main(){
  int N, R;
  cin >> N >> R;
  if(N >= 10){
    cout << R << endl;
  }
  else{
    cout << R + 100*(10-N) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
#define eprintf(...) fprintf(stderr,__VA_ARGS__)

const int inf=int(1e9)+11;

int main(){
	int x,y; scanf("%d%d",&x,&y);
	int ans=inf;
	for(int u=0;u<=1;u++) for(int v=0;v<=1;v++){
		int xx=u?-x:x,yy=v?-y:y;
		if(xx<=yy) ans=min(ans,yy-xx+u+v);
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
map<ll,ll> m;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    for(ll i=0;i<n;i++){
        ll x;
        cin>>x;
        if(m.find(x)==m.end())
        m.insert({x,0});
        m[x]++;
    }
    ll a=m.begin()->first,c=prev(m.end(),1)->first;
    if(a==0&&m[a]==n)
    cout<<"Yes";
    else if(m.size()==2&&a==0&&2*m[a]==m[c])
    cout<<"Yes";
    else if(m.size()==3){
        ll b=next(m.begin(),1)->first;
        if((a^b)==c&&m[a]==m[b]&&m[b]==m[c])
        cout<<"Yes";
        else
        cout<<"No";
    }
    else
    cout<<"No";
}

Measured memory_bytes: 5120
#include<iostream>
using namespace std;
int main(){
    int n, m, l;
    cin>>n>>m>>l;
    int a[101][101], b[101][101];
    long long c[101][101]={};
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++){
            cin>>a[i][j];
        }
    for(int i=0;i<m;i++)
        for(int j=0;j<l;j++){
            cin>>b[i][j];
        }
    for(int i=0;i<n;i++)
        for(int j=0;j<l;j++)
            for(int k=0;k<m;k++){
                c[i][j] += a[i][k] * b[k][j];
            }
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            if(j) cout<<" ";
            cout<<c[i][j];
        }
        cout<<endl;
    }
}



Measured memory_bytes: 3188
#include<iostream>
 #include<stdio.h>
 #include<cstdlib>
 #include<cstdio>
 #include<string>
 #include<math.h>
 #include<time.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<fstream> 
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 #include<list>
 #include<memory>
 
 using namespace std;

 int main()
 {
   int x,y,z;
   while(cin>>x>>y>>z)
   {
     int n=(int)(1.0*(x-z)/(y+z));
     cout<<n<<endl; 
   }
   return 0;
 }
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
string S;
  cin >> S;
  if(S.at(0) == S.at(1) && S.at(1) == S.at(2) && S.at(2)==S.at(0)){
cout << "No" <<endl;
}
  else{
  cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#[warn(unused_imports)]
use std::io::*;
use std::str::FromStr;
use std::cmp;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<i64>();
    let mut ans = 0;
    for _ in 0..n {
        let tmp = read::<i64>();
        ans += tmp - 1;
    }
    println!("{}", ans);
}

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

int main() {
  
  int N; cin >> N; int64_t sum = 0;
  
  map<int64_t, int64_t> memo;
  
  for (int i = 0; i < N; i++) {
    
    int64_t a; cin >> a;
    
    memo[a]++;
    
  }
  
  for (auto x : memo) {
    
    int64_t key = x.first, value = x.second;
    
    if (value < key) sum += value;
    
    else sum += value - key;
    
  }
  
  cout << sum << endl;
  
}

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

int main()
{
    int n;
    cin >> n;
    int MAX_A = 2020202;
    vector<int> a(MAX_A+1, 0);
    rep(i,n)
    {
        int t;
        cin >> t;
        a[t]++;
    }
    for(int i = 1; i <= MAX_A; i++)
    {
        if(a[i] == 0) continue;
        for(int j = i+i; j <= MAX_A; j+=i)
        {
            a[j] = 2;
        }
    }
    int ans = 0;
    for(int i = 1; i <= MAX_A; i++)
    {
        if(a[i] == 1) ans++;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 11180
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
// #define int ll
using PII = pair<int, int>;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
 
template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) { 
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const int MOD = 1000000007;

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

  int n, m;
  cin >> n >> m;

  vector<int> v;
  for(int i=1; i*i<=m; ++i) {
    if(m%i==0) {
      v.push_back(i);
      if(i*i != m) v.push_back(m/i);
    }
  }

  int ans = 0;
  for(auto i: v) {
    if(m%i == 0 && m >= (ll)n*i) {
      chmax(ans, i);
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int n = Integer.parseInt(sc.next());
        String S = sc.next();
        sc.close();
        String ans2 = "";

        for (int i = 0; i < S.length(); i++) {
            if (((int) (S.charAt(i))) + n < 91) {
                ans2 = ans2 + String.valueOf((char) (S.charAt(i) + n));

            } else {
                ans2 = ans2 + String.valueOf((char) (S.charAt(i) + n -26));

            }
        }
        // 出力
        System.out.println(ans2);
    }
}


Measured memory_bytes: 147024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define yn(x, ok, ng) cout << ((x)?(ok):(ng)) << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;


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

int D;
cin >> D;
vi c(26);
rep(i,26) cin >> c[i];
vvi s(D,vi(26));
rep(d,D) rep(i,26) cin >> s[d][i];
vi t(D);
rep(d,D) {
    cin >> t[d];
    t[d]--;
}

vi last(26);

int res = 0;
rep(d,D) {
    res += s[d][t[d]];
    last[t[d]] = d+1;
    rep(i,26) {
        res -= c[i] * (d+1 - last[i]);
    }
    cout << res << endl;
}

return 0;
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;
#define MOD 998244353
#define INF 1000000000

int main(){
  int H1,M1,H2,M2,K;
  cin>>H1>>M1>>H2>>M2>>K;
  int start=60*H1+M1;
  int end=60*H2+M2;
  cout<<max(0,end-start-K)<<endl;
}


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

int main() {
  ll N;
  cin >> N;
  vector<double> x(N), y(N);
  vector<int> v(N);
  REP(i,N) {
    cin >> x[i] >> y[i];
    v[i] = i;
  }
  double total = 0;
  REP(i,N-1) {
    for( int j = i+1; j<N; ++j ) {
      double d = sqrt( (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
      total += d * 2 / N;
    }
  }
  cout << fixed << setprecision(10) << total << endl;
}

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


public class Main {
    int N,X;
    int[] L;
    private void solve() {
        N = nextInt();
        X = nextInt();
        L = new int[N];

        for(int i = 0;i < N;i++) {
            L[i] = nextInt();
        }

        int D = 0;
        int ans = 1;
        for(int i = 0;i < N;i++) {
            D = D + L[i];

            if (D <= X) {
                ans++;
            }
        }

        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[4096];
    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: 22612
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n - 1; i >= 0; i--)
#define ALL(x) x.begin(),x.end()

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const ll INF = 1e18;
const int mod = 1e9+7;
const int MAX = 1e6;

struct unionfind {
    vector<int> par; // 各要素の親(根の場合は-1)
    unionfind(int n) {
        par.resize(n, -1);
    }
    int root(int x) { // 要素xの属する集合の根のindexを返す(xが根の場合はx)
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }
    void unite(int x, int y) { // 要素xとyを同一の集合(根)に結合
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
    }
    bool same(int x, int y) { // 要素xとyが同一の集合に属するか判定
        return root(x) == root(y);
    }
    int size(int x) { // 要素の属する集合の大きさ
        return -par[root(x)];
    }
};

struct edge {int to, cost;}; // 辺
vector<edge> graph[MAX]; // 隣接リスト
bool visited[MAX]; // 訪問の有無

void dfs(int cur, int &cnt) {
    cnt++;
    visited[cur] = true;
    for (edge e : graph[cur]) {
        if (not visited[e.to]) {
            dfs(e.to, cnt);
        }
    }
}

void solve1() {
    int n, m;
    cin >> n >> m;
    rep(i, m) {
        int a, b;
        cin >> a;
        cin >> b;
        graph[a].push_back({b, 0});
        graph[b].push_back({a, 0});
    }
    int ans = 0;
    rep(i, n) {
        int cnt = 0;
        if (not visited[i]) {
            dfs(i, cnt);
            ans = max(cnt, ans);
        }
    }
    cout << ans << endl;
}

void solve2() {
    int n, m;
    cin >> n >> m;
    unionfind f(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        f.unite(a, b);
    }
    int ans = 0;
    rep(i, n) {
        ans = max(ans, f.size(i));
    }
    cout << ans << endl;
}

int main() {
    solve1();
    // solve2();
}

Measured memory_bytes: 42740
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] a = new int[n];
    for(int i=0; i<n; i++){
      a[i] = sc.nextInt();
    }

    int j = 0;
    int cnt = 0;
    int pre;
    while(true){
      if(a[j] != -1 && a[j] - 1 != j){
        pre = j;
        j = a[j] - 1;
        a[pre] = -1;
        cnt++;
        if(j==1){
          System.out.print(cnt);
          return;
        }
      }else{
        System.out.print("-1");
        return;
      }
    }

	}

}


Measured memory_bytes: 50812
#include<stdio.h>
#include<stdlib.h>
#include<assert.h>

#define max(a,b) (((a)>(b))?(a):(b))
#define min(a,b) (((a)>(b))?(b):(a))
#define abs(a)   (((a)<(0))?(-(a)):(a))

typedef long long ll;
typedef unsigned long long ull;

typedef struct s
{
	char* str;
	int i;
	int l;
} s_;

int cmp(const void* a,const void* b) {
	char* p1 = *(char**)a;
	char* p2 = *(char**)b;
	for (; *p1 == *p2; p1++, p2++) {
		if (*p1 == '\0') return ((s_*)b)->i - ((s_*)a)->i;
	}
	return *p1 - *p2;
}

int main(void)
{
	int n;
	scanf("%d", &n);
	s_* ss = malloc(n * sizeof(s_));
	for (size_t i = 0; i < n; i++)
	{
		ss[i].str = malloc(11 * sizeof(char));
		scanf("%s %d", ss[i].str, &ss[i].i);
		ss[i].l = i + 1;
	}
	qsort(ss, n, sizeof(s_), cmp);

	for (size_t i = 0; i < n; i++)
	{
		printf("%d\n", ss[i].l);
	}
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

  	int A, B, C, D; cin >> A >> B >> C >> D;
    cout << min(A, B) + min(C, D) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <numeric>
#include <climits>
#include <math.h>
#include <memory.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int N, M;
int cnt = 0;
ll ans = 0LL;
int i_index;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};
string board[64];
int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(abs(a - b) <= d && abs(b - c) <= d || abs(a - c) <= d)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <functional>
#include <iomanip>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

// #define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _fromto2(i,n) for(int i=0;i<=(n);++i)
#define _fromto3(i,a,b) for(int i=(a);i<=(b);++i)
#define fromto(...) _overload3(__VA_ARGS__,_fromto3,_fromto2,)(__VA_ARGS__)

#define rrep(i,n) for(int i=(n);i>=0;--i)
#define iter(it,v) for(auto it=v.begin();it!=v.end();++it)
const int MOD = 1e9+7;
const int INF = 1e9;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

// debug
template<class T>ostream& operator<<(ostream& os, vector<T>& vec){os<<"{";for(int i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
template<class T1,class T2>ostream& operator<<(ostream& out,const pair<T1,T2>& rhs){out<<"("<<rhs.first<<", "<<rhs.second<<")";return out;}
#include<type_traits>
template<typename T,size_t SIZE,enable_if_t<!is_same<remove_cv_t<T>,char>::value,nullptr_t> = nullptr>ostream& operator<<(ostream& os,T(&arr)[SIZE]){os<<"{";for(size_t i=0;i<SIZE;++i)os<<(i?", ":"")<<arr[i];os<<"}";return os;}
#ifdef LOCAL
    #define debug(v) cerr<<v<<"\n"
#else
    #define debug(...) 42
#endif


int main() {
  int N, M; cin >> N >> M;

  set<int> s;
  map<int, int> wa;
  rep(i, M) {
    int p; string S;
    cin >> p >> S;
    if (S == "AC") {
      s.insert(p);
    } else if (s.find(p) == s.end())
      ++wa[p];
  }
  int ans = 0;
  for (const auto& e : s) {
    ans += wa[e];
  }
  cout << s.size() << " " << ans << endl;

  return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <cstring>

#define INF 100000000

using namespace std;

int main()
{
    int h,w;
    cin >> h >> w;
    char s[h+2][w+2];
    bool key[h+2][w+2] = {false};
    for (int i = 1;i<=h;i++)
    {
        for(int j = 1;j<=w;j++)
        {
            cin >> s[i][j];
            if(s[i][j] == '#')
            {
                key[i][j] = true;
            }
        }
    }

    int ans[h+2][w+2] = {0};
    int dx[8] = {0,-1,0,1,1,-1,1,-1},dy[8] = {-1,0,1,0,1,-1,-1,1};

    for(int i = 1;i<=h;i++)
    {
        for(int j = 1;j<=w;j++)
        {
            if(key[i][j] == true)
            {
                
                for(int p = 0;p<8;p++)
                {
                    if(key[i+dx[p]][j+dy[p]] == true)
                    continue;
                    else{
                        ans[i+dx[p]][j+dy[p]] ++;
                    }
                }
            }
        }
    }
    for(int i = 1;i<=h;i++)
    {
        for(int j = 1;j<=w;j++)
        {
            if(key[i][j] == true)
            cout << "#";
            else
            cout << ans[i][j];
        }
        cout << "\n";
    }
    return 0;
    

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T, class T2> void smin(T& a, T2 val) {if (a > val) a = val;}template<class T, class T2> void smax(T& a, T2 val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, k;

void Mod(int &left){
   left %= mod;
   left += mod;
   left %= mod;
}

int32_t main(){_
   
   cin>>n>>k;

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

   sort(a.begin(), a.end());

   if (k == n){
      int pro = 1;
      for (int i = 0; i < n; ++i)
      {
         pro *= a[i];
         Mod(pro);
      }
      cout<<pro;
      exit(0);
   }

   if (k % 2){
      if (a.back() == 0){
         cout<<0;
         exit(0);
      }
      else if (a.back() < 0){
         int pro = 1;
         for (int i = n-1; i >= n-k; --i){
            pro *= a[i];
            Mod(pro);
         }
         cout<<pro;
         exit(0);
      }
   }
   
   int pro = 1, i = 0, j = n-1;
   if (k % 2){
      // i am sure that last element is > 0
      assert(a.back() > 0);
      pro = a.back();
      --k;
      --j;
   }

   while(k){
      int left = a[i] * a[i+1];
      int right = a[j] * a[j-1];
      if (left > right){
         Mod(left);
         pro *= left;
         Mod(pro);
         i += 2;
      }
      else{
         Mod(right);
         pro *= right;
         Mod(pro);
         j -= 2;
      }
      k -= 2;
   }

   cout<<pro;

   return 0;
}

Measured memory_bytes: 5128
import sys
from io import StringIO
import unittest

def resolve():
    N, = map(int, input().split())
    As = list(map(int, input().split()))
    ans = 0
    last = 0
    for a in As:
        dif = max(0,last-a)
        last = a+dif
        ans = ans+dif


    print("{}".format(ans))

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """5
2 1 5 4 3"""
        output = """4"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """5
3 3 3 3 3"""
        output = """0"""
        self.assertIO(input, output)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 97404
#include <iostream>

using namespace std;

#define MOD 1000000007
#define ll long long

ll gcdExtended(ll a, ll b, ll *x, ll *y)
{
    // Base Case
    if (a == 0)
    {
        *x = 0, *y = 1;
        return b;
    }

    ll x1, y1; // To store results of recursive call
    ll gcd = gcdExtended(b%a, a, &x1, &y1);

    // Update x and y using results of recursive
    // call
    *x = y1 - (b/a) * x1;
    *y = x1;

    return gcd;
}

ll modInverse(ll b, ll m)
{
    ll x, y; // used in extended GCD algorithm
    ll g = gcdExtended(b, m, &x, &y);

    // Return -1 if b and m are not co-prime
    if (g != 1)
        return -1;

    // m is added to handle negative x
    return (x%m + m) % m;
}

int
main(){
    int n;

    cin >> n;
    ll a[n];
    ll array_sum = 0, individual_square_sum = 0;
    for(int i=0;i<n;i++) {
        cin >> a[i];
        array_sum += a[i];
        array_sum %= MOD;

        individual_square_sum += (a[i]) * (a[i]);
        individual_square_sum %= MOD;
    }

    ll array_sum_square = (array_sum) * (array_sum);

    ll ac = (array_sum_square - individual_square_sum) % MOD;
    ll inv = modInverse(2, MOD);

    cout << ((inv * ac) % MOD) << endl;

    return 0;
}


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

int main()
{
	int a, b;
	while (cin >> a >> b){
		int sum = a + b;
		int counter = 1;
		while (sum > 9){
			counter++;
			sum = sum / 10;
		}
		if (a == 0 && b == 0)
			cout << 0 << endl;
		else
			cout << counter << endl;
	}
	return 0;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)

using namespace std;

/////////////////////////////////////////////////////
#define pll pair<ll,ll>
#define mp make_pair
#define MOD 998244353l

ll N,A[606060];
ll lp[303030];
ll ct[303030];
ll ctrl;
ll ans;

ll i,j;

void zerort(){
    printf("0\n");
    exit(0);
}

int main(){
    scanf("%lld",&N);
    fornum(i,0,N){
        scanf("%lld",&A[i]);
        A[i+N]=A[i];
    }
    ll ast;
    ll Ac=A[0];
    for(ast=0;ast<N&&A[ast]==Ac;ast++);
    
    Ac=A[ast];
    lp[Ac]=ast;
    fornum(i,ast,ast+N){
        if(A[i]==Ac){
            ct[Ac]++;
            continue;   
        }
        if(ct[A[i]]!=0){
            zerort();
        }
        //printf("%lld:%lld\n",Ac,ct[Ac]);
        Ac=A[i];
        lp[Ac]=i;
        ct[Ac]++;
    }
    //printf("%lld:%lld\n",Ac,ct[Ac]);

    ctrl=ct[1]-1;
    if(ctrl==N-1){
        ans=1;
        fornum(i,1,N+1)
            ans=(ans*i)%MOD;
        printf("%lld\n",ans);
        return 0;
    }
    fornum(i,1,N+1)
        if(ctrl<ct[i]-1)
            zerort();
    
    ll space=0;
    ans=1;
    fornum(i,1,N+1){
        if(ct[i]==0){
            if(space==0)
                zerort();
            ans=(ans*space)%MOD;
            space--;
        }else{
            ll il=A[lp[i]-1];
            ll ir=A[lp[i]+ct[i]];
            if(il>i&&i<ir&&ct[i]-1<ctrl)
                zerort();
            if(il<i){
                if(i>ir){
                    ans=(ans*(ctrl-ct[i]+2<ct[il]?ctrl-ct[i]+2:ct[il]))%MOD;
                    ll ctiil=ct[il]+ct[i];
                    ct[il]=ctiil-ctrl-1>1?ctiil-ctrl-1:1;
                    ct[i]=ctiil-ct[il];
                }else{
                    ll ctiil=ct[il]+ct[i];
                    if(ctiil-ctrl-1<1)
                        zerort();
                    ct[i]=ctrl+1;
                    ct[il]=ctiil-ct[i];
                }
                space+=ct[il]-1;
                //printf("%lld,%lld,%lld ",il,ct[il],space);
            }
            if(i>ir){
                space+=ct[i]-1;
            }
        }
        //printf("%lld:%lld %lld %lld\n",i,ct[i],space,ans);
    }
    printf("%lld",ans);



    return 0;
}

Measured memory_bytes: 9728
#include <cstdio>
#include <cstring>
using namespace std;

const int MOD = 998244353;

char s[2002];
int dp[2][2002], inv[2002];

void add(int &a, int b){ a = a + b < MOD ? a + b : a + b - MOD; }
int mul(int a, int b){ return 1LL * a * b % MOD; }

int main(){
  scanf("%s", s + 1); int N = strlen(s + 1);

  inv[1] = 1;
  for(int i = 2; i <= N + 1; i++) inv[i] = MOD - mul(MOD / i, inv[MOD % i]);

  dp[0][0] = 1;

  for(int i = 0; i < N; i++){
    int i_ = i & 1, _i = i_ ^ 1;
    for(int j = 0; j <= i + 1; j++) dp[_i][j] = 0;

    for(int j = 0; j <= i; j++){
      int v = dp[i_][j];

      int r = j + '2' - s[i + 1];
      int b = i - j + s[i + 1] - '0';

      if(r > 0) add(dp[_i][r - 1], v);
      if(b > 0) add(dp[_i][r], v);
    }
  }

  int n = N & 1, ans = 0, bin = 1;

  for(int i = 0; i <= N; i++){
    add(ans, mul(dp[n][i], bin));
    bin = mul(bin, mul(N - i, inv[i + 1]));
  }

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

Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String S = scan.next();
		scan.close();
		if(S.equals("SUN"))System.out.println("7");
		if(S.equals("MON"))System.out.println("6");
		if(S.equals("TUE"))System.out.println("5");
		if(S.equals("WED"))System.out.println("4");
		if(S.equals("THU"))System.out.println("3");
		if(S.equals("FRI"))System.out.println("2");
		if(S.equals("SAT"))System.out.println("1");
	}
}


Measured memory_bytes: 21716
#include <stdio.h>
int main(void) {
	int x,n,t,min,sum;
	sum  = min = 0;

	scanf("%d %d %d", &n, &x, &t);
	while (sum < n) {
		sum += x;
		min += t;
	}

	printf("%d\n", min);
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

template<int um> class UF {
	public:
	vector<int> par,rank;
	UF() {rank=vector<int>(um,0); for(int i=0;i<um;i++) par.push_back(i);}
	int operator[](int x) {return (par[x]==x)?(x):(par[x] = operator[](par[x]));}
	int operator()(int x,int y) {
		if((x=operator[](x))==(y=operator[](y))) return x;
		if(rank[x]>rank[y]) return par[x]=y;
		rank[x]+=rank[x]==rank[y]; return par[y]=x;
	}
};
UF<500000> uf;

int N,M;
int U[2020],V[2020],W[2020],T[2020];
vector<pair<int,int>> E[2020];
int D[1010][1010];
ll X;
ll p2[2020];
ll mo=1000000007;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	p2[0]=1;
	FOR(i,2010) p2[i+1]=p2[i]*2%mo;
	
	cin>>N>>M>>X;
	priority_queue<pair<int,int>> PQ;
	FOR(i,M) {
		cin>>U[i]>>V[i]>>W[i];
		U[i]--;
		V[i]--;
		E[U[i]].push_back({V[i],i});
		E[V[i]].push_back({U[i],i});
		PQ.push({-W[i],i});
	}
	
	ll S=0;
	while(PQ.size()) {
		x=PQ.top().second;
		PQ.pop();
		if(uf[U[x]]!=uf[V[x]]) {
			S+=W[x];
			uf(U[x],V[x]);
			T[x]=1;
		}
	}
	FOR(i,N) {
		FOR(x,N) D[i][x]=1<<30;
		D[i][i]=0;
		priority_queue<pair<int,int>> Q;
		Q.push({0,i});
		while(Q.size()) {
			int co=-Q.top().first;
			int cur=Q.top().second;
			Q.pop();
			if(D[i][cur]!=co) continue;
			FORR(e,E[cur]) {
				if(D[i][e.first]>max(co,W[e.second])) {
					D[i][e.first]=max(co,W[e.second]);
					Q.push({-D[i][e.first],e.first});
				}
			}
		}
	}
	
	ll DD=X-S;
	
	int eq=0,up=0;
	FOR(i,M) if(T[i]==0) {
		if(W[i]-D[U[i]][V[i]]==DD) eq++;
		if(W[i]-D[U[i]][V[i]]>DD) up++;
	}
	ll ret=0;
	if(DD>0) {
		ret=2*(p2[eq]+mo-1)*p2[up]%mo;
	}
	else if(DD==0) {
		ret=2*(p2[eq]+mo-1)*p2[up]%mo;
		ret+=(p2[N-1]+mo-2)*p2[M-N+1]%mo;
	}

	cout<<ret%mo<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 8432
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String line = scanner.nextLine();
        String[] values = line.split(" ");
        long count = Integer.parseInt(values[0]);
        ArrayList<Long> l1 = new ArrayList<>();
        line = scanner.nextLine();
        values = line.split(" ");
        for (int i = 0; i < count; i++) {
            l1.add(Long.valueOf(values[i]));
        }
        HashSet<Long> s1 = new HashSet<>(l1);
        if (l1.size() == s1.size()) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 66620
N = int(input())
T = 86400
W = 10801
mem = [0 for i in range(T)]
time = 0
for i in range(N):
    a,b = map(int,input().split())
    time += a
    mem[time % T] += 1
    time += b

mem += mem
cums = [0]
for t in mem:
    cums.append(cums[-1] + t)

ans = 0
for t in range(T):
    ans = max(ans, cums[t+W] - cums[t])
print(ans)


Measured memory_bytes: 11308
require 'set'

class Array
    def pop_q
        first = self[0]
        self.delete_at 0
        return first
    end
end

def main
    al = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
    n = gets.to_i
    as = [[0]]
    while as[0].size < n
        target = as.pop_q
        (0..target.max+1).each do |n|
            new_a = target + [n]
            as.push new_a
        end
    end
    as.each do |a|
        s_a = []
        a.each do |m|
            s_a.push al[m]
        end
        puts s_a.join("")
    end
end

main

## イディオムなど
# until s.empty? do
#
## 配列のインデックス
# s[0,6] # 0番目から6文字
# s[0..6] # 0番目から6番目まで
# s[5..-1] # 5番目から最後まで
#
## 全探索
# [0, 1].repeated_permutation(n) do |combination| # bit全探索
# array.combination(i) do |selected| # array から要素が i 個である部分列を全部抽出
#
## 無向グラフの幅優先探索(BFS)
# to = Array.new(n).map{Array.new()} # ある頂点と繋がる頂点のリスト
# m.times do
#     a,b = gets.chomp.split(" ").map(&:to_i)
#     to[a].push b
#     to[b].push a
# end
# q = Queue.new # BFS は queue
# ds = Array.new(n, -1)
# pre = Array.new(n, -1)
#
## その他
# a1 = Marshal.load(Marshal.dump(a2)) # 深いコピー
# matrix = Array.new(n).map{Array.new()} # 二次元配列の初期化
# 

Measured memory_bytes: 41852
# solution
import io

n,m,k = map(int,input().split())
if 2*k >= m-n+1:
    for i in range(n,m+1):
        print(i)
else:
    for j in range(n,n+k):
        print(j)
    for p in range(m-k+1,m+1):
        print(p)

Measured memory_bytes: 3060
#include<cstdio>

int main(){
	int A,B;
	scanf("%d %d",&A,&B);
	if(A>=13){
		printf("%d",B);
	}
	if(A>=6 && A<=12){
		printf("%d",B/2 );
	}
	if(A<=5){
		printf("0");
	}
}

Measured memory_bytes: 128