akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
int A[100010];

signed main(){
	cin>>N;
	REP(i,N+1){
		cin>>A[i];
	}
	if(N==0){
		if(A[0]==1){
			cout<<1<<endl;
			return 0;
		}
		else{
			cout<<-1<<endl;
			return 0;
		}
	}
	if(A[0]!=0){
		cout<<-1<<endl;
		return 0;
	}
	int sum=0;
	REP(i,N+1){
		sum+=A[i];
	}
	int now=1;
	int ans=1;
	for(int i=1;i<N+1;i++){
		now*=2;
		if(now<A[i]){
			cout<<-1<<endl;
			return 0;
		}
		ans+=min(sum,now);
		now=min(now,sum)-A[i];
		sum-=A[i];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4384
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
const int inf   = 1e9+7;
const ll  longinf = 1LL<<60;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

int n,dist[101010];

int bfs(){
  priority_queue<pint,vector<pint>,greater<pint>> pq;
  pq.push({1,1});
  dist[1]=1;
  while(pq.size()){
    pint p=pq.top();
    pq.pop();
    int d=p.first,now=p.second;
    int next=(now+1)%n;
    if(dist[next]>d+1){
      dist[next]=d+1;
      pq.push({d+1,next});
      }
    next=(now*10)%n;
    if(dist[next]>d){
      dist[next]=d;
      pq.push({d,next});
      }
    }
  return dist[0];
  }      

int main(){
  cin>>n;
  rep(i,n)dist[i]=inf;
  cout<<bfs()<<endl;
  return 0;
  }


Measured memory_bytes: 1276
N, M, K = map(int, input().split())


def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod


mod = 998244353
n = 2*10**5
g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル

for i in range(2, n + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod//i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)

ans = 0
for i in range(K+1):
    # print(i, cmb(N-1, i, mod)*pow(M, N-i, mod))
    ans += cmb(N-1, i, mod)*M*pow(M-1, N-1-i, mod)
    ans %= mod
print(ans)


Measured memory_bytes: 33292
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N];
		long sum =0;
		for (int i=0;i<N;i++) {
			A[i] = sc.nextInt();
			sum +=A[i];
		}
		int M = sc.nextInt();
		for (int i=0;i<M;i++) {
			int q = sc.nextInt();
			int t= sc.nextInt();
			System.out.println(sum-A[q-1]+t);
		}
	}
}

Measured memory_bytes: 36088
/*
 * 16-10-1_AGC005_A.cpp
 *
 *  Created on: 2016/10/01
 *      Author: ryoma
 */

#include<iostream>
#include<algorithm>
#include<string>


using namespace std;

int a,cnt;
string X;

int main(){
	cin >> X;
	for(int i=0;i<X.length();i++){
		if(X[i]=='S')
			a++;
		if(X[i]=='T'&& a>0){
			a--;
			cnt++;
		}
	}
	cout << (X.length()-2*cnt)<<endl;
	return 0;
}




Measured memory_bytes: 644
#include<iostream>
#include<algorithm>

using namespace std;

int main()
{
	double ma=0,mi=1000000000.0;
	double a;
	
	for(;cin >> a;)
	{
		ma=max(ma,a);
		mi=min(mi,a);
	}
	cout << ma-mi << endl;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
using namespace std;
 
int main(){
    
    int T[5],mod[5]={},x,l,ans;

    x=10;
    l=5;
    ans=0;

    for(int i=0;i<5;i++){
        cin >> T[i];
        mod[i] = T[i] % 10;
        if(mod[i]<=x && mod[i]!=0){
            x = mod[i];
            l = i;
        }
    }

    for(int i=0;i<5;i++){
            if(i!=l&&mod[i]!=0){
                ans += T[i] + (10-mod[i]);
            }else{
                ans += T[i];
            }
    }
    
    cout << ans ;

    return 0;

}

Measured memory_bytes: 256
rooms = [0] * (4*3*10)
n = input();
for i in xrange(n):
	b,f,r,v = map(int, raw_input().split())
	rooms[(b-1)*30+(f-1)*10+(r-1)] += v

sep = "#" * 20
for b in xrange(4):
	for f in xrange(3):
			t = 30*b + 10*f
			print ""," ".join(map(str, rooms[t:t+10]))
	if b < 3: print sep

Measured memory_bytes: 6448
#include <cstdio>
#include <cstring>
#define MAXN 12
char a[MAXN], b[MAXN], c[MAXN];
int main() {
	int l1, l2;
	scanf("%s %s %s", a, b, c);
	l1 = strlen(a);
	l2 = strlen(b);
	if(a[l1-1] == b[0] && b[l2-1] == c[0])
		printf("YES\n");
	else 
		printf("NO\n");
	return 0;
}


Measured memory_bytes: 128
n, p = map(int, input().split())


def factorization(n):
    retval = []
    tmp = n
    for p in range(2, int(n**.5)+1):
        if tmp % p == 0:
            cnt = 0
            while tmp % p == 0:
                cnt += 1
                tmp //= p
            retval.append([p, cnt])
    if tmp != 1:
        retval.append([tmp, 1])
    return retval


ans = 1
for k, v in factorization(p):
    ans *= pow(k, v//n)
print(ans)


Measured memory_bytes: 3188
# https://atcoder.jp/contests/abc047/tasks/arc063_a
# 連長圧縮すれば簡単
# 圧縮後の文字列長-1となる


def run_length_encoding(s):
    '''連長圧縮を行う
    s ... iterable object e.g. list, str
    return
    ----------
    s_composed,s_num,s_idx
    それぞれ、圧縮後の文字列、その文字数、その文字が始まるidx'''
    s_composed, s_sum = [], []
    s_idx = [0]
    pre = s[0]
    cnt = 1
    for i, ss in enumerate(s[1:], start=1):
        if pre == ss:
            cnt += 1
        else:
            s_sum.append(cnt)
            s_composed.append(pre)
            s_idx.append(i)
            cnt = 1
            pre = ss
    s_sum.append(cnt)
    s_composed.append(pre)
    # assert len(s_sum) == len(s_composed)
    return s_composed, s_sum, s_idx


# def run_length_encoding(s):
#     '''連長圧縮を行う
#     s ... iterable object e.g. list, str
#     return
#     ----------
#     s_composed,s_num,s_idx
#     それぞれ、圧縮後の文字列、その文字数、その文字が始まるidx'''
#     from itertools import groupby
#     s_composed, s_sum = [], []
#     s_idx = [0]
#     for k, v in groupby(s):
#         s_composed.append(k)
#         n = len(list(v))
#         s_sum.append(n)
#         s_idx.append(s_idx[-1] + n)

#     # assert len(s_sum) == len(s_composed)
#     return s_composed, s_sum, s_idx


S_composed, _, _ = run_length_encoding(input())
print(len(S_composed) - 1)


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

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second

#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

using ll = long long;
using ull = unsigned long long;
const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9 + 7;
typedef pair<ll, int> P;

TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;
TPL<TNM T> using vec4 = vec<vec3<T>>;
TPL<TNM T> using vec5 = vec<vec4<T>>;

TPL<TNM T> inline istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; }
TPL<TNM V, TNM H> void resize(vector<V>& _v, const H _h) { _v.resize(_h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& _v, const H& _h, const T& ... _t) { _v.resize(_h); for (auto& __v : _v) resize(__v, _t ...); }
TPL<TNM V, TNM T> TNM enable_if<!is_class<V>::value>::type fill(vector<V>& _v, const T &_t) { std::fill(ALL(_v), _t); }
TPL<TNM V, TNM T> TNM enable_if<is_class<V>::value>::type fill(vector<V>& _v, const T &_t) { for (auto &_e : _v) fill(_e, _t); }
TPL<TNM T> inline void UNIQUE(vector<T>& _v) { sort(ALL(_v)); _v.erase(unique(ALL(_v)), _v.end()); }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(6); } } pre__;

int main(void) {
	int W, H, N;
	cin >> W >> H >> N;
	vec2<int> F;
	resize(F, H, W);
	fill(F, 0);
	REP(i, N) {
		int x, y, a;
		cin >> x >> y >> a;
		if (a == 1) {
			for (int h = 0; h < H; ++h) {
				for (int w = 0; w < W; ++w) {
					if (w < x) {
						F[h][w] = 1;
					}
				}
			}
		}
		else if (a == 2) {
			for (int h = 0; h < H; ++h) {
				for (int w = 0; w < W; ++w) {
					if (w >= x) {
						F[h][w] = 1;
					}
				}
			}
		}
		else if (a == 3) {
			for (int h = 0; h < H; ++h) {
				for (int w = 0; w < W; ++w) {
					if (h < y) {
						F[h][w] = 1;
					}
				}
			}
		}
		else {
			for (int h = 0; h < H; ++h) {
				for (int w = 0; w < W; ++w) {
					if (h >= y) {
						F[h][w] = 1;
					}
				}
			}
		}
	}
	int ans = 0;
	for (int h = 0; h < H; ++h) {
		for (int w = 0; w < W; ++w) {
			if (F[h][w]) {
				++ans;
			}
		}
	}
	cout << W * H - ans << endl;
	return 0;
}

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

int main(void){
  int N;
  cin >> N;
  if(N % 2 == 0){
    cout << N << endl;
  } else {
    cout << 2*N << endl;
  }

  return 0;
}

Measured memory_bytes: 256
/*
मनस्वी म्रियते कामं कार्पण्यं न तु गच्छति ।
अपि निर्वाणमायाति नानलो याति शीतताम् ॥
*/

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
using namespace std;

#define mod 1000000007
#define pb push_back
#define ll long long int
#define ull unsigned ll
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define vpi vector<ppi>
#define vpl vector<ppl>
#define all(x) x.begin(),x.end()
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define p2d(v) for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v) for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppd(v) for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;
#define imx INT_MAX
#define imn INT_MIN
#define inf 9000000000000000000
#define minf -inf
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set
#define pi 3.141592653589793
#define MAXN 100005
#define test1(x) cout << #x " = " << x << endl;
#define test2(x,y) cout << #x " = " << x << " " << #y " = " << y << endl;
#define test3(x,y,z) cout << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << endl;
#define test4(w,x,y,z) cout << #w " = " << w << " " << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << endl;
#define oset tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>

/*
const ll infinity = 9e18;

bool compare(ll a,ll b) {return a > b;}
bool compare1(ppl a,ppl b) {return a.ff > b.ff;}
bool compare2(ppl a,ppl b) {return a.ss < b.ss;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}

ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md = mod) {ll product = 1; while(b){if(b&1){product = (product*a)%md;}a = (a*a)%md;b = b>>1;} return product%md;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/




int main()
{
    fast

/*
    #ifndef ONLINE_JUDGE
        freopen("input.txt",  "r",  stdin);
        freopen("output.txt", "w", stdout);
    #endif
//*/

        
    ll n;
    cin>>n;

    if(n%2 == 0)
    {
        cout<<-1;
        return 0;
    }

    ll count = 0;

    queue<ppl> q;

    q.push({7%n,1});
    // count++;

    while(!q.empty())
    {

        ppl p = q.front();
        q.pop();

        if(p.ff == 0)
        {
            cout<<p.ss;
            return 0;
        }
        if(p.ss == 1e7) break;
        q.push({((p.ff*10)+7)%n,p.ss+1});
    }
        
        


    cout<<-1;









    return 0;
}       

Measured memory_bytes: 3656
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;

int main() {
    string s;
    cin >> s;
    if (s[0] == '7' || s[1] == '7' || s[2] == '7') {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3592
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <iomanip>

using namespace std;

#define x first
#define y second
#define int long long

signed main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	vector<pair<int, int>> ans;
	for (int i = 1; i < a.size() - 1; i++) {
		if (a[i] >= 0) {
			ans.push_back({ a[0], a[i] });
			a[0] -= a[i];
			a[i] = 1e9;
		}
	}
	for (int i = 0; i < a.size() - 1; i++) {
		if (a[i] <= 0) {
			ans.push_back({ a[a.size() - 1], a[i] });
			a[a.size() - 1] -= a[i];
		}
	}
	cout << a.back() << endl;
	for (auto el : ans)
		cout << el.x << ' ' << el.y << endl;
	return 0;
}


Measured memory_bytes: 4336
#include <stdio.h>

int main(void){
	int i, x, y, temp;
	while(1){
		scanf("%d %d", &x, &y);
		if(x == 0 && y == 0){
			break;
		}
		if(x > y){
			temp = x;
			x = y;
			y = temp;
		}
		printf("%d %d\n", x, y);
	}
	return 0;
}

Measured memory_bytes: 600
#include<stdio.h>
int main(){
    int a;
    int b;
    scanf("%d",&a);
    scanf("%d",&b);
    if(a==b){
     printf("a == b\n");
    }else if(a<b){
        printf("a < b\n");
    }else if(a>b){
        printf("a > b\n");
    }
    return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }eni(!=) cerr  << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
} sim dor(rge<c> d) { *this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it; ris << "]";}
#else
sim dor(const c&) { ris; }
#endif
};
#define err(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll=long long;
using vi=vector<int>;



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

    int n; cin >> n;
    int k; cin >> k;
    vi a(n);
    for(int & i : a)
        cin >> i;
    const int INF_LL = 1e18;
    vector < ll > dp(n + 1 , INF_LL);
    dp[0] = 0;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j <= i + k && j < n ; j++){
            dp[j] = min( dp[j] , abs( a[i] - a[j] ) + dp[i] );
        }
    }
    cout << dp[n - 1] << '\n';


    return 0;
}




Measured memory_bytes: 1408
n, m = map(int, input().split())
k = [0] * m
s = [[]] * m
t = [set() for _ in range(n)]
for i in range(m):
    ki, *si = map(int, input().split())
    k[i] = ki
    for j in si:
        t[j - 1].add(i)
p = list(map(int , input().split()))
ans = 0
for i in range(2 ** n):
    on = [0] * m
    light = [0] * m
    for j in range(n):
        if((i >> j) & 1):
            for k in t[j]:
                light[k] += 1
            #print(j, t[j], light)
    is_all = True
    for x in range(m):
        is_all = is_all and (light[x] % 2 == p[x])
    if is_all:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<math.h>
typedef long long ll;
using namespace std;

ll health(ll n){
	if(n==1)
		return 1;
	else{
		return 2 * health(n/2) + 1; 
	}
}

int main(){
	ll n;
	cin>>n;
	cout<<health(n);
	
}

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

using namespace std;

const int maxn=300005;
typedef long long ll;

int n;
char c[maxn];
int ans,cnt;

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>c[i];
	for(int i=1;i<=n;i++)
		if(c[i]=='R')
			ans++;
	for(int i=1;i<=ans;i++)
		if(c[i]=='W')
			cnt++;
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 3816
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
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; }

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    ll s;
    cin >> s;
    ll h = s / 3600;
    s %= 3600;
    ll m = s / 60;
    s %= 60;
    cout << h << ":" << m << ":" << s << endl;
    return 0;
}


Measured memory_bytes: 3216
import sys
n, m = [int(i) for i in sys.stdin.readline().split()]
a_ls = []
b_ls = []
for i in range(n):
    a_ls.append(sys.stdin.readline().strip())
for i in range(m):
    b_ls.append(sys.stdin.readline().strip())

def matching(a, b, size, start):
    start_y, start_x = start
    flg = True
    for i in range(size):
        for j in range(size):
            flg &= a[start_y + i][start_x + j] == b[i][j]
            if not flg:
                return flg
    return flg

res = False
for i in range(n - m + 1):
    for j in range(n - m + 1):
        res |= matching(a_ls, b_ls, m, (i, j))
        if res:
            break
    if res:
        break
print("Yes" if res else "No")

Measured memory_bytes: 38256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace A {
	class Program {
		static void Main (string[] args) {
			string[] uinps = Console.ReadLine ().Split (new char[] { ' ' });

			//string s;
			if (uinps[0].Last () == uinps[1].First () && uinps[1].Last () == uinps[2].First ()) {
				Console.WriteLine ("YES");
			} else {
				Console.WriteLine ("NO");
			}


		}
	}
}


Measured memory_bytes: 11220
#include "bits/stdc++.h"

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 11451419194545;

int main(){
    ll N; cin >> N;
    vector<string > dp(N+100, "No");
    dp[0] = "Yes";
    for(ll i = 0; i < N; i++){
        if(dp[i] != "No"){
            dp[i+4] = "Yes";
            dp[i+7] = "Yes";
        }
    }

    cout << dp[N] << endl;
    
    return 0;

}


Measured memory_bytes: 256
n=int(input())
a=[list(input())for i in range(n)]
d={'M':0,"A":0,"R":0,'C':0,'H':0}
for i in a:
    if i[0] in d:
        d[i[0]]+=1
dl=[]
for i in d.values():
    dl.append(i)
ans=0
for i in range(3):
    for j in range(i+1,4):
        for k in range(j+1,5):
            ans+=dl[i]*dl[j]*dl[k]
print(ans)

Measured memory_bytes: 20300
#include <bits/stdc++.h>
 
using namespace std;
 
#define SZ(x) ((int)(x).size())
using namespace std;
typedef pair<int,int> PII;
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define REP(i,n) for (int i = 0; i < n; ++i)
#define FOR(i,a,b) for (int i = a; i <= b; ++i)
#define M 1000000007
#define MM 998244353
#define SZ(a) int((a).size())
#define all(v) (v).begin(), (v).end()
#define uni(v) sort(all(v)), (v).erase(unique(all(v)), (v).end())
#define mod 1000000007
using ll = long long;

//a and b are assumed to be taken modulo p
inline ll add(ll a, ll b, ll p = mod){ ll c = a + b; if(c >= p) c -= p; return c; }
inline ll sub(ll a, ll b, ll p = mod){ ll c = a - b; if(c < 0) c += p; return c; }
inline ll mul(ll a, ll b, ll p = mod){ return (a * 1ll * b) % p; }
 
using VI = vector<int>;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
using VLL = vector<ll>;
using ld = long double;
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
      
}
ll power(ll x, ll y, ll p)
{
    ll res = 1;     // Initialize result
  
    x = x % p; // Update x if it is more than or
                // equal to p
  
    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;
  
        // y must be even now
        y = y>>1; // y = y/2
        x = (x*1ll*x) % p;
    }
    return res;
}
const int MX = 2e4+10;
const int MX2 = 1e6+5;

ll INF= 4 * (ll)1e18;
int mx = 2 * (ll)1e9 + 10;

ll dp[500][500];
ll calcPower[500][500];
ll sumPower[500][500];
ll A[500],B[500];

void store() {
    FOR(i,1,402) {
        calcPower[i][0] = 1;
        sumPower[i][0] = sumPower[i - 1][0] + 1;
        FOR(j,1,401) {
            calcPower[i][j] = mul(i,calcPower[i][j - 1],mod);
            sumPower[i][j] = add(sumPower[i - 1][j],calcPower[i][j],mod);
        }
    }
}
int main(int argc, const char * argv[]) {

    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0); // insert code here...
    int N,C;
    cin >> N >> C;
    FOR(i,1,N) cin >> A[i];
    FOR(i,1,N) cin >> B[i];
    store();
    REP(i,C+1) dp[0][0] = 1;
    FOR(i,1,N) {
        FOR(CC,0,C) {
                FOR(j,0,CC) {
                    dp[i][CC] = add(dp[i][CC],mul(sub(sumPower[B[i]][j],sumPower[A[i] - 1][j],mod),dp[i - 1][CC-j],mod),mod);
                }
        }
    }
    cout << dp[N][C] << endl;
    return 0;
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<bool> ckd(4);
  for (int i = 0; i < 4; i++) {
    int n;
    cin >> n;
    if (n == 1) {
      ckd[0] = true;
    } else if (n == 9) {
      ckd[1] = true;
    } else if (n == 7) {
      ckd[2] = true;
    } else if (n == 4) {
      ckd[3] = true;
    }
  }
  bool flag = true;
  for (int i = 0; i < 4; i++) {
    if (!ckd[i]) {
      cout << "NO" << '\n';
      return 0;
    }
  }
  cout << "YES" << '\n';
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
#define two(i) (1<<(i-1))
using namespace std;
const int maxn=15+10,inf=1000000000;
int f[(1<<16)+10][maxn],p[(1<<16)+10],id[(1<<16)+10];
int dis[maxn][maxn];
int i,j,k,l,r,s,t,n,m,now,all,ans,sum;
int lowbit(int x){
    return x&-x;
}
int main(){
    scanf("%d%d",&n,&m);
    fo(i,1,n) id[two(i)]=i;
    all=(1<<n)-1;
    fo(i,1,m){
        scanf("%d%d%d",&j,&k,&t);
        sum+=t;
        dis[j][k]=dis[k][j]=t;
    }
    fo(i,1,all){
        now=id[lowbit(i)];
        p[i]=p[i-two(now)];
        fo(j,now+1,n)
            if ((i&two(j))) p[i]+=dis[now][j];
    }
    fo(i,0,n)
        fo(j,0,all)
            f[j][i]=-inf;
    f[two(1)][1]=0;
    ans=-inf;
    fo(s,1,all){
        fo(i,1,n){
            r=s;
            while (r){
                if ((r&two(i))) f[s][i]=max(f[s][i],f[(s-r)|two(i)][i]+p[r]);
                r=(r-1)&s;
            }
            fo(j,1,n)
                if (!(s&two(j))&&dis[i][j]) f[s|two(j)][j]=max(f[s|two(j)][j],f[s][i]+dis[i][j]);
        }
        if ((s&two(n))) ans=max(ans,f[s][n]);
    }
    printf("%d\n",sum-ans);
}

Measured memory_bytes: 3840
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int p[100000];
int root(int x){
	if(x == p[x]) return x;
	return p[x] = root(p[x]);
}

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n, m, l; cin >> n >> m >> l;
	rep(i, n) p[i] = i;
	vi cnt(n), sz(n);
	vector<pi> f;
	rep(i, m){
		int a, b; cin >> a >> b;
		f.emplace_back(--a, --b);
		a = root(a);
		b = root(b);
		if(a != b) p[b] = a;
	}
	for(pi i : f){
		if(root(i.first) == root(i.second)){
			cnt[i.first]++;
			cnt[i.second]++;
		}
	}
	rep(i, l){
		int a, b; cin >> a >> b;
		if(root(--a) == root(--b)){
			cnt[a]++;
			cnt[b]++;
		}
	}
	
	rep(i, n) sz[root(i)]++;
	rep(i, n) cout << sz[root(i)] - cnt[i] - 1 << (i == n - 1 ? "\n" : " ");
	
	return 0;
}

Measured memory_bytes: 3572
#!/usr/bin/env python3
import sys


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    N = int(input())
    a = sorted(list(map(int,input().split())))
    print(a[-1] - a[0])
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		try (Scanner sc = new Scanner(System.in);) {
			int a = Integer.parseInt(sc.next());
			int b = Integer.parseInt(sc.next());
			int c = Integer.parseInt(sc.next());
			int all = 0;
			List<Integer> list = new ArrayList<>();
			list.add(a);
			list.add(b);
			list.add(c);

			Collections.sort(list);
			all += Math.abs(list.get(0) - list.get(1));
			all += Math.abs(list.get(1) - list.get(2));

			System.out.println(all);

		}
	}
}


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

int main(){
	int n;
  	cin >> n;
  	vector<int> l(n);
  	rep(i, n) cin >> l[i];
  	
  	int ans = 0;
  	rep(i, n-2){
    	for(int j = i+1; j < n-1; j++){
        	for(int k = j+1; k < n; k++){
              	if(l[i] == l[j] || l[j] == l[k] || l[k] == l[i]) continue;
				if(l[i] < l[j]+l[k] && l[j] < l[i]+l[k] && l[k] < l[i]+l[j]) ans++;
            }
        }
    }
  
  	cout << ans << endl;
}

Measured memory_bytes: 3620
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  a=b=c=d=0
  n=I()
  for _ in range(n):
    s=S()
    if s=='AC':
      a+=1
    elif s=='WA':
      b+=1
    elif s=='TLE':
      c+=1
    else:
      d+=1

  print('AC x '+str(a))
  print('WA x '+str(b))
  print('TLE x '+str(c))
  print('RE x '+str(d))

main()
# print(main())


Measured memory_bytes: 10784
#include<bits/stdc++.h>
using namespace std;
#define     debug       printf("\n<<CameHere<<\n")
#define     mem(x,y)    memset(x, y, sizeof(x))
#define     all(qz)     qz.begin(),qz.end()
#define     rall(qz)    qz.rbegin(),qz.rend()
#define     inf         LLONG_MIN
#define     INF         LLONG_MAX
#define     mod         1000000007
#define     Sqr(x)      ((x)*(x))
#define     ll          long long
#define     mk          make_pair
#define     pb          push_back
#define     pi          acos(-1.0)
#define     cos(a)      cos(a*pi/180)
#define     sin(a)      sin(a*pi/180)
#define     tan(a)      tan(a*pi/180)

ll pow(ll c,ll d){return d==0?:c*pow(c,d-1);}
ll gcd(ll a,ll b) {return b==0? a:gcd(b,a%b);}
ll lcm(ll a,ll b) {return ((a*b)/gcd(a,b));}
/*---------AL ASAD NUR RIYAD------------*/


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ll n,k;
    cin>>n>>k;
    vector<ll> v(n);
    for(ll i=0;i<n;i++) cin>>v[i];
    sort(all(v));
    ll cnt=0;
    for(ll i=0;i<k;i++){
        cnt+=v[i];
    }
    cout<<cnt<<endl;
    return 0;
}



















Measured memory_bytes: 3660
#include <iostream>

using namespace std;

int main(){
  double x1,y1,x2,y2,x3,y3,x4,y4;
  int n;
  cin>>n;
  while(n--){
    cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
    if((y2-y1)/(x2-x1)==(y4-y3)/(x4-x3))cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}
  return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    vector<ll> B(A.size());
    partial_sum(A.begin(), A.end(), B.begin());

    map<ll,ll> ma;
    ma[0]++;
    for(auto b: B) {
        ma[b % M]++;
    }

    ll sum = 0;
    for(auto m: ma) {
        sum += m.second * (m.second - 1) / 2;
    }

    cout << sum << endl;
}


Measured memory_bytes: 5760
#include<stdio.h>
int main(){
    int count[4][3][10]={{{0}}};
    int i,j,k,n;
    int b,f,r,v;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d %d %d %d\n",&b,&f,&r,&v);
        count[b-1][f-1][r-1]+=v;
    }
    for(i=0;i<4;i++){
        for(j=0;j<3;j++){
            for(k=0;k<10;k++){
                printf(" %d",count[i][j][k]);
            }
        printf("\n");
        }
    if(i!=3)printf("####################\n");
    }

return 0;
}




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

int main(){
    int w, a, b;
    cin >> w >> a >> b;
    if(a+w < b){
        cout << b - (a + w) << endl;
    }
    else if(b+w < a){
        cout << a - (b + w) << endl;
    }
    else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define llint long long
#define mod 1000000007

using namespace std;

const int FACT_MAX = 200005;
llint fact[FACT_MAX], fact_inv[FACT_MAX];

llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	}
	else{
		return modpow((a*a)%mod, n/2) % mod;
	}
}

void make_fact()
{
	llint val = 1;
	fact[0] = 1;
	for(int i = 1; i < FACT_MAX; i++){
		val *= i;
		val %= mod;
		fact[i] = val;
	}
	fact_inv[FACT_MAX-1] = modpow(fact[FACT_MAX-1], mod-2);
	for(int i = FACT_MAX-2; i >= 0; i--){
		fact_inv[i] = fact_inv[i+1] * (i+1) % mod;
	}
}

llint comb(llint n, llint k)
{
	llint ret = 1;
	ret *= fact[n];
	ret *= fact_inv[k], ret %= mod;
	ret *= fact_inv[n-k], ret %= mod;
	return ret;
}

llint n;
llint a[100005];
llint sum[100005];

int main(void)
{
	make_fact();
	
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 1; i <= n; i++) sum[i] = sum[i-1] + modpow(i, mod-2), sum[i] %= mod;
	
	llint ans = 0;
	for(int i = 1; i <= n; i++) ans += mod - a[i] * fact[n] % mod, ans %= mod;
	for(int i = 1; i <= n; i++){
		llint tmp = sum[i] + sum[n-i+1]; tmp %= mod;
		tmp *= fact[n], tmp %= mod;
		tmp *= a[i], tmp %= mod;
		ans += tmp, ans %= mod;
	}
	cout << ans << endl;
	
	return 0;
}

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

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(tx, ty, w, h) (0 <= tx && tx <= w && 0 <= ty && ty <= h)

/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;

/* constant */
const int inf = pow(2, 62);
const int mod = 1e9 + 7;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}

/* general_method */
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; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}

/* main */

string s;
void in(){
    cin >> s;
}

void solve(){

    rep(i,0,s.size() - 1){
        if(s[i] == 'A' && s[i + 1] == 'C'){
            print("Yes");
            return ;
        }
    }
    print("No");

}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}

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

#define MOD (1000000000+7)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;
#define forf(i,a,b) for(int i = (a); i < (b); i++)
#define forr(i,a,b) for(int i = (a); i > (b); i--)
#define input(vec,N) for(int i = 0; i < (N); i++) cin >> vec[i];

// template starts
typedef long long int ll;

void solve(){
	// code starts from here
	ll A, B, N;
	cin >> A >> B >> N;
	
	ll x = min(N, B-1);
	ll t1 = A*x;
	t1 /= B;
	
	ll t2 = x/B;
	t2 *= A;
	
	//cout << t1 << " " << t2 << " " << A << " "<< B <<" "<< x << endl;
	cout << t1-t2 << endl;
}

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

	int T;
	T = 1;
	while(T--){
		solve();
	}

	return 0;
}


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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};



int main(){

  int n;
  cin >> n;
  vector<int> v,ten;
  ll sum = 0;
  REP(i,n){
    int x;cin >> x;
    if(x % 10)v.push_back(x);
    else ten.push_back(x);
    sum += x;
  }
  ll res = 0;
  if(!v.empty())sort(ALL(v));
  if(sum % 10){
    res = sum;
  }else{
    if(v.empty()){
      res = 0;
    }else{
      res = sum-v[0];
    }
  }
  cout << res << endl;






  return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;
  
int main(void){

	int sold[10];
	int n,ice;

	while(1){
		cin>>n;
		if(n==0) break;
		for(int i=0;i<=9;i++) sold[i]=0;
		for(int i=0;i<n;i++){
			cin>>ice;
			sold[ice]++;
		}
		for(int i=0;i<=9;i++){
			if(sold[i]==0) cout<<"-"<<endl;
			else{
				while(sold[i]--){
					cout<<"*";
				}
				cout<<endl;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

map<pii, int> ans_map;
vector<int> G[100000];
bool used[100000];

int main() {
    int N, A[100000], B[100000];
    cin >> N;
    REP(i, N - 1) {
        cin >> A[i] >> B[i]; A[i]--; B[i]--;
        G[A[i]].push_back(B[i]);
        G[B[i]].push_back(A[i]);
    }

    queue<pair<int, pii>> que; que.push({0, {-1, -1}});
    int max_num = 0;
    while (!que.empty()) {
        auto f = que.front(); que.pop();
        int v = f.first, before = f.second.first, before_num = f.second.second, num = 1;
        for (int i : G[v]) {
            if (i == before) continue;
            if (num == before_num) num++;
            ans_map[{min(v, i), max(v, i)}] = num;
            que.push({i, {v, num}});
            num++;
        }
        max_num = max(max_num, num - 1);
    }

    cout << max_num << endl;
    REP(i, N - 1) {
        cout << ans_map[{A[i], B[i]}] << endl;
    }
    return 0;
}

Measured memory_bytes: 13056
N, M, C =[int(x) for x in input().split()]
B = [int(x) for x in input().split()]
cnt = 0
for _ in range(N):
  A = [int(x) for x in input().split()]
  P = sum([a * b for (a, b) in zip(A, B)])
  if P > -C:
    cnt += 1
print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "No" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    int N;
    string S;
    cin >> N;
    cin >> S;
    int Ans=1;
    REP(i,N-1){
        if(S[i]!=S[i+1]){
            Ans++;
        }
    }
    cout << Ans << endl;
    return 0;
}

Measured memory_bytes: 512
n = int(input())
line = sorted(list(map(int,input().split())),reverse = True)
alice = 0
bob = 0
if n % 2 == 0:
  for i in range(0,n-1,2):
    alice += line[i]
  for j in range(1,n,2):
    bob += line[j]
else:
  for i in range(0,n,2):
    alice += line[i]
  for j in range(1,n-1,2):
    bob += line[j]
  
print(alice - bob)

Measured memory_bytes: 3064
n = int(input())
a = [int(i) for i in input().split()]
myline = sum(a)//2
for i in range(1,n+1):
    if myline <= sum(a[:i]):
        print(abs(sum(a)-min(sum(a[:i]),sum(a[:i-1]),key=lambda x:abs(myline-x))*2))
        break

Measured memory_bytes: 3060
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin >> n;
    double sum = 0;
    for (int i = 0; i < n; i++)
    {
        double a;
        cin >> a;
        sum += 1.0 / a;
    }
    cout << setprecision(15) << (1.0 / sum) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>
#include <typeinfo>
#include <cmath>
#include <numeric>
#include <queue>
#include <set>
#include <iomanip>
using namespace std;

int main(){
    int N, M;
    std::cin >> N >> M;
    int zero_flag = 0;
    int min, max;
    int L , R;
    std::cin >> min >> max;
    
    for (int i = 1; i < M; ++i)
    {
        std::cin >> L;
        std::cin >> R;
        if((L >= min)&&(L <= max)) min = L;
        if((R <= max)&&(R >= min)) max = R;
        if(R < min) zero_flag = 1;
        if(L > max) zero_flag = 1;
    }
    
    if(zero_flag){
        std::cout << 0 << "\n";
    }else{
        if(N < min){
            std::cout << 0 << "\n";
        }else if(N < max){
            std::cout << N - min + 1 << "\n";
        }else{
            std::cout << max - min + 1 << "\n";
        }
    }
}

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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 coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
 
//Write From this Line

//const ll mod = 1e9+7;
//const ll mod = 998244353;
int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> v(n);
	rep(i, n)cin>>v[i];

	ll ans = INT_MIN;
	for(int left = 0; left <= n; left ++){
		for(int right = 0; right <= n; right++){
			ll tmp = 0;
			if(left + right > n) continue;
			int back = (k - left - right); // back 個まで無視出来る
			if(back < 0) continue;
			priority_queue<int,vector<int>, greater<int>> q;
			rep(i,left){
				q.push(v[i]);
			}
			rep(i,right){
				q.push(v[n-1-i]);
			}
			int count = 0;
			rep(i,left+right){
				// back個まで戻せる
				int t = q.top(); q.pop();
				if(t < 0 && count < back){
					count ++;
					continue;
				}
				else {
					tmp += t;
				}
			}
			chmax(ans,tmp);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
typedef long long ll;

using namespace std;

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

    ll n, k;
    cin>>n>>k;
    const ll mod = 1e9+7;

    ll s = 0;
    for(ll i = k; i <= n+1; i++){
        ll mi = (i - 1)*(i) / 2;
        ll ma = (2*n - i + 1)*(i) / 2;
        s += ma - mi + 1;
    }
    cout<<s%mod<<endl;
}


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


using ll = long long;
int main() {
    ll n;
    cin>>n;
    ll min = 0;
    for(int i = 0; i < 5; i++) {
        long long a;
        cin>>a;
        if(i == 0) {
            min = a;
        } else {
           if(min > a) {
               min = a;
           } 
        }
    }
    ll res = (n + min - 1) / min + 4;
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b,c;
  cin >> a >> b >> c;
  int sum = a + b + c;
  if (sum - max(max(a,b),c) == max(max(a,b),c)) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
int n,x;
int s[6]; 
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&x),s[x%4]++;s[4]=s[0];
	if(s[4]+1==s[1]+s[3]){
		if(s[2]==0) printf("Yes\n");
		else printf("No\n");
	}
	else if(s[4]>=s[1]+s[3]) printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define w(x) int x;cin>>x;while(x--)
#define ll long long
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define vi vector<int>
#define fr(a,b) for(int i=a;i<=b;i++)
#define inf 1e18
#define mod 1000000007

int main()
{   

	fast;
	ll n;
	cin>>n;
	ll a[n+1];
	ll b[n+1];
	for(int i=0;i<n;i++)
	{
		ll x,y;
		cin>>x>>y;
		a[i]=x+y;
		b[i]=x-y;
	}
	sort(a,a+n);
	sort(b,b+n);
	cout<<max(a[n-1]-a[0],b[n-1]-b[0])<<"\n";
	
	return 0;

}


Measured memory_bytes: 6776
package main

import "fmt"

func main() {
	var n, m int

	fmt.Scan(&n, &m)


	// 奇数が０の場合は偶数のみ
	if ( m == 0 ) {
		fmt.Println( combination(n,2))
		return
	} else if ( n == 0 ) {
		fmt.Println( combination(m, 2))
		return
	}

	// n1,m1
	n2 := combination(n, 2)
	m2 := combination(m, 2)

	fmt.Println( n2 + m2)

}


func permutation(n int, k int) int {
	v := 1
	if 0 < k && k <= n {
		for i := 0; i < k; i++ {
			v *= (n - i)
		}
	} else if k > n {
		v = 0
	}
	return v
}

func factorial(n int) int {
	return permutation(n, n - 1)
}

func combination(n int, k int) int {
	return permutation(n, k) / factorial(k)
}

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

const ll MOD = 1000000007;
const int MN = 200010;

ll mod_pow(ll x, ll k)
{
	ll res = 1;
	for (; k; k /= 2, x = x * x % MOD) {
		if (k & 1) {
			res = res * x % MOD;
		}
	}
	return res;
}

int N, X, Y;
vi vec[MN];

ll fac[MN], ifac[MN];
ll comb(int n, int k) {
	if (k < 0 || k > n) return 1;
	return fac[n] * ifac[k] % MOD * ifac[n-k] % MOD;
}

int main() {
	fac[0] = ifac[0] = 1;
	for (int i = 1; i < MN; ++i) {
		fac[i] = fac[i-1] * i % MOD;
		ifac[i] = ifac[i-1] * mod_pow(i, MOD - 2) % MOD;
	}

	cin >> N >> X >> Y;

	rep(i, N) {
		int c, w;
		cin >> c >> w; --c;
		vec[c].pb(w);
	}

	rep(i, N) sort(ALL(vec[i]));

	vector<pii> mns;
	rep(i, N) if (vec[i].size()) {
		mns.eb(vec[i][0], i);
		int p = 1;
		while (p < vec[i].size() && vec[i][p] + vec[i][0] <= X) {
			vec[i][p] = vec[i][0];
			++p;
		}
	}
	
	sort(ALL(mns));

	if (mns.size() == 1) {
		puts("1");
		return 0;
	}

	vi nums;
	for (int i = 1; i < mns.size(); ++i) {
		int id = mns[i].se;
		if (mns[i].fi + mns[0].fi <= Y) {
			int p = upper_bound(ALL(vec[id]), Y - mns[0].fi) - vec[id].begin();
			nums.pb(p);
		}
	}

	int id = mns[0].se;
	if (mns[0].fi + mns[1].fi <= Y) {
		int p = upper_bound(ALL(vec[id]), Y - mns[1].fi) - vec[id].begin();
		nums.pb(p);		
	}

	int sum = 0;
	for (int x:nums) {
		sum += x;
	}

	ll t = fac[sum];

	for (int x:nums) {
		t = t * ifac[x] % MOD;
	}
	cout << t << endl;
	return 0;
}

Measured memory_bytes: 14584
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    x, a, b = LI()

    if abs(x - a) < abs(x - b):
        print('A')
    else:
        print('B')

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10104