akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int inf=1e9,mod=1e9+7;
typedef long long ll;
int read() {
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9') f=(c=='-')?-1:1,c=getchar();
	while(c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}
int a[100001],b[100001],n;
int pd() {
	for(int i=1; i<=n; i++)
		if(a[i]!=b[i]) return 0;
	return 1;
}
main() {
	n=read();
	for(int i=1; i<=n; i++)
		b[i]=a[i]=read();
	sort(a+1,a+1+n);
	if(pd()) puts("YES"),exit(0);
	for(int i=1; i<=n; i++)
		for(int j=1; j<i; j++) {
			swap(a[i],a[j]);
			if(pd()) puts("YES"),exit(0);
			swap(a[i],a[j]);
		}
	puts("NO");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define vector2(a,b,c) vector<vector<int>> a(b/*縦！w*/,vector<int>(c/*横！w*/))
#define INF 1e10
#define MOD 1e9+7
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;
signed main(){
  vector<char> a(3);
  rep(i,3)
    cin>>a[i];
  int b=0;
  rep(i,3){
    if(a[i]=='o')
      b++;
      }
  cout<<700+b*100<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
	int moji[26] = {0},len,i,j,num;
	char str;
	while(scanf("%c",&str) != EOF){
		if(str>='A' && str<='Z'){
			str += 0x20;
		}
		if(str>='a' && str<='z'){
			num = str - '0';
			j = num - 49;
			moji[j]++;
		}
	}
	for(i=0;i<26;i++){
		printf("%c : %d\n",i+97,moji[i]);
	}
	return 0;
}

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

int main(){
	int a, N,i,count=1;
	cin >> N;
	vector<int> v;
	for (i = 0; i < N; i++) {
		cin >> a;
		v.push_back(a);
	}
	sort(v.begin(), v.end());
	a = v[0];
	for(i=0;i<N;i++){
		if (a != v[i]) { count++; a = v[i]; }
	}
	cout << count;
	return 0;
}

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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    int a, b;
    cin >> a >> b;
    if(a*b%2) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define rsort(x) sort(all(x));reverse(all(x))
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
 
bool debug=false;
/*---------------------------------------------------*/

int main(){
  int n,k;
  int ans=0;
  int x;
  cin>>n>>k;
  rep(i,n){
    cin>>x;
    ans+=min(x*2,(k-x)*2);
  }
  cout<<ans<<endl;
  return 0;
}


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

int main(int argc, char const *argv[])
{
    string s;
    cin >> s;
    int ans = 0;
    int tmp = 0;
    for(int i = 0; i < s.length(); i++) {
        if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
            tmp++;
            ans = max(ans, tmp);
        } else {
            tmp = 0;
        }
    }

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


Measured memory_bytes: 256
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(Math.abs(a-b) >= 2) {
			if(a > b)	System.out.println(a+(a-1));
			else	System.out.println(b+(b-1));
		}else {
			System.out.println(Math.max(a, b)+Math.min(a, b));
		}

	}

}


Measured memory_bytes: 23764
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n; cin>>n;
    cout<<(n-2)*180<<endl;
}


Measured memory_bytes: 3620
#include <iostream>

using namespace std;

int main(void) {
    int64_t H, W;
    cin >> H >> W;
    if(H == 1 || W == 1) {
        cout << 1 << endl;
    } else {
        cout << (H*W+1)/2 << endl;
    }
    return 0;
}


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

using namespace std;

using LL = long long;

void solver() {
    int N; LL D;
    cin >> N >> D;

    D = D * D;

    int ans = 0;

    while(N--) {
        LL x, y;
        cin >> x >> y;
        ans += (x * x + y * y <= D);
    }

    cout << ans << '\n';
}

int main() {

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

    int t;
    //cin >> t;
    t = 1;

    while(t--)
        solver();

    return 0;
}

Measured memory_bytes: 3652
package main

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

var (
	n   int
	sum int
	tmp int
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	n = intOfString(sc.Text())
	ss := make([]int, 0, n)

	for sc.Scan() {
		tmp = intOfString(sc.Text())
		sum += tmp
		ss = append(ss, tmp)
	}

	if sum%10 == 0 {
		min := findMin(ss)
		if min == 101 {
			sum = 0
		} else {
			sum -= min
		}
	}

	fmt.Println(sum)
}

func intOfString(s string) int {
	x, _ := strconv.Atoi(s)
	return x
}

func findMin(ls []int) int {
	tmp := 101
	for _, v := range ls {
		if v%10 != 0 && v < tmp {
			tmp = v
		}
	}

	return tmp
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(){
int x=0,temp=0,N;
string s;
cin>>N>>s;
for(int i=0; i<N;i++)
{
if(s[i]=='I')
{
x+=1;
if(x>temp)
{
temp=x;
}
}
if(s[i]=='D')
{
x-=1;
if(x>temp)
{
temp=x;
}
}}
cout<<temp;
return 0;
}

Measured memory_bytes: 256
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*
    I LOVE CLARICE STARLING

     ♥LOVE♥        ♥LOVE♥
  ♥LOVE♥♥LOVE♥  ♥LOVE♥♥LOVE♥
♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥
   ♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥
      ♥LOVE♥♥LOVE♥♥LOVE♥
         ♥LOVE♥♥LOVE♥
            ♥LOVE♥
               ♥


        EXPLAINATION BELOW->
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
void solve()
{
    ll n,m,i;cin>>n>>m;
    ll A[m];
    fo(i,0,m)cin>>A[i];
    sort(A,A+m);
    
    fo(i,0,m)
    {
        n-=A[i];
        if(n<0){cout<<"-1\n";return;}
    }
    cout<<n<<"\n";
}
int main()
{
   fastio
   solve();
  return 0;
}
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/

Measured memory_bytes: 3736
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(void)
{
    int a, b, c;
    cin >> a >> b >> c;
    int x = a + b + c, y = max(a, b);
    y = max(y, c);
    if(x%2==y%2){
        cout << (3 * y - x) / 2;
    }
    else
        cout << (3 * y - x) / 2 + 2;
    return 0;
}

Measured memory_bytes: 256
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import permutations,combinations
from collections import defaultdict,Counter
from pprint import pprint

def myinput():
    return map(int,input().split())

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col):
    data.sort(key=lambda x:x[col],reverse=False)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

n = int(input())
ab = mylistinput(n-1)

g = [ [] for _ in range(n) ]
for i in range(n-1):
    a = ab[i][0] - 1
    b = ab[i][1] - 1
    g[a].append(b)
    g[b].append(a)
# print(g)

color = [-1] * n

def bfs(g):
    used_color = [ [-1] ]*n
    q = deque()
    q.append([0,0])
    while q:
        tmp = q.popleft()
        v = tmp[0]
        c = tmp[1]
        color[v] = c
        ls_nc = list(reversed(list(range(1,len(g[v])+1))))
        if c==0:
            pass
        elif c in ls_nc:
            ls_nc.remove(c)
        else:
            pass
        for nv in g[v]:
            if color[nv]!=-1:
                pass
            else:
                nc = ls_nc.pop()
                q.append([nv,nc])
    return True

if bfs(g):
    print(max(color))
    for i in range(n-1):
        b = ab[i][1] - 1
        print(color[b])
else:
    print("Error")

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

int main()
{

  int S;
  int h,m,s;
  int temp;
  cin >> S;
  h = S / 3600;

  temp = S - (h * 3600);

  m = temp / 60;

  s = temp - (m * 60);

  cout << h << ":" << m << ":" << s << endl;

  return 0;
}

Measured memory_bytes: 1168
#AGC015 A - A+...+B Problem
n,a,b = map(int,input().split())
ans = 0
if n==1:
    if a==b:
        ans=1
    else:
        ans=0
else:
    if b>a:
        num_min = (n-2)*a+a+b
        num_max = (n-2)*b+a+b
        ans = num_max-num_min+1
    elif b<a:
        ans=0
    elif a==b:
        ans=1
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	cin >> n;
	
	vector<double> a(n);
	double sum = 0.0;
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
		sum += 1.0 / a[i];
	}
	
	printf("%.10f\n", 1.0 / sum);

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define SZ(x) ((int)(x).size())
#define MEM(x,a) memset(x,a,sizeof(x))
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
const ll mod=1000000007,N=1e5+5,M=1e5+5,INF=0x3f3f3f3f;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
//head
char s[110];
bool check(int l,int r){
    while(l<r){
        if(s[l]!=s[r])return 0;
        ++l;--r;
    }
    return 1;
}
int main(void){
    cin>>s+1;
    int n=strlen(s+1);
    cout<<(check(1,n)&&check(1,(n-1)/2)&&check((n+3)/2,n)?"Yes":"No");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll one = 1;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    ll N, K;
    cin >> N >> K;
    vector<ll> inv(500000); inv[1] = 1;
    for (int i = 2; i < 500000; i++) {
        inv[i] = MOD - (MOD / i) * inv[MOD % i] % MOD;
    }   
    vector<ll> fact(500000);
    fact[0] = 1; fact[1] = 1;
    for (int i = 2; i < 500000; i++) {
        fact[i] = fact[i-1] * i % MOD;
    }   
    vector<ll> invfact(500000);
    invfact[0] = 1; invfact[1] = 1;
    for (int i = 2; i < 500000; i++) {
        invfact[i] = invfact[i-1] * inv[i] % MOD;
    }  
    ll ans; 
    if(K >= N - 1){
        ans = fact[2 * N - 1] * invfact[N-1] % MOD;
        ans = ans * invfact[N] % MOD;
    }
    else{
        ll tmp;
        ans = 0;
        for (ll i = 0; i < K+1; i++) {
            tmp = fact[N] * fact[N-1] % MOD;
            tmp = tmp * invfact[N-i-1] % MOD;
            tmp = tmp * invfact[N - i] % MOD;
            tmp = tmp * invfact[i] % MOD;
            tmp = tmp * invfact[i] % MOD;
            ans = (ans + tmp) % MOD;
        }
    }
    printf("%lld\n", ans);

}

Measured memory_bytes: 15260
#include <iostream>
#include <string>
 
using namespace std;
 
int main(){
	int n;
	cin >> n;
	int a[4] = {0, 0, 0, 0};
	for(int i=0;i<n;i++){
		string s;
		cin >> s;
		if(s == "AC"){
			a[0] ++;
		} else if(s == "WA"){
			a[1] ++;
		} else if(s == "TLE"){
			a[2] ++;
		} else if(s == "RE"){
			a[3] ++;
		}
	}
	printf("AC x %d\n", a[0]);
	printf("WA x %d\n", a[1]);
	printf("TLE x %d\n", a[2]);
	printf("RE x %d\n", a[3]);
}

Measured memory_bytes: 3708
N, M = list(map(int, input().split()))

L_list = []
R_list = []

for i in range(M):
    L, R = list(map(int, input().split()))
    L_list.append(L)
    R_list.append(R)
    
ans = max(min(R_list) - max(L_list) + 1, 0)

print(ans)

Measured memory_bytes: 11048
import std.stdio, std.string, std.conv, std.array, std.algorithm;
import std.uni, std.range, std.math, std.container, std.datetime;
import core.bitop, std.typetuple, std.typecons;

immutable long MOD = 1_000_000_007;
alias tie = TypeTuple;
alias triplet = Tuple!(int, int, int);

void main(){
    int N, M, a, b;
    readVars(N, M);

    auto ncnt = new int[](N);

    foreach(i ; 0 .. M){
        readVars(a, b);
        a--; b--;
        ncnt[a]++;
        ncnt[b]++;
    }

    foreach(i ; 0 .. N){
        if (ncnt[i] & 1) {
            writeln("NO");
            return;
        }
    }

    writeln("YES");
}


void readVars(T...)(auto ref T args){
    auto line = readln.split;
    foreach(ref arg ; args){
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    if(!line.empty){
        throw new Exception("args num < input num");
    }
}

Measured memory_bytes: 3580
#include <bits/stdc++.h> //library
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //for-loop (from 0)
#define reps(i,n) for(int i = 1; i <= (int)(n); i++) //for-loop (from 1)
#define all(x) (x).begin(),(x).end() //start-to-end iteration, mainly in upper_bound, lower_bound
#define SZ(x) ((int)(x).size()) //unsigned to signed

using namespace std;
using ll = long long; //long long
ll M = 1000000000 + 7;
const ll INF = 1LL << 60;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; } //compare a,b and replace by greater
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; } //compare a,b and replace by smaller
ll qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; } //power
ll qp(int a, ll b, ll Mod) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%Mod; a = 1ll * a*a%Mod; } while (b >>= 1); return ans; } //power(mod)
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; } //gcd
int dx[4] = { 1,0,-1,0 }; //path
int dy[4] = { 0,1,0,-1 }; //path
ll RS(ll N, ll P) { if (P == 0)return 1; else if (P % 2 == 0) { ll sq = RS(N, P / 2); return sq*sq; } else { return N*RS(N, P - 1); } } //power(repeat-square,fast)
ll nPr(ll n, ll r) { ll ans = 1; rep(i, r) { ans = ans * (n - i); } return ans; } //permutation
ll nCr(ll n, ll r) { ll bunbo = 1; ll bunshi = 1; rep(i, r) { bunbo = bunbo * (i + 1); bunshi = bunshi * (n - i); } return bunshi / bunbo; } //combination
ll RS(ll N, ll P, ll Mod) { if (P == 0)return 1; else if (P % 2 == 0) { ll sq = RS(N, P / 2, Mod); return sq*sq%Mod; } else { return N*RS(N, P - 1, Mod) % Mod; } } //power(mod)(repeat-square,fast)
ll nPr(ll n, ll r, ll Mod) { ll ans = 1; rep(i, r) { ans = ans * (n - i) % Mod; } return ans; } //permutation
ll nCr(ll n, ll r, ll Mod) { ll bunbo = 1; ll bunshi = 1; rep(i, r) { bunbo = bunbo * (i + 1) % Mod; bunshi = bunshi * (n - i) % Mod; } return bunshi * RS(bunbo, Mod - 2, Mod) % Mod; } //combination

int main(void) {
  int N; cin >> N;
  if ( N <= 999) cout << "ABC" << "\n";
  else cout << "ABD" << "\n";
  return 0;
}


Measured memory_bytes: 256
w, h, x, y = gets.chomp.split(" ").map(&:to_i)

m = [w*0.5, h*0.5]
d = w*h*0.5

if x == m[0] && y == m[1]
  puts sprintf("%.6f 1", d)
else
  puts sprintf("%.6f 0", d)
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

struct Point {
  __int128_t x, y;
};

__int128_t cross(Point p1, Point p2) {
  return p1.x * p2.y - p2.x * p1.y;
}

bool cmp(Point p1, Point p2) {
  return cross(p1, p2) > 0;
}

ll pow2[200200];

void init() {
  pow2[0] = 1;
  rep(i, 200200 - 1) {
    pow2[i + 1] = pow2[i] * 2 % mod;
  }
}

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

  init();

  ll n;
  cin >> n;
  vector<Point> p[2];
  ll ans = 0;
  rep(i, n) {
    Point a;
    ll x, y;
    cin >> x >> y;
    a = {x, y};
    if (a.x == 0 && a.y == 0) {
      ans++;
      continue;
    }
    if (a.x > 0 && a.y >= 0) p[0].push_back(a);
    else if (a.x <= 0 && a.y > 0) {
      a.x *= -1;
      swap(a.x, a.y);
      p[1].push_back(a);
    }
    else if (a.x < 0 && a.y <= 0) {
      a.x *= -1;
      a.y *= -1;
      p[0].push_back(a);
    }
    else {
      a.y *= -1;
      swap(a.x, a.y);
      p[1].push_back(a);
    }
  }
  rep(i, 2) sort(p[i].begin(), p[i].end(), cmp);
  vector<int> siz(2);
  rep(i, 2) siz[i] = p[i].size();
  vector<int> idx(2, 0);
  ll res = 1;
  vector<int> cnt(2, 1);
  while (idx[0] < siz[0] && idx[1] < siz[1]) {
    rep(i, 2) {
      while (idx[i] + 1 < siz[i] && cross(p[i][idx[i]], p[i][idx[i] + 1]) == 0) {
        cnt[i]++;
        idx[i]++;
      }
    }
    if (cross(p[0][idx[0]], p[1][idx[1]]) == 0) {
      res = res * ((pow2[cnt[0]] + pow2[cnt[1]] - 1) % mod) % mod;
      idx[0]++, idx[1]++;
      cnt[0] = 1, cnt[1] = 1;
    }
    else if (cross(p[0][idx[0]], p[1][idx[1]]) > 0) {
      res = res * pow2[cnt[0]] % mod;
      idx[0]++;
      cnt[0] = 1;
    }
    else {
      res = res * pow2[cnt[1]] % mod;
      idx[1]++;
      cnt[1] = 1;
    }
  }
  rep(i, 2) {
    while (idx[i] < siz[i]) {
      res = res * 2 % mod;
      idx[i]++;
    }
  }
  res = (res - 1 + mod) % mod;
  ans = (ans + res) % mod;
  cout << ans << '\n';







  
  return 0;
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n, W;
    cin >> n >> W;
    ll w,v;
    cin >> w >> v;
    vector<vector<ll>> tmpv(4);
    tmpv.at(0).push_back(v);
    for(i = 1;i < n;++i){
        ll tw;
        cin >> tw >> v;
        tmpv.at(tw-w).push_back(v);
    }
    for(i = 0;i < 4;++i){
        sort(all(tmpv.at(i)), greater<ll>());
    }
    ll k,l;
    ll ans = 0;
    for(i = 0;i <= tmpv.at(0).size();++i){
        rep(j, tmpv.at(1).size()+1){
            rep(k, tmpv.at(2).size()+1){
                rep(l, tmpv.at(3).size()+1){
                    ll ti,tj,tk,tl;
                    ll sumw = 0;
                    ll sumv = 0;
                    sumw += i*w + j*(w+1) + k*(w+2) + l*(w+3);
                    if(sumw > W) continue;
                    rep(ti, i){
                        sumv += tmpv.at(0).at(ti);
                    }
                    rep(tj, j){
                        sumv += tmpv.at(1).at(tj);
                    }
                    rep(tk, k){
                        sumv += tmpv.at(2).at(tk);
                    }
                    rep(tl, l){
                        sumv += tmpv.at(3).at(tl);
                    }
                    ans = max(ans, sumv);
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}

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

sou = sum(As)
th = sou/4/m
count = 0
for e in As:
  if e >= th:
    count += 1
    if count == m:
      print('Yes')
      break
if count < m:
  print('No')


Measured memory_bytes: 3060
def main():
    from collections import deque

    h,w = map(int,input().split())
    A = []
    for i in range(h):
        A += list(input())

    queue = deque([])
    Distance = [-1]*(h*w)

    for i in range(h):
        for j in range(w):
            if A[i*w+j]=='#':
                queue.append([i,j])
                Distance[i*w+j] = 0

    ans = 0

    while queue:
        x,y = queue.popleft()
        d = Distance[x*w+y]
        if x!=0 and Distance[(x-1)*w+y] == -1:
                queue.append([x-1,y])
                ans = Distance[(x-1)*w+y] = d+1
        if x!=h-1 and Distance[(x+1)*w+y] == -1:
                queue.append([x+1,y])
                ans = Distance[(x+1)*w+y] = d+1
        if y!=0 and Distance[x*w+y-1] == -1:
                queue.append([x,y-1])
                ans = Distance[x*w+y-1] = d+1
        if y!=w-1 and Distance[x*w+y+1] == -1:
                queue.append([x,y+1])
                ans = Distance[x*w+y+1] = d+1

    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 179608
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin>>n;
  unordered_map<int,int> v1,v2;
  int a;
  for(int i=0;i<n;i++){
    cin>>a;
  	if(i%2==0){
    	if(v1.find(a)!=v1.end()){v1[a]++;}
      	else{v1[a]=1;}
    }else{
    	if(v2.find(a)!=v2.end()){v2[a]++;}
      	else{v2[a]=1;}
    }
  }
  a=0;
  int ans,x1,x2,x3,x4;
  for(auto i=v1.begin();i!=v1.end();++i){
  	if((i->second)>a){
      a=i->second;
      x1=i->first;
    }
  }
  ans=n/2-a;
  a=0;
  for(auto i=v2.begin();i!=v2.end();++i){
  	if((i->second)>a){
      a=i->second;
      x2=i->first;
    }
  }
  ans+=n/2-a;
  if(ans==0&&x1==x2){ans=n/2;}
  else if(x1==x2){
    a=0;
    for(auto i=v1.begin();i!=v1.end();++i){
      if((i->second)>a&&i->first!=x1){
        a=i->second;
        x3=i->first;
      }
    }
    a=0;
    for(auto i=v2.begin();i!=v2.end();++i){
      if((i->second)>a&&i->first!=x2){
        a=i->second;
        x4=i->first;
      }
    }
    if(v1[x3]+v2[x2]>v2[x4]+v1[x1]){
      ans=n-v1[x3]-v2[x2];
    }else{
      ans=n-v1[x1]-v2[x4];
    }
  }
  cout<<ans<<endl;
  
}

Measured memory_bytes: 4376
counts, numbers, plus = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]

counter = 0
for i in range(counts):
    a = [int(j) for j in input().split()]
    c = 0
    for k in range(numbers):
        c += a[k] * b[k]
    if c + plus > 0:
        counter += 1

print(counter)

Measured memory_bytes: 3060
import scala.io.StdIn.{readLine,readInt}

object Main extends App {

  def exec(w:String):Unit =  {
    val len = w.length

    def shuffle(i:Int, cnt:Int):String =
      if(i == 0) (w drop (cnt%len))+(w take (cnt%len)) else shuffle(i-1, cnt+readInt)

    if(w=="-") return else { println(shuffle(readInt, 0));exec(readLine) }
  }
  exec(readLine)
}

Measured memory_bytes: 43672
#include<bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define mat vector<vec>

using namespace std;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

int main(){

  ll x,k,d;
  cin >> x >> k >>d;
  x=abs(x);

  ll ans=0;
  if(x/d-k>=0)ans=x-k*d;
  else{
    ll a=x/d;
    ll b=x%d;
    if(k%2==a%2){
      ans = b;
    }
    else ans=d-b;
  }
  cout << ans << endl;


}

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

int INF=0x3f3f3f3f;


int main(){
	ios_base::sync_with_stdio(false);
	int n,m,k;
	cin>>n>>m>>k;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=m;j++){
			if((i*m+j*n-2*i*j)==k) {cout<<"Yes"<<endl;return 0;}
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

char map[60][60], v[60][60];
int H, W;
int dr[]={-1, 0, 1, 0}, dc[]={0, -1, 0, 1};

int dfs(int r, int c, int k)
{
    int i;
    char *t=&v[r][c];
    *t|=k;
    for(i=0;i<4;++i) {
        int nr=r+dr[i];
        int nc=c+dc[i];
        if (nr<0 || nr>=H || nc<0 || nc>=W)
            *t|=4;
        else if (map[nr][nc]=='B')
            *t|=1;
        else if (map[nr][nc]=='W')
            *t|=2;
    }
    for(i=0;i<4;++i) {
        int nr=r+dr[i];
        int nc=c+dc[i];
        if (nr<0 || nr>=H || nc<0 || nc>=W) continue;
        if (map[nr][nc]!='.' || (*t&v[nr][nc])==*t) continue;
        dfs(nr, nc, *t);
    }
}

int main(void)
{
    while (scanf("%d%d", &W, &H), W) {
        int r, c, b, w;
        memset(map, 0, sizeof(map));
        memset(v, 0, sizeof(v));
        b=w=0;
        for(r=0;r<H;++r) scanf("%s", map[r]);

        for(r=0;r<H;++r) for(c=0;c<W;++c) {
            if (!v[r][c] && map[r][c]=='.') dfs(r, c, 0);
        }
        for(r=0;r<H;++r) for(c=0;c<W;++c) {
            b+=(v[r][c]==1 || v[r][c]==5);
            w+=(v[r][c]==2 || v[r][c]==6);
        }
        printf("%d %d\n", b, w);
    }
    return 0;
}

Measured memory_bytes: 760
import java.io.*;
import java.lang.*;
import java.util.*;
public class Main{
    public static long sumGCD(long[] arr){
        long max=0;
        for(int i=0;i<arr.length;i++)
            if(arr[i]>max) max=arr[i];
        long[] c=new long[(int)max+1];
        long[] d=new long[(int)max+1];
        long[] e=new long[(int)max+1];
        for(int i=0;i<arr.length;i++) c[(int)arr[i]]++;
        for(int i=1;i<=max;i++){
            for(int j=i;j<=max;j+=i) d[i]+=c[j];
        }
        for(int i=(int)max;i>=1;i--){
            e[i] = d[i]*d[i]*d[i];
            for(int j=2*i;j<=max;j+=i) e[i] -= e[j];
        }
        long sum=0;
        for(int i=1;i<=max;i++) sum+=(i*e[i]);
        return sum;
    }
    public static void main(String[] args) throws IOException{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(br.readLine());
        long[] arr=new long[n];
        for(int i=1;i<=n;i++) arr[i-1]=i;
        long ans=sumGCD(arr);
        System.out.println(ans);
    }
}

Measured memory_bytes: 32632
#include <bits/stdc++.h>
#define ll long long
#define pi 3.14159265358979
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;
const int INF = 1000100100;

int main(){
    ll t,cnt=0,ans=0;
    string s;
    cin>>s;
    t=s.size();
    rep(i,t){
        if(cnt==0){
            cnt++;
            if(s[i]=='p'){
                ans--;
            }
        }else{
            cnt--;
            if(s[i]=='g'){
                ans++;
            }
        }
    }
    cout<<ans;
}

Measured memory_bytes: 3752
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    X=[int(_) for _ in input().split()]
    sum_x=sum(X)
    ans=0
    if sum_x/n-sum_x//n<0.5:p=sum_x//n
    else:p=sum_x//n+1
    for i in range(n):
        ans+=(X[i]-p)**2
    print(ans)

if __name__=='__main__':
    main()

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

int main(){
    int N;
    cin >> N;
    int nums_count[100002];
    fill(nums_count, nums_count + 100002, 0);
    for(int i = 0; i < N; i++){
        int num;
        cin >> num;
        nums_count[num]++;
        nums_count[num + 1]++;
        nums_count[num + 2]++;
    }
    int ans = 0;
    for(int i = 0; i < 100002; i++){
        ans = max(ans, nums_count[i]);
    }
    cout << ans << endl;
}


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

#define trav(a, A) for (auto & a : A)
#define f first
#define s second

typedef long long ll;

const ll MOD = 1e+9+7;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const ll MAXN = 1e+5+7;

int main ()
{
	ios_base::sync_with_stdio (0);
	cin.tie (0);
	ll i, j, n, k;
	cin >> k >> n;
	vector <ll> inp (n);
	trav (a, inp) cin >> a;
	ll mx = inp[0] + k - inp[inp.size () - 1];
	for (i = 1; i < n; ++i)
		mx = max (mx, inp[i] - inp[i - 1]);
	cout << k - mx << '\n';

	return 0;
}



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

int main() {
  int n,m;
  cin >> n >> m;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    a.at(i) = 0;
  }
  
  vector<vector<int>> road(m, vector<int>(2));
  for(int i=0;i<m;i++){
    cin >> road.at(i).at(0) >> road.at(i).at(1);
    a.at(road.at(i).at(0)-1)++;
    a.at(road.at(i).at(1)-1)++;
  }
  
  for(int i=0;i<n;i++){
    cout << a.at(i) << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
//#define ll long long
#define ll unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rrep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define elif else if
#define maxe(x) *max_element(all(x))
#define mine(x) *min_element(all(x))
#define Size(x) ((int)(x).size())
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
long long MOD = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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


//mint,UnionFind,modnCr,modpow,soinsubunkai
//yakusurekkyo
    ll T,N,A,B,C,D;
    map<ll,ll> m;
    ll dfs(ll n){
        if(n==0)return 0;
        if(n==1)return D;
        if(m[n]!=0)return m[n];
        ll res=D*n;
        chmin(res,D*(n%5)+C+dfs(n/5));
        if(n%5!=0)chmin(res,D*(5-n%5)+C+dfs(n/5+1));
        chmin(res,D*(n%3)+B+dfs(n/3));
        if(n%3!=0)chmin(res,D*(3-n%3)+B+dfs(n/3+1));
        chmin(res,D*(n%2)+A+dfs(n/2));
        if(n%2!=0)chmin(res,D*(2-n%2)+A+dfs(n/2+1));
        return m[n]=res;
    }
    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        cin>>T;
        rep(i,T){
            cin>>N>>A>>B>>C>>D;
            cout<<dfs(N)<<endl;
            m.clear();
        }
    }

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

#define fi first
#define se second
#define sc scanf
#define pr printf
#define pb push_back
#define ll long long
#define fin(s) freopen( s, "r", stdin );
#define fout(s) freopen( s, "w", stdout );

const long long N = 100100;
const long long MX = sqrt(N);
const long long H = 17;
const long long MAGIC = 1000;
const long long mod = 1e9 + 7;

using namespace std;

string s;

bool co(string x, char c)
{
        for(int i = 0; i < x.size(); i++){
                if(x[i] != c){
                        return false;
                }
        }
        return true;
}

int f(char c)
{
        string x = s;
        while(!co(x, c)){
                string y = "";
                for(int i = 0; i + 1 < x.size(); i++){
                        if(x[i] == c || x[i + 1] == c){
                                y += c;
                        }
                        else{
                                y += x[i];
                        }
                }
                x = y;
        }
        return s.size() - x.size();
}

void solve()
{
        cin >> s;
        int ans = 1e9;
        for(char c = 'a'; c <= 'z'; c++){
                ans = min(ans, f(c));
        }
        cout << ans << endl;
}

bool mtest = false; int main()
{
        //fin("input.txt");
        //fout("output.txt");
        //fin("landscape.in");
        //fout("landscape.out");
        ios_base::sync_with_stdio(0);
        int TE = 1;
        if(mtest)
                cin >> TE;
        while(TE--)
                solve();
        return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ios>//左右揃え
#include<iomanip>//setwで幅指定

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007LL

long GCM(long a, long b) {
    long r = a % b;
    if (r == 0) return b;
    else return GCM(b, r);
}

int main(void) {
    long a, b, c, d;
    cin >> a >> b >> c >> d;
    long cx_ina_1 = (a - 1) / c, cx_inb = b / c, dx_ina_1 = (a - 1) / d, dx_inb = b / d;
    long lcm = c * d / GCM(c, d);
    long lcmx_ina_1 = (a - 1) / lcm, lcmx_inb = b / lcm;
    long ina_1 = cx_ina_1 + dx_ina_1 - lcmx_ina_1, inb = cx_inb + dx_inb - lcmx_inb;
    long inab = inb - ina_1;
    cout << b - a - inab + 1 << endl;;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

	int n, i, j, k, l;
	int b, f, r, v;
	int x[4][3][10] = { 0 };

	scanf("%d", &n);
	for (i = 0; i < n; i++){
		scanf("%d %d %d %d", &b, &f, &r, &v);
		x[b-1][f-1][r-1] += v;
	}
	for (l = 0; l < 4; l++){
		for (k = 0; k < 3; k++){
			for (j = 0; j < 10; j++){
				printf(" %d", x[l][k][j]);
			}
			printf("\n");
		}
		if (l < 3){
			printf("####################\n");
		}
	}
	return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>

typedef long long ll;

const int MAXN = 1e5+7;
const int inf = 0x3f3f3f3f;
using namespace std;

int f[200][20];
int p[150][20];
int main()
{
    int n;
    cin>>n;
    for(int i = 0 ; i< n;i++)
    {
        for(int j = 0; j < 10;j++)
        {
            cin>>f[i][j];
        }
    }

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

    int ans = -inf;
    for(int i = 1; (i< (1<<10)); i++)
    {

        int sum = 0;
        for(int j = 0 ;j< n; j++)
        {
            int cot = 0;
            for(int k  = 0 ;k < 10 ; k++)
            {
                if(f[j][k] && ( (i>>k)&1) )
                    cot++;
            }

            sum+= p[j][cot];
        }
        ans = max(sum,ans);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N, K = map(int, input().split())
S = input().strip()

if len(S) == 1:
    print(0)
    exit()
ans = 0
if S[0] == 'R' and S[1] == 'R':
    ans += 1
if S[-1] == 'L' and S[-2] == 'L':
    ans += 1
for i in range(1, N-1):
    if S[i] == 'L' and S[i-1] == 'L':
        ans += 1
    elif S[i] == 'R' and S[i+1] == 'R':
        ans += 1

ans += 2 * K

if ans == N:
    print(ans - 1)
elif ans > N:
    print(N - 1)
else:
    print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n,m;
    cin >> n  >> m;
    vector<string> s(m);
    vi p(m),ac(m,0),wa(m,0);
    rep(i,m){
        cin >> p.at(i) >> s.at(i);
    }
    vector<bool> result(n+1, false);
    int64_t sum_wa = 0, sum_ac = 0;
    rep(i,m){
        if(s.at(i)=="AC" && !result.at(p.at(i))){
            result.at(p.at(i)) = true;
            sum_ac++;
        }else if(s.at(i)=="WA" && !result.at(p.at(i))){
            wa.at(i)++;
        }
    }
    rep(i,m){
        if(result.at(p.at(i))){
            sum_wa+=wa.at(i);
        }
    }
    cout << sum_ac << " " << sum_wa << endl;
}


Measured memory_bytes: 8064
N, M, Q = map(int, input().split())
coordinate = [[0 for _ in range(N+1)] for i in range(N+1)]
for m in range(M):
    l, r = map(int, input().split())
    coordinate[l-1][r-1] += 1

for i in range(N):
    for j in range(1, N):
        coordinate[i][j] += coordinate[i][j-1]


for i in range(Q):
    p, q = map(int, input().split())
    ans = 0
    for i in range(p-1, q):
        ans += coordinate[i][q-1] - coordinate[i][p-2]
    print(ans)

Measured memory_bytes: 56072
package main

import (
	"fmt"
)

func main() {
	var N, Y int
	fmt.Scan(&N, &Y)

	for x := 0; x <= N; x++ {
		for y := 0; y <= N-x; y++ {
			z := N - x - y
			var sum int = x*10000 + y*5000 + z*1000
			if sum == Y {
				fmt.Println(x, y, z)
				return
			}
		}
	}
	fmt.Println("-1 -1 -1")
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T>
using vec = vector<T>;

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

int main(){
  int n,k;
  cin >>n >>k;
  vec<int> l(n);
  REP(i,n) cin >>l[i];

  int ans=0;
  sort(all(l));
  REP(i,k) ans += l[n-1-i];

  cout <<ans <<endl;
}


Measured memory_bytes: 256
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
#include <chrono>

using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=a-1;i>=n;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pii>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
template<typename T>void max_self(T &a,T b){a=max(a,b);}
template<typename T>void min_self(T &a,T b){a=min(a,b);}
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=4e5+10,oo=0x3f3f3f3f,MOD=1e9+7;
const long double PI = acos(-1),eps=1.0e-14;

void solve(){
    int n;
    cin>>n;
    int cnt[3]={};
    loop(n,i,0){
        int x;
        cin>>x;
        int c=0;
        while(x%2==0)
            c++,x/=2;
        cnt[c>2?2:c]++;
    }
    if(!cnt[0]||(cnt[0]==cnt[2]&&cnt[1])||(cnt[0]<=cnt[2]+1&&!cnt[1]))
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();

}


Measured memory_bytes: 3592
import java.util.Scanner;
import java.util.Arrays;
import java.util.Collections;
 
class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a <= 9 && b <= 9){
            System.out.println(a*b);
        }else{
            System.out.println("-1");
        }
    }
}

Measured memory_bytes: 23380
/*
-----------------------------------------------------------------------------
Author :            ---------------------------------------------------------
    UTKAR$H $AXENA  ---------------------------------------------------------
    GOOGLE          ---------------------------------------------------------
-----------------------------------------------------------------------------
*/
#include <iostream>
#include <map>
#include <set>
#include <vector>
using namespace std;
#define fre freopen("0.in", "r", stdin), freopen("0.out", "w", stdout)
#define abs(x) ((x) > 0 ? (x) : -(x))
#define MOD 1000000007
#define LL signed long long int
#define ps(x) push_back(x)
#define scan(x) scanf("%d", &x)
#define print(x) printf("%d\n", x)
#define scanll(x) scanf("%lld", &x)
#define printll(x) printf("%lld\n", x)
#define boost ios_base::sync_with_stdio(0)
// vector<int> g[2*100000+5];int par[2*100000+5];
int main() {
  // fre;
  int N;
  int ans = 0;
  cin >> N;
  int cunt = 0;
  int last = -1;
  for (int i = 1; i <= N; ++i) {
    int x;
    scan(x);
    if (x == last) {
      cunt++;
    } else {
      ans += cunt / 2;
      last = x;
      cunt = 1;
    }
  }
  ans += cunt / 2;
  cout << ans;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		const int MOD = 1000000007;
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			int n = cin.Int();
			long[] a = new long[n];
			for (int i = 0; i < n; i++) {
				a[i] = cin.Long();
			}

			long ans = 0;
			bool? upper = null;
			for (int i = 0; i < n; i++) {
				if (i == n - 1) {
					++ans;
					break;
				}

				if (a[i + 1] == a[i]) {
					continue;
				} else if (a[i + 1] > a[i]) {
					if (upper == false) {
						upper = null;
						++ans;
					} else {
						upper = true;
					}
				} else {
					if (upper == true) {
						upper = null;
						++ans;
					} else {
						upper = false;
					}
				}
			}

			Console.WriteLine(Math.Max(ans, 1));
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;
		
		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long Long()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double Double()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}


Measured memory_bytes: 18912
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
#define REP(i,st,ed) for(int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(int i=st,i##end=ed;i>=i##end;--i)
typedef double lf;
const int maxn=200005;
const lf pi=acos(-1.0);
int n;
struct point{int x,y;}p[maxn];
bool cmpx(const point &A,const point &B){return A.x<B.x;}
bool cmpy(const point &A,const point &B){return A.y<B.y;}
int stk[maxn],stktop;
int main(){
	int x1,y1,x2,y2;
	scanf("%d%d%d%d%d",&x1,&y1,&x2,&y2,&n);
	REP(i,1,n)
		scanf("%d%d",&p[i].x,&p[i].y);
	if(x1==x2){
		if(y1>y2)swap(y1,y2);
		sort(p+1,p+1+n,cmpx);
		int pos=lower_bound(p+1,p+1+n,(point){x1,0},cmpx)-p;
		lf ans=100.0*(y2-y1);
		if((p[pos].x==x1)&&(p[pos].y>y1)&&(p[pos].y<y2))ans+=10*pi-20;
		printf("%.15lf\n",ans);
	}else if(y1==y2){
		if(x1>x2)swap(x1,x2);
		sort(p+1,p+1+n,cmpy);
		int pos=lower_bound(p+1,p+1+n,(point){0,y1},cmpy)-p;
		lf ans=100.0*(x2-x1);
		if((p[pos].y==y1)&&(p[pos].x>x1)&&(p[pos].x<x2))ans+=10*pi-20;
		printf("%.15lf\n",ans);
	}else{
		if(y1>y2)swap(x1,x2),swap(y1,y2);
		sort(p+1,p+1+n,cmpx);
		if(x1<x2){
			lf ans=100.0*(x2-x1+y2-y1);
			REP(i,1,n){
				if((p[i].x<x1)||(p[i].x>x2)||(p[i].y<y1)||(p[i].y>y2))continue;
				int pos=lower_bound(stk+1,stk+1+stktop,p[i].y)-stk;
				if(pos>stktop)++stktop;
				stk[pos]=p[i].y;
			}
			ans+=stktop*(5*pi-20);
			if(stktop==min(x2-x1,y2-y1)+1)ans+=5*pi;
			printf("%.15lf\n",ans);
		}else{
			lf ans=100.0*(x1-x2+y2-y1);
			DREP(i,n,1){
				if((p[i].x<x2)||(p[i].x>x1)||(p[i].y<y1)||(p[i].y>y2))continue;
				int pos=lower_bound(stk+1,stk+1+stktop,p[i].y)-stk;
				if(pos>stktop)++stktop;
				stk[pos]=p[i].y;
			}
			ans+=stktop*(5*pi-20);
			if(stktop==min(x1-x2,y2-y1)+1)ans+=5*pi;
			printf("%.15lf\n",ans);
		}
	}
	return 0;
}

Measured memory_bytes: 2560