akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
6
1 2 2 3
2 2 3 4
3 1 5
4 1 6
5 1 6
6 0

output:
1 1 12
2 2 11
3 3 8
4 9 10
5 4 7
6 5 6
"""
import sys

UNVISITED, VISITED_IN_STACK, POPPED_OUT = 0, 1, 2


def generate_adj_matrix(v_info):
    for v_detail in v_info:
        v_index, adj_num, *adj_list = map(int, v_detail)
        # assert len(adj_list) == adj_num
        init_adj_table[v_index].extend(sorted(adj_list, reverse=True))
    return init_adj_table


def graph_dfs(v_init):
    global time

    # init the first node of overall graph iterations(times >= 1)
    stack.append(v_init)
    color[v_init] = VISITED_IN_STACK
    d_time[v_init] += time
    # init end

    while stack:
        current = stack[-1]
        v_table = adj_table[current]
        # if adj is None, current's adj(s) have been all visited
        adj = v_table.pop() if v_table else None

        if adj:
            if color[adj] is UNVISITED:
                color[adj] = VISITED_IN_STACK
                time += 1
                d_time[adj] += time
                stack.append(adj)
        else:
            stack.pop()
            color[current] = POPPED_OUT
            time += 1
            f_time[current] += time

    return None


def dfs_start():
    global time
    for i in range(vertices_num):
        if color[i + 1] == UNVISITED:
            # print('round: ', i + 1)
            graph_dfs(i + 1)
            time += 1


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    vertices_num = int(_input[0])
    vertices_info = map(lambda x: x.split(), _input[1:])
    init_adj_table = tuple([] for _ in range(vertices_num + 1))
    # assert len(vertex_info) == vertex_num

    # config length = (vertex_num + 1)
    stack = []
    color = [UNVISITED] * (vertices_num + 1)
    d_time, f_time = ([0] * (vertices_num + 1) for _ in range(2))

    adj_table = generate_adj_matrix(vertices_info)
    # timing start from 1
    time = 1
    dfs_start()

    for index, v in enumerate(zip(d_time[1:], f_time[1:]), 1):
        print(index, *v)

Measured memory_bytes: 7796
#include <bits/stdc++.h>
using namespace std;
int main() {
    int L;
    cin >> L;
    double M;
    if (L % 3 == 1){
        M = L/3 +0.3333333333333;
    }
    else if (L % 3 == 2){
        M = L/3 +0.666666666666;
    }
    else if (L % 3 == 0){
        M = L/3;
    }
    cout << fixed << setprecision (10);
    cout << M * M * M << endl;
}

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

int main() {
    ll n;
    cin >> n;
    vector<ll> vec(n);
    rep(i, n){
        cin >> vec[i];
        if(vec[i] == 0){
            cout << 0 << endl;
            return 0;
        }
    }
    ll current = 1;
    rep(i, n){
        ll tmp = current * vec[i];
        if(tmp > (ll)1e18 || tmp < current){
            cout << -1 << endl;
            return 0;
        }else{
            current = tmp;
        }
    }
    cout << current << endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  if (N % 2 == 0) {
    double a = 0.5;
    cout << a << endl;
  } else {
    double a = ((N / 2) + 1) / (double)N;
    cout << a << endl;
  }
}


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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sqr(a) ((a) * (a))
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define forn(i, n) for(int i = 0; i < int(n); i++) 
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out << "(" << a.x << ", " << a.y << ")";
}

template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
	out << "[";
	forn(i, sz(v)) {
		if(i) out << ", ";
		out << v[i];
	}
	return out << "]";
}

mt19937 rnd(time(NULL));

const int INF = int(1e9);
const li INF64 = li(1e18);
const int MOD = INF + 7;
const ld EPS = 1e-9;
const ld PI = acos(-1.0);

const int N = 200 * 1000 + 13;

int n;
pt a[N];

bool read () {
	if (scanf("%d", &n) != 1)
		return false;
	forn(i, n)
		scanf("%d", &a[i].x);
	forn(i, n)
		scanf("%d", &a[i].y);
	return true;
}

li f[N];

void upd(int x, li val){
	for (int i = x; i < N; i |= i + 1)
		f[i] = max(f[i], val);
}

li get(int x){
	li res = 0;
	for (int i = x; i >= 0; i = (i & (i + 1)) - 1)
		res = max(res, f[i]);
	return res;
}

void solve() {	
	memset(f, 0, sizeof(f));
	forn(i, n)
		upd(a[i].x, get(a[i].x) + a[i].y);
	printf("%lld\n", *max_element(f, f + n + 1));
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	
	int tt = clock();
	
#endif
	
	cerr.precision(15);
	cout.precision(15);
	cerr << fixed;
	cout << fixed;

	while(read()) {	
		solve();
		
#ifdef _DEBUG
	cerr << "TIME = " << clock() - tt << endl;
	tt = clock();
#endif

	}
}

Measured memory_bytes: 3328
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//vector<pair<ll,ll>> pc;
//int ABS(int a){return max(a,-a);}
//int a[100001];
int main(){
    int n;
    cin>>n;
    double ans=0.00000000;
    for(int i=0;i<n;i++){
        double x;
        string s;
        cin>>x;
        cin>>s;
        if(s=="JPY") ans+=x;
        else ans+=(x*380000.0000);
    }
    printf("%.11f",ans);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;

int main(){
	char str[5];
	cin>>str;
	for(int i=0;i<3;i++){
		if(str[i]=='1') cout<<'9';
		else cout<<'1';
	}
	
	return 0;
}

Measured memory_bytes: 256
n,m,l = map(int, input().split())

A_table = [[0 for i in range(m)] for j in range(n)]
B_table = [[0 for i in range(l)] for j in range(m)]
C_table = [[0 for i in range(l)] for j in range(n)]

for i in range(n):
    Col = list(map(int, input().split()))
    A_table[i] = Col
for i in range(m):
    Col = list(map(int, input().split()))
    B_table[i] = Col


for i in range(l):
    for j in range(n):
        ele = 0
        for t in range(m):
            ele += A_table[j][t]*B_table[t][i]
        C_table[j][i] = ele

for i in range(n):
    for j in range(l):
        if j == l-1:
            print(C_table[i][j], end = "")
        else:
            print(C_table[i][j], end = " ")
    print()



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

int main() {
  int n;
  long long h;
  cin>>n>>h;
  long long A=-1;
  vector<long long> B;
  rep(i,n){
    long long a,b;
    cin>>a>>b;
    A=max(A,a);
    B.push_back(b);
  }
  sort(B.begin(),B.end(),greater<long long>());
  
  long long ans=0;
  for(auto b:B){
    if(b>A){
      h-=b;
      ans++;
    }
    else break;
    if(h<=0) break;
  }
  if(h>0) ans+=(h+A-1)/A;
  cout<<ans<<endl;
}


Measured memory_bytes: 1400
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.Math;

public class Main {
    public static void main(String[] args) {
        FS reader = new FS();
        // write reader
        int N = reader.nextInt();
        int K = reader.nextInt();
        int Q = reader.nextInt();

        int[] P = new int[N];
        for (int i=0; i<Q; i++) {
            P[reader.nextInt()-1]++;
        }
        for (int i=0; i<N; i++) {
            if (P[i] > Q-K) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
    }
    
    public static void solver() {
        // write logic
    }
    
    // Read Class
    static class FS {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
    
        private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
        private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
        private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public int nextInt() {
            return (int)nextLong();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if(b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
    }
}



Measured memory_bytes: 39768
# 2019/10/26

a,b=map(int,input().split())
n_even=(b//2)-(a-1)//2

if (b-a+1)%2:
    if a%2:
        print(a^(n_even%2))
    else:
        print(b^((n_even-1)%2))
else:
    if a%2:
        print(a^b^((n_even-1)%2))
    else:
        print(n_even%2)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::map;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  ui N{}; cin >> N;

  cout << (N * 180 - 360) << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
	return (ull)rng() % B;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int m;
    while(cin >> m,m){
        vector<int> t(m);
        for(int i=0;i<m;i++){
            cin >> t[i];
        }
        int n; cin >> n;
        vector<int> a(n),b(n);
        for(int i=0;i<n;i++){
            cin >> a[i] >> b[i];
            a[i]--;
        }
        int res=1e9;
        vector<int> x(100,24);
        for(int i=0;i<n;i++){
            x[a[i]]=min(x[a[i]],b[i]);
        }
        vector<vector<int>> dp(101,vector<int>(m,1e9));
        dp[0][0]=0;
        for(int i=0;i<100;i++){
            for(int j=0;j<m;j++){
                if(t[j]<=x[i]){
                    dp[i+1][(j+1)%m]=min(dp[i+1][(j+1)%m],dp[i][j]);
                }
                dp[i+1][1%m]=min(dp[i+1][1%m],dp[i][j]+1);
            }
        }
        for(int i=0;i<m;i++){
            res=min(res,dp[100][i]);
        }
        printf("%d\n",res);
    }
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)

const ll INF = 10010001010;
const int inf = 1000034000;
typedef vector<ll> vecl;
typedef vector<int> veci;
typedef tuple<string, int, int> TUP;

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

uintmax_t combination(unsigned int n, unsigned int r)
{
    if (r * 2 > n)
        r = n - r;
    uintmax_t dividend = 1;
    uintmax_t divisor = 1;
    for (unsigned int i = 1; i <= r; ++i)
    {
        dividend *= (n - i + 1);
        divisor *= i;
    }
    return dividend / divisor;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout << fixed << setprecision(15);
    int N,D;
    cin >> N >>D;
    vector<double> X(N),Y(N);
    ll ans = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> X[i] >> Y[i];
        double p = X[i] * X[i];
        double q = Y[i] * Y[i];
        p += q;
        p = sqrt(p);
        if (p <= D)
        {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 6364
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

const int MAX_N = 10000;
const int MAX_K = 10;

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

    string s;

    cin >> s;

    long long sum = 0;

    for (int i = 0; i < (1 << (s.size() - 1)); i++) {
        int last = s.size() - 1;
        for (int j = 0; j < s.size() - 1; j++) {
            if (i & (1 << j)) {
                int start = s.size() - j - 1;
                long long num = stoll(s.substr(start, last - start + 1));
                sum += num;
                last = start - 1;
            }
        }
        long long num = stoll(s.substr(0, last + 1));
        sum += num;
    }



    cout << sum << "\n";

    return 0;
}

Measured memory_bytes: 3576
a,b,x=map(int,input().split())

div=a/b

from math import tan
from math import degrees
from math import pi

l=0
r=pi/2
for i in range(1000):
    mid=(l+r)/2
    t=tan(mid)
    if t<=div:
        f=a*b*b*t/2
    else:
        f=a*a/2*(2*b-a/t)
    if f<=x:
        l=mid
    else:
        r=mid

print(90-degrees(r))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/priority_queue.hpp>
#define lp(i, l, r) for (int i = l; i <= r; ++i)
#define rp(i, r, l) for (int i = r; i >= l; --i)
#define ls(i, s) for (int i = 0; s[i]; ++i)
#define rs(i, s) for (int i = strlen(s) - 1; i >= 0; --i)
#define lv(i, a) for (int i = 0; i < int(a.size()); ++i)
#define rv(i, a) for (int i = (int)a.size() - 1; i >= 0; --i)
#define fast ios::sync_with_stdio(0), cin.tie(0)
#define prec(a) cout << setprecision(a) << fixed
#define appl(f, a) for (auto i = begin(a); i != end(a); f, ++i)
#define many for (int T = -1; T < 0 && cin >> T, T--;)
#define rang(a) begin(a), end(a)
#define gene template <class T>
#define endl '\n'
#define asse assert
using namespace std;
using namespace __gnu_pbds;
gene T inf() { return numeric_limits<T>::max(); }
gene int tmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
gene int tmax(T &a, T b) { return b > a ? a = b, 1 : 0; }
gene auto min(const T &a) { return *min_element(rang(a)); }
gene auto max(const T &a) { return *max_element(rang(a)); }
gene auto sum(const T &a) { return accumulate(rang(a), 0); }
gene auto gath(const T &a, const vector<int> &b) {
    vector<typename T::value_type> r;
    for (auto i : b)
        r.push_back(a[i]);
    return r;
}
gene void sort(T &a) { sort(rang(a)); }
gene void reve(T &a) { reverse(rang(a)); }
gene void uniq(T &a) { sort(a), a.erase(unique(rang(a)), end(a)); }
gene void shuf(T &a) { random_shuffle(rang(a)); }
gene void merg(T l, T m, T r) { inplace_merge(l, m, r); }
// template <typename... T> void in(T &... a) { ((cin >> a), ...); }
// template <typename... T> void ou(T... a) { ((cout << a << ' '), ...); }
template <class F, class S> auto &operator>>(istream &s, pair<F, S> &a) {
    return s >> a.first >> a.second;
}
template <class F, class S> auto &operator<<(ostream &s, const pair<F, S> &a) {
    return s << '(' << a.first << ", " << a.second << ')';
}
gene auto &operator>>(istream &s, vector<T> &a) {
    for (int i = -1; i < 0 && (!a.size() && (cin >> i, a.resize(i), 0), i = 0),
             i < int(a.size());)
        s >> a[i++];
    return s;
}
gene auto &operator<<(ostream &s, const vector<T> &a) {
    lv(i, a) cout << a[i] << (i + 1 == int(a.size()) ? "" : " ");
    return s;
}
gene using bbst =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
gene using heap = __gnu_pbds::priority_queue<T, greater<T>, pairing_heap_tag>;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
int main() {
    fast, prec(12);
    vi a;
    cin >> a;
    int mi = a[0];
    int ans = 0;
    lv(i, a) {
        if (mi >= a[i])
            ++ans;
        tmin(mi, a[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){

        int N;
        cin >> N;
        string s;
        int c = 0;

        for(int i = 0; i < N; i++){
            cin >> s;
            if(s == "Y")
                c++;
        }
        if (c == 0)
            cout << "Three";
        else 
            cout << "Four";
        

}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    int one=0;
    one=n%10;
    if(one==3)
    printf("bon\n");
    else if(one==0 || one==1 || one==6 || one==8)
    printf("pon\n");
    else
     printf("hon\n");
    return 0;
}

Measured memory_bytes: 1620
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


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

int dp[3001][3001];
int presum[3001][3001];
int arr[3001];

int32_t main()
{
	c_p_c();
	int n, s; cin >> n >> s;

	for (int i = 1; i <= n; ++i)
		cin >> arr[i];

	dp[1][arr[1]] = 1;
	presum[1][arr[1]] = 1;

	for (int i = 2; i <= n; ++i)
	{
		for (int j = 1; j <= s; ++j)
		{
			dp[i][j] = dp[i - 1][j];

			//include i vala case;
			if (j == arr[i])
				dp[i][j] += i;

			else if (j > arr[i])
				dp[i][j] += dp[i - 1][j - arr[i]];

			presum[i][j] = presum[i - 1][j] + dp[i][j];
			presum[i][j] %= mod;
			dp[i][j] %= mod;
		}
	}

	/*for (int i = 1; i <= n; ++i)
		cout << dp[i][s] - dp[i - 1][s] << '\n';*/

	//cout << dp[2][0] << '\n';

	cout << presum[n][s] << '\n';

	return 0;
}

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

int main()
{
	long long a, b, c, d;
	cin >> a >> b >> c >> d;
	long long ac, ad, bc, bd;
	ac = a * c;
	ad = a * d;
	bc = b * c;
	bd = b * d;
	cout << max({ ac, ad, bc, bd }) << endl;
	return 0;
}


Measured memory_bytes: 3640
//#include <bits/stdc++.h>
//
//using namespace std;
//
//int main() {
//    int a[200];
//    bool vis[200];
//    memset(vis,0,sizeof(vis));
//    for(int i = 1; i <= 3; i++) cin >> a[i];
//    long long ans = 1e18;
//    for(int i = 1; i <= 3; i++) {
//        memset(vis,0,sizeof(vis));
//        vis[i] = 1;
//        for(int j = 1; j <= 3; j++) {
//        long long sum = 0;
//            if(!vis[j]) {
//                vis[j] = 1;
//                sum += abs(a[i] - a[j]);
//                for(int k = 1; k <= 3; k++) {
//                    if(!vis[k]) sum += abs(a[j] - a[k]),ans = min(ans,sum);;
//                }
//                vis[j] = 0;
//            }
//        }
//        vis[i] =0;
//
//    }
//    cout << ans << endl;
//    return 0;
//}


//
//
//#include <bits/stdc++.h>
//
//using namespace std;
//
//int main() {
//    string s,t;
//    while(cin >> s >> t) {
//        int len = s.size();
//        for(int i = 0; i < len; i++) {
//            string s1 = s.substr(0,1);
//            string s2 = s.substr(1,len - 1);
//            s2 += s1;
//            s = s2;
//            if(s2 == t){
//                printf("Yes\n");
//                return 0;
//            }
//        }
//        printf("No\n");
//    }
//    return 0;
//}







#include <bits/stdc++.h>

using namespace std;

const int maxn = 1e6 + 100;
int n,a[maxn];
int main() {
    while(cin >> n){
            long long ans = 0;
        for(int i = 1;i <= n;i++) cin >> a[i],ans += (a[i] - 1);
    cout << ans << endl;
    }
    return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

int res = 0;

void merge(vector<ll> &a, int left, int mid, int right)
{
    int n1 = mid - left, n2 = right - mid;
    vector<ll> L(n1 + 1), R(n2 + 1);
    for (int i = 0; i < n1; i++)
    {
        L[i] = a[left + i];
    }
    for (int i = 0; i < n2; i++)
    {
        R[i] = a[mid + i];
    }
    L[n1] = 1e15;
    R[n2] = 1e15;
    int i = 0, j = 0;
    for (int k = left; k < right; k++)
    {
        res++;
        if (L[i] <= R[j])
        {
            a[k] = L[i];
            i++;
        }
        else
        {
            a[k] = R[j];
            j++;
        }
    }
}

void mergeSort(vector<ll> &a, int left, int right)
{
    if (left + 1 < right)
    {
        int mid = (left + right) / 2;
        mergeSort(a, left, mid);
        mergeSort(a, mid, right);
        merge(a, left, mid, right);
    }
}

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

    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    mergeSort(a, 0, n);
    printv(a);
    cout << res << endl;
}


Measured memory_bytes: 10560
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <map>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

int main() {
  long long N, M;
  cin >> N >> M;

  vector< int > ok;

  long long maxL = 0;
  long long minR = N;

  long long l, r;
  for (int i = 0; i < M; i++) {
    cin >> l >> r;

    maxL = max(maxL, l);
    minR = min(minR, r);
  }

  long long answer = max(minR - maxL + 1, (long long)0);
  cout << answer << endl;

  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,fast-math,unroll-loops")
 
#include <bits/stdc++.h>
 
#define int ll
//#define double long double
#define endl '\n'
#define all(C) (C).begin(), (C).end()
#define rall(C) (C).rbegin(), (C).rend()
#define mp make_pair 
#define pb emplace_back
#define dbg(x) cerr << #x << " : " << x << endl
#define PI 3.1415926535
 
using namespace std;
        
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair <int, int>;
using pld = pair <ld, ld>;

/*
const ll MAX_MEM = 25e7;
char MEM[MAX_MEM];
ll MEM_POS = 0;
void* operator new(size_t x)
{
    auto ret = MEM + MEM_POS;
    MEM_POS += x;
    assert(MEM_POS < MAX_MEM);
    return ret;
}
void operator delete(void*)
{}
*/
        
template <class T>
istream& operator>> (istream &in, vector <T> &a)
{
    for (auto &i : a)
        in >> i;
    return in;
}
        
template <class T> 
ostream& operator<< (ostream &out, vector <T> a)
{
    for (auto &i : a)
        out << i << ' ';
    return out;
}
        
template <class T, class U>
istream& operator>> (istream &in, pair <T, U> &p)
{
    in >> p.first >> p.second;
    return in;
}
        
template <class T, class U>
ostream& operator<< (ostream &out, pair <T, U> p)
{
    out << p.first << " " << p.second << " ";
    return out;
}
        
inline void Start()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    //freopen("lol.in", "r", stdin);
    //freopen("lol.out", "w", stdout);
}
const int P = 2019;
signed main()
{
    Start();
    string s;
    cin >> s;
    reverse(all(s));
    int n = s.size();
    vector <int> hs(n);
    int ds = 1;
    vector <int> lol(P);
    lol[0] = 1;
    int ans = 0;
    for (int i = 0; i < n; ++i)
    {
        hs[i] = (i ? hs[i - 1] : 0) + (s[i] - '0') * ds;
        ds = (ds * 10) % 2019;
        hs[i] %= P;
        ans += lol[hs[i]];
        lol[hs[i]]++;
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 5124
#include<stdio.h>
#define MAX 100
#define INFTY 100000
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n , M[MAX][MAX];

int prim()
{
  int i,u,v, minv,sum=0;
  int d[MAX],p[MAX],color[MAX];

  for(i=0;i<n;i++){
    d[i]=INFTY;
    p[i]=-1;
    color[i]=WHITE;
  }
  d[0]=0;

  while(1){
    minv=INFTY;
    u=-1;
    for(i=0;i<n;i++){
      if(minv>d[i]&&color[i]!=BLACK){
	  u=i;
	  minv=d[i];
      }
    }
    if(u==-1)break;
    color[u]=BLACK;
    for(v=0;v<n;v++){
      if(color[v]!=BLACK&&M[u][v]!=INFTY){
	if(d[v]>M[u][v]){
	  d[v]=M[u][v];
	  p[v]=u;
	  color[v]=GRAY;
	}
      }
    }
  }
  for(i=0;i<n;i++){
    if(p[i]!=-1)sum+=M[i][p[i]];
  }

  return sum;
}

int main(){
  int i, j,e;
  scanf("%d",&n);
   for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&e);
      M[i][j]=(e==-1)?INFTY:e;
    }
  }
   printf("%d\n",prim());

   return 0;
}



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

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> p(N);
    for (int &pp : p)
    {
        cin >> pp;
    }
    vector<double> e(N);
    for (int i = 0; i < N; i++)
    {
        e[i] = (double)(p[i] * (p[i] + 1) / 2) / (double)p[i];
    }
    double ans = 0.;
    double current = 0.;
    queue<double> q;

    for (int i = 0; i < N; i++)
    {
        if (q.size() == K)
        {
            current -= q.front();
            q.pop();
        }
        q.push(e[i]);
        current += e[i];
        ans = max(ans, current);
    }
    cout << fixed << setprecision(8) << ans << endl;
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
//#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define mp make_pair
signed main(){
    int n; cin>>n;
    vector<int>v((int)pow(2,n),0);
    int range=(int)(pow(2,n));
    rep(i,range){
        cin>>v[i];
    }
    vector<int>res=v;
    for(int i=n;i>0;i--){
        vector<int>t;
        for(int j=0;j<(int)(pow(2,i));j+=2){
            if(res[j]==res[j+1])t.push_back(res[j]);
            else t.push_back(abs(res[j]-res[j+1]));
        }
        res=t;
    }
    cout<<res[0]<<endl;
}


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

const ll INF = 1e18L+7;

int main(){
int n,w;
cin>>n>>w;
vector<int> weight(n) , value(n);

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

ll sum=0;
for(auto aa:value){
	sum+=aa;
}

vector<ll> dp(sum+1,INF);

dp[0]=0;

for(ll i=0;i<n;i++){

    for(ll val_already = sum - value[i] ; val_already>=0 ; val_already--){

         if( dp[val_already]!=INF){
         	dp[val_already + value[i]] = min( dp[val_already + value[i]] , dp[val_already] + weight[i] );
         }

    }
}

ll ans=0;

for(ll i=sum ;i>=0;i--){
	if(dp[i]<=w){
		ans=i;break;
	}
}


cout<<ans;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
typedef long long i64;
int main(){
    string s;
    cin >> s;
    cout << s.substr(0,4) << " " << s.substr(4,8) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    map<string,int> memo;
    int n;
    cin>>n;
    string s;
    rep(i,n){
        cin>>s;
        memo[s]++;
    }
    int maxi=0;
    for(auto x:memo){
        int v=x.second;
        if(v>maxi) maxi=v;
    }
    for(auto y=memo.begin();y!=memo.end();y++){
        if(y->second==maxi) cout<<y->first<<endl;
    }
}

Measured memory_bytes: 19240
#include <bits/stdc++.h>
#define fi first
#define se second

typedef long long ll;
typedef std::pair < int, int > pr;

using std::cin;
using std::cout;

inline void up(int &x, int y) { x < y ? x = y : 0; }
inline void down(int &x, int y) { x > y ? x = y : 0; }
int n, a[100005];
inline int check(int len) {
    int L = n - len + 1, R = len;
    if ((a[R] - a[L - 1] == 0) || (a[R] - a[L - 1] == R - L + 1)) return 1;
    return 0;
}

std::string s;
int main() { 
    std::ios::sync_with_stdio(false), std::cin.tie(0);
    cin >> s;
    n = s.size();
    for (int i = 0; i < n; ++i) a[i + 1] = a[i] + (s[i] & 15);
    for (int i = n; i >= n / 2; --i) 
        if (check(i)) return cout << i << '\n', 0;
    return 0;
}

Measured memory_bytes: 4120
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n) ; i++)
constexpr auto INF = 2147483647;
typedef long long ll;
constexpr int MIN = -1;

int r, l, H, A[2000001];

void MaxHeapfy(int i){
  int lagest;
  l = i * 2;
  r = i * 2 + 1;
  lagest = i;
  if(l <= H && A[l] > A[lagest]) lagest = l;
  if(r <= H && A[r] > A[lagest]) lagest = r;

  if( lagest != i) {
    swap(A[lagest], A[i]);
    MaxHeapfy(lagest);
  }
}

void IncreaseKey(int h, int k){
  if(k < A[h]) return;
  A[h] = k;
  while(h > 1 && A[h/2] < A[h]){
    swap(A[h/2], A[h]);
    h = h/2;
  }
}

void Insert(int k){
  H++;
  A[H] = -INF;
  IncreaseKey(H, k);
}


int Extract(){
  int max = A[1];
  if(H < 1) return -MIN;
  A[1] = A[H--];
  MaxHeapfy(1);
  return max;
}

int main(){
  // Input
  string com;
  int k;
  while(com != "end"){
    cin >> com;
    if(com == "extract") cout <<  Extract() << endl ;
    else if(com == "insert"){
      cin >> k;
      Insert(k);
    }
  }

  return 0;
}


Measured memory_bytes: 6916
#include <bits/stdc++.h>
#define MAXN 100100
#define pii pair<int, int>
#define pb push_back
typedef long long ll;

using namespace std;

int A, B;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    cin >> A >> B;
    cout << "100 100" << endl;
    for(int i = 0; i < 50; i++){
		for(int j = 0; j < 100; j++){
			if(i % 2){
				cout << '#';
			} else{
				if(j % 2 and A-- > 1) cout << '.';
				else cout << '#';
			}
		}
		cout << endl;
    }
    for(int i = 0; i < 50; i++){
		for(int j = 0; j < 100; j++){
			if(i % 2 == 0){
				cout << '.';
			} else{
				if(j % 2 and B-- > 1) cout << '#';
				else cout << '.';
			}
		}
		cout << endl;
    }
}


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

class Dice{
public:
  int face[6];
  Dice(){}

  void roll_x(){ roll(0,3,5,2);}
  void roll_y(){ roll(0,1,5,4);}
  void roll_z(){ roll(1,2,4,3);}
  void roll(int i, int j, int k, int l){
    int t = face[i]; face[i] = face[j]; face[j] = face[k]; face[k] = face[l]; face[l] = t;
  }
};

bool check(Dice d1,Dice d2){
  for (int i = 0; i < 6; i++){
    if (d1.face[i] != d2.face[i]) return false;
  }
  return true;
}

bool equal(Dice d1, Dice d2){
  for(int j = 0; j < 6; j++){
    for(int k = 0; k < 4; k++){
      if(check(d1, d2)) return true;
      d1.roll_z();
    }

    if(check(d1,d2)) return true;
    if (j == 2) d1.roll_y();
    else d1.roll_x();
  }
  return false;
}

bool equal_all(Dice d[],int n){
  for(int i = 0; i < n-1; i++){
    for(int j = i+1; j < n; j++){
      if(equal(d[i],d[j])) return true;
    }
  }
  return false;
}

int main(){
  int n;
  cin >> n;
  // ???????????????????????????
  Dice d[100];
  for(int i = 0; i < n; i++){
    for(int j = 0; j < 6; j++){
    cin >> d[i].face[j];
    }
  }

  //??????
  if(equal_all(d,n)) cout << "No" << endl;
  else cout << "Yes" << endl;

  return 0;
}

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

int main() {
 int n;
  cin>>n;
  vector<vector<int>> a(2,vector<int>(n));
  for(int j=0;j<2;j++){
  	for(int i=0;i<n;i++) cin>>a[j][i];
  }
  int ans=0;
   for(int i=0;i<n;i++){
     int cnt=0,k=0;
 	 for(int j=0;j<n;j++){
        cnt+=a[k][j];
       if(j==i) {k=1;cnt+=a[1][j];}
     }
     ans=max(ans,cnt);
   }
  cout<<ans<<endl;
}
    

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

using namespace std;

int main()
{
    string s;
    cin >> s;
    int cnt=0;
    for(int i=0;i<3;i++)
    {
        if(s[i]=='1')
            cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
num_str = '1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51'
a = num_str.split(', ')
print(a[int(input()) - 1])


Measured memory_bytes: 2940
#include<stdio.h>
#include<string.h>
#define M 1000033
#define L 14
char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
  else return -1;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  //cout<<str<<" "<<sum<<endl;
  return sum;
}

int h1(int key){ return key%M; }
int h2(int key){ return 1+key%(M-1);}
int h3(int key,int i){return (h1(key)+i*h2(key))%M;}

int find(char str[]){
  int key=getKey(str),i=0;
  while(1){
    int idx=h3(key,i);
    if(H[idx][0]=='\0')return -1;
    if(strcmp(str,H[idx])==0)return 1; 
    i++;
  }
}
void insert(char str[]){
  int key=getKey(str),i=0;
  int idx=0;
  while(1){
      idx=h3(key,i);
      if(H[idx][0]=='\0')break;
      i++;
  }
  strcpy(H[idx],str);
}

int main(){
  int i, h,n;
  char str[L], com[9];
  for ( i = 0; i < M; i++ ) H[i][0] = '\0';
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%s %s", com, str);
    if ( com[0] == 'i' ){
      insert(str);
    } else {
      if (find(str)!=-1){
	printf("yes\n");
      } else {
	printf("no\n");
      }
    }
  }
  return 0;
}



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

int main(){
    int k, a, b;
    cin >> k >> a >> b;
    int f = -1;
    for (int i=a; i<=b; i++ ){
        if(i%k == 0){
            cout << "OK" << endl;
            return 0;
        }
    }
    if (f==-1){
        cout << "NG" << endl;
    }
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;

const int MAXN = 31;

lli dp[MAXN];

int main() {
  dp[0] = 1;
  for(int i = 0; i < MAXN; ++i) {
    for(int j = 1; j <= 3 && i+j < MAXN; ++j) {
      dp[i+j] += dp[i];
    }
  }
  for(lli n; cin >> n, n;) {
    cout << ( (dp[n]+9)/10 + 364 ) / 365 << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
import sys

SUITS = ['S', 'H', 'C', 'D']
SUIT_INDEX = {suit: i for i, suit in enumerate(SUITS)}

remain_cards = {(suit, rank) for rank in range(1, 14) for suit in range(4)}

lines = int(sys.stdin.readline())
for _ in range(lines):
    suit, rank = sys.stdin.readline().strip().split()
    suit = SUIT_INDEX[suit]
    rank = int(rank)
    remain_cards.remove((suit, rank))

for suit, rank in sorted(remain_cards):
    print(f'{SUITS[suit]} {rank}')



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

int main(){
  int N;
  cin>>N;
  vector<string> shiritori(N);
  map<string, int> hantei;
  bool seiritsu=true;
  for(int i=0; i<N; i++){
    if(i==0){
      string W;
      cin>>W;
      shiritori.at(i)=W;
      hantei[W]=1;
    }
    else{
      string W;
      cin>>W;
      shiritori.at(i)=W;
      string a = shiritori.at(i-1);
      string b = shiritori.at(i);
      if(hantei.count(W)) seiritsu=false;
      if(a.at(a.size()-1)!=b.at(0)) seiritsu=false;
      else hantei[W]=1;
    }
  } //i
  if(seiritsu) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int>a(n);
  int b[100001]={};
  for(int i=0;i<n;i++){
    cin >> a[i];
    b[a[i]]++;
  }
  sort(b,b+100001);
  int k;
  k=*lower_bound(b,b+100001,1);
  //cout << k << endl;
  int co=0;
  while(1){
    if(co!=0){
      int kk=1;
      for(int i=2;i*i<=k;i++){
	if(k%i==0){
	  kk=k/i;
	  break;
	}
      }
      k=kk;
    }
    
    // cout << k << endl;
    if(k==1)break;
    int f=0;
    if(n%k!=0){
      co++;
      continue;
    }
    for(int i=0;i<n/k;i++){
      if(i+n/k>=n)break;
      if(a[i+n/k]!=a[i]){
	f=1;
	break;
      }
    }
    if(f==0)break;
    co++;
  }
  cout << k << endl;
  return 0;
}

Measured memory_bytes: 3892
import sys
from itertools import permutations
from math import factorial

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def distance2(x1, y1, x2, y2):
    return ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5


def main():
    N = int(readline())
    C = [tuple(map(int, readline().split())) for _ in range(N)]

    dist = [[0] * N for _ in range(N)]
    for i in range(N):
        for j in range(i + 1, N):
            dist[i][j] = dist[j][i] = distance2(C[i][0], C[i][1], C[j][0], C[j][1])

    ans = 0
    for perm in permutations(range(N)):
        for i in range(N - 1):
            ans += dist[perm[i]][perm[i + 1]]

    print(ans / factorial(N))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
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;}
const ll LLINF = 1LL<<60;
const int INF = 1<<29;
const int MOD = 1000000007;
 
void add(long long &a, long long b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    double ans;
    int n;
    cin >> n;
    vector<int> A(n);
    rep(i,n) cin >> A[i];
    rep(i,n) ans += 1.0/A[i];
    cout << 1.0/ans << endl;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;
typedef pair<int,int> ii;

#define MAX 200010
int par[MAX];

int find(int x) {
  if( x == par[x] ) return x;
  return par[x] = find(par[x]);
}

void unite(int x,int y) {
  x = find(x), y = find(y);
  if( x != y ) par[x] =y;
}

void solve() {

}

int main() {
  int V,E;
  cin >> V >> E;
  rep(i,V) par[i] = i;
  int s,t;
  rep(i,E) {
    cin >> s >> t;
    --s, --t;
    unite(s,t);
  }
  map<int,int> S;
  rep(i,V) ++S[find(i)];
  int maxi = 0;
  for(auto tmp : S) {
    maxi = max(maxi,tmp.snd);
  }
  cout << maxi << endl;

  return 0;
}


Measured memory_bytes: 13712
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] <= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) left = mid;
		else right = mid;
	}
	/* left は条件を満たす最大の値、right は条件を満たさない最小の値になっている */
	return left;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int main() {
	int x;
	cin >> x;
	if (x == 0) {
		cout << 1;
	}
	else {
		cout << 0;
	}
}

Measured memory_bytes: 3504
H,W = map(int,input().split())
S = [input() for i in range(H)]

### その1
"""
# 4方向の累積和をとって計算する
Rs = [[0]*W for i in range(H)]
Ls = [[0]*W for i in range(H)]
Ds = [[0]*W for i in range(H)]
Us = [[0]*W for i in range(H)]

for i in range(H):
    tmp = 0
    # 順方向(左にどれだけ伸びてるか)
    for j in range(W):
        if S[i][j] == '#':
            tmp = 0
        else:
            tmp += 1
            Ls[i][j] = tmp
    tmp = 0
    # 逆方向(右にどれだけ伸びてるか)
    for j in reversed(range(W)):
        if S[i][j] == '#':
            tmp = 0
        else:
            tmp += 1
            Rs[i][j] = tmp

# 行列転置 順番逆にするだけ
for j in range(W):
    tmp = 0
    # 順方向 上にどれだけ伸びているか
    for i in range(H):
        if S[i][j] == '#':
            tmp = 0
        else:
            tmp += 1
            Us[i][j] = tmp
    tmp = 0
    # 順方向 下にどれだけ伸びているか
    for i in reversed(range(H)):
        if S[i][j] == '#':
            tmp = 0
        else:
            tmp += 1
            Ds[i][j] = tmp

ans = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == '#': 
            continue
        # 上下左右に伸びた数を重なっている部分引く
        tmp = Rs[i][j] + Ls[i][j] + Ds[i][j] + Us[i][j] - 3
        ans = max(ans, tmp)
print(ans)
"""

# その2
"""
左・上からゴリゴリ攻めていくパターン
一回通ったかどうかのフラグが必要
"""

cnt = [[0] * (W+1) for i in range(H+1)]
# 横
for i in range(H):
    done = [False] * (W+1)
    for j in range(W):
        l = 0
        if done[j]: continue
        if S[i][j] == ".":
            while j+l < W:
                if S[i][j+l] == ".":
                    l += 1
                else:
                    break
        for k in range(j,j+l):
            cnt[i][k] += l
            done[k] = True

# 縦
for j in range(W):
    done = [False] * (H+1)
    for i in range(H):
        l = 0
        if done[i]: continue
        if S[i][j] == ".":
            while i+l < H:
                if S[i+l][j] == ".":
                    l += 1
                else:
                    break
        for k in range(i,i+l):
            cnt[k][j] += l
            done[k] = True

ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans,cnt[i][j])
print(ans-1)

Measured memory_bytes: 103128
#include <iostream>
#include <string>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)

int xb[7][3] = {
	{1, 0, 1},
	{0, 0, 0},
	{1, 2, 3},
	{0, -1, -1},
	{1, 1, 2},
	{0, 1, 1},
	{1, 0, -1}
};

int yb[7][3] = {
	{0, 1, 1},
	{1, 2, 3},
	{0, 0, 0},
	{1, 1, 2},
	{0, 1, 1},
	{1, 1, 2},
	{0, 1, 1}
};

int main() {
	string field[8];
	while(getline(cin, field[0])) {
		for(int i = 1; i < 8; i++) getline(cin, field[i]);

		char ans = '\0';
		rep(y,8) {
			rep(x,8) {
				if(field[y][x] == '1') {
					// cerr << "x: " << x << " " << "y: " << y << endl;
					rep(i,8) {
						bool f = true;
						rep(j,3) {
							int nx = x + xb[i][j];
							int ny = y + yb[i][j];
#if 1
							if(!(0 <= nx && nx < 8 && 0 <= ny && ny < 8 && field[ny][nx] == '1')) {
								f = false;
								break;
							}
#endif
						}
						if(f) {
							ans = 'A' + i;
							goto END;
						}
					}
				}
			}
		}
	END:
		cout << ans << endl;
		getline(cin, field[0]);
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		a -= 2 * b;
		if(a > 0) {
			System.out.println(a);
		} else {
			System.out.println(0);
		}

	}

}


Measured memory_bytes: 21844
#include<stdio.h>
#include<string.h>
int main()
{
    int len=0,i,a;
    char s[101];
    scanf("%s",&s);
    len=strlen(s);
    a=0;
    for(i=0;i<len;i++)
    {
        if(s[i]=='7')
        a=1;
    }
    if(a==1)
        printf("Yes\n");
    else
    printf("No\n");
    return 0;

}

Measured memory_bytes: 1624