akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){


}

Node treeMaximum(Node x){


}

Node treeSearch(Node u, int k){
  if(u == NIL || k == u->key)
    return u;
  if(k < u->key)
    return treeSearch(u->left,k);
  else
    return treeSearch(u->right,k);

}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL ){
    y = x;
    if(z->key < x->key)
      x = x->left;
    else
      x = x->right;
  }


  if(y == NIL)
    root = z;
  else if(z->key < y->key)
    y->left = z;
  else
    y->right = z;

}

void inorder(Node u){
  if(u != NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}
void preorder(Node u){
  if(u != NIL){
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



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

int main() {
    string s, ret =""; cin >>s;
    for (auto c: s) {
        if (c == 'B') {if(ret.size()>0)ret.pop_back();}
        else {ret.push_back(c);}
    }
    cout << ret << endl;
    return 0;
}

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


int main(void) {
	int N;
	scanf("%d", &N);
	int i;
	long ans = 1;

	long int X = 1000000007;

	for(i=0; i<N; i++){
		ans *= (long)(i+1) % X;
		if(ans > X){
			ans = ans % X;
		}
	}
	printf("%ld\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <map>
#include <bitset>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
int main(int argc, char const *argv[])
{

    int n, m;
    cin >> n >> m;
    int k[m];
    vector<int> v[m];
    int p[m];
    rep(i, m)
    {
        cin >> k[i];
        rep(j, k[i])
        {
            int t;
            cin >> t;
            v[i].push_back(t - 1);
        }
    }
    rep(i, m) cin >> p[i];
    ll ans = 0;
    rep(i, 1 << (n))
    {
        bool all = true;
        rep(j, m)
        {
            int ok = 0;
            rep(l, v[j].size())
            {
                if (((i >> v[j][l]) & 1) == 1)
                    ok ^= 1;
            }
            //  cerr << ok << endl;
            if (ok != p[j])
            {
                all = false;
                break;
            }
        }
        if (all == true)
        {
            //   cerr << bitset<8>(i) << endl;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
//by azidoazideazide(c2n14)
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm> //#include<map>
#include<vector>
using namespace std;
typedef long long ll;
//#include<fstream>
//ifstream fin("rps.in");
//ofstream fout("rps.out");
//#define pb push_back
int main(){
	ios::sync_with_stdio(0);
	int f,j;
  for(f=1;f<=9;f++){
    for(j=1;j<=9;j++)
      cout<<f<<"x"<<j<<"="<<f*j<<endl;
  }
return 0;
}


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

int main() {
  
  vector<int>a(3);
  for (int i = 0; i < 3; i++) {
    cin>>a.at(i);
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  int ans=0;
  while(a.at(0)>a.at(1)+1){
    a.at(1)+=2;
    ans++;
  }
  while(a.at(0)>a.at(2)+1){
    a.at(2)+=2;
    ans++;
  }
  if(a.at(0)-a.at(1)+a.at(0)-a.at(2)==1){
    ans+=2;
  }
  if(a.at(0)-a.at(1)+a.at(0)-a.at(2)==2){
    ans++;
  }


    
    cout<<ans<<endl;
  
}




Measured memory_bytes: 256
s = input()
words = set()
words.add('')
words.add(s)
for i in range(len(s)):
    words.add(s[i])
    for j in range(i, len(s)+1):
        words.add(s[i:j])

matched = []
for w in words:
    n = 0
    for i in w:
        if i not in ['A', 'T', 'G', 'C']:
            n += 1
    if n == 0:
        matched.append(len(w))
print(max(matched))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <tuple>
#include <sstream>
#include <typeinfo>
#include <fstream>
#include <random>
#include <queue>
#include <deque>
#include <iterator>
#include <map>
#include <functional>
#include <numeric>
using namespace std;
#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 pb(a) push_back(a)
#define llong long long
#define INF 1145141919
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
int dy[] = { 1, 0, -1, 0 };
int dx[] = { 0, 1, 0, -1 };
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

int main() {
	int d;
	cin >> d;
	if (d == 22) {
		cout << "Christmas Eve Eve Eve" << endl;
	}
	else if (d == 23) {
		cout << "Christmas Eve Eve" << endl;
	}
	else if (d == 24) {
		cout << "Christmas Eve" << endl;
	}
	if (d == 25) {
		cout << "Christmas" << endl;
	}

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

template<typename T>
vector<T> divisor(T n)
{
    vector<T> res;
    for(T i=1;(ll)i*i<=n;i++){
        if(n%i==0){
            res.pb(i);
            if(i != n/i){
                res.pb(n/i);
            }
        }
    }
    sort(all(res));
    return res;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    auto res = divisor(m);
    rrep(i,len(res)){
        if(n <= m/res[i]){
            cout << res[i] << "\n";
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>
#include <vector>

using namespace std;

int main()
{
  int counter = 0;
  int N, D;
  cin >> N >> D;
  vector<int> x;
  vector<int> y;
  int temp;
  for (int i = 0; i < N; ++i)
  {
    cin >> temp;
    x.push_back(temp);
    cin >> temp;
    y.push_back(temp);
  }
  for (int i = 0; i < N; ++i)
  {
    if (sqrt(pow(x[i], 2) + pow(y[i], 2)) <= D)
      counter++;
  }

  cout << counter << endl;

  return 0;
}

Measured memory_bytes: 5136
def main():
    n = int(input())
    k = int(input())
    #k > 2*n 2倍
    tmp = 1
    i=0
    while(i<n):
        if(tmp < k):
            tmp += tmp
        else:
            tmp += k
        i+=1
    print(tmp)
if __name__ == '__main__':
    main()


Measured memory_bytes: 9084
def main():
    n = input()
    cnt = 0

    if n[0] == n[1]:
        cnt += 1
    else:
        cnt = 0

    for i in range(2, 4):
        if n[i-1] == n[i]:
            cnt += 1
        else:
            cnt -= 1
        if cnt >= 2:
            print('Yes')
            break
    if cnt < 2:
        print('No')


if __name__ == "__main__":
    main()


Measured memory_bytes: 9072
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
   
    string a;
    string b;
    cin>>a>>b;
    ll count=0;
    
    for(int i{0};i<a.length();i++)
    {
        if(a.substr(i,1)!=b.substr(i,1))
        {
            count++;
        }
    }
    cout<<count;
    return 0;
}

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

int getmd(int a,int b,int c,int d){
    return abs(a-c)+abs(b-d);
}

int main(){
    int d;
    cin >> d;

    if(d==25)   puts("Christmas");
    if(d==24)   puts("Christmas Eve");
    if(d==23)   puts("Christmas Eve Eve");
    if(d==22)   puts("Christmas Eve Eve Eve");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n;
    cin >> n;

    vector<tuple<string, ll, ll>> tup;
    rep(i, n) {
        string s;
        ll p;
        cin >> s >> p;
        p *= -1;
        tup.emplace_back(s, p, i+1);
    }
    sort(all(tup));

    for(auto u : tup) {
        out(get<2>(u));
    }

    re0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;

    if (x + r <= w && x - r >= 0 && y + r <= h && y - r >= 0)
    {
        cout << "Yes" << endl;
    }
    else
        cout << "No" << endl;
}



Measured memory_bytes: 3124
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = s; i < (int)(n); i++)
#define print(a) cout << (a) << endl; 
typedef long long ll;
const int MOD = 1000000007; 

int main() {
    int n;
    cin >> n;
    int ret;
    if (n*100%108==0) {
        ret = n*100/108;
    } else {
        ret = n*100/108;
        ret++;
        int cmpi = ret*1.08;
        if (cmpi != n) {
            cout << ":(" << endl;
            return 0; 
        }
    }  
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
//Resting_Prince
#include<bits/stdc++.h>
#define mod 1000000007
#define inf 1e18
#define PI 3.141592653589
#define fi first
#define se second 
#define sv(v) sort(all(v));reverse(all(v))
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mk make_pair
#define en '\n'
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double ld;
 
int main()
{
    ll n,h[200005],i,j,k,l,dp[200005];
    cin>>n>>k;
    rep(i,0,n-1)cin>>h[i+1],dp[i+1]=inf; 
    dp[0]=0;
    dp[1]=0;
    rep(i,1,n)
    {
        rep(j,1,k)
        dp[i+j]=min(dp[i+j],dp[i]+abs(h[i+j]-h[i]));
    }cout<<dp[n];
    return 0;
}

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

int main() {
	ll n, k;
	cin >> n >> k;
	vector<ll> a(n);
	for (ll i = 0; i < n; ++i)cin >> a[i];
	for (ll i = k; i < n; ++i) {
		if (a[i - k] < a[i])cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}


Measured memory_bytes: 4836
-- https://github.com/minoki/my-atcoder-solutions
import Data.Char (isSpace)
import Data.List (unfoldr)
import qualified Data.Vector.Unboxed as U
import qualified Data.ByteString.Char8 as BS

main = do
  n <- readLn :: IO Int
  xs <- U.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  let ys = U.scanl (+) 0 xs
  let total = U.last ys
  let (zs,ws) = U.span (\x -> 2 * x <= total) ys
  if 2 * (U.last zs) == total then
    putStrLn "0"
  else do
    let a = U.last zs
        b = U.head ws
    print $ minimum $ map abs [total - 2 * a, total - 2 * b]


Measured memory_bytes: 7804
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli n;
    cin >> n;
    vec(string) s(n);
    vi t(n);
    rep(i,n){
        cin >> s[i] >> t[i];
    }
    string x;
    cin >> x;
    lli ans=0;
    bool c = false;
    rep(i,n){
        if(s[i]==x){
            c = true;
            continue;
        }
        if(c){
            ans +=t[i];
        }

    }
    out(ans);
}

Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    
    
    ll H,W;
    cin >> H >> W;
    vector<vector<char>> masu(H,vector<char>(W));
    for(auto& vec:masu) for(auto& in:vec) cin >> in;
    
    
    for(int i = 0; i < H;i++){
        for(int j = 0; j < W;j++){
            if(masu[i][j] == '.') continue;
            
            int d[4] = {1,0,-1,0};
            int cnt = 0;
            for(int k = 0; k < 4;k++){
                int ni = i + d[k];
                int nj = j + d[k^1];
                if(ni < 0 || ni >= H || nj < 0 || nj >= W) continue;
                if(masu[ni][nj] == '#') cnt++;
            }
            if(cnt == 0) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int L = sc.nextInt();
		sc.close();
		int l = L;

		int a = 0;
		for (int i = 0; i < N; i++) {
			a += L;
			L++;
		}

		int min = 99999;
		int ans = 0;
		for (int i = 0; i < N; i++) {
			int b = a;
			b -= l;
			int c = Math.abs(a - b);
			if (min > c) {
				min = c;
				ans = l;
			}
			l++;
		}
		int ans2 = a - ans;
		System.out.println(ans2);
	}
}


Measured memory_bytes: 23380
/**************************
*                         *
*  Nothing Is Impossible  *
*                         *
**************************/
#include <algorithm>
#include <iostream>
#include <fstream>
#include <ctype.h>
#include <string>
#include <vector>
#include <thread>
#include <math.h>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <set>
#include <map>
#define GetRand(Min, Max) ((rand()%(int)(((Max) + 1)-(Min))) + (Min))
#define Rep(i, min, max) for(int i = min; i < max; ++i)
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef long double ld;
using namespace std;

void Solve(){
	ll n;	cin >> n;
	ll arr[n];
	Rep(i,0,n){
		cin >> arr[i];
	}
	ll last = arr[0];
	ll ans = 0;
	Rep(i,1,n){
		if(arr[i] < last){
			ans += last-arr[i];
			arr[i] += (last-arr[i]);
		}
		last = arr[i];
	}
	cout << ans << endl;
}

int main(){
	ios::sync_with_stdio(NULL);
	cin.tie(NULL); cout.tie(NULL);
	int t = 1;
	//int t;	cin >> t;
	while(t--) Solve();
	return 0;
}


Measured memory_bytes: 5104
#include<iostream>
#include<math.h>
#include<iomanip>
using namespace std;
int main()
{
  int n,k,i,j,score,c=0;
  double temp=1,prob=0,ans;
  cin>>n>>k;
  for(i=0;i<n;i++)
  {
    c=0;
    score=i+1;
    for(j=0;score<k;j++)
    {
      score=score*2;
      c++;
    }
    temp=pow(2,c);
    prob=prob+(1/temp);
  }
  ans=prob/n;
  cout<<setprecision(10)<<ans;
}


Measured memory_bytes: 256
from sys import setrecursionlimit as SRL, stdin

SRL(10 ** 7)
rd = stdin.readline
rrd = lambda: map(int, rd().strip().split())

n = int(input())
p = list(rrd())

bit = [0] * 100005


def add(x):
    while x <= n:
        bit[x] += 1
        x += x & -x


def sum(x):
    tot = 0

    while x:
        tot += bit[x]
        x -= x & -x
    return tot


def search(x):
    tot = 0
    if x < 0:
        return tot
    for i in range(20)[::-1]:
        if (1 << i) + tot <= n and bit[(1 << i) + tot] <= x:
            tot += 1 << i
            x -= bit[tot]
    return tot + 1


idx = [0] * 100005

for i in range(n):
    idx[p[i]] = i + 1

ans = 0
for i in range(n, 0, -1):

    j = sum(idx[i])
    l1 = search(j - 1)
    l2 = search(j - 2)
    r1 = search(j)
    r2 = search(j + 1)

    tt = (idx[i] - l1) * (r2 - r1) + (r1 - idx[i]) * (l1 - l2)
    ans += tt * i
    add(idx[i])

print(ans)


Measured memory_bytes: 55200
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
#define INF 200000000000
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}
bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}

const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};
int main() {
    ll H,W;
    cin>>H>>W;
    vector<vector<char>> G(H,vector<char>(W));
    ll cnt = 0;

    vector<vector<ll>> dist(H,vector<ll>(W,-1));
    queue<Pi> que;
    rep(i,H){
        rep(j,W){
            cin>>G[i][j];
            if(G[i][j] == '#'){
                dist[i][j] = 0;
                que.push(mp(i,j));
            }
        }
    }

    

    ll ans = 0;

    while(!que.empty()){
        Pi v =que.front();
        que.pop();

        rep(dir,4){
            ll ny = v.first + dy[dir];
            ll nx = v.second + dx[dir];

            if(!In_map(ny,nx,H,W)) continue;
            if(dist[ny][nx] != -1) continue;
            if(G[ny][nx] == '#') continue;
            dist[ny][nx] = dist[v.first][v.second]+1;
            que.push(mp(ny,nx));
            chmax(ans,dist[ny][nx]);
        }

    }


    cout<<ans<<endl;



    return 0;
    

}

Measured memory_bytes: 28412
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  int n;
  cin>>n;

  vector<ll> p(n);
  bool z=false;
  rep(i,n){
    cin>>p[i];
    if(p[i]==0) z=true;
  }

  if(z) {
    cout << 0 << endl;
    return 0;
  }

  ll ans=1;

  rep(i,n){
    if(p[i]>(ld)1000000000000000000/ans) {
      cout << -1 << endl;
      return 0;
    }
    else ans*=p[i];
  }

  cout << ans << endl;
}

Measured memory_bytes: 3952
implicit none
integer(8) :: i,j,k,n
 
read(5,*) n

do i = 1,int(3*n/4)
  do j = int(3*n/4), 3500
       if (4*i*j-N*i-N*j<=0) then
            continue
       else if (mod(N*i*j,4*i*j-N*i-N*j)==0) then
            goto 100
             endif
enddo
enddo
 
100 write(6,"(i0,1x,i0,1x,i0)") i,j,(N*i*j)/(4*i*j-N*i-N*j)

end


Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;

int main(void){
	int n;
	cin>>n;
	if(n==1)cout<<"Hello World"<<endl;
	else{
		int a,b;
		cin>>a>>b;
		cout<<a+b<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"container/list"
	"fmt"
)

type queue struct {
	list *list.List
}

type proc struct {
	name string
	time int
}

func (q *queue) enqueue(p proc) {
	q.list.PushBack(p)
}

func (q *queue) dequeue() proc {
	return q.list.Remove(q.list.Front()).(proc)
}

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

	q := queue{list: list.New()}
	for i := 0; i < n; i++ {
		var name string
		var time int
		fmt.Scan(&name, &time)
		q.enqueue(proc{name: name, time: time})
	}

	var sum int
	for 0 < q.list.Len() {
		v := q.dequeue()
		time := min(v.time, qt)
		v.time -= time
		sum += time
		if 0 < v.time {
			q.enqueue(v)
		} else {
			fmt.Printf("%s %d\n", v.name, sum)
		}
	}
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}



Measured memory_bytes: 9300
# 50
from collections import Counter
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


n = I()
if n % 2 != 0:
    print(0)
    exit()
ans = n // 10
i = 50
while i <= n:
    ans += n // i
    i *= 5
print(ans)


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

int main()
{
    int n, m, a[1000] = {}, b[1000] = {}, c[1000] = {};

    cin >> n >> m;
    for( int i = 0; i < n; i++ )
        cin >> a[i];
    
    int res = 0;
    for( int i = 0; i < m; i++ )
    {
        cin >> b[i];
        for( int j = 0; j < n; j++ )
        {
            if( a[j] <= b[i] )
            {
                c[j]++;
                if( c[res] < c[j] )
                    res = j;
                break;
            }
        }
    }

    cout << res + 1 << endl;

    return 0;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MX=100010, inf=2e9;
int a, b, c, x, y, ans;
int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	cin>>a>>b>>c>>x>>y;
	if(a+b>2*c){
		int t=min(x,y);
		x-=t, y-=t;
		ans+=2*c*t;
	}
	if(a>2*c){
		ans+=2*c*x, x=0;
	}
	if(b>2*c){
		ans+=2*c*y, y=0;
	}
	ans+=a*x+b*y;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int input;
            Int32.TryParse(Console.ReadLine(), out input);
            if (input > 81)
            {
                Console.WriteLine("No");
                return;
            }
            else
            {
                for (int i = 9; i > 0; i--)
                {
                    if (input % i == 0 && (input / i) <= i)
                    {
                        Console.WriteLine("Yes");
                        return;
                    }
                }
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
int main(){
    string S;
    cin>>S;
    int N=S.size();
    if(N%2==1){S.push_back('a');N++;}
    for(int i=0;i<N/2;i++){
        cout<<S[2*i];
    }
    puts("");
}

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

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n, k, c;
  cin >> n >> k >> c;
  string s;
  cin >> s;
  vector <ll> f(n, 0);
  vector <ll> b(n, 0);
  ll f_c = 0, b_c = k;
  rep(i, n) {
    if (s.at(i) == 'o') {
      f_c++;
      f.at(i) = f_c;
      i += c;
    }
  }
  rep(i, n) {
    if (s.at(n-1-i) == 'o') {
      b.at(n-1-i) = b_c;
      b_c--;
      i += c;
    }
  }
  rep(i, n) {
    if (f.at(i)==b.at(i) && f.at(i)) cout << i+1 << endl;
    if (f.at(i) == k) break;
  }
}

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

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    int n; cin>>n;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin>>a[i];
    sort(a.begin(), a.end());

    ll ans=0;
    if(n%2==1){
        ll MAX=0;
        ans+=a[n-1]-a[0];
        if(n/2<n-1-1) ans+=a[n-2]-a[0];
        for(int i=1; i<=n/2; i++){
            ans+=a[n-i]-a[i];
            if(n/2<n-i-2) ans+=a[n-i-2]-a[i];
        }
        MAX=max(MAX, ans);
        ans=0;
        ans+=a[n-1]-a[0];
        if(n/2-1<n-1-1) ans+=a[n-2]-a[0];
        for(int i=1; i<=n/2-1; i++){
            ans+=a[n-i]-a[i];
            if(n/2-1<n-i-2) ans+=a[n-i-2]-a[i];
        }
        MAX=max(MAX, ans);
        cout << MAX << endl;
    }
    else{
        ans+=a[n-1]-a[0];
        if(n/2-1<n-1-1) ans+=a[n-2]-a[0];
        for(int i=1; i<=n/2-1; i++){
            ans+=a[n-i]-a[i];
            if(n/2-1<n-i-2) ans+=a[n-i-2]-a[i];
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define pi pair<ll,ll>
#define ss second
#define ll long long
#define MAXN 100005
using namespace std;
using namespace __gnu_pbds;  

ll n,cnt;

void solve()
{
	cin>>n;
	for(ll i=1;i<=n;i++)
	{
		if(!(i%3==0 || i%5==0)) cnt+=i; 
	}
	cout<<cnt<<endl;
}

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


Measured memory_bytes: 3608
// C++ 14
#include <iostream>
#include <string>
#include <cstring> // memset
#include <vector>
#include <list>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <math.h>

#define ll long long
#define Int ll
#define loop(__x, __start, __end) for(Int __x = __start; __x < __end; __x++)
#define loopdown(__x, __start, __end) for(Int __x = __start; __x > __end; __x--)
#define rep(__n) for(Int __x = 0; __x < __n; __x++)
#define span(__a,__x,__y) __a.begin()+__x,__a.begin()+__y
#define span_all(__a) __a.begin(),__a.end()
#define len(__x) (__x.size())
#define last(__x) (__x[__x.size()-1])

using namespace std;

struct Point {
  Int x, y;
  Point(Int x, Int y): x(x), y(y) {}
  Point(): x(0), y(0) {}

  bool operator< (const Point &p1) {
    return x < p1.x && y < p1.y;
  }
};
ostream & operator << (ostream & out, Point const & v) {
  out << "Point(" << v.x << ", " << v.y << ')';
  return out;
}

istream & operator >> (istream & in, Point & v) {
  Int x, y;
  in >> x; in >> y; v.x = x; v.y = y;
  return in;
}

// Geometry

#define EPS 0.0000000001

class Vector2 {
public:
  double x, y;
  
  Vector2(double x = 0, double y = 0): x(x), y(y) {}
  
  Vector2 operator + (Vector2 v) { return Vector2(x + v.x, y + v.y); }
  Vector2 operator - (Vector2 v) { return Vector2(x - v.x, y - v.y); }
  Vector2 operator * (double k) { return Vector2(x * k, y * k); }
  Vector2 operator / (double k) { return Vector2(x / k, y / k); }
  
  double length() { return sqrt(norm()); }
  double norm() { return x * x + y * y; }
  double dot (Vector2 v) { return x * v.x + y * v.y; }
  double cross (Vector2 v) { return x * v.y - y * v.x; }

  bool operator < (const Vector2 &v) const {
    return x != v.x ? x < v.x : y < v.y;
  }

  bool operator == (const Vector2 &v) const {
    return fabs(x - v.x) < EPS && fabs(y - v.y) < EPS;
  }
};

ostream & operator << (ostream & out, Vector2 const & v) { 
  out<< "Vector2(" << v.x << ", " << v.y << ')';
  return out;
}

istream & operator >> (istream & in, Vector2 & v) { 
  double x, y;
  in >> x;
  in >> y;
  v.x = x;
  v.y = y;
  return in;
}

Int D;
vector<int> N;
#define MOD 1000000007


void input() {
  string n;
  cin >> n >> D;

  for (auto x: n) {
    N.push_back(x - '0');
  }
}

// (整数の最大桁数, 次の数字に制限があるか, 和)
int dp[10002][2][101];


Int solveRec(vector<int> &digits, int k = 0, bool tight = true, int sum = 0) {
  // 整数文字列の最後まで到達
  if (k == digits.size()) {
    return sum % D == 0;
  }
  Int x = digits.at(k);
  Int r = tight ? x : 9; // その桁において最大の場合は次の桁で制限がかかる

  Int res = dp[k][tight][sum];
  if (~res) return res; // DP
  res = 0;
  for (Int i=0; i<=r; i++) {
    res += solveRec(digits, k + 1, tight && i == r, (sum + i) % D);
    res %= MOD;
  }
  dp[k][tight][sum] = res;
  return res;
}


void solve() {
  memset(dp, -1, sizeof(dp));
  Int total = solveRec(N);
  total = (total - 1) % MOD; // remove 0
  if (total < 0) total += MOD;
  cout << total << endl;
}


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


Measured memory_bytes: 9088
# 問題文の意味はわからんけど（ちょうど1回、ちょうど2回割り切れる？？？？は？？？？？？？？）サンプルを適当に読む
d, n = map(int, input().split())
if d == 0:
    if n == 100:
        print(101)
    else:
        print(n)
elif d == 1:
    if n == 100:
        print(101 * 100)
    else:
        print(n * 100)
else:
    if n == 100:
        print(101 * 10000)
    else:
        print(n * 10000)



Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

//gcd,lcm,べき,二進展開
//組み合わせ、mod計算
//最短路問題、bit、union find

///////////////////////////




int main() {

	ll N, A, B;
	cin >> N >> A >> B;

	if ((B - A) % 2 == 0) { cout << (B - A) / 2; }
	else {
		ll ans1 = A - 1 + (B - A + 1) / 2;
		ll ans2 = N - B + (B - A + 1) / 2;
		cout << min(ans1, ans2);
	}

	
	system("PAUSE");


}

Measured memory_bytes: 504
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string s1 = Console.ReadLine();
            string p1 = Console.ReadLine();
            string S1 = s1 + s1;
            int num1 = S1.Length;
            int num2 = p1.Length;
            char[] S2 = S1.ToCharArray();
            char[] p2 = p1.ToCharArray();
            int TFflg;
            int YNflg = 0;
            for (int i1 = 0; i1 < num1 - num2; i1++)
            {
                TFflg = 0;
                for (int i2 = 0; i2 < num2; i2++)
                {
                    if (S2[i1 + i2] == p2[i2])
                    {
                        TFflg = TFflg + 1;
                    }
                }
                if(TFflg==num2)
                {
                    YNflg = 1;
                }
            }

            if(YNflg==1)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }


        }
    }
}



Measured memory_bytes: 17836
#include <bits/stdc++.h>
#define ri register
#define int long long
using namespace std; const int N=5010;
inline int read()
{
    int s=0,w=1; char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48),ch=getchar(); return s*w;
}
int n,A,B,val[N];
int dp[N][N],p[N];
signed main()
{
	n=read(), A=read(), B=read();
	for(ri int i=1;i<=n;i++) {int x=read(); p[x]=i; }
	for(ri int i=1;i<=n;i++) for(ri int j=0;j<=n;j++) dp[i][j]=LONG_LONG_MAX/2;
	for(ri int i=1;i<=n;i++)
	{
		for(ri int j=0;j<=n;j++)
		{
			if(p[i]==j) dp[i][j]=min(dp[i-1][j-1],dp[i][j]);
			dp[i][j]=min(dp[i][j],dp[i-1][j]+(j<p[i]?B:A));
		}
		for(ri int j=1;j<=n;j++) dp[i][j]=min(dp[i][j],dp[i][j-1]);
	}
	printf("%lld\n",dp[n][n]);
    return 0;
}

Measured memory_bytes: 195968
import java.util.Arrays;
import java.util.Scanner;

class Key{
	int a, b;
	int[] c;

	public Key(int a, int b, int[] c) {
		this.a = a;
		this.b = b;
		this.c = c;
	}
}

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), M = sc.nextInt();
		Key[] keys = new Key[M];
		for(int i = 0; i < M; i++) {
			int a = sc.nextInt(), b = sc.nextInt();
			int[] c = new int[b];
			for(int j = 0; j < b; j++) c[j] = sc.nextInt() - 1;
			keys[i] = new Key(a, b, c);
		}
		int[][] dp = new int[(1 << N)][M + 1];
		for(int i = 1; i < (1 << N); i++) Arrays.fill(dp[i], Integer.MAX_VALUE);
		Arrays.fill(dp[0], 0);


		for(int i = 0; i < (1 << N); i++) {
			for(int j = 0; j < M; j++) {
				if(dp[i][j] == Integer.MAX_VALUE) {
					if(j != 0) dp[i][j] = dp[i][j - 1];
				}
				else {
					// in i, use j
					int j_subset = 0;
					for(int elem : keys[j].c) j_subset += (1 << elem);
					dp[i | j_subset][j + 1] = Math.min(Math.min(dp[i | j_subset][j + 1], dp[i | j_subset][j]) , dp[i][j] + keys[j].a);
					dp[i][j + 1] = Math.min(dp[i][j], dp[i][j + 1]);
				}
			}
		}
		System.out.println(dp[(1 << N) - 1][M] == Integer.MAX_VALUE ? -1 : dp[(1 << N) - 1][M]);
	}
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const long long mod = 1e9 + 7;

int stoi(const char c) {
  switch (c) {
    case '0':
      return 0;
    case '1':
      return 1;
    case '2':
      return 2;
    case '3':
      return 3;
    case '4':
      return 4;
    case '5':
      return 5;
    case '6':
      return 6;
    case '7':
      return 7;
    case '8':
      return 8;
    case '9':
      return 9;
    default:
      return -1;
  }
}

int main() {
  ll n, k, ans = 0;
  cin >> n >> k;
  vector<ll> a(n), ansl(n, 0), ansr(n, 0);
  rep(i, n) cin >> a[i];
  rep(i, n) {
    for (int l = 0; l < i; l++) {
      if (a[i] < a[l]) {
        ansl[i]++;
      }
    }
    for (int r = i + 1; r < n; r++) {
      if (a[i] < a[r]) {
        ansr[i]++;
      }
    }
  }
  ll kl = (((k + 1) * k) / 2) % mod, kr = (((k - 1) * k) / 2) % mod;
  rep(i, n) { ans += (kl * ansl[i]) % mod + (kr * ansr[i]) % mod; }
  cout << ans % mod;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	int n,h;
	cin>>n>>h;
	int a[n],b[n];
	ll x = 0;int c=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i]>>b[i];
		
	}
	sort(a,a+n);
	sort(b,b+n,greater<int>());
	for(int i=0;i<n;i++)
		if(b[i]>a[n-1]){
			x += b[i];
			c++;
			if(x>=h)
			{
				cout<<c<<"\n";
				return 0;
			}
		}

	c += (h-x+a[n-1]-1)/a[n-1];
	cout<<c<<"\n";
}

Measured memory_bytes: 4420
i = gets.to_i
 ary = gets.split(" ").map(&:to_i)
 a = 0
 b = ary.inject(:+)
 goal = 100000000
(0..i-2).each do |n|
      a += ary[n]
      b -= ary[n]
      k = a-b
      if goal > k.abs
          goal = k.abs
      end
end
puts goal

Measured memory_bytes: 3836
import java.util.Scanner;

public class Main {
   
    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int i,x;
        for(i=1;i<=10000;i++){
        	x=scan.nextInt();
        	if(x==0)break;
        	System.out.println("Case "+ i +": "+ x);
        }
    }
}

Measured memory_bytes: 42116
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned ll
#define ioi exit(0);
 
#define f first
#define s second
 
#define inf (int)1e9 + 7
 
#define NFS ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);
 
#define mp(x,y) make_pair(x,y)
 
#define lb(x) lower_bound(x)
#define ub(x) upper_bound(x)
 
#define pb push_back
#define ppb pop_back
 
#define bitcoin __builtin_popcount
 
#define endl "\n"
 
#define in(x) insert(x)
 
#define sz(x) (int)x.size()
 
#define all(x) x.begin(),x.end()
 
#define pw2(x) (1ll<<x) //2^x
 
#define forit(it,v) for (typeof(v.begin()) it = v.begin(); it != v.end(); ++it)
 
#define sqr(x) ((x) * 1ll * (x))
 
#define UpdateRandom srand (time(NULL));
 
using namespace std;
 
const int N = (int)3e3 + 7, MOD = (int)1e9 + 7;

string s,t;

string dp[4][N];

int main(){
		
	NFS

	cin >> s >> t;

	for(int i=1;i<=sz(s);i++){
		for(int j=1;j<=sz(t);j++){
			if(sz(dp[2][j-1])>sz(dp[2][j]))dp[2][j]=dp[2][j-1];
			if(sz(dp[2-1][j])>sz(dp[2][j]))dp[2][j]=dp[2-1][j];
			if(sz(dp[2-1][j-1])>sz(dp[2][j]))dp[2][j]=dp[2-1][j-1];
			if(s[i-1]==t[j-1]){
				if(sz(dp[2-1][j-1])+1>sz(dp[2][j]))dp[2][j]=dp[2-1][j-1]+s[i-1];
			}
		}
		for(int j=1;j<=sz(t);j++)dp[1][j]=dp[2][j],dp[2][j].clear();
	}
	
	cout << dp[1][sz(t)] << endl;
	
	ioi
}

Measured memory_bytes: 7936
/*高橋君は Kの倍数と 7が好きです。
		7,77,777,…
 という数列の中に初めて
Kの倍数が登場するのは何項目ですか？
存在しない場合は代わりに -1 を出力してください。*/

#include <stdio.h>

int main(void){
	int X,i=0,k=0;
	scanf("%d",&X);
	if((X%10)%2==0||X%10==5){
		printf("-1");
		return 0;
	}
	int x=9*X;
	if(X%7==0)x=9*X/7;
	//printf("%d\n",x);
	while(k!=1){
		if(i==0){
			k=10%x;
			i++;
			//printf("%d\n",k);
		}else{
			i++;
			k=k*10;
			k=k%x;
			//printf("%d : %d\n",i,k);
		}
	}
	printf("%d",i);
	return 0;
}

Measured memory_bytes: 1736
using System;
using System.Linq;

namespace abc051_d
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[,] d = new int[x[0], x[0]];
            int[,] edge = new int[x[1], 3];
            for (int i = 0; i < x[0]; i++)
            {
                for (int j = 0; j < x[0]; j++)
                {
                    if (i == j) continue;
                    d[i, j] = 10000000;
                }
            }
            for (int i = 0; i < x[1]; i++)
            {
                int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
                a[0]--; a[1]--;
                d[a[0], a[1]] = a[2]; d[a[1], a[0]] = a[2];
                for (int j = 0; j < 3; j++) edge[i, j] = a[j];
            }
            for (int k = 0; k < x[0]; k++)
                for (int i = 0; i < x[0]; i++)
                    for (int j = 0; j < x[0]; j++)
                        d[i, j] = Math.Min(d[i, j], d[i, k] + d[k, j]);
            int ret = x[1];
            for (int i = 0; i < x[1]; i++)
            {
                bool flag = false;
                for (int j = 0; j < x[0] && !flag; j++)
                {
                    for (int k = 0; k < x[0] && !flag; k++)
                    {
                        if (j != edge[i, 0] && k != edge[i, 1])
                        {
                            if (d[j, k] == d[j, edge[i, 1]] + edge[i, 2] + d[edge[i, 0], k])
                                flag = true;
                        }
                        if (j != edge[i, 1] && k != edge[i, 0])
                        {
                            if (d[j, k] == d[j, edge[i, 0]] + edge[i, 2] + d[edge[i, 1], k])
                                flag = true;
                        }
                    }
                }
                if (flag) ret--;
            }
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 13372
#include<stdio.h>
int main(void){
    int W,H,x,y,r;
    scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
    if (x+r > W || y+r > H || x < r || y < r) printf("No\n");
    else printf("Yes\n");
    return 0;
}


Measured memory_bytes: 2112
#include <limits>
#include <queue>
#include <vector>

template<typename T, typename I, typename J, typename F, typename G, typename Z, typename INF>
std::vector<T> dijkstra(I begin_cnct, I end_cnct, J begin_cost, int s, F &&f, G &&g, Z &&zero, INF &&inf) {
    int n = end_cnct - begin_cnct;
    std::vector<T> ret(n, inf());
    using P = std::pair<T, int>;
    auto c = [&](P a, P b) -> bool { return g(a.first, b.first); };
    std::priority_queue<P, std::vector<P>, decltype(c)> pq(c);
    ret[s] = zero();
    pq.push({ret[s], s});
    while (!pq.empty()) {
        P p = pq.top();
        pq.pop();
        int v = p.second;
        if (g(p.first, ret[v])) { continue; }
        for (int i = 0; i < (begin_cnct + v)->size(); i++) {
            int u = (*(begin_cnct + v))[i];
            T dist_u = f(ret[v], (*(begin_cost + v))[i]);
            if (g(ret[u], dist_u)) { ret[u] = dist_u, pq.push({dist_u, u}); }
        }
    }
    return ret;
}

template<typename T, typename I, typename J>
std::vector<T> basic_dijkstra(I begin_cnct, I end_cnct, J begin_cost, int s) {
    auto zero = []() -> T { return 0; };
    auto inf = []() -> T { return std::numeric_limits<T>::max(); };
    auto f = [&](T a, T b) -> T { return a == inf() ? inf() : a + b; };
    auto g = [](T a, T b) -> bool { return a > b; };
    return dijkstra<T>(begin_cnct, end_cnct, begin_cost, s, f, g, zero, inf);
}

#include<bits/stdc++.h>
using namespace std;

int main() {
    int V, E, r;
    cin >> V >> E >> r;
    vector<int> cnct[110000], cost[110000];
    for (int i = 0; i < E; i++) {
        int s, t, d;
        cin >> s >> t >> d;
        cnct[s].push_back(t), cost[s].push_back(d);
    }
    vector<int> dist = basic_dijkstra<int>(cnct, cnct + V, cost, r);
    for (int i = 0; i < V; i++) { cout << (dist[i] == INT_MAX ? "INF" : to_string(dist[i])) << endl; }
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, M;
    cin >> N >> M;
    string S;
    cin >> S;
    reverse(S.begin(), S.end());
    vector<ll> ans;
    ll i = 0;
    while (i < N) {
        ll target = -1;
        rrep(j, M, 1) {
            if (S[i + j] == '0') {
                target = j;
                break;
            }
        }
        if (target != -1) {
            i += target;
            ans.push_back(target);
        }else {
            cout << -1 << '\n';
            return;
        }
    }
    reverse(ans.begin(), ans.end());
    rep(i, ans.size()) cout << ans[i] << ' ';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 1480
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

// 二部グラフ判定

bool dfs(Graph &G, vector<int> &color, int x) {
  
  for (int nx : G[x]) {
    if (color[nx] == color[x]) return false;
    if (color[nx] == -1) {
      color[nx] = 1 - color[x];
      if (!dfs(G, color, nx)) return false;
    }
  }
  
  return true;
}

int main () {
  
  // 入力
  
  int N;
  cin >> N;
  
  Graph G(N);
  
  for(int i = 0; i < N; i++) {
    
    string S;
    cin >> S;
    
    for(int j = i + 1; j < N; j++) {
      if (S[j] == '1') {
        G[i].push_back(j);
        G[j].push_back(i);
      }
    }
    
  }
  
  // 頂点の二色塗分け可能か
  
  vector<int> color(N, -1);
  color[0] = 0;
  
  if (!dfs(G, color, 0)) {
    cout << -1 << endl;
    return 0;
  }
  
  // 最短距離の最大値
  
  int MAX = 0;
  
  for (int x = 0; x < N - 1; x++) {
    
    vector<int> dist(N, -1);
    queue<int> que;
    
    dist[x] = 0;
    que.push(x);
    
    while (!que.empty()) {
      
      int v = que.front();
      que.pop();
      
      for (int nv : G[v]) {
        if(dist[nv] != -1) continue;
        dist[nv] = dist[v] + 1;
        que.push(nv);
      }
      
    }
    
    for (int y = x + 1; y < N; y++) {
      if (MAX <= dist[y]) MAX = dist[y];
    }
    
  }
  
  // 出力
  cout << MAX + 1 << endl;
  return 0;
  
}

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

using namespace std;

int main(){
    int n, m, x, y;
    cin >> n >> m >> x >> y;
    int x_max=x;
    for(int i=0; i<n; ++i){
        int xi;
        cin >> xi;
        x_max=max(x_max, xi);
    }
    int y_min=y;
    for(int i=0; i<m; ++i){
        int yi;
        cin >> yi;
        y_min=min(y_min, yi);
    }
    cout << (x_max < y_min ? "No War" : "War") << endl;
    return 0;
}


Measured memory_bytes: 256