akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC127
{
    class D
    {
        static void Main(string[] args)
        {
            int[] nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] b = new int[nm[1]];
            int[] c = new int[nm[1]];
            for (int i = 0; i < nm[1]; i++)
            {
                int[] j = Console.ReadLine().Split().Select(int.Parse).ToArray();
                b[i] = j[0];c[i] = j[1];
            }
            Array.Sort(a);
            Array.Sort(c, b);
            Array.Sort(c);
            int k = c.Length-1, l=b[b.Length-1], sum = 0;
            for (int i = 0; i < nm[0]; i++)
            {
                if (a[i] >= c[k]) { break; }
                a[i] = c[k];
                l--;
                if (0 == l) {
                    if (k == 0) { break; }
                        k--; l = b[k];
                }
            }
            long ans = 0;
            for (int i = 0; i < nm[0]; i++)
            {
                ans += a[i];
            }
            Console.WriteLine(ans);
        }
    }
}


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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
using Graph = vector<vector<int>>;

int main(){
    int a,b; cin>>a>>b;
    a--;b--;
    cout<<100<<" "<<100<<endl;
    rep(i,50){
        rep(j,100){
            if(a>0&&(i+j)%2==0&&i%2==0)cout<<".",a--;
            else cout<<"#";
        }
        cout<<endl;
    }
    rep(j,100)cout<<".";
    cout<<endl;
    rep(i,49){
        rep(j,100){
            if(b>0&&(i+j)%2==0&&i%2==0)cout<<"#",b--;
            else cout<<".";
        }
        cout<<endl;
    }
}


Measured memory_bytes: 3592
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder_ABC140
{
    class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }
        public void Solve(ConsoleInput cin)
        {
            var n = cin.ReadInt;
            var b = cin.ReadIntArray(n-1);
            var a = new int[n];
            var score = 0;

            score = b[0];
            for (int i = 1; i < n-1; i++)
            {
                if (b[i] <= b[i - 1])
                    score += b[i];
                else
                    score += b[i - 1];
            }
            score += b[n - 2];
            WriteLine($"{score}");
        }
    }
    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 13396
a, b, c = map(int, input().split())
k = int(input())
ans = "No"
for i in range(k):
  if a>=b:
    b = 2*b
  elif b>=c:
    c = 2*c
  else:
    ans="Yes"
    break
if a<b and b<c:
    ans = "Yes"
print(ans)

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

#define INF (INT64_MAX)
#define MOD (1000000000+7)
#define MAX 100000

int main() {
	int a, b, c;

	cin >> a >> b >> c;

	int ans = 3;
	if( a == b && b == c ) {
		ans = 1;
	}
	else if( a == b || b == c || c == a ) {
		ans = 2;
	}

	cout << ans << endl;

	return 0;
}


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

int gcd(int a, int b) {
    if(a % b == 0) return b;
    else return(gcd(b, a % b));
}

int main()
{
    int n;
    cin >> n;
    int ans;
    cin >> ans;
    repl(i, 1, n) {
        int a;
        cin >> a;
        ans = gcd(ans, a);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 2000000010;
constexpr ll INF= 2000000000000000000;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}

// N^P mod M（ただしM == -1の時はmodを取らない）
template<typename T>
T RS(T N, T P, T M){
    if(P == 0) {
        return 1;
    }
    if(P < 0) {
        return 0;
    }
    if(P % 2 == 0){
        ll t = RS(N, P/2, M);
        if(M == -1) return t * t;
        return t * t % M;
    }
    if(M == -1) {
        return N * RS(N,P - 1,M);
    }
    return N * RS(N, P-1, M) % M;
}

int N;
bool flag[310][310][310];
double dp[310][310][310];

double solve(int a,int b,int c) {
    if(flag[a][b][c]) {
        return dp[a][b][c];
    }
    flag[a][b][c] = true;
    if(a == 0 && b == 0 && c == 0) {
        return dp[a][b][c] = 0;
    }
    double fans = 1 / ( 1 - (double)(N - a - b - c) / N);
    if(a > 0) {
        fans += solve(a - 1,b,c) * a / N / (1 - (double)(N - a - b - c) / N);
    }
    if(b > 0) {
        fans += solve(a + 1,b - 1,c) * b / N / (1 - (double)(N - a - b - c) / N);
    }
    if(c > 0) {
        fans += solve(a,b + 1,c - 1) * c / N / (1 - (double)(N - a - b - c) / N);
    }
    return dp[a][b][c] = fans;
}

int main() {
    cin >> N;
    int one = 0;
    int two = 0;
    int three = 0;
    for(int i = 0;i < N;i++) {
        int A;
        cin >> A;
        if(A == 1) {
            one++;
        }
        else if(A == 2) {
            two++;
        }
        else {
            three++;
        }
    }
    for(int i = 0;i < 310;i++) {
        for(int j = 0;j < 310;j++) {
            for(int k = 0;k < 310;k++) {
                flag[i][j][k] = false;
            }
        }
    }
    cout << fixed;
    cout << setprecision(12) << solve(one,two,three) << endl;
}         

Measured memory_bytes: 143380
n = int(input())
v = list(map(int, input().split()))
odds = {}
evens = {}
for i in v[0::2]:
    if i in odds:
        odds[i] += 1
    else:
        odds[i] = 1
for i in v[1::2]:
    if i in evens:
        evens[i] += 1
    else:
        evens[i] = 1
odds = list(odds.items())
evens = list(evens.items())
odds.sort(key=lambda x:-x[1])
evens.sort(key=lambda x:-x[1])
odds.append((None, 0))
evens.append((None, 0))
if odds[0][0]!=evens[0][0]:
    print(n-odds[0][1]-evens[0][1])
else:
    print(n-max(odds[0][1]+evens[1][1], odds[1][1]+evens[0][1]))

Measured memory_bytes: 18292
// -*- coding:utf-8-unix -*-

use proconio::input;
use std::collections::HashSet;

fn main() {
    input! {
        n: usize,
        s: String,
    }

    let vc: Vec<char> = s.chars().collect();
    let mut ans = 0u64;
    let mut hsi = HashSet::new();
    for i in 0..n {
        if hsi.len() == 10 {
            break;
        } else if hsi.contains(&vc[i]) {
            continue;
        }

        hsi.insert(&vc[i]);
        // println!("{}", vc[i]);
        let mut hsj = HashSet::new();
        for j in i + 1..n {
            if hsj.len() == 10 {
                break;
            } else if hsj.contains(&vc[j]) {
                continue;
            }

            hsj.insert(&vc[j]);
            // println!("j: {}", vc[j]);
            let mut uniq = HashSet::new();
            for k in j + 1..n {
                if uniq.len() == 10 {
                    break;
                } else if uniq.contains(&vc[k]) {
                    continue;
                }

                uniq.insert(vc[k]);
            }
            // println!("ans += {:?}", uniq);
            ans += uniq.len() as u64;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2324
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#define REP(i, n) for(int i=0;i<n;++i)
#define INF 100000000
#define ll long long

using namespace std;

typedef pair<int, int> P;

int a, b, c;
string ans;

int main(){
  cin >> a >> b >> c;
  ans = a + b >= c ? "Yes" : "No";
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
#define MPlus(x,y) {x=(x+y)%M;}
#define MSub(x,y) {x=(x-y+M)%M;}
#define MMul(x,y) {x=(x*y)%M;}


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

  vi a(3);
  rep(i,3){
    cin>>a[i];
  }
  int k;
  cin>>k;
  sort(all(a));
  reverse(all(a));
  rep(i,k){
    a[0]*=2;
  }

  cout<<a[0]+a[1]+a[2]<<endl;


}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <math.h>
#define ll long long
#define N 100000
using namespace std;


int main(){
    ll x;
    cin>>x;
    vector<ll> num;
    ll count=0;
    ll y=pow(x, 0.5);
    for (ll i=1; i<=y; i++){
        if (x%i==0){
            count+=2;
            num.push_back(i);
            num.push_back(x/i);
        }
    }
    bool ans=false;
    ll s,t;
    ll r=0-N;
    for (ll i=r; i<=N; i++){
        for (ll j=0; j<count; j++){
            ll w=i+num[j];
            ll p=w*w*w*w*w;
            ll q=i*i*i*i*i;
            if (p-q==x){
                ans=true;
                s=w;
                t=i;
                break;
            }
        }
    }
    if (ans) cout<<s<<" "<<t<<endl;
    else cout<<"-1"<<endl;
}

Measured memory_bytes: 4096
import numpy as np
n=5
a=[int(input()) for i in range(n)]
b=[0] * 5
for i in range(5):
    b[i]=10-a[i]%10
    if b[i]==10:
        b[i]=0
b=np.array(b)
c=list(b.argsort())
x=0
for i in range(4):
    unchi=a[c[i]]
    x=x+unchi    
    if (unchi%10)!=0:
        omake=10-unchi%10
        x=x+omake
    
x=x+a[c[4]]
print(x)

Measured memory_bytes: 12448
#include <iostream>
#include <string>
using namespace std;
int main(){
	string s;
	cin >> s;
	int n = s.size()-1;
	if(n==0){
		cout << s << endl;
		return 0;
	}

	long long sum = 0;

	for(int bit=0; bit < (1<<n); bit++){
		int l=0, r=0;
		for(r=0; r<n; r++){
			if(bit & (1<<r)){
				sum += stoll(s.substr(l, r-l+1));
				l = r+1;
			}
			if(r==n-1) sum += stoll(s.substr(l, r-l+2));
		}
 	}
	cout << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for ((i)=1;(i)<=(n);(i)++)
#define per(i,n) for ((i)=n;(i)>=(1);(i)--)
using namespace std;
int n,i,sg[200005];
vector<int> adj[200005];
void dfs(int x,int fa)
{
	int i;
	for(i=0;i<adj[x].size();i++)if(adj[x][i]!=fa)
	{
		dfs(adj[x][i],x);
		sg[x]^=(sg[adj[x][i]]+1);
	}
}
int main()
{
	cin>>n;
	rep(i,n-1)
	{
		int x,y;
		cin>>x>>y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	dfs(1,0);
	if(sg[1]) puts("Alice");else puts("Bob");
	return 0;
}

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

using namespace std;

int main(){

    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cout.precision(20);

    int n;
    cin >> n;
    vector<int>v(n);
    int ans = 0;
    for(int i = 0; i < n; i++)
        cin >> v[i];
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            ans = max(ans, abs(v[i]-v[j]));
        }
    }
    cout << ans << '\n';

}

Measured memory_bytes: 256
package main

import "fmt"

func main() {

  var a, b int
  fmt.Scanf("%d %d", &a, &b)
  
  if ( a < b ) {
      fmt.Println("a < b")
  } else if ( a > b) {
      fmt.Println("a > b")
  } else {
      fmt.Println("a == b")
  }
}


Measured memory_bytes: 1172
# encoding: utf-8

import sys
from collections import deque


class Solution:
    @staticmethod
    def doubly_linked_list():
        # write your code here
        array_length = int(input())
        task_deque = deque()
        _input = sys.stdin.readlines()

        for i in range(array_length):
            l_arg = _input[i].split()
            action = l_arg[0]
            if len(l_arg) > 1:
                value = l_arg[-1]
            # print(action, 'v', value)

            if action == 'insert':
                task_deque.appendleft(value)
            elif action == 'deleteFirst':
                task_deque.popleft()
            elif action == 'deleteLast':
                task_deque.pop()
            else :
                try:
                    task_deque.remove(value)
                except Exception as e:
                    pass
        print(" ".join(task_deque))


if __name__ == '__main__':
    solution = Solution()
    solution.doubly_linked_list()

Measured memory_bytes: 214340
#MLE注意！0や1のケースに注意

def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    #from math import gcd

    #inf = 10**17
    #mod = 10**9 + 7

    x = int(input())
    for i in range(10**3, -(10**3), -1):
        for j in range(10**3, -(10**3), -1):
            if i**5 - j**5 == x:
                print(i, j)
                exit()


if __name__ == '__main__':
    main()

Measured memory_bytes: 68100
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
int main() {
    lli n;
    cin>>n;
    lli sum =0;
    sum=((n)*(n-1))/2;
    cout<<sum<<endl;
    // vector<vector<int>> a(n,vector<int>(m,0));
}

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

int main() {
  int N;
  cin>>N;
  int x = N;
  int sum = 0;
  while ( x != 0){
    sum+=x%10;
    x=x/10;
  }
  if (N%sum==0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  


}


Measured memory_bytes: 256
//hinagata.cpp
/*includes*/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <numeric>
#include <iomanip>
#include <limits>
/*namespace*/
using namespace std;
using ll= long long;
/*define macro*/
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPi(i,a,b) for(int i=(a);i<(b);i++)
#define REPRi(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(x) (x).begin(),(x).end()

int main(){
    int D;
    cin>>D;
    cout<<"Christmas";
    REPi(i,D,25){
        cout<<" Eve";
    }
    cout<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	long ans = sc.nextInt();
    	for(int i = 1; i < N; i++){
    		 ans = gcd(ans, sc.nextInt());
    	}
    	sc.close();
    	System.out.println(ans);
    }

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

}


Measured memory_bytes: 49140
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;

int main() {
  string S;
  cin >> S;
  
  string S1 = {S.at(0), S.at(1)};
  string S2 = {S.at(2), S.at(3)};
  
  bool flag1 = "01"<=S1 && S1<="12";
  bool flag2 = "01"<=S2 && S2<="12";
  
  if (flag1 && flag2)
    cout << "AMBIGUOUS" << endl;
  else if (flag1 && !(flag2))
    cout << "MMYY" << endl;
  else if (!(flag1) && flag2)
    cout << "YYMM" << endl;
  else
    cout << "NA" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <climits>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <utility>
#include <vector>

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;
using uintl32 = std::uint_least32_t;



template<typename T, size_t bitsize>
class wavelet_matrix {
	std::vector<std::uint_least32_t> dic[bitsize];
	uint32 border[bitsize];
	inline uint32 rank(uint32 i, uint32 index) {
		return dic[i][(index >> 5) << 1] + __builtin_popcount(dic[i][index >> 4 | 1] & ((uintl32)1 << (index & 0x1f)) - 1);
	}
public:
	wavelet_matrix(std::vector<T> &a) {
		const uint32 len = a.size(), block = ((len >> 5) + 1) << 1;
		for (uint32 i = 0; i < bitsize;++i) {
			dic[i] = std::vector<std::uint_least32_t>(block, 0);
		}
		std::queue<T> Q0, Q1;
		for (uint32 i = 0;i < len;++i) {
			Q0.push(a[i]);
		}
		for (uint32 i = bitsize - 1;~i;--i) {
			const uint32 size = Q0.size();
			uint32 j;
			for (j = 0;j < size;++j) {
				if (Q0.front() >> i & 1) {
					dic[i][j >> 4 | 1] |= (std::uint_least32_t)1 << (j & 0x1f);
					Q1.push(Q0.front());
				}
				else {
					Q0.push(Q0.front());
				}
				Q0.pop();
			}
			for (;j < len;++j) {
				if (Q1.front() >> i & 1) {
					dic[i][j >> 4 | 1] |= (std::uint_least32_t)1 << (j & 0x1f);
					Q1.push(Q1.front());
				}
				else {
					Q0.push(Q1.front());
				}
				Q1.pop();
			}
			border[i] = Q0.size();
			for (j = 2;j < block;j+=2) {
				dic[i][j] = dic[i][j - 2] + __builtin_popcount(dic[i][j - 1]);
			}
		}
		return;
	}
	T access(uint32 index) {
		T ret = 0;
		for (uint32 i = bitsize - 1;~i;--i) {
			ret <<= 1;
			if (dic[i][index >> 4 | 1] >> (index & 0x1f) & 1) {
				++ret;
				index = rank(i, index) + border[i];
			}
			else {
				index -= rank(i, index);
			}
		}
		return ret;
	}
	T rank(uint32 begin, uint32 end, T data) {
		for (uint32 i = bitsize - 1;~i;--i) {
			if (data >> i & 1) {
				begin = rank(i,begin) + border[i];
				end = rank(i,end) + border[i];
			}
			else {
				begin -= rank(i, begin);
				end -= rank(i, end);
			}
		}
		return end - begin;
	}
	T quantile(uint32 begin, uint32 end, uint32 k) {
		T ret = 0;
		for (uint32 i = bitsize - 1;~i;--i) {
			const uint32 l = rank(i, begin), r = rank(i, end);
			ret <<= 1;
			if (r - l > k) {
				begin = l + border[i];
				end = r + border[i];
				++ret;
			}
			else {
				begin -= l;
				end -= r;
				k -= r - l;
			}
		}
		return ret;
	}
	T rquantile(uint32 begin, uint32 end, uint32 k) {
		return quantile(begin, end, end - begin - k - 1);
	}
};

int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	uint32 n, l;
	std::cin >> n >> l;
	std::vector<uint32> a(n);
	for (uint32 i = 0;i < n;++i) {
		std::cin >> a[i];
	}
	wavelet_matrix<uint32, 30> T(a);
	std::cout << T.rquantile(0, l, 0);
	for (uint32 i = 1;i < n - l + 1;++i) {
		std::cout << " " << T.rquantile(i, i + l, 0);
	}
	std::cout << "\n";
	return 0;
}


Measured memory_bytes: 26756
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<unistd.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define ST first
#define ND second
#define ll long long
#define ld long double
using namespace std;
using namespace __gnu_pbds;
 
// replace ll with pair if multiset needed
typedef tree<pair<int,int>, null_type, greater<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ordered_set secik;
 
const ll INF = 1e9 + 9;
const ll MOD = 1e9 + 7;
const long long LINF = (ll)1e18 + 3;
 
// secik.insert({x, t++});
// secik.erase(secik.lower_bound({x,-1}));
// *secik.find_by_order(x)).first << "\n";
// secik.order_of_key(x)
 
//random_device device;
//mt19937 gener(device());
//uniform_int_distribution<int> gen(0,n-1);

const int SIZE = 3e3 + 6;

ld dp[SIZE][SIZE];
ld tab[SIZE]; 

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

	int n; cin >> n;
	for(int i = 0; i < n; i++){
		cin >> tab[i];
	}
	
	dp[1][1] = tab[0];
	dp[1][0] = 1.000000 - tab[0];

	for(int i = 2; i <= n; i++){
		for(int j = i; j >= 0; j--){
			if(j == i){
				dp[i][j] = dp[i-1][j-1] * tab[i-1];
			} else if(j == 0){
				dp[i][j] = dp[i-1][j] * (1.0000000 - tab[i-1]);
			} else {
				dp[i][j] = dp[i-1][j] * (1.0000000 - tab[i-1]) + dp[i-1][j-1] * tab[i-1];
			}
		} 
	}
	
	ld result = 0;

	for(int i = n/2 + 1; i <= n; i++) result += dp[n][i];

	cout << fixed << setprecision(12) << result;

}

Measured memory_bytes: 139392
//#define NDEBUG

#pragma region cp_template

#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <utility>
#include <vector>

namespace n91 {

using i32 = std::int32_t;
using i64 = std::int64_t;
using u32 = std::uint32_t;
using u64 = std::uint64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

struct rep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr rep(const usize f, const usize l) noexcept
      : f(std::min(f, l)), l(l) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
struct revrep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr revrep(const usize f, const usize l) noexcept
      : f(l - 1), l(std::min(f, l) - 1) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) noexcept {
  return a < b ? b - a : a - b;
}
template <class T> void chmin(T &a, const T &b) noexcept {
  if (b < a)
    a = b;
}
template <class T> void chmax(T &a, const T &b) noexcept {
  if (a < b)
    a = b;
}
template <class F> class rec_lambda {
  F f;

public:
  rec_lambda(F &&f) : f(std::move(f)) {}
  template <class... Args> auto operator()(Args &&... args) const {
    return f(*this, std::forward<Args>(args)...);
  }
};
template <class F> auto make_rec(F &&f) { return rec_lambda<F>(std::move(f)); }
template <class T> T scan() {
  T ret;
  std::cin >> ret;
  return ret;
}
constexpr char eoln = '\n';
template <class T> T ceildiv(const T &l, const T &r) {
  return l / r + (l % r != 0 ? 1 : 0);
}

} // namespace n91

#pragma endregion cp_template

namespace n91 {

void main_() {
  /*
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  //*/
  const u32 x = scan<u32>();
  std::cout << (10 - x / 200) << eoln;
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a)%MOD)+((b)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define EPS (1e-20)
#define INF 214748364700000
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using VLL = std::vector<llint>;
using MCI = std::map<char, int>;
using namespace std;


signed main(){
	int N, K;
	cin >> N >> K;

	if(N%K == 0) cout << 0 << endl;
	else cout << 1 << endl;

	return 0;
}

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

int main(void)
{
  char s[100],t[100],tmp;
  if(scanf("%s",s)<0) exit(1);
  if(scanf("%s",t)<0) exit(1);

// fgets(s,100,stdin);
// fgets(t,100,stdin);
  int i,j;
//  printf("%lu",strlen(s));


   for(i=0;i<strlen(s)-1;i++)
  {
    if(strcmp(s,t)==0)
    {
      break;
    }
    else
    {
      tmp=s[0];
      for(j=0;j<strlen(s)-1;j++)
      {
        s[j]=s[j+1];
      }
      s[strlen(s)-1]=tmp;
    }
  }

  if(strcmp(s,t)==0)
  {
    printf("Yes\n");
  }
  else printf("No\n");

  return 0;
}



Measured memory_bytes: 128
import java.util.*;

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

    while(true){
      String str = sc.next();
      if(str.equals("-")) break;

      int m=sc.nextInt();

      for (int i=0; i<m; i++) {
        int l = sc.nextInt();
        str = str.substring(l) + str.substring(0, l);
      }
      System.out.printf("%s\n", str);
    }

  }
}



Measured memory_bytes: 26404
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] h = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }

        int max = 0;
        for (int i = 0; i < n - 1; i++) {
            int tmpMax = 0;
            if (max > n - i) {
                break;
            }
            for (int j = i; j < n - 1; j++) {
                if (h[j] >= h[j + 1]) {
                    tmpMax++;
                } else {
                    break;
                }
            }
            if (tmpMax > max) {
                max = tmpMax;
            }
        }

        System.out.println(max);

        sc.close();
    }
}


Measured memory_bytes: 51032
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int dp[202020],n,a[202020]; 

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  cin >> n;        
  for(int i=1;i<=n;i++){
    cin >> a[i];
    dp[i]=-10000000000;
  }  
  for(int i=1;i<=n;i++){
    dp[a[i]] = max(dp[a[i]] , dp[a[i]-1]+1 );
  }
  int ans = n;
  for(int i=1;i<=n;i++){
    ans = min(ans, n-dp[i]);    
  }
  if(ans>=n)ans=-1;
  cout << ans << endl;

return 0;
}
///....


Measured memory_bytes: 3456
#include<iostream>
#include<cmath>
#include<stdio.h>
#include <ctype.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<stack>
#include<set>
#include<map>
#include<deque> //<< fixed << setprecision()
#include<queue> //priority_queue
#include<vector>
#define em3 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define iof freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

using namespace std;
#define f first
#define s second
#define X real()
#define Y imag()
#define cross(a, b) ((conj(a) * (b)).Y)
#define dot(a, b) ((conj(a) * (b)).X)
#define inFile(t) freopen((t),"r",stdin)
#define outFile(t) freopen((t),"w",stdout)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define EPS 1e-7
long long mod = 1e9 + 7;
const int N = 1e4 + 5;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const double pi = acos(-1);
//typedef complex <ll> point;
typedef tuple<int, int, int> line;
//typedef vector<point> polygon;


int main()
{
	map<ll, ll>mp;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		ll a, b;
		cin >> a >> b;
		mp[b] += a;
	}
	ll sum = 0;
	bool good = 1;
	for (auto i : mp)
	{
			sum += i.second;
		if (sum > i.first)
		{
			good = 0;
			break;
		}

	}
	if (good)
		cout << "Yes";
	else
		cout << "No";
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int a,b,k;
  cin >> a >> b >> k;
  map<int, int> ans;
  rep(i, k){
    if(i + a <= b) ans[i + a]++;
  }
  for(int i = k - 1; i >= 0; i--){
    if(b - i >= a) ans[b - i]++;
  }
  for(auto a : ans) cout << a.first << endl;
}

Measured memory_bytes: 256
from itertools import combinations
N=int(input())
L = [str(input()) for i in range(N)]
count_M=0
count_A=0
count_R=0
count_C=0
count_H=0
for i in L:
    if i[0]=='M':count_M+=1
    elif i[0]=='A':count_A+=1
    elif i[0]=='R':count_R+=1
    elif i[0]=='C':count_C+=1
    elif i[0]=='H':count_H+=1
name_list=[count_M,count_A,count_R,count_C,count_H]
sum_list=list(combinations(name_list,3))
s_list=[i[0]*i[1]*i[2] for i in sum_list]
print(sum(s_list))

Measured memory_bytes: 9776
#include<stdio.h>
#define MOD 1000000007

int main(){
	int N;
	scanf("%d",&N);
	char S1[N+1],S2[N+1];
	scanf("%s%s",S1,S2);
	long long ans=1;
	int flag;
	
	int i;
	if(S1[0]==S2[0]){
		ans=3;
		i=1;
		flag=0;
	}
	else{
		ans=6;
		i=2;
		flag=1;
	}
	
	for(i;i<N;i++){
		if(S1[i]==S2[i]){
			if(flag==0)ans*=2;
			flag=0;
		}
		else{
			if(flag==0)ans*=2;
			else ans*=3;
			i++;
			flag=1;
		}
		ans%=MOD;
	}
	
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
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; }
ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a,b);}

int main(){
  string s,t;
  cin >> s>>t;
  int a,b;
  cin >>a>>b;
  string u;
  cin >> u;
  if(u==s) a-=1;
  if(u==t) b-=1;
  cout << a << ' '<< b << endl;


}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

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

const int mod = 1e9 + 7;
const int maxn = 1e6 + 5;

int fac[maxn], inv[maxn];

int qpow(int a, int n){
    int ret = 1;
    while(n > 0){
        if(n & 1){
            ret = 1LL * ret * a % mod;
        }
        a = 1LL * a * a % mod;
        n >>= 1;
    }
    return ret;
}

void pre_comb(){
    fac[0] = 1;
    for(int i = 1;i < maxn;i++){
        fac[i] = 1LL * fac[i - 1] * i % mod;
    }
    inv[maxn - 1] = qpow(fac[maxn - 1], mod - 2);
    for(int i = maxn - 2;i >= 0;i--){
        inv[i] = 1LL * inv[i + 1] * (i + 1) % mod;
    }
}

int n;
int X, Y;
vector<int> a[maxn];
vector<pi> b[maxn];

int cnt[maxn];

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    pre_comb();
    cin >> n >> X >> Y;
    for(int i = 1;i <= n;i++){
        int c, w;
        cin >> c >> w;
        a[c].push_back(w);
    }
    for(int i = 1;i <= n;i++){
        sort(a[i].begin(), a[i].end());
    }
    int colors = 0;
    for(int i = 1;i <= n;i++){
        if(a[i].size() == 0){
            continue;
        }else if(a[i].size() == 1){
            colors++;
            b[i].eb(a[i][0], 1); 
        }else{
            colors++;
            int j;
            for(j = 1;j < a[i].size();j++){
                if(a[i][0] + a[i][j] > X){
                    break;
                }
            }
            b[i].eb(a[i][0], j);
            for(int k = j;k < a[i].size();k++){
                b[i].eb(a[i][k], 1); 
            }
        }
    }
    if(colors == 1){
        cout << 1 << endl;
    }else{
        vector<pi> A;
        for(int i = 1;i <= n;i++){
            if(a[i].size() > 0){
                A.eb(a[i][0], i);
            }
        }
        sort(A.begin(), A.end());
        int u = A[0].se;
        int v = A[1].se;
        if(a[u][0] + a[v][0] > Y){
            cout << 1 << endl;
        }else{
            int sum = 0;            
            for(int i = 1;i <= n;i++){
                if(i == u){
                    for(auto p : b[i]){
                        if(p.fi + a[v][0] <= Y){
                            cnt[i] += p.se;
                        }
                    }
                }else{
                    for(auto p : b[i]){
                        if(p.fi + a[u][0] <= Y){
                            cnt[i] += p.se;
                        } 
                    }
                }
            }
            int ans = 1;
            for(int i = 1;i <= n;i++){
                sum += cnt[i];
                ans = 1LL * ans * inv[cnt[i]] % mod;
            }
            ans = 1LL * ans * fac[sum] % mod;
            cout << ans << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 67960
import java.util.*;
 
public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	int[] r = new int[N];
    	for (int i = 0; i < N; i++) {
    		r[i] = sc.nextInt();
    	}
    	int index = 1;
    	int crush = 0;
    	boolean can = false;
    	for (int i = 0; i < N; i++) {
    		if (r[i] == index) {
    			can = true;
    			index++;
    			continue;
    		} else {
    			crush++;
    		}
    	}
    	System.out.println(can ? crush : -1);
    }
}

Measured memory_bytes: 81604
#include "bits/stdc++.h"
#define ff first
#define ss second
#define szof(_x) ((int) (_x).size())
#define TASK_NAME ""

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9 + 7;
const ll INFL = 1e18 + 123;
const double PI = atan2(0, -1);
mt19937 tw(960172);
ll rnd(ll x, ll y) { static uniform_int_distribution<ll> d; return d(tw) % (y - x + 1) + x; }

int dfs(int x, int y, int col, int n, int d, vector<vector<bool>>& used, vector<vector<int>>& f, vector<pii> const& shifts) {
	used[x][y] = true;
	f[x][y] = col;
	for (auto s : shifts) {
		int nx = x + s.ff;
		int ny = y + s.ss;
		if (0 <= nx && nx < n * 2 && 0 <= ny && ny < n * 2 && !used[nx][ny]) {
			dfs(nx, ny, 1 - col, n, d, used, f, shifts);
		}
	}
	return 0;
}

void solve() {
	int n, d1, d2;
	cin >> n >> d1 >> d2;
	vector<pii> shifts1, shifts2;
	for (int i = -n * 2 + 1; i < n * 2; ++i) {
		for (int j = -n * 2 + 1; j < n * 2; ++j) {
			if (i * i + j * j == d1) {
				shifts1.push_back({i, j});
			}
			if (i * i + j * j == d2) {
				shifts2.push_back({i, j});
			}
		}
	}

	vector<vector<int>> f1(n * 2, vector<int>(n * 2));
	vector<vector<bool>> used(n * 2, vector<bool>(n * 2));
	for (int i = 0; i < n * 2; ++i) {
		for (int j = 0; j < n * 2; ++j) {
			if (!used[i][j]) {
				dfs(i, j, 0, n, d1, used, f1, shifts1);
			}
		}
	}
	used = vector<vector<bool>>(n * 2, vector<bool>(n * 2));
	vector<vector<int>> f2(n * 2, vector<int>(n * 2));	
	for (int i = 0; i < n * 2; ++i) {
		for (int j = 0; j < n * 2; ++j) {
			if (!used[i][j]) {
				dfs(i, j, 0, n, d2, used, f2, shifts2);
			}
		}
	}

	vector<pii> res[2][2];
	for (int i = 0; i < n * 2; ++i) {
		for (int j = 0; j < n * 2; ++j) {
			res[f1[i][j]][f2[i][j]].push_back({i, j});
		}
	}

	for (int i = 0; i < 2; ++i) {
		for (int j = 0; j < 2; ++j) {
			if (szof(res[i][j]) >= n * n) {
				for (int k = 0; k < n * n; ++k) {
					cout << res[i][j][k].ff << " " << res[i][j][k].ss << "\n";
				}
				return;
			}
		}
	}
}


int main() {
	//freopen(TASK_NAME ".in", "r", stdin);
	//freopen(TASK_NAME ".out", "w", stdout);
	cerr << fixed << setprecision(15);
	cout << fixed << setprecision(15);
	ios::sync_with_stdio(false);

	int tests = 1;
	// cin >> tests;
	for (int it = 1; it <= tests; ++it) {
		solve();
	}
	
	#ifdef LOCAL
		cerr << "time: " << clock() << " ms\n";
	#endif
	return 0;
}

Measured memory_bytes: 40796
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<char> vchar;
typedef vector<vector<char>> vvchar;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef priority_queue<long long> prque;
#define ain(i,n,a) for(long long i=0;i<(long long)(n);i++){cin>>a[i];}
#define aout(i,n,a) for(long long i=0;i<(long long)(n);i++){if(i){cout<<" ";}cout<<a[i];if(i==n-1){cout<<endl;}}
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define vsort(v) sort((v).begin(),(v).end())
#define vrsort(v) sort((v).rbegin(),(v).rend())
#define vreverse(v) reverse((v).begin(),(v).end())
#define pf(a) push_front(a)
#define pb(a) push_back(a)
#define INF 1998021900
#define MOD 1000000007
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  //input
  ll k,x;cin>>k>>x;
  cout<<x-k+1;
  for(ll i=x-k+2;i<k+x;i++){cout<<" "<<i;}
  cout<<endl;
  //caricurate
  //output
}


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

using namespace std;

int main()
{
	string s;
	getline(cin, s);

	for (int i = 0; i < s.length(); i++)
	{
		char c = s[i];

		if ('a' <= c && c <= 'z')
		{
			c &= 0xdf;
		}
		else if ('A' <= c && c <= 'Z')
		{
			c |= 0x20;
		}
		cout << c;
	}
	cout << endl;
}


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

#define MAX(p,q) ((p>q)?(p):(q))
#define MIN(p,q) ((p<q)?(p):(q))

#define INF 1000000000;
#define REP(i,n) for(i=0;i<n;i++)

int gcd(int a,int b);
/*比較函数の実装
int -32768 to 32767 (2**15-1)
long -2147483648 to 2147483648 (2**31-1)
*/
int intcmp(const void *a,const void *b){
  return *(int *)a - *(int *)b;
}
//qsort(a,sizeof(a)/sizeof(int),sizeof(int),intcmp);
int longcmp(const void *a,const void *b){
  return *(long *)a - *(long *)b;
}
//qsort(a,sizeof(a)/sizeof(long),sizeof(long),longcmp);
int doublecmp(const void *a, const void *b){
  return *(double *)a - *(double *)b;
}
//qsort(a,sizeof(a)/sizeof(double),sizeof(double),doublecmp);
int main(void)
{
  int x,a;
  scanf("%d%d",&x,&a);
  if(x<a)printf("0");
  else printf("10");
  return 0;
}

int gcd(int a,int b)
{
  int max,min,tmp;
  max = MAX(a,b);
  min = MIN(a,b);
  if(max%min==0) return min;
  else
  {
    tmp = min;
    min = max%min;
    max = tmp;
    return gcd(max,min);
  }
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<functional>
#include<vector>
#include<map>
#include<string>
#include<set>
#include<unordered_map>
#include<math.h>
#include<stack>
#include<deque>
using namespace std;

signed main() {
	int n; cin >> n;
	unordered_map<int, int>U;
	for (int i = 0; i < n; i++) {
		int a; cin >> a;
		U[a]++;
	}
	int ans = 0;
	for (auto i : U) {
		if (i.second & 1) {
			ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 4388
#include<iostream>
#include<algorithm>
using namespace std;
int n,m,p;
int t[10][10][10];

int A[10][10][10];
int B[10][10][10];
int C[10][10][10];

int D[10][10][10];
int E[10][10][10];
int F[10][10][10];
int G[10][10][10];
int H[10][10][10];
int I[10][10][10];

int J[10][10][10];
int K[10][10][10];
int L[10][10][10];
int M[10][10][10];


bool calc(int x,int y,int z){
  if(t[x][y][z]==-1)return false;
  int maxm=0;
  A[x][y][z]=1;
  B[x][y][z]=1;
  C[x][y][z]=1;
  D[x][y][z]=1;
  E[x][y][z]=1;
  F[x][y][z]=1;
  G[x][y][z]=1;
  H[x][y][z]=1;
  I[x][y][z]=1;
  J[x][y][z]=1;
  K[x][y][z]=1;
  L[x][y][z]=1;
  M[x][y][z]=1;
  
  if(t[x][y][z]==t[x-1][y][z]){
    maxm=max(maxm,A[x][y][z]=A[x-1][y][z]+1);
  }
  if(t[x][y][z]==t[x][y-1][z]){
    maxm=max(maxm,B[x][y][z]=B[x][y-1][z]+1);
  }
  if(t[x][y][z]==t[x][y][z-1]){
    maxm=max(maxm,C[x][y][z]=C[x][y][z-1]+1);
  }
  
  if(t[x][y][z]==t[x-1][y-1][z]){
    maxm=max(maxm,D[x][y][z]=D[x-1][y-1][z]+1);
  }
  if(t[x][y][z]==t[x+1][y-1][z]){
    maxm=max(maxm,E[x][y][z]=E[x+1][y-1][z]+1);
  }
  if(t[x][y][z]==t[x][y-1][z-1]){
    maxm=max(maxm,F[x][y][z]=F[x][y-1][z-1]+1);
  }
  if(t[x][y][z]==t[x][y+1][z-1]){
    maxm=max(maxm,G[x][y][z]=G[x][y+1][z-1]+1);
  }
  if(t[x][y][z]==t[x-1][y][z-1]){
    maxm=max(maxm,H[x][y][z]=H[x-1][y][z-1]+1);
  }
  if(t[x][y][z]==t[x+1][y][z-1]){
    maxm=max(maxm,I[x][y][z]=I[x+1][y][z-1]+1);
  }
  
  if(t[x][y][z]==t[x-1][y-1][z-1]){
    maxm=max(maxm,J[x][y][z]=J[x-1][y-1][z-1]+1);
  }
  if(t[x][y][z]==t[x-1][y+1][z-1]){
    maxm=max(maxm,K[x][y][z]=K[x-1][y+1][z-1]+1);
  }
  
  if(t[x][y][z]==t[x+1][y-1][z-1]){
    maxm=max(maxm,L[x][y][z]=L[x+1][y-1][z-1]+1);
  }
  
  if(t[x][y][z]==t[x+1][y+1][z-1]){
    maxm=max(maxm,M[x][y][z]=M[x+1][y+1][z-1]+1);

  }
  
  if(maxm==m){
    cout<<(t[x][y][z]?"White":"Black")<<" ";
    return true;
  }else{
    return false;
  }
}

bool check(){
  for(int i=1;i<9;i++)
    for(int j=1;j<9;j++)
      for(int k=1;k<9;k++)
	if(calc(k,j,i))return true;
  return false;
}

void init(){
  for(int i=0;i<10;i++)
    for(int j=0;j<10;j++)
      for(int k=0;k<10;k++)
	t[i][j][k]=-1;
  for(int x=0;x<10;x++)
    for(int y=0;y<10;y++)
      for(int z=0;z<10;z++){
        A[x][y][z]=0;
	B[x][y][z]=0;
	C[x][y][z]=0;
	D[x][y][z]=0;
	E[x][y][z]=0;
	F[x][y][z]=0;
	G[x][y][z]=0;
	H[x][y][z]=0;
	I[x][y][z]=0;
	J[x][y][z]=0;
	K[x][y][z]=0;
	L[x][y][z]=0;
	M[x][y][z]=0;
      }
}

void solve(){
  bool flg=false;
  for(int i=0;i<p;i++){
    int x,y;
    cin>>x>>y;
    if(flg)continue;
    for(int j=1;j<10;j++){
      if(t[x][y][j]==-1){
	t[x][y][j]=i%2;
	break;
      }
    }
    if(check()){
      flg=true;
      cout<<i+1<<endl;
      /*
      for(int z=1;z<=n;z++){
	for(int x=1;x<=n;x++){
	  for(int y=1;y<=n;y++){
	    printf("%3d",t[x][y][z]);
	  }
	  cout<<endl;
	}
	cout<<endl;
      }
*/
    }
  }
  if(!flg)cout<<"Draw"<<endl;
}

int main(){
  while(1){
    cin>>n>>m>>p;
    if(n==0&&m==0&&p==0)break;
    init();
    solve();
 
  }
  return 0;
}

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

int main(){
  int N,L;
  cin >> N >> L;
  vector<int> p(N);
  int goukei=0;
  
  for (int i=0;i<N;i++){
    p[i] = L+i-1+1;
    goukei +=p[i];
  }
  int ans = 1e9;
  for (int i=0;i<N;i++){
    int t = goukei - p[i];
    if(abs(t-goukei)<abs(ans-goukei))ans = t;
  }
  cout << ans << endl;
}
    
  
 
  


Measured memory_bytes: 256
import java.util.Random;
import java.util.Scanner;

public class Main {
	private static final int K = 26;
	private static final int TIME = 300;
	private static Random rand = new Random(System.currentTimeMillis());

	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		var d = sc.nextInt();
		var c = new int[K];
		var s = new int[d][K];
		for (var i = 0; i < K; i++) {
			c[i] = sc.nextInt();
		}
		for (var i = 0; i < d; i++) {
			for (var j = 0; j < K; j++) {
				s[i][j] = sc.nextInt();
			}
		}
		sc.close();

		var t = search(c, s, d);
		for (var i = 0; i < d; i++) {
			System.out.println(t[i]);
		}
	}

	private static int[] search(int[] c, int[][] s, int d) {
		var time = System.currentTimeMillis();
		var t = create(c, s, d);
		while (System.currentTimeMillis() - time <= TIME) {
			var mdi = rand.nextInt(d);
			var mti = rand.nextInt(K);
			var check = check(c, s, t, d, mdi, mti);
			if (border(time) < check) {
				t[mdi] = mti + 1;
			}

			var mdi1 = rand.nextInt(d);
			var mdi2 = rand.nextInt(d);
			var check1 = check(c, s, t, d, mdi1, t[mdi2] - 1);
			var tbk = t[mdi1];
			t[mdi1] = t[mdi2];
			var check2 = check(c, s, t, d, mdi2, tbk - 1);
			if (border(time) < check1 + check2) {
				t[mdi2] = tbk;
			} else {
				t[mdi1] = tbk;
			}
		}

		return t;
	}

	private static int border(long time) {
		return (int) (-300.0 * (1 - (double)(System.currentTimeMillis() - time) / TIME));
	}

	private static int check(int[] c, int[][] s, int[] t, int d, int mdi, int mti) {
		var sum = 0;
		var ti = t[mdi] - 1;
		sum += s[mdi][mti] - s[mdi][ti];

		var last1 = 0;
		var last2 = 0;
		for (var i = mdi - 1; i >= 0; i--) {
			if (t[i] == ti + 1) {
				last1 = i + 1;
				break;
			}
		}
		for (var i = mdi - 1; i >= 0; i--) {
			if (t[i] == mti + 1) {
				last2 = i + 1;
				break;
			}
		}

		var count1 = 1;
		var count2 = 1;
		for (var i = mdi + 1; i < d; i++) {
			if (t[i] == ti + 1) {
				break;
			}
			count1++;
		}
		for (var i = mdi + 1; i < d; i++) {
			if (t[i] == mti + 1) {
				break;
			}
			count2++;
		}
		sum += (mdi - last2 + 1) * c[mti] * count2 - (mdi - last1 + 1) * c[ti] * count1;

		return sum;
	}

	private static int[] create(int[] c, int[][] s, int d) {
		var t = new int[d];
		for (var i = 0; i < d; i++) {
			t[i] = rand.nextInt(K) + 1;
		}
		return t;
	}
}


Measured memory_bytes: 52744