akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)

string s;
int n;
int m;
char solve(){
    stack<pair<int,string> > q;
    stack<int> st;
    string tmp;
    int dep = 0;
    for(int i=0;i<m;i++){
        bool flag = 0;
        int k = 0;
        while(isdigit(s[i])){
            flag = 1;
            k *=10;
            k += s[i]-'0';
            i++;
        }
        if(flag){
            if(s[i]=='('){
                st.push(tmp.size());
                n -= tmp.size();
                q.push(MP(k,tmp));
                tmp = "";
                dep++;
            }else{
                string tmp2(k,s[i]);
                tmp += tmp2;
                if((int)tmp.size()-1>=n){
                    return tmp[n]; 
                }
            }
        }else{
            if(s[i]==')'){
                dep--;
                int y = st.top();
                st.pop();
                n += y;
                auto xx = q.top();
                q.pop();
                int p = xx.first;
                string t = xx.second;
                if(t.size()+p*(int)tmp.size()-1>=n){
                    n -= t.size();
                    int id = n % tmp.size();
                    return tmp[id];
                }else{
                    string tmp2 = t;
                    rep(zz,p){
                        tmp2 += tmp;
                    }
                    tmp = tmp2;
                    if(dep==0){
                        n -= tmp.size();
                        tmp = "";
                    }
                }
            }else{
                tmp.push_back(s[i]);
            }
        }
    }
    if((int)tmp.size()-1<n){
        return '0';
    }else{
        return tmp[n];
    }
}

int main(){
    while(cin >> s >> n){
        if(s=="0"&&n==0)break;
        m = s.size();
        cout << solve() << endl;
    }
    return 0;
}


Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); ++i)
#define rep2(i, n) for(ll i = 1; i <= ll(n); ++i)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); ++i)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); ++i)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll n;
  cin >> n;
  
  vl L(87);
  L[0]=2;
  L[1]=1;
  for(ll i=2; i<=n; i++) L[i] = L[i-1] + L[i-2];
  cout << L[n] << newl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i+=1)
#define vi vector<int>
using namespace std;

//int gcd(int a, int b){
//	return b==0 ? a : gcd(b, a%b);
//}

int32_t main(void){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	
	int n;
	cin>>n;
	int arr[n];
	vi d;
	unordered_map<int, int> m;
	
	rep(i, 0, n)
	{
		cin>>arr[i];
		m[arr[i]]+=1;
		if(m[arr[i]] == 1) d.push_back(arr[i]);
	}
	
	int total = 0;
	rep(i, 0, d.size())
	{
		total+=(m[d[i]]*(m[d[i]]-1))/2;
	}
	
	rep(i,0,n)
	{
		int ans = total-(m[arr[i]]-1);
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 10176
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, V, C):
    return sum(map(lambda x: x[0]-x[1], filter(lambda x: x[0]>x[1], zip(V, C))))


def main():
    N = read_int()
    V = read_int_n()
    C = read_int_n()
    print(slv(N, V, C))


if __name__ == '__main__':
    main()


Measured memory_bytes: 5484
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll num[100001];

int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++)cin>>num[i];
  
  ll ans=0;
  for(int i=1;i<n;i++){
    ans+=num[i-1]/2;
    num[i-1]%=2;
    ll mn=min(num[i-1],num[i]);
    ans+=mn;
    num[i-1]-=mn,num[i]-=mn;
  }
  ans+=num[n-1]/2;
  cout <<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long				ll;
typedef pair<int,int >			pii;
#define V						vector
#define SYNC					ios_base::sync_with_stdio(0);cin.tie(0);
#define rep(i,b)				for(int i=0;i<b;i++)
#define repn(i,n)				for(int i=1;i<=n;i++)
#define ALL(x)					(x).begin(),(x).end()
#define fi						first
#define se						second
#define pb						push_back
#define dzx						cerr<<"here";
const ll MOD=1e9+7,INF=9e18;
const int inf=2e9;
/* Equinox */
int main(){SYNC
	ll n,a,b,c,d;
	cin>>n>>a>>b>>c>>d;
	if(b<a)
		swap(a,b);
	b-=a;
	bool f=0;
	for(ll i=(n-1)&1;i<=(n-1);i+=2){
		ll l=i*c;
		ll r=i*d;
		r+=(d-c)*(n-1LL-i)/2LL;
		l-=(d-c)*(n-1LL-i)/2LL;
		if(b>=l && b<=r){
			f=1;
			break;
		}
	}
	cout<<(f==1?"YES":"NO")<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX(a,b) (((a)>(b))?(a):(b))

#define MAX_LENGTH 1000 + 1

int q;

int main() {
	scanf("%d", &q);
	int numInput = 2 * q;

	int lcs;

	char **input = (char**)malloc(numInput * sizeof(char*));
	for (int i = 0; i < numInput; i++) input[i] = (char*)malloc(MAX_LENGTH * sizeof(char));
	for (int i = 0; i < numInput; i++) {
		scanf("%s", input[i]);
		if (i % 2 != 0) {
			lcs = LCSLength(input[i - 1], input[i]);
			printf("%d\n", lcs);
		}
	}

	for (int i = 0; i < numInput; i++) free(input[i]);
	free(input);

	return 0;
}

int LCSLength(char A[], char B[]) {
	int m = strlen(A) + 1;
	int n = strlen(B) + 1;

	int maxLCS = 0;

	int** C = (int**)malloc(m * sizeof(int*));
	for (int i = 0; i < m; i++) C[i] = (int*)calloc(n, sizeof(int));

	for (int i = 1; i < m; i++) {
		for (int j = 1; j < n; j++) {
			if (A[i-1] == B[j-1]) C[i][j] = 1 + C[i - 1][j - 1];
			else C[i][j] = MAX(C[i - 1][j], C[i][j - 1]);
			maxLCS = MAX(C[i][j], maxLCS);
		}
	}

	return maxLCS;
}


Measured memory_bytes: 80428
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
    long x,y,ans=0;
    cin >> x >> y;
    while(x<=y){
        x *= 2;
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
int n;
int main(){
  scanf("%d", &n);
  int ans = 0;
  for(int i = 1; i <= n; i+=2){
    int cnt = 0;
	for(int j = 1; j <= i; j++){
      if(i % j == 0){
		cnt++;
      }
    }
    if(cnt == 8){
      ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define f first
#define s second
#define int long long
int a[114514];
int ans[114514];
bool p(int x){
	if(x==1)return false;
	rep(2,i,x){
		if(x%i==0)return false;
	}
	return true;
}		
signed main(){
	ic(n)
	rep(n,i,114514){
		if(p(i)==1){
			c(i)
			return 0;
		}	
	}	
}	


Measured memory_bytes: 256
s = int(input())

d = []
i = 0


def e(i):
    return int(i / 2)
def f(i):
    return int(3 * i + 1)

    
while(len(d) == len(set(d))):
    if i == 0:
        d = [s]
        o = s
    elif o % 2 != 0:
        o = f(o)
        d.append(o)
    else:
        o = e(o)
        d.append(o)
    i += 1

print(i)


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

using ll = long long;
using pii = pair<int, int>;

#define vt          vector
#define sz(x)       (int)(x).size()
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

signed main() {
    ios::sync_with_stdio(0), cin.tie(0);

    int n, m;
    string s;
    cin >> n >> m >> s;

    vt<int> ng{n}, ok;
    for (int i = n; i > 0; i--) {
        if (s[i - 1] == '1' && s[i] == '0') {
            ok.push_back(i);
        } else if (s[i - 1] == '0' && s[i] == '1') {
            ng.push_back(i);
        }
    }
    ok.push_back(0);

    vt<int> ans;
    for (int i = n; i > 0;) {
        int t = max(0, i - m);
        auto it = upper_bound(all(ok), t, greater<int>());
        if (it == ok.end()) it--;

        int okIdx = distance(ok.begin(), it);
        if (t >= ng[okIdx]) {
            if (!okIdx || *--it == i) return cout << -1, 0;
        }

        int mv = min(i - t, i - *it);
        ans.push_back(mv);
        i -= mv;
    }

    reverse(all(ans));
    for (int i : ans) cout << i << ' ';
}


Measured memory_bytes: 4108
#include <iostream>
#include <vector>

using namespace std;
int n;
vector<int> pre, in, post;
int pos = 0;

void rec(int l, int r) {
    if (l >= r) {
        return;
    }
    int root = pre[pos++];
    int m;
    int d = 0;
    for (vector<int>::iterator i = in.begin(); i != in.end(); i++, d++) {
        if (*i == root) {
            m = d;
            break;
        }
    }
    rec(l, m);
    rec(m + 1, r);
    post.push_back(root);
}

void solve() {
    rec(0, n);
    for (int i = 0; i < n; i++) {
        if (i) {
            cout << " ";
        }
        cout << post[i];
    }
    cout << endl;
}

int main() {
    cin >> n;
    int k;
    for (int i = 0; i < n; i++) {
        cin >> k;
        pre.push_back(k);
    }
    for (int j = 0; j < n; j++) {
        cin >> k;
        in.push_back(k);
    }
    solve();
    return 0;
}

Measured memory_bytes: 3156
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC169A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int A = int.Parse(input[0]);
            int B = int.Parse(input[1]);
            int M = A * B;
            Console.WriteLine(M);
        }
    }
}


Measured memory_bytes: 27440
package main

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

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

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

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

func b2i(b bool) int8 {
	if b {
		return 1
	}
	return 0
}

func solve(io *Io) {
	n := io.NextInt()

	ans := 0
	for ; n > 0; n-- {
		d := io.NextInt()
		for d % 2 == 0 {
			d /= 2
			ans++
		}
	}

	io.PrintLn(ans)
}

func main() {
	io := NewIo()
	defer io.Flush()

	solve(io)
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
    using namespace std;
 
    #define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
    #define mod 1000000007
    #define qmod 998244353
    #define M 1000001
    #define endl "\n"
    #define all(a) (a).begin(),(a).end()
    #define rep(i,a,b) for(int i=a;i<b;++i)
    #define repr(i,a,b) for(int i=a;i>=b;--i)
    #define F first
    #define S second
    #define pb push_back
    #define mp make_pair
 
    typedef long long ll;
    typedef pair<int,int> pii;
    typedef vector<int> vi;
    typedef vector<string> vs;
    typedef vector<pii> vii;
    typedef vector<vi> vvi; 

    int main(){
                
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin); 
    // freopen("output.txt","w",stdout);   
    // #endif 
 
        fast;
        int t=1;
        // cin>>t;  
        while(t--){     
            int a,b,c,d;
            cin>>a>>b>>c>>d;
            bool poss;
            while(1){
                //;
                c-=b;
                a-=d;
                //cout<<a<<" "<<c<<endl;
                if(c<=0){
                    poss=true;
                    break;
                }
                if(a<=0){
                    poss=false;
                    break;
                }
            }
            if(!poss) cout<<"No"; else cout<<"Yes"; 
        } 
        return 0;   
    }       


    //keep it simple stupid 

Measured memory_bytes: 3652
N, Q = gets.chomp.split(' ').map(&:to_i)
S = gets.chomp
dp = Array.new(N + 10) { -1 }
dp[0] = 0
(1..N).each do |i|
  prev = S[i - 1]
  ch = S[i]
  if prev == 'A' && ch == 'C'
    dp[i] = dp[i - 1] + 1
  else
    dp[i] = dp[i - 1]
  end
end

Q.times do
  l, r = gets.chomp.split(' ').map(&:to_i)
  # 1 to 0-origin
  l -= 1
  r -= 1
  puts dp[r] - dp[l]
end


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

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

  std::cout << ceil((double)(n - k) / (k - 1)) + 1 << std::endl;

  return 0;
}


Measured memory_bytes: 3788
n = int(input())
explored = set()
next = [[]for _ in range(n)]

from collections import deque
ls = []
for i in range(n-1):
    u, v, w= map(int, input().split())
    ls.append((u-1, v-1, w%2))
    next[u-1].append((v-1, w%2))
    next[v-1].append((u-1, w%2))

ans = [-1] * n

exploring = deque()
next_que = deque([0])
ans[0]=0
explored.add(0)
while next_que:
    i = next_que.popleft()
    exploring.extend(next[i])
    while exploring:
        a, b = exploring.popleft()
        ans[a] = (ans[i]+b)%2
        list = next[a]
        if a not in explored:
            next_que.append(a)
        explored.add(a)


for i in ans:
    print(i)

Measured memory_bytes: 123484
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>

using namespace std;

int main()
{    
    int n, m;
    cin >> n >> m;
    
    using ll = long long;
    
    vector<ll> a(n);
    
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    
    priority_queue<ll> que(a.begin(), a.end());
    
    for (int i = 0; i < m; i++) {
        ll x = que.top();
        que.pop();
        
        que.push(x / 2);
    }
    
    ll ans = 0;
    
    while(!que.empty()) {
        ans += que.top();
        que.pop();
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

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

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

    int q;
    cin >> q;

    set<int> st;
    while(q--){
        int m, x;
        cin >> m >> x;

        if(m == 0){
            st.insert(x);
            cout << st.size() << endl;
        }else if(m == 1){
            cout << st.count(x) << endl;
        }else if(m == 2){
            st.erase(x);
        }
    }

    return 0;
}


Measured memory_bytes: 12584
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
using namespace std;
#define LONG_INF 10000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353LL
#define seg_size 65536*4
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	int n, m;
	cin >> n >> m;
	map<int, int> a;
	vector<int> b, c;
	REP(i, n+m) {
		int d;
		cin >> d;
		a[d]++;
	}
	for (auto i = a.begin(); i != a.end(); ++i) {
		c.push_back(i->first);
		if (i->second == 1) {

		}
		else b.push_back(i->first);
	}
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());
	cout << b.size() << " " << c.size() << endl;
	REP(i, b.size()) {
		cout << b[i] << endl;
	}
	REP(i, c.size()) {
		cout << c[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 14096
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int N;
    scan(N);
    auto dp = new bool[](N + 1);
    dp[0] = true;

    auto a = [100, 101, 102, 103, 104, 105];

    foreach (i ; 1 .. N + 1) {
        foreach (ai ; a) {
            if (i - ai >= 0) {
                dp[i] |= dp[i - ai];
            }
        }
    }

    writeln(dp[N] ? 1 : 0);
}






void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 380
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

string S;
ll f[200001] = {};

int main() {
	cin >> S;
	f[1] = 1;
	if (S.length() >= 2) {
		if (S[0] != S[1]) {
			f[2] = 2;
		}
		else {
			f[2] = 1;
		}
	}
	if (S.length() >= 3) {
		if (S[0] != S[1] && S[1] != S[2]) {
			f[3] = 3;
		}
		else {
			f[3] = 2;
		}
	}
	for (int i = 4; i <= S.length(); i++) {
		if (S[i - 1] != S[i - 2]) {
			f[i] = f[i - 1] + 1;
		}
		else {
			f[i] = f[i - 3] + 2;
		}
	}
	cout << f[S.length()] << endl;
	return 0;
}

Measured memory_bytes: 2180
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

int main() {
	int n;
	while (cin >> n, n) {
		int *c = new int[n];
		for (int i = 0; i < n; i++)
			cin >> c[i];
		sort(c, c + n);
		long long ans = 0;
		for (int i = 0; i < n; i++)
			for (int j = 0; j < i; j++)
				ans += c[j];
		cout << ans << endl;
		delete[] c;
	}
	return 0;
}

Measured memory_bytes: 1244
n = int(input())
a = list(map(int, input().split(" ")))
dp = [[0 for i in range(2)] for i in range(n)]

dp[1][0] = a[0] + a[1]
dp[1][1] = -(a[0] + a[1])

for i in range(2, n):
    dp[i][0] = max(dp[i-1][0]+a[i], dp[i-1][1]+a[i])
    dp[i][1] = max(dp[i-1][0]+(-2*a[i-1])+(-a[i]), dp[i-1][1]+2*a[i-1]+(-a[i]))

print(max(dp[n-1][0], dp[n-1][1]))



Measured memory_bytes: 26224
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
res = [-1] * (n+1)
for i in range(n+1):
    if res[a[i]] == -1:
        res[a[i]] = i
    else:
        d = a[i]
        l, r = res[d], n-i


def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range(2, n + 2):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod//i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)


for i in range(1, n+2):
    print((cmb(n+1, i, mod)-cmb(l+r, i-1, mod)) % mod)


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

using namespace std;

/*long long int wop(long long int x, long long int y) {
    if(y===0)return 1;
    long long int ret=wop(x,y/2);
    ret=(ret*ret)%mod;
    if(y&1)ret*=x;
    return ret%mod;
}*/

/*long long int chos(long long int r, long long int n) {
    return fac[n]*rev[r]*rev[n-r]
}*/

const int N = 1e5;

int main () {
    long long int n, h, w;
    cin >> h >> w >> n;
    long long int mx = max(h,w);
    cout << (n+mx-1)/mx << '\n';
}


Measured memory_bytes: 256
#include<queue>
#include<map>
#include <string>
#include<bits/stdc++.h>
#define pi 3.141592654
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);
//#define x real()
//#define y imag()
using namespace std;
typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
//typedef complex<double> point;
//template<typename T>T gcd(T x, T y) { if(y == 0)return x; else return gcd(y, x%y); }
//typedef bitset<30> mask;
//int x[8]={1,0,0,-1,-1,-1,1,1};
//int y[8]={0,1,-1,0,-1,1,-1,1};
//#define var(x) ((x)<<1)
//#define nvar(x) ((x)^1)
const int N=210,M=20500;

int n;
char a[1000005];
 main()
{

//cout<<Pow((ll)1000000,(ll)110);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
//    char input[15];
//    scanf("%s", &input);  array of char
//  gets(c+1);  array of char
//printf("%s, ",name[k[i]].c_str());  printf of string
input;

cin>>n;
forr(i,1,n) cin>>a[i];


int q,x;
cin>>q;
while(q--)
{
    cin>>x;
    ll ans=0,ck=0,d=0,m=0,c=0;
    forr(i,1,n)
    {
        if(c>=x)
        {
            if(a[i-x]=='D')ck-=m,d--;
            else if(a[i-x]=='M')m--;

        }
        if(a[i]=='D')d++;
        else if(a[i]=='M')ck+=d,m++;
        else if(a[i]=='C')ans+=ck;
        c++;
    }
    cout<<ans<<endl;

}
return 0;
}


Measured memory_bytes: 1280
n,k=list(map(int,input().split()))
A=list(map(int,input().split()))
start,steps=1,0
root=dict()

while start not in root and steps < k:
  root[start]=steps
  steps+=1
  start=A[start-1]

if steps == k:
  print(start)
else:
  pa = steps-root[start]
  ans= root[start] + (k-steps)%pa
  root={v: k for k, v in root.items()}
  print(root[ans])

Measured memory_bytes: 37044
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define INF I64_MAX
#define MOD 1000000007
#define MEM_SIZE = 1e5+5;

template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}




//-----CODE------//
//-----CODE------//


void solve(void)
{
  int A,B;
  char c;
  cin>>A>>c>>B;
  if(c == '+')
  {
    DEBUG(A+B);
  }
  else
  {
    DEBUG(A-B);
  }
  
     
  
  return; 
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 768
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;

class Program
{
	static void Main(string[] args)
	{
        int n = int.Parse(Console.ReadLine());
        int[] a = new int[n];
        string[] s = Console.ReadLine().Split(' ');

		for (int i = 0; i < n; i++)
		{
            a[i] = int.Parse(s[i]);
        }

        int sum = selectionSort(a,n);

        for (int i = 0; i < n - 1; i++)
        {
            Console.Write("{0} ", a[i]);
        }

        Console.WriteLine(a[n - 1]);
        Console.WriteLine(sum);


    }

    static int selectionSort(int[] A,int N)
    {
        int sum = 0;

        for (int i = 0; i < N - 1;i++)
        {
            int minj = i;
            for (int j = i; j < N;j++)
            {
                if (A[j] < A[minj])
                {
                    minj = j;
                }
            }

            if (minj != i)
            {
                int tmp = A[i];
                A[i] = A[minj];
                A[minj] = tmp;
                sum++;
            }

        }
        return sum;
    }
}

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

int main() {
	int N;
	cin >> N;
	long long ans = 0;
	for (long long i = 1; i <= N; i++) ans += i * (i + 1) / 2;
	for (int i = 0; i < N - 1; i++) {
		long long u, v;
		cin >> u >> v;
		if (u > v) swap(u, v);
		ans -= u * (N - v + 1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3620
#include<stdio.h>
int main()
{
    char a[3];
    scanf("%s",a);
    if(a[0]==a[1]){printf("Bad");}
    else if(a[1]==a[2]){printf("Bad");}
    else if(a[2]==a[3]){printf("Bad");}
    else{printf("Good");}
    return 0;  

}

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int n;cin>>n;
    vl a(n);
    rep(i,n)cin>>a[i];
    ll ans = L_INF;
    exrep(i,-100,101){
        ll res = 0;
        rep(j,n){
            res += (a[j]-i)*(a[j]-i);
        }
        chmin(ans,res);
    }
    out(ans);
}


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

static const int N = 8;
int l[N];
int minmp;
int A, B, C;

void rec(int n, int tA, int tB, int tC, int mp){
    if(n <= 0){
        if(tA != 0 && tB!= 0 && tC != 0){
            mp += abs(tA - A) + abs(tB - B) + abs(tC - C);
            if(mp < minmp) {
                minmp = mp;
            }
        }
    }else{
        rec(n-1, tA + l[n-1], tB, tC, mp + 10);
        rec(n-1, tA, tB + l[n-1], tC, mp + 10);
        rec(n-1, tA, tB, tC + l[n-1], mp + 10);
        rec(n-1, tA, tB, tC, mp);
    }
}
int main(){
    int n;
    minmp = (1 << 21);
    cin >> n >> A >> B >> C;
    for(int i = 0; i < n; i++){
        cin >> l[i];
    }
    rec(n, 0, 0, 0, -30);
    cout << minmp << endl;

    return 0;
}

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

int main()
{
    int a,b,k,ans,cnt;

    cin >> a >> b >> k;

    cnt = ans=0;
    for (int i = a;i > 0 ;--i) {
        if (a % i == 0 && b % i == 0) {
            if (++cnt == k) {
                ans = i;
                break;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3628
N = int(input())
l = list(map(int, input().split()))
ans = 0
for i in range(N):
  if(i == 0):
    minint = l[i]
  if(l[i] < minint):
    minint = l[i]
  if(l[i] <= minint):
    ans += 1
print(ans)

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

using namespace std;

int main(){
    int r,g,b,n;
    cin>>r>>g>>b>>n;
    long long ans=0;
    for (int i = 0; i*r <= n; ++i) {
        for (int j = 0; i*r+j*g <= n; ++j) {
            if((n-(i*r+j*g))%b==0)++ans;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

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

		int n = Integer.parseInt(sc.next());
		ArrayList<Double> nums = new ArrayList<Double>();

		for (int i = 0; i < n; i++) {
			nums.add(Double.parseDouble(sc.next()));
		}

		Collections.sort(nums);

		double result = nums.get(0);

		for (int i = 0; i < nums.size(); i++) {
			result = (result + nums.get(i)) / 2;
		}

		System.out.println(result);

	}
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
typedef long long ll;
using namespace std;

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


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

//C

int gcd(int x,int y,int z)
{
    vector<int> temp = {x,y,z};
    sort(temp.begin(),temp.end());
    
    if(temp[0] == 0)
    {
        temp[2] %= temp[1];
        if(temp[2] == 0)
        {
            return temp[1];
        }
    }
    else
    {
        temp[1] %= temp[0];
        temp[2] %= temp[0];
        if(temp[1] == 0 && temp[2] == 0)
        {
            return temp[0];
        }
    }
    return gcd(temp[0],temp[1],temp[2]);
}

int main()
{
    int N;
    cin >> N;
    
    int ans = 0;
    for(int i= 0;i<N;i++)
    {
        for(int j = i;j<N;j++)
        {
            for(int k = j;k<N;k++)
            {
                int t = gcd(i+1,j+1,k+1);
                if(i == j  && j== k)
                {
                    ans += t;
                }
                else if(i ==j || j == k || k == i)
                {
                    ans += 3*t;
                }
                else
                {
                    ans += 6*t;
                }
            }
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


//B
/*
int main()
{
    int N;
    cin >> N;
    
    vector<int> a(N);
    long long ans = 0;
    for(int i= 0;i<N;i++)
    {
        if((i+1) %3 == 0 || (i+1) %5 == 0)
        {
            a[i] = 0;
        }
        else
        {
            a[i] = i+1;
            ans += i+1;
        }
    }
    cout << ans << endl;
    
    return 0;
    /*
    vector<int> a(N);
    for(int i= 0;i<N;i++)
    {
        cin >> a[i];
    }
    */
    
//}


/*
 int main()
 {
 int N;
 cin >> N;
 
 vector<int> a(N);
 for(int i= 0;i<N;i++)
 {
 cin >> a[i];
 }
 
 int ans;
 cout <<ans << endl;
 return 0;
 
 }
*/

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define F first
#define S second
string s;
signed main(){
    cin>>s;
    if(s=="Sunny")puts("Cloudy");
    else if(s=="Cloudy")puts("Rainy");
    else puts("Sunny");
    return 0;
}





Measured memory_bytes: 256
/*
ID: tohoast1
TASK: gymnastics
LANG: C++
*/
#include <bits/stdc++.h>
#define speedup ios_base::sync_with_stdio(NULL)
#define fin freopen("allcodefs.in", "r", stdin)
#define fout freopen("allcodefs.out", "w", stdout)
#define FILENAME
#define PUBG push_back
#define p_b pop_back
#define mp make_pair
#define fi first
#define se second
#define cls clear
#define INF const int ci = 1e6 + 100
#define K_INF 1e9 + 7
#define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
#define MIN_INT -999999999
#define MOD 1000000007
#define d109 1000000000
#define basay break
#define bmbr exit(0)

using namespace std;
typedef long long LL;
typedef long L;
typedef unsigned long long ULL;
typedef unsigned long UL;
typedef string STR;
LL N, K, dup_n, a, cnt;
vector <LL> vc;

int main() {
    #ifdef FILENAMEs
        fin;
        fout;
    #endif // FILENAME
    cin >> N >> K;
    int arr[N];
    dup_n = N;
    while (N --) {
        cin >> a;
        vc.PUBG(a);
    }
    N = dup_n;
    sort (vc.rbegin(), vc.rend());
    for (int i = K ; i < N ; ++ i) {
        cnt += vc[i];
    }
    cout << cnt;
    ///time;
    return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define all(cont) cont.begin(), cont.end()
#define pb push_back
#define fi first
#define se second
#define DEBUG(x) cerr << (#x) << ": " << (x) << '\n'

using namespace std;

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

template<class T> bool uin(T &a, T b) {return (a < b ? false : (a = b, true));}
template<class T> bool uax(T &a, T b) {return (a > b ? false : (a = b, true));}

//ifstream f(".in");
//ofstream g(".out");

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
#ifdef LOCAL_DEFINE
  freopen(".in", "r", stdin);
#endif

  int n;
  cin >> n;
  vector<int> dp(3);
  for (int i = 1; i <= n; ++i) {
    vector<int> score(3);
    for (int &x : score) cin >> x;
    vector<int> new_dp(3);
    for (int j = 0; j < 3; ++j) {
      for (int k = 0; k < 3; ++k) if (j != k) {
        uax(new_dp[j], score[j] + dp[k]);
      }
    }
    dp = new_dp;
  }

  cout << max({dp[0], dp[1], dp[2]}) << '\n';

#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}


Measured memory_bytes: 256
def main():
    s=input()[::-1]
    string=('maerd','remaerd','esare','resare')
    
    n=len(s)
    i=0
    while i<n:
        st=s[i:i+5]
        if st in string:
            i+=5
            continue
        st=s[i:i+6]
        if st==string[3]:
            i+=6
            continue
        st=s[i:i+7]
        if st==string[1]:
            i+=7
            continue
        else:
            print('NO')
            exit()
    print('YES')   

if  __name__=='__main__':
    main()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    ll n;
    cin >> n;
    ll a[n];
    rep(i, 0, n) cin >> a[i];
    ll ans = 0;
    rep(i, 0, 61) {
        int sum1 = 0;
        rep(j, 0, n) {
            if (a[j] & (1LL << i)) sum1++;
        }
        ans += (((1LL << i) % MOD) * ((sum1 * (n - sum1)) % MOD)) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--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 IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  string s; 
  cin >> s;

  int N = s.size();

  // dp[i][j]: i文字目まで見て, 13で割った余りがjの数
  vector<vector<int>> dp(N+1, vector<int>(14, 0));
  dp[0][0] = 1;

  REP(i, N){
    if(s[i] == '?'){
      REP(d, 10){
        REP(j, 14){
          (dp[i+1][(j*10+d)%13] += dp[i][j]) %= MOD;
        }
      }
    }else{
      int d = s[i]-'0';
      REP(j, 14){
        (dp[i+1][(j*10+d)%13] += dp[i][j]) %= MOD;
      }
    }
  }

  cout << dp[N][5] << endl;

  return 0;
}

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

using namespace std;

bool solve() {
  int n;
  cin >> n;
  if (n == 0) return false;
  vector<int> a(n);
  for (int& i : a) cin >> i;
  int sum = 0, res = a[0];
  for (int i = 0; i < n; ++i) {
    res = max(res, sum + a[i]);
    if (sum + a[i] < 0) sum = 0;
    else sum += a[i];
  }
  cout << res << endl;
  return true;
}

int main() {
  while (solve());
}

Measured memory_bytes: 2996
n = int(input())
ab = [list(map(int, input().split())) for i in range(n)]


if n % 2 == 1:
  man = n // 2 + 1
  ab.sort(key=lambda x:x[0])
  ansmin1 = ab[man-1][0]
  ab.sort(key=lambda x:x[1])
  ansmax2 = ab[man-1][1]
  print(ansmax2-ansmin1+1)
else:
  man = n // 2 
  man2 = n // 2 + 1
  ab.sort(key=lambda x:x[0])
  ansmin1 = ab[man-1][0]
  ansmin2 = ab[man2-1][0]
  ab.sort(key=lambda x:x[1])
  ansmax1 = ab[man-1][1]
  ansmax2 = ab[man2-1][1]
  print(ansmax1+ansmax2-ansmin1-ansmin2+1)


Measured memory_bytes: 48640
import java.util.Scanner;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt()-1;
        int b = sc.nextInt()-1;
        int[] f ={
            1,3,1,2,1,2,1,1,2,1,2,1
        };
        System.out.println(f[a]==f[b]?"Yes":"No");
    }
}


Measured memory_bytes: 21204
using System.Linq;
using System;
class stati{static void Main(){
int []n=Console.ReadLine().Split().Select(int.Parse).ToArray();
int ans=n[0]+n[1]*5+n[2]*10+n[3]*50+n[4]*100+n[5]*500;
Console.WriteLine(ans>=1000?"1":"0");
}}

Measured memory_bytes: 9192
#include<iostream>
#include<cstdio>
//#include<cmath> 
using namespace std;
int n,ans; 
int main()
{
	scanf("%d",&n);
	/*for(int i=1;i<n;i++)
	{
		for(int j=1;j<=i;j++)
		{
			if(i%j==0) ans++;
		}
	}*/
	for(int i=1;i<n;i++)
	{
		for(int j=1;j<n;j++)
		{
			if(i*j>=n) break;
			ans++;
		}
	}
	printf("%d",ans);
	return 0;
 } 

Measured memory_bytes: 3820
package main

import "fmt"

func main() {
	var N, K int64
	fmt.Scan(&N, &K)
	var tmp int64
	N = N % K
	for {
		tmp = N - K

		if tmp < 0 {
			tmp = -1 * tmp
		}
		if tmp < N {
			N = tmp
		} else {
			break
		}
		if N == 0 {
			break
		}
	}

	fmt.Println(N)

}


Measured memory_bytes: 512
MD=998244353

import sys
read=sys.stdin.buffer.read
readline=sys.stdin.buffer.readline
readlines=sys.stdin.buffer.readlines

import numpy as np

N=int(readline())
#print(N)
D=list(map(int,readline().split()))
#print(D)

C=[0]*(N)

for i in range(N):
  C[D[i]]+=1
#print(C)

tmp=1
for i in range(N-1):
  tmp*=(C[i]**C[i+1])
  tmp%=MD
answer=tmp

if N==1:
  answer=0 if C[0]!=0 else 1
for i in range(1,N):
  if D[i]==0:
    answer=0  

print(answer)

Measured memory_bytes: 22564
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 2e5; int k, n;
int a[maxN];
int diff[maxN];

int main()
{
  while (scanf("%d %d", &k, &n) != EOF)
  {
    for (int i = 0; i < n; i++)
      scanf("%d", &a[i]);

    for (int i = 1; i < n; i++)
      diff[i - 1] = a[i] - a[i - 1];
    diff[n - 1] = k - a[n - 1] + a[0];

    int s = 0;
    for (int i = 0; i < n; i++)
      s += diff[i];

    printf("%d\n", s - *max_element(diff, diff+n));
  }
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main(void)
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string str;
  cin >> str;
  cout << ((str[2] == str[3] && str[4] == str[5])? "Yes" : "No") << '\n'; 
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
constexpr int INF = 1LL<<60;

signed main() {
  string s; cin>>s;
  
  for(int bit=0;bit<(1<<3);++bit){
    int res = s[0]-'0';
    for(int i=0;i<3;++i){
      // iビット目が立っている時は+1, 立っていない時は-1をかけることで, +-としている
      res += ((bit>>i)&1?+1:-1) * (s[i+1]-'0');
    }
    if (res == 7) {
       // 解ができた時は出力
       cout<<s[0];
       for(int i=0;i<3;++i){
         // この書き方でもok
         cout<<(bit&(1<<i)?"+":"-")<<s[i+1];
       }
       cout<<"=7"<<endl;
       return 0;
    }
  }
  return 0;
}

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

int main() {
	vector<int> V(3);
	for (int i = 0; i < 3; i++) {
		cin >> V[i];
	}
	sort(V.begin(), V.end());	
	cout << V[0] << " " << V[1] << " " << V[2] << endl;
}



Measured memory_bytes: 3136
package main

import (
	"fmt"
	"sort"
)

func main() {
	v := make([]int, 3)
	for i := 0; i < 3; i++ {
		var a int
		fmt.Scan(&a)
		v[i] = a
	}

	sort.Ints(v)
	fmt.Println(v[0], v[1], v[2])
}



Measured memory_bytes: 1128
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using edge = struct {
  int to;
  int cost;
};
#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 BITS(n, num) std::bitset<(n)>((num)).to_string()
#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 VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))

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

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

ll merge_cnt(vector<ll> &a) {
  ll n = a.size();
  if (n <= 1) {
    return 0;
  }

  ll cnt = 0;
  vl b(a.begin(), a.begin() + n / 2);
  vl c(a.begin() + n / 2, a.end());

  cnt += merge_cnt(b);
  cnt += merge_cnt(c);

  ll ai = 0, bi = 0, ci = 0;
  // merge の処理
  while (ai < n) {
    if (bi < b.size() && (ci == c.size() || b[bi] <= c[ci])) {
      a[ai++] = b[bi++];
    } else {
      cnt += n / 2 - bi;
      a[ai++] = c[ci++];
    }
  }
  return cnt;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  vl A(N, 0);
  REP(i, N) cin >> A[i];
  auto B = A;
  sort(ALL(B), REV(ll));

  ll left = -1;
  ll right = N;

  while (abs(right - left) > 1) {
    ll mid = left + (right - left) / 2;
    ll x = B[mid];
    vl S(N + 1, 0);
    FOR(i, 1, N + 1) { S[i] = S[i - 1] + ((A[i - 1] >= x) ? 1 : (-1)); }
    ll ans = merge_cnt(S); //転倒数
    if (ans <= (((N + 1) * N) / 2 / 2)) {
      right = mid;
    } else
      left = mid;
  }
  cout << B[right] << endl;
  return 0;
}


Measured memory_bytes: 4224