akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
	int m,max,min,gap,maxgap,ans;
  	vector<int> score(201);
  	for(int i=0; i < 10001; i++){
      cin >> m >> min >> max;
      if(m == 0 && min == 0 && max == 0){
        break;
      }else{
  	  	for(int j=0; j < m; j++){
          cin >> score.at(j);
        }
        maxgap = score.at(min-1) - score.at(min);
        ans = min;
        for(int k = min; k < max; k++){
          gap = score.at(k) - score.at(k+1);
          if(gap >= maxgap){
            maxgap = gap;
            ans = k+1;
          }
        }
        cout << ans << endl;
      }
    }
  return 0;
}


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  string s; cin >> s;
  string t; cin >> t;
  int ans = 0;
  for (int i = 0; i < s.size(); i++) { 
    ans += (s[i] != t[i]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3924
#include <iostream>

using namespace std;

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

  int count = 0;

  for (int i = 0; i < n - 1; i++) {
    cin >> cur;
    if (prev == cur) {
      count++;
      prev = -1;
    } else {
      prev = cur;
    }
  }

  cout << count << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define chmin(x,y) if(x>y)x=y
#define chmax(x,y) if(x<y)x=y
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const ll inf=100100100100;
const int Inf=1001001001;
const int mod=1000000007;

int dp[102][4][4][4];
bool ck(int a,int b,int c,int d){
    if(a==0&&b==1&&c==2)return false;
    if(b==0&&c==1&&d==2)return false;
    return true;
}
bool check(int a,int b,int c,int d){
    vi k(4);
    k[0]=a;k[1]=b;k[2]=c;k[3]=d;
    if(!ck(a,b,c,d))return false;
    rep(i,3){
        swap(k[i],k[i+1]);
        if(!ck(k[0],k[1],k[2],k[3]))return false;
        swap(k[i],k[i+1]);
    }
  return true;
}

int main(){
  int n;cin>>n;
    rep(i,4)rep(j,4)rep(k,4)rep(l,4)if(check(i,j,k,l))dp[3][j][k][l]++;
    REP(i,4,n){
        rep(j,4){
            rep(k,4){
                rep(l,4){
                    rep(m,4){
                        if(check(j,k,l,m)){
                            dp[i][k][l][m]=(dp[i][k][l][m]+dp[i-1][j][k][l])%mod;
                        }
                    }
                }
            }
        }
    }
  ll ans=0;
  rep(j,4)rep(k,4)rep(l,4)ans+=dp[n-1][j][k][l];
  if(n==3)cout<<61<<endl;
  else cout<<ans%mod<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
#define Max 1000001
#define inf INT_MAX
#define llinf LONG_LONG_MAX
#define rep(i,a,b) for(i=a;i<=b;i++)
#define rrep(i,a,b) for(i=a;i>=b;i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define pb push_back
#define pf push_front
#define F first
#define S second
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
const ll N=5e2+1,mod=1000000007;
signed main()
{
    fast;
    ll pro=1,temp,t,n,i,m,k,j,l,r,mid,x,y,z,rem,carry=0,ind,ans=0,mx=-llinf,mn=llinf,cnt=0,curr=0,prev,sum=0,flag=1,i1=-1,i2=-1;
    cin>>x>>y;
    if((x+y)%2==0)
    {
        cout<<(x+y)/2;
    }
    else
    {
        cout<<"IMPOSSIBLE";
    }
    return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int t,n,s=0;

int a[100005];
 
 
int cache[100005];
 
 
int dp(int n)
{
    if (n==0)
        return 0;
    if (n<0) 
        return  1e8;
    if (cache[n]!=-1)
        return cache[n];
    else
    {
        cache[n]=min(abs(a[n]-a[n-1])+dp(n-1),abs(a[n]-a[n-2])+dp(n-2));
        return cache[n];
    }
}
 
int main()
    {
        cin>>n;
        for(int i=0;i<n;i++)
            cin>>a[i];
        memset(cache,-1,sizeof(cache));
        
        cout<<dp(n-1)<<endl;
        return 0;
    }

Measured memory_bytes: 3328
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define SZ(x) ((ll)(x).size())
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i,n){
        cin >> a[i];
    }
    ll res = 0;
    REP(i,n-1){
        res += a[i]/2;
        a[i]%=2;
        if(a[i]&&a[i+1]){
            res++;
            a[i]--;
            a[i+1]--;
        }
    }
    res += a[n-1]/2;
    put(res);
    return 0;
}


Measured memory_bytes: 640
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
hp = [tuple(map(int, input().split())) for _ in range(n)]
hp.sort(key=lambda x: x[0]+x[1])
dp = [10**15] * (n+1)
dp[0] = 0
for i in range(n):
    h,p = hp[i]
    for j in range(n,0,-1):
        if dp[j-1]<=h:
            dp[j] = min(dp[j], dp[j-1]+p)
#     print(dp)
for i in range(n, -1, -1):
    if dp[i]<10**15:
        break
ans = i
print(ans)

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

int main() {
  int n;
  cin>>n;
  int a[n];
  for (int i=0; i<n; i++) cin>>a[i];
  map<int, int> m;
  long long cnt = 0;
  for (int i=0; i<n; i++) {
    int tmp = i - a[i];
    if (m.find(tmp) != m.end()) {
      cnt += m[tmp];
    }
    ++m[i+a[i]];
  }
  cout<<cnt<<endl;
}

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX

const double EPS = 1e-14;
const double PI  = acos(-1.0);


int dsum(int n) {
  int x = n;
  int res = 0;
  while(x > 0) {
    res += x % 10;
    x /= 10;
  }
  return res;
}

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

  string ans;
  if (n % dsum(n) == 0) ans = "Yes";
  else ans = "No";

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
using namespace std;

int main() {
    int n,m,x,a[100],l=0,r=0;
    cin>>n>>m>>x;
    for(int i=0;i<m;i++){
        cin>>a[i];
        if(a[i]<x){
            l++;
        }else{
            r++;
        }
    }
    if(l>r){
        cout<<r<<endl;
    }else{
        cout<<l<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int gcd(int m,int n){
        
    while (m != n){    
        if(m > n)
            m = m -n;
        else
            n = n - m;
    }
    return m;
}

int main(void){
    int m,n;
    while(scanf("%d %d", &m, &n)!= EOF){
        
        printf("%d ", gcd(m,n));
        int lcm = m / gcd(m,n) * n;
        printf("%d\n", lcm);
    }
    return 0;   
}



Measured memory_bytes: 1908
#include <stdio.h>
#include <stdlib.h>

int cmp(const void* a,const void*b){
	return *(int*)a-*(int*)b;
}
int main(void){
	int n;
	scanf("%d",&n);
	int a[n];
	int i,ans=0;
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);;
	}
	qsort(a,n,sizeof(int),cmp);
	i=0;
	int num = 0;
	for(i=0;i<n;i++){
		num = 1;
		while( (i+1<n)&&a[i]==a[i+1]){
			num++;
			i++;
		}
		//a[i]には数値が入り、numにはその個数が入っている
		if(num >=a[i])ans += (num-a[i]);
		else ans += num;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#define N 100006
using namespace std;
int n,c,k,v,st,ans,a[N];
int main()
{
	scanf("%d%d%d",&n,&c,&k);
	for(int i=1;i<=n;i++)scanf("%d",a+i);
	sort(a+1,a+n+1);
	ans=1;v=1;st=a[1];
	for(int i=2;i<=n;i++){
		if(a[i]-st<=k&&v+1<=c)v++;
		else{
			v=1;st=a[i];ans++;
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 640
from collections import deque
def main():
    N = int(input())
    P = [str(int(n)-1) for n in input().split()]
    Q = [str(int(n)-1) for n in input().split()]
    P = "".join(P)
    Q = "".join(Q)
    q = deque([str(i) for i in range(N)])
    i = 0
    while len(q) > 0:
        i += 1
        s = q.popleft()
        if s == P:
            pp = i
        if s == Q:
            qq = i
        if len(s) == N:
            continue
        for i in range(N):
            if str(i) not in s:
                q.append(s + str(i))
    print(abs(pp-qq))
main()

Measured memory_bytes: 6252
N = int(input())
A = list(map(int, input().split()))

A.sort(reverse=True)

cnt = 0
if N % 2 == 0:
    cnt += A[0]
    for i in range(1, N//2):
        cnt += A[i] * 2
    
else:
    cnt += A[0]
    for i in range(1, N//2):
        cnt += A[i] * 2
    cnt += A[i+1]
print(cnt)

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N;
int A[200100];

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

  std::cin >> N;

  for(int i=0;i<N;++i){
      std::cin >> A[i];
  }

  std::sort(A, A + N);

  for(int i=0;i+1<N;++i){
      if(A[i] == A[i+1]){
          std::cout << "NO" << std::endl;
          return 0;
      }
  }

  std::cout << "YES" << std::endl;
}


Measured memory_bytes: 1024
def main():
    m, d = map(int, input().split(" "))
    count = 0
    for m in range(1, m+1):
        for day in range(1, d+1):
            d1 = day % 10
            d10 = (day - d1) // 10
            if d1>=2 and d10 >=2 and d1*d10==m:
                count += 1

    print(count)

main()

Measured memory_bytes: 2940
#include<iostream>
#include<numeric>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

typedef long long ll;
const ll INF=1LL<<60;


int main(){ 
	int n,A[100000]; cin>>n;
	for(int i=0;i<n;i++) cin>>A[i];
	vector<long long>dp(n,INF);
	dp[0]=0;
	for(int i=1;i<n;i++){
		for(int j=1;j<=2;j++){
			if(i-j>=0){
				dp[i]=min(dp[i],dp[i-j]+abs(A[i-j]-A[i]));
			}
		}
	}
	cout<<dp.back()<<endl;
}

Measured memory_bytes: 1408
n = gets.to_i
a = gets.split.map(&:to_i)

rate = Hash.new(0)
a.each do |i|
  rate[[i, 3200].min / 400] += 1
end

wild = rate.delete(8)
min = rate.keys.size
min = 1 if min == 0 && wild
max = rate.keys.size
max += wild if wild

puts "#{min} #{max}"


Measured memory_bytes: 1788
// Date: 2020-04-20

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define IO freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout)
#define FIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define D(x) cout << #x << " = " << x << endl;
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)x.size())
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 2000 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

pii a[N];
int n;
LL dp[N][N];

int main() {
    FIO;
    cin >> n;
    rep(i, 1, n) {
        cin >> a[i].fi;
        a[i].se = i;
    }
    sort(a+1, a+1+n);
    reverse(a+1, a+1+n);
    mem(dp, -1);
    dp[0][0] = 0;
    rep(i, 1, n) rep(j, 0, i) {
        if(dp[i-1][j] != -1) chkmax(dp[i][j], dp[i-1][j] + 1LL*a[i].fi*abs(n-(i-1-j)-a[i].se));
        if(j && dp[i-1][j-1] != -1) chkmax(dp[i][j], dp[i-1][j-1] + 1LL*a[i].fi*abs(j-a[i].se));
    }
    LL ans = 0;
    rep(i, 0, n) chkmax(ans, dp[n][i]);
    cout << ans;

    return 0;
}

Measured memory_bytes: 35208
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace _001_FindingMissingCards
{


    class Program
    {
        static void Main()
        {
            var n = Convert.ToInt32(Console.ReadLine());
            var r = new long[n];

            for (int i = 0; i < n; i++)
            {
                r[i] = Convert.ToInt64(Console.ReadLine());
            }
            var maxv = r[1]-r[0];
            var minv = r[0];
            for (int j = 1; j < n; j++)
            {
                if (maxv < r[j] - minv) maxv = r[j] - minv;
                if (minv > r[j]) minv = r[j];
            }
            Console.WriteLine(maxv);
            
        }
    }
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;

const ll linf = 1LL << 62;
const int inf = 999999;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const ll atcoder = int(1e9 + 7);

#define Endl endl
#define pr(x) cout << x << endl
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define all(x) x.begin(),x.end()
#define atcoder(int)1e9+7
#define rep(i,n) for(int i = 0;i<n;i++)
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)


ll gcd(ll a, ll b) {//最大公約数
	if (a%b == 0)return b;
	else gcd(b, a%b);
}

ll lcm(ll a, ll b) {//最小公倍数
	return (a / gcd(a, b))*b;
}

vector<pair<int, int>>v[200010];
int dist[100010] = { 0 };
bool f[100010] = { false };

bool search(int n) {

	for (int i = 0; i < v[n].size();i++) {
		int a = v[n][i].first;
		int b = v[n][i].second;
		
		if (!f[a]) {
			dist[a] = dist[n] + b;
			f[a] = true;
			search(a);
		}
		else if (dist[a] != dist[n] + b) {
			pr("No");
			exit(0);
		}
	}			
}

int  main() {

	int n, m;
	cin >> n >> m;

	rep(i, m) {
		int l, r, d;
		cin >> l >> r >> d;
		v[l].pb(mp(r, d));
		v[r].pb(mp(l, -d));
	}
	f[1] = {true};

	rep(i, n) search(i + 1);
			
	pr("Yes");
	
	return 0;

}

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

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define all(x) (x).begin(), (x).end()
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define ford(i, n, e) for (int i = (int)(n); i >= (int)(e); --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
#define RETURN(x) do{cout << (x) << '\n'; return 0;}while(0)

const int MOD = 998244353; //1e9+7;
const int MAXN = 1e6+1;

int main(int argc, char **argv) {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    string s; cin >> s;
    auto f = [](const string &x) {
        for(int i=0,j=x.size()-1; i <= j; i++,j--) {
            if(x[i] != x[j]) return false;
        }

        return true;
    };

    bool ok = f(s);
    ok &= f(s.substr(0,(s.size()-1)/2));
    ok &= f(s.substr((s.size()+3)/2-1,s.size()-(s.size()+3)/2+1));
    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}


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

int main() {
 string S,T;
 cin >> S >> T;
 int x=0;
 for(int i=0;i<3;i++){
   if(S.at(i)==T.at(i)){
     x++;
   }
 }
  cout << x << endl;
}

Measured memory_bytes: 3628
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(n)-1,i##_len=(int)(s);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};
//今回の変数
int d[100000];

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
ll Minl(ll a, ll b) {
	return (a)<(b) ? (a) : (b);
}
ll Maxl(ll a, ll b) {
	return (a)>(b) ? (a) : (b);
}
void ShowData(int x[], int left, int right)
{
	int i;
	for (i = left; i <= right; i++)printf("%d  ", x[i]);
	printf("\n");
}
void hSwap(int x[], int i, int j)
{
	int temp;

	temp = x[i];
	x[i] = x[j];
	x[j] = temp;
}
void QSort(int x[], int left, int right, int n) {
	int i, j;	//左端,右端
	int pivot;	//軸

	i = left;
	j = right;
	pivot = x[(left + right) / 2];

	while (1) {
		if (n > 0) {				//n>0なら昇順、n<=0なら降順
			while ((x[i] < pivot) && (i <= right))i++;	//軸値より大きい要素
			while ((pivot < x[j]) && (i <= right))j--;	//軸値より小さい要素
		}
		else {
			while ((x[i] > pivot) && (i <= right))i++;	//軸値より小さい要素
			while ((pivot > x[j]) && (i <= right))j--;	//軸値より大きい要素
		}
		if (i >= j)	break;
		hSwap(x, i, j);
		i++; j--;
	}
	//ShowData(x, left, right);

	if (left < i - 1)QSort(x, left, i - 1, n);
	if (j + 1 <  right)QSort(x, j + 1, right, n);
}

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

	REP(i, n) {
		scanf("%d", &d[i]);
	}
	QSort(d, 0, n - 1, 1);

	PRINTD(d[n / 2] - d[n / 2 - 1]);
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppiii;

void solve() {
  int n;
  cin >> n;
  if(n==3||n==5||n==7) cout << "YES\n";
  else cout << "NO\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
  int n,i,a,b,j;
  cin >> n;
  vector<pair<int,int> > pa(n),pb(n);
  for(i=0;i<n;i++)cin >> pa[i].second >> pa[i].first;
  for(i=0;i<n;i++)cin >> pb[i].first >> pb[i].second;
  sort(pa.begin(),pa.end());
  sort(pb.begin(),pb.end());
  reverse(pa.begin(),pa.end());
  vector<int> a_used(n,0),b_used(n,0);
  int cnt = 0;
  for(i=0;i<n;i++){
    int bx = pb[i].first;
    int by = pb[i].second;
    for(j=0;j<n;j++){
      int ax = pa[j].second;
      int ay = pa[j].first;
      if(ax<bx && ay<by && a_used[j]==0 && b_used[i]==0){
        cnt++;
        //cout << ax << " " << ay << " " << bx << " " << by << endl;
        a_used[j]=1;
        b_used[i]=1;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int ans = (a < 10 && b < 10) ? a * b : -1;
		System.out.println(ans);
	}
}

Measured memory_bytes: 23252
#include "iostream"
#include "vector"
#include "algorithm"

using namespace std;
typedef pair<int, int> pii;

int main()
{
  int n, t, a;
  cin >> n >> t >> a;
  t *= 1000;
  a *= 1000;
  int h[1010];
  for (int i = 0; i < n; i++)
  {
    cin >> h[i];
  }
  vector<pii> v;
  for (int i = 0; i < n; i++)
  {
    v.push_back(pii(abs(t - a - 6 * h[i]), i + 1));
  }
  sort(v.begin(), v.end());
  cout<< v[0].second << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include<algorithm> 
#include <iomanip>
#include <math.h>
#include <iostream>
#include <bitset>

#define db double
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define ll long long
#define ld long double
#define maxn 5005
#define mod 998244353
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define vv(z,a,b) vector<vector<int>>z(a,vector<int>(b))
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(c) begin(c),end(c)
#define pp pair<int,int>
#define fix(n) fixed << setprecision(n)
using namespace std;


int main(){
int n;cin>>n;
vv(a,n,2);
rep(i,n)rep(j,2)cin>>a.at(i).at(j);
vi d(n);

rep(i,n)d.at(i)=i;
double sum=0;
int flag=0;
do{
    double kyori=0;
    for(int i=1;i<n;i++){
       int x=abs(a.at(d.at(i-1)).at(0)-a.at(d.at(i)).at(0));
       x*=x;
       int y=abs(a.at(d.at(i-1)).at(1)-a.at(d.at(i)).at(1));
       y*=y;
        kyori+=sqrt(x+y);
    }
    sum+=kyori;
    //cout<<sum<<endl;
    flag++;
}while(next_permutation(all(d)));

double ans=sum/flag;

cout<<fix(10)<<ans<<endl;
}

Measured memory_bytes: 3840
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <map>
#include <list>
#define MOD 1000000007
#define INF 1000000000
typedef long long ll;
using namespace std;
typedef pair<int,int> P;

int main(void){
    
    int n;
    cin>>n;
    vector<int>a(n);
    bool ok=true;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]%2)ok=false;
    }
    int cnt=0;
    while(1){
        if(ok==false)break;
        for(int i=0;i<n;i++){
            if(a[i]%2){
                ok=false;
                break;
            }else{
                a[i]=a[i]/2;
            }
        }
        if(ok==false)break;
        cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>
#include <fstream>
#include <ctime>

using namespace std;
using ll = long long;

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<int> enum_div(int n) {
    std::vector<int> ret;
    for (int i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i != 1 && i * i != n) {
                ret.push_back(n / i);
            }
        }
    }
    return ret;
}

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

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

template<class T>
bool is_integer(T x) {
    return std::floor(x) == x;
}

struct ToUpper {
    char operator()(char c) { return toupper(c); }
};

struct ToLower {
    char operator()(char c) { return tolower(c); }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N;
    cin >> N;

    int cnt = 0;
    FOR(i, 1, N + 1) {
        if (i % 2 == 1)cnt++;
    }

    cout << (double)cnt / N << endl;
    return 0;
}

Measured memory_bytes: 256
using System;

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            var flag = false;
            for(var i = 1; i <= 9; i++){
                for (var j = 1; j <= 9; j++){
                    if(i * j == n){
                        flag = true;
                        break;
                    }                    
                }
            }

            Console.WriteLine(flag ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13140
import itertools

while True:
    count = 0
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break
    l = [i for i in range(1, n + 1)]
    for j in itertools.combinations(l, 3):
        if sum(j) == x:
            count += 1
    print(count)


Measured memory_bytes: 5640
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n); i >= 0; i--)
#define loop(i, a, n) for(int i = (a); i < (n); i++)
using namespace std;
using ll = int64_t;

int main(){
    int n, k; cin >> n >> k;
    ll h[n]; rep(i, n) cin >> h[i];
    sort(h, h+n);
    ll ans = 0;
    rrep(i, n-1){
        if(i >= n-k) continue;
        ans += h[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ

signed main(){
    constexpr ll MOD = 998244353;
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n,k; cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(ALL(a));
    int ans=0;
    rep(i,k) ans+=a[i];
    cout << ans << endl;
}


Measured memory_bytes: 3656
#include<cmath>
#include<vector>
#include<iostream>
#include<cstring>
#include<algorithm>

using namespace std;


int main() {
	int N;
	cin >> N;
	vector<pair<int, int>> pea(N);
	for (int i = 0; i < N; i++) {
		cin >> pea.at(i).first;
		pea.at(i).second = i + 1;
	}
	sort(pea.begin(),pea.end());

	for (int j = 0; j < N; j++) {
		cout << pea.at(j).second << endl;
	}
}



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

using namespace std;

struct Vector{
    double x,y;
    Vector(double x=0,double y=0):x(x),y(y){}
};
typedef Vector Point;

double dot(Vector a,Vector b){
    return a.x*b.x+a.y*b.y;
}

double cross(Vector a,Vector b){
    return a.x*b.y-a.y*b.x;
}

double abs(Vector a){
    return sqrt(a.x*a.x+a.y*a.y);
}

int main(){
    Point a,b;
    cin>>a.x>>a.y>>b.x>>b.y;
    int q;
    cin>>q;
    while(q--){
        Point t;
        cin>>t.x>>t.y;
        Vector p1(b.x-a.x,b.y-a.y),p2(t.x-a.x,t.y-a.y);
        double s1=dot(p1,p2);
        double s2=abs(p1);
        double k=s1/(s2*s2);
        Vector p3(k*p1.x,k*p1.y);
        Point d(p3.x+a.x,p3.y+a.y);
        Vector p4(d.x-t.x,d.y-t.y);
        Vector p5(2*p4.x,2*p4.y);
        Point ans(p5.x+t.x,p5.y+t.y);
        printf("%.10lf %.10lf\n",ans.x,ans.y);

    }
}

Measured memory_bytes: 3196
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

//--------------------------------------------

int n,m;
vi a;
int dp[10010];
const int match[10] = {11451419,2,5,5,4,5,6,3,7,6};

signed main(){
    I(n); I(m);
    a.resize(m);
    REP(i,m) I(a[i]);
    sort(all(a));

    REP(i,n) dp[i] = -1145141919810LL;
    dp[0] = 0;
    REP(i,n+1){
        for(auto v: a){
            dp[i + match[v]] = max(dp[i + match[v]], dp[i]+1);
        }
    }
    int dig = n;
    sort(all(a), greater<int>());

    while(dig){
        // cerr << dig << endl;
        for(auto v:a){
            if ( dig >= match[v] && dp[dig-match[v]] == dp[dig] - 1){
                cout << v;
                dig -= match[v];
                break;
            } 
        }
    }
    cout << endl;
}

Measured memory_bytes: 384
N = int(input())
p = [list(map(int, input().split())) for i in range(N)]
h = [h for x, y, h in p]
maxh = max(h)
def height(H, cx, cy, l):
    for x, y, h in l:
        if h != max(H-abs(x-cx)-abs(y-cy) , 0):
            return False
    return True
flag = False
for i in range(maxh,10**9 +201):
    for cx in range(101):
        for cy in range(101):
            if height(i, cx, cy, p):
                print(cx, cy, i)
                flag = True
                break
        if flag:
            break
    if flag:
        break

Measured memory_bytes: 3064
package main

import (
	"fmt"
)

func main() {
	var N, T int
	fmt.Scan(&N)
	fmt.Scan(&T)

	minc := 9999
	for i := 0; i < N; i++ {
		var ci, ti int
		fmt.Scan(&ci)
		fmt.Scan(&ti)
		if ti <= T {
			if ci < minc {
				minc = ci
			}
		}
	}

	if minc == 9999 {
		fmt.Println("TLE")
	} else {
		fmt.Println(minc)
	}
}


Measured memory_bytes: 512
#n, m, q = map(int, input().split())
#List = list(map(int, input().split()))
#req = [list(map(int, input().split())) for _ in range(q)]
#t = t[:-1]
#print(ans[j], end = "") 改行無しで出力
#[0]*n
#sort = sorted(a)[::-1] 降順
#if l[i] == l[j]: continue
n, x, t = map(int, input().split())
if n%x == 0:
    a = int(n/x)
else:
    a = int(n/x)+1

print(t*a)


Measured memory_bytes: 9152
#include<iostream>
#include<math.h>
using namespace std;
//エラトステネス
bool isprime(int x) {
	//2葉素数
	if (x == 2) {return true; }
	//偶数は素数でない
	else if (x % 2 == 0) { return false; }
	//奇数かつ2以外
	else {
		for (int i = 3; i <= sqrt(x); i++) {
			//iで割り切れた時点で合成数
			if (x%i == 0) { return false; }
		}
		//すべてのiで割り切れないので素数
		return true;
	}
}

int main()
{
	int count = 0;
	int N;
	cin >> N;
	int* x = new int[N];
	for (int i = 0; i < N; i++) {
		cin >> x[i];
		if (isprime(x[i]))
			count++;
	}
	cout << count << endl;
	delete[] x;
}




Measured memory_bytes: 3120
n = int(input())
h = [int(x) for x in input().split()]

c = [None] * n
c[0] = 0
c[1] = abs(h[1] - h[0])
for i in range(2, n):
    c[i] = min(
        c[i - 2] + abs(h[i] - h[i - 2]), c[i - 1] + abs(h[i] - h[i - 1])
    )
print(c[n - 1])



Measured memory_bytes: 13980
void main() {
	auto N = ri;
	alias Pair = Tuple!(int, "u", int, "v", int, "w");
	Pair[] pairs;
	Pair[][long] next;
	foreach(i; 0..N-1) {
		auto ip = readAs!(int[]), u = ip[0], v = ip[1], w = ip[2];
		pairs ~= Pair(u-1, v-1, w);
		pairs ~= Pair(v-1, u-1, w);
		next[u-1] ~= Pair(u-1, v-1, w);
		next[v-1] ~= Pair(v-1, u-1, w);
	}
	auto visitable = new bool[](N);
	auto visited = new bool[](N);
	visitable[0] = true;
	long[] queue = [0];
	
	while(queue != []) {
		long i = queue.front;
		queue.popFront;
		if(visited[i]) continue;
		visited[i] = true;
		//i.writeln;
		
		foreach(v; next.get(i, [])) {
			//v.writeln;
			if(((visitable[i] ? 0 : 1) + v.w) % 2 == 0) visitable[v.v] = true;
			else visitable[v.v] = false;
			if(!visited[v.v]) queue ~= v.v;
		}
	}
	//visitable.writeln;
	visitable.map!(i => i ? 0 : 1).each!writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 30076
from collections import deque

n = int(input())
m = n * (n - 1) // 2
b = [[0, 0] for _ in range(m + 1)]
f = [0] * (m + 1)
q = deque()
for i in range(1, n + 1):
    a = list(map(int, input().split()))
    for j in range(n - 1):
        ma, mi = max(i, a[j]), min(i, a[j])
        x = (ma - 1) * (ma - 2) // 2 + mi
        if j == 0:
            f[x] += 1
            if f[x] == 2:
                q.append(x)
        else:
            if b[y][0] == 0:
                b[y][0] = x
            else:
                b[y][1] = x
        y = x
ans = 0
while q:
    ans += 1
    l = len(q)
    for _ in range(l):
        i = q.popleft()
        for j in range(2):
            k = b[i][j]
            f[k] += 1
            if f[k] == 2 and not k == 0:
                q.append(k)
print(ans if f[0] == n else -1)

Measured memory_bytes: 88476
#include <cstdio>
int n, m, u, c[100005];
int main() {
	scanf("%d%d", &n, &m);
	m *= 2;
	while(m--) scanf("%d", &u), c[u]++;
	while(n--) if(c[n]%2) {puts("NO"); return 0;}
	puts("YES");
	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
int main(void){
	int n,i,a[10000],min=1000000,max=-1000000;
	long sum=0;
	scanf("%d",&n);
	for(i=0; i<n  ; i=i+1 ){
		scanf("%d",&a[i]);
	}
	for(i=0; i<n  ; i=i+1 ){
		if(a[i]<min){
			min=a[i];
		}
		if(a[i]>max){
			max=a[i];
		}
	}
	for(i=0; i<n  ; i=i+1 ){
		sum=sum+a[i];
	}
	printf("%d %d %ld\n",min,max,sum);
	return 0;
}

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

const int64_t MOD = 998244353;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

map<string, int64_t> memo;
int64_t rec(string S){
    if(memo.count(S)) return memo[S];
    int N = S.size();
    int64_t res = rec(S.substr(1, N-1)) * (1 + S[0] - '0') % MOD;
    for(int w=1; w<=N/2; w++){
        string s = S.substr(0, w);
        for(int k=2; k*w<=N; k++){
            for(int x=0; x<w; x++) if(S[x+(k-1)*w] == '0') s[x] = '0';
            add(res, rec(s) * rec(S.substr(k*w, N-k*w)));
        }
    }
    memo[S] = res;
    return res;
}

int main(){
    string S;
    cin >> S;
    memo[""] = 1;
    cout << rec(S) << endl;
    return 0;
}


Measured memory_bytes: 5632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int flag=0;
    int n;
    scanf("%d",&n);
    ll sum=0;
    for(int i=1;i<=n;i++)
    {
       for(int j=1;j<=n;j++)
       {
        for(int k=1;k<=n;k++)
            sum+=(ll)__gcd(__gcd(i,j),k);
       }
    }
    printf("%lld",sum);
}


Measured memory_bytes: 3832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long int ulli;
typedef long long int lli;
#define pb(a) push_back(a)
#define pbb(a) pop_back(a)  
#define ph(a) push_heap(a.begin(), a.end())
#define pph(a) pop_heap(a.begin(), a.end())
#define si set<int>
#define sl set<long>
#define sc set<char>
#define pii pair<int, int>
#define pll pair<long, long>
#define pdd pair<double, double>
#define TC(t) while(t--)
#define FORA(a,b,c) for ((a) == (b); (a) < (c); (a) ++)
#define FORB(a,b,c) for ((a) == (b); (a) <= (c); (a) ++)
#define FORC(a,b) for ((a) == (b); (a) > 0; (a)--)
#define FORD(a,b) for ((a) == (b); (a) >= 0; (a)--)                         
#define WM(a) while(a--)
#define WP(a) while(a++)
#define print(data) cout << data << endl
#define tin(a) cin >> a
#define ttin(a,b) cin >> a >> b
#define tttin(a,b,c) cin >> a >> b >> c
#define maxheap(a) make_heap(a.begin(),a.end())
#define fixp(a)  cout << fixed << setprecision(a);
#define RM(a,n) a.erase(remopricee(a.begin(), a.end(), n),a.end())
#define MOD 1000000007
ll prime[] = {2 , 3 , 5 , 7 , 11 , 13 , 17 , 19 , 23 , 29 , 31 , 37 , 41 , 43 , 47};
inline int gmx (int a, int b){
	return a > b ? a : b;
}
inline int gmm (int a, int b){
	return a < b ? a : b;
}
inline ll get_gcd(ll a, ll b){
    ll rem = 0;
    while( b != 0){
        rem = a % b;
        a = b; 
        b = rem;
    }
    return a;   
}
ll fastexp (ll base, ll exp){
	ll res = 1;
	if (exp == 0) return 1LL;
	while(exp){
		if(exp&1) res = (res*base)%MOD;
		res = (res+MOD)%MOD;
		base = (base*base)%MOD;
		base = (base+MOD)%MOD;
		exp >>= 1;
	}
	return (ll)res;
}
struct compare {
    bool operator()(const std::string& first, const std::string& second) {
        return first.size() < second.size();
    }
};
void Verdict_Check(){
	ifstream A("my_output.txt");
	ifstream B("code_output.txt");
	
	int c1=0,c2=0;
	bool WA = false;
	string str;
	while(getline(A,str)){
		c1++;
	}
	while(getline(B,str)){
		c2++;
	}
	A.close();
	B.close();
	ifstream AA("my_output.txt");
	ifstream BB("code_output.txt");
	if (c1 != c2){
		WA = true;
	}else{
		string s,ss;
		while(getline(AA,s) && getline(BB,ss)){
			if(s != ss){
				WA = true;
			}
		}
	}
	if (WA){
		cout << "Wrong answer!!!" << endl;
	}else{
		cout << "All test cases are passed!!!" << endl;
	}
	AA.close();
	BB.close();
}
int main(){
	
	//freopen("a.in","r",stdin);
	//freopen("my_output.txt","a", stdout);
	clock_t tStart = clock();
	int ans = 0;
	int n; cin >> n;
	int rem = 0;
	while(n){
		rem = n % 10;
		int a = rem;
		n /= 10;
		rem = n % 10;
		int b = rem;
		n /= 10;
		rem = n % 10;
		int c = rem;
		n /= 10;
		rem = n % 10;
		int d = rem;
		n /= 10;
		if(a == b && b == c || b == c && c == d){
			ans = 1;
			break;
		}
	}
	if(ans){
		cout << "Yes" << endl; 
	}else{
		cout << "No" << endl;
	}
	//freopen("CON", "w", stdout);
	//Verdict_Check();
	// printf("Time taken: %.7fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
using namespace std;

int main()
{
	unsigned long long N, M;
	cin >> N >> M;

	vector<unsigned long long> count(N + 1);
	for (auto i = 0; i < M; ++i)
	{
		int L, R;
		cin >> L >> R;
		count[L - 1]++;
		count[R]--;
	}

	for (auto i = 1; i < N; ++i)
	{
		count[i] += count[i - 1];
	}

	auto result = 0;
	for (auto i = 0; i < N; ++i)
	{
		if (count[i] == M)
		{
			++result;
		}
	}

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <queue>

using namespace std;

int main(int argc, char* argv[]) {
  int N, M;
  cin >> N >> M;

  priority_queue<long long> q;
  for (int i = 0; i < N; ++i) {
    long long tmp;
    cin >> tmp;
    q.push(tmp);
  }

  while (M > 0) {
    long long tmp = q.top();
    q.pop();
    q.push(tmp / 2);
    --M;
  }

  long long ret = 0;
  while (!q.empty()) {
    ret += q.top();
    q.pop();
  }

  cout << ret << endl;

  return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<vector<long long>> A(10, vector<long long>(10));
  for (int i=1; i<=N; i++){
    string hoge = to_string(i);
    A[hoge[0]-'0'][hoge[hoge.size()-1]-'0']++;
  }
  long long ans = 0;
  for (int i=1; i<=N; i++){
    string hoge = to_string(i);
    ans += A[hoge[hoge.size()-1]-'0'][hoge[0]-'0'];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import math

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

A.sort()
def isPossible(maxL):
    cuts = 0
    for x in A:
        if x > maxL:
            cuts += math.ceil(x / maxL) - 1
    return cuts <= K

lo = 0
hi = max(A)
EPS = 10e-7
while hi - lo > EPS:
    mid = (lo + hi) / 2
    if isPossible(mid):
        hi = mid
    else:
        lo = mid

print(math.ceil(hi))

Measured memory_bytes: 94200
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int
const int MAX = 510000;


using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll x, y;
    cin >> x >> y;
    ll ans = 0;
    while(true){
        if(x * 2 <= y){
            ans ++;
            x = x * 2;
        }
        else break;
    }
    cout << ans + 1<< endl;


}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
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;}
ll powmod(ll a,ll b,ll MOD){ll ans=1ll;while(b){if(b&1)ans=ans*a%MOD;a=a*a%MOD;b>>=1;}return ans;}
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
long long getXor(long long L, long long R)
    {
		if(L==R)
        	return L;
       	else
       	{
       		long long u,ans;
			if(L%2)
			{
				
				ans=L;
				u=L+1;	
				if(R%2)
					ans^=((R-u+1)/2)%2;
				else
				{
					ans^=((R-u)/2)%2;
					ans^=R;
				}
				return ans;
			}   
			else
			{
				ans=0;
				if(R%2)
					ans^=((R-L+1)/2)%2;
				else
				{
					ans^=((R-L)/2)%2;
					ans^=R;
				}
				return ans;
			}
		}
    }
int main()
{
	//    freopen("C:\\Users\\DH_M\\Desktop\\code_io\\in.txt.txt","r",stdin);
	//    freopen("C:\\Users\\DH_M\\Desktop\\code_io\\out.txt.txt","w",stdout);
	gbtb;
	ll l,r;
	cin>>l>>r;
	ll ans=getXor(l,r);
	cout<<ans<<endl;
    return 0;
}

inline void getInt(int* p) {char ch;do {ch = getchar();} 
while (ch == ' ' || ch == '\n');if (ch == '-') {*p = -(getchar() - '0');
while ((ch = getchar()) >= '0' && ch <= '9') {*p = *p * 10 - ch + '0';}}
else {*p = ch - '0';while ((ch = getchar()) >= '0' && ch <= '9') 
{*p = *p * 10 + ch - '0';}}}

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

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;
 
#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;

int main() {
  
  int n,a,b;
  cin >> n;
  
  for ( int i = 0; i < 100; i++){
    for ( int j = 0; j < 100; j++){
      if ( 4 * i + 7 * j == n ){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  
  cout << "No" << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int w, h, n;
  cin >> w >> h >> n;
  vector<int> x(n),y(n),a(n);
  for (int i=0;i<n;i++){
    cin >> x[i] >> y[i] >> a[i];
  }
  int xl=0, xr=w, yd=0, yu=h;
  for(int i=0;i<n;i++){
    if(a[i]==1){
      xl=max(xl,x[i]);
    }
    if(a[i]==2){
      xr=min(xr,x[i]);
    }
    if(a[i]==3){
      yd=max(yd,y[i]);
    }
    if(a[i]==4){
      yu=min(yu,y[i]);
    }
  }
  if(xr>=xl&&yu>=yd){
    cout << (xr-xl)*(yu-yd) << endl;
  }
  else{
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256