akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define DEBUG true
#ifdef ONLINE_JUDGE
#undef DEBUG
#define DEBUG false
#endif 

using namespace std;

#define MAXN ((int)2e5+5)
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9 + 9)
#define ll long long
#define _ << " " <<
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define TRACE(x) if(DEBUG) cerr << #x << " = " << x << endl;
#define TRACE2(x,y) if(DEBUG) cerr << #x << " = " << x << " | " << #y << " = " << y << endl;
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl "\n"
#define pii pair<int,int>
#define mid ((l+r)/2)

int n;
vector <int> d;

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	cin >> n;
	d.resize(n);
	for (int i = 0; i < n; ++i)
		cin >> d[i];

	int ans = 0;
	for (int i = 0; i < n - 1;)
	{
		int save = i;
		while(d[i] >= d[i+1] && i < n - 1) i++;
		ans = max(ans, i-save);
		
		i++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 640
#include<stdio.h>

int main(void)
{
        double a,b;

        scanf("%lf",&a);
        scanf("%lf",&b);

        if(a>b)
                printf("GREATER\n");
        else if(a<b)
                printf("LESS\n");
        else
                printf("EQUAL\n");

        return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{
  
  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String sl[];

    sl = r.readLine().split(" ");
    int n = Integer.parseInt(sl[0]);
    int a = Integer.parseInt(sl[1]);
    int b = Integer.parseInt(sl[2]);
    
    System.out.println(n * a < b ? n * a : b);
    
  }

}


Measured memory_bytes: 23124
N = list(input())
N2 = list(map(int,N))

if len(N2) == 1:
  print("0")
  exit()

counter = 0
c = 1

while len(N2) > 0 and c <= len(N2)-1:
  # print(N2,c)
  before = N2[c-1]

  if before == 0 and N2[c] == 1:
    N2.pop(c-1)
    N2.pop(c-1)

    c -= 2
    counter += 2

    if len(N2) == 0:
      break

    if c <= 0:
      before = N2[0]
      c = 1
    else:
      before = N2[c-1]

  elif before == 1 and N2[c] == 0:
    N2.pop(c-1)
    N2.pop(c-1)

    c -= 2
    counter += 2

    if len(N2) == 0:
      break

    if c <= 0:
      before = N2[0]
      c = 1
    else:
      before = N2[c-1]

  else:
    c += 1

print(counter)

Measured memory_bytes: 4776
#include <stdio.h>
#include <stdlib.h>


int main() {
	int N, i, total = 0, candies=0;

	scanf("%d", &N);

	for (i= 0; i < N+1; i++){
		candies = i;
		total = total + candies; 
	}

	printf("%d\n", total);

	return 0;
}


Measured memory_bytes: 1732
import sys
n,x=map(int,input().split())
a=list(map(int,input().split()))
k=-1
for i in range(n-1):
  if a[i]+a[i+1]>=x:
    k=i
    break
  if i==n-2:
    print('Impossible')
    sys.exit()
print('Possible')
for i in range(k):
  print(i+1)
for i in range(n-2,k,-1):
  print(i+1)
print(k+1)

Measured memory_bytes: 84616
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int R; cin >> R;
	if (R < 1200){
		cout << "ABC" << endl;
	}else
	if (R < 2800){
		cout << "ARC" << endl;
	}else{
		cout << "AGC" << endl;
	} // end if

	return 0;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
	ll N, K;
	cin >> N >> K;
	vecl(A);
	fx(N) {
		vecpl(A);
	}

	ll mask = 1ll << 62;
	ll ans = 0;
	while (mask > K) {
		mask >>= 1;
	}
	while (mask>0) {
		int count = 0;
		fx(N) {
			count += (A[x] & mask) == 0 ? 1 : 0;
		}
		if (count>N/2 &&ans+mask<=K) {
			ans += mask;
		}
		mask >>= 1;
	}
	ll res = 0;
	fx(N) {
		res += A[x] ^ ans;
	}
	ce(res)

    return 0;
}



Measured memory_bytes: 1400
using System;
using System.Linq;
using System.Collections.Generic;

class MyClass
{
    public static void Main(string[] args)
    {
        var n = 0;
        while ((n = int.Parse(Console.ReadLine())) != 0)
        {
            var s = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var m = s.Average();
            var stddev = Math.Sqrt(s.Sum(x => Math.Pow(x-m,2)) / n);
            Console.WriteLine(stddev);
        }
   }
}


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

#define rep(i, n)  for (int i = 0; i < (int) (n); i++)
#define Rrep(i, n) for (int i = ((int) n - 1); i >= 0; i--)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
#define INF 2e15
#define MOD 10e9 + 7

typedef vector <int> vint;
typedef long long    ll;



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

    int a, b;
    cin >> a >> b;
    if (a > b) {
        rep(i, a) {
            cout << b;
        }
        cout << endl;

        return 0;
    }
    else {
        rep(i, b) {
            cout << a;
        }
        cout << endl;

        return 0;
    }


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int MAX=1000000007;

  
signed main() {
    string s;
    cin>>s;
    int ans[s.length()]={},a1=0,a2=0;
    for(int i=0;i<s.length();i++){
      if(s[i]=='R'){
        if(i%2==0)a1++;
        else a2++;
      }else{
        if(i%2==0){
          ans[i]+=a1;
          ans[i-1]+=a2;
          a1=0;a2=0;
      }else{
        ans[i]+=a2;
        ans[i-1]+=a1;
        a1=0;a2=0;
      }
    }
    }
    a1=0;a2=0;
    for(int i=s.length()-1;i>=0;i--){
      if(s[i]=='L'){
        if(i%2==0)a1++;
        else a2++;
      }else{
        if(i%2==0){
          ans[i]+=a1;
          ans[i+1]+=a2;
          a1=0;a2=0;
      }else{
        ans[i]+=a2;
        ans[i+1]+=a1;
        a1=0;a2=0;
      }
    }
    }
    for(int i=0;i<s.length();i++)cout<<ans[i]<<' ';
    return 0;
}


Measured memory_bytes: 1408
using System;
using System.Collections.Generic;
using System.Linq;

namespace question3
{
    class Program
    {
        static void Main(string[] args)
        {
            var p = new Program();
            p.Run();
        }

        void Run()
        {
            var line1 = Console.ReadLine();
            var n = int.Parse(line1.Split(' ')[0]);
            var m = int.Parse(line1.Split(' ')[1]);

            var inputs = new List<Tuple<int,int>>();
            var cities = new List<Tuple<int, int, int>>[n];
            var citiesNumbers = new Dictionary<Tuple<int, int>, string>();

for(int i=0;i<n;i++){
    cities[i] = new List<Tuple<int,int,int>>();
}
            for (int i = 0; i < m; i++)
            {
                var line = Console.ReadLine().Split(' ');
                var pi = int.Parse(line[0]);
                var yi = int.Parse(line[1]);

                inputs.Add(new Tuple<int,int>(pi,yi));
                cities[pi-1].Add(new Tuple<int, int, int>(pi, yi, i));
            }

            for (int i = 0; i < n; i++)
            {
                var list = cities[i].OrderBy(e => e.Item2);
                var c = 0;
                foreach (var elem in list)
                {
                    citiesNumbers.Add(new Tuple<int, int>(elem.Item1, elem.Item2), String.Format("{0:000000}{1:000000}", elem.Item1, c + 1));
                    c++;
                }
            }

            foreach(var i in inputs){
                Console.WriteLine($"{citiesNumbers[Tuple.Create(i.Item1,i.Item2)]}");
            }
        }
    }
}


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

typedef long long ll;
#define MAX_N 100000

void solve(long long X, long long Y){
    for(ll i = 2; i < MAX_N; ++i){
        if(X * i % Y != 0){
            cout << i * X << endl;
            return;
        }
    }
    cout << -1 << endl;
    return;
}

int main(){
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    solve(X, Y);
    return 0;
}


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

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(f, x, ...)                                                         \
    ([&] (decltype ((x)) ALL) {                                                \
        return (f) (begin (ALL), end (ALL), ##__VA_ARGS__);                    \
    }) (x)

using namespace std;
using ll = int64_t;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    bool flg = false;
    if (A == B && B != C)
        flg = true;
    else if (B == C && C != A)
        flg = true;
    else if (C == A && A != B)
        flg = true;
    cout << (flg ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
int n,power1[maxn],power2[maxn];
string x;
int main()
{
	cin>>n>>x;
	int cnt=0;
	for(int i=0;i<n;i++)
		if(x[i]=='1')
			cnt++;
	if(cnt==0)
	{
		for(int i=0;i<n;i++)
			cout<<1<<endl;
		return 0;
	}
	power1[n-1]=1%(cnt+1);
	for(int i=n-2;i>=0;i--)
		power1[i]=power1[i+1]*2%(cnt+1);
	int sum1=0;
	for(int i=0;i<n;i++)
		if(x[i]=='1')
			sum1=(sum1+power1[i])%(cnt+1);
	int sum2=0;
	if(cnt>1)
	{
		power2[n-1]=1%(cnt-1);
		for(int i=n-2;i>=0;i--)
			power2[i]=power2[i+1]*2%(cnt-1);
		for(int i=0;i<n;i++)
			if(x[i]=='1')
				sum2=(sum2+power2[i])%(cnt-1);
	}
	for(int i=0;i<n;i++)
	{
		if(x[i]=='0')
		{
			int ans=1,tmp=(sum1+power1[i])%(cnt+1);
			while(tmp)
			{
				ans++;
				tmp%=__builtin_popcount(tmp);
			}
			cout<<ans<<endl;
		}
		else
		{
			if(cnt==1)
				cout<<0<<endl;
			else
			{
				int ans=1,tmp=(sum2-power2[i]+cnt-1)%(cnt-1);
				while(tmp)
				{
					ans++;
					tmp%=__builtin_popcount(tmp);
				}
				cout<<ans<<endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 5316
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	static int count = 0;
	static int input = 0;

	public static int sum(int x, int y) {
		return (x + y) * (y - x + 1) / 2;
	}

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while (true) {
			input=0;
			count=0;
			String num = br.readLine();
			if (num.equals("0")) {
				return;
			}

			input = Integer.parseInt(num);

			for (int i = 1; i < input; i++) {
				for (int j = i+1; j < input; j++) {
					if (input == sum(i, j)) {
						count++;
						break;
					}
					if (input < sum(i, j)) {
						break;
					}
				}
			}
			System.out.println(count);
		}
	}

}



Measured memory_bytes: 24288
n, m = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(m)]
sorted(sc)

def f1():
    if m == 0:
        return 0
    for i in range(1, m):
        if sc[i - 1][0] == sc[i][0] and sc[i - 1][1] != sc[i][1]:
            return -1
    return sc[0][1]

def f2():
    if m == 0:
        return 10
    for i in range(1, m):
        if sc[i - 1][0] == sc[i][0] and sc[i - 1][1] != sc[i][1]:
            return -1
    l = [10 * i + j for i in range(1, 10) for j in range(0, 10)]
    sl = ["1", "0"]
    for i in range(m):
        sl[sc[i][0] - 1] = str(sc[i][1])
    s = sl[0] + sl[1]
    for i in l:
        if str(i) == s:
            return i
    return -1

def f3():
    if m == 0:
        return 100
    for i in range(1, m):
        if sc[i - 1][0] == sc[i][0] and sc[i - 1][1] != sc[i][1]:
            return -1
    l = [100 * i + 10 * j + k for i in range(1, 10) for j in range(0, 10) for k in range(0, 10)]
    sl = ["1", "0", "0"]
    for i in range(m):
        sl[sc[i][0] - 1] = str(sc[i][1])
    s = sl[0] + sl[1] + sl[2]
    for i in l:
        if str(i) == s:
            return i
    return -1

if n == 1:
    print(f1())
elif n == 2:
    print(f2())
else:
    print(f3())


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int n,k;
vector<pair<int,int>>v;
int main(){
	cin>>n>>k;
	if((n-1)*(n-2)/2<k){
		puts("-1");
		return 0;
	}
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			v.push_back({i,j});
		}
	}
	rep(i,k)v.pop_back();
	cout<<v.size()<<endl;
	for(pair<int,int> p:v)cout<<p.first<<" "<<p.second<<endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define MMOD(i) ((i%MOD)+MOD)%MOD;
#define all(v) v.begin() , v.end()
#define vec(i,j) vector<vector<ll>>(i,vector<ll>(j,0))
#define input(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;
const ll MAX_N=100010;
ll a,b,c,d,e,f,x,y,z,k,m,n,l,h,w,t,p,q,ans=0;
vl v,v2,dp(1000,INF);
stack<ll> ss;
ll solve(){
	ans=INF;
    dp[0]=0;
    for(ll i=1;i<201;i++){
        rep(j,4){
            if(i>v[j]-1)dp[i]=min(dp[i-v[j]]+v2[j],dp[i]);
        }
    }
 
    for(ll i=n;i<201;i++){
    	ans=min(ans,dp[i]);
    }
 
    return ans;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n;
    input(v2,4);
    input(v,4);
    cout<<solve()<<endl;
}


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

int main() {
  int A,B;
  string S,T,U;
  cin >> S >> T;
  cin >> A >> B;
  cin >> U;
  if(S==U) {
    A = A - 1;
  }
    if(T==U) {
    B = B - 1;
  }
  cout << A << " " << B << endl;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    h = [int(i) for i in input().split()]
    cost = [0 for _ in range(n)]
    cost[0] = 0
    cost[1] = abs(h[1] - h[0])
    for i in range(2, n):
        cost[i] = min(cost[i-1]+abs(h[i] - h[i-1]), cost[i-2]+abs(h[i] - h[i-2]))
    print(cost[-1])
main()


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

int h[200000];

int main()

{
	int n,i,k;
	long long z=0;
	cin>> n >>k;
	for(i=0;i<n;i++)
		cin >> h[i];

	sort(h,h+n);
	for(i=0;i<n-k;i++)
		z=z+h[i];
	cout << z;
	
}


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

int main()
{
    int n;
    cin >> n;
    n = n % 10;
    if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9)
    {
        cout << "hon";
    }
    if(n == 0 || n == 1 || n == 6 || n == 8)
    {
        cout << "pon";
    }
    if(n == 3){cout << "bon";}

    return 0;
}

Measured memory_bytes: 3596
def main():
    N, T = (int(i) for i in input().split())
    AB = [[int(i) for i in input().split()] for j in range(N)]
    A = [a[0] for a in AB]
    B = [b[1] for b in AB]

    dp1 = [[0]*(T+1) for _ in range(N+1)]
    for i in range(N):
        for j in range(T):
            t = j - A[i]
            if 0 <= t:
                dp1[i+1][j] = max(dp1[i][j], dp1[i][t] + B[i])
            else:
                dp1[i+1][j] = dp1[i][j]
    dp2 = [[0]*(T+1) for _ in range(N+2)]
    for i in range(1, N+1)[::-1]:
        for j in range(T):
            t = j - A[i-1]
            if 0 <= t:
                dp2[i][j] = max(dp2[i+1][j], dp2[i+1][t] + B[i-1])
            else:
                dp2[i][j] = dp2[i+1][j]
    ans = 0
    for i in range(N):
        for j in range(T):
            ans = max(ans, dp1[i][j] + dp2[i+2][T - 1 - j] + B[i])
    print(ans)


if __name__ == '__main__':
    main()


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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i, x) for (long long i = 0; i < x; i++)
#define repn(i, x) for (long long i = 1; i <= x; i++)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin())
#define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin())
vector<pair<string, P>> vec;
// vector<vector<int>> data(3, vector<int>(4));

const string NO = "Impossible";

struct uf_tree {
    std::vector<int> parent;
    int __size;
    uf_tree(int size_) : parent(size_, -1), __size(size_) {}
    void unite(int x, int y) {
        if ((x = find(x)) != (y = find(y))) {
            if (parent[y] < parent[x]) std::swap(x, y);
            parent[x] += parent[y];
            parent[y] = x;
            __size--;
        }
    }
    bool is_same(int x, int y) { return find(x) == find(y); }
    int find(int x) { return parent[x] < 0 ? x : parent[x] = find(parent[x]); }
    int size(int x) { return -parent[find(x)]; }
    int size() { return __size; }
};

void solve(long long N, long long M, std::vector<long long> a, std::vector<long long> x, std::vector<long long> y) {
    if (N - 1 == M) {
        cout << "0" << endl;
        return;
    }
    if (M == 0) {
        if (N == 2) cout << a[0] + a[1] << endl;
        if (N >= 3) cout << NO << endl;
        return;
    }
    if (N < 2 * (N - M - 1)) {
        cout << NO << endl;
        return;
    }
    vector<pair<ll, ll>> v(N);
    rep(i, N) { v[i] = make_pair(a[i], i); }
    SORT(v);

    uf_tree ut(N);
    rep(i, M) { ut.unite(x[i], y[i]); }
    vector<bool> used(N);
    set<ll> st;

    ll res = 0, c = 0;
    rep(i, N) {
        ll id = v[i].second;
        if (st.find(ut.find(id)) == st.end()) {
            res += v[i].first;
            used[id] = true;
            st.insert(ut.find(id));
            c++;
        }
    }

    rep(i, N) {
        ll id = v[i].second;
        if (!used[id] && c < 2 * (N - M - 1)) {
            c++;
            res += v[i].first;
        }
    }

    cout << res << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    std::vector<long long> a(N - 1 - 0 + 1);
    for (int i = 0; i < N - 1 - 0 + 1; i++) {
        scanf("%lld", &a[i]);
    }
    std::vector<long long> x(M);
    std::vector<long long> y(M);
    for (int i = 0; i < M; i++) {
        scanf("%lld", &x[i]);
        scanf("%lld", &y[i]);
    }
    solve(N, M, std::move(a), std::move(x), std::move(y));
    return 0;
}


Measured memory_bytes: 6144
#include <iostream>
#include <string>
#include <sstream>
using namespace std;

void eo(int a){
	if     (a==0) cout << " + ";
	else if(a==1) cout << " - ";
	else          cout << " * ";
}

void po(int a,int b,int c,int d,int p[3],int e[3]){
	if(p[0]==0){
		if(p[1]==1){ cout << "((" << a; eo(e[0]); cout << b << ")"; eo(e[1]); cout << c << ")"; eo(e[2]); cout << d << endl; }
		else{ cout << "(" << a; eo(e[0]); cout << b << ")"; eo(e[1]); cout << "(" << c; eo(e[2]); cout << d << ")" << endl; }
	}
	else if(p[0]==1){
		if(p[1]==0){ cout << "(" << a; eo(e[0]); cout << "(" << b; eo(e[1]); cout << c << "))"; eo(e[2]); cout << d << endl; }
		else{ cout << a; eo(e[0]); cout << "((" << b; eo(e[1]); cout << c << ")"; eo(e[2]); cout << d << ")" << endl; }
	}
	else{
		if(p[1]==1){ cout << a; eo(e[0]); cout << "(" << b; eo(e[1]); cout << "(" << c; eo(e[2]); cout << d << "))" << endl; }
		else{ cout << a; eo(e[0]); cout << "((" << b; eo(e[1]); cout << c << ")"; eo(e[2]); cout << d << ")" << endl; }
	}
}

int fn(int a,int b,int c){
	if     (c==0) return a+b;
	else if(c==1) return a-b;
	else          return a*b;
}

int calc(int a,int b,int c,int d,int p[3],int e[3]){
	if(p[0]==0){
		if(p[1]==1) return fn(fn(fn(a,b,e[0]),c,e[1]),d,e[2]);
		else        return fn(fn(a,b,e[0]),fn(c,d,e[2]),e[1]);
	}
	else if(p[0]==1){
		if(p[1]==0) return fn(fn(a,fn(b,c,e[1]),e[0]),d,e[2]);
		else        return fn(fn(a,b,e[0]),fn(c,d,e[2]),e[1]);
	}
	else{
		if(p[1]==0) return fn(a,fn(fn(b,c,e[1]),d,e[2]),e[0]);
		else        return fn(a,fn(b,fn(c,d,e[2]),e[1]),e[0]);
	}
}
int main(){
	int a,b,c,d;
	while(1){
		int R[4];
		cin >> R[0] >> R[1] >> R[2] >> R[3];
		if(R[0]+R[1]+R[2]+R[3]==0) break;
		bool x = false;
		for(int Z0=0;Z0<4;Z0++){
		for(int Z1=0;Z1<4;Z1++){
		for(int Z2=0;Z2<4;Z2++){
			if(Z1==Z0) continue;
			if(Z2==Z0) continue;
			if(Z2==Z1) continue;
			int Z3 = 6-Z0-Z1-Z2;
			int a = R[Z0];
			int b = R[Z1];
			int c = R[Z2];
			int d = R[Z3];

		for(int i=0;i<3;i++){ for(int j=0;j<3;j++){ for(int k=0;k<3;k++){
			for(int l=0;l<3;l++){
			for(int m=0;m<3;m++){
				if(l==m) continue;
				int n = 3-l-m;
				int p[3] = {l,m,n};
				int e[3] = {i,j,k};
				if(calc(a,b,c,d,p,e)==10){
					po(a,b,c,d,p,e);
					x = true;
				}
				if(x) break;
			}
			if(x) break;}
		if(x) break;} if(x) break;} if(x) break;}
		if(x) break;} if(x) break;} if(x) break;}
		if(not x) cout << 0 << endl;
	}
}

Measured memory_bytes: 1164
#include<iostream>
#include<stdio.h>
#include<math.h>

int main()
{
	int n;
	std::cin >> n;
	
	while( n-- ){
	 	double x[2], y[2], r[2];
		for( int i = 0; i < 2; i++ ){
			std::cin >> x[i] >> y[i] >> r[i];
		}
		
		double d = sqrt( pow( x[1] - x[0], 2 ) + pow( y[1] - y[0], 2 ) );
		
		if( d > r[0] + r[1] ){
		 	puts("0");
		}
		else if( d < fabs( r[0] - r[1] ) ){
			std::cout << (  r[0] > r[1] ? 1 : -1 ) * 2 << std::endl;
		}
		else{
			puts("1");
		}
	}

 	return 0;
}

Measured memory_bytes: 1232
#!/usr/bin/env python3
import sys
import collections as cl


def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def LI(): return list(map(int, sys.stdin.readline().split()))


MOD = 998244353


def main():
    N, K = MI()

    kukan = []
    for _ in range(K):
        tmp = LI()
        kukan.append(tmp)

    dp = [0] * (N + 1)
    dp[1] = 1
    dp_sum = [0] * (N+1)
    dp_sum[1] = 1

    for i in range(N+1):
        for k in range(K):
            l, r = kukan[k]
            pre_l = i - r
            pre_r = i - l
            if pre_r < 0:
                continue
            pre_l = max(pre_l, 0)
            dp[i] += dp_sum[pre_r] - dp_sum[pre_l - 1]

        dp_sum[i] = dp[i] + dp_sum[i-1]
        dp_sum[i] %= MOD
        dp[i] %= MOD

    print(dp[-1])


main()


Measured memory_bytes: 77096
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

struct ST {
  ll X;
  ll Y;
};
bool operator<(const ST& a, const ST& b){
  if(a.X == b.X) return a.Y < b.Y;
  return a.X < b.X;
}

int main(){
  ll A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;

  ST best;
  best.X = 100*A;
  best.Y = 0;
  
  ST st;
  st.X = 0;
  st.Y = 0;

  map<ST,int> memo;
  queue<ST> que;
  que.push(st);
  while(!que.empty()){
    st = que.front(); que.pop();
    if(st.X + st.Y > F) continue;
    if(100 * st.Y > E * st.X) continue;
    if(memo.count(st) > 0) continue;
    memo[st] = 1;

    if( (100 * best.Y) * (st.X + st.Y) < (100 * st.Y) * (best.X + best.Y) ){
      best = st;
    }

    que.push((ST){st.X+100*A,st.Y});
    que.push((ST){st.X+100*B,st.Y});
    que.push((ST){st.X,st.Y+C});
    que.push((ST){st.X,st.Y+D});

  }

  cout << best.X + best.Y << " " << best.Y << endl;
  
  return 0;
}



Measured memory_bytes: 768
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
namespace mp = boost::multiprecision;
using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  string s;
  ll aa,bb;
  aa=bb=0;
  cin>>s;
  ll a,b;
  a=(s[0]-'0')*10+(s[1]-'0');
  b=(s[2]-'0')*10+(s[3]-'0');
  if(a>12||a==0){
    aa=1;
  }
  if(b>12||b==0){
    bb=1;
  }
  if(aa&&bb){
    cout<<"NA"<<endl;
  }
  else if(aa){
    cout<<"YYMM"<<endl;
  }
  else if(bb){
    cout<<"MMYY"<<endl;
  }
  else{
    cout<<"AMBIGUOUS"<<endl;
  }
}


Measured memory_bytes: 888
//#include <tourist>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
ll n, l;
vector<ll> a;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>l;
    ll center=-1;
    for (int i = 0; i < n; i++)
    {
        ll temp;
        cin >> temp;
        a.push_back(temp);
    }
    for (int i = 0; i < n-1; i++)
    {
        if(a[i]+a[i+1]>=l){
            center=i;
        }
    }
    if(center==-1){
        return cout<<"Impossible"<<"\n",0;
    }
    cout<<"Possible"<<"\n";
    for(int i=0;i<center;i++){
        cout<<i+1<<"\n";
    }
    for(int i=n-2;i>=center;i--){
        cout<<i+1<<"\n";
    }
}



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

bool possible(const vector<int> &a){
    if(a.size()<=1u)return true;
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
    for(size_t i=0; i<a.size(); i++){
        pq.push(make_pair(a[(i+1)%a.size()]-a[i], i));
    }
    int dec=0;
    long long zero=0LL;
    while(true){
        pair<int, int> cur=pq.top();
        pq.pop();
        //fprintf(stderr, "pos = %d, delta = %d\n", cur.second, cur.first-dec);
        if(cur.first-dec>0)return false;
        if(cur.first-dec==0){
            while(!pq.empty()){
                if(pq.top().first-dec!=0){
                    return false;
                }
                pq.pop();
            }
            break;
        }
        int multi=(-cur.first+dec+((int)a.size())-1)/((int)a.size());
        cur.first+=((int)a.size())*multi;
        pq.push(cur);
        zero+=(a.size()*1LL-cur.second)*multi;
        dec+=multi;
        if(zero>a[0]*1LL)return false;
    }
    if(zero!=a[0]*1LL){
        return false;
    }
    return true;
}

int main(){
    int n;
    while(scanf("%d", &n)!=EOF){
        vector<int> a(n, 0);
        for(int i=0; i<n; i++){
            scanf("%d", &a[i]);
        }
        if(possible(a)){
            printf("YES\n");
        }else{
            printf("NO\n");
        }
    }
    return 0;
}

Measured memory_bytes: 1784
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstdio>
using namespace std;

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)
static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;


class Point
{
public:
	double x, y;
	Point(double x = 0, double y = 0) :x(x), y(y) {}

	Point operator + (Point p) { return Point(x + p.x, y + p.y); }
	Point operator - (Point p) { return Point(x - p.x, y - p.y); }
	Point operator * (double a) { return Point(a * x, a * y); }
	Point operator / (double b) { return Point(x / b, y / b); }
	friend istream& operator >> (istream & s, Point p) { s >> p.x >> p.y; }

	double dot(Point a, Point b) { return a.x* b.x + a.y * b.y; }
	double abs() { return sqrt(norm()); }
	double norm() { return x * x + y * y; }

	bool operator <(const Point & p)const { return x != p.x ? x < p.x : y < p.y; }
	bool operator == (const Point & p) const { return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS; }
};
typedef Point Vector;

struct Segment {
	Point p1, p2;
	Segment() {}
	Segment(Point p1, Point p2) :p1(p1), p2(p2) {}
};
typedef Segment Line;

double norm(Vector a) { return a.x* a.x + a.y * a.y; }
double abs(Vector a) { return sqrt(norm(a)); }

double dot(Vector a, Vector b) { return a.x* b.x + a.y * b.y; }
double cross(Vector a, Vector b) { return a.x* b.y - a.y * b.x; }

int ccw(Point p0, Point p1, Point p2) {
	Vector a = p1 - p0;
	Vector b = p2 - p0;
	if (cross(a, b) > EPS) return COUNTER_CLOCKWISE;
	if (cross(a, b) < -EPS) return CLOCKWISE;
	if (dot(a, b) < -EPS) return ONLINE_BACK;
	if (a.norm() < b.norm()) return ONLINE_FRONT;
	else return ON_SEGMENT;
}

bool isOrthogonal(Vector a, Vector b) { return equals(dot(a, b), 0.0); }
bool isParallel(Vector a, Vector b) { return equals(cross(a, b), 0.0); }

int main(){
  int n;cin>>n;
  double x0,y0,x1,y1,x2,y2,x3,y3;
  while(n--){
    cin>>x0>>y0>>x1>>y1>>x2>>y2>>x3>>y3;
    Point p0=Point(x0,y0),p1=Point(x1,y1),p2=Point(x2,y2),p3=Point(x3,y3);
    if(isParallel(p0-p1,p2-p3)) cout << 2 << endl;
    else if(isOrthogonal(p0-p1,p2-p3)) cout << 1 << endl;
    else cout << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 3232
<?php
$input = STDIN;

$slopes = trim(fgets($input));
$down = [];
$areas = [];
$left_edges = [];

foreach (str_split($slopes) as $pos => $slope) {
    if ($slope === "\\") {
        $down[] = $pos;
    } elseif ($slope === "/" && $down) {
        $left_edge = array_pop($down);
        $area = $pos - $left_edge;

        while ($areas && $left_edge < end($left_edges)) {
            $pre_area = array_pop($areas);
            array_pop($left_edges);

            $area += $pre_area;
        }
        array_push($areas, $area);
        array_push($left_edges, $left_edge);
    }
}

print array_sum($areas) . "\n";
array_unshift($areas, count($areas));
print implode(" ", $areas) . "\n";


Measured memory_bytes: 15724
/*
  Author - KISHAN TIWARI
  Dream bigger. Do bigger.
  Wake up with determination. Go to bed with satisfaction.
*/
//Sometimes later becomes never. Do it now.
#include<bits/stdc++.h>
using namespace std;
#define ll           long long
#define f(i,a,b)     for(ll i=a;i<b;i++)
#define mod          1000000007
#define fi           first
#define se           second
#define pa           pair <ll,ll>
#define mp           make_pair
#define pb           push_back
#define ve           vector<ll>
#define vep          vector< pa >
#define all(a)       a.begin(), a.end()
#define sz(x)        (ll)x.size()
#define c(t)         cout<<t<<"\n"
using namespace std;
void solve()
{  ll n,m;
cin>>n>>m;
multiset<ll> s;
pa a[100001];
f(i,0,n)
{
    cin>>a[i].se>>a[i].fi;
}
sort(a,a+n,greater<pa>());
ll ans=0;
f(i,0,m+1)
 s.insert(i);
 f(i,0,n)
 {
     ll y=m-a[i].se;
     if(s.upper_bound(y)==s.begin())
        continue;
    multiset<ll>::iterator t=(s.upper_bound(y));
    t--;
     s.erase(t);
     ans+=a[i].fi;
 }
c(ans);
}
int main()
{
    ios::sync_with_stdio(true);
   //freopen ("input.txt","r",stdin);
   //freopen ("output.txt","w",stdout);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
    //cin>>t;
    while(t--)
    {

        solve();
    }
return 0;
}


Measured memory_bytes: 6528
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = long long;
#define rep(i, n) for (in i = 0; i < (in)(n); i++)
#define REP(i,a,b) for(in i=(in)(a);i<(in)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007ll;
const in INF=1<<30;
using P=pair<in,in>;
vector<in> dx={0,1,-1,0};
vector<in> dy={1,0,0,-1};

//dijkstraの負も出来る版
//O(V*E)  V:頂点数,E:辺の数
//close=trueの時、負の閉路に到達
using T=tuple<in,in,in>;
const in MAX_dist=(in)(1e18);
vector<T> graph(0);//from,to,cost
vector<in> d(0);
in V,E;//V:頂点数,E:辺の数
bool close=false;
in ans1=MAX_dist,ans2=MAX_dist;

void init(in n){//辺をgraphに入れた後に
    d.resize(n,MAX_dist);
    V =n;
    // neg.resize(n,false);
}

void Bellman(in s,in n){//s:始点
    E=graph.size();
    d[s]=0;
    in close_cnt=0;
    close=false;
    while(1){//V回以上のループで負閉路に到達
        close_cnt ++;
        bool update=0;
        for(auto e: graph){
            in from,to,cost;
            tie(from,to,cost)=e;
            if(d[from]!=MAX_dist && d[to]>d[from]+cost){
                update =true;
                d[to]=d[from]+cost;
            }
        }
        if(!update) break;
        if(close_cnt==V+1ll) ans1=d[n-1];
        if(close_cnt==V*2+1ll){ans2=d[n-1];break;}
    }
}


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10); 
    in n,m,a,b,c;
    cin>>n>>m;
    init(n);
    rep(i,m){
        cin>>a>>b>>c;
        c=-c;
        a --,b--;
        graph.emplace_back(a,b,c);
    }
    Bellman(0ll,n);
    in ans =d[n-1];
    ans *=(-1ll);
    if(ans1!=ans2 && ans2!=MAX_dist) cout<<"inf"<<endl;
    else cout<<ans<<endl;
}

Measured memory_bytes: 384
fun main(args: Array<String>) {
    val list = readLine()!!.split(" ").map(String::toInt)
    var A = list[0]
    var B = list[1]
    val C = A - B * 2
    if(C < 0) {
        println(0)
    } else {
        println(C)
    }
}

Measured memory_bytes: 37928
#include<iostream>
#include<algorithm>
#define LL long long
int N;
int A[100010];
LL sum;

int main() {
	std::cin >> N;
	for (int i = 1; i <= N; i++) {
		std::cin >> A[i];
		sum += A[i];
		if (i == 0)A[0] = A[N];
	}
	LL D = (((LL)N + 1)*(LL)N) / 2;
	if (sum%D) {
		std::cout << "NO" << std::endl;
		return 0;
	}
	int ave = sum / D;
	for (int i = 1; i < N; i++) {
		int tmp = A[i] - A[i + 1] + ave;
		if (tmp < 0 || tmp % N) {
			std::cout << "NO" << std::endl;
			return 0;
		}
	}
	std::cout << "YES" << std::endl;
	return 0;
}


Measured memory_bytes: 640
from sys import stdin
input = stdin.readline

n, k = map(int, input().split())
arr = list(tuple(map(int, input().split())) for _ in range(n))
arr = sorted(arr, key=lambda x:x[0])
res = 0
for i in range(n):
    tk = min(k, arr[i][1])
    res += tk*arr[i][0]
    k -= tk
print(res)

Measured memory_bytes: 58204
#include <iostream>
#include <math.h>

using namespace std;

int main() {
	int N, count = 0;
	long long x, y, D;

	cin >> N >> D;
	for (int i = 0; i < N; ++i) {
		cin >> x >> y;
		long long tmp = x * x + y * y;
		if (tmp <= D * D) {
			count++;
		}
	}
    std::cout << count << std::endl;
	return 0;
}


Measured memory_bytes: 3632
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
asorted = sorted(a)
bsorted = sorted(b)
cost = {asorted[0]+bsorted[0]}

for i in range(M):
  x, y, c = map(int, input().split())
  cost.add(a[x-1]+b[y-1]-c)
cost = sorted(cost)
print(cost[0])

Measured memory_bytes: 18648
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

int sumOfSumOfDigits(int a, int b) {

    int sum = 0;

    while (a > 0) {
        sum += a % 10;
        a /= 10;
    }
    
    while (b > 0) {
        sum += b % 10;
        b /= 10;
    }

    return sum;

}

int main() {

    int n;
    cin >> n;

    int min = 9999999;
    int sum;

    for (int a = 1; a < n; a++) {
        int b = n - a;
        sum = sumOfSumOfDigits(a, b);
        if (sum < min) min = sum;
    }

    cout << min << endl;

    return 0;

}


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


int main(){
    
    int N,R;cin>>N>>R;
    if(N<10){
        cout<<R+(10-N)*100<<endl;
        
    }
    else cout<<R<<endl;
}




Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>

using namespace boost::multiprecision;
*/

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#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 = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define debug(aa, a) fprintf(stderr, aa, a)

using ll =long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acos(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

ll lcm(ll number1, ll number2) {//lcmを求める
	return number1 / gcd(number1, number2) * number2;
}

/*-----------------------------------------ここからコード-----------------------------------------*/

int main() {

	int n;
	scanf("%d", &n);
	int a = 0, b = 0, c;
	rep(i, n){
	  scanf("%d", &c);
	  if(c % 4 == 0)++a;
	  else if(c % 2 == 0)++b;
	}
	printyn(((n - b + 1) / 2 <= a) || (n / 2) <= a);

	Please AC;
}

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

int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    vector<vector<int>> adj(n, vector<int>(0));
    vector<int> indeg(n, 0);
    for (int i=0; i<m; i++) {
        int u, v;
        scanf("%d %d", &u, &v);
        u--, v--;
        adj[u].push_back(v);
        indeg[v]++;
    }
    queue<int> q;
    for (int i=0; i<n; i++) {
        if (indeg[i]==0) q.push(i);
    }
    vector<int> longestpath(n, 0);
    while (!q.empty()) {
        int u = q.front();
        q.pop();
        for (int v: adj[u]) {
            longestpath[v] = max(longestpath[v], longestpath[u]+1);
            indeg[v]--;
            if (indeg[v]==0) q.push(v);
        }
    }

    printf("%d\n", *max_element(longestpath.begin(), longestpath.end()));
}

Measured memory_bytes: 6528
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>

using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
#define INF 999999
#define rep(i,j) for(int i=0;i<(j);++i)
#define reps(i,j,k) for(int i=j;i<k;++i)
typedef long long ll;
typedef unsigned long long ull;

int main(){
	string str;
	getline(cin,str);
	int cnt = 0;
	int len = str.size();
	string ans;
	bool f = true;
	rep(i,len){
		if(str[i] == ' '){
			if(cnt < 3 || cnt > 6){
				ans = "";
				cnt = 0;
			}
			else{
				if(f)cout << ans;
				if(!f)cout << " " << ans;
				f = false;
				cnt = 0;
				ans = "";
			}
		}
		else{
			if(str[i] == ',' || str[i] == '.')continue;
			cnt++;
			ans += str[i];
		}
	}
	if(cnt > 2 && cnt < 7)cout << " " << ans;
	cout << endl;
	return 0;
}

Measured memory_bytes: 1168
//hinagata.cpp
//作成日
//更新日
//目的
//手段
/*includes*/
#include <bits/stdc++.h>
/*namespace*/
using namespace std;
using ll= long long;
/*define macro*/
#define REP(i,n) for(ll i=0;i<(n);i++)
#define REPi(i,a,b) for(ll i=(a);i<(b);i++)
#define REPRi(i,a,b) for(ll i=(a);i>(b);i--)
#define ALL(x) (x).begin(),(x).end()

int main(){
    int N;
    cin>>N;
    if(N%2==0){
        cout<<N/2<<endl;
    }else{
        cout<<(N+1)/2<<endl;
    }
}

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

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

    int s;
    int ans = 0;
    vector<int> s_subset;
    for (int i = 0; i < N; i++)
    {
        cin >> s;
        ans += s;
        if (s % 10 != 0)
        {
            s_subset.push_back(s);
        }
    }
    if (ans % 10 == 0 && s_subset.size() > 0)
    {
        sort(s_subset.begin(), s_subset.end());
        ans -= s_subset.front();
    }

    if (ans % 10 == 0)
    {
        ans = 0;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 110 , mz = 1e9+7;

int main(){
    int n,m;
    cin>>n>>m;
    if( n == 1 && m == 1 )    puts("1");
    else if( n == 1 || m == 1 )   printf("%d\n",max(n-2,m-2));
    else cout<<1LL*n*m-m*2 - n*2 + 4<<endl;
    return 0;
}


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

typedef long long i64;
#define put(n) cout<<(n)<<"\n"
#define FOR(i,num,N) for(int(i)=(num);(i)<(N);(i)++)
#define RFOR(i,num,N) for(int (i)=(num);(i)>(N);(i)--)
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()

int main(){
    double n,m,d;
    cin>>n>>m>>d;
    if(d == 0) cout<<setprecision(12)<<(m-1)/n;
    else cout<<setprecision(12)<<2*(n-d)*(m-1)/(n*n);
}

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

using namespace std;
using LL = long long;

constexpr LL mod = 1000000000000037LL;
constexpr LL A = 307;

const int N = 5e3 + 5;

LL p[N];
LL h[N];

LL mul(LL x, LL y) {
    LL rv = 0;
    while (y) {
        if (y & 1) rv = (rv + x) % mod;
        y /= 2;
        x = (x + x) % mod;
    }
    return rv;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    p[0] = 1;
    for (int i = 1; i < N; i ++) p[i] = mul(p[i - 1], A);
    int n;
    cin >> n;
    string s;
    cin >> s;


    LL hash = 0;
    for (int i = 0; i < n; i ++) {
        hash = mul(hash, A) + s[i];
        hash %= mod;
        h[i] = hash;
    }

    int l = 0, r = n, ans = 0;
    while (l <= r) {
        int m = (l + r) / 2;
        unordered_map< LL, vector< int>> mp;
        mp[h[m - 1]].push_back(0);
        for (int i = m; i < n; i ++) {
            LL hash = h[i] - mul(h[i - m], p[m]);
            hash %= mod;
            if (hash < 0) hash += mod;
            mp[hash].push_back(i - m + 1);
        }
        bool ok = false;
        for (auto item : mp) {
            int sz = item.second.size();
            if (sz > 0) {
                int x = item.second[0];
                int y = item.second.back();
                if (y - x >= m) ok = true;
            }
            if (ok) break;
        }
        if (ok) {
            l = m + 1;
            ans = m;
        }
        else {
            r = m - 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 896
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define MAXN 1005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,m,dp[MAXN][MAXN];
char str[MAXN][MAXN];
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++) scanf("%s",str[i]+1);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
        {
            if(i==1&&j==1) dp[i][j]=1;
            else if(str[i][j]=='.') dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD; else dp[i][j]=0;
        }
    printf("%d\n",dp[n][m]);
    return 0;
}



Measured memory_bytes: 5120
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int check(char *s)
{
    int i;
    char key[] = "keyence";
    int len;

    len = strlen(s);

    //文字数が足りない場合
    if (len < 7) {
        return 0;
    }
    // そのまま入っている場合
    if (strstr(s, key) != NULL) {
        return 1;
    }
    // 分割されている場合
    for (i = 0; i < 7; i++) {
        if (s[i] != key[i]) {
            break;
        }
    }
    for (; i < 7; i++) {
        if (s[len - 7 + i] != key[i]) {
            break;
        }
    }
    if (i == 7) {
        return 1;
    }

    return 0;
}

int main(int argc, char *argv[])
{
    char s[127];

    scanf("%s", &s);

    if (check(s)) {
        printf("YES\n");
    } else {
        printf("NO\n");
    }

    return 0;
}

Measured memory_bytes: 128
from collections import defaultdict
N = int(input())
A = list(map(int,(input().split())))
c = defaultdict(lambda:0)
for i in range(1,10**5+1):
    c[i]
for i in A:
    c[i] += 1
l = list(c.items())
l.sort()
p = []
for i in range(0,10**5-2):
    p.append(l[i][1]+l[i+1][1]+l[i+2][1])
print(max(p))

Measured memory_bytes: 66792
# include <bits/stdc++.h>
#define INF 9223372036854775807
using namespace std;

int main(){

  int N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;

  int prefix[N+1];
  prefix[0] = 0;
  prefix[1] = 0;
  for(int i=1; i<N; i++){
    if(S.substr(i-1, 2) == "AC"){
      prefix[i+1] = prefix[i-1] + 1;
    } else{
      prefix[i+1] = prefix[i];
    }
    // cout << i+1 << " " << prefix[i+1] << endl;
  }
  for(int i=0; i < Q; i++){
    int l, r;
    cin >> l >> r;
    int ans = 0;
    ans = prefix[r] - prefix[l-1];
    if(l > 1 and S.substr(l-2, 2) == "AC"){
      ans -= 1;
    }
    cout << ans << endl;
  }

}

Measured memory_bytes: 1408
//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>

using namespace std;

typedef pair<long long, long long> pl;

long long N, M, k, a, b, c, d, e, H, W,X;
long long A[200000] = {};
long long B[200002] = {};
long long tt[20000] = {};
bool f;
bool ff;
string S, SS;
set <long long>sll;
pl buf;
vector <long long>vpl[100002];
vector <long long>vl;


int main() {
	N = 0;
	for (int i = 0; i < 6; i++) {
		cin >> A[i];
	}

	if (A[4] - A[0] <= A[5]) {
		cout << "Yay!" << endl;
	}
	else {
		cout << ":(" << endl;
	}

	return 0;
}

Measured memory_bytes: 4352