akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
using namespace std;
typedef long long ll;

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

  vector<vector<int>> s(m);
  vector<int> k(m);

  rep (i, m) {
    cin >> k[i];
    rep (j, k[i]) {
      int tmp_s;
      cin >> tmp_s;
      tmp_s--;
      s[i].push_back(tmp_s);
    }
  }
  vector<int> p(m);
  rep (i, m) cin >> p[i];

  int ans = 0;

  for (int bit = 0; bit < (1 << n); bit++) {
    vector<int> switchOnNum(m, 0);
    for (int i = 0; i < n; i++) {
      if (bit & (1 << i)) {

        for (int j = 0; j < m; j++) {
          auto res = find(s[j].begin(), s[j].end(), i);
          if (res != s[j].end()) switchOnNum[j]++;
        }

      }
    }

    bool ok = true;
    for (int j = 0; j < m; j++) {
      if (switchOnNum[j] % 2 != p[j]) ok = false;
    }
    if (ok) ans++;
    
  }
  cout << ans << endl;
  return 0;
}


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

int main () {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	long long n,k;
	long long a ;
	cin >> n >> k;
	if (n%k == 0) cout << '0';
	else {
		a = min(n%k, k - n%k);
		cout << a;
	}

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
 if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};        
int main(){
  string s;
  cin>>s;
  if(sz(s)==2&&s[0]==s[1]){
    cout<<1<<" "<<2<<endl;
    return 0;
  }
  rep(i,sz(s)-2){
    set<char> d;
    rep(j,3){
      d.insert(s[i+j]);
    }
    if(sz(d)<=2){
      rep(j,3){
        if(j==1)continue;
        cout<<i+j+1<<" ";
      }
      return 0;
    }
  }
  cout<<-1<<" "<<-1<<endl;
}


Measured memory_bytes: 512
import java.util.*;
public class Main {
  Scanner sc = new Scanner(System.in);
  int n, u, k, v;
  int[][] A;
  int[] d;
  int[] f;
  int[] c;
  int time;

  public static void main(String[] args){ 
    Main main = new Main();
    main.in();
    main.dfs();
    main.out();
  }
public void dfs(){
  for(int i = 0;i < u;i++){
    c[i] = 0;
  }
  time = 0;
    for(int i = 0;i < n;i++){
      if(c[i] == 0){
        visit(i);
      }
    }
}
public void visit(int i){
  c[i] = -1;
  d[i] = ++time;
  for(int j = 0;j < n;j++){
    if(c[j] == 0 && A[i][j] == 1){
      visit(j);
    }  
  }
  c[i] = 1;
  f[i] = ++time;
}
public void in(){
  n = sc.nextInt();
  A = new int[n][n];
  d = new int[n];
  f = new int[n];
  c = new int[n];
  for(int i = 0;i < n;i++){
    u = sc.nextInt();
    k = sc.nextInt();
    for(int j = 0;j < k;j++){
      v = sc.nextInt();
      A[u - 1][v - 1] = 1;
    }
    }
}
public void out(){
  for(int i = 0;i < n;i++){
    System.out.println(i + 1 +" "+d[i]+" "+f[i]);
  }
 }
}



Measured memory_bytes: 28680
///////////////////// author : TrEbLeCleF /////////////////////
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<pii> vpii;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define For(i, a) for (int i=0; i<(a); i++)
#define FORR(i,a,b) for (int i = (b)-1; i >= a; i--)
#define Forr(i,a) for (int i = (a)-1; i >= 0; i--)
/////////////////////////// DEBUG ///////////////////////////
#define deb(...) cerr << "[" << #__VA_ARGS__ << "] : [", DBG(__VA_ARGS__) 
void DBG() { cerr << "]\n";}
template<typename T, typename ...Args> void DBG(T first, Args... args){
cerr << first; if(sizeof...(args))cerr<<", "; DBG(args...); }
/////////////////////////// DEBUG ///////////////////////////
#define pb(x) push_back(x)
#define print(v,s,e) for(int i = s; i < e; i++)cout << v[i]<<" ";cout<<"\n";
#define INF 1e17
#define PI 3.14159265358979323846 
int del_x[4] = {-1, 1, 0, 0};
int del_y[4] = {0, 0, 1, -1};
int XX[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int YY[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
/////////////////////////// GLOBAL ///////////////////////////
const int mod = 1e9+7;
int mul(int x,int y){
	int res = x*y;
	if(res >= mod)res%=mod;
	return res;
}
int add(int x, int y){
	int res = x+y;
	if(res >= mod)res-=mod;
	return res;
}
int sub(int x, int y){
	int res = x-y;
	if(res<0)res+=mod;
	return res;
}
int power(int x, int y){
	int res = 1;
	while(y){
		if(y&1)res = mul(res,x);
		y = y>>1;
		x = mul(x,x);
	}
	return res;
}

/////////////////////////// GLOBAL ///////////////////////////
void solve(){
	int n,m;
	cin >> n >> m;
	char matrix[n][m];
	For(i,n)For(j,m)cin >> matrix[i][j];
	int dp[n+1][m+1];
	memset(dp,0,sizeof(dp));
	dp[0][0]=1;
	For(i,n){
		if(matrix[i][0]!='#')dp[i][0]=1;
		else break;
	}
	For(j,m){
		if(matrix[0][j]!='#')dp[0][j]=1;
		else break;
	}
	For(i,n){
		For(j,m){
			if(matrix[i+1][j+1]!='#')
			dp[i+1][j+1] = add(dp[i+1][j],dp[i][j+1]);
		}
	}
	cout << dp[n-1][m-1] <<"\n";
}

int32_t main(){ 
	#ifndef ONLINE_JUDGE
		clock_t tStart = clock();
		freopen("TC", "r", stdin);
		//freopen("output.txt","w",stdout);
	#endif 
    ios_base:: sync_with_stdio(false); 
   	cin.tie(0); 
	int t=1;
	//cin >> t;
	for(int tt=1;tt<=t;tt++){
		//cout << "Case #"<<tt<<": ";
		solve();
	}
	#ifndef ONLINE_JUDGE
    	cerr << "\nRun Time -> "<<(double)(clock()-tStart)/CLOCKS_PER_SEC <<" sec\n";
    #endif
}

Measured memory_bytes: 8544
S=input()
T=input()

#当てはまるかのフラグ
f=False

#順に当てはまるか見ていけばいい
#当てはまったら当てはまった場所をTで置き換え、それ以外の?をaで置き換える？

ns = len(S)
nt = len(T)
correspond=-1
index=ns-nt
answer=-1

while(1):
    correspond=1
    if index<0:break


    
    if nt > ns : break
    if (ns-index) < nt:break

    for i in range(index,nt+index):
        if S[i]=='?':
            continue
        elif S[i]!=T[i-index]:
            correspond=-1
            break

    if correspond==1 :    
        f=True
        answer=index
        # print(answer)
        break

    index-=1
    


if f==False:
    print('UNRESTORABLE')

if f==True:
    if ns==nt:
        answer_word=T
    else:
        if answer==0:
            answer_word=T+S[nt:]
        elif ns-answer==nt:
            answer_word=S[:answer]+T
        else:
            answer_word=S[:answer]+T+S[(nt+answer):]

    while(answer_word.count('?')>=1):
        answer_word=answer_word.replace('?','a')
        # break

    print(answer_word)


Measured memory_bytes: 3064
/* << IN THE NAME OF GOD >> */
#include <bits/stdc++.h>
using namespace std;



#define err(x) cerr << #x  << " = "<<  x << '\n'
#define out(x) cout << x << '\n'
#define forp(i, r, l) for(int i = int(r); i < int(l); i++)
#define forn(i, r, l) for(int i = int(r); i > int(l); i--)
#define FAST ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll ,ll> pll;
const int maxn = 5e5 + 120;


int main(){FAST;   
int a ,b;
cin >> a >> b;
    a % b == 0 ? cout << 0 : cout << 1;

return 0;
}
 










Measured memory_bytes: 256
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

K, T = list(map(int, sys.stdin.readline().split()))
A = list(map(int, sys.stdin.readline().split()))


def argmax(except_i=None):
    m = 0
    ret = -1
    for i, a in enumerate(A):
        if a > m and i != except_i:
            ret = i
            m = a
    return ret


prev = argmax()
A[prev] -= 1

ans = 0
for _ in range(K - 1):
    i = argmax(prev)
    if i < 0:
        ans += 1
        A[prev] -= 1
    else:
        A[i] -= 1
        prev = i
print(ans)


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

string S;
int K;

int dp[105][4][2];

int main() {
    cin >> S;
    int N = S.size();
    cin >> K;

    dp[0][0][0] = 1;

    // i 何桁目まで
    // j 非ゼロの数 0 ~ 3
    // k 一致したかどうか 
    // 0: N と一致
    // 1: N 以下が確定
    rep(i, N)rep(j, 4)rep(k, 2) {
        int nd = S[i] - '0';

        // 遷移
        rep(d, 10) {
            int ni = i + 1, nj = j, nk = k;
            if (d != 0) nj++;
            if (nj > K) continue;
            if (k == 0) {
                if (d > nd) continue;
                if (d < nd) nk = 1;
            }
            dp[ni][nj][nk] += dp[i][j][k];
        }
    }

    int ans = dp[N][K][0] + dp[N][K][1];
    cout << ans << endl;
}

Measured memory_bytes: 256
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()
	n := readInt()
	k := readInt()
	val := 1
	for i := 1; i <= n; i++ {
		if val <= k {
			val *= 2
		} else {
			val += k
		}
	}
	println(val)
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 58) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


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

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

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}


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

  int bit[500000] = {};
  for(int i = 0; i < N; i++) {
    bit[i] = S[i] - 'a';
    bit[i] = 1 << bit[i];
  }

  for(int i = 0; i < Q; i++) {
    int t;
    cin >> t;
    if(t == 1) {
      int k;
      char c;
      cin >> k >> c;
      --k;
      bit[k] = c - 'a';
      bit[k] = 1 << bit[k];
    } else {
      int l, r;
      cin >> l >> r;
      --l;
      int tap = 0;
      for(int k = l; k < r; k++) tap |= bit[k];
      cout << __builtin_popcount(tap) << endl;
    }
  }
}



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


#define int long long int
#define ff first
#define ss second
#define pb push_back

#define N 1010

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int a, b;
    cin >> a >> b;
    cout << ((a < 10 && b < 10) ? a * b : -1 );
    return 0;	
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <deque>
#include <tuple>
#include <unordered_set>

using namespace std;
using ld = long double;
using ll = long long;

int main()
{
    int a;
    cin >> a;
    cout << a + a*a + a*a*a;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
const int DN=3005;
int n,m,dp[DN][DN],pr[2][DN][DN];
string s,t;
void solve(int n,int m)
{
	if(n==0&&m==0)
		return;
	solve(pr[0][n][m],pr[1][n][m]);
	if(pr[0][n][m]==n-1&&pr[1][n][m]==m-1)
		cout<<s[n];
}
int main()
{
    cin>>s>>t;
    n=s.size();
    m=t.size();
    s=" "+s;
    t=" "+t;
    for(int i=0;i<=n;i++)
    	for(int j=0;j<=m;j++)
    	{
    		if(i==0&&j==0)
    			continue;
    		if(i)
    		{
    			dp[i][j]=dp[i-1][j];
    			pr[0][i][j]=i-1;
    			pr[1][i][j]=j;
    		}
    		if(j&&dp[i][j-1]>dp[i][j])
    		{
    			dp[i][j]=max(dp[i][j],dp[i][j-1]);
    			pr[0][i][j]=i;
    			pr[1][i][j]=j-1;
    		}
    		if(s[i]==t[j]&&1+dp[i-1][j-1]>dp[i][j])
    		{
    			dp[i][j]=max(dp[i][j],1+dp[i-1][j-1]);
    			pr[0][i][j]=i-1;
    			pr[1][i][j]=j-1;
    		}
    	}
    solve(n,m);
}


Measured memory_bytes: 106368
from heapq import heappush, heappop
inf = float('inf')
def dijkstra(graph:list, node:int, start:int) -> list:
    dist = [inf]*node

    dist[start] = 0
    heap = [(0,start)]
    while heap:
        cost,thisNode = heappop(heap)
        for NextCost,NextNode in graph[thisNode]:
            dist_cand = dist[thisNode]+NextCost
            if dist_cand < dist[NextNode]:
                dist[NextNode] = dist_cand
                heappush(heap,(dist[NextNode],NextNode))
    return dist

N,M,S = map(int,input().split())
graph = [[] for i in range(2501*N)]
for i in range(M):
    u,v,a,b = map(int,input().split())
    u -= 1
    v -= 1
    for s in range(a,2501):
        graph[2501*u+s].append([b,2501*v+s-a])
        graph[2501*v+s].append([b,2501*u+s-a])

for i in range(N):
    c,d = map(int,input().split())
    for s in range(2500):
        graph[2501*i+s].append([d,2501*i+min(2500,s+c)])

dist = dijkstra(graph,2501*N,min(2500,S))

ans = [inf]*N
for i in range(N):
    for s in range(2501):
        ans[i] = min(ans[i],dist[2501*i+s])

for i in range(1,N):
    print(ans[i])

Measured memory_bytes: 151816
#include<cstdio>
#include<cstring>
#include<iostream>
#include<queue>
#include<map>
#define ll long long
using namespace std;
int main()
{
	ll n;
	scanf("%lld", &n);
	ll x = n - 1;
	ll max;
	max = x + x * (x - 1) / 2;
	printf("%lld", max);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
 
typedef long long ll;
typedef pair<int, int> ii;

#define EPS 1e-8

int main(){

	vector<double> hold;
	double v  = 0;
	int i = 0;
	while(v < 300.0){
		int y = i * 5;
		double t = sqrt(y / 4.9);
		double tmp = 9.8 * t;
		hold.push_back(tmp);
		i++;
		v = tmp;
	}
	
	while(cin >> v){
		rep(i, hold.size()){
			if(v < hold[i]){
				cout << i + 1 << endl;
				break;
			}
		}
		
	}
	return 0;
}

Measured memory_bytes: 3128
#include<stdio.h>

int main(void){
    int n, m, c;
    scanf("%d%d", &n, &m);
    int a[n][m], b[m];
    for(int i=0; i<m; i++){
        for(int l=0; l<n; l++) a[l][i] = 0;
        b[i] = 0;
    }
    for(int i=0; i<n; i++) for(int l=0; l<m; l++) scanf("%d", &a[i][l]);
    for(int i=0; i<m; i++) scanf("%d", &b[i]);
    for(int i=0; i<n; i++){
        c = 0;
        for(int l=0; l<m; l++) c += a[i][l] * b[l];
        printf("%d\n", c);
    }
    return 0;
}


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

int main() {
	char input;
 	cin >> input;
 	string cstr(1, input);
 	if(isupper(input)) {
 		cout << 'A' << endl;
 	}
 	if (islower(input)) {
 		cout << 'a' << endl;
 	}
	return 0;
}


Measured memory_bytes: 3596
import sys
from io import StringIO
import unittest


def resolve():
    tak_hp, tak_ak, ao_hp, ao_ak = map(int, input().split())

    for i in range(9999999999999):
        ao_hp -= tak_ak
        if ao_hp <= 0:
            print("Yes")
            return
        tak_hp -= ao_ak
        if tak_hp <= 0:
            print("No")
            return



class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """10 9 10 10"""
        output = """No"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """46 4 40 5"""
        output = """Yes"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()


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

int main() {
  ll ma=pow(10,3),x;
  cin>>x;
  for(ll a=ma*(-1); a<ma; a++){
    for(ll b=ma*(-1); b<ma; b++){
      ll A=a*a*a*a*a, B=b*b*b*b*b;
      if(A-B==x){
        cout<<a<<" "<<b<<endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 3640
if __name__ == "__main__":
    S = input()
    T = input()
    
    result = 999999
    for i in range(len(S)-len(T)+1):
        to_change = 0
        for j in range(len(T)):
            if T[j] != S[i+j]:
                to_change += 1
        result = min(result,to_change)

    print(result)

Measured memory_bytes: 9096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define fs first
#define sc second
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<tuple<ll,ll>> vtl;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

void solve(){
    //abc96c
    int h,w;
    cin>>h>>w;
    char board[60][60];
    rep1(i,h){
      rep1(j,w){
        cin>>board[i][j];
      }
    }
    int dx[]={1,0,-1,0};
    int dy[]={0,1,0,-1};
    bool f=0;
    int cnt=0;
    rep1(i,h){
        rep1(j,w){
            if (board[i][j] == '#' && board[i][j - 1] != '#' && board[i - 1][j] != '#' && board[i][j + 1] != '#' && board[i + 1][j] != '#') cnt++;
        }
    }
    if(h==1&&w==1&&board[1][1]=='#'){
        cout<<"Yes"<<endl;
        return;
    }
    cout<<(cnt==0?"Yes":"No")<<endl;
}

int main(){
    cout<<std::fixed<<std::setprecision(10);
    ios::sync_with_stdio(false);
    cin.tie(0);
    solve();
}

Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;


int main(){
    int n,m,s;
    cin>>n>>m;
    vector<int> A(m,0);
    for(int i=0;i<m;i++){
        int k;
        cin>>k;
        for(int j=0;j<k;j++){
            cin>>s;
            A[i]|=1<<(s-1);
        }
    }
    int x=0;
    for(int i=0;i<m;i++){
        cin>>s;
        x|=s<<i;
    }
    int ans=0;
    for(int i=0;i<1<<n;i++){
        bool ok=true;
        for(int j=0;j<m;j++){
            if(__builtin_popcount(i&A[j])%2!=(x>>j&1)){ok=false;}
        }
        if(ok){ans++;}
    }
    cout<<ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    for(int i=0; ;i++){
        int x,y;
        cin >> x>>y;
        if(x==0 && y==0)break;
        if(x>y)swap(x,y);
        cout << x<<" "<<y<<endl;
            }
}


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int main(void){
	int N,ans=0,max1=0,H1;
  	cin>>N;
  for(int i=0;i<N;i++){
    cin>>H1;
  	if(max1<=H1){ans++;max1=H1;}
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if(a<=5){
    cout<<0;
  }
  else if(a>=13){
    cout<<b;
  }
  else {
    cout<<b/2;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    if (s == u) cout << a - 1 << ' ' << b;
    else cout << a << ' ' << b - 1;
}


Measured memory_bytes: 3548
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int p = scn.nextInt();
		System.out.println((p/1000==(p%1000)/100 || (p%1000)/100 == (p%100)/10 || (p%100)/10 == p%10)?"Bad":"Good");
	}

}

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

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

int main() {
  char a;

  cin >> a;
  if (a > 96) cout << 'a' << endl;
  else cout << 'A' << endl;
  return 0;
}


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

using namespace std;

typedef long long LL;
#define N 120000

LL n,ans,a[N];
map<LL,LL> f;
map<LL,bool> vis;

LL calc(LL x){
	LL ret=1;
	for (LL i=2;i*i*i<=x;++i){
		LL k=0; for (;x%i==0;x/=i,++k); k%=3;
		ret=ret*(k>0?i:1)*(k>1?i:1);
	}
	ret=ret*x;
	return ret;
}

LL icalc(LL x){
	LL ret=1;
	for (LL i=2;i*i*i<=x;++i){
		LL k=0; for (;x%i==0;x/=i,++k); k%=3;
		ret=ret*(k>0?i:1)*(k==1?i:1);
	}
	LL t=sqrt(x);
	if (t*t<x) ++t; if (t*t>x) --t;
	if (t*t==x) ret=ret*t; else ret=ret*x*x;
	return ret;
}

int main(){
	scanf("%lld",&n);
	for (LL i=1;i<=n;++i){
		scanf("%lld",a+i);
		LL t=calc(a[i]);
		if (t==1) ans=1; else ++f[t];
	}
	for (LL i=1;i<=n;++i){
		LL t=calc(a[i]);
		if (t==1||vis[t]) continue;
		LL tt=icalc(a[i]);
		vis[t]=vis[tt]=1;
		ans+=max(f[t],f[tt]);
	}
	printf("%lld\n",ans);
	
	return 0;
}
			

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

using namespace std;

void solve(){
  int mini = 1e6;
  int n;
  cin >> n;
  int cnt = 0;
  for(int i = 0; i < n; i++){
    int x;
    cin >> x;
    if(x <= mini){
      cnt ++;
      mini = min(mini , x);
    }
  }
  cout << cnt << endl;
}

int main(){
  
  solve();

}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ll long long
#define newl "\n"
#define rep(a, b, c, i) for (int i = a; i < b; i += c)
#define ff first
#define ss second

using namespace std;

class MakingTriangle{
public:
	int ways(vector<ll> &a){
		if (a.size() < 3) return 0;
		sort(a.begin(), a.end());
		int c = 0;
		rep(0, a.size(), 1, i){
			rep(i + 1, a.size(), 1, j){
				rep(j + 1, a.size(), 1, k){
					if (a[i] + a[j] > a[k] && (a[i] != a[j] && a[j] != a[k])) c++;
				}
			}
		}
		return c;
	}
};

int main(){
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(0, n, 1, i){
		cin >> a[i];
	}
	MakingTriangle mtrg;
	cout << mtrg.ways(a) << newl;
}


Measured memory_bytes: 3604
/*
     riirr                                                        rLir                         BBBr
    rBBBBB                                                        tBBP                         PBMr
    aBBbBBZ        rLtstT      Tltstr     rslsi     rLir YsTr    rkBBDLss    rTsLsr       rLlLihBbr
   rBBy UBBr     tBBBBBBBD  rHBBBBBBBr  CBBHHDBBh   FBBBBBBBBBL  mBBBBBBBr  hBbhHBBBC   iBBBBBBMBDr
   DBh   bBD    XBBm     r rBBBi    r  ZBBtrriHBBa  YBBs   rbBBr  rBMy     BBMrrrtBBBr vBBHr   mBbr
  UBBBBBBBBBF   MBB        vBBa        BBBDHBMDmHi  YBBv    EBBr  TBBy    lBBMDbBbHPE  yBBT    EBDr
 rBBPTvliyBBBr  XBBS     r rBBMr    r  hBBr         iBBL   iBBBr  yBBa    rBBb         tBBa    kBMr
rBBBr     CBBBr  tBBBBBBBD  rDBBBBBBBr  yBBBBBBBBt  YBBbBBBBBkr   rBBBBBBr rhBBBBBBBBr  ZBBBBBMBBBr
rsTr       rYsr    rsytyL      Tsytyr     rstttyr   vBByrTlLr       rTsSs     Ytttts      vssv rvi
                                                    CBBC
                                                     rr                                             */
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <queue>
#include <cstdio>
#include <map>
#include <set>
#include <utility>
#include <stack>
#include <cstring>
#include <cmath>
#include <vector>
#include <ctime>
#include <ostream>
using namespace std;
typedef long long ll;
#define pb push_back
#define scand(n) scanf("%d",&n)
#define scandd(n,m) scanf("%d%d",&n,&m)
#define scanlld(n) scanf("%lld",&n)
#define scanlldd(n,m) scanf("%lld%lld",&n,&m)
#define scans(str) scanf("%s",str)
#define ans() printf("%d",ans)
#define ansn() printf("%d\n",ans)
#define anss() printf("%d ",ans)
#define llans() printf("%lld",ans)
#define llanss() printf("%lld ",ans)
#define llansn() printf("%lld\n",ans)
#define REP(i,n) for(int i=0;i<(n);++i)
#define mst(abc,bca) memset(abc,bca,sizeof abc)

const int mod = 1000000007;
int a[100005],b[100005];
int main()
{
#ifdef LOCAL
    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
#endif // LOCAL

    int n;
    scand(n);
    REP(i,n)
    {
        scandd(a[i],b[i]);
    }
    ll ans=0;
    for(int i=n-1;i>=0;--i)
    {
        if((a[i]+ans)%b[i]==0)continue;
        ans+=b[i]-(a[i]+ans)%b[i];
    }
    llans();
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#define lli long long int
#define uli unsigned long long int
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
using namespace std;
int main(){
  int n;
  cin>>n;
  if(n<=999)ou("ABC");
  else ou("ABD");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long  int
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)

void solve()
{
    ll n;
    cin>>n;
    ll arr[n],i;
    for(i=0;i<n;i++)
    {
    	cin>>arr[i];
    }
    ll ans=0;
    ll dp[n];
    dp[0]=0;
    dp[1]=abs(arr[1]-arr[0]);
    for(i=2;i<n;i++)
    {
        dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
    }
    cout<<dp[n-1];
}
int main()
{
    fast();
      solve();
    return 0;
}


Measured memory_bytes: 5188
n = int(input())
list_a = list(map(int,input().split()))

list_a.sort()

for m in range(n - 1):
    new = 0
    new += (list_a[0] + list_a[1]) / 2
    del list_a[0:2]
    list_a.append(new)
    list_a.sort()

print(list_a[0])


Measured memory_bytes: 3060
n = int(input())
def make_prime_list_2(num):
    if num < 2:
        return []

    # 0のものは素数じゃないとする
    prime_list = [i for i in range(num + 1)]
    prime_list[1] = 0 # 1は素数ではない
    num_sqrt = math.sqrt(num)

    for prime in prime_list:
        if prime == 0:
            continue
        if prime > num_sqrt:
            break

        for non_prime in range(2 * prime, num, prime):
            prime_list[non_prime] = 0

    return [prime for prime in prime_list if prime != 0]
import math
def search_divisor_num_1(num):
    if num < 0:
        return None
    elif num == 1:
        return 1
    else:
        num_sqrt = math.floor(math.sqrt(num))
        prime_list = make_prime_list_2(num_sqrt)

        divisor_num = 1
        for prime in prime_list:
            count = 1
            while num % prime == 0:
                num //= prime
                count += 1
            divisor_num *= count

        if num != 1:
            divisor_num *= 2

        return divisor_num
count = 0
for i in range(1,n+1):
    if (search_divisor_num_1(i) == 8) and (i % 2 != 0):
        count += 1
print(count)

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

int main () {
  int H, N, cnt;
  cin >> H >> N;
  cnt = 0;
  vector<int> damage(N);
  for( int i = 0; i < N; i++ ) {
    cin >> damage.at(i);
    cnt = cnt + damage.at(i);
  }
  if ( H > cnt ) {
    cout << "No";
  }
  else {
    cout << "Yes";
  }
}

Measured memory_bytes: 768
#include <stdio.h>

int main(void)
{
  int n, x;
  int i;
  int count = 1;
  int d = 0;

  scanf("%d %d", &n, &x);

  int l[n];

  for(i = 0; i < n; i++){
    scanf("%d", &l[i]);
    d = d + l[i];
    if(d <= x){
      count += 1;
    }
  }
  printf("%d\n", count);

  return 0;
}


Measured memory_bytes: 128
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ;; $n:expr) => {
        (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
    };
}

fn pow_mod(mut n: usize, mut t: usize, p: usize) -> usize {
    let mut r = 1;
    while t > 0 {
        if t%2 == 1 {
            r = (r * n) % p;
        }
        n = n * n % p;
        t /= 2;
    }
    return r;
}

fn main() {
    let n = get!(usize);
    let mut aa = get!(String).split_whitespace().map(|a| a.parse::<i32>().unwrap()).collect::<Vec<_>>();
    aa.sort();
    let mut x = 0;
    let mut i = 0;
    if n%2 == 1 {
        if aa[i] != 0 {
            println!("{}", 0);
            return;
        }
        i = 1;
    } else {
        x = -1;
    }
    while i < n {
        x += 2;
        if aa[i] != x || aa[i+1] != x {
            println!("{}", 0);
            return;
        }
        i += 2;
    }

    println!("{}", pow_mod(2usize, n/2, 10usize.pow(9) + 7usize));
}

Measured memory_bytes: 4476
#include <iostream>
#include <cstdint>
#include <cmath>
#include <numeric>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <algorithm>
#include <iomanip>
#include <sstream>

int main(void)
{
    int64_t X, Y;
    std::cin >> X >> Y;

    if (X % Y == 0) {
        std::cout << -1 << std::endl;
        return 0;
    }

    int64_t i = 1;
    int64_t ans = 0;
    while (true) {
        i++;
        ans = X * i;
        if (ans % Y != 0) break;
    }

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

    return 0;
}


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

const int N = 2010;

int n, sum, x;

bitset<N * N> s;

int main()
{
	scanf("%d", &n);
	s[0] = 1;
	for(int i = 1; i <= n; i++)
		scanf("%d", &x), s = s | (s << x), sum += x;
	sum = (sum + 1) / 2;
	for(int i = 1; i < N * N; i++)
		if(s[i] && i >= sum) { printf("%d", i); return 0; }
	return 0;
}

Measured memory_bytes: 2304
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <limits.h>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <string>
using namespace std;
#define ll long long
string s[105],ss;
int n,m;
map<string,int> mp;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>s[i];
        mp[s[i]] += 1;
    }
    cin>>m;
    while(m--){
        cin>>ss;
        mp[ss] -= 1;

    }
    int ans = 0;
    for(int i=1;i<=n;i++){
        ans = max(ans , mp[s[i]]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int a,b,c;

    scanf("%d %d %d",&a,&b,&c);

    if(a==b && b!=c){
        printf("Yes");
    }else if(c==b && b!=a){
        printf("Yes");
    }else if(c==a && b!=a){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}

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

#define ll long long
#define rep(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define MOD (ll)(1e9+7)

ll moddiv(ll a,ll b){
    a %= MOD;
    b %= MOD;
    for(ll m=MOD-2;m>0;m/=2){
        if(m&1){
            a=a*b%MOD;
        }
        b=b*b%MOD;
    }
    return a;
}

ll N, K;
ll A[202020];
pll Abs[202020];
ll i, j, k,ans;

int main(){
    scanf("%lld%lld", &N,&K);

    j = 0;
    rep(i,0,N){
        scanf("%lld", &A[i]);
        if(A[i]>0){
            ++j;
        }
        Abs[i] = {abs(A[i]), A[i]};
    }
    sort(Abs, Abs + N);
    ans = 1;

    if(N==K){
        rep(i,0,N){
            (ans *= MOD+A[i]) %= MOD;
        }
        printf("%lld\n", ans);
        return 0;
    }

    if(j==0){
        if(K%2==0)
            reverse(Abs, Abs + N);
        rep(i,0,K){
            (ans *= MOD + Abs[i].second) %= MOD;
        }
        printf("%lld\n", ans);
        return 0;
    }

    reverse(Abs, Abs + N);

    ll a = -1, b = -1, c = -1, d = -1;
    rep(i,0,N){
        ll aa = Abs[i].second;
        if(i<K){
            if(aa>0){
                if(a!=-1)
                    (ans *= Abs[a].second) %= MOD;
                a = i;
            }else{
                if(b!=-1){
                    (ans *= Abs[b].second * aa % MOD) %= MOD;
                    b = -1;
                }else{
                    b = i;
                }
            }
        }else{
            if(aa>0){
                if(c==-1)
                c = i;
            }else{
                if(d==-1)
                d = i;
            }
        }
    }
    if(b==-1){
        if(a!=-1)
            (ans *= Abs[a].second) %= MOD;
    }else if(a==-1){
        if(c!=-1)
            (ans *= Abs[c].second) %= MOD;
    }else{
        ll aa = 0;
        if(a!=-1&&c!=-1&&aa<Abs[a].second*Abs[c].second){
            aa = Abs[a].second * Abs[c].second;
        }
        if(b!=-1&&d!=-1&&aa<Abs[b].second*Abs[d].second){
            aa = Abs[b].second * Abs[d].second;
        }
        (ans *= aa%MOD) %= MOD;
    }
    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 8520
N = int(input())
A = list(map(int, input().split()))
m = {}
for a in A:
    m.setdefault(a-1, 0)
    m.setdefault(a, 0)
    m.setdefault(a+1, 0)
    m[a-1] += 1
    m[a] += 1
    m[a+1] += 1

max_num = 0
for n in m.values():
    if n > max_num:
        max_num = n
print(max_num)


Measured memory_bytes: 18752
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aryssoncf
 */



// Taken from: https://github.com/bqi343/USACO/blob/master/Implementations/content/contest/templateShort.cpp

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ull> vul;
typedef vector<ll> vl;
typedef vector<pii> vpii;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i,0,a)
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i, a) ROF(i,0,a)
#define trav(a, x) for (auto& a: x)

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

#define mp make_pair
#define pb push_back
#define f first
#define s second

const int MOD = 1e9 + 7; // 998244353; // = (119<<23)+1
const int MX = 2e5 + 5;

template<class T>
bool ckmin(T &a, const T &b) {
    return a > b ? a = b, 1 : 0;
}

template<class T>
bool ckmax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

mt19937 rng((uint32_t) chrono::steady_clock::now().time_since_epoch().count());


//
// Created by aryssoncf on 28/10/2019.
//

#include <type_traits>


#include <iterator>
#include <utility>

template<typename T>
constexpr auto hasBegin(int) -> decltype(std::begin(std::declval<T>()), true) {
    return true;
}

constexpr bool hasBegin(...) {
    return false;
}

template<typename T>
using IsContainer = std::integral_constant<bool, hasBegin<T>(0)>;


#ifndef JHELPER_EXAMPLE_PROJECT_IO_HPP
#define JHELPER_EXAMPLE_PROJECT_IO_HPP

#endif //JHELPER_EXAMPLE_PROJECT_IO_HPP

template<typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &vec) {
    for (T &element: vec) {
        is >> element;
    }
    return is;
}

template<typename T, typename U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
    is >> p.first;
    is >> p.second;
    return is;
}

template<class X, class Y>
std::ostream &operator<<(std::ostream &os, std::pair<X, Y> const &p) {
    return os << p.first << " " << p.second;
}

template<class Ch, class Tr, class Container>
std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, Container const &x) {
    bool first = true;
    for (auto &y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

using namespace std;

class CDivideTheProblems {
public:
    void solve(std::istream &in, std::ostream &out) {
        int n;
        in >> n;
        vi D(n);
        in >> D;
        sort(all(D));
        int res = D[n / 2] - D[n / 2 - 1];
        out << res << '\n';
    }

    void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
    CDivideTheProblems solver;
    solver.setup();
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3748
#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 2e9
using namespace std;
typedef long long ll;

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

  switch (n % 10) {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      cout << "hon" << endl;
      break;
    case 0:
    case 1:
    case 6:
    case 8:
      cout << "pon" << endl;
      break;
    default:
      cout << "bon" << endl;
  }

  return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <cstring>
char s[100050];
int fail;
int maxlen;
const char str[4][10]={"eraser ","erase ","dreamer ","dream "};
const int len[4]={6,5,7,5};
bool dfs(int pos)
{
	if(pos==maxlen) return 1;
	for(int i=3;i>=0;i--)
	{
		bool flag=1;
		for(int j=0;str[i][j]!=' ';j++)
			if(pos+j>=maxlen || str[i][j]!=s[pos+j])
			{flag=0;break;}
		if(flag)
		{
			if(dfs(pos+len[i])) return 1;
		}
	}
	return 0;
}
int main()
{
	scanf("%s",s);
	maxlen=strlen(s);
	bool ans=dfs(0);
	if(ans) puts("YES");
	else puts("NO");
}


Measured memory_bytes: 1024
n = int(input())
mod0 = set()
mod1 = set()

for i in range(1, int(n**0.5)+1):
    if n%i==0:
        mod0.add(i)
        mod0.add(n//i)
    if (n-1)%i==0:
        mod1.add(i)
        mod1.add((n-1)//i)
mod0.remove(1)
mod1.remove(1)
ans = 0
for i in mod0:
    nn = n
    while nn%i==0:
        nn//=i
    if nn%i==1:
        ans += 1
ans += len(mod1)
print(ans)

Measured memory_bytes: 3828
#include<iostream>
using namespace std;
int main() {
	int c1, c5, c10, c50, c100, c500;
	cin >> c1 >> c5 >> c10 >> c50 >> c100 >> c500;
	int a = c1 + c5 * 5 + c10 * 10 + c50 * 50 + c100 * 100 + c500 * 500;
	if (a / 1000 >= 1) {
		cout << "1" << endl;
	}
	else {
		cout << "0" << endl;
	}
	return 0;
}

Measured memory_bytes: 3100
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


ll dp[2020][2020];
int a[2020];
int N, Z, W;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	cin >> N >> Z >> W;
	for (int i = 1; i <= N; i++)cin >> a[i];

	for (int i = N; i >= 0; i--) {
		for (int j = N; j >= 0; j--) {
			if (i == j)continue;
			if (i == N || j == N){
				int temp1 = (i == 0) ? Z : a[i];
				int temp2 = (j == 0) ? W : a[j];
				dp[i][j] = abs(temp1 - temp2);
			}
			else if (i > j) {
				if (i == j + 1) {
					dp[i][j] = 5e9;
					for (int k = i + 1; k <= N; k++)dp[i][j] = min(dp[i][j], dp[i][k]);
				}
				else dp[i][j] = dp[i][j+1];
			}
			else {
				if (j == i + 1) {
					dp[i][j] = -5e9;
					for (int k = j + 1; k <= N; k++)dp[i][j] = max(dp[i][j], dp[k][j]);
				}
				else dp[i][j] = dp[i+1][j];
			}
		}
	}
	
	ll ans = 0;
	for (int i = 1; i <= N; i++)ans = max(ans, dp[i][0]);
	puts(ans);

	return 0;
}

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

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

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

void gen_sosuu(int sosuu[]){
  REP(i,100010){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(100000)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<=100000;j++){
      //printf("%d %d %d\n",i*j,i,j);
      sosuu[i*j] =false;
    }
  }
}

int w,a,b;

int main(){
  scanf("%d %d %d",&w,&a,&b);
  if(abs(a-b) <w){
    printf("0\n");
  }else{
    printf("%d\n",min(abs(a+w-b),abs(b+w-a)));
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int A[5]={0};
int main(){
	int T;
	cin>>T;
	while(T--){
		string s;
		cin>>s;
		if(s=="AC")A[0]++;
		else if(s=="WA")A[1]++;
		else if(s=="TLE")A[2]++;
		else if(s=="RE")A[3]++;
	}	
	printf("AC x %d\n",A[0]);
	printf("WA x %d\n",A[1]);
	printf("TLE x %d\n",A[2]);
	printf("RE x %d\n",A[3]);
	return 0;
}


Measured memory_bytes: 3728
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

s=get_nsp
q=gets.to_i
temp=0
q.times do
  que=get
  t=que[0].to_i
  case t
  when 1 then
    temp=(temp+1)%2
  when 2 then
    f=(temp+que[1].to_i)%2
    c=que[2]
    if f==1
      s.unshift(c)
    else
      s.push(c)
    end
  end
end
if temp==1
  s.reverse!
end
puts s.join("")

Measured memory_bytes: 28796
n,m = map(int,input().split())
base = [input() for _ in range(n)]
tmp = [input() for _ in range(m)]
count = 0
flg = False

for i in range(n - m + 1):
    for j in range(n - m + 1):
        for k in range(m):
            if base[i + k][j:j+m] == tmp[k]:
                count += 1
            else:
                break
        if count == m:
            flg = True
            break
        else:
            count = 0
if flg:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
using namespace std;
#define EPS (1e-10)

const char *Class(double w)
{
#define judgeit(lim, name) { if (w < lim + EPS) return name; }
  judgeit(48.00, "light fly");
  judgeit(51.00, "fly");
  judgeit(54.00, "bantam");
  judgeit(57.00, "feather");
  judgeit(60.00, "light");
  judgeit(64.00, "light welter");
  judgeit(69.00, "welter");
  judgeit(75.00, "light middle");
  judgeit(81.00, "middle");
  judgeit(91.00, "light heavy");
  return "heavy";
}

int main(int argc, char **argv)
{
  double weight;
  while (cin>>weight) {
    cout << Class(weight) << endl;
  }
  return 0;
}

Measured memory_bytes: 1228
n, x = map(int, input().split())
l = [0] + list(map(int, input().split()))
d = 0
i = 0
while True:
    if d > x:
        print(i - 1)
        break
    if i == n + 1:
        print(i)
        break
    i += 1
    d += l[i-1]


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define gc getchar
#define int long long
const int N=1e6+5;
int n,m,k,ans,a[N],b[N];
char s[N];
//char buf[1<<21],*p1=buf,*p2=buf;
//inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
inline int read()
{
    int ret=0,f=0;char c=gc();
    while(!isdigit(c)){if(c=='-')f=1;c=gc();}
    while(isdigit(c)){ret=ret*10+c-48;c=gc();}
    if(f)return -ret;return ret;
}
signed main()
{
	n=read();
	int A=n/500;
	ans+=1000*A;
	n-=A*500;
	A=n/5;
	ans+=5*A;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256