akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
#include <set>
#include <utility>
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

int main() {
    int a, b; cin >> a >> b;
    int ans = INT_MAX;
    for(int i = 0; i < 10000; i++){
        if((i * 8) /100 == a && (i * 10)/100 == b) ans = min(ans, i);
    }
    if(ans == INT_MAX) cout << -1 << endl;
    else cout << ans << endl;
	return 0;
}


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

void printVector(vector<ll> vec){
    stringstream ss;
    for(ll i=0;i<vec.size();i++)
    {
        ss<<vec[i];
    }
    cout<<ss.str()<<endl;
}

int main()
{
    ll N,M;
    cin >> N >> M;
    if(M<=N)
    {
        cout<<0;
        return 0;
    }
    vector<ll> X(M,0);
    vector<ll> S(M-1,0);
    for(ll i=0;i<M;i++){
        cin>>X[i];
    }
    sort(X.begin(),X.end());
    for(ll i=1;i<M;i++)
    {
        S[i-1]=X[i]-X[i-1];
    }
    sort(S.rbegin(),S.rend());
    ll res=accumulate(S.begin(),S.end(),0);
    for(ll i=0;i<N-1;i++)
    {
        res-=S[i];
    }
    cout<<res; 
    return 0;
}

Measured memory_bytes: 4608
#include<bits/stdc++.h>
#define fi first
#define se second
#define show(x) cerr<<#x<<"="<<x<<"\n"
typedef long long ll;
using namespace std;
//const ll MOD=(ll)1e9+7;
//const ll inf=(ll)1e14;
const int dy[]={1,0,-1};
const int dx[]={1,0,-1};
int n,m,h,w;
string s;
int a[11][11];
int dp[11][100001];

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  //FILE *stream2;
  stream1=freopen("in","r",stdin);
  //stream2=freopen("out","w",stdout);
  if(stream1==NULL)return 0;
  //if(stream2==NULL)return 0;
#endif
  cin>>w>>h>>n;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>a[i][j];
    }
  }
  for(int i=0;i<h;i++)for(int j=0;j<100001;j++)dp[i][j]=-1;
  dp[0][0]=n;
  for(int i=0;i<h-1;i++){
    for(int j=0;j<100001;j++){
      if(dp[i][j]==-1)continue;
      for(int k=0;k<w;k++){
        int cont=1;
        while(dp[i][j]-cont*a[i][k]>=0){
          dp[i][j+cont*a[i+1][k]]=max(dp[i][j]-cont*a[i][k],dp[i][j+cont*a[i+1][k]]);
          dp[i+1][0]=max(dp[i+1][0],dp[i][j]-cont*a[i][k]+cont*a[i+1][k]);
          cont++;
        }
      }
      dp[i+1][0]=max(dp[i][j]+j,dp[i+1][0]);
    }
  }
  cout<<dp[h-1][0]<<endl;
#ifdef LOCAL_DEFINE
  cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
  fclose(stream1);
  //fclose(stream2);
#endif
  return 0;
}







Measured memory_bytes: 7140
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;
vector<string> field;
void query(int n) {
  if (field[n]!="") return;
  string s;
  cout<<n<<endl;
  cin>>s;
  if(s=="Vacant") exit(0);
  field[n]=s;
}

int main()
{
  int n;
  cin>>n;
  string s;
  int inf=0,sup=n-1,mid=sup/2;
  field=vector<string>(n,"");

  while(inf!=mid) {
    query(inf);
    query(mid);
    if(field[inf]==field[mid]) {
      if((mid-inf)%2==0) inf = mid;
      else sup=mid;
    } else {
      if((mid-inf)%2==0) sup=mid;
      else inf=mid;
    }
    mid=(inf+sup)/2;
  }
  query(sup);
}

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

const int N = 50;

int judge(int* a, int l){
	int s = 0;
	for(int i = 0;i < l;++i){
		s += a[i];
	}
	return s;
}

int main(){
	int n, p, i;
	int ss[N];
	while(cin >> n >> p, n){
		i = 0;
		fill(ss, ss + n, 0);
		while(1){
			if(!p){
				p += ss[i];
				ss[i] = 0;
			}
			else{
				++ss[i];
				--p;
			}
			if(!p){
				if(ss[i] == judge(ss, n)){
					break;
				}
			}
			++i;
			i = i == n ? 0 : i;
		}
		cout << i << endl;
	}
	return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

const int IINF = INT_MAX;

string s;
int len;


int dfs(int &cur){

  assert( s[cur] == '[' );
  int ret = 0;
  if( s[cur+1] == '[' ) {
    deque<int> deq;
    int depth = 0;
    ++cur;
    while( s[cur] != ']' ) deq.push_back(dfs(cur));
    ++cur;
    sort(deq.begin(),deq.end());
    rep(i,(int)ceil((double)deq.size()/2.0)) ret += deq[i];
    return ret;
  } else {
    ++cur;
    while( '0' <= s[cur] && s[cur] <= '9' ) {
      ret *= 10;
      ret += s[cur++] - '0';
    }
    ++cur;
  }
  return (int)ceil((double)ret/2.0);

}

int main(){
  int T;
  cin >> T;
  cin.ignore();
  while( T-- ){
    getline(cin,s);
    len = s.size();
    int cur = 0;
    cout << dfs(cur) << endl;
  }
  return 0;
}

Measured memory_bytes: 1264
#include <iostream>
#include <stdio.h>
#include <vector>

using namespace std;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    long long n, m, sum = 0, inp;

    cin >> n >> m;

    for(int i=0; i<m; i++){
        cin >> inp;
        sum += inp;
    }

    if(n < sum) cout << "-1" << endl;
    else cout << n - sum << endl;

    return 0;

}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

Int dp[301][301];

int main() {
    vector<Int> res;
    Int n;
    while (cin >> n and n) {
        vector<Int> a(n);
        for (Int i = 0; i < n; i++) {
            cin >> a[i];
        }
        for (Int i = 0; i <= 300; i++) {
            for (Int j = 0; j <= 300; j++) {
                dp[i][j] = 0;
            }
        }
        for (Int i = 0; i < n - 1; i++) {
            if (abs(a[i] - a[i + 1]) <= 1) {
                dp[i][i + 1] = 2;
            }
        }
        if (n == 1) {
            dump(0);
            return 0;
        }
        if (n == 2) {
            if (abs(a[0] - a[1]) <= 1) {
                dump(2);
            }
            else {
                dump(0);
            }
            return 0;
        }
        if (n == 3) {
            if (abs(a[0] - a[1]) <= 1 or abs(a[1] - a[2]) <= 1) {
                dump(2);
            }
            else {
                dump(0);
            }
            return 0;
        }
        for (Int i = 0; i + 3 < n; i++) {
            for (Int j = 0; j + i + 3 < n; j++) {
                if (dp[j + 1][j + i + 2] == i + 2) {
                    dp[j][j + i + 3] = i + 2;
                    if (abs(a[j] - a[j + i + 3]) <= 1) {
                        dp[j][j + i + 3] = max(dp[j][j + i + 3], dp[j + 1][j + i + 2] + 2);
                    }
                }
                for (Int k = j + 1; k < j + i + 3; k++) {
                    dp[j][j + i + 3] = max(dp[j][j + i + 3], dp[j][k] + dp[k + 1][j + i + 3]);
                }
            }
        }
        res.push_back(dp[0][n - 1]);
    }
    for (Int i = 0; i < (Int)res.size(); i++) {
        dump(res[i]);
    }
    return 0;
}



Measured memory_bytes: 3868
#include <bits/stdc++.h>
#define endl        '\n'
#define db          double
#define ld          long double
#define ll          long long
#define ull         unsigned long long
#define sqr(x)      (x) * (x)
#define gcd(a, b)   __gcd(a, b)
#define lcm(a, b)   ((a/gcd(a,b)) * b)
#define pf(x) 		push_front(x)
#define pb(x)       push_back(x)
#define eb(x)		emplace_back(x)
#define all(x)      (x).begin(), (x).end()
#define rall(x) 	(x).rbegin(), (x).rend()
#define sz(x) 		(int)x.size()
#define debug(x) 	cerr << #x << " = " << (x) <<endl
#define unsyncIO    ios_base::sync_with_stdio(0); cin.tie(0)

const ld PI = acos((ld)-1);
const int MOD = 1e9+7;
const ll INF = 1e18; 

using namespace std;

int main()
{
    //freopen("/home/taalpatar_shepai/Documents/my_codes/out.txt", "w", stdout);
    int n, x, y;
    cin >> n;
    x = n * 800;
    int temp;
    temp = n / 15;
    y = temp * 200;
    cout << x - y << endl;
    return 0;
}


Measured memory_bytes: 3608
N = int(input())
H = [int(i) for i in input().split()]
H[0] -= 1
for i in range(0,N-1):
  if H[i+1] >= H[i] + 1:
    H[i+1] -= 1
  elif H[i+1] == H[i]:
    continue
  else:
    print("No")
    exit()
print("Yes")

Measured memory_bytes: 14252
n = int(input())

list = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
characters = {'S':0, 'H':1, 'C':2, 'D':3}
characters_rev = {0:'S', 1:'H', 2:'C', 3:'D'}

for i in range(n):
    character, integer = [x for x in input().split()]
    
    integer = int(integer)
    
    for c in characters:
        if c == character: character = characters[c]
    
    list[character][integer - 1] = 1
    
for c in range(len(characters)):
    for i in range(13):
        if list[c][i] == 0:
            print(characters_rev[c], i+1)


Measured memory_bytes: 5620
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;


const int M_N=200001;

struct UnionFind{
    int par[M_N];
    int rank[M_N];

    void init(int n){
        for(int i=0;i<n;i++){
            par[i]=i;
            rank[i]=0;
        }
    }

    int find(int x){
        if(par[x]==x){
            return x;
        }
        else{
            return par[x]=find(par[x]);
        }
    }

    void unite(int x,int y){
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]){
            par[x]=y;
        }
        else{
            par[y]=x;
            if(rank[x]==rank[y]) rank[x]++;
        }
    }

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


int main(){
    int n,m;cin >> n >> m;
    if(n-1==m){
        puts("0");
        return 0;
    }
    vector<LL> a(n);
    UnionFind uf;
    uf.init(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < m; i++) {
        int x,y;cin >> x >> y;
        uf.unite(x,y);
    }
    vector<P> v(n);
    set<LL> st;
    for (int i = 0; i < n; i++) {
        v[i] = make_pair(a[i],i);
        st.insert(uf.find(i));
    }
    sort(ALL(v));
    if(2*(st.size()-1)>n){
        puts("Impossible");
        return 0;
    }
    int sz = 2*(st.size()-1);
    vector<bool> used(n,false);
    vector<bool> us(n,false);
    LL ans = 0;
    for (int i = 0; i < n; i++) {
        if(us[uf.find(v[i].sc)]) continue;
        ans += v[i].fs;
        used[i] = true;
        us[uf.find(v[i].sc)] = true;
        sz--;
    }
    for (int i = 0; i < n && sz; i++) {
        if(used[i]) continue;
        ans += v[i].fs;
        sz--;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8064
from bisect import bisect_right
n=int(input())
L=[int(i) for i in input().split()]
L.sort()


ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    c=L[i]+L[j]-1
    ans+=bisect_right(L,c)-j-1
    
print(ans)

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int N, W;
int v[110], w[110];
int dp[101][10101];

void solve_dp() {
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j <= W; ++j) {
            if (j < w[i]) dp[i+1][j] = dp[i][j];
            else dp[i+1][j] = max(dp[i][j], dp[i+1][j-w[i]]+v[i]);
        }
    }
    cout << dp[N][W] << endl;
}

int solve(int i, int j) {
    int& res = dp[i][j];
    if (~res) return res;
    if (i >= N) {
        res = 0;
    }
    else if (j < w[i]) {
        res = solve(i+1, j);
    }
    else {
        res = max(solve(i+1, j), solve(i, j-w[i]) + v[i]);
    }
    return res;
}

int main() {
    cin >> N >> W;
    rep(i, N) cin >> v[i] >> w[i];
    //solve_dp();
    fill(dp[0], dp[N], -1);
    cout << solve(0, W) << endl;
    return 0;
}



Measured memory_bytes: 7504
"""
NTC here
"""
import sys
input= sys.stdin.readline
# import t  hreading
# setrecursionlimit(10**6)
# threading.stack_size(2**26)

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

# range = xrange
# input = raw_input

def main():
    n = iin()
    Q = [lin() for i in range(n)]
    ans = [[0, 0, 0] for i in range(n+1)] 
   # print(ans)
    for i in range(n-1, -1, -1):
        for j in range(3):
            ans[i][j]=Q[i][j]+max([
                ans[i+1][k] for k in range(3) if k!=j
            ])
  #  print(ans)
    print(max(ans[0]))

        



                









        
main()
#threading.Thread(target=main).start()


Measured memory_bytes: 72284
l = input().split()
h,w = int(l[0]),int(l[1])
mapxy = []
for i in range(h):
    mapxy.append(list(input()))
dx = [1,0,-1,0]
dy = [0,1,0,-1]
flag1 = 0
flag2 = 0
for i in range(h):
    for j in range(w):
        if mapxy[i][j] == "#":
            for k in range(4):
                if 0<=i+dy[k]<h and 0<=j+dx[k]<w:
                    if mapxy[i+dy[k]][j+dx[k]] == "#":
                        flag1 = 1
            if flag1 == 0:
                flag2 = 1
                break
            flag1 = 0
    if flag2 == 1:
        print("No")
        break
if flag2 != 1:
    print("Yes")

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
  int N;string S;
  cin >> N >> S;
  int ans = 0;
  for(int i=0;i<N-2;i++){
    if(S.at(i)=='A'&&S.at(i+1)=='B'&&S.at(i+2)=='C') ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <string.h>
typedef struct{
  int time;
  char names[10];
}pr;
int main(){
  int i,n,q,time,sum=0,head=0;
  pr p[1000000],array;
  scanf("%d %d",&n,&time);
  for(i=0;i<n;i++)scanf("%s %d",p[i].names,&p[i].time);
  while(1){
    if(n==head)break;
    if(p[head].time<=time){
      sum+=p[head].time;
      printf("%s %d\n",p[head].names,sum);
      head++;
    }
    else {
      sum+=time;
      p[head].time-=time;
      p[n].time=p[head].time;
      strcpy(p[n].names,p[head].names);
      head++;
      n++;
    }

  }
  return 0;
}



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

using namespace std;

int main(){
  int K, S;
  cin >> K >> S;
  int count=0;
  for (int i=0; i<=K; i++){
      for (int j=0; j<=K; j++){
          if (0<=S-i-j && S-i-j<=K){
              count++;
          }
      }
  }
  cout << count << endl;
}


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

const int maxn=1e5+10;
const int INF=1e9+100;

int H[maxn],n,A,B;

bool check(long long x){
	long long ret=0;
	for(int i=0;i<n;i++){
		long long sum=B*x;
		if(sum<H[i]){
			long long cha=H[i]-sum;
			if(cha%(A-B)==0) ret+=cha/(A-B);
			else ret+=cha/(A-B)+1;
		}
	}
	if(ret<=x) return true;
	return false; 
}

int main(){
	scanf("%d%d%d",&n,&A,&B);
	for(int i=0;i<n;i++){
		scanf("%d",&H[i]);
	}
	long long low=0,high=INF;
	long long ans=1e10;
	while(low<high){
		long long mid=(low+high)/2;
		if(check(mid)){
			ans=min(ans,mid);
			high=mid;
		}
		else low=mid+1;
	}
	printf("%d",ans);
	return 0;
}

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

int n;

int main(void){
    cin >> n;
    vector<int> a(n+1);
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    int res = 0;
    for(int i = 1; i <= n; i++){
        if(i%2 == 1 && a[i]%2 == 1) res++;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h> 
 
#define INF (1<<31) - 1 //INT_MAX/2
#define MOD 1000000007
#define PI  acos(-1)
 
using ll  = long long;
using ull = unsigned long long;

int main(int argc, char *argv[])
{
    int n;
    std::cin >> n;

    std::vector<int> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }

    ll sum1 = 0;
    ll ans1 = 0;
    for (int i = 0; i < n; i++) {
        sum1 += a[i];

        if (i%2 == 0) {
            if (sum1 <= 0) {
                ans1 += -sum1 + 1;
                sum1 = 1;
            }
        } else {
            if (sum1 >= 0) {
                ans1 += sum1 + 1;
                sum1 = -1;
            }
        }
    }

    ll sum2 = 0;
    ll ans2 = 0;
    for (int i = 0; i < n; i++) {
        sum2 += a[i];

        if (i%2 == 0) {
            if (sum2>= 0) {
                ans2 += sum2 + 1;
                sum2 = -1;
            }
        } else {
            if (sum2 <= 0) {
                ans2 += -sum2 + 1;
                sum2 = 1;
            }
        }
    }

    std::cout << std::min(ans1, ans2) << std::endl;

    return 0;
}

Measured memory_bytes: 768
import queue
from collections import defaultdict
n,m = map(int,input().split())
g = defaultdict(set)
ans = [0]*n
for _ in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    g[a].add(b)
    g[b].add(a)

visited = [False]*n
visited[0] = True
q = queue.Queue()
q.put(0)
while not q.empty():
    v = q.get()
    for p in g[v]:
        if not visited[p]:
            ans[p] = v
            q.put(p)
            visited[p] = True
print('Yes')
for x in ans[1:]:
    print(x+1)

Measured memory_bytes: 68864
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
using namespace std;
map<int,int> s;
char w[310001];
int i,j,k,n,f[310001],a[310001];
int main(){
	scanf("%s",w+1);n=strlen(w+1);s.clear();
	for (i=1,a[0]=f[0]=0;i<=n;i++) a[i]=a[i-1]^(1<<(w[i]-'a'));
	s[0]=0;
	for (i=1;i<=n;i++){
		f[i]=n+1;
		if (s.count(a[i])) f[i]=s[a[i]]+1;
		for (j=0;j<26;j++)
		 if (s.count(a[i]^(1<<j))) f[i]=min(f[i],s[a[i]^(1<<j)]+1);
		if (!s.count(a[i])) s[a[i]]=f[i];else s[a[i]]=min(s[a[i]],f[i]);
	}
	printf("%d\n",f[n]);
	return 0;
}

Measured memory_bytes: 11392
n = int(input())
csfl = []

for _ in range(n-1):
    c,s,f = map(int,input().split())
    csfl.append((c,s,f))

while csfl:
    time = 0
    for c,s,f in csfl:
        if time % f == 0:
            time = max(s, time)
        else:
            time = max(s, time+f-(time%f))
        time += c
    print(time)
    csfl.pop(0)

print(0)
        


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

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

int main(){
    int N;
    cin >> N;
    vector<int> C(N);
    for(int i=0; i<N; i++) cin >> C[i];
    vector<int> nxt(N, -1), last(200001, -1);
    for(int i=N-1; i>=0; i--){
        nxt[i] = last[C[i]];
        last[C[i]] = i;
    }
    vector<int64_t> dp(N+1);
    dp[0] = 1;
    for(int i=0; i<N; i++){
        add(dp[i+1], dp[i]);
        if(nxt[i] != -1 && nxt[i] != i+1) add(dp[nxt[i]], dp[i]);
    }
    cout << dp[N] << endl;
}


Measured memory_bytes: 4224
s = input()

if s[0] == s[1] and s[2] == s[3]:
    if s[0] != s[2]:
        print('Yes')
    else:
        print('No')
elif s[0] == s[2] and s[1] == s[3]:
    print('Yes')
elif s[0] == s[3] and s[1] == s[2]:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 3060
import fractions

def main(): 
    A,B,C,D = map(int, input().split())

    c_cnt = (B // C) - ((A-1) // C)
    d_cnt = (B // D) - ((A-1) // D)

    lcm= (C * D) // fractions.gcd(C, D)

    cd_cnt = (B // lcm) - ((A-1) // lcm)

    print(B - (A-1) - c_cnt - d_cnt + cd_cnt)


    
if __name__ == "__main__":
    main() 

Measured memory_bytes: 5048
#include <stdio.h>

int main() {
    
    int a,b,c;
    
    scanf("%d %d %d",&a,&b,&c);
   
   if(a==b)
   {
       printf("%d",c);
   }
   if(b==c)
   {
       printf("%d",a);
   }
   if(a==c)
   {
       printf("%d",b);
   }
    return 0;
}

Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	c := 0
	ans := 0
	var a int
	for i := 0; i < n; i++ {
		fmt.Scan(&a)
		if c+1 == a {
			c = c + 1
		} else {
			ans++
		}
	}
	if c == 0 {
		fmt.Println(-1)
	} else {
		fmt.Println(ans)
	}
}


Measured memory_bytes: 5504
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <utility>
#include <algorithm>
using namespace std;

int main(void){

    long long int a, b, k;
    cin>>a>>b>>k;
    
    vector<long long int> c;
    
    int t=a+k<b?a+k:b;
    for(int i=a; i<t; i++){
        c.push_back(i);
    }
    
    t=b-k+1>a?b-k+1:a;
    for(int i=t; i<=b; i++){
        c.push_back(i);
    }
    sort(c.begin(), c.end());
    int offset=0;
    
    for(int i=1; i<c.size(); i++){
        if(c[i-1]==c[i]){
            c[i-1]=-1;
            offset++;
        }
    }
    
    sort(c.begin(), c.end());
    
    for(int i=offset; i<c.size(); i++){
        cout<<c[i]<<endl;
    }
}


Measured memory_bytes: 256
import bisect,copy,heapq,itertools,string
from collections import *
from math import *
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n, a, b, c, d = MAP()
s = 'a' + input()

flag = 0
for i in range(min(a,b)+1,max(c,d)):
        if (a < i < c or b < i < d) and s[i] == s[i-1] == '#':
                print("No")
                exit()       
        elif max(a,b) <= i <= min(c,d) and s[i-1] == s[i] == s[i+1] == '.':
                flag = 1

if c > d and flag == 0:
        print("No")
else:
        print("Yes")

Measured memory_bytes: 10300
#include <bits/stdc++.h>
using namespace std;
int main(){
    const double pi=3.141592653589793;
    double a,b,h,m;
  cout<<fixed<<setprecision(15);
    
    cin>>a>>b>>h>>m;
    
    double rad = (h+m/60)/6.0-m/30.0;
    if(rad<0) {
      rad = -1*rad;}

    double c = cos(pi*rad);

    double ans2 = a*a+b*b-2*a*b*c;
 
    double ans = sqrt(ans2);
    cout<<ans<<endl;
    }

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

ll gcd(ll a, ll b)//最大公約数
{
  return b != 0 ? gcd(b, a % b) : a;
}


int main(void)
{
    int n, a;
    cin >> n;
    vector<ll> l(n);
    rep(i, n)
    {
        cin >> a;
        l.at(i) = a;
    }
    
    ll LCM = l.at(n-1); 
    rep(i, n-1)
    {
        LCM = LCM * l.at(i) / gcd(LCM, l.at(i));
    }
    cout << LCM << endl;
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
 
using namespace std;
 
#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign

double solve(int i, int m, double ret);

vector<double> l, a, b;
vi sele;
int n, m;
 
signed main()
{
    cin >> n >> m;

    l.assign(n, 0);
    a.assign(n, 0);
    b.assign(n, 0);

    rep(i, n) {
        cin >> l[i] >> a[i] >> b[i];
    }

    printf("%.10lf\n", solve(0, m, 0.0));

    return 0;
}

double solve(int i, int m, double ret)
{
    double ans = 0.0;
    if (i == n || m == 0) {
        return (!m) ? ret : 0.0;
    } else {
        ans = max(solve(i+1, m, ret), ret);
        rep(j, sele.size()) {
            ret += (l[sele[j]] - l[i]) * (l[sele[j]] - l[i]);
            ret += (a[sele[j]] - a[i]) * (a[sele[j]] - a[i]);
            ret += (b[sele[j]] - b[i]) * (b[sele[j]] - b[i]);
        }
        sele.pb(i);
        ans = max(solve(i+1, m-1, ret), max(ans, ret));
        sele.pop_back();
    }
    return ans;
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  int a, b, c;
  cin >> a >> b >> c;
  int total = a + b + c;
  if (total % 2 == 1) {
    cout << "No" << '\n';
    return 0;
  }

  int half = total / 2;
  if (a == half || b == half || c == half) {
    cout << "Yes" << '\n';
  } else {
    cout << "No" << '\n';
  }
  return 0;
}

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

int func(int x){
    if(x<10) return x;
    return x%10 + func(x/10);
}

int main(){
    int N, A, B;
    cin >> N >> A >> B;
    
    int ds, sum=0;
    for(int i=1; i<=N; i++){
        ds = func(i);
        if(A<=ds && ds<=B)
            sum += i;
    }
    
    cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
constexpr int TEN(int n)
{
	return (n==0)?1:10*TEN(n-1);
}
struct Node
{
	using NP = Node*;
	int ma = -1;
	int get(int a, int b)
	{
		if (b <= 0 or sz <= a)
			return -1;
		if (a <= 0 and sz <= b)
			return ma;
		return max(l->get(a, b), r->get(a-sz/2, b-sz/2));
	}
	void set(int k, int x)
	{
		if (sz == 1)
		{
			ma = x;
			return;
		}
		if (k < sz/2)
			l->set(k, x);
		else
			r->set(k-sz/2, x);
		ma = max(l->ma, r->ma);
	}
	NP l, r;
	int sz;
	Node(int sz) : sz(sz)
	{
		if (sz == 1) return;
		l = new Node(sz/2);
		r = new Node(sz - sz/2);
	}
};
int main()
{
	int n, k;
	scanf("%d %d", &n, &k);
	int p[n], q[n];
	for (int i = 0; i < n; i++)
	{
		scanf("%d", p+i);
		p[i]--;
	}
	for (int i = 0; i < n; i++)
		q[p[i]] = i;
	Node* rmq = new Node(n);
	int mi[n];
	vector<vector<int>> g(n);
	for (int i = 0; i < n; i++)
	{
		{
			int v = rmq->get(max(0, q[i]-k+1), q[i]);
			if (v != -1)
			{
				int qv = q[v];
				g[q[i]].push_back(qv);
			}
		}
		{
			int v = rmq->get(q[i], min(n, q[i]+k));
			if (v != -1)
			{
				int qv = q[v];
				g[q[i]].push_back(qv);
			}
			rmq->set(q[i], i);
		}
		rmq->set(q[i], i);
	}
	int deg[n];
	fill_n(deg, n, 0);
	for (int i = 0; i < n; i++)
		for (int j: g[i])
			deg[j]++;
	priority_queue<int> que;
	for (int i = 0; i < n; i++)
		if (deg[i] == 0)
			que.push(i);
	vector<int> v;
	while (que.size())
	{
		int p = que.top();
		que.pop();
		v.push_back(p);
		for (int d: g[p])
		{
			deg[d]--;
			if (deg[d] == 0)
				que.push(d);
		}
	}
	reverse(v.begin(), v.end());
	int ans[n];
	for (int i = 0; i < n; i++)
		ans[v[i]] = i+1;
	for (int i = 0; i < n; i++)
		printf("%d\n", ans[i]);
}

Measured memory_bytes: 87672
/*  Bismillahir Rahmanir Rahim
    Author  :  Md. Sajjat Hosen
    Created :  Friday, 05 June, 2020 */

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long               ll;
typedef long double             ld;
typedef unsigned long long      ull;
typedef pair<int, int>          pii;
typedef pair<ll, ll>            pll;
typedef vector<int>             vi;
typedef vector<ll>              vll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds_set;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> pbds_multiset;

inline int Int() { int x; scanf("%d", &x); return x; }
inline ll Long() { ll x; scanf("%lld", &x); return x; }

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

const int N       = (int) 2e5 + 5;
const int maxN    = (int) 1e6 + 6;
const int Mod     = (int) 1e9 + 7;

#define     debug(x)    cerr << #x << " = " << x << '\n';
#define     all(x)      x.begin(), x.end()
#define     szof(x)     (int) x.size()
#define     ff          first
#define     ss          second
#define     pb          push_back
#define     mp          make_pair
#define     PI          acos(-1.0)
#define     TN          typename
#define     nl          '\n'
#define     Fast_IO     ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

inline int add(int a, int b) { a += b; return a >= Mod ? a - Mod : a < 0 ? a + Mod : a; }
inline int mult(int a, int b) { return (ll) a * b % Mod; }

template <TN T> T gcd(T a, T b) { return !b ? a : gcd(b, a % b); }
template <TN T> T lcm(T a, T b) { return a * (b / gcd(a, b)); }

string a, b;

int main() {
    //Fast_IO
    //clock_t tStart = clock();
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int test = 1, tc = 0;
    while (test--) {
        cin >> a >> b;
        int cnt = 0;
        for (int i = 0; i < szof(a); ++i) {
            if (a[i] != b[i]) cnt++;
        }
        printf("%d\n", cnt);
    }
    //fprintf(stderr, "\nRuntime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
    return 0;
}

Measured memory_bytes: 3840
while True:
    m,f,r = [int(x) for x in input().split()]
    
    if m == -1 and f == -1 and r == -1:
        break
    
    if m == -1 or f == -1:
        print("F")
        continue
    
    if m + f >= 80:
        print("A")
    elif m + f >= 65:
        print("B")
    elif m + f >= 50:
        print("C")
    elif m + f >= 30:
        if r >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")


Measured memory_bytes: 5604
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <locale>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

const long long int INF = 1e9;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define Rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define llrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define llRep(i, n) for(ll i = 1; i <= (ll)(n); i++)

using namespace std;

struct Point{
	int x,y;
};

bool vector_finder(std::vector<ll> vec, ll number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return true;
    }
  else { // 発見できなかったとき
    return false;
    }
}

ll factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
    }
    return ans;
}

ll extended_factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
        ans %= (ll)(1e9+7);
    }
    return ans;
}

vector<ll> Eratosthenes(ll N){
    bool arr[N+1];
    //initialization
    arr[0] = false;
    arr[1] = false;
	for(ll i = 2; i < N+1; i++){
		arr[i] = true;
	}
    //eratosthenes
	for(ll i = 2; i <= sqrt(N); i++){
		if(arr[i]){
			for(ll j = 0; i * (j + 2) <= N; j++){
				arr[i *(j + 2)] = false;//not prime number
			}
		}
	}
    vector<ll> prime;
    llRep(i,N){
        if (arr[i]==true){
            prime.push_back(i);
        }
    }
    return prime;
}

char alphabet[] = {
    'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'
};

// 二分探索
// llrep(i,N){
//     b = B[i];
//     auto cntA = lower_bound(A.begin(), A.end(), b);//イテレータなのでそのままllに変換とかはできない
//     auto cntC = upper_bound(C.begin(), C.end(), b);
//     ll cntA_ll = distance(A.begin(), cntA);
//     ll cntC_ll = C.size() - distance(C.begin(), cntC);
//     cnt += (cntA_ll * cntC_ll);
// }


bool visited[52];
int N,M,a,b;
bool edge[52][52];


void dfs(int v){
    visited[v] = true;
    Rep(i,N){
        if (edge[v][i] && !visited[i]){
            dfs(i);
        }
    }
}

ll minimum_m(ll goal, ll cur){
    ll ans=0;
    while(cur<goal){
        cur *= 2;
        ans ++;
    }
    return ans;
}

int main(){
    ll N,K;
    cin >> N >> K;
    if (K<=N){
        double p = (double)(N-K+1)/(double)N;
        llRep(i,K-1){
            ll min_m = minimum_m(K,i);
            p += (double)pow(0.5,(double)min_m)/(double)N;
        }
        cout << std::fixed << std::setprecision(12) << p << endl;
        return 0;
    }else{
        double p = 0;
        llRep(i,N){
            ll min_m = minimum_m(K,i);
            p += ( (double)1 / pow(2,(double)min_m) ) / (double)N;
        }
        cout << std::fixed << std::setprecision(12) << p << endl;
        return 0;
    }

    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[3];
            for (int i = 0; i < n; ++i) {
                int x = in.nextInt();
                if (x % 4 == 0) {
                    ++a[2];
                } else if (x % 2 == 0) {
                    ++a[1];
                } else {
                    ++a[0];
                }
            }
            if (a[1] > 0) {
                out.println(a[2] >= a[0] ? "Yes" : "No");
            } else {
                out.println(a[0] - a[2] > 1 ? "No" : "Yes");
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}



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

int main(){
  int n;
  ll k;
  cin >> n >> k;
  vector<int> A(n);
  rep(i,n) cin >> A[i];
  sort(A.begin(),A.end());
  vector<int> F(n);
  rep(i,n) cin >> F[i];
  sort(F.rbegin(),F.rend());

  ll ng = -1;
  ll ok = 0;
  rep(i,n) ok = max(ok, (ll)A[i] * F[i]);
  while (abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    bool isok = [&]{
      ll s = 0;
      rep(i,n){
        s += max(0ll, A[i] - mid / F[i]);
      }
      return s <= k;
    }();
    if (isok) ok = mid;
    else ng = mid;
  }
  cout << ok << endl;
  return 0;
}


Measured memory_bytes: 1920
#include<cstdio>

int main(){
    while (1) {
        int a, b;
        char op;
        scanf("%d %c %d", &a, &op, &b);
        if (op == '?') {
            break;
        }

        if (op == '+') {
            printf("%d\n", a + b);
        } else if (op == '-') {
            printf("%d\n", a - b);
        } else if (op =='*') {
            printf("%d\n", a * b);
        } else {
            printf("%d\n", a / b);
        }
    }

    return 0;
}


Measured memory_bytes: 2684
#include<bits/stdc++.h>
using namespace std;
int main(){
  string l;
  cin >> l;
  vector<vector<long> >dp(l.length(),vector<long>(2,0)); // 0:　まだLを守ってる　1::Lを破る

  dp[0][0] = 2;
  dp[0][1] = 1;

  long const MOD = 1e9+7;

  for(int i=1;i<l.length();i++){
    if(l[i] == '0'){
      dp[i][1] = dp[i-1][1] * 3;
      dp[i][1] %= MOD;
      dp[i][0] = dp[i-1][0];
    }else{
      dp[i][0] = 2 * dp[i-1][0];
      dp[i][0] %= MOD;

      dp[i][1] = dp[i-1][1]*3 + dp[i-1][0];
      dp[i][1] %= MOD;
    }
  }
  cout << (dp[l.length()-1][0] + dp[l.length()-1][1])%MOD<<endl;
  
  
}


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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int N, d, ans = 0, arr[11][11];
    cin >> N >> d;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < d; j++) {
            cin >> arr[i][j];
        }
    }
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
                double unders = 0.0;
                for (int l = 0; l < d; l++) {
                    if (arr[i][l] < 1e9 && arr[j][l] < 1e9) {
                        unders += pow(arr[i][l] - arr[j][l], 2);
                    } else {
                        unders = -1;
                        break;
                    }
                    if (i == j) {
                        unders = -1;
                        break;
                    }
                }
                if (unders == -1) {
                    continue;
                } else {
                    //cout << sqrt(unders) << " " << floor(sqrt(unders)) << "\n";
                    if (sqrt(unders) == floor(sqrt(unders))) ans++;
                }
        
        }
        for (int m = 0; m < d; m++) {
            arr[i][m] = 1e9;
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
a = int(input()) 
b = int(input()) 
c = int(input()) 
d = int(input()) 
e = int(input())

import math 
aa=math.ceil(a/10)*10
bb=math.ceil(b/10)*10
cc=math.ceil(c/10)*10
dd=math.ceil(d/10)*10
ee=math.ceil(e/10)*10

r = max(aa-a,bb-b,cc-c,dd-d,ee-e)
s = aa+bb+cc+dd+ee-r

print(s)

Measured memory_bytes: 3060
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    template<typename T>
    vector<T> read_vec(size_t n){
        vector<T> tmp(n);
        for(size_t i = 0; i < n; i++){
            cin >> tmp[i];
        }
        return tmp;
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

constexpr int MOD = 1000000007;

int main(){
    Stream io;
    
    ll N;
    io.read(N);
    string ans;
    while(N > 0){
        N--;
        int r = N % 26;
        ans.push_back('a' + r);
        N /= 26;
    }
    reverse(ans.begin(), ans.end());
    cout << ans;

    return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<int>> a(31,vector<int>(31));
  int i,j,k;
  int ko;
  for(i=0;i<n;i++){
    cin >> ko;
    for(j=0;j<ko;j++) cin >> a[i][j];
  }
  int cnt = 0;
  int cnt2 = 0;
  for(i=1;i<=m;i++){
    for(j=0;j<n;j++){
      for(k=0;k<m;k++){
        if(a[j][k] == i) cnt++;
      }
    }
    if(cnt == n) cnt2++;
    cnt = 0;
  }
  cout << cnt2 << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  set<int> s1, s2;
  for(int i=0; i<m; i++){
    int tmp1, tmp2;
    cin >> tmp1 >> tmp2;
    if(tmp1==1) s1.insert(tmp2);
    if(tmp2==n) s2.insert(tmp1);
  }
  for(auto itr=s1.begin(); itr!=s1.end(); itr++){
    if(s2.count(*itr)){
      cout << "POSSIBLE";
      return 0;
    }
  }
  cout << "IMPOSSIBLE";
  return 0;
}

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

#define ll long long

int main(){
	ll a,x,ar[2005], cnt[2005], nct[2005], ans=0;
	for(int i=0; i<2005; i++){
		cnt[i]=0;
		nct[i]=0;
	}
	cin>>a;
	for(int i=0; i<a; i++){
		cin>>x;
		ar[i]=x;
		cnt[x]++;
	}
	sort(ar,ar+a);
	for(int i=1; i<=2005; i++){
		cnt[i]+=cnt[i-1];
	}
	for(ll i=0; i<a-1; i++){
		for(int j=i+1; j<a; j++){
			ans+=cnt[ar[i]+ar[j]-1]-j-1;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
int len[3], used[3], s[3][100], d, i;

void rec(int t){
        if(used[t]++>=len[t]) putchar('A'+t);
        else rec(s[t][used[t]-1]);
}

int main(){
        for(i=0;i<3;i++) while((d=getchar())!='\n') s[i][len[i]++] = d-'a';
        rec(0);
        return 0;
}

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

int main() {

    int bingo[3][3];

    for(int i = 0; i < 3; ++i) {
        for(int j = 0; j < 3; ++j)
            cin >> bingo[i][j];
    }    

    int n;

    cin >> n;

    for(int i = 0; i < n; ++i) {
        int num;
        cin >> num;

        for(int bi = 0; bi < 3; bi++) {
            for(int bj = 0; bj < 3; bj++) {
                if(bingo[bi][bj] == num)
                    bingo[bi][bj] = 0;
            }
        }

    }

    bool isBingo = false;

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

        int Rsum = bingo[i][0] + bingo[i][1] + bingo[i][2];
        if(Rsum == 0)
            isBingo = true;

        int Csum = bingo[0][i] + bingo[1][i] + bingo[2][i];
        if(Csum == 0)
            isBingo = true;

    }


    if(bingo[0][0] + bingo[1][1] + bingo[2][2] == 0)
        isBingo = true;
    
    if(bingo[0][2] + bingo[1][1] + bingo[2][0] == 0)
        isBingo = true;

    if(isBingo)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>

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

using namespace std;

int main(void)
{
	int N, K, T, U, V, L;
	int eat_d;
	int distance;
	int carrot = 0;
	double result = 0.0;
	cin >> N >> K >>T >> U >> V >> L;
	rep(i, N){
		int D;
		cin >> D;
		if (i == 0){
			result += (double)D / U;
			eat_d = D;
		}else{
			distance = D - eat_d;
			while(distance > V*T && carrot >= 1){
				carrot--;
				result += (double)T;
				eat_d += V*T;
				distance = D - eat_d;
			}
			
			if (distance > V*T){
				result += (double)T + (double)(distance - V*T) / U;
				eat_d = D;
			}else if(carrot == K){
				result += (double)distance / V; 
				eat_d = D;
			}else{
				carrot++;
			}
		}
	}

	distance = L - eat_d;
	while(distance > V*T && carrot >= 1){
		carrot--;
		result += (double)T;
		eat_d += V*T;
		distance = L - eat_d;
	}

	if (distance > V*T){
		result += (double)T + (double)(distance - V*T) / U;
	}else{
		result += (double)distance / V;
	}
	cout << fixed << setprecision(9) << result << endl;
	return 0;
}


Measured memory_bytes: 3284
/*** akshaykumar99 ***/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;

const long long MOD = 1e9+7;
const long double PI = acos(-1);
const long long N = 1e5+1;
 
typedef long long ll;
typedef long double ld;

void test_case()
{
    ll x;
    cin >> x;
    if( x <= 599)
        cout << 8;
    else if(x <= 799)
        cout << 7;
    else if(x <= 999)
        cout << 6;
    else if(x <= 1199)
        cout << 5;
    else if( x<= 1399)
        cout << 4;
    else if( x <= 1599)
        cout << 3;
    else if( x <= 1799)
        cout << 2;
    else
        cout << 1;

}
 
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); 
    ll tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}

Measured memory_bytes: 3636
#!/usr/bin/env python3

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from fractions import gcd                    # for Python3.4.3


def main():
    mod = 10000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    

    def check_no_contradict(case):
        for i, person in enumerate(case):
            if person == 1:
                for comment in comments[i]:
                    if case[comment[0]] != comment[1]:
                        return False
        return True


    n = ii()
    comments = [[] for _ in range(n)]
    for i in range(n):
        num = ii()
        for _ in range(num):
            a, b = mi()
            comments[i].append(tuple([a-1, b]))
    
    ans = 0
    for case in product([0, 1], repeat=n):
        if check_no_contradict(case):
            # print(f"case: {case}")
            ans = max(ans, case.count(1))
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int num;
string s;
int main()
{
	cin>>s;
	for(int i=0;i<=s.size()-1;i++) if (s[i]=='o') num++;
  if(15-s.size()+num>=8) cout<<"YES\n";
	else cout<<"NO\n";
  return 0;
}

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

namespace ConsoleApp15
{
    class Class205
    {
        static void Main()
        {
            int X = int.Parse(Console.ReadLine());
            int a = X / 500;
            int b = (X % 500) / 5;
            Console.WriteLine(a*1000+b*5);
        }
    }
}


Measured memory_bytes: 13140
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
typedef long long int ll;

int main()
{
	int n, a;
  scanf("%d %d", &n, &a);
  int x[50];
  for(int i=0; i<n; i++){
    scanf("%d", &x[i]);
    x[i]-=a;
  }
  ll dp[5001]={};
  dp[2500]=1;
  for(int i=0; i<n; i++){
    ll dp1[5001];
    for(int k=0; k<5001; k++){
      if(k-x[i]>=0 && k-x[i]<=5000){
        dp1[k]=dp[k]+dp[k-x[i]];
      }else{
        dp1[k]=dp[k];
      }
    }
    for(int k=0; k<5001; k++){
      dp[k]=dp1[k];
    }
  }
  printf("%lld\n", dp[2500]-1);
 
	return 0;
}


Measured memory_bytes: 256
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===
def main():
    s = list(sys.stdin.readline())
    d = []

    for i in range(len(s)):
        if s[i] != "B":
            d.append(s[i])
        else:
            if len(d) != 0:
                del d[-1]

    print(*d, sep="")


if __name__ == '__main__':
    main()


Measured memory_bytes: 10316
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String W=sc.next();
        int sum=0;
        while(true){
            String H=sc.next();
            if(H.equals("END_OF_TEXT"))break;
            if(H.equalsIgnoreCase(W))sum++;
        }
        System.out.println(sum);
        sc.close();
    } 
}


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

int main() {
    ll n;
    cin >> n;
    vector<string> s(n);
    rep(i,n) cin >> s[i];

    sort(s.begin(), s.end());
    s.erase(unique(s.begin(), s.end()), s.end());
    cout << s.size() << endl;

    return 0;
}


Measured memory_bytes: 9536