akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz size
#define f first
#define s second

// int arr[100001];

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int N, M;
    cin >> N >> M;

    int L, R;
    int u, l;
    u = 100002;
    l = -1;

    F0R (i, M)
    {
        cin >> L >> R;
        if (u > R)
            u = R;
        if (l < L)
            l = L;
    }

    if (u - l + 1 < 0)
        cout << 0;
    else
        cout << u - l + 1;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;


int main(){
    fast_io

    int x, n;
    cin>>x>>n;
    vector<int> p(n);
    vector<int> num(105, 0);
    rep(i,n) {
        cin>>p[i];
        num[p[i]-1]=1;
    }
    if(n==0) {
        cout<<x<<endl;
        return 0;
    }
    x--;
    if(num[x]==0){
        cout<<x+1<<endl;
        return 0;
    }
    int left=x;
    int right=x+1;
    while(num[left]==1 && left>=0) left--;
    while(num[right]==1 && right<=100) right++;
    if(x-left <= right-x) cout<<left+1<<endl;
    else cout<<right+1<<endl; 
    return 0;
}


Measured memory_bytes: 3640
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string.h>
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%I64d",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define INF                         (int)1e9
#define EPS                         1e-9
#define bitcount                    __builtin_popcount
#define gcd                         __gcd
#define forall(i,a,b)               for(int i=a;i<b;i++)
#define foreach(v, c)               for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ( (b).find(a) != (b).end())
#define pb                          push_back
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define mp                          make_pair
#define MOD                         1000000007
typedef long long ll;
/*For you see , each day i love you
 more.Today more than yesterday
  less than tomorrow.*/
using namespace std;

int main()
{
	int n;s(n);
	vector<ll> vec;
	
	for(int i = 0;i<n;i++)
	{
		ll x;cin>>x;
		vec.push_back(x);
	}
	
	ll val = 0;
	
	for(int i = 1;i<n;i++)
	{
		if(vec[i] <= vec[i-1])
		{
			val+=(vec[i-1] - vec[i]);
			vec[i] = vec[i-1];	
		}	
	}
	
	cout<<val<<endl;
	
	return 0;
}

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

using namespace std;
 
#define MAX 4000
int num[MAX+1], cnt[MAX/2+1];
 
void make()
{     
    for (int i = 0; i <= MAX/4; i++) {
        for (int j = 0; j <= MAX/4; j++) {
            ++cnt[i+j];
	}
    }
     
    for (int i = 0; i <= MAX/2; i++) {
        for (int j = 0; j <= MAX/2; j++) {
            num[i+j] += cnt[i] * cnt[j];
	}
    }
}
 
int main()
{
    int n;
    make(); 
    while (cin >> n) {
	cout << num[n] << endl;
    }
    return 0;
}

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

restaurants = {}

for i in range(n):
    s, p = [j for j in input().split()]
    if s in restaurants:
        restaurants[s].append([int(p), i])
    else:
        restaurants[s] = [[int(p), i]]

for ip in sorted(restaurants.items()):
     for i in sorted(ip[1], reverse=True):
         print(i[1] + 1)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;

const int INF = INT_MAX;
const long long INFL =LONG_LONG_MAX;
const double PI = atan(1)*4;
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}


int main() {
    ll a, b;cin>>a>>b;

    if(a>0)puts("Positive");
    else if(b>=0)puts("Zero");
    else if((b-a+1)%2 == 0)puts("Positive");
    else puts("Negative");
    
    return 0;
}










Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
def gcd(a, b):
  while b:
    a, b = b, a%b
  return a
al=[]
ar=[]
tmp=a[0]
al.append(a[0])
for ai in a[1:]:
  tmp=gcd(ai,tmp)
  al.append(tmp)
ar.append(a[-1])
tmp=a[-1]
for ai in a[:-1][::-1]:
  tmp=gcd(ai,tmp)
  ar.append(tmp)
ans=ar[n-2]
for i in range(n-1):
  ans=max(ans,gcd(al[i],ar[n-i-3]))
ans=max(ans,al[n-2])
print(ans)



Measured memory_bytes: 14488
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define x first
#define y second

using namespace std;

typedef long long ll;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0);
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    if (a + b <= 2 * c) cout << x * a + y * b;
    else
    {
        int sum = min(x, y) * 2 * c;
        if (x >= y) sum += min(2 * c, a) * (x - y);
        else sum += min(2 * c, b) * (y - x);
        cout << sum;
    }
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <chrono>
#include <cstring>

using namespace std;

typedef long long ll;

#define int long long

int n, m, v, p;
vector <int> a;

bool check(int pos) {
	if (pos < p) {
		return true;
	}
	if (a[pos] + m < a[p - 1]) {
        return false;
	}
	int vv = v;
	vv -= n - pos;
	vv -= p - 1;
	if (vv <= 0 && a[pos] + m >= a[p - 1]) {
		return true;
	} else if (vv <= 0) {
		return false;
	}
	vector <int> b;
	for (int i = p - 1; i < pos; i++) {
		b.push_back(a[i]);
	}
	int sz = (int) b.size();
	int fval = a[pos] + m;
	ll sum = 0;
	for (int i = 0; i < sz; i++) {
		int t = fval - b[i];
		sum += min(m, fval - b[i]);
	}
	if (sum >= vv * m) {
		return true;
	}
	return false;
}

int32_t main() {
	cin >> n >> m >> v >> p;
	a.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	map <int, int> poss;
	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());
	int l = 0, r = n - 1;
	int res = 0;
	while (l <= r) {
		int mid = (l + r) / 2;
		if (check(mid)) {
			l = mid + 1;
			res = mid;
		} else {
			r = mid - 1;
		}
	}
	for (int i = 0; i < n; i++) {
		if (a[i] >= a[res]) {
			poss[a[i]] = true;
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (poss[a[i]]) {
			ans++;
		}
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 7340
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>

using namespace std;

static const int INF = 1e9 + 7;



int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> c(m);
    c.resize(m);
    for(auto&& i : c){
        cin >> i;
    }
    sort(begin(c), end(c));
    vector<int> dp(n + 1, INF);
    dp[0] = 0;
    for(int i = 0; i < m; i++){
        for(int j = c[i]; j <= n; j++){
            dp[j] = min(dp[j], dp[j - c[i]] + 1);
        }
    }
    cout << dp[n] << "\n";
}


Measured memory_bytes: 3236
// [[ABC134C] Exception Handling] https://www.luogu.com.cn/problem/AT4843
#include <algorithm>
#include <iostream>
#include <map>
using namespace std;
int AC[105000], ACans, WAans, WA[105000];
int main() {
  int n, m;
  cin >> n >> m;

  int p;
  string S;
  while (m--) {
    cin >> p >> S;
    if (AC[p]) continue;
    if (S == "AC") {
      AC[p] = true;
      ACans++;
      WAans += WA[p];
    } else if (S == "WA") {
      WA[p]++;
    }
  }
  cout << ACans << " " << WAans << endl;
  return 0;
}


Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	sc.Scan()
	var inputs []int
	for _, v := range strings.Split(sc.Text(), " ") {
		tmp, _ := strconv.Atoi(v)
		inputs = append(inputs, tmp)
	}

	var flag bool
	var count int
	for {
		if flag {
			break
		}
		flag = true
		for i := range inputs[:len(inputs)-1] {
			if inputs[i] > inputs[i+1] {
				tmp := inputs[i]
				inputs[i] = inputs[i+1]
				inputs[i+1] = tmp
				flag = false
				count++
			}
		}
	}

	fmt.Printf("%d", inputs[0])
	for _, v := range inputs[1:] {
		fmt.Printf(" %d", v)
	}
	fmt.Printf("\n%d\n", count)

}



Measured memory_bytes: 1140
//#define _CRT_SECURE_NO_WARNINGS
//#include <bits/stdc++.h>
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()

#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
#define MAX_N (100001)
typedef long long ll;

using namespace std;



signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	vector<int> v(n, 0);
	rep(i, n - 1) {
		int k; cin >> k; k--;
		v[k]++;
	}
	rep(i, n) {
		cout << v[i] << "\n";
	}
}


Measured memory_bytes: 4788
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <cstdio>
#include<cctype>
using namespace std;

int main()
{
	char ch;
	int cnt[26] = {};
	while (scanf("%c",&ch)!=EOF) {
		ch = tolower(ch);
		if (isalpha(ch)) {
			cnt[ch - 'a']++;
		}
		
	}
	
	for (int i = 0; i < 26; i++) {
		printf("%c : %d\n", i + 'a', cnt[i]);
	}


	return 0;
}

Measured memory_bytes: 3180
s = input()
c = 0

if len(s) < 2 or len(s) > 26:
    quit()
if len(s) >= 2 and len(s) <= 26:
    s2 = ''.join(sorted(s))
    for i in s2:
        if c+1 >= len(s):
            break
        elif s2[c] == s2[c+1]:
             print('no')
             quit()
        else:
            c = c + 1
print('yes')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

int power(int n){
	return n*n*n*n*n;
}


int32_t main(){
	int x;
	cin >> x;

	
	int cur = 1;
	
	map<int,int> m;
	m[0] = 0;
	m[1] = 1;
	while(power(cur) <= 1e18){
		m[power(cur)] = cur;
		cur++;
	}
	
	if(m.count(x)){
		cout << m[x] << " " << 0 << endl;
		return 0;
	}
	
	
	for(auto e : m){
		int a1 = x + e.first;
		int a2 = x - e.first;
		
		if(m.count(a1)){
			cout << m[a1] << " " << e.second;
			return 0;
		}
		
		if(a2 > 0 && m.count(a2)){
			cout << m[a2] << " " << -e.second;
			return 0;
		}
	}

	return 0;
}



Measured memory_bytes: 3860
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
#include <cstring>
#include <numeric>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define repll(i,n) for(long long int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
template <typename T_char>
char ToUpper (char cX) { return toupper(cX); }
//g++ -std=c++1z temp.cpp
//./a.exe
ll digit(ll a){
    ll count = 0;
    for (ll i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }
    }
    return count;
}

uintmax_t comb(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}
//桁数のカウント
//pow(x,n) == x^n
//sum = accumulate(v.begin(),v.end(),0);
using Graph = vector<vector<int>>;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a,   b) * b;}


int digsum(int n) {
      int res = 0;
      while(n > 0) {
          res += n%10;
          n /= 10;
      }
      return res;
  }
#include <iomanip>


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

ll a,b,v,w,t;
cin >> a >> v >> b >> w >> t;

if((abs(a-b)+w*t)>v*t) cout << "NO" << endl;
else cout << "YES" << endl;





//////////////////////////////////////////////////////
return 0;}


Measured memory_bytes: 3652
x,n=map(int,input().split())
if n==0:
  print(x)
  exit()
p=[int(y) for y in input().split()]
a=0
for i in range(101):
  if x-a not in p:
    print(x-a)
    break
  elif x+a not in p:
    print(x+a)
    break
  a+=1

Measured memory_bytes: 9036
n = int(input())
A = list(map(int, input().split()))
count = 0
for i in range(n):
    if A[i]<0:
        A[i] = -A[i]
        count += 1
if count % 2 == 1:
    print(sum(A)-2*min(A))
else:
    print(sum(A))

Measured memory_bytes: 14412
use std::io;

fn main() {
    loop {
        let numbers = input_number();
        let h = numbers[0];
        let w = numbers[1];
        if h == 0 && w == 0 { break }
        for _ in 0..h {
            let mut output = "#".to_string();
            for _ in 1..w {
                output = output + "#";
            }
            println!("{}", output);
        }
        println!("");
    }
}

#[allow(dead_code)]
fn input_number() -> Vec<i64> {
    let mut input = String::new();

    io::stdin().read_line(&mut input)
        .expect("Failed to read line");

    let vec: Vec<i64> = input
        .split_whitespace()
        .map(|x| x.parse().unwrap_or(0))
        .collect();
    vec
}



Measured memory_bytes: 5024
h, w = (int(i) for i in input().split())
e = [[int(i) for i in input().split()] for i in range(h)]

res = []
for j in range(h)[::2]:
    for i in range(w):
        if e[j][i] % 2 == 1:
            if i < w-1:
                e[j][i+1] += 1
                res.append("{} {} {} {}".format(j+1, i+1, j+1, i+2))
            else:
                if j<h-1:
                    e[j+1][i] += 1
                    res.append("{} {} {} {}".format(j+1, i+1, j+2, i+1))

    if j+1 >= h:
        break

    for i in range(w)[::-1]:
        if e[j+1][i] % 2 == 1:
            if 0 < i:
                e[j+1][i-1] += 1
                res.append("{} {} {} {}".format(j+2, i+1, j+2, i))
            else:
                if j+1<h-1:
                    e[j+2][i] += 1
                    res.append("{} {} {} {}".format(j+2, i+1, j+3, i+1))

print(len(res))
for x in res:
    print(x)



Measured memory_bytes: 68316
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<unordered_set>
#include<map>
#include<cmath>
#include <iterator>
#include<stack>
#include<queue>
#include <iomanip>
#include<math.h>
#include <limits.h>
#include <numeric>
#include <functional>
#include<fstream>
#include <bitset>
#include <cstring>
using namespace std;

#define ll  long long
#define endl '\n'
const ll mod = 1000000007;
ll dp[3][(int)1e5 + 1], a[3][(int)1e5 + 1];
int x;
ll f(int i,int j) {
	if (j == x)
		return 0;
	else if (dp[i][j] != -1)
		return dp[i][j];
	else if (i == 0)
		return dp[i][j] = a[i][j] + max(f(1, j + 1), f(2, j + 1));
	else if (i==1)
		return dp[i][j] = a[i][j] + max(f(0, j + 1), f(2, j + 1));
	else if (i == 2)
		return dp[i][j] = a[i][j] + max(f(0, j + 1), f(1, j + 1));
}
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cin >> x;
	int l = 0, c = 0;
	for (int i = 0; i < x; i++)
	{
		l = 0;
		for (int j = 0; j < 3; j++) {
			cin >> a[l][c];
			l++;
		}
		c++;
	}
	memset(dp, -1, sizeof(dp));
	ll mx = 0;
	for (int i = 0; i < 3; i++)
		mx = max(mx, f(i, 0));
	cout << mx << endl;
	return 0;
}

Measured memory_bytes: 9600
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define pii pair<ll,ll>
#define vi(x) vector<x>
#define maxn 300005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;
ll n,m;
ll mx[300005];
ll ma[300005];
vector<ll> adj[300005];
signed main()
{
    fast;
  
    ll k,i,j,ans=0;
    cin>>n>>m>>k;
    vector<pii> v;
    vector<ll> ox;
    for(i=0;i<k;i++)
    {
    	ll x,y;
    	cin>>x>>y;
        if(!mx[x]) ox.pb(x);
        mx[x] = 1;
        ma[y]++;
        adj[x].pb(y);
    }
    multiset<pii> mu;
    for(i=1;i<=m;i++)
    {
    	mu.in({ma[i],i});
    }
    for(auto u: ox)
    {
    	ll temp = adj[u].size();
    	for(auto j: adj[u])
    	{
    		mu.erase(mu.find({ma[j],j}));
    		ma[j]--;
    		mu.in({ma[j],j});
    	}
    	pii st = *mu.rbegin();
    	for(auto j: adj[u])
    	{
    		mu.erase(mu.find({ma[j],j}));
    		ma[j]++;
    		mu.in({ma[j],j});
    	}
    	ans = max(ans,temp + st.fi);
    }
    cout<<ans;
}

Measured memory_bytes: 45360
(let ((n (read))
    (s 0))
    (dotimes (i n)
        (let ((a (read)))
            (if (not (zerop (rem a 2)))
                (incf s)
            )
        )
    )
    (if (zerop (rem s 2))
        (princ "YES")
        (princ "NO")
    )
)

Measured memory_bytes: 76084
N = int(input())
words = []
for inp in range(N):
	words.append(input())

frst = words[0]
wrds = set(words)
if len(wrds) != len(words):
	print("No")
else:	
	for i in range(1,len(words)):
		flag = 1
		if words[i-1][-1] != words[i][0]:
			print("No")
			flag = 0
			break
	if flag == 1:
		print("Yes")  


Measured memory_bytes: 3060
n, m = (int(i) for i in input().split())
a = list(map(int, input().split()))

vote_sum = sum(a)
threshold = vote_sum / (4*m)

pick = 0
for a_i in a:
    if(a_i >= threshold):
        pick += 1
if (pick >= m):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
const ll MOD = 1e9+7;

int main(){
  int n;
  while(cin>>n,n){
	string s[1111];
	for(int i=0;i<n;i++){
	  cin>>s[i];
	  for(int j=0;j<s[i].size();j++){
		if(s[i][j]=='.')continue;
		if(j==0)break;
		s[i][j-1]='+';
		break;
	  }
	  for(int j=0;j<1111;j++)s[i]+='.';
	}
	//  for(int i=0;i<n;i++)cout<<s[i]<<endl;
	for(int i=0;i<1111;i++){
	  int mode=0;
	  for(int j=n-1;j>=0;j--){
		if(s[j][i]=='+')mode=1;
		else if(s[j][i]!='.')mode=0;

		if(s[j][i]=='.'){
		  s[j][i]=(mode?'|':' ');
		}
	  }
	}
	for(int i=0;i<n;i++){
	  int f=0;
	  for(int j=0;;j++){
		if('a'<=s[i][j]&&s[i][j]<='z')f=1;
		if(f&&(s[i][j]==' '||s[i][j]=='.'))break;
		cout<<s[i][j];
	  }
	  cout<<endl;
	}
  }
  return 0;
}



Measured memory_bytes: 5580
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
	unsigned short N, L, i, j;
	char *buf, **ptr, *tmp;
	scanf("%hu %hu", &N, &L);
	scanf("%*c");
	L++;
	buf = malloc(N * L);
	ptr = malloc(sizeof(char *) * N);
	memset(buf, 0, N * L);
	memset(ptr, 0, sizeof(char *) * N);
	for (i = 0; i < N; i++) {
		ptr[i] = buf + i * L;
		scanf("%100[^\n]%*[^\n]", ptr[i]);
		scanf("%*c");
		for (j = i; 0 < j; j--) {
			if (strncmp(ptr[j], ptr[j - 1], L) < 0) {
				tmp        = ptr[j];
				ptr[j]     = ptr[j - 1];
				ptr[j - 1] = tmp;
			}
		}
	}
	for (i = 0; i < N; i++) {
		printf("%s", ptr[i]);
	}
	printf("\n");
	free(buf);
	free(ptr);
	return 0;
}


Measured memory_bytes: 128
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    ll n,m,x[100001];
    std::cin >> n>>m;
    ll s[100001];
    for (int i = 0; i < m; i++) {
        std::cin >> x[i];
    }
    if(m <= n){
        std::cout << 0 << std::endl;
        return 0;
    }
    sort(x,x+m);
    
    for (int i = 0; i < m-1; i++) {
        s[i] = x[i+1] - x[i];
    }
    
    sort(s,s+m-1);
    
    
    ll result = 0;
    for (int i = 0; i < m-n ; i++) {
        result += s[i];
    }
    std::cout << result << std::endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>
#include <sstream>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

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

    if(N == 1 and M >=3)
        cout << M - 2 << endl;
    else if(N >= 3 and M == 1)
        cout << N - 2 << endl;
    else if(N ==2 or M == 2)
        cout << 0 << endl;
    else
        cout << (N - 2) * (M - 2) << endl;
}

Measured memory_bytes: 3572
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
static const int N = 1000;

int lcs(string X, string Y){
  int c[N+1][N+1];
  int m = X.size();
  int n = Y.size();
  int maxl = 0;
  X = ' ' + X;  // X[0]に空白を挿入
  Y = ' ' + Y;  // X[0]に空白を挿入
  for (int i = 0; i <= m; i++) c[i][0] = 0;
  for (int j = 0; j <= n; j++) c[0][j] = 0;

  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= n; j++) {
      if ( X[i] == Y[j] ) {
        c[i][j] = c[i - 1][j - 1] + 1;
      } else {
        c[i][j] = max(c[i - 1][j],  c[i][j - 1]);
      }
      maxl = max(maxl, c[i][j]);
    }
  }

  return maxl;
}


int main() {
  string s1, s2;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s1 >> s2;
    cout << lcs(s1, s2) << endl;
  }
  return 0;
}
        



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

#define int long long
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<typename T, typename U> inline bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> inline bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
struct Init {
    Init() {
        cout << fixed << setprecision(20);
    };
} init;

int N, M;
int A[110000], B[110000];
pint AB[110000];
signed main() {
    cin >> N >> M;
    for (int i = 0; i < N; i++) { cin >> A[i] >> B[i], AB[i] = pint(A[i], B[i]); }
    sort(AB, AB + N);
    int ans = 0;
    for (int i = 0; i < N; i++) { ans += AB[i].first * min(M, AB[i].second), M -= min(M, AB[i].second); }
    cout << ans << endl;
}


Measured memory_bytes: 3328
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=5e18;
using P=pair<int,int>;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  double n;
  cin >> n;
  if((int)n%2) {
    cout << fixed << setprecision(10) << ((n+1)/2)/n << endl;
  }
  else {
    cout << fixed << setprecision(10) << (n/2)/n << endl;
  }
}

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

int main()
{
 int x;
  cin>>x;
  vector<bool> v(x+1);
  v[1]=1;
  for(int b=2;b<=x;b++)
  {
    int cur=b*b;
    while(cur<=x)
    {v[cur]=1;cur*=b;}
  }
  for(int i=x;i>=1;i--)
    if(v[i])
    {
      cout<<i<<"\n";return 0;
    }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize(3)
using namespace std;
const int maxn=1e6+13;

set<int> d[maxn];
int a[maxn];
int p[maxn];//筛出每个数最小素因子
int cnt[maxn]; 
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	p[1]=0;
	for(int i=2;i<=maxn;i++)
	{
		if(p[i]) continue;
		for(int j=i;j<=maxn;j+=i)
		{
			p[j]=i;
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=a[i];p[j];j/=p[j])
		{
			d[i].insert(p[j]);
		}
	}
	int type=0;
	for(int i=1;i<=n;i++)
	{
		for(const auto &j:d[i])
		{
			if(++cnt[j]>=2)
			{
				type=1;
			}
		}
	}
	int gcd=a[1];
	for(int i=2;i<=n;i++)
	{
		gcd=__gcd(gcd,a[i]);
	}
	if(gcd!=1)
	{
		printf("not coprime");
	}
	else if(gcd==1)
	{
		if(type==1)
		{
			printf("setwise coprime");
		}
		else
		{
			printf("pairwise coprime");
		}
	}
 } 

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

int main() {

	int N , M , C;
	int res = 0;
	int B[20];
	int A[1000];
	cin >> N >> M >> C;
	for (int i = 1; i <= M; i++)cin >> B[i]; 
	for (int j = 1; j <= M * N; j++) cin >> A[j];

		int sum;

		for (int k = 1; k <= N; k++) {
			sum = 0;
			for (int l = 1; l <= M; l++) {

				sum += A[M*(k - 1) + l] * B[l];

			}
			res += (sum > -C) ? 1 : 0;
	}

	cout << res << endl;
}

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    vector<int> cnt(n + 1, 0);
    for (int i = 0; i < n; i++) {
        cnt[i + 1] = (s[i] == 'E');
    }

    for (int i = 1; i <= n; i++) {
        cnt[i] += cnt[i - 1];
    }

    int ans = n;
    for (int i = 0; i < n; i++) {
        ans = min(ans, i - cnt[i] + cnt[n] - cnt[i + 1]);
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    string s;
    cin >> s;
    map<string,string> m;
    m["Sunny"] = "Cloudy";
    m["Cloudy"] = "Rainy";
    m["Rainy"] = "Sunny";
    cout << m.at(s) << endl;
}

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

int main(){
    ios_base::sync_with_stdio(0);
    long long n; cin >> n;
    int cnt = 0;
    for(long long i = 2; i * i <= n; ++i){
        if(n % i == 0){
            int t = 0;
            while(n % i == 0){
                t++;
                n /= i;
            }
            int i = 1;
            for(;t >= i;++i) t -= i, ++cnt;
        }
    }
    if( n > 1 ) cnt++;
    cout << cnt << '\n';
}

Measured memory_bytes: 3632
#include <iostream>
#include <limits>
#include <map>
#include <set>
#include <tuple>
#include <vector>

template <class... Ts> using tuple_t = std::tuple<Ts...>;
template <class T, class U> using map_t = std::map<T, U>;
template <class T, class U> using pair_t = std::pair<T, U>;
template <class T> using vector_t = std::vector<T>;
template <class T> using set_t = std::set<T>;

int min(vector_t<int> nums) {
  int min_ = std::numeric_limits<int>::max();
  for (auto &i : nums)
    if (min_ > i)
      min_ = i;
  return min_;
}

int max(vector_t<int> nums) {
  int max_ = std::numeric_limits<int>::min();
  for (auto &i : nums)
    if (max_ < i)
      max_ = i;
  return max_;
}

int main() {
  int N, a;
  std::cin >> N;
  int res = 0;
  for (int i = 0; i < N; ++i) {
    std::cin >> a;
    res += a - 1;
  }
  std::cout << res << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000001


int main(){
	
	int N,M;
	cin>>N>>M;
	
	cout<<N*(N-1)/2+M*(M-1)/2<<endl;
	
    return 0;
}


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

int main(){
  int A,B,C;
  
  cin >> A >> B >> C;
  
  if(A == 5 && B ==7 && C == 5){
    cout << "YES" << endl;
  }
  else if(A == 7 && B ==5 && C == 5){
    cout << "YES" << endl;
  }
  else if(A == 5 && B ==5 && C == 7){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int N,M;
    bool flag=true;
    cin>>N>>M;
    int c[N];
    for(int i=0;i<N;i++){
        c[i]=0;
    }
    for(int i=0;i<M;i++){
        int a,b;
        cin>>a>>b;
        c[a-1]++;
        c[b-1]++;
    }
    
    for(int i=0;i<N;i++){
        if(c[i]%2==1){
        flag=false;
        }
    }
    
    if(flag){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
}


Measured memory_bytes: 640
from heapq import heappush, heappop

def dijkstra(s, edge):
    '''
    始点sから各頂点への最短距離を求める
    '''
    d = [float("inf")] * n
    d[s] = 0
    used = [False] * n
    used[s] = True
    edgelist = []

    for e in edge[s]:
        heappush(edgelist, e)

    while edgelist:
        cost, v = heappop(edgelist)
        if used[v]:
            continue
        d[v] = cost
        used[v] = True
        for e in edge[v]:
            if not used[e[1]]:
                heappush(edgelist, [e[0] + d[v], e[1]])

    return d


n, m, s, t = map(int, input().split())

e1 = [[] for _ in range(n)]
e2 = [[] for _ in range(n)]
for _ in range(m):
    u, v, a, b = map(int, input().split())
    e1[u-1].append([a, v-1])
    e1[v-1].append([a, u-1])
    e2[u-1].append([b, v-1])
    e2[v-1].append([b, u-1])

d1 = dijkstra(s-1, e1)
d2 = dijkstra(t-1, e2)
dist = [d1[i] + d2[i] for i in range(n)]

res = [0] * n

min_dist = float('inf')
for i in range(n-1, -1, -1):
    min_dist = min(min_dist, dist[i])
    res[i] = 10 ** 15 - min_dist

for v in res:
    print(v)

Measured memory_bytes: 162948
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;

struct Point {
  double x;
  double y;
};

int main(void){
  Point p1, p2;
  cin >> p1.x >> p1.y >> p2.x >> p2.y;

  double dis = sqrt(pow(p1.x - p2.x, 2) + pow(p1.y - p2.y, 2));

  printf("%.6f\n", dis);
}


Measured memory_bytes: 3284
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.valueOf(scanner.nextLine());

        Map<String, List<String>> data = IntStream.range(0, n)
                .mapToObj(i -> scanner.nextLine())
                .collect(Collectors.groupingBy(e -> e));

        Arrays.stream(new String[]{"AC", "WA", "TLE", "RE"})
                .forEach(e -> System.out.println(e + " x "
                        + data.getOrDefault(e, Collections.emptyList()).size()));
    }
}


Measured memory_bytes: 59300
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i,b)  for(int i=0;i<(int)(b);i++)
#define Rep(i,n) for(int i=1;i<(int)(n);i++)
#define repp(i,a,b)  for(int i=a;i<=(int)(b);i++)
#define Repp(i,a,b)  for(int i=a;i>=(int)(b);i--)
#define bye(x) {cout<<x;return 0;}
typedef long long ll;
typedef long double ld;

using namespace std;

int main(){
    cs
    int a,b,c;
    cin>>a>>b>>c;
    repp(i,b,c) if(i%a==0) bye("OK")


    cout<<"NG";
}

Measured memory_bytes: 3608
N=int(input())
A,B=map(int,input().split())
P=list(map(int,input().split()))
listA=[]
listB=[]
listC=[]
for i in P:
    if i<=A:
        listA.append(i)
    elif A+1<=i<=B:
        listB.append(i)
    else:
        listC.append(i)
print(min(len(listA),len(listB),len(listC)))

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

int search_max_sugar(int max_sugar, set<int> &s){
    int res=0;
    for(auto s1: s) {
        if(s1 > max_sugar){break;}
        res = s1;
    }
    return res;
}

int main(){
    int a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;

    set<int> water,sugar;
    for(int i = 0; 100*a*i <= f ; i++){
        for(int j = 0; 100*a*i+100*b*j <= f; j++){
            water.insert(100*a*i+100*b*j);
        }
    }
    for(int i = 0; c*i <= f ; i++){
        for(int j = 0; c*i+d*j <= f; j++){
            sugar.insert(c*i+d*j);
        }
    }
    pair<int,int> ans;
    int tmp;
    double max_cardinality=0.0;
    for(auto s: water){
        tmp = search_max_sugar(min(e*s/100, f-s) , sugar);
        double cardinality = (double)100*tmp/(s+tmp);
        if(max_cardinality <= cardinality){
            max_cardinality = cardinality;
            ans.first = s+tmp;
            ans.second = tmp;
        }
    }



    cout << ans.first << " " << ans.second <<"\n";
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define mem(a,b) memset(a,b,sizeof(a))
#define ll long long
#define ull unsigned long long
#define EPS 1e-8
using namespace std;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
const double pi = acos(-1.0);
int read()
{
	int ret=0;char ch=getchar();
	while(ch<'0'||ch>'9') ch=getchar();
	for(;ch>='0'&&ch<='9';ch=getchar()) ret=ret*10+ch-'0';
	return ret;
}
map<int,int> ma;
int n,m,temp;
int main()
{
 	#ifdef TEST
	 	freopen("input.txt","r",stdin);
	#endif
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&temp);
		ma[temp]++;
	}
	scanf("%d",&m);
	for(int i=0;i<m;i++)
	{
		scanf("%d",&temp);
		if(ma[temp]>=1)
		{
			ma[temp]--;
		}
		else
		{
			puts("NO");
			return 0;
		}
	}
	puts("YES");
	return 0;
}



Measured memory_bytes: 9600
#include<iostream>
using namespace std;
int main(){int p[5],tmp,ans;char n[5]={'A','B','C','D','E'};while(1){ans=0;for(int i=0;i<5;i++){cin>>p[i]>>tmp;p[i]+=tmp;if(!p[0])return 0;if(p[ans]<p[i])ans=i;}cout<<n[ans]<<' '<<p[ans]<<endl;}}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 0
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
using namespace std;

int n,ans;
signed main(){
	int a[11111];
	cin>>n;
	rep(i,n)cin>>a[i];
	rep(i,n){
		for(int j=i+1;j<n;j++){
			ans+=a[i]*a[j];
		}
	}
	cout<<ans<<endl;
}


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

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  string s;
  cin >> s;
  bool yes = s[0] == 'A';
  int cnt = 0;
  for (int i = 2; i < s.size() - 1; i++) {
    cnt += s[i] == 'C';
  }
  yes &= cnt == 1;
  for (int i = 1; i < s.size(); i++) {
    if (s[i] == 'C') continue;
    yes &= ('a' <= s[i] && s[i] <= 'z');
  }
  cout << (yes ? "AC" : "WA") << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int dp[100002]={0}, arr[100002]={0},visited[100002]={0};
vector<int> v[100002];
void solve(int i)
{
    //dp[i]=0;
    for(int j=0; j<v[i].size(); j++)
    {
        //visited[v[i][j]] = 1;
        arr[v[i][j]]--;
        if(dp[i]+1>dp[v[i][j]])
        {
            dp[v[i][j]] = dp[i]+1;
            //solve(v[i][j]);
        }
        if(arr[v[i][j]]==0)
        {
            visited[v[i][j]] = 1;
            solve(v[i][j]);
        }
    }
}
int32_t main()
{
        int n,m;
        cin>>n>>m;
        //int arr[n+1]={0};
        //vector<int> v[n];
        for(int i=0; i<m; i++)
        {
            int a,b;
            cin>>a>>b;
            arr[b]++;
            v[a].push_back(b);
        }
        //int dp[n]={0};
        for(int i=1; i<=n; i++)
        {
            if(!visited[i] && !arr[i])
            {
                //cout<<i<<endl;
                solve(i);
            }
        } 
        int ans=0;
        for(int i=1; i<=n; i++)
        {
            ans=max(ans,dp[i]);
        }
        cout<<ans;
        return 0;
}

Measured memory_bytes: 12800
#include <stdio.h>
int main(){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a==b){
    puts("Draw");
    return 0;
  }
  if(a==1)a=14;
  if(b==1)b=14;
  if(a>b)puts("Alice");
  if(a<b)puts("Bob");
  return 0;
}

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

int qr()
{
    int s=0,f=1;char ch=0;
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=(s<<3)+(s<<1)+(ch^48);ch=getchar();}
    return s*f;
}

int main()
{
    int n,m;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>m;
        if(m%2==0)
        {
            if(m%3!=0&&m%5!=0)
            {
                cout<<"DENIED"<<endl;
                return 0;
            }
        }
    }
    cout<<"APPROVED"<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int n; cin >> n;
	int min[114514], max[114514];
	for (int i = 0; i < n; i++) {
		cin >> min[i] >> max[i];
	}
	for (int i = n + 1; i >= 1; i--) {
		int cnt = 0;
		for (int j = 0; j < n; j++) {
			if (min[j] <= i&&i <= max[j])cnt++;
		}
		if (cnt >= i - 1) {
			cout << i - 1 << endl;
			return 0;
		}
	}
	cout << "0\n";
	return 0;
}

Measured memory_bytes: 3900
#include <bits/stdc++.h>
#define int long long
#define N 100010
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}


int getCost(int a,int b,int A,int B,int div){
  int p = abs(a-A*div);
  int q = abs(a-A*div-A);
  if(abs(b-B*div)) p = INF;
  if(abs(b-B*div-B)) q = INF;
  return min(p,q);
}

signed main(){
  int a,b,n;
  cin>>a>>b>>n;
 
  int ans = INF;
  for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++){
      int cost = min(getCost(a,b,i,j,a/i),getCost(a,b,i,j,b/j));
      Min(ans,cost);
    }
  cout<<ans<<endl;
 
  return 0;
}

Measured memory_bytes: 3100
#include<stdio.h>
 
typedef struct node{
 
  int p;
  int r;
  int l;
  int br;
}Node;
 
Node node[26];
int m;
void nodegene( Node*);
//void putdepth( Node*);
 
int depth(int);
int height(int);
void nodegene( Node* nod){
 
  nod -> l = -1;
  nod -> r = -1;
  nod -> p = -1;
  nod -> br = -1;
}
 
 
int depth(int k){
  int dep = 0;
  for(dep = 0 ; node[k].p != -1 ; dep++){
    k = node[k].p;
  }
  return dep;
 
}
 
int height(int k){
  int left=0,right=0; 
  
  if( node[k].l != -1 ) left = height(node[k].l) + 1;
  
  if( node[k].r != -1 ) right = height(node[k].r) + 1;
 
  if( right <= left ) return left;
  
  else if( right > left ) return right;
}
 
 
   
int main(){
 
  int i, j, n, l, r, nod, d, degree;
 
  Node c;
  scanf("%d",&m);
 
  for( i = 0; i < m; i++)nodegene(&node[i]);
   
  for( i = 0; i < m; i++){
 
    scanf("%d", &n);
    scanf("%d%d", &r, &l);
    node[l].p = n;
    node[r].p = n;
    node[l].br = r;
    node[r].br = l;
    node[n].r = r;
    node[n].l = l;
     
  }
 
  //  for(i = 0; i < m; i ++)putdepth(&node[i]);
 
  for( i = 0; i < m; i++){
 
    printf("node %d: parent = %d, sibling = %d, degree = ", i, node[i].p, node[i].br);
 
    if(node[i].r != -1 && node[i].l != -1)
      printf("2, ");
    else if(node[i].r != -1 || node[i].l != -1)
      printf("1, ");
    else
      printf("0, ");
 
    printf("depth = %d, height = %d, ",depth(i), height(i));
 
    if((node[i].r == -1 && node[i].l == -1) && node[i].p != -1)
      printf("leaf\n");
    else if(node[i].p == -1)
      printf("root\n");
    else if((node[i].l != -1 || node[i].r != -1) && node[i].p != -1)
      printf("internal node\n" );
     
 
  }
  return 0;
}

Measured memory_bytes: 612
import bisect
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
for q in range(Q):
    x = int(input())
    b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    res = INF
    for S in [s[b - 1], s[b]]:
        for T in [t[d - 1], t[d]]:
            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
            res = min(res, d1, d2)
    print(res)

Measured memory_bytes: 12804
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>
#include <limits>
#include <cmath>
#include <iomanip>
 
#define ALL(a)  (a).begin(),(a).end()
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
 
int main() {
    ll x, ans = 0;
    cin >> x;

    if (x == 2) {
        cout << 2 << endl;
        return 0;
    }

    while (1) {
        bool flag = 0;
        for (int i = 2; i < (double)(sqrt(x) + 1); i++) {
            if (x % i == 0) flag = 1; 
        }
        if (flag == 0) break;
        x++;
    }

    cout << x << endl;
    return 0;
}

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

int main()
{
    int h, w;
    cin >> h >> w;
    char box[1010][1010]={};
    queue<int> qa;
    queue<int> qb;
    int counta = 0, countb = 0, countc = 0;

    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin >> box[i][j];
            if(box[i][j]=='#'){
                qa.push(i);
                qb.push(j);
                counta ++;
            }
        }
    }

    int wa[4] ={-1,0,1,0};
    int wb[4] ={0,1,0,-1};
    int currenta , currentb;
    int ans = 0;


    while(qa.size()!=0){
        currenta = qa.front();
        currentb = qb.front();
        qa.pop();
        qb.pop();
        for(int j=0;j<4;j++){
            if(box[currenta+wa[j]][currentb+wb[j]]=='.'){
                box[currenta+wa[j]][currentb+wb[j]]='#';
                qa.push(currenta+wa[j]);
                qb.push(currentb+wb[j]);
                countc ++;
            }
        }
        countb ++;
        if(counta == countb){
            ans ++;
            counta = countc;
            countb = 0;
            countc = 0;
        }
    }

    ans --;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9472
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N];
int32_t main(){_

   cin>>n;

   int sum = 0, f = 0;
   for (int i = 0; i < n; ++i)
   {
      cin>>a[i];
      if(f == 0){
         sum += a[i];
         f = 1;
      }
      else{
         sum -= a[i];
         f = 0;
      }
   }

   int prev = sum/2;
   cout<<2*prev<<' ';

   for (int i = 0; i < n-1; ++i)
   {
      prev = a[i] - prev;
      cout<<2*prev<<' ';
   }

   return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
#define rep(i,n) for (int i = 0; i < (ll)(n); ++i)
ll INF = 1LL << 60;
ll mod = 1e9 + 7;

int main() {
	int n; cin >> n;
	vint a{105, 135, 165, 189, 195};
	int ans=0;
	rep(i,5) {
		if(n>=a[i]) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
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 T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main(){
    ll a, b, k;
    cin >> a >> b >> k;
    if(a>=k){
        cout << a - k << " " << b << endl;
    }
    else {
        if(b>=k-a){
            cout << 0 << " " << b - (k - a) << endl;
        }
        else{
            cout << 0 << " " << 0 << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256