akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
#include <omp.h>
using namespace std;
#define eps 0.000001
#define LONG_INF 10000000000000
#define GOLD 1.61803398874989484820458
#define seg_size 65536*4
#define REP(i,n) for(long long i = 0;i < n;++i)
unsigned long xor128() {
	static unsigned long x = time(NULL), y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}



int gogo[2000][2000] = {};
vector<pair<int,int>> nexter;
// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long H,W;
    cin >> H >> W;
    REP(i,H){
        REP(q,W)
        gogo[i][q] = 100000;
    }
    for(int i = 0 ; i < H ; i++){
        string s;
        cin >> s;
        REP(q,W){
            if(s[q] == '#'){
                nexter.push_back(make_pair(i,q));
                gogo[i][q] = 0;
            }
        }
    }
    int now_itr = 0;
    while(nexter.size() != now_itr){
        pair<int,int> now = nexter[now_itr];
        now_itr++;
        int xe[4] = {0,0,1,-1};
        for(int i = 0;i < 4;++i){
            int now_x = now.first + xe[i];
            int now_y = now.second + xe[3-i];
            if(now_x >= 0&&now_x < H&&now_y >= 0&&now_y < W){
                if(gogo[now_x][now_y] > gogo[now.first][now.second]+1){
                    gogo[now_x][now_y] = gogo[now.first][now.second]+1;
                    nexter.push_back(make_pair(now_x,now_y));
                }
            }
        }
    }
    int ans = 0;
    REP(i,H){
        REP(q,W){
            ans = max(ans,gogo[i][q]);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 18668
A,B,C,X,Y = list(map(int,input().split()))

if C*2 <= A+B:
    ans = 0
    ans += C*2*min(X,Y)
    ans += min(A,C*2)*(X-Y) if Y<X else min(B,C*2)*(Y-X)
    print(ans)
else:
    print(A*X+B*Y)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

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

  int k;
  string s;
  cin >> k >> s;
  if (s.size() <= k) {
    cout << s << endl;
  } else {
    for (int i = 0; i < k; ++i) {
      cout << s[i];
    }
    for (int i = 0; i < 3; ++i) {
      cout << '.';
    }
    cout << endl;
  }
}

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

public class Main {

	public static void main(String[] args) {
		//		new Main().solveA();
		//		new Main().solveB();
		new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		String topping = "";

		try {
			scanner = new Scanner(System.in);
			topping = scanner.next();

			int res = 700;

			for (int i = 0; i < topping.length(); i++) {
				switch (topping.charAt(i)) {
				case 'o':
					res += 100;
					break;
				case 'x':
					break;

				}
			}

			System.out.println(res);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int numN = 0;
		int numX = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();
			numX = scanner.nextInt();

			int[] wk = new int[numN];

			int res = 0;
			for (int i = 0; i < numN; i++) {
				wk[i] = scanner.nextInt();
				res++;
				numX -= wk[i];
			}

			Arrays.sort(wk);

			boolean isExit = false;
			while (!isExit) {
				if (numX >= wk[0]) {
					numX -= wk[0];
					res++;
				} else {
					isExit = true;
				}
			}

			System.out.println(res);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		int numA = 0;
		int numB = 0;
		int numC = 0;
		int numX = 0;
		int numY = 0;

		try {
			scanner = new Scanner(System.in);
			numA = scanner.nextInt();
			numB = scanner.nextInt();
			numC = scanner.nextInt();
			numX = scanner.nextInt();
			numY = scanner.nextInt();

			int sabun0 = Math.abs(numX - numY);
			int sabun1 = Math.min(numX, numY);

			int res = 0;
			if (numA + numB > numC * 2) {
				res += sabun1 * (numC * 2);
			} else if (numA + numB == numC * 2) {
				res += sabun1 * (numC * 2);
			} else if (numA + numB < numC * 2) {
				res += sabun1 * (numA + numB);
			}

			if (numX > numY) {
				if (numA <= numC * 2) {
					res += (numX - sabun1) * numA;
				} else {
					res += (numX - sabun1) * (numC * 2);
				}
			} else if (numX < numY) {
				if (numB <= numC * 2) {
					res += (numY - sabun1) * numB;
				} else {
					res += (numY - sabun1) * (numC * 2);
				}
			}

			System.out.println(res);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

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

template<typename T>
istream& operator >> (istream& istr, vector<T>& vec){
    for(T& x: vec) istr >> x;
    return istr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<T>& vec){
    if(!vec.empty()){
        ostr << vec.front();
        for(auto itr = ++vec.begin(); itr != vec.end(); itr++)
            ostr << " " << *itr;
    }
    return ostr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<vector<T>>& mat){
    if(!mat.empty()){
        ostr << mat.front();
        for(auto itr = ++mat.begin(); itr != mat.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, vector<pair<T,U>>& vpr){
    if(!vpr.empty()){
        auto x = vpr.front();
        // ostr << x.first << " " << x.second;
        ostr << x.first+1 << " " << x.second+1;
        for(auto itr = ++vpr.begin(); itr != vpr.end(); itr++){
            x = *itr;
            // ostr << endl << x.first << " " << x.second;
            ostr << endl << x.first+1 << " " << x.second+1;
        }
    }
    return ostr;
}

typedef long long ll;
typedef vector<ll> vll;
// vll x(n); x[i]=a;
typedef vector<pair<ll,ll>> vpll;
// vpll x(n); x[i]={a,b}; x[i].first/second;
typedef vector<vector<ll>> vvll;
// vvll x(m,vi(n)); x[i][j]=a;

#define REP(i,n) for(ll i=0; i<(n); i++)
#define RREP(i,n) for(ll i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORR(i,a,b) for(ll i=(b)-1; i>=(a); i--)
#define dump(x) cout << #x << " = " << (x) << endl
#define all(x) (x).begin(),(x).end()
// sort(all(x));

void spanning(vector<vpll>& p, vll& q, vpll& a, vpll& z, ll n){
    int m;
    q[n] = 0;
    REP(i,p[n].size()){
        m = p[n][i].first;
        if(q[m]){
            z.push_back({m, n});
            a[p[n][i].second] = {-1, -1};
            spanning(p, q, a, z, m);
        }
    }
}

int main(){
    ll n, m, c, d;
    cin >> n >> m;

    vll q(n);
    // q : 到達情報
    vpll a(m), z;
    // a : すべての辺
    // z : 全域木
    vector<vpll> p(n);
    // p : 連結情報(頂点,辺)

    REP(i,n) q[i] = 1;
    REP(i,m){
        cin >> c >> d;
        c -= 1; d -= 1;
        a[i] = {c, d};
        p[c].push_back({d, i});
        p[d].push_back({c, i});
    }

    if(m % 2){
        cout << -1 << endl;
        return 0;
    }

    spanning(p, q, a, z, 0);

    REP(i,n) q[i] = 0;
    REP(i,m){
        if(a[i].first == -1) continue;
        q[a[i].first] += 1;
    }

    RREP(i,z.size()){
        if(q[z[i].first] % 2){
            a.push_back({z[i].first, z[i].second});
            q[z[i].first] += 1;
        }
        else{
            a.push_back({z[i].second, z[i].first});
            q[z[i].second] += 1;
        }
    }

    REP(i,a.size()){
        if(a[i].first != -1){
            cout << a[i].first+1 << " " << a[i].second+1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 24916
#include <cstdio>
#include <utility>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

#define gcu getchar_unlocked
#define ii inline int in
#define is inline bool scan
ii(int c) {
	int n = 0;
	bool minus = false; if (c == '-') minus = true, c = gcu();
	do {n = 10 * n + (c - '0'), c = gcu();} while (c >= '0');
	//return n; }
	return minus ? -n : n; }
ii() {return in(gcu());}
is(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
is(char &c){c=gcu();gcu();return c!=EOF;}
//is(string &s){int c;
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#undef ii
#define pcu putchar_unlocked
template <typename T>
void out(T n) {
	static char buf[20];
	char *p = buf;
	if(n < 0) pcu('-'), n *= -1;
	if (!n) *p++ = '0';
	else while (n) *p++ = n % 10 + '0', n /= 10;
	while (p != buf) pcu(*--p); }
void out(const char *s){while(*s)pcu(*s++);}
void out(char c){pcu(c);}
//void out(string &s){for (char c: s) pcu(c);}
template <typename head, typename... tail>
void out(head&& h, tail&&... t){out(h);out(move(t)...);}
//template <typename T>
//void out(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
#undef svo

int main() {
	vector<int> v(10);
	for (int i = 0; i < 2; i++) {
		for(int &s: v)
			s = in();
		sort(v.rbegin(), v.rend());
		out(accumulate(v.begin(), v.begin() + 3, 0), i ? '\n' : ' ');
	}
}


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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;
const long long MOD = (long long)1e9 + 7;

int n, m, q;
vector<int> a, b, c, d, t;

int calc(vector<int> t){
    int res = 0;
    for(int i = 0; i < q; i++){
        if(t[b[i]] - t[a[i]] == c[i]){
            res += d[i];
        }
    }
    return res;
}


int dfs(int p, int x){
    if(p == n){
        return calc(t);
    }
    int res = 0;
    for(int i = x; i <= m; i++){
        t[p] = i;
        res = max(res, dfs(p + 1, i));
    }
    return res;
}


int main(){
    cin >> n >> m >> q;
    a = vector<int>(q);
    b = vector<int>(q);
    c = vector<int>(q);
    d = vector<int>(q);
    t = vector<int>(n);
    for(int i = 0; i < q; i++){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--;
        b[i]--;
    }
    int ans = dfs(0, 1);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3648
a,b,c = (int(i) for i in input().split())

"""
ra + rb < rc
a + b + 2rab < c
(c - a - b > 0) and (2rab < c - a - b)
(c - a - b > 0) and (4ab < (c - a - b) ** 2)
249999999, 250000000, 999999998
"""

if (0 < (c-a-b)) and (4*a*b < (c-a-b)**2):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
priority_queue <int,vector<int>,greater<int> > q;
const int maxn=1e5+5;
struct node
{
    int b,c;
}a[maxn];
bool cmp(node &x,node &y)
{
    return x.c>y.c||(x.c==y.c&&x.b>y.b);
}
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(ll i=1;i<=n;i++)
    {
        int x;
        scanf("%d",&x);
        q.push(x);
    }
    for(int i=1;i<=m;i++)
    {
        scanf("%d%d",&a[i].b,&a[i].c);
    }
    sort(a+1,a+1+m,cmp);
    for(int i=1;i<=m;i++)
    {
        int bi=a[i].b;
        int ci=a[i].c;
        while(bi--)
        {
            int t=q.top();
            if(t<ci)
            {
                q.pop();
                q.push(ci);
            }
            else
                break;
        }
    }
    ll ans=0;
    while(!q.empty())
    {
        ans+=q.top();
        q.pop();
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1528
using System;

public class hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        var b = Array.ConvertAll(line, int.Parse);
        Array.Sort(b);
        var count = 0;
        for (int i = 0; i < n; i++)
            if (a[i] == b[i]) count++;
        if (count == n) { Console.WriteLine(0); goto end; }
        var q = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < q; i++)
        {
            line = Console.ReadLine().Trim().Split(' ');
            var x = int.Parse(line[0]) - 1;
            var y = int.Parse(line[1]) - 1;
            if (a[x] == b[x]) count--;
            if (a[y] == b[y]) count--;
            swap(a, x, y);
            if (a[x] == b[x]) count++;
            if (a[y] == b[y]) count++;
            if (count == n) { Console.WriteLine(i + 1); goto end; }
        }
        Console.WriteLine(-1);
        end:;
    }
    public static void swap (int[] a, int x, int y)
    {
        var w = a[x];
        a[x] = a[y];
        a[y] = w;
    }
}




Measured memory_bytes: 49784
from collections import defaultdict
mod = 998244353

n = int(input())
ds = list(map(int, input().split()))
if ds[0] != 0:
    print(0)
    exit(0)
ds = ds[1:]
dd = defaultdict(int)
dmax = -1
for d in ds:
    if d <= 0:
        print(0)
        exit(0)
    dd[d] += 1
    dmax = max(d, dmax)

for d in range(1, dmax+1):
    if d not in dd:
        print(0)
        exit(0)

total = 1
dd[0] = 1
for d in range(1, dmax+1):
    total *= (dd[d-1] ** dd[d])
    total = total % mod
print(total)

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

using namespace std;

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

  vector<int> V(N);
  for (int i=0; i<N; i++){ cin >> V[i]; }
  vector<int> C(N);
  for (int i=0; i<N; i++){ cin >> C[i]; }

  int ans = 0;
  for (int i=0; i<N; i++){
    if (V[i] > C[i]){
      ans += V[i]-C[i];
    }
  }
  cout << ans << endl;
}

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

int main() {
    int n, l;
    string s;
    cin >> n >> l;
    vector <string> v;
    for(int i  = 0; i < n; i++) {
        cin >> s;
        v.push_back(s);
    }
    sort(v.begin(), v.end());
    for(int i = 0; i < n; i++) {
        cout <<v[i];
    }
}

Measured memory_bytes: 3608
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int INF = pow(2,29);
const ll MOD = 998244353;

const int N_MAX = pow(10,5);

// factorial(階乗)の計算

ll fac[N_MAX+1] = {};

ll c_fac(int n) {
  if (fac[n]!=0) return fac[n];
  if (n==0) return fac[n]=1;
  return fac[n] = (c_fac(n-1)*n)%MOD;
}

// inverse(逆元)の計算

ll inv(ll a,ll m) {
  ll b = m, x = 1, y = 0;
  while (b!=0) {
    ll d = a/b;
    a -= b*d; swap(a, b);
    x -= y*d; swap(x, y);
  }
  return x>=0 ? x : x+m;
}

// combinataionの計算

ll nck(ll n, ll k) { 
  c_fac(n);
  if (n<k) return 0;
  ll nume = fac[n];
  ll deno = ( inv(fac[n-k],MOD) * inv(fac[k],MOD) ) % MOD;
  return ( nume * deno ) % MOD;
}

int main() {
  int K, N; cin >> K >> N;
  ll sum = nck(K+N-1,N);

  ll result[K]={};
  rep(i,K) {
    ll r = sum, pat = (min(i+1, 2*K-(i+1))+1)/2;
    int use = 1, left = N-2;
    while (use<=pat && left>=0) {
      ll tmp = nck(K+left-1,left) * nck(pat, use); tmp %= MOD;
      r += tmp * pow(-1,use%2); r %= MOD;
      use++; left -= 2;
    }
    result[i] = ( r%MOD + MOD ) % MOD;
  }
  rep(i,2*K-1) {
    int pos = min(i, 2*(K-1)-i);
    cout << result[pos] << endl;
  }
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <iomanip>
#include <cmath>
using namespace std;
const int MOD = 1e9+7;
using ll = long long;
using vi = vector<int>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(x) x.begin(), x.end()
int main() {
  ll a,b,tmp,Min;
  int ans;
  cin >> a >> b;
  vector<vector<ll>> stu(a, vector<ll>(2));
  vector<vector<ll>> chp(b, vector<ll>(2));
  for (int i = 0; i < a; i++) {
    for (int j = 0; j < 2; j++) {
      cin >> stu.at(i).at(j);
    }
  }
  for (int i = 0; i < b; i++) {
    for (int j = 0; j < 2; j++) {
      cin >> chp.at(i).at(j);
    }
  }
  for (int i = 0; i < a; i++) {
    Min = 100000000000;
    for (int j = 0; j < b; j++) {
      tmp = 0;
      for (int k = 0; k < 2; k++) {
        tmp += abs(stu.at(i).at(k) - chp.at(j).at(k));
      }
       if(Min>tmp){
         Min = tmp;
         ans = j + 1;
       }
    }
      cout << ans <<  endl;;
                   }
  }

Measured memory_bytes: 3640
N = gets.to_i
as = gets.split.map(&:to_i)

hash = {}
free = 0
as.each do |a|
    if a < 3200
        hash[a/400] = true
    else
        free += 1
    end
end

fixed = hash.length
puts "#{[fixed, 1].max} #{fixed + free}"

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;

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

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin>>n;
    int a[n];
    for (int i=0;i<n;++i)
    {
        cin>>a[i];
    }
    if (n%2==0)
    {
        ll f=0,s=0,newF,newS;
        for (int i=0;i<n;i+=2)
        {
            newF=f+a[i];
            newS=max(f,s)+a[i+1];
            f=newF;
            s=newS;
        }
        cout<<max(f,s);
        return 0;
    }
    ll dp[n][2][2];
    dp[0][0][0]=0;
    dp[1][0][0]=0;
    dp[0][0][1]=0;
    dp[1][0][1]=0;
    dp[0][1][1]=a[0];
    dp[1][1][1]=a[1];
    dp[0][1][0]=-1000000000000000000;
    dp[1][1][0]=-1000000000000000000;
    for (int i=2;i<n-1;i+=2)
    {
        dp[i][0][0]=max(dp[i-1][1][1],dp[i-1][1][0]);
        dp[i][0][1]=dp[i-1][0][0]+a[i];
        dp[i][1][0]=-1000000000000000000;
        dp[i][1][1]=max(dp[i-1][1][0],dp[i-2][1][1])+a[i];
        dp[i+1][0][0]=max(dp[i][0][0],dp[i][0][1]);
        dp[i+1][0][1]=dp[i-1][0][0];
        dp[i+1][0][1]+=a[i+1];
        dp[i+1][1][0]=dp[i][1][1];
        dp[i+1][1][1]=max(dp[i-1][1][1],dp[i-2][1][1]);
        dp[i+1][1][1]+=a[i+1];
    }
    cout<<max(max(dp[n-3][0][0],dp[n-3][0][1])+a[n-1],max(dp[n-3][1][1],dp[n-2][1][1]));
    return 0;
}

Measured memory_bytes: 10636
uses crt;
var     n,i,j: byte;
ok: boolean;
begin
read(n);
ok:=false;
for i:=1 to 9 do
if n mod i =0 then if n div i<10 then begin ok:=true; break; end;
if ok=true then write('Yes') else write('No');
readln;
readln;
end.


Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;

long long c[100][100];	//combination


int main(){
	int l,k;
	scanf("%d %d", &l, &k);

	long long ans = 0;

	for(int i=0;i<100;i++){
		c[i][0] = 1;
		c[i][i] = 1;
	}
	for(int i=1;i<100;i++){
		for(int j=1;j<i;j++){
			c[i][j] = c[i-1][j] + c[i-1][j-1];
		}
	}

	/*
	 *  x : number of dark thin disk
	 *  y : number of dark k cm dick
	 *  	-> number of white thin disk = x + y - 1
	 * 		answer is sum of (x+y C x)
	 *  1*x + (k+1)*y + 1*(x+y-1) <= l
	 *  	-> y <= (l+1-2*x)/(k+1)
	 *
	 */

	for(int x=0;l+1>=2*x;x++){
		int y = (l+1-2*x)/(k+1);
		for(int z=0;z<=y;z++){
			if(x!=0 || z!=0) ans += c[x+z][x]; // add x+z C x
		}
	}

	printf("%lld\n",ans);

	return 0;
}

Measured memory_bytes: 2832
#include<stdio.h>
        #define N 100

        int n,A[N][N],cp[N];

        void Breadth(int pl,int res)
        {
          int i;

          res++;
          cp[pl]=res;

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

            if(A[pl][i]==1){
              if(cp[i]<=res && cp[i]>=0)continue;
              Breadth(i,res);
            }

          }
        }

        int main(void){
          int i,j,k,x,y;

          scanf("%d",&n);

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

            for(j=0; j<n; j++){

              A[i][j]=0;

            }

          }
          for(i=0; i<n; i++){
            scanf("%d %d",&x,&k);
            x--;

            for(j=0; j<k; j++){
              scanf("%d",&y);
              y--;
              A[x][y]=1;
            }
          }
          for(i=0; i<n; i++){
            cp[i]=-1;
          }
          Breadth(0,-1);
          for(i=0; i<n; i++){
            printf("%d %d\n",i+1,cp[i]);
          }
          return 0;
        }



Measured memory_bytes: 2096
import math

def main():
    n,d = map(int, input().split())
    kyori = 0
    cnt = 0
    
    xy = [map(int, input().split()) for _ in range(n)]
    x, y = [list(i) for i in zip(*xy)]
    for i in range(n):
        kyori = math.sqrt(x[i]**2 + y[i]**2)
        if kyori <= d:
            cnt += 1
    print(cnt)
            
    
    
if __name__ == "__main__":
    main()


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

int main() {
  int n, m; cin >> n >> m;
  int count = 0;
  int Max, Min;
  vector<int> l(m), r(m);
  
  for(int i=0; i<m; i++){
    cin >> l[i] >> r[i];
  }
  sort(l.begin(), l.end(), greater<int>());
  sort(r.begin(), r.end());
  Max = l[0];
  Min = r[0];
  
  for (int i=1; i<n+1; i++) {
    if (i >= Max && i <= Min) {
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
	int N;
	cin>>N;
	vector<int> T(N), A(N);
	for(int i=0;i<N;i++){
		cin>>T[i];
	}
	for(int i=0;i<N;i++){
		cin>>A[i];
	}
	vector<int> minT(N),maxT(N),minA(N),maxA(N);
	minT[0] = T[0];
	maxT[0] = T[0];
	minA[N-1] = A[N-1];
	maxA[N-1] = A[N-1];
	for(int i=1;i<N;i++){
		if(T[i] == T[i-1]){
			minT[i] = 1;
			maxT[i] = maxT[i-1];
		}
		else{
			minT[i] = T[i];
			maxT[i] = T[i];
		}
	}
	for(int i=N-2;i>=0;i--){
		if(A[i] == A[i+1]){
			minA[i] = 1;
			maxA[i] = maxA[i+1];
		}
		else{
			minA[i] = A[i];
			maxA[i] = A[i];
		}
	}
	long long int res = 1;
	long long int mod  = 1000000007;
	for(int i=0;i<N;i++){
		if(maxT[i] < minA[i] || maxA[i] < minT[i]){
			cout<<0<<endl;
			return 0;
		}
		//cout<<min(maxA[i],maxT[i])-max(minA[i],minT[i])<<endl;
		res = (res * ((min(maxA[i],maxT[i])-max(minA[i],minT[i]) + 1) % mod)) % mod;
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define ll long long int 
#define RD(v,n) for(ll i =0;i<n;i++ ) cin>>v[i]
#define bolt ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

int main()
{
	bolt;
    ll n,m;
    cin>>n>>m;
    cout<<n*(n-1)/2+m*(m-1)/2<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define inf 10000000000

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

    char a, b;
    cin >> a >> b;
    cout << ((a == 'H' && b == 'H' || a == 'D' && b == 'D') ? 'H' : 'D') << endl;
}


Measured memory_bytes: 256
//by Top1
#include <bits/stdc++.h>
     
#define f first
#define s second
#define int long long
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>
#define pll pair <long, long>
#define mp make_pair
#define pb push_back
#define pf push_front
#define pp pop_back
#define rev reverse
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define forn(i, a, b) for (int i = a; i <= b; i++)
#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define nxtp next_permutation
#define pvtp prev_permutation
#define KZ return 
#define x1 x21212121
#define y1 y21212121
#define sqr(x) x * x 
 
const int inf = INT_MAX;
const int mod = 1e9 + 7;
const int maxn = 6e5 + 111;
     
using namespace std;

int n, k, a[maxn], b[maxn], c[maxn], dp[5][maxn], q;

void solve(){    
	cin >> n;

	for (int i = 1; i <= n; i++)
		cin >> a[i] >> b[i] >> c[i];

	dp[1][1] = a[1];
	dp[2][1] = b[1];
	dp[3][1] = c[1];

	for (int i = 2; i <= n; i++){
		dp[1][i] = a[i] + max(dp[2][i - 1], dp[3][i - 1]);
		dp[2][i] = b[i] + max(dp[1][i - 1], dp[3][i - 1]);
		dp[3][i] = c[i] + max(dp[2][i - 1], dp[1][i - 1]);
	}

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

main(){
    boost;
	    
	q = 1;

	while (q--){
		solve();
	}
}


Measured memory_bytes: 16640
#include <bits/stdc++.h>
#define CYES cout << "Yes" \
                  << "\n";
#define CNO cout << "No" \
                 << "\n";
#define CFS           \
    cin.tie(nullptr); \
    ios::sync_with_stdio(false);
#define CST(x) cout << fixed << setprecision(x);
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
const int IINF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = (int)1e9 + 7;
const string MM = " ";

struct UnionFind {
    vector<int> _root;
    vector<int> _size;

    explicit UnionFind(int n) : _root(n) {
        for (int i = 0; i < n; i++)
            _root[i] = i;
        _size.assign(n, 1);
    }

    // 要素xの親を取得(経路圧縮もする)
    int root(int x) {
        if (_root[x] == x)
            return x;
        return _root[x] = root(_root[x]);
    }

    // 要素xとyが同じ木にいるかどうかを返す
    bool same(int x, int y) {
        return root(x) == root(y);
    }

    // 要素xとyが属する木を結合する
    // サイズの小さい木を大きい木につなぐ
    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry)
            return;
        if (size(rx) < size(ry))
            swap(rx, ry);
        _root[ry] = rx;
        _size[rx] += _size[ry];
    }

    // 要素xが属する木の要素数を返す
    int size(int x) {
        return _size[root(x)];
    }
};

int main()
{
    CFS
    int n, m, k;
    cin >> n >> m >> k;
    UnionFind relation(n);
    vector<int> f(n, 0);
    vector<pii> b;
    for (size_t i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        f[a]++;
        f[b]++;
        relation.unite(a, b);
    }
    for (size_t i = 0; i < k; i++)
    {
        int c, d;
        cin >> c >> d;
        c--;
        d--;
        b.emplace_back(c, d);
    }
    vector<int> ans(n);
    for (size_t i = 0; i < n; i++)
    {
        ans[i] = relation.size(i) - f[i] - 1;
    }
    for (size_t i = 0; i < b.size(); i++)
    {
        int c, d;
        tie(c, d) = b[i];
        if (relation.same(c, d)) {
            ans[c]--;
            ans[d]--;
        }
    }
    
    for (size_t i = 0; i < n; i++)
    {
        cout << ans[i] << MM;
    }
    cout << "\n";
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9+7;
Int INF = 1e18;
double EPS = 0.00000001;
//Int mod = 998244353;

vector<priority_queue<Int>> v(100005);

int main() {
    Int n, m;
    cin >> n >> m;

    for (Int i = 0; i < n; i++) {
        Int a, b;
        cin >> a >> b;
        v[a].push(b);
    }
    Int res = 0;
    priority_queue<pair<Int, Int>> q;
    for (Int i = 1; i <= m; i++) {
        
        if (!v[i].empty()) q.push({v[i].top(), i});
        if (q.empty()) continue;
        pair<Int, Int> p = q.top();
        q.pop();
        res += p.fi;
        v[p.se].pop();
        if (!v[p.se].empty()) {
            q.push({v[p.se].top(), p.se});
        }
    }
    dump(res);
    return 0;
}

Measured memory_bytes: 6528
#include<iostream>
using namespace std;
int main(void){
  unsigned long long k,a,b,ans=0;
  cin>>k>>a>>b;
  if(a+2>b){
    ans=k+1;
  }
  else 
    ans=((k-(a-1))/2)*b-((k-(a-1))/2-1)*a+(k-(a-1))%2;
  cout<<ans;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <functional>

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define fst first
#define snd second
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cout << #x << ": " << x << endl
const int MOD = 1000000007;
const int INF = 100100100;
const double EPS = 0.000000001;

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, h[30];
  cin >> n;
  REP(i, n) {
    cin >> h[i];
  }
  int ans = 0;
  int max = 0;
  REP(i, n) {
    if(h[i] >= max) {
      ans++;
      max = h[i];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main
{
  public static void main(String Args[])
  {
    Scanner in = new Scanner(System.in);
    int n = in.nextInt();
    int A[] = new int[n];
    int B[] = new int[n];
    int C[] = new int[n-1];
    for(int i = 0;i<n;i++)
      A[i] = in.nextInt();
    for(int i = 0;i<n;i++)
      B[i] = in.nextInt();
    for(int i = 0;i<n-1;i++)
      C[i] = in.nextInt();
    int sum = 0;
    int last = 0;
    for(int i = 0;i<n;i++)
    {
      int a = A[i]-1;
      if(i!=0)
      {
        sum += B[a];
        if(a-last==1)
          sum+= C[last];
        last = a;
      }
      else{
        sum += B[a];
        last = a;
      }
    }
     System.out.println(sum);
  }
}

Measured memory_bytes: 23508
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>
#include <iomanip>

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;

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

	ll N, M;
	cin >> N >> M;

	vector<ll> k(M);
	vector<ll> p(M);
	vector<vector<ll>> s(M);
	for (ll i = 0; i < M; ++i)
	{
		cin >> k[i];
		s[i].resize(k[i]);

		for (ll j = 0; j < k[i]; ++j)
		{
			cin >> s[i][j];
		}
	}

	for (ll i = 0; i < M; ++i)
	{
		cin >> p[i];
	}

	ll ans = 0;

	for (ll d = 0; d < pow(2, N); ++d)
	{
		bool flag = true;

		for (ll i = 0; i < M; ++i)
		{
			ll cnt = 0;

			for (ll bit = 0; bit < N; ++bit)
			{
				ll val = (d >> bit) & 1;

				for (auto e : s[i])
				{
					if (val && (e-1 == bit))
					{
						cnt++;
					}
				}

			}
			if (cnt % 2 != p[i]) flag = false;
			//cout << "i" << i << " " << "cnt" << cnt << endl;// << endl;
		}

		//if (flag) cout << 1 << endl;
		//else cout << 0 << endl;
		if (flag) ans++;
	}


	//ll ans = 0;
	cout << ans << endl;

	//system("pause");
}


Measured memory_bytes: 384
import numpy as np

N, K = [int(a) for a in input().split()]
A = [int(a) for a in input().split()]

K = format(K, 'b')
B = [format(a, 'b') for a in A]
max_order = len(max(B + [K], key=len))

K = K.zfill(max_order)
B = np.array([list(b.zfill(max_order)) for b in B], dtype='i')
B = B.sum(axis=0)
B = np.where(B < N/2, '1', '0')

for i, k, b in zip(range(max_order), K, B):
    if k < b:
        B[i] = '0'
    elif k > b:
        break

X = int(''.join(map(str, B)), 2)

print(sum(map(lambda a: X ^ a, A)))

Measured memory_bytes: 89636
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        aa: [usize; n],
    }
    let mut i = 1;
    let mut cnt = 0;
    while i < n {
        if aa[i] == aa[i-1] {
            cnt += 1;
            i += 2;
        } else {
            i += 1;
        }
    }
    println!("{}", cnt);
}


Measured memory_bytes: 4352
var lines = [];
var MOD = Math.pow(10, 9) + 7;

var readline = require('readline');
var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var a = lines[1].split(" ").map(value => Number(value));

    var ans = 0;
    for (var value of a) {
        ans += value - 1
    }
    console.log(ans)
});

Measured memory_bytes: 7988
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;

int main() {
	string s;
	cin >> s;
	if(s[0] == '9' || s[1] == '9') cout <<"Yes"<< endl;
	else cout <<"No"<< endl;
	
	return 0;
}

Measured memory_bytes: 256
raw_input = list(map(int, input().split()))
n = raw_input[0]
k = raw_input[1]
sunuke = [0 for _ in range(n)]
for i in range(k):
    d = int(input().strip())
    a = list(map(int, input().split()))
    for j in a:
        sunuke[j-1] += 1
counter = 0
for i in sunuke:
    if i == 0:
        counter += 1
print(counter)


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

int main() {
    char vowel[5] = {'a', 'i', 'u', 'e', 'o'};
    char c; cin >> c;
    for (int i = 0; i < 5; i++) {
        if (c == vowel[i]) {
            cout << "vowel";
            return 0;
        }
    }
    cout << "consonant" << endl;
    return 0;
}

Measured memory_bytes: 256
from sys import exit

N = int(input())
if N < 2:
    F = 1
    print(0)
    exit()
elif N % 2 == 1:
    print(0)
    exit()
else:
    t = 10
    result = 0
    while t <= N:
        result += N // t
        t = t * 5
print(result)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

const ll N=1e5+10;
ll n,m;
mat G(N);
vec dp(N);

void dfs1(ll cur, ll pre) {
  dp[cur]=1;
  for(ll nex:G[cur]) {
    if(nex==pre) continue;
    dfs1(nex,cur);
    (dp[cur]*=1+dp[nex])%=m;
  }
}

void dfs2(ll cur, ll pre, ll dp_p=0) {
  ll n=G[cur].size();
  vec mul1(n),mul2(n);
  for(ll i=0;i<n;i++) {
    ll nex=G[cur][i];
    if(nex==pre) {
      mul1[i]=mul2[i]=(dp_p+1)%m;
      (dp[cur]*=dp_p+1)%=m;
    } else mul1[i]=mul2[i]=(dp[nex]+1)%m;
  }
  for(ll i=0;i+1<n;i++) {
    (mul1[i+1]*=mul1[i])%=m;
  }
  for(ll i=n-1;i>0;i--) {
    (mul2[i-1]*=mul2[i])%=m;
  }
  for(ll i=0;i<n;i++) {
    ll nex=G[cur][i];
    if(nex==pre) continue;
    ll a=(i?mul1[i-1]:1);
    ll b=(i+1<n?mul2[i+1]:1);
    dfs2(nex,cur,a*b%m);
  }
}

int main() {
  cin >> n >> m;
  for(ll i=0;i<n-1;i++) {
    ll x,y;
    cin >> x >> y;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  dfs1(1,0);
  dfs2(1,0);
  for(ll i=1;i<=n;i++) {
    cout << dp[i] << endl;
  }
}

Measured memory_bytes: 17792
#include <bits/stdc++.h>
using namespace std;
  int main(){
  int N,x,y;
   cin>>N;
   x=N;
    while (x>0)
    {y+=x%10;
     x/=10;
     }
    if (N%y==0){
    cout<<"Yes"<<endl;
    }
    else{cout<<"No"<<endl;}
  }

Measured memory_bytes: 256
/**
 *    author:  lets
 *    created: 2020-06-07 13:40:22 JST
 **/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string ss;
  cin >> ss;
  while (1) {
    ss.pop_back();
    ss.pop_back();
    int n = (int)ss.size();
    if (ss.substr(0, n / 2) == ss.substr(n / 2, n / 2)) {
      cout << n << '\n';
      return 0;
    }
  }
  return 0;
}

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

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

int MOD = 1e9 + 7;
int INF = 0x3f3f3f3f;
//lint INF = 1e14;

int n, inPath[100005]={};
vector<int> g[100005];
vector<int> now, path;

void getpath(int u, int p = -1){
	now.push_back(u);
	if(u == n - 1) path = now;
	for(int v: g[u]) if(v - p)
		getpath(v, u);
	now.pop_back();
}

int color(int u, int p = -1){
	now.push_back(u);
	for(int v:g[u]) if(v - p)
		color(v, u);
}

int solve(){
	cin >> n;
	for(int i=0;i+1<n;i++){
		int u, v; cin >> u >> v; u--, v--;
		g[u].push_back(v); g[v].push_back(u);
	}
	getpath(0);
	for(int x: path) inPath[x] = 1;
	int ff = 0, ss = 0;

	int lo = 0, hi = path.size() - 1;
	while(lo < hi){
		// take lo
		int u = path[lo];
		now.push_back(u);
		for(int v:g[u]) if(!inPath[v]) color(v, u);
		ff += now.size(); now.clear();
		lo++;
		// take hi
		u = path[hi];
		now.push_back(u);
		for(int v:g[u]) if(!inPath[v]) color(v, u);
		ss += now.size(); now.clear();
		hi--;
	}
	if(lo == hi){
		// take l
		int u = path[lo];
		now.push_back(u);
		for(int v:g[u]) if(!inPath[v]) color(v, u);
		ff += now.size(); now.clear();
	}
	if(ff > ss)
		cout << "Fennec" << endl;
	else
		cout << "Snuke" << endl;
	return 0;
}

int main(){
	ios::sync_with_stdio(0);
	// int t; cin >> t; while(t--)
	solve();
	// cout << (solve() ? "YES" : "NO") << endl;
	return 0;
}


Measured memory_bytes: 14840
#include<bits/stdc++.h> 
using namespace std;
#define se second
#define fr first
#define int long long int
#define pb push_back
#define inf 1e18
#define all(v) v.begin(),v.end()
#define CHAL_BAAP_KO_MT_SIKHA ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
/*
    Damn Fast:TheFuckinMastermind
    while(How to solve the Question?){
                Read the Question Again!!
           }
        do
            Practise
    #Motivation::::0/0  
*/
const int N=4e3;
int dp[N+1][N+1];
string s,g;
int solve(int i,int j){
    if(i<=0 or j<=0){
        return 0;
    }
    if(dp[i][j]!=-1)
        return dp[i][j];
    if(s[i-1]==g[j-1]){
        return dp[i][j]=1+solve(i-1,j-1);
    }
    else{
        return dp[i][j]=max(solve(i-1,j),solve(i,j-1));
    }
}
signed main()
{
    
    CHAL_BAAP_KO_MT_SIKHA
    cin>>s>>g;
    memset(dp,-1,sizeof(dp));
    solve(s.length(),g.length());
    int i=s.length();
    int j=g .length();
    stack<char> st;
    while(i>0 and j>0){
        if(s[i-1]==g[j-1]){
            st.push(s[i-1]);
            i--;
            j--;
        }
        else{
            if(dp[i][j-1]>dp[i-1][j]){      
                j--;
            }
            else{
                i--;
            }
        }
    }
    while(!st.empty()){
        cout<<st.top();
        st.pop();
    }
}

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    string s; cin >> s;
    for (auto &e: s) {
        if (e == ',') e = ' ';
    }
    cout << s << endl;
    return 0;
}


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

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

  vector<ll> ws(n + 1), vs(n + 1);
  for (int i = 1; i <= n; ++i)
    cin >> ws[i] >> vs[i];

  vector<vector<ll>> dp(n + 1, vector<ll>(w + 1));
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= w; ++j) {
      int p = j - ws[i];
      dp[i][j] = max(dp[i - 1][j], p < 0 ? 0 : dp[i - 1][p] + vs[i]);
    }
  }
  cout << dp[n][w] << endl;
}

Measured memory_bytes: 80256
import math
from collections import deque
def main():
    h,w,k = tuple([int(t)for t in input().split()])
    s = [list(input())for _ in range(h)]
    output = [[-1]*w for _ in range(h)]

    counter = 1
    for i,s_ in enumerate(s):
        if '#' in s_ :
            temp = 0
            for j,piece in enumerate(s_):
                output[i][j] = counter
                if piece == "#":
                    counter +=1
                    temp = j+1
                    
            if s_[w-1] != "#":
                counter -=1
                output[i][temp:w] = [counter]*(w-temp)
                counter +=1

    for i in range(h-1):
        if not "#" in s[i+1]:
            output[i+1] = output[i]
    for i in range(1,h)[::-1]:
        if not "#" in s[i-1]:
            output[i-1] = output[i]

    for o_ in output:
        for o in o_:
            print(o,end=" ")
        print()

if __name__ == "__main__":
    main()

Measured memory_bytes: 8652
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define int long long
using namespace std;
bool hantei(string s) {
    if((int)s.size() % 2 != 0)
        return false;
    else {
        if(s.substr(0, (int)s.size() / 2) == s.substr((int)s.size() / 2))
            return true;
        else
            return false;
    }
}
signed main() {
    string s;
    cin >> s;
    while(s.size() > 0) {
        s.erase((int)s.size() - 1);
        if(hantei(s) == true) break;
    }
    cout << s.size() << endl;
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
 
n, m, x, y = map(int, input().split())
xn = list(map(int, input().split()))
ym = list(map(int, input().split()))
xn.append(x)
ym.append(y)
flag = 0

if max(xn) < min(ym):
    print("No War")
else:
    print("War")

Measured memory_bytes: 3060
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int64_t divide_round(int64_t n, int64_t x) { return (n - 1) / x + 1; }

int main() {
  int64_t n;
  cin >> n;
  int64_t b = n;
  int64_t c;
  for (int i = 0; i < 5; ++i) {
    cin >> c;
    b = min(b, c);
  }

  int64_t ans = 5 + divide_round(n, b) - 1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

from itertools import accumulate
a = list(accumulate(a))
b = list(accumulate(b))

from collections import deque
u = deque([0])
a.insert(0,0)

import bisect
for i in range(n+1):
    if k-a[i]>=0:
        index = bisect.bisect_right(b,k-a[i])
        u.append(index+i)
    else:
        break
print(max(u))

Measured memory_bytes: 40356
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<random>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldb = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(ll i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIF(v, n) printf("%."#n"f\n", v)
#define PRIY PRI("Yes")
#define PRIN PRI("No")
#define MINS(a,b) a = min(a,(decltype(a))(b))
#define MAXS(a,b) a = max(a,(decltype(a))(b))

ll mod = 1e9 + 7;

//拡張ユークリッドの互除法。戻り値は最大公約数、x,yはax+by=gcd(a,b)を満たす組の一つ
long long gcdext(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long g = gcdext(b, a % b, y, x);
	y -= a / b * x;
	return g;
}

//モジュラ逆数
long long modinv(long long a, long long mod) {
	long long x, y;
	gcdext(a, mod, x, y);
	x = ((x % mod) + mod) % mod;
	return x;
}

class com_table {
public:
	vector<long long> frac;
	vector<long long> finv;
	long long mod;
	com_table() = default;
	void init(long long size, long long mod) {
		this->mod = mod;
		frac.resize(size + 1);
		finv.resize(size + 1);
		frac[0] = 1;
		finv[0] = 1;
		for (int i = 1; i <= size; ++i) frac[i] = frac[i - 1] * i % mod;
		finv[size] = modinv(frac[size], mod);
		for (int i = size; i >= 2; --i) finv[i - 1] = finv[i] * i % mod;
	}
	long long operator()(int a, int b) {
		if (a < b)return 0;
		return ((frac[a] * finv[b] % mod) * finv[a - b]) % mod;
	}
};

com_table tbl;

ll T(ll X, ll Y) {
	ll ans = 0;
	REP(y, 0, Y + 1) {
		ans = (ans + tbl(y + X + 1, X)) % mod;
	}
	return ans;
}

ll Mod(ll  x) { return (x % mod + mod) % mod; }

int main() {
	tbl.init(3000000,mod);

	ll r1, c1, r2, c2;
	cin >> r1 >> c1 >> r2 >> c2;
	--r1; --c1;
	ll ans = T(r2, c2);
	ans -= T(r2, c1);
	ans -= T(r1, c2);
	ans += T(r1, c1);
	ans = Mod(ans);
	PRI(ans);
	return 0;
}




Measured memory_bytes: 50092
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    long n;
    scanf("%ld", &n);
    long iDistPlusMax = 0;
    long iDistPlusMin = 2000000000;
    long iDistMinusMax = -1000000000;
    long iDistMinusMin = 1000000000;
  
    for(long i = 0; i < n; i++){
        long x,y;
        scanf("%ld %ld", &x, &y);
        iDistPlusMax = max(iDistPlusMax, x+y);
        iDistPlusMin = min(iDistPlusMin, x+y);
        iDistMinusMax = max(iDistMinusMax, x-y);
        iDistMinusMin = min(iDistMinusMin, x-y);
    }
    
    long nAns = max(iDistPlusMax - iDistPlusMin, iDistMinusMax - iDistMinusMin);
    printf("%ld", nAns);
    return 0;
}


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

using namespace std;

typedef long long ll;

#define INF (int)1e9+7
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
//#define N 100005
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795



ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }

return ans;
}






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


double a,b,h,m;
cin>>a>>b>>h>>m;

double h_eq=h*30;
double m_eq=m*6;

double dis1=(h_eq-m_eq);
if(dis1<0)dis1+=360;

double an=dis1+m/2;
//cout<<an<<"\n";
double angle =PI*(an)/180;

double ans=sqrt(a*a+b*b-2*a*b*cos(angle));

cout<<fixed<<setprecision(15)<<ans<<"\n";




return 0;

}

Measured memory_bytes: 4232