akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int main(){
  int n, m;
  cin >> n >> m;
  vector<int> B(n), P(m), one;
  for(int i = 0; i < n; ++i){
    cin >> B[i];
    if(B[i]) one.push_back(i);
  }

  for(int i = 0; i < m; ++i) cin >> P[i];
  int ans = 1000000000;
  for(int i = 0; i < 2; ++i){
    vector<int> A(n);
    int t = 0;
    vector<int> one_;
    for(int j = 0; j < m; ++j){
      for(int k = 0; k < P[j]; ++k){
        A[t] = (i+j)%2;
        if((i+j)%2) one_.push_back(t);
        ++t;
      }
    }
    if(one.size() != one_.size()) continue;
    int d = 0;
    for(int j = 0; j < one.size(); ++j)
      d += abs(one[j]-one_[j]);
    ans = min(d,ans);
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3148
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() { 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string S;
    cin >> S;
    for(int i = 0; i < S.size(); i += 2) {
        if (S.substr(i, 2) != "hi") {
            cout << "No" << endl;
            return 0;
        }
    }

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

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    ll sum = 0;
    REP(i,N){
        ll a;
        cin >> a;
        sum += a;
        A[i] = a;
    }

    ll now = 0;
    ll ans = LLONG_MAX;
    REP(i,N-1){
        ll a = A[i];
        now += a;
        ll rem = sum - now;
        ll tmp = abs(rem - now);
        chmin(ans, tmp);
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
import java.awt.Frame;
import java.awt.image.SinglePixelPackedSampleModel;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import javax.sql.rowset.FilteredRowSet;
import javax.swing.BorderFactory;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.stream.events.EndDocument;
import java.math.BigInteger;
import java.time.chrono.MinguoChronology;
import java.util.Scanner;

public class Main {
  static InputReader in;
  static PrintWriter out;
  
  static class Solution {
    void solve() throws IOException {
      double a = in.nextDouble();
      double b = in.nextDouble();
      double C = Math.toRadians(in.nextDouble());
      double S = a * b * Math.sin(C) / 2;
      double c = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(C));
      double h = b * Math.sin(C); 
      double L = a + b +c;
      
      out.printf("%.5f\n%.5f\n%.5f\n", S, L, h);
//      End solve()
    }
    
//  End solution
  } 
  

  public static void main(String[] args) throws IOException {
    in = new InputReader(System.in);
    out = new PrintWriter(System.out);
    Solution solver = new Solution();
    solver.solve();
    out.close();
}

  static class InputReader {
    public BufferedReader br;
    public StringTokenizer st;
    
    public InputReader(InputStream stream) {
      br = new BufferedReader(new InputStreamReader(stream));
    }
   
    public int nextInt() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Integer.parseInt(st.nextToken());
    }
    
    public long nextLong() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Long.parseLong(st.nextToken()); 
    }
    
    public String next() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return st.nextToken();
    }
    
    public double nextDouble() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Double.parseDouble(st.nextToken());
    }
    
  }
  
}

Measured memory_bytes: 24848
#include <iostream>
#include <string>

int main(int argc, char const *argv[])
{
	std::string word;
	while(true){
		std::cin >> word;
		if(word == "-") break;
		int times;
		std::cin >> times ;
		int idx = 0;
		int h = 0;
		for(int i = 0 ; i < times ; i ++ ){
			std::cin >> h;
			idx += h;
			idx %= word.length();
		}
		for(unsigned int i = 0 ; i < word.length() ;i ++){
			std::cout << word.at((i+idx)%word.length());
		}
		std::cout << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

bool isPrime(ll n) {
    if (n < 2)return false;
    for (ll i = 2; i * i <= n; i++)if (!(n % i))return false;
    return true;
}
vector<bool> prime_table(int n) {
    vector<bool> prime(n + 1, true);
    if (n >= 0)prime[0] = false;
    if (n >= 1)prime[1] = false;
    for (int i = 2; i * i <= n; i++) {
        if (!prime[i])continue;
        for (int j = i + i; j <= n; j += i) {
            prime[j] = false;
        }
    }
    return prime;
}

ll POW(ll n, ll p) {
    ll ret = 1;
    for (; p > 0; p >>= 1, n = n * n % mod) {
        if (p & 1)ret = ret * n % mod;
    }
    return ret;
}
ll INV(ll n) { return POW(n, mod - 2); }

int main() {
    init();

    string n; cin >> n;
    bool ok = false;
    each(i, n)ok |= i == '7';
    cout << (ok ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 3656
N, X, Y=map(int, input().split())

anss=[0]*(N-1)

def judge(i, j):
  #1<=a<X
  #X<=b<=Y
  #Y<c<=N
  if 1<=i and i<X:
    if 1<=j and j<X:
      return j-i
    if X<=j and j<=Y:
      #1,4 4-1 4-4+2-1
      return min(j-i, Y-j+X-i+1)
    if Y<j and j<=N:
      return j-i-(Y-X-1)
    
  if X<=i and i<=Y:
    if X<=j and j<=Y:
      return min(j-i, Y-j+i-X+1)
    if Y<j and j<=N:
      return min(j-i, i-X+j-Y+1)
    
  if Y<i and i<=N:
    return j-i

for i in range(1,N):
  for j in range(i+1, N+1):
    l=judge(i,j)
    #print(i,j,l)
    anss[l-1]+=1

for a in anss:
  print(a)

Measured memory_bytes: 3444
import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))

ans = 0
m = 10 ** 9 + 1
for i in range(N - 1):
    if A[i] < 0:
        A[i] = -A[i]
        A[i + 1] = -A[i + 1]
    ans += A[i]
    if A[i] < m:
        m = A[i]

if A[N - 1] < 0:
    m = min(m, abs(A[N - 1]))
    ans += abs(A[N - 1])
    ans -= 2 * m
else:
    ans += A[N - 1]
print(ans)

Measured memory_bytes: 60272
#include <stdio.h>
#include<math.h>
 
int main()
{
long long int N,l;
int a[100001]={0};
scanf("%lld",&N);
for(int i=1;i<=100;i++)
{
    for(int j=1;j<=100;j++)
    {
        for(int k=1;k<=100;k++)
        {
            l=i*i+j*j+k*k+i*j+i*k+j*k;
          a[l]++;
        }
    }
}
for(int i=0;i<N;i++)
{
printf("%d\n",a[i+1]);
}
}

Measured memory_bytes: 2124
#include<stdio.h>

int main(void){
  int a,b;
  scanf("%d %d", &a,&b);
  if(a<b){
    printf("a < b\n");
  }else if(a>b){
    printf("a > b\n");
  }else{
    printf("a == b\n");
  }
  return 0;
}

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

int main(){
	int n;
	cin >> n;
	int a[25565] = {0};
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	for(int i=0;i<n-1;i++){
		cout << a[n-i-1] << " ";
	}
	cout << a[0] << endl;
}

Measured memory_bytes: 1268
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
#define REP(i,m,n) for(LL i=(m);i<(n);i++)

int main(){
  LL n,a;
  cin >> n >> a;
  
  if(n%500 <= a){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
  return 0;
}


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

using namespace std;
#define int long long
const int N = 2666 , inf = 0x3f3f3f3f; 
int dx[]={0,0,1,-1},dy[]={1,-1,0,0};
int n,m,Sx,Sy,Tx,Ty;
char mp[N][N];
int vis[N][N];
struct Node{int x,y,z;};
deque<Node> q;
int step[N][N];
signed main(){
	
	cin>>n>>m>>Sx>>Sy>>Tx>>Ty;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			cin>>mp[i][j],step[i][j]=inf;
	
	q.push_back((Node){Sx,Sy,0});
	while(!q.empty()){
		Node t=q.front();
		q.pop_front();
		if(vis[t.x][t.y])
			continue;
		vis[t.x][t.y]=1;
		step[t.x][t.y]=min(step[t.x][t.y],t.z);
		for(int i=0;i<4;i++){
			int tx=t.x+dx[i],ty=t.y+dy[i];
			if(tx>=1&&ty>=1&&tx<=n&&ty<=m&&mp[tx][ty]!='#'){
				q.push_front({tx,ty,t.z});
			}
		}
		for(int i=(t.x-2);i<=(t.x+2);i++)
			for(int j=(t.y-2);j<=(t.y+2);j++)
				if(i>=1&&j>=1&&i<=n&&j<=m&&mp[i][j]!='#'){
						q.push_back({i,j,t.z+1});
				}
	}
	if(step[Tx][Ty]==inf) cout<<"-1";else cout<<step[Tx][Ty];
	return 0;
}

Measured memory_bytes: 32220
#include <stdio.h>

int GCD(int m, int n);

int main(void)
{
	int m, n;
	int gcd;
	int lcm;
	
	while (scanf("%d %d", &m, &n) != EOF){
		if (m < n){
			gcd = m;
			m = n;
			n = gcd;
		}

		gcd = GCD(m, n);
		lcm = n * (m / gcd);
		
		printf("%d %d\n", gcd, lcm);
	}
		
	return (0);
}

int GCD(int m, int n)
{
	int r;
	
	while (m % n != 0){
		r = n;
		n = m % n;
		m = r;
    }
	//if (m %  n != 0){
	//	GCD(m, n);
	//}
	
	return (n); 
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
int main() {
	int ans=0;
	string s,s1="CODEFESTIVAL2016";
	cin>>s;
	for(int i=0;i<16;i++){
		if(s[i]!=s1[i]){
			ans++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 384
fun main(arg: Array<String>) {
    val (H, W) = listOfInt()
    val N = nextInt()
    val A = listOfInt()
    val M = mutableListOf<Int>()
    A.forEachIndexed { index, a ->
        for (m in 0 until a) M.add(index + 1)
    }
//System.err.println(M)
    repeat(H) { h ->
        if (h % 2 == 0) println(M.subList(h * W, (h + 1) * W).joinToString(" "))
        else println(M.subList(h * W, (h + 1) * W).reversed().joinToString(" "))
    }
}
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfInt(vararg deltas: Int) = listOfString().map { Integer.parseInt(it) }.mapIndexed { index, int -> int + deltas[index % deltas.size] }



Measured memory_bytes: 39608
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

void yes(){
    cout << "Yes" << endl;
}

void no (){
    cout << "No" << endl;
}

ll cel (ll a, ll b){
    if (a % b == 0) return a / b;
    else return a / b + 1;
}

ll gcds(ll a, ll b){
    ll c = a % b;
    while (c != 0){
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}

ll col(ll n){
    if (n % 2LL == 0) return n / 2LL;
    else return 3LL * n + 1LL;
}

int main() {
    ll n; cin >> n;
    vector<int> ar(1000,0);
    bool t = true;
    int ans = 1;
    ar[n]++;
    while (t){
        n = col(n);
        ar[n]++;
        ans++;
        if (ar[n] == 2){
            t = false;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

ll func(ll A, ll x, ll B) {
    return floor(A * x / B) - A * floor(x / B);
}

int main() {
    ll A, B, N; cin >> A >> B >> N;
    ll ans = func(A, min(B-1, N), B);
    cout << ans << endl;
}

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

using namespace std;

int main() {
    int N;
    cin >> N;
    
    vector<int> A(N);
    // 入力を記録する配列
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    
    sort(A.begin(), A.end());
    // Aを昇順にソート
    
    cout << A.back() - A.front() << endl;
    // A.back()でAの末尾、A.front()でAの先頭が取り出せる
    
    return 0;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		Set<String> set = new HashSet<String>();
		
		char wordEnd = '0';
		for(int i = 0;  i < N; i++) {
			String s = sc.next();
			if(i != 0) {
				if(wordEnd != s.charAt(0)|| set.contains(s)) {
					System.out.println("No");
					return;
				}
			}
			wordEnd = s.charAt(s.length()-1);
			set.add(s);
		}
		System.out.println("Yes");
	}

}


Measured memory_bytes: 23508
#include <bits/stdc++.h>
using namespace std;
const auto start_time = std::chrono::high_resolution_clock::now();
void timecalculater(){
    #ifndef ONLINE_JUDGE
    auto end_time = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double> diff = end_time-start_time;
    cerr<<"Time Taken : "<<diff.count()<<"\n";
    #endif
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a,v) memset(a, v, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
ll p=1e9+7;
const int N=2e5+5;
int main() {
   
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int T=1;
    // cin>>T;
    while(T--){
        string s,t;cin>>s>>t;
        for(int i=0;i<sz(s);i++){
        	if(s[i]!=t[i]){
        		cout<<"No";return 0;
        	}
        }
        cout<<"Yes";return 0;
    }   
    timecalculater();
    return 0;   
} 

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

int main(){
  int n,ans=1;
  string s;
  cin >> n >> s;
  if(n%2==1)
    ans = 0;
  for(int i = 0 ;i < n/2; i++){
    if(s[i]!=s[i+n/2])
      ans = 0;
  }
  if(ans==1){
    cout << "Yes"<<endl;
  }else {
    cout << "No"<<endl;
  }
}


Measured memory_bytes: 3628
n, x, y = list(map(int, input().split()))
dist_cnt = (n) * [0]
x -= 1
y -= 1
for i in range(0, n - 1):
    for j in range(i + 1, n):
        dist = j - i
        if i <= x:
            if j >= y:
                dist = x - i + j - y + 1
            else:
                dist = min(dist, y - j + 1 + x - i)
        else:
            if j >= y:
                dist = min(dist, j - y + 1 + i - x)
            else:
                dist = min(dist, i - x + 1 + y - j)
        dist_cnt[dist] += 1
print( '\n'.join(map(str, dist_cnt[1:])))


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

const int M = 1000005;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  vector<int> cnt(4);
  rep(i, n){
    if(s[i] == 'N') cnt[0]++;
    if(s[i] == 'S') cnt[1]++;
    if(s[i] == 'W') cnt[2]++;
    if(s[i] == 'E') cnt[3]++;
  }
  bool exist = true;
  if(cnt[0] != 0 && cnt[1]!= 0 && cnt[2] != 0 && cnt[3] != 0){
    exist = true;
  }else if(cnt[0] != 0 && cnt[1] != 0 && cnt[2] == 0 && cnt[3] == 0 ){
    exist = true;
  }else if(cnt[2] != 0 && cnt[3] != 0 && cnt[0] == 0 && cnt[1] == 0){
    exist = true;
  }else{
    exist = false;
  }
  if(exist) cout << "Yes" << endl;
  else cout << "No" << endl;

}

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

const int N = (1 << 21) * 21 + 7;

int hghbit[N];
int endbit(int x, int b) {
	return x ^ x >> b << b;
}
int dethghbit(int x) {
	return x ^ 1 << hghbit[x];
}

int n, k;
int cnt[N];
void addedge(int u, int v) {
	cnt[v] += cnt[u];
}

int main() {
//	freopen("code.in", "r", stdin);
//	freopen("code.out", "w", stdout);

	hghbit[0] = -1;
	for (int i = 1; i < 1 << 22; ++i)
		hghbit[i] = std::max(hghbit[i >> 1] + 1, i & 1 ? 0 : -1);

	scanf("%d%d", &n, &k);
	static char s[1 << 22 | 7];
	scanf("%s", s);
	for (int i = 1; i <= n; ++i) {
		scanf("%s", s);
		for (int j = 0; j < 1 << i; ++j)
			cnt[(1 << i | j) * (n + 1) + i] += s[j] ^ 48;
	}

	for (int i = n; ~i; --i)
		for (int j = 1 << i, k, l; j < 1 << n + 1; ++j) {
			int x = dethghbit(j) >> i, y = endbit(j, i), u, v;
			if (y)
				k = hghbit[y],
				u = x << 1 | 1, v = endbit(y, k),
				l = 1 << hghbit[j] - (i - k) + 1 | u << k | v,
				addedge(j * (n + 1) + i, l * (n + 1) + k);
			if (y ^ (1 << i) - 1)
				k = hghbit[y ^ (1 << i) - 1],
				u = x << 1, v = endbit(y, k),
				l = 1 << hghbit[j] - (i - k) + 1 | u << k | v,
				addedge(j * (n + 1) + i, l * (n + 1) + k);
			if (i)
				l = j >> i, k = 0,
				addedge(j * (n + 1) + i, l * (n + 1) + k);
		}

	int ans = 0, bit = 0;
	for (int i = 2, j; i < 1 << n + 1; ++i)
		if (cnt[i * (n + 1)] >= k && (j = hghbit[i]) > bit) ans = i, bit = j;
	if (ans)
		for (ans ^= 1 << bit; bit; --bit)
			if (ans >> bit - 1) printf("1"), ans ^= 1 << bit - 1;
			else printf("0");
	return 0;
}


Measured memory_bytes: 192896
n, m = map(int, input().split())
h = list(map(int, input().split()))
tembo = [True]*n
for i in range(m):
    a, b = map(int, input().split())
    if h[a-1] <= h[b-1]:
        tembo[a-1] = False
    if h[a-1] >= h[b-1]:
        tembo[b-1] = False

ans = 0
for i in range(n):
    if tembo[i] == True:
        ans += 1

print(ans)


Measured memory_bytes: 84828
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#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 equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  ll ans = 0;
  vector<ll> s(n, 0);
  s[0] = a[0];
  if (s[0] <= 0) {
    ans += 1 - s[0];
    s[0] = 1;
  }
  rep(i, n - 1) {
    s[i + 1] = s[i] + a[i + 1];
    if ((i + 1) % 2 == 1 && s[i + 1] >= 0) {
      ans += s[i + 1] + 1;
      s[i + 1] = -1;
    }
    else if ((i + 1) % 2 == 0 && s[i + 1] <= 0) {
      ans += 1 - s[i + 1];
      s[i + 1] = 1;
    }
  }

  ll res = 0;
  rep(i, n) s[i] = 0;
  s[0] = a[0];
  if (s[0] >= 0) {
    res += s[0] + 1;
    s[0] = -1;
  }
  rep(i, n - 1) {
    s[i + 1] = s[i] + a[i + 1];
    if ((i + 1) % 2 == 1 && s[i + 1] <= 0) {
      res += 1 - s[i + 1];
      s[i + 1] = 1;
    }
    else if ((i + 1) % 2 == 0 && s[i + 1] >= 0) {
      res += s[i + 1] + 1;
      s[i + 1] = -1;
    }
  }
  cout << min(ans, res) << endl;

  
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;
#define dump(a) cout << (a) << endl;
typedef long long ll;

int main() {
   int n;
   cin >> n;
   bool p[60000];
   for( int i = 0; i <= 56000; i++ ) p[i] = true;
   for( int i = 2; i*i <= 55555; i++ ) {
       if( p[i] ) {
           for( int j = 0; i*(j+2) <= 55555; j++ ) {
               p[i*(j+2)] = false;
           }
       }
   }
   int cnt = 0;
   for( int i = 2; i <= 55555; i++ ) {
       if( p[i] && i%5 == 1 ) {
           dump(i);
           cnt++;
       }
       if( cnt == n ) break;
   }
   return 0;  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vl vector<ll>

int main() {

    ll K;
    cin >> K;

    queue<ll> q;
    for (ll i = 1; i < 10; ++i) {
        q.push(i);
    }

    ll x;
    for (ll i = 0; i < K; ++i) {
        x = q.front();
        q.pop();
        if (x % 10 > 0) q.push(10*x + x%10 - 1);
        q.push(10*x + x%10);
        if (x % 10 < 9) q.push(10*x + x%10 + 1);
    }

    cout << x << endl;

    return 0;
}


Measured memory_bytes: 5124
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long LL;
const int MAXN = 125555;
LL a[MAXN], b[MAXN], c[MAXN], d[MAXN];
bool vis[MAXN];
const double eps = 1e-2;
inline int sgn(double x) {
	return x < -eps ? -1 : x > eps;
}

int main() {
	int n;
	while (scanf("%d", &n) != EOF && n) {
		int m = n * (n + 1) / 2;
		int cn = 0, dn = 0;
		for (int i = 0; i < m; i++) {
			scanf("%lld", &b[i]);
			if (!(b[i] & 1)) {
				c[cn++] = b[i];
			} else {
				d[dn++] = b[i];
			}
		}
		sort(c, c + cn);
		sort(d, d + dn);
		a[0] = (long long)(sqrt((double(c[0]) * c[1] / d[0])) + 0.5);
		/*for (LL x = max(0LL, a[0] - 500); ; x++) {
			if (sgn(double(x) * x * d[0] - ((double)c[0] * c[1])) == 0) {
				a[0] = x;
				break;
			}
		}*/
		printf("%lld\n", a[0]);
		for (int i = 0; i < cn; i++) {
			if (i) putchar(' ');
			printf("%lld", c[i] / a[0]);
		}
		puts("");
	}
}

Measured memory_bytes: 1720
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  cout << (n+1)/2 << endl;
}

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

int w, a, b;

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

	cin >> w >> a >> b;
	
	if (max(a, b) <= min(a+w, b+w)) {
		cout << 0 << '\n';
	}
	else {
		cout << min(abs((a+w) - b), abs(a - (b+w))) << '\n';
	}

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    int[] ps = new int[n];

    for (int i = 0; i < q; i++) {
      int p = sc.nextInt();
      ps[p - 1] = ps[p - 1] + 1;
    }

    for (int p : ps) {
      if (p + k - q > 0) {
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }
    }
  }
}

Measured memory_bytes: 50792
D=int(input())
c=[int(x) for x in input().split()]
s=[[0]*i for i in range(D)]
t=[]
last_d=[0]*26
for i in range(D):
  s[i]=[int(x) for x in input().split()]
for i in range(D):
  t.append(int(input()))

v=0
for i in range(D):
  a=0
  for j in range(26):
    if j!=t[i]-1:
      n=i+1-last_d[j]
      a+=c[j]*n
  v=v+s[i][t[i]-1]-a
  print(v)
  last_d[t[i]-1]=i+1

Measured memory_bytes: 9828
package main
import "fmt"
import "sort"
func main(){
    var n, k int
    fmt.Scan(&n, &k)
    h := make([]int, n)
    for i := range h{
        fmt.Scan(&h[i])
    }
    sort.Sort(sort.Reverse(sort.IntSlice(h)))
    var sum int
    for i := range h{
        if i >= k{
            sum += h[i]
        }
    }
    fmt.Println(sum)
}


Measured memory_bytes: 6656
#include<iostream>
#include<cstdio>
#include <vector>
using namespace std;
bool used[8][8];
   int n, m;
 
bool check(int x, int y){
	return x >= 0 && x < n && y >= 0 && y < m;	
}
int main(){
    cin >> n >> m;
    char a[8][8];
    for (int i = 0; i< n; i++)
    	for (int j = 0; j < m; j++){
    		cin >> a[i][j];
    	}
    int curx = 0;
    int cury = 0;
    if (a[0][0] == '#'){
    while (curx != n - 1 || cury != m - 1){
    	used[curx][cury] = 1;
    	int hod1 = 0, hod2 = 0;
    	if (check(curx + 1, cury) && a[curx + 1][cury] == '#'){
    		hod1 = 1;	
    	}
    	if (check(curx, cury + 1) && a[curx][cury + 1] == '#'){
    		hod2 = 1;
    	}
    	if (hod1 && hod2)
    	{
    		cout << "Impossible\n";
    		return 0;
    	}
    	if (!hod1 && !hod2){
    		cout << "Impossible\n";
    		return 0;
    	}
    	if (hod1){
    		curx = curx + 1;
    		used[curx][cury] = 1;
    	}else
    	{
    		cury = cury+1;
    		used[curx][cury] = 1;
    	}
    }
    }
    for (int i = 0; i < n; i++)
    	for (int j = 0; j < m; j++){
    		if (a[i][j] == '#' && !used[i][j]){
    		cout << "Impossible\n";
    		return 0;
    	}
    	}
    cout << "Possible\n";
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    char a;
    cin >> a;
    if(a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
        cout << "vowel" << endl;
    else 
        cout << "consonant" << endl;

    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func solve() {
	var A, B int
	fmt.Scan(&A, &B)
	var S string
	fmt.Scan(&S)

	for i, s := range S {
		if i < A {

			if s == '-' {
				fmt.Println("No")
				return

			}
		} else if i == A {
			if s != '-' {
				fmt.Println("No")
				return

			}

		} else {
			if s == '-' {
				fmt.Println("No")
				return

			}

		}
	}
	fmt.Println("Yes")
}

func main() {
	solve()
}


Measured memory_bytes: 512
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define REV(i,a,n) for(int i=n;i>=a;--i)
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define show(n) cerr<<#n<<" = "<<n<<endl
#define showp(n) cerr<<n.fs<<", "<<n.sc<<endl
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl
#define showsp(n) for(auto z:n){cerr<<z.fs<<" "<<z.sc<<", "}cerr<<endl

#define yes puts("Yes")
#define no puts("No")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

inline void io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}
template<typename T> inline void in(T &e){cin>>e;}
template<typename T> inline void out(T e){cout<<e<<endl;}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

int n,k;
int ans=0;

signed main(){
    io();
    cin>>n>>k;
    if(k==0){
        ans=n*n;
    }else{
        REP(b,k+1,n+1){
            ans+=(n/b)*(b-k);
            //show(n%b-k+1);
            int x=(n%b-k+1>=0)?n%b-k+1:0;
            //show(x);
            ans+=x;
        }
    }
    
    out(ans);

    return 0;
}


Measured memory_bytes: 256
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

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

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {//228
	int n;
	cin>>n;
	if(n==7||n==5||n==3)cout<<"YES";
	else cout<<"NO";
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3636
#include<stdio.h>
int main(void){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a%3==0||b%3==0||(a+b)%3==0){
        printf("Possible\n");
    }
    else{
        printf("Impossible\n");
    }
    return 0;
}

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

class Program
{
    static void Main(string[] args) {
        long[] s = Console.ReadLine().Split().Select(long.Parse).ToArray();
        long x = s[0];
        long y = s[1];
        Console.WriteLine(solve(x, y));
    }
    static long solve(long x, long y) {
        List<long> a = new List<long>();
        while(x <= y) {
            a.Add(x);
            x *= 2;
        }
        return a.Count();
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include <set>
using namespace std;
typedef long long ll;

int a[55],b[55];


int n;
int che(int u,int j)
{

	int chec=0;
	for (int i=1; i<=n; i++) if (u==a[i]&&j==b[i]) chec=1;
	
	return chec;
}
int dfs(int x,int y)
{
	int dx=a[y]-a[x];
	int dy=b[y]-b[x];
	
	
	int sum=0;
	for (int i=1; i<=n; i++)
	    if (che(a[i]+dx,b[i]+dy)) sum++;
	
	
	return sum; 
	
}
int main()
{
	cin>>n;
	for (int i=1; i<=n; i++) 
	{
		cin >> a[i]>> b[i];		
	}
	
	int ans=0;
	for (int i=1; i<=n; i++)
	    for (int j=1; j<=n; j++)
	        if (j!=i) ans=max(ans,dfs(i,j));
	        
    cout << n-ans;
}

Measured memory_bytes: 384
import java.util.*;
import java.lang.*;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();
		System.out.println((n + 1 - h) * (n + 1 - w));
	}
}

Measured memory_bytes: 22868
#include <iostream>
#include <fstream>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long ll;
typedef pair<int,int> PP;

/*
    freopen("input","r",stdin);
    freopen("output","w",stdout);
*/

ll cal(ll x) {
	// Calculate y that can be get from or operation in (0 - x)
	ll t = 1;
	while (x > 0) {
		t *= 2;
		x /= 2;
	}
	return t - 1;
}

int main() {
    ios::sync_with_stdio(false);
    ll a, b, A, B;
    cin >> a >> b;
    if (a == b) {
    	cout << 1 << endl;
    	return 0;
    }
    A = a;
    B = b;
    ll rem = 1LL << 62;
    while (1 > 0) {
    	if (A / rem != B / rem) break;
    	rem /= 2;
    }
    ll x = a % rem;
    ll y = b % rem;
    ll t = cal(y);
    ll ans;
    if (t >= x) {
    	ans = rem - x + rem;
    }
    else {
    	ans = (rem - x) * 2 + (t + 1);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int a[1001][1001];

int main() {
    int h, w;
    cin >> h >> w;
    for (int i = 0; i < h; ++i) {
        string s;
        cin >> s;
        for (int j = 0; j < w; ++j) {
            a[i][j] = s[j] == '#' ? 0 : 2001;
        }
    }
    for (int i = 0; i < h; ++i) {
        for (int j = 1; j < w; ++j) {
            a[i][j] = min(a[i][j], a[i][j - 1] + 1);
        }
        for (int j = w - 2; j >= 0; --j) {
            a[i][j] = min(a[i][j], a[i][j + 1] + 1);
        }
    }
    for (int j = 0; j < w; ++j) {
        for (int i = 1; i < h; ++i) {
            a[i][j] = min(a[i][j], a[i - 1][j] + 1);
        }
        for (int i = h - 2; i >= 0; --i) {
            a[i][j] = min(a[i][j], a[i + 1][j] + 1);
        }
    }
    int answer = 0;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            answer = max(answer, a[i][j]);
        }
    }
    cout << answer << endl;
}


Measured memory_bytes: 4096
#128_C
n,m=map(int,input().split())
sw=[]
for _ in range(m):
    k,*s=map(int,input().split())
    sw.append(s)
p=list(map(int,input().split()))

ans=0
for i in range(2**n):
    L=[(i>>j)&1 for j in range(n)]
    if all([sum([L[s-1] for s in sw[k]])%2==p[k] for k in range(m)]):
        ans+=1
print(ans)

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

A.sort()

first_edge = -1
second_edge = -1

used = [False for i in range(N)]
for i in range(N - 1, 0, -1):
    if first_edge < 0 and A[i] == A[i - 1] and (not used[i]) and (not used[i - 1]):
        first_edge = A[i]
        used[i] = True
        used[i - 1] = True
    if first_edge > 0 and A[i] == A[i - 1] and (not used[i]) and (not used[i - 1]):
        second_edge = A[i]
        break
        
if first_edge < 0 or second_edge < 0:
    print(0)
else:
    print(first_edge * second_edge)

Measured memory_bytes: 14244
#include<bits/stdc++.h>
#define inf 10000
using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[n+3];
    int dp[100001];

    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        dp[i]=inf;
    }
    dp[0]=0;
    dp[1]=0;
    dp[2]=abs(a[0]-a[1]);
    for(int i=3;i<n+1;i++)
    {
        int l1=dp[i-1]+abs(a[i-2]-a[i-1]);
        int l2=dp[i-2]+abs(a[i-3]-a[i-1]);

        dp[i]=min(l1,l2);
    }

    cout<<dp[n];


}



Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] arg) {
		Scanner in = new Scanner(System.in);
		while (in.hasNext()) {
			int[] nums = new int[101];
			int max = 2;
			while (nums[0] != 2) {
				int num = in.nextInt();
				nums[num] += 1;
				max = Math.max(max, num);
			}
			String s = "NG";
			if (nums[1] % 2 == 1 && nums[2] % 2 == 1) {
				s = "OK";
				for (int i = 3; i <= max; i++) {
					if (nums[i] != 0 && nums[i] % 2 == 1) {
						s = "NG";
						break;
					}
				}
			}
			System.out.println(s);
		}
	}
}

Measured memory_bytes: 21076
#include<bits/stdc++.h>
using namespace std; 
double t[200005];
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        cin>>t[i];
        t[i]=(t[i]+1)/2;
    }
    double max1,sum;
    for(int i=0;i<m;i++)
        max1+=t[1+i];
        sum=max1;
    for(int i=2;i<=n-m+1;i++)
    {
        sum=sum-t[i-1]+t[i+m-1];
        max1=max(sum,max1);
    }
 
    cout << fixed << setprecision(12)<<max1;

    return 0;
}


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

using namespace std;

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

  string a, b;
  cin >> a >> b;
  int asz = a.size();
  int bsz = b.size();
  string res;
  if (asz > bsz || (asz == bsz && a > b)) res = "GREATER";
  else if (a == b) res = "EQUAL";
  else res = "LESS";
  cout << res << endl;

  return 0;
}



Measured memory_bytes: 256
//includes
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#include<assert.h>
#include<cstring>
#include<unordered_map>
#include<bitset>

//macros and consts
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define FORE(i,a) for(auto &i : a)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define accm accumulate
#define Fi first
#define Se second
#define INF 1e9
#define llINF (1LL<<60)
#define mINF -1e9
#define mllINF -(1LL<<60)
#define endl "\n"
#define CONT continue
#define BRK break
#define modulo(n, m) (((n)%(m)+(m))%m)

//shorter types
using namespace std;
using ll = long long;
using vi = std::vector<int>;
using vc = std::vector<char>;
using vll = std::vector<long long>;
using vs = std::vector<string>;
using Mi = map<int,int>;
using Mll = map<ll,ll>;
using UMi = unordered_map<int,int>;
using UMll = unordered_map<ll,ll>;
using Pi = pair<int,int>;
using Pll = pair<ll,ll>;
using vPi = vector<Pi>;
using vPll = vector<Pll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pqgi = priority_queue<int,vector<int>,greater<int>>;
using pqsi = priority_queue<int,vector<int>,less<int>>;
using pqgll = priority_queue<int,vector<int>,greater<int>>;
using pssll = priority_queue<int,vector<int>,less<int>>;
template<class T>
using vec = vector<T>;

//here begins your code
//

long factorial(int k){
	long sum = 1;
	for(int i = 1 ; i <= k ; i++){
		sum = sum * i;
	}
	return sum;
}

template<typename T>
class BIT {
    int N;
    vector<T> data;
public:
    BIT(int N) : N(N) {
        data.resize(N + 1, 0);
    }

    T sum(int k) {
        T res = 0;
        for (; k > 0; k -= k & -k) {
            res += data[k];
        }
        return res;
    }

    void add(int k, T x) {
        for (; k <= N; k += k & -k) {
            data[k] += x;
        }
    }

    int lowerBound(int w) {
        if (w <= 0) return 0;
        int x = 0;
        int k = 1;
        while (k * 2 <= N) k *= 2;
        for (; k > 0; k /= 2) {
            if (x + k <= N && data[x + k] < w) {
                w -= data[x + k];
                x += k;
            }
        }
        return x + 1;
    }
};

signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int N;
  vi P;
  vi Q;
  cin >> N;
  P.resize(N);
  Q.resize(N);

  for(int i = 0 ; i < N ; i++){
  	cin >> P[i];
  }
  for(int i = 0 ; i < N ; i++){
  	cin >> Q[i];
  }

  long a = 0;
  long b = 0;

  BIT<int> bit1(N);
  BIT<int> bit2(N);

  for(int i = 0 ; i < N; i++){
  	a += ((P[i] - 1) - bit1.sum(P[i] - 1)) * factorial(N - i - 1);
  	bit1.add(P[i],1);
  }


  for(int i = 0 ; i < N; i++){
  	b += ((Q[i] - 1) - bit2.sum(Q[i] - 1)) * factorial(N - i - 1);
  	bit2.add(Q[i],1);
  }


  cout << abs(a - b) << endl;

  //check types
  //do not eb if you resize
  //resize before you access by idx
  return 0;
} 

Measured memory_bytes: 256
import java.util.*;

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

        long n = sc.nextInt();
        long a = sc.nextInt();
        long b = sc.nextInt();

        if(a > b){
            System.out.println(0);
        }else if(n == 1){
            if(a == b){
                System.out.println(1);
            }else{
                System.out.println(0);
            }
        }else{
            System.out.println((b - a) * (n - 2) + 1);
        }
    }
}

Measured memory_bytes: 23764
use std::io::*;
use std::str::FromStr;

fn main() {
    let s: Vec<char> = read::<String>().chars().collect();
    let mut cnt = 0;
    for i in 0..s.len() {
        if s[i] == 'o' {
            cnt += 1;
        }
    }
    let k = s.len();
    println!("{}", 
        if cnt + (15 - k) >= 8 {
            "YES"
        } else {
            "NO"
        });
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String W = in.next().toLowerCase();
		String T = new String();
		int cnt = 0;
		while (!in.hasNext("END_OF_TEXT")) {
			T = in.next().toLowerCase();
			if (T.matches(W)) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 19896
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			long k = in.nextLong();
			long[] a = in.nextLongArray(n);

			long max = -1;
			for (int i = 0; i < n; i++) {
				max = Math.max(max, a[i]);
			}

			if (k > max) {
				out.println("IMPOSSIBLE");
				return;
			}

			long gcd = a[0];
			for (int i = 1; i < n; i++) {
				gcd = gcd(gcd, a[i]);
			}

			out.println(k % gcd == 0 ? "POSSIBLE" : "IMPOSSIBLE");

		}
	}

	public static long gcd(long a, long b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


Measured memory_bytes: 33916
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define PPC(x) __builtin_popcount((x))
#define ALL(x) (x).begin(), (x).end()
#define pb push_back
using namespace std;

const int maxN = 342;

char T[maxN];
stack <int> S;
int visCtr, vis[maxN][maxN], dp[maxN][maxN][2], End[maxN];

void go(int a, int b)
{
	if (vis[a][b] == visCtr)
		return;
		
	vis[a][b] = visCtr;
	if (a == b)
	{
		dp[a][b][0] = T[a] != '0';
		dp[a][b][1] = T[a] != '1';
		return;
	}
	
	int c = End[a+1] + 1;
	go(a+1, c-1);
	go(c+1, b-1);
	
	if (T[c] == '&')
	{
		dp[a][b][0] = min(dp[a+1][c-1][0], dp[c+1][b-1][0]);
		dp[a][b][1] = dp[a+1][c-1][1] + dp[c+1][b-1][1];
	}
	
	if (T[c] == '|')
	{
		dp[a][b][0] = dp[a+1][c-1][0] + dp[c+1][b-1][0];
		dp[a][b][1] = min(dp[a+1][c-1][1], dp[c+1][b-1][1]);
	}
	
	if (T[c] == '^')
	{
		dp[a][b][0] = min(dp[a+1][c-1][0] + dp[c+1][b-1][0], dp[a+1][c-1][1] + dp[c+1][b-1][1]);
		dp[a][b][1] = min(dp[a+1][c-1][0] + dp[c+1][b-1][1], dp[a+1][c-1][1] + dp[c+1][b-1][0]);
	}
}

void solve()
{
	scanf ("%s", T);
	int n = strlen(T);
	FOR(i, 0, n)
	{
		if (T[i] == '(')
			S.push(i);
		
		else if (T[i] == ')')
		{
			End[S.top()] = i;
			S.pop();
		}
		
		else
			End[i] = i;
	}
	assert(S.empty());
	
	visCtr++;
	go(0, n-1);
	printf("%d\n", min(dp[0][n-1][0], dp[0][n-1][1]));
}

int main()
{
	int n, k;
	scanf ("%d%d", &n, &k);
	
	if (k == 1)
		printf("0\n");
	
	else
		printf("%d\n", n-k);
	
	return 0;
}


Measured memory_bytes: 256