akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        // 文字列の数
        int strNum = sc.nextInt();
        // 文字列のリスト
        List<Map<String, Integer>> strArray = new ArrayList<>();
        while(sc.hasNext()) {
            String line = sc.next();
            String[] charArray = line.split("");
            Map<String, Integer> charMap = new HashMap<>();
            for(String charVal : charArray) {
                
                if(charMap.containsKey(charVal)) {
                    int count = charMap.get(charVal);
                    charMap.put(charVal, count + 1);
                } else {
                    charMap.put(charVal, 1);
                }
            }
            strArray.add(charMap);
        }
        
        Map<String, Integer> sampleMap = strArray.get(0);
        String strContainedAll = "";
        
        for(String key : sampleMap.keySet()) {
            boolean containsAll = true;
            int allCount = sampleMap.get(key);
            
            for(int i=1; i<strArray.size(); i++) {
                Map<String, Integer> otherMap = strArray.get(i);
                if(otherMap.containsKey(key)) {
                    int count = otherMap.get(key);
                    if(allCount > count) {
                        allCount = count;
                    }
                    containsAll = true;
                } else {
                    containsAll = false;
                    break;
                }
            }
            if(containsAll) {
                strContainedAll += new String(new char[allCount]).replace("\0", key);
            }
        }
        String[] resultArray = strContainedAll.split("");
        Arrays.sort(resultArray);
        String result = "";
        for(String val : resultArray) {
            result += val;
        }
        System.out.println(result);
    }
}


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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, __VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

#define MOD 1000000007
#define INF 1000000000
#define MAX_N 100010

// 200, 10min

string S;

int main()
{
    cin >> S;
    bool isN = false;
    bool isS = false;
    bool isE = false;
    bool isW = false;
    REP(i, S.length()) {
        if(S[i] == 'N') { isN = true; }
        if(S[i] == 'S') { isS = true; }
        if(S[i] == 'E') { isE = true; }
        if(S[i] == 'W') { isW = true; }
    }
    if((isN != isS) || (isE != isW)) { printf("No\n"); }
    else { printf("Yes\n"); }

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int r = sc.nextInt();
    int g = sc.nextInt();
    int b = sc.nextInt();
    
    int n = r*100 + g*10 + b;
    if(n%4 == 0) {
      System.out.println("YES");
    }else {
      System.out.println("NO");
    }
  }
}

Measured memory_bytes: 20948
from collections import deque, Counter

N, M = map(int, input().split())
Road = [[] for _ in range(N)]
Ans = [-2] * N
Q = deque()
for _ in range(M):
    A, B = map(int, input().split())
    A -= 1
    B -= 1
    Road[A].append(B)
    Road[B].append(A)

now = 0
Ans[0] = -1
Q.append(now)

while len(Q) > 0:
    now = Q.popleft()
    for next in Road[now]:
        if Ans[next] == -2:
            Ans[next] = now
            Q.append(next)

Ans_S = set(Ans)

if -2 in Ans_S:
    print('No')
else:
    print('Yes')
    for i in Ans[1:]:
        print(i+1)

Measured memory_bytes: 36508
import math

c60 = math.cos(math.radians(60))
s60 = math.sin(math.radians(60))

def koch(d, p1, p2):
    if d == 0:
        return
    
    sx = (p2[0] + 2 * p1[0]) / 3
    sy = (p2[1] + 2 * p1[1]) / 3
    tx = (p2[0] * 2 + p1[0]) / 3
    ty = (p2[1] * 2 + p1[1]) / 3
    ux = (tx - sx) * c60 - (ty - sy) * s60 + sx
    uy = (tx - sx) * s60 + (ty - sy) * c60 + sy
    
    koch(d-1, p1, (sx, sy))
    print("{0:.5f} {1:.5f}".format(sx, sy))
 
    koch(d-1, (sx, sy), (ux, uy))
    print("{0:.5f} {1:.5f}".format(ux, uy))
 
    koch(d-1, (ux, uy), (tx, ty))
    print("{0:.5f} {1:.5f}".format(tx, ty))
    
    koch(d-1, (tx, ty), p2)

n = int(input())

print("0 0")
koch(n, (0, 0), (100, 0))
print("100 0") 


Measured memory_bytes: 5788
#include <cstring>
#include <cstdio>

#define FOR(i, a, b) for(i=a; i<b; ++i)
#define EFOR(i, a, b) for(i=a; i>b; --i)

#define MAXN 100
#define MAXW 11

int ck(char *sPrev, char *sNext) {
	return ((sPrev[strlen(sPrev)-1] == sNext[0])?0:1);
}

void soluver(char (*s)[MAXW], int sSize) {
	int i,j;
	FOR(i, 1, sSize) {
		if (ck(s[i-1], s[i])) {
			printf("No\n");
			return;
		}

		EFOR(j, i-1, -1) {
			if (strcmp(s[j], s[i]) == 0) {
				printf("No\n");
				return;
			}	
		}
	}
	printf("Yes\n");
}

int main() {
	int i,n;
	char a[MAXN][MAXW] = {0};

	scanf("%d", &n);

	FOR(i, 0, n) {
		scanf("%s", a[i]);
	}

	soluver(a, n);
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main ()
{
	int input[10];
	
	for (int i = 0; i < 10; i++)
		scanf ("%d", &input[i]);
		
	for (int i = 0; i < 10; i++)
	{
		for (int j = i + 1; j < 10; j++)
		{
			if (input [j] > input[i])
			{
				int swap = input[i];
				input[i] = input[j];
				input[j] = swap;
			}
		}
	}
	
	for (int i = 0; i < 3; i++)
		printf ("%d\n", input[i]);
		
	return 0;
}

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

using namespace std;

int main() {
    long long n;
    cin >> n;
    int x = n;
    int res = 0;
    while (n) {
        res += n % 10;
        n /= 10;
    }
    if (x % res == 0)
            puts("Yes");
    else
            puts("No");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
int par[200000];
int height[200000];
int size[200000];
void init(int n){
    rep(i,n){
        par[i]=i;
        height[i]=0;
        size[i]=1;
    }
}
int find(int x){
    if(par[x]==x){
        return x;
    }else{
        return par[x]=find(par[x]);
    }
}
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)return;
    if(height[x]<height[y]){
        par[x]=y;
        size[y]=size[x]+size[y];
    }else{
        par[y]=x;
        size[x]=size[x]+size[y];
        if(height[x]==height[y])height[x]++;
    }
}
bool same(int x,int y){
    return find(x)==find(y);
}
int tri(int n){
    if(n==1)return 1;
    else return n+tri(n-1);
}
int n,m;
int cnt=0;
int a[200000],b[200000],ans[200000];
signed main(){
    cin>>n>>m;
    init(n);
    rep(i,m)cin>>a[i]>>b[i];
    reverse(a,a+m);
    reverse(b,b+m);
    int mol=tri(n-1);
    rep(i,m){
        ans[m-i-1]=mol-cnt;
        if(same(a[i],b[i])==false){
            cnt+=size[find(a[i])]*size[find(b[i])];
        }
        unite(a[i],b[i]);
    }
    rep(i,m)cout<<ans[i]<<endl;
    return 0;
}

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

const int mxN=1e5;
int n, m, dp[mxN], ui, vi, ans;
vector<int> adj[mxN];

int cdp(int u) {
	if(!dp[u]) {
		for(int v : adj[u])
			dp[u]=max(cdp(v), dp[u]);
		++dp[u];
	}
	return dp[u];
}

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

	cin >> n >> m;
	while(m--) {
		cin >> ui >> vi, --ui, --vi;
		adj[ui].push_back(vi);
	}
	for(int i=0; i<n; ++i)
		ans=max(cdp(i), ans);
	cout << ans-1;
}

Measured memory_bytes: 7424
/*     ####   ####  #               ####  #        ##   #    # #    # ###### #####
	  #      #    # #              #      #       #  #  ##  ## ##  ## #      #    #
	   ####  #    # #               ####  #      #    # # ## # # ## # #####  #    #
		   # #  # # #                   # #      ###### #    # #    # #      #####
	  #    # #   #  #              #    # #      #    # #    # #    # #      #   #
	   ####   ### # ###### #######  ####  ###### #    # #    # #    # ###### #    #
*/
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<pair<LL, LL> > VP;
 
 
#define For(in) for (LL i = 0; i < (n); i++)
#define FOR(in) for(LL i=1; i <= (n); i++)
#define pb push_back
#define sr(v) sort(v.begin(), v.end())
#define rev(v) reverse(v.begin(), v.end())
#define uniq(v) v.erase(unique(v.begin(), v.end()), v.end());
#define exit(); return 0;
#define no "NO"
#define yes "YES"
#define con continue;
 
 
LL concate(LL a, LL b)
{
	ostringstream os;
	os <<a <<b;
	istringstream is(os.str());
	LL c;
	is>> c;
	return c;
}
 
 
LL check(char c)
{
	return c=='a' || c=='e' || c=='i' || c=='o' || c=='u';
}
LL mod = 1e9+7;
 
 
int main()
{
	//LL q,t;
	//cin>>t;
	//while(t--)
	//{
	   LL a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,r=0,u=0,w=0,x=0,y=0,z=0;
		LL aa[1000];
		LL flag=0, flag1=0, co=0, co1=0, co2=0, co3=0, x1=0, x2=0, y1=0, y2=0, z1=0, z2=0;
		LL ma=0, mi=100000000;
		LL mid=0, temp=0, stop=0, start=0;
		double pi= 3.141592653589793;
		double d1=0.0, d2, d3, d4;
		VLL v,v1,v2,v3,v4,v5,v6,v7,v8,v9,v10;
		VS vs, vs1, vs2, vs3, vs4;
		VP vp, vp1,vp2;
		char ch, ch1, ch2[1001];
		string str, str1, str2, str3, str4, str5;
		pair<LL, LL> pa;
		list<LL> li, li1;
		map<LL, LL> mp, mp1;
		set<LL> st;
		map<LL ,LL> :: iterator imll;
		VLL :: iterator ivll;
		set<LL> :: iterator isll;
		VP :: iterator ivp;
 
		cin>>x>>y;
		LL ia[7]={1,3,5,7,8,10,12};
		LL ib[4]={4,6,9,11};
			
		if(x==2 || y==2)cout<<"No"<<endl;
		else 
		{
			for(i=0; i<7; i++)
			{
				if(x==ia[i] || y==ia[i])flag++;
			}
		
			if(flag==2)
			{
				cout<<"Yes"<<endl;
				exit()
			}
			else if(flag==1)cout<<"No"<<endl;
			else cout<<"Yes"<<endl;
		}
		
		
		
	exit()
 
 
}


Measured memory_bytes: 3636
s = input()
if s[0] == s[1] and s[0] != s[2] and s[0] != s[3]:
    if s[2] == s[3]:
        print("Yes")
    else:
        print("No")
elif s[1] == s[2] and s[1] != s[3]:
    if s[0] == s[3]:
        print("Yes")
    else:
        print("No")
elif s[0] == s[2] and s[0] != s[3]:
    if s[1] == s[3]:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 38256
N = int(input())						# 5

A=[]
for i in range(N):
	a,b = map(int, input().split())			# "5 7" -> ["5", "7"] -> 5, 7 => N=5,K=7
	A.append([a,b])

B = sorted(A, key=lambda x: x[1])

ans="Yes"
a_sum=0
for i in range(N):
	a=B[i][0]
	b=B[i][1]
	
	a_sum+=a
	if a_sum>b:
		ans="No"
		break


print(ans)



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

int main() {
    int n;
    int a, b;
    int total = 0;

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a >> b;
        total += b - a + 1;
    }
    cout << total << endl;
    return 0;
}

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

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

    vector<int> a_cost(n,0);
    vector<int> b_cost(n,0);
    vector<int> c_cost(n,0);

    vector<int> a_value(n,0);
    vector<int> b_value(n,0);
    vector<int> c_value(n,0);

    for(int i = 0; i < n; ++i)
    {
        int a, b, c;
        cin >> a >> b >> c;
        a_cost.at(i) = a;
        b_cost.at(i) = b;
        c_cost.at(i) = c;
    }
    
    a_value.at(0) = a_cost.at(0);
    b_value.at(0) = b_cost.at(0);
    c_value.at(0) = c_cost.at(0);

    for(int i = 1; i < n; ++i)
    {
        a_value.at(i) = max(a_cost.at(i)+b_value.at(i-1), a_cost.at(i)+c_value.at(i-1));
        b_value.at(i) = max(b_cost.at(i)+a_value.at(i-1), b_cost.at(i)+c_value.at(i-1));
        c_value.at(i) = max(c_cost.at(i)+b_value.at(i-1), c_cost.at(i)+a_value.at(i-1));

    }

    int ans = max(a_value.at(n-1), max(b_value.at(n-1), c_value.at(n-1)));

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 2560
def Bubble_Sort(A, N):
    count = 0
    for i in range(N):
        for j in reversed(range(i+1,N)):
            if A[j] < A[j-1]:
                a = A[j]
                A[j] = A[j-1]
                A[j-1] = a
                count += 1
    
    return(A, count)

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

ans1, ans2 = Bubble_Sort(A, N)
print(' '.join(map(str, ans1)))
print(ans2)


Measured memory_bytes: 5600
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

ll modpow(ll a, ll p) {
    if(p == 0)
        return 1;
    if(p % 2 == 0) {
        ll halfp = p / 2;
        ll half = modpow(a, halfp);
        return half * half % MOD;
    } else {
        return a * modpow(a, p - 1) % MOD;
    }
}

ll calcComb(ll a, ll b) {
    if(b > a - b) {
        return calcComb(a, a - b);
    }
    ll ansMul = 1;
    ll ansDiv = 1;
    REP(i, b) {
        ansMul *= (a - i);
        ansDiv *= (i + 1);
        ansMul %= MOD;
        ansDiv %= MOD;
    }
    ll ans = ansMul * modpow(ansDiv, MOD - 2);
    ans %= MOD;
    return ans;
}

int N, M, K;
long long ans = 0;
vector<pair<int, int>> v;
int main() {
    cin >> N >> M >> K;
    ll ans = 0;
    ll p = calcComb(N * M - 2, K - 2);
    REP(i, N) {
        ans += i * (N - i) * M * M;
        ans %= MOD;
    }
    REP(i, M) {
        ans += i * (M - i) * N * N;
        ans %= MOD;
    }
    ans *= p;
    ans %= MOD;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[59];
int main() {
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<n;i++)
		for(int j=i+1;j<n;j++)
			if(a[i]>a[j]) {
				bool b=1;
				swap(a[i],a[j]);
				for(int k=0;k<n-1;k++)
					if(a[k]>a[k+1]) {
						b=0;
						break;
					}
				if(b) {
					cout<<"YES"<<endl;
					return 0;
				}
				swap(a[i],a[j]);
			}
	for(int i=0;i<n-1;i++)
		if(a[i]>a[i+1]) {
			cout<<"NO"<<endl;
			return 0;
		}
	cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll,ll>
#define pint pair<int,int>
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define mod 1000000007
#define MAX 1e10
#define endl '\n'
#define mp make_pair
#define INF INT_MAX
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ff first
#define ss second
#define ps(x,y) fixed<<setprecision(y)<<x
#define setbits(x) __builtin_popcountll(x)			//counts no of ones in binary representation
#define w(t) 	int t; cin>>t; while(t--)
#define pi 3.141592653589793238
#define sortt(v)  sort(v.begin(),v.end())
#define lb(v,x) std::lower_bound(v.begin(),v.end(),x)
#define ub(v,x) std::upper_bound(v.begin(),v.end(),x)

using namespace std;

int main(){
	fast;
	ll n;
	cin>>n;
	map<ll,ll> ma;
	vector<ll> a(n);
	set<ll> se;
	forn(i,n){
		cin>>a[i];
		se.insert(a[i]);
		ma[a[i]]++;
	}
	vector<ll>::iterator it1,it2;
	ll ans=n;
	sortt(a);
	for(int i=n-1;i>=0;i--){
		for(int j=1;j*j<=a[i];j++){
			if(a[i]%j==0){
				ll x=a[i]/j;
				if(se.find(j)!=se.end()){
					if(j>1){
						ans--;
						break;
					}
					else{
						if(a[i]!=1){
							ans--;
							break;
						}
						else{
							if(ma[1]>1){
								ans--;
								break;
							}
						}
					}
				}
				if(se.find(x)!=se.end()){
					if(x!=a[i]){
						ans--;
						break;
					}
					else{
						if(ma[x]>1){
							ans--;
							break;
						}
					}
				}
			}
		}
		
	}
	cout<<ans;
}

Measured memory_bytes: 26632
#include <cstdio>
#include <cstring>

int main(void)
{
    int n, shuffle;
    char str[500];
    char tmp;
    
    while (true){
        for (int i = 0; i < 500; i++){
            str[i] = '\0';
        }

        scanf(" %s", str);
        if (!strcmp(str, "-")){
            break;
        }

        scanf(" %d", &n);
        for (int i = 0; i < n; i++){
            scanf(" %d", &shuffle);
            for (int j = 0; j < shuffle; j++){
                tmp = str[0];
                for (int k = 0; k < strlen(str) - 1; k++){
                    str[k] = str[k+1];
                }
                str[strlen(str)-1] = tmp;
            }
        }

        printf("%s\n", str);
    }

    return 0;
}

Measured memory_bytes: 1012
n, k = map(int, input().split())
r, s, p = map(int, input().split())
T = list(input())


for i in range(k, n):
    if T[i] == T[i - k]:
        T[i] = "x"

answer = 0
for t in T:
    if t == "r":
        answer += p
    elif t == "s":
        answer += r
    elif t == "p":
        answer += s


print(answer)


Measured memory_bytes: 4084
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;

int M[1000][1440],C[1000],T[1000],X[1000];
vector<pair<int,int> >v;

void newday(){
	if(T[0]>=0)v.push_back(make_pair(T[0],1440));
	int i,p,t,u;
	for(p=1;p<1000;p++){
		if(C[p])for(t=T[p];t<1440;t++)M[p][t]=1;
	}
	for(i=0;i<v.size();i++){
		for(p=1;p<1000;p++){
			t=v[i].first,u=v[i].second;
			for(;t<u;t++)
				if(M[p][t])X[p]++;
		}
	}
	memset(M,0,sizeof(M));
	memset(C,0,sizeof(C));
	memset(T,0xff,sizeof(T));
	v.clear();
}

int main(){
	int n,M1,D1,M2,D2,h,m,s,p,q;char e;
	for(;scanf("%d",&n),n;){
		memset(M,0,sizeof(M));
		memset(C,0,sizeof(C));
		memset(T,0xff,sizeof(T));
		memset(X,0,sizeof(X));
		v.clear();
		for(M1=0;n;n--){
			scanf("%02d/%02d %02d:%02d %c %03d",&M2,&D2,&h,&m,&e,&p);
			if(M1!=M2||D1!=D2)newday(),M1=M2,D1=D2;
			s=e=='I'?1:0;
			h=h*60+m;
			if(T[p]==-1)T[p]=h;
			if(s)C[p]++;
			else{
				C[p]--;
				if(!C[p]){
					if(p==0)v.push_back(make_pair(T[0],h));
					else{
						//printf("---%d %d %d\n",p,T[p],h);
						for(q=T[p];q<h;q++)M[p][q]=1;
					}
					T[p]=-1;
				}
			}
		}
		newday();
		for(m=0,p=1;p<1000;p++){
			if(m<X[p])m=X[p];
		}
		printf("%d\n",m);
	}
}

Measured memory_bytes: 6472
# coding: utf-8
from collections import deque
N, X, Y = map(int, input().split())
X -= 1
Y -= 1
D = [[0 for _ in range(N)] for _ in range(N)]
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        D[i][j] = abs(j-i)
        D[j][i] = abs(j-i)
D[X][Y] = 1
D[Y][X] = 1
# print(*D, sep="\n")
queue = deque([[X, Y]])
visited = [[False for _ in range(N)] for _ in range(N)]
visited[X][Y] = True 
while queue:
    x,y = queue.popleft()
    for i, j in zip([1, 0, -1, 0], [0, 1, 0, -1]):
        nx, ny = x+i, y+j
        if nx < 0 or nx >= N or ny < 0 or ny >= N:
            continue
        if visited[nx][ny]:
            continue
        else:
            visited[nx][ny] = True
            D[nx][ny] = min(D[nx][ny], D[x][y]+1)
            queue.append([nx, ny])
# print(*D, sep="\n")
ans = [0 for _ in range(N)]
cnt = 0
for i in range(N):
    for j in range(i+1, N):
        # cnt += 1
        v = D[i][j]
        # print(i,j, v)
        ans[v-1] += 1
print(*ans[:-1], sep="\n")

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

int main() {
    int n; cin >> n;
    ll a;
    int odd = 0,even=0,times4=0;
    for(int i=0;i<n;i++){
        cin >> a;
        if(a % 4==0)times4++;
        else if(a%2 ==0)even++;
        else odd++;
    }
    if(even){
      if(odd<=times4)cout<<"Yes"<<endl;
      else cout<<"No"<<endl;
    }
    else{
      if(odd<=times4+1)cout<<"Yes"<<endl;
      else cout<<"No"<<endl;
    }
}   



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long ll;

bool arr[100010];
void prime(int x){
	for(int i = 0;i <= x;i++) arr[i] = true;
	arr[0] = false;
	arr[1] = false;
	for(int i = 0;i < x;i++){
		if(arr[i]){
			for(int j = 2*i; j <= x; j += i){
				arr[j] = false;
			}
		}
	}
	return;
}
int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);

	int q, l[100000], r[100000];
	cin >> q;
	for(int i = 0;i < q;i++) cin >> l[i] >> r[i];

	int sum[50010] = {0};	// sum[i] = ~ 2*i+1
	prime(100010);

	sum[0] = 0;
	for(int i = 0;i < 50005;i++){
		if(arr[2*i+3] and arr[i+2]) sum[i+1] = sum[i] + 1;
		else sum[i+1] = sum[i];
	}

	for(int i = 0;i < q;i++){
		int ans;
		if(l[i] == 1) ans = sum[(r[i]-1)/2];
		else ans = sum[(r[i]-1)/2] - sum[(l[i]-1)/2 -1];
		cout << ans << endl;
	}
	return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;

#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define one 1.0
#define INF 1000000000000000000
#define all(vl) vl.begin(),vl.end()
#define m_p make_pair 
#define sz(a) sizeof(a)
#define forn(mp,it) for(it = mp.begin();it!=mp.end();it++)
#define FOR(i,a,n) for(int i=a;i<n;i++) 
#define FORE(i,a,n) FOR(i,a,n+1)
#define Endl endl
#define eNdl endl
#define enDl endl
#define endL endl

ll div_ceil(ll a,ll b)
{
	return (a+b-1)/b;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);
	ll a,b,c;
	cin>>a>>b>>c;
	cout<<c*(div_ceil(a,b))<<endl;
	return 0;
}


Measured memory_bytes: 3648
from collections import defaultdict

n,k = map(int,input().split())
town_list = list(map(int,input().split()))

town_dict = dict()
for a,town in enumerate(town_list, 1):
    town_dict[a] = town


if k <= n:
    now_place = 1
    for _ in range(k):
        now_place = town_dict[now_place]

    print(now_place)

if k > n:
    now_place = 1
    visit_town = dict()
    visit_town[1] = 0
    tmp_last_visit = -1
    tmp_visit = -1
    for j in range(n):
        now_place = town_dict[now_place]

        if now_place in visit_town:
            tmp_last_visit = visit_town[now_place]
            tmp_visit = j+1
            break

        visit_town[now_place] = j+1

    if tmp_last_visit == -1:
        print(now_place)
    else:
        ans = (k-tmp_visit)%(tmp_visit-tmp_last_visit)
        
        for _ in range(ans):
            now_place = town_dict[now_place]

        print(now_place)

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

using namespace std;

#define ll long long




void solve() {

	int n;
	string s;
	cin >> n >> s;
	int cnt = 1;
	for(int i = 1; i < n; i++) {
		if(s[i] != s[i - 1]) {
			cnt++;
		}
	}
	cout << cnt;
			

	




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	solve();

	return 0;
}

Measured memory_bytes: 3788
use std::io;
use std::cmp::Ordering;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        W: i32,
        H: i32,
        x: i32,
        y: i32,
        r: i32,
    }
    
    if 0 <= ( x - r ) && ( x + r ) <= W && 0 <= ( y - r ) && ( y + r ) <= H {
        println!("Yes");
    }
    else
    {
        println!("No");
    }
}



Measured memory_bytes: 5028
#include <iostream>

int main(int argc, char **argv){
	for(int i = 1; i < 10; i++){
		for(int j = 1;j < 10; j++){
			std::cout << i << "x" << j << "=" << i * j;
			/* if(!(i == 9 && j == 9)){ */
				std::cout << std::endl;
			/* } */
		}
	}
}

Measured memory_bytes: 2984
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

using namespace std;

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

	int m = 100000;
	for (int i = 0; i < n; i++)
	{
		m += (int)(0.05 * m);
		m = (m / 1000 + (m%1000 == 0 ? 0 : 1)) * 1000;
	}

	cout << m << endl;
}


Measured memory_bytes: 3072
from itertools import permutations
import sys
input = sys.stdin.readline

N, M, _ = list(map(int, input().split()))
R = list(map(int, input().split()))

T = [[float("inf")] * N for _ in range(N)]

for _ in range(M):
    A, B, C = list(map(int, input().split()))
    A -= 1
    B -= 1
    T[A][B] = T[B][A] = min(C, T[A][B])
for i in range(N):
    T[i][i] = 0

# T[j][i]: cost from j to i, O(V^3)
# T[j][i] = 0 if j == i


def warshall_floyd(T, V):
    for k in range(V):
        for j in range(V):
            for i in range(V):
                T[j][i] = min(T[j][i], T[j][k] + T[k][i])


warshall_floyd(T, N)


ans = float("inf")

for v in permutations(R):
    tmp = 0
    for i in range(len(v)-1):
        tmp += T[v[i]-1][v[i+1]-1]
    ans = min(ans, tmp)

print(ans)


Measured memory_bytes: 55772
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repR(i, n) for(int i = (n) - 1; i > -1; i--)
#define rep1(i, n) for(int i = 1; i < (int)(n + 1); i++)
#define rep1R(i, n) for(int i = (n); i > 0; i--)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main() {
  int N; cin >> N;
  vector<int> A(N);
  rep(i, N) {
    int a;
    cin >> a;
    A[i] = a - (i + 1);
  }
  sort(A.begin(), A.end());
  int b = 0;
  if (A.size() % 2 != 0) {
    b = A[A.size() / 2];
  } else {
    b = (A[A.size() / 2] + A[A.size() / 2 - 1]) / 2;
  }
  ll ans = 0;
  rep(i, N) {
    ans += abs(A[i] - b);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"xyz
abc"# => r#"xaybzc"#,

r#"xyzd
abc"# => r#"xaybzcd"#,
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        o: chars,
        e: chars,
    }
    let mut ans = "".to_string();
    let len = o.len() + e.len();

    for i in 0..len {
        if i % 2 == 0 {
            ans.push_str(&o[i - (i / 2)].to_string());
        } else {
            ans.push_str(&e[i - (i / 2) - 1].to_string());
        }
    }

    ans.to_string()
}

Measured memory_bytes: 4352
n,m = map(int,input().split())
d = []
for _ in range(m):
  l,r,c = map(int,input().split())
  d.append([l,r,c])
d.sort(key=lambda x:x[0])
g = [float("inf") for _ in range(n+1)]
g[1] = 0
f = 1
for i in range(m):
  if d[i][0] > f:
    print(-1)
    exit()
  f = max(f,d[i][1])
  sm = d[i][2]+g[d[i][0]]
  if g[d[i][1]] > sm:
    g[d[i][1]] = sm
    j = d[i][1]-1
    while g[j] > sm:
      g[j] = sm
      j -= 1
if g[n] != float("inf"):
  print(g[n])
else:
  print(-1)

Measured memory_bytes: 69132
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_set>
#include <cmath>
using namespace std;

int main() {
	vector<int> prime;
	bool judge;
	prime.push_back(2);
	for (int i = 3; i < 1000; i++) {
		judge = true;
		for (int j = 0; j < (int)prime.size(); j++) {
			if (prime[j] > sqrt(i)) {
				break;
			}
			if (i % prime[j] == 0) {
				judge = false;
				break;
			}
		}
		if (judge) {
			prime.push_back(i);
		}
	}
	int N;
	cin >> N;
	int A;
	vector<int> pair(1000001);
	unordered_set<int> set;
	int n;
	bool judge_pair = true;
	for (int x : prime) set.insert(x);
	for (int i = 0; i < N; i++) {
		cin >> A;
		n = A;
		unordered_set<int> next_set;
		for (int j = 0; j < (int)prime.size(); j++) {
			if (prime[j] > sqrt(n)) break;
			if (n % prime[j] == 0) {
				if (judge_pair) {
					if (pair[prime[j]] == 0) pair[prime[j]] = 1;
					else judge_pair = false;
				}
				if (set.count(prime[j])) {
					next_set.insert(prime[j]);
				}
				if (set.count(A / prime[j])) {
					next_set.insert(A / prime[j]);
				}
				while (n % prime[j] == 0) {
					n /= prime[j];
				}
			}
		}
		if (n != 1) {
			if (judge_pair) {
				if (pair[n] == 0) pair[n] = 1;
				else judge_pair = false;
			}
			if (set.count(n)) {
				next_set.insert(n);
			}
		}
		set = next_set;
	}
	if (judge_pair) cout << "pairwise coprime" << endl;
	else if (set.empty()) cout << "setwise coprime" << endl;
	else cout << "not coprime" << endl;
}

Measured memory_bytes: 7264
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

vector<vector<int>> to;
vector<int> col;
bool ok = true;

void dfs(int v, int c) {
    if (col[v] != -1) {
        if (col[v] != c) ok = false;
        return;
    }
    col[v] = c;
    for (auto u : to[v]) {
        dfs(u, col[v]^1);
    }
}

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

    int n;
    cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s[i];
    to.resize(n);
    rep(i, n) {
        rep(j, n) {
            if (s[i][j] == '1') to[i].push_back(j);
        }
    }
    col.resize(n, -1);
    dfs(0, 0);
    if (!ok) {
        cout << "-1" << endl;
        return 0;
    }
    auto dist = make_vec<int>(n, n);
    const int inf = 1001001001;
    rep(i, n) {
        rep(j, n) {
            if (s[i][j] == '1') dist[i][j] = 1;
            else if (i == j) dist[i][j] = 0;
            else dist[i][j] = inf;
        }
    }
    rep(k, n) rep(i, n) rep(j, n) chmin(dist[i][j], dist[i][k] + dist[k][j]);
    int mx = 0;
    rep(i, n) rep(j, n) chmax(mx, dist[i][j]);
    cout << mx+1 << endl;
}


Measured memory_bytes: 3892
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
using namespace std;

#define ll long long

int main()
{
    ll A, B, C, D;
    scanf("%lld %lld %lld %lld", &A, &B, &C, &D);

    ll tturn = C / B + (C % B > 0 ? 1 : 0);
    ll aturn = A / D + (A % D > 0 ? 1 : 0);

    if (tturn > aturn)
        printf("No");
    else
        printf("Yes");
}


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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(2);
  
  int n;
  while (cin >> n, n != -1) {
    double x = 1, y = 0;
    for (int i = 0; i < n - 1; i++) {
      double t = atan2(y, x);
      x -= sin(t);
      y += cos(t);
    }
    cout << x << endl;
    cout << y << endl;
  }

  return 0;
}


Measured memory_bytes: 3608
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000;
int n;
int a[maxn + 10], b[maxn + 10], aid[maxn + 10], bid[maxn + 10], ans;
int pos[maxn + 10], cnt, c[maxn + 10], fa[maxn + 10];
bool vis[maxn + 10];
map<int, vector<int> > st;
vector<int> d[maxn + 10];

int cmpa(int x, int y) {
	return a[x] == a[y] ? x < y : a[x] < a[y];
}
int cmpb(int x, int y) {
	return b[x] == b[y] ? x < y : b[x] < b[y];
}
int getf(int p) {
	return fa[p] == p ? p : fa[p] = getf(fa[p]);
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &a[i]); a[n + 1] ^= a[i];
	}
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &b[i]); b[n + 1] ^= b[i];
	}
	for (int i = 1; i <= n + 1; ++i)
		aid[i] = bid[i] = i;
	sort(aid + 1, aid + n + 2, cmpa);
	sort(bid + 1, bid + n + 2, cmpb);
	for (int i = 1; i <= n + 1; ++i) {
		if (a[aid[i]] != b[bid[i]]) {
			printf("-1"); return 0;
		}
	}
	for (int i = 1; i <= n + 1; ++i)
		if (i == n + 1 || a[i] != b[i]) {
			aid[++cnt] = i;
			bid[cnt] = i;
		}
	sort(aid + 1, aid + cnt + 1, cmpa);
	sort(bid + 1, bid + cnt + 1, cmpb);
	for (int i = 1; i <= cnt; ++i) c[aid[i]] = bid[i];
	for (int i = 1; i <= n + 1; ++i) fa[i] = i;
	for (int i = 1; i <= n + 1; ++i)
		if ((i == n + 1 || a[i] != b[i]) && !vis[i]) {
			for (int j = i; !vis[j]; j = c[j]) {
				fa[getf(j)] = getf(i); vis[j] = 1;
			}
		}
	for (int i = 1; i <= n + 1; ++i)
		if (i == n + 1 || a[i] != b[i]) st[a[i]].push_back(i);
	for (map<int, vector<int> >::iterator it = st.begin(); it != st.end(); ++it) {
		for (int j = 1; j < (int)it -> second.size(); ++j)
			fa[getf(it -> second[j])] = getf(it -> second[j - 1]);
	}
	for (int i = 1; i <= n + 1; ++i)
		if (i == n + 1 || a[i] != b[i]) d[getf(i)].push_back(i);
	for (int i = 1; i <= n + 1; ++i)
		if ((i == n + 1 || a[i] != b[i]) && fa[i] == i) {
			int len = 0; bool fd = 0;
			for (int j = 0; j < (int)d[i].size(); ++j) {
				++len; fd |= d[i][j] == n + 1;
			}
			if (fd) ans += len - 1; else ans += len + 1;
		}
	printf("%d", ans);
}


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

int primes[30010];

int main() {
    memset(primes, 0, sizeof(primes));

    primes[0] = primes[1] = 1;
    for(int i=4; i<=30000; i+=2) primes[i] = 1;
    for(int i=3; i*i<=30000; i+=2)
        if(primes[i] == 0)
            for(int j=2; i*j<=30000; ++j)
                primes[i*j] = 1;

    int t;
    while(cin>>t, t) {
        int ans = 0;
        for(int i=2; i<=(t/2)+1; ++i) {
            if(primes[i]) continue;
            for(int j=i; i+j<t && t-i-j>=j; ++j) {
                if(primes[j]) continue;
                int k = t - i - j;
                if(primes[k]) continue;
                if(!(i<=j && j<=k)) continue;
                if(i+j <= k) continue;
                ans++;
            }
        }
        cout<<ans<<endl;
    }
}

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

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

using namespace std;

int main(){
	string a,b,c; cin>>a>>b>>c;
	cout<<(a.back()==b.front() && b.back()==c.front()?"YES":"NO")<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define double long double
#define pb push_back
#define ff first
#define ss second
#define PI acos(-1)
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define sp fixed<<setprecision
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int MOD = (1e9)+7;
const int N = 1000005;

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        int n,k;
        cin>>n>>k;
        int ans = 0,f = 0,b = n,l = 0,r = 0;
        for(int i=1;i<=n+1;i++,f++,b--)
        {
            l+=f;l%=MOD;
            r+=b;r%=MOD;
            if(i>=k)ans+=(r-l+1+MOD)%MOD,ans%=MOD;
        }
        cout<<ans<<endl;
    }
    return 0;
}
/*
Test Case
*/


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

int main(){
    int a,b;
    
    cin>>a>>b;
    if( a < b ){ cout << "a < b" << endl;}else
    if( a > b ){ cout << "a > b" << endl;}else
    if( a = b ){ cout << "a == b" << endl;}
    return 0;

}


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

int main() {
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >>f;
  vector<int> mizu;
  vector<int> sato(1,0);
  for (int i = 0; i <= f / 100 / a; i++) {
    for (int j = 0; j <= f / 100 / b; j++) {
      int ariemizu = (i * a + j * b) * 100;
      if (ariemizu != 0 && ariemizu <= f) mizu.push_back(ariemizu);
    }
  }
  for (int i = 0; i <= (f - 100 * a) / c; i++) {
    for (int j = 0; j <= (f - 100 * a) / d; j++) {
      int ariesato = i * c + j * d;
      if (100 * a + ariesato <= f) sato.push_back(ariesato);
    }
  }
  pair<int, int> answer(100 * a, 0);//first砂糖水,second溶けてる砂糖
  double maxnodo = 0.000000;
  double gendo = 100 * (double)e / (100 + (double)e);
  for (int i = 0; i < mizu.size(); i++) {
    for (int j = 0; j < sato.size(); j++) {
      int satomizu = mizu[i] + sato[j];
      double nodo = 100 * (double)sato[j] / (double)satomizu;
      if (satomizu <= f && maxnodo < nodo && nodo <= gendo) {
        maxnodo = nodo;
        answer = make_pair(satomizu, sato[j]);
      }
    }
  }
  cout << answer.first << ' ' << answer.second;
}

Measured memory_bytes: 4088
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
#include<cmath>
#include<stack>
#include<tuple>
#include<numeric>
#include<cassert>

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back
#define DEBUG false

using namespace std;

using ll = long long;
using P = pair<int,int>;
using Pl = pair<int,ll>;
using Pd = pair<double,double>;
using T = tuple<double,double,int>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll LINF=1LL<<60;
const int MAX_N = 100005;
const ll lmod = 1e9+7;

int p[MAX_N],q[MAX_N];

int main(){
  string S,T;
  cin >> S >> T ;
  int temp = 0;
  rep(i,S.size()) p[i+1] = (temp = (temp + int(S[i]-'A') + 1) % 3 );
  temp = 0;
  rep(i,T.size()) q[i+1] = (temp = (temp + int(T[i]-'A') + 1) % 3 );
  int Q,a,b,c,d;
  cin >> Q ;
  rep(i,Q){
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if((p[b]-p[a-1]-q[d]+q[c-1])%3==0) printf("YES\n");
    else printf("NO\n");
  }
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using namespace std;
int main()
{
	int n;
	cin >> n;
	n %= 10;
	if (n == 3) {
		cout << "bon" << endl;
	}
	else if (n == 0 || n == 1 || n == 6 || n == 8) {
		cout << "pon" << endl;
	}
	else {
		cout << "hon" << endl;
	}
	return 0;
}

Measured memory_bytes: 3040
# coding: utf-8
def elatostenes(x):
    for i in range(2, int(x ** 0.5)+1):
        if x % i == 0:
            return False
    return True

X = int(input())
while True:
    if elatostenes(X):
        print(X)
        exit()
    else:
        X += 1

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

typedef long long llt;

const int MaxN = 100000 + 5, MaxM = 200000 + 5;
const llt Mod = 1e9 + 7;

int N; int cnte;
int Head[MaxN], To[MaxM], Next[MaxM];
int fa[MaxN];
llt dp[MaxN][2];

inline void add_edge(int from, int to) {
  cnte++; To[cnte] = to;
  Next[cnte] = Head[from]; Head[from] = cnte;
}

void init() {
  scanf("%d", &N);
  for (int i = 1; i < N; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    add_edge(u, v); add_edge(v, u);
  }
}

void dfs(int u) {
  dp[u][0] = dp[u][1] = 1;
  for (int i = Head[u]; i; i = Next[i]) {
    int v = To[i];
    if (v == fa[u]) continue;
    fa[v] = u;
    dfs(v);

    dp[u][0] = dp[u][0] * (dp[v][0] + dp[v][1]) % Mod;
    dp[u][1] = dp[u][1] * dp[v][0] % Mod;
  }
}

void solve() {
  dfs(1);
  llt ans = (dp[1][0] + dp[1][1]) % Mod;
  cout << ans << endl;
}

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

Measured memory_bytes: 9728
#include <iostream>
#include <map>
#include <string.h>
#include <vector>

using namespace std;

const int MAX_N = 2e5;
int dp[1 + MAX_N];
char s[1 + MAX_N];
int bin[1 + MAX_N];
map<int, int> f;

const int SIGMA = 'z' - 'a' + 1;

int main() {
    cin >> ( s + 1 );

    int n = strlen( s + 1 );

    for ( int i = 1; i <= n; i ++ )
        bin[i] = ( 1 << ( s[i] - 'a' ) );

    f[0] = 1;
    int sm = 0;
    for ( int i = 1; i <= n; i ++ ) {
        sm ^= bin[i];
        //cout << s[i] << ' ' << sm << ' ' << f[sm];

        if ( f[sm] )
            dp[i] = f[sm];
        else
            dp[i] = i;
        for ( int j = 0; j < SIGMA; j ++ ) {
                int smp = sm ^ ( 1 << j );
                if ( f[smp] )
                    dp[i] = min( dp[i], f[smp] );
            }

        //cout << ' ' << dp[i] << ' ' << f[1] << endl;
        if ( !f[sm] || dp[i] + 1 < f[sm] )
            f[sm] = dp[i] + 1;
    }
    //cout << SIGMA << endl;
    cout << dp[n];

    return 0;
}


Measured memory_bytes: 205824
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    vector<vector<int>> x(n), y(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        x[i].resize(a[i]);
        y[i].resize(a[i]);
        for (int j = 0; j < a[i]; ++j) {
            cin >> x[i][j] >> y[i][j];
            x[i][j]--;
        }
    }
    int ret = 0;
    for (int i = 0; i < 1 << n; ++i) {
        bool ok = true;
        for (int j = 0; j < n; ++j) {
            if (i & 1 << j) {
                for (int k = 0; k < a[j]; ++k) {
                    if ((y[j][k]) ^ bool(i & (1 << x[j][k]))) {
                        ok = false;
                    }
                }
            }
        }
        if (ok) {
            chmax(ret, __builtin_popcount(i));
        }
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cstdint>
#include <functional>
#include <vector>

template <typename CommutativeMonoid> class FenwickTree {
	using uint32 = std::uint_fast32_t;

public:
	using value_type = CommutativeMonoid;
	using reference = value_type &;
	using const_reference = const value_type &;

private:
	using F = std::function<value_type(const_reference, const_reference)>;
	const value_type neutral_;
	const F f;
	const uint32 size_;
	std::vector<value_type> tree;
	static uint32 getsize(const uint32 size) {
		uint32 ret = 1;
		while (ret < size)
			ret <<= 1;
		return ret;
	}

public:
	FenwickTree(const uint32 size, const_reference neutral = value_type(),
		const F &f = std::plus<value_type>())
		: neutral_(neutral), f(f), size_(getsize(size)),
		tree(size_ + 1, neutral_) {}
	void update(uint32 index, const_reference diff) {
		assert(index < size_);
		for (++index; index <= size_; index += index & ~index + 1)
			tree[index] = f(tree[index], diff);
	}
	value_type range(uint32 end) const {
		assert(end <= size_);
		value_type ret = neutral_;
		do
			ret = f(tree[end], ret);
		while (end &= end - 1);
		return ret;
	}
	uint32 search(const std::function<bool(const_reference)> &b) const {
		if (!b(tree[size_]))
			return size_;
		uint32 i = 0, k = size_;
		value_type acc = neutral_;
		while (k >>= 1)
			if (!b(f(acc, tree[i + k])))
				acc = f(acc, tree[i += k]);
		return i;
	}
};

#include <iostream>
int main(void) {
	int n,q;
	std::cin >>n>> q;
	FenwickTree<int> T(n, 0);
	while (q--) {
		int t, x,y;
		std::cin >> t >> x>>y;
		if (t == 1) {
			std::cout << T.range(y)-T.range(x-1) << std::endl;
		}
		else {
			T.update(x-1, y);
		}
	}
	return 0;
}


Measured memory_bytes: 3368
#include <limits>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>

using namespace std;

struct sushi {
    int64_t x;
    int64_t v;
    int64_t f_r;
    int64_t f_l;
    int64_t f_r_max;
    int64_t f_l_max;
};

int main()
{
    int64_t N,C;
    cin >> N >> C;

    vector<sushi> ss;
    ss.reserve(N);

    for(int i = 0; i < N; ++i)
    {
        sushi s;
        cin >> s.x >> s.v;
        ss.push_back(s);
    }   
    {
        int64_t vsum = 0;
        int64_t rmax = 0;
        for(int i = 0; i < N; ++i)
        {
            vsum += ss[i].v;
            ss[i].f_r = vsum - ss[i].x;
            ss[i].f_r_max = rmax = max(ss[i].f_r, rmax);
        }
    }
    {
        int64_t vsum = 0;
        int64_t lmax = 0;
        for(int i = N-1; i >= 0; --i)
        {
            vsum += ss[i].v;
            ss[i].f_l = vsum - (C-ss[i].x);
            ss[i].f_l_max = lmax = max(ss[i].f_l, lmax);
        }
    }
    
    //cout << "x\tv\tfr\tfl\tfrm\tflm\n";
    //for(auto&& s : ss)
    //    cout << s.x << '\t' << s.v << '\t' << s.f_r << '\t' << s.f_l << '\t' << s.f_r_max << '\t' << s.f_l_max << '\n';
       
    
    int64_t lrmax = ss[N-1].f_r_max;
    for(int i = N-1; i >= 1; --i)
    {
        lrmax = max(lrmax, ss[i].f_l - (C - ss[i].x) + ss[i-1].f_r_max);
    }
    int64_t rlmax = ss[0].f_l_max;
    for(int i = 0; i < N-1; ++i)
    {
        rlmax = max(rlmax, ss[i].f_r - ss[i].x + ss[i+1].f_l_max);
    }
    
    cout << max(0L,max(rlmax,lrmax)) << '\t';

    return 0;
}


Measured memory_bytes: 4992
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			Question.Exec();
		}
	}

	public static class Question
	{
		public static bool IsOdd(long n)
		{
			bool isOdd = n % 2 == 1;
			return isOdd;
		}

		public static void Exec()
		{
			var n = long.Parse(Console.ReadLine());
			var array = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
			var list = array.ToList();

			var oddList = list.Where(x => IsOdd(x)).ToList();
			var noOddList = list.Where(x => IsOdd(x) == false).ToList();

			bool isOK = IsOdd(oddList.Count) == false;
			if (isOK) {
				Console.WriteLine($"YES");
			} else {
				Console.WriteLine($"NO");
			}

			Console.ReadKey();
		}
	}
}

Measured memory_bytes: 25824