akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
using namespace std;
typedef long long LL;

int main(void) {
	string s;
	cin >> s;
	for (;;) {

		s.pop_back();
		if (s.size() % 2 == 0) {
			for (int j = 0; j < s.size() / 2; j++) {
				if (s[j] != s[j + (s.size() / 2)])break;
				if (j == s.size()/2-1) {
					cout << s.size() << endl;
					return 0;
				}
			}
		}
	}
	return 0;
}

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

string b2a(bool result) {
  if(result) {
    return "Yay!";
  } else {
    return ":(";
  }
}

bool check(int points[], int size, int k) {
  for (int i = 0; i < 5; i++) {
    for (int j = i + 1; j < 5; j++) {
      if (abs(points[i] - points[j]) > k) {
        return false;
      }
    }
  }
  return true;
}

int main() {
  int points[5];
  int k;
  for (int i = 0; i < 5; i++) {
    cin >> points[i];
  }
  cin >> k;
  bool result = check(points, 5, k);
  cout << b2a(result);
  return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Scanner;

public class Main{
	static final int MOD = 1000000007;
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		//入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		long[] x = new long[n];
		long[] y = new long[m];
		for(int i = 0; i < n; i++){
			x[i] = sc.nextLong();
		}
		for(int i = 0; i < m; i++){
			y[i] = sc.nextLong();
		}
		sc.close();

		//処理
		long tx = 0;
		long ty = 0;
		for(int i = 0; i < n; i++){
			tx += i * x[i] - (n - i - 1) * x[i];
			tx %= MOD;
		}
		for(int i = 0; i < m; i++){
			ty += i * y[i] - (m - i - 1) * y[i];
			ty %= MOD;
		}

		//出力	
		out.println((tx * ty) % MOD);
		out.flush();
	}
}

Measured memory_bytes: 91188
// AOJ 0504: Card Game II
// 2017.12.6 bal4u@uu

#include <stdio.h>
#include <string.h>

#define N 6
char ans[10015], *ap = ans+1;
int  d[10015];

void calc(int b, int n)
{
	int i, a;

	for (a = 1, i = 0; a > 0 && i <= n; i++) {
		d[i] += a / b, a %= b;
		a *= 10;
	}
}

int main()
{
	int n, k, m, r, i;
	
	while (scanf("%d%d%d%d", &n, &k, &m, &r) && n > 0) {
		r += N;

		memset(d, 0, sizeof(d));
		calc(n, r);
		if (m == 1) for (k = n, i = 1; i < n; i++, k+=n) calc(k, r);
		for (k = 0, i = r; i >= 0; i--) {
			k += d[i];
			ap[i] = '0' + k % 10;
			k /= 10;
		}
		ans[0] = ans[1], ans[1] = '.';
		ans[r-N+2] = 0;
		puts(ans);
	}
	return 0;
}

Measured memory_bytes: 1764
//T?????????????????????????±?????????????e??????????¢???????p[e]??¨????????¨, ?£cost[e] * p[e]????????????????????????
//T'?????????????????????????±?????????????????????¨????°??????§, T???????????????????????? + ?£(cost[e] + T????????????????????????) * p[e]????±????????????????
//??????, p[e] = p^(e??????????????????????????±??????????????§?????????)?????????????????£???, ??????????????±???(?????????????????°)???dfs??§?±?????????°?????????

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <tuple>
#include <cmath>
using namespace std;
typedef tuple<int, int, int> T;

double P;
int n;
vector<int> et[100000];
vector<T> edges;
int depth[100000];

void dfs(int p, int v, int dep = 0) {
	depth[v] = dep;
	for (int i = 0; i < et[v].size(); i++) {
		if (et[v][i] == p) continue;
		dfs(v, et[v][i], dep + 1);
	}
}

int main() {
	cin >> P >> n;
	for (int i = 0; i < n - 1; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		a--;
		b--;
		et[a].push_back(b);
		et[b].push_back(a);
		edges.push_back(T(a, b, c));
	}
	dfs(-1, 0);
	
	double expect = 0;
	static double p[100000];
	
	for (int i = 0; i < edges.size(); i++) {
		p[i] = pow(P, max(depth[get<0>(edges[i])], depth[get<1>(edges[i])]));
		expect += get<2>(edges[i]) * p[i];
	}
	
	double ans = expect;
	for (int i = 0; i < edges.size(); i++) {
		ans += (get<2>(edges[i]) + expect) * p[i];
	}
	
	printf("%.14f\n", ans);
	return 0;
}

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

using namespace std;

#define ll long long

const int N=1e6+5,MOD=1000000007;

int n,idx[N],a[N],q,m,u,v,tc,k,l,x,y,ans;

char s[N];

int main(){ 
    std::ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    
    scanf("%d%d",&n,&k);
    printf("%d\n",max(n-k,max(n+k,n*k)));
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

int N;
string s, ans;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> N >> s;
	for (int i = 0, j = 0; i < N; ++i)
	{
		for (j = i + 1; j < N && s[i] == s[j]; ++j);
		ans += s[i];
		i = j - 1;
	}
	cout << ans.size();
}

Measured memory_bytes: 592
#include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<fstream>
#include<algorithm>
using namespace std;
using ll = long long;

int main(){
    int n=0;
    int a,b;
    cin >> a >> b;
    while(b>n*a-n+1){
        n++;
    }
    cout << n << endl;
}

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

void rec(int d, long long val, vector<long long> &lunlun)
{
    lunlun.push_back(val);
    if (d == 10)
        return;

    for (int j = -1; j <= 1; j++)
    {
        int v = (val % 10) + j;
        if (0 <= v && v <= 9)
            rec(d + 1, val * 10 + v, lunlun);
    }
}

int main()
{
    int K;
    cin >> K;
    vector<long long> lunlun;
    for (int i = 1; i < 10; i++)
        rec(1, i, lunlun);
    sort(lunlun.begin(), lunlun.end());
    cout << lunlun[K - 1] << endl;
    return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n); for(long long i = 0;i < (n);i++)
typedef long long ll;
typedef vector<long long> vl;
// i ~ N-1の範囲にNの約数が存在するか
bool has_divisor(ll N, ll i) {
  // ベースケース1
  if (i == N) {
    return false;
  }
  // ベースケース2
  if (N % i == 0) {
    // 実際にiはNの約数なので、i ~ N-1の範囲に約数が存在する
    return true;
  }
 
  // 再帰ステップ
  // i+1 ~ N-1の範囲の結果がi ~ N-1の範囲の結果となる
  // (ベースケース2によって、iがNの約数の場合は取り除かれているので、あとはi+1 ~ N-1の範囲を調べればよい)
  return has_divisor(N, i + 1);
}
 
bool is_prime(ll N) {
  if (N == 1) {
    // 1は素数ではない
    return false;
  }
  else if (N == 2) {
    // 2は素数
    return true;
  }
  else {
    // 2~(N-1)の範囲に約数が無ければ、Nは素数
    return !has_divisor(N, 2);
  }
}
int main(){
	ll x; cin >> x;
  while (true){
    if(is_prime(x))break;
    x++;
  }
  cout << x << endl;
  
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
int main()
{
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int tot=read(),n=read(),sum=0;
	for(int i=1;i<=n;i++)sum+=read();
	if(sum>=tot)puts("Yes");
	else puts("No");
	return 0;
}

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

int main(){
  int n, a, b, c, d;
  string s;
  cin >> n >> a >> b >> c >> d;
  a--; b--; c--; d--;
  cin >> s;

  bool psb = true;
  for (int i = a; i < c; i++){
    if (s.at(i) == '#'){
      if (s.at(i + 1) == '#') psb = false;
    }
  }
  for (int i = b; i < d; i++){
    if (s.at(i) == '#'){
      if (s.at(i + 1) == '#') psb = false;
    }
  }

  if (!psb){
    cout << "No" << endl;
    return 0;
  }

  if (d < c){
    psb = false;
    for (int i = b; i <= d; i++){
      if (s.at(i - 1) == '.' && s.at(i) == '.' && s.at(i + 1) == '.'){
        psb = true;
        break;
      }
    }
  }

  cout << (psb ? "Yes" : "No") << endl;
}

Measured memory_bytes: 640
PROGRAM ATCODER

implicit none
integer(16) :: i,j,n,m,k,ans=0,count
integer(16),allocatable :: a(:),b(:),c(:),d(:),i_d(:),index(:)

read*, n,m 
allocate(a(n),b(m),c(m))
read*, a(1:n)
do i = 1, m, 1
  read*, b(i),c(i)
end do

allocate(d(n+m),i_d(n+m),index(n+m))
i_d = 1

do i = 1, n+m, 1
  if ( i >= n+1 ) then
    d(i) = c(i-n)
    i_d(i) = b(i-n)
  else
    d(i) = a(i)
  end if
end do

call heapsort2(n+m,d,index)

count = n
do i = n+m, m+1, -1
  if ( count == 0 ) exit
  if ( i_d(index(i)) > 0 ) then
    if ( count - i_d(index(i)) <= 0 ) then
      ans = ans + count*d(i)
      exit
    end if
    ans = ans + i_d(index(i))*d(i)
    count = count - i_d(index(i))
  else
    ans = ans + d(i)
    count = count - 1
  end if
end do

print'(i0)', ans

contains
  subroutine heapsort2(n,array,turn)
  implicit none
  integer(16),intent(in)::n
  integer(16),intent(out)::turn(1:n)
  integer(16),intent(inout)::array(1:n)
  
  integer::i,k,j,l,m
  double precision::t
  
  if(n.le.0)then
     write(6,*)"Error, at heapsort"; stop
  endif
  if(n.eq.1)return

  do i=1,N
     turn(i)=i
  enddo

  l=n/2+1
  k=n
  do while(k.ne.1)
     if(l.gt.1)then
        l=l-1
        t=array(l)
        m=turn(l)
     else
        t=array(k)
        m=turn(k)
        array(k)=array(1)
        turn(k)=turn(1)
        k=k-1
        if(k.eq.1) then
           array(1)=t
           turn(1)=m
           exit
        endif
     endif
     i=l
     j=l+l
     do while(j.le.k)
        if(j.lt.k)then
           if(array(j).lt.array(j+1))j=j+1
        endif
        if (t.lt.array(j))then
           array(i)=array(j)
           turn(i)=turn(j)
           i=j
           j=j+j
        else
           j=k+1
        endif
     enddo
     array(i)=t
     turn(i)=m
  enddo

  return
  end subroutine heapsort2


END PROGRAM ATCODER

Measured memory_bytes: 14848
#include <stdio.h>

int c;

void merge(int a[],int n,int l,int mid,int r){
	int n1,n2,i,j,k;
	n1 = mid - l;
	n2 = r - mid;
	int left[n1],right[n2];
	for(i=0;i<n1;i++){
		left[i] = a[l + i];
	}
	for(i=0;i<n2;i++){
		right[i] = a[mid + i];
	}
	left[n1] = right[n2] = 2000000000;
	i=0;
	j=0;
	for(k=l;k<r;k++){
		c++;
		if(left[i] <= right[j]){
			a[k] = left[i++];
		}else{
			a[k] = right[j++];
		}
	}
}

void mergeSort(int a[],int n,int l,int r){
	int mid;
	if(l+1 < r){
		mid = (l+r)/2;
		mergeSort(a,n,l,mid);
		mergeSort(a,n,mid,r);
		merge(a,n,l,mid,r);
	}
}

int main(void){
	int n,i;
	int s[500000];
	c = 0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&s[i]);
	}
	mergeSort(s,n,0,n);
	for(i=0;i<n;i++){
		printf("%d",s[i]);
		if(i!=n-1)printf(" ");
	}
	printf("\n%d\n",c);
}


Measured memory_bytes: 5592
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>

#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)

using namespace std;

const int N = 100010;

typedef long long LL;

struct Segment_Tree{
	LL Min[N << 2], addv[N << 2];
	int pos[N << 2];

	#define lc (o << 1)
	#define rc (o << 1 | 1)
	#define M ((L + R) >> 1)

	void build(int o, int L, int R){
		if(L == R) pos[o] = L;
		else{
			build(lc, L, M), build(rc, M + 1, R);
			pushup(o);
		}
	}

	void pushup(int o){
		if(Min[lc] < Min[rc]) Min[o] = Min[lc] + addv[o], pos[o] = pos[lc];
		else Min[o] = Min[rc] + addv[o], pos[o] = pos[rc];
	}

	void modify(int o, int L, int R, int l, int r, LL v){
		if(l <= L && R <= r) addv[o] += v, Min[o] += v;
		else{
			if(l <= M) modify(lc, L, M, l, r, v);
			if(r > M) modify(rc, M + 1, R, l, r, v);
			pushup(o);
		}
	}

}T;

int Begin[N], Next[N << 1], to[N << 1], e;

void add(int u, int v){
	to[++e] = v, Next[e] = Begin[u], Begin[u] = e;
}

int n;
int top[N], id[N], sz[N], son[N], dep[N], fa[N];

void DFS_init(int o){
	sz[o] = 1;
	for(int i = Begin[o]; i; i = Next[i]){
		int u = to[i];
		if(u == fa[o]) continue;
		fa[u] = o, dep[u] = dep[o] + 1;
		DFS_init(u);
		sz[o] += sz[u];
		if(sz[u] > sz[son[o]]) son[o] = u;
	}
}

void DFS_partition(int o){
	static int clk = -1;
	top[o] = son[fa[o]] == o ? top[fa[o]] : o;
	id[o] = ++clk;
	if(son[o]) DFS_partition(son[o]);
	for(int i = Begin[o]; i; i = Next[i]){
		int u = to[i];
		if(u == fa[o] || u == son[o]) continue;
		DFS_partition(u);
	}
}

void add(int u, int v, int val){
	while(top[u] ^ top[v]){
		int x = top[u], y = top[v];
		if(dep[x] < dep[y]) swap(x, y), swap(u, v);
		T.modify(1, 1, n - 1, id[x], id[u], val);
		u = fa[x];
	}
	if(dep[u] < dep[v]) swap(u, v);
	if(u ^ v) T.modify(1, 1, n - 1, id[v] + 1, id[u], val);
}

int eu[N], ev[N];

int main(){
	scanf("%d", &n);
	For(i, 2, n){
		int u, v;
		scanf("%d%d", &u, &v);
		add(u, v), add(v, u);
	}
	DFS_init(1);
	DFS_partition(1);
	T.build(1, 1, n - 1);
	For(i, 1, n - 1){
		scanf("%d%d", &eu[i], &ev[i]);
		add(eu[i], ev[i], i + n);
	}
	For(i, 1, n - 1){
		LL x = T.Min[1];
		int p = T.pos[1];
		if(x >= 2 * n){
			puts("NO");
			return 0;
		}
		add(eu[x - n], ev[x - n], -x);
		T.modify(1, 1, n - 1, p, p, 1LL << 50);
	}
	puts("YES");
	return 0;
}

Measured memory_bytes: 16768
#include <stdio.h>
#include <stdlib.h>
#define MAX 10000

int main(){
  int i,j,n,q,c,key,cnt = 0,flag;
  int S[MAX],T[MAX];
  
  scanf("%d",&n);
  //if(n>=10001) exit(1);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  
  scanf("%d",&q);
  //if(q>=501) exit(2);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }

  
  for(i=0;i<q;i++){
    for(j=0;j<n;j++){
      if(S[j] == T[i]){
	cnt++;
	break;
      }
    }
  }

  printf("%d\n",cnt);
  
  return 0;
}



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

int main(void){
    int tmp;
    char s[100], p[100];
    scanf("%s", &s);
    scanf("%s", &p);
    for(int i=0; i<strlen(s); i++){
        if(s[i]==p[0]){
            for(int j=0; j<strlen(p); j++){
                if(i+j+1>strlen(s)) tmp = i+j-strlen(s);
                else tmp = i+j;
                if(s[tmp]!=p[j]) break;
                if(j+1==strlen(p)){
                    printf("Yes\n");
                    return 0;
                }
            }
        }
    }
    printf("No\n");
    return 0;
}


Measured memory_bytes: 2080
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main(void){
    ll x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<PL> p;
    REP(i,a) p.push_back(PL(in(), 0));
    REP(i,b) p.push_back(PL(in(), 1));
    REP(i,c) p.push_back(PL(in(), 2));
    sort(ALL(p));
    reverse(ALL(p));
    VL cnt(3);
    ll ans = 0;
    REP(i,a+b+c){
        cnt[p[i].second]++;
        if (cnt[0] <= x && cnt[1] <= y && cnt[0] + cnt[1] + cnt[2] <= x + y){
            ans += p[i].first;
        }else{
            cnt[p[i].second]--;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 10348
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define endl '\n'
#define ld long double
#define mid (l+r)/2
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
const int maxn=100005;
char s[maxn];
int fa[maxn];
int now,tot;
void newfa()
{
    fa[now]=++tot;
    now=tot;
}
void newson()
{
    fa[++tot]=now;
}
int main()
{
    #ifdef local
    freopen("in.txt","r",stdin);
    #endif
    cin>>s+1;
    int n=strlen(s+1);
    bool f=1;
    f&=(s[1]=='1');
    f&=(s[n]=='0');
    for(int i=1;i<=n/2;i++)
        if(s[i]!=s[n-i])
            f=0;
    if(!f)
    {
        cout<<"-1\n";
        return 0;
    }
    now=tot=1;
    newfa();
    for(int i=2;i<=n-1;i++)
    {
        if(s[i]=='0') newson();
        else newfa();
    }
    for(int i=1;i<=n-1;i++) cout<<i<<' '<<fa[i]<<endl;
}


Measured memory_bytes: 1920
#include <stdio.h>
#include <algorithm>

int main(void)
{
    while(true) {
        int M=0,m=50000,n,sum=0;
        scanf("%d", &n);
        if(n==0) break;
        for(int i=0; i < n; i++)
        {
            int s;
            scanf("%d", &s);
            M = std::max(s, M);
            m = std::min(s, m);
            sum += s;
        }
        printf("%d\n", (sum-M-m)/(n-2));
    }

    return 0;

}

Measured memory_bytes: 1028
D = int(input()) #365
c = list(map(int, input().split()))
s_matrix = [list(map(int, input().split())) for _ in range(D)]
last = [0] * 26
last_temp = []
satis = 0
satis_temp = []

for i in range(D):
    for k in range(26):
        satis2 = satis
        last2 = last.copy()

        satis2 += s_matrix[i][k]
        last2[k] = i + 1
        for j in range(26):
            satis2 -= c[j] * (i+1 - last2[j])
        
        satis_temp.append(satis2)
        last_temp.append(last2)
    
    satis = max(satis_temp)
    index = satis_temp.index(satis)
    last = last_temp[index]
    satis_temp = []
    last_temp = []

    print(index + 1)


Measured memory_bytes: 74624
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main()
{
    int n,m; cin >> n >> m;
    ll ans = 0;
    vector<int> a;
    for(int i = 0; i < n; i++){
        int tmp;
        cin >> tmp;
        a.push_back(tmp);
    }
    vector<P> cb;
    for(int i = 0; i < m; i++){
        int b,c;
        cin >> b >> c;
        cb.push_back(make_pair(c,b));
    }
    sort(a.begin(),a.end());
    sort(cb.rbegin(),cb.rend());
    int cnt = 0;
    for(int i = 0; i < n; i++){
        if(cnt > m){
            break;
        }
        if(a[i] < cb[cnt].first && cb[cnt].second > 0){
            a[i] = cb[cnt].first;
            cb[cnt].second--;
        }
        if(cb[cnt].second == 0){
            cnt++;
            continue;
        }
    }
    for(int i = 0; i < n; i++){
        ans += a[i];
    }
    cout << ans;
}


Measured memory_bytes: 1784
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define rep(i,x,y) for(int i=(x); i<(y); ++i)

template <typename T>
void vec_print(vector<T> VEC){
  rep(i, 0, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  rep(i, 0, MAT.size()){
    rep(j, 0, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(ll key, ll value){
      this->key = key;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value > obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value < obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N;
  cin >> N;
  vector<HOGE<ll, ll>> A_B;
  vll A_vec(N), B_vec(N);
  rep(i, 0, N){
    ll a, b;
    cin >> a >> b;
    HOGE<ll, ll> hoge(i, a+b);
    A_B.push_back(hoge);
    A_vec[i] = a;
    B_vec[i] = b;
  }

  sort(A_B.begin(), A_B.end());

  ll cnt_A=0;
  ll cnt_B=0;
  ll sum_A=0;
  ll sum_B=0;

  vector<bool> flag(N, false);

  rep(i, 0, N){
    ll pos = A_B[i].key;
    if(i%2==0) sum_A += A_vec[pos];
    else sum_B += B_vec[pos];
  }

  cout << sum_A - sum_B << "\n";

  return 0;
}


Measured memory_bytes: 3956
//#include"pch.h"
//#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<math.h>
#include<string.h>
#include<algorithm>


int main() {

	long long N, a, b, c, d, e;
	long long time = 0;
	long long min;
	scanf("%lld", &N);
	scanf("%lld", &a);
	scanf("%lld", &b);
	scanf("%lld", &c);
	scanf("%lld", &d);
	scanf("%lld", &e);

	min = a; if (min > b)min = b; if (min > c)min = c; if (min > d)min = d; if (min > e)min = e;
	if(N % min == 0)time = 4 + N / min;
	else time = 5 + N / min;
	



	printf("%lld", time);

	return(0);
}

Measured memory_bytes: 128
N,M=map(int,input().split())
H=list(map(int,input().split()))
H_max=[0 for i in range(N)]
for i in range(M):
    A,B=map(int,input().split())
    H_max[A-1]=max(H_max[A-1],H[B-1])
    H_max[B-1]=max(H_max[B-1],H[A-1])
count=0
for i in range(N):
    if H[i]>H_max[i]:
        count+=1
print(count)

Measured memory_bytes: 20116
// Practice DPC 5
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
    	($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!(usize);
    let k = get!(usize);
    let mut xs = vec![0; n + 1];
    for i in 0..n {
    	let a = get!();
        xs[i+1] += a + xs[i];
    }
    let mut ys = vec![];
    for i in 0..xs.len() {
    	for j in i+1..xs.len() {
        	let y = xs[j] - xs[i];
            ys.push(y);
        }
    }
    let mut ans = 0_i64;
    for i in 0..64 {
    	let i = 63 - i;
    	let mut tmp = vec![];
        for &y in ys.iter() {
        	if y & (1 << i) != 0 {
            	tmp.push(y);
            }
        }
        if tmp.len() >= k {
        	ans |= 1 << i;
            ys = tmp;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 10360
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

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

int main(void) {
  int i,j;
  int n,q;
  cin>>n>>q;
  vi c(n,0);
  c[0]=1;
  c[1]=-1;
  int ball=0;
  rep(i,q){
    int a,b;
    cin>>a>>b;
    a--;b--;
    swap(c[a],c[b]);
    if(a==ball)ball=b;
    else if(b==ball)ball=a;
    if(ball>0 && c[ball-1]==0)c[ball-1]=-1;
    if(ball<n-1 && c[ball+1]==0)c[ball+1]=-1;
  }
  int ans=0;
  rep(i,n)if(c[i]!=0)ans++;
  cout<<ans<<endl;
}


Measured memory_bytes: 640
nums = gets.split("").map(&:to_i)


["+", "-"].repeated_permutation(nums.size - 1) do |a|
    ans = 0
    4.times do |i|
        if i == 0
            ans = nums[i]
        else
            if a[i - 1] == "+"
                ans += nums[i]
            else
                ans -= nums[i]
            end
        end
        if i == 3 && ans == 7
            puts "#{nums[0]}#{a[0]}#{nums[1]}#{a[1]}#{nums[2]}#{a[2]}#{nums[3]}=7"
            exit
        end
    end
end

Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;


int main() {

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

	Int N, Q;
	cin >> N >> Q;

	string s;
	cin >> s;

	vector<vector<Int>> lr(Q, vector<Int>(2, 0));
	for (Int i = 0; i < Q; i++) {
		for (int j = 0; j < 2; j++) {
			cin >> lr[i][j];
			lr[i][j]--;//0Indexed
		}
	}

	//配列acの作成
	vector<Int> ac(N, 0);
	for (Int i = 0; i < N-1; i++) {
		if (i == 0) {
			if (s[0] == 'A' && s[1] == 'C') {
				ac[0] = 1;
				continue;
			}
			else continue;
		}

		else if (s[i] == 'A') {
			if (s[i + 1] == 'C') {
				ac[i] = ac[i - 1] + 1;
				continue;
			}
			else {
				ac[i] = ac[i - 1];
				continue;
			}
		}
		else {
			ac[i] = ac[i - 1];
			continue;
		}
	}
	ac[N - 1] = ac[N - 2];

	//解の出力
	Int ans = 0;
	for (Int i = 0; i < Q; i++) {
		if (lr[i][0] == 0) {//区間の左端が0番目の場合
			ans = ac[lr[i][1]];
			if ((lr[i][1] != N - 1) && (s[lr[i][1] + 1] == 'C') && (s[lr[i][1]] == 'A')) {
				ans = max(0LL, ans - 1);
			}
			printf("%lld\n", ans);
			continue;
		}

		else {
			ans = ac[lr[i][1]] - ac[lr[i][0] - 1];
			if ((lr[i][1] != N - 1) && (s[lr[i][1] + 1] == 'C') && (s[lr[i][1]] == 'A')) {
				ans = max(0LL, ans - 1);
			}
			printf("%lld\n", ans);
		}
	}

}




Measured memory_bytes: 7248
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <string.h>
#include <vector>

using namespace std;
int main() {
    int a,b,c,d;
    string ans;
    cin >> a >> b >> c >> d;
    if(abs(a-c)<=d||(abs(b-a)<=d&&abs(c-b)<=d)){
        ans="Yes";
    }else{
        ans="No";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using namespace std;

int main() {
    fastIO;
    int d;
    cin >> d;
    cout << "Christmas";
    rep(_, 25 - d) cout << " Eve";
}

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

int main(){
    long long int n;
    long long int a;
    long long int b;
    long long int result = 0;
    long long int tmp;

    cin >> n >> a >> b;

    if(a == 0){
        result = 0;
    }else{
        tmp = n / (a + b);
        result = tmp * a;
        tmp = n % (a + b);
        while(tmp > a){
            tmp--;
        }
        result += tmp;
    }

    cout << result << endl;

}

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


int bit_s(int x){
	int re=0;
	for(int i=0;i<31;i++){
		if(x&1<<i)re++;
	}
	
	return re;
}	

int main(){
	int n,k;
	while(cin>>n>>k && n && k){
		set<int> ans;
		int data[50];
		for(int i=0;i<n;i++)cin>>data[i];
		
		for(int i=0;i<2<<(n-1);i++){
			if(bit_s(i)==k){
				vector<int> tmp;
				for(int j=0;j<n;j++){
					
					if(i&1<<j)tmp.push_back(data[j]);
				}
				vector<int> loop;
				for(int i=0;i<tmp.size();i++)loop.push_back(i);
				do{
					int a=0;
					for(int i=0;i<loop.size();i++){
						if(tmp[loop[i]]<10)a=a*10+tmp[loop[i]];
						else a=a*100+tmp[loop[i]];
					}
					ans.insert(a);
				}while(next_permutation(loop.begin(),loop.end()));
			}
		}
		cout<<ans.size()<<endl;
		//for(set<int>::iterator itr =ans.begin();itr!=ans.end();itr++)cout<<(*itr)<<endl;
	}
	
	
}

Measured memory_bytes: 1332
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;

int dp[2*1000+1][2*1000+1];

int sum(int x1, int y1, int x2, int y2) {
  return dp[x2][y2] - dp[x1-1][y2] - dp[x2][y1-1] + dp[x1-1][y1-1];
}

int calc(int x, int y,int k) {
  return sum(1, 1, x, y) + sum(x+1, y+1, x+k, y+k) + sum(x+k+1, 1, 2*k, y) + sum(1, y+k+1, x, 2*k) + sum(x+k+1, y+k+1, 2*k, 2*k);
}

int main(){
	int N;
	int K;
	long long x[100000];
	long long y[100000];
	char c[100001];

	scanf("%d %d",&N,&K);
	for(int i=0;i<N;i++){
		scanf("%lld %lld %c",&x[i],&y[i],&c[i]);
		if(c[i]=='B') y[i] += K;
		x[i] %= 2*K;
		y[i] %= 2*K;
		x[i]++;
		y[i]++;
		dp[x[i]][y[i]]++;
	}

	for(int i=1;i<=2*K;i++){
		for(int j=1;j<=2*K;j++){
			dp[i][j] += dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1];
		}
	}

	int max = 0;
	for(int i=1;i<=K;i++){
		for(int j=1;j<=K;j++){
			int tmp;
			tmp = (calc(i,j,K) > N-calc(i,j,K) ? calc(i,j,K) : N-calc(i,j,K));
			max = (tmp > max ? tmp : max);
		}
	}


	printf("%d\n", max);

	return 0;
}


Measured memory_bytes: 17408
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
int a[305][305];
int n, m, l;

int main(){
//	freopen("E.out","w",stdout);
	cin >> n >> m >> l;
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++)
			if(i == j)	a[i][j] = 0;
			else a[i][j] = INF;
	int x, y, z;	
	for(int i = 1; i <= m; i++){
		scanf("%d%d%d",&x,&y,&z);
		if(z <= l)
			a[y][x] = a[x][y] = z;
	}
	//用两次 Floyd 算法
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++)
			for(int k = 1; k <= n; k++)
				if(a[j][k] > a[j][i] + a[i][k])
					 a[j][k] = a[j][i] + a[i][k];
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++)
			if(a[i][j] <= l)	a[i][j] = 1;
			else a[i][j] = INF;	
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++)
			for(int k = 1; k <= n; k++)
				if(a[j][k] > a[j][i] + a[i][k])
					 a[j][k] = a[j][i] + a[i][k];		
	int q;
	cin >> q;
	for(int i = 0; i < q; i++){
		scanf("%d %d",&x,&y);
		if(a[x][y] >= INF)	cout << -1 << "\n";
		else cout << a[x][y] - 1 << "\n"; 
	}
	
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...) 0
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    vector<vector<int>> a(3, vector<int>(3));
    rep(i, 0, 3) rep(j, 0, 3) cin >> a[i][j];
    int n;
    cin >> n;
    vector<vector<bool>> c(3, vector<bool>(3, false));
    rep(i, 0, n) {
        int b;
        cin >> b;
        rep(i, 0, 3) rep(j, 0, 3) {
            if (a[i][j] == b) c[i][j] = true;
        }
    }
    string ans = "No";
    rep(i, 0, 3) {
        if (c[i][0] && c[i][1] && c[i][2]) ans = "Yes";
        if (c[0][i] && c[1][i] && c[2][i]) ans = "Yes";
    }
    if (c[0][0] && c[1][1] && c[2][2]) ans = "Yes";
    if (c[0][2] && c[1][1] && c[2][0]) ans = "Yes";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def main(H, W, s_list):
    row_count = [[0]*W for _ in range(H)]
    for i_row in range(H):
        i_col = 0
        j_col = 0
        s = s_list[i_row]
        while(i_col < W):
            char = s[i_col]
            j_col = i_col
            
            if char == '.':
                while(True):
                    j_col += 1
                    if j_col == W:
                        break
                    c = s[j_col]
                    if c == '#':
                        break
                
                for k in range(i_col, j_col):
                    row_count[i_row][k] = j_col - i_col
            i_col = j_col + 1


    col_count = [[0]*W for _ in range(H)]
    for i_col in range(W):
        i_row = 0
        j_row = 0
        s_col = [s[i_col] for s in s_list]
        while(i_row < H):
            char = s_col[i_row]
            j_row = i_row
            if char == '.':
                while(True):
                    j_row += 1
                    if j_row == H:
                        break
                    c = s_col[j_row]
                    if c == '#':
                        break
                for k in range(i_row, j_row):
                    col_count[k][i_col] = j_row - i_row
            i_row = j_row + 1

    m = 0
    for i_row in range(H):
        for i_col in range(W):
            sumation = row_count[i_row][i_col] + col_count[i_row][i_col]
            if sumation > m:
                m = sumation
    print(int(m) - 1)



if __name__ == "__main__":
    H, W = [int(x) for x in input().split()]
    s_list = []
    for _ in range(H):
        s_list.append(input())

    main(H, W, s_list)


Measured memory_bytes: 126040
#include<cstdio>

int n,d,i,j,vis[21],last,ans,sum;

int main()
{
	scanf("%d%d",&n,&d);
	sum=n;
	while(i<n)
	{
		if(vis[i])
		{
			i++;
			continue;
		}
		if(i-last==d)
		{
			for(j=last;j<=i+d;j++)
				vis[j]=1,sum--;
			ans++;
			last=i+d+1;
		}
		i++;
	}
	if(sum>0)ans++;
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef pair<ll,ll> P;
typedef map<ll,ll> MP;
typedef priority_queue<ll> PQ;
typedef stack<ll> ST;
typedef queue<ll> QUE;
#define pb push_back
#define st first
#define nd second
#define SZ(x) ((int)(x).size())
#define FOR(i,s,n) for(int i=(int)(s); i< (int)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define each(x,c) for(auto x: (c))
#define LB(x,a) lower_bound(all(x), a)
#define UB(x,a) upper_bound(all(x), a)
const ll mod=1e9+7;
const ll INF=1e18;
const double EPS=1.0e-10;
const double PI=M_PI;

int main(){
    string S; cin>>S;
    bool b = false;
    rep(i,3){
        if(S[i] == '7'){
            b = true;
        }
    }
    if(b) cout<<"Yes"<<endl;
    else  cout<<"No"<<endl;
}

Measured memory_bytes: 3624
#include <iostream>
using namespace std;
int main(){
int N, K, p[1010];
cin >> N >> K;
for(int i = 0; i < N; ++i) cin >> p[i];
sort(p, p + N);
int ans = 0;
for(int i = 0; i < K; ++i) ans += p[i];
cout << ans << endl;
}

Measured memory_bytes: 3192
n = int(input())
A = [[int(i) for i in input().split()] for j in range(n)]
C = [[int(i) for i in input().split()] for j in range(n)]


ans = 0
used = [False] * n
A.sort(key=lambda x:x[1], reverse=True)
C.sort()

for c, d in C:
    i = 0
    while i < n and (used[i] or A[i][0] >= c or A[i][1] >= d):
        i += 1
    if i >= n:
        continue
    ans += 1
    used[i] = True

print(ans)

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

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

  vector<vector<int>> g(n, vector<int>(n));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      g[i][j] = 0;
    }
  }

  for (int i = 0; i < n; i++) {
    int u, k;
    cin >> u >> k;
    u--;
    for (int j = 0; j < k; j++) {
      int a;
      cin >> a;
      a--;
      g[u][a] = 1;
    }
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (j != 0) cout << " ";
      cout << g[i][j];
    }
    cout << endl;
  }
}


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

struct ts
{
	long long b, l, u, p;
	bool operator<(const ts &r) const {
		return p > r.p;
	}
};

ts a[100009];
long long s[100009];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n; long long x; cin >> n >> x;
	long long cs = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i].b >> a[i].l >> a[i].u; 
		a[i].p = a[i].b * a[i].l + (x - a[i].b) * a[i].u;
		cs += a[i].b * a[i].l;
	}
	sort(a + 1, a + n + 1);
	for (int i = 1; i <= n; i++) s[i] = s[i - 1] + a[i].p;
	long long rs = cs, c = -1;
	for (int i = 1; i <= n; i++) {
		cs -= a[i].p; c++;
		if (cs <= 0) break;
	}
	cs = rs;
	long long mn = 1000000000000000000LL;
	for (int i = 1; i <= n; i++) { 
		if ((i <= c && s[c + 1] >= cs) || (i > c && s[c] + a[i].p >= cs)) {
			if (i <= c) rs = cs - s[c + 1] + a[i].p;
			else rs = cs - s[c];
			if (a[i].b * a[i].l >= rs) mn = min(mn, (rs + a[i].l - 1) / a[i].l);
			else mn = min(mn, (rs - a[i].b * a[i].l + a[i].u - 1) / a[i].u + a[i].b);
		}
	}
	cout << c * x + mn << '\n';
	return 0;
}

Measured memory_bytes: 4224
#include <iostream>

using namespace std;

const int maxn = 29;

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

	int n, m, c, b[maxn];
	cin >> n >> m >> c;
	for (int i = 0; i < m; i++) {
		cin >> b[i];
	}
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		int sum = 0;
		for (int j = 0; j < m; j++) {
			int num;
			cin >> num;
			sum += num * b[j];
		}
		if (sum + c > 0) cnt++;
	}
	cout << cnt << '\n';

	return 0;
}


Measured memory_bytes: 256
import java.io._
import java.util.StringTokenizer

import scala.collection.mutable
import scala.util.Sorting
import math.{abs, max, min}
import scala.collection.mutable.ArrayBuffer
import scala.reflect.ClassTag

object Main {
  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val S, T = sc.next()

    val ok = (S.length == T.length) && {
      map(S.length) { i =>
        val S1 = S.drop(i) + S.take(i)
        S1 == T
      } contains true
    }
    val ans = if (ok) "Yes" else "No"

    out.println(ans)
  }

  def main(args: Array[String]): Unit = {
    solve()
    out.flush()
  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = null

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  def rep(n: Int)(f: Int => Unit): Unit = {
    var i = 0
    while(i < n) { f(i); i += 1 }
  }
  def rep_r(n: Int)(f: Int => Unit): Unit = {
    var i = n - 1
    while(i >= 0) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    rep(n)(i => res(i) = f(i))
    res
  }

  implicit class ArrayOpts[A](val as: Array[A]) extends AnyVal {
    // todo Orderingだとboxing発生するので自作Orderを用意したい
    def maxByOpt[B: Ordering](f: A => B): Option[A] = {
      if (as.nonEmpty) Some(as.maxBy(f)) else None
    }

    def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {
      val map = mutable.Map.empty[K, ArrayBuffer[A]]
      rep(as.length)(i => map.getOrElseUpdate(f(as(i)), ArrayBuffer()) += as(i))
      map
    }

    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
      var sum = num.zero
      rep(as.length)(i => sum = num.plus(sum, f(as(i))))
      sum
    }

    def minByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {
      limit(f, ixRange)(cmp.lt)
    }

    def maxByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {
      limit(f, ixRange)(cmp.gt)
    }

    private def limit[B](f: A => B, ixRange: Range)(cmp: (B, B) => Boolean): (A, B) = {
      var limA = as(ixRange.head)
      var limB = f(limA)

      for (i <- ixRange.tail) {
        val a = as(i)
        val b = f(a)
        if (cmp(b, limB)) {
          limA = a
          limB = b
        }
      }
      (limA, limB)
    }
  }

  implicit class IterableOpts[A](val as: Iterable[A]) extends AnyVal {
    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
      as.foldLeft(num.zero)((acc, a) => num.plus(acc, f(a)))
    }
  }
}


Measured memory_bytes: 25412
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }
template<class T> inline void printYesNo(const T& t) { cout << (t ? "Yes" : "No") << CRLF; }
template<class T = int64_t> T modpow(T N, T P, T M) { T ret{1}; N %= M; while (P) { if (P & 0x01) { ret *= N; ret %= M; } P >>= 1; N *= N; N %= M; } return ret; }

/** code for assert debug begin */
int gErr = 0;
#define ASSERT(p) if(!(p)){ gErr = 1; }else{ ; }
/** code for assert debug end */

struct Tmp
{
public:
  int N;
  Tmp(int N)
  : N(N)
  {}
};

void solve(void)
{
  int r, g, b; cin >> r >> g >> b;
  auto n = r*100 + g*10 + b;
  auto ans = n % 4 == 0;
  cout << (ans ? "YES" : "NO") << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
	std::ios::sync_with_stdio(false);
	cin>>s;
	int n=s.size();
	for(int i=0;i<n;i++)
	{
		if(s[i]==',') s[i]=' ';
	}
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	int d;
	cin>>d;
	if(fabs(a-b)<=d&&fabs(c-b)<=d||fabs(c-a)<=d)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
n,m=list(map(int, input().split() ))
Firstlis=[]
Secondlis=[]
for i in range(m):
  s=list(map(int,input().split()))
  S1=s[0]
  S2=s[1]
  Firstlis.append(S1)
  Secondlis.append(S2)
Min=max(Firstlis)
Max=min(Secondlis)
if Max>=Min:
    print(Max-Min+1)
else:
    print(0)




  


Measured memory_bytes: 11064
def main():
  N = int(input())

  ## 証言を入れる
  p = [[-1 for i in range(N)] for j in range(N)]

  ans = 0

  for i in range(N):
    A = int(input())

    for j in range(A):
      x, y = list(map(int, input().split()))
      x -= 1
      p[i][x] = y


  for i in range(1 << N):
    d = [0] * N

    for j in range(N):
      # 0-indexedで考える
      # 下i桁目を0桁目に持ってきて1と&をとると、i番目の人が正直者のフラグが立っているかどうかが判定できる
      if(i >> j & 1):
        d[j] = 1

    ok = True
    
    for j in range(N):
      if(d[j]):
        for k in range(N):
          if(p[j][k] == -1):
            continue
          if(p[j][k] != d[k]):
            ok = False

    if(ok):
      ans = max(ans, bin(i).count("1"))

  print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iterator>
#include <map>
#include <unordered_map>
#define ll long long int
#define vi vector<long long int>
#define vvi vector<vi >
#define vs vector<string>
#define vsf v.begin(),v.end()
#define pb push_back
#define mp make_pair
using namespace std;
int main(){
	ll i,n;
	cin>>n;
	vvi v(n);
	for(i=0;i<n;i++){
		v[i]=vector<ll>(3);
		cin>>v[i][0]>>v[i][1]>>v[i][2];
	}
	for(i=1;i<n;i++){
		v[i][0]+=max(v[i-1][1],v[i-1][2]);
		v[i][1]+=max(v[i-1][0],v[i-1][2]);
		v[i][2]+=max(v[i-1][0],v[i-1][1]);
	}
	cout<<max(max(v[n-1][0],v[n-1][1]),v[n-1][2])<<endl;
}


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

int main() {
  
  char c;
  cin >> c;
  
  
  if (c == 'a'){
    cout << "vowel" << endl;
  }
  else if (c == 'i'){
    cout << "vowel" << endl;
  }
  else if (c == 'u'){
    cout << "vowel" << endl;
  }
  else if (c == 'e'){
    cout << "vowel" << endl;
  }
  else if (c == 'o'){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
  
  

 }

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


using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0; i<ll(n); i++)
#define FOR(i,m,n) for(ll i=ll(m); i<ll(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;




int main() {

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

}

Measured memory_bytes: 3628