akhauriyash/Code-Regression huggingface dataset:
nm = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

n = nm[0]
m = nm[1]

a_s = sorted(a)[::-1]
if a_s[m-1] < sum(a)/(4*m):
  print('No')
else:
  print('Yes')

Measured memory_bytes: 3060
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

type number struct{ a, b int }
type numbers []number

func (n numbers) Len() int           { return len(n) }
func (n numbers) Swap(i, j int)      { n[i], n[j] = n[j], n[i] }
func (n numbers) Less(i, j int) bool { return n[i].a < n[j].a }

func main() {
	n, k := scanInt(), scanInt()
	nums := numbers(make([]number, n))
	for i := range nums {
		nums[i].a, nums[i].b = scanInt(), scanInt()
	}

	sort.Sort(nums)
	cnt := 0
	for _, num := range nums {
		if cnt+num.b >= k {
			fmt.Println(num.a)
			return
		}
		cnt += num.b
	}
}


Measured memory_bytes: 3840
#include <algorithm>
#include <bitset>
#include <cmath>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(a) begin(a),end(a)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1e+9;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
ll gcd(ll a, ll b){
  if (b==0) return a;
  else return gcd(b,a%b);
}
int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


int fac(int num) {
  if(num==1) return 1;
  else return num*fac(num-1);
}


ll a[110000];
ll dp[110000][2];

int main() {
  int N;cin >> N;
  rep(i,N) {
    cin >> a[i+1];
  }
  dp[0][0] = 0;
  dp[0][1] = -inf;

  for(int i = 0; i<N; i++) {
    dp[i+1][0] = max(dp[i][0]+a[i+1],dp[i][1]-a[i+1]);
    dp[i+1][1] = max(dp[i][0]-a[i+1],dp[i][1]+a[i+1]);    
  }
  cout << dp[N][0] << endl;
 

  
  
  return 0;
}


Measured memory_bytes: 2560
#include <math.h>
#include <stdio.h>
int n, m, q, p[10], A[11], a[50], b[50], c[50], d[50];
int sum, max = 0;
void dfs(int num, int pt) {
	if (pt == n + 1) {
		sum = 0;
		for (int i = 0; i < q; i++) {
			if (A[b[i]] - A[a[i]] == c[i]) {
				sum += d[i];
			}
		}
		if (sum > max)
			max = sum;
		return;
	}
	A[pt] = num;
	while (num <= m) {
		dfs(num, pt + 1);
		num++;
	}
	return;
}
int main() {
	scanf("%d%d%d", &n, &m, &q);
	for (int i = 0; i < q; i++) {
		scanf("%d%d%d%d", &a[i], &b[i], &c[i], &d[i]);
	}
	dfs(1, 1);
	printf("%d\n", max);
	return 0;
}

Measured memory_bytes: 1728
#include <iostream>
#include <sstream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main(void){
	int x,a,b;
	cin >> x >> a >> b;
	if(a-b>=0){
		cout << "delicious" << endl;
	}else if(b-a<=x){
		cout << "safe" << endl;
	}else{
		cout << "dangerous" <<endl;
	}
	return 0;
}

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

int w, h;
int land[51][51];

void dfs(int x, int y) {
  land[x][y] = 2;
  int dx[8] = {1,1,1,0,0,-1,-1,-1};
  int dy[8] = {1,0,-1,1,-1,1,0,-1};
  for (int i = 0; i < 8; i++) {
    int nx = x + dx[i];
    int ny = y + dy[i];
    if (0 <= nx && nx < w && 0 <= ny && ny < h && land[nx][ny] == 1) dfs(nx, ny);
  }
  return;
}

int main() {
  bool jud = true;
  while (jud) {
  cin >> h >> w;
  if (h == 0 && w == 0) {
    jud == false;
    break;
  }
  if (jud == false) break;
  for (int a = 0; a < w; a++) {
    for (int b = 0; b < h; b++) {
      cin >> land[a][b];
    }
  }
  int ans = 0;
  for (int a = 0; a < w; a++) {
    for (int b = 0; b < h; b++) {
      if (land[a][b] == 1) {
        dfs(a, b);
        ans++;
      }
    }
  }
  cout << ans << endl;
  }
}


Measured memory_bytes: 3284
n, m = list(map(int, input().split()))
edges = [[] for _ in range(n)]

for i in range(m):
    a, b = list(map(int, input().split()))

    edges[a-1].append(b-1)
    edges[b-1].append(a-1)

ind = 1
queue = [0]
visitedOrder = {}
visited = {}
cnt = 0

while queue:
    cur = queue[-1]

    if cur not in visited:
        visited[cur] = ind
        visitedOrder[cur] = ind
        ind += 1

    neighbours = False
    for nei in edges[cur]:
        if nei not in visited:
            neighbours = True
            queue.append(nei)
            break

    if not neighbours:
        queue.pop()

        if cur != 0:
            connected = visited[cur]

            for nei in edges[cur]:
                if nei != queue[-1]:
                    connected = min(connected, visited[nei])

            visited[cur] = connected
            if connected > visitedOrder[queue[-1]]:
                cnt += 1

print(cnt)

Measured memory_bytes: 9264
#include<stdio.h>
double f(double a){
  return a<0?-1*a:a;
}
int main(){
  int a,e=0;
  scanf("%d",&a);
  double b,c,d[a];
  scanf("%lf %lf",&b,&c);
  for(int i=0; i<a; i++){
    scanf("%lf",&d[i]);
  }
  for(int i=1; i<a; i++){
    if(f(c-(b-d[e]*0.006))>f(c-(b-d[i]*0.006))){
      e=i;
    }
  }
  printf("%d",e+1);
  return 0;}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
using namespace std;
template<class T>inline void read(T &res)
{
    char c;
    T flag=1;
    while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;
    res=c-'0';
    while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';
    res*=flag;
}
int main()
{
    int n;
    ll a[200005],sum=0;
    read(n);
    for(int i=0;i<n;i++)
    {
        read(a[i]);
        sum^=a[i];
    }
    for(int i=0;i<n;i++)
        printf("%lld ",sum^a[i]);
    return 0;
}


Measured memory_bytes: 5308
// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//


#define _USE_MATH_DEFINES
#include<math.h>

//#include<cmath>

#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>



//#include "Ants.h"
using namespace std;
typedef long long ll;
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<n;i++)
#define show(s) cout<<s<<endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define LINF (1000000000000000000ll)

//typedef pair < int, int> P;
ll gcd(ll a, ll b) {//最大公約数を求める///最大公倍数a*b/gcd(a,b)
	if (b == 0) return a;
	return gcd(b, a % b);
}

ll lcd(ll a, ll b) {//最小公倍数を求める　b=0のときaを返す
	if (b == 0) return a;
	return (a / gcd(a, b)) * b;
}
vector<int> divnum(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p;
}
int keta(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p.size();
}

string S;
int dp[1000005][2];
int main()
{
	cin >> S;
	
	reverse(S.begin(), S.end());
	S += '0';
	dp[0][1] = INF;
	rep(i, S.size()) {
		dp[i + 1][0] = INF; dp[i + 1][1] = INF;
		rep(j, 2) {
			int x = S[i] - '0';
			x += j;
			if (x < 10)chmin(dp[i + 1][0], dp[i][j] + x);
			chmin(dp[i + 1][1], dp[i][j] + (10 - x));
		}
	}
	cout << dp[S.size()][0] << endl;
	
}

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

int N, P;
string S;

int main() {
	cin >> N >> P >> S;

	// 例外処理
	if (P == 2 or P == 5) {
		long long ans = 0;
		for (int r = 0; r < N; r++) {
			if ((S[r] - '0') % P == 0) {
				ans += r + 1;
			}
		}
		cout << ans << endl;
		return 0;
	}

	// 各桁ごとにmodを求める
	vector<int> s(N+1);
	int ten = 1;
	for (int i = N-1; i >= 0; i--) {
		int num = (S[i] - '0') * ten;
		s[i] = num % P;
		ten *= 10;
		ten %= P;
	}

	// 累積和を求める
	for (int i = N-1; i >= 0; i--) {
		s[i] += s[i+1];
		s[i] %= P;
	}

	// 両端の数値を判定して答えを求めていく
	long long ans = 0;
	map<int, int> mp;
	mp[0] = 1;
	for (int i = N-1; i >= 0; i--) {
		ans += mp[s[i]];
		mp[s[i]]++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1668
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll val[100005]={0};
bool used[100005];
int main(){
  ll n,ans=0;
  cin>>n;
  for(int i=0;i<n;i++) used[i]=false;
  for(int i=0;i<n;i++) cin>>val[i];
  for(ll d=1;d<n;d++){
    ll l=0,r=0;
    for(int i=0;i<n;i+=d){
      if(used[i]) break;
      used[i]=true;
      if(used[n-i-1]) break;
      used[n-i-1]=true;
      if(n-i-1<=d) break;
      l+=val[i];
      r+=val[n-i-1];
      ans=max(ans,l+r);
    }
    for(int i=0;i<n;i+=d) used[i]=false;
    for(int i=n-1;i>=0;i-=d) used[i]=false;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define ff(i,s,n) for(int i=s;i<n;i++)
#define fr(i,s,n) for(int i=n-1;i>=s;i--)
#define llu unsigned long long int

int minimumChar(string S1, string S2) 
{ 
    // Get the sizes of both strings 
    int n = S1.size(), m = S2.size(); 
  
    int ans = INT_MAX; 
  
    // Traverse the string S2 
    for (int i = 0; i < m - n + 1; i++) { 
        int minRemovedChar = 0; 
  
        // From every index in S2, check the number of 
        // mis-matching characters in substring of 
        // length of S1 
        for (int j = 0; j < n; j++) { 
            if (S1[j] != S2[i + j]) { 
                minRemovedChar++; 
            } 
        } 
  
        // Take minimum of prev and current mis-match 
        ans = min(minRemovedChar, ans); 
    } 
  
    // return answer 
    return ans; 
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s,t;
	cin>>s>>t;
	cout << minimumChar(t, s); 
}

//1
//7 2
//3 5 4 5 1 1 1


Measured memory_bytes: 3616
import sys
sys.setrecursionlimit(10**5+5)
from collections import defaultdict,deque
input = sys.stdin.readline

def bfs():
    q = deque([1])
    while q:
        now = q.popleft()
        for nex,c,w in e[now]:
            if depth[nex]>= 0:
                continue
            depth[nex] = depth[now]+1
            dis[nex] = dis[now]+w
            lca[0][nex] = now
            q.append(nex)

def dfs1(now,p,count1,count2):
    for cou in dcount[now]:
        dcount[now][cou] = count1[cou]
    for wei in dweight[now]:
        dweight[now][wei] = count2[wei]

    for nex,c,w in e[now]:
        if nex == p:
            continue
        count1[c] += 1
        count2[c] += w
        dfs1(nex,now,count1,count2)
        count1[c] -= 1
        count2[c] -= w
n,q = map(int,input().split())
e = [[] for i in range(n+1)]

for i in range(n-1):
    a,b,c,d = map(int,input().split())
    e[a].append((b,c,d))
    e[b].append((a,c,d))
size = n+1
bitlen = 19
lca = [[0]*size for i in range(bitlen)]
depth = [-1]*size
dis = [-1]*size
depth[1] = 0
dis[1] = 0

bfs()
for i in range(1,bitlen):
    for j in range(1,size):
        if lca[i-1][j] > 0:
            lca[i][j] = lca[i-1][lca[i-1][j]]
    
def search(x,y):
    dx = depth[x]
    dy = depth[y]
    if dx < dy:
        x,y = y,x
        dx,dy = dy,dx
    dif = dx-dy
    while dif:
        s = dif & (-dif)
        x = lca[s.bit_length()-1][x]
        dif -= s
    if x == y:
        return x
    for i in range(bitlen-1,-1,-1):
        if lca[i][x] != lca[i][y]:
            x = lca[i][x]
            y = lca[i][y]
    return lca[0][x]


Q = []
dcount = defaultdict(lambda : defaultdict(int))
dweight = defaultdict(lambda : defaultdict(int))
for i in range(q):
    x,y,u,v = map(int,input().split())
    a = search(u,v)
    dcount[u][x] = 0
    dcount[v][x] = 0
    dcount[a][x] = 0
    dweight[u][x] = 0
    dweight[v][x] = 0
    dweight[a][x] = 0
    Q.append((x,y,u,v,a))

    
dfs1(1,0,defaultdict(int),defaultdict(int))

for x,y,u,v,a in Q:
    cal = dis[u]+dis[v]-2*dis[a]
    cal += y*(dcount[u][x]+dcount[v][x]-2*dcount[a][x]) - dweight[u][x]-dweight[v][x]+2*dweight[a][x]
    print(cal)

Measured memory_bytes: 930564
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2e5+5;
int a[N];
ll f[N][3];
int main() {
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++) {
        scanf("%d",&a[i]);
    }
    for(int i=1;i<=n;i++) {
        for(int j=0;j<3;j++) {
            f[i][j]=-1e18;
        }
    }
    for(int i=1;i<=3;i++) {
        f[i][i-1]=a[i];
    }
    f[3][0]=a[1]+a[3];
    for(int i=4;i<=n;i++) {
        f[i][0]=f[i-2][0]+a[i];
        f[i][1]=max(f[i-2][1],f[i-3][0])+a[i];
        f[i][2]=max(f[i-2][2],f[i-3][1])+a[i];
        if(i>4) f[i][2]=max(f[i][2],f[i-4][0]+a[i]);
    }
    ll ans;
    if(n&1) ans=max(f[n][2],max(f[n-1][1],f[n-2][0]));
    else ans=max(f[n][1],f[n-1][0]);
    printf("%lld\n",ans);
    return 0;
}

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

using ll = long long;

int main() {
    int n;
    cin >> n;
    int p[10010] = {};
    int sum = 0;
    rep(i, n) {
        cin >> p[i];
        sum += p[i];
    }
    cout << sum - *max_element(p, p + 10010) / 2 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	int n,d[110],ans=0,num[110]={};
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>d[i];
	}
	
	for(int i=0;i<n;i++){
		num[d[i]-1]=1;
	}
	for(int i=0;i<100;i++){
		ans+=num[i];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define ALL(x) (x).begin(),(x).end()
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)

int main(){
	int N, K; cin >> N >> K;
	if(K==1){
		cout << 0 << endl;
	}else{
		cout << N-K << endl;
	}
	return 0;
}


Measured memory_bytes: 256
N=int(input())
d=[[0]*10 for i in range(10)]
#10x10のグリッドを作る

#9x9パターンに分類されるため、各数字をグリッドに振り分ける
for i in range(1,N+1):
  n=str(i)
  d[int(n[0])][int(n[-1])]+=1

#組み合わせの数は[Aの数]x[Bの数] 先頭か語尾に0が付くものはカウントしない
r=0
for i in range(9):
  for j in range(9):
    r+=d[i+1][j+1]*d[j+1][i+1]
print(r)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
long long n,m,a,b,c;
int main()
{
	cin>>n;
	bool no=false;
	for(int i=0;i<n;i++)	
	{
		cin>>a;
		if(a%2==0 && a%3!=0 && a%5!=0)
			no=true;
	}
	if(no==true)
		cout<<"DENIED"<<endl;
	else
		cout<<"APPROVED"<<endl;
} 

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

int main() {
  
  int n;
  cin >> n;
  
  vector<int> vec(n);
  
  int a;
  cin >> a;
  for (int i=0; i<n-1; i++) {
    int h;
    cin >> h;
    if (a<h) vec.at(i)=0;
    else vec.at(i)=1;
    a=h;
  }
  
  int c=0;
  for (int i=0; i<n; i++) {
    if (vec.at(i)==1) c++;
    if (i==n-1) vec.at(i)=c;
    if (vec.at(i)==0) {
      vec.at(i)=c;
      c=0;
    }
  }
  
  sort(vec.begin(), vec.end());
  
  cout << vec.at(n-1) << endl;
}

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

static const int MAX = 200000;
int main() {
    int n, a[MAX];

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    int x = a[0];
    int64_t sum = 0;
    for (int i = 1; i < n; i++) {
        if (a[i] <= x) {
            sum += x - a[i];
        } else {
            x = a[i];
        }
    }
    cout << sum << endl;
}


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

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

using namespace std;

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

	int n=s.length();
	rep(i,n-1) if(s[i]==s[i+1]) return printf("%d %d\n",i+1,i+2),0;
	rep(i,n-2) if(s[i]==s[i+2]) return printf("%d %d\n",i+1,i+3),0;
	puts("-1 -1");

	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>

using namespace std;

void honponbon(char Nb) {
    if (Nb == '2' || Nb == '4' || Nb == '5' || Nb == '7' || Nb == '9') {
        cout << "hon" << endl;
    } else if (Nb == '0' || Nb == '1' || Nb == '6' || Nb == '8') {
        cout << "pon" << endl;
    } else if (Nb == '3') {
        cout << "bon" << endl;
    }
}

int main(void) {
    string Ns;
    cin >> Ns;
    if (Ns.length() == 3) {
        honponbon(Ns[2]);
    } else if (Ns.length() == 2) {
        honponbon(Ns[1]);
    } else if (Ns.length() == 1) {
        honponbon(Ns[0]);
    }
}



Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			if (n == 0) {
				break;
			}
			int[] values = new int[n];
			for (int i = 0; i < n; i++) {
				values[i] = sc.nextInt();
			}
			int min = 1000, max = 0;
			for (int i = 0; i < n; i++) {
				if (values[i] >= max) {
					max = values[i];
				}
				if (values[i] <= min) {
					min = values[i];
				}
			}
			double ave = 0;
			for (int i = 0; i < n; i++) {
				ave += values[i];
			}
			ave -= (max + min);
			ave /= n - 2;
			System.out.println((int) ave);
		}
	}
}

Measured memory_bytes: 29508
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>
#include <sstream>
#include <fstream>
#include <climits>
#include <map>
#include <numeric>
#include <functional>
#include <utility>

using namespace std;

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

int main(void) {
  int n, k;
  cin >> n >> k;

  vector<vector<int> > tbl(k);

  for (int i = 0; i < k; i++) {
    int d;
    cin >> d;
    tbl.at(i).resize(d);
    for (int j = 0; j < d; j++) {
      cin >> tbl.at(i).at(j);
    }
  }

  vector<int> snk(n, 1);

  for (int i = 0; i < k; i++) {
    for (int j = 0; j < tbl.at(i).size(); j++) {
      snk.at(tbl.at(i).at(j) - 1) = 0;
    }
  }

  int ans = accumulate(snk.begin(), snk.end(), 0);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3640
IDENTIFICATION DIVISION.
       PROGRAM-ID. TESTA.
       DATA DIVISION.
       FILE SECTION.
       WORKING-STORAGE SECTION.
       77 N PIC 9(5).
       77 K PIC 9(5).
       77 X PIC 9(5).
       77 Y PIC 9(5).
       77 ANS PIC 9(9).
       77 ANSS PIC Z(9).

       PROCEDURE DIVISION.
       MAIN-PROCEDURE.
               ACCEPT N.
               ACCEPT K.
               ACCEPT X.
               ACCEPT Y.
               IF K < N THEN
                   COMPUTE ANS = K * X + (N - K) * Y
               ELSE
                   COMPUTE ANS = N * X
               END-IF.
               MOVE ANS TO ANSS.
               DISPLAY ANSS.
               STOP RUN.
       END PROGRAM TESTA.


Measured memory_bytes: 636
//https://beta.atcoder.jp/contests/abc064/tasks/abc064_a
#include<iostream>

using namespace std;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if((a*100 + b*10 + c) % 4 ==0) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let m: usize = itr.next().unwrap().parse().unwrap();

    let mut red = vec![false; n];
    let mut cnt = vec![1; n];
    let mut ans = 0;
    red[0] = true;
    for _ in 0..m {
        let x: usize = itr.next().unwrap().parse::<usize>().unwrap() - 1;
        let y: usize = itr.next().unwrap().parse::<usize>().unwrap() - 1;
        if red[x] {
            if cnt[x] == 1 {
                red[x] = false;
            }
            red[y] = true;
        }
        cnt[x] -= 1;
        cnt[y] += 1;
    }

    for i in 0..n {
        ans += if red[i] { 1 } else { 0 };
    }
    println!("{}", ans);
}


Measured memory_bytes: 3592
/*
 *
 *   Author     : Amit Kumar
 *   Date    	: June 1 2019
 * 
 */

#include <bits/stdc++.h>

//#define FAST_INPUT_OUTPUT
//#define MORE_THAN_ONE_TESTCASE // COMMENT IT

#define vi vector<int>
#define vl vector<long long>
#define mii map<int , int>
#define mll map<long long , long long>
#define msi map<string , i>
#define msl map<string , long long>
#define umii unordered_map<int,int>
#define umll unordered_map<long long ,long long>
#define umsi unordered_map<string , int>
#define umsl map<string , long long> 
#define si set<int>
#define sl set<long long>
#define pii pair<int , int >
#define psi pair<string,int>
#define psl pair<string , long > 
#define pll pair<long long , long long>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpsi vector<psi>
#define vpsl vector<psl>
#define pqi priority_queue<int>
#define pql priority_queue<long long>
#define ub upper_bound
#define lb lower_bound
#define bint long long int
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define iv(v) for(auto &i:v){cin>>i;}
#define ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define ovn(v) for(auto i:v){cout<<i<<endl;}
#define euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define eovn(v) for(auto i:v){cerr<<i<<endl;}
#define os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define osn(s) for(auto itr:s){cout<<itr<<endl;}
#define eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define eosn(s) for(auto itr:s){cerr<<itr<<endl;}
#define rep(x) for(auto i=0 ; i<(x); ++i)
#define _rep(a,b) for(auto i=(a); i<(b); ++i)
#define endl '\n'
using namespace std;




auto SOLUTION_FUNCTION( void ) ->void {

    // your solution goes here 

    int n , m;

    cin>>n>>m;

    bint maxl = INT_MIN , minr = INT_MAX;

    rep(m){

        bint l , r;

        cin>>l>>r;

        maxl = max(maxl , l);

        minr = min(minr , r);

    }

    cout<<max((bint)0 , minr - maxl + 1)<<endl;




    return ;
}




int main(void){
#ifdef FAST_INPUT_OUTPUT
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout<<setprecision(10);
    cout<<fixed;
    cout<<boolalpha;
#endif
#ifdef MY_LOCAL_PROJECT
    freopen("cin","r",stdin);
    freopen("cout","w",stdout);
#endif
    int testcase = 1;


#ifdef MORE_THAN_ONE_TESTCASE
    cin>>testcase;
#endif
    
    while(testcase--){
        SOLUTION_FUNCTION();
    }

#ifdef MY_LOCAL_PROJECT
    cout<<"Time : "<<1.0*(double)clock()/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}


Measured memory_bytes: 256
#define _CRT_NONSTDC_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>
#include <map>
#include <numeric>
#include <vector>

using namespace std;
using ll = long long;
const int INTMAX = numeric_limits<int>::max();
const int INTMIN = numeric_limits<int>::min();
const ll LLMAX = numeric_limits<long long>::max();
const ll LLMIN = numeric_limits<long long>::min();
const int MOD = 1000000007;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

bool solve() {

	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	vector<pair<int, int>> bc(m);
	for (auto&& e : a) cin >> e;
	for (auto&& e : bc) {
		cin >> e.second >> e.first;
	}
	sort(bc.begin(), bc.end(), greater<pair<int,int>>());
	vector<int> c;
	int qsize = 0;

	for (int i = 0; i < m; i++) {
		while (bc[i].second) {
			if (c.size() < n) {
				c.push_back(bc[i].first);
				bc[i].second--;
			} else {
				goto b;
			}
		}
	}
b:
	sort(a.begin(), a.end());//, greater<int>());
	for (int i = 0, j = 0; i < n && j < c.size(); i++) {
		if (a[i] < c[j]) {
			a[i] = c[j];
			j++;
		}
	}


	ll ans = 0;
	for (auto&& e : a) ans += e;
	cout << ans << endl;


	return true;
}

signed main() {
	solve();

	return 0;
}

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

s = list(raw_input())
stk = []

i = 0
while i<len(s):
	if s[i] == ')' and not stk:
		s.insert(0,"(")
		i += 1

	if s[i] == ')' and  stk:
		stk.pop()

	if s[i] == '(':
		stk.append('(')
	i += 1

for i in range(len(stk)):
	stk[i] = ')'

print ''.join(s) + ''.join(stk)


Measured memory_bytes: 2820
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()

int main() {
  //
  ll n, m;
  cin >> n >> m;
  if (n == 1 && m == 1) {
    cout << 1 << endl;
  } else if (n == 1) {
    // m>=2
    cout << m - 2 << endl;
  } else if (m == 1) {
    // n>=2
    cout << n - 2 << endl;
  } else {
    cout << (m - 2) * (n - 2) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}


	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		Set<Integer> s = new HashSet<Integer>();
		for(int i=0; i<n; i++) {
			int v=sc.nextInt();
			if(s.contains(v)) {
				s.remove(v);
			}else {
				s.add(v);
			}
		}
		System.out.println(s.size());
		sc.close();
	}
}


Measured memory_bytes: 62224
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <stack>

using namespace std;

typedef long long LL;
#define FAST ios::sync_with_stdio(false);
const int MaxN = 105;

int main()
{
	string a,b,c;
	cin >> a >> b >> c;
	cout << a[0] << b[0] << c[0] << endl;
	return 0;
	}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
struct DOBERMAN{
char c[61],s[61];
int g;
};
struct DOBERMAN doberman[1000000]={0},q[1000000]={0},t;
int main(){
int i,j,n,f,m,u=0,o=0,r,l,b=0,jc,jk,js;
static int p[1000000]={0};
char d[61][61];
scanf("%d%d",&n,&f);
for(i=0;i<n;i++){
	scanf("%d",&m);
	for(j=0;j<m;j++){
		scanf("%s",d[j]);
	}
	for(j=0;j<m;j++){
		for(r=j+1;r<m;r++){
			o=0;
			//printf("%s %s\n",d[j],d[r]);
			for(l=0;l<u;l++){
				if((strcmp(d[j],doberman[l].c)==0&&strcmp(d[r],doberman[l].s)==0)||(strcmp(d[r],doberman[l].c)==0&&strcmp(d[j],doberman[l].s)==0)){
					//printf("%d:%d\n%d:%d\n",strcmp(d[j],doberman[l].c),strcmp(d[r],doberman[l].s),strcmp(d[r],doberman[l].c),strcmp(d[j],doberman[l].s));
					o=1;
					doberman[l].g++;
					if(doberman[l].g>=f&&p[l]==0){
						q[b]=doberman[l];
						p[l]=1;
						b++;
					}
					break;
				}
			}
			if(o==0){
				//printf("MorishitaSHINE\n");
				js=0;
				if(strlen(d[j])>strlen(d[r])){
					jk=strlen(d[r]);
				}
				else{
					jk=strlen(d[j]);
				}
				for(jc=0;jc<jk;jc++){
					if(d[j][jc]-'a'>d[r][jc]-'a'){
						js=1;
						break;
					}
					if(d[j][jc]-'a'<d[r][jc]-'a'){
						js=2;
						break;
					}
				}
				if(js==1){
					strcpy(t.c,d[r]);
					strcpy(t.s,d[j]);
					t.g=doberman[u].g+1;
				}
				else{
				strcpy(t.c,d[j]);
				strcpy(t.s,d[r]);
				t.g=doberman[u].g+1;
				}
				doberman[u]=t;
				//printf("%s %s %d\n",doberman[u].c,doberman[u].s,doberman[u].g);
				if(doberman[u].g>=f&&p[u]==0){
					q[b]=doberman[u];
					p[u]=1;
					b++;
				}
				u++;
			}
		}
	}
}
for(i=0;i<b;i++){
	for(j=i+1;j<b;j++){
		js=0;
				if(strlen(q[i].c)>strlen(q[j].c)){
					jk=strlen(q[j].c);
				}
				else{
					jk=strlen(q[i].c);
				}
		for(jc=0;jc<jk;jc++){
			if(q[i].c[jc]-'a'>q[j].c[jc]-'a'){
				js=1;
				break;
			}
			if(q[i].c[jc]-'a'<q[j].c[jc]-'a'){
				js=2;
				break;
			}
		}
		if(js==0){
				if(strlen(q[i].s)>strlen(q[j].s)){
					jk=strlen(q[j].s);
				}
				else{
					jk=strlen(q[i].s);
				}
		for(jc=0;jc<jk;jc++){
			if(q[i].s[jc]-'a'>q[j].s[jc]-'a'){
				js=1;
				break;
			}
			if(q[i].s[jc]-'a'<q[j].s[jc]-'a'){
				js=2;
				break;
			}
		}
		}
		if(js==1){
			t=q[i];
			q[i]=q[j];
			q[j]=t;
		}
	}
}
printf("%d\n",b);
for(i=0;i<b;i++){
	printf("%s %s\n",q[i].c,q[i].s);
}
return 0;
}


Measured memory_bytes: 2920
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

int main(){
  int n,sum = 0;
  cin >> n;
  int l[n];
  REP (i,n) {
    cin >> l[i];
  }
  SORT(l,n);
  REP(i,n-1) {
    sum+=l[i];
  }
  if (sum > l[n-1]) {
    cout << "Yes";
  } else {
    cout << "No";
  }
} 

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
    N=ii()
    for i in range(1,10):
        for j in range(1,10):
            if i*j==N:
                print('Yes')
                exit()
    print('No')
if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>

using namespace std;

typedef long long ll ;
typedef double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector< pair<int,int> > vii;
const double pi = 2*acos(0) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define mp			make_pair
#define fi			 first
#define se			 second
#define for0(i,n)        for(int i=0;i<n;i++)
#define for1(i,n)        for(int i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
#define abs(x)		fabs(x)
#define pcase(z,x)    cout<<"Case "<<z<<": "<<x<<"\n"

int main()
{
	int n,c=0;
	string s;
	cin>>s;
	n = s.size();
	for0(i,n/2){
		if(s[i]!=s[n-i-1]) c++;
		}
	cout<<c<<nw;
	return 0;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, T, *AB = map(int, read().split())
    D = [(a, b) for a, b in zip(*[iter(AB)] * 2)]

    D.sort()
    A, B = zip(*D)

    dp = [[0] * T for _ in range(N + 1)]
    for i, (a, b) in enumerate(D):
        for t in range(T):
            if 0 <= t - a:
                dp[i + 1][t] = dp[i][t - a] + b
            if dp[i + 1][t] < dp[i][t]:
                dp[i + 1][t] = dp[i][t]

    ans = 0
    for i in range(N):
        tmp = dp[i + 1][T - 1] + max(B[i + 1 :], default=0)
        if ans < tmp:
            ans = tmp

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 144876
// Template
#include <bits/stdc++.h>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep3(i, l, r) for (int i = (int)(l); i < (int)(r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define per(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003LL;
template <typename T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}
struct IOSET {IOSET() {cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} ioset;

// Main
int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    
    vector<int> a_cnt(n + 1, 0), b_cnt(n + 1, 0);
    rep(i, n) {
        ++a_cnt[a[i]];
        ++b_cnt[b[i]];
    }
    rep(i, n + 1) {
        if (a_cnt[i] + b_cnt[i] > n) {
            cout << "No\n";
            return 0;
        }
    }
    
    reverse(all(b));
    int begin_idx = -1, end_idx = n;
    rep(i, n) {
        if (a[i] == b[i] && begin_idx == -1) begin_idx = i;
        if (a[i] != b[i] && begin_idx != -1 && end_idx == n) end_idx = i;
    }
    if (begin_idx == -1) {
        cout << "Yes\n";
        rep(i, n) cout << b[i] << " \n"[i == n - 1];
        return 0;
    }
    int cnt = end_idx - begin_idx, now = 0, x = b[begin_idx];
    while (cnt) {
        while (a[now] == x || b[now] == x) ++now;
        swap(b[end_idx - cnt], b[now]);
        --cnt;
    }
    cout << "Yes\n";
    rep(i, n) cout << b[i] << " \n"[i == n - 1];
    return 0;
}


Measured memory_bytes: 6340
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

ll dp[1000][6][6][6];

int main(){
    ll n; 
    cin >> n;
    constexpr ll mod = 1e9+7;
    dp[0][0][0][0] = 1;
    rep(i, 0, n){
        rep(j, 0, 5){
            rep(k, 0, 5){
                rep(l, 0, 5){
                    rep(m, 1, 5){
                        if(j == 1 && k == 2 && m == 3) continue; // AG*C
                        if(j == 1 && l == 2 && m == 3) continue; // A*GC
                        if(k == 1 && l == 2 && m == 3) continue; // *AGC
                        if(k == 1 && l == 3 && m == 2) continue; // *ACG
                        if(k == 2 && l == 1 && m == 3) continue; // *GAC
                        dp[i+1][k][l][m] += dp[i][j][k][l];
                        dp[i+1][k][l][m] %= mod;
                    }
                }
            }
        }
    }
    ll ans = 0;
    rep(i, 1, 5){
        rep(j, 1, 5){
            rep(k, 1, 5) {
                ans += dp[n][i][j][k];
                ans %= mod;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3740
#include <iostream> // {{{
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <cstdio> // }}}

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

using namespace std;

int main() {
    int n,k,sum;
    cin >>  n >> k;
    sum = 1;
    rep(i,n){
        if (sum < k) {
            sum = sum * 2;
        } else {
            sum = sum + k;
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
odd = len([a for a in A if a %2 == 1])
 
if K == 0 and odd == 0:
  print(2**N)
elif K == 1 and odd == 0:
  print(0)
else:
  print(2**(N-1))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define int long long
using namespace std;
bool chmax(int &a,int b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
signed main(){
  int N;
  cin>>N;
  vector<int> A(N);
  int mx1=0,mx2=0,n1=0,n2=0;
  for(int i=0;i<N;i++){
    cin>>A[i];
    if(A[i]>0){
      if(chmax(mx1,A[i]))n1=i;
    }else if(chmax(mx2,-A[i]))n2=i;
  }
  vector<pair<int,int>> ans;
  if(mx1>=mx2){
    for(int i=0;i<N;i++)
      if(A[i]<0)ans.push_back({n1,i});
    for(int i=1;i<N;i++)ans.push_back({i-1,i});
  }else{
    for(int i=0;i<N;i++)
      if(A[i]>0)ans.push_back({n2,i});
    for(int i=N-1;i>0;i--)ans.push_back({i,i-1});
  }
  cout<<ans.size()<<endl;
  for(pair<int,int> p:ans)cout<<p.first+1<<' '<<p.second+1<<endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include<cmath>
#include<stack>
#include<queue>
#include<string>
#include<algorithm>
using namespace std;


int main(){
    
    int n,q;
    cin>>n>>q;
    queue< pair<string,int> > Q;
    for(int i=0;i<n;i++){
        string name;
        int t;
        cin>>name>>t;
        Q.push(make_pair(name,t));
    }
    
    pair<string,int> u;
    int elaps=0;
    int a;
    
    while(!Q.empty()){
        u=Q.front();
        Q.pop();
        a=min(u.second,q);
        u.second-=a;
        elaps+=a;
        if(u.second>0){
            Q.push(u);
        }else{
            cout<<u.first<<' '<<elaps<<endl;
        }
        
        
        
    }
    
    
  /*  queue<int> Q;
    Q.push(1);
    cout<<Q.front()<<endl;
    Q.push(2);
    cout<<Q.front()<<endl;
    Q.pop();
    cout<<Q.front()<<endl;
*/
    
    return 0;
}



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

inline void longswap(int64_t& a, int64_t& b){
  if (b > a){
    int64_t t = a;
    a = b;
    b = t;
  }
}

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

  vector<int64_t> L(N);
  
  for (int n = 0; n < N; n++){
    cin >> L.at(n);
  }

  int ans = 0;
  for (int a = 0; a < N; a++){
    for (int b = a+1; b < N; b++){
      for (int c = b+1; c < N; c++){
	int64_t la = L.at(a);
	int64_t lb = L.at(b);
	int64_t lc = L.at(c);
	if (la == lb || lb == lc || lc == la){
	  continue;
	}
	//cout << a << ":" << b << ":" << c << " " << la << " " << lb << " " << lc << endl;
	longswap(lb, lc);
	longswap(la, lb);
	if (la < (lb + lc)){
	  ans++;
	}
      }
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3616
#include <stdio.h>
 
int main(void){
  int a[6];
  int h;
  scanf("%d %d",&a[0],&a[1]);
  scanf("%d %d",&a[2],&a[3]);
  scanf("%d %d",&a[4],&a[5]);

  int tmp,j,i;

  for (i = 1; i<6; i++) {
    tmp = a[i];
    if (a[i - 1] > tmp) {
        j = i;
        do {
            a[j] = a[j - 1];
            j--;
        } while (j > 0 && a[j - 1] > tmp);
        a[j] = tmp;
    }
  }
  
  /*for (i = 0; i<6; i++){
  	printf("%d",a[i]);  //ここまで配列の準備
  }*/
  
  if((a[0]==1 && a[1]==1 && a[2]==2 && a[3]==2 && a[4]==3 && a[5]==4)||(a[0]==1 && a[1]==1 && a[2]==2 && a[3]==3 && a[4]==3 && a[5]==4)||(a[0]==1 && a[1]==1 && a[2]==2 && a[3]==3 && a[4]==4 && a[5]==4)||(a[0]==1 && a[1]==2 && a[2]==2 && a[3]==3 && a[4]==3 && a[5]==4)||(a[0]==1 && a[1]==2 && a[2]==2 && a[3]==3 && a[4]==4 && a[5]==4)||(a[0]==1 && a[1]==2 && a[2]==3 && a[3]==3 && a[4]==4 && a[5]==4)){
    printf("YES");
  }else{
    printf("NO");
  }

  return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;
const ll INF = 1e18;

int main() {
    int N; cin >> N;
    vector<ll> a(N); for (int i = 0; i < N; i++) cin >> a[i];

    // Cumulative sum
    for (int i = 1; i < N; i++) a[i] += a[i - 1];

    ll ans = INF;
    for (int i = 0; i < N - 1; i++) ans = min(ans, abs(2*a[i] - a[N - 1]));

    cout << ans << endl;
    return 0;
}

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

int main(int argc, char *argv[]) {
	int students = 0;
	int checkpoints = 0;
	std::vector<std::map<int, int>> student_coords;
	std::vector<std::map<int, int>> checkpoint_coords;

	std::cin >> students;
	std::cin >> checkpoints;

	int current_x = 0;
	int current_y = 0;
	for (int i = 0; i < students; i++) {
		std::cin >> current_x;
		std::cin >> current_y;
		student_coords.push_back({
			{
				current_x,
				current_y
			} 
		});
	}
	for (int j = 0; j < checkpoints; j++) {
		std::cin >> current_x;
		std::cin >> current_y;
		checkpoint_coords.push_back({
			{
				current_x,
				current_y
			} 
		});
	}

	for (auto student_coord: student_coords) {
		auto student_coord_map = student_coord.begin();
		int student_x = student_coord_map->first;
		int student_y = student_coord_map->second;

		int min_distance = INT_MAX;
		int min_distance_point = INT_MAX;
		
		int current_checkpoint = 1;	
		for (auto checkpoint_coord: checkpoint_coords) {
			auto checkpoint_coord_map = checkpoint_coord.begin();
			int checkpoint_x = checkpoint_coord_map->first;
			int checkpoint_y = checkpoint_coord_map->second;

			int distance_x = std::abs(
				student_x - checkpoint_x
			);
			int distance_y = std::abs(
				student_y - checkpoint_y
			);
			int distance = distance_x + distance_y;

			if (distance <= min_distance) {
				if (min_distance == distance) {
					if (current_checkpoint <= min_distance_point) {
						min_distance_point = current_checkpoint;
					}
				} else {
					min_distance_point = current_checkpoint;
				}
				min_distance = distance;
			}
			current_checkpoint++;
		}

		std::cout << min_distance_point << std::endl;
	}

	return 0;
}


Measured memory_bytes: 256
# ABC136D - Gathering Children
def main():
    S = input().rstrip() + "R"
    n = len(S)
    # decompose into partial strings (RR...LL)
    cur, P = S[0], []
    for i in S[1:]:
        if cur[-1] == "L" and i == "R":
            P += [cur]
            cur = ""
        cur += i
    # children on even numbers -> even, odds -> odd
    # children gather the border of "RL"
    ans = []
    for p in P:
        e, o = len(p) // 2, len(p) // 2 + len(p) % 2
        r_cnt, l_cnt = p.count("R"), p.count("L")
        l, r = (e, o) if p.index("L") % 2 == 0 else (o, e)
        ans += [0] * (r_cnt - 1) + [l] + [r] + [0] * (l_cnt - 1)
    print(*ans)


if __name__ == "__main__":
    main()

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

int main(){
    int n;
    cin >> n;
    int ansnum = -1;
    int ans = 0;
    for(int i = 1; i <= n; i++){
        int count = 0;
        int tmp = i;
        while(tmp % 2 == 0){
            count++;
            tmp /= 2;
        }
        if(ansnum < count){
            ansnum = count;
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define MOD 1000000007

#define trace1(x)                    cout <<#x<<": "<<x<< endl;
#define trace2(x, y)                 cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)              cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)           cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;

typedef long long ll;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    ll i,j,n,m;
    cin>>n;
    ll a[n],b[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        b[i]=a[i];
    }
    sort(b,b+n);
    ll cnt=0;
    for(i=0;i<n;i++)
    {
        if(a[i]!=b[i])
        cnt++;
    }
    if(cnt<=2)
    cout<<"YES";
    else
    cout<<"NO";
    return 0;
}

Measured memory_bytes: 256
from operator import mul
from functools import reduce
from functools import lru_cache


H,W,A,B = map(int,input().split())
ans = 0
mod = 10**9+7

lru_cache(maxsize=None)
def cmb(c, r):
    return fc[c + r] * ic[c] * ic[r] % mod
 
fc = [1] * (H + W)
for i in range(2, H+W):
    fc[i] = fc[i - 1] * i % mod
ic = [pow(x, mod-2, mod) for x in fc]
 
if H-A <= W-B:
    for i in range(0,H-A):
        ans += cmb(i, B-1) * cmb(H - 1 - i,W - 1 -B ) % mod
else:
    for i in range(B, W):
        ans += cmb(i, H - 1 - A) * cmb(W - 1 - i, A - 1) % mod
  
print(ans%(mod))

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

using namespace std;

int main()
{
  int N, M;
  int G[50] = {};

  cin >> N >> M;
  for(int i = 0; i < M; i++) {
    int A, B;
    cin >> A >> B;
    --A, --B;
    G[A]++;
    G[B]++;
  }
  for(int i = 0; i < N; i++) {
    cout << G[i] << endl;
  }

}

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

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

    string S;
    cin >> S;
    char s1, s2;
    s1 = S[0];
    if (S[1] == s1){
        if (S[2] == S[3] && S[2] != s1){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
    else {
        s2 = S[1];
        if (S[2] == s1){
            if (S[3] = s2){
                cout << "Yes" << endl;
            }
            else{
                cout << "No" << endl;
            }
        }
        else{
            if (S[2] == s2 && S[3] == s1){
                cout << "Yes" << endl;
            }
            else{
                cout << "No" << endl;
            }
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
 
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FILL0(x) memset(x,0,sizeof(x))
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
 
int main()
{
    string N;
    cin >> N;
 
    rep(i, 3)
    {
        if(N[i]=='7')
        {
        cout << "Yes" << endl;
        return 0;
        }
    }
    
    cout << "No" << endl;
 
 
 
 
 
 
 
 
    return 0;
}

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


long long calc(vector<long long>&s,vector<long long>&t,long long x){
    vector<long long>::iterator sRight = lower_bound(s.begin(),s.end(),x);//x[i]以上が最初に現れる要素
    vector<long long>::iterator sLeft;
    if(sRight != s.begin()){
        sLeft =sRight -1;
    }else{
        sLeft =sRight;
    }
    vector<long long>::iterator tRight = lower_bound(t.begin(),t.end(),x);
    vector<long long>::iterator tLeft;
    if(tRight != t.begin()){
        tLeft = tRight -1;
    }else{
        tLeft = tRight;
    }
    long long tmp = min({
    (long long)abs(*sRight-x)+(long long)abs(*sRight-*tRight),
    (long long)abs(*sRight-x)+(long long)abs(*sRight-*tLeft),
    (long long)abs(*sLeft-x)+(long long)abs(*sLeft-*tRight),
    (long long)abs(*sLeft-x)+(long long)abs(*sLeft-*tLeft),
    (long long)abs(*tRight-x)+(long long)abs(*tRight-*sRight),
    (long long)abs(*tRight-x)+(long long)abs(*tRight-*sLeft),
    (long long)abs(*tLeft-x)+(long long)abs(*tLeft-*sRight),
    (long long)abs(*tLeft-x)+(long long)abs(*tLeft-*sLeft),
    });
    return tmp;
}

int main(){
    long long A,B,Q;cin>>A>>B>>Q;
    vector<long long> s(A),t(B),x(Q);
    vector<long long>ans(Q);
    for(long long i = 0; i < s.size(); i++)
    {
        cin>>s[i];
    }
    for(long long i = 0; i < t.size(); i++)
    {
        cin>>t[i];
    }
    for(long long i = 0; i < x.size(); i++)
    {
        cin>>x[i];
    }
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    for(long long i = 0; i < ans.size(); i++)
    {
        ans[i] = calc(s,t,x[i]);
    }
    for(long long i = 0; i < ans.size(); i++)
    {
       std::cout<<ans[i]<<endl;
    }
}

Measured memory_bytes: 4480
/*
   Creator - Glitched
   Yeet!!
*/
#include "bits/stdc++.h"
using namespace std;

#define testcases ll T;cin>>T;while(T--)
#define ll long long
#define loop(i,x,n) for(ll i=x;i<n;i++)
#define loopr(i,x,n) for(ll i=n-1;i>=x;i--)
#define ff first
#define ss second
#define pb push_back
#define elif else if
#define flush cout<<"\n"
#define mod 1E9+7
#define L LONG_MAX
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
const string yes = "Yes", no = "No";

int main()
{	
	fastio;
	ll k,n,ans = L;
	cin>>k>>n;
	vector<ll> v(n);
	loop(i,0,n)cin>>v[i];
	sort(v.begin(), v.end());

	loop(i,1,n){
		ll x = v[i] - v[i-1];
		x = k-x;
		ans = min(ans,x);
	}
	ll x = v[n-1] - v[0];
	ans = min(ans,x);
	cout<<ans;

}


Measured memory_bytes: 1792
#include<stdio.h>
#include<map>
#include<algorithm>
#include<string.h>
#include<vector>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<ctype.h>
using namespace std;

typedef long long ll;

const int MM = 1000000007;
const int MX = 1005;

int main()
{
	int A, B, C;
	scanf("%d%d%d", &A, &B, &C);
	if( A%2 == 0 || B%2 == 0 || C%2 == 0 ) return !printf("0\n");
	printf("%lld\n", min({(ll)A*B, (ll)B*C, (ll)C*A}));
}


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

int main() {
  int x, y;
  cin >> x >> y;

  if (x < y) {
    if (-x == y)
      cout << 1 << endl;
    else if (x >= 0 || y <= 0)
      cout << y - x << endl;
    else {
      if (abs(x) < y)
        cout << y + x + 1 << endl;
      else
        cout << abs(y + x) + 1 << endl;
    }
  }
  if (x > y) {
    if (x == 0)
      cout << 1 + abs(y) << endl;
    else if (x < 0)
      cout << 2 + x - y << endl;
    else if (y > 0)
      cout << 2 + x - y << endl;
    else
      cout << 1 + abs(x + y) << endl;
  }
}

Measured memory_bytes: 256