akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	int K, N;
	scanf("%d", &K);
	scanf("%d", &N);

	const int mod = 998244353;
	int H[2001][2001];
	rep(i, 2001) H[0][i] = 1;
	rep1(i, 2000) {
		H[i][0] = 1;
		rep1(j, i) {
			H[i][j] = H[i][j - 1] + H[i - 1][j];
			if (H[i][j] >= mod) H[i][j] -= mod;
			H[j][i] = H[i][j];
		}
	}

	int kotae[1001];
	rep1(i, (K + 1) / 2) {
		ll tmp = 0;
		for (int j = 0; j <= i && N >= j * 2; j++) {
			if (j & 1) tmp -= (ll)H[j][i - j] * H[K - 1][N - j * 2];
			else tmp += (ll)H[j][i - j] * H[K - 1][N - j * 2];
			tmp %= mod;
		}
		kotae[i] = (tmp + mod) % mod;
	}

	rep1(i, (K + 1) / 2 - 1) printf("%d\n%d\n", kotae[i], kotae[i]);
	if (K & 1) printf("%d\n", kotae[(K + 1) / 2]);
	else printf("%d\n%d\n%d\n", kotae[(K + 1) / 2], kotae[(K + 1) / 2], kotae[(K + 1) / 2]);
	for (int i = (K + 1) / 2 - 1; i >= 1; i--) printf("%d\n%d\n", kotae[i], kotae[i]);

	Would you please return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)

const double EPS = 1e-8;
const double INF = 1e12;
typedef complex<double> P;
namespace std {
	bool operator < (const P& a, const P& b) {
		return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
	}
}
double cross(const P& a, const P& b) {
	return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
	return real(conj(a)*b);
}

struct L : public vector<P> {
	L() {}
	L(const P &a, const P &b) {
		push_back(a); push_back(b);
	}
};

typedef vector<P> G;

int ccw(P a, P b, P c) {
	b -= a; c -= a;
	if (cross(b, c) > 0)   return +1;       // counter clockwise
	if (cross(b, c) < 0)   return -1;       // clockwise
	if (dot(b, c) < 0)     return +2;       // c--a--b on line
	if (norm(b) < norm(c)) return -2;       // a--b--c on line
	return 0;
}

// assumption : 3 <= ps.size()
G convex_hull(vector<P> ps) {
	int n = ps.size(), k = 0;
	sort(ps.begin(), ps.end());
	G ch(2 * n);
	for (int i = 0; i < n; ch[k++] = ps[i++]) // lower-hull
		while (k >= 2 && ccw(ch[k - 2], ch[k - 1], ps[i]) <= 0) --k;
	for (int i = n - 2, t = k + 1; i >= 0; ch[k++] = ps[i--]) // upper-hull
		while (k >= t && ccw(ch[k - 2], ch[k - 1], ps[i]) <= 0) --k;
	ch.resize(k - 1);
	return ch;
}

P crosspoint(const L &l, const L &m) {
	double A = cross(l[1] - l[0], m[1] - m[0]);
	double B = cross(l[1] - l[0], l[1] - m[0]);
	if (abs(A) < EPS && abs(B) < EPS) return m[0]; // same line
	if (abs(A) < EPS) assert(false); // !!!PRECONDITION NOT SATISFIED!!!
	return m[0] + B / A * (m[1] - m[0]);
}

#define curr(PP, i) PP[i]
#define next(PP, i) PP[(i+1)%PP.size()]
G convex_cut(const G& g, const L& l) {
	G Q;
	for (int i = 0; i < g.size(); ++i) {
		P A = curr(g, i), B = next(g, i);
		if (ccw(l[0], l[1], A) != -1) Q.push_back(A);
		if (ccw(l[0], l[1], A)*ccw(l[0], l[1], B) < 0)
			Q.push_back(crosspoint(L(A, B), l));
	}
	return Q;
}

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

	int N;
	while (cin >> N)
	{
		if (N == 0) return 0;

		G pol;
		rep(i, 0, N)
		{
			double x, y;
			cin >> x >> y;
			pol.push_back(P(x, y));
		}

		G ans;
		ans.push_back(P(0,0));
		ans.push_back(P(10001, 0));
		ans.push_back(P(10001, 10001));
		ans.push_back(P(0, 10001));

		rep(i, 0, N)
		{
			L line = L(pol[i], pol[(i + 1) % pol.size()]);
			ans = convex_cut(ans, line);
		}

		if (ans.empty())
			cout << 0 << endl;
		else
			cout << 1 << endl;
	}
}

Measured memory_bytes: 3232
from statistics import mean, median,variance,stdev
import sys
import math
import fractions
def j(a):
    if a==1: print("Yes")
    else :print("No")


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())

#x = ip()                              #入力整数1つ
#x,y = (int(i) for i in input().split())      #入力整数横2つ
x,y,z = (int(i) for i in input().split())    #入力整数横3つ
#a,b,c,k = (int(i) for i in input().split())  #入力整数横4つ
a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
c = z
a.append(c)
a.sort()
p = a.index(c)
print(min(len(a)-p-1,p))


Measured memory_bytes: 5660
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b;
  cin >> a >> b;
  
  if ((a/2)*2==a || (b/2)*2==b){
    cout << "Even" << endl;
  }
  
  else{
    cout << "Odd" << endl;
  }
  
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define re register
#define int ll
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=100010,Mod=1e9+7;
int n,A,B,a[N],f[N],s[N];
signed main(){
	n=gi();A=gi();B=gi();if(A>B)swap(A,B);
	for(int i=1;i<=n;i++)a[i]=gi();
	for(int i=1;i<n-1;i++)
		if(a[i+2]-a[i]<A)return puts("0"),0;
	f[0]=s[0]=1;int mx=0,mn=0;
	for(int i=1;i<=n;i++){
		while(mx<i && a[i]-a[mx+1]>=B)mx++;
		if(mn<=mx)f[i]=(s[mx]-(mn?s[mn-1]:0)+Mod)%Mod;
		s[i]=(s[i-1]+f[i])%Mod;
		if(i>1 && a[i]-a[i-1]<A)mn=i-1;
	}
	int ans=0;
	for(int i=n;~i;i--){
		ans=(ans+f[i])%Mod;
		if(i<n && a[i+1]-a[i]<A)break;
	}
	printf("%lld\n",ans);
	return 0;
}



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

int adj[30][30];
int gl=0,n,m;

int rec(int bmsk,int prev,int depth){
	if(depth==n && bmsk!=gl)
		return 0;
	if(bmsk==gl)
		return 1;
	int cnt=0;
//	cout<<bmsk<<" "<<prev<<" "<<depth<<endl;
	for(int i=1;i<=n;i++){
		int tmp=1<<i;
		int tmp2=tmp&bmsk;
		//cout<<tmp<<" sadfg "<<(tmp2)<<endl;
		if(tmp2==0 && adj[prev][i]){
		//	cout<<i<<" sdf "<<endl;
			cnt+=rec(bmsk|tmp,i,depth+1);
		}
	}
	return cnt;
}

int main(){
	int u,v;
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		gl|=(1<<i);
	}
	for(int i=0;i<m;i++){
		cin>>u>>v;
		adj[u][v]=1;
		adj[v][u]=1;
	}
	cout<<rec(1<<1,1,1)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll inv[70001];
ll fact[70001];
ll inv_fact[70001];

void inv_init(){
	inv[1]=1;
	for(int i=2;i<=70000;i++){
		inv[i]=MOD-(MOD/i)*inv[MOD%i]%MOD;
	}
	fact[0]=inv_fact[0]=1;
	for(ll i=1;i<=70000;i++){
		fact[i]=fact[i-1]*i%MOD;
		inv_fact[i]=inv_fact[i-1]*inv[i]%MOD;
	}
}

ll com(ll a,ll b){
	if(b<0 || a<b)return 0;
	return (inv_fact[b]*inv_fact[a-b])%MOD*fact[a]%MOD;
}

ll dp[17][1<<16];
int n,m;
int a[17];

int main(void){
	scanf("%d%d",&n,&m);
	inv_init();
	for(int i=0;i<m;i++){
		scanf("%d",&a[i]);
	}
	sort(a,a+m);
	reverse(a,a+m);
	dp[0][0]=1;
	for(int i=0;i<m;i++){
		for(int bit=0;bit<(1<<n);bit++){
			dp[i+1][bit]+=dp[i][bit];
			dp[i+1][bit]%=MOD;
			for(int j=0;j<n;j++){
				if((bit&(1<<j)))continue;
				dp[i+1][bit+(1<<j)]+=(dp[i][bit]*com((1<<n)-a[i]-bit,(1<<j)-1))%MOD*fact[1<<j]%MOD;
				dp[i+1][bit+(1<<j)]%=MOD;
			}
		}
	}
	ll ans=0;
	for(int i=0;i<(1<<n);i++){
		if(__builtin_popcount(i)%2==0){
			ans+=dp[m][i]*fact[(1<<n)-i-1];
		}else{
			ans-=dp[m][i]*fact[(1<<n)-i-1];
		}
		ans%=MOD;
	}
	if(ans<0LL)ans+=MOD;
	ans*=(1<<n);
	ans%=MOD;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 10112
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <algorithm>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
#include <stdio.h>

#define rep(i,m,n) for(unsigned long long int i=(m);i<(n);++i)
#define rem(i,m,n) for(int i=(m);i>(n);--i)
#define MOD 1000000007

using namespace std;

using ll =long long int;
using std::swap;

vector<long long int> v;
vector<long long int> w;

int main() {
	int A, B; cin >> A >> B;
	int ans = 0;
	int outlet = 1;
	while (outlet < B) {
		 --outlet;
		 outlet += A;
		 ++ans;
	
	}
	 cout << ans << endl;
	
}

/*
int main() {
	int a, b;
	cin >> a >> b;
	int ans = 1;
	b -= a;
	while (b > 0) {
		b -= a - 1;
		++ans;
	}
	cout << ans << '\n';

	return 0;
}
*/

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int N;
int A[100005];

int main(void)
{
	cin >> N;
	for(int i = 0; i < N; i++) cin >> A[i];
	
	int ans = 1, up = 0;
	for(int i = 0; i < N-1; i++){
		if(A[i] < A[i+1]){
			if(up == 0) up = 1;
			else if(up == -1){
				ans++;
				up = 0;
			}
		}
		if(A[i] > A[i+1]){
			if(up == 0) up = -1;
			else if(up == 1){
				ans++;
				up = 0;
			}
		}
	}
	
	cout << ans << endl;
	return 0;
}
	

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int ll
#define ll long long
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I32_MAX
#define MOD 1000000007
// #define MOD 998244353
#define MEM_SIZE 201010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template <typename T>
void DEBUG(T e)
{
  if (DEBUG_OUT == false)
    return;
  std::cout << e << " ";
}
template <typename T>
void DEBUG(const std::vector<T> &v)
{
  if (DEBUG_OUT == false)
    return;
  for (const auto &e : v)
  {
    std::cout << e << " ";
  }
  std::cout << std::endl;
}
template <typename T>
void DEBUG(const std::vector<std::vector<T>> &vv)
{
  if (DEBUG_OUT == false)
    return;
  for (const auto &v : vv)
  {
    DEBUG(v);
  }
}
template <class T, class... Ts>
void DEBUG(T d, Ts... e)
{
  if (DEBUG_OUT == false)
    return;
  DEBUG(d);
  DEBUG(e...);
}
template <class T>
void corner(bool flg, T hoge)
{
  if (flg)
  {
    cout << hoge << endl;
    abort();
  }
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, T2 b)
{
  return a < b && (a = b, true);
}
template <typename T1, typename T2>
inline bool chmin(T1 &a, T2 b)
{
  return a > b && (a = b, true);
}

void solve(void)
{
  string str;
  cin >> str;

  if (str.back() == 's')
  {
    str += "es";
  }
  else
  {
    str += "s";
  }
  cout << str << endl;

  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 3624
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		final int n = sc.nextInt();
		int[] arr = new int[n];
		for(int i = 0; i < n; i++){
			arr[i] = sc.nextInt();
		}
		
		int max = arr[n - 1];
		int diff_max = Integer.MIN_VALUE;
		for(int i = n - 2; i >= 0; i--){
			diff_max = Math.max(diff_max, max - arr[i]);
			
			max = Math.max(max, arr[i]);
		}
		
		
		System.out.println(diff_max);
		
	}
}

Measured memory_bytes: 96600
#include<bits/stdc++.h>
using namespace std;
int n,m,t,ans;char s[10][10];int col,ro;bool no[10][10];
int main(){
	cin>>n>>m>>t;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>s[i][j];
		}
		
	}
	for(int i=0;i<(1<<n);i++){
		for(int j=0;j<(1<<m);j++){
			int i1=i,j1=j;
			for(int k=n-1;k>=0;k--){
				if(i1>=(1<<k)){
					i1-=(1<<k);
					for(int l=0;l<m;l++){
						no[k][l]=1;
					}
				}
			}
			for(int k=m-1;k>=0;k--){
				if(j1>=(1<<k)){
					j1-=(1<<k);
					for(int l=0;l<n;l++){
						no[l][k]=1;
					}
				}
			}
			int trues=0;
			
			for(int k=0;k<n;k++){
				for(int l=0;l<m;l++){
					if(s[k][l]=='#' && !no[k][l])trues++;
				}
			}
			if(trues==t)ans++;
			for(int k=0;k<n;k++){
				for(int l=0;l<m;l++){
					no[k][l]=0;
				}
			}
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3592
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    string S, T; cin >> S >> T;
    int A, B; cin >> A >> B;
    string U; cin >> U;
    if (U == S) {
        A--;
    } else B--;
    cout << A << " " << B << endl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



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

using namespace std;

#define sz(x) ((int) ((x).size()))
typedef long long ll;
typedef long double ld;

int n, m, t, x[100100], y[100100];
bitset<50000> r[50000];

void reconstruct(int i) {
  bitset<50000> c;
  c[i] = true;
  string res;
  for (int j = m - 1; j >= 0; j--) {
    if (c[x[j]])
      res.push_back('^'), c[y[j]] = true;
    else if (c[y[j]])
      res.push_back('v'), c[x[j]] = true;
    else
      res.push_back('^');
  }
  reverse(res.begin(), res.end());
  cout << res << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  cin >> n >> m >> t;
  for (int i = 0; i < m; i++)
    cin >> x[i] >> y[i], x[i]--, y[i]--;
  if (t == 1) {
    for (int i = 0; i < n; i++)
      r[i][i] = true;
    for (int i = m - 1; i >= 0; i--)
      r[x[i]] |= r[y[i]], r[y[i]] = r[x[i]];
    bitset<50000> res;
    res.set();
    for (int i = 0; i < n; i++)
      res &= r[i];
    if (res.any()) {
      int i = 0;
      while (!res[i])
        i++;
      reconstruct(i);
    } else
      cout << -1 << "\n";
  } else {
    if (n == 2) {
      cout << -1 << "\n";
      return 0;
    }
    int a = 0, b = 1, c = 2, l = -1;
    string res;
    for (int i = 0; i < m; i++) {
      if (!(x[i] == a || x[i] == b || x[i] == c))
        res.push_back('v');
      else if (!(y[i] == a || y[i] == b || y[i] == c))
        res.push_back('^');
      else if (l == -1) {
        if (b == x[i])
          swap(a, b);
        else if (c == x[i])
          swap(a, c);
        if (c == y[i])
          swap(b, c);
        l = i;
        res.push_back('^');
      } else if (x[i] == c || y[i] == c) {
        if (x[i] == a || y[i] == a) {
          res[l] = 'v';
          swap(a, b);
        }
        swap(a, c);
        if (a > b)
          swap(a, b);
        res.push_back('^');
        l = i;
      } else {
        res.push_back('^');
        l = i;
      }
    }
    cout << res << "\n";
  }
}


Measured memory_bytes: 306816
import java.util.Arrays;
import java.util.Scanner;
 
public class Main{    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Player[] winner = new Player[6];
        Player[][] r = new Player[3][8];
        for(int i=0;i<3;i++){
            for(int j=0;j<8;j++){r[i][j]=new Player(sc.nextInt(),sc.nextDouble());}
        }
        for(int i=0;i<3;i++){
        Arrays.sort(r[i]);
        }
        int x = 0;
        for(int i=0;i<3;i++){
            System.out.printf("%d %.2f\n", r[i][0].id, r[i][0].time);
            System.out.printf("%d %.2f\n", r[i][1].id, r[i][1].time);
            winner[x++] = r[i][2];
            winner[x++] = r[i][3];
        }
        Arrays.sort(winner);
        System.out.printf("%d %.2f\n", winner[0].id, winner[0].time);
        System.out.printf("%d %.2f\n", winner[1].id, winner[1].time);
    }
    static class Player implements Comparable<Player>{
        int id;
        double time;
        public Player(int id, double time) {
            this.id = id;
            this.time = time;
        }
        public int compareTo(Player p) {
            return time-p.time<0?-1:p.time-time<0?1:0;
        }
    }
 
}
 

Measured memory_bytes: 28000
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)

int main(){
	
	int a,b,h;

	cin>>a>>b>>h;

	int answer = (a+b) * h / 2;

	cout<<answer<<endl;


	return 0;
}


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

double solve(vector<vector<double>> &dp, vector<double> &p, int i, int h){
    if(i<h){
        return 0;
    }
    if(h < 0){
        return 0;
    }
    if(i==0){
        return 1;
    }
    if(dp[i][h] != -1){
        return dp[i][h];
    }
    dp[i][h] = p[i]*solve(dp, p, i-1, h-1) + (1-p[i])*solve(dp, p, i-1, h);
    // cout<<temp<<endl;
    return dp[i][h];
}

int main(){
    int n;
    cin>>n;
    vector<double> p(n+1, 0.0);
    for(int i = 1; i <= n;++i){
        scanf("%lf", &p[i]);
    }
    double ans = 0;
    vector<vector<double>> dp(n+1, vector<double> (n+1, -1));
    // solve(p, n, n/2 + 1);
    for(int i = n/2+1; i <= n; ++i){
        // cout<<solve(p, n, i)<<endl;
        ans += solve(dp, p, n, i);
    }
    printf("%0.10lf", ans);
    return 0;
}


Measured memory_bytes: 74120
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main(){
  string s;
  int a[100];
  int b=0;
  cin >> s;
  for(int i=0;i<100;i++){
    a[i]=0;
  }
  for(int i=0;i<4;i++){
    a[(int) s[i]] +=1;
  }
  for(int i=0;i<100;i++){
    if(a[i]==2) b++;
  }
  if(b==2)cout <<"Yes"<<endl;
  else cout <<"No"<<endl;
}

Measured memory_bytes: 256
#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(){
    string s; cin >> s;
    if(s <= "2019/04/30") cout << "Heisei" << endl;
    else cout << "TBD" << endl;
}

Measured memory_bytes: 256
/*
 
dunjen_master
 
*/
 
 

 
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
 
using namespace std;
 
const int MAX_N = int(1e6) + 10;
const long long int MOD=1e9+7;
const long long int INF=1e18;
 
typedef long long int ll;
typedef unsigned long long int llu;
 
 

inline ll mul(ll a,ll b){

    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll c=a*b;
    c=(c+MOD)%MOD;
    return c;
}
inline ll add(ll a,ll b){
    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll ans=(a+b);
    ans=(ans+MOD)%MOD;
    return ans;
}
ll power(ll a,ll b,ll c=0){
    ll ans=1;
    while(b){
        if(b&1){
            ans=mul(ans,a);
        }
        a=mul(a,a);
        b=b/2;
    }
    return ans;
}

  

 
#define all(x) (x).begin(),(x).end()


ll a[200005];


int main(){


   ll n,k;
   cin>>n>>k;

   for(int i=0;i<n;i++){
    cin>>a[i];
   }

   vector<int>v;
   int i=1;
   set<int>s;
   while(s.find(i)==s.end()){
    v.push_back(i);
    s.insert(i);
    i=a[i-1];
   }

   int banda=i;
   int indx=0;
   for(int i=0;i<v.size();i++){
    if(v[i]==banda){
        indx=i;
    }
   }

   if(k<=indx){
    cout<<v[k]<<endl;
    return 0;
   }else{
    vector<int>v2;
    for(int i=indx;i<v.size();i++){
        v2.push_back(v[i]);
    }
    v.clear();
    for(int i=0;i<v2.size();i++){
        v.push_back(v2[i]);
    }
    k-=indx;
   }

   cout<<v[k%((ll)v.size())]<<endl;

    

    
}

    

    
 
    



Measured memory_bytes: 14616
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
typedef long long int lint;
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> c[i];
    }
    sort(all(a));
    sort(all(b));
    sort(all(c));
    // bc[i]:b[i]の下に置けるcの数
    vector<lint> bc(n);
    for (int i = 0; i < n; i++) {
        bc[i] = c.end() - upper_bound(all(c), b[i]);
    }
    // sum_b[i]:=b[i]~b[n-1]の和
    vector<lint> sum_b(n);
    sum_b[n - 1] = bc[n - 1];
    for (int i = n - 2; i >= 0; i--) {
        sum_b[i] = sum_b[i + 1] + bc[i];
    }
    lint ans = 0;
    for (int i = 0; i < n; i++) {
        if (upper_bound(all(b), a[i]) != b.end()) {
            ans += sum_b[upper_bound(all(b), a[i]) - b.begin()];
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

vector<bool> sieve(int n) {
    vector<bool> arr(n + 1, true);
    arr[0] = false;
    arr[1] = false;
    
    for (int i = 2; i * i <= n; i++) {   
        if (!arr[i]) continue;
        for (int j = i * i; j <= n; j += i) {
            arr[j] = false;
        }
    }
    return arr;
}

int main(int argc, char *argv[]) {
    vector<bool> parr = sieve(100000);
    vector<bool> arr2017(100000 + 1, false);
    for (int i = 2; i <= 100000; i++) {
        if (i % 2 == 1 && parr[i] && parr[(i + 1) / 2]) {
            arr2017[i] = true;
        }
    }
    int sum = 0;
    vector<int> sarr(100000 + 1, 0);
    for (int j = 1; j <= 100000; j++) {
        if (arr2017[j]) {
            sum++;
        }
        sarr[j + 1] = sum;
    }

    int Q;
    cin >> Q;
    for (int i = 0; i < Q; i++) {
        int l, r;
        cin >> l >> r;
        cout << sarr[r + 1] - sarr[l] << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

bool line[100][100][1000];
int n, m, a;

main(){
  while(cin >> n >> m >> a && (n|m|a)){
    fill(line[0][0], line[100][0], false);
    for(int i=0;i<m;i++){
      int h, p, q;
      cin >> h >> p >> q;
      line[p-1][q-1][h-1] = line[q-1][p-1][h-1] = true;
    }
    int p = a-1;
    for(int i=999;i>=0;i--){
      for(int j=0;j<n;j++){
        if(line[p][j][i]){
          p = j;
          break;
        }
      }
    }
    cout << p+1 << endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
class DisjointSet {
	public:
	vector<int> rank, p;
	DisjointSet() {}
	DisjointSet(int size) {
		rank.resize(size, 0);
		p.resize(size, 0);
		rep(i, 0, size) makeSet(i);
	}
	void makeSet(int x) {
		p[x] = x;
		rank[x] = 0;
	}
	bool same(int x, int y) {
		return findSet(x) == findSet(y);
	}
	void unite(int x, int y) {
		link(findSet(x), findSet(y));
	}
	void link(int x, int y) {
		if(rank[x] > rank[y]) p[y] = x;
		else {
			p[x] = y;
			if(rank[x] == rank[y]) ++rank[y];
		}
	}
	int findSet(int x) {
		if(x != p[x]) p[x] = findSet(p[x]);
		return p[x];
	}
};
int main() {
	int n, q; cin >> n >> q;
	DisjointSet ds = DisjointSet(n);
	int t, a, b;
	rep(i, 0, q) {
		cin >> t >> a >> b;
		if(t == 0) ds.unite(a, b);
		else if (t == 1) P(ds.same(a, b) ? 1 : 0);
	}
	return 0;
}

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

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

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

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

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

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

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Long() + add;
        }
        return Array;
    }
}
class Program {
    static Scanner cin = new Scanner();
    static void Main() {
        int N = cin.Int();
        int x = cin.Int();
        if(N == 2 && x == 2) {
            Console.WriteLine("Yes");
            for (int i = 1; i <= 3; i++) {
                Console.WriteLine(i);
            }
        }
        else if (2 <= x && x <= 2 * N - 2) {
            Console.WriteLine("Yes");
            var list = new List<int>();
            for (int i = 1; i < 2 * N; i++) list.Add(i);
            if(x == 2) {
                for (int j = x - 1; j <= x + 2; j++) {
                    list.Remove(j);
                }
                for (int j = 0; j < N - 2; j++) {
                    Console.WriteLine(list[j]);
                }
                Console.WriteLine(x + 1);
                Console.WriteLine(x);
                Console.WriteLine(x - 1);
                Console.WriteLine(x + 2);
                for (int j = N - 2; j < 2 * N - 5; j++) {
                    Console.WriteLine(list[j]);
                }
            }
            else {
                for (int j = x - 2; j <= x + 1; j++) {
                    list.Remove(j);
                }
                for (int j = 0; j < N - 2; j++) {
                    Console.WriteLine(list[j]);
                }
                Console.WriteLine(x - 1);
                Console.WriteLine(x);
                Console.WriteLine(x + 1);
                Console.WriteLine(x - 2);
                for (int j = N - 2; j < 2 * N - 5; j++) {
                    Console.WriteLine(list[j]);
                }
            }
        }
        else Console.WriteLine("No");
        Console.ReadLine();
    }
}

Measured memory_bytes: 18904
#include <iostream>
#include <math.h>
#include <limits.h>
using namespace std;

int main() {
    
    long long N;
    int min_a = INT_MAX;
    double n;
    
    cin >> N;
    
    n = sqrt(N);
    
    for ( int i = 2; i <= n; i++ ) {
        if ( ( N % i ) == 0 ) {
           int a;
           a = max( static_cast<int>( log10( N / i ) ), static_cast<int>( log10(i) ) );
           
           if ( min_a > a ) {
               min_a = a;
           }
        }
    }
    
    if ( min_a == INT_MAX ) { min_a = log10(N); }
    cout << min_a+1 << endl;
    
    return 0;
}

Measured memory_bytes: 512
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

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

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	ll n;
	cin>>n;
	ll a,b;
	cin>>a>>b;
	if(n==1&&a!=b) {
		cout<<0;
		return;
	}
	if(n==1||a==b) {
		cout<<1;
		return;
		}
	n-=2;
	if(n<0||b<=a){
		cout<<0;
		return;
	}
	ll ans = b*n-a*n+1;
	cout<<ans;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3644
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <cstring>

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))

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

using namespace std;

int main(){
    int n;
    int v[30],c[30];

    cin >> n;

    rep(i, n){
        cin >> v[i];
    }
    rep(i, n){
        cin >> c[i];
    }

    int sum = 0;
    rep(i, n){
        if(v[i] - c[i] > 0){
            sum += v[i] - c[i];
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
#define X real()
#define Y imag()
#define curr(P, i) P[i]
#define next(P, i) P[(i+1)%P.size()]
#define prev(P, i) P[(i+P.size()-1) % P.size()]
#define diff(P, i) (next(P, i) - curr(P, i))
const double EPS = 1e-8;
const double INF = 1e12;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}

//??????
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}

//??????
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}

//??? (??????)
struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};

int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}

//????§???¢
typedef vector<P> G;

double convex_diameter(const G &pt) {
  const int n = pt.size();
  int is = 0, js = 0;
  for (int i = 1; i < n; ++i) {
	 //?????????????????¨?????????????????£?????????????????????????????????
    if (imag(pt[i]) > imag(pt[is])) is = i;
    if (imag(pt[i]) < imag(pt[js])) js = i;
  }
  double maxd = norm(pt[is]-pt[js]);
  int i, maxi, j, maxj;
  i = maxi = is;
  j = maxj = js;
  do {
    if (cross(diff(pt,i), diff(pt,j)) >= 0) j = (j+1) % n;
    else i = (i+1) % n;
    if (norm(pt[i]-pt[j]) > maxd) {
      maxd = norm(pt[i]-pt[j]);
      maxi = i; maxj = j;
    }
  } while (i != is || j != js);
  return sqrt(maxd); /* farthest pair is (maxi, maxj). */
}

int main() {
  int N; cin >>N;
  G g(N);
  REP(i, N){
    double x, y; cin >>x >>y;
    g[i] = P(x, y);
  }
  printf("%.10lf\n", convex_diameter(g));
  return 0;
}

Measured memory_bytes: 4068
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
using namespace std;

typedef long long ll;



int main() {
	int n; cin >> n;
	string s; cin >> s;
	int cnt = 0, l = 0, r = 0;
	for (int i = 0; i < n; i++) {
		cnt += s[i] == '(' ? 1 : -1;
		if (s[i] == ')' && cnt < 0) l++;
		cnt = max(0, cnt);
	}
	cnt = 0;
	for (int i = n - 1; i >= 0; i--) {
		cnt += s[i] == '(' ? -1 : 1;
		if (s[i] == '(' && cnt < 0) r++;
		cnt = max(0, cnt);
	}
	for (int i = 0; i < l; i++) cout << "(";
	cout << s;
	for (int i = 0; i < r; i++) cout << ")";
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define N 1010
#define ll long long
int last[N*2],cur[N*2],len=1;
ll dis[N*2];
int q[N*2],p[N*2];
ll ans=0;
struct
{
	int c,w,to,next;
}a[N*20];
int n,ns,m;
void add(int x,int y,int c,int w)
{
	a[++len].to=y;
	a[len].next=last[x];
	a[len].c=c,a[len].w=w;
	last[x]=len;
}
int id = 0;
int SPFA()
{
	for(int i=0;i<=ns;i++) dis[i]=-1e16;
	q[1]=0,p[0]=++id,dis[0]=0;
	int l=0,r=1;
	while(l!=r)
	{
		l=l%(ns+10)+1;
		int k=q[l];
		p[k]=0;
		for(int i=last[k];i;i=a[i].next) 
		{
			int x=a[i].to;
			if(dis[k]+a[i].w>dis[x]&&a[i].c)
			{
				dis[x]=dis[k]+a[i].w;
				if(p[x] < id)
				{
					p[x]=id;
					r=r%(ns+10)+1;
					q[r]=x;
				}
			}
		}
	}
	return dis[ns]>0;
}
int dfs(int k,int flow)
{
	if(k==ns) return flow;
	int have=0;
	p[k]=1;
	for(int i=cur[k];i;i=a[i].next)
	{
		int x=a[i].to;
		if(!p[x]&&dis[k]+a[i].w==dis[x]&&a[i].c)
		{
			cur[k] = i;
			int t=min(flow-have,a[i].c);
			int now=dfs(x,t);
			ans+=(ll)now*a[i].w;
			have+=now,a[i].c-=now,a[i^1].c+=now;
			if(have==flow) break;
		}
	}
	p[k]=0;
	return have;
}
int main()
{
	int i,x,y,c;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d%d%d",&x,&y,&c);
		add(i,2*n+1,c,x+y);
		add(2*n+1,i,0,-x-y);
		add(i,2*n+2,c,x-y);
		add(2*n+2,i,0,y-x);
		add(i,2*n+3,c,y-x);
		add(2*n+3,i,0,x-y);
		add(i,2*n+4,c,-x-y);
		add(2*n+4,i,0,x+y);
		add(0,i,c,0);
		add(i,0,0,0);
	}
	for(i=1;i<=n;i++)
	{
		scanf("%d%d%d",&x,&y,&c);
		add(2*n+1,i+n,1e6,-x-y);
		add(i+n,2*n+1,0,x+y);
		add(2*n+2,i+n,1e6,y-x);
		add(i+n,2*n+2,0,x-y);
		add(2*n+3,i+n,1e6,x-y);
		add(i+n,2*n+3,0,y-x);
		add(2*n+4,i+n,1e6,x+y);
		add(i+n,2*n+4,0,-x-y);
		add(i+n,2*n+5,c,0);
		add(2*n+5,i+n,0,0);
	}
	ns=2*n+5;
	while(SPFA())
	{
		while(1) {
			for(i = 0; i <= ns; i++) cur[i] = last[i];
			int t = dfs(0,1e6);	
			if(!t) break;
		}
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 2056
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i = a; i<n; i++)
#define per(i,a,n) for (int i = n-1; i>=a; i--)
#define pb push_back
#define mp make_pair
#define all(now) (now).begin(),(now).end()
#define fi first
#define se second
#define SZ(now) ((int)(now).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod = 1000000007;
inline int read(int &n){char c=getchar();int x=0,f=1;while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9'){x=x*10+(c-'0');c=getchar();}return n = x*f;}
ll powmod(ll a,ll b,ll mod) {ll res = 1; a%=mod; assert(b>=0); for(;b; b>>=1){if(b&1)res = res*a%mod; a = a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
const int N = 1e2+7;
int T,n,m;
VI X,Y,H;
int main()
{
    //ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n;
    rep(i,0,n){
        int x, y, h;
        cin >> x >> y >> h;
        X.pb(x);
        Y.pb(y);
        H.pb(h);
    }
    rep(x,0,101){
        rep(y,0,101){
            int height = -1;
            bool flag = 0;
            rep(i,0,n){
                if(H[i]==0)
                    continue;
                if(height==-1)
                    height = H[i] + abs(X[i] - x) + abs(Y[i] - y);
                else if(height != H[i] + abs(X[i] - x) + abs(Y[i] - y))
                    flag = 1;
            }
            // rep(i,0,n){
            //     if(H[i]==0 && height-abs(X[i]-x)-(Y[i]-y) > 0)
            //         flag = 1;
            // }
            for(int i=0;i<n;i++){
				if(H[i]==0){
					if(height-abs(X[i]-x)-abs(Y[i]-y)>0)
						flag=1;
				}
			}
            if(!flag){
                // printf("%d %d %lld\n", i, j, height);
				cout<<x<<" "<<y<<" "<<height<<endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    cout << a*b << endl;
}


Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <queue>
using namespace std;
const int M=1e5;
int main(int argc, char *argv[])
{
	int n,x;
	while(cin>>n>>x)
	{
		int a[M],i;
		for(i=0;i<n;i++)
			cin>>a[i];
		a[i]=x;
		sort(a,a+n+1);
		priority_queue<int,vector<int>,greater<int> >q;
		for(int i=0;i<n;i++)
			q.push(a[i+1]-a[i]);
		while(q.size()!=1)
		{
			int a,b,c;
			a=q.top();
			q.pop();
			b=q.top();
			q.pop();
			c=b%a;
			while(c!=0)
			{
				b=a;
				a=c;
				c=b%a;
			}
			q.push(a);
		}
		printf("%d\n",q.top());
	}
	return 0;
}

Measured memory_bytes: 1276
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main() {
	int n;
	while(cin >> n&&n != 0) {
		int a[100][100];
		bool b[100][100];
		bool c[100][100];
		for (int i = 0; i < n; i++) {
			int d = 1000000;
			vector<int>e;
			for (int j = 0; j < n; j++) {
				cin >> a[i][j];
				if (d > a[i][j]) {
					e.clear();
					d = a[i][j];
					e.push_back(j);
				}
				else if (d == a[i][j]) {
					e.push_back(j);
				}
				b[i][j] = false;
				c[i][j] = false;
			}
			for (int z = 0; z < e.size(); z++) {
				b[i][e[z]] = true;
			}
		}
		for (int i = 0; i < n; i++) {
			int d = -1;
			vector<int>e;
			for (int j = 0; j < n; j++) {
				if (d < a[j][i]) {
					e.clear();
					d = a[j][i];
					e.push_back(j);
				}
				else if (d == a[j][i]) {
					e.push_back(j);
				}
			}
			for (int z = 0; z < e.size(); z++) {
				c[e[z]][i] = true;
				if (b[e[z]][i]) {
					cout << a[e[z]][i] << endl;
					goto stop;
				}
			}
		}
		cout << 0 << endl;
	stop:;
	}
}

Measured memory_bytes: 3132
#include <iostream>

#include <vector>

using namespace std;

int main(){

    int N, K;

    cin >> N >> K;

    vector<int> h(N, 0), dp(N, 1000000000);

    for(int i = 0; i < N; i++){

    cin >> h[i];
    }
    dp[0] = 0;

    for(int j = 1; j < N; j++){

        for(int k = 1; k <= K; k++){

            if(j - k < 0){

                continue;
            }
        dp[j] = min(dp[j], abs(h[j] - h[j-k]) + dp[j-k]);
        }
  }

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

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;++i)
    cin>>a[i];
  int len=1,now=1;
 for(int i=0;i<n-1;++i)
 {
   if(a[i]>=a[i+1])
   { now++;
   len=max(len,now);
   }
   else now=1;
 }
  cout<<len-1;
  return 0;
}
   
   

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define lowbit(x) ((x)&(-x))
#define inf 0x3f3f3f3f
#define endl '\n'
#define MP(x,y) (make_pair(x,y))
#define pll pair<int,int>
#define pi 3.1415926535
using namespace std;
int n,m;
double a[105],sum;
int main(){
    cin>>n>>m;
    for(int i=0;i<n;i++) cin>>a[i],sum+=a[i];
    double x = sum/(4.0*m);
    int num = 0;
    for(int i=0;i<n;i++){
        if(a[i]>=x)
            num++;
    }
    if(num >=m)
        puts("Yes");
    else
        puts("No");

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi              first
#define se              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define endl			"\n"
void fast()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int n, capacity;
int dp[101][100001];
vector<int> w, v;

int solve(int max_profit)
{
	for (int i = 0; i <= n; i++)
	{
		for (int j = 0; j <= max_profit; j++)
		{
			if (i == 0 and j == 0)
				dp[i][j] = 0;
			else if (i == 0)
				dp[i][j] = inf;
			else if (v[i - 1] <= j)
				dp[i][j] = min(w[i - 1] + dp[i - 1][j - v[i - 1]], dp[i - 1][j]);
			else
				dp[i][j] = dp[i - 1][j];
		}
	}
	int ans = 0;
	for (int j = 0; j <= max_profit; j++)
	{
		if (dp[n][j] <= capacity)
			ans = j;
	}
	return ans;
}
int32_t main()
{
	fast();
	cin >> n >> capacity;
	w.resize(n);	v.resize(n);
	int max_profit = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> w[i] >> v[i];
		max_profit += v[i];
	}
	cout << solve(max_profit);
	return 0;
}


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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;



template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7ll;
const double PI=3.14159265358979323846;

// 二項係数ライブラリ---------------------------------------------------------------------------------------//
const ll MAX_COM = 1000007;
ll fac[MAX_COM], finv[MAX_COM], inv[MAX_COM];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1ll;
    finv[0] = finv[1] = 1ll;
    inv[1] = 1ll;
    for (int i = 2; i < MAX_COM; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] % MOD * finv[k] % MOD * finv[n - k] % MOD;
}

// Nが大きいときの二項係数計算
// N = 10^9, k = 2*10^5まで使える
const ll MAX_COM_NB = 200010;
vector<ll> COM_NB(MAX_COM_NB);
void COM_NBinit(int N) {
    // COMinit();
    COM_NB[0] = 1ll;
    rp(i, 1, MAX_COM_NB) {
        COM_NB[i] = COM_NB[i-1] * (N+1-i) % MOD * inv[i] % MOD;
    }
}

// 二項係数ライブラリここまで-----------------------------------------------------------------------------------//


int main() {
    COMinit();
    int N, K;
    cin >> N >> K;
    vector< vector<int> > graph(N+10);
    rp(i, 0, N-1) {
        int a, b;
        scanf("%d%d", &a, &b);
        a--; b--;
        graph.at(a).emplace_back(b);
        graph.at(b).emplace_back(a);
    }
    vector<int> parent(N+10);
    parent.at(0) = -1;
    queue<int> q;
    q.push(0);
    while(!q.empty()) {
        int s = q.front(); q.pop();
        for(auto x: graph.at(s)) {
            parent.at(x) = s;
            if(x != parent.at(s)) q.push(x);
        }
    }
    ll res = K;
    int ch = int(graph.at(0).size());
    res = res * COM(K-1, ch) % MOD * fac[ch] % MOD;
    rp(i, 1, N) {
        ch = int(graph.at(i).size());
        if(ch != 1) {
            res = res * COM(K-2, ch-1) % MOD * fac[ch-1] % MOD;
        }
    }
    cout << res << endl;
    return 0;

}

Measured memory_bytes: 34900
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

// fact(n)
int fact(int n){
	if(n == 1)	return 1;
	else return (n * fact(n - 1));
}

// nCr(n,r)
int nCr(int n, int r){
	if(r == 0 || r == n)	return 1;
	else if(r == 1)	return n;
	return (nCr(n - 1, r - 1) + nCr(n - 1, r));
}

// gcd(a,b)
int gcd(int a,int b){
	if(a == 0) return b;
	else if(b == 0) return a;
	else return gcd(b,a % b);
}

// lcm(a,b)
int lcm(int a,int b){
	return (a * b) / gcd(a,b);
}

// swap(&a, &b);
void swap(int *a,int *b){
	int tmp;
	tmp = *a;	*a = *b;	*b = tmp;
	return;
}

// qsort(array, size, sizeof(int),comp);
int ASC(const int *a,const int *b){
	return (*a - *b);
}

int DESC(const int *a,const int *b){
	return (*b - *a);
}

// append(array,*size,addNum)
void append(int *array,int *size,int num){
	realloc(array, sizeof(int) * (*size + 1));
	array[(*size)] = num;
	++(*size);
}

// pop(array,*size) & nongetpop(array,*size)
int pop(int *array,int *size){
	int temp = array[(*size - 1)];
	nongetpop(array,&(*size));
	return temp;
}

int nongetpop(int *array,int *size){
	realloc(array,sizeof(int) * (*size - 1));
	--(*size);
}

int main(int argc, char const *argv[])
{
	int n,d;
	int x[13][13];
	int dis,temp;
	int cnt = 0;
	scanf("%d%d",&n,&d);
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < d; ++j)	scanf("%d",&x[i][j]);
	}
	for (int i = 0; i < n; ++i)
	{
		for (int j = i + 1; j < n; ++j)
		{
			dis = 0;
			for (int k = 0; k < d; ++k)
			{
				temp = abs(x[i][k] - x[j][k]);
				dis += (temp * temp);
			}
			if( (int)sqrt((double)dis) * (int)sqrt((double)dis) == dis ){
				++cnt;
			} 
		}
	}
	printf("%d\n", cnt);
	return 0;
}


Measured memory_bytes: 128
n,m = map(int,input().split())
penalty = [0]*n
did = [0]*n
for i in range(m):
    p,s = input().split()
    p = int(p)
    if s == 'WA':
        if did[p-1]==0:
            penalty[p-1] +=1
    else:
        did[p-1]=1
for i in range(n):
    penalty[i]*=did[i]
print(sum(did),sum(penalty))
  

Measured memory_bytes: 45752
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

map<int,int> times;
int n , a;

int main(){
    scanf("%d",&n);
    rep(i,0,n){
        scanf("%d",&a);
        times[a]++;
    }
    vi v;
    for(auto e : times) rep(i,0,e.se/2) v.pb(e.fi);
    sort(all(v));
    if(sz(v) < 2) puts("0");
    else printf("%lld\n",(ll)v[sz(v)-1]*v[sz(v)-2]);
    return 0;
}


Measured memory_bytes: 4992
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int p[] = new int[N+1];

		for (int i=1; i<=N; i++){
			p[i] = sc.nextInt();
		}

		int swap = 0;
		boolean skip = false;
		for (int i=1; i<=N; i++){
			if (skip){
				skip = false;
				continue;
			}
			if (i == p[i]){
				swap++;
				if (i<N && i+1 == p[i+1]){
					skip = true;
				}
			}
		}
		System.out.println(swap);
	}
}





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

namespace ABC144A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c, d;

            var word = Console.ReadLine().Split(' ');

            a = int.Parse(word[0]);
            b = int.Parse(word[1]);

            c = a * b;

            d = -1;

            if (a < 10 && b < 10)
                Console.WriteLine(c);

            else Console.WriteLine(d);
        }
    }
}

Measured memory_bytes: 13140