akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdlib>
using namespace std;


struct tree{
	tree* left;
	tree* right;
	tree* parent;
	int val;
};

void printPreorder(tree* root){
	if(root== NULL)return;
	cout << " " << root->val;
	printPreorder(root->left);
	printPreorder(root->right);
	return;
}
void printInorder(tree* root){
	if(root== NULL)return;
	printInorder(root->left);
	cout << " " << root->val;
	printInorder(root->right);
	return;
}

tree* findNode(int val, tree* root){
	if(root->val == val)return root;

	tree* next;
	if(val < root->val)next = root->left;
	else next = root->right;

	if(next)return findNode(val,next);
	else return NULL;
}
tree* getMax(tree* root){
	if(root->right == NULL)return root;
	else return getMax(root->right);
};

void deleteNode(tree* node){
	return;
	bool nodeIsRoot = node->parent == NULL;
	bool nodeIsLeft = false;
	if(!nodeIsRoot)nodeIsLeft = node->parent->left == node;
	tree* subNode = NULL;
	if(node->left == NULL && node->right == NULL){
	}else if(node->left != NULL && node->right != NULL){
		subNode = getMax(node->left);
		if(subNode -> left != NULL){
			subNode->parent->right = subNode->left;
			subNode->left->parent = subNode->parent;
		}else{
			subNode->parent->right = NULL;
		}
		subNode->left = node->left;
		subNode->right = node->right;
	}else{
		if(node->left == NULL)subNode = node->right;
		else subNode = node->left;
	}
	if(subNode)subNode->parent = node->parent;
	if(nodeIsLeft)node->parent->left = subNode;
	else if(!nodeIsRoot)node->parent->right = subNode;
	free(node);
};

void insert(int val, tree* root){
	tree* next;
	bool flag = val < root->val;
	if(flag)next = root->left;
	else next = root->right;

	if(next == NULL){
		tree* newNode = (tree*)malloc(sizeof(tree));
		newNode->val = val;
		newNode->left = NULL;
		newNode->right = NULL;
		newNode->parent = root;
		if(flag)root->left = newNode;
		else root->right = newNode;
	}else{
		insert(val,next);
	}
}

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

	tree* root = (tree*)malloc(sizeof(tree));

	char order[10];
	int val;
	int numOfOrder;

	cin >> numOfOrder;
	cin >> order;
	cin >> val;

	root->val = val;
	root->left = NULL;
	root->right = NULL;
	root->parent = NULL;
	

	for(int i = 0; i <  numOfOrder - 1; i++){
		cin >> order;
		if(order[0] == 'i'){
			cin >> val;
			insert(val, root);
		}else if(order[0] == 'p'){
			printInorder(root);
			cout << endl;
			printPreorder(root);
			cout << endl;
		}else if(order[0] == 'f'){
			cin >> val;
			if(findNode(val, root) == NULL)cout << "no" << endl;
			else cout << "yes" << endl;
		}else{
			cin >> val;
			deleteNode(findNode(val, root));	
		}
	}


	return 0;

}

Measured memory_bytes: 24652
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  char a;
  cin >> a;
  if (a >= 65 && a <= 90)
  {
    cout << "A" << endl;
  }
  else
  {
    cout << "a" << endl;
  }
  return 0;
}

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

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

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int main()
{
    ll H,N;
    cin >> H >> N;

    vector<int> A(N);
    ll all = 0;
    rep(i,N)
    {
        cin >> A[i];
        all += A[i];
    }
    if( H <= all ) cout << "Yes" << endl;
    else cout << "No" << endl;


}


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

using namespace std;

#define MAX 100002
int X[MAX];

int main(){
    int N, a;
    scanf("%d", &N);
    for(int i=0; i<MAX; i++) X[i] = 0;
    for(int i=0; i<N; i++) {
        scanf("%d", &a);
        X[a]++; X[a+1]++; X[a+2]++;
    }
    int ans = 0;
    for(int i=0; i<MAX; i++) ans = max(ans, X[i]);
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 640
N = int(input())
abcList = [list(map(int, input().split())) for i in range(N)]
dp = [abcList[0]]

if len(abcList) == 1:
    print(max(abcList[0][0], abcList[0][1], abcList[0][2]))
else:
    for i in range(1, N):
        dp.append([abcList[i][0] + max(dp[i - 1][1], dp[i - 1][2]),
                   abcList[i][1] + max(dp[i - 1][0], dp[i - 1][2]),
                   abcList[i][2] + max(dp[i - 1][0], dp[i - 1][1])])
    print(max(dp[-1]))

Measured memory_bytes: 70232
from bisect import bisect_left
N=int(input())
triangle=[]
count=0
L=list(map(int,input().split()))
L.sort()
#print(L)
for a in range(N):
    for b in range(a+1,N):
        c=L[a]+L[b]
        zahyo=bisect_left(L,c)
        count+=max(0,zahyo-b-1)
print(count)

Measured memory_bytes: 3188
#include<iostream>
using namespace std;
int main(void)
{
	int a,b,k;
	cin>>a>>b>>k;
	for(int i=min(a,b);i>=0;i--)
	{
		if(a%i==0&&b%i==0)
			k--;
		if(!k)
		{
			cout<<i;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#s<t!
#一番期待値が悪くなる辺だけ考える
n,m = map(int, input().split( ))

E= [[] for _ in range(n)]

for _ in range(m):
    s,t = map(int, input().split( ))
    E[s-1].append(t-1)

dp = [0]*n 

for s in range(n-2,-1,-1):
    for t in E[s]:
        dp[s] += dp[t]
    if E[s]:
        dp[s] /= len(E[s])
    dp[s] += 1

#print("dp",*dp)

ans = dp[0]
for s2 in range(n-1):
    if len(E[s2])-1:
        dp2 = [0]*n
        mxi = 0
        mxt = -1
        for t in E[s2]:
            if mxt<dp[t]:
                mxi = t 
                mxt = dp[t]
        if mxt<0:
            continue            
        for s in range(n-2,-1,-1):
            for t in E[s]:
                dp2[s] += dp2[t]
            if s ==s2:###ループ深さ
                dp2[s] -= mxt
            if s == s2:
                dp2[s] /= (len(E[s])-1)
            elif E[s]:##el if
                dp2[s] /= len(E[s])
            dp2[s] += 1
        ans = min(ans, dp2[0])
        #print("dp2",*dp2)

print(ans)

Measured memory_bytes: 66520
IDENTIFICATION DIVISION.
       PROGRAM-ID. ATCODER.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  indata PIC X(100).
       01  a1 PIC S9(08).
       01  a2 PIC S9(08).
       01  a3 PIC S9(08).
       01  r1 PIC S9(08).
       01  r2 PIC S9(08).
       01  r3 PIC S9(08).
       01  g1 pic S9(08).
       01  g2 pic S9(08).
       01 disp pic Z(20)9.
       PROCEDURE DIVISION.
        ACCEPT indata.
        
        UNSTRING indata DELIMITED BY SPACE INTO a1 a2.

        compute r1 = a1 * a2
        divide r1 by 2 giving g1 remainder r1

        compute r2 = a1 * a2 * 3
        divide r2 by 2 giving g1 remainder r2

        if r1 = 1 or r2 = 1 then
         display "Yes"
        else
         display "No"
        end-if

 
 
       STOP RUN.


Measured memory_bytes: 384
a,b,k = map(int,input().split())
lst = []
for i in range(a,b+1):
    if i >= a+k:
        break
    lst.append(i)
for i in range(b,a-1,-1):
    if i <= b-k:
        break
    lst.append(i)

lst = list(set(lst))
lst.sort()
for i in lst:
    print(i)


Measured memory_bytes: 38256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#define N 210
#define M N*N
#define MX 20000000
using namespace std;
int nxt[M<<1],to[M<<1],head[N],cnt;
bool vis[N<<1];
int link[N<<1],lf[N<<1],rf[N<<1],n,m;
int prime[MX],maxp[MX];
bool cant[MX];
void add(int u,int v)
{
	nxt[++cnt]=head[u];
	to[cnt]=v;
	head[u]=cnt;
}
bool check(int u)
{
	for(int i=head[u];i;i=nxt[i])
	{
		int v=to[i];
		if(vis[v]) continue;
		vis[v]=true;
		if(!link[v] || check(link[v]))
		{
			link[u]=v;
			link[v]=u;
			return true;
		}
	}
	return false;
}
void build()
{
	for(int i=1;i<=lf[0];i++)
	{
		int x=lf[i];
		for(int j=1;j<=rf[0];j++)
		{
			int y=rf[j];
			if(cant[abs(x-y)]) continue;
			add(i,j+lf[0]);
			add(j+lf[0],i);
		}
	}
}
bool color[MX];
int maxn=0;
void solve()
{
	lf[0]=rf[0]=0;
	for(int i=1;i<=maxn;i++)
		if(color[i]!=color[i-1])
		{
			if(i&1) rf[++rf[0]]=i;
			else lf[++lf[0]]=i;
		}
	build();
	int ans=0;
	for(int i=1;i<=lf[0];i++)
	if(!link[i])
	{
		memset(vis,0,sizeof(vis));
		ans+=check(i);
	}
	int res=0;
	if(ans<lf[0]) res+=(lf[0]-ans)/2*2;
	if(ans<rf[0]) res+=(rf[0]-ans)/2*2;
	if((lf[0]-ans)%2==1) res+=3;
	printf("%d\n",ans+res);
}
int main()
{
	int cnt=0;
	prime[1]=1;
	cant[1]=1;
	for(int i=2;i<=MX-10;++i)
	{
		if(!cant[i])
		{
			prime[++cnt]=i;
			maxp[i]=i;
		}
		for(int j=1;j<=cnt && i*prime[j]<=MX-10;j++)
		{
			cant[i*prime[j]]=true;
			if(i%prime[j]==0)
			{
				maxp[i*prime[j]]=prime[j];
				break;
			}
		}
	}
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		int a;
		scanf("%d",&a);
		color[a]=true;
		maxn=max(maxn,a);
	}
	maxn++;
	solve();
	return 0;
}


Measured memory_bytes: 113024
#include<bits/stdc++.h>
using namespace std;
#define forr(x,n) for(int x = 0; x < n; ++x)
#define pr pair<int,int>
#define ll long long int
const int mod=1e9+7;
struct node{
    char color;
    ll cost;
};
bool cmp(node a,node b)
{
    return a.cost>b.cost;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int x,y,n1,n2,n3;
    cin>>x>>y>>n1>>n2>>n3;
    int n=n1+n2+n3;
    node a[n];
    int i=0;
    for(;i<n1;i++)
    {
        cin>>a[i].cost;
        a[i].color='r';
    }
    for(;i<n1+n2;i++)
    {
        cin>>a[i].cost;
        a[i].color='g';
    }
    for(;i<n1+n2+n3;i++)
    {
        cin>>a[i].cost;
        a[i].color='c';
    }
    sort(a,a+n,cmp);
    int r=0,g=0,c=0;
    ll ans=0;
    i=0;
    while(i<n&&r+g+c<x+y)
    {
    //    cout<<"total="<<r+g+c<<endl;
        if(a[i].color=='r'&&r<x&&r+g+c<x+y)
        {
            r++;
            ans+=a[i].cost;
        }
        if(a[i].color=='g'&&g<y&&r+g+c<x+y)
        {
            g++;
            ans+=a[i].cost;
        }
        if(a[i].color=='c'&&r+g+c<x+y)
        {
            c++;
            ans+=a[i].cost;
        }
    //    cout<<"i="<<i<<endl;
        i++;
    }
    cout<<ans;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  int k,a,b;
  cin>>k>>a>>b;
  for (int i = a; i <= b; ++i)
  {
    if(i%k==0)
    {
      cout<<"OK"<<endl;
      return 0;
    }
  }
  cout<<"NG"<<endl;
}

Measured memory_bytes: 3632
// 17:29 - 17:37
// debug: - 17:49
#include<bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define lch (o << 1)
#define rch (o << 1 | 1)

typedef double db;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> pint;

const int N = 1000 + 5;
const int INF = 0x3f3f3f3f;
const ll INF_LL = 0x3f3f3f3f3f3f3f3f;

int a[N];
ll f[N][N];
int g[N][N];

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

	for(int i=0; i<N; i++)
		for(int j=0; j<N; j++)
			f[i][j] = -INF_LL;

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

	for(int i=3; i<=n; i+=2)
		for(int l=1; l+i-1 <= n; l++){
			int r = l + i - 1;
			if(a[r] >= 0){
				f[l][r] = f[l][r-2] + a[r];
				g[l][r] = 1;
			}else{
				f[l][r] = f[l][r-2];
				g[l][r] = 0;
			}
		}

	int nl = 0, nr = 0;
	for(int i=1; i<=n; i+=2)
		for(int l=1; l+i-1 <= n; l++){
			int r = l + i - 1;
			if(f[l][r] > f[nl][nr])
				nl = l, nr = r;
		}

	cout << f[nl][nr] << endl;

	vector<int> ans;
	int siz = n;
	for(int i=1; i <= (nl - 1); i++){
		ans.push_back(1);
		siz--;
	}
	int pos = nl + 2;
	for(int i=1; i <= (nr - nl + 1) / 2; i++){
		if(g[nl][pos]) ans.push_back(2);
		else ans.push_back(3);
		pos += 2;
		siz -= 2;
	}
	for(int i=1; i <= (n - nr); i++)
		ans.push_back(siz--);

	cout << ans.size() << endl;
	for(auto a: ans)
		cout << a << endl;

	return 0;
}

Measured memory_bytes: 12160
/**
 * Title: D - Even Relation
 * Url: https://atcoder.jp/contests/abc126/tasks/abc126_d
 */
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<numeric>
#include<functional>
#include<sstream>
#include<iomanip>
#include<queue>

using namespace std;

#define ll long long

struct info
{
    /* data */
    int from;
    int to;
    int weight;
};


int main() {
    int n; cin >> n;
    vector<vector<pair<int, int>>> v(n+1, vector<pair<int, int>>());
    for(int i=0; i<n-1; i++) {
        int ui, vi, wi; cin >> ui >> vi >> wi;
        v[ui].push_back(make_pair(vi, wi));
        v[vi].push_back(make_pair(ui, wi));
    }

    vector<ll> dst(n+1, 0);

    queue<info> q;
    q.push(info{from: 0, to: 1, weight: 0});
    while(!q.empty()) {
        info i = q.front();
        q.pop();
        if(i.from==0) {
            for(auto vi : v[i.to]) {
                q.push(info{from: i.to, to: vi.first, weight: i.weight+vi.second});
                dst[vi.first] = i.weight+vi.second;
            }
        } else {
            for(auto vi:v[i.to]) {
                if(vi.first==i.from) continue;
                q.push(info{from: i.to, to: vi.first, weight: i.weight+vi.second});
                dst[vi.first] = i.weight+vi.second;
            }
        }
    }

    for(int i=1; i<=n; i++) {
        if(dst[i]%2==0) {
            cout << "0" << endl;
        } else {
            cout << "1" << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 7168
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    ll m;
    cin >> m;
    cout << 48 - m << "\n";
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
//ABC 179, task a, 2020/09/19
//ms,

/*
*/

int main(void){
  int64_t N;
  int64_t ans=0;

  cin >>N;
  for(int64_t a=1;a<N;a++){
    int64_t max_b=N/a;
    if(N%a==0) max_b--;
    ans+=max_b;
  }

  cout <<ans <<endl;
  return 0;
}
/*
AB=N-Cとして、各CについてN-Cの約数列挙？
いや、それではNrootNのオーダー。通らない。
式変形まではよくて、そのあと左辺で考えればよさそう。
そうか。AB<Nと同値の問題だな。つまり、Aに1から10~6まで代入していけばオーケー。
*/


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


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

    // pair<end,start>
    vector<pair<int,int>> v(N);

    REP(i,N) {
        int x,l;
        cin >> x >> l;
        v[i] = make_pair(x+l,x-l);
    }

    // sort from end
    sort(ALL(v));

    int ans = 0;
    ll lastWork = -1 * 1e10;
    REP(i,N) {
        // 最後に働いた時間より作業の開始時間の方が遅いなら使う
        if (lastWork <= v[i].second) {
            // cout << "use " << v[i].first << endl;
            ans++;
            lastWork = v[i].first;
            continue;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
#include <map>
#include <math.h>
#include <list>
#include <deque>
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll MOD = 1000000007;
ll INF = 1LL << 60;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) {return a / GCD(a, b) * b;}

int getdigit(ll N)
{
    int digit = 0;
    while(N != 0)
    {
        N /= 10;
        digit++;
    }
    return (digit);
}

int main()
{
    ll N;
    cin >> N;
    ll Max = 0;
    for(ll i = 1; i <= sqrt(N); i++)
    {
        if(N % i == 0) Max = max(Max,i);
    }
    cout << getdigit(N / Max) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
#define MOD (ll)(1e9+7)
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using Pll = pair<P,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;


signed main(){
    ll h,w;
    cin >> h >> w;
    ll d[10][10] = {};
    ll a[h][w] = {};
    ll ans = 0;

    rep(i,0,10) rep(j,0,10) cin >> d[i][j];

    rep(k,0,10) rep(i,0,10) rep(j,0,10) d[i][j] = min(d[i][j],d[i][k] + d[k][j]);

    rep(i,0,h) rep(j,0,w){
        cin >> a[i][j];
        if(a[i][j] != -1) ans += d[a[i][j]][1]; 
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main{
	
	public static void main(String[] args){
		int data[] = new int[10];
		Scanner scan = new Scanner(System.in);
		for(int i = 0; i < 10; i++){
			data[i] = scan.nextInt();
		}
		int total = 0;
		for(int i = 0; i < 10; i++){
			total = total + data[i];
		}
		System.out.println(total);
	}
}

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

using namespace std;

int main() {
  int A, B, C;
  
  cin >> A >> B >> C;
  
  int ans;
  
  ans = C - (A - B);
  
  if (ans < 0) {
    cout << 0 << endl;
  }
  else {
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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

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

int main() {
    init();
    ll a, b, tt;
    cin >> a >> b >> tt;
    ld th = tt * 2 * PI / 360.0L;
    ld S = a * b * sinl(th) / 2.0, c = sqrtl(a * a + b * b - 2 * a * b * cosl(th));
    cout << S << endl
         << a + b + c << endl
         << b * sinl(th) << endl;
}


Measured memory_bytes: 3564
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			long A = scan.nextLong();
			long B = scan.nextLong();
			long C = scan.nextLong();
			long D = scan.nextLong();
			
			long bc = B/C;
			long bd = B/D;
			long bcd = B/lcm(C,D);
			
			long ac = A/C;
			long ad = A/D;
			long acd =A/lcm(C,D);
			
			long Bwari = B-bc-bd+bcd;
			long Awari = A-ac-ad+acd;
			
			if(A%C!=0&&A%D!=0) {
				System.out.println(Bwari-Awari+1);
			}else {
				System.out.println(Bwari-Awari);
			}
			
			
			
		}
		
		
	}
	
	
	
	private  static long lcm(long A,long B) {//最小公倍数
		return A*B/gcd(A,B);
	}
	
	private static long gcd(long A,long B){//最大公約数
		return B==0?A:gcd (B,A%B);
	}
		

}


Measured memory_bytes: 21972
#include<iostream>
#include<deque>
#include<queue>
#include<math.h>
#include<string>
#include<string.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<iomanip>
#include<map>
#include<bitset>
#include<algorithm>
#include<stack>
#include<unordered_map>
#include<cstdlib>
#include<unordered_set>
#include<algorithm>
#include<chrono>
 
#define inf 0x3f3f3f3f
#define sup_inf 2e18
#define pb push_back
		
#define ii pair	<long long ,long long >
#define i64ii pair< long long, pair<int,int> >
#define i64i pair<long long , int >
#define f first
#define s second
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define iii pair<int, ii >	
#define in freopen("entrada","r",stdin);
#define out freopen("myfile.txt", "w", stdout);
#define eps 1e-9
#define id pair<int ,double > 
#define di pair<double, int>
 
#define pi 3.14159265359
#define nl (no<<1)
#define nr ( (no<<1)|1)
#define mid l + ( (r-l)>>1)
 
using namespace std;
 
 
typedef long long ll;	
typedef vector< int> vi;
typedef long double ld;
		
typedef  pair <ii, ii > iiii;
typedef vector < ii > vii;
 
const int MAX = 6e2;
const int maxn = 1e6  + 10;
 


map < ii, ll > m;
int n ;

ii c(int n ){
	int last = -1;
	int fst = -1;
	bool flag = 0;
 
	while(n ){
		int dig = n%10;
		if ( !flag)	{
			fst = dig;
			flag = 1;
		}
		last = dig;
		n/=10;
	}
	if (fst and last) {
		return { fst, last };
	}else {
		return{ -1, -1};
	}
}

int main (){
	//~ in
	scanf("%d",&n);
	ll ans = 0;
	for(int i = 1 ;i <= n;i++){
		ii x = c(i);
		m[x]++;
	}
	
	for(int i = 1 ;i < 10 ;i++){
		for(int j = i ;j < 10 ;j++){
			ll a = m[{i,j}];
			ll b = m[{j,i}];
			ll x = a * b;
			ans += x;
			if ( i != j )
				ans += x;
		}
	}
	
	printf("%lld\n",ans );
	return 0;
}


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

using namespace std;

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,j,k) for(int i=j;i<(k);i++)
#define foreach(T,c,i) for(T::iterator i=c.begin();i!=c.end();i++)
typedef vector<int> Array;
typedef vector<Array> Mat;
typedef long long int ll;
const int INF = 99999999;

int n,a,b;
string str;
string alpha = "abcdefghijklmnopqrstuvwxyz";
typedef pair<int,int> P;
P p;
stack<P> s;

void solve(int num)
{
    int x=alpha.find(str[p.first-1])+num;
    int y=alpha.find(str[p.second-1])+num;
    while(x>25) x-=26;
    while(y>25) y-=26;
    str[p.first-1]=alpha[x];
    str[p.second-1]=alpha[y];
}

int main()
{
    while(1){
        cin >> n >> str;
        if(n==0) return 0;
        rep(i,n){
            cin >> a >> b;
            p.first=a;
            p.second=b;
            s.push(p);
        }
        rep(i,n){
            p=s.top();
            s.pop();
            swap(str[p.first-1],str[p.second-1]);
            solve(p.second-p.first);
        }
        cout << str << endl;
    }
    return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int no = 1;
		while (true) {
			int i = sc.nextInt();
			if (i == 0) {
				break;
			}
			System.out.println("Case " + no + ": " + i);
			no++;
		}
	}
}

Measured memory_bytes: 42276
// D - Christmas
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll f(int n, ll x){
	if(n==0) return x<=0? 0:1;
	ll Ln = (1LL<<n+2) - 3;//L[n]
	ll Pn_1 = (1LL<<n) - 1;//P[n-1]
	ll m = Ln/2 + 1;
	if(m > x) return f(n-1, x-1);
	else if(m < x) return Pn_1 + 1LL + f(n-1, x-m);
	else return Pn_1 + 1LL;
}

int main(){
	int N; ll X; cin>>N>>X;
	cout<< f(N, X) <<endl;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner stdIn = new Scanner(System.in);
		int N = Integer.parseInt(stdIn.nextLine());
		String[] S = new String[N];
		for(int i = 0; i < N; i ++) {
			S[i] = stdIn.nextLine();
		}
		HashMap<String, Integer> itemNum = new HashMap<String, Integer>();
		for(int i = 0; i < S.length; i ++) {
			if(itemNum.get(S[i]) == null) {
				itemNum.put(S[i], 1);
			}
		}
		System.out.println(itemNum.size());
	}
}

Measured memory_bytes: 76284
#include<stdio.h>
int main(){
	int n,x;
	scanf("%d",&n);
	for(int i=3;i<=n;i++){
		x=i;
		if(x!=0&&x%3==0){
			printf(" %d",i);
		}else{
			while(x!=0){
				if(x%10==3){
					printf(" %d",i);
					break;
				}else{
					x/=10;
				}
			}
		}
	}
	printf("\n");
}


Measured memory_bytes: 2104
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (size_t i = 0; i < size_t(n); i++)
#define forn1(i,n) for (size_t i = 1; i <= size_t(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

const int MAX_N = 15;
int n;
vec<pii> s[MAX_N];

int main() {
    fastio();

    cin >> n;
    forn(i, n) {
        int a;
        cin >> a;
        forn(j, a) {
            int x, y;
            cin >> x >> y;
            x--;
            s[i].emplace_back(x, y);
        }
    }

    int ans = 0;
    for (int b = 0; b < (1 << n); b++) {
        bool ok = true;
        for (int i = 0; i < n; i++) {
            bool unkind = !((b >> i) & 1);
            if (unkind) continue;
            for (auto p : s[i]) {
                ok &= ((b >> p.fst) & 1) == p.snd;
            }
        }
        if (ok) {
            chmax(ans, popcnt(b));
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import heapq
def dijkstra(start,goal,graph):

    INF = 2 << 20
    node_num = len(graph) 
    visited = [False] * node_num
    costs = [INF] * node_num
    pq = []
    costs[start] = 0
    heapq.heappush(pq, [0,start])
    while not len(pq) == 0:

        cur_cost,cur_node = heapq.heappop(pq)
        if visited[cur_node]:
            continue
        visited[cur_node] = True
        costs[cur_node] = cur_cost
        for i in xrange(node_num):
            if not visited[i]:
                heapq.heappush(pq,[graph[cur_node][i] + costs[cur_node],i])
    return costs[goal]

n = input()
m = input()
INF = 2 << 20
graph = [[INF] * (n+1) for _ in xrange(n+1)]
for _ in xrange(m):
    a,b,c,d = map(int,raw_input().split(","))
    graph[a][b] = c
    graph[b][a] = d
home,shop,reward,price = map(int,raw_input().split(","))
cost = dijkstra(home,shop,graph) + dijkstra(shop,home,graph)
print reward - price - cost

Measured memory_bytes: 4508
#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; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;



ll GCD(ll p,ll q){
    ll r=p%q;
    
  while(r>0){
      p=q;
      q=r;
      r=p%q;
  }
  return q;
}

int main(){
  ll a,b,ans=1; cin>>a>>b;
  ll gcd=GCD(a,b);

  
    for(ll i=2; i*i<gcd; i++){ //素数iか合成数i
    //ただし合成数でわろうとしてもすでに合成数を構成する素因数で割れるだけ割ってある
     if(gcd% i==0){//gcdの約数である素数iを追い出す
         ans++;
         while (gcd % i == 0) gcd /= i; //iでわれるだけわる
     }//これで一つの素因数を失った
     // cout<<i<<" "<<gcd<<endl;
  }
  //求めたいのはAとBの公約数かつ素数のもの
  //AとBの公約数はGCDの約数
 //最大公約数の素因数の種類数が約数かつ素数であるようなものの数
 if (gcd != 1) ans++;
 
  cout<<ans<<endl;
}

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

int main() {
	vector<int> v(3);
  	for(auto &el : v) cin >> el;
  	sort(begin(v), end(v));
  	if(v[0] == 5 && v[1] == 5 && v[2] == 7) cout << "YES" << endl;
  	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 3612
N = int(input())
preorder = list(map(lambda s: int(s) - 1, input().split()))
inorder = list(map(lambda s: int(s) - 1, input().split()))
postorder = []


def f(n, left, right):
    num = preorder[n]
    # print(n, left, right, num)
    if right - left == 1:
        postorder.append(num)
        return
    idxin = inorder.index(num)
    n += 1
    if idxin - left >= 1:
        f(n, left, idxin)
    n += idxin - left
    if right - idxin - 1 >= 1:
        f(n, idxin+1, right)
    postorder.append(num)


f(0, 0, N)
print(' '.join(map(lambda x: str(x+1), postorder)))


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

int main()
{
  int n, m;
  cin >> n >> m;

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

  int a, b;
  vector<double> maxdata(n, 0);
  for (int i = 0; i < m; i++)
  {
    cin >> a >> b;
    maxdata[a - 1] = max(maxdata[a - 1], high[b - 1]);
    maxdata[b - 1] = max(maxdata[b - 1], high[a - 1]);
  }

  int count = 0;
  double max;
  for (int i = 0; i < n; i++)
  {
    if (high[i] > maxdata[i])
      count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 4896
//  Mayank Agarwal
//  IIIT Hyderabad



#include<bits/stdc++.h>
using namespace std;
const long long int M = 1000000007; 
#define ll long long int
#define ld double
#define pb push_back
#define mp make_pair
ll power(ll x, ll y,  ll p) 
{ 
    ll res = 1;      
    x = x % p;   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;x = (x*x) % p; 
    } return res%p; 
} 
ll modinver(ll a,ll b)
{
    return (power(a,1,M)*power(b,M-2,M))%M;
}
void SieveOfEratosthenes(int n) 
{   
    bool prime[10005]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
} 
std::vector<ll> v[100002];
ll dp[100002][3];
ll independentsetans(ll x,ll col,ll par)
{
	if(v[x].size()==1 && v[x][0]==par)
	{
		// cout<<x<<" "<<col<<'\n';
		return 1;
	}
	if(dp[x][col]!=-1)
		return dp[x][col];
	ll ans=1;
	for (int i = 0; i < v[x].size(); ++i)
	{
		if(v[x][i]==par)
			continue;
		if(col==0)
		{
			ans=ans%M*independentsetans(v[x][i],1,x)%M;
		}
		else
		{
			ans=ans%M*(independentsetans(v[x][i],0,x)+independentsetans(v[x][i],1,x))%M;
		}
	}
	dp[x][col]=ans%M;
	return ans%M;

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n;
    cin>>n;
    for (int i = 0; i < n-1; ++i)
    {
    	ll a,b;
    	cin>>a>>b;
    	v[a].pb(b);
    	v[b].pb(a);
    }
    for (int i = 0; i <=100000; ++i)
    {
    	dp[i][0]=-1;
    	dp[i][1]=-1;
    }
    // if(n==1)
    // {
    // 	cout<<"2\n";
    // 	return 0;
    // }
    ll ans=independentsetans(1,0,-1)%M;
    ans=ans+independentsetans(1,1,-1);
    cout<<ans%M<<'\n';
}


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

using namespace std;

int main() {
    std::ios::sync_with_stdio(false); 
    cin.tie(nullptr);
    
    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
    }
    vector<pair<int, int>> dp(K + 1, {0, 0});
    for (int i = 0; i <= K; ++i) {
        for (int j = 0; j < N; ++j) {
            if (i - a[j] >= 0) {
                if (dp[i - a[j]].second == 0) {
                    dp[i].first = 1;
                }
                if (dp[i - a[j]].first == 0) {
                    dp[i].second = 1;
                }
            }
        }
    }
    cout << (dp[K].first ? "First" : "Second") << "\n";

    return 0;
}

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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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 MAX_V (ll)2e6+1

struct edge {
    ll to;
    ll cost;
};

// <最短距離, 頂点の番号>
#define P pair<ll, ll>

// Vは頂点数
ll V;
vector<edge> G[MAX_V];
vector<ll> d(MAX_V, INF_LL);

void dijkstra(ll s) {
    priority_queue<P, vector<P>, greater<P> > que;
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        ll v = p.second;
        if (d[v] < p.first) continue;

        for (ll i=0; i<G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}


int main()
{
    ll N,M;
    cin >> N >> M;
    
    rep(i,M)
    {
        ll a,b;
        cin >> a >> b;
        edge e = {a, 1};
        G[b].push_back(e);
        e = {b, 1};
        G[a].push_back(e);
    }

    dijkstra(1);

    if( d[N] < 3 ) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 75232
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			char[] s = scanner.next().toCharArray();
			int count1 = 0, count2 = 0;
			for (int i = 0; i < s.length; i++) {
				char t = (0 == (i & 1)) ? '0' : '1';
				if (s[i] != t) {
					count1++;
				} else {
					count2++;
				}
			}
			System.out.println(Math.min(count1, count2));
		}
	}
}


Measured memory_bytes: 39252
/* Priyansh Agarwal*/
#include<bits/stdc++.h>
#include<algorithm>
#include<unordered_map>
#include<vector>
#include<unordered_set>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD 1000000007
#define MOD1 998244353
#define nline "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define PI 3.141592653589793238462
#define debug(x) cout << #x << " " << x <<endl;
#define set_bits __builtin_popcount
typedef long long ll;
typedef unsigned long long ull;
/*---------------------------------------------------------------------------------------------------------------------------*/
ll gcd(ll a, ll b) {if (b > a) {return gcd(b, a);} if (b == 0) {return a;} return gcd(b, a % b);}
ll expo(ll a, ll b, ll mod)
{ll res = 1; while (b > 0) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b = b >> 1;} return res;}
vector<int> sieve(int n) {int*arr = new int[n + 1](); vector<int> vect; for (int i = 2; i <= n; i++)if (arr[i] == 0) {vect.push_back(i); for (int j = 2 * i; j <= n; j += i)arr[j] = 1;} return vect;}
void extendgcd(ll a, ll b, ll*v) {if (b == 0) {v[0] = 1; v[1] = 0; v[2] = a; return ;} extendgcd(b, a % b, v); ll x = v[1]; v[1] = v[0] - v[1] * (a / b); v[0] = x; return;} //pass an arry of size 3
ll mminv(ll a, ll b) {ll arr[3]; extendgcd(a, b, arr); return arr[0];} //for non prime b
ll mminvprime(ll a, ll b) {return expo(a, b - 2, b);}
bool revsort(ll a, ll b) {return a > b;}
void swap(int &x, int &y) {int temp = x; x = y; y = temp;}
ll combination(ll n, ll r, ll m, ll* fact) {ll val1 = fact[n]; ll val2 = mminvprime(fact[r], m); ll val3 = mminvprime(fact[n - r], m); return ((val1 * val2) % m * val3) % m;}
/*--------------------------------------------------------------------------------------------------------------------------*/
int main()
{
	fastio();
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
	freopen("Error.txt", "w", stderr);
#endif
	int n, k;
	cin >> n >> k;
	ll arr[n];
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	sort(arr, arr + n);
	ll sum = 0;
	for (int i = 0; i < k; i++)
		sum += arr[i];
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>

using namespace std;

int a1, a2, a3;

void solve() {
  int ans = 0;
// int A1, A2, A3;
  
  if(a3 <= a2 && a2 <= a1) {
    ans = a1 - a2 + a2 - a3;
  }
  else if(a2 <= a3 && a3 <= a1) {
    ans = a1 - a3 + a3 - a2;
  }
  else if(a3 <= a1 && a1 <= a2) {
    ans = a2 - a1 + a1 - a3;
  }
  else if(a1 <= a3 && a3 <= a2) {
    ans = a2 - a3 + a3 - a1;
  }
  else if(a2 <= a1 && a1 <= a3) {
    ans = a3 - a1 + a1 - a2;
  }
  else {
ans = a3 - a2 + a2 - a1;
  }
  
  cout << ans << endl;
}

int main() {
  cin >> a1;
  cin >> a2;
  cin >> a3;

  solve();
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;

int main(){
    int N;
    cin>>N;
    int c[22],v[22];
    for(int i=0;i<N;i++){
        cin>>v[i];
    }
    int ans=0;
    for(int i=0;i<N;i++){
        cin>>c[i];
        if(v[i]>c[i]){
            ans+=v[i]-c[i];
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
X=[]
for i in range(m):
    x=list(map(int,input().split()))
    X.append(x)
P=list(map(int,input().split()))

ans=0

for i in range(2**n):
    B=[]
    b=format(i,'b')
    b=b.zfill(n)
    for j in range(n):
        B.append(int(b[j]))
    flag=True
    for k in range(m):
        cnt=0
        for l in range(X[k][0]):
            cnt+=B[X[k][l+1]-1]
        if cnt%2!=P[k]:
            flag=False
    if flag:
        ans+=1
        
print(ans)

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

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

typedef long long LL;

struct youbou{
  int a;
  int b;
  bool operator<(const struct youbou & right) const{
    return b<right.b;
  }
};

int main(){
  int n,m;
  cin >> n >> m;
  vector<struct youbou> a(m);
  for(int i=0;i<m;i++){
    cin >> a[i].a >> a[i].b;
  }
  sort(a.begin(),a.end());
  int ans=0;
  set<int> cut;
  set<int>::iterator itr;
  for(int i=0;i<m;i++){
    itr=cut.upper_bound(a[i].a);
    if(a[i].b<(*itr)||itr==cut.end()){
      ans++;
      cut.insert(a[i].b);
    }
  }
  // for(itr=cut.begin();itr!=cut.end();itr++) cout << (*itr) << endl;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#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 tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());
const double pi = 3.14159265358979;

int hs, he, ms, me, k;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> hs >> ms >> he >> me >> k;
	if(he < hs) he += 24;
	cout << (60 - ms + (he - hs - 1) * 60 + me - k) << "\n";
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define ms(s,x) memset(s,x,sizeof(s))
#define pb push_back
#define inf 0x3f3f3f3f
#define IOS ios::sync_with_stdio(false);cin.tie(0)
typedef long long ll;
using namespace std;

const double PI = acos(-1.0);
const double eps = 1e-8;
const int MAXN = 1e5+5;
const ll MOD = 1e9+7;

int n, pos = 0;
vector <int> pre, in, post;

void rec(int l, int r) //由先序和中序推出后序
{
    if (l >= r) return;
    int root = pre[pos++];
    int sign = find(in.begin(), in.end(), root) - in.begin();
    rec(l, sign);
    rec(sign+1, r);
    post.pb(in[sign]);
}

void postorder()
{
    rep(i, 0, n-1){
        if (i) putchar(' ');
        printf("%d", post[i]);
    }
    putchar('\n');
    return;
}

int main()
{
    int id;
    cin >> n;
    rep(i, 0, n-1){
        cin >> id;
        pre.pb(id);
    }
    rep(i, 0, n-1){
        cin >> id;
        in.pb(id);
    }
    rec(0, n);
    postorder();

    return 0;
}



Measured memory_bytes: 3228
/* */

#include <cstdio>
#include <cstring>
#include <cassert>
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
#include <map>
#include <set>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;

#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
#else
	#define errp(...)
#endif
#define dbg(x) errp(" %s = %s\n", #x, to_string(x).data())
/* ==================== */ 
const int N = 81;
const int M = N * N;
int f[N][N][M * 2];
int a[N][N], b[N][N], n, m; 

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			scanf("%d", &a[i][j]);
	
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			scanf("%d", &b[i][j]);
	
	memset(f, 0, sizeof f);
	f[0][0][M + a[0][0] - b[0][0]] = 1;
	f[0][0][M + b[0][0] - a[0][0]] = 1;
	for (int i = 1; i < n; i++) {
		for (int v = 0; v < M * 2; v++) if (f[i - 1][0][v]) {
			int t = a[i][0] - b[i][0];
			f[i][0][v + t] = f[i][0][v - t] = 1;
		}
	}
	
	for (int j = 1; j < m; j++) {
		for (int v = 0; v < M * 2; v++) if (f[0][j - 1][v]) {
			int t = a[0][j] - b[0][j];
			f[0][j][v + t] = f[0][j][v - t] = 1;
		}
	}
	
	for (int i = 1; i < n; i++) {
		for (int j = 1; j < m; j++) {
			for (int v = 0; v < M * 2; v++) if (f[i - 1][j][v] || f[i][j - 1][v]) {
				int t = a[i][j] - b[i][j];
				f[i][j][v + t] = f[i][j][v - t] = 1;
			}
		}
	}
	
	int mn = M * M;
	for (int v = 0; v < M * 2; v++) if (f[n - 1][m - 1][v])
		mn = min(mn, abs(v - M));
	printf("%d\n", mn);
}



Measured memory_bytes: 336640
#include "bits/stdc++.h"
using namespace std;
int main(){
    int n;
    string s;
    cin >> n;
    cin >> s;
    int cnt = 1;
    if(s.size() == 1){
        cout << 1 << endl;
    }
    else{
        for(int i = 0; i < s.size() - 1; i++){
            if(s.at(i) != s.at(i + 1))
            cnt++;
        }
        cout << cnt << endl;
    }
    return 0;
}


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

using namespace std;

using ll = long long;

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

    int n, ub;
    cin >> n >> ub;
    vector<pair<int, int>> p(n);
    for (int i = 0; i < n; ++i)
        cin >> p[i].first >> p[i].second;

    ll min_area = 4 * 1e9 * 1e9;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            for (int k = 0; k < n; ++k) {
                for (int t = 0; t < n; ++t) {
                    ll u = max({p[i].first, p[j].first, p[k].first, p[t].first});
                    ll b = min({p[i].first, p[j].first, p[k].first, p[t].first});
                    ll r = max({p[i].second, p[j].second, p[k].second, p[t].second});
                    ll l = min({p[i].second, p[j].second, p[k].second, p[t].second});

                    int cnt = 0;
                    for (int s = 0; s < n; ++s) {
                        if (b <= p[s].first && p[s].first <= u
                            && l <= p[s].second && p[s].second <= r) ++cnt;
                    }
                    if (ub <= cnt) min_area = min(min_area, (u - b) * (r - l));
                }
            }
        }
    }

    cout << min_area << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int b[110];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%d",b+i);
	}
	std::sort(b,b+a);
	int ret=0;
	for(int i=0;i<a;i++){
		if(i%2==0)ret+=b[a-1-i];
		else ret-=b[a-1-i];
	}
	printf("%d\n",ret);
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using edge = pair<ll, P>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
using Graph = vector<vector<ll>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N, K;
    cin >> N >> K;
    vector<ll> H(N);
    rep(i, N) cin >> H[i];
    vector<ll> dp(N + K + 1, INF);
    dp[0] = 0;
    rep(i, N) {
        rep2(k, 1, K + 1) {
            dp[i + k] = min(dp[i] + abs(H[i + k] - H[i]), dp[i + k]);
        }
    }
    cout << dp[N - 1] << endl;
}

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


Measured memory_bytes: 1792
using System;

class Pratice
{
    public static void Main()
    {
        while (true)
        {
            string[] str = Console.ReadLine().Split(' ');
            int n = int.Parse(str[0]), x = int.Parse(str[1]);
            if (n == 0 && x == 0) break;
            int cnt = 0;
            for (int i = 1; i <= n; ++i)
            {
                for (int j = i + 1; j <= n; ++j)
                {
                    int k = x - (i + j);
                    if (1 <= k && k <= n && k > j) ++cnt;
                }
            }
            Console.WriteLine(cnt);
        }
    }
}


Measured memory_bytes: 17916
# わからない
import numpy as np
k, n = map(int, input().split())
a = np.array(list(map(int, input().split())))
maxi = -1
for i in range(0, len(a)):
    if i == 0:
        tmp = max(abs((a[i] + k) - a[i - 1]), abs(a[i] - a[i + 1]))
    elif 0 < i < len(a) - 1:
        tmp = max(abs(a[i] - a[i - 1]), abs(a[i] - a[i + 1]))
    else:
        tmp = max(abs(a[i] - a[i-1]), abs(a[i] - (a[0] + k)))
    if maxi == -1:
        maxi = tmp
    else:
        maxi = max(maxi, tmp)
print(k - maxi)

Measured memory_bytes: 34184
N, M = map(int, input().split())
L = []
R = []
for _ in range(M):
  l, r = map(int, input().split())
  L.append(l)
  R.append(r)

l = max(L)
r = min(R)
print(r-l+1 if r-l+1 > 0 else 0)

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

int main()
{

    int H, W, N, temp, i=1;

    scanf("%d %d %d", &H, &W, &N);

        if(H>=W)
        {
            while(N>H*i)
            {
                i++;
            }

            printf("%d", i);

        }

        else
        {
            {
            while(N>W*i)
            {
                i++;
            }

            printf("%d", i);

        }


        }

    }




Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int N;
	cin >> N;
	int a[200000]={};
	for(int i=0;i<N-1;i++){
		int tmp;
		cin >> tmp;
		a[--tmp]++;
	}
	for(int i=0;i<N;i++){
		cout << a[i] << endl;
	}
	return 0;
}


		


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

int main(){
      string s;cin >> s;
      int n = s.length();
      int ans = INT_MAX;
      for(int i = 0;i < n - 2;i++){
            int t = stoi(s.substr(i, 3));
            if(abs(t - 753) < abs(ans - 753))ans = t;
      }
      cout << abs(ans - 753);
}

Measured memory_bytes: 256
h,w,a,b = gets.split.map(&:to_i)
k = 10 ** 9 + 7

fac = [1]
1.upto(h+w-2) do |i|
    fac << fac[i-1] * i % k
end
#p fac

s = "111011100110101100101000000101".reverse
rfac = Array.new(h+w-1,1)
t = fac[h+w-2]
s.each_char do |c|
    rfac[h+w-2] = (rfac[h+w-2] * t) % k if (c == '1')
    t = t ** 2 % k
end

(h+w-3).downto(0) do |i|
    rfac[i] = rfac[i+1] * (i+1) % k
end
#p rfac

ans = 0
1.upto(h-a) do |i|
    x = fac[b+i-2] * rfac[b-1] % k * rfac[i-1] % k
    y = fac[w-b+h-i-1] * rfac[w-b-1] % k * rfac[h-i] % k
    ans = (ans + x * y) % k
end

puts ans

Measured memory_bytes: 4988