akhauriyash/Code-Regression huggingface dataset:
/* {{{ */
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let 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! {
        n: usize,
        k: usize,
        x: [i64;n]
    }
    use std::cmp::min;
    let mut res = std::i64::MAX;
    for i in 0..(n-k+1) {
        let l = x[i];
        let r = x[i+k-1];
        let d = r - l + min(l.abs(), r.abs());
        res = min(d, res);
    }
    println!("{}", res);
}
/* vim:set foldmethod=marker: */


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

const int INF = 1e+8;
typedef pair<int,int> P;
int w, h, gx, gy, ans;

int dx[4] = {0,0,-1,+1};
int dy[4] = {-1,+1,0,0};

void debug(const vector<string>& s){
	cout << "[debug]" << endl;
	for(int y=0 ; y < s.size() ; y++ ){
		cout << s[y] << endl;
	}
	cout << endl;
}

// (x,y) ツづ個暗環置ツつゥツづァツ古シツつォ dir ツづ?環環づァツつオツつスツづ?つォ, ツ氾閉外ツづ可出ツつスツ篠楪づ?false ツづーツ陛板つオ,
// ツつサツつ、ツづ?づ按つ「ツづ?つォツづ?true ツづーツ陛板つオ, ツ環環づィツ終ツづュツづ?つスツつ?づ?づ個暗環置ツづー p ツづ可妥」ツ禿シツつキツづゥ.
bool move(const vector<string>& s,int x, int y, P& p, int dir, bool& flag){
	while( true ){
		int mx = x + dx[dir];
		int my = y + dy[dir];
		// ツ氾閉外ツづ可出ツつスツ篠?
		if( mx < 0 || my < 0 || mx >= w || my >= h ){
			return false;
		}
		// ツゴツーツδ仰づ可づつつ「ツつスツ篠?
		if( gx == mx && gy == my ){
			flag = true;
			return true;
		}
		if( s[my][mx] == '1' ){
			p.first = x;
			p.second = y;
			return true;
		}
		x = mx;
		y = my;
	}
}

void solve(vector<string> s, int x, int y , int cnt){
	if( cnt > 10 || cnt > ans ) return ;
	
	for(int i=0 ; i < 4 ; i++ ){
		if( x+dx[i] >= 0 && y+dy[i] >= 0 && x+dx[i] < w && y+dy[i] < h ){
			if( s[ y+dy[i] ][ x+dx[i] ] == '1' ) continue;
		}
		P p;
		bool flag = false;
		// ツ環環づァツつケツづゥ
		if( move( s , x , y , p , i , flag ) ){
			// ツゴツーツδ仰づ可づつつ「ツつスツ篠?
			if( flag ){
				ans = min( ans , cnt );
				return ;
			}else{
				int mx = p.first + dx[i];
				int my = p.second + dy[i];
				s[my][mx] = '0';
				solve( s , p.first , p.second , cnt+1 );
				s[my][mx] = '1';
			}
		}
	}
	
}

int main(){
	while( cin >> w >> h , w || h ){
		vector<string> s(h);
		
		for(int y=0 ; y < h ; y++ ){
			for(int x=0 ; x < w ; x++ ){
				char c;
				cin >> c;
				s[y].push_back( c );
			}
		}
		int sx, sy;
		for(int y=0 ; y < h ; y++ ){
			for(int x=0 ; x < w ; x++ ){
				if( s[y][x] == '2' ){
					sx = x;
					sy = y;
					s[y][x] = '0';
				}else if( s[y][x] == '3' ){
					gx = x;
					gy = y;
					s[y][x] = '0';
				}
			}
		}
		ans = INF;
		solve( s , sx , sy , 1 );
		if( ans == INF ){
			cout << -1 << endl;
		}else{
			cout << ans << endl;
		}
	}
}

Measured memory_bytes: 932
Q = int(input())
l, r = [], []
for i in range(Q):
    _l, _r = map(int, input().split())
    l.append(_l)
    r.append(_r)
max_r = max(r)

is_sosu = [1] * (max_r + 1)
is_sosu[0] = is_sosu[1] = 0
for i in range(2, max_r+1):
    if is_sosu[i]:
        for j in range(i*i, max_r+1, i):
            is_sosu[j] = 0

sums = [0] * (max_r + 1)
for i in range(1, max_r+1):
    if is_sosu[i] and is_sosu[(i+1)//2]:
        sums[i] = sums[i-1] + 1
    else:
        sums[i] = sums[i-1]

for i in range(Q):
    print(sums[r[i]] - sums[l[i]-1])


Measured memory_bytes: 87812
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
class Program
{       
    public void Slove()
    {
        var inputs = Console.ReadLine().Split();
        int a = int.Parse(inputs[0]);
        int b = int.Parse(inputs[1]);
        int k = int.Parse(inputs[2]);
        int max = Math.Max(a, b);
        int result = Enumerable.Range(1, max).Reverse().Where(x => a % x == 0 && b % x == 0).ToArray()[k - 1];
        System.Console.WriteLine(result);
    }
    
    static void Main(string[] args)
    {
        new Program().Slove();
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    lint X;
    cin >> X;
    lint amt = 100;
    int years = 0;
    while (amt < X) {
        amt += amt / 100;
        years++;
    }

    cout << years << endl;
    return 0;
};


Measured memory_bytes: 3652
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
)

var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	a := make([]int, 5)
	for i := 0; i < 5; i++ {
		a[i] = nextInt()
	}
	sort.Ints(a)
	d := 0
	if n%a[0] > 0 {
		d = a[0] - n%a[0]
	}
	t := (n+d)/a[0] + 4
	fmt.Fprintf(writer, "%d", t)
}

func main() {
	answer(os.Stdin, os.Stdout)
}


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

#define ed cout<<"\n";
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long 
#define ffor(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
#define rep(i, n) ffor(i,0,n)
#define All(obj) (obj).begin(),(obj).end()
#define INF ((ll)1e9+7)
#define c(a) cout<<a<<"\n";
using namespace std;
const int N = 100005;






int main() {
	speed;
	cout << fixed << setprecision(6);
	/*start*/
	int n, a, b;
	cin >> n >> a >> b;
	a *= n;
	n = a > b ? b : a;
	c(n);
	ed;
	return 0;
}



Measured memory_bytes: 256
import std.stdio;

void main(){
	int n, ans;
	while (readf("%d\n", &n), n != -1) {
		ans = 1150;
		if (n <= 10) {}
		else if (n < 20) ans += 125 * (n-10);
		else if (n < 30) ans += 1250 + 140 * (n-20);
		else ans += 1250 + 1400 + 160 * (n-30);
		writeln(4280 - ans);
	}
}

Measured memory_bytes: 984
#define		_CRT_SECURE_NO_WARNINGS
#include <cstdio>

int main()
{
	int		n;

	scanf("%d", &n);

	for (int i = 1; i <= n; i++)
	{
		if ((i % 3) == 0)
		{
			printf(" %d", i);
		}
		else
		{
			int	a = i;
			int b, c;

			while (a != 0)
			{
				b = a / 10;
				c = b * 10;

				if ((a - c) == 3)
				{
					printf(" %d", i);
					break;
				}
				a = b;
			}
		}
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 2700
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        boolean isOk = false;

        Scanner sc = new Scanner(System.in);
        int target = Integer.parseInt(sc.next());
        int minDistance = sc.nextInt();
        int maxDistance = sc.nextInt();

        for (int i=minDistance;i <= maxDistance;i++){
            if (i%target == 0){
                isOk = true;
                break;
            }
        }
        if(isOk){
            System.out.println("OK");
        }else{
            System.out.println("NG");
        }
    }
}


Measured memory_bytes: 35764
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int m, k;
  cin >> m >> k;
  int n = 1 << m;
  if(n <= k) {
    cout << -1 << endl;
    return 0;
  }
  if(m == 0) {
    cout << "0 0" << endl;
    return 0;
  }
  if(m == 1) {
    if(k == 1) {
      cout << -1 << endl;
    } else {
      cout << "0 0 1 1" << endl;
    }
    return 0;
  }
  for(int i = 0; i < n; i++) if(i != k) cout << i << " ";
  cout << k << " ";
  for(int i = n - 1; i >= 0; i--) if(i != k) cout << i << " ";
  cout << k << endl;
  return 0;
}


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

int main()
{
    int N;
    long int K;
    int Q;
    
    cin >> N;
    cin >> K;
    cin >> Q;
    
    vector<int> A(Q);
    vector<int> ans(N);

    for(int i= 0; i<N; i++){
        ans[i] = 0;
    }
    
    for(int i=0; i<Q; i++){
        int a;
        cin >> a;
//        A[i] = a;
        ans[a-1]++;
    }
    
    for(int i=0; i<N; i++){
        if(K-Q+ans[i] > 0){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 1408
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N, M;
  cin >> N >> M;
  vl H(N);
  REP(i, N) cin >> H[i];
  vl HH(N, 0);
  REP(i, M) {
    ll a, b;
    cin >> a >> b;
    HH[a - 1] = max(HH[a - 1], H[b - 1]);
    HH[b - 1] = max(HH[b - 1], H[a - 1]);
  }
  ll ans = 0;
  REP(i, N) if (HH[i] < H[i]) ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4780
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n;
int main(){
    cin>>n;
    vector<ll> a(n),b(n),c(n);
    rep(i,n) cin>>a[i];
    rep(i,n) cin>>b[i];
    rep(i,n) cin>>c[i];
    ll sum = 0;
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    rep(j,n){
        ll min1,max1;
        min1 = c.end()-upper_bound(c.begin(),c.end(),b[j]);
        max1 = lower_bound(a.begin(),a.end(),b[j]) - a.begin();
        //cout << min1 <<" "<< max1 << endl;
        sum += min1 * max1;
    }
    cout<<sum<<endl;

/*
    auto it = lower_bound(v.begin(), v.end(), 3);
    //探索したい値以上が現れる最初の位置のイテレータを取得。
    //ある値 keyより小さい配列Aの要素の個数nを求める場合
    auto Iter = lower_bound(A.begin(), A.end(), key);
    long n = Iter - A.begin();
    auto it = upper_bound(v.begin(), v.end(), 3);
    //探索したい値より大きい値が現れる最初の位置のイテレータを取得。
    auto Iter2 = upper_bound(C.begin(), C.end(), key);
    long n = B.end() - Iter;
    */
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vpii = vector<pii>;

const ll MOD = 1e9 + 7;
const int SZ = 2e5 + 100;
const int N = 3282;
int fact[SZ], factinv[SZ];
int dp[N];

ll modpow(ll x, ll n) {
    ll ans = 1;
    for (; n; n/=2) {
        if (n % 2 == 1) {
            ans = ans * x % MOD;
        }
        x = x * x % MOD;
    }
    return ans;
}

ll binom(ll n, ll k) {
    if (k < 0 || k > n) {
        return 0;
    }
    ll ans = fact[n];
    ans = ans * factinv[k] % MOD;
    ans = ans * factinv[n-k] % MOD;
    return ans;
}

ll paths(int dx, int dy) {
    return binom(dx+dy, dx);
}

int main() {
    ios::sync_with_stdio(false);
    fact[0] = 1;
    for (int i=1; i<SZ; i++) {
        fact[i] = 1ll * fact[i-1] * i % MOD;
    }
    factinv[SZ-1] = modpow(fact[SZ-1], MOD-2);
    for (int i=SZ-2; i>=0; i--) {
        factinv[i] = 1ll * factinv[i+1] * (i+1) % MOD;
    }
    int r, c, n;
    cin >> r >> c >> n;
    vpii walls(n+1);
    walls[n] = pii(r-1, c-1);
    for (int i=0; i<n; i++) {
        int y, x;
        cin >> y >> x;
        y--, x--;
        walls[i] = pii(y, x);
    }
    sort(walls.begin(), walls.end(), [](pii a, pii b) {
        int da = a.first + a.second;
        int db = b.first + b.second;
        if (da != db) {
            return da < db;
        }
        return a < b;
    });
    for (int i=0; i<=n; i++) {
        int y, x;
        tie(y, x) = walls[i];
        dp[i] = paths(y, x);
        for (int j=0; j<i; j++) {
            int y2, x2;
            tie(y2, x2) = walls[j];
            if (y2<=y && x2<=x) {
                int tmp = 1ll * dp[j] * paths(y-y2, x-x2) % MOD;
                dp[i] = (dp[i] + MOD - tmp) % MOD;
            }
        }
    }
    cout << dp[n] << '\n';
}


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

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define here(x) cout << " #x = " << x << endl;
#define show(x) {for( auto ii : x) cout << ii << " "; cout << endl;}
#define ll  long long int
#define ld long double
#define vi vector<ll>
#define vii vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,a,b) for(ll i=a;i>=b;i--)
#define traverse(x,it) for(typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define all(c) c.begin(),c.end()
#define sz(c) (ll)c.size()
#define lcm(a,b) (a*b)/(__gcd(a,b))
#define init(x,a) memset(x,a,sizeof(x))
#define lbd(a,val) lower_bound(all(a),val)
#define ubd(a,val) upper_bound(all(a),val)
#define flush fflush(stdout)
#define pb push_back
#define pob pop_back
#define mp1 make_pair
#define F first
#define S second
#define en '\n'
#define mod (ll)1000000007
#define M (ll)998244353
#define N 100005
#define PI 3.14159265358979323846
//printf("%.10Lf\n",z);
void judge()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    return;
}

bool compare(ll x, ll y)
{
    //ll i,j,k=0,l=0;
    return x > y;
}
ll powerlong(ll base, ll exponent, ll modulus)
{
    ll k = 1;
    while (exponent)
    {
        if (exponent & 1 == 1)
        {
            k = (k * base) % modulus; exponent--;
            continue;
        }
        exponent = exponent / 2;
        base = (base * base) % modulus;
    }
    return k;
}

int main()
{
    IOS;
    //judge();
    ll t = 1;
    //cin >> t;
    while (t--)
    {
        ll i = 0, j = 0, k = 0, l = 0, z = 0;
        ll n, m = 0;
        cin >> n;
        ll a[3 * n] = {0};
        ll left[n + 1] = {0}, right[n + 1] = {0};
        multiset<ll> ls, rs;
        for (i = 0; i < 3 * n; i++)
        {
            cin >> a[i];
            if (i < n)
            {
                ls.insert(a[i]); l += a[i];
            }
            if (i >= 2 * n)
            {
                rs.insert(a[i]); z += a[i];
            }
        }
        sort(a, a + n);
        sort(a + 2 * n, a + 3 * n); i = 0; j = n;
        for (k = 0; k <= n; k++)
        {
            left[i] = l;
            ls.insert(a[i + n]); l += a[i + n] - *(ls.begin());
            ls.erase(ls.begin()); i++;
            right[j] = z;
            rs.insert(a[n + j - 1]); z += a[n + j - 1] - *(--rs.end());
            rs.erase(--rs.end()); j--;
        }
        /*for (i = 0; i <= n; i++)
        {
            cout << left[i] << " " << right[i] << endl;
        }*/
        for (i = 0, k = (ll) - 1000000000000000 ; i <= n; i++)
        {
            l = left[i] - right[i];
            k = max(k, l);
        }
        cout << k << endl;
    }
}

Measured memory_bytes: 13568
/*
                        Author: Ankit Kaul
**********************Code Belongs to Respective Author Only************************************
*/
/*#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include <bits/stdc++.h>
#define endl       '\n'
#define PI          3.141592653589
#define jaldi       ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define M           1000000007
#define int         long long int
#define inf         INT_MAX
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
using namespace std;
int gcd(int a,int b) { return b == 0 ? a : gcd(b, a % b); }
int power(int x,int n){
    int result=1;
    while(n>0)
        {   if(n % 2 ==1)
            result=(result * x) % M;
            x=(x*x)% M;
            n=n/2;
        }
    return result % M;
}      
bool isPrime(int n)
    {
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    return true;
    }
int inv(int a,int m)
{   return power(a,m-2);
}
int lcm(int a,int b)
{   return a*b/(gcd(a,b));
}
signed main()
{   jaldi
    int n;
    cin>>n;
    vector<int>a;
    for(int i=0;i<n;i++)
    {   int x;
        cin>>x;
        a.pb(x);
    }
    sort(all(a));
    int ans=0;
    for(int i=0;i<n;i++)
    {   for(int j=i+1;j<n;j++)
        {   int mx=a[i]+a[j];
            ans+=lower_bound(all(a),mx)-a.begin()-j-1;   
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,a,f[100005],ans;
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        f[a-1]++;
	    f[a+1]++;
	    f[a]++;
    }
    for(int i=1;i<=100000;i++){
    	if(f[i]>ans){
    		ans=f[i];
		}
	}
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-
import sys

str_lines = [x.strip("\n") for x in sys.stdin.readlines()]

int_lines=[]
for S in str_lines:
  int_lines.append( list( map(int, S.split()) ) )

#-----
for L in int_lines:
  x, y = L
  
  if x == 0 and y == 0:
    break
  else:
    if x > y:
      print(y, x)
    else:
      print(x, y)



Measured memory_bytes: 6448
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  int X, t;
  ci(X, t);
  if(X <= t){
    co(0);
  }
  else{
    co(X - t);
  }
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
# define MOD 1000000007
typedef long long ll;
int dp[3001][3001];
// int solve(int n, string str, int index, int greater){
//     if(index == n-1){
//         if(greater == 0){
//             if(str[index-1] == '>') return 1;
//             else return 0;
//         }else{
//             if(str[index-1] == '>') return 0;
//             else return 1;
//         }
//     }
//     if(dp[index][greater] != -1) return dp[index][greater];
//     int rem = n - index;
//     int smaller = rem - greater;
//     int ans = 0;
//     if(str[index-1] == '>'){
//         if(greater == 0){
//             for(int i=1;i<=smaller;i++){
//                 ans = (ans + solve(n, str, index + 1, smaller - i))%MOD;
//             }
//         }
//         else ans = (MOD + solve(n, str, index, greater - 1) - solve(n, str, index + 1, greater - 1))%MOD;
//     }else if(str[index-1] == '<'){
//         if(greater > 0) ans = (solve(n, str, index, greater - 1) + solve(n, str, index + 1, greater - 1))%MOD;
//     }
//     return dp[index][greater] = ans;
// }
int main(){
	int n;
	string str;
	cin>>n;
	cin>>str;
	dp[n-1][0] = (str[n-2] == '>') ? 1 : 0;
	dp[n-1][1] = (str[n-2] == '<') ? 1 : 0;
	for(int i=n-2;i>=1;i--){
	    int rem = n-i;
	    for(int g=0;g<=rem;g++){
	        int s = rem - g;
	        if(g == 0){
	            dp[i][g] = 0;
	            if(str[i-1] == '>'){
	                for(int j=1;j<=s;j++){
    	                dp[i][g] = (dp[i][g] + dp[i+1][s-j])%MOD;
    	            }
	            }
	        }else{
	            if(str[i-1] == '>'){
	                dp[i][g] = (dp[i][g-1] - dp[i+1][g-1] + MOD)%MOD;
	            }else if(str[i-1] == '<'){
	                dp[i][g] = (dp[i][g-1] + dp[i+1][g-1])%MOD;
	            }
	        }
	    }
	}
	int ans = 0;
	for(int i=1;i<=n;i++){
	    ans = (ans + dp[1][n-i])%MOD;
	}
	cout<<ans;
}

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

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i <= int(n); ++i)
#define ms(a, x) memset(a, x, sizeof(a))
#define F first
#define S second
#define endl '\n'
#define all(x) (x).begin(),(x).end()

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,k;
    cin>>n>>k;
    constexpr int mod=1e9+7;
    ll ans=0;
    for(int i=k;i<=n;i++){
        ll mn=ll(i-1)*i/2;
        ll mx=ll(n+n-i+1)*i/2;
        (ans+=mx-mn+1)%=mod;
    }
    cout<<ans+1;
    return 0;
}



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

class Program
{
    static void Main()
    {
        int[] arr = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int a = arr[0];
        int b = arr[1];
        int c = arr[2];
        int ans = 0;
        for (int i = a; i <= b; i++)
        {
            if (c % i == 0)
            {
                ans++;
            }
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 18428
#include <stdio.h>
int main(){
  int a,b,c;
  int temp;

  scanf("%d%d%d",&a,&b,&c);
  if(b>c){
    temp=b;
    b=c;
    c=temp;
  }
  if(a>b){
    temp=a;
    a=b;
    b=temp;
  }
  if(b>c){
    temp=b;
    b=c;
    c=temp;
  }

  printf("%d %d %d\n",a,b,c);

  return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <cmath>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <algorithm>
#include <unordered_map>
using namespace std;
#define ll long long
 
const int N = 1e5+5;
int n, m;
vector<int> adj[N];
int res[N];
bool vis[N];
 
void dfs(int node){
    vis[node]=true;
    for (int v: adj[node]){
        if (!vis[v]){
            dfs(v);
        }
    }
}
 
int count_components(){
    int count=0;
    for (int i=1; i<=n; i++){
        if (!vis[i]){
            res[count]=i;
            count++;
            dfs(i);
        }
    }
    return count;
}
int main() {
    cin>>n>>m;
    for (int i=0; i<m; i++){
        int u, v;
        cin>>u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    int ans=count_components();
    cout<<ans-1<<endl;
    return 0;
}

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

typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int H, W;
    cin >> H >> W;
    vector<vector<int>> dist(10,vector<int>(10,0));
    for (int i=0;i<10;i++){
        for (int j=0;j<10;j++){
            cin >> dist[i][j];
        }
    }
    for (int k=0;k<10;k++){
        for (int i=0;i<10;i++){
            for (int j=0;j<10;j++){
                dist[i][j] = min(dist[i][j],dist[i][k]+dist[k][j]);
            }
        }
    }
    int sum = 0;
    for (int i=0;i<H;i++){
        for (int j=0;j<W;j++){
            int a;
            cin >> a;
            if (a==-1) continue;
            if (a==1) continue;
            sum += dist[a][1];
        }
    }
    cout << sum << "\n";
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    long long int N,K,mintemp,abs,min;

    scanf("%lld%lld",&N,&K);
    mintemp = N%K;

    if(mintemp-K<0)abs = K-mintemp;
    else abs = mintemp-K;
    if(mintemp<=abs)
        min = mintemp;
    else
        min = abs;
    printf("%lld\n",min);
    

    return 0;
}

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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
// #define LOG(...)
#define FOR(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for(int i = (int)(n - 1); i >= 0; --i)
#define RFOR(i, a, b) for(int i = (int)(b - 1); i >= (int)(a); --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)
#define BIT(x, i) (((x) >> (i)) & 1)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vc> vvc;
typedef vector<vll> vvll;

struct P {
  string name;
  int begin, end;

  bool operator <(const P& p) const {
    return begin < p.begin;
  }
};

int main() {
  int n, p;
  while(cin >> n >> p, n) {
    vector<P> database(n);
    REP(i, n){
      int y;
      cin >> database[i].name >> y >> database[i].end;
      database[i].begin = database[i].end - y + 1;
    }
    SORT(database);
    REP(i, p){
      int y;
      cin >> y;
      auto it = lower_bound(ALL(database), y, [](const P &p, const int &y){
        return p.end < y;
      });
      if (it == database.end() || it->begin > y)
        cout << "Unknown" << endl;
      else
        printf("%s %d\n", it->name.c_str(), y - it->begin + 1);
    }
  }
}

Measured memory_bytes: 3240
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;using pll=pair<ll,ll>;using pld=pair<ld,ld>;
const ll INF=1LL<<60;void solve();int main(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();}
#define fi first
#define se second
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
#define _rep2(i,k,n,d) for(ll i=k;d!=0&&d>0?i<n:i>n;i+=d)
template<class T> vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b; return 1;} return 0;}
template<class T> void contout(const T &v){for(auto it=v.begin();it!=v.end();++it,cout<<(it!=v.end()?" ":"\n"))cout<<*it;}

void solve(){
  ll n,k; cin>>n>>k;
  vector<ll> cnt(40);
  rep(i,n){
    ll a; cin>>a;
    rep(d,40) cnt[d]+=(a>>d)&1;
  }
  vector<ll> dp{0,-1};
  rep(d,39,-1,-1){
    ll kb=(k>>d)&1;
    vector<ll> newdp{-1,-1};
    rep(lt,2)rep(x,2){
      ll nlt=lt;
      if((!lt)&&(x>kb)) continue;
      if(x<kb) nlt=1;
      if(dp[lt]>=0) chmax(newdp[nlt],dp[lt]+(x?n-cnt[d]:cnt[d])*((ll)1<<d));
    }
    dp=newdp;
  }
  cout<<max(dp[0],dp[1])<<"\n";
}

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列 -92
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}



int main(){
    int x1,y1,x2,y2;
    cin >> x1 >> y1 >>x2 >> y2;
    int x3,y3,x4,y4;
    y3 = y2 + (x2-x1);
    x3 = x2 - (y2-y1);
    x4 = x1 - (y2-y1);
    y4 = y1 + (x2-x1);
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn get<T: FromStr>() -> T
        where <T as FromStr>::Err: Debug
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
        where <T as FromStr>::Err: Debug
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

fn main() {
    let nm: Vec<i64> = util::gets();
    let n = nm[0];
    let m = nm[1];

    let mut xs: Vec<i64> = util::gets();
    let mut ys: Vec<i64> = util::gets();

    xs.sort();
    ys.sort();

    let modulo = 1_000_000_000 + 7;

    let xx = xs.windows(2)
        .map(|ab| ab[1] - ab[0])
        .enumerate()
        .map(|(i, l)| ((n - i as i64 - 1) * (i as i64 + 1) * l) % modulo)
        .fold(0, |acc, a| (acc + a) % modulo);

    let yy = ys.windows(2)
        .map(|ab| ab[1] - ab[0])
        .enumerate()
        .map(|(i, l)| ((m - i as i64 - 1) * (i as i64 + 1) * l) % modulo)
        .fold(0, |acc, a| (acc + a) % modulo);

    println!("{}", (xx * yy) % modulo);
}


Measured memory_bytes: 10492
#include <stdio.h>
int main(void){
    
    int N;
    scanf("%d",&N);
    char s[N+1],t[N+1],u[N+N+1];
    scanf("%s%s",s,t);
    int l=0,m=0,n=0;
    while(s[l]!='\0'){
       u[n]=s[l];
       n++;
       u[n]=t[m];
       l++; m++; n++;
    }
    u[n]='\0';
    printf("%s\n",u);
    return 0;
}

Measured memory_bytes: 128
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let (w, h, n) = read!(usize, usize, usize);
    let xya: Vec<(usize, usize, usize)> = read!(usize, usize, usize; n);

    let mut p1 = (0usize, 0usize);
    let mut p2: (usize, usize) = (w, h);

    for (x, y, a) in xya {
        if a == 1 {
            p1 = (max(p1.0, x), p1.1);
        } else if a == 2 {
            p2 = (min(p2.0, x), p2.1);
        } else if a == 3 {
            p1 = (p1.0, max(p1.1, y));
        } else if a == 4 {
            p2 = (p2.0, min(p2.1, y));
        }
    }

    if p2.0 > p1.0 && p2.1 > p1.1 {
        println!("{}", (p2.0 - p1.0) * (p2.1 - p1.1));
    } else {
        println!("0");
    }
}


Measured memory_bytes: 4352
def A(i,x):
 while i<=n:t[i]+=x;i+=i&-i
(n,q),c,*z=[[*map(int,t.split())]for t in open(0)]
a=[0]*q
j,*b=t=[0]*9**6
for i in sorted(range(q),key=lambda x:z[x][1]):
 l,r=z[i]
 while j<r:d=c[j];j+=1;A(b[d]+1,1);b[d]=j;A(j+1,-1)
 while l:a[i]+=t[l];l-=l&-l
print(*a)

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> input(m);
    for (int i = 0; i < m; ++i) {
        int x, y;
        cin >> x >> y;
        --x; --y;
        input[i].first = x;
        input[i].second = y;
    }
    vector<bool> red(n, false);
    red[0] = true;
    vector<int> num(n, 1);
    for (int i = 0; i < m; ++i) {
        int from = input[i].first;
        int to = input[i].second;
        if (red[from]) red[to] = true;
        if (num[from] == 1) red[from] = false;
        num[from]--;
        num[to]++;
    }
    int ans = 0;
    for (bool i : red) if (i) ans++;
    cout << ans << endl;
}


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

typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;

#define endl '\n'
#define ff first
#define ss second
#define int long long
#define pb push_back
#define f(i,l,r) for(ll i=l;i<=r;i++)
#define rf(i,r,l) for(ll i=r;i>=l;i--)
#define Max 5000001
#define inf 2147483647
#define llinf 9223372036854775807
#define all(v) v.begin(),v.end()
#define bp(n) __builtin_popcountll(n)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

#define d0(a) cout<<a<<' ';
#define d1(a) cout<<a<<endl;
#define d2(a,b) cout<<a<<' '<<b<<endl;
#define d3(a,b,c) cout<<a<<' '<<b<<' '<<c<<endl;
#define d4(a,b,c,d) cout<<a<<' '<<b<<' '<<c<<' '<<d<<endl;
#define d5(a,b,c,d,e) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<endl;
#define d6(a,b,c,d,e,f) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<' '<<f<<endl;

const ll N=1e5+5,mod=1e9+7,bit=61;

bool check(vector<pair<pll,ll>> &v)
{
    ll sum=0;
    for(auto x:v)
    {
        if(sum+x.ff.ff<0)
        {
            return 0;
        }
        sum+=x.ff.ss;
    }
    return 1;
}

signed main()
{
    fast;

    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll n;
        vector<pair<pll,ll>> l,r;
        cin>>n;
        ll b=0;
        f(i,1,n)
        {
            string s;
            cin>>s;
            ll pref=0;
            ll sum=0;
            for(auto x:s)
            {
                sum+=(x=='('?1:-1);
                pref=min(pref,sum);
            }
            if(sum>=0)  // only left side
            {
                l.pb({{pref,sum},i});
            }
            else
            {
                r.pb({{-sum+pref,-sum},i});
            }
            b+=sum;
        }
        sort(l.rbegin(),l.rend());
        sort(r.rbegin(),r.rend());
        if(check(l) and check(r) and b==0)
        {
            cout<<"Yes\n";
//            for(auto x:l)
//            {
//                cout<<x.ss<<' ';
//            }
//            for(auto x:r)
//            {
//                cout<<x.ss<<' ';
//            }
//            cout<<endl;
        }
        else
        {
            cout<<"No\n";
        }
    }
    return 0;
}


















Measured memory_bytes: 26824
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    string s,t; cin>>s>>t;
    ll n=s.size();
    bool ifokay=false;
    rep(i,n){
        bool ifokay_=true;
        rep(j,n){
            if(s[j]!=t[(i+j)%n]) ifokay_=false;
        }
        if(ifokay_) ifokay=true;
    }
    if(ifokay) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<vector>
#include <iostream>
#include<string>
#include <complex>
#include <algorithm>
#include<string>

using namespace std;

int main(){
    int n , _t;
    cin >> n;
    cin >> _t;
    int c[n];
    int t[n];

    for(int i = 0; i <n; i++){
        cin >> c[i];
        cin >> t[i];
    }

    int min = 1001;

    for(int i = 0; i < n; i++){
        if(_t >= t[i] && c[i] < min){
            min = c[i];
        }
    }

    if(min == 1001){
        cout << "TLE" << endl;
    }else{
        cout << min << endl;
    }

}

Measured memory_bytes: 256
S = input()
T = input()

lenS = len(S)
lenT = len(T)
ansA = 0
for i in range(lenS-lenT+1):
    cnt = 0
    ans = 0
    for j in S[i:i+lenT]:
        if j == T[cnt]:
            ans += 1
        cnt += 1
    ansA = max(ans, ansA)

print(lenT - ansA)
            


Measured memory_bytes: 9112
while True:
    H, W = [int(x) for x in input().split()]
    
    if H == W == 0: break
        
    for i in range(H):
        if i == 0 or i == H-1:
            print('#'*W)
        else:
            print('#' + '.'*(W-2) + '#')
    print()


Measured memory_bytes: 5616
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;
pair <long long, long long> arm_lr[100000];
int main(){
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        int X;
        int L;
        cin >> X >> L;
        arm_lr[i] = make_pair(X + L, X - L);
    }
    sort(arm_lr, arm_lr + N);
    long long cur_pos = LLONG_MIN;
    int ans = 0;
    for(int i = 0; i < N; i++){
        if(cur_pos <= arm_lr[i].second){
            ans ++;
            cur_pos = arm_lr[i].first;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n,a,b,c,y;
    cin>>n>>y;
    y/=1000;
    bool flag=0;
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=n-i;j++)
        {
            for(int k=0;k<=n-i-j;k++)
            {
                if(i*10+j*5+k==y&&i+j+k==n)
                {
                    a=i;
                    b=j;
                    c=k;
                    flag=1;
                    break;
                }
            }
            if(flag)
                break;
        }
        if(flag)
            break;
    }
    if(flag)
        printf("%d %d %d\n",a,b,c);
    else
        printf("-1 -1 -1\n");
    return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int N, K; cin >> N >> K;
  if ((N+1)/2<K) { cout << -1 << endl; return 0;}
  int l = (N+1)/2;
  rep(i,l) {
    int a = K+i;
    int b = K+(2*N-l)+i;
    int c = K+2*N+i*2;
    cout << a << " " << b << " " << c << endl;
  }
  rep(i,N-l) {
    int a = K+l+i;
    int b = K+N+i;
    int c = K+2*N+i*2+1;
    cout << a << " " << b << " " << c << endl;
  }
  return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
vector<vector<vector<double>>> memo;
double ex(int n, int i, int j, int k) {
  double mem = memo[i][j][k];
  if(mem >= 0) return mem;
  if(i == 0 && j == 0 && k == 0) return 0.0;
  double res = 0.0;
  if(i > 0) res += i * ex(n, i-1, j, k);
  if(j > 0) res += j * ex(n, i+1, j-1, k);
  if(k > 0) res += k * ex(n, i, j+1, k-1);
  res += n;
  res *= 1.0 / (i + j + k);
  memo[i][j][k] = res;
  return res;
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  memo.resize(310, vector<vector<double>>(310, vector<double>(310, -1)));
  int n; cin >> n;
  vector<int> v(3);
  for(int i=0;i<n;++i) {
    int tmp; cin >> tmp;
    v[tmp-1]++;
  }
  cout << ex(n, v[0], v[1], v[2]) << endl;
}


Measured memory_bytes: 239616
#include <cstdio>
#include <cmath>

#define EPS (1e-10)
#define equals( A, B ) (fabs((A) - (B)) < EPS)

class Point {
public:
    double x, y;
    Point( double x = 0, double y = 0 ): x(x), y(y) {}
    
    Point operator + ( Point p ) { return Point( x + p.x, y + p.y ); }
    Point operator - ( Point p ) { return Point( x - p.x, y - p.y ); }
    Point operator * ( double a ) { return Point( a * x, a * y ); }
    Point operator / ( double a ) { return Point( x / a, y / a ); }

    double abs() { return sqrt( norm() ); }
    double norm() { return x * x + y * y; }

    bool operator < ( const Point &p ) const {
	return ( x != p.x ) ? x < p.x : y < p.y;
    }

    bool operator == ( const Point &p ) const {
	return equals( x, p.x ) && equals( y, p.y ); 
    }

    double dot( Point a ) { return x * a.x + y * a.y; }
    double cross( Point a ) { return x * a.y - y * a.x; }
};

typedef Point Vector;

class Line {
public:
    Point p1, p2;
    Line( Point p1 = Point(), Point p2 = Point() ) {}
    // ?????´????????????( cos = 0 )
    bool isOrthogonal( Line a ) {
	return equals( 0.0, (p1 - p2).dot( a.p1 - a.p2 ) );
    }
    // ??????????????????( sin = 0 )
    bool isParallel( Line a ) {
	return equals( 0.0, (p1 - p2).cross( a.p1 - a.p2 ) );
    }
    Point projection( Point p ) {
	Vector v12 = p2 - p1;
	double r = v12.dot( p - p1 ) / v12.norm();
	
	return p1 + v12 * r;
    }
};

typedef Line Segment;

int main()
{
    Point p1, p2, p;
    int q;
    Line l12;

    scanf( "%lf %lf %lf %lf", &p1.x, &p1.y, &p2.x, &p2.y );

    if ( p1 == p2 ) return 1;

    l12.p1 = p1;
    l12.p2 = p2;

    scanf( "%d", &q );
    
    for ( int i = 0; i < q; i++ ) {
	scanf( "%lf %lf", &p.x, &p.y );
	
	Point proj = l12.projection( p );

	printf( "%.10lf %.10lf\n", proj.x, proj.y );
    }

    return 0;
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

struct Data
{
    ll P;
    ll Y;
    ll i;
};
Data D[100005];
pll A[100005];
int B[100005];
string S[100005];

int main()
{
    ll N, M;
    cin >> N >> M;
    REP(i, M)
    {
        cin >> D[i].P >> D[i].Y;
        D[i].i = i;
    }
    sort(D, D + M, [](Data a, Data b) { return a.Y < b.Y; });
    REP(i, M)
    {
        A[D[i].i].second = ++B[D[i].P];
        A[D[i].i].first = D[i].P;
    }

    S[0] = "000000";
    REP(i, 100000)
    {
        S[i + 1] = S[i];
        S[i + 1][5]++;
        for (int j = 5; j >= 0; --j)
        {
            if (S[i + 1][j] - '0' <= 9)
                break;
            S[i + 1][j] = '0';
            S[i + 1][j - 1]++;
        }
    }

    REP(i, M)
    {
        cout << S[A[i].first] << S[A[i].second] << endl;
    }
    return 0;
}

Measured memory_bytes: 11392