akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

int main(int argc, char *argv[])
{
	int r;
	cin >> r;

	if (r < 1200)
		cout << "ABC";
	else
		cout << "ARC";

	cout << endl;

	return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);

    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> cnt(1e6+1);
    ll sol = 0;
    FOR(i, n){
        cin >> a[i];
        cnt[a[i]]++;
    }
    sort(a.begin(), a.end());
    for(auto it : a){
        if (cnt[it]){
            sol += cnt[it]==1;
            int x = it;
            while(x <= 1e6){
                cnt[x] = 0;
                x += it;
            }
        }
    }
    cout << sol << endl;

    if (argc == 2 && atoi(argv[1]) == 123456789) cout << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

Measured memory_bytes: 7928
#include <cmath>
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
//Constant
const int N=200000;
const int A=2000;
const int D=A*2;
const int F=A*4;
const int MOD=1000000007;
//Quick Read
int Read(){
	int x=0;
	bool neg=false;
	char c=getchar();
	while(isdigit(c)==false)neg^=c=='-',c=getchar();
	while(isdigit(c)==true)x=x*10+c-'0',c=getchar();
	return neg==true?-x:x;
}
inline void Read(int &x){x=Read();}
//Math
long long fac[F+1],facinv[F+1];
int Power(long long x,int y){
	long long ans=1;
	for(int i=y;i>=1;i>>=1){
		if(i&1)ans=ans*x%MOD;
		x=x*x%MOD;
	}
	return ans;
}
inline long long Comb(int n,int m){return (long long)fac[n]*facinv[n-m]%MOD*facinv[m]%MOD;}
//Main
int a[N+1],b[N+1];
long long f[D+1][D+1];
int main(){
	// freopen("AGC001E.in","r",stdin);
	// freopen("AGC001E.out","w",stdout);
	int n=Read();
	for(int i=1;i<=n;++i)Read(a[i]),Read(b[i]),++f[A-a[i]][A-b[i]];
	for(int i=0;i<=D;++i)
		for(int j=0;j<=D;++j){
			if(i!=0)f[i][j]=(f[i][j]+f[i-1][j])%MOD;
			if(j!=0)f[i][j]=(f[i][j]+f[i][j-1])%MOD;
		}
	long long ans=0;
	for(int i=1;i<=n;++i)ans+=f[A+a[i]][A+b[i]];
	fac[0]=1;
	for(int i=1;i<=F;++i)fac[i]=(fac[i-1]*i)%MOD;
	facinv[F]=Power(fac[F],MOD-2);
	for(int i=F-1;i>=0;--i)facinv[i]=facinv[i+1]*(i+1)%MOD;
	for(int i=1;i<=n;++i)ans=(ans-Comb((a[i]+b[i])*2,b[i]*2))%MOD;
	ans=ans*facinv[2]%MOD;
	if(ans<0)ans+=MOD;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 126976
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>

using namespace std;
using ll = long long;

int main() {
	ll N;
	cin >> N;
	vector<pair<ll, ll>> num(100002);
	for (ll i = 0; i < 100002; i++)
	{
		num[i].second = i;
	}
	vector<ll> a(N);
	for (ll i = 0; i < N; i++)
	{
		cin >> a[i];
		num[a[i]].first++;
		if (a[i] > 0) num[a[i] - 1].first++;
		num[a[i] + 1].first++;
	}
	sort(num.begin(), num.end());
	reverse(num.begin(), num.end());
	cout << num[0].first << endl;
	return 0;
}

Measured memory_bytes: 2560
from bisect import*
class BTreeNode:
    def __init__(self):self.key,self.child=[],[]
root=BTreeNode()
def main():
    def search_higher(key):
        ptr=root
        ret=None
        while ptr.child:
            i=bisect(ptr.key,key)
            if i!=len(ptr.key):ret=ptr.key[i]
            ptr=ptr.child[i]
        i=bisect(ptr.key,key)
        if i!=len(ptr.key):ret=ptr.key[i]
        return ret
    def search_lower(key):
        ptr=root
        ret=None
        while ptr.child:
            i=bisect_left(ptr.key,key)
            if i:ret=ptr.key[i-1]
            ptr=ptr.child[i]
        i=bisect_left(ptr.key,key)
        if i:ret=ptr.key[i-1]
        return ret
    def insert_rec(ptr,key):
        b_size=512
        if not ptr.child:
            insort(ptr.key,key)
            if len(ptr.key)==b_size*2-1:
                ret=BTreeNode()
                ret.key=ptr.key[:b_size]
                ptr.key=ptr.key[b_size:]
                return ret
        else:
            i=bisect(ptr.key,key)
            tmp=insert_rec(ptr.child[i],key)
            if tmp:
                ptr.key.insert(i,tmp.key.pop())
                ptr.child.insert(i,tmp)
                if len(ptr.child)==b_size*2:
                    ret=BTreeNode()
                    ret.child=ptr.child[:b_size]
                    ptr.child=ptr.child[b_size:]
                    ret.key=ptr.key[:b_size]
                    ptr.key=ptr.key[b_size:]
                    return ret
    def insert(key):
        global root
        tmp=insert_rec(root,key)
        if tmp:
            p=BTreeNode()
            p.key=[tmp.key.pop()]
            p.child=[tmp,root]
            root=p
    n,*a=map(int,open(0).read().split())
    l=[0]*n
    for i,v in enumerate(a,1):l[v-1]=i
    insert(0)
    insert(n+1)
    c=0
    for i,v in enumerate(l,1):
        c+=(search_higher(v)-v)*(v-search_lower(v))*i
        insert(v)
    print(c)
main()

Measured memory_bytes: 25884
from itertools import product
n, k = list(map(int, input().split()))
dl = list(map(int, input().split()))
target = []
for i in range(10):
    if i not in dl:
        target.append(i)
# print(target)
ansl = []
for R in range(1, 6):
    for bit in product(target, repeat=R):
        t = 0
        for i, b in enumerate(bit):
            t += (10**i)*b
        # print(bit, t)
        if t >= n:
            ansl.append(t)
print(min(ansl))


Measured memory_bytes: 43612
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>

using namespace std;

int main() {
    int A,B,C;
    cin>>A>>B>>C;

    if(A+B+C>=22){
        cout<<"bust"<<endl;
    }
    else{
        cout<<"win"<<endl;
    }

}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define MOD (long long)1000000007
#define INF (long long)998244353
using namespace std;

int main(void){
    int a,b,t;
    cin >> a >> b >> t;
    cout << (t/a)*b << endl;
    return 0;
}


Measured memory_bytes: 764
#include <algorithm>
#include <stdio.h>
#include <vector>
using namespace std;
int main() {
	int n, A[100002], distance = 0;
	scanf("%d", &n);
	A[0] = A[n + 1] = 0;
	for (int i = 1; i <= n; i++) {
		scanf("%d", A + i);
		distance += abs(A[i] - A[i - 1]);
	}
	distance += abs(A[n]);
	for (int i = 1; i <= n; i++)
		printf("%d\n", distance - abs(A[i] - A[i - 1]) - abs(A[i + 1] - A[i]) + abs(A[i + 1] - A[i - 1]));
}

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

using namespace std;

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0);
	int n, k;
	cin >> n >> k;
	vector<set<int> > a(n);
	for (int i = 0; i < k; i++) {
		int m, x;
		cin >> m;
		for (int j = 0; j < m; j++) {
			cin >> x;
			a[x - 1].insert(i);
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++)
		if (a[i].size() == 0) ans++;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3992
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define DEBUG(x) cout<<#x<<": "<<x<<endl

using namespace std;

int main(){

	int N;

	cin >> N;

	long long A[N];

	for(int i =0 ; i < N; i++){
		cin >> A[i];
	}
	
	sort(A, A+N);

	cout << A[N-1] - A[0] << endl;

	return 0;
}


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

using namespace std;

int main()
{
    int N, L;
    string S[101];

    cin >> N >> L;

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

    sort(S, S+N);

    for (int i = 0; i < N; i++)
        cout << S[i];

    cout << endl;

    return 0;
}

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

using namespace std;

int main(){

  int n,m;

  while(cin>>n>>m,n){

    int taro[100];
    int hanako[100];
    int taro_total=0;
    int hanako_total=0;
    int min=300;
    int h=10000;
    int t=10000;

    for(int i=0;i<n;++i){
      cin>>taro[i];
      taro_total+=taro[i];
    }

    for(int i=0;i<m;++i){
      cin>>hanako[i];
      hanako_total+=hanako[i];
    }

    for(int i=0;i<n;++i){
      for(int j=0;j<m;++j){
	if(taro_total-taro[i]+hanako[j]==hanako_total-hanako[j]+taro[i]){
	  if(min>taro[i]+hanako[j]){
	    t=taro[i];
	    h=hanako[j];
	    min=t+h;
	  }
	}
      }
    }
    if(h==10000 && t==10000)
      cout<<-1<<endl;
    else
      cout<<t<<' '<<h<<endl;
  }
}

Measured memory_bytes: 3072
program main
	implicit none
    character(5)::s
    integer::len1,i,j
    read(*,*)s
    len1=len_trim(s)
    if(len1==2)then
    	if(s=='AC')then
        	write(*,*)'Yes'
        else
        	write(*,*)'No'
        end if
    else
    	do i=1,len1
    		do j=2,len1-1
            	if(s(i:j)=='AC')then
                	write(*,*)'Yes'
                    stop
                end if
            end do
        end do
        write(*,*) 'No'
    end if
    stop
end program main
    


Measured memory_bytes: 2852
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int cost,money,time;
    cin>>cost>>money>>time;
    if(money/cost>=time)
    {
        cout<<time<<endl;
    }
    else if(money/cost<=time)
    {
        cout<<money/cost<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()

ans = 0
for i in range(1, n):
    x = s[0:i]
    y = s[i:]

    uniq_x = set(x)
    uniq_y = set(y)

    cnt = 0
    for c in uniq_y:
        if c in uniq_x:
            cnt += 1

    ans = max(ans, cnt)

print(ans)


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

typedef long long ll;

ll mdiv(ll a, ll b){
    return ((a + (int)abs(a) * b) % b);
}

int main(){
    ll n;
    while( cin >> n, n ){
        int ans = 0, m = 1;
        while( n ){
            ll r = mdiv(n, 10);
            ans += r * m;
            n = (r - n)/10;
            m *= 10;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

  public static void main(String[] args) throws Exception {
    try (final var stdin = new InputStreamReader(System.in);
         final var br = new BufferedReader(stdin)) {
      final var s = Arrays.stream(br.readLine().split(" "))
        .mapToInt(Integer::parseInt)
        .toArray();
      final var a = s[0];
      final var b = s[1];
      final var c = s[2];
      final var x = s[3];
      final var y = s[4];

      var max = Integer.MAX_VALUE;
      final var len = Math.max(x, y);
      for (int i = 0; i <= len; i++) {
        var cost = a * Math.max(x - i, 0) + b * Math.max(y - i, 0) + c * 2 * i;
        max = Math.min(cost, max);
      }

      System.out.println(max);
    }
  }
}


Measured memory_bytes: 34268
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0;
#define ll long long

int a, b, c;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> a >> b >> c;
    cout << (a-b)%c << endl;
    return 0;
}


Measured memory_bytes: 256
// atcoder/abc122/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  char c;
  while (cin >> c) {
    map<char, char> m;
    m['A'] = 'T';
    m['T'] = 'A';

    m['C'] = 'G';
    m['G'] = 'C';
    cout << m[c] << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys

input = sys.stdin.readline

def main():
    S = list(input().strip())
    n = 0
    max_n = 0
    for c in S:
        if c == 'A' or c == 'C' or c == 'G' or c == 'T':
            n += 1
        else:
            n = 0
        max_n = max(max_n, n)
    print(max_n)

main()


Measured memory_bytes: 2940
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    static int N;
    static String S;
    static int Q;
    static int[] K;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        N = sc.nextInt();
        S = sc.next();
        Q = sc.nextInt();
        K = sc.nextIntArray(Q);

        long[] ans = solve();
        PrintWriter pw = new PrintWriter(System.out);
        for (long i : ans) {
            pw.println(i);
        }
        pw.flush();
    }

    static long[] solve() {
        long[] ans = new long[Q];
        for (int i = 0; i < Q; i++) {
            ans[i] = calc(K[i]);
        }
        return ans;
    }

    static long calc(int k) {
        int d = 0;
        int m = 0;
        long dm = 0;
        long ret = 0;
        for (int i = 0; i < N; i++) {
            char in = S.charAt(i);
            if( in == 'D' ) {
                d++;

            } else if( in == 'M' ) {
                m++;
                dm += d;

            } else if( in == 'C' ) {
                ret += dm;
            }

            if( i >= k-1 ) {
                char out = S.charAt(i-k+1);
                if( out == 'D' ) {
                    d--;
                    dm -= m;

                } else if( out == 'M' ) {
                    m--;
                }
            }

            // System.out.println(i + " " + d + " " + m + " " + dm + " " + ret);
        }
        return ret;
    }

    @SuppressWarnings("unused")
    static class FastScanner {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken("\n");
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 31352
import java.util.*

fun main(args: Array<String>) {
    val mod = 1000000007L
    val list = readIntList()
    val max = list.max()!!
    println(10*max + list.sum() - max)
}

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toInt)


Measured memory_bytes: 35944
from collections import deque
N=int(input())
A=deque(list(map(int,input().split())))

B=[i for i in range(1,N+1)]
C=[]
ans=0
for i in B:
    while A:
        x=A.popleft()
        if i!=x:
            ans+=1
        else:
            C.append(x)
            break
if C==[]:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 26780
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(int i = a;i < n;i++)
#define INF 1e15
typedef unsigned long long ull;
typedef long long ll;

int main(){
    ll n,m,ans = INF;
    cin >> n >> m;
    ll dp[n+1][m+1] = {0},dis[n] = {0},weather[m] = {0};
    
    rep(i,0,n){
        cin >> dis[i];
    }
    
    rep(j,0,m){
        cin >> weather[j];
    }
    
    rep(i,0,n+1){
        rep(j,0,m+1){
            if(i == 0)dp[i][j] = 0;
            else dp[i][j] = INF;
        }
    }
    
    
    rep(i,1,n+1){
        rep(j,i,m+1){
            dp[i][j] = min(dp[i][j-1],dp[i-1][j-1] + dis[i-1]*weather[j-1]);
        }
    }
    
    rep(i,0,m+1){
        ans = min(dp[n][i],ans);
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9340
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
ll mod= 1e9 + 7;


int main(){
  int n,k;
  cin >> n >> k;
  ll rp,sp,pp;
  cin >> rp >> sp >> pp;
  string t;
  cin >> t;
  vector<char> tp;
  ll ans=0;
  rep(i,n){
    if(t[i]=='r'){
      if(k<=i && tp[i-k]=='p'){tp.push_back('g');}//gはどうせポイントがもらえないので適当な文字→次のk回目にはどうせ勝たせるから、今回の出した手は気にしなくてよい
      else{tp.push_back('p');ans+=pp;}
    }
    if(t[i]=='s'){
      if(k<=i && tp[i-k]=='r'){tp.push_back('g');}
      else{tp.push_back('r');ans+=rp;}
    }
    if(t[i]=='p'){
      if(k<=i && tp[i-k]=='s'){tp.push_back('g');}
      else{tp.push_back('s');ans+=sp;}
    }
  }

  cout << ans << endl;
}

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

#define pb push_back
#define eb emplace_back
#define mk make_pair
#define fi first
#define se second
#define mset(a, b) memset(a, b, sizeof(a))
#define DBG(x) cout << "[" << #x << "]: " << x << endl
using ll = long long;
using pii = pair<int, int>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#ifdef _WIN32
#define getchar_unlocked _getchar_nolock
#endif

template<class Ty> Ty randint(Ty a, Ty b) { return uniform_int_distribution<Ty>(a, b)(rng); }
template<class num> inline void rd(num& x) {
	char c, neg = 0; while(isspace(c = getchar_unlocked()));
	if(!isdigit(c)) neg = (c == '-'), x = 0;
	else x = c - '0';
	while(isdigit(c = getchar_unlocked())) x = (x << 3) + (x << 1) + c - '0';
	x = neg ? -x : x; }
template <class... Args> inline void rd(Args&... args) { (rd(args), ...); }

const int MAXN = 2e5 + 5, INF = 0x3f3f3f3f;

int main() {
	int d, t, s;
	rd(d, t, s);

	bool ok = (d + s - 1) / s <= t;
	printf("%s\n", ok ? "Yes" : "No");
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000010;
constexpr ll INF= 1000000000000000000;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}

ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}

ll RS(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P < 0) {
        return 0;
    }
    if(P%2==0){
        ll t = RS(N, P/2, M);
        return t*t % M;
    }
    return N * RS(N, P-1, M) % M;
}

int main() {
    int H,W,K;
    cin >> H >> W >> K;
    vector<vector<char>> vec(H,vector<char>(W));
    for(int i = 0;i < H;i++) {
        for(int j = 0;j < W;j++) {
            cin >> vec.at(i).at(j);
        }
    }
    int ret = 0;
    for(int bit = 0;bit < (1 << (H + W));bit++) {
        vector<bool> cnt(H + W);
        for(int i = 0;i < H + W;i++) {
            if(bit & (1 << i)) {
                cnt.at(i) = true;
            }
        }
        vector<vector<bool>> cnt2(H,vector<bool>(W));
        for(int i = 0;i < H;i++) {
            if(cnt.at(i) == true) {
                for(int j = 0;j < W;j++) {
                    cnt2.at(i).at(j) = true;
                }
            }
        }
        for(int i = H;i < H + W;i++) {
            if(cnt.at(i) == true) {
                for(int j = 0;j < H;j++) {
                    cnt2.at(j).at(i - H) = true;
                }
            }
        }
        int cnt3 = 0;
        for(int i = 0;i < H;i++) {
            for(int j = 0;j < W;j++) {
                if(vec.at(i).at(j) == '#' && cnt2.at(i).at(j) == false) {
                    cnt3++;
                }
            }
        }
        if(cnt3 == K) {
            ret++;
        }
    }
    cout << ret << endl;
}

Measured memory_bytes: 3644
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
#include<map>
#include<iomanip>

using namespace std;
int main(void){
 int a,b,c;
 char s[3];

 cin>>s;
 a=s[0]-'0';
 b=s[1]-'0';
 c=s[2]-'0';
 
 if(a>=b && a>=c)std::cout<<a<<a<<a<<std::endl;
 else std::cout<<a+1<<a+1<<a+1<<std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
ll n,p;
map<ll,int> g;
int main()
{
    cin>>n>>p;
    int nn = sqrtl(p);
    for(int i=2;i<=nn;++i) {
        while(p % i == 0 ){
            g[i]++;
            p/=i;
        }
    }
    if(p>1){
        g[p]++;
    }
    long long ans = 1;
    for(auto pp:g) {
        ll bas = pp.first;
        ll num = pp.second;
        ll mul = num / n;
        ll gx = powl(bas,mul);
        ans = ans * gx;
    }
    cout<<ans<<endl;
}

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

#define ll long long
#define vecint vector<int>
#define listint list<int>
#define Pii pair<int, int>

#define REP(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define print(a) cout << a << endl

#define MOD 1000000007
#define NIL -1


int main(){
  int N,T;
  int last_min=MOD,max_profit=0;
  int ans=0;

  cin>>N>>T;
  int cost[N];
  rep(i,N){
    cin>>cost[i];
  }
  rep(i,N){
    if(cost[i]-last_min>max_profit){
      max_profit=cost[i]-last_min;
      ans=1;
    }else if(cost[i]-last_min==max_profit){
      ans++;
    }
    last_min=min(last_min,cost[i]);
  }
  print(ans);
  return 0;
}


Measured memory_bytes: 640
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<ll>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    ll n, m, v, p;
    cin >> n >> m >> v >> p;
    vi a(n);
    rep(i, n) {
        cin >> a[i];
    }

    if(v <= p) {
        sort(all(a));
        int cri = a[n-p];
        int x = a.end()-lower_bound(all(a), cri-m);
        cout << x << endl;
    } else {
        sort(all(a));
        int cri = a[n-p];
        auto itr = lower_bound(a.begin()+v-p, a.end(), cri-m);
        int x = a.end()-itr;
        if(itr == a.begin()+v-p) {
            ll sum = 0;
            int ww = 0;
            for(auto iitr = a.end()-p; iitr >= itr; --iitr) {
                sum += cri-*iitr;
                ww++;
            }
            int j = v-p-1;
            int cou = 1;
            while(j >= 0) {
                ll ff = cou*m-sum;
                if(ff < 0) ff = 0;
                if(m+a[j] >= cri+(ff+ww-1)/ww) {
                    x++;
                } else {
                    break;
                }
                cou++;
                ww++;
                sum += cri-a[j];
                --j;
            }

        }
        cout << x << endl;

    }
}

Measured memory_bytes: 1024
import java.util.*

val sc = Scanner(System.`in`)
val A = mutableListOf<String>()
val B = mutableListOf<String>()
var N = 0
var M = 0

fun main(args: Array<String>) {
    N = sc.nextInt()
    M = sc.nextInt()

    for (i in 0 until N) {
        A.add(sc.next())
    }
    for (i in 0 until M) {
        B.add(sc.next())
    }
    for (i in 0 until N) {
        for (j in 0 until N) {
            if (judge(i, j)) {
                println("Yes")
                return
            }
        }
    }
    println("No")
}

fun judge(Ni: Int, Nj: Int): Boolean {
    for (i in 0 until M) {
        for (j in 0 until M) {
            when {
                Ni + i >= N || Nj + j >= N || B[i][j] != A[Ni + i][Nj + j]
                -> return false
            }
        }
    }
    return true
}



Measured memory_bytes: 31260
#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>;

void solve() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int takahashi = 1;
    while (1) {
        if (takahashi) {
            c -= b;
            if (c <= 0) {
                cout << "Yes" << endl;
                return;
            }
        } else {
            a -= d;
            if (a <= 0) {
                cout << "No" << endl;
                return;
            }
        }
        takahashi ^= 1;
    }
}

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


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int w,n,v,w2;
  int cnt = 1;
  char c;
  while(cin >> w){
    if(w == 0) break;
    cin >> n;
    int dp[1001][1001] ={};
    REP(i,0,n){
      cin >> v>>c>>w2;
      rep(j,w+1){
        dp[i+1][j] = max(dp[i][j], j-w2 >= 0? dp[i][j-w2]+ v : 0);
      }
    }
    cout << "Case " + to_string(cnt) + ":"<<endl;
    rep(i,w+1){
      if(dp[n][i] == dp[n][w]){
        cout << dp[n][w]<<endl<<i<<endl;
        break;
      }
    }
    ++cnt;
  }
  return 0;
}

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

int N;

int main() {
  cin >> N;
  int cake = 0;    // 4
  int dounut = 0;  // 7
  string ans = "No";

  while (true) {
    int tmpn = N - cake * 4;
    if (tmpn < 0) break;
    if (tmpn % 7 == 0) {
      ans = "Yes";
      break;
    }
    ++cake;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int ishodn[105000][3];
int otv[105000][3];
int n;

int main(){

cin >> n;

for (int i = 1; i <= n; i++){
	for (int j = 1; j <= 3; j++)
		cin >> ishodn[i][j];	
}

otv[1][1] = ishodn[1][1];
otv[1][2] = ishodn[1][2];
otv[1][3] = ishodn[1][3];

for (int i = 2; i <= n; i++){
	otv[i][1] = max(ishodn[i][1] + otv[i - 1][2], ishodn[i][1] + otv[i - 1][3]);
	otv[i][2] = max(ishodn[i][2] + otv[i - 1][1], ishodn[i][2] + otv[i - 1][3]);
	otv[i][3] = max(ishodn[i][3] + otv[i - 1][2], ishodn[i][3] + otv[i - 1][1]);
}

cout << max(otv[n][1], max(otv[n][2], otv[n][3]));

}

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

int main(){
  int Rr, Ww, C, R;
  int c = 0;

  while(1){
    cin >> Rr >> Ww >> C >> R;
    int sum = Rr + Ww + C + R;
    if(sum == 0) break;

    int Count = 0;
    int f = 0;
    while(f == 0){
      int cimf = (Rr + (Count * R));
      if(cimf / Ww >= C){
        f = 1;
      }
      Count++;
    }
    cout << Count - 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 3128
#include <iostream>
#include <vector>

int main()
{
    int n;
    std::cin >> n;
    std::vector<int> t(n);
    for(int i = 0; i < n; i++){
        std::cin >> t[i];
    }
    int m;
    std::cin >> m;
    std::vector<std::vector<int>> px(m,std::vector<int>(2));
    for(int i = 0; i < m; i++){
        std::cin >> px[i][0] >> px[i][1];
    }
    //nは問題数・tは問題が入った配列・mはドリンクの数・pxはエナジードリンクの番号と時間が入った配列

    int sum = 0;
    for(int j = 0; j < n; j++){
        sum += t[j];
    }
    for(int j = 0; j < m; j++){
        int tmp = px[j][0];
        int tm2 = t[tmp-1];
        std::cout << sum - tm2 + px[j][1] << std::endl;
    }
    return 0;
}



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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  bool ok = true;
  rep(i,n) {
    if (a[i]%2 == 1) continue;
    if (a[i]%3 != 0 && a[i]%5 != 0) ok = false;
  }
  if (ok) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    char str[20001];
    int n,m,length;
    while (true)
    {
        scanf("%s",str);
        if(str[0]=='-')break;
        length = 0;
        for (int k = 0; str[k]!='\0'; k++)length++;
        scanf("%d",&m);
        int index =0;
        REP(i,m){
            scanf("%d",&n);
            REP(j,n){
                str[index+length]=str[index];
                index++;
            }
        }
        REP(p,length) printf("%c",str[index+p]);
        printf("\n");
    }
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
const int MAX_V=100000;  //変える
const ll INF=1e16;  //変える
struct edge {int to; ll cost; };

int V;
vector <edge> G[MAX_V];
ll d[MAX_V];

void dijkstra (int s){
    //小さい順に取り出す firstは最短距離、secondは頂点の番号
    priority_queue<P, vector<P>, greater<P>> que;
    fill(d,d+V,INF);
    d[s]=0;
    que.push(P(0,s));
    
    while (!que.empty()) {
        P p=que.top();  que.pop();
        int v=p.second;
        if (d[v]<p.first) continue;
        rep(i,0,G[v].size()){
            edge e=G[v][i];
            if (d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>V;
    rep(i,1,V){
        rep(j,1,10){
            G[i].pb(edge{int(i+j)%V, j});
        }
        G[i].pb(edge{int(10*i)%V, 0});
    }
    ll ans=1e17;
    rep(i,1,min(10, V)){
        dijkstra(i);
        ans=min(ans, d[0]+i);
    }
    cout <<ans<<"\n";
}

Measured memory_bytes: 33568
import sys

def main():
    input = sys.stdin.readline
    sx, sy, tx, ty = map(int, input().rstrip().split())

    horiz = tx - sx
    vert = ty - sy

    first_move = "U"*vert + "R"*horiz + "D"*vert + "L"*horiz
    second_move_go = "L" + "U"*(vert+1) + "R"*(horiz+1) + "D"
    second_move_back = "R" + "D"*(vert+1)+ "L"*(horiz+1) + "U" 
    print(first_move + second_move_go + second_move_back)

if __name__ == "__main__":
    main()

Measured memory_bytes: 8900
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int a,b;
  cin>>a>>b;
  if(a+b==15){
    cout<<'+'<<'\n';
  }
  else if(a*b==15){
    cout<<'*';
  }
  else{
    cout<<'x';
  }
  return(0);
}


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

#define INF (1 << 30)
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define out(x) cout << x << endl;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;

int main(){
    int n;
    cin >> n;
    int v[n];
    map<int, int> m; // key, count
    map<int, int> even;
    map<int, int> odd;
    rep(i, n){
        cin >> v[i];
        m[v[i]]++;
        if(i%2 == 0){
            even[v[i]]++;
        }else{
            odd[v[i]]++;
        }
    }
    if(m.size() == 1){
        cout << n/2 << endl;
        return 0;
    }
    int evenm = 0;
    int evens = 0;
    int oddm = 0;
    int odds = 0;
    int evenmcount = 0;
    int oddmcount = 0;
    int evenscount = 0;
    int oddscount = 0;

    for(auto x : even){
        if(x.second > evenmcount){
            evenscount = evenmcount;
            evenmcount = x.second;
            evens = evenm;
            evenm = x.first;
        }else if(x.second <= evenmcount && x.second > evenscount){
            evenscount = x.second;
            evens = x.first;
        }
    }
    for(auto x : odd){
        if(x.second > oddmcount){
            oddscount = oddmcount;
            oddmcount = x.second;
            odds = oddm;
            oddm = x.first;
        }else if(x.second <= oddmcount && x.second > oddscount){
            oddscount = x.second;
            odds = x.first;
        }
    }
    
    if(oddm == evenm){
        cout << n - oddmcount - max(oddscount, evenscount) << endl;
    }else{
        cout << n - oddmcount - evenmcount << endl;
    }
    return 0;
}

Measured memory_bytes: 9984
n,m,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
List=[]
for i in range(X+1,Y+1):
  num=0
  for j in range(n):
    if i>x[j]:
      pass
    else:
      num+=1  
  for k in range(m):
    if i<=y[k]:
      pass
    else:
      num+=1
  List.append(num)
if 0 in List:
  print('No War')
else:
  print('War')

Measured memory_bytes: 39024
k = int(input())
cnt = 1
loop = 1
r_li = []

# 一桁小さいるんるんリストから次のるんるんリストを作成
def make_runrun(i, runrun_list):
    new_list = []
    for runrun in runrun_list:
        new_list.append('{}{}'.format(i, runrun))
    return new_list

tmp = [[str(i)] for i in range(10)]
r_li = [str(i) for i in range(1, 10)]

# 桁数ごとにループ
while len(r_li) < k:
    # 一桁小さいルンルン数のリスト
    next_tmp = [[]] * 10
    for i in range(1, 10):
        l = 0
        r_li.extend(make_runrun(i, tmp[i - 1]))
        l += len(tmp[i - 1])
        r_li.extend(make_runrun(i, tmp[i]))
        l += len(tmp[i])
        if i != 9:
            r_li.extend(make_runrun(i, tmp[i + 1]))
            l += len(tmp[i + 1])
        next_tmp[i] = r_li[-l:]
    for i in tmp[0]:
        next_tmp[0].append('{}{}'.format(0, i))
    for i in tmp[1]:
        next_tmp[0].append('{}{}'.format(0, i))
    tmp = next_tmp

print(r_li[k - 1])

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

using namespace std;

void solve(int S, int W) {
  cout << (W >= S ? "unsafe" : "safe") << endl;
}

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

  int S, W;
  cin >> S >> W;
  solve(S, W);
  return 0;
}


Measured memory_bytes: 3648
N = int(input())
ABC = [list(map(int,input().split())) for _ in range(N)]

dp = [[0 for i in range(3)] for j in range(N)]

# 1日目の初期化
dp[0]= ABC[0]
for i in range(1,N):
    # 次ステップでA,B,Cに行く場合、
    for toi in range(3):
        s = 0
        # どこから来るのが最大か求める
        for fromi in range(3):
            # 同じ行動はとらない
            if toi==fromi:
                continue
            s = max(s, dp[i-1][fromi] + ABC[i][toi])
        dp[i][toi] = s

print(max(dp[-1]))

Measured memory_bytes: 76120
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define ll long long
#define mod 998244353
#define maxn 200010
inline ll read()
{
    ll x=0; char c=getchar(),f=1;
    for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
    for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
    return x*f;
}
inline void write(ll x)
{
    static char buf[20],len; len=0;
    if(x<0)x=-x,putchar('-');
    for(;x;x/=10)buf[len++]=x%10+'0';
    if(!len)putchar('0');
    else while(len)putchar(buf[--len]);
}
inline void writesp(ll x){write(x); putchar(' ');}
inline void writeln(ll x){write(x); putchar('\n');}
struct Data{
    int x,id;
}num[maxn];
struct point{
    int x,y,rk;
}a[maxn];
int n;
bool cmp1(Data a,Data b){return a.x<b.x;}
bool cmp2(point a,point b){return a.x<b.x;}
inline ll power(ll a,ll b)
{
    ll ans=1;
    for(;b;b>>=1,a=a*a%mod)
        if(b&1)ans=ans*a%mod;
    return ans;
}
int bit1[maxn],bit2[maxn];
void add1(int x,int k){for(;x<=n;x+=x&(-x))bit1[x]+=k;}
int getsum1(int x){int sum=0; for(;x;x-=x&(-x))sum+=bit1[x]; return sum;}
void add2(int x,int k){for(;x<=n;x+=x&(-x))bit2[x]+=k;}
int getsum2(int x){int sum=0; for(;x;x-=x&(-x))sum+=bit2[x]; return sum;}
int main()
{
    n=read();
    for(int i=1;i<=n;i++){
        a[i].x=read(); a[i].y=read();
        num[i].x=a[i].y; num[i].id=i;
    }
    std::sort(num+1,num+n+1,cmp1);
    for(int i=1;i<=n;i++)
        a[num[i].id].rk=i;
    std::sort(a+1,a+n+1,cmp2);
    for(int i=1;i<=n;i++)
        bit1[i]=0,bit2[i]=i&(-i);
    ll ans=0;
    for(int i=1;i<=n;i++){
        add2(a[i].rk,-1);
        int A=getsum1(a[i].rk),B=getsum1(n)-getsum1(a[i].rk),C=getsum2(a[i].rk),D=getsum2(n)-getsum2(a[i].rk);
        ll totA=power(2,A),totB=power(2,B),totC=power(2,C),totD=power(2,D);
        ans=(ans+(totA-1)*(totB)%mod*totC%mod*(totD-1))%mod;
        ans=(ans+(totA)*(totB-1)%mod*(totC-1)%mod*totD)%mod;
        ans=(ans-(totA-1)*(totB-1)%mod*(totC-1)%mod*(totD-1)%mod+mod)%mod;
        ans=(ans+power(2,n-1))%mod;
        add1(a[i].rk,1);
    }
    writeln(ans);
    return 0;
}
/*
        |
    B   |    D
--------|--------
    A   |    C
        |
*/

Measured memory_bytes: 5632
/*B - Papers, Please*/
#include <bits/stdc++.h>

using namespace std;

int main(){
	
	int tam;
	int num;
	bool can = true;

	cin >> tam;

	for (int i = 0; i < tam; ++i)
	{
		cin >> num;

		if(num % 2 == 0)
			if(num % 3 != 0)
				if(num % 5 != 0)
					can = false;
	}

	if(can)
		cout << "APPROVED";
	else
		cout << "DENIED";
	
	return 0;	
}

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

int main(){
    string s;
    cin>>s;
    int ans=1000;
    for(int i=0;i<s.size()-2;i++){
        ans=min(ans,abs(stoi(s.substr(i,3))-753));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <numeric>
#include <cmath>
#include <iomanip> //cout << fixed << setprecision(15) << << endl;
#include <cassert>
//#include "atcoder/all"

using namespace std;
//using namespace atcoder;

#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define P pair<int,int>

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};
const int MOD = 1000000007;


int main(){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    vector<vector<char>> s(h, vector<char> (w));
    rep(i,h) rep(j,w) cin >> s[i][j];

    int ans = 0;
    const int D = -1;
    rep(i,h) rep(j,w){
        if(s[i][j] == '#') continue;
        queue<P> q;
        q.push(P(i,j));
        vector<vector<int>> dist(h, vector<int> (w));
        rep(l,h) rep(t,w) dist[l][t] = D;
        dist[i][j] = 0;
        while(!q.empty()){
            P p = q.front(); q.pop();
            int d = dist[p.first][p.second];
            rep(k,4){
                int y = p.first + my4[k];
                int x = p.second + mx4[k];
                if(y < 0 || y >= h || x < 0 || x >= w) continue;
                if(s[y][x] == '#') continue;
                if(dist[y][x] != D) continue;
                dist[y][x] = d+1;
                ans = max(ans, d+1);
                q.push(P(y,x));
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3620
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

bool p[30000];
bool isGaussianPrime(int a, int b) {
  if (a < 0) a = -a;
  if (b < 0) b = -b;
  if (a == 0) return b % 4 == 3 && !p[b];
  if (b == 0) return a % 4 == 3 && !p[a];
  return !p[a*a+b*b];
}

int main(){
	for(int i = 2; i * i < 30000; i++) if(!p[i]) for(int j = i * i; j < 30000; j += i) p[j] = 1;
	p[0] = p[1] = 1;
	
	int n;
	cin >> n;
	while(n--){
		int a, b;
		cin >> a >> b;
		cout << (isGaussianPrime(a, b) ? "P" : "C") << endl;
	}
	return 0;
}

Measured memory_bytes: 1180
#include <stdio.h>
int main(void)
{
  int n[5];
  int sa = 0;
  int i;

  for(i=0;i<5;i++)
    {
      scanf("%d",&n[i]);
      if(n[i]<40)
	n[i] = 40;
      sa += n[i];
    }
  printf("%d\n",sa/=5);
  return 0;
}

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

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
typedef long long ll;

using namespace std;

#define MAX_N 1000000

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll a, b; cin >> a >> b;
	ll d = a / b;
	ll r = a % b;
	double f = (double)(a) / (double)(b);
	cout << d << " " << r << " " << fixed << setprecision(5) << f << endl;
}


Measured memory_bytes: 3264
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>
#include <numeric>
#include <iterator>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi >;
using vl = vector<ll>;
using vvl = vector<vl >;
using pairi = pair<int, int>;
using pairl = pair<ll, ll>;

#define TR ","
#define TS " "
#define rep(i,N) for(int i=0;i<(int)N;++i)
#define rpt(i,a,b) for(ll i=a;i<(ll)b;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

ll waz = 76543217;

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

int n, A[50];

int solve(int i, int m) {
    if (m == 0) return 1;
    if (i >= n) return 0;
    int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
    return res;
}

int main()
{
    IO;

    int q, M;
    cin >> n;
    rep(i, n) cin >> A[i];
    cin >> q;
    rep(i, q) {
        cin >> M;
        if (solve(0, M)) {
            cout << "yes" << endl;
        }
        else {
            cout << "no" << endl;
        }
    }

}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


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

    ll l = 0;
    ll r = 1000000000;
    while(abs(r-l) > 1){
        ll mid = (l+r)/2;
        ll tcut = 0;
        rep(i, n){
            tcut += ((a[i] + mid -1) /mid) -1;           
        }
        if (tcut > k){
            //over
            l = mid;
        } else {
            r = mid;
        }
    }

    cout << r << endl;

}



Measured memory_bytes: 4836