akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define op_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define fo(i,a,b) for(int i=a; i <b; i++)
#define foi(i,a,b) for(int i=a; i >=b; i--)
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef map<int,int> mpii;
typedef map<ll,ll> mpll;
typedef map<int,ll> mpil;
typedef map<ll,int> mpli;

const ll modn = 998244353LL;
const ll maxn = 2e5+10LL;

vector<ll> fact(maxn, 0LL);
vector<ll> inv(maxn, 0LL);

ll mpow(ll a, ll b, ll modval){
  ll res = 1LL;
  while(b){
    if((b%2) == 1){
      res = (res*a)%modval;
    }
    a = (a*a)%modval;
    b = b / 2;
  }
  return (res%modval);
}

void init(void){
  fact[0] = 1LL;
  fo(i,1,maxn){
    fact[i] = (((ll)(i))*fact[i-1])%modn;
  }
  inv[0] = 1LL;
  fo(i,1,maxn){
    inv[i] = mpow(fact[i], modn-2, modn)%modn;
  }
}

ll nck(ll n, ll k){
  ll res = (fact[n]*inv[k])%modn;
  res = (res*inv[n-k])%modn;
  return res%modn;
}


int main(){
  op_io;
  init();
  ll n,m,k;
  cin>>n>>m>>k;
  ll ans = 0;
  fo(i,n-k,n+1){
    ll ret = nck(n-1, i-1);
    ret = (ret*m)%modn;
    ret = (ret*mpow(m-1,i-1,modn))%modn;
    ans = (ans + ret)%modn;
  }
  cout<<(ans%modn)<<endl;
  return 0;
}


Measured memory_bytes: 6320
from fractions import gcd

from functools import reduce


n = int(input())
a_list = [int(x) for x in input().split()]

temp = 1
for a in a_list:
    temp *= a // gcd(a, temp)

mod = 10 ** 9 + 7
ans = sum([temp // a for a in a_list]) % mod
print(ans)

Measured memory_bytes: 264572
#include <map>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#define LL long long
using namespace std;
const int MAXN = 2e5+55;
int vis[MAXN];
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    vis[a]++;
    vis[b]++;
    vis[c]++;
    if(vis[5]==2&&vis[7]==1) cout<<"YES";
    else cout<<"NO";
    return 0;
}




Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

using namespace std;


using int64 = long long;
const int mod = (1e9 + 7);

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

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

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
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< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}


int main() {
  int N, K;
  cin >> N >> K;
  vector< int > P(N), C(N);
  cin >> P >> C;
  for(auto &p : P) --p;
  int64 ret = -infll;
  for(int i = 0; i < N; i++) {
    int circle = P[i];
    vector< int > nxt;
    while(circle != i) {
      nxt.emplace_back(C[circle]);
      circle = P[circle];
    }
    nxt.emplace_back(C[circle]);
    int64 add = 0;
    int64 all = max(0LL, accumulate(begin(nxt), end(nxt), 0LL));
    for(int j = 0; j < nxt.size(); j++) {
      add += nxt[j];
      int rest = K - (j + 1);
      if(rest < 0) break;
      chmax(ret, rest / (int) nxt.size() * all + add);
    }
  }
  cout << ret << "\n";
}



Measured memory_bytes: 3620
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll r,l;
    cin >> l >> r;
    if(abs(l-r)>=2019){
        cout << 0 << endl;
        return 0;
    }
    ll ans=INF;
    FOR(i,l,r){
        FOR(j,i+1,r+1){
            chmin(ans,i*j%2019);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3640
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(i64 ngtkana_is_a_genius=0; ngtkana_is_a_genius<(i64)k; ngtkana_is_a_genius++)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T, class U> using pair = std::pair<U, T>;
template <class T> using diag_pair = std::pair<T, T>;
template <class... Args> using tuple = std::tuple<Args...>;
template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/
auto cmx = [](auto& x, auto y){ if (x<y) { x=y; return true; } return false; };
int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    std::string march = "MARCH";

    usize n;
    std::cin >> n;
    vec<u64> a(5);
    while (n--) {
        std::string s;
        std::cin >> s;
        auto it = std::find(ALL(march), s.front());
        if (it==march.end()) continue;
        a.at(it-march.begin())++;
    }

    i64 ans = 0;
    for (u32 bs=0; bs<(u32)1<<5; bs++) if (__builtin_popcount(bs)==3) {
        i64 now = 1;
        for (usize i=0; i<5; i++) if (bs>>i&u32{1}) {
            now *= a.at(i);
        }
        ans += now;
    }
    std::cout << ans << '\n';
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n; cin>>n;
    string s; cin>>s;
    int sz = s.size();

    vector<int> v(sz);
    vector<char> ans(sz);
    for(int i=0; i<sz; i++){
        v[i] = s[i] - 'A';
        ans[i] = ((v[i] + n) % 26) + 'A';
    }

    for(int i=0; i<sz; i++){
        cout << ans[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;	

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define test() ll t;cin>>t;for(ll test = 1;test<=t;test++)
#define f first
#define s second
#define pb push_back
#define nl cout<<"\n"
#define MOD(x) ((x%P)+P)%P
#define vec(v) loop(i,0,v.size()) cout<<v[i]<<" "; nl
const int N = 100005;
const ll P = 1000000007;
const double eps = 1e-6;

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

vector<int> gr[N];

ll dp[N][2]; // black, white

void dfs(int node, int parent)
{
	for(int i: gr[node])
	{
		if(i!=parent)
			dfs(i,node);
	}
	ll white = 1, black = 1;
	for(int i:gr[node])
	{
		if(i!=parent)
		{
			white = MOD(white*(dp[i][0]+dp[i][1]));
			black = MOD(black*dp[i][0]);
		}
	}
	dp[node][0] = white;
	dp[node][1] = black;
}


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

	for(int i=1; i<n; i++)
	{
		int u,v; cin>>u>>v;
		gr[u].pb(v);
		gr[v].pb(u);
	}
	
	dfs(1, -1);

	cout<<MOD(dp[1][0]+dp[1][1]),nl;

	//cerr << "\nTime elapsed : " << 1000 * clock() / CLOCKS_PER_SEC << " ms\n";
	return 0;
}

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


int main()
{
char b;
cin >> b;

if(b == 'A') cout << 'T' << endl;
if(b == 'T') cout << 'A' << endl;
if(b == 'C') cout << 'G' << endl;
if(b == 'G') cout << 'C' << endl;



return 0;
}

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

int main() {
  int n,t,a;
  cin >> n >> t >> a;
  vector<int> H(n);
  for(int i = 0;i < n;i++){
    cin >> H.at(i);
  }
  int ans = 1;
  double min = 0;
  double ave = 0;
  for(int i = 0;i < H.size();i++){
    min = a - (t - (H.at(i)*0.006));
    if(i == 0){
      ave = abs(min);
    }else if(ave > abs(min)){
      ave = abs(min);
      ans = i+1;
    }
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int p[510];
int q[510];
int r[510];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a-1;i++){
		scanf("%d%d%d",p+i,q+i,r+i);
	}
	for(int i=0;i<a;i++){
		int now=0;
		for(int j=i;j<a-1;j++){
			int nx=now/r[j]*r[j];
			if(now%r[j])nx+=r[j];
			nx=max(nx,q[j]);
			now=nx+p[j];
		}
		printf("%d\n",now);
	}
}

Measured memory_bytes: 128
n, m = gets.split.map(&:to_i)
prefectures = Array.new(n) {[]}
m.times do |i|
  p, y = gets.split.map(&:to_i)
  prefectures[p - 1] << [y, i]
end

puts prefectures.flat_map.with_index(1) {|v, p|
  v.sort.map.with_index(1) {|(y, i), j| [i, sprintf("%06d%06d", p, j)]}
}.sort.map(&:last)

Measured memory_bytes: 35308
#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define maxn 500010
#define mod 1000003
ll po(ll x){
    ll bas=1,y=mod-2;
    while(y){
        if(y%2) bas=bas*x%mod;
        x=x*x%mod;
        y/=2;
    }
    return bas;
}
ll poo(ll x,ll y){
    ll bas=1;
    while(y){
        if(y%2) bas=bas*x%mod;
        x=x*x%mod;
        y/=2;
    }
    return bas;
}
ll ans[2000000];
int main(){
    int t;
    scanf("%d",&t);
    ans[0]=1;
    for(int i=1;i<=mod;i++){
        ans[i]=ans[i-1]*i%mod;
    }
    //cout<<po(ans[0]);
    while(t--){
        ll x,d,n;
        scanf("%lld%lld%lld",&x,&d,&n);
        if(d==0){
            printf("%lld\n",poo(x,n));
            continue;
        }
        ll y=x*po(d)%mod;
        //printf("%lld___\n",y);
        if(y+n-1>=mod||y==0){
            printf("0\n");
            continue;
        }
        d=poo(d,n);
        d*=ans[y+n-1];
        d%=mod;
        d*=po(ans[y-1]);
        d%=mod;
        printf("%lld\n",d);
    }
    return 0;
}

Measured memory_bytes: 9088
#include <stdio.h>

int main()
{
  int x,y,z,n;

  scanf("%d %d",&x,&y);
  if( x < y ){
    n = x;
    x = y;
    y = n;
  }

  z = x % y;
  while( z != 0){
    x = y;
    y = z;
    z = x % y;
  }

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

Measured memory_bytes: 592
import bisect
MOD = 10**9+7
N,K = map(int,input().split())
A = list(map(int,input().split()))
# N,K = 2000,10*9
# A = [1 for i in range(2000)]
SA = sorted(map(lambda x:-x, A))
befores = []
r_be = []
r_all = []
for i,a in enumerate(A):
  rbb = bisect.bisect_left(befores,-a)
  r_be.append(rbb)
  raa = bisect.bisect_left(SA,-a)
  r_all.append(raa)
  befores.insert(rbb,-a)
  # print(a,rbb,raa,befores)

sm_be = sum(r_be)
sm_al = sum(r_all)

r = ((sm_be*K)%MOD + ((((K*(K-1))//2)%MOD)*sm_al)%MOD)%MOD
print(r)
# print()
# print(A)
# print(r_be)
# print(r_all)


Measured memory_bytes: 41712
#include <bits/stdc++.h>
 
#define vi vector<int>
#define tests int t; cin>>t; while(t--)
#define ll long long
#define vll vector<long long>
#define srt(v) sort(v.begin(), v.end())
#define srtg(v) sort(v.begin(), v.end(), greater<int> ())
#define FOR(k, n) for(int k=0; k<n; k++)
#define pb push_back
 
 
using namespace std;

 

 
char nums[10] = { '0','1','2','3','4','5','6','7','8','9' };
char alphsl[26] = { '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' };
const ll MOD = 998244353;
char alphs[26] = { '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' };





void solve() {
    
  int a, b;
  cin>>a>>b;
  cout<<a*b<<endl;
   
}
   
   

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

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

using namespace std;

int main ()
{
    long long n, i, ans = 100;
    int cnt = 0;

    scanf("%lld", &n);
    for (i = 100; i < n; cnt++) {
        ans /= 100;
        i += ans;
        ans = i;
        //cout << i << " ";
    }
    printf("%d\n", cnt);

    return 0;
}


Measured memory_bytes: 3816
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <string>

using namespace std;

int main() {
    string s;
    cin >> s;
    int ans;

    if      (s=="SUN")ans=7;
    else if (s=="MON")ans=6;
    else if (s=="TUE")ans=5;
    else if (s=="WED")ans=4;
    else if (s=="THU")ans=3;
    else if (s=="FRI")ans=2;
    else if (s=="SAT")ans=1;


    cout << ans << endl;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
 
int main(void) {
 
    int N,K;
    cin >> N >> K;

    int ans = 0;
    int tmp = 1;

    while (tmp <= N)
    {
        tmp = tmp * K;
        ans++;
    }


    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,b;
    float a,c=0;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        {
            cin>>b;
            if(b>=k)
            c++;
        }
    cout<<c;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <iostream>
#include <cmath>
#define INF 1LL<<5
using namespace std;
struct P{
	int x,y;
	P(){}
	P(int xx,int yy){
		x=xx;
		y=yy;
	}
	P operator +(P p){
		return P(x+p.x,y+p.y);
	}
	P operator -(P p){
		return P(x-p.x,y-p.y);
	}
	P operator *(int d){
		return P(x*d,y*d);
	}
	bool operator ==(const P &p)const{
		return (x==p.x && y==p.y);
	}
};

typedef P Vector;
typedef vector<P> Polygon;
int norm(P p){
	return p.x*p.x+p.y*p.y;
}

int dot(P a,P b){
	return a.x*b.x+a.y*b.y;
}

int cross(P a,P b){
	return a.x*b.y-a.y*b.x;
}

int ccw(P p0,P p1,P p2){
	Vector a=p1-p0;
	Vector b=p2-p0;
	if(cross(a,b)>0)return 1;
	if(cross(a,b)<0)return -1;
	if(dot(a,b)<0)return 2;
	if(norm(a)<norm(b))return -2;
	return 0;
}

bool intersect(P p1,P p2,P p3,P p4){
	if(ccw(p1,p2,p3)*ccw(p1,p2,p4)>0 || ccw(p3,p4,p1)*ccw(p3,p4,p2)>0)return false;
	if(ccw(p1,p2,p3)*ccw(p1,p2,p4)<0 && ccw(p3,p4,p1)*ccw(p3,p4,p2)<0)return true;
	if(ccw(p1,p2,p4)==0 && ccw(p1,p2,p3)==0)return true;
	if(ccw(p3,p4,p1)==0 && ccw(p3,p4,p2)==0)return true;
	if(ccw(p1,p2,p3)==0 && !(p1==p3) && !(p2==p3) && abs(ccw(p1,p2,p4))!=1)return true;
	if(ccw(p1,p2,p4)==0 && !(p1==p4) && !(p2==p4) && abs(ccw(p1,p2,p3))!=1)return true;
	return false;
}



int n;
map<string,int> id;
Polygon territory[101];
vector<int> ind[101];
bool edge[11][11];
vector<int> paint;
int dp[1<<11];

bool share(int c1,int c2){
	for(int i=0;i<ind[c1].size();i++){
		for(int j=0;j<ind[c2].size();j++){
			int t1=ind[c1][i],t2=ind[c2][j];
			for(int k=0;k<territory[t1].size();k++){
				P p1=territory[t1][k];
				P p2=territory[t1][(k+1)%territory[t1].size()];
				for(int l=0;l<territory[t2].size();l++){
					P p3=territory[t2][l];
					P p4=territory[t2][(l+1)%territory[t2].size()];
					if(intersect(p1,p2,p3,p4)){
						return true;
					}
				}
			}
		}
	}
	return false;
}

int main(void){
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		int all=0;
		id.clear();
		for(int i=0;i<n;i++){
			territory[i].clear();
			ind[i].clear();
		}
		for(int i=0;i<n;i++){
			string str;
			cin >> str;
			if(id.find(str)==id.end()){
				id[str]=all++;
			}
			ind[id[str]].push_back(i);
			while(1){
				int x,y;
				scanf("%d",&x);
				if(x==-1)break;
				scanf("%d",&y);
				territory[i].push_back(P(x,y));
			}
		}
		memset(edge,false,sizeof(edge));
		for(int i=0;i<all;i++){
			for(int j=i+1;j<all;j++){
				if(share(i,j)){
					edge[i][j]=true;
					edge[j][i]=true;
				}
				
			}
		}
		paint.clear();
		for(int i=0;i<(1<<all);i++){
			bool flag=true;
			for(int j=0;j<all;j++){
				if(!((i>>j) & 1))continue;
				for(int k=j+1;k<all;k++){
					if(!((i>>k) & 1))continue;
					if(edge[j][k])flag=false;
				}
			}
			if(flag)paint.push_back(i);
		}
		fill(dp,dp+(1<<all),INF);
		dp[0]=0;
		for(int i=0;i<(1<<all);i++){
			if(dp[i]==INF)continue;
			for(int j=0;j<paint.size();j++){
				int k=paint[j];
				dp[i|k]=min(dp[i|k],dp[i]+1);
			}
		}
		printf("%d\n",dp[(1<<all)-1]);
	}
	return 0;
}

Measured memory_bytes: 1308
#!/usr/bin/env python3
import sys

def main():
    N, M, X = map(int, input().split())
    C = [None] * N
    A = [None for _ in range(N)]
    for i in range(N):
        C[i], *A[i] = map(int, input().split())
    
    # print(C,A)
    ans = 10**12
    for i in range(2**N):
        tmp = [0] * M
        tmpC = 0
        for j in range(N):
            if (i >> j) & 1:
                for k in range(M):
                    tmp[k] += A[j][k]
                tmpC += C[j]
        flag = True
        for k in range(M):
            if tmp[k] < X:
                flag = False
                break
        if flag:
            ans = min(ans, tmpC)
    
    if ans == 10**12:
        print(-1)
    else:
        print(ans)

if __name__ == '__main__':
    main()


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

int main(){
	int n,num[100000] = {},a,sum = 0;
	cin >> n;
	for(int i = 0;i < n;i++) {
		cin >> a;
		num[a - 1]++;
	}
	for(int i = 0;i < 100000;i++) {
		if(num[i] >= 2) sum += num[i] - 1;
	}
	int t = (sum + 1) / 2;
	n -= t * 2;
	cout << n << endl;
	return 0;
}

Measured memory_bytes: 768
from collections import defaultdict
import heapq

N,M,S = map(int,input().split())
Edges=[list(map(int,input().split())) for _ in range(M)]
Exchanges=[list(map(int,input().split())) for _ in range(N)]

max_money=max([a for _,_,a,_ in Edges])*N

Graph=defaultdict(lambda :[])

#nodeと状態は tupleで管理する。(node,money)
#Graph[cur_state]=[ (cost,next_state),...]


for u,v,a,b in Edges:
    u-=1;v-=1
    for cur_money in range(max_money+1):
        if cur_money-a<0:#お金が足りなくて移動できない
            continue
        from_state_u=(u,cur_money)
        to_state_v=(v,cur_money-a)
        Graph[from_state_u].append((b,to_state_v))

        from_state_v=(v,cur_money)
        to_state_u=(u,cur_money-a)
        Graph[from_state_v].append((b,to_state_u))

for n,[c,d] in enumerate(Exchanges):
    for cur_money in range(max_money+1):
        after_money=min(max_money,cur_money+c)#両替後のお金(money_max以上は同じにする)
        from_state=(n,cur_money)
        to_state=(n,after_money)
        Graph[from_state].append((d,to_state))



# Dijksttra する
#startの状態(Sがmax_moneyより大きいならmax_moneyにする)
start=(0,min(max_money,S))

Q=[(0,start)]

dist=defaultdict(lambda :float('inf'))
dist[start]=0

while Q:
    q = heapq.heappop(Q)
    cur_time,cur_state=q

    if dist[cur_state]<cur_time:
        continue
    for cost,next_state in Graph[cur_state]:
        next_time = cost+cur_time

        if dist[next_state]>next_time:
            dist[next_state]=next_time
            heapq.heappush(Q,(next_time,next_state))

for dest in range(1,N):
    ans=float("inf")
    #goal次の所持金は関係ないので、ある頂点のあらゆる所持金に対してminをとる
    for a in range(max_money+1):
        state=(dest,a)
        ans=min(ans,dist[state])
    print(ans)


Measured memory_bytes: 175132
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int main(){
	int N;
	cin>>N;
	vector<int> a(N);
	rep(i,N) cin>>a[i];
	int ans = 0;
	rep(i,N-1){
		if(a[i]==a[i+1]){
			a[i+1] = -100-i;
			ans++;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
def main()
        stdin = $stdin.readlines.map {|i| i.chomp}
        length = stdin[0].to_i
        elem = stdin[1].split(" ").map{|i|i.to_i}
        elem = elem.sort()
        higher = elem[length/2]
        lower = elem[(length/2)-1]
        size = (lower...higher).size()
        print(size)
end
main()

Measured memory_bytes: 10352
import sys

t1, t2 = map(int, input().split())
a1, a2 = map(int, input().split())
b1, b2 = map(int, input().split())

if (a1-b1)*t1+(a2-b2)*t2 == 0:
  print("infinity")
  sys.exit()

e1 = (a1-b1)*t1
e2 = e1 + (a2-b2)*t2

if e1*e2 > 0:
  print(0)
  sys.exit()

e1, e2 = abs(e1), abs(e2)

if e1%e2:
  print(1+2*(e1//e2))
else:
  print(2*(e1//e2))

Measured memory_bytes: 9180
#include <stdio.h>

int main(void)
{
	char card[11];
	int a, b, c, below;
	int i;
	double percent;
	
	while (scanf("%d%d%d", &a, &b, &c) != EOF){
		for (i = 1; i <= 10; i++){
			card[i] = 0;
		}
		
		card[a] = card[b] = card[c] = 1;
		below = 0;
		
		for (i = 1; i <= 10; i++){
			if (card[i] == 0 && a + b + i <= 20){
				below++;
			}
		}
		
		percent = (below / 7.0) * 100.0;
		
		if (percent >= 50.0){
			printf("YES\n");
		}
		
		else {
			printf("NO\n");
		}
	}
	
	return (0);
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int t[2000],u[2000];
int a[2000000],b[2000000];
int N,M;
int main(){
  while(1){
    cin>>N>>M;
    if(N==0&&M==0)break;
    for(int i=0;i<2000000;i++)a[i]=b[i]=0;
    for(int i=1;i<=N;i++)cin>>t[i],t[i]+=t[i-1];
    for(int i=1;i<=M;i++)cin>>u[i],u[i]+=u[i-1];
    for(int i=1;i<=N;i++)
      for(int j=i;j<=N;j++)
    a[t[j]-t[i-1]]++;
    for(int i=1;i<=M;i++)
      for(int j=i;j<=M;j++)
    b[u[j]-u[i-1]]++;
    int ans=0;
    for(int i=0;i<2000000;i++)ans+=a[i]*b[i];
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 16796
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;
typedef long long ll;
const long long MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,m,n) for(ll i=(m);i<(n);i++)
#define ALL(v) v.begin(), v.end()
#define pb push_back





int main(){

    string s;
    cin>>s;

    if (s=="RRR"){
        cout<<3<<endl;
    }

    else if (s=="RRS" or s=="SRR"){
        cout<<2<<endl;
    }

    else if (s=="RSS" or s=="SRS" or s=="SSR" or s=="RSR"){
        cout<<1<<endl;
    }
    else {
        cout<<0<<endl;
    }

















}

Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1<<30;
vvi in;
vi dp;
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll lcm(ll a,ll b){
	return a/gcd(a,b)*b;
}
ll f(int a){
	if(dp[a])return dp[a];
	ll s=(in[a][2]?f(in[a][2]-1):1);
	ll t=(in[a][3]?f(in[a][3]-1):1);
	ll w=lcm(s*in[a][0],t*in[a][1]);
	dp[a]=w/in[a][0]+w/in[a][1];
	return dp[a];
}
int main(){
	int n;
	while(cin>>n,n){
		in=vvi(n,vi(4));
		rep(i,n)rep(j,4)cin>>in[i][j];
		dp=vi(n);
		rep(i,n)f(i);
		ll out=0;
		rep(i,n)out=max(out,dp[i]);
		cout<<out<<endl;
	}
}

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

int main(){
    int s;
    cin >> s;
    int h, m, n;
    h = s/3600;
    m = (s%3600)/60;
    n = (s%3600)%60;
    cout << h << ":" << m << ":" << n << endl;
    return 0;
}



Measured memory_bytes: 3112
#include <iostream>
#include <string>
#include <vector>
#include <map>

using namespace std;

const int N = 100101;

int main() {
	int n; cin >> n;
	int ans = 0;
	int mx = 10101010;
	for(int i = 0; i < n; ++i) {
		int x; cin >> x;
		if (x <= mx) {
			++ans;
		}
		mx = min(mx, x);
	}
	
	cout << ans << endl;
}


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

ll gcd(ll n, ll m){
  if(n%m==0) return m;
  else {
      return gcd(m, n%m);;
  }
}

int main(){
    int n; ll X; cin>>n>>X;
    ll x; cin >> x;
    ll ans = abs(x-X);
    ll num = 0;
    for (int i=0; i<n-1; i++){
        if(ans == 1) break;
        cin >> x;
        ll tmp = abs(x-X);
        ans = gcd(ans, tmp);
    }
    cout << ans << endl;
}

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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} c(200005);

int main() {
  int n, m, k;
  cin >> n >> m >> k;

  mint ans = 0;
  mint col = m;
  for (int x = n-1; x >= 0; --x) {
    mint now = col;
    now *= c(n-1,x);
    if (x <= k) ans += now;
    col *= m-1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6248
#include<bits/stdc++.h>
using namespace std;
    int main(){
        string S; cin >> S;
            int t = 0;
                for(int i = 0; i < 3; i++){
                    if(S.at(i) == 'o'){
                        t = t + 100;
                    }else{}
                }
                    cout << 700 + t << endl;
    return 0;}

Measured memory_bytes: 764
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e9
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

int kk, nn;
int Rank[200005];
int tmp[200005];

bool compare_sa(int i, int j)
{
	if(Rank[i] != Rank[j]) return Rank[i] < Rank[j];
	int ri, rj;
	if(i+kk <= nn) ri = Rank[i+kk]; else ri = -1;
	if(j+kk <= nn) rj = Rank[j+kk]; else rj = -1;
	return ri < rj;
}

//sa[0]～sa[s.size()]の長さ(s.size()+1)の配列を返す（sa[0]は空文字列を指す）
void makeSA(string s, int sa[]){
	nn = s.size();
	for(int i = 0; i <= nn; i++) sa[i] = i;
	for(int i = 0; i < nn; i++) Rank[i] = s[i];
	s += " ";
	s[nn] = -1;

	for(kk = 1; kk <= nn; kk*=2){
		sort(sa, sa+nn+1, compare_sa);
		int val = 0;
		tmp[sa[0]] = 0;
		for(int i = 1; i <= nn; i++){
			if(compare_sa(sa[i-1], sa[i])) val++;
			tmp[sa[i]] = val;
		}
		for(int i = 0; i <= nn; i++) Rank[i] = tmp[i];
	}
}

llint k, n;
string s;
int sa[100005], rnk[100005];

bool check(llint x)
{
	llint rem = n % k;
	for(int i = 0; i < n;){
		if(rnk[i] <= x && rem > 0 && i+n/k+1 <= n){
			rem--;
			i += n/k+1;
		}
		else i += n/k;
	}
	return rem == 0;
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> k >> s;
	
	k++;
	n = s.size();
	if(n % k == 0){
		string ans = "";
		for(int i = 0; i < n; i += n/k){
			ans = max(ans, s.substr(i, n/k));
		}
		cout << ans << endl;
		return 0;
	}
	
	makeSA(s, sa);
	for(int i = 0; i <= n; i++) rnk[sa[i]] = i;
	
	llint ub = n+1, lb = 0, mid;
	while(ub-lb>1){
		mid = (ub+lb)/2;
		if(check(mid)) ub = mid;
		else lb = mid;
	}
	llint ans = sa[ub];
	
	cout << s.substr(ans, n/k+1) << endl;
	
	return 0;
}

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

string to_string(string s) {
    return '"' + s + '"';
}
string to_string(char ch) {
    string s(1, ch);
    return '\'' + s + '\'';
}
string to_string(const char *s) {
    return to_string((string)s);
}
string to_string(bool b) {
    return (b ? "true" : "false");
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}
 
#ifndef ONLINE_JUDGE
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

typedef long long int ll;
#define int ll
#define pb          push_back
#define pll         pair<int,int>
#define mll	        map<int,int>
#define F           first
#define S           second
#define lbnd(v,val) lower_bound(v.begin(),v.end(),val)
#define ubnd(v,val) upper_bound(v.begin(),v.end(),val)
#define bs(v,val)   binary_search(v.begin(),v.end(),val)
#define mp          make_pair
#define f(i,x,n)    for(int i=x;i<n;i++)
#define isup		isupper
#define islow 		islower
#define max3(a,b,c)	max(a,max(b,c))
#define endl        "\n"
#define countbits(n)	 __builtin_popcountll(n)
#define all(ar) ar.begin(), ar.end()
#define rall(ar) (ar).rbegin(), (ar).rend()
const ll mod = 1e9 + 7;
const ll inf = LLONG_MAX;
const ll N = 2e5 + 10;

typedef vector<vector<ll>> matrix;
typedef vector<ll> vll;


void solve(){
	int n;
	cin>>n;
	vll dp(3);
	f(i,0,n){
		vll new_dp(3,0);
		vll c(3);
		f(j,0,3){
			cin>>c[j];
		}
		f(j,0,3){
			f(k,0,3){
				if(j!=k){
					new_dp[k] = max(new_dp[k],dp[j]+c[k]);
				}
			}
		}
		dp = new_dp;
	}
	cout<<*max_element(all(dp))<<endl;
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    

    int t=1;
    // cin>>t;
    while(t--){
    	solve();
    }
    return 0;
}


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

bool check[101];
int row1,row2,row3,col1,col2,col3,leftD,rightD;
int main(){
    int ar[101][101],n,temp;
    for(int i=1; i<=3; i++){
        for(int j=1; j<=3; j++){
            scanf("%d",&ar[i][j]);
        }
    }
    cin >> n;
    while(n--){
        cin >> temp;
        check[temp] = true;
    }
    for(int i=1; i<=3; i++){
        if(check[ar[1][i]])row1++;
    }
    for(int i=1; i<=3; i++){
        if(check[ar[2][i]])row2++;
    }
    for(int i=1; i<=3; i++){
        if(check[ar[3][i]])row3++;
    }
    for(int i=1; i<=3; i++){
        if(check[ar[i][1]])col1++;
    }
    for(int i=1; i<=3; i++){
        if(check[ar[i][2]])col2++;
    }
    for(int i=1; i<=3; i++){
        if(check[ar[i][3]])col3++;
    }
    if(check[ar[1][3]]) leftD++;
    if(check[ar[2][2]]) leftD++;
    if(check[ar[3][1]]) leftD++;
    if(check[ar[1][1]]) rightD++;
    if(check[ar[2][2]]) rightD++;
    if(check[ar[3][3]]) rightD++;
    if(row1 == 3 || row2 == 3 || row3 == 3 || col1 == 3 || col2 == 3 || col3 == 3 || leftD == 3 || rightD == 3 ) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}



Measured memory_bytes: 256
from collections import deque

K = int(input())
q = deque(list(range(1, 10)))
cnt = 0
ans = 0
while True:
    u = q.popleft()
    cnt += 1
    if cnt == K:
        ans = u
        break

    ll = u % 10
    for i in range(max(0, ll - 1), min(9, ll + 1) + 1):
        q.append(u * 10 + i)

print(ans)


Measured memory_bytes: 82856
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main() {
  int nums;
  string tmp;
  cin >> nums;
  map<string, int> store;
  for (int i = 0; i < nums; i++) {
    cin >> tmp;
    if (store.count(tmp))
      continue;
    else
      store.insert(pair<string, int>(tmp, 1));
  }
  cout << store.size() << endl;
}

Measured memory_bytes: 19176
#include<map>
#include<queue>
#include<time.h>
#include<limits.h>
#include<cmath>
#include<ostream>
#include<iterator>
#include<set>
#include<stack>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define rep_1(i,m,n) for(int i=m;i<=n;i++)
#define mem(st) memset(st,0,sizeof st)
inline int read()
{
	int num=0, w=0;
	char ch=0;
	while (!isdigit(ch))
	{
		w|=ch=='-';
		ch = getchar();
	}
	while (isdigit(ch))
	{
		num = (num<<3) + (num<<1) + (ch^48);
		ch = getchar();
	}
	return w? -num: num;
}
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
typedef pair<double,double> pdd;
const int inf = 0x3f3f3f3f;
const int N=2e6+10;
ll dp[3020][3020][5];
ll a[3020][3020];
void solve()
{
	int r,c,k;
	cin>>r>>c>>k;
	for(int i=0; i<k; i++)
	{
		int x,y,z;
		cin>>x>>y>>z;
		a[x][y]=z;
	}
	for(int i=1; i<=r; i++)
		for(int j=1; j<=c; j++)
		{
			if(j==1)
			{
				dp[i][j][3]=dp[i-1][1][3]+a[i][j];
				dp[i][j][2]=dp[i-1][1][3]+a[i][j];
				dp[i][j][1]=dp[i-1][1][3]+a[i][j];
				dp[i][j][0]=dp[i-1][1][3];
				continue ;
			}
			dp[i][j][0]=max(dp[i][j-1][0],dp[i-1][j][3]);
			for(int k=1; k<=3; k++)
			{
				dp[i][j][k]=max(dp[i][j-1][k],dp[i][j-1][k-1]+a[i][j]);
				dp[i][j][k]=max(dp[i][j][k],dp[i-1][j][3]+a[i][j]);
			}
		}
	cout<<dp[r][c][3]<<endl;
}
signed main()
{
	int t=1;
	while(t--)
		solve();
	return 0;
}



Measured memory_bytes: 428220
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
const int N=2e5+10;
const int inf=1e9;
const int mod=1e9+7;
typedef pair<int,int> pii;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int n,st[N],pre[N],suf[N],top=0,f[N],sum[N];
pii a[N];
vector<int> v[N];
int main() {
    cin>>n;
    for(int i=1;i<=n;i++) a[i].fi=gi(),a[i].se=gi(),st[++top]=a[i].se;
    sort(st+1,st+top+1);
    for(int i=1;i<=n;i++) a[i].se=lower_bound(st+1,st+top+1,a[i].se)-st;
    sort(a+1,a+n+1);
    for(int i=1;i<=n;i++) pre[i]=max(pre[i-1],a[i].se);
    suf[n+1]=inf;
    for(int i=n;i;i--) suf[i]=min(suf[i+1],a[i].se);
    for(int i=1;i<=n;i++) v[pre[i]].pb(suf[i]);
    f[0]=sum[0]=1;
    for(int i=1;i<=n;i++) {
        sum[i]=sum[i-1];
        for(int j:v[i]) {
            f[i]=(f[i]+sum[i])%mod;
            if(j>=2) f[i]=(f[i]-sum[j-2]+mod)%mod;
            sum[i]=(sum[i-1]+f[i])%mod;
        }
    }
    printf("%d\n",f[n]);
    return 0;
}
//orzgzy
//鸡贼明年进队超稳


Measured memory_bytes: 16640
N = int(input())
A = []
B = []
for i in range(N):
    a_,b_ = map(int,input().split())
    A.append(a_)
    B.append(b_)
A.sort()
B.sort()
if N % 2 == 1:
    print(B[(N - 1) // 2] - A[(N - 1) // 2] + 1)
else:
    print(((B[N // 2] + B[N // 2 - 1]) - (A[N // 2] + A[N // 2 - 1])) + 1)

Measured memory_bytes: 25172
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
using namespace std;
int a,b,c,m;
int ans;
int main(){
   cin>>a>>b>>c>>m;
   for(int i=0;i<=a;i++){
   	   for(int j=0;j<=b;j++){
   	   	   for(int k=0;k<=c;k++){
   	   	   	  if(i*500+j*100+k*50==m)ans++;
			}
		}
   }
   cout<<ans;
    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 tate = sc.nextInt();
		//?¨????????????????
		int yoko = sc.nextInt();
		//??¢???????±???????
		int menseki = tate * yoko;

		//??¨?????????????±???????
		int syuu = (tate + yoko) * 2;
		//??¨???
		System.out.println(menseki +" "+ syuu);

	}
}

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

typedef long long ll;
typedef long double ld;
using namespace std;
mt19937_64 mrand(chrono::steady_clock::now().time_since_epoch().count());
//mt19937_64 mrand(42);
#define ii for(int i=1;i<=n;++i)
#define ji for(int j=1;j<=n;++j)
#define jj for(int j=1;j<=m;++j)
#define ij for(int i=1;i<=m;++i)
#define sz(x) ((ll)x.size())
#define all(x) x.begin(),x.end()
#define al(x) x+1,x+1+n
#define asd cout<<"ok"<<endl;
#define asdd cout<<"okok"<<endl;
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define pr(v) for(auto i:v) cout<<i<<" ";cout<<endl
#define prt(a, l, r) for(auto i=l;i<=r;++i) cout<<a[i]<<" ";cout<<endl;
#define pc(x) __builtin_popcount(x)
#define pb push_back

int main() {
    string s;
    cin >> s;
    if(s == "ABC") cout << "ARC";
    else cout << "ABC";
}

Measured memory_bytes: 3600
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      int minv = Integer.parseInt(br.readLine());
      int n1   = Integer.parseInt(br.readLine());
      int maxv = n1- minv;
      if ( n1 < minv ) minv = n1;

      for( int i=2,r,mv; i<n; i++ ) {
        r = Integer.parseInt(br.readLine());
        if ( (mv = r-minv) > maxv ) maxv = mv;
        else if ( r < minv ) minv = r; 
      }

      System.out.println(maxv);
    }
  }
}


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

int main()
{
	int num;
	cin >> num;
	int* T = new int[num];
	for(int i=0;i<num;i++)
	{
		cin >> T[i];
	}
	int maxdis = -1e9;
	int minnum = T[0];
	for(int i=1;i<num;i++)
	{
		maxdis = max(maxdis, T[i] - minnum);
		minnum = min(minnum,T[i]);
	}
	cout << maxdis<<endl;
}


Measured memory_bytes: 3864
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define mp make_pair
long long gcd(long long a, long long b) {return b ? gcd(b, a % b) : a;}
long long lcm(long long m, long long n ){
    if((0 == m )||( 0 == n ))return 0;
    return ((m / gcd(m, n)) * n);
}
int dp[41][401][401];
signed main(){
    int n; cin>>n;
    pii comp; cin>>comp.first>>comp.second;
    rep(i,n)rep(j,401)rep(k,401)dp[i][j][k]=INF;
    dp[0][0][0]=0;
    vector<pii>val;
    vector<int>c(n);
    rep(i,n){
        pii temp; cin>>temp.first>>temp.second;
        cin>>c[i];
        val.push_back(mp(temp.first,temp.second));
        dp[i][val[i].first][val[i].second]=c[i];
    }
    rep(i,n-1){
        rep(j,401){
            rep(k,401){
                if(dp[i][j][k]==INF)continue;
                cmin(dp[i+1][j][k],dp[i][j][k]);
                pii ni=mp((j+val[i+1].first),(k+val[i+1].second));
                cmin(dp[i+1][ni.first][ni.second],dp[i][j][k]+c[i+1]);
            }
        }
    }
    int ans=INF;
    rep(i,401)rep(j,401){
        int div=gcd(i,j);
        if(i&&j){
        if(i/div==comp.first&&j/div==comp.second)cmin(ans,dp[n-1][i][j]);
        }
    }
    if(ans==INF)ans=-1;
    cout<<ans<<endl;
}


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

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static long LINF = 1L << 55;

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			long x = in.nextLong();

			long ans = 1;
			for (int i = 2; i <= (long)Math.sqrt(x)+1; i++) {
				for (int j = 2; (long)Math.pow(i, j) <= x; j++) {
					ans = Math.max(ans, (long)Math.pow(i, j));
				}
			}
			out.println(ans);
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

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

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

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

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public int[] nextIntArrayDec(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt() - 1;
			}
			return res;
		}

		public int[] nextIntArray1Index(int n) {
			int[] res = new int[n + 1];
			for (int i = 0; i < n; i++) {
				res[i + 1] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public long[] nextLongArrayDec(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong() - 1;
			}
			return res;
		}

		public long[] nextLongArray1Index(int n) {
			long[] res = new long[n + 1];
			for (int i = 0; i < n; i++) {
				res[i + 1] = nextLong();
			}
			return res;
		}

		public double[] nextDoubleArray(int n) {
			double[] res = new double[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextDouble();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


Measured memory_bytes: 20692
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}

signed main() {
	int n;
	cin >> n;
	int p[200005];
	rep(i, n) {
		cin >> p[i];
	}
	int mi = INF, ans = 0;
	rep(i, n) {
		if (mi >= p[i]) {
			mi = p[i];
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1792
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        String S = sc.next();
        
        Pattern p = Pattern.compile("^[0-9]{" + A + "}-[0-9]{" + B + "}$");
        Matcher m = p.matcher(S);
        
        System.out.println( (m.find()) ? "Yes" : "No" );
    }
}


Measured memory_bytes: 39372