akhauriyash/Code-Regression huggingface dataset:
//by kcz 1552920354@qq.com
//if you find any bug in my code
//please tell me
#include<bits/stdc++.h>
using namespace std;

template <typename T> void chmin(T&x,const T &y)
{
	if(x>y)x=y;
}
template <typename T> void chmax(T &x,const T &y)
{
	if(x<y)x=y;
}
typedef long long s64;
typedef unsigned long long u64;
typedef unsigned int u32;
typedef pair<int,int> pii;
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r;i>=l;--i)
#define pb push_back
#define gc (c=getchar())
int read()
{
	char c;
	while(gc<'-');
	if(c=='-')
	{
		int x=gc-'0';
		while(gc>='0')x=x*10+c-'0';
		return -x;
	}
	int x=c-'0';
	while(gc>='0')x=x*10+c-'0';
	return x;
}
#undef gc

s64 mi(s64 x,int y,int D)
{
	s64 ans=1;
	while(y)
	{
		if(y&1)ans=ans*x%D;
		x=x*x%D;y>>=1;
	}
	return ans;
}
s64 niv(s64 x,int D)
{
	return mi(x,D-2,D);
}
const int N=250000+5;
typedef pair<s64,s64> hash_t;
const int D1=998244353,D2=1e9+7;
const hash_t w=hash_t(N+5,N+7);
hash_t operator +(const hash_t &a,const hash_t &b)
{
	return hash_t((a.first+b.first)%D1,(a.second+b.second)%D2);
}
hash_t operator -(const hash_t &a,const hash_t &b)
{
	return hash_t((a.first+D1-b.first)%D1,(a.second+D2-b.second)%D2);
}
hash_t operator /(const hash_t &a,const hash_t &b)
{
	return hash_t(a.first*niv(b.first,D1)%D1,a.second*niv(b.second,D2)%D2);
}
hash_t operator *(const hash_t &a,const hash_t &b)
{
	return hash_t(a.first*b.first%D1,a.second*b.second%D2);
}

int n;
char s[N];
hash_t k[N],b[N];

int main()
{
	//freopen("1.in","r",stdin);//freopen("1.out","w",stdout);
	cin>>n;
	scanf("%s",s+1);
	k[n+1]=hash_t(1,1);b[n+1]=hash_t(0,0);
	per(i,n,1)
	if(s[i]=='+')
	{
		k[i]=k[i+1];
		b[i]=b[i+1]+hash_t(1,1);
	}
	else
	if(s[i]=='-')
	{
		k[i]=k[i+1];
		b[i]=b[i+1]-hash_t(1,1);
	}
	else
	if(s[i]=='>')
	{
		k[i]=k[i+1]*w;
		b[i]=b[i+1]*w;
	}
	else
	{
		k[i]=k[i+1]/w;
		b[i]=b[i+1]/w;
	}

	map<hash_t,int>mp;
	s64 ans=0;
	per(i,n,1)
	{
		++mp[b[i+1]/k[i+1]];
		ans+=mp[(b[i]-b[1])/k[i]];
	}
	cout<<ans;
}



Measured memory_bytes: 39552
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n; cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	sort(a.begin(), a.end());
	int mid = n / 2;
	cout << a[mid] - a[mid - 1] << endl;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool comp(ll a, ll b)
{
    return (a < b);
}
int main(){

ll n,i,j,k;
cin>>n;
vector < vector<ll> > v;

ll dp1[n],dp2[n],dp3[n];
ll *a,*b,*c;
for(i=0;i<n;i++){
vector <ll> x;
    for(j=0;j<3;j++){
        cin>>k;
        x.push_back(k);
    }
    v.push_back(x);
}
                // for(i=0;i<n;i++){
                //     for(j=0;j<3;j++)
                //     cout<<v[i][j];
                //     cout<<endl;
                // }
for(i=0;i<n;i++){

if(i==0){
    dp1[i]=v[i][0];
    dp2[i]=v[i][1];
    dp3[i]=v[i][2];
}
else{
    dp1[i]=v[i][0]+ std::max(dp2[i-1],dp3[i-1],comp);
     dp2[i]=v[i][1]+ std::max(dp1[i-1],dp3[i-1],comp);
      dp3[i]=v[i][2]+ std::max(dp1[i-1],dp2[i-1],comp);
}
}
//cout<<dp1<<dp2<<dp3;
a=std::max_element(dp1, dp1 + n);
b=std::max_element(dp2, dp2 + n);
c=std::max_element(dp3, dp3 + n);

cout<<std :: max({*a,*b,*c},comp)<<endl;

return 0;
}



Measured memory_bytes: 8624
#include <cstdio>

const int N = 500 + 10;
const char s[] = "RGBY";

int n, m, d, ans[N][N];

int main() {
  scanf("%d%d%d", &n, &m, &d);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j)
      ans[i][j] = (((i + j) / d) & 1);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j)
      if (((i - j + N * d) / d) & 1) ans[i][j] |= 2;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) putchar(s[ans[i][j]]);
    putchar('\n');
  }
  return 0;
}


Measured memory_bytes: 1408
from fractions import gcd
MOD=10**9+7
N,*A=map(int,open(0).read().split())

def lcm(a,b):
  return a*b//gcd(a,b)
s=1
for i in A:
  s=lcm(s,i)
s%=MOD
ans=0
for i in A:
  ans+=s*pow(i,MOD-2,MOD)
  ans%=MOD
print(ans)

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

int main(){
	string s;
	cin >> s;
	int l=s.length();
	int ans1=0,ans2=0;
	for (int i=0;i<l;i++)
		if (s[i]-'0' != i%2) ans1++;
	for (int i=0;i<l;i++)
		if (s[i]-'0' != (i+1)%2) ans2++;
	if (ans1>ans2) cout << ans2;else cout << ans1;
}

Measured memory_bytes: 512
#![allow(dead_code)]
use std::io;

fn main() {
    solve_a();
}

fn solve_d() {
    let mut n = String::new();
    io::stdin().read_line(&mut n).unwrap();
    let n = n.trim().parse::<u32>().unwrap();

    let mut i = 1;
    while i <= n {
        let mut x = i;
        if (x % 3) == 0 {
            print!(" {}", i);
            i += 1;
            continue;
        }

        loop {
            if (x % 10) == 3 {
                print!(" {}", i);
                break;
            }
            x /= 10;
            if x == 0 {
                break;
            }
        }
        i += 1;
    }
    print!("\n");
}

fn solve_c() {
    loop {
        let mut x = String::new();
        io::stdin().read_line(&mut x).unwrap();

        let v: Vec<u64> = x.trim()
            .split(' ')
            .map(|s| s.parse::<u64>().unwrap())
            .collect();

        let h = v[0];
        let w = v[1];
        if h == 0 && w == 0 {
            break;
        } else {
            for i in 0..h {
                if i % 2 == 0 {
                    for j in 0..w {
                        if j % 2 == 0 {
                            print!("#");
                        } else {
                            print!(".");
                        }
                    }
                } else {
                    for j in 0..w {
                        if j % 2 == 0 {
                            print!(".");
                        } else {
                            print!("#");
                        }
                    }
                }
                print!("\n");
            }
            print!("\n");
        }
    }
}

fn solve_b() {
    loop {
        let mut x = String::new();
        io::stdin().read_line(&mut x).unwrap();

        let v: Vec<u64> = x.trim()
            .split(' ')
            .map(|s| s.parse::<u64>().unwrap())
            .collect();

        let h = v[0];
        let w = v[1];
        if h == 0 && w == 0 {
            break;
        } else {
            for i in 0..h {
                for j in 0..w {
                    if 1 <= i && i < h - 1 && 1 <= j && j < w - 1 {
                        print!(".");
                    } else {
                        print!("#");
                    }
                }
                print!("\n");
            }
            print!("\n");
        }
    }
}

fn solve_a() {
    let mut n = String::new();
    io::stdin().read_line(&mut n).unwrap();
    let n = n.trim().parse::<usize>().unwrap();

    let mut a = String::new();
    io::stdin().read_line(&mut a).unwrap();
    let mut a: Vec<_> = a.trim()
        .split(' ')
        .map(|s| s.parse::<u16>().unwrap())
        .collect();
    a.reverse();

    for i in 0..a.len() {
        if i != n - 1 {
            print!("{} ", a[i]);
        } else {
            print!("{}\n", a[i]);
        }
    }
}



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

typedef long long ll;

const int mod = 1e9 + 7;

void solve() {
    string S;
    cin >> S;
    int c[] = { 0, 0, 0 }, n = S.size();
    rep(i, n) c[S[i] - 'a']++;
    string ans = "YES";
    rep(i, 3) if (c[i] > (n + 2) / 3) ans = "NO";
    cout << ans << endl;
    return;
}

int main() {
    solve();
}

Measured memory_bytes: 512
package main

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

func main() {
	fsc := NewFastScanner()
	_ = fsc.NextInt()
	S := fsc.Next()
	x := 0

	resMax := 0
	for _, v := range S {
		if v == 'I' {
			x++
		} else {
			x--
		}
		resMax = IntMax(resMax, x)
	}
	fmt.Println(resMax)
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1024)
	return &FastScanner{r: rdr}
}
func (s *FastScanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *FastScanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *FastScanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *FastScanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *FastScanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *FastScanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

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

func Int64Max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func Float64Max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

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

func Int64Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func Float64Min(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}


Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <bits/stdc++.h>
#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

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

template<class T>bool umax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool umin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;

// gcd
int gcd(int a, int b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}

// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end

bool eight(int n){
    int divisor=0;
    for(int i=1; i<=n; i++){
        if(n%i == 0) divisor++;
    }
    return (divisor == 8);
}

int main() {
    int N;
    int answer = 0;
    cin >> N;
    for(int i = 1; i<=N; i = i+2){
        if(eight(i)) answer++;
    }

    cout << answer << endl;
    return 0;
}



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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  string s,t;
  cin>>s>>t;
  string a=t, b=s;
  reverse(ALL(a)); reverse(ALL(b));
  if(a==s && t==b){
    puts("YES");
  }else{
    puts("NO");
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
//#include <stdio.h>
using namespace std;

int main()
{
   int n;
   cin >> n;
   int a[n+1];
   //a = new int[n+1];
   a[0] = 0;
   int yen = 0;
   for (int i = 1; i <= n; i++) {
      cin >> a[i];
      yen += abs(a[i] - a[i-1]);
      if (i == n) yen += abs(a[i] - a[0]);
   }

   /*for (int i = 1; i <= n; i++) {
      cout << a[i] << endl;
   }*/

   for (int i = 1; i <= n; i++) {
      int result = 0;
      if (i != n) {
         result = yen - ( abs(a[i] - a[i-1]) + abs(a[i+1] - a[i]) ) + abs(a[i+1] - a[i-1]);
      } else {
         result = yen - ( abs(a[i] - a[i-1]) + abs(a[0] - a[i]) ) + abs(a[0] - a[i-1]);
      }
      cout << result << endl;
      //printf("%d\n", yen);
   }

   return 0;

}



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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int M,D;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>M>>D;
	
	int ret=0;
	for(i=1;i<=M;i++) {
		for(j=1;j<=D;j++) {
			int a=j/10;
			int b=j%10;
			if(a>=2 && b>=2 && a*b==i) ret++;
		}
	}
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

using namespace std;

int popcount(int x) {
    int count = 0;
    while (x > 0) {
        count += x % 2;
        x /= 2;
    }
    return count;
}
int main() {
    assert(popcount(1) == 1);
    assert(popcount(0) == 0);
    assert(popcount(7) == 3);
    vector<int> cache(200000 + 10);
    for (int i = 1; i < (int) cache.size(); ++i) {
        cache[i] = 1 + cache[i % popcount(i)];
    }
    assert(cache[0] == 0);
    assert(cache[1] == 1);
    assert(cache[7] == 2);
    assert(cache[2] == 1);
    int n;
    cin >> n;
    string x;
    cin >> x;
    int bc = 0;
    for (char c: x) {
        if (c == '1')
            ++bc;
    }
    if (bc == 0) {
        for (int i = 0; i < n; ++i) {
            cout << "1\n";
        }
    } else {
        vector<int> s;
        vector<vector<int>> ds;
        for (int m = bc - 1; m <= bc + 1; m += 2) {
            vector<int> d(n);
            if (m == 0) {
                ds.push_back(d);
                s.push_back(0);
                continue;
            }
            d[0] = 1 % m;
            for (int i = 1; i < n; ++i)
                d[i] = (2 * d[i - 1]) % m;
            reverse(d.begin(), d.end());
            int sum = 0;
            for (int i = 0; i < n; ++i) {
                if (x[i] == '1') {
                    sum = (sum + d[i]) % m;
                }
            }
            s.push_back(sum);
            ds.push_back(d);
        }
        for (int i = 0; i < n; ++i) {
            int m;
            int sum;
            if (x[i] == '0') {
                m = bc + 1;
                sum = s[1] + ds[1][i];
            } else {
                m = bc - 1;
                sum = s[0] - ds[0][i];
            }
            if (m == 0) {
                cout << "0\n";
                continue;
            } else {
                sum = ((sum % m) + m) % m;
                cout << cache[sum] + 1 << "\n";
            }
        }
    }
    return 0;
}


Measured memory_bytes: 6568
#include <iostream>

using namespace std;

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

  int x,y,z;
  bool flag = false; // flag for existence of answer.

  if(1000*N <= Y && Y <= 10000*N){
    x = Y/10000; // Number of 10000 bill
    while(x >= 0){
      y = N - x; // Number of 5000 bill
      while(y >= 0){
	z = N-x-y;
	int Sum = 10000*x+5000*y+1000*z;
	if(Sum == Y) flag = true;
	if(flag == true) break;
	y--;
      }
      if(flag == true) break;
      x--;
    }
  }

  if(flag == false){
    x = -1;
    y = -1;
    z = -1;
  }
  
  cout << x << " " << y << " " << z << "\n";
  
  return 0;
}


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

using namespace std;

int n;

void solve(){
    int i,j;
    string str;
    cin >> n;
    vector<int> a(n),b(n);
    for(i = 0;i < n;i++){
        cin >> a[i];
        b[i] = a[i];
    }
    sort(a.begin(),a.end());
    for(i = 0;i < n;i++){
        if(b[i] == a.back()) cout << a[a.size()-2] << endl;
        else cout << a.back() << endl;
    }
}

int main(){
    solve();
}


Measured memory_bytes: 3200
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define int long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB emplace_back
#define PF emplace_front
#define FILL(a,b) memset(a,b,sizeof(a))
#define lwb lower_bound
#define upb upper_bound
using namespace std;
int la,lb,a[100],b[100];
const int mod=1e9+7;
int dp[100][2][2];
int dfs(int p,bool f1,bool f2){
	if(p==0)RE 1;
	if(dp[p][f1][f2]!=-1)RE dp[p][f1][f2];
	int l=f1?a[p]:0,r=f2?b[p]:1,re=0;
	FOR(i,l,r){
		FOR(j,l,i)re=(re+dfs(p-1,f1&&j==l,f2&&i==r))%mod;
	}
	RE dp[p][f1][f2]=re;
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int x,y;
	cin>>x>>y;
	while(x)a[++la]=x&1,x=x/2;
	while(y)b[++lb]=y&1,y=y/2;
	int ans=0;
	FILL(dp,-1);
	FOR(i,la,lb)ans=(ans+dfs(i-1,i==la,i==lb))%mod;
	cout<<ans<<'\n';
	RE 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>

using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define pb(a) push_back(a)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

typedef long long unsigned int ll;
typedef pair<ll, ll> P;

int main(){
	int n,k;
	cin >>n>>k;
	long double p=0;
	REP(i,n+1){
		if(i==0) continue;
		if(i<k){
			p += pow(2,-ceil(log2((double)k/(double)i)));
		}else{
			p += 1;
		}
	}
	p /= n;
	cout <<setprecision(14)<<p <<endl;
}


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

using namespace std;
// #define int long long
mt19937 rnd(time(0));
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

// #define _GLIBCXX_DEBUG
#define f first
#define s second
#define pb push_back
#define pii pair<int, int> 
#define vi vector<int>
#define int ll

const int mod = 1e9 + 7;


void solve(){
    // cout << (1LL << 62) << endl;
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    int suf[n][60];
    memset(suf, 0, sizeof(suf));
    for (signed i = n - 1; i >= 0; --i) {
        for (signed j = 0; j < 60; ++j) {
            if ((1LL << j) & a[i])
                suf[i][j] = 1;
        }
        if (i != n - 1) {
            for (signed j = 0; j < 60; ++j) {
                suf[i][j] += suf[i + 1][j];
            }
        }
    }
    int ans = 0;
    for (signed i = 0; i < n - 1; ++i) {
        for (signed j = 0; j < 60; ++j) {
            if (a[i] & (1LL << j)) {
                ans += (1LL << j) % mod * (n - i - 1 - suf[i + 1][j]) % mod;
            } else {
                ans += (1LL << j) % mod * suf[i + 1][j] % mod;
            }
            ans %= mod;
        }
    }
    cout << ans << endl;
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int t = 1;
    while(t--){
        solve();
    }
    
    return 0;
}


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

using namespace std;
static const int NG = 0;
static const int OK = 1;
static const int UNKNOWN = 2;

class list
{
public:
	int power, motor, cable;
	list(int x, int y, int z)
	{
		power = x;
		motor = y;
		cable = z;
	}
};

void solve()
{
	int a, b, c, N;
	while(cin >> a >> b >> c, a || b || c)
	{
		cin >> N;
		vector<int> item(a + b + c + 1);
		for(int i = 0; i < item.size(); ++i)
		{
			item[i] = UNKNOWN;
		}
		vector<list> lists;
		for(int i = 0; i < N; ++i)
		{
			int d, e, f, g;
			cin >> d >> e >> f >> g;
			if(g == 1)
			{
				item[d] = OK;
				item[e] = OK;
				item[f] = OK;
			}
			else
			{
				lists.push_back(list(d, e, f));
			}
		}	
		for(int i = 0; i < lists.size(); ++i)
		{
			if(item[lists[i].power] == OK && item[lists[i].motor] == OK && item[lists[i].cable] == UNKNOWN)
			{
				item[lists[i].cable] = NG;
			}

			if(item[lists[i].power] == OK && item[lists[i].cable] == OK && item[lists[i].motor] == UNKNOWN)
			{
				item[lists[i].motor] = NG;
			}

			if(item[lists[i].cable] == OK && item[lists[i].motor] == OK && item[lists[i].power] == UNKNOWN)
			{
				item[lists[i].power] = NG;
			}
		}
		for(int i = 1; i < item.size(); ++i)
		{
			cout << item[i] << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1220
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;
#define sz(x) (int)(x).size()
const int N = 200010;
vector<int> adj[N], adj2[N];
vector<vector<int>> cmp, res;
int id[N], cnt, n, vis[N], ans[N];

bool by_id (int u, int v) { return id[u] < id[v]; }

void dfs (int u) {
	cmp.back().push_back(u);
	vis[u] = 1;
	for (int v : adj[u]) if (!vis[v]) dfs(v);
}

void dfs2 (int u) {
	vis[u] = 1;
	id[u] = cnt;
	for (int v : adj2[u]) if (!vis[v]) dfs2(v);
}

int main() {
	int k, l, x, y;
	scanf("%d%d%d", &n, &k, &l);
	while (k--) {
		scanf("%d%d", &x, &y);
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	while (l--) {
		scanf("%d%d", &x, &y);
		adj2[x].push_back(y);
		adj2[y].push_back(x);
	}
	memset(vis, 0, sizeof vis);
	for (int i = 1; i <= n; i++) if (!vis[i]) {
		cmp.push_back(vector<int>(0));
		dfs(i);
	}
	cnt = 0;
	memset(vis, 0, sizeof vis);
	for (int i = 1; i <= n; i++) if (!vis[i]) {
		dfs2(i);
		cnt++;
	}
	for (vector<int>& v : cmp) {
		sort(v.begin(), v.end(), by_id);
		vector<int> t = {v[0]};
		for (int i = 1; i < sz(v); i++) {
			if (id[v[i - 1]] == id[v[i]]) t.push_back(v[i]);
			else { res.push_back(t); t.clear(); t.push_back(v[i]); }
		}
		res.push_back(t);
	}
	for (const vector<int>& v : res) {
		for (int x : v) ans[x] = sz(v);
	}
	for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
	printf("\n");
}



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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int a,b,c,k; cin>>a>>b>>c>>k;
	while(a>=b)b*=2,--k;
	while(b>=c)c*=2,--k;
	cout<<(k<0?"No"s:"Yes"s)<<"\n"s;
}


Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.IO;
using System.Text;
using System.Diagnostics;

class Program
{
    static void Main()
    {
        long[] xy = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

        long tmp = xy[0];
        long ans = 1;

        while(tmp * 2 <= xy[1])
        {
            tmp *= 2;
            ans++;
        }

        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13268
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <array>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define all(c) begin(c), end(c)
#define dump(c) cerr << "> " << #c << " = " << (c) << endl
#define tr(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define mp make_pair
#define pb push_back
#define repi(i, n) for (i = 0; i <= (n); i++)

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

const int INF = 1 << 29;
const double EPS = 1e-10;


int main() {
  bool flg = false;
  for (int N; cin >> N, N != 0; ) {
    if (flg) puts("");
    flg = true;

    int num[4];
    rep(i, 4) cin >> num[i];

    int ans[4] = {};
    int best = INF;
    static int coin[] = {10, 50, 100, 500};
    int idx[4] = {};
    repi(idx[3], num[3]) repi(idx[2], num[2]) repi(idx[1], num[1]) repi(idx[0], num[0]) {
      int ret = 0;
      rep(i, 4) ret += idx[i] * coin[i];
      ret -= N;
      if (ret < 0) continue;

      int tmp[4];
      int t = 0;
      for (int i = 3; i >= 0; i--) {
        tmp[i] = num[i] - idx[i] + ret / coin[i];
        t += tmp[i];
        ret %= coin[i];
      }

      if (best > t) {
        best = t;
        rep(i, 4) ans[i] = idx[i];
      }
    }

    rep(i, 4) if (ans[i]) cout << coin[i] << ' ' << ans[i] << endl;
  }
  
  
  return 0;
}

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



def main():
    # Failed to predict input format
    N, K = map(int, input().split())
    #print(N, K)
    s = set()
    for k in range(K):
        d = int(input())
        for Ai in map(int, input().split()):
            s.add(Ai)
    print(N - len(s))

if __name__ == '__main__':
    main()


Measured memory_bytes: 9168
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
bool right(int x,int y) {
	if ((x == 1 || x == 4 || x == 7) && y != 1 && y != 4 && y != 7)return true;
	else if ((x == 8 || x == 2) && (y == 3 || y == 6 || y == 9))return true;
	return false;
}
bool left(int x,int y) {
	if ((x == 3 || x == 6 || x == 9) && y != 3 && y != 6 && y != 9)return true;
	else if ((x == 8 || x == 2) && (y == 1 || y == 4 || y == 7))return true;
	return false;
}
int main() {
	string s;
	while (cin >> s, s != "#") {
		int len = s.length();
		int dp[100000][2];
		rep(i, 100000) {
			rep(j, 2) {
				dp[i][j] = (int)MOD;
			}
		}
		dp[0][0] = 0;
		dp[0][1] = 0;
		Rep(i, 1, len) {
			dp[i][0] = dp[i - 1][0] + 1;
			dp[i][1] = dp[i - 1][1] + 1;
			if (!right(s[i - 1] - '0', s[i] - '0')) {
				dp[i][0] = dp[i - 1][1];
			}
			if (!left(s[i - 1] - '0', s[i] - '0')) {
				dp[i][1] = dp[i - 1][0];
			}
		}
		cout << min(dp[len - 1][0], dp[len - 1][1]) << endl;
	}
	return 0;
}


Measured memory_bytes: 4048
////////////////////////////////////////////////////////////////////
// This source code is for Visual Studio
////////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <stack>
#include <functional>
#include <iomanip>
#include <string>
#include <cstring>
#include <deque>
#include <math.h>
#include <assert.h>

#define	numberof(a)	(sizeof(a) / sizeof(a[0]))
#define	INF32		INT32_MAX
#define	INF64		INT64_MAX
#define Rep(i,n) for(int i = 0; i < (n); ++i )

using namespace std;

typedef vector< vector<int> > MAT;
typedef pair<int, int> PINT;
typedef long long ll;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int32_t s32;
typedef int64_t s64;

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

bool pair_comp(const pair<ll, ll> & p1, const pair<ll, ll> & p2)
{
	// sort(item.begin(), item.end(), throw_comp)のように使う
	if (p1.first != p2.first) {
		return p1.first < p2.first;
	}
	else {
		return p1.second > p2.second;
	}
}

// main function
int main()
{
	string S = "", T = "";
	string ans = "Yes";
	vector<ll> vec0('z' - 'a' + 1, 0);
	vector<ll> vec1('z' - 'a' + 1, 0);

	cin >> S >> T;

	sort(S.begin(), S.end());
	sort(T.begin(), T.end());

	Rep(i, S.length()) {
		vec0[S[i] - 'a']++;
		vec1[T[i] - 'a']++;
	}
	sort(vec0.begin(), vec0.end());
	sort(vec1.begin(), vec1.end());

	Rep(i, 'z' - 'a' + 1) {
		if (vec0[i] != vec1[i]) {
			ans = "No";
			break;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 776
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define inf LLONG_MAX>>2
#define MAX 1000000
#define mod 1000000007
#define pb push_back
#define f(i,a,n,x) for ((i)=(a);(i)<(n);(i)+=(x))
#define fd(i,a,n,x) for ((i)=(a);(i)>=(n);(i)-=(x))
#define fi first
#define se second
#define mk make_pair
#define pi pair
#define vt vector
using namespace std;
void read(vt<ll> &a,ll n){ll i,temp;f(i,0,n,1){cin>>temp;a.pb(temp);}}
void solve(){
    ll n,x;
    vt<ll> a;
    cin>>n;
    read(a,n);
    sort(a.begin(),a.end());
    x=unique(a.begin(),a.end())-a.begin();
    cout<<(x-(x&1?0:1))<<endl;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--)
        solve();
    return 0;
}

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

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

		　　var inputArray = retreiveLongArray();
			var inputCount = 3;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			var H = (int)inputArray[0];
			var W = (int)inputArray[1];
			var D = (int)inputArray[2];

			var zahhyou = new Dictionary<int, Tuple<int, int>>();

			for (int i = 0; i < H; i++) {
				var inp = retreiveLongArray();
				for (int j = 0; j < W; j++) {
					var input = (int)inp[j];
					zahhyou.Add(input, new Tuple<int, int>(i, j));
				}
			}
			var Q = retreiveLongArray()[0];
			var Questions = new List<Tuple<int, int>>();

			for (int i = 0; i < Q; i++) {
				var inp = retreiveLongArray();
				Questions.Add(new Tuple<int, int>((int)inp[0], (int)inp[1]));
			}
			var ruiseki = new Dictionary<int, int>();
			for (int i = 1; i <= D; i++) {
				ruiseki.Add(i, 0);
				var k = i+D;
				var previous = zahhyou[i];
				while (k <= H*W) {
					var current = zahhyou[k];
					var distanse = Math.Abs(current.Item1 - previous.Item1) + Math.Abs(current.Item2 - previous.Item2);
					ruiseki.Add(k, ruiseki[k - D] + distanse);
					previous = current;
					k += D;
				}

			}
			foreach (var question in Questions) {
				Console.WriteLine(ruiseki[question.Item2] - ruiseki[question.Item1]);
			}



		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}


Measured memory_bytes: 59180
N, *A = map(int, open(0).read().split())
P = [-e for e in set(A)]
P.sort()
P.append(1)
MP = {e: i for i, e in enumerate(P)}
N += 1

data = [0]*(N+1)
def get(k):
    r = 0
    while k:
        r += data[k]
        k -= k & -k
    return r
def add(k, x):
    while k <= N:
        data[k] += x
        k += k & -k
N0 = 2**(N-1).bit_length()
def lower_bound(x):
    w = i = 0
    k = N0
    while k:
        if i+k <= N and w + data[i+k] <= x:
            w += data[i+k]
            i += k
        k >>= 1
    return i+1

for a in A:
    j = MP[-a]
    i = lower_bound(get(j+1))
    if i != N+2:
        add(i, -1)
    add(j+1, 1)
print(get(N))

Measured memory_bytes: 28188
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
  int n, m, i, j;
  while(cin >> n >> m) {
    int vote[n] = {};
    int cost[n] = {};
    int req;
    
    for(i = 0; i < n; i++) {
      cin >> cost[i];
    }
    for(i = 0; i < m; i++) {
      cin >> req;
      for(j = 0; j < n; j++) {
	if(req >= cost[j]) {
	  vote[j]++;
	  break;
	}
      }
    }
    int ans = 0;
    for(i = 0; i < n; i++) {
      if(vote[ans] < vote[i]) {
	ans = i;
      }
    }
    cout << ans + 1 << endl;
  }
}

      
    
  

Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
constexpr int N = 2e5 + 100;

int fa[N], son_num[N];

int Find(int x) {
    if (fa[x] == x) return fa[x];
    else return fa[x] = Find(fa[x]);
}

void Union(int x, int y) {
    x = Find(x);
    y = Find(y);
    if (x != y) {
        fa[y] = x;
        son_num[x] += son_num[y];
    }
}

void Init() {
    for (int i = 0; i < N; i++) {
        fa[i] = i;
        son_num[i] = 1;
    }
}

int main() {
    Init();
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        Union(x, y);
    }
    cout << *max_element(son_num, son_num + N) << "\n";
}


Measured memory_bytes: 5180
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#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() {
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  int sum = 0;
  rep(i,N) {
    cin >> A[i];
    sum += A[i];
  }
  sort(A.begin(), A.end(), greater<int>());
  if (A[M-1] * 4 * M < sum) cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}

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

typedef long long ll;

#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18


int main() {
    int N,x; cin >> N >> x;
    vector<int> X(N+1);
    X[0] = x;
    vector<int> D(N);
    FOR(i,1,N+1){
        cin >> X[i];
    }
    sort(ALL(X));
    REP(i,N){
        D[i] = X[i+1] - X[i];
    }

    int ans = D[0];

    REP(i,N-1){
        ans = min(ans, __gcd(D[i], D[i+1]));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3984
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<map>
#include<queue>
#include<set>

using namespace std;
typedef pair<int,int> PII;
typedef long long ll;

int main(){
	vector<string> pattern(8);
  for(int i=0;i<8;i++)
		cin>>pattern[i];
	cout<<90<<endl;
	for(int y=0;y<8;y++){
		for(int x=0;x<8;x++){
			cout<<pattern[7-x][y];
		}
		cout<<endl;
	}
	cout<<180<<endl;
	for(int y=0;y<8;y++){
		for(int x=0;x<8;x++){
			cout<<pattern[7-y][7-x];
		}
		cout<<endl;
	}
	cout<<270<<endl;
	for(int y=0;y<8;y++){
		for(int x=0;x<8;x++){
			cout<<pattern[x][7-y];
		}
		cout<<endl;
	}
  return 0;
}

Measured memory_bytes: 0
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,d,w,h,i,j,k,l,m,n,x,y,z;
	ll		ans = 0;
	string	s;
	cin >> a >> b;
	if (b%a==0) ans = a + b;
	else ans = b - a;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3600
#!/usr/bin/env ruby

n = gets.chomp.to_i
ary = gets.chomp.split(' ').map(&:to_i)

right_gcd = [ary.first]
ary.slice(1..-1).each { |num| right_gcd << right_gcd.last.gcd(num) }

left_gcd = [ary.last]
ary.reverse.slice(1..-1).each { |num| left_gcd << left_gcd.last.gcd(num) }
left_gcd = left_gcd.reverse

ans = 0

0.step(n - 1) do |i|
  case i
  when 0 
    left_gcd[i + 1]
  when n - 1 
    right_gcd[i - 1]
  else 0...(n - 1)
    right_gcd[i - 1].gcd(left_gcd[i + 1])
  end.tap { |gcd| ans = (gcd > ans ? gcd : ans) }
end

puts ans


Measured memory_bytes: 12940
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>

using namespace std;

int main(void)
{
	long long count = 0;
	char S[3],T[3];

	cin >> S;

	cin >> T;

	for (int i = 0; i < 3; i++)
	{
		if (S[i] == T[i])
		{
			count++;
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>
#include <cstring>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i < n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl
typedef long long ll;

typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;

using namespace std;

int main() 
{   
    int n, m;
    cin >> n >> m;
    int ans = (m * 1900 + (n-m) * 100)*(pow(2, m));
    cout << ans << endl;
    return 0;
}
    



Measured memory_bytes: 512
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

    if (X == 7 || X == 5 || X == 3)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
constexpr ll mod = 1e9 + 7;
#define endl '\n'
 
int main() {
  ios::sync_with_stdio(0); cin.tie(0);
 
  ll H,W,Ch,Cw,Dh,Dw;
  cin >> H >> W >> Ch >> Cw >> Dh >> Dw;
  --Ch,--Cw,--Dh,--Dw;
  if (Ch==Dh && Cw==Dw) {
    cout << 0 << endl;
    return 0;
  }


  vector<vector<int>> M(H, vector<int>(W));
  for (auto& row : M) for (auto& _a : row) {
      char c;
      cin >> c;
      _a = c != '#';
    }

  queue<array<ll,2>> mq,rq;
  mq.push({Ch,Cw});
  vector<vector<bool>> visited(H, vector<bool>(W));
  visited[Ch][Cw] = true;
  int dist = 0;

  const vector<pair<int,int>> dirs{{0,1}, {0,-1}, {1,0}, {-1,0}};


  while (true) {
    
    while (mq.size()) {
      for (int iq = mq.size()-1; iq >= 0; --iq) {
        auto [y,x] = mq.front(); mq.pop();
        rq.push({y,x});
        for (const auto& [dy,dx] : dirs) {
          int ty = y + dy;
          int tx = x + dx;
          if (ty >= 0 && ty < H && tx >= 0 && tx < W && !visited[ty][tx] && M[y][x]) {
            if (ty == Dh && tx == Dw) {
              cout << dist << endl;
              return 0;
            }
            visited[ty][tx] = true;
            mq.push({ty,tx});
          }
        }
      }
    }
    ++dist;
    if (rq.empty()) break;


    while (rq.size()) {
      for (int iq = rq.size()-1; iq >= 0; --iq) {
        auto [y,x] = rq.front(); rq.pop();
        for (int dy = -2; dy <= 2; ++dy) {
          for (int dx = -2; dx <= 2; ++dx) {
            int ty = y + dy;
            int tx = x + dx;
            if (ty >= 0 && ty < H && tx >= 0 && tx < W && !visited[ty][tx] && M[y][x]) {
              if (ty == Dh && tx == Dw) {
                cout << dist << endl;
                return 0;
              }
              visited[ty][tx] = true;
              mq.push({ty,tx});
            }
          }
        }

      }
    }

  }
  cout << -1 << endl;
}


Measured memory_bytes: 8108
#pragma GCC optimize("O3")

#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/rope"

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define f first
#define s second

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

struct custom_hash 
{
    static uint64_t splitmix64(uint64_t x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const 
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
int n;
vector<ll> a, p;
vector<vector<ll>> dp;
ll sum(int i, int j)
{
    return p[j] - p[i];
}
int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    a.assign(n, 0);
    F0R(i, n) cin >> a[i];
    dp.assign(n + 1, vector<ll>(n + 1, INT64_MAX - 1e13));
    F0R(i, n) dp[i][i + 1] = 0;
    p.assign(n + 1, 0);
    FOR(i, 1, n + 1) p[i] = p[i - 1] + a[i - 1];
    // for(auto i : p) cout << i << " ";
    FOR(k, 1, n + 1)
    {
        FOR(j, 0, n)
        {
            FOR(i, 1, n + 1)
            {
                if(i < k && j + k  <= n) 
                {
                    // if(j == n - 3 && k == 3)
                    // {
                    //     cout << sum(j, k) << " " << i << "\n";
                    //     cout << dp[j][j + i] << " " << dp[j + i][j + k] << "\n\n";
                    //         cout << dp[n - 2][n];
                    // }
                    dp[j][j + k] = min(dp[j][j + k], dp[j][j + i] + dp[j + i][j + k] + sum(j, j + k));
                }
            }
        }
    }
    // cout << "\n";
    // for(auto i : dp)
    // {
    //     for(auto j : i)
    //     {
    //         if(j == dp[0][0]) cout << "INF\t";
    //         else cout << j << "\t";
    //     }
    //     cout << "\n";
    // }
    cout << dp[0][n];
    return 0;
}

Measured memory_bytes: 1536
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <numeric>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  int n;
  cin >> n;
  ll a[n], b[n];
  REP(i,n) cin >> a[i];
  REP(i,n) cin >> b[i];
  ll sum_a = accumulate(a,a+n,0LL);
  ll sum_b = accumulate(b,b+n,0LL);
  ll cnt = sum_b-sum_a; //操作回数
  ll add1=0, add2 = 0;
  REP(i,n){
    add1 += max(a[i]-b[i],0LL);
    add2 += max((b[i]-a[i]+1)/2,0LL);
  }
  if(max(add1,add2)<=cnt) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

int main() {
  char c[9];
  cin >> c[0]>> c[1]>> c[2]>> c[3]>> c[4]>> c[5]>> c[6]>> c[7]>> c[8];
  cout << c[0] << c[4] << c[8];
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;

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

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

    vector<lli> X(N);

    X[0] = 0;
    for (int i = 0; i < N; ++i) {
        X[0] += A[i];
        if (i % 2 != 0) {
            X[0] -= 2 * A[i];
        }
    }

    for (int i = 1; i < N; ++i) {
        X[i] = 2 * A[i - 1] - X[i - 1];
    }

    for (int i = 0; i < N; ++i) {
        cout << X[i] << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 2944
import java.io.*;
import java.util.StringTokenizer;
import java.util.Arrays;

class Main {
	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String buf;

		try {
			while (!(buf = br.readLine()).equals("0 0")) {
				StringTokenizer st = new StringTokenizer(buf);
				int m = Integer.parseInt(st.nextToken());
				int n = Integer.parseInt(st.nextToken());
				int player_list[] = new int[m];
				int now_player = 0;
				Arrays.fill(player_list,0);
				int c = m;
				for (int i=1;i<=n;i++) {
					String ans = br.readLine();
					if (c>1) {
						if (i%15==0) {
							if (!ans.equals("FizzBuzz")) {
								player_list[now_player] = 1;
								c--;
							}
						} else if (i%3==0) {
							if (!ans.equals("Fizz")) {
								player_list[now_player] = 1;
								c--;
							}
						} else if (i%5==0) {
							if (!ans.equals("Buzz")) {
								player_list[now_player] = 1;
								c--;
							}
						} else {
							if (checkStringNumber(ans)) {
								if (Integer.parseInt(ans)!=i) {
									player_list[now_player] = 1;
									c--;
								}
							} else {
								player_list[now_player] = 1;
								c--;
							}
						}

						now_player = (now_player+1)%m;
						while (player_list[now_player]==1) {
							now_player = (now_player+1)%m;
						}
					}
				}
				int cc = 0;
				for (int j=0;j<m;j++) {
					if (cc==0&&player_list[j]==0) {
						System.out.print(j+1);
						cc = 1;
					} else if (player_list[j]==0) {
						System.out.print(" "+(j+1));
					}
				}
				System.out.println();
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static boolean checkStringNumber(String s) {
		try {
			Integer.parseInt(s);
		} catch (NumberFormatException e) {
			return false;
		}
		return true;
	}
}

Measured memory_bytes: 41912
import java.util.Scanner;

class Main{
	static final long MOD = 1000000007;

	static int H, W, K;
	static long[][] dp = new long[110][10];
	static int ans = 0;
	static long n = 0;


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		n = sc.nextLong();
		dfs(0);
		System.out.println(ans);



	}

	static void dfs(long x){
		if(n < x){
			return;
		}

		if (check(x)){
			ans++;
		}

			dfs(10*x + 3);
			dfs(10*x + 5);
			dfs(10*x + 7);
		

	}

	static boolean check(long x){

		String num = String.valueOf(x);
		

		if(num.contains("3") &&num.contains("5") &&num.contains("7")){
			return true;
		}else{
			return false;
		}



	}





}







class Pair implements Comparable{
	int from;		//p
	int end;		//y
	int num;
	int bango;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}


Measured memory_bytes: 24780
A = []
b = []

# 送信用の入力処理
n, m = map(int, input().split())
for i in range(n):
    A.append([int(i) for i in input().split()])
for i in range(m):
    b.append(int(input()))

# # テスト用にファイルから入力する処理
# with open('input_itp1_6_d_1.txt', mode='r', encoding='utf8') as f:
#     n, m = map(int, next(f).split())
#     try:
#         for i in range(n):
#                 A.append([int(i) for i in next(f).split()])
#         for i in range(m):
#             b.append(int(next(f)))
#     except StopIteration:
#         raise ValueError('入力データがおかしい')

for row in range(len(A)):
    tmp = 0
    for col in range(len(A[row])):
        tmp += A[row][col] * b[col]
    print(tmp)


Measured memory_bytes: 6008