akhauriyash/Code-Regression huggingface dataset:
def yoko_chk( a )
	0.upto( 2 ){|y|
		t = a[ y * 3 ]
		ng = 0
		1.upto( 2 ){ |x|
			if a[ y * 3 + x] != t
				ng = 1
				break
			end
		}
		return true,t if (ng == 0 && t != 's')
	}	
	return false,'a'
end

def tate_chk( a )
	0.upto( 2 ){|x|
		t = a[ x ]
		ng = 0
		1.upto( 2 ){ |y|
			if a[ y * 3 + x] != t
				ng = 1
				break
			end
		}
		return true,t if (ng == 0 && t!= 's')
	}	
	return false,'a'
end

def naname_chk( a )
	#1	
	if a[0]	== a[4] && a[4] == a[8] && a[0] != 's'
		return true, a[ 0 ]
	elsif a[2] == a[4] && a[ 4 ] == a[6] && a[2] !='s'
		return true, a[ 2 ]
	end
end


def tictactoe_check( line )
	a = line.split( // )	
	check, kachi = yoko_chk( a )
	if check && (kachi != 's')
		return kachi
	end
	check, kachi = tate_chk( a )
	if check && (kachi != 's')
		return kachi
	end
	check, kachi = naname_chk( a )
	if check && (kachi != 's')
		return kachi
	end
	return 'd'
end

answers = Array.new
while line = $stdin.gets
	answers << tictactoe_check( line.chomp )
end
answers.each{|a| puts a }


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

int main() 
{
    int N, K;
    cin >> N >> K;
    vector<int> A(N+1, 0);
    for (int i = 1; i <= N; i++){
        int a;
        cin >> a;
        A[a]++;
    }
    sort(A.begin(), A.end());
    
    int ans = 0;
    for (int i = 1; i <= N-K; i++) {
        ans += A[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

char s[100001];
int len;

int main()
{
    scanf("%s",s);
    len=strlen(s);
    for(int i=0;i<len-1;i++)
    {
        if(s[i]==s[i+1])
        {
            printf("%d %d\n",i+1,i+2);
            return 0;
        }
        if(s[i]==s[i+2]&&i<len-2)
        {
            printf("%d %d\n",i+1,i+3);
            return 0;

        }
    }
    printf("-1 -1\n");
    return 0;
}


Measured memory_bytes: 384
A = []
for i in range(3):
  a = input().split()
  a = [int(num) for num in a]
  A.append(a)

N = int(input())
b = [int(input()) for i in range(N)]

for i in range(3):
  for j in range(3):
    if b.count(A[i][j]) != 0:
      A[i][j] = 0
    else:
      continue

def Agetraw(j):
    Ans = [int(A[i][j]) for i in range(3)]
    return(Ans)

if (sum(A[0])==0 or sum(A[1])==0 or sum(A[2])==0 
    or sum(Agetraw(0))==0 or sum(Agetraw(1))==0 or sum(Agetraw(2))==0 
    or A[0][0]+A[1][1]+A[2][2]==0 or A[0][2]+A[1][1]+A[2][0]==0):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
void insertionSort(int A[],int N)
{
    int v,j;
    static int i=1;
    v=A[i];
    j=i-1;
    while(j>=0&&A[j]>v){
        A[j+1]=A[j];
        j--;
    }
    A[j+1]=v;
    i++;
}

int main()
{
    int n;
    cin>>n;
    int a[100];

    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=0;i<n;i++){
        cout<<a[i];
        if(i!=n-1)
            cout<<" ";
    }
    cout<<endl;
    for(int i=1;i<n;i++)
    {
        insertionSort(a,n);
        for(int i=0;i<n;i++){
            cout<<a[i];
            if(i!=n-1)
                cout<<" ";
        }
        cout<<endl;
    }
    return 0;
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(30) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 5100000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  lli A,B,C,D,E,F,N,M,K,L,R,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N;
  rep(i,0,N){
    cin >> A >> B;
    sum+=A*B;
    num+=B;
  }
  Out(num+(sum-1)/9-1);
}

Measured memory_bytes: 256
from collections import deque

h, w = map(int, input().split())
ch, cw = map(lambda x: int(x)-1, input().split())
dh, dw = map(lambda x: int(x)-1, input().split())
maze = [input() for _ in range(h)]

INF = 10**12
path = [[INF] * w for _ in range(h)] #ここに各マスの移動コストを記録する

walk = [(1,0), (0,1), (-1,0), (0,-1)] #ワープしない移動
warp = [(i,j) for i in range(-2,3) for j in range(-2,3) if (i,j) not in [(0,0)] + walk] #ワープするときの移動

q = deque()
path[ch][cw] = 0
q.append((ch, cw, 0))

while q:
    x, y, s = q.popleft()
    for dx, dy in walk:
        nx = x + dx
        ny = y + dy
        if 0 <= nx < h and 0 <= ny < w and maze[nx][ny] != "#" and path[nx][ny] > s:
            path[nx][ny] = s
            q.appendleft((nx, ny, s))
    for dx, dy in warp:
        nx = x + dx
        ny = y + dy
        if 0 <= nx < h and 0 <= ny < w and maze[nx][ny] != "#" and path[nx][ny] > s+1:
            path[nx][ny] = s+1
            q.append((nx, ny, s+1))

ans = path[dh][dw] if path[dh][dw] < INF else -1
print(ans)

Measured memory_bytes: 94348
#include <iostream>
using namespace std;
 
int n;
 
int main() {
	cin >> n;
	if(n == 1 || n == 2 || n == 3 || n == 5 || n == 6 || n == 9 || n == 10 || n == 13 || n == 17) {
		cout<<"No"<<endl;
	}
	else{
		cout<<"Yes"<<endl;
	}
	return 0;
}

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


int main()
{
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	int ans=arr[0]^arr[1];
	for(int i=2;i<n;i++)
	{
		ans=ans^arr[i];
	}

	for(int i=0;i<n;i++)
	{
		int temp=ans^arr[i];
		cout<<temp<<" ";
	}
	return 0;
}

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

class C
{
	static void Main()
	{
		var c = new int[3].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();
		Console.WriteLine(c.Select(r => r[0] - r[1]).Distinct().Count() == 1 && c.Select(r => r[0] - r[2]).Distinct().Count() == 1 ? "Yes" : "No");
	}
}


Measured memory_bytes: 13408
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func next() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func main() {
	buf := make([]byte, 1024 * 1024)
	scanner.Buffer(buf, bufio.MaxScanTokenSize)
	scanner.Split(bufio.ScanWords)

	n := nextInt()
	sum := 0
	m := nextInt()

	for i := 0; i < n - 1; i++ {
		a := nextInt()
		if a < m {
			sum += m - a
		} else {
			m = a
		}
	}

	fmt.Println(sum)
}


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

#define PI	3.1415926535
#define EPS	0.00000000001

int main()
{
	int n,a;
	int a1,a2;
	double h1,h2;
	while(cin >> n, n)
	{
		a1=a2=0;
		h1=h2=0;
		while(--n)
		{
			cin >> a;
			a1 += a;
			h1 += sin(a*PI/180.0);
		}
		cin >> n;
		while(--n)
		{
			cin >> a;
			a2 += a;
			h2 += sin(a*PI/180.0);
		}

		h1 += sin((360-a1)*PI/180.0);
		h2 += sin((360-a2)*PI/180.0);

		if(-EPS<h1-h2 && h1-h2<EPS)
		{
			cout << 0 << endl;
		}
		else if(h1>h2)
		{
			cout << 1 << endl;
		}
		else
		{
			cout << 2 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using Int = int64_t;
using UInt = uint64_t;
using C = std::complex<double>;
#define rep(i, n) for(Int i = 0; i < (Int)(n); ++i)
#define guard(x) if( not (x) ) continue;
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif

int main() {
   std::string ss[3];
   rep(i,3)
      std::cin >> ss[i];
   rep(i,3)
      putchar(ss[i][i]);
   putchar('\n');
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<58;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n,m;
map<int,int> M;

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		int A;
		cin>>A;
		M[A]++;
	}
	cin>>m;
	for(int i=0;i<m;i++){
		int A;
		cin>>A;
		if(M[A]==0){
			cout<<"NO"<<endl;
			return 0;
		}
		M[A]--;
	}
	cout<<"YES"<<endl;
}

Measured memory_bytes: 9600
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

void b_digits_sums(void) {
	string n;
	int n_int;
	string msg = "Yes";

	cin >> n;

	n_int = stoi(n);

	int s_n = 0;
	for (int i = 0; i < n.size(); i++) s_n += (n[i] - '0');

	if (n_int % s_n != 0) msg = "No";

	cout << msg << endl;
}

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

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

using namespace std;

int n;
long long a[55];

long long cek(long long k) {
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    long long cur = a[i] + k;
    if ((cur % (n+1)) == n) return -1;
    sum += cur / (n+1);
  } 
  return sum;
}

bool cek2(long long k) {
  for (long long i = max(k-n, 0LL); i <= k+n; i++)
    if (cek(i) >= i)
      return true;
  return false;
}

int main() {
  scanf("%d", &n);
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  long long ans = sum;
  for (long long i = max(0LL, sum - (n-1) * n); i <= sum; i++)
    if (cek(i) == i)
      ans = min(ans, i);
  cout << ans << endl;
  return 0;
}

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 r,g,b; cin >> r >> g >> b;
  int s = 100*r + 10*g + b;
  if(s % 4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var k, s int
	fmt.Scan(&k, &s)
	ans := 0
	for x := 0; x <= k; x++ {
		for y := 0; y <= k; y++ {
			z := s - x - y
			if 0 <= z && z <= k && (x+y+z) <= 3*k {
				// fmt.Printf("x,y,z -> %d,%d,%d\n", x, y, z)
				ans++
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define gc getchar()
#define pc(x) putchar(x)
template<typename T> void scan(T &x){x = 0;bool _=0;T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void printn(T n){bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=char(n%10+48);n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);}
template<typename First, typename ... Ints> void scan(First &arg, Ints&... rest){scan(arg);scan(rest...);}
template<typename T> void print(T n){printn(n);pc(10);}
template<typename First, typename ... Ints> void print(First arg, Ints... rest){printn(arg);pc(32);print(rest...);}

using namespace std;
const int MM = 2e5+5;

int n, m, mx, sz;
vector<int> adj[MM];
bool vis[MM];

void dfs(int cur){
	sz++;
	vis[cur] = 1;
	for(int u: adj[cur]){
		if(!vis[u])
			dfs(u);
	}
}

int main(){
	scan(n, m);
	while(m--){
		int a, b;
		scan(a, b);
		adj[a].emplace_back(b);
		adj[b].emplace_back(a);
	}
	for(int i = 1; i <= n; i++){
		if(!vis[i]){
			sz = 0;
			dfs(i);
			mx = max(mx, sz);
		}
	}
	print(mx);
}

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

using namespace std;

int main()
{
    int n,ans=0,prev=0;
    cin>>n;
    int a[n+1];
    bool f = false;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        if(a[i] != i)
        {
            ans++;
            if(ans == 2)
            {
                if(prev == i)f=true;
                else ans = 3;
            }
            prev = a[i];
        }
    }
    if(f && ans == 2 || ans == 0)cout<<"YES";
    else cout<<"NO";
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int[] a = new int[]{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K = scanner.nextInt();
    System.out.println(a[K - 1]);
  }
}


Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
long long n,a,b;
long long h[100100];
long long tmp[100100];
bool chk(long long mid){
	for(int i=1;i<=n;i++)
		tmp[i]=max(h[i]-mid*b,0LL);
	for(int i=1;i<=n;i++){
		if(tmp[i]>0){
			mid=mid-(tmp[i]-1)/(a-b)-1;
		} 
	} 
	return mid>=0;
}
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>a>>b;
	for(int i=1;i<=n;i++)	
		cin>>h[i];
	long long le=0,ri=1e9;
	while(le!=ri){
		long long mid=(le+ri)/2;
		if(chk(mid)){
			ri=mid;
		}
		else{
			le=mid+1;
		}
	}
	cout<<le<<endl;
	return 0;
}


Measured memory_bytes: 1920
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int main(void){
	int n,i;
	string o,e;
	cin >> o;
	cin >> e;
	n = e.l_ength();
	for(i=0; i<n; ++i){
		cout << o[i] << e[i];
	}
	if(o.l_ength()>n){
		cout << o[n];
	}
	cout << endl;
	return 0;
}


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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

void solve()
{
  int a,b,c; cin>>a>>b>>c;
  cout << min(b/a, c) << endl;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <set>

using namespace std;

vector<string> field;
vector<vector<int>> d;

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

	int h, w;
	cin >> h >> w;
	field.resize(h);
	d.resize(h);
	for (int i = 0; i < h; ++i) {
		cin >> field[i];
		d[i].resize(w);
	}

	int cnt = 0;

	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			if (field[i][j] == '#') {
				d[i][j] = -1;
				continue;
			}
			for (int shift_top = -1; shift_top <= 1; ++shift_top) {
				for (int shift_right = -1; shift_right <= 1; ++shift_right) {
					if (i + shift_top >= 0 && i + shift_top < h && j + shift_right < w && j + shift_right >= 0 && field[i + shift_top][j + shift_right] == '#')
						++d[i][j];
				}
			}
		}
	}

	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			if (d[i][j] == -1) 
				cout << "#";
			else
				cout << d[i][j];
		} cout << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>

#include <vector>
#include <cmath>
#include <limits>
#include <functional>
using namespace std;

int main()
{
    int N, M;
    cin >> N >> M;
    int ans = 0;
    int a[55], b[55];
    for (int i = 0; i < 55; i++)
    {
        a[i] = -1;
        b[i] = -1;
    }

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

    for (int i = 1; i <= N; i++)
    {
        for (int j = 0; j < M; j++)
        {
            if(i==a[j]||i==b[j])
                ans++;
        }
        cout << ans << endl;
        ans = 0;
    }

    return 0;
}

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//Write From this Line

int main()
{
	int a;
	cin >> a;
	int b = a;
	int sum = 0;
	rep(i,3){
		sum += a;
		a *= b;
	}
	cout << sum << endl;
}


Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a>b && b!=1) cout<<"Alice"<<endl;
    else if(a>b && b==1) cout<<"Bob"<<endl;
    else if(a<b && a==1) cout<<"Alice"<<endl;
    else if(a==b) cout<<"Draw"<<endl;
    else cout<<"Bob"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }


void solve();

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

  int T;
  // cin >> T;
  T = 1;

  while (T--) {
    solve();
  }
}

void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  cin >> a;

  vector<int> v;
  rep(i, n) {
    int it = lb(v, a[i]);
    it--;
    if (it < 0) v.insert(v.begin(), a[i]);
    else v[it] = a[i];
  }
  cout << sz(v) << endl;
}


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

using namespace std;

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    cin >> n >> k;
    vector<ll> a(n), f(n);
    for(i = 0; i < n; i++) {
        cin >> a[i];
    }
    for(i = 0; i < n; i++) {
        cin >> f[i];
    }
    sort(a.begin(), a.end());
    sort(f.rbegin(), f.rend());
    ll l = -1, r = 1e12;
    while(l + 1 != r) {
        ll m = (l + r) / 2;
        ll cnt = 0;
        for(i = 0; i < n; i++) {
            cnt += max(0LL, a[i] - m / f[i]);
        }
        if(cnt <= k)
            r = m;
        else
            l = m;
    }
    cout << r << endl;
    return 0;
}

Measured memory_bytes: 3328
"use strict";

const main = (input) => {
    const spi = input.split('\n');
    let n = parseInt(spi[0]);
    n = (n  % 100) % 10;

    if (n === 3) console.log("bon");
    else if (n === 0 || n === 1 || n === 6 || n === 8) console.log("pon");
    else console.log("hon");
};

main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, n, m) for (int i = n; i < m; i++)
#define ll long long int

using namespace std;

int main()
{
  int n,m;
  cin >> n >> m;
  int rt = (int)ceil(sqrt(m));
  int result = 1;
  FOR(i, 1, rt+1) {
    if(m%i != 0) {
      continue;
    }
    int q = m/i;
    if (min(q,i) < n) {
      if(max(q,i) < n) continue;
      result = max(result, min(q,i));
    } else {
      result = max(result, max(q,i));
    }
  }
  cout << result << endl;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	var bs []int
	fmt.Scanf("%d", &n)
	for i := 1; i < n; i++ {
		var tmp int
		fmt.Scanf("%d", &tmp)
		bs = append(bs, tmp)
	}
	fmt.Println(exec(bs))
}

// Bi >= MAX(Ai, Ai+1)
func exec(bs []int) int {
	as := make([]int, len(bs)+1)
	var s int
	for i, b := range bs {
		as[i] = b
		as[i+1] = b
		if i != 0 && bs[i-1] < as[i] {
			as[i] = bs[i-1]
		}
	}
	for _, a := range as {
		s += a
	}
	return s
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>

using namespace std;

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

using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    if (n == 1) {
        cout << "1.0" << "\n";
    }
    else if (n % 2 == 0) {
        cout << "0.5" << "\n";
    } 
    else {
        cout << 1.0 * (n + 1) / (2.0 * n) << "\n";
    } 
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {

	int d;
	cin >> d;
	int c[26];
	int i, j;
	for (i = 0; i < 26; i++) {
		cin >> c[i];
	}
	int s[365][26];
	for (i = 0; i < d; i++) {
		for (j = 0; j < 26; j++) {
			cin >> s[i][j];
		}
	}
	int last[26];
	for (i = 0; i < 26; i++) {
		last[i] = 0;
	}
	int jmax, jindex;
	for (i = 1; i <= d; i++) {

		jmax = 0;
		jindex = -1;
		for (j = 0; j < 26; j++) {
			if (c[j] *(i - last[j]) > jmax) {
				jmax = c[j] *(i - last[j]);
				jindex = j;
			}
			else if (c[j] *(i - last[j]) == jmax) {
				if (s[i - 1][j] > s[i - 1][jindex]) {
					jindex = j;
				}
			}
		}
		for (j = 0; j < 26; j++) {
			if (s[i - 1][j] + 100 * c[j] * (i - last[j]) >= jmax) {
				jmax = s[i - 1][j] + 100 * c[j] * (i - last[j]);
				jindex = j;
			}
		}
		last[jindex] = i;
		cout << jindex + 1 << endl;
		


	}
	return 0;


}

Measured memory_bytes: 3668
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define int ll
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
#define FOR(i,a,b) for(ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
const double pi = acos(-1);
const double EPS = 1e-10;

signed main(){
  int n;
  cin >> n;
  vi a(n),b(n);
  REP(i,n) cin >> a[i];
  sort(ALL(a));
  b = a;
  reverse(ALL(b));
  vi ans;
  int c;
  bool fl =false;
  int sz = (int)a.size();
  if(sz % 2 == 1){
    REP(i,sz/2 + 1) b.pop_back();
    REP(i,sz/2 ) a.pop_back();
    c = a.back();
    a.pop_back();
    if (b.back()-c >= c-a.back()) {
      ans.pb(c);
      fl = true;
    }
    REP(i,n-1){
      if (i % 2 == 0) {
        ans.pb(b.back());
        b.pop_back();
      } else {
        ans.pb(a[i/2]);
      }
    }
    if (!fl) {
      ans.pb(c);
    }
  } else{
    REP(i,sz/2){
      b.pop_back();
      a.pop_back();
    }
    ans.pb(a.back());
    REP(i,n-1){
      if (i % 2 == 0) {
        ans.pb(b[i/2]);
      } else {
        ans.pb(a[i/2]);
      }
    }
    ans.pb(b.back());
  }
  int sum = 0;
  FOR(i,1,(int)ans.size()) sum += abs(ans[i] - ans[i-1]);
  cout << sum << endl;
}

Measured memory_bytes: 2936
from collections import defaultdict
import sys

S = input()
T = input()
dic1 = defaultdict(str)
dic2 = defaultdict(str)

for x, y in zip(S, T):
    if not x in dic1:
        dic1[x] = y
    if not y in dic2:
        dic2[y] = x
    if x in dic1:
        if dic1[x] != y:
            print('No')
            sys.exit()
    if y in dic2:
        if dic2[y] != x:
            print('No')
            sys.exit()

print('Yes')

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

long long INF = 1e18;

int main(){
    ll a;
    cin >> a;
    ll ans = 0;
    ll cnt = 0;
    ll g = 0;
    cnt = a / 500;
    g = (a - (cnt * 500)) / 5;
    cout << (cnt * 1000) + (g * 5) << endl;
    return 0;
}


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

int main(){
  int N;
  std::string S, T, fusion;
  std::cin >> N;
  std::cin >> S >> T;
  

  for(int i = 0; i < N; i++){
    fusion = fusion + S[i] + T[i];
  }
  std::cout << fusion << std::endl;

  return 0;
}


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

int main(void) {
    int n, k;
    int result = 1;

    cin >> n >> k;

    for (int i = 0; i < n; i++) {
        if (i == 0) result = k;
        else result *= (k - 1);
    }

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <algorithm>

using namespace std;

int main(){
	int a1,a2,a3,a4,b1,b2,b3,b4,A=0,B=0;
	scanf("%d %d %d %d",&a1,&a2,&a3,&a4);
	scanf("%d %d %d %d",&b1,&b2,&b3,&b4);
	A = a1 + a2 + a3 + a4;
	B = b1 + b2 + b3 + b4;
	if(A > B){
		printf("%d\n",A);
	}else{
		printf("%d\n",B);
	}

    return 0;
}



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

int main(){    
    int n, a[200001], b[200001] = {0};
    cin >> n;
    for(int i=1;i<=n;i++) cin >> a[i];
    int m = 0;
    vector<int> ans;

    for(int i=n;i>0;i--){
        int cur = 0;
        for(int j=i*2;j<=n;j+=i) cur += b[j];
        if(a[i] == cur % 2) b[i] = 0;
        else{
            b[i] = 1;
            m++;
            ans.push_back(i);
        }
    }

    cout << m << endl;
    for(int i=0;i<m;i++) cout << ans[i] << " \n"[i==m-1];
    
    return 0;
}

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

const int64_t MOD = 1000000007;
typedef int64_t ll;
typedef uint64_t ull;

#define INF LLONG_MAX

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  ll n;
  cin >> n;

  string s;
  cin >> s;
  int count = 0;
  for(int i=1;i<n;i++){
    if(s[i]=='E') count++;
  }
  int minCount = count;
  for(int i=1;i<n;i++){
    if(s[i-1]=='W') count++;
    if(s[i]=='E') count--;
    minCount = min(minCount,count);
  }

  cout << minCount << endl;

 return 0;
}



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


using namespace std;

int main() {
    int n;
    cin >> n;
    int cnt = 0;
    for (int i = 1; i <= n; ++ i) {
        int x;
        cin >> x;
        if (i % 2 == 1 and x % 2 == 1) {
            cnt += 1;
        }
    }
    cout << cnt << '\n';
    return 0;
}

Measured memory_bytes: 3592
// 問題の URL を書いておく
// 

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <bitset>
#include <numeric>
#include <cmath>
#include <iomanip>
using namespace std;

//#define ENABLE_PRINT

template<typename T>
T Input()
{
    T v;
    cin >> v;
    return v;
}

template<typename T>
vector<T> InputVector(int n)
{
    vector<T> v(n);
    for(int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }
    return v;
}

template<typename T>
void InputArray(T* begin, int n)
{
    for(int i = 0; i < n; ++i)
    {
        cin >> begin[i];
    }
}

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

int main(int, const char**)
{
    uint64_t a;
    string b;
//    double b;
    cin >> a >> b;
    char c[4];
    int i = 0;
    for(int j = 0; j < b.size(); ++j)
    {
        if(b[j] != '.')
        {
            c[i++] = b[j];
        }
    }
    auto d = strtoll(c, nullptr, 10);
    //auto c = static_cast<uint64_t>(b * 100);
    cout << d * a / 100 << endl;

    return 0;
}


Measured memory_bytes: 3624
n = int(input())
l = [11,41,61,71,101,131,151,181,191,211,241,251,271,281,311,331,401,421,431,461,491,521,541,571,601,641,661,691,701,751,761,811,821,911,941,971,991,1031,1021,1051,1061,1091,1151,1201,1231,1171,1181,1291,1321,1381,1451,1481,1471,1361,1301]
print(*l[:n])

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

int main()
{
    string s;
    cin >> s;
    if (s[0] == 'A' or s[0] == 'B' or s[0] == 'C' or s[0] == 'D' or s[0] == 'E' or s[0] == 'F' or s[0] == 'G' or s[0] == 'H' or s[0] == 'I' or s[0] == 'J' or s[0] == 'K' or s[0] == 'L' or s[0] == 'M' or s[0] == 'N' or s[0] == 'O' or s[0] == 'P' or s[0] == 'Q' or s[0] == 'R' or s[0] == 'S' or s[0] == 'T' or s[0] == 'U' or s[0] == 'V' or s[0] == 'W' or s[0] == 'X' or s[0] == 'Y' or s[0] == 'Z')
    {
        cout << "A" << endl;
    }
    else
    {
        cout << "a" << endl;
    }
    return 0;
}


Measured memory_bytes: 3620
import java.util.*;

public class Main {
  public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int a = sc.nextInt();
    	int b = sc.nextInt();
    	int c = sc.nextInt();
    	if(b - a == c - b) {
          System.out.println("YES");
        } else {
          System.out.println("NO");
        }
  }
}

Measured memory_bytes: 21972
N, A, B = map(int, input().split())
if (A == 0):
    print('0')
elif (B == 0):
    print(N)
else:
    sum = A + B
    div = N // sum
    mod = N % sum
    plus = mod - A
    if (plus > 0):
        ans = div*A + A
        print(ans)
    else:
        ans = div*A + mod
        print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

int main(void){
	string S;
	cin >> S;
	ll ans = 0;
	ll p = 0;
	for(int i=0;i<S.size();i++){
		if(S[i]=='W'){
			ans += i-p;
			p++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<deque>


#define REP(i,a,b) for(int i = (a); i < b; ++i)
#define inf 1e9+10
#define MOD 1000000007

using ll = long long;
using namespace std;

int main() {
	ll a, b, c, d;

	cin >> a >> b >> c >> d;

	ll s1,s2,s3,s4;

	ll result;

	s1 = a * c;
	s2 = a * d;
	s3 = b * c;
	s4 = b * d;
	
	s1 = max(s1, s2);
	s3 = max(s3, s4);

	result = max(s1, s3);


	cout << result;

	return 0;
}

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

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

  int cnt = 0, good = 0;
  int n;
  cin >> n;

  for (int i = 0; i < n; ++i) {
    int a, b;
    cin >> a >> b;

    if (a == b) ++cnt;
    else cnt = 0;

    if (cnt >= 3) good = 1;
  }

  if (good) cout << "Yes\n";
  else cout << "No\n";
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
//#define int long long
typedef pair<int,int> ii;
typedef tuple<int,int,int> iii;
#define ll long long
#define iiMPQ priority_queue<ii,vector<ii>,greater<ii> >
#define MPQ priority_queue<int,vector<int>,greater<int> >
#define PQ priority_queue<int>
#define iiPQ priority_queue<ii>
#define US unordered_set<int>
#define UMS unordered_multiset<int>
#define UM unordered_map<int>
#define ST stack<int>
#define MS multiset<int>
#define scan(n) cin>>n
#define scann(a,b) cin>>a>>b
#define scannn(a,b,c) cin>>a>>b>>c
#define print(n) cout<<n
#define println(n) cout<<n<<"\n"
#define first fi
#define second se
#define REP(i,n) for(int i=0;i<n;++i)
 
void m1(){
  char c;
  scan(c);
  if(isupper(c)) print('A');
  else print('a');
}
/* 
void m2(){
  int t; scan(t);
  while(t--) m1();
}
*/
 
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  //freopen("in.txt","r",stdin);
  m1();
  //m2();
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define gcd(m,n) __gcd(m,n)
#define lcm(m,n) m*(n/gcd(m,n))
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)
#define endl '\n'
#define MOD 1000000007
#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define dbg(x) cout << #x << "  " << x << endl;
 
ll power(ll base, ll exp) 
{ll res=1;while(exp>0) {if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return res;}
ll mod(ll a, ll b) {return (a % b + b) % b;}
using namespace std;

int main()
{
	fast;
	ll h,w;
  	cin >> h >> w;
  	if (h % 3 == 0 || w % 3 == 0)
  	{
    	cout << 0 << endl;
  	}
  	else
  	{
    	ll ans = INT_MAX;
    	for (ll i = 1; i < h; i++)
    	{
      		ll x1 = i*w;
      		ll x2 = (h - i) * (w / 2);
      		ll x3 = (h - i) * (w - w / 2);
      		ll y2 = (h - i) / 2 * w;
      		ll y3 = ((h - i) - (h - i) / 2) * w;
      		ans = min(ans, max(x1, max(x3, x2)) - min(x1, min(x3, x2)));
      		ans = min(ans, max(x1, max(y3, y2)) - min(x1, min(y3, y2)));
    	}
	    for (ll i = 1; i < w; i++)
	    {
	      	ll x1 = i * h;
	      	ll x2 = (w - i) * (h / 2);
	      	ll x3 = (w - i) * (h - h / 2);
	     	ll y2 = (w - i) / 2 * h;
	      	ll y3 = ((w - i) - (w - i) / 2) * h;
	      	ans = min(ans, max(x1, max(x3, x2)) - min(x1, min(x3, x2)));
	      	ans = min(ans, max(x1, max(y3, y2)) - min(x1, min(y3, y2)));
	    }
	    cout << ans << endl;
  	}
	return 0;
}

Measured memory_bytes: 256
from collections import deque
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [ai - bi for ai, bi in zip(a, b)]
if sum(c) < 0:
    print(-1)
    exit()
c.sort()
minus = deque()
for ci in c:
    if ci >= 0:
        break
    minus.append(ci)
ans = len(minus)
s = sum(minus) * (-1)
plus = 0
idx = -1
while s > plus:
    plus += c[idx]
    ans += 1
    idx -= 1
print(ans)

Measured memory_bytes: 18668
#include <bits/stdc++.h>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;
const ll Lmax=ll(1e18);
const ll Nmax=1e9;
const ll INF=1e9;

int main(){
  int n;
  cin>>n;
  map<string,int> count;
  rep(i,n){
    string s;
    cin>>s;
    count[s]++;
  }

  cout<<"AC x "<<count["AC"]<<endl;
  cout<<"WA x "<<count["WA"]<<endl;
  cout<<"TLE x "<<count["TLE"]<<endl;
  cout<<"RE x "<<count["RE"]<<endl;


}


Measured memory_bytes: 3636
n, x = map(int, input().split())
L = []
while n != 0 or x != 0:
    L.append([n, x])
    n, x = map(int, input().split())
for i in range(len(L)):
    A = []
    for a in range(1, L[i][0] - 1):
        for b in range(2, L[i][0]):
            for c in range(3, L[i][0] + 1):
                if a < b < c and a + b + c == L[i][1]:
                    A.append([a, b, c])
    print(len(A))


Measured memory_bytes: 5600
import java.util.*;

public class Main {

	public static void main (String[] args)  {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				int x;
				if (j < a ^ i < b) {
					x = 1;
				} else {
					x = 0;
				}
				sb.append(x);
			}
			sb.append("\n");
		}
		System.out.print(sb);
	}
}


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

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int N;
    cin >> N;
    int div4 = 0;
    int div2 = 0;
    for (int i = 0; i < N; i++) {
        int A;
        cin >> A;
        if (A % 4 == 0) div4++;
        else if (A % 2 == 0) div2++;
    }
    int div1 = N - div2 - div4;
    if (div2 > 0) div1 ++;
    bool ok = div4 + 1 >= div1;
    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
import math
def gcd(a, b):
    if a > b:
        a, b = b, a
    if a == 0:
        return b
    else:
        return gcd(a, b % a)

# N = int(input())
A, B = [int(_) for _ in input().split()]

gcd_ab = gcd(A, B)
cds = []
for k in range(1, math.ceil(math.sqrt(gcd_ab)) + 1):
    if gcd_ab % k == 0:
        cds.append(k)
        cds.append(gcd_ab // k)
cds = list(set(cds))
cds.sort()

ans = []
for cd in cds[1:]:
    for a in ans:
        if cd % a == 0:
            break
    else:
        ans.append(cd)

print(len(ans) + 1)


Measured memory_bytes: 40668
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

ifstream in("data.txt");
ofstream out("result.txt");

int main(int argc, const char * argv[]) {
    // insert code here...
    int n, temp;
    vector < int > a;
    cin >> n;
    
    for (int i = 0; i < n; i++){
        cin >> temp;
        a.push_back(temp);
    }
    
    sort(a.begin(), a.end(), greater<int>());
    unsigned long long alice = 0,bob = 0;
    
    for(unsigned long i = 0; i < a.size(); i++){
        if (i % 2 == 0) alice += a[i];
        else bob += a[i];
    }
    cout << alice - bob << endl;
    return 0;
}


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

int n ;

pair < int , int > a[100010], b[100010] ;

int main(){
	#define NAME ""
	//freopen( NAME".inp" , "r" , stdin ) ; freopen( NAME".out" , "w" , stdout ) ;

	ios_base :: sync_with_stdio(false) ;

	cin >> n ;

	for (int i = 1; i <= 100000; ++ i) a[i].second = b[i].second = i ;

	for (int i = 1; i <= n; ++ i){
		int x ; cin >> x ;
		if(i % 2) a[x].first ++ ;
		else b[x].first ++ ; 
	}

	sort(a + 1, a + 100000 + 1) ; sort(b + 1, b + 100000 + 1) ;	

	reverse(a + 1, a + 100001) ; reverse(b + 1, b + 100001) ;

	int ans = 0 ;

	if(a[1].second == b[1].second) ans = max(a[1].first + b[2].first, a[2].first + b[1].first) ;
	else ans = a[1].first + b[1].first ;

	cout << n - ans << endl ;

	return 0 ;
}

Measured memory_bytes: 1792
h,w = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(h)]
n = 0
ans = []
for i in range(h):
    for j in range(w):
        if a[i][j]%2==0:continue
        if j<w-1:
            a[i][j] -= 1
            a[i][j+1] += 1
            n += 1
            ans.append([i+1,j+1,i+1,j+2])
        elif i<h-1:
            a[i][j] -= 1
            a[i+1][j] += 1
            n += 1
            ans.append([i+1,j+1,i+2,j+1])
print(n)
for i in ans:
    print(*i)


Measured memory_bytes: 32384
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-03-29 20:41:02
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<(x)>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

LL modpower(LL n, LL m, LL mod) {
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod) {
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod) {
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

ostringstream oss_global;
string s_global = oss_global.str();

int main()
{
    int H, W, h, w;
    cin >> H >> W >> h >> w;

    int ans = H*W - h*W - H*w + h*w;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
	int a[3];
	int x=0,y=0;
	for(int i=0;i<3;i++)
	{
		cin >> a[i];
		if(a[i]==5) x++;
		if(a[i]==7) y++;
	}
	if(x==2&&y==1) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const int nmax = 8;
bool graph[nmax][nmax];
const int INF = 1e9;
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
 
ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}
 
ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

int dfs(int v, ll N, bool visited[nmax])
{
    bool all_visited = true;
 
    for (int i = 0; i < N; i++)
    {
        if (!visited[i])
        {
            all_visited = false;
        }
    }
 
    if (all_visited)
    {
        return 1;
    }
    int ret = 0;
    for (size_t i = 0; i < N; i++)
    {
        if (!graph[v][i])
        {
            continue;
        }
        if (visited[i])
        {
            continue;
        }
 
        visited[i] = true;
        ret += dfs(i, N, visited);
        visited[i] = false;
    }
 
    return ret;
}

void solve(long long A, long long B, long long C){
    cout << min(C,B/A) << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    solve(A, B, C);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
const int MAX = 1000000;
typedef pair<int,int> P;
int main(){
	int N,M,S,T,u,v;
	vector<int> vec[300000];
	int ans[300000];
	priority_queue<P,vector<P>,greater<P>> que;
	P p;
	cin>>N>>M;
	for(int i=0;i<M;i++){
		cin>>u>>v;u--;v--;
		vec[u].push_back(v+N);
		vec[u+N].push_back(v+2*N);
		vec[u+2*N].push_back(v);
	}
	fill(ans,ans+3*N,MAX);
	cin>>S>>T;S--;T--;
	ans[S]=0;
	que.push(P(0,S));
	while(!que.empty()){
		p = que.top();
		que.pop();
		for(int i:vec[p.second]){
			if(ans[i]>ans[p.second]+1){
				ans[i]=ans[p.second]+1;
				que.push(P(ans[i],i));
			}
		}
	}
	
	if(ans[T]<MAX)cout<<ans[T]/3;
	else cout<<-1;
	return 0;
}

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

#define MAX 100000
int n, k;
long long T[MAX];

//最大容量Pのときk台のトラックで何個詰めるか。
int check(long long P){
    int i=0;
    for(int j=0; j<k; ++j){
        long long s = 0;
        while( s + T[i] <=P){
            s += T[i];
            i++;
            if( i==n )
                return n;
        }

    }
    return i;
}

int solve(){
    long long left = 0;
    long long right = 100000*10000;
    long long mid;
    while ( right - left > 1){
        mid = (left + right)/2;
        int v = check(mid);
        if( v>=n )
            right = mid;
        else
            left = mid;
    }

    return right;
}

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

    long long ans = 0;
    ans = solve();

    cout << ans << endl;

}



Measured memory_bytes: 3872
#include <bits/stdc++.h>
#define io() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); srand(time(NULL));
 
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

signed main(){
    io();
    int n, k; cin >> n >> k;
    vector<int> v(n);
    int og = 0;
    for(int i = 0; i < n; ++i){
        v[i] = k + i;
        og += v[i];
    }   
    int index = 0;
    int maxi = INT_MAX;
    for(int i = 0; i < n; ++i){
        int dif = og - v[i];
        int dist = abs(og - dif);
        if(maxi > dist){
            maxi = dist;
            index = i;
        }
    }
    cout << og - v[index] << '\n';
    return 0;  
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
//Remove below header file if c++ version greater than 14
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
using namespace std;
#define ll long long int
#define pb push_back
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define endl '\n'
#define deb(x) cout << #x << " "<< x << endl;
#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)

const int inf = -1000;
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a /gcd(a, b) *b;
}

int main() {

   int n;
   cin>>n;

   int arr[n];

   fo(i,n)
       cin>>arr[i];

    int s1 = accumulate(arr,arr+n,0);
    int s2  = 0;
    int minn = INT_MAX;
    fo(i,n)
        {

            s1-=arr[i];
            s2+=arr[i];
            minn = min(minn,abs(s2-s1));
        }


        cout<<minn;


























    return 0;

      }


Measured memory_bytes: 256
<?php

$conv = array_merge(
  array_combine(range("a", "z"), range("A", "Z")),
  array_combine(range("A", "Z"), range("a", "z"))
);

$input = trim(fgets(STDIN));
$data_size = strlen($input);

for ($i=0; $i<$data_size; $i++) {
  if (in_array($input[$i], $conv)) {
    echo $conv[$input[$i]];
  } else {
    echo $input[$i];
  }
}
echo PHP_EOL;

Measured memory_bytes: 15420