akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int main() {
  int n;
  scan(n);
  double sum = 0;
  rep (i, n) {
    double x;
    scan(x);
    vector<char> symbol(3);
    scan(symbol);
    if (symbol[0] == 'J') {
      sum += x;
    } else {
      sum += x * 380000;
    }
  }
  print(sum);

  return 0;
}


Measured memory_bytes: 888
#include <math.h>

#include <algorithm>
#include <bitset>
#include <iostream>
#include <queue>
#include <sstream>
#include <vector>

using namespace std;

const int INF = 10000000;
typedef pair<int, int> P;

int main() {
  string S, T;
  cin >> S;
  cin >> T;
  if (T.length() - S.length() != 1) {
    cout << "No" << endl;
  }
  T.erase(T.length() - 1, 1);
  if (T == S) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 3568
// D - Wide Flip

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

string S;

bool is_ok(int K) {
	int N = S.size();
	int l = N - K;
	int r = K - 1;

	bool ok = true;
	for (int i=l; i<r; i++) {
		if (S[i] != S[i+1]) {
			ok = false;
			break;
		}
	}

	return ok;
}

ll find_max_ok(ll lower, ll upper) {
	if (!is_ok(lower)) return -1; // 存在しない

	ll ok = lower;
	ll ng = upper;

	while(ng - ok > 1) {
		ll trying = (ng + ok) / 2;

		if (is_ok(trying)) {
			ok = trying;
		} else {
			ng = trying;
		}
	}

	return ok;
}

int main() {
	cin >> S;

	ll K = find_max_ok(1, S.size() + 1);

	cout << K << endl;

	return 0;
}

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

#define debug(x) cout <<"DEBUG"<<" "<<#x<<":"<<x<<'\n'

//↓0-indexか1-indexでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-index昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-index昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-index降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-index降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
using i64 = int_fast64_t;
template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

/* 円周率は M_PI を使おうね */
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;

/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(15);

    int m; cin >> m;
    ll digitsum = 0;
    ll p = 0;
    rep(i,m) {
        ll d, c;
        cin >> d >> c;
        digitsum += d*c;
        p += c;
    }
    cout << (digitsum-1)/9 + p -1 << '\n';
}

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

Measured memory_bytes: 1724
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);++i)
#define rep(i,n) REP(i, 0, n)
typedef long long int i64;
typedef pair<int, int> pint;
int imos[100010];
int main() {
    int N; scanf("%d", &N);
    int a, b;
    memset(imos, 0, sizeof(imos));
    rep(i, N) {
        scanf("%d%d", &a, &b);
        imos[a]++; imos[b + 1]--;
    }
    rep(i, N + 2) imos[i + 1] += imos[i];
    rep(i, N + 2) {
        if(imos[i] < i - 1) imos[i] = 0;
        if(imos[i] > i - 1) imos[i] = i - 1;
    }
    int ans = 0;
    rep(i, N + 2) ans = max(ans, imos[i]);
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 1588
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    vector<int> x;
    vector<int> y;
    for(int i=0;i<n;i++){
        int v;
        cin>>v;
        x.push_back(v);
        y.push_back(v);
    }
    sort(y.begin(),y.end());
    int b=n/2;
    for(int i=0;i<n;i++){
        if(x[i]<y[b])cout<<y[b]<<endl;
        else cout<<y[b-1]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3948
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**8)

n=int(input())
G=[[] for i in range(n)]
for i in range(n-1):
    u,v,w=map(int,input().split())
    u-=1
    v-=1
    G[u].append([v,w])
    G[v].append([u,w])

A=[0]*n
def dfs(s,p=-1):
    for g in G[s]:
        if g[0]!=p:
            A[g[0]]=A[s]+g[1]
            dfs(g[0],s)

dfs(0)
for a in A:
    if a%2==0:
        print(0)
    else:
        print(1)

Measured memory_bytes: 158512
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
using namespace std;
typedef pair <int, int> pii;
int main()
{

	//int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	long long a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, l = 0, ans = 0;
	//cout << LONG_MAX << endl;
	//string s, t;
	//long long n, A[1000000000];
	long long n, m;
	//int   y[100001], z[100001], x[10001] = {};
	//pii y[100001];
	//pair<int, float> pii[100001];
	int x[100];
	//for (e = -100;e < 100;e++)
	{


		for (a = 0; a < 100; a++)
		{
			x[a] = -1;
		}
		//string s[2001];
		cin >> a;
		//a = e;
		//if (a % 2 <= 1&& a % 2 >= 1)
		//{
		//	x[0] = 1;
		//}
		//if ((a - 1) % 4 <= 2 && a % 4 >= 1)
		//{
		//	x[1] = 1;
		//}
		//if ((a - 1) % 8 <= 4 && a % 8 >= 1)
		//{
		//	x[2] = 1;
		//}
		//if ((a - 5) % 16 <= 8 && a % 16 >= 1)
		//{
		//	x[3] = 1;
		//}
		//if ((a - 5) % 32 <= 16 && a % 16 >= 1)
		//{

		//}
		if (a >= 0)
		{


			if (a % 2 <= 1 && a % 2 >= 1)
			{
				x[1] = 1;
			}
			else
			{
				x[1] = 0;
			}
			c = 2;
			d = 1;
			for (b = 2; b <= 40; b++)
			{
				c *= 2;
				if ((a - d) % c <= (c / 2) && (a - d) % c >= 1 && (a - d) >= 0)
				{
					x[b] = 1;
				}
				else
				{
					x[b] = 0;
				}
				b++;
				c *= 2;
				if ((a - d) % c <= (c / 2) && (a - d) % c >= 1 && (a - d) >= 0)
				{
					x[b] = 1;
				}
				else
				{
					x[b] = 0;
				}
				d += (c / 2);
			}
			f = 0;
			for (b = 40; b != 1; b--)
			{
				if (x[b] == 1 && f == 0)
				{
					f = 1;
				}
				if (x[b] != -1 && f == 1)
				{
					cout << x[b];

				}

			}
			cout << x[1] << endl;
		}
		else
		{
			/*if (a % 2 <= 1 && a % 2 >= 1)
			{
				x[1] = 1;
			}
			else
			{
				x[1] = 0;
			}*/
			a *= -1;
			c = 1;
			d = 0;
			for (b = 1; b <= 40; b++)
			{
				c *= 2;

				if ((a - d) % c <= (c / 2) && (a - d) % c >= 1 && (a - d) >= 0)
				{
					x[b] = 1;
				}
				else
				{
					x[b] = 0;
				}
				b++;
				c *= 2;
				if ((a - d) % c <= (c / 2) && (a - d) % c >= 1 && (a - d) >= 0)
				{
					x[b] = 1;
				}
				else
				{
					x[b] = 0;
				}
				d += (c / 2);
				if (d == 0)
				{
					d = 2;
				}
			}
			f = 0;
			for (b = 40; b != 0; b--)
			{
				if (x[b] == 1 && f == 0)
				{
					f = 1;
				}
				if (x[b] != -1 && f == 1)
				{
					cout << x[b];

				}

			}
			cout << endl;
		}

	}
	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;

	//cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
	int a;
	cin >> a;
	string s;
	cin >> s;

	if (a >= 3200) {
		cout << s << endl;
	} else {
		cout << "red" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b,c,d,i;cin >> n >> a >> b >> c >> d;
  a--;b--;c--;d--;
  char m[n+1];m[n] = '#';
  for(i=0;i<n;i++) cin >> m[i];
  if(c==d){
    cout << "No\n";return 0;
  }
  for(i=a;i<c;i++){
    if(m[i] == '#' && m[i+1] == '#'){
      cout << "No\n";return 0;
    }
  }
  for(i=b;i<d;i++){
    if(m[i] == '#' && m[i+1] == '#'){
      cout << "No\n";return 0;
    }
  }
  if(c<d){
    cout << "Yes\n";return 0;
  }
  for(i=b;i<min(c,d+1);i++){
    if(m[i-1]=='.' && m[i]=='.' && m[i+1]=='.'){
      cout << "Yes\n";return 0;
    }
  }
  cout << "No\n";return 0;
}

Measured memory_bytes: 3788
#include <iostream>
#include <string>

using namespace std;

class Dice{
    public:
        int dice[6];
        int buf1, buf2, buf3;
        void north(){
            buf1 = dice[0];
            buf2 = dice[1];
            buf3 = dice[5];
            dice[5] = dice[4];
            dice[0] = buf2;
            dice[4] = buf1;
            dice[1] = buf3;
        }
        void south(){
            buf1 = dice[0];
            buf2 = dice[1];
            buf3 = dice[5];
            dice[0] = dice[4];
            dice[1] = buf1;
            dice[5] = buf2;
            dice[4] = buf3;
        }
        void west(){
            buf1 = dice[0];
            buf2 = dice[2];
            buf3 = dice[5];
            dice[0] = buf2;
            dice[2] = buf3;
            dice[5] = dice[3];
            dice[3] = buf1;
        }
        void east(){
            buf1 = dice[0];
            buf2 = dice[2];
            buf3 = dice[5];
            dice[2] = buf1;
            dice[5] = buf2;
            dice[0] = dice[3];
            dice[3] = buf3;
        }
};



int main(){

    string D;
    string::iterator itr;

    Dice d;

    for(int i=0; i<6; i++){
        cin >> d.dice[i];
    }
    cin >>D;
    char dir;

    for(itr = D.begin(); itr != D.end(); itr++){
       dir = *itr;
       if(dir == 'N') d.north();
       if(dir == 'S') d.south();
       if(dir == 'W') d.west();
       if(dir == 'E') d.east();
    } 

    cout << d.dice[0] << endl;

    return 0;
}

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

int main(){
    int N,K;
    cin>>N>>K;
    int ans=1;
    for(int i = 0; i < N; i++){
        if(ans*2>ans+K){
            for(int j = i; j < N;j++){
                ans += K;
            }
            break;
        }else{
            ans *= 2;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
n=int(input())
l=[]
j=0
for i in range(n):
  a=list(map(int,input().split()))
  l.append(a)
for k in range(n-2):
  if l[k][0]==l[k][1] and l[k+1][0]==l[k+1][1] and l[k+2][0]==l[k+2][1]:
    j+=1
    break
if j==1:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 9192
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;

int n,m,suma,sumb;
int data[21];

void dfs(int a, int b,int cnt){
  suma+=a;
  sumb+=b;
  if(cnt==n){ 
    m=min(m,abs(suma-sumb));
  }else{
    dfs(data[cnt],0,cnt+1);
    dfs(0,data[cnt],cnt+1);
  }
  suma-=a;
  sumb-=b;
}
int main(){
  while(1){
    scanf("%d",&n);
    if(!n) break;
    m=10000000,suma=sumb=0;
    for(int i=0;i<n;i++)
      scanf("%d",&data[i]);
    dfs(0,0,0);
    printf("%d\n",m);
  }
  return 0;
}

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

long int N;
int num = 0;

bool in_string(string s, string digit){
    for (int i = 0; i < s.length(); i++){
        if (s[i] == digit[0]){
            return true;
        }
    }
    return false;
}

void dfs(string s){
    if (in_string(s, "3") && in_string(s, "5") && in_string(s, "7")){
        if (stol(s) <= N){
            num += 1;
        }
    }
    if (s.length() < 9){
        dfs(s + "3");
        dfs(s + "5");
        dfs(s + "7");
    }
}

int main(){
    cin >> N;
    dfs("");
    cout << num << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
char s[500005];
int a[500005],n,b[500005];
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	int sum=0;
	for(int i=1;i<=n;i++) a[i]=s[n-i+1]-'0';
	for(int i=1;i<=n;i++){
		b[i]+=a[i]*9;
		if(b[i]>9){
			b[i+1]+=b[i]/10;
			b[i]%=10;
		}
	}
	if(b[n+1]) n++;
	for(int i=1;i<=n;i++) a[i]=b[i],sum+=a[i];
	for(int i=1;i<=n;i++){
		a[1]+=9;sum+=9;
		for(int p=1;p<=n;p++){
			if(a[p]<=9) break;
			a[p]-=10;a[p+1]++;
			sum-=9;
		}
		if(sum<=9*i) return printf("%d",i),0;
	}
	return 0;
}

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

int main(){
	int H,W;
	cin >> H >> W;
	vector<string> S(H);
	for(auto &i:S)cin >> i;
	int a[H][W];
	int ans[H][W];
	
	for(int i=0;i<H;i++)for(int j=0;j<W;j++)ans[i][j]=0;
	
	for(int i=0;i<H;i++){
		int count=0;
		for(int j=0;j<W;j++){
			if(S[i][j]=='.')count++;
			else count=0;
			a[i][j]=count;
		}
	}
	for(int i=0;i<H;i++){
		int tmp=0;
		for(int j=W-1;j>=0;j--){
			if(a[i][j]>0){
				if(tmp==0)tmp=a[i][j];
			}
			else tmp=0;
			ans[i][j]+=tmp;
		}
	}
	
	for(int i=0;i<H;i++)for(int j=0;j<W;j++)a[i][j]=0;
	
	for(int j=0;j<W;j++){
		int count=0;
		for(int i=0;i<H;i++){
			if(S[i][j]=='.')count++;
			else count=0;
			a[i][j]=count;
		}
	}
	for(int j=0;j<W;j++){
		int tmp=0;
		for(int i=H-1;i>=0;i--){
			if(a[i][j]>0){
				if(tmp==0)tmp=a[i][j];
			}
			else tmp=0;
			ans[i][j]+=tmp;
		}
	}
	
	int an=0;
	for(int i=0;i<H;i++)for(int j=0;j<W;j++)an=max(an,ans[i][j]-1);
	cout << an << endl;
	return 0;
}

Measured memory_bytes: 35584
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 10000000
)

var (
	sc = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
)

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

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

func nextFloat() float64 {
	sc.Scan()
	f, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func main() {
	n := nextInt()
	a := make([]int, n)
	diffs := make(map[int][]int)
	for i := 0; i < n; i++ {
		a[i] = nextInt()
		diffs[a[i]-i] = append(diffs[a[i]-i], i)
	}

	ans := 0
	for i := 0; i < n; i++ {
		diff := -a[i] - i
		ans += len(diffs[diff])
	}
	fmt.Println(ans)
}


Measured memory_bytes: 25324
// 2015/05/19 Tazoe

#include <iostream>
using namespace std;

int main()
{
	bool is_hamming[1000001];	// ハミング数かどうかのテーブル

	for(int i=0; i<1000001; i++){
		is_hamming[i] = false;
	}

	for(int i=1; i<1000001; i*=2){
		for(int j=i; j<1000001; j*=3){
			for(int k=j; k<1000001; k*=5){
				is_hamming[k] = true;
			}
		}
	}

	int n_hamming[1000001];		// ハミング数の個数のテーブル

	int cnt = 0;
	for(int i=0; i<1000001; i++){
		if(is_hamming[i]){
			cnt++;
		}
		n_hamming[i] = cnt;
	}

	while(true){
		int m;
		cin >> m;

		if(m==0)
			break;

		int n;
		cin >> n;

		cout << n_hamming[n]-n_hamming[m-1] << endl;
	}

	return 0;
}

Measured memory_bytes: 6044
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<numeric>
#include<iomanip>
#include<utility>
#include<cstdlib>
#include<typeinfo>
#include<stack>
#include<cassert>
#include<functional>
#define int long long int
#define double long double
using namespace std;
#define INT_MAX 1000000005
#define INF 1000000005
const int MAX_N = 1 << 17;
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;

signed main()
{
int x,y;
std::cin >> x >> y;
int sum = 0;
int now = x;
while(now <= y){
    sum++;
    now = now * 2;
}
std::cout << sum << std::endl;
return 0;
}

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

int main(){
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    for(auto &&i : a)
        std::cin >> i;
    
    int count = 0;
    for(int i=0; i<n; i++){
        int min_index = i;
        for(int j=i; j<n; j++){
            if(a.at(j) < a.at(min_index)){
                min_index = j;
            }
        }
        if(i != min_index){
            std::swap(a.at(min_index), a.at(i));
            count += 1;
        }
    }
    for(int i=0; i<n; i++){
        std::cout << a.at(i) << ((i == n - 1) ? "\n" : " ");
    }
    std::cout << count << std::endl;
}   


Measured memory_bytes: 3088
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        String [][] s = new String[H+2][W+2];
        int [][] t = new int[H+2][W+2];

        for(int i = 1 ; i <= H  ; i++){
            String[] str = sc.next().split("");
            for(int j = 1 ; j <= W ; j++){
                s[i][j] = str[j-1];
                t[i][j] = 0;
            }
        }

        for(int i = 1 ; i <= H  ; i++){
            for(int j = 1 ; j <= W ; j++){
                if(s[i][j].equals("#")){
                    t[i-1][j-1]++;
                    t[i-1][j]  ++;
                    t[i-1][j+1]++;
                    t[i][j-1]  ++;
                    t[i][j+1]  ++;
                    t[i+1][j-1]++;
                    t[i+1][j]  ++;
                    t[i+1][j+1]++;
                }
//                System.out.println(t[i][j]);
            }
        }

        for(int i = 1 ; i <= H  ; i++){
            for(int j = 1 ; j <= W ; j++){
                if(s[i][j].equals(".")){
                    s[i][j] = String.valueOf(t[i][j]);
                }
                System.out.print(s[i][j]);
            }
            System.out.println("");
        }
    }
}

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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
const ll mod = 1000000007;

int main() {
    string s; cin >> s;
    int n = s.size();

    int l = 0;
    int to[n]; rep(i,n) to[i] = -1;
    for (int i = 1; i < n; i++) {
        if (s[i] != 'R') {
            for (int j = l; j < i; j++) {
                to[j] = i-1;
            }
            l = i+1;
        }
    }
    int r = n-1;
    for (int i = n-2; i >= 0; i--) {
        if (s[i] != 'L') {
            for (int j = r; j > i; j--) {
                to[j] = i+1;
            }
            r = i-1;
        }
    }
  
    int ans[n]; rep(i,n) ans[i] = 0;
    rep(i,n) {
        if (abs(i-to[i])%2) {
            if (s[i] == 'R') ans[to[i]+1]++;
            else ans[to[i]-1]++;
        }
        else ans[to[i]]++;
    }
    rep(i,n-1) printf("%d ", ans[i]);
    printf("%d\n",ans[n-1]);

    return 0;
}


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

int d; //日数
const int z=26; //コンテスト数
vector<int> c(z); //コンテストiが開催されないペナルティ
vector<vector<int>> s; //i日目にコンテストjが開催された時の満足度

int score(vector<int> &t)
{
    int sum = 0;
    vector<int> last(z, -1); //コンテストが最後に開催された日
    for (int i = 0; i < t.size(); i++)
    {
        sum += s[i][t[i]];
        last[t[i]] = i;
        for (int j = 0; j < z; j++)
        {
            sum -= c[j] * ((i+1) - (last[j]+1));
        }
        
    }
    return sum;
}

void Main()
{
    cin >> d;
    s = vector<vector<int>>(d, vector<int>(z));
    for (int i = 0; i < z; i++)
    {
        cin >> c[i];
    }
    for (int i = 0; i < d; i++)
    {
        for (int j = 0; j < z; j++)
        {
            cin >> s[i][j];
        }
    }

    vector<int> t;
    for (int i = 0; i < d; i++)
    {
        int tmp;
        cin >> tmp;
        t.push_back(tmp-1);
        cout << score(t) << endl;
    }
}

int main(int argc, char **argv)
{
    Main();
    return 0;
}


Measured memory_bytes: 3680
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
  public static void main(String args[]) {

    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int A[] = new int[N];
    Map<Integer, Integer> map = new HashMap<>();

    for (int i = 0; i < N; i++) {
      A[i] = sc.nextInt();
      map.put(A[i], i + 1);
    }

    for (int i = 1; i <= N; i++) {
      System.out.print(map.get(i) + " ");
    }

    sc.close();
  }
}

Measured memory_bytes: 72556
fun main(args: Array<String>) {
    val (N, D) = listOfInt()
    val w = D + D + 1
    val ans = (N + w - 1) / w
    println(ans)
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }


Measured memory_bytes: 37876
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#define  ms(a,b) memset(a,b,sizeof(a))

using namespace std;
typedef long long LL;
const LL INF=1e17L;
const int inf=0x3f3f3f3f;
const int maxn=1e5+5;
const int Mod=1e9+7;

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if((a*100+b*10+c)%4==0)
        cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt(), y = sc.nextInt();
		int[] a = new int[] {-1,0,2,0,1,0,1,0,0,1,0,1,0};
		System.out.println(a[x]==a[y]?"Yes":"No");
		sc.close();
	}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rp(i,n) for (int i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define all_acc(x) (x).begin(), (x).end(), 0LL
#define int long long
#define absSort(v) sort(a.begin(), a.end(), [](int i, int j) -> bool { return abs(i) < abs(j); });
using namespace std;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
using ll = long long;
double pi=3.14159265359;

//出力するよ
void output(vector<int> s){
    int n = s.size();
    for (int i = 0; i < n; i++){
        //if (i != 0)
        //    cout << " ";
        cout << s[i]<<endl;
    }
    //cout << endl;
}

void output3(vector<int> s){
    int n = s.size();
    for (int i = 0; i < n; i++){
        if (i != 0)
            cout << " ";
        cout << s[i];//<<endl;
    }
    cout << endl;
}
int MOD = pow(10, 9) + 7;

//出力形式を返す関数
string out(vector<int> v){
    string ans="[";
    for(int i=0;i<v.size();i++){
        if(i!=0) ans+=", ";
        ans+=to_string(v[i]);
    }
    ans+="]";
    return ans;
}

signed main() {
	int n; cin>>n;
    vector<vector<int>> child(n);
    vector<int> parent(n,-1);
    vector<int> depth(n,0);
    vector<string> status(n,"internal node");

    int root=0;

    for(int i=0;i<n;i++){
        int id,k; cin>>id>>k;
        for(int c=0;c<k;c++){
            int ci;cin>>ci;
            //子どもをリストに格納する
            child[id].push_back(ci);
            parent[ci]=id;
        }
        //葉の場合
        if(k==0){
            status[id]="leaf";
        }
    }


    for(int i=0;i<n;i++){
        if(parent[i]==-1){ 
            status[i]="root";
            root=i;
        }
    }
    //cout<<root<<endl;

    queue<int> search;
    search.push(root);
    //深さを求めるよ
    while(!search.empty()){
        //cout<<"おっぱい"<<endl;
        int node=search.front();
        search.pop();
        for(auto c:child[node]){
            depth[c]=depth[node]+1;
            search.push(c);
        }
    }

    for(int i=0;i<n;i++){
        if(parent[i]==-1) status[i]="root";
        string ans="node ";
        ans+=to_string(i)+": parent = "+to_string(parent[i])+", depth = ";
        ans+=to_string(depth[i])+", "+status[i]+", "+out(child[i]);
        cout<<ans<<endl;
    }

}


Measured memory_bytes: 16544
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define second sec
#define first fir
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



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

	int n, k;
	cin >> n >> k;
	int p[n];
	rep(i, n) cin >> p[i];
	double memo[1010];
	memo[0] = 0;
	REP(i, 1, 1010) {
		memo[i] = memo[i-1] + i;
	}

	double imos[n] = {};
	imos[0] = memo[p[0]] / p[0];
	REP(i, 1, n) {
		imos[i] = imos[i-1] + memo[p[i]] / p[i];
	}

	double ans = 0;
	rep(i, n - k + 1) {
		chmax(ans, imos[i + k - 1] - imos[i-1]);
	}
	fcout << ans << endl;
	return 0;
}

Measured memory_bytes: 3968
import java.util.*;
class Main{
    Scanner sc=new Scanner(System.in);
    void main(){
	int n=sc.nextInt();
	for(int i=1;i<=n;i++){
	    boolean e=false;
	    if(i%3==0)e=true;
	    for(int j=1;j<100000;j*=10)if(i/j%10==3)e=true;
	    if(e)System.out.print(" "+i);
	}
	System.out.println();
    }
    public static void main(String[]ag){
	new Main().main();
    }
}

Measured memory_bytes: 28772
#include<bits/stdc++.h>
using namespace std;
#define ll long long
inline ll read() {
    ll x=0,f=1; char ch=getchar();
    for(;ch<'0'||ch>'9';ch=getchar())
        if(ch=='-')f=-f;
    for(;ch>='0'&&ch<='9';ch=getchar())
        x=x*10+ch-'0';
    return x*f;
}
inline void chkmin( int &a,int b ) { if(a>b) a=b; }
inline void chkmax( int &a,int b ) { if(a<b) a=b; }
#define _ read()
#define ln endl
int main() {
	int a=_,b=_;
	cout<<max(max(a+b,a-b),a*b);
}		

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

main()
{
    int a, b;
    while (cin >> a >> b){
        if (a == 0 && b == 0)return 0;
        for (int i = 0; i < a; i++){
            for (int j = 0; j < b; j++)printf("#");
            puts("");
        }
        puts("");
    }
}



Measured memory_bytes: 3072
var input = '';
var readable = process.stdin;
readable.resume();
readable.setEncoding( 'utf-8' );
readable.on( 'data', function( chunk ) {
  input += chunk;
});

readable.on( 'end', function() {
  var data = input.split( '\n' );
  var rc = data[0].split( ' ' )
  var r = parseInt( rc[0] );
  var c = parseInt( rc[1] );
  var t = Array( c+1 );
  for( var i=0; i<c+1; i++ ) { t[i] = 0; }
  for( var i=1; i<r+1; i++ ) {
    var n = data[i].split( ' ' ).map( Number );
    var s = 0;
    for( var j=0; j<c; j++ ) {
      s += n[j];
      t[j] += n[j];
      t[c] += n[j];
    }
    n.push( s );
    console.log( n.join( ' ' ) );
  }
  console.log( t.join( ' ' ) );
});

Measured memory_bytes: 10312
"use strict"
function main(arg) {
    var text = arg.trim().split("\n").map(Number).sort()
    for (var i = 1; i <= 3; i++) {
        if (!includeValue(i, text)) {
            console.log(i)
            break
        }
    }
}

function includeValue(x, arr) {
    for (var i = 0; i < arr.length; i++) {
        if (arr[i] === x) {
            return true
        }
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main() {
  string S;
  cin >> S;
  int N = S.size()-1;
  
  long long ans=0;
  for(int i=0;i<(1<<N);i++){
    bitset<9> B(i);
    int cnt = 0;
    ans += S[N]-'0';
    for(int j=0;j<N;j++){
      if(B.test(j)) cnt = 0;
      else ++cnt;
      ans += (S[N-j-1]-'0') * pow(10,cnt);
    }
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
module Main where

import Data.Functor
import Data.List

main :: IO ()
main = do
  { [n] <- getInts
  ; as  <- getInts
  ; putStr . unlines . map (unwords . map show) . insertSorting $ as
  }

insertSorting :: Ord a => [a] -> [[a]]
insertSorting = unfoldr phi . (,) []
  where
    phi z@(xs,[])   = Nothing
    phi z@(xs,y:ys) = Just (zs ++ ys, (zs,ys))
      where zs = insert y xs

getInts :: IO [Int]
getInts = map read . words <$> getLine

Measured memory_bytes: 4080
#include <bits/stdc++.h>
#define int long long
using namespace std;
  
using Graph = vector<vector<int>>;
Graph G(100005);
vector<int> as(100005, 0);
vector<int> dist(100005, -1);
queue<int> que;

void bfs() {
  dist[0] = 0;
  que.push(0);

  while (!que.empty()) {
    int v = que.front(); // キューから先頭頂点を取り出す
    que.pop();

    // v から辿れる頂点をすべて調べる
    for (int nv : G[v]) {
        if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

        // 新たな白色頂点 nv について距離情報を更新してキューに追加する
        dist[nv] = dist[v] + 1;
        as[nv] = v + 1;
        que.push(nv);
      }
  }
}


signed main() {
  int N, M;
  cin >> N >> M;
  int A[M], B[M];
  for (int i = 0; i < M; i++) {
    cin >> A[i] >> B[i];
    A[i]--; B[i]--;
    G[A[i]].push_back(B[i]);
    G[B[i]].push_back(A[i]);
  }
  bfs();
//  for (int v = 0; v < N; ++v) cout << v << ": " << dist[v] << endl;
  cout << "Yes" << endl;
  for (int i = 1; i < N; i++) cout << as[i] << " " << endl;
}


Measured memory_bytes: 16736
#include <stdio.h>

int main(){
    int a;
    char c[10000];
    scanf("%d",&a);
    getchar();
    
    scanf("%[^\n]", c);
    
    for (int i=0; c[i]!='\0'; i++){
        if(c[i]>='A' && c[i]<='Z'){
            c[i]+=a;
            if(c[i]>90){
                c[i]-=26;
            }
            printf("%c",c[i]);
        }
    }
return 0;
}

Measured memory_bytes: 1664
// Last Change: 10/19/2019 21:54:41.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

int main() {
  ll N;
  cin >> N;
  vector<ll> L(N);
  for (auto &&e : L) {
    cin >> e;
  }
  sort(L.begin(), L.end());

  ll ans = 0;
  {
    ll a, b, aMb, aPb;
    for (auto i = L.begin(); i != L.end(); ++i) {
      for (auto j = i + 1; j != L.end(); ++j) {
        a = *i;
        b = *j;
        // cout << "a: " << a << " b: " << b << endl;
        aMb = b - a;
        aPb = a + b;
        auto left = upper_bound(i + 1, j, aMb);
        auto right = lower_bound(i + 1, j, aPb);
        auto res = distance(left, right);

        /*
        if (aMb < a and a < aPb) {
          --res;
        }
        if (aMb < b and b < aPb) {
          --res;
        }*/
        res = max(0LL, static_cast<ll>(res));
        // cout << ' ' << res << endl;
        ans += res;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
# Card Game

cardAmount = int(input())

taro = 0
hanako = 0
for i in range(cardAmount):
    cards = input().rstrip().split()
    sortedCards = sorted(cards)
    if cards[0] == cards[1]:
        taro += 1
        hanako += 1
    elif cards == sortedCards:
        hanako += 3
    else:
        taro += 3
print(taro, hanako)



Measured memory_bytes: 5600
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
    #include <filesystem>
    namespace fs = std::filesystem;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

ll a,b,c,d;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path __p = __FILE__;
        fs::path __input, __output;
        __input = __output = __p.parent_path();
        __input += string("/input/") + string(__p.stem()) + string(".txt");
        __output += string("/output/") + string(__p.stem()) + string(".txt");
        freopen(__input.c_str(), "r", stdin);
        freopen(__output.c_str(), "w", stdout);
    #endif
    cin >> a >> b>> c >> d;
}

ll __gcd(ll x, ll y){
    if(x==0) return y;
    return __gcd(y%x,x);
}

ll __lcm(ll x, ll y){
    return x*y/__gcd(x,y);
}

ll count_multi(ll x){
    ll ret = 0;
    ret += x/c;
    ret += x/d;
    ret -= x/__lcm(c,d);
    return x-ret;
}

int solve(){
    cout << (count_multi(b)-count_multi(a-1)) << endl;
    return 0;
}   

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


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



int main()
{
string S,T;
cin>>S>>T;
int answer=0;
for(int i=0;i<S.size();i++)
{
if(S[i]==T[i]){answer++;}
}
if(answer==S.size()&&T.size()==S.size()+1){cout<<"Yes"<<endl;}
else{cout<<"No"<<endl;}

}


Measured memory_bytes: 3596
from fractions import gcd
from functools import reduce

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(numbers):
    return reduce(lcm_base, numbers, 1)

N = int(input())
num = []
for i in range(N):
  num.append(int(input()))

ans = lcm(num)

print(ans)


  

Measured memory_bytes: 5076
package main

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

const (
	defaultBufferSize = 1024
	maxBufferSize     = 1e6
	Mod               = 1e9 + 7
)

var sc = bufio.NewScanner(os.Stdin)

// sc.Buffer(make([]byte, defaultBufferSize), maxBufferSize)

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

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

func readInt64() int64 {
	sc.Scan()
	i, err := strconv.ParseInt(sc.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return int64(i)
}

func readfloat64() float64 {
	sc.Scan()
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

func abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}

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

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

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func ModComb(n, k int) int {
	if k == 0 {
		return 1
	}
	x, y := n, k
	for i := 1; i < k; i++ {
		x = x * (n - i) % Mod
		y = y * (k - i) % Mod
	}
	inv := ModInv(y)
	return x * inv % Mod
}

func ModFact(x int) int {
	fact := 1
	for i := 1; i <= x; i++ {
		fact = fact * i % Mod
	}
	return fact
}

func ModInv(x int) int {
	return ModPow(x, Mod-2)
}

func ModPow(a, n int) int {
	res := 1
	for n > 0 {
		if n%2 != 0 {
			res = res * a % Mod
		}
		a = a * a % Mod
		n /= 2
	}
	return res
}

func pow(a, n int) int {
	if n == 0 {
		return 1
	}

	ans := 0
	if n%2 == 0 {
		ans = pow(a*a, n/2)
	} else {
		ans = a * pow(a*a, (n-1)/2)
	}
	return ans
}

func intSliceReverse(slice []int) []int {
	for i, j := 0, len(slice)-1; i < j; i, j = i+1, j-1 {
		slice[i], slice[j] = slice[j], slice[i]
	}
	return slice
}

func stringReverse(str string) string {
	runes := []rune(str)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func primeFactorization(x int) map[int]int {
	result := make(map[int]int, 0)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			result[i]++
			x /= i
		}
	}
	if x != 1 {
		result[x]++
	}
	return result
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	for i := 2; i*i <= x; i++ {
		if i == x {
			continue
		}
		if x%i == 0 {
			return false
		}
	}
	return true
}

func main() {
	sc.Split(bufio.ScanWords)
	x := readInt()

	if 400 <= x && x <= 599 {
		fmt.Println(8)
	} else if 600 <= x && x <= 799 {
		fmt.Println(7)
	} else if 800 <= x && x <= 999 {
		fmt.Println(6)
	} else if 1000 <= x && x <= 1199 {
		fmt.Println(5)
	} else if 1200 <= x && x <= 1399 {
		fmt.Println(4)
	} else if 1400 <= x && x <= 1599 {
		fmt.Println(3)
	} else if 1600 <= x && x <= 1799 {
		fmt.Println(2)
	} else if 1800 <= x && x <= 1999 {
		fmt.Println(1)
	}
}


Measured memory_bytes: 1776
package main

import (
    "fmt"
)

func main() {
    var n, m int
    fmt.Scan(&n, &m)
    ls := make([]int, m)
    for i := 0; i < m; i++ {
        var k int
        fmt.Scan(&k)
        var sb int
        for j := 0; j < k; j++ {
            var s uint
            fmt.Scan(&s)
            s--
            sb |= 1 << s
        }
        ls[i] = sb
    }
    ps := make([]int, m)
    for i := 0; i < m; i++ {
        var p int
        fmt.Scan(&p)
        ps[i] = p
    }
    var sc int
    for i := 0; i < 1<<uint(n); i++ {
        var ng bool
        for j := 0; j < m; j++ {
            so := ls[j] & i
            var cnt int
            for l := 0; l < n; l++ {
                if so&(1<<uint(l)) > 0 {
                    cnt++
                }
            }
            if cnt%2 != ps[j] {
                ng = true
            }
        }
        if !ng {
            sc++
        }
    }
    fmt.Println(sc)
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main() {
  int n, sum, temp;
  cin >> n;
  while (n != 0) {
    sum = 0;
    for (int i = 0; i < n/4; i++) {
      cin >> temp;
      sum += temp;
    }
    cout << sum << endl;
    cin >> n;
  }
}



Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;

int main() {
	double a, b, x;
	cin >> a >> b >> x;
	cout << fixed << setprecision(9);
	double d = atan(2 * x / b / b / a);
	if (d < atan(a / b)) {
		cout << 90 - d * 180 / acos(-1) << endl;
	} else {
		cout << atan(2 * (a * a * b - x) / a / a / a) * 180 / acos(-1) << endl;
	}
	return 0;
}


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

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <map>
#include <queue>
#define mp make_pair
#define pb push_back
#define p push
#define FOR(a,c) for(int a = 0;a<c;a++)
#define FORR(el,vecc) for(auto& el:vecc)
#define ll long long
#define abs(x) (x<0 ? (-x) : x)
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d %d",&a,&b)
#define getIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a,b) scanf("%lld %lld",&a,&b)
#define getLLL(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).begin(),(c).end(),greater<int>()
#define fi first
#define se second
#define PI 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a,b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a,b) printf("%lld%lld",a,b);
#define SIZE 1000000007

using namespace std;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef vector<long long> vl;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long,long long>> vpl;
typedef vector<vector<pair<long long,long long>>> vvpl;
typedef vector<bool> vb;
typedef pair<int,int> pii;
typedef pair <ll,ll> pll;
const  double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MX = 200005;
/*ios_base::sync_with_stdio(false);cin.tie(0);*/

ll gcd(ll n,ll m){
    if (n==0)return m;
    return gcd(m%n,n) ;
}

long long fast_exp(long long n,long long k){
    if(k == 0)
        return 1;
    if(k==1)
        return n;

    long long temp = fast_exp(n,k>>1);

    if((k&1)==1)
        return (n*temp*temp)%SIZE;
    return (temp*temp)%SIZE;

}

int main() {
    ll n;
    cin >>n;
    vi vec(n);
    for (int i = 0; i <n ; ++i) {
        cin>>vec[i];
    }
    int hei = vec[0];
    for (int j = 1; j <n ; ++j) {

        if(vec[j] >= vec[j-1] +1){
            vec[j]--;

        }
        if(hei > vec[j]){
            cout << "No";
            return 0;
        }

        hei = vec[j];
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int main()
{
    int A,B,K,count=0,c,i;

    scanf("%d%d%d",&A,&B,&K);
    for(i=A;count<K;i--)
    {
        if(A%i==0 && B%i==0)
        {
            count++;
            c = i;
        }
    }
    printf("%d",c);
    return 0;

}


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

template<class T> inline bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
struct Unionfind {
    vector<int> par;
    vector<int> sizes;

    Unionfind(int n) : par(n), sizes(n, 1) {
        for(int i = 0; i < n; ++i) par[i] = i;
    }

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

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        if(sizes[x] < sizes[y]) swap(x, y);
        par[ry] = rx;
        sizes[rx] += sizes[ry];
    }

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

    int size(int x) {
        return sizes[root(x)];
    }

};

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

    int n;
    cin >> n;

    int ans = 0;
    for(int a = 1; a < n; ++a) {
        ans += (n-1) / a;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>

int main(){
  int i,flag=1,t,cnt=0,n,A[100];
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  while(flag){
    flag=0;
    for(i=n-1;i>0;i--){
      if(A[i]<A[i-1]){
	cnt++;
	t=A[i];
	A[i]=A[i-1];
	A[i-1]=t;
	flag=1;
      }
    }
  }
  for(i=0;i<n-1;i++)printf("%d ",A[i]);
  printf("%d\n%d\n",A[i],cnt);
  return 0;
}



Measured memory_bytes: 2104
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<tuple>
#include<cmath>


#define MOD 1000000007
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back

typedef long long ll;

using namespace std;

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

struct UnionFind{
    vector<ll> par;
    vector<ll> rank;

    UnionFind(ll N): par(N,-1), rank(N, 1){
    }

    ll root(ll x){
        if(par[x] < 0) return x;
        else{
            par[x] = root(par[x]);
            return par[x];
        }
    }

    void unite(ll x, ll y){
        x = root(x);
        y = root(y);
        if(x == y) return;
        if(rank[x] < rank[y]) swap(x,y);
        if(rank[x] == rank[y])rank[x]++;
        par[x] += par[y];
        par[y] = x;
        return;
    }

    bool is_same(ll x, ll y){
        return root(x) == root(y);
    }

    ll size(ll x){
        return -1 * par[root(x)];
    }
};


int main(){
    ll N,M,K;
    cin>>N>>M>>K;
    UnionFind tree(N);

    vector<vector<ll>> block(N),fri(N);
    rep(i,0,M){
        ll a,b;
        cin>>a>>b;
        tree.unite(a-1,b-1);
        fri[a-1].PB(b-1);
        fri[b-1].PB(a-1);
    }
    rep(i,0,K){
        ll a,b;
        cin>>a>>b;
        block[a-1].PB(b-1);
        block[b-1].PB(a-1);
    }
    rep(i,0,N){
        ll sum=tree.size(i)-1;
        rep(j,0,block[i].size()){
            if(tree.is_same(i,block[i][j])){
                sum--;
            }
        }
        rep(j,0,fri[i].size()){
            if(tree.is_same(i,fri[i][j])){
                sum--;
            }
        }
        cout<<sum<<" ";
    }
    return 0;
}

Measured memory_bytes: 14452
import java.util.Scanner;


public class Main{

	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
        int a = sc.nextInt();
        
        int result = (n % 500);
        if(result <= a) {
        	System.out.println("Yes");
        }else {
        	System.out.println("No");
        }
	}
}

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

int main(){
  unsigned long int N, A, B, fatigueA, sumFatigue=0;
  unsigned int dist1, dist2;

  cin >> N >> A >> B;
  cin >> dist1;
  
  for(int i=1; i<N; i++){
    cin >> dist2;
    fatigueA = (dist2 - dist1) * A;
    if(fatigueA < B) sumFatigue += fatigueA;
    else sumFatigue += B;
    dist1=dist2;    
  }

  cout << sumFatigue << endl;

  return 0;
}


Measured memory_bytes: 384