akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int p = sc.nextInt();
		int before = 0;
		long dai = 0;
		for (int i = 0; i < p; i++) {
			int height = sc.nextInt();
			if(before > height) {
				dai+=before - height;
			}else {
				before = height;
			}
		}
		System.out.println(dai);
	}
}

Measured memory_bytes: 58528
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <cctype>
#define rep(x,y,z) for(long long x=y;x<z;++x)
#define dwn(x,y,z) for(long long x=y;x>z;--x)
using namespace std;

typedef long long ll;

int main() {
    ll n;
    cin >> n;
    if (n == 1) {
        cout << "Hello World" << endl;
    } else {
        ll a, b;
        cin >> a >> b;
        cout << a + b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <math.h>
using namespace std;

int main()
{
	long long N;
	cin >> N;

	map<long long, int> m;
	for (long long i = 2; i*i<=N; i+=1)
	{
		while (N%i == 0)
		{
			if (m.count(i) == 0) m.insert(make_pair(i, 1));
			else ++m[i];
			N /= i ;
		}
	}
	if (N != 1 && m.count(N) == 0) m.insert(make_pair(N, 1));

	int cnt = 0;
	for (auto x : m)
	{
		int d = 1;
		while(x.second - d >= 0)
		{
			x.second -= d;
			++d;
			++cnt;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 3540
#約数
def make_divisors(n): #約数をリストで返す
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

#素因数分解
def soinsu_bunkai(m):
    pf={}

    for i in range(2,int(m**0.5)+1):
        while m%i==0:
            pf[i]=pf.get(i,0)+1
            m//=i
    if m>1:
        pf[m]=1
    return pf

# 初期入力
import sys
input = sys.stdin.readline
N = int(input())
div =make_divisors(N)
div.sort()
div_2 =div[1:]

count =0
for i in div_2:
    i2 = soinsu_bunkai(i)
    if len(i2) ==1:
        q,mod =divmod(N,i)
        if mod ==0:
            count +=1
            N =q
print(count)

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

typedef vector<int> vi;
typedef set<int> si;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define onesNumber(x) builtin_popcount(x) //builtin_popcount(ll)
#define testCases int t; cin >> t; while(t--)
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) (x * y / gcd(x, y))
const double PI = acos(-1.0);
const int N = 1e3 + 6;
const int MD = 1e5 * 4;

void solve(){

}

int main()
{
    //ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //testCases
        //solve();
    int n;
    cin >> n;
    int a[10000];
    a[0] = 1000;
    if(a[0] >= n)
        return cout << a[0] - n,0;
    FOR(i, 1, 9999){
        a[i] = a[i - 1] + 1000;
        if(a[i] >= n){
            cout << a[i] - n;
            break;
        }
    }



    return 0;
}


Measured memory_bytes: 3652
/*                    */
#include <bits/stdc++.h>
using namespace std;
using lint = int64_t;
namespace my {
char itoc(int i) { return i + '0'; }
int ctoi(char c) { return c - '0'; }
lint gcd(lint a, lint b) {
  a = abs(a);
  b = abs(b);
  if (a < b) swap(a, b);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
lint lcm(lint a, lint b) { return a * b / my::gcd(a, b); }
}  // namespace my
/*                    */

int main() {
  lint x;
  cin >> x;
  for (lint b = 0; b < (lint)pow(2, 62); b++) {
    lint uhen = x + pow(b, 5);
    for (lint a = 0; (lint)pow(a, 5) <= uhen; a++) {
      if ((lint)pow(a, 5) == uhen) {
        cout << a << " " << b << endl;
        // cout << 1 << endl;
        return 0;
      }
    }
    b = -b;
    uhen = x + pow(b, 5);
    for (lint a = 0; (lint)pow(a, 5) <= uhen; a++) {
      if ((lint)pow(a, 5) == uhen) {
        cout << a << " " << b << endl;
        // cout << 2 << endl;
        return 0;
      }
    }
    b = -b;
  }
}

Measured memory_bytes: 4032
package main

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

type span struct {
	val   byte
	start int
	end   int
}

func (s *span) len() int {
	return s.end - s.start + 1
}

func main() {
	var n int
	fmt.Scan(&n)
	reader := bufio.NewReader(os.Stdin)
	s, _ := reader.ReadString('\n')
	s = strings.TrimSuffix(s, "\n")

	spans := make([]*span, 0)

	spans = append(spans, &span{s[0], 0, 0})

	for i := 0; i < len(s)-1; i++ {
		if s[i] != s[i+1] {
			tmp := spans[len(spans)-1]
			tmp.end = i
			spans = append(spans, &span{s[i+1], i + 1, i + 1})
		}
	}
	spans[len(spans)-1].end = len(s) - 1

	min := 0xffffffff
	split := 0 // left of split: . right of split: #
	left := 0
	right := 0

	for _, v := range spans {
		if v.val != '#' {
			right += v.len()
		}
	}
	if right < min {
		min = right
	}

	for split = 1; split <= len(spans); split++ {
		v := spans[split-1]
		if v.val == '.' {
			right -= v.len()
		} else {
			left += v.len()
		}
		if right + left < min {
			min = right+left
		}
	}
	fmt.Println(min)
}

/*
###...##
 */

Measured memory_bytes: 13056
#include <stdio.h>
#include <algorithm>
using namespace std;

typedef long long ll;

ll x[111111], y[111111], parent[111111], incv[111111], grp[111111];

ll Find(ll p)
{
    if (parent[p] == p)
		return p;
	else
		return parent[p] = Find(parent[p]);
}

int main(void)
{
    ll n, m, i;

    scanf("%lld %lld" ,&n, &m);
	for (i = 1; i <= m; i++)
		scanf("%lld %lld" ,&x[i], &y[i]);

	for (i = 1; i <= n; i++)
		parent[i] = i, grp[i] = 1;

	incv[m] = n * (n - 1) / 2;

    for (i = m; i >= 2; i--)
	{
		ll a = x[i], b = y[i];

        a = Find(a);
        b = Find(b);

        if (a != b)
		{
			incv[i - 1] = incv[i] - grp[a] * grp[b];
			parent[b] = a;

			grp[a] += grp[b];
			grp[b] = 0;
		}
		else
			incv[i - 1] = incv[i];
	}

	for (i = 1; i <= m; i++)
		printf("%lld\n" ,incv[i]);
	return 0;
}

Measured memory_bytes: 5376
#include <stdio.h>

int main(void) {
	int A, B;
	int asumikana;
	if (scanf("%d%d", &A, &B) != 2) return 1;
	asumikana = A + B;
	if (A - B > asumikana) asumikana = A - B;
	if (A * B > asumikana) asumikana = A * B;
	printf("%d\n", asumikana);
	return 0;
}


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

using namespace std;
int main(){
    int N;cin>>N;
    int A[N];for(int i=0;i<N;i++)cin>>A[i];
    int cnt=0;
    bool flag = false;
    while(1){
        for(int i=0;i<N;i++){if(A[i]%2==1){flag=true;break;}else A[i]/=2;}
        if(flag)break;
        else cnt++;
    }
    cout<<cnt;
}

Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]
ans = 0
cnt = [0]*(max(a)+1)

for i in range(n):
    cnt[a[i]] += 1

if len(cnt) < 3:
    ans = sum(cnt)
else:
    for i in range(len(cnt)-2):
        ans = max(ans,cnt[i]+cnt[i+1]+cnt[i+2])

print(ans)

Measured memory_bytes: 13864
N, M = map(int, input().split())
height = list(map(int, input().split()))
good = [True] * N

for i in range(M):
    A, B = map(int, input().split())
    if height[A-1] < height[B-1]:
        good[A-1] = False
    elif height[A-1] > height[B-1]:
        good[B-1] = False
    else:
        good[A-1] = False
        good[B-1] = False

print(good.count(True))


Measured memory_bytes: 20140
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int N, maxi = -1, A[1<<18];
char s[1<<18][11];
int main(){
	scanf("%d", &N);
	for(int i=0; i<N; i++){
		scanf("%s", s[i]);
		A[i] = 1;
	}
	qsort(s, N, sizeof(s[0]), strcmp);
	for(int i=1; i<N; i++){
		if(!strcmp(s[i], s[i-1])){
			A[i] += A[i-1];
		}
		maxi = maxi>A[i]?maxi:A[i];
	}
	for(int i=0; i<N; i++){
		if(A[i] == maxi)puts(s[i]);
	}
	return 0;
}

Measured memory_bytes: 6532
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int preT=0;
        int preX=0;
        int preY=0;

        for(int i=0; i<N; i++){
            int postT = sc.nextInt();
            int postX = sc.nextInt();
            int postY = sc.nextInt();

            int dt = postT - preT;
            int dist = Math.abs(postX - preX) + Math.abs(postY - preY);
            if((dt<dist)||((dist-dt)%2!=0)){
                System.out.println("No");
                return;
            }

            preT = postT;
            preX = postX;
            preY = postY;
        }

        System.out.println("Yes");
    }
}

Measured memory_bytes: 87412
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
//	while(scanf("%d%d",&n,&k)==2)
		
			long long ans=0;
			long long p=n/k;
			ans+=p*p*p;
			if(k%2==0 && n>=k/2)
				{
					long long m=k/2;
					p=(n-m)/k+1;
					ans+=p*p*p;
				}
			cout<<ans<<endl;
	return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  int n,m;
  cin >> n >> m;
  if(n & 1){
    for(int i = 1,j = n;i <= m;i++,j--)printf("%d %d\n",i,j);
  }else{
    bool is = false;
    for(int i = 1,j = n-1;m;i++,j--){
      if(!is && j-i <= n/2){
        j--;
        is = true;
      }
      printf("%d %d\n",i,j);
      m--;
    }
  }
  
  
  
  return 0;
}

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

int n, m, p, a[7][7][7], h[7][7];
int dx[]{ 1,1,-1,0,0,0,0,1,1,1,1,-1,-1 };
int dy[]{ 0,0,0,1,-1,1,0,1,-1,1,-1,-1,1 };
int dz[]{ 0,1,1,1,1,0,1,0,0,1,1,1,1 };

bool judge() {
	rep(t, 13)rep(i, n)rep(j, n)rep(k, n) {
		int x = i, y = j, z = k;
		int back = a[i][j][k], cnt = 0;
		while (x >= 0 && x < n&&y >= 0 && y < n&&z < n) {
			if (back != a[x][y][z])cnt = 0;
			back = a[x][y][z];
			if (++cnt >= m&&back != -1)return 1;
			x += dx[t]; y += dy[t]; z += dz[t];
		}
	}
	return 0;
}
int main() {
	while (scanf("%d%d%d", &n, &m, &p), n) {
		memset(a, -1, sizeof(a));
		memset(h, 0, sizeof(h));
		bool ok = true;
		rep(i, p) {
			int x, y; scanf("%d%d", &x, &y); x--; y--;
			a[x][y][h[x][y]++] = i & 1;
			if (ok && judge()) {
				printf(i & 1 ? "White " : "Black ");
				printf("%d\n", i + 1);
				ok = false;
			}
		}
		if (ok)puts("Draw");
	}
}

Measured memory_bytes: 3120
a,b,c,d = map(int,input().split())

from math import gcd

lcm = (c*d)//gcd(c,d)

b_div_c = b//c
a_div_c = (a-1)//c

b_div_d =b//d
a_div_d = (a-1)//d

b_div_cd = b//lcm
a_div_cd = (a-1)//lcm



ans1 = b_div_c - a_div_c
ans2 = b_div_d - a_div_d
ans3 = b_div_cd - a_div_cd

ans = b -(a-1) - ans1 - ans2 + ans3
print(ans)

Measured memory_bytes: 9176
# D - Bouquet
def comb(n,k,mod):
    a = 1
    b = 1
    for i in range(k):
        a = a * (n-i) % mod
        b = b * (i+1) % mod
    return a * pow(b, mod-2, mod) % mod
n,a,b=map(int,input().split())
mod=10**9+7
c_n=pow(2,n,mod)-1
c_a=comb(n,a,mod)
c_b=comb(n,b,mod)
print((c_n-c_a-c_b)%mod)

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

int N,M;
string A[51]={},B[51]={};

int search(int x,int y){
	
	for(int i=0;i<M;i++){
		for(int k=0;k<M;k++){
			if(A[i+x][k+y]!=B[i][k]){
				return 0;
			}
		}
	}
	
	return 1;
	
}

int main(){
	int answer = -1;

	cin >> N >> M;
	
	for(int i=0;i<N;i++){
		cin >> A[i];
	}
	for(int i=0;i<M;i++){
		cin >> B[i];
	}
	
	for(int i=0;i<N-M;i++){
		for(int k=0;k<N-M;k++){
			answer=max(answer,search(i,k));
		}
	}
	
	if(answer){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <cmath>
#include <algorithm>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define INF 999999999
using namespace std;

const int lengthmax=100;

int main(){
          string a,b,c;
          cin >> a >> b >> c;

          char Turn;
          Turn=1;

          int x=0,y=0,z=0;

          for(;;){
                    char A,B,C;
                    A=a[0+x],B=b[0+y],C=c[0+z];
                    if(x==a.size()+1){
                              cout << "A" << endl;
                              return 0;
                    }
                    else if(y==b.size()+1){
                              cout << "B" << endl;
                              return 0;
                    }
                    else if(z==c.size()+1){
                              cout << "C" << endl;
                              return 0;
                    }
                    if(Turn==1){
                              x++;
                              if(A=='a')          Turn=1;
                              else if(A=='b')     Turn=2;
                              else      Turn=3;
                    }
                    else if(Turn==2){
                              y++;
                              if(B=='a')          Turn=1;
                              else if(B=='b')     Turn=2;
                              else      Turn=3;
                    }
                    else {
                              z++;
                              if(C=='a')          Turn=1;
                              else if(C=='b')     Turn=2;
                              else Turn=3;
                    }
          }
          return 0;
}


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

#ifdef LOCAL
#include "debug_print.hpp"
#else
void debug(...) {}
#endif

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

    ll N, X, M;
    cin >> N >> X >> M;

    ll ans = 0;
    ll x = X;
    ll cnt = 0;
    map<ll, ll> mp;
    for(ll i = 0; i<N; i++) {
        if(mp[x]) {
            ll loop = cnt - mp[x] + 1;
            debug(ans, i, loop, mp[x]);
            ll p = 0;
            for(int j=mp[x]-1; j<i; j++) {
                p += x;
                x *= x;
                x %= M;
            }
            ans += ((N - mp[x] + 1) / loop - 1) * p;
            i = N - (N - mp[x] + 1) % loop;
            mp.clear();
            debug(ans, i, p);
            if(i >= N) break;
        }
        else {
            mp[x] = i + 1;
            cnt++;
        }
        ans += x;
        x *= x;
        x %= M;
        debug("x=", x);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e7 + 5;
const int maxm = 5e5 + 5;
const ll inf = 2147483647;

int main(){
    string s;
    cin>>s;
    cout<<s[0]<<s[1]<<s[2];
    return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

void resolve() {
    string s;
    cin >> s;
    string aki = "AKIHABARA";
    REP(i,0,s.size()-1) {
        if (s[i] == 'K' && s[i+1] != 'I') s = s.substr(0,i+1) + "I" + s.substr(i+1);
        if (s[i] == 'H' && s[i+1] != 'A') s = s.substr(0,i+1) + "A" + s.substr(i+1);
        if (s[i] == 'B' && s[i+1] != 'A') s = s.substr(0,i+1) + "A" + s.substr(i+1);
        if (s[i] == 'R' && s[i+1] != 'A') s = s.substr(0,i+1) + "A" + s.substr(i+1);
        //cerr << i << s << endl;
    }
    if (s == aki || "A" + s == aki || s + "A" == aki || "A" + s + "A" == aki) cout << "YES" << endl;
    else cout << "NO" << endl;
}

int main() {
    resolve();
    
    return 0;
}

Measured memory_bytes: 256
N, M = [int(i) for i in input().strip().split(' ')]

L, R = [int(i) for i in input().strip().split(' ')]
for _ in range(M - 1):
  l, r = [int(i) for i in input().strip().split(' ')]
  L = max(L, l)
  R = min(R, r)

v = (R - L + 1)
v = v if  v > 0 else 0
print(v)


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

int main() {
	string a, b;
	cin >> a >> b;
	int len=b.length();
	
	for (int i=0; i<len; i++){
		cout<< a[i] << b[i];
	}
    if (a.length()>b.length()) cout << a[len];
	cout << "\n";
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var k int
	fmt.Scan(&k)
	appears := make([]bool, k)
	count := 1
	a := 7
	a %= k
	if a == 0 {
		fmt.Println(1)
		return
	}

	for !appears[a] {
		appears[a] = true
		a = (a*10 + 7) % k
		count++
		if a == 0 {
			fmt.Println(count)
			return
		}
	}
	fmt.Println(-1)
}


Measured memory_bytes: 2800
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
//typedef long double ld;
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 gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
ll jow(ll n, ll x){
  ll res = 1;
  while(n){
    if(n & 1) res = res*x % mo;
    x = x*x%mo;
    n >>= 1LL;
  }
  return res;
}
int main(){
  ll N; cin>>N;
  ll sum = 0;
  for(ll i=1 ; i*i<=N ; i++){
    if((N-i)%i==0 && (N-i)/i>i) sum += (N-i)/i;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<iomanip>
#include<cmath>
#include<algorithm>
using namespace std;
int t;
double x1,y_1,x2,y2,x3,y3,x,y,r;
int main(){
    cin>>t;
    for(int i=1;i<=t;i++){
        cin>>x1>>y_1>>x2>>y2>>x3>>y3;
        x=((x1*x1+y_1*y_1-x2*x2-y2*y2)/2*(y_1-y3)-(x1*x1+y_1*y_1-x3*x3-y3*y3)/2*(y_1-y2))/(x1*(y2-y3)+x2*(y3-y_1)+x3*(y_1-y2));
        y=((x1*x1+y_1*y_1-x3*x3-y3*y3)/2*(x1-x2)-(x1*x1+y_1*y_1-x2*x2-y2*y2)/2*(x1-x3))/(x1*(y2-y3)+x2*(y3-y_1)+x3*(y_1-y2));
        r=sqrt((x-x1)*(x-x1)+(y-y_1)*(y-y_1));
        cout<<fixed<<setprecision(3)<<x<<" "<<y<<" "<<r<<endl;
    }
    return 0;
}


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

int main(void)
{
    char O[51], E[51];
    char P[101];
    int nO, nE, i, k;

    scanf("%s", &O);
    scanf("%s", &E);

    nO = strlen(O);
    nE = strlen(E);

    k=0;
    for (i=0; i<nO; i++) {
        if (O[i]!='\0') P[k++] = O[i];
        if (E[i]!='\0') P[k++] = E[i];
    }

    P[k] = '\0';

    printf("%s\n", P);

    return 0;
}

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

int main(){
	char s[500005];
	scanf("%s",s);
	int n=strlen(s);
	long long ans=0;
	vector<int> v;
	if(s[0]=='<')v.push_back(0);
	for(int i=1;i<n;i++){
		if(s[i-1]=='>'&&s[i]=='<')v.push_back(i);
	}
	if(s[n-1]=='>')v.push_back(n);
	int idx=0;
	for(int i=0;i<=n;i++){
		while(idx<(int)v.size()&&v[idx]<=i)idx++;
		//printf("%d\n",idx);
		int cur=0;
		if(idx>0&&i>0&&s[i-1]=='<')cur=max(cur,i-v[idx-1]);
		if(idx<(int)v.size()&&i<n&&s[i]=='>')cur=max(cur,v[idx]-i);
		ans+=cur;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 1404
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();
		int r = 0;
		for(int i=0; i < 3; i++) {
			if(s.charAt(i)=='R') {
				if(i==2&&s.charAt(1)=='S')r=0;
				r++;
			}
		}
		System.out.println(r);
	}
}


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

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);

template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define dbg(x) true
#endif

const int MAX_N = 1000001;

namespace uf {
int par[MAX_N];
int rank[MAX_N];
int count[MAX_N];
}  // namespace uf

void init(int n) {
  for (int i = 0; i < n; i++) {
    uf::par[i] = i;
    uf::rank[i] = 0;
    uf::count[i] = 1;
  }
}

int find(int x) {
  if (uf::par[x] == x) {
    return x;
  } else {
    return uf::par[x] = find(uf::par[x]);
  }
}

void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y)
    return;

  if (uf::rank[x] < uf::rank[y]) {
    uf::par[x] = y;
    uf::count[y] += uf::count[x];
  } else {
    uf::par[y] = x;
    if (uf::rank[x] == uf::rank[y])
      uf::rank[x]++;
    uf::count[x] += uf::count[y];
  }
}

int group_size(int x) {
  return uf::count[find(x)];
}

bool same(int x, int y) {
  return find(x) == find(y);
}

void solve(long long N, long long M, std::vector<long long> A, std::vector<long long> B) {
  init(N);
  REP(i, M) {
    unite(A[i] - 1, B[i] - 1);
  }
  ll ans = 0;
  REP(i, N) {
    ans = max(ans, (ll)group_size(find(i)));
  }
  cout << ans << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  std::vector<long long> A(M);
  std::vector<long long> B(M);
  for (int i = 0; i < M; i++) {
    scanf("%lld", &A[i]);
    scanf("%lld", &B[i]);
  }
  solve(N, M, std::move(A), std::move(B));
  return 0;
}


Measured memory_bytes: 8820
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i.second<< " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  // bit全探索
  int N;
  cin >> N;
  vector<vector<P>> XY;
  rep(i, N) {
    int A;
    cin >> A;
    vector<P> B;
    rep(j, A) {
      int X, Y;
      cin >> X >> Y;
      --X;
      B.push_back(make_pair(X, Y));
    }
    XY.push_back(B);
  }
  //rep(i, N) show(XY[i]);
  int ans = 0;  
  for (int bit = 0; bit < (1<<N); bit++) {
    bool flag = true;
    for (int i = 0; i < N; i++) {
      if ((bit&(1<<i)) == 0) continue;
      for (auto p : XY[i]) {
        if (((bit>>p.first)&1) ^ (p.second==1)) {
          //cout << bit << '-' << i << '-' << p.first << '\n';
          flag = false; break;
        }
      }
    }
    if (flag) {
      int temp = 0;      
      for (int j = 0; j < 15; j++) {
        if (bit>>j&1) {
          ++temp;
        }
      }
      if (temp > ans) {
        //cout << '-' << bit << '\n';
        ans = temp;
      }
    }
  }
  cout << ans << '\n';
  return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}






void _main() {
        int n; cin >> n;
        vector<vector<pair<int,int>>> t(n);
        for (int i = 0; i < n; i++) {
                int x; cin >> x;
                while (x--) {
                        int a, b; cin >> a >> b;
                        a--;
                        t[i].emplace_back(a, b);
                }
        }


        int ans = 0;
        for (int mask = 0; mask < (1 << n); mask++) {
                bool ok = 1;
                for (int bit = 0; bit < n; bit++) {
                        if (1 << bit & mask) {
                                for (int i = 0; i < sz(t[bit]); i++) {
                                        if (!!(1 << t[bit][i].first & mask) != t[bit][i].second) ok  =0;
                                }
                        }
                }

                if (ok) ans = max(ans, __builtin_popcount(mask));
        }


        cout << ans << '\n';
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 3620
#include <cstdio>
#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 <complex>
#include <stack>
#include <queue>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
#define FOR(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	int n;
	cin>>n;
	double d=100;
	rep(i,n){
		d*=1.05;
		d=(int)(d+0.99999);
	}
	cout<<d<<"000"<<endl;
	return 0;
}

Measured memory_bytes: 0
/*input
5
0.42 0.01 0.42 0.99 0.42
*/
#include<bits/stdc++.h>
using namespace std;

#define int long long 
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define WL(t) while(t --)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;
const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int fast_ex(int a,int n,int m){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= fast_ex(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

const int N = 3000;

double a[N];
double p[N][N];

void solve(){
	int n;cin >> n;
	RE(i,n)cin>> a[i];
	p[0][0] = 1;
	RE(i,n){
	   REP(j,n+1){
	   	 p[i][j] = (double)p[i-1][j-1]*a[i]+(double)p[i-1][j]*(1-a[i]);
	   	 //cout << p[i][j] << " ";
	   }	
	   //cout << endl;
	}
	double ans = 0;
	for(int i = n;i > n/2;i--)ans += p[n][i];
	cout << fixed  << setprecision(15) << ans;
}

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  //freopen(".in","r",stdin);freopen(".out","w",stdout);
  int t = 1;//cin >> t;
  WL(t)solve();
  return 0;
}

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

int N;
vector<int> v;

int main(){
    cin>>N;
    v.resize(N);
    for(int i=0;i<N;i++){
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    double ans=(double)(v[0]+v[1])/2;
    for(int i=2;i<N;i++){
        ans=(double)(ans+v[i])/2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#ifdef CURIOUSCAT
#define Pr(f,...) fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)
#else
#define Pr(f,...)
#endif

typedef long long ll;

template<typename T>
void read(T &x){
	x=0; 
	char c;
	for(c=getchar();!isdigit(c);c=getchar()); 
	for(;isdigit(c);c=getchar())x=x*10+c-'0'; 
}

const int N=1e6+50,P=998244353;

int mul(int a,int b){ return 1ll*a*b%P; }
int add(int a,int b){ a+=b; return a>=P?a-P:a; }
int sub(int a,int b){ a-=b; return a<0?a+P:a; }
int gcd(int a,int b){ return !b?a:gcd(b,a%b); }

int C(int n,int m) { 
	if (m<0||m>n)return 0;
	if(m<=1)return m==1?n:1;
	return 1ll*C(n/2,m/2)*C(n%2,m%2)%2;
}

int n,exist_1,ans1,ans2; 
char a[N];
int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
#endif
	read(n); 
	scanf("%s", a+1); 
	rep(i,1,n){
		ans1^=(C(n-1,i-1)*((a[i]-'1')%2))%2;
		ans2^=C(n-1,i-1)*(a[i]=='3')%2;
		exist_1 |= a[i]=='2';
	}
	printf("%d\n",ans1?1:(exist_1?0:ans2*2)); 
	return 0;
}


Measured memory_bytes: 4776
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T> inline void read(T &n) {
  n = 0; RI ch = gc(), f;
  while ((ch < '0' || ch > '9') && ch != '-') ch = gc();
  f = (ch == '-' ? ch = gc(), -1 : 1);
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
  n *= f;
}

int main() {
  
#ifdef LOCAL
  FILEIO("a");
#endif

  char ch; ch = getchar();
  ++ch; putchar(ch);

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<sstream>
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);
    int t; //cin>>t;
    t=1;
    while(t--)
    {
     string s; cin>>s;
     for(int i=0;i<s.length();i++)
     {
         if(s[i]=='?')
         s[i]='D';
     }
     cout<<s<<"\n";
    }

}

Measured memory_bytes: 3780
import java.util.Scanner;
import java.util.regex.Pattern;
public class Main {
	public static boolean hantei(String str) {
        return Pattern.matches("^[a-z]+$", str);
    }
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String S;
		String T;
		do {
			S = stdIn.next();
			T = stdIn.next();
		}while(hantei(S)==false||hantei(T)==false||S.length()<1||S.length()>100||T.length()<1||T.length()>100);
		System.out.println(T+S);
	}
}


Measured memory_bytes: 21844
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    // rlsうる
    let mut s = io.chars();

    let mut switchc = 0;
    for (i, &c) in s.iter().enumerate() {
        if i > 0 {
            if c != s[i - 1] {
                switchc += 1;
            }
        }
    }
    io.writeln(switchc);
}

static MOD: i64 = 1000000007;
static INF: i64 = std::i64::MAX >> 1;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn chari(&mut self) -> Vec<i64> {
        self.chars()
            .iter()
            .map(|&c| (c as u8 - b'0') as i64)
            .collect::<Vec<i64>>()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


Measured memory_bytes: 4352
a, b = map(int, input().split())

a -= 1
b -= 1
print(100, 100)
for i in range(100):
  l = []
  for j in range(100):
    c = '#' if i < 50 else '.'
    if i % 2 and j % 2:
      if i < 50 and a:
        c = '.'
        a -= 1
      if i >= 50 and b:
        c = '#'
        b -= 1
    l.append(c)
  print(''.join(l))
    


Measured memory_bytes: 9200
a = list(map(int,input().split()))
A = a[0]
B = a[1]
K = a[2]
A1 = A - K
B1 = B
if A1 < 0:
    B1 = A1 + B
    A1 = 0
    if B1 < 0:
        B1 = 0

print(A1,end=" ")
print(B1)


Measured memory_bytes: 38256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <map>
#include <utility>
#include <vector>

#define MAX_N (200000)
#define MAX_EXP (30)

using namespace std;

int main(int argc, char *argv[]) {
  // read inputs
  int N, as[MAX_N];
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &as[i]);
  }

  // put into map
  map<int, int> m;
  for (int i = 0; i < N; i++) {
    m[as[i]]++;
  }

  // create graph
  int ans = 0;
  for (int t = MAX_EXP; t > 0; t--) {
    const int pow2 = (1 << t);
    // remove all pow2/2
    const int k = (1 << (t - 1)), cnt_k = m[k], pair_k = cnt_k / 2;
    ans += pair_k;
    m[k] -= pair_k * 2;
    m.erase(k);
    // printf("k = %d, cnt_k = %d, pair_k = %d\n", k, cnt_k, pair_k);
    // make pairs
    map<int, int> used;
    for (pair<int, int> p : m) {
      const int a_i = p.first, cnt_a_i = p.second;
      if (a_i > k) {
        break;
      }
      const int a_j = pow2 - a_i, cnt_a_j = m[a_j];
      if (cnt_a_j > 0) {
        const int cnt = min(cnt_a_i, cnt_a_j);
        ans += cnt;
        used[a_i] = cnt;
        used[a_j] = cnt;
      }
    }
    for (pair<int, int> p : used) {
      m[p.first] -= p.second;
    }
  }
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 29056
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, A[201010];
int lft[201010], rht[201010];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N) cin >> A[i];

	rep(i, 0, N) lft[i] = A[i];
	rep(i, 1, N) chmax(lft[i], lft[i - 1]);

	rep(i, 0, N) rht[i] = A[i];
	rrep(i, N - 2, 0) chmax(rht[i], rht[i + 1]);

	rep(i, 0, N) {
		int ans = -1;
		if (0 < i) chmax(ans, lft[i - 1]);
		if (i + 1 < N) chmax(ans, rht[i + 1]);
		printf("%d\n", ans);
	}
}







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

int main(){
    int K,N; cin >> K >> N;
    vector <int> A(N);
    
    rep(i,N) cin >> A[i];
    sort(A.begin(),A.end());
    int tmp1=(A[0]+K)-A[N-1];
    
    int tmp2=0;
    rep(i,N-1) tmp2=max(tmp2,A[i+1]-A[i]);
    
    int tmp3=max(tmp1,tmp2);
    //cout << tmp1 << " " << tmp2 << endl;
    ll ans=K-tmp3;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#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>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    S[K-1] = S[K-1] - 'A' + 'a';
    print(S);
    
    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
h = list(map(int, input().split()))
 
dp = [float("inf")] * N
dp[0] = 0
 
for i in range(1, N):
    for j in range(1, K+1):
        if i - j < 0:
            break
        else:
            step = abs(h[i] - h[i-j])
            dp[i] = min(dp[i], dp[i-j]+step)
 
print(dp[N-1])

Measured memory_bytes: 55008
N,K = map(int,input().split())
a = [list(map(int,input().split())) for i in range(2*K)]
s = []; t = 0
for i in range(K):
    s = s + a[2*i+1]
for i in range(1,N+1):
    if i not in s:
        t+=1
print(t)

Measured memory_bytes: 9128
from bisect import bisect_right, bisect_left


def main():
    N = int(input())

    A = sorted(map(int, input().split()))
    B = sorted(map(int, input().split()))
    C = sorted(map(int, input().split()))

    ans = 0
    for b in B:
        idx_a = bisect_left(A, b)
        cnt_a = idx_a

        idx_c = bisect_right(C, b)
        cnt_c = N - idx_c

        ans += cnt_a * cnt_c

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 105444
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
 
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,W;
  cin>>N>>W;
  
  int v[101],w[101];
  rep(i,N) cin>>v[i+1]>>w[i+1];
  
  int dp[101][10001];
  
  rep(i,10001) dp[0][i]=0;
  rep(i,101) dp[i][0]=0;
  
  for(int i=0;i<N;i++){
    for(int j=1;j<=10000;j++){
      if(j<w[i+1]) dp[i+1][j]=dp[i][j];
      else dp[i+1][j]=max(dp[i][j],max(dp[i][j-w[i+1]]+v[i+1],dp[i+1][j-w[i+1]]+v[i+1]));
    }
  }
  
  cout<<dp[N][W]<<endl;
      
  return 0;
}


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

int main(){
    int D, N;
    cin >> D >> N;

    long long ans;
    if(N!=100){
        ans = round(pow(100, D))*N;
    }else{
        ans = round(pow(100, D))*(N+1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3804
#include <stdio.h>
#include <string.h>
#define LEN 100006

typedef struct {
  char name[100];
  int t;
}process;

process  q[100006]; 
int head,tail,n;
void enqueue();
process dequeue();


int main(){
  int n,qu,i,j,ti,ans = 0;
  process p;
  scanf("%d%d",&n,&qu);
  head = 1;
  tail = n + 1;


  for(i = 1;i <= n;i++){
    scanf("%s",q[i].name);
    scanf("%d",&q[i].t);
  }
  
  while(tail != head){
    p = dequeue();
    if(p.t > qu){
      ans += qu;
      p.t -= qu;
      enqueue(p);
    }
    else{
      ans += p.t;
      printf("%s %d\n",p.name,ans);
    }
  }
    
  return 0;
}

void  enqueue( process in){
   q[tail] = in;
   tail = (tail + 1) % LEN;
 }

process dequeue(){
  process out;
  out = q[head];
  head = (head + 1) % LEN;
  return out;
}

Measured memory_bytes: 10756
def main():
    N, K = (int(i) for i in input().split())
    H = [0] + [int(i) for i in input().split()]
    if N == K:
        return print(0)
    elif K == 0:
        ans = 0
        for i in range(N):
            ans += max(H[i+1] - H[i], 0)
        return print(ans)

    dp = [[10**10]*(N-K+1) for i in range(N+1)]
    dp[0][0] = 0
    for x in range(1, N+1):
        for y in range(N-K+1):
            for i in range(x):
                dp[x][y] = min(dp[x][y], dp[i][y-1] + max(0, H[x] - H[i]))
    ans = 10**10
    for i in range(N+1):
        # print(dp[i])
        ans = min(ans, dp[i][N-K])
    print(ans)


if __name__ == '__main__':
    main()


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

int main()
{
    int i,j,n;
    int arr[1000];

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

    sort(arr,arr+n);
    //x = abs(arr[0])
    cout<<abs(arr[0] - arr[n-1]);
}


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


int main() {
	int64_t N, K,F,T;
	cin >> N >> K;
	
	F = N % K;
	T = abs(K - F);
	if (F<T)
	{
		cout << F << endl;
	}
	else {
		cout << T << endl;
	}
	
}


Measured memory_bytes: 3536
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
//#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
//#include <array>
#include <valarray>
#include <stdio.h>
//#include <random>
//#include <windows.h>
//#pragma comment(lib, "winmm.lib")
#include <algorithm>

using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

long long  int nCm(long long int n, long long int m) {
	if (m == 1) {
		return n;
	}
	else {
		return n*nCm(n - 1, m - 1) / m;
	}
}

long long int npm(long long int n,long long int m) {
	if (m == 1) {
		return n;
	}
	else 
		if (m == 0) {
			return 1;
		}else {
		return n*npm(n, m - 1);
	}
}

 int main() {
	 string s;
	 int K;
	 cin >> s;
	 cin >> K;
	 vector<int> str(s.size());
	 for (int i = 0; i < s.size(); ++i) {
		 str[i] = (int)s[i]-'a';
	 }
	 for (int i = 0; i < s.size() - 1; ++i) {
		 if (str[i] != 0) {
			 if (26 - str[i] <= K) {  K -=( 26 - str[i]); str[i] = 0;}
		 }
	 }
	 str[s.size() - 1] = (str[s.size() - 1] + K) % 26;
	 
	 for (int i = 0; i < s.size(); ++i) {
		 s[i] = (char)str[i]+ 'a';
	 }
	 cout << s << endl;
}

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

int main()
{
  int64_t n, k;
  cin >> n >> k;

  vector<int64_t> a(n);
  for (auto&& e : a) cin >> e;

  int64_t inv = 0;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < i; j++) {
      if (a[i] < a[j]) {
        inv++;
      }
    }
  }

  int64_t ans = inv * k;
  sort(begin(a), end(a));
  int64_t c = 0;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < i; j++) {
      if (a[j] < a[i]) {
        c++;
      }
    }
  }

  ans += c * (k * (k - 1) / 2 % 1000000007);
  ans %= 1000000007;
  cout << ans << endl;
}


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

using namespace std;

string x;

int main()
{
	getline(cin, x);
	bool C = false, F = false;
	for(register int i = 0; i < x.length(); i++)
	{
		if(C && F) break;
		if(!C)
		{
			if(x[i] == 'C') C = true;
		}
		else {
			if(x[i] == 'F') F = true;
		}
	}
	if(C && F) cout << "Yes" << '\n';
	else cout << "No" << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

using Weight=int;
using DArray=vector<Weight>;
using DMatrix=vector<DArray>;

static const Weight INF=1<<29;

struct Edge {
    size_t src, dst;
    Weight weight;
    Edge() {}
    Edge(size_t src, size_t dst, Weight weight=1):
        src(src), dst(dst), weight(weight)
    {}
};

bool operator<(const Edge &e, const Edge &f) {
    if (e.weight != f.weight) {
        return e.weight > f.weight;
    } else {
        return e.src!=f.src? e.src<f.src : e.dst<f.dst;
    }
}

using Edges=vector<Edge>;
using Vertex=vector<Edge>;
using Graph=vector<Vertex>;

void join(Graph &g, size_t s, size_t d, Weight w=1) {
    // non-directed
    g[s].push_back(Edge(s, d, w));
    g[d].push_back(Edge(d, s, w));
}

void connect(Graph &g, size_t s, size_t d, Weight w=1) {
    // directed
    g[s].push_back(Edge(s, d, w));
}

int main() {
    size_t n;
    scanf("%zu", &n);

    Graph g(n);
    for (size_t i=0; i<n; ++i) {
        size_t k;
        scanf("%*d %zu", &k);
        for (size_t j=0; j<k; ++j) {
            size_t v;
            scanf("%zu", &v);
            --v;

            connect(g, i, v);
        }
    }

    queue<size_t> q; q.push(0);
    vector<size_t> d(n, -1); d[0]=0;
    while (!q.empty()) {
        size_t v=q.front(); q.pop();
        for (Edge &e: g[v]) {
            if (d[e.dst] > d[v] + 1) {
                d[e.dst] = d[v] + 1;
                q.push(e.dst);
            }
        }
    }

    for (size_t i=0; i<n; ++i)
        printf("%zu %zd\n", i+1, d[i]);

    return 0;
}

Measured memory_bytes: 2760