akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main()
{
    int A,B;
    cin >> A >> B;

    if( A+B == 3) cout << 3 << endl;
    else if( A+B == 5) cout << 1 << endl;
    else cout << 2 << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int b[110000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%d",b+i);
	long long ret=0;
	int sd=1;
	for(int i=0;i<a;i++){
		ret+=(b[i]-1)/sd;
		if((b[i]-1)/sd){
			b[i]=1;
		}
		sd=max(sd,b[i]+1);
	//	printf("%lld %d\n",ret,sd);
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
// #include "/usr/local/include/cxx_pretty_print/cxx_pretty_print.hpp"

using namespace std;
/* type aliases */
using i32 = int32_t; using ui32 = uint32_t; using i64 = int64_t; using ui64 = uint64_t; using i128 = __int128;
using f32 = float;   using f64  = double;   using f80 = long double;
using PII = pair<i32, i32>; using PLL = pair<i64, i64>; using PFF = pair<f32, f32>; using PDD = pair<f64, f64>;
using VB  = vector<bool>;   using VS  = vector<string>;
using VI  = vector<i32>;    using VL  = vector<i64>;    using VF  = vector<f32>;    using VD  = vector<f64>;
using VVI = vector<VI>;     using VVL = vector<VL>;     using VVF = vector<VF>;     using VVD = vector<VD>;
using VPI = vector<PII>;    using VPL = vector<PLL>;    using VPF = vector<PFF>;    using VPD = vector<PDD>;
/* constants */
constexpr i64 mod = 1000000007;                                // 10^9+7
constexpr i64 inf = 9000000000000000000;                       // 9*10^18
/* macros */
#define MAX(c)        *max_element(ALL(c))
#define MIN(c)        *min_element(ALL(c))
#define SIZE(c)       (i64)((c).size())                        // unsined int (size_t) -> int64_t
#define ALL(c)        (c).begin(), (c).end()
#define RALL(c)       (c).rbegin(), (c).rend()
#define REP(i, n)     for (i64 i=0; i<(i64)(n); ++i)           // 0 to n-1
#define REPD(i, n)    for (i64 i=(i64)(n)-1; i>=0; --i)        // n-1 to 0
/* debug */
#define debug(x)      cerr << #x << ": " << (x) << '\n'
#define debugvec(v)   for (size_t _ = 0; _ < (v).size(); ++_) {cerr << #v << '[' << _ << "]: " << (v)[_] << '\n';}
/* useful output */
auto print = [](auto x) {cout << (x) << '\n';};
template <class T> void printvec(T v, string sep=" ", string end="\n") {REP(i, SIZE(v)-1) cout << v[i] << sep; cout << v[SIZE(v)-1] << end;}
/* useful input */
VS splitstr(string s, char delim=' ') {VS v; string buf; stringstream ss{s}; while (getline(ss, buf, delim)) v.push_back(buf); return v;}




void Main() {
    i32 n, elm;
    i32 cnt{};
    cin >> n;
    for(i32 i = 1; i <= n; ++i) {
        cin >> elm;
        if (i % 2 == 1 && elm % 2 == 1) ++cnt;
    }
    print(cnt);
}


signed main() {
    cin.tie(nullptr);                                         // cin と cout の tie を切り高速化
    cout << fixed << setprecision(15);                        // 浮動小数点数が 1e-006 のように表示されることを防ぐ
    Main();
}

Measured memory_bytes: 3644
#include <iostream>

using namespace std;

int main() {
    int w, h, x, y, r;
    cin>> w >> h >> x >> y >> r;
    if(x - r < 0 || r + x > w || y + r > h || y - r < 0){
        cout<< "No" << endl;    
    }
    else{
    cout << "Yes" << endl;
    }
}


Measured memory_bytes: 3092
def resolve():
	n = int(input())
	div4 = 0
	div2 = 0
	divn = 0
	for i in list(map(int, input().split())):
		if i % 4 == 0:
			div4 += 1
		else:
			if i % 2 == 0:
				div2 += 1
			else:
				divn += 1
	if div2:
		divn += 1
	if div4 + 1 >= divn:
		print('Yes')
	else:
		print('No')
resolve()

Measured memory_bytes: 62704
#include <iostream>

int main(){
    int x, a, b;
    std::cin >> x >> a >> b;

    int da = abs(x - a);
    int db = abs(x - b);
    
    if(da < db){
        std::cout << "A" << std::endl;
    }else{
        std::cout << "B" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 504
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

/*#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;*/

int k, n, a[200010];

int main()
{
    cin.tie(0);ios_base::sync_with_stdio(false);
    cin >> k >> n;
    forn(i, n) cin >> a[i];
    int maxi = 0;
    forn(i, n-1) maxi = max(maxi, a[i+1] - a[i]);
    maxi = max(maxi, a[0] + k - a[n-1]);
    cout << k - maxi << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
const int Maxn = 10005;
int n, k, mini = 0x3f3f3f3f, maxi, cnt[Maxn], ct;
string S[Maxn], str, tmp;
int main()
{
	scanf("%d%d", &n, &k);
	cin >> str;
	for (int i = 0; i < n; i++)
		str += str[n - i - 1];
	for (int i = 0; i < 2 * n; i++)
		mini = min(mini, str[i] - 'a');
	for (int i = 0; i < 2 * n; i++)
	{
		if (str[i] - 'a' == mini) cnt[i] = cnt[i - 1] + 1;
		else cnt[i] = 0;
		maxi = max(maxi, cnt[i]);
	}
	int limit = min(n, maxi * ((1 << (min(15, k) - 1)) - 1));
	for (int i = 0; i < n; i++)
	{
		tmp = "";
		if (cnt[i + n] != maxi) continue;
		for (int j = i + n; j > i + limit; j--)
			tmp += str[j];
		S[++ct] = tmp;
	}
	sort(S + 1, S + 1 + ct);
	for (int i = 0; i < limit; i++)
		putchar(mini + 'a');
	for (int i = limit; i < n; i++)
		putchar(S[1][i - limit]);
	return 0;
}


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

int main()
{
    int N;
    cin >> N;
    int L[N];
    int sum = 0;
    int m = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> L[i];
        sum += L[i];
        m = max(m, L[i]);
    }

    if (sum - m > m)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int n; cin >> n;
    int sum = 0;
    vector<int> x(n);
    rep(i,n) {
        cin >> x[i];
        sum += x[i];
    }
    int ave1 = round(sum / n);
    int ave2 = (sum+n-1)/n;
    int ans1 = 0;
    int ans2 = 0;
    rep(i,n) {
        ans1 += (x[i]-ave1)*(x[i]-ave1);
        ans2 += (x[i]-ave2)*(x[i]-ave2);
    }
    cout << min(ans1, ans2) << endl;
    return 0;
}

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

int k;
string s;
signed main(){
    cin >> s >> k;
    int j=0;
    int ans=0;
    while(s[j]=='1'){
        ans++;
        j++;
    }
    if(k<=ans) cout<<1;
    else cout<<s[j];
}

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

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

    vector<int> C(4, 0);
    string S;
    for (int i = 0; i < N; i++)
    {
        cin >> S;
        if (S == "AC") C[0]++;
        else if (S == "WA") C[1]++;
        else if (S == "TLE") C[2]++;
        else if (S == "RE") C[3]++;
        else return 1;
    }

    cout << "AC x " << C[0] << endl;
    cout << "WA x " << C[1] << endl;
    cout << "TLE x " << C[2] << endl;
    cout << "RE x " << C[3] << endl;

    return 0;
}


Measured memory_bytes: 3624
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int x = Integer.parseInt(sc.next());
        int t = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int result = (int) Math.ceil((double) n / x) * t;

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


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

const double EPS  = 0.0000001;

int main()
{
  int t;
  while (cin >> t) {
    double E1 = 0.0;
    for (int i = 0; i < t; ++i) {
      int n, m;
      cin >> n >> m;

      double tmp = 0.0, valid = 0.0;
      for (int j = 0; j < m; ++j) {
	int v;
	double r;
	cin >> v >> r;
	tmp += v * r;
	valid += r;
      }
      E1 = max(E1, tmp / valid);
    }

    double E2 = 0.0, valid = 0.0;
    int p, q;
    cin >> p >> q;
    for (int i = 0; i < q; ++i) {
      int v;
      double r;
      cin >> v >> r;
      E2 += v * r;
      valid += r;
    }

    if (E1 - (E2/valid) > EPS)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <numeric>
#include <iomanip>
#include <climits>
#include <cstring>
#include <cmath>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)(n);++i)
#define rep1(i, n) for (int i=1;i<=(int)(n);++i)
#define rrep(i, n) for (int i=(int)(n)-1;i>=0;--i)
#define rrep1(i, n) for (int i=(int)(n);i>=1;--i)
#define range(i, l, r) for (int i=l;i<(int)(r);++i)
#define rrange(i, l, r) for (int i=(int)(r)-1;i>=l;--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

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

constexpr int TEN(int n){return n==0?1:10*TEN(n-1);}
template<typename T>bool chmin(T&a,T b){return a>b?(a=b,1):0;}
template<typename T>bool chmax(T&a,T b){return a<b?(a=b,1):0;}
int read(){int a;scanf("%lld",&a);return a;}

const long double pi = acos(-1);
constexpr int inf = 3*TEN(18) + 10;

struct UF {
	vi data, black, white;
	void init(int n)
	{
		data.resize(n);
		black.resize(n);
		white.resize(n);
		fill(all(data), -1);
		fill(all(black), 0);
		fill(all(white), 0);
	}
	int root(int x)
	{
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	void unite(int x, int y)
	{
		x = root(x);
		y = root(y);
		if (x == y) return;
		if (size(x) < size(y)) swap(x, y);
		data[x] += data[y];
		data[y] = x;
		black[x] += black[y];
		white[x] += white[y];
	}
	bool same(int x, int y)
	{
		return root(x) == root(y);
	}
	int size(int x)
	{
		x = root(x);
		return -data[x];
	}
	int calc(int x)
	{
		x = root(x);
		return black[x] * white[x];
	}
	bool is_root(int x)
	{
		return x == root(x);
	}
};

int H, W;
int a[405][405];
int dy[] = {-1, 0, 1, 0};
int dx[] = {0, -1, 0, 1};
bool done[400*400+10];

int encode(int y, int x)
{
	return y * W + x;
}

bool inside(int y, int x)
{
	return 0 <= y and y < H and 0 <= x and x < W;
}

UF uf;

signed main()
{
	cin >> H >> W;

	uf.init(H * W + 10);

	rep(i, H) rep(j, W) {
		char c; cin >> c;
		a[i][j] = c == '#';
		if (a[i][j]) uf.black[encode(i, j)]++;
		else uf.white[encode(i, j)]++;
	}

	rep(y, H) rep(x, W) {
		rep(k, 4) {
			int ny = y + dy[k], nx = x + dx[k];
			if (inside(ny, nx) and a[y][x] != a[ny][nx]) {
				uf.unite(encode(y, x), encode(ny, nx));
			}
		}
	}

	int ans = 0;

	rep(y, H) rep(x, W) {
		int id = uf.root(encode(y, x));

		if (done[id]) {
			continue;
		}

		ans += uf.calc(id);
		done[id] = true;
	}

	cout << ans << endl;
}




Measured memory_bytes: 8324
using System;
using System.Collections.Generic;
using System.Linq;
class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Long() + add;
        }
        return Array;
    }
}
class Program {
    static Scanner cin = new Scanner();
    static void Main() {
        int a = cin.Int();
        int b = cin.Int();
        int c = cin.Int();
        if(b > a * c) {
            Console.WriteLine(c);
        }
        else {
            Console.WriteLine(b / a);
        }
        Console.ReadLine();
    }
}

Measured memory_bytes: 13140
using Microsoft.VisualBasic.CompilerServices;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace Contest
{


    class Program
    {


        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            int count = 0;
            int max = 0;

            for(int i = 0; i < s.Length; i++)
            {
                if(s[i] == 'R')
                {
                    count++;
                    max = Math.Max(max, count);
                } else
                {
                    count = 0;
                }
            }

            Console.WriteLine(max);

        }

    }
}


Measured memory_bytes: 25916
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define MOD 1000000007
typedef long long ll;
using namespace std;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int x,y; cin >> x >> y;
    if(y-2*x >= 0 && (y-2*x)%2 == 0){
        int b = (y-2*x)/2;
        if(x-b>=0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3604
// Winners don't quit and Quitters don't win
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mod 998244353
#define MAX 100005
ll a[2*MAX];
ll prefix[2*MAX];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,k,i,j,x,c=0,p,ele,pos,xx;
    cin>>n>>k;
    for(i=1;i<=n;++i){
    	cin>>a[i];
	}
	//set <ll> s;
	vll v;
	p=1;
	x=a[p];
	while(prefix[p]==0){
		prefix[p]++;
		v.pb(p);
		c++;
		p=x;
		x=a[p];
	}
	ele=p;
	pos=-1;
	for(i=0;i<(ll)v.size();++i){
		if(v[i]==ele){
			pos=i;
			break;
		}
	}
	//cout<<pos<<'\n';
	//cout<<c<<'\n';
	if(k<pos){
		cout<<v[k]<<'\n';
		return 0;
	}
	k=k-pos;
	//cout<<k<<'\n';
	xx=c-pos;
	k=k%xx;
	//cout<<k<<'\n';
	cout<<(v[pos+k]);
}

Measured memory_bytes: 8380
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define print(ele) cout << (ele) << endl
#define print10(ele) cout << fixed << setprecision(10) << (ele) << endl

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

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

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

ll factorial(ll n) {
  ll answer = 1;
  while (n > 1) {
    answer *= n;
    answer %= mod;
    n--;
  }
  return answer;
}

ll combination(ll n, ll r) {
  return factorial(n) / (factorial(r) * factorial(n - r) % mod);
}

mint f(int n) {
  if (n == 0) return 1;
  mint x = f(n / 2);
  x *= x;
  if (n % 2 == 1) x *= 2;
  return x;
}

mint choose(int n, int a) {
  mint x = 1, y = 1;
  REP(i, a) {
    x *= n - i;
    y *= i + 1;
  }
  return x / y;
}

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  mint ans = f(n);

  ans -= 1;
  ans -= choose(n, a);
  ans -= choose(n, b);

  print(ans.x);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl "\n"
#define PI acos(-1)
#define BMW_GTR ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)

typedef long long ll;
using namespace std;

//ll const n = 50005;

int main()
{
   // BMW_GTR;

    char A[102], B[102], a[102], b[102];

    scanf("%s %s", &A, &B);

    for(int i = 0; i < 101; i++)
    {
        a[i] = '0';
        b[i] = '0';
    }

    int j = 100;
    for(int i = strlen(A) - 1; i >= 0; i--)
    {
        a[j] = A[i];
        j--;
    }

    j = 100;
    for(int i = strlen(B) - 1; i >= 0; i--)
    {
        b[j] = B[i];
        j--;
    }

    for(int i = 101 - max(strlen(A), strlen(B)); i < 101; i++)
    {
        if(a[i] > b[i])
        {
            printf("GREATER");
            break;
        }

        if(a[i] < b[i])
        {
            printf("LESS");
            break;
        }

        else
        {
            printf("EQUAL");
            break;
        }
    }

    return 0;
}


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

using namespace std;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
    ifstream t("/proc/self/status");
    cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getchar());
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) - '0' + ch;
	return sum * fg;
}

typedef long long LL;
typedef long double LD;
typedef pair<int, int> pii;

const int MOD = (int) 1e9 + 7;
const int MAXN = (int) 5e3;

int n;

vector<int> adj[MAXN + 5];

inline void input()
{
	n = read<int>();
	for(int i = 1; i < n; ++i)
	{
		int u = read<int>(), v = read<int>();
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
}

int g[MAXN + 5];

int size[MAXN + 5], f[MAXN + 5][MAXN + 5];

inline void dfs(int u, int fa)
{
	size[u] = 1, f[u][1] = 1;
	for(auto v : adj[u]) if(v != fa)
	{
		dfs(v, u);

		static int res[MAXN + 5];
		for(int i = 0; i <= size[u] + size[v]; ++i) res[i] = 0;

		for(int i = 1; i <= size[u]; ++i)
			for(int j = 0; j <= size[v]; ++j)
				(res[i + j] += (LL) f[u][i] * f[v][j] % MOD) %= MOD;

		size[u] += size[v];
		for(int i = 0; i <= size[u]; ++i) f[u][i] = res[i];
	}

	for(int i = 1; i <= size[u]; ++i) (f[u][0] += (LL) -f[u][i] * g[i] % MOD) %= MOD;
}

inline void solve()
{
	g[0] = 1, g[1] = 0;
	for(int i = 2; i <= n; ++i) g[i] = (LL) g[i - 2] * (i - 1) % MOD;

	dfs(1, 0);

	printf("%d\n", (-f[1][0] + MOD) % MOD);
}

int main()
{
//#ifndef ONLINE_JUDGE
//	freopen("E.in", "r", stdin);
//	freopen("E.out", "w", stdout);
//#endif

	input();
	solve();

	return 0;
}



Measured memory_bytes: 97152
#include <bits/stdc++.h>
int main(){
  int A, B, M, amin = 1e9, bmin = 1e9;
  std::cin >> A >> B >> M;
  std::vector<int> a(A), b(B);
  for(int i=0; i<A; i++) {
    std::cin >> a.at(i);
   	amin = std::min(amin, a.at(i));
  }
  for(int i=0; i<B; i++) {
    std::cin >> b.at(i);
    bmin = std::min(bmin, b.at(i));
  }
  int ans = amin + bmin;
  for(int i=0; i<M; i++) {
    int x,y,c;
    std::cin >> x >> y >> c;
    ans = std::min(ans, a.at(x-1)+b.at(y-1)-c);
  }
  std::cout << ans << '\n';
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void) {
	int H, W;
	while(1){
	    scanf("%d %d", &H, &W);
	    if(H==0 && W==0){
	    	break;
	    }
	    for(int i=0; i<H; i++){
	    	if(i%2==1){
	    		for(int j=0; j<W; j++){
	    		    if(j%2==1){
	    		    	printf("#");
	    	        }else{
	    	            printf(".");
	    		}
	    	}
	    	printf("\n");
	    }else{
	    	 for(int j=0; j<W; j++){
	    		    if(j%2==1){
	    		    	printf(".");
	    	        }else{
	    	            printf("#");
	    		}
	    	}
	    	printf("\n");
	    		
	    	}
	    }
	printf("\n");
	}

	return 0;
}



Measured memory_bytes: 2052
s = input()
t = " " + input()
line = [1]
next = 1
t_size = len(t)
flag = False
for i in s:
    if t[next] == i:
        line[0] += 1
        next = line[0]
        line += [0]
        j = 0
        while line[j] == t_size:
            line[j] = 0
            next = line[j + 1] = line[j + 1] + 1
            j += 1
        if line[-1] == 0:
            line.pop()
print(len(line) - 1)


Measured memory_bytes: 5864
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
int main(){
	std::ios::sync_with_stdio(false);
	int a,b;
	cin>>a>>b;
	if(a>8||b>8){
		cout<<":("<<endl;
	}
	else{
		cout<<"Yay!"<<endl;
	}
} 
	

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;
    Func cin2;
    void calc()
    {
        cin = new Scanner();
        cin2 = new Func();
        string s=cin.next();
        int ans=0;
        for(int i=0;i<4;i++)
        {
          if(s[i]=='+')ans++;
          else ans--;
        }
        Console.WriteLine(ans);
    }
}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Answer
{
    public static void Int2DArrayAns(int[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }//Answer.IntArrayAns(x);
    public static void Char2DArrayAns(char[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
}

class Func
{
    public long GCDLong(long a, long b)
    {
        while(a!=0)
        {
          long t=a;
          a=b%a;
          b= t;
        }
      
        return b;        
    }
}



Measured memory_bytes: 11092
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) throws Exception {
        InputStreamReader r = new InputStreamReader(System.in);
        int ans = 6;
        ans -= nextInt(r);
        ans -= nextInt(r);
        System.out.println(ans);
    }

    public static int nextInt(InputStreamReader r) throws Exception {
        String str = "";
        while (true) {
            int c = r.read();
            if (c == 32 || c == 10 || c == -1) {
                break;
            }
            str += (char)c;
        }
        return Integer.parseInt(str);
    }
}


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

struct node {
	node *l, *r;
	int cnt;
	node(node *l = nullptr, node *r = nullptr) : l(l), r(r), cnt(0) {}
};

class uint_Trie {
	node *root;
	int siz;
	int count(node *t) {
		return t == nullptr ? 0 : t->cnt;
	}
	unsigned get(node *t, int k, unsigned tmp, int b) {
		if (b < 0) return tmp;
		assert(t != nullptr);
		int c = count(t->l);
		return k < c ? get(t->l, k, tmp, b - 1) : get(t->r, k - c, tmp | (1 << b), b - 1);
	}
	node *add(node *t, unsigned val, int b) {
		if (t == nullptr) t = new node();
		t->cnt++;
		if (b < 0) return t;
		if (val & (1 << b)) {
			t->r = add(t->r, val, b - 1);
		}
		else {
			t->l = add(t->l, val, b - 1);
		}
		return t;
	}
	node *sub(node *t, unsigned val, int b) {
		assert(t != nullptr);
		t->cnt--;
		if (b < 0) {
			if (t->cnt == 0) {
				delete t;
				return nullptr;
			}
			return t;
		}
		if (val & (1 << b)) {
			t->r = sub(t->r, val, b - 1);
		}
		else {
			t->l = sub(t->l, val, b - 1);
		}
		if (t->cnt == 0) {
			delete t;
			return nullptr;
		}
		return t;
	}
	void print(node *t, unsigned val, int b) {
		if (t == nullptr) return;
		if (b < 0) {
			printf(" %d", (int)val);
			return;
		}
		print(t->l, val, b - 1);
		print(t->r, val + (1 << b), b - 1);
	}
public:
	uint_Trie() : root(nullptr) {}
	int size() {
		return count(root);
	}
	void insert(unsigned val) {
		root = add(root, val, 31);
	}
	void erase(unsigned val) {
		root = sub(root, val, 31);
	}
	bool find(unsigned val) {
		node *t = root;
		for (int i = 31; i >= 0; i--) {
			if (val & (1 << i)) {
				if (t->r == nullptr) return false;
				t = t->r;
			}
			else {
				if (t->l == nullptr) return false;
				t = t->l;
			}
		}
		return true;
	}
	unsigned max() {
		assert(count(root) >= 1);
		return get(root, count(root) - 1, 0, 31);
	}
	unsigned min() {
		assert(count(root) >= 1);
		return get(root, 0, 0, 31);
	}
	unsigned operator[](int k) {
		assert(0 <= k && k < count(root));
		return get(root, k, 0, 31);
	}
	void print() {
		print(root, 0, 31);
	}
};

int main()
{
	cin.sync_with_stdio(false);
	uint_Trie ut;
	string com;
	int k;
	while (cin >> com, com != "end") {
		if (com == "insert") {
			cin >> k;
			ut.insert(k);
		}
		else {
			int res = ut.max();
			printf("%d\n", res);
			ut.erase(res);
		}
	}
	return 0;
}

Measured memory_bytes: 3804
#include<vector>
#include<iostream>

using namespace std;

const int W = 1001;
const int N = 1001; 

int table[W][N];

void solve(int n,int lim, vector<int> price, vector<int> weight){
  int maxi_p = 0,maxi_w = 0;
  for(int i = 0;i < W;i++){
    for(int j = 0;j < N;j++){
      table[i][j] = 0;
    }
  }
  
  for(int i = 0;i < n;i++){
    table[weight[i]][i] = price[i]; 
  }
  
  
  for(int i = 0;i <=lim;i++){
    for(int j = 1;j < n;j++){
      table[i][j] = table[i][j-1]; 
      if(i - weight[j] < 0)continue;
      table[i][j] =max(table[i - weight[j]][j-1]+price[j],table[i][j-1]);
    } 
  }

  for(int i = 0;i <= lim;i++){
    if(maxi_p < table[i][n-1]){
      maxi_p = table[i][n-1];
      maxi_w = i;
    }

    
  }
  cout << maxi_p << endl; 
  cout << maxi_w << endl;
}  

int main(){
  int count = 1;
  int lim;
  int n;
  int price,weight;  
  while(cin >> lim >> n &&lim){

    vector<int> a,b;
    int tmp;
    char damy;
    cout << "Case "<< count <<":"<<endl;
    for(int i = 0;i < n;i++){
      cin >> price >> damy >> weight;
      a.push_back(price);
      b.push_back(weight);
    }
    
    solve(n,lim,a,b);
    count++;
  }
  return 0;
}

Measured memory_bytes: 0
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Sparsh Sanchorawala
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ADDCCFinals solver = new ADDCCFinals();
        solver.solve(1, in, out);
        out.close();
    }

    static class ADDCCFinals {
        public void solve(int testNumber, InputReader s, PrintWriter w) {
            int x = Math.min(4, s.nextInt()), y = Math.min(4, s.nextInt());
            int res = (4 - x) * 100000 + (4 - y) * 100000;
            if (x == 1 && y == 1)
                res += 400000;
            w.println(res);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



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

int main(void)
{
  char s[100] = {};
  int n;
  int count = 0;

  scanf("%s", s);

  n = strlen(s);

  for (int i = 0; i < n / 2; i++){
    if (s[i] != s[n-1-i]) count++;
    if (s[i] != s[(n/2) - 1 - i]) count++;
  }
  if (count == 0) printf("Yes\n");
  else printf("No\n");

  return 0;
}

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

using namespace std;

#define int long long

#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)

typedef pair<int, int> PII;

//--------



signed main(){  
    int H, W;
    cin >> H >> W;

    int h, w;
    cin >> h >> w;

    cout << H * W - (H * w + W * h - w * h) << endl;

    return 0;
}


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

using namespace std;

#define ll long long int
#define ld long double
#define loop(i, n) for (int i = 0; i < n; i++)
#define loops(i, s, n) for (int i = s; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
#define deb(x) cout<< #x << '=' << x <<endl
#define MOD 1000000007
const int N = 1e6 + 1;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int k;
    cin>>k;
    if(k % 2 == 0 || k % 5 == 0){
        cout<<"-1\n";
        return 0;
    }
    int val = 7 % k;
    for(int i = 1; i < N; i++){
        if(val == 0){
            cout<<i;
            break;
        }
        val = (val*10 + 7) % k;
    }
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <math.h>

int main(){
  int H,W,K;
  char S[10][1000];
  char s[1002];
  int pattern;
  
  scanf("%d %d %d",&H,&W,&K);
  
  for(int i=0;i<H;i++){
    scanf("%s",s);
    for(int j=0;j<W;j++)
      S[i][j] = s[j];
  }
  
  pattern = 1;
  for(int i=0;i<H-1;i++)
    pattern *= 2;

  int cut = 0;
  int min = H + W -2;
  for(int i=0;i<pattern;i++){
    int bit=1, count = 0;
    int cutH[9];
    int regionH[10], index=0;

    for(int j=0;j<H-1;j++){
      if( i & bit){
	cutH[index] = j;
	index += 1;
      }
      bit *= 2;
    }
    count += index;

    /*    printf("pattern%d [",i);
    for(int j=0;j<index;j++) printf("%d",cutH[j]);
    printf("]\n");*/
    
    for(int j=0;j<index+1;j++)
      regionH[j] = 0;
    
    for(int j=0;j<W;j++){
  
      /*      for(int k=0;k<index+1;k++)
	printf("%d\n",regionH[k]);
	printf( "----\n");*/
      int indexH=0;
      for(int k=0;k<H;k++){
	regionH[indexH] += (S[k][j] == '1');
	if(indexH < index && cutH[indexH]==k)
	  indexH += 1;
      }
      int flagH=0;
      for(int k=0;k<index+1;k++)
	if(regionH[k]>K)
	  flagH++;
      if(flagH){
	//	printf("cut!!\n");
	for(int k=0;k<index+1;k++)
	  regionH[k] = 0;
	indexH = 0;
	for(int k=0;k<H;k++){
	  regionH[indexH] += (S[k][j] == '1');
	  if(indexH<index &&cutH[indexH]==k)
	    indexH += 1;
	}
	count++;
	
	flagH=0;
	for(int k=0;k<index+1;k++)
	  if(regionH[k]>K)
	    flagH++;
	if(flagH) count=H+W-2;
      }
    }
    //    printf("count %d\n",count);
    if(count<min) min = count;
  }
  printf("%d\n", min);
}


Measured memory_bytes: 128
open System.Collections.Generic

type Scanner() = class
    let mutable hold = [||]
    let mutable index = 0
    member public this.Next() =
        if hold.Length > index
        then 
            index <- index + 1
            hold.[index - 1]
        else
            let mutable st = stdin.ReadLine()
            while st = "" do st <- stdin.ReadLine()
            hold <- st.Split(' ')
            if hold.Length = 0
            then
                this.Next()
            else
                index <- 1
                hold.[index - 1]
            
    member public this.NextI32() =
        this.Next() |> int

    member public this.ArrayI32(n: int) =
        [|for _ in 0 .. n - 1 -> this.NextI32()|]

    member public this.IArrayI32(n: int) =
        [|for i in 0 .. n - 1 -> this.NextI32(), i|]

    member public this.NextI64() =
        this.Next() |> int64
    
    member public this.ArrayI64(n: int) =
        [|for _ in 0 .. n - 1 -> this.NextI64()|]

    member public this.IArrayI64(n: int) =
        [|for i in 0 .. n - 1 -> this.NextI64(), i|]

    member public this.NextF32() =
        this.Next() |> float32
    
    member public this.ArrayF32(n: int) =
        [|for _ in 0 .. n - 1 -> this.NextF32()|]

    member public this.IArrayF32(n: int) =
        [|for i in 0 .. n - 1 -> this.NextF32(), i|]

    member public this.NextF64() =
        this.Next() |> double
    
    member public this.ArrayF64(n: int) =
        [|for _ in 0 .. n - 1 -> this.NextF64()|]

    member public this.IArrayF64(n: int) =
        [|for i in 0 .. n - 1 -> this.NextF64(), i|]

    member public __.Tuple2Array n (f : int -> 'a list) =
        [|for _ in 0 .. n - 1 -> f 2 |> fun x -> x.[0], x.[1]|]
    
    member public __.Tuple3Array n (f : int -> 'a list) =
        [|for _ in 0 .. n - 1 -> f 3 |> fun x -> x.[0], x.[1], x.[2]|]

    member public __.CountDic n (f : unit -> 'a) =
        let seqs = seq {for _ in 0 .. n - 1 -> f()}
        let dic = new Dictionary<'a, int64>();
        for i in seqs do
            if dic.ContainsKey(i)
            then dic.[i] <- dic.[i] + 1L
            else dic.Add(i, 1L)
        dic

end

[<EntryPoint>]
let main _ =
#if DEBUG
    printfn "debuged"
#endif

    let scanner = Scanner()
    let n = scanner.NextI32()
    let arr = [|for _ in 0..n-1 -> scanner.Next()|]
    let p = 
        arr
        |> Array.groupBy id
        |> Array.map (fun (x, a) -> x, (Array.length a))
    let mx = Array.maxBy snd p |> snd
    p
    |> Array.where (fun (_, c) -> c = mx)
    |> Array.map fst
    |> Array.sort
    |> String.concat "\n"
    |> printfn "%s"

    0


Measured memory_bytes: 80232
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define LOOP(i) while(i--)
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	map<char,string> encode={{' ',"101"},{'\'',"000000"},{',',"000011"},{'-',"10010001"},
							 {'.',"010001"},{'?',"000001"},{'A',"100101"},{'B',"10011010"},
							 {'C',"0101"},{'D',"0001"},{'E',"110"},{'F',"01001"},
							 {'G',"10011011"},{'H',"010000"},{'I',"0111"},{'J',"10011000"},
							 {'K',"0110"},{'L',"00100"},{'M',"10011001"},{'N',"10011110"},
							 {'O',"00101"},{'P',"111"},{'Q',"10011111"},{'R',"1000"},
							 {'S',"00110"},{'T',"00111"},{'U',"10011100"},{'V',"10011101"},
							 {'W',"000010"},{'X',"10010010"},{'Y',"10010011"},{'Z',"10010000"}};
	map<string,char> decode={{"00000",'A'},{"00001",'B'},{"00010",'C'},{"00011",'D'},
							 {"00100",'E'},{"00101",'F'},{"00110",'G'},{"00111",'H'},
							 {"01000",'I'},{"01001",'J'},{"01010",'K'},{"01011",'L'},
							 {"01100",'M'},{"01101",'N'},{"01110",'O'},{"01111",'P'},
							 {"10000",'Q'},{"10001",'R'},{"10010",'S'},{"10011",'T'},
							 {"10100",'U'},{"10101",'V'},{"10110",'W'},{"10111",'X'},
							 {"11000",'Y'},{"11001",'Z'},{"11010",' '},{"11011",'.'},
							 {"11100",','},{"11101",'-'},{"11110",'\''},{"11111",'?'}};

	char str[110];
	while(cin.getline(str,sizeof(str))){
		string S;
		int index=0;
		while(str[index]!='\0'){
			S.append(encode[str[index++]]);
		}
		int pad = S.size()%5;
		if(pad){
			REP(i,5-pad){
				S.push_back('0');
			}
		}
		string T;
		for(int i=0,ei=S.size();i<ei;i+=5){
			T.push_back(decode[S.substr(i,5)]);
		}
		out(T);
	}
	
	return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define endl			"\n"
#define ll				long long
#define all(v)			((v).begin()), ((v).end())
#define sz(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define vi				vector <int>
#define vl				vector <ll>
#define ii				pair <ll,ll>
#define vii				vector <ii>
#define ull				unsigned long long
const double PI = 2 * acos(0.0);
void run() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
}
const int M = 1e5;
int n, k;
vi v[4];
int dp[M + 9][9];
int sol(int i, int prev) {
	if (i == n)
		return 0;
	int &ret = dp[i][prev];
	if (~ret)
		return ret;
	for (int j = 1; j <= 3; j++) {
		if (j != prev)
			ret = max(ret, v[j][i] + sol(i + 1, j));
	}
	return ret;
}
int main() {
	run();
	cin >> n;
	v[1].resize(n);
	v[2].resize(n);
	v[3].resize(n);
	lp(i,n)
		cin >> v[1][i] >> v[2][i] >> v[3][i];
	clr(dp, -1);
	cout << sol(0, 0);
	return 0;
}



Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
   int a,b,k;
   cin>>k>>a>>b;
   for(int i=a;i<=b;i++)
      {
      	if(i%k==0)
      	{
		   cout<<"OK";return 0; 
	   } 
  } 
   cout<<"NG";
return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>

#define NMAX 10000
#define QMAX 500

int LinearSearch (int *, int , int);

int main (void)
{
  int i,n,q,count = 0,result,arrayS[NMAX],arrayT[QMAX];

  scanf ("%d",&n);
  for (i = 0 ; i < n ; i++){
    scanf ("%d",&arrayS[i]);
  }
  scanf ("%d",&q);
  for (i = 0 ; i < q ; i++){
    scanf ("%d",&arrayT[i]);
  }
  
  for (i = 0 ; i < q ; i++){
    result = LinearSearch(arrayS,arrayT[i],n);
    if (result < n)
      count++;
  }

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

int LinearSearch (int *S, int key, int n)
{
  int i;
  i = 0;

  S[n] = key;
  while (S[i] != key)
    i++;
  if (i == n)
    return n;
  return i;
}

Measured memory_bytes: 640
/**
        	C++14 (GCC 5.4.1)
**/
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
using namespace std;

typedef struct S{
    int num;
    string name;
    int i;
} s;

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

    vector
 shop(N);

    for(int i = 0 ; i < N ; i++){
        string s;
        int p;
        cin >> s>> p;
        shop[i].num = i;
        shop[i].name = s;
        shop[i].i = p;
        // name[shop[i]] = i;
    }

    // sort(shop.begin(), shop.end());
    sort(shop.begin(), shop.end(), 
     [](const s& x, const s& y) { if(x.name != y.name) return x.name < y.name; else return x.i > y.i;});

    for(int i = 0 ; i < N ; i++){
        cout << shop[i].num + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
from collections import deque
N, M = map(int, input().split())
graph = [[] * N for _ in range(N)]
uv = [list(map(int, input().split())) for _ in range(M)]

ans = 0
for i in range(M):
    graph = [[] * N for _ in range(N)]
    for k in range(M):
        if k == i:
            continue
        u = uv[k][0] - 1
        v = uv[k][1] - 1
        graph[u].append(v)
        graph[v].append(u)
    
    # BFSのためのデータ構造
    dist = [False for _ in range(N)]
    que = deque()

    # 初期条件
    dist[0] = True
    que.append(0)

    # BFS開始
    while que:
        v = que[0]
        que.popleft()
        for new_v in graph[v]:
            if dist[new_v]:
                continue
            # 探索した頂点はTrueにする
            dist[new_v] = True
            que.append(new_v)
    
    if False in dist:
        ans += 1

print(ans)

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

int N;

int main() {

  cin >> N;

  string N_str;


  while(N) {
    N_str += '0' + (N % 10);
    N /= 10;
  }

  int sz = N_str.size();
  for(int i = 0; i < sz / 2; i++) {
    if (N_str[i] != N_str[sz-1-i]) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
n=int(input())
d,x=map(int,input().split())
eat=[]
for i in range(n):
    a=int(input())
    count=0
    for j in range(101):
        aeat=a*j+1
        if aeat<=d:
            count+=1
        else:
            eat.append(count)
            break
print(x+sum(eat))


Measured memory_bytes: 9012
#include <iostream>
using namespace std;
 
int main(){
	int A,B,C;
  	char F;
  	scanf("%d %c %d %c %d",&A,&F,&B,&F,&C);
  	if(A > 2019){
    	cout <<"TBD";
    }
    else if(A<=2018){
    	cout <<"Heisei";
    }
  	else if(B<5){
    	cout << "Heisei";
    }
    else{
        cout <<"TBD";
    }
}

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

namespace 競プロ_Csharp {
    class Program {
        static void Main(string[] args) {

            int n = NextInt();
            int[] ar = NextInts();

            Array.Sort(ar);
            int min = ar[0];
            int max = ar[n - 1];

            long sum = 0;
            for (int i = 0; i < n; i++) sum += ar[i];

            Println(min + " " + max + " " + sum);

        }

        public static void Println (Object o) {
            Console.WriteLine(o);
        }

        public static string NextString() {
            return Console.ReadLine();
        }

        public static string[] NextStrings () {
            return Console.ReadLine().Split();
        }

        public static int NextInt () {
            return int.Parse(Console.ReadLine());
        }

        public static int[] NextInts () {
            string[] a = Console.ReadLine().Split();
            int[] b = new int[a.Length];
            for (int i = 0; i < a.Length; i++) {
                b[i] = int.Parse(a[i]);
            }
            return b;
        }

        public static double NextDouble () {
            return double.Parse(Console.ReadLine());
        }

    }
}



Measured memory_bytes: 18268
#include <iostream>
#include <map>

using namespace std;

typedef pair<int,int> pi;
typedef long long ll;
int n, w;

pi items[100];
ll memo[100][100000];
ll dp(int i, ll c)
{
	ll result;
	if(i < 0)
		result = 0;
	else if(memo[i][c] != 0)
		result = memo[i][c];
	else
	{
		int weight = items[i].first;
		int value = items[i].second;
		ll best = dp(i-1, c);
		if(c+weight <= w)
			best = max(best, value + dp(i-1, c+weight));
		result = memo[i][c] = best;
	}
	return result;
}

int main()
{
	cin >> n >> w;
	for(int i = 0; i < n; i++)
	{
		pi pa;
		cin >> pa.first >> pa.second;
		items[i] = pa;
	}
	cout << dp(n-1, 0LL) << endl;
}


Measured memory_bytes: 75036