akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<ll>::iterator sit;
typedef map<ll,ll>::iterator mit;
 
const int INF = 10000001;
 
ll dp[501][501];
ll a[501][501];
 
ll sub(int x1, int y1, int x2, int y2)
{
	return (dp[x2][y2]-dp[x1-1][y2]-dp[x2][y1-1]+dp[x1-1][y1-1]);
}
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int n,m,h,w; cin>>n>>m>>h>>w;
	
	if(n%h==0&&m%w==0)
	{
		cout<<"No\n";
		return 0;
		
	}
	memset(dp,0,sizeof(dp));
	memset(a,0,sizeof(a));
	cout<<"Yes\n";
	//cerr<<n<<' '<<m<<' '<<h<<' '<<w<<'\n';
	for(int i=1;i<=n;i+=h)
	{
		for(int j=1;j<=m;j+=w)
		{
			a[i][j]=INF;
		}
	}
	for(int i=h;i<=n;i+=h)
	{
		for(int j=w;j<=m;j+=w)
		{
			a[i][j]=-(INF+1);
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			dp[i][j]=a[i][j]+dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1];
		}
	}
	assert(dp[n][m]>0);
	for(int i=1;i<=n-h+1;i++)
	{
		for(int j=1;j<=m-w+1;j++)
		{
			assert(sub(i,j,i+h-1,j+w-1)<0);
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cout<<a[i][j];
			if(j<m) cout<<' ';
		}
		cout<<'\n';
	}
}

Measured memory_bytes: 6528
#S: Area of the triangle
#L: The length of the circumference of the triangle
#h: The height of the triangle with side a as a bottom edge
#一つづつの計算を出すプログラム

a,b,c=gets.split.map(&:to_f)

puts a*b*Math.sin(c/180*3.14159265358979)/2                              #Area of the triangle
puts a+b+Math.sqrt(a**2+b**2-2*a*b*Math.cos(c/180*3.14159265358979))     #The length of the circumference of the triangle
puts b*Math.sin(c/180*3.14159265358979)                                  #The height of the triangle with side a as a bottom edge



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

using namespace std;

#define int long long

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

const int inf = 3e18;
int dp[20010];

signed main()
{
    int N, M, K; cin >> N >> M >> K;

    vector<int> a(N);

    rep(i, N) cin >> a[i];

    rep(i, N+1) dp[i] = inf;
    dp[0] = 0;

    rep(i, N) {
        int mi = inf, ma = 0;
        rep(j, M) {
            if (i + j >= N) continue;
            mi = min(mi, a[i+j]);
            ma = max(ma, a[i+j]);

            dp[i + j + 1] = min(dp[i + j + 1], dp[i] + (ma - mi) * (j + 1) + K);
        }
    }

    cout << dp[N] << endl;
}

Measured memory_bytes: 3268
using namespace std;
#include<bits/stdc++.h>
#define debug(x) clog<<#x<<" = "<<x<<'\n'
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fir first
#define sec second
#define mp make_pair
#define pb push_back
#define sz(c) ((int)c.size())
#define all(c) (c).begin(),(c).end()
#define MASK(i) (1LL<<(i))
#define BIT(x,i) (((x)>>(i))&1)
#define fn "C"  /// ___FILE_NAME_HERE___
#define rep(c,it) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define __rep(c,it) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();it++)

template <class T,class U>
void maximize(T &x,U y)
{
    if(x < y)x=y;
}
template <class T,class U>
void minimize(T &x,U y)
{
    if(x > y)x=y;
}
template <class T>
T Abs(T x)
{
    return (x < 0 ? -x : x);
}
template <class T>
T safe_sqrt(T x)
{
    return sqrt(max(x,(T)0));
}
template <class T,class U,class V>
T addmod(T x,U k,V MOD)
{
    return ((x+k)%MOD + MOD)%MOD;
}
template <class T,class U,class V>
T submod(T x,U k,V MOD)
{
    return ((x-k)%MOD + MOD)%MOD;
}
template <class T,class U,class V>
T mul(T x,U y,V MOD)
{
    return (ll)x*y%MOD;
}
/*------------------------------------------END_OF_TEMPLATE------------------------------------------*/

namespace task{

unordered_map <int,int> ma;
int n;
ll ans=0;
vector <int> ve;

void solve()
{
    scanf("%d",&n);
    for(int x,i=1;i<=n;++i)
        scanf("%d",&x),ma[x]++;
    rep(ma,it)
    {
        if(it->sec > 1)ve.pb(it->fir);
        if(it->sec > 3)maximize(ans,1ll*(it->fir) * 1ll*(it->fir));
    }
    sort(all(ve));
    if(sz(ve) > 1)maximize(ans,1ll*ve[sz(ve)-2]*1ll*ve.back());
    printf("%lld\n",ans);
}}

int main(void)
{
    task::solve();
}


Measured memory_bytes: 4388
Scanf.(Array.((scanf" %d %d %d"@@fun n m q->
	let a=make_matrix n n 0 in
	for _=1 to m do scanf" %d %d"@@fun l r->a.(l-1).(r-1)<-a.(l-1).(r-1)+1 done;
	for l=n-2 downto 0 do for r=0 to n-1 do
		a.(l).(r) <- a.(l).(r)+a.(l+1).(r) done;done;
	for r=0 to n-2 do for l=0 to n-1 do
			a.(l).(r+1) <- a.(l).(r+1)+a.(l).(r) done;done;
	for _=1 to q do
		scanf" %d %d"@@fun p q->Printf.printf"%d\n"a.(p-1).(q-1) done)))

Measured memory_bytes: 6912
import sys
n=int(input())
a=[list(map(int,input().split()))for _ in range(n)]
for i in range(n-1):
 d=a[i][:];d[3],d[4]=d[4],d[3]
 for j in range(i+1,n):
  e=a[j][:];e[3],e[4]=e[4],e[3]
  for p in('012345','152043','215304','302541','410352','514320'):
   f=[d[int(k)]for k in p]
   if f[0]==e[0]and f[5]==e[5]:
    f=f[1:5]*2
    for k in range(4):
     if f[k:k+4]==e[1:5]:print('No');sys.exit()
print('Yes')


Measured memory_bytes: 5616
#include <iostream>
#include <vector>
#include <bitset>
#include <string>
#include <array>
#include <random>
#include <chrono>
#include <algorithm>
#include <unordered_map>

int road_group[200 * 1000];
int rail_group[200 * 1000];

int search(int idx, int node, const std::vector<std::vector<int>>& path, int* dp){
	if(dp[node] >= 0)return 0;
	dp[node] = idx;
	int connect_count = 1;
	for(int nxt : path[node]){
		connect_count += search(idx, nxt, path, dp);
	}
	return connect_count;
}
int main(void){
	int n, k, l;
	std::cin >> n >> k >> l;
	for(int i=0;i<n;i++){
		road_group[i] = rail_group[i] = -1;
	}
	std::vector<std::vector<int>> pq(n), rs(n);
	for(int i=0;i<k;i++){
		int p, q;
		std::cin >> p >> q;
		p--;q--;
		pq[p].push_back(q);
		pq[q].push_back(p);
	}
	for(int i=0;i<l;i++){
		int r, s;
		std::cin >> r >> s;
		r--;s--;
		rs[r].push_back(s);
		rs[s].push_back(r);
	}
	for(int i=0;i<n;i++){
		search(i, i, pq, road_group);
		search(i, i, rs, rail_group);
	}
	std::unordered_map<int64_t, int> group_count;
	for(int i=0;i<n;i++){
		int64_t id = road_group[i];
		id *= n;
		id += rail_group[i];
		group_count[id]++;
	}
	for(int i=0;i<n;i++){

		int64_t id = road_group[i];
		id *= n;
		id += rail_group[i];
		if(i != 0)std::cout << " ";
		std::cout << group_count[id];
	}
	std::cout << std::endl;

}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

const int N = 200000;
int n;
vector<int> graph[N+1];

void dfs(int cur, int par, int d, int& dist, int& deepest) {
    if(d > dist) {
        deepest = cur;
        dist = d;
    }
    for(int child : graph[cur]) {
        if(child != par) {
            dfs(child, cur, d+1, dist, deepest);
        }
    }
}

int findDiam() {
    int deepest = 1, dist = 0;
    dfs(1, 0, 0, dist, deepest);

    int ignore = 1, diam = 0;
    dfs(deepest, 0, 0, diam, ignore);
    return diam;
}

bool firstWins(int diam) {
    if(diam == 0) return true;
    int m = diam%3;
    return m == 0 || m == 2;
}

int32_t main() {

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

    cin >> n;
    for(int i = 0; i < n-1; ++i) {
        int a, b; cin >> a >> b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    int diam = findDiam();

    if(firstWins(diam)) {
        cout << "First\n";
    } else {
        cout << "Second\n";
    }
    
    return 0;
}


Measured memory_bytes: 26880
import sys
from collections import deque

def resolve():
    input=sys.stdin.readline
    N,Q=map(int,input().rstrip().split())
    S=list(input().rstrip())
    R=[list(map(int,input().rstrip().split())) for _ in range(Q)]
    cumsum=[0 for i in range(N)]

    _S=deque(S)
    prevT=_S.popleft()
    for i in range(1,N):
        #T=S[0:i+1]#i=0で一字含む, 
        """
        T+=_S.popleft()
        cumsum[i]=T.count("AC")#cumsum[i]:i+1文字以下でACを含むか
        """
        nowT=_S.popleft()
        if(prevT=="A" and nowT=="C"):
            cumsum[i]=cumsum[i-1]+1
        else:
            cumsum[i]=cumsum[i-1]
        prevT=nowT

    cumsum=[0]+cumsum#cumsum[i]:i文字以下でACを含むか
    for j in range(Q):
        print(cumsum[R[j][1]]-cumsum[R[j][0]])

from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """8 3
ACACTACG
3 7
2 3
1 8"""
        output = """2
0
3"""
        self.assertIO(input, output)

if __name__ == "__main__":
    #unittest.main()
    resolve()

Measured memory_bytes: 84996
#define _USE_MATH_DEFINES

typedef long long ll;

#include <iostream>
#include <math.h>
#include <climits>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <map> 
#include <set>
#include <string>
using namespace std;

/* sample input

*/

int main()
{
	ll n;
	ll a;
	vector<ll> b;
	vector<ll>::iterator it;
	cin >> n;

	b.resize(n);

	ll harf = n / 2;

	for (ll i = 0; i < n; i++){
		cin >> a;

		if (i % 2){
			b[harf - (i / 2 + 1)] = a;
		}
		else{
			b[harf + (i / 2)] = a;
		}

		//if (i % 2){
		//	it = b.begin();
		//	b.insert(it, a);
		//}
		//else{
		//	b.push_back(a);
		//}
	}

	ll bsize = b.size();

	if (bsize % 2){
		for (ll i = bsize - 1; i >= 0; i--){


			cout << b[i];

			//if (i == 0){
			//	break;
			//}
			cout << " ";
		}
	}
	else{

		for (ll i = 0; i < bsize; i++){
			cout << b[i];

			//if (i == bsize - 1){
			//	break;
			//}
			cout << " ";
		}
	}


	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll Pow(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

const int M=55;
ll F[M];

void Init(){
	F[0]=1;
	for(int i=1;i<M;i++) F[i]=F[i-1]*i%mod;
}

ll Div(ll n,ll m){
	return n*Pow(m,mod-2)%mod;
}

ll n,dp[M][M][M];

int main(){
	cin>>n;
	Init();
	dp[0][1][0]=F[n];
	dp[0][2][1]=mod-F[n];
	for(int i=0;i<n;i++){
		for(int j=0;j<M;j++) for(int k=1;j+k<M;k++) (dp[i][j+k][k]+=dp[i][j+k-1][k-1])%=mod;
		for(int j=1;j<M;j++) for(int k=1;j+k<M;k++) (dp[i][k][j+k]+=dp[i][k-1][j+k-1])%=mod;
		for(int j=0;j<M;j++) for(int k=0;k<M;k++) if(i+j+k<M){
			for(int l=0;l<=j;l++) (dp[i+j+k][l][0]+=Div(dp[i][j][k],F[j-l]*F[k+l]%mod))%=mod;
			for(int l=1;l<=k;l++) (dp[i+j+k][0][l]+=Div(dp[i][j][k],F[j+l]*F[k-l]%mod))%=mod;
		}
	}
	cout<<dp[n][0][0]<<endl;
}

Measured memory_bytes: 1536
#!/usr/bin/env python3
import sys
INF = 1<<32

def solve(N: int, h: "List[int]"):
    dp = [INF] * (N+2)
    dp[0] = 0
    dp[1] = abs(h[1]-h[0])

    for i in range(N):
        if(i+1 < N):
            dp[i+1] = min(dp[i+1], dp[i]+abs(h[i+1]-h[i]))
        if(i+2 < N):
            dp[i+2] = min(dp[i+2], dp[i]+abs(h[i+2]-h[i]))

    print(dp[N-1])

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    h = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, h)

if __name__ == '__main__':
    main()


Measured memory_bytes: 19252
#include<stdio.h>
#include<string.h>
int main()
{
    char a[100], b[100];
    int count = 0, i;
    gets(a);
    gets(b);
    int x, y;
    x = strlen(a);
    y = strlen(b);
    if((x + 1) != y){
        printf("No\n");
    }

    else if( ( x + 1) == y){
        for(i = 0; i < x; i++){
            if(a[i] == b[i]){
                count++;
            }
        }
        if(x == count){
        printf("Yes\n");
    }
    else if( x != count){
        printf("No\n");
    }
    }



    return 0;
}


Measured memory_bytes: 1536
#!/usr/bin/env python3
import sys

YES = "YES"  # type: str
NO = "NO"  # type: str


def solve(N: int, p: "List[int]"):
    count = 0

    p_ = [i for i in range(1, N+1)]
    for i in range(N):
        if p[i] != p_[i]:
            count += 1
            
    if count > 2:
        print(NO)
    else:
        print(YES)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    p = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, p)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
S = input()
if S == 'SUN':
    print(7)
elif S == 'MON':
    print(6)
elif S == 'TUE':
    print(5)
elif S == 'WED':
    print(4)
elif S == 'THU':
    print(3)
elif S == 'FRI':
    print(2)
else:
    print(1)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }

struct Tmp
{
public:
  Tmp(int N);
  bool isGusu;
  vector<int> A;
  vector<vector<ll>> dp;
  ll rec(int i, int j);
};

Tmp::Tmp(int N)
  : A(N)
  , dp(N+1, vector<ll>(N+1, -1))
{
  isGusu = (N % 2 == 0);
}

ll Tmp::rec(int i, int j)
{
  if (dp[i][j] != -1) {
    return dp[i][j];
  }
  if (i == j) {
    return dp[i][j] = 0;
  }
  if (((j - i) % 2 == 0) == isGusu) {
    return dp[i][j] = std::max(
      rec(i+1, j) + A[i],
      rec(i, j-1) + A[j-1]
    );
  }
  else {
    return dp[i][j] = std::min(
      rec(i+1, j) - A[i],
      rec(i, j-1) - A[j-1]
    );
  }
}

void solve(void)
{
  int N; cin >> N;
  Tmp t(N);
  for (auto& a : t.A) { cin >> a; }

  auto ans = t.rec(0, N);
  cout << ans << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 70912
#include <bits//stdc++.h>
using namespace std;
#define int long long
#define rep(i,n,k) for(int i=n;i<k;i++)
#define P make_pair
#define F first
#define S second
#define M LLONG_MAX
signed main(void){
    int n,m,ans,w,p,q;
    ans=0;
    string s,s1,s2;
    vector<int> v;
   cin>>n>>m>>p;
   if(p<=m+n)
   cout<<"No"<<endl;
   else if(4*m*n<(p-m-n)*(p-m-n))
   cout<<"Yes"<<endl;
   else
   cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>   
using namespace std;
using namespace __gnu_pbds;
typedef long long ll; 
#define int long long
typedef unsigned long long lu;
typedef vector<ll> v;
typedef vector<vector<ll> > vv;
typedef vector<string>  vs;
typedef vector<pair<ll,ll>> vpr;
typedef vector<bool>vb;
typedef vector<double>vd;
typedef long double ld;
#define f(i,n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define amax(x,y) if(y>x) x=y;
#define amin(x,y) if(y<x)x=y;
#define bg(x) x.begin()
#define sz(x) (ll)x.size()
#define in(x,n) for(ll i=0;i<n;i++)cin>>x[i]
#define out(x,n) for(ll i=0;i<n;i++)cout<<x[i]<<" " 
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a) *(min_element(a.begin(),a.end())
#define tc ll t;cin>>t;while(t--)
typedef pair<ll,ll> pi;
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define yesno(f) if(f) yes else no
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
const ld PI = 2 * acos(0.0);
ll cel(ll x1,ll y1){if((x1%y1)==0)return x1/y1;else return x1/y1+1;}
ll power(ll a,ll b,ll m)
{
    if(b==0)
        return 1;
    ll d=power(a,b/2,m);
    d=(d*d)%m;
    if(b&1)
        d=(d*a)%m;
    return d;
}
const ll mod=1e9+7;
int MOD(int a)
{
    if(a<0)
        a+=mod;
    if(a>=mod)
        a%=mod;
    return a;
}
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */
int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    v cnt(1e4+2,0);
    for(int i=1;i<=100;i++)
    {
        for(int j=1;j<=100;j++)
        {
            for(int k=1;k<=100;k++)
            {
                int a=1e4+1;
                cnt[min(i*i+j*j+k*k+i*j+i*k+j*k,a)]++;
            }
        }
    }
    int n;cin>>n;
    for(int i=1;i<=n;i++)
        cout<<cnt[i]<<endl;
    return 0;
}

Measured memory_bytes: 3732
n = int(input())
v_list = [int(v) for v in input().split(" ")]
v_list.sort(reverse=True)
sum = 0
for i in range(len(v_list)):
    if i+1 < len(v_list):
        sum += v_list[i]/(2**(i+1))
    else:
        sum += v_list[i]/(2**i)
print(sum)


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

int N;

vector<int> A, B, C;

int main(){
	cin >> N;
	int x;
	for(int i = 0; i < N; i++){
		cin >> x;
		A.push_back(x);
	}
	for(int i = 0; i < N; i++){
		cin >> x;
		B.push_back(x);
	}
	for(int i = 0; i < N; i++){
		cin >> x;
		C.push_back(x);
	}
	sort(A.begin(), A.end());
	sort(C.begin(), C.end());
	long long count = 0, count1, count2;
	for(int i = 0; i < B.size(); i++){
		count1 = lower_bound(A.begin(), A.end(), B[i]) - A.begin();
		count2 = C.end() - upper_bound(C.begin(), C.end(), B[i]);
		count += count1 * count2;
	}
	cout << count << endl;

	return 0;
}


Measured memory_bytes: 1784
S = list(input())
def atgc(s):
    if s == "A" or s == "T" or s == "G" or s == "C":
        return True
    else:
        return False
c = 0
nax = 0
for i in range(len(S)):
    if atgc(S[i]):
        c += 1
        if i == len(S)-1:
            nax = max(nax,c)
    else:
        nax = max(nax,c)
        c = 0
print(nax)

Measured memory_bytes: 38256
a, b, c = map(int, input().split())

ma = max(a, b, c)

if (ma * 3) % 2 == 0:
    if (a + b + c) % 2 == 0:
        print((ma*3-(a+b+c)) // 2)
    else:
        print(((ma+1)*3 -(a+b+c))//2)

else:
    if (a + b + c) % 2 == 1:
        print((ma*3-(a+b+c)) // 2)
    else:
        print(((ma+1)*3 -(a+b+c))//2)

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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()
typedef pair<ll, ll>    P;

//Combination Table
ll C[51][51]; /* C[n][k] -> nCk */

void comb_table(int N) {
    REP(i, N+1) REP(j, i+1) {
        if(j == 0 || j == i) {
            C[i][j] = 1LL;
        } else {
            C[i][j] = (C[i-1][j-1] + C[i-1][j]);
            //cout << C[i][j] << endl;
        }
    }
}

int main() {
    ll n, p;
    cin >> n >> p;
    vector<ll> a(n);
    ll gusu, kisu = 0;
    gusu = 0;

    REP(i, n) {
        cin >> a[i];
        if(a[i] % 2 == 0) {
            gusu++;
        } else {
            kisu++;
        }
    }

    ll tori = 1;
    REPN(i, 1, gusu+1) {
        tori *= 2;
    }
    comb_table(50);
    ll ans = 0;

    if(p % 2 == 1) {
        /* 奇数を奇数個 */
        for(int i = 1; i <= kisu ; i += 2) {
            ll tmp = C[kisu][i];
            //cout << kisu << " " << i << " " << tmp << endl;
            tmp *= tori;
            ans += tmp;
        }
    } else {
        /* 奇数を偶数個 */
        for(int i = 0; i <= kisu ; i += 2) {
            ll tmp = C[kisu][i];
            //cout << kisu << " " << i << " " << tmp << endl;
            tmp *= tori;
            ans += tmp;            
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import kotlin.math.*
import java.util.*

const val MOD = 1_000_000_007L

fun readI() = readLine()!!.toInt()
fun readL() = readLine()!!.toLong()
fun readD() = readLine()!!.toDouble()
fun readIs() = readLine()!!.split(' ').map(String::toInt)
fun readLs() = readLine()!!.split(' ').map(String::toLong)
fun readDs() = readLine()!!.split(' ').map(String::toDouble)

fun main() {
    val n = readI()
    val a = mutableMapOf("AC" to 0, "WA" to 0, "TLE" to 0, "RE" to 0)
    repeat(n) {
        val s = readLine()!!
        a[s] = a[s]!! + 1
    }
    println("""
      AC x ${a["AC"]}
      WA x ${a["WA"]}
      TLE x ${a["TLE"]}
      RE x ${a["RE"]}
    """.trimIndent())
}


Measured memory_bytes: 61304
n,m=map(int,input().split())
h=list(map(int,input().split()))
small=set()

for i in range(m):
  a,b=map(int,input().split())
  
  if h[a-1]>=h[b-1]:
    small.add(b)
  if h[b-1]>=h[a-1]:
    small.add(a)
    
print(n-len(small)) 

Measured memory_bytes: 19876
<?php                                                                                                                                                          
                                                                                                                                                               
function fget_array()                                                                                                                                          
{                                                                                                                                                              
    return explode(' ', trim(fgets(STDIN)));                                                                                                                   
}                                                                                                                                                              
                                                                                                                                                               
$num = fget_array()[0];                                                                                                                                        
$str = fget_array()[0];                                                                                                                                        
$result = $num < 3200 ? 'red' : $str;                                                                                                                          
echo $result.PHP_EOL; 

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

int main() {
  int n;
  cin >> n;
  vector<vector<int>> a(n, vector<int>(3));
  for (int i = 0; i < n; ++i) {
    cin >> a[i][0] >> a[i][1] >> a[i][2];
  }

  vector<vector<int>> dp(n, vector<int>(3, INT_MAX));
  dp[0] = a[0];
  for (int i = 1; i < n; ++i) {
    for (int j = 0; j < 3; ++j) {
      int x = INT_MIN;
      for (int k = 0; k < 3; ++k) {
        if (j != k) {
          x = max(x, dp[i - 1][k]);
        }
      }
      dp[i][j] = a[i][j] + x;
    }
  }

  int ret = INT_MIN;
  for (int e : dp.back()) {
    ret = max(ret, e);
  }
  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 14032
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    while(cin>>n)
    {
        int sum=0;
        for(int i=1;i<=n;i++)
        {
            int cnt=0;
            for(int j=1;j<=i;j++)
            {
                if(i%j==0)
                    cnt++;
            }
            if(cnt==8&&(i&1))
                sum++;
        }
        printf("%d\n",sum);
    }
    return 0;
}

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

void Solve() {
	UL n; cin >> n;
	string s, t; cin >> s >> t;
	rep(i, s.size()) {
		cout << s[i] << t[i];
	}
	cout << endl;
}
int main() { Solve(); return 0; }


Measured memory_bytes: 256
n = int(input())
C = []
mod = 10**9+7
for i in range(n):
    c = int(input())
    if i==0:
        C.append(c)
    elif C[-1]!=c:
        C.append(c)
n = len(C)
dp = [0]*n
idx = {}
for i in range(n):
    if i==0:
        idx[C[i]] = i
        dp[i] = 1
    else:
        if C[i] not in idx:
            dp[i] = dp[i-1]
            idx[C[i]] = i
        else:
            dp[i] = dp[i-1]+dp[idx[C[i]]]
            idx[C[i]] = i
print(dp[-1]%mod)

Measured memory_bytes: 754292
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a;
  cin >> a;
  int key = 0;
  for(int i = 0;i<26;i++){
    for(int j = 0;j<13;j++){
      if(a == 4*i+7*j){
        cout << "Yes" << endl;
        key = 1;
        break;
      }
    }
    if(key == 1)
        break;
  }
  if(key == 0)
    cout << "No" << endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main() {
    let h: usize = read().unwrap();
    let n: usize = read().unwrap();
    let mut vec: Vec<usize> = Vec::new();

    for _ in 0..n {
        vec.push(read().unwrap());
    }
    if h <= vec.iter().sum() {
        println!("Yes")
    } else {
        println!("No");
    }
}

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

typedef pair<int, int> II;
typedef vector< II > VII;
typedef vector<int> VI;

#define endl "\n"
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (ll)(a.size())
#define ll long long
#define fr(i,n) for(i=0;i<n;i++)

VI v[300010];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll tp,n,a,b,i,j,k;
    cin>>n>>a>>b;
    if(a+b-1>n)
        cout<<-1<<endl;
    else
    {
        if(a+b-1==n)
        {
            for(i=1;i<a;i++)
                cout<<i<<" ";
            for(i=n;i>=a;i--)
                cout<<i<<" ";
            cout<<endl;
        }
        else if(b<((n+a-1)/a))
            cout<<-1<<endl;
        else
        {
            for(i=0;i<b;i++)
            {
                if(b-i==((n-i+a-1)/a))
                    break;
            }
            if(i==b)
                cout<<-1<<endl;
            else
            {
                for(j=n;j>n-i;j--)
                    cout<<j<<" ";
                tp=n-i;
                i=0;
                for(j=tp;j>0;j--)
                {
                    if(SZ(v[i])>=a)
                        i++;
                    v[i].PB(j);
                }
                for(j=0;j<=i;j++)
                {
                    for(k=SZ(v[j])-1;k>=0;k--)
                        cout<<v[j][k]<<" ";
                }
                cout<<endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 10104
l, r = map(int, input().split())
min = 10**5
if r-l >= 2018:
    print(0)
else:
    for i in range(l,r+1):
        for j in range(i+1, r+1):
            if i*j % 2019 < min:
                min = i*j % 2019
    print(min)




Measured memory_bytes: 9172
# メモ化再帰でやる
N, A, B = gets.chomp.split.map(&:to_i)
@a_arr, @b_arr, @c_arr = [], [], []
N.times do
    a, b, c = gets.chomp.split.map(&:to_i)
    @a_arr << a; @b_arr << b; @c_arr << c
end

@memo = Array.new(N).map{Array.new(40*10+1).map{Array.new(40*10+1, -1)}}

def rec(i, a, b, c)
    # 見つかった場合は終了
    if a*b>0 && a*B == A*b
        return c
    end
    # 探索できなかったら終了
    if i==N
        return 10**10
    end
    # 既に探索済みならそれを返す
    if @memo[i][a][b] > 0
        return @memo[i][a][b] == 10**10 ? @memo[i][a][b] : @memo[i][a][b] + c
    end
    ret = [rec(i+1, a+@a_arr[i], b+@b_arr[i], c+@c_arr[i]), rec(i+1, a, b, c)].min
    @memo[i][a][b] = ret == 10**10 ? ret : ret - c
    return ret
end

ans = rec(0, 0, 0, 0)
puts ans==10**10 ? -1 : ans


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

using namespace std;

const int N = 123456;

int n, m, s[N], value[N], father[N], dfn[N], coef[N], tt, answer;
bool ban[N];
vector<int> adj[N], circle;

void dfs(int x, int f, int d) {
  s[x] = 0;
  father[x] = f;
  for (auto y : adj[x]) {
    if (y != f && (!ban[x] || !ban[y])) {
      dfs(y, x, !d);
      s[x] += s[y];
    }
  }
  s[x] += value[x];
  if (d) {
    ++s[x];
  } else {
    --s[x];
  }
  answer += abs(s[x]);
}

void find_circle(int x, int f) {
  dfn[x] = ++tt;
  father[x] = f;
  for (auto y : adj[x]) {
    if (y != f) {
      if (!dfn[y]) {
        find_circle(y, x);
      } else if (dfn[y] < dfn[x]) {
        circle.push_back(x);
        int z = x;
        while (z != y) {
          circle.push_back(z = father[z]);
        }
      }
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1, x, y; i <= m; ++i) {
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  if (m == n - 1) {
    dfs(1, 0, 0);
    cout << (s[1] ? -1 : answer) << '\n';
  } else {
    find_circle(1, 0);
    ban[circle[0]] = ban[circle[1]] = true;
    dfs(1, 0, 0);
    if (circle.size() & 1) {
      if (s[1] & 1) {
        cout << -1 << '\n';
      } else {
        value[circle[0]] -= s[1] >> 1;
        value[circle[1]] -= s[1] >> 1;
        answer = abs(s[1] >> 1);
        dfs(1, 0, 0);
        cout << answer << '\n';
      }
    } else {
      if (s[1]) {
        cout << -1 << '\n';
      } else {
        int x = circle[0], y = circle[1];
        while (x) {
          ++coef[x];
          x = father[x];
        }
        while (y) {
          --coef[y];
          y = father[y];
        }
        answer = 0;
        vector<int> values(1, 0);
        for (int i = 1; i <= n; ++i) {
          if (coef[i] == 0) {
            answer += abs(s[i]);
          } else if (coef[i] == 1) {
            values.push_back(-s[i]);
          } else {
            values.push_back(s[i]);
          }
        }
        sort(values.begin(), values.end());
        int p = values[values.size() >> 1];
        for (auto v : values) {
          answer += abs(v - p);
        }
        cout << answer << '\n';
      }
    }
  }
  return 0;
}

Measured memory_bytes: 17144
N,A,B = map(int,input().split())
X = list(map(int,input().split()))
X = [i-X[0] for i in X]
X.pop(0)
now = 0
count = 0
for i in X:
    if A*(i-now) < B:
        count += A*(i-now)
    else:
        count += B
    now = i
print(count)

Measured memory_bytes: 14224
#include <iostream>
#include <algorithm>

using namespace std;

int N, C, K;
int T[1000005];

int main(void)
{
	cin >> N >> C >> K;
	for(int i = 0; i < N; i++) cin >> T[i];
	sort(T, T+N);
	
	int ans = 0, prev = T[0], ride = C+1;
	for(int i = 0; i < N; i++){
		if(T[i] > prev + K || ride >= C){
			ans++;
			prev = T[i];
			ride = 0;
		}
		ride++;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i = 0; i < n; i++)
#define rep2(i,start,end) for(ll i = start; i < end; i++)
#define dwn(i,n) for(int i = n; i >= 0; i--)
#define dwn2(i,start,end) for(ll i = start; i >= end; i--)
#define pll pair<ll,ll>
#define mk(x,y) make_pair(x,y)
#define pdl pair<double, ll>
const ll N = 4e5 + 200;
const ll INF = 0x3f3f3f3f;
const ll mod = 1e9 + 7;

ll a[N],b[N];
int main(){
	ll n,k;
	cin>>n>>k;
	ll sum = 0;
	a[0] = n;
	for(int i = 1; i <= n; i++){
		a[i] = a[i-1] + n - i;
//		a[i] %= mod;
	}
	b[0] = 0;
	for(int i = 1; i <= n; i++){
		b[i] = b[i-1] + i;
//		b[i] %= mod;
	}
	for(int i = k-1; i <= n; i++){
		ll tmp = a[i] - b[i] + 1;
		tmp %= mod;
//		cout<<tmp<<endl;
		sum += tmp;
		sum %= mod;
		
	}
	cout<<sum<<endl;


	return 0;
}






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

int main(){
    int s;
    cin>>s;
    int a1=s/100;
    int a2=s%100;
    if(1<=a1 &&a1<=12){
        if (1 <= a2 && a2 <= 12){
            cout << "AMBIGUOUS" <<endl;
        }else if((13<=a2 && a2<=99) || a2==0){
            cout << "MMYY" <<endl;
        }else{
            cout<<"NA"<<endl;
        }
    }
    else if((13<=a1 && a1<=99)||a1==0){
        if (1 <= a2 && a2 <= 12){
            cout<<"YYMM"<<endl;
        }
        else{
            cout << "NA" << endl;
        }
    }
    else{
        cout << "NA" << endl;
    }
}

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

int main(){
    string s;
    cin>>s;
    int n=s.size();
    vector<int>a(n+1,0);
    rep(i,n){
        if(s[i]=='<')if(a[i]>=a[i+1])a[i+1]=a[i]+1;
    }
    for(int i=n; i>0; --i){
        if(s[i-1]=='>')if(a[i]>=a[i-1])a[i-1]=a[i]+1;
    }
    ll ans=0;
    rep(i,n+1)ans+=a[i];
    cout<<ans<<endl;
}


Measured memory_bytes: 2820
import java.util.Scanner;

/**
 *
 * @author cs18097
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int ans = c+b-a;
        if(ans<0)ans=0;
        System.out.print(ans);
    }
    
}


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

class Program
{
    static void Main(string[] args)
    {
        var sol = new Solve();
        sol.Exec();
    }
}

class Solve
{
    public void Exec()
    {
        var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int N = l[0], M = l[1];

        var dict = new Dictionary<int, int>();

        if (N == 1 && M == 0)
        {
            Console.WriteLine(0);
            return;
        }

        for (var i = 0; i < M; i++)
        {
            var t = Console.ReadLine().Split().Select(int.Parse).ToArray();
            if (t[0] == 1 && t[1] == 0)
            {
                if (N != 1)
                {
                    Console.WriteLine(-1);
                    return;
                }
            }

            if (dict.ContainsKey(t[0]))
            {
                if (dict[t[0]] != t[1])
                {
                    Console.WriteLine(-1);
                    return;
                }
            }
            else
                dict[t[0]] = t[1];
        }

        var one = dict.ContainsKey(1) ? dict[1] : 1;
        var two = dict.ContainsKey(2) ? dict[2] : 0;
        var three = dict.ContainsKey(3) ? dict[3] : 0;

        var ans = one.ToString();
        if (N >= 2) ans += two.ToString();
        if (N >= 3) ans += three.ToString();

        Console.WriteLine(ans);
    }
}

public class Util
{
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds ;
#define ll long long
#define pp pair<ll,ll>
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define sz(a) int((a).size())
#define present(c,x) ((c).find(x) != (c).end())
#define mp make_pair
#define hell 1000000007
#define F first
#define S second
#define sll(x) scanf("%lld",&x)
#define si(x) scanf("%d",&x)
typedef tree<pp , null_type , less<pp> , rb_tree_tag , tree_order_statistics_node_update > ordered_set ;
ll t=1 ;
void solve()
{
    ll n , T , a ;
    cin >> n >> T >> a ;
    vector<ll> v( n + 1 ) ;
    vector<pair<long double,ll> > vv ;
    rep( i , 1 , n + 1 )
    {
        cin >> v[i] ;
        long double x = T - 0.006*v[i] ;
        vv.pb( {abs(x-a),i});
    }
    sort(all(vv));
    cout << vv[0].S;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //cin>>t;
    while(t--)
        solve() ;
    return 0 ;
}


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

using namespace std;
using ll = long long;
using ld = long double;
using Vec = vector<int>;


int main() {

  int x,n;
  cin>>x>>n;
  Vec vec(n);
  for(int i=0;i<n;i++){
      cin>>vec[i];
  }
  int c=0;
  for(int i=0;i<n;i++){
      if(x!=vec[i]){
          c++;
      }

  }
  if(n==0){
      cout<<x<<endl;
  }
  else if(c==n){
      cout<<x<<endl;
  }
  else{
  Vec vec2(n),vec3(n);
  for(int i=0;i<n;i++){
      vec2[i]=vec[i];
  }
  for(int i=0;i<n;i++){
    vec[i]=abs(vec[i]-x);
  }
  for(int i=0;i<n;i++){
      vec3[i]=vec[i];
  }
  sort(vec.begin(),vec.end());
     int ans;
  for(int i=1;i<100;i++){
      int count=0;
      
      for(int j=0;j<n;j++){
        
      if(i!=vec[j]){
          count++;
      }
      }
      if(count==n-1||count==n){
      ans=i;
      break;
      }
  }
  bool t=true,r=true;
  for(int i=0;i<n;i++){
      if(x-ans==vec2[i]){
          t=false;
          break;
      }
  }
  if(t==true){
      cout<<x-ans<<endl;
  }
  else
  {
      cout<<x+ans<<endl;
  }
  


  }
  }


  


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv)
{
	int a, b, c;
	scanf("%d %d", &a, &b);
	if (a == 1)
	{
		if (b == 2) 
		{
			c = 3;
		}
		else if (b == 3)
		{
			c = 2;
		}
	}
	else if (a == 2)
	{
		if (b == 1)
		{
			c = 3;
		}
		else if (b == 3)
		{
			c = 1;
		}
	}
	else if (a == 3)
	{
		if (b == 1)
		{
			c = 2;
		}
		else if (b == 2)
		{
			c = 1;
		}
	}
	printf("%d", c);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = (1 << 29);
const long long INFL = (1LL<<60);
const double eps = (1e-9);

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
  return (x / gcd(x, y)) * y;
}

int main(int argc, char* argv[])
{
  int n;
  cin >> n;
  int num2 = 0;
  int num4 = 0;
  rep(i, n) {
    ll a;
    cin >> a;
    if (a % 4 == 0) {
      num4++;
    } else if (a % 2 == 0) {
      num2++;
    }
  }

  if (num2 > 0) {
    n -= (num2 -1);
  }

  if (num4 >= n / 2) {
    cout << "Yes";
  } else {
    cout << "No";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll n;
vector<ll> divisor(ll n){
    vector<ll> res;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            res.push_back(i);
            if(i!=n/i) res.push_back(n/i);
        }
    }
    return res;
}
int main(void){
    cin>>n;
    vector<ll> v,w;
    v=divisor(n);
    w=divisor(n-1);
    ll ans=w.size()-1;
    for(int i=1;i<v.size();i++){
        ll m=n;
        ll k=v[i];
        while(m%k==0){
            m=m/k;
        }
        if(m%k==1){
            ans++;
        }
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 3704
def GCD(a, b):
    r = a % b
    while(r!=0):
        a = b
        b = r
        r = a % b
    
    return b

def main():
    ans = 0 
    K = int(input())
    for i in range(1, K+1):
        for j in range(1, K+1):
            if(i < j):
                gcd1 = GCD(j, i)
            else:
                gcd1 = GCD(i, j)
            for k in range(1, K+1):
                ans += GCD(gcd1, k)

    print(ans)



if __name__ == main():
    main()

Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define per(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n, k; cin >> n >> k;
    vector<vector<int> > tmp(n);
    rep(i, n) {
        int t0, d0;
        cin >> t0 >> d0;
        t0--;
        tmp[t0].push_back(d0);
    }

    rep(i, n) sort(all(tmp[i]), greater<int>()); //各ネタごとに美味しさ降順でソート

    vector<int> y1, y0;
    rep(i, n) {
        if (sz(tmp[i]) == 0) continue;
        y1.push_back(tmp[i][0]); //各寿司の一番美味しいやつの味を格納
        for (int j=1; j<sz(tmp[i]); j++) {
            y0.push_back(tmp[i][j]); //一番美味しいやつ以外の味を格納
        }
    }
    sort(all(y1), greater<int>());
    sort(all(y0), greater<int>());
    //以降、各寿司を食う場合は一番美味しいやつを食えばよく
    //その一番美味しいやつを何個食うかで調べていけば良い
    ll ans = 0;
    ll tmp2 = 0;
    bool flag = false;
    for (int i=1; i<=min(sz(y1), k); i++) {
        tmp2 += (ll)i*i-(ll)(i-1)*(i-1); //何種類の寿司を食うか
        tmp2 += y1[i-1];
        int m = k-i; //あと何個一番美味しい寿司以外食うか
        if (sz(y0) < m) continue;
        if (flag) {
            tmp2 -= y0[m];
        }
        else {
            rep(j, m) {
                tmp2 += y0[j];
                flag = true;
            }
        }
        chmax(ans, tmp2);
    }

    cout << ans << endl;
}

Measured memory_bytes: 6396
#C
import numpy as np
x, n = map(int, input().split())

if n!=0:
    p_list = list(map(int, input().split()))
    kouho = list(range((x-n//2-1),(x+n//2+1)))    
    kouho2 = list(set(kouho) - set(p_list))
    ans = [j for i, j in enumerate(kouho2) if abs(j-x) == min(abs(np.array(kouho2) - x))]
    ans = min(ans)

else:
    ans = x

print(ans)

Measured memory_bytes: 27224
n = int(input())
lst = []
ans = 0
for i in range(n):
    a = int(input())
    lst.append([list(map(int,input().split())) for _ in range(a)])

for k in range(1<<n):
    target = bin(k)[2:].zfill(n)
    nk = 0
    for i in range(n):
        if target[i] == '1':
            if any(target[x-1] != str(y)  for x,y in lst[i]):
                break
            else:
                nk += 1
    else:
        ans = max(ans,nk)
print(ans)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		int a[n];
		for(int i=0;i<n;i++){
			cin>>a[i];
		}
		for(int i=0;i<n;i++){
			int k=i;
			for(int j=i-1;j>=0;j--){
				if(a[k]<a[j]){
					int temp=a[k];
					a[k]=a[j];
					a[j]=temp;
				}
				k--;
			}
			cout<<a[0];
			for(int l=1;l<n;l++){
				cout<<" "<<a[l];
			}
			cout<<endl;
		} 
	}
	return 0;
} 


Measured memory_bytes: 3104
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main() {
  string s;
  cin >> s;

  int result = 0;
  int sum = 0;
  rep(i, s.size()) {
    int d = s[i] - '0';
    sum += d;
    if (d > 0) {
      int z = sum - 1 + 9 * (s.size() - 1 - i);
      result = max(result, z);
    }
  }
  result = max(result, sum);
  cout << result << endl;

  return 0;
}

Measured memory_bytes: 3616