akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;

int main()
{
	string a,b;
	while(getline(cin,a))
	{
		getline(cin,b);
		int hit=0,blow=0;

		for (int i = 0; i < 7; ++i)
		{
			for (int j = 0; j < 7; ++j)
			{
				if(b[i]!=' '&&b[i]==a[j])
				{
					if(i==j) hit++;
					else blow++;
				}
			}
		}
		cout<<hit<<" "<<blow<<endl;
	}
	return 0;
}

Measured memory_bytes: 1172
#include<stdio.h>
 
int main(void) {
    int x,y;
    int menseki,gaishu;
    scanf("%d %d", &x, &y);
    menseki = x * y;
    gaishu = 2*(x + y);
    printf("%d %d\n", menseki, gaishu);
    return 0;
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
import sys, re, copy, math, itertools
from copy import *
from collections import deque, defaultdict
from heapq import *
from bisect import *
#import numpy as np
#import scipy as sp

# 読み込み
Sp = input()
T  = input()

def exist_match(Sp, T):
    idx = []
    for i in range( len(Sp)-len(T)+1 ):
        OK = 1
        for j in range( len(T) ):
            if Sp[i+j]!='?' and Sp[i+j]!=T[j]:
                OK = 0
                break
        if OK==1:
            idx.append(i)
    return idx

Idx = exist_match(Sp, T)

# マッチなし
if len(Idx)==0:
    print('UNRESTORABLE')
    exit()

# 文字列候補作成
Ls = len(Sp)
Lt = len(T)
Ss = []

for i in Idx:
    S = ""
    for j in range(i) : S += Sp[j]
    for j in range(Lt): S += T[j]
    for j in range(Ls-i-Lt): S += Sp[ i+Lt+j ]
    S = S.replace('?', 'a')
    Ss.append(S)

# 辞書順最小
Ss.sort()
print(Ss[0])

Measured memory_bytes: 3824
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<functional>
using namespace std;

int main(){

  int a,b;
  cin>>a>>b;
  char x[a+b+1];
  for(int i=0;i<a+b+1;i++){
    cin>>x[i];
  }

  for(int i=0;i<a+b+1;i++){
      if(i==a){
          if(x[i]!='-'){
              cout<<"No"<<endl;
              return 0;
          }
      }else{
          if(x[i]=='-'){
              cout<<"No"<<endl;
              return 0;
          }
      }
  }
  cout<<"Yes"<<endl;

}

Measured memory_bytes: 256
def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end  
def copy(a) Marshal.load(Marshal.dump(a)) end
def kaizyo(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end
def na(n=0,d=0) Array.new(n,d)end
def na2(n=0,m=0,d=0) Array.new(n){Array.new(m,d)}end
def na3(n=0,m=0,l=0,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def bit(n) n.to_s(2).split("").map(&:to_i) end
def inp() a=gets.chomp.split(" ").map(&:to_i)end
n = inp[0]
a=inp
sum = a[0]
summ = sum
c = 0
if(sum <0)
  sum = sum
else
  c += (1+(sum))
  sum = -1
end
a.delete_at(0)
(a).each do |d|
  if(sum >0)
    if(sum+d < 0)
      sum+=d
    else
      c+=((sum+d)+1)
      sum = -1
    end
  else
    if(sum+d > 0)
      sum+=d
    else
      c+=(1-(sum+d))
      sum = 1
    end
  end
end
min = c
c = 0
sum = summ
if(sum >0)
  sum = sum
else
  c += (1-(sum))
  sum = 1
end
(a).each do |d|
  if(sum >0)
    if(sum+d < 0)
      sum+=d
    else
      c+=((sum+d)+1)
      sum = -1
    end
  else
    if(sum+d > 0)
      sum+=d
    else
      c+=(1-(sum+d))
      sum = 1
    end
  end
end
p [c,min].min
=begin
=end


Measured memory_bytes: 9628
package main

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

var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt()

	aArray := make([]int, n)
	for i := range aArray {
		aArray[i] = nextInt()
	}

	ans := 0
	for i, a := range aArray {
		if i < a-1 && aArray[a-1] == i+1 {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 2048
import sys
sys.setrecursionlimit(10**9)

N, A, B, C, D = map(int, input().split())
inputs = list(input())

def compute(index, end):
    if inputs[index] == '#' or index > end:
        return False
    if index == end:
        return True
    return compute(index+1, end) or compute(index+2, end)

flag = False
if A < C and C < B:
    flag = compute(A-1, C-1) and compute(B-1, D-1)
elif B < C < D:
    flag = compute(A-1, C-1) and compute(B-1, D-1)
elif D < C:
    for index in range(B-2, D-1):
        if (index != A - 1) and inputs[index] != '#' and inputs[index+1] != '#' and inputs[index+2] != '#':
            flag = True
    flag = flag and compute(A-1, C-1) and compute(B-1, D-1)

print('Yes' if flag else 'No')


Measured memory_bytes: 98128
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int a, b, c;
  cin >> a >> b >> c;
  cout << min(b / a, c);
}
#endif


Measured memory_bytes: 3596
N = int(input())
a = list(map(int, input().split()))

mod_4 = 0
mod_2 = 0
for a_i in a:
    if a_i % 4 == 0:
        mod_4 += 1
    elif a_i % 2 == 0:
        mod_2 += 1

if mod_2 == 0:
    m = 2 * mod_4 + 1
else:
    m = 2 * mod_4 + mod_2

if m >= N:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin >> N;
    vector<long long> X(N),Y(N);
    vector<pair<long long,int>> P(N);
    for(int i = 0; i < N; i++){
        cin >> X[i];
        P[i] = make_pair(X[i],i);
    }
    sort(P.begin(),P.end());
    long long a = P[N/2-1].first;
    long long b = P[N/2].first;
    vector<pair<long long,int>> Q(N);
    for(int i = 0; i < N; i++){
        if(i < N/2) Y[i] = b;
        else Y[i] = a;
        Q[i] = make_pair(P[i].second,Y[i]);
    }
    sort(Q.begin(),Q.end());
    for(int i = 0; i < N; i++) cout << Q[i].second << endl;
}


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

const double eps=1e-5;

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	int a[n],s=0;
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
		s+=a[i];
	}
	double ave=(double)s/n,mi=1000000.0,ans=-1;
	for (int i = 0; i < n; ++i)
	{
		if (fabs((double)ave-a[i])+eps<mi)
		{
			mi=fabs((double)ave-a[i]);
			ans=i;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
H = list(map(int,input().split()))

dp = [0 for i in range(n)]
dp[0] = 0
dp[1] = abs(H[0]-H[1])

for i in range(2,n):
    dp[i] = min(dp[i-1]+abs(H[i]-H[i-1]), dp[i-2]+abs(H[i]-H[i-2]))

print(dp[n-1])

Measured memory_bytes: 13980
fun main(args: Array<String>) {
    a102(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

fun a102(args: Array<String>) {
    if (args.size != 1) {
        throw IllegalArgumentException()
    }
    val num = args[0].toInt()
    println(if (num % 2 == 0) num else num * 2)
}


Measured memory_bytes: 33592
#include <iostream>
#include <functional>
#include <algorithm>
#include <climits>
#include <string>
#include <vector>
#include <map>
#include <cmath>

using namespace std;

namespace _{struct _{_(){ // initialize
  cin.tie(0); ios::sync_with_stdio(false);
}}_;}
template <typename T, size_t size>
inline size_t len(const T (&)[size]) { return size; }
#define println(s) cout << s << '\n';
#define str to_string
#define rep(i, n) for (int i=0; i<int(n); i++)
#define all(c) (c).begin(), (c).end()


int main() {
  // A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
  // <-> D E F G H I J K L M N O P Q R S T U V W X Y Z A B C
  char str[1000];
  cin >> str;
  rep(i, len(str)) {
    char c = str[i];
    // end of input
    if (c == '\0') break;
    char a;
    if      (c == 'A') a = 'X';
    else if (c == 'B') a = 'Y';
    else if (c == 'C') a = 'Z';
    else a = (char)(c-3);
    cout << a;
  }
  cout << endl;
  return 0;
}

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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 1e5, ksz = 3e3, mod = 1e9 + 7;
int n, m, k, fac[2 * nsz + 5], ifac[2 * nsz + 5], dp[nsz + 5];
pair<int, int> pos[ksz + 5];

int inline qpow(int a, int p) {
    int res = 1;
    for (; p; p >>= 1) {
        p & 1 && (res = (num) res * a % mod);
        a = (num) a * a % mod;
    }
    return res;
}

void inline init() {
    fac[0] = ifac[0] = 1;
    cont (i, 2 * nsz) {
        fac[i] = (num) fac[i - 1] * i % mod;
        ifac[i] = qpow(fac[i], mod - 2);
    }
}

int inline C(int n, int m) {
    return (num) fac[n] * ifac[m] % mod * ifac[n - m] % mod;
}

int main() {
    init();
    scanf("%d%d%d", &n, &m, &k);
    cont (i, k) {
        scanf("%d%d", &pos[i].first, &pos[i].second);
    }
    sort(pos + 1, pos + k + 1);
    cont (i, k) {
        int x = pos[i].first, y = pos[i].second;
        dp[i] = C(x + y - 2, x - 1);
        cont (j, i - 1) {
            int cx = pos[j].first, cy = pos[j].second, dx = x - cx + 1, dy = y - cy + 1;
            if (cx <= x && cy <= y) {
                dp[i] -= (num) dp[j] * C(dx + dy - 2, dx - 1) % mod;
                if (dp[i] < 0) {
                    dp[i] += mod;
                }
            }
        }
    }
    dp[0] = C(n + m - 2, n - 1);
    cont (i, k) {
        int dx = n - pos[i].first + 1, dy = m - pos[i].second + 1;
        dp[0] -= (num) dp[i] * C(dx + dy - 2, dx - 1) % mod;
        if (dp[0] < 0) {
            dp[0] += mod;
        }
    }
    printf("%d\n", dp[0]);
}

Measured memory_bytes: 1792
def f0(N):
    if N < 2:
        return 1
    return N * f0(N-2)

def f(N):
    answer = 1
    n = N
    while n >= 2:
        answer *= n
        n -= 2
    return answer

def test(N):
    b = f(N)
    answer = 0
    while b > 0:
        b, r = divmod(b, 10)
        if r == 0:
            answer += 1
        else:
            break
    return answer

def solve(N):
    M = 10**18
    a = 10
    A = []
    while a <= M:
        A.append(a)
        a *= 5
    #print(len(A))

    if N % 2 == 1:
        return 0
    answer = 0
    for a in A:
        answer += N//a
    return answer

"""
for i in (98, 100, 110, 120, 148, 150, 200, 248, 250, 296, 298, 300, 400, 900, 950, 1000, 5000, 100000):
    t = test(i)
    print(i, t, solve(i), i//10, i//50, i//250, "rem:%d"%(t-(i//10+i//50+i//250+i//(5**3*10))), sep="\t")
"""
N = int(input())
print(solve(N))


Measured memory_bytes: 3064
o = input()
e = input()
n = len(o)
x = ''
if len(o) == len(e):
    for i in range(n):
        x += o[i]
        x += e[i]
else:
    for i in range(n):
        if i != n-1:
            x += o[i]
            x += e[i]
        else:
            x += o[i]
print(x)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <stack>
#include <vector>
#include <queue>
#include <math.h>
#include <algorithm>
#include <numeric>
#include <set>

using namespace std;

void solve();

int main() {
	solve();
	return 0;
}

//////////////////////////////////////////////////
//////////////////////////////////////////////////

int X, Y, Z, K;
vector<long long> A, B, C;
vector<long long> AB;
vector<long long> ABC;


void solve() {
	cin >> X >> Y >> Z >> K;
	A.resize(X);
	B.resize(Y);
	C.resize(Z);
	for (int x = 0; x < X; x++)cin >> A[x];
	for (int y = 0; y < Y; y++)cin >> B[y];
	for (int z = 0; z < Z; z++)cin >> C[z];
	sort(A.begin(), A.end(), greater<long long>());
	sort(B.begin(), B.end(), greater<long long>());
	sort(C.begin(), C.end(), greater<long long>());
	for (int x = 0; x < X; x++) {
		for (int y = 0; y < Y; y++)AB.push_back(A[x]+B[y]);
	}
	sort(AB.begin(),AB.end(),greater<long long>());
	for (int xy = 0; xy < min(K, X*Y); xy++) {
		for (int z = 0; z < Z; z++) {
			ABC.push_back(AB[xy]+C[z]);
		}
	}
	sort(ABC.begin(),ABC.end(),greater<long long>());
	for (int a = 0; a < min(X*Y*Z, K); a++) cout << ABC[a] << endl;
	return;
}

Measured memory_bytes: 43240
//package kadai3;
import java.util.*;
public class Main {
	public boolean overlap(int[][] table, int h, int v) { 
		for(int i = 0; i < table.length; i++) {
			if(table[h][v] == table[i][v] && i != h) return true;
		}
		return false;
	}
	void doIt() {
		Scanner sc = new Scanner(System.in);
		Main check = new Main();
		int N = sc.nextInt();
		int[] point = new int[N];
		int[][] num = new int[N][3]; 
		for(int i = 0; i < N; i++) {
			num[i][0] = sc.nextInt();
			num[i][1] = sc.nextInt(); 
			num[i][2] = sc.nextInt();
		}
		for(int i = 0; i < 3; i++) {
			for(int j = 0; j < N; j++) {
				if(!check.overlap(num, j, i)) point[j] += num[j][i];
			}
		}
		for(int i = 0; i < N; i++) System.out.println(point[i]);
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().doIt();
	}

}

Measured memory_bytes: 20800
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	static int V;
	static int E;
	static ArrayList<Integer>[] g;

	@SuppressWarnings("unchecked")
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		V = sc.nextInt();
		E = sc.nextInt();
		g = new ArrayList[V];
		for (int i = 0; i < V; ++i)
			g[i] = new ArrayList<>();

		for (int i = 0; i < E; ++i) {
			int s = sc.nextInt();
			int t = sc.nextInt();
			g[s].add(t);
		}

		ord = new int[V];
		vis = new boolean[V];
		pending = new boolean[V];

		sort();

		for (int i = 0; i < V; ++i) {
			System.out.println(ord[i]);
		}
	}

	static int[] ord;
	static boolean[] vis;
	static boolean[] pending;
	static int now = 0;

	static void sort() {
		for (int i = 0; i < V; ++i) {
			if (!vis[i])
				dfs(i, -1);
		}
	}

	static void dfs(int cur, int pre) {
		for (int to : g[cur]) {
			if (to != pre && !vis[to]) {
				if (pending[to])
					throw new AssertionError();
				dfs(to, cur);
			}
		}
		ord[V - now - 1] = cur;
		vis[cur] = true;
		++now;
	}
}

Measured memory_bytes: 70292
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<long> a(n),b(n);
    for (int i=0;i<n;i++){
        cin >> a.at(i);
    }
    reverse(a.begin(), a.end());
    if (n%2==0){
        for (int i=0;i<n/2;i++){
        b.at(i)=a.at(2*i);
        b.at(n-i-1)=a.at(2*i+1);
    }
    }
    else {
        for (int i=0;i<n/2;i++){
        b.at(i)=a.at(2*i);
        b.at(n-i-1)=a.at(2*i+1);
    }
    b.at(n/2)=a.at(n-1);
    }
    for (int i=0;i<n;i++){
        cout << b.at(i) << ' ';
    }
}


Measured memory_bytes: 5248
def scan; gets.split.map(&:to_i); end

hh,ww = scan

min = hh*ww
1.upto(ww-1){|x|
    a = x*hh
    b = (ww-x)*(hh/2)
    c = (ww-x)*((hh+1)/2)
    min = [[a,b,c].max-[a,b,c].min,min].min
}
1.upto(hh-1){|y|
    a = y*ww
    b = (hh-y)*(ww/2)
    c = (hh-y)*((ww+1)/2)
    min = [[a,b,c].max-[a,b,c].min,min].min
}
a = (hh/3)*ww
b = ((hh+1)/3)*ww
c = ((hh+2)/3)*ww
min = [[a,b,c].max-[a,b,c].min,min].min
a = (ww/3)*hh
b = ((ww+1)/3)*hh
c = ((ww+2)/3)*hh
min = [[a,b,c].max-[a,b,c].min,min].min

p min

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

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  
  sort(a.begin(), a.end());
  int ans = 0;
  rep(i,n) {
    x -= a[i];
    if (x < 0) break;
    ans++;
  }
  
  if (x > 0)
    cout << ans-1 << endl;
  else
  cout << ans << endl;
}

Measured memory_bytes: 256
from collections import deque
N,M=map(int,input().split())
G=[[] for i in range(N)]
for i in range(M):
    a,b=map(int,input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
Q=int(input())
v=[0 for i in range(Q)]
d=[0 for i in range(Q)]
c=[0 for i in range(Q)]
for i in range(Q):
    v[-i-1],d[-i-1],c[-i-1]=map(int,input().split());v[-i-1]-=1
q=deque()
color=[0 for i in range(N)]
dp=[-1 for i in range(N)]
for t in range(Q):
    if dp[v[t]]>=d[t]:
        continue
    dp[v[t]]=d[t]
    q.append((v[t],d[t]))
    while(q):
        vv,dd=q.popleft()
        if color[vv]==0:
            color[vv]=c[t]
        dd-=1
        for y in G[vv]:
            if dp[y]>=dd:
                continue
            dp[y]=dd
            q.append((y,dd))
for line in color:
    print(line)


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

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

    int x, n;
    cin >> x >> n;

    vector<int> p(n);
    rep(i, n) cin >> p[i];

    sort(p.begin(), p.end(), greater<int>());
    int res = -1;
    int min_diff = 1001001001;
    rep(i, 201){
        bool flg = false;
        rep(j, n){
            if(i==p[j]){
                flg = true;
                break;
            }
        }
        if(flg) continue;
        int diff = abs(x - i);
        if(diff < min_diff){
            res = i;
            min_diff = diff;
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	long long int a,L[100];
	L[0]=2,L[1]=1;
	cin>>a;
	for(int i=2;i<=86;i++){
		if(i<=a){
			L[i]=L[i-1]+L[i-2];
		}
	}
	
	cout<<L[a]<<endl;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
 
int main(){
  ll x,y;
  ll a;
  bool flag = false;
  cin >> x >> y;
  
  rep(i, x+1){
    a = x - i;
    if((2*a + 4*i) == y) flag = true;
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */


int main(){
    string s, t; cin >> s >> t;
    ii2(a, b); string u; cin >> u;
    if(s == u) a--; else b--;
    cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    #define __STDC_LIMIT_MACROS
    #include <stdint.h>
    using namespace std;
    #define int             long long
     
    bool isPrime(int n)
    {
        if (n <= 1)
            return false;
        if (n <= 3)
            return true;
        if (n % 2 == 0 || n % 3 == 0)
            return false;
        for (int i = 5; i * i <= n; i += 6)
        {
            if (n % i == 0 || n % (i + 2) == 0)
                return false;
     
        }
        return true;
    }
     
    void c_p_c()
    {
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
     
    }
    int32_t main()
    {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        //c_p_c();
        int x,y;
        cin>>x>>y;
        int a,b,f=0;
        for(int i = 0; i<=x; i++)
        {
            a = i;
            b = x-i;
            if((2*a+4*b)==y)
            {
                cout<<"Yes"<<endl;
                f = 1;
                break;
            }
        }
        if(f==0) cout<<"No"<<endl;
    }   

Measured memory_bytes: 3648
S = input()
Q = int(input())
reverse = False
pref, suf = "", ""

for i in range(Q):
    query = list(input().split())
    if query[0] == "1":
        reverse = not reverse
    else:
        if reverse == False:
            if query[1] == "1":
                pref = query[2] + pref
            else:
                suf = suf + query[2]
        else:
            if query[1] == "1":
                suf = suf + query[2]
            else:
                pref = query[2] + pref

if reverse == False:
    ans = pref + S + suf
else:
    ans = suf[::-1] + S[::-1] + pref[::-1]

print(ans)


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

int main(){
	int N;
	cin >> N;
	int i, a[N], min=10000, max=-10;
	for(i=0; i<N; i++){
		cin >> a[i];
		if(a[i] < min)	min = a[i];
		if(max < a[i])	max = a[i];
	}
	
	cout << max-min << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
import numpy as np

sys.setrecursionlimit(10 ** 9)

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

ans = 0
dp = np.zeros(N, dtype=int)
H = np.array(H_)

for i in range(1, N):
    k = i - K if i - K > 0 else 0
    
    dp[i] = np.min(dp[k:i] + abs(H[k:i] - H[i]))
#    np.minimum(dp[k:i], abs(H[k:i] - H[i]), out = dp[i])

ans = dp[-1]
print(ans)

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

ll A[55];
ll P[55];

ll f(ll N, ll X){
    if(X == 1){
        if(N == 0){
            return 1;
        }else{
            return 0;
        }
    }
    else if((1 < X) and (X <= 1+A[N-1])){ return f(N-1, X-1);}
    else if(X == 2+A[N-1]){ return P[N-1]+1;}
    else if((2+A[N-1] < X) and (X <= 2+2*A[N-1])){ return P[N-1]+1+f(N-1, X-2-A[N-1]);}
    else if(3+2*A[N-1] == X){ return 2*P[N-1]+1;}
}


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

    ll N, X;
    cin >> N >> X;
    rep(i, N){
        if(i == 0){
            A[i] = 1;
            P[i] = 1;
        }else{
            A[i] = 2*A[i-1]+3;
            P[i] = 2*P[i-1]+1;
        }
    }
    cout << f(N, X) << endl;

}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

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

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();

        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int x = scanner.nextInt();
        int y = scanner.nextInt();
        int x_max = x;
        int y_min = y;

        int tmp = 0;
        for (int i=0;i<n;i++) {
        	tmp = scanner.nextInt();
        	if(tmp>x_max) {
        		x_max = tmp;
        	}
        }
        for (int j=0;j<m;j++) {
        	tmp = scanner.nextInt();
        	if(tmp<y_min) {
        		y_min = tmp;
        	}
        }

        if(x_max>=y_min){
        	System.out.println("War");
        }else if((x_max == x)&&(y_min==y)) {
        	System.out.println("War");
        }else {
        	System.out.println("No War");
        }


    }

    private static long gcd(long m, long n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }

    private static long lcm(long m, long n) {
        return m * n / gcd(m, n);
    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}

Measured memory_bytes: 23252
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))

out = 0
negative_cnt = 0
min_abs = 1000000000
for _a in a:
    tmp = abs(_a)
    if _a <= 0:
        negative_cnt += 1
    min_abs = min(min_abs, tmp)
    out += tmp

if negative_cnt % 2 != 0:
    out -= min_abs * 2

print(out)


Measured memory_bytes: 14412
#include<iostream> 
#include<vector>
using namespace std; 
int main() {
	int n, t; 
	cin >> n >> t;  
	int a, b; 
	int ans = 0;
	int c, d; 
	int tle = 0;
	cin >> c >> d; 
	
		ans = c;
		if (t < d)
		{
			tle++;
	}
	
	for (int i = 0; i < n-1; i++)
	{
		cin >> a >> b; 
		if (b<=t)
		{
			if (ans >= a)
			{
				ans = a;

		  }
		} 
		else
		{
			tle++;
		}
	} 
	 
	if (tle==n)
	{
		cout << "TLE\n";
	} 
	else
	{
		cout << ans << "\n";
	}
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>




using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const int INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 1000 * 1000 * 1000 + 7;



void solve() {
    string s;
    cin >> s;
    ll k;
    cin >> k;
    int n = s.size();
    ll res = 0;
    int ls = -1;
    for (int i = 1; i < n; ++i) {
        if (s[i] == s[i - 1]) {
            ++res;
            ls = i;
            ++i;
        }
    }
    if (k == 1) {
        cout << res << endl;
        return;
    }
    if (s[0] != s[n - 1]) {
        cout << res * k << endl;
        return;
    }
    if (ls == n - 1) {
        cout << res * k << endl;
        return;
    }
    ll add = 1;
    ls = 0;
    for (int i = 2; i < n; ++i) {
        if (s[i] == s[i - 1]) {
            ++add;
            ls = i;
            ++i;
        }
    }
    if (ls != n - 1) {
        cout << res + add * (k - 1) << endl;
        return;
    }
    ll ans = res + add;
    ans = ans * (k / 2);
    if (k & 1)
        ans += res;
    cout << ans << endl;



}


//#define LOCAL

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

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    solve();


#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<functional>
#include<utility>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<list>
using namespace std;
constexpr auto MOD = 1000000007;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
#define rep(i,n) for(int i = 0; i < (n);i++)
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VLL;



int main() {
   int a, b;
   cin >> a >> b;
   cout << max(0, a - 2 * b) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include <cmath>
#include <limits>
using namespace std;
 
int main() {
	int a = 0;
	int b = 0;
	cin >> a >> b;
	int couA = 0;
	int couB = 0;
	for (int i = 0; i < b;i++) {
		couA += a*pow(10,i);
	}
	for (int i = 0; i < a; i++) {
		couB += b * pow(10, i);
	}
	if (b<=a) {
		cout<<couB<<endl;
	}
	else {
		cout << couA << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include<iomanip>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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; }

typedef long long ll;

using namespace std;
typedef pair<int,int > P;
vector<vector<P>> edge;
int n;
ll memo[100001];
void dfs(int par,int node,ll cost)
{
  memo[node]=cost;
  for(auto ne:edge[node])
  {
    if(ne.first!=par)
    {

      dfs(node,ne.first,cost+ne.second);
    }
  }
}


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout<<setprecision(10);
  cin>>n;
  fill(memo,memo+100001,-1);
  edge.resize(n+1);
  rep(i,n-1)
  {
    int a,b,c;
    cin>>a>>b>>c;
    edge[a].push_back({b,c});
    edge[b].push_back({a,c});
  }
  int q,k;
  cin>>q>>k;
  dfs(0,k,0);
  rep(i,q)
  {
    int x,y;
    cin>>x>>y;
    cout<<memo[x]+memo[y]<<"\n";
  }
  cout<<flush;

  return 0;

}


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

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;

vvvi dp(101, vvi(101, vi(2)));

int dfs(int a, int b, int n, int t)
{
    if(dp[a][b][t]) return dp[a][b][t];

    dp[a][b][t] = -1;

    for(int o : {-1, 1})
    {
        if(t == 1)
        {
            int a_ = a + o;

            if(a_ < 1 || a_ > n || a_ == b) continue;

            int r = dfs(a_, b, n, 2);

            if(r == 1) return dp[a][b][t] = 1;
        }
        else
        if(t == 2)
        {
            int b_ = b + o;

            if(b_ < 1 || b_ > n || b_ == a) continue;

            int r = dfs(a, b_, n, 1);

            if(r == 2) return dp[a][b][t] = 2;
        }
    }

    return dp[a][b][t] = (t == 1) ? 2 : 1;
}

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

    int r = dfs(a, b, n, 1);

    string ans;

    if(r == 1) ans = "Alice";
    else ans = "Borys";

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

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
const int  N = 2e5 + 314;
void foo(){
    ll x;
    cin>>x;
    ll best = 1;
    for (ll a = 2; a*a <= x; ++a) {
        for (ll b = a*a; b <= x; b *= a) {
            best = max(best, b);
        }
    }
    cout << best << '\n';
}
int main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)foo();
}

Measured memory_bytes: 256
//                                 Alisher_2211
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        # include <bits/stdc++.h>
# define  long          long long
# define  all(vc)       vc.begin(),vc.end()
# define  allr(vc)      vc.rbegin(),vc.rend()
# define  pb            push_back
# define  fi            first 
# define  se            second
# define  pi            pair <long, long>    
# define  lcm(a, b)     (a * b) / __gcd(a, b)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        using namespace std;
const long N = 100100;
void read(){freopen("input.txt" , "r" , stdin );freopen("output.txt", "w" , stdout );}
void solve(){
    long n;
    cin >> n;
    vector <long> v(n);
    map <long, long> dp;
    for(auto &i: v) cin >> i;
    dp[0] = v[0];
    for (int i = 1; i < n; ++i){
        dp[i] = dp[i - 1] + v[i];
        dp[i] %= 1000000007;
    }
    long ans = 0;
    for (int i = 1; i < n; ++i){
        ans += v[i] * dp[i - 1];
        ans %= 1000000007;
    }
    cout << ans;
}
int32_t main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); 
        long T = 1;
        //cin >> T;
        while( T-- ){
            solve();
            cout<<'\n';
        }
cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}

Measured memory_bytes: 17128
def insertion_sort(A, N):
    print(' '.join(map(str, A)))
    for i in range(1, N):
        v = A[i]
        j = i -1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
        print(' '.join(map(str, A)))

N = int(input())
A = list(map(int, input().split()))
insertion_sort(A, N)


Measured memory_bytes: 5604
#include <stdio.h>
double round3(double a){
	a=a*10000;
	if(int(a)%10>=5){
		a=a+10-int(a)%10;
	}else{
		a=a-int(a)%10;
	}
	a=a/10000;
	return a;

}
int main(){
	double a,b,c,d,e,f;
	double x,y;
	while((scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f))!=EOF){
		if(a==0){
			y=c/b;
			x=(f-e*y)/d;
		}else if(b==0){
			x=c/a;
			y=(f-d*x)/e;
		}else if(d==0){
			y=f/e;
			x=(c-b*y)/a;
		}else if(e==0){
			x=f/d;
			y=(c-a*x)/b;
		}else{
			y=(c*d-a*f)/(b*d-a*e);
			x=(c-b*y)/a;
		}
		
		x=round3(x);
		y=round3(y);
		
		printf("%0.3lf %0.3lf\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 1080
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i = (a); i <= (b); ++ i)
#define rrp(i,a,b) for (int i = (a); i >= (b); -- i)
#define gc() getchar()
#define fir first
#define sec second
typedef pair<int,int> pii;
typedef double db;
typedef long long ll;
template <typename tp>
inline void read(tp& x) {
  x = 0; char tmp; bool key = 0;
  for (tmp = gc(); !isdigit(tmp); tmp = gc())
    key = (tmp == '-');
  for (; isdigit(tmp); tmp = gc()) 
    x = (x << 3) + (x << 1) + (tmp ^ '0');
  if (key) x = -x;
}
template <typename tp>
inline void ckmn(tp& x,tp y) {
  x = x < y ? x : y;
}
template <typename tp>
inline void ckmx(tp& x,tp y) {
  x = x < y ? y : x;
}

const int MOD = 998244353;
inline void Add(int& x,int y) {
  x = x + y >= MOD ? x + y - MOD : x + y;
}
inline void Sub(int& x,int y) {
  x = x - y < 0 ? x - y + MOD : x - y;
}
int power(int a,int b) {
  int ret = 1;
  while (b) {
    if (b&1) ret = 1ll * ret * a % MOD;
    a = 1ll * a * a % MOD;
    b >>= 1;
  }
  return ret;
}

const int N = 410;
int n, a[N], b[N], dp[2][N][N], sz = 400;
int ijc[N], jc[N];
void prework() {
  jc[0] = 1;
  rep (i, 1, sz) jc[i] = 1ll * jc[i-1] * i % MOD;
  ijc[sz] = power(jc[sz], MOD - 2);
  rrp (i, sz-1, 0) ijc[i] = 1ll * ijc[i+1] * (i+1) % MOD;
}
int main() {
  read(n);
  rep (i, 1, n)
    read(a[i]), read(b[i]);
  prework();
  int p = 0;
  dp[0][0][0] = MOD - 1;
  int sum = 0;
  rep (i, 1, n) sum += a[i];
  rep (i, 1, n) {
    p ^= 1;
    memset(dp[p], 0, sizeof dp[p]);
    int val = 1;
    int rec = 1ll * a[i] * power(sum, MOD - 2) % MOD;
    rep (j, 0, b[i]-1) {
      rep (ta, 0, sz - j) rep (tb, 0, sz) {
	Sub(dp[p][ta + j][tb], 1ll * dp[p^1][ta][tb] * ijc[j] % MOD * val % MOD);
      }
      val = 1ll * val * rec % MOD;
    }
    rep (ta, 0, sz) rep (tb, 0, sz - a[i])
      Add(dp[p][ta][tb + a[i]], dp[p^1][ta][tb]);
  }
  int ans = 0;
  rep (ta, 0, sz) rep (tb, 0, sz) if (dp[p][ta][tb] && tb < sum) {
    int pro = 1ll * tb * power(sum, MOD - 2) % MOD;
    int val = dp[p][ta][tb];
    // \sum_{n >= ta} n^{d ta} * val * pro^n / {pro^ta}
    // ta! * 1 / ((1 - pro * x)^{ta+1})
    int tmp = power(1 - pro + MOD, ta + 1);
    tmp = power(tmp, MOD - 2);
    tmp = 1ll * jc[ta] * tmp % MOD;
    tmp = 1ll * tmp * val % MOD;
    // pro = power(pro, ta);
    // tmp = 1ll * tmp * power(pro, MOD - 2) % MOD;
    Add(ans, tmp);
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 1536
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top,S[1000];

void push(int x){
  S[++top]=x;
}

int pop(){
  top--;
  return S[top+1];
}

int main(){
  int a,b;
  top=0;
  char s[100];

  while(scanf("%s",s)!=EOF){
    if(s[0]=='+'){
      a=pop();
      b=pop();
      push(b+a);
    }else if(s[0]=='-'){
      a=pop();
      b=pop();
      push(b-a);
    }else if(s[0]=='*'){
      a=pop();
      b=pop();
      push(a*b);
    }else {
      push(atoi(s)); 
    }
  }

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

  return 0;
}



Measured memory_bytes: 2144
N = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

ans = len(make_divisors(N-1)) - 1

for i in set(make_divisors(N)) - {1}:
    M = N
    while M >= i:
        if M % i == 0:
            M //= i
        else:
            break
    if M % i ==  1:
        ans += 1

print(ans)


Measured memory_bytes: 40300
#include <stdio.h>
#include <string.h>
#define mod 998244353
typedef long long ll;

int main(void) {
  ll i, j, k, n;
  char s[2100];
  scanf("%s", s);
  n = strlen(s);
  ll dp[2 * n][2 * n + 1], sum[2 * n];
  for(i = 0; i < 2 * n; ++i) {
    if(i) {
      sum[i] = sum[i - 1];
      if(i < n) sum[i] += s[i] - '0';
    } else sum[i] = s[i] - '0';
    for(j = 0; j <= 2 * n; ++j) dp[i][j] = 0;
  }
  if(sum[0] != 2) dp[0][0] = 1;
  if(sum[0]) dp[0][1] = 1;
  for(i = 1; i < 2 * n; ++i) {
    for(j = 0; j < 2 * n; ++j) if((i + 1) * 2 - sum[i] > i - j && i + 1 - j > 0) dp[i][j] += dp[i - 1][j];
    for(j = 1; j <= 2 * n; ++j) if(sum[i] >= j) dp[i][j] += dp[i - 1][j - 1];
    for(j = 0; j <= 2 * n; ++j) dp[i][j] %= mod;
  }
  printf("%lld", dp[2 * n - 1][sum[2 * n - 1]]);
  return 0;
}

Measured memory_bytes: 125184
#include<cstdio>
using namespace std;

int main()
{
	int temp;
	int n;
	int four, even, odd;
	four = 0;
	even = 0;
	odd = 0;
	scanf("%d", &n);
	while (n--)
	{
		scanf("%d", &temp);
		if (temp % 4 == 0)
			four++;
		else if(temp%2!=0)
		{
			odd++;
		}
		else {
			even++;
		}
	}
	if (odd > four) {
		if (odd - four == 1 && even == 0)
			printf("Yes\n");
		else
			printf("No\n");
	}
	else
		printf("Yes\n");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static  ll INF = 1e9;
using namespace std;

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


Measured memory_bytes: 256
# frozen_string_literal: true

a = 3.times.map { gets.split.map(&:to_i) }
n = gets.to_i
b = n.times.map { gets.to_i }

hitted = Array.new(3) { Array.new(3, false) }
3.times do |i|
  3.times do |j|
    hitted[i][j] = b.any? { |n| n == a[i][j] }
  end
end

transposed = hitted.transpose
ans = 'No'

3.times do |i|
  ans = 'Yes' if hitted[i].all? || transposed[i].all?
end

if [hitted[0][0], hitted[1][1], hitted[2][2]].all? || [hitted[0][2], hitted[1][1], hitted[2][0]].all?
  ans = 'Yes'
end

puts ans


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

int main() {
  int64_t A,B,K;
  cin>>A>>B>>K;
  int ansT = A;
  int ansA = B;
  if(A>=K){
    cout<<A-K<<" "<<B<<endl;
  }
  else if(A<K&&A+B>=K){
    cout<<"0"<<" "<<A+B-K<<endl;
  }
  else{
    cout<<"0"<<" "<<"0"<<endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define inf 1e9 + 10
using namespace std;
int main()
{
    ll n,W;
    cin>>n>>W;
    ll w[n+1];
    ll v[n+1];
    ll sum=0;
    for(ll i=1;i<=n;i++)
    {
        cin>>w[i]>>v[i];
        sum+=v[i];
    }
    sum=n*1000;
    ll dp[n+1][sum+1];
    for(ll i=0;i<=sum;i++)
    {
        dp[1][i]=inf;
    }
    dp[1][0]=0;
    dp[1][v[1]]=w[1];
    for(ll i=2;i<=n;i++)
    {
        for(ll j=0;j<=sum;j++)
        {
            dp[i][j]=dp[i-1][j];
            if(v[i]>j)
            {
                continue;
            }
            dp[i][j]=min(dp[i-1][j],w[i]+dp[i-1][j-v[i]]);
        }
    }
    ll ans=0;
    for(ll x=0;x<=sum;x++)
    {
        if(dp[n][x]<=W)
        {
            ans=x;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 81768
#include <bits/stdc++.h>
using namespace std ; 
#define ll              long long int
// #define cini(x)	        scanf("%lld",&x)
// #define cins(s)	        scanf("%s",s)
#define deb(x)          cout << (x) << "  " ;
#define out(x)          cout << (x) << endl ;
#define endl            '\n'
#define pb              push_back
#define mk              make_pair
#define fastio          ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define loop(x,n,v)     for(ll v=x; v<n; v++)
#define loopr(n,x,v)     for(ll v=n-1; v>=x; v--)
#define mod             1000000007
#define all(x)          x.begin(), x.end()
#define clr(x)          memset(x, 0, sizeof(x))
#define sortall(x)      sort(all(x))
#define tr(it, a)       for(auto it = a.begin(); it != a.end(); it++)
#define PI              3.1415926535897932384626
#define setbits(x)      __builtin_popcount(x)
#define zrobits(x)      __builtin_ctz(x)
#define ps(x,y)         fixed << setprecision(y) << (x)
#define w(t)            int t; cin>>t; while(t--) 
#define     vi          vector<ll>
#define     vtt         vector<pair<ll,ll>> 
#define     pii         pair<ll,ll> 
#define  mapp           map<ll,ll> 
#define  sett           set<ll>
int dp[1000][1000] ;
ll mpow(ll base, ll exp); 
// =================================
// =================================





int main(){
    fastio ;
    // w(t)
    // {
        ll a=0, b=0, c=0, d=0, e=0, p=0, q=0, r=0 ;
        ll ans=0, res=0, cnt=0, sum=0, diff=0, mul=1, val=0, k=0 ;
        // loop(0,n,i) brr[i]=0;
        // char s[100005];
        string s ;
        ll n,m ;
        cin >> n ;
        // cin >> m ;
        // cin >> s ;
        ll arr[n+1][3], brr[n+1][3]; 
        loop(0,n,i) cin >> arr[i][0] >> arr[i][1] >> arr[i][2] ;

        brr[0][0]=arr[0][0];
        brr[0][1]=arr[0][1];
        brr[0][2]=arr[0][2];

        loop(1,n,i){
            brr[i][0] = arr[i][0] + max(brr[i-1][1],brr[i-1][2]);
            brr[i][1] = arr[i][1] + max(brr[i-1][0],brr[i-1][2]);
            brr[i][2] = arr[i][2] + max(brr[i-1][1],brr[i-1][0]);
        }

        ans = max({brr[n-1][0],brr[n-1][1],brr[n-1][2]});
        out(ans)
    // }
    return 0 ;
}

// g++ x.cpp -o as && ./as

Measured memory_bytes: 8268
#include <algorithm>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define REP(i, m, n) for (int i = int(m); i < int(n); i++)
#define RREP(i, m, n) for (int i = int(n) - 1; i >= int(m); --i)
#define EACH(i, c) for (auto &(i) : c)
#define all(c) begin(c), end(c)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(begin(c), end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x) cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s)                                                               \
    do {                                                                       \
    } while (0)
#define dump(x)                                                                \
    do {                                                                       \
    } while (0)
#define BR
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int, int>;
using VP = vector<PII>;

// struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
// constexpr double PI  = acos(-1.0);
// constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
// inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template <class T> inline T sqr(T x) { return x * x; }

void solve() {
    int n;
    cin >> n;
    VI p(n);
    REP(i, 0, n) cin >> p[i];
    int ans = 0;
    {
        int cnt = 0;
        VI a(n);
        REP(i, 0, n) a[i] = p[i];
        REP(i, 0, n - 1) if (a[i] == i + 1) {
            swap(a[i], a[i + 1]);
            ++cnt;
        }
        if (a[n - 1] == n)
            ++cnt;
        ans = cnt;
    }
    {
        int cnt = 0;
        VI a(n);
        REP(i, 0, n) a[i] = p[i];
        RREP(i, 1, n) if (a[i] == i + 1) {
            swap(a[i], a[i - 1]);
            ++cnt;
        }
        if (a[0] == 1)
            ++cnt;
        ans = min(ans, cnt);
    }
    cout << ans << endl;
}

int main() {
    solve();

    return 0;
}


Measured memory_bytes: 1024