akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<string>
#include<set>
using namespace std;
#define rep(i, a, n) for (int i = a; i < n; i++)
typedef long long ll;
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){//A
/*
    int n,x,t;
    cin>>n>>x>>t;
    int c;
    if(n%x==0){
        c=int(n/x);
    }
    else{
        c=int(n/x)+1;
    }
    cout<<c*t<<endl; 
    */
   //B
   string n;
   cin>>n;
   int len=n.length();
   ll c=0;
   rep(i,0,len){
       c+=ctoi(n[i]);
   }
    if(c%9==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}

Measured memory_bytes: 3716
// B - Frog 2
#include <bits/stdc++.h>
using namespace std;

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

	vector<int> h(N); for(int i=0; i<N; i++) cin>>h[i];

	vector<int> dp(N);
	for(int n=1; n<N; n++){
		int m = INT_MAX;
		for(int k=1; k<=min(n,K); k++) m = min(m, dp[n-k] + abs(h[n] - h[n-k]));
		dp[n] = m;
	}
	cout<< dp[N-1] <<endl;
}

Measured memory_bytes: 1024
s = gets.chomp.split("")
count_g = 0
count_p = 0
win = 0
lose = 0

s.each do |item|
    if count_p < count_g then
        win += 1 if item == "g"
        count_p += 1
    else
        lose += 1 if item == "p"
        count_g += 1
    end
end

puts win - lose

Measured memory_bytes: 21896
a[100],v,j,k,n;p(){for(k=0;k<n;printf("%d%s",a[k++],k-n+1?" ":"\n"));}main(i){scanf("%d",&n);for(;j<n;scanf("%d",&a[j++]));p();for(;i<n;i++){v=a[i];j=i-1;for(;/*j+1&&*/a[j]>v;a[j+1]=a[j--]);a[j+1]=v;p();}exit(0);}

Measured memory_bytes: 600
m,d=map(int,input().split())

if m<=3:
    print(0)
else:
    ans=0
    for i in range(4, m+1):
        for j in range(2, i):
            if i%j==0:
                if len(str(j))==1 and len(str(i//j))==1 and 10*j+i//j<=d:
                    ans+=1
    print(ans)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, N) for (int i = 0; i < N; i++)
#define vec vector<int>
using namespace std;
int main()
{
    string a, b;
    cin >> a >> b;
    int ab = stoi(a + b);
    for (int i = 1; i <= 1000; i++)
    {
        if (ab == i * i)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
#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(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int A, B;
	set<int> ss;
	cin >> A >> B;
	REP(i, 3) ss.insert(i + 1);
	ss.erase(A);
	ss.erase(B);
	cout << *ss.begin() << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int n,k,d,a,i,j,sum=0;
  int sunuke[101];
  scanf("%d%d",&n,&k);
  for(i=0;i<101;i++){
    sunuke[i]=0;
  }
  for(i=0;i<k;i++){
    scanf("%d",&d);
    for(j=0;j<d;j++){
      scanf("%d",&a);
      sunuke[a]++;
    }
  }
  for(i=1;i<=n;i++){
    if(sunuke[i]==0){
      sum++;
    }
  }
  printf("%d\n",sum);
  return 0;
}


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


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

  int ans = 0;
  if (s == "RSS") ans = 1;
  else if (s == "SRS") ans = 1;
  else if (s == "SSR") ans = 1;
  else if (s == "RRS") ans = 2;
  else if (s == "RSR") ans = 1;
  else if (s == "SRR") ans = 2;
  else if (s == "RRR") ans = 3;

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

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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; }

int main(){
    int a,b;
    cin>>a>>b;
    if(a<=9 && b<=9) cout<<a*b<<endl;
    else cout<<-1<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
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; }
//#define int long long

void solve() {
	int n; string s, t; cin >> n >> s >> t;
    string ans;
    rep(i, n) {
        ans += s[i];
        ans += t[i];
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
ll llmax = LLONG_MAX;
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
vi d1 = {1, 0, -1, 0}, d2 = {0, 1, 0, -1};
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}

int main() {
  ll n, m, p = 1000000007;
  cin >> n >> m;
  vll a(m), check(100001, 0);
  for (ll i = 0; i < m; i++) {
    cin >> a[i];
    check[a[i]] = 1;
  }
  vll dp(100001, 0);
  dp[0] = 1;
  if (check[1] == 0) dp[1] = 1;
  for (ll i = 2; i <= n; i++) {
    if (check[i] == 1) continue;
    dp[i] += dp[i - 1] + dp[i - 2];
    dp[i] %= p;
  }
  cout << dp[n] << endl;
}

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

int main() {
    char a,b; cin >> a >> b;
    if (a == 'H')
    {
        if (b == 'H')
        {
            cout << "H\n";
        } else {
            cout << "D\n";
        }
    } else {
        if (b == 'H')
        {
            cout << "D\n";
        } else {
            cout << "H\n";
        }
    }
    return 0;
}

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

using namespace std;

typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef complex<ld> pt;

int main() {
	ios::sync_with_stdio(0);
	int k, x; cin >> k >> x;
	for (int i = x - k + 1; i < x + k; i++) {
		cout << i << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

struct restaurant{
    string nam;
    ll id, point;
};

bool asc( const restaurant& left, const restaurant& right ) {
    return left.nam == right.nam ? left.point > right.point : left.nam < right.nam;
}

int main() {
    

    vector <restaurant> lis;
    ll n;
    cin >> n;
    for (ll i=0;i<n;i++){
        ll p;
        string s;
        cin >> s >> p;
        restaurant res;
        res.id = i;
        res.nam = s;
        res.point = p;
        lis.push_back(res);
    }
    sort(lis.begin(), lis.end(), asc);
    ll ans[101] = {};
    for(ll i=0;i<n;i++){
        ans[i] = lis[i].id + 1;
    }
    for (ll i=0;i<n;i++){
        cout << ans[i] << endl;
    }


}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void)

{
	double r;
	double menseki;
	double syuu;
	
	scanf("%lf",&r);
	
	menseki=r*r*3.14159265358979323846;
	syuu=r*2*3.14159265358979323846;
	
	printf("%lf %lf\n", menseki, syuu);
	
	return (0);
}

Measured memory_bytes: 648
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int dice;
int n;
vector<int> a;
vector<bool> memo;

bool solve(int curr)
{
    if(curr == n-1)
        return true;

    if(memo[curr])
        return false;
    memo[curr] = true;

    for(int i=1; i<=dice; ++i){
        int next = min(n-1, curr + i);
        next = max(0, min(n-1, next + a[next]));
        if(solve(next))
            return true;
    }

    return false;
}

int main()
{
    for(;;){
        cin >> dice >> n;
        if(dice == 0)
            return 0;

        a.assign(n+2, 0);
        for(int i=1; i<=n; ++i)
            cin >> a[i];
        n += 2;

        vector<bool> access(n, false);
        access[0] = true;
        queue<int> q;
        q.push(0);
        while(!q.empty()){
            int curr = q.front();
            q.pop();
            for(int i=1; i<=dice; ++i){
                int next = min(n-1, curr + i);
                next = max(0, min(n-1, next + a[next]));
                if(!access[next]){
                    access[next] = true;
                    q.push(next);
                }
            }
        }

        bool ok = true;
        for(int i=0; i<n; ++i){
            memo.assign(n, false);
            if(access[i] && !solve(i))
                ok = false;
        }

        if(ok)
            cout << "OK" << endl;
        else
            cout << "NG" << endl;
    }
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int a,b;
  cin>>a>>b;
  bitset<32>b1(a);
  bitset<32>b2(b);
  cout<<(b1&b2)<<endl;
  cout<<(b1|b2)<<endl;
  cout<<(b1^b2)<<endl;
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define pb push_back
#define mp make_pair
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
signed main()
{
    SPEED;   
  	string s;
  cin>>s;
  if(s[1]=='R')
    cout<<"ABC";
 	else
      cout<<"ARC";
}

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


int cnt(int n){
    int rtn = 0;
    for(int i = 1; i <= n; i++){
        if(n % i == 0) rtn++;
    }
    return rtn;
}

int main(){
    int n, ans = 0;
    cin >> n;

    for (int i = 1; i <= n; i++){
        if(i % 2 == 1){
            if(cnt(i) == 8) ans++;
            }
    }
    
    cout << ans << endl;

}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int N; cin >> N;
    vi A(N); REP(i, N) cin >> A[i];
    int ans = 0;
    for(int i = 0; i < N; i++)
    {
        for(int j = i+1; j < N; j++)
        {
            ans = max(ans, abs(A[i] - A[j]));
        }
    }
    cout << ans << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

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

int main(){
    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    int K;

    cin >> K;

    cout << a[K-1] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <numeric>
#include <string>
#include <functional>

using namespace std;

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

    long long ans=0;

    int maxh=*max_element(h.begin(),h.end());
    for(int i=0;i<maxh;i++){
        for(int start=0;start<N;start++){
            if(h[start]==0){continue;}
            bool is0=false;
            for(int k=start;k<N;k++){
                start=k;
                if(h[k]==0){is0=true;}
                else if(is0){start--;break;}
                else{h[k]--;}
            }
            ans++;
        }
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, Counter
from itertools import product, groupby, count
from math import pi
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = 10 ** 10


def main():
    N = int(input())
    A_list = list(map(int, input().split()))
    c = Counter(A_list)

    x = []
    for length, n in sorted(c.items(), key=lambda x: x[0], reverse=True):
        if n >= 4:
            x += [length] * 4
        elif n >= 2:
            x += [length] * 2
    x += [0] * 4
    print(x[0] * x[2])

if __name__ == '__main__':
    main()


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

using namespace std;
#define Real double
#define int long long

const int MAXN=100020;
int dp[100020]={0};
namespace SA{
	int rank[MAXN],tmp[MAXN];
	int n,k;
	bool compare_sa(int i,int j){
		if(rank[i]!=rank[j]) return rank[i] <rank[j];
		int ri=(i+k<=n) ?rank[i+k]:-1;
		int rj=(j+k<=n) ?rank[j+k]:-1;
		return ri<rj;
	}

	void createSA(const string &s,int *sa){
		n=s.size();
		for(int i=0;i<=n;i++){
			sa[i]=i;
			rank[i]=i<n?s[i]:-1;
		}
		for(k=1;k<=n;k*=2){
			sort(sa,sa+n+1,compare_sa);
			tmp[sa[0]]=0;
			for(int i=1;i<=n;i++){
				tmp[sa[i]]=tmp[sa[i-1]]+(compare_sa(sa[i-1],sa[i])?1:0);
			}
			for(int i=0;i<=n;i++) rank[i]=tmp[i];
		}
	}
}
int N;
vector<int> G[100020];
string e[200020];

int me[100020];
int saiki(int u){
//	cout<<u<<endl;
	if(u==N) return 1;
	if(me[u]>=0)return me[u];
int r=0;
	for(int i=0;i<G[u].size();i++){
		r+=saiki(G[u][i]);
		r %= 1000000007;
	} 
		me[u]=r;
	return r;

}
vector<int> ve;
int sa[MAXN];
signed main() {
	int t;
	cin>>t;

for(int i=0;i<t;i++){
	cin>>e[i];
}

string s;
cin>>s;
N=s.size();
SA::createSA(s,sa);
for(int i=0;i<100020;i++) me[i]=-1;
//for(int i=0;i<=N;i++) cout<<sa[i]<<" ";
//	cout<<endl;

//cout<<"s"<<esss
	int ch[30]={0};
	for(int i=0;i<N;i++) ch[s[i]-'a']++;
bool w=false;
int mo;
		for(int i=0;i<26;i++) if(ch[i]==100000){
			w=true;
			mo=i;
}

if(w){

for(int i=0;i<t;i++){
	for(int j=0;j<30;j++) ch[j]=0;
		for(int j=0;j<e[i].size();j++) ch[e[i][j]-'a']++;
			if(ch[mo]==e[i].size()) ve.push_back(e[i].size());
}

dp[0]=1;
for(int i=1;i<=100000;i++){
	for(int j=0;j<ve.size();j++){
		if(i<ve[j]) continue;
		dp[i] += dp[i-ve[j]];
		dp[i] %= 1000000007;
	}
}
cout<<dp[100000]<<endl;
return 0;

}

for(int i=0;i<t;i++){

int l=e[i].length();
	int ue=N+1;
	int si=0;
	int me;
	while(ue-si>1){
		me=(ue+si)/2;
		if(s.substr(sa[me])<e[i]) si=me;
		else ue=me;
	}
	int hanisi=ue;

	ue=N+1,si=0;
string ee=e[i];
ee[e[i].length()-1]++;
	while(ue-si>1){
		me=(ue+si)/2;
		if(s.substr(sa[me])>=ee) ue=me;
		else si=me;
	}
	int haniue=si;
//cout<<e[i]<<endl;
//cout<<"   "<<hanisi<<" "<<haniue<<endl;1
	for(int j=hanisi;j<=haniue;j++){
		G[sa[j]].push_back(sa[j]+l);
	//	cout<<sa[j]<<" "<<sa[j]+l<<endl;
	}

}

//cout<<"e"<<endl;


cout<<saiki(0)<<endl;
    return 0;

}


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

int main() {
  int n;
  bool check = 1;
  cin >> n;
  vector<int>num(n);
  for (int i = 0; i < n; i++) {
    cin >> num.at(i);
  }
  sort(num.begin(),num.end());
  
  for (int i = 0; i < n-1; i++) {
    if (num.at(i) == num.at(i+1)) {
      check = 0;
      cout << "NO";
      return 0;
    }
  } 
  cout << "YES";
}

Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;

const int M = 1546527;
const int L = 14;

char H[M][L];

int GetChar(char ch)
{
	if(ch == 'A')		return 1;
	else if(ch == 'C')	return 2;
	else if(ch == 'G')	return 3;
	else 				return 4;
}



long long GetKey(char str[])
{
	long long sum = 0, p = 1;
	for(int i = 0; i < strlen(str); i++)
	{
		sum += p * (GetChar(str[i]));
		p *= 5; 
	}
	return sum;
}

int h1(int key) {	return key % M;}
int h2(int key) { return 1 + (key%(M-1));}

bool find(char str[])
{
	long long key = GetKey(str), i = 0, h;
	while(1)
	{
		h = (h1(key) + i*h2(key)) % M;
		if(strcmp(H[h], str) == 0)	return true;
		else if(strlen(H[h]) == 0)  return false;
		i = i + 1;
	}
	return false;
}


int insert(char str[])
{
	int i = 0, h;
	long long key = GetKey(str);
	while(1)
	{
		h = (h1(key) + i * h2(key)) % M;
		if(strcmp(H[h], str) == 0)
			return 1;
		else if(strlen(H[h]) == 0)
		{
			strcpy(H[h], str);
			return 0;
		}
		
		i++;
	} 
	return 0;
}


int main ()
{
	int n;
	char str[L], com[L];
	scanf("%d", &n);
	for(int i = 0; i < n; i++)
	{
		scanf("%s %s", com, str);
		if(com[0] == 'i') insert(str);
		
		else 
		{
			if(find(str))
				printf("yes\n");
			else
				printf("no\n");
		}
	}
	return 0;
}


Measured memory_bytes: 23152
n,m = gets.chomp.split.map(&:to_i)
yakusu = []

for i in 1..(m**(1/2.0)).to_i
  if m % i == 0
    yakusu << i
    yakusu << m/i
  end
end
yakusu.sort! {|a, b| b <=> a }

yakusu.each do |num|
  if num <= m/n
    print(num)
    break
  end
end


Measured memory_bytes: 1916
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
  int N;
  scanf("%d", &N);
  
  int t[N], a[N];
  for(int i=0; i<N; i++)
    scanf("%d %d", &t[i], &a[i]);
  
  long long T, A, n;
  for(int i = 0; i < N; i++){
    if(i == 0)
      n = 1;
    else{
      long long x = T / t[i];
      long long y = A / a[i];
      if(T%t[i] != 0)
        x++;
      if(A%a[i] != 0)
        y++;
      
      n = max(x,y);
    }
    T = t[i] * n;
    A = a[i] * n;
  }
  printf("%lld", T+A);
  
  return 0;
}


Measured memory_bytes: 128
def b_in_row(row):
  return sum([1 if c == '#' else 0 for c in row])

def in_flag(value, flag):
  return bool((1 << value) & flag)

def count_removes(h, w, row_flag, col_flag):
  tbr = 0
  for row in range(h):
    if in_flag(row, row_flag):
      tbr += b_in_row(m[row])
    else:
      for col in range(w):
        if in_flag(col, col_flag):
          if m[row][col] == '#':
            tbr += 1
  return tbr

h, w, k = [int(x) for x in input().split()]

m = []
for _ in range(h):
  m.append(input())

black = sum([b_in_row(row) for row in m])

remove = black - k

ans = 0
for row_flag in range(1 << h):
  for col_flag in range(1 << w):
    tbr = count_removes(h, w, row_flag, col_flag)
    
    if tbr == remove:
      ans += 1

print(ans)


Measured memory_bytes: 9228
import java.util.Scanner;
class Main
{
    public static void main(String args[])
    {
	int a,b,d,r;
	double f;
	Scanner scan=new Scanner(System.in);
	a=scan.nextInt();
	b=scan.nextInt();
	d=a/b;
	r=a%b;
	f=(double)a/(double)b;
	System.out.printf("%d %d %.5f\n",d,r,f);
    }
}

Measured memory_bytes: 17344
N, A = map(int,input().split())
x = list(map(int,input().split()))

dp = [[[0]*(max(sum(x),N*A)+1) for k in range(N+1)] for l in range(N+1)]
# dp[i][j][k] := i番目まででj枚選んで和がkになる組み合わせの数
dp[0][0][0] = 1

for i in range(N):
    for j in range(N):
        for k in range(sum(x)+1):
            dp[i+1][j][k] += dp[i][j][k]
            if k-x[i] >= 0:
                dp[i+1][j+1][k] += dp[i][j][k-x[i]]

ans = 0
for k in range(1,N+1):
    ans += dp[N][k][A*k]
print(ans)


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

using namespace std;

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

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
using namespace std;
int main()
{
    char s1[100],s2[100];
    while(scanf("%s\n%s",s1,s2)!=EOF)
    {
        int len1=strlen(s1),len2=strlen(s2);
        int len=min(len1,len2);
        for(int i=0;i<len;i++)
            printf("%c%c",s1[i],s2[i]);
        for(int i=len;i<len1;i++)
            printf("%c",s1[i]);
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
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; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;


lint D, M, d, q;
lint decrease[26];
lint decrease_sum[26];
lint positive_sum = 0;
lint satis[365][26];
lint last[26];
lint t[365];
lint prv_score = 0;

lint downscore(lint passed) {
	lint sum = 0;
	REP(i, 26) {
		sum += decrease[i] * (passed - last[i]);
	}
	return -sum;
}

lint query(set<lint> app[26], lint d, lint q) {
	lint score = prv_score;
	score += satis[d][q] - satis[d][t[d]];
	score += decrease[q] * decrease_sum[q];
	score += decrease[t[d]] * decrease_sum[t[d]];
	app[t[d]].erase(d);
	app[q].insert(d);

	{
		decrease_sum[t[d]] = 0;
		lint prv = -1;
		for (auto itr : app[t[d]]) {
			lint k = itr - prv - 1;
			decrease_sum[t[d]] += k * (k + 1) / 2;
			prv = itr;
		}
		{
			lint k = D - prv - 1;
			decrease_sum[t[d]] += k * (k + 1) / 2;
		}
	}

	{
		decrease_sum[q] = 0;
		lint prv = -1;
		for (auto itr : app[q]) {
			lint k = itr - prv - 1;
			decrease_sum[q] += k * (k + 1) / 2;
			prv = itr;
		}
		{
			lint k = D - prv - 1;
			decrease_sum[q] += k * (k + 1) / 2;
		}	
	}
	score -= decrease[q] * decrease_sum[q];
	score -= decrease[t[d]] * decrease_sum[t[d]];

	app[q].erase(d);
	app[t[d]].insert(d);
	return score;
}


int main() {
	cin >> D;
	REP(i, 26) {
		cin >> decrease[i];
	}
	REP(i, D) {
		REP(j, 26) {
			cin >> satis[i][j];
		}
	}
	set<lint> app[26];
	REP(i, D) {
		cin >> t[i]; t[i]--;
		app[t[i]].insert(i);
	}
	REP(i, D) {
		positive_sum += satis[i][t[i]];
	}
	REP(i, 26) {
		vector<lint> vec;
		vec.push_back(-1);
		for (auto itr : app[i]) {
			vec.push_back(itr);
		}
		vec.push_back(D);
		REP(j, SZ(vec) - 1) {
			lint k = vec[j + 1] - vec[j] - 1;
			decrease_sum[i] += k * (k + 1) / 2;
		}
	}
	prv_score = positive_sum;
	REP(i, 26) prv_score -= decrease[i] * decrease_sum[i];

	cin >> M;
	REP(i, M) {
		cin >> d >> q; d--; q--;
		lint ans = query(app, d, q);
		cout << ans << endl;
		prv_score = ans;
		app[t[d]].erase(d);
		app[q].insert(d);
		t[d] = q;
	}
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int tmp = a - b;
  int mi = min(tmp, c);
  int ans = c - mi;
  cout << ans << endl;
}

Measured memory_bytes: 3588
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int n;
map<string,bool> ma;

void solve(){
    cin >> n;
    rep(i,n){
        string s;cin >> s;
        ma[s]=true;
    }
    int ans=0;
    for(auto m:ma){
        ans+=1;
    }
    cout << ans << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

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

int main()
{
  string O, S;
  cin >> O >> S;
  for (int i = 0; i < O.size(); i++)
  {
    if (O.size() - S.size() == 1 and i == O.size() - 1)
    {
      cout << O.at(i);
    }
    else
    {
      cout << O.at(i);
      cout << S.at(i);
    }
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=20000000000;
//setprecision(2) <<
typedef struct {
	int h;
	int w;
}Point;

long nCr(int n, int r) {
    long ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin>>n;
	int A[n+2];
	int B[n+1];
	for(int i=1;i<=n+1;i++)cin>>A[i];
	for(int i=1;i<=n;i++)cin>>B[i];
	
	long long ans=0;
	
	for(int i=1;i<=n;i++){
		if(A[i]<=B[i]){
			ans+=A[i];
			B[i]-=A[i];
			ans+=min(B[i],A[i+1]);
			A[i+1]-=min(B[i],A[i+1]);
		}else{
			ans+=B[i];
			B[i]=0;
		}
	}
	
	cout<<ans<<endl;
}
	


Measured memory_bytes: 1024
h,w = map(int, input().split(' '))
s = []
s0 = '.'*(w+2)
s.append(s0)
i = 0
while i < h:
    s0 = '.'+input()+'.'
    s.append(s0)
    i += 1
s0 = '.'*(w+2)
s.append(s0)
f0 = 0
h0 = 0
while h0 < len(s) and f0 == 0:
    slist = list(s[h0])
    indices = [i for i, x in enumerate(slist) if x == "#"]
    for ind in indices:
        if (s[h0][ind-1] == "." and s[h0][ind+1] == '.') and (s[h0-1][ind] == '.' and s[h0+1][ind] == '.'):
            f0 = 1
            break
    h0 += 1
if f0 == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int N;
int e[101];

int num(int m){ // e の要素のうち m - 1 以上のものの個数
	int res = 0;
	rep (i, N){
		res += (int)(e[i] >= m - 1);
	} // end rep
	return res;
}

int main()
{
	memset(e, 0, sizeof(e));
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> N;

	for (int i = 2; i <= N; ++i){
		int curr = i;
		for (int j = 2; j <= i; ++j){
			while(curr % j == 0){
				++e[j];
				curr /= j;
			} // end while
		} // end for
	} // end for

	int res = 0;
	res += num(75);
	res += num(25) * (num(3) - 1);
	res += num(15) * (num(5) - 1);
	res += num(5) * (num(5) - 1) / 2 * max(0, num(3) - 2);

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
def main(k):
  if k % 2 == 0:
    return -1

  num = 1
  cnt = 1
  if k % 7 == 0:
    k = k//7

  for i in range(1000000):
    num = num % k
    if num == 0:
      return cnt
    else:
      num += pow(10, cnt, k)
      cnt += 1
  return -1

k = int(input())
print(main(k))

Measured memory_bytes: 62892
package main
import (
  "fmt"
)
func main() {
  var n int
  fmt.Scan(&n)
  result := n
  for i := 0; i <= n; i++ {
    cnt := 0
    num := i
    for 0 < num {
      cnt += num%6
      num /= 6
    }
    num = n-i
    for 0 < num {
      cnt += num%9
      num /= 9
    }
    if cnt < result {
      result = cnt
    }
  } 
  fmt.Println(result)
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,N) for(ll i=0; i<N; i++)
using namespace std;
using ll = long long;
const ll MOD = 1000000007;

int main(){
    ll n, x; cin >> n >> x;
    ll a[n]; rep(i,n) cin >> a[i];

    ll cnt = 0;
    for(ll i=1; i<n; i++){
        if(a[i-1] + a[i] <= x){
            //処理しない
        }
        else if(a[i-1] <= x){
            cnt += a[i] - (x - a[i-1]);
            a[i] = x - a[i-1];
        }
        else{
            cnt += a[i] + (a[i-1] - x);
            a[i] = 0; a[i-1] = x;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * Created by darshan on 2/19/19.
 */
public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        long n = Long.parseLong(br.readLine());
        long s = Long.parseLong(br.readLine());

        if (n < s) {
            System.out.println(-1);
            return;
        }
        if (n == s) {
            System.out.println(n + 1);
            return;
        }

        /*
        Let x = (square root of n) + 1
        Try all possible bases till x
        Once we exceed x, n can be represented in two digits of base x
         */
        long squareRootN = Double.valueOf(Math.ceil(Math.sqrt(n))).longValue();
        for (long base = 2; base <= squareRootN; base++) {
            long sum = sumDigitsInBase(base, n);
            if (sum == s) {
                System.out.println(base);
                return;
            }
        }

        /*
        b > x
        n = pb + q
        p + q = s
        b = (n - s) / p + 1
        p = [1, x]
         */
        long nMinusS = n - s;
        long minBase = -1;
        for (long p = 1; p <= squareRootN; p++) {
            if (nMinusS % p != 0) {
                continue;
            }
            long base = nMinusS / p + 1;
            if (base > squareRootN) {
                long sum = sumDigitsInBase(base, n);
                if (sum == s) {
                    minBase = base;
                }
            }
        }
        System.out.println(minBase);
    }

    private static long sumDigitsInBase(long base, long number) {
        if (base > number) {
            return number;
        }
        long sum = sumDigitsInBase(base, number / base);
        return sum + (number % base);
    }
}


Measured memory_bytes: 22740
#include <iostream>
#include <cmath>
#include <algorithm>
int main()
{
    int N,M;
    int L[100000];
    int R[100000];
    int R_c,L_c;
    std::cin >>N >> M;
    for(int i=0; i<M; i++){
        std::cin >> L[i] >> R[i];
    }
    R_c=R[0];
    L_c=L[0];
    for(int i=1; i<M; i++){
        if(L_c <L[i]){
            L_c=L[i];
        }
        if(R_c >R[i]){
            R_c=R[i];
        }
    }
    if(R_c-L_c+1>0){
        std::cout <<R_c-L_c+1<<std::endl;
    }else{
        std::cout << 0 << std::endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(void){
    int n,x,t;
    int ans;
    scanf("%d %d %d",&n,&x,&t);
    if(n%x==0){
    ans=(n/x)*t;
    }else{
        ans=((n/x)+1)*t;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1708
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;
 
vector<vector<pair<int,ll> > > g;     // to,dist
vector<ll> depth;

void dfs(int par, int curr, ll depth_curr)
{
    depth[curr]=depth_curr;
    int siz=(int)g[curr].size();
    int i;
    for(i=0; i<siz; i++) {
        int next=g[curr][i].first;
        if(next==par) continue;

        dfs(curr,next,depth_curr+g[curr][i].second);

    }

    return;
}

int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

    g.resize(n);
    depth.resize(n);
    int i;
    for(i=0; i<n-1; i++) {
        int a,b,c;
        scanf("%d%d%d", &a, &b, &c); a--; b--;
        g[a].push_back(make_pair(b,c));
        g[b].push_back(make_pair(a,c));
    }

    int Q,K;
    scanf("%d%d", &Q, &K);
    K--;
    dfs(-1, K, 0);

    for(i=0; i<Q; i++) {
        int a,b;
        scanf("%d%d", &a, &b); a--; b--;
        printf("%lld\n", depth[a]+depth[b]);
    }

    return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

int main(){
    int p,q,r;
    cin >> p >> q >> r;
    cout << min(p+q,min(q+r,r+p)) << endl;
}

Measured memory_bytes: 3600
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <assert.h>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main(){
  ll n,k;
  cin>>n>>k;
  vector<ll> v;
  rep(i,0,n){
    ll a;
    cin>>a;
    v.pb(a);
  }
  sort(all(v));
  ll ans = 0;
  rep(i,0,k){
    ans += v[i];
  }
  cout << ans << endl;
  return 0;
}

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

#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <climits>
using Graph = vector<vector<int>>;
const double PI = 3.14159265358979323846;

int needed_kaisu(long long a, long long N, long long *A) {
	int count = 0;
	for (long long i = 0; i < N; i++) {
		count += (A[i]+a-1) / a -1;
	}
	return count;
}


int main() {


	string S;

	cin >> S;

	int N;

	N = 1;

	if (S == "SSS") {
		N = 0;
	}

	if (S == "RRS") {
		N = 2;
	}

	if (S == "SRR") {
		N = 2;
	}

	if (S == "RRR") {
		N = 3;
	}

	cout << N;

	cin >> N;

	return 0;


}



Measured memory_bytes: 3624
N, M = STDIN.gets.chomp.split(' ').map(&:to_i)
H = STDIN.gets.chomp.split(' ').map(&:to_i)
A, B = STDIN.read.chomp.split("\n").map {|line| line.chomp.split(' ').map(&:to_i) }.transpose

o = (1..N).to_a.map {|i| [i, true] }.to_h

0.upto(M - 1) do |i|
  case
  when H[A[i] - 1] > H[B[i] - 1]
    o.delete(B[i])
  when H[A[i] - 1] < H[B[i] - 1]
    o.delete(A[i])
  else
    o.delete(A[i])
    o.delete(B[i])
  end
end

print o.size


Measured memory_bytes: 34832
#include <iostream>

using namespace std;

int main(){
    //入力
    string s;
    cin >> s;
    //文字列のサイズを取得
    int l = s.size();
    //正解だった時の答え
    string ans = "AC";
    //もし一文字目がAじゃなかった時不正解。
    if(s.front() != 'A') ans = "WA";
    //もし前から一文字目から見ていって、大文字を見つけた時、それが一文字目と最後の文字だったら大文字であるのはおかしいから不正解。またそれがC以外であったときも不正解。
    int cnt = 0;
    for(int i = 1; i < l; ++i){
        if(isupper(s[i])){
            if(i == 1 || i == l-1 || s[i] != 'C'){
                ans = "WA";
            }
            //そしてCの数はひとつしかないから大文字もひとつしかないはず。
            ++cnt;
        }
    }
    //大文字が一文字でなかった時も不正解。
    if(cnt != 1){
        ans = "WA";
    }
    //出力
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n+1);
    REP(i, n) {
        cin >> a[i+1];
        a[i+1] = (a[i+1]-1) % k;
    }
    FOR(i, 1, n+1) (a[i] += a[i-1]) %= k;

    dump(a);

    ll ans = 0;
    map<ll,ll> mp;
    mp[0] = 1;
    FOR(i, 1, n+1) {
        if(i>=k) mp[a[i-k]]--;
        dump(i, mp, ans);
        if(mp.find(a[i]) != mp.end()) {
            ans += mp[a[i]];
        }
        mp[a[i]]++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 14336
#include "bits/stdc++.h"
#include <boost/range/irange.hpp>
using namespace std;
using boost::irange;

// 定義
typedef long long           ll;
typedef pair<ll, ll>        P;
#define ALL(x)              (x).begin(),(x).end()
#define REP(i, n)           for (ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)       for (ll i = m ; i < (ll)n ; ++i)
const ll                    INF = 2e9;
const ll                    INF_LL = 1LL<<60;
const ll                    MOD = 998244353;

ll Ceil(ll val, ll div)   { return (val + div - 1) / div; }
ll CeilN(ll val, ll div)  { return Ceil(val, div) * div; }
ll FloorN(ll x, ll n)     { return (x - x % n); }
bool IsOdd(ll x)          { return ((x & 1) == 1); }
bool IsEven(ll x)         { return ((x & 1) == 0); }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// 処理
void Solve()
{
	ll N;
	cin >> N;
	vector<ll> A(N);
	for(auto i : irange<ll>(0, N, 1)) { cin >> A[i]; };

	ll ans = 0;
	REP(i, N - 1) {
		if (IsOdd(A[i])) {
			if (0 < A[i + 1]) {
				ans++;
				A[i]--;
				A[i + 1]--;
			}
		}
	}
	
	for (auto &one : A) {
		ans += one / 2;
	}

	cout << ans << endl;
}

// メイン
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Solve();
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
    int n; cin >> n;
    vector<int> w(n);
    REP(i, n) cin >> w[i];

    int ans = numeric_limits<int>::max();
    REP(i, n-1){
        int s1 = 0, s2 = 0;
        FOR(j, 0, i+1) s1 += w[j];
        FOR(j, i+1, n) s2 += w[j];

        ans = min(ans, abs(s1-s2));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#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()
{
    string s;
    cin >> s;
    string t = s.substr(0, s.size() / 2);
    string u = s.substr(s.size() - s.size() / 2);
    int cnt = 0;
    rep(i, t.size())
    {
        if (t[i] != u[t.size() - 1 - i])
            ++cnt;
    }
    cout << cnt << 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
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		boolean yes = false;
		for(int i = 0;i<n;i++){
			yes = false;
			int x = sc.nextInt();
			int y = sc.nextInt();
			int z = sc.nextInt();
			if(((x*x)+(y*y))==(z*z)) yes = true;
			else if(((z*z)+(y*y))==(x*x)) yes = true;
			else if(((x*x)+(z*z))==(y*y)) yes = true;
			
			if(yes) System.out.println("YES");
			else System.out.println("NO");
		}
 	}

}

Measured memory_bytes: 21564
# -*- coding: utf-8 -*-
"""
D - Card Eater
https://atcoder.jp/contests/arc068/tasks/arc068_b

"""
import sys


from collections import Counter

def solve(N, cards):
    cnt = Counter(cards)
    freq = [1 if v%2 else 2 for k, v in cnt.items()]
    ones = len([1 for f in freq if f == 1])
    twos = len([2 for f in freq if f == 2])
    if twos:
        if twos % 2:
            ones += (twos-1)
        else:
            ones += twos
    return ones


def main(args):
    N = int(input())
    cards = [int(a) for a in input().split()]
    ans = solve(N, cards)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 18648
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		double tempResult = 0.0d;
		for (int i = 0; i < N; ++i) {
			double t = sc.nextDouble();
			tempResult += 1.0d / t;
		}
		double result = 1.0d / tempResult;
		
		
		System.out.println(result);
		
	}
	
	private static int kaijo(int x) {
		int result = 1;
		for(int i = 1; i <= x; ++i) result *= 2;
		return result;
	}

}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 21204
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vl;
typedef vector<vector<int, int> > vvi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    string s;
    cin >> s;
    vector<pair<char, int> > p;
    for(int i = 0; i < s.size(); i++){
        if(s[i]=='A'){
            p.pb(mp(s[i], i));
        }
        else if(s[i]=='Z'){
            p.pb(mp(s[i], i));
        }
    }
    sort(all(p));
    cout << p[p.size()-1].second - p[0].second + 1;
}

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

int max(int a,int b){
    return (a>b?a:b);
}

int main() {
	
	int n,i;
	cin >> n;
	int a[n],b[n],c[n];
	for(i=0;i<n;i++)
	cin >> a[i] >> b[i] >> c[i];
	
	int dp1[n],dp2[n],dp3[n];
	dp1[0]=a[0];dp2[0]=b[0];dp3[0]=c[0];
	
	for(i=1;i<n;i++)
	{
	    dp1[i] = a[i]+max(dp2[i-1],dp3[i-1]);
	    dp2[i] = b[i]+max(dp1[i-1],dp3[i-1]);
	    dp3[i] = c[i]+max(dp1[i-1],dp2[i-1]);
	    
	}
	
	cout << max(dp1[n-1],max(dp2[n-1],dp3[n-1]));
	
	
	
}


Measured memory_bytes: 2560
INF = 2000000000
n,limit_w = map(int, input().split())
w = [0]*n
v = [0]*n
for i in range(n):
    w[i], v[i] = map(int, input().split())
sum_v = sum(v)
dp = [INF for i in range(sum_v + 1)]
dp[0] = 0
for i in range(n):
    for j in range(sum_v ,-1 ,-1):
        if j >= v[i]:
            dp[j] = min(dp[j], dp[j - v[i]] + w[i])
for i in range(sum_v, -1, -1):
    if dp[i] <= limit_w:
        print(i)
        break

Measured memory_bytes: 45168
# (c) midandfeed
q = [int(x) for x in input().split()]
a, b, c = [int(x) for x in q]
while( (a+b) != (a+c) ):
	q = q[1:] + [q[0]]
	a, b, c = [int(x) for x in q]
print(a)

Measured memory_bytes: 2940