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


public class Main {
	
	Scanner cin = new Scanner(System.in);
	
	public static void main(String[] args) {
		new Main().run(); 
	}
	
	public void run() {		
		
		/*input*/
		String input = cin.nextLine();
		
		
		/*start*/
		int n = input.length();
		int result1 = -1;
		int result2 = -1;
		
		for (int i = 0; i < n - 1; i ++) {
			
			char ch = input.charAt(i);
			
			if (ch == input.charAt(i + 1)) {
				result1 = i + 1;
				result2 = i + 1 + 1;
				break;
			}
			
			if (i + 2 < n && ch == input.charAt(i + 2)) {
				result1 = i + 1;
				result2 = i + 2 + 1;
			}
		}
		
		/*finish*/
		System.out.println(result1 +" " + result2);
	}
}



Measured memory_bytes: 26444
import java.util.Scanner;

public class Main {
	
	static int r = (int)Math.pow(10,  9) + 7;
	static int n;
	static long fact[], finv[], inv[];
	
	public static void cominit() {
		fact[0] = fact[1] = 1;
		finv[0] = finv[1] = 1;
		inv[1] = 1;
		for(int i = 2; i < n + 2; ++i) {
			fact[i] = fact[i - 1] * i % r;
			inv[i] = r - inv[r % i] * (r / i) % r;
			finv[i] = finv[i - 1] * inv[i] % r;
		}
	}
	
	public static long comb(int n, int k) {
		if(n < k)return 0;
		if(k < 0 || n < 0)return 0;
		if(k == 0)return 1;
		
		return fact[n] * (finv[k] * finv[n - k] % r) % r;
	}
	
	public static long solve(int k, int snum[]) {
		long ans = 0;
		
		ans = comb(n + 1, k);
		ans %= r;
		ans -= comb(snum[0] + n - snum[1], k - 1);
		ans += r;
		ans %= r;
		
		return ans;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a[], count[];
		
		n = sc.nextInt();
		a = new int[n + 1];
		count = new int[n + 1];
		fact  = new long[n + 2];
		finv = new long[n + 2];
		inv = new long[n + 2];
		
		cominit();
		
		for(int i = 0; i <= n; ++i) {
			a[i] = sc.nextInt();
			++count[a[i]];
		}
		sc.close();
		
		long ans = 0;
		int s = 0, snum[];
		snum = new int[2];
		
		for(int i = 0; i < n + 1; ++i) {
			if(count[i] == 2)s = i;
		}
		
		int k = 0;
		for(int i = 0; i < n + 1; ++i) {
			if(a[i] == s) {
				snum[k] = i;
				++k;
			}
		}
		
		for(int i = 1; i <= n + 1; ++i) {
			ans = solve(i, snum);
			System.out.println(ans);
		}
		
	}

}


Measured memory_bytes: 61384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		if(B % A == 0) {
			System.out.println(A + B);
		} else {
			System.out.println(B - A);
		}
		
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, t, a;
    cin >> n >> a;
    int tot = 0;
    for(int i = 0; i < a; ++i) {
        cin >> t;
        tot += t;
    }
    if(tot >= n) puts("Yes");
    else puts("No");

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cassert>
#include <cmath>

using ll = long long;
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

int const nmax = 100000;
int const modulo = 1000000007;

class Matrix{
public:
  int mat[3][3] = {0};
  Matrix operator * (Matrix a) {
    Matrix result;
    for(int i = 0; i < 3; i++)
      for(int j = 0; j < 3; j++)
        for(int h = 0; h < 3; h++) {
          result.mat[i][j] += 1LL * mat[i][h] * a.mat[h][j] % modulo;
          if(modulo <= result.mat[i][j])
            result.mat[i][j] -= modulo;
        }
    return result;
  }
};

Matrix lgpow(Matrix a, int b) {
  if(b == 1)
    return a;
  else {
    Matrix result = lgpow(a, b / 2);
    if(b % 2 == 0)
      return result * result;
    else
      return result * result * a;
  }
}

int main() {
  int n, m;
  std::cin >> n >> m;
  std::vector<int> v;
  v.push_back(0);
  for(int i = 1;i <= m; i++) {
    int val;
    std::cin >> val;
    v.push_back(val);
  }
  v.push_back(n);
  Matrix init, basic;
  init.mat[0][1] = init.mat[0][2] = 1;
  basic.mat[0][0] = 1;
  basic.mat[1][0] = modulo + -1;
  basic.mat[2][0] = 2;
  basic.mat[0][1] = 1;
  basic.mat[2][1] = 2;
  basic.mat[0][2] = 1;
  basic.mat[1][2] = 0;
  basic.mat[2][2] = 3;
  for(int i = 1; i <= m + 1; i++) {
    init = init * lgpow(basic, v[i] - v[i - 1]);
    init.mat[0][1] -= init.mat[0][0];
    init.mat[0][2] -= init.mat[0][0];
    if(init.mat[0][1] < 0)
      init.mat[0][1] += modulo;
    if(init.mat[0][2] < 0)
      init.mat[0][2] += modulo; 
  }
  std::cout << init.mat[0][0];
  return 0;
}


Measured memory_bytes: 3932
# coding: utf-8
# Here your code !
data = input()

if data == "SUN":
    print(7)
elif data == "MON":
    print(6)
elif data == "TUE":
    print(5)
elif data == "WED":
    print(4)
elif data == "THU":
    print(3)
elif data == "FRI":
    print(2)
elif data == "SAT":
    print(1)






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

/*
    (0, 0), (1e9, 1), (a, b)を端点とすると
    面積は1/2(1e9 * b - a)
    Sが与えられたら
    1e9 * b - a == 2S
    となるb, aを求めたい
*/

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

    long long s;
    cin >> s;
    int b = (s + int(1e9) - 1) / int(1e9);
    int a = 1LL * int(1e9) * b - s;
    assert(a >= 0);
    cout << 0 << ' ' << 0 << ' ' << int(1e9) << ' ' << 1 << ' ' << a << ' ' << b << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	long long n,x,ans;
	scanf("%lld%lld",&n,&x);
	n-=x;
//	if(x<n)
//	{
		ans=x+n;
		while(x)
		{
			ans+=(n/x*x)<<1;
			n%=x;
			swap(n,x);
		}
		ans-=n;
//	}
//	else
//	{
//		ans=x+n;
//		while(x%n)
//		{
//			ans+=(x/n*n)<<1;
//			x%=n;
//			swap(n,x);
//		}
//		ans-=n;
//	}
	
	printf("%lld\n",ans);
}
/*
5 2
*/


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

int main(){
  string s;
  cin >> s;
  int ans = 0, xa = 0, xz = 0, temp = 0;
  
  for(int i = 0; i < s.size(); i++){
    if(s[i] == 'A'){
      xa = i;
      break;
    }
  }
  
  for(int j = xa; j < s.size(); j++){
    if(s[j] == 'Z') {
      xz = j;
      temp = xz-xa+1;
      ans = max(temp,ans);
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<cmath>
#include<vector>
using namespace std;
using LL = long long;
LL gcd(LL a, LL b){
    while(a && b){
        if(a > b)a %= b;
        else b %= a;
    }
    return a + b;
}

int main(){
    LL a, b;
    LL ans = 0;
    cin >> a >> b;

    const LL C = gcd(a, b);
    LL c = C;

    for(int i = 2;i < sqrt(C);i++){
        if(c % i == 0){
            ans++;
            while(c % i == 0)c /= i;
        }
    }
    if(c != 1)ans++;
    cout << ans + 1;
}

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

int main(){
    int n,m;
    while(cin>> n >> m&&n!=0){
        vector<pair<int,int> > a;
        rep(i,n){
            int b,c;
            cin >> b >> c;
            a.push_back(make_pair(c,b));
        }
        sort(a.rbegin(),a.rend());
        vector<bool> p(m+1);
        int res = 0;
        rep(i,n){
            if(!p[a[i].second]){
                res += a[i].first;
                p[a[i].second] = 1;
            }
        }
        cout << res << "\n";
    }
    return 0;
}


Measured memory_bytes: 3108
using System;
using System.Linq;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();
            var a = s[0];
            var b = s[1];

            var d = new DateTime(2020,1,1,a,0,0);
            var t = new TimeSpan(b,0,0);

            Console.WriteLine((d+t).Hour);
        }
    }
}


Measured memory_bytes: 13396
#include<stdio.h>
int main(void){
    int N;
    scanf("%d",&N);
    if(N>=65 && N<=90){
        printf("1\n");
    }else if(N>=97 && N<=122){
        printf("2\n");
    }else{
        printf("0\n");
    }
    return 0;
}


Measured memory_bytes: 2128
import java.util.LinkedList;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        LinkedList<Character> st = new LinkedList<>();
        String x = sc.next();
        for (char ch: x.toCharArray()) {
            if (ch == 'T' && !st.isEmpty() && st.getLast() == 'S') {
                st.removeLast();
            } else {
                st.addLast(ch);
            }
        }
        System.out.println(st.size());
    }
}


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

int a[1005];

int main(int argc, char** argv)
{
	int n, m, cnt = 0;
	float min = 0;
	scanf("%d%d", &n, &m);
	for(int i=0; i<n; i++)
	{
		scanf("%d", a + i);
		min += a[i];
	}
	min /= m << 2;
	for(int i=0; i<n; i++)
		if(a[i] >= min)
			if(++cnt == m)
			{
				puts("Yes");
				return 0;
			}
	puts("No");
	return 0;
}

Measured memory_bytes: 128
import Control.Monad
import Data.List
main = getLine >>= main' . map read . words
    where
        main' [n, k]
            | n == 0 && k == 0 = return ()
            | otherwise = replicateM (n + 1) getLine >>= putStrLn . solve . map (map read . words) >> main

solve :: [[Int]] -> String
solve = br . all (>= 0) . foldl1' (zipWith (-))
    where
        br x
            | x = "Yes"
            | otherwise = "No"

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

int n, m;
typedef pair<int, int> P;
vector<P> v;
int ans;
int r = -1;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n >> m;
	for(int i=0; i<m; ++i){
		int a, b;
		cin >> a >> b;
		v.push_back(P(a, b));
	}
	sort(v.begin(), v.end(), [](P a, P b){ return a.second < b.second;});
//	for(int i=0; i<v.size(); ++i)
//		cout << v[i].first << " " << v[i].second << "\n";
	for(int i=0; i<v.size(); ++i){
		if(r < v[i].first){
			++ans;
			r = v[i].second-1;
		}
	}
	cout << ans << "\n";
}

Measured memory_bytes: 1400
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    int64_t N;
    std::cin >> N;

    std::vector<int64_t> X;
    for (decltype(N) i = 0; i < N; ++i) {
        int64_t t;
        std::cin >> t;
        X.push_back(t);
    }

    auto Y = X;
    std::sort(std::begin(Y), std::end(Y));

    for (int64_t i = 0; i < N; ++i) {
        if (X[i] < Y[N/2]) {
            std::cout << Y[N/2] << std::endl;
        }
        else {
            std::cout << Y[N/2-1] << std::endl;
        }
    }

    return 0;
}


Measured memory_bytes: 5488
#include <stdio.h>
#define MAX(x,y) ((x>y)?(x):(y))
#define MIN(x,y) ((x<y)?(x):(y))

double x,max=-1.0,min=200000000.0;

int main(){
	while(scanf("%lf",&x)!=EOF) {
		max=MAX(max,x);
		min=MIN(min,x);
    	}
    	printf("%.2f\n",max-min);
    	return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#include <algorithm>
#include <queue>
using namespace std;
int main() {
	long long int N, P; 
	cin >> N >> P; 
	if(N == 1){cout << P << endl;}
	else{int A[1000010] = {}; 
	long long int M = P; 
	for(long long int i = 2; i * i <= P; i++){
		while(M % i == 0){
			A[i] ++; M /=  i; 
		}
	}
	long long int ans = 1; 
	for(long long int i = 2; i * i <= P; i++){
		for(long long int j = 1; j <= A[i]/N ; j++){
			ans *= i; 
		}
	}
	cout << ans << endl; 
	}
}

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
const long long INF = 1LL << 60;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ld a, b;
  cin >> a >> b;
  ld ans = a * b + 1e-15;
  cout << (ll)floor(ans) << endl;

  return 0;
}


Measured memory_bytes: 3772
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <iomanip>
#include <cmath>

using namespace std;
typedef long long ll;

#define cout (cout << setprecision(12))

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

    cout << x << " " << y << " " << z << " " << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		long[] c = new long[26];
		int n = sc.nextInt();
		String s = sc.next();
		for(int i = 0; i < n; i++){
			c[s.charAt(i)-97]++;
		}
		long ans = 1;
		for(int i = 0; i < 26; i++){
			ans=ans*(c[i]+1)%1000000007;
		}
		System.out.print(ans-1);
	}
}


Measured memory_bytes: 25544
use std::io;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.trim().chars();
	let mut v = Vec::new();
	for i in iter {
		v.push((i as u32) - 48)
	}
	let mut flag = true;
	for i in 0..3 {
		if v[(i + 1) as usize] == v[i as usize] {
			flag = false;
			break;
		}
	}
	if flag {
		println!("Good");
	}else{
		println!("Bad");
	}
}

Measured memory_bytes: 4352
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    sx, sy, tx, ty = MI()

    ans = deque([])
    # path1
    ans.extend(['U']*abs(ty - sy))
    ans.extend(['R']*abs(tx - sx))

    # path2
    ans.extend(['D']*abs(ty - sy))
    ans.extend(['L']*abs(tx - sx))

    # path3
    ans.extend(['L'])
    ans.extend(['U']*(abs(ty - sy)+1))
    ans.extend(['R']*(abs(tx - sx)+1))
    ans.extend(['D'])

    # path4
    ans.extend(['R'])
    ans.extend(['D'] * (abs(ty - sy)+1))
    ans.extend(['L'] * (abs(tx - sx)+1))
    ans.extend(['U'])

    # print(ans)
    printlist(ans, '')


if __name__ == '__main__':
    solve()


Measured memory_bytes: 9548
#include<stdio.h>
int main(){
  int n,m,i,j,x,y,a[100][100]={0};
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&x,&m);
    for(j=0;j<m;j++){
      scanf("%d",&y);
      a[x-1][y-1]=1;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      printf("%d",a[i][j]);
      if(j!=n-1)printf(" ");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 652
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i< (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;

//priority_queue<int, vector<int>, greater<int>> min_heap;
//struct Point {
//	int x,y;
//};
//long long ccw(const Point& A, const Point& B, const Point& C) { // 시계방향이면 음수 
//	return 1LL * (B.x - A.x)*(C.y - A.y) - 1LL * (B.y - A.y)*(C.x - A.x);
//}
int a[100001];

int main() { // 골드 1, 플레 1, 네트워크 유량(디닉 알고리즘), 

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int ans = 1;
	int n; cin >> n;
	rep(i, n)cin >> a[i];
	int cmp = a[n - 1];
	int cnt = 1;
	for (int i = n - 2; i >= 0; i--) {
		if (cmp <= a[i]) {
			cnt += 1; cmp = a[i];
		}
		else {
			ans = max(ans, cnt);
			cmp = a[i];
			cnt = 1;
		}
	}
	ans = max(ans, cnt);
	cout << ans - 1 << '\n';


}


Measured memory_bytes: 640
#ifdef HIRO
#include "../stdc++.h"
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#include <bits/stdc++.h>
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;

int main() {
#ifdef HIRO
  string file_path(QUIZ);
  ifstream cin(file_path + "/input.txt");
  std::cin.rdbuf(cin.rdbuf());
#endif
  int n;
  int k;
  cin >> n;
  cin >> k;
  vector<long> a(n);
  int i = n;
  while(i--)
    cin >> a[i];
  
  sort(a.begin(), a.end(), greater<long>());
  long ans = 0;
  for(int i = k; i < n; i++) {
    ans += a[i];
  }


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



Measured memory_bytes: 1792
s = str(input())

n = len(s)

L = [0]*(n+1)
cnt = 0
for i in range(n):
    if s[i] == '<':
        cnt += 1
    else:
        cnt = 0
    L[i+1] = cnt


R = [0]*(n+1)
cnt = 0
for i in reversed(range(n)):
    if s[i] == '>':
        cnt += 1
    else:
        cnt = 0
    R[i] = cnt

A = [0]*(n+1)
for i in range(n+1):
    A[i] = max(L[i], R[i])
print(sum(A))


Measured memory_bytes: 85860
def prf(m):
    pf = {}
    for i in range(2, int(m**0.5)+1):
        while m % i == 0:
            pf[i] = pf.get(i, 0)+1
            m //= i
    if m > 1:
        pf[m] = 1
    return pf
def inpl(): return [int(i) for i in input().split()]
def comb(n, k):
    k = min(k, n - k)
    result = 1
    for i in range(n, n - k, -1):
        result *= i
    for i in range(1, k + 1):
        result //= i 
    return result

mod = 10**9+7
N, M = inpl()

ans = 1
for i in prf(M).values():
    ans = ans*comb(N+i-1, i)%mod
print(ans)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(int i=0; i<(n); i++)
#define REPj(n) for(int j=0; j<(n); j++)
#define REPinit(i,a,n) for(int i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(int j=(a); j<(n); j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//Optimizer
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/*
    add utility Algorithm
*/


int main(int argc, char const* argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int a;
    cin >> a;

    cout << (a + (a * a) + (a * a * a)) << endl;


    

    return 0;
}


Measured memory_bytes: 3632
n=int(input())
a=list(map(int, input().split()))
import collections
import math
def combinations_count2(n):
    if(n<=1):
        answer=0
    else:
        answer=n*(n-1)/2
    return answer

table=collections.Counter(a)
keytable=table.keys()
sums=0
for value in table.values():
    sums+=combinations_count2(value)
#print(ca)
#print(sum)
#print(keytable)
#print(table)
for i in range(len(a)):
    answer=sums-table[a[i]]+1
    print(int(answer))

Measured memory_bytes: 26140
<?php
fscanf(STDIN,'%s',$S);
fscanf(STDIN,'%s',$T);
$Sarr=str_split($S);
$Tarr=str_split($T);
$judge=0;
for ($i=0; $i < count($Sarr) ; $i++) { 
    # code...
    $deleted = array_shift($Sarr);
    $Sarr[] = $deleted;
    if ($Sarr==$Tarr) {
        # code...
        $judge=1;
        break;
    }
    
}
if($judge==1){
    echo 'Yes';
}else{
    echo 'No';
}
?>

Measured memory_bytes: 3576
#include <string>
#include <vector>
#include <iostream>
using namespace std;
int A, B;
int main() {
	cin >> A >> B; A--, B--;
	int H = 99, W = 98;
	vector<string> v(H, string(W / 2, '.') + string(W / 2, '#'));
	for (int i = 0; i < H; i += 2) {
		for (int j = 1; j <= W / 2 - 2; j += 2) {
			if (B >= 1) {
				B--;
				v[i][j] = '#';
			}
			if (A >= 1) {
				A--;
				v[i][W / 2 + j] = '.';
			}
		}
	}
	cout << H << ' ' << W << endl;
	for (int i = 0; i < H; i++) cout << v[i] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
//const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, A, B;
    cin >> N >> A >> B;
    N %= 12;
    REP(i,N){
        if(i%2==0) A = A - B;
        else B = A + B;
        //cout << A << " " << B << endl;
    }
    cout << A << " " << B << endl;
}


Measured memory_bytes: 3212
import itertools
N = int(input())

nums = set([int("".join(n)) for r in range(1,9+1)
              for n in itertools.product(list("753"), repeat=r)])

for chars in ["75","53","37","7","5","3"]:
    nums -= set([int("".join(n)) for r in range(1,9+1)
                   for n in itertools.product(list(chars), repeat=r)])


print(len([n for n in list(nums) if n <= N]))


Measured memory_bytes: 6804
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr double INF{1e9};
constexpr int MAGIC_PRIME{1000000000 + 7};
constexpr array<int, 4> dy{-1, 1, 0, 0};
constexpr array<int, 4> dx{0, 0, -1, 1};
constexpr int div_ru(int a, int b)
{
    return (a - b + 1) / b;
}

class UnionFindTree
{
private:
    vector<int> par_;
    vector<int> rank_;

public:
    UnionFindTree(int);
    ~UnionFindTree();
    int root(int);
    bool same(int, int);
    void unite(int, int);
    int numRoot();
};

UnionFindTree::UnionFindTree(int n) : par_(n), rank_(n)
{
    iota(par_.begin(), par_.end(), 0);
}

UnionFindTree::~UnionFindTree()
{
}

int UnionFindTree::root(int x)
{
    return par_[x] == x ? x : par_[x] = root(par_[x]);
}

bool UnionFindTree::same(int x, int y)
{
    return root(x) == root(y);
}

void UnionFindTree::unite(int x, int y)
{
    x = root(x);
    y = root(y);
    if (x == y)
        return;
    else if (rank_[x] < rank_[y])
        par_[x] = y;
    else
    {
        par_[y] = x;
        if (rank_[x] == rank_[y])
            rank_[x]++;
    }
}

int UnionFindTree::numRoot()
{
    int n = 0;
    for (int i = 0; i < par_.size(); i++)
    {
        if(i==root(i))
            n++;
    }
    return n;
}

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

    int n, m;
    cin >> n >> m;
    vector<int> x(m), y(m), z(m);
    for (int i = 0; i < m; i++)
        cin >> x[i] >> y[i] >> z[i];

    UnionFindTree t(n);

    for (int i = 0; i < m; i++)
    {
        t.unite(x[i] - 1, y[i] - 1);
    }

    cout << t.numRoot() << endl;
}
// 　　　　　　_......_
// 　　　　 , ´　 <＊y　♪
// 　　　　 i,（i ﾉﾉﾊ）_）
// 　　　　ﾉ_iﾊﾟ ヮﾟﾉﾊ
// 　　　 　 ,´i'_ｿﾉj,〈つ　))
// 　　　　〈_,ﾉ＾＾＾ヽ.´
// 　　　　 .＾＾i_ｿ_ｿ^´
// 　　　　 ￣￣ ￣　


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

const int maxn = 200001;

vector<int> e[maxn];

void rm(int x,int p){
	for(int i=0;i<e[x].size();i++)
		if(e[x][i]==p){
			swap(e[x][i],e[x].back());
			e[x].pop_back();
		}
	for(int it:e[x])
		rm(it,x);
}

int dep[maxn],pass[maxn],cnt[maxn];
bool color[maxn];
int notpass[maxn],pre[maxn];
void dfs(int x){
	dep[x]=0;
	pass[x]=1e9;
	cnt[x]=color[x];
	for(int it:e[x]){
		dfs(it);
		cnt[x]+=cnt[it];
		dep[x]=max(dep[x],dep[it]+1);
		if(cnt[it])
			pass[x]=min(pass[x],dep[it]+1);
	}
	if(color[x])
		pass[x]=min(pass[x],dep[x]);
}
void dfs2(int x){
	notpass[x]=pre[x]-1;
	int mx=-1;
	for(int it:e[x]){
		pre[it]=max(pre[it],mx+2);
		mx=max(mx,dep[it]);
	}
	mx=-1;
	for(int i=(int)e[x].size()-1;i>=0;i--){
		int it=e[x][i];
		pre[it]=max(pre[it],mx+2);
		mx=max(mx,dep[it]);
	}
	for(int it:e[x]){
		pre[it]=max(pre[it],1+pre[x]);
		dfs2(it);
	}
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	for(int i=1,u,v;i<n;i++){
		cin>>u>>v;
		e[u].emplace_back(v);
		e[v].emplace_back(u);
	}
	string s;
	cin>>s;
	long long int ans=0;
	for(int i=0;i<s.size();i++)
		if(s[i]=='1')
			color[i+1]=true,ans=1;
	rm(1,0);
	dfs(1);
	dfs2(1);
	for(int i=1;i<=n;i++){
		int low=color[i]?0:min(pass[i],(cnt[1]==cnt[i]?2000000000:pre[i]));
		int high=max(dep[i],pre[i])-1;
		if(i!=1)	high=min(high,dep[i]+1);
		for(int it:e[i])
			high=min(high,notpass[it]+1);
		if(high>=low)
			ans+=high-low+1;
	}
	cout<<ans<<endl;

}


Measured memory_bytes: 22800
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,n) for(int i = (a); i < (n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define debug_v(v,N) for(int i=0;i<N;i++) { cout << v[i] << " "; } cout << endl;
#define debug_vv(v,H,W) for(int i=0;i<H;i++) { for(int j=0;j<W;j++) { cout << v[i][j] << " "; } cout << endl; }

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

int dp[5005][5005];

void Main()
{
	int N; cin >> N;
	string S; cin >> S;
	for (int i = N - 1; i >=0; --i) {
		for (int j = N - 1; j >=0; --j) {
			if (S[i] != S[j]) dp[i][j] = 0;
			else dp[i][j] = dp[i + 1][j + 1] + 1;
		}
	}
	int ans = 0;
	rep(i,N) rep(j, N) {
		if (i > j) continue;
		int tmp = min(dp[i][j], j - i);
		ans = max(ans, tmp);
	}
	cout << ans << endl;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


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

int main(){
    int a,b,d,r;
    double f;
    cin >>a>>b;
    d=a/b;
    r=a%b;
    f=(double)a/b;
    cout<<fixed<<setprecision(5);
    cout <<d<<" "<<r<<" "<<f<<endl;}



Measured memory_bytes: 3252
import sys
input = sys.stdin.readline
from itertools import chain

def readlines(*xy):
    for n in xy:
        yield sorted(map(int, input().split()), reverse=True)[:n]
    
    yield map(int, input().split())

def main():
    x, y, a, b, c = map(int, input().split())
    apples = sorted(chain(*readlines(x,y)), reverse=True)
    print(sum(apples[:x+y]))


main()




Measured memory_bytes: 25776
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <vector>
using namespace std;
 
int main() {
    int N,K;
    cin>>N>>K;
    vector<int> A(N);
    for(int i=0;i<N;i++)
    {
      cin>>A[i];
    }
    vector<int> a = A;
    for (int i = 0; i < K; i++) {
        vector<int> B(N+1, 0);
        for (int j = 0; j < N; j++) {
            B[max(0, j - a[j])]++;
            B[min(N, j + a[j] + 1)]--;
        }
 
        for (int j = 0; j < N; j++) {
            B[j + 1] +=B[j];
        }
      B.pop_back();
      if(a==B)break;
      a=B;
    }
    for(int i=0;i<N;i++)
    {
      cout<<a[i]<< (i == N - 1 ? '\n' : ' ');
    }
    return 0;
}

Measured memory_bytes: 5588
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n;
string s;
bool dp[2005][3];
int main(){
	cin >> n >> s;
	dp[0][0] = 1;
	rep(i,n){
		for(int j=2;j>=0;j--){
			rep(x,105){
				if(dp[x][j] == false) continue;
				dp[x*10+s[i]-'0'][j+1] = 1;
			}
		}
	}
	int ans = 0;
	for(int i=0;i<1000;i++) if(dp[i][3])ans++;
	cout<<ans<<endl;}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
//#define int long long

//ダブりに注意
//魔法をダブらせて使う
void solve() {
    int n; cin >> n;
    ll x; cin >> x;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    vector<ll> b(n);
    rep(i, n) {
        b[i] = a[i];
    }
    ll ans = INF;
    //魔法を使う回数を先に確定しちゃうとただのgreedy
    rep(i, n) {
        ll res = x * i;
        rep(j, n) {
            int k = (j - i + n) % n;
            b[j] = min(b[j], a[k]);
            //同じ計算を何度もしない（累積和など）
        }
        rep(j, n) {
            res += b[j];
        }
        ans = min(ans, res);
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;

inline void up(int &x,const int &y){if(x<y)x=y;}
inline void down(int &x,const int &y){if(x>y)x=y;}
const int maxn = 210000;
const int maxd = 20;
const int maxv = 810000;

int n,V,d,t[maxn];
int p[maxn];
int li[maxn*maxd],ri[maxn*maxd],cnt,bel[maxd][maxn];
int f[maxv],g[maxv];
int dp[maxn];

int main()
{
	scanf("%d%d",&n,&V);
	for(int i=1;i<=n;i++) scanf("%d",&p[i]);
	d=0; for(int now=V;now;now>>=1) t[++d]=now; t[++d]=0;
	for(int i=1;i*2<=d;i++) swap(t[i],t[d-i+1]);
	
	for(int i=1;i<=d;i++)
	{
		int cc=t[i]; int now=cnt;
		bel[i][1]=++cnt;
		li[cnt]=ri[cnt]=1;
		for(int j=2;j<=n;j++)
		{
			if(p[j]-p[j-1]<=cc) ri[bel[i][j]=bel[i][j-1]]=j;
			else li[bel[i][j]=++cnt]=ri[cnt]=j;
		}
	}
	int al=1<<d-1;
	memset(f,-1,sizeof f); f[0]=0;
	for(int i=0;i<al;i++) if(f[i]!=-1)
	{
		if(f[i]==n) 
		{
			for(int j=0;j<d-1;j++) if(!(i>>j&1)) 
				up(f[i+(1<<j)],f[i]);
		}
		else
		{
			for(int j=0;j<d-1;j++) if(!(i>>j&1)) 
				up(f[i+(1<<j)],ri[bel[j+1][f[i]+1]]);
		}
	}
	for(int i=0;i<al;i++) g[i]=n+1;
	for(int i=0;i<al;i++)
	{
		if(g[i]==1)
		{
			for(int j=0;j<d-1;j++) if(!(i>>j&1))
				down(g[i+(1<<j)],g[i]);
		}
		else
		{
			for(int j=0;j<d-1;j++) if(!(i>>j&1))
				down(g[i+(1<<j)],li[bel[j+1][g[i]-1]]);
		}
	}
	for(int i=0;i<=n;i++) dp[i]=n+1;
	for(int i=0;i<al;i++) down(dp[f[i]],g[al-1-i]);
	for(int i=n-1;i>=0;i--) down(dp[i],dp[i+1]);
	
	for(int i=1;i<=n;i++)
	{
		int l=li[bel[d][i]],r=ri[bel[d][i]];
		if((r==n&&f[al-1]>=l-1)||(r<n&&dp[l-1]<=r+1)) puts("Possible");
		else puts("Impossible");
	}
	
	return 0;
}


Measured memory_bytes: 34944
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll mod = 998244353;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<ll> vec){ //for debug
    ll n = vec.size();
    cout << "------------------------------------\n" ;
    rep(i,n) cout << i << " " << vec.at(i) << "\n";
    cout << "------------------------------------\n" ;
}

void pr2d(vector<vector<ll>> vec){ // for debug
    ll h = vec.size();
    ll w = vec.at(0).size();
    cout << "------------------------------------\n" ;
    rep(i,h){
        rep(j,w){
            cout << vec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
    cout << "------------------------------------\n" ;
}

int main(){
    ll n , c;  cin >> n >> c;
    vector<vector<ll>> d(c,vector<ll>(c,-1));
    rep(i,c) rep(j,c) cin >> d.at(i).at(j);
    vector<vector<ll>> b(n,vector<ll>(n,0));
    rep(i,n) rep(j,n){
        cin >> b.at(i).at(j);
        b.at(i).at(j)--;
    }

    vector<ll> zero(c,0),one(c,0),two(c,0);
    rep(i,n){
        rep(j,n){
            ll x = b.at(i).at(j);
            if((i+j)%3 == 0){
                zero.at(x)++;
            }else if((i+j)%3 == 1){
                one.at(x)++;
            }else{
                two.at(x)++;
            }
        }
    }

    ll minimum_cost = INF;

    for(int i=0;i<c;i++){ //zero
        for(int j=0;j<c;j++){ //one
            if(i==j) continue;
            for(int k=0;k<c;k++){ //two
                if(i==k || j==k) continue;
                ll cost = 0;

                for(int ii=0;ii<c;ii++){
                    if(ii==i) continue;
                    cost += zero.at(ii) * d.at(ii).at(i);
                }
                for(int jj=0;jj<c;jj++){
                    if(jj==j) continue;
                    cost += one.at(jj) * d.at(jj).at(j);
                }
                for(int kk=0;kk<c;kk++){
                    if(kk==k) continue;
                    cost += two.at(kk) * d.at(kk).at(k);
                }

                minimum_cost = min(minimum_cost,cost);
            }
        }
    }

    cout << minimum_cost << endl;
    return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h> 
#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vp = vector<P>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using vvb = vector<vb>;
const int INF = 1e9;
const int MOD = 1e9+7;


signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    string S; cin >> S;
    if(S == "AAA" || S == "BBB") cout << "No" << endl;
    else cout << "Yes" << endl;
}

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

int main()
{
  int N,X,Y ;
  cin>>N>>X>>Y ;
  
  vector<int>k(N-1,0) ;
  for(int i=0;i<N-1;i++){
    for(int j=i+1;j<N;j++){
      if(i==X-1&&j==Y-1) k.at(0)++ ;
      else if(j-i==1) k.at(0)++ ;
      else{
        int min=0 ;
        if(i<X-1) min+=X-1-i ;
        else min+=i-X+1 ;
        min++ ;
        if(j>Y-1) min+=j-Y+1 ;
        else min+=Y-1-j ;
        //cout<<"("<<i<<","<<j<<")="<<min<<endl ;
        if(min>j-i) k.at(j-i-1)++ ;
        else k.at(min-1)++ ;
      } 
      //cout<<k.at(0)<<" "<<k.at(1)<<" "<<k.at(2)<<" "<<k.at(3)<<endl ;
    }
  }
  
  for(int i=0;i<N-1;i++) cout<<k.at(i)<<endl ;
  
  return 0 ;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

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

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::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==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 N;
	cin >> N;
	vector<int64> p(N);
	int64 cnt = 0;
	REP(i, N) cin >> p[i];
	REP(i, N) {
	    if (i+1 != p[i]) cnt++;
	}
	if (cnt == 0 || cnt == 2) {
	    cout << "YES" << endl;
	} else {
	    cout << "NO" << endl;
	}
}


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

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

static constexpr bool is_odd(ll n) { return n & 0x01 != 0; }
static constexpr bool is_multiple_of_4(ll n) { return n % 4 == 0; }

int main() {
  ll N;
  cin >> N;
  ll odd = 0, multi4 = 0;
  REP(i, N) {
    ll a;
    cin >> a;
    if (is_odd(a)) {
      odd++;
    } else if (is_multiple_of_4(a)) {
      multi4++;
    }
  }
  if (odd == 0) {
    cout << "Yes" << endl;
    return 0;
  }
  const ll multi2not4 = N - odd - multi4;
  const ll not4chunk = odd + (multi2not4 > 0);
  cout << (multi4 >= not4chunk - 1 ? "Yes" : "No") << endl;
  return 0;
}


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

using namespace std;

int main()
{
	int n;
	cin >> n;
	string s;
	int a, b;
	cout << 0 << endl;
	cin >> s;
	char c = s[0];
	a = 1, b = n - 1;
	while (s != "Vacant")
	{
		int m = (a + b) / 2;
		cout << m << endl;
		cin >> s;
		int q = (s[0] == c) + m % 2;
		if (q % 2 == 1)
			a = m + 1;
		else
			b = m - 1;
	}
}

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

using namespace std;

int N, K, lg[200009], p[200009], mx[200009], mn[200009], s[200009];

typedef pair < int, int > myS;
myS rmq[2][18][200009];

myS mrg (myS x, myS y)
{
    return {min (x.first, y.first), max (x.second, y.second)};
}

void buildRMQ (int lin, int v[])
{
    for (int i=1; i<=N; i++)
        rmq[lin][0][i] = {v[i], v[i]};
    for (int i=1; i<=lg[N]; i++)
        for (int j=1; j + (1 << i) - 1 <= N; j++)
            rmq[lin][i][j] = mrg (rmq[lin][i - 1][j], rmq[lin][i - 1][j + (1 << (i - 1))]);
}

myS query (int lin, int i, int j)
{
    int p = lg[j - i + 1];
    return mrg (rmq[lin][p][i], rmq[lin][p][j - (1 << p) + 1]);
}

bool isIncreasing (int i, int j)
{
    if (i == j) return 1;
    return (s[j - 1] - s[i - 1] == j - i);
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d", &N, &K);
for (int i=1; i<=N; i++)
    scanf ("%d", &p[i]);
for (int i=1; i<N; i++)
    s[i] = s[i - 1] + (p[i + 1] > p[i]);
lg[0] = 0;
for (int i=1; i<=N; i++)
{
    lg[i] = lg[i - 1];
    if ((2 << lg[i]) <= i)
        lg[i] ++;
}
buildRMQ (0, p);
int ans = 0;
for (int i=1; i<=N - K + 1; i++)
    if (isIncreasing (i, i + K - 1)) ans = 1;
    else
    {
        ///analyzing [i, i + K - 1]
        int l = i, r = i + K - 2, ras = i - 1;
        ///looking for the biggest pos s.t. [i..pos] is increasing and a[pos] < min(a[pos+1..i+K-1]
        while (l <= r)
        {
            int mij = (l + r) >> 1;
            if (isIncreasing (i, mij) && p[mij] < query (0, mij + 1, i + K - 1).first) ras = mij, l = mij + 1;
            else r = mij - 1;
        }
        mx[i] = ras;

        l = i + 1, r = i + K - 1, ras = i + K;
        ///looking for the smallest pos s.t. [pos..i+K-1] is increasing and max(a[i..pos - 1] < a[pos]
        while (l <= r)
        {
            int mij = (l + r) >> 1;
            if (isIncreasing (mij, i + K - 1) && query (0, i, mij - 1).second < p[mij]) ras = mij, r = mij - 1;
            else l = mij + 1;
        }
        mn[i] = ras;
    }
buildRMQ (1, mx);
for (int i=1; i<=N - K + 1; i++)
    if (!isIncreasing (i, i + K - 1))
    {
        ///does this bring something new?
        bool ok = 1;
        /*for (int j=1; j<i; j++)
            if (j + K - 1 >= mn[i] - 1 && mx[j] >= i - 1)
                ok = 0, printf ("%d same as %d\n", i, j);*/
        ///j + K - 1 >= mn[i] - 1 => j >= mn[i] - K
        int l = max (mn[i] - K, 1), r = i - 1;
        if (l <= r && query (1, l, r).second >= i - 1)
            ok = 0;
        ans += ok;
    }
printf ("%d\n", ans);
return 0;
}


Measured memory_bytes: 60416
S = input()
list = []
counter = 0
for i in range(len(S)):
    if S[i] == 'A' or S[i] == 'T' or S[i] == 'G' or S[i] == 'C':
        counter += 1
    else:
        counter = 0
    list.append(counter)
print(max(list))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INFINITO 1000000000
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )


int main() {

    int n;
    cin >> n;
    map<string, int> m;
    int maior = 0;

    fo(i, n) {
        string s;
        cin >> s;
        m[s]++;
        maior = max(maior, m[s]);
    }

    for ( auto it : m ) {
        if ( it.ss == maior ) cout << it.ff << endl;
    }

    return 0;
}

Measured memory_bytes: 25216
def main():
    n = int(input())
    up, down = [], []
    for _ in range(n):
        s = list(input())
        m = 0
        height = 0
        for si in s:
            if si == "(":
                height += 1
            else:
                height -= 1
                m = min(m, height)
        if height >= 0:
            up.append([m, height])
        else:
            down.append([m-height, -height])
    up.sort(reverse=True)
    down.sort(reverse=True)
    if sum([j for i, j in up])-sum([j for i, j in down]) != 0:
        print("No")
        return
    h = 0
    for mi, hi in up:
        if h+mi < 0:
            print("No")
            return
        h += hi
    h = 0
    for hmi, hi in down:
        if h+hmi >= 0:
            h += hi
        else:
            print("No")
            return
    print("Yes")
    
        
if __name__ == "__main__":
    main()

Measured memory_bytes: 228496
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define forn(i, a, b) for (int i = a; i < b; ++i)
#define SZ(x) int(x.size())
#define pb push_back
#define F first
#define S second
void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
  cerr << ' ' << H;
  dbg_out(T...);
}

int main() {
#ifdef LOCAL
  freopen("f.txt", "r", stdin);
// freopen("main.txt", "w", stdout);
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
  ios::sync_with_stdio(0);
  cin.tie(0);
#define endl '\n'
#define dbg(...) 18
#endif
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  sort(v.rbegin(), v.rend());
  int a = 0, b = 0;
  for (int i = 0; i < n; i++) {
    if (i & 1)
      b += v[i];
    else
      a += v[i];
  }
  cout << (a - b) << endl;
  return 0;
}

Measured memory_bytes: 3568
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

pair<int,int> move(char c){
    int a=0,b=0;
    if(c == 'U'){
        a = -1;
    }else if(c == 'D'){
        a = 1;
    }else if(c == 'L'){
        b = -1;
    }else if(c == 'R'){
        b = 1;
    }
    return pair<int,int>{a,b};
}

bool solve(int H,int W,int N, string& S, string& T, char taka, char aoki, int x, int y){
    for (int i = 0; i < N; i++)
    {
        // cout<<i<<endl;
        // cout<<x<<y<<endl;
        if(S[i] == taka){
            // cout<<"!"<<endl;
            pair<int,int> m = move(taka);
            x += m.first;
            y += m.second;
        }
        if(x < 0 || x >= H || y < 0 || y >= W){
            // cout<<taka<<aoki<<endl;
            return false;
        }
        if(T[i] == aoki){
            pair<int,int> m = move(aoki);
            x += m.first;
            y += m.second;
            if(x < 0 || x >= H){
                x -= m.first;
            }
            if(y < 0 || y >= W){
                y -= m.second;
            }
        }
    }
    return true;
}

int main(){
    int H,W,N;cin>>H>>W>>N;
    int sr,sc;cin>>sr>>sc;
    sr--;sc--;
    string S,T;cin>>S>>T;
    if(!solve(H,W,N,S,T,'U','D',sr,sc) || !solve(H,W,N,S,T,'R','L',sr,sc)
        || !solve(H,W,N,S,T,'D','U',sr,sc) || !solve(H,W,N,S,T,'L','R',sr,sc)){
        cout<<"NO"<<endl;
    }else{
        cout<<"YES"<<endl;
    }

}

Measured memory_bytes: 776
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

struct CumulativeSum{
    vector<int> data;
    CumulativeSum(int sz) : data(sz, 0) {};
    void add(int k, int x){
        data[k] += x;
    }
    void build(){
        for(int i = 1; i < data.size(); i++){
            data[i] += data[i - 1];
        }
    }
    //区間[0,k]の和
    int query(int k){
        if(k < 0) return 0;
        return (data[min(k, (int)data.size() - 1)]);
    }
    //区間[l.r)の和
    int query(int l, int r){
        return query(r - 1) - query(l - 1);
    }
};

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    CumulativeSum cs(n);
    rep(i, 0, n){
        cin >> a[i];
        cs.add(i, a[i]);
    }
    vector<int> b;
    cs.build();
    rep(i, 0, n){
        rep(j, i, n){
            b.push_back(cs.query(i, j + 1));
        }
    }
    int m = b.size();
    vector<bool> f(m, true);
    int ans = 0;
    for(int i = 40; i >= 0; i--){
        int cnt = 0;
        rep(j, 0, m){
            if(f[j] && b[j] & (1LL << i)){
                cnt++;
            }
        }
        if(cnt < k) continue;
        ans += 1LL << i;
        rep(j, 0, m){
            if(!(b[j] & (1LL << i))){
                f[j] = false;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 6384