akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void) {
	int N[3], count5 = 0, count7 = 0;

	if (scanf("%d %d %d", &N[0], &N[1], &N[2]) >= 10) return 0;
	
	for (int i = 0; i < 3; i++) {
		if (N[i] == 5)count5++;
		if (N[i] == 7)count7++;
	}

	if (count5 == 2 && count7 == 1)printf("YES\n");
	else printf("NO\n");
	

	return 0;

}

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

#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif

int readInt() {
	int n, c;
	while ((c = getchar()) < '0');
	n = c - '0';
	while ((c = getchar()) >= '0') {
		n = n * 10 + c - '0';
	}
	return n;
}

const int N = 5000;
const int M = 200;

struct Stack {
	short dat[N + 1];
	short sp;

	void push(short v) {
		dat[sp++] = v;
	}

	void pop() {
		sp--;
	}

	short fst() {
		return dat[sp - 1];
	}

	short snd() {
		return dat[sp - 2];
	}
};

int n, m;
Stack mono[M];
int b[N + 1][M];
long long a[N];

struct Tuple {
	long long val, imos;
};
Tuple tup[N + 1];

int main() {
	n = readInt();
	m = readInt();
	for (int i = 1; i < n; i++) {
		a[i] = readInt() + a[i - 1];
		tup[i].val -= a[i];
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			b[i][j] = readInt();
		}
	}
	for (int i = 0; i < m; i++) {
		b[n][i] = 2e9;
		mono[i].push(n);
	}

	long long ans = 0;
	for (int i = n - 1; i >= 0; i--) {
		for (int j = 0; j < m; j++) {
			while (b[mono[j].fst()][j] <= b[i][j]) {
				int l = mono[j].fst();
				int r = mono[j].snd();
				int v = b[l][j];
				mono[j].pop();
				tup[l].imos -= v;
				tup[r].imos += v;
			}
			mono[j].push(i);
			int l = mono[j].fst();
			int r = mono[j].snd();
			tup[l].imos += b[i][j];
			tup[r].imos -= b[i][j];
		}
		long long u = -1e18;
		for (int j = i; j < n; j++) {
			tup[j + 1].imos += tup[j].imos;
			tup[j].val += tup[j].imos;
			tup[j].imos = 0;
			u = max(u, tup[j].val);
		}
		ans = max(ans, u + a[i]);
	}
	cout << ans << endl;
}


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

class Program
{
    static void Main()
    {
        Console.WriteLine(Solve());
        //Solve();
        return;
    }

    public static string Solve()
    {
        int[] input = ReadInts();
        int S = input[0];
        int W = input[1];
        if (W >= S)
        {
            return "unsafe";
        }
        else
        {
            return "safe";
        }
    }

    public static int Gcd(int a, int b)
    {
        if (a < b)
            return Gcd(b, a);
        while (b != 0)
        {
            var remainder = a % b;
            a = b;
            b = remainder;
        }
        return a;
    }

    private static string Read() { return Console.ReadLine(); }
    private static int ReadInt() { return int.Parse(Read()); }
    private static long ReadLong() { return long.Parse(Read()); }
    private static double ReadDouble() { return double.Parse(Read()); }
    private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
    private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
    private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
}


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

int main() {
  string s;
  cin >> s;
  bool ans = false;
//解法1
  //OOXX
  if ((s[0] == s[1]) && (s[2] == s[3]) && (s[1] != s[2])) {
    ans = true;
  }
  //OXOX
  if ((s[0] == s[2]) && (s[1] == s[3]) && (s[1] != s[2])) {
    ans = true;
  }
  //OXXO
  if ((s[0] == s[3]) && (s[1] == s[2]) && (s[0] != s[1])) {
    ans = true;
  }

/*
  //解法2(sort)
  sort(s.begin(), s.end());
  //OOXX
  if ((s[0] == s[1]) && (s[2] == s[3]) && (s[1] != s[2])) {
    ans = true;
  }
*/
  if (ans) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
	long x;
	cin>>x;
	long res=0;
	if(x/500>0){
		res += (x/500)*1000;
		x=x%500;
	}
	if(x/5>0)
		res += (x/5)*5;
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
before = [input() for s in range(h)]

after = []
for i in range(h):
    row = ''
    for j in range(w):
        tmp = ''
        if before[i][j] == '.':
            for i2 in (i-1, i, i+1):
                for j2 in (j-1, j, j+1):
                    if (i2 == i and j2 == j) or (0 > i2) or (h <= i2) or (0 > j2) or (w <= j2):
                        continue
                    else:
                        tmp += before[i2][j2]
            row += str(tmp.count('#'))
        else:
            row += '#'
    after.append(row)

for row in after:
    print(row)


Measured memory_bytes: 3064
import java.io._;

object Main {

	def main(arg:Array[String]) = {
		// val in = scala.io.StdIn.readLine();
    val in = new BufferedReader(new InputStreamReader(System.in))
    val line = in.readLine();
		if(line.contains('a') && line.contains('b') && line.contains('c')) println("Yes");
		else println("No");
	}
}


Measured memory_bytes: 25300
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N := ReadInt()
	S := ReadString()

	dp := make([][]int, N+1)
	for i := 0; i < N+1; i++ {
		dp[i] = make([]int, N+1)
	}
	for i := N - 1; i >= 0; i-- {
		for j := N - 1; j >= 0; j-- {
			if S[i] == S[j] {
				dp[i][j] = 1 + dp[i+1][j+1]
			}
		}
	}

	ans := 0
	for i := 0; i < N-1; i++ {
		for j := i + 1; j < N; j++ {
			ans = Max(ans, Min(dp[i][j], j-i))
		}
	}
	fmt.Println(ans)
}

func Max(xs ...int) int {
	max := xs[0]
	for _, x := range xs[1:] {
		if max < x {
			max = x
		}
	}
	return max
}

func Min(xs ...int) int {
	min := xs[0]
	for _, x := range xs[1:] {
		if min > x {
			min = x
		}
	}
	return min
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 209472
#include <bits/stdc++.h>
 
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
// #define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
 
struct S002 {
  int n;
  S002& operator > (long& x) {
    n = x;
    return *this;
  }
  S002& operator > (long&& x) {
    n = x;
    return *this;
  }
  S002& operator >= (long& x) {
    if( scanf("%ld", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (double& x) {
    if( scanf("%lf", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (std::string& s) {
    if( not (std::cin >> s) ) exit(0);
    return *this;
  }
  template<typename a>
  S002& operator >= (std::vector<a>& v) {
    v.resize(n);
    for(long i = 0; i < n; ++i) {
      *this >= v[i];
    }
    return *this;
  }
  template<typename a, std::size_t s>
  S002& operator >= (std::array<a, s>& x) {
    for(long i = 0; i < (long)s; ++i) {
      *this >= x[i];
    }
    return *this;
  }
};


struct Solver {
  long a, b, c;
  Solver() {
    S002 reader;
    reader >= a >= b >= c;
  }
  void solve() {
    for(long i = 1; i <= b; ++i) {
      if( (a * i) % b == c ) {
        puts("YES");
        return;
      }
    }
    puts("NO");
  }
    
  ~Solver() { fprintf(stderr, "--end--\n"); }
};
 

int main() {
  loop std::unique_ptr<Solver>(new Solver())->solve();
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;
// A utility function that returns maximum of two integers
ll max(ll a, ll b)
{
    return (a > b) ? a : b;
}

// Returns the maximum value that can be put in a knapsack of capacity W
ll knapSack(ll W, ll wt[], ll val[], ll n)
{
    ll i, w;
    ll K[n + 1][W + 1];

    // Build table K[][] in bottom up manner
    for (i = 0; i <= n; i++)
    {
        for (w = 0; w <= W; w++)
        {
            if (i == 0 || w == 0)
                K[i][w] = 0;
            else if (wt[i - 1] <= w)
                K[i][w]
                        = max(val[i - 1] + K[i - 1][w - wt[i - 1]], K[i - 1][w]);
            else
                K[i][w] = K[i - 1][w];
        }
    }

    return K[n][W];
}

int main()
{
    //cout << "Enter the number of items in a Knapsack:";
    int n, W;
    cin >> n;
    //cout << "Enter the capacity of knapsack";
    cin >> W;
    ll val[n], wt[n];
    for (int i = 0; i < n; i++)
    {
        //cout << "Enter value and weight for item " << i << ":";
         cin >> wt[i];
        cin >> val[i];

    }

    //    int val[] = { 60, 100, 120 };
    //    int wt[] = { 10, 20, 30 };
    //    int W = 50;

    cout << knapSack(W, wt, val, n);

    return 0;
}


Measured memory_bytes: 82408
#include<iostream>
#include<iomanip>
#define M_PI 3.14159265358979
using namespace std;

int main() {
	double r;
	cin >> r;
	cout << fixed << setprecision(10) << M_PI * r * r << " " << 2 * M_PI * r << endl;
	return 0;
}

Measured memory_bytes: 1288
#%%
import math

# 素数判定関数
def isPrime(num):
    # 2未満の数字は素数ではない
    if num < 2: return False
    # 2は素数
    elif num == 2: return True
    # 偶数は素数ではない
    elif num % 2 == 0: return False

    # 3 ~ numまでループし、途中で割り切れる数があるか検索
    # 途中で割り切れる場合は素数ではない
    for i in range(3, math.floor(math.sqrt(num))+1, 2):
        if num % i == 0:
            return False

    # 素数
    return True

# 素数判定
def callIsPrime(input_num=1000):
    numbers = []
    # ループしながら素数を検索する
    for i in range(1, input_num):
        if isPrime(i):
            numbers.append(i)

    # 素数配列を返す
    return numbers

# 関数の呼び出し
l = callIsPrime(20 ** 3)
ll = []
for i in range(len(l)):
    tmp = str(l[i])
    if tmp[-1] == '1':
        ll.append(l[i])

#print(ll)

n = int(input())
ans_list = ll[:n]
for i in range(len(ans_list)):
    ans_list[i] = str(ans_list[i])
print(' '.join(ans_list))



# %%


Measured memory_bytes: 3064
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		int[] odd = new int[n];
		int sum = 1;
		for(int i = 0;i < n;i++){
			int num = saori.saori_hayami();
			if(num % 2 == 0){
				odd[i] = odd[i] + 2;
			} else {
				odd[i]++;
			}
			sum *= 3;
		}
		int oddsum = 1;
		for(int i = 0;i < n;i++){
			oddsum *= odd[i];
		}
		System.out.println(sum-oddsum);
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define all(x) (x).begin(),(x).end()
#define print(x) if(x)cout<<"YES\n";else cout<<"NO\n";
#define f(i,x,y) for(ll i=x;i<=y;i++)
#define rf(i,x,y) for(ll i=x;i>=y;i--)
#define pb push_back
#define F first
#define S second
using namespace std;
int main()
{
// #ifndef HP
//   freopen("in.txt", "r", stdin);
//   freopen("out.txt", "w", stdout);
// #endif

  fastio;
  int t = 1;
  //cin >> t;
  while (t--)
  {
    ll n;
    cin >> n;
    bool flag = 0;
    ll   p = 0;
    for (ll i = 0; i < n; i++)
    {
      ll a, b;
      cin >> a >> b;
      if (a == b)
      {
        p++;
        if (p >= 3)
          flag = 1;

      }
      else
      {
        p = 0;
      }
    }
    if (flag)
      cout << "Yes";
    else
      cout << "No";
  }
}


Measured memory_bytes: 3656
#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
    double a;

    cout << setprecision(7) << fixed;
    while (cin >> a) {
        double ans = a;

        for (int i = 2; i <= 10; i++) {
            if (i % 2) 
                a /= 3.0;
            else 
                a *= 2.0;
            ans += a;
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1276
#include <iostream>

using namespace std;

class dice {
public:
    int face[6];
    void rotate(char dir) {
        int temp;
        switch(dir) {
        case 'N':
            temp = face[0];
            face[0] = face[1];
            face[1] = face[5];
            face[5] = face[4];
            face[4] = temp;
            break;
        case 'E':
            temp = face[0];
            face[0] = face[3];
            face[3] = face[5];
            face[5] = face[2];
            face[2] = temp;
            break;
        case 'W':
            temp = face[0];
            face[0] = face[2];
            face[2] = face[5];
            face[5] = face[3];
            face[3] = temp;
            break;
        case 'S':
            temp = face[0];
            face[0] = face[4];
            face[4] = face[5];
            face[5] = face[1];
            face[1] = temp;
            break;
        }
    }
    bool operator==(const dice &d) {
        for(int i=0; i<6; i++) {
            if(face[i] != d.face[i]) return false;
        }
        return true;
    }
    bool isSame(dice &d) {
        const char *dir = "EEENWWWS";
        for(int i=0; i<24; i++) {
            if(*this == d) return true;
            d.rotate(dir[i%8]);
        }
        return false;
    }
};

dice d[100];

int main()
{
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for(int i=0; i<n; i++) {
        for(int j=0; j<6; j++) {
            cin >> d[i].face[j];
        }
        for(int k=0; k<i; k++) {
            if(d[i].isSame(d[k])) {
                cout<<"No\n";
                return 0;
            }
        }
    }
    cout<<"Yes\n";
    return 0;
}

Measured memory_bytes: 1172
while True:
    n, w, h = map(int, input().split())
    if w == 0:
        break
    ls = [[w, h]]
    for i in range(n):
        p, s = map(int, input().split())
        p -= 1
        pw, ph = ls[p]
        if s % (pw + ph) < pw:
            s %= pw + ph
            ls.extend([[min(s, pw - s), ph], [max(s, pw - s), ph]])
        else:
            s = (s - pw) % (ph + pw)
            ls.extend([[pw, min(s, ph - s)], [pw, max(s, ph - s)]])
        ls.pop(p)
    # print(ls)
    ans = sorted([hi * wi for wi, hi in ls])
    print(' '.join(map(str, ans)))



Measured memory_bytes: 5628
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 105
#define INF 1000000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000005;
const int MOD = 1000000007;
int main(){
    int n,m;
    cin>>n>>m;
    vector<P>a(m);
    REP(i,m){
        int x,y;
        cin>>x>>y;
        x--;
        y--;
        a[i]={x,y};
    }
    sort(ALL(a));
    int l=0;
    int r=n-1;
    int ans=0;
    REP(i,m){
        if(l<=a[i].first&&a[i].first<r){
            l=max(l,a[i].first);
            r=min(r,a[i].second);
        }else{
            ans++;
            l=a[i].first;
            r=a[i].second;
        }
        //cout<<l<<" "<<r<<endl;
    }
    ans++;
    OUT(ans);
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i; i < N; i++) cin >> vec[i];
  sort(vec.begin(), vec.end());
  reverse(vec.begin(),vec.end());

  int alice = 0, bob = 0;
  for (int i; i < N; i++) {
    if (i%2 == 0) alice += vec[i];
    else bob += vec[i];
  }
  cout << alice - bob << endl;
}

Measured memory_bytes: 3592
# include <bits/stdc++.h>
using namespace std; 
int main(){
	int n , k;
	string s;
	cin >> n >> k >> s;
	int cnt = 0 , res = 0 , L = 0 , R = 0 , stL = 0 , stR = 0 , enL = 0 , enR = 0;
	for(int i = 1; i < n; i ++){
		if(s[i] != s[i - 1]){
			if(s[i - 1] == 'L')L ++;
			if(s[i - 1] == 'R')R ++;
			res += cnt;
			cnt = 0;
		}
		else
			cnt ++;
	}
	res += cnt;
	if(s[n - 1] == 'R') enR = 1 , R ++; else enL = 1 , L ++;
	if(s[0] == 'L') stL = 1; else stR = 1;
	R -= stR + enR;
	L -= stL + enL;
	L = min(L , k);
	R = min(R , k);
	res += max(L * 2 + min(k - L , stL + enL) , R * 2 + min(k - R , stR + enR));
	cout << res << "\n";
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define in(x, a, b) (a <= x && x < b)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
const ll inf = 1000000001, INF = (ll)1e18 + 1;

void solve() {
	int n, k;
	cin >> n >> k;
	
	int ans = 0;
	for(int i = 0; i < n; i++) {
		int h;
		cin >> h;
		if(h  >= k) ans++;
	}
	
	cout << ans << endl;
}

int main() {
	ios_base::sync_with_stdio(false);
	solve();
    return 0;
}

Measured memory_bytes: 3560
#if 0
????????£?????????????´?1?????????
?°?????????¨?????£??????????????????????????§?????????
???????????????????????°????????????????±?legal??¢??°?????????????????¨?????????????????????
x<h???y<w???????????????????????????
#endif

#include <iostream>
#include <queue>
using namespace std;
int w,h;
int g[21][21];
bool visited[21][21];
int moves[4][2]={{-1,0},{1,0},{0,-1},{0,1}};
int count;
bool legal(int x, int y)
{
  if(visited[x][y]!=true&&0<=x&&x<h&&0<=y&&y<w&&g[x][y]==0)
    return true;
  else
    return false;
}

void dfs(int x,int y)
{
  visited[x][y]=true;
  count++;
  for(int i=0;i<4;i++)
  {
    int newx=x+moves[i][0];
    int newy=y+moves[i][1];
    if(legal(newx,newy))
    {
      dfs(newx,newy);
    }
  }
}

int main()
{
  while(1)
  {
    cin>>w>>h;
    if(w==0&&h==0) break;
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
      {
        g[i][j]=-1;
        visited[i][j]=false;
      }
    int psx,psy;
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
      {
        char s;
        cin>>s;
        switch(s)
        {
          case '.':
            g[i][j]=0;break;
          case '#':
            g[i][j]=1;break;
          case '@':
            g[i][j]=2;psx=i;psy=j;break;
        }
      }
    count=0;
    dfs(psx,psy);
/*    int count=0;
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
      {
        count+=visited[i][j];
      }
*/  cout<<count<<endl;

  }
}

Measured memory_bytes: 3020
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
//#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define F first
#define S second


typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	int q; cin >> q;
	bool flag;
	vector<unsigned long long> print;
	bitset<64> b = 0;
	rep(z, q) {
		int qu, i; cin >> qu;
		switch (qu) {
		case 0:
			cin >> i;
			flag = b.test(i);
			print.pb(flag ? 1 : 0);
			break;
		case 1:
			cin >> i;
			b.set(i);
			break;
		case 2:
			cin >> i;
			b.reset(i);
			break;
		case 3:
			cin >> i;
			b.flip(i);
			break;
		case 4:
			flag = b.all();
			print.pb(flag ? 1 : 0);
			break;
		case 5:
			flag = b.any();
			print.pb(flag ? 1 : 0);
			break;
		case 6:
			flag = b.none();
			print.pb(flag ? 1 : 0);
			break;
		case 7:
			print.pb(b.count());
			break;
		case 8:
			unsigned long long num = b.to_ullong();
			print.pb(num);
			break;
		}
	}
	for (auto a : print) {
		cout << a << endl;
	}
}


Measured memory_bytes: 4828
#include<bits/stdc++.h>
#define REP(i,b,e) for(int i=b;i<e;i++)
using P = std::pair<int,int>;

struct Segtree {
	int len, n = 1;
	std::vector<P> tree;
	
	Segtree(int len): len(len) {
		while(n<len) n *= 2;
		tree.resize(2*n, P(0,0));
		REP(i, n, 2*n) tree[i] = P(0, i-n);
	}

	void update(int idx, int value){
		int i = n + idx;
		tree[i].first = value;
		while(i>>=1){
			if(tree[2*i].first > tree[2*i+1].first){
				tree[i] = tree[2*i];
			}else{
				tree[i] = tree[2*i+1];
			}
		}
	}

	P query(int left, int right){
		P x, y;
		x = y = P(0, 0);
		for(left+=n, right+=n; left<right; left>>=1, right>>=1){
			if(left&1){
				if(x.first < tree[left].first) x = tree[left];
				left++;
			}
			if(right&1){
				right--;
				if(y.first < tree[right].first) y = tree[right];
			}
		}
		if(x.first > y.first) return x;
		else return y;
	}
};

	

int main(){
	int n;
	scanf("%d", &n);
	int psg[n], cnt = 0;
	Segtree seg(300000);
	REP(i, 0, n){
		scanf("%d", &psg[i]);
		REP(j, 0, psg[i]){
			int c;
			scanf("%d", &c);
			seg.update(cnt++, c);
		}
	}

	long long ans = 0;
	int left, right;
	left = right = cnt;
	for(int i=n-1; i>=0; i--){
		left -= psg[i];
		P p = seg.query(left, right);
		ans += p.first;
		seg.update(p.second, 0);
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 11940
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
int main(){
  string S; cin >> S;
  if(S=="ABC"){
    cout << "ARC" << endl;
  } else {
    cout << "ABC" << endl;
  }
  return 0;
}

Measured memory_bytes: 3592
N,M=map(int,input().split())
X=list(map(int,input().split()))
X.sort()
mi=X[0]
ma=X[len(X)-1]
l=[]
c=0
#print(X)
#for i in (mi,ma+1,1):
for i in range(M-1):
    l.append(X[i+1]-X[i])
l.sort()
for i in range(len(l)-(N-1)):
    c=c+l[i]
print(c)

Measured memory_bytes: 56744
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
  int n;
  cin >> n;
  vector<int> x(n);
  for(int i = 0; i < n; i++){
    cin >> x.at(i);
  }
  ll min;
  for(int i = 0; i < n; i++){
  	min += (x[i] - 1) * (x[i] - 1); 
  } 
  for(int i = 1; i <= 100; i++){
    int sum = 0;
    for(int j = 0; j < n; j++){
      sum += (x[j] - i) * (x[j] - i);
    }
    if(sum < min){
      min = sum;
    }
  }
  cout << min;
}

Measured memory_bytes: 256
Imports System.Collections.Generic
	Imports System.Console
	Module Program
	    Sub Main()
	        Dim tmp As String() = Split(Console.ReadLine())
	        Dim a As Integer = tmp(0)
	        Dim b As Integer = tmp(1)
	        If a = 1 Then
	          a+=13
	        End If
	        If b = 1 Then
	          b+=13
	        End If
	        Dim res As String = "Draw"
	        If a>b Then
	           res = "Alice"
	        ElseIf a<b Then
	           res = "Bob"
	        Else
	           res = "Draw"
	        End If
	        Console.WriteLine(res)
	    End Sub
	End Module


Measured memory_bytes: 11488
s = input()
MOD = 10**9 + 7

dp = [[0 for i in range(13)] for j in range(2)]
if s[0] == '?':
    for i in range(10):
        dp[0][i] = 1
else:
    dp[0][int(s[0])] = 1

for i in range(1, len(s)):
    for j in range(13):
        dp[i%2][j] = 0

    if s[i] == '?':
        for j in range(13):
            for k in range(10):
                dp[i%2][(10*j+k)%13] = (dp[i%2][(10*j+k)%13] + dp[(i-1)%2][j]) % MOD
    else:
        k = int(s[i])
        for j in range(13):
            dp[i%2][(10*j+k)%13] = (dp[i%2][(10*j+k)%13] + dp[(i-1)%2][j]) % MOD

    # print(dp[(i-1)%2])
    # print(dp[i%2])
    # print()


print(dp[(len(s)-1)%2][5])


Measured memory_bytes: 44856
# -*- coding: utf-8 -*-
"""
Created on Tue Dec 19 13:54:17 2017

@author: kotania
"""

s = input()
t = input()

s_list = list(s)
t_list = list(t)

s_list.sort()
t_list.sort()
t_list.reverse()

if s_list <  t_list:
    print ("Yes")
else :
    print ("No")



Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i <= (int)(n); i++) 
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
typedef long long ll;

int main() {
    int k,x;
    cin >> k >> x;
    if(500*k >= x) dunk("Yes");
    else dunk("No");
    return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::*;
use std::f64::consts::*;
use std::f64;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        b: [[i32; 3]; 3],
        n: i32,
        v: [i32; n],
    }
    let mut b = b;
    for i in v {
        for j in 0..3 {
            for k in 0..3 {
                if i == b[j][k] {
                    b[j][k] = 0;
                }
            }
        }
    }
    if (b[0][0] + b[0][1] + b[0][2] == 0)
        || (b[1][0] + b[1][1] + b[1][2] == 0)
        || (b[2][0] + b[2][1] + b[2][2] == 0)
        || (b[0][0] + b[1][0] + b[2][0] == 0)
        || (b[0][1] + b[1][1] + b[2][1] == 0)
        || (b[0][2] + b[1][2] + b[2][2] == 0)
        || (b[0][0] + b[1][1] + b[2][2] == 0)
        || (b[0][2] + b[1][1] + b[2][0] == 0) {
        println!("Yes");
    } else {
        println!("No");
    }
}

Measured memory_bytes: 2096
///#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define int long long
///#define double long double
#define all(x) (x).begin(), (x).end()
#define finout(x) freopen(x".in", "r", stdin); freopen(x".out", "w", stdout);
#define X first
#define Y second

using namespace std;
const int MOD = 1e9 + 7;

typedef pair <int, int> pii;
typedef vector <int> vi;
inline int ni() {int x; cin >> x; return x;}
template <class T>
inline T nt() {T x; cin >> x; return x;}
inline void print(){}
template<typename T, typename ...TAIL>
inline void print(const T &t, TAIL... tail) {cout << t; print(tail...);}
inline void input() {return;}
template<typename T, typename ...TAIL>
inline void input(T &t, TAIL&... tail) {cin >> t; input(tail...);}

const int N = 3001;
const int inf = 1e9 + 7;
const double PI = 3.14159265359;

signed main () {
    ios_base::sync_with_stdio(NULL);  cin.tie(0); cout.tie(0);
    string s;
    cin >> s;
    int n = s.size();
    for (int  i= 0; i < n; i++) {
        map <int, int> mp;
        for (int j = i; j < min<int>(n, i + 5); j++) {
            mp[s[j]]++;
            for (auto it : mp) {
                if (it.second > (j - i + 1) / 2 && j - i + 1 >= 2) {
                    return cout << i + 1 << ' ' << j + 1 << '\n', 0;
                }
            }
        }
    }
    cout << -1 << ' ' << -1 << '\n';
    return 0;
}




















Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define maxn 2005
#define maxl 1000000000

using namespace std;

#define st first
#define nd second
#define ALL(x) (x).begin(), (x).end()

template <class T>
void mini(T& l, T r) {
  l = min(l, r);
}
template <class T>
void maxi(T& l, T r) {
  l = max(l, r);
}

using LL = long long;
using LD = long double;
using ULL = unsigned long long;
const int dx[] = {0, -1, 1, 0, -1, -1, 1, 1},
          dy[] = {-1, 0, 0, 1, -1, 1, -1, 1};
const int INF = 1e9;
const LL MOD = 1e9 + 7;


void Solve() {
  // TODO
  int n;
  cin >> n;
  cout << (n * n * n) << '\n';
  return;
}

void Prepare() {
  // TODO
  return;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  // Prepare();
  // cin >> T;
  // for (t = 1; t <= T; t++) {
  //   printf("Case #%d: ", t);
  Solve();
  // }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n;
vector<int> p[10];
string s;

int pos(int x, int i) {
  auto it = lower_bound(begin(p[x]), end(p[x]), i);
  return it == end(p[x]) ? -1 : *it;
}

int main() {
  cin >> n >> s;
  for (int i = 0; i < n; ++i) {
    p[s[i] - '0'].push_back(i);
  }

  i64 ans = 0;
  for (int a = 0; a <= 9; ++a) {
    int pa = pos(a, 0);
    if (pa == -1) continue; 
    for (int b = 0; b <= 9; ++b) {
      int pb = pos(b, pa + 1);
      if (pb == -1) continue;
      for (int c = 0; c <= 9; ++c) {
        int pc = pos(c, pb + 1);
        if (pc == -1) continue;
        ++ans;
      }
    }
  }

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

Measured memory_bytes: 512
# -*- coding: utf-8 -*-
source = 'CODEFESTIVAL2016'
count = 0
# Get a string.
s = raw_input()
# Do a character-wise comparison from source to target string
for i in range(len(s)):
    if s[i] != source[i]:
        count += 1
# Add extra operations for strings of uneven length.
if len(s) != len(source):
    count += abs(len(source) - len(s))
# Output.
print count

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

int main(){
    int N;
    cin>>N;
    vector<int> V;
    for(int i=0;i<2*N;i++){
        int n;
        cin>>n;
        V.push_back(n);
    }
    sort(V.begin(),V.end());
    int ans=0;
    for(int i=0;i<N;i++){
        ans+=V[i*2];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{min,max};
#[allow(unused_imports)]
use std::collections::BTreeMap;
#[allow(unused_imports)]
use std::ops::*;
#[allow(unused_imports)]
use std::collections::BinaryHeap;

fn main() {
    let n = read_i64();
    let inf = 1i64 << 50;
    let mut xs = vec![inf; 200001];
    xs[0] = 0;
    let ys = [1, 6, 36, 216, 1296, 7776, 46656, 9, 81, 729, 6561, 59049];
    for i in 0..100000 {
        for y in ys.iter() {
            xs[i+y] = min(xs[i+y], xs[i] + 1);
        }
    }
    println!("{}", xs[n as usize]);
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    return ss.parse::<i64>().unwrap();
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let mut res = vec![];
    let ss = read_line();
    for ts in ss.split_whitespace() {
        let x = ts.parse::<i64>().unwrap();
        res.push(x);
    }
    return res;
}

use std::fmt::Display;
#[allow(dead_code)]
fn write_vec<T: Display>(xs: &Vec<T>) {
    if xs.len() == 0 {
        println!("");
        return;
    }
    print!("{}", xs[0]);
    for i in 1..xs.len() {
        print!(" {}", xs[i]);
    }
    println!("");
}


Measured memory_bytes: 6396
package main

import (
	"fmt"
)

func main() {
	var s, t []byte
	fmt.Scan(&s)
	fmt.Scan(&t)
	var ans int
	for i := range s {
		if s[i] != t[i] {
			ans++
		}
	}
	fmt.Println(ans)
}

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

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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


Measured memory_bytes: 4908
class Node
  def initialize(id)
    @id = id
    @parent = -1
    @depth = 0
    @type = nil
    @children = []
  end

  attr_accessor :id, :parent, :depth, :type, :children
end

def assign(node, depth)
  if (node.parent == -1) then
    node.type = "root"
  else
    node.type = (node.children.size > 0) ? "internal node" : "leaf"
  end

  node.depth = depth

  node.children.each do |index|
    assign($node_map[index], depth+1)
  end
end

n = gets.chomp.to_i
$node_map = {}
n.times do |index|
  $node_map[index] = Node.new(index)
end

n.times do
  array = gets.chomp.split.map(&:to_i)
  if (array[1] > 0) then
    $node_map[array[0]].children = array[2..-1]
  end
  array[2..-1].each do |item|
    $node_map[item].parent = array[0]
  end
end

root_map = $node_map.select{|key, val| val.parent == -1}
assign(root_map.values[0], 0)

$node_map.each do |key, node|
  puts "node #{node.id}: parent = #{node.parent}, depth = #{node.depth}, #{node.type}, #{node.children}"
end

Measured memory_bytes: 46352
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_p(x) cerr<<#x": "<<(x).first<<' '<<(x).second<<endl
#define dbg_v(x, n) {cerr<<#x"[]: ";for(long long _=0;_<n;++_)cerr<<(x)[_]<<' ';cerr<<endl;}
#define all(v) v.begin(), v.end()
#define fi first
#define se second
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

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

template <typename T>
ostream& operator <<(ostream &out, const vector<T>& v) {
	for(const auto &item : v) out << item << ' ';
	return out;
}

const int N = 100010;

int single[N];
pii s[N];
bool vis[N];
vector<int> cords;
vector<pii> adj[N];

bool dfs(int v) {
	vis[v] = true;

	for(const auto &item : adj[v]) {
		int u = item.fi;
		int id = item.se;
		if(vis[u]) continue;
		if(dfs(u)) cords.push_back(id), s[v].se ^= 1;
	}

	return s[v].se;
}

int main()
{
	ios_base::sync_with_stdio(false);
	
	int n, m, l, r;

	cin >> n >> m;
	for(int i = 1; i <= n; ++i) cin >> s[i].fi >> s[i].se;
	sort(s + 1, s + n + 1);

	vector<int> priority;
	for(int i = 1; i <= m; ++i) {
		cin >> l >> r;
		int a = lower_bound(s + 1, s + n + 1, make_pair(l, 0)) - s;
		int b = upper_bound(s + 1, s + n + 1, make_pair(r, 2)) - s;
		if(a > n || a == b) continue;

		if(b > n) priority.push_back(a), single[a] = i;
		else {
			adj[a].push_back({b, i});
			adj[b].push_back({a, i});
		}
	}

	for(int i = n; i >= 1; --i) s[i].se ^= s[i - 1].se;
	for(int i = 1; i <= n; ++i) priority.push_back(i);

	for(auto i : priority)
		if(!vis[i]) {
			if(dfs(i)) {
				if(single[i]) cords.push_back(single[i]);
				else return cout << -1 << '\n', 0;
			}
		}

	sort(all(cords));

	cout << cords.size() << '\n';
	cout << cords << '\n';

	return 0;
}



Measured memory_bytes: 14328
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

typedef complex<double> P;
namespace std{bool operator<(const P& a, const P& b){
  return real(a)!=real(b)?real(a)<real(b):imag(a)<imag(b);
}}
struct C{
  P p; double r;
  C(const P& p, double r):p(p),r(r){}
};

pair<P,P> cc_cross(const C& c1, const C& c2){
  double d = abs(c1.p - c2.p);
  double rc = (d*d+c1.r*c1.r - c2.r*c2.r) / (2*d);
  double rs = sqrt(c1.r*c1.r - rc*rc);
  P diff = (c2.p - c1.p) / d;
  return make_pair(c1.p+diff*P(rc,rs), c1.p + diff*P(rc,-rs));
}


static const double EPS = 1e-8;

// K枚以上か
bool check(double X, const vector<vector<int>>& v, int K){
  vector<P> cand;
  rep(i,v.size()){
    P p1(v[i][0], v[i][1]);
    double d1 = X/v[i][2];

    cand.push_back(p1);
    rep(j,v.size()){
      
      P p2(v[j][0], v[j][1]);
      double d2 = X/v[j][2];

      C c1(p1, d1);
      C c2(p2, d2);

      if(abs(p1-p2) < d1+d2+EPS){
        pair<P,P> res = cc_cross(c1,c2);
        cand.push_back(res.first);
        cand.push_back(res.second);
      }
    }
  }

  bool ret = false;
  rep(i,cand.size()){
    P p = cand[i];
    //cerr << real(p) << " " << imag(p) << endl;
    int cnt = 0;
    rep(j,v.size()){
      P p1(v[j][0], v[j][1]);
      double d1 = X/v[j][2];
      double dist = abs(p-p1);
      //cerr << "  " << d1 << " " << dist << endl;
      
      if(d1+EPS>dist) cnt++;
    }
    //cerr << "   " << cnt << " " << K << endl;
    if(cnt >= K) ret = true;

  }
  //cerr << X << "\t" << (ret?"OK":"NG") << endl;
  return ret;
}

int main(){
  int N, K;
  cin >> N >> K;
  vector<vector<int>> v;
  rep(i,N){
    int x, y, c;
    cin >> x >> y >> c;
    v.push_back({x,y,c});
  }

  double lb = 0.0, ub = 1e20;
  rep(i,150){
    double mid = (lb+ub)/2.0;
    if(!check(mid, v, K)) lb = mid;
    else ub = mid;
  }

  printf("%.12lf\n", ub);
  
  return 0;
}


Measured memory_bytes: 552
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
    const a = lines[0].split("");
    let flg = (a.indexOf("N") >= 0 &&  a.lastIndexOf("S") < 0) ||
        (a.indexOf("W") >= 0 && a.indexOf("E") < 0 ) ||
        (a.indexOf("W") < 0 && a.indexOf("E") >= 0 ) ||
        (a.indexOf("N") < 0 &&  a.lastIndexOf("S") >= 0)
    console.log(!flg?"Yes":"No");
});


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

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  vector<int> p(n);
  for (int i = 0; i < n; i++) cin >> p[i];
  sort(p.begin(), p.end());
  int ac = 0, bc = 0, i = 0;
  while (p[i] <= a && i < n) {
    ac++;
    i++;
  }
  while (p[i] <= b && i < n) {
    bc++;
    i++;
  }
  cout << min({ac, bc, n - ac - bc});
  return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())

if N%K == 0:
    print(0)
if N%K != 0 and N > K :
    a = N%K
    b = K%a
    if a >= b :
        print(b)
    if a < b:
        print(a)
if N%K != 0 and N < K :
    c = K-N
    if c > N:
        print(N)
    if c < N:
        print(c)

Measured memory_bytes: 9160
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int H,W,N;
int X[303030],Y[303030];
int ma;

void dfs(int T,int B,vector<pair<int,int>>& P) {
	if(T>=B || (B-T)+W<=ma) return;
	if(P.empty()) {
		ma=(B-T)+W;
		return;
	}
	if(P.size()==1) {
		ma=max(ma,max(B-P[0].second,P[0].second-T)+W);
		ma=max(ma,max(P[0].first,W-P[0].first)+B-T);
		return;
	}
	
	vector<int> Y;
	FORR(r,P) Y.push_back(r.second);
	sort(ALL(Y));
	int my=Y[Y.size()/2], x;
	vector<pair<int,int>> PT,PB;
	
	
	FORR(r,P) {
		if(r.second<my) PT.push_back(r);
		if(r.second>my) PB.push_back(r);
	}
	dfs(T,my,PT);
	dfs(my,B,PB);
	
	vector<pair<int,pair<int,int>>> LL,RR;
	vector<int> RM;
	int mid = lower_bound(ALL(P),make_pair(W/2,0))-P.begin();
	
	int CT=T,CB=B;
	for(x=mid-1;x>=0 && CT!=CB;x--) {
		while(LL.size() && LL.back().second==make_pair(CT,CB)) LL.pop_back();
		LL.push_back({P[x].first,{CT,CB}});
		if(P[x].second<=my && P[x].second>CT) CT=P[x].second;
		if(P[x].second>=my && P[x].second<CB) CB=P[x].second;
	}
	if(CT!=CB) {
		while(LL.size() && LL.back().second==make_pair(CT,CB)) LL.pop_back();
		LL.push_back({0,{CT,CB}});
	}
	
	CT=T,CB=B;
	for(x=mid;x<P.size() && CT!=CB;x++) {
		while(RR.size() && RR.back().second==make_pair(CT,CB)) RR.pop_back(), RM.pop_back();
		RR.push_back({P[x].first,{CT,CB}});
		RM.push_back(CB-CT+P[x].first);
		
		if(P[x].second<=my && P[x].second>CT) CT=P[x].second;
		if(P[x].second>=my && P[x].second<CB) CB=P[x].second;
	}
	if(CT!=CB) {
		while(RR.size() && RR.back().second==make_pair(CT,CB)) RR.pop_back(), RM.pop_back();
		RR.push_back({W,{CT,CB}});
		RM.push_back(CB-CT+W);
	}
	for(x=RM.size()-2;x>=0;x--) RM[x]=max(RM[x],RM[x+1]);
	
	int TL=0, TR=0;
	FORR(l,LL) {
		while(TL<RR.size()-1 && RR[TL+1].second.first<=l.second.first && RR[TL+1].second.second>=l.second.second) TL++;
		while(TR<RR.size() && (RR[TR].second.first<l.second.first || RR[TR].second.second>l.second.second)) TR++;
		
		for(x=TL;x<=min((int)RR.size()-1,TR);x++) {
			auto r=RR[x];
			int dx=r.first-l.first;
			int dy=min(l.second.second,r.second.second)-max(l.second.first,r.second.first);
			if(dy>0) ma=max(ma,dx+dy);
		}
		if(TR<RR.size()) ma=max(ma,RM[TR]-l.first);
		
	}
}


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>W>>H>>N;
	FOR(i,N) cin>>X[i]>>Y[i];
	ma=max(W,H)+1;
	
	FOR(j,2) {
		vector<pair<int,int>> P;
		FOR(i,N) P.push_back({X[i],Y[i]});
		sort(ALL(P));
		
		dfs(0,H,P);
		
		swap(W,H);
		FOR(i,N) swap(X[i],Y[i]);
	}
	
	cout<<ma*2<<endl;
	
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 17920
#include <algorithm>
#include <bits/stdc++.h>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0; i != n; ++i)
#define REPR(i, n) for(int i = n - 1; i != -1; --i)
#define FOR(i, a, b) for(int i = a; i != b; ++i)
#define RBF(i, n) for(auto &i : n)
#define ABS(n) (n < 0 ? -n : n)
#define MIN(a, b) (a < b ? a : b)
#define MAX(a, b) (a > b ? a : b)
#define IN(n) (cin >> n)
#define OUT(n) (cout << n << "\n")
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define PB push_back
#define MP make_pair
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>())

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

using namespace std;
using ll = long long;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


void Main() {
  int N;
  cin >> N;
  string S;
  IN(S);
  int i=0;
  while(i<S.length()-1){
    if(S[i] == S[i+1]){
      S.erase(i+1,1);
      i-=1;
    }
    i+=1;
  }
  OUT(S.length());
}

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

  return 0;
}

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

using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define REP(i, n) for(ll i = n-1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << " = " << x << endl
#define mp(a, b) make_pair(a, b)
#define pb push_back

const long long MOD = 1000000007;

set<ll> prime_factor(ll n){
    set<ll> res;
    res.insert(1);
    ll on = n;
    for(ll i = 2; i*i <= on; i++){
        if(n%i==0) {
            res.insert(i);
            while(n % i == 0) {
                n /= i;
            }
        }
    }
    if(n!=1){
        res.insert(n);
    }
    return res;
}

int main(){
    ll a, b;
    cin >> a >> b;

    set<ll> da = prime_factor(a);
    set<ll> db = prime_factor(b);
    set<ll> cd;

    set_intersection(da.begin(), da.end(), db.begin(), db.end(), inserter(cd, cd.end()));

    for(auto e: da){
        cerr << e << endl;
    }
    cerr << endl;
    for(auto e: db){
        cerr << e << endl;
    }
    cerr << endl;
    for(auto e: cd){
        cerr << e << endl;
    }

    cout << cd.size() << endl;

    return 0;
}


Measured memory_bytes: 256
from heapq import heappush, heappop
from itertools import accumulate
def dijkstra(s,n,dic):
  q = [(0,s)]
  dist = [10**20]*n
  dist[s] = 0
  while q:
    v,p = heappop(q)
    if dist[p]<v:
      continue
    for e,c in dic[p]:
      if dist[e]>dist[p]+c:
        dist[e] = dist[p]+c
        heappush(q,(dist[e],e))
  return dist
N,M,s,t,*L = map(int, open(0).read().split())
Els = [[] for i in range(N+1)]
yEls = [[] for i in range(N+1)]
sEls = [[] for i in range(N+1)]
for u,v,a,b in zip(*[iter(L)]*4):
  sEls[u].append((v,b))
  sEls[v].append((u,b))
  yEls[u].append((v,a))
  yEls[v].append((u,a))

ydist = dijkstra(s,N+1,yEls)
sdist = dijkstra(t,N+1,sEls)
ls = list(accumulate((ydist[i]+sdist[i] for i in range(N,0,-1)),min))
for i in range(N-1,-1,-1):
  print(10**15-ls[i])

Measured memory_bytes: 91052