akhauriyash/Code-Regression huggingface dataset:
l = list(map(int, input().split()))
l += list(map(int, input().split()))
l += list(map(int, input().split()))
n = int(input())
for i in range(n):
  b = int(input())
  if b in l:
    index = l.index(b)
    l[index] = 0
if l[0] == l[1] == l[2] or l[3] == l[4] == l[5] or l[6] == l[7] == l[8] or l[0] == l[3] == l[6] or l[1] == l[4] == l[7] or l[2] == l[5] == l[8] or l[0] == l[4] == l[8] or l[2] == l[4] == l[6]:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9240
import java.util.Scanner;
public class Main {
public static int n ;
public static int k ;
public static boolean []d = new boolean [10];
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while (scan.hasNextInt()) {
			int n = scan.nextInt();
			int k = scan.nextInt();
			for (int i = 1; i <=k; i++) {
				d[scan.nextInt()] = true;
			}
			while (n>0) {
				if (panduan(n)) {
					System.out.println(n);
					break;
				}
				++n;
			}
		}
	}
	public static boolean  panduan (int n) {
		 while(n>0)
		    {
		        if(d[n%10]) return false;
		        n /= 10;
		    }
		
		return true;
	}
}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repm(i, m, n) for (int i = m; i < (n); i++)
#define eps (1e-7)
#define inf (1e9)
#define pi (acos(-1))
typedef long long ll; //1e19
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

    ll n, a, b;
    cin >> n >> a >> b;
    ll k = n / (a + b);
    ll l = n % (a + b);
    cout << k * a + min(a, l) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio> 
#include <cstring>

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rangeRep(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
struct Student {
	int t, n, m, s;
};

constexpr int timeOffset = 540;
//[PC][time] = Student
int dp[1000][1260 - timeOffset] = { 0 };


class Solve {
public:
	Solve() {};
	~Solve() {};

	void solver() {
		std::vector<std::vector<int>> results;
		while (1) {
			int n, m, r, q;
			std::vector<Student> students;
			std::cin >> n >> m;
			if (!n) break;

			std::memset(dp, 0, 1000 * (1260 - timeOffset) * sizeof(int));
			long long a = 1000 * (1260 - timeOffset) * sizeof(int);
			results.push_back(std::vector<int>());
			//login info
			std::cin >> r;
			Student s;
			rep(i, r) {
				//time, PC, student, isLogin
				std::cin >> s.t >> s.n >> s.m >> s.s;
				//login
				if (s.s) {
					//set login start time
					dp[s.n - 1][s.t - timeOffset] = s.m;
				}//logout
				else {
					//Fill until login start time
					int time = s.t - timeOffset - 1;
					while (dp[s.n - 1][time] == 0) {
						dp[s.n - 1][time--] = s.m;
					} 
				}
			}

			//question [ts, te]
			std::cin >> q;
			rep(i, q) {
				int num = 0;
				int ts, te, m;
				std::cin >> ts >> te >> m;
				ts -= timeOffset; te -= timeOffset;
				//Check if logged in on any PC.
				rangeRep(j, ts, te) {
					rep(k, n) {
						if (dp[k][j] == m) {
							num++;
							break;
						}
					}
				}
				results.back().push_back(num);
			}
		}

		for (auto& x : results) {
			for (auto& y : x) {
				std::cout << y << std::endl;
			}
		}
	}
private:

};

int main() {
	Solve solve;
	solve.solver();
	return 0;
}

Measured memory_bytes: 5792
# include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
template<typename T>vector<T> make_v(size_t a){ return vector<T>(a); }
template<typename T,typename... Ts>auto make_v(size_t a, Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type fill_v(T &t, const V &v){ t = v; }
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type fill_v(T &t, const V &v){ for(auto &e : t) fill_v(e, v); }
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int a[5];

int main(){
    INIT;
    REP(i, 5)cin >> a[i];
    int ans = 0;
    REP(i, 5){
        ans += a[i]/10*10;
        a[i] %= 10;
    }
    sort(a, a + 5);
    REP(i, 5){
        if(a[i] != 0){
            ans += a[i];
            a[i] = 0;
            break;
        }
    }
    REP(i, 5){
        if(a[i])ans += 10;
    }
    cout << ans << endl;
}

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

int main() {
int A,B,C,D,E,F,H,I;
cin >> A >> B >> C >> D >> E;
 F = -A*C;
 H=B*E;
  if(A<0&&A>-100){
        cout<< F+D+H <<endl;
      } else if(A>0&&A<100) {
         I = (B-A)*E;
        cout<< I <<endl; 
        }
  return 0;

}


Measured memory_bytes: 3096
#include <bits/stdc++.h> 
using namespace std;
int n,k,ans,p;
int GuiLv[12][6]= 
{
    {4,2,0,9,7},
    {1,10,8,6,4},
    {9,7,5,3,1},
    {6,4,2,0,9},
    {3,1,10,8,6},
    {0,9,7,5,3},
    {8,6,4,2,0},
    {5,3,1,10,8},
    {2,0,9,7,5},
    {10,8,6,4,2},
    {7,5,3,1,10}
};
int main() 
{
	ios::sync_with_stdio(false);
    scanf("%d%d",&n,&k);
    ans=((n-2)/11)*5;
    if(n<=2)
        for(int i=0; i<p; i++)
            for(int j=0; j<5; j++) 
			{
                if(GuiLv[i][j]==k)
                    ans++;
            }
    else 
        for(int i=0; i<(n-2)%11; i++) 
            for(int j=0; j<5; j++)
                if(GuiLv[i][j]==k)
                    ans++;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>

int main(){

    double x1, y1, x2, y2;
    std::cin >> x1 >> y1 >> x2 >> y2;

    std::printf("%.10f\n", std::sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)));

    return 0;
}



Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

int main() {
    int n, y;
    cin >> n >> y;
    
    for (int i=0; i<=n; i++){
        for (int j=0; i+j<=n; j++){
            int k = n-i-j;

            if (10000*i + 5000*j + 1000*k == y){
                cout << i << endl;
                cout << j << endl;
                cout << k << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main{
	
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		for(int i = 0; i < n; i++){
			CCircle c1 = new CCircle(new CPoint(sc.nextDouble(), sc.nextDouble()), sc.nextDouble());
			CCircle c2 = new CCircle(new CPoint(sc.nextDouble(), sc.nextDouble()), sc.nextDouble());
			
			System.out.println(CCircle.clossing(c1, c2));
		}
		
		sc.close();
	}
	
}

class CCircle{
	CPoint center;
	double r;
	
	CCircle(CPoint center, double r) {
		this.center = center;
		this.r = r;
	}
	
	static Clossing clossing(CCircle c1, CCircle c2) {
		double distance = CPoint.distance(c1.center, c2.center);
		
		if(distance + c1.r < c2.r) return Clossing.AINB;
		else if(distance + c2.r < c1.r) return Clossing.BINA;
		else if(c1.r + c2.r < distance) return Clossing.OUTSIDE;
		else return Clossing.X;
	}
	
	static double max(double d1, double d2) {
		return (d1 > d2) ? d1: d2;
	}
	
	static double min(double d1, double d2) {
		return (d1 < d2) ? d1: d2;
	}
}

class CPoint{
	double x;
	double y;
	
	CPoint(double x, double y) {
		this.x = x;
		this.y = y;
	}
	
	static double distance(CPoint p1, CPoint p2) {
		double dx = p1.x - p2.x;
		double dy = p1.y - p2.y;
		
		return Math.sqrt(dx * dx + dy * dy);
	}
}

enum Clossing{
	
	OUTSIDE(0), X(1), AINB(-2), BINA(2);
	
	private int n;
	
	private Clossing(int n) {
		this.n = n;
	}
	
	public String toString() {
		return String.valueOf(this.n);
	}
}

Measured memory_bytes: 20548
#include <iostream>

int main(){
  int Vol_1_B,Vol_1_A,Vol_2;
  
  std::cin >> Vol_1_B >> Vol_1_A >> Vol_2;
  int res = Vol_2 - (Vol_1_B - Vol_1_A) >= 0 ? Vol_2 - (Vol_1_B - Vol_1_A) : 0;

	std::cout << res << std::endl; 
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<utility>
using namespace std;
#define int long long
#define veb vector<bool>
#define vveb vector<veb>
#define vel vector<long long>
#define vvel vector<vel>
#define vvvel vector<vvel>
void mmin(int &a, int b) { a = min(a, b); }
void mmax(int &a, int b) { a = max(a, b); }
void sor(vel &v) { sort(v.begin(), v.end()); }
void rev(vel &v) { reverse(v.begin(), v.end()); }
int zero(void) { return 0; }
int ord(int n, int p) {
	if (n%p != 0)return 0;
	return 1 + ord(n / p, p);
}
int rui(int a, int n) {
	if (n == 0) { return 1; }
	return a * rui(a, n - 1);
}
int rui1(int a, int n, int p) {
	if (n == 0) { return 1; }
	int x = rui1(a, n / 2, p);
	x = (x*x) % p;
	if (n % 2 == 0) { return x; }
	else { return (x*a) % p; }
}
int kai(int n, int p) {
	if (n == 0) { return 1; }
	return (kai(n - 1, p)*n) % p;
}
signed main() {
	int n; int m;
	cin >> n >> m;
	int mm = m;
	vel fr(30);
	int th = 0;
	for (int i = 2; i < 100000; i++) {
		int k = ord(mm, i);
		if (k > 0) {
			fr[th] = k;
			th++;
			mm = mm / rui(i, k);
		}
	}
	if (mm != 1) {
		fr[th] = 1;
		th++;
	}
	int pr = 1000;
	pr *= pr * pr;
	pr += 7;
	vel ka(31);
	ka[0] = kai(n-1, pr);
	for (int i = 1; i <= 30; i++) {
		ka[i] = (ka[i - 1] * (n + i-1)) % pr;
	}
	int inv = rui1(ka[0], pr - 2, pr);
	vel in(31);
	for (int i = 0; i <= 30; i++) {
		in[i] = rui1(kai(i,pr), pr - 2, pr);
	}
	int ans = 1;
	for (int i = 0; i < 30; i++) {
		if (fr[i] != 0) {
			ans *= ka[fr[i]];
			ans = ans % pr;
			ans *= inv;
			ans = ans % pr;
			ans *= in[fr[i]];
			ans = ans % pr;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3328
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
def A():
    return

#B
def B():
    return

#C
def C():
    n,m = LI()
    v = LIR(m)
    for i in range(m):
        v[i] = [v[i][0],v[i][1],i]
    v.sort(key = lambda x:x[1])
    f = [0 for i in range(n+1)]
    ans = [None for i in range(m)]
    for p,y,i in v:
        f[p] += 1
        s = "{:0>6}".format(p)
        t = "{:0>6}".format(f[p])
        ans[i] = s+t
    for i in ans:
        print(i)
#D
def D():
    h,w,k = LI()
    dp = [[0 for i in range(w)] for j in range(h+1)]
    dp[0][0] = 1
    p = [1 for i in range(w+1)]
    for i in range(w):
        p[i+1] = p[i]*2
    l = [i for i in range(p[w-1])]
    i = 0
    while i < len(l):
        a = l[i]
        for j in range(w):
            if a&p[j] and a&p[j+1]:
                l.pop(i)
                i -= 1
                break
        i += 1
    d = [[0 for i in range(3)] for j in range(w)]
    for j in range(w):
        for s in l:
            if 0 < j < w-1:
                if p[j]&s:
                    d[j][2] += 1
                elif p[j-1]&s:
                    d[j][0] += 1
                else:
                    d[j][1] += 1
            elif j == 0:
                if p[j]&s:
                    d[j][2] += 1
                else:
                    d[j][1] += 1
            else:
                if p[j-1]&s:
                    d[j][0] += 1
                else:
                    d[j][1] += 1
    for i in range(h):
        for j in range(w):
            dp[i+1][j] += d[j][1]*dp[i][j]
            dp[i+1][j] %= mod
            if j > 0:
                dp[i+1][j-1] += d[j][0]*dp[i][j]
                dp[i+1][j-1] %= mod
            if j < w-1:
                dp[i+1][j+1] += d[j][2]*dp[i][j]
                dp[i+1][j+1] %= mod
    print(dp[h][k-1])
#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    D()


Measured memory_bytes: 40048
#include <iostream>
using namespace std;
int main() {
	long long  n, x;
	long long  a[100000];
	cin >> n >> x;
	int i, j;
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	long long  b;
	j = 0;
	long long ans=0;
	while (j < n-1) {
		b = a[j] + a[j + 1];
		if (b > x) {
			if (a[j + 1] >= b - x)a[j + 1] = a[j + 1] - (b - x);
			else {
				a[j] = a[j] - ((b - x) - a[j + 1]);
				a[j + 1] = 0;
			}
			ans = ans + (b - x);
		}
		j++;
	}
 
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1152
n, k = gets.to_s.split.map{|t| t.to_i }
x    = gets.to_s.split.map{|t| t.to_i }

ans = (0..n-k).map do |t|
    l = x[t]
    r = x[t + k - 1]
    m = l.abs < r.abs ? l.abs : r.abs
    m + r - l
end.min

puts ans

Measured memory_bytes: 8964
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while (true) {
			int n = stdIn.nextInt();
			if(n == 0) {
				break;
			}
			int[] k = new int[n + 1];
			for (int i = 0; i < n + 1; i++) {
				k[i] = stdIn.nextInt();
			}
			IN: for (int i = 0; i < n + 1; i++) {
				int[] ktmp = new int[n];
				int p = 0;
				for(int j = 0; j < i; j++) {
					ktmp[p++] = k[j];
				}
				for(int j = i+1; j < k.length; j++) {
					ktmp[p++] = k[j];
				}
				for(int j = 2; j < ktmp.length; j++) {
					if(ktmp[j-1] - ktmp[j-2] != ktmp[j] - ktmp[j-1]) {
						continue IN;
					}
				}
				System.out.println(k[i]);
				break;
			}
		}
	}
}

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

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

  int L, R, d;
  cin >> L >> R >> d;

  int L_q = L / d;
  int L_r = L % d;
  int R_q = R / d;
  int R_r = R % d;

  int ans = R_q - L_q;
  if(L_r == 0) ans++;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3608
import java.util.*;
public class Main{
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int cnt = 0;
        int s = 1;
        for(int i=0; i<n; i++){
            a[i] = sc.nextInt();
        }
        
        for(int i=0; i<a.length; i++){
            s = a[s-1];
            cnt++;
            if(s == 2){
                System.out.println(cnt);
                return;
            }
        }
        System.out.println("-1");
    }
}

Measured memory_bytes: 52252
#include <iostream>
#include <string.h>
#include <queue>

using namespace std;

struct P
{
	int x, y;
};

int W, H;

int field[20][20];

int main()
{
	int x, y;
	char c;
	while( 1 )
	{
		cin >> W >> H;
		if(W==0 && H==0) break;

		memset(field, 0, sizeof(int) * 400);
		for(int j=0; j<H; j++)
		{
			for(int i=0; i<W; i++)
			{
				cin >> c;
				if(c == '.')
	  				field[i][j] = 1;
				else if(c == '#')
					field[i][j] = 2;
				else if(c == '@')
				{
					field[i][j] = 3;
					x = i;
					y = j;
				}
			}
		}

		int offset[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
		int total = 1;
		queue<P> que;
		P init_p = {x, y};
		que.push(init_p);

		while(!que.empty())
		{
			P p = que.front();
			que.pop();

			int cx = p.x;
			int cy = p.y;

			for(int i=0; i<4; i++)
			{
				int xx = cx + offset[i][0];
				int yy = cy + offset[i][1];
				if(xx>=0 && yy>=0 && xx<W && yy<H)
				{
					if(field[xx][yy] == 1)
					{
						P new_p = {xx, yy};
						que.push(new_p);
						field[xx][yy] = 4;
						total++;
					}
				}
			}
		}

		printf("%d\n", total);
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() {
  long long A;
  string S;
  cin >> A >> S;
  ll B = (S[0] - '0') * 100 + 10 * (S[2] - '0') + S[3] - '0';
  cout << A * B / 100 << endl;
}

Measured memory_bytes: 3604
// In the name of GOD
#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

#define     IOS         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	setprecn(x) cout<<fixed<<setprecision(x);
#define 	ll          long long int
#define 	pb          push_back
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	mod         1000000007
#define 	inf         10000000000000007
#define 	rep(i,n)    for(ll i=0;i<n;i++)
#define 	repe(i,a,b) for(ll i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search

ll power(ll a,ll b,ll m=mod)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2,m);
	if(b%2==0)
		return((c%m)*(c%m))%m;
	return ((((c%m)*(c%m))%m)*(a%m))%m;
}
/********************************************************/
//	d.erase(unique(all(d)), d.end());



int main()
{
	IOS;
	ll n,k,m,i,j,c=0,cs=0,t;
	t=1;

	// cin>>t;
	string s;
	while(t--)
	{
		cin>>n>>m;
		// n=s.length();
		ll h[n];
		vector<ll> g[n+1];
		rep(i,n)
		{
			cin>>h[i];
		}
		rep(i,m)
		{
			cin>>j>>k;
			g[j].pb(k);
			g[k].pb(j);
		}
		rep(i,n)
		{
			cs=1;
			for(auto x:g[i+1])
			{
				if(h[i]<=h[x-1])
					cs=0;
			}
			c+=cs;
		}
		cout<<c;

		
		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 10284
n = int(input())
h = list(map(int,input().split()))

for i in reversed(range(1,n)):
    if h[i-1] - h[i] == 1:
        h[i-1] -= 1
    elif h[i-1] - h[i] >=2:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 15020
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n, i;
  cin >> n >> i;
  cout << n - i + 1 << endl;
}


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

typedef long long LL;
const int N = 1e5 + 10;
const int Mod = 1e9 + 7;
struct mat {
	int a[3][3];
	mat() {memset(a, 0, sizeof a);}
	inline mat operator * (const mat &t) const {
		mat ret;
		for (int i = 0; i < 3; ++i)
			for (int j = 0; j < 3; ++j)
				for (int k = 0; k < 3; ++k)
					ret.a[i][j] = ((LL)ret.a[i][j] + 1LL * a[i][k] * t.a[k][j]) % Mod;
		return ret;
	}
} e, t1, t2;
int n, m, f[3], g[3], a[N];

template <class T> inline void in(T &x) {
	x = 0; int f = 0; char ch = getchar();
	for (; ch<'0' || ch>'9';) {if (ch=='-') f=-1; ch = getchar();}
	for (; ch>='0' && ch<='9';) x = x*10 + ch-'0', ch = getchar();
	x = f ? -x : x;
}

inline mat qpow(mat A, int B) {
	mat S = e;
	for (; B; B >>= 1, A = A * A)
		if (B & 1) S = S * A;
	return S;
}

int main() {
	mat tmp, ret; in(n), in(m);
	for (int i = 1; i <= m; ++i) in(a[i]);
	t1.a[0][0] = t1.a[1][1] = t1.a[2][2] = t1.a[1][2] = t1.a[0][2] = 1;
	t1.a[0][1] = 2;
	t2.a[0][2] = t2.a[1][0] = t2.a[1][1] = t2.a[1][2] = t2.a[2][0] = t2.a[2][2]=1;
	t2.a[0][0] = t2.a[0][1] = 2;
	e.a[0][0] = e.a[1][1] = e.a[2][2] = 1;
	f[0] = 1, a[++m] = n;
	for (int k = 1, pos = 0; k <= m; pos = a[k], ++k) {
		ret = qpow(t2, a[k] - pos - 1);
		ret = ret * t1;
		for (int i = 0; i < 3; ++i) {
			g[i] = 0;
			for (int j = 0; j < 3; ++j)
				g[i] = ((LL)g[i] + 1LL * f[j] * ret.a[j][i]) % Mod;
		}
		for (int i = 0; i < 3; ++i) f[i] = g[i];
	}
	printf("%d\n", f[2]);
	return 0;
}

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

int h[201],r[201];
int num[201];


void LIS(int n,int m){

  int max;

  h[0]=0;
  r[0]=0;
  num[0]=0;
  
  for(int i=1 ; i <= m+n ; i++){
    max=0;
    for(int j=0 ; j < i ; j++){
      if(r[j] < r[i] && h[j] < h[i] && max < num[j])max=num[j];
    }
    num[i]=max+1;
  }
  
  /*cout <<endl;
  for(int i=0 ; i <= m+n ; i++){
    cout <<num[i]<<endl;
  }
  */

  max=num[0];
  for(int i=0 ; i <= n+m ; i++){
    if(max < num[i])max=num[i];
  }

  cout <<max<<endl;
	
  
}
int main(){

  int n,m;

  while(1){
    
    cin >>n;
    if(n == 0)break;
    
    for(int i=1 ; i <= n ; i++){
      cin >>h[i]>>r[i];
    }
    
    cin >>m;
    for(int i=n+1 ; i <= m+n ; i++){
      cin >>h[i]>>r[i];
    }
    
    for(int i=n+m ; i > 1 ; i--){
      for(int j=1 ; j < i ; j++){
	if(h[j] > h[j+1]){
	  swap(h[j],h[j+1]);
	  swap(r[j],r[j+1]);
	}else if(h[j] == h[j+1] && r[j] > r[j+1]){
	  swap(r[j],r[j+1]);
	}
      }
    }
    
    //cout <<endl;
    //for(int i=1 ; i <= n+m ; i++){
    //  cout <<h[i]<<" "<<r[i]<<endl;
    //}
    
    LIS(n,m);

  }
  return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <cstring>
using namespace std;
#define N 300
int a[N+1];
int main()
{
    int n; cin >> n;
    memset(a, 0, sizeof(a));
    a[0] = 1;
    for (int i=2; i<=n; ++i) {
        for (int j=0; j<N; ++j) a[j] *= i;
        for (int j=0; j<N; ++j) {
            a[j+1] += a[j] / 10;
            a[j] %= 10;
        }
    }
    int k=N;
    while (a[k] == 0) k--;
    for (int i=k; i>=0; --i) cout << a[i]; cout << endl;
    return 0;
}

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

int main() {
    string s;
    cin>>s;

    int count=0,ans=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C') count++;
        else count=0;

        ans=max(ans, count);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  if(a + b == 15){
    cout << "+" << endl;
  } else if(a * b == 15) {
    cout << "*" << endl;
  } else {
    cout << "x" << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String args []) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int [] list = new int [N+1];
        int [] list2 = new int [N+1];
        for(int i=0;i<N+1;i++){
            list[i]=0;
            list2[i]=0;
        }
        for(int i=0;i<M;i++){
            int p = sc.nextInt();
            String S = sc.next();
            if(S.charAt(0)=='A'&&list[p]==0)list[p]=1;
            else if(S.charAt(0)=='W'&&list[p]==0) list2[p]++;
        }
        int A_sum =0, W_sum=0;
        for(int i=1;i<N+1;i++){
            if(list[i]==1){
                W_sum+=list2[i];
                A_sum++;
            }
        }
        System.out.println(A_sum+" "+W_sum);
    }
}


Measured memory_bytes: 63056
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int MOD = 1000000007;
int INF = numeric_limits<int>::max() / 2;

signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int N, M;
  cin >> N >> M;
  pair<int, int> P[M];
  rep(i,M){
    cin >> P[i].second >> P[i].first;
  }
  sort(P, P+M);
  int ans = 0, t = 0;
  for(int i=0;i<M;i++){
    if(t <= P[i].second){
      ans++;
      t = P[i].first;
    }
  }
  cout << ans << endl;
}

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

const int MAX = 1000002; 

// array to store prime factors 
int factor[MAX] = { 0 }; 

// function to generate all prime factors 
// of numbers from 1 to 10^6 
void generatePrimeFactors() 
{ 
	factor[1] = 1; 

	// Initializes all the positions with their value. 
	for (int i = 2; i < MAX; i++) 
		factor[i] = i; 

	// Initializes all multiples of 2 with 2 
	for (int i = 4; i < MAX; i += 2) 
		factor[i] = 2; 

	// A modified version of Sieve of Eratosthenes to 
	// store the smallest prime factor that divides 
	// every number. 
	for (int i = 3; i * i < MAX; i++) { 
		// check if it has no prime factor. 
		if (factor[i] == i) { 
			// Initializes of j starting from i*i 
			for (int j = i * i; j < MAX; j += i) { 
				// if it has no prime factor before, then 
				// stores the smallest prime divisor 
				if (factor[j] == j) 
					factor[j] = i; 
			} 
		} 
	} 
} 

// function to calculate number of factors 
int calculateNoOFactors(int n) 
{ 
	if (n == 1) 
		return 1; 

	int ans = 1; 

	// stores the smallest prime number 
	// that divides n 
	int dup = factor[n]; 

	// stores the count of number of times 
	// a prime number divides n. 
	int c = 1; 

	// reduces to the next number after prime 
	// factorization of n 
	int j = n / factor[n]; 

	// false when prime factorization is done 
	while (j != 1) { 
		// if the same prime number is dividing n, 
		// then we increase the count 
		if (factor[j] == dup) 
			c += 1; 

		/* if its a new prime factor that is factorizing n, 
		then we again set c=1 and change dup to the new 
		prime factor, and apply the formula explained 
		above. */
		else { 
			dup = factor[j]; 
			ans = ans * (c + 1); 
			c = 1; 
		} 

		// prime factorizes a number 
		j = j / factor[j]; 
	} 

	// for the last prime factor 
	ans = ans * (c + 1); 

	return ans; 
} 
int main(){
	int n;
	cin>>n;
	generatePrimeFactors();
	int ans = 0;
	for(int i=1;i<n;i++){
		ans += calculateNoOFactors(n-i);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 7520
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

def lcm(a, b):
    return (a * b) // gcd(a,b)


while True:
    try:
        a, b = [int(i) for i in input().split()]
        print(gcd(a, b), lcm(a, b))
    except EOFError:
        break

Measured memory_bytes: 7600
using System;
using System.Linq;
using System.IO;
using System.Collections.Generic;
using static System.Math;

class P
{
  static int[] Input(){
    return Console.ReadLine().Split().Select(int.Parse).ToArray();
  }
  static int[][] Input2(int n){
    int[][] X = new int[n][];
    for(int i = 0; i < n; i++){
      X[i] = Input();
    }
    return X;
  }
  static void Main()
  {
    int[] NT = Input();
    int[] X = Input();
    int mnx = Int32.MaxValue;
    int mxx = 0; int R = 0;
    for (int i=0; i<NT[0];i++) {
      if (X[i] > mnx){
        if(X[i]-mnx>mxx){
          R = 1; mxx = X[i]-mnx;
        } else if (X[i]-mnx==mxx){
          R+=1;
        }
      }
      mnx = Min(X[i], mnx);
    }
    var sw = new StreamWriter(Console.OpenStandardOutput()){AutoFlush = false};
    Console.SetOut(sw);
    Console.WriteLine(R);
    Console.Out.Flush();
  }
}


Measured memory_bytes: 21728
#!C:\Users\daichi\Anaconda3/python.exe
# -*- coding: utf-8 -*-

N = int(input())
S =  input().split()
T = [0,0,0,0]

#for i in range(N):
 #   S[i] = input()
i=0
for i in range(N):
    if(S[i]=='P'):
        T[0] = 1
    if(S[i]=='W'):
        T[1] = 1
    if(S[i]=='G'):
        T[2] = 1
    if(S[i]=='Y'):
        T[3] = 1

Sum = 0
i=0
for i in range(4):
    Sum = Sum + T[i]
    
if(Sum == 3):
    print("Three")
if(Sum == 4):
    print("Four")

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

int main() {
  int a;
  int b;
  
  cin >> a;
  cin >> b;
  
  if(((a*b)%2) == 0){
    cout << "Even" << endl;
  }else{
    cout << "Odd" << endl;
  }
}


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int M, T, P, R;
  while (cin >> M >> T >> P >> R, M) {
    vector<vector<int>> time(T, vector<int>(P));
    vector<vector<int>> ac(T, vector<int>(P));
    while (R--) {
      int m, t, p, j;
      cin >> m >> t >> p >> j;
      --t, --p;
      if (j == 0) {
        time[t][p] += m;
        ac[t][p] = 1;
      } else {
        time[t][p] += 20;
      }
    }
    vector<pair<int, int>> v(T);
    for (int t = 0; t < T; ++t) {
      int sum = 0;
      for (int p = 0; p < P; ++p) {
        if (ac[t][p]) {
          sum += time[t][p];
        }
      }
      v[t] = {accumulate(begin(ac[t]), end(ac[t]), 0), -sum};
    }
    vector<int> idx(T);
    iota(rbegin(idx), rend(idx), 0);
    stable_sort(begin(idx), end(idx), [&](int l, int r) {
      return v[l] > v[r];
    });
    bool first = true;
    for (int i = 0; i < T; ++i) {
      int t = idx[i];
      if (not exchange(first, false)) {
        cout << (v[t] == v[idx[i - 1]] ? '=' : ',');
      }
      cout << t + 1;
    }
    cout << '\n';
  }
}



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

const int INF=1001001001;
int dp[100010];

int main(){
    int n,k;
    cin>>n>>k;
    vector<int>h(n);
    rep(i,n)cin>>h[i];
    rep(i,100010)dp[i]=INF;
    dp[0]=0; dp[1]=abs(h[0]-h[1]);
    for(int i=0; i<n; ++i){
            for(ll j=i+1;j<=k+i;j++)
            {
                if(j<n)
              dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
            }
    }
    cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 4012
#include <iostream>

using namespace std;
 
int p,q,a,n,cnt;
 
void dfs(int depth,int sum_p,int sum_q,int nowq){
    if(p*sum_q == sum_p*q){
	cnt++;
	return;
    }
 
    if(depth == n) return;
 
    for(int i = nowq ; i*sum_q <= a ; i++){
	dfs(depth+1,i*sum_p+sum_q,i*sum_q,i);
    }
}
 
int main(){
    while(cin >> p >> q >> a >> n , p + q + a + n){
	cnt = 0; 
	dfs(0,0,1,1);
	cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 3000
#pragma comment(linker, "/STACK:102c000000,102c000000")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <string>
#include <algorithm>
#include <list>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
// #include <conio.h>
using namespace std;
#define clc(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
const int N = 3*1e6+10;
const int MOD = 1e9+7;
#define LL long long
#define mi() (l+r)>>1
double const pi = acos(-1);

void fre() {
    freopen("in.txt","r",stdin);
}

// inline int r() {
//     int x=0,f=1;char ch=getchar();
//     while(ch>'9'||ch<'0') {if(ch=='-') f=-1;ch=getchar();}
//     while(ch>='0'&&ch<='9') { x=x*10+ch-'0';ch=getchar();}return x*f;
// }

LL Gcd(LL a,LL b){ return b? Gcd(b, a % b) : a; }
int main(){
    LL n,x; cin >> n >> x;
    LL d = Gcd(n,x);
    n/=d;
    // cout << d*3*(n-1) << endl;
    unsigned long long ans=d*3*(n-1);
    printf("%llu\n",ans);
}

Measured memory_bytes: 256
n=int(input())
a,b,c=map(int,input().split())
d,e,f=list(map(int,input().split()))
s=[0]*(n+1)
for i in range(a,n+1):
    s[i]=max(s[i],s[i-a]+d-a)
for i in range(b,n+1):
    s[i]=max(s[i],s[i-b]+e-b)
for i in range(c,n+1):
    s[i]=max(s[i],s[i-c]+f-c)
n+=s[-1]
s=[0]*(n+1)
for i in range(d,n+1):
    s[i]=max(s[i],s[i-d]+a-d)
for i in range(e,n+1):
    s[i]=max(s[i],s[i-e]+b-e)
for i in range(f,n+1):
    s[i]=max(s[i],s[i-f]+c-f)
print(s[-1]+n)

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

int main() {
  int n;
  string str;
  cin >> n;
  int count = 0;

  bool flag = true;
  for (int i=0; i<n; i++) {
    cin >> str;
    if (str == "A") {
      count++;
    } else if (str == "Un") {
      if (count > 0) {
	count--;
      } else {
	flag = false;
      }
    }
  }

  if (count > 0) {
    flag = false;
  }

  if (flag) {
    puts("YES");
  } else {
    puts("NO");
  }
}

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

int main(){
	int S;
	int h;
	int m;
	int s;

	cin >> S;
	s = S % 60;
	m = ((S-s) % 3600) / 60;
	h = S / 3600;
	cout << h << ":" << m << ":" << s << endl;
}

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

typedef long long int ll;
typedef vector<int> vi;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define pvec(v) for(auto e: v) cout << e << " ";
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i, a, b) for(int i = (a); i<(b); ++i)
#define pb push_back
#define INF 1000000005
#define MOD 1000000007
#define all(v) v.begin(), v.end()

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

ll power(ll x, ll y, ll p = MOD){  
    ll res = 1LL; 
    x = x % p;
    if (x == 0) return 0;
    while (y > 0){
        if (y & 1LL)  
            res = (res*x) % p;
        y = y>>1LL; 
        x = (x*x) % p;  
    }  
    return res;  
}  

int main(){
	IO
	int n, w;
	cin >> n >> w;
	ll dp[n+1][w+1];
	rep(i, 0, n+1) rep(j, 0, w+1) dp[i][j] = -1;

	rep(i, 0, n+1) dp[i][0] = 0;
	rep(i, 0, w+1) dp[0][i] = 0;

	ll price, weight;
	rep(i, 1, n + 1){
		cin >> weight >> price;
		for(int wi = 0; wi <= w; ++wi){
			if(wi < weight)
				dp[i][wi] = dp[i-1][wi];
			else 
				dp[i][wi] = max(dp[i-1][wi], dp[i-1][wi - weight] + price);
		}
	}

	ll ans = -1;
	rep(i, 0, w+1) ans = max(ans, dp[n][i]);

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

Measured memory_bytes: 82416
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int N; cin >> N;
    vector<int> p(N+1);
    for(int i=1; i<=N; i++) cin >> p[i];
    vector<int> a(N+1), b(N+1);
    int k = 50000;
    for(int i=1; i<=N; i++){
        a[i] = i*k;
        b[i] = (N+1-i)*k;
    }

    for(int i=1; i<=N; i++) b[p[i]] -= (N-i);

    for(int i=1; i<=N; i++){
        if(i != 1) cout << " ";
        cout << a[i];
    }
    cout << endl;

    for(int i=1; i<=N; i++){
        if(i != 1) cout << " ";
        cout << b[i];
    }
    cout << endl;
}

Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define int long long
using namespace std;
signed main() {
	int k; cin >> k;
	int n = 1;
	for (int i = 0; i < k; i++)n *= 2;
	int d, a[20], p;
	cin >> d;
	for (int i = 0; i < d; i++) cin >> a[i];
	for (int i = 0; i < n; i++) {
		bool b[20];
		for (int i = 0; i < 20; i++)b[i] = 0;
		p = i;
		for (int j = 0; j < k; j++) {
			if (p % 2 == 1)b[j] = 1;
			p /= 2;
		}
		for (int i = 0; i < d; i++)if (!b[a[i]])goto heaven;
		p = i;
		cout << p << ':';
		for (int j = 0; j < k; j++) {
			if (p % 2 == 1)cout << ' ' << j;
			p /= 2;
		}cout << endl;
	heaven:;
	}
}


Measured memory_bytes: 3124
import java.util.Scanner;

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

		String a = sc.next();
		String b = sc.next();
		String c = sc.next();
		System.out.println(a.substring(0,1)+b.substring(0,1)+c.substring(0,1));

	}
}

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

int main() {
  int n;
  cin >> n;
  vector<double> v;
  cout << fixed << setprecision(7);
  for(int i=0; i<n; i++){
    double a;
    cin >> a;
    v.push_back(a);
  }
  while(v.size() >= 2){
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    int s = v.size();
    double x,y;
    x = v.at(s-1);
    y = v.at(s-2);
    v.pop_back();
    v.pop_back();
    v.push_back((x+y)/2.0);
  }
  cout << v.at(0) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef  long long  ll;
ll inf=1000000000000000000,mod=998244353;
int main() {
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n,x,m;cin>>n>>x>>m;
  	if(m==0){cout<<"0";return 0;}
    ll st=0,en=n-1,curr=x%m,sum=0,presum[m]={0},vis[m]={0},idx[m]={0},val;
    for(ll i=0;i<n;i++){
        if(vis[curr]){
            st=idx[curr];
            en=i-1;break;
        }
        vis[curr]=1;
        idx[curr]=i;
        // cout<<curr<<endl;
        presum[i]=curr;
        if(i)
        presum[i]+=presum[i-1];
        curr=(curr*curr)%m;
    }
    if(st-1>=0)
    val=presum[en]-presum[st-1];
    else
    val=presum[en];

    ll ans=0;
    if(st-1>=0){
    ans+=presum[st-1];
    n-=st;}
    // cout<<((n/(en-st+1))*val)<<" ";
    ans+=(n/(en-st+1))*val;
	n%=(en-st+1);
	if(n){
    ans+=presum[st+n-1];
    if(st-1>=0)
    ans-=presum[st-1];}
    cout<<ans;
}


Measured memory_bytes: 5968
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 123456789012

int main(){
    string s;
    cin>>s;
    int x=(s[5]-'0')*10+s[6]-'0';
    if(x<=4) cout<<"Heisei"<<endl;
    else cout<<"TBD"<<endl;
    return 0;
}

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

using namespace std;

const int INF = 1e9;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (auto &x : a)
    cin >> x;
  vector<int> dp(n, INF);
  dp[0] = 0;
  dp[1] = abs(a[1] - a[0]);
  for (int i = 2; i < n; ++i) {
    for (int j = 1; j <= k; ++j) {
      int from = i - j;
      if (from < 0)
        break;
      dp[i] = min(dp[i], dp[from] + abs(a[i] - a[from]));
    }
  }
  cout << dp[n - 1] << '\n';
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

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

  if((a % 3) * (b % 3) *((a + b) % 3) == 0) cout << "Possible";
  else cout << "Impossible";
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <memory>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long ll;

int dta[200100],dtb[200100];
int tb[200100];
int n,r;
int main(){
	cin>>n;
	r=0;
	for(int i=1;i<=n;i++)cin>>tb[i];
	for(int i=1;i<=n;i++)cin>>dta[i];
	for(int i=1;i<n;i++)cin>>dtb[i];
	tb[n+1]=0;
	for(int i=1;i<=n;i++){
		r+=dta[tb[i]];
		if(tb[i]==tb[i+1]-1)r+=dtb[tb[i]];
	}
	cout<<r<<endl;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int n, m;
int ans = 1;

void dfs(int a, int b) {
    if(b == 1){
        //cout << a << endl;
        if(m/a >= n){
            ans = max(ans, a);
        }
        return;
    }

    for(int i=2;i*i<=b;i++){
        if(b%i == 0){
            int cnt = 0;
            while(b%i==0){
                b /= i;
                cnt++;
            }
            int na = a;
            inc(j, 0, cnt+1){
                dfs(na, b);
                na *= i;
            }
            return;
        }
    }
    dfs(a, 1);
    dfs(a*b, 1);
}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    cin >> n >> m;
    dfs(1, m);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma region

#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define _rep3(i, begin, end) for (register int i = (begin), i##_end = (end); i < i##_end; i++)
#define _irep3(i, begin, end) for (register int i = (end)-1, i##_begin = (begin); i >= i##_begin; i--)
#define _rep2(i, n) _rep3(i, 0, n)
#define _irep2(i, n) _irep3(i, 0, n)
#define _overload3(_1, _2, _3, name, ...) name
#define rep(...) _overload3(__VA_ARGS__, _rep3, _rep2, )(__VA_ARGS__)
#define irep(...) _overload3(__VA_ARGS__, _irep3, _irep2, )(__VA_ARGS__)
#define out(x) cout << (x) << '\n';
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<long long>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<long long>>;
using vvb = vector<vector<bool>>;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &pair) {
  cin >> pair.first >> pair.second;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[ ";
  rep(i, vec.size()) i == 0 ? os << vec[i] : os << ", " << vec[i];
  os << " ]";
  return os;
}

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

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

void init() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(16);
}

#pragma endregion

#define MOD 1000000007
#define INF 2147483647

int main() {
  init();
  ll H, W;
  cin >> H >> W;

  if (H==1||W==1) {
    out(1);
    return 0;
  }

  out(((H + W) % 2 == 0) ? ((H * W + 1) / 2) : ((H * W) / 2));
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>

using namespace std;

int main(){
  double x1,y1,x2,y2;
  cin >> x1 >> y1;
  cin >> x2 >> y2;
  double distx = (x2 - x1)*(x2 - x1);
  double disty = (y2 - y1)*(y2 - y1);
  double dist = sqrt(distx + disty);
  printf("%.8lf",dist);
  return 0;
}


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

typedef long long ll;
typedef unsigned long long int llu;
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define mem(a, v) memset(a, v, sizeof(a))
#define PI acos(-1)
#define S(a) scanf("%d",&a)
#define SL(a) scanf("%lld",&a)
#define S2(a, b) scanf("%d%d",&a,&b)
#define nl printf("\n")
#define deb(x) cout<<#x<<" : "<<x<<endl;
#define deb2(x, y) cout<<#x<<" : "<<x<<" | "<<#y<<" : "<<y<<endl;
#define deb3(x, y, z) cout<<#x<<" : "<<x<<" | "<<#y<<" : "<<y<<" | "<<#z<<" : "<<z<<endl;
#define debv(x) {cout<<#x<<" : "<<endl; for(int ii =0; ii < x.size(); ii++) cout<<x[ii]<<" "; cout<<endl; }
#define debarr(x, xs) {cout<<#x<<" : "<<endl; for(int ii =0; ii < xs; ii++) cout<<x[ii]<<" "; cout<<endl; }
//auto T=clock(); 
//cout<<double(clock()-T)/CLOCKS_PER_SEC<<'\n';
//cout << fixed << setprecision(10) << f(0, 0, 0) << "\n";
const ll mod = 1000000007LL;
const int lmt = 1000005;

stack<char> st;
string s, ans = "";

int main(){
    int n, a = 0, b = 0;
    S(n);
    cin >> s;

    for(int i = 0; i < n; i++) {
        char ch = s[i];
        if(ch == ')') {
            if(st.empty())
                a++;
            else
                st.pop();

        } else {
            st.push(ch);
        }
    }
    while(!st.empty()) {
        b++;
        st.pop();
    }
    for(int i = 0; i < a; i++)
        ans +='(';
    ans += s;
    for(int i = 0; i < b; i++)
        ans += ')';

    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;

int main(){
    string s;
    cin>>s;
    int ans=0;
    for(int i=1;i<s.size();i++){
        if(s[i]!=s[i-1])ans++;
    }
    cout<<ans<<endl;
}

   


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

using namespace std;

int main() {
    bool flag=true;
    int N;
    cin >> N;
    char pre_end;
    map<string, int> mp;
    for(int n=0; n<N; n++) {
        string str;
        cin >> str;
        
        mp[str]++;
        if(n>0) {
            if(pre_end!=str[0]) {
                flag=false;
            }
            if(mp[str]>1) {
                flag=false;
            }
        }
        pre_end = str[str.size()-1];
    }
    
    if(flag) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
 
typedef long long ll;

#define rep(i,n) for(ll i = 0; i < n; i++)
 
using namespace std;
 
const ll INF = ll(1e18)+1;
const double PI=3.14159265358979323846;
int dp[101][10001];

int main(){
  int N,W,v[1001]={},w[1001]={};
  cin >> N >> W;
  rep(i,N) cin >> v[i] >> w[i];

  rep(i,N){
    rep(j,10001){
      if(j>=w[i])
	dp[i+1][j] = max(dp[i][j-w[i]] + v[i], dp[i][j]);
      else
	dp[i+1][j] = dp[i][j];
    }
  }
  cout << dp[N][W] << endl;
}



Measured memory_bytes: 7000
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
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; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;



int main(){
    int n;cin>>n;
    string s[n];
    ll t[n];
    rep(i,n)cin >> s[i]>>t[i];
    string x; cin >> x;
    int count=0;

    for(int i=0;i<n;i++){
        if(s[i]==x)count = i;
    }

    int ans=0;
    for(int j=count+1;j<n;j++){
        ans = ans +t[j];
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256