akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
template <class Key, class Compare = less<Key>>
using Tree = __gnu_pbds::tree<Key, __gnu_pbds::null_type, Compare, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;





void Main() {
  int n;
  cin >> n;
  static int a[100000][3];
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 3; ++j) {
      cin >> a[i][j];
    }
  }
  static int dp[100000][3];
  for (int j = 0; j < 3; ++j) {
    dp[0][j] = a[0][j];
  }
  for (int i = 1; i < n; ++i) {
    for (int j = 0; j < 3; ++j) {
      int bestprev = 0;
      for (int k = 0; k < 3; ++k) {
        if (k != j) {
          bestprev = max(bestprev, dp[i-1][k]);
        }
      }
      dp[i][j] = max(dp[i][j], bestprev + a[i][j]);
    }
  }
  int ans = 0;
  for (int j = 0; j < 3; ++j) {
    ans = max(ans, dp[n-1][j]);
  }
  cout << ans << '\n';
}


int main() {
  ios::sync_with_stdio(false);
//  cin.tie(nullptr);
  #ifdef _DEBUG
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  #endif
  Main();
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
// x^y≡x^(y%(p-1))mod p
// but there is a condition that x needs to be coprime to p
///assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
typedef long long int ll;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
#define  pb push_back
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fo(i,a,b) for(ll i = a; i<=b;i+=1)
#define rf(i,a,b)  for(ll i=a;i>=b;i--)
#define vll vector<ll>
#define tests() int test_cases ; cin >> test_cases ; while(test_cases--)
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define MAXN 100010
#define MOD 1000000007
#define mod 998244353
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define sp " "
#define MS(x,y) fill_n(*x, sizeof x / sizeof **x, y);
#define mem(x,y) memset(x,y,sizeof(x));
#define INF 1000000000000000000
ll power(ll x, ll y,ll p) 
{ 
    ll res = 1;     // Initialize result 
    x = x % p;
    if (y==0)return 1;
    if(x==0)return 0;   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p;    
        y = y>>1; // y = y/2 
        x = (x*x) % p;  // Change x to x^2 
    } 
    return res; 
}
int gcd(int a, int b) { if (a == 0)return b;return gcd(b % a, a);} 

ll modinv(ll a,ll p){return power(a,p-2,p);}

int solve(){
    ll x;
    cin>>x;
    ll cur = 100;
    ll ans = 0;
    while(cur<x){
        cur = cur*1.01;
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);



    
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif



    // tests(){solve();}
    solve();
    return 0;
}/*#ifndef ONLINE_JUDGE
    #endif*/

    // make_pair make_tuple  tuple<int,int,int> 

Measured memory_bytes: 3636
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=5e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll h,w,d,a,posx[90005]={},posy[90005]={},x[90005]={},q,l,r;
  cin >> h >> w >> d;
  for(int i=0; i<h; i++) {
    for(int j=0; j<w; j++) {
      cin >> a;
      posx[a]=j,posy[a]=i;
    }
  }
  for(int i=d+1; i<=h*w; i++) {
    x[i]=x[i-d]+abs(posx[i]-posx[i-d])+abs(posy[i]-posy[i-d]);
  }
  cin >> q;
  while(q--) {
    cin >> l >> r;
    cout << x[r]-x[l] << endl;
  }
}

Measured memory_bytes: 3200
s = input()
t = input()
ans = 0
cur = 0
cnt = 0
for i in t:
  f = s.find(i, cur)
  if f == -1:
    cnt += 1
    f = s.find(i)
    if f == -1:
      print(-1)
      exit()
    else:
      cur = f + 1
  else:
    cur = f + 1
print(cur + len(s) * cnt)

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

int main(){
	double a,b,c,d,e,f;
	while(cin>>a>>b>>c>>d>>e>>f){
		double y=(c*d-a*f)/(b*d-a*e);
		double x=(c-b*y)/a;
		printf("%.3lf %.3lf\n",x,y);
	}
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,D;
  cin>>N>>D;
  vector<vector<int>> A(N,vector<int>(D));
  for(int i=0;i<N;i++){
  for(int j=0;j<D;j++){
  cin>>A[i][j];
  }
  }
  int a =0;
  for(int i=0;i<N;i++){
  for(int j=i+1;j<N;j++){
  int count=0;
    for(int k=0;k<D;k++){
    int d=abs(A[i][k]-A[j][k]);
      count+=d*d;
    }
    bool f=false;
    for(int k=0;k<=count;k++){
    if(k*k==count){
    f=true;
    }
    }
  if(f){
  a++;
  }
  }
  }
cout<<a<<endl;
}


Measured memory_bytes: 256
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word

#include <bits/stdc++.h>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace std;
const long long N=200005, INF=1e18;
lld pi=3.1415926535897932;
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }

int32_t main()
{
    IOS;
    lld a,b;
    cin>>a>>b;
    a*=b;
    cout<<floor(a);
}

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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

const int N_MAX = 100000;

ll N, H;
ll a[N_MAX];
ll b[N_MAX];

bool f(int n)
{
    ll h = H;
    int pt_b = N - 1;
    if (n > N) {
        h -= (n - N) * a[N - 1];
        n -= (n - N);
    }
    for (int i = 0; i < n && h > 0; i++) {
        if (pt_b >= 0 && b[pt_b] > a[N-1]) {
            h-= b[pt_b];
            pt_b--;
        } else {
            h -= a[N-1];
        }
    }
    return (h <= 0);
}

int binsearch(int first, int last)
{
    if (last - first <= 4) {
        FOR(i, first, last) {
            if (f(i)) {
                return i;
            }
        }
        assert(0);
    }
    int mid = first + (last - first) / 2;
    if (f(mid)) {
        return binsearch(first, mid + 1);
    } else {
        return binsearch(mid, last);
    }
}

int main(void)
{
    cin >> N >> H;
    REP(i, N) {
        cin >> a[i] >> b[i];
    }
    sort(a, a + N);
    sort(b, b + N);
    cout << binsearch(0, 1000000002) << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ChenChuLing main
#define INF 2001052800
using namespace std;
int n,ans=INF;
int pre[300004],las[300004];
char s[300004];

int ChenChuLing (){
    scanf("%d",&n);
    scanf("%s",s+1);
    pre[0]=0;
    las[n+1]=0;
    for(int i=1;i<=n;i++){
        pre[i]=pre[i-1]+(s[i]=='E');
    }
    for(int i=n;i>=1;i--){
        las[i]=las[i+1]+(s[i]=='W');
    }
    for(int i=1;i<=n;i++){
        ans=min(ans,n-1-pre[i-1]-las[i+1]);
    }
    printf("%d\n",ans);
    return 0;
}


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

#define ll long long
#define endl "\n"

int main ()
{

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #define int ll
    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
    vector <int> divisors(n+5, 0);
    for (int i=1; i<=n; i++){
    	for (int j=i; j<=n; j+=i){
    		divisors[j]++;
		}
	}
	
	//for (int i=1; i<=n; i++) cerr << divisors[i] << " ";
	//cerr << endl;
	for (int i=1; i<=n; i++){
		divisors[i] *= i;	
	}
	
	//for (int i=1; i<=n; i++) cerr << divisors[i] << " ";
	
	for (int i=1; i<=n+2; i++){
		divisors[i] += divisors[i-1];
	}
    
	//for (int i=1; i<=n; i++) cerr << divisors[i] << " ";
    //cerr << endl;
    
	cout << divisors[n] << endl;
    
	return 0;

}

Measured memory_bytes: 81276
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,j,n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(), i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9 + 7;
 
typedef long long i64;
typedef pair<int, int> pi;
 
template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;
 
i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcm(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

  int h, w, k;
  cin >> h >> w >> k;
  vt<string> s(h);
  rep(i, 0, h) cin >> s[i];

  vvt<int> ans(h, vt<int>(w, -1));
  int num = 1;
  rep(i, 0, w) {
    bool find = false;
    rep(j, 0, h) {
      ans[j][i] = num;
      if(s[j][i] == '#') {
        if(find == false) find = true;
        else num++, ans[j][i] = num;
      }
    }

    if(find == true) {
      num++;
      continue;
    }

    int idx = i - 1;
    while(idx >= 0 && ans[0][idx] == -1) idx--;

    if(idx < 0) rep(j, 0, h) ans[j][i] = -1;
    else rep(j, 0, h) ans[j][i] = ans[j][idx];
  }

  for(int i = w - 1; i >= 0; --i) {
    if(ans[0][i] != -1) continue;

    int idx = i;
    while(idx < w && ans[0][idx] == -1) idx++;
    rep(j, 0, h) ans[j][i] = ans[j][idx];
  }

  rep(i, 0, h) rep(j, 0, w) cout << ans[i][j] << " \n"[j == w - 1];
}

Measured memory_bytes: 1280
n, m=[int(i) for i in input().split()]

maxL = float("-inf")
minR = float("inf")

for i in range(m):
    l, r = [int(i) for i in input().split()]
    maxL, minR = max(maxL, l), min(minR, r)

print(max(0, minR - maxL + 1))

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define FILL(Itr,n) fill((Itr).begin(),(Itr).end(),n)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;
#define MOD 1000000007

int main(){
    
    ll N; cin>>N;
    ll ans=1;
    for(ll i=1;i<=N;i++){
        ans *= i;
        ans %= MOD;
    }
    
    cout<<ans<<endl;
    
    
    return 0;
}


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

/***********************************************/
/* Dear online judge:
 * I've read the problem, and tried to solve it.
 * Even if you don't accept my solution, you should respect my effort.
 * I hope my code compiles and gets accepted.
 *  ___  __     _______    _______      
 * |\  \|\  \  |\  ___ \  |\  ___ \     
 * \ \  \/  /|_\ \   __/| \ \   __/|    
 *  \ \   ___  \\ \  \_|/__\ \  \_|/__  
 *   \ \  \\ \  \\ \  \_|\ \\ \  \_|\ \ 
 *    \ \__\\ \__\\ \_______\\ \_______\
 *     \|__| \|__| \|_______| \|_______|
 */
const long long mod = 1000000007;

const int mxN = 500010;
int dp[mxN];
int nxt[mxN];
string s;

int bt(int ind) {
	if(ind >= (int)s.size()) return 0;
	if(s[ind] == '0') return bt(nxt[ind]);
	int & ref = dp[ind];
	if(ref != -1) return ref;
	if(nxt[ind] >= (int)s.size()) return 0;
	
	ref = bt(ind+1);
	if(nxt[nxt[ind]] == nxt[ind]+1 && nxt[nxt[ind]] < (int)s.size()) {
		ref = max(ref,nxt[ind]-ind+bt(nxt[nxt[ind]]+1));
	}
	if(nxt[ind] == ind+1 && nxt[nxt[ind]] == ind+2 && ind+2 < (int)s.size()) {
		ref = max(ref,nxt[nxt[nxt[ind]]]-nxt[nxt[ind]]+bt(nxt[nxt[nxt[ind]]]));
		ref = max(ref,nxt[nxt[nxt[ind]]]-nxt[nxt[ind]]-1+bt(nxt[nxt[nxt[ind]]]-1));
	}
	
	return ref;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	int N;
	cin>>N>>s;
	nxt[s.size()-1] = s.size();
	for(int i = s.size()-2;i >= 0;i--) {
		if(s[i] == s[i+1]) nxt[i] = nxt[i+1];
		else nxt[i] = i + 1;
	}
	memset(dp,-1,sizeof dp);
	cout<<bt(0)<<'\n';
	return 0;
}


Measured memory_bytes: 28188
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline bool chmin(A &a,const B &b){if(a>b){a=b;return true;}else{return false;}}
template<typename A,typename B>inline bool chmax(A &a,const B &b){if(a<b){a=b;return true;}else{return false;}}

int main()
{
    int N;
    cin >> N;
    vll A(N);
    cin >> A;
    ll xorAll = 0;
    for(auto a:A){
        xorAll = xorAll ^ a;
    }
    for(auto a:A){
        cout << (xorAll^a) << " ";
    }
    cout << endl;
}

Measured memory_bytes: 4840
from itertools import combinations

N, K = map(int, input().split())
P = [tuple(map(int, input().split())) for _ in range(N)]

ans = 10**18*5

for x in combinations(range(N), 2):
    u = max(P[x[0]][0], P[x[1]][0])
    d = min(P[x[0]][0], P[x[1]][0])
    for y in combinations(range(N), 2):
        r = max(P[y[0]][1], P[y[1]][1])
        l = min(P[y[0]][1], P[y[1]][1])
        count = 0
        for i in range(N):
            if d <= P[i][0] <= u and l <= P[i][1] <= r:
                count += 1
        if count >= K:
            ans = min(ans, (u - d) * (r - l))

print(ans)

Measured memory_bytes: 50396
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 1000000007
#define MAX 2100000

int main(){
  int N,K;
  cin>>N>>K;
  vector<ll> x(N),y(N);
  for(int i=0;i<N;i++){
    cin>>x.at(i)>>y.at(i);
  }

  ll ans=4000000000000000000;
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      ll left=x.at(i);
      ll right=x.at(j);
      if(right<left){
        continue;
      }
      for(int k=0;k<N;k++){
        for(int l=0;l<N;l++){
          ll top=y.at(k);
          ll bottom=y.at(l);
          if(top<bottom){
            continue;
          }
          int count=0;
          for(int m=0;m<N;m++){
            if(left<=x.at(m)&&x.at(m)<=right&&bottom<=y.at(m)&&y.at(m)<=top){
              count++;
            }
          }
          if(count>=K){
            ans=min(ans,(right-left)*(top-bottom));
          }
        }
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

using Weight = int;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int s = 0, int d = 0, Weight w = 0)
    : src(s), dst(d), weight(w) {
  }
};

using Edges  = vector<Edge>;
using Graph  = vector<Edges>;
using Array  = vector<Weight>;
using Matrix = vector<Array>;

void addArc(Graph &g, const int &a, const int &b, const Weight &w = 1) {
  g[a].emplace_back(a, b, w);
}

void addEdge(Graph &g, const int &a, const int &b, const Weight &w = 1) {
  addArc(g, a, b, w);
  addArc(g, b, a, w);
}

void solve() {
  int v, e;
  cin >> v >> e;
  Graph g(v);
  while (e--) {
    int s, t, d;
    cin >> s >> t >> d;
    addArc(g, s, t, d);
  }
  vvi dp(1 << v, vi(v, INF));
  dp[0][0] = 0;
  rep(s, 1 << v) {
    for (auto &es : g) {
      for (auto &e : es) {
        if (~s >> e.dst & 1) cmin(dp[s | 1 << e.dst][e.dst], dp[s][e.src] + e.weight);
      }
    }
  }
  int x = dp.back().front();
  cout << (x == INF ? -1 : x) << endl;
}

Measured memory_bytes: 7540
#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 a, b, c;
  cin >> a >> b >>c;
  if (b-a==c-b) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
D, G = map(int, input().split())
P, C = [], []

for _ in range(D):
    p, c = map(int, input().split())
    P.append(p); C.append(c)

ans = float('inf')

for bit in range(2**D):
    score, solve_num = 0, 0

    for i in range(D):
        if (bit >> i) & 1:
            score += (100 * (i+1) * P[i] + C[i])
            solve_num += P[i]

    for i in range(D-1, -1, -1):
        if score >= G:
            break

        if (bit >> i) & 1:
            continue

        for j in range(P[i]):
            score += 100*(i+1)
            solve_num += 1

            if score >= G:
                break

    ans = min(ans, solve_num)

print(ans)


Measured memory_bytes: 3064
from collections import deque
d = deque()
length = 0
for x in input():
    d.append(x)
    length += 1
Q = int(input())
f = 0
for _ in range(Q):
    l = list(input().split())
    if l[0] == '1':
        f ^= 1
    else:
        length += 1
        if f == 0: 
            if l[1] == '2': d.append(l[2])
            else: d.appendleft(l[2])
        else:
            if l[1] == '2': d.appendleft(l[2])
            else: d.append(l[2])
ans = ''
for x in range(length):
    ans += d.pop()
if f == 0:
    print(ans[::-1])    
else:
    print(ans)


Measured memory_bytes: 6260
#include <stdio.h>
#include<stdlib.h>
#define MAX 51
struct node{int x; struct node* next;};

void initcard(struct node *p){
  p = NULL;
  return;
}
struct node* push_card(struct node *p,int n){
  struct node *x;
  x = (struct node*)malloc(sizeof(struct node));
  x->x = n;
  x->next = p;
  p = x;
  return p;
}

struct node* cut(struct node *q,int p,int c){
  struct node *head,*tail,*b;
  int i;
  if(p==1)return q;
  head = q;
  //printf("%d",q->x);
  for(i=1;i<p-1;i++)q = q->next;
  tail = q;//一番下になる
  b = q->next;//一番上になる
  for(i=0;i<c;i++)q=q->next;
  tail->next = q->next;
  q->next = head;
  return b;
}

void c_free(struct node* p){
  struct node *a;
  while(p!=NULL){
    p = p->next;
    a = p;
    free(a);
  }
  return;
}
int main(){
  struct node *card;
  int i,j,n,r,p,c,m[MAX],str[MAX];
  scanf("%d %d",&n,&r);
  while(n){
    card = NULL;
    for(i=1;i<=n;i++)card = push_card(card,i);
    /*while(card!=NULL){
      printf("%d ",card->x);
      card=card->next;
    }
    printf("\n");*/
      for(j=0;j<r;j++){
        scanf("%d %d",&p,&c);
        card = cut(card,p,c);
        /*while(card!=NULL){
          printf("%d ",card->x);
          card=card->next;
        }
        printf("\n");*/
      }
      printf("%d\n",card->x);
      scanf("%d %d",&n,&r);
    }
      return 0;
}



Measured memory_bytes: 2916
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)(a);i<=(sign)(b);++i)
#define Fordown(i,a,b) for(register sign i=(sign)(a);i>=(sign)(b);--i)
const int N=2e5+5;
template<typename T>bool cmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool cmin(T &a,T b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
template<typename T>void write(T x,char y)
{
	if(x==0)
	{
		putchar('0'),putchar(y);
		return;
	}
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	static char wr[20];
	int top=0;
	for(;x;x/=10)wr[++top]=x%10+'0';
	while(top)putchar(wr[top--]);
	putchar(y);
}
void file()
{
#ifndef ONLINE_JUDGE
	freopen("E.in","r",stdin);
	freopen("E.out","w",stdout);
#endif
}
int n;
typedef pair<ll,ll>pii;
#define mk make_pair
#define fir first
#define sec second
#define pb push_back
vector<pii>E[N],f[N],tl,tr;
ll l,r;
void input()
{
	int fa,w;
	n=read<int>();
	For(i,2,n)
	{
		fa=read<int>(),w=read<int>();
		E[fa].pb(mk(i,w));
		r+=w;
	}
}

ll Lim;
void insert(int u,pii t)
{
	if(f[u].size()&&f[u].back()<=t)return;
	while(f[u].size()&&f[u].back().sec>=t.sec)f[u].pop_back();
	f[u].pb(t);
}
bool DP(int u)
{
	f[u].clear();
	if(!E[u].size()){f[u].pb(mk(0,0));return true;}
	int ls=0,rs=0,dl=0,dr=0;
	for(pii t:E[u])
	{
		if(!DP(t.fir))return false;
		if(!ls)ls=t.fir,dl=t.sec;
		else   rs=t.fir,dr=t.sec;
	}
	tl.clear(),tr.clear();
	ll now=Lim-dl-dr;
	if(now<0)return false;
	for(int p1=0,p2=0;p2<f[rs].size();p2++)
	{
		while(p1<f[ls].size()&&f[ls][p1].fir+f[rs][p2].sec>now)p1++;
		if(p1==f[ls].size())break;
		tl.pb(mk(f[rs][p2].fir+dr,f[ls][p1].sec+dl));
	}
	for(int p1=0,p2=0;p1<f[ls].size();p1++)
	{
		while(p2<f[rs].size()&&f[ls][p1].sec+f[rs][p2].fir>now)p2++;
		if(p2==f[rs].size())break;
		tr.pb(mk(f[ls][p1].fir+dl,f[rs][p2].sec+dr));
	}
	int pl=0,pr=0;
	while(pl<tl.size()&&pr<tr.size())
	{
		if(tl[pl].fir>=tr[pr].fir)insert(u,tl[pl++]);
		else insert(u,tr[pr++]);
	}
	while(pl<tl.size())insert(u,tl[pl++]);
	while(pr<tr.size())insert(u,tr[pr++]);
	return f[u].size()>0;
}
bool check(ll limite)
{
	Lim=limite;	
	return DP(1);
}
void work()
{
	ll mid,ans=-1;
	while(l<=r)
	{
		mid=(l+r)>>1;
		if(check(mid))ans=mid,r=mid-1;
		else l=mid+1;
	}
	write(ans,'\n');
}
int main()
{
//	file();
	input();
	work();
	return 0;
}


Measured memory_bytes: 36828
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,a,b; cin >> n >> a >> b;
  cout << min(n*a,b) << endl;
}

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

int main() {
  int m;
  cin >> m;
  vector<string> blueCards(m);
  for(int i = 0; i < m; i++) {
    cin >> blueCards.at(i);
  }
  int n;
  cin >> n;
  vector<string> redCards(n);
  for(int i = 0; i < n; i++) {
    cin >> redCards.at(i);
  }

  int ans = 0;
  string current;
  int times = m;
  if(m < n) times = n;
  for(int i = 0; i < m; i++) {
 	current = blueCards.at(i); 
    int tmpAns = 0;
    for(int j = 0; j < times; j++) {
      if(j < blueCards.size() && blueCards.at(j) == current) tmpAns++;
      if(j < redCards.size() && redCards.at(j) == current ) tmpAns--;
    }
    if(tmpAns > ans) ans = tmpAns;
  }
	cout << ans << endl;  
  
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
int main()
{


  int n,m,x;
  int a[102];
  while(cin>>n>>m>>x)
  {
      int sum=0,sum2=0;
      memset(a,0,sizeof(a));
      int vis;
      while(m--)
      {
          cin>>vis;
          a[vis]=1;
      }
      for(int i=x;i<=n;i++)
      {
          if(a[i]==1)
            sum++;
      }
      for(int i=x;i>=0;i--)
        if(a[i]==1)
            sum2++;
      cout<<min(sum,sum2)<<endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int day[200],clo[200][3];
int dp[200][200];
int main(){
  int d,n;
  cin >>d>>n;
  for(int i=0; i<d; i++) cin >>day[i];
  for(int i=0; i<n; i++) for(int j=0; j<3; j++) cin >>clo[i][j];
  for(int i=0; i<d; i++) for(int j=0; j<n; j++) dp[i][j] = -1;
  for(int i=0; i<n; i++) if(clo[i][0]<day[0] && day[0]<clo[i][1]) dp[0][i] = 0;
  for(int i=1; i<d; i++){
    for(int j=0; j<n; j++){
      if(dp[i-1][j] == -1) continue;
      for(int k=0; k<n; k++){
	if(day[i]<clo[k][0] || clo[k][1]<day[i]) continue;
	dp[i][k] = max(dp[i][k],dp[i-1][j]+abs(clo[j][2]-clo[k][2]));
      }
    }
  }
  int ans = 0;
  for(int i=0; i<n; i++) ans = max(ans,dp[d-1][i]);
  cout <<ans<<endl;
  return 0;
}

Measured memory_bytes: 1320
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


int main() {
	char S[1000000];
	
	scanf("%s", S);
	int i;
	for(i = 0; i < strlen(S); i++) {
		if (S[i] == 'd') {
			if(S[++i] != 'r') {
				printf("NO");
				return 0;
			}
			if(S[++i] != 'e') {
				printf("NO");
				return 0;
			}
			if(S[++i] != 'a') {
				printf("NO");
				return 0;
			}
			if(S[++i] != 'm') {
				printf("NO");
				return 0;
			}
			if(S[i+1] == 'e') {
				if(S[i+2] == 'r') {
					if(S[i+3] != 'a') {
						i += 2;
					}
				}
			}
		} else if (S[i] == 'e') {
			if(S[++i] != 'r') {
				printf("NO");
				return 0;
			}
			if(S[++i] != 'a') {
				printf("NO");
				return 0;
			}
			if(S[++i] != 's') {
				printf("NO");
				return 0;
			}
			if(S[++i] != 'e') {
				printf("NO");
				return 0;
			}
			if(S[i + 1] == 'r')
					i++;
		} else {
			printf("NO");
			return 0;
		}
	}
	printf("YES");
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)    \
  for (auto v : (V)) { \
    cerr << v << " ";  \
  }                    \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> using vec = std::vector<T>;
template <class T> void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567, INF2 = INF * INF;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
#define MAXN 110
// bool flg[MAXN][MAXN];
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int W, H, N;
  cin >> W >> H >> N;
  // vec<vec<bool>> flg(H, vec<bool>(W, false));
  int xl = 0, xr = W, yl = 0, yr = H;
  REP(i, N) {
    int x, y, a;
    cin >> x >> y >> a;
    switch (a) {
      case 1:
        xl = max(xl, x);
        break;
      case 2:
        xr = min(xr, x);
        break;
      case 3:
        yl = max(yl, y);
        break;
      case 4:
        yr = min(yr, y);
        break;
    }
  }

  int area = (xr - xl) * (yr - yl);
  if ((xr - xl) > 0 && (yr - yl) > 0) {
    print(area);
  } else {
    print(0);
  }

  // print(count(ALL(flg), false));
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main{
 public static void main(String args[]){
  BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
  try{
   String str=br.readLine();
   int n[]=new int[3];
   while((str=br.readLine())!=null){
    StringTokenizer st=new StringTokenizer(str);
    for(int i=0;i<=2;i++){
     n[i]=Integer.parseInt(st.nextToken());
    }
    Arrays.sort(n);
    int a=(int)Math.pow(n[0],2);
    int b=(int)Math.pow(n[1],2);
    int c=(int)Math.pow(n[2],2);
    if(a+b==c){
     System.out.println("YES");
    }else{
     System.out.println("NO");
    }
   }
  }catch(Exception ex){
  }
 }
}

Measured memory_bytes: 18456
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	d := getInts(N)

	b := make([]int, N)
	b[N-1] = d[N-1]
	for i := N - 2; i >= 0; i-- {
		b[i] = b[i+1] + d[i]
	}
	ans := 0
	for i := 0; i < N-1; i++ {
		ans += d[i] * b[i+1]
	}

	out(ans)
}


Measured memory_bytes: 1776
#include<iostream>
using namespace std;
int main(){
  long long int A, V, B, W, T;
  cin >> A >> V;
  cin >> B >> W;
  cin >> T;
  if(abs(A-B) <= T*(V-W)){
      cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define VI vector<int>
#define PII pair<int, int>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
const int INF=1<<30; const ll LINF=1LL<<60 ; const ll MOD=1e9+7 ;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//-------------------
struct pa{
    ll val;
    int x,y,z;
    pa(ll v, int x, int y, int z):val(v), x(x), y(y), z(z) {}
    bool operator <(const pa& right) const {
        if(this->val < right.val) return true;
        if(this->val > right.val) return false;
        if(this->x < right.x) return true;
        if(this->x > right.x) return false;
        if(this->y < right.y) return true;
        if(this->y > right.y) return false;
        if(this->z < right.z) return true;
        else return false;
    }
};

int x,y,z,k;
const int MX = 1005;
//ll sm[MX][MX][MX];
vector<ll> a,b,c;
priority_queue<pa> pq;

int main(){

    cin >> x >> y >> z >> k;
    set<pa> s;

    FOR(i,0,x-1){
        ll m; cin >>m; a.push_back(m);
    }
    FOR(i,0,y-1){
        ll m; cin >> m; b.push_back(m);
    }
    FOR(i,0,z-1){
        ll m; cin >> m; c.push_back(m);
    }
    sort(ALL(a), greater<ll>()); sort(ALL(b),greater<ll>()); sort(ALL(c), greater<ll>());

    //sm[0][0][0] = a[0] + b[0] + c[0];
    pa now(a[0]+b[0]+c[0], 0,0,0);
    pq.push(now);
    FOR(i,1,k){
        pa cur = pq.top(); pq.pop(); 
        cout << cur.val << endl;// << cur.val << cur.x << cur.y << cur.z << endl;
        
        pa now1(a[cur.x+1] + b[cur.y] + c[cur.z],cur.x+1, cur.y, cur.z);
        pa now2(a[cur.x] + b[cur.y+1] + c[cur.z],cur.x, cur.y+1, cur.z);
        pa now3(a[cur.x] + b[cur.y] + c[cur.z+1],cur.x, cur.y, cur.z+1);
    
        if(s.find(now1)==s.end() && cur.x+1<=x-1){
            s.insert(now1);
            pq.push(now1);
        }
        if(s.find(now2)==s.end() && cur.y+1 <= y-1){
            s.insert(now2);
            pq.push(now2);
        }
        if(s.find(now3)==s.end() && cur.z+1 <=z-1){
            s.insert(now3);
            pq.push(now3);
        }
    }
    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,i,x=0;
	cin>>a>>b;
	if(a<=0 && b>=0)
		{
			cout<<"Zero"<<endl;
			return 0;
		}
	for(i=a;i<=b;i++)
	{
		if(i<0)
		{
			x++;
		}
	}
	if(x%2!=0)
	{
		cout<<"Negative"<<endl;
	}
	else
	{
		cout<<"Positive"<<endl; 
	}
}

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

int main()
{
  int n, m;
  cin >> n >> m;
  vector<int> a(n * m, -1);
  int i, j, k;
  for(i = 0; i < n; i++)
  {
    cin >> k;
    for(j = 0; j < k; j++)
    {
      cin >> a.at(i*m+j);
    }
  }
  vector<int> aa(m);
  for(i = 0; i < n*m; i++)
  {
    if(a.at(i) != -1)
    {
      aa.at(a.at(i)-1)++;
    }
  }
  int ans = 0;
  for(i = 0; i < m; i++)
  {
    if(aa.at(i) == n)
    {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

vector<string> dfs(string s, ll depth, vector<char> symbol)
{
    vector<string> ret;
    if (depth == 0)
    {
        ret.push_back(s);
        return ret;
    }

    for (ll i = 0; i < symbol.size(); i++)
    {
        auto vec = dfs(s + symbol[i], depth - 1, symbol);
        for (auto &&e : vec)
        {
            ret.push_back(e);
        }
    }
    return ret;
}

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return b;
    }
    return gcd(b, a % b);
}

int main()
{
    ll N, K;
    cin >> N >> K;

    string s;
    cin >> s;

    s[K-1] += 32;
    cout << s << endl;
}

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

using namespace std;

int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    cout << a[n/2] - a[n/2-1] << endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;
import java.lang.String;
public class Main
{
	public static void main(String args[])
	{
		Scanner input = new Scanner(System.in);
		int[] sum = new int[55];
		String s;
		int b;
		while (input.hasNext())
		{
			s = input.next();
			for(int i = 0; i < s.length(); i++)
			{
				if(s.charAt(i) >= 'A' && s.charAt(i) <= 'Z')
				{
					b = (int)(s.charAt(i)-'A');
					sum[b]++;
				}
				else if(s.charAt(i)>='a' && s.charAt(i)<='z') {
					b = (int)(s.charAt(i)-'a');
					sum[b]++;
				}
			}
		}
		for(int i = 0; i < 26; i++)
		{
			System.out.println((char)('a' + i) + " : " + sum[i]);
		}
	}
}

Measured memory_bytes: 26332
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#define MAXN 250
#define ll long long
using namespace std;

int vis[MAXN];
int prime[MAXN];
int id = 0;
void sieve(){
	for(int i = 2;i <= MAXN;i++){
		if(!vis[i]){
			for(int j = i * i;j <= MAXN;j += i){
				vis[j] = 1;
			}
		}
	}
	
	for(int i = 2;i <= MAXN;i++){
		if(!vis[i]){
			prime[id++] = i;
		}
	}
}
int mpow(int x,int p){
	int ans = 1;
	for(int i = 1;i <= p;i++) ans *= x;
	return ans;
}

int main(){
	int n;
	scanf("%d",&n);
	if(n < 105) {
		printf("0");	
		return 0;
	}
	sieve();
	int ans = 0;
	vis[1] = 1;
	for(int i = 105;i <= n;i++){
		for(int j = 2;j <= i;j++) vis[j] = 0;
		int num = i;
		for(int z = 0;z < id;z++){
			int k = 0;
			while(num % prime[z] == 0){
				k++;
				num /= prime[z];
				vis[mpow(prime[z],k)] = 1;
				vis[i / mpow(prime[z],k)] = 1;
			}
		}
		int cnt = 0;
		vis[i] = 1;
		for(int j = 1;j <= i;j++) if(vis[j]) cnt++;
		//printf("%d\n",cnt);
		if(cnt == 8 && (i & 1)) ans++;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
// RAM RAM

#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define ppb pop_back
#define vi vector<int>
#define mp make_pair
#define arrayin(a,n) for(int i=0;i<n;i++){cin>>a[i];}
#define N 55

using namespace std;


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

    set<int> s;
    int a,b,c;cin>>a>>b>>c;
    s.insert(a);
    s.insert(b);
    s.insert(c);
    cout<<s.size()<<endl;
	return 0;
}

Measured memory_bytes: 256
from itertools import permutations


n, m = map(int, input().split())
path = [[False] * n for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    path[a][b] = True
    path[b][a] = True
ans = 0
for i in permutations(range(n), n):
    if i[0] == 0:
        for j in range(n):
            if j == n - 1:
                ans += 1
                break
            elif not path[i[j]][i[j + 1]]:
                break
print(ans)


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    if (a < b)
       cout << "a < b" << endl;
    else if (a > b)
       cout << "a > b" <<endl;
    else
       cout << "a == b" << endl;
     
    return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
    
using namespace std;
typedef long long ll;
    
int main()
{
    int N; cin >> N;
    int A; cin >> A;

    int zan = N%500;
    if (A < zan) {
        cout << "No";
    } else {
        cout << "Yes";
    }

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int main(){
    long long N, Q;
    cin >> N >> Q;
    long long sum = (N - 2)*(N - 2);
    vector<long long> tate(N), yoko(N);
    for(int i = 0; i < N; i++){
        tate[i] = N;
        yoko[i] = N;
    }
    int H = N, W = N;
    for(int i = 0; i < Q; i++){
        int t, x;
        cin >> t >> x;
        if(t == 1){
            if(x < W){
                for(int j = x; j < W; j++){
                    yoko[j] = H;
                }
                sum -= yoko[x] - 2;
                W = x;
            }
            else sum -= yoko[x] - 2;
        }
        else{
            if(x < H){
                for(int j = x; j < H; j++){
                    tate[j] = W;
                }
                sum -= tate[x] - 2;
                H = x;
            }
            else sum -= tate[x] - 2;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 6428
# -*- coding: utf-8 -*-

s=input()
n=len(s)

ans=0
tmp=0
for i in range(n):
    if s[i]=='A' or s[i]=='C' or s[i]=='G' or s[i]=='T':
        tmp=1
        for j in range(i+1,n):
            if s[j]=='A' or s[j]=='C' or s[j]=='G' or s[j]=='T':
                tmp+=1
            else:
                break
        if tmp>ans:
            ans=tmp
        
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
//#include"atcoder/all"
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
//using namespace atcoder;
typedef long long ll;
int main(){
  ll H,W,N,i,j,k,a,b;scanf("%lld%lld%lld",&H,&W,&N);
  set<pair<ll,ll>> black;
  vector<pair<ll,ll>> check;
  for(i=0;i<N;i++){
    scanf("%lld%lld",&a,&b);a--;b--;
    black.insert(make_pair(a,b));
    for(j=-1;j<=1;j++){
      for(k=-1;k<=1;k++){
        if(a+j >= 1 && a+j < H-1 && b+k >= 1 && b+k < W-1){
          check.emplace_back(make_pair(a+j,b+k));
        }
      }
    }
  }
  sort(check.begin(),check.end());
  check.erase(unique(check.begin(),check.end()),check.end());
  ll ans[10] = {},cnt;
  for(i=0;i<check.size();i++){
    cnt = 0;
    for(j=-1;j<=1;j++){
      for(k=-1;k<=1;k++){
        cnt += check[i].first+j >= 0 && check[i].first+j < H && check[i].second+k >= 0 && check[i].second+k < W && black.count(make_pair(check[i].first+j,check[i].second+k));
      }
    }
    ans[cnt]++;
  }
  ans[0] = (H-2)*(W-2)-accumulate(ans+1,ans+10,0LL);
  for(i=0;i<10;i++) printf("%lld\n",ans[i]);
}

Measured memory_bytes: 23660
import math

n = int(input())
ans = 0
if n== 0:
  print(0)
  exit()


if n%2 == 1:
  print(0)
else:
  for j in range(1,100):
    if n//((5**j)*2) == 0:
      break
    ans += n//((5**j)*2)
    
    
  print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>

using namespace std;

int main(){
  int N,M;
  cin>>N>>M;
  int s[100000],t[100000];
  for(int i=0;i<N;i++){
    cin>>s[i]>>t[i];
  }
  int P[100000];
  vector<pair<int,int> > ev;
  for(int i=0;i<M;i++){
    cin>>P[i];
    ev.emplace_back(P[i],-1);
  }
  sort(begin(P),begin(P)+M);
  auto bp=begin(P);
  auto ep=begin(P)+M;
  for(int i=0;i<N;i++){
    if(s[i]<t[i]){
      ev.emplace_back(s[i],3);
      ev.emplace_back(t[i],((upper_bound(bp,ep,t[i])-upper_bound(bp,ep,s[i]))%2==0)*2);
    }else{
      ev.emplace_back(t[i],((upper_bound(bp,ep,s[i])-upper_bound(bp,ep,t[i]))%2==0)*2+1);
      ev.emplace_back(s[i],2);
    }
  }
  sort(begin(ev),end(ev));
  int l=0;
  long long len=0;
  int ns[2]={};
  for(auto e:ev){
    len+=(e.first-l)*1LL*ns[1];
    l=e.first;
    if(e.second==-1){
      swap(ns[0],ns[1]);
    }else{
      ns[e.second>>1]+=(e.second%2)?1:-1;
    }
  }
  cout<<len<<endl;
}

Measured memory_bytes: 8416
#include<cstdio>
#include<cstring>
#include<iostream>
#include<map>
#include<queue>
using namespace std;

int main(){
	int a[200005];
	int n,t,i,T=0;
	scanf("%d%d",&n,&t);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(i=1;i<n;i++){
		if((a[i]-a[i-1])>=t) T=T+t;
		if((a[i]-a[i-1])<t) T=T+(a[i]-a[i-1]);   	   
	}
	T=T+t;
	printf("%d\n",T);
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

typedef long long int ll;

ll bit[100001];

ll read(ll n) {
	ll s = 0;
	while (n) {
		s += bit[n];
		n -= (-n & n);
	}
	return s;
}

void update(ll d, ll n) {
	while (n < 100001) {
		bit[n] += d;
		n += (-n & n);
	}
}

int main() {
	ll n, q, c, x, y;
	cin >> n >> q;
	for (ll i = 0; i < q; i++) {
		cin >> c >> x >> y;
		if (c == 0)update(y, x);
		else cout << read(y) - read(x - 1) << endl;
	}
}



Measured memory_bytes: 3884
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>  
#include <stdbool.h>   
#define inf (INT_MAX-1)
#define INF 9223372036854775807;
#define PI 3.14159265358979323846;
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
/*
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r)
*/
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r)
#define TYPE long long
#define ll long long
#define MEMSET(a) memset(a,0,sizeof(a))
#define MEMSET_U(a) memset(a,-1,sizeof(a))
#define bool    _Bool
const int mod = (int)1e09 + 7;

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF
#define DUMMY

int in(void) { int i; scanf("%d", &i); return i; }
long long llin(void) { long long i; scanf("%lld", &i); return i; }
double din(void) { double i; scanf("%lf", &i); return i; }
void chin(char s[]) { scanf("%s", s); }

void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }
int Max(int a, int b) { if (a > b) { return a; }return b; }
int Min(int a, int b) { if (a < b) { return a; }return b; }
long long llmax(long long a, long long b) { return a > b ? a : b; }
long long llmin(long long a, long long b) { return a < b ? a : b; }
double dmax(double a, double b) { return a > b ? a : b; }
double dmin(double a, double b) { return a < b ? a : b; }
//long long llmax(long long a, long long b) { return a > b ? a : b; }
//long long llmin(long long a, long long b) { return a < b ? a : b; }
//double dmax(double a, double b) { return a > b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); }
int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); }
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }

int N, M;
int visited[10];
int connected[10][10];
int ans;

void dfs(int, int);

int main() {
	scanf("%d %d", &N, &M);
	int i;

	for (i = 0; i < M; i++) {
		int a, b;
		scanf("%d %d", &a, &b);
		connected[a][b] = 1;
		connected[b][a] = 1;
	}
	dfs(1, 1);
	printf("%d\n", ans);


#ifdef DEBUGF
	getch();
#endif
	return 0;
}

void dfs(int now, int depth) {
	if (depth >= N) {
		ans++;
		return;
	}

	visited[now] = 1;

	for (int i = 1; i <= N; i++) {
		if (connected[now][i] == 1 && visited[i] == 0) {
			visited[i] = 1;
			dfs(i, depth + 1);
			visited[i] = 0;
		}
	}
}

Measured memory_bytes: 128
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

signed main() {
    int N, Q;
    cin >> N >> Q;

    vector<tuple<int, int, int>> events;
    for (int i = 0; i < N; i++) {
        int s, t, x;
        cin >> s >> t >> x;
        // -1: delete, 1: insert
        events.push_back(tuple<int, int, int>(s - x, 1, x));
        events.push_back(tuple<int, int, int>(t - x, -1 , x));
    }
    sort(events.begin(), events.end());

    vector<P> queries;
    for (int i = 0; i < Q; i++) {
        int d;
        cin >> d;
        queries.push_back({d, i});
    }
    sort(queries.begin(), queries.end());

    vector<int> ans(Q);
    set<int> stop_places;

    int q = 0;
    for (auto e : events) {
        while (q < Q && queries[q].first < get<0>(e)) {
            if (stop_places.empty()) {
                ans[queries[q].second] = -1;
            } else {
                ans[queries[q].second] = *stop_places.begin();
            }
            q++;
        }

        if (get<1>(e) == 1) {
            stop_places.insert(get<2>(e));
        } else {
            stop_places.erase(stop_places.find(get<2>(e)));
        }
    }

    while (q < Q) {
        ans[queries[q].second] = -1;
        q++;
    }

    for (int a : ans) cout << a << endl;

    return 0;
}

Measured memory_bytes: 26472