akhauriyash/Code-Regression huggingface dataset:
import sys, re
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from collections import deque, defaultdict, Counter
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop, heapify
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

H, W = MAP()
c = [LIST() for _ in range(10)]
A = [LIST() for _ in range(H)]

for k in range(10):
	for i in range(10):
		for j in range(10):
			c[i][j] = min(c[i][j], c[i][k] + c[k][j])

#for i in range(10):
#	print(c[i])

ans = 0
for i in range(H):
	for x in A[i]:
		if x == 1 or x == -1:
			continue
		else:
			ans += c[x][1]

print(ans)

Measured memory_bytes: 5460
// clang-format off
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
#define DEB(variable) cout << #variable << '=' << variable << endl

#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

using llint = long long int;

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr long long int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

// clang-format on
int main() {

    string s;
    cin >> s;
    llint n = s.size();
    llint result = 0;
    REP(i, n) {
        if(i == 0 || (i % 2)) {
            continue;
        }
        string t = s.substr(0,i);
      //  cout << t << endl;
        if(t.substr(0,i/2)==t.substr(i/2)){
            result = max(result, i);
        }
    }
    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;


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

  ll y = X / 100;
  ll z = X % 100;

  ll a = (z + 4) / 5;

  ll ans = 0;
  if (a <= y) ans = 1;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
typedef long long ll;
using namespace std;

int main(void){
  static ll i,n,a[100010],b[100010],sum=0;
  cin>>n;
  for(i=0;i<n+1;i++){
    cin>>a[i];
  }
  for(i=1;i<=n;i++){
    cin>>b[i];
  }
  b[0]=0;
  b[n+1]=0;

  for(i=0;i<=n;i++){
    if(b[i]>0){
      if(a[i]<=b[i]){
        sum+=a[i];
        continue;
      }
      else{
        sum+=b[i];
        a[i]-=b[i];
      }
    }
    if(b[i+1]>=a[i]){
      sum+=a[i];
      b[i+1]-=a[i];
    }
    else{
      sum+=b[i+1];
      b[i+1]=0;
    }
  }

  cout<<sum<<endl;
  
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,p;
int f[100][100];
signed main()
{
	scanf("%d%d",&n,&p);
	f[0][0]=1;
	int tmp;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&tmp);
		tmp%=2;
		f[i][0]=f[i-1][0];f[i][1]=f[i-1][1];
		f[i][0^tmp]+=f[i-1][0];
		f[i][1^tmp]+=f[i-1][1];
	}
	printf("%lld\n",f[n][p]);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAX = 8020;

signed main(void) {
	string s;
	int x, y;
	cin >> s >> x >> y;
	
	vector<int> fn;
	int cnt = 0;
	for(int i=0;i<s.size();i++) {
		if(s[i] == 'T') {
			fn.push_back(cnt);
			cnt = 0;
		} else {
			cnt++;
			if(i == s.size() - 1)
				fn.push_back(cnt);
		}
	}
	vector<int> xa, ya;
	for(int i=0;i<fn.size();i++) {
		if(i % 2 == 0) {
			xa.push_back(fn[i]);
		} else {
			ya.push_back(fn[i]);
		}
	}

	vector<vector<bool>> dpx(xa.size()+1, vector<bool>(2*MAX, false));
	vector<vector<bool>> dpy(ya.size()+1, vector<bool>(2*MAX, false));

	dpx[0][MAX] = dpy[0][MAX] = true;

	for(int i=0;i<xa.size();i++) {
		for(int j=0;j<=2*MAX;j++) {
			if(j + xa[i] <= 2 * MAX) {
				dpx[i+1][j+xa[i]] = dpx[i+1][j+xa[i]] | dpx[i][j];
			}
			// 最初の移動ではx軸の正の向きにしか進めない
			if(j - xa[i] >= 0 and i > 0) {
				dpx[i+1][j-xa[i]] = dpx[i+1][j-xa[i]] | dpx[i][j];
			}
		}
	}
	for(int i=0;i<ya.size();i++) {
		for(int j=0;j<=2*MAX;j++) {
			if(j + ya[i] <= 2 * MAX) {
				dpy[i+1][j+ya[i]] = dpy[i+1][j+ya[i]] | dpy[i][j];
			}
			if(j - ya[i] >= 0) {
				dpy[i+1][j-ya[i]] = dpy[i+1][j-ya[i]] | dpy[i][j];
			}
		}
	}

	if(dpx[xa.size()][MAX+x] and dpy[ya.size()][MAX+y]) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 16256
#include<bits/stdc++.h>
using namespace std;
string u;
string s[105];
map<string,bool> mpp;
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>s[i];
	}
	u=s[0];
	mpp[s[0]]=true;
	for(int i=1;i<n;i++)
	{
		if(u[u.length()-1]==s[i][0] && !mpp[s[i]])
		{
			u=s[i];
			mpp[s[i]]=true;
		}
		else {cout<<"No"<<endl; return 0;}
	}
	cout<<"Yes"<<endl;
	return 0; 
}

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

int main(){
  int a,b,d;
  cin>>a>>b;
  vector<pair<int,int>> c(b);
  for(int i=0;i<b;i++)
    cin>>c.at(i).first>>c.at(i).second;
  for(int i=1;i<=a;i++){
    d=0;
    for(int j=0;j<b;j++){
    if(i==c.at(j).first||i==c.at(j).second)
      d++;
    }
    cout<<d<<endl;
  }
}


Measured memory_bytes: 256
a, b, c = map(int, input().split())
print(min(abs(a - b) + abs(b - c), abs(a - c) + abs(c - b), abs(b - a) + abs(a - c), abs(b - c) + abs(c - a), abs(c - b) + abs(b - a), abs(c - a) + abs(a - b)))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	//作れるあまりの配列を出す
	set<int> mod = { 0 };
	int zan = 0;
	while (true) {
		zan += a % b;
		if (mod.count(zan % b)) {
			break;
		}
		else {
			mod.insert(zan % b);
		}
	}
	(mod.count(c)) ? cout << "YES" : cout << "NO";
}

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

int main()
{
	int n,a,b;
	cin >> n>>a>>b;
	for (int i = a; i <= b; i++) {
		if (i % n == 0) {
			cout << "OK" << endl;
			break;
		}
		if(i==b){
			cout << "NG" << endl;
		}
	}
}


Measured memory_bytes: 3632
package main

import (
	"bufio"
	"flag"
	"fmt"
	"os"
	"sort"
	"strconv"
	"testing"
)

/*-----------Main-----------*/

func main() {
	x := readIs(5)
	for i := 0; i < 5; i++ {
		if x[i] == 0 {
			fmt.Println(i + 1)
		}
	}
}

/*-----------Utilities-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	testing.Init()
	if flag.Parse(); flag.Arg(0) == "debug" {
		debug()
	}
	const maxBuf = 200100
	var buf []byte = make([]byte, maxBuf)
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBuf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Println("Error : There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

func readS() string {
	sc.Scan()
	return sc.Text()
}

func readSs(a int) []string {
	b := make([]string, a)
	for i := 0; i < a; i++ {
		b[i] = readS()
	}
	return b
}

func readI() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func readIs(a int) []int {
	b := make([]int, a)
	for i := 0; i < a; i++ {
		b[i] = readI()
	}
	return b
}

func readF() float64 {
	sc.Scan()
	r, _ := strconv.ParseFloat(sc.Text(), 64)
	return r
}

func readFs(a int) []float64 {
	b := make([]float64, a)
	for i := 0; i < a; i++ {
		b[i] = readF()
	}
	return b
}

func max(a []int) int {
	l := len(a)
	m := a[0]
	for i := 1; i < l; i++ {
		if a[i] > m {
			m = a[i]
		}
	}
	return m
}

func min(a []int) int {
	l := len(a)
	m := a[0]
	for i := 1; i < l; i++ {
		if a[i] < m {
			m = a[i]
		}
	}
	return m
}

func sortI(a []int) []int {
	sort.Ints(a)
	return a
}

func reverse(a []int) []int {
	l := len(a)
	r := make([]int, l)
	for i := 0; i < l; i++ {
		r[i] = a[l-i-1]
	}
	return r
}

func countI(a []int, b int) int {
	l := len(a)
	var c int
	for i := 0; i < l; i++ {
		if a[i] == b {
			c++
		}
	}
	return c
}


Measured memory_bytes: 1848
#include <iostream>
#include <algorithm>
#include <cstring>
#include <map>
#include <stack>
#include <tuple>
#include <queue>
#include <vector>
#include <math.h>



#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define rREP(i, n) for(int (i) = (n) - 1; (i) >= 0; --(i))
#define ALL(TheArray) TheArray.begin(), TheArray.end()

using lli = long long int;
using pii = std::pair<int, int>;

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;
}



constexpr lli inf = 1e18;

lli choose(lli a, lli b, lli c){
    if(a <= b){
        if(b <= c) return c - a;
        return b - ((a < c) ? a : c);
    }
    else{
        if(b >= c) return a - c;
        return ((a > c) ? a : c) - b;
    }
}

 
int main(void){
    lli H, W; scanf("%lld%lld", &H, &W);
    if(H % 3 == 0 or W % 3 == 0) puts("0");
    else{
        lli res = H > W ? W : H;

        lli W1 = W / 3, H1 = H / 3,
            hW = W / 2, hH = H / 2;
        lli k[4];
        k[0] = choose(H * W1,   hH*(W - W1),   (H-hH)*(W - W1) );
        k[1] = choose(H*(W1+1), hH*(W-W1-1), (H-hH)*(W-W1-1) );
        k[2] = choose(W * H1,   hW*(H - H1),   (W-hW)*(H - H1) );
        k[3] = choose(W*(H1+1), hW*(H-H1-1), (W-hW)*(H-H1-1));
        REP(i, 4) chmin(res, k[i]);
        printf("%lld\n", res);
    }
    return 0;
}

Measured memory_bytes: 384
from operator import itemgetter
N = int(input())
l = []
for i in range(N):
  a = input().split()
  a[1] = int(a[1])
  a.append(i+1)
  l.append(a)
l.sort(key=itemgetter(1),reverse=True)
l.sort(key=itemgetter(0))
for j in l:
  print(j[2])

Measured memory_bytes: 3188
s = input()
t = input()

ans = len(t)

for i in range(len(s)-len(t) + 1):
    tmp = s[i:i+len(t)]
    cnt = 0
    for j in range(len(t)):
        if tmp[j] != t[j]:
            cnt += 1
    ans = min(ans, cnt)

print(ans)

Measured memory_bytes: 9000
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use proconio::{input, marker::*};
use superslice::*;
fn main() {
    input! {
        r: i64,
    }
    let r = r as f64;
    println!("{}", r * 2. * std::f64::consts::PI);
}


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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

  string s;
  cin >> s;

  string r = "CODEFESTIVAL2016";
  int ans = 0;
  for (int i = 0; i < r.size(); i++) {
    if (r[i] != s[i]) {
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <complex>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
const double EPS = 1e-8;
const double PI = acos(-1);
inline bool equals(double a, double b) { return abs(b - a) < EPS; }
using Point = complex<double>;
namespace std { bool operator < (const Point &a, const Point &b) { return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b); } }
struct Line
{
    Point a, b;
    Line(Point a, Point b) : a(a), b(b) {}
};
inline double dot(const Point &a, const Point &b) { return real(a) * real(b) + imag(a) * imag(b); }
inline double cross(const Point &a, const Point &b) { return real(a) * imag(b) - imag(a) * real(b); }
inline bool isParallel(const Line &a, const Line &b) { return equals(cross(a.b - a.a, b.b - b.a), 0.0); }
inline bool isOrthogonal(const Line &a, const Line &b) { return equals(dot(a.a - a.b, b.a - b.b), 0.0); }
inline Point projection(const Line &l, const Point &p)
{
    double t = dot(p - l.a, l.a - l.b) / norm(l.a - l.b);
    return l.a + (l.a - l.b) * t;
}
inline Point reflection(const Line &l, const Point &p) { return p + (projection(l, p) - p) * 2.0; }
inline int ccw(const Point &a, Point b, Point c)
{
    b = b - a, c = c - a;
    if(cross(b, c) > EPS) return 1;
    if(cross(b, c) < -EPS) return -1;
    if(dot(b, c) < 0) return 2;
    if(norm(b) < norm(c)) return -2;
    return 0;
}
inline bool isIntersect(const Point &a, const Point &b, const Point &c, const Point &d) { return (ccw(a, b, c) * ccw(a, b, d) <= 0) and (ccw(c, d, a) * ccw(c, d, b) <= 0); }
inline bool isIntersect(const Line &l, const Line &m) { return isIntersect(l.a, l.b, m.a, m.b); }
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(8);
    int n; cin >> n;
    while(n--)
    {
        double x0, y0, x1, y1, x2, y2, x3, y3; cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        Point a = Point(x0, y0), b = Point(x1, y1), c = Point(x2, y2), d = Point(x3, y3);
        int res = isIntersect(Line(a, b), Line(c, d));
        cout << res << endl;
    }
    return 0;
}




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

int main() {
    int n, m;
    cin >> n >> m;
    vector<pair<int,int>> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i].first >> a[i].second;
    
    sort(a.begin(), a.end());
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        if (m > a[i].second) {
            m -= a[i].second;
            ans += (long long)a[i].first * a[i].second;
        }
        else if (m <= a[i].second) {
            ans += (long long)a[i].first * m;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3904
#include <stdio.h>
#include <math.h>
int main(void)
{
    int i,n,s[1000];
    double a,m;
    
    while(1){
        scanf("%d",&n);
        if(!n) break;
        
        m=0;
        a=0;
        
        for(i=0;i<n;i++){
            scanf("%d",&s[i]);
            m=m+s[i];
        }
        
        m=m/n;
        
        for(i=0;i<n;i++){
            a=a+pow(s[i]-m,2.0);
        }
        a=a/n;
        
        printf("%lf\n",pow(a,1.0/2.0));
    }
    
    return 0;
}


Measured memory_bytes: 2052
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    P = []
    input_raw = read_func().strip().split()
    for i in range(N):
        P.append(float(input_raw[i]))

    dp = [[0 for i in range(N + 1)] for j in range(N + 1)]
    dp[0][0] = 1
    for i in range(0, N):
        for j in range(0, i + 1):
            dp[i + 1][j] += (1.0 - P[i]) * dp[i][j]
            dp[i + 1][j + 1] += P[i] * dp[i][j]

            #dp[i][j] += p[i] * dp[i - 1][j - 1] + (1 - p[i])

    count = 0L
    for j in range(N/2 + N%2, N + 1):
        count += dp[N][j]
    print count
if __name__ == '__main__':
    main()


Measured memory_bytes: 170524
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
using VS = vector<string>;
using VVS = vector<VS>;

int main(){
	int n,m,p,sz;
	string s;
	int ac=0,wa=0;
	cin>>n>>m;
	VVS P(n);
	rp(i, 0, m){
		cin>>p>>s; --p;
	// 	cout<<p<<" "<<s<<"\n";////
	// for(auto v:P){for(auto x:v){cout<<x<<" ";}puts("");}///
		sz = P[p].size();
		if(sz){
			// puts("test 0");
			if(P[p][sz-1]=="AC"){
				continue;
			}
			// else{}
		}
		// else{}
		P[p].push_back(s);
	}

	for(auto v:P){
		sz = v.size();
		if(sz==0) continue;
		if(v[sz-1]=="WA") continue;
		ac++;
		wa += sz-1;

		// for(auto x:v){
		// 	cout<<x<<" ";///
		// }
		// puts("");////

	}

	cout<<ac<<" "<<wa<<endl;
}


Measured memory_bytes: 10368
import scala.io.Source.stdin

object Main {
  def switchingRailroadCars(t: Iterator[String]): Vector[Int] = {
    def loop(n: Int,
      switchList: Vector[Int] = Vector(),
      exitList: Vector[Int] = Vector()): Vector[Int] = {
      if (t.nonEmpty) {
        n match {
          case 0 => loop(t.next.toInt, switchList.init, exitList :+ switchList.last)
          case _ => loop(t.next.toInt, switchList :+ n, exitList)
        }
      } else exitList :+ switchList.last
    }

    loop(t.next.toInt)
  }

  def main(args: Array[String]): Unit = {
    val trains = stdin.getLines
    switchingRailroadCars(trains).foreach(println)
  }
}

Measured memory_bytes: 43660
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int ans = 0;
  int flag = 1;
  rep(i, n) {
    if (a[i] == flag) {
      ans++;
      flag++;
    }
  }
  if (ans == 0) {
    cout << -1 << endl;
    return 0;
  }
  cout << n - ans << endl;
  return 0;
}

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

int main(){
    long long int H,W;
    cin >> H >> W;

    if(H == 1 || W == 1){
        cout << 1;
        return 0;
    }
    if(H%2==0){
        cout << H/2 * W; 
    }else{
        if(W%2==0)
            cout << H/2 * W + W/2;
        else
        {
            cout << H/2 * W + W/2 + 1;
        }
    }
    return 0;
}

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

using namespace std;

typedef long long int64;

struct SegmentTree
{
  vector< int > seg, lazy;
  int sz;

  SegmentTree(int n)
  {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz - 1, 0);
    lazy.assign(2 * sz - 1, -114514);
  }

  void push(int k, int l, int r)
  {
    if(lazy[k] != -114514) {
      seg[k] = lazy[k] * (r - l);
      if(k < sz - 1) lazy[2 * k + 1] = lazy[2 * k + 2] = lazy[k];
      lazy[k] = -114514;
    }
  }

  void update(int a, int b, int x, int k, int l, int r)
  {
    push(k, l, r);
    if(a >= r || b <= l) return;
    if(a <= l && r <= b) {
      lazy[k] = x;
      push(k, l, r);
      return;
    }
    update(a, b, x, 2 * k + 1, l, (l + r) >> 1);
    update(a, b, x, 2 * k + 2, (l + r) >> 1, r);
    seg[k] = seg[2 * k + 1] + seg[2 * k + 2];
  }

  void update(int a, int b, int x)
  {
    update(a, b, x, 0, 0, sz);
  }

  int query(int a, int b, int k, int l, int r)
  {
    push(k, l, r);
    if(a >= r || b <= l) return (0);
    if(a <= l && r <= b) return (seg[k]);
    return (query(a, b, 2 * k + 1, l, (l + r) >> 1) + query(a, b, 2 * k + 2, (l + r) >> 1, r));
  }

  int query(int a, int b)
  {
    return (query(a, b, 0, 0, sz));
  }
};

int main()
{
  int N;
  string S;

  cin >> N;
  cin >> S;

  SegmentTree tree1(N), tree2(N - 1);
  for(int i = 0; i < N; i++) {
    tree1.update(i, i + 1, S[i] == '1');
  }
  for(int i = 0; i < N - 1; i++) {
    tree2.update(i, i + 1, S[i] == '1' && S[i + 1] == '1');
  }

  int Q;
  cin >> Q;
  while(Q--) {
    int L, R, B;
    cin >> L >> R >> B;
    --L;

    tree1.update(L, R, B);
    tree2.update(L, R - 1, B);

    if(L - 1 >= 0) {
      int64 get = tree1.query(L - 1, L);
      tree2.update(L - 1, L, get & B);
    }

    if(R + 1 <= N) {
      int64 get = tree1.query(R, R + 1);
      tree2.update(R - 1, R, get & B);
    }

    cout << tree1.query(0, N) - tree2.query(0, N) << endl;
  }


}

Measured memory_bytes: 7164
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second
#define endl "\n"

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef pair<string, int> P;


class Graph{
    struct edge{
        int vertice;
        ll weight;
    };

    vector<vector<edge>> g;
    unsigned int n;

public:
    Graph(unsigned int n): n{n}{
        g.resize(n);
    }

    void add_edge(int u, int v){
        g[u].emplace_back(edge{v, 1});
    };

    void add_edge(int u, int v, ll w){
        g[u].emplace_back(edge{v, w});
    }

    vector<edge>& get_edge(int v){
        return g[v];
    }

    unsigned int size(){
        return n;
    }

    vector<edge>& operator[](int v){
        return get_edge(v);
    }
};


int main(){
    int s, w;   cin >> s >> w;
    if(w >= s){
        cout << "unsafe" << endl;
    }
    else{
        cout << "safe" << endl;
    }


    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

int main(){
    long long A, B;
    cin >> A >> B;
    long long g = __gcd(A, B);
    cout << A*B/g << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
from bisect import bisect_left
from itertools import product
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def LSI(): return list(map(int, list(sys.stdin.readline().rstrip())))
def LSI2(N): return [list(map(int, list(sys.stdin.readline().rstrip()))) for i in range(N)]
def S(): return sys.stdin.readline().rstrip()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 998244353
INF = float("inf")
sys.setrecursionlimit(10**6+10)
input = sys.stdin.readline

N,P = MI()
S = S()
mod = 0
ans = 0
dic = {0:1}
if P == 2 or P == 5:
    for i in range(N):
        if int(S[i])%P==0:
            ans += i+1
else:
    for i in range(N-1,-1,-1):
        mod = (mod+pow(10,(N-1-i),P)*int(S[i]))%P
        dic[mod] = dic.get(mod,0)+1
    for i in dic.values():
        ans += int(i*(i-1)/2)
print(ans)


Measured memory_bytes: 63432
import std.stdio;
import std.string, std.conv, std.array, std.algorithm;
import std.uni, std.math, std.container, std.typecons;
import core.bitop, std.datetime, std.range;

void main(){
    auto rd = readln.split.to!(int[]);
    auto n = rd[0], q = rd[1];
    auto uf = new UnionFind(n);

    foreach(lp ; 0 .. q){
        rd = readln.split.to!(int[]);
        auto c = rd[0], x = rd[1], y = rd[2];

        if(c == 0){
            uf.unite(x, y);
        } else{
            writeln(uf.is_same(x, y) ? 1 : 0);
        }
    }
}

class UnionFind{
private:
    int[] ds;
    int[] p;
    int[] rank;

public:
    this(int N){
        ds = iota(N).array;
        p = iota(N).array;
        rank = new int[](N);
    }

    int find_root(int x){
        if(x != p[x]){
            p[x] = find_root(p[x]);
        }
        return p[x];
    }

    bool is_same(int x, int y){
        return find_root(x) == find_root(y);
    }

    void unite(int x, int y){
        auto u = find_root(x);
        auto v = find_root(y);

        if(rank[u] < rank[v]){
            p[u] = v;
        } else{
            p[v] = u;

            if(rank[u] == rank[v]) ++rank[u];
        }
    }
}

Measured memory_bytes: 3724
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
ll array[100001];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    ll K;
    cin >> N >> K;
    
    REP(i,N){
        int a,b;
        cin >> a >> b;
        array[a]+=b;
    }
    for(int i=1;i<=100000;++i){
        if(K<=array[i]){
            cout << i << endl;
            break;
        }
        K -= array[i];
    }
    return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (3e15)

using namespace std;

int N, sum[300005];
string S;

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

    cin >> N;
    cin >> S;

    if (S[0] == 'E') sum[0] = 1;
    REPS(i, N - 1) {
        char s = S[i];
        if (s == 'E') {
            sum[i] = sum[i - 1] + 1;
        } else {
            sum[i] = sum[i - 1];
        }
    }

    int ans = INF;
    REP(i, N) {
        int left = i >= 1 ? i - sum[i - 1] : 0;
        int right = i <= N - 2 ? sum[N - 1] - sum[i] : 0;
        ans = min(ans, left + right);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2964
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long long INF = 1LL << 60;
using ping = pair<ll, ll>;

int main(){
    ll N, K;
    cin >> N >> K;
    ll A[100100]={0};
    for(int i = 0; i < N; i++)cin >> A[i];
    ll cnt = 0;
    if ((N - 1) % (K - 1) == 0) {
      cnt = (N - 1) / (K - 1);
    }
    else{
        cnt = (N - 1) / (K - 1)+1;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 4384
// Package main provides
//
// File:  main.go
// Author: ymiyamoto
//
// Created on Sun Feb  2 11:20:26 2020
//
package main

import (
	"fmt"
	"math/big"
)

const MOD = 1e9 + 7

var N int
var A []int

func solve() int64 {
	mod := big.NewInt(MOD)

	lcm := big.NewInt(int64(A[0]))
	for i := range A {
		a := big.NewInt(int64(A[i]))
		g := big.NewInt(0).GCD(nil, nil, lcm, a)
		lcm.Mul(lcm, a)
		lcm.Div(lcm, g)
	}

	ans := big.NewInt(0)
	for i := range A {
		a := big.NewInt(int64(A[i]))
		x := big.NewInt(0).Div(lcm, a)
		ans.Add(ans, x)
	}
	return ans.Mod(ans, mod).Int64()
}

func main() {
	fmt.Scan(&N)
	A = make([]int, N)
	for i := range A {
		fmt.Scan(&A[i])
	}

	fmt.Println(solve())
}


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

int main() {
  int N;
  cin>>N;
  
  int xmax=0;
  int sum=0;
  
  for(int i=0;i<N;++i){
    int x;
    cin>>x;
    sum=sum+x;
    xmax=max(xmax,x);
  }
  
  if(xmax<sum-xmax)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

# 各都市に対して、
# (1)Sから到達したときの円貨の最小値
# (2)Gから到達したときのスヌークの最小値
# をダイクストラで求める。
# 各都市で両替したときのコストは、(1)と(2)の和である。
# 年を逆順に遡って、順に両替所が開設されると仮定する。
# 新規に開設された(1)と(2)の和が最小値を更新するようであれば更新。最小値がその年の答え。
# コストは最大でも(10 ** (9 + 5)) * 2程度であるため、所持金は超えない。最後に引けばOK。

N,M,S,T = map(int,readline().split())
G = [[] for i in range(N)]
for i in range(M):
  u,v,a,b = map(int,readline().split())
  G[u - 1].append((v - 1, a, b))
  G[v - 1].append((u - 1, a, b))

INF = 10 ** 15

import heapq as hq
# ダイクストラ
# グラフ, 取るべきコストのindex(円:1, スヌーク:2), 開始点
def get_min_cost(G, label, start):
  dist_from_start = [INF] * len(G)
  # そこまでのコスト, 頂点, 親
  q = [(0, start, -1)]
  hq.heapify(q)
  while q:
    cost, v, parent = hq.heappop(q)
    if dist_from_start[v] <= cost:
      continue
    dist_from_start[v] = cost
    for child in G[v]:
      if child[0] == parent:
        continue
      hq.heappush(q, (dist_from_start[v] + child[label], child[0], v))
  return dist_from_start
  
dist_from_s = get_min_cost(G, 1, S - 1)
dist_from_g = get_min_cost(G, 2, T - 1)

best = INF
ans = [0] * N
wallet = 10 ** 15
for i in range(N - 1, -1, -1):
  # 逆順に両替所を更新していく
  if dist_from_s[i] + dist_from_g[i] < best:
    best = dist_from_s[i] + dist_from_g[i]
  ans[i] = wallet - best

for a in ans:
  print(a)

Measured memory_bytes: 60072
n=int(input())
s=list(input())

a=set(s)
ans=0
for i in range(len(s)-1):
    l=set(s[:i+1])
    r=set(s[i+1:])
    d=len(l)+len(r)-len(a)
    if d>ans:
        ans=d
print(ans)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/STACK: 2000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>

#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl '\n'
#define elif else if
#define lli long long int
#define ld long double
#define vec vector
#define forn(a) for(lli a=0; a<n; a++)
#define all(x) x.begin(), x.end()
#define presicion(x) cout<<fixed<<setprecision(x)
#define deb(x) cerr<<#x<<" = "<<x<<endl
#define PI 3.14159265358979323
#define sen(ang) sin((ang)*PI/180)
//cout<<flush;

using namespace std;

int main(){
    IOS;

    int n; cin>>n;
    string a, b, c;
    cin>>a>>b>>c;
    int cont = 0;
    for(int i=0; i<n; i++){
        set<char> p;
        p.insert(a[i]);
        p.insert(b[i]);
        p.insert(c[i]);
        cont += p.size()-1;
    }
    cout<<cont<<endl;

    return 0;
}

Measured memory_bytes: 256
import random

class  Dise:
    def __init__(self,top,flont,right,left,back,bottom):
        self.top,self.flont,self.right,self.left,self.back,self.bottom=top,flont,right,left,back,bottom
        
    def rot(self,d):
        if d=='N':
            self.top,self.flont,self.bottom,self.back=self.flont,self.bottom,self.back,self.top
        elif d=='E':
            self.top,self.right,self.bottom,self.left=self.left,self.top,self.right,self.bottom
        elif d=='S':
                self.top,self.flont,self.bottom,self.back=self.back,self.top,self.flont,self.bottom
        elif d=='W':
            self.top,self.right,self.bottom,self.left=self.right,self.bottom,self.left,self.top
    
    def gettop(self):
        return self.top
    def getfront(self):
        return self.flont
    def getright(self):
        return self.right
    def getleft(self):
        return self.left
    def getback(self):
        return self.back
    def getbottom(self):
        return self.bottom
    
n1=list(map(int,input().split()))
n2=list(map(int,input().split()))

dise1=Dise(n1[0],n1[1],n1[2],n1[3],n1[4],n1[5])
dise2=Dise(n2[0],n2[1],n2[2],n2[3],n2[4],n2[5])
for j in range(1000):
    dise1.rot(random.choice('NESW'))
    if dise1.gettop()==dise2.gettop() and dise1.getfront()==dise2.getfront() and dise1.getright()==dise2.getright() and dise1.getleft()==dise2.getleft() and dise1.getback()==dise2.getback() and dise1.getbottom()==dise2.getbottom():
        print("Yes")
        break
if j==999:
    print("No")

            
        


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

#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << (a) << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

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

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

    multiset<int> c;
    int n, ans = 0; cin >> n;
    while (n--) {
        int x; cin >> x;
        c.insert(x);
    }
    while (!c.empty()) {
        auto x = *c.rbegin();
        c.erase(c.find(x));
        forn(l,31) {
            auto y = (1<<l)-x;
            if (c.count(y)) {
                auto it = c.find(y);
                c.erase(it);
                ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}


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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long



int32_t main() {

    vector<int> f(10, 0);
    for(int i = 0; i < 4; ++i) {
        int x; cin >> x;
        f[x]++;
    }

    if(f[1] && f[9] && f[7] && f[4]) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  int a,b;
  cin >> a >> b;
  if((a+1)/2>=b)cout << "YES" << endl;
  else cout << "NO" << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();
  return 0;
}


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

int main(void) {
  int i;
  int N, A;
  bool flag;
  
  // stdin
  cin >> N >> A;
  
  // calculate
  flag = 0;
  for (i=0; i<=A; i++) {
    if ((N-i) % 500 == 0) {
      flag = 1;
      break;
    }
  }
  
  // stdout
  cout << ((flag) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
import sys

loc = [3, 1]

def print_dir(h):
    if h == 0:
        print('R', end='')
    elif h == 1:
        print('D', end='')
    elif h == 2:
        print('L', end='')
    elif h == 3:
        print('U', end='')

dir = [[1, 0], [0, 1], [-1, 0], [0, -1]]
hand = 3

board = [[0 for _ in range(11)] for _ in range(11)]
for i, line in enumerate(sys.stdin):
    for j, c in enumerate(line.strip()):
        board[i+1][1 + (i+1)%2 + j*2] = int(c)

print("R", end='')

while loc != [1, 1]:
    for i in range(4):
        if board[loc[1]+dir[(hand+i)%4][1]][loc[0]+dir[(hand+i)%4][0]] == 1:
            loc[0] += dir[(hand+i)%4][0]*2
            loc[1] += dir[(hand+i)%4][1]*2
            if i == 1:
                print_dir((hand+1)%4)
            elif i == 2:
                print_dir((hand+2)%4)
                hand = (hand+1)%4
            elif i == 3:
                print_dir((hand+3)%4)
                hand = (hand+2)%4
            elif i == 0:
                print_dir(hand%4)
                hand = (hand+3)%4

            break

print()

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

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

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstring>

using namespace std;
#define MAX_N 50
#define rep(i,n) for(int i=0;i<n;i++)

int W,H,D,N,K;
int X1[MAX_N],X2[MAX_N],Y1[MAX_N],Y2[MAX_N],D1[MAX_N],D2[MAX_N];
vector<int> xl,yl,dl;

int fld[MAX_N * 2][MAX_N*2][MAX_N*2];

int compress(int *x1,int *x2, int w,vector<int> *xs){
	
	rep(i,N){
			int tx1=x1[i], tx2=x2[i];
			xs->push_back(tx1);
			xs->push_back(tx2);
	}
	sort(xs->begin(),xs->end());
	xs->erase(unique(xs->begin(),xs->end()),xs->end());
	
	rep(i,N){
		x1[i] = find(xs->begin(),xs->end(),x1[i] )- xs->begin();
		x2[i] = find(xs->begin(),xs->end(),x2[i] )- xs->begin();
	}
	return xs->size();
	
}

void solve(){
	W=compress(X1,X2,W,&xl);
	H=compress(Y1,Y2,H,&yl);
	D=compress(D1,D2,D,&dl);

	memset(fld, 0, sizeof(fld));
	rep(i,N){
		for(int d=D1[i]; d<D2[i]; d++){
			for(int y = Y1[i]; y<Y2[i];y++){
				for(int x = X1[i]; x<X2[i];x++){
					fld[d][y][x]++;
				}
			}
		}
	}

	long long int ans=0;
	rep(d,D-1){
		rep(y,H-1){
			rep(x,W-1){
				if(fld[d][y][x]<K)continue;
				ans+=(long long int)(xl[x+1]-xl[x])*(long long int)(yl[y+1]-yl[y])*(long long int)(dl[d+1]-dl[d]);
				ans=ans;
			}
		}
	}

	printf("%lld\n",ans);
}

int main(){
	scanf("%d %d",&N,&K);
	W=H=D=1000000;
	rep(i,N){
		//int x1,x2,y1,y2,d1,d2;
		scanf("%d %d %d %d %d %d",&X1[i],&Y1[i],&D1[i],&X2[i],&Y2[i],&D2[i]);
	}
	solve();

	return 0;
}

Measured memory_bytes: 4968
//In the name of God!
#include <bits/stdc++.h>

using namespace std;
const int maxn = 1e5 + 12;

int a[maxn];
int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> a[i];
    sort(a, a + n);
    cout << a[n / 2] - a[n / 2 - 1];
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int K = int.Parse(Console.ReadLine());
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		int M = int.Parse(str[1]);
		string ans = "NG";
		for(var i=N;i<=M;i++){
			if(i%K==0){
				ans = "OK";
			}
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 17880
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n = [int(i) for i in STR()]
k = INT()
l = len(n)
dp = [[[0, 0] for _ in range(l)] for _ in range(k + 1)] #dp[i個の0以外][j桁目まで][0:未満 1:未決定]
dp[0][0][0] = 1 #0
dp[1][0][1] = 1 #n[0]
dp[1][0][0] = n[0] - 1 #1からn[0] - 1
for j in range(1, l):
    dp[0][j][0] = dp[0][j - 1][0] #全部0

    for i in range(1, k + 1):
        dp[i][j][0] += dp[i - 1][j - 1][0] * 9 #0以外i-1個に0以外を
        dp[i][j][0] += dp[i - 1][j - 1][1] * (n[j] - 1) if n[j] > 0 else 0 #0以外i個の未満未決定にn[j]未満の数を
        dp[i][j][0] += dp[i][j - 1][0] #0以外i個かつ未満に0を
        dp[i][j][0] += dp[i][j - 1][1] if n[j] > 0 else 0 #0以外i個かつ未満未決定に0を

        dp[i][j][1] += dp[i][j - 1][1] if n[j] == 0 else 0 #0以外i個の未満未決定にn[j]を
        dp[i][j][1] += dp[i - 1][j - 1][1] if n[j] > 0 else 0 #0以外i-1個の未満未決定にn[j]を
print(sum(dp[k][l - 1]))

Measured memory_bytes: 62060
n=int(input())
l=sorted(list(map(int,input().split())))
c=0
for i in range(n-2):
  for j in range(i+1,n-1):
    for k in range(j+1,n):
      if l[i]==l[j] or l[j]==l[k]:
        continue
      if l[i]+l[j]>l[k] and l[j]-l[i]<l[k]:
        c+=1
print(c)

Measured memory_bytes: 9212
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<algorithm>

using namespace std;

int A, B;

int main() {
	cin >> A >> B;
	if (A < 6)cout << 0 << endl;
	else if (A < 13)cout << B / 2 << endl;
	else cout << B << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
    int n; cin >> n;
    bool flag = false;
    if(n%10 == 9) flag = true;
    if(n/10 == 9) flag = true;
    if(flag) puts("Yes");
    else puts("No");
    return 0;
}

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

#define int long long

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

template<class T> bool chmax(T &a, const T &b) { if(a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if(a > b) { a = b; return true; } return false; }


signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N, A; cin >> N >> A;
    vi x(N);
    REP(i, N)
    {
        cin >> x[i];
        x[i] -= A;
    }

    vvi dp(N+1, vi(6000, 0));
    dp[0][3000] = 1;
    for(int i = 0; i < N; i++)
    {
        for(int j = -3000; j < 3000; j++)
        {
            dp[i+1][j+3000] += dp[i][j+3000];
            if(j+x[i] < 3000) dp[i+1][j+3000] += dp[i][j+3000-x[i]];
        }
    }
    cout << dp[N][3000] - 1 << endl;
}

Measured memory_bytes: 5576
#include<bits/stdc++.h>
using namespace std;
long long x[1000010],y[1000010];
#define int long long
signed main(){
  
  cin.tie(0);
  ios::sync_with_stdio(false);

  string s;
  cin>>s;
  
  for(int i=0; i<s.size(); i++){
    if(s[i]==','){
      cout<<" ";
    }else cout<<s[i];
  }
  cout<<'\n';
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

string AL = "abcdefghijklmnopqrstuvwxyz";
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S;
    cin >> S;

    int N = sz(S);
    int mi = INT_MAX;

    for(char a : AL)for(char b : AL) {
        if(S[0] != a)continue;
        if(S[0] != S[N - 1] && b != S[N - 1])continue;
        char c[2];
        c[0] = a;
        c[1] = b;
        int k = 0, x = 0;
        rep(i, N) {
            if(S[i] == c[k]) {
                k = !k;
            } else {
                x++;
            }
        }
        smin(mi, x);
    }

    cout << ((mi&1)?"First":"Second") << endl;
}

Measured memory_bytes: 512
x,y,a,b,c=map(int,input().split()) #x,yだけ見る。
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p=sorted(p,reverse=True)[:x]
q=sorted(q,reverse=True)[:y]
print(sum(sorted(p+q+r, reverse=True)[:x+y]))


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

using ll = long long;

int main(){
  int n,w;
  cin >> n >> w; 
  vector<ll> dp(w+1);
  for(int item=0; item < n; item++){
    int peso, valor;
    cin >> peso >> valor;

    for(int peso_actual=w-peso; peso_actual >= 0; peso_actual--){
      dp[peso_actual+peso] = max(dp[peso_actual+peso], dp[peso_actual] + valor);
    }
  }

  ll ans = 0;
  for(int i=0; i < w+1; i++){
    ans = max(ans, dp[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
-- import Data.Array
import Data.Array.Unboxed
import Control.Monad.ST
import Data.Array.ST
import Data.Char

import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)
readInt = fst . fromJust . B.readInt
readInts = map readInt . B.words <$> B.getLine :: IO [Int]
readIntegers = map (fst . fromJust . B.readInteger) . B.words <$> B.getLine :: IO [Integer]
read2dInts = map (map (fst . fromJust . B.readInt) . B.words) . B.lines <$> B.getContents
readVInts = map (fst . fromJust . B.readInt) . B.lines <$> B.getContents
readVTuple = map ((\(a:b:_) -> (readInt a, readInt b)) . B.words) . B.lines <$> B.getContents :: IO [(Int, Int)] 

main :: IO ()
main = do
  (n:q:_) <- map read . words <$> getLine :: IO [Int]
  buff <- readVTuple :: IO [(Int, Int)]
  let (abs, pxs) = splitAt (n-1) buff
  putStrLn . unwords . map show $ solve' n q abs pxs
    
solve' n q abs pxs = elems dfs
  where
    tree = foldl' f (Map.singleton 1 []) abs :: Map.Map Int [Int]
    f t (a, b) = Map.insertWith (++) a [b] $ Map.insertWith (++) b [a] t
    countMap = foldl' g (IntMap.empty) pxs
    g counts (p, x) =  IntMap.insertWith (+) p x counts

    dfs :: UArray Int Int 
    dfs = runSTUArray $ do
      c <- newArray (1, n) 0 :: ST s (STUArray s Int Int)
      let 
        loop current parent point c = do
          let p = point + case (IntMap.lookup current countMap) of 
                Nothing -> 0 
                Just v -> v
          writeArray c current p
          forM_ (tree Map.! current) $ \next -> 
            if next == parent then return c else loop next current p c
          return c

      loop 1 0 0 c
        


Measured memory_bytes: 159612