akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>  // This will work only for g++ compiler. 

#define int             long long
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >


#define for0(i, n) for (int i = 0; i < (int)(n); ++i) // 0 based indexing
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (int i = (int)(n); i >= 1; --i) // reverse 1 based

//short hand for usual tokens
#define pb push_back
#define fi first
#define se second

// to be used with algorithms that processes a container Eg: find(all(c),42)
#define all(x) (x).begin(), (x).end() //Forward traversal. Now with C++11 auto alleviates the pain.
#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)

// find if a given value is present in a container. Container version. Runs in log(n) for set and map
#define present(c,x) ((c).find(x) != (c).end())

#define rall(x) (x).rbegin, (x).rend() //reverse traversal

// traversal function to avoid long template definition
//find version works for all containers. This is present in std namespace.
#define cpresent(c,x) (find(all(c),x) != (c).end())

// Avoiding wrap around of size()-1 where size is a unsigned int.
#define sz(a) int((a).size())

// mutilple input
#define w(x)            int x; cin>>x; while(x--)


using namespace std;

// Shorthand for commonly used types
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;



//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;



void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	long long a;
	long double b;
	cin>>a>>b;
	long double ans=a*b;
	cout<<(long long) ans<<endl;


	
}

int32_t main()
{
	c_p_c();
	return 0;
}

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

typedef long long LL;

int f(int n) {
    int rs = 0;
    while(n) {
        rs += (n % 10);
        n /= 10;
    }
    return rs;
}

int main() {

    int n, a, b;
    cin >> n >> a >> b;

    LL calc = 0;
    for(int i = 1; i <= n; i++) {
        int rs = f(i);
        if(rs <= b and rs >= a) calc+= i;
    }

    cout << calc << endl;

    return 0;
}

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

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;

#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))

int F()
{
	char ch;
	int x, a;
	while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
	if (ch == '-') ch = getchar(), a = -1;
	else a = 1;
	x = ch - '0';
	while (ch = getchar(), ch >= '0' && ch <= '9')
		x = (x << 1) + (x << 3) + ch - '0';
	return a * x;
}

int N, A, B;

int main()
{
	giii(N, A, B);
	B -= A;
	int64 v = 1LL * (N - 1) * B - B + 1;
	printf("%lld\n", v > 0 ? v : 0LL);
} 

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int total;
		int book;

		total = sc.nextInt();
		while (total != 0) {
			for (int i = 0; i < 9; i++) {
				total -= sc.nextInt();
			}
			System.out.println(total);
			total = sc.nextInt();
		}
	}
}

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

int dp[3030][3030];
int dp_sum[3030][3030];

int main(){
    const int MOD = pow(10,9)+7;
    int N; cin >> N;
    string s; cin >> s;
    dp[1][1]=1; dp_sum[1][0]=0; dp_sum[1][1]=1;
    for(int i=2; i<=N; i++){
        for(int j=1; j<=i; j++){
            if(s.at(i-2)=='>'){
                dp[i][j] =  MOD +dp_sum[i-1][i-1] - dp_sum[i-1][j-1];
                dp[i][j] %= MOD;
            }
            if(s.at(i-2)=='<'){
                dp[i][j]=dp_sum[i-1][j-1];
            }
        }
        for(int j=1; j<=i; j++){
            dp_sum[i][j] = ( dp_sum[i][j-1]+dp[i][j] )%MOD;
        }
    }
    cout << dp_sum[N][N] << endl;
}

Measured memory_bytes: 70656
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
int a[10];
int main(){
	int x;
    in(x);
    a[x]=1;
    in(x);
    a[x]=1;
    for(int i=1;i<=3;i++)if(a[i]!=1){printf("%d\n",i);return 0;}
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int H, W, i, j;
	
	while (1) {
		scanf("%d %d", &H, &W);
		if (H == 0 && W == 0) {
			break;
		}
		
		for (i = 0; i < H; i++) {
			for (j = 0; j < W; j++) {
				if ((i + j) % 2 == 0) {
					printf("#");
				} else {
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 572
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }

void main() {
  auto S = readln.chomp;
  auto L = S.length;

  int distinct_count;
  foreach(i; 0..L/2) {
    if (S[i] != S[L-i-1]) distinct_count++;
  }
  writeln(distinct_count);
}


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

void merge(int arr[], int l, int m, int r){ 
    int i, j, k; 
    int n1 = m - l + 1; 
    int n2 =  r - m;
    int L[n1], R[n2]; 
    for (i = 0; i < n1; i++) 
        L[i] = arr[l + i]; 
    for (j = 0; j < n2; j++) 
        R[j] = arr[m + 1+ j]; 
    i = 0; // Initial index of first subarray 
    j = 0; // Initial index of second subarray 
    k = l; // Initial index of merged subarray 
    while (i < n1 && j < n2){ 
        if (L[i] <= R[j]) { 
            arr[k] = L[i]; 
            i++; 
        } 
        else
        { 
            arr[k] = R[j]; 
            j++; 
        } 
        k++; 
    } 
    while (i < n1){ 
        arr[k] = L[i]; 
        i++; 
        k++; 
    } 
    while (j < n2){ 
        arr[k] = R[j]; 
        j++; 
        k++; 
    } 
} 
void mergeSort(int arr[], int l, int r){ 
	if (l < r) { 
        int m = l+(r-l)/2; 
        mergeSort(arr, l, m); 
        mergeSort(arr, m+1, r); 
        merge(arr, l, m, r); 
    } 
} 
int main(){
	int n,k;
	cin>>n>>k;
	int l;
	int* p;
	p=(int*)malloc(sizeof(int)*n);
	for(int i=0;i<n;i++){
		cin>>l;
		p[i]=l;
	}
	mergeSort(p,0,n-1);
	int min=p[n-1];
	for(int i=0;i<=n-k;i++){
		if(min>p[k-1+i]-p[i])
			min=p[k-1+i]-p[i];
	}
	cout<<min;
	return 0;
}

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

bool is_cyc(string S) {
    string T = S;
    reverse(all(T));
    if (S == T) return true;
    else return false;
}

int main() {
    string S;
    cin >> S;
    int N = S.size();
    int N1 = (N - 1) / 2;
    int N2 = (N + 3) / 2 - 1;

    string S1 = S.substr(0, N1);
    // cout << S1 << endl;
    string S2 = S.substr(N2, N - N2);
    // cout << S2 << endl;
    if (is_cyc(S) && is_cyc(S1) && is_cyc(S2)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

using namespace std;

int main(){
  map<char,int> m;
  string S;
  cin >>S;
  for(int i=0;i<4;i++)
    m[S[i]]++;

  
  if(m[S[0]]==2&&m[S[1]]==2&&m[S[2]]==2&&m[S[3]]==2)
     cout<<"Yes"<<endl;
     else
       cout<<"No"<<endl;


  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define MAX 100000
#define SENTINEL 2000000000
 
struct Card{
    char suit;
    int value;
};
struct Card L[MAX/2+2],R[MAX/2+2];
 
void merge(struct Card A[],int n,int left,int mid,int right){
    int i,j,k;
    int n1=mid-left;
    int n2=right-mid;
    for ( i = 0; i < n1; ++i) {L[i]=A[left+i];   }
    for ( i = 0; i < n2; ++i) {R[i]=A[mid+i];    }
    L[n1].value=R[n2].value=SENTINEL;
    i=j=0;
    for ( k = left; k < right; ++k) {
        if(L[i].value<=R[j].value){
            A[k]=L[i++];
        }else{
            A[k]=R[j++];
        }
    }
}
void mergeSort(struct Card A[],int n,int left,int right){
    int mid;
    if(left+1<right){
        mid=(left+right)/2;
        mergeSort(A,n,left,mid);
        mergeSort(A,n,mid,right);
        merge(A,n,left,mid,right);
    }
}
 
int partition(struct Card A[],int n,int p,int r){
    int i,j;
    struct Card t,x;
    x=A[r];
    i=p-1;
    for ( j = p; j < r; ++j) {
        if(A[j].value<=x.value){
            i++;
            t=A[i];A[i]=A[j];A[j]=t;
        }
    }
    t=A[i+1];A[i+1]=A[r];A[r]=t;
    return i+1;
}
void quickSort(struct Card A[],int n,int p,int r){
    int q;
    if(p<r){
        q=partition(A,n,p,r);
        quickSort(A,n,p,q-1);
        quickSort(A,n,q+1,r);
    }
}
 
int main(){
    int n,i,v;
    struct Card A[MAX],B[MAX];
    char S[10];
    int stable=1;
    scanf("%d",&n);
    for ( i = 0; i < n; ++i) {
        scanf("%s %d",S,&v);
        A[i].suit=B[i].suit=S[0];
        A[i].value=B[i].value=v;
    }
    mergeSort(A,n,0,n);
    quickSort(B,n,0,n-1);
 
    for (i = 0; i < n; ++i) {
        if(A[i].suit!=B[i].suit)stable=0;
    }
    if (stable==1) {printf("Stable\n");
    } else {printf("Not stable\n"); }
    for (i = 0; i < n; ++i) {
        printf("%c %d\n",B[i].suit,B[i].value);
    }
    return 0;
}


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

using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    vector<bool> mid(200010);
    vector<int> a(m), b(m);
    for (int i = 0; i < m; ++i) {
        cin >> a[i] >> b[i];
        if (b[i] == n) mid[a[i]] = true;
    }
    bool possible = false;
    for (int i = 0; i < m; ++i) {
        if (a[i] == 1 && mid[b[i]] == true) {
            possible = true;
            break;
        }
    }
    cout << ((possible) ? "POSSIBLE" : "IMPOSSIBLE") << "\n";
    return 0;
}


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

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define IN freopen("input.txt","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

//using namespace __gnu_pbds;
using namespace std ;

typedef pair<int, int> pi ;
//typedef tree< pi, null_type, less<pi>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const i64 mod = 1000000007LL ;

#define maxn 500005

/*
     *os.find_by_order(k) -> returns the k'th smallest element (indexing starts from 0)
      os.order_of_key(v)  -> returns how many elements are strictly smaller than v
*/

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

    int ans = 0 ;

    for(int i=0 ; i*r<=n ; i++)
    {
        for(int j=0 ; i*r+j*g <=n ; j++ ) if( (n- (i*r+j*g) )%b == 0 ) ans++ ;
    }

    printf("%d\n",ans) ;

    return 0 ;
}


Measured memory_bytes: 256
s1 = []
s2 = []
s3 = []
gets.chomp.chars.each do |ch|
  s1.push ch
end
gets.chomp.chars.each do |ch|
  s2.push ch
end
gets.chomp.chars.each do |ch|
  s3.push ch
end

first_element = s1.shift
answer = ''
while first_element
  if first_element == 'a'
    answer = 'A'
    first_element = s1.shift
  elsif first_element == 'b'
    answer = 'B'
    first_element = s2.shift
  else
    answer = 'C'
    first_element = s3.shift
  end
end
print answer

Measured memory_bytes: 1916
#include <bits/stdc++.h>
//#include <tr1/unordered_map>
//#include"Bignum/bignum.h"
//#define big bignum
#define lowbit(x) (x & -x)
#define debug(x) (cout << "#x = " << (x) << endl)
#define Set(x, i) memset (x, i, sizeof(x))
#define R register
#define For(i, j, k) for(R int i = (j), ED = (k); i <= ED; ++i)
#define Rep(i, j, k) for(R int i = (j), ED = (k); i >= ED; --i)
#define Cross(i, j, k) for(R int i = (j); i; i = (k))
using namespace std;
typedef long long ll;
const ll N = 100011;
const ll INF = 5e16;

namespace IO {

	inline char gc() {
		static char buf[100000], *p1 = buf, *p2 = buf;
		return (p1 == p2) && (p2 = (p1 = buf) +
			fread (buf, 1, 100000, stdin), p1 == p2)? EOF: *p1++;
	}

	#define dd ch = getchar()
	inline ll read() {
		R ll x = 0; R int f = 0; R char dd;
		for (; !isdigit (ch); dd) f ^= (ch == '-');
		for (; isdigit (ch); dd)  x = x * 10 + (ch ^ 48);
		return f? -x: x;
	}
	#undef dd

	inline void write( ll x ) {
		if (x < 0) putchar ('-'), x = -x;
		if (x > 9) write (x / 10); putchar (x % 10 | 48);
	}

	inline void wrn ( ll x ) { write (x); putchar (' '); }

	inline void wln ( ll x ) { write (x); putchar ('\n'); }

	inline void wlnn ( ll x, ll y ) { wrn (x), wln (y); }

}

using IO::wln;
using IO::read;

namespace Cesare {
	
	ll Ans = 0;
	ll n, p[N];
	
	int main() {
		n = read();
		For ( i, 1, n ) p[i] = read();
		For ( i, 2, n - 1 ) 
			if (p[i] > p[i - 1] && p[i] < p[i + 1] || 
				p[i] < p[i - 1] && p[i] > p[i + 1]) ++Ans;
		return wln (Ans), 0;
	}
	
}

int main()
{
	return Cesare::main();
}

/*

*/






Measured memory_bytes: 256
// Ver19.02
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF 1 << 29
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  int h, w;
  char s[101][101];
  int yoko[101];
  int tate[101];
  scanf("%d%d", &h, &w);
  for (int i = 0; i < h; i++)
  {
    scanf("%s", s[i]);
  }
  for (int i = 0; i < h; i++)
  {
    for (int j = 0; j < w; j++)
    {
      if (s[i][j] == '#')
      {
        yoko[i] = 1;
        break;
      }
      else
        yoko[i] = 0;
    }
  }
  for (int j = 0; j < w; j++)
  {
    for (int i = 0; i < h; i++)
    {
      if (s[i][j] == '#')
      {
        tate[j] = 1;
        break;
      }
      else
        tate[j] = 0;
    }
  }
  for (int i = 0; i < h; i++)
  {
    if (yoko[i] == 1)
    {
      for (int j = 0; j < w; j++)
      {
        if (tate[j] == 1)
        {
          putchar(s[i][j]);
        }
      }
      puts("");
    }
  }
  return 0;
}


Measured memory_bytes: 128
import java.util.*;
public class Main {
	
	public static long gcd(long a, long b) {
		return b == 0 ? a: gcd(b, a % b);
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		long B = sc.nextLong();
		long C = gcd(A, B);
		int ans = 1;
		for(int i = 2; i <= Math.sqrt(C); i ++) {
			if(C % i == 0) {
				while(C % i == 0)
					C /= i;
				ans++;
			}
		}
		System.out.println(C > 1 ? ans+1 : ans);

	}

}

Measured memory_bytes: 23764
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>
using namespace std;
#define All(v) (v).begin(),(v).end()
const long long mod = 1000000007;
const long long inf = mod*mod;
const int MAXS = 114514;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
signed main(){
    long long n,x;
    cin>>n>>x;
    vector<long long> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    long long res = 0;
    if(a[0]>=x){
        res+=a[0]-x;
        a[0]=x;
    }
    for(int i=1;i<n;i++){
        long long d1 = a[i]+a[i-1]-x;
        if(d1>0){
            res+=d1;
            a[i]-=d1;
            if(a[i]<0)a[i]=0;
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 1024
MOD = 998244353

def fastExponentiation(a,b,N): # Calculates a^b mod N in log b time
    ans = 1
    bDiv2 = b
    aPow2 = a
    while bDiv2 > 0:
        if bDiv2 % 2 != 0:
            ans *= aPow2
            ans %= N
        bDiv2 //= 2
        aPow2 = aPow2 * aPow2
        aPow2 %= N
    return ans

a,b,c,d = map(int,input().split())
DP = []
for i in range(c-a+1):
    DP.append([])
    for j in range(d-b+1):
        DP[i].append(0)

for i in range(c-a+1):
    partialSum = 0
    if i == 0:
        DP[i][0] = 1
        continue
    for j in range(d-b+1):
        if j == 0:
            DP[i][j] = (DP[i-1][j] * b) % MOD
        else:
            partialSum += DP[i-1][j-1]
            partialSum *= (a + i - 1)
            partialSum %= MOD
            DP[i][j] = (DP[i-1][j] * (j + b) + partialSum) % MOD

ans = 0
for j in range(d-b+1):
    ans = ans + DP[c-a][j] * fastExponentiation(c,d-b-j,MOD)
    ans %= MOD
print(ans)

Measured memory_bytes: 147320
#include <bits/stdc++.h>
 
using namespace std;
 
#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign
 
signed main()
{
    Int(n);
    int2(a, b);
    vi data(n);
    rep(i, n) cin >> data[i];
    int ans = 0;

    Rep(i, n) {
        ans += min(b, a * (data[i] - data[i-1]));
    }
    cout << ans << endl;



    return 0;
}



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

using namespace std;

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;i++)
#define FORVEC(i, v) for(int i = 0;i < v.size();i++)

#define INF 1000000000
#define pb(a) push_back(a)
#define llong long long
#define vi vector<int>
#define P pair<int,int>
#define all(vec) (vec.begin()),(vec.end())

int main(){
	int a,b,c,d,p;
	cin>>a>>b>>c>>d>>p;
	cout<<min(p*a,b+((p<c)?0:d*(p-c)))<<"\n";
	return 0;
}

Measured memory_bytes: 3084
#include <stdio.h>

int main() {
  char s[4];
  scanf("%s", s);
  long x = (long)s[0] * (long)s[1] * (long)s[2];
  long y = (long)'a' * (long)'b' * (long)'c';
  
  if (x == y) printf("Yes\n");
  else printf("No\n");
  
  return 0;
}
  

Measured memory_bytes: 128
#include<iostream>
#include<vector>
using namespace std;
const int N=3400;
vector<int> E[N];
int n,A[N];
int dfs(int x,int fr)
{
    for(auto R:E[x])
        if(R!=fr&&A[x]>A[R]&&!dfs(R,x)) return 1;
    return 0;
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++) cin>>A[i];
    for(int i=1,x,y;i<n;i++) cin>>x>>y,E[x].push_back(y),E[y].push_back(x);
    for(int i=1;i<=n;i++) if(dfs(i,0)) printf("%d ",i);
}


Measured memory_bytes: 512
using System;
using System.Linq;

namespace ABC105.Task01
{
    internal class Task01
    {
        public static void Main(string[] args)
        {
            var line = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var n = line[0];
            var k = line[1];
            var rest = n % k;
            if (rest == 0)
            {
                Console.WriteLine("0");
            } else
            {
                Console.WriteLine("1");
            }
        }
    }
}


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

const int MXN = 3e3 + 20;

long long dp[MXN][MXN];
int n;
vector <long long> a;

long long fill(int i, int j) {
	if (i == j)
		return a[i];
	if (dp[i][j])
		return dp[i][j];
	return dp[i][j] = max(a[i] - fill(i + 1, j), a[j] - fill(i, j -  1));
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int tmp;
		cin >> tmp;
		a.push_back(tmp);
	}
	cout << fill(0, n - 1) << endl;
	return 0;
}


Measured memory_bytes: 70400
# -*- coding: utf-8 -*-
N = int(input())
b = list(map(int, input().split(' ')))

buf = []
for _ in range(N):
    is_end = True
    for i in range(len(b)-1, -1, -1):
        if i+1 == b[i]:
            buf.append(b[i])
            b.pop(i)
            is_end = False
            break

    # 終了条件
    if is_end:
        print(-1)
        exit()

for n in reversed(buf):
    print(n)


Measured memory_bytes: 38512
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
int n,a[N],vis[N],d[N];
LL k;
vector<int>v;
int main() {
  ios::sync_with_stdio(false);
  cin>>n>>k;
  for(int i=1;i<=n;i++){
  	cin>>a[i];
  	d[a[i]]++;
  }
  queue<int>q;
  for(int i=1;i<=n;i++){
  	if(!d[i])q.push(i);
  }
  while(!q.empty()){
  	int x=q.front();
  	vis[x]=1;
  	q.pop();
  	if(--d[a[x]]==0)q.push(a[x]);
  }
  int st=1;
  while(vis[st]){
  	st=a[st];
  	k--;
  	//cout<<st<<' '<<k<<endl;
  	if(!k)return cout<<st,0;
  }
  k++;
  while(!vis[st]){
  	vis[st]=1;
  	v.pb(st);
  	st=a[st];
  }
  int s=v.size();
  k%=s;
  if(k==0)k=s;
  cout<<v[k-1]<<'\n';
 	return 0;
}

Measured memory_bytes: 6680
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

const int mod = 1000000007; // 998244353;
struct mint {
  long long x;
  mint(long long x=0) : x((x%mod+mod)%mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint& a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint& a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint& a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint& a) const {
    return mint(*this) += a;
  }
  mint operator-(const mint& a) const {
    return mint(*this) -= a;
  }
  mint operator*(const mint& a) const {
    return mint(*this) *= a;
  }
  mint pow(long long t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod-2); }
  mint& operator/=(const mint& a) { return *this *= a.inv(); }
  mint operator/(const mint& a) const {
    return mint(*this) /= a;
  }
};
istream& operator>>(istream& is, const mint& a) {
  return is >> a.x;
}
ostream& operator<<(ostream& os, const mint& a) {
  return os << a.x;
}

int main(){
  int n,k;
  cin>>n>>k;
  mint l=0,r=0;
  mint ans=0;
  for(int i=0;i<=n;i++){
    l+=i;
    r+=n-i;
    if(i>=k-1)ans+=r-l+1;
  }
  cout<<ans<<endl;
  return(0);
}


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

using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> sum(n + 1, 0);
    vector<int> sumx(n + 1, 0);
    REP(i, n) {
        cin >> a[i];
        sum[i + 1] = sum[i] + a[i];
        sumx[i + 1] = sumx[i] ^ a[i];
    }
    ll ans = 0;
    int l = 0;
    int r = 0;
    int x = 0;
    while (l < n && r < n) {
        if ((sumx[r + 1] ^ sumx[l]) == sum[r + 1] - sum[l]) {
            ans++;
            r++;
        } else {
            ans += (r - 1) - l;
            l++;
            if (l > r) {
                r = l;
            }
        }
    }
    FOR(i, l + 1, n) ans += (ll)n - i;
    cout << ans << EOL;
}



Measured memory_bytes: 2560
from collections import Counter

n = int(input())
a = [int(x) for x in input().split()]
d = Counter(a)
ans = 0
for i in d.values():
    ans += i * (i-1) // 2
for i in range(n):
    ans_m = ans
    z = a[i]
    zz = d[z]
    ans_m -= zz-1
    print(ans_m)

Measured memory_bytes: 88124
n = int(input())
b = list(map(int, input().split()))


ans = 0
for i in range(n):
    if i == 0:
        ans += b[0]
    elif i == n - 1:
        ans += b[-1]
    else:
        ans += min(b[i-1], b[i])

print(ans)


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

const int N = 1e5 + 5;

int n, m;

vector <int> A, B, IA, IB, fil[10];

vector <int> Inv(vector <int> cxt) {
	vector <int> tmp = cxt;
	for(int i = 0; i < (int) cxt.size(); ++ i)
	tmp[cxt[i]] = i;
	return tmp;
}

vector <int> operator * (vector <int> a, vector <int> b) {
	vector <int> ans; ans.resize(a.size());
	for(int i = 0; i < n; ++ i) {
		ans[i] = a[i];
	}
	for(int i = 0; i < n; ++ i)
	ans[i] = b[ans[i]];
	return ans;
} 

vector <int> Pow(vector <int> x, int y) {
	vector <int> res; res.clear();
	for(int i = 0; i < n; ++ i) res.push_back(i);
	for(; y; y >>= 1, x = x * x) {
		if(y & 1)
		res = res * x;
	}
	return res;
}

int main() {
	cin >> n >> m;
	A.resize(n);  B.resize(n);
	for(int i = 0; i < n; ++ i) scanf("%d", &A[i]), -- A[i];
	for(int i = 0; i < n; ++ i) scanf("%d", &B[i]), -- B[i];
	int now = (m - 1) / 6; m -= now * 6;
	IA = Inv(A), IB = Inv(B);
	vector <int> k1 = A * IB * IA * B, k2 = Inv(k1);
	swap(k1, k2);
	k1 = Pow(k1, now); k2 = Pow(k2, now);
	fil[1] = k1 * A * k2;
	fil[2] = k1 * B * k2;
	for(int i = 3; i <= m; ++ i) {
		fil[i].resize(n);
		for(int j = 0; j < n; ++ j)
		fil[i][fil[i - 2][j]] = fil[i - 1][j];
	}
	for(int j = 0; j < n; ++ j) {
		printf("%d ", fil[m][j] + 1);
	}
}

Measured memory_bytes: 5480
// Problem : D - Alter Altar
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long
#define db double
#define mod 1000000007
#define pb push_back
#define pp pair<int,int>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define maxn 200005
#define ss second
#define ff first
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
int inv(int a, int b){
 return 1<a ? b - inv(b%a,a)*b/a : 1;
}
void solve()
{
	int n;
	cin >> n;
	string str;
	cin >> str;
	int st=0;
	rep(i,0,n)
		if(str[i] == 'R')
			st++;
	int cnt=0;
	rep(i,0,n)
	{
		if(str[i] == 'R' and i >= st)
		cnt++;
	}
	cout << cnt;
}
signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 3748
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }    

    static void Write(object obj) {
#if DEBUG
        Debug.Write(obj.ToString());
#else
        Console.Write(obj.ToString());
#endif
    }
    static void WriteLine(object obj) {
#if DEBUG
        Debug.WriteLine(obj.ToString());
#else
        Console.WriteLine(obj.ToString());
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());
        var aa = new int[n];
        var bb = new int[n];

        var ab = new List<Bar>[n];

        for (int i = 0; i < n; i++)
            ab[i] = new List<Bar>();

        for(int i=0; i<n-1; i++) {
            var spl   = input.ReadLine().Split(' ');
            var a     = int.Parse(spl[0]) -1;
            var b     = int.Parse(spl[1]) -1;

            ab[a].Add(new Bar(i, b));
            ab[b].Add(new Bar(i, a));
        }

        var k = ab.Max(x => x.Count());
        WriteLine(k);

        var colors = new int[n-1];

        Paint(ab, colors, 0, -1, -1);

        foreach(var co in colors) {
            WriteLine(co);
        }

        return null;
    }

    static void Paint(List<Bar>[] ab, int[] colors, int p, int from, int fromColor) {

        int color = 1;

        for (int i=0; i<ab[p].Count; i++) {
            var ba = ab[p][i];

            if (ba.to == from) continue;

            if (color == fromColor) color++;

            colors[ba.no] = color;
            Paint(ab, colors, ba.to, p, color);

            color++;
        }
    }

    class Bar
    {
        public int no;
        public int to;

        public Bar(int no, int to) {
            this.no = no;
            this.to = to;
        }
    }
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define cinv(n,vec) V vec(n);for(auto&v:vec)cin>>v;
#define int long long
#define itn int
#define pb push_back
#define m_p make_pair
#define m_t meke_tuple
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a));reverse(all(a))
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define SZ(a) (ll)(a.size())
#define ENDL cout<<endl
#define debg(a) cout<<#a<<" "<<a<<endl;
#define debgp(a) cout<<#a<<" "<<a.fi<<" : "<<a.se<<endl
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define show(a) rep(ghf,SZ(a)){rep(kjh,SZ(a[ghf])){cout<<(a[ghf][kjh]<10?" ":"")<<a[ghf][kjh]<<" ";}ENDL;}
#define out(a) cout<<(a)<<endl
#define fi first
#define se second
#define Vec vector
#define P pair
#define VV(type,name,y,x,a) vector<vector<type>> name = vector<vector<type>>(y,vector<type>(x,a))
typedef long long ll;
typedef double D;
typedef long double LD;
typedef string str;
typedef vector<ll> V;
typedef pair<ll,ll> Pi;
typedef vector<Pi> VP;
const long long INF = 1LL<<60;
const long long MOD = 1e9+7;
void Yes(){cout<<"Yes"<<endl;}
void No(){cout<<"No"<<endl;}
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

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

  double n,k;
  cin>>n>>k;

  long double ans=0.0;
  for(LD i=1.0;i<=n;i+=1.0){
    long double res=1/n;
    long double x=(long double)i,cnt=0;
    while(k>x){
      x*=2.0;
      cnt+=1.0;
    }
    res*=pow(1.0/2.0,cnt);
    ans+=res;
  }
  cout<<fixed<<setprecision(10)<<ans<<endl;
  
  return 0;
}



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

int N, A[300000];

int main(){
    cin >> N;
    for(int i=0;i<3*N;i++)    cin >> A[i];
    
    sort(A, A+3*N, greater<int>());

    int64_t ans = 0;
    for(int i=1;i<N*2;i+=2)  ans += A[i];

    cout << ans << endl;
}

Measured memory_bytes: 1408
#include<stdio.h>
#define NUM 200

int main(void)
{
  int m,n_min,n_max,i,gap=0,new_gap,num;
  int p[NUM];

  while(1)
  {
    gap = 0;

    scanf("%d",&m);
    scanf("%d",&n_min);
    scanf("%d",&n_max);

    if(m==0&&n_min==0&&n_max==0)
    {
      break;
    }

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

    for(i=n_min;i<=n_max;i++)
    {
      new_gap = p[i-1] - p[i];
      if(gap<=new_gap)
      {
        gap = new_gap;
        num = i;
      }
    }
    printf("%d\n",num);
  }
  return 0;
}



Measured memory_bytes: 2048
n=int(input())
k=0
i=0
while k<=n:
	k+=26**i
	i+=1
p=i-1
r=[]
k-=26**(i-1)
n-=k
for i in range(p):
	r.append(n%26)
	n//=26
ans=""
for x in r:
	ans+=chr(ord("a")+x)
print(ans[::-1])


Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向
const int MAX_N = 101;
const int MAX_V = 100100;

ll N;
ll W;
ll w[MAX_N],v[MAX_N];
ll dp[MAX_N][MAX_V];

void input(){
    cin >> N >> W;
    for(int i=0;i<N;i++) cin >> w[i] >> v[i];
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    for(int i=0;i<MAX_N;i++)for(int j=0;j<MAX_V;j++) dp[i][j] = INF+9;
    dp[0][0] = 0;
    for(int i=0;i<N;i++){
        for(int sum_v=0;sum_v<MAX_V;sum_v++){
            if(sum_v - v[i] >= 0) chmin(dp[i+1][sum_v], dp[i][sum_v - v[i]] + w[i]);
            chmin(dp[i+1][sum_v], dp[i][sum_v]);
        }
    }
    ll ans = 0;
    for(int sum_v=0;sum_v<MAX_V;sum_v++){
        if(dp[N][sum_v] <= W) ans = sum_v;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 79360
using System;

namespace AtCoder.ABC094
{
    class c
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Trim();
            var N = int.Parse(line);
            line = Console.ReadLine().Trim();
            var spl = line.Split(' ');
            var X = Array.ConvertAll(spl, new Converter<string, int>(s=>int.Parse(s)));
            int[] Z = new int[N];
            X.CopyTo(Z,0);
            Array.Sort(Z);
            var min = Z[N / 2 - 1];
            var max = Z[N / 2];
            for (var i = 0; i < N; ++i)
            {
                if (X[i] <= min) Console.WriteLine(max);
                else Console.WriteLine(min);
            }
        }
    }
}


Measured memory_bytes: 34248
/* Aditya0412 */
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
#define pb push_back 
//#define pop pop_back
#define mp make_pair
#define ve vector
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpl vector < pll >
#define fi first
#define sz size 
#define len length 
#define se second 
//const ll mod=998244353;
const ll mod = 1000000000+7;
const ll N=1000000+6;
#define M_PI           3.14159265358979323846 
string ans[N];
vector< string > v[10];
   vector< string > vv[10];
ll x=1;
int main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //  #ifndef ONLINE_JUDGE
    //   freopen ("INPUT.txt" , "r" , stdin);
    //   freopen ("OUTPUT.txt", "w" , stdout);
    // #endif 
   
   
   
   for(int i=0;i<10;i++)
   {
    char cc='0'+i;
    string c(1,cc);

  //  cout<<c<<'\n';
    v[i].pb(c);
   // cout<<v[i][0]<<'\n';
    if(v[i][0][0]!='0')
    {
      ans[x]=""+v[i][0];
      x++;
    }
   }
   // for(int i=1;i<=5;i++)
   //  cout<<ans[i]<<'\n';
   while(x<=100005)
   {
    for(int i=0;i<10;i++)
    {
      int j=i-1;
      if(j>=0)
      {
        for(int k=0;k<v[j].size();k++)
        {  
          string temp(1,'0'+i);
           temp=temp+v[j][k];  
          vv[i].pb(temp);
          if(vv[i][vv[i].size()-1][0]!='0')
          {
            ans[x]=vv[i][vv[i].size()-1];
            x++;
          }
        }
      }
      j=i;
      for(int k=0;k<v[j].size();k++)
        {
          string temp(1,'0'+i);
           temp=temp+v[j][k];  
          vv[i].pb(temp);
          if(vv[i][vv[i].size()-1][0]!='0')
          {
            ans[x]=vv[i][vv[i].size()-1];
            x++;
          }
        }
        j=i+1;
        if(j<=9)
        {
          for(int k=0;k<v[j].size();k++)
        {
          string temp(1,'0'+i);
           temp=temp+v[j][k];  
          vv[i].pb(temp);
          if(vv[i][vv[i].size()-1][0]!='0')
          {
            ans[x]=vv[i][vv[i].size()-1];
            x++;
          }
        }
        }

    }
    for(int i=0;i<10;i++)
      v[i].clear();
    for(int i=0;i<10;i++)
    {
      for(int j=0;j<vv[i].size();j++)
      {
        v[i].pb(vv[i][j]);
      }
      vv[i].clear();
    }

   }
   //cout<<"here haha\n";
   // for(int i=1;i<=150;i++)
   //  cout<<ans[i]<<'\n';
   int k;
   cin>>k;
   cout<<ans[k];
}

Measured memory_bytes: 28796
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define INF 1e9

using ll = long long;
const ll mod = LLONG_MAX;

int N,T,ans;
int t[200010];
int main(){
  cin>>N>>T;
  for(int i=0;i<N;i++){
    cin>>t[i];
  }

  for(int i=0;i<N;i++){
    int temp=t[i];
    int j=i;
    while(1){
      if(temp+T>t[j+1] && j<N-1){
        j++;
      }else{
        break;
      }
    }
    ans+=t[j]-temp;
    if(t[j]==temp){
      ans+=T;
    }else{
      i=j-1;
    }


    //if(i==N-1)ans+=T;
    //cout<<"i="<<i<<endl;

    //cout<<"ans="<<ans<<endl;
  }
cout<<ans<<endl;



}


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

int main(void)
{
    ll x, y;
    cin >> x >> y;

    ll x_ = abs(x);
    ll x_s = (x < 0) ? -1 : 1;
    ll y_ = abs(y);
    ll y_s = (y <= 0) ? -1 : 1;

    ll inc = y_ - x_;

    ll pushCnt = abs(inc);

    if (x_s * y_s < 0)
    {
        pushCnt++;
    }
    else
    {
        if (inc > 0)
        {
            if (x_s == -1)
                pushCnt += 2;
        }
        else if(inc < 0)
        {
            if (x_s == 1)
                pushCnt += 2;
        }
    }
    
    cout << pushCnt << endl;

    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (k+k)
#define sag (k+k+1)
#define orta ((bas+son)/2)
#define coc g[node][i]
#define mod 1000000007
#define inf 1000000009
#define N 1000005
using namespace std;
 
typedef long long ll;
typedef pair < int , int > ii;

int n,a[N],dp[N];

int main() 
{	
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> a[i];

	sort(a,a+n);

	cout << abs(a[n/2-1] - a[n/2]);	

	return 0;
}

Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {
    public static Scanner sc;
    public static void main(String[] args) throws Exception {
        sc = new Scanner(System.in);
        int n = sc.nextInt();
        int res = 0;
        for (int i = 0; i < n; i++) {
            int num = sc.nextInt();
            if (num == 2 || num == 3) {
                res++;
                continue;
            }
            boolean b = true;
            for (int j = 2; j*j <= num; j++) {
                if (num%j == 0) {
                    b = false;
                    break;
                }
            }
            if (b) res++;
        }
        System.out.println(res);
    }
}

Measured memory_bytes: 42456
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N, T = map(int, readline().split())
    ans = INF

    for _ in range(N):
        c, t = map(int, readline().split())
        if t <= T:
            ans = min(ans, c)

    if ans == INF:
        print("TLE")
    else:
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 62088
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = new Info[N + 1];

            for (int i = 1; i <= N; i++)
            {
                A[i] = new Info();
                var m = int.Parse(Console.ReadLine());

                for (int _ = 0; _ < m; _++)
                {
                    var xy = Console.ReadLine().Split().Select(int.Parse).ToArray();

                    if (xy[1] == 1) A[i].TruePersonList.Add(xy[0]);
                    else A[i].FalsePersonList.Add(xy[0]);
                }
            }

            Console.WriteLine(Max(1, N, A, new bool[N + 1]));
        }

        static int Max(int i, int N, Info[] A, bool[] bArray)
        {
            if (i > N)
            {
                var trueList = new List<int>();
                var falseList = new List<int>();

                for (int j = 1; j <= N; j++)
                {
                    if (bArray[j])
                    {
                        trueList.AddRange(A[j].TruePersonList);
                        falseList.AddRange(A[j].FalsePersonList);
                    }
                }

                if (trueList.All(s => bArray[s]) && falseList.All(s => !bArray[s])) return bArray.Count(s => s);
                else return 0;
            }

            var trueMax = Max(i + 1, N, A, Set(bArray, i, true));
            var falseMax = Max(i + 1, N, A, Set(bArray, i, false));
            return Math.Max(trueMax, falseMax);
        }

        static bool[] Set(bool[] bArray, int i, bool b)
        {
            var ret = new bool[bArray.Length];
            Array.Copy(bArray, ret, bArray.Length);
            ret[i] = b;
            return ret;
        }

        class Info
        {
            public List<int> TruePersonList { get; set; }
            public List<int> FalsePersonList { get; set; }
            public Info()
            {
                TruePersonList = new List<int>();
                FalsePersonList = new List<int>();
            }
        }
    }
}

Measured memory_bytes: 17804
#include <cstdio>
#include <algorithm>

using namespace std;

int main(){
    int k;
    int num[3];
    scanf("%d%d%d",&num[0],&num[1],&num[2]);
    scanf("%d",&k);
    sort(num,num+3);
    for(int i=0; i<k; i++){
        num[2] = num[2] * 2;
    }
    printf("%d\n",num[0]+num[1]+num[2]);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    unsigned long long int a,b;
    cin>>a>>b;
    if(a<6) cout<<"0"<<endl;
    else if((a>5) && (a<13)) cout<<b/2<<endl;
    else cout<<b<<endl;
    return 0;
}


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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	vector<ll> a(n+1), b(n);
	for (int i=0; i<n+1; i++)
		cin>>a[i];
	for (int i=0; i<n; i++)
		cin>>b[i];
	ll ret=0;
	for (int i=0; i<n; i++) {
		ll cur=min(a[i],b[i]);
		a[i]-=cur;
		b[i]-=cur;
		ret+=cur;
		cur=min(a[i+1],b[i]);
		a[i+1]-=cur;
		b[i]-=cur;
		ret+=cur;
	}
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 1792
N,H,W=map(int,input().split())
kekka=[]
count=0
for i in range(N):
    a,b=map(int,input().split())
    kekka.append(a)
    kekka.append(b)
for i in range(len(kekka)//2):
    if H<=kekka[i*2]:
        if W<=kekka[i*2+1]:
            count+=1
print(count)
    

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

int main(){
	int N, M, X, Y;
	std::cin>>N>>M>>X>>Y;
	std::vector<int> Ns;
	for(int i = 0; i < N;++i){
		int a;
		std::cin>>a;
		Ns.push_back(a);
	}
	
	std::vector<int> Ms;
	for(int i = 0; i < M;++i){
		int a;
		std::cin>>a;
		Ms.push_back(a);
	}

	for(int i = X  + 1;i < Y;++i){
		bool ok{true};
		int ii;
		for( ii = 0; ii < N;++ii){
			if(Ns[ii] >= i){
				
				ok = false;
				}
			
			
		}
		for( ii = 0; ii < M;++ii){
			if(Ms[ii] < i){
				
				ok = false;
				}
		}
			
	
		if(ok){
		
			std::cout<<"No War";
			return 0;
		}
		
	}
	std::cout<<"War";
			return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
  int N, X;
  cin >> N >> X;
  vector<int> m(N);
  int count = 0;
  for(int i = 0; i < N; i++){
    cin >> m.at(i);
    X -= m.at(i);
    count = N;
  }
  sort(m.begin(),m.end());
  while(X - m.at(0) >= 0){
    X -= m.at(0);
    count++;
  }
  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        long A = sc.nextLong(), B = sc.nextLong();

                        long ans = (long)1e11;
                        if (A <= B) {
                                ans = Math.min(ans, B - A);
                        }
                        A *= -1;
                        if (A <= B) {
                                ans = Math.min(ans, B - A + 1);
                        }
                        B *= -1;
                        if (A <= B) {
                                ans = Math.min(ans, B - A + 2);
                        }
                        A *= -1;
                        if (A <= B) {
                                ans = Math.min(ans, B - A + 1);
                        }
                        System.out.println(ans);
                }
        }
}

Measured memory_bytes: 9808
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
using namespace std;
#define LL long long 
#define LD long double
LL n,k,r,s,p;
char str[100005];
LL dp[100005][3];//0 拳 1剪刀 2 布 
int main()
{
	cin>>n>>k>>r>>s>>p;
	cin>>str+1;
	for(int i=1;i<=n;i++)
	{
		int now=max(i-k,0ll);
		dp[i][2]+=max(dp[now][1],dp[now][0]);
		dp[i][0]+=max(dp[now][1],dp[now][2]);
		dp[i][1]+=max(dp[now][2],dp[now][0]);
		if(str[i]=='r')dp[i][2]+=p;
		else if(str[i]=='s')dp[i][0]+=r;
		else if(str[i]=='p')dp[i][1]+=s;
	}
	LL ans=0;
	for(int i=n-k+1;i<=n;i++)
	{
	//	cout<<i<<" "<<dp[i][0]<<" "<<dp[i][1]<<" "<<dp[i][2]<<endl;
		ans=(ans+max(max(dp[i][0],dp[i][1]),dp[i][2]));
	}	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2688
import java.util.*;

public class Main {
  public static void main(String[] args) {
          Scanner sc = new Scanner(System.in);
          int num1 = sc.nextInt();
          int num2 = sc.nextInt();
          int num3 = sc.nextInt();
          if(num1 + num2 + num3 >= 22){
            System.out.println("bust");
          } else {
            System.out.println("win");
          }
      }
    }


Measured memory_bytes: 23636