akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <vector>

#define rep(i,st,ed) for (int i=st;i<=ed;++i)

const int N=400005;

std:: vector <int> v;

struct edge {int x,y,next;} e[N];

int vis[N],cnt[N],a[N];
int ls[N],edCnt,ans;

int read() {
	int x=0,v=1; char ch=getchar();
	for (;ch<'0'||ch>'9';v=(ch=='-')?(-1):v,ch=getchar());
	for (;ch<='9'&&ch>='0';x=x*10+ch-'0',ch=getchar());
	return x*v;
}

void add_edge(int x,int y) {
	e[++edCnt]=(edge) {x,y,ls[x]}; ls[x]=edCnt;
	e[++edCnt]=(edge) {y,x,ls[y]}; ls[y]=edCnt;
}

void dfs(int x) {
	vis[x]=1; v.push_back(x);
	for (int i=ls[x];i;i=e[i].next) {
		if (vis[e[i].y]) continue;
		dfs(e[i].y);
	}
}

int main(void) {
	int n=read(),m=read();
	rep(i,1,n) a[i]=read();
	rep(i,1,m) add_edge(read(),read());
	rep(i,1,n) if (!vis[i]) {
		v.clear();
		dfs(i);
		for (int x:v) ++cnt[x];
		for (int x:v) if (cnt[a[x]]) ans++;
		for (int x:v) --cnt[x];
	}
	printf("%d\n", ans);
	return 0;
}

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

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}

signed main(){
    string s;
    cin >> s;
    int n = s.size();
    int cn = 0;
    int ans = n;
    for(int i = 0; i < n; ++i){
        if(s[i] == 'S'){
            ++cn;
        }
        else{
            if(cn){
                --cn;
                ans -= 2;
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3720
#include<bits/stdc++.h>
#define int long long
#define INF 1<<25
using namespace std;

int N,W;
int ans;
int v[1010],w[1010];
int mem[10100][10100];

int dfs(int n,int h){
    if(n==0){
        ans=0;
    }
    else if(mem[n][h]!=0)ans=mem[n][h];
    else if(w[n]>h)ans=dfs(n-1,h);
    else {
        ans=max(dfs(n-1,h),dfs(n-1,h-w[n])+v[n]);
    }
    return mem[n][h]=ans;
}

signed main(){
    cin>>N>>W;
    for(int i=1;i<=N;i++){
        cin>>v[i]>>w[i];
    }
    cout<<dfs(N,W)<<endl;
}

Measured memory_bytes: 9352
N = int(input())
x = [0] * N
u = [0] * N
for i in range(N):
    x[i], u[i] = map(str, input().split())

ans = 0
for i in range(N):
    if u[i] == "JPY":
        ans += int(x[i])
    else:
        ans += float(x[i]) * 380000
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cctype>
#include <vector>
#include <numeric>
#include<string>

using namespace std;

#define ll long long
#define rep(cnt,a,n) for(ll cnt=a;cnt<n+a;cnt++) //aから始めてn回ループ
#define vector2(type,name,a,b) vector<vector<type>> name(a, vector<type>(b))
#define PI 3.141592653589793



int main() {
    
    ll n;
    cin >> n;
    vector<ll> bts;
    while (n>0) {
        n--;
        bts.push_back(n % 26);
        n /= 26;
    }
    ll s = bts.size();
    rep(cnt,0, s) {
        char c = 'a' + bts[s - 1 - cnt];

        cout << c;
    }
    cout << endl;
    



    return 0;
}

Measured memory_bytes: 3600
#!/usr/bin/env python
"""<https://github.com/cheran-senthil/PyRival>"""
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
else:
    _str = str
    str = lambda x=b"": x if type(x) is bytes else _str(x).encode()


def main():
    n, k  = map(int, input().split())

    print(n - k + 1)


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._buffer = BytesIO()
        self._fd = file.fileno()
        self._writable = "x" in file.mode or "r" not in file.mode
        self.write = self._buffer.write if self._writable else None

    def read(self):
        if self._buffer.tell():
            return self._buffer.read()
        return os.read(self._fd, os.fstat(self._fd).st_size)

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()

    def flush(self):
        if self._writable:
            os.write(self._fd, self._buffer.getvalue())
            self._buffer.truncate(0), self._buffer.seek(0)


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", b" "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", b"\n"))
    if kwargs.pop("flush", False):
        file.flush()


sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip(b"\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 28652
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        int x = Integer.parseInt(sc.next());
        int y = Integer.parseInt(sc.next());

        System.out.println(calcCost(n,k,x,y));
        sc.close();
    }

    public static  int calcCost(
          final int n
        , final int k
        , final int x
        , final int y) {

        if(n <= k) {
            return x * n;
        } else {
            return x * k + y * (n - k);
        }
    }
}

Measured memory_bytes: 23636
D,G=map(int,input().split())
p=[0]*D
c=[0]*D
for i in range(D):
    p[i],c[i]=map(int,input().split())

ans=1000
for i in range(2 ** D):
    op = ["-"] * D
    for j in range(D):
        if ((i >> j) & 1):
            op[D - 1 - j] = "+"
    s=0
    cnt=0
    for j in range(D):
        if op[j]=="+":
            s+=100*(j+1)*p[j]
            s+=c[j]
            cnt+=p[j]
    if s<G:
        for j in range(D-1,-1,-1):
            if op[j]=="-":
                for k in range(p[j]):
                    if s>=G:
                        break
                    s+=100*(j+1)
                    cnt+=1
    ans=min(cnt,ans)

print(ans)

Measured memory_bytes: 9124
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 5100000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main(){
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N >> K;
  Vec(P,double,N,0);
  rep(i,0,N)cin >> P[i];
  rep(i,0,N)P[i]=(P[i]+1)/2;
  Vec(Q,double,N,0);
  Vec(R,double,0,0);
  Q[0]=P[0];
  rep(i,1,N)Q[i]=Q[i-1]+P[i];
  R.pb(Q[K-1]);
  rep(i,K,N)R.pb(Q[i]-Q[i-K]);
  Sort(R);
  cout<<fixed;
  Out(R[N-K]);
}


Measured memory_bytes: 5492
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  string str;
  cin >> str;
  int q,i;
  cin >> q;
  string s1,s2;
  int a,b;
  for(i=0;i<q;i++){
    //cout << str << endl;
    cin >> s1 >> a >> b;
    if(s1=="print"){
      cout << str.substr(a,b-a+1) << endl;
    }else if(s1=="reverse"){
      string s3=str.substr(a,b-a+1);
      reverse(s3.begin(),s3.end());
      str=str.substr(0,a)+s3+str.substr(b+1,str.size()-a-1);
    }else{
      cin >> s2;
      str=str.substr(0,a)+s2+str.substr(b+1,str.size()-a-1);
    }
  }
}



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

ll N, M;
vector<int>childs[100010];
vector<int>parents[100010];
int ans[100010];
int childsNum[100010];

int main(){
    rep(i, 100010)ans[i]=-1;
    cin >> N >> M;
    for(int i=0;i<N-1+M;i++){
        int a, b;
        cin >> a >> b;
        childs[a].push_back(b);
        parents[b].push_back(a);
    }
    queue<int>Q;
    for(int i=1;i<=N;i++){
        childsNum[i] = childs[i].size();
        if(childsNum[i]==0)Q.push(i);
    }
    while(!Q.empty()){
        int id = Q.front();
        Q.pop();
        ans[id] = -2;
        for(int i=0;i<childs[id].size();i++){
            //cout << id << " -> " << childs[id][i] << " : " <<  ans[childs[id][i]] << endl;
            if(ans[childs[id][i]]==-2){

                ans[childs[id][i]] = id;
            }
        }
        for(int i=0;i<parents[id].size();i++){
            childsNum[parents[id][i]]--;
            if(childsNum[parents[id][i]] == 0){
                Q.push(parents[id][i]);
            }
        }
    }
    for(int i=1;i<=N;i++){
        if(ans[i]==-2)cout<<0<<endl;
        else cout << ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 12544
#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define mp make_pair
#define All(v) v.begin(),v.end()
#define mod 1000000007

using namespace std;
int a[400005];
bool vis[400005];
int main()
{
    int n;
    cin >> n;
    for(int i=0; i<3*n; i++)
        scanf("%d",&a[i]);

    ll half1 = 0;
    ll half2 = 0;

    priority_queue<int,vector<int>,greater<int> > L;
    priority_queue<pair<int,int>,vector<pair<int,int> > ,greater<pair<int,int> > > R;

    for(int i=0; i<n; i++)
    {
        half1 += a[i];
        L.push(a[i]);
    }
    vector<pair<int,int> > v;
    for(int i=n; i<3*n; i++)
    {
        v.push_back(mp(a[i],i));
    }
    sort(All(v));
    for(int i=0; i<n; i++)
    {
        half2 += v[i].F;
        vis[v[i].S] = 1;
    }
    int last = n-1;
    for(int i=n; i<v.size(); i++)
        R.push(v[i]);

    ll res = half1 - half2;
    for(int i=n; i<2*n; i++)
    {

        if(vis[i])
        {
        //    cout << a[i] << endl;
            half2 -= a[i];
            vis[i] = 0;
            while(R.top().S <= last)
                R.pop();
            pair<int,int> x = R.top();
            R.pop();
            vis[x.S] = 1;
            half2 += x.F;
           // cout << ": " << half1 << endl;
            if(a[i] > L.top())
            {
                half1 += a[i];
                half1 -= L.top();
                L.pop();
                L.push(a[i]);
            last = i;
            }
        }
        else
        {
            if(a[i] > L.top())
            {
                half1 += a[i];
                half1 -= L.top();
                L.pop();
                L.push(a[i]);
                last = i;
            }
        }
       // cout << half1 << " " << half2 << endl;
       // cout << res << endl;
        res = max(res,half1-half2);
    }
    cout << res << endl;


    return 0;
}


Measured memory_bytes: 5360
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    cout << (n % 2 == 0 ? n : n * 2) << EOL;
}


Measured memory_bytes: 256
//  Copyright 2020 Nikita Golikov

#include <bits/stdc++.h>

using namespace std;

using i64 = int64_t;
using ui64 = uint64_t;

template <class A, class B>
bool smin(A &x, B &&y) {
  if (y < x) {
    x = y;
    return true;
  }
  return false;
}

template <class A, class B>
bool smax(A &x, B &&y) {
  if (x < y) {
    x = y;
    return true;
  }
  return false;
}

int main() {
#ifdef GOLIKOV
  assert(freopen("in", "rt", stdin));
  auto _clock_start = chrono::high_resolution_clock::now();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;
  vector<int> a(n);
  for (int& x : a) cin >> x;
  sort(a.begin(), a.end());
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      for (int k = j + 1; k < n; ++k) {
        if (a[i] != a[j] && a[j] != a[k]) {
          ans += (a[i] + a[j]) > a[k];
        }
      }
    }
  }
  cout << ans << '\n';

#ifdef GOLIKOV
  cerr << "Executed in " << chrono::duration_cast<chrono::milliseconds>(
      chrono::high_resolution_clock::now()
          - _clock_start).count() << "ms." << endl;
#endif
  return 0;
}


Measured memory_bytes: 3644
// glory be to the sky
#include<bits/stdc++.h> 


using namespace std;
	
typedef long long ll; 



int main(){

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

	int n, m;
	int dg[250];
	cin >> n >> m;
	memset(dg, 0, sizeof(dg));
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		++dg[a];
		++dg[b];
	}
	for (int i = 1; i <= n; i++) cout << dg[i] << endl;
	return 0;	
}


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

int main(){
  int A,B;
  cin >> A >> B;
  int flag =1;
  int C = 0;
  while(flag){
    C = max(A,B)%min(A,B);
    if(C==0){
      flag =0;
    }else{
      A = B;
      B = C;
    }
  }
  cout << B << endl;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef pair<int,ii> iii;
typedef pair<int, iii> iiii;
typedef pair<double, ii> dii;
typedef long long ll;
typedef pair<ll, ii> lii;
const int INF = 1000000000;
const double EPS = 1e-9;
#define LSOne(S) (S & (-S))
int mods(int a, int b) { return (b + (a%b)) % b; }

int n, cap, w[105], v[105];
ll dp[105][100005];

ll solve(int id, int rem) {
    if (id == n || rem == 0) return 0;
    if (dp[id][rem] != -1) return dp[id][rem];

    ll ans = solve(id+1, rem);
    if (rem >= w[id]) ans = max(ans, v[id] + solve(id+1, rem-w[id]));

    return dp[id][rem] = ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    cin >> n >> cap;

    for (int i = 0; i < n; i++)
        cin >> w[i] >> v[i];

    memset(dp, -1, sizeof(dp));
    cout << solve(0, cap) << '\n';


    return 0;
}


Measured memory_bytes: 82304
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    H,W=MI()
    A=LLIN(H)
    odds=[]
    ans=[]
    for i in range(H):
        if i&1:
            for j in range(W)[::-1]:
                if A[i][j]&1:
                    if j==0:
                        dy=1
                        dx=0
                    else:
                        dy=0
                        dx=-1
                    if i+dy!=H:
                        
                        ans.append((i+1,j+1,i+dy+1,j+dx+1))
                        A[i+dy][j+dx]+=1
        else:
            for j in range(W):
                if A[i][j]&1:
                    if j==W-1:
                        dy=1
                        dx=0
                    else:
                        dy=0
                        dx=1
                    if i+dy!=H:
                       
                        ans.append((i+1,j+1,i+dy+1,j+dx+1))
                        A[i+dy][j+dx]+=1

    print(len(ans))
    for a in ans:
        print(*a)
    


if __name__ == '__main__':
  main()

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

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

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

// 枝定義
struct Edge
{
	ll	to;
	ll	dist;
	Edge(){}
	Edge(int to, ll dist) : to(to), dist(dist){}
};

// グラフ定義(二次元配列)
template <class E>
using Graph = vector<vector<E>>;

// ダイクストラ
class Dijkstra
{
public:
	// res[i] = sからiまでの最短距離
	vector<ll> res;

	// 復元パス
	//	vector<int> pathList;

	vector<ll> pathRev;

public:
	template<class E>
	Dijkstra(const Graph<E> &G, int startFrom)
	{
		int V = (int)G.size();
		res = vector<ll>(V, INF);
		pathRev.resize(V, -1);

		using P = pair<ll, int>;
		priority_queue<P, vector<P>, greater<P>> que;
		que.push(P(0, startFrom));
		res[startFrom] = 0;

		while (!que.empty()) {
			P p = que.top(); que.pop();
			int egdeFrom = p.second;

			// 違う最短距離がキューにあるのでスキップ
			if (res[egdeFrom] < p.first) {
				continue;
			}

			// 最短距離を更新
			for (E edge : G[egdeFrom]) {
				ll nextDist = p.first + edge.dist;
				if (nextDist < res[edge.to]) {
					res[edge.to] = nextDist;
					pathRev[edge.to] = egdeFrom;
					que.push(P(nextDist, edge.to));
				}
			}
		}
	}

	// 経路を取得する
	vector<ll> getPath(ll dstPos)
	{
		vector<ll> pathList;

		while (dstPos != -1) {
			pathList.push_back(dstPos);
			dstPos = pathRev[dstPos];
		}
		reverse(pathList.begin(), pathList.end());
		return pathList;
	}
};

// 処理
void Solve()
{
	int N, M;
	cin >> N >> M;
	Graph<Edge>	G(N);
	REP(i, M) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		G[a].emplace_back(Edge(b, 1));
		G[b].emplace_back(Edge(a, 1));
	}

	Dijkstra dijk(G, 0);
	if (0 ==  count_if(ALL(dijk.res), [](ll one ){ return one == INF;})) {
		cout << "Yes" << endl;
		REPN(i, 1, N) {
			cout << dijk.pathRev[i] + 1 << endl;
		}
	} else {
		cout << "No" << endl;
	}
}

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


Measured memory_bytes: 19508
#include <bits/stdc++.h>
using namespace std;
const int dx[5]={0,0,0,-1,1};
const int dy[5]={0,-1,1,0,0};
struct node {
	int x,y,s;
};
int n,m;
bool vis[30][30];
char a[30][30];
int bfs(int x,int y) {
	memset(vis,0,sizeof(vis));
	vis[x][y]=1;
	queue <node> q;
	q.push((node){x,y,0});
	int Max;
	while (!q.empty()) {
		node h=q.front();
		q.pop();
		for (int i=1; i<=4; i++) {
			int tx=h.x+dx[i],ty=h.y+dy[i];
			if (vis[tx][ty]==1||a[tx][ty]=='#'||tx<1||tx>n||ty<1||ty>m) {
				continue ;
			}
			vis[tx][ty]=1;
			q.push((node){tx,ty,h.s+1});
			Max=h.s+1;
		} 
	}
	return Max;
}
int main() {
	cin>>n>>m;
	for (int i=1; i<=n; i++) {
		for (int j=1; j<=m; j++) {
			cin>>a[i][j];
		}
	}
	int Max=0;
	for (int i=1; i<=n; i++) {
		for (int j=1; j<=m; j++) {
			if (a[i][j]=='#') {
				continue ;
			}
			Max=max(Max,bfs(i,j));
		}
	}
	cout<<Max;
    return 0;
}

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

void chmax (int &x, int a) {
    x = max(x, a);
}

signed main () {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    vector < int > points_beg, points_end; // whats the point, dumbass?
    if (s.front() == '0') {
        int i;
        for (i = 0; i < n; ++i) {
            if (s[i] == '1')
                break;
        }
        points_end.push_back(i);
    }
    points_beg.push_back(0);
    for (int i = 1; i < n; ++i) {
        if (s[i] == '1' && s[i - 1] == '0')
            points_beg.push_back(i);
        if (s[i] == '0' && s[i - 1] == '1')
            points_end.push_back(i);
    }
    if (s.back() == '0') 
        points_beg.push_back(points_end.back());
    points_end.push_back(n);
    int ans = 0;
    for (int i = 0; i < int(points_beg.size()); ++i) 
        chmax(ans, points_end[min(i + k, int(points_end.size()) - 1)] - points_beg[i]);
    cout << ans << '\n';
}


Measured memory_bytes: 1020
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int A[110000],n,K;
long long B[110000],C[110000];
int main(){
	scanf("%d%d",&n,&K);
	for (int i=1;i<=n;i++) scanf("%d",&A[i]);
	for (int i=1;i<=n;i++){
		B[i]=B[i-1]+max(A[i],0);
		C[i]=C[i-1]+A[i];
	}
	long long ans=0;
	for (int i=1;i<=n-K+1;i++){
		int l=i,r=i+K-1;
		long long num=B[l-1]+B[n]-B[r];
		ans=max(ans,num+max(C[r]-C[l-1],0ll));
	}
	cout<<ans<<endl;
}

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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
    }

    vector<int> dp(n,0);
    rep(i,k){
        rep(j,n) dp[j] = 0;
        rep(j,n){
            int left, right;
            left = j - a[j];
            right = j + a[j];
            int begin; 
            if(left<0) begin = 0;
            else begin = left;
            dp[begin]++;
            if(right<n-1) dp[right+1]--;
        }
        rep(j,n){
            if(j>0) dp[j] += dp[j-1];
        }
        rep(j,n){
            int tmp = dp[j];
            a[j] = tmp;
        }
        
        int flag = 0;
        rep(j,n){
            if(a[j]<n) {
                flag = 1;
                break;
            }
        }
        if(!flag){
            rep(j,n){
                cout << n << " ";
            }
            cout << endl;
            return 0;
        }
    }

    rep(i,n) cout << a[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 4844
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

//ABC179D
int main(void) {
  long long n, k, m, i, j, tmp, mod=998244353;
  scanf("%lld %lld", &n, &k);
  long long le[k], ri[k], cou[n];
  for(i=0; i<k; i++){
    scanf("%lld %lld", &le[i], &ri[i]);
  }
  for(i=0; i<n; i++)
    cou[i]=0;
  cou[0]=1;

  for(i=1; i<n; i++){
    cou[i]=cou[i-1];
    for(j=0; j<k; j++){
      if(i-le[j]<0) continue;
      else if(i-ri[j]<=0) cou[i]=(cou[i]+cou[i-le[j]])%mod;
      else cou[i]=(cou[i]+cou[i-le[j]]-cou[i-ri[j]-1])%mod;
      //printf("cou[%lld]=%lld\n", i, cou[i]);
    }
  }
  tmp=cou[n-1]-cou[n-2];
  while(tmp<0)tmp+=mod;
  printf("%lld", tmp%mod);
  return 0;

  /*for(i=0; i<n; i++){
   if(cou[i]==0)continue;
   for(j=0; j<k; j++){
   for(m=le[j]; m<=ri[j]; m++){
   if(i+m<n){
   cou[i+m]=(cou[i+m]+cou[i])%mod;
   //printf("cou[%lld+%lld]=%lld\n", i, m, cou[i+m]);
   }else break;
   }
   }
   }*/
}

Measured memory_bytes: 3288
#include <iostream>
using namespace std;
int main(void){
    int n,c=0;
    cin>>n;
    int a[n],b[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
    }
    for(int i=0;i<n;i++){
        if(a[i]>b[i]){
            c=c+a[i]-b[i];
        }
    }
    cout<<c<<endl;
}


Measured memory_bytes: 888
/*....
     
 "Be not afraid of GROWING slowly, be afraid only of STANDING Still"
                                                                     
....*/
#include<bits/stdc++.h>
#define Abhi_921 ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define ld long double
#define fi(i,j,n) for(int i=j;i<n;i++)
#define fd(i,j,n) for(int i=j;i>n;i--)
#define print(a,n) for(int i=0;i<n;i++){cout<<a[i]<<' ';}cout<<endl;
#define inp(a,n) for(int i=0;i<n;i++) cin>>a[i]
#define printe(v) for(auto &i:v){cout<<i<<' ';}cout<<endl;
#define deb(n1) cout<<n1<<endl;
#define pb push_back
#define eb emplace_back
#define vi vector<ll>
#define vll vector<pair<ll,ll>>
#define umap unordered_map<ll,ll>
using namespace std;
const long long mod=1e9+7;
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
Abhi_921;
int t;
t=1;
while(t--){
int n,x,t;
cin>>n>>x>>t;
int cnt=0;
while(n>0){
    n-=x;
    cnt++;
}
cout<<cnt*t<<endl;
}
return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
const ll mod = 1e9+7;
int inf = 1000000000; //10e9

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

    int ans = 0;
    for(int i = 0; i <= n;i=i+2){
        if(a[i]%2!=0){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 3584
import math
A,B,N = map(int, input().split())

if B <= N:
    i = B - 1
    print(int(math.floor(A*i/B) - A * math.floor(i/B)))
else:
    i = N
    print(int(math.floor(A*i/B) - A * math.floor(i/B)))


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

#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
 
////////////////////////////////////////////////////////////////////

const int N = 2e3 + 5;

int DP[3 * N][N];

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	mt19937 Rnd(time(0));
	
	int n, m; cin >> n >> m;
	DP[0][0] = 1;
	for (int i = 1; i <= 3 * n; i++) for (int j = 0; j <= (i >> 1); j++) {
		DP[i][j] = DP[i - 1][j];
		if (j && i >= 2) DP[i][j] = (DP[i][j] + 1LL * (i - 1) * DP[i - 2][j - 1] % m) % m;
		if (j && i >= 3) DP[i][j] = (DP[i][j] + 1LL * (i - 1) * (i - 2) % m * DP[i - 3][j - 1] % m) % m;
	}
	int ans = 0;
	for (int i = 0; i <= n; i++) ans = (ans + DP[3 * n][i]) % m;
	cout << ans << endl;


	return 0;
}


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

const int N=5e5+15;
int n,m,q,cnt;
int ans[N],t[N];
struct Que{
	int l,r,fl;
}p[N];
bool operator < (Que a,Que b) {return a.r<b.r||(a.r==b.r&&a.fl<b.fl);} 
inline int read(){
	char ch=getchar();int s=0,f=1;
	while (ch<'0'||ch>'9') {if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9') {s=(s<<3)+(s<<1)+ch-'0';ch=getchar();}
	return s*f;
}
void modify(int x,int y)
{
	while (x<=n)
	{
		t[x]+=y;
		x+=x&-x;
	}
}
int query(int x)
{
	int re=0;
	while (x)
	{
		re+=t[x];
		x-=x&-x;
	}
	return re;
}
int main()
{
	n=read();m=read();q=read();
	for (int i=1;i<=m;i++)
	{
		int l=read(),r=read();
		p[++cnt]=(Que){l,r,0};
	}
	for (int i=1;i<=q;i++)
	{
		int l=read(),r=read();
		p[++cnt]=(Que){l,r,i};
	}
	sort(p+1,p+1+cnt);
	int s=0;
	for (int i=1;i<=cnt;i++)
	{
		if (p[i].fl==0)
		{
			modify(p[i].l,1);
			++s;
		}
		else 
		{
			ans[p[i].fl]=s-query(p[i].l-1);
		}
	}
	for (int i=1;i<=q;i++) printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 9088
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)

typedef long long ll;

const int Inf = 100100100;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int day;
    cin >> day;
    string s, e;
    s = "Christmas";
    e = " Eve";

    while (day != 25) {
      s += e;
      day++;
    }

    cout << s << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string str;
    //string rev_str;
    cin>>str;
    
    int start=0,end=0;
    for(int i=0;i<str.size();i++){
        start++;
        if(str[i]=='A')break;
    }

    reverse(str.begin(),str.end());
    for(int i=0;i<str.size();i++){
        end++;
        if(str[i]=='Z')break;
    }
    end = str.size()-end+1;
    cout<<end-start+1<<endl;
    return 0;
}
    

Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <stack>
#include <queue>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
using ld = long double;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll N, M, i, cut=-1, ans=0;

    cin >> N >> M;

    vector<pair<ll,ll>> ab(M);

    for(i=0; i<M; i++){
        cin >> ab[i].second >> ab[i].first;
    }

    sort(ab.begin(), ab.end());

    for(i=0; i<M; i++){
        if(cut < ab[i].second){
            ans++;
            cut = ab[i].first-1;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		String[] input = S.split("");
		int[] ansArray = new int[1000];
		for (int i = 0; i < 1000; i++) {
			String cipher = String.format("%03d", i);
			String[] cipherSplit = cipher.split("");
			int count = 0;
			for (int j = 0; j < input.length; j++) {
				if (cipherSplit[count].equals(input[j])) {
					count++;
				}
				if (count > 2) {
					ansArray[Integer.parseInt(cipher)] = 1;
					break;
				}
			}
		}
		int res = 0;
		for (int count : ansArray) {
			res += count;
		}
		System.out.print(res);
	}
}


Measured memory_bytes: 29092
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(){

    int n;
    int ans;

    char buf[30];

    fgets(buf,sizeof(buf),stdin);

    n= atoi(buf);

    ans=n+(n*n)+(n*n*n);


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

Measured memory_bytes: 1612
import java.util.*;
     
class Main{
    public static void main(String[] args) {
        
        try(Scanner sc = new Scanner(System.in)){
 
            long n = sc.nextLong();
            long k = sc.nextLong();

            if(n == 0){
                System.out.println(0);
                System.exit(0);
            }else if(n >= k){
                if((n % k) == 0){
                    System.out.println(0);
                    System.exit(0);
                }else{
                    if((n % k) < Math.abs((n % k) - k)){
                        System.out.println(n % k);
                        System.exit(0);
                    }else{
                        System.out.println(Math.abs((n % k) - k));
                        System.exit(0);
                    }
                }
            }else{
                if((k/2) <= n){
                    System.out.println(Math.abs(n-k));
                    System.exit(0);
                }else{
                    System.out.println(n);
                    System.exit(0);
                }
            }
 
        }catch(Exception e){
            e.printStackTrace();
        }        
    }
}

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

MOD = 1000000007

sum_a = sum(a) % MOD 
sum_aa = sum((ai * ai) % MOD for ai in a) % MOD

mod_inv = pow(2, -1, MOD) 

ans = ((((sum_a * sum_a) % MOD) - sum_aa) * mod_inv) % MOD

print(ans)

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

void Main(){
    VI x(5); REP(i,5){
        cin >> x[i];
    }

    REP(i,5){
        if(x[i]==0){
            cout << i+1 << en;
            return;
        }
    }
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
int main(){
  int n,m,i,j,k,l,mi,min,a,b,e;
  int c[2][110]={0};
  while(scanf("%d %d",&n,&m),n||m){
    int d[110][110]={0};
    while(m--){
      scanf("%d %d %d",&a,&b,&e);
      d[a][b]=d[b][a]=e;
    }
    for(i=2;i<=n;i++)c[0][i]=c[1][i]=100000000;
    c[0][1]=c[1][1]=0;
    for(k=0;k<2;k++){
      mi=1;
      int f[110]={0};
      for(i=0;i<n*2;i++){
	f[mi]=1;
	for(j=1;j<=n;j++){
	  if(d[mi][j]==0)continue;
	  if(c[k][j]>c[k][mi]+d[mi][j])c[k][j]=c[k][mi]+d[mi][j];
	  if(k)continue;
	  for(l=1;l<=n;l++){
	    if(d[j][l]==0)continue;
	    if(c[1][l]>c[0][mi])c[1][l]=c[0][mi]; 
	  }
	}
	min=2100000000;
	for(j=1;j<=n;j++){
	  if(f[j])continue;
	  if(min>c[k][j])min=c[k][mi=j];
	}
      }
      //for(j=1;j<=n;j++)printf("%d ",c[k][j]);printf("\n");
    }
    printf("%d\n",c[1][n]);
  }
  return 0;
}

Measured memory_bytes: 656
character(100000) :: s
integer Ssize
integer(8),allocatable,dimension(:,:) :: dp
integer mo
read*,s
n=len_trim(s)
mo=10**9+7

allocate(dp(2,0:n))
dp=0
dp(1,0) = 1
do i = 1,n
  dp(1,i)=mod(merge(dp(1,i-1),dp(1,i-1)*2,s(i:i)=='0'),mo)
  dp(2,i)=mod(merge(dp(2,i-1)*3,dp(1,i-1)+dp(2,i-1)*3,s(i:i)=='0'),mo)
end do

print"(i0)", mod(dp(1,n)+dp(2,n),mo)

end

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

using namespace std;

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

    int n;
    cin >> n;

    vector<int> score(n);
    vector<string> name(n);
    for (int i = 0 ;i < n ;i++)
        cin >> name[i] >> score[i];


    vector<int> order(n);
    iota(order.begin() , order.end() , 0);

    sort(order.begin() , order.end() , [&](int i , int j){
        if (name[i] != name[j])
            return name[i] < name[j];
        return score[i] > score[j];
    });

    for (int x : order)
        cout << x + 1 << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))
 
#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
 
typedef long long LL;
typedef pair<int, int> PII;
 
const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = (LL)INF * INF;

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, w, h;
	cin >> h >> w >> n;
	w = max(w, h);
	cout << (n + w - 1) / w << endl;
	return 0;
}


Measured memory_bytes: 256
s = int(input())
def f(n):
  a = 0
  if n % 2 == 0:
    a = n // 2
  else:
    a = 3 * n + 1
  return a

arr = [s]
i = 1
flag = 0
while flag == 0:
  an = f(arr[i - 1])
  arr.append(an)
  for j in range(i):
    if an == arr[j]:
      flag = 1
      break
  i += 1
print(len(arr))

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
 
public class Main {
 
    void solve() throws IOException {
        int H = ni();
        int W = ni();
        int K = ni();
        int[][] grid = new int[H][W];
        for (int i = 0; i < H; i++) {
            String s = ns();
            for (int j = 0; j < W; j++) {
                if(s.charAt(j)=='#')grid[i][j]=1;
                if(s.charAt(j)=='.')grid[i][j]=0;
            }
        }
        int ans = 0;
        for (int i = 0; i < (1<<H)-1; i++) {
            for (int j = 0; j < (1<<W)-1; j++) {
                int count = 0;
                for (int ii = 0; ii < H; ii++) {
                    if(((i>>ii)&1) == 1) continue;
                    for (int jj = 0; jj < W; jj++) {
                        if(((j>>jj)&1) == 0 && grid[ii][jj] == 1) count++;
                    }
                }
                if(count ==K) ans++;
            }
        }
        
        out.println(ans);
    }

    final int mod = 1000000007;
    int mul(int x, int y){
        return (int)((x * 1L * y) % mod);
    }
    int add(int x, int y) {
        x += y;
        return x >= mod ? (x - mod) : x;
    }
    int sub(int x, int y){
        x = add(x,mod-y);
        return x >= mod ? (x - mod) : x;
    }
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 33084
private val scanner = java.util.Scanner(System.`in`)

private fun readInts(n: Int) = Array(n) { scanner.nextInt() }
private fun readLongs(n: Int) = Array(n) { scanner.nextLong() }
private fun readLineInts() = readLine()!!.split(" ").map { it.toInt() }.toTypedArray()
private fun readLineLongs() = readLine()!!.split(" ").map { it.toLong() }.toTypedArray()

private fun String.toIntOrNull(): Int? = try { this.toInt() } catch (ignored: Throwable) { null } 

fun main(args: Array<String>) {
    val N = readLine()!!.toInt()

    val digit = N.toString().length
    val matchSet = setOf('3', '5', '7').map { it.toString() }
    val notMatchSet = ('0'..'9').map { it.toString() }.filter { it !in matchSet }

    fun f(text: String = "", count: Int = 0): Int {
        return if (text.length == count && count < digit) {
            matchSet.plus("").map { f(text + it, count + 1) }.sum()
        } else {
            when {
                text.toIntOrNull() ?: -1 > N -> 0
                matchSet.any { !text.contains(it) } -> 0
                notMatchSet.any { text.contains(it) } -> 0
                else -> 1
            }
        }
    }

    println(f())
}

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

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

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

	int a, b;
	cin >> a >> b;
	a--; b--;

	vector<vector<string>> ans(100);
	for (int i = 0; i < 50; i++) {
		ans[i].assign(100, "#");
	}
	for (int i = 50; i < 100; i++) {
		ans[i].assign(100, ".");
	}

	for (int x = 0, y = 0; a > 0; a--) {
		ans[y][x] = '.';
		x += 2;
		if (x >= 100) {
			x = 0;
			y += 2;
		}
	}

	for (int x = 0, y = 99; b > 0; b--) {
		ans[y][x] = '#';
		x += 2;
		if (x >= 100) {
			x = 0;
			y -= 2;
		}
	}

	cout << "100 100" << endl;
	for (auto s : ans) {
		for (auto c : s) {
			cout << c;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 384
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()



int main() {
  int A, B, C;
  cin >> A >> B >> C;
  int a = A, b = B, c = C, cnt = 0;
  
  while(a%2 == 0 && b%2 == 0 && c%2 == 0) {
    int a_ = a, b_ = b, c_ = c;
    a = b_/2 + c_/2;
    b = a_/2 + c_/2;
    c = a_/2 + b_/2;
    cnt++;
    if (a==A && b==B && c==C) {
      cout << -1 << endl;
      return 0;
    }
  }
  
  cout << cnt << endl;
}

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

int main() {
	while (true) {
		int a, b, c;
		cin >> a >> b >> c;
		if (a == -1 && b == -1 && c == -1)
			break;
		else {
			if (a == -1 || b == -1) {
				cout << "F" << endl;
			}
			else if (a + b > 79) {
				cout << "A" << endl;
			}
			else if (a + b > 64 && a + b < 80) {
				cout << "B" << endl;
			}
			else if (a + b > 49 && a + b < 65) {
				cout << "C" << endl;
			}
			else if (a + b < 30) {
				cout << "F" << endl;
			}
			else {
				if (c > 49) {
					cout << "C" << endl;
				}
				else
					cout << "D" << endl;
			}
		}
	}

}


Measured memory_bytes: 3100
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=INT()
    l=LIST()
    temp=0
    for i in l:
        temp+=(1/i)
    print(1/temp)
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, tmp, count=1;
  cin >> N;
  vector<int> H(N);
  for (int i=0; i<N; i++)
    cin >> H.at(i);
  tmp = H.at(0);
  for (int i=1; i<N; i++){
    if(H.at(i) >= tmp){
      tmp = H.at(i);
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ll a,b,c,i,j,k,l;
map<ll,ll>m;
cin>>a;
for(i=1;i<a;i++)
{
cin>>b;m[b]++;
}
for(i=1;i<=a;i++)
cout<<m[i]<<endl;
}

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

int main(){
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for(int i=0; i<n; i++){
		cin >> a.at(i);
	}
	vector<int> vec(n);
	for(int i=0; i<n; i++){
		vec.at(a.at(i)-1)++;
	}
	sort(vec.begin(), vec.end());
	reverse(vec.begin(), vec.end());
	int num=0;
	for(int i=0; i<n; i++){
		if(vec.at(i)!=0){
			num++;
		}
		if(vec.at(i)==0){
			break;
		}
	}
	vector<int> sam(num);
	for(int i=0; i<num; i++){
		sam.at(i)=vec.at(i);
	}
	reverse(sam.begin(), sam.end());
	int ans=num-k;
	if(ans<=0){
		ans=0;
	}
	else {
		int sum=0;
		for(int i=0; i<ans; i++){
			sum += sam.at(i);
		}
		ans = sum;
	}
	cout << ans << endl;
}


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

int main() {
    string res = "";
    string ope;
    cin >> ope;
    for(int i = 0; i < ope.size(); i++) {
        if(ope.at(i) == 'B') {
            if(res == "") {
                continue;
            }
            res.pop_back();
        } else {
            res.push_back(ope.at(i));
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 3588