akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

public class Hello
{
    private const int MOD_N = 1000000000 + 7;

    private sealed class Lesser : IComparer<int>
    {
        public int Compare(int a, int b)
        {
            return b - a;
        }
    }

    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var ass = new int[n];
        for (int i = 0; i < ass.Length; ++i)
        {
            ass[i] = int.Parse(Console.ReadLine());
        }

        int count = 1;
        var dec = new int[n];
        dec[0] = ass[0];
        for (int i = 1; i < dec.Length; ++i)
            dec[i] = int.MaxValue;

        var lesser = new Lesser();

        for (int i = 1; i < ass.Length; ++i)
        {
            var a = ass[i];
            var index = Array.BinarySearch(dec, 0, count, a - 1, lesser);

            if (index < 0)
                index = - (index + 1);

            dec[index] = a;
            if (index == count)
                ++count;
        }

        Console.WriteLine(count);
    }

    private static int GCD(int a, int b) => a > b ? GCD_impl(a, b) : GCD_impl(b, a);
    private static int GCD_impl(int a, int b) => b == 0 ? a : GCD_impl(b, a % b);
    private static long LCM(int a, int b) => (long)a * b / GCD(a, b);

    private static int Comb(int m, int n)
    {
        var t = m - n;
        if (n > t)
            n = t;

        long numerator = 1;
        for (int i = 0; i < n; ++i)
        {
            numerator *= m - i;
            numerator %= MOD_N;
        }
        long denominator = 1;
        for (; n != 0; --n)
        {
            denominator *= n;
            denominator %= MOD_N;
        }

        var inv_denominator = ModInv((int)denominator, MOD_N);
        var ret = (int)(numerator * inv_denominator % MOD_N);

        return ret >= 0 ? ret : ret + MOD_N;
    }

    private static int ModInv(int a, int m)
    {
        int b = m, x = 1, y = 0;
        while (b != 0)
        {
            var t = a / b;
            a -= t * b;
            Swap(ref a, ref b);
            x -= t * y;
            Swap(ref x, ref y);
        }
        x %= m;
        return x >= 0 ? x : x + m;
    }

    private static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
}


Measured memory_bytes: 15836
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,K=MI()
    
    imos2d = [[0]*(2*K+1) for _ in range(2*K+1)]
    
    def get_cord(x):
        if x<K-1:
            return [(0,x+1), (x+K+1,2*K)]
        else:
            return [(x-K+1,x+1)]

    for _ in range(N):
        x,y,c = ST().split()
        x,y = int(x), int(y)
        if c=="W":
            x+=K
        x,y = x%(2*K), y%(2*K)
        for base in [0,K]:
            for l,r in get_cord((x+base)%(2*K)):
                for u,d in get_cord((y+base)%(2*K)):
                    imos2d[l][u] += 1
                    imos2d[l][d] -= 1
                    imos2d[r][u] -= 1
                    imos2d[r][d] += 1

    for i in range(2*K):
        for j in range(2*K+1):
            imos2d[i+1][j] += imos2d[i][j]
    
    for i in range(2*K+1):
        for j in range(2*K):
            imos2d[i][j+1] += imos2d[i][j]


    ans = 0
    for a in imos2d:
        ans = max(ans,max(a))
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 105560
#include<cstdio>
 
int main(){
  int a, b, d, r;
  double f;
  scanf("%d %d", &a, &b);
  d = a / b;
  r = a % b;
  f = 1.0 * a / b;
  printf("%d %d %f\n", d, r, f);
}

Measured memory_bytes: 2748
A,B,K=map(int,input().split())
A_print=A
B_print=B
if(K>=A+B):
  A_print=0
  B_print=0
elif(K>=A):
  A_print=0
  B_print=B-(K-A)
else:
  A_print=A-K
  B_print=B
print(A_print,B_print)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,i,j,ii,jj,zx,xc,f[1000009],lef,rig;
string s,h;
long double x,y,z;
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>a;
	b=a/2+a%2;
	c=a-b;
	x=b;y=a;
	z=x/y;
	cout<<setprecision(12)<<z;
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());
		boolean judge = true;
		int voteSum = 0;
		Integer[] arrayA = new Integer[N];

		for (int i = 0; i < N; i++) {
			arrayA[i] = Integer.parseInt(sc.next());
			voteSum += arrayA[i];
		}
		sc.close();
		//降順にソートする
		Arrays.sort(arrayA, Comparator.reverseOrder());

		for (int i = 0; i < M; i++) {
			//総投票数の1/4M未満であるか
			if (4 * M * arrayA[i] < voteSum ) {
				judge = false;
				break;
			}
		}
		System.out.println(judge ? "Yes" : "No");
	}
}

Measured memory_bytes: 35616
// In god we trust
 
#include <bits/stdc++.h>
#include <chrono>
#include <algorithm>
#include <signal.h>
#include <thread>
 
#define pb push_back
#define fi first
#define se second
#define Vi vector<int>
#define Vb vector<bool>
#define Pi pair<int, int>
#define MP make_pair
#define MT make_tuple
#define INF 1000000000 
#define LINF 1000000000000000000
#define int long long
using namespace std;
using namespace std::chrono;
 
vector<Pi> g[500000];
int prohibit[500000];
int col[500000];
int k = 0;

void dfs(int v, int par = -1){
  Vi cols;
  for (int i = 0; i < g[v].size(); i++)
    if (i + 1 != prohibit[v])
      cols.pb(i + 1);

  int cnt = 0;
  for (int i = 0; i < g[v].size(); i++){
    if (g[v][i].fi != par){
      prohibit[g[v][i].fi] = cols[cnt];
      col[g[v][i].se] = cols[cnt++];
    }
  }
  for (auto i: g[v]){
    if (i.fi != par)
      dfs(i.fi, v);
  }
}
signed main(){
  ios_base::sync_with_stdio(false); 
  cin.tie(NULL);
  
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++){
    int a, b;
    cin >> a >> b;
    a--, b--;
    g[a].pb({b, i});
    g[b].pb({a, i});
  }
  for (int i = 0; i < n; i++)
    k = max(k, (int)g[i].size());; 
  
  dfs(0);
  cout << k << endl;
  for (int i = 0; i < n - 1; i++)
    cout << col[i] << endl;
}


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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;

int main() {
	string s;
	cin >>s;
	int sol = 1e9;
	for (char c='a' ; c<='z' ; c++) {
		int cnt = 0;
		for (int i=0 ; i<s.size() ; i++) {
			int minn = s.size()-i;
			for (int j=i ; j<s.size() ; j++) {
				if  (s[j] == c) {
					minn = j-i;
					break;
				}
			}
			cnt = max(cnt, minn);
		}
		sol = min(sol, cnt);
	}
	cout <<sol<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
const int sz=18;

int n;
ll a[sz][sz];

void add_self(ll& a,ll b){
	a+=b;
}
void max_self(ll& a,ll b){
	a=max(a,b);
}

int main()
{  
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>n;
    for(int i=0;i<n;i++){
    	for(int j=0;j<n;j++){
    		cin>>a[i][j];
		}
	}
	
	vector<ll> pre(1<<n);
	
    for(int mask=0;mask<(1<<n);mask++){
    	for(int i=0;i<n;i++){
    		if(mask&(1<<i)){
    			for(int j=i+1;j<n;j++){
    				if(mask&(1<<j)){
    					add_self(pre[mask],a[i][j]);
					}
				}
			}
		}
    }
	
	
	vector<ll> dp(1<<n);
	for(int mask=0;mask<(1<<n);mask++){
		vector<ll> not_taken;
		for(int i=0;i<n;i++){
			if(!(mask&(1<<i))){
				not_taken.push_back(i);
			}
		}
		int len=not_taken.size();
		for(int msk=0;msk<(1<<len);msk++){
			int group=0;
			for(int j=0;j<len;j++){
				if(msk&(1<<j)){
					group=group|(1<<not_taken[j]);
				}
			}
			max_self(dp[mask|group],dp[mask]+pre[group]);
		}
	}

   cout<<dp[(1<<n)-1]<<"\n";
    
}



Measured memory_bytes: 1280
#include<stdio.h>
int main()
{
    int a,b,c,d,r,x,y,z;

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

    x = a-c;
    y = b-d;

    z = x*y;

    printf("%d",z);

    return 0;
}


Measured memory_bytes: 1692
#include <bits/stdc++.h>
using namespace std;
const int MAXN=200;
char ch[MAXN][MAXN];
int r[MAXN][MAXN],c[MAXN][MAXN];
int f[MAXN][MAXN][MAXN],g[MAXN][MAXN][MAXN];
int c1[MAXN][MAXN][MAXN],c2[MAXN][MAXN][MAXN];
int n,m,ans;
inline void init()
{
	for(register int i=1;i<=n;i++)
		for(register int j=m;j;j--)
			if(ch[i][j]==ch[i][j+1]) r[i][j]=r[i][j+1]+1;
			else r[i][j]=1;
	for(register int i=1;i<=m;i++)
		for(register int j=n;j;j--)
			if(ch[j][i]==ch[j+1][i]) c[j][i]=c[j+1][i]+1;
			else c[j][i]=1;
	for(register int i=1;i<=n;i++)
		for(register int j=1;j<=m;j++)
		{
			f[i][j][j]=c[i][j];
			for(register int k=j+1;k<=m;k++)
				if(ch[i][k]==ch[i][k-1]) f[i][j][k]=min(f[i][j][k-1],c[i][k]);
				else f[i][j][k]=0;
		}
	for(register int i=1;i<=m;i++)
		for(register int j=1;j<=n;j++)
		{
			g[i][j][j]=r[j][i];
			for(register int k=j+1;k<=n;k++)
				if(ch[k][i]==ch[k-1][i]) g[i][j][k]=min(g[i][j][k-1],r[k][i]);
				else g[i][j][k]=0;
		}
	return;
}
inline void work()
{
	for(register int i=1;i<=n;i++)
		for(register int j=1;j<=m;j++)
			for(register int k=j;k<=m;k++)
			{
				f[i][j][k]=f[i][j][k]+f[i+f[i][j][k]][j][k];
				if(f[i][j][k]) c1[j][i][i+f[i][j][k]-1]=max(c1[j][i][i+f[i][j][k]-1],k-j+1);
			}
	for(register int i=1;i<=m;i++)
		for(register int j=1;j<=n;j++)
			for(register int k=j;k<=n;k++)
			{
				g[i][j][k]=g[i][j][k]+g[i+g[i][j][k]][j][k];
				if(g[i][j][k]) c2[j][i][i+g[i][j][k]-1]=max(c2[j][i][i+g[i][j][k]-1],k-j+1);
			}
	for(register int i=1;i<=n;i++)
		for(register int j=1;j<=m;j++)
			for(register int k=m;k>=j;k--) f[i][j][k]=max({f[i][j][k],f[i][j][k+1],c2[i][j][k]});
	for(register int i=1;i<=m;i++)
		for(register int j=1;j<=n;j++)
			for(register int k=n;k>=j;k--) g[i][j][k]=max({g[i][j][k],g[i][j][k+1],c1[i][j][k]});
	return;
}
int main()
{
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>n>>m;
	for(register int i=1;i<=n;i++) cin>>(ch[i]+1);
	init();
	while(f[1][1][m]<n) ans++,work();
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 123264
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
const int MAX=1e+5;
vector<int> g[MAX];
vector<int> check(MAX,-1);//1:black,0:white
int u;
bool dfs(int v){//O(E)
	rep(i,0,g[v].size()){
        u=g[v][i];
		if(check[u]!=-1){
			if(check[u]==check[v]) return false;
		}else{
			check[u]=check[v]^1;
			if(!dfs(u)) return false;
		}
	}return true;
}
int main(){
	long N,M;cin>>N>>M;
	int a,b;
	rep(i,0,M){
		cin>>a>>b;a--;b--;
		g[a].push_back(b);
		g[b].push_back(a);
    }
    check[0]=0;
    if(dfs(0)){
        long count=0;
        rep(i,0,N){
            if(check[i]) count++;
        }cout<<count*(N-count)-M<<endl;
    }else{
        cout<<N*(N-1)/2-M<<endl;
    }
}

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

#define FOR(i, l, r) for(ll i = l; i < r; i++)
#define rep(i, N) FOR(i, 0, N)

#define MOD 1000000007
#define INF 1000000000

using ll = long long int;
using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main() {
    int A,V,B,W,T; cin >> A>>V>>B>>W>>T;

    bool ans = false;
    if(V <= W) {

    }else{
        double t = (double)abs(A-B)/(V-W);
        if(t <= T) ans = true;
    }
    
    cout << (ans?"YES":"NO") << endl;
    return 0;
}


Measured memory_bytes: 3632
input = gets.chomp.split
a = input[0].to_i
b = input[1].to_i
c = input[2].to_i
d = input[3].to_i

if (a - c).abs <= d || ((a - b).abs <= d && (b - c).abs <= d)
    puts "Yes"
else
    puts "No"
end

Measured memory_bytes: 1788
from collections import deque
import sys

N = int(input())

x = list(map(int,input().split()))

mustuse = deque([])
ableuse = deque([])

xlis = []
ans = [None] * (N ** 2)

for i in range(N):
    ans[x[i]-1] = i+1
    xlis.append([x[i],i+1])

xlis.sort()

for i in range(N):

    for j in range(xlis[i][1]-1):
        mustuse.append(xlis[i][1])

#print (ans)
#print (mustuse)

for i in range(N**2):

    if ans[i] != None:

        if len(mustuse) > 0 and mustuse[0] == ans[i]:
            print ("No")
            sys.exit()
        for j in range(N-ans[i]):
            ableuse.append(ans[i])

    else:

        if len(mustuse) > 0:
            ans[i] = mustuse.popleft()

        elif len(ableuse) > 0:
            ans[i] = ableuse.popleft()

        else:
            print ("No")
            sys.exit()

print ("Yes")
print (" ".join(map(str,ans)))



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

using namespace std;
#define  ll long long
#define ld long double
#define f first
#define s second
const int N = 2e6+5;

ll fact[N] , inv[N] , pw[N] , pw2[N] , mod=1e9+7 , k;
string s;

ll fp(ll base, ll exp)
{
    if (exp == 0)
        return 1;
    ll ans = fp(base, exp / 2);
    ans = (ans * ans) % mod;
    if (exp % 2 != 0)
        ans = (ans * (base % mod)) % mod;
    return ans;
}

void calcFacAndInv(ll n)
{
    pw[0]=1 , pw2[0]=1;
    fact[0] = inv[0] = 1;
    for (ll i = 1; i <= n; i++)
    {
        pw[i] = (25*pw[i-1])%mod;
        pw2[i] = (26*pw2[i-1])%mod;
        fact[i] = (i * fact[i - 1]) % mod;
        inv[i] = fp(fact[i], mod - 2);
    }
}

ll ncr(ll n, ll r)
{
    return ((fact[n] * inv[r]) % mod * inv[n - r]) % mod;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    calcFacAndInv(N-1);

    cin >> k >> s;

    ll ans = 0 , sz=s.size() , n = sz+k;

    for(int i=sz; i<=n; i++)
    {
        ll tmp = (ncr(i-1 , sz-1)*pw[i-sz])%mod;
        tmp = (tmp*pw2[n-i])%mod;
        ans = (ans + tmp)%mod;
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 66720
#include<stdio.h>
int main(void){
long a,b,c,k;
scanf("%ld %ld %ld %ld",&a,&b,&c,&k);
  if(k>a+b) printf("%ld",2*a-k+b);
  else if(k>a) printf("%ld",a);
  else printf("%ld",k);
return 0;
}


Measured memory_bytes: 1680
n,k=list(map(int,input().split(" ")))
l=list(map(int,input().split(" ")))
f=[0]*n
f[1]=abs(l[1]-l[0])

for i in range(2,n):

	x1=f[i-1]+abs(l[i-1]-l[i])
	z=min(k,i)
	for j in range(z):
		# print(i,i-j-1)
		x1=min(x1,(f[i-j-1]+abs(l[i]-l[i-j-1])))

	# x2=f[i-2]+abs(l[i-2]-l[i])
	f[i]=x1
print(f[-1])

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

typedef long long ll;
#define REP(i, n, m) for(int i = n; i < m; i++)
#define REPR(i, n, m) for(int i = n; i >= m; i--)
#define LREP(i, n, m) for(ll i = n; i < m; i++)
#define LREPR(i, n, m) for(ll i = n; i >= m; i--)

#define P pair<int, int >


const ll INF = 1e9 + 1;
const ll MOD = 1e9 + 7;



//---functions---//
int gcd(int a, int b){
    if(a < b) swap(a, b);
    return b?gcd(b, a%b):a;
}

int s2i(string num){stringstream ss; ss << num << flush; int n; ss >> n; return n;}
string i2s(int n){stringstream ss; ss << n << flush; return ss.str();}

bool firstCompare(const P& firstElof, const P& secondElof){
    return firstElof.first < secondElof.first;
}
bool secondCompare(const P& firstElof, const P& secondElof){
    return firstElof.second < secondElof.second;
}
//---------------//

ll N, K;
int main(){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> K;
    vector<vector<ll>> comb(N + 1, vector<ll>(N + 1));
    comb[0][0] = 1;
    LREP(i, 1, N + 1){
        LREP(j, 0, N + 1){
            if(j == 0) comb[i][j] = 1;
            else comb[i][j] = comb[i-1][j-1] + comb[i-1][j];
            comb[i][j] %= MOD;
        }
    }
    LREP(i, 1, K + 1){
        cout << comb[K-1][i-1] * comb[N-K+1][i] % MOD << '\n';
    }

}


Measured memory_bytes: 31616
using System;
using System.Collections.Generic;
using System.Linq;

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        int x1 = cin.nextInt();
        int y1 = cin.nextInt();
        int x2 = cin.nextInt();
        int y2 = cin.nextInt();

        int vx = x2 - x1;
        int vy = y2 - y1;
        int x3 = x2 - vy;
        int y3 = y2 + vx;
        int x4 = x3 - vx;
        int y4 = y3 - vy;
        Console.WriteLine("{0} {1} {2} {3}", x3, y3, x4, y4);
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

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

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}




Measured memory_bytes: 13268
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }
    
    static final char[] alphabet = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();
        int X = (int)Math.ceil(N/1.08);
        if((int)Math.floor(X*1.08) == N)
            os.println(X);
        else
            os.println(":(");
    }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
vector<string> split(string s, char p){vector<string>v;stringstream m(s);string b;while(getline(m,b,p))v.push_back(b);return v;}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;

int main(){
    ll N; cin >> N;
    vector<ll> L(N);
    REP(n, N) cin >> L[n];

    ll ans = 0;
    REP(i, N-2) {
        FOR(j, i+1, N-1) {
            FOR(k, j+1, N) {
                if (L[i]<L[j]+L[k] && L[j]<L[i]+L[k] && L[k]<L[i]+L[j]) {
                    if (L[i]!=L[j] && L[j]!=L[k] && L[i]!=L[k]) {
                        ans++;
                    }
                }
            }
        }
    }

    cout << ans << "\n";
}


Measured memory_bytes: 3648
import itertools

A, B, C, D = input()  # 文字列はこの書き方が出来る
op = ('+', '-')
ans_str = ''
for op1, op2, op3 in itertools.product(op, repeat=3):  # 8通り
    ans_str = A + op1 + B + op2 + C + op3 + D
    if eval(ans_str) == 7:
        ans_str += '=7'
        break
print(ans_str)


Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

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

using namespace std;
using namespace __gnu_pbds;

#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1)
	{
		cerr << name << " = " << arg1 << endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args)
	{
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " = " << arg1 << " || ";
		__f(comma+1, args...);
	}
#else
#define debug(...)
#endif

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ; ";
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
	return os << "[ " << p.first << ", " << p.second << "]" ;
}

#define FAST_IO std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define pb push_back
#define mp make_pair
#define ld long double
#define sz(a) (ll)(a).size()
#define endl "\n"

// priority_queue<ll, vector<ll>, less<ll>>pq;     // Max Heap
// priority_queue<ll, vector<ll>, greater<ll>>pq;  // Min Heap

typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//K-th smallest
//cout << k << "kth (1 based indexing) smallest: " << *A.find_by_order(k - 1) << endl;
//NO OF ELEMENTS < X
//cout << "No of elements less than " << X << " are " << A.order_of_key(X) << endl;

int main()
{
	FAST_IO;

 	ll x, y, z;
 	cin >> x >> y >> z;
 	cout << z << " " << x << " " << y << endl;   
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;

#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 FORR(i, m, n) for (int i = m; i >= n; i--)

ll const INF = 1000000000000000000;
int const I_MAX = 2147483647;
ll const MOD = 1e9 + 7;
int const POW_MAX = 1e5;

// nCr
ll po[POW_MAX + 2];
ll mod_pow(ll x, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % MOD;
    x = x * x % MOD;
    n >>= 1;
  }
  return res;
}
ll mod_inv (ll x) {
  return mod_pow(x, MOD - 2) % MOD;
}
ll comb(int n, int r) {
  return (((po[n] * mod_inv(po[r])) % MOD) * mod_inv(po[n - r])) % MOD;
}
// greatest common divisor
ll gcd(ll a, ll b) {
  while (a % b != 0) {
    ll tmp = a;
    a = b;
    b = tmp % b;
  }
  return b;
}

int const N_MAX = 1e4;

int N;
string ss[N_MAX + 1];

int main() {
  scanf("%d", &N);
  rep(i, N) {
    cin >> ss[i];
  }

  int count = 0;
  int a_count = 0;
  int b_count = 0;
  int ab_count = 0;
  rep(i, N) {
    string s = ss[i];
    char f = s[0];
    char l = s[s.length() - 1];

    if (f == 'B' && l == 'A') {
      ab_count++;
    } else {
      if (f == 'B') b_count++;
      if (l == 'A') a_count++;
    }

    rep(j, s.length()) {
      char c = s[j];
      if (c == 'B' && j > 0 && s[j - 1] == 'A') count++;
    }
  }

  if (ab_count > 0) {
    int tmp_count = ab_count;
    if (a_count > 0) {
      tmp_count++;
      a_count--;
    }
    if (b_count > 0) {
      tmp_count++;
      b_count--;
    }
    count += tmp_count - 1;
  }
  count += min(a_count, b_count);

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


Measured memory_bytes: 768
area a b = a*b
circumference a b = 2 * (a+b)

main = do
    ls <- getLine
    let [a,b] = map read . words $ ls :: [Int]
        menseki = area a b
        syuu = circumference a b
    putStrLn $ (show menseki) ++ " " ++ (show syuu)
        


Measured memory_bytes: 3604
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
count=0
for i,b in enumerate(B):
    attack=min(b,A[i]+A[i+1])
    count+=attack
    A[i+1]-=max(0,attack-A[i])
print(count)

Measured memory_bytes: 19116
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

#include <vector>
#include <stdio.h>
#include <iostream>
#include <unordered_set>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
#include <random>
#include <time.h>
#include <cassert>


#define prev askdnsajd
#define rank asasdmdnasd
#define next lsjndajbs
#define hash asmdklansd
#define index asdklnas
#define right sld
#define left sldl

using namespace std;

typedef long long ll;
typedef long double dbl;

template<class T>
void print(vector<T> s){
    for (T x : s)
        cout << x << " ";
    cout << endl;
}

mt19937 mrand(random_device{} ());
int rnd() {
    return mrand();
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(77);
    string s, t;
    cin >> s >> t;
    vector<vector<int>> pos(26);
    for (int i = 0; i < s.size(); i++)
        pos[int(s[i] - 'a')].push_back(i);
    int cur = 0;
    ll answer = 0;
    for (int i = 0; i < t.size(); i++){
        int c = int(t[i] - 'a');
        if (pos[c].size() == 0){
            cout << -1 << endl;
            return 0;
        }
        int next = lower_bound(pos[c].begin(), pos[c].end(), cur) - pos[c].begin();
        if (next == pos[c].size()){
            answer += s.size() - cur + pos[c][0] + 1;
            cur = pos[c][0] + 1;
        }
        else{
            answer += pos[c][next] - cur + 1;
            cur = pos[c][next] + 1;
        }
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 1228
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <utility>

using namespace std;


int main(void){
    int n,a,b;
    cin >> n >> a >> b;
    int cost = n*a;
    if(cost < b){
        cout << cost << endl;
    }else{
        cout << b << endl;
    }
    
    return 0;

}

Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#define N_MAX 100
#define M_MAX 100
#define L_MAX 100

long v1[N_MAX][M_MAX];
long v2[M_MAX][L_MAX];

int main()
{
	int n, m,l;
	scanf("%d %d %d", &n, &m, &l);

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			scanf("%d", &v1[i][j]);
		}
	}
	
	for (int i = 0; i < m; i++)
	{
		for (int j = 0; j < l; j++)
		{
			scanf("%d", &v2[i][j]);
		}
	}
	
	for(int i=0;i<n;i++)
	{
	    for (int j=0;j<l;j++)
	    {
	        long v=0;
	        for(int k=0;k<m;k++)
	        {
	            v+=v1[i][k]*v2[k][j];
	        }
	        std::cout<<v;
	        if(j!=l-1)std::cout<<" ";
	    }
	    std::cout<<std::endl;
	}
}


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

int main ()
{
  int a, b, c, x, ans;
  cin >> a >> b >> c >> x;
  ans = 0;
  for(int i = 0; i<=a; i++){
      for(int j = 0; j<= b; j++){
          for(int k = 0; k <=c; k++){
              if(i*500 + j*100 + k*50 == x) ans++;
          }
      }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		int A = sc.nextInt();
		int B = sc.nextInt();

		int ans = -1;
		for (int i=0; i<10; i++) {
			int x = B*10 + i;
			if ((int)(x * 0.08) == A) {
				ans = x;
				break;
			}
		}
		
		System.out.println(ans);
	}
}

Measured memory_bytes: 23636
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

n = int(readline())

p = [list(map(int,readline().split())) for i in range(n)]

for i in range(n):
    x = p[i][0]
    y = p[i][1]
    p[i][0] = x-y
    p[i][1] = x+y

dmax0 = -INF
dmin0 = INF
dmax1 = -INF
dmin1 = INF

for (x,y) in p:
    dmax0 = max(dmax0, x)
    dmin0 = min(dmin0, x)
    dmax1 = max(dmax1, y)
    dmin1 = min(dmin1, y)

print(max(dmax1-dmin1, dmax0-dmin0))



Measured memory_bytes: 104676
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

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

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

const int N = 5e5 + 10;
char s[N];

int main() {
  scanf("%s", s);
  int n = strlen(s) + 1;
  vector<int> L(n), R(n);
  R[n - 1] = 0;
  for (int i = n - 2; i >= 0; --i) {
    R[i] = s[i] == '>' ? R[i + 1] + 1 : 0;
  }
  L[0] = 0;
  for (int i = 1; i < n; ++i) {
    L[i] = s[i - 1] == '<' ? L[i - 1] + 1 : 0;
  }
  int64 ret = 0;
  for (int i = 0; i < n; ++i) {
    // trace(i, L[i], R[i]);
    ret += max(L[i], R[i]);
  }
  printf("%lld\n", ret);
  return 0;
}


Measured memory_bytes: 4608
n,m = map(int, input().split())
lst = [None]*m
for i in range(m):
    s,c = map(int, input().split())
    lst[i] = [s,c]

pass_lst =[]
ans = "no"
if n==1:
    for i in range(0,10):
        cnt = 0
        for j in range(m):
            num = str(i)
            if int(num[lst[j][0]-1]) == lst[j][1]:
                cnt += 1
            if cnt  == m:
                ans = "ok"
                pass_lst.append(i)
                break
elif n==2:  
    for i in range(10,100):
        cnt = 0
        for j in range(m):
            num = str(i)
            if int(num[lst[j][0]-1]) == lst[j][1]:
                cnt += 1
            if cnt  == m:
                ans = "ok"
                pass_lst.append(i)
                break
elif n==3:  
    for i in range(100,1000):
        cnt = 0
        for j in range(m):
            num = str(i)
            if int(num[lst[j][0]-1]) == lst[j][1]:
                cnt += 1
            if cnt  == m:
                ans = "ok"
                pass_lst.append(i)
                #print(cnt)
                break       

if ans == "no" and m != 0:
    print("-1")
elif  m == 0 :
    if n == 1:
        print(0)
    elif n == 2:
        print(10)
    elif n == 3:
        print(100)
elif  ans == "ok" and m != 0: 
    print(min(pass_lst))

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

int main(void) {
  int n,m;
  cin>>n>>m;
  int like[m];
  for(int i=0;i<m;i++) like[i]=0;
  
  for(int i=0;i<n;i++){
    int k;
    cin>>k;
    int a;
    for(int j=0;j<k;j++){
      cin>>a;
      like[a-1]++;
    }
  }
  
  int ans=0;
  for(int i=0;i<m;i++){
    if(like[i]==n) ans++;
  }
  cout<<ans<<"\n";
  return 0;
}


Measured memory_bytes: 256
N = int(input())
l = []

for _ in range(N):
    a, b, c = map(int, input().split())
    l.append([a,b,c])

dp = [[0]*3 for _ in range(N+1)]

for i in range(N):
    for j in range(3):
        for k in range(3):
            if j != k:
                dp[i+1][k] = max(dp[i+1][k], dp[i][j] + l[i][k])
ans = 0
for i in range(3):
    ans = max(ans, dp[N][i])
print(ans)

Measured memory_bytes: 73176
n = int(input())

t = []
c = 'abcdefghij'

def f(s, d, m):
  if d == 0:
    t.append(s)
    return
  
  for k in range(m+1):
    f(s*10 + k, d-1, m+1 if k==m else m)
    
f(0, n, 0)

for i in t:
  x = []
  for j in range(n):
    x.append(c[i // 10**(n-j-1) % 10])
  print(''.join(x))

Measured memory_bytes: 8960
N, Q = input().split()
N = int(N)
Q = int(Q)
S=str(input())

im = [0 for i in range(N)]
AA = False
for i,v in enumerate(S):
  if AA:
    if v=="C": im[i] += 1
    elif v=="A": continue
    AA = False
  else:
    if v=="A": AA=True

for i in range(1,N):
  im[i] = im[i-1]+im[i]

for i in range(Q):
  l, r = input().split()
  l = int(l)-1
  r = int(r)-1
  print(im[r]-im[l])

Measured memory_bytes: 7692
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
	//ios::sync_with_stdio(false);
	//cin.tie(nullptr);
	const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll n;
	cin >> n;
	vll a(n);
	for (ll i = 0; i < n; i++) cin >> a[i];

	vll dp(n, 0);
	map<ll, ll> mp;
	if (a[0] == 0) {
		dp[0] = 3;
		mp[0] = 2;
		mp[1] = 1;
	}

	for (ll i = 1; i < n; i++) {
		dp[i] = dp[i - 1] * mp[a[i]] % p;
		mp[a[i]]--;
		mp[a[i] + 1]++;
	}
	cout << dp[n - 1] << endl;
}


Measured memory_bytes: 8064
import math
a,b,x=[int(x) for x in input().rstrip().split()]
S=x/a
if S==a*b:
  print(0)
else:
  if S<=(a*b)/2:
    a1=S/b
    tan=(b**2)/(2*S)
    print(math.degrees(math.atan(tan)))
  else:
    tan=(2*a*b-2*S)/a**2
    print(math.degrees(math.atan(tan)))




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

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define range(x,min,max) ((min) <= (x) && (x) <= (max))
#define xyrange(x, minX, maxX, y, minY, maxY) (range(x, minX, maxX) && range(y, minY, maxY))

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef pair<int,int> PII;
typedef vector<PII> VPII;


const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};
const int INF = INT_MAX / 2;

string t1, t2, s;
int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	cin >> t1 >> s >> t2;
	cout << 'A' << s[0] << 'C' << endl;
	return 0;
}



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

int main(){
    string s,t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    if(s<t){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

int n;
bool ok;
std::string tt[4] = {"dream", "dreamer", "erase", "eraser"};
int len[4] = {5, 7, 5, 6};
std::string s;

void dfs(int x, int i) {
    if (ok)
        return;
    if (s.find(tt[i], x) != x) {
        return;
    } else {
        if (x + len[i] == n) {
            ok = true;
            return;
        } else
            for (int j = 0; j < 4; j++)
                dfs(x + len[i], j);
    }
}

int main() {
    std::cin >> s;
    std::string t;
    n = s.length();
    ok = false;
    for (int i = 0; i < 4; i++)
        dfs(0, i);
    if (ok)
        std::cout << "YES" << std::endl;
    else
        std::cout << "NO" << std::endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std; 
const int maxn = 5000500;
const int mod = 1e9 + 7;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, k;
    cin >> n >> k;
    if(k == 1) return cout << 0 << '\n', 0;
    cout << n - k << '\n';
    return 0;

}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
class Program
{
    static void Main()
    {
        //入力
        //int[] input = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();
        //string input= Console.ReadLine();
        int input= int.Parse(Console.ReadLine());
        int input2= int.Parse(Console.ReadLine());
        Console.WriteLine(input*input-input2);


        /*
        //処理速度計測
        var sw = new System.Diagnostics.Stopwatch();
        sw.Start();
        //解法
 
        //処理速度表示
        sw.Stop();
        TimeSpan ts = sw.Elapsed;
        Console.WriteLine((int)(Math.Floor((ts).TotalMilliseconds))+"ms");
        */
        Console.ReadLine();

    }
}

Measured memory_bytes: 11092
module Main where

import Data.List
import Control.Monad
import Debug.Trace
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as = let
    (fo, la) = span f as
    las = case la of
        [] -> []
        xs -> split f $ tail xs
    in
        case fo of
            [] -> las
            xs -> xs : las
    
solve :: Int -> Float
solve n = case even n of
        True -> 0.5
        False -> fromIntegral ((n + 1) `div` 2) / (fromIntegral n)

main = do
    n <- readInt
    print $ solve n

Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  string s;
  cin>>s;
  if(s[0]!=s[1] && s[1]!=s[2] && s[0]!=s[2]) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}



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


int main(){
    int n; cin>>n;
    vector<int> X(n);
    int ans(0);
    for(int i=0;i<n;i++){
        cin >> X[i];
        ans += X[i];
    }
    sort(X.begin(),X.end());
    cout << (X.back()-X[0]+1)/2 << endl;
}


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

using namespace std;

int main(){
  #ifdef HOME
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
  #endif
  string a, b, c;
  cin >> a >> b >> c;
  if (a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0]) puts("YES");
  else puts("NO");

  #ifdef HOME
    fprintf(stderr, "Time:- %.3f\n", (double) clock() / CLOCKS_PER_SEC);
    fflush(stderr);
  #endif
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> PII;
typedef pair<ll,ll> Pll;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef pair<ll,ll>P;
#define N  1000000+10
#define M  4000000+10
#define INF 1e9
#define fi first
#define se second
#define MP make_pair
#define pb push_back
#define pi acos(-1)
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(i,a,b) for(int i=(int)a;i<=(int)b;i++)
#define per(i,a,b) for(int i=(int)a;i>=(int)b;i--)
#define lowbit(x) x&(-x)
#define Rand (rand()*(1<<16)+rand())
#define id(x) ((x)<=B?(x):m-n/(x)+1)
#define ls p<<1
#define rs p<<1|1
#define fors(i) for(auto i:e[x]) if(i!=p)

const int MOD=1e9+7,inv2=(MOD+1)/2;

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



int read()
{
  int v=0,f=1;
  char c=getchar();
  while(c<48||57<c)
  {
    if(c=='-') f=-1;
    c=getchar();
  }
  while(48<=c&&c<=57) v=(v<<3)+v+v+c-48,c=getchar();
  return v*f;
}

ll readll()
{
  ll v=0,f=1;
  char c=getchar();
  while(c<48||57<c)
  {
    if(c=='-') f=-1;
    c=getchar();
  }
  while(48<=c&&c<=57) v=(v<<3)+v+v+c-48,c=getchar();
  return v*f;
}

int main()
{
   int n=read();
string a,b;
cin>>a;
cin>>b;
rep(i,0,n-1)
{
    printf("%c",a[i]);
    printf("%c",b[i]);

}


  return 0;
}


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

int main(){
    int n = 0;
    cin >> n;

    vector<uint32_t> a(n);
    uint32_t min = UINT32_MAX, max = 0;
    for(auto i = 0; i < n; i++) {
        cin >> a[i];
        if(min > a[i]) min = a[i];
        if(max < a[i]) max = a[i];
    }

    cout << (max - min) << endl;

    return 0;
}

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

int main() {
	 int h,w;
	 cin>>h>>w;
	 
	 pair<int,int> arr [h][w];
	 for (int i=0; i <h; i ++){
	     for (int j=0; j <w; j ++){
	         pair<int,int> p;
	         p.first = 100000;
	         char c;
	         cin>>c;
	         if(c=='#')p.second = 1;
	         else p.second = 0;
	         
	         arr[i][j] = p;
	       //  cout<<p.first<<" "<<p.second<<" | ";
	     }
	   //  cout<<endl;
	 }
	 if(arr[0][0].second==0){
	     arr[0][0].first=0;
	 }
	 else {
	     arr[0][0].first=1;
	 }
	 for(int i=0; i <h; i ++){
	     for(int j=0; j <w; j ++){
	         if(arr[i][j].second == 1){
	             if(i>0){
	                 if(arr[i-1][j].second==1){
	                    arr[i][j].first = min(arr[i][j].first,arr[i-1][j].first); 
	                 }
	                 else {
	                    arr[i][j].first = min(arr[i][j].first,arr[i-1][j].first + 1);
	                 }
	             }
	             if(j>0){
	                 if(arr[i][j-1].second==1){
	                    arr[i][j].first = min(arr[i][j].first,arr[i][j-1].first); 
	                 }
	                 else {
	                    arr[i][j].first = min(arr[i][j].first,arr[i][j-1].first + 1);
	                 }
	             }
	         }
	         else {
	             if(i>0){
	                 if(arr[i-1][j].second==0){
	                    arr[i][j].first = min(arr[i][j].first,arr[i-1][j].first); 
	                 }
	                 else {
	                    arr[i][j].first = min(arr[i][j].first,arr[i-1][j].first);
	                 }
	             }
	             if(j>0){
	                 if(arr[i][j-1].second==0){
	                    arr[i][j].first = min(arr[i][j].first,arr[i][j-1].first); 
	                 }
	                 else {
	                    arr[i][j].first = min(arr[i][j].first,arr[i][j-1].first);
	                 }
	             }
	         }
	     }
	 }
	 
// 	 for(int i=0; i <h; i ++){
// 	     for(int j=0; j <w; j ++){
// 	         cout<<arr[i][j].first<<" ";
// 	     }
// 	     cout<<endl;
// 	 }
	 
	 cout<<arr[h-1][w-1].first;
	 
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoder.Tool;
namespace AtCoder
{
    class AC
    {
        const int MOD = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;
        const double EPS = 1e-8;
        static readonly int[] dx = { 0, 1, 0, -1 };
        static readonly int[] dy = { 1, 0, -1, 0 };
        //static List<List<int>> G = new List<List<int>>();
        //static List<List<Edge>>G = new List<List<Edge>>();
        //static List<Edge> E = new List<Edge>();

        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();

            var p = cin.ReadSplitLong();
            long a = p[0];
            long b = p[1];
            long k = p[2];
            if (a >= k) { Console.WriteLine($"{a - k} {b}"); }
            else { Console.WriteLine($"0 {Max(0, b - (k - a))}"); }

            //Console.Out.Flush();
        }
        
        struct Edge
        {
            public int from;

            public int to;
            public long dist;
            public Edge(int t, long c)
            {
                from = -1;
                to = t;
                dist = c;
            }
            public Edge(int f, int t, long c)
            {
                from = f;
                to = t;
                dist = c;
            }

        }
    }
    
    public class Scanner
    {
        public int[] ReadSplitInt()
        {
            return ConvertAll(Console.ReadLine().Split(), int.Parse);
        }
        public long[] ReadSplitLong()
        {
            return ConvertAll(Console.ReadLine().Split(), long.Parse);
        }
        public double[] ReadSplit_Double()
        {
            return ConvertAll(Console.ReadLine().Split(), double.Parse);
        }
    }
    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for (var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }
        static public void Swap<T>(ref T a, ref T b)
        {
            T keep = a;
            a = b;
            b = keep;
        }

        static public void Display<T>(T[,] array2d, int n, int m)
        {
            for (var i = 0; i < n; i++)
            {
                for (var j = 0; j < m; j++)
                {
                    Console.Write($"{array2d[i, j]} ");
                }
                Console.WriteLine();
            }
        }

        static public long LPow(int a, int b)
        {
            return (long)Pow(a, b);
        }
    }
}


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

int main(){
  long N,K;cin>>N>>K;
  vector<long> A(N),F(N);
  for(int i=0;i<N;i++) cin>>A.at(i);
  for(int i=0;i<N;i++) cin>>F.at(i);
  sort(A.begin(),A.end());
  sort(F.begin(),F.end());
  reverse(F.begin(),F.end());
  long left=0;
  long right=1000000000001;
  while(left<right){
    long count=0;
    long X=(left+right)/2;
    for(int i=0;i<N;i++){
      if(A.at(i)*F.at(i)>X) count+=A.at(i)-X/F.at(i);
    }
    if(count>K) left=X+1;
    else right=X;
  }
  cout<<right<<endl;
}


Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
     
    int main(){
      int N;
      int64_t D;
      cin >> N >> D;
      int64_t X, Y;
      int c = 0;
      for (int i=0; i<N; i++){
        cin >> X >> Y;
        if (X*X + Y*Y <= D*D){
          c++;
        }
      }
      cout << c << endl;
    }

Measured memory_bytes: 3632