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

using namespace std;
typedef long long ll;
#define rep(i, n, s) for (int i = s; i < (int)(n); i++)

ll calcNumOfCombination(ll n, ll r) {
    ll num = 1;
    for (ll i = 1; i <= r; i++) {
        num = num * (n - i + 1) / i;
    }
    return num;
}

int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }

int findSumDigits(int s) {
    int num = 0;
    int temp = 0;
    while (s) {
        temp = s % 10;
        num += temp;
        s = s / 10;
    }
    return num;
}

int main() {
    string n;
    cin >> n;
    int a = stoi(n.substr(0, 1));
    int b = stoi(n.substr(1, 1));
    int c = stoi(n.substr(2, 1));
    int d = stoi(n.substr(3, 1));

    if (a + b + c + d == 7) {
        cout << a << '+' << b << '+' << c << '+' << d << "=7" << endl;
        return 0;
    } else if (a + b + c - d == 7) {
        cout << a << '+' << b << '+' << c << '-' << d << "=7" << endl;
        return 0;
    } else if (a + b - c + d == 7) {
        cout << a << '+' << b << '-' << c << '+' << d << "=7" << endl;
        return 0;
    } else if (a - b + c + d == 7) {
        cout << a << '-' << b << '+' << c << '+' << d << "=7" << endl;
        return 0;
    } else if (a + b - c - d == 7) {
        cout << a << '+' << b << '-' << c << '-' << d << "=7" << endl;
        return 0;
    } else if (a - b + c - d == 7) {
        cout << a << '-' << b << '+' << c << '-' << d << "=7" << endl;
        return 0;
    } else if (a - b - c + d == 7) {
        cout << a << '-' << b << '-' << c << '+' << d << "=7" << endl;
        return 0;
    } else if (a - b - c - d == 7) {
        cout << a << '-' << b << '-' << c << '-' << d << "=7" << endl;
        return 0;
    }


    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <map>
using namespace std;

const int INF = 1000000007;

// aとbを掛けた値をmodする(a * b mod p)
int modmulti(int a, int b)
{
    int res = 0;
    int mod = a % INF;
    while (b > 0)
    {
        if ((b & 1) == 1)
        {
            res += mod;
            if (res > INF)
            {
                res -= INF;
            }
        }
        mod <<= 1;
        if (mod > INF)
        {
            mod -= INF;
        }
        b >>= 1;
    }
    return res;
}

int main()
{
    const int zero = 0;

    int N;
    map<int, int> A;
    map<int, int> X;

    if (scanf("%d", &N) < 1) return 0;

    for (int i = 0; i < N; i++)
    {
        int a = 0;
        if (scanf("%d", &a) < 1) return 0;
        A[a]++;
    }

    int j = 1;
    int half = (N + 1) / 2;
    for (int i = 0; i < half; i++)
    {
        if (j < N)
        {
            X[N - j]++;
            X[N - j]++;
            j = j + 2;
        }
        else if (j == N) X[0]++;
    }

    for (int i = 0; i < N; i++)
    {
        if (A[i] != X[i])
        {
            printf("%d\n", zero);
            return 0;
        }
    }

    int multi = N / 2;

    int ans = 1;
    for (int i = 0; i < multi; i++) ans = modmulti(ans, 2);

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


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

bool check_even(string line){
for(size_t i = 0; i < line.size();i+=2){
if(line[i] != 'R' &&  line[i]!='U' &&  line[i] != 'D')return false;
}
return true;
}

bool check_odd(string line){
for(size_t i = 1; i < line.size();i+=2){
if(line[i] != 'L' &&  line[i]!='U' &&  line[i] != 'D')return false;
}
return true;
}


int main(){

string line;

cin>>line;

if(check_odd(line) && check_even(line))cout<<"Yes";
else cout<<"No";

}

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

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

string solve(int N, vector<ii>& xs)
{
    sort(xs.begin(), xs.end());

    ll t = 0;

    for (auto x : xs)
    {
        auto b = x.first, a = x.second;

        if (t + a > b)
            return "No";

        t += a;
    }

    return "Yes";
}

int main()
{
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    vector<ii> xs(N);

    for (int i = 0; i < N; ++i)
        cin >> xs[i].second >> xs[i].first;

    auto ans = solve(N, xs);

    cout << ans << '\n';

    return 0;
}


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


int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    int ans = 0;
    while(1) {
        if(*max_element(all(h))==0) break;
        int i = 0;
        while(i<n){
            if(h[i]==0) i++;
            else{
                ans++;
                while(i<n && h[i]>0){
                    h[i]--;
                    i++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

vector<list<int>> child,rchild;
vector<bool> isSearched,isRSearched;
vector<int> order,del;

int dfs(int a,int count){
  isSearched[a]=true;
  for(auto itr=child[a].begin();itr!=child[a].end();itr++){
    if(!isSearched[(*itr)]) count=dfs((*itr),count);
  }
  order[count]=a;
  return count+1;
}

void rdfs(int a,int d){
  //cout << a << " " << d << endl;
  isRSearched[a]=true;
  del[a]=d;
  for(auto itr=rchild[a].begin();itr!=rchild[a].end();itr++){
    if(!isRSearched[(*itr)]) rdfs((*itr),d);
  }
  if(a!=d){
    for(auto itr=child[a].begin();itr!=child[a].end();itr++){
      if(del[(*itr)]!=d) child[d].push_back((*itr));
    }
  }
  return;
}

LL ansdfs(int a){
  //cout << a << endl;
  LL ans=1;
  for(auto itr=child[a].begin();itr!=child[a].end();itr++){
    ans=ans*ansdfs((*itr))%1000000007;
  }
  return ans+1;
}

int main(){
  int n,m;
  cin >> n >> m;
  child=vector<list<int>>(n,list<int>());
  rchild=vector<list<int>>(n,list<int>());
  isSearched=vector<bool>(n,false);
  isRSearched=vector<bool>(n,false);
  order=vector<int>(n,-1);
  del=vector<int>(n,-1);
  vector<bool> isRoot(n,true);
  int s,d;
  for(int i=0;i<m;i++){
    cin >> s >> d;
    s--;
    d--;
    child[d].push_back(s);
    rchild[s].push_back(d);
  }
  int count=0;
  for(int i=0;i<n;i++){
    if(!isSearched[i]){
      count=dfs(i,count);
    }
  }
  // for(int i=0;i<n;i++){
  //   cout << order[i] << " ";
  // }
  // cout << endl;
  for(int i=0;i<n;i++){
    if(!isRSearched[order[n-i-1]]){
      rdfs(order[n-i-1],order[n-i-1]);
    }
  }
  for(int i=0;i<n;i++){
    if(del[i]==i){
      for(auto itr=child[i].begin();itr!=child[i].end();itr++){
        if(del[i]==del[(*itr)]){
          itr=child[i].erase(itr);
          itr--;
        }else{
          (*itr)=del[(*itr)];
          isRoot[(*itr)]=false;
        }
      }
    }
  }
  // for(int i=0;i<n;i++){
  //   cout << i << ":   ";
  //   for(auto itr=child[i].begin();itr!=child[i].end();itr++){
  //     cout << (*itr) << " ";
  //   }
  //   cout << endl;
  // }
  LL ans=1;
  for(int i=0;i<n;i++){
    if(isRoot[i]&&del[i]==i){
      ans=ans*ansdfs(i)%1000000007;
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3220
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fix(n) cout<<fixed<<setprecision(n)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
using namespace std;
typedef long long ll;
const ll mod=1000000007;
const double pi=3.1415926535;

int main(){
  double n;
  fix(12);
  cin>>n;
  co(2*pi*n);
  return 0;
}


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

int main() {
  int is, a;
  char str[1001];
  while(scanf("%s", str), str[0] != '0') {
    a = 0;
    for(is = 0; is < strlen(str); ++is) a += str[is] - '0';
    printf("%d\n", a);
  }
  return 0;
}

Measured memory_bytes: 536
import java.io.*;
import java.util.*;

public class Main {

    public void solve() {
        String s = in.nextToken();
        out.println(s.substring(0, 4) + " " + s.substring(4));
    }

    public void run() {
        in = new FastScanner();
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

    FastScanner in;
    PrintWriter out;

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String fileName) {
            try {
                br = new BufferedReader(new FileReader(fileName));
            } catch (FileNotFoundException e) {
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 8276
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#define MAXN 100000
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
bool cmp(const PII &a,const PII &b)
{return a.first-a.second<b.first-b.second;}
PII seq[MAXN+5];
set<int> S[2];
map<int,int> cnt[2];
int siz[2],target[2];
LL ansn;
LL ans[2][MAXN+5];
int X,Y,Z;
void Erase(int val,int typ)
{
	if(cnt[typ][val]==1)
		S[typ].erase(S[typ].find(val));
	cnt[typ][val]--;
	siz[typ]--;
	ansn-=1LL*val;
}
void Insert(int val,int typ)
{
	if(cnt[typ][val]==0)
		S[typ].insert(val);
	cnt[typ][val]++;
	siz[typ]++;
	ansn+=1LL*val;
}
void Try_To_Insert(int val,int typ)
{
	if(siz[typ]==target[typ])
	{
		int fro=*S[typ].begin();
		if(fro>val)	return;
		Erase(fro,typ);
	}
	Insert(val,typ);
}
int main()
{
	scanf("%d %d %d",&X,&Y,&Z);
	int n=X+Y+Z;
	int x,y,z;
	LL tot=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%d %d %d",&x,&y,&z);
		x-=z,y-=z;
		tot+=1LL*z;
		seq[i].first=x;
		seq[i].second=y;
	}
	sort(seq+1,seq+1+n,cmp);
	target[1]=Y,target[0]=X;
	//=====================================
	ansn=0;
	for(int i=1;i<=Y;i++)
		Try_To_Insert(seq[i].second,1);
	ans[1][Y]=ansn;
	for(int i=Y+1;i<=n-X;i++)
	{
		Try_To_Insert(seq[i].second,1);
		ans[1][i]=ansn;
	}
	//=====================================
	ansn=0;
	for(int i=n;i>=n-X+1;i--)
		Try_To_Insert(seq[i].first,0);
	ans[0][n-X+1]=ansn;
	for(int i=n-X;i>=Y+1;i--)
	{
		Try_To_Insert(seq[i].first,0);
		ans[0][i]=ansn;
	}
	//=====================================预处理完毕
	LL finans=-1;
	for(int i=Y;i<=n-X;i++)
		finans=max(finans,tot+ans[0][i+1]+ans[1][i]);
	printf("%lld\n",finans);
	return 0;
}

Measured memory_bytes: 10368
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Main main = new Main();
    main.solve();
  }
  public void solve() {
    Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    int N = scan.nextInt();
    int ans = 0;
    while (0 < N) {
      if (N % 10 == 2) {
        ans += 1;
      }
      N /= 10;
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 21844
/*
 * ・方針
 * 1. ボタン a を押すと、ボタン b が光るという関係を、
 *    a -> b の有向グラフと捉える
 * 2. 有向グラフをBFSして、頂点2への経路 (ボタン2を光らせるために必要な手順) を探索
 *    ※ 経路が発見できなかった場合 -1 を格納させると、そのまま 出力できて便利
 */
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> A(N+1);
    vector<vector<int> > G(N+1);
    for(int i = 1; i <= N; i++){
        cin >> A[i];
        G[i].push_back(A[i]);
    }

    // BFS のためのデータ構造
    vector<int> dist(N+1, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;

    // 初期条件 (頂点 1 を初期ノードとする)
    dist[1] = 0;
    que.push(1); // 1 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            que.push(nv);
        }
    }

    // 結果出力 (各頂点の頂点 1 からの距離を見る)
//    for (int v = 1; v <= N; ++v) cout << v << ": " << dist[v] << endl;

    cout << dist[2] << endl;
}

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

char f(int xsig) {
  return xsig == 1 ? '+' : '-';
}

int main()
{
  int n, a, b, c, d;
  cin >> n;
  a = n / 1000;
  b = n / 100 % 10;
  c = n / 10 % 10;
  d = n % 10;
  for (int i = 0; i < 8; i++) {
    int bsig = 2 * (i / 4) - 1, csig = 2 * (i / 2 % 2) - 1, dsig = 2 * (i % 2) - 1;
    if (a + bsig * b + csig * c + dsig * d == 7) {
      cout << a << f(bsig) << b << f(csig) << c << f(dsig) << d << "=7" << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<numeric>
#include<set>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef long long li;
#define yn(i) print((i)?"Yes":"No")
#define rep(i,n) for(int i=0;i<(n);i++)

#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
}



int main(){
  int a,b,c; cin >>a >>b >>c;
  if(a>b)swap(a,b);
  yn(a<=c and c<=b);
}





Measured memory_bytes: 3568
#include <iostream>
#include <algorithm>
#include <math.h>

using namespace std;


int main(){
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    printf( "%.10f\n",  pow( pow(x1-x2, 2.0)+pow(y1-y2, 2.0), 0.5 ) );
    return 0;
}



Measured memory_bytes: 3396
#include<stdio.h>

int main(){
  int i, j;
  int h, w;

  while(1){
    scanf("%d %d", &h, &w);

    if(h == 0 && w == 0) break;
  
    for(i = 0; i < h; i++){
      for(j = 0; j < w; j++){
	printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }
  
  return 0;
}


Measured memory_bytes: 2044
import java.util.Scanner;

public class Main {

    private void execute() throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.nextLine());
        String s = sc.nextLine();
        if (a >= 3200) {
            System.out.println(s);
        } else {
            System.out.println("red");
        }
    }

    public static void main(String[] args) {
        try {
            new Main().execute();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}


Measured memory_bytes: 21972
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define MAXN 405
#define INF 1000000000000000000LL
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll n,k,a[MAXN],dp[MAXN][MAXN],sum[MAXN];
int main()
{
    scanf("%lld",&n);
    for(ll i=1;i<=n;i++) scanf("%lld",&a[i]);
    for(ll i=1;i<=n;i++) sum[i]=sum[i-1]+a[i];
    for(ll l=2;l<=n;l++)
    {
        for(ll i=1;i+l-1<=n;i++)
        {
            ll j=i+l-1;
            dp[i][j]=INF;
            for(ll k=i;k<j;k++) dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]+sum[j]-sum[i-1]);
        }
    }
    printf("%lld\n",dp[1][n]);
    return 0;
}



Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int a,b,c,x,y;
int main()
{
    while(cin>>a>>b>>c>>x>>y)
    {
       long long ans=0;
       if(a+b>2*c)
       {
           if(x>y)
           {
               ans+=2*y*c;
               if(a>2*c)
               {
                   ans+=(x-y)*2*c;
               }
               else
               {
                   ans+=(x-y)*a;
               }
           }
           else
           {
               ans+=2*x*c;
               if(b>2*c)
               {
                   ans+=(y-x)*2*c;
               }
               else
               {
                   ans+=(y-x)*b;
               }
           }
       }
       else
       {
           ans+=x*a+y*b;
       }
       cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
/*

  "With age, comes wisdom. With travel, comes understanding.
   Remember that happiness is a way of travel – not a destination"

*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int            long long int
#define ld             long double
#define F              first
#define S              second
#define pb             push_back
#define si             set <int>
#define vi             vector <int>
#define pii            pair <int, int>
#define vpi            vector <pii>
#define vpp            vector <pair<int, pii>>
#define mii            map <int, int>
#define mpi            map <pii, int>
#define spi            set <pii>
#define endl           "\n"
#define sz(x)          ((int) x.size())
#define all(p)         p.begin(), p.end()
#define que_max        priority_queue <int>
#define que_min        priority_queue <int, vi, greater<int>>
#define bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)       for(auto x : a) cout << x << " "; cout << endl
#define print1(a)      for(auto x : a) cout << x.F << " " << x.S << endl
#define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << endl

inline int power(int a, int b)
{
	int x = 1;
	while (b)
	{
		if (b & 1) x *= a;
		a *= a;
		b >>= 1;
	}
	return x;
}

typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> Set;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr (names + 1, ',');
	cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 200005;
int a[N], n, m, k;
string s;

void solve()
{
	cin >> s;
	for (auto x : s)
		cout << 'x';

}

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cout << setprecision(9) << fixed;
	clock_t z = clock();
	solve();
	cerr << "Run Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);

	return 0;
}

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


def solve(A: int, B: int, N: int):
    def f(x):
        return int(A * x / B) - A * int(x / B)
    x = min(N, B-1)
    return f(x)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    print(solve(A, B, N))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


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

using namespace std;

typedef pair<int, int> P_ii;
typedef pair<string, int> P_si;

int main() {
    int c1, c2, c3, c4, c5, c6, c7, c8, c9;
    cin >> c1 >> c2 >> c3 >> c4 >> c5 >> c6 >> c7 >> c8 >> c9;

    if (c1 + c5 != c2 + c4) printf("%s\n", "No");
    else if (c1 + c9 != c3 + c7) printf("%s\n", "No");
    else if (c5 + c9 != c6 + c8) printf("%s\n", "No");
    else if (c1 + c8 != c7 + c2) printf("%s\n", "No");
    else printf("%s\n", "Yes");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

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

int dp[101][4][4][4];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin>>N;
    dp[0][3][3][3]=1;
    for(int index=0;index<N;index++){
        for(int i=0;i<4;i++){
            for(int j=0;j<4;j++){
                for(int k=0;k<4;k++){
                    if(dp[index][i][j][k]==0) continue;
                    //文字を新しく追加
                    for(int c=0;c<4;c++){
                        if(i == 1 && j == 0 && c == 2) continue;
                        if(i == 0 && j == 1 && c == 2) continue;
                        if(i == 2 && j == 0 && c == 1) continue;
                        if(i == 1 && k == 0 && c == 2) continue;
                        if(j == 1 && k == 0 && c == 2) continue;

                        dp[index+1][c][i][j] += dp[index][i][j][k];
                        dp[index+1][c][i][j] %= MOD;
                    }
                }
            }
        }
    }
    int ans=0;
    for(int i=0;i<4;i++){
        for(int j=0;j<4;j++){
            for(int k=0;k<4;k++){
                ans += dp[N][i][j][k];
                ans %= MOD;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
/* https://codeforces.com/contest/1360/problem/H */
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
using vs = vector<string>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vpi = vector<pair<int, int>>;
using vpl = vector<pair<ll, ll>>;
using ld = double;

#define f first
#define s second 
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define pb push_back
#define	lb lower_bound
#define	ub upper_bound
#define	sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define ins insert

const int MAX = INT_MAX;

int main() {
	
	string s;
	cin>>s;
	string t;
	cin>>t;
	int ans = INT_MAX;
	for (int i = 0;i < s.length() - t.length() + 1;++i) {
		int cnt = 0 ;
		for (int j = 0;j < t.length();++j) {
			if (t[j] != s[i+j]) {
				cnt += 1;
			}
		}

		ans = min(ans, cnt);
	}

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


Measured memory_bytes: 3588
class UnionFindTree:
    def __init__(self, n):
        self.par = [-1 for _ in range(n)]
        
    def find(self, x):
        if self.par[x] < 0:
            return x
        self.par[x] = self.find(self.par[x])
        return self.par[x]
        
    def size(self, x):
        return -self.par[self.find(x)]
        
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return 0
        if self.size(x) < self.size(y):
            x, y = y, x
        self.par[x] += self.par[y]
        self.par[y] = x
        return 1
        
n, m = map(int, input().split())
uf = UnionFindTree(n)
ans = n
for _ in range(m):
    x, y, z = map(int, input().split())
    ans -= uf.unite(x-1, y-1)
print(ans)

Measured memory_bytes: 5512
/*#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
*/

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

#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())

typedef long long ll;
const ll INF = LLONG_MAX - 100;
const ll mod = 1e9 + 7;
const int MAX_N = 5e5 + 5;
int dx[] = { -1LL,0,1LL,0 }, dy[] = { 0,1LL,0,-1LL };
vector<ll> prime;

ll inv[MAX_N], fac[MAX_N];

template <class T = ll> T in() { T x; cin >> x; return (x); }
inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; }return a; }
inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); }
inline ll POW(ll a, ll b) { ll c = 1LL; while (b > 0) { if (b & 1LL) { c = a * c%mod; }a = a * a%mod; b >>= 1LL; }return c; }
inline void _nCr() { fac[0] = 1LL; for (int i = 1LL; i < MAX_N; i++) { fac[i] = fac[i - 1LL] * i%mod; }for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], mod - 2); } }
inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % mod)*inv[n - r] % mod; }
inline void PRI(ll n) { bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) { a[i] = 1LL; }for (int i = 2; i < n + 1LL; i++) { if (a[i]) { prime.pb(i); ll b = i; while (b <= n) { a[b] = 0; b += i; } } } }

// class segtree {
// public:
// 	int p = 2;
// 	vector<int> B;
// 	segtree(vector<int> &A) {
// 		while (A.size() > p) p *= 2;
// 		B = vector<int>(2*p-1,INF);
// 		for (int i = 0;i < A.size();i++) {
// 			B[p-1+i] = A[i];
// 		}
// 		for (int i = p - 2;i >= 0;i--) {
// 			B[i] = min(B[i*2+1],B[i*2+2]);
// 		}
// 	}

// 	void update(int pos) {
// 		pos += p-1;
// 		B[pos] = {'~',0};
// 		pos = (pos-1)/2;
// 		while (pos >= 0) {
// 			B[pos].first = min(B[pos*2+1].first,B[pos*2+2].first);
// 			B[pos].second = B[pos*2+1].second + B[pos*2+2].second;
// 			if (pos == 0) break;
// 			pos = (pos-1)/2;
// 		}
// 	}

// 	int getval(int start,int end,int k = 0,int l = 0,int r = -1) {
// 		if (r < 0) r = p - 1;
// 		if (start <= l && r <= end) {return B[k];}
// 		if (r < start || end < l) {return INF;}
// 		int L,R;
// 		L = getval(start,end,k*2+1,l,(l+r)/2);
// 		R = getval(start,end,k*2+2,(l+r)/2+1,r);
// 		return min(L,R);
// 	}
// };

signed main() {
	int n; cin >> n;
	pair<int,int> A[n], B[n];
	REP (i,n) cin >> A[i].first >> A[i].second;
	REP (i,n) cin >> B[i].second >> B[i].first; //(Y,X)
	sort(A,A+n,greater<pair<int,int>>());
	sort(B,B+n);
	bool ok[n];
	REP (i,n) ok[i] = true;
	int ans = 0;
	REP (i,n) {
		REP (j,n) {
			if (A[i].first < B[j].second && A[i].second < B[j].first && ok[j]) {
				ans++; ok[j] = false;
				break;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef pair<long long int,long long int> mypair;
int main(void){
long long int n,k;
cin>>n>>k;
long long int a,b;
long long int t=0;
vector<mypair> m;
for(int i=0;i<n;i++){
	cin>>a>>b;
	m.push_back(mypair(a,b));
}
sort(m.begin(),m.end());
int l=0;
for(int i=0;i<n;i++){
	//cin>>a[i]>>b[i];
t+=m[i].second;
if(t>=k&&l==0){
	cout<<m[i].first<<endl;
l++;
}
}
	return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define ll  long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define br cout <<"\n";
#define all(x)  (x).begin(),(x).end()
#define rall(x)  (x).rbegin(),(x).rend()
#define tr(c,i) for(auto i : c)
#define pii pair< int,int >
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define pq priority_queue< pair<ll,pii> ,vector<pair<ll,pii>>,greater <pair<ll,pii>> >p;//container adapter makes ascending q
using namespace std;
const int dx[] = { 1, -1 , 0 , 0  };
const int dy [] = { 0 ,0 , 1 , -1  };
const int MOD = 1000 * 1000 * 1000 + 7 ;
const int N = 4  ;
const int MAXN = 1000*100 + 5 ;
const int INF = INT_MAX ;

int main (){
int a , b , c ;
cin >>a >> b >> c ;

set<int > s({a,b,c}) ;
if ((int)s.size() == 2 )
cout << "Yes" ; 
else
cout <<"No"; 


 


return 0 ;
 
}

// 2 year => 2 3 -> 6 5 1 5 5 1 5 


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

int main(){
  string big = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  string ans = "a";
  char in;
  cin >> in;
  for(int i=0; i<26;i++){
    if(in == big[i]){
      ans = "A";
      break;
    }
  }
  cout << ans << endl;
}

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

const long long mod = 1000000007;

long long dfs(int K, vector<vector<int>> &graph, int now, int from) {
    int can_use_color_num;
    if (from == -1) {
        can_use_color_num = K - 1;
    } else {
        can_use_color_num = K - 2;
    }

    if (K < graph[now].size()) {
        return 0;
    } else {
        long long case_num = 1;
        for (int e : graph[now]) {
            if (e == from) continue;

            case_num *= can_use_color_num;
            can_use_color_num--;
            case_num %= mod;
        }

        for (int e : graph[now]) {
            if (e == from) continue;
            case_num *= dfs(K, graph, e, now);
            case_num %= mod;
        }
        return case_num;
    }
}

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

    vector<vector<int>> graph(N);
    for (int i = 0; i < N - 1; ++i) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    long long answer = K * dfs(K, graph, 0, -1);
    answer %= mod;
    cout << answer << endl;
    return 0;
}

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

public class Main {
	Scanner sc = new Scanner(System.in);

	void run() {
		for (;;) {
			int n = sc.nextInt();
			if (n == 0) {
				break;
			}

			int[][] wf = new int[11][11];

			boolean[] used = new boolean[11];
			for (int i = 0; i < wf.length; i++) {
				Arrays.fill(wf[i], Integer.MAX_VALUE >> 4);
			}
			for (int i = 0; i < n; i++) {
				int x = sc.nextInt();
				int y = sc.nextInt();
				int c = sc.nextInt();
				wf[x][y] = c;
				wf[y][x] = c;
				wf[x][x] = 0;
				wf[y][y] = 0;
				used[x] = true;
				used[y] = true;
			}

			for (int k = 0; k < 11; k++) {
				for (int i = 0; i < 11; i++) {
					for (int j = 0; j < 11; j++) {
						wf[i][j] = Math.min(wf[i][j], wf[i][k] + wf[k][j]);
					}
				}
			}

			int ans = -1;
			int min = Integer.MAX_VALUE >> 2;
			for (int i = 0; i < 11; i++) {
				int sum = 0;
				for (int j = 0; j < 11; j++) {
					if (used[j]) {
						sum += wf[i][j];
					}
				}
				if (min > sum) {
					min = sum;
					ans = i;
				}
			}
			System.out.println(ans + " " + min);

		}
	}

	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};


template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
const int MOD =1000000007;
using mint= Fp<MOD>;

int main(){
  ll N,K;cin>>N>>K;
  mint min,max;
  ll start=K-1;
  mint ans=0;
  for(ll i=start;i<N+1;i++){
    ans+=N*(i+1)-(i+1)*i/2-i*(i+1)/2+1;
  }
  cout<<ans<<endl;

}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 998244353;

signed main() {
  int q;
  cin>>q;
  int a,b,t,p1,q1,p2,q2,ans=0,o=0;
  long double k;
  for(int i=0;i<q;i++){
    ans=0;
    cin>>a>>b;
    k=a*b;
    k=sqrt(k);
  t=floorl(k)+1;
    if(t==a)p1=t+1;
    else p1=t;
    if((a*b)%p1!=0)q1=(a*b)/p1;
    else q1= (a*b)/p1 -1;
    if(q1<b)ans+=q1;
    else  ans+=q1-1;
    if(t==b)q2=t+1;
    else q2=t;
    if((a*b)%q2!=0)p2=(a*b)/q2;
    else p2=(a*b)/q2 -1;
    if(p2<a)ans+=p2;
    else ans+=p2-1;
    if((t-1)*(t-1)==a*b)t--;
    if(t>b&&q1<b)q1++;
    if(t>a&&p2<a)p2++;
    ans+=max(o,min(t-q1-1,t-p2-1));
  cout<<ans<<endl;
  //cerr<<p1<<' '<<q1<<' '<<p2<<' '<<q2<<' '<<t;
  }





  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define INF 0x7fffffff
#define LL_INF 0x7fffffffffffffff
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

vector<pair<ll, int>> primeFactorization(ll n)
{
	vector<pair<ll, int>> primes;
	for(ll i=2;i<=sqrt(n);i++)
	{
		if(n%i==0)
		{
			int cnt = 0;
			while(n%i==0)
			{
				n/=i;
				cnt++;
			}
			primes.push_back(make_pair(i, cnt));
		}
	}
	if(n!=1)
		primes.push_back(make_pair(n, 1));
	return primes;
}


int main(void)
{
	ll n; cin >> n;
	auto p1 = primeFactorization(n-1);
	ll ans = 1;
	for(auto i : p1) {
		ans *= (i.second + 1);
	}
	for(ll i=2;i*i<=n;i++) {
		if(n % i == 0) { 
			if(i * i == n) { 
				ans++;
			}
			else {
				ll nn = n;
				while(nn % i == 0) nn /= i;
				if(nn % i == 1) {
					ans++;
				}
				nn = n;
				while(nn % (n/i) == 0) nn /= (n/i);
				if(nn % (n/i) == 1) {
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N=5050;
const ll inf=9e18;
ll dp[N];
int p[N],cnt[N];
int main()
{
	int n,A,B;
	scanf("%i %i %i",&n,&A,&B);
	for(int i=1;i<=n;i++) scanf("%i",&p[i]),dp[i]=inf;
	for(int i=1;i<=n;i++)
	{
		int lo=0,hi=0,mx=0;
		for(int j=i-1;j>=1;j--)
		{
			if(p[j]<p[i])
			{
				if(p[j]>mx)
				{
					mx=p[j];
					dp[i]=min(dp[i],dp[j]+(ll)lo*B+(ll)hi*A);
				}
				lo++;
			}
			else hi++;
			//printf("%i %i\n",p[j],p[i]);
		}
		if(lo==0) dp[i]=min(dp[i],(ll)hi*A);
		//printf("%i %lld hi:%i lo:%i\n",i,dp[i],hi,lo);
	}
	ll ans=inf;
	for(int i=n;i>=1;i--)
	{
		int lo=0,hi=0;
		for(int j=1;j<p[i];j++) lo+=cnt[j];
		for(int j=p[i]+1;j<=n;j++) hi+=cnt[j];
		ans=min(ans,dp[i]+(ll)lo*B+(ll)hi*A);
		cnt[p[i]]++;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 384
C = [list(map(int, input().split())) for i in range(3)]

AB = [0 for i in range(6)]
AB[3] = C[0][0] - 0
AB[1] = C[1][0] - AB[3]
AB[2] = C[2][0] - AB[3]
AB[4] = C[0][1] - 0
AB[5] = C[0][2] - 0
if C[1][1] != AB[1] + AB[4]:
    print('No')
    quit()
if C[1][2] != AB[1] + AB[5]:
    print('No')
    quit()
if C[2][1] != AB[2] + AB[4]:
    print('No')
    quit()
if C[2][2] != AB[2] + AB[5]:
    print('No')
    quit()

print('Yes')

Measured memory_bytes: 38384
import java.util.*;
import static java.lang.Math.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		long k = sc.nextLong();
		int[][] ab = new int[n][2];
		for(int i = 0; i < n; i++){
		    int a = sc.nextInt();
		    int b = sc.nextInt();
		    ab[i][0] = a;
		    ab[i][1] = b;
		}
		Arrays.sort(ab, (s, t) -> Integer.compare(s[0], t[0]));
		
		// 計算
		int result = 0;
		for(int i = 0; i < n; i++){
		    k -= ab[i][1];
		    if(k <= 0){
		        result = ab[i][0];
		        break;
		    }
		}
		
		// 出力
		System.out.println(result);
	}
}


Measured memory_bytes: 91608
N=int(input())
h=list(map(int,input().split()))

inf=float("inf")
dp=[inf]*N
dp[0]=0

for i in range(N-1):
    if i!=N-2:
        dp[i+2]=min(dp[i+2],dp[i]+abs(h[i+2]-h[i]))
    dp[i+1]=min(dp[i+1],dp[i]+abs(h[i+1]-h[i]))

print(dp[N-1])

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

int main() {
  
  int A, B, C, X, Y;
  int price = 0;

  cin >> A >> B >> C >> X >> Y;

  if (X >= Y) {
    if (A + B <= 2 * C) {
      if (A <= 2 * C) price += Y * (A + B) + (X - Y) * A;
      else if (A > 2 * C) price += Y * (A + B) + 2 * (X - Y) * C;
    }
    else if (A + B > 2 * C) {
      if (A <= 2 * C) price += 2 * Y * C + (X - Y) * A;
      else if (A > 2 * C) price += 2 * Y * C + 2 * (X - Y) * C;
    }
  }
  else if (X < Y) {
    if (A + B <= 2 * C) {
      if (B <= 2 * C) price += X * (A + B) + (Y - X) * B;
      else if (B > 2 * C) price += X * (A + B) + 2 * (Y - X) * C;
    }
    else if (A + B > 2 * C) {
      if (B <= 2 * C) price += 2 * X * C + (Y - X) * B;
      else if (B > 2 * C) price += 2 * X * C + 2 * (Y - X) * C;
    }
  }
  
  cout << price << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(arr) (int)(arr).size()
#define rng(arr) arr.begin(), arr.end()
#define show(x) cout << #x << " = " << x << endl;
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;
typedef long long int ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

void Main();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

void Main() {
  vector<vector<int>> c(3, vector<int>(3));
  rep(i, 3) rep(j, 3) cin >> c[i][j];

  vector<int> a(3), b(3);
  a[0] = 1;
  rep(i, 3) b[i] = c[0][i] - a[0];
  rep(i, 3) a[i] = c[i][0] - b[0];

  bool f = true;
  rep(i, 3) rep(j, 3) {
    if (c[i][j] != a[i] + b[j]) f = false;
  }

  cout << (f ? "Yes" : "No") << endl;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
	string s;
	cin >> s;
	if (s[5] == '0' and s[6] <= '4') {
		cout << "Heisei" << endl;
	}
	else {
		cout << "TBD" << endl;
	}
	return 0;
}


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

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define upper(n,m) (n+m-1)/m
#define rounding(n) (int)((double)n+0.5)

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define ALL(a) a.begin(),a.end()

#define coutALL(i,a) {int i=0;for(int e:a) cout<<(i++?" ":"")<<e; cout<<endl;}
#define coutYN(a) cout<<(a?"Yes":"No")<<endl;
#define coutyn(a) cout<<(a?"yes":"no")<<endl;

#define deb cout<<"debug"<<endl
#define debn(n) cout<<"debug: "<<n<<endl

//#define int long long

const int INF=100000;
const int MOD=(int)1e9+7;
const int EPS=1e-12;
//const int dx[]={0,1,0,-1},dy[]={-1,0,1,0};
const int dx[]={-1,-1,-1,0,1,1,1,0},dy[]={-1,0,1,1,1,0,-1,-1};

using namespace std;

typedef pair<int,int> P;
typedef long long LL;

int dp[41][410][410];

void print(int dp[410][410]){

  REP(i,20){
    REP(j,20){
      if(j) cout<<" ";
      cout<<(dp[i][j]==INF?-1:dp[i][j]);
    }
    cout<<endl;
  }

}

signed main(){

  ios::sync_with_stdio(false);

  int n,ma,mb;
  cin>>n>>ma>>mb;

  fill(dp[0][0],dp[41][0],INF);
  dp[0][0][0]=0;

  REP(i,n){

    int a,b,c;
    cin>>a>>b>>c;

    REP(j,410)
      REP(k,410)
      if(dp[i][j][k]!=INF){
	dp[i+1][j][k]=min(dp[i+1][j][k],dp[i][j][k]);
	dp[i+1][j+a][k+b]=min(dp[i+1][j+a][k+b],dp[i][j][k]+c);
      }

  }

  int r=INF;

  for(int i=1;ma*i<410 && mb*i<410;i++) r=min(r,dp[n][ma*i][mb*i]);

  cout<<(r==INF?-1:r)<<endl;

  return 0;

}


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

for i in range(n):

    if (n-2*i) != 0 and (k-m*i) % (n-2*i) == 0:
        j = (k - m * i) // (n - 2 * i)
        if 0 <= j <= m:
            print('Yes')
            exit()
print('No')


Measured memory_bytes: 3060
#include <bits/stdc++.h> 
    //#define M_PI 3.14159265358979323846



using namespace std;

#define rep(i,a,b) for(int i=a;i<b;++i)
#define repb(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vl vector<long long int>
#define vc vector<char>
#define vld vector<ld>
#define vvi vector<vector<int> >
#define vvl vector<vector<long long> >
#define vvld vector<vector<ld> >
#define vpii vector<pii>
#define vpll vector<pll>
#define ld long double
#define ll long long
#define sz(a) (ll)a.size()
#define ssortA(arr)   stable_sort(arr.begin(),arr.end())
#define ssortB(arr)   stable_sort(arr.begin(),arr.end(),greater<ll >());
#define pii pair<int,int>
#define pll pair<long long,long long>
#define ff first
#define ss second
#define search(arr,c)  binary_search(arr.begin(),arr.end(),c)
#define pb   push_back
#define pf push_front
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define endl "\n" 
#define PI acos(-1.0)
#define GCD(a,b) __gcd(a,b)
#define popcount(x) __builtin_popcountll(x)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define r1(x) cin>>x
#define r2(x,y) cin>>x>>y
#define r3(x,y,z) cin>>x>>y>>z
#define r4(a,b,c,d) cin>>a>>b>>c>>d
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define fix(f,n) fixed<<setprecision(n)<<f<<endl
#define check(ds, a) (ds.find(a)!=ds.end()?1:0)
#define mem(arr)  memset(arr,0,sizeof(arr))
const int M=(int)1e9+7;
int main(){
    int n;cin>>n;
    vl arr(n);
    rep(i,0,n){r1(arr[i]);}
    vl suf(n,0);suf[n-1]=0;
    repb(i,n-2,0){
        suf[i]=(suf[i+1]+arr[i+1])%M;
    }
    ll res=0;
    rep(i,0,n-1){
        ll pro=(arr[i]*suf[i])%M;
        res=(res+pro)%M;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 6408
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

from collections import deque
ss = ins()
s = deque([ss[i] for i in range(len(ss))])
dir = 0
q = inn()
for qq in range(q):
    a = input().split()
    if a[0]=='1':
        dir = 1-dir
    else:
        f = a[1]
        c = a[2]
        if f=='1' and dir==0 or f=='2' and dir==1:
            s.appendleft(c)
        else:
            s.append(c)
    #ddprint(f"s {s} dir {dir}")
if dir==1:
    s.reverse()
print(''.join(s))


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

#define REP(i, x) for (int i = 0, i##_len = (int)(x); i < i##_len; i++)
#define REP1(i, x) for (int i = 1, i##_len = (int)(x); i <= i##_len; i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREP1(i, x) for (int i = ((int)(x)); i > 0; i--)
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)
const int MOD = (int)1e9 + 7;
const int INF = 1145141919;
using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using l_l = pair<ll, ll>;
using d_d = pair<double, double>;
using vint = vector<int>;
using vintint = vector<vector<int>>;
using vll = vector<ll>;
using vbool = vector<bool>;

int main() {
    // input
    int H, W;
    cin >> H >> W;

    vintint c(10, vint(10));
    REP(i, 10) REP(j, 10) cin >> c[i][j];

    vintint A(H, vint(W));
    REP(i, H) REP(j, W) cin >> A[i][j];

    // solve
    // warshall_floyd
    vintint d(10, vint(10));
    REP(i, 10) REP(j, 10) d[i][j] = c[i][j];
    // REP(i, 10) REP(j, 10) d[i][j] = (c[i][j] != -1 ? c[i][j] : 10000000);

    REP(k, 10) {
        REP(i, 10) {
            REP(j, 10) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }

    int ans = 0;
    REP(i, H) REP(j, W) {
        if (A[i][j] != -1)
            ans += d[A[i][j]][1];
    }
    cout << ans;
}

Measured memory_bytes: 384
#include<stdio.h>
main(){

 int a,b,c,x,y,z;

 scanf("%d%d%d",&a,&b,&c);

 if(a > b){
 x = a;
 a = b;
 b = x;
}

if(b > c){
 y = b;
 b = c;
 c = y;
}

 if(a > b){
 z = a;
 a = b;
 b = z;
}

printf("%d %d %d\n",a,b,c);

return 0;

}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
 
 
int main()
{
 
    int n;
    cin>>n;

    vector<int> p(n);
    for(int i=0;i<n;i++){
        cin>>p.at(i);
    }


    int cnt=0;
    for(int i=0;i<n-2;i++){
        if(p.at(i)<p.at(i+1)&&p.at(i+1)<p.at(i+2))
            cnt++;
        else if(p.at(i+1)<p.at(i)&&p.at(i+2)<p.at(i+1))
            cnt++;
    }

    cout<<cnt<<endl;

    return 0;
}   

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<cstdlib>
#include<ctime>
using namespace std;
typedef long long ll;
int main() {
	int n, ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		while (a % 2 == 0) {
			a /= 2;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

/* define const */

/* end up defineing const */

long a;
long b;
long x;

int main()
{
  cin >> a >> b >> x;
  if (a%x == 0)
    cout << b/x - a/x + 1 << endl;
  else
    cout << b/x - a/x << endl;
}


Measured memory_bytes: 256