akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int N;
string s;
int a,b,c,d,x,y;
int ans;

int main(){
	cin >> N;
	cin >> s;
	s += "0";
	d = -123456;
	repp(i,0,N+1){
		if(s[i] == '0'){
			if(y == 0){
				a = max(max(a,b),max(c,d));
				b = c = d = 0;
			} else {
				int p = 0;
				int q = c+x;
				int r = max(max(a,b),max(c,d));
				int s = r;
				if(x > 0) s = max(s,max(c,d)+y-1);
				if(x > 1) s = max(s,b+y-1);
				if(x > 0) q = max(q,b+x-1);
				if(x > 1) p = max(p,b+y);
				if(x > 0) p = max(p,max(c,d)+y);
				a = p , b = q , c = r , d = s;
			}
			x = y;
			y = 0;
			ans = max(ans , max(max(a,b),max(c,d)));
		} else {
			++y;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 900
import java.util.*;
import java.util.stream.IntStream;

public class Main {

    public static boolean found = false;

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

        int n = sc.nextInt();
        int k = sc.nextInt();

        long ans = k;

        for (int i = 0; i < n - 1; i++) {
            ans *= (k - 1);
        }
        System.out.println(ans);
    }

}

Measured memory_bytes: 21460
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()

	a := make([]int, n)
	b := make([]int, n)
	c := make([]int, n)
	d := make([]int, n)

	for i := 0; i < n; i++ {
		a[i] = scanInt()
		b[i] = scanInt()
	}

	for i := 0; i < n; i++ {
		c[i] = scanInt()
		d[i] = scanInt()
	}

	pair := make([][]int, n*2)
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if a[i] < c[j] && b[i] < d[j] {
				pair[i] = append(pair[i], n+j)
				pair[n+j] = append(pair[n+j], i)
			}
		}
	}

	ans,_ := bipartiteMatching(pair)

	fmt.Fprintln(wr, ans)
}

func bipartiteMatching(g [][]int) (int, []int) {
	used := make([]int, len(g))
	match := make([]int, len(g))
	for i := 0; i < len(g); i++ { match[i] = -1 }
	cnt := 0

	var fn func(v int) bool
	fn = func(v int) bool {
		used[v] = cnt
		for _, to := range g[v] {
			if match[to] == -1 || (used[match[to]]!=cnt && fn(match[to])) {
				match[v] = to
				match[to] = v
				return true
			}
		}
		return false
	}

	res := 0

	for i := 0; i < len(g); i++ {
		if match[i] == -1 {
			if fn(i) { res++ }
			cnt++
		}
	}

	return res, match
}


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

typedef long long ll;
const ll InF = 1e15;

int main() {
    string s;
    int k;
    cin>>s>>k;
    vector<string> v;
    for (int i = 1; i <= k; i++) {
        for (int j = 0; j < s.size() - i + 1; j++) {
            v.push_back(s.substr(j,i));
        } 
    }
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    printf("%s\n",v[k-1].c_str());
    return 0;
}

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

int main() {

	bool backFlg = false;
	int countY = 0;
	int inputX ;
	cin >> inputX;

	while (!backFlg) {

		countY++;
		if (countY * 360 % inputX == 0) {
			backFlg = true;
		}
		

		
	}
	
	cout << countY * 360 / inputX << endl;

}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

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

  int a, b;
  cin >> a >> b;
  if (a > b) swap(a, b);
  if (a == 1 && b == 2) cout << 3;
  else if (a == 1 && b == 3) cout << 2;
  else cout << 1;

  cout << endl;

  return 0;
}


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

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

    std::array<long long, 200005> v;
    for (int i = 0; i < n; ++i)
    {
        long long temp;
        std::cin >> temp;
        v[i] = temp;
    }

    long long count = 0;
    long long sum = v[0];
    long long temp = v[0];
    for (int i = 0, j = 1; i < n; i++)
    {
        while ((j < n) && (temp & v[j]) == 0)
        {
            temp ^= v[j++];
        }
        temp ^= v[i];
        count += j - i;
    }
    std::cout << count << std::endl;
    return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <cstring>
#define N 100010
using namespace std;
char str[N];
int main() {
	scanf("%s", str);
	int len = strlen(str);
	int ans = 0;
	for (int i = 1; i < len; ++i) {
		if (str[i] != str[i - 1]) ans++;
	}
	printf("%d\n", ans);
}

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

using namespace std;

typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli>> mat;

lli n;
vll p;
lli ans;

int main(){
  cin >> n;
  p = vll(n+1);
  for(lli i = 1;i <= n;i++) cin >> p[i];
  for(lli i = 1;i <= n;i++){
    if(p[i] == i) swap(p[i],p[i == n ? i-1 : i+1]),ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
import java.io.*;
import java.util.*;
 

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Unstoppable solver = new Unstoppable();
	//	int t=in.nextInt();
	//	while(t-->0)
        solver.solve(in, out);
        out.close();
    }
 
    static class Unstoppable {
        
     
        public void solve(InputReader in, PrintWriter out) {
         long n=in.nextLong();
         long k=in.nextLong();
         out.println(Math.min(n%k,k-n%k));
         
        }
    } 

 
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
 
        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }
 
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public long nextLong(){
            return Long.parseLong(next());
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
 
    }
}
 

Measured memory_bytes: 22740
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>

#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

using namespace std;

int gcd(int a,int b){
	while(1){
		if(a<b)swap(a,b);
		if(!b)break;
		a%=b;
	}
	return a;
}

int main(){
	int N;
	cin >> N;
	int A[N];
	int L[N+1];
	int R[N+1];
	int ans=1;
	rep(i,0,N){
		cin >> A[i];
	}
	L[0] = 0;
	R[N] = 0;
	rep(i,0,N){
		L[i+1] = gcd(L[i],A[i]);
	}
	rel(i,N,0){
		R[i] = gcd(R[i+1],A[i]);
	}
	rep(i,0,N){
		ans = max(ans,gcd(R[i+1],L[i]));
	}
	
	
	cout << ans << endl;

}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll=long long;  
using pLL = std::pair<ll, ll>;

#define SORT(v) std::sort(v.begin(), v.end())
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K;
    ll ans=LINF;
    cin >> N >> K;
    vector<ll> a(N);
    for(int i=0;i<N;++i){
        cin >> a[i];
    }
    SORT(a);
    for(size_t i=0;i<N-K+1;i++){
        ll temp=a[i+K-1]-a[i];
        ans=min(ans,temp);
    }
    cout << ans <<endl;
    return 0;
}

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

int main() {
  ll a, b, k;
  scanf("%ld%ld%ld", &a,&b,&k);
  if (a>k) {
    printf("%ld%*s%ld", a-k,1,"",b);
  }else if(b>(k-a)) {
    printf("%ld%*s%ld", 0,1,"",b-(k-a));
  }else {
    printf("%ld%*s%ld", 0,1,"",0);
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<lint> a(n);
    vector<int> op(n, 1);
    cin >> a[0];
    for (int i = 1; i < n; ++i) {
        char o;
        cin >> o >> a[i];
        if (o == '-')
            op[i] = -1;
    }
    vector<vector<lint>> dp(n + 1, vector<lint>(4, -inf));
    dp[0][0] = 0;
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j < 4; ++j) {
            if (op[i - 1] == 1) {
                for (int k = j; k < 4; ++k) {
                    chmax(dp[i][j], dp[i - 1][k] + a[i - 1] * (j % 2 == 0 ? 1 : -1));
                }
            } else if (op[i - 1] == -1) {
                if (j ==0)
                    continue;
                for (int k = max(0, j - 1); k < 4; ++k) {
                    chmax(dp[i][j], dp[i - 1][k] + a[i - 1] * (j % 2 == 0 ? 1 : -1));
                }
            }
        }
    }
    cout << *max_element(dp[n].begin(), dp[n].end()) << "\n";
    return 0;
}

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

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> cuisine(N);
    vector<int> sufficiently(N);
    vector<int> addition(N - 1);
    for(int i = 0; i < N; i++) cin >> cuisine.at(i);
    for(int i = 0; i < N; i++) cin >> sufficiently.at(i);
    for(int i = 0; i < N - 1; i++) cin >> addition.at(i);

    int sum = 0;
    for(int i = 0; i < N; i++){
        int ryori = cuisine.at(i); //i番目に食べた料理
        sum += sufficiently.at(ryori - 1);
        if(i < N - 1){
            if(cuisine.at(i) + 1 == cuisine.at(i + 1)){
                sum += addition.at(ryori - 1);
            }
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;

class Main {

    public static void main(String[] args) throws IOException {
        doit(args, System.in, System.out);
    }

    static void doit(String[] args, InputStream in, PrintStream out)
            throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        double maxHeight = Double.MIN_VALUE;
        double minHeight = Double.MAX_VALUE;
        while (true) {
            String line = reader.readLine();
            if (line == null || line.isEmpty()) {
                break;
            }
            double height = Double.parseDouble(line);
            if (height > maxHeight) {
                maxHeight = height;
            }
            if (height < minHeight) {
                minHeight = height;
            }
        }
        out.println(maxHeight - minHeight);
    }
}

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

int main() {
  int n;
  cin >> n;
  
  bool ans = false;
  for(int i=0; i<3; i++){
    int a=n/pow(10,i);
    int b=n/pow(10,i+1);
    if(a-b*10==7) ans = true;
  }
  
  if(ans==true) cout << "Yes";
  else cout << "No";
  
  return 0;
  
}


Measured memory_bytes: 4036
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import math
import numpy as np
import copy
from collections import defaultdict, Counter
from itertools import product
from bisect import bisect_left, bisect_right
def inpl(): return list(map(int, input().split()))

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

print(math.ceil((N-K)/(K-1))+1)



Measured memory_bytes: 23428
import bisect
N=int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort()
C.sort()
d=0
for i in B:
 d+=bisect.bisect_right(A,i-0.1)*(N-bisect.bisect_left(C,i+0.1))
print(d)


Measured memory_bytes: 23360
#include <bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define PII pair<int,int>
#define ls x<<1
#define rs x<<1|1
#define fi first
#define se second
#define pb push_back
#define cwk freopen("D:\\c++\\in.txt","r",stdin),freopen("D:\\c++\\out.txt","w",stdout)
using namespace std;
const int N=1e6+10;
int ans[N];
int n;
int main()
{
	//cwk;
	scanf("%d",&n);
	for(int i=1;i<n;i++) {
		int x;
		scanf("%d",&x);
		ans[x]++;
	}
	for(int i=1;i<=n;i++) {
		printf("%d\n",ans[i]);
	}
	return 0;
}

Measured memory_bytes: 4540
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1<<30
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define RREP(i,a,b) for(ll i=(a); i>=(b); i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> p;
typedef vector<pair<ll, ll>> vpl;


int main(){
    ll q; cin >> q;
    ll dp[1005][1005];
    rep(i,q){
        string a,b; cin >> a >> b;
        ll m = a.size();
        ll n = b.size();
        a = ' ' + a;
        b = ' ' + b;
        rep(i,m+1) dp[i][0] = 0;
        rep(i,n+1) dp[0][i] = 0;
        REP(i,1,m+1){
            REP(j,1,n+1){
                if(a[i] == b[j]){
                    dp[i][j] = dp[i-1][j-1] + 1;
                }else{
                    dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
                }
            }
        }
        cout << dp[m][n] << "\n";
    }
}


Measured memory_bytes: 10988
#include  <iostream>
#include  <stdio.h>
using namespace std;




int main(){

    int N;
    string S;
    cin >> N;
    cin >> S;

    string tmp;
    int ni;

    ni = N - 1;
    tmp = S.substr(ni,1);
    int length;
    
    if(tmp == "#"){
        while(tmp == "#"){
            ni = ni - 1;
            if(ni >= 0){
                tmp = S.substr(ni,1);
            }else{
                tmp = "";
            }
        }
    }

    if(ni < 0){
        // all black
        cout << 0;
    }else{
        int ne;
        ne = 0;
        tmp = S.substr(ne,1);
        while(tmp == "."){
            ne = ne + 1;
            if(ne <= ni){
                tmp = S.substr(ne,1);
            }else{
                tmp = "";
            }
        }

        if(ne >= ni){
            //all white or white black
            cout << 0;
        }else{

            length = ni + 1 - ( ne + 1 ) + 1 ;
            int count_bk[N];
            int count_wh[N];
            tmp = S.substr(ne,1);
            if(tmp=="#"){
                count_bk[ne]=1;
                count_wh[ne]=0;
            }else{
                count_bk[ne]=0;
                count_wh[ne]=1;
            } 
            for( int nni = ne + 1 ; nni <= ni ; nni++ ){
                tmp = S.substr(nni,1);
                if(tmp=="#"){
                    count_bk[nni]=count_bk[nni-1] + 1;
                    count_wh[nni]=count_wh[nni-1];
                }else{
                    count_bk[nni]=count_bk[nni-1];
                    count_wh[nni]=count_wh[nni-1] + 1;
                } 
            }
            int min;
            int count;
            //cout << ne << ":" << ni << endl;
            min = count_wh[ni];
            for( int nni = ne; nni <= ni ; nni++ ){
                count = count_bk[nni] + ( count_wh[ni] - count_wh[nni]);
                //cout << count << endl;
                if(min > count){
                    min = count;
                }
            }
            cout << min;
            
        }
    }
}

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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define bit(n) (1LL<<(n))
#define sz(x) ((int)(x).size())
#define fst first
#define snd second
using ll=long long;using pii=pair<int,int>;using vb=vector<bool>;
using vi=vector<int>;using vvi=vector<vi>;using vvvi=vector<vvi>;
using vl=vector<ll>;using vvl=vector<vl>;using vvvl=vector<vvl>;
using vd=vector<double>;using vvd=vector<vd>;using vvvd=vector<vvd>;
using vpii=vector<pii>;using vvpii=vector<vpii>;using vvvpii=vector<vvpii>;
template <typename T> T read() {T t; cin >> t; return t;}

void Main() {
  string s = read<string>();
  int c = -1, f = -1;
  rep(i, sz(s)) {
    char ch = s[i];
    if (ch == 'C' && c == -1) c = i;
    if (ch == 'F') f = i;
  }

  if (c != -1 && f != -1 && c < f) {
    puts("Yes");
  }
  else puts("No");
}
int main() { cin.tie(nullptr); ios::sync_with_stdio(false); Main(); return 0; }


Measured memory_bytes: 384
let main: () = {
    let (N, M) = *listOfInt()
    var s = Array(N + 2) { $0 - 1 }
    s[0] = 0
    for n in 1 ... N + 1 { s[n] += s[n - 1] }
    var ans = 0
    for n in M ... N + 1 {
        let min = s[n] - s.first!
        let max = s.last! - s[N - n + 1]
        ans += max - min + 1
        ans %= 1000000007
    }
    print(ans)
}()

@inlinable func next() -> String { readLine()! }
@inlinable func nextInt() -> Int { Int(next())! }
@inlinable func listOfString() -> [String] { next().split(separator: " ").map(String.init) }
@inlinable func listOfInt() -> [Int] { listOfString().map { Int($0)! } }
extension Array {
    init(_ size: Int, _ initValue: ((Int) -> Element)) {
        self = [Element]()
        for index in 0 ..< size {
            let value = initValue(index)
            self.append(value)
        }
    }
}

prefix operator *
prefix func * <T> (a: [T]) -> (T, T) { (a[0], a[1]) }


Measured memory_bytes: 9320
import numpy as np

n, m, x = map(int, input().split())
a = []
c = []
for _ in range(n):
    i = [int(j) for j in input().split()]
    c.append(i[0])
    a.append(i[1:])


c = np.array(c)
a = np.array(a)


def cost(buy):
    return np.dot(buy, c)


def learnable(buy):
    return np.min(np.dot(buy, a)) >= x


answer = False, 10 ** 8
for bit in range(2 ** n):
    buy = np.array([int(i) for i in bin(bit)[2:].zfill(n)])
    if learnable(buy):
        answer = True, min(answer[1], cost(buy))


if answer[0]:
    print(answer[1])
else:
    print(-1)


Measured memory_bytes: 27312
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>

using namespace std;

int main()
{
	int n;
	cin >> n;
	int lt = 0, lx = 0, ly = 0;

	bool can = true;

	for (int i = 1; i <= n; i++)
	{
		int t, x, y;
		cin >> t >> x >> y;
		int k = abs(x - lx) + abs(y - ly);
		if (t - lt >= k && (t - lt) % 2 == k % 2)
			lt = t, lx = x, ly = y;
		else
		{
			can = false;
			break;
		}
	}

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

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define MOD ((ll)1000000007)

int main(int argc, char const *argv[])
{
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	int H, W;
	cin >> H >> W;
	vector<vector<char>> s(H, vector<char>(W));
	int total_white = 0;
	for (size_t i = 0; i < H; i++)
	{
		for (size_t j = 0; j < W; j++)
		{
			cin >> s[i][j];
			if (s[i][j] == '.')
			{
				total_white++;
			}
		}
	}

	vector<vector<int>> d_min(H, vector<int>(W, -1));
	queue<tuple<int, int, int>> q;
	q.push(make_tuple(0, 0, 0));

	while (!q.empty())
	{
		auto t = q.front();
		q.pop();

		auto i = get<0>(t);
		auto j = get<1>(t);
		auto d = get<2>(t);
		if (i < 0 || i > H - 1 || j < 0 || j > W - 1)
		{
			continue;
		}
		if (s[i][j] == '#')
		{
			continue;
		}
		if (d_min[i][j] != -1)
		{
			continue;
		}

		d_min[i][j] = d;
		q.push(make_tuple(i - 1, j, d + 1));
		q.push(make_tuple(i + 1, j, d + 1));
		q.push(make_tuple(i, j - 1, d + 1));
		q.push(make_tuple(i, j + 1, d + 1));
	}

	if (d_min[H - 1][W - 1] == -1)
	{
		cout << -1 << endl;
	}
	else
	{
		int min_white = d_min[H - 1][W - 1] + 1;
		int ans = total_white - min_white;
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 256
def input_n
  gets.to_i               # 単一整数
end

def input_s
  gets.chomp              # 文字列。chompを付けないと改行文字がついてくる
end

def input_a
  gets.split.map(&:to_i)  # スペースで区切られた複数の整数
end

def input_o(num)
  num.times.map { gets.to_i }  # 縦に並んだ複数の整数。たまにある
end

def output_f(num)
  puts sprintf("%.12f", num)
end

n, x, y  = input_a
dist = Array.new(n, 0)

(1..n).each do |i|
  ((i+1)..n).each do |j|
    d = [(i - j).abs, (i - x).abs + (j - y).abs + 1, (i - y).abs + (j - x).abs + 1].min
    dist[d] += 1
  end
end
dist.shift
dist.each do |k|
  puts k
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define MAX_N 2000
#define P 1000000007
using namespace std;
template <class T> inline void read(T &x) {
	x = 0; int c = getchar(), f = 1;
	for (; !isdigit(c); c = getchar()) if (c == 45) f = -1;
	for (; isdigit(c); c = getchar()) (x *= 10) += f*(c-'0');
}
int n, m, f[2][MAX_N+5];
int main() {
	read(n), read(m);
	for (int i = 1; i <= n+1; i++) f[0][i] = 1;
	for (int i = 1, c = 1; i < m; i++, c ^= 1) {
		memset(f[c], 0, sizeof f[c]);
		for (int j = 1; j <= n-i+1; j++) f[c][j] = f[c^1][j];
		for (int j = n; j; j--) f[c][j] = (f[c][j]+f[c][j+1])%P;
	}
	int ans = f[(m-1)&1][2];
	for (int i = 1; i <= n-m-1; i++)
		ans = (ans<<1)%P;
	return printf("%d\n", ans), 0;
}

Measured memory_bytes: 256
ht, st, ha, sa = list(map(int, input().split(' ')))
bool_player = True  # Takashi
while (ht > 0 and ha > 0):
    if bool_player:
        ha -= st
        bool_player = False
    else:
        ht -= sa
        bool_player = True

if ht <= 0:
    print('No')
else:
    print('Yes')


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

int main(){
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    vector<LL> a(x), b(y), c(z);
    for(int i = 0;i < x;i++)    cin >> a[i];
    for(int i = 0;i < y;i++)    cin >> b[i];
    for(int i = 0;i < z;i++)    cin >> c[i];
    vector<LL> ab;
    for(auto s : a) for(auto t : b) ab.push_back(s+t);
    sort(ab.rbegin(), ab.rend());
    vector<LL> abk(k), abc;
    copy(ab.begin(), ab.begin()+min(k, (int)ab.size()), abk.begin());
    for(auto s : abk)   for(auto t : c) abc.push_back(s+t);
    sort(abc.rbegin(), abc.rend());
    for(int i = 0;i < k;i++)    cout << abc[i] << endl;
}

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

int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    string result;
    if(a == b)result = "Draw";
    else if(a == 1)result = "Alice";
    else if(b == 1)result = "Bob";
    else if(a > b)result = "Alice";
    else result = "Bob";

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
using P = pair<long, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

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

const int mod = 1000000007;

vector<bool> isPrime;
vector<int> yks[5];

void sieve(long max){
    if(max+1 > isPrime.size()){ 
        isPrime.resize(max+1, true);
    } 
    isPrime[0] = false;
    isPrime[1] = false;

    for(long i=2; i*i<=max; ++i) 
        if(isPrime[i]) 
            for(long j=2; i*j<=max; ++j) 
                isPrime[i*j] = false;  
}

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

  int n;
  cin >> n;

  sieve(55555);

  for(int i = 2; i <= 55555; i++) {
    if(isPrime[i]) {
      yks[i%5].push_back(i);
    }
  }

  rep(i, n) {
    cout << yks[1][i] << endl;
  }
}


Measured memory_bytes: 632
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define rep(i,n) for (int i=0;i<(n);++i)
#define rep2(i,a,b) for (int i=(a);i<(b);++i)
#define rrep(i,n) for (int i=(n)-1;i>=0;--i)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;--i)
#define range(i,a,b,c) for (int i=a;((c>0)?i<b:i>b);i+=c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define ALL(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif

int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 1 << 28;
const ll INFL = (ll)1 << 58;
ll mod = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real& r) { return (r > eps) - (r < -eps); }
int sgn(const Real& a, const Real &b) { return sgn(a - b); }

//.....................
const int MAX = (int)2e5 + 5;

ll N;
string str;

void solve() {
  cin >> N >> str;
  int x = 0;
  int res = 0;
  rep(i, str.size()) {
	char c = str[i];
	if (c == 'I') x++;
	if (c == 'D') x--;
	chmax(res, x);
  }
  cout << res << endl;
}

int main() {
  int T = 10;
  rep(i, T) {
  	char s[MAX];
  	if (scanf("%s", s) == EOF) break;
  	rrep(i, strlen(s)) {
  	  ungetc(s[i], stdin);
  	}
  	solve();
  }
  return 0;
}


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

int main(){
  int N;
  cin >> N;
  char S[300005];

  rep(i,N){
    cin >> S[i];
  }

  //i番目より以前にいる西向きの人々
  long int west[300005] = {};

  west[0] = 0;
  REP(i,N){
    if (S[i-1] == 'W') {
      west[i] += west[i-1]+1;
    }else{
      west[i] += west[i-1];
    }
  }

  //i番目の人がリーダーになったときに方向を変える人の数
  int ans[300005] = {};

  ll min = 10000000000;

  rep(i,N){
    ans[i] = N - i - 1 - west[N] + west[i+1] + west[i];
    if (min > ans[i]) {
      min = ans[i];
    }
  }

  cout << min << endl;


}


Measured memory_bytes: 2944
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
int main() {
    ll a;
    cin >> a;
    cout << (a-2)*180 << endl;
    return 0;
}


Measured memory_bytes: 256
N,D=gets.chomp.split(" ").map(&:to_i)

c = 0
for i in 1..N do
  a,b=gets.chomp.split(" ").map(&:to_i)
  if (a ** 2 + b ** 2) ** (1/2.0) <= D
    c += 1 
  end
end

puts c

Measured memory_bytes: 14968
if __name__ == '__main__':
    s1 = []
    s2 = []

    data = input()
    total_sum = 0
    for i in range(len(data)):
        if data[i] == '\\':
            s1.append(i)
        elif data[i] == '/' and len(s1) > 0:
            j = s1.pop()
            a = i - j
            total_sum += a

            while (len(s2) and s2[-1][0] > j):
                temp = s2.pop()
                a += temp[1]
            s2.append([j, a])

    print(total_sum)
    length = len(s2)
    if not length:
        print(length)
    else:
        print(length, end=' ')
    for i in range(0, length):
        endl = ' '
        if i == length - 1:
            endl = '\n'
        print(s2[i][1], end=endl)




Measured memory_bytes: 6512
#include <bits/stdc++.h>
#define inf 111111111
using namespace std;

int main()
{
    char s[101], x[101];
    cin >> s;
    for (int i = 0; i < 100; ++i) x[i] = 'x';
    strncpy(s, x, strlen(s));
    cout << s;
    return 0;
}


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

int main(){
    string str;
    cin >> str;
    reverse(str.begin(), str.end());
    int i = 0;
    bool flag = true;
    while(i < str.size()){
        string sub = str.substr(i, 5);
        string sub2 = str.substr(i, 6);
        string sub3 = str.substr(i, 7);
        if(sub == "esare" || sub == "maerd"){
            i += 5;
        } else if(sub2 == "resare"){
            i += 6;
        } else if(sub3 == "remaerd"){
            i += 7;
        } else {
            flag = false;
            break;
        }
    }
    printf(flag ? "YES\n" : "NO\n");
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define mset(arr, val) memset(arr, val, sizeof(arr))
#define ll long long
#define endl "\n"
using namespace std;
// const double PI = acos(-1.0);
// const double E = exp(1.0);
// const double EPS = 1e-9;
const int MOD = (int)1e9 + 7;
const int N = (int)1e5;

int main()
{
#ifdef MY_PREPROCESSOR
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int k;
    cin >> k;
    while (k-- > 0)
    {
        cout<< "ACL";
    }
    
    return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>

int main(void){
  int N,i;
  long long int p = 1;
  scanf("%d",&N);
   
  for(i=1; i <= N;i++){
    p = p * i;
    p = p % 1000000007;
    }
    
   printf("%lld\n",p);

  return 0;
    
 }

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

using namespace std;
typedef long long ll;
#define FOR(i,n) for(int i=0; i<int(n); i++)
#define FOR1(i,m,n) for(int i=int(m); i<int(n); i++)

const int MAXN=1e5;
const int MAXA=1e9;
int n;
ll count[2], sum[2];

int main(int argc, char *argv[])
{
    int a, sign=1;
    scanf("%d", &n);
    FOR(i,n) {
        cin >> a;
        sum[0] += a;
        sum[1] -= a;
        FOR(j,2) {
            if (sign * sum[j] <= 0) {
                ::count[j] += 1 - sign * sum[j];
                sum[j] = sign;
            }
        }
        sign *= -1;
    }

    printf("%lld\n", min(::count[0], ::count[1]));
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define lli long long int
#define llu long long unsigned int
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FOR(i,s,e) for(i=s; i<e; i++)
#define mod 1000000007
#define F first
#define S second
#define plli pair<lli,lli>
#define pqlli priority_queue<lli>
#define test(t) cin>>t; while(t--)
using namespace std;

lli power(lli a, lli b, lli M = mod)
{
	lli result = 1;
    for (;;)
    {
        if (b & 1)
            result = (result*a)%M;
        b >>= 1;
        if (!b)
            break;
        a = (a*a)%M;
    }
    return result;
}
map<lli,lli> dis;

void bfs(vector<vector<lli> > &g, lli start, lli n)
{
	queue<plli> q;
	q.push(mp(start, 0));
	int mark[n+1];
	memset(mark, 0, sizeof(mark));
	mark[start] = 1;
	while(!q.empty())
	{
		lli temp = q.front().first;
		lli c = q.front().second;
		q.pop();
		for(auto i : g[temp])
		if(mark[i] == 0)
		q.push(mp(i, c+1)), dis[c+1]++, mark[i] = 1;
	}
}

int main()
{
	IOS;
	lli k,n;
	cin>>k>>n;

	lli a[n];
	for(lli i = 0; i<n; i++)
	cin>>a[i];

	lli temp = k - a[n-1] + a[0];
	for(lli i = 0; i<n-1; i++)
	temp = max(temp, a[i+1] - a[i]);
	cout<<k-temp<<endl;
}


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

typedef long long int lli;
lli h, w, n, a, b;
set<pair<lli, lli>> st;
lli answers[10];

//Returns how many marked squares there are in rows r-1 to r+1 intersection columns c-1 to c+1
int checkGrid(lli r, lli c) {
	int retVal = 0;
	for(int i = r-1; i <= r+1; i++) for(int j=c-1; j<=c+1; j++) if(st.find(make_pair(i, j)) != st.end()) retVal++;
	return retVal;
}

int main() {
	ios_base::sync_with_stdio(false);

	cin >> h >> w >> n;
	for(int i = 0; i<10; i++) answers[i]=0;
	answers[0] = (h-2)*(w-2);	

	for(int i = 0; i < n ; i++) {
		cin >> a >> b;
		a--; b--;
		for(int j=a-1; j<=a+1; j++) {
			if(j<=0 || j>=h-1) continue;
			for(int k=b-1; k<=b+1; k++) {
				if(k<=0 || k>=w-1) continue;
				int oldVal = checkGrid(j, k);
				answers[oldVal]--;
				answers[oldVal+1]++;
			}
		}
		st.insert(make_pair(a, b));
	}

	for(int i=0; i<10; i++) cout << answers[i] << endl;

	return 0;
}

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

int n,k;
vector<int> p(200001);

int main(){
  cin >> n >> k;
  for(int i=0;i<n;i++){
    cin >> p[i];
  }
  double ss=0;
  int left=0;
  int right=k;
  int max_left=left;
  int max_right=right;
  for(int i=0;i<right;i++){
    ss+=((double)p[i]+1)/2.0;
  }
  double tmp_ss=0;
  tmp_ss=ss;
  for(int i=0;i<n-k;i++){
    tmp_ss-=((double)p[i]+1)/2.0;
    tmp_ss+=((double)p[i+k]+1)/2.0;
    if(tmp_ss>ss){
      ss=tmp_ss;
      max_left=i+1;
      max_right=i+k+1;
    }
  }
  double ans=0.0;
  for(int i=0;i<k;i++){
    double ex=(double)p[i+max_left]+1;
    ex=ex/2.0;
    ans+=ex;
  }
  cout << fixed<<setprecision(40)<<ans << endl;
  return 0;
}

Measured memory_bytes: 1024
s = list(input())

count = len(s) - 1
ans = 0

while count > 0:
    # print(
    #     "s[0 : count // 2] ,s[count // 2 :]", s[0 : count // 2], s[count // 2 : count]
    # )
    if count % 2 == 0:
        if s[0 : count // 2] == s[count // 2 : count]:
            ans = max(ans, count)
    count -= 1

print(ans)


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

using namespace std;

int main(){
    cout<<fixed<<setprecision(11);
    int n;
    cin>>n;
    double p[n];
    for(int i=0;i<n;i++)
        cin>>p[i];
    double a[n+1][n+1];
    a[0][0]=1;
    for(int i=1;i<=n;i++){
        a[0][i]=a[0][i-1]*p[i-1];
        a[i][0]=a[i-1][0]*(1-p[i-1]);
    }
    int i,j;
    for(int k=1;k<n;k++){
        for(i=k,j=1;i>0;i--,j++){
            a[i][j]=p[k]*a[i][j-1]+a[i-1][j]*(1-p[k]);
        }
    }
    double sum = 0;
    for(i=n;i>n/2;i--)
        sum+=a[n-i][i];
            //cout<<a[n-i][i]<<endl;}
   
    cout<<sum<<endl;
}

Measured memory_bytes: 70528
N, K = map(int, raw_input().split())
R0, R1 = range(K), range(K + 1)
D = [[0] * (K + 1) for i in R1]
a = b = 0

for i in range(N):
    x, y, c = raw_input().split()
    x, y, c = int(x), int(y), c == 'W'
    p = (x / K + y / K + c) % 2
    D[y % K + 1][x % K + 1] += 1 - 2 * p
    b += p

for i in R0:
    for j in R1:
        D[i + 1][j] += D[i][j]

for i in R1:
    for j in R0:
        D[i][j + 1] += D[i][j]

for i in R1:
    for j in R1:
        S = D[i][K] + D[K][j] - D[i][j] * 2
        a = max(a, S, D[K][K] - S)

print a + b

Measured memory_bytes: 23024
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{

    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int A = int.Parse(s[0]);
            int B = int.Parse(s[1]);

            int ans = Math.Abs(A - B);

            if ( ans % 2 != 0)
            {
                Console.WriteLine("IMPOSSIBLE");
                return;
            }

            ans /= 2;

            if ( A > B)
            {
                Console.WriteLine(Math.Abs(B + ans));
            }
            else
            {
                Console.WriteLine(Math.Abs(A + ans));
            }
        }
    }
}


Measured memory_bytes: 11220
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#endif

using namespace std;


typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()) {
  v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t) {
  stringstream ss;
  ss << f;
  ss >> t;
}


#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb push_back


#define MOD 1000000007LL
#define EPS 1e-8

int main() {
  int n, k, x, y;
  cin >> n >> k >> x >> y;
  if (n > k) {
    cout << k*x + (n - k)*y << endl;
  } else {
    cout << n*x << endl;
  }
  return 0;
}

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

void PRINT(int* A,int Len){
    for(int i = 0;i<Len-1;i++){
        printf("%d ",A[i]);
    }
    printf("%d\n",A[Len-1]);
    return;
}


void insertionSort(int* A,int Len){
    for(int i = 1;i<Len;i++){
        int buff = A[i];
        int j = i-1;

        PRINT(A,Len);
        
        while(0 <= j && buff < A[j]){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = buff;
    }
}

int main(){
    
    int Len;
    scanf("%d",&Len);
    int Num[Len];

    for(int i = 0;i<Len;i++){
        scanf("%d",&Num[i]);
    }


    insertionSort(Num,Len);
    PRINT(Num,Len);


    return 0;
}



Measured memory_bytes: 2716
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  int A, B, X;
  cin >> A >> B >> X;
  if (A<=X && X<=A+B) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 3584
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int result = k;
    for (int i = 1; i < n; i++) {
      result *= k - 1;
    }
    System.out.println(result);
  }
}


Measured memory_bytes: 21716
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*
import kotlin.math.abs
import kotlin.math.min

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val (n, c) = readIntegerList()
    val group = Array(n) {
        val (s, t, c) = readIntegerList()
        Triple(s, t, c)
    }.groupBy { it.third }

    val imos = LongArray(100001 * 2)
    for (v in group.values) {
        val tmp = v.sortedWith(compareBy { it.first })
        var currnet = tmp[0]
        imos[currnet.first * 2 - 1]++
        imos[currnet.second * 2]--
        for (t in tmp.drop(1)) {
            if (currnet.second != t.first) {
                imos[t.first * 2 - 1]++
                imos[t.second * 2]--
            } else {
                imos[currnet.second * 2]++
                imos[t.second * 2]--
            }

            currnet = t
        }
    }

    val sums = LongArray(100001 * 2 + 1)
    for (i in 0 until 100001 * 2) {
        sums[i + 1] = sums[i] + imos[i]
    }

    val ans = sums.max()
    out.println(ans)
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 71048
n, k = map(int, input().split())
s = list(input().strip())
count = 0
for i in range(len(s)):
    if (i == 0 and s[i] == 'L') or (i == len(s) - 1 and s[i] == 'R'):
        pass
    elif (s[i] == 'R' and s[i + 1] == 'R') or (s[i] == 'L' and s[i - 1] == 'L'):
        count += 1

count = min(count+(k*2), n-1)

print(count)


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

struct RQ {
 using RQV = LL;
 using RQRV = LL;
 static RQV Zero(){ return 0; }
 static RQRV RZero(){ return 0; }
 // addition
 static RQV f(RQV a,RQV b){ return a+b; }
 // update function
 static void uf(RQV& a,RQV b){ a += b; }
 // effect of range queries n-sized
 static void ef(RQV& a,RQRV b,int n){ a+=b*n; }
 // range query update
 static void ruf(RQRV& a,RQRV b){ a += b; }
 struct Node{
  RQV v; RQRV r;
 };
 int N;
 vector<Node> V;

 void init(int n){
  N=1; while (N<n) N*=2;
  V.assign(N*2,{Zero(),RZero()});
 }

 void spread(int i,int z){
  if (z!=1) {
   ef(V[i*2].v,V[i].r,z/2);
   ruf(V[i*2].r,V[i].r);
   ef(V[i*2+1].v,V[i].r,z/2);
   ruf(V[i*2+1].r,V[i].r);
  }
  V[i].r = RZero();
 }

 void upd(int p,RQV v){
  for(int d=N; d>=1; d/=2) spread(p/d,d);
  p+=N; uf(V[p].v,v);
  int z=1;
  while(p!=1){
   p/=2; z*=2;
   V[p].v = f(V[p*2].v,V[p*2+1].v);
   ef(V[p].v,V[p].r,z);
  }
 }

 void updr(int l,int r,RQRV v,int a=0,int b=0,int i=-1){
  if(i==-1){ a=0; b=N; i=1; }
  spread(i,b-a);
  if(r<=a || b<=l) return;
  if(l<=a && b<=r){
   ruf(V[i].r,v);
   ef(V[i].v,V[i].r,b-a);
   return;
  }
  updr(l,r,v,a,(a+b)/2,i*2);
  updr(l,r,v,(a+b)/2,b,i*2+1);
  V[i].v = f(V[i*2].v,V[i*2+1].v);
  ef(V[i].v,V[i].r,b-a);
 }

 RQV query(int l,int r,int a=0,int b=0,int i=-1){
  if(i==-1){ a=0; b=N; i=1; }
  if(r<=a || b<=l) return Zero();
  if(l<=a && b<=r) return V[i].v;
  RQV q1 = query(l,r,a,(a+b)/ 2,i*2);
  RQV q2 = query(l,r,(a+b)/2,b,i*2+1);
  q1 = f(q1,q2);
  ef(q1,V[i].r,min(r,b)-max(l,a));
  return q1;
 }
};

int N,Q;
RQ G;

int main(){
 scanf("%d%d",&N,&Q);
 G.init(N);
 rep(i,N){
  int a; scanf("%d",&a);
  G.upd(i,a);
 }
 rep(q,Q){
  int c; scanf("%d",&c);
  if(c==0){
   int p,x; scanf("%d%d",&p,&x);
   G.upd(p,x);
  }
  if(c==1){
   int l,r; scanf("%d%d",&l,&r);
   printf("%lld\n",G.query(l,r));
  }
 }
 
 return 0;
}


Measured memory_bytes: 20720
import sys

N = int(input())
A = list(map(int, sys.stdin.readline().rsplit()))
A.sort(reverse=True)

res = A[0]
cnt = 1
for i in range(1, N):
    cnt += 2
    res += 2 * A[i]
    if cnt == N + 1:
        res -= 2 * A[i]
        break
    elif cnt == N:
        res -= A[i]
        break
    elif cnt == N - 1:
        break

print(res)


Measured memory_bytes: 92024
import java.io.*;
import java.util.*;

class Main{
  public static void main(String[] args)throws java.lang.Exception {
    Scanner sc = new Scanner(System.in);
        while(true) {
            int H = sc.nextInt(), W = sc.nextInt();
            if(H == 0 && W == 0) break;
            for(int i = 0; i < H; i++) {
                for(int j = 0; j < W; j++) {
                    System.out.print("#");
                }
                System.out.println();
            }
            System.out.println();
        }
  }
}


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

using namespace std;

#define pb push_back
#define prr pair<int,int> 
#define int long long
#define fir first
#define sec second
#define double long double
#define ll long long



int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int a,b,c,k;
    cin>>a>>b>>c>>k;

    int s1=0;
    int ans=0;
    s1+=a;
    ans+=a;
    if(s1>=k){
        cout<<k;
        return 0;
    }

    s1+=b;
    if(s1>=k){
        cout<<a;
        return 0;
    }
    int d1=k-s1;
    ans=ans-d1;
    cout<<ans;
    


    // if(s.length()>=1 && s.length()<=10){
    //     if(t.length()==s.length()+1){
    //         cout<<"Yes";
    //     }else{
    //         cout<<"No";
    //     }

    // }else{
    //     cout<<"No";
    // }
}



Measured memory_bytes: 3652