akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

ll n;

int main() {
	cin >> n;
	for (ll i = 1; i <= 3500; ++i) {
		for (ll j = i; j <= 3500; ++j) {
			if ((4 * i*j - n*i - n*j) == 0) continue;
			if ((i*j*n) % (4 * i*j - n*i - n*j) == 0 && 0 < (i*j*n)/(4 * i*j - n*i - n*j)) {
				cout << i << " " << j << " " << (i*j*n)/(4 * i*j - n*i - n*j) << endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int n; cin>>n;
	vector<bool> v(n+100);
	v[1]=1;
	rep(i,2,n+1){
		int a=i*i;
		while(a<=n){
			v[a]=1;
			a*=i;
		}
	}
	for(int i=n;i>=1;--i){
		if(v[i]){
			cout<<i<<endl;
			return 0;
		}
	}
	
	return 0;
}

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

using namespace std;

int main(){
    string s;
    cin>>s;
    int ans1=0,ans2=0;
    for(int i=0;i<s.size();i++){
        if(i&1){
            if(s[i]=='0')ans2++;
            else ans1++;
        }
        else {
            if(s[i]=='1')ans2++;
            else ans1++;
        }
    }
    printf("%d\n",min(ans1,ans2));
    return 0;
}


Measured memory_bytes: 512
n=int(input())
s=input()
ans=0

for ii in range(1000):
    v = str(ii).zfill(3)
    start=0
    f=0
    
    for j in range(3):
        idx=s.find(v[j],start)
        if idx > -1:
            start = idx + 1
            f+=1
        else:
            break

    if f == 3:
        ans += 1

print(ans)


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




int main() {
    int N; cin >> N;
    vector<int> A(N); for(int i = 0; i < N; i++)cin >> A[i];
    int ans=1e9;
    for(int i = -100; i <= 100; i++){
        int temp = 0;
        for(int j = 0; j < N; j++){
            temp += pow(i-A[j], 2);
        }
        ans = min(ans, temp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
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
        

fast();
//ll t;cin>>t;while(t--)
{
    ll n,x;
    cin>>x>>n;
    ll a[105];
    memset(a,0,sizeof(a));
    for(int i=0;i<n;i++)
    {
        ll x;
        cin>>x;
        a[x]++;
    }
    ll f=0,s=0;
     for(int i=x;i<102;i++)
     {
        if(!a[i])
        {
            f=i;
            break;
        }

     }
     for(int i=x;i>=0;i--)
     {
        if(!a[i])
        {
            s=i;
            break;
        }
     }
    // cerr<<f<<" "<<s<<endl;
     if(abs(x-f)<abs(x-s))
        cout<<f;
    else
        cout<<s<<endl;

    
}
return 0;
}

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

unordered_map<int, bool> mp;
const int nax = 1e5 + 4;
vector<int> edges[nax];


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

    while(e--) {
        int a, b;
        cin >> a >> b;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }

    vector<int> ans(n + 1, -1);

    queue<int> q;
    q.push(1);

    ans[1] = 0;

    while(!q.empty()) {


        int top = q.front();
        q.pop();

        for(int b : edges[top]) {
            if(ans[b] == -1) {
                ans[b] = top;
                q.push(b);
            }
        }
    }

    bool ok = true;

    for(int i = 2; i <= n; ++i) {
        if(ans[i] == -1) {
            ok = false;
            break;
        }
    }

    if(ok) {
        cout << "Yes\n";
        for(int i = 2; i <= n; ++i) {
            cout << ans[i] << "\n";
        }
    }else{
        cout << "No\n";
    }
}

Measured memory_bytes: 10192
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  string t = "AKIHABARA";
  if(s.length() > 9){
    cout << "NO" << endl;
    return 0;
  }
  int p = 0;
  int q = 0;
  string ans = "YES";
  while(q != 9){
    if(s[p] == t[q]){
      p++;
      q++;
    }
    else if(t[q] == 'A'){
      q++;
    }
    else{
      ans = "NO";
      break;
    }
  }
  if(p != s.length()) ans = "NO";
  cout << ans << endl;
  return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

// G13E_5.cpp

void mat_prod(LL a[3][3], LL b[3][3], LL c[3][3], LL MOD) { // a = b * c;
	static LL d[3][3];
	inc(i, 3) {
	inc(j, 3) {
		d[i][j] = (b[i][0]*c[0][j] + b[i][1]*c[1][j] + b[i][2]*c[2][j]) % MOD;
	}
	}
	
	inc(i, 3) {
	inc(j, 3) {
		a[i][j] = d[i][j];
	}
	}
}

void mat_exp(LL a[3][3], LL b[3][3], LL c, LL MOD) { // a = b ^ c;
	static LL t[60][3][3];
	static bool flag = true;
	
	if(flag) { // いいかげんな高速化
		inc(i, 3) {
		inc(j, 3) {
			t[0][i][j] = b[i][j];
		}
		}
		inc(i, 60 - 1) {
			mat_prod(t[i + 1], t[i], t[i], MOD);
		}
		flag = false;
	}
	
	LL cc = c, d = 0;
	while(cc) { cc >>= 1; d++; }
	
	inc(i, 3) {
	inc(j, 3) {
		a[i][j] = 0;
	}
	}
	inc(i, 3) { a[i][i] = 1; }
	inc(i, d) {
		if((c >> i) & 1) {
			mat_prod(a, a, t[i], MOD);
		}
	}
}

const LL MOD = 1000000007;
LL n, m, x[100002];

int main() {
	cin >> n >> m;
	inc1(i, m) { cin >> x[i]; }
	x[0] = 0;
	x[m + 1] = n + 1;
	
	LL a[3][3] = { { 2, 1, 1 }, { 2, 1, 0 }, { 1, 1, 1 } };
	LL b[3][3] = { { 1, 0, 0 }, { 2, 1, 0 }, { 1, 1, 1 } };
	LL c[3][3] = { { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 } };
	LL d[3][3];
	
	inc(i, m + 1) {
		if(i != 0) { mat_prod(c, b, c, MOD); }
		mat_exp(d, a, x[i + 1] - x[i] - 1, MOD);
		mat_prod(c, d, c, MOD);
	}
	
	cout << c[2][0] << endl;
	
	return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef long long ll;
const int maxn=100000+10,mo=1000000007;
int ans[3][3],a[3][3],b[3][3],d[3][3],o[3][3];
int x[maxn],sta[80];
int i,j,k,l,t,n,m,now,num,top;
void mult(int a[3][3],int b[3][3],int c[3][3]){
    int i,j,k;
    fo(i,0,2)
        fo(j,0,2)
            o[i][j]=0;
    fo(k,0,2)
        fo(i,0,2)
            fo(j,0,2)
                o[i][j]=(o[i][j]+(ll)a[i][k]*b[k][j]%mo)%mo;
    fo(i,0,2)
        fo(j,0,2)
            c[i][j]=o[i][j];

}
void work(int n){
    int i,j;
    fo(i,0,2)
        fo(j,0,2)
            d[i][j]=(i==j);
    top=0;
    while (n){
        sta[++top]=n%2;
        n/=2;
    }
    while (top){
        mult(d,d,d);
        if (sta[top--]) mult(d,a,d);
    }
}
int main(){
    scanf("%d%d",&n,&m);
    fo(i,1,m) scanf("%d",&x[i]);
    x[++m]=n;
    ans[0][0]=ans[0][2]=1;
    ans[0][1]=2;
    a[0][0]=a[0][2]=a[1][1]=a[1][2]=a[2][0]=1;
    a[0][1]=a[2][1]=a[2][2]=2;
    fo(i,0,2)
        fo(j,0,2)
            b[i][j]=a[i][j];
    b[2][0]--;
    b[2][1]-=2;
    b[2][2]--;
    now=1;
    fo(i,1,m){
        work(x[i]-now);
        mult(ans,d,ans);
        if (i==m) break;
        mult(ans,b,ans);
        now=x[i]+1;
    }
    num=ans[0][2];
    (num+=mo)%=mo;
    printf("%d\n",num);
}

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

using namespace std;

#define ll long long

//Tumhe kya laga me code nahi kar sakta, me sab kar sakta hai,
//kyunki hindustan ka yuva sirf hindustan ko nahi desh ko badal sakta hai

int main()
{
	ll n;
	cin>>n;
	set<ll> a;
	for(int i = 0;i<n;i++)
	{
		ll t;
		cin>>t;
		a.insert(t);
	}
	if(a.size() == n)
	{
		cout<<"YES";
	}
	else
	{
		cout<<"NO";
	}
	return 0;
}

Measured memory_bytes: 9600
n=int(input())
l=list(map(int,input().split()))
mod=10**9+7
ans=1
rgb=[0]*3
for i in range(n):
    f=0
    for j in range(3):
        if l[i]==rgb[j]:
            if f==0:
                rgb[j]+=1
            f+=1
    ans*=f
    ans%=mod
print(ans)

Measured memory_bytes: 53996
#!/usr/bin/env python3
import numpy as np
b = abs
n, *a = map(int, open(0).read().split())
a = np.array([0] + a + [0])
s = sum(map(b, a[1:] - a[:-1]))
for i in range(n):
    print(s + b(a[i+2] - a[i]) - b(a[i+1] - a[i]) - b(a[i+2] - a[i+1]))

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

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}

vector<int> p;
vector<int> r;

void init(int n) {
  p.reserve(n);
  r.reserve(n);
  for (int i = 0; i < n; i++) {
    p[i] = i;
    r[i] = 0;
  }
}

int root(int x) { return p[x] == x ? x : p[x] = root(p[x]); }

bool same(int x, int y) { return root(x) == root(y); }

void unite(int x, int y) {
  x = root(x);
  y = root(y);
  if (x == y)
    return;

  if (r[x] < r[y])
    p[x] = y;
  else {
    p[y] = x;
    if (r[x] == r[y])
      r[x]++;
  }
}

int main() {
  int N, T;
  cin >> N >> T;
  int ans = INT32_MAX;
  for (int i = 0; i < N; i++) {
    int c, t;
    cin >> c >> t;
    if (t > T)
      continue;
    ans = min(ans, c);
  }
  if (ans == INT32_MAX)
    cout << "TLE" << endl;
  else
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

void swap(int *a, int *b){
  int tmp = 0;
  tmp = *a;
  *a = *b;
  *b = tmp;
}

int main(){
  int a[3];
  scanf("%d %d %d",&a[0],&a[1],&a[2]);
  if(a[0]>a[1]){
    swap(&a[1],&a[0]);
  }
  if(a[0]>a[2]){
    swap(&a[2],&a[0]);
  }
  if(a[1]>a[2]){
    swap(&a[1],&a[2]);
  }
  printf("%d\n",a[2]-a[0]);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
    int n,W;
    cin >> n >> W;
    vector<int> w(n),v(n);
    for(int i = 0;i < n;i ++){
        cin >> w.at(i) >> v.at(i);
    }

    vector<vector<int>> a(n,vector<int>(100001));
    for(int i = 0;i < n;i ++){
        for(int j = 0;j < 100000;j ++){
            a.at(i).at(j) = 1000000001;
        }
    }

    for(int i = 0;i < 100000;i ++){
        if(i <= v.at(0)-1){
            a.at(0).at(i) = w.at(0);
        }
    }

    for(int i = 1;i < n;i ++){
        for(int j = 0;j < 100000;j ++){
            if(j >= v.at(i)){
                a.at(i).at(j) = min(a.at(i-1).at(j),a.at(i-1).at(j-v.at(i)) + w.at(i));
            }else{
                a.at(i).at(j) = min(a.at(i-1).at(j),w.at(i));
            }
        }
    }

    int m;
    for(int i = 100000-1;i >= 0;i --){
        if(a.at(n-1).at(i) <= W){
            m = i;
            break;
        }
    }

    cout << m + 1 << endl;
}

Measured memory_bytes: 39808
#include<iostream>
using namespace std;
int main() {
  int n;
  int dp[45] = {};
  cin >> n;
  dp[1] = 1;
  dp[0] = 1;

  for(int i = 2; i <= n; i++) {
    dp[i] = dp[i-1] + dp[i-2];
  }
  cout << dp[n] << endl;
}

Measured memory_bytes: 3092
#include <iostream>
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
using namespace std;
bool ok(int m, int n, int s[100], int width) {
	int cnt = 0, size = s[0];
	if(width<size) return false;
	rep2(i,1,n) {
		if(width<size) return false;
		if(width<size+s[i]) {
			size = 0;
			cnt++;
		}
		size += s[i];
	}
	if(width<size) return false;
	if(size>0)cnt++;
	if(m>=cnt) return true;
	return false;
}
int main(){
	int m, n;
	while(cin >> m >> n, (m||n)) {
		int s[100] = {};
		rep(i,n) {
			cin >> s[i];
		}
		int lo = 0, hi = 1500000;
		while(hi-lo>1) {
			int mid = (hi+lo)/2;
			if(ok(m,n,s,mid)) hi = mid;
			else lo = mid;
		}
		cout << hi << endl;
	}
	return 0;
}

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

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

  int ans = (N%A == 0) ? N/A : N/A+1;
  cout << ans << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e8;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
	int n;
	cin>>n;
	vi in(n);
	rep(i,n){
		string s;cin>>s;
		s=s.substr(0,1)+s.substr(2);
		in[i]=stoi(s);
	}
	vi t=in;
	sort(all(in));
	rep(i,n){
		int a=upper_bound(all(in),t[i])-lower_bound(all(in),t[i]),b=lower_bound(all(in),t[i])-in.begin();
		cout<<a-1+b*3<<endl;
	}
}

Measured memory_bytes: 3680
#define rep( i, n )	for( i = 0; i <= n; i++ )

#include <bits/stdc++.h>
using namespace std;

int main()
{
int i;
int j;
int k;
int N;
int M;
int Y;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> N;
	cin >> Y;

	Y /= 1000;
	rep( i, N )
	{
		M = N - i;
		rep( j, M )
		{
			k = M - j;
			if( 10 * i + 5 * j + k == Y )
			{
				cout << i << " " << j << " " << k << endl;

				return 0;
			}
		}
	}

	cout << "-1 -1 -1" << endl;

	return 0;
}


Measured memory_bytes: 256
X, N = map(int, input().split())
p_int_list = []

if N == 0:
    print(X)
    exit()
else:
    p_int_list = list(map(int, input().split()))

p_int_set = set(p_int_list)

if X not in p_int_set:
    print(X)
    exit()

for i in range(1, 10000):
    if X - i not in p_int_set:
        print(X - i)
        exit()
    elif X + i not in p_int_set:
        print(X + i)
        exit()


Measured memory_bytes: 9068
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: chars
    }
    println!("{}", if n.iter().any(|&c| c == '7') {"Yes"} else {"No"});
}


Measured memory_bytes: 2112
#include<vector>
#include<map>
#include<algorithm>
#include<set>
#include<iostream>
#include<string>
#include<set>
#include<queue>
#include<random>

using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")

#define pb push_back
#define ld long double
#define int long long
#define mp make_pair

mt19937 rnd(51);

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    int n = 100, m, cnt = 0;
    cin >> m;
    while(m > n){
        n += n / 100;
        cnt++;
    }
    cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3644
H, W, K = map(int, input().split())
S = [list(map(int, input())) for _ in range(H)]

ans = 100000
for i in range(2**H):
    cnt = 0
    temp = i
    group = [0]*H
    for j in range(H):
        group[j] = cnt
        if temp & 1:
            cnt += 1
        temp >>= 1
    div = [0]*H
    for j in range(W):
        for k in range(H):
            if div[group[k]] + S[k][j] > K:
                cnt += 1
                div = [0]*H
                for l in range(H):
                    div[group[l]] += S[l][j]
                    if div[group[l]] > K:
                        cnt = 100000
                break
            else:
                div[group[k]] += S[k][j]
    ans = min(ans, cnt)
print(ans)
    


Measured memory_bytes: 47452
// practice with kaiboy
import java.io.*;
import java.util.*;

public class Main extends PrintWriter {
	Main() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		Main o = new Main(); o.main(); o.flush();
	}

	static final int A = 26;
	void main() {
		byte[] aa = sc.next().getBytes();
		byte[] bb = sc.next().getBytes();
		int n = aa.length;
		int m = bb.length;
		int inf = n * 2;
		int[][] dd = new int[n + 1][A];
		Arrays.fill(dd[n], inf);
		for (int i = n - 1; i >= 0; i--) {
			int a = aa[i] - 'a';
			dd[n][a] = i;
		}
		for (int i = n - 1; i >= 0; i--) {
			for (int a = 0; a < A; a++)
				dd[i][a] = 1 + dd[i + 1][a];
			int a = aa[i] - 'a';
			dd[i][a] = 0;
		}
		long i = 0;
		for (int j = 0; j < m; j++) {
			int a = bb[j] - 'a';
			int d = dd[(int) (i % n)][a];
			if (d >= inf) {
				println(-1);
				return;
			}
			i += d + 1;
		}
		println(i);
	}
}


Measured memory_bytes: 52444
//   ALLAH IS THE ALMIGHTY   //
#include<bits/stdc++.h>
using namespace std;
int main(){
   ios::sync_with_stdio(false);
   cin.tie(0);cout.tie(0);
  string s;
  cin >> s;
  if (s.size() == 6 && s[2] == s[3] && s[4] == s[5])
    cout << "Yes\n";
  else
    cout << "No\n";
  return 0;
}
//           SOLVED!            //


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

int main (){

  int a[101] , i = 0 , n = 0 , num = 0 ;

  cin >> n ;

  for ( i = 1 ; i <= n ; i++ ){

    cin >> num ;

    a[i] = num ;
}
  cout << a[n];
  for ( i = n - 1 ; i >= 1 ; i-- ){
    
    cout << ' ' << a[i] ;
    //   if (i){
    // cout << " " ;
    
    }    
  
  cout << "\n" ;

  return 0 ;

}

Measured memory_bytes: 1164
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}


 main()

{
    fast
    int n;
    cin>>n;
    int sum=0;
    f(i,1,n)
    {
        if(i%3==0  || i%5==0)continue;
        sum+=i;
    }
    cout<<sum<<endl;


















    return 0;

}













Measured memory_bytes: 3664
"use strict";

const main = arg => {
    const inputList = arg.trim().split("\n");
    // 回答を記述
    const nums = inputList[0].split(" ");

    const N = parseInt(nums[0]);
    const M = parseInt(nums[1]);
    const X = parseInt(nums[2]);

    // 参考書を別配列化
    let Books = []
    for (let i = 1; i <= N; i++) {
        Books.push(inputList[i].split(" ").map(ele => parseInt(ele)))
    }

    let answer = Infinity;
    let exist = false;

    // N冊の本を選ぶ選ばない=> 2 ** N 通り, 2 ** N = 1をNビット左シフト
    for (let i = 0; i < 2 ** N; i++) {
        let sumM = Array(M + 1).fill(0);
        for (let k = 0; k < N; k++) {
            if (i & (1 << k)) {
                // 配列には金額も含まれているので M + 1
                for (let j = 0; j < M + 1; j++) {
                    sumM[j] += Books[k][j];
                }
            }
        }
        // 合計金額を抜き出す
        const cost = sumM.shift();

        // 閾値を超えた要素数がM個あるか確認
        if (sumM.filter(ele => ele >= X).length === M) {
            exist = true;
            answer = Math.min(answer, cost);
        }
    }

    if (exist) {
        console.log(answer);
    } else {
        console.log(-1);
    }
}


main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 34284
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	h := make([]int, N)
	for i := 0; i < N; i++ {
		h[i] = getInt()
	}

	ans := 0
	for {
		l := 0
		for i := 0; i < N; i++ {
			if h[i] != 0 {
				break
			}
			l++
		}
		mi := 10000
		r := l
		for i := l; i < N; i++ {
			if h[i] == 0 {
				break
			}
			mi = min(mi, h[i])
			r++
		}
		// out(l, r, h)
		if l == r {
			break
		}
		for i := l; i < r; i++ {
			h[i] -= mi
		}
		ans += mi
	}
	out(ans)
}


Measured memory_bytes: 640
n=int(input())
a=list(map(int,input().split()))

b=0
c=0
for i in range(n):
    if a[i]%2==0:
        b+=1
        if a[i]%3==0 or a[i]%5==0:
            c+=1
if b==c:
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
   int x,y,r,tmp;

   scanf("%d %d",&x ,&y);

   if(x < y){
      tmp = x;
      x = y;
      y = tmp;
   }

   r = x%y;

   while(r > 0){
      x = y;
      y = r;
      r = x%y;
   }

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

   return 0;
}

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

int main(void){
    int i,j,k;
    int N,L,aji[200],answer = 0;
    int min = 9999999,min_index;
   
    scanf("%d %d",&N,&L);
    
    for(i = 0;i < N;i++){
        aji[i] = L + i;
        if(abs(aji[i]) < min){
            min = abs(aji[i]);
            min_index = i;
        }
    }
    
    for(i = 0;i < N;i++){
        if(i != min_index){
            answer += aji[i];
        }
    }
   
    printf("%d\n",answer);
    return 0;
}

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

int h,w;
int hw;
int tai;
int cheak;
int mn;
int high,wide;

main(){
  while(cin >> h >> w,h||w){
    hw=h*h+w*w;
    tai=-1;
    mn=0;
    for(int i=1;i<=150 && mn==0;i++){
      cheak=0;
      for(int j=i+1;j<=150 && cheak==0;j++){
        if(hw<i*i+j*j && (tai==-1 || tai>i*i+j*j)){
          tai=i*i+j*j;
          high=i;
          wide=j;
        }
        else if(hw==i*i+j*j && i>h){
          high=i;
          wide=j;
          cheak=1;
          mn=1;
        }
      }
    }
    cout << high << " " << wide << endl;

  }
}

Measured memory_bytes: 1160
import java.util.Scanner;

class Main {
    
    public static void main(String... args) {
        Scanner scanner = new Scanner(System.in);
        String[] numbers = scanner.nextLine().split(" ");
        
        int a = Integer.parseInt(numbers[0]);
        int b = Integer.parseInt(numbers[1]);
        
        if (a > b) {
            System.out.println("a > b");
        } else if (a < b) {
            System.out.println("a < b");
        } else {
            System.out.println("a == b");
        }
    }
}


Measured memory_bytes: 26304
import sys
input = sys.stdin.readline
sys.setrecursionlimit(pow(10, 6))


def main():
    n, k = map(int, input().split())
    ab = [tuple(map(int, input().split())) for _ in range(n)]
    ans = 0
    # とりあえずansの候補
    for a, b in ab:
        if k&a == a:
            ans += b
    
    i = 1
    while i<=k:
        # 下のbitから全部1に変えていく
        if k&i:
            k ^= i
            tmp = 0
            for a, b in ab:
                if k&a == a:
                    tmp += b
            if ans < tmp:
                ans = tmp
        k ^= i
        i *= 2
    
    print(ans)


if __name__ == '__main__':
    main()


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

int main()
{
    int n, d;

    cin >> n >> d;

    int temp = (d * 2) + 1;

    int ans = n / temp;

    if(n % temp != 0)
    {
        ans++;
    }

    cout << ans << endl;

    return 0;
}


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

int main(int argc, const char * argv[]) {
    int n; cin >> n;
    while(n--){
        set<string> kinds;
        string str; cin >> str;
        
        for(int i = 1; i < str.size(); i++){
            string s1 = str.substr(i), s2 = str.substr(0,i);
            string r1 = s1, r2 = s2;
            reverse(r1.begin(), r1.end());
            reverse(r2.begin(), r2.end());
            
            string s[8] = {
                s1 + s2, s1 + r2, r1 + s2, r1 + r2,
                s2 + s1, r2 + s1, s2 + r1, r2 + r1,
            };
            for(int j = 0; j < 8; j++) kinds.insert(s[j]);
        }
        cout << kinds.size() << endl;
    }
}

Measured memory_bytes: 1288
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int y = sc.nextInt();

		for(int a = 0; a <= n; a++) {
			for(int b = 0; b <= n; b++) {
				int c = n - a - b;
				int total = a * 10000 + b * 5000 + c * 1000;
				if(total == y && c >= 0) {
					System.out.println(a + " " + b + " " + c);
					return;
				}
			}
		}

		System.out.println("-1 -1 -1");
	}
}

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

typedef long long ll;

int main() {
	string s;
	cin >> s;
	int n = (int)s.size();
	set<char> p;
	for(int i = 0; i < n; ++i) {
		p.insert(s[i]);
	}
	if ((int)p.size() == n) {
		cout << "yes";
	}else {
		cout << "no";
	}
}



















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

long long int K=0, N=0;
cin >> K >> N;
vector <int> house(N+100);
vector <int> kankaku(N+100);
rep(i,N) cin >> house.at(i);
kankaku.at(0)=house.at(0);
for (int i=1; i<=N-1; i++) kankaku.at(i)=house.at(i)-house.at(i-1);
kankaku.at(N)=K-house.at(N-1)+house.at(0);

//rep(i,N) cout << kankaku.at(i) << endl;

sort(kankaku.begin(), kankaku.end(), greater<int>());
int dmax=kankaku.at(0);
cout << K-dmax << endl;
//rep(i,N) cout << kankaku.at(i) << endl;

}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int maxn = 1e5 + 5;
const int mod = 1e9+7;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    for (auto &i : s) {
        int cur = i - 'A';
        cur += n;
        cur %= 26;
        cur += 26;
        cur %= 26;
        i = 'A' + cur;
    }
    cout << s << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <algorithm>
#define MAXN 100001
#define rep(i,a,b) for (register unsigned int i=a; i<=b; i++)
#define rrep(i,a,b) for (register unsigned int i=a; i>=b; i--)
#define ll long long
#define clr(a,x) memset (a,x,sizeof(a))
#define LowBit(x) (x & -x)
using namespace std;
int N,a[MAXN<<1+2];
inline bool yes1(int i,int j,int val) {return a[i]<=val&&a[j]<=val;}
inline bool yes2(int i,int j,int val) {return a[i]>val&&a[j]>val;}
inline bool check(int value){
	for(int i=0;i<N-1;i++){
        if(yes2(N+i,N+i+1,value)||yes2(N-i,N-i-1,value)) return 0;
        if(yes1(N+i,N+i+1,value)||yes1(N-i,N-i-1,value)) return 1;
    }
    return yes1(1,1,value);
}
int main(){
	cin>>N;
	int tmpN=N*2-1; 
	rep (i,1,tmpN) cin>>a[i];
	int L=1,R=tmpN;
	for (;L<R;) {
		int mid=(L+R)/2;
		if(check(mid)) R=mid;
		else L=mid+1;
	}
	cout << R << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ll_s long
#define mod 1000000007
#define forn(i,start,lim) for(ll i=start;i<lim;i++)
#define forn_d(i,start,lim) for(ll i=start;i>=lim;i--)
#define f first
#define s second
#define pb push_back
#define pf push_front
#define mp make_pair
#define debug1(a) cout<<"------\n"<<#a<<" = "<<a<<endl<<"------"<<endl
#define debug2(a,b) cout<<"--------------\n"<<#a<<" = "<<a<<" ; "<<#b<<" = "<<b<<endl<<"--------------"<<endl
#define debug3(a,b,c) cout<<"----------------------\n"<<#a<<" = "<<a<<" ; "<<#b<<" = "<<b<<" ; "<<#c<<" = "<<c<<endl<<"----------------------"<<endl
#define sz(a) (ll)(a.size())
#define debug4(a) cout<<"chu "<<a<<endl
#define endl "\n"

int main()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  ll n;
  cin>>n;
  vector<double> probs(n+1);
  forn(i,1,n+1)
    cin>>probs[i];
  vector<vector<double>> dp(n+1,vector<double>(n+1,0));
  dp[0][0] = 1.0;
  double finalprob=0.0;
  forn(i,1,n+1){
    forn(h,0,i+1){
      dp[i][h] = (h>=1?dp[i-1][h-1]:0.0)*probs[i] + dp[i-1][h]*(1-probs[i]);
      if(i==n){
        if(2*h>n)
          finalprob += dp[i][h];
      }
    }
  }
  cout<<fixed<<setprecision(10)<<finalprob<<endl;
  return 0;
}


Measured memory_bytes: 73764
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return a % 1000000007;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}


int main(){
  ll n,x; cin >> n >> x; ll a ; cin >> a;
  
  ll greatest = abs(a-x);
  
  for(ll i=0; i < n-1; i++){
    ll a; cin >> a;
    greatest = gcd(greatest,abs(a-x));
  }
  
  cout << greatest << endl;
}

Measured memory_bytes: 256
n = int(input())
g = [[[],[]] for _ in range(n)]
for i in range(n):
  a = int(input())
  g[i]=[tuple(map(int,input().split())) for _ in range(a)]
ans = 0
for num in range(1<<n):
  p = [j for j in range(n) if num&(1<<j)]
  fl = 0
  for v in p:
    for x,y in g[v]:
      if bool(num&(1<<(x-1))) != y:
        fl = 1
        break
    if fl:
      break
  else:
    if ans < len(p):
      ans = len(p)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll a,b,c;
    set<ll>s;
    cin>>a>>b>>c;
    s.insert(a);
    s.insert(b);
    s.insert(c);
    if (s.size()==2){
        cout<<"Yes\n";
    }
    else {
        cout<<"No\n";
    }
}

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

int main(){
    ll h, w;
    cin >> h >> w;

    if ( h == 1 || w == 1 ) {
        cout << 1 << endl;
    }
    else {
        cout << ( h * w + 1 ) / 2 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007
#define MAX 300005
using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF64 = 1'000'000'000'000'000'000ll;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void doc()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}
int main()
{
	fast();
	int a,b;
	cin>>a>>b;
	if(a>9 or b>9)
		cout<<-1;
	else
		cout<<a*b;
}

Measured memory_bytes: 256
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

n,x=map(int,input().split())
a=list(map(int,input().split()))

res=abs(a[0]-x)
for i in range(n-1):
    res=gcd(res,abs(a[i+1]-x))
print(res)

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

int main() {
  long long int h;
  cin >> h;
  long long int count = 0;
  for(long long int i = 1; 1; i *= 2) {
    if(h / 2 == 0) {
      count += i;
      break;
    } else {
      count += i;
      h /= 2;
    }
  }
  cout << count;
}
  

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define MP make_pair
#define x first
#define y second

typedef long long ll;

const int N = 2e5 + 10;
const int INF = 0x3f3f3f3f;

typedef pair<int, int> PII;

vector<int> nex[N];
int vis[N];
int n, m, flag, cnt;

void dfs(int u) {
    cnt += vis[u];
    for(int v:nex[u]) {
        if(vis[v] == -1) {
            vis[v] = vis[u]^1;
            dfs(v);
        }
        else if(vis[v] == vis[u]) flag = 1;
    }
}

int main ()
{
	scanf("%d %d", &n, &m);
	for(int i = 0; i < m; i++){
		int u, v;
		scanf("%d %d", &u, &v);
		nex[u].push_back(v);
		nex[v].push_back(u);
	}
	
	cnt = 0;
	flag = 0;
	memset(vis, -1, sizeof(vis));
	vis[1] = 0; dfs(1);
	
	ll ans = 0;
	if(flag) ans = (ll)n * (n - 1) / 2;
	else ans = (ll)cnt * (n - cnt);
	
//	printf("f = %d\n", f);
	printf("%lld\n", ans - m);
	
	return 0;
}

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

int lcs(string X, string Y) {
  vector<vector<int>> c(2000, vector<int>(2000));
  int m = X.length();
  int n = Y.length();
  int maxl = 0;
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= n; j++) {
      if (X.at(i - 1) == Y.at(j - 1)) {
        c.at(i).at(j) = c.at(i - 1).at(j - 1) + 1;
      } else {
        c.at(i).at(j) = max(c.at(i - 1).at(j), c.at(i).at(j - 1));
      }
      maxl = max(maxl, c.at(i).at(j));
    }
  }
  return maxl;
}

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

  vector<string> x(q);
  vector<string> y(q);
  rep(i, q) {
    cin >> x.at(i);
    cin >> y.at(i);
  }

  rep(i, q) { cout << lcs(x.at(i), y.at(i)) << endl; }
  return 0;
}


Measured memory_bytes: 18796
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
cin >> N;
vector<int> a(N);
for(int i = 0; i < N; i++){
  cin >> a.at(i);
}
int b = 0;
for(int i = 0; i< N; i++){
  if(a.at(i)%2 !=0){
    b++;
  }
}
if(b%2!=0){
  cout << "NO" << endl;
}
else cout << "YES" << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <unordered_map>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
    int n;
    cin >> n;
    vector<int> L(n);
    for (int &l : L) cin >> l;

    int count = 0;
    for (int i = 0; i < n - 2; i++) {
        for (int j = i + 1; j < n - 1; j++) {
            for (int k = j + 1; k < n; k++) {
                bool different_lengths = L[i] != L[j] && L[j] != L[k] && L[k] != L[i];
                if (!different_lengths) continue;
                vector<int> ll;
                ll.push_back(L[i]);
                ll.push_back(L[j]);
                ll.push_back(L[k]);
                sort(ll.begin(), ll.end());
                bool triangle_inequality = ll[0] + ll[1] > ll[2]; 
                if (triangle_inequality) {
                    count++;
                }
            }
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3544
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<climits>

using namespace std;


int main(void){
  string s;

  while(cin >> s){
    int cnt=0;
    for(int i=0;i<s.size()/2;i++){
      if((s[i]=='i' && s[s.size()-i-1]!='i')||
	 (s[i]=='w' && s[s.size()-i-1]!='w')||
	 (s[i]=='(' && s[s.size()-i-1]!=')')||
	 (s[i]==')' && s[s.size()-i-1]!='('))cnt++;
    }
    if(s.size()%2 && !(s[s.size()/2]=='i'||s[s.size()/2]=='w'))cnt++;
    cout << cnt << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1180
import java.util.*;
public class Main {
 public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int N=sc.nextInt();

	double bunsi=0;
   	for(int i=0;i<N;i++)bunsi+=(1000.0/sc.nextInt());
	System.out.println(1000/bunsi);
 }
}


Measured memory_bytes: 23764
#include<iostream>
using namespace std;
int main(){

	int n, m;
	cin >> n;
	m = n;

	for (int i = 0; i < m; i++){

		if (n % 4 == 0){
			cout << "Yes" << endl;
			break;
		}

		else if (n < 7){
			cout << "No" << endl;
			break;
		}

		n -= 7;
	}

	return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;
#define ll int64_t
const long MOD = 1e9 + 7;
const long LINF = 1e13;
const long LLINF = 1e18;
const long ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}



int main() {

  int n;
  cin >> n;

  vector<long> p(n);

  long ans = 0;
  long mx = -1;

  for(int i=0;i<n;i++){
    cin >> p[i];
    ans += p[i];
    mx = max(p[i],mx);
  }


  cout << (ans-mx/2) <<endl;


}




















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

int main(){
    int N,M;
    cin>>N>>M;
    std::vector<int> X(M);
    for(int i=0;i<M;i++){
        cin>>X[i];
    }

    if(N>=M) cout<<0<<endl;
    else{
        sort(X.begin(),X.end());
        int left=X[0],right=X[X.size()-1];

        std::vector<int> l(M-1);
        for(int i=1;i<M;i++){
            l[i-1]=X[i]-X[i-1];
        }
        sort(l.begin(),l.end());
        int count=0,s=0;
        for(int i=M-2;i>-1;i--){
            if(count>=N-1) break;
            s+=l[i];
            count++;
        }

        cout<<right-left-s<<endl;
    }
}

Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args){
 
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		ArrayList<Integer> dList = new ArrayList<>();
		long ans = 0;
		
		for(int i = 0; i < N; i++) {
			dList.add(sc.nextInt());
		}

		for(int i = 0; i < N; i++) {
			for(int j = i + 1; j < N; j++) {
				ans += dList.get(i) * dList.get(j);
			}
		}

		System.out.println(ans);
		sc.close();
	}
 
}

Measured memory_bytes: 21204
#include <stdio.h>
 
main(){
  int a[4], b[4];
  int i, j;
  int h, br;
 
  while(1){
    h=br=0;
    if(scanf("%d", &a[0])==EOF) break;
    for(i=1;i<4;i++){
      scanf("%d", &a[i]);
    }
    for(i=0;i<4;i++){
      scanf("%d", &b[i]);
      for(j=0;j<4;j++){
    if(b[i]==a[j]){
      br++;
    }
      }
    }
    for(i=0;i<4;i++){
      if(a[i]==b[i]){
    br--;
    h++;
      }
    }
    printf("%d %d\n", h, br);
  }
  return 0;
}

Measured memory_bytes: 596
inf = float('inf')
from scipy.optimize import fmin
from collections import defaultdict
dir = {'R', 'L', 'U', 'D'}
N = int(input())
dic = defaultdict(list)
for _ in range(N):
    x, y, d = input().split()
    x, y = int(x), int(y)
    dic[d].append((x, y))
x_max = defaultdict(lambda : -inf)
x_min = defaultdict(lambda : inf)
y_max = defaultdict(lambda : -inf)
y_min = defaultdict(lambda : inf)
for d in dir:
    if dic[d]:
        dic[d].sort()
        x_max[d] = dic[d][-1][0]
        x_min[d] = dic[d][0][0]
        dic[d].sort(key = lambda x:x[1])
        y_max[d] = dic[d][-1][1]
        y_min[d] = dic[d][0][1]
def dx(t):
    return max(x_max['U'], x_max['D'], x_max['R']+t, x_max['L']-t)-min(x_min['U'], x_min['D'], x_min['R']+t, x_min['L']-t)
def dy(t):
    return max(y_max['U']+t, y_max['D']-t, y_max['R'], y_max['L'])-min(y_min['U']+t, y_min['D']-t, y_min['R'], y_min['L'])
def f(t):
    if t<0:
        return inf
    return dx(t)*dy(t)
def make_cand(s, d, i):
    return [abs(s-i), abs(d-i)/2, abs(s-d)]
cand = [0]+make_cand(max(x_max['U'], x_max['D']), x_max['R'], x_max['L'])               +make_cand(min(x_min['U'], x_min['D']), x_min['R'], x_min['L'])               +make_cand(max(y_max['R'], y_max['L']), y_max['U'], y_max['D'])               +make_cand(min(y_min['R'], y_min['L']), y_min['U'], y_min['D'])
ans = min(f(t)for t in cand)
print(ans)















Measured memory_bytes: 32012
#include <bits/stdc++.h>
using namespace std;
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define mii map<ll,ll>
#define pii pair<ll,ll>
#define vi vector<ll>
#define endl "\n"
#define deb(x) cout << #x << "=" << x << endl
const ll mod = 1e9+7;

ll msum(ll a,ll b,ll m) { return (a%m+b%m)%m; }
ll msub(ll a,ll b,ll m) { return (a%m-b%m)%m; }
ll mpro(ll a,ll b,ll m) { return ((a%m)*(b%m))%m; }
ll m_m(ll a,ll b,ll m);
ll fxp(ll a,ll b,ll m);
void swap(ll &a,ll &b){ ll t=a; a=b; b=t;}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        ll n,i,k;
        cin>>n>>k;
        vi v;
        fo(i,n)
        {
            ll x;
            cin>>x;
            v.pb(x);
        }  
        ll dp[n]={0};
        for(i=1;i<n;i++)
        {
            ll val=INT_MAX;
            for(ll j=1;j<=k;j++)
            {
                if(i-j<0)
                    break;
                // deb(dp[i-j]);
                // deb(v[i]);
                // deb(v[i-j]);
                // deb(dp[i-j]+abs(v[i]-v[i-j]));
                val=min(val,dp[i-j]+abs(v[i]-v[i-j]));
            }
            dp[i]=val;
        }
        // for(i=0;i<n;i++)
        //     cout<<dp[i]<<" ";
        cout<<dp[n-1]<<endl;
    }
 return 0;
}
ll fxp(ll a,ll b,ll m) {
    if(b==0)
        return 1;
    if(b%2==0)
        return fxp(m_m(a,a,m),b/2,m);
    return m_m(fxp(a,b-1,m),a,m);
}
ll m_m(ll a,ll b,ll m) 
{
    ll res=0;
    a=a%m;
    while(b)
    {
        if(b&1)
        {
            res+=a; 
            res=res%m;
        }
        a=(a*2)%m;
        b=b/2;
    }
    return res;
}

Measured memory_bytes: 4800
#include"bits/stdc++.h"
using namespace std;
using ll = long long;

int main() {
    ll N;
    cin >> N;
    vector<ll> a(N), pos(N + 2, -1);
    pos[0] = 0;
    pos[N + 1] = N - 1;
    for (ll i = 0; i < N; i++) {
        cin >> a[i];
        pos[a[i]] = i;
    }

    set<ll> st;

    ll ans = 0;
    st.insert(-1);
    st.insert(N);
    for (ll i = 1; i <= N; i++) {
        auto itr = st.lower_bound(pos[i]);
        ll r_value = *itr;
        itr--;
        ll l_value = *itr;

        ll l_num = pos[i] - l_value;
        ll r_num = r_value - pos[i];

        ans += i * (l_num) * (r_num);

        st.insert(pos[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 12800