akhauriyash/Code-Regression huggingface dataset:
class Dice:
    def __init__(self, top, south, east, west, north, bottom):
        self.top = top
        self.south = south
        self.east = east
        self.west = west
        self.north = north
        self.bottom = bottom

    def toN(self):
        tmp = self.top
        self.top = self.south
        self.south = self.bottom
        self.bottom = self.north
        self.north = tmp

    def toE(self):
        tmp = self.top
        self.top = self.west
        self.west = self.bottom
        self.bottom = self.east
        self.east = tmp

    def toS(self):
        tmp = self.top
        self.top = self.north
        self.north = self.bottom
        self.bottom = self.south
        self.south = tmp

    def toW(self):
        tmp = self.top
        self.top = self.east
        self.east = self.bottom
        self.bottom = self.west
        self.west = tmp

    def printTop(self):
        print(self.top)

    def printWest(self):
        print(self.west)

    def printEast(self):
        print(self.east)

    def getTop(self, target):
        if self.top == target:
            return
        for i in range(3):
            self.toN()
            if self.top == target:
                return
        for i in range(3):
            self.toE()
            if self.top == target:
                return

        if self.top != target:
            print("Error")

    def getSouth(self, target):
        if self.south == target:
            return
        for i in range(3):
            self.lotate()
            if self.south == target:
                return
    
    def lotate(self):
        tmp = self.north
        self.north = self.east
        self.east = self.south
        self.south = self.west
        self.west = tmp


n = input().split()
count = int(input())
dice = Dice(int(n[0]), int(n[1]), int(n[2]), int(n[3]), int(n[4]), int(n[5]))

for i in range(count):
    buf = input().split()

    dice.getTop(int(buf[0]))
    dice.getSouth(int(buf[1]))
    dice.printEast()




Measured memory_bytes: 5608
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include<cassert>
#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>
#include<bitset>

#define REP(i, b, n) for(int i=b;i<(int)n;i++)
#define rep(i, n)   REP(i,0,n)
#define ALL(C)     (C).begin(),(C).end()
#define FOR(it, o)  for(__typeof((o).begin()) it=(o).begin(); it!=(o).end(); ++it)
#define dbg(x) cout << __LINE__ << ' ' << #x << " = " << (x) << endl


typedef long long ll;

using namespace std;

//ハマったらチェックリスト見ろ!!

int calc(int n, int K){
    int ret = n / (K-1);
    if(n%(K-1) != 0)ret++;
    return ret;
}

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    int mini = 1e9;
    rep(i, N) mini = min(mini, A[i]);

    vector<int> distR(N);
    int now = 1e9;
    rep(i, N){
        now++;
        if(A[N-i-1] == mini)now = 0;
        distR[N-i-1] = now;
    }

    bool needMini = true;
    int remain = 0;
    int ans = 0;
    rep(i, N){
        if(A[i] == mini){
            needMini = false;
            remain--;
            continue;
        }
        // まだ最小値を含んでない
        if(needMini){
            assert(remain >= 0);
            if(remain <= 1){
                ans++;
                remain = K;
            }
            remain--;
            continue;
        }
       // もう含んでる
        else{
            // 範囲外
            if(remain <= 0){
                // 右にあるなら，右から塗ったほうが良い
                if(distR[i] != 1e9){
                    needMini = true;
                    remain = K;
                }
                else{
                    // 一つ左から塗る
                    needMini = false;
                    remain = K-1;
                }
                ans++;
            }
            remain--;
        }
    }
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
using namespace std;

int main()
{
	vector<int> A(3);
	for (auto i = 0; i < 3; ++i)
	{
		cin >> A[i];
	}
	sort(A.begin(), A.end(), greater<int>());

	cout << A[0] - A[2] << endl;

	return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> l(n);
    int ans = 0;

    rep(i, n)cin >> l[i];

    sort(l.begin(), l.end(), greater<int>());

    rep(i, n-2){
        int a = l[i];
        for(int j = i+1; j < n - 1; j++){
            int b = l[j];
            for(int k = j + 1; k < n; k++){
                if(a<b+l[k]){ans++;
              //  cout << a << " " << b << " " << l[k] << endl;
                }
                else break;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
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 s = sc.nextInt();
		int max = 1000000000;
		for (int i = 0; i < n; i++) {
			if(i < k) {
				System.out.printf("%d ", s);
			}else {
				System.out.printf("%d ",s == max? max-1:s+1);
			}
		}
		sc.close();
	}
}

Measured memory_bytes: 57472
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int
var t float64

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n, m := intScanner(), intScanner()
	x := intSliceScanner(n)
	y := intSliceScanner(m)
	z := 0
	for i := 0; i < n-1; i++ {
		z += (i + 1) * (n - i - 1) % mod * (x[i+1] - x[i]) % mod
		z %= mod
	}
	ans := 0
	for i := 0; i < m-1; i++ {
		ans += (i + 1) * (m - i - 1) % mod * z % mod * (y[i+1] - y[i]) % mod
		ans %= mod
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5860
#include<stdio.h>
int a[100000];
int ans[100000];
int main(){
int n;
scanf("%d",&n);
for (int i=1;i<=n;i++)
{
    scanf("%d",&a[i]);
}
int top=1;
ans[1]=a[1];
for (int i=2;i<=n;i++){
    if(ans[top]<a[i])
        ans[++top]=a[i];
    else{
        int mid;
        int left=1;
        int right=top;
        while(left<=right){
            mid=(left+right)/2;
            if(a[i]>ans[mid])
                left=mid+1;
            else right=mid-1;
        }
        ans[left]=a[i];
    }
}printf("%d\n",top);
return 0;
}

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

#define int long long

vector<vector<string> > mino(4);
vector<int> offset(4);
vector<string> grid(4); 

bool solve(vector<int> &use) {
  vector<string> tmp = grid;
  for ( int id: use ) {
    auto &now = mino[id];
    bool flag = false;
    for ( int i = 0; i < 4; i++ ) {
      for ( int j = 0; j < 10; j++ ) {
	if ( tmp[i][j] != '.' ) continue;
	flag = true;
	j -= offset[id];	
	for ( int y = 0; y < now.size(); y++ ) {
	  for ( int x = 0; x < now[y].size(); x++ ) {
	    if ( i+y >= 4 || j+x >= 10 || j+x < 0 ) return false;
	    if ( tmp[i+y][j+x] == '#' && now[y][x] == '#' ) return false;	    
	    if ( tmp[i+y][j+x] == '.' && now[y][x] == '#' ) {	     
	      tmp[i+y][j+x] = '#';	      
	    }	    
	  }
	}
	if ( flag ) {
	  i = 4; break;	  
	}
      }
    }
  }

  /* if ( use[0] == 0 && use[1] == 1 && use[2] == 2 ) {
    cout << 'a' << endl;
    for ( int i = 0; i < 4; i++ ) cout << tmp[i] << endl;
    }*/

  for ( int i = 0; i < 4; i++ ) {
    for ( int j = 0; j < 10; j++ ) {
      if ( tmp[i][j] == '.' ) return false;
    }
  }

  // cout << use[0] << " " << use[1] << " " << use[2] << endl;
  return true;  
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  for ( int i = 0; i < 4; i++ ) {
    int h, w;
    cin >> h >> w;
    mino[i].resize(h);
    for ( int j = 0; j < h; j++ ) cin >> mino[i][j];    
  }

  for ( int i = 0; i < 4; i++ ) {
    for ( int k = 0; k < mino[i][0].size(); k++ ) {      
      if ( mino[i][0][k] == '#' ) {
	offset[i] = k;
	break;
      }
    }
  }

  int n;
  cin >> n;
  while ( n-- ) {
    for ( int i = 0; i < 4; i++ ) cin >> grid[i];

    bool ok = false;
    for ( int i = 0; i < 4; i++ ) {
      for ( int j = 0; j < 4; j++ ) {
	for ( int k = 0; k < 4; k++ ) {
	  set<int> all{i, j, k};
	  if ( all.size() < 3 ) continue;
	  vector<int> use{i, j, k};
	  if ( solve(use) ) {
	    // cout << "Yes" << endl;
	    ok = true;
	    i = 4; j = 4; break;	    
	  }
	}
      }
    }

    if ( ok ) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  
  return 0;
}



Measured memory_bytes: 3204
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <limits.h>
#include <cinttypes>
#include <string.h>
#include <bits/stdc++.h>

#define max(a,b) (((a) > (b)) ? (a) : (b))
#define min(a,b) (((a) < (b)) ? (a) : (b))
#define abs(a) (((a) < 0) ? -(a) : (a))

#define FOR(var, to)          for (register int var = 0; var < to; var++)
#define FROMTO(var, from, to) for (register int var = from; var <= to; var++)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

using namespace std;

static inline int ri() {
	int a;
	scanf("%d", &a);
	return a;
}

static inline s64 rs64() {
	s64 a;
	scanf("%" SCNd64, &a);
	return a;
}

static inline void wi(int a) {
	printf("%d", a);
}

static inline void wu64(u64 a) {
	printf("%" PRIu64, a);
}

int main() {
	int a1 = ri();
	int a2 = ri();
	int a3 = ri();
	int r1 = abs(a2-a1)+abs(a3-a2);
	int r2 = abs(a3-a1)+abs(a2-a3);
	int r3 = abs(a3-a1)+abs(a1-a2);
	
	wi(min(min(r1,r2),r3));
	printf("\n");
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a, b) (a > b ? a = b : a)
#define cmax(a, b) (a < b ? a = b : 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)
using namespace std;

#define Pr(f,...) printf(f, ##__VA_ARGS__), fflush(stdout)

typedef long long ll; 

const int N = 1000;

int n, ans;
char s[N]; 

int main(int argc,char *argv[]){
	scanf("%s", s + 1); 
	n = strlen(s + 1); 
	rep(i, 1, n) ans += s[i] - '0';
	cmax(ans, s[1] - '1' + (n - 1) * 9);
	printf("%d\n", ans);
    return 0; 
}


Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;
const int mod = 998244353;
char s[310];
int dp[310][310][310];
void add(int &v, int x) {
	v += x;
	if (v >= mod) v -= mod;
}
int main() {
	int k;
	scanf("%s%d", s, &k);
	string a(s);
	for (int i = 0; i < a.size(); i++) {
		if (a[i] == '0') {
			a = a.substr(i);
			break;
		}
	}
	while (a.size() > 0 && a.back() == '0') {
		a.pop_back();
	}
	k = min(k, 300);
	int l = a.size();
	dp[l][k][0] = 1;
	for (int i = l - 1; i >= 0; i--) {
		if (a[i] == '1') {
			int j = i;
			while (j >= 0 && a[i] == a[j]) {
				j--;
			}
			int c = i - j;
			for (int m = 0; m <= k; m++) {
				for (int b = 0; b <= k; b++) {
					if (!dp[i+1][m][b]) continue;
					for (int t = 0; t <= c; t++) {
						if (t > m) break;
						if (b + t > 300) break;
						add(dp[j+1][m-t][b+t], dp[i+1][m][b]);
					}
				}
			}
			i = j + 1;
		} else if (a[i] == '0' && i > 0 && a[i-1] == '1') {
			int j = i - 1;
			while (j >= 0 && a[i-1] == a[j]) {
				j--;
			}
			for (int m = 0; m <= k; m++) {
				for (int b = 0; b <= k; b++) {
					if (!dp[i+1][m][b]) continue;
					for (int t = 1; t <= b; t++) {
						add(dp[j+1][m][b-t], dp[i+1][m][b]);
					}
				}
			}
			int c = i - 1 - j;
			for (int m = 0; m <= k; m++) {
				for (int b = 0; b <= k; b++) {
					if (!dp[i+1][m][b]) continue;
					for (int t = 0; t <= c; t++) {
						if (t > m) break;
						if (b + t > 300) break;
						add(dp[j+1][m-t][b+t], dp[i+1][m][b]);
					}
				}
			}
			i = j + 1;
		} else {
			for (int m = 0; m <= k; m++) {
				for (int b = 0; b <= k; b++) {
					if (!dp[i+1][m][b]) continue;
					for (int t = 0; t <= b; t++) {
						add(dp[i][m][b-t], dp[i+1][m][b]);
					}
				}
			}
		}
	}
	int ans = 0;
	for (int i = 0; i <= k; i++) {
		add(ans, dp[0][i][0]);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 17676
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
#include<cstdio>
#include<cstring>
#include<math.h>
#include<algorithm>
using namespace std;
#define ll long long
#define INF 2*1000000000
ll a[200010];
ll sum,sum1,sumw;
int main()
{
     int i,j,k,n,m;
     sum=0;
     scanf("%d",&n);
     for(i=0;i<n;i++)
     {
          scanf("%lld",&a[i]);
          sum+=a[i];
     }
     sumw=INF;
     sum1=0;
     for(i=0;i<n-1;i++)
     {
          sum1+=a[i];
          long long x=sum-sum1-sum1;
          if(x<0)
               x=-x;
          if(x<sumw)
               sumw=x;
     }
     printf("%lld\n",sumw);
     return 0;
}


Measured memory_bytes: 1792
#include <cmath>
#include <cstdlib>
#include <cstdio>

#include <iostream>
#include <vector>
#include <algorithm>

int main() {
  double a, b, c, d, e, f; 
  double x, y;

  while( std::cin >> a >> b >> c >> d >> e >> f ) {   
    x = (c * e - b * f) / (a * e - b * d);
    y = (c * d - a * f) / (b * d - a * e);

    x = (double)(long)(x*1000);
    y = (double)(long)(y*1000);

    x /= 1000;
    y /= 1000;    

    printf("%.03lf %.03lf\n", x, y); 
  }

  return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
int N,K;
vector<int> A;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N>>K;
    A.resize(N);
    int m;
    rep(i,0,N){
        cin>>A[i];
        if(A[i]==1) m=i;
    }
    int ans=(N-1+K-2)/(K-1);
    cout <<ans<<"\n";
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;

char str[100005];

int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);
    scanf("%s", str);

    map<char, long> zz;
    long i;
    for(i=0; i<n; i++) {
        zz[str[i]]++;
    }

    ll ans=1;
    auto it=zz.begin();
    for(; it!=zz.end(); ++it) {
        ans = ans * (it->second +1) %MOD;
    }
    printf("%lld\n", ans-1);

    return 0;
}


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

int main() {
  int n,k,ans = (int)1e9+1;
  cin >> n >> k;
  vector<int>h(n);
  for(int i = 0;i < n;i++) cin >> h[i];
  sort(h.begin(),h.end());
  for(int i = 0;i < n-k+1;i++) if(h[i+k-1]-h[i] < ans) ans = h[i+k-1]-h[i];
  cout << ans << endl;
}


Measured memory_bytes: 768
//https://atcoder.jp/contests/dp/tasks/dp_g
//shauryakr
#include<bits/stdc++.h>
using namespace std;
vector<int> v[100010];
int inDegrees[100010];
int dist[100010];
int visited[100010];
void dfs(int node)
{
    if(visited[node])
        return;
    visited[node] = 1;
    for(int child:v[node])
    {
        dist[child] = max(dist[child], dist[node] + 1);
        inDegrees[child]--;
        if(inDegrees[child] == 0)
        {
            dfs(child);
        }
    }
}

int main()
{
    int n, m;
    cin >> n >> m;
    for(int i=0; i<m; i++)
    {
        int a, b;
        cin >> a >> b;
        v[a].push_back(b);
        inDegrees[b]++;
    }

    for(int i=1; i<=n; i++)
    {
        if(!visited[i] && inDegrees[i] == 0)
            dfs(i);
    }
    int ans = 0;
    for(int i=1; i<=n; i++)
    {
        ans = max(ans, dist[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9984
n = int(input())
h = list(map(int,input().split()))
count = 0
ans = 0
for i in range(1,n):
    if h[i-1] >= h[i]:
        count += 1
    else:
        ans = max(ans,count)
        count = 0
ans = max(ans,count)
print(ans)

Measured memory_bytes: 20296
n=str(input())

# print(n[-1])

if n[-1]==str(3):print('bon')
elif n[-1]==str(0):print('pon')
elif n[-1]==str(1):print('pon')
elif n[-1]==str(6):print('pon')
elif n[-1]==str(8):print('pon')
else:print('hon')

Measured memory_bytes: 9120
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    cout << max(max(a * 10 + b + c, b * 10 + a + c), c * 10 + a + b) << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

long long n;

int main(void) {
  scanf("%lld", &n);
  if (n%2 == 1) {
    puts("0");
    return 0;
  }
  long long res = 0;
  long long b = 5;

  while (n >= b) {
    res += n/b - (n+b-1)/b/2;
    b *= 5;
  }
  
  printf("%lld\n", res);
  return 0;
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
#pragma endregion

void solve() {
    int n;
    cin >> n;
    vector<pair<int, int>> point(n);
    for (int i=0; i<n; i++) {
        cin >> point.at(i).first >> point.at(i).second;
    }
    double low = 0.0, high = 1500.0;
    for (int i=0; i<50; i++) {
        double r = (low + high) / 2.0;
        vector<tuple<double, double, int, int>> ps;
        for (int j=0; j<n; j++) {
            for (int k=j+1; k<n; k++) {
                double dis = sqrt(pow(point.at(j).first - point.at(k).first, 2) + pow(point.at(j).second - point.at(k).second, 2));
                if (dis > 2 * r) continue;
                double h = sqrt(pow(r, 2) - pow(dis / 2.0, 2));
                double x = (point.at(j).first + point.at(k).first) / 2.0, y = (point.at(j).second + point.at(k).second) / 2.0;
                int xx = point.at(j).first - point.at(k).first, yy = point.at(k).second - point.at(j).second;
                double theta = atan2(xx, yy);
                ps.push_back(make_tuple(x + h * cos(theta), y + h * sin(theta), j, k));
                ps.push_back(make_tuple(x - h * cos(theta), y - h * sin(theta), j, k));
            }
        }
        bool found = false;
        for (auto p : ps) {
            double x = get<0>(p), y = get<1>(p);
            int c1 = get<2>(p), c2 = get<3>(p);
            bool ok = true;
            for (int j=0; j<n; j++) {
                if (j == c1 || j == c2) continue;
                double dis = sqrt(pow(x - point.at(j).first, 2) + pow(y - point.at(j).second, 2));
                if (dis > r) {
                    ok = false;
                    break;
                }
            }
            if (ok) {
                found = true;
                break;
            }
        }
        if (found) high = r;
        else low = r;
    }
    cout << low << "\n";
}

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

    solve();

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main() {
	/*int a;
	string s;
	cin >> a >> s;
	if (a >= 3200)cout << s;
	else cout << "red";*/

	int n;
	cin >> n;
	double a, ans = 0;
	rep(i, n) {
		cin >> a;
		ans += 1 / a;
	}
	cout << setprecision(20) << 1 / ans;
	return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}

void solve() {
    int a, b, k; cin >> a >> b >> k;
    for (int i = a; i < a+k && i <= b; ++i) {
        cout << i << '\n';
    }
    for (int i = max(b-k+1, a+k); i <= b; ++i) {
        cout << i << '\n';
    }
}

int main() {
    init();
    int t = 1; //scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

struct Graph
{
  int cost;
  vector<int> to;
};

Graph graph[200010];
bool checked[200010];

void dfs(int x, int y)
{
  graph[y].cost += graph[x].cost;
  x = y;
  for (int i = 0; i < graph[x].to.size(); ++i)
  {
    int y = graph[x].to[i];
    if (checked[y])
      continue;
    checked[y] = true;
    dfs(x, y);
  }
}

int main()
{
  long long N;
  scanf("%lld", &N);
  long long Q;
  scanf("%lld", &Q);
  for (int i = 0; i < N - 1; i++)
  {
    int a, b;
    scanf("%d", &a);
    scanf("%d", &b);
    a--;
    b--;
    graph[a].to.push_back(b);
    graph[b].to.push_back(a);
  }
  for (int i = 0; i < Q; i++)
  {
    int p, x;
    scanf("%d", &p);
    scanf("%d", &x);
    p--;
    graph[p].cost += x;
  }
  checked[0] = true;
  for (int i = 0; i < graph[0].to.size(); ++i)
  {
    int j = graph[0].to[i];
    if (checked[j])
      continue;
    checked[j] = true;
    dfs(0, j);
  }
  for (int i = 0; i < N; ++i)
    cout << graph[i].cost << " \n"[i == N - 1];

  return 0;
}


Measured memory_bytes: 24448
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>
#include <iterator>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

const int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;


int N, M, K;

long long power_mod(long long x, long long n, long long m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return power_mod(x * x % m, n / 2, m);
	else
		return x * power_mod(x, n - 1, m) % m;
}

vector<int>v;
int aa[200020], bb[200020], tt[200020];
multiset<int>st;
signed main() {

	int Q; cin >> Q;
	REP(i, Q) {
		cin >> tt[i];
		if (tt[i] == 1) {
			cin >> aa[i] >> bb[i];
		}
	}

	int B = 0;
	//int t, a, b; cin >> t >> a >> b;
	B += bb[0];
	st.insert(aa[0]);
	ll sm = 0;
	int med = aa[0];
	auto itr = st.find(med);

	FOR(i, 1, Q) {
		if (tt[i] == 2) {
			pe(med); print(sm + B);
		}
		else {
			int a = aa[i], b = bb[i];
			B += b;
			int x = a;
			if (st.size() % 2 == 1) {
				//左にずれる
				if (x < med) {
					st.insert(x);
					itr--;
					sm += abs(med - x);
					med = *itr;
				}
				//ずれない
				else if (x == med) {
					st.insert(x);
					med = *itr;
				}
				//ずれない
				else {
					st.insert(x);
					sm += abs(med - x);
				}
			}
			else {
				//ずれない
				if (x < med) {
					st.insert(x);
					sm += abs(med - x);
					med = *itr;
				}
				//ずれない
				else if (x == med) {
					st.insert(x);
					itr++; med = *itr;
				}
				//右にずれる
				else {
					auto itr2 = itr; itr2++;
					int med2 = *itr2;					

					if (x <= med2) {
						st.insert(x);
						itr++;
						med = *itr;
					}
					else {
						int d = med2 - med;
						int N = st.size();
						sm += d * (N / 2 - 1);
						sm -= d * (N - 1 - N / 2);
						sm += abs(med2 - x);
						st.insert(x);
						itr++;
						med = *itr;
					}
				}
			}
		}
	}
}


Measured memory_bytes: 14336
#include <iomanip>
#include <stdio.h>
#include <math.h>
using namespace std;

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

int lcm(int a,int b){
	int max_common = gcd(a,b);
	return (a/max_common)*b;
}

int main(){
    long long a, b;

	while(scanf("%lld %lld",&a,&b)!=EOF){
		printf("%lld %lld\n",gcd(a,b),lcm(a,b));
	}

    return 0;
}



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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	string s; cin>>s;
	int i=1;
	while(i<s.size()&&s.at(i-1)!=s.at(i))++i;
	if(i==s.size()){
		i=2;
		while(i<s.size()&&s.at(i-2)!=s.at(i))++i;
		if(i<s.size())cout<<i-1<<" "s<<i+1<<"\n"s;
		else cout<<"-1 -1\n"s;
		return 0;
	}
	cout<<i<<" "s<<i+1<<"\n"s;
}

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

int main(){
  int n;cin>>n;
  double ans=0,money;
  string s;
  REP(i,n){
    cin>>money>>s;
    if(s=="JPY") ans+=money;
    else ans+=money*380000;
  }
  cout<<ans;
}

Measured memory_bytes: 256
#pragma GCC optimize "03"
#include "bits/stdc++.h"
using namespace std;
 
#define ll long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;
 
int deg[N], dp[N];
vector<int> g[N];

signed main() {
	IOS;
	#ifdef LOCAL
		freopen("input.txt","r", stdin);
		freopen("output.txt","w",stdout);
	#endif
	int n, m;
	cin >> n >> m;
	for(int i = 1; i <= m; i++){
		int u, v;
		cin >> u >> v;
		g[u].push_back(v);
		deg[v]++;
	}	
	queue<int> q;
	for(int i = 1; i <= n; i++){
		if(deg[i] == 0)
			q.push(i);
	}
	int ans = 0;
	while(!q.empty()){
		int x = q.front();
		q.pop();
		ans = max(ans, dp[x]);
		for(auto i: g[x]){
			if(dp[i] <= dp[x] + 1){
				deg[i]--;
				if(deg[i] == 0)
					q.push(i);
				dp[i] = dp[x] + 1;
			}
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 6528
//Author : Vipul Sharma

// LIBRARIES
#include <bits/stdc++.h>

// MACROS
#define rep(i, a, b) for (i = a; i < b; i++)
#define itrep(at) for (auto it = at.begin(); it != at.end(); it++)
#define ll long long int
#define ld long double
#define pb push_back
#define w(t) while (t--)
#define booster                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
#define mod 1000000007
#define endl "\n"
#define deb1(x) cout << #x << " : " << x << endl;
#define deb2(x, y) cout << #x << " : " << x << "\t" << #y << " : " << y << endl;
#define deb3(x, y, z) cout << #x << " : " << x << "\t" << #y << " : " << y << "\t" << #z << " : " << z << endl;
#define deb4(x, y, z, w) cout << #x << " : " << x << "\t" << #y << " : " << y << "\t" << #z << " : " << z << "\t" << #w << " : " << w << endl;
#define deb5(a, b, c, d, e) cout << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define deb6(a, b, c, d, e, f) cout << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

using namespace std;
long long cost = 1e18;
// FUNCTIONS
ll power(ll a, ll n)
{
    ll res = 1;
    while (n)
    {
        if (n & 1)
        {
            res *= a;
            n--;
        }
        else
        {
            a *= a;
            n >>= 1;
        }
    }
    return res;
}

struct cmp
{

    bool operator()(const pair<int, int> &a, const pair<int, int> &b)
    {
        int l1 = a.second - a.first + 1;
        int l2 = b.second - b.first + 1;
        if (l1 == l2)
            return a.first < b.first;
        return l1 > l2;
    }
};

bool visited[100005];
ll path[100005];
vector<ll> adj[100005];
queue<ll> que;

//MAIN
int main()
{
    booster;
    ll n, m, i;
    bool flag = true;
    cin >> n >> m;
    memset(visited, false, sizeof(visited));
    while (m--)
    {
        ll x, y;
        cin >> x >> y;
        adj[x].push_back(y);
        adj[y].push_back(x);
        if (x == 1 || y == 1)
            flag = false;
    }
    if (flag)
    {
        cout << "No" << endl;
        return 0;
    }

    que.push(1);

    while (!que.empty())
    {
        ll cur = que.front();
        que.pop();
        if (!visited[cur])
        {

            visited[cur] = true;

            for (i = 0; i < adj[cur].size(); i++)
            {
                que.push(adj[cur][i]);

                if (path[adj[cur][i]] == 0)
                    path[adj[cur][i]] = cur;
            }
        }
    }

    cout << "Yes" << endl;
    for (i = 2; i <= n; i++)
        cout << path[i] << endl;

    return 0;
}

Measured memory_bytes: 14524
#include<bits/stdc++.h>
using namespace std;
int main() {
  vector<vector<int>> a(3,vector<int>(3));
  vector<vector<int>> c(3,vector<int>(3));
  int n,i,j,k;
  for (i=0;i<3;i++) {
    for (j=0;j<3;j++) cin>>a.at(i).at(j);
  }
  cin>>n;
  vector<int> b(n);
  for (k=0;k<n;k++) {
    cin>>b.at(k);
    for (i=0;i<3;i++) {
      for (j=0;j<3;j++) {
        if(b.at(k)==a.at(i).at(j)) {
          c.at(i).at(j)=1;
          i=3;j=3;
        }
      }
    }
  }
  if (c.at(0).at(0)==1 && c.at(0).at(1)==1 && c.at(0).at(2)==1) cout<<"Yes"<<endl;
  else if (c.at(1).at(0)==1 && c.at(1).at(1)==1 && c.at(1).at(2)==1) cout<<"Yes"<<endl;
  else if (c.at(2).at(0)==1 && c.at(2).at(1)==1 && c.at(2).at(2)==1) cout<<"Yes"<<endl;
  else if (c.at(0).at(0)==1 && c.at(1).at(0)==1 && c.at(2).at(0)==1) cout<<"Yes"<<endl;
  else if (c.at(0).at(1)==1 && c.at(1).at(1)==1 && c.at(2).at(1)==1) cout<<"Yes"<<endl;
  else if (c.at(0).at(2)==1 && c.at(1).at(2)==1 && c.at(2).at(2)==1) cout<<"Yes"<<endl;
  else if (c.at(0).at(0)==1 && c.at(1).at(1)==1 && c.at(2).at(2)==1) cout<<"Yes"<<endl;
  else if (c.at(0).at(2)==1 && c.at(1).at(1)==1 && c.at(2).at(0)==1) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(){
  int n,i,ax,ay,bx,by,x,y;
  double s;
  for(i=1;scanf("%d",&n),n;i++){
    scanf("%d %d %d %d",&ax,&ay,&bx,&by);
    s=0;
    for(n-=2;n;n--){
      scanf("%d %d",&x,&y);
      s+=((bx-ax)*(y-ay)-(by-ay)*(x-ax))/2.0;
      bx=x;
      by=y;
    }
    printf("%d %.1f\n",i,fabs(s));
  }
  return 0;
}

Measured memory_bytes: 636
import java.util.Scanner;
public class Main{

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

		int h = stdIn.nextInt(); //体力
		int n = stdIn.nextInt();
		
		int[] a = new int[n];
		
		long sum = 0;
		for(int i = 0; i < n; i++) {
			a[i] = stdIn.nextInt();
			sum += a[i];
		}
		
		if(sum < h) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}
		
		

	}

}


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

class omalbig{
    public:
        vector<int> rank,p;
        omalbig(){};
        omalbig(int size){
            rank.resize(size,0);
            p.resize(size,0);
            for(int i=0;i<size;i++){
                makeSet(i);
            }
            
        }
        bool same(int x,int y){
            return findSet(x) == findSet(y);
        }
        void makeSet(int X){
            p[X]=X;
            rank[X]=0;
        }
        void unite(int X,int Y){
            link(findSet(X),findSet(Y));
        }
        void link(int X,int Y){
            if(rank[X]>rank[Y]){
                p[Y]=X;
            }
            else{
                p[X]=Y;
                if(rank[X]==rank[Y]) rank[Y]++;
            }
        }
        int findSet(int x){
            if(x!=p[x]){
                p[x]=findSet(p[x]);
               
            }
             return p[x];
        }
};
int main(){
    int n,q;
    cin>>n>>q;
    omalbig omal=omalbig(n);
    
    int c,a,b;
    for(int j=0;j<q;j++){
        cin>>c>>a>>b;
        if(c==0){
            omal.unite(a,b);
        }
        else if(c==1){
            if(omal.same(a,b)){
                cout<<1<<endl;
            }
            else{
                cout<<0<<endl;
            }
        }
    }
   
}


Measured memory_bytes: 3176
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	int n, m;
	cin >> n >> m;
	priority_queue<int>que;
	rep(i, n) {
		int a;
		cin >> a;
		que.push(a);
	}
	rep(i, m) {
		int a = que.top();
		que.pop();
		a/= 2;
		que.push(a);
	}
	int ans = 0;
	while (!que.empty()) {
		int a = que.top();
		que.pop();
		ans += a;
	}
	print(ans);
}

Measured memory_bytes: 1400
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			String str = sc.next();
			if (str.equals("-"))
				break;
			int m = sc.nextInt();
			int sum = 0;
			int[] x = new int[m];
			for (int i = 0; i < m; i++) {
				x[i] = sc.nextInt();
				sum += x[i];
			}
			int a = sum % str.length();
			System.out.printf("%s%s\n", str.substring(a), str.substring(0, a));
		}
	}

}


Measured memory_bytes: 26260
import math
n,m=map(int, input().split())
def comb(n,r):
    return math.factorial(n) // (math.factorial(n-r) * math.factorial(r))
if n == 1 and m == 1:
    print(0)
elif n < 2 or m < 2:
    if n < 2:
        print(comb(m,2))
    else:
        print(comb(n,2))
else:
    n_comb = comb(n,2)
    m_comb = comb(m,2)
    print(n_comb+m_comb)



Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  lint A[N];
  REP(i,N)cin>>A[i];
  lint temp=1,ans=1;
  REP(i,N){
    if(A[i]==0){
      cout<<0<<endl;
      return 0;
    }
  }
  REP(i,N){
    ans*=A[i];
    if(ans<temp or ans>1000000000000000000LL){
      cout<<-1<<endl;
      return 0;
    }
    temp=ans;
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

double a,b,x;
const double EPS = 1e-9;
const double PI = acos(-1);

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

	cin >> a >> b >> x;
	double ang = atan(b/a);
	x /= a;
	double l = 0,r = 90;
	double res = 0;
	while(l - r <= EPS)
	{
		double mi = (r + l)/2;
		if (mi * PI / 180 - ang < EPS)
		{
			double S = a*b;
			double tmp = a*tan(mi * PI / 180);
			double S1 = (a * tmp)/2;	
			double z = S - S1;
			if (z - x >= EPS)
			{
				res = mi;
				l = mi + EPS;
			} 
			else
				r = mi - EPS; 
		}
		else
		{
			double tmp = b*tan((90 - mi) * PI / 180);
			double z = (tmp * b)/2;
			if (z - x >= EPS)
			{
				res = mi;
				l = mi + EPS;
			} 
			else
				r = mi - EPS;
		}
	}
	cout << setprecision(6) << fixed << res;
}

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

typedef long long ll;
typedef long double ld;
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353
#define Graph vector<vector<int>>

int main() {
    int N; cin >> N;
    if (N > 999) cout << "ABD" << endl;
    else cout << "ABC" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define N 100

int main(){
  int i,j,n,A[N],tmp,count=0,min;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  
  for(i=0;i<n;i++){
    min=i;
    for(j=i;j<n;j++){
      if(A[j]<A[min]){
	min=j;
      }
    }
    if(A[i]!=A[min]){
      tmp=A[i];
      A[i]=A[min];
      A[min]=tmp;
      count++;
    }
  }
  for(i=0;i<n;i++){
    printf("%d",A[i]);
    if(i<n-1)printf(" ");
  }
  printf("\n%d\n",count);
  return 0;
}

Measured memory_bytes: 604
# 1 "b.cpp"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "b.cpp"
# 1 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 1
       
# 12 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp"
# 1 "/home/tysm/dev/cpplib/bin/../stdlib/bits/stdc++.h" 1
 #include <bits/stdc++.h>
# 13 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 2
# 1 "/home/tysm/dev/cpplib/bin/../stdlib/ext/pb_ds/assoc_container.hpp" 1
 #include <ext/pb_ds/assoc_container.hpp>
# 14 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 2
# 1 "/home/tysm/dev/cpplib/bin/../stdlib/ext/pb_ds/tree_policy.hpp" 1
 #include <ext/pb_ds/tree_policy.hpp>
# 15 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 2







using namespace std;
using namespace __gnu_pbds;

using ii = pair<long long, long long>;
using vi = vector<long long>;
using vd = vector<long double>;
using vb = vector<bool>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vvd = vector<vd>;
using vvb = vector<vb>;
using vvii = vector<vii>;
# 50 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp"
inline long long mod(const long long n, const long long m = ((long long)1e9+7)){
    return (n%m + m)%m;
}

/**
 * Euclidean GCD.
 *
 * Time Complexity: O(log(min(a, b))).
 * Space Complexity: O(log(min(a, b))).
 */
long long gcd(const long long a, const long long b){
    if(a < 0 or b < 0)
        return gcd(abs(a), abs(b));
    if(a == 0)
        return b;
    return gcd(b%a, a);
}

/**
 * Euclidean derivated LCM.
 *
 * Time Complexity: O(log(min(a, b))).
 * Space Complexity: O(log(min(a, b))).
 */
long long lcm(const long long a, const long long b){
    // same as a*b/gcd(a, b) but avoiding overflow.
    return a/gcd(a, b)*b;
}
# 2 "b.cpp" 2

int32_t main(){
    (ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL));
    long long n, k;
    cin >> n >> k;
    vi arr(n);
    for(long long &i:arr)
        cin >> i;
    vi dp(n);
    for(long long i=1; i<n; ++i){
        dp[i] = dp[i-1] + abs(arr[i] - arr[i-1]);
        for(long long j=2; j<=k and i-j>=0; ++j)
            dp[i] = min(dp[i], dp[i-j] + abs(arr[i] - arr[i-j]));
    }
    cout << dp[n-1] << "\n";
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;

int main(){
  int a, b, c;
  int N, ans = 0;
  cin >> N;
  vector<int> l(N);
  for(int i = 0; i < N; i++) cin >> l.at(i);
  
  sort(l.begin(), l.end()/*, [](int l, int r)->bool{
    return l > r;
  }*/);
  
  for(int i = 0; i < N-2; i++){
    a = l.at(i);
    for(int j = i+1; j < N-1; j++){
      b = l.at(j);
      c = l.at(j+1);
      if(b >= c+a) continue;
      for(int k = j+1; k < N; k++){
        c = l.at(k);
        if(c >= a+b) break;
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int x,y;
  int ans=0;
  scanf("%d %d",&x,&y);
  if(x==1) ans+=300000;
  else if(x==2) ans+=200000;
  else if(x==3) ans+=100000;

  if(y==1) ans+=300000;
  else if(y==2) ans+=200000;
  else if(y==3) ans+=100000;
  
  if(x==1 && y==1) ans+=400000;
  
  printf("%d",ans);
  
  return 0;
}

Measured memory_bytes: 128
#グラフの連結成分を調べる
def Graph(ab):
    G=[[] for i in range(n)]
    for a,b in ab:
        G[a-1].append(b)
        G[b-1].append(a)
    return G
from collections import deque
def dfs(G,point,v,p):
    q=deque()
    q.append((v,p,0))

    while q:
        V,P,S=q.pop()
        if S==0:
            for new_v in G[V-1]:
                if new_v==P:continue
                point[new_v - 1] += point[V - 1]
                q.append((new_v,V,0))

n, q = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(n - 1)]
G = Graph(ab)

point = [0] * n
for i in range(q):
    p, x = map(int,input().split())
    point[p - 1] += x

dfs(G, point, 1, -1)
print(*point)

Measured memory_bytes: 89176
#include<bits/stdc++.h>
using namespace std;
main(){
        string str;
        long long k,n=0,i=0;
        cin>>str>>k;
        while(i<str.size())
                if(str[i]-'0'==1)
                        n++,i++;
                else break;
        if(k<=n){cout<<1;return 0;}
        cout<<str[i];
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int A = scan.nextInt();
        int B = scan.nextInt();
        int ans = A * B;
        System.out.println(ans);
    }
}


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

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

    s = input().rstrip()
    if s=='Sunny':
        print('Cloudy')
    if s=='Cloudy':
        print('Rainy')
    if s=='Rainy':
        print('Sunny')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define rev(v) reverse(v.begin(), v.end())
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v)cout<<i<<' '; cout << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
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 (a > b) { a = b; return 1; } return 0; }
int dx[] = { 0, 0, -1, 1 };
int dy[] = { 1, -1, 0, 0 };
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(15);

	int N;
	cin >> N;
	int digit = N % 10;
	if (digit == 0 || digit == 1 || digit == 6 || digit == 8) {
		cout << "pon";
	}
	else if (digit == 3) {
		cout << "bon";
	}
	else  {
		cout << "hon";
	}

	return 0;
}


Measured memory_bytes: 3600
#!/usr/bin/env python3
import sys


def solve(n: int):
    ret = ''
    for i in range(len(n)):
        if n[i] == '1':
            ret += '9'
        else:
            ret += '1'
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = str(next(tokens))  # type: int
    solve(n)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main(){
    ll ans = 0;
    rep(i,2){
        cin>>A>>B;
        ans += min(A,B);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256