akhauriyash/Code-Regression huggingface dataset:
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;


    void calc()
    {
        cin = new Scanner();
        int[] ABC = cin.ArrayInt(3,0);
        if(ABC[0]<ABC[2]&&ABC[1]>ABC[2]&&ABC[0]<ABC[1])Console.WriteLine("Yes");
      else if(ABC[0]>ABC[2]&&ABC[1]<ABC[2]&&ABC[0]>ABC[1])Console.WriteLine("Yes");
      else Console.WriteLine("No");
    }


}



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;
    }
}

Measured memory_bytes: 11092
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;

int main(void) {
  int scan; // scanf result
  char *s; // to input 

  s = (char *)malloc(sizeof(char) * 4);
  scan = scanf("%s", s);
  if (strcmp(s, "ABC")) {
    printf("ABC");
    return (0);
  } else {
    printf("ARC");
    return (0);
  }

  return (0);
}


Measured memory_bytes: 1704
#include<bits/stdc++.h>
using namespace std;
const int N=4010;
int n,a,b,top,stk[N],ans[N];
char s[5];
int qry(int x,int y){
	printf("? %d %d\n",x,y); fflush(stdout);
	scanf("%s",&s); return (s[0]=='Y');
}
int main(){
	scanf("%d%d",&a,&b); n=a+b;
	if(a<=b){ puts("Impossible"); return 0; }
	for(int i=0;i<n;i++){
		if(!top) stk[++top]=i;
		else{
			int pd=qry(stk[top],i);
			if(pd) stk[++top]=i; else --top;
		}
	}
	for(int i=0;i<n;i++) ans[i]=qry(stk[top],i);
	printf("! "); for(int i=0;i<n;i++) printf("%d",ans[i]);
}


Measured memory_bytes: 3840
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <numeric>
#include <string>

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl

using namespace std;
using i64 = long long;

int main()
{
    vector<vector<int>> a(3, vector<int>(3));
    vector<vector<int>> amemo(3, vector<int>(3));
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin >> a[i][j];
            amemo[i][j] = 0;
        }
    }
    int n;
    cin >> n;
    vector<int> b(n);
    for (int k = 0; k < n; k++)
    {
        cin >> b[k];
        for (int i = 0; i < 3; i++)
        {
            for (int j = 0; j < 3; j++)
            {
                if (a[i][j] == b[k])
                {
                    amemo[i][j] = 1;
                }
            }
        }
    }

    bool flag = false;

    for (int i=0; i<3; i++)
    {
        int sum = amemo[i][0] + amemo[i][1] + amemo[i][2];
        if (sum == 3) flag = true;
    }
    for (int i=0; i<3; i++)
    {
        int sum = amemo[0][i] + amemo[1][i] + amemo[2][i];
        if (sum == 3) flag = true;
    }
    int sum = amemo[0][0] + amemo[1][1] + amemo[2][2];
    if (sum == 3) flag = true;
    sum = amemo[2][0] + amemo[1][1] + amemo[0][2];
    if (sum == 3) flag = true;

    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

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

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

int main() {
  int n, y;
  cin >> n >> y;
  for (int a = 0; a <= n; ++a) {
    for (int b = 0; a + b <= n; ++b) {
      int c = n - a - b;
      if (a * 10000 + b * 5000 + c * 1000 == y) {
        cout << a << " " << b << " " << c << endl;
        return 0;
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1 << endl;
}



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

using namespace std;

typedef long long ll;

int N;
string S[101];
int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> S[i];
	}
	set<string> s;
	s.insert(S[0]);
	for (int i = 1; i < N; i++) {
		if (S[i][0] != S[i - 1].back()) {
			cout << "No" << endl;
			return 0;
		}
		if (s.find(S[i]) != s.end()) {
			cout << "No" << endl;
			return 0;
		}
		s.insert(S[i]);
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int X,Y,Z;
  int K,S;
  int count=0;
  cin >>K>>S;
  for(int i=0;i<=K;i++){
    for(int j=0;j<=K;j++){
      if(0<=(S-i-j)&&(S-i-j)<=K){
        count ++;
      }
    }
  }
  
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define co(x) cout << (x) << "\n"
#define ll long long
#define pb push_back
#define Never
#define To

using namespace std;

int main(){

	cin.tie(0);
	ios::sync_with_stdio(false);

	ll N, M;
	priority_queue<long long> pq;

	cin >> N >> M;

	ll x;
	for(ll l = 0; l < N; l++){
		cin >> x;
		pq.push(x);
	}

	for(ll l = 0; l < M; l++){
		x = pq.top()/2;
		pq.pop();
		pq.push(x);
	}

	ll ans = 0;
	while(!pq.empty()){
		ans += pq.top();
		pq.pop();
	}

	cout << ans << endl;

	Never To return 0;
}


Measured memory_bytes: 1400
#include <stdio.h>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))

#define scani(i) scanf("%d", &(i))
#define scanc(c) scanf("%c", &(c))
#define scand(d) scanf("%lf", &(d))

#define printi(i) printf("%d", (i))
#define pr printf("\n")

#define NUM (100)

int main(int argc, char** argv){
    int a, b;
    scani(a);
    scani(b);

    if(a >= 10){
        printi(-1);
        pr;
        return 0;
    }
    if(b >= 10){
        printi(-1);
        pr;
        return 0;
    }

    printi(a * b);
    pr;
    return 0;
}



Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
  int n;  // no of heroes
  cin>>n;
   int a[n+1]; //no of towns n+1 a[i] is no of monsters attacking
  for(int i=0;i<=n;i++)
  {
    cin>>a[i];
  }
  int b[n]; // heroes fighting number
  for(int i=0;i<n;i++)
  {
    cin>>b[i];
  }
  long long int ans=0;
  if(a[0]<b[0]) {ans+=a[0];
  b[0]-=a[0];
  }
  else
  {
    ans+=b[0];
    b[0]=0;
  }
  for(int i=1;i<n;i++)
  {
    if(a[i]<=b[i-1])
      ans+=a[i];
    else
    {
      if(b[i-1]+b[i] >= a[i])
      {
        ans+=a[i];
        b[i]-=a[i]-b[i-1];
      }
      else
      {
        ans+=b[i]+b[i-1];
        b[i]=0;
      }
    }
  }
  if(b[n-1]>a[n]) ans+=a[n];
  else ans+=b[n-1];
  cout<<ans;
}
  

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b; cin>>a>>b;
    int n = b-a;
    cout<<(1+n)*n/2-b<<endl;
    return 0;
}


Measured memory_bytes: 256
#if __has_include("noamoa_atcoder_lib.h")
#include "noamoa_atcoder_lib.h"
#else
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define endl '\n'
#define all(x) (x).begin(),(x).end()
namespace atcoder {
	using namespace std;
	using ll = long long;
	using intv = vector<int>;
	using charv = vector<char>;
	using boolv = vector<bool>;
	using floatv = vector<float>;
	using doublev = vector<double>;
	using stringv = vector<string>;

	constexpr ll MOD  = 1000000007;
	constexpr ll MOD9 = 1000000009;

	template<typename T>
	void sort(vector<T>& v){
		sort(all(v));
	}
	template<typename T>
	void sortInv(vector<T>& v){
		sort(all(v), greater<T>());
	}

	template<typename T>
	T sum(const vector<T>& v){
		T ret = 0;
		for(const auto& e : v) ret += e;
		return ret;
	}

	template<typename T>
	inline vector<T>& operator+=(vector<T>& v, const T& e){
		v.push_back(e);
		return v;
	}

	template<typename T>
	void in(vector<T>& v){
		for(auto& e : v) cin >> e;
	}

	template<typename T>
	istream& operator>>(istream &stream, vector<T>& v){
		for(auto& e : v) stream >> e;
		return stream;
	}

	template<typename T>
	void out(const vector<T>& v){
		for(const auto& e : v) cout << e << ' ';
		cout << endl;
	}

	template<typename T>
	void outln(const vector<T>& v){
		for(const auto& e : v) cout << e << endl;
	}

	void init(){
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(15);
	}
}
using namespace atcoder;
#endif

int main(){
	init();

	int K,A,B;cin>>K>>A>>B;
	for(int i=A;i<=B;i++){
		if(i%K==0){
			cout << "OK";
			return 0;
		}
	}
	cout <<"NG"
;}

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

int main() {

	string a, b; cin >> a >> b;
	
	string ans;
	if (a.size() < b.size()) {
		ans = "LESS";
	}

	else if (b.size() < a.size()) {
		ans = "GREATER";
	}
	else { // a.size() == b.size()
		if (a < b) ans = "LESS";
		else if (b < a) ans = "GREATER";
		else ans = "EQUAL";
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
// IOI 2021
#include <bits/stdc++.h>
using namespace std;
 
#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
 
////////////////////////////////////////////////////////////////////
 
const int N = 1e5 + 5;

int A[N];

int main() {
 
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	mt19937 Rnd(time(0));
	
	string S; cin >> S;
	bool n, w, s, e;
	n = w = s = e = 0;
	for (char c : S) {
		n |= (c == 'N');
		w |= (c == 'W');
		s |= (c == 'S');
		e |= (c == 'E');
	}
	cout << (n == s && e == w ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 3632
i=0
N=gets.to_i

a=gets.split(" ").map(&:to_i)
b=[0,0]

a=a.sort{|a,b|b<=>a}

until i==2 do

if a[0]==a[1]
  b[i]=a[0]
  i+=1
  a.slice!(0,2)
else 
  a.slice!(0)
end

end

print(b[0].to_i*b[1].to_i)


Measured memory_bytes: 10112
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#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;
  map<int,int> m;
  ll ans = 0LL;
  for (int i = 0;i < n;i++){
    int tmp;
    cin >> tmp;
    ans += (ll)m[i-tmp];
    m[tmp+i]++;
  }
  cout << ans << endl;
  
  
  return 0; 
}



Measured memory_bytes: 20592
n,m=map(int,input().split())
l1="."*(m+2)
l2="."+input()+"."
b=True
for i in range(n-1):
  l3="."+input()+"."
  for j in range(1,1+m):
    if l2[j]=="#" and (l2[j-1]=="." and l2[j+1]=="." and l1[j]=="." and l3[j]=="."):
      b=False
      break
  l1,l2=l2,l3
l3=="."*(m+2)
for j in range(m):
    if l2[j]=="#" and (l2[j-1]=="." and l2[j+1]=="." and l1[j]=="." and l3[j]=="."):
      b=False
      break
if b:
  print("Yes")
else:
  print("No")
      
      

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

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

    if (V%10 == 3) {
        cout << "bon" << endl;
    } else if (V%10 == 0 || V%10 == 1 || V%10 == 6 || V%10 == 8) {
        cout << "pon" << endl;
    } else {
        cout << "hon" << endl;
    }

    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>

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

using namespace std;
typedef long long int ll;
const int INF = 100000000;

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

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

    int ans = 0;
    while (true) {
        bool is_prime = IsPrime(x);
        if (is_prime) {
            ans = x;
            break;
        }
        x++;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

const int INF = 1e9;

void enumerate(std::vector<std::pair<int, int>> &items, std::vector<std::pair<int, int>> &ps) {
  int L = items.size();
  REP(j, 1 << L) {
    int w = 0, v = 0;
    REP(k, L) {
      if (j >> k & 1) v += items[k].first, w += items[k].second;
    }
    ps.emplace_back(w, v);
  }
  sort(ALL(ps));
  int M = 1;
  REP(j, 1 << L) {
    if (ps[M-1].second < ps[j].second) {
      ps[M++] = ps[j];
    }
  }
  ps.resize(M);
}


int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  std::cin >> N;
  std::vector<int> V(N), W(N);
  REP(i, N) std::cin >> V[i] >> W[i];

  int n_perm = std::min(N, (1 << 11) - 1);
  std::vector<std::vector<std::pair<int, int>>> permed(n_perm);

  REP(i, n_perm) {
    std::vector<std::pair<int, int>> items;
    int v = i;
    while (true) {
      items.emplace_back(V[v], W[v]);
      if (v == 0) {
        break;
      }
      v = (v - 1) / 2;
    }

    std::vector<std::pair<int, int>> ps;
    enumerate(items, ps);
    permed[i] = ps;
  }
  /*
  for (auto ps : permed) {
    for (auto p : ps) std::cout << '(' << p.first << ',' << p.second << ')' << ' ';
    std::cout << std::endl;
  }
  */

  int Q;
  std::cin >> Q;
  REP(_, Q) {
    int v, L;
    std::cin >> v >> L;
    v--;
    if (v < n_perm) {
      auto ans = std::lower_bound(ALL(permed[v]), std::make_pair(L, INF)) - 1;
      std::cout << ans->second << '\n';
    } else {
      std::vector<std::pair<int, int>> items;
      while (v >= n_perm) {
        items.emplace_back(V[v], W[v]);
        v = (v - 1) / 2;
      }
      int M = items.size();
      int ans = 0;
      REP(i, 1 << M) {
        int vv = 0, w = 0;
        REP(j, M) if (i >> j & 1) vv += items[j].first, w += items[j].second;
        if (w <= L) {
          auto cand = std::lower_bound(ALL(permed[v]), std::make_pair(L - w, INF)) - 1;
          ans = std::max(vv + cand->second, ans);
        }
      }
      std::cout << ans << '\n';
    }
  }
  return 0;
}

Measured memory_bytes: 25352
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<algorithm>

using namespace std;

#define LL long long
string s;
int W, H, x, y, r, a, b, c, num[5];

int main() {
	for (int i = 0; i < 10000; i++) {
		cin >> x;
		if (x == 0) break;
		cout << "Case " << i+1 << ": " << x << endl;

	}

	return 0;
}


Measured memory_bytes: 3148
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

#define INF (1 << 30)
#define MAX_V 100

int cost[MAX_V][MAX_V]; // cost[u][v] ?????????u??????v???????????????
int mincost[MAX_V];
bool used[MAX_V];
int V;// V???????????°

// ????°???¨?????¨??§?????????O(V^2)

// ???????????????????????????????????????cost????¨?????????????????????¨

int prim(){
	
	for(int i = 0; i < V; i++){
		mincost[i] = INF;
		used[i] = false;
	}
	
	mincost[0] = 0;
	
	int total = 0;
	
	while(true){
		
		int add_v = -1;
		
		for(int u = 0; u < V; u++){
			if(!used[u] && (add_v == -1 || mincost[u] < mincost[add_v])){
				add_v = u;
			}
		} // ??????????????????????±????
		
		if(add_v == -1){
			break;
		} // ??´??°???????????????????????´????????????
		used[add_v] = true;
		total += mincost[add_v];
		
		for(int u = 0; u < V; u++){
			mincost[u] = min(mincost[u], cost[add_v][u]);
		} // ???????????????????????????????°???????????????´??°
	}
	return total;
}

int main(){
	
	int ans, m;
	
	while(true){
		cin >> V >> m;
		if(V == 0 && m == 0){
			break;
		}
		for(int i = 0; i < V; i++){
			for(int j = 0; j < V; j++){
				cost[i][j] = INF;
			}
		}
		
		int a, b, c;
		
		for(int i = 0; i < m; i++){
			cin >> a >> b >> c;
			cost[a][b] = c;
			cost[b][a] = c;
		}
		
		ans = prim();
		printf("%d\n", ans);
	}
	
	return 0;
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
using namespace std;
const int N=(1<<19)+5;
int lim=1,M=924844033,a[N],r[N],fac[N],inv[N],b[N],tot,h[N],sz[N],g=5,gi=554906420,n,i,x,y,l;
struct node{
	int to,ne;
}e[N];
inline int mul(int x,int y){return 1ll*x*y%M;}
inline int inc(int x,int y){x+=y;if(x>=M)x-=M;return x;}
inline int dec(int x,int y){x-=y;if(x<0)x+=M;return x;}
void add(int x,int y){e[++tot]={y,h[x]},h[x]=tot;}
int pw(int x,int y){
	int z=1;
	for (;y;y>>=1,x=1ll*x*x%M)
		if (y&1) z=1ll*z*x%M;
	return z;
}
int Inv(int x){return pw(x,M-2);}
void dfs(int u,int fa){
	sz[u]=1;
	for (int i=h[u],v;i;i=e[i].ne)
		if ((v=e[i].to)!=fa) dfs(v,u),sz[u]+=sz[v],a[sz[v]]++;
	a[n-sz[u]]++;
}
void ntt(int *a,int op){
	for (int i=0;i<lim;i++)
		if (i<r[i]) swap(a[i],a[r[i]]);
	for (int mid=1,pp=M-1>>1;mid<lim;mid<<=1,pp>>=1)
		for (int R=mid<<1,j=0,wn=pw(op==1?g:gi,pp);j<lim;j+=R)
			for (int k=0,w=1;k<mid;k++,w=mul(w,wn)){
				int x=a[j|k],y=mul(w,a[j|k|mid]);
				a[j|k]=inc(x,y);
				a[j|k|mid]=dec(x,y);
			}
	if (op==-1){
		int inv=Inv(lim);
		for (int i=0;i<lim;i++) a[i]=mul(a[i],inv);
	}
}
int main(){
	scanf("%d",&n);
	for (i=1;i<n;i++) scanf("%d%d",&x,&y),add(x,y),add(y,x);
	dfs(1,0);
	fac[0]=1,a[0]=0;
	for (i=1;i<=n;i++) fac[i]=1ll*fac[i-1]*i%M,a[i]=1ll*a[i]*fac[i]%M;
	b[0]=inv[n]=Inv(fac[n]);
	for (i=n-1;~i;i--) inv[i]=1ll*inv[i+1]*(i+1)%M,b[n-i]=inv[i];
	for (;lim<=n+n;lim<<=1,l++);
	for (i=0;i<lim;i++) r[i]=(r[i>>1]>>1)|((i&1)<<(l-1));
	ntt(a,1),ntt(b,1);
	for (i=0;i<lim;i++) a[i]=1ll*a[i]*b[i]%M;
	ntt(a,-1);
	for (i=1;i<=n;i++) printf("%lld\n",(1ll*fac[n]*inv[i]%M*inv[n-i]%M*n%M-1ll*inv[i]*a[n+i]%M+M)%M);
}


Measured memory_bytes: 28544
def examC():
    N = I()
    A = LI()
    d = defaultdict(int)
    for a in A:
        d[a] += 1
    a = [0,0]
    for key,i in d.items():
        if i>=4:
            if a[1]<key:
                a = [key,key]
            elif a[0]<key:
                a = [key,a[1]]
        elif i>=2:
            if a[1]<key:
                a = [a[1],key]
            elif a[0]<key:
                a = [key,a[1]]
    ans = a[0]*a[1]
    print(ans)
    return

def examD():
    N = I()
    S = [SI() for _ in range(2)]
    ans = 1
    flag = 0
    i = 0
    while(i<N):
        if S[0][i]==S[1][i]:
            if flag==1:
                ans *= 2
            elif flag==0:
                ans *= 3
            flag = 1
        else:
            if flag==0:
                ans *= 6
            elif flag==1:
                ans *= 2
            elif flag==2:
                ans *= 3
            flag = 2
        i += flag
        ans %= mod
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math,random
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examD()

"""

"""

Measured memory_bytes: 5992
str1 = input()

A = str1.split(" ")

# 存在する動物が全員4本足ならば
all4 = int(A[0])*4
res = "No"

for i in range(0, int(A[0])+1):
    if all4 == int(A[1]):
        res = "Yes"
        break
    else:
        all4 = all4 - 2
        
print(res)

Measured memory_bytes: 9180
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

const double pi = 3.141592653589793;
// -------------------------------------------------------
int N;

int main() {
  cin >> N;
  int pt = 0;
  int px = 0;
  int py = 0;
  rep(i, 0, N) {
    int t, x, y;
    cin >> t >> x >> y;
    int dt = abs(t - pt);
    int dx = abs(x - px);
    int dy = abs(y - py);
    int dist = dx + dy;

    if (dist > dt) {
      cout << "No" << endl;
      return 0;
    }
    if (dist % 2 != dt % 2) {
      cout << "No" << endl;
      return 0;
    }
    pt = t;
    px = x;
    py = y;
  }
  cout << "Yes" << endl;
  return 0;
}


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

int main(){
    int n,m,qq;
    cin>>n>>m>>qq;
    int ll[m],rr[m];

    for(int i=0;i<m;i++){
        cin>>ll[i]>>rr[i];
    }

    int p[qq],q[qq];

    for(int i=0;i<qq;i++){
        cin>>p[i]>>q[i];
    }

    int c[n][n];

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            c[i][j]=0;
        }
    }

    for(int i=0;i<m;i++){
        c[ll[i]-1][rr[i]-1]+=1;
    }

    for(int i=0;i<n;i++){
        for(int j=1;j<n;j++){
            c[i][j]+=c[i][j-1];
        }
    }

    for(int i=0;i<qq;i++){
        int r=0;

        for(int j=p[i]-1;j<q[i];j++){
            r+=c[j][q[i]-1];
            if(1<p[i]){
                r-=c[j][p[i]-2];
            }
        }

        cout<<r<<endl;
    }

    return 0;
}


Measured memory_bytes: 4224
S = input()

ans = len(S)
for i in range(26):
    c = chr(ord('a') + i)
    if not c in S: continue
    s = S
    ope = 0
    while any(a!=c for a in s):
        t = ''
        for a,b in zip(s,s[1:]):
            if a==c or b==c:
                t += c
            else:
                t += '-'
        s = t
        ope += 1
    ans = min(ans, ope)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    rep(i, n) ans += s[i] == 'R';
    int w = 0, r = ans;
    rep(i, n) {
        if (s[i] == 'W') {
            w++;
            chmin(ans, max(w, r));
        } else {
            r--;
            chmin(ans, max(w, r));
        }
    }
    cout << ans << endl;
}

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

const int MAXN = 101;
const int W = 17;
int wait[MAXN];
int u[W];

void make() {
  fill(u, u+W, 0);
  queue<pair<int,int> > que;
  for(int t = 0, i = 0; i < 100 || que.size(); ++t) {
    if(i < 100 && t == 5*i) que.push(make_pair(i++, t));
    while(que.size()) {
      int k = que.front().first;
      int s = que.front().second;
      int x = k%5 == 1 ? 5 : 2;
      int d = 17 * (k%2) + 3*(k%3) + 19;

      int pos = -1;
      for(int j = 0; j+x <= W; ++j) {
        bool flag = true;
        for(int a = 0; a < x; ++a) {
          if(u[j+a] > t) {
            flag = false;
            break;
          }
        }
        if(flag) {
          pos = j;
          break;
        }
      }
      if(pos == -1) break;
      wait[k] = t - s;
      que.pop();
      for(int a = 0; a < x; ++a) u[pos+a] = t + d;
    }
  }
}

int main() {
  make();
  int n;
  while(cin >> n) {
    cout << wait[n] << endl;
  }
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  
  int i, sum = 0;
  vector<int> l(n);
  for(i = 0; i < n; i++){
    cin >> l.at(i);
    sum += l.at(i);
  }
  
  sort(l.begin(), l.end());
  
  if(l.at(l.size() - 1) < sum - l.at(l.size() - 1)) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> dp(k, 0);
  dp[0] = 1;
  sort(a.begin(), a.end());
  int l = 0, r = n;
  while(l != r) {
    int mid = (l + r) / 2;
    vector<int> na;
    for(int i = 0; i < n; i++) {
      if(i != mid) na.push_back(a[i]);
    }
    vector<vector<int>> dp(n, vector<int> (k, 0));
    dp[0][0] = 1;
    for(int i = 0; i < n - 1; i++) {
      for(int j = 0; j < k; j++) {
        dp[i + 1][j] += dp[i][j];
        if(j + na[i] < k) dp[i + 1][j + na[i]] += dp[i][j];
      }
    }
    int check = 0;
    for(int i = max(0, k - a[mid]); i < k; i++) {
      check |= dp[n - 1][i];
    }
    if(check) r = mid;
    else l = mid + 1;
  }
  cout << l << "\n";
  return 0;
}


Measured memory_bytes: 98352
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber , InputReader in , PrintWriter out){
            int n = in.nextInt();
            int m = in.nextInt();
            int[] arr = new int[n+1];
            for (int i = 0; i <m ; i++) {
                arr[in.nextInt()] = 1;
            }
           long[] dp = new long[n+1];
            dp[0] = 1;
            if (arr[1] == 0) dp[1] = 1;
            for (int i = 2 ; i <=n ; i++) {
                dp[i] = dp[i-1]+dp[i-2];
                dp[i]%=1000000000+7;
                if (arr[i] == 1) dp[i] = 0;
            }
            out.println(dp[n] %(1000000000+7));






        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }

}

Measured memory_bytes: 33208
def union(parent,size,a,b):
    x=find(parent,a)
    y=find(parent,b)
    if x!=y:
        if size[x]<size[y]:
            parent[x]=y 
            size[y]=size[x]+size[y]
        else:
            parent[y]=x 
            size[x]=size[x]+size[y]
    return parent,size 
def find(parent, a):
    while a != parent[a]:
            parent[a]=parent[parent[a]]
            a=parent[a]
    return a
n,q=map(int,input().split())
size=[1]*n
ans=0 
l=[int(i) for i in input().split()]
parent=[i for i in range(n)]
for i in range(q):
    a,b=map(int,input().split())
    parent,size=union(parent,size,a-1,b-1)
for i in range(n):
    if find(parent,i)==find(parent,l[i]-1):
        ans+=1 
print(ans)

Measured memory_bytes: 62700
#include<bits/stdc++.h>
#define ALL(c) begin(c), end(c)
using namespace std;
using ll = long long;
using ld = long double;


void go_karatsuba(auto a, auto b, auto ret, size_t n){
    if(n<=32){
        fill(ret, ret+n*2-1, 0);
        for(size_t i=0; i<n; ++i)
        for(size_t j=0; j<n; ++j) ret[i+j] += a[i]*b[j];
    }else
    if(n&1){
        go_karatsuba(a,b,ret,n-1);
        ret[n*2-3] = 0;
        for(size_t i=0; i<n-1; ++i) ret[i+n-1] += a[i]*b[n-1] + b[i]*a[n-1];
        ret[n*2-2] = a[n-1]*b[n-1];
    }else{
        auto ar = a, al = a+n/2, 
		     br = b, bl = b+n/2,
        	 asum = ret+n*5, bsum = asum+n/2,
        	 x1 = ret, x2 = x1+n, x3 = x2+n;
        for(size_t i=0; i<n/2; ++i){
            asum[i] = al[i] + ar[i];
            bsum[i] = bl[i] + br[i];
        }
        go_karatsuba(ar, br, x1, n/2);
        go_karatsuba(al, bl, x2, n/2);
        go_karatsuba(asum, bsum, x3, n/2);
        for(size_t i=0; i<n; ++i) x3[i] -= x1[i]+x2[i];
        for(size_t i=0; i<n; ++i) ret[i+n/2]+=x3[i];
	}
	ret[n*2-1] = 0;
}

template<class T>
vector<T> mul(const vector<T> &_a, const vector<T> &_b){
	auto n = max(size(_a), size(_b));
	vector<T> a(n), b(n);
	copy(ALL(_a), begin(a));
	copy(ALL(_b), begin(b));
	vector<T> ret(n*6);
	go_karatsuba(begin(a), begin(b), begin(ret), n);
	return vector<T>(begin(ret), begin(ret)+size(_a)+size(_b)-1);
} 


int main(){
	//freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);//cout.precision(12);cout<<fixed;
	
	const int P = 2e5+3;
	const int g = 2;
	
	vector<int> f(P);
	for(int x=1,i=0;i<P-1;++i){
		f[x] = i;
		x = 1LL*x*g %P;
	}
	
	int n;
	cin>>n;
	
	vector<int> a(n);
	for(auto &_ : a) cin>>_;
	//ll answer = 0;
	//for(int i=0;i<n;++i) for(int j=0;j<n;++j) answer+=1LL*a[i]*a[j]%P;
	
	vector<ll> cnt(P-1);
	for(int x : a){
		x%=P;
		if(x) cnt[f[x]]++;
		//cerr<<x<<' '<<f[x]<<endl;
	}
	
	//for(int i=0;i<P;++i) cout<<cnt[i]<<' '; cout<<endl;
	
	auto m = mul(cnt,cnt);
	//for(auto x : m) cout<<x<<' '; cout<<endl;
	for(int i=P-1;i<size(m);++i) m[i%(P-1)]+=m[i];
	m.resize(P-1);
	//for(auto x : m) cout<<x<<' '; cout<<endl;
	
	ll ans = 0;
	for(int i=0,x=1; i<P-1; ++i, x=1LL*x*g%P) ans+=m[i]*x;
	
	for(int x:a) ans-=1LL*x*x%P;
	ans/=2;
	
	cout<<ans<<endl;
	
	//cout<<answer<<endl;
	
	return 0;
}


Measured memory_bytes: 21924
N,M=map(int,input().split())

a=list(map(int,input().split()))
a.sort()
ch=[list(map(int,input().split())) for i in range(M)]
ch=sorted(ch,key=lambda x: x[1],reverse=True)
b=[ch[i][0] for i in range(M)]

ans=sum(a)
tmp=0
for i in range(N):
    if a[i]<ch[tmp][1]:
        if ch[tmp][0]>0:
            ans+=ch[tmp][1]-a[i]
            if ch[tmp][0]>1: ch[tmp][0]-=1
            else:
                tmp+=1
                if tmp>=M: break
    else: break

print(ans)

Measured memory_bytes: 33752
#include <stdio.h>

int main(void) {
	int datanum,datamax;
	int start,end;
	int i;
	scanf("%d",&datamax);
	for(datanum=0;datanum<datamax;datanum++) {
		scanf("%d %d",&start,&end);
		if(start<=5 && end<start) {
			for(i=start;i>=end;i--) {
				printf("%d",i);
				if(i>end)printf(" ");
			}
		} else if(start<=5 && end>start) {
			for(i=start;i<=end;i++) {
				printf("%d",i);
				if(i<end)printf(" ");
			}
		} else if(start<end) {
			for(i=start;i<=end;i++) {
				printf("%d",i);
				if(i<end)printf(" ");
			}
		} else if(end<=5) {
			for(i=start;i<=9;i++) {
				printf("%d ",i);
			}
			for(i=5;i>=end;i--) {
				printf("%d",i);
				if(i>end)printf(" ");
			}
		} else {
			for(i=start;i<=9;i++) {
				printf("%d ",i);
			}
			printf("5 4 3 2 1 0 1 2 3 4 ");
			for(i=5;i<=end;i++) {
				printf("%d",i);
				if(i<end)printf(" ");
			}
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  vector<int> x(N);
  rep(i, N) {
    cin >> x[i];
    x[i] -= A;
  }

  vector<vector<long long>> dp(N+1);
  rep(i, N+1) {
    dp[i].resize(2 * N * 50, 0);
  }
  dp[0][N*50] = 1;

  for(int i=1; i<=N; i++) {
    rep(j, 2*N*50) {
      dp[i][j] = dp[i-1][j] + dp[i-1][j-x[i-1]];
    }
  }

  cout << dp[N][N*50] - 1 << endl;

  return 0;
}


Measured memory_bytes: 2304
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <set>
#include <cmath>
#include <map>
using namespace std;
int _count,base=1,ans;
int main()
{
	int N;
	scanf("%d",&N);
	while(base<=N)
	{
		_count++;
		base*=10;
	}
	for(int i=1;i<_count;i+=2)
	{
		ans+=pow(10,i-1)*9;
	}
	if(_count%2==1)
	{
		ans+=N-pow(10,_count-1)+1;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 512
/*
 * main.c
 *
 *  Created on: 2020/03/28
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a > b ? b : a)
typedef long long int ll;
typedef unsigned long long int ull;

int sort_inc(const void *a, const void *b) { return (*(int*)a - *(int*)b);}
int sort_dec(const void* a, const void* b) { return (*(int*)b - *(int*)a);}
int sort_dec_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = -1; }
    else if (da == db) { val = 0; }
    else { val = 1; }
    return val;
}
int sort_inc_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = 1; }
    else if (da == db) { val = 0; }
    else { val = -1; }
    return val;
}
int sort_dic(const void *a, const void *b) {
    char *pa = (char *)a;    char *pb = (char *)b;    int i = 0, val = 0, N = 10;
    for (i = 0; i < N; i++) {
    	char da = pa[i], db = pb[i];
    	if (da == db) continue;
  		if (da > db) val = 1; else val = -1;
        break;
    }
    return val;
}

void yesno(int ans) {
	if (ans == 1) {	printf("Yes\n");
	} else {		printf("No\n");	}
	return;
}

void okng(int ans) {
	if (ans == 1) { printf("OK\n");
	} else { 		printf("NG\n");	}
	return;
}

int contest[27] = {0};
int satisfact[366][27] = {0};
int ans[366] = {0};

int main()
{
	int D = 0;
	scanf("%d", &D);
	memset(satisfact, 0, sizeof(satisfact));

	int i = 1, d = 1;
	for (i = 1; i <= 26; i++ ) {
		scanf("%d", &contest[i]);
	}
	for (d = 1; d <= D; d++) {
		for (i = 1; i <= 26; i++ ) {
			scanf("%d", &satisfact[d][i]);
		}
	}

	// day 1 stisfact = 0
	// contest open .. day d, contest type i statisfact(d,i) increase
	// if contest type not open, test never open last(d,i) = 0.
	for (d = 1; d <= D; d++) {
		int val = 0, con = 0;
		for (i = 1; i <= 26; i++ ) {
			if (val < satisfact[d][i] * contest[i]) {
				con = i;
				val = satisfact[d][i] * contest[i];
			}
		}
		ans[d] = con;
	}
	for (d = 1; d <= D; d++) {
		printf("%d\n", ans[d]);
	}
	return 0;
}


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

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
//const int INF = 1 << 30;
const ll INF = 1LL << 60;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)

int V, E;

struct edge { ll from, to, cost; };

edge es[100010];

ll d[10010];
bool negative, upn, inf;

ll ans;

void shortest_path(int s) {
	for (int i = 0; i < V; i++) d[i] = INF;
	d[s] = 0;
	for (int i = 0; i < V; i++) {
		bool update = false, upn = false;
		for (int j = 0; j < E; j++) {
			edge e = es[j];
			if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				update = true;

				if(e.to == V - 1) upn = 1;
			}
		}
		if (!update) break;
		if (upn && i == V - 1) {
			inf = true;
			return;
		}
	}
	ans = -d[V - 1];
}

int main(void){
	int n, m; cin>>n>>m;
	for (int i = 0; i < m; i++) {
		int a, b, c; cin>>a>>b>>c;
		a--; b--; c = -c;
		es[i].from = a; es[i].to = b; es[i].cost = c;
	}
	V = n; E = m;

	shortest_path(0);

	if(inf) cout<< "inf" <<endl;

	else cout<< ans <<endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 25
 
typedef struct{
  int id;
  int sibling;
  int parent;
  int right;
  int left;

} Node;

int CheckHeight(Node *, int);

int main(){
  int i, n;
  int id, right, left, depth, parent;
  Node node[N];
 
  scanf("%d", &n);
 
  for(i = 0; i < n;  i++){
    node[i].sibling = -1;
    node[i].parent = -1;
  }
 
  for( i = 0; i < n; i++){
    scanf("%d%d%d", &id, &left, &right);
 
    node[id].id = id;
    node[id].right = right;
    node[id].left = left; 

    if(right != -1 || left != -1){
      node[right].parent = id;
      node[left].parent = id;
      node[right].sibling = left;
      node[left].sibling = right;
    }
  }
 
  for( i = 0; i < n; i++){
    printf("node %d: parent = %d, sibling = %d, ", node[i].id, node[i].parent, node[i].sibling);
 
    if( node[i].right == -1 && node[i].left == -1 ) printf("degree = 0, ");
    else if( node[i].right == -1 || node[i].left == -1 ) printf("degree = 1, ");
    else printf("degree = 2, ");
 
    depth = 0;
    parent = node[i].parent;
    while(1){
      if(parent == -1) break;
      else {
        parent = node[parent].parent;
        depth++;
      }
    }
 
    printf("depth = %d, ", depth);
 
    printf("height = %d, ", CheckHeight(node, i));
 
    if( node[i].parent == -1 ) printf("root");
    else if( node[i].left == -1 && node[i].right == -1) printf("leaf");
    else printf("internal node");
    printf("\n");
  }
 
  return 0;
} 

int CheckHeight(Node node[], int i){
  int left, right, height = 0;
 
  if(node[i].right == -1 && node[i].left == -1 ) return height;
  else if( i == -1 ) return height;

  right = CheckHeight(node, node[i].right); 
  left = CheckHeight(node, node[i].left);

  if( left > right ) return left + 1;
  else return right + 1;
 
}

Measured memory_bytes: 604
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

#define INF LLONG_MAX / 5
#define MOD 1000000007
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define enld endl

signed main() {
	int N, Ma, Mb;
	cin >> N >> Ma >> Mb;
	vector<int>a(N);
	vector<int>b(N);
	vector<int>c(N);
	rep(i, N) {
		cin >> a[i] >> b[i] >> c[i];
	}
	int Sa = 0;
	int Sb = 0;
	rep(i, N) {
		Sa += a[i];
		Sb += b[i];
	}
	Sa++;
	Sb++;
	int size = 100;
	vector<vector<vector<int>>>dp(N + 1, vector<vector<int>>(Sa, vector<int>(Sb,INF)));
	rep(i, N + 1) {
		rep(j, Sa) {
			rep(k, Sb) {
				if (i == 0) {
					if (j == 0 && k == 0) {
						dp[i][j][k] = 0;
					}
				}
				else {
					if (j - a[i - 1] < 0 || k - b[i - 1] < 0) {
						dp[i][j][k] = dp[i - 1][j][k];
					}
					else {
						if (dp[i - 1][j][k] == INF && dp[i - 1][j - a[i - 1]][k - b[i - 1]] == INF) {
							dp[i][j][k] = INF;
						}
						else {
							dp[i][j][k] = min(dp[i - 1][j][k], dp[i - 1][j - a[i - 1]][k - b[i - 1]] + c[i - 1]);
						}
					}
				}
			}
		}
	}


	/*
	rep(i, N+1) {
		rep(j, size) {
			rep(k, size) {
				cout << i << ' ' << j << ' ' << k << ' ' << dp[i][j][k] << endl;
			}
		}
	}
	*/
	
	int ans = INF;
	rep(i, N + 1) {
		rep(j, Sa) {
			rep(k, Sb) {
				if (i == N && j * Mb == k * Ma &&j!=0&&k!=0) {
					ans = min(ans, dp[i][j][k]);
				}
			}
		}
	}
	if (ans == INF) {
		cout << -1 << enld;
	}
	//cout << endl;
	else {
		cout << ans << endl;
	}
	
}

Measured memory_bytes: 22028
#include <iostream>

using namespace std;

int main(){
    int A;
    //Aを定義
    int B;
    //Bを定義
    cin >> A >> B;
    //A,Bの順で標準入力
    if (A % 3 == 0){
        cout << "Possible" << endl;
        //Aが3で割り切れる場合はPossibleと出力
    } else if(B % 3 == 0){
        cout << "Possible" << endl;
        //Bが3で割り切れる場合はPossibleと出力
    } else if((A + B) % 3 == 0){
        cout << "Possible" << endl;
        //(A + B)が3で割り切れる場合はPossibleと出力
    } else {
        cout << "Impossible" << endl;
        //それ以外の場合はImpossibleと出力
    }
}

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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007;

int main(){
    
    int N,M;cin>>N>>M;
    vector<bool> A(N+1,false);
    vector<ll> B(N+1,0);
    for(int i=0;i<M;i++){
        int a;cin>>a;
        A[a]=true;
    }
    B[0]=1;
    for(int i=0;i<N;i++){
        if(i!=N-1){
            if(A[i+1]==false){
                B[i+1]+=B[i];
                B[i+1]=B[i+1]%mod;
            }if(A[i+2]==false){
                B[i+2]+=B[i];
                B[i+2]=B[i+2]%mod;
            }
        }else{
            if(A[i+1]==false){
                B[i+1]+=B[i];
                B[i+1]=B[i+1]%mod;
            }
        }
    }
    cout<<B[N]<<endl;
}


Measured memory_bytes: 1024
// Ala be zekrellah tatmaenolgholoob ...
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define F first
#define S second
#define MP make_pair
const int maxn = 1e5+9;
const ll mod = 1e9+7;

int a[maxn];

int main () {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n, res = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; ) {
		int cur = 0, col = a[i];
		while (i < n && a[i] == col) {
			cur++;
			i++;
		}
		res += cur / 2;
	}
	cout << res << "\n";
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) * b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}



int main() {

	/*string s; cin >> s;
	int a,b,c; cin >> a;
	vector<string>ss;*/
	Int n, s, t; cin >> n>>s;
	Int m = max(n + s, n - s);
	cout << max(m, n * s);

	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){

	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