akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(12), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
using Int = long long;
struct SegTree {
    int N;
    vector<int> A;
    SegTree(int n) {
        N = 1; while (N < n) N *= 2;
        A.resize(2 * N);
    }
    void set(int idx, int val) {
        idx += N;
        A[idx] = val;
        idx >>= 1;
        while (idx > 0) {
            A[idx] = max(A[2*idx+0], A[2*idx+1]);
            idx >>= 1;
        }
    }
    int maximum(int L, int R) {
        L += N, R += N;
        int ans = INT_MIN;
        while (L < R) {
            if (L & 1) ans = max(ans, A[L++]);
            if (R & 1) ans = max(ans, A[--R]);
            L >>= 1, R >>= 1;
        }
        return ans;
    }
    int find_ge_0(int L, int val, int node, int nodeL, int nodeR) {
        if (nodeR <= L || A[node] < val) {
            return -1;
        }
        if (nodeR - nodeL == 1) {
            return node - N;
        }
        int idx = 0;
        if ((idx = find_ge_0(L, val, 2*node+0, nodeL, (nodeL + nodeR) / 2)) >= 0 ||
            (idx = find_ge_0(L, val, 2*node+1, (nodeL + nodeR) / 2, nodeR)) >= 0) {
            return idx;
        }
        return -1;
    }
    int find_ge(int L, int val) { // min idx s.t. idx >= L && st[idx] >= val
        return find_ge_0(L, val, 1, 0, N);
    }
};
int main() {
    int N, Q; cin >> N >> Q;
    SegTree st(N);
    for (int i = 0; i < N; i++) {
        int a; cin >> a; st.set(i, a);
    }
    for (int i = 0; i < Q; i++) {
        int t; cin >> t;
        if (t == 1) {
            int x, v; cin >> x >> v; x--;
            st.set(x, v);
        } else if (t == 2) {
            int l, r; cin >> l >> r; l--, r--;
            cout << st.maximum(l, r + 1) << '\n';
        } else {
            int x, v; cin >> x >> v; x--;
            int idx = st.find_ge(x, v);
            cout << (idx < 0 ? N + 1 : idx + 1) << '\n';
        }
    }
    return 0;
}


Measured memory_bytes: 5288
#include<stdio.h>
#include<string.h>

int main(void){
  int n;
  scanf("%d",&n);

  char s[n][11];
  for(int i = 0;i < n;i ++){
    scanf("%s",s[i]);
  }
  
  qsort(s,n,11,strcmp);
  
  int count = 1;
  for(int i = 0;i < n-1;i ++){
    if(strcmp(s[i],s[i+1]) != 0){
      count ++;
    }
  }

  printf("%d\n",count);
  
  return 0;
}

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

namespace Test01
{
    class PriorityQueue
    {
        int H;        
        int[] heap;
        const int MAX = 2000000;

        public PriorityQueue()
        {
            H = 0;
            heap = new int[MAX];
        }

        public PriorityQueue(int size)
        {
            H = size;
            heap = new int[H + 1];
        }

        //上のuから下までずーと(入れ替えられなくなるor限界Hまで)
        public void MaxHeapfy(int p)
        {
            while (2 * p <= H)
            {
                int son_n = 2 * p;
                int son = heap[2 * p];
                if (2 * p + 1 <= H && son < heap[2 * p + 1])
                {
                    son = heap[2 * p + 1];
                    son_n++;
                }

                if (son > heap[p])
                {
                    int tmp = heap[p];
                    heap[p] = son;
                    heap[son_n] = tmp;
                }
                else
                {
                    break;
                }

                p = son_n;
            }
        }

        public void BuildMaxHeap()
        {
            for (int s = H / 2; s >= 1; s--)
            {
                MaxHeapfy(s);
            }
        }

        public void Insert(int key)
        {
            //下から上にずーとヒープ
            H++;
            heap[H] = key;

            int son = H;

            while (son != 1)
            {
                int p = son / 2;
                if (heap[son] > heap[p])
                {
                    int tmp = heap[p];
                    heap[p] = heap[son];
                    heap[son] = tmp;
                    son /= 2;
                }
                else
                {
                    break;
                }
            }

        }

        public int ExtractMax()
        {
            int max = heap[1];
            heap[1] = heap[H];
            H--;

            MaxHeapfy(1);

            return max;
        }

    }

    class Program
    {
        
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int N = input[0];
            int M = input[1];

            PriorityQueue pq = new PriorityQueue();
            int[] A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            for (int i = 0; i < N; i++) pq.Insert(A[i]);
            for(int i = 0; i < M; i++)
            {
                int a = pq.ExtractMax();               
                a /= 2;
                pq.Insert(a);
            }

            long sum = 0;
            for(int i = 0; i < N; i++)
            {
                sum += pq.ExtractMax();
            }

            Console.WriteLine(sum);
        }
    }
}


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

namespace ABC136A
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] ABC = CIN.LongArray();

            long A = ABC[0];
            long B = ABC[1];
            long C = ABC[2];

            if (A - B > C)
            {
                Console.WriteLine(0);
                return;
            }
            Console.WriteLine(C - A + B);
        }
    }

    internal static class CIN
    {
        public static string String()
        {
            return Console.ReadLine();
        }

        public static int Int()
        {
            return int.Parse(Console.ReadLine());
        }

        public static int[] IntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        public static long Long()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] LongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] DoubleArray()
        {
            return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
        }
    }
}

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

int calc(vector<int> &v) {
    if (v.size() == 1) return v[0];
    vector<int> nv;
    for (int i = 0; i < v.size() - 1; i++)
        nv.push_back(abs(v[i] - v[i + 1]));
    return calc(nv);
}

int calc2(vector<int> &v) {
    if(v.size()==1) return v[0];
    vector<int> nv;
    for (int i = 0; i < v.size() / 2; i++)
        nv.push_back(abs(v[2*i] - v[2*i+1]));
    if (v.size() & 1) { 
        vector<int> nv2;
        for (int i = 0; i < v.size() / 2; i++) nv2.push_back(abs(v[2*i + 1] - v[2*i+2]));
        for (int i = 0; i < nv.size(); i++) nv[i] = abs(nv[i] - nv2[i]);
    }
    return calc2(nv);
}

int calc3(vector<int> &v) {
    int c2 = calc2(v);
    if (c2 == 2) {
        int has1 = 0;
        for (auto &x : v) has1 |= x == 1;
        if (has1) c2 = 0;
    }
    return c2;
}

int main () {
    int n;
    string s;
    cin >> n >> s;
    vector<int> a(n, 0);
    for (int i = 0; i < n; i++) a[i] = s[i] - '1';
    cout << calc3(a) << "\n";
}


Measured memory_bytes: 9980
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <bitset>
#include <functional>
#include <queue>
#include <utility>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long LL;
const int INF = 1 << 29;	// 十分大きい値にする, INT_MAX にしないのはオーバーフロー対策

using namespace std;

// 深さ優先探索 cur:竹のインデックス a:Aの素材になる竹の長さ b:Bの素材になる竹の長さ c:Cの素材になる竹の長さ
int dfs(vector<int> l, int cur, int a, int b, int c, const int N, const int A, const int B, const int C)
{
	if (cur == N) {
		if (min({ a, b, c }) > 0) {
			return abs(a - A) + abs(b - B) + abs(c - C) - 30;
		}
		return INF;
	}
	int ret0 = dfs(l, cur + 1, a, b, c, N, A, B, C);	// 何も竹を使わない
	int ret1 = dfs(l, cur + 1, a + l[cur], b, c, N, A, B, C) + 10;	// 竹をAに使う
	int ret2 = dfs(l, cur + 1, a, b + l[cur], c, N, A, B, C) + 10;	// 竹をBに使う
	int ret3 = dfs(l, cur + 1, a, b, c + l[cur], N, A, B, C) + 10;	// 竹をCに使う
	return min({ ret0, ret1, ret2, ret3 });
}

int main(void)
{
	int N, A, B, C;
	vector<int> l;

	cin >> N >> A >> B >> C;
	FOR(i, 0, N) {
		int tmp;
		cin >> tmp;
		l.push_back(tmp);
	}

	cout << dfs(l, 0, 0, 0, 0, N, A, B, C) << endl;

	return 0;
}

Measured memory_bytes: 256
using System;

namespace _171_b
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var firstData = ReadSplitLineInt();
            if (firstData.Length != 2) return;
            var n = firstData[0];
            var k = firstData[1];

            var secondData = ReadSplitLineInt();
            if (secondData.Length != n) return;
            var prices = secondData;
            Array.Sort(prices);

            var sum = 0;
            for (var i = 0; i < k; i++)
            {
                sum += prices[i];
            }
            Console.WriteLine(sum);
        }

        private static int[] ReadSplitLineInt()
        {
            var line = Console.ReadLine();
            var stArray = line?.Split(' ');
            if (stArray == null) return new[] {0};

            var data = new int[stArray.Length];
            for (var i = 0; i < stArray.Length; i++)
            {
                data[i] = int.Parse(stArray[i]);
            }

            return data;
        }
    }
}

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

int main() {
    int A, B, C, K;
    cin >> A >> B >> C >> K;

    if (A > B) {
        int t = A;
        A = B;
        B = t;
    }
    if (B > C) {
        int t = B;
        B = C;
        C = t;
    }
    if (A > B) {
        int t = A;
        A = B;
        B = t;
    }

    for (int i = 0; i < K; ++i) C *= 2;

    cout << A + B + C << endl;
    
    return 0;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int n, mx = 0;
    string s;
    map<string, int> m;
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> s, ++m[s], mx = max(mx, m[s]);
    for (auto i = m.begin(); i != m.end(); ++i) if (i -> second == mx) cout << i -> first << '\n';
    return 0;
}


Measured memory_bytes: 23808
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        l: [usize; n],
    }
    let mut count = 0;
    let mut pos_a = 0;
    let mut i_cnt = 0;
    for i in &l {
        i_cnt += 1;
        let mut j_cnt = 0;
        for j in &l {
            if i_cnt > j_cnt {
                j_cnt += 1;
                continue;
            }
            j_cnt += 1;
            if *i == *j {
                continue;
            }
            let mut k_cnt = 0;
            for k in &l {
                if j_cnt > k_cnt {
                    k_cnt += 1;
                    continue;
                }
                k_cnt += 1;
                if *j == *k || *k == *i {
                    continue
                }
                let amari = (*i+*j+*k)%2;
                if (*i+*j+*k)/2 + amari <= *i || (*i+*j+*k)/2 + amari <= *j || (*i+*j+*k)/2 + amari <= *k {
                    continue;
                }
                //println!("{} {} {}", *i, *j, *k);
                count += 1;
            }
        }
    }

    println!("{}", count);
    
}


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

using LL = long long;
using Point = pair<int, int>;
using Interval = pair<int, int>;
using Event = pair<int, bool>;
const bool IN = false;
const bool OUT = true;

int N, K;
string S;

LL loop(auto& p) {
  set<Point> s(begin(p), end(p));
  LL res = 0;
  for(auto i: s) {
    auto x = i.first, y = i.second;
    if(s.count(Point(x+1, y)) && s.count(Point(x, y+1)) && s.count(Point(x+1, y+1))) ++res;
  }
  return res;
}

LL solve(auto& p, int a, int b) {
  // vectorize
  map<Point, set<Interval>> vec;
  for(auto i: p) {
    auto k = i.first / a;
    auto x = i.first % a;
    auto y = i.second - b * k;
    if(x < 0) {
      --k;
      x += a;
      y += b;
    }
    vec[{x, y}].emplace(k, k + K - 1);
  }
//   for(auto i: vec){
//     cout<<i.first.first<<","<<i.first.second<<": ";
//     for(auto j: i.second)cout<<" ["<<j.first<<","<<j.second<<"] ";
//     cout<<endl;
//   }

  // merge
  map<Point, set<Event>> event;
  for(auto& i: vec) {
    auto cur = begin(i.second);
    auto l = cur->first, h = cur->second;
    for(auto pre = cur++; pre != end(i.second); pre = cur++) {
      if(cur == end(i.second)) {
        event[i.first].emplace(l, IN);
        event[i.first].emplace(h, OUT);
        break;
      }
      if(cur->first - 1 <= pre->second) h = cur->second;
      else {
        event[i.first].emplace(l, IN);
        event[i.first].emplace(h, OUT);
        l = cur->first;
        h = cur->second;
      }
    }
  }
//   for(auto i: event) {
//     cout<<i.first.first<<","<<i.first.second<<": ";
//     for(auto j: i.second)cout<<" "<<j.first<<"_"<<j.second<<" ";
//     cout<<endl;
//   }

  // intersect
  LL res = 0;
  for(auto i: event) {
    auto cur = i.first;
//     cout<<res<<endl;
//     cout<<"TRY: "<<cur.first<<","<<cur.second<<endl;
    multiset<Event> q;
    for(auto e: event[cur]) q.emplace(e);
    for(auto nex: {Point(cur.first + 1, cur.second), Point(cur.first + 1, cur.second + 1), Point(cur.first, cur.second + 1)}) {
//       cout<<"  with: "<<nex.first<<","<<nex.second<<endl;
      auto dif = 0;
      if(nex.first >= a) {dif = 1; nex = Point(nex.first - a, nex.second - b);}
//       if(!event.count(nex)) cout<<"NG"<<endl;
      if(!event.count(nex)) break;
      for(auto e: event[nex]) q.emplace(e.first - dif, e.second);
    }
    // count
    auto cnt = 0;
    auto l = 0;
    for(auto e: q) {
      if(e.second == IN) {
        ++cnt;
        l = e.first;
      } else {
        if(cnt == 4) res += e.first - l + 1;
        --cnt;
      }
    }
  }
  return res;
}

LL solve() {
  // simulate
  auto x = 0, y = 0;
  vector<Point> p;
  p.emplace_back(x, y);
  for(auto i: S) {
    x += (i=='E') - (i=='W');
    y += (i=='N') - (i=='S');
    p.emplace_back(x, y);
//     cout<<x<<" "<<y<<endl;
  }

  if(x == 0 && y == 0) return loop(p);

  if(x == 0) {swap(x, y); for(auto& i: p) swap(i.first, i.second);}
  if(x < 0) {x *= -1; for(auto& i: p) i.first *= -1;}
  return solve(p, x, y);
}

int main() {
  cin >> N >> K >> S;
  cout << solve() << endl;
}

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

class MaximumAverageSets {
    static void Main(string[] args)
    {
        int N, A, B;
        long[,] C = new long[51, 51];
        long t, ans = 0;
        int X = 0, Y = 0;
        string[] s;
        List<long> v = new List<long>();

        s = Console.ReadLine().Split();

        N = int.Parse(s[0]);
        A = int.Parse(s[1]);
        B = int.Parse(s[2]);

        for (int i = 0; i <= N; i++) {
            for (int j = 0; j <= i; j++) {
                if (j == 0 || j == i)
                    C[i, j] = 1;
                else
                    C[i, j] = C[i-1, j-1] + C[i-1, j];
            }
        }

        foreach (var i in Console.ReadLine().Split())
            v.Add(long.Parse(i));

        v.Sort();
        v.Reverse();

        t = v[A-1];

        X = v.Count(n => n == t);

        for (int i = 0; i < A; i++) {
            if (v[i] == t) Y++;
        }

        if (v[0] != v[A-1])
            ans = C[X, Y];
        else {
            for (int i = A; i <= B; i++) {
                if (i <= X)
                    ans += C[X, i];
            }
        }
        Console.WriteLine((decimal)v.GetRange(0, A).Sum() / A);
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13492
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

def dfs(graph:list, node:int, start:int) -> list:
    # 未探索のノードは距離INF
    INF = float("inf")
    dist = [INF]*node
    
    # 始点ノードの距離を0とし、dfsのためのstackを作成
    dist[start] = 0
    stack = [(0,start)]
    
    while stack:
        cost, cur_node = stack.pop()

        # 未探索のノードをstackに入れる
        for nex_cost, nex_node in graph[cur_node]:
            if dist[nex_node] != INF:
                continue
            else:
                dist[nex_node] = dist[cur_node] + nex_cost
                stack.append((dist[nex_node],nex_node))
                
    return dist

n = ni()
a = [ni() for _ in range(n)]

adj = [[] for _ in range(n)]

for i in range(n):
    adj[i].append((1,a[i]-1))

dist = dfs(adj, n, 0)

if dist[1] != float("inf"):
    print(dist[1])
else:
    print(-1)

Measured memory_bytes: 32180
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    int n, m; cin >> n >> m;
    vector<pair<int, int>> all;
    for (int i = 0; i < n; i++) {
        int cost, amount; cin >> cost >> amount;
        all.emplace_back(cost, amount);
    }
    sort(all.begin(), all.end());
    ll res = 0;
    for (int i = 0; i < n && m > 0; i++) {
        int cost = all[i].first, amount = all[i].second;
        int taking = min(amount, m);
        res += (ll) cost * (ll) taking;
        m -= taking;
    }
    cout << res << "\n";
}


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

#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#define MOD 1000000007

signed main(){
	int n;
	cin >> n;
	int a[200010];
	for(int i = 0;i < n;i++) cin >> a[i];

	int ans = 0;
	int tmp = 0;
	for(int i = 0;i < n;i++){
		ans += (tmp * a[i]) % MOD;
		ans %= MOD;
		tmp = (tmp + a[i]) % MOD;
	}

	cout << ans << endl;

	return 0;
}


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

int main(){

 int w, h, x, y, r;

 cin >> w >> h >> x >> y >> r;

 if (((x - r) < 0) || ((y - r) < 0)) {

  cout << "No\n";

 } else if (((x + r) > w) || ((y + r) > h)) {

  cout << "No\n";

 } else {

  cout << "Yes\n";

 }

 return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	int A,B,C,X,Y; cin >> A >> B >> C >> X >> Y;

	int lis[3];
	if(X > Y){
		lis[0] = 2*C*X;
		lis[1] = 2*C*Y+(X-Y)*A;
	}else{
		lis[0] = 2*C*Y;
		lis[1] = 2*C*X+(Y-X)*B;
	}

	lis[2] = A*X+B*Y;

	cout << min(lis[0], min(lis[1],lis[2])) << endl;

	return 0;
}


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

int main() {
    int N;
    cin>>N;
    vector<int> vec(N);
    int a=1;
    for(int i=0;i<N;i++){
        cin>>vec.at(i);
    }
    for(int i=0;i<N;i++){
        a=vec.at(a-1);
        if(a==2){
            cout<<i+1<<endl;
            break;
        }
      	if(i==N-1){
			cout<<-1<<endl;
        }
    }
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;

long long gcd(long long a,long long b){
   if(b==0)return a;
   return gcd(b,a%b);
}
long long lcm(long long a,long long b){
   return (a/gcd(a,b))*(b/gcd(a,b))*gcd(a,b);
}
int main(){
  int n;
  cin>>n;
  vector<long long>t(n);
  for(int i=0;i<n;i++)cin>>t[i];
  long long ans=t[0];

  for(int i=1;i<n;i++){
     ans=lcm(ans,t[i]);
  }
  cout<<ans<<endl;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N;
    cin >> N;
    vec A(N);
    REP(i,0,N) cin >> A[i];

    ASC(A);
    ll cnt = 1;
    vec C(N+1,0);
    REP(i,0,N) C[i+1] = C[i] + A[i];
    REP(i,1,N+1) {
        if(C[N-i] >= (A[N-i] + 1) / 2) ++cnt;
        else break;
    }
    PR(cnt);

    return 0;
}

/*



*/

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

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

  int cnt2=0,cnt4=0;
  for (int i = 0; i < n; i++)
  {
    int a;
    cin >> a;
    if(a%4==0){
      cnt4++;
      continue;
    }
    if(a%2==0) cnt2++;
  }

  int m = cnt4+cnt2/2;
  if(m>=n/2) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int a, b;
    cin >> a >> b;
    cout << a + (a <= b) - 1 << endl;
    return 0;
}


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

using namespace std;
using ll = long long;


int main()
{
    int n;
    cin >> n;
    set<int> st;
    for(int i = 0; i < n; i++){
        int a; cin >> a; st.insert(a);
    }
    cout << st.size() << endl;
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var AopB = ReadSplit();
            if (AopB[1] == "+") Println(int.Parse(AopB[0]) + int.Parse(AopB[2]));
            else Println(int.Parse(AopB[0]) - int.Parse(AopB[2]));
        }

        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static void YESOrNO(bool e) => Println(e ? "YES" : "NO");

        static void YesOrNo(bool e) => Println(e ? "Yes" : "No");

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
const int maxn = 100 + 7;
long long n, k;
char s[maxn];

int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	scanf("%lld", &k);
	long long fl = 0;
	if(s[1] == s[n]) {
		int p = 1; fl = 1;
		while(s[p] == s[1] && p <= n) ++p;
		if(((p - 1) & 1) == 0) fl = 0;
		if(p == n + 1) {
			long long sum = n * k;
			printf("%lld\n", sum >> 1);
			return 0;
		}
		p = n;
		while(s[p] == s[n] && p) --p;
		if(((n - p) & 1) == 0) fl = 0;
	}
	fl = fl * (k - 1);
	long long ans = 0;
	for (int i = 2; i <= n; ++i) {
		if(s[i] == s[i - 1]) {
			s[i] = 0;
			++ans;
		}
	}
	ans = ans * k + fl;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3812
// B - 123 Triangle
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	int n;
	string s;
	cin >> n >> s;
	vector<int> a(n);
	for (int i = 0; i < n; i++) a[i] = s[i] - '1';
	vector<int> c(n);
	for (int i = 1; i < c.size(); i++) c[i] = __builtin_ctz(i) + c[i - 1];
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int d = c[n - 1] - c[i] - c[n - 1 - i];
		ans ^= d ? 0 : (a[i] % 2);
	}

	if (ans != 0) {
		cout << 1 << endl;
	} else {
		bool has_one = false;
		for (int i = 0; i < a.size(); i++) if (a[i] == 1) has_one = true;
		if (has_one) {
			cout << 0 << endl;
		} else {
			for (int i = 0; i < a.size(); i++) a[i] /= 2;
			int ans = 0;
			for (int i = 0; i < n; i++) {
				int d = c[n - 1] - c[i] - c[n - 1 - i];
				ans ^= d ? 0 : (a[i] % 2);
			}
			cout << (ans ? 2 : 0) << endl;
		}
	}

	return 0;
}


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


int main()
{
	int A,P;
	cin>>A>>P;
	cout<<(A*3+P)/2<<endl;
	return 0;
}


Measured memory_bytes: 256
from math import factorial

def combinations_count(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))

def main():
    num = int(input())
    data = list(map(int, input().split()))

    ketasuu = 20
    righ = 0

    keta_flg = [0 for i in range(ketasuu)]
    ans = 0


    for left in range(num):

        left_bin = bin(data[left])[2:]
        left_bin = left_bin.zfill(ketasuu)

        for i in range(ketasuu):
            if left_bin[i] == '1':
                keta_flg[i] = 1

        righ = max(righ, left + 1)

        while righ < num:
            righ_bin = bin(data[righ])[2:]
            righ_bin = righ_bin.zfill(ketasuu)

            flg = 0
            for i in range(ketasuu):
                if righ_bin[i] == '1' and keta_flg[i]:
                    flg = 1
                    break

            if flg:
                break

            for i in range(ketasuu):
                if righ_bin[i] == '1':
                    keta_flg[i] = 1

            righ += 1

        ans += righ - left


        for i in range(ketasuu):
            if left_bin[i] == '1':
                keta_flg[i] = 0

    print(ans)






if __name__ == '__main__':
    main()

Measured memory_bytes: 77388
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <tuple>
#include <algorithm>
#include <iomanip>
#include <cmath>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(c) (c).begin(), (c).end()
const double inf = 1e8, eps = 1e-8;

template<typename T> inline void chmin(T& t, T f){if(t > f)t = f;}

int n, m, p, a, b;
vector<int> t;
vector<vector<pair<int, int> > > G;
vector<vector<double> > mem;

string solve(){
    mem.assign(1<<n, vector<double>(m, inf));
    priority_queue<tuple<double, int, int> > q;
    for(q.emplace(0, 0, a); !q.empty();){
        double c; int used, v;
        tie(c, used, v) = q.top(); q.pop();
        if(mem[used][v] - c < -eps || v == b)continue;
        for(auto u: G[v])rep(i, n)if(!(used >> i & 1)){
            double nc = 1. * u.second / t[i] - c;
            if(mem[used | 1<<i][u.first] <= nc)continue;
            mem[used | 1<<i][u.first] = nc;
            q.emplace(-nc, used | 1<<i, u.first);
        }
    }
    double res = inf;
    rep(i, 1<<n)chmin(res, mem[i][b]);
    stringstream ss;
    if(abs(res - inf) < eps)ss << "Impossible";
    else ss << fixed << setprecision(3) << res;
    return ss.str();
}

int main(){
    while(cin >> n >> m >> p >> a >> b, n|m|p|a|b){
        a--; b--;
        t.assign(n, 0);
        rep(i, n)cin >> t[i];
        G.assign(m, vector<pair<int, int> >());
        rep(i, p){
            int x, y, z;
            cin >> x >> y >> z;
            x--; y--;
            G[x].emplace_back(y, z);
            G[y].emplace_back(x, z);
        }
        cout << solve() << '\n';
    }
    return 0;
}

Measured memory_bytes: 2812
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const ll mod=1000000007;
int main(void){
    char a;
    cin>>a;
    if('a'<=a&&a<='z') cout<<"a"<<endl;
    else cout<<"A"<<endl;
}

Measured memory_bytes: 3616
using System;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Security.Cryptography.X509Certificates;

namespace hello_world
{
	class Program
	{
		static void Main(string[] args)
		{
			long x = long.Parse(Console.ReadLine());
			long sum = 100;
			int year = 0;
			while (sum < x)
			{
				sum += (sum / 100);
				year++;
			}
			Console.WriteLine(year);

		}

	}
}


Measured memory_bytes: 27376
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
//#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 4300;
const int K = 60;
const int mod = 998244353;
int p1[N], p0[N], a[N], b[N], s1[N][N], s0[N][N], dp[N][N];
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    for (int i = 1; i <= 2 * n; i++){
        char c;
        cin >> c;
        cin >> b[i];
        if (c == 'B'){
            a[i] = 1;
            p1[b[i]] = i;
        } else{
            p0[b[i]] = i;
        }
    }
    for (int i = 0; i <= n; i++){
        for (int j = 1; j <= 2 * n; j++){
            if (a[j] == 1 && b[j] > i) s1[i][j] = s1[i][j - 1] + 1; else s1[i][j] = s1[i][j - 1];
        }
    }
    for (int i = 0; i <= n; i++){
        for (int j = 1; j <= 2 * n; j++){
            if (a[j] == 0 && b[j] > i) s0[i][j] = s0[i][j - 1] + 1; else s0[i][j] = s0[i][j - 1];
        }
    }
    for (int i = 0; i <= n; i++){
        for (int j = 0; j <= n; j++){
            if (i == 0 && j == 0) continue;
            dp[i][j] = 1e9;
            if (i != 0){
                int x = p0[i];
                dp[i][j] = min(dp[i - 1][j] + s0[i][x - 1] + s1[j][x - 1], dp[i][j]);
            }
            if (j != 0){
                int x = p1[j];
                dp[i][j] = min(dp[i][j - 1] + s0[i][x - 1] + s1[j][x - 1], dp[i][j]);
            }
           // cout << i << " " << j << " " << dp[i][j] << endl;
        }
    }
    cout << dp[n][n];
}


Measured memory_bytes: 104192
using System;
class Program
{
    static void Main(string[] args)
    {
        while (true)
        {
            string[] data = Console.ReadLine().Split(' ');
            int H = int.Parse(data[0]);
            int W = int.Parse(data[1]);
            if (H == 0 && W == 0)
            {
                return;
            }

            string line = "";
            string line2 = "";
            for (int i = 0; i < W; i++)
            {
                int flag = i & 1;
                if (flag == 0)
                {
                    line = line + ".";
                    line2 = line2 + "#";
                }
                else
                {
                    line = line + "#";
                    line2 = line2 + ".";
                }
            }

            for (int i = 0; i < H; i++)
            {
                int flag = i & 1;
                if (flag == 0)
                {
                    Console.WriteLine(line2);
                }
                else
                {
                    Console.WriteLine(line);
                }
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 19588
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node{
	int key;
	Node *next,*prev;
};

Node *nil;

Node* listSearch(int key){
	Node *cur = nil->next;
	while(cur != nil && cur->key != key){
		cur = cur->next;
	}
	return cur;
}

void init(){
	nil = (Node *)malloc(sizeof(Node));
	nil->next = nil;
	nil->prev = nil;
}

void printList(){
	Node *cur = nil->next;
	int isf = 0;
	while( 1 ){
		if(cur == nil)break;
		if(isf++ > 0)printf(" ");
		printf("%d",cur->key);
        cur = cur->next;
	}
	printf("\n");
}

void deleteNode(Node *t){
	if(t == nil)return;
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
}

void deleteFirst(){
	deleteNode(nil->next);
}

void deleteLast(){
	deleteNode(nil->prev);
}

void deletekey(int key){
	
	deleteNode(listSearch(key));
}

void insert(int key){
	Node *x = (Node *)malloc(sizeof(Node));
	x->key = key;
	
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
}

int main(){
	int key,n,i;
	int size = 0;
	char com[20];
	int np = 0, nd = 0;
	scanf("%d",&n);
	init();
	for(i = 0; i < n; i++){
	scanf("%s%d",com,&key);
		if(com[0] == 'i'){ insert(key); np++; size++; }
	else if(com[0] =='d'){
		if(strlen(com) > 6){
			if(com[6] == 'F')deleteFirst();
				else if(com[6] == 'L')deleteLast();
}else{
	deletekey(key); nd++;
}
size--;
	}
	}

 printList(); 

 return 0;
}
	



Measured memory_bytes: 33936
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 200003;
ll i,n,b,ans,r;
ll a[N],st[4 * N];
void update(ll i,ll p,ll v,ll l,ll r)
{
    if(l == r){
        st[i] = v;
        return;
    }
    ll m = (l + r) / 2;
    if(p <= m)
        update(2 * i,p,v,l,m);
    else
        update(2 * i + 1,p,v,m + 1,r);
    st[i] = max(st[2 * i],st[2 * i + 1]);
}
ll query(ll i,ll s,ll e,ll l,ll r)
{
    if(e < l || s > r) return 0;
    if(s <= l && r <= e)
        return st[i];
    ll m = (l + r) / 2;
    return max(query(2 * i,s,e,l,m),query(2 * i + 1,s,e,m + 1,r));
}
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n;
    rep(i,1,n + 1) cin>>a[i];
    rep(i,1,n + 1){
        cin>>b;
        r = b + query(1,1,a[i] - 1,1,N);
        ans = max(ans,r);
        update(1,a[i],r,1,N);
    }
    cout<<ans;
    return 0;
}

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

using namespace std;

long long gcd(long long a, long long b){
    if (a == 0) return b;
    if (b == 0) return a;
    if (a > b) return gcd(b, a % b);
    return gcd(a, b % a);
}

int main() {
  int N, K;
  cin >> N >> K;
  int mx = 0;
  int gd = 0;
  for (int i = 0; i < N; i++) {
      int a;
      cin >> a;
      gd = gcd(a, gd);
      mx = max(mx, a);
  }
  cout << (K <= mx && K % gd == 0 ? "POSSIBLE" : "IMPOSSIBLE");
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;

int main(){
int A, B;
cin >> A >> B;

if(A * B >= A + B && A * B >= A - B) cout << A * B << endl;
else if(A + B >= A * B && A + B >= A - B) cout << A + B << endl;
else cout << A - B << endl;
}

Measured memory_bytes: 256
// Author : Syed Mujtaba
// Seek knowledge from the Cradle to the Grave !!
// https://www.linkedin.com/in/syed-mujtaba-064a5016a 

#include <bits/stdc++.h>
using namespace std;
#define int     long long
#define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod ((int)(1e9 + 7))
vector < int > to[100005];
vector < int > from[100005];
vector < int > roots;
int dp[100005];
int cal(int i)
{
	if(dp[i] != -1)
		return dp[i];
	int dist = -1;
	for(int j = 0; j < to[i].size(); j++)
	{
		dist = max(dist, 1 + cal(to[i][j]));
	}
	return dp[i] = dist;
}
signed main()
{
	fast_io
	int n, m;
	int x, y;
	cin >> n >> m;
	for(int i = 0; i < m; i++)
	{	
		cin >> x >> y;
		to[y].push_back(x);
		from[x].push_back(y);
	}
	for(int i = 1; i <= n; i++)
		dp[i] = -1;
	for(int i = 1; i <= n; i++)
	{
		if(to[i].size() == 0)
		{
			roots.push_back(i);
			dp[i] = 0;
		}
	}
	for(int i = 1; i <= n; i++)
	{
		if(dp[i] == -1)
			dp[i] = cal(i);
	}
	int ans = -1;
	for(int i = 1; i <= n; i++)
	{
		ans = max(ans, dp[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 16512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c;
  cin >> a >> b;
  
  c = (9-a/10000)*100+(9-a%10000/1000)*10+9-a%1000/100;
  if (a%10000/1000*10+a/10000 >= a%100)
    c++;
  
  c -= (9-b/10000)*100+(9-b%10000/1000)*10+9-b%1000/100;
  if (b%10000/1000*10+b/10000 > b%100)
    c--;

  
  cout << c << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  ll n, a, b, ans;
  cin >> n >> a >> b;
  ans = (n/(a+b))*a + min(a, n%(a+b));
  cout << ans << endl;
return 0;
}

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

int main() {
  ll n,k,d;
  cin >> n >>k >>d;
  ll abs =0;
  if (n>=0) abs = n;
  else abs = -n;
  
  if (abs/d > k){
    cout << abs - k*d << endl;
    return 0;
  }
  
  else{
    ll hikaku = abs - (abs/d)*d;
    ll kaisuu = k-(abs/d);
    if(kaisuu%2==0){
      cout << hikaku <<endl;
      return 0;
    }
    else{
      cout << d-hikaku << endl;
      return 0;
    }
  }
 
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var set = new HashSet<string>();
            var n = int.Parse(Console.ReadLine());
            for (var i = 0; i < n; i++)
            {
                set.Add(Console.ReadLine());
            }
            Console.WriteLine(set.Count);
        }
    }
}

Measured memory_bytes: 47108
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<VL> VVL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T>  // chmax(max, a);
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> //chmin(min,a)
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}

ll max=-1000000000,min=1e9+1;

int main(){
    ll x=0,y=0,n,m,h,k,w,sum=0;
    string s,pre,bac;
    cin >> n >> s;

    for(int i=0; i<s.size();i++){
        if(s[i]=='('){
            x++;
        }
        else{
            y++;
            if(x>0){
                x--;
                y--;
            }
        }
    }
    if(x>0){
        while(x>0){
            bac += ')';
            x--;
        }
    }
    if(y>0){
        while(y>0){
            pre += '(';
            y--;
        }
    }
    cout << pre + s + bac << endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np

N,K = map(int, input().split())

list = np.array([], dtype=int)
N = N % K

while(True):
    new_N =np.abs(N-K)
    list = np.append(list, new_N)
    N = new_N
    # listが現れた場合
    if(len(list) != len(set(list))):
        break;

N_min = np.min(list)
print(N_min)

Measured memory_bytes: 12488
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var N, ans int

func main() {
	fmt.Scan(&N)

	reader := bufio.NewScanner(os.Stdin)
	reader.Split(bufio.ScanWords)
	t := make([]XY, N)

	for i := 0; i < N; i++ {
		reader.Scan()
		t[i].x, _ = strconv.Atoi(reader.Text())
		reader.Scan()
		t[i].y, _ = strconv.Atoi(reader.Text())
	}

	for i := 0; i < N; i++ {
		for j := i + 1; j < N; j++ {
			p := t[i].x - t[j].x
			q := t[i].y - t[j].y

			var cnt int
			for k := 0; k < N; k++ {
				for l := 0; l < N; l++ {
					if t[k].x-t[l].x == p && t[k].y-t[l].y == q {
						cnt++
					}
				}
			}
			ans = max(ans, cnt)
		}
	}
	fmt.Println(N - ans)
}

/*  ----------------------------------------  */

func combination(x, y int) int {
	return permutation(x, y) / permutation(y, y)
}

func permutation(x, y int) int {
	var ans int = 1
	for i := x - y; 0 < i; i-- {
		ans *= i
	}
	return ans
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }

type XY struct {
	x int
	y int
}
type SortBy []XY

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	if a[i].x == a[j].x {
		return a[i].y > a[j].y
	}
	return a[i].x > a[j].x
}


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

using namespace std;

int main(){

   string s, p;
   
   cin >> s >> p;

   s += s;

   for(int i = 0; i < s.length() / 2; i++){
      string sub_s = s.substr(i, p.length());

      if(sub_s == p){
         cout << "Yes" << endl;
         return 0;
      }
   }

   cout << "No" << endl;

   return 0;
}


Measured memory_bytes: 3204
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>

typedef long long ll;
const ll LL_MAX (1LL<<60);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    ll f(0);
    for (ll i=0;; i++)
    {
        if (a[i] >= x) break;
        f++; 
    }

    ll b(0);
    for (ll i=m-1;; i--)
    {
        if (a[i] <= x) break;
        b++; 
    }

    //cout << f << ' ' << b << endl;
    if (f < b)
        cout << f << endl;
    else
        cout << b << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <string>

using namespace std;
int main(int argc, const char * argv[]) {

    string s;
    cin >> s;
    int z = 0;
    for (int i=0; i< s.size(); i++) {
        if (s[i] == '0') {
            z ++;
        }
    }

    z = min(z, (int)s.size()-z);

    cout << z*2 << endl;
    
    return 0;
}

Measured memory_bytes: 512
fn main() {
    let k = read::<usize>();
    let ab = read_vec::<usize>();

    let mut cnt = 1;
    loop {
        let d = k * cnt;
        if ab[0] <= d && d <= ab[1] {
            println!("OK");
            return;
        }
        if ab[1] < d {
            break;
        }
        cnt += 1;
    }

    println!("NG");
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 2136
n = int(input())
is_yes = False

for i in range(n):
    t, x, y = map(int, input().split())
    if (x + y <= t) & ((x + y + t) % 2 == 0):
        is_yes = True
    else:
        print("No")
        quit()

if is_yes:
    print("Yes")

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

int N,L;
int A[1000000];
deque<int> deq;
vector<int> ans;

int main(){
  cin>>N>>L;
  for(int i=0;i<N;i++){

    while( !deq.empty() && deq.front() <= i-L)deq.pop_front();
    
    cin>>A[i];
    while( !deq.empty() && A[deq.back()] > A[i]){
      deq.pop_back();
    }
    deq.push_back(i);
    if( i>=L-1) ans.push_back( A[deq.front()] );
  }

  for(int i=0;i<(int)ans.size();i++){
    if(i)cout<<' ';
    cout<<ans[i];
  }
  cout<<endl;
  
  return 0;
}



Measured memory_bytes: 10908