akhauriyash/Code-Regression huggingface dataset:
package main

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

func main() {
	var sc = bufio.NewScanner(os.Stdin)
	var s string
	if sc.Scan() {
		s = sc.Text()
	}

	fmt.Printf("%c\n", int32(s[0])+1)
}


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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 10000000000
#define MOD 10007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
  int N,M,K;cin>>N>>M>>K;
  if(K%N==0||K%M==0){
    cout<<"Yes"<<endl;
    return 0;
  }
  else{
    for(int i = 1; i <= N; i++){
      for(int j = 1; j <= M; j++){
        int tmp = M*i + N*j - 2*i*j;
        if(K==tmp){
          cout<<"Yes"<<endl;
          return 0;
        }
      }
    }
  }
  cout<<"No"<<endl; 
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
    int i,n,k;
	cin >> n;
    for(i=1;i<=n;i++){
        if(i % 3 == 0){
            cout << " " << i;
        }
        else{
            for(k=i;k !=0;k /=10){
                if(k % 10 == 3){
                    cout << " " << i;
                    break;
                }
            }
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define rep(i, a, b) for(i = a; i < b; i++)
#define per(i, a, b) for(i = a; i >= b; i--)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define trav(x, it) for(auto it = x.begin(); it != x.end(); it++)
#define pr(x) cout << #x << " = " << x << endl
#define fill(x,y) memset(x,y,sizeof(x))
#define endl "\n"
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector< pii > vpii;
typedef vector< pll > vpll;
const ld eps = 1e-7;
const ll mod = 1000000007;
const ll N = 998244353;

ll binpow(ll b, ll p){ ll ans = 1; while(p > 0){if(p & 1) ans = (ans * b) % mod; b = (b * b) % mod; p >>= 1;}return ans;}
ll modinv(ll x){return binpow(x, mod - 2);}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	ll n, i;
	cin >> n;
	ll a[n], x = 0, b[n];
	rep(i, 0, n)
	{
		cin >> a[i];
		x ^= a[i];
	}
	rep(i, 0, n)
	{
		b[i] = a[i] ^ x;
	}
	rep(i, 0, n)
	{
		cout << b[i] << " ";
	}
	cout << endl;
}

Measured memory_bytes: 6688
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
ll pre[200005];
int a[200005];


int main() {
int n,i;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    sort(a,a+n);
    for(i=1;i<=n;i++)
        pre[i] = pre[i-1] + a[i-1];
    int ans = 1;
    for(i=n-1;i>=0;i--)
        {
       // printf("%d %d\n",pre[i],a[i]);
        if(pre[i]*2 >= a[i])ans++;
        else break;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>

 int main(){
     int h, w;
     std::cin >> h >> w;

     std::vector<std::string> s(h);
     for(int i = 0; i < h; i++){
         std::cin >> s[i];
     }

    std::vector<std::vector<int>> cnt(h, std::vector<int>(w));

    for(int i = 0; i < h; i++){
        //whether the position is already checked
        std::vector<int> done(w);
        
        for(int j = 0; j < w; j++){
            //# cannot be lightened
            if(s[i][j] == '#') continue;

            //if the cell already checked, it must not be double-counted
            if(done[j])continue;

            //length of continuous . sequences
            int l = 0;

            //whether the right position is . or not
            while(j+l < w){
                if(s[i][j+l] == '#')break;
                l++;
            }

            //record the number of . between two #s.
            for(int k = 0; k < l; k++){
                cnt[i][j+k] += l;
                done[j+k] = 1;
            }
        }

    }

    //the colum direction
    for(int j = 0; j < w; j++) {
    
        //whether the position is already checked
        std::vector<int> done(h);

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

            //# cannot be lightened
            if (s[i][j] == '#') continue;

            //if the cell already checked, it must not be double-counted
            if (done[i]) continue;

            //length of continuous . sequences
            int l = 0;

            //whether the lower position is . or not
                while (i+l < h) {
                    if (s[i+l][j] == '#') break;
                        ++l;
                }

            //record the number of . between two #s.
            for(int k = 0; k < l; k++) {
                    cnt[i+k][j] += l;
                    done[i+k] = 1;
            }
        }
    }

    int ans = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){

        //the [i][j]the cell is counted doubly-> -1 is needed
        ans = std::max(ans, cnt[i][j]-1);
        }
    }

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

Measured memory_bytes: 20096
n,m,q = map(int,input().split())
P = [list(map(int,input().split())) for i in range(q)]

import itertools
num_list = list(itertools.combinations_with_replacement(range(1,m+1), n))

base = 0
for i in range(len(num_list)):
    sum = 0
    for j in range(q):
        if num_list[i][P[j][1]-1] - num_list[i][P[j][0]-1] == P[j][2]:
            sum += P[j][3]
    
    if base  < sum:
        base = sum

print(base)

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

#define all(s) s.begin(), s.end()
#define pb push_back
#define ii pair<int, int>
#define x first
#define y second
#define bit(x, y) ((x >> y) & 1)
#define sz(s) ((int) (s).size())

const int N = 105;

int n, m;
string s[N];
int dp[N][N];

int main() {
    ios::sync_with_stdio(false); cin.tie(0); 
    cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= m + 1; i++) {
        s[0] += ".";
    }
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= m; j++) {
            dp[i][j] = 1e9;
        }
    }
    dp[0][1] = 0;
    dp[1][0] = 0;
    for (int i = 1; i <= n; i++) {
        cin >> s[i];
        s[i] = "." + s[i];
        for (int j = 1; j <= m; j++) {
            if (s[i][j] == '.') {
                dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]);
            } else {
                int foo1 = dp[i - 1][j];
                if (s[i - 1][j] == '.') foo1 += 1;
                int foo2 = dp[i][j - 1];
                if (s[i][j - 1] == '.') foo2 += 1;
                dp[i][j] = min(foo1, foo2);
            }
        }
    }
    cout << dp[n][m];
    return 0;
}

Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9

typedef long long ll;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
ll Max(ll a, ll b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

int main(){
	int n, m, q;
	int l[500][500] = { 0 };
	scanf("%d%d%d", &n, &m, &q);
	REP(i, m) {
		int a, b;
		scanf("%d %d", &a, &b);
		l[a-1][b-1]++;
	}
	REP(i, n) {
		REPS(j, n-1) {
			l[i][j] += l[i][j - 1];
			//PRINTD(l[i][j - 1]);
		}
		//PRINTD(l[i][n-1]);
	}
	int ans;
	REP(i, q) {
		ans = 0;
		int a, b;
		scanf("%d %d", &a, &b);
		a--; b--;
		FOR(j,a,b+1) {
			ans += l[j][b];
			//PRINTD(ans);
		}
		PRINTD(ans);
	}

}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define endl "\n"
#define fi first
#define sec second 
#define pb push_back
#define test cout<<"debuged\n";
#define INF ll(1e18)
#define MOD 1000000007
#define debug(x) cout<<x<<"\n";
#define pll pair<ll,ll>
#define all(v) v.begin(),v.end()
#define MAX 500005


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


    ll n,w,sumval=0;
    cin>>n>>w;
    vector<ll> v(n),we(n);
    for(ll i=0;i<n;i++)
    {
      cin>>we[i]>>v[i];
      sumval+=v[i];
    }
    vector<ll> dp(sumval+1,INF);
    dp[0]=0;
    for(ll i=0;i<n;i++)
    {
      for(ll j=sumval-v[i];j>=0;j--)
      {
        dp[j+v[i]]=min(dp[j+v[i]],dp[j]+we[i]);
      }
    }
    ll ans=0;
    for(ll i=0;i<=sumval;i++)
    {
      if(dp[i]<=w)
      {
          ans=max(ans,i);
      }
    }
    cout<<ans;

  
}

Measured memory_bytes: 1024
//#define _GRIBCXX_DEBUG
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;


// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T>
constexpr int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F>
constexpr int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T>
void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C>
void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U>
constexpr void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U>
constexpr void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C>
constexpr void reverse(C& c) { reverse(ALL(c)); }
template<typename C>
constexpr void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred>
constexpr void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-9)
#define MOD (int)(1e9+7)
#pragma endregion


int main()
{
    map< string, vi > index;
    string sbuf;
    int ibuf;
    while(cin>>sbuf>>ibuf) index[sbuf].push_back(ibuf);
    for(auto &el : index) {
        sort(el.second);
        P(el.first);
        for(auto vel : el.second) {
            cout << vel;
            if(vel != *(el.second.end()-1)) cout << " ";
        }
        PED;
    }
    return 0;
}

Measured memory_bytes: 3124
# coding: utf-8
# Your code here!

# 最大積載量p でk台のトラックに全ての荷物を積載できるかチェックする
def check(p):
  global n, k, w

  # k台のトラックに積載済の荷物の個数
  i = 0

  # k台のトラックに順番に荷物を積載する
  for j in range(k):
    # j台目のトラックの積載量の合計
    s = 0

    # 積載量の合計が 最大積載量p を超えるまで荷物を積み込む
    while (s + w[i] <= p):
      s += w[i]
      
      # トラックに積載済の荷物の個数をカウントアップ
      i += 1

      # 最大積載量p で すべての荷物を積み込めた場合
      if (i == n):
        return True

  # 最大積載量p で すべての荷物を積み込めなかった場合
  return False


# メイン処理
def solve():
  global n

  # 積載量の下限
  left = 0

  # 積載量の上限（個数の最大値 × 重量の最大値）
  right = 100000 * 10000

  while (1 < right - left):
    # 最大積載量p
    p = int((left + right) / 2)

    if check(p):
      # 最大積載量pで全ての荷物が積み込めた場合、p より小さい範囲を探索
      right = p
    else:
      # 最大積載量pで全ての荷物が積み込めなかった場合、p より大きい範囲を探索
      left = p
  
  # 全ての荷物を積み込むことができた最小の最大積載量を返却する
  return right

n, k = map(int, input().split())
w = [int(input()) for i in range(n)]
print(solve())


Measured memory_bytes: 9576
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S seconnd
#define PB push_back
#define int ll

int a[1000][1000];
int H,W,h,w;

signed main(){
  cin>>H>>W>>h>>w;
  rep(i,H){
    rep(j,W){
      a[i][j]=1000;
    }
  }

  rep(i,H){
    rep(j,W){
      if((i+1)%h==0&&(j+1)%w==0)
        a[i][j]=-1000*(h*w-1)-1;
    }
  }


  int sum=0;
  rep(i,H){
    rep(j,W){
      sum+=a[i][j];
    }
  }
  

  if(sum<=0){
    cout<<"No"<<endl;
  }
  else{
    cout<<"Yes"<<endl;
    rep(i,H){
      rep(j,W){
        if(j==0) cout<<a[i][j];
        else cout<<' '<<a[i][j];
      }
      cout<<endl;
    }
  }

}


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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i < n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i < n; i++)

typedef long long ll;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::pair<ll, ll> pll;

using namespace std;

int main() 
{
    int h,w;
    cin >> h >> w;
    v2_string s(h, v_string(w, ""));
    v_int t = {-1, 0, 1}; 
    v_int u = {-1, 0, 1}; 
    v2_string ans(h, v_string(w, "#"));
    
    irep(i, h) {
        string tmp;
        cin >> tmp;
        irep(j, w) {
            s[i][j] = tmp[j];
        }
    }

    irep(i, h) {
        irep(j, w) {
            int cnt = 0;
            irep(k, 3) {
                irep(l, 3) {
                    if(k == 1 && l == 1) { continue; }
                    if(i+t[k] < 0 || i+t[k] >= h) { continue; }
                    if(j+u[l] < 0 || j+u[l] >= w) { continue; }
                    if(s[i+t[k]][j+u[l]] == "#") { cnt++; }
                }
            }
            if(s[i][j] == ".") { ans[i][j] = to_string(cnt); } 
        }
    }
    
    irep(i, h) {
        irep(j, w) {
            cout << ans[i][j];
        }
        cout << endl;
    }

    return 0;
}


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

using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define M 1000000007
typedef long long ll;
int main() { 
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll t,a[1000000],n,i;
    cin>>t>>n;
    cout<<max(0ll,t-2*n);
    return 0;
}


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


int gcd(int i, int j) {
    int a = max(i, j);
    int b = min(i, j);
    if (a % b == 0) {
        return b;
    }else{
        return gcd(b, a%b);
    }
}

int main() {
    int K;
    cin >> K;
    int ans = 0;

    for (int i = 1; i <= K; i++) {
        for (int j = 1; j <= K; j++) {
            for (int l = 1; l <= K; l++) {
                ans += gcd(gcd(i, j), l);
            }
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 3632
#include <stdio.h>
#define abs(x) ((x) > 0 ? (x) : -(x))
#define min(x, y) ((x) < (y) ? (x) : (y))

int
main(int argc, char *argv[])
{
  int n, a[200000];
  long long int sum = 0, sum2 = 0;
  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    scanf("%d", &a[i]);
    sum += (long long)a[i];
  }
  long long ans = abs(2*(long long)a[0] - sum);
  for(int i = 0; i < n - 1; i++){
    sum2 += (long long)a[i];
    sum -= (long long)a[i];
    ans = min(ans, abs(sum - sum2));
  }
  printf("%lld\n", ans);
  return 0;
}
  


Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;
typedef long long ll;

const int mod=1000000007;
int N,W;
int w[201];
ll dp[2][10001][202];

int main(){

	cin>>N>>W;
	for(int i=0;i<N;i++)cin>>w[i];
	for(int j=0;j<=W;j++){
		for(int k=0;k<=N;k++){
			if(j<=W&&(k==N||w[k]+j>W))dp[N%2][j][k]=1;
			else dp[N%2][j][k]=0;
		}
	}

	for(int i=N-1;i>=0;i--){
		int cur=(i+1)%2;
		int nxt=(i)%2;
		for(int j=0;j<=W;j++){
			for(int k=0;k<=N;k++){
				dp[nxt][j][k]=0;
				int nmwidx=k;
				if(k==N||w[k]>w[i])nmwidx=i;
				dp[nxt][j][k]+=dp[cur][j][nmwidx];
				if(j+w[i]<=W)dp[nxt][j][k]+=dp[cur][j+w[i]][k];
				dp[nxt][j][k]%=mod;
			}
		}
	}
	cout<<dp[0][0][N]<<endl;

	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <algorithm>
#include <math.h>
using namespace std;
int main()
{
int a[5],b,mia;
int min=15;
for(int i=0;i<5;i++)
{
scanf("%d",&a[i]);
b=a[i]%10;
if(b==0){b=10;}
if(b<min){min=b; mia=i;}
}
int ans=0;
for(int i=0;i<5;i++)
{
if(mia==i){ans=ans+a[i];}
else {if(a[i]%10!=0){a[i]=a[i]/10; a[i]=a[i]*10+10;}
ans=ans+a[i];}
}
printf("%d\n",ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
#define rev(i, r, l) for(register int i = r; i >= l; i--)
#define pb push_back
#define int ll
#ifndef JOEON
#define D(...)
#define R(x, l)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
signed main(void)
{
	#ifdef JOEON
//		freopen("C:\\Users\\Joeon\\Desktop\\IN.txt", "r", stdin);
//		freopen("C:\\Users\\Joeon\\Desktop\\OUT.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	string a, b, c;
	cin>>a>>b;
	rep(i, 0, b.length()-1) c += b[i];
	if (a == c) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}


Measured memory_bytes: 3640
n = int(input())
a = [int(x) for x in input().split()]
 
for i in range(n):
    v = a[i]
    j = i - 1
    while j >= 0 and a[j] > v:
        a[j+1] = a[j]
        j -= 1
    a[j+1] = v
    print(" ".join(map(str,a)))

Measured memory_bytes: 7688
h,w,k=map(int,input().split())
board=[list(input()) for _ in range(h)]
ans=0
for paint_h in range(2**h): #すべての行の塗りつぶし方を2進数で列挙する
 for paint_w in range(2**w): #すべての列の塗りつぶし方を2進数で列挙する
   cnt=0
   for i in range(h): #すべてのi行目j列目の要素についてみる
     for j in range(w):
       if (paint_h>>i)&1==0 and (paint_w>>j)&1==0: #各行のi番目のビットと各列のj番目のビットがともに0であればそのマスは塗りつぶされない
         if board[i][j]=='#': #塗りつぶされないマスが黒マスであれば個数を+1する
           cnt+=1
   if cnt==k: #塗りつぶされない黒マスの個数がKに等しければ答えを+1する
     ans+=1
print(ans)

Measured memory_bytes: 73940
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static long Solve(int N, Tuple<long, long>[] tuples)
        {
            Array.Sort(tuples, (a, b) => (b.Item1 + b.Item2).CompareTo(a.Item1 + a.Item2));
            long sum = 0;
            for (int i = 0; i < N; ++i)
            {
                sum += (i % 2 == 0) ? tuples[i].Item1 : -tuples[i].Item2;
            }
            return sum;
        }

        static void Main(string[] args)
        {
            int N = ReadInt();
            var tuples = new Tuple<long, long>[N];
            for (int i = 0; i < N; ++i)
            {
                var V = ReadLongs();
                tuples[i] = new Tuple<long, long>(V[0], V[1]);
            }
            Console.WriteLine(Solve(N, tuples));
        }
    }
}


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

typedef long long ll;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define sz(v) ll(v.size())


void solve(ll N, vector<ll> a){
    ll dp[N+1][N+1];
    fill(dp[0], dp[N], 0);
    for(int l = N-1; l >= 0; l--) {
        FOR(r, l, N) {
            if (l == r) dp[l][r] = a[l];
            else dp[l][r] = max(a[l] - dp[l+1][r], a[r] - dp[l][r-1]);
        }
    }
    cout << dp[0][N-1] << endl;
}

int main() {
  ll N;
    scanf("%lld",&N);
    vector<ll> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
  solve(N, move(a));
  return 0;
}


Measured memory_bytes: 70656
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <string>
#include <cmath>
#include <cstdio>
using namespace std;

#define PI 4*atan(1);

int main(){
  int y;
  while(cin >> y && y){
     int b = 1000, c = 0;
    b -= y;
    for(int i = 0;; i++){
      if(b - 500 >= 0){
        b -= 500;
        c++;
        if(b == 0){
          break;
        }
      }else if(b - 100 >= 0){
        b -= 100;
        c++;
        if(b == 0){
          break;
        }
      }else if(b - 50 >= 0){
        b -= 50;
        c++;
        if(b == 0){
          break;
        }
      }else if(b - 10 >= 0){
        b -= 10;
        c++;
        if(b == 0){
          break;
        }
      }else if(b - 5 >= 0){
        b -= 5;
        c++;
        if(b == 0){
          break;
        }
      }else if(b - 1 >= 0){
        b -= 1;
        c++;
        if(b == 0){
          break;
        }
      }
    }
    cout << c << endl;
  }
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long y = (long) x / 11;
        long z = x % 11;
        if (z == 0) {
            System.out.println(2 * y);
        } else if (z <= 6) {
            System.out.println(2 * y + 1);
        } else {
            System.out.println(2 * y + 2);
        }
    }

}

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

int h[110];

int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) cin >> h[i];
  int res = 0;
  while (true) {
    bool finish = true;
    for (int i = 0; i < N; i++) {
      if (h[i] != 0) finish = false;
    }
    if (finish) break;

    int i = 0;
    int range_cnt = 0;
    while (i < N) {
      if (h[i] == 0) {
        i++;
        continue;
      }
      while (i < N && h[i] != 0) {
        h[i] -= 1;
        i++;
      }
      range_cnt += 1;
    }
    res += range_cnt;
  }

  cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007LL



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

    string s;
    cin>>s;

    int len = s.length();
    if (s[len-1]=='s')
    {
        cout<<s<<"es"<<endl;
    }
    else
    {
        cout<<s<<'s'<<endl;
    }
    
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int i;
    vector<int> A;
    int n;
    cin >> n;
    for (i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        A.push_back(a);
    }
    int q;
    cin >> q;
    for (i = 0; i < q; i++)
    {
        int b, e;
        cin >> b >> e;
        reverse(A.begin() + b, A.begin() + e);
    }
    for (i = 0; i < A.size() - 1; i++)
    {
        cout << *(A.begin() + i) << ' ';
    }
    cout << A.back() << endl;
}


Measured memory_bytes: 3156
#include <iostream>
#include <stdio.h>
#include <iomanip>
using namespace std;

int main(){
  int a, b, d, r;
  double ad, bd, f;
  cin >> a >> b;
  d = a/b;
  r = a%b;
  ad = a;
  bd = b;
  f = (double)ad/bd;
  //printf("%d %d %lf\n", a/b, a%b, (double)a/b);
  cout << d << " " << r << " " << fixed << setprecision(9) << f << endl;
  return 0;
}


Measured memory_bytes: 3260
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = std::numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, q, last, cnt, sum[1000000], ans, dp[110000];
Pll a[200000], b[2000000];
string str, ss, dd;
bool f[2000][2000],ff;
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ -1,0 } ,{ 0,-1 } };
struct Edge { LL to, cost; };
vector<Edge>vec[10000];
vector<Pll>v;
map<string, LL>ma;
set<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

int main() {
	cin >> n;
	ans = 1;
	rep(i, n) {
		ans *= i + 1;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4608
#include <cstdio>
#include <cstring>

const int N = 200010, D = 26;
int n, f[D], dp[N], sol[N], next[N][D], prev[D];
char s[N];

int main()
{
	scanf("%s", s + 1);
	n = strlen(s + 1);
	for (int i = 1; i <= n; i++)
	{
		for (int j = prev[s[i] - 'a'] + 1; j <= i; j++) next[j][s[i] - 'a'] = i;
		prev[s[i] - 'a'] = i;
	}
	dp[n + 1] = 1;
	for (int i = n; i; i--)
	{
		dp[i] = n + 1;
		for (int j = D - 1; j >= 0; j--) if (!next[i][j]) dp[i] = 1; else
		if (dp[next[i][j] + 1] + 1 <= dp[i]) dp[i] = dp[next[i][j] + 1] + 1, sol[i] = next[i][j];
	}
	int k = 1;
	while (dp[k] > 1) printf("%c", s[sol[k]]), k = sol[k] + 1;
	for (int i = k; i <= n; i++) f[s[i] - 'a'] = true;
	for (int i = 0; i < D; i++) if (!f[i])
	{
		printf("%c", i + 'a');
		break;
	} 
	return 0;
}

Measured memory_bytes: 22272
NW=input().split()

N=int(NW[0])
W=int(NW[1])

item= []
for i in range(N):
    item.append(list(map(int, input().split())))

C=[[0 for i2 in range(W+1)]for i1 in range(N+1)]

for i in range(1,N+1):
    for j in range(1,W+1):
        if j>=item[i-1][1]:
            if item[i-1][0] + C[i][j -item[i - 1][1]] > C[i - 1][j]:#???????????????
                C[i][j] = item[i-1][0] + C[i][j - item[i - 1][1]]
            else:
                C[i][j] = C[i -1][j]
        else:
            C[i][j]=C[i-1][j]

print(C[N][W])

Measured memory_bytes: 18240
#include<bits/stdc++.h> 
using namespace std;
int main(){
	char a[100010];
	cin>>a;
	char kkksc03=a[0];
	int ans=0;
	for(int i=1;i<strlen(a);i++){
		if(kkksc03!=a[i]){
			ans++;
			kkksc03=a[i];
		}
	}
	cout<<ans;
	cout<<endl;
}

Measured memory_bytes: 384
# coding: utf-8
A, B, K = map(int, input().split())
a = set(i for i in range(A, min(A + K, B + 1)))
b = set(j for j in range(max(B - K + 1, A), B + 1))
c = list(a | b)
c.sort()
for k in c:
    print(k)


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

int main () {
    int N;
    cin >> N;
    int K;
    cin >> K;
    int X;
    cin >> X;
    int Y;
    cin >> Y;

    if (N>K) {
        cout << K*X+(N-K)*Y << endl;
    }
    else {
        cout << N*X <<endl;
    }
}


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

using namespace std;



int main(){
    long long i,n;
    cin >> n;
    long long d[n];
    for(i=0;i<n;i++){
        cin >> d[i];
    }
    if(n%2==1){
        cout << "0" << endl;
        return 0;
    }
    sort(d,d+n);
    cout << d[n/2]-d[n/2-1] << endl;

    return 0;
}

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



int main() 
{ 

    int a,b;
    cin>>a>>b;
    string s1,s2;

    if(a>=1&&a<=9&&b>=1&&b<=9)
    cout<<a*b<<endl;
    else
    {
        cout<<"-1"<<endl;
    }
    
    
  

return 0; 
} 



Measured memory_bytes: 256
s = input()
flag = True
if s[0] != 'A':
    flag = False
elif 'C' not in s[2:-1]:
    flag = False
else:
    s=list(s)
    s.remove('C')
    if not str(s[1:]).islower():
        flag = False

if flag:
    print('AC')
else:
    print('WA')

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
int main(){
std::string a,b,c;
std::cin >> a >> b >> c;
transform(a.begin(), a.end(), a.begin(), ::toupper);
transform(b.begin(), b.end(), b.begin(), ::toupper);
transform(c.begin(), c.end(), c.begin(), ::toupper);
std::cout << a[0] << b[0] << c[0] << std::endl;
}

Measured memory_bytes: 256
#include <stdio.h>

   int main(){

    int a,b;

    scanf("%d" ,&a);
    scanf("%d" ,&b);

    if(a>b){
     printf("a > b\n");
    }

    else if(a<b){
    printf("a < b\n");
    }

    else if(a == b){
     printf("a == b\n");
    }

    return 0;
 }




Measured memory_bytes: 2060
#include <iostream>
#include <cstring>
#include<vector>
#include <algorithm>
#include<cstdlib>
#include<set>
#include<math.h>
#include<map>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;i++)



int main()
{
	ll n;
	cin >> n;
	vector<ll> p(n);
	rep(i, n) cin >> p[i];

	ll min = n + 10;
	ll ans = 0;
	rep(i, n)
	{
		if (p[i] < min)
		{
			ans++;
			min = p[i];
		}
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 4848
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<cstdlib>
#define LL long long
#define LD long double
using namespace std;
const int NN=3000000 +117;
const int MM=1 +117;
int read(){
	int fl=1,x;char c;
	for(c=getchar();(c<'0'||c>'9')&&c!='-';c=getchar());
	if(c=='-'){fl=-1;c=getchar();}
	for(x=0;c>='0'&&c<='9';c=getchar())
		x=(x<<3)+(x<<1)+c-'0';
	return x*fl;
}
void open(){
	freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
}
void close(){
	fclose(stdin);
	fclose(stdout);
}


int m,n,k;
char s[NN]={};
int res[2][NN]={};
int xt[NN]={};
int len;
int getfa(int x){
	if(res[0][x]^res[1][x])return x;
	if(x==len+1)return x;
	return xt[x]=getfa(xt[x]);
}
int main(){
	//open();
	n=read();
	m=read();
	k=read();
	len=max(n,m);
	scanf("%s",s+1);
	int st=1;
	for(int i=n;i>=1;--i){
		res[0][st++]=s[i]-'0';
	}
	scanf("%s",s+1);
	st=1;
	for(int i=m;i>=1;--i){
		res[1][st++]=s[i]-'0';
	}
	xt[len+k+1]=len+k+100;
	for(int i=len+k;i>=1;--i){
		if(res[0][i+1]^res[1][i+1])xt[i]=i+1;
		else xt[i]=xt[i+1];
	}
	for(int i=len;i>=1;--i){
		if(!res[0][i]&&!res[1][i])continue;
		if(res[0][i]&&res[1][i]){
			res[0][i]=res[1][i]=0;
			int tp=xt[i];
			int dis=k;
			int np=i;
			bool fl=0;
			while(tp<=len+k+10&&tp-np<=dis){
				res[0][tp]+=1;
				res[1][tp]+=1;
				int k=(res[1][tp]==2);
				dis-=tp-np;
				int pre=tp;
				while(res[k][tp]==2){
					res[k][tp]=0;
					++tp;
					res[k][tp]++;
				}
				for(int i=tp;i>=pre;--i){
					if(res[0][i+1]^res[1][i+1])xt[i]=i+1;
					else xt[i]=xt[i+1];
				}
				if(res[0][tp]&&res[1][tp]){
					np=tp;
					tp=xt[np];
					res[0][np]=res[1][np]=0;
				}
				else{
					fl=1;
					break;
				}
			}
			if(!fl){
				res[0][np]=0;
				res[1][np]=0;
				res[0][np+dis]=1;
				res[1][np+dis]=1;
			}
		}
	}
	int pos=len+k+10;
	while(!res[0][pos])--pos;
	while(pos){
		putchar(res[0][pos]+'0');
		--pos;
	}
	putchar('\n');
	pos=len+k+10;
	while(!res[1][pos])--pos;
	while(pos){
		putchar(res[1][pos]+'0');
		--pos;
	}
	putchar('\n');
	close();
	return 0;
}

Measured memory_bytes: 30720
#include <iostream>

using namespace std;

int abs(int x)
{
  if (x >= 0) return x;
  else return -x;
}

int main(void)
{
  while (true) {
    int n;
    cin >> n;
    if (n == 0) break; 
    int a[n];
    for (size_t i = 0; i < n; i++)
      cin >> a[i];
    int min = 1000000;
    for (size_t i = 0; i < n; i++) {
      int first;
      first = a[i];
      for (size_t j = i + 1; j < n; j++) {
	int diff = abs(first - a[j]);
	if (diff < min)
	  min = diff;	
      }
    }
    cout << min << endl;
  }
  return 0;

}

Measured memory_bytes: 3040
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)
#define MAX 1000000000
using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}

unsigned long long gcd(unsigned long long a, unsigned long long b){
  if(b == 0) return a;

  return gcd(b, a%b);
}

unsigned long long lcm(unsigned long long a, unsigned long long b){
  return a/gcd(a,b)*b;
}

/*
n
t1
...
tn

n 100
t 10 ^18
 */
int n;

int main(){
  cin>>n;
  unsigned long long ans=1;
  REP(i,n){
    unsigned long long t;
    cin>>t;
    LOG("i = %d, t = %lld\n", i, t);
    ans = lcm(ans, t);
    LOG("ans = %lld\n",ans);
  }

  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
	int n,m;
	cin>> n>> m;
	int a[n][m];
	vector<int> v1;
	for (int i=0;i<n;i++){
		for (int j=0;j<m;j++){
			cin>> a[i][j];
		}
	}
	int x;
	for (int i=0;i<m;i++){
		cin>> x;
		v1.push_back(x);
	}
	vector<int> c1;
	x=0;
	for (int i=0;i<n;i++){
		for (int j=0;j<m;j++){
			x=x+(a[i][j]*v1[j]);
		}
		c1.push_back(x);
		x=0;
	}
	for (int i=0;i<n;i++){
		cout<< c1[i]<< endl;
	}
	return 0;
}

Measured memory_bytes: 3136
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import _collections
import string

class cin():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def mapInt():
        return [int(x) for x in cin.string().split()]
    def stringList(n):
        return [input() for i in range(n)]
    def intListList(n):
        return [cin.mapInt() for i in range(n)]
    def intColsList(n):
        return [int(input()) for i in range(n)]

class Util():
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Util.round_up(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x
class Math():
    def gcd(a,b):
        if b == 0:
            return a
        return Math.gcd(b,a % b)

def main():
    N,A,B,C = cin.mapInt()
    L = cin.intColsList(N)

    ans = int(1e09)
    for i in range(1 << N * 2):
        D = [0] * 3
        mp = 0
        for j in range(N):
            n = (i >> (j * 2)) & 3
            if n == 0:
                continue
            if D[n - 1] > 0:
                mp += 10
            D[n - 1] += L[j]
        if 0 in D:
            continue
        mp += abs(A - D[0])
        mp += abs(B - D[1])
        mp += abs(C - D[2])
        ans = min(ans,mp)
    print(ans)
    return

if __name__ == "__main__":
    main()


Measured memory_bytes: 45548
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class A
{
	public static void Main()
	{
		string[] args;

		args = Console.ReadLine().Split(' ');
		int H = Int32.Parse(args[0]);
		int W = Int32.Parse(args[1]);
		
		args = Console.ReadLine().Split(' ');
		int h = Int32.Parse(args[0]);
		int w = Int32.Parse(args[1]);
		
		Console.WriteLine((H - h) * (W - w));
	}	
}





Measured memory_bytes: 13140
// 基本テンプレート
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int d[500010], A[500010], B[500010];

signed main() {
    int N, D; cin >> N >> D;

    int pre = D;
    A[0] = D;
    for(int i=0; i<N; i++) {
        cin >> d[i];
        A[i+1] = min(A[i], abs(A[i] - d[i]));
    }

    B[N] = 1;
    for(int i=N-1; i>=0; i--) {
        if(d[i] / 2 >= B[i+1]) {
            B[i] = B[i+1];
        }
        else {
            B[i] = B[i+1] + d[i];
        }
    }

    int Q; cin >> Q;
    for(int i=0; i<Q; i++) {
        int q; cin >> q; q--;
        if(A[q] != 0 and A[i] >= B[i+1]) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}


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

char b[100];

int main(){
	int a[10],x=0,i,len;
	gets(b);
	len=strlen(b);
	for(i=0;i<len;i++)
	{
		if(b[i]=='1') {a[x]=1;x++;}
		if(b[i]=='0') {a[x]=0;x++;}
		if(b[i]=='B'&&x>0) x--;
	}
	if(x>0)
	{
		for(i=0;i<x;i++)
		    cout<<a[i];
	}
		cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

static int N;
static int book[40000];

int offset(void)
{
  int i = 1;
  int j = N-1;
  int cost = 0;

  if (!book[0]) {
    if (book[2*N]) {
      ++cost;
    } else {
      for (; i<N; ++i) {
        if (book[2*i-1] || book[2*i]) {
          break;
        } else if (book[2*(i+N)-1] || book[2*(i+N)]) {
          ++cost;
          break;
        }
      }
    }
  }

  if (!book[2*N-1]) {
    if (book[4*N-1]) {
      ++cost;
    } else {
      for (; i<j; --j) {
        if (book[2*j-1] || book[2*j]) {
          break;
        } else if (book[2*(j+N)-1] || book[2*(j+N)]) {
          ++cost;
          break;
        }
      }
    }
  }

  return cost;
}

int main(void)
{
  int i,j;
  int T;

  scanf("%d", &T);

  for (i=0; i<T; ++i) {
    int cost = 0;

    scanf("%d", &N);
    getchar();
    for (j=0; j<N*4; ++j) {
      switch (getchar()) {
      case 'Y':
        book[j] = 1;
        break;
      case 'N':
        book[j] = 0;
        break;
      }
    }
    getchar();

    cost += offset() + N;
    cost += book[0] + book[2*N];
    for (j=1; j<N; ++j) {
      if (book[2*j-1] || book[2*j]) {
        ++cost;
      }
      if (book[2*(j+N)-1] || book[2*(j+N)]) {
        ++cost;
      }
    }
    cost += book[2*N-1] + book[4*N-1];

    printf("%d\n", cost);
  }

  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
using namespace std;
#define vel vector<long long>
#define vvel vector<vel>
#define int long long
#define rep(i,n) for(long long i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define V vector
long long p = 998244353;
vel state;
int ru(int a, int r) {
	if (r == 0) { return 1; }
	int ans = ru(a, r / 2);
	ans *= ans; ans %= p;
	if (r % 2 == 1) { ans *= a; ans %= p; }
	return ans;
}
bool dfs(int i, vel &state,vvel &way) {
	if (state[i] == 2) { return false; }
	else if(state[i]==1){return true;}
	state[i] = 1;
	rep(j, way[i].size()) {
	    int to1 = way[i][j];
		if (dfs(to1, state, way)) { return true; }
	}
	state[i] = 2;
	return false;
}
signed main() {
	int n, m; cin >> n >> m;
	string c; cin >> c;
	vel st(2 * m), to(2 * m);
	rep(i, m) {
		cin >> st[i] >> to[i]; st[i]--; to[i]--;
		to[i + m] = st[i];
		st[i + m] = to[i];
	}
	vvel way(2 * n + 2 * m);
	rep(i, 2 * m) {
		int st1 = st[i];
		int to1 = to[i];
		if (c[st1] == c[to1]) {
			way[i].push_back(to1 + 2 * m);
			way[st1 + n + 2 * m].push_back(i);
		}
		else {
			way[i].push_back(to1 + n + 2 * m);
			way[st1 + 2 * m].push_back(i);
		}
	}
	int sz = 2 * n + 2 * m;
	state=vel(sz,0);
	rep(i, sz) {
		if (dfs(i, state, way)) {
			cout << "Yes" << endl; return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 50052
#include <bits/stdc++.h>
#define int long long
#define moder (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), moder - 2, moder) % moder * mod_pow(kai(y), moder - 2, moder) % moder;
}
/*--------Library Zone!--------*/

int n, a[214514], sum[214514];
signed main() {
	cin >> n;
	REP(i, n + 1) {
		cin >> a[i];
		sum[i] = sum[i - 1] + a[i];
	}
	map<int, int>mp;
	mp[0] = 1;
	int ans = 0;
	REP(i, n + 1) {
		ans += mp[sum[i]];
		mp[sum[i]]++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 15872
#include <stdio.h>

char C[105][105];

int main(){

	int H,W;

	scanf("%d %d",&H,&W);

	int i;

	for(i=1;i<=H;i++){
	scanf("%s",C[i]);
	}

	for(i=1;i<=2*H;i++){
	printf("%s\n",C[(i+1)/2]);
	}


	return 0;
}

Measured memory_bytes: 128
import static java.lang.Integer.*;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

public class Main {
	public static String N;
	public static long Ni;
	public static long count =0L;
	public static long[] i753 = {3L,5L,7L};
	public static List<Long> l753 = new ArrayList<Long>(){
	    {
	        add(3L);
	        add(5L);
	        add(7L);
	    }
	};
	public static void main(String[] args) throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
		st = new StringTokenizer(br.readLine());
		N = st.nextToken();
		Ni = parseInt(N);


		make753List();

		for(long v : l753) {
			String si = String.valueOf(v);
			if(si.contains("7") && si.contains("5") && si.contains("3")) {
				count++;

			}
		}
		System.out.println(count);


	}

	public static void make753List() {
		label : for(int i=0;i<l753.size();i++) {
			for(int k=0;k<i753.length;k++) {
				long num = l753.get(i) * 10 + i753[k];
				if(num <= Ni) {
					l753.add(num);
				}else {
					break label;
				}
			}
		}
	}

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int T;
    cin >> T;
    rep(i,T){
        ll N, M,A,B;
        cin >> N >> M >> A >> B;
        cout << floor_sum(N, M, A, B) << endl;
    }
}


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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)

using namespace std;


struct Node{
    vector<string> s;
    ll cost;
    bool operator< (const Node &r) const{
        return cost > r.cost;
    }
};

int main() {
    ll white, black;
    cin >> white >> black;

    ll h = 100;
    ll w = 100;

    vector<string> s(h, "");
    rep(hx, h){
        rep(wx, w) s[hx] += ".";
    }

    rep(hx, h){
        rep(wx, w){
            if(wx == 0)         s[hx][wx] = '.';
            else if(wx == w-1)  s[hx][wx] = '#';
            else if(hx%2 == 0)  s[hx][wx] = '.';
            else                s[hx][wx] = '#';
        }
    }
   
    ll wcnt = 1;
    ll bcnt = 1;

    ll cnt = 0;
    ll whx = 0;
    ll wwx = w-3;
    while(wcnt < white){
        if(1e6 < cnt)   break;
        cnt++;
        s[whx][wwx] = '#';
        wcnt++;
        wwx-=2;
        if(wwx < 0){
            whx+=2;
            wwx = w-3;
        }
    }

    ll bhx = h-1;
    ll bwx = 2;
    while(bcnt < black){
        if(1e6 < cnt)   break;
        cnt++;
        s[bhx][bwx] = '.';
        bcnt++;
        bwx+=2;
        if(w <= bwx){
            bhx-=2;
            bwx = 2;
        }
    }


    cout << h << " " << w << endl;
    rep(hx, h) cout << s[hx] << endl;
    cout << endl;

    

    /*
..........
..........
..........
.#.#.#.#.#
#.#.#.#.#.
.#.#.#.#.#
#.#.#.#.#.
.#.#.#.#.#
#.#.#.#.#.
.#.#.#.#.#
    */

    return 0;
}


Measured memory_bytes: 256