akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define veccat(v1, v2) std::copy((v2).begin(),(v2).end(),std::back_inserter(v1)/*v1の後ろにv2を入れる*/)
#define intmax (std::numeric_limits<int64_t>::max() / 4)
using namespace std;
typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);



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




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

	int N;
	cin >> N;
	vector<int>T(N);
	rep(i, N)cin >> T[i];
	int ans = 1;
	rep(i, N) {
		ans *= (T[i] / gcd(ans, T[i]));
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef double db;
#define fi first
#define se second
#define pb push_back
#define vi vector<int>
#define SZ(x) (int)(x.size())
#define sci(x) scanf("%d",&(x))
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
#define syn ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
ll modpow(ll x,ll n,ll mod){ll res=1;for(;n;n>>=1,x=x*x%mod)if(n&1)res=res*x%mod;return res;}
const db eps=1e-8,PI=acos(-1.0);
const int N=2e5+10,M=1e6+10,INF=0x3f3f3f3f,mod=1e9+7;//998244353
int n;
ll a[N],dp[N][2];
int main(){
	sci(n);
	rep(i,1,n){
		scanf("%lld",&a[i]);
		if(i&1){
			dp[i][0]=max((i-2<0?0:dp[i-2][0])+a[i],dp[i-1][1]);
			dp[i][1]=(i-2<0?0:dp[i-2][1])+a[i];
		}
		else{
			dp[i][0]=max(dp[i-2][0]+a[i],dp[i-1][0]);
			dp[i][1]=max(dp[i-2][1]+a[i],dp[i-1][1]);
		}
	}
	if(n&1)printf("%lld\n",dp[n][0]);
	else printf("%lld\n",dp[n][1]);
    return 0;
}

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

int main(){
    string S; cin >> S;
    int ans = 0;
    for(int i=0;i<S.size();i++){
        for(int j=i;i<S.size();j++){
            if(S[j]=='A' || S[j]=='T' || S[j]=='G' || S[j]=='C'){
                if(ans < j-i+1){
                    ans = j-i+1;
                }
            }else{
                break;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#d=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
#import numpy as np
#n=int(input())
#li=input().split()
#S=input()
#import fractions
#n=int(input())

lis=list(map(int,input().split()))
ans=lis[0]-lis[1]+1


print(ans)


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

int n,q;
long long S;
long long T[50010];
int main(){
	cin >> n;
	set<long long> s;
	for(int i=1;i<=n;i++){
		cin >> S;
		s.insert(S);
	}
	cin >> q;
	for(int i=1;i<=q;i++){
		cin >> T[i];
	}
	int count = 0;
	for(int i=1;i<=q;i++){
		decltype(s)::iterator it = s.find(T[i]);
		if(it!=s.end()) count++;
	}
	cout << count << endl;
}


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

#define sz(x) int(x.size())
#define pii pair<int, int>
#define Task "abc"
#define For(i, a, b) for(int i = (a), _b = (b); i <= b; ++i)
#define Debug(X) cout << #X << " = " << X << '\n'
#define All(x) (x).begin(), (x).end()
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;

const int maxn = 1e5 + 10;
const int inf = 0x3f3f3f3f;
const ll mod = 1e9 + 7;

int n, a, b, c;
int l[8];
int ans = 3e3;

void backtrack(int i, int ca, int cb, int cc, int am, int bm, int cm){
  if (i == n){
    if (am == 0 || bm == 0 || cm == 0) return;
    ans = min(ans, am + abs(ca - a) + bm + abs(cb - b) + cm + abs(cc - c) - 30);
    return;
  }
  backtrack(i + 1, ca, cb, cc, am, bm, cm);
  backtrack(i + 1, ca + l[i], cb, cc, am + 10, bm, cm);
  backtrack(i + 1, ca, cb + l[i], cc, am, bm + 10, cm);
  backtrack(i + 1, ca, cb, cc + l[i], am, bm, cm + 10);
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
//  freopen(Task".inp", "r", stdin);
//  freopen(Task".out", "w", stdout);
  cin >> n >> a >> b >> c;
  for (int i = 0; i < n; ++i) cin >> l[i];
  backtrack(0, 0, 0, 0, 0, 0, 0);
  cout << ans;
}



Measured memory_bytes: 256
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>

#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>

using namespace std;



int main()
{
    int64_t N;
    std::cin >> N;

    struct P {
        int64_t time;
        int64_t x;
        int64_t y;
    };

    std::vector<P> points;

    for (int64_t n = 0; n < N; ++n) {
        P p;
        std::cin >> p.time >> p.x >> p.y;
        points.push_back(p);
    }

    P prev = {};

    for (auto p: points) {
        auto diffTime = p.time - prev.time;
        auto diffX = p.x > prev.x ? p.x - prev.x : prev.x - p.x;
        auto diffY = p.y > prev.y ? p.y - prev.y : prev.y - p.y;

        auto diff = diffX + diffY;

        if (diff > diffTime) {
            std::cout << "No" << std::endl;
            return 0;
        }
        if ((diffTime - diff) % 2 != 0) {
            std::cout << "No" << std::endl;
            return 0;
        }

        prev = p;
    }

    std::cout << "Yes" << std::endl;

    return 0;
}


Measured memory_bytes: 4468
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <limits>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, a, n) for (int i = a; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eps 1e-15

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef tuple<int, int, int> ti3;

int main()
{
    int n;
    scanf("%d", &n);
    printf("%d\n", (n / 2) * ((n + 1) / 2));
    return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
//#include <atcoder/all>
//using namespace atcoder;
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++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};


int main(){
 ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 cout << fixed << setprecision(10);
    int n;
    cin>>n;
    int x;
    vector<queue<int>> b(n);
    rep(i,n)rep(j,n-1){
        cin>>x;
        x --;
        b[i].emplace(x);
    }
    set<int> seen;
    int ans=-1;
    bool f=1;
    while(f){
        f=0;
        rep(i,n){
            if(b[i].empty()) continue;
            int op=b[i].front();
            if(op<i) continue;
            if(seen.count(op) || seen.count(i)) continue;
            if(b[op].front() != i) continue;
            f=1;
            b[i].pop();
            b[op].pop();
            seen.emplace(op);
            seen.emplace(i);
        }
        ans ++;
        seen.clear();
    }
    rep(i,n){
        if(!b[i].empty()){
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<ans<<endl;
}/*
./problem.exe
*/

Measured memory_bytes: 7872
#include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FSP(x) fixed << setprecision(x)
using namespace std;
using ll = long long;
constexpr ll INF = LLONG_MAX;
constexpr long double PI = acosl(-1);
void Yes() {cout << "Yes\n";}
void No() {cout << "No\n";}
void YES() {cout << "YES\n";}
void NO() {cout << "NO\n";}

#include <map>

/*	verified : 2020/07/18
		AOJ, Prime Factorize
		http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=NTL_1_A
*/

std::map<long long, long long> prime_fact(long long n) {
	std::map<long long, long long> ret;
	for (long long i = 2; i * i <= n; i++) {
		if (n % i) continue;
		long long cnt = 0;
		while (n % i == 0) {
			n /= i;
			cnt++;
		}
		ret[i] = cnt;
	}
	if (n > 1) ret[n] = 1;
	return ret;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//constexpr ll P = 1e9 + 7;
	//constexpr ll P = 998244353;

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

	ll x = a[0];
	for (ll i = 1; i < n; i++) x = __gcd(x, a[i]);
	if (x > 1) {
		cout << "not coprime" << endl;
		return 0;
	}

	set<ll> st;
	for (ll i = 0; i < n; i++) {
		map<ll, ll> mp = prime_fact(a[i]);
		for (auto j : mp) {
			if (st.find(j.first) != st.end()) {
				cout << "setwise coprime" << endl;
				return 0;
			} else st.insert(j.first);
		}
	}
	cout << "pairwise coprime" << endl;
}

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

#define fa(x,v) for(auto x:v)
#define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define spc " "
#define endl '\n'
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(s) (ll)int(s.length())
#define sz(v) (ll)int(v.size())
#define MOD 1000000007

void Fast_IO() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef rsd511
    freopen("input.in","r",stdin);
    freopen("output.out","w",stdout);
    #endif
    #ifndef rsd511
    #define trace(...) {}
    #define cotra(...) {}
    #endif
} 

// Code Here

int main()
{
    Fast_IO();
    ll n; cin >> n;
    if(n == 1) {
        cout << 0;
        return 0;
    }
    ll ans = 1;
    f(i,1,n) ans *= 10, ans %= MOD;
    ll umm = 1;
    f(i,1,n) umm *= 8, umm %= MOD;
    ans += umm;
    ans += MOD;
    ans %= MOD;
    umm = 1;
    f(i,1,n) umm *= 9, umm %= MOD;
    ans -= 2 * umm;
    ans += MOD;
    ans += MOD;
    ans %= MOD;
    cout << ans;
    return 0;
}

Measured memory_bytes: 3656
use proconio::{fastout, input, marker::Chars};
#[allow(unused_mut)]
#[fastout]
fn main() {
    input! {
        s: Chars
    }
    let mut res = 0;
    for i in 0..s.len() / 2 {
        if s[i] != s[s.len() - i - 1] {
            res += 1;
        }
    }
    println!("{}", res);
}


Measured memory_bytes: 2116
import java.util.*;
public class Main {
 
		public static void main(String[] args){
			Scanner sc = new Scanner(System.in);
			// 整数の入力
			int N = sc.nextInt();
			int X = sc.nextInt();
			ArrayList<Integer> L = new ArrayList<Integer>();
			for(int i=0 ; i<N ; i++){
				L.add(sc.nextInt());
			}
			int count = 1;
			int distance = 0;
			for(int i=0 ; i<N ; i++){
				distance += L.get(i);
				if(distance<=X){
					count+=1;
				}else break;
			}
			System.out.println(count);
		}
 
	}

Measured memory_bytes: 21844
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

void update(double& a, double b){
    a = min(a, b);
}

int main()
{
    vector<vector<double> > x(11, vector<double>(11));
    for(int i=3; i<=10; ++i){
        for(int j=3; j<=i; ++j){
            x[i][j] = x[j][i] = sqrt(pow(i+j, 2.0) - pow(i-j, 2.0)); 
        }
    }

    for(;;){
        string s;
        if(!getline(cin, s))
            return 0;
        istringstream iss(s);
        int w;
        iss >> w;
        vector<int> r;
        for(;;){
            int a;
            if(!(iss >> a))
                break;
            r.push_back(a);
        }
        int n = r.size();

        vector<vector<double> > dp(1<<n, vector<double>(11, w+1));
        for(int i=0; i<n; ++i)
            dp[1<<i][r[i]] = r[i];

        for(int i=0; i<(1<<n); ++i){
            bitset<12> bs(i);
            for(int j=0; j<n; ++j){
                if(bs[j])
                    continue;
                bitset<12> bs1 = bs;
                bs1[j] = true;
                for(int k=3; k<=10; ++k)
                    update(dp[bs1.to_ulong()][r[j]], dp[bs.to_ulong()][k] + x[k][r[j]]);
            }
        }

        bool ok = false;
        for(int i=3; i<=10; ++i){
            if(dp[(1<<n)-1][i] + i <= w)
                ok = true;
        }
        if(ok)
            cout << "OK" << endl;
        else
            cout << "NA" << endl;
    }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    int N;cin>>N;
    map<string,int> k;
    REP(i,N){
        string S;
        cin>>S;
        k[S]++;
    }
    vector<pair<int,string>> d;

    for (auto itr = k.begin(); itr != k.end(); ++itr)
    {
        d.push_back({itr->second, itr->first});
    }
    sort(d.begin(),d.end(),greater<pair<int,string>>());
    int q;
    vector<string> m;
    for( auto i = d.begin(); i != d.end() ; ++i ) {
        if(i==d.begin()){
            q = i->first;
            m.push_back(i->second);
        } else{
            if(q == i->first){
                m.push_back(i->second);
            }
        }
    }
    sort(m.begin(),m.end());
    for (const auto& e : m) {
        cout<<e<<endl;
    }
}

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


const int MAX_N = 2000000;
ll inv[MAX_N + 10];
ll fac[MAX_N + 10], facInv[MAX_N + 10];

const ll MOD = 1e9 + 7;

class MATH{
public:
	MATH(){
		inverse();
		factroial();
	}
	ll nCk(ll n, ll k){// n! / k!*(n-k)!
		if(k < 0 || k > n) return 0;
		ll ret = fac[n];
		(ret *= facInv[k]) %= MOD;
		(ret *= facInv[n - k]) %= MOD;
		return ret;
	}
	ll nHk(ll n, ll k){// nHk = n+k-1 C k = (n+k-1)! / k! * (n-1)!
		if(n == 0 && k == 0) return 1;
		ll ret = fac[n + k - 1];
		(ret *= facInv[k]) %= MOD;
		(ret *= facInv[n - 1]) %= MOD;
		return ret;
	}
	ll nPk(ll n, ll k){//nPk = n! / (n-k)!
		if(k < 0 || k > n) return 0;
		ll ret = fac[n];
		(ret *= facInv[n - k]) %= MOD;
		return ret;
	}
private:
	void inverse(void){
		inv[1] = 1;
		for (int i = 2; i <= MAX_N; ++i){
			// inv[i] = MOD - (MOD / i) * inv[MOD % i] % MOD;
			inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
		}
	}
	void factroial(void){
		fac[0] = facInv[0] = 1;
		for (int i = 1; i <= MAX_N; ++i){
			fac[i] = (fac[i - 1] * i) % MOD;
			facInv[i] = (facInv[i - 1] * inv[i]) % MOD;
		}
	}
};


int main(int argc, char const *argv[])
{
	int x, y; cin >> x >> y;
	MATH ma;
	ll  ans = 0;
	rep(i, x + 1) {
		int nx = i, ny = 2 * i;
		int dx = x - nx, dy = y - ny;
		if (dx == dy * 2) {
			int ci = i, cj = dy;
			ans += ma.nCk(ci + cj, ci);
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main()
{
	int n, m;

	cin >> n >> m;

	while (n > 0 || m > 0) {
		int a[1000], b[1000];

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

		for (int i = 0; i < m; i++) 
			cin >> b[i];

		int j = 0;
		for(int i = 0; i < m; i++){
			j += b[i];
			j += a[j];
			if (j >= n - 1) {
				cout << i + 1 << endl;
				break;
			}
		}

		cin >> n >> m;
	}

	return 0;
}


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


using namespace std;
 
int main(){
   int A,B,C;

   cin >> A >> B >> C;

   if(A == B && B != C){ cout << "Yes";}
   else if(A == C && C != B){ cout << "Yes"; }
   else if(C == B && B != A){ cout << "Yes"; }
   else{ cout << "No"; }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

  for (int i=0; i*4<=n; ++i) {
    for (int j=0; j*7<=n; ++j) {
      if (n == (i*4 + j*7)) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

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

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int cnt[200001];
int main(void){
    int n,i,max=0;
    scanf("%d",&n);
    char s[200001][11];
    for(i=0;i<n;i++) scanf("%s",s[i]);
    qsort(s,n,11,strcmp);
    cnt[0]=1;
    for(i=1;i<n;i++){
        if(strcmp(s[i],s[i-1])==0) cnt[i]=cnt[i-1]+1;
        else{
            cnt[i]=1;
            if(max<cnt[i-1]) max=cnt[i-1];
        }
    }
    if(max<cnt[n-1]) max=cnt[n-1];
    for(i=0;i<n;i++){
        if(cnt[i]==max) printf("%s\n",s[i]);
    }
    return 0;
}

Measured memory_bytes: 4884
#include <iostream>

#include <algorithm>
#include <utility>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

using std::make_pair;
using std::pair;
using std::sort;
using std::vector;

typedef pair<int, int> intpair;

class DisjointSet
{
  vector<int> parent_;
  vector<int> weight_;
  
public:
  int
  root(int a)
  {
    int node = a;
    for (;;)
    {
      int p = parent_[node];
      if (p == node)
      {
        break;
      }
      node = p;
    }
    return node;
  }
  
  int
  weight(int a)
  {
    return weight_[a];
  }
  
  void
  unite(int a, int b)
  {
    int root_a = root(a);
    int root_b = root(b);
    if (root_a != root_b)
    {
      if (weight_[root_a] < weight_[root_b])
      {
        parent_[root_a] = root_b;
        weight_[root_b] += weight_[root_a];
      }
      else
      {
        parent_[root_b] = root_a;
        weight_[root_a] += weight_[root_b];
      }
    }
  }
  
  DisjointSet(int N)
  {
    parent_.resize(N);
    weight_.assign(N, 1);
    for (int i = 0; i < N; i++)
    {
      parent_[i] = i;
    }
  }
};

int
main()
{
  int N, M, K;
  cin >> N >> M >> K;
  vector<intpair> related;
  DisjointSet ds(N);
  for (int m = 0; m < M; m++)
  {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    ds.unite(a, b);
    related.push_back(make_pair(a, b));
    related.push_back(make_pair(b, a));
  }
  for (int k = 0; k < K; k++)
  {
    int c, d;
    cin >> c >> d;
    c--;
    d--;
    related.push_back(make_pair(c, d));
    related.push_back(make_pair(d, c));
  }
  sort(related.begin(), related.end(),
       [](auto const &lhs, auto const &rhs) { return rhs.first < lhs.first; });
  // for (auto it = related.begin(); it != related.end(); it++)
  // {
  //   cout << it->first << ' ' << it->second << endl;
  // }

  for (int n = 0; n < N; n++)
  {
    // 友人集合の要素数 - 自分(1)
    int root = ds.root(n);
    int count = ds.weight(root) - 1;
    while (!related.empty() && related.back().first == n)
    {
      if (ds.root(related.back().second) == root)
      {
        count--;
      }
      related.pop_back();
    }
    if (n != 0)
    {
      cout << ' ';
    }
    cout << count;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 7152
#
# abc06x b
#
import unittest
from io import StringIO
import sys


def input():
    return sys.stdin.readline().rstrip()


def resolve():
    s = input()
    print(s[0]+str(len(s)-2)+s[-1])


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 = """internationalization"""
        output = """i18n"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """smiles"""
        output = """s4s"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """xyz"""
        output = """x1z"""
        self.assertIO(input, output)


if __name__ == "__main__":
    #unittest.main()
    resolve()


Measured memory_bytes: 6376
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#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()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
    int N, result = 1;
    cin >> N;
    vector<string> S(N);
    REP(i, N) {
        cin >> S[i];
    }
    sort(ALL(S));
    REP(i, N-1) {
        if (S[i] != S[i+1]) {
            result++;
        }
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 9576
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

static class Program
{
    static long Solve(int N, int[] C)
    {
        var dp = new long[N];
        var pos = Enumerable.Repeat(-1, 200001).ToArray();
        Func<int, long> DP = i => (i < 0) ? 1 : dp[i];
        for (int i = 0; i < N; ++i)
        {
            int j = pos[C[i]];
            if (0 <= j && j < i - 1)
            {
                dp[i] = (DP(i - 1) + DP(j)) % 1000000007;
            }
            else
            {
                dp[i] = DP(i - 1);
            }
            pos[C[i]] = i;
        }
        return dp[N - 1];
    }

    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        var C = new int[N];
        for (int i = 0; i < N; ++i)
        {
            C[i] = int.Parse(Console.ReadLine());
        }
        Console.WriteLine(Solve(N, C));
    }
}


Measured memory_bytes: 20060
#include <bits/stdc++.h>
using namespace std;
 
#define trace(...) __f( #__VA_ARGS__ , __VA_ARGS__ )
template <typename Arg1>
void __f( const char* name , Arg1&& arg1 ) {
        cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f( const char* na , Arg1&& arg1 , Args&&... args ) {
        const char* c = strchr( na + 1 , ',' );
        cerr.write( na , c - na ) << " : " << arg1 << " , ";
        __f( c + 1 , args... );
}
#define endl "\n"
#define all(V) V.begin(),V.end()
#define Unique(V) sort(all(V)),V.erase(unique(all(V)),V.end())
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long int LL;
typedef pair <int,int> pii;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const long long INF = 1e18;
const int N = 1e5 + 5;
 
int main( ) {
        IO;
        #ifdef LOCAL
            //freopen( "input.txt" , "r" , stdin );
        #endif // LOCAL
        LL a , b;
        cin >> a >> b;
        LL m = ( a + b ) >> 1;
        if( abs( a - m ) == abs( b - m ) ) cout << m << endl;
        else cout << "IMPOSSIBLE" << endl;
        return 0;
}




Measured memory_bytes: 256
#include<stdio.h>

int maxf(int a[], int n);

int main (void)
{
        int n, i, p[100], max, pay;
        scanf("%d",&n);
        pay = 0;
        for(i=0;i<n;i++){
                scanf("%d",&p[i]);
        }
        max = maxf(p, n);
        for(i=0;i<n;i++){
                pay = pay + p[i];
        }
        pay = pay - max/2;
        printf("%d\n",pay);
        return 0;
}

int maxf(int a[], int n)
{
        int b, i;
        b=0;
        for(i=0; i<n; i++){
                if(b<a[i])
                b=a[i];
        }
        return b;
}

Measured memory_bytes: 128
fun main(args: Array<String>) {
    val (N, M) = listOfInt()
    var K = Array(N + 1) { true }
    repeat(M) { K[nextInt()] = false }
    var dp = Array(N + 1) { 0 }
    dp[0] = 1
    val MOD = 1000000007
    for (n in 0 until N - 1) {
        for (s in 1..2)
            if (K[n + s]) dp[n + s] = (dp[n + s] + dp[n]) % MOD
    }
    dp[N] = (dp[N] + dp[N - 1]) % MOD
    println(dp[N])
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)

Measured memory_bytes: 39492
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int year(int n){
    int res = 0;
    n++;
    for(; n<1000; n++){
        if(n%3 != 0) res++; 
    }
    return res;
}
int month(int y, int m){
    int res = 0;
    if(y%3 == 0) return 0;
    for(; m<=10 ;m++)
        if(m%2 == 0) res++;
    return res;
}

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

    int y, m, d;
    int res = 0;
    for(int i=0; i<N; i++){
        cin >> y >> m >> d;
        res = ((999-y)*20*10 + (10-m)*20 + (20-d));
        res -= year(y)*5 + month(y, m)  ; 
        res++;
        cout << res << endl;
    }
}

Measured memory_bytes: 2980
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<array>
#include<vector>
#include<functional>
#include<unordered_map>
#include<map>
#include<numeric>
#include<limits>
#include<utility>
#include<queue>
#include<random>
using namespace std;

int main(){
 
    string s;
   int N[3];
    
    cin >> s ;
    for(int i = 0;i<=2;i++){
    N[i] = s[i];
    }    
    if(N[0] == N[2]){
    cout << "Yes" << endl;}
    else {cout << "No" << endl;}
    
    return 0;

}

Measured memory_bytes: 384
# B - Trick or Treat
N,K = map(int,input().split())
lis = [1]+[0]*N
for _ in range(K):
    d = int(input())
    A = map(int,input().split())
    for x in A:
        lis[x] += 1
print(len([x for x in lis if x==0]))

Measured memory_bytes: 9112
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   int N, A, B, C, D;
   cin >> N >> A >> B >> C >> D;
   string S;
   cin >> S;
   A--;
   B--;
   C--;
   D--;
   for (int i = 0; i < N; i++) {
      if (A > i || i > max(C, D)) continue;
      if (S[i] == '#') {
         if (i + 1 <= max(C, D) && S[i + 1] == '#') {
            cout << "No" << endl;
            return 0;
         }
      }
   }
   if (C < D) {
      cout << "Yes" << endl;
      return 0;
   }

   for (int i = 0; i < N; i++) {
      if (i < A || D < i) continue;
      if (S[i] == '.' && B - 1 <= i && i + 2 <= D + 1 && S[i + 1] == '.' && S[i + 2] == '.') {
         cout << "Yes" << endl;
         return 0;
      }
   }
   cout << "No" << endl;
   return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <iterator>
#include <vector>
#include <algorithm>

using namespace std;

static void print(const vector<int> &nums) {
  for (auto itr = nums.begin(); itr != nums.end(); itr++) {
    if (itr != nums.begin()) {
      cout << " ";
    }
    cout << *itr;
  }

  cout << endl;
}

static void insertion_sort(vector<int> &nums) {
  print(nums);

  for (size_t i = 1; i < nums.size(); i++) {
    int key = nums[i];
    size_t j = i;
    while (j > 0 && nums[j - 1] > key) {
      nums[j] = nums[j - 1];
      j--;
    }
    nums[j] = key;

    print(nums);
  }
}

int main(int argc, char *argv[]) {
  // Read input
  istream_iterator<int> eos;
  istream_iterator<int> iit(cin);

  vector<int> nums;
  if (iit != eos) {
    iit++;  // skip first line
  }

  for (; iit != eos; iit++) {
    nums.push_back(*iit);
  }

  insertion_sort(nums);

  return 0;
}

Measured memory_bytes: 3160
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class AtCoderC
{
    static void Main()
    {
        long n = long.Parse(Console.ReadLine());

        long min = long.MaxValue;
        for (long i = 1; i * i <= n; i++)
        {
            if (n % i == 0)
            {
                min = Math.Min(min, i + (n / i) - 2);
            }
        }

        Console.WriteLine(min);
    }
}

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

#define forO( a_i, n ) for( a_i=1; a_i<=n; a_i++ )
#define resize( a, b ) resize( a, vector < int > ( b, 0 ) )

vector < vector < int > > vD, vC;

int main(){
    int a_i, b_i, n, temp, c, r, c_i, d_i, mini = INT_MAX;

    cin>>n>>c;

    vD.resize( c+1, c+1 ); vC.resize( 3, c+1 );


    forO( a_i, c ) forO( b_i, c ) cin>>vD[a_i][b_i];

    forO( a_i, n ) forO( b_i, n ){
        cin>>temp;

        r = ( a_i+b_i )%3;

        vC[r][temp]++;

    }

    temp = 0;

    forO( a_i, c ){
        forO( b_i, c ){
            forO( c_i, c ){
                if(a_i!=b_i && b_i!=c_i && c_i!=a_i ){

                    temp = 0;

                    forO( d_i, c ){
                        temp += ( vD[ d_i ][ a_i ]*vC[0][d_i] );
                        temp += ( vD[ d_i ][ b_i ]*vC[1][d_i] );
                        temp += ( vD[ d_i ][ c_i ]*vC[2][d_i] );
                    }

                    mini = min( temp, mini );

                }
            }
        }
    }

    cout<<mini<<endl;

}


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

int main(){
  int a,b; cin>>a>>b;
  int ans=0;
  for(int i=0;i<2;i++){
    if(a>b){ ans+=a; a--; }
    else { ans+=b; b--; }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
arr = list(map(int, input().split()))

arr.sort()
length = len(arr)

ans = 0
for x in range(length):
    for y in range(x + 1, length):
        for z in range(y + 1, length):
            if arr[x] != arr[y] and arr[y] != arr[z] and arr[z] != arr[x]:
                if arr[x] + arr[y] > arr[z]:
                    ans += 1

print(ans)

Measured memory_bytes: 9196
import collections

N = int(input())
A = list(map(int, input().split()))

L = [i + A[i] for i in range(N)]
R = [i - A[i] for i in range(N)]

countL = collections.Counter(L)
countR = collections.Counter(R)

print(sum([countL[n] * countR[n] for n in countL.keys()]))

Measured memory_bytes: 63352
import { readFileSync } from 'fs'

function main(input: string[]) {
  let [K, N] = input[0].split(' ').map(v=>parseInt(v, 10))
  let A : number[] = input[1].split(' ').map(v=>parseInt(v, 10))

  let ans = 1000000000
  A = A.sort((a, b) => a - b)
  for (let i = 0; i < A.length - 1; i++) {
    let ansOne = K - Math.abs(A[i + 1] - A[i])
    ans = Math.min(ans, ansOne)
  }
  let ansOne = K - (A[0] + K - A[N - 1])
  ans = Math.min(ans, ansOne)

  console.log(ans.toString())
}

let lines: string[] = [];
const reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', function (line: string) {
  lines.push(line);
});
reader.on('close', function () {
  main(lines)
});


Measured memory_bytes: 46956
sx, sy, tx, ty = list(map(int, input().split()))


PATH = ""
# 1st round
for i in range(tx-sx):
    PATH += "R"
for i in range(ty - sy):
    PATH += "U"
for i in range(tx - sx):
    PATH += "L"
for i in range(ty - sy):
    PATH += "D"

# 2nd round
PATH += "D"
for i in range(tx+1-sx):
    PATH += "R"
for i in range(ty - sy + 1):
    PATH += "U"

PATH += "L"
PATH += "U"
for i in range(tx - sx+1):
    PATH += "L"
for i in range(ty - sy+1):
    PATH += "D"
PATH += "R"
print(PATH)


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
int main()
{
	int n, fr = 0, total = 0;
	vector<int> co(8, 0);
	scanf("%d", &n);
	for(int i = 0, j; i < n; ++i)
	{
		scanf("%d", &j);
		if(j < 3200)
		{
			j /= 400;
			co[j] = 1;
		}
		else
		{
			++fr;
		}
	}
	total = accumulate(co.begin(), co.end(), 0);
	printf("%d %d\n", max(1, total), min(n, total + fr));
}


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    if (k <= a)
        cout << k << endl;
    else if (a + b >= k) {
        cout << a << endl;
    } else {
        k -= (a + b);
        cout << a - k << endl;
    }
}


Measured memory_bytes: 3652
from collections import defaultdict

MOD = 10 ** 9 + 7

N = int(input())
c = [int(input()) for _ in range(N)]

dp = [0 for _ in range(N + 1)]
dp[0] = 1

d = defaultdict(lambda: -1)

for i, cc in enumerate(c, 1):
    dp[i] = dp[i - 1]
    if 0 <= d[cc] < i - 1:
        dp[i] += dp[d[cc]]
    dp[i] %= MOD
    d[cc] = i
    # print(d)
    # print(dp)
print(dp[N])

Measured memory_bytes: 36876
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
	    long B = sc.nextLong();
	    long C = sc.nextLong();
	    long D = sc.nextLong();
	    long CD = LCM(C,D);
	    
	    long count = 0;
	 
	    	long a_max = B/C;
	    	long a_min = A/C;
	    	long a_c=0;
	    	
	    	if (a_min==0) {
	    		a_c=a_max;
	    	}
	    	
	    	
	    	else if (A%C==0) {
	    		a_c=a_max-a_min+1;
	    	}
	    	
	    	else {
	    		a_c=a_max-a_min;
	    	}
	    		
	    	
	    	long b_max = B/D;
	    	long b_min = A/D;
	    	long b_c=0;
	    	
	    	if (b_min==0) {
	    		b_c=b_max;
	    	}
	    	
	    	
	    	else if (A%D==0) {
	    		b_c=b_max-b_min+1;
	    	}
	    	
	    	else {
	    		b_c=b_max-b_min;
	    	}
	    	
	    	long c_max = B/CD;
	    	long c_min = A/CD;
	    	long c_c=0;
	    	
	    	if (c_min==0) {
	    		c_c=c_max;
	    	}
	    	
	    	
	    	else if (A%CD==0) {
	    		c_c=c_max-c_min+1;
	    	}
	    	
	    	else {
	    		c_c=c_max-c_min;
	    	}
	    	
	    	count = a_c+b_c-c_c;
	    	
	    
	    System.out.println(B-A-count+1);
	}
	static public long GCF(long a, long b) {
	    if (b == 0) return a;
	    else return (GCF (b, a % b));
	}
	public static long LCM(long a, long b) { 
		return (a * b) / GCF(a, b); 
		}

	
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 1e9+7;
#define ll long long

signed main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int,int>> a(m);
  rep(i,m) {
    int x,y;
    cin >> x >> y;
    a[i]={x,y};
  }
  sort(a.begin(),a.end());
  
  int s = a[0].first;
  int e = a[0].second;
  int ans = 1;
  FOR(i,1,m) {
    if(e<=a[i].first) {
      ans++;
      s = a[i].first;
      e = a[i].second;
    }
    e = min(e, a[i].second);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4824
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define l long
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define pii pair<int,int>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;
ll a[100005] , siz[100005],n;
void init()
{
	for(ll i=1;i<=n;i++)
    {
    	a[i] = i;
    	siz[i] = 1;
    }
}
ll root(ll i)
{
	while(i!=a[i])
	{
		a[i] = a[a[i]];
		i = a[i];
	}
	return i;
}
void uni(ll n,ll m)
{
	if(siz[m]>siz[n])
	{
		a[n] = a[m];
		siz[m] += siz[n];
	}
	else
	{
		a[m] = a[n];
		siz[n] += siz[m];
	}
}
signed main()
{
    fast;
    
    ll m,k,i;
    cin>>n>>m>>k;
    init();
    ll deg[n+2] = {0};
    for(i=0;i<m;i++)
    {
    	ll x,y;
    	cin>>x>>y;
    	ll a = root(x);
    	ll b = root(y);
    	deg[x]++;
    	deg[y]++;
    	if(a!=b) uni(a,b);
    }
    for(i=0;i<k;i++)
    {
    	ll x,y;
    	cin>>x>>y;
    	ll a = root(x);
    	ll b = root(y);
    	if(a!=b) continue;
    	else
    	{
    		deg[x]++;
    	    deg[y]++;
    	}
    }
    for(i=1;i<=n;i++)
    {
    	ll ro = root(i);
    	ll candidates = siz[ro] - deg[i] - 1;
    	cout<<candidates<<" ";
    }

}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>   
using namespace std;
using namespace __gnu_pbds;
typedef long long ll; 
#define int long long
typedef unsigned long long lu;
typedef vector<ll> v;
typedef vector<vector<ll> > vv;
typedef vector<string>  vs;
typedef vector<pair<ll,ll>> vpr;
typedef long double ld;
#define f(i,n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define amax(x,y) if(y>x) x=y;
#define amin(x,y) if(y<x)x=y;
#define bg(x) x.begin()
#define sz(x) (ll)x.size()
#define in(x,n) for(ll i=0;i<n;i++)cin>>x[i]
#define out(x,n) for(ll i=0;i<n;i++)cout<<x[i]<<" " 
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a) *(min_element(a.begin(),a.end())
#define tc ll t;cin>>t;while(t--)
typedef pair<ll,ll> pi;
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define yesno(f) if(f) yes else no
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
const ll mod=1e9+7;
const ld PI = 2 * acos(0.0);
ll m(ll a){ return (a+mod)%mod;}
ll cel(ll x1,ll y1){if((x1%y1)==0)return x1/y1;else return x1/y1+1;}
ll power(ll a,ll b,ll m)
{
	if(b==0)
		return 1;
	ll d=power(a,b/2,m);
	d=(d*d)%m;
	if(b&1)
		d=(d*a)%m;
	return d;
}
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */

int solve(){}
int dp[2000][2000],p[2000][2000],fact[2000],ncr[2000][2000];
int32_t main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    // int tt=1;
    //tc{

    //	cout<<"Case #"<<tt++<<": "<<solve()<<endl;
    //}

	int n,a,b,c,d;cin>>n>>a>>b>>c>>d;
	fact[0]=1;
	for(int i=1;i<=n;i++)
		fact[i]=(fact[i-1]*i)%mod;

	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=n;j+=i)
		{
			int denom=(power(fact[i],j/i,mod)*fact[j/i])%mod;
			denom=power(denom,mod-2,mod);
			p[i][j]=(fact[j]*denom)%mod;

		}
	}
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=i;j++)
		{
			int denom=power((fact[j]*fact[i-j])%mod,mod-2,mod);
			ncr[i][j]=(fact[i]*denom)%mod;
		}
	}
	// return 0;

	// p[b][0]=1;
	dp[b+1][0]=1;
	for(int i=b;i>=a;i--)
	{
		for(int j=0;j<=n;j++)
		{
			for(int x=0;x<=j;x+=i)
			{
				int nn=x/i;
				if((nn <=d && nn >=c)  || nn==0){
					int ans=(p[i][x]*dp[i+1][j-x])%mod;
					ans*=ncr[j][x];
					if(ans  > mod)
						ans%=mod;
					dp[i][j]+=ans;
					if(dp[i][j] > mod)
						dp[i][j]%=mod;
				}
			}
		}
	}
	cout<<dp[a][n]<<endl;
	return 0;
}

Measured memory_bytes: 50048
import java.util.*;
 
public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = (int)1e9 + 7;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	int len = (int)1e7;
	
	
	void doIt() {
		int N = sc.nextInt();
		int M = sc.nextInt();
		int K = sc.nextInt();
		long A[] = new long[N + 1];
		long B[] = new long[M + 1];
		for(int i = 1; i <= N; i++) {
			A[i] = sc.nextLong();
			A[i] += A[i - 1];
		}
		for(int i = 1; i <= M; i++) {
			B[i] = sc.nextLong();
			B[i] += B[i - 1];
		}
		int max = 0;
		for(int i = 0; i <= N; i++) {
			long cur = K - A[i];
			if(cur < 0) continue;
			int l = 0, r = M, m = (l + r + 1) / 2;
			while(cur < B[r]) {
				if(cur < B[m]) {
					r = m - 1;
					m = (l + r + 1) / 2;
				}
				else {
					l = m;
					m = (l + r + 1) / 2;
				}
			}
			max = Math.max(max, i + r);
		}
		System.out.println(max);
	}
	
	public static void main(String[] args) {
		new Main().doIt();
	}
 
}

Measured memory_bytes: 63196
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

ll S;

void solve(){
    cin >> S;
    ll root_S = sqrt(S);
    if (root_S*root_S!=S) root_S+=1;
    //cout << root_S << endl;
    cout << 0 << " " << 0 << " " << root_S << " " << 1 << " " << root_S*root_S-S <<  " "  << root_S << endl; 
}

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

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

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

    int ans = 0;
    for(int i=1;i<(n-1);i++){
        if(p[i] > p[i-1] && p[i] < p[i+1]) ans++;
        else if(p[i] < p[i-1] && p[i] > p[i+1]) ans++;
    }

    cout << ans << endl;
}

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

int main()
{
    int n, q;
    string s;
    cin >> n >> q >> s;
    vector<pair<int, int>> qCnt(q);
    rep (i, q)
        cin >> qCnt[i].first >> qCnt[i].second;

    vector<int> acCnt(n, 0);
    for (int i = 1; i < n; i++)
    {
        if (s[i - 1] == 'A' && s[i] == 'C')
            acCnt[i]++;
        acCnt[i] += acCnt[i - 1];
    }
    
    rep (i, q)
        cout << acCnt[qCnt[i].second - 1] - acCnt[qCnt[i].first - 1] << endl;

    return 0;
}

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

int main() {
    int N;
    double T, A;
    cin >> N >> T >> A;
    vector<double> H(N);
    rep(i, N) cin >> H[i];

    int mi = 0;
    for(int i=1; i<N; i++) {
        double t1, t2;
        t1 = T - H[mi] * 0.006;
        t2 = T - H[i] * 0.006;
        if(abs(A-t2) < abs(t1-A)) mi = i;        
    }

    cout << mi+1 << endl;
    return 0;
}

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

int main() {
    int S = 0;;
    int W = 0;

    cin >> S >> W;

    //vector<int> vec(N);

    if(S <= W){
        cout << "unsafe" << endl;
    }else{
        cout << "safe" << endl;
    }


}


Measured memory_bytes: 3624
#include <iostream>

using namespace std;

int main() {
    const int z = 100001;
    int x, k, r[z], s[z], o[z], w[z], q, i;
    cin >> x;
    cin >> k;
    int v = -1;
    r[0] = w[0] = o[0] = 0;
    s[0] = x;
    for (i = 1; i <= k; i++, v *= -1) {
        cin >> r[i];
        int d = (r[i] - r[i-1]) * v;
        w[i] = min(max(w[i-1] + d, 0), x);
        s[i] = max(min(s[i-1] + d, x), 0);
        o[i] = min(o[i-1] - min(0, w[i-1] + d), x);
    }
    cin >> q;
    i = 0;
    while(q--) {
        int t, a;
        cin >> t >> a;
        if (t >= r[k]) i = k;
        else {
            int n = k;
            while (i < n - 1) {
                int c = i + (n - i) / 2;
                if (r[c] < t) i = c;
                else n = c;
            }
        }
        int ans = min(w[i] + max(a - o[i], 0), s[i]) + (t - r[i]) * ((i % 2) * 2 - 1);
        cout << min(max(ans, 0), x) << endl;
    }
}


Measured memory_bytes: 2816
#pragma GCC optimize("Ofast")
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<math.h>
#include<utility>
using namespace std;
 

int main(){
    
    int n;
    cin >> n;
    int sum = 0;
    vector<int> x(n);

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

    int pos;
    int res  = 0;
    if(sum % n == 0) {
        pos = sum / n;
        for(int i=0;i<n;i++){
            res += (x[i]-pos)*(x[i]-pos);
        }
        cout << res << endl;
    }
    else {
        pos = sum / n;
        int tmp = 0;
        for(int i=0;i<n;i++){
            tmp += (x[i]-pos)*(x[i]-pos);
        }
        pos++;
        int tmp1 = 0;
        for(int i=0;i<n;i++){
            tmp1 += (x[i]-pos)*(x[i]-pos);
        }
        if(tmp >= tmp1) cout << tmp1 << endl;
        else cout << tmp << endl;
    } 
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<string>
using namespace std;
string s[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
int main()
{
	string a;
	cin>>a;
	int b;
	for(int i=0;i<7;i++){
		if(s[i]==a) b=i;
	}
	if(!b) b=7;
	int ans=7-b;
	if(ans) cout<<ans;
	else cout<<7;
	cout<<"\n"; 
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define endl '\n'
#define all(x) (x).begin(),(x).end()
const int INF=500+5;
const int N=3000+5;
const ll oo=1e18+5;
const ll mod=998244353;

ll mul(ll a,ll b){
	return a*b%mod;
}

ll poww(ll a,ll b){
	ll r=1;
	while(b){
		if(b&1) r=mul(r,a);
		a=mul(a,a);
		b>>=1;
	}
	return r;
}

void add_self(ll& a,ll b){
	a+=b;
	if(a>=mod) a-=mod;
}

int n,s;
ll dp[N];

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n>>s;
	vector<ll> a(n);
	for(ll& x:a) cin>>x;
	dp[0]=1;
	ll inv2=poww(2,mod-2);
	for(int i=0;i<n;++i) dp[0]=mul(dp[0],2);
	for(int i=0;i<n;++i){
		for(int sum=s;sum>=a[i];--sum){
			add_self(dp[sum],mul(dp[sum-a[i]],inv2));
		}
	}
	cout<<dp[s];
	return 0;
}


Measured memory_bytes: 3704
import std.stdio;
import std.string;
import std.conv;

void main() {
  uint[string] table;
  while(true) {
    string line = readln.chomp;
    if (stdin.eof) break;
    auto data = line.split(",");
    table[data[1]] += 1;
  }
  foreach(type; ["A", "B", "AB", "O"]) {
    if (type in table)
      writeln(table[type]);
    else
      writeln(0);
  }
}

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

int main() {
  vector<vector<int>> a(3, vector<int>(3));
  rep(i,3) rep(j, 3) {
    cin >> a[i][j];
  }
  
  vector<int> tate(3, 0);
  vector<int> yoko(3, 0);
  vector<int> naname(2, 0);
  
  int n;
  cin >> n;
  rep(i,n) {
    int x;
    cin >> x;
    rep(i,3) rep(j,3) {
      if (x == a[i][j]) {
        tate[i] += 1;
        yoko[j] += 1;
        if (i == j) naname[0] += 1;
        if (i + j == 2) naname[1] += 1;
    	break;
      }
    }
  }
  
  string ans = "No";
  rep(i,3) {
    if (tate[i] == 3 || yoko[i] == 3) {
      ans = "Yes";
      break;
    } else if (i <= 1 && naname[i] == 3) {
      ans = "Yes";
      break;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256