akhauriyash/Code-Regression huggingface dataset:
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char **argv)
{
    int n;
    scanf("%d", &n);
    int qty[101] = {0};
    for (int i = 0; i < n; i++) {
        int d;
        scanf("%d", &d);
        qty[d]++;
    }
    int h = 0;
    for (int i = 1; i <= 100; i++) {
        if (qty[i] != 0) h++;
    }
    printf("%d\n", h);
    return EXIT_SUCCESS;
}


Measured memory_bytes: 128
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

A_sum = [A[0]]
for i in range(1,N):
    A_sum.append(A_sum[i-1]+A[i])
    

a_cnt = Counter(A_sum)


ans = 0
for k,v in a_cnt.items():
    ans += v*(v-1)//2
    if k==0:
        ans += v
    
print(ans)

Measured memory_bytes: 41672
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b;
  cin >> a >> b;
  if (a+b >= 10)cout << "error" << endl;
  else cout << a+b << endl;

}


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 MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,vector<int>>;

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

  vector<P> A(M);
  REP(i,M){
    cin >> A[i].first;
    REP(j,A[i].first){
      int z;
      cin >> z;
      A[i].second.push_back(z);
    }
  }
  vector<int> p(M);
  REP(i, M) cin >> p[i];
  
  int cnt2 = 0;
  REP(i,pow(2,N)){
    int flag = 0;
    int x = i;
    vector<int> B(N);
    REP(j,N){
      B[j] = x%2;
      x/=2;
    }
    REP(j,M){
      int cnt = 0;
      REP(k,A[j].first){
        if(B[A[j].second[k]-1]==1){
          cnt++;
        }
      }
      if(cnt%2!=p[j]){
        flag = 1;
        break;
      }
    }
    if(flag == 0){
      cnt2++;
    }
  }

  cout << cnt2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,ll>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    ll N;
    cin>>N;
    vector<ll> A(N),X(2*N);
    rep(i,N)cin>>A.at(i);
    sort(A.rbegin(),A.rend());
    ll ans=0;
    rep(i,2*N){
        X.at(i)=A.at(i/2);
    }
    rep(i,N){
        if(i==0)continue;
        ans+=X.at(i);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 8004
/*input
1 1 1
1000000000
*/
#include <bits/stdc++.h>
using namespace std;
const long long md=1e9+7;
long long a[2005],n,memo[2005][2][2005],dp[2005][2];

long long solve(int idx, int player, int card){
	if(memo[idx][player][card]!=-1) return memo[idx][player][card];
	if(idx==n-1) return memo[idx][player][card]=abs(a[card]-a[idx]);
	long long ans=abs(a[n-1]-a[card]);
	if(player==0){
		for(int i=idx;i<n;++i){
			ans=max(ans,solve(i+1,!player,i));
		}
	}
	else{
		for(int i=idx;i<n;++i){
			ans=min(ans,solve(i+1,!player,i));
		}
	}
	return memo[idx][player][card]=ans;
}
int main(){
	#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	#endif
	long long q,m,k,h,ans=0,sum=0,p,x,y;
	cin>>n>>x>>y;
	for(int i=0;i<n;++i)
		cin>>a[i];
	memset(memo,-1,sizeof(memo));
	a[n]=x,a[n+1]=y;
	cout<<solve(0,0,n+1);
}

Measured memory_bytes: 63232
n = int(input())
lst = list(map(int, input().split()))

count = 0

for i in range(0, len(lst)-2):
    target = lst[i:i+3]
    minVal = min(target)
    maxVal = max(target)
    val = lst[i+1]
    if val != minVal and val != maxVal:
        count += 1

print(count)

Measured memory_bytes: 3060
#include <algorithm>
#include <cstdio>

using namespace std ;

typedef long long LL ;

LL n ;

int main ()
{
	scanf("%lld",&n);
	if ( n&1 ) return puts("0")*0;
	LL two=n/2 , five=0 , i ;
	for ( i=2 ; i<=n/2 ; i*=2 )
		two+=n/2/i;
	for ( i=5 ; i<=n/2 ; i*=5 )
		five+=n/2/i;
	printf("%lld\n",min(two,five));
	return 0 ;
}


Measured memory_bytes: 128
K, N = gets.chomp.split(" ").map(&:to_i)
A = gets.chomp.split(" ").map(&:to_i)

ans = []
(0..(N-2)).each{|i|
  ans << A[i+1] - A[i]
}
ans << (K - A[-1] + A[0])

puts K - ans.max


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

for _ in range(N):
    X.append(list(map(int, input().split())))


def dist(a, b):
    d = 0
    for i in range(D):
        d += (a[i] - b[i])**2
    return d


dists = []
for i in range(N):
    for j in range(i + 1, N):
        dists.append(dist(X[i], X[j]))

v = [i**2 for i in range(1000)]

ans = 0
for d in dists:
    if d in v:
        ans += 1
print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstdlib> 
#include<cstring>
using namespace std;
int read()
{
	int x=0,f=1; char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1; c=getchar();}
	while (c>='0'&&c<='9') {x=x*10+c-'0';c=getchar();}
	return x*f;
}
long long N,w;
int main()
{
	cin>>N;
	for (int n=1; n<=3500; n++)
		for (int h=1; h<=3500; h++) {
			if (4*h*n-N*n-N*h!=0) {
				w=N*h*n/(4*h*n-N*n-N*h);
				if (w>0&&(N*h*n)%(4*h*n-N*n-N*h)==0) {
					cout<<n<<" "<<h<<" "<<w;
					return 0;
				}	
			}
		}
	return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <map>
#include <cstring>
#include <string>
#include <math.h>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repp(i, m, n) for(int i = m; i < (int)n; i++)
#define reps(i, n) for(int i = 1; i <= (int)n; i++)
#define pb push_back
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;

int kakui(int a)
{
	int ret=0;
	while(a>0)
	{
		ret+=(a%10);
		a/=10;
	}
	return ret;
}

int main()
{
	int n;
	cin >> n;
	int ans=100;
	reps(i, n-1)
	{
		ans=min(ans, kakui(i)+kakui(n-i));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#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(){
	int n;
	while(cin>>n){
		if(!n)break;

		int magic[n][n];
		for(int i=0;i<n*n;i++)
			magic[i/n][i%n] = 0;

		int x = n/2,y = (n+1)/2;
		for(int i=0;i<n*n;i++){
			magic[y][x] = i+1;
			y = (++y)%n;
			x = (++x)%n;
			if(magic[y][x]!=0){
				y = (++y)%n;
				x += n-1;
				x %= n;
			}
		}
	
		
		for(int y = 0;y<n;y++){
			for(int x = 0;x<n;x++){
				printf("%4d",magic[y][x]);
			}
			cout<<endl;
		}
		
	}
  return 0;
}

Measured memory_bytes: 0
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (int i = 0; i < (int)vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

#ifdef _DEBUG
template <class Head>
void dump(const char* str, Head &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + 1, t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

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

	int A, B;
	cin >> A >> B;

	cout << max({ A + B, A - B, A * B }) << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	long long int a, b;
	scanf("%lld", &a);
	scanf("%lld", &b);
	long long int result_a, result_b;
	result_a = a;
	result_b = b;
	long long int result = 1;

	long long int counter = 1;
	
	while(1){
		++counter;
		if(counter == a || counter == b)
			break;
		while(((result_a % counter) == 0) && ((result_b % counter) == 0)){
			result_a = result_a / counter;
			result_b = result_b / counter;
			result = result * counter;
			//printf("%d %d\n", result_a, result_b);
		}
	}
	printf("%lld\n", (long long int)(result * result_a * result_b));

	return 0;
}

Measured memory_bytes: 128
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a


N = int(input())
A = list(map(int,input().split()))

ans = A[1]
for i in range(2,N):
    ans = gcd(ans,A[i])

d = []
for n in range(1,int(A[0]**0.5)+1):
    if A[0]%n == 0:
        d.append(n)
        d.append(A[0]//n)

d.sort(reverse=True)

for n in d:
    cnt = 0
    for a in A:
        if a%n==0:
            cnt += 1
    if cnt >= N-1:
        break
ans = max(ans,n)

print(ans)

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

int main() {
  long long n;
  cin >> n;
  long long num = sqrt(n);
  long long ans=1e18;
  for (int i=1; i<=num; i++){
    if (n%i==0) ans = min(ans, i+n/i-2);
  }
  
  cout << ans << endl;
}


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

int main(){
    int N;
    cin >> N;
    map<int,int> B;
    for(int i=2;i<=N;i++){
        int num;
        cin >> num;
        B[num]++;
    }
    for(int i=1;i<=N;i++){
        cout << B[i] <<endl;
    }
    return 0;
}

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const ll MOD = 998244353;
const int MX = TEN(6) * 2;
ll inv[MX], fact[MX], ifact[MX];

void init() {
	inv[1] = 1;
	for (int i = 2; i < MX; ++i) {
		inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
	}
	fact[0] = ifact[0] = 1;
	for (int i = 1; i < MX; ++i) {
		fact[i] = fact[i-1] * i % MOD;
		ifact[i] = ifact[i-1] * inv[i] % MOD;
	}
}

inline ll comb(int n, int r) {
	if (n < 0 || r < 0 || r > n) return 0;
	return fact[n] * ifact[r] % MOD * ifact[n - r] % MOD;
}

inline ll way(int a, int b) {
	return comb(a + b, a);
} 

inline ll calc(int x, int y, int t) {
	if (t <= 0) return 0;
	ll res = way(x, y) - way(y - t, x + t);
	if (res < 0) res += MOD;
	return res;
}

int main() {
	init();

	int N, K; cin >> N >> K;
	ll ans = 0;

	for (int r = 0; r <= K; ++r) {
		int b = K - r;
		if (b > r || r < N) continue;

		if (b == r) {
			ll v = calc(r, b - 1, b - N + 1);
			ans = (ans + v) % MOD;
		} else {
			ll v = calc(r, b, r - N + 1);
			ans = (ans + v) % MOD;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 47104
package main

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

// input scanner
var sc = bufio.NewScanner(os.Stdin)

const (
	initialBufSize = 10e4
	maxBufSize     = 10e6
)

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

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

// util
func max(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n > ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

func min(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n < ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

// main
func main() {
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	m := nextInt()
	if n == m {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

const int N=1e6+100,mod=1e9+7;
int n;
LL f[N],s[N],Ans;

void Inc(LL &x,LL y) {x+=y, x>=mod ? x-=mod : 233;}

int main()
{
	scanf("%d",&n);
	f[0]=s[0]=1;
	for(int i=1;i<=n;++i)
	{
		f[i]=f[i-1];
		if(i>2) Inc(f[i],s[i-3]);
		s[i]=s[i-1], Inc(s[i], f[i]);
		//cout<<f[i]<<endl;
	}
	for(int i=0;i<=n-2;++i)
	{
		Inc(Ans,1ll*(n-1)*(n-1)%mod*f[i]%mod),
		Inc(Ans,1ll*(i+1)*f[i]%mod);
	}
	Inc(Ans,f[n-1]*(n-1)%mod); Inc(Ans,f[n]); printf("%lld",Ans);
	return 0;
}

Measured memory_bytes: 15872
(defun f ()
  (let ((N (read)) (M (read)) (K (read)))
    (defun fLIP? (N M K)
      (defun iter (i j)
	  (if (= i (+ N 1))
	      nil
	      (if (= (+ M 1) j)
		  (iter (+ i 1) 0)
		  (if (= (+ (* i j) (* (- N i) (- M j)))
			 K)
		      t
		      (iter i (+ j 1))))))
      (iter 0 0))
    (if (fLIP? N M K)
	(format t "~A~%" "Yes")
	(format t "~A~%" "No"))))

(f)

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

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

	int N, Q;
	scanf("%d %d", &N, &Q);

	vector<vector<int>> c(N + 1);  // 0は欠番
	vector<int> counter_single(N + 1, 0);
	vector<int> counter_result(N + 1, 0);

	//辺入力
	int a, b;
	for (int i = 0; i < N - 1; i++) {
		scanf("%d %d", &a, &b);
		// printf("%d %d \n", a, b);
		c[a].push_back(b);
		c[b].push_back(a);
	}

	for (int i = 0; i < c.size(); i++) {
		// printf("c[%d] -> ", i);
		for (int j = 0; j < c[i].size(); j++) {
			// printf("%d ", c[i][j]);
		}
		// printf("\n");
	}

	// count入力
	int p, x;
	for (int i = 0; i < Q; i++) {
		scanf("%d %d", &p, &x);
		counter_single[p] += x;
	}

	for (int i = 1; i < counter_single.size(); i++) {
		// printf("counter_single[%d] = %d\n", i, counter_single[i]);
	}

	stack<pair<int, int>> st;
	int tmp_i, before;

	st.push(make_pair(1, 0));
	while (st.size() > 0) {
		tmp_i = st.top().first;
		before = st.top().second;
		st.pop();
		counter_result[tmp_i] += counter_single[tmp_i];
		// printf("counter_result[%d] = %d\n", tmp_i, counter_result[tmp_i]);
		for (auto j : c[tmp_i]) {
			if (j != before) {
				st.push(make_pair(j, tmp_i));
				counter_result[j] += counter_result[tmp_i];
			}
		}
	}

	for (int i = 1; i < counter_result.size(); i++) {
		printf("%d ", counter_result[i]);
	}
	return 0;
}


Measured memory_bytes: 17140
#include<stdio.h>
#define NIL -1
#define n_max 100001
void pchild(int);
int parent[n_max],cleft[n_max],right[n_max];

int main(){
  int n, i, j, id, k;

  scanf("%d",&n);
  for(i=0;i<=n-1;i++)
    parent[i]=cleft[i]=right[i]=NIL;
  
  for(i=0;i<=n-1;i++){
    scanf("%d %d",&id,&k);

    int c[k+1];
    
    for(j=1;j<=k;j++){
      scanf("%d",&c[j]);
    }
    
    if(k>=1){
      parent[c[1]]=id;
      cleft[id]=c[1];
    }
    
    for(j=2;j<=k;j++){
      parent[c[j]]=id;
      right[c[j-1]]=c[j];
    }
  }
    
    
  for(i=0;i<=n-1;i++){
    printf("node %d: parent = %d, depth = %d, ",i,parent[i],depth(i));
    if(parent[i]==NIL) printf("root, [");
    else if(cleft[i]==NIL) printf("leaf, [");
    else printf("internal node, [");
    pchild(i);
    printf("]\n");
        
  }
    
  return 0;
}


int depth(int i){//深さをかえす
  int dep=0;
  while(parent[i]!=NIL){
    dep++;
    i=parent[i];
  }
  return dep;
}


void pchild(int i){//子供をプリントする
  int child=cleft[i];
  
  while(child!=NIL && right[child]!=NIL){
    printf("%d, ",child);
    child=right[child];
  }
  
  if(cleft[i]!=NIL)
    printf("%d",child);
}



Measured memory_bytes: 3256
// Created by new_sm
//
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
s.find_by_order(x) xth element in set
x.order_of_key(x) number of elements <x*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define si set<int>
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu 1000000007
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) s.size()
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
void solve()
{
fastio
string s;
cin>>s;
cout<<count(all(s),'2');
}
int main()
{
//code
fastio
int t;
t=1;
while(t--)
{
	solve();
	cout<<endl;
}
}



Measured memory_bytes: 3616
#include <bits/stdc++.h>
 
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
 
#define fi first
#define se second
#define pb push_back
#define last(s) (s)[(s).length()-1]
#define all(a) (a).begin(),(a).end()
#define elif else if
#define left asdasd
#define next zaza
#define prev azaz
#define cclear cout<<flush;
#define x0 kerker
#define y0 lolik
#define kchay ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 
using namespace std;
 
using llong = long long;
using ld = long double;
using ii = pair<int,int>;
using ull = unsigned long long;
using pll = pair<llong, llong>;
 
const llong over999 = 1e18;
const llong md = 1e9+7;
const ld eps = 1e-16;
const ld Pi = acos(-1);
 
/*
*/

int n, m, k;

int32_t main()
{
    kchay;
    
    cin >> n >> m >> k;
    
    for(int i = 1; i <= n; i++)
    {
        for(int j = 0; j <= m; j++)
        {
            if(i*(m-j) + j*(n-i) == k)return cout << "Yes", 0;
        }
    }
    
    swap(n, m);
    
    
    for(int i = 1; i <= n; i++)
    {
        for(int j = 0; j <= m; j++)
        {
            if(i*(m-j) + j*(n-i) == k)return cout << "Yes", 0;
        }
    }
    
    cout << "No";
    return 0;
}

Measured memory_bytes: 256
list_HW = list()
while True:
    base = input("")
    term = base.split(' ')
    if(int(term[0]) == 0 and int(term[0]) == 0):
        break
    else:
        map_HW = {'H': int(term[0]), 'W': int(term[1])}
        list_HW.append(map_HW)

for HW in list_HW:
    h = HW['H']
    w = HW['W']

    for r in range(h):
        if r == 0 or 0 == r%2:
            for s in range(w):
                if 0 == s%2:
                    print('#',end='')
                else:
                    print('.',end='')
        else:
            for s in range(w):
                if 0 != s%2:
                    print('#',end='')
                else:
                    print('.',end='')
        print('',end='\n')

    print('',end='\n')



Measured memory_bytes: 7024
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int n,weight;
  scanf("%d%d",&n,&weight);
  int v[100];
  int w[100];
  int i;
  for(i=0;i<n;i++) scanf("%d%d",v+i,w+i);
  int sum=0;
  for(i=0;i<n;i++) sum+=v[i];
  int dp[10001];//dp[i] : 価値iを達成する最小の重さ
  for(i=0;i<=sum;i++) dp[i]=weight+1;
  dp[0]=0;
  for(i=0;i<n;i++){
    int j;
    for(j=sum;j>=v[i];j--){
      dp[j]=MIN(dp[j],dp[j-v[i]]+w[i]);
    }
  }
  for(i=sum;i>=0;i--){
    if(dp[i]<=weight) break;
  }
  printf("%d\n",i);
  return;
}

int main(void){
  run();
  return 0;
}



Measured memory_bytes: 2100
#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 <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {
    ll N;
    cin >> N;
    ll ans = 0;
    rep(i, 1, N+1){
        if (i % 3 != 0 && i % 5 != 0) ans += i;
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3224
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 1e9+7;
int N;
ll A[3003];
ll DP[3003][3003]; // iからj-1までの区間のときのポイント

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

  cin >> N;
  rep(i, N) cin >> A[i];
  for (int len = 1; len <= N; ++len) {
    rep(s, N-len+1) {
      int e = s + len;
      if ((N - len) % 2 == 0) DP[s][e] = max(DP[s + 1][e] + A[s], DP[s][e - 1] + A[e - 1]);
      else DP[s][e] = min(DP[s + 1][e] - A[s], DP[s][e - 1] - A[e - 1]);
    }
  }

  cout << DP[0][N] << "\n";
  return 0;
}

Measured memory_bytes: 70144
#include<bits/stdc++.h>
using namespace std;
long long x[5009];

int main(){
  int r,d;
  cin>>r>>d>>x[2000];
  for(int i=2001;i<=2010;i++){
    x[i]=r*x[i-1]-d;
    cout<<x[i]<<endl;
  }
  return(0);
}


Measured memory_bytes: 256
using System;


public class A{
	
	public static void Main(){
	
		string[] args = Console.ReadLine().Split(' ');
		int k = Int32.Parse(args[0]);
		if( k % 2 == 1 ){
			Console.WriteLine( (k*k - 1)/4 );
		}else{
			Console.WriteLine( k*k/4 );
		}	
		
	}
	
}

Measured memory_bytes: 11092
#include<stdio.h>

int main(void){
  char Word;
  scanf("%c", &Word);
  if(Word == 'A') printf("T");
  else if(Word == 'T') printf("A");
  else if(Word == 'C') printf("G");
  else if(Word == 'G') printf("C");
  else printf("Error");
  
  return 0;
} 

Measured memory_bytes: 128
a, b = gets.chomp.split().map(&:to_i)
x = [] 
ct = 0
a.times do |n|
  x.push(gets.chomp.split().map(&:to_i))
end

a.times do |n|
  (1+n).upto(a-1) do |m|
    dist = 0
    b.times do |c|
      dist += (x[n][c] - x[m][c])**2
    end
    root = Math.sqrt(dist)
    ct += 1 if root.to_i == root
  end
end

puts ct

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

ll ans=0;


void Main() {
  ll n;
  R n;
  vector<ll> v[n];
  rep(i,n-1) {
    ll x,y;
    cin >> x >> y;
    x--,y--;
    v[x].pb(y);
    v[y].pb(x);
  }
  ll c[n],d[n];
  rep(i,n) R c[i];
  sort(c,c+n,greater<ll>());
  queue<int> que;
  que.push(0);
  memset(d,-1,sizeof(d));
  ll k=0,ans=0;
  d[0]=c[k++];
  int N = 100000;
  int flag[N];
  memset(flag,0,sizeof(flag));
  flag[0]=1;
  while(!que.empty()) {
    ll x=que.front();que.pop();
    rep(i,v[x].size()) {
      ll y=v[x][i];
	  
      //if(d[y]!=-1) continue;
	  if(flag[y])continue;
	  flag[y]=1;
      d[y]=c[k++];
      ans+=d[y];
      que.push(y);
    }
  }
  pr(ans);
  PR(d,n);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 1536
#include <stdio.h>

int main (void){
	char ch;
	int x,c[26]={0};
	
	while(scanf("%c",&ch)!=EOF){
		if(ch>='A' && ch<='Z'){
			x=ch-'A';
			c[x]+=1;
		}else if(ch>='a' && ch <='z'){
			x=ch-'a';
			c[x]+=1;
		}
	}
	for(x=0,ch='a';x<26;x++,ch++){
		printf("%c : %d\n",ch,c[x]);
	}
}
		


Measured memory_bytes: 2140
#include<bits/stdc++.h>
using namespace std;
int dp[10000][10000],c[10000],d[10000],g;
int main(){
    int N,W;
    cin>>N>>W;
    for(int i=1;i<N+1;i++){
        cin>>c[i]>>d[i];
    }
    for(int i=0;i<=10000;i++){
        dp[0][i]=-998648;
    }
    dp[0][0]=0;
    for(int i=1;i<N+1;i++){
        for(int j=W;j>=0;j--){
            //dp[i][j]=max(dp[i-1][j],dp[i-1][j-d[i]]+c[i]);
            dp[i][j] = dp[i - 1][j];
            if(j - d[i] >= 0)dp[i][j] = max(dp[i][j],dp[i - 1][j - d[i]] + c[i]);
        }
    }

   

    for(int i=0;i<=W;i++){
        g=max(dp[N][i],g);
    }
    cout<<g<<endl;

}

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

int main() {

    int n;
    int c[4] = {0, 0, 0, 0};
    char s[4];

    scanf("%d", &n);

    for (int i  = 0; i < n; i++) {
        scanf("%s", s);
        if (s[0] == 'A') {
            c[0]++;
        } else if (s[0] == 'W') {
            c[1]++;
        } else if (s[0] == 'T') {
            c[2]++;
        } else if (s[0] == 'R') {
            c[3]++;
        }
    }

    printf("AC x %d\n", c[0]);
    printf("WA x %d\n", c[1]);
    printf("TLE x %d\n", c[2]);
    printf("RE x %d\n", c[3]);

    return 0;
}

Measured memory_bytes: 3808
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<string>
#include<cmath>
#include<utility>
#define rep(i,rept) for (ll i = 0; i < rept; i++)
typedef long long ll;
int main() {
	int a = 0, b = 0, c = 0;
	std::cin >> a;
	if (a < 1200) {
		std::cout << "ABC" << std::endl;
		return 0;
	}
	if (a < 2800) {
		std::cout << "ARC" << std::endl;
		return 0;
	}
	else {
		std::cout << "AGC" << std::endl;
		return 0;
	}
	
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>

#define LP(i,n) for(int i=0;i<n;i++)
#define Mset(x,v) memset(x,v,sizeof(x))
#define INF INT_MAX
#define MAX 100000

using namespace std;
using LL=long long;

int main(){
    int n,d,p,t=0;
    cin>>n>>d;
    for(int i=0;i<n;i++){
        cin>>p;
        t+=max(0,p-d);
    }
    if(!t) cout<<"kusoge"<<endl;
    else cout<<t<<endl;
    return 0;
}



Measured memory_bytes: 3048
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int d = sc.nextInt();
    int x = sc.nextInt();
    int[] a = new int[n];
    for (int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
    }
    int sum = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j * a[i] + 1 <= d; j++) {
        sum++;
      }
    }
    System.out.println(x + sum);
  }

}


Measured memory_bytes: 22736
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<string>
#include<math.h>
#include<cstring>
using namespace std;
string s[200000];
bool cmp(string a,string b)
{
    return a<b;
}
int main()
{
    int n;
    int i;
    cin>>n;
    for(i=0;i<n;i++)
        cin>>s[i];
    sort(s,s+n,cmp);
    int con=1;
    int y=1,ans=1;
    for(i=1;i<n;i++)
    {
        if(s[i]==s[i-1])
            con++;
        else
            con=1;
        y=max(con,y);
    }
    con=1;
    if(y==1)cout<<s[0]<<endl;
    for(i=1;i<n;i++)
    {
        if(s[i]==s[i-1])
            con++;
        else
            con=1;
        if(con==y)
        cout<<s[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 6656
#include <iostream>

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(char c) {
  auto pred = false;
  switch(c) {
    case 'a':
    case 'e':
    case 'i':
    case 'o':
    case 'u':
      pred = true;
  }
  cout << (pred ? "vowel" : "consonant") << endl;
}

int main() {
  char c;
  cin >> c;
  solve(c);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  int l, r;

  cin >> n;
  int count = 0;

  for(int i=0; i<n; i++){
    cin >> l >> r;
    count = count + (r - l)+ 1;
  }

  cout << count;
}

Measured memory_bytes: 3592
N=int(input())
A=[int(input()) for _ in range(N)]
mp=A[1]-A[0]
mn=A[0]
for i in range(1,N):
    x=A[i]
    if mp < (x-mn):
        mp=x-mn
        if 0>x-mn:
            mn = x
    if x<mn:
        mn=x
print(mp)

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

int main(){

	// #ifndef ONLINE_JUDGE
 //    	freopen("input", "r", stdin);
 //    	freopen("output", "w", stdout);
	// #endif
	ios_base::sync_with_stdio(false);
   	cin.tie(NULL);

   	int n,d;
   	cin>>n>>d;

   	d = 2*d + 1;

   	cout<<ceil((double)n/d)<<endl;
}

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

int main( int argc, char *argv[] )
{
char S[ 110 ];
char lpAns[] = "ABC";

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

	cin >> S;
	cin >> S;
	lpAns[ 1 ] = S[ 0 ];
	cout << lpAns << endl;

	return 0;
}




Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

int main() {
    int A,B;cin >>A  >>B;
    cout << A*B << endl;
}


Measured memory_bytes: 3624
def dfs(arr, i, j, val, mx):
    val += arr[i][j]
    if (i == 1 and j == N - 1):
        mx.append(val)
    else:
        if i + 1 < 2:
            dfs(arr, i + 1, j, val, mx)
        if j + 1 < N:
            dfs(arr, i, j + 1, val, mx)


N = input()
arr = []
for i in range(2):
    arr.append(map(int, raw_input().split()))

mx = []
dfs(arr, 0, 0, 0, mx)

print max(mx)

Measured memory_bytes: 2692
//i hate _____
#include<bits/stdc++.h>

#define ll long long int 
#define ld long double 
#define pb push_back
#define mk make_pair
#define ii pair<int , int>

using namespace std;
double pi = 2 * acos(0.0) ;

template<typename T> 
ostream& operator<<(ostream &os, const vector<T> &v) { 
    os << '{'; 
    for (const auto &x : v) os << " " << x;
        return os << '}'; 
}

void solve(){
    
}

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

    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    int n; cin>>n;
    bool ok = false;
    int cnt = 0;
    while (n--){
        int x,y; cin>>x>>y;
        if (x==y)cnt++;
        else cnt = 0;
        if (cnt==3) ok = true;
    }
    if (ok) cout << "Yes\n";
    else cout << "No\n";
    
    return 0;
}
/*
    problems are the sign of life
*/


Measured memory_bytes: 3664
def solve():
    H, W = map(int, input().split())
    maze = [[] for _ in range(H)]
    for i in range(H):
        maze[i] = list(input())

    u = [[0 for _ in range(W)] for _ in range(H)]
    r = [[0 for _ in range(W)] for _ in range(H)]
    d = [[0 for _ in range(W)] for _ in range(H)]
    l = [[0 for _ in range(W)] for _ in range(H)]
    for i in range(H):
        for j in range(W):
            if maze[i][j] == '#':
                continue
            if i == 0:
                u[i][j] = 1
            else:
                u[i][j] = u[i-1][j] + 1
            if j == 0:
                l[i][j] = 1
            else:
                l[i][j] = l[i][j-1] + 1
    for i in range(H-1, -1, -1):
        for j in range(W-1, -1, -1):
            if maze[i][j] == '#':
                continue
            if i == H - 1:
                d[i][j] = 1
            else:
                d[i][j] = d[i+1][j] + 1
            if j == W - 1:
                r[i][j] = 1
            else:
                r[i][j] = r[i][j+1] + 1

    ans = 0
    for i in range(H):
        for j in range(W):
            ans = max(ans, u[i][j] + r[i][j] + d[i][j] + l[i][j] - 3)
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 313608
n = int(input())
a = list(map(int, input().split()))
mx = max(a)+1
mn = min(a)-1
b = [0]*(mx-mn+1)
for i in range(n):
    b[a[i]-1-mx] += 1
    b[a[i] -mx] += 1
    b[a[i]+1-mx] += 1
print(max(b))


Measured memory_bytes: 13964
# include <iostream>
# include <math.h>
# include <cmath>
using namespace std;
int main()
{
	int n,k,m,d;
	cin>>n;
	k=2*n/3;
	m=sqrt(k);
	int a[n+1]={0};
	if(m==0)
	{
		cout<<"0"<<endl;
		return 0;
	}
	for(int i=1; i<=105; i++)
	{
		for(int j=1; j<=105; j++)
		{
			for(int l=1; l<=105; l++)
			{
				d=(i+j)*(i+j)+(j+l)*(j+l)+(l+i)*(l+i);
				if(d<=2*n)
				{
					if(d%2==0)
					{
					a[d/2]=a[d/2]+1;
				}
				}
			}
		}
	}
	for(int i=1; i<n+1; i++)
	{
		cout<<a[i]<<endl;
	}
}

Measured memory_bytes: 3704
def main():
    N = int(input())
    A = []
    for _ in range(2):
        A.append([int(a) for a in input().split()])
    dp = [[0]*(N+1) for _ in range(3)]
    for i in range(2):
        for j in range(N):
            dp[i+1][j+1] = A[i][j] + max(dp[i][j+1], dp[i+1][j])
    return dp[2][N]

if __name__ == '__main__':
    print(main())

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

int main() {
	string s;
	int i,count=0;
	cin>>s;
	for(i=0;i<3;i++){
		if(s.at(i)=='1'){
			count+=1;
		}
	}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
n = int(input())
w_arr = []

for i in range(n):
    w_arr.append(input())

if len(list(set(w_arr))) == len(w_arr):
    for i in range(n-1):
        if w_arr[i][-1] == w_arr[i+1][0]:
            continue
        else: 
            print("No")
            sys.exit()

else:
    print("No")
    sys.exit()

print("Yes")

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <numeric>//accumulate(v.begin(), v.end(), 0);
#include <algorithm>//sort(v.begin(),v.end());
#include <string>//
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main(){
        int n;
        cin >> n;
        vector <int> v(n,0);
        rep(i,n){
                cin  >> v[i];
        }
        sort(v.begin(),v.end());
        int ans=1;
        bool flag =false;
        rep(i,n-1){
                if(v[i]==v[i+1]) {
                        if(flag) {
                                ans++;
                                flag =false;
                        }else{
                                ans--;
                                flag =true;
                        }
                }else{
                        ans++;
                        flag =false;
                }
        }
        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>
#include <sstream>
#include <unordered_map>
#include <set>

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
static ull tenq = 1000000000;
static ull mod = tenq + 7;

using namespace std;

int main()
{
  ll N, x;
  cin >> N >> x;
  vector<ll> as(N);
  for (auto i = 0; i < N; i++) {
    cin >> as[i];
  }

  ll prev = 0;
  ll res = 0;
  for (auto i = 0; i < N; i++)
  {
    ll num_eat = max(0LL, (prev + as[i]) - x);
    res += num_eat;
    prev = as[i] - num_eat;
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 1024
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();
		int A = sc.nextInt();
		int B = sc.nextInt();
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				if(i < B) {
					if(j < A) {
						System.out.print("1");
					} else {
						System.out.print("0");
					}
				} else {
					if(j < A) {
						System.out.print("0");
					} else {
						System.out.print("1");
					}
				}
			}
			System.out.println("");
		}
	}
}


Measured memory_bytes: 45200
#include<iostream>
using namespace std;
int main(){
  int n,m;
  while(cin >>n,n){
    int field[101][11] = {0},ans[11] = {0};
    for(int i=1,x; i<=n; i++){
      cin >>x;
      for(int j=0,r; j<x; j++){
	cin >>r;
	field[i][r/10] |= 1<<(r%10);
      }
    }
    cin >>m;
    for(int i=0,q; i<m; i++){
      cin >>q;
      ans[q/10] |= 1<<(q%10);
    }
    int x = 0;
    for(int i=1,j; i<=n; i++){
      for(j=0; j<11; j++){
	if((ans[j]&field[i][j]) != ans[j]){break;}
      }
      if(j == 11){
	if(!x){x = i;}
	else{x = -1;break;}
      }
    }
    if(!x){x = -1;}
    cout <<x<<endl;
  }
  return 0;
}

Measured memory_bytes: 872
#include <iostream>
#include <algorithm>

using namespace std;

#define MAX1 200000
#define MINF (-1 * (10*10*10*10*10*10*10*10*10))

int main() {
	int ar[MAX1];
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> ar[i];

	int vmax = ar[0], vmin = ar[0];
	int res = MINF;
	bool f = true;
	for (int i = 1; i < n; i++) {
		if (vmin > ar[i]) {
			vmin = vmax = ar[i];
			if (f)
				res = max(res, ar[i] - ar[i - 1]);
		}
		else if (vmax <= ar[i]) {
			f = false;
			vmax = ar[i];
			res = max(res, vmax - vmin);
		}
	}
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 1940
def ceil(n, m):
    return -(-n // m)

# K回のカットで長さlにできるかどうか
def possible(l, K):
    cut = 0
    if l <= 0:
        return False
    for i in range(N):
        cut += ceil(A[i], l) - 1
        if cut > K:
            return False
    return True

N, K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
L = sum(A)

ng = (L // (N + K)) - 1  # min -1
ok = max(A)

while ok - ng > 1:
    mid = (ok + ng) // 2
    if possible(mid, K):
        ok = mid
    else:
        ng = mid

print(ok)

Measured memory_bytes: 30840
n = int(input())
a = [i - 1 for i in list(map(int, input().split()))]
b = list(map(int, input().split()))
c = list(map(int, input().split()))
res = 0

for a_idx, i in enumerate(a):
  res += b[i]
  if a_idx >= 1 and (a[a_idx - 1] + 1 == i):
    res += c[i-1]

print(res)
  

Measured memory_bytes: 3060
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;

namespace AGC005A
{
    public class Program
    {
        void Solve(StreamScanner ss, StreamWriter sw)
        {
            //---------------------------------
            var ls = new Stack<char>();
            var rs = new Stack<char>(Console.ReadLine().Reverse());

            while (rs.Count > 0)
            {
                if (ls.Count != 0 && ls.Peek() == 'S' && rs.Peek() == 'T')
                {
                    ls.Pop();
                    rs.Pop();
                }
                else
                {
                    ls.Push(rs.Pop());
                }
            }

            sw.WriteLine(ls.Count);
            //---------------------------------
        }

        static void Main()
        {
            var ss = new StreamScanner(new StreamReader(Console.OpenStandardInput()));
            var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            new Program().Solve(ss, sw);
            sw.Flush();
        }

        static readonly Func<string, string> String = s => s;
    }

    public class StreamScanner
    {
        static readonly char[] Sep = {' '};
        readonly Queue<string> buffer = new Queue<string>();
        readonly TextReader textReader;

        public StreamScanner(TextReader textReader)
        {
            this.textReader = textReader;
        }

        public T Next<T>(Func<string, T> parser)
        {
            if (buffer.Count != 0) return parser(buffer.Dequeue());
            var nextStrings = textReader.ReadLine().Split(Sep, StringSplitOptions.RemoveEmptyEntries);
            foreach (var nextString in nextStrings) buffer.Enqueue(nextString);
            return Next(parser);
        }

        public T[] Next<T>(Func<string, T> parser, int x)
        {
            var ret = new T[x];
            for (var i = 0; i < x; ++i) ret[i] = Next(parser);
            return ret;
        }

        public T[][] Next<T>(Func<string, T> parser, int x, int y)
        {
            var ret = new T[y][];
            for (var i = 0; i < y; ++i) ret[i] = Next(parser, x);
            return ret;
        }
    }
}

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

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

  ll ans = 0;
  ll tmp = 0;
  for (int i = 0; i < n; ++i) {
    ll a;
    cin >> a;
    if (a == 0) {
      ans += tmp / 2;
      tmp = 0;
    } else {
      tmp += a;
    }
  }
  ans += tmp / 2;
  cout << ans << endl;
}

Measured memory_bytes: 256
import math

def is_prime(n):
    if n == 1:
        return False
    elif n == 2:
        return True
    else:
        for i in range(3,int(math.sqrt(n))+1,2):
            if n % i == 0:
                return False
            else:
                pass
        return True

x = int(input())
if x != 2 and x%2 == 0:
    x += 1

while True:
    if is_prime(x):
        print(x)
        break
    else:
        x += 2

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>

int main(int argc, char const *argv[])
{
    int N,K,X,Y;
    std::cin >> N >> K >> X >> Y;
    int fee = std::min(N,K) * X + std::max(N - K, 0) * Y;
    std::cout << fee << '\n';    
    return 0;
}


Measured memory_bytes: 3608
num, sum = map(int, input().split())
sum /= 1000
for i in range(num+1):
  for j in range(num-i+1):
    if 10*i + 5*j + (num-i-j) == sum:
      print(i, j, num-i-j)
      exit()
print(-1, -1, -1)


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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int n = in();
    string s = in();
    int ans = 0;
    rep(i, n - 2)
    {
        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
            ++ans;
    }
    cout << ans << endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#define fi first
#define se second
using namespace std;
int dy[4]={0,0,-1,1},dx[4]={1,-1,0,0};
int X,Y,N;
char field[1000][1001];
pair<int,int> time1[1000][1001];
struct point{
    int y,x,t,n;
    point(int y_,int x_,int t_,int n_){
        y=y_;x=x_;t=t_;n=n_;
    }
};
int bfs(int y,int x);
int main(){
    cin>>Y>>X>>N;
    int rep;
    for(int i=0;i<Y;i++)cin>>field[i];
    for(int i=0;i<Y;i++){
        for(int j=0;j<X;j++){
            time1[i][j].fi=time1[i][j].se=-1;
        }
    }
    for(int i=0;i<Y;i++){
        bool flag=false;
        for(int j=0;j<X;j++){
            if(field[i][j]=='S'){
                rep=bfs(i,j);
                flag=true;
                break;
            }
        }
        if(flag)break;
    }
    cout<<rep<<endl;
    return 0;

}

int bfs(int y,int x){
    point start=point(y,x,0,0);
    queue<point>Q;
    Q.push(start);
    while(Q.size()){

        point a=Q.front();
        Q.pop();
        if(a.y<0 || a.y>=Y ||a.x<0||a.x>=X)continue;

        if(field[a.y][a.x]=='X')continue;

        if(a.n+1==field[a.y][a.x]-'0')a.n++;

        if(a.n>time1[a.y][a.x].se){
            time1[a.y][a.x].fi=a.t;
            time1[a.y][a.x].se=a.n;
        }else if(a.n==time1[a.y][a.x].se&&a.t<time1[a.y][a.x].fi){
            time1[a.y][a.x].fi=a.t;
        }else continue;

        if(a.n==N){
            return a.t;
        }


        for(int i=0;i<4;i++){
            point next=point(a.y+dy[i],a.x+dx[i],a.t+1,a.n);
            Q.push(next);
        }
    }
}

Measured memory_bytes: 10016