akhauriyash/Code-Regression huggingface dataset:
##### UnionFind #####
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

(n, m), *q = [list(map(int, o.split())) for o in open(0)]
c = 0
for i in range(m):
    UF = UnionFind(n)
    for j, (a, b) in enumerate(q):
        if i == j:continue
        UF.union(a - 1, b - 1)
    if UF.group_count() > 1:
        c += 1
print(c)

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


void dfs(ll remain,ll t){
    // cerr <<"remain=" << remain<<"t="<<t << endl;
    if(remain==0){
        //出力
        sort(ans.rbegin(),ans.rend());
        int maxV =ans[0];
        int t=0;
        for(int i=maxV;i>=0;--i){
            if(t<ans.size()&&ans[t] == i){
                t++;
                cout << 1;
            }else{
                cout <<0;
            }
        }
        cout <<endl;
        return;
    }
    if(abs(remain)%2 != 0){
        ans.push_back(t);
        t++;
        if(t %2 ==1){
            dfs((remain-1)/2,t);
        }else{
            dfs((remain+1)/2,t);
        }
    }else{
        t++;
        dfs(remain/2,t);
    }
}

int main() {
    cin >> N;
    if(N==0){
        cout << 0 << endl;
        return 0;
    }
    
    dfs(N,0);


    return 0;
}

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

int main(void){
    int N,M;
    cin>>N>>M;
    int cnt[M];
    int ans=0;

    for(int i=0;i<M;i++)
        cnt[i]=0;

    for(int i=0;i<N;i++){
        int K;
        cin>>K;
        for(int j=0;j<K;j++){
            int A;
            cin>>A;
            cnt[A-1]++;
        }
    }

    for(int i=0;i<M;i++){
        if(cnt[i]==N)
            ans++;
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func solve(str string) string {
	var memo [100]int
	for _, c := range str {
		memo[int(c-'a')] += 1
	}
	for _, cnt := range memo {
		if cnt%2 != 0 {
			return "No"
		}
	}

	return "Yes"
}

func main() {
	var str string

	fmt.Scan(&str)

	fmt.Println(solve(str))
}


Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <functional>
#include <stack>
#include <utility>
#include <map>
#include <queue>
#include <set>
#include <climits>

using namespace std;

typedef long long ll;
const ll MOD = 1000000007;

ll n, m, ans;

ll f(ll x) {
	ll res = 1;
	while (x > 1) {
		res *= x;
		res %= MOD;
		x--;
	}
	return res%MOD;
}

int main() {
	cin >> n >> m;
	if (abs(n - m) > 1)ans = 0;
	else {
		ans = f(n)*f(m) % MOD;
		if (n == m)ans *= 2;
	}
	cout << ans%MOD << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){

    int m,n,l,i,j,k;
    scanf("%d%d%d",&n,&m,&l);

    int a[101][101]={};
    int b[101][101]={};
    long mult[101][101]={};

    //配列の読み込み
    for(i = 0; i < n; i++){
        for(j = 0; j < m; j++){
            scanf("%d",&a[i][j]);
        }
    }
    for(i = 0; i < m; i++){
        for(j = 0; j < l; j++){
            scanf("%d",&b[i][j]);
        }
    }

    //配列の掛け算計算
    for(i=0; i<n; i++){
        for(j=0; j<l; j++){
            for(k=0; k<m; k++){
                mult[i][j] += a[i][k]*b[k][j];
            }
        }
    }


    for(i=0; i<n; i++){
        for(j=0; j<l; j++){
            printf("%ld",mult[i][j]);
            if(j == l-1) putchar('\n');
            else putchar(' ');
        }
    }

    return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
using namespace std;
typedef long long ll;
typedef long double ld;
const double EPS = 1e-9;
const int N = 1e3+2, M = 3e5+5, OO = 0x3f3f3f3f;
// int dx[] = {1,-1,0,0} , dy[] = {0,0,1,-1}; // 4 Direction
// int dx[] = {1,-1,0,0,1,1,-1,-1}, dy[] = {0,0,1,-1,1,-1,1,-1}; // 8 Direction
// int dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1}; // Knight Direction
// int dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1}; // Hexagonal Direction
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
  int r;
	cin>>r;
	double cir;
	cir = 2 * PI * r;
	cout << fixed << setprecision(2) << cir<<endl;
	return 0;

}


Measured memory_bytes: 3792
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <sstream>
#include <iostream>
#include <time.h>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <string.h>
#include <bitset>
#define sf scanf
#define pf printf
#define lf double
#define p123 printf("123\n");
#define pn printf("\n");
#define pk printf(" ");
#define p(n) printf("%d",n);
#define pln(n) printf("%d\n",n);
#define s(n) scanf("%d",&n);
#define ss(n) scanf("%s",n);
#define ps(n) printf("%s",n);
#define sld(n) scanf("%lld",&n);
#define pld(n) printf("%lld",n);
#define slf(n) scanf("%lf",&n);
#define plf(n) printf("%lf",n);
#define sc(n) scanf("%c",&n);
#define pc(n) printf("%c",n);
#define gc getchar();
#define ll long long
#define re(n,a) memset(n,a,sizeof(n));
#define len(a) strlen(a)
#define eps 1e-7
#define zero(x) (((x) > 0? (x):(-x)) < eps)
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <sstream>
#include <iostream>
#include <time.h>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <string.h>
#include <bitset>

using namespace std;
//https://codeforces.com/contest/1238/problems
//https://codeforces.com/contest/1238/submit

int main(){
    int n;
    string a;
    cin >> a;
    if(a == "SUN"){
        cout << 7<<endl;
    }else if(a == "MON"){
        cout << 6<<endl;
    }else if(a == "TUE"){
        cout << 5<<endl;
    }else if(a == "WED"){
        cout << 4<<endl;
    }else if(a == "THU"){
        cout << 3<<endl;
    }else if(a == "FRI"){
        cout << 2<<endl;
    }else if(a == "SAT"){
        cout << 1<<endl;
    }




    return 0;
}


Measured memory_bytes: 764
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        JSushi solver = new JSushi();
        solver.solve(1, in, out);
        out.close();
    }

    static class JSushi {
        double[][][] dp;
        int n;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            n = in.nextInt();
            int a = 0;
            int b = 0;
            int c = 0;
            for (int i = 0; i < n; i++) {
                int x = in.nextInt();
                if (x == 1) a++;
                if (x == 2) b++;
                if (x == 3) c++;
            }
            dp = new double[n + 1][n + 1][n + 1];
            boolean[][][] used = new boolean[n + 1][n + 1][n + 1];
            for (int i = 0; i <= n; i++) {
                for (int j = 0; j <= n; j++) {
                    for (int k = 0; k <= n; k++) {
                        dp[i][j][k] = 0;
                    }
                }
            }

            out.println(f(a, b, c));
        }

        double f(int a, int b, int c) {
            if (dp[a][b][c] > 0) {
                return dp[a][b][c];
            }

            if (a == 0 && b == 0 && c == 0) {
                return 0;
            }
            double N = n;
            double sum = a + b + c;
            double res = N / sum;

            if (a > 0) res += (double) a / sum * f(a - 1, b, c);
            if (b > 0) res += (double) b / sum * f(a + 1, b - 1, c);
            if (c > 0) res += (double) c / sum * f(a, b + 1, c - 1);

            return dp[a][b][c] = res;
        }

    }
}



Measured memory_bytes: 306824
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();

		sc.close();

		out.println(Math.max(0, C - (A - B)));

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
}


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

int main() {
  char c ;
  bool s = false;
  string str = "aiueo";
  cin >> c;
  for (int i = 0; i < str.size(); i++) {
    if (str.at(i) == c) {
      cout << "vowel" << endl;
      s = true;
      break;
    }
  }
  if (s == false)
    cout << "consonant" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[3001];
long long f[3001][3001];
int main()
{
	int i,j,n;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(n%2==0)
			f[i][i]=-a[i];
		else
			f[i][i]=a[i];
	}
	for(j=1;j<=n;j++)
	{
		for(i=1;i+j<=n;i++)
		{
			if(j%2!=n%2)
				f[i][i+j]=max(a[i]+f[i+1][i+j],f[i][i+j-1]+a[i+j]);
			else 
				f[i][i+j]=min(f[i][i+j-1]-a[i+j],f[i+1][i+j]-a[i]);
		}
	}
	printf("%lld",f[1][n]);	
	return 0;
}

Measured memory_bytes: 70016
#include<iostream>
#include<iomanip>
#include<sstream>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<numeric>
#include<complex>

using namespace std ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define np string::npos
#define X real()
#define Y imag()
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define repc(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto n :(array))

typedef long long ll ;
typedef deque<int> di ;
typedef deque<ll> dl ;
typedef map<string,int> dict;
typedef complex<double> comd;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
const double PI = atan(1.0) * 4 ;
double eps = 1e-10 ;

template <typename T>
void out(deque < T > d)
{
  for(size_t i = 0; i < d.size(); i++)
  {
    debug(d[i]);
  }
}

template<typename T>
T ston(string str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

double CalcDist(comd p1, comd p2){
  return sqrt(pow(p1.X - p2.X,2.0) + pow(p1.Y -p2.Y,2.0));
}

double CalcArea(comd p1,comd p2, comd p3){
  double a,b,c,z;
  a = CalcDist(p1,p2);
  b = CalcDist(p2,p3);
  c = CalcDist(p3,p1);
  z = (a+b+c)/2;
  return sqrt(z*(z-a)*(z-b)*(z-c)) ;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  double x,y,s = 0;
  char c;
  deque<comd> ps;
  while(cin >> x >> c >>y){
   ps.pb(comd(x,y)) ;
  }
  rep(i,ps.size()-2){
    s += CalcArea(ps[0],ps[i+1],ps[i+2]) ;
  }
  fcout(6) << s << endl;
  return 0;
}

Measured memory_bytes: 3256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,k = inpl()
a = inpl()
ln = max(len(bin(max(a))), len(bin(k))) - 2
c = [0] * ln
res = 0
for x in a:
    for i in range(ln):
        c[i] += (x>>i)%2
# print(c)
for i in range(ln)[::-1]:
    if c[i] < (n+1)//2:
        # print(i)
        now = pow(2,i)
        if res + now <= k:
            res += now
ans = 0
for x in a:
    ans += res^x
print(ans)

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

int main() {
	string s,t,k="No";
	cin >> s >> t;
	int ss = s.size();
	for(int i = 0;i < ss;i++)
	{
		if(s == t)
		{
			k = "Yes";
			break;
		}
		s = s.at(ss-1) + s.substr(0,ss-1);
	}
    cout << k << endl;
	return 0;
}


Measured memory_bytes: 256
from collections import Counter

s = input()

for i in range(len(s) - 1):
    if s[i] == s[i + 1]:
        print(i + 1, i + 2)
        exit()
for i in range(len(s) - 2):
    if s[i] == s[i + 2]:
        print(i + 1, i + 3)
        exit()
print(-1, -1)


Measured memory_bytes: 9412
#include<bits/stdc++.h>
using namespace std;
#define F(n) for(int i=0;i<n;++i)
const int MOD=1e9+7;

int main(){
    long n;
    cin >> n;
    long x[n];
    F(n) cin >> x[i];
    long b[n];
    F(n) b[i]=x[i];
    sort(b,b+n);
    F(n){
        if(b[n/2]>x[i]){
            cout << b[n/2] << endl;
        }
        else{
            cout << b[n/2-1] << endl;
        }
    }
    return 0;
}

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

int N, v[120];
long long int W, w[120], dp[120][120000];

int main(void) {

	cin >> N >> W;

	for (int i = 1; i <= N; i++) {
		cin >> w[i] >> v[i];
	}

	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= 120000; j++) {
			dp[i][j] = 999999999999;
		}
	}
	

	dp[0][0] = 0;

	for (int i = 1; i <= N; i++) {
		for (int x = 0; x <= 120000; x++) {
			dp[i][x] = min(dp[i][x], dp[i - 1][x]);
			if (x - v[i] >= 0) { dp[i][x] = min(dp[i][x], dp[i - 1][x - v[i]] + w[i]); }
		}
	}

	int ans = 0;

	for (int x = 0; x <= 110000; x++) {
		if (dp[N][x] <= W) { ans = max(ans,x); }
	}

	cout << ans << endl;

	

	return 0;
}

Measured memory_bytes: 96512
#include <stdio.h>
#include <stdbool.h>

#define BUFSIZE (10)

int main()
{
	char s[BUFSIZE] = {0};
	scanf("%s", &s);

	int ans = true;
	int size = strlen(s);

	if((size % 2) != 0) {
		ans = false;
		goto EXIT;
	}

	int i;
	for (i=0; i<size; i+=2) {
		if ((s[i] != 'h') || (s[i+1] != 'i')) {
			ans = false;
			break;
		}
	}

EXIT:
	if (ans) {
		printf("Yes");
	} else {
		printf("No");
	}

	return 0;
}


Measured memory_bytes: 128
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=5e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int d;
  string s;
  cin >> s >> d;
  ll ans=0,dp[10005][2][105]={};
  cin >> s >> d;
  dp[0][0][0]=1;
  for(int i=0; i<s.size(); i++) {
    for(int j=0; j<2; j++) {
      for(int k=0; k<d; k++) {
        int lim=j?9:s[i]-'0';
        for(int l=0; l<=lim; l++) {
          (dp[i+1][j||l<lim][(k+l)%d]+=dp[i][j][k])%=MOD;
        }
      }
    }
  }
  for(int i=0; i<2; i++) {
    ans+=dp[s.size()][i][0];
    ans%=MOD;
  }
  ans--;
  if(ans<0) {
    ans+=MOD;
  }
  cout << ans << "\n";
}

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

int main() {
    int N;
    cin >> N;
    map<int,int> mp;
    vector<int> vec;
    int ma = 0;
    for (int i = 0;i < N;i++) {
        int a;
        cin >> a;
        mp[a]++;
        ma = max(ma,a);
        if (mp[a] == 1) vec.push_back(a);
    }
    int ans = 0;
    for (int i : vec) {
        if (mp[i] >= i) {
            ans += mp[i] - i;
        }
        else if (mp[i] != 0) {
            ans += mp[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5112
#include<bits/stdc++.h>
#define int long long
int a[20];
using namespace std;
signed main(){
    int d,b,c;
    cin>>d>>b>>c;
    int waru=1;
    int ans=0;
    int sum=0;
    for(int n=1;n<d+1;n++){
        ans=0;
        for(int k=0;k<20;k++){
            waru=1;
            for(int l=0;l<k+1;l++){
                waru=waru*10;
            }
            a[k]=(n%waru)/(waru/10);
            ans+=a[k];
        }
        if(ans>=b&&ans<=c){
            sum+=n;
        }
    }
    cout<<sum<<endl;
    
}

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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;


vector<ll> enumDivisor(ll n) {
    vector<ll> res;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i != 0) continue;
        res.push_back(i);
        if (i * i != n) res.push_back(n / i);
    }
    return res;
}

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

    ll ans = 0;
    for (ll x : enumDivisor(n)) {
        if (x == 1) continue;
        ll tmp = n;
        while (tmp % x == 0) tmp /= x;
        tmp %= x;
        if (tmp == 1) ans++;
    }

    ans += enumDivisor(n - 1).size() - 1;
    cout << ans << endl;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto x:v)cerr<<x<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define EPS 1e-9
typedef long long ll;

signed main(){
  int N,T;
  int ans = INF;
  cin >> N >> T;
  int c,t;
  vector<pair<int,int>> v;
  FOR(i,0,N){
    cin >> c >> t;
    if(t <= T)ans = min(ans,c);
  }
  cout << (ans == INF ? "TLE" : to_string(ans)) << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <stack>
#include <queue>
#include <cmath>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define repp(i,j,k) for(int i=j;i>=k;i--)
#define llrep(i,j,k) for(long long int i=j;i<(long long int)k;i++)
#define Sort(x) sort(x.begin(),x.end()); 
#define vi vector<int>
#define vvi vector<vector<int>> 
#define ll long long
int mod=1e9+7;
const int INF = 100000000;

using namespace std;

void p(int x) {
	cout << x << endl;
}

void pp(string s) {
	cout << s << endl;
}




int main(void) {
	bool n=false, s=false, e=false, w=false;
	string ss;
	cin >> ss;
	rep(i, 0, ss.length()) {
		if (ss[i] == 'N') n = true;
		else if (ss[i] == 'S') s = true;
		else if (ss[i] == 'W') w = true;
		else if (ss[i] == 'E')e = true;
	}

	if ((s&&n) && (e&&w))cout << "Yes" << endl;
	else if ((s&&n) && (!e && !w))cout << "Yes" << endl;
	else if ((e&&w) && (!n && !s))cout << "Yes" << endl;
	else cout << "No" << endl;


	
	return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val (X, Y) = nextIntList()
    if (Y in (X * 2..X * 4) && Y % 2 == 0) {
        println("Yes")
    } else {
        println("No")
    }
}


Measured memory_bytes: 36500
# AOJ ITP2_1_A: Vector
# Python3 2018.6.24 bal4u

from collections import deque
Q = deque()
q = int(input())
for i in range(q):
    a = input()
    if   a[0] == '0': Q.append(a[2:])      # pushBack
    elif a[0] == '1': print(Q[int(a[2:])]) # randomAccess
    else:             Q.pop()              # popBack



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

#define ll              long long
#define ull             unsigned long long
#define endl            "\n"
#define F               first
#define S               second
#define io              ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb              push_back
#define mp(a,b)         make_pair(a,b)
#define all(v)          (v).begin(),(v).end()
#define bs              binary_search
#define lbd             lower_bound
#define ubd             upper_bound
#define vi              vector<int>
#define ii              pair<int,int>
#define vii             vector<ii>
#define si              set<int>
#define umii            unordered_map<int, int> 
#define mii             map<int,int>
#define msi             map<string,int>
#define rep(i,a,b)      for(int i=int(a) ; i<int(b) ;i++)
#define rvi(c,it)       for(vi::iterator it= (c).begin(); it!=(c).end(); it++)
#define rvii(c,it)      for(vii::iterator it= (c).begin(); it!=(c).end(); it++)
#define rmii(c,it)      for(mii::iterator it= (c).begin(); it!=(c).end(); it++)
#define rmsi(c,it)      for(msi::iterator it= (c).begin(); it!=(c).end(); it++)
#define mem(arr,value)        memset(arr,value,sizeof(arr))
using namespace std ;


int main() {
    io ; 
    
    string s , t ;
    cin>>s>>t ;
    int cnt=0 ;
    for(int i=0 ; i<3 ;i++){
        if(s[i]==t[i]) cnt++ ;
    }
      
      cout<<cnt; 
    
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int N = 3e5 + 5;
int n;
int arr[N];
long long ans;
int ptr1 , ptr2;
int main(){
	scanf("%d" , &n);
	n *= 3;
	for(int i = 1 ; i <= n ; ++i){
		scanf("%d" , arr + i);
	}
	ans = 0;
	sort(arr + 1 , arr + 1 + n);
	n /= 3;
	ptr1 = 1;
	ptr2 = n * 3;
	for(int i = 1 ; i <= n ; ++i){
		ans += arr[ptr2 - 1];
		ptr2 -= 2;
		ptr1 += 1;
	}
	printf("%lld\n" , ans);
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
using namespace std;

int A[200000];
map <int, int> elem_occurence;

int closest_two_power(int n){
    for(int i = 1; i < 32; i++){
        if((1 << (i - 1)) <= n && n < (1 << i)){
            return (1 << i);
        }
    }
    return -1;
}
int main(){
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    for(int i = 0; i < N; i++){
        if(elem_occurence.find(A[i]) == elem_occurence.end()){
            elem_occurence[A[i]] = 1;
        } else {
            elem_occurence[A[i]] ++;
        }
    }

    sort(A, A + N, greater<int>());

    int ans = 0;
    for(int i = 0; i < N; i++){
        if(elem_occurence.find(A[i]) == elem_occurence.end()){
            continue;
        }
        int target = closest_two_power(A[i]) - A[i];
        if(target != A[i]){
            if(elem_occurence.find(target) != elem_occurence.end()){
                ans ++;
                elem_occurence[target] --;
                elem_occurence[A[i]] --;
                if(elem_occurence[target] == 0){
                    elem_occurence.erase(target);
                }
                if(elem_occurence[A[i]] == 0){
                    elem_occurence.erase(A[i]);
                }
            }
        } else {
            if(elem_occurence[target] >= 2){
                ans ++;
                elem_occurence[target] -= 2;
                if(elem_occurence[target] == 0){
                    elem_occurence.erase(target);
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, k;
    string s;
    char ch;

    cin >> n >> s >> k;
    ch = s.at(k - 1);

    for (int i = 0; i < n; i++)
    {
        if (s.at(i) != ch)
        {
            s.at(i) = '*';
        }
    }

    cout << s << endl;

    return 0;
}

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

int main() {
  int n, ans = 0;
  cin >> n;
  vector<vector<pair<int, int>>> v(n);
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    v[i].resize(a);
    for (int j = 0; j < a; ++j) {
      cin >> v[i][j].first >> v[i][j].second;
      --v[i][j].first;
    }
  }
  for (int bit = 0; bit < (1<<n); ++bit) {
    bool check = 1;
    
    for (int i = 0; i < n; ++i) {
      if(!(bit & (1<<i))) continue;
      int a;
      for (pair<int, int> xy: v[i]) {
        int x = xy.first, y = xy.second;
      	
        if (y == 1 and !(bit & (1<<x))) 
          check = 0;
        else if (y == 0 and (bit & (1<<x)))
          check = 0;
      }
    }
    if (check) {
      int tmp = 0;
      for (int t = 0; t < n; ++t) {
        if (bit & (1 << t)) ++tmp;
      }
      ans = max(ans, tmp);
    }
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
s=list(input())
t=list(input())
s.sort()
t.sort()
s1={}
t1={}
s1_v=[]
t1_v=[]

for i in s:
    if not i in s1:
        s1[i]=1
    else:
        s1[i]+=1
    
for i in t:
    if not i in t1:
        t1[i]=1
    else:
        t1[i]+=1
        
for v in s1.values():
    s1_v+=[v]  
for v in t1.values():
    t1_v+=[v]  
    
s1_v.sort()
t1_v.sort()

if( s1_v == t1_v ):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 7320
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int sum;
        int other;
        while((sum=sc.nextInt())!=0){
            for(int i=0;i<9;i++){
                other=sc.nextInt();
                sum-=other;
            }
            System.out.println(sum);
        }
    }
}


Measured memory_bytes: 26064
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

using namespace std;
typedef long long ll;

long long floor_sum(long long n, long long m, long long a, long long b) {
    long long ans = 0;
    if (a >= m) {
        ans += (n - 1) * n * (a / m) / 2;
        a %= m;
    }
    if (b >= m) {
        ans += n * (b / m);
        b %= m;
    }

    ll x = (b+a*(n))/m;
    if(a == 0) return ans;
    ans += floor_sum(x, a, m, (b+a*(n))%m);
    return ans;
}



void solve(){
    ll n, m, a, b; cin >> n >> m >> a >> b;
    cout << floor_sum(n, m, a, b) << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int t; cin >> t;
    for(int i = 0; i < t; i++) solve();
}

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

using namespace std;

#define FOR(i,s,e) for((i)=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)

#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

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

const double EPS = 1e-10;

const int N = 200000;
int r[N];
int n;

int main() {
  int i, j;
  scanf("%d ", &n);
  for (i=0; i<n; i++)
    scanf("%d ", r+i);

/*
  //O(n^2):TLE
  int res = r[1] - r[0];
  for (i=0; i<n-1; i++)
    for (j=i+1; j<n; j++) {
      res = (res < r[j] - r[i]) ? r[j] - r[i] : res; 
    }
  printf("%d\n", res);
*/

/*
  //WA(miniが余計に更新されてmaxj-miniがおかしなことになる)
  int maxj = r[1];
  int mini = r[0];
  for (j=1; j<n; j++) {
    if (maxj-mini < r[j]-mini) {
      maxj = r[j];
      if (j < n-1 && r[j] < mini) mini = r[j];
    }
//    if (j < n-1 && r[j] < mini) mini = r[j];
  }
  printf("%d\n", maxj-mini);
*/

  //resにmax-minを持たせる(上のようにminiの更新で変なことにならない)
  int res = r[1] - r[0];
  int mini = r[0];
  for (j=1; j<n; j++) {
    if (res < r[j] - mini) res = r[j] - mini;
    if (r[j] < mini) mini = r[j];
  }

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

  return 0;
}

Measured memory_bytes: 1972
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W, x, y, z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

template <std::int_fast64_t Modulus> class modint {
	using u64 = std::int_fast64_t;
public:
	u64 a;
	constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept {
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept {
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept {
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const noexcept {
		return modint(*this) /= rhs;
	}
	constexpr modint& operator+=(const modint rhs) noexcept {
		a += rhs.a;
		if (a >= Modulus) {
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint& operator-=(const modint rhs) noexcept {
		if (a < rhs.a) {
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint& operator*=(const modint rhs) noexcept {
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr modint& operator/=(modint rhs) noexcept {
		u64 exp = Modulus - 2;
		while (exp) {
			if (exp % 2) {
				*this *= rhs;
			}
			rhs *= rhs;
			exp /= 2;
		}
		return *this;
	}
};
#pragma endregion

int arr[100];
int main() {
	cin >> N;
	rep(i, N) {
		cin >> arr[i];
	}
	for (int i = 0; i <= 100; i++) {
		ll sum = 0;
		rep(j, N) {
			sum += (i - arr[j]) * (i - arr[j]);
		}
		min_value = min(min_value, sum);
	}
	cout << min_value;
}



Measured memory_bytes: 256
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector as V
import Data.Ord

main :: IO ()
main = readLine >>= main'
    where
        main' [h, w, d] = readContents h >>= main'' . build h w d 
        main'' vs = readLn >>= readContents >>= printRes . solve vs
        printRes = mapM_ print 

build :: Int -> Int -> Int -> [[Int]] -> V.Vector Int
build h w d as = V.fromList . (0 :) . map snd . sortBy (comparing fst) $ buildLoop bs
    where
        bs = sortBy cmpf . concatMap mf $ zip [1..] as
        mf (i, xs) = map (\(j, a) -> (a, (i, j))) $ zip [1..] xs
        cmpf (la, _) (ra, _) = (comparing (`mod` d)) la ra `mappend` compare la ra

        buildLoop (x@(a, _) : xs) = (a, 0) : inner 0 x xs
            where
                inner pv (ap, (lp, rp)) (y@(ay, (ly, ry)) : ys)
                    | ap `mod` d == ay `mod` d = (ay, nv) : inner nv y ys
                    | otherwise = buildLoop $ y : ys
                    where
                        nv = pv + abs (lp - ly) + abs (rp - ry)
                inner _ _ _ = buildLoop []
        buildLoop _ = []


solve :: V.Vector Int -> [[Int]] -> [Int]
solve vs = map (\[l, r] -> vs V.! r - vs V.! l)

readLine :: IO [Int]
readLine = unfoldr (\s -> second (maybe B.empty snd . B.uncons) <$> B.readInt s) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

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

ll N;
vector<ll> x, y;
int main() {
    cin >> N;
    x.resize(N);
    y.resize(N);
    rep(i, N) {
        cin >> x[i] >> y[i]; 
    }

    vector<ll> v;
    rep(i, N) {
        v.push_back(i);
    }

    double sum = 0;
    double total = 0;

    do {
        double dist = 0;
        total++;

        for (int i = 0; i < v.size() - 1; i++) {
            double tmp_x = x[v[i]] - x[v[i + 1]];
            double tmp_y = y[v[i]] - y[v[i + 1]];
            dist += sqrt(tmp_x * tmp_x + tmp_y * tmp_y);
            // cout << sqrt(tmp_x * tmp_x + tmp_y * tmp_y) << endl;
        }
        sum += dist;
    } while (next_permutation(v.begin(), v.end()));
    double ans = sum / total;
    printf("%.10f\n", ans);
}

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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    vector<int> vec(3);
    vec.at(0) = a;
    vec.at(1) = b;
    vec.at(2) = c;
    sort(vec.rbegin(), vec.rend());
    if ( vec.at(0) == 7 && vec.at(1) == 5 && vec.at(2) == 5){
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <cstring>
using namespace std;

#define F first
#define S second
#define pb push_back
#define pf pop_front
#define mp make_pair

typedef pair<int, int> pii;
typedef pair<int, bool> pib;

const long MAX_N = 1000 + 24;

int n, m, s, t, ans = 0;
int img[MAX_N][MAX_N], par[MAX_N];
bool mark[MAX_N];
deque<int> dq;
vector<pair<int, pii> > G[MAX_N];

pair<int, bool> bfs(int v, int mn = 1000 * 1000 + 24) {
  dq.pb(v);
  mark[v] = true;
  while (dq.size()) {
    v = *dq.begin();
    if (v == t) {
      //cerr<<"here"<<endl;
      int u = t, mn = 1000 * 1000 + 24;
      while (u != s) {
        mn = min(mn, G[par[u]][img[par[u]][u]].S.S - G[par[u]][img[par[u]][u]].S.F);
        u = par[u];
      }
      u = t;
      while (u != s) {
        G[par[u]][img[par[u]][u]].S.F += mn;
        G[u][img[u][par[u]]].S.F -= mn;
        u = par[u];
      }
      return mp(mn, 1);
    }
    dq.pf();
    for (int i = 0; i < G[v].size(); i++) {
      auto e = G[v][i];
      if (mark[e.F] == 0 and e.S.S - e.S.F > 0) {
        dq.pb(e.F);
        mark[e.F] = true;
        par[e.F] = v;
      }
    }
  }
  return mp(-1, 0);
}

int main() {
  cin>>n>>m;
  int u, v, c;
  for (int i = 0; i < m; i++) {
    cin>>u>>v>>c;
    img[u][v] = G[u].size();
    img[v][u] = G[v].size();
    G[u].pb(mp(v, mp(0, c)));
    G[v].pb(mp(u, mp(0, 0)));
  }
  s = 0, t = n-1;
  //cerr<<"out"<<endl;
  //cin>>s>>t;
  while (true) {
    memset(mark, 0, sizeof(mark));
    memset(par, -1, sizeof(par));
    dq.clear();
    auto t = bfs(s);
    if (t.S == 0) break;
    ans += t.F;
  }
  cout<<ans<<endl;
}



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

main() {
  int H, W;
  string C[2 * MAX_H];
  cin >> H >> W;
  rep(i, 2 * H) {
    cin >> C[i];
    C[i + 1] = C[i];
    i++;
  }
  rep(i, 2 * H) {
    cout << C[i] << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int n;
  cin >> n;
  int p[n];
	for(int i = 0 ; i < n; i++)	
      cin >> p[i];
  int res = 0;
  for (int i = 1; i < n-1; i++)
    (((p[i] < p[i-1])&&(p[i]>p[i+1]))||((p[i] > p[i-1])&&(p[i]<p[i+1])))? res += 1 : res = res;
  cout << res <<'\n';  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <map>

using namespace std;

int main() {
    int p, q, r;
    cin >> p >> q >> r;
    int min = 0;

    if (p >= q && p >= r) {
        min = q + r;
    } else if (q >= p && q >= r) {
        min = p + r;
    } else {
        min = p + q;
    }

    cout << min << endl;

    return 0;
}


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

int main()
{
    string S;
    cin>>S;
    if(S[0]!='A'){cout<<"WA"<<endl; return 0;}
    if(S[S.length()-1]=='C' || S[1]=='C'){cout<<"WA"<<endl; return 0;}
    int count_C=0;
    for(int i=2;i<S.length()-1;i++){
        if(S[i]=='C')count_C++;
    }
    if(count_C>1){cout<<"WA"<<endl;}
    else{
        int count_lowercase=0;
        for(int i=0;i<S.length();i++){
            if(islower(S[i]))count_lowercase++;
        }
        if(count_lowercase==S.length()-2){cout<<"AC"<<endl;}
        else{cout<<"WA"<<endl;}
    }
}





Measured memory_bytes: 256
// Problem: E - Coprime
// Contest: AtCoder - AtCoder Beginner Contest 177
// URL: https://atcoder.jp/contests/abc177/tasks/abc177_e
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

#define int long long
#define endl "\n"
#define deb(x) cout << #x << " -> " << x << endl;
#define print(x)                         \
    for (auto x_ : x) cout << x_ << " "; \
    cout << endl;
#define pb push_back
#define all(x) x.begin(), x.end()
#define mod 1000000007  // 1e9 + 7
#define prec(x, y) fixed << setprecision(y) << x

const int N = (int)1e6 + 3;
bool visited[N] = {};

void solve() {
    int n;
    cin >> n;
    int e_count, o_count;
    e_count = o_count = 0;
    int a[n];
    for (auto &x : a) {
        cin >> x;
        if (x & 1)
            o_count++;
        else
            e_count++;
    }

    bool okay = true;

    for (int i = 0; i < n; ++i) {
        for (int k = 1; k * k <= a[i]; ++k) {
            if (a[i] % k == 0) {
                int factor1 = a[i] / k;
                int factor2 = k;

                if (factor1 != 1 && visited[factor1]) {
                    okay = false;
                    break;
                }

                if (factor2 != 1 && visited[factor2]) {
                    okay = false;
                    break;
                }

                else {
                    visited[factor1] = true;
                    visited[factor2] = true;
                }
            }
        }
    }

    if (okay) {
        cout << "pairwise coprime";
        return;
    }

    int total_gcd = __gcd(a[0], a[1]);
    for (int i = 2; i < n; ++i) total_gcd = __gcd(total_gcd, a[i]);

    if (total_gcd == 1) {
        cout << "setwise coprime\n";
        return;
    }

    cout << "not coprime\n";
    return;
}

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

    int tc = 1;
    // cin >> tc;
    while (tc--) {
        solve();
    }
}


Measured memory_bytes: 12444
/*
7
nikoandsolstice
*/

function main(input){
  input = input.trim();
  var ten = "..."
  var jisuu = input.split("\n")[0];
  var moji = input.split("\n")[1];
  if(moji.length>jisuu){
    console.log(moji.substr(0,jisuu)+ten);
  }else{
    console.log(moji);
  }
}
main(require("fs").readFileSync("/dev/stdin","utf8"));

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

#define ll long long 
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(), (x).end()

int main(){

	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt", "r", stdin);
	// 	freopen("output.txt", "w", stdout);
	// #endif
		
	ios::sync_with_stdio(0); cin.tie(0);
	
	ll n, k; 
	cin >> n >> k;
	ll ans = 0;
	while(n) {
		ans++;
		n /= k;
	}
	cout << ans;
	return 0;
}

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

int main(){
    int N; cin >> N;
    vector<int> X(N);
    rep(i, N) cin >> X[i];
    vector<int> sorted_X(N);
    rep(i, N) sorted_X[i] = X[i];
    sort(sorted_X.begin(), sorted_X.end());
    int left_median = sorted_X[N/2-1];
    int right_median = sorted_X[N/2];
    rep(i, N){
        if(X[i] <= left_median){
            cout << right_median << endl;
        }else{
            cout << left_median << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
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;
}
int main() {
    int n;cin>>n;
    vector<int> d(n);
    rep(i,n){
        cin>>d[i];
    }
    sort(ALL(d));
    n/=2;
    cout<<d[n]-d[n-1]<<endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  int ma = (-1), mi = 1001;
  for (int i=0; i<n; i++) {
    int c;
    cin >> c;
    ma = max(ma, c);
    mi = min(mi, c);
  }
  cout << ma - mi << endl;
}

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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();

            if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3])
            {
                Console.WriteLine("Bad");
            }
            else
            {
                Console.WriteLine("Good");
            }
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <math.h>
#include <string>
#include <iomanip>
#define PI 3.14159265359
using namespace std;

int main(void)
{
	double a, b, c, s, l, h, theta;

	cin >> a >> b >> c;

	theta = c * PI / 180;
	s = a * b * cos(theta-PI/2)/2;
	l = a + b + sqrt(pow(a, 2) + pow(b, 2) - 2 * a*b*cos(theta));
	h = b * cos(theta-PI/2);

	cout << setprecision(10) << s << endl;
	cout << setprecision(10) << l << endl;
	cout << setprecision(10) << h << endl;
}


Measured memory_bytes: 3436
n, m = list(map(int,input().split()))
issafe = [True] * (n + 1)

for i in range(m):
    a = int(input())
    issafe[a] = False

dp = [0] * (n + 1)

dp[0] = 1
if issafe[1]: dp[1] = 1;

for i in range(n - 1):
    if issafe[i]: dp[i + 2] += dp[i]
    if issafe[i + 1]: dp[i + 2] += dp[i + 1]
    dp[i + 2] %= 1000000007

print(dp[n])

Measured memory_bytes: 45656
mod = 10**9+7
n,a,b = map(int,input().split())
def combination(n, a):
    res = 1
    div = 1
    for i in range(a):
        res *= n-i
        res %= mod
        div *= a - i
        div %= mod
    res = (res * pow(div, mod-2, mod)) % mod
    return res
print((pow(2,n,mod)-1-combination(n,a)-combination(n,b))%mod)

Measured memory_bytes: 9096
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] H = new int[N];
    int n =0;
    for (int i =0; i<N; i++) {
      H[i] = sc.nextInt();
    }
    for (int i =1; i<N; i++) {
      for (int j =0; j<i; j++) {
        if(H[i] < H[j]) {
          n++;
          break;
        }
      }
    }
    System.out.println(N-n);
  }
}

Measured memory_bytes: 22868
import math
x1, y1, x2, y2 = map(int,input().split())
x = x2 - x1
y = y2 - y1
x3 = x2 - y
y3 = y2 + x
x4 = x1 - y
y4 = y1 + x
print(x3,y3,x4,y4)

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

int main(){
  int x,a,b;
  cin>>x>>a>>b;
  int y,z;
  if(x>a) y=x-a;
  else y=a-x;
  if(x>b) z=x-b;
  else z=b-x;
  if(y<z)
  cout<<'A'<<endl;
  else
    cout<<'B'<<endl;
}


Measured memory_bytes: 256
import sys
N,M,X,Y = map(int,input().split())
array_x = list(map(int,input().split()))
array_y = list(map(int,input().split()))

if not ( 1 <= N <= 100 and 1 <= M <= 100 ): sys.exit()
if not ( -100 <= X <= 100 and -100 <= Y <= 100 ): sys.exit()
for I in array_x:
    if not ( -100 <= I <= 100 and array_x.count(I) == 1 and I != X): sys.exit()
for J in array_y:
    if not ( -100 <= J <= 100 and array_y.count(J) == 1 and J != Y): sys.exit()

for I in range(X+1,Y+1):
    if I > max(array_x) and I <= min(array_y):
        print('No War')
        sys.exit()
print('War')

Measured memory_bytes: 9224
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long k = sc.nextLong();
		
		long s = n % k;
		long ans = Long.min(s, Math.abs(s - k));
		System.out.println(ans);
		
	}
}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
string alp="abcdefghijklmnopqrstuvwxyz";
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

ll n;
void Rep(string s,ll i,ll f){
    if(f==n){
        cout<<s<<endl;
        return ;
    }
    rep(j,0,i+1){
        if(j<=i){
            Rep(s+alp[j],i,f+1);
        }else{
            Rep(s+alp[j],i+1,f+1);
        }
    }
}

int main(){
    cin>>n;
    ll flag=0;
    Rep("",-1,0);
    
    return 0;
}


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

int main() {
	int h, w, k, ans = 0;
	cin >> h >> w >> k;
	vector<string> c(h);
	rep(i, h) cin >> c[i];
	rep(is, 1 << h) rep(js, 1 << w) {
		int cnt = 0;
		rep(i, h) rep(j, w) {
			if (js >> j & 1) continue;
			if (is >> i & 1) continue;
			if (c[i][j] == '#') cnt++;
		}
		if (cnt == k) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3640