akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>

using namespace std;

int main(void){
  int N, M;
  cin >> N >> M;
  vector<int> count(N, 1);
  vector<bool> red(N, false);
  red[0] = true;
  for(int i = 0; i < M; i++){
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    count[x]--;
    count[y]++;
    if(red[x]) red[y] = true;
    if(count[x] == 0) red[x] = false;
  }
  int ans = 0;
  for(int i = 0; i < N; i++){
    if(red[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstring>
using namespace std;
int main(){
  int N;
  cin>>N;
  int d[N];
  for(int i=0;i<N;i++)cin>>d[i];
  int total=0;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      total+=d[i]*d[j];
    }
  }
  cout<<total<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main() {
    long n, ans = 0, cur = 0;
    vector<long long int> h;

    cin >> n;
    for (long i = 0; i < n; i++) {
        long tmp;
        cin >> tmp;
        h.push_back(tmp);
    }

    for (long i = 0; i < n-1; i++) {
        if (h.at(i) >= h.at(i+1)) {
            cur++;
        } else {
            ans = max(ans, cur);
            cur = 0;
        }
    }

    ans = max(ans, cur);
    cout << ans << endl;
}

Measured memory_bytes: 1400
import java.util.ArrayList;
import java.util.Collections;
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> list = new ArrayList<>();
        for (int i=0; i<N; i++){
            list.add(sc.nextInt());
        }
        sc.close();

        Collections.sort(list);

        int a = N/2 - 1;
        int b = N/2;

        int t = list.get(a);
        int y = list.get(b);

        if (t == y){
            System.out.println("0");
            return;
        }

        int count = y - t;
        System.out.println(count);
    }
}

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

int main () {
    int N, M, A, P;
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        cin >> A;
        N = N - A;
        P = N;
    }
    if (P < 0){
        cout << "-1" << endl;
    } else {
    cout << P << endl;
    }
}

Measured memory_bytes: 3636
#include<stdio.h>

#define inf 999999

int G[100][100];

void MST(int);

void MST(int n)
{
  int u,min,sum=0,i,j;
  int a[100],b[100],judge[100];

  for(i=0;i<n;i++) {
    a[i] = inf;
    b[i] = -1;
    judge[i] = 0;  /* judgeは0で未判断,1で判断済,2で判断の必要なし */
  }

  a[0] = 0;

  while(1) {
    min = inf;
    u = -1;
    for(i=0;i<n;i++) {
      if(min > a[i] && judge[i] != 2) {
	u = i;
	min = a[i];
      }
    }
    if(u == -1)
      break;
    judge[u] = 2;
    for(j=0;j<n;j++) {
      if(judge[j] != 2 && G[u][j] != inf) {
	if(a[j] > G[u][j]) {
	  a[j] = G[u][j];
	  b[j] = u;
	  judge[j] = 1;
	}
      }
    }
  }

  for(i=0;i<n;i++) {
    if(b[i] != -1)
      sum += G[i][b[i]];
  }

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

}


int main()
{
  int n,m,i,j;

  scanf("%d",&n);

  for(i=0;i<n;i++) {
    for(j=0;j<n;j++) {
      scanf("%d",&m);
      if(m == -1) {
	G[i][j] = inf;
      }else{
	G[i][j] = m;
      }
    }
  }

  MST(n);

  return 0;
}



Measured memory_bytes: 2052
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
using namespace std;
map <int ,int> mpa,mpb;

int search(int A[], int n, int key){
  int i=0;
  A[n]=key;
  while(A[i] !=key){
    i++;
  }
  return i !=n;
}

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

  int q;
  cin >> q;
  int t,ans=0;
  for(int i=0;i<q;i++){
    cin >> t;
    if(search(A,N,t)){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6996
from __future__ import division
import sys

def can_place(pos, idx, col):
    for i in range(8):
        if pos[i] is not None and pos[i] == col: return False
    for i in range(8):
        if pos[i] is not None and abs(pos[i] - col) == abs(i - idx): return False
    return True

def dfs(pos, depth):
    if 8 == depth:
        for idx, p in enumerate(pos):
            print('.' * p + 'Q' + '.' * (7 - p))
    else:
        if pos[depth] is None:
            for i in range(8):
                if can_place(pos, depth, i):
                    pos[depth] = i
                    dfs(pos, depth + 1)
                    pos[depth] = None
        else:
            return dfs(pos, depth + 1)

if __name__ == '__main__':
    n = int(sys.stdin.readline())
    pos = [None] * 8
    for _ in range(n):
        row, col = map(int, sys.stdin.readline().strip().split())
        pos[row] = col
    dfs(pos, 0)

Measured memory_bytes: 6496
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int N;
    cin >> N;
    vector<int> p( N );
    for( auto &x : p )
    {
        cin >> x;
    }
    int res = INT_MIN, sum{}, no{};
    REP( i, N )
    {
        if( res < p[ i ] )
        {
            res = p[ i ];
            no = i;
        }
        sum += p[ i ];
    }
    cout << sum - p[ no ] / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iterator>
#include <vector>

using namespace std;

namespace mod {

template <class T, int M>
class MInt;

template <class T, int M>
MInt<T, M> Pow(const MInt<T, M> &base, T exp);

template <class T, int M>
MInt<T, M> Inv(const MInt<T, M> &n);

template <class T, int M>
class MInt {
  T n_;

 public:
  MInt() : n_(0) {}
  MInt(T n) : n_((n % M + M) % M) {}

  MInt &operator+=(const MInt &rhs) {
    n_ += rhs.n_;
    if (n_ >= M) {
      n_ -= M;
    }

    return *this;
  }

  MInt &operator-=(const MInt &rhs) {
    n_ += M - rhs.n_;
    if (n_ >= M) {
      n_ -= M;
    }

    return *this;
  }

  MInt &operator*=(const MInt &rhs) {
    n_ = n_ * rhs.n_ % M;
    return *this;
  }

  MInt &operator/=(const MInt &rhs) { return (*this) *= Inv(rhs); }

  T Get() { return n_; }
};

template <class T, int M>
MInt<T, M> operator-(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {
  MInt<T, M> res(lhs);
  return res -= rhs;
}

template <class T, int M>
MInt<T, M> operator+(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {
  MInt<T, M> res(lhs);
  return res += rhs;
}

template <class T, int M>
MInt<T, M> operator*(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {
  MInt<T, M> res(lhs);
  return res *= rhs;
}

template <class T, int M>
MInt<T, M> operator/(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {
  MInt<T, M> res(lhs);
  return res /= rhs;
}

template <class T, int M>
MInt<T, M> Pow(const MInt<T, M> &base, T exp) {
  if (exp == 0) {
    return 1;
  }

  auto a = Pow(base, exp / 2);
  a *= a;
  if (exp % 2 == 1) {
    a *= base;
  }

  return a;
}

template <class T, int M>
MInt<T, M> Inv(const MInt<T, M> &n) {
  return Pow(n, static_cast<T>(M - 2));
}
}  // namespace mod

const int md = 1e9 + 7;
using MInt = mod::MInt<long long, md>;
class BinCoef {
  vector<MInt> f;

 public:
  BinCoef(int n) : f(n + 1) {
    f[0] = f[1] = 1;
    for (int i = 2; i <= n; i++) {
      f[i] = MInt(i) * f[i - 1];
    }
  }

  MInt NCM(int n, int m) { return f[n] * mod::Inv(f[m] * f[n - m]); }
};

int main(int argc, const char *argv[]) {
  int n, k;
  cin >> n >> k;
  vector<int> va(n);
  for (auto &a : va) {
    cin >> a;
  }

  sort(va.begin(), va.end());

  BinCoef bc(n);
  MInt ans(0);
  for (auto it = va.rbegin(); it != va.rend() - k + 1; it++) {
    int idx = distance(va.rbegin(), it);
    ans += MInt(*it) * bc.NCM(n - idx - 1, k - 1);
  }

  for (auto it = va.begin(); it != va.end() - k + 1; it++) {
    int idx = distance(va.begin(), it);
    ans -= MInt(*it) * bc.NCM(n - idx - 1, k - 1);
  }

  cout << ans.Get() << "\n";
  return 0;
}

Measured memory_bytes: 1408
n = int(input())
a_list = list(map(int, input().split()))

a_count = len(a_list)

boll_list = [0] * n

for rev_index, a in enumerate(reversed(a_list)):
    #indexはa_listへのアクセス用
    index = a_count - rev_index - 1
    divide_max = a_count // (index + 1)
    total = 0
    for divide in range(divide_max):
        total += boll_list[(index + 1) * (divide + 1) - 1]
    if a_list[index] != total % 2:
        boll_list[index] = 1

if 1 in boll_list:
    output_list = []
    for index, i in enumerate(boll_list):
        if i == 1:
            output_list.append(str(index + 1))
    print(len(output_list))
    print(' '.join(output_list))
else:
    print('0')


Measured memory_bytes: 17204
#include<iostream>
//#include <cmath>
//#include <bits/stdc++.h>

typedef long long ll;

using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
   // freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int x,a;cin>>x>>a;
    if(x<a)cout<<0;
    else cout<<10;
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>

using namespace std;

int main() {
    int N;
    char str[100001];
    cin >> N >> str;
    for (int i = 0; i < 4; i++) {
        char ans[100001];
        int s = i;
        for (int j = 0; j < N; j++) {
            int f0 = s / 2;
            int f1 = s % 2;
            int f2 = f0 ^ (str[j] == 'o' ? 0 : 1);
            ans[(j+1) % N] = f2 == 0 ? 'S' : 'W';
            s = ((f1 ^ f2) << 1) | f2;
        }
        if (i == s) {
            ans[N] = '\0';
            cout << ans << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 512
#include<stdio.h>

static const int N = 100;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int n, i, j,key;
  int A[N+1];
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
  
  trace(A, n);
  for(j=2;j<=n;j++){
    key=A[j];
    i=j-1;
    while(i>0 && A[i]>key){
      A[i+1]=A[i];
      i--;
      A[i+1]=key;
    }
    trace(A, n);
  }
 
 return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
#define LL long long
#define Max 100005
#define Mod 1e9+7
const LL mod=1e9+7;
const LL inf=0x3f3f3f3f;
using namespace std;
vector<int>a[Max];
int n;
int x,y;
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(a>b)
	{
		printf("%d\n",0);
	}
	else
	{
		int t=b/a;
		//printf("%d\n",t);
		printf("%d\n",min(t,c));
	}
    return 0;
}


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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)):((m)-(n))),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)
#define loop for(;;)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;
typedef vector<int> vi;
typedef vector<string> vs;
typedef map<string,int> Dictionary;
const Real PI = acos(-1);

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  if (v.size() == 0) {
    os << "(empty)";
    return os;
  }
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

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

bool
intersect(vector<int>&xs, vector<int>&ys, vector<int>&rs, int i, int j) {
  int x0 = xs[i];
  int y0 = ys[i];
  int r0 = rs[i];
  int x1 = xs[j];
  int y1 = ys[j];
  int r1 = rs[j];
  return pow(x1 - x0, 2) + pow(y1 - y0, 2) < pow(r0 + r1, 2);
}

string ni(unsigned int n) {
  string r = "";
  rep (i, 10) r += n & (1 << i) ? "1" : "0";
  return r;
}

int f(vector<vector<bool>>&d, vector<int>&cs) {
  const int n = d.size();

  vector<bool> memo(1 << n, false);

  stack<pair<unsigned int, int>> s;
  s.push(cons(0, 0));
  int ans = 0;

  int cx = 0;

  while (!s.empty()) {
    auto t = s.top(); s.pop();
    int r = car(t);
    int m = cdr(t);
    ans = max(ans, m);
    if (ans == n) return n;

    if (memo[r]) continue;
    memo[r] = true;
    //trace(ni(r));

    rep (i, n) {
      if (r & (1 << i)) continue;
      range (j, i + 1, n) {
        if (r & (1 << j)) continue;
        if (cs[i] != cs[j]) continue;

        bool bi = false;
        rep (k, i) if (!(r & (1 << k)) && d[k][i]) bi = true;
        if (bi) continue;
        bool bj = false;
        rep (k, j) if (!(r & (1 << k)) && d[k][j]) bj = true;
        if (bj) continue;

        s.push( cons(r | (1 << i) | (1 << j), m + 2) );
        //cout << "remove " << cons(i, j) << endl;
      }
    }
  }

  return ans;
}

int main() {

  for (int n; cin >> n, n; ) {
    vector<int> xs;
    vector<int> ys;
    vector<int> rs;
    vector<int> cs;

    rep (i, n) {
      int x, y, r, c;
      cin >> x >> y >> r >> c;
      --c;
      xs.push_back(x);
      ys.push_back(y);
      rs.push_back(r);
      cs.push_back(c);
    }

    // d[i][j] = i is on j
    vector<vector<bool>> d(n, vector<bool>(n, false));
    rep (i, n) {
      for (int j = i + 1; j < n; ++j) {
        d[i][j] = intersect(xs, ys, rs, i, j);
      }
    }
    cout << f(d, cs) << endl;

  }

  return 0;
}

Measured memory_bytes: 3272
n = int(input())
A = list(map(int, input().split()))
ans = 0
s = 0
j = 0
for i in range(n):
    while j < n and not (s & A[j]):
        s ^= A[j]
        j += 1
    ans += j-i
    s ^= A[i]
print(ans)

Measured memory_bytes: 24424
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>

using namespace std;

#define mp make_pair
#define pb push_back
#define x first
#define y second

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;

const int N=100010;

int a[N];
ll s[N],c[N],b[N];

int main()
{
	int n,k;scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	s[0]=0;for (int i=1;i<=n;i++) s[i]=s[i-1]+a[i];
	b[0]=0;for (int i=1;i<=n;i++) b[i]=b[i-1]+max(a[i],0);
	c[n+1]=0;for (int i=n+1;i;i--) c[i]=c[i+1]+max(a[i],0);
	ll ans=0;
	for (int i=1;i<=n-k+1;i++)
		ans=max(ans,max(s[i+k-1]-s[i-1],0ll)+b[i-1]+c[i+k]);
	cout<<ans<<endl;
	return 0;
}


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

int main()
{
	int a[100000][2], i, I, x, y;
	for(i = 0 ;  ; i++)
	{
		scanf("%d%d", &a[i][0], &a[i][1]);
		if(a[i][0] == 0 || a[i][1] == 0)
		{
			for(I = 0; I < i ; I++)
			{
				for(x = 0 ; x < a[I][0] ; x++)
				{
					for(y = 0 ; y < a[I][1] ; y++)
					{
						printf("#");
					}
					printf("\n");
				}
				printf("\n");
			}
			exit(0);
		}
	}
	return 0;
}


Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
signed main(void){
    int n; cin>>n;
    vector <int> a(n);
    vector <int> b(n); 
    vector <pair <int,int>> s(n); 
    rep(i,n) {cin>>a[i]>>b[i]; s[i] = {a[i]+b[i], i};}
    sort(s.begin(),s.end(),greater<pair<int,int>>());
    
    int tak = 0, ao = 0;
    rep(i,n){
        if(i%2==0){
            tak += a[s[i].S];
        }else ao += b[s[i].S];
    }
    cout<<tak - ao<<endl;
    
}


Measured memory_bytes: 3328
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

class Node<T>
{
    private int Height { get; set; }
    private Node<T> Parent { get; set; }
    private long size;
    public long Size { get { return Find().size; } set { size = value; } }
    public T Item { get; }

    public Node(T item)
    {
        Height = 0;
        Parent = this;
        Item = item;
        Size = 1;
    }

    public Node<T> Find()
    {
        if (Parent == this)
        {
            return this;
        }
        var p = Parent.Find();
        Parent = p;
        return p;
    }

    public static void Unite(Node<T> a, Node<T> b)
    {
        var p = a.Find();
        var q = b.Find();
        if (p.Height < q.Height)
        {
            p.Parent = q;
            q.Height = Math.Max(p.Height + 1, q.Height);
            q.Size += p.Size;
            p.Size = 0;
        }
        else
        {
            q.Parent = p;
            p.Height = Math.Max(q.Height + 1, p.Height);
            p.Size += q.Size;
            q.Size = 0;
        }
    }

    public static bool Same(Node<T> a, Node<T> b)
    {
        return a.Find().Item.Equals(b.Find().Item);
    }
}

class MyClass
{
    public static void Solve()
    {
        var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var N = input[0];
        var K = input[1];
        var A = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var l = 0;
        var r = 0;
        var min = int.MaxValue;
        var set = new HashSet<int>();
        var count = new int[K + 1];
        if (A[0] <= K)
        {
            set.Add(A[0]);
            count[A[0]]++;
        }
        while (l < N && r < N)
        {
            var b = set.Count == K;
            if (b)
            {
                min = Math.Min(min, r - l + 1);
            }
            if (b && l < r)
            {
                if (A[l] <= K)
                {
                    count[A[l]]--;
                    if (count[A[l]] == 0)
                    {
                        set.Remove(A[l]);
                    }
                }
                l++;
            }
            else
            {
                r++;
                if (r < N && A[r] <= K)
                {
                    count[A[r]]++;
                    set.Add(A[r]);
                }
            }
        }
        Console.WriteLine(min == int.MaxValue ? 0 : min);
    }

    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}



Measured memory_bytes: 29704
n,m,k=map(int,input().split())
a=[int(j)for j in input().split()]
b=[int(j)for j in input().split()]
from itertools import accumulate
a=[0]+list(accumulate(a))
b=[0]+list(accumulate(b))
ans=0
j=m
for i in range(n+1):
    if a[i]<=k:
        while a[i]+b[j]>k:j-=1
        ans=max(ans,i+j)
print(ans)

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

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

  for (int i = 1; i < 10; i++){
    for (int j = 1; j < 10; j++){
      
      if (i * j == N){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}





Measured memory_bytes: 256
#include<stdio.h>
int main()
{
 int x,y;
 for(;;)
 {
  scanf("%d %d",&x,&y);
  if(x<y)
  {
   printf("%d %d\n",x,y);
  }
  else if(y<x)
  {
   printf("%d %d\n",y,x);
  }
  else if(x==y&&x!=0&&y!=0)
  {
   printf("%d %d\n",x,y);
  }
  else if(x==0&&y==0)
  {
   break;
  }
 }
 return 0;
}

Measured memory_bytes: 1028
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <map>
#include <stdio.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = (a); i < (int)(b); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll MOD = (ll)pow(10.0, 9.0) + 7;
pint dx[4] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };

ll min(ll a, ll b)
{

	return (a < b) ? a : b;
}




ll A, B, C;
ll An, Bn, Cn;
int main() {

	cin >> A >> B >> C;

	ll K = A + B + C;
	
	
	ll k1 = 0;


	if (A == (K - A) / 2 && B == (K - B) / 2 && C == (K - C) / 2 && A % 2 == 0 && B % 2 == 0 && C % 2 == 0) {
		cout << -1 << endl;
		return 0;
	}

	An = A, Bn = B, Cn = C;
	while (An % 2 == 0 && Bn % 2 == 0 && Cn % 2 == 0) {

		An = (K - An) / 2;
		Bn = (K - Bn) / 2;
		Cn = (K - Cn) / 2;

			k1 += 1;
	}
	


	
	cout << k1 << endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))

count = 0

for x in range(N):
    if x != N - 1:
        if a[x] == a[x + 1]:
            if x < N - 2:
                if a[x + 2] == 10000:
                    a[x + 1] = 9999
                    count += 1
                else:
                    a[x + 1] = 10000
                    count += 1
            else:
                a[x + 1] = 10000
                count += 1
print(count)


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

using namespace std;

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

int rot[2][8] = {{3, 0, 1, 2, 7, 4, 5, 6}, {4, 5, 1, 0, 7, 6, 2, 3}};

set<int> st;
int to_int(vector<int>& v) {
    int ret = 0;
    int p10 = 1;
    REP(i, v.size()) {
        ret += p10 * v[i];
        p10 *= 10;
    }
    return ret;
}
void dfs(vector<int> v) {
    int num = to_int(v);
    if (st.count(num)) return;
    st.insert(num);
    vector<int> nv(8);
    REP(i, 2) {
        REP(j, 8) { nv[j] = v[rot[i][j]]; }
        dfs(nv);
    }
}

bool solve() {
    int b[8];
    st.clear();
    map<string, int> mp;
    int id = 0;
    REP(i, 8) {
        string s;
        if (cin >> s)
            ;
        else
            return false;
        if (mp.count(s)) {
            b[i] = mp[s];
        } else {
            mp[s] = id;
            id++;
            b[i] = mp[s];
        }
    }
    sort(b, b + 8);
    int ans = 0;
    do {
        vector<int> v(8);
        REP(i, 8) v[i] = b[i];
        if (!st.count(to_int(v))) ans++;
        dfs(v);
    } while (next_permutation(b, b + 8));
    cout << ans << endl;
    return true;
}
signed main() {
    while (solve())
        ;
    // solve();
}


Measured memory_bytes: 4932
#include <bits/stdc++.h>
using namespace std;
int main(){
    int K;
    vector<int> x(5);
    for(int i = 0; i < 5; i++){
        cin >> x.at(i);
    }
    cin >> K;
    bool m = true;
    for(int i = 4; i > 0; i--){
        if(x.at(i)-x.at(0) > K){
            m = false;
        }
        else{
        }
    }
    if(m){
        cout << "Yay!" << endl;
    }
    else{
        cout << ":(" << endl;
    }
    return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
const int dx[]={1,0,-1,0,1,-1,-1,1}; 
const int dy[]={0,1,0,-1,1,1,-1,-1}; 
const int INF = 1e9; 
const long long LINF = 1e18; 
const double EPS = 1e-8; 
#define pb push_back
#define mk make_pair 
#define fr first 
#define sc second 
#define ll long long 
#define reps(i,j,k) for(int i = (j); i < (k); ++i) 
#define rep(i,j) reps(i,0,j) 
#define all(a) (a).begin(),(a).end() 
#define MOD 1000000007 
typedef pair<int,int> Pii;
typedef pair<Pii,int> P;
typedef vector<int> vi;

int main(){

	string str;
	cin >> str;
	string rev;
	reverse(str.begin(),str.end());
	
	rev = str;
	reverse(str.begin(),str.end());
	
	rep(i,rev.size()){
		if(rev[i] == 'b'){
			rev[i] = 'd';
		}
		else if(rev[i] == 'd'){
			rev[i] = 'b';
		}
		else if(rev[i] == 'p'){
			rev[i] = 'q';
		}
		else if(rev[i] == 'q'){
			rev[i] = 'p';
		}
	}	

	puts(rev==str?"Yes":"No");


	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MD 1000000007
#define INF 1ll<<60
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main(){
    int n,l;
    cin>>n>>l;
    int sum=1e9,ans;
    for(int i=1;i<=n;i++){
        int sum1=0,sum2=0;
        for(int j=1;j<=n;j++){
            sum1+=(l+j-1);
            if(j!=i) sum2+=(l+j-1);
        }
        if(abs(sum1-sum2)<sum){
            sum=abs(sum1-sum2);
            ans=sum2;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

#define ALL(a) (a).begin(), (a).end()

typedef long long ll;

using namespace std;

ll tob(ll x){
	ll ret = 0;
	for(;x;x >>= 1)ret++;
	return ret;
}

int main(){
	ll n; cin >> n;
	map<ll, ll> m;
	for(int i = 0; i < n; i++){
		ll a; cin >> a;
		if(m.find(a) == m.end())m[a] = 0;
		m[a]++;
	}
		
	ll ans = 0;
	for(auto itr = m.rbegin(); itr != m.rend(); ++itr){
		//cerr << itr->first << endl;
		ll c = (1 << tob(itr->first)) - itr->first;
		if(m.find(c) != m.end()){
			if(itr->first == c){
				ans += itr->second >> 1;
				itr->second = itr->second & 1;
				continue;
			}
			ll cc = min(m[itr->first], m[c]);
			ans += cc;
			//for(auto e : m)cerr << e.first << ":" << e.second << " ";
			//cerr << endl;
			m[c] -= cc;
		}
	}
	cout << ans << endl;


	return 0;
}


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

int v, j;

void printArr(int A[], int n) {
    for (int i = 0; i < n; ++i) {
        cout << A[i];
        if (i < n-1)
            cout << ' ';
    }
    cout << endl;
}

void insertionSort(int A[], int N) {
    printArr(A, N);

    for (int i = 1; i <= N-1; ++i) {
        v = A[i];
        j = i-1;
        while (j >= 0 && A[j] > v) {
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        printArr(A, N);
    }
}

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

    int n;
    cin >> n;

    int arr[n];
    for (int i = 0; i < n; ++i) cin >> arr[i];

    insertionSort(arr, n);
}


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

using namespace std;

int a[7];

int main()
{
    for(int i = 1;i <= 6;i++)
        scanf("%d",&a[i]);
    sort(a + 1,a + 6);
    if(a[5] - a[1] <= a[6])
        printf("Yay!\n");
    else
        printf(":(\n");
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
#include<deque>
#include<queue>
#include<string>
#include<iostream>
#include<tuple>
#include<utility>
#include<set>
#include<queue>
#include<iomanip>
#include<iterator>
//#include<chrono>
//#include<mt19937>
using namespace std;
typedef long long int llint;
const int big=1e9+100000;
const int mod=1e9+7;
const long double pai=3.141592653589793238462643;
#define mt make_tuple
#define mp make_pair
#define fir first
#define sec second
#define pub push_back
#define res resize
#define ins insert
#define era erase
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
int main(void){
	int xi,yi,xn,yn;cin>>xi>>yi>>xn>>yn;
	int i,n;cin>>n;
	vector<pair<int,int>>fun;
	for(i=0;i<n;i++){
		int x,y;cin>>x>>y;
		if(x<min(xi,xn)){continue;}
		if(x>max(xi,xn)){continue;}
		if(y<min(yi,yn)){continue;}
		if(y>max(yi,yn)){continue;}
		fun.pub(mp(abs(xi-x),abs(yi-y)));
	}
	sort(fun.begin(),fun.end());
	//lisする
	
	set<int> lis;//set ちゃんす！
	for(i=0;i<fun.size();i++){
		int va=fun[i].sec;
		auto it=lis.insert(va).fir;
		if(next(it)!=lis.end()){lis.erase(next(it));}
	}int lisa=lis.size();
	llint anss=100*(llint)(abs(xi-xn)+abs(yi-yn));
	long double pen;
	if(lisa==min(abs(xi-xn),abs(yi-yn))+1){
		pen=pai*5;
	}else{pen=0;}
	cout<<std::setprecision(20)<<anss-(lisa*(20-pai*5))+pen<<endl;
}

Measured memory_bytes: 11248
#include <stdio.h>

int main(){
    int H, W;
    int i, j;
    while(1){
        scanf("%d %d", &H, &W);
        if(H == 0)break;

        for(i = 0; i < H; i++){
            for(j = 0; j < W; j++){
                printf("%c%s", ((i % 2 == 0 && j % 2 == 0) || (i % 2 == 1 && j % 2 == 1)) ? '#' : '.', (j == W - 1) ? "\n" : "");
            }
            if(i == H - 1)printf("\n");
        }
    }
}


Measured memory_bytes: 2120
N, K = map(int, input().split())
moves = [tuple(map(int, input().split())) for _ in range(K)] #Sを構成する区間の情報
MOD = 998244353

DP = [0 for _ in range(N)] #DP[n]で0からnまで動く動き方の数
DP[0] = 1
DP_sum = [0 for _ in range(N)] #のちのためにDPの累積和を格納するための配列を確保する
DP_sum[0] = 1

for n in range(1,N):
  # やりたいこと DP[n] = Σ_(集合Sに属するiについて) DP[n-i]
  # しかし、上記右辺の和を愚直に計算するとTLEする
  # → Sが区間10個以下の和集合であることに注目。区間和は、累積和の差を使えばO(1)で計算できる。
  for l,r in moves:
    # DP[n] += DP[n-l] + DP[n-l-1] + … + DP[n-r]の計算
    if n-l >= 0:
      DP[n] += DP_sum[n-l]
      if n-r-1 >= 0: #右端が-1に到達する場合には、以下の処理は行わない。
        DP[n] -= DP_sum[n-r-1]
    DP[n] %= MOD
    
  DP_sum[n] = (DP_sum[n-1] + DP[n]) % MOD #次以降のnのため、累積和を更新
  
print(DP[N-1] % MOD)
  


Measured memory_bytes: 100404
import sys
import numpy as np

def input():
    return sys.stdin.readline()[:-1]
  
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

H, W = map(int,input().split())
#A = [list(map(int,input().split())) for _ in range(H)]
A = np.array([list(input()) for _ in range(H)], 'U1')
eq = A == '.'

dp = np.zeros(W+1, dtype=int)
dp[1] = 1

for i in range(1,H+1):
    prev = dp.copy()
    for j in range(1,W+1):
        if eq[i-1][j-1]:
            dp[j] = prev[j] + dp[j-1]
        else:
            dp[j] = 0
    dp %= mod

print(dp[-1])

Measured memory_bytes: 25188
N = int(input())
l = list(map(int, input().split()))
n = int(len(l))

x = 0
y = l[0]
for i in range(1, n):
    z = l[i] - y
    if z >= 0:
        y = l[i]
        x += 0
    else:
        x += abs(z)

print(x)

Measured memory_bytes: 32336
//compiledef
#include <bits/stdc++.h>
#define rep(i, n) for(i=0;i<(n);i++)
#define per(i, n) for(i=(n);i>0;i--)
#define repx(i, n, x) for(i=(x);i<(n);i++)
#define xper(i, n, x) for(i=(n);i>(x);i--)
#define pback push_back

//c++def
using namespace std;
typedef long long int ll;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF =2e9;
ll matrixchainorder(int *a, int n){
	int i;
	static ll dp[150][150];
	repx(i, n, 1) dp[i][i] = 0;
	for(int l = 2;l<=n;l++){
		for(i = 1;i<=n-l+1;i++){
			int j = i+l-1;
			dp[i][j] = INF;
			for(int k = i; k<j;k++){
				ll x = dp[i][k] + dp[k+1][j] + (a[i-1]*a[k]*a[j]);
				dp[i][j] = min(dp[i][j], x);
			}
		}
	}
	return dp[1][n];	
}

int main(){
	int n;
	int i;
	cin >> n;
	int a[n+3];
	for(i=1;i<=n;i++){
		cin >> a[i-1] >> a[i];
	}
	cout <<	matrixchainorder(a, n) <<endl;
}



Measured memory_bytes: 3208
#include <iostream>

using namespace std;
typedef long long ll;
ll a[100010],inf = 1000000000000000000;
int main(){
    int i,n;
    cin >> n;
    ll ans = 1;
    for(i=0;i<n;i++){
        cin >> a[i];
        if(a[i]==0){
            cout << 0 << endl;
            return 0;
        }
    }
    for(i=0;i<n;i++){
        if(a[i]>(inf + ans - 1)/ans){
            cout << -1 << endl;
            return 0;
        }else{
            ans *= a[i];
        }
        if(ans>inf){
            cout << -1 << endl;
            return 0;
        }
        if(ans<0){
            cout << -1 << endl;
            return 0;
        }
    }
    if(ans>inf){
        cout << -1 << endl;
        return 0;
    }
    cout << ans << endl;
}

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

using namespace std;

int main() {
    int n = 0;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }

    int ans = h[0];
    for (int i = 1; i < n; ++i) {
        if (h[i] > h[i - 1]) {
            ans += h[i] - h[i - 1];
        }
    }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

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

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

int main() {
    int n;
    cin >> n;
    ll t, ans = 1;
    rep(i, n) {
        cin >> t;
        ans = lcm(t, ans);
    }
    cout << ans << endl;

    return 0;
}

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

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

    int ans = 0;
    for(int i=0; i<=d; i++){
        int d1 = i % 10;
        int d2 = i / 10;
        if(d1 >= 2 && d2 >= 2 && d1 * d2 <= m){
            //cout << d1 << " " << d2 << endl;
            ans += 1;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;

using namespace std;

const long long _MOD = 1000000007;
const long long MOD = 998244353;

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

	int a, b, c, d;
	cin >> a >> b >> c >> d;

	while (true) {
		a -= d;
		c -= b;

		if (c <= 0) {
			cout << "Yes" << "\n";
			break;
		}
		else if (a <= 0) {
			cout << "No" << "\n";
			break;
		}
	}

	return 0;
}



Measured memory_bytes: 3640
/*    Mohammed Sami Khan
                       মোহাম্মদ সামী খান
*/
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define endl "\n"
#define mp(a,b) make_pair(a,b)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long ll;
typedef unsigned long long ull;

bool sortbysecc(const pair<int,int> &a, const pair<int,int> &b){
    return (a.second < b.second);
}

int main()
{
    fastio;
    ll t, n, sum=0, x, y, p, q, r, i, j, d, f=0, char_count[26]={0};
    //char *ye="YES", *no="NO";
    map<int, int> mp;
    map<int, int> :: iterator it;
    cin>>n;
    ll a[n];
    for(i=0;i<n;i++){
        cin>>a[i];
        if(mp.count(a[i])) mp[a[i]]++;
        else mp[a[i]]=1;
    }
    for(it=mp.begin();it!=mp.end();it++){
        if((*it).second%2) f++;
    }
    cout<<f;
}


Measured memory_bytes: 9052
is = gets.chomp!.split(" ")
is.map!(&:to_i)
 
w = is[0]
h = is[1]
x = is[2]
y = is[3]
r = is[4]
if (((x+r)>w) || ((x-r)<0) || ((y+r)>h) || ((y-r)<0)) then
                puts "No"
else
                puts "Yes"
end

Measured memory_bytes: 6100
import sys
readline = sys.stdin.readline
class Tree:
    __slots__ = ['id', 'p', 'depth', 'type', 'c']
    def __init__(self):
        self.id = 0
        self.p = -1
        self.depth = -1
        self.type = "leaf"
        self.c = []
    def __str__(self):
        return f"node {self.id}: parent = {self.p}, depth = {self.depth}, {self.type}, {self.c}"
n = int(input())
li = tuple(Tree() for _ in range(n))
for _ in range(n):
    id, k, *c = map(int, readline().split())
    if k == 0:
        c = []
    else:
        li[id].type = "internal node"
    li[id].id = id
    li[id].c = c
    for j in c:
        li[j].p = id
root = 0
while True:
    a = li[root].p
    if a == -1:
        li[root].type = "root"
        li[root].depth = 0
        break
    root = a
dp = [(root, 0)]
while dp:
    id, d = dp.pop()
    d += 1
    for i in li[id].c:
        li[i].depth = d
        dp.append((i, d))
print(*li, sep="\n")



Measured memory_bytes: 34844
#include<iostream>
using namespace std;
inline int read() { char c = getchar(); int sign = 1; int x = 0; while(c > '9' || c < '0') { if(c=='-')sign = -1; c = getchar(); } while(c <= '9' && c >= '0') { x *= 10; x += c - '0'; c = getchar(); } return x * sign; }
int main()
{
    int x = read();
    x ^= 1;
  cout << x;
  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

// editorial AC
    int N, L;
    cin >> N >> L;

    vector<int> a(N);
    REP(i, N) {
        cin >> a[i];
    }

    int tmp = inf;
    for(int i = 0; i < N-1; i++) {
        if (a[i] + a[i+1] >= L) {
            tmp = i;
            break;
        }
    }

    if (tmp == inf) {
        cout << "Impossible" << endl;
        return 0;
    } else {
        cout << "Possible" << endl;
    }

    for (int i = 0; i < tmp; i++) {
        cout << i+1 << " ";
    }
    for (int i = N-2; i > tmp; i--) {
        cout << i+1 << " ";
    }

    cout << tmp+1 << endl;


// WA
    // ll N, L;
    // cin >> N >> L;
    
    // vector<pll> a;
    // ll sum = 0;
    // for(ll i; i < N; i++) {
    //     ll t;
    //     cin >> t;
    //     a.push_back(make_pair(t, i+1));
    //     sum += t;
    // }

    // vector<ll> ans; // ほどく順番

    // while(a.size() >= 2) {
    //     if (sum < L) {
    //         cout << "Impossible" << endl;
    //         return 0;
    //     }
    //     if (a[0].first < a[a.size()-1].first) {
    //         sum -= a[0].first;
    //         ans.push_back(a[0].second);
    //         a.erase(a.begin());
    //     } else {
    //         sum -= a[a.size()-1].first;
    //         ans.push_back(a[a.size()-1].second);
    //         a.erase(a.end()-1);
    //     }
    // }

    // cout << "Possible" << endl;
    // for (ll i = 0; i < N-1; i++) {
    //     cout << ans[i] << " ";
    // }

    // cout << endl;
    

    return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int n;
    cin >> n;
    LL res = 0;
    vector<int> v(n);
    for(int i = 0; i < n; ++i) {
        cin >> v[i];

    }
    sort(all(v));

    for(int i = 0; i < n; ++i) {
        for(int j = i + 1; j < n; ++j) {
            int t = v[i] + v[j];
            int pos = lower_bound(all(v), t) - v.begin();
            res += max(pos - j - 1, 0);

        }
    }
    cout << res << endl;
    return 0;
}



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

#define FOR(i, j, n) for (int i(j); i < n; ++i)
#define FORR(v, c) for (auto &v : c)
#define F first
#define S second
#define SQ(x) (x)*(x)
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define dbg(x) cerr<<#x<<" = " << (x) << endl
#define pnl(x) cout << x << '\n'
#define pns(x) cout << x << ' '
#define read(x) cin >> x
#define read2(x,y) cin >> x >> y
#define read3(x, y, z) cin >> x >> y >> z
#define read4(a, b, c, d) cin >> a >> b >> c >> d
#define readv(v) FORR(c,v) read(c)

struct Arrete { int v, c;};
struct Point {int x, y; double distance(Point other) const {return sqrt(SQ(x-other.x)+SQ(y-other.y));}};

typedef	vector<int>	vi;
typedef pair<int,int>	ii;
typedef vector<string>	vs;
typedef vector<ii>	vii;
typedef vector<Arrete>	vg;
typedef vector<long long>	vl;
typedef	long long ll;

const int MAXN = 200;

int dis[MAXN][MAXN];


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

	FOR(i,0,n) FOR(j,0,n){
		char c;
		read(c);
		dis[i][j] = c-'0';
		if (dis[i][j] ==0) dis[i][j] = 1e9;
	}

	FOR(k,0,n) FOR(i,0,n) FOR(j,0,n)
		dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
	
	bool is_bipartite(true);
	for (int i(1); i < n; ++i)
		for (int j(i+1) ; j < n; ++j)
			if (dis[i][j] == 1 and dis[0][i]%2 == dis[0][j]%2)
				is_bipartite = false;

	int ans(0);
	FOR(i,0,n) FOR(j,i+1,n) ans = max(ans, dis[i][j]);
	if (!is_bipartite)
		ans = -1;
	else
		ans++;
	pnl(ans);
}



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

int main(){
    int n, m, l;
    vector<pair<int,int>> edge[300];
    cin >> n >> m >> l;
    for(int i=0;i<m;++i){
        int a, b, c;
        cin >> a >> b >> c;
        --a; --b;
        edge[a].emplace_back(b, c);
        edge[b].emplace_back(a, c);
    }

    pair<int,int> ans[300][300];

    for(int i=0;i<n;++i){
        for(int j=0;j<n;++j) ans[i][j] = {-1, 0};
        priority_queue<pair<pair<int,int>, int>> Q;
        Q.emplace(pair<int,int>{500, l}, i);
        while(!Q.empty()){
            auto t = Q.top();
            //cerr << "i=" << i << "\t" << t.second << " " << "(" << t.first.first << ", " << t.first.second << ")\n";
            Q.pop();
            for(auto ed: edge[t.second]){
                pair<int, int> alt{t.first.first, t.first.second-ed.second};
                if(alt.second < 0) alt = {t.first.first-1, l-ed.second};
                if(alt.second < 0) continue;
                if(ans[i][ed.first].first < 0 || ans[i][ed.first] < alt){
                    ans[i][ed.first] = alt;
                    Q.emplace(alt, ed.first);
                }
            }
        }
    }

    int q;
    cin >> q;
    for(int i=0;i<q;++i){
        int s, t;
        cin >> s >> t;
        if(ans[s-1][t-1].first < 0) cout << -1 << endl;
        else cout << 500 - ans[s-1][t-1].first << endl;
    }
    
    return 0;
}

Measured memory_bytes: 2432
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N, X = MI()
    L = LI()
    now = 0
    ans = 1
    for l in L:
        now += l
        if now <= X:
            ans += 1
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
N=int(input())
A=list(map(int,input().split()))
heikin=sum(A)/N
kouho = []

if heikin in A:
    print(A.index(heikin))
else:
    for i in A:
        kouho.append(abs(heikin-i))
    ans = kouho.copy()
    ans.sort()
    print(kouho.index(ans[0]))

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n;
  cin >> n;
  vll a(n);
  rep(i, n) {
    cin >> a[i];
  }

  vll color(9);
  rep(i, n) {
    if (a[i] >= 3200) {
      a[i] = 3200;
    }
    color[a[i] / 400]++;
  }

  ll mn = 0;
  rep(i, 8) {
    if (color[i]) {
      mn++;
    }
  }

  if (mn == 0) {
    mn++;
    color[8]--;
  }

  cout << mn << " " << mn + color[8] << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
string s[1002];
int dp[1002][1002];
int main()
{
   int h,w;
   cin>>h>>w;
   for(int i = 0; i < h; i++)
   {
       cin>>s[i];
   }
   dp[0][0] = 1;
   for(int i = 0; i < h; i++)
   {
       for(int j = 0; j < w; j++)
       {
           if(s[i][j] == '#')
           {
               dp[i][j] = 0;
               continue;
           }
           if(i > 0)
           {
               dp[i][j] += dp[i - 1][j];
               dp[i][j] %= MOD;
           }
           if(j > 0)
           {
               dp[i][j] += dp[i][j - 1];
               dp[i][j] %= MOD;
           }
       }
   }
   cout<<dp[h - 1][w - 1]<<endl;
}


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

int main(){
  string s;
  cin >> s;
  vector<int> a(26);
  for(int i=0;i<s.size();i++){a.at(s.at(i)-97)++;}
  for(int i=0;i<26;i++){
    if(a.at(i)==0){
      char t=i+97;
      cout << t << endl;
      break;
    }
    else if(i==25){
      cout << "None" << endl;
    }
  }
}

Measured memory_bytes: 512
# import math
N = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]

cnt = [0,0]
for ai, bi in zip(a, b):
    if ai < bi:
        cnt[0] += (bi - ai) // 2
    elif ai > bi:
        cnt[1] += ai - bi

if cnt[0] < cnt[1]:
    print("No")
    exit()

if sum(b)-sum(a) >= cnt[0]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 4596
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int r,g,b; cin >> r >> g >> b;
    if ((g*10 + b) % 4 == 0) cout << "YES\n";
    else  cout << "NO\n";
    return 0;
}

Measured memory_bytes: 256