akhauriyash/Code-Regression huggingface dataset:
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static long dp[][]=new long[1000000][3];
    public static void main (String[]args){
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        StringBuffer sb = new StringBuffer();
        int br[][]=new int[t][3];
        for(int i=0;i<t;i++)
        {
            br[i][0]=sc.nextInt();
            br[i][1]=sc.nextInt();
            br[i][2]=sc.nextInt();
        }

        long te=vac(br,0,-1);
        //for(int i=0;i<=t;i++)
       // System.out.println(Arrays.toString(dp[i]));
        System.out.println(Math.max(Math.max(dp[0][0],dp[0][1]),dp[0][2]));
        }

    public static long vac(int br[][],int i,int ls)
    {
        //for(int p=0;p<3;p++)
          //  System.out.println(Arrays.toString(dp[p]));

        if(i>=br.length)
            return 0;
        if(ls!=-1&&dp[i][ls]!=0)
        {
            return dp[i][ls];
        }
        if(ls==0)
        {
            long r1=br[i][1]+vac(br,i+1,1);
            long r2=br[i][2]+vac(br,i+1,2);
            dp[i][ls]=Math.max(r1,r2);

        }
        else if(ls==1)
        {
            long r1=br[i][0]+vac(br,i+1,0);
            long r2=br[i][2]+vac(br,i+1,2);
            dp[i][ls]= Math.max(r1,r2);
        }
        else if(ls==2)
        {
            long r1=br[i][0]+vac(br,i+1,0);
            long r2=br[i][1]+vac(br,i+1,1);
            dp[i][ls]= Math.max(r1,r2);
        }
        else
        {
            dp[i][0]=br[i][0]+vac(br,i+1,0);
            dp[i][1]=br[i][1]+vac(br,i+1,1);
            dp[i][2]=br[i][2]+vac(br,i+1,2);
            //dp[i]=Math.max(Math.max(r1,r2),r3);
        }
        if(ls!=-1)
        return dp[i][ls];
        else
            return dp[i][0];
    }
}


Measured memory_bytes: 141488
def main():
    n, x, m = map(int, input().split())
    idx = [-1] * (m + 1)  # mで割った余り（0,1,...m-1）が何回目に出てきたか
    res = []  # 数列A

    for i in range(1, m + 3):  # 余りはm+1種類なのでm+2回計算すれば絶対ループが発生する
        if idx[x] == -1:  # 初めて
            idx[x] = i
            res.append(x)
        else:  # 既出（ループ発見）
            len_loop = i - idx[x]
            len_head = idx[x] - 1
            break
        x = (x ** 2) % m

    if n <= len_head + len_loop:  # 1ループ目までで出力する場合
        print(sum(res[:n]))
    else:
        ans = sum(res[:len_head])  # ループ前
        ans += (n - len_head) // len_loop * sum(res[len_head:])  # ループ
        ans += sum(res[len_head: len_head + (n - len_head) %
                       len_loop])  # ループ後の余り
        print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 68780
// Created by Kshitij Anand NSIT
#include <bits/stdc++.h>
//#include <ext/numeric>
//using namespace __gnu_cxx;


using namespace std;


#define int long long
#define pb push_back
#define P pair<int,int>
#define F first
#define S second
#define vi vector<int>
#define vc vector<char>
#define vb vector<bool>
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define mp(a, b) make_pair(a, b)
#define min3(a, b, c) min(min(a, b), c)
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define max3(a, b, c) max(max(a, b), c)
#define max4(a, b, c, d) max(max(a, b), max(c, d))
#define fill(arr,val) memset(arr,val,sizeof(arr))
#define inf 1e18
#define ps(x,y) fixed<<setprecision(y)<<x
#define db(x)  cout<<#x<<" : "<<x<<endl


const int N = 1000000007;

// int num_val = 1e5 + 1;

int func(P arr[] , int n , int V){

    //base cases
    int num_val = n*1000;
    int dp[105][num_val + 1];

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

        for(int j=1; j<=n; j++) {
            dp[1][i] = inf; // as it is impossible to fill with these weights

        }
    }
  
    //db(dp[n][100001]);

    dp[1][0] = 0; //as no weights will be required
    dp[1][arr[1].S] = arr[1].F;
  
    //for(int i=1 ; i<= n ; i++)
      //dp[i][0] = 0;

    //now we need to write the recurrence

    for(int i=2 ; i<= n ; i++){

        // dp[i][j] = dp[i-1][]

        for(int j=0; j<= num_val; j++) {

            dp[i][j] = dp[i-1][j];

            if(j - arr[i].S < 0) continue;
                dp[i][j] =  min(dp[i][j] ,  arr[i].F + dp[i-1][j - arr[i].S]);
        }
    }

    int ans = 0;

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

        if(dp[n][i] <= V){
            ans = max(i , ans);
        }
    }
  
    // db(dp[n][10001]);

    return ans;

}

void solve(){

    int n,V ,a,b,c, ans=0, count=0, sum=0;
    cin>>n>>V;
    P arr[n +1];
    //F->weight , S->value

    for(int i=1;i<=n;i++){
      cin>>arr[i].F>>arr[i].S;
    }

    ans = func(arr , n , V);

    cout<<ans<<endl; 
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    
  //  int t; cin>>t; while(t--)
    {     
      solve();
    }

  return 0;
}


Measured memory_bytes: 81744
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
A = [[int(x) for x in input().split()] for _ in range(N)]

grp_score = [0] * (1<<N)
for x in range(1,1<<N):
    for i in range(N):
        bit = 1<<i
        if x & bit:
            break
    s = grp_score[x^bit] # i番目の人以外
    s += sum(A[i][j] for j in range(i+1,N) if x & (1<<j))
    grp_score[x] = s

dp = [0] * (1<<N)
for x,s in enumerate(grp_score):
    y = x
    while y > x//2:
        z = x^y
        s = max(s, dp[y] + dp[z])
        y = (y-1) & x
    dp[x] = s

answer = dp[-1]
print(answer)

Measured memory_bytes: 58460
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N;
typedef pair<int, int> P;
P q[200005];

int main() {
  INCANT;
  cin >> N;
  int a;
  rep(i, N) {
    cin >> a;
    q[i] = P(a, i);
  }
  sort(q, q+N);
  int MAX=1;
  int cnt=0;
  int prev=-1;
  for (auto p: q) {
    if (p.second > prev) {
      cnt++;
      MAX=max(MAX, cnt);
    } else {
      cnt=1;
    }
    prev=p.second;
  }
  cout << N-MAX << endl;
  return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<double>u(N);
    for (int i = 0; i < N; i++) {
        cin >> u[i];
    }
    sort(u.begin(),u.end());
    double ans = u[0];
    for (int i = 1; i < N; i++) {
        ans+=u[i];
        ans/=2;
    }
    cout << setprecision(10) << ans << endl;
}

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

int main(void)
{
    string s = "aeiou";
    char c; 
    cin >> c;

    if(s.find(c) == string::npos)
        cout << "consonant" << endl;
    else 
        cout << "vowel" << endl;
   

    return 0;
}

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

namespace AtCorder
{
    public static class Program
    {
        static public void Main(string[] args)
        {
            var input1 = Console.ReadLine();
            var input2 = Console.ReadLine();
            var comp = "";
            for (var num = 0; num < input2.Length-1; num++)
            {
                comp = comp + input2[num].ToString();
            }

            if (input1 == comp)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");

            }
        }
    }
}

Measured memory_bytes: 25688
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>
#include<utility>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 1000000000
#define MOD 1000000007

typedef  long long ll;

using namespace std;

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

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

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

ll gcd(ll  a,ll b){
    ll r;
    if(a < b){
        ll tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return b;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

ll r_fuct[2000];
ll fuct[2000];

//MOD逆元
void conb(ll n,ll k){
    fuct[0] = 1;
    for(int i = 1;i < k+1;i++){
        fuct[i] *= fuct[i-1]%MOD;
        
        ll b = MOD, u = 1, v = 0;
        ll value = fuct[i];
        while (b) {
            ll t = value / b;
            value -= t * b;
            swap(value, b);
            u -= t * v;
            swap(u, v);
        }
        u %= MOD;
        if (u < 0) u += MOD;
        r_fuct[i] = u;
    }
}

void solve() {
   int n;
   cin >> n;
   ll h[n];
   bool flag = false;
   for(int i = 0;i < n;i++){
       cin >> h[i];
   }
//3 5 5 4 8 9
    ll m[n];
    ll mx = 0;
   for(int i = 0;i < n;i++){
      mx = max(mx,h[i]);
      m[i] = mx;
   } 

   for(int i = 0;i < n;i++){
       if(m[i]-1 > h[i]) flag = true;
   }
   if(flag) cout << "No" << endl;
   else cout << "Yes" << endl;

}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n); i++)

int main(){

    string N;
    int m=0,l,count=0;
    cin>>N;

    l=N.length();
    rep(i,l){
        string subN=N.substr(i,1);
        int num=stoi(subN);
        count+=num;
    }
    if(count%9==0)  cout<<"Yes"<<endl;
    else    cout<<"No"<<endl;
    
    return 0;
}

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

int main(){
while(1){
int H,W;
cin>>H>>W;

if(H == 0 && W == 0) break;

for(int i=0; i < H; i++){
   for(int j=0; j<W; j++){
       cout<<"#";
   }
   cout<<endl;
}
cout<<endl;
}

return 0;
}


Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define endl        "\n"
#define fast        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int         long long int
#define mod         1000000007
#define test        int t;cin>>t;while(t--)
#define REP(i,a,b)  for(int i=a,i<=b;i++)
#define MAXN        200001
#define INF         INT_MAX

int32_t main(){

	int n,m;
	cin>>n>>m;
	int arr[m];
	int sum=0;
	for(int i=0;i<m;i++){
		cin>>arr[i];
		sum+=arr[i];
	}
	if(sum<=n){
		cout<<n-sum<<endl;
	}
	else
		cout<<-1<<endl;

	return 0;
}

Measured memory_bytes: 3668
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
#include <random>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<bool> vbool;
typedef vector<string> vstr;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _KTy, typename _Ty> istream& operator >> (istream& istr, pair<_KTy, _Ty>& m) { cin >> m.first >> m.second; return istr; }
template <typename _Ty> istream& operator >> (istream& istr, vector<_Ty>& v) { for (size_t i = 0; i < v.size(); i++) cin >> v[i]; return istr; }
ll modpow(ll n, ll p, ll m) { ll result = 1; while (p > 0) { if (p & 1) result = (result * n) % m; p >>= 1; n = (n * n) % m; } return result; }
template <typename _Ty> _Ty ipow(_Ty x, _Ty n) { _Ty ret = _Ty(1); for (_Ty i = _Ty(0); i < n; i++) ret *= x; return ret; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#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 fake false




int main()
{
	//clock_t start, end;
	//start = clock();

	double x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;

	printf("%.10f\n", sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2)));

	//end = clock();
	//printf("%d msec.\n", end - start);

	return 0;
}



Measured memory_bytes: 3212
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector as V
import Debug.Trace

main :: IO ()
main = readLine >>= main'
    where
        main' [n, k] = getLine >>= print . solve k

solve :: Int -> String -> Int
solve k ss = prep k 0 ns
    where
        ns = map ((,) <$> head <*> length) . group $ map (== '1') ss

        prep n acc xxs@(x@(b, l) : xs)
            | b = prep n (acc + l) xs
            | n == 0 = check acc acc ns xxs
            | otherwise = prep (n - 1) (acc + l) xs
        prep _ acc _ = acc

        check acc pcc pps@((pb, pl) : ps) xxs@(_ : _)
            | pb = check (max acc rcc) rcc ps ys
            | otherwise = check (max acc rcc2) rcc2 ps ys2
            where
                rcc = pcc - pl + bls
                (bls, ys) = count 0 0 xxs

                rcc2 = pcc - pl + bls2
                (bls2, ys2) = count 1 0 xxs
        check acc _ _ _ = acc

        count n acc xxs@((b, l) : xs)
            | b = count n (acc + l) xs
            | n > 0 = count (n - 1) (acc + l) xs
            | otherwise = (acc, xxs)
        count _ acc _ = (acc, [])

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

Measured memory_bytes: 9980
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

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; }
template<class T>
T GCD(T a, T b) { if (b == 0) return a; else return GCD(b, a % b); }
template<class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

int main() {
	string s, t;
	cin >> s >> t;
	t.pop_back();
	if (t == s) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int cnt = 0;
		while(true) {
			int num = sc.nextInt();
			if(num == 0) break;
			cnt++;
			System.out.println("Case " + cnt + ": " + num);
		}
		sc.close();
	}
}


Measured memory_bytes: 41452
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define llu unsigned long long int
#define Endl endl
#define mod  1000000007
#define mkp make_pair
#define pb push_back
#define cin(n) scanf("%d",&n)
#define cout(n) printf("%d ",n)
#define sf(n) scanf("%d",&n)
#define pf(n) printf("%d ",n)
#define bitget(n) __builtin_popcountll(n)
#define maxi 500111

ll dx[] = {1,1,0,-1,-1,-1,0,1};
ll dy[] = {0,-1,-1,-1,0,1,1,1};
ll dxx[] = {1,-1,0,0};
ll dyy[] = {0,0,-1,1};
ll modexpo(ll x,ll y){if(y==0)return 1;if(y%2){ll viky=modexpo(x,y/2);
return (((x*viky)%mod)*viky)%mod;}else{ll viky=modexpo(x,y/2);return (viky*viky)%mod;
}}
ll intpoint(ll x1, ll y1, ll x2, ll y2) { return ( __gcd(abs(x1-x2),abs(y1-y2))+1); }
bool isvalid(ll x,ll y,ll n,ll m) { return (x>=0&&x<n&&y>=0&&y<m); }
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// int pp = uniform_int_distribution<int>(0, kk-1)(rng);
// ---------------------///////////////---------------------------------
// ---------------------///////////////----------------------------------
// -------------/////////////////---------------------------------///////



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

    // ll ap[n+11];
    // for(ll i=0;i<n;i++){
    //   cin>>ap[i];
    // }

    // ll a,b,c;
    // cin>>a>>b>>c;

    // ll p = __gcd(a,b);

    // ll cnt = 0;
    // for(ll i = p;i>=1;i--){
    //   if(p%i == 0){
    //     cnt++;
    //   }
    //   if(cnt == c){
    //     cout<<i;
    //     return 0;
    //   }
    // }
    string s;
    ll ans ;
    cin>>s;
    ans = s.size();
    ll zero = 0,one = 0;
    for(ll i=0;i<ans;i++){
      if(s[i]=='0'){
        zero++;
      }else{
        one++;
      }
    }
    ans = min(ans,min(zero*2,one*2));
      cout<<ans;
    // cout<<"-1\n";
    return 0;
}

Measured memory_bytes: 512
// Package main provides
//
// File:  d.go
// Author: ymiyamoto
//
// Created on Wed Dec 19 22:42:09 2018
//
package main

import "fmt"

type point struct {
	x, y int
}

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

func checkPossible(points []point) bool {
	oe := abs(points[0].x+points[0].y) % 2
	for _, p := range points {
		if oe != abs(p.x+p.y)%2 {
			return false
		}
	}
	return true
}

func pow2(n int) int {
	if n == 0 {
		return 1
	}
	return 2 * pow2(n-1)
}

func main() {
	var N int
	fmt.Scan(&N)
	points := make([]point, N)
	for i := range points {
		fmt.Scan(&points[i].x, &points[i].y)
	}

	if !checkPossible(points) {
		fmt.Println(-1)
		return
	}
	arms := []int{}
	if abs(points[0].x+points[0].y)%2 == 0 {
		arms = append(arms, 1)
	}

	for i := 0; i < 32; i++ {
		arms = append(arms, pow2(i))
	}

	fmt.Println(len(arms))
	for i, arm := range arms {
		if i != 0 {
			fmt.Print(" ")
		}
		fmt.Print(arm)
	}
	fmt.Println()

	for _, p := range points {
		u := p.x + p.y
		v := p.x - p.y
		modes := ""
		for i := len(arms) - 1; i >= 0; i-- {
			l := arms[i]
			if u >= 0 && v >= 0 {
				u -= l
				v -= l
				modes += "R"
			} else if u >= 0 && v <= 0 {
				u -= l
				v += l
				modes += "U"
			} else if u <= 0 && v >= 0 {
				u += l
				v -= l
				modes += "D"
			} else {
				u += l
				v += l
				modes += "L"
			}
		}
		for i := len(modes) - 1; i >= 0; i-- {
			fmt.Print(string(modes[i]))
		}
		fmt.Println()
	}
}


Measured memory_bytes: 2048
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		char s[] = sc.next().toCharArray();
		boolean b = true;
		int cnt = 0;
		if (s[0] == 'A') {

			for (int i = 1; i < s.length; i++) {
				if (s[i] >= 'a' && s[i] <= 'z') {
				} else if (s[i] == 'C' && i != s.length - 1 && i != 1) {
					cnt++;
					if (cnt > 1) {
						b = false;
						break;
					}
				} else {
					b = false;
					break;
				}
			}

		} else {
			b = false;
		}

		if (b && cnt == 1) {
			System.out.println("AC");
		} else {
			System.out.println("WA");
		}
	}
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.00000001
#define pi 3.141592653589793
#define pii pair<int,int>
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vii vector<int>
#define vpl vector<pll>
#define vll vector<ll>
#define sti stack <int>
#define stll stack <ll>
#define mseti multiset <ll>
#define msetd multiset <ll, greater <ll> >
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define stp setprecision(20)//use fixed before stp
#define endl '\n'
int main()
{  
    FAST
    ll h,w;
    cin>>h>>w;
    string s;
    ll a[h][w];
    ll ans[h][w];
    ll q;
    for(ll i=0;i<h;i++)
    {
        cin>>s;
        for(ll j=0;j<w;j++)
        {
            if(s[j]=='#')
                a[i][j]=1;
            else
                a[i][j]=0;
            ans[i][j]=0;
        }
    }
    for(ll i=0;i<h;i++)
    {
        q=0;
        for(ll j=0;j<w;j++)
        {
            if(a[i][j]==0)
                q++;
            else
                q=0;
            ans[i][j]+=q;
        }
        q=0;
        for(ll j=w-1;j>=0;j--)
        {
            if(a[i][j]==0)
                q++;
            else
                q=0;
            ans[i][j]+=q;
        }
    }
    for(ll i=0;i<w;i++)
    {
        q=0;
        for(ll j=0;j<h;j++)
        {
            if(a[j][i]==0)
                q++;
            else
                q=0;
            ans[j][i]+=q;
        }
        q=0;
        for(ll j=h-1;j>=0;j--)
        {
            if(a[j][i]==0)
                q++;
            else
                q=0;
            ans[j][i]+=q;
        }
    }
    ll max=0;
    for(ll i=0;i<h;i++)
    {
        for(ll j=0;j<w;j++)
        {
            if(a[i][j]==0)
            {
                if(ans[i][j]>max)
                    max=ans[i][j];
            }
        }
    }
    if(max==0)
        cout<<max;
    else
    cout<<max-3;
}

Measured memory_bytes: 62720
// #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;
using ll = long long int;
using int64 = 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;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

void solve() {
    int N; scanf("%d", &N);
    vector<ll> A(N);
    for(int i=0; i<N; i++) scanf("%lld", &A[i]);
    string s; cin >> s;

    vector<ll> base;
    for(int i=N-1; i>=0; i--) {
        ll e = A[i];
        for(auto b : base) {
            chmin(e, e ^ b);
        }

        if(s[i] == '1' and e > 0) {
            puts("1");
            return;
        }
        base.emplace_back(e);
    }
    
    puts("0");
}

int main() {
    int T; scanf("%d", &T);
    while(T--) solve();
    return 0;
}


Measured memory_bytes: 3688
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[][] arr = new int[2][n];
		for (int i = 0; i < n; i++) {
		    arr[0][i] = sc.nextInt();
		    if (i != 0) {
		        arr[0][i] += arr[0][i - 1];
		    }
		}
		for (int i = 0; i < n; i++) {
		    if (i == 0) {
		        arr[1][i] = sc.nextInt() + arr[0][i];
		    } else {
		        arr[1][i] = Math.max(arr[1][i - 1], arr[0][i]) + sc.nextInt();
		    }
		}
		System.out.println(arr[1][n - 1]);
	}
}


Measured memory_bytes: 23764
import std.stdio, std.conv, std.string;
import std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

int DEBUG_LEVEL = 0;
void print()(){ writeln(""); }
void print(T, A ...)(T t, lazy A a){ write(t), print(a); }
void print(int level, T, A ...)(T t, lazy A a){ if(level <= DEBUG_LEVEL) print(t, a); }

void main(string[] args){
	if(args.length > 1 && args[1] == "-debug"){
		if(args.length > 2 && args[2].isNumeric) DEBUG_LEVEL = args[2].to!int;
		else DEBUG_LEVEL = 1;
	}
	
	int n = read.to!int;
	int k = read.to!int;
	
	real ans = 0;
	real prob0 = 1.0 / cast(real) n;
	foreach(i; 1 .. n + 1){
		int value = i;
		real prob = prob0;
		while(value < k) prob *= 0.5, value *= 2;
		ans += prob;
	}
	
	format("%12.12f", ans).writeln;
	
}


Measured memory_bytes: 256
<?php

while (true) {
    $pos = [];
    $data_set = trim(fgets(STDIN));
    if ('-' == $data_set) break;

    $loop = trim(fgets(STDIN));
    for ($i = 0; $i < $loop; $i++) {
        $pos[] = trim(fgets(STDIN));
    }
    echo get_string($data_set, $pos) . PHP_EOL;
}
function get_string($string, $array_pos) {
    $pos = array_pop($array_pos);
    if (null == $pos) return $string;
    return get_string(substr($string, -(strlen($string) - $pos)) . substr($string, 0, $pos), $array_pos);
}


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

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

  if (N!=n){
    
    cout<<1<<endl;
  }
  else{
    cout <<0<<endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
using namespace std;
#define rep(i, j) for(int i = 0; i < j; i++)
#define f(i, k, j) for(int i = k; i < j; i++)
#define P pair<int, int>
const int INF = (1 << 26);
const int MAX_N = 1001;
const int MAX_W = 1001;

int w, n, dp[MAX_N][MAX_W];
vector<P> vec;

void solve();

int main(){
    int c = 1;
    while(cin >>w && w != 0){
        cin >>n;
        vec.clear();
        rep(i, n){
            int a, b;
            scanf("%d,%d", &a, &b);
            //first = 価値, second = 重さ
            vec.push_back( P(a, b) );
        }
        solve();
        int ans = -1, ansi = 0;
        rep(i, w + 1){
            if(dp[n][i] > ans){
                ans = dp[n][i];
                ansi = i;
            }
        }
        cout <<"Case " <<c <<":" <<endl;
        cout <<ans <<endl <<ansi <<endl;
        c++;
    }
    return 0;
}

void solve(){
    memset(dp, 0, sizeof(dp));
    rep(i, w) dp[0][i] = 0;

    rep(i, n){
        //cout <<"! " <<vec[i].first <<", " <<vec[i].second <<endl;
        rep(j, w + 1){
            if(j < vec[i].second) dp[i + 1][j] = dp[i][j];
            else dp[i + 1][j] = max(dp[i][j], dp[i][j - vec[i].second] + vec[i].first);
        }
        //rep(i, n){
        //    cout <<":";
        //    rep(j, w + 1){
        //        cout <<dp[i][j] <<", ";
        //    }
        //    cout <<endl;
        //}
    }
}

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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define dep(i, a, n) for(int i = a; i >= (n); i--)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll a, b, c, d, n, result = 0, ch = 0;
  cin >> n;
  rep(i, n) {
    result = 0, ch = 0;
    cin >> a >> b >> c >> d;
    ch = (a * c + b * d);
    if(5 <= c && 2 <= d) {
      result = ch / 5 * 4;
    } else if(5 <= c) {
      result = min(ch, (a * c + b * 2) / 5 * 4);
    } else if(2 <= d) {
      result = min(ch, (a * 5 + b * d) / 5 * 4);
    } else {
      result = min(ch, (a * 5 + b * 2) / 5 * 4);
    }
    cout << result << endl;
  }
	return 0;
}


Measured memory_bytes: 3200
import java.io.*;
import java.util.*;
public class Main {
	
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		int N = Integer.parseInt(st.nextToken());
		double count = 0;
		for (int i = 0; i < N; i++) {
			st = new StringTokenizer(br.readLine());
			double x = Double.parseDouble(st.nextToken());
			String u = st.nextToken();
			if (u.equals("BTC")) {
				x *= 380000.0;
				count += x;
			}
			else if (u.equals("JPY")) {
				count += x;
			}
		}
		System.out.println(count);
	}

}

Measured memory_bytes: 21076
#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) (v).begin(),(v).end()
#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; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const ll INFL = 1e18+100;
const ll MOD = 1e9+7;
const bool debug = 0;
//-----------------------------------------------//

int N;
int A[212345]; // 0-index
int sum[212345], sux[212345]; // 1-index

int main() {
	cin >> N;
	REP(i, N) scanf("%d", A + i);
	
	REP(i, N) sum[i + 1] = sum[i] + A[i];
	REP(i, N) sux[i + 1] = sux[i] ^ A[i];
	
	ll ans = 0;
	int r = 0;
	REP(i, N) {
		while (r < N - 1 && (sum[r+2] - sum[i]) == (sux[r+2] ^ sux[i])) r++;
		ans += r - i + 1;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 2560
/*================================================================
*   Copyright (C) 2019 Sangfor Ltd. All rights reserved.
*
*   创 建 者： badcw
*   创建日期： 2019/12/22
*
================================================================*/
#include <bits/stdc++.h>

#define ll long long
using namespace std;

const int maxn = 1e5+50;
const int mod = 1e9+7;
ll qp(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

template <class T>
inline bool scan(T& ret) {
    char c;
    int sgn;
    if (c = getchar(), c == EOF) return 0; // EOF
    while (c != '-' && (c < '0' || c > '9')) c = getchar();
    sgn = (c == '-') ? -1 : 1;
    ret = (c == '-') ? 0 : (c - '0');
    while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
    ret *= sgn;
    return 1;
}

//template <class T>
//inline void out(T x) {
//    if (x > 9) out(x / 10);
//    putchar(x % 10 + '0');
//}

int main(int argc, char* argv[]) {
    ll a, b;
    scanf("%lld%lld", &a, &b);
    printf("%lld\n", a / __gcd(a, b) * b);
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main() {
    ll n; // 0 <= n <= 10^18
    ll k; // 1 <= k <= 10^18
    cin >> n >> k;

    cout << min(n % k, k - (n % k)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(a) begin(a),end(a)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1e+9;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
ll gcd(ll a, ll b){
  if (b==0) return a;
  else return gcd(b,a%b);
}
int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



int par[1000010];
int Tree_rank[1000010];

void init(int n) {
  for(int i=0; i<n; i++) {
    par[i] = i;
    Tree_rank[i] = 0;
  }
}

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

void unite(int x, int y) {
  x = find(x);
  y = find(y);

  if(x == y) return;

  if(Tree_rank[x] < Tree_rank[y]) {
    par[x] = y;
  }
  else {
    par[y] = x;
    if(Tree_rank[x] == Tree_rank[y]) Tree_rank[x]++;
  }
}

bool same(int x, int y) {
  return find(x) == find(y);
}


map<int,int> mp;
vector<int> p;

int main() {
  int N,M;
  cin >> N >> M;
  p.resize(N);
  init(N);
  rep(i,N) {
    int a;
    cin >> a;
    a--;
    mp[a] = i;
  }
  rep(i,M) {
    int x,y;
    cin >> x >> y;
    x--;
    y--;
    unite(x,y);
  }
  int ans = 0;
  rep(i,N) {
    if(same(mp[i],i)) ans++;
  }
  cout << ans << endl;
  
}


Measured memory_bytes: 9856
#include <bits/stdc++.h>
   
using namespace std;
#define pb push_back
#define int long long


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


    double l;
    cin>>l;
    
    double ans=(l*l*l);
    ans=ans/(27);
    cout<<fixed<<setprecision(7)<<ans;
        
        
    
   
    
    
   
}

Measured memory_bytes: 256
#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 A, ll B, ll C, ll D, ll E){
    ll dish[5] = {A, B, C, D, E};
    ll ddish[5];
    ll sum = 0;
    rep(i, 5) {
        ddish[i] = dish[i] % 10 == 0 ? dish[i] : (dish[i] / 10 + 1) * 10;
        sum += ddish[i];
    }
    ll mn = 10000;
    rep(i, 5) {
        ll res = sum - ddish[i] + dish[i];
        mn = min(res, mn);
    }
    cout << mn << endl;
}

int main() {
  ll A;
    scanf("%lld",&A);
    ll B;
    scanf("%lld",&B);
    ll C;
    scanf("%lld",&C);
    ll D;
    scanf("%lld",&D);
    ll E;
    scanf("%lld",&E);
  solve(A, B, C, D, E);
  return 0;
}


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

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

    if(s == "ARC") cout << "ABC" << endl;
    else cout << "ARC" << endl;

    return 0;
}

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

const int M = 1000005;

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for (int i = 0; i < N; i++) cin >> vec.at(i);

    vector<int> cnt(M);
    for (int x : vec) {
        if (cnt.at(x) != 0) {
            cnt.at(x) = 2;
            continue;
        }
        for (int i = x; i < M; i += x) cnt.at(i)++;
    }

    int num = 0;
    for (int x : vec) {
        if (cnt.at(x) == 1) num++;
    }
    cout << num << endl;
}

Measured memory_bytes: 8028
#include <algorithm>
#include <cassert>
#include <iostream>
#include <numeric>
#include <set>
#include <tuple>
#include <vector>
using namespace std;

vector<int> build_edges(const string &s) {
  const int n = s.size();
  vector<int> edges(n);
  for (int i = 0, j = 0; ; ++i, ++j ) {
    while (i < n && s[i] != 'a') ++i;
    while (j < n && s[j] != 'b') ++j;
    if (i < n) {
      assert(j < n);
      edges[i] = j;
      edges[j] = i;
    } else {
      assert(j == n);
      break;
    }
  }
  return edges;
}

string solve_a(const string &s) {
  string res = "";
  const vector<int> edges = build_edges(s);
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == 'a') {
      res += "ab";
      assert(edges[i] > i);
      i = edges[i];
    }
  }
  return res;
}

string solve_b(const string &s) {
  string res = "";
  for (int i = 0, skipped_b = 0; i < s.size(); ++i) {
    if (s[i] == 'b') {
      // try pick this one first
      string current;
      for (int j = i, rest_a = skipped_b; j < s.size(); ++j) {
        if (rest_a <= 0 || s[j] == 'b') current += s[j];
        if (s[j] == 'a') --rest_a;
      }
      res = max(res, current);
      ++skipped_b;
    } else if (s[i] == 'a') {
      --skipped_b;
    }
  }
  return res;
}

int main() {
  int n;
  string s;
  cin >> n >> s;
  vector<int> l, r;
  for (int i = 0, t = 0; i < 2 * n; ++i) {
    if (t == 0) l.push_back(i);
    t += s[i] == 'a' ? +1 : -1;
    if (t == 0) r.push_back(i + 1);
  }
  assert(l.size() == r.size());
  assert(l.front() == 0);
  assert(r.back() == 2 * n);
  const int t = l.size();

  reverse(l.begin(), l.end());
  reverse(r.begin(), r.end());
  string res = "";
  for (int i = 0; i < t; ++i) {
    string chunk = s.substr(l[i], r[i] - l[i]);
    string current = (s[l[i]] == 'a') ? solve_a(chunk) : solve_b(chunk);
    res = max(res, current + res);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
const ll MOD = 1e9+7;
const ll MAX = 1e6+5;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll dp[MAX][4]={};
signed main(){
  init_io();
  ll n;
  COMinit();
  cin >> n;
  dp[0][0] = 1;
  for(ll i=0;i<n;i++){
    for(int j=0;j<4;j++){
      for(int k=0;k<10;k++){
        ll nb = j;
        if(k==0) nb |= 1;
        if(k==9) nb |= 2;
        dp[i+1][nb] += dp[i][j];
        dp[i+1][nb] %= MOD;
      }
    }
  }
  cout << dp[n][3] << endl;
}


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

using namespace std;

int main(){
    int h,w,k;
    cin>>h>>w>>k;
    int grid[h][w];
    for(int i=0;i<h;i++){
        string s;
        cin>>s;
        for(int j=0;j<w;j++){
            grid[i][j]=s[j]=='.'?1:0;
        }
    }
    int ans=0;
    for(int i=0;i<(1<<h);i++){
        for(int j=0;j<(1<<w);j++){
            int new_grid[h][w];
            for(int ii=0;ii<h;ii++){
                for(int jj=0;jj<w;jj++){
                    new_grid[ii][jj]=grid[ii][jj];
                }
            }
            for(int dig=0;dig<7;dig++){
                if(i&(1<<dig)){
                    for(int ii=0;ii<w;ii++){
                        new_grid[dig][ii]=1;
                    }
                }
                if(j&(1<<dig)){
                    for(int jj=0;jj<h;jj++){
                        new_grid[jj][dig]=1;
                    }
                }
            }
            int count=0;
            for(int ii=0;ii<h;ii++){
                for(int jj=0;jj<w;jj++){
                    if(new_grid[ii][jj]){
                        continue;
                    }
                    count++;
                }
            }
            //cout<<count<<endl;
            if(count==k){
                //cout<<i<<" "<<j<<endl;
                ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define NUM 1000000009
#define MAX 100001
#define INF LLONG_MAX
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    double d,t,s;
    cin>>d>>t>>s;
    double ans = d*1.0/s;
    if(ans<=t)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3736
N,K = map(int,input().split())
A = list(map(lambda x:int(x)-1,input().split()))
i = 0
visited = set([0])

while K > 0:
    i = A[i]
    K -= 1
    if i in visited:
        break
    visited.add(i)
if K == 0:
    print(i+1)
    exit(0)
ls = [i]
j = i
while True:
    j = A[j]
    if j == i:
        break
    ls.append(j)
print(ls[K % len(ls)]+1)

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

#define UPPER_BOUND 100000
#define UPPER_BOUND_INDEX 12
#define POW_BOUND 7+1

typedef enum { false, true } bool;

int change[UPPER_BOUND_INDEX];

int min = 100000;
bool flag = true;

void change_array(void)
{
    int i, index6, index9, pow6[POW_BOUND], pow9[POW_BOUND];
    
    
    index6 = index9 = 0;
    
    
    for(i=0; i<POW_BOUND; i++)
    {
        pow6[i] = pow(6, i);
        pow9[i] = pow(9, i);
    }
    
    for(i=0; pow6[index6]<=UPPER_BOUND || pow9[index9]<=UPPER_BOUND; i++)
    {
        if(pow6[index6] < pow9[index9])
        {
            change[i] = pow6[index6];
            
            index6++;
                
            continue;
        }
        if(pow6[index6] > pow9[index9])
        {
            change[i] = pow9[index9];
            
            index9++;
            
            continue;
        }
        if(pow6[index6] == pow9[index9])
        {
            change[i] = pow6[index6];
            
            index6++;
            index9++;
            
            continue;
        }
    }
    /*for(i=0; i<UPPER_BOUND_INDEX; i++)
    {
        printf("%d\n", change[i]);
    }*/
}

int change_index(int N)
{
    int i;
    
    
    for(i=UPPER_BOUND_INDEX-1; i>=0; i--)
    {
        if(change[i] <= N)
            break;;
    }
    
    return i;
}

void DIV(int R, int index, int num)
{
    int i;
    
    
    if(num >= min)
    {
        flag = false;
        
        return;
    }
    else if(index == 0)
    {
        if(min > num + R)
            min = num + R;
            
        return;
    }
    else
    {
        if(R >= change[index])
        {
            for(i=R/change[index]; i>=0; i--)
            {
                if(flag)
                {
                    DIV(R-change[index]*i, index-1, num+i);
                }
                else
                {
                    flag = true;
                    
                    return;
                }
            }
        }
        else
        {
            DIV(R, index-1, num);
        }
    }
}

int main(void)
{
    int N;
  
  
    scanf("%d", &N);


    change_array();

    DIV(N, change_index(N), 0);


    printf("%d\n", min);


    //system("pause");
    return 0;
}


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

int main()
{
  	int n;
  	cin>>n;
  	string s[n];
  	for(int i = 0; i < n; i++)
      cin>>s[i];
  	int m[n][26];
  	memset(m, 0, sizeof(m));
  	for(int i = 0; i < n; i++)
    {
    	for(int j = 0; j < s[i].length(); j++)
          	m[i][s[i][j]-'a'] += 1;
    }
  	//string res = "";
  	for(int j = 0; j < 26; j++)
    {
      	int mi = INT_MAX, flag = 0;
    	for(int i = 0; i < n; i++)
        {
        	if(m[i][j] == 0)
            {
              	flag = 1;
              	break;
            }
          	mi = min(mi, m[i][j]);
        }
      	if(flag == 0)
        {
          	for(int k = 0; k < mi; k++)
              	cout<<char('a'+j);
        }
    }
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cstdio>
#include<vector>
#include<queue>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long LL;
const int mod = 998244353;
inline int read()
{
	register int x = 0 , f = 0; register char c = getchar();
	while(c < '0' || c > '9') f |= c == '-' , c = getchar();
	while(c >= '0' && c <= '9') x = (x << 3) + (x << 1) + c - '0' , c = getchar();
	return f ? -x : x;
}
int n , sa , sb;
int a[420] , b[420] , f[420][420][420] , inv[420] , fac[420];
inline int add(int a , int b) { a += b; return a >= mod ? a - mod : a; }
inline int mul(int a , int b) { return (LL)a * b % mod; }
inline int ksm(int a , int k) { int ans = 1; for( ; k ; k >>= 1 , a = mul(a , a)) if(k & 1) ans = mul(ans , a); return ans; }
int main()
{
	n = read();
	for(int i = 1 ; i <= n ; ++i) sa += (a[i] = read()) , sb += (b[i] = read());
	inv[0] = fac[0] = 1;
	for(int i = 1 ; i <= 400 ; ++i) fac[i] = mul(fac[i-1] , i);
	inv[400] = ksm(fac[400] , mod - 2);
	for(int i = 399 ; i ; --i) inv[i] = mul(inv[i+1] , i+1);
	f[0][0][0] = mod - 1;
	for(int i = 0 ; i <  n ; ++i)
		for(int j = 0 ; j <= sa ; ++j)
			for(int k = 0 ; k <= sb ; ++k) if(f[i][j][k])
			{
				f[i+1][j][k] = add(f[i+1][j][k] , f[i][j][k]);
				int res = 1;
				for(int l = 0 ; l < b[i+1] ; ++l , res = mul(res , a[i+1])) f[i+1][j+a[i+1]][k+l] = add(f[i+1][j+a[i+1]][k+l] , mod - mul(f[i][j][k] , mul(inv[l] , res)));
			}
	int ans = 0;
	for(int i = 0 ; i <= sa ; ++i)
	{
		int y = ksm(i , mod - 2);
		int x = mul(sa , y);
		for(int j = 0 ; j <= sb ; ++j , x = mul(x , y)) ans = add(ans , mul(mul(fac[j] , x) , f[n][i][j]));
	}
	cout << ans << '\n';
	return 0;
}



Measured memory_bytes: 274688