akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep2(i,i0,n) for(int i=i0;i<n;++i)

int main()
{
    int k;
    cin >> k;
    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << a[k-1] << endl;
    return 0;
}

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

ll N, M, U, V;
vector<ll> E[100000];
bool used1[200000], used2[200000];

ll dfs1(ll v) {
  if(used1[v]) return 0;
  used1[v] = true;

  ll ret = 1;
  for(ll u : E[v]) ret += dfs1(u);
  return ret;
}

ll dfs2(ll v, ll s) {
  if(used2[v + N * s]) return 0;
  used2[v + N * s] = true;

  ll ret = 1;
  for(ll u : E[v]) ret += dfs2(u, 1 - s);
  return ret;
}

int main(void) {
  cin >> N >> M;
  REP(i, 0, M) {
    cin >> U >> V; U--; V--;
    E[U].push_back(V);
    E[V].push_back(U);
  }

  ll iso = 0, even = 0, odd = 0;
  REP(i, 0, N) used1[i] = false;
  REP(i, 0, N * 2) used2[i] = false;
  REP(i, 0, N) if(!used1[i]) {
    ll z = dfs1(i), w = dfs2(i, 0);
    if(z == 1) iso++;
    else if(w == z) even++;
    else if(w == z * 2) odd++;
  }

  cout << odd * odd + (even * odd * 2) + even * even * 2 + (iso * (N - iso) * 2 + iso * iso) << endl;
}


Measured memory_bytes: 14720
N = int(input())

a = [0]*N
for i in range(N):
    a[i]=input()

result=[0]*4
for i in range(len(a)):
    if a[i] == "AC":
        result[0]+=1

    if a[i] == "WA":
        result[1]+=1

    if a[i] == "TLE":
        result[2]+=1

    if a[i] == "RE":
        result[3]+=1

print("AC x ",result[0])
print("WA x ",result[1])
print("TLE x ",result[2])
print("RE x ",result[3])


Measured memory_bytes: 15984
S=input()
count={'a':0,'b':0,'c':0,'d':0,'e':0,'f':0,'g':0,'h':0,'i':0,'j':0,'k':0,'l':0,'m':0,'n':0,'o':0,'p':0,'q':0,'r':0,'s':0,'t':0,'u':0,'v':0,'w':0,'x':0,'y':0,'z':0}
for i in range(len(S)):
    count[S[i]]+=1

ans=[]
for key, value in count.items():
    if value==0:
        ans.append(key)

if len(ans)==0:
    print('None')
else:
    ans=sorted(ans)
    print(ans[0])

Measured memory_bytes: 3316
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include <bits/stdc++.h>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007


#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(int a,int b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
 

 
int main() {
    ll N,T,A;
    cin >>N;
    cin >>T>>A;
    double H[N];
    double ondo[N];

    FOR(i,0,N-1){
      cin>>H[i];
    }

    FOR(i,0,N-1){
      ondo[i]=T-H[i]*0.006-A;
      if(ondo[i]<0){ondo[i]=-ondo[i];}

    }
    double diff=9999999999;
    int no=0;
    FOR(i,0,N-1){
      if(diff>ondo[i]){
        diff=ondo[i];
        no=i+1;
      }
    }

    cout<<no<<endl;

  return 0;
}



Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aryssoncf
 */



// Taken from: https://github.com/bqi343/USACO/blob/master/Implementations/content/contest/templateShort.cpp

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ull> vul;
typedef vector<ll> vl;
typedef vector<pii> vpii;

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

#define mp make_pair
#define pb push_back
#define f first
#define s second

const int MOD = 1e9+7; // 998244353; // = (119<<23)+1
const int MX = 2e5+5;

template<class T> bool ckmin(T& a, const T& b) {
    return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) {
    return a < b ? a = b, 1 : 0; }

mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());


//
// Created by aryssoncf on 28/10/2019.
//

#include <type_traits>


#include <iterator>
#include <utility>

template <typename T>
constexpr auto hasBegin(int) -> decltype(std::begin(std::declval<T>()), true) {
    return true;
}

constexpr bool hasBegin(...) {
    return false;
}

template <typename T>
using IsContainer = std::integral_constant<bool, hasBegin<T>(0)>;


#ifndef JHELPER_EXAMPLE_PROJECT_IO_HPP
#define JHELPER_EXAMPLE_PROJECT_IO_HPP

#endif //JHELPER_EXAMPLE_PROJECT_IO_HPP

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

template<typename T, typename U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
    is >> p.first;
    is >> p.second;
    return is;
}

template <class X, class Y>
std::ostream & operator << (std::ostream & os, std::pair <X, Y> const& p) {
    return os << p.first << " " << p.second;
}

template <class Ch, class Tr, class Container>
std::basic_ostream <Ch, Tr> & operator << (std::basic_ostream <Ch, Tr>& os, Container const& x) {
    bool first = true;
    for(auto& y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

using namespace std;

class CGreenBin {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n;
        in >> n;
        vector<string> vs(n);
        in >> vs;
        map<string, int> counter;
        trav(str, vs) {
            sort(all(str));
            counter[str]++;
        }
        ll res = 0;
        for (auto[_, c]: counter) {
            res += (ll)c * (c - 1) / 2;
        }
        out << res << '\n';
	}

	void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
	CGreenBin solver;
    solver.setup();
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 14288
#include <stdio.h>
#include <string.h>

int main(void)
{
  char s[500001];
  char *p1 = &s[200000];
  scanf("%s", p1);
  char *p2 = p1 + strlen(p1);
  int q;
  scanf("%d", &q);
  int flag = 1;
  for (int i = 0; i < q; i++) {
    int n, f;
    char c;
    scanf("%d", &n);
    if (n == 1) {
      flag = 1 - flag;
      continue;
    }
    scanf("%d %c", &f, &c);
    if (flag ^ --f) {
      *--p1 = c;
    } else {
      *p2++ = c;
    }
  }
  *p2 = '\0';
  if (flag) {
    puts(p1);
  } else {
    while (--p2 >= p1) {
      putchar(*p2);
    }
    putchar('\n');
  }
}


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

const ll mod = 1e9 + 7;

long long gcd(ll x, ll y){
	if(x > y) swap(x, y);
	while(x != 0){ y %= x; swap(x, y); }
	return y;
}

ll mpow(ll x, ll r){
	if(r == 0) return 1;
	if(r % 2 == 1){ return x * mpow(x, r-1) % mod; }
	else{ ll aa = mpow(x, r/2); return aa*aa%mod; }
}

long double pi = 3.14159265358979;
int num[200010];


int main(){
	ll N, K; cin >> N >> K;
	ll ans = 0;
	for(ll i=K; i<=N+1; i++){
		ans = (ans + ((2*N-i+1)*i)/2 - (i*(i-1))/2 + 1) % mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
using namespace std;
  
int main(){
  int N;
  cin >> N;
  int res[4] = {}; 
  string S; 
  for(int i=0; i < N; i++){
    cin >> S;
    if(S == "AC")res[0]++;
    if(S == "WA")res[1]++;
    if(S == "TLE")res[2]++;
    if(S == "RE")res[3]++;
  }
  cout << "AC x " << res[0] << endl;
  cout << "WA x " << res[1] << endl;
  cout << "TLE x " << res[2] << endl;
  cout << "RE x " << res[3] << endl;
  return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<(n);i++)
#define init(a,i) for(int k=0;k<(i);k++)(a)[k]=0
#define in(a,i) for(int k=0;k<(i);k++)cin>>(a)[k]
#define all(a)  (a).begin(),(a).end()
#define el(a) (a).end()-(a).begin()

int main(){
	int n,m;
	cin>>n>>m;
	int a[n];
	in(a,n);
	ll b=a[0],c=a[0];
	rep(i,n){
		b=gcd(b,a[i]);
		c=lcm(c,a[i]);
	}
	b/=2;
	c/=2;
	if((c/b)%2==0){
		cout<<0;
		return 0;
	}
	cout << (m/c+1)/2;
	return 0;
}

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

#define int long long
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define fr(i,j,k) for(i = j; i < (k); i++)
#define all(x) x.begin(), x.end()
#define el '\n'
#define remax(a,b) a = max(a, b)
#define remin(a,b) a = min(a, b)
#define sz(x) int32_t(x.size())

typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpi;
// --------------------------------------------------------------------

const pii dxy[] = { {-1, 0}, {1, 0}, {0, 1}, {0, -1} };
const int mod = 1e9 + 7;
const int INF = 2e18;
const ld EPS = 1e-9;
const int NN = 1e5 + 2;


void solve() {
      int i = 0, j = 0, k = 0, n = 0, m = 0; 
      int a, b, c;
      cin >> a >> b >> c >> k;
      if(k <= a) cout << k << el;
      else if(k <= a+b) cout << a << el;
      else cout << (a - (k - (a+b))) << el;
      
}

int32_t main() {
      ios::sync_with_stdio(false); cin.tie(0); 
      int T = 1; 
      // cin >> T;
      for(int tc = 1; tc <= T; tc++) {
            solve();
       }
      return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W;
  cin >> H >> W;
   vector<vector<char>> datain(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
     for (int j = 0; j < W; j++) {
       cin >> datain.at(i).at(j) ;
     }
  }  
   vector<vector<char>> dataout(H+2, vector<char>(W+2,'#'));
      for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
          dataout.at(i+1).at(j+1) = datain.at(i).at(j);
        }
      }
  
      for (int i = 0; i < H+2; i++) {
        for (int j = 0; j < W+2; j++) {
          cout << dataout.at(i).at(j) ;
          if (j == W+1) {
            cout << endl; // 末尾なら改行
          }
        }
      }
}
  

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
int W;
int H;
int x;
int y;
int r;
scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

if(r+x>W){
printf("No\n");
}else if(x-r<0){
printf("No\n");
}else if(r+y>H){
printf("No\n");
}else if(y-r<0){
printf("No\n");
}else{
printf("Yes\n");
}
return 0;
}


Measured memory_bytes: 2100
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define bg begin()
#define en end()
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

#define pr_arr(name, a, b) \
  for (int i = (a); i < (b); i++) { \
    for (int j = (a); j < (b); j++) {\
      if (j > (a)) printf(" "); \
      printf("%lld", name[i][j]); \
    }\
    printf("\n");\
  }\

#define YES puts("YES")
#define NO  puts("NO")
#define Yes puts("Yes")
#define No  puts("No")

using namespace std;

typedef long long ll;

int ans, N;
char S[100005];


int main(void) {
    scanf("%d", &N);
    scanf("%s", S);

    rep(i, 0, strlen(S)) {
      int t = S[i] - 'A';
      t = (t+N)%26;
      S[i] = t + 'A';
    }
   

  
    printf("%s\n", S);

	return 0;
}


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

#define debug(x) cerr << #x << " = " << x << endl

const int N_MAX = 1003;
string s[N_MAX];

const int mod = 1e9 + 7;
int power(int x, long long y) {
  int ret = 1;
  while (y > 0) {
    if ((y & 1) == 1)
      ret = 1ll * x * ret % mod;
    x = 1ll * x * x % mod, y >>= 1;
  }
  return ret;
}

struct Matrix {
  int a, b, c;
  Matrix() {}
  Matrix(int _a, int _b, int _c) : a(_a), b(_b), c(_c) {}
  Matrix(int x) : a(x), b(0), c(x) {}
  friend Matrix operator*(const Matrix &lhs, const Matrix &rhs) {
    return Matrix(1ll * lhs.a * rhs.a % mod,
                  (1ll * lhs.a * rhs.b + 1ll * lhs.b * rhs.c) % mod,
                  1ll * lhs.c * rhs.c % mod);
  }
};
Matrix power(Matrix x, long long y) {
  Matrix ret = Matrix(1);
  while (y > 0) {
    if ((y & 1) == 1)
      ret = x * ret;
    x = x * x, y >>= 1;
  }
  return ret;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int H, W;
  long long K;
  cin >> H >> W >> K;
  int cntB = 0;
  for (int i = 0; i < H; ++i) {
    cin >> s[i];
    for (int j = 0; j < W; ++j)
      cntB += s[i][j] == '#';
  }
  int HC = 0, VC = 0;
  for (int i = 0; i < H; ++i)
    HC += s[i][0] == '#' && s[i][W - 1] == '#';
  for (int j = 0; j < W; ++j)
    VC += s[0][j] == '#' && s[H - 1][j] == '#';
  
  if ((HC > 0 && VC > 0) || K == 0) {
    cout << 1 << endl;
    return 0;
  }
  if (HC == 0 && VC == 0) {
    cout << power(cntB, K - 1) << endl;
    return 0;
  }
  
  if (HC > 0) {
    int cntC = 0;
    for (int i = 0; i < H; ++i)
      for (int j = 1; j < W; ++j)
        cntC += s[i][j - 1] == '#' && s[i][j] == '#';
    Matrix ans = power(Matrix(cntB, -cntC, HC), K - 1);
    cout << ((ans.a + ans.b) % mod + mod) % mod << endl;
  }
  else {
    int cntC = 0;
    for (int i = 1; i < H; ++i)
      for (int j = 0; j < W; ++j)
        cntC += s[i - 1][j] == '#' && s[i][j] == '#';
    Matrix ans = power(Matrix(cntB, -cntC, VC), K - 1);
    cout << ((ans.a + ans.b) % mod + mod) % mod << endl;
  }
  return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#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 REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); if (n == 0) cout << endl; REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

class BIT
{
public:
    vector<int> bit;
    int M;

    BIT(int M):
        bit(vector<int>(M+1, 0)), M(M) {}

    int sum(int i) {
        if (!i) return 0;
        return bit[i] + sum(i-(i&-i));
    }

    void add(int i, int x) {
        if (i > M) return;
        bit[i] += x;
        add(i+(i&-i), x);
    }
};

void solve() {
    int n, q;
    cin >> n >> q;
    vi c(n);
    REP(i, n) {
        cin >> c[i];
        c[i]--;
    }
    
    BIT bit(n + 1);
    vi s(n, -1);
    vector<tuple<int, int, int>> query(q);
    int l, r;
    REP(i, q) {
        cin >> l >> r;
        l--;
        r--;
        query.emplace_back(r, l, i);
    }
    SORT(query);
    int p = -1;
    vi ans(q);
    int idx;
    for (auto m : query) {
        tie(r, l, idx) = m;
        FOR(i, p + 1, r + 1) {
            if (s[c[i]] != -1) bit.add(s[c[i]] + 1, -1);
            bit.add(i + 1, 1);
            s[c[i]] = i;
        }
        p = r;
        ans[idx] = bit.sum(r + 1 + 1) - bit.sum(l);
    }
    printlnv(ans);
}


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

using namespace std;
constexpr long long int mod = 1000000007;

int main() {
	bitset<12> tester;
	int N,M,X;
	cin >> N >> M >> X;
	vector<int> price(N);
	vector < vector<int>> learn(N,vector<int>(M));
	for (size_t i = 0; i < N; i++)
	{
		cin >> price.at(i);
		for (size_t j = 0; j < M; j++)
		{
			cin >> learn.at(i).at(j);
		}
	}
	int ans = mod;
	for (size_t i = 0; i < (1<<12); i++)
	{
		int testable = 0;
		bool pass = true;
		vector<int>avil(M,0);
		tester = i;
		for (size_t j = 0; j < N; j++)
		{
			if (tester.test(j)) {
				testable += price.at(j);
				for (size_t k = 0; k < M; k++)
				{
					avil.at(k) += learn.at(j).at(k);
				}
			}
		}
		for (size_t j = 0; j < M; j++)
		{
			if (avil.at(j) < X)pass = false;
		}
		if (pass)ans = min((int)ans, testable);
		//cout << ans<<endl;
	}
	if (ans == mod)cout << -1;
	else cout << ans;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


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

    ll h;
    ll ans = 0;
    rep(i, N){
        cin >> h;
        if(h >= K){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3596
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            Double[] list = Arrays.stream(sc.nextLine().split(" ")).map(Double::parseDouble).toArray(Double[]::new);
            System.out.println((float)((list[2]-list[0])*(list[6]-list[4]))+(float)((list[3]-list[1])*(list[7]-list[5]))==0.0?"YES":"NO");
        }
    }
}



Measured memory_bytes: 31920
n, m = map(int, input().split())

sw_li = [list(map(int, input().split())) for _ in range(m)]
p_li = list(map(int, input().split()))

count = 0
for i in range(2**n):
    tf = True
    on_li = format(i, "b").zfill(n)
    
    for index, j in enumerate(sw_li):
        sum = 0
        for k in j[1:]:
            sum += int(on_li[n - k-1])
        if sum % 2 != p_li[index]:
            tf = False
            break

    if tf :
        count+= 1

print(count)
                

Measured memory_bytes: 3064
import itertools
 
N,M,Q=map(int,input().split())
all=[]
for i in range(Q):
  all.append(list(map(int,input().split())))
 
x=[i for i in range(1,M+1)]
maxdsum=0
 
for A in itertools.combinations_with_replacement(x, N):
  dsum=0
  for num in range(Q):
    if A[all[num][1]-1]-A[all[num][0]-1]==all[num][2]:
      dsum+=all[num][3]
  if maxdsum<dsum:
    maxdsum=dsum
print(maxdsum)

Measured memory_bytes: 9096
#include<iostream>
using namespace std;
int main(){
	int x[10001] = { 0 };
	for (int i = 1; i <= 10000; i++){
		cin >> x[i];
		if (x[i] == 0)break;
	}
	for (int i = 1; i <= 10000
		; i++){
		cout << "Case " << i << ": " << x[i] << endl;
		if (x[i] == 0)break;
	}
	return 0;
}

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

struct data
{
	int num,ptr;
	bool operator<(const data &c) const
	{
		return (ptr!=c.ptr ? ptr>c.ptr : num<c.num);
	}
};

int main()
{
	int t,i,j,n;
	data tmp;
	while(cin >> n, n)
	{
		vector<data> rank;
		for(int k=0; k<n; k++)
		{
			vector<int> score;

			cin >> tmp.num;
			while(cin.peek() != '\n')
			{
				cin >> t;
				score.push_back(t);
			}
			score.push_back(0);
			score.push_back(0);

			tmp.ptr=0;
			for(i=j=0; i<10; i++)
			{
				if(score[j]==10)
				{
					tmp.ptr += score[j]+score[j+1]+score[j+2];
					j+=1;
				}
				else if(score[j]+score[j+1]==10)
				{
					tmp.ptr += score[j]+score[j+1]+score[j+2];
					j+=2;
				}
				else
				{
					tmp.ptr += score[j]+score[j+1];
					j+=2;
				}
			}
			rank.push_back(tmp);
		}
		sort(rank.begin(), rank.end());
		for(int k=0; k<n; k++)
		{
			cout << rank[k].num << " " << rank[k].ptr << endl;
		}
	}
}

Measured memory_bytes: 0
import java.util.*;
public class Main
{
	public static void main(String[] args)
	{
	  Scanner s=new Scanner(System.in);
	  int n=s.nextInt();
	  int k=n%1000;
	  if(k==0)
	  System.out.println("0");
	  else
	  System.out.println((1000-k));
	
	}
}

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

//defines
#define openin freopen("input.txt","r",stdin)
#define openout freopen("output.txt","w",stdout)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long
#define int long long
#define mod 1000000007
#define repr(i,x,y) for (__typeof(x) i=x;i>=y;i--)
#define rep(i,x,y) for (__typeof(x) i=x;i<=y;i++)
#define all(c) (c).begin(),(c).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

/* Print pair */
template <typename T,typename S>
ostream & operator << (ostream &os , const pair<T,S> &v) {
    os << "(" ;
    os << v.first << "," << v.second << ")" ;
    return os ;
}
/* Print vector */
template <typename T>
ostream & operator << (ostream &os , const vector<T> &v) {
    os << "[" ;
    int sz = v.size() ;
    for(int i = 0 ; i < sz ; ++i) {
        os << v[i] ;
        if(i!=sz-1)os << "," ;
    }
    os << "]\n" ;
    return os ;
}
/* Print set */
template <typename T>
ostream & operator << (ostream &os , const set<T> &v) {
    T last = *v.rbegin() ;
    os << "[" ;
    for(auto it : v) {
        os << it  ;
        if(it != last) os << "," ;
    }
    os << "]\n" ;
    return os ;
}
/* Print Map */
template <typename T,typename S>
ostream & operator << (ostream &os , const map<T,S> &v) {
    for(auto it : v) {
        os << it.first << " : " << it.second << "\n" ;
    }
    return os ;
}
int power(int a , int b)
{
    int res = 1 ;
    while(b)
    {
        if(b%2) {
            res = (res * a) % mod ;
        }
        b/=2 ;
        a = (a*a) % mod ;
    }
    return res ;
}

//debug
#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
        cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

int32_t main()
{
    fast;
    string s ; cin >> s ; 
    string ss = s ; reverse(all(s)) ; 
    if(s == ss) cout << "Yes\n" ; 
    else cout << "No\n" ; 
    return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;


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

	cin >> N >> M;
	int ans = MOD;
	for (int i = 0; i < N; i++) {
		cin >> L >> R;
		if (R <= M)ans = min(ans, (int)L);
	}
	if (ans == MOD)cout << "TLE\n";
	else cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

const ll mod = 1000000007;

int main(){
    int n;
    string s;
    cin >> n >> s;
    int ans = 1;
    rep(i, n - 1){
        if(s[i] != s[i+1]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3740
#include <bits/stdc++.h>
#define reg register

using namespace std;

typedef long long ll;
const int maxn = 100005;

inline ll read() {
    reg ll s = 0, t = 0; reg char ch = getchar();
    while (!isdigit(ch)) t |= ch == '-', ch = getchar();
    while (isdigit(ch)) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}

int n, a[maxn];

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    if (n == 1) { cout << a[1] << endl; return 0; }
    sort(a + 1, a + n + 1);
    double Ans = (a[1] + a[2]) / 2.0;
    for (int i = 3; i <= n; i++) Ans = (Ans + a[i]) / 2.0;
    cout << Ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    {
        int tmp;
        cin >> tmp;
    }
    int t;
    cin >> t;
    int cost, time, prevCost = 1001;
    int ans = 0;
    while (cin >> cost >> time) {
        if (time <= t) {
            if (cost <= prevCost) {
                ans = cost;
                prevCost = cost;
            }
        }
    }
    if (ans == 0) cout << "TLE" << endl;
    else cout << ans << endl;
}


Measured memory_bytes: 256
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, k = list(map(int, readline().split()))
    h = list(map(int, readline().split()))
    dp = [10 ** 20] * n
    dp[0] = 0
    for i in range(n):
        for j in range(i + 1, min(i + k + 1, n)):
            dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]))
    print(dp[-1])


if __name__ == '__main__':
    solve()


Measured memory_bytes: 52464
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;
#define pb push_back
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int mod = 1e9 + 7;
const int N = 16;
vector<pii> a[N];
void solve(){
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int k;
        cin >> k;
        for (int j = 0; j < k; ++j) {
            int x, y;
            cin >> x >> y;
            x--;
            a[i].pb({x, y});
        }
    }
    int ans = 0;
    for (int mask = 0; mask < (1 << n); ++mask) {
        vi u(n, 0);
        bool q = true;
        int cnt = 0;
        for (int i = 0; i < n; ++i) {
            if ((1 << i) & mask) cnt++;
            if (u[i] == 0) {
                if ((1 << i) & mask) u[i] = 2;
                else u[i] = 1;
            }
            else {
                if ((1 << i) & mask) {
                    if (u[i] != 2) {
                        q = false;
                        break;
                    }
                } else if (u[i] != 1) {
                    q = false;
                    break;
                }
            }
            if (u[i] == 1) continue;
            for (auto p : a[i]) {
                if (u[p.fi] == 0) u[p.fi] = p.se + 1;
                else if (u[p.fi] != p.se + 1) {
                    q = false;
                    break;
                }
            }
        }
        if (q) ans = max(ans, cnt);
    }
    cout << ans;
}
int main(){
    speed;
    int t = 1;
    //cin >> t;
    for (int i = 1; i <= t; ++i) {
        solve();
    }
}

Measured memory_bytes: 256
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        if (N % 2 == 1)
        {
            Console.WriteLine((N / 2) + 1);
        }
        else
        {
            Console.WriteLine(N / 2);
        }
    }
}


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

#ifdef _DEBUG
    #include "/home/v-o_o-v/deb.h"
    #define deb(x...)cerr << "[" << #x << "] = [";_print(x);
#else
    #define deb(x...)
#endif

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int a[5];
    for(int i = 0; i < 5; i++){
        cin >> a[i];
        if(a[i] == 0)cout << i + 1 << '\n';
    }
    return 0;
}
// Write Here


Measured memory_bytes: 3696
from collections import Counter
from functools import reduce

def binom(n, r):
    if n < r or n < 0 or r < 0: return 0
    
    if n - r < r: r = n - r
    if r == 0: return 1
    elif r == 1: return n

    numerator = [n - r + 1 + k for k in range(r)]  # (n-r+1)*(n-r+2)*...*(n-1)*n
    denominator = [1 + k for k in range(r)]         # 1*2*...*(r-1)*r

    # reduce prod(numerator)//prod(denominator)
    for p in range(2, r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1, r, p):
                numerator[k - offset] //= pivot
                denominator[k] //= pivot
    
    # calculate nCr
    return reduce(lambda x, y: x*y, numerator)

N = int(input())
*A, = map(int, input().split())
count = Counter(A)
use_all = {}
use_minus_one = {}
total = 0
for k, v in count.items():
    temp = binom(v, 2)
    total += temp
    use_all[k] = temp
    use_minus_one[k] = binom(v - 1, 2)
for a in A:
    ans = total - use_all[a] + use_minus_one[a]
    print(ans)

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

int main(){
	LL a[4];
	for(int i = 0; i < 4; i++) cin >> a[i];
	LL n;
	cin >> n;
	n *= 4;
	for(int i = 0; i < 3; i++){
		a[i+1] = min(a[i+1], 2*a[i]);
		//a[i] = min(a[i], a[i+1]);
	}
	LL ans = 0;
	ans += (n/8) * a[3]; n %= 8;
	ans += (n/4) * a[2]; n %= 4;
	ans += (n/2) * a[1]; n %= 2;
	ans += (n/1) * a[0]; n %= 1;
	cout << ans << endl;
}


Measured memory_bytes: 256
/* nuttela - Soham Chakrabarti */
 
#include <bits/stdc++.h>
 
using namespace std;
 
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL)
#define all(v) v.begin(),v.end()
#define pb push_back
#define FR(i,j,k) for(int i=j;i<k;i++)
#define FRR(i,j,k) for(int i=j;i>=k;--i)
#define ff first
#define ss second
#define Judge
 
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <ll,ll> pii;
 
const int N = 1e5 + 5;
const int M = 1e5 + 5;
const int inf = INT_MAX;
const int MOD = 1e9 + 7;

int32_t main() {

    IO;
    #ifndef Judge
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    // int t;
    // cin>>t;
    // while(t--) {
    int n,k;
    cin >> n >> k;
    map<ll,ll> mu;
    while(k--) {
        int d,x;
        cin >> d;
        FR(i,0,d) {
            cin >> x;
            mu[x]++;
        }
    }
    int ans=0;
    FR(i,1,n+1) {
        if(!mu.count(i))++ans;
    }
    cout << ans;
    // }   
    return 0;
}


Measured memory_bytes: 3596
n=int(input())
ab=[list(map(int,input().split())) for _ in range(n)]
ab.sort(key=lambda x:x[1])
f=1
now=0
for i in range(n):
    now+=ab[i][0]
    if now>ab[i][1]:
        f=0
        break
if f:
    print("Yes")
else:
    print("No")


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

using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll mod = 1000000007;


int main()
{
	int n, m;
	cin >> n >> m;
	cout << (n * (n - 1) / 2) + (m * (m - 1)) / 2 << endl; 
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getint(_T& a) {
	std::cin >> a;
}
template<class _T> static void getint(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}

static void ARC081C();

int main()
{
	ARC081C();
	fflush(stdout);
	return 0;
}

static void ARC081C()
{
	int N;
	getint(N);

	std::vector<LLONG> ai(N, 0);
	for (int i = 0; i < N; i++) {
		getint(ai[i]);
	}

	std::sort(ai.begin(), ai.end(), std::greater<LLONG>());

	LLONG e1 = 0, e2 = 0;
	LLONG now, bfr = 0;
	for (int i = 0; i < N; i++) {
		now = ai[i];
		if (now == bfr) {
			if (!e1) {
				e1 = now;
			}
			else {
				e2 = now;
				break;
			}
			now = 0;
		}
		bfr = now;
	}
	printf("%lld\n", e1 * e2);
}


Measured memory_bytes: 1024
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> as(n); cin >> as;
    vector<int> bs(n); cin >> bs;
    vector<int> cs(n - 1); cin >> cs;
    int ans = 0, prev = -2;
    for(int i = 0; i < n; i++){
        ans += bs[as[i] - 1];
        ans += prev + 1 == as[i] ? cs[prev - 1] : 0;
        prev = as[i];
    }
    cout << ans << '\n';
}


Measured memory_bytes: 256
/***
 **   A S M Atikur Rahman
 **   Update: 01-04-2020
***/

//#include <bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<cstring>
#include<time.h>
#include<limits.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<bitset>
#include<utility>
#include<iterator>
#include<algorithm>
#include<cassert>
#include<iomanip> ///setprecision


#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define sci(x) scanf("%d%*c", &(x))
#define sci2(x,y) scanf("%d%*c%d%*c", &(x), &(y))
#define sci3(x,y,z) scanf("%d%*c%d%*c%d%*c", &(x), &(y), &(z))
#define scll(x) scanf("%lld%*c", &(x))
#define scll2(x,y) scanf("%lld%*c%lld%*c", &(x), &(y))
#define scll3(x,y,z) scanf("%lld%*c%lld%*c%lld%*c", &(x), &(y), &(z))
#define scd(x) scanf("%lf%*c", &(x))
#define scd2(x,y) scanf("%lf%*c%lf%*c", &(x), &(y))
#define scstr(x) scanf("%s", x)
#define pfi(x) printf("%d", (x))
#define pfi2(x,y) printf("%d %d", (x), (y))
#define pfll(x) printf("%lld", (x))
#define pfll2(x,y) printf("%lld %lld", (x), (y))
#define pfd(x) printf("%f", (x))
#define pfstr(x) printf("%s", (x))
#define ps printf(" ")
#define pn printf("\n")
#define pfdot printf("..")

#define For(a,n) for(int i=(a); i<(n); i++)
#define rFor(n,a) for(int i=n-1; i>=0; i--)
#define trav(a,x) for (auto &a : x)
#define Mset(ara, val) memset(ara, val, sizeof(ara))

#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound

#define pi  (2*acos(0))


using namespace std;

using ll=long long;
using pii= pair<int,int>;
using pll= pair<long long, long long>;
using pcc= pair<char, char>;
using pdd= pair<double, double>;

#define V(a) vector<a>
using vi= vector<int>;
using vs= vector<string>;
using vll= vector<ll>;
using vpii= vector<pii>;
using vc= vector<char>;
using vd= vector<double>;

//ll POW(ll a,ll b){if(b==0)return 1;ll x=POW(a,b/2);x=(x*x);if(b&1)x=(x*a);return x;}
//ll Sqrt(ll a) { ll x=(ll)sqrt(a); if((x+1)*(x+1)==a) x++; return x; }

/*------------------------Bitmask--------------------------*/

//int Set(int n, int p){return n= n|(1<<p);}
//ll Set(ll n, ll p){return n= n|(1ll<<p);}
//int Reset(int n,int p){return n= n&(~(1<<p));}
//ll Reset(ll n,ll p){return n= n&(~(1ll<<p));}
//bool Check(int n, int p){return (bool) (n&(1<<p));}
//bool Check(ll n, ll p){return (bool) (n&(1ll<<p));}
//int Toggle(int n, int p){return n= n^(1<<p);}
//ll Toggle(ll n, ll p){return n= n^(1ll<<p);}

/*----------------------------------------------------------*/



/*------------------------Declarations------------------------*/

//priority_queue<int,vector<int>, greater<int>>  //priority queue sorted in increasing order

/*------------------------------------------------------------*/




int main( int argc, char *argv[] )
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stout);
    ll n, k;
    cin>>n>>k;
    cout<<min(n%k, k-(n%k))<<endl;


    return 0;
}

























Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();

    int a = A+B;
    int b = A-B;
    int c = A*B;
    
	System.out.println(Math.max(c,Math.max(a,b)));
      }
      }


Measured memory_bytes: 35636
def resolve():
    N = int(input())
    P = input().split()
    Q = input().split()
    Fac = [1] * (N+1)
    for i in range(1,N+1):
        Fac[i] = Fac[i-1] * i
    A = 0
    Alist = list(range(0,N))
    B = 0
    Blist = list(range(0,N))
    for i in range(N): 
        A += Alist[int(P[i]) - 1] * Fac[N-1-i]
        for j in range(int(P[i])-1, N):
            Alist[j] -= 1
        B += Blist[int(Q[i]) - 1] * Fac[N-1-i]
        for j in range(int(Q[i])-1, N):
            Blist[j] -= 1
    print(abs(A-B))
resolve()

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

#define ll long long

template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}

void solve() {
  int n; cin >> n;
  ll ans=1;
  int mod = 1e9 + 7;
  for(int i=1; i<=n; ++i) {
    ans*=i;
    ans%=mod;
  }
  cout << ans << '\n';

  return;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T=1;
  //cin >> T;
  while(T--) solve();

  return 0;
}


Measured memory_bytes: 3592
# BFS
# 現在の頂点、スコア、通過した頂点の数、を状態量としてもち、2*n個まで試す
# n個より多いものが最大になるのなら'inf'を出力
from collections import deque
from sys import stdin
def input():
    return stdin.readline().strip()

inf = float('inf')

n, m = map(int, input().split())

edge = [[] for _ in range(n)]
weight = [[] for _ in range(n)]
for _ in range(m):
    i, j, k = map(int, input().split())
    i -= 1
    j -= 1
    edge[i].append(j)
    weight[i].append(k)

seen = [-inf] * n
todo = deque([(0, 0, 1)])
while len(todo) > 0:
    node, score, num = todo.popleft()
    if num > 2 * n:
        break

    for i in range(len(edge[node])):
        if seen[edge[node][i]] < score + weight[node][i]:
            seen[edge[node][i]] = score + weight[node][i]
            todo.append((edge[node][i], score + weight[node][i], num + 1))
            if edge[node][i] == n - 1 and num >= n:
                print('inf')
                exit()

print(seen[n-1])

Measured memory_bytes: 94212
using System;
using System.Linq;
using System.Collections.Generic;

namespace Competition
{
    class Program
    {
        static void Main(string[] args)
        {
            var ab = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var A = ab[0]; var B = ab[1];

            var sum = 1;
            var res = 0;
            while(sum < B)
            {
                sum += A - 1;
                res++;
            }
            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
using namespace std;
int main() {
    string a[3];
    for(int i = 0 ; i < 3; ++i)cin>>a[i];
    string s = "";
    for(int i = 0 ; i < 3; ++i){
        s += a[i][0];
    }
    cout<<s<<"\n";
}


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

int fmin(int a,int b)
{
  if(a>b)
{
  return b;
}
else
{
  return a;
}
}

int main(void){
int N,M;
int D[1001],C[1001],DP[1001][1001];

cin >> N >> M;
for(int i=1;i<=N;i++){
    cin >> D[i];
}
for(int j=1;j<=M;j++){
    cin >> C[j];
}
for(int i=1;i<=N;i++){
    for(int j=1;j<=M;j++){
 DP[i][j]=-1;
    }
}

DP[1][1]=C[1]*D[1];
for(int j=2;j<=M;j++){
    DP[1][j]=fmin(C[j]*D[1],DP[1][j-1]);
    for(int i=2;i<=N;i++){
        if(DP[i][j-1]<0){
            DP[i][j]=DP[i-1][j-1]+C[j]*D[i];
        }
        else{
            DP[i][j]=fmin(DP[i][j-1],DP[i-1][j-1]+C[j]*D[i]);
        }
        if(DP[i-1][j-1]<0){DP[i][j]=-1;}
    }
}
cout << DP[N][M]<<endl;

}



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

int main(){
    int a[2],c;
    cin >> a[0] >> a[1] >> c;
    sort(a,a+2);
    if(a[0] <= c&&c <= a[1])cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
N,K,S = map(int,input().split(' '))

result = []
for i in range(N):
    if i < K:
        result.append(S)
    else:
        if S == 10**9:
            result.append(S-1)
        else: 
            result.append(S+1)
print(' '.join(map(str,result)))

Measured memory_bytes: 66336
#include<stdio.h>
int main(void){
int a, b;
	scanf("%d %d", &a, &b);

	if(a == b){
		printf("a == b\n");
	}
	else if(a > b){
		printf("a > b\n");
	}
	else{
		printf("a < b\n");
	}



	return 0;
}

Measured memory_bytes: 580
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int N,n;
	bool res=true;
	string S;
	cin>>S;
	N=S.length();
	n=(N-1)/2;
	for(int i=0;i<N;i++){
		if(S[i]!=S[N-i-1])res=false;
	}
	for(int i=0;i<n;i++){
		if(S[i]!=S[n-i-1])res=false;
	}
	for(int i=n+1;i<N;i++){
		if(S[i]!=S[N-i-1])res=false;
	}
	if(res)cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main() {

    int h,w; cin >>h>>w;
    vector<vector<char> > a(h+2, vector<char>(w+2, '#')); REP(i,h) REP(j,w) cin >> a[i+1][j+1];

    for (int i = 0; i < h+2; i++) {
        for (int j = 0; j < w+2; j++) {
            cout << a[i][j];
        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
import sys
from collections import deque, defaultdict
import copy
import bisect
input=sys.stdin.readline
#sys.setrecursionlimit(10 ** 9)
import math
import heapq

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

S = input()
renketu = [0]
renketu_sum = [0,0]

mozi = '1'
num = 0
for i in range(N):
	if mozi == S[i]:
		renketu[-1] += 1
		renketu_sum[-1] += 1
	else:
		renketu_sum.append(renketu_sum[-1]+1)
		renketu.append(1)
	mozi = S[i]
if len(renketu) % 2 == 0:
	renketu.append(0)
	renketu_sum.append(renketu_sum[-1])


length = 2*K + 1
if length >= len(renketu_sum):
	print(renketu_sum[-1])
else:
	max_num = 0
	for i in range(len(renketu_sum) - length):
		if i % 2 == 0:
			max_num = max(max_num, renketu_sum[i + length] - renketu_sum[i])
			#print(max_num, i, renketu,renketu_sum, length)
	print(max_num)

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

#define ll long long
#define MAXN 3010
using namespace std;

const ll mod = 998244353LL;
int A[MAXN];
int N, S;


ll dp2[MAXN];

int main()
{
	cin>>N>>S;
	ll ans = 0;
	for(int i = 1; i <= N; ++i)
		cin>>A[i];
	memset(dp2, 0, sizeof(dp2));
	dp2[A[N]] = 1;
	ans = ans + dp2[S] * N;
	for(int i = N - 1; i >= 1; --i)
	{
			if(A[i] < S)
				ans = (ans + dp2[S-A[i]] * i) % mod;
			if(A[i] == S)
				ans = (ans + (N-i+1)*i) % mod;
			for(int j = S; j > A[i]; --j)
			{
					dp2[j] += dp2[j-A[i]];
					dp2[j] %= mod;
			}
			
			dp2[A[i]] += (N-i+1);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
n, k = gets.chomp.split.map(&:to_i)
h = gets.chomp.split.map(&:to_i)

dp = Array.new(n, Float::INFINITY)
dp[0] = 0
dp[1] = dp[0] + (h[0] - h[1]).abs

(2..(n-1)).each do |i|
  (1..k).each do |j|
    rep = dp[i-j] + (h[i-j] - h[i]).abs
    dp[i] = rep if rep < dp[i]
  end
end

puts dp[n-1]

Measured memory_bytes: 12036
N=int(input())
ans = 0
for i in range(1,10):
  if i<=N:
    ans = ans + 1
for i in range(100,1000):
  if i<=N:
    ans = ans + 1
for i in range(10000,100000):
  if i<=N:
    ans = ans + 1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) sort((c).rbegin(),(c).rend())
#define UNIQUE(c) SORT(c); (c).erase(unique((c).begin(), (c).end()), (c).end());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
const double INF = 1e7;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


const LL MOD = 1e9 + 7;

inline LL mod_add(LL a, LL b) {
    return (a + b) % MOD;
}

inline LL mod_sub(LL a, LL b) {
    return (a + MOD - b) % MOD;
}

inline LL mod_mul(LL a, LL b) {
    return ((a % MOD) * (b % MOD)) % MOD;
}


void solve(string S){
	VVI dp;
	dp.resize(SZ(S) + 1);
	REP(i, SZ(dp)) {
		dp[i].resize(4);
	}
	map<char, int> conv;
	conv['A'] = 0;
	conv['B'] = 1;
	conv['C'] = 2;
	
	dp[SZ(S)][3] = 1;
	for (int i = SZ(S) - 1; i >= 0; i--) {
		int flag_q = 0;
		if (S[i] == '?') {
			flag_q = 1;
		}
		dp[i][3] = mod_mul((flag_q == 1) ? 3 : 1, dp[i + 1][3]);
		for (int j = 2; j >= 0; j--) {
			int flag_m = 0;
			if (flag_q == 1 || conv[S[i]] == j) {
				flag_m = 1;
			}
			dp[i][j] = mod_add(mod_mul((flag_q == 1) ? 3 : 1, dp[i + 1][j]), mod_mul((flag_m == 1) ? 1 : 0, dp[i + 1][j + 1]));
		}
	}
	cout << dp[0][0] << endl;
}


int main(){	
	string S;
	cin >> S;
	solve(S);
	return 0;
}



Measured memory_bytes: 5888