akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(void){
  int a,b,n,r=0,t,s;
  for(scanf("%d%d%d",&n,&a,&b);n;--n){
    for(t=n,s=0;t;t/=10)s+=t%10;
    r+=a<=s?s<=b?n:0:0;
  }
  printf("%d\n",r);
  return 0;
}

Measured memory_bytes: 128
#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 a[305][305];
vector<int>to[305];

int main(){
    int n;
    cin>>n;
    rep(i,n)rep(j,n){
        cin>>a[i][j];
        to[i].push_back(j);
    }
    //WF
    rep(k,n)rep(i,n)rep(j,n){
        if(a[i][j]>a[i][k]+a[k][j]){
            cout<<-1<<endl;
            return 0;
        }
    }
    ll ans=0;
    for(int i=0; i<n; ++i)for(int j=i+1; j<n; ++j){
        bool ok=false;
        rep(k,n){
            if(k==i||k==j)continue;
            if(a[i][j]==a[i][k]+a[k][j])ok=true;
        }
        if(!ok)ans+=a[i][j];
    }
    cout<<ans<<endl;
}

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

int main() {
    int n;
    int a = 0;
    int b = 0;
    int array[110];
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> array[i];
    }
    sort(array, array + n, greater<int>());
    
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) {
            a += array[i];
        } else {
            b += array[i];
        }
    }
    cout << a - b << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Objects;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        System.out.println(problem166a(s));
    }

    private static String problem166a(String s) {
        return (Objects.equals(s, "ABC")) ? "ARC" : "ABC";
    }
}

Measured memory_bytes: 35608
# ABC062a
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


# Union-Find木


class UnionFind:
    def __init__(self, n):
        self.tree = [i for i in range(n)]

    def root(self, x):
        if(self.tree[x] == x):
            return x
        self.tree[x] = self.root(self.tree[x])
        return self.tree[x]  # 経路圧縮

    def same(self, x, y):  # xとyが同じ木に属するか
        return self.root(x) == self.root(y)

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if(x == y):
            return
        self.tree[x] = y


uf = UnionFind(12)
uf.unite(0, 2)
uf.unite(0, 4)
uf.unite(0, 6)
uf.unite(0, 7)
uf.unite(0, 9)
uf.unite(0, 11)
uf.unite(3, 5)
uf.unite(3, 8)
uf.unite(3, 10)

x, y = map(int, input().split())
print('YNeos'[not uf.same(x-1, y-1)::2])


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int MOD = 1e9 + 7;
using namespace std;
const int N = 100010;
int a[N] = {},b[N] = {},c[N] = {},dp[N][4] = {};

int fun(int idx,int d)
{
	if(idx == -1)
		return 0;
	if(dp[idx][d] != -1)
		return dp[idx][d];
	int ans = 0;
	if(d == 1)
		ans = max(fun(idx-1,2) + b[idx],fun(idx-1,3) + c[idx]);
	if(d == 2)
		ans = max(fun(idx-1,1) + a[idx],fun(idx-1,3) + c[idx]);
	if(d == 3)
		ans = max(fun(idx-1,1) + a[idx],fun(idx-1,2) + b[idx]);
	dp[idx][d] = ans;
	return ans;
}

int32_t main()
{
    IOS
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    int n;
    cin >> n;
    for(int i = 1;i<=n;i++)
    {
    	//int a,b,c;
    	cin >> a[i] >> b[i] >> c[i];
    }
    memset(dp,-1,sizeof(dp));
    cout << max(fun(n-1,1) + a[n],max(fun(n-1,2) + b[n],fun(n-1,3) + c[n])) << '\n';
    return 0;
}

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

#include <vector>
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<vector<int> > d(n, vector<int>(2, 0));
  rep(i, n) {
    cin >> d[i][0];
    cin >> d[i][1];
  }
  int count = 0;
  rep(i, n) {
    if (d[i][0] == d[i][1]) {
      count++;
    } else {
      count = 0;
    }
    if (count == 3) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using boost::multiprecision::cpp_int;

typedef long long ll;
typedef pair<ll, ll> pll;

const ll INF = 1e17;
const ll MOD = 1e9+7;

int main() {
    // input, ready
    int R;
    cin >> R;

    cout << setprecision(8) << 2*R*3.141593 << endl;


    return 0;
}


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

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

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define maxs(x,y) x = max(x, y)
#define mins(x,y) x = min(x, y)
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int N;
    cin >> N;
    
    int ans = 0;
    for (int j = 1; j <= N; j++) {
        if (j % 2 == 0) continue;
        int cnt = 0;
        for (int i = 1; i <= j; i++) {
            if (j%i == 0) cnt++;
        }        
        if (cnt == 8) {
            // cout << j << endl;
            ans++;
        }
    }

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

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

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

  int L=a;
  int R=n-b;
  int X=max(0,L-R);
  cout<<min(a,b)<<' '<<X<<endl;
  return 0;
}


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

/*

void bfs(int vertex, int depth)
{
  seen[vertex] = true;
  ans [vertex] = depth;
  for (auto &&i : G[vertex]) que.push(i);
  while(!(que.empty()))
  {
    int next = que.front();
    que.pop();
    if (seen[next] == false)
    {
      bfs(next,depth + 1);
    }
  }

  
}




int main()
{
  fill_n(ans,105,-1);
  fill_n(seen,105,false);
  int n;cin>>n;
  for (int i = 0; i < n; i++)
  {
    int u;cin>>u;
    int k;cin>>k;
    for (int j = 0; j < k; j++)
    {
      int v;cin>>v;
      G[u].push_back(v);
    }
    
  }

}
*/



  
int ans[105];
vector<int> G[105];
queue<int> que;

int main()
{
  fill_n(ans,105,-1);
  int n;cin>>n;
  for (int i = 0; i < n; i++)
  {
    int u;cin>>u;
    int k;cin>>k;
    for (int j = 0; j < k; j++)
    {
      int v;cin>>v;
      G[u].push_back(v);
    }
    
  }


/*
  for (int i = 1; i <= n; i++)
  {
    cout << i << ": " ;
    for (auto &&j : G[i])
    {
      cout << j << " ";
    }
    cout << endl;
    
  }
*/


  que.push(1);
  ans[1] = 0;

  while (!que.empty())
  {
    int vertex = que.front();
    que.pop();

    for (auto &&next : G[vertex])
    {
      if (ans[next] != -1) continue;
      que.push(next);
      ans[next] = ans[vertex] + 1;
    }
  

  }
  

  for (int i = 1; i <= n; i++)
  {
    cout << i << " " << ans[i] << endl;
  }
  

}
  


Measured memory_bytes: 3156
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T, class U> void _W(const pair<T, U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
#define DEBUG(...) {printf("[DEBUG] ");W(__VA_ARGS__);}
#else
#define DEBUG(...)
#endif
int MOD = 1e9 + 7;
void ADD(LL& x, LL v) {x = (x + v) % MOD; if (x < 0)x += MOD;}
/*}}}*/
void solve() {
	int n, m;
	R(n, m);
	VI v(n);
	int sum = 0;
	REP(i, n) {
		R(v[i]);
		sum += v[i];
	}
	int cnt = 0;
	REP(i, n) {
		if (v[i] * 4 * m >= sum)
			cnt++;
	}
	if (cnt >= m) W("Yes");
	else W("No");
}

int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

#define MULTITEST 0
#if MULTITEST
	CASET {
		solve();
	}
#else
	solve();
#endif
	return 0;
}


Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
double a[200010];
int main(){
	int n,k;
	cin >> n >> k;
	for(int i=1;i<=n;i++){
		double t;
		cin >> t;
		a[i]=(1.0+t)/2.0;
	}
	double sum=0,maxn=0;
	for(int i=1;i<=n;i++){
		if(i<=k){
			sum+=a[i];
		}
		else{
			sum=sum-a[i-k]+a[i];
		}
		maxn=max(maxn,sum);
	}
	printf("%lf",maxn);
	return 0;
} 

Measured memory_bytes: 1792
n = int(input())
a = [list(map(int, input().split())) for i in range(2)]
l = []
r = []
sum = 0
for x in a[0]:
    sum += x
    l.append(sum)
sum = 0
for x in a[1][::-1]:
    sum += x
    r.append(sum)
ans = 0
for x, y in zip(l,r[::-1]):
    ans = max(ans, x + y)
print(ans)

Measured memory_bytes: 3064
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 k=sc.nextInt();

		if(b-a+1<=2*k-1){
			for(int i=a;i<=b;i++) System.out.println(i);
		}else{
			for(int i=a;i<=a+k-1;i++) System.out.println(i);
			for(int j=b-k+1;j<=b;j++) System.out.println(j);
		}

	}
}

Measured memory_bytes: 23764
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


class Mod:
    def __init__(self, m):
        self.m = m

    def add(self, a, b):
        return (a + b) % self.m

    def sub(self, a, b):
        return (a - b) % self.m

    def mul(self, a, b):
        return ((a % self.m) * (b % self.m)) % self.m

    def div(self, a, b):
        return self.mul(a, pow(b, self.m-2, self.m))

    def pow(self, a, b):
        return pow(a, b, self.m)


m = Mod(10**9 + 7)


@mt
def slv(N, M, A):
    dp = [0] * (N+3)
    b = [False] * (N+3)
    for a in A:
        b[a] = True

    dp[0] = 1
    for i in range(N):
        if not b[i+1]:
            dp[i+1] = m.add(dp[i+1], dp[i])
        if not b[i+2]:
            dp[i+2] = m.add(dp[i+2], dp[i])
    return dp[N]


def main():
    N, M = read_int_n()
    A = [read_int() for _ in range(M)]
    print(slv(N, M, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 11204
n=int(input())
l=list(map(int,input().split()))
if n<=2:print(1);exit()
ans=1
chk=0
left=0
while chk<n-2:
  if (l[left]-l[chk+1])*(l[chk+1]-l[chk+2])<0:ans+=1;chk+=2;left=chk
  else:chk+=1
print(ans)


Measured memory_bytes: 14252
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    /*ll x=3000000000;
    cout<<x<<endl;*/
    ll n,k,x;
    cin>>n>>k;
    vector<ll> v;
    for(ll i=0;i<n;i++){
        cin>>x;
        v.push_back(x);
    }
    sort(v.begin(),v.end());
    if(k>=n){
        cout<<0<<endl;
    }else{
    ll sum=0;
    for(ll i=0;i<n-k;i++){
        sum+=v[i];
    }

    cout<<sum<<endl;}
    return 0;


}



Measured memory_bytes: 2420
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;
#include <cstring>

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cout << "ACL";
  }
  cout << endl;
}

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

using namespace std;

#define IOS ios::sync_with_stdio(0);cin.tie(0);

int main(){
	int n,m;
	while(cin>>n){
		cin>>m;
		if(m>=n){
			cout<<n;
		}
		else{
			cout<<n-1;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

// Union-Find Disjoint Sets Library written in OOP manner, using both path compression and union by rank heuristics
// initialize: UnionFind UF(N)

class UnionFind {                                              // OOP style
private:
	vector<int> p, rank, setSize;
	// p = path toward the root of disjoint set; p[i] = i means it is root
	// rank = upper bound of the actual height of the tree; not reliable as accurate measure
	// setSize = size of each disjoint set

	int numSets;
public:
	UnionFind(int N) {
		setSize.assign(N, 1);
		numSets = N;
		rank.assign(N, 0);
		p.assign(N, 0);
		for (int i = 0; i < N; i++) p[i] = i;	// each belongs to its own set
	}

	int findSet(int i) {
		return (p[i] == i) ? i : (p[i] = findSet(p[i]));		// path compression: cut short of the path if possible
	}

	bool isSameSet(int i, int j) {
		return findSet(i) == findSet(j);
	}

	void unionSet(int i, int j) {
		if (!isSameSet(i, j)) {
			numSets--;
			int x = findSet(i), y = findSet(j);
			// rank is used to keep the tree short
			if (rank[x] > rank[y]) { p[y] = x; setSize[x] += setSize[y]; }
			else {
				p[x] = y; setSize[y] += setSize[x];
				if (rank[x] == rank[y]) rank[y]++;
			}
		}
	}

	int numDisjointSets() {		// # of disjoint sets
		return numSets;
	}

	int sizeOfSet(int i) {		// size of set
		return setSize[findSet(i)];
	}
};


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

	int n, m, k, i, j, x;
	cin >> n >> m;
	vector<vector<int>> plist(m + 1);
	for (i = 0; i < n; i++) {
		cin >> k;
		while (k--) {
			cin >> x;
			plist[x].push_back(i);
		}
	}

	UnionFind uf(n);
	for (i = 1; i <= m; i++) {
		for (j = 1; j < plist[i].size(); j++) uf.unionSet(plist[i][0], plist[i][j]);
	}

	bool valid = true;
	for (i = 0; i < n; i++) {
		if (!uf.isSameSet(i, 0)) valid = false;
	}

	if (valid) cout << "YES\n";
	else cout << "NO\n";


	return 0;
}


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

using namespace std;

void test()
{
    int n,k;
    cin>>n>>k;
    
    int p[n];
    for(int i=0;i<n;i++)
        cin>>p[i];
    
    sort(p,p+n);
    
    long sum=0;
    for(int i=0;i<k;i++)
        sum+=p[i];
    
    cout<<sum;
}

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

        test();

    return 0;
}


Measured memory_bytes: 3652
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();
        int c =sc.nextInt();
        
        int kadai=0;
        for(int i = a; i <= b;i++){
            if(c%i==0){
                kadai++;
            }
        }
        System.out.println(kadai);
    }
}

                
        
            



Measured memory_bytes: 26396
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int t = 1;
        Solver s = new Solver();
        for (int i = 1; i <= t; i++) {
            s.solve(i, in, out);
        }
        out.close();
    }

}

class Solver {

    static final long MODULO = (long) (1e9 + 7);

    void solve(int test, InputReader in, PrintWriter out) throws IOException {
        int n = in.nextInt();
        int[] p = new int[(int) (1e3 + 7)];
        for (int i = 2; i < p.length; i++) {
            if (p[i] == 0)
            for (int j = i; j < p.length; j += i) p[j] = i;
        }
        long ans = 1;
        HashMap<Integer, Integer> map = new HashMap<>();
        for (int i = 2; i <= n; i++) {
            HashMap<Integer, Integer> m = getFactors(i, p);
            map = merge(m, map);
        }
        for (Map.Entry<Integer, Integer> entry : map.entrySet()) ans = (ans * (entry.getValue() + 1)) % MODULO;
        out.println(ans);
    }

    private HashMap<Integer, Integer> merge(HashMap<Integer, Integer> m, HashMap<Integer, Integer> map) {
        for (Map.Entry<Integer, Integer> entry : m.entrySet()) {
            if (map.containsKey(entry.getKey())) map.put(entry.getKey(), map.get(entry.getKey()) + entry.getValue());
            else map.put(entry.getKey(), entry.getValue());
        }
        return map;
    }

    private HashMap<Integer, Integer> getFactors(int i, int[] p) {
        HashMap<Integer, Integer> map = new HashMap<>();
        int x = i;
        while (x > 1) {
            int j = p[x];
            int exp = 0;
            while (x % j == 0) {
                x /= j;
                exp++;
            }
            map.put(j, exp);
        }
        return map;
    }
}

class InputReader {
    BufferedReader br;
    StringTokenizer st;

    public InputReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
        st = null;
    }

    public String next() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return st.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public String nextLine() throws IOException {
        return br.readLine();
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 21588
#include<stdio.h>
int main(void){
	int i, a[2],b[2];
	
	for (i = 0; i < 2; i++){
		scanf("%d %d", &a[i],&b[i]);
	}
	i = (a[0] - a[1])*(b[0] - b[1]);
	printf("%d\n",i);
	return 0;
}

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

const int MAX_HW = 25;
const int MAX_VERTEX = 625;
const int INF = 1e9;
char MAZE[MAX_HW][MAX_HW];
int graph[MAX_VERTEX][MAX_VERTEX];
int H, W, VERTEX;

void init(){
    VERTEX = H*W;
    for(int i = 0; i < VERTEX; ++i) for(int j = 0; j < VERTEX; ++j) graph[i][j] = INF;
    for(int i = 0; i < VERTEX; ++i) graph[i][i] = 0;
    int dy[4] = { 1, 0,-1, 0};
    int dx[4] = { 0, 1, 0,-1};
    for(int i = 0; i < H; ++i) {
        for(int j = 0; j < W; ++j) {
            if(MAZE[i][j] == '#') continue;
            int cur = i*W + j;
            for(int k = 0; k < 4; ++k) {
                int ny = i + dy[k], nx = j + dx[k];
                if(ny < 0 || ny >= H || nx < 0 || nx >= W) continue;
                if(MAZE[ny][nx] == '#') continue;
                int nxt = ny*W + nx;
                //printf("%d %d\n", cur , nxt);
                graph[cur][nxt] = graph[nxt][cur] = 1;
            }
        }
    }
}

void warshall_floyd(){
    for(int k = 0; k < VERTEX; ++k) 
        for(int i = 0; i < VERTEX; ++i)
            for(int j = 0; j < VERTEX; ++j)
                graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
}

int main()
{
    scanf("%d %d", &H, &W);
    for(int i = 0; i < H; ++i) scanf("%s", MAZE[i]);

    init();
    warshall_floyd();
    int res = -1;
    for(int i = 0; i < VERTEX; ++i)
        for(int j = 0; j < VERTEX; ++j)
            if(graph[i][j] != INF) res = max(res, graph[i][j]);
    printf("%d\n", res);
    return 0;
}

Measured memory_bytes: 1280
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>

auto& in = std::cin;
auto& out = std::cout;

int64_t N;
int32_t m;
bool MAP[200001][8];
bool MOD[700010];

template<typename T>
void fill_all(T& arr, const T& v) {
	arr = v;
}
template<typename T, typename ARR>
void fill_all(ARR& arr, const T& v) {
	for (auto& i : arr) { fill_all(i, v); }
}

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	int32_t Q;
	in >> N >> m >> Q;
	auto m_l = m;
	if ((m_l % 7) != 0) {
		m_l *= 7;
	}
	for (int32_t i = 0; i < Q; ++i)
	{
		int32_t a;
		in >> a;
		do{
			MOD[a] = true;
			a += m;
		}while (a < m_l);
	}
	m = m_l;

	for (int32_t y = 0; y < (m / 7); ++y) {
		MAP[y][7] = true;
	}
	for (int32_t x = 0; x < 8; ++x) {
		MAP[(m / 7)][x] = true;
	}
	int32_t count = 0;
	std::stack<std::pair<int32_t, int32_t>> stack;
	for (int32_t y = 0; y < (m/7); ++y)
		for (int32_t x = 0; x < 7; ++x)
		{
			if (MOD[(7 * y + x) % m]) {
				MAP[y][x] = true;
			}
			if (!MAP[y][x])
			{
				++count;
				stack.emplace(y, x);
				MAP[y][x] = true;
				while (!stack.empty())
				{
					auto pos = stack.top(); stack.pop();
					auto y = pos.first;//オーバーライド
					auto x = pos.second;
					int diff[] = { 1,0,-1,0,1 };
					for (int32_t j = 0; j < 4; ++j)
					{
						auto ny = std::max(0, y + diff[j + 1]);
						auto nx = std::max(0, x + diff[j]);
						if (!MAP[ny][nx])
						{
							if (MOD[(7 * ny + nx) % m]) {
							}
							else {
								stack.emplace(ny, nx);
							}
							MAP[ny][nx] = true;
						}
					}
				}
			}
		}

	int32_t count1 = count;

	fill_all(MAP, false);
	for (int32_t y = 0; y < (m / 7) * 2; ++y) {
		MAP[y][7] = true;
	}
	for (int32_t x = 0; x < 8; ++x) {
		MAP[(m / 7) * 2][x] = true;
	}
	count = 0;
	for (int32_t y = 0; y < (m / 7)*2; ++y)
		for (int32_t x = 0; x < 7; ++x)
		{
			if (MOD[(7 * y + x) % m]) {
				MAP[y][x] = true;
			}
			if (!MAP[y][x])
			{
				++count;
				stack.emplace(y, x);
				MAP[y][x] = true;
				while (!stack.empty())
				{
					auto pos = stack.top(); stack.pop();
					auto y = pos.first;//オーバーライド
					auto x = pos.second;
					int diff[] = { 1,0,-1,0,1 };
					for (int32_t j = 0; j < 4; ++j)
					{
						auto ny = std::max(0, y + diff[j + 1]);
						auto nx = std::max(0, x + diff[j]);
						if (!MAP[ny][nx])
						{
							if (MOD[(7 * ny + nx) % m]) {
							}
							else {
								stack.emplace(ny, nx);
							}
							MAP[ny][nx] = true;
						}
					}
				}
			}
		}

	out << (count - count1)*((7*N)/m - 1)+count1 << endl;
	

	return 0;
}
#endif

Measured memory_bytes: 3200
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define SORTD(a) sort(a.rbegin(), a.rend());
#define UNIQUE(a) unique(a.begin(), a.end())
#define ll long long
#define INF 1000000000000000000
#define INT_MAX 2147483647

#include <iostream>
#include <vector>
#include <cmath>
#include <cctype>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <utility>
#include <ios>
#include <iomanip>

using namespace std;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

int main(){
    int n;
    cin >> n;
    vi p(n);
    bool c=false;

    REP(i,n){
        int pt;
        cin >> pt;
        if(pt==i+1){
            if(c==false){
                p.push_back(1);
                c=true;
            }else{
                p.back()++;
            }
        }else{
            c=false;
        }
    }

    int ans = 0;
    REP(i,p.size()){
        ans += ceil((double)p[i]/2);
    }
    cout << ans << endl;

}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
#include <algorithm>
#include <array>
#include <string.h>
#include <vector>




int main() {
	int N,X;

	scanf("%d %d", &N,&X);

	std::vector<int> M;
	int tmp;
	for (int i = 0; i < N; i++) {
		scanf("%d", &tmp);
		M.push_back(tmp);
	}
	std::sort(M.begin(), M.end());
	
	int sum = 0;
	for (int i = 0; i < N; i++) {
		X -= M[i];
		sum++;
	}
	
	sum += X / M[0];



	printf("%d", sum);

	return 0;
}

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

int main(){
  int n;
  cin>>n;
  int l[105];
  int sum=0,ma=0;
  rep(i,n) {
    cin>>l[i];
    sum+=l[i];
    ma=max(ma,l[i]);
  }
  if(ma<sum-ma) puts("Yes");
  else puts("No");
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		String S = in.readLine();
		char c = S.charAt(0);
		boolean result = true;
		for (int i = 1; i < S.length(); ++i) {
			if (c == S.charAt(i)) {
				result = false;
				break;
			}
			c = S.charAt(i);
		}
		String str = result ? "Good" : "Bad";
		System.out.println(str);
		in.close();
	}

}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
#define int long long
#define pb emplace_back
#define mp make_pair
#define mt make_tuple
#define all(v) v.begin(),v.end()
#define rep(i,start,lim) for(long long (i)=(start);i<(lim);i++)
#define revrep(i,n) for(long long i=n-1;i>=0;i--)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define osit ostream_iterator<int> output (cout," ")
#define endl '\n'
#define f first
#define s second
#define PI 3.141592653589793
#define MOD 1000000007
#define set0(x) memset(x,0,sizeof(x))
#define set1(x) memset(x,1,sizeof(x))
using namespace std;
typedef vector<int> vi;
typedef list<int> li;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef tuple<int, int, int> iii;
template<typename T> T gcd(T a,T b){if(a==0) return b; return gcd(b%a,a);}
template<typename P> P dectobin(P a){if(a==0)return 0; else return(a%2 + 10*dectobin(a/2));}
template<typename Y> Y bintodec(Y a){int ans=0,b=1,t=a; while (t){int ld=t%10; t/=10;ans+=ld* b;b=b*2;} return ans; }
template<typename H> H modExp(H x, H n){ int r=1; while(n>0){if(n%2==1){r=(r*x)%MOD;}x=(x*x)%MOD;n/=2;}return r;}
template<typename T> T isPowerOfTwo(T x){return x && (!(x & (x - 1)));}	
template<typename T> T lcm(T a,T b) {return a*b/gcd(a,b);}
//template<typename T> T extendedEuclid(T A,T B){if(B==0){d=A; x=1;y=0;}else{ extendedEuclid(B,A%B);int temp=x; x=y; y=temp-(A
//B)*y;}}
int32_t main(){
	boost;osit;
	int x,a;
	cin>>x>>a;
	if(x<a) cout<<0;
	else cout<<10;
	return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
strToInt s = (read :: String -> Int) s

main :: IO ()
main = do
    -- 整数の入力
    n <- getLine
    -- スペース区切り整数の入力
    l <- map strToInt . words <$> getLine
    putStrLn $ show $ (maximum l) - (minimum l)


Measured memory_bytes: 892
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,i,ans,ma
    integer(int32), allocatable:: a(:)

    read*, n
    allocate(a(n))
    read*, a(:)

    a = a-minval(a)
    ma = maxval(a)
    if (ma==0) then
        print'(i0)', 0
        stop
    end if
    
    ans = 1000000000
    do i=1, ma
        ans = min(ans,sum(a*a))
        a(:) = a(:) - 1
    end do

    print'(i0)', ans
end program name

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main()
{
    int a;
    cin>>a;
    int h , m , s;
    h=a/3600;
    m=(a%3600)/60;
    s=(a%3600)%60;
    cout<<h<<":"<<m<<":"<<s;
cout<<"\n";
    return 0;
}


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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    int cnt[N+1] = {};
    for(int x = 1; x <= 150; x++){
        for(int y = 1; y <= 150; y++){
            for(int z = 1; z <= 150; z++){
                int calc = x*x + y*y + z*z + x*y + y*z + z*x;
                if(calc <= N) cnt[calc]++;
            }
        }
    }
    for(int i = 1; i <= N; i++) cout << cnt[i] << endl;
    return 0;
}

Measured memory_bytes: 3616
import java.util.*;


public class Main {

	/**
	 * @param args
	 */
	Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().doit();

	}
	
	private void doit() {
		new A();
	}

	class A{
		A(){
			while(true){
				int n = sc.nextInt();
				int q = sc.nextInt();
				if((n | q ) == 0) break;
				String name [] = new String[n];
				int [] s = new int[n];
				int [] e = new int[n];
				for(int i = 0 ; i < n; i++){
					name[i] = sc.next();
					int span = sc.nextInt();
					e[i] = sc.nextInt();
					int start = e[i] - span + 1;
					s[i] = start;
				}
				
				while(q-- > 0){
					int input = sc.nextInt();
					boolean ansflg = false, dupflg = false;
					int ind = -1, ans = 0;
					for(int i = 0 ; i < n; i++){
						if(isB(input, s[i], e[i])){
							ansflg = true;
							if(dupflg){
								ansflg = false;
								break;
							}
							
							ind = i;
							ans = input - s[i] + 1;
							
							dupflg = true;
						}else{
							
						}
					}
					if(ansflg){
						System.out.println(name[ind] + " " + ans);
					}
					else{
						System.out.println("Unknown");
					}
				}
			}
		}

		private boolean isB(int input, int s, int e) {
			if(s <= input && input <= e){
				return true;
			}
			return false;
		}
	}
}

Measured memory_bytes: 14000
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  vector<int> v(3);
  for (int i = 0; i < 3; ++i) cin >> v[i];
  Cin(int, k);

  sort(all(v));

  for (int i = 0; i < k; ++i) v.back() *= 2;

  int ans = 0;
  for (auto e : v) ans += e;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

bool isOK(ll P, ll K, vector<ll> A) {
    ll cnt = 0, acc = 0;
    rep(i, A.size()) {
        if (A[i] > P)
            return false;
        if (acc + A[i] <= P)
            acc += A[i];
        else
            cnt++, acc = A[i];
    }

    if (acc <= P)
        cnt++;
    else
        return false;

    if (cnt <= K)
        return true;
    else
        return false;
}

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

    int N, K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i, N) { cin >> A[i]; }
    ll sum = accumulate(all(A), (ll)0);
    ll ng = -1, ok = sum;
    while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;
        if (isOK(mid, K, A))
            ok = mid;
        else
            ng = mid;
    }

    cout << ok << endl;
}


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

#define ll long long int
#define absdiff(a,b) (a>b)?a-b:b-a
#define mp make_pair 
#define pb push_back
#define pp pop_back
#define ff first
#define ss second
#define fast  ios_base::sync_with_stdio(false);cin.tie(0);
#define endl "\n"
const ll ll_MAX = 19223372036859;
const ll MOD = 998244353;
ll fast_expo(ll x,ll p){if(p==0) return 1;
    else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;
        return (t*t)%MOD;} 
    else return (x*(fast_expo(x,p-1))%MOD)%MOD;}

ll bit[200005];

void upd(ll pos, ll n, ll val){
	for(; pos <= n; pos += (pos&(-pos))){
		bit[pos] = max(bit[pos], val);
	}
}

ll query(ll pos){
	ll ans = 0;
	for(; pos > 0; pos -= (pos&(-pos)))
		ans = max(bit[pos], ans);
	return ans;
}

int main()
{
	fast
    ll t_c; t_c = 1;
    // cin >> t_c;
    for(ll t_i=0; t_i<t_c; ++t_i){
		ll n; cin >> n;
		pair<ll,ll> arr[n+1];
		for(ll i=1; i<=n; ++i)
			cin >> arr[i].ff;
		for(ll i=1; i<=n; ++i)
			cin >> arr[i].ss;
		
		for(ll i=1; i<=n; ++i){
			ll find = query(arr[i].ff-1);
			upd(arr[i].ff, n, find+arr[i].ss);
		}
		ll maxi = 0;
		for(auto i:bit)
			maxi = max(maxi, i);
		cout << maxi;
    }  
    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <math.h>
#include <string>    // useful for reading and writing
#include <fstream>   // ifstream, ofstream
#include <sstream>   // istringstream

using namespace std;

int main()
{
    int a,b,c;
    cin >> a >> b >>c;
    int x = 0;
    for(int i = a; i <= b; i++)
    {
        if(c%i==0){x+=1;}
    }
    cout << x << endl;
    return 0;
}


Measured memory_bytes: 3120
import copy
import sys
import math

def main():
	x,y = map(int,input().split())
	ans=0
	while x<=y:
		x *= 2
		ans+=1
	if(x==y): print(ans+1)
	else: print(ans)


def listtodict(a):
	b = {}
	for i in a:
		try:
			b[i] += 1
		except:
			b[i] = 1
	return b

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

main()

Measured memory_bytes: 3444
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int a[10000000];
inline int read(){
   int s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}
int cmp(int x,int y){
	return x>y;
}
long long gcd(long long a,long long b){
	return b==0?a:gcd(b,a%b);
}
int main(){
    long long A;
    long long B;
    cin>>A>>B;
    long long F=A%B;
    
    cout<<min(B-F,F)<<endl;
 	return 0;
} 

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

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

    string s;
    cin >> s;
    int n;
    cin >> n;

    map<char, vector<int>> mp;
    REP(i, s.size()) mp[s[i]].push_back(i);

    set<string> st;
    for(int i = 0; i <= 25; i++){
        char c = 'a' + i;
        if(!(mp[c].size())) continue;
        for(auto j: mp[c]){
            j = (int)j;
            string tmp = "";
            for(int k = j; k < j + n; k++){
                if(k >= s.size()) break;
                tmp += s[k];
                st.insert(tmp);
            }
        }
        if(st.size() > n) break;
    }

    vector<string> A;
    for(auto x: st) A.push_back(x); 
    sort(A.begin(), A.end());
    cout << A[n - 1] << endl;

    return 0;
}

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

using namespace std;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
  	
  	int a, b;
 	cin >> a >> b;
  	if(a > 9 || b > 9) cout << "-1\n";
    else cout << a * b << "\n";
  
	return 0;
}

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

namespace Contest
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            var a = Array.ConvertAll(Console.ReadLine().Split(), Convert.ToInt32);
            for (int i = 1; i < n; i++)
                if (a[i] < a[i - 1])
                {
                    Console.WriteLine("No");
                    return;
                }
                else if (a[i] > a[i - 1]) a[i]--;
            Console.WriteLine("Yes");
        }
    }
}


Measured memory_bytes: 25180
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);  //"for float-base
  // problem"
  int A, B, H, M;
  long double pie = 2.0 * (long double)asin(1.0);
  cin >> A >> B >> H >> M;
  double L = 6.0 * M;
  double S = H * 30.0 + (M / 2.0);
  double sa = min((double)abs(S - L * 1.0), 360 - (double)abs(S - L * 1.0));
  double yogen = A * A + B * B - 2 * A * B * (double)cos(sa * pie / 180.0);
  // cout << sa << "" << cos(sa) << " " << yogen << endl;
  cout << (double)sqrt(yogen) << endl;
}

Measured memory_bytes: 4172
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s = sc.next()
    var ans = Int.MAX_VALUE
    for (i in 0..(s.length - 3)) {
        val sub = s.substring(i, i + 3).toInt()
        ans = Math.min(ans, Math.abs(753 - sub))
    }
    println(ans)
}

Measured memory_bytes: 31136
#include <bits/stdc++.h>
#define debug(x) cout << #x << ": " << (x) << endl
using namespace std;

using ull = unsigned long long;
using ll = long long;

using Int = int;
using Double = double;

using P = pair<Int, Int>;
using V = vector<Int>;
using M = vector<V>;

const double PI  = 3.141592653589793238463;
const int MOD = 1000000007;
const Int INF = numeric_limits<Int>::max() / 3;

template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec){
        is >> x;
    }
    return is;
}

bool solve(int n, string s){
    if(n % 2 != 0){
        return false;
    }
    string x = s.substr(0, n / 2);
    string y = s.substr(n / 2);
    return x == y;
}

int main(int argc, char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    int n;
    string s;
    cin >> n >> s;
    cout << (solve(n, s) ? "Yes" : "No") << "\n";

    return 0;
}


Measured memory_bytes: 256
#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, start, stop) for (int i = start; i < stop; i++)
#define FORR(i, start, stop) for (int i = start; i > stop; i--)
#define SORT(v, n) sort(v, v + n);
#define SORTR(v, n) sort(v, v + n,greater<int>());
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.begin(), v.end(),greater<int>());
#define REMOVE(v,n) remove(vector<int> v,v+v.size(),int n)
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
#define V(v,i,j) vector(v.begin() + i, v.begin() + j)
#define INSERT(va,vb) va.insert(va.end(), vb.begin(), vb.end())
using namespace std;
typedef vector<int> vint;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};

//vector< vector<int> > v (size1, vector<int>(size2) );

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

	ll n;
	cin>>n;
	ll a;
	ll odd = 0;
	ll four = 0;
	ll two = 0;

	
	FOR(i,0,n){
		cin>>a;
		if (a%2==1) odd++;
		else if (a%4==0) four++;
		else if (a%2==0) two++;
	}

	if (four>=odd) cout<<"Yes"<<endl;
	else if (four==odd-1 && two==0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

}

Measured memory_bytes: 256
hoge=input()
str=input()

dic={}
for alp in str:
    if alp in dic:
        dic[alp] += 1
    else:
        dic[alp] = 1

ans=1

for alp,num in dic.items():
    ans *= (num+1)

ans -= 1
print(ans%(10**9 + 7))


Measured memory_bytes: 3188
import java.util.PriorityQueue;
import java.util.Scanner;

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

    void solve(Scanner sc) {
        int n = sc.nextInt();
        int m = sc.nextInt();
        PriorityQueue<Shop> shops = new PriorityQueue<>(n, (x, y) -> {
            if (x.price == y.price) {
                return 0;
            } else if (x.price > y.price) {
                return 1;
            } else {
                return -1;
            }
        });

        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            Shop shop = new Shop(a, b);
            shops.add(shop);
        }

        long ans = 0;
        long tmp = 0;
        while (tmp < m) {
            Shop s = shops.poll();
            if (m - tmp >= s.stock) {
                ans += s.price * s.stock;
                tmp += s.stock;
            } else {
                ans += s.price * (m - tmp);
                tmp += m - tmp;
            }
        }
        System.out.println(ans);
    }
}

class Shop {
    public long price;
    public long stock;

    Shop(long price, long stock) {
        this.price = price;
        this.stock = stock;
    }
}


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

typedef long long ll;
typedef unsigned long long ull;

int main() {
    int A, B, Q;
    cin >> A >> B >> Q;
    vector<ll> s(A), t(B);
    rep(i, A) cin >> s[i];
    rep(i, B) cin >> t[i];
    ll x;
    vector<int> a(2), b(2);
    rep(i, Q) {
        cin >> x;
        int j = lower_bound(s.begin(), s.end(), x) - s.begin();
        a[0] = max(0, j - 1), a[1] = min(j, A - 1);
        j = lower_bound(t.begin(), t.end(), x) - t.begin();
        b[0] = max(0, j - 1), b[1] = min(j, B - 1);
        ll ans = 1e18;
        rep(j, 2) {
            rep(k, 2) {
                ans = min(ans, abs(x - s[a[j]]) + abs(s[a[j]] - t[b[k]]));
                ans = min(ans, abs(x - t[b[k]]) + abs(s[a[j]] - t[b[k]]));
            }
        }
        cout << ans << "\n";
    }
}

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

typedef long long ll;

int main() {
    int N;
    string S;
    int cnt;
    cin >> N;
    cin >> S;
    for (int i = 0; i < 1000; i++) {
        int c[3] = {i/100, (i/10) % 10, i % 10};
        int f = 0;
        for (int j = 0; j < N; j++) {
            if (S[j] == ('0'+c[f])) f++;
            if (f == 3) break;
        }
        if (f == 3) cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 111111
int n,i,j;
double pw,w[N],f[N],v[N],t[N],l,r,p,q,a,e;
double c(double x){
  for(e=pw*x,j=0;j<n;j++) e+=max(0.0,(t[j]-w[j]*x)*f[j]/v[j]);
  a=min(a,e);
  return e;
}
int main(){
  while(cin>>n,n){
    for(cin>>pw,i=0;i<n;i++) scanf("%lf%lf%lf%lf",w+i,f+i,v+i,t+i);
    for(i=0,l=0,r=1e9,a=c(0);i<100;i++) p=l+(r-l)/3,q=l+(r-l)*2/3,(c(p)>c(q))?l=p:r=q;
    cout<<a<<endl;
  }
  return 0;
}

Measured memory_bytes: 6480
#include <stdio.h>
#include <math.h>
  
  
int main(void)
{
double x[100], y, max = 0.0, D1 = 0.0, D2 = 0.0, D3 = 0.0;
int n, i;
  
scanf("%d", &n);
  
for (i = 0; i < n; i++) {
scanf("%lf", &x[i]);
}
  
for (i = 0; i < n; i++) {
scanf("%lf", &y);
x[i] = x[i] - y;
if (x[i] < 0) x[i] = -x[i];
if (x[i] > max) max = x[i];
}
  
for (i = 0; i < n; i++) {
D1 += y = x[i];
D2 += y *= y;
D3 += x[i] * y;
}
printf("%20.8lf\n", D1);
printf("%20.8lf\n", sqrt(D2));
printf("%20.8lf\n", cbrt(D3));
printf("%20.8lf\n", max);
  
return 0;
}

Measured memory_bytes: 688
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

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

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

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

int n;
string s[100];

void solve() {
	int cnt[26] = {0};
	int i, j;
	
	for (i = 0; i < n; i++) {
		int id = s[i][0] - 'A';
		cnt[id]++;
		
		int scnt[26];
		for (j = 0; j < 26; j++) { scnt[j] = cnt[j]; }
		sort(scnt, scnt + 26, greater<int>());
		if (scnt[0] > scnt[1] + n - (i + 1)) {
			//?¢????
			int maxi = -1;
			char ans;
			for (j = 0; j < 26; j++) {
				if (maxi < cnt[j]) {
					maxi = cnt[j];
					ans = 'A' + j;
				}
			}
			cout << ans << " " << i + 1 << endl;
			return;
		}
	}
	cout << "TIE" << endl;
}

int main() {
	while (cin >> n) {
		if (!n) break;
		for (int i = 0; i < n; i++) cin >> s[i];
		solve();
	}
	return 0;
}

Measured memory_bytes: 3104