akhauriyash/Code-Regression huggingface dataset:
//#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
typedef long long ll;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
ll a,b,c,d,f;
ll e;
bool w[3005],s[3005];
ll answ,anss;
long double p=-1;
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin>>a>>b>>c>>d>>e>>f;
    for(int i=0;100*a*i<=f;i++){
        for(int j=0;100*b*j<=f;j++){
            if(100*a*i+100*b*j<=f){
                w[100*a*i+100*b*j]=true;
            }
        }
    }
    for(int i=0;c*i<=f;i++){
        for(int j=0;d*j<=f;j++){
            if(c*i+d*j<=f){
                s[c*i+d*j]=true;
            }
        }
    }
    for(int i=1;i<=f;i++){
        for(int j=0;j<=f;j++){
            if(w[i]&&s[j]){
                long double W=i,S=j;
                if(i+j<=f&&100*S<=e*W&&p*(S+W)<100.0*S){
                    p=100.0*(S/(S+W));
                    answ=i;
                    anss=j;
                }
            }
        }
    }
    cout<<answ+anss<<" "<<anss<<endl;
    
}


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

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

    float res = 0;
    for (int i = 1; i < N+1; i++) {
        if (i % 2 == 1) res++;
    }

    cout << res / N << endl;
}

Measured memory_bytes: 256
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { -1,0,1,0 }, dy[4] = { 0,-1,0,1 };
const char dir[4] = { 'u','l','d','r' };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)

int n;
LL x1[2020], x2[2020], y334[2020], y2[2020];
int iscover[4040][4040];
int main() {
	cin >> n;
	vector<LL>x, y;
	REP(i, n) {
		cin >> x1[i] >> y334[i] >> x2[i] >> y2[i];
		x.emplace_back(x1[i]);
		x.emplace_back(x2[i]);
		y.emplace_back(y334[i]);
		y.emplace_back(y2[i]);
	}
	UNIQUE(x);
	UNIQUE(y);
	REP(i, n) {
		int xx1 = lower_bound(ALL(x), x1[i]) - x.begin();
		int xx2 = lower_bound(ALL(x), x2[i]) - x.begin();
		int yy1 = lower_bound(ALL(y), y334[i]) - y.begin();
		int yy2 = lower_bound(ALL(y), y2[i]) - y.begin();
		iscover[yy1][xx1]++;
		iscover[yy2][xx1]--;
		iscover[yy1][xx2]--;
		iscover[yy2][xx2]++;
	}
	REP(i, 4040) {
		REP(j, 4040) {
			if (j)iscover[i][j] += iscover[i][j - 1];
		}
	}
	REP(j, 4040) {
		REP(i, 4040) {
			if (i)iscover[i][j] += iscover[i - 1][j];
		}
	}
	LL ans = 0;
	REP(i, 4040)REP(j, 4040) {
		if (iscover[i][j] > 0) {
			ans += (x[j + 1] - x[j])*(y[i + 1] - y[i]);
		}
	}
	cout << ans << endl;
	//system("pause");
}


Measured memory_bytes: 67060
#include <algorithm>
#include <cstdio>
#define fo(i, a, b) for (i = a; i <= b; i++)
using namespace std;
typedef long long ll;
const int maxn = 100000 + 10, mo = 1000000007;
ll a[maxn], A, B;
int tree[maxn * 4], f[maxn];
int i, j, k, l, r, t, n, m, ans;
void change(int p, int l, int r, int a, int b) {
    if (l == r) {
        (tree[p] += b) %= mo;
        return;
    }
    int mid = (l + r) / 2;
    if (a <= mid)
        change(p * 2, l, mid, a, b);
    else
        change(p * 2 + 1, mid + 1, r, a, b);
    tree[p] = (tree[p * 2] + tree[p * 2 + 1]) % mo;
}
int query(int p, int l, int r, int a, int b) {
    if (a > b) return 0;
    if (l == a && r == b) return tree[p];
    int mid = (l + r) / 2;
    if (b <= mid)
        return query(p * 2, l, mid, a, b);
    else if (a > mid)
        return query(p * 2 + 1, mid + 1, r, a, b);
    else
        return (query(p * 2, l, mid, a, mid) +
                query(p * 2 + 1, mid + 1, r, mid + 1, b)) %
               mo;
}
int main() {
    scanf("%d%lld%lld", &n, &A, &B);
    if (A < B) swap(A, B);
    fo(i, 1, n) scanf("%lld", &a[i]);
    sort(a+1,a+n+1);
    a[0] = -A;
    a[n + 1] = a[n] + A;
    f[0] = 1;
    change(1, 0, n, 0, f[0]);
    l = 0;
    r = 0;
    fo(i, 1, n + 1) {
        while (a[i] - a[r + 1] >= A) r++;
        if (i >= 2 && a[i - 1] - a[i - 2] < B) l = i - 2;
        if (a[i] - a[i - 1] >= A) f[i] = f[i - 1];
        (f[i] += query(1, 0, n, l, min(i - 2, r))) %= mo;
        if (i <= n && a[i + 1] - a[i - 1] >= B) change(1, 0, n, i, f[i]);
    }
    ans = f[n + 1];
    (ans += mo) %= mo;
    printf("%d\n", ans);
}

Measured memory_bytes: 2304
#include<iostream>
#include<algorithm>
#include <bits/stdc++.h>
#include <map>
#define endl "\n"
using namespace std;


int main()
{
    map <string,int> poll;
    int i,n,maxi=0;
    string S;
    cin >> n;
    for (i=0;i<n;i++)
    {
        cin >> S;
        poll[S]++;
    }
    map <string,int>:: iterator itr;
    for (itr=poll.begin();itr != poll.end();itr++)
    {
        if (itr->second > maxi)
        {
            maxi = itr->second;
        }
    }
    for (itr=poll.begin();itr != poll.end();itr++)
    {
        if (itr->second == maxi)
        {
            cout << itr->first << endl;
        }
    }


}


Measured memory_bytes: 19228
#include<stdio.h>
int main() {
    int a,b,c;
  
    scanf("%d %d %d", &a, &b, &c);
  
    if((a==b) && (b==c) || (a!=b) && (b!=c) && (a!=c)) {
       printf("No");
    }else {
       printf("Yes");
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
#include <cstdint>
#include <sys/time.h>

typedef std::int_fast32_t  s32;
typedef std::uint_fast32_t u32;
typedef std::int_fast64_t  s64;
typedef std::uint_fast64_t u64;

typedef std::pair<int, int> P;

int map[64][64];
int H, W;

void dfs_erase(int x, int y) {
  if( not ( 0 <= x and x < H and 0 <= y and y < W ) ) return;
  if( not ( map[x][y] == 1 ) ) return;

  map[x][y] = 0;
  
  int dx[8] = {1, 1, 1, 0, 0, -1, -1, -1};
  int dy[8] = {1, 0, -1, 1, -1, 1, 0, -1};
  for(int i = 0; i < 8; ++i) {
    dfs_erase(x + dx[i], y + dy[i]);
  }
  return;
}
  
int main(void) {

  for(;;) {
    std::cin >> W >> H;
    if( W == 0 and H == 0 ) break;

    for(int i = 0; i < H; ++i) {
      for(int j = 0; j < W; ++j) {
        std::cin >> map[i][j];
      }
    }

    int res = 0;
    for(int i = 0; i < H; ++i) {
      for(int j = 0; j < W; ++j) {
        if( map[i][j] == 1 ) {
          dfs_erase(i, j);
          res += 1;
        }
      }
    }

    std::cout << res << std::endl;
  }
  
  return 0;
}

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

using namespace std;

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define sz(s) (int)s.size()

int main() {
    int x;
    cin >> x;
    cout << ((x == 3 || x == 5 || x == 7) ? "YES\n" : "NO\n");
}

Measured memory_bytes: 256
import java.util.Scanner;

class Point {
    double x, y;

    public Point(double x, double y) {
        this.x = x;
        this.y = y;
    }

     public void show() {
        System.out.println(x + " " + y);
     }
}

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        Point left = new Point(0, 0);
        Point right = new Point(100, 0);
        left.show();
        showKochCurve(n, left, right);
        right.show();
    }

    static void showKochCurve(int n, Point p1, Point p2) {
        if (n == 0) {
            return;
        }
        Point s = new Point((2 * p1.x + p2.x) / 3, (2 * p1.y + p2.y) / 3);
        Point t = new Point((p1.x + 2 * p2.x) / 3, (p1.y + 2 * p2.y) / 3);
        Point u = new Point((t.x - s.x) / 2 - (t.y - s.y) * Math.sqrt(3) / 2 + s.x,
                (t.x - s.x) * Math.sqrt(3) / 2 + (t.y - s.y) / 2 + s.y);
        showKochCurve(n - 1, p1, s);
        s.show();
        showKochCurve(n - 1, s, u);
        u.show();
        showKochCurve(n - 1, u, t);
        t.show();
        showKochCurve(n - 1, t, p2);
    }
}



Measured memory_bytes: 32240
#include <iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<limits>
#include<string.h>
#include<vector>
#include<stack>
#include<queue>
using namespace std;

int main()
{
	char a[110];
	cin >> a;
	char d[10] = "keyence";
	int b=strlen(a)-7;
	for (int i = 0; i < 8; i++) {
		char c[10];
		for (int j = 0; j < 7;j++) {
			if (j < i) {
				c[j] = a[j];
			}
			else c[j] = a[j + b];
		}
		if (strstr(c, d) != NULL) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int S, h, m, s;
    cin >> S;
    h = S/3600;
    m = (S-3600*h)/60;
    s = S-3600*h-60*m;
	cout << h << ":" << m << ":" << s << endl;
	return 0;
}


Measured memory_bytes: 3132
# https://atcoder.jp/contests/nikkei2019-2-qual/tasks/nikkei2019_2_qual_b
# まず、本当に木を構築するモノではないだろう
from collections import Counter
n = int(input())
nums = [int(i) for i in input().split()]
mod = 998244353
MAX = max(nums)

c = Counter(nums)
if nums[0] != 0 or nums.count(0) != 1:
    ans = 0
else:
    ans = 1
    for i in range(1, MAX + 1):
        ans = ans * pow(c.get(i - 1, 0), c.get(i, 0), mod) % mod
    ans %= mod
print(ans)

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

int main()
{
    int n; cin>>n;
    vector<long> a(n);
    long s=0;
    for(auto& e: a) { cin>>e; s+=e; }

    auto m=n*(n+1L)/2;
    if (s%m>0) return cout<<"NO"<<endl, 0;

    int k=s/m;
    auto b=a;
    int t=0;
    for(int i=0; i<n; ++i) {
        auto& e=b[i];
        e=a[(i+1)%n]-a[i]-k;
        if (e%n!=0 or e>0) return cout<<"NO"<<endl, 0;
        t+=-e/n;
    }
    cout<<(t==k ? "YES" : "NO")<<endl;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
const int maxn=1000005;
typedef long long ll;
typedef double dbl;
typedef long double ld;
const ld EPS=1e-9;
const ld PI=3.141592653589793;
const ll MOD = 1e9+7;
const int SQRT = 300;
const int LG=21;
const int FOURIER = (1<<LG);
////////////////
ll a[maxn];
pair<int,int> dp[maxn];

int sum[maxn];
void make_max(int ind,int val){
    if (val>dp[ind].first){
        dp[ind].second=dp[ind].first;
        dp[ind].first=val;
    }
    else if (val>dp[ind].second){
        dp[ind].second=val;
    }
}
int ans[maxn];
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    int N=1<<n;
    for(int i=0; i<N; ++i){
        cin>>a[i];
        dp[i]=make_pair(-1,-1);
    }
    for(int OR=0; OR<N; ++OR){
        int z=OR;
        while(1){
            make_max(OR,a[z]);
            if (!z)
                break;
            z=(z-1)&OR;
        }
    }
    for(int i=0; i<N; ++i){
        if (dp[i].second){
            sum[i]=dp[i].first+dp[i].second;
            ans[i]=sum[i];
        }

    }
    for(int i=1; i<N; ++i){
        ans[i]=max(ans[i],ans[i-1]);
    }
    for(int i=1; i<N; ++i)
        cout<<ans[i]<<"\n";
}



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

int main(){
    string s,t; cin>>s>>t;
    int val = (-1)*(int)('a');
    vector<int> rep(26,-1);
    vector<int> rev(26,-1);

    for(int i=0; i<s.size(); i++){
        rep[val+(int)s[i]] = (int)t[i];
        rev[(int)t[i]] = val+(int)s[i];
        
    }

    for(int i=0; i<s.size(); i++){
        if(rev[(int)t[i]] != val+(int)s[i]){
            cout<<"No"<<endl;
            return 0;
        }
        s[i] = (char)rep[val+(int)s[i]];
    }
    

    if(s == t) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 776
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int b = sc.nextInt();
        if(n>=13)System.out.println(b);
        else if(n<13 && n>5)System.out.println(b/2);
        else System.out.println(0);
        
        
        
    }
 
}

Measured memory_bytes: 20820
n = int(input())
AB = [[0]+list(map(int,input().split())) for _ in range(n)]
CD = [list(map(int,input().split())) for _ in range(n)]
from operator import itemgetter

points = AB.copy()
for c,d in CD:
    points.append([1,c,max(0,d-0.1)])
points.sort(key = itemgetter(2))

ans = 0
record = [0]*(2*n+1)
for flag, x, y in points:
    if flag:
        for i in range(x-1,-1,-1):
            if record[i] > 0:
                ans += 1
                record[i] -= 1
                break
    else:
        record[x] += 1
print(ans)


Measured memory_bytes: 3064
#![allow(unused_imports)]
#![allow(unused_variables)]
use proconio::input;
use proconio::marker::*;
use std::cmp::{min, max};
use std::collections::{HashSet, HashMap, BinaryHeap};

fn main() {
    input! {
        mut t: Chars,
    }
    let n = t.len();
    for i in 0..n - 1{
        if t[i] == 'P' && t[i + 1] == '?'{
            t[i + 1] = 'D';
        }else if t[i] == '?'{
            if t[i + 1] == '?'{
                t[i] = 'P';
                t[i + 1] = 'D';
            }else if t[i + 1] == 'P'{
                t[i] = 'D';
            }else if t[i + 1] == 'D'{
                t[i] = 'P';
            }
        }
    }
    if t[n - 1] == '?'{
        t[n - 1] = 'D';
    }
    for i in t.iter(){
        print!("{}", i);
    }
    println!();
}


Measured memory_bytes: 3036
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<functional>
using namespace std;
#define ll long long int
#define ld long double
using namespace __gnu_pbds;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,
tree_order_statistics_node_update> in_set;
#define rep(n) for(ll i=0;i<(n);i++)
#define jrep(n) for(ll j=0;j<(n);j++)
#define krep(n) for(ll k=0;k<(n);k++)
#define all(a) (a).begin(), (a).end()
#define dpp(a) cout<<(a).first<<" "<<(a).second<<endl;
#define append push_back
#define mod 1000000007
#define ff first
#define ss second
#define ffast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fast ios::sync_with_stdio(0);
ll pw(ll x,ll y,ll p=mod){ll r=1; x=x%p;while(y>0){ if(y&1)r=(r*x)%p;
y=y>>1;x=(x*x)%p;} return r; } vector<ll> uniq(vector<ll> arr)
{vector<ll>brr;sort(all(arr));brr.append(arr[0]);
for(auto i:arr)if(brr.back()!=i)brr.append(i);return brr;}

void solve(ll ts){
    ll n; cin>>n; vector<ll> arr(n); rep(n) cin>>arr[i];
    ll mh=0; ll tot=0;
    for(auto i:arr) if(i>=mh) mh=i; else tot+=(mh-i);
    cout<<tot<<endl;
}
 
int main(){
    ffast
    ll t=1;
//    cin>>t;
    rep(t) solve(i+1);
}
 
 
// *p.find_by_order(n) : nth value (0 indexed)
// p.order_of_key(7): index of 7 (0 indexed)


Measured memory_bytes: 4708
#include <stdio.h>
#define N 20
#define QN 200

int solve(int,int);

int n,A[N];

int main(){
  int i,q,m[QN];
 
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&A[i]);
  }

  scanf("%d",&q);
  for(i=0; i<q; i++){
    scanf("%d",&m[i]);
  }

  for(i=0; i<q; i++){
    if(solve(0,m[i]) == 1) printf("yes\n");
    else printf("no\n");
  }

  return 0;
}
 
int solve(int i, int m){
  if(m == 0) return 1;
  if(i >= n) return 0;
  if(solve(i+1,m) == 1 || solve(i+1,m-A[i]) == 1) return 1;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
long long n,f[100];
int main()
{
    cin>>n;
    f[0]=2;
    f[1]=1;
    for(int i=2;i<=n;i++)
        f[i]=f[i-1]+f[i-2];
    cout<<f[n];
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env lua

k = 0
a = io.read("*line")

for i in a:gmatch(".") do
    for j in a:gmatch(".") do
        if i == j then k = k + 1 end
    end
end

if k == string.len(a) then
        print("yes")
else
        print("no")
end

Measured memory_bytes: 256
import collections
S=str(input())

T=[0 for i in range(len(S))]
T[0]=int(S[-1])

for i in range(1,len(S)):
    T[i]=(pow(10,i,2019)*int(S[len(S)-1-i])+T[i-1])%2019
    
cnt=0
T_di=collections.Counter(T)

for key in T_di.keys():
    x=T_di[key]
    cnt+=x*(x-1)/2
    if key==0:
        cnt+=x

print(int(cnt))

Measured memory_bytes: 81892
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) 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; }
using namespace std;

// AtCoder Beginner Contest 141
int main(){

    string s;
    cin >> s;

    rep(i, (int)s.size()){
        if(i % 2 == 0){
            if(s[i] == 'L'){
                cout << "No" << endl;
                return 0;
            }
        } else {
            if(s[i] == 'R'){
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
    return 0;

}

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

long long INF = 1e18;

int main(){
    int n, k;
    cin>>n>>k;
    int i = 0;
    
   
    while(n>0){
        n = n / k;
        i++;
    }
    cout << i << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int a,b,c,k;
	int max=0;
	int x=1;
	scanf("%d %d %d %d",&a,&b,&c,&k); getchar();
	for(int i=1;i<=k;i++)
	{
		if(a*2*x+b+c>=max) max=a*2*x+b+c;
	//		printf("%d\n",a*2*x+b+c);
		if(a+b*2*x+c>=max) max=a+b*2*x+c;
	//		printf("%d\n",a+b*2*x+c);
		if(a+b+c*2*x>=max) max=a+b+c*2*x;
	//		printf("%d\n",a+b+c*2*x);
		x=x*2;
	}
	printf("%d\n",max);
	return 0;
}

Measured memory_bytes: 128
// ABC 111 C

#include <bits/stdc++.h>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(v) int(v.size())

using namespace std;

const int mod = 1000000007;
const int INF = int(1e+6);

int main(int argc, char** argv) {
  int n;
  cin >> n;
  map<int, int> mp1;
  map<int, int> mp2;
  rep (i, n) {
    int a;
    cin >> a;
    if (i % 2 == 0) {
      mp1[a] += 1;
    } else {
      mp2[a] += 1;
    }
  }

  int max1 = 0;
  int next1 = 0;
  int val1 = 0;
  for (auto itr = mp1.begin(); itr != mp1.end(); ++itr) {
    int v = itr->second;
    if (v >= max1) {
      next1 = max1;
      max1 = v;
      val1 = itr->first;
    } else if (v >= next1) {
      next1 = v;
    }
  }

  int max2 = 0;
  int next2 = 0;
  int val2 = 0;
  for (auto itr = mp2.begin(); itr != mp2.end(); ++itr) {
    int v = itr->second;
    if (v >= max2) {
      next2 = max2;
      max2 = v;
      val2 = itr->first;
    } else if (v >= next2) {
      next2 = v;
    }
  }

  int ans = 0;
  if (val1 != val2) {
    ans = n - max1 - max2;
  } else {
    int tmp1 = n - max1 - next2;
    int tmp2 = n - next1 - max2;
    if (mp1.size() == 1 && mp2.size() == 1) {
      ans = n / 2;
    } else if (mp1.size() == 1) {
      ans = tmp1;
    } else if (mp2.size() == 1) {
      ans = tmp2;
    } else {
      ans = min(tmp1, tmp2);
    }
  }

  cout << ans << endl;

  return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define PRINT(a)   cout << (a) << endl
#define RALL(v) rbegin(v), rend(v)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second

#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

using ll = long long int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

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; }

const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

  if(N%2==1){
    PRINT("No");
  }else if(S.substr(0,N/2) == S.substr(N/2,N/2)){
    PRINT("Yes");
  }else{
    PRINT("No");
  }
}



Measured memory_bytes: 3532
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int w, h, n;
	cin >> w >> h >> n;
	
	vector<int> x(n);
	vector<int> y(n);
	vector<int> a(n);
	for(int i = 0; i < n; i++)
	{
		cin >> x[i] >> y[i] >> a[i];
	}
	
	int w_begin = 0;
	int w_end = w;
	int h_begin = 0;
	int h_end = h;
	for(int i = 0; i < n; i++)
	{
		switch(a[i])
		{
			case 1 : if(w_begin < x[i]) w_begin = x[i]; break;
			case 2 : if(w_end > x[i]) w_end = x[i]; break;
			case 3 : if(h_begin < y[i]) h_begin = y[i]; break;
			case 4 : if(h_end > y[i]) h_end = y[i]; break;
		}
	}
	
	if(w_end - w_begin < 0 || h_end - h_begin < 0)
	{
		cout << 0 << endl;
	}
	else
	{
		cout << (w_end - w_begin) * (h_end - h_begin) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n - r] % p


N, K = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
p = 10 ** 9 + 7
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

i = 0
f_max = 0
f_min = 0
while N - 1 - i >= K - 1:
    r = cmb(N - 1 - i, K - 1, p)
    f_max += a[i] * r
    f_min += a[N - i - 1] * r
    i += 1

print((f_max - f_min) % p)



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

typedef long long int ll;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(v,a,b) v.begin(a),v.end(b)
#define in cin>>
#define out cout<<
#define endl <<endl
#define INF 100000000000000

int main()
{
	int N;
	in N;
	string S;
	in S;
	vector<char> X(S.size());
	rep(i, S.size())
	{
		X.at(i) = S.at(i);
		int n = 0;
		n = (int)(X.at(i) + N);
		if (n > 90)
		{
			n -= 26;
		}
		X.at(i) = (char)n;
		out X.at(i);
	}
	cout endl;
}


Measured memory_bytes: 256
n = int(input())
S = [int(input()) for _ in range(n)]
t = [s for s in S if s % 10 != 0]
if len(t) == 0:
    print(0)
    exit()
ans = sum(S)
if ans % 10 == 0:
    print(ans - min(t))
else:
    print(ans)


Measured memory_bytes: 2940
n = int(input())
v = list(map(int, input().split()))

from collections import Counter, defaultdict
e, o = Counter(), Counter()
for i in range(n):
    if i % 2 == 0:
        e[v[i]] += 1
    else:
        o[v[i]] += 1

e_inv = defaultdict(list)
for key in e:
    e_inv[n // 2 - e[key]].append(key)
e_inv[n // 2].append(0)

o_inv = defaultdict(list)
for key in o:
    o_inv[n // 2 - o[key]].append(key)
o_inv[n // 2].append(0)

e_inv_keys = sorted(list(e_inv.keys()))
o_inv_keys = sorted(list(o_inv.keys()))

l1, l2 = e_inv[e_inv_keys[0]], o_inv[o_inv_keys[0]]
if len(l1) == 1 and len(l2) == 1 and l1 == l2:
    ans = min(e_inv_keys[0] + o_inv_keys[1], e_inv_keys[1] + o_inv_keys[0])
else:
    ans = e_inv_keys[0] + o_inv_keys[0]

print(ans)


Measured memory_bytes: 60932
# AGC018A - Getting Difference
from fractions import gcd
from functools import reduce


def main():
    N, K, *A = map(int, open(0).read().split())
    G, M = reduce(gcd, A), max(A)  # gcd, max of A
    flg = K <= M and K % G == 0
    print("POSSIBLE" if flg else "IMPOSSIBLE")


if __name__ == "__main__":
    main()

Measured memory_bytes: 16080
#include <iostream>
#include <string>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define int long long
#define INF 1e9+7
using namespace std;
typedef pair<int,int>P;
queue<P>que;
int h, w;
char c[1000][1000];
int a[1000][1000];
int ax[4] = {0, -1, 0, 1}, ay[4] = {1, 0, -1, 0};
int ans = 0;
void bfs() {
    rep(i, h) {
        rep(j, w) {
            a[i][j] = INF;
        }
    }
    rep(i, h) {
        rep(j, w) {
            if (c[i][j] == '#') {
                que.push(P(i, j));
                a[i][j] = 0;
            }
        }
    }
    while (que.size()) {
        P p = que.front(); que.pop();
        rep(i, 4) {
            int px = p.first + ax[i], py = p.second + ay[i];
            if (px >= 0 && py >= 0 && px < h && py < w) {
                if (a[px][py] > a[p.first][p.second] + 1) {
                    a[px][py] = a[p.first][p.second] + 1;
                    que.push(P(px, py));
                }
            }
        }
    }
}
signed main() {
    cin >> h >> w;
    rep(i, h) {
        rep(j, w) {
            cin >> c[i][j];
        }
    }
    bfs();
    rep(i, h) {
        rep(j, w) {
            ans = max(a[i][j], ans);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 25396
import scala.math._

object Main extends App {

  val YES = "YES"
  val Yes = "Yes"
  val NO = "NO"
  val No = "No"
  ///////////////////////////////////////////

  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt
  val h = List.fill(n)(sc.nextInt)

  val ans = h.foldLeft((0, 0)) { (acc, v) => if (acc._1 <= v) (v, acc._2 + 1) else acc }

  println(ans._2)

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

  def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =
    Iterator.iterate(start)(_ + step).takeWhile(_ <= end)

  def lcm(a :Int, b :Int): Int =
    a / gcd(a, b) * b

  def lcm(a :Long, b :Long): Long =
    a / gcd(a, b) * b

  def gcd(a: Int, b: Int): Int =
    if (b == 0) a else gcd(b, a % b)

  def gcd(a: Long, b: Long): Long =
    if (b == 0) a else gcd(b, a % b)

  def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =
    a.get(key) match {
      case Some(v) => a.updated(key, f(value, v))
      case _ => a + (key -> value)
    }
}

Measured memory_bytes: 27440
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int S(int i) {
  int ans = 0;
  while (i) {
    ans += i % 10;
    i /= 10;
  }
  return ans;
}

double g(int i) {
  return (double)i / S(i);
}

signed main() {
  int K;
  cin >> K;

  int i = 1;
  int d = 1;
  rep(_, K) {
    cout << i << endl;
    int ni1 = i + d, ni2 = i + d * 10;
    if (g(ni1) <= g(ni2)) {
      i = ni1;
    } else {
      i = ni2;
      d *= 10;
    }
  }
}

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

using namespace std;

#define all(x) (x).begin(),(x).end()

#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))

#define rep(i, n) for(int i = 0; i < (int)(n); i++)

typedef long long ll;

int main(int argc, char* argv[]) {
    string s;
    cin >> s;
    long ans = 0;
    int len = s.length();
    rep(i, pow(2,len-1)){
        //cout << i << endl;
        vector<string> v;
        int n = 0;
        rep(k,len-1){
            if(i & (1<<k)){
                //cout << "push: " << s.substr(len - 1 - k,k+1 - n) << endl;
                v.push_back(s.substr(len - 1 - k,k+1 - n));
                n += k+1 - n;
            }
        }
        v.push_back(s.substr(0,len - n));
        for(string x : v){
            //cout << "i: " << i << " x: "<< x << endl;
            ans += stol(x);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
N, T = gets.chomp.split(' ').map(&:to_i)
input = Array.new(N) { gets.chomp.split(' ').map(&:to_i) }
new_input = input.select do |item|
  item[1] <= T
end
if new_input.size == 0
  puts 'TLE'
  exit
end
new_new_input = Array.new
new_input.each do |item|
  new_new_input << item[0]
end
puts new_new_input.min


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << 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; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

struct union_find{//rank,経路圧縮で高速化
    vector<int> par;//parは添字の親（または自分が根の時自身）を示す。
    vector<int> rank;//rankは木の高さ（根についてのみ実装,0-indexed）
    vector<int> size;
    union_find(int sz){//コンストラクタ,sz個のノードを作成し、自分を親につける
        par.resize(sz);
        rank.assign(sz,0); //rankは最初0
        size.assign(sz,1);
        for(int i = 0;i < sz;++i) par[i]=i;
    }
    int find(int a){//根を探す
        if(par[a]==a) return a; //親が自身を指す時、根である
        else return par[a] = find(par[a]);//根に直接つける
    }
    void unite(int a,int b){//小さい方の木の根に大きい方の根を上書きする
        int root_a,root_b;
        root_a = find(a),root_b = find(b);
        if(rank[root_a]>rank[root_b]){ //rankの高い方の根に低い方の根をつける
            par[root_b] = root_a;
            size[root_a]+=size[root_b];
        }else if(rank[root_a]<rank[root_b]){
            par[root_a] = root_b;
            size[root_b]+=size[root_a];
        }else{ //rankが同じ時、適当な方につけ、つけられた方のrankを1増やす
            rank[root_a]++;
            par[root_b] = root_a;
            size[root_a]+=size[root_b];
        }
    }
    bool same(int a,int b){return find(a)==find(b);}
};

int main(){
  ll n,m;
  cin>>n>>m;
  union_find uf(n+1);
  rep(i,m){
      ll x,y;
      cin>>x>>y;
      if(!uf.same(x,y)){
          uf.unite(x,y);
      }
  }
  int maxi=0;
  rep(i,n+1){
      chmax(maxi,uf.size[i]);
  }
  print(maxi);
}


Measured memory_bytes: 5612
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

class Solution {
public:
    int longestSubarray(vector<int>& nums, int limit) {
        multiset<int>S;
        int l=0;
        S.insert(nums[0]);
        int ans=0;
        for (int i=1;i<nums.size();i++) {
            while ((*S.rbegin()-*S.begin())>limit && l<i) {
                S.erase(S.find(nums[l]));
                l++;
            }

            ans=max(ans, (int)S.size());
            S.insert(nums[i]);
        }
        return ans;
    }
};

int main() {
    long long x;
    long long ans=0;
    cin>>x;
    ans=x*(x-1)/2;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3640
// C++(GCC 9.2.1)
// 解き直し.
// https://img.atcoder.jp/arc064/editorial.pdf
// ① 1_27.txt, 1_28.txt, 1_30.txt, 1_31.txt で, WA版となったため, ロジック修正.
// -> d[i] / 2 は d[i] * 500000004 % MOD に 修正.
// ② 1_27.txt で, WA版となったため, ロジック修正.
// mPow の 第二引数が, 切り捨てだったものを, 切り上げに修正.
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define pb push_back
#define all(x) x.begin(), x.end()
const LL MOD = 1e9 + 7;

// 与えられた正の整数のすべての約数を抽出.
// @param X: 約数を抽出したい正の整数.
// @return ret: すべての約数.
vector<LL> div(LL X){
    vector<LL> ret;
    ret.pb(1);
    for(LL d = 2; d * d <= X; d++){
        if(X % d == 0){
            ret.pb(d);
            if(d * d != X) ret.pb(X / d);
        }
    }
    if(X > 1) ret.pb(X);
    sort(all(ret));
    return ret;
}

// Fermat's little theorem から, 大きな冪乗の計算を行う.
// @param a: べき乗したい正整数.
// @param b: 指数.
// @return:  べき乗した計算結果(mod版).
LL mPow(LL a, LL b){
    LL t = 1;
    while(b){
        if(b & 1) t = (t * a) % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return t % MOD;
}

int main(){
    
    // 1. 入力情報.
    LL N, K;
    scanf("%lld %lld", &N, &K);
    
    // 2. 例外.
    if(N == 1){
        printf("%lld\n", K);
        return 0;
    }
    
    // 3. N の 約数.
    vector<LL> d = div(N);
    // for(auto &p : d) printf("%lld ", p);
    // puts("");
    
    // 4. 各最小周期に対応する数列の個数.
    int l = d.size();
    LL num[l];
    memset(num, 0, sizeof(num));
    rep(i, l){
        // num[i] = mPow(K, d[i] / 2);
        // num[i] = mPow(K, d[i] * 500000004 % MOD);
        num[i] = mPow(K, (d[i] + 1) / 2);
        rep(j, i){
            if(d[i] % d[j] == 0) num[i] = (num[i] + MOD - num[j]) % MOD;
        }
    }
    
    // 5. 解答を求めるための数式を計算.
    LL ans = 0, nd;
    rep(i, l){
        // nd = (d[i] & 1) ? d[i] : d[i] / 2;
        nd = (d[i] & 1) ? d[i] : (d[i] * 500000004 % MOD);
        ans += num[i] * nd;
        ans %= MOD;
    }
    
    // 6. 出力.
    printf("%lld\n", ans);
    return 0;
    
}

Measured memory_bytes: 3800
#import<bits/stdc++.h>
using namespace std;int m,a,b['   '],i,j,r;int main(){for(;cin>>a>>b[i];++i)i?a<m?:m=a:r=*b;for(sort(b+1,++i+b);--i;r=min(r,max(j,++j+(m-1+*b)/m)))*b-=b[i];cout<<r;}

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

using namespace std;

using ll = long long;

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

    int n;
    cin >> n;

    vector<ll> a(n + 1), sum(n + 1);
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        sum[i] = sum[i - 1] + a[i];
    }

    vector<vector<ll>> dp(n, vector<ll>(n, LLONG_MAX));
    for (int l = 0; l < n; ++l) dp[l][l] = 0;

    for (int size = 2; size <= n; ++size) {
        for (int l = 0; l + size <= n; ++l) {
            const int r = l + size - 1;

            for (int m = l; m < r; ++m)
                dp[l][r] = min(dp[l][r], dp[l][m] + dp[m + 1][r]);
            dp[l][r] += sum[r + 1] - sum[l];
        }
    }

    cout << dp[0][n - 1] << endl;

    return 0;
}


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

using namespace std;

#define REP(i, N) for (int (i) = 0; (i) < (N); ++(i))
#define READALL(c) for (auto &e : c) { cin >> e; }
#define PRINTALL(c) for (const auto &e : c) { cout << e << "\t"; } cout << "\n";

template <typename T>
using V = vector<T>;

typedef long double ld;


int A, B ,C, D, E, F;
vector<int> dp;
int f(int rem) {
	if (rem < 0)
		return 1e9;
	if (dp[rem] != -1)
		return dp[rem];
	int ans = rem;
	ans = min(ans, f(rem-C));
	ans = min(ans, f(rem-D));
	return dp[rem] = ans;
}


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

	cin >> A >> B >> C >> D >> E >> F;

	ld best = -1;
	int besttop, bestbot;

	dp.assign(10000, -1);

	for (int i = 0; 100*A*i <= F; ++i) {
		for (int j = 0; 100*(j*B+i*A) <= F; ++j) {
			int water = 100*(j*B+i*A);
			int lim = min(F-water, E*(i*A+j*B));
			int r = f(lim);
			int usedsug = lim-r;
			// cout << water << " " << lim << " " << usedsug << endl;
			if (ld(usedsug)/ld(water+usedsug) > best) {
				best = ld(usedsug)/ld(water+usedsug);
				besttop = water+usedsug;
				bestbot = usedsug;
			}

		}
	}

	cout << besttop << " " << bestbot << endl;
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define wuyt main
typedef long long ll;
#define HEAP(...) priority_queue<__VA_ARGS__ >
#define heap(...) priority_queue<__VA_ARGS__,vector<__VA_ARGS__ >,greater<__VA_ARGS__ > >
template<class T> inline T min(T &x,const T &y){return x>y?y:x;}
template<class T> inline T max(T &x,const T &y){return x<y?y:x;}
///#define getchar()(p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
///char buf[(1 << 21) + 1], *p1 = buf, *p2 = buf;
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();
if(c == '-')Nig = -1,c = getchar();
while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();
return Nig*x;}
#define read read()
const ll inf = 1e15;
const ll INF = 0x3f3f3f3f;
const int maxn = 3e5 + 7;
const int mod = 998244353;
#define start int wuyt()
#define end return 0
#define pi 3.14159265358979323846
ll gcd(ll a,ll b)
{
    ll t;
    while(b!=0)
    {
        t=a%b;
        a=b;
        b=t;
    }
    return a;
}
ll qPow(ll x, ll k)
{
    ll res = 1;
    while(k) {
        if(k&1)
            res=(res*x);
        k>>=1;
        x=(x*x);
    }
    return res;
}
ll maxx=-1;
ll minn=inf;
ll num[maxn];
///ll a[maxn];
ll num2[maxn];
ll res,ans;
priority_queue <int ,vector<int> ,greater<int> > xiaogen;
deque<int> q;
ll posx[2000],posy[2000];
map<string ,ll> mp;
int main()
{
    ll a=read,b=read,c=read,d=read;
    if(d<=a+b){
        if(d<=a) cout<<d<<endl;
        else cout<<a<<endl;
    }
    else if(d>a+b) cout<<a-(d-a-b)<<endl;
    return 0;
}



Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>
#include <sstream>
#include <fstream>
#include <climits>
#include <map>
#include <numeric>
#include <functional>
#include <utility>

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

int main(void) {
  int n;
  std::string s;
  std::cin >> n;
  std::cin >> s;
  int cnt = 0;
  for (int i = 0; i < s.size() - 2; i++) {
    std::string ss = s.substr(i, 3);
    if (ss == "ABC") cnt++;
  }
  std::cout << cnt << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    char a,b;
    scanf("%c %c", &a, &b);

    if (a == 'H' && b == 'H'){
        printf("%c",'H');
    }
    else if (a == 'H' && b == 'D'){
        printf("%c", 'D');
    }
    else if (a == 'D' && b == 'H'){
        printf("%c", 'D');
    }
    else if (a == 'D' && b == 'D'){
        printf("%c", 'H');
    }

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

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

    if(x == 0) cout << 1 << endl;
    else cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		sc.close();

		long ans = 0;
		long add = 1;
		for (int i = 0; i < k; i++) {
			long next = ans + add * 10;
			ans += add;
			int sn = sum(next);
			int sa = sum(ans);
			if (next * sa < ans * sn) {
				ans = next;
				add *= 10;
			}
			System.out.println(ans);
		}
	}

	static int sum(long n) {
		int ret = 0;
		while (n > 0) {
			ret += n % 10;
			n /= 10;
		}
		return ret;
	}
}


Measured memory_bytes: 21716
N,M = map(int,input().split())
minnum = 0
maxnum = 10**5
for m in range(M):
    l,r = map(int,input().split())
    if l>=minnum:
        minnum=l
    if r<=maxnum:
        maxnum=r
print(max(0,maxnum-minnum+1))


Measured memory_bytes: 3060
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

template <typename T>
bool chmax(T &a, const T& b) {
    if (a < b) {
      a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmin(T &a, const T& b) {
    if (a > b) {
      a = b;
      return true;
    }
    return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vP c(N);
    rep(i,N){
        cin >> c[i].first;
        c[i].second=i;
    }
    sort(c.begin(),c.end());
    vl before(N,-1);
    rep(i,N){
        if(c[i].first==c[i+1].first){
            before[c[i+1].second]=c[i].second;
        }
    }
    ll dp[N];
    rep(i,N){
        dp[i]=0;
    }
    dp[0]=1;
    rep(i,N-1){
        dp[i+1]=dp[i];
        if(before[i+1]!=-1&&before[i+1]!=i){
            dp[i+1]+=dp[before[i+1]];
        }
        dp[i+1]%=MOD;
    }
    rep(i,N){
        cerr << i << ' ' << dp[i] << endl;
    }
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 10008
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda x: [ni() for _ in range(x)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda x: [ns() for _ in range(x)]
nas = lambda: stdin.readline().split()

x, y = na()
print(x + (y // 2))

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}
long long gcd(long long x,long long y){
	return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
	return x/gcd(x,y)*y;
}

typedef struct{
	int x,y;
}queue;

int main(void){
	int r,c,i,j,w=0,head,teil,dy[]={1,-1,0,0},dx[]={0,0,1,-1},f[50][50];
	char m[50][51];
	queue q[100000];
	memset(f,-1,sizeof(f));
	memset(q,-1,sizeof(q));
	scanf("%d %d",&r,&c);
	for(i=0;i<r;i++){
		scanf("%s",m[i]);
		rep(j,c){
			if(m[i][j]=='.')w++;
		}
	}
	r--;c--;
	head=teil=0;
	q[head].y=0;
	q[head].x=0;
	f[0][0]=1;
	while(q[head].x!=-1){
		int ty=q[head].y;
		int tx=q[head].x;
		head++;
		for(i=0;i<4;i++){
			int ny=ty+dy[i];
			int nx=tx+dx[i];
			if(0<=nx&&nx<=c&&0<=ny&&ny<=r&&m[ny][nx]=='.'&&f[ny][nx]==-1){
				f[ny][nx]=f[ty][tx]+1;
				teil++;
				q[teil].y=ny;
				q[teil].x=nx;
			}
		}
	}
	if(f[r][c]==-1)print(-1);
	else 	printf("%d\n",w-f[r][c]);
	return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int p[100005];
set<int>s[100005];

int u_find(int a){
	if(p[a]==0) return a;
	return p[a] = u_find(p[a]);
}
void merge(int a,int b){
	a = u_find(a);
	b = u_find(b);
	if(a==b) return;
	p[a] = b;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,m;
	cin>>n>>m;
	int arr[n+1]={0};
	for(int i=1; i<=n; i++) cin>>arr[i];
	while(m--){
		int a,b;
		cin>>a>>b;
		merge(a,b);
		
	}
	for(int i=1; i<=n; i++){
		s[u_find(i)].insert(arr[i]);
	}
	int ret = 0;
	for(int i=1; i<=n; i++){
		if(s[u_find(i)].find(i)!=s[u_find(i)].end()) ret++;
	}
	cout<<ret;
}

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

int main() 
{
  int a, b, ans;
  cin >> a >> b;
  ans = a *b;

  if (ans % 2 ==0){
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N = int(input())
d = list(map(int, input().split()))
d.sort()
ans = d[N // 2] - d[N // 2 - 1]
print(ans)

Measured memory_bytes: 52764
#include <vector>
#include <queue>
#include <cstdio>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

pair<Weight, Edges> minimumSpanningTree(const Graph &g, int r1) {
  int n = g.size();
  Edges T;
  Weight total = 0;

  vector<bool> visited(n);
  priority_queue<Edge> Q;
  Q.push( Edge(-1, r1, 0) );
  //Q.push( Edge(-1, r2, 0) );
  while (!Q.empty()) {
    Edge e = Q.top(); Q.pop();
    if (visited[e.dst]) continue;
    T.push_back(e);
    total += e.weight;
    visited[e.dst] = true;
    FOR(f, g[e.dst]) if (!visited[f->dst]) Q.push(*f);
  }
  return pair<Weight, Edges>(total, T);
}

int main(){
	int N,M,Q,a,b,c;
	scanf("%d%d",&N,&M);
	Graph g(N);
	for(;M--;){
		scanf("%d%d%d",&a,&b,&c);
		g[a].emplace_back(a,b,c);
		g[b].emplace_back(b,a,c);
	}
	//scanf("%d",&Q);
	//for(;Q--;){
	//	scanf("%d%d",&a,&b);
		printf("%d\n",minimumSpanningTree(g,0).first);
	//}
}

Measured memory_bytes: 8224