akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <array>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <cctype>
#include <map>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <queue>


#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long

using namespace std;

bool is_integer( float x ){
    return floor(x)==x;
}

bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

//yakusuu rekkyo
vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // push its partner
            if (N/i != i) res.push_back(N/i);
        }
    }

    sort(res.begin(), res.end());
    return res;
}


vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // exponential

        // divide as much as you can
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // push the result
        res.push_back({a, ex});
    }

    // last num (if the lasting n is prime number and not 1)
    if (N != 1) res.push_back({N, 1});
    return res;
}



int main() {
    string s;
    ll k;
    int next=0;
    int one=0;
    cin >> s >> k;
    rep(i,s.size()){
        if(s[i] == '1'){
            one ++;
        }else{
            next = (int)(s[i]-'0');
            break;
        }
    }

    if(one >= k) cout << 1;
    else{
        if(next == 0) cout << 1;
        else{
            cout << next;
        }
    }

    return 0;
}











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

#define int long long int

int32_t main()
{
  int r,d,x;
  cin>>r>>d>>x;

  int ans=0;

  for(int i=1;i<=10;++i)
  {
    ans = x*r -d;
    cout<<ans<<endl;
    x=ans;
  }

  

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = LONG_LONG_MAX / 2;
const ll mod = 1000000000 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> v(H, vector<char>(W));

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      char c;
      cin >> c;
      v[i][j] = c;
    }
  }

  vector<bool> row(H, false), col(W, false);
  for (int i = 0; i < H; i++) {
    bool flag = true;
    for (int j = 0; j < W; j++) {
      if (v[i][j] != '.') {
        flag = false;
        break;
      }
    }
    if (flag) row[i] = true;
  }

  for (int j = 0; j < W; j++) {
    bool flag = true;
    for (int i = 0; i < H; i++) {
      if (v[i][j] != '.') {
        flag = false;
        break;
      }
    }
    if (flag) col[j] = true;
  }

  for (int i = 0; i < H; i++) {
    if (row[i]) continue;
    for (int j = 0; j < W; j++) {
      if (col[j]) continue;
      cout << v[i][j];
    }
    cout << endl;
  }
}


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 2e5+23;

int a[N], b[N];

void solve() {
  int n, k; scanf("%d%d", &n, &k);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a+i);
  }
  for (int i = 0; i < k; ++i) {
    for (int j = 0; j < n; ++j) {
      int l = max(0, j-a[j]),
          r = min(n-1, j+a[j]);
      ++b[l];
      if (r+1 < n) --b[r+1];
    }
    a[0] = b[0];
    bool allsame = true;
    for (int j = 1; j < n; ++j) {
      a[j] = (b[j] += b[j-1]);
      b[j-1] = 0;
      if (a[j] != a[j-1] || a[j] != n) allsame = false;
    }
    if (allsame) break;
    b[n-1] = 0;
  }
  for (int i = 0; i < n; ++i) printf("%d ", a[i]);
}

int main() {
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 5344
#include<iostream>
#include<stack>
using namespace std;
#define WHITE 0
#define BLACK 1
int main()
{
  int n,i,color,num;
  stack<int>table;
  while(cin>>n,n){
    while(table.size())table.pop();
    for(i=1;i<=n;i++){
      cin>>color;
      if(table.empty()){
	table.push(color==WHITE?1:-1);
      }else if(i&1){
	num=table.top();
	if(num>0&&color==WHITE){num++;table.pop();}
	else if(num<0&&color==BLACK){num--;table.pop();}
	else num=(color==WHITE?1:-1);
	table.push(num);
      }else{
	num=table.top();
	table.pop();
	if(num>0&&color==WHITE)num++;
	else if(num<0&&color==BLACK)num--;
	else{
	  if(table.empty()){
	    num=-num+(color==WHITE?1:-1);
	  }else{
	    num=-num+(color==WHITE?1:-1)+table.top();
	    table.pop();
	  }
	}
	table.push(num);
      }
    }
    num=0;
    while(table.size()){
      if(table.top()>0)num+=table.top();
      table.pop();
    }
    cout<<num<<endl;
  }
}

Measured memory_bytes: 0
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import deque 
INF = 100000
dir = ((1, 0), (-1, 0), (0, 1), (0, -1)) 
def main():
    H, W = map(int, readline().split())
    maze = []
    for _ in range(H):
        s = readline().rstrip().decode()
        maze.append(s) 
    
    
    def bfs(si, sj):
        dq = deque()
        dq.append((si, sj))        
        dist = [[INF for _ in range(W)] for _ in range(H)]
        dist[si][sj] = 0
        while len(dq)>0:
            i, j = dq.popleft()
            for di, dj in dir:
                nxi = i+di
                nxj = j+dj
                if (nxi<0) or (nxj<0) or (nxi>=H) or (nxj>=W):
                    continue
                if maze[nxi][nxj] == '#':
                    continue
                if dist[nxi][nxj] != INF:
                    continue
                dist[nxi][nxj] = dist[i][j]+1
                dq.append((nxi, nxj))
        res = 0
        for i in range(H):
            for j in range(W):
                if dist[i][j] == INF:
                    continue
                res = max(dist[i][j], res)        
        return res

    ans = 0
    for si in range(H):
        for sj in range(W):
            if maze[si][sj] == '#':
                continue
            ans = max(bfs(si, sj), ans)

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3440
#include <bits/stdc++.h>
using namespace std;
long long int a[3004];
long long int dp[3004][3004];

long long int calculate(int i,int j)
{
	if(i==j)
	{
		dp[i][j]=a[i];
		return dp[i][j];
	}
	if(dp[i][j]!=-1)
	{
		return dp[i][j];
	}
	dp[i][j]=max(a[j]-calculate(i,j-1) , a[i]-calculate(i+1,j));
	return dp[i][j];
}
int main(void)
{
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	for (int i = 0; i <=n; ++i)
	{
		for (int j = 0; j <=n; ++j)
		{
			dp[i][j]=-1;
		}
	}
	printf("%lld\n",calculate(0,n-1));

}

Measured memory_bytes: 70912
# coding: utf-8

import sys

n, k = [int(x) for x in input().split()]
ss = [int(x) for x in input()]

zero_array = []
one_array = []
curr_num = ss[0]
flag = 0

if curr_num == 0:
    zero_array.append(0)
else:
    one_array.append(0)
    flag = 1

for i in ss:
    if curr_num == i:
        if i == 0:
            zero_array[-1] += 1
        else:
            one_array[-1] += 1
    else:
        curr_num = i
        if i == 0:
            zero_array.append(1)
        else:
            one_array.append(1)

# print("zero_array", zero_array)
# print("one_array", one_array)
# print("flag", flag)

if k >= len(zero_array):
    print(sum(zero_array) + sum(one_array))
    sys.exit()
else:
    t = 0
    tmp = sum(zero_array[t: t+k]) + sum(one_array[t: t+k+flag])
    max_count = tmp
    # print("outer_tmp", tmp)
    # print()
    while t + k + flag <= len(one_array) and t + k < len(zero_array):
        # print("t", t)
        tmp += zero_array[t+k] - zero_array[t]
        if t+k+flag < len(one_array):
            tmp += one_array[t+k+flag]
            if not (t == 0 and flag == 0):
                if t == 0:
                    pass
                    # print("yeh")
                tmp -= one_array[t+flag-1]
        elif not (t == 0 and flag == 0):
            tmp -= one_array[t+flag-1]
        # print("tmp", tmp)
        if tmp > max_count:
            max_count = tmp
            # print(t, max_count)
        t += 1

    print(max_count)
# print(zero_array)
# print(one_array)

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

int main(){
	ll n, d;
	cin >> n >> d;
	vector<ll> x(n), y(n);
	ll cnt = 0;
	rep(i, n) {
		cin >> x[i] >>y[i];
		if (d*d >= x[i]*x[i] + y[i]*y[i]) {
			cnt++;
		}
	}
  cout << cnt << endl;
}


Measured memory_bytes: 6360
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<cmath>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define pb push_back
using namespace std;
const int INF = 1e9;
typedef long long ll;

int main(){
  double n,m;
  cin >> n >> m;
  double sum = 0;
  double t = 1;
  while(1){
    double r = pow(2,-1*m);
    sum += (1900*m+100*(n-m))*t*pow((pow(2,m)-1)/pow(2,m),t-1)*r;
    //cout << sum << endl;
    t++;
    if(t == 1000 && n > 2)
      break;
    if(t == 20 && n <= 2)
      break;
  }
  
  ll s = sum;
  if(sum > s){
    s++;
    //cout << "Yes" << endl;
  }
  cout << s << endl;
  return 0;
}


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

int main()
{

	int d;
	
	while (cin >> d)
	{
		int z = 0;
		for (int x = 0; x < 600; x += d)
		{
			z += x * x * d;
		}
		cout << z << endl;
	}
	return 0;
}


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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

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

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

LL modinv(LL a) {
    LL b = MOD, u = 1, v = 0;
    while (b) {
        LL t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= MOD;
    if (u < 0) u += MOD;
    return u;
}

LL moddev(LL a, LL b){
	return a * modinv(b) % MOD;
}

void Main()
{
    int n,l;
    cin>>n>>l;
    int result = 0;
    
    REP(i,n){
        result += l+i;
    }
    if(l>=0){
        cout << result - l << endl;
    }
    else{
        cout << result - min(l+n-1,0) << endl;
    }

	return;
}

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

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
int main() {
	int a, b, s, n;
	while (~scanf("%d %d %d", &a, &b, &n)) {
		s = 0, a %= b;
		while (n--) {
			a *= 10;
			s += (a / b) % 10;
			a %= b;
		}
		printf("%d\n", s);
	}
	return 0;
}

Measured memory_bytes: 592
n=int(input())
a=[list(map(int,input().split()))for i in range(n)]
t=[0]*(1<<n)
for i in range(1,1<<n):
    p=i&(i-1)
    g=sum([sum([a[j][h]for h in range(n) if 1<<h&i])for j in range(n)if 1<<j&i])
    while p:
        g=max(g,t[p]+t[i^p])
        p=(p-1)&i
    t[i]=g
print(t[-1]//2)

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

int main(void)
{
    string S;
    cin >> S;
    if (S[0] == S[1] && S[2] == S[3] && S[0] != S[2] || 
        S[0] == S[2] && S[1] == S[3] && S[0] != S[1] ||
        S[0] == S[3] && S[1] == S[2] && S[0] != S[1]) {
            cout << "Yes" << endl;
            return 0;
        }
    
    cout << "No" << endl;
}

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

using namespace std;

int main()
{
	int n;
	long a[110];

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

	long max = 0, min = 10000000000;
	for(int i = 0; i < n; i++) {
		max = (a[i] > max) ? a[i] : max;
		min = (a[i] < min) ? a[i] : min;
	}
	cout << max - min << endl; 
	return 0;
}


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

const int INF = 2e9;



int main(){
    int n;
    cin >> n;
    vector<int> t(n+1),x(n+1),y(n+1);
    rep(i,n) cin >> t[i+1] >> x[i+1] >> y[i+1];
    bool can = true;
    rep(i,n){
        int dt = t[i+1] - t[i];
        int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
        if(dt < dist) can = false;
        if(dist % 2 != dt % 2) can = false;
    }
    if(can) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 4228
use proconio::input;
use std::cmp::min;
fn main() {
    input! {
        l: usize,
        r: usize
    }

    if 2019 < r - l {
        println!("0");
        return;
    }

    let mut res = std::usize::MAX;
    for i in l..=r {
        for j in i + 1..=r {
            let im = i % 2019;
            let jm = j % 2019;
            res = min(res, (im * jm) % 2019);
        }
    }
    println!("{}", res);
}


Measured memory_bytes: 2136
#include<iostream>
#include<vector>
#include<cmath>

using namespace std;


int main() {
    string s;
    cin >> s;
    int si = s.length();
    vector <int> hint;
    vector <int> hint2;
    vector <int> ans;
    int l = 0, r = 0;
    for (int i = 0; i < si; i++) {
        if (i > 0) {
            if (s[i] == 'L' && s[i - 1] == 'R') {
                hint.push_back(r);
                r = 0;
            }
            else if (s[i] == 'R' && s[i - 1] == 'L') {
                hint.push_back(l);
                l = 0;
            }
        }
        if (s[i] == 'R') {
            r++;
        }
        if (s[i] == 'L') {
            l++;
        }
        if (i == si - 1) {
            hint.push_back(l);
        }
    }

    for (int i = 0; i < si; i++) {
        ans.push_back(0);
    }

    
    for (int i = 0; i < hint.size() / 2; i++) {
        r = 0, l = 0;
        r += hint[i * 2] / 2;
        l += hint[i * 2] - hint[i * 2] / 2;
        l += hint[i * 2 + 1] / 2;
        r += hint[i * 2 + 1] - hint[i * 2 + 1] / 2;
        hint2.push_back(l);
        hint2.push_back(r);
    }

    int basyo;
    for (int i = 0; i < hint.size() / 2; i++) {
        basyo = 0;
        for (int j = 0; j <= i * 2; j++) {
            basyo += hint[j];
        }
        ans[basyo-1] = hint2[i * 2];
        ans[basyo] = hint2[i * 2 + 1];
    }

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

    return 0;
}

Measured memory_bytes: 1976
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
double pi = 3.14159265359;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int n;
double dp[310][310][310];

double rec (int i, int j, int k) {
    if (dp[i][j][k] >= 0) return dp[i][j][k];
    if (i == 0 && j == 0 && k == 0) return 0.0;

    double res = 0.0;
    if (i > 0) res += rec (i - 1, j, k) * i;
    if (j > 0) res += rec (i + 1, j - 1, k) * j;
    if (k > 0) res += rec (i, j + 1, k - 1) * k;
    res += (double)n;
    res *= 1.0 / (double)(i + j + k);
    return dp[i][j][k] = res;
}

int main() {
    cin >> n;
    int n1 = 0, n2 = 0, n3 = 0;
    double a[n];
    rep (i, 0, n) {
        cin >> a[i];
        if (a[i] == 1) n1++;
        else if (a[i] == 2)
            n2++;
        else
            n3++;
    }
    rep (i, 0, 310) rep (j, 0, 310) rep (k, 0, 310) dp[i][j][k] = -1;

    cout << fixed << setprecision (10) << rec (n1, n2, n3) << "\n";
}


Measured memory_bytes: 233088
#include <stdio.h>

int main(void){
  	int data[200];
  	int max=0;
    int result=0;
    int i=0;
  	int j=0;
  	scanf("%d",&max);
  	for(i=0;i<max;i++)
      scanf("%d",&data[i]);
  	i=0;
  	for(;i==0;){
    	for(j=0;j<max;j++){
    		if(data[j]%2!=0){
              i=1;
          	  break;
            }
          	data[j]/=2;
            
    	}
      result++;
    }
  	printf("%d",result-1);
 	return 0; 
}

Measured memory_bytes: 1708
#include <queue>
#include <iostream>
#include <string>
using namespace std;

int x;
string order;
int num;

int main() {
  priority_queue<int> Q; //int型を格納するキュー
  while (cin >> order){
    if (order == "insert"){
	  cin >> num;
	  Q.push(num);
	  }
	else if (order == "extract"){
	  int n = Q.top();
	  Q.pop();
	  cout << n << endl;
	  }
	else if (order == "end") break;
	  }
}
  

Measured memory_bytes: 6504
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define nl cout<<'\n'
#define sor(x) sort(x.begin(),x.end())
#define rev(v) reverse(v.begin(),v.end())
#define llmax 100000000000000000
#define deb(x) cout<<"value here is "<<x<<"\n"
#define pll pair<ll,ll>
#define vll vector <ll>
#define rub cout<<"ohlala"<<'\n';
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b;
    cin>>a>>b;
    ll c=0;
    cout<<max(c,(a-2*b));
    
    
}

Measured memory_bytes: 256
<?php
// 問題URL
// 
$n = fgets(STDIN);
$t = explode(' ', fgets(STDIN));
$count = fgets(STDIN);
$drink = array();

for ($i = 0; $i < $count; $i++) {
	$drink[] = fgets(STDIN);
}

for ($i = 0; $i < (int)$count; $i++) {
	$tmp = explode(' ', $drink[$i]);
	$out = 0;
	for ($j = 0; $j < $n; $j++) {
		if ((int)$tmp[0] - 1 == $j) {
			$out += (int)$tmp[1];
		} else {
			$out += (int)$t[$j];
		}
	}
	print (string)$out . "\n";
}


// print $out;

Measured memory_bytes: 3828
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

const int maxn = 2000;

int n, diameter;
vector<int> adj[maxn];

int dist[maxn];

int solve(int x, int y, int limit)
{
    queue<int> Q;
    memset(dist, -1, sizeof(dist));
    dist[x] = dist[y] = 0;
    Q.push(x);
    if (x != y)
        Q.push(y);
    int ret = 0;
    while (!Q.empty()) {
        int p = Q.front();
        Q.pop();
        ret ++;
        if (dist[p] == limit)
            continue;
        for (int q : adj[p]) {
            if (dist[q] < 0) {
                dist[q] = dist[p] + 1;
                Q.push(q);
            }
        }
    }
    return ret;
}

int main()
{
    scanf("%d%d", &n, &diameter);
    for (int i = 1; i < n; i++) {
        int ai, bi;
        scanf("%d%d", &ai, &bi);
        ai --, bi --;
        adj[ai].push_back(bi);
        adj[bi].push_back(ai);
    }
    int maxSize = 0;
    for (int i = 0; i < n; i++) {
        if (diameter % 2 == 0) {
            maxSize = max(maxSize, solve(i, i, diameter / 2));
        } else {
            for (int j : adj[i])
                maxSize = max(maxSize, solve(i, j, diameter / 2));
        }
    }
    printf("%d\n", n - maxSize);
}


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

int main()
{
   int w,a,b;
   cin>>w>>a>>b;
   int p,q;
   p=min(a,b);
   q=max(a,b);

   if(p+w>=q)
   {
       cout<<"0\n";
   }
   else
    cout<<q-(p+w)<<endl;
}



Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Queue;
import java.util.Scanner;

class Main {

  private static final int INF = Integer.MAX_VALUE / 4;
  private static final Integer[] di = { 1, -1, 0, 0 };
  private static final Integer[] dj = { 0, 0, 1, -1 };

  public static boolean isIn(int i, int j, int H, int W) {
    if (0 <= i && i < H && 0 <= j && j < W) {
      return true;
    } else {
      return false;
    }
  }

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int H = scanner.nextInt();
    int W = scanner.nextInt();
    String[] map = new String[H];
    int[][] min = new int[H][W];
    int cntBlack = 0;
    for (int i = 0; i < H; i++) {
      map[i] = scanner.next();
      for (int j = 0; j < W; j++) {
        if (map[i].charAt(j) == '#') {
          cntBlack++;
        }
      }
    }
    for (int[] is : min) {
      Arrays.fill(is, INF);
    }
    Queue<Integer[]> queue = new ArrayDeque<Integer[]>();
    queue.add(new Integer[] { 0, 0 });
    min[0][0] = 0;
    while (!queue.isEmpty()) {
      Integer[] p = queue.poll();
      for (int k = 0; k < 4; k++) {
        int ci = p[0] + di[k];
        int cj = p[1] + dj[k];
        if (isIn(ci, cj, H, W) && map[ci].charAt(cj) == '.' && min[ci][cj] == INF) {
          min[ci][cj] = min[p[0]][p[1]] + 1;
          queue.add(new Integer[] { ci, cj });
        }
      }
    }
    if (min[H - 1][W - 1] == INF) {
      System.out.println(-1);
    } else {
      System.out.println(H * W - min[H - 1][W - 1] - cntBlack - 1);
    }
  }
}


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

const int N = 5001;

int n, k, dp[N], mod = 1e9 + 7;
vector <int> a;

void add(int x){
    for(int i = k ; i >= x ; i--){
        dp[i] += dp[i - x];
        if(dp[i] >= mod) dp[i] -= mod;
    }
}
void del(int x){
    for(int i = x ; i <= k ; i++){
        dp[i] -= dp[i - x];
        if(dp[i] < 0) dp[i] += mod;
    }
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    dp[0] = 1;
    cin >> n >> k;
    a.resize(n);
    for(auto &i : a){
        cin >> i;
        add(i);
    }
    int ans = 0;
    for(int i = 0 ; i < n ; i++){
        del(a[i]);
        int ok = 0;
        for(int j = max(0, k - a[i]) ; j < k ; j++){
            ok |= dp[j];
        }
        ans += !ok;
        add(a[i]);
    }
    cout << ans << endl;
}


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

int hantei(int a, int b){
    if(a==1 && b==1){
        return 0;
    }else if(a==1){
        return 2;
    }else if(b==1){
        return 1;
    }

    if (a > b){
        return 2;
    }else if(b >a){
        return 1;
    }else{
        return 0;
    }
}

int main (){
    int a, b;
    cin >> a >> b;
    if(hantei(a,b)==2){
        cout << "Alice" << endl;
    }else if(hantei(a,b)==1){
        cout << "Bob" << endl;
    }else if(hantei(a,b)==0){
        cout << "Draw" << endl;
    }
}

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

int main(){
    int n; cin >> n;
    vector<double> v(n); rep(i,n) cin >> v[i];
    sort(v.begin(),v.end());
    double ans = (v[0] + v[1])/2.0;
    for(int i = 2; i < n; i++){
        ans = (ans + v[i])/2.0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public void main(Scanner sc) {
        int h = sc.nextInt();
        int w = sc.nextInt();
        int map[][] = new int[h + 2][w + 2];

        for (int i = 0; i < h; i++) {
            String s = sc.next();
            for (int j = 0; j < w; j++) {
                if (s.charAt(j) == '#') {
                    map[i + 1][j + 1] = 1;
                }
            }
        }

        for (int i = 1; i <= h; i++) {
            for (int j = 1; j <= w; j++) {
                if (map[i][j] == 1) {
                    if (map[i - 1][j] + map[i][j - 1] + map[i + 1][j] + map[i][j + 1] == 0) {
                        System.out.println("No");
                        return;
                    }
                }
            }
        }

        System.out.println("Yes");
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        new Main().main(sc);
        sc.close();
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define endl "\n"
#define all(v) v.begin(),v.end()
#define mp make_pair
#define mm(a) memset(a,0,sizeof(a))
#define rep(i,a,b) for(ll i = a; i < b; i++)
#define repn(i,a,b) for(ll i = a; i >= b; i--)
#define pb push_back
#define ff first
#define ss second
#define fto(k,m) for(auto k:m)
#define in_edges(m) repp(i, 1, m){ ll a, b; cin >> a >> b; adj[a].pb(b), adj[b].pb(a);}
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define MOD 1000000007
#define sz(a) ll((a).size())
#define pii 3.1415926535897
#define quick ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int main()
{
	quick
	// Bahut gussa aya mujhe YE QUESTION BANAKE @!@
	ll t;t=1;
    // cin >> t;
	while(t--)
	{
		string s1,s2; cin>>s1>>s2;
		ll cnt = 0;
		rep(i,0,sz(s1))
		{
			if(s1[i]!=s2[i])cnt++;
		}
		cout<<cnt<<endl;
	}
}

Measured memory_bytes: 3884
M=1e9+7;f[999];n;k;long a=1;main(i,N){for(scanf("%d",&N);n=N;f[n]++,--N)for(k=2;k*k<=n;)n%k?k++:(n/=k,f[k]++);for(;++i<998;)a=a*-~f[i]%M;printf("%d",a);}

Measured memory_bytes: 128
$n = gets.to_i
INF = 1 << 30
$m = Array.new($n){ Array.new }
$n.times do
  l = gets.split.map(&:to_i)
  (1..l[1]).each{ |i| $m[l[0]] << l[2*i, 2] }
end
def dijkstra(x)
  d = Array.new($n, INF)
  d[x] = 0
  v = Array.new($n){ |i| i }
  while v.size > 0
    a = Array.new($n, INF)
    v.each{ |i| a[i] = d[i] }
    t = v.delete(a.index(a.min))
    $m[t].each do |r|
      u, w = r
      d[u] = d[t] + w if d[t] + w < d[u]
    end
  end
  d
end
ret = dijkstra(0)
ret.each_index{ |i| puts "#{i} #{ret[i]}" }

Measured memory_bytes: 9012
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int NUM = 222;
const int MAX_N = 1010101;
const int INF = 1001001001;

ll tri[NUM];
ll tet[NUM];
ll dp_a[MAX_N];
ll dp_o[MAX_N];

int main() {
    for (int i = 1; i < NUM; i++) {
        tri[i] = tri[i - 1] + i;
    }
    for (int i = 1; i < NUM; i++) {
        tet[i] = tet[i - 1] + tri[i];
    }
    fill(dp_a, dp_a + MAX_N, INF);
    fill(dp_o, dp_o + MAX_N, INF);
    dp_a[0] = dp_o[0] = 0;
    for (int i = 0; i < NUM; i++) {
        for (int j = tet[i]; j <= MAX_N; j++) {
            dp_a[j] = min(dp_a[j], dp_a[j - tet[i]] + 1);
            if (tet[i] & 1) dp_o[j] = min(dp_o[j], dp_o[j - tet[i]] + 1);
        }
    }
    int n;
    while (cin >> n && n) {
        cout << dp_a[n] << ' ' << dp_o[n] << endl;
    }
}


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

int main()
{
    int n;
    cin >> n;
    cout << (int)n/3 << "\n";
    return 0;
}


Measured memory_bytes: 256
k, a, b = [0] * 3

def format_input(filename = None):
	global k, a, b
	if filename == None:
		k = int(input())
		a, b = list(map(int, input().split()))

	elif filename == '__random__':
		from random import randint as rng
		a = rng(1, 10**3)
		b = rng(a, 10**3)
		k = rng(1, 10**3)
		print(k)
		print(a, b)

def get_answer():
	answer = 'NG'

	target = (b // k) * k

	if target >= a:
		answer = 'OK'

	return answer

if __name__ == '__main__':
	format_input()

	ans = get_answer()
	print(ans)


Measured memory_bytes: 9212
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
int main() {
	int n, t[50], sum = 0;
	bool isSleep = false;
	char s[50][101], x[101];
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s%d", s[i], &t[i]);
	}
	scanf("%s", x);
	for (int i = 0; i < n; i++) {
		if (isSleep) {
			sum += t[i];
		} else if (strcmp(x, s[i]) == 0) {
			isSleep = true;
		}
	}
	printf("%d\n", sum);
	return 0;
}

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, r;
    cin>> n >> r;
    cout << r + max(100 * (10 - n), 0) << endl;
    return 0;
}

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

int _abs (int n) { return n<0?-n:n; }
int main () {
	int i,n,d,a,T[20]={1},S[10]={4};
	for (i=1;i<20;++i) T[i]=T[i-1]+(i+1)*T[0];
	for (i=1;i<10;++i) S[i]=S[i-1]+(i+1)*S[0];
	while (cin>>n) {
		d=18-_abs(n-18);a=0;
		if (0<=d&&d<=18) {
			for (i=d+1;i--;) a+=T[i];
			if (d>9) for (i=d-9;i--;) a-=S[i];
		}
		cout << a << endl;
	}
}

Measured memory_bytes: 1160
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<set>

#define ll long long
#define db double
#define rg register int

using namespace std;

const int mod=1e9+7;//998244353;

int n,m;
int tt,ans=1;
int a[500005];
int b[500005];
int k[500005];
int f[500005];
int tr[500005];

struct su{
	int x,y;
	inline bool operator <(const su &z)const{
		if(y==z.y)return x>z.x;
		return y<z.y;
	}
}s[500005];

inline int qr(){
	register char ch; register bool sign=0; rg res=0;
	while(!isdigit(ch=getchar()))if(ch=='-')sign=1;
	while(isdigit(ch))res=res*10+(ch^48),ch=getchar();
	if(sign)return -res; else return res;
}

inline void add(int x,int v){
	for(;x<=tt;x+=x&-x) (tr[x]+=v)%=mod;
}

inline int ask(int x){
	rg res=0;
	for(;x;x-=x&-x) (res+=tr[x])%=mod;
	return res;
}

int main(){
	//freopen("robot.in","r",stdin);
	//freopen("robot.out","w",stdout);
	n=qr(); m=qr();
	for(rg i=1;i<=n;++i) a[i]=qr();
	for(rg i=1;i<=m;++i) b[i]=qr();
	for(rg i=1,j=1;i<m&&j<=n;++i){
		while(j<=n&&a[j]<=b[i])++j;
		if(j>n)break;
		while(j<=n&&a[j]<b[i+1]){
			k[++tt]=a[j]-b[i];
			s[tt]=su{k[tt],b[i+1]-a[j]}; ++j;
		}
	} sort(k+1,k+tt+1);
	//cout<<4225453<<endl;
	for(rg i=1;i<=tt;++i)
		s[i].x=lower_bound(k+1,k+tt+1,s[i].x)-k;
	sort(s+1,s+tt+1);
	for(rg i=1;i<=tt;++i){
		if(s[i].x==s[i-1].x&&s[i].y==s[i-1].y)continue;
		f[i]=(ask(s[i].x-1)+1)%mod;
		ans=(ans+f[i])%mod;
		add(s[i].x,f[i]);
	}
	printf("%d\n",ans);
	return 0;
}


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

int main() {
	int n; cin >> n;
	rep(i, n) {
		int x, y, b, p; cin >> x >> y >> b >> p;
		cout << min(x*b + y*p, (max(b, 5)*x + max(p, 2)*y) * 4 / 5) << endl;
	}
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int N, W;
int w[101], v[101];
ll dp[101][100001];
ll shop(int i, int wi) {
	if(dp[i][wi] != -1)
		return dp[i][wi];
	if(i == N)
		return 0;
	if(w[i] <= wi) dp[i][wi] = max(dp[i][wi], v[i] + shop(i+1, wi - w[i]));
	dp[i][wi] = max(dp[i][wi], shop(i+1, wi));
	return dp[i][wi];
}
int main() {
	cin >> N >> W;
	for(int i=0;i<N;i++)
		cin >> w[i] >> v[i];
	for(int i=0;i<101;i++)
		for(int j=0;j<100001;j++)
			dp[i][j] = -1;
	cout << shop(0,W) << "\n";
	return 0;
}


Measured memory_bytes: 79104
#include <stdio.h>
#include <string.h> //文字列操作


int main () {
	char str[201]; //最後null文字入るからね
	int shu_time,shu_cont;
	int i,j,k,l;
	int tmp;
	
	for (i = 0;i < 10;i ++) {
		scanf ("%s",&str);
		if (strcmp (str,"-")  == 0) {
			break;
		}
		
		scanf ("%d",&shu_time); //シャッフル回数   
		for (j  = 0;j < shu_time;j ++) {
			scanf ("%d",&shu_cont); //shuffle_content 前から何枚後ろに
            while (shu_cont) {
            	tmp = str[0]; 
            	for (k = 1;k < strlen (str) ;k ++) { //strの中身をスライドします
            		str[k-1] = str[k];
            	}
            	str[strlen (str) - 1] = tmp;
                shu_cont --;	
            }
			
		}
		
		for (l = 0;l < strlen (str) ;l ++) {
			printf ("%c",str[l]);
		}
		putchar ('\n');
	}
	
	
	return 0;
}


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

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

  for (int i = 1; i < 10; i++) {
    if (N / i < 10 && N % i == 0) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
#include<cstring>
#include<vector>
#include<stack>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<iomanip>
#include<functional>
#include<unordered_map>
#define io ios::sync_with_stdio(false),cin.tie(0)
#define inf 0x3f3f3f3f
#define ll long long
#define P pair<int,int>
#define lc rt*2
#define rc rt*2+1
const int maxn = 1e6 + 10;
const int mod = 1e9 + 7;
const double PI = 3.1415926536;

using namespace std;


string s;
int main()
{
	cin >> s;
	if (s.size() & 1)
	{
		cout << "No";
		return 0;
	}
	for (int i = 0; i < s.size(); i += 2) {
		if (s[i] != 'h' || s[i + 1] != 'i')
		{
			cout << "No";
			break;
		}
		if (i == s.size() - 2)
			cout << "Yes";
	}

	return 0;
}

Measured memory_bytes: 256
//#include "stdafx.h"
#include<iostream>
#include<string>
using namespace std;

int main() {
	int n;
	string s;
	while (cin >> n, n) {
		cin >> s;
		
		for (int x = 0;x < n;x++) {
			s += '@';
			string sg="";

			char now = s[0];
			int ko = 0;

			for (int i = 0;i < s.size();i++) {
				if (s[i] == now)ko++;
				else {
					string sa = to_string(ko);
					sg += sa;
					sg.push_back(now);
					now = s[i];
					ko = 1;
				}
			}
			s = sg;
		}

		cout << s << endl;

	}
	return 0;
}

Measured memory_bytes: 3340
#include <iostream>
#include <bits/stdc++.h>
#include<math.h>
#define ll long long int
#define MX 10000

using namespace std;

/*bool sortBySec(pair <ll, ll> &a, pair <ll,ll> &b){
    return a.second<b.second;
}
ll binarySearch(vector<ll> v, ll ele){
    ll low=0, high=v.size()-1;
    ll mid;
    while(low<high){
        mid=low + (high-low)/2;
        if(v[mid]>=ele){
            high=mid;
        }
        else{
            low=mid+1;
        }
    }
    return low;
}*/

void solve(){

}


int main() {
    std::ios_base::sync_with_stdio(false);
    ll a, b, c, d;
    cin>>a>>b>>c>>d;
    ll p1=a*c, p2=a*d, p3=b*c, p4=b*d;
    ll hi=p1;
    hi=max(hi, p2);
    hi=max(hi, p3);
    hi=max(hi, p4);
    cout<<hi;
}




/*

5 to 3
1 2 3 4 5

*/


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int n;
int c[500];
int s[500];
int f[500];
int ans[500];

int main(){
    cin>>n;
    for(int i=0;i<n-1;i++){
        cin>>c[i]>>s[i]>>f[i];
    }
    for(int i=n-2;i>=0;i--){
        int time=s[i]+c[i];
        if(i==n-2){
            ans[i]=time;
            continue;
        }
        for(int j=i+1;j<n-1;j++){
            if(s[j]>=time){
                ans[i]=ans[i+1];
                break;
            }
            else{
                if(time%f[j]==0) time=time+c[j];
                else time=(time/f[j]+1)*f[j]+c[j];
                if(j==n-2) ans[i]=time;
            }
        }
    }
    ans[n-1]=0;
    for(int i=0;i<n;i++){
        cout<<ans[i]<<endl;
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <string>
#include <vector>
#include <iostream>
#include <boost/algorithm/string/join.hpp>


using namespace std;
using namespace boost;

typedef int64_t INT;

void KyoproResolve(istream& is, ostream& os)
{
	INT N, M, X, Y;
	is >> N >> M >> X >> Y;
	INT maxX = -1000;
	INT minY = 1000;
	for(auto i = 0;i < N;i++)
	{
		INT n;
		is >> n;
		maxX = max(maxX, n);
	}
	for(auto i = 0;i < M;i++)
	{
		INT n;
		is >> n;
		minY = min(minY, n);
	}
	if(maxX < Y && X < minY && maxX < minY)
	{
		os << "No War" << '\n';
	}else
	{
		os << "War" << '\n';
	}
}

#if !_DEBUG

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

	KyoproResolve(cin, cout);
	return 0;
}
#endif


Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.string;
import std.array;
import std.conv;
import std.math;

char[12][12] map;
int[] dx = [1,0,-1,0];
int[] dy = [0,1,0,-1];

void saiki(int x, int y){
    if(map[y][x] == '1'){
	map[y][x] = '0';
	for(int i=0;i<4;i++){
	    if(x+dx[i]>=12||y+dy[i]>=12||x+dx[i]<0||y+dy[i]<0) continue;
	    saiki(x+dx[i],y+dy[i]);
	}
    }
}

void main(){
    auto temp = map.dup;
    while(true){
	map = temp.dup;
	int ans;
	for(int i=0;i<12;i++){
	    string t = readln().chomp();
	    for(int j=0;j<12;j++) map[i][j] = t[j];
	}
	for(int i=0;i<12;i++){
	    for(int j=0;j<12;j++){
		if(map[j][i]=='1'){
		    saiki(i,j);
		    ans++;
		}
	    }
	}
	writeln(ans);
	auto a = readln();
	if(stdin.eof()) break;
    }
}

Measured memory_bytes: 2360
#include<iostream>
#include<cstdio>
#include<set>
#include<map>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<cassert>
#include<string>
#include<vector>
#include<queue>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 100000005
#define rep(i,n) for(int i = 0;i < n;i++)
using namespace std;
typedef long long int ll;
typedef pair<int,int> PI;

int main(){
    ll a[6];

    while(1){
        ll sum = 0;
        cin>>a[0]>>a[2]>>a[4]>>a[1]>>a[3]>>a[5];
        rep(i,6){
            sum+=a[i];
        }
        if(!sum)
            break;
        ll b[3];
        rep(i,3){
            b[i]=0;
            b[i]+=a[i*2];
            b[i]+=a[i*2+1];
        }
        ll ans = 0;
        ll bal = INF;
        rep(i,3){
            bal = min(bal,b[i]);
        }
        rep(i,3){
            if(bal<0)break;
            ll temp=bal;
            rep(j,3){temp+=(b[j]-bal)/3;}
            ans = max(ans,temp);
            bal--;
        }
        cout<<ans<<endl;

    }
}

Measured memory_bytes: 1160
n, m = map(int, input().split())
arr = [int(input()) for _ in range(m)]
mod = 10 ** 9 + 7

dp = [0] * (n + 1)
dp[0] = 1

j = 0
for i in range(1, n + 1):
    if j < m and i == arr[j]:
        dp[i] = 0
        j += 1
        continue

    if i == 1:
        dp[1] = dp[0]
        continue

    dp[i] = dp[i - 1] + dp[i - 2]
    dp[i] %= mod

print(dp[n])


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

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

    map<string, int> m;
    int max_value = 0;
    for(int i=0; i<N; ++i) {
        string s;
        cin >> s;
        // v[i] = s;
        if(m.find(s)==m.end()) {
            // cout << "new word found " << s << endl;
            m[s] = 1;
        }
        else m[s] += 1;
        if (m[s] > max_value ) {
            max_value = m[s];
        }
    }

    vector<string> result;
    for(auto itr=m.begin(); itr!=m.end(); ++itr) {
        // cout << itr->first << " " << itr->second << endl;
        if(itr->second==max_value) {
            result.push_back(itr->first);
        }
    }
    sort(result.begin(), result.end());
    for (auto v:result){
        cout << v << endl;
    }

}

Measured memory_bytes: 26868
#include <iostream>
#include <set>
#include <string>
using namespace std;

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

    int n = s.size();

    set<string> table;
    for (int i = 0; i < n; i++) {
        for (int j = 1; j <= k && i + j <= n; j++) {
            table.insert(s.substr(i, j));
        }
    }

    auto it = table.begin();
    while (--k) it++;

    cout << *it << '\n';

}


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

int find_root(vector<int>& root, int x)
{
  if (root.at(x) == x) {
    return x;
  }
  int r = find_root(root, root.at(x));
  root.at(x) = r;
  return r;
}

int main()
{
  int nnode, nedge;
  cin >> nnode >> nedge;
  vector<int> root(nnode);
  for (int i = 0; i < nnode; i++) {
    root.at(i) = i;
  }
  for (int i = 0; i < nedge; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    int aroot = find_root(root, a);
    int broot = find_root(root, b);
    root.at(aroot) = broot;
  }
  unordered_map<int, int> cnt;
  for (int i = 0; i < nnode; i++) {
    int r = find_root(root, i);
    cnt[r]++;
  }
  int maxi = 0;
  for (const auto& p : cnt) {
    maxi = max(maxi, p.second);
  }
  cout << maxi << '\n';
  return 0;
}


Measured memory_bytes: 12144
cards = []
mark = ["S", "H", "C", "D"]
for m in mark:
    for i in range(1, 14):
        cards.append(m + " " + str(i))
        
n = int(input())

for _ in range(n):
    x = input()
    cards.remove(x)
    
for c in cards:
    print(c)


Measured memory_bytes: 5592
#!/bin/bash

max(){
    if (( $1 > $2 ));then
        echo $1
    else
        echo $2
    fi
}

ans=-1000
read a b
ans=$( max $ans $((a+b)) )
ans=$( max $ans $((a-b)) )
ans=$( max $ans $((a*b)) )

echo $ans

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    ll n; cin >> n;
    vector<ll> a(n + 1);
    for (int i = 0; i < n + 1; ++i) {
        cin >> a[i];
    }

    // 各深さで取り得る頂点数の範囲
    vector<ll> l(n + 1, 0);
    vector<ll> r(n + 1, 0);

    l[n] = r[n] = a[n];

    // 深さ(i + 1)での範囲が(l[i + 1], r[i + 1])の時、深さiでは葉でない頂点数はその半分以上あればよい
    for (int i = n - 1; i >= 0; --i) {
        l[i] = a[i] + (l[i + 1] + 1) / 2; // 最小値
        r[i] = a[i] + r[i + 1]; // 最大値
    }

    if (l[0] > 1) {
        cout << -1 << endl;
        return 0;
    }

    ll ans = 0;
    // 頂点から見ていく
    ll cur = 1;
    for (int i = 0; i < n + 1; ++i) {
        ans += cur;
        cur -= a[i]; // 葉の数を引く
        cur = min(cur * 2, r[i + 1]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 5500
#include <bits/stdc++.h>
using namespace std;
//C
int main(){
  
  int N; cin >> N;
  
  set<string> data;
  for(int i=0; i<N; i++) {
    string a; cin >> a;
    data.insert(a);
  }
  
  cout << data.size() << endl;
  
}

Measured memory_bytes: 19064
import math

ip = int(input())

if ip == 2:
    print(2)
    exit()

primes = [2]
for i in range(3, 100001, 2):
    for p in primes:
        if i % p == 0:
            break
    else:
        primes.append(i)

primes.append(100003)
primes = primes[::-1]

for i in range(len(primes)):
    if primes[i] < ip:
        print(primes[i - 1])
        exit()


Measured memory_bytes: 41692
import sys

def sa(Type= int):
  return [Type(x) for x in input().split()]

def solve():
  seen = set()
  n = int(input())

  for _ in range(n):
    line = input()
    seen.add(line)

  types = ['S', 'H', 'C', 'D']

  for t in types:
    for i in range(1, 14):
      card = '{} {}'.format(t, i)
      if card not in seen:
        print(card)



if __name__ == '__main__':
  # sys.stdin = open('input.txt', 'r')
  solve()


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

#define all(A) begin(A), end(A)
#define sz(A) int(A.size())

using namespace std;

typedef long long ll;

int main () {
  const ll INF = 1e18;
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  vector <ll> arr(n + 1);
  vector <vector <ll>> dp(2, vector <ll> (n + 1, -INF));
  for (int i = 1; i <= n; i++) cin >> arr[i];
  dp[0][1] = arr[1];
  dp[1][1] = -arr[1];
  for (int pos = 2; pos <= n; pos++) {
    for (int prev: {0, 1}) {
      ll cur = arr[pos];
      if (prev == 1) cur *= -1;
      dp[0][pos] = max(dp[0][pos], dp[prev][pos - 1] + cur);
      dp[1][pos] = max(dp[1][pos], dp[prev][pos - 1] - cur);
    }
  }
  cout << dp[0][n] << endl;
  return (0);
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <limits>
#include <string>
#include <vector>

using namespace std;

const long long INF = 1LL << 60;

//各桁の和を出力
long long Sum(long long n) {
  long long m = 0;
  while (n) {
    m += n % 10;
    n /= 10;
  }
  return m;
}

const int MAX = 510000;
const int MOD = 1000000007;

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

void Comuse() {
  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;
  }
}

#define comuse Comuse()
// nCk(comuseを使え)
long long combi(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;
}
// pCk(comuseを使え)
long long perm(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] % MOD) % MOD;
}

//最小公倍数(aとbの)
long long lcm(long long a, long long b) {
  long long n;
  n = a / __gcd(a, b) * b;
  return n;
}

// auto A = div(n)
vector<long long> div(long long n) {
  vector<long long> ret;
  for (long long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) {
        ret.push_back(n / i);
      }
    }
  }
  sort(ret.begin(), ret.end());
  return ret;
}

//(aのn乗をmodで割ったあまり)
long long modpow(long long a, long long n, long long mod) {
  long long ans = 1;
  while (n > 0) {
    if (n & 1) {
      ans = ans * a % mod;
    }

    a = a * a % mod;

    n >>= 1;
  }

  return ans;
}

void solve();

const int MAX_N = 131072;
// segment tree
int NN;
int seg[MAX_N * 2 - 1];
void seguse() {
  for (int i = 0; i < 2 * NN - 1; i++) {
    seg[i] = INT_MAX;
  }
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << fixed;
  solve();
}

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

long long N, R, B;

void solve() {
  cin >> N >> B >> R;
  long long BR = B + R;
  long long katamari = (N / BR) * B;
  if(N % BR > B){
    cout << katamari + B <<endl;
  } else{
   cout << katamari + (N % BR) <<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
  
using namespace std; 
  
void Solve(){
    string s;
    cin>>s;
    int n = s.size();
    for(int i = n - 1; i >= 0; i--){
        if(s[i] == '?') s[i] = 'D';
    }
    cout<<s<<'\n';
} 
int main() 
{ 
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    Solve();
}

  

Measured memory_bytes: 3772
# -*- coding: utf-8 -*-

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians, log10
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul, xor
from copy import copy, deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, M = MAP()
A = LIST()
need = [0,2,5,5,4,5,6,3,7,6]

dp = [''] * (N+10)
for a in A:
    dp[need[a]] = max(dp[need[a]], str(a))

for i in range(N):
    if dp[i] != '':
        for a in A:
            # 基本は文字列の長さ(桁数)で比較
            if len(dp[i+need[a]]) < len(dp[i])+1:
                dp[i+need[a]] = dp[i]+str(a)
            # それが同じ時だけ大小で比較
            elif len(dp[i+need[a]]) == len(dp[i])+1:
                dp[i+need[a]] = max(dp[i+need[a]], dp[i]+str(a))
print(dp[N])


Measured memory_bytes: 144876