akhauriyash/Code-Regression huggingface dataset:
import static java.lang.Math.*;
import static java.util.Arrays.*;

import java.util.*;
import java.io.*;
import java.math.BigInteger;

import static java.math.BigInteger.*;

public class Main {
	void solve() {
		int N = sc.nextInt();
		int[] A = sc.nextIntArray(N);
		long ans = 0;
		for (int i = 0; i < N; i++) {
			if (A[i] % 2 == 1 && i + 1 < N && A[i+1] >= 1) {
				ans += 1;
				A[i] -= 1;
				A[i+1] -= 1;
			}
			ans += A[i] / 2;
		}
		out.println(ans);
	}

	static void tr(Object... os) { System.err.println(deepToString(os)); }

	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	MyScanner sc = null;
	PrintWriter out = null;
	public void run() throws Exception {
		sc = new MyScanner(System.in);
		out = new PrintWriter(System.out);
		for (;sc.hasNext();) {
			solve();
			out.flush();
		}
		out.close();
	}

	class MyScanner {
		String line;
		BufferedReader reader;
		StringTokenizer tokenizer;

		public MyScanner(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream));
			tokenizer = null;
		}
		public void eat() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					line = reader.readLine();
					if (line == null) {
						tokenizer = null;
						return;
					}
					tokenizer = new StringTokenizer(line);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
		}
		public String next() {
			eat();
			return tokenizer.nextToken();
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		public boolean hasNext() {
			eat();
			return (tokenizer != null && tokenizer.hasMoreElements());
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++) a[i] = nextInt();
			return a;
		}
	}
}

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

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

void solve() {
  string s;
  cin >> s;
  int sum = 0;
  for (auto &i : s) {
    sum += i - '0';
  }
  if (sum % 9 == 0) cout << "Yes" << '\n';
  else cout << "No" << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) solve();
}


Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int n, x;
    cin >> n >> x;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    int ans = 0;
    rep(i,n-1){
        if (x >= a[i]){
            ans++;
        } else break;
        x -= a[i];
    }
    if (x == a[n-1]) ans++;
    cout << ans << endl;
    return 0;
}

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

int main() {
    int n; cin >> n;
    ll ans = 0;
    for(ll i=1; i<=n; i++) {
        ll x = n / i;
        ans += x * (x + 1) * i / 2;
    }
    cout << ans << endl;
}

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

int main(){
  int N;
  cin >> N;
  for (int i = 0; i < (N/7)+1; i++) {
    if((N-i*7)%4==0) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace std;
//using namespace __gnu_pbds;
#define ll long long
#define M 1000000007LL
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define sep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define vl vector<ll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define sz(v) ((ll)v.size())
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pii pair<ll,ll> 
#define mod 1000000007
#define MAXN 300002
ll arr[100002];
ll ans=0;
vector<ll>v;
void f(ll i,ll k,ll ind,ll an,ll su)
{

if(k==0 and i<v.size()) return;
  if(i==v.size() and k) return;
  if(i==v.size()and k==0) {ans=max(ans,an);
    return;}
  ll btti=(an >> (ind - 1)) & 1;
  if(btti==0) return;

  f(i+1,k-1,ind,(an&(su+v[i])),0);
  
  f(i+1,k,ind,an,su+v[i]);
}
int main() {
       ll t;
       ios::sync_with_stdio(0);
       cin.tie(0);
       cout.tie(0);
      ll n;
      cin>>n;
      ll mn=0,ans=0;

      for(ll i=0;i<n;i++)
      {
        ll x;
        cin>>x;
        if(x>=mn)
          ans++;
        mn=max(mn,x);
      }
      cout<<ans;
       return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem B

if __name__ == '__main__':
    a, b, c = map(int, input().split())
    count = 1

    while count < 10001:
        if ((a * count) % b) == c:
            print('YES')
            exit()

        count += 1

    print('NO')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define REP(i, l, r) for (int i=(l); i<(r); ++i)
#define RREP(i, r, l) for (int i=(r); i>(l); --i)
#define CASET int _T; cin >> _T; REP(caset, 0, _T)
#define print(x) cout << to_string(x) << '\n'
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vvi vector<vi>
#define vvb vector<vb>
#define pii pair<int,int>
#define t3i tuple<int,int,int>
#define mii map<int,int>
#define sq(x) (x)*(x)
#define inv(x) powa(x, MOD-2)
 
int INF = 1LL<<60;
int MOD = 998244353;
 
string to_string(char &c) {string x(1, c); return x;}
string to_string(string &s) {return s;}
string to_string(const char s[]) {return (string)s;}
template <class C> string to_string(C &v) {
    string res;
    for (auto &x : v) res += to_string(x) + ' ';
    return res;
}
template <typename A> istream &operator>>(istream &is, vector<A> &v) {
    for (auto &x : v) is >> x;
    return is;
}
template <typename A, typename B> ostream &operator<<(ostream &os, pair<A, B> pr) {
    os << '(' << pr.first << ", " << pr.second << ')';
    return os;
}
ostream &operator<<(ostream &os, char &c) {os << (char)c; return os;}
ostream &operator<<(ostream &os, string &s) {for (char &c : s) os << (char)c; return os;}
ostream &operator<<(ostream &os, const char s[]) {os << (string)s; return os;}
template <class Container> ostream &operator<<(ostream &os, Container &v) {
    bool first = true;
    os << '[';
    for (auto &x : v) {
        if (!first) os << ',' << ' ';
        first = false;
        os << x;
    }
    os << ']';
    return os;
}
string bin_string(int x) {
    const int d = 32;
    string res(d, ' ');
    REP(i, 0, d) res[d-1-i] = '0'+(x>>i & 1LL);
    return res;
}
int powa(int base, int exp) {
    int res = 1;
    while (exp) {
        if (exp&1) res = res*base % MOD;
        base = base*base % MOD;
        exp >>= 1;
    }
    return res;
}
 
main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    
    int R, C;
    cin >> R >> C;
    vvb grid(R, vb(C));
    REP(i, 0, R) REP(j, 0, C) {
        char x;
        cin >> x;
        grid[i][j] = x=='#';
    }
    
    vector<pii> DELTAS = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
    int res=-1;
    REP(sr, 0, R) REP(sc, 0, C) if (!grid[sr][sc]) {
        vi qr = {sr}, qc = {sc};
        int qi=0;
        vvi dist(R, vi(C, -1));
        dist[sr][sc] = 0;
        while (qi<qr.size()) {
            int r=qr[qi], c=qc[qi];
            for (pii pr : DELTAS) {
                int dr,dc; tie(dr,dc) = pr;
                if (0<=r+dr&&r+dr<R && 0<=c+dc&&c+dc<C && !grid[r+dr][c+dc] && dist[r+dr][c+dc] == -1) {
                    qr.push_back(r+dr);
                    qc.push_back(c+dc);
                    dist[r+dr][c+dc] = dist[r][c] + 1;
                }
            }
            ++qi;
        }
        REP(i, 0, R) REP(j, 0, C) res = max(res, dist[i][j]);
    }
    print(res);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	ll n,m,k;
	scanf("%lld%lld%lld",&n,&m,&k);
	if(n%2==0||m%2==0||k%2==0)
	printf("0");
	else
	{
		ll ans=min(n*m,n*k);
		ans=min(ans,m*k);
		printf("%lld",ans);
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

main()
{

	int S, h, m, s;

	scanf("%d", &S);

	h = S/3600;
	m = S/60-(h*60);
	s = S-(h*3600)-(m*60);

	printf("%d:%d:%d\n", h, m, s);

	return 0;

}

Measured memory_bytes: 592
d, n = map(int, input().split())
if d == 0:
    if n == 100:
        n += 1
    print(n)
elif d == 1:
    if n == 100:
        n = n * 100
        n += 100
        print(n)
    else:
        print(100*n)
else:
    if n == 100:
        n = n * 10000
        n += 10000
        print(n)
    else:
        print(10000*n)


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

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

    if (K == 1) {
        cout << "1\n";
        return 0;
    }
    if (K % 2 == 0 || K % 5 == 0) {
        cout << "-1\n";
        return 0;
    }
    //if (K % 7 == 0) K /= 7;
    K *= 9;
    int a = 10;
    for (int i = 0; i <= 10 * K; i++) {
        if ((7 * (a - 1 + K)) % K == 0) {
            cout << i + 1 << "\n";
            return 0;
        }
        a = (a * 10) % K;
    }
   
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
int n,a[N];
int main() {
  ios::sync_with_stdio(false);
  cin>>n;int C=0,B=0;
  for(int i=1;i<=n;i++)cin>>a[i],C+=a[i]*a[i],B+=2*a[i];
  //a^2 +x^2 -2*x*a
  //n*x^2-B*a+C=0
  int ans=1e9;
  for(int i=-1000;i<=1000;i++){
    int tot=0;
    for(int j=1;j<=n;j++){
      tot+=(a[j]-i)*(a[j]-i);
    }
    ans=min(ans,tot);
  }
  cout<<ans<<'\n';
  return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;

typedef pair<int,int>Pi;
typedef pair<long long,long long>P;
typedef pair<long long,P>PP;
typedef pair<P,P>PPP;

const long long MOD=1e9+7;
const long long INF=5e18;
const int di[4]={1,0,-1,0};
const int dj[4]={0,1,0,-1};

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()

ll n,m,a,b;
ll sa,sb;

void input(){
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>a;
		sa+=a;
	}
	for(int i=0;i<m;i++){
		cin>>b;
		sb+=b;
	}
	return;
}

void solve(){
	cout<<sa*sb<<endl;
	return;
}

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


Measured memory_bytes: 3084
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <tuple>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef std::pair<int, int> P;

using namespace std;

// 一番大きい桁の数, １桁の数のペアを返す
P make_p(int x) {
  int head = 0;
  int tail = x % 10;
  while(x > 0) {
    if (x / 10 == 0) {
      head = x;
    } 
    x /= 10;
  }
  return P(head, tail);
}

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

  // {i, j}, cnt
  map<P, int> m;

  for(int i = 1; i <= n; i++) {
    P p = make_p(i);
    m[p]++;
  }

  long long ans = 0;
  rep(i, 10) {
    rep(j, 10) {
      P p = P(i, j);
      P r = P(j, i);
      ans += m[p] * m[r];
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
import math
N = int(input())
flag = False
for h in range(1, 3501, 1):
    for n in range(1, 3501, 1):
        bumbo = 4 * h * n - N * h - N * n
        bunshi = N * h * n
        if bumbo == 0:
            continue
        wc = math.ceil(bunshi / bumbo)
        wf = math.floor(bunshi / bumbo)
        if wc == wf and wc >= 1:
            ans_h = h
            ans_n = n
            ans_w = wc
            flag = True
            break
    if flag:
        break
print(ans_h, ans_n, ans_w)

Measured memory_bytes: 42652
#include<iostream>
#include<string>
using namespace std;
int main(){
  char s;
  cin >> s;
  if(s == 'A')
      cout << 'T' <<endl;
  else if(s == 'T')
      cout << 'A' <<endl;
  else if(s == 'C')
      cout << 'G' <<endl;
  else if(s == 'G')
      cout << 'C' <<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n, m, i, sum_n[9], sum_m[9];
	char c[9][15];
	
	for (i = 0; i < 9; i++){
		scanf("%s %d %d", c[i], &n, &m);
		sum_n[i] = n + m;
		sum_m[i] = n * 200 + m * 300;
	}
	
	for (i = 0; i < 9; i++){
		printf("%s %d %d\n", c[i], sum_n[i], sum_m[i]);
	}
	
	return (0);
}

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

int main() {
  int N, M;
  cin >> N;
  vector<string> S(N);
  for (int i = 0; i < N; i++) cin >> S[i];
  cin >> M;
  vector<string> T(M);
  for (int i = 0; i < M; i++) cin >> T[i];

  map<string, int> m;
  for (string s : S) m[s]++;
  for (string s : T) m[s]--;
  int ans = 0;
  for (auto it = m.begin(); it != m.end(); it++) {
    ans = max(it->second, ans);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int parent(int i){
  return i/2;
}
int left(int i){
  return 2*i;
}
int right(int i){
  return 2*i+1;
}

int main(){
  int H, i, j, a[250];
  scanf("%d", &H);

  for(i=1;i<=H;i++){
    scanf("%d", &a[i]);
  }
  for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,a[i]);
    if(i!=1){
      printf("parent key = %d, ",a[parent(i)]);
    }
    if(left(i)<=H){
      printf("left key = %d, ", a[left(i)]);
    }
    if(right(i)<=H){
      printf("right key = %d, ", a[right(i)]);
    }
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2048
n = int(input());
a = list(map(int,input().split()))

ans = 0;
s = [0]*(n+1);
m = {};
for i in range(0,n):
  s[i+1] = s[i]+a[i];
for i in range(0,n+1):
  m.setdefault(s[i],0);
  m[s[i]]+=1;
for v in m.values():
  ans += v*(v-1)//2
print(ans);

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

int main() {

    int r;
    cin >> r;

    long double ans;

    ans = 2 * PI * r;
    cout << ans << endl;
}   

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

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  ll x = c-a-b;
  if (x < 0) {
    cout << "No" << endl;
    return 0;
  }
  if (4*a*b < x*x) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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

using namespace std;

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

    vector<int> v(n);
    for (int i = 0; i < n; i++) cin >> v[i];
    int total = 0;
    for (int i : v) total ^= i;

    vector<int> res(n, 0);
    for (int i = 0; i < n; i++) res[i] = total ^ v[i];

    for (int i : res) cout << i << " ";
    cout << endl;
}

Measured memory_bytes: 4756
"""/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Union-Find！Union-Find！Union-Find！Union-Findぅぅうううわぁああああああああああああああああああああああん！！！
あぁああああ…ああ…あっあっー！あぁああああああ！！！Union-FindUnion-FindUnion-Findぅううぁわぁああああ！！！
あぁクンカクンカ！クンカクンカ！スーハースーハー！スーハースーハー！いい匂いだなぁ…くんくん
んはぁっ！Union-Findたんの桃色ブロンドの髪をクンカクンカしたいお！クンカクンカ！あぁあ！！
間違えた！モフモフしたいお！モフモフ！モフモフ！髪髪モフモフ！カリカリモフモフ…きゅんきゅんきゅい！！
小説12巻のUnion-Findたんかわいかったよぅ！！あぁぁああ…あああ…あっあぁああああ！！ふぁぁあああんんっ！！
アニメ2期放送されて良かったねUnion-Findたん！あぁあああああ！かわいい！Union-Findたん！かわいい！あっああぁああ！
コミック2巻も発売されて嬉し…いやぁああああああ！！！にゃああああああああん！！ぎゃああああああああ！！
ぐあああああああああああ！！！コミックなんて現実じゃない！！！！あ…小説もアニメもよく考えたら…
U n i o n - F i n d ち ゃ ん は 現 実 じ ゃ な い？にゃあああああああああああああん！！うぁああああああああああ！！
そんなぁああああああ！！いやぁぁぁあああああああああ！！はぁああああああん！！う　し　た　ぷ　に　き　あ　王　国　笑ぁああああ！！
この！ちきしょー！やめてやる！！現実なんかやめ…て…え！？見…てる？表紙絵のUnion-Findちゃんが僕を見てる？
表紙絵のUnion-Findちゃんが僕を見てるぞ！Union-Findちゃんが僕を見てるぞ！挿絵のUnion-Findちゃんが僕を見てるぞ！！
アニメのUnion-Findちゃんが僕に話しかけてるぞ！！！よかった…世の中まだまだ捨てたモンじゃないんだねっ！
いやっほぉおおおおおおお！！！僕にはUnion-Findちゃんがいる！！やったよdefault dict！！ひとりでできるもん！！！
あ、コミックのUnion-Findちゃああああああああああああああん！！いやぁあああああああああああああああ！！！！
あっあんああっああんあset様ぁあ！！さ、最小全域木ー！！Dijkstraぁああああああ！！！セグ木ぃいいい！！
ううっうぅうう！！俺の想いよUnion-Findへ届け！！う　し　た　ぷ　に　き　あ　王　国　笑のUnion-Findへ届け！
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////"""
class UnionFind():
    def __init__(self, n):
        self.parents = list(range(n))
        self.size = [1] * n
    def find(self, x):
        if self.parents[x] == x:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.size[x] < self.size[y]:
            self.size[y] += self.size[x]
            self.parents[x] = y
        else:
            self.size[x] += self.size[y]
            self.parents[y] = x
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    def group_count(self):
        return len(self.roots())
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
n,m,k=map(int,input().split())
uf=UnionFind(n)
friends=[0]*n
for i in range(m):
    a,b=map(int,input().split())
    uf.union(a-1,b-1)
    friends[a-1]+=1
    friends[b-1]+=1
block=[[] for _ in range(n)]
for i in range(k):
    c,d=map(int,input().split())
    block[c-1].append(d)
    block[d-1].append(c)
ans=[0]*n
cnt=[0]*n
for i in range(n):
    cnt[i]=uf.find(i)
for i in range(n):
    num1=uf.size[uf.find(i)]-friends[i]-1
    num2=cnt[i]
    for j in range(len(block[i])):
        if num2==cnt[block[i][j]-1]:
            num1-=1
    ans[i]=num1
print(*ans)


Measured memory_bytes: 36392
#include<iostream>
#include <cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<utility>
#include<queue>

#define REP(i,n) for(int i = 0;i < n ;i++)
#define pa pair<int,int>
#define pq queue< pair<int,int> >
	

using namespace std;

int w,h;
char mp[22][22];
bool dp[22][22];
int dx[]={1,0,-1,0},dy[] = {0,1,0,-1};
int sx,sy;
int cou;

int main()
{
	for(;;)
	{
		cin >> w >>h;
		if(w == 0 && h == 0) break;
		cou = 1;sx = 0;sy = 0;
		REP(i,22)REP(j,22)dp[i][j] = 0;
		
		REP(i,h)REP(j,w)
		{
			cin >> mp[i][j];
			if(mp[i][j] == '@'){sx = i;sy = j;}
		}
		
		pq p;
		p.push(make_pair(sx,sy));
		dp[sx][sy] = 1;
//		cout << sx << ' '<<sy<<endl;
		while(!p.empty())
		{
			pa t = p.front();p.pop();
			REP(i,4)
			{
				int cx = t.first+dx[i],cy = t.second+dy[i];
				if(cx >= 0 && cx < h && cy >= 0 && cy < w)
				if( dp[cx][cy] == 0&& mp[cx][cy] != '#')
				{
//					cout << cx << ' ' <<cy << endl;
					p.push(make_pair(cx,cy));
					dp[cx][cy] = 1;
					cou++;
				}
			}
		}
		
			
		
		cout << cou << endl;
	}
	return 0;
}
		
		
	

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

typedef long long      ll;
typedef vector<int>    vi;
typedef vector<string> vs;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n)    FOR(i, 0, n)
#define pb           push_back
#define all(a)       (a).begin(), (a).end()
#define UNIQUE(v)    v.erase(unique(all(v)), v.end());
#define fill(a, x)   memset(a, x, sizeof(a))
#define zero(a)      fill(a, 0)
#define minus(a)     fill(a, -1)
#define dbg(x)       cout << #x "=" << x << endl

int top, stk[1000];

int calculate(string o, int a, int b) {
  if (o == "+") {
    return a + b;
  }
  if (o == "-") {
    return a - b;
  }
  if (o == "/") {
    return a / b;
  }
  return a * b;
}

bool isOperator(string c) {
  return c == "+" || c == "-" || c == "*" || c == "/";
}

void push(int num) {
  top++;
  stk[top] = num;
}

int pop() {
  int ret = stk[top];
  for (int i = top; i >= 1; i--) {
    stk[i] = stk[i - 1];
  }
  return ret;
}

int main() {
  string a[1000];

  top = 0;
  string op;

  while (cin >> op) {
    if (isOperator(op)) {
      int b = pop();
      int c = pop();
      int res = calculate(op, c, b);
      push(res);
    } else {
      push(atoi(op.c_str()));
    }
  }

  cout << stk[top] << endl;

  return 0;
}



Measured memory_bytes: 3188
#coding: utf-8
def solve():
    for ac in xrange(q2, 0, -1):
        nc = (b - c1 * ac) / c2
        if nc >= 0 and nc + ac >= q1:
            return "{} {}".format(ac, nc)
    return "NA"
    
while True:
    data = raw_input().strip()
    if data == "0":
        break
    q1, b, c1, c2, q2 = map(int, data.split())
    print solve()

Measured memory_bytes: 4200
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD=1000000007;

int main() {
    int N; cin>>N;
    vector<ll> A(N,0);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    int ans=0;
    int now=0;
    for(int i=1;i<N;i++){
        if(A[i]>A[i-1]){
            if(now==1){
                ans++;
                now=0;
                continue;
            }
            now=-1;
        }
        else if(A[i]<A[i-1]){
            if(now==-1){
                ans++;
                now=0;
                continue;
            }
            now=1;
        }
    }
    cout<<ans+1;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>

int main(){
    
    char num[999];
    int sum=0;
    while(1){
        scanf("%s",num);
        sum=0;
        if(num[0]=='0')break;
        int i,sz=strlen(num);
        for(i=0;i<sz;i++){
            sum+=num[i]-'0';
        }
        printf("%d\n",sum);
    }
    
    
    return 0;
}



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

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

    if(S % 10 == 1){
        cout << "pon" << endl;
    }
    if(S % 10 == 6){
        cout << "pon" << endl;
    }
    if(S % 10 == 8){
        cout << "pon" << endl;
    }
    if(S % 10 == 0){
        cout << "pon" << endl;
    }
    if(S % 10 == 3){
        cout << "bon" << endl;
    }
    if(S % 10 == 2){
        cout << "hon" << endl;
    }
    if(S % 10 == 4){
        cout << "hon" << endl;
    }
    if(S % 10 == 5){
        cout << "hon" << endl;
    }
    if(S % 10 == 7){
        cout << "hon" << endl;
    }
    if(S % 10 == 9){
        cout << "hon" << endl;
    }

}


Measured memory_bytes: 3544
/*
    PROG: milk2
	LANG: C++14
	ID: ashikuj1
*/

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

#define mod (ll) (1e9)
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define pb push_back
#define make_pair mp
#define pi acos(-1)
#define N (int)3e5


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


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

   int n,count=0;
   cin>>n;
   string s;
   cin>>s;
   for(int i=0;i<n;i++)
   {
       if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
       {
           count++;
       }
   }
   cout<<count<<endl;

}


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

int main() {
  int l = 1, r = 0, n, k;

  cin >> n >> k;

  vector<int> a(n,0);
  
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    r = max(r, a[i]);
  }

  while(r > l) {
    int x = l + (r - l) / 2, c = 0;

    for(int i = 0; i < n; i++)
      c += (a[i] - 1) / x;
    
    if(c <= k)
      r = x;
    else
      l = x + 1;
  }

  cout << r;

  return 0;
}

Measured memory_bytes: 4040
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <string>
using namespace std;

int main() {
	int n;
	cin >> n;
	string s[100];
	int p[100];
	for (int i = 0; i < n; i++) {
		cin >> s[i] >> p[i];
	}
	int num[101];
	for (int i = 0; i < n; i++) {
		num[i] = i + 1;
	}
	for (int i = 1; i < n; i++) {
		for (int j = i - 1; j >= 0; j--) {
			if (s[j] > s[j + 1]) {
				string h;
				h = s[j];
				s[j] = s[j + 1];
				s[j + 1] = h;
				int g;
				g = num[j];
				num[j] = num[j + 1];
				num[j + 1] = g;
				int f;
				f = p[j];
				p[j] = p[j + 1];
				p[j + 1] = f;
			}
			else if (s[j] == s[j + 1] && p[j] < p[j + 1]) {
				int g;
				g = num[j];
				num[j] = num[j + 1];
				num[j + 1] = g;
				int f;
				f = p[j];
				p[j] = p[j + 1];
				p[j + 1] = f;
			}
			
			
			else break;
		}
		
	}
	
	for (int i = 0; i < n; i++) {
		cout << num[i] << endl;
	}



	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<map>
using namespace std;
typedef long long LL;

int main()
{
	int n;
	cin >> n;
	if(n < 3) cout << 0 << endl;
	else cout << n / 3 << endl;
	return 0;
}

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

int main()
{
	int a, b;
	cin >> a >> b;
	cout << a / b << " " << a % b << " ";
	cout << fixed;
	cout.precision(5);
	cout << (double)a / (double)b << endl;

	return 0;
}


Measured memory_bytes: 3256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll m, t, p, r;

bool ff(const pair<P, ll> p1, const pair<P, ll> p2) {
	if (p1.first.first == p2.first.first) {
		if (p1.first.second == p2.first.second) {
			return p1.second > p2.second;
		}
		return p1.first.second < p2.first.second;
	}
	return p1.first.first > p2.first.first;
}

int main() {
	while (cin >> m >> t >> p >> r&&m + t + p + r) {
		bool f[51][11] = {};
		ll ti[51][11] = {};
		rep(i, r) {
			ll mm, tt, pp, jj;
			cin >> mm >> tt >> pp >> jj;
			tt--;
			pp--;
			if (jj == 0) {
				f[tt][pp] = 1;
				ti[tt][pp] += mm;
			}
			else {
				ti[tt][pp] += 20;
			}
		}
		ll cnt[51] = {};
		ll sum[51] = {};
		vector<pair<P, ll>> vpl;
		rep(i, t) {
			rep(j, p) {
				cnt[i] += f[i][j];
				if (f[i][j])sum[i] += ti[i][j];
			}
			vpl.push_back({ P(cnt[i],sum[i]),i + 1 });
		}
		sort(ALL(vpl), ff);
		rep(i, vpl.size()) {
			if (i != 0) {
				if (vpl[i-1].first.first == vpl[i].first.first&&
					vpl[i-1].first.second == vpl[i].first.second) {
					cout << "=";
				}
				else cout << ",";
			}
			cout << vpl[i].second;
		}
		cout << endl;
	}
}


Measured memory_bytes: 3100
# coding: utf-8
s=input()
ans='AKIHABARA'
make=''
p=0
for i in range(len(ans)):
    if p<len(s) and s[p]==ans[i]:
        make+=s[p]
        p+=1
    elif ans[i]=='A':
        make+='A'
if p!=len(s) or make!=ans:
    print('NO')
else:
    print('YES')

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main() {
  double a, b, C;
  double S, L, h;
  cin >> a >> b >> C;

  double D = acos(-1.0) * C /180.0;
  S = a * b * sin(D) / 2.0;
  L = a + b + sqrt(a*a + b*b -2*a*b*cos(D));
  h = b*sin(D);

  printf("%lf\n%lf\n%lf\n",S, L, h);

  return 0;
}

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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);++i)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) ( ((x)&1)==0?0:1 )
#define SIGN(x) ( ((x) > 0) - ((x) < 0)  )
#define dbg(x) cerr << #x"= " << x << endl

std::mt19937_64  generator(std::chrono::system_clock::now().time_since_epoch().count());

inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a, ll b) { return a ? gcd(b%a, a): b; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }


void READ(bool _local){
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _DEBUG
    if (_local)
        freopen ("in.txt", "r", stdin);
#endif
}

int main() {
    READ(0);
    int n,a,b;cin>>n>>a>>b;
    ll ret= powmod(2,n,MOD)-1;
    ll fa = 1;
    for(int i=2;i<=a;++i) fa = (fa * i)%MOD;
    ll fb = fa;
    for(int i=a+1;i<=b;++i) fb = (fb*i)%MOD;
    ll ncra = 1;
    for(int j=n;j>n-a;--j) ncra = (ncra*j)%MOD;
    ll ncrb = ncra;
    for(int j=n-a;j>n-b;--j) ncrb = (ncrb*j)%MOD;
    ret -= (ncra * powmod(fa,MOD-2,MOD))%MOD;
    if (ret<0) ret += MOD;
    ret -= (ncrb*powmod(fb,MOD-2,MOD))%MOD;
    if (ret<0) ret += MOD;
    cout << ret;

    return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class PaizaSample
{

    static int pow(int x, int y)
    {
        int a = 1;
        for (int i = 0; i < y; i++)
        {
            a *= x;
        }

        return a;
    }


    static void Main()
    {


        int[] nt = Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        int n = nt[0];
        int t = nt[1];

        string[] fn = Console.ReadLine().Split('+').ToArray();

        int result = 0;
        bool flag = true;
        foreach (string f in fn)
        {
            int num = int.Parse(f.Split('^')[1]);
            if (9 < num * Math.Log10(n) + Math.Log10(t))
            {
                flag = false;
                break;
            }
            else
            {
                result += pow(n, num) * t;
            }

            if (9 < Math.Log10(result))
            {
                flag = false;
                break;
            }

        }

        if (flag)
        {
            Console.WriteLine(result);
        }
        else
        {
            Console.WriteLine("TLE");
        }
            
        Console.ReadKey();

    }
}

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

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define int long long

using namespace std;

using P = pair<int, int>;
using ll = long long;

const long long INF = LLONG_MAX/3;
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

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

class UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
public:
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[a]+=siz[b];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}
bool isbig(string a,string b){
	if(a.size()>b.size())return true;
	else if(a.size()<b.size())return false;
	else {
		if(a>b)return true;
		else return false;
	}
}
signed main(){
	int need[9]={2,5,5,4,5,6,3,7,6};
	int n,m;
	cin>>n>>m;
	int a[10];
	rep(i,m)cin>>a[i];
	string dp[11000];
	rep(i,11000){
		dp[i]="";
	}
	rep(i,11000){
		if(i!=0&&dp[i]=="")continue;
		rep(j,m){
			if(i+need[a[j]-1]<11000){
				if(isbig(dp[i]+to_string(a[j]),dp[i+need[a[j]-1]]))dp[i+need[a[j]-1]]=dp[i]+to_string(a[j]);
			}
		}
	}
	cout<<dp[n]<<endl;
}

Measured memory_bytes: 41984
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9)+7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";
const double PI = acos(-1);

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n) {
  vector< pair<ll, ll> > p;
  for (ll i = 2; i * i <= n; i++) {
    if ((n % i) != 0) continue;
    p.push_back(make_pair(i, 0));
    while ((n % i) == 0) {
      n /= i;
      p[i].second += 1;
    }
    p.push_back(make_pair(n, 0));
  }

  if (n != 1) p.push_back(make_pair(n, 1));
  return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a) {
	ll b = MOD, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b;
		swap(a, b);
		u -= t * v;
		swap(u, v);
	}
	u %= MOD;
	if (u < 0) { u += MOD; }
	return u;
}
// 順列
ll permutation(const ll n, const ll m) {
	ll result = 1;
	for (ll i = n; i > n - m; i--) { result = (result * i) % MOD; }
	return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x) {
	if (x == 0) return 1;
	ll res = repeat_square(n, x/2);
	res = res * res % MOD;
	if ((x % 2) == 1) res = res * n % MOD;
  return res;
}
// 組み合わせ nCm
ll combination(ll n, ll m) {
	ll p = permutation(n, m);
	ll div = 1;
	for (ll i = 2; i <= m; i++) {
		div = (div * i) % MOD;
	}
	return (p * modinv(div)) % MOD;
}

int main() {
	int N;
	ll C, K;
	cin >> N >> C >> K;
	vector<ll> T(N);

	rep(i, N) {
		cin >> T[i];
	}

	sort(T.begin(), T.end());
	ll result = 0;
	ll a = T[0];
	ll wait = 1;
	rep(i, 1, N) {
		// cout << "Ti: " << T[i] << ", w: " << wait << ", re: " << result << ", a = " << a+K << endl; 
		if ((T[i] > a + K) || (wait == C)) {
			result += 1;
			wait = 1;
			a = T[i];
			continue;
		}
		wait += 1;
	}

	if (wait > 0) result += 1;

	cout << result << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int s,w;
    cin >> s >> w;
    if(w>=s)cout << "unsafe" << endl;
    else cout << "safe" << endl;
}

Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <vector>
#include <complex>

using namespace std;

int d,g;
int p[11][2];
int minn = 1000;

int getCnt(int bonus)
{
    //cout << "bonus: " << bonus << endl;

    int ncnt = 0;
    int point = 0;
    for(int i=0; i<d; i++)
    {
        if(bonus & (1 << i)){
            ncnt += p[i][0];
            point += p[i][1];
            point += 100 * (i + 1) * p[i][0];
        }
    }

    if(point >= g) return ncnt;
    else{
        for(int i=d-1; i>=0; i--)
        {
            //cout << point << " " << ncnt << endl;

            if(bonus & (1 << i)) continue;
            for(int j=0; j<p[i][0]; j++)
            {
                point += (i + 1) * 100;
                ncnt++;
                if(point >= g)
                {
                    //cout << point << " " << ncnt << endl;
                    return ncnt;
                }
            }
        }
    }
    return -1;
}

int main() {

    cin >> d; cin >> g;

    for(int i=0; i<d; i++)
    {
        cin >> p[i][0]; cin >> p[i][1];
    }

/*
    for(int i=0; i<d; i++)
    {
        int maxI = i;
        for(int j=i; j<d; j++)
        {
            if(p[j][0] > p[maxI][0]) maxI = j;
        }
        auto tmpP = p[i][0];
        auto tmpC = p[i][1];
        p[i][0] = p[maxI][0];
        p[i][1] = p[maxI][1];
        p[maxI][0] = tmpP;
        p[maxI][1] = tmpC;
    }
    */

    for(int i=0; i<=pow(2, d); i++)
    {
        int cnt = getCnt(i);
        if(cnt > 0) minn = min(cnt, minn);
    }

    cout << minn << endl;

    return 0;
}

Measured memory_bytes: 512
// g++ -std=gnu++1y -O2 xxx.cpp

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

int main() {
    string S; cin>>S;

    for (int i=0;i<S.length();i++) {
        cout << 'x';
    }

    cout << endl;

    return 0;
}

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

template<class like_bool> inline void YES(like_bool condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class like_bool> inline void Yes(like_bool condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class like_bool> inline void POSS(like_bool condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class like_bool> inline void Poss(like_bool condition){ if(condition)cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class like_bool> inline void First(like_bool condition){ if(condition)cout << "First" << endl; else cout << "Second" << endl; }
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
long gcd(long a, long b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcount(n)

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> degrees(N, 0);
    for(int i = 0; i < M; i++){
        int a, b;
        cin >> a >> b;
        if(a == 1){
            degrees[b - 1]++;
        }else if(b == N){
            degrees[a - 1]++;
        }
    }
    for(int i = 0; i < N; i++){
        if(degrees[i] == 2){
            POSS(true);
            return 0;
        }
    }
    POSS(false);
}


Measured memory_bytes: 1024
#include<stdio.h>

int main(void)
{
    int h,w;
    do{
    scanf("%d %d",&h,&w);
    for(int i=0;i<h;i++){
    	for(int j=0;j<w;j++){printf("#");}
    printf("\n");
    }
   	if(h!=0 && w!=0)printf("\n");
    }while(h!=0 || w!=0);
    
    return 0;

}


Measured memory_bytes: 2100
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1e18;
#define Pint pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rnr(i,a,b) for(int i=int(a);i>=int(b);i--)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    int n; cin >> n;
    if(n >= 30) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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

const int N=500005,INF=0x3f3f3f3f;
int n,a[N],sz[N],lst[N];
int v[N],nxt[N],head[N];
long long dp[N],ans[N];
bool vis[N];

void dfs1(int x,int fa)
{
	sz[x]=1;
	for(int i=head[x];i>0;i=nxt[i])
	{
		if(v[i]==fa) continue;
		dfs1(v[i],x),sz[x]+=sz[v[i]];
	}
	dp[x]=sz[x];
}

void dfs2(int x,int fa)
{
	int ls=lst[a[x]];
	dp[lst[a[x]]]-=sz[x];
	for(int i=head[x];i>0;i=nxt[i])
	{
		if(v[i]==fa) continue;
		lst[a[x]]=v[i],dfs2(v[i],x);
	}
//	cout<<x<<' '<<fa<<' '<<sz[x]<<' '<<lst[a[x]]<<' '<<dp[x]<<endl;
	lst[a[x]]=ls,ans[a[fa]]+=dp[x]*(dp[x]+1)/2;
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<n;i++)
	{
		scanf("%d%d",&v[i],&v[i+n]);
		nxt[i]=head[v[i+n]],head[v[i+n]]=i;
		nxt[i+n]=head[v[i]],head[v[i]]=i+n;
	}
	for(int i=1;i<=n;i++) lst[i]=i+n,dp[i+n]=n;
	dfs1(1,0),dfs2(1,0);
	for(int i=1;i<=n;i++) ans[i]+=dp[i+n]*(dp[i+n]+1)/2;
//	for(int i=1;i<=n+n;i++) cout<<i<<' '<<dp[i]<<endl;
	for(int i=1;i<=n;i++) printf("%lld\n",1ll*n*(n+1)/2-ans[i]);
}

Measured memory_bytes: 30272
#include<iostream>
#include<iomanip>
#include<vector>
#include<queue>
#include<list>
#include<stack>
#include<algorithm>
#include<cmath>
#include<memory>
#include<array>

using namespace std;

int n, s;

int count( int x, int d, int z )
{
  int ret = 0;
  
  if ( z < 0 )
    return 0;

  if ( x == n )
    if ( d == z )
      return 1;
    else
      return 0;

  for ( int i = d + 1; i <= 9; ++i )
    ret += count( x + 1, i, z - d );

  return ret;
}

int main()
{
  while( cin >> n >> s && ( n != 0 || s != 0 ) )
    {
      int ret = 0;
      
      for ( int i = 0; i <= 9 ; ++i )
        ret += count( 1, i, s );
      
      cout << ret << endl;
    }
  
  return 0;
}

Measured memory_bytes: 1156
package main

import (
	"fmt"
)

func main() {
	var n string
	fmt.Scanf("%s", &n)

	ans := "No"
 	sum := 0
  	for _, v := range n{
      	sum += int(v)-48
	}
    if sum % 9 == 0{
      	ans = "Yes"
    }
	fmt.Printf("%s\n", ans)
}


Measured memory_bytes: 3284
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

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

	public static void solve() {
  	Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int r = sc.nextInt();   
		int g = sc.nextInt(); 
		int b = sc.nextInt();
		sc.close();
		if((r*100+g*10+b) % 4 == 0){
			out.println("YES");
		}else{
			out.println("NO");
		}
		out.flush();
	}
}

Measured memory_bytes: 21716
from collections import Counter
H, W, M = map(int, input().split())
h = [0] * M
w = [0] * M
h_w = {}
for i in range(M):
    h[i], w[i] = map(int, input().split())
    h_w[(h[i], w[i])] = 1
hl = Counter(h)
hl = list(reversed(sorted(hl.items(), key=lambda x:x[1])))
wl = Counter(w)
wl = list(reversed(sorted(wl.items(), key=lambda x:x[1])))
ans = 0
#print(hl)
#print(wl)
max_hl = hl[0][1]
max_wl = wl[0][1]
ans = max_hl + max_wl
end_flag = 0
max_flag = 1
for i in range(len(hl)):
    for j in range(len(wl)):
        if hl[i][1] < max_hl:
            end_flag = 1
            break
        if wl[j][1] < max_wl:
            break
        if (hl[i][0], wl[j][0]) in h_w.keys():
            continue
        else:
            end_flag = 1
            max_flag = 0
            break
    else:
        continue
    if end_flag == 1:
        break
print(ans - max_flag)


Measured memory_bytes: 228616
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(),(x).end()
using ll = long long;
using namespace std;
using gragh = vector<vector<int>>;

int main() {
    string S;
    cin>>S;

    if(S=="SUN"){
        cout<<7<<endl;}
    else if(S=="MON"){
        cout<<6<<endl;
        }else if(S=="TUE"){
        cout<<5<<endl;}
    else if(S=="WED"){
        cout<<4<<endl;}
    else if(S=="THU"){
        cout<<3<<endl;}
    else if(S=="FRI"){
        cout<<2<<endl;}
    else if(S=="SAT") {
        cout << 1 << endl;
    }
}


Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
typedef vector<ll> vec;
typedef vector<vec> mat;
mat mult(mat &A, mat &B){
    mat C(A.size(), vec(B[0].size(),0));
    rep(i,0,A.size()){
        rep(k,0,B.size()){
            rep(j,0,B[0].size()){
                C[i][j] += A[i][k] * B[k][j] % MOD;
                C[i][j] %= MOD;
            }
        }
    }
    return C;
}

mat pow_mat(mat A, ll n){
    if(n == 1) return A;
    if(n % 2 == 0){
        mat B = pow_mat(A, n/2);
        return mult(B,B);
    }else{
        mat B = pow_mat(A, n-1);
        return mult(A,B); 
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K;
    cin >> N >> K;
    mat A(N, vec(N,0));
    rep(i,0,N){
        rep(j,0,N){
            cin >> A[i][j];
        }
    }
    mat res = pow_mat(A, K);
    ll ans = 0;
    rep(i,0,N){
        rep(j,0,N){
            ans += res[i][j];
            ans %= MOD;
        }
    }
    print(ans);



    

}

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

int main(){
    vector<string> s = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    string today;
    cin >> today;
    rep(i, 7) if(today == s[i]) cout << 7-i << endl;
    return 0;
}

Measured memory_bytes: 256