akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    long double a, b, c;
    cin >> a >> b >> c;
    cout << (sqrtl(a) + sqrtl(b) + 1e-15 < sqrtl(c) ? "Yes" : "No") << endl;
}

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


Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

// ModInt
// region
class ModInt(x: Long) {

    companion object {
        const val MOD = 1000000007L
        //const val MOD = 998244353L
    }

    val x = (x % MOD + MOD) % MOD

    operator fun plus(other: ModInt): ModInt {
        return ModInt(x + other.x)
    }

    operator fun minus(other: ModInt): ModInt {
        return ModInt(x - other.x)
    }

    operator fun times(other: ModInt): ModInt {
        return ModInt(x * other.x)
    }

    operator fun div(other: ModInt): ModInt {
        return this * other.inv()
    }

    fun pow(exp: Long): ModInt {
        if (exp == 0L) return ModInt(1L)
        var a = pow(exp shr 1)
        a *= a
        if (exp and 1L == 0L) return a
        return this * a
    }

    fun inv(): ModInt {
        return this.pow(MOD - 2)
    }

    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (javaClass != other?.javaClass) return false

        other as ModInt

        if (x != other.x) return false

        return true
    }

    override fun hashCode(): Int {
        return x.hashCode()
    }

    override fun toString(): String {
        return "$x"
    }

}

val fac = mutableListOf<ModInt>()
val invfac = mutableListOf<ModInt>()

fun fact(n: Long, b: Boolean): ModInt {
    if (fac.count() == 0) {
        fac.add(ModInt(1))
        invfac.add(ModInt(1))
    }
    while (fac.count() <= n) {
        fac.add(fac.last() * ModInt(fac.count().toLong()))
        invfac.add(fac.last().inv())
    }
    return if (b) {
        fac[n.toInt()]
    } else {
        invfac[n.toInt()]
    }
}

fun comb(n: Long, k: Long): ModInt {
    return fact(n, true) * fact(k, false) * fact(n - k, false)
}

fun comb2(n: Long, k: Long): ModInt {
    var ans = ModInt(1)
    for (i in 0 until k) {
        ans = ans * ModInt(n - i) / ModInt(k - i)
    }
    return ans
}
// endregion

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextLong()
    println(ModInt(10).pow(n) - ModInt(9).pow(n) - ModInt(9).pow(n) + ModInt(8).pow(n))
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 34376
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define lc 2 * v
#define rc 2 * v + 1
#define mid (s + e) / 2
#define ll long long
#define int long long
#define ld long double
#define pii pair <int , int>
#define pll pair <long long , long long>
#define FAST ios::sync_with_stdio(false);cin.tie(0);
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

const int maxn = 1e5 + 10 , N = 1e5 + 5 , SQ = 600 , base = 1999 , mod = 1e9 + 7 , INF = 1e18 , lg = 17;

int n , m , maxi , dp[maxn];
vector <int> edges[maxn] , revedges[maxn] , topol;
bool mark[maxn];

void dfs(int v) {
    mark[v] = 1;
    for (auto u : edges[v]) {
        if(!mark[u]) {
            dfs(u);
        }
    }
    topol.PB(v);
}

int32_t main() {
    FAST
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int x , y; cin >> x >> y;
        x--; y--;
        edges[x].PB(y);
        revedges[y].PB(x);
    }
    for (int i = 0; i < n; ++i) {
        if(!mark[i]) {
            dfs(i);
        }
    }
    reverse(topol.begin() , topol.end());
    memset(mark , 0 , sizeof mark);
    for (int i = 1; i < n; ++i) {
        int v = topol[i];
        for (auto u : revedges[v]) {
            dp[v] = max(dp[v] , dp[u] + 1);
        }
        maxi = max(maxi , dp[v]);
    }

    cout << maxi << '\n';
 }


Measured memory_bytes: 17832
typedef long long ll;
typedef long double ld;
#include <bits/stdc++.h>
using namespace std;
const int MAX = 2000010;
 const int MOD = 1000000007;
 
 long long fac[MAX], finv[MAX], inv[MAX];
 
 // テーブルを作る前処理
 void COMinit() {
     fac[0] = fac[1] = 1;
     finv[0] = finv[1] = 1;
     inv[1] = 1;
     for (int i = 2; i < MAX; i++){
         fac[i] = fac[i - 1] * i % MOD;
         inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
         finv[i] = finv[i - 1] * inv[i] % MOD;
     }
 }
 
 // 二項係数計算
 long long COM(int n, int k){
     if (n < k) return 0;
     if (n < 0 || k < 0) return 0;
     return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
 }
int main() {
    ll r1,c1,r2,c2;
    std::cin >> r1>>c1>>r2>>c2;
    COMinit();
    ll ans = 0;
    const ll MOD= 1e9+7;
    
    for (int i = c1; i <= c2; i++) {
        ans += COM(i+1+r2, r2)-COM(i+r1, r1-1)+MOD;
        ans %= MOD;
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 50408
n,m = map(int,input().split())
H = list(map(int,input().split()))
good = [1 for _ in range(n)]
for i in range(m):
    a,b = map(int,input().split()); a-=1; b-=1
    if H[a]>H[b]:
        good[b]=0
    elif H[a]<H[b]:
        good[a]=0
    else: #H[a]==H[b]
        good[a]=0;good[b]=0
print(sum(good))

Measured memory_bytes: 20136
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(int i = a;i < n;i++)
#define LINF (ll)1e17
#define INF 1e9
#define MOD 1e9+7
#define sMOD 1e5
#define fs first
#define sc second


signed main(){
	
	ll a,b,c,n;
	ll A[n],B[n],C[n];
	string s,t;
	bool flag = false;
	
	cin >> A[0] >> A[1] >> A[2];
	
	sort(A,A+n);
	cout << A[0]*A[1]/2 << endl;
	
	return 0;

}

Measured memory_bytes: 256
import numpy as np
import functools
import math
import scipy
import fractions
import itertools

def solve():
    n = int(input())
    x, l = [0]*n, [0]*n
    for i in range(n):
        x[i], l[i] = map(int, input().split())
    hoge = []
    for i in range(n):
        hoge.append([x[i]+l[i], x[i]-l[i]])
    hoge.sort()
    t = -1000000000000000000000
    ans = 0
    for i in range(n):
        if t <= hoge[i][1]:
            ans += 1
            t = hoge[i][0]
    print(ans)
    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 38300
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVSORT(v) sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){

  int n;cin>>n;
  int ans = 0;
  for(int i=1;i<=n;i++){
    if(i<10){
      ans++;
    }else if(i<100){

    }else if(i<1000){
      ans++;
    }else if(i<10000){

    }else if(i<100000){
      ans++;
    }
  }
  cout<<ans<<endl;

 

  return 0;
}

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


#define INF 1000000000000
  signed main(){
    int n;
    int k;
    cin>>n;
    if(n==1){cout<<0;exit(0);}
    vector<int> a(n);
    rep(i,n){
      cin>>k;
      a[i]=k-i-1;
    }
    sort(a.begin(),a.end());
    int s=a.size();
    int c,h;
    if(s%2==1){c=s/2;h=s/2;}
    else{c=s/2;h=s/2-1;}

    int chuuouchi;
    chuuouchi=(a[c]+a[h])/2;

    int ans=0;
    rep(i,n){
      ans+=abs(a[i]-chuuouchi);
    }
  cout<<ans;
 }


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

using namespace std;

string s;

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

    for (int i = 0; i < 12; ++i) {
        cout << s[i];
        if (i == 3) {
            cout << " ";
        }
    }
    cout << endl;

    return 0;
}


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

int main() {
  int N ;
  cin >> N ;
  
  vector<int64_t> L(87);
  	L.at(0) = 2;
  	L.at(1) = 1;
  	for ( int i = 2 ; i <= 86 ; i++){
    	L.at(i) = L.at(i-1) + L.at(i-2);
    }
  cout << L.at(N) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using namespace boost::multiprecision;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPI(i,a,b) for(int i=int(a);i<int(b);++i)
#define ALL(x) (x).begin(),(x).end()
inline cpp_int between(cpp_int n, cpp_int x) {
  if(n >= 0)
    return (n/x)+1;
  else
    return 0;
}

int main () {
  int a, b, c;
  cin >> a >> b >> c;
  REP(i, b) {
    if(((i*a) % b) == c) {
      cout << "YES" << endl;
      return 0;
    }
  }

  cout << "NO" << endl;
  return 0;
}


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

using ll = long long;

ll rec(ll x){
    if(x == 0) return 0;
    if(x == 1) return 1;
    return rec(x/2)*2 + 1;
}

int main(){
    ll h, ans = 0;
    cin >> h;
    cout << rec(h) << endl;
    return 0;
}



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

int main(){
int n[4];
int sum=0;
int i,j;
for(i=0;i<4;i++){
cin>>n[i];
}  

for(i=0;i<4;i++){
if(n[i]!=1 && n[i]!=9&& n[i]!=7 && n[i]!=4){
sum++;
  }
}
for(i=0;i<4;i++){
for(j=0;j<4;j++){
if(i!=j){
if(n[i]==n[j]){
sum++;
}
}
}
}
if(sum!=0){
cout<<"NO";
}
if(sum==0){
cout<<"YES";
}

}

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

typedef long long ll;
typedef long double ld;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vstr;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define asd cout << "ok" << endl;

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define trav(it, m) for(auto it = m.begin(); it it!= m.end(); it++)

const char nl = '\n';
const int MOD = 1e9 +7;
const ll INF = 1e19;
const ld PI = acos((ld)-1);
const int MX = 2e5 + 5;

int main(){

  ios_base::sync_with_stdio(0); cin.tie(0);
  int n; cin >>n ;
  int maxN = -1;
  int sum = 0;
  for(int i = 0; i < n; i++){
    int x; cin >> x;
    sum+= x;
    maxN= max(maxN, x);
  }
  cout << sum - maxN/2 << nl;







  return 0;
}



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

int main(){
    long long n;
    long long a,b;
    cin >> n >> a >> b;
    long long c = n % (a+b);
    long long d;
    if(c <=a)d = c;
    else d = a;
    long long e = n / (a+b);
    cout << e * a + d << endl;
}

Measured memory_bytes: 256
/*I MAY NOT GET THE SUCCESS IMMEDIATELY BUT I WILL GET IT FOR SURE*/
#include<bits/stdc++.h>
#define opt std::ios_base::sync_with_stdio(false)
#define I int
#define li		int32_t
#define lli		long long
#define ulli unsigned long long

#define pn			 printf("\n")
#define nl			 cout<<'\n'
#define sf(N)        scanf("%lld",&N)
#define pf(N)        printf("%lld",N)
#define sf1(N1,N2)    scanf("%lld %lld",&N1,&N2)
#define pf1(N1,N2)    printf("%lld %lld",N1,N2)
#define sf2(N1,N2,N3) scanf("%lld %lld %lld",&N1,&N2,&N3)
#define pf2(N1,N2,N3) printf("%lld %lld %lld",N1,N2,N3)

#define sl          cout<<' '
#define ps          printf(" ")

#define rep(i,a,b)	for(i=a;i<b;i++)
#define repr(i,a,b)	for(i=a;i>b;i--)
#define elif		else if
#define mset(a,b)	memset(a,b,sizeof(a))

#define pb		push_back
#define pob		pop_back
#define itr		iterator
#define sz()	size()
#define szof    sizeof
#define lb		lower_bound
#define ub		upper_bound
#define mp		make_pair
#define vlli    vector<lli>
#define plli	pair<lli,lli>
#define vplli	vector<plli >
#define F   	first
#define S		second
#define Dup     erase(unique(V.begin(),V.end()),V.end())

#define bs      binary_search
#define ub      upper_bound
#define lb      lower_bound

#define ALL(V)  V.begin(),V.end()

#define MX1     100000
#define MX2     1000000
#define Inf     1000000000000000
#define mod		1000000007
#define mod1    1000000007
#define mod2    1000000009
using namespace std;

lli Power(lli a,lli b)
{
    lli result=1;

    while(b)
    {
        if(b%2)
        {
            result=(result*a)%mod;
        }

        b=b>>1;
        a=(a*a)%mod;
    }

 return result;
}

int main()
{
    opt;

    /*#ifndef ONLINE_JUDGE
    freopen("double_squares.txt","r",stdin);
    freopen("double_squares_out.txt","w",stdout);
    #endif // ONLINE_JUDGE*/

    lli N;
    cin>>N;

    lli Sum=0,N1=N;

    while(N1)
    {
        Sum+=N1%10;
        N1/=10;
    }

    if(N%Sum)
    {
        cout<<"No";
    }
    else
    {
        cout<<"Yes";
    }







 return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
    private static MyScanner scanner;

    public static void main (String[] args){
        Main instance = new Main();
        scanner = instance.new MyScanner();
        instance.solve();
    }

    private void solve() {
        try {
            int n = scanner.nextInt();
            HashSet<Integer> set = new HashSet<Integer>();
            for (int i = 0; i < n; i++) {
                set.add(scanner.nextInt());
            }
            int size = set.size();
            if (size % 2 == 0) {
                System.out.println(size - 1);
            } else {
                System.out.println(size);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";

        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String line = br.readLine();
            while (line.equals("")) {
                line = br.readLine();
            }
            s = line.split(reg, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }

        public long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 35000
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
    ll n;
    cin>>n;
    ll sq=sqrt(n);
    cout<<sq*sq<<endl;
}
return 0;
}

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

int main() {
  int A, B, C; cin >> A >> B >> C;
  long long ans = 0;
  ans += min(A, C);
  C -= min(A, C);
  int tmp = min(B, C);
  ans += 2 * tmp;
  B -= tmp;
  C -= tmp;
  if (B > 0) ans += B;
  if (C > 0) ans += 1;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  string s;
  cin >> N >> s;
  int cnt_w = 0;
  int cnt_e = 0;
  for(int i=0; i<s.size(); i++){
    if(s.at(i) == 'E'){
      cnt_e++;
    }
    else{
      cnt_w++;
    }
  }
  
  int64_t ans = 1000000000;
  int cnt_w_pre = 0;
  int cnt_e_pre = 0;
  for(int i=0; i<s.size(); i++){
    int64_t x = 0;
    if(s.at(i) == 'E'){
      x = (cnt_e-1) + cnt_w_pre;
      ans = min(x,ans);
      cnt_e--;
      cnt_e_pre++;
    }
    else{
      x = cnt_e + cnt_w_pre;
      ans = min(x,ans);
      cnt_w--;
      cnt_w_pre++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  ll N,i,j,ans=0;cin>>N;
  vector<P>BLUE(N),RED(N);
  REP(i,N)cin>>RED.at(i).S>>RED.at(i).F;
  REP(i,N)cin>>BLUE.at(i).F>>BLUE.at(i).S;
  sort(ALL(BLUE));sort(ALL(RED));reverse(ALL(RED));
  REP(i,N)REP(j,N)if(BLUE.at(i).F>RED.at(j).S&&BLUE.at(i).S>RED.at(j).F){
    RED.at(j)=P(2*N,2*N);ans++;break;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
int H, W;
char s[21][21];
int dp[21][21]; 
typedef pair<pair<int, int>, int> P; 
int dh[4] = {1, 0, -1, 0}, dw[4] = {0, 1, 0, -1};


// 計算量はO(HW)
int bfs(int sh, int sw) {
  rep(i, H) rep(j, W) dp[i][j]=-1;
  dp[sh][sw] = 0; 
  queue<P> que;
  que.push(P(make_pair(sh, sw), 0));
  int max_cnt = 0;
  while(!que.empty()) {
    P p = que.front(); que.pop();
    int h = p.first.first, w = p.first.second, cnt = p.second;
    rep(i, 4) {
      int nh = h +dh[i], nw = w+dw[i];
      if ((nh<0) || (nh>=H) || (nw<0) || (nw>=W)) continue;
      if (s[nh][nw] == '#') continue;
      if (dp[nh][nw] != -1) continue;
      int next_cnt = cnt+1; 
      que.push(P(make_pair(nh, nw), next_cnt));
      dp[nh][nw] = next_cnt;
      max_cnt = next_cnt;
    }
  }
  
  return max_cnt;
}

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

  cin >> H >> W;
  int sh,sw;
  rep(i, H) {
    rep(j, W) {
      cin >> s[i][j];
      if (s[i][j]=='.') {
        sh = i;
        sw = j;
      } 
    }
  }
  int ans = -1;
  rep(i, H){
    rep(j, W) {
      if  (s[i][j]=='#') continue;
      int cnt = bfs(i, j);
      if (ans < cnt) ans = cnt;
    }
  }

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

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,b;
	while(scanf("%d%d",&a,&b)!=EOF&&a&&b)
	{
		int i,j;
		for(j=0;j<b;j++)
			{
				printf("#");
			}
		printf("\n");
		for(i=0;i<(a-2);i++)
		{
			printf("#");
			for(j=0;j<(b-2);j++)
			{
				printf(".");
			}
			printf("#\n");
		}
		for(j=0;j<b;j++)
			{
				printf("#");
			}
			
		printf("\n\n");
	}
	return 0;
 } 

Measured memory_bytes: 1016
#include <bits/stdc++.h>
#define MAX 10000007
#define PI acos(-1)
#define eps 1e-8
#define eq(x,y) (fabs((x)-(y)) < eps)
#define debug(x) cout<<x<<endl;
#define endl "\n"
#define MEM(a,x) memset(a,x,sizeof(a))

using namespace std;
typedef long long ll ;
const int inf= 1e9+7;
const int nmax = 1e5+10;

//priority_queue<int,vector<int>,greater<int>>pq; //ascending

/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<long long,null_type,less<long long>, rb_tree_tag,tree_order_statistics_node_update>
using namespace __gnu_pbds;
*/
/*
bool sortbysec(const pair<int,int>&a, const pair<int,int>&b)
{
    return (a.second<b.second);
}
*/
int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout.tie(NULL);
    int n;
    cin>>n;
    vector<pair<int,pair<int,int>>>v;
    v.push_back({0,{0,0}});

    for(int i=1;i<n;i++)
    {
        int c,s,f;
        cin>>c>>s>>f;
        v.push_back({c,{s,f}});
    }

    vector<ll>t;

    ll time=0;

    for(int j=1;j<=n;j++)
    {
        for(int i=j;i<n;i++)
        {
            if(i==j)
            {
                time+=v[i].first+v[i].second.first;
            }else
            {
                if(v[i].second.first>time)
                    time+=(v[i].second.first-time);
                if(time%v[i].second.second)
                    time+=(v[i].second.second-(time%v[i].second.second));
                time+=v[i].first;
            }
        }

        t.push_back(time);
        time=0;
    }

    for(int i=0;i<t.size();i++)
        cout<<t[i]<<" ";


    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
  
void sort_book(vector<tuple<string,int,int>> &a){
   for( size_t i = 0; i < (int)(a.size()) - 1; ++i ){
      for( size_t j = i + 1; j < (int)(a.size()); ++j ){
        if( get<0>(a.at(i)) > get<0>(a.at(j)) ){
          swap(a.at(i), a.at(j));
        }
        else if(get<0>(a.at(i)) == get<0>(a.at(j)) ){
          if( get<1>(a.at(i)) < get<1>(a.at(j)) ){
            swap(a.at(i), a.at(j));
          }
        }
      }
   }
}
             
int main(){
  int n;
  cin >> n;
  
  vector<tuple<string,int,int>> a(n);
  for(int i=0;i<n;i++){
    string name;
    int score;
    cin >> name >> score;
    a.at(i) = make_tuple(name,score,i+1);
  }
  sort_book(a);
  for(int i= 0;i < n;i ++){
    cout << get<2>(a.at(i)) << endl;
  }
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

#define faster ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define read freopen("in.txt", "r", stdin)
#define write freopen("out.txt", "w", stdout)
#define mem(x, n) memset(x, n, sizeof(x))
#define all(x) x.begin(), x.end()
#define endl "\n"

ll mod = 1e9 + 7;

ll dp[2005], arr[2005];

int main() {
	faster;
	mem(dp, 0);
	ll n;
	cin >> n;

	dp[0] = 1;

	for (int i = 0; i < n; i++) {
		arr[i] = 3 + i;
	}

	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < n - 2; j++) {
			if (arr[j] <= i) {
				dp[i] = (dp[i - arr[j]] + dp[i]) % mod;
			}
		}
	}

	cout << dp[n] << endl;

	return 0;
}

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

int main(void) {
  int n;
  int a[200000];
  cin >> n;
  
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  
  int m = 0;
  int b[200000];
  
  for(int i = n/2; i < n; i++) {
    b[i] = a[i];
    if(b[i] == 1) m++;
  }
  for(int i = n/2 - 1; i >= 0; i--) {
    int x = 0;
    for(int j = 2*(i+1); j <= n; j += i+1) {
      x += b[j-1];
    }
    if(x%2 == 0) {
      b[i] = a[i];
    } else {
      b[i] = 1 - a[i];
    }
    if(b[i] == 1) m++;
  }
  
  cout << m << endl;
  
  for(int i = 0; i < n; i++) {
    if(b[i] == 1) cout << i+1 << " ";
  }
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 2432
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	private class DisjointSet {
		
		int[] p;
		int[] rank;

		public DisjointSet(int size) {
			p = new int[size];
			rank = new int[size];
			for (int i = 0; i < size; i++) makeSet(i);
		}

		private void makeSet(int x) {
			p[x] = x;
			rank[x] = 0;
		}
		
		public boolean same(int x, int y) {
			return findSet(x) == findSet(y);
		}

		private int findSet(int x) {
			int parent = p[x];
			int v = x;
			while (parent != v) {
				parent = p[v];
				v = p[parent];
				p[x] = parent;
			}
			return parent;
		}
		
		public void unite(int x, int y) {
			link(findSet(x), findSet(y));
		}

		private void link(int x, int y) {
			if (rank[x] < rank[y]) {
				p[y] = x;
			} else {
				p[x] = y;
				if (rank[x] == rank[y]) {
					rank[y]++;
				}
			}
		}
	}
	
	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	
	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(reader.readLine());
		int n = Integer.parseInt(st.nextToken());
		DisjointSet ds = new DisjointSet(n);
		int q = Integer.parseInt(st.nextToken());
		for (int i = 0; i < q; i++) {
			st = new StringTokenizer(reader.readLine());
			int c, x, y;
			c = Integer.parseInt(st.nextToken());
			x = Integer.parseInt(st.nextToken());
			y = Integer.parseInt(st.nextToken());
			if (c == 0) {
				ds.unite(x, y);
			} else if (c == 1) {
				System.out.println(ds.same(x, y)?"1":"0");
			}
		}
		reader.close();
	}
}



Measured memory_bytes: 60620
//Bismillahir Rahmanir Rahim
#include <iostream>
#define ll              long long
#define ull             unsigned long long
#define pb              push_back
#define fastread()      (ios_base:: sync_with_stdio(false),cin.tie(NULL));
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if((a == b)) {
        cout<<"Draw\n";
    }
    else if((a == 1) || (a > b && b != 1)){
        cout<<"Alice\n";
    }
    else if((b == 1) || (b > a && a != 1) ) {
        cout<<"Bob\n";
    }

    return 0;
}

Measured memory_bytes: 3048
//Author : pakhandi
//
using namespace std;

#include<bits/stdc++.h>

#define wl(n) while(n--)
#define fl(i,a,b) for(i=a; i<b; i++)
#define rev(i,a,b) for(i=a; i>=b; i--)

#define si(n) scanf("%d", &n)
#define sll(l) scanf("%lld",&l)
#define ss(s) scanf("%s", s)
#define sc(c) scanf("%c", &c)
#define sd(f) scanf("%lf", &f)

#define pi(n) printf("%d\n", n)
#define pll(l) printf("%lld\n", l)
#define ps(s) printf("%s\n", s)
#define pc(c) printf("%c\n", c)
#define pd(f) printf("%lf\n", f)

#define debug(x) cout<<"\n#("<<x<<")#\n"
#define nline printf("\n")

#define mem(a,i) memset(a,i,sizeof(a))

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

#define mclr(strn) strn.clear()
#define ignr cin.ignore()
#define PB push_back
#define SZ size
#define MP make_pair
#define fi first
#define sec second

ll a[102];


int main()
{
	int i, j;

	int n;

	si(n);

	fl(i,0,n)
	{
		cin>>a[i];
	}

	ll ans = INT_MAX;

	ll val;

	fl(val,-100,101)
	{
		ll thisAns = 0;
		fl(i,0,n)
		{
			thisAns += ((a[i] - val) * (a[i] - val));
		}
		ans = min(ans, thisAns);
	}

	cout<<ans;


	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    vector<ll> BA(100000+1,0);
    ll n,k;
    cin >> n >> k;
    REP(i,n){
        ll ai, bi;
        cin >> ai >> bi;
        BA[ai]+=bi;
    }
    ll ans=0;

    for(int i =1; i<=100000; i++){

        if(k<=BA[i]){
            ans=i;
            break;
        }
        else k-=BA[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
s = input()
q = int(input())
r, st1, st2 = 0, "", ""
for _ in range(q):
  query = input()
  if query[0] == "1":
    r += 1
  else:
    t, f, c = query.split()
    if (r + int(f)) % 2:
      st1 += c
    else:
      st2 += c

string = "".join(reversed(list(st1))) + s + st2
if r % 2 == 0:
  print(string)
else:
  print("".join(reversed(list(string))))

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

int main()
{
  int A, B;

  cin >> A >> B;

  int X = floor((100 * A - 10 * B) / 7);

  bool valid = false;

  for (int i = 0; i < 100; i++) {
    if (floor((X + i) * 0.08) == A && floor((X + i) * 0.1) == B && X + i >= 0) {
      cout << X + i << endl;
      valid = true;
      break;
    }
  }
  if (!valid) {
    cout << -1 << endl;
  }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES // for C++
#include <cmath>
#include <iostream>
#include <iomanip>

using namespace std;

int main(){

	double r;

	cin >> r;

	cout << fixed << setprecision(6);
	cout << M_PI * r * r << " " << 2 * M_PI * r << endl;

	return 0;
}

Measured memory_bytes: 1288
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    printf("%s\n",a+b>c+d?"Left":a+b==c+d?"Balanced":"Right");
    return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class B
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		int N = GetInt();
		string S = GetString();

		if(N % 2 == 0 && S.Substring(0, N / 2).Equals(S.Substring(N / 2, N / 2)))
			WriteLine("Yes");
		else
			WriteLine("No");
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
	public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <deque>
#include <queue>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
#define INF 10000000000000
using namespace std;
using ll = long long;
vector<ll> w(110);
vector<ll> v(110);
ll dp[110][100010];
int main() {
	ll n, W;
	cin >> n >> W;

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

	for (ll i = 0; i <= W; i++) {
		dp[0][i] = 0;
	}
	for (ll i = 0; i < n; i++) {
		for (ll j = 0; j <= W; j++) {
			if (j >= w[i]) {
				dp[i + 1][j] = max(dp[i][j - w[i]] + v[i], dp[i][j]);
			}
			else {
				dp[i + 1][j] = dp[i][j];
			}
		}
	}
	cout << dp[n][W] << endl;
}

Measured memory_bytes: 80128
import java.util.*;
import java.io.*;
public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		String s = sc.next();
		sc.close();
		int[] q = new int[n];
		for(int i = 0 ; i < n ; i++) q[i] = (int)s.charAt(i) - 48;
		int yono = 0;
		int[] k = new int[3];
		int ke = 0;
		for(int i = 0 ; i < 1000 ; i++){
			k[2] = i % 10;
			k[1] = (i / 10) % 10;
			k[0] = (i / 100) % 10;
			ke = 0;
			boolean che = true;
			for(int j = 0 ; che && j < n ; j++){
				if(ke == 3){
					che = false;
					yono++;
				}else if(k[ke] == q[j]){
					ke++;
				}
				if(ke == 3){
					che = false;
					yono++;
				}
			}
		}
		ou.print(yono + "\n");
		ou.flush();
    }
}

Measured memory_bytes: 39524
#include <iostream>
#include <cstdio>
#include <cctype>
#include <cstring>
using namespace std;

int main() {
	char s[201],s2[101],p[101];
	scanf("%s", s);
	scanf("%s", p);
	strcpy(s2,s);
	strcat(s,s2);
	if(strstr(s,p) != NULL){
		printf("Yes\n");
	}else printf("No\n");
	return 0;
}


Measured memory_bytes: 3172
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

template<typename T>
string to_string(const vector<T>& vc, int w) {
	if(vc.empty()) return "";
	if(w + 1 == vc.size()) return to_string(vc[w]);
	return to_string(vc[w]) + "," + to_string(vc, w + 1);
}

template<typename T>
string to_string(const vector<T>& vc) {
	return "{" + to_string(vc, 0) + "}";
}

void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	#endif

	int n;
	cin >> n;
	string str;
	cin >> str;
	int a = 0, b = n - 1, ans = 0;
	while(1) {
		while(a < n && str[a] != 'W') a++;
		while(b >= 0 && str[b] != 'R') b--;
		if(a < b) ans++, swap(str[a], str[b]);
		else break;
	}
	cout << ans << '\n';
}



Measured memory_bytes: 3776
#include<stdio.h>

int main()
{
    int n,x,y,z,sum=0,min;
    scanf(" %d %d",&n,&x);

    int m[n];
    for(y=0;y<n;y++){
        scanf(" %d",&m[y]);
        sum+=m[y];
    }

    x-=sum;

    min=m[0];
    for(y=1;y<n;y++){
        if(min>m[y]){
            min=m[y];
        }
    }

    x/=min;

    printf("%d",n+x);

    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>

typedef __int128_t int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
    long long tmp; input >> tmp; value = tmp;
    return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
    output << (long long)value;
    return output;
}

int N, K;

int main(int argc, char **argv) {
    std::cin >> N >> K;

    if (K == 1) {
        std::cout << 0 << std::endl;
    } else {
        std::cout << N - K << std::endl;
    }

    

    return 0;
}

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

int main()
{
    int n,w,h,i,count=0;
    scanf("%d",&h);
    scanf("%d",&w);
    scanf("%d",&n);
    if(h>=w)
    {
        i=0;
        while(count<n)
        {
            count+=h;
            i++;
        }
    }
    else
    {
        i=0;
        while(count<n)
        {
            count+=w;
            i++;
        }
    }
    printf("%d",i);
    return 0;
}


Measured memory_bytes: 128
package main

import (
	"fmt"
	"strings"
)

func main() {
	var (
		n int
		s string
	)
	fmt.Scan(&n, &s)

	r := strings.Count(s, "R")
	b := n - r
	if r > b {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    int A[3];
    cin >> N >> A[0] >> A[1] >> A[2];
    int l[10];
    rep(i, N) cin >> l[i];
    int ans = INF;
    rep(i, pow(4, N) + 0.5) {
        int bit = i;
        int L[4] = {};
        int cnt[4] = {};
        rep(j, N) {
            L[bit % 4] += l[j];
            cnt[bit % 4]++;
            bit /= 4;
        }
        int tmp = 0;
        rep(j, 3) if (cnt[j] == 0) tmp += 10000000;
        rep(j, 3) tmp += abs(L[j] - A[j]) + (cnt[j] - 1) * 10;
        ans = min(ans, tmp);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#include <queue>
#include <string.h>
#include <bitset>

#define ll long long int
#define ld long double
#define rep(i,n) for(int i = 0;i < n;i++)
#define rep1(i,n) for(int i = 1;i < n;i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "
#define all(x) x.begin(),x.end()
#define allr(x) x.begin(),x.end(),greater<int>()
#define P pair<ll,ll>
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1ll << 60
#define PI 3.14159265359

using namespace std;

int main(){
	int n,ma,mb;
	cin >> n >> ma >> mb;
	vector<int> a(n),b(n),c(n);
	int a1,b1,c1;
	for(int i = 0;i < n;i++){
		cin >> a1 >> b1 >> c1;
		a[i] = a1;
		b[i] = b1;
		c[i] = c1;
	}
	ll dp[n+1][401][401];
	rep(i,n+1){
		rep(j,401){
			rep(k,401){
				dp[i][j][k] = 10000;
			}
		}
	}
	dp[0][0][0] = 0;
	for(int i = 1;i <= n;i++){
		rep(j,401){
			rep(k,401){
				if(j-a[i-1] >= 0 && k - b[i-1] >= 0){
					dp[i][j][k] = min(dp[i-1][j-a[i-1]][k-b[i-1]]+c[i-1],dp[i][j][k]);
				}
				dp[i][j][k] = min(dp[i-1][j][k],dp[i][j][k]);
			}
		}
	}
	ll ans = 10000;
	for(int i = 1;ma*i < 401 && mb*i < 401;i++){
		ans = min(ans,dp[n][ma*i][mb*i]);
	}
	if(ans == 10000) cout << -1 << endl;
	else cout << ans << endl;
	return 0;
}

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

#define pii pair<int,int>
#define pll pair<ll,ll>
#define eb emplace_back
#define ll long long
#define nl '\n'
#define deb(x) cerr<<#x" = "<<x<<nl
#define in() ( { int a ; scanf("%d",&a); a; } )

const int N = 3e5 + 9;
const int mod = 1e9 + 7;

int32_t main()
{
    int n=in();
    string a, b; cin>>a>>b;
    for(int i=0; i<n; i++) cout<<a[i]<<b[i];
    cout<<nl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <string>
#include <map>
#include <vector>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define LargeNum 1000000007;
int main(){
    string S, s;
    int A[4], ans, b=0;
    cin >> S;
    rep(i, 4){
        s = S[i];
        A[i] = stoi(s);
    }
    bitset<3> bit;
    rep(i, pow(3, 2)){
        ans = A[0];
        bit = b;
        for (int j=1; j<4; j++){
            if(bit[j-1]==0) ans = ans + A[j];
            else ans = ans - A[j];
        }
        if (ans == 7) break;
        b ++;
    }
    cout << A[0];
    rep(i, 3){
        if(bit[i]==0) cout << '+';
        else cout << '-';
        cout << A[i+1];
    }
    cout << "=7" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;
int main()
{
	boost;
	int n, h, i;
	cin >> h >> n;
	int x;
	ll sum = 0;
	fo(i, 0, n) {
		cin >> x;
		sum += x;
	}
	if(sum >= h) cout << "Yes";
	else cout << "No";
}


Measured memory_bytes: 256
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
  int c[3][3],difft[3],diffy[3];
  rep(i,3)rep(j,3)cin>>c[i][j];
  rep(i,3)difft[i]=c[i][0]-c[0][0];
  rep(i,3)diffy[i]=c[0][i]-c[0][0];
  bool ans=false;
  rep(a,101){
    rep(b,101){
      if(c[0][0]!=a+b)continue;
      int d;
      bool check=true;
      rep(i,3){
	rep(j,3){
	  d=(a+difft[i])+(b+diffy[j]);
	  if(d!=c[i][j]){
	    check=false;
	    break;
	  }
	}
	if(!check)break;
      }
      if(check){
	ans=true;
	break;
      }
    }
    if(ans)break;
  }
  cout<<(ans?"Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 256
import Foundation

extension String {
    func wordsMap<T>(_ f: (Substring) -> T?) -> [T] {
        return self.split(separator: " ").compactMap(f)
    }
}

private func readWords<T>(_ f: (Substring) -> T?) -> [T] {
    return readLine()!.wordsMap(f)
}

extension Optional {
    func pleaseAC(){
        print(self!)
    }
}

readLine().map { line -> Any in 
    let nh = line.wordsMap { Int($0) }
    let n = nh[0]
    let h = nh[1]

    var maxA = 0
    let weapons = (1...n).map { _ -> (Int, Int) in
        let ab = readWords { Int($0) }
        let a = ab[0]
        let b = ab[1]
        maxA = max(a, maxA)
        return (a, b)
    }

    let niceB = weapons.lazy.filter { $0.1 > maxA }.map { $0.1 }.sorted(by: >)

    var total = 0
    var ans = 0
    for b in niceB {
        total += b
        ans += 1
        if total >= h {
            return ans
        }
    }

    let rest = h - total

    return (rest % maxA == 0 ? 0 : 1) + rest / maxA + ans

}
.pleaseAC()


Measured memory_bytes: 15864
s = input()
a = int(s[:2])
b = int(s[2:])

if 0 < a <= 12:
    if 0 < b <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 0 < b <= 12:
        print("YYMM")
    else:
        print("NA")



Measured memory_bytes: 38256
#include<cstdio>
#include<cctype>
#include<cstdlib>
#include<cstring>
inline int $(){
	register int x = 0;register char ch = getchar();
	while(!isdigit(ch))ch = getchar();
	for(;isdigit(ch);ch = getchar())x = (x << 1) + (x << 3) + (ch ^ 48);
	return x;
}
#define MAXN 100010
int head[MAXN], next[MAXN << 1], to[MAXN << 1], tot = 0, n = $();
inline void $(int u, int v){
	next[tot] = head[u];to[tot] = v;head[u] = tot++;
	next[tot] = head[v];to[tot] = u;head[v] = tot++;
}
int dp(int x, int fa){
	int cnt = 0;
	for(int i = head[x];~i;i = next[i]){
		if(to[i] == fa)continue;
		cnt += dp(to[i], x);
		if(cnt >= 2)puts("First"), exit(0);
	}
	return !cnt;
}
int main(){
	memset(head, -1, sizeof(head));
	for(int i = 1;i < n;i++)$($(), $());
	if(dp(1, 0))puts("First");
	else puts("Second");
	return 0;
}

Measured memory_bytes: 2176
a=input()
maxvalue=0
for i in range(1,len(a)+1):
    for j in range(0,len(a)+1-i):
        tmp=a[j:j+i]
        flag=True
        for k in range(0,len(tmp)):
            if (not(tmp[k]=='A' or tmp[k]=='T' or tmp[k]=='G' or tmp[k]=='C')):
                flag=False
        if flag==True:
            maxvalue=max(maxvalue,i)
print(maxvalue)

Measured memory_bytes: 3064
#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 INF = 1001001001;

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

int main() {
    int h, n;
    cin >> h >> n;
    vector<int> dp(h+1, INF);
    dp[0] = 0;
    rep(i,n) {
        int a, b;
        cin >> a >> b;
        rep(j,h) {
            int nj = min(j+a,h);
            dp[nj] = min(dp[nj], dp[j]+b);
        }
    }
    cout << dp[h] << endl;
    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
//最高点問題を解く時以外はコンプリートボーナス狙いで9!調べる...?


int main()
{
    int d,g;
    std::cin >> d >> g; // d : 問題数 / g : 目標点数
    std::vector<std::pair<int,std::pair<int,int>>>  a(d); //first : 問題番号 second.first : 問題数 second.second : ボーナス
    for(int i = 0; i < d; i++){
        std::cin >> a[i].second.first >> a[i].second.second;
        a[i].first = (i+1) * 100;
    }
    std::sort(a.begin(),a.end());
    int min = 1000000000;
    do{
        int gg = g; //これが0になるまで
        int cnt = 0;
        for(int i = 0; i < d; i++){
            if(gg - a[i].first * a[i].second.first >= 0){
                gg -= a[i].first * a[i].second.first;
                gg -= a[i].second.second;
                cnt += a[i].second.first;
                if(gg <= 0)break;
            }else{
                // gg <= a[i].first * x
                cnt += (gg + a[i].first - 1) / a[i].first;
                break;
            }
        }
        min = std::min(min,cnt);

    }while(std::next_permutation(a.begin(),a.end()));
    std::cout << min << std::endl;
}

Measured memory_bytes: 256