akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <cmath>
#include <math.h>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Info{
	int value,cost;
};

Info info[100][50];
int item_num[100],sell_count[100];
int dp[301],next_dp[301];

int main(){

	int S,D,M;

	while(scanf("%d %d %d",&S,&D,&M) != EOF){

		for(int i = 0; i < S; i++)sell_count[i] = 0;

		for(int i = 0; i < S; i++){
			scanf("%d",&item_num[i]);

			for(int k = 0; k < item_num[i]; k++){
				scanf("%d %d",&info[i][k].value,&info[i][k].cost);
			}
		}

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

		dp[0] = 0;
		next_dp[0] = 0;
		for(int i = 1; i <= M; i++){
			dp[i] = -1;
			next_dp[i] = -1;
		}

		for(int i = 0; i < S; i++){
			if(sell_count[i] == 0)continue;

			for(int k = 0; k < item_num[i]; k++){
				for(int num = 1; num <= sell_count[i]; num++){
					for(int budget = M; budget-num*info[i][k].cost >= 0; budget--){
						if(dp[budget-num*info[i][k].cost] >= 0){
							next_dp[budget] = max(next_dp[budget],dp[budget-num*info[i][k].cost]+num*info[i][k].value);
						}
					}
				}
				for(int budget = 0; budget <= M; budget++)dp[budget] = next_dp[budget];
			}
		}

		int max_effect = -1,min_budget;
		for(int budget = 0; budget <= M; budget++){
			if(max_effect < dp[budget]){
				max_effect = dp[budget];
				min_budget = budget;
			}
		}

		printf("%d %d\n",max_effect,min_budget);
	}
	return 0;
}

Measured memory_bytes: 3216
import java.util.*;
//import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
//		int i,j;
		Scanner sc = new Scanner(in);
		long n = parseLong(sc.next());
		long m = parseLong(sc.next());
		sc.close();
		out.println(abs(n-2)*abs(m-2));
	}
}


Measured memory_bytes: 24148
//02-03-20202

#include<bits/stdc++.h>
using namespace std;
#define MKM(i,a,b) for(int i=a;i<=b;i++)
int main()
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);

    int h,w,n,a,b,Max;
    cin>>h>>w>>n;
    Max=max(h,w);

    MKM(i,1,w)
    {
        a=i*Max;
        if(a>=n)
        {
            b=i;
            break;
        }
    }
    cout<<b<<"\n";
    return 0;   //:D

}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>

#define _GLIBCXX_DEBUG
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n;
    cin >> n;
    vi d(n);
    for(int i=0; i<n; i++){
        cin >> d.at(i);
    }
    priority_queue<int64_t> q;
    for(int i=0; i<n; i++){
        q.push(d.at(i));
    }
    for(int i=0; i<n/2-1; i++){
        q.pop();
    }
    int64_t kmax = q.top();
    q.pop();
    int64_t kmin = q.top();
    cout << kmax - kmin << endl;
 }


Measured memory_bytes: 2168
N = int(input())

if N<10:
    ans = N
elif N<100:
    ans = 9
elif N<1000:
    ans = N - 99 + 9
elif N<10000:
    ans = 900 + 9
elif N<100000:
    ans = N - 9999 + 900 + 9
else:
    ans = 90000 + 900 + 9

print(ans)

Measured memory_bytes: 3060
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	int d, t, s; cin >> d >> t >> s;
    if(d <= t * s) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 3676
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <numeric>
# include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define ALL(x)    (x).begin(),(x).end()
#define UNIQ(c)   (c).erase(unique(ALL((c))), end((c)))
#define mp        make_pair
#define eb        emplace_back
typedef pair<LL, LL> P;
typedef pair<P, P> PP;

int N;
int W[333];

bool dp[333][333];
int dp2[333];
void solve() {
	for (int i = 0; i < N; i++)cin >> W[i];
	for (int i = 0; i < 333; i++)for (int j = 0; j < 333; j++)dp[i][j] = 0;
	for (int i = 0; i < 333; i++) dp2[i] = 0;
	for (int i = 0; i < N; i++)dp[i][i] = true;

	for (int len = 2; len <= N; len++) {
		for (int i = 0; i + len <= N; i++) {
			int j = i + len;
			if (abs(W[i] - W[j - 1]) <= 1)dp[i][j] |= dp[i + 1][j - 1];
			for (int k = i + 1; k < j; k++)dp[i][j] |= dp[i][k] & dp[k][j];
		}
	}
	for (int i = 0; i < N; i++) {
		dp2[i + 1] = max(dp2[i + 1], dp2[i]);
		for (int j = i + 1; j <= N; j++)if (dp[i][j])dp2[j] = max(dp2[j], dp2[i] + j - i);
	}
	cout << dp2[N] << endl;
}
int main() {
	while (cin >> N, N)solve();
}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

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

	vector<int> X;
	map<int, int> Y;
	for (int i = 0; i < m; i++)
	{
		int a, b;
		cin >> a >> b;
		if (a == 1)
			X.push_back(b);
		if (b == n)
			Y[a] = 1;
	}

	bool ans = false;
	for (int i = 0; i < (int)X.size(); i++)
	{
		if (Y.count(X[i]))
			ans = true;
	}
	cout << (ans ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}



Measured memory_bytes: 5368
#include <iostream>
#include <math.h>

int main()
{
	int N = 0, ans = 0;
	std::cin >> N;

	int  K = 0;
	int num = N;
	while (num != 0)
	{
		num /= 10;
		K++;
	}

	switch (K){
		case(1) :
				ans = N; 	break;
		case(2) :
			ans = 9; break;
		case(3) :
			ans = 9 + (N - 100 + 1); break;
		case(4) :
			ans = 9 + 900; break;
		case(5):
			ans = 9 + 900 + (N - 10000 + 1); break;
		case(6):
			   ans = 9 + 900 + 90000;
			break;
	}

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    int N; cin >> N;
    vector<int> A(N), B(N); for (int i = 0; i < N; i++) cin >> A[i] >> B[i];
    vector<int> I(N); iota(begin(I), end(I), 0);
    sort(begin(I), end(I), [&](int i, int j) { return B[i] < B[j]; });
    Int curr = 0;
    bool fail = false;
    for (int i = 0; i < N; i++) {
        int t = I[i];
        curr += A[t];
        if (curr > B[t]) fail = true;
    }
    cout << (fail ? "No" : "Yes") << '\n';
    return 0;
}

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

int main()
{
    int a,count=0;cin>>a;
    int b[a];
    for(int i=1;i<=a;i++){cin>>b[i];
        if(i%2==1){
            if(b[i]%2==1){
                count++;
            }
        }
    }
    std::cout << count << std::endl;
}


Measured memory_bytes: 3620
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = B[A[0]-1]
for i in range(1, N):
    if A[i-1] == A[i] - 1:
        ans += C[A[i-1]-1]
    ans += B[A[i]-1]

print(ans)


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

int main(){
    long x;
    scanf("%ld", &x);
    
    long result = 0;
    for (int i=1;i<x+1;i++){
        if (i % 3 != 0 && i % 5 != 0){
            result = result + i;
        }
    }
    printf("%ld",result);
}

Measured memory_bytes: 1728
from itertools import permutations

n = int(input())
N = [i for i in range(1, n+1)]
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
all = [p for p in permutations(N, n)]
ans = abs(all.index(P) - all.index(Q))
print(ans)


Measured memory_bytes: 13900
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
#define P pair<int,int>
typedef long long ll;
using namespace std;

int main(){
    string s,t; cin >> s >> t;
    int sl=s.length();
    int tl=t.length();
    s='#'+s;
    t='#'+t;
    int dp[sl+1][tl+1];
    rep(i,sl+1) dp[i][0]=0;
    rep(i,tl+1) dp[0][i]=0;

    for(int i=1; i<=sl; i++){
        for(int j=1; j<=tl; j++){
            if(s[i]==t[j]) dp[i][j]=dp[i-1][j-1]+1;
            else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }

    int len=dp[sl][tl];
    string ans="";
    int nowi=sl; int nowj=tl;
    while(len){
        if(s[nowi]==t[nowj]){
            ans=s[nowi]+ans;
            nowi--;
            nowj--;
            len--;
        }
        else if(dp[nowi][nowj]==dp[nowi-1][nowj]) nowi--;
        else nowj--;
    }
    cout << ans << endl;
return 0;
}


Measured memory_bytes: 35456
#include<bits/stdc++.h>
#define cs const
#define pb push_back
using namespace std;
cs int Mod = 1e9 + 7;
int add(int a, int b){ return a + b >= Mod ? a + b - Mod : a + b; }
int dec(int a, int b){ return a - b < 0 ? a - b + Mod : a - b; }
int mul(int a, int b){ return 1ll * a * b % Mod; }
void Add(int &a, int b){ a = add(a,b); }
void Mul(int &a, int b){ a = mul(a,b); }
void Dec(int &a, int b){ a = dec(a,b); }
int ksm(int a, int b){ int as=1; for(;b;b>>=1,Mul(a,a)) if(b&1) Mul(as,a); return as; }
cs int N = 1e5 + 50;
int n; char S[N];
int dp[N], trs[N][2];
int main(){
	#ifdef FSYolanda
	freopen("1.in","r",stdin);
	#endif
	scanf("%s",S+1); n=strlen(S+1); bool ok=true;
	for(int i=1; i<n; i++) if(S[i]==S[i+1]) ok=false;
	if(ok) return puts("1"),0; int k=0; dp[n+1]=1;
	trs[n+1][0]=trs[n+1][1]=trs[n+2][0]=trs[n+2][1]=1;
	for(int i=n,c; i>=1; i--){
		c=S[i]-'a'+1; k=(k+c)%3;
		trs[i][0]=S[i]=='a'?i+1:(S[i+1]=='b'?i+2:trs[i+2][0]);
		trs[i][1]=S[i]=='b'?i+1:(S[i+1]=='a'?i+2:trs[i+2][1]);
		dp[i]=add(dp[trs[i][0]],dp[trs[i][1]])+(k==0);
	} cout<<dec(dp[1],k==0); return 0;
}

Measured memory_bytes: 1536
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        char[] tmp = s.toCharArray();
        
        for(int i=0; i<tmp.length; i++){
            int j = n;
            while(j > 0){
                if(tmp[i] == 'Z'){
                    tmp[i] = 'A';
                }
                else{
                    tmp[i] = (char)(tmp[i]+1);
                }
                j--;
            }
        }
        
        for(char c : tmp){
            System.out.print(c);
        }
    }
}

Measured memory_bytes: 26788
#!/usr/bin/env python3
import sys
import collections

sys.setrecursionlimit(10 ** 7)

# 1 ✕ 1 (str)
S = input().rstrip()

# 1 ✕ 1 (str)
T = input().rstrip()

if len(S) < len(T):
    print("UNRESTORABLE")
    sys.exit()

array = []
for i in range(len(S) - len(T) + 1):
    for t in range(len(T)):
        if S[i + t] not in ("?", T[t]):
            break
    else:
        # tmp = S[:i]
        # tmp += T
        # tmp += S[i + len(T):]
        # tmp.replace("?", "a")
        # array.append(tmp)
        memo = S[:i] + T + S[i + len(T):]
        array.append(memo.replace('?', 'a'))

if len(array) == 0:
    print("UNRESTORABLE")
else:
    print(min(array))
    # print(sorted(list(map(lambda x:, array)))[0])


Measured memory_bytes: 3316
#include<iostream>
#include<algorithm>
//#include<cmath>
//#include<string>
//#include<cctype>
//#include <vector>
using namespace std;
int main() {
	int s = 0,a;
	for (int i = 0; i < 5; i++)cin >> a, s += max(40, a);
	cout << s / 5 << endl;
	return 0;
}

Measured memory_bytes: 2988
package main

import (
	"fmt"
	"sort"
)

func main () {
	var n, l int
	var s []string
	var str string
	fmt.Scanf("%d %d", &n, &l)

	for i := 0; i < n; i++ {
		fmt.Scanf("%s", &str)
		s = append(s, str)
	}
	sort.Strings(s)

	for _, w := range(s) {
		fmt.Printf("%s", w)
	}
	fmt.Println()
}

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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  std::string s;
  std::cin >> s;
  std::fill(s.begin(), s.end(), 'x');
  std::cout << s << std::endl;
  return 0;
}

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

ll l(ll N){
    if (N==0LL){
        return 1LL;
    }
    return l(N-1)*2LL+3LL;
}
ll P(ll N){
    if (N==0LL){
        return 1LL;
    }
    return P(N-1)*2LL+1LL;
}
ll ans(ll N, ll X){
  	if (X==0LL){
      return 0LL;
    }
    if (N==0LL and X==1LL){
        return 1LL;
    }
    if (X==1LL){
        return 0LL;
    }
    if (X<=l(N-1LL)+1LL){
        return ans(N-1LL,X-1LL);
    }
    if (X==l(N-1LL)+2LL){
        return ans(N-1LL,X-2LL)+1LL;
    }
    if (X<=l(N-1LL)*2LL+2LL){
        return P(N-1LL)+ans(N-1LL,X-l(N-1LL)-2LL)+1LL;
    }
    return P(N);
}
int main()
{
    ll N,X;
    cin >> N >> X;
    cout << ans(N,X) << endl;
    return 0;
}

Measured memory_bytes: 256
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [input() for _ in range(n)]

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

l.sort()
print(l[2]*10+l[1]+l[0])




Measured memory_bytes: 9000
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<algorithm>
#include<list>
#include<cmath>
#include<iomanip>
#include<queue>
#include<functional>
#include<climits>
#include<iterator>
#include<unordered_set>
#include<unordered_map>
using namespace std;

const double pi=4*atan(1.0);

template<typename iterator>
iterator search(iterator begin,iterator end,int key){
	if(begin==end)return end;
	iterator itr=begin+(end-begin)/2;
	if(*itr==key)return itr;
	else if(*itr>key){
		iterator ans=search(begin,itr,key);
		return ans==itr?end:ans;
	}
	else{
		iterator ans=search(itr,end,key);
		return ans==end?end:ans;
	}
}

int main() {
	int N;
	cin>>N;
	vector<int> arr(N);
	for(auto& val:arr)
		cin>>val;

	vector<int> s_arr(arr);
	sort(begin(s_arr),end(s_arr));

	long long ans=0;
	for(int i=0;i<arr.size();++i){
		auto itr=search(begin(s_arr),end(s_arr),arr[i]);
		if(i%2!=(itr-begin(s_arr))%2)++ans;
	}

	cout<<ans/2<<endl;

	//system("pause");
	return 0;
}


Measured memory_bytes: 1024
N, M, X= map(int, input().split())
arr=[list(map(int, input().split())) for _ in range(N)]

ans=float('inf')
for paint_h in range(2**N):
	temp_arr=[0]*(M+1)
	for i in range(N):
		if (paint_h>>i)&1==1:
			temp_arr=[a+b for (a, b) in zip(temp_arr, arr[i])]
	if all(i>=X for i in temp_arr[1:]):
		ans=min(ans, temp_arr[0])
print(ans if ans != float('inf') else -1)

Measured memory_bytes: 9184
#include<algorithm>//sort(all(変数),greater<型名>())で降順に、*max_element(all(変数))で最大値を獲得
#include<bits/stdc++.h>
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric>
// xとyのgcdは__gcd(x,y),xとyのlcmは(x*y)/__gcd、accumulate(all(変数),0)で要素の全加算
#include<queue>//priority_queue<型名> 変数
#include<set>
#include<stack>
#include<string>//変数.substr(どこから,いくつ)
#include<vector>
#define rep(i,n)  for(ll i=0; i<n; i++)
#define rrep(i,n) for(ll i=n-1; 0<=i; i--)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF 1e9
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
  int n; cin >> n;
  vi s(n); rep(i,n) cin >> s[i];
  int sum = accumulate(all(s),0);
  sort(all(s));
  for(int i = 0; sum % 10 == 0; i++){
    if((sum-s[i])%10!=0) sum -= s[i];
    if(i == n){
      sum = 0;
      break;
    }
  }
  cout << sum;
  cout << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
#include <iomanip>
using namespace std;

int main(void){
    int n, a[105], min = 1e9, value = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int j = -100; j <= 100; j++) {
        for (int i = 1; i <= n; i++) {
            value += ((a[i] - j) * (a[i] - j));
        }
        if (value < min) min = value;
        value = 0;
    }
    cout << min << endl;
    return 0;
}


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

K, S = map(int, input().split())
count = 0

for x in range(0, K+1):
    for y in range(0, K+1):
        z = S - x - y
        if z < 0 or z > K:
            continue
        if x + y + z == S:
            count += 1

print(count)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
                     
#define int             long long
#define ld              long double
#define mp              make_pair
#define ff              first
#define ss              second
#define pb              push_back
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(i=1;i<=n;i++)
#define FO(i,a,b)       for(i=a;i<=b;i++)
#define FOR(i,a,b)      for(i=a;i>=b;i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<int,int>
#define vpii            vector<pii>
#define vvi             vector<vi>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x)           cout<<setprecision(x)<<fixed;
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define in(a,n)         vi a(n);fo(i,n)cin>>a[i];
#define in1(a,n)        vi a(n+1);fo1(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define sz(v)           (int)v.size()
#define gcd             __gcd
#define lcm(x,y)        x*(y/gcd(x,y))
#define endl            '\n'
#define PI              3.14159265358979323846
const int inf =         1e18;
const int mod =         1e9+7;
void __p(int x) {cout<<x;}
void __p(int32_t x){cout<<x;}
void __p(float x){cout<<x;}
void __p(double x){cout<<x;}
void __p(ld x) {cout<<x;}
void __p(char x){cout <<'\''<<x<<'\'';}
void __p(const char *x){cout <<'\"' <<x<<'\"';}
void __p(const string &x) {cout<<'\"'<<x<<'\"';}
void __p(bool x) {cout<<(x?"true":"false");}
void _p() {cout << "]\n";}
template<typename T,typename V>     void __p(const pair<T,V> &x) {cout<<'{';__p(x.first);cout<<',';__p(x.second);cout<<'}';}
template<typename T>                void __p(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __p(i); cout << "}";}
template <typename T,typename... V> void _p(T t, V... v) {__p(t);if(sizeof...(v))cout<<", ";_p(v...);}
int po(int x,int p) {int ans=1;x%=mod;while(p>0){if(p&1)ans=(ans*x)%mod;p=p>>1;x=(x*x)%mod;}return ans;}
int inv(int x){return po(x,mod-2)%mod;}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_p(x)
#else 
#define dbg(x...)
#endif
//=================================================================================




const int N=1e6+6;
int n,m,k,x,y,z,a,b,c,d,i,j,l,r,f,q;








void sol()
{   
    cin>>n;
    if(n<600)cout<<8;
    else if(n<800)cout<<7;
    else if(n<1000)cout<<6;
    else if(n<1200)cout<<5;
    else if(n<1400)cout<<4;
    else if(n<1600)cout<<3;
    else if(n<1800)cout<<2;
    else cout<<1;
    
    
    
    //cout<<  <<endl;
}





int32_t main()
{   
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //pre();
    //sp(10);
    // w(t)
    sol();
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <utility>
#include <set>
#include <vector>
using namespace std;
 
int max_deg[200] ={};
set<int> vec[200]  ={};
 
void dfs(int x, int p, int d = 0){
    max_deg[d] = max<int>(max_deg[d], vec[x].size());
    for(auto y : vec[x])
        if(y != p)
            dfs(y, x, d + 1);  }
 
using ll = __int128;
 
pair<ll, ll> solve(int center){
    memset(max_deg, 0, sizeof(max_deg));
    dfs(center, -1, 0);
    ll rez = 1;
    int i;
    for(i = 0; max_deg[i]; ++i)
        rez *= max(max_deg[i] - (i != 0), 1);
    return make_pair(i, rez); }
 
pair<ll, ll> solve(int x, int y){
    memset(max_deg, 0, sizeof(max_deg));
    vec[x].erase(y);
    vec[y].erase(x);
 
 
    dfs(x, -1, 0);
    dfs(y, -1, 0);
 
    ll rez = 1;
    int i;
    for(i = 0; max_deg[i]; ++i){
        rez *= max(max_deg[i] - (i != 0), 1); }
 
    vec[x].insert(y);
    vec[y].insert(x);
 
    return make_pair(i, 2 * rez); }
 
int main(){
    
    int n;
    cin >> n;

    if(n == 2){
        cout << 1 << ' ' << 2 << endl;
        return 0; }
    vector<pair<int, int>> e;
    for(int i = 0, x, y; i < n-1; ++i){
        cin >> x >> y;
        e.emplace_back(x, y);
        vec[x].insert(y);
        vec[y].insert(x); }
 
    pair<ll, ll> rez = { 10000000, 0 };
 
    for(int i = 1 ; i <= n; ++i)
        rez = min(rez, solve(i));
 
    for(auto x : e)
        rez = min(rez, solve(x.first, x.second));
 
    cout << (long long)rez.first << ' ' << (long long)rez.second << endl;
    
    return 0; }


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

  int k = n%10;

  if(k==1 or k==0 or k==6 or k==8){
	  cout << "pon" << endl;
  }
  else if(k==3){
	  cout << "bon" << endl;
  }
  else{
	  cout << "hon" << endl;
  }
  return 0;
}

Measured memory_bytes: 3632
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int main(int argc, char **argv) {
	string a, b, c;
	cin >> a >> b >> c;
	cout << (a[a.length() - 1] == b[0] && b[b.length() - 1] == c[0] ? "YES" : "NO") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 10e+6

using namespace std;

int main(){
    bool ans=true;
    int n,a,b,c,d;
    cin >> n >> a >> b >> c >>d;
    string s;
    cin >> s;
    if(d<c){
        bool jama=true; //Bが邪魔になる
        int f=0;//通れるところが連続何個か
        for(int i=b-2;i<=d;i++){
            if(s.at(i)=='#'){
                f=0;
            }
            else if(s.at(i)=='.'){
                f++;
            }
            if(f==3) {
                jama=false;
            }
        }
        //最後だけ２連続しかなくてもいける。
       
        if(jama) ans=false;
        for(int i=d-1;i>b-2;i--){
            //飛び越え処理
            if(s.at(i)=='#'){
                if(s.at(i-1)=='#') {
                    ans=false;
                    break;
                }
                else{
                    i--;
                }
            }
        }
        for(int i=c-1;i>a-2;i--){
            //飛び越え処理
            if(s.at(i)=='#'){
                if(s.at(i-1)=='#') {
                    ans=false;
                    break;
                }
                else{
                    i--;
                }
            }
        }
    }
    else{
        for(int i=d-1;i>b-2;i--){
            //飛び越え処理
            if(s.at(i)=='#'){
                if(s.at(i-1)=='#') {
                    ans=false;
                    break;
                }
                else{
                    i--;
                }
            }
        }
        
        
        
        for(int i=c-1;i>a-2;i--){
            //飛び越え処理
            if(s.at(i)=='#'){
                if(s.at(i-1)=='#') {
                    ans=false;
                    break;
                }
                else{
                    i--;
                }
            }
        }
    }
    
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}




Measured memory_bytes: 640
using namespace std;
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<cfloat>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(ll i=0;i<n;i++)
#define Rip(i,n) for(ll i=1;i<n;i++)
#define all(V) V.begin(),V.end()
#define ll long long
#define ld long double
#define MOD 998244353
#define mod MOD
#define sec setprecision
constexpr double eps = 1e-9;
constexpr double PI = 3.141592653589793238462643383279;
ll gcd(ll a, ll b) {
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
int ketasuu(ll h) {
	if (h < 0)return(-(ketasuu(-h)));
	else if (h < 10)return(1);
	else return(1 + ketasuu(h / 10));
}
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void cominit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
vector<ll> soinnsuubunnkai(ll n) {
	vector<ll>a;
	while (n % 2 == 0) {
		a.push_back(2);
		n /= 2;
	}
	ll f = 3;
	while (f * f <= n) {
		if (n % f == 0) {
			a.push_back(f);
			n /= f;
		}
		else f += 2;
	}
	if (n != 1)
		a.push_back(n);
	return(a);
}
// 二項係数計算
long long com(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
ll pow(ll a, ll b) {
	a = a % mod;
	if (b == 0)return(1);
	else if (b % 2 == 0)return(pow((a * a) % mod, b / 2));
	else return(a * (pow(a, b - 1)));
}
void solve() {
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(b, n * a) << endl;
}
int main() {
	solve();
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES cout<<"YES"<<'\n'
#define NO cout<<"NO"<<'\n'
#define Yes cout<<"Yes"<<'\n'
#define No cout<<"No"<<'\n'
#define yes cout<<"yes"<<'\n'
#define no cout<<"no"<<'\n'
void YN(bool flg) {cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg) {cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg) {cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) cout << n << '\n'
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n >>= 1; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    string s; cin >> s;
    cout << s[0] << s.length()-2 << s.back() << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split())) 
# -+-+-
cost1 = 0
sum1 = 0
for i in range(N):
    sum1 += A[i]
    if (i + 1) % 2 == 0 and sum1 <= 0:
        cost1 += (abs(sum1) + 1)
        sum1 = 1
    if (i + 1) % 2 != 0 and sum1 >= 0:
        cost1 += (abs(sum1) + 1)
        sum1 = -1

# +-+-+
cost2 = 0
sum2 = 0
for i in range(N):
    sum2 += A[i]
    if (i + 1) % 2 == 0 and sum2 >= 0:
        cost2 += (abs(sum2) + 1)
        sum2 = -1
    if (i + 1) % 2 != 0 and sum2 <= 0:
        cost2 += (abs(sum2) + 1)
        sum2 = 1

print(min(cost1, cost2))

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



class UnionFind():

    # https://note.nkmk.me/python-union-find/

    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


# スペース区切りの整数の入力
n, m = map(int, input().split())

uf = UnionFind(n)
# print(uf)
for i in range(m):
  # print("---")
  a, b = map(int, input().split())
  uf.union(a-1, b-1)
  # print(uf)

roots = uf.roots()
ans = 0
for i in roots:
  ans=max(ans, uf.size(i))

print(ans)


Measured memory_bytes: 18292
#include <stdio.h>
int main(void){
	int k;
	scanf("%d",&k);
	//奇数の数を求める
	int oddnumber=(k+1)/2;
	//偶数の数を求める
	int evennumber=k/2;
	//それらを掛け算して出力する
	printf("%d",oddnumber*evennumber);
	return 0;
}

Measured memory_bytes: 128
import sys
input=sys.stdin.readline

def main():
    N=int(input())
    R=[]
    for _ in range(N):
        R.append(list(map(int, input().split())))
    B=[]
    for _ in range(N):
        B.append(list(map(int, input().split())))

    B.sort(key=lambda x:x[0]) # Bをxでソート
    ans = 0
    while B:
        Bm = []
        for b in B:
            if b[0] == B[0][0]:
                Bm.append(b)
        Bm.sort(key=lambda x:x[1]) # xが最小のbのリストを、yでソート

        while Bm:
            b = Bm[0] # xが最小のbを、yが小さい順に処理
            cr = []
            for r in R:
                if r[0]<=b[0] and r[1]<=b[1]:
                    cr.append(r) # ペア候補
            if cr:
                cr.sort(key=lambda x:x[1]) # 候補のうち、yが最大のもの
                R.remove(cr[-1])
                ans += 1
            Bm.remove(b)
            B.remove(b)

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
	int moun[10];
	int height[10001] = {0};
	int sub = 3;
	int i;
	
	for (i = 0; i < 10; i++){
		scanf("%d", &moun[i]);
		height[moun[i]]++;
	}
	while (1){
		for (i = 10000; i >= 0; i--){
			if (height[i] > 0){
				printf("%d\n", i);
				height[i]--;
				sub--;
				break;
			}
		}
		if (sub == 0)break;
	}
	
	return (0);
}

Measured memory_bytes: 1900
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define mp	    make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define MOD        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define rep(i,a,b)  for(int i=a;i<b;i++)

void solve(){
	int a, b;
	cin>>a>>b;
	string s;
	cin>>s;
	rep(i,0,sz(s)){	
		if(i == a){
			if(s[i] != '-'){
				cout<<"No"<<endl; 
				return;
			}
		}
		else if(s[i] < '0' || s[i] > '9'){
			cout<<"No"<<endl;
			return;
		}
	}
	cout<<"Yes"<<endl;
}

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i)

string alpha = "abcdefghijklmnopqrstuvwxyz";
const int mod = 1e9+7;
const int inf = 2e18+5;
const int nax = 200010;
const int mod1 = 998244353;
signed main()
 {
   
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 
  int k,n;
  cin>>k>>n;
  if(k >=10)
  {
    cout<<n;
    return 0;
  }
  int ans = n + ((100) * (10 - k));
  cout<<ans;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main(int argc, char *argv[]) {
	int a, b;
	cin >> a >> b;
	
	int ans = 0;
	if (a > b) {
		ans += a;
		a -= 1;
	} else {
		ans += b;
		b -= 1;
	}
	if (a > b) {
		ans += a;
		a -= 1;
	} else {
		ans += b;
		b -= 1;
	}
	
	cout << ans << endl;
}

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

int main(){
  int N,M;cin>>N>>M;
  vector<int> v;
  for(int i=1;i*i<=M;i++)if(M%i==0){
    v.push_back(i);
    if(M/i!=i) v.push_back(M/i);
  }
  sort(v.begin(),v.end());
  int c=*lower_bound(v.begin(),v.end(),N);
  cout<<M/c<<endl;
  return 0;
}

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

int main(int argc, char** argv)
{
	int K;
	std::string S;
	std::cin >> K >> S;
	if (S.length() > K)
	{
		std::cout << S.substr(0, K) << "..." << std::endl;
	}
	else
	{
		std::cout << S << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3628
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int T = sc.nextInt();
		
		List<Integer> list = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			int c = sc.nextInt();
			int t = sc.nextInt();
			if (t <= T) list.add(c);
		}
		sc.close();
		
		if (list.isEmpty()) {
			System.out.println("TLE");
			return;
		}
		
		list.sort((a, b) -> a - b);
		System.out.println(list.get(0));
		
	}
}




Measured memory_bytes: 32592
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String[] args) {
        FastScanner sc=new FastScanner(System.in);
        long n=sc.nextLong();
        long a=sc.nextLong();
        long b=sc.nextLong();
        long ans=0;
       ans=(n/(a+b))*a+Math.min(a,n%(a+b));
       System.out.println(ans);
       
        
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream stream) {
            try {
                br = new BufferedReader(new
                    InputStreamReader(stream));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong()
        {
            return Long.parseLong(next()); 
        }
    }

}


Measured memory_bytes: 23120
import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array,
  std.functional, std.container, std.typecons;

void main() {
  int n = readln.chomp.to!int;
  int[] p = readln.split.to!(int[]);

  int ans = 0;
  foreach(i; 1..(n-1)) {
    auto sorted = [p[i-1], p[i], p[i+1]].sort();
    if(sorted[1] == p[i]) ans++;
  }
  ans.writeln;
}


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

ll N, D;

int main(){
    cin >> N >> D;
    cin.ignore();
    ll cnt = 0;
    for(ll i = 0; i < N; i++){
        ll X, Y;
        cin >> X >> Y;
        cin.ignore();

        ll r2 = X * X + Y * Y;
        if(r2 <= D * D){
            ++cnt;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define inf (int)(1e9)

int main(){
	int N, M, i, j, k, v;
	scanf("%d%d", &N, &M);
	vector<int> A(M), B(M);
	vector<vector<int>> from(N, vector<int>(0)), to(N, vector<int>(0));
	for(i = 0; i < M; i++){
		scanf("%d%d", &A[i], &B[i]);
		A[i]--;
		B[i]--;
		to[A[i]].push_back(B[i]);
		from[B[i]].push_back(A[i]);
	}
	int K = inf;
	vector<int> ans(0);
	for(i = 0; i < M; i++){
//		printf("(A, B)(%d) = (%d, %d)\n", i, A[i], B[i]);
		vector<int> dis(N, inf);
		queue<pair<int, int>> q;
		q.push(pair<int, int>(B[i], 0));
		while(q.size() > 0){
			j = q.front().first;
			v = q.front().second;
			q.pop();
			if(dis[j] <= v){
				continue;
			}
			dis[j] = v;
			for(k = 0; k < to[j].size(); k++){
				q.push(pair<int, int>(to[j][k], v + 1));
			}
		}
/*		printf("dis:\n");
		for(j = 0; j < N; j++){
			printf("%d ", dis[j]);
		}
		printf("\n");
*/		if(dis[A[i]] + 1 < K){
			K = dis[A[i]] + 1;
			ans.assign(0, 0);
			for(j = A[i];;){
				ans.push_back(j);
//				printf("j = %d\n", j);
				if(j == B[i]){
					break;
				}
				for(k = 0; k < from[j].size(); k++){
					if(dis[from[j][k]] + 1 == dis[j]){
						j = from[j][k];
						break;
					}
				}
			}
		}
	}
	if(K < inf){
		printf("%d\n", K);
		for(i = 0; i < K; i++){
			printf("%d\n", ans[i] + 1);
		}
	}
	else{
		printf("-1\n");
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long int l1;
typedef vector <int> vi;
typedef vector <long long int> v1;
#define pb push_back
#define iter(i,a,b) for(i=a;i<b;i++)


int main()
{
    ios_base::sync_with_stdio(false);      //for fast cin and cout streams
    cin.tie(NULL);
    cout.tie(NULL);
    int test=1;
    while(test--)
{
int n;
      cin>>n;
      vector<string>vec(n);
      int i;
      iter(i,0,n)
        cin>>vec[i];
      int ac=count(vec.begin(),vec.end(),"AC");
      int wa=count(vec.begin(),vec.end(),"WA");
      int tle=count(vec.begin(),vec.end(),"TLE");
      int re=count(vec.begin(),vec.end(),"RE");
      cout<<"AC x "<<ac<<"\n"<<"WA x "<<wa<<"\n"<<"TLE x "<<tle<<"\n"<<"RE x "<<re;
		







}

return 0;
}






Measured memory_bytes: 6360
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rrep(i,n,a) for(int i=n;i>=a;i--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define all(s) s.begin(),s.end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define pcnt(n) __builtin_popcount(n)
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const double PI = acos(-1);

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    cout<<s.substr(0,3)<<endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int N = 100010;
int r[30][N]={};

int v[N]={};

int main()
{
    int n,c;
    cin >>n >>c;
    rep(i,n)
    {
        int s,t;
        cin >>s >>t >>c;
        --c;

        ++r[c][s];
        --r[c][t];
    }

    rep(cc,30)rep(i,N-1) r[cc][i+1] += r[cc][i];
    rep(cc,30)
    {
        rep(i,N-1)
        {
            if(r[cc][i]==0 && r[cc][i+1]==1) ++r[cc][i];
        }

        rep(i,N) v[i] += r[cc][i];
    }

    int ans = 0;
    rep(i,N) ans = max(ans,v[i]);
    cout << ans << endl;
    return 0;
}


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

int main()
{
	vector <int> v(3);
	cin >> v[0] >> v[1] >> v[2];

	sort(v.begin(), v.end());

	cout << v[1] - v[0] + v[2] - v[1] << endl;

	return 0;
}


Measured memory_bytes: 256
import itertools
import math
N = int(input())
XY = [list(map(int,input().split())) for _ in range(N)]
#print(XY)

S = list(itertools.permutations(XY))
D = []
for s in S:
  #print(s)
  d = 0
  for i in range(1,len(s)):
      d += math.sqrt((s[i-1][0] - s[i][0])**2 + (s[i-1][1] - s[i][1])**2)
  D.append(d)
#print(D)
print(sum(D)/math.factorial(N))



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

using namespace std;

int ans, sum, n, m, a[10000];

int main(){
	cin >> n >> m;
	for(int i = 0; i < m; ++i){
		cin >> a[i];
		sum += a[i];
	}
	if(n - sum < 0){
		cout << -1 << endl;
		return 0;
	}
	cout << n - sum << endl;
}


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

int main() {
  int D, N, Ans;
  cin >> D >> N;
  if(D==0 && N%100!=0) Ans=N;
  else if(D==0 && N%100==0) Ans=N+1;
  else if(D==1 && N*100%10000!=0) Ans=N*100;
  else if(D==1 && N*100%10000==0) Ans=(N+1)*100;
  else if(D==2 && N*10000%1000000!=0) Ans=N*10000;
  else if(D==2 && N*10000%1000000==0) Ans=(N+1)*10000;
  cout << Ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + (ll)b) % mod
#define MUL(a, b) a = (a * (ll)b) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rer(i, a, b) for(int i = a - 1; i >= b; i--)
#define all(a) (a).begin(), (a).end()
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef pair<int, pi> ppi;
typedef vector<ll> vec;

const int MAX_N = 200010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;

void Debug() {cout << '\n'; }

template<class FIRST, class... REST> 
void Debug(FIRST arg, REST... rest) { cout << arg << " "; Debug(rest...); }

template<class T>
ostream& operator<< (ostream& out, const vector<T>& v) {
	out << "[";
	if(!v.empty()) {
		rep(i, 0, (int)v.size() - 1) out << v[i] << ", ";
		out << v.back();
	}
	out << "]";
  return out;
}

template<class S, class T>
ostream& operator<< (ostream& out, const pair<S, T>& v) {
	out << "(" << v.first << ", " << v.second << ")";
	return out;
}

///g++ -g3 -std=c++0x -DLOCAL -Wall -ftrapv -D_GLIBCXX_DEBUG -Wl,-stack,268435456 -o
///g++ -O2 -std=c++0x -DLOCAL -Wall -Wl,-stack,268435456 -o

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

int A[8] = {0, 400, 800, 1200, 1600, 2000, 2400, 2800};
int B[8] = {400, 800, 1200, 1600, 2000, 2400, 2800, 3200};

bool C[8];
int N;

void solve() {
	cin >> N;
	int target = 0;
	rep(i, 0, N) {
		int a; cin >> a;
		bool found = false;
		rep(i, 0, 8) {
			if(A[i] <= a && a < B[i]) {
				C[i] = true;
				found = true;
				break;
			}
		}
		if(!found) target++;
	}
	int cnt = 0;
	rep(i, 0, 8) if(C[i]) cnt++;
	cout << max(1, cnt) << " " << target + cnt << '\n';
}

int main() {
	ios::sync_with_stdio(false);
    cin.tie(0);	
    cout << fixed;
	cout.precision(20);
#ifdef LOCAL
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) = println(run {
    val (n,m,x,y) = readLine()!!.split(" ").map { it.toInt() }
    val a = readLine()!!.split(" ").map { it.toInt() }
    val b = readLine()!!.split(" ").map { it.toInt() }

    if (Math.max(x, a.max()!!) < Math.min(y, b.min()!!)) "No War" else "War"
})


Measured memory_bytes: 36132