akhauriyash/Code-Regression huggingface dataset:
from typing import List

N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))


def solve(N: int, K: int, P: List[int], C: List[int]):
    ans = max(C)
    visited = [False] * N
    for i in range(N):
        if visited[i]:
            continue

        cycle = []
        to = i
        while not visited[to]:
            visited[to] = True
            cycle.append(C[to])
            to = P[to] - 1

        ans = max(ans, partial_solve(len(cycle), K, cycle))

    return ans


def partial_solve(N: int, K: int, A: List[int]):
    ret = max(A)
    B = [0] * (3 * N + 1)
    for i in range(1, 3 * N + 1):
        B[i] = B[i - 1] + A[(i - 1) % N]

    if N > K:
        for l in range(1, N + 1):
            for r in range(l, l + K):
                ret = max(ret, B[r] - B[l - 1])

    else:
        if B[N] < 0:
            K = N
            for l in range(1, N + 1):
                for r in range(l, l + K):
                    ret = max(ret, B[r] - B[l - 1])
        else:
            cnt = K // N - 1

            K = K % N + N

            for l in range(1, N + 1):
                for r in range(l, l + K):
                    ret = max(ret, B[r] - B[l - 1])

            ret += cnt * B[N]

    return ret

print(solve(N, K, P, C))


Measured memory_bytes: 75988
//Matrix Chain Multiplication
#include<stdio.h>
#include<limits.h>

#define N 100

int main(){
	int n,i,j,k,l,Ponta;
	int P[N+1],M[N+1][N+1];


	//input
	scanf("%d",&n);

	for(i=1;i<=n;i++){
		scanf("%d %d",&P[i-1],&P[i]);
	}


	//init
	for(i=1;i<=n;i++){
		M[i][i]=0;
	}

	for(l=2;l<=n;l++){
		for(i=1;i<=n-l+1;i++){
			j=i+l-1;
			M[i][j]=INT_MAX;
			for(k=i;k<=j-1;k++){
				//which min?
				Ponta=M[i][k]+M[k+1][j]+P[i-1]*P[k]*P[j];
				if(Ponta<M[i][j]){
					M[i][j]=Ponta;
				}
			}
		}
	}


	//output
	printf("%d\n",M[1][n]);

	return 0;
}



Measured memory_bytes: 2112
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main() {
  ll k, q;
  cin >> k >> q;

  vector<ll> d(k);
  for(ll i = 0; i < k; i++) {
    cin >> d[i];
  }

  for(ll i = 0; i < q; i++) {
    ll n, x, m;
    cin >> n >> x >> m;

    ll sub = 0;
    vector<ll> D(k);

    ll S = 0;
    for(ll j = 0; j < k; j++) {
      D[j] = d[j] % m;
      S += D[j];
      if(D[j] == 0) {
        sub++;
      }
    }
    
    S += S * ((n-1)/k - 1);
    sub *= (n-1)/k;
    for(ll j = 0; j < (n-1) % k; j++) {
      S += D[j];
      if(D[j] == 0) {
        sub++;
      }
    }

    ll y = x + S;
    sub += (y / m) - (x / m);
 
    cout << n-1-sub << endl;
  } 

  return 0;
}

Measured memory_bytes: 384
import java.util.*;

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

    long x1 = 0;
    long y1 = 0;
    long x2 = 1000000000 ;
    long y2 = 1;
    long x3 ;
    long y3 ;

    //s=abs{(x2*y3-x3*y2)};

    long p = s/1000000000;
    long q = s%1000000000;

    x3 = (x2 - q)% x2;
    y3 = (s+x3)/x2;
    System.out.println(x1+" "+y1+" "+x2+" "+y2+" "+x3+" "+y3);


  }
}

Measured memory_bytes: 22868
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

ll pow2_m(ll x, ll n, ll mod) { //x^n 計算量O(logn)
	ll ans = 1ll;
	while (n > 0) {
		if ((n & 1) == 1) {
			ans = ans * x % mod;
		}
		x = x * x % mod; //一周する度にx, x^2, x^4, x^8となる
		n >>= 1; //桁をずらす n = n >> 1
	}
	return ans;
}

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

	ll n,x;
	cin >> n >> x;
	Array a(n, 0);
	REP(i, n) cin >> a[i];

	ll sum = 0;
	REP(i, n-1) {
		ll d = a[i] + a[i + 1]-x;
		if (d > 0) {
			if (d <= a[i + 1]) {
				a[i + 1] -= d;
				sum += d;
			}
			else {
				a[i + 1] = 0;
				a[i] = x;
				sum += d;
			}
		}
	}
	cout << sum << endl;

	return 0;
}

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

using namespace std;

#define PB push_back
#define MP make_pair
#define X first
#define Y second

#define cil(a,b) ( ((a)%(b) == 0)?((a)/(b)):((a)/(b)+1) )
#define err(x) cerr << #x << " = " << x << endl;
#define forall(i,a,b) for(int i=a;i<b;i++)
#define foreach(v, c) for(typeof((c).begin())v=(c).begin();v!=(c).end();++v)
#define read(a) freopen(a,"r",stdin)
#define write(a) freopen(a,"w",stdout)

typedef long long ll;
typedef long long l;
typedef double db;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pii> vii;

clock_t start;
void Time(bool timeIt) {
	if (!timeIt) return;
	clock_t end = clock();
	double elapsed_time = ((db)end - (db)start) / (db)CLOCKS_PER_SEC;
	fprintf(stderr, "Time elapsed = %0.4lf\n", elapsed_time); 
}

#define LINF (long long)1e18
#define EPS 1e-9
#define INF 1000000007ll
#define SIZE 100010
#define MAX_A 1000010

int main() {
	start = clock();
    ll N, K;
    cin >> N >> K;

    ll ans = 0, num = N / K, num1 = 0;
    ans += num * num * num;
    if (K % 2 == 0 && N >= K / 2) {
        num1 = (N - K / 2) / K + 1;
        ans += num1 * num1 * num1;
    }
    cout << ans << endl;

	Time(true);
	return 0;
}


Measured memory_bytes: 256
n=int(input())
q=[[] for i in range(n+1)]
for i in range(n-1):
    a,b,c=map(int,input().split())
    q[a].append((b,c))
    q[b].append((a,c))

l=[-1]*n
s=[(1,0)]
while s:
    a,w=s.pop()
    l[a-1]=w%2
    for b,c in q[a]:
        if l[b-1]==-1:
            s.append((b,w+c))

for i in l:
    print(i)

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<char,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;

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

    int h, w;
    cin >> h >> w;

    char ans1;
    int ans2;
    rep(i, h){
        rep(j, w){
            string s;
            cin >> s;

            if(s == "snuke"){
                ans1 = j + 'A';
                ans2 = i + 1;
            }
        }
    }

    cout << ans1 << ans2 << endl;

    return 0;
}

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

int main() {
  int n;
  cin >> n;
  int count[4][3][10] = {};
  int b, f, r, v;
  for (int i = 0; i < n; i++) {
    cin >> b >> f >> r >> v;
    count[b - 1][f - 1][r - 1] += v;
  }

  for (int i = 0; i < 4; i++) {
    if (i) {
      cout << "####################" << endl;
    }
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 10; k++) {
        cout << " " << count[i][j][k];
      }
      cout << "\n";
    }
  }
  
  return 0;
}


Measured memory_bytes: 3100
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N = sc.nextInt()
    val A = Array.fill(N)(sc.nextInt())

    val NC = new Array[Int](N+1)
    val NCOMB = new Array[Long](N+1)

    for {
      i <- 0 until N
    } {
      NC(A(i)) += 1
    }

    NCOMB(0) = 0
    NCOMB(1) = 0
    NCOMB(2) = 1
    for {
      i <- 3 to N
    } {
      NCOMB(i) = i * NCOMB(i - 1) / (i - 2)
    }

    val S = (for {
      a <- A.toSet[Int].toSeq
    } yield NCOMB(NC(a))).sum

    val ans = for {
      i <- 0 until N
    } yield {
      S - NCOMB(NC(A(i))) + NCOMB(NC(A(i)) - 1)
    }

    println(ans.mkString("\n"))
  }

}


Measured memory_bytes: 109828
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>

bool f(std::vector<intmax_t>& a) {
  std::sort(a.rbegin(), a.rend());
  intmax_t n = a.size();
  a[0] -= n;
  for (size_t i = 1; i < a.size(); ++i) ++a[i];
  std::sort(a.begin(), a.end());

  return !std::all_of(a.begin(), a.end(), [=](auto x) { return x < n; });
}

int main() {
  intmax_t k;
  scanf("%zu", &k);

  size_t n = 50;
  std::vector<intmax_t> a(n, n+(n+k-1)/n);
  for (size_t i = 0; i < 50; ++i) f(a);
  if (k % n != 0) {
    size_t m = n - k%n;
    for (size_t i = 0; i < m; ++i) f(a);
  }

  printf("%zu\n", n);
  for (size_t i = 0; i < a.size(); ++i)
    printf("%jd%c", a[i], i+1<a.size()? ' ': '\n');
}


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

int main() {
	int H, W, M;
	cin >> H >> W >> M;
	set<pair<int, int>>s;
	vector<int>h(H);
	vector<int>w(W);
	for (int i = 0; i < M; ++i) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		h[x]++;
		w[y]++;
		s.insert(make_pair(x, y));
	}

	int ans = 0;
	int max = 0;
	for (int i = 0; i < H; ++i) {
		if (h[i] > max) {
			max = h[i];
		}
	}
	ans += max;
	vector<int>subh;
	for (int i = 0; i < H; ++i) {
		if (h[i] == max) {
			subh.push_back(i);
		}
	}
	max = 0;
	for (int i = 0; i < W; ++i) {
		if (w[i] > max) {
			max = w[i];
		}
	}
	ans += max;
	vector<int>subw;
	for (int i = 0; i < W; ++i) {
		if (w[i] == max) {
			subw.push_back(i);
		}
	}
	bool b = true;
	for (int i = 0; i < subh.size(); ++i) {
		for (int j = 0; j < subw.size(); ++j) {
			pair<int, int> p = make_pair(subh[i], subw[j]);
			if (s.count(p) ==  0) {
				cout << ans << endl;
				return 0;
			}
		}
	}
	cout << ans -1<< endl;
	return 0;
}

Measured memory_bytes: 23704
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <set>
#include <cmath>
#include <map>

using namespace std;

typedef long long ll;

void solve() {
    ll a, b;
    cin >> a >> b;
    if (a + 1 == b || b + 1 == a || a == b) {
        cout << "Brown\n";
    } else {
        cout << "Alice\n";
    }
}

int main() {
    iostream::sync_with_stdio(false);
    cout.precision(20);
    solve();
}

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

int main(void){
	char ball = 'A';

	while( 1 ){
		int st;
		char a, b;
		
		st = scanf("%c,%c%*c", &a, &b);
		if( st == EOF ) break;
		if( ball == a ) ball = b;
		else if( ball == b ) ball = a;
	}
	printf("%c\n", ball);
	return 0;
}

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

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

using i64 = int_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 n;
    cin >> n;
    vector<i64> a(n);
    for (auto& e : a) cin >> e;

    i64 ans = 0;
    for (i64 i = 0; i < n; i++) {
        while (i + 1 < n && a[i] == a[i + 1]) i++;

        if (i + 1 < n && a[i] < a[i + 1]) {
            while (i + 1 < n && a[i] <= a[i + 1]) i++;
        } else if (i + 1 < n && a[i] > a[i + 1]) {
            while (i + 1 < n && a[i] >= a[i + 1]) i++;
        }

        ans++;
    }

    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


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

public class Main{
	public static void main(String args[]){
		try{
			new Main();
		}catch(IOException err){
			err.printStackTrace();
		}
	}
	
	public Main() throws IOException{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		List<Integer> Ans = new ArrayList<Integer>();
		String line;
		
		while((line = in.readLine()) != null){
			int isGood = 0;
			int size = Integer.parseInt(line);
			
			if(size==0) break;
			
			List<Integer> ids = new ArrayList<Integer>();
			List<Long> sales = new ArrayList<Long>();
			
			for(int n=0; n<size; n++){
				line = in.readLine();
				String[] dst = line.split(" ");
				int id = Integer.parseInt(dst[0]);
				int price = Integer.parseInt(dst[1]);
				int num = Integer.parseInt(dst[2]);
				long sale = (long)price * (long)num;
				
				if(!ids.contains(id)){
					ids.add(id);
					sales.add(sale);
				}
				else{
					int index = ids.indexOf(id);
					sale = sale + sales.get(index);
					sales.set(index, sale);
				}
			}
			
			for(int n=0; n<ids.size(); n++){
				if(sales.get(n) >= 1000000){
					Ans.add(ids.get(n));
					isGood = 1;
				}
			}
			
			if(isGood == 0){
				Ans.add(-1);
			}
		}
		
		for(int n=0; n<Ans.size(); n++){
			if(Ans.get(n)==-1){
				System.out.println("NA");	
			}
			else{
				System.out.println(Ans.get(n));
			}
		}
	}
}

Measured memory_bytes: 11000
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
using namespace std;
int main(void){
    ll n;
    ll res=1;
    cin>>n;
    vector<ll> p(n);
    rep(i, n){
        cin>>p[i];
    }
    ll max=p[0];
    ll min=p[0];
    for(int i = 1;i<n;i++){
        if(p[i]<min){
            min=p[i];
            res++;
        }else if(p[i]>max){
            max=p[i];
        }
    }
    cout<<res;
}


Measured memory_bytes: 1792
#include<iostream>
using namespace std;
char ch[510][510];
int main()
{
	int a,b;
	cin>>a>>b;
	for(int i=0;i<100;i++)
	{
		for(int j=0;j<100/2;j++)
		{
			ch[i][j]='.';
		}
	}
	for(int i=0;i<100;i++)
	{
		for(int j=100/2;j<100;j++)
		{
			ch[i][j]='#';
		}
	}
	a--;
	b--;
	for(int i=0;i<100;i+=2)
	{
		for(int j=0;j<50;j+=2)
		{
			if(b)
			{
				ch[i][j]='#';
				b--;
			}
			else
			{
				break;
			}
		}
		if(b==0)
		{
			break;
		}
	}
	for(int i=0;i<100;i+=2)
	{
		for(int j=51;j<100;j+=2)
		{
			if(a)
			{
				ch[i][j]='.';
				a--;
			}
			else
			{
				break;
			}
		}
		if(a==0)
		{
			break;
		}
	}
	cout<<"100 100\n";
	for(int i=0;i<100;i++)
	{
		ch[i][100]='\0';
		cout<<ch[i]<<endl;
	}
	return 0;
}

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

using namespace std;

int main() {
	string s; cin >> s;
  	int n = stoi(s.substr(0, 4) + s.substr(5, 2) + s.substr(8, 2));
    if (n > 20190430) {
        cout << "TBD" << endl;
    } else {
        cout << "Heisei" << endl;
    }
	return 0;
}

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    string S, T;
    cin >> S >> T;
    int n = 0;
    REP(i, 3)
    {
        if (S[i] == T[i])
            n++;
    }
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,m=map(int,input().split())
    A=[[INF]*n for _ in range(n)]
    for i in range(n):
        A[i][i]=0
    ABC=[None]*m
    for i in range(m):
        a,b,c=map(int,input().split())
        a-=1; b-=1
        A[a][b]=c; A[b][a]=c
        ABC[i]=(a,b,c)

    from itertools import product
    for k,i,j in product(range(n),repeat=3):
        A[i][j]=min(A[i][j],A[i][k]+A[k][j])

    ans=0
    for a,b,c in ABC:
        ans+=all(A[u][v]<A[u][a]+c+A[b][v] for u,v in product(range(n),repeat=2))
    print(ans)
resolve()

Measured memory_bytes: 47596
in_str = input()
temp_list = in_str.split()
a = int(temp_list[0])
b = int(temp_list[1])
c = int(temp_list[2])
if abs(a) <= 100 and abs(b) <= 100 and abs(c) <= 100:
    print("Yes" if a < b < c else "No")

Measured memory_bytes: 7620
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

int data;
int mountain[10];

int main(){
	for(int i=0;i<10;i++){
		cin >> data;
		mountain[i] = data;
	}

	sort(mountain, mountain + 10);

	for(int j=9;j>6;j--){
		printf("%d\n",mountain[j]);
	}

    return 0;
}

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

int main(){
    int n;
    cin >> n;
    int p[n],q[n];
    for(int i=0; i<n; i++){
        cin >> p[i];
    }
    for(int i=0; i<n; i++){
        cin >> q[i];
    }
    int a=0,b=0;
    vector<int> c,d;
    for(int i=1; i<=n; i++){
        c.push_back(i);
        d.push_back(i);
    }
    int e[n];
    e[0] = 1;
    for(int i=1; i<n; i++){
        e[i] = e[i-1]*i;
    }
    for(int i=0; i<n; i++){
        auto cit = lower_bound(c.begin(),c.end(),p[i]);
        auto dit = lower_bound(d.begin(),d.end(),q[i]);
        a += (cit-c.begin())*e[n-1-i];
        b += (dit-d.begin())*e[n-1-i];
        c.erase(cit);
        d.erase(dit);
    }
    cout << abs(a-b) << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def read():
    S = list(input().strip())
    T = list(input().strip())
    return S, T


def solve(S, T):
    k = -1
    for i in range(len(S) - len(T), -1, -1):
        count = 0
        for j in range(len(T)):
            if S[i+j] in [T[j], "?"]:
                count += 1
        if count == len(T):
            k = i
            break
    if k == -1:
        return "UNRESTORABLE"
    for i in range(len(T)):
        S[k+i] = T[i]
    for i in range(len(S)):
        if S[i] == "?":
            S[i] = "a"
    return "".join(S)


if __name__ == '__main__':
    inputs = read()
    print(solve(*inputs))


Measured memory_bytes: 8976
#配列を定義
#JPY bit の定義
N = int(input())
#x,y = [], []
S = 0
for i in range(N):
    x_t,y_t = list(input().split())
    #x.append(x_t)
    #y.append(y_t)
    if y_t == "JPY":
        S += int(x_t)
    else:
        S += float(x_t)*380000.0
print(S)



Measured memory_bytes: 2940
#include<cstdio>
#include<algorithm>
using namespace std;
int a[5];
int t;
int main()
{
	scanf("%d%d%d",&a[1],&a[2],&a[3]);
	sort(a+1,a+4);
	int k=a[3]-a[2];
	a[1]+=k;
	if((a[3]-a[1])%2==0)
		k+=(a[3]-a[1])/2;
	else
		k+=(a[3]-a[1]+1)/2+1;
	printf("%d",k);
	return 0;
}

Measured memory_bytes: 128
X=int(input())
stp=0
for a in range(120):
    if stp==1:
        break
    else:
        for b in range(120):
            A=a**5
            B=b**5
            tmp1=A-B
            tmp2=-A+B
            tmp3=-A-B
            tmp4=A+B
            if tmp1==X:
                print(a,b)
                stp=1
                break
            elif tmp2==X:
                print(-a,-b)
                stp=1
                break
            elif tmp3==X:
                print(-a,b)
                stp=1
                break
            elif tmp4==X:
                print(a,-b)
                stp=1
                break

Measured memory_bytes: 9212
//
//  main.cpp
//  ProCon
//
//  Created by hashimotoryoma on 2017/08/20.
//  Copyright © 2017年 hashimotoryoma. All rights reserved.
//

#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <vector>

#define repeat(i,n) for (int i = 0; (i) < (n); ++ (i))

using namespace std;

typedef long long ll;



int main() {
    // insert code here...    return 0;
    //////
    // input from txt
    /*
     std::ifstream in("input.txt");
     std::cin.rdbuf(in.rdbuf());
     std::ofstream out("output.txt");
     std::cout.rdbuf(out.rdbuf());
     ////
     */
    string s[3];
    cin >> s[0] >> s[1] >> s[2];
    cout << ((s[0].back() == s[1][0] && s[1].back() == s[2][0])? "YES":"NO") << endl;
    return 0;
}


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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (long long i = 0; i < (n); ++i)

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

  if (a + b + c >= 22) {
    ANS("bust");
  } else {
    ANS("win");
  }
  return 0;
}


Measured memory_bytes: 256
from sys import exit, setrecursionlimit
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

setrecursionlimit(1000000)

S = input()
result = sum(S[i] != S[i-1] for i in range(1, len(S)))
print(result)


Measured memory_bytes: 3940
#include <algorithm>
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <climits>
#include <utility>
#include <deque>
#include <list>
#include <stdexcept>
//#include <boost/graph/adjacency_list.hpp>
using namespace std;

#define ll long long
#define IN(type, name) type name; cin >> name
#define IN_V(type, name, size) vector<type> name(size); for(auto& x: name) cin >> x
#define IN_VW(type, name, size) vector<type> name(size); for(auto& x: name) 

int main()
{
	cout << fixed << setprecision(6);
	IN(ll, k);
	IN(ll, x);
	//IN_V(ll, als, n);

	cout << x - k + 1;
	for (ll i = x - k + 2; i < x + k; ++i)
		cout << " " << i;
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
 
 int a, b, c;
 
 scanf("%d%d%d", &a, &b, &c);

 if ( a < b && b < c ) {


    printf("Yes\n");

 } else {


  printf("No\n");

}

 
  
    return 0;
}



Measured memory_bytes: 2108
import qualified Data.ByteString.Char8 as C
import Data.Maybe ( fromJust )
import Data.List

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

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

main :: IO ()
main = do
  [n,k] <- getParms
  as    <- getParms
  print $ f n k as

f :: Int -> Int -> [Int] -> Int
f n k as 
  | k >= l = 0
  | k <  l = g as'' (l-k) 0
  where
    as'  = group . sort $ as
    l    = length as'
    as'' = map length $ sortOn length as'

    g :: [Int] -> Int -> Int -> Int
    g _      0 x = x
    g (b:bs) k x = g bs (k-1) (x + b)

Measured memory_bytes: 44412
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    while(1){
        int w, h; cin>>w>>h;
        if(w == 0) return 0;

        vector<vector<int>> c(h, vector<int>(w));
        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                cin>>c[i][j];
            }
        }

        int ans=0;
        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                if(c[i][j]){
                    ans++;
                    c[i][j] = 0;

                    queue<P> que;
                    que.push(P(i, j));
                    while(que.size()){
                        int cy, cx;
                        tie(cy, cx) = que.front();
                        que.pop();

                        for(int k=0; k<8; k++){
                            int ny = cy + dy[k];
                            int nx = cx + dx[k];

                            if(0 <= ny && ny < h && 0 <= nx && nx < w){
                                if(c[ny][nx]){
                                    c[ny][nx] = 0;
                                    que.push(P(ny, nx));
                                }
                            }
                        }
                    }
                }
            }
        }

        cout << ans << endl;
    }
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
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; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

std::vector<ll> enum_div(ll n)//nの約数を列挙
{
	std::vector<ll> ret;
	for(ll i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
  ret.push_back(n);
	return ret;
}

int main(){
  ll n;cin>>n;
  auto d=enum_div(n);
  int dsz=d.size();
  ll ans=0;
  rep(i,dsz){
    ll m=d[i]-1;
    if(m==0)continue;
    if(n/(m+1)<m){
      ans+=m;
    }
  }
  cout<<ans<<endl;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define FOR(NAME, START, NUM) for (ll NAME = START; NAME < (NUM); NAME++)
#define REP(NAME, NUM) for (ll NAME = 0; NAME < (NUM); NAME++)
#define BREP(NAME, NUM) for (ll NAME = (NUM)-1; NAME >= 0; NAME--)
#define ALL(NAME) (NAME).begin(), (NAME).end()
const ll INF =1000000000000000;

int main(){
  string s;cin>>s;
  bool a=false,b=false;
  if(s[0]=='0' && s[1]!='0')a=true;
  if(s[0]=='1' && s[1]<='2')a=true;
  if(s[2]=='0' && s[3]!='0')b=true;
  if(s[2]=='1' && s[3]<='2')b=true;
 
  if(a==true && b==true)
    cout<<"AMBIGUOUS"<<endl;
  else if(a==true)
    cout<<"MMYY"<<endl;
  else if(b==true)
    cout<<"YYMM"<<endl;
  else 
    cout<<"NA"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <string>

class Process
{
public:
    std::string name;
    int reqtime;
};

int main()
{
    std::queue<Process> queProcess;

    int processNum;
    std::cin >> processNum;

    int quantumTime;
    std::cin >> quantumTime;

    for (int i = 0; i < processNum; i++)
    {
        Process tempProcess;
        std::cin >> tempProcess.name >> tempProcess.reqtime;
        queProcess.push(tempProcess);
    }

    int elapsedTime = 0;
    while (!queProcess.empty())
    {
        Process tempProcess;
        tempProcess = queProcess.front(); queProcess.pop();

        if (tempProcess.reqtime <= quantumTime)
        {
            elapsedTime += tempProcess.reqtime;
            tempProcess.reqtime = 0;
            std::cout << tempProcess.name << " " << elapsedTime << std::endl;
        }
        else
        {
            elapsedTime += quantumTime;
            tempProcess.reqtime -= quantumTime;
            queProcess.push(tempProcess);
        }
    }
}


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

int main() {
    string s, ans = "AC";
    cin >> s;
    if (s[0] != 'A') ans = "WA";
    int cnt = 0;
    REP(i, 1, s.size()) {
        if (isupper(s[i])) {
            cnt++;
            if (i == 1 || i == s.size() - 1 || s[i] != 'C') {
                ans = "WA";
            }
        }
    }
    if (cnt != 1) ans = "WA";
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using ll = long long;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

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

  int ans = 0;
  rep(i, n) {
    ll x, y;
    cin >> x >> y;
    if (x * x + y * y <= (ll)d * d) ++ans;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <cstdio>  
#include <iostream>  
using namespace std;  
int prime[1000005];  
bool is_prime[1000005];  
int seve(int n)  
{  
    int p=0;  
    for(int i=0;i<=n;i++)  
        is_prime[i]=true;  
    is_prime[0]=is_prime[1]=false;  
    for(int i=2;i<=n;i++)  
    {  
        if(is_prime[i])  
        {  
            prime[p++]=i;  
            for(int j=2*i;j<=n;j+=i)  
                is_prime[j]=false;  
        }  
    }  
    return p;  
}  
int main(void)  
{  
    int n;  
    while(scanf("%d",&n)!=EOF)  
    {  
        printf("%d\n",seve(n));  
    }  
    return 0;  
}  


Measured memory_bytes: 4388
#include <bits/stdc++.h>
#include <algorithm>
#include <queue>
using namespace std;
int main() {
	int N; 
    cin >> N; 
	int A[110] = {}; 
	for(int i = 0; i < N; i++){
		cin >> A[i]; 
	} 
	int ans = 1145141919; 
	for(int K = -100; K <= 100; K++){
		int sum = 0; 
		for(int i = 0; i < N; i++){
			sum += (A[i] - K) * (A[i] - K); 
		}
		ans = min(ans, sum); 
	}
	cout << ans << endl; 
}

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

struct P
{
    int x,y,z;

    bool operator<(const P &a)const{
              return x>a.x;
    }

};

vector<int> v,v1;
//bitset<4001000> b;
int a,c,i,b,n,m,k,d;//dy[15]={0,1,0,-1,-1,1,-1,1},dx[15]={1,0,-1,0,1,1,-1,-1};//
int o[333331];
long long l[333331];
int j[1];
int e;
int dx[10]={0,1,0,-1,1,1,-1,-1},dy[10]={1,0,-1,0,1,-1,1,-1},dz[10]={0,0,0,0,1,-1};
long long x,y,mod=1000000007,mod2=1000000009,mod3=2017;
long long z;
double pi=3.14159265;
P u[1];
stack<int> s;

//set<long long> s;
queue<P> q;

//2147483647
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
//map<int,int> p,p1;
//list<int> l;

//string r,r1;
char r[1113];
//deque<int> de;

bool as(P a,P b)
{
    if(max(a.z,-a.z)!=max(b.z,-b.z))
        return max(a.z,-a.z)<max(b.z,-b.z);
    return a.z<b.z;
    //return a.y<b.y;
}

void f(int a,int m)
{
    k=max(a+1,k);
    if(m%2==0)
    {
        q.push({a,0,m});
        m--;
    }
    q.push({a,a+1,0});
    q.push({a,a+1,(m+1)/2});
    if(m>1)
    {
    f(a+1,(m+1)/2-1);
    }
}

int main()
{
    scanf("%d",&a);
    f(1,a-1);
    printf("%d %d\n",k,q.size());
    for(;q.size();q.pop())
    {
        if(q.front().y)
            printf("%d %d %d\n",q.front().x,q.front().y,q.front().z);
        else
            printf("%d %d %d\n",q.front().x,k,q.front().z);
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  if(a*b > a-b && a*b >a+b)
    cout << a*b << endl;
  else if(a+b > a-b && a+b >a*b)
    cout << a+b << endl;
  else
    cout << a-b << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int n,q;
	while(cin>>n>>q){
		if(!n&&!q)break;
		int count[101]={0},ans=0,max=0;
		while(n--){
			int m,date;
			cin>>m;
			while(m--){
				cin>>date;
				count[date]++;
				if(max<count[date]) max=count[date];
			}
		}
		if(max>=q) for(ans=1;ans<101;++ans) if(count[ans]==max&&q<=count[ans]) break;
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

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

    int H=scan.nextInt();
    int W=scan.nextInt();

    while (H != 0 || W != 0) {

        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                if(i==0 || j==0 || i==(H-1) || j==(W-1)){
                    System.out.print("#");
                }else{
                    System.out.print(".");
                }
            }
            System.out.print("\n");
        }

        System.out.print("\n");
        H=scan.nextInt();
        W=scan.nextInt();
    }
    }
}


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

#define ll long long
#define ld long double
#define db double
#define str string
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define rall(v) rbegin(v),rend(v)
#define selp(a) for(auto i:a)cout<<i<<" ";cout<<nl;
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr<<name<<" : "<<arg1<<nl;
}
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
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const db pi=2*acos(0.0);

int main(){
    nimble;
    int tt=1;//cin>>tt;
    while(tt--){
        int n,k;
        cin>>n>>k;
        map<int,int> mp;
        rep(i,0,k){
            int d;
            cin>>d;
            mp[d]++;
        }
        while(1){
            int f=0;
            string x=to_string(n);
            rep(i,0,_sz(x))
                if(mp[x[i]-'0']){
                    f=1;
                    break;
                }
            if(!f)break;
            n++;
        }
        cout<<n<<nl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}
long long gcd(long long a, long long b) {
    if(a < b) {
        swap(b, a);
    }
    if(b == 0) {
        return a;
    }
    if(a == 0) {
        return b;
    }
    a = a % b;
    return gcd(b, a);
}
int main() {
    long long N, K;
    cin >> N >> K;
    vector<long long> A(N);
    REP(i, N) { cin >> A[i]; }
    long long gc = gcd(A[0], A[1]);
    REP(i, N) { gc = gcd(gc, A[i]); }
    // KがAiの最大値以下でありかつgcdで割り切れるか
    long long m = *max_element(A.begin(), A.end()); // c++11
    if(K <= m and K % gc == 0) {
        cout << "POSSIBLE" << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
}

Measured memory_bytes: 1024
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let s: u16 = read(&mut stdin_lock, &mut buf, b'\n');
    let u1: u16 = s / 100;
    let u2: u16 = s % 100;
    let ym = 1 <= u2 && u2 <= 12;
    let my = 1 <= u1 && u1 <= 12;
    let ans = match (ym, my) {
        (true, true) => "AMBIGUOUS",
        (true, false) => "YYMM",
        (false, true) => "MMYY",
        (false, false) => "NA",
    };
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e14;
using Graph = vector<vector<int>>;

signed main(){
  string S;
  cin >> S;
  int t = 0;
  for( int i = 0; i < S.size(); i++ ){
    t += S[i]-'0';
  }
  if( t%9 == 0 ) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3748
from __future__ import print_function

import sys
sys.setrecursionlimit(500000)

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# from fractions import gcd
# from math import gcd

# def lcm(n, m):
#     return int(n * m / gcd(n, m))


# def coprimize(p, q):
#     common = gcd(p, q)
#     return (p // common, q // common)


# def find_gcd(list_l):
#     x = reduce(gcd, list_l)
#     return x


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def main():
    # 
    n,m,q = map(int,input().strip().split())
    abcd = []
    for i in range(q):
        # a,bはindexの次元，cは値， dはポイント
        temp_a,temp_b,temp_c,temp_d = map(int,input().strip().split())
        abcd.append((temp_a - 1, temp_b - 1, temp_c, temp_d ))

    # 
    eprint('n,m,q ',end=':\n')
    eprint(n,m,q)
    eprint('abcd ',end=':\n')
    eprint(abcd)

    #
    ans=0
    ll=[i for i in range(1,m+1)]
    # # ll=[i for i in range(1,m+1)]+[i for i in range(1,m+1)]+[i for i in range(1,m+1)]+[i for i in range(1,m+1)]
    # A=[]
    # rep(n)
    # for a1 in range(1,m+1):
    #     for a2 in range(p,m+1):
    #         for a3 in range(j,m+1):
    #             for a4 in range(k,m+1):
    #                 for a5 in range(k,m+1):
    #                     for a6 in range(k,m+1):
    #                         for a7 in range(k,m+1):
    #                             for a8 in range(k,m+1):
    #                                 for a9 in range(k,m+1):
    #                                     if :
    #                                         pass
    #                     pass
    #                 A=[p,j,k,l]
    #                 point = 0
    #                 for i in range(q):
    #                     a=abcd[i][0]
    #                     b=abcd[i][1]
    #                     c=abcd[i][2]
    #                     d=abcd[i][3]
    #                     if A[b] - A[a] == c:
    #                         point+=d
    #                 ans = max(point,ans)
    # print(ans)   
    for A in itertools.combinations_with_replacement(ll,n):
        #
        eprint('A ',end=':\n')
        eprint(A)

        point = 0
        for i in range(q):
            a=abcd[i][0]
            b=abcd[i][1]
            c=abcd[i][2]
            d=abcd[i][3]
            if A[b] - A[a] == c:
                point+=d
        ans = max(point,ans)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 82544
a,b = map(int, input().split())
result = 0
for i in range(1,21):
  if b == 1:
    break
  elif i == 1:
     if a >= b:
        result = 1
        break
  else:
     if a * i -i + 1>= b:
        result = i
        break
print(result)


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF (1LL<<60)
#define mod 1000000007

ll n;
ll a[101],b[101];
ll d[101][101];

int main(){
  cin>>n;
  rep(i,n)cin>>a[i];
  rep(i,n)cin>>b[i];

  ll res=0;
  while(1){
    rep(i,101)rep(j,101)d[i][j]=(i==j?0LL:INF);

    repl(i,1,51){
      repl(k,1,51){
        if(((1LL<<k)&res)==(1LL<<k)) d[i][i%k]=0;
        else minch(d[i][i%k],1LL<<k);
      }
    }

    rep(k,51)rep(i,51)rep(j,51)minch(d[i][j],d[i][k]+d[k][j]);

    ll mx=0;
    rep(i,n){
      maxch(mx,d[a[i]][b[i]]);
    }
    if(mx==0)break;
    if(mx>=INF){
      cout<<-1<<endl;
      return 0;
    }
    for(ll i=50;i>=0;i--){
      if((mx>>i)&1LL){
        res|=(1LL<<i);
        break;
      }
    }
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
#define INF 200000000000
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; }
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;}
#define all(x) x.begin(), x.end()

bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}
// 入力

vector<vector<ll> > G;
vector<bool> seen;
vector<ll> h;

ll cnt=1;
ll mx;
ll flag;
//ll fcnt=1;
void dfs(ll v){
    seen[v] = 1;
    if(h[v]==mx){
        flag = 1;
    }
    if(h[v]>mx){
        mx = h[v];
        flag = 0;
    }
    rep(i,G[v].size()){
        if(seen[G[v][i]] == 0){
            dfs(G[v][i]);
        }
    }

}

int main() {
    ll n,m;
    cin >> n>>m;
    G.resize(n);
    seen.resize(n);
    h.resize(n);

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

    rep(i,m){
        ll a,b;
        cin>>a>>b;
        a--;
        b--;
        G[a].pb(b);
        G[b].pb(a);
    }

    ll ans  = 0;
    vector<ll> an(n);
    rep(k,n){
        
        if(an[k]==0){

            for(ll i : G[k]){
                if(h[k]==h[i]){
                    an[k] = 1;
                    an[i] = 1;
                    break;
                } else if(h[k] < h[i]){
                    an[k] = 1;
                    break;
                }else{
                    an[i] = 1;
                }
            }
 
            
        }
    }

    rep(i,n){
        if(an[i]==0){
            ans++;
        }
    }
    cout <<ans<<endl;

    
   
    


    return 0;
    

}

Measured memory_bytes: 10660
/*  
    Talkin' to myself and feelin' old
    Sometimes I'd like to quit, nothin' ever seems to fit
    Hangin' around, nothin' to do but frown
    Rainy days and Mondays always get me down
    _________________________
    _________________________
    960 Hours of Solitude
    Quarantine_Day : 40
*/

#include<bits/stdc++.h>

using namespace std;

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

#define pb(n)           push_back(n)
#define GSORT(v)        sort(v.begin(), v.end(), greater<ll>())
#define SORT(v)         sort(v.begin(), v.end());
#define REV(v)          reverse(v.begin(), v.end());
#define db(a)           cout<<#a<<" = "<<a<<endl;
#define FIN             freopen("in.txt","r",stdin);
#define FOUT            freopen("out.txt","w",stdout);
#define REP(i,n)        for(int i = (int)(0); i < (int)(n); i++)
#define FOR(i, a, b)    for(int i = (int)a; i <= (int)b; i++)    

#define MAX 200005

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

    set<char>st;
    int n; cin>>n;
    while(n--){
        char c; cin>>c;
        st.insert(c);
    }
    cout<<(st.size() == 4?"Four\n":"Three\n");
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include <sstream>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include <iomanip>

#define A_P(n,a,d) (n/2)*(2*a + (n-1)*d)
using namespace std;
long nCr(int n, int r){
    if(n == r) 
        return 1;
    long dividend = 1;
    long divisor  = 1;
    for ( int i = 1; i <= r; ++i ) {
        dividend *= (n-i+1);
        divisor  *= i;
    }
    return dividend / divisor;
}



//ちゃんとlong型でやってる？

int main(void){
    map<int,int> balls;
    int N;
    cin >> N;
    vector<long> henteko;
    for(int i =0; i < N; i++){
        int tmp;
        cin >> tmp;
        balls[tmp] += 1;
        henteko.push_back(tmp);
    } 
    long sum = 0;
    
    for(auto it = balls.begin(); it != balls.end(); ++it){
        long tmp = nCr(it->second,2); 
        sum += tmp;
    }
    
    for(int i =0 ; i < henteko.size(); i++){
        if(balls[henteko[i]] > 1){
            cout << sum - (nCr(balls[henteko[i]],2)) + (nCr(balls[henteko[i]] - 1,2)) << endl;
        }else{
            cout << sum << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 10732
#include<iostream>
#include<bits/stdc++.h>
#define ll                    long long int
#define fo(i,a,b)          for( i=(ll)a;i<(ll)b;++i)
#define loopr(i,a,b)          for(int i=(int)a;i>=(int)b;--i)
#define pb                    push_back
#define mset(a,b,c)           loop(i,0,b) a[i]=c
#define F                     first
#define S                     second
#define mp                    make_pair
#define clr(x)                x.clear()
#define MOD                   1000000007
#define MAX                   1e9
#define MIN                   -1e9
#define vi                    vector<ll>
#define vvi                   vector<vi>
#define pll                   pair<ll,ll>
#define all(p)                p.begin(),p.end()
#define max(x,y)              (x>=y)?x:y
//#define min(x,y)              (x<=y)?x:y
#define mid(s,e)              (s+(e-s)/2)
#define start()                  int t; scanf("%d",&t); while(t--)
using namespace std;
ll extgcd(ll a,ll b,ll& x,ll& y){if(b==0){x=1;y=0;return a;}else{int g=extgcd(b,a%b,y,x);y-=a/b*x;return g;}}
ll modpow(ll a,ll b) {ll res=1;a%=MOD;for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}
ll min(ll x,ll y)
{
		return x<=y?x:y;
}

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


}

Measured memory_bytes: 3624
def iin(): return int(input())
def nl(): return list(map(int, input().split()))
def ary(r, c, v): return [[v for _ in range(c)] for _ in range(r)]

k = iin()
if k % 2 == 0:
    ans = (k // 2) ** 2
else:
    ans = (k // 2) * (k // 2 + 1)
print(ans)

Measured memory_bytes: 3316
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;

int main(){
    
    int a,b,c,x;
    cin >> a >> b >> c >> x;
    int cnt  = 0;

    for(int i=0;i<=a; i++){
        for(int j=0;j<=b;j++){
            for(int k=0;k<=c;k++){
                if(x == 500*i + 100*j + 50*k){
                    cnt ++;
                }
            }
        }
    }

    cout << cnt << endl;


    return 0;
}

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

int main() {
	int a, b;
	cin >> a >> b;
	string ans = "No";
	for (int i = 0 ; i <= a; i++) {
		int j = a - i ;

		if (i * 2 + j * 4 == b) {
			ans = "Yes";
		}
	}

	cout << ans << endl;
}

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

int main(){
	ll n,m; cin >> n >> m;
	ll a = 0,b = n;
	rep(i,m){
		ll l,r; cin >> l >> r;
		--l; --r;
		if(a < l)a = l;
		if(r < b)b = r;
	}
	a > b ? cout << 0 << endl : cout << b - a + 1 << endl;
}

Measured memory_bytes: 256