akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, z, n) for(int64_t i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979
//const int64_t INF = 1LL << 60;
const int INF = 1 << 29;
//const int MODINF = 1000000007;
//const int64_t INF = 998244353;
using namespace std;
int main(){
    ll N, A, B;
    cin >> N >> A >> B;
    if ((B - A) % 2 == 0) cout << (B - A) / 2 << endl;
    else cout << min((A + B - 1), (2 * N - A - B + 1)) / 2 << endl;
}


Measured memory_bytes: 384
from bisect import bisect_left

N = int(input())
L = list(map(int, input().split()))
L.sort()
# print (L)
count = 0
for a in range(N - 1):
    tmp = L[a]
    for b in range(a + 1, N):
        c = tmp + L[b]
        count += max(0, bisect_left(L, c) - b - 1)

print (count)

Measured memory_bytes: 3188
S = input()

alfa = [chr(i) for i in range(97,97+26)]

A = []


counter = []
for i in range(4):
    counter.append(S.count(S[i]))

flag = 0
for i in range(4):
    if counter[i] == 2:
        flag += 1

if flag > 3:
    print('Yes')
else:
    print('No')

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

long long MOD=1000000007ll;

int main(){
	int N;
	string S1,S2;
	cin >> N >> S1 >> S2;
	
	int pos=0;
	long long ans;
	bool v;
	if(S1[0]==S2[0]){
		ans=3;
		pos++;
		v=true;
	}else{
		ans=6;
		pos+=2;
		v=false;
	}
	
	for(;pos<N;){
		if(S1[pos]==S2[pos]){
			if(v)ans*=2;
			pos++;
			v=true;
		}else{
			if(v)ans*=2;
			else ans*=3;
			pos+=2;
			v=false;
		}
		if(ans>=MOD)ans%=MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<cmath>
using namespace std;
int main(){
    int ans=0;
    int hati=0;
    int n;
    cin>>n;
    
    if(n<105){cout<<0<<endl;return 0;}
    if(n==105){cout<<1<<endl;return 0;}
    
    for(int i=1;i<=n;i++){
        hati=0;
        for(int j=1;j<=i;j=j+2){
            if(i%j==0)hati++;
        }
        if(hati==8)ans++;
    }

    cout<<ans<<endl;

return 0;
}


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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

#define INF 1e9

int main(){ 
  ll A, B, K;
  cin >> A >> B >> K;
  if(A >= K){
    cout << A -K << " " << B << endl;
  }
  else if(A+B >= K){
    cout << 0 << " " << A+B-K << endl;
  }
  else{
    cout << 0 << " " << 0 << endl;
  }
  return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N + 1), B(N);
    for (int i = 0; i < N + 1; i++) {
        cin >> A.at(i);
    }
    for (int i = 0; i < N; i++) {
        cin >> B.at(i);
    }

    long long ans = 0;
    for (int i = 0; i < N; i++) {
        if (A.at(i) != 0) {
            if (A.at(i) >= B.at(i)) {
                ans += B.at(i);
                A.at(i) -= B.at(i);
                B.at(i) = 0;
            }
            else {
                ans += A.at(i);
                B.at(i) -= A.at(i);
                A.at(i) = 0;
            }
        }
        if (A.at(i + 1) != 0) {
            if (A.at(i + 1) >= B.at(i)) {
                ans += B.at(i);
                A.at(i + 1) -= B.at(i);
                B.at(i) = 0;
            }
            else {
                ans += A.at(i + 1);
                B.at(i) -= A.at(i + 1);
                A.at(i + 1) = 0;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG
#define DEBUG(a) cerr<<#a<<"="<<a<<endl
#define DEBUG_ARRAY(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define DEBUG(a) 
#define DEBUG_ARRAY(a,n) 
#endif
#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> P;
typedef pair<ll,P> PP;
typedef vector<ll> vll;

const ll INF=(1LL<<50);

const string YES = "YES";
const string NO = "NO";

void solve(long long N, long long K){
    bool flag=false;
    if(N%2==0){
        if(N/2>=K)
            flag=true;
    }else{
        if((N+1)/2>=K)
            flag=true;
    }
    if(flag){
        cout<<YES<<endl;
    }else{
        cout<<NO<<endl;
    }
}

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


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

using namespace std;

using ll = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<ll>;
using Vs = V<string>;

template<typename T1, typename T2> using P = pair< T1, T2 >;
using Pii = P<int, int>;
using Pdd = P<double, double>;

const ll MOD = 1e9+7;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()


int main() {
    int n, m;
    cin >> n >> m;

    V<Vi> v(m+1);
    REP(i, n) {
        int a, b;
        cin >> a >> b;
        if (a <= m) {
            v[a].push_back(b);
        }
    }

    priority_queue<int, Vi> q;

    ll cnt = 0;
    RREP(i, m-1, 0) {
        FOR(j, v[m-i]) {
            q.push(*j);
        }

        if (!q.empty()) {
            cnt += q.top();
            q.pop();
        }
    }

    std::cout << cnt << '\n';

    return 0;
}


Measured memory_bytes: 5504
#ifndef ___Class_RangeTree
#define ___Class_RangeTree

// ------ Includes ------ //
#include <limits>
#include <vector>
#include <algorithm>

template<typename Type> class RangeTree {
private:
	int size_;
	std::vector<std::vector<Type> > dat;
	std::vector<std::vector<int> > vl;
	inline int query_(int a, int b, Type x, int k, int l, int r, int e) {
		// Find range [a, b) : value < x : Now k-th node and the range is [l, r) and e integers below x in the range
		if (r <= a || b <= l || e == 0) return 0;
		if (a <= l && r <= b) return e;
		int lc = query_(a, b, x, k << 1, l, (l + r) >> 1, vl[k][e - 1]);
		int rc = query_(a, b, x, k << 1 | 1, (l + r) >> 1, r, e - vl[k][e - 1]);
		return lc + rc;
	}
public:
	RangeTree() : size_(0), dat(std::vector<Type>()) {};
	template<class T>
	RangeTree(T begin_, T end_) {
		int n = (end_ - begin_);
		for (size_ = 1; size_ < n; size_ <<= 1);
		dat.resize(size_ << 1, std::vector<Type>());
		vl.resize(size_, std::vector<int>());
		for (int i = 0; i < n; i++) dat[i + size_].push_back(*(begin_ + i));
		for (int i = size_ - 1; i > 0; i--) {
			dat[i].resize(dat[i << 1].size() + dat[i << 1 | 1].size());
			vl[i].resize(dat[i].size());
			int cl = 0;
			for (int j = 0; j < dat[i].size(); j++) {
				if (j - cl == dat[i << 1 | 1].size() || (cl != dat[i << 1].size() && dat[i << 1][cl] < dat[i << 1 | 1][j - cl])) dat[i][j] = dat[i << 1][cl++];
				else dat[i][j] = dat[i << 1 | 1][j - cl];
				vl[i][j] = cl;
			}
		}
	}
	inline int size() { return size_; }
	inline int query(int l, int r, Type x) {
		// Find range [a, b) : value < x
		int ptr = lower_bound(dat[1].begin(), dat[1].end(), x) - dat[1].begin();
		return query_(l, r, x, 1, 0, size_, ptr);
	}
};

#endif

#include <cstdio>
#include <vector>
#pragma warning(disable : 4996)
using namespace std;
int N, Q, xl, yl, xr, yr;
int main() {
	scanf("%d%d", &N, &Q);
	vector<pair<int, int> > p(N);
	for (int i = 0; i < N; i++) scanf("%d%d", &p[i].first, &p[i].second);
	sort(p.begin(), p.end());
	vector<int> z1(N), z2(N);
	for (int i = 0; i < N; i++) {
		z1[i] = p[i].first;
		z2[i] = p[i].second;
	}
	RangeTree<int> seg(z2.begin(), z2.end());
	while (Q--) {
		scanf("%d%d%d%d", &xl, &yl, &xr, &yr);
		int ptr1 = lower_bound(z1.begin(), z1.end(), xl) - z1.begin();
		int ptr2 = lower_bound(z1.begin(), z1.end(), xr + 1) - z1.begin();
		int res1 = seg.query(ptr1, ptr2, yl);
		int res2 = seg.query(ptr1, ptr2, yr + 1);
		printf("%d\n", res2 - res1);
	}
	return 0;
}

Measured memory_bytes: 4108
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

int main(){
  ll n,y;cin>>n>>y;
  set<ll> s;
  rep(i,n+1){
    if(y-1000*i>=0){
      s.insert(y-1000*i);
    }
  }
  rep(i,n+1){
    rep(j,n+1){
      if(s.count(10000*i+5000*j)){
        if(i+j+(y-10000*i-5000*j)/1000==n){
          cout<<i<<" "<<j<<" "<<(y-10000*i-5000*j)/1000<<endl;
          return 0;
        }
      }
    }
  }
  cout<<-1<<" "<<-1<<" "<<-1<<endl;
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
string s;
long long l,r;
int p;
int n;
long long num[200010][26];
vector<int>zfunc()
{
	vector<int>z(1000010);
	int l=0,r=0;
	int ln=s.size();
	for(int k=2;k<=ln;k++)
	{
		if(s[k-1]!=s[0])continue;
		if(k>r)
		{
			l=r=k;
			while(r<=ln&&s[r-1]==s[r-l])r++;
			r--;
			z[k]=r+1-l;
		}
		else
		{
			int tk=k+1-l;
			if(z[tk]<r+1-k)
				z[k]=z[tk];
			else
			{
				l=k;
				while(r<=ln&&s[r-1]==s[r-l])r++;
				r--;
				z[k]=r+1-l;
			}
		}
	}
	return z;
}
long long doit(long long x,int y)
{
	if(x<=n)return num[x][y];
	if(x<=2*n)return num[n][y]+num[x-n][y];
	long long x1=num[n][y]+num[p][y],x2=num[n][y];
	long long l1=n+p,l2=n;
	while(x>l1+l2)
	{
//		cout<<x1<<" "<<x2<<" "<<l1<<" "<<l2<<endl;
		long long t=x1;
		x1+=x2;
		x2=t;
		t=l1;
		l1+=l2;
		l2=t;
	}
	x1+=doit(x-l1,y);
//	cout<<x<<" "<<x1<<endl;
	return x1;
}
long long sol(long long x,int y)
{
	if(x<=n)return num[x][y];
//	if(x<=2*n)return num[n][y]+num[x-n][y];
	if(n%p==0)
	{
		long long xx=(x-n)/(long long)p*num[p][y]+num[n][y];
		x%=(long long)p;
		xx+=num[x][y];
		return xx;
	}
	return doit(x,y);
}
int main()
{
	cin>>s>>l>>r;
	n=s.size()/2;
	vector<int>z=zfunc();
	for(int i=n+2;i<=2*n;i++)
	{
		if(i+z[i]==2*n+1)
		{
			p=z[i];
			break;
		}
	}
	p=n-p;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<26;j++)num[i][j]+=num[i-1][j];
		num[i][s[i-1]-'a']++;
	}
	for(int i=0;i<26;i++)cout<<sol(r,i)-sol(l-1,i)<<" ";
	cout<<endl;
	return 0;
}

Measured memory_bytes: 24964
h, w = map(int, input().split())
s = [list(input()) for i in range(h)]

command = (-1, 0, 1)
for row in range(h):
    ans = ""
    for col in range(w):
        if s[row][col] == "#":
            ans += "#"
        else:
            bomb = 0
            for i in command:
                for j in command:
                    if 0 <= row + i < h and 0 <= col + j < w and s[row + i][col + j] == "#":
                        bomb += 1
            ans += str(bomb)
    print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include <string>
#include <iomanip>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <math.h>
#include <stack>
#include <cctype>
using namespace std;
#define int long long
#define pi 2*acos(0.0)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)

signed main()
{
	int r;
	cin >> r;
	cout << 800*r - 200*(r/15) << endl;
}


Measured memory_bytes: 256
#include <cstdio>

int main() {
  int n;
  scanf("%d", &n);
  int ret = 1;
  for (int i = 0, x; i < n; ++i) {
    scanf("%d", &x);
    ret &= (x % 2 == 1) || (x % 3 == 0) || (x % 5 == 0);
  }
  if (ret) puts("APPROVED");
  else puts("DENIED");
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
int main(void){
    int i,n;
    int a[10000],b[10000];
    int pa,pb;
    
    while(1){
        scanf("%d",&n);
        if(n==0)break;
        
        pa=pb=0;
        for(i=0;i<n;i++){
            scanf("%d %d",&a[i],&b[i]);
            
            if(a[i]-b[i]>0)pa+=a[i]+b[i];
            else if(a[i]-b[i]<0)pb+=a[i]+b[i];
            else {
                pa+=a[i];
                pb+=b[i];
            }
        }
        
        printf("%d %d\n",pa,pb);
    }
    
    return 0;
}

Measured memory_bytes: 676
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,ans=0;cin>>n;
  lvector A(n);rep(i,n) cin>>A[i];sort(ALL(A));
  vector<bool> v(1000001,false);
  rep(i,n-1) {
    if(v[A[i]]==true) continue;
    if(A[i]<A[i+1]) ans++;
    ll b=A[i];
    while(b<1000001) {v[b]=true;b+=A[i];}
  }
  if(v[A[n-1]]==false) ans++;
  print(ans);
  return 0;
}

Measured memory_bytes: 5080
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 2e5 + 10; 

int n,k;
int P[N][62];

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   cin >> n >> k;
   f(i,1,n+1){
      int x;
      cin >> x;
      P[i][0] = x;
   }
   f(j,1,62){
      f(i,1,n+1){
         if(P[i][j-1]){
            P[i][j] = P[P[i][j-1]][j-1];
         }
      }
   }
   int cur = 1;
   f(i,0,62){
      if((1ll<<i)&k){
         cur = P[cur][i];
      }
   }
   cout << cur << '\n';
   return 0;
} 

Measured memory_bytes: 100536
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll x[10005],y[10005],h[10005],n;

int check(ll cx,ll cy){
	int H=-1;
	
	for (int i=0;i<n;i++){
		if (h[i]>0){
			H=h[i]+abs(cx-x[i])+abs(cy-y[i]);
			if (H>=1) break;
			else H=-1;
		}
	}
	
	for (int i=0;i<n;i++){
		ll _h=max(H-abs(cx-x[i])-abs(cy-y[i]),(ll)0);
		if (_h!=h[i]){
			return -1;
		}
	}
	
	return H;
}

int main(){
	cin>>n;
	
	for (int i=0;i<n;i++){
		cin>>x[i]>>y[i]>>h[i];
	}	
	
	int ans=-1;
	
	for (int i=0;i<=100;i++){
		for (int j=0;j<=100;j++){
			if ((ans=check(i,j))!=-1){
				
				cout<<i<<" "<<j<<" "<<ans<<endl;
				return 0;
			}
		}
	}
}
 

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

int main() {
    int N;
    while (cin >> N, N) {
        int S = 0;
        if (N != 1) S = 1;
        for (int i=2; i*i<=N; ++i) {
            if (i * i == N) {
                S += i;
            } else if (N % i == 0) {
                S += i;
                S += N / i;
            }
        }
        if (N == S) {
            cout << "perfect number" << endl;
        } else if (N > S) {
            cout << "deficient number" << endl;
        } else if (N < S) {
            cout << "abundant number" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1156
($a,$b,$x)=glob<>;
$x/=$a;
$PI=3.14159265358979323846;
if($x>$a*$b/2){
	print 180/$PI*atan2(2*($a*$b-$x)/$a**2,1)
}else{
	print 180/$PI*atan2($b**2/(2*$x),1)
}


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

#define INF INT_MAX
#define UINF UINT_MAX
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef std::pair<int,int> pii;

using namespace std;

int temp(int a){
    int r = 0;
    if(a == 1){
        return 300000;
    }else if(a == 2){
        return 200000;
    }else if(a == 3){
        return 100000;
    }
    return 0;
}

int main() {
    int x,y;
    cin >> x >> y;

    
    int ans = temp(x) + temp(y);
    if(x == 1 && y == 1){
        ans += 400000;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
hash = {
  1 => 0,
  2 => 0,
  3 => 0,
  4 => 0,
  5 => 0,
  6 => 0,
}

n = gets.chomp.to_i

n.times do
  height = gets.chomp.to_f
  if height < 165.0
    hash[1] += 1
  elsif height < 170.0
    hash[2] += 1
  elsif height < 175.0
    hash[3] += 1
  elsif height < 180.0
    hash[4] += 1
  elsif height < 185.0
    hash[5] += 1
  else
    hash[6] += 1
  end
end

hash.each do |key, value|
  puts sprintf('%d:%s', key, '*' * value)
end

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


int main(void){
  int n,m,i,s[6],c[6],d[4],t,k;
  
  cin >> n >> m;
  for (i=0;i<m;i++) cin >> s[i] >> c[i];
  
  for (i=0;i<m;i++){
    if (s[i]!=1 || c[i]!=0) break;
  }
  if (i==m && n==1){
    cout << 0 << endl;
    return 0;
  }
  
  for (t=1;t<1000;t++){
    vector<int> d;
    k=t;
    while (k>0){
      d.push_back(k%10);
      k/=10;
    }
    if (d.size()!=n) continue;
    for (i=0;i<m;i++){
      if (s[i]>d.size()) break;
      if (d[d.size()-s[i]]!=c[i]) break;
    }
    if (i==m) break;
  }
  
  if (t==1000) cout << -1 << endl;
  else cout << t << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

int main(){
  ll x;
  cin >> x;
  map<ll,int> st;
  for(ll i=0; i<4000; i++){
    ll tmp = i*i*i*i*i;
    st.emplace(tmp,i);
  }
  for(auto it:st){
    if(st.count(x+it.F)){
      cout << st[x+it.F] << " " << it.S << endl; return 0;
    }
    if(st.count(x-it.F)){
      int tmp = -1*it.S;
      cout << st[x-it.F] << " " << tmp << endl; return 0;
    }
  }
  return 0;
}

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

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

	std::string S;
	int K, N;
	std::cin >> N >> K >> S;
	S[K-1] -= ('A' - 'a');
	std::cout << S;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;
using f32 = float;
using f64 = double;
using i8 = int_fast8_t;
using u8 = uint_fast8_t;
using i16 = int_fast16_t;
using u16 = uint_fast16_t;
using i32 = int_fast32_t;
using u32 = uint_fast32_t;
using i64 = int_fast64_t;
using u64 = uint_fast64_t;
inline void fast_io() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

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

    string s;
    cin >> s;
    bool flag = true;
    for (i32 i = 0, j = s.length() - 1; i < j; i++, j--) {
        if (s[i] != s[j]) {
            flag = false;
            break;
        }
    }
    for (i32 i = 0, j = (s.length() - 1) / 2 - 1; i < j; i++, j--) {
        if (s[i] != s[j]) {
            flag = false;
            break;
        }
    }
    for (i32 i = (s.length() + 3) / 2 - 1, j = s.length() - 1; i < j;
         i++, j--) {
        if (s[i] != s[j]) {
            flag = false;
            break;
        }
    }
    if (flag) {
        cout << "Yes";
    } else {
        cout << "No";
    }

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<cstring>
#include<queue>
#include<cmath>
#include<algorithm>
using namespace std;
const int MAXN=105;
int n;
int a[MAXN];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	int ans=100000000;
	for(int i=-100;i<=100;i++)
	{
		int jans=0;
		for(int j=1;j<=n;j++)
		{
			jans+=(a[j]-i)*(a[j]-i);
		}
		ans=min(ans,jans);
	}
	printf("%d\n",ans);
}

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

using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define mod 1000000007
#define endl "\n"

set<ll> adj[100005];
vector<ll> a[100005]; 
map<pair<ll,ll>,ll> hm;

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

    // cout<<fixed<<setprecision(15);

    ll n;
    cin>>n;

    ll a[n];

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

    ll ans[n];

    ll x = a[0];

    for(ll i = 1 ; i < n ; i++)
    {
        x = a[i] - x;
    }

    x /= 2;

    ans[0] = a[0] - x;
    ans[n - 1] = x;

    for(ll i = 1 ; i < n - 1 ; i++)
    {
        ans[i] = a[i] - ans[i - 1];
    }

    cout<<2*ans[n-1]<<" ";
    for(ll i = 0 ; i < n - 1; i++)
    {
        cout<<2 * ans[i]<<" ";
    }



}

Measured memory_bytes: 9984
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int main(){
    cout << fixed << setprecision(10);
    string s;
    ll k;
    cin >> s >> k;
    rep(i,int(s.size())){
        int sub = 'z' - s[i]  + 1;
        if(sub <= k && i != int(s.size()) - 1 && s[i] != 'a'){
            s[i] = 'a';
            k -= sub;
        }
        if(sub <= k && i == int(s.size()) - 1){
            int subsub = (k - sub) % ('z' - 'a' + 1);
            s[i] = char('a' + subsub);
        }
        if(sub > k && i == int(s.size() - 1) ){
            s[i] = char(s[i] + k);
        }
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  if(a+b == 15) cout << "+" << endl;
  else if(a*b == 15) cout << "*" << endl;
  else cout << "x" << endl;  
  return 0;
}

Measured memory_bytes: 256
n=int(input())
patt=[]  #パターンを格納するためのリスト
for i in range(2 ** n): #全パターンを作る
  bag = []
  for j in range(n):  
    if ((i >> j) & 1):
      bag.append(1)  
    else:
      bag.append(0)
  patt.append(bag)
per=[[-1 for i in range(n)] for l in range(n)] #証言格納用のリストを作っている、発言していないものは-1
for s in range(n): #証言を二次元リストに格納するためのループ
  a=int(input())
  for t in range(a):    
    x, y = map(int, input().split())
    per[s][x-1]=y
ma=0
for i in patt: #一個ずつ、パターンをチェックするためのループ
  check=0
  for l in range(n): #各人の真偽について
    if i[l]==1: #i[l]が正しかった場合
      for t in range(n): #lさんの発言一個一個を確認する
        if per[l][t]!=i[t] and per[l][t]!=-1:
          check=-1
          break
        else:
          continue
  if check==0:
    ma=max(ma, sum(i))
        
print(ma)

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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

template <typename T>
class range_add_range_sum {
	const int n;
	const T id;
	vector<T> data, data2;
	int size(int n) {
		int res = 1;
		while (res < n) res <<= 1;
		return res;
	}
	T sub(int l, int r, int node, int lb, int ub) {
		if (ub <= l || r <= lb) return id;
		if (l <= lb && ub <= r) return data[node] + data2[node] * (ub - lb);
		return data2[node] * (min(r, ub) - max(l, lb))
			+ sub(l, r, node * 2, lb, (lb + ub) / 2)
			+ sub(l, r, node * 2 + 1, (lb + ub) / 2, ub);
	}
	void suc(int l, int r, int node, int lb, int ub, T val) {
		if (ub <= l || r <= lb) return;
		if (l <= lb && ub <= r) {
			data2[node] += val;
			return;
		}
		data[node] += val * (min(r, ub) - max(l, lb));
		suc(l, r, node * 2, lb, (lb + ub) / 2, val);
		suc(l, r, node * 2 + 1, (lb + ub) / 2, ub, val);
	}
public:
	range_add_range_sum(int n_) : n(size(n_)), id(0), data(n * 2, id), data2(n * 2, id) {}
	void add(int l, int r, T val) {
		suc(l, r + 1, 1, 0, n, val);
	}
	T getsum(int l, int r) {
		return sub(l, r + 1, 1, 0, n);
	}
};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  LL N,Q;
  cin >> N >> Q;
  range_add_range_sum<LL> rars(N+1);

  REP(i,Q){
		LL y;
		cin >> y;
		if(y==0){
			LL s, x;
			cin >> s >> x;
			rars.add(s, s, x);
		}
		else
		{
			LL s, t;
			cin >> s >> t;
			cout << rars.getsum(s, t)<<endl;
		}
	}
}



Measured memory_bytes: 7020
#include <cstdio>
#include <iostream>
#define MN 18
#define mod 1000000007

int n, m;
int a[MN], w[MN];
int f[MN][1 << MN];
int fac[1 << MN], inv[1 << MN];

int inc(int a, int b) {return (a += b) >= mod ? a - mod : a;}
int dec(int a, int b) {return (a -= b) < 0 ? a + mod : a;}

int C(int a, int b) {if(a < b) return 0; return 1ll * fac[a] * inv[b] % mod * inv[a - b] % mod;}

int main()
{
	fac[0] = inv[0] = inv[1] = 1;
	for(int i = 1; i <= 65536; i++) fac[i] = 1ll * fac[i - 1] * i % mod;
	for(int i = 2; i <= 65536; i++) inv[i] = 1ll * (mod - mod / i) * inv[mod % i] % mod;
	for(int i = 1; i <= 65536; i++) inv[i] = 1ll * inv[i - 1] * inv[i] % mod;
	
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= m; i++) scanf("%d", &a[i]);
	w[0] = 1; for(int i = 1; i <= n; i++) w[i] = inc(w[i - 1], w[i - 1]);
	f[m + 1][0] = 1;
	for(int i = m; i >= 1; i--)
	{
		for(int S = 0; S < (1 << n); S++)
		{
			int tot = 0;
			for(int j = 0; j < n; j++)
				if((S >> j) & 1) tot += w[j];
			f[i][S] = f[i + 1][S];
			
			for(int j = 0; j < n; j++)
				if((S >> j) & 1)
					f[i][S] = dec(f[i][S], 1ll * C((w[n] - a[i]) - (tot - w[j]), w[j] - 1) * fac[w[j]] % mod * f[i + 1][S ^ (1 << j)] % mod);
		}
	}
	
	int Ans = 0;
	for(int S = 0; S < (1 << n); S++)
	{
		int tot = w[n] - 1;
		for(int j = 0; j < n; j++)
			if((S >> j) & 1) tot -= w[j];
		
		for(int j = 0; j < n; j++)
			if(!((S >> j) & 1))
			{
				f[1][S] = 1ll * C(tot, w[j]) * fac[w[j]] % mod * f[1][S] % mod;
				tot -= w[j];
			}
		Ans = inc(Ans, f[1][S]);
	}
	
	printf("%lld\n", 1ll * Ans * w[n] % mod);
}

Measured memory_bytes: 19200
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

long long N, K, A[1 << 18];

int main() {
	cin >> N >> K;
	for (int i = 1; i <= N; i++) cin >> A[i];

	long long S = 0, maxn = 0;
	for (int i = 1; i <= K; i++) S += A[i];
	maxn = max(maxn, S);
	for (int i = K + 1; i <= N; i++) { S += A[i]; S -= A[i - K]; maxn = max(maxn, S); }

	double I = 0.5 * (maxn + K);
	printf("%.12lf\n", I);
	return 0;
}

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


int main(void) {
	// 自分の得意な言語で
	// Let's チャレンジ！！

	int n;
	int nn[20];

	cin >> n;

	for (int i = 0; i < n; i++)
	{
		cin >> nn[i];
	}
	int a = 0;
	for (int i = 1; i < n - 1; i++)
	{
		if (nn[i - 1] < nn[i] && nn[i] < nn[i + 1])
			a++;
        else if (nn[i - 1] > nn[i] && nn[i] > nn[i + 1])
          a++;
	}
	cout << a << endl;

	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import math

a, b = map(int, input().split())

temp_a1 = 100 * a // 8
temp_a2 = 100 * (a + 1) // 8
temp_b1 = 10 * b
temp_b2 = 10 * (b + 1)

result = -1
for i in range(min(int(temp_a1), int(temp_b1)), min(int(temp_a2), int(temp_b2))):
    if math.floor(i * 0.08) == a and math.floor(i * 0.1) == b:
        result = i
        break

print(result)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef long double lld;
#define mod 1000000007
#define mod2 998244353
#define fori(n) for (int i = 0; i < n; i++)
#define forj(n) for (int j = 0; j < n; j++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define sortvec(a) sort(a.begin(), a.end())
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl
#define cerr if(true)cerr
void print(){cout<<endl;}
template<typename T,typename... Args>
void print(T a, Args... args) {cout<<a<<" ";print(args...);}
lli llipowerp(lli x, lli y, lli p=LLONG_MAX)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1) res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
lli binarySearch(vector<int> arr, int l, int r, int x)
{
    if (r >= l)
    {
        lli mid = l + (r - l) / 2;
        if (arr[mid] == x)
            return mid;
        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);
        return binarySearch(arr, mid + 1, r, x);
    }
    return -1;
}
template <typename T>
inline void printvec(vector<T> inp){
    for(auto it:inp) cout<<it<<" ";
    cout << endl;
}
//---------------------------------------------------------------------------------
vector<int> h;
int dp[(int)1e5+5];
int fill(int n){
    if(dp[n]!=-1) return dp[n];
    if(n==1) return 0;
    if(n==2) return abs(h[2]-h[1]);
    dp[n]=min(fill(n-1)+abs(h[n]-h[n-1]),fill(n-2)+abs(h[n]-h[n-2]));
    return dp[n];
}
int main(){
    int n;
    cin>>n;
    h.resize(n+1);
    fori(n) cin>>h[i+1];
    memset(dp,-1,sizeof(dp));
    cout<<fill(n)<<endl;

}


Measured memory_bytes: 3328
n = int(input())
pList = [int(x) for x in input().split()]

c = 0
for i,j,k in zip(pList[0:], pList[1:], pList[2:]):
    x = [i,j,k]
    x.sort()
    if x[1] == j:
        c += 1
print(c)

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

const int N = 200010;

int n, a[N];
int l[N], r[N];
long long ans;

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

	stack<int> st;
	for (int i = 1; i <= n; ++i) {
		while(!st.empty() && a[st.top()] > a[i]) st.pop();
		if (st.empty()) l[i] = 1; else l[i] = st.top() + 1;
		st.push(i);
	}

	st = stack<int>();
	for (int i = n; i >= 1; --i) {
		while(!st.empty() && a[st.top()] > a[i]) st.pop();
		if (st.empty()) r[i] = n; else r[i] = st.top() - 1;
		st.push(i);
	}

	for (int i = 1; i <= n; ++i) {
		ans += 1ll * a[i] * (r[i] - i + 1) * (i - l[i] + 1);
	}

	cout << ans << endl;
}

Measured memory_bytes: 3456
// https://atcoder.jp/contests/abc167/tasks/abc167_e
// 
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define is_in(i, s) (s.find(i) != s.end())
#define all(x) (x).begin(),(x).end()
#define outl(x) cout<<x<<endl
#define outsp(x) cout<<x<<" "
typedef long long ll;
typedef pair<int,int> P;

#define MAX_N 200005
#define M 998244353
vector<ll> fac(MAX_N); //n!(mod M)
vector<ll> ifac(MAX_N); //k!^{M-2} (mod M)

ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1; // n = n/2
    }
    return ans;
}
void init_comb(){
	fac[0] = 1;
	ifac[0] = 1;
	for(ll i = 1; i<MAX_N; i++){
		fac[i] = fac[i-1]*i % M; // n!(mod M)
		ifac[i] = ifac[i-1] * mpow(i, M-2) % M; // k!^{M-2} (mod M)
	}
}
ll combination(ll n,ll m){
	if(m==n || m==0) return 1;
	ll tmp = fac[n] * ifac[m] % M;
	return tmp * ifac[n-m] % M;
}


int main() {
	init_comb();
	ll n,m,k;
	cin >> n >> m >> k;
	ll ans=0;
	rep(i,k+1){
		ll tmp = m * mpow(m-1,n-1-i) % M;
		tmp = (tmp * combination(n-1,i)) % M;
		ans = (ans + tmp) % M;
	}
	outl(ans);
    return 0;
}



Measured memory_bytes: 6288
import queue
import math
q = queue.Queue()
A = []
B = []
N,M = map(int,input().split())
check = [-1]*N
graph = [[] for i in range(N+1)]
flag = [0]*N
for i in range(M):
	lines = list(map(int,input().split()))
	A.append(lines[0])
	B.append(lines[1])
	graph[lines[0]].append(lines[1])
	graph[lines[1]].append(lines[0])

q.put(1)
check[0] = 0
while not q.empty():
	p = q.get()
	for np in graph[p]:
		if check[np-1] == -1:
			check[np-1] = check[p-1] + 1
			q.put(np)

for i in range(M):
	if check[A[i]-1] - check[B[i]-1] == 1:
		flag[A[i]-1] = B[i]
	if check[B[i]-1] - check[A[i]-1] == 1:
		flag[B[i]-1] = A[i]

print('Yes')
for i in range(1,N):
	print(flag[i])


Measured memory_bytes: 38076
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i, n) for (int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"
#define fcout cout << fixed << setprecision(18)

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926535
/*
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
*/
#define ll long long int         // 10^18
#define INF 1000000001           // 1e9+1
#define LINF 1000000000000000001 // 1e18+1

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

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

    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    
    string a;cin>>a;
    int c=0;
    for(int i=0;i<6;i++){
        if(a[i]=='1')c++;
    }
    P(c);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int K, T;
    cin >> K >> T;
    vector<int> A(T);

    rep(i, T) cin >> A[i];

    int ans = 0;
    if (T == 1) {
        ans = K - 1;
    }
    while (T != 1) {
        sort(all(A));
        reverse(all(A));
        if (A[0] == 0) {
            ans = 0;
            break;
        }
        else if (A[1] == 0) {
            ans = A[0] - 1;
            break; 
        }
        A[0]--;
        A[1]--;
    }

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

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

public class Main {

	public static void main(String args[]) throws Exception {
		MyScanner sc = new MyScanner();
		PrintWriter pr = new PrintWriter(System.out);
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		List<List<Integer>> graph = new ArrayList<>();
		
		for(int i = 0; i <= n; i++)
			graph.add(new ArrayList<>());
		
		int heights[] = new int[n + 1];
		
		for(int i = 0; i < n; i++)
			heights[i + 1] = sc.nextInt();
		
		for(int i = 0; i < m; i++ ) {
			int u = sc.nextInt();
			int v = sc.nextInt();
			
			graph.get(u).add(v);
			graph.get(v).add(u);
		}
		int count = 0;
		for(int i = 1; i <= n; i++) {
			List<Integer> neighbour = graph.get(i);
			boolean isgood = true;
			for(int x : neighbour) {
				
				if(heights[x] >= heights[i]) {
					isgood = false;
					break;
				}
			}
			if(isgood) {
				//System.out.println(i);
				count++;
			}
		}
		System.out.println(count);
		
		pr.close();
	}

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

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

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

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

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}

Measured memory_bytes: 67788
#include<stdio.h>
#include<math.h>
typedef struct{
  double x;
  double y;
}POINT;

void koch(int,POINT,POINT);

int main(){
  POINT a,b;
  int n;
  scanf("%d",&n);
  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;
  printf("%.8f %.8f\n",a.x,a.y);
  koch(n,a,b);
  printf("%.8f %.8f\n",b.x,b.y);

  return 0;
}

void koch(int n,POINT a,POINT b){
  POINT s,t,u;
  double th = M_PI * 60 / 180;
  if(n == 0)return;
  s.x = (2 * a.x + 1 * b.x) / 3;
  s.y = (2 * a.y + 1 * b.y) / 3;
  t.x = (1 * a.x + 2 * b.x) / 3;
  t.y = (1 * a.y + 2 * b.y) / 3;
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;
  koch(n-1,a,s);
  printf("%.8f %.8f\n",s.x,s.y);
  koch(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  koch(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  koch(n-1,t,b);
}



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

int main()
{
	long long n,m;
	cin>>n>>m;
	long long sum=0;
	long long x;
	for(long long i=0;i<m;++i)
	{
		cin>>x;
		sum+=x;
	}
	if(sum>n)
		cout<<"-1\n";
	else
		cout<<n-sum<<endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
 
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
     
    int n;
    cin >> n;
     
    while(n-- > 0){
     
    double x1, y1, x2, y2, x3, y3;
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
     
    double a = 2 * (x2 - x1);
    double b = 2 * (y2 - y1);
    double c = x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2;
    double d = 2 * (x3 - x2);
    double e = 2 * (y3 - y2);
    double f = x2 * x2 - x3 * x3 + y2 * y2 - y3 * y3;
         
    double cx = (b * f - c * e)/(a * e - d * b);
    double cy = (a * f - c * d)/(b * d - a * e);
         
    double r = sqrt((x1 - cx)*(x1 - cx) + (y1 - cy)*(y1 - cy));
     
    cout << fixed << setprecision(3) << cx << " " << cy << " " << r << endl;
     
    }
     
    return 0;
}

Measured memory_bytes: 3292
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()


using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;

const ll MOD = INF + 7;

const double pi = 3.14159265358979323846264338327950288419716939937510;
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int sum = 0;
    rep(i, n){
        cin >> a[i];
        sum += a[i];
    }
    sort(ALL(a));
    bool f;
    if(sum % 10 == 0)f = false;
    else f = true;
    if(!f){
        rep(i, n)if(a[i] % 10 != 0){
            sum -= a[i];
            f = true;
            break;
        }
    }
    cout << (f ? sum : 0) << endl;
}




Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include<map>
#include<tuple>
using namespace std;
#define INF 1100000000000
#define MAX 1100000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<pair<int,int>,int> p;
typedef pair< pair<int,int>, int> p; 
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
//__builtin_popcount(S)

ll dp[1<<22];

int main(){
    int N,a[22][22];
    cin>>N;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++) cin>>a[i][j];
    }
    dp[0]=1;
    for(int S=1;S<(1<<N);S++){
        for(int i=0;i<N;i++){
            if(bit(S,i)){
                int num=__builtin_popcount(S);
                num--;
                if(a[num][i]==0) continue;
                dp[S]+=dp[S^(1<<i)];
                dp[S]%=MOD;
            }
        }
        //return 0;
    }
    //cout<<dp[2]<<endl;
    cout<<dp[(1<<N)-1]<<endl;
}



Measured memory_bytes: 18688
/* Manish Pant - insider_pants */
    
#include <bits/stdc++.h>
using namespace std;
    
#define F first
#define S second
#define endl "\n"
#define pb push_back
    
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
    
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ", "; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << " "; return os; }
template <class T> ostream& operator << (ostream &os, const multiset<T> &v) { for (T i : v) os << i << " "; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.F << ' ' << v.S; return os; }
template <class T, class S> ostream& operator << (ostream &os, const map<T, S> &v) { for (auto i : v) os << '(' << i.F << " => " << i.S << ')' << ' '; return os; } 

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

ll a, b;
void solve()
{
    for(int i = 1; i < 100000; i++)
    {
        if((i * 8 / 100 == a) && (i * 10 / 100 == b))
        {
            cout<<i<<endl;
            return;
        }
    }
    cout<<-1<<endl;
}

int main()
{
    fast();
    cin>>a>>b;
    solve();
}

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

int main(){
	int a, b, c, d;
  	cin >> a >> b >> c >> d;
  
  	while(a > 0 || c > 0){
    	c -= b;
      	if(c <= 0) break;
      	a -= d;
    }
  
  	cout << (a > 0 ? "Yes" : "No") << endl;
}

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

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

  int ans = 0;

  string A = S.substr(0, S.size() / 2);
  string B = S.substr(S.size() / 2);
  reverse(B.begin(), B.end());
  for (int i = 0; i < A.size(); i++) {
    if (A.at(i) != B.at(i)) ans++;
  }

  cout << ans << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;

#define PI 3.14159265358979323846264338327950L

int res;

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

    string S;
    cin >> S;
    if (S=="ABC"){
        cout << "ARC" << endl;
    }else{
        cout << "ABC" << endl;
    }
return 0;
}

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

int main()
{
    int h,w,a,b;
    cin >> h >> w >> a >> b;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(i<b){
                if(j<a) cout << 0;
                else cout << 1;
            }
            else{
                if(j<a) cout << 1;
                else cout << 0;
            }
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
 
int main(){
  string s;
  cin>>s;
  int n=s.size();
  ll arr[n+1]={0};
  for(int i=0;i<n;i++)
  {
    if(s[i]=='<')
    {
      arr[i+1]=arr[i]+1;
    }
  }
  for(int i=n-1;i>=0;i--)
  {
    if(s[i]=='>')
    {
      arr[i]=max(arr[i+1]+1,arr[i]);
    }
  }
  ll ans=0;
  for(int i=0;i<n+1;i++)
  {
    ans+=arr[i];
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 7712
#include<iostream>
#include<cmath>
#include<set>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(ui,n)  REP(i,0,n)
#define double long double
const double r = 1./sqrt(3);
const double pi=acos(-1);
const double eps = 1e-10;

double CONVERT(double r){
  return r*pi/180.;
}

double solve(int n,double theta){
  double npolygon=0,minus=0;
  double l =2*r*sin(CONVERT(theta/2));
  npolygon=n*r*r*cos(CONVERT(theta/2))*sin(CONVERT(theta/2));
  minus=n*l*tan(CONVERT(60-theta/2))*l/4.;
  return npolygon-minus;
}

main(){
  int n;
  while(cin>>n && n){
    double now=0;
    if (n%3 == 0){
      printf("%.6Lf\n",solve((int)n,360./n));
    }else {
      printf("%.6Lf\n",solve((int)3*n,120./n));      
    }
  }
  return false;
}

Measured memory_bytes: 0
x = 0
MASK = 2 ** 64 - 1

def x_test(i):
    return int((x & (1 << i)) > 0)
def x_set(m):
    global x
    x |= M[m]
def x_clear(m):
    global x
    x = (x | M[m]) ^ M[m]
def x_flip(m):
    global x
    x ^= M[m]
def x_all(m):
    return int(x & M[m] == M[m])
def x_any(m):
    return int(x & M[m] > 0)
def x_none(m):
    return int(x & M[m] == 0)
def x_count(m):
    return bin(x & M[m]).count("1")
def x_val(m):
    return x & M[m]
    
command = [
    x_test,
    x_set,
    x_clear,
    x_flip,
    x_all,
    x_any,
    x_none,
    x_count,
    x_val
]

M = []
N = int(input())
for i in range(N):
    k, *B = map(int, input().split())
    M.append(sum(1 << b for b in B))
    
q = int(input())
for j in range(q):
    t, cmd = map(int, input().split())
    ans = command[t](cmd)
    if ans is not None:
        print(ans)


Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	    // #ifndef ONLINE_JUDGE
     //   // for getting input from input.txt
     //   freopen("input.txt", "r", stdin);
     //   // for writing output to output.txt
     //   freopen("output.txt", "w", stdout);
     //  #endif
		ll n,t=1,a=0;
		cin>>n;
		vector<ll> v(n,0);
		for (int i = 0; i < n; ++i)
		{
			cin>>v[i];
			if(v[i]%2 != 0){
				cout<<0<<endl;
				return 0;
			}
		}
		while(t == 1){
			for (int i = 0; i < n; ++i)
			{
				if(v[i]%2 == 0){
					v[i] = v[i]/2;
				}
				else{
					t = 0;
				}

			}
			a++;
		}
		cout<<a-1<<endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"sort"
	"strconv"
)

type IntListForSort []int

func (s IntListForSort) Len() int           { return len(s) }
func (s IntListForSort) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s IntListForSort) Less(i, j int) bool { return s[i] < s[j] }

func sortIntList(intList []int) {
	sort.Sort(IntListForSort(intList))
}

type IntListForSortDesc []int

func (s IntListForSortDesc) Len() int           { return len(s) }
func (s IntListForSortDesc) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s IntListForSortDesc) Less(i, j int) bool { return s[i] > s[j] }

func sortIntListDesc(intList []int) {
	sort.Sort(IntListForSortDesc(intList))
}

// ASC前提
func binarySearchInt(intList []int, key int, iMin int, iMax int) int {
	if iMax < iMin {
		return -1
	} else {
		iMid := iMin + (iMax-iMin)/2
		if intList[iMid] > key {
			return binarySearchInt(intList, key, iMin, iMid-1)
		} else if intList[iMid] < key {
			return binarySearchInt(intList, key, iMid+1, iMax)
		} else {
			return iMid
		}
	}
}

func input() string {
	var s string
	_, _ = fmt.Scan(&s)
	return s
}

func inputLn() string {
	var s string
	_, _ = fmt.Scanln(&s)
	return s
}

func inputByScanner(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func convListStrToInt(strList []string) []int {
	intList := make([]int, len(strList))
	for k, v := range strList {
		intV, _ := strconv.Atoi(v)
		intList[k] = intV
	}
	return intList
}

func convListStrToFloat(strList []string) []float64 {
	intList := make([]float64, len(strList))
	for k, v := range strList {
		intV, _ := strconv.Atoi(v)
		intList[k] = float64(intV)
	}
	return intList
}

func main() {
	n, _ := strconv.Atoi(inputLn())
	aList := make([]int, n)
	bList := make([]int, n)
	cList := make([]int, n-1)
	for i := 0; i < n; i++ {
		v, _ := strconv.Atoi(input())
		aList[i] = v
	}
	for i := 0; i < n; i++ {
		v, _ := strconv.Atoi(input())
		bList[i] = v
	}
	for i := 0; i < n-1; i++ {
		v, _ := strconv.Atoi(input())
		cList[i] = v
	}
	res := 0
	for i := 0; i < n; i++ {
		res += bList[aList[i]-1]
		if i > 0 {
			if aList[i-1] == aList[i]-1 {
				res += cList[aList[i-1]-1]
			}
		}
	}
	fmt.Println(res)
}


Measured memory_bytes: 640