akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int k;
    string s;
    cin >> k >> s;
    if(s.size() <= k) cout << s << endl;
    else {
        cout << s.substr(0,k) << "..." << endl;
    }
}


Measured memory_bytes: 3652
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using ll = long long;
using P = pair<ll,ll>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll n;
cin >> n;
vector<ll> dams(n);
ll tmp_a = 0;
rep(i,n){
    cin >> dams[i];
    tmp_a += (i % 2 == 0 ? dams[i] : -dams[i]);
}
vector<ll> ans(1,tmp_a);
for(int i = 1; i < n; i++){
    ans.emplace_back(dams[i - 1] * 2 - ans.back());
}
rep(i,n){
    cout << ans[i] << (i == n ? "\n" : " ");
}
}

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

const int INF = 1e8;
int n, m;
int c[22];
int dp[55555]; // dp[i]: i円になるまでのコインの最小枚数

int main() {
    // 入力
    cin >> n >> m;
    for (int i = 0; i < m; i++) { cin >> c[i]; }

    // DPテーブル初期化
    fill(dp, dp+n+1, INF);
    dp[0] = 0;

    // DP
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < m; j++) {
            if (i >= c[j]) {
                dp[i] = min(dp[i], dp[i-c[j]]+1);
            }
        }
    }
    cout << dp[n] << endl;

    return 0;
}


Measured memory_bytes: 3264
#include <iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node { int p, l, r;};

Node T[MAX];
int n, D[MAX];

void print(int u) {
  int i,c;
  cout << "node " << u << ": ";
  cout << "parent = " << T[u].p << ", ";
  cout << "depth = " << D[u] << ", ";

  if( T[u].p == NIL ) cout << "root, ";
  else if( T[u].l == NIL ) cout << "leaf, ";
  else cout << "internal node, ";

  cout << "[";

  for(i=0, c=T[u].l; c!=NIL; i++,c=T[c].r) {
    if(i) cout <<", ";
    cout << c;
  }
  cout << "]" << endl;
}

void rec(int u, int p) {
  D[u] = p;
  if(T[u].r != NIL) rec(T[u].r,p);
  if(T[u].l != NIL) rec(T[u].l,p+1);
}

int main(void) {
  int i,j,d,v,c,l,r;
  cin >> n;
  for(i=0;i<n;i++) T[i].p = T[i].l = T[i].r = NIL;
  for(i=0;i<n;i++) {
    cin >> v >> d;
    for(j=0;j<d;j++) {
      cin >> c;
      if(j==0) T[v].l=c;
      else T[l].r =c;
      l = c;
      T[c].p = v;
    }
  }
  for(i=0;i<n;i++) {
    if(T[i].p == NIL) r = i;
  }
  
  rec(r,0);
  
  for(i=0;i<n;i++) print(i);
  
  return 0;
}


Measured memory_bytes: 7760
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int n; cin >> n;
    vector<ll> a(n);
    int ans = 1002003004;

    rep(i,n){
        cin >> a[i];
        int tmp = 0;
        while(a[i] %2 == 0){
            tmp++;
            a[i] /=2;
        }
        ans = min(ans,tmp);
    }

    cout << ans << endl;
}
    

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

int main()
{
    ll n;
    cin >> n;
    map<string, ll> count;
    for(int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        count[s]++;
    }

    cout << "AC x " << count["AC"] << endl;
    cout << "WA x " << count["WA"] << endl;
    cout << "TLE x " << count["TLE"] << endl;
    cout << "RE x " << count["RE"] << endl;

    return 0;
}


Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;

class Solution
{
    static void Main(string[] args)
    {
        int[] s = Array.ConvertAll(Console.ReadLine().ToCharArray(), c => c - '0');

        bool ok = s[0] == 1 && s[s.Length - 1] == 0;
        for (int i = 0; i < s.Length - 1; i++)
        {
            if (s[i] != s[s.Length - 2 - i]) ok = false;
        }
        if (!ok)
        {
            Console.WriteLine(-1);
        }
        else
        {
            List<Edge> edges = new List<Edge>();
            Stack<int> children = new Stack<int>();
            for (int v = 1; v <= s.Length; v++)
            {
                if (s[v - 1] == 1 || v == s.Length)
                {
                    while (children.Count > 0)
                    {
                        edges.Add(new Edge(v, children.Pop()));
                    }
                }
                children.Push(v);
            }

            foreach (var e in edges)
            {
                Console.WriteLine($"{e.u} {e.v}");
            }
        }
    }
}

struct Edge
{
    public int u, v;
    public Edge(int u, int v)
    {
        this.u = u;
        this.v = v;
    }
}


Measured memory_bytes: 20176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    REP(i, n) cin >> a[i], a[i]--;

    // step[i][j] = 2^i回進んだ場合の距離
    vector<vector<ll>> step(60, vector<ll>(n));
    vector<ll> next(200000);
    for(ll i=2*n-1; i>=0; --i) {
        if(i < n) step[0][i] = next[a[i]] - i + 1;
        next[a[i%n]] = i;
    }
    FOR(i, 1, 60) REP(j, n) {
        step[i][j] = step[i-1][j] + step[i-1][(j+step[i-1][j])%n];
        if(step[i][j] >= n*k) step[i][j] = n*k;
    }
    ll x = 0;
    for(ll i=59; i>=0; --i) {
        if(x+step[i][x%n] < n*k) {
            x += step[i][x%n];
        }
    }
    
    set<ll> exist;
    stack<ll> st;
    FOR(i, x, n*k) {
        if(exist.find(a[i%n]) != exist.end()) {
            while(exist.find(a[i%n]) != exist.end()) {
                exist.erase(st.top());
                st.pop();
            }
        } else {
            exist.insert(a[i%n]);
            st.push(a[i%n]);
        }
    }

    vector<ll> ans;
    while(st.size()) {
        ans.push_back(st.top());
        st.pop();
    }
    reverse(ALL(ans));
    REP(i, ans.size()) cout << ans[i]+1 << (i+1==(ll)ans.size() ? '\n' : ' ');

    return 0;
}

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

int main(){

    int n,d,ans = 0,cnt = 0;

    cin>>n>>d;

    while(1){
        ans += 2*d+1;
        cnt++;
        if(n <= ans) break;
    }

    cout<<cnt<<endl;
    
    return 0;
}


Measured memory_bytes: 256
N, M, K = map(int, input().split())
*A, = map(int, input().split())
*B, = map(int, input().split())

dp = [0]*(N+1)
tot, lb = sum(B), M
while tot > K: 
    tot -= B.pop(-1)
    lb -= 1
dp[0] = lb

for i in range(N):
    K -= A[i]
    if K < 0:
        continue
    while tot > K and lb > 0: 
        tot -= B.pop(-1)
        lb -= 1
    dp[i+1] = i+1 + lb

print(max(dp))

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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

#define	MOD 1000000007

int	main() {
	string S;
	cin >>S;
	sort(S.begin(), S.end());
	if ("abc"==S)
		cout <<"Yes" <<endl;
	else
		cout <<"No" <<endl;
	return 0;
}



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

/*
提出前に確認!
- setとmultisetを間違えない
*/

int	main(void)
{
	int n;
	cin >> n;
	vector<int> l(n);
	for (int i = 0; i < n; i++) cin >> l[i];
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			for (int k = j + 1; k < n; k++)
			{
				if (l[i] == l[j] || l[j] == l[k] || l[k] == l[i]) continue;
				int l_max = max({l[i], l[j], l[k]});
				if (2 * l_max < (long long)l[i] + l[j] + l[k]) ans++;
			}
		}
	}
	cout << ans << endl;
	return (0);
}


Measured memory_bytes: 3596
function isLeapYear(y) {
  return y % 4 === 0 && (y % 100 !== 0 || y % 400 === 0);
}

function main() {
  var
  i,
  a, b, line,
  leaps,
  len = input.length;
  for(i = 0; i < len; i++) {
    line = input[i].split(' ').map(parseFloat);
    a = line[0]; b = line[1];
    if(a === 0 && b === 0) break;
    if(i !== 0) {
      console.log('');
    }
    leaps = [];
    for(; a <= b; a++) {
      if(isLeapYear(a)) leaps.push(a);
    }
    console.log(leaps.length ? leaps.join('\n') : 'NA');
  }
}

var
input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main();
});

Measured memory_bytes: 8968
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
#define fori(i,s,n) for(ll i=s;i<=n;i++)
#define ford(j,s,n) for(int i=n;i>=s;i--)
#define pb push_back
#define TEST int t; cin>>t; for(int T=1;T<=t;T++)
ll ma=LLONG_MAX,x;
void calc(vector<vector<ll>> &v,vector<ll> all,ll sum,ll in,ll nu){
	if(in>=v.size()){
		return;
	}
	if(nu==all.size()){
		ma=min(ma,sum);
		return;
	}
	calc(v,all,sum,in+1,nu);
	ll c=0;
	fori(j,0,all.size()-1){
		if(all[j]<x&&(all[j]+v[in][j+1]>=x)) c++;
		all[j]+=v[in][j+1];
	}
	//cout<<v[in][0]<<" "<<nu<<" ";
	calc(v,all,sum+v[in][0],in+1,nu+c);
	if((nu+c)==all.size()){
		ma=min(ma,sum+v[in][0]);
		return;
	}
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m,k;
    cin>>n>>m>>x;
    vector<vector<ll>> vc(n);
    vector<ll> all(m,0);
    fori(i,0,n-1){
    	fori(j,0,m){
    	cin>>k;
    	vc[i].pb(k);
    	}
    }
    calc(vc,all,0,0,0);
    if(ma==LLONG_MAX) cout<<"-1";
    else
    	cout<<ma;
    return 0;
}


Measured memory_bytes: 3676
#include <algorithm> // std::sort(begin,end)
#include <iostream>
#include <queue>
#include <string>
#include <unordered_map>
#include <utility> // std::swap
#include <vector>

using namespace std;
using ll = long long;
int board[301][301] = {};
ll acc[300 * 300 + 1] = {};
pair<int,int> pos[300*300+1];


int main(int argc, char const *argv[]) {
  int h, w, d, a, q, l, r;
  cin >> h >> w >> d;
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      cin >> a;
      board[i][j] = a;
      pos[a].first = i;
      pos[a].second = j;
    }
  }
  for(int i = 1;i <= h * w; i++){
    if(i <= d)
      acc[i] = 0; 
    else{ 
      auto prev = pos[i-d];
      auto now = pos[i];
      acc[i] = acc[i-d] + ll(abs(now.first - prev.first) + abs(now.second - prev.second));
    }
  } 

  cin >> q;
  for(int i = 0; i < q; i++){
    cin >> l >> r;
    cout << acc[r] - acc[l] << endl;
    /*
    for(int j = l ; j <=r ; j++){
      cerr << "pos[" << j << "]:" << acc[j] << endl;
    }*/
  }

  return 0;
}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
int arr[20];
int main(){
	for(int i=2;i<=13;i++){
		arr[i]=i-1;
	}
	arr[1]=13;
	int a,b;
	scanf("%d%d",&a,&b);
	if(arr[a]>arr[b]){
		printf("Alice");
	}else if(arr[a]==arr[b]){
		printf("Draw");
	}else printf("Bob");
}

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

typedef long long int ll ;

int main(){
  ll x ;cin >> x ;
  ll happiness = 0 ;
  happiness+=(x/500)*1000 ;
  x = x - (x/500)*500 ;
  happiness+=(x/5)*5 ;
  cout << happiness ;
  return 0 ;
}

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

int N, K;
#define MAX_N 2000
set<pair<int, int>> S;
int L;
vector<bool> A;
long long D[2][MAX_N + 1][2];
long long F[MAX_N + 1];
long long R;
#define MOD 924844033LL

int main() {
  cin >> N >> K;
  for(int i = 1; i <= N; ++i) {
    if(i - K >= 1) S.insert({i - K, i});
    if(i + K <= N) S.insert({i + K, i});
  }
  L = S.size();
  while(!S.empty()) {
    int a = S.begin()->first, b = S.begin()->second;
    S.erase({a, b}); A.push_back(false);
    while(true) {
      if(a < b) a = b + K; else b = a + K;
      if(!S.count({a, b})) break;
      S.erase({a, b}); A.push_back(true);
    }
  }
  D[0][0][0] = 1;
  for(int i = 0; i < L; ++i) {
    int prev = i % 2, cur = (i + 1) % 2;
    for(int j = 0; j <= N; ++j) {
      D[cur][j][0] = (D[prev][j][0] + D[prev][j][1]) % MOD;
      D[cur][j][1] = 0;
      if(j > 0) {
        D[cur][j][1] = D[prev][j - 1][0];
        if(!A[i]) (D[cur][j][1] += D[prev][j - 1][1]) %= MOD;
      }
    }
  }
  F[0] = 1; for(int i = 1; i <= N; ++i) F[i] = i * F[i - 1] % MOD;
  for(int i = 0; i <= N; ++i) {
    (R += (i % 2 == 0 ? 1 : MOD - 1)
      * (D[L % 2][i][0] + D[L % 2][i][1]) % MOD
      * F[N - i] % MOD) %= MOD;
  }
  cout << R << endl;
  return 0;
}


Measured memory_bytes: 512
import sys
input = sys.stdin.readline
#-------------------------------------

n = int(input())
ab = []
for _ in range(n):
        ab.append(list(map(int,input().split())))

ab = sorted(ab, key=lambda x: x[1])

c = 0
for v in ab:
        c += v[0]
        if c>v[1]:
                print("No")
                break
else:
        print("Yes")

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

using namespace std;

#define debug(x) '[' << #x << " is: " << x << "] "
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

template<int SZ> struct MAXM{
	vector<int> g[SZ];
	bool seen[SZ];
	int matchR[SZ],n,m;

	void init(int N,int M){
		n = N;
		m = M;
	}
		
	bool bpm(int u){ 
	    for(int v : g[u]){ 
	        if (!seen[v]){
	            seen[v] = true;
	            if (matchR[v] == -1 || bpm(matchR[v])){
	                matchR[v] = u; 
	                return true; 
	            }
	        }
	    }
	    return false; 
	} 
	void maxBPM(){
	    memset(matchR, -1, sizeof(matchR)); 
	    int result = 0;
	    for (int u=0;u<n; u++) { 
	        memset(seen, 0, sizeof(seen)); 
	        if (bpm(u)) result++;
	    } 
	    cout << result << endl;
	    // for(int i=0;i<SZ;i++){
	    // 	if(matchR[i] == -1)continue;
	    // 	cout << matchR[i] << ' ' << i << '\n';
	    // }
	}
};

MAXM<300> tree;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;
	#ifndef ONLINE_JUDGE
//		freopen("input.txt","r",stdin);
	#endif
	int n;
	cin>>n;
	tree.init(n,n);
	vector<pair<int,int>> p(n);
	for(int i=0;i<n;i++){
		cin>>p[i].first >> p[i].second;
	}
	for(int i=0;i<n;i++){
		int x,y;
		cin>>x>>y;
		for(int j=0;j<n;j++){
			if(p[j].first < x && p[j].second < y){
				tree.g[j].push_back(i+n);
				tree.g[i+n].push_back(j);
			}
		}
	}
	tree.maxBPM();
}


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

int main(){
	int a,b,c;
  	while(~scanf("%d%d%d",&a,&b,&c)){
    	if(a+b==c||a+c==b||b+c==a) puts("Yes");
      	else puts("No");
    }
    return 0;
}

Measured memory_bytes: 3152
#include"bits/stdc++.h"
using namespace std;

void Main() {
  int n;
  cin >> n;

  int A[n][20];
  memset(A, 0, sizeof(A));
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    int j;
    for (j = 0; tmp > 0 && j < 20; j++) {
      if (tmp % 2) A[i][j] = 1;
      else A[i][j] = 0;
      tmp >>= 1;
    }
    A[i][j] = tmp;
  }

  int c[20];
  memset(c, 0, sizeof(c));
  int l = 0, r = -1;
  long long ans = 0;
  auto f = [&] {
    for (int i = 0; i < 20; i++) {
      if (c[i] > 1) return false;
    }
    return true;
  };
  for (l = 0; l < n; l++) {
    while (r < n && f()) {
      r++;
      for (int i = 0; i < 20; i++) {
        c[i] += A[r][i];
      }
    }
    ans += r - l;
    for (int i = 0; i < 20; i++) {
      c[i] -= A[l][i];
    }
  }
  cout << ans << endl;
}

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



Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

int main(){
    int n;cin >> n;
    vector<int> a(n);
    vector<P> v(2,mp(0,-1));
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if(v[1].fs<a[i]){
            if(v[0].fs<v[1].fs){
                v[0]=v[1];
            }
            v[1]=mp(a[i],i);
        }
        else if(v[0].fs < a[i]){
            v[0]=mp(a[i],i);
        }
    }
    for (int i = 0; i < n; i++) {
        if(i==v[1].sc) cout << v[0].fs << endl;
        else cout << v[1].fs << endl;
    }
    return 0;
}


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

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    char[] s = in.readLine().toCharArray();
    in.close();
    
    for(int i = 0; i < s.length; i++) {
      int x = s[i] + n;
      if('Z' < x)
        x -= 26;
      s[i] = (char)x;
    }
    
    System.out.println(String.valueOf(s));
  }
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

int main(){
    int n,k;
    cin>>n>>k;

    double ans=1/(double)n;
    double tmp=0;
    for(int i=1;i<=n;i++){
        int x=i;
        int cnt=1;
        if(i>=k) cnt=0; 
        while(1){
            if(x*2>=k) break;
            cnt++;
            x*=2;
        }
        //cout<<cnt<<endl;
        double add=1/(double)pow(2,cnt);
        //cout<<add<<endl;
        tmp+=add;
    }
    //cout<<ans<<endl;
    ans*=tmp;
    cout<<fixed<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 4056
#include <bits/stdc++.h>
using namespace std;
#define ul unsigned long long
#define ll long long
#define ld long double



int main()
{
  ll n,cv,dp[100000],ml=0;
  cin>>n;
  cin>>dp[0];
  for (ll i = 1; i < n; i++)
  {
    cin>>cv;
    if (dp[ml]<cv) {
      ml++;
      dp[ml]=cv;
    } else {
      *lower_bound(dp,dp+ml+1,cv)=cv;
    }
  }
  cout<<ml+1<<endl;

  return 0;
}



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

int main()
{
	int n,ans=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int a;
		cin>>a;
		if(i%2==1&&a%2==1)
			ans++;
	}
	cout<<ans;
}



Measured memory_bytes: 3632
object Main{
  def main(args:Array[String]){
    val sc = new java.util.Scanner(System.in)
    val SEP="####################"
    val n=sc.nextInt
    var a=Array.fill(4,3,10)(0)
    for(i<-0 until n){
      val b,f,r,v=sc.nextInt
      a(b-1)(f-1)(r-1)+=v
    }
    println(a.map(_.map(_.map(" "+_).mkString).mkString("\n")).mkString("\n"+SEP+"\n"))
  }
}

Measured memory_bytes: 47752
n=int(input())

t = list(map(int,input().split()))

memo = 0

for i in range(1, n):
    if i%2==0:
        continue
    else:
        memo += t[i]
x1 = sum(t)-2*memo

res = []

res.append(x1)

for i in range(1, n):
    res.append(2*t[i-1]-res[i-1])
    
print(' '.join(map(str,res)))

Measured memory_bytes: 84836
def read_dict():
  n = int(input())
  c = {}
  
  for _ in range(n):
    s = input()
    if s in c:
      c[s] += 1
    else:
      c[s] = 1
  return c

blue = read_dict()
red = read_dict()

res = 0
for text in blue:
  to_add = blue[text]
  to_subtract = 0 if text not in red else red[text]
  res = max(res, to_add - to_subtract)
  
print(res)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int n,m,x,y,cnt;
int a[2000];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		cnt+=a[i];
	}
	cin>>m;	
	for(int i=1;i<=m;i++){
		cin>>x>>y;
		cout<<cnt-(a[x]-y)<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <iomanip>
#include <cmath>
#include <queue>
#include <bitset>
#include <numeric>
#include <array>
#include <cstring>
#include <random>
#include <chrono>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {

  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  int l = 0, r = 0, d = 0, ans = 0;

  cin >> l >> r >> d;

  for(int i = l; i <= r; i++)
    ans += (i % d == 0);

  cout << ans;

  return 0;
}
/*

*/


Measured memory_bytes: 3652
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
using namespace std;



int main(){
	int n,m,x;
	cin >> n >> m >> x;
	vector<int> masu(n+1,0);
	
	int a;
	for(int i=0;i<m;i++){
		cin >> a;
		masu[a]=1;
	}
	
	int cost_r=0;
	for(int i=x;i<=n+1;i++){
		if(masu[i]==1)cost_r++;
	}
	
	int cost_l=0;
	for(int i=x;i>=0;i--){
		if(masu[i]==1)cost_l++;
	}
	
	cout << min(cost_r,cost_l) << endl;
		
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

/**
 * Kakezan
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;


		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int Q = parseInt(line);

			for (int i = 0; i < Q; i++) {

				int N = parseInt(br.readLine());
				int c = 0;

				while (N >= 10) {
					int _N = 0;
					for (int j = 1; ; j++) {
						if (Math.pow(10, j) >= N) break;
						int l = (int) (N / Math.pow(10, j));
						int r = (int) (N % Math.pow(10, j));
						_N = Math.max(_N, l * r);
					}
					//
					if (N == _N) {
						c = -1;
						break;
					}
					c++;
					N = _N;
				}
				System.out.println(c);
			}
		} //end while
	} //end main
}

Measured memory_bytes: 24276
/* 
 * Project: AtCoder Beginners Contest 064 B - Traveling AtCoDeer Problem
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/06/28
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <algorithm>
using namespace std;

int n;
int a[1000];

void solve() {

    sort(a, a+n);
    printf("%d\n", a[n-1]-a[0]);
}

int main() {

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

    solve();

}


Measured memory_bytes: 3232
#include <set>
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits>
#include <map>
#include <numeric>

#define ll long long
using namespace std;
static ll imin = std::numeric_limits<ll>::min();
static ll imax = std::numeric_limits<ll>::max();
#define rep(i, n) for(int i = 0; i<n; ++i)
#define rep1(i, n) for(int i = 1; i<n; ++i)
#define rev_rep(i, n) for(int i = n - 1; i >= 0; --i)
#define dump(x) cout << #x << ":" << x << "\n";
#define all(v) v.begin(), v.end()

template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::pair<T1, T2>& pair){
  os << '(' << pair.first << ',' << pair.second << ')';
  return os;
}
template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec){
  std::size_t n = vec.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(int i = 0; i<n - 1; ++i){
    os << vec[i] << " ";
  }
  os << vec[n - 1];
  os << std::endl;
  return os;
}


#ifndef BOOST_TEST_MAIN
int main(int const argc, char const** argv){
  string march = "MARCH";
  ll N;
  cin >> N;
  vector<ll> cs(5, 0);
  rep(i, N){
    string c;
    cin >> c;
    rep(j, 5){
      if(c[0] == march[j]){
        cs[j]++;
      }
    }
  }
  // dump(cs);
  ll res = 0;
  rep(i, 3){
    for(ll j = i + 1; j != 4; j++){
      for(ll k = j + 1; k != 5; k++){
        // dump(i);
        // dump(j);
        // dump(k);
        res += cs[i] * cs[j] * cs[k];
      }
      
    }
  }
  cout << res;
}
#endif


Measured memory_bytes: 256
N, K = map(int, input().split())
P = list(map(int, input().split()))

# print( (max(sum(P[i:i+K]) for i in range(0, N-K+1)) + K)/2 )

tmp = sum(P[0:K])
result = tmp

for i in range(1, N-K+1):
    tmp += (P[i+K-1] - P[i-1])
    if (tmp > result):
        result = tmp

print((result+K)/2)


Measured memory_bytes: 24804
#![allow(unused_imports)]
use proconio::{input, fastout};
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
    n: usize,
    c: [usize; 5]
    }
    let m = c.iter().min().unwrap();
    let ans: usize = 5 + n / m - if n % m == 0 {1} else {0};
    println!("{}", ans);
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repin(a, n)  \
	vector<ll> a(n); \
	rep(i, n) { cin >> a[i]; }
#define repins(a, n)     \
	vector<string> a(n); \
	rep(i, n) { cin >> a[i]; }
#define repind(a, n)     \
	vector<double> a(n); \
	rep(i, n) { cin >> a[i]; }
#define in(a) \
	ll a;     \
	cin >> a;
#define ins(a) \
	string a;  \
	cin >> a;
#define ind(a) \
	double a;  \
	cin >> a;
template <class T>
inline void out(T a)
{
	cout << a << endl;
}
inline void out(double a) { printf("%.10f\n", a); }
#define all(x) (x).begin(), (x).end()
#define rep2(i, a, b) for (ll i = (a); i < (b); ++i)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
#define yes out("Yes")
#define no out("No")
#define OK out("OK")
#define NG out("NG")
#define degtorad(deg) (deg * M_PI / 180.0)
#define radtodeg(rad) (rad * 180.0 / PI)

int main()
{
	in(k);
	in(a);
	in(b);

	rep2(i,a,b+1){
		if(i%k==0){
			OK;
			return 0;
		}
	}
	NG;
}

Measured memory_bytes: 3600
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int main(){
	char a,b;
	scanf("%c %c",&a,&b);
	puts(a=='H'^b=='H'?"D":"H");
}

Measured memory_bytes: 128
use std::str::FromStr;
use std::io::stdin;
use std::cmp::max;

fn main() {
    let (n, w) = {
        let line = read_vec::<usize>();
        (line[0], line[1])
    };
    let mut vec = Vec::with_capacity(n);
    for _ in 0..n {
        let line = read_vec::<usize>();
        vec.push((line[0], line[1]));
    }
    let mut dp = Vec::with_capacity(n + 1);
    for i in 0..(n + 1) {
        dp.push(Vec::new());
        for _ in 0..(w + 1) { dp[i].push(0 as usize); }
    }
    for i in 0..n {
        let (weight, value) = vec[i];
        for j in 0..(w + 1) {
            if (j as i64) - (weight as i64) >= 0 {
                dp[i + 1][j] = max(dp[i][j], dp[i][j - weight] + value);
            } else {
                dp[i + 1][j] = dp[i][j];
            }
        }
    }
    println!("{}", dp.last().unwrap().last().unwrap());
}

fn read_vec<T: FromStr>() -> Vec<T> {
    let mut line = String::new();
    stdin().read_line(&mut line).ok();
    line.trim().split_whitespace()
        .map(|i| i.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 209148
n = int(input())
ans = 0
cnt_a, cnt_b, cnt_ab  = 0, 0, 0
for i in range(n):
    s = input()
    ans += s.count("AB")
    if s[-1] == "A":
        cnt_a += 1
    if s[0] == "B":
        cnt_b += 1
    if s[0] == "B" and s[-1] == "A":
        cnt_ab += 1
#print(cnt_a, cnt_b, cnt_ab)
print(ans + min(cnt_a, cnt_b) if cnt_ab < max(cnt_a, cnt_b) or cnt_b == 0 else ans + (cnt_ab - 1))

Measured memory_bytes: 9220
import Control.Monad

main = do
    [n, a, b, c, d, e] <- forM [1 .. 6] $ \i -> read <$> getLine
    putStrLn $ show $ solve n [a, b, c, d, e]

solve :: Integer -> [Integer] -> Integer
solve n a = (n + m - 1) `div` m + 4
  where
    m = minimum a

Measured memory_bytes: 508
//g++ -std=c++14 test.cpp -o test.out
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const int INF_INT = 2147483647-1e6;
const LL mod = 1000000007ll;

struct mint {
  LL x; 
  mint(LL x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(LL t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int N,M;
int S[2003],T[2003];

LL ans = -1;

//Sの先頭i文字を抽出したものと
//TのSの先頭j文字を抽出したものに対して
//
mint dp0[2003][2003];
mint dp1[2003][2003];
 
void solve(){
	dp0[0][0] = 1;
	for(int i=0;i<=N;i++){
		for(int j=0;j<=M;j++){
			dp0[i+1][j] += dp0[i][j];//iを進める
			dp1[i][j] += dp0[i][j];//iを進めるモードからjを進めるモードに移行
			dp1[i][j+1] += dp1[i][j];
			if(S[i]==T[j]){
				dp0[i+1][j+1] += dp1[i][j];
			}
		}
	}
	ans = dp1[N][M].x;
}
 
int main(){
	cin >> N >> M;
	for(int i=0;i<N;i++) cin >> S[i];
	for(int i=0;i<M;i++) cin >> T[i];
 
	solve();
 
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 62976
import java.util.Scanner;

public class Main{
    public static void main(String[]argc){
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        double pi = Math.PI;
        double area = r * r * pi;
        double length = 2 * r * pi;
        System.out.printf("%f %f",area,length);
    }
}



Measured memory_bytes: 28304
#include <cstdio>
#include <iostream>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 10;
const int mod = 998244353;
int d[maxn];
int cnt[maxn];
ll qpow(ll x,ll k){
	ll res=1;
	while (k) {
		if(k&1) res=res*x%mod;
		x=x*x%mod;
		k>>=1;
	}
	return res;
}
int main(){
	ios::sync_with_stdio(0);cin.tie(0);
	int n;cin>>n;
	int mx=0;
	for(int i=1;i<=n;i++) {
		cin>>d[i];
		cnt[d[i]]++;
		mx=max(d[i],mx);
	}
	for(int i=1;i<=mx;i++) if(!cnt[i]){
		puts("0");
		return 0;
	}
	if(cnt[0]!=1 || d[1]!=0){
		puts("0");
		return 0;
	}
	ll ans=1;
	for(int i=1;i<=n;i++){
		ans=ans*qpow(cnt[i-1], cnt[i])%mod;
	}
	printf("%lld\n",ans);
}


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

using namespace std;

#define NEWLINE cout << endl
#define DEBUGGER cout << "Here" << endl
#define infinity 1e9 + 5

int main(){
    int x;
    cin >> x;
    if(x >= 30){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return(0);
}

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b,c; cin>>a>>b>>c;
	if (a==b&&b==c&&c==a) cout<<"Yes";
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N, K;
    scan(N, K);
    long R, S, P;
    scan(R, S, P);
    string T = sread();
    auto dp = new long[][](N + 1 + K, 3);
    foreach (i; 0 .. N)
    {
        dp[i + K][0] = max(dp[i][1], dp[i][2]) + ((T[i] == 's') ? R : 0);
        dp[i + K][1] = max(dp[i][0], dp[i][2]) + ((T[i] == 'p') ? S : 0);
        dp[i + K][2] = max(dp[i][0], dp[i][1]) + ((T[i] == 'r') ? P : 0);
    }
    long ans;
    foreach (i; 0 .. K)
    {
        ans += max(dp[N + K - 1 - i][0], dp[N + K - 1 - i][1], dp[N + K - 1 - i][2]);
    }
    writeln(ans);
}


Measured memory_bytes: 10748
#include<stdio.h>
#include<string.h>
int main(void)
{
	int i,j,x=0;
	char a[101],b[101];
	char n[11]={"0123456789"};
	scanf("%s %s", a, b);
	if(strlen(a)>strlen(b))
	printf("GREATER\n");
	if(strlen(a)<strlen(b))
	printf("LESS\n");
	if(strlen(a)==strlen(b))
	{
		for(i=0; i<strlen(a); i++)
		{
			for(j=9; j>=0; j--)
			{
				if(a[i]==n[j]&&b[i]!=n[j])
				{
					x=1;
					break;
				}
				if(a[i]!=n[j]&&b[i]==n[j])
				{
					x=2;
					break;
				}
			}
			if(x>0)
			break;
		}
		if(x==1)
		printf("GREATER\n");
		if(x==2)
		printf("LESS\n");
		if(x==0)
		printf("EQUAL\n");
	}
	
	return 0;
}

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

const double EPS=1e-6;

double evaluate(vector<double>&r){
    double res=r[0]+r[r.size()-1];
    for(int i=0;i+1<r.size();i++){
        double h=(r[i]+r[i+1]);
        double s=abs(r[i]-r[i+1]);
        res+=sqrt(h*h-s*s);
    }
    return res;
}

double optimize(vector<double>r){

    if(r.size()<=5){
        sort(r.begin(),r.end());
        double res=evaluate(r);
        do{
            res=min(res,evaluate(r));
        }while(next_permutation(r.begin(),r.end()));
        return res;
    }

    double T=10000;
    double cool=0.99;

    double mi=evaluate(r);

    while(T>0.000001){
        int a,b;
        while(true){
            a=rand()%r.size();
            b=rand()%r.size();
            if(a!=b)break;
        }

        double score=evaluate(r);
        swap(r[a],r[b]);
        double new_score=evaluate(r);

        double p=exp(-abs(new_score-score)/T);

        if(new_score>score || rand()<p*RAND_MAX);
        else{
            swap(r[a],r[b]);
        }

        mi=min(mi,new_score);
        T*=cool;
    }
    return mi;
}

int main(){
    srand((unsigned)time(NULL));
    int l;
    while(cin>>l){
        string str;
        getline(cin,str);
        stringstream ss(str);
        vector<double>r;
        while(!ss.eof()){
            double t;
            ss>>t;
            r.push_back(t);
        }

        if(optimize(r)<l+EPS)puts("OK");
        else puts("NA");
    }

    return 0;
}

Measured memory_bytes: 1312
def c_stones(N, S):
    black_left_of_the_boundary, white_right_of_the_boundary = 0, S.count('.')
    ans = black_left_of_the_boundary + white_right_of_the_boundary
    for c in S:
        if c == '#':
            black_left_of_the_boundary += 1
        else:
            white_right_of_the_boundary -= 1
        ans = min(ans, black_left_of_the_boundary + white_right_of_the_boundary)
    return ans

N = int(input())
S = input()
print(c_stones(N, S))

Measured memory_bytes: 3500
import math

a, b, x = map(int, input().split())

vol = a**2 * b
ans = 0
if vol/2 < x:
    #print("水多し、台形になる")
    h0 = x/(a**2)
    c = 2*h0 - b
    ans = math.degrees(math.atan((b-c)/a))
else:
    #print("水少ない、三角形になる")
    d = (2*x)/(b*a)
    ans = math.degrees(math.atan(b/d))
print(ans)


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

int main() {
  int D, N;
  cin >> D >> N;
  if (D == 0) {
    if (N ==100) cout << 101 << endl;
    else cout << N << endl;
  }
  else if (D == 1) {
    if (N == 100) cout << 10100 << endl;
    else cout << 100*N << endl;
  }
  else {
    if (N == 100) cout << 1010000 << endl;
    else cout << 10000*N << endl;
  }
}

Measured memory_bytes: 256
n = int(input())

#約数を返す関数
def yaku(n):
  x = 0
  for i in range(1,n+1):
    if(not n%i):
      x += 1
  return x

count = 0
for i in range(1,n+1,2):
  if(yaku(i) == 8):
    count += 1

print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
 
int main() {
 
	int n,m,c;
	int b[21],a[21];
	ll total=0;
	int t2=0;
 
	cin>>n>>m>>c;
	rep(i,m){
		cin>>b[i];
	}
	rep(i,n){
		total=c;
		rep(j,m){
			cin>>a[j];
			total+=a[j]*b[j];
		}
		if(total>0)t2++;
	}
	cout<<t2<<endl;
	return 0;
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) (V).begin(),(V).end()

int G[201][201];
vector<ll> arr(201), arrs = arr;

int main(){
	int N;
	cin >> N;
	string S;
	for (int i = 0;i < N;i++) {
		cin >> S;
		for (int j = 0;j < N;j++) {
			if (S[j] == '0')G[i][j] = 0;
			else G[i][j] = 1;
		}
	}
	ll cnt = 0;
	ll a, x = 0, mx = 0;
	queue<int> Q, QS;
	QS.push(-1);
	bool bo = 0;
	for (int i = 0;i < N;i++) {
		bo = 0;
		x = 0;
		arr = arrs;
		Q = QS;
		Q.push(i);
		while (Q.size() > 1) {
			a = Q.front();
			Q.pop();
			if (a < 0) {
				x++;
				Q.push(-1);
				continue;
			}
			if (arr[a] != 0)continue;
			arr[a] = x;
			for (int j = 0;j < N;j++) {
				if (G[a][j]) {
					if (arr[j] != 0){
						if (abs(arr[j] - x) != 1) {
							bo = 1;break;
						}
						else
							continue;
					}
					Q.push(j);
				}
			}
			if (bo)break;
		}
		if (!bo) {
			mx = max(mx, x);
		}
	}
	if (mx != 0)cout << mx << endl;
	else cout << -1 << endl;
}

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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound


signed main() {
    int x, a;
    cin >> x >> a;
    if (x < a)cout << 0 << endl;
    else cout << 10 << endl;
    return 0;
}


Measured memory_bytes: 764
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll A[3];
    rep(i, 3){
        cin >> A[i];
    }
    sort(A, A + 3);

    cout << A[2] - A[0] << endl;

    return 0;
}

Measured memory_bytes: 3652
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true) {
			int H = stdIn.nextInt();
			int R = stdIn.nextInt();
			
			if(H == 0 && R == 0) {
				break;
			}
			
			int[] hx = new int[H];
			int[] hy = new int[H];
			for(int i = 0; i < H; i++) {
				hx[i] = stdIn.nextInt();
				hy[i] = stdIn.nextInt();
			}
			
			int U = stdIn.nextInt();
			int M = stdIn.nextInt();
			int S = stdIn.nextInt();
			int du = stdIn.nextInt();
			int dm = stdIn.nextInt();
			int ds = stdIn.nextInt();
			
			int[] ux = new int[U];
			int[] uy = new int[U];
			for(int i = 0; i < U; i++) {
				ux[i] = stdIn.nextInt();
				uy[i] = stdIn.nextInt();
			}
			
			int[] mx = new int[M];
			int[] my = new int[M];
			for(int i = 0; i < M; i++) {
				mx[i] = stdIn.nextInt();
				my[i] = stdIn.nextInt();
			}
			
			int[] sx = new int[S];
			int[] sy = new int[S];
			
			for(int i = 0; i < S; i++) {
				sx[i] = stdIn.nextInt();
				sy[i] = stdIn.nextInt();
			}
			
			int[] w = new int[R];
			int[] a = new int[R];
			for(int i = 0; i < R; i++) {
				w[i] = stdIn.nextInt();
				a[i] = stdIn.nextInt();
			}
			
			//---処理ここから---//
			int[] day = new int[H];
			for(int i = 0; i < R; i++) { //風
				IN:for(int j = 0; j < H; j++) { //家
					//---私の桜が届くか---//
					if(!ReachWind(0,0,hx[j],hy[j],w[i],du,a[i])) {
						continue;
					}
					//---梅---//
					for(int k = 0; k < U; k++) {
						if(ReachWind(ux[k],uy[k],hx[j],hy[j],w[i],du,a[i])) {
							continue IN;
						}
					}
					//---桃---//
					for(int k = 0; k < M; k++) {
						if(ReachWind(mx[k],my[k],hx[j],hy[j],w[i],dm,a[i])) {
							continue IN;
						}
					}
					//---桜---//
					for(int k = 0; k < S; k++) {
						if(ReachWind(sx[k],sy[k],hx[j],hy[j],w[i],ds,a[i])) {
							continue IN;
						}
					}
					day[j]++;
					
					
					
					
				}
			}
			int max = 0;
			for(int i = 0; i < H; i++) {
				if(max < day[i]) {
					max = day[i];
				}
			}
			if(max != 0) {
				boolean tmp = false;
				for(int i = 0; i < H; i++) {
					if(!tmp && max == day[i]) {
						System.out.print((i + 1));
						tmp = true;
					}
					else if(max == day[i]) {
						System.out.print(" " + (i+1));
					}
				}
				System.out.println();
			}
			else {
				System.out.println("NA");
			}
		}
	}
	
	public static boolean ReachWind(int x0, int y0, int x1, int y1, int w, int d, int a) {
		//---長さ---//
		if(Math.sqrt((x0 - x1) * (x0 - x1) + (y0 - y1)*(y0 - y1)) > a) {
			return false;
		}
		
		//---角度(x軸から何度か)---//
		int xlen = x1 - x0;
		int ylen = y1 - y0;
		double angle = Math.atan2(ylen, xlen);
		angle = Math.toDegrees(angle);
		double ue = w + d/2.0;
		double shita = w - d/2.0;
		if(angle >= shita && angle <= ue) {
			return true;
		}
		angle += 360;
		if(angle >= shita && angle <= ue) {
			return true;
		}
		angle -= 1080;
		if(angle >= shita && angle <= ue) {
			return true;
		}
		return false;
		
	}
}

Measured memory_bytes: 29068
class Union:
  def __init__(self, num):
    self.T = [-1 for i in range(num)]

  def root(self, x):
    if self.T[x] < 0: return x
    return self.root(self.T[x])

  def size(self, x):
    return -self.T[self.root(x)]

  def merge(self, x, y):
    a = self.root(x)
    b = self.root(y)
    if a == b: return False
    if self.size(a) < self.size(b): a, b = b, a
    self.T[a] += self.T[b]
    self.T[b] = a
    return True

  def same(self, x, y):
    return self.root(x) == self.root(y)

import sys
input = sys.stdin.readline
N, M, K = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(M)]
CD = [list(map(int, input().split())) for _ in range(K)]

uni = Union(N)
ans = [-1] * N
for a, b in AB:
  a -= 1
  b -= 1
  uni.merge(a, b)
  ans[a] -= 1
  ans[b] -= 1

L = [[] for _ in range(N)]
for c, d in CD:
  c -= 1
  d -= 1
  L[c].append(d)
  L[d].append(c)

for i in range(N):
  ans[i] += uni.size(i)
  for j in L[i]:
    if uni.same(i, j):
      ans[i] -= 1

ans = map(str, ans)
print(" ".join(ans))

Measured memory_bytes: 131804
import math
a, b, d = map(float, input().split())
h = b * math.sin(d*math.pi/180)
s = a * h / 2
l = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(d*math.pi/180)) + a + b
print(s)
print(l)
print(h)


Measured memory_bytes: 5692
#include <algorithm>
#include <climits>
#include <iostream>
#include <vector>

const int N = 26, D = 365;

using namespace std;
int main() {
    int d;
    cin >> d;
    vector<int> c(N);
    vector<vector<int>> s(D, vector<int>(N));
    for (int i = 0; i < N; ++i)
        cin >> c[i];
    for (int i = 0; i < d; ++i)
        for (int j = 0; j < N; ++j)
            cin >> s[i][j];
    vector<int> ans;
    double best = LLONG_MIN;
    for (int start = 0; start < N; ++start) {
        double tot = s[0][start];
        vector<int> last(N, 0), cans = {start + 1};
        for (int i = 0; i < N; ++i)
            if (i != start)
                tot -= c[i];
        last[start] = 1;
        for (int i = 2; i <= d; ++i) {
            int maxt = 0;
            double maxg = LLONG_MIN;
            for (int j = 0; j < N; ++j) {
                double gain = s[i - 1][j];
                for (int k = 0; k < N; ++k)
                    if (k != j)
                        gain -= (double)s[i - 1][k] * c[k] * (i - last[k]);
                if (gain > maxg) {
                    maxg = gain;
                    maxt = j;
                }
            }
            last[maxt] = i;
            cans.emplace_back(maxt + 1);
            tot += maxg;
        }
        if (tot > best) {
            best = tot;
            ans = cans;
        }
    }
    for (int i : ans)
        cout << i << endl;
}


Measured memory_bytes: 3672
import java.util.*;

class CircleInARectangle {
    public static void main(String...args) {
        final Scanner sc = new Scanner(System.in);
        final int W = sc.nextInt();
        final int H = sc.nextInt();
        final int x = sc.nextInt();
        final int y = sc.nextInt();
        final int r = sc.nextInt();
        System.out.println(r <= x && r <= y && x <= W - r && y <= H - r ? "Yes" : "No");
    }
}
public class Main {
    public static void main(String... args) {
        CircleInARectangle.main();
    }
}

Measured memory_bytes: 17352