akhauriyash/Code-Regression huggingface dataset:
/*suri_kumkaran*/

#include <bits/stdc++.h>

using namespace std;

#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define MP make_pair
#define EB emplace_back
#define endl "\n"
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long

typedef long long int64;
typedef vector<int> VI64;
typedef vector<pair<int,int>> VII64;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;

int32_t main()
{
    IOS;
    int T=1;
    //cin>>T;
    while(T--)
    {
        int x,y,a,b,c,i,tem;
        cin>>x>>y>>a>>b>>c;
        VII64 v;
        for(i=0;i<a;i++)
        {
            cin>>tem;
            v.push_back({tem,1});
        }
        for(i=0;i<b;i++)
        {
            cin>>tem;
            v.push_back({tem,2});
        }
        for(i=0;i<c;i++)
        {
            cin>>tem;
            v.push_back({tem,0});
        }
        sort(ALL(v),greater<pair<int,int>>());
        int tot=x+y;
        int n=v.size();
        int ans=0;
        for(i=0;i<n;i++)
        {
            if(!tot)
            {
                break;
            }
            if(v[i].S==1)
            {
                if(x)
                {
                    x--;
                    ans+=v[i].F;
                    tot--;
                }
            }
            else if(v[i].S==2)
            {
                if(y)
                {
                    y--;
                    ans+=v[i].F;
                    tot--;
                }
            }
            else
            {
                tot--;
                ans+=v[i].F;
            }

        }
        cout<<ans<<endl;
    }

    return 0;
}

Measured memory_bytes: 10220
#include<bits/stdc++.h>
#define rep(i,f,n) for(ll i=(f); (i) < (n); i++)
#define repe(i,f,n) for(ll i=(f); (i) <= (n); i++)
using namespace std;
using ll = long long;
#define MOD (ll)1000000007
#define PI 3.14159265359
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
//#define P pair<ll, ll>
#define dvec vector<vector<ll>>
//printf("%.10f\n")
//cout << fixed << setprecision(10);
template<class T> inline bool chmax(T& a, T b){if (a < b) { a = b; return true; } return false;}
template<class T> inline bool chmin(T& a, T b){if (a > b) { a = b; return true; } return false;}
ll INF = 1e+18;
int iINF = 1e9;


int main()
{
  string S, T; cin >> S >> T;
  sort(S.begin(), S.end());
  sort(T.begin(), T.end());
  reverse(T.begin(), T.end());


  if(S < T) cout << "Yes" << endl;
  else cout << "No" << endl;

}

Measured memory_bytes: 3612
//*
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <functional>
#define MOD 1000000007
#define MAX 0x3f3f3f3f
#define MAX2 0x3f3f3f3f3f3f3f3fll
#define ERR 1e-10
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#pragma warning(disable:4996)
using namespace std;

typedef long long ll;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

int n, t;
int a[200000];

int main()
{
	int i, j, k, l;
	cin>>n>>t;
	for(i=0;i<n;i++) scanf("%d", &a[i]);
	int ma=0;
	int u=0;
	for(i=n-1;i>=0;i--)
	{
		if(ma > a[i]) u=max(u, ma-a[i]);
		else ma=a[i];
	}
	int ans=0;
	ma=0;
	for(i=n-1;i>=0;i--)
	{
		if(a[i]+u == ma) ans++;
		ma=max(ma, a[i]);
	}
	cout<<ans<<endl;
	return 0;
}
//*/

Measured memory_bytes: 640
down_positions = []
ponds = []
for index, value in enumerate(raw_input()):
    if value == '\\':
        down_positions.append(index)
    elif value == '/' and down_positions:
        right = index
        left = down_positions.pop()
        area = right - left
        candidate_area = 0
        while ponds and left < ponds[-1][0]:
           candidate_area += ponds.pop(-1)[1]

        ponds.append((left, area + candidate_area))

print sum(x[1] for x in ponds)
print len(ponds), 
for pond in ponds:
    print pond[1], 

Measured memory_bytes: 6840
#include <bits/stdc++.h>
using namespace std;
int main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int x = x2, y = y2;
    int dx = x2 - x1, dy = y2 - y1;
    for (int i = 0; i < 2; i++) {
        swap(dx, dy);
        dx *= -1;
        x += dx;
        y += dy;
        cout << x << ' ' << y << ' ';
    }
}

Measured memory_bytes: 256
import math


def primeFactorisation(x):
    res = set([1])
    while x % 2 == 0:
        res.add(2)
        x = x//2
    for i in range(3, int(math.sqrt(x)) + 1, 2):
        while (x % i == 0):
            res.add(i)
            x = x // i

    if (x > 2):
        res.add(x)
    return res


if __name__ == "__main__":
    prevs = []
    a, b = map(int, input().split())
    fa = primeFactorisation(a)
    fb = primeFactorisation(b)
    fres = fa.intersection(fb)
    print(len(fres))


Measured memory_bytes: 3064
#include <iostream>
#include <vector>

int N;
std::vector<int> A;
std::vector<int> portfolio;
long long standard_sum;

int main() {
  std::cin >> N;
  A.assign(N, 0);
  portfolio.assign(N, 0);
  for (int i = 0; i < N; ++i) {
    std::cin >> A[i];
    ++portfolio[A[i]-1];
  }

  for (int i = 0; i < N; ++i) {
    standard_sum += portfolio[i] * (long long)(portfolio[i]-1)/2;
  }
  for (int k = 0; k < N; ++k) {
    long long out = 0;
    if (portfolio[A[k]-1] == 1) {
      out = standard_sum;
    } else {
      out = standard_sum - portfolio[A[k]-1] + 1;
    }
    std::cout << out << std::endl;
  }
}


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

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

using namespace std;

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

  int result=0;
  rep(i, b-a+1){
    string s = to_string(i+a);
    string rs = s;
    reverse(rs.begin(),rs.end());

    if(s==rs)result++;
  }
  cout<<result;

  return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce, lru_cache  # @lru_cache(None)
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return (int(x) for x in input().split())
def LI(): return list(Is())
def TI(): return tuple(Is())
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(S())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

n = I()

if n == 1:
    print(0)
    exit()

def prime_factorize_tuple(n):
    ret = []
    tmp = n
    for i in range(2, ceil(sqrt(n))):
        if tmp % i == 0:
            count = 0
            while tmp % i == 0:
                count += 1
                tmp //= i
            ret.append((i, count))

    if tmp != 1:
        ret.append((tmp, 1))

    if not ret:
        ret.append([n, 1])  # n is prime

    return ret

def check(n, x):
    return n*(n+1)//2 <= x

def meguru_bisect(ng, ok, x):
    """
    初期値のng,okを受け取り, check=>Trueを満たす最大値(最小値)を返す
    条件を満たす最大値を求める場合、初期値は(ng:上限の外, ok:下限の外)   例) 10**9+1, -1
    条件を満たす最小値を求める場合、初期値は(ng:下限の外, ok:上限の外)   例) -1, 10**9+1
    上限の外や下限の外が返ってくる場合は条件を満たす値が範囲内になかったことを示すので、例外処理が必要
    """
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if check(mid, x):
            ok = mid
        else:
            ng = mid
    return ok

ans = 0
for p, x in prime_factorize_tuple(n):
    ans += meguru_bisect(10**13, 0, x)

print(ans)

Measured memory_bytes: 72784
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

signed main(){

	lli n,w;
	vector<pair<lli,lli>> p;

	cin>>n>>w;
	REP(i,0,n){
		lli a,b;
		cin>>a>>b;
		p.push_back(make_pair(a,b));
	}

	lli dp[100100]={0};

	REP(i,0,n){
		for(lli j=100000;j>0;j--){
			lli nextW = j + p[i].first;
			if(dp[j] && nextW <= w){
				dp[nextW] = max(dp[nextW],dp[j]+p[i].second);
			}
		}
		dp[p[i].first] = max(dp[p[i].first],p[i].second);
	}

	lli ans=0;
	REP(i,0,w+1){
		ans = max(ans,dp[i]);
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <string>
#include <sstream>
#include <iostream>
#include <cmath>
#include <bits/stdc++.h>
#define int long long
using namespace std;
static const int MAX_N = 20;
static const double inf = 1ll<<60;
static const double EPS = 0.0000001;
int N;
double L;
double R[MAX_N];
int maxbit;
int s;
double mem[10005][MAX_N];

double call(int bit,int p){
    double res=inf;
    if(mem[bit][p]!=-1.0d)return mem[bit][p];
    if(bit==maxbit){
        return R[p]+R[s];
    }
    for(int i=0;i<N;++i){
        int b=bit;
        int k=1<<i;
        if(b&k)continue;
        double a = abs(R[i] - R[p]), c = R[i] + R[p];
		double val = sqrt(c*c - a*a);
        res=min(call(b+k,i)+val,res);
    }
    return mem[bit][p]=res;
}

signed main(){
    while (cin >> L)
	{
		N = 0;
		string S;
		getline(cin, S);
		stringstream SS(S);
		while (!SS.eof()) SS >> R[N++];
		for(int i=0;i<N;++i)maxbit+=pow(2,i);
		double ans=inf;
		if (N == 1) ans = R[0]*2;
		else{
            for(int i=0;i<N;++i){
                for(int i=0;i<=5000;++i)for(int j=0;j<=12;++j)mem[i][j]=-1.0;
                s=i;
                ans = min(ans,call(pow(2,i),i));
            }
		}
		if (L - ans + EPS > 0) puts("OK");
		else puts("NA");
		maxbit=0;
	}
	return 0;
}

Measured memory_bytes: 2056
n = int(input())
dat = list(map(int, input().split()))
res = [0] * n
#print("dat: {0}".format(dat))
for i in range(n, 0, -1):
    # i-1で参照すること
    #print(i)
    t = 0
    for j in range(0, n // i):
        #print("add:{0}".format( str( ((j+1) * i) -1 )  ))
        t += res[ ((j+1) * i) -1]

    #print("i[{0}]:  t = {1}".format(i, t))

    if t % 2 == 1:
        if dat[i-1] == 1:
            res[i-1] = 0
        else:
            res[i-1] = 1
    else:
        if dat[i-1] == 1:
            res[i-1] = 1
        else:
            res[i-1] = 0

    #print(res[i-1])
    #print("res: {0}".format(res))

#print(res)

c = 0
for i in range(n):
    if res[i] == 1:
        c += 1

resl = []
resc = c
for i in range(n):
    if c == 0:
        break
    if res[i] == 1:
        c -= 1
        resl.append(str(i + 1))
    else:
        pass
        # resl.append("0")

print( resc )
if resc !=0:
    print(" ".join(resl))


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

using namespace std;

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



Measured memory_bytes: 3616
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int g = sc.nextInt();
		int b = sc.nextInt();
		int n = sc.nextInt();
		// long[] a = new long[n];
		// for (int i = 0; i < n; i++) {
		// a[i] = sc.nextLong();
		// }
		sc.close();
		int ans = 0;
		for (int R = 0; R <= n / r; R++) {
			for (int G = 0; G <= (n - r * R) / g; G++) {
				// System.out.println(R + " " + G + "");
				if ((n - r * R - g * G) % b == 0)
					ans++;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23636
#include<stdio.h>
int dpRR[100][100];
int dpUR[100][100];
int dpUU[100][100];
int dpRU[100][100];
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a){
		for(int i=0;i<a;i++)dpRR[i][0]=1;
		for(int i=0;i<b;i++)dpUU[0][i]=1;
		for(int i=1;i<a;i++){
			for(int j=1;j<b;j++){
				dpUR[i][j]=dpUU[i-1][j];
				dpRR[i][j]=(dpUR[i-1][j]+dpRR[i-1][j])%100000;
				dpRU[i][j]=dpRR[i][j-1];
				dpUU[i][j]=(dpRU[i][j-1]+dpUU[i][j-1])%100000;
				//printf("%d %d: %d %d %d %d\n",i,j,dpRR[i][j],dpUR[i][j],dpUU[i][j],dpRU[i][j]);
			}
		}
		int ret=(dpUR[a-1][b-1]+dpRR[a-1][b-1]+dpUU[a-1][b-1]+dpRU[a-1][b-1])%100000;
		printf("%d\n",ret);
	}
}

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

public class Main {
	public static void main(String args[]) {	
		Scanner sc = new Scanner(System.in);
		String n = sc.nextLine();
		String s = sc.nextLine();
		
		HashMap<String,String> alpha = new HashMap<String,String>();
		long count = 1;
		for(int i = 0;i < Integer.parseInt(n);i++) {
			char mark = s.charAt(i);
			if(alpha.containsKey(String.valueOf(mark))) {
				
			}else {
				alpha.put(String.valueOf(mark), "");
				int sum=0;
				for(int j=i;j<Integer.parseInt(n);j++ ) {
					if(s.charAt(j) == mark){
						sum++;
					}
				}
				count = count%1000000007;
				count *= sum+1;
			}
			
		}
		
		System.out.println((count-1)%1000000007);
	}
}


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

int get_num(vector<vector<char>> &s,int h, int w,int H,int W){
  int cnt =0;
  for(int i =max(h-1,0); i <=min(h+1,H-1); i++)
    for(int j =max(w-1,0); j <=min(w+1,W-1); j++)
      if(s.at(i).at(j) == '#')cnt++;
  return cnt;
}

int main() {
  int H,W;
  cin >> H >> W;
  vector<vector<char>> s(H,vector<char>(W));
  
  for(int i=0; i <H; i++)
    for(int j=0; j<W; j++)
      cin >> s.at(i).at(j);
  
  for(int i=0; i<H; i++)
    for(int j=0; j<W; j++){
      if(s.at(i).at(j) == '#') cout << '#';
      else cout << get_num(s,i,j,H,W);
      if(j == W-1) cout << endl;
    }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define djfs first
#define akdk second
#define N 100000000
#define fo(i,m,n) for(int i=m;i<n;i++)
#define M 7
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
using ll=long long;
using ul=unsigned long long;
using pii=pair<int,int>;
using vvi=vector<vector<int>>;
using vi=vector<int>;
using pll=pair<ll,ll>;
using vsi=vector<set<int>>;
using vll=vector<ll>;

ll power(ll a,ll n){
    ll j=0;
    ll x=1;
    while(1ll<<j<=n){
        if(1ll<<j&n)
            x=(x*a)%mod;

        a=a*a%mod;
        j++;
    }

    return x;
}

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

}

int lb(vi &a,int x){
    int n=a.size();
    int l=0;
    int r=n-1;
    int ind=-1;
    while(l<=r){
        int mid=(l+r)/2;
        if(x>=a[mid]){
            l=mid+1;
            ind=mid;
        }
        else
            r=mid-1;

    }

    return ind+1;

}

int up(vll &a,ll x){
    int n=a.size();
    int l=0;
    int r=n-1;
    int ind=-1;

    while(l<=r){
        int mid=(l+r)/2;
        if(a[mid]>x){
            r=mid-1;
            ind=mid;
        }
        else
            l=mid+1;

    }

    return ind;
}

ll max(ll a,ll b){
    if(a>b)
        return a;
    else
        return b;

}

ll min(ll a, ll b){
    if(a>b)
        return b;
    else
        return a;

}

void yn(bool a){
    if(a)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;

}


bool isodd(int a,int b,int agx,int agy){

    return (abs(a-agx)+abs(b-agy))%2;

}
int fap(vi &par,int x){
    if(par[x]!=x)
        par[x]=fap(par,par[x]);

    return par[x];
}

void unin(vi &par,vi &rank,int x,int y){
    int px=fap(par,x);
    int py=fap(par,y);

    if(px!=py){
        if(rank[px]<rank[py])
            swap(px,py);

        par[py]=px;
        rank[px]+=rank[py];
    }
}

struct fenwick_tree
{
    vll bit;
    int n;
    fenwick_tree(int n){
        this->n=n;
        bit=vll(n+1);
    }

    void update(int idx,ll val){
        while(idx<=n){
            bit[idx]+=val;
            idx+=idx&-idx;
        }
    }

    void rupdate(int l,int r,int x){
        update(l,x);
        update(r+1,-x);
    }

    ll query(int idx){
        ll tot=0;
        while(idx){
            tot+=bit[idx];
            idx-=idx&-idx;
        }

        return tot;
    }

};


int main(){

    int n;
    cin>>n;

    int pts[n][2];

    fo(i,0,n)
            cin>>pts[i][0]>>pts[i][1];

    int pma=INT_MIN;
    int pmi=INT_MAX;
    int nma=INT_MIN;
    int nmi=INT_MAX;
    fo(i,0,n){
        pma=max(pts[i][0]+pts[i][1],pma);
        pmi=min(pts[i][0]+pts[i][1],pmi);
        nma=max(pts[i][0]-pts[i][1],nma);
        nmi=min(pts[i][0]-pts[i][1],nmi);
    }

    int ans=max(pma-pmi,nma-nmi);
    cout<<ans<<endl;

}


Measured memory_bytes: 5192
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <stdio.h>

using namespace std;

//typedefリスト
typedef vector<int> vint;
typedef vector<string> vstr;




int main(void) {
	int H, W,n;
	cin >> H >> W;
	n = 0;
	vector<char> a(H*W);
	for (int i = 0; i < H*W; i++)cin >> a[i];

	for (int i = 0; i < W + 1; i++) cout << '#';

	cout << '#' << endl;

	for (int i = 1; i <= H*(W + 2);i++) {
		if (i%(W + 2) == 1)cout << '#';
		else if (i%(W + 2) == 0)cout << '#' << endl;
		else {
			cout << a[n];
			n++;
		}
	}
	for (int i = 0; i < W + 1; i++) cout << '#';

	cout << '#' << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

struct list{
	char name[15];
	int time;
};
struct list node[100005];

int main()
{
	int n,ti,T=0;
	int i=0;
	scanf("%d%d",&n,&ti);
	int coun=n;
	while(coun--)
	{
		scanf("%s %d",&node[i].name,&node[i].time);
		i++;
	}
	for(int head=0,tail=n;head!=tail;head=(head+1)%(n+1))
	{
		i=head;
		if(node[i].time<=ti)
		{
			T+=node[i].time;
			printf("%s %d\n",node[i].name,T);
			node[i].time=0;
		}
		else
		{
			T+=ti;
			node[tail].time=node[i].time-ti;
			strcpy(node[tail].name,node[i].name);
			tail=(tail+1)%(n+1);
		}
	}
	return 0;
}



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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll to;
	ll cost;
};
using Graph = vector<vector<Edge>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 2.0 * asin(1.0);
const ll INF = 1L<<60;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MAX = 10000000;
/****** define constant end ********/
/****** define variable start ******/
ll n, m, k;
vl a, b;
/******* define variable end *******/
int solve() {
	cin >> n >> m >> k;
	a.resize(n);
	b.resize(m);
	REP(i, n){
		cin >> a[i];
	}
	REP(i, m){
		cin >> b[i];
	}
	vl suma(n+1);
	vl sumb(m+1);
	sumb[0] = 0;
	suma[0] = 0;
	REP(i, n){
		suma[i+1] = suma[i] + a[i];
	}
	REP(i, m){
		sumb[i+1] = sumb[i] + b[i];
	}
	ll ans = 0;
	REP(i, n+1){
		ll a_sum = suma[i];
		if(a_sum > k) continue;
		auto ite = upper_bound(ALL(sumb), k - a_sum);
		ll anst = i + ite-sumb.begin()-1;
		ans = max(anst, ans);
	}
	cout << ans << endl;
	return 0;
}

int main() {
	//clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


Measured memory_bytes: 9532
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>



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

using namespace std;
string a,b,c;

int main(){
  cin >> a >> b >> c;
  if(a[a.size()-1]==b[0] && b[b.size()-1]==c[0]) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll sum = 0;
    int N;
    cin >> N;
    int mx = 0;
    for(int i=0; i<N; i++){
        int a;
        cin >> a;
        sum += a;
        chmax(mx,a);
    }
    if(mx < sum-mx){
        cout << "Yes" << enld;
    }else{
        cout << "No" << enld;
    }
    return 0;
}

Measured memory_bytes: 256
#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 pb push_back


/* alias */


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


/* constant */
const int inf = 1000100010010010;
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};
const string alpha = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
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; }




/* main */
int n;
vi arr;
vi dp(100010, -1);

int dfs(int i){

	if(i >= n - 1) return 0;

	if(dp[i] > - 1) return dp[i];

	int ans = inf;
	if(i < n - 1) chmin(ans, abs(arr[i] - arr[i + 1]) + dfs(i + 1));
	if(i < n - 2) chmin(ans, abs(arr[i] - arr[i + 2]) + dfs(i + 2));

	return dp[i] = ans;


	



}



signed main(){


    cin.tie(0);
    ios::sync_with_stdio(false);

	n = input();
	rep(i,0,n) arr.push_back(input());

	print(dfs(0));




    



	








    



    





    


    

}



Measured memory_bytes: 5108
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import scipy as scp

# 入力の受け取り
n = int(input())
arrA = list(map(int,input().split()))

while len(arrA)>1:
    arrA.sort(reverse = True)
    num = (arrA.pop() + arrA.pop()) / 2
    arrA.append(num)

print(*arrA)
# print("{:.10f}".format(ans))
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する



Measured memory_bytes: 2940
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
res = 1
for i in range(n):
    res *= i+1
    res %= mod
print(res)

Measured memory_bytes: 65900
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
// #include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main() //input->compute->output
{
        int N, K;
        cin >> N;

        cout << N * (N +1) / 2 << endl;

        return 0;
}

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

using namespace std;

#define mod 1000000007
#define pb push_back
#define mk make_pair
#define ff first
#define ss second

int inp[55];
int n;
long long dp[55][55][55*50];

long long solve(int ind, int rem, int sum){

    if(sum<0) return 0;
    if(rem<0) return 0;
    if(ind==n){
        if(sum==0 && rem==0)
        return 1;
        else return 0;
    }

    if(dp[ind][rem][sum]!=-1) return dp[ind][rem][sum];

    long long ans = solve(ind+1,rem,sum);
    if(rem!=0 && sum>=inp[ind]){
        ans=ans+solve(ind+1,rem-1,sum-inp[ind]);
    }
    dp[ind][rem][sum]=ans;
    return ans;

}


int main(){

    int a;
    cin>>n>>a;
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<n;i++){
        cin>>inp[i];
    }
    long long ans = 0;
    for(int i=1;i<=n;i++){
        ans=ans+solve(0,i,a*i);
    }
    cout<<ans<<endl;

	return 0;
}



Measured memory_bytes: 65280
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll, ll>
using namespace std;
 
 
int main(){
    int a,p; cin  >> a >> p;
    cout << (a*3+p)/2 << endl;
return 0;
}

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

int main(void) {
  int N;
  cin >> N;
  vector<int> H(N);
  rep(i, N) {
    cin >> H[i];
  }

  reverse(H.begin(), H.end());

  int maxCount = 0;
  int count = 0;

  for (int i = 1; i < N; ++i) {
    if (H[i - 1] <= H[i]) {
      count++;
    } else {
      count = 0;
    }
    maxCount = max(count, maxCount);
  }

  cout << maxCount << endl;
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<int,int>
#define lowbit(i) i&-i
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	ull ans=0; For(i,0,5)ans=ans<<15^rand(); return ans;
}
ll ycl[20],f[10],ans,d,L;
ll xqz(ll x,ll y){
	if(x>=0)return x/y;
	x=-x;
	x--; return -x/y-1;
}
void dfs(int p,ll xs,ll d){
	if(p==L/2){
		if(d==0)ans+=xs*((L&1)?10:1); return;
	}
	ll cz=ycl[L-1-p]-ycl[p],t=xqz(d,cz);
	//cout<<d<<" "<<cz<<" "<<t<<" "<<L/2<<endl;
	if(abs(t)<=9){
		dfs(p+1,xs*(f[abs(t)]-(p==0&&t>=0)),d-t*cz);
	}
	t++;
	if(abs(t)<=9){
		dfs(p+1,xs*(f[abs(t)]-(p==0&&t>=0)),d-t*cz);
	}
}
void get(int len,ll d){
	L=len;
	dfs(0,1,d);
}
int main(){
	For(i,0,9)For(j,0,i)f[i-j]++;
	d=read();
	int ws=1;
	For(i,ycl[0]=1,18){ycl[i]=ycl[i-1]*10; if(d>=ycl[i])ws++;}
	//get(2,d); cerr<<ans<<endl; return 0;
	For(i,max(2,ws),2*ws){
		get(i,d);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long n,a[300100];
long long ans;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	long long g=1;	
	for(int i=0;i<=60;i++)
	{
		long long h=0;
		for(int o=0;o<n;o++)
			if((a[o] & g) == g)
				h++;
		ans+=((((h)*(n-h))%1000000007)*(g%1000000007)%1000000007);
		g*=2;
	}	
	cout<<ans%1000000007<<endl;
} 

Measured memory_bytes: 2560
#include <stdio.h>

int main() {
  int N;
  scanf("%d", &N);
  long long int arr[N], max = 1e18, prod = 1, flag = 0, zero = 0;
  
  for (int i = 0; i < N; i++) {
    scanf("%lld", &arr[i]);
    flag = (arr[i] > max) ? 1 : flag;
    prod *= arr[i];
    (arr[i]) ? max /= arr[i] : zero = 1;
  }

  (zero) ? puts("0") : ((flag) ? puts("-1") : printf("%lld\n", prod));
  return 0;
}

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

using namespace std;

long long dp[51][51][101];

long long arr[51];

long long solve(int i, int j, int k){
    if(k == 0) return 0;
    if(k < 0)return -1e10;
    if(i > j)return 0;
    if(dp[i][j][k] != -1)return dp[i][j][k];
    long long resp = 0;
    resp = max(resp, solve(i + 1, j, k - 2));
    resp = max(resp, solve(i + 1, j, k - 1) + arr[i]);
    resp = max(resp, solve(i, j - 1, k - 2));
    resp = max(resp, solve(i , j - 1, k - 1) + arr[j]);
    return dp[i][j][k] = resp;
}

int main(){
    memset(dp, -1, sizeof dp);
    int n, k;
    scanf("%d %d", &n, &k);
    for(int i = 0; i < n; i++){
        scanf("%lld", &arr[i]);
    }  
    printf("%lld\n", solve(0, n - 1, k));
    return 0;
}

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

int main(){
    int64_t a,b;
    cin >> a >> b;
    if((a+b)%2 == 1){
        cout << "IMPOSSIBLE" << endl;
        return 0; 
    }
    int p = abs(a+b);
    cout << p / 2 << endl;
}

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

using namespace std;

typedef long long ll;

int main() {
    ll n, i, j;
    cin >> n;
    vector<ll> A(n);
    for(i = 0; i < n; i++) {
        cin >> A[i];
    }
    ll ret = 0;
    ll now = 0;
    for(ll x : A) {
        if(x % (now+1) != 0){
            ret += x / (now+1);
        } else {
            ret += (x / (now+1)) - 1;
        }
        if(x == now + 1) {
            now = x;
        }
        if(now == 0) now = 1;
        //cout << now << endl;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void) {
	int a,b,sum,digit;

	while(scanf("%d %d",&a,&b)!=EOF) {
		for(sum=a+b,digit=0;sum>0;sum/=10) {
			digit++;
		}
		printf("%d\n",digit);
	}
	return 0;
}

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
int a[125252];
int b[125252];
int c[125252];
int d[125252];

int data[125252];
void init(){
  REP(i,125252)data[i] = -1;
}
int root(int x){
  return data[x]<0 ? x : data[x] = root(data[x]);
}
void unite(int a,int b){
  a = root(a);
  b = root(b);
  if(a!=b){
    if(data[a]>data[b])swap(a,b);
    data[a] += data[b];
    data[b] = a;
  }
}

int main(){
  scanf("%d",&n);
  REP(i,n)scanf("%d",a+i);
  REP(i,n)scanf("%d",b+i);
  REP(i,n)a[n]^=a[i];
  REP(i,n)b[n]^=b[i];
  {
    // same check
    REP(i,n+1)c[i] = a[i];
    REP(i,n+1)d[i] = b[i];
    sort(c,c+n+1);
    sort(d,d+n+1);
    REP(i,n+1)if(c[i]!=d[i]){
      puts("-1");
      return 0;
    }
    // zaatu
    int m = unique(c,c+n+1)-c;
    REP(i,n+1)a[i] = lower_bound(c,c+m,a[i])-c;
    REP(i,n+1)b[i] = lower_bound(c,c+m,b[i])-c;
  }
  int ans = 0;
  init();
  REP(i,n)if(a[i]!=b[i]){
    ans++;
    unite(a[i],b[i]);
  }
  REP(i,n)if(root(i)==i && -data[i]>=2)ans++;
  if(-data[root(a[n])]>=2)ans--;
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 2304
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
#define ref(i,x,y)for(int i=x;i<=y;++i)
#define def(i,x,y)for(int i=x;i>=y;--i)
const int N=100001;
int n,cnt,head[N],du[N];
struct xint{int to,next;}e[N*2];
void addedge(int x,int y){
	e[++cnt]=(xint){y,head[x]};head[x]=cnt;
	e[++cnt]=(xint){x,head[y]};head[y]=cnt;
	du[x]++;du[y]++;
}
int Mid,p[N],f[N],a[N];
int top,stk[N];bool mk[N];
bool Check(){
	ref(i,1,p[0])mk[i]=0;
	int pos=1;top=0;
	def(i,p[0],1)if(!mk[i]){
		if(pos>i)pos=i;
		while(top>0&&stk[top]>=i)top--;
		while(pos<i&&p[pos]+p[i]<=Mid)stk[++top]=pos,pos++;
		if(!top)return 0;
		mk[stk[top]]=1;top--;mk[i]=1;
	}
	return 1;
}
bool check(int x){
	a[0]=0;
	ref(i,1,p[0])if(i!=x)a[++a[0]]=p[i];
	if(a[0]&1)a[0]--;
	ref(i,1,a[0])mk[i]=0;
	int pos=1;top=0;
	def(i,a[0],1)if(!mk[i]){
		if(pos>i)pos=i;
		while(top>0&&stk[top]>=i)top--;
		while(pos<i&&a[pos]+a[i]<=Mid)stk[++top]=pos,pos++;
		if(!top)return 0;
		mk[stk[top]]=1;top--;mk[i]=1;
	}
	return 1;
}
void dfs(int fa,int x){
	for(int i=head[x];i;i=e[i].next){
		int y=e[i].to;if(y==fa)continue;dfs(x,y);
	}
	p[0]=0;
	for(int i=head[x];i;i=e[i].next){
		int y=e[i].to;if(y==fa)continue;
		p[++p[0]]=f[y]+1;
		if(p[p[0]]>Mid){f[x]=1e9;return;}
	}
	if(!p[0]){f[x]=0;return;}
	sort(p+1,p+p[0]+1);
	if(x==1&&!(p[0]&1)){
		if(!Check())f[x]=1e9;else f[x]=0;
		return;
	}
	if(!(p[0]&1)&&Check()){f[x]=0;return;}
	int l=1,r=p[0]+1;
	while(l<r){
		int mid=(l+r)>>1;
		if(check(mid))r=mid;else l=mid+1;
	}
	if(l==p[0]+1){f[x]=1e9;return;}
	f[x]=p[l];
}
int main(){
	scanf("%d",&n);
	ref(i,2,n){
		int x,y;
		scanf("%d%d",&x,&y);
		addedge(x,y);
	}
	int tot=0;
	ref(i,1,n)if(du[i]&1)tot++;
	cout<<tot/2<<" ";
	int L=1,R=n-1;
	while(L<R){
		memset(f,0,sizeof f);
		Mid=(L+R)>>1;
		dfs(0,1);
		if(f[1]<=Mid)R=Mid;else L=Mid+1;
	}
	cout<<L<<endl;
}

Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
const int INT_INF = 1001001001;
//stoi(s) : string→int stoll(s) :string→longlong


int main(){
    int n;
    cin >> n;
    int p = n%10;
    if(p==2||p==4||p==5||p==7||p==9){
        cout << "hon" << endl;
    }else if(p==0||p==1||p==6||p==8)
    {
        cout << "pon" << endl;
    }else{
        cout<< "bon" << endl;
    }
}

Measured memory_bytes: 3620
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<cassert>
#include<atcoder/all>
using namespace std;
using namespace atcoder;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll BIG = 1'000'000'000; //'

void solve() {
	int n, k; cin >> n >> k;
    vector<vector<int>> a(n, vector<int>(n));
    rep(i, n) {
        rep(j, n) {
            cin >> a[i][j];
        }
    }
    mcf_graph<int, long long> g(2 * n + 2);
    int s = 2 * n, t = 2 * n + 1;
    // we can waste the flow
    g.add_edge(s, t, n * k, BIG);
    rep(i, n) {
        g.add_edge(s, i, k, 0);
        g.add_edge(n + i, t, k, 0);
    }
    rep(i, n) {
        rep(j, n) {
            g.add_edge(i, n + j, 1, BIG - a[i][j] * 1LL);
        }
    }
    auto result = g.flow(s, t, n * k);
    cout << 1LL * n * k * BIG - result.sc << endl;
    vector<vector<char>> grid(n, vector<char>(n, '.'));
    auto es = g.edges();
    for(auto e: es) {
        if(e.from == s || e.to == t || e.flow == 0) continue;
        grid[e.from][e.to - n] = 'X'; 
    }
    rep(i, n) {
        rep(j, n) {
            cout << grid[i][j];
        }
        cout << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 3920
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned ll
#define PI acos(-1)
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<typename T> using v2 = vector<vector<T>>;
template<typename T> using v3 = vector<vector<vector<T>>>;
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
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 int MOD = 1e9 + 7;
const int INF = 1e9 + 200;
const ll INFLL = 2e18 + 200;

// Last updated 2020-05-09
class UnionFind {
private:
    vector<int> data;

public:
    explicit UnionFind(size_t data_size) : data(data_size, -1)  {}

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if(x == y) return false;
        if(data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return true;
    }

    int find(size_t index) {
        if (data[index] < 0) return index;
        else return (data[index] = find(data[index]));
    }

    int size(size_t index) {
        return (-data[find(index)]);
    }
};

int main() {
    int N, M;
    cin >> N >> M;
    UnionFind uf(N);
    for (int i = 0; i < M; i++) {
        int A, B;
        cin >> A >> B;
        A--; B--;
        uf.unite(A, B);
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
        chmax(ans, uf.size(i));
    }
    cout << ans << endl;
}

Measured memory_bytes: 4048
import numpy as np
n, m, c = map(int, input().split())
B = np.array(list(map(int, input().split())))
ans = 0
for _ in range(n):
    A = np.array(list(map(int, input().split())))
    if np.dot(A, B)+c > 0:
        ans += 1

print(ans)

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

int main() {
  int A, B, C, D;
  int N;
  vector<int> team;
  vector<int> score;

  cin >> N;

  for(int i = 0; i < N; i++) {
    team.push_back(0);
  }

  for(int i = 0; i < N * (N - 1) / 2; i++) {
    cin >> A >> B >> C >> D;

    if(C > D)
      team[A-1] += 3;
    else if(C == D) {
      team[A-1] += 1;
      team[B-1] += 1;
    }
    else
      team[B-1] += 3;
  }

  for(int i = 0; i < N; i++) {
    score.push_back(team[i]);
  }

  sort(score.begin(), score.end(), greater<int>());

  for(int i = 0; i < N; i++) {
    for(int j = 0; j < score.size(); j++) {
      if(team[i] == score[j]) {
        cout << j+1 << endl;
        break;
      }
    }
  }

  team.clear();
  score.clear();
  return 0;
}



Measured memory_bytes: 3120
import sys

a, b = map(int, input().split())
s = input()

for i in range(a + b + 1):
  if i < a and s[i] == '-':
    print('No')
    sys.exit()
  elif i == a and s[i] != '-':
    print('No')
    sys.exit()
  elif i > a + 1 and s[i] == '-':
    print('No')
    sys.exit()
print('Yes')

Measured memory_bytes: 9072
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
typedef long long ll;
const int INF = 1000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007ll;


int main(){
	string s;
	std::cin >> s;
	set<char> ss;
	rep(i,s.size())ss.insert(s[i]);
	if(s.size()==ss.size())std::cout << "yes" << std::endl;
	else std::cout << "no" << std::endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;

internal static class CR
{
    public static string GetText() { return Console.ReadLine(); }
    public static List<string> GetTexts() { return Console.ReadLine().Split(' ').ToList(); }
    public static long GetLong() { return long.Parse(Console.ReadLine()); }
    public static List<long> GetLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }
}

namespace AtCoder.D
{
    public class Program
    {
        public static string S { get; private set; }
        public static long Q { get; private set; }

        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            S = CR.GetText();
            Q = CR.GetLong();

            var sbPrefix = new StringBuilder();
            var sbSuffix = new StringBuilder();

            var isReverse = false;
            for (int i = 0; i < Q; i++)
            {
                var q = CR.GetTexts();
                if (q[0] == "1")
                {
                    isReverse = !isReverse;
                    var temp = sbPrefix;
                    sbPrefix = sbSuffix;
                    sbSuffix = temp;
                    continue;
                }

                if (q[1] == "1")
                {
                    sbPrefix.Append(q[2]);
                }
                else
                {
                    sbSuffix.Append(q[2]);
                }
            }
            return new string(sbPrefix.ToString().Reverse().ToArray())
                + (isReverse ? new string(S.Reverse().ToArray()) : S)
                + sbSuffix.ToString();
        }
    }
}


Measured memory_bytes: 20000
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    vector<vector<int>> ans(h, vector<int>(w, 0));
    rep(i, h)rep(j, w){
        if((i<b&&j<a) || (i>=b&&j>=a))ans[i][j] = 1;
    }
    rep(i, h){
        rep(j, w)cout << ans[i][j];
        cout << endl;
    }
    
}

Measured memory_bytes: 7516
use std::io::*;
use std::str::FromStr;

fn main(){
    let (n,m) = (read::<i64>(),read::<i64>());
    println!("{}",if n==1{
        if m==1{1}
        else if m==2{0}
        else{m-2}
    }else if n==2{
        0
    }else{
        if m==1{n-2}
        else if m==2{0}
        else{(n-2)*(m-2)}
    });
}
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin.bytes().map(|c| c.expect("Error") as char) 
        .skip_while(|c| c.is_whitespace()).take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("Error")
}

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

class Cube {
public:
	int f[6];
	Cube(){}
	void roll_z() { roll(1, 2, 4, 3); }
	void roll_y() { roll(0, 2, 5, 3); }//to W
	void roll_x() { roll(0, 1, 5, 4); }//to N
	void roll(int i, int j, int k, int l) {
		int t = f[i]; f[i] = f[j]; f[j] = f[k]; f[k] = f[l]; f[l] = t;
	}
	void move(char ch) {
		if (ch == 'E')for (int i = 0; i < 3; i++)roll_y();
		if (ch == 'W')roll_y();
		if (ch == 'N')roll_x();
		if (ch == 'S')for (int i = 0; i < 3; i++)roll_x();
	}
};

int main()
{
	Cube c;
	string com;

	for (int i = 0; i < 6; i++)cin >> c.f[i];

	cin >> com;

	for (int i = 0; i < com.size(); i++)c.move(com[i]);

	cout << c.f[0] << endl;

	return 0;
}

Measured memory_bytes: 3224
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/math/special_functions.hpp>

using namespace std;
using namespace boost::math;
using namespace boost::adaptors;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

namespace mymath {
    ll combination(ll r, ll k) {
        ll ret{1};
        if (k == 0 || k == r) return ret;

        ll _k = r - k;
        if (k > _k) swap(k, _k);
        for (int i = 0; i < k; i++) {
            assert(ret < numeric_limits<ll>::max() / (r - k + i + 1));
            ret *= r - k + i + 1;
            ret /= i + 1;
        }
        return ret;
    }

    ll pow(ll base, ll exponent) {
        if (exponent == 0) return 1;
        else if (exponent == 1) return base;
        else {
            ll half = pow(base, exponent / 2);
            assert(abs(half) < 3037000500LL);
            ll full = half * half;
            if (exponent % 2 == 0) {
                return full;
            } else {
                assert(full < numeric_limits<ll>::max() / abs(base));
                return base * full;
            }
        }
    }
}


int main() {
    ll N, A, B;
    cin >> N >> A >> B;
    vector<ll> vs;
    for (auto &&i: boost::irange(0LL, N)) {
        ll v;
        cin >> v;
        vs.emplace_back(v);
    }
    sort(vs.begin(), vs.end(), greater<>());

    ll s{0};
    double ave;
    if (vs.front() == vs.at(A-1)) {
        // この場合，同じ数だったら何個選んでも同じ
        ave = (double)vs.front();
        ll n{0};
        for (auto &&i: boost::irange(0LL, N)){
            if (vs.at(i) == vs.at(A-1)){
                n++;
            }
        }
        ll count{0};
        for (auto &&i: boost::irange(A, min(n, B)+1)){
            count += mymath::combination(n, i);
        }

        cout << fixed << ave << endl;
        cout << count << endl;

    } else {
        // この場合，同じ数たちのなかから，何個選ぶか問題
        for (auto &&i: boost::irange(0LL, A)) {
            s += vs.at(i);
        }
        ave = (double)s / (double)A;
        // ここから先がケタ落ちとの戦い
        // 答えはnCaで良い
        ll n{0};
        for (auto &&i: boost::irange(0LL, N)){
            if (vs.at(i) == vs.at(A-1)){
                n++;
            }
        }
        ll a{0};
        for (auto &&i: boost::irange(0LL, A)){
            if (vs.at(i) == vs.at(A-1)){
                a++;
            }
        }
        cout << fixed << ave << endl;
        cout << mymath::combination(n, a) << endl;
    }


    return 0;
}

Measured memory_bytes: 256