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

typedef pair <int, int> ii;

const int Maxm = 605;
const int Maxn = 3000005;

int sqr[Maxn];
int n, d1, d2;
vector <ii> delt1, delt2;
vector <ii> neigh1[Maxm][Maxm], neigh2[Maxm][Maxm];
int col1[Maxm][Maxm], col2[Maxm][Maxm];
vector <ii> colec[4];

bool Inbounds(int r, int c) { return 0 <= r && r < 2 * n && 0 <= c && c < 2 * n; }

void Traverse(ii v, int cand, vector <ii> neigh[][Maxm], int col[][Maxm])
{
	if (col[v.first][v.second] != -1) return;
	col[v.first][v.second] = cand;
	for (int i = 0; i < neigh[v.first][v.second].size(); i++)
		Traverse(neigh[v.first][v.second][i], 1 - cand, neigh, col);
}

int main()
{
	fill(sqr, sqr + Maxn, -1);
	for (int i = 0; i * i < Maxn; i++)
		sqr[i * i] = i;
	cin >> n >> d1 >> d2;
	for (int i = 0; i * i <= d1; i++)
		if (sqr[d1 - i * i] != -1) {
			int j = sqr[d1 - i * i];
			for (int a = -1; a <= 1; a += 2) if (a == -1 || i != 0)
				for (int b = -1; b <= 1; b += 2) if (b == -1 || j != 0)
					delt1.push_back(ii(a * i, b * j));
		}
	for (int i = 0; i * i <= d2; i++)
		if (sqr[d2 - i * i] != -1) {
			int j = sqr[d2 - i * i];
			for (int a = -1; a <= 1; a += 2) if (a == -1 || i != 0)
				for (int b = -1; b <= 1; b += 2) if (b == -1 || j != 0)
					delt2.push_back(ii(a * i, b * j));
		}
	for (int i = 0; i < 2 * n; i++)
		for (int j = 0; j < 2 * n; j++) {
			for (int z = 0; z < delt1.size(); z++)
				if (Inbounds(i + delt1[z].first, j + delt1[z].second))
					neigh1[i][j].push_back(ii(i + delt1[z].first, j + delt1[z].second));
			for (int z = 0; z < delt2.size(); z++)
				if (Inbounds(i + delt2[z].first, j + delt2[z].second))
					neigh2[i][j].push_back(ii(i + delt2[z].first, j + delt2[z].second));
			col1[i][j] = col2[i][j] = -1;
		}
	for (int i = 0; i < 2 * n; i++)
		for (int j = 0; j < 2 * n; j++) {
			Traverse(ii(i, j), 0, neigh1, col1);
			Traverse(ii(i, j), 0, neigh2, col2);
			colec[col1[i][j] | col2[i][j] << 1].push_back(ii(i, j));
		}
	int i = 0;
	while (colec[i].size() < n * n) i++;
	for (int j = 0; j < n * n; j++)
		printf("%d %d\n", colec[i][j].first, colec[i][j].second);
	return 0;
}

Measured memory_bytes: 196860
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<iosfwd>
#include<sstream>
#include<math.h>
#define N 100
using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    if((n+1)/2 >= k) cout << "YES" << "\n";
    else cout << "NO" << "\n";
}

Measured memory_bytes: 256
s=list(map(int,input().split()))
list=[]
i=0
p=abs(i+s[1])
for i in range(s[0]):
  list.append(i+s[1])
  if min(list)+s[1]==0:
    p=0
  else:
    if p>abs(i+s[1]):
      p=abs(i+s[1])
a=sum(list)
if a<0:
  print(a+p)
else:
  print(a-p)

Measured memory_bytes: 3064
#include <iostream>
#include<cstring>
#include<cmath>
#include <algorithm>
#include <vector>
using namespace std;
long long n;
int main()
{
  long long ans=0;
  cin>>n;
  long long a[n],b[n],c[n];
  for(long long i=0;i<n;i++)
    cin>>a[i]>>b[i]>>c[i];
  long long dp[n+1][3];
  dp[0][0]=dp[0][1]=dp[0][2]=0;
  dp[1][0]=a[0];
  dp[1][1]=b[0];
  dp[1][2]=c[0];
  for(long long i=2; i<=n;i++)
  {
    dp[i][0]=max(dp[i-1][1]+a[i-1],dp[i-1][2]+a[i-1]);
    dp[i][1]=max(dp[i-1][0]+b[i-1],dp[i-1][2]+b[i-1]);
    dp[i][2]=max(dp[i-1][0]+c[i-1],dp[i-1][1]+c[i-1]);
  }
  for(int i=0;i<=2;i++)
  ans=max(dp[n][i],ans);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4992
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
using namespace std;

#define A_MAX 100

typedef struct _order {
    int i;
    int buf[A_MAX];
} Order;

Order preorder;
Order inorder;
Order postorder;


int find(int *inorder, int id)
{
    int i = 0;
    while (1) {
        if (inorder[i] == id) return i;
        i++;
    }
}

void reconstruction(int left, int right)
{
//    printf("left %d right %d\n", left ,right);
    if (left >= right) return;

    int root = preorder.buf[preorder.i];
    int mid = find(inorder.buf, root);
//    printf("  root %d mid %d\n", root ,mid);
//    printf("  preorder.i %d %d\n", preorder.i, preorder.buf[preorder.i]);
    preorder.i++;
    reconstruction(left, mid);
    reconstruction(mid+1, right);
    postorder.buf[postorder.i++] = inorder.buf[mid];
//    printf("  postorder.i %d %d\n", postorder.i ,postorder.buf[postorder.i-1]);
}

int main() {
    int n;
    preorder.i = 0;
    inorder.i = 0;
    postorder.i = 0;

    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> preorder.buf[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> inorder.buf[i];
    }

    // input
    reconstruction(0, n);

    for(int i = 0; i < n-1; i++) {
        cout << postorder.buf[i] << " ";
    }
    cout << postorder.buf[n-1] << endl;

    return 0;
}



Measured memory_bytes: 3108
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main(void) {

	long long int N, K;
	cin >> N >> K;

	vector<long long int> H(N);
	for (long long int i = 0; i < N; i++) {
		cin >> H[i];
	}

	// Hをソートして大きい方からゼロにする(降順ソート)
	std::sort(H.begin(), H.end(), std::greater<long long int>());

	// 大きい方からK個ゼロにする
	for (long long int i = 0; i < N; i++) {
		if (i < K){
			H[i] = 0;
		}
	}

	// 結果計算
	long long int ans = 0;
	for (long long int i = 0; i < N; i++) {
		ans += H[i];	
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 1792
import math
from functools import reduce


def gcd(*numbers):
    return reduce(math.gcd, numbers)


K = int(input())

Sum = 0

for i in range(1, K + 1):
    for j in range(1, K + 1):
        for k in range(1, K + 1):
            Sum += gcd(i, j, k)

print(Sum)

Measured memory_bytes: 69788
#include <iostream>
using namespace std;
int main(void){
   int a,b,c,d,e,k;
   cin>>a;
   cin>>b;
   cin>>c;
   cin>>d;
   cin>>e;
   cin>>k;
   int P[10]={e-d,e-c,e-b,e-a,d-c,d-b,d-a,c-b,c-a,b-a};
   for(int i=0;i<10;i++){
       if(P[i]>k){
           cout<<":("<<endl;
           return 0;
       }
   }
   cout<<"Yay!"<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        String n = sc.nextLine();
        String str[] = new String[3];
        str = n.split("");
        int a[] = new int[3];
        for (int i = 0; i < 3; i++)
            a[i] = Integer.parseInt(str[i]);
        for (int i = 0; i < 3; i++) {
            if (a[i] == 1)
                a[i] = 9;
            else if (a[i] == 9)
                a[i] = 1;
        }
        System.out.println(String.valueOf(a[0]) + String.valueOf(a[1]) + String.valueOf(a[2]));
    }
}


Measured memory_bytes: 21844
#include <cstdio>

#pragma warning (disable : 4996)

#define MAX_A 100
#define MAX_B 100
#define MAX_C 100
#define MAX_N 1000

int a, b, c, d, n, p, q, r, s;

int ok[MAX_A + MAX_B + MAX_C], ca[MAX_N], cb[MAX_N], cc[MAX_N];

int main()
{
	while (true)
	{
		for (int i = 0; i < MAX_A + MAX_B + MAX_C; i++) { ok[i] = 2; }

		d = 0;

		scanf("%d", &a);
		scanf("%d", &b);
		scanf("%d", &c);

		if (a == 0 && b == 0 && c == 0) { break; }

		scanf("%d", &n);

		for (int i = 0; i < n; i++)
		{
			scanf("%d", &p);
			scanf("%d", &q);
			scanf("%d", &r);
			scanf("%d", &s);

			if (s == 1)
			{
				ok[p - 1] = 1;
				ok[q - 1] = 1;
				ok[r - 1] = 1;
			}
			else
			{
				ca[d] = p - 1;
				cb[d] = q - 1;
				cc[d] = r - 1;

				d++;
			}
		}

		for (int i = 0; i < d; i++)
		{
			for (int j = 0; j < d; j++)
			{
				if (ok[ca[j]] == 1 && ok[cb[j]] == 1) { ok[cc[j]] = 0; }
				if (ok[ca[j]] == 1 && ok[cc[j]] == 1) { ok[cb[j]] = 0; }
				if (ok[cb[j]] == 1 && ok[cc[j]] == 1) { ok[ca[j]] = 0; }
			}
		}

		for (int i = 0; i < a + b + c; i++)
		{
			printf("%d\n", ok[i]);
		}
	}

	return 0;
}

Measured memory_bytes: 2720
//   __                    .__              ________ .________ ________   ______  
//  |  | __  ____    ______|  |__   __ __  /  _____/ |   ____//   __   \ /  __  \ 
//  |  |/ /_/ __ \  /  ___/|  |  \ |  |  \/   __  \  |____  \ \____    / >      < 
//  |    < \  ___/  \___ \ |   Y  \|  |  /\  |__\  \ /       \   /    / /   --   \
//  |__|_ \ \___  >/____  >|___|  /|____/  \_____  //______  /  /____/  \______  /
//       \/     \/      \/      \/               \/        \/                  \/

#include<bits/stdc++.h>
#define range 100005
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ <<" "<<


using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

map<int,bool> m;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("test.txt","r",stdin);
	int n;
	cin>>n;
	for(int i=1;i<=9;i++)
		 for(int j=1;j<=9;j++)
		 	m[i*j] = true;
	if(m.find(n)!=m.end()){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdint>

using namespace std;

uintmax_t combination(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}

int main() {
  string s;
  cin >> s;
  cout << ((s.back()=='s') ? (s+"es") : (s+"s")) << endl;

}

Measured memory_bytes: 3612
t=input()
s=list(map(int,input().split()))
a=int(t)
list=[]
for i in range(a-1):
  if s[i]>=s[i+1]:
    list.append(1)
  else:
    list.append(0)
d=0
c=0
for i in range(a-1):
  if list[i]==1:
    c+=1
    d=max(d,c)
  else:
    c=0
print(d)

Measured memory_bytes: 14252
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int a,b,c,d,ma;
	cin>>a>>b>>c>>d;
	ma=max(a*b,c*d);
	cout<<ma<<endl;
	return 0;
}



Measured memory_bytes: 256
N = int(input())
L = sorted(list(map(int, input().split())))
ans = 0
for l1 in L:
    for l2 in L:
        for l3 in L:
            ans += (l1 !=l2) and (l2 != l3) and (l3 != l1) and (2*max(l1, l2, l3) < l1+l2+l3)
print(ans//6)


Measured memory_bytes: 68256
#include<iostream>
#include<algorithm>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  rep(i,s.size()){
    s[i] = (s[i]-'A'+n)%26 + 'A';
  }
  cout << s << endl;
}

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

const double PI=acos(-1.0);

int main() {
    int n, k;
    cin >> n >> k;
    
    ll ans = 0;
    rep(i, n) {
        if(i == 0) ans = k;
        else ans *= k - 1;
    }

    cout << ans << endl;

    return 0;
}

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

int main()
{
    int n; cin >> n;
    string s = to_string(n);
    for (char c: s) {
        if (c == '7') {
            cout << "Yes\n";
            return 0;
        }
    }
  cout << "No\n";
  return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
using matrix = vector<vector<uint>>;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const pii INI = {INT_MAX, -1};

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

    int a, b, c;
  	cin >> a >> b >> c;
  	cout << (b - a == c - b ? "YES" : "NO") << endl;
    return 0;
}


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

int main()
{
	int N, K;
	char s[100001];
	scanf("%d %d",&N,&K);
	scanf("%s",s);
	int ans = -1,num;
	int i;
	int ct = 1;
	int flag = 1;
	int zero_one_start[100001] = {0};
	
	for (i = 0;i < N;i++)
	{
		if (s[i] - '0' != flag)
		{
			zero_one_start[ct] = i;//0と１の先頭
			ct++;
			flag = 1 - flag;
		}
	}
	if (ct == 1)ans = N;
	zero_one_start[ct] = N;
	for (i = 1;i < ct;i++)
	{
		if (s[zero_one_start[i]] == '0')
		{
			num = zero_one_start[i+2*K>ct?ct:i+2*K] - zero_one_start[i - 1];
			if (ans < num)ans = num;
		}

	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 640
import java.util.* ;		

class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);		
		String s = in.nextLine();
		int result = 0;
		for (int i = 0; i < 6; i++) {
			if (s.charAt(i) == '1') {
				result++;
			}
		}
		System.out.println(result);
	}
}	

Measured memory_bytes: 21844
n,*as=$<.read.split.map &:to_i
hc={}
m=0
as.each{|e|
  t=hc[e]
  if t
    m+=t
    hc[e]=t+1
  else
    hc[e]=1
  end
}
as.each{|e|
  puts m-hc[e]+1
}

Measured memory_bytes: 30332
from copy import *
from sys import *
from math import *
import queue
from collections import defaultdict,Counter,deque

setrecursionlimit(1000000)


def main():
	n,k = map(int,input().split())
	h = list(map(int,input().split()))
	dp = [0]
	for i in range(1,n):
		count = k if i > k else i
		temp = []
		for j in range(1,count+1):
			temp.append(dp[i-j] + abs(h[i] - h[i-j]))
		dp.append(min(temp))
	print(dp[-1])


def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(m,n):
	x = max(m,n)
	y = min(m,n)
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	return y

class Queue():
	#競プロ用のQueue
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)

class Stack():
	#怯プロ用のStack
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)

main()

Measured memory_bytes: 63264
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong a, b;
llong wh, bl;
char mp[505][505];

int main() {
    for (int i = 0; i < 50; i++) {
        for (int j = 0; j < 100; j++) {
            mp[i][j] = '.';
        }
    }
    for (int i = 50; i < 100; i++) {
        for (int j = 0; j < 100; j++) {
            mp[i][j] = '#';
        }
    }

    for (int i = 1; i < 49; i += 2) {
        for (int j = 1; j < 99; j += 2) {
            mp[i][j] = '#';
            bl++;
        }
    }
    bl++;

    for (int i = 51; i < 99; i+= 2) {
        for (int j = 1; j < 99; j += 2) {
            mp[i][j] = '.';
            wh++;
        }
    }
    wh++;
    
    cin >> a >> b;

    for (int i = 0; i < 50; i++) {
        for (int j = 0; j < 100; j++) {
            if (mp[i][j] == '#' && bl > b) {
                mp[i][j] = '.';
                bl--;
            }
        }
    }
    for (int i = 50; i < 100; i++) {
        for (int j = 0; j < 100; j++) {
            if (mp[i][j] == '.' && wh > a) {
                mp[i][j] = '#';
                wh--;
            }
        }
    }

    cout << 100 << ' ' << 100 << endl;
    for (int i = 0; i < 100; i++) {
        cout << mp[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#define FOR(idx, begin, end) for(int idx = (int)(begin); idx < (int)(end); ++idx)

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

using namespace std;
typedef long long lint;

const int MOD = 100000007;
const int INF = 1 << 29;
const double EPS = 1e-9;


int main() {

	cin.tie(0);

	lint N, M;
	cin >> N >> M;

	lint ans = (2 * N < M) ? N + (M - 2 * N) / 4 : (M / 2);

	cout << ans;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public void DL() {
        Scanner s = new Scanner(System.in);
        int w = s.nextInt();
        int n = s.nextInt();
        int[][] list1 = new int[n][w + 1];
        int[][] list2 = new int[n][w + 1];

        for (int i = 0; i < n; i++) {
            String[] input = s.next().split(",");
            int in0 = Integer.parseInt(input[0]);
            int in1 = Integer.parseInt(input[1]);
            list1[i][in0] = in1;
            list2[i][in1] = in0;
        }

        int[] a = new int[w + 1];

        for (int i = 1; i <= w; i++) {
            int p = i;
            for (int j = 0; j < n; j++) {
                if (list1[j][p] != 0) {
                    p = list1[j][p];
                } else if (list2[j][p] != 0) {
                    p = list2[j][p];
                }
            }
            a[p] = i;
        }

        for (int i = 1; i <= w; i++) {
            System.out.println(a[i]);
        }

    }

    public static void main(String[] args) {
        Main main = new Main();
        main.DL();
    }
}


Measured memory_bytes: 26152
#include<bits/stdc++.h>
using namespace std;
#define fo(i,a,n) for(i=a;i<n;i++)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define sortrev(x) sort(all(x),greater<int>())
#define pi 3.1415926535897932384626

typedef pair<int,int> pii;
typedef pair<ll, ll> pl;
typedef vector<int>	vi;
typedef vector<ll>	vl;
typedef vector<pii>	vpii;
typedef vector<pl>	vpl;
typedef vector<vi>	vvi;
typedef vector<vl>	vvl;


const int mod = 100000007;
const int inf = 100000005;
const int N = 3e5, M = N;
ll i,j,n,m;


void solve() {
    char s;
    cin>>s;
    
    if(s>=65 && s<=91) cout<<"A\n";
    else cout<<"a\n";
}


int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    int t = 1;
    //cin >> t;
    while(t--) {
      solve();
    }

    return 0;
}




Measured memory_bytes: 3612
n = int(input())
xy = [[] for _ in range(n)]
for i in range(n):
  a = int(input())
  for j in range(a):
    x, y = map(int, input().split())
    x -= 1
    xy[i] += [[x, y]]
result = 0
for i in range(2**n):
  dic = {i:-1 for i in range(n)}
  flag = True 
  ans = 0
  for j in range(n):
    if (i>>j)&1:
      if dic[j] != -1 and dic[j] != 1:
        flag = False
        break
      dic[j] = 1
      for x, y in xy[j]:
        if dic[x] == -1:
          dic[x] = y 
        elif dic[x] != -1 and dic[x] != y:
          flag = False
          break
      if flag:
        ans += 1
    else:
      if dic[j] != -1 and dic[j] == 1:
        flag = False
        break
      dic[j] = 0
      """
      for x, y in xy[j]:
        if dic[x] == -1:
          dic[x] = 1-y 
        elif dic[x] != -1 and dic[x] == y:
          flag = False
          break
      """

  if flag:
    result = max(result, ans)

print(result)

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define x first
#define y second
#define Time (double)clock()/CLOCKS_PER_SEC
#define debug(x) std::cout << #x << ": " << x << '\n';

const int N = 1007;
const double INF = 1e18;
double dist[N];
bool used[N];

signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(20); 
    #endif

    vector <int> r(2);
    vector <ii> a(2);
    for (int i = 0; i < 2; ++i) {
        cin >> a[i].x >> a[i].y;
        r[i] = 0;
    }
    int n;
    cin >> n;
    n += 2;
    a.resize(n);
    r.resize(n);
    for (int i = 2; i < n; ++i)
        cin >> a[i].x >> a[i].y >> r[i];

    /*
    #ifdef HOME      
    debug(n);
    for (int i = 0; i < n; ++i) 
        cout << a[i].x << ' ' << a[i].y << ' ' << r[i] << endl;
    #endif
    */
            
    for (int i = 1; i < N; ++i)
        dist[i] = INF;

    auto dist_point = [&] (ii a, ii b) {
        return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
    };

    /*
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j)
            cout << dist_point(a[i], a[j]) << ' ';
        cout << endl;
    }
    */  
        

    for (int t = 0; t < n; ++t) {
        int u = -1;
        for (int i = 0; i < n; ++i) {
            if (!used[i] && dist[i] < INF) {
                if (u == -1 || dist[i] < dist[u])
                    u = i;
            }   
        }   
        if (u == -1)
            break;

        used[u] = 1;
        //cout << u << ' ' << dist[u] << endl;

        for (int v = 0; v < n; ++v) {
            dist[v] = min(dist[v], dist[u] + max(0., dist_point(a[u], a[v]) - r[u] - r[v]));
        }   

    }   
    cout << dist[1] << endl;
}


Measured memory_bytes: 3860
int main(void){
  int n;
  int v,j=0,i=0,k=0;
  scanf("%d",&n);
  int A[n];
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  for(i=0;i<n;i++){
    v=A[i];
    j=i-1;
    if(i>=1){
      for(k=0;k<n;k++){
	if(k==n-1){
	  printf("%d",A[k]);
	}else{
	  printf("%d ",A[k]);
	}
      }
      printf("\n");
    }
    while(j>=0 && A[j]>v){
      A[j+1]=A[j];
      j=j-1;
      A[j+1]=v;
    }
  }
  for(k=0;k<n;k++){
    if(k==n-1){
      printf("%d",A[k]);
    }else{
      printf("%d ",A[k]);
    }
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 2040
#float型を許すな
#numpyはpythonで
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,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

def ceil(x,y):
    return -((-x)//y)
#print(ceil(5,2))
n,a,b=MI()
hp=[I() for i in range(n)]
x=0
y=10**9+1
while x+1<y:
    mid=(x+y)//2
    count=0
    for i in range(n):
        count+=max(0,ceil(hp[i]-b*mid,a-b))
    #print(mid,end=" ")
    #print(count<=mid)
    if count<=mid:
        y=mid
    else:
        x=mid
print(y)
    

    
            
        
        
    
    
    
    

    
    


    
    

        
        
    


    

Measured memory_bytes: 72244
//19/01/2020
#include<bits/stdc++.h>

using namespace std;

#define debug printf("Debug\n");
#define ll long long
#define ull unsigned long long

#define pi acos(-1.0)
#define mod 1000000007

#define p_b(x) push_back(x)
#define m_p(x) make_pair(x,y)

#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define in_fre  freopen("in.txt", "r", stdin);
#define out_fre freopen("out.txt", "w", stdout);

struct Node{
    ll val,pos;
};
vector<ll>v;


int main(){
    _fastio
    ll n,m;
    cin>>n>>m;
    if(n==m) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;


    return 0;
}


Measured memory_bytes: 256
# C - Best-of-(2n-1)
class Combi():
    def __init__(self, N, mod):
        self.power = [1 for _ in range(N+1)]
        self.rev = [1 for _ in range(N+1)]
        self.mod = mod
        for i in range(2, N+1):
            self.power[i] = (self.power[i-1]*i) % self.mod
        self.rev[N] = pow(self.power[N], self.mod-2, self.mod)
        for j in range(N, 0, -1):
            self.rev[j-1] = (self.rev[j]*j) % self.mod

    def com(self, K, R):
        if K < R:
            return 0
        else:
            return ((self.power[K])*(self.rev[K-R])*(self.rev[R])) % self.mod

    def pom(self, K, R):
        if K < R:
            return 0
        else:
            return (self.power[K])*(self.rev[K-R]) % self.mod


mod = 10**9 + 7
combi = Combi(2*10**5, mod)
N, A, B, C = map(int, input().split())

X = 0
Y = (100-C)*pow(A+B, 2*N-1, mod)

for i in range(N, 2*N):
    X += pow(A+B, 2*N-1-i, mod)*i*combi.com(i-1, N-1)*(pow(A, N, mod)
                                                       * pow(B, i-N, mod)+pow(B, N, mod)*pow(A, i-N, mod))
    X %= mod
X *= 100
ans = X*pow(Y, mod-2, mod) % mod
print(ans)

Measured memory_bytes: 24676
#include <bits/stdc++.h>
     
#define pll pair <long long,long long>
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define vll vector <ll>
#define NFS ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl '\n'
#define M 1000000007   
using namespace std;
 
int main()
{
    NFS
 	ll k,n,sum=0;
 	cin>>n>>k;
 	ll a[n];
 	for(int i=0;i<n;i++)
 	{
 		cin>>a[i];		
 	}
 	sort(a,a+n);
 	for(int i=0;i<n-k;i++)
 	{
 		sum+=a[i];
 	}
 	cout<<sum;
    return 0;
}

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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    set<int> st;
    rep(i, n) {
        cin >> a.at(i);
        st.insert(a.at(i));
    }
    
    if (a.size() != st.size())
        puts("NO");
    else
        puts("YES");
    return 0;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using f80 = __float80;
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define pb push_back
#define rng(a) a.begin(),a.end()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define sz(x) (i64)(x).size()
#define bit(n) (1LL<<(n))
#define fi first
#define se second
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef vector<i64> vi;
typedef vector<vi> vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

i64 pow_mod(i64 n, i64 k, i64 m){
  i64 r = 1;
  for(;k;k>>=1){
    if(k&1) r=(r*n)%m;
    n=(n*n)%m;
  }
  return r;
}

void Main()
{
  i64 n;
  cin >> n;

  i64 ans = 0;
  for(int i=1;i<n+1;i+=2){
    i64 tmp=0;
    rep(j,1,i+1)
      if(i%j==0) tmp++;
    if(tmp==8) ans++;
  }
  cout << ans << endl;
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}


Measured memory_bytes: 256
import java.io.*;

public class Main {
	public static void main(String[] args)throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String str2[] = br.readLine().split(" ");
		long sum = 0;
		int tmp = 0;
		int max = -1000000;
		int min = 1000000;
		
		for(int i=0; i<n;i++) {
			tmp = Integer.parseInt(str2[i]);
			if(tmp>max) max = tmp;
			if(tmp<min) min = tmp;
			sum += tmp;
		}
		System.out.println(min + " " + max + " " + sum);
	}
}

Measured memory_bytes: 28396
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
typedef pair<int,int> P;
const int MOD = 1000000007;
const int INF = 1e9;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 
//#define int long long
//#define double long dounle

////////////////////////////////////////////////////////////////////
struct edge {
  int to, from, cost;
  edge(int to, int cost) : from(-1), to(to), cost(cost) {}
  edge(int from, int to, int cost) : from(from), to(to), cost(cost) {}
};
using edges = vector<edge>;
using graph = vector<edges>;
using matrix = vector<vector<int>>;
vector<int> dijkstra(int s, graph &g){
  vector<int> dist(g.size()+10, INF);dist[s] = 0;
  priority_queue<P, vector<P>, greater<P>> que;que.push(P(0,s));
  while(!que.empty()){
    P p = que.top();que.pop();
    int v = p.second;
    if(dist[v] < p.first)continue;
    rep(i, g[v].size()){
      edge e = g[v][i];
      if(dist[e.to] > dist[v] + e.cost){
        dist[e.to] = dist[v] + e.cost;
        que.push(P(dist[e.to], e.to));
      }
    }
  }
  return dist;
}

vector<int> bellman(int s, graph &g){
  vector<int> dist(g.size()+10, INF);dist[s] = 0;
  while(true){
    bool update = false;
    rep(i,g.size()){
      edges es = g[i];
      rep(j,es.size()){
        edge e = es[j];
        if(dist[e.from] != INF && dist[e.to] > dist[e.from] + e.cost){
          dist[e.to] = dist[e.from] + e.cost;
          update = true;
        }
      }
    }
    if(!update)break;
  }
  return dist;
}

vector<vector<int>> warshall(matrix &g){
  vector<vector<int>> dist(g.size()+10);
  rep(i,g.size()+10){
    dist[i].resize(g.size()+10);
    rep(j,g.size()+10)dist[i][j] = (g[i][j] ? g[i][j] : (i==j ? 0 : INF));
  }
  rep(k,g.size()){
    rep(i,g.size()){
      rep(j,g.size()){
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  return dist;
}
////////////////////////////////////////////////////////////////////

signed main(){
  int x,y;cin>>x>>y;
  int ans = 0;
  if(x == 1)ans += 300000;
  if(x == 2)ans += 200000;
  if(x == 3)ans += 100000;
  if(y == 1)ans += 300000;
  if(y == 2)ans += 200000;
  if(y == 3)ans += 100000;
  if(x == 1 && y == 1)ans += 400000;
  cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

std::vector<std::vector<int>> g;
std::string s;
int n, m, now = 0;

int main(){
	cin >> n >> m >> s; std::vector<int> a(m), b(m);
	std::vector<std::vector<int>> h(n, std::vector<int>(2, 0)); g.resize(n);
	for(int i = 0; i < m; i++) {
		cin >> a[i] >> b[i]; a[i]--; b[i]--;
		
		g[a[i]].push_back(b[i]);
		g[b[i]].push_back(a[i]);
		h[a[i]][s[b[i]] != 'A']++;
		h[b[i]][s[a[i]] != 'A']++;
	}
	
	std::queue<int> qu;
	std::vector<bool> used(n, false);
	for(int i = 0; i < n; i++) {
		if(!h[i][0] or !h[i][1]) {
			qu.push(i);
			used[i] = true;
		}
	}
	
	while(!qu.empty()) {
		auto p = qu.front(); qu.pop();
		
		for(auto e : g[p]) {
			if(used[e]) continue;
			h[e][s[p] != 'A']--;
			
			if(!h[e][0] or !h[e][1]) {
				qu.push(e);
				used[e] = true;
			}
		}
	}
	
	for(int i = 0; i < n; i++) if(h[i][0] and h[i][1]) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 22660
string = input()
array = string.split()
hp_t = int(array[0])
attack_t = int(array[1])
hp_a = int(array[2])
attack_a = int(array[3])

for i in range(100):
    hp_a -= attack_t
    if hp_a <= 0:
        print('Yes')
        break
    hp_t -= attack_a
    if hp_t <= 0:
        print('No')
        break
    

Measured memory_bytes: 9188
#include <iostream>
#include <assert.h>
#include <vector>

bool check_consistency(std::vector<bool>& res, std::vector<bool>& ans) {
  for (int32_t i = 1; i < (int32_t)ans.size() - 1; i++) {
    if (res[i] && ans[i]) res[i+1] = res[i-1];//sheep 'o'
    else if (res[i] && !ans[i]) res[i+1] = !res[i-1]; //sheep 'x'
    else if (!res[i] && ans[i]) res[i+1] = !res[i-1]; //wolf 'o'
    else res[i+1] = res[i-1]; //wolf 'x'
  }
  bool first_elem;
  if (res.back() && ans.back()) first_elem = *(res.end() - 2);//sheep 'o'
  else if (res.back() && !ans.back()) first_elem = !(*(res.end() - 2));//sheep 'x'
  else if (!res.back() && ans.back()) first_elem = !(*(res.end() - 2));//wolf 'o'
  else first_elem = *(res.end() - 2);//wolf 'x'

  if (first_elem != res[0]) {
    return false;
  } else {
    bool second_elem;
    if (res[0] && ans[0]) second_elem = res.back();//sheep 'o'
    else if (res[0] && !ans[0]) second_elem = !res.back(); //sheep 'x'
    else if (!res[0] && ans[0]) second_elem = !res.back(); //wolf 'o'
    else second_elem = res.back(); //wolf 'x'
    return (second_elem == res[1]);
  }
}

void dump_res(std::vector<bool>& res) {
  for (auto i : res) {
    char animal = i? 'S' :'W';
    std::cout << animal;
  }
  std::cout << std::endl;
  return;
}

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

  int32_t N;
  std::cin >> N;;
  std::vector<bool> ans_vect(N); // 'o': True
  for (int32_t i = 0; i< N; i++) {
    char tmp;
    std::cin >> tmp;
    ans_vect[i] = tmp == 'o'? true : false;
  }

  std::vector<bool> pattern(N); //Sheep: True, Wolf: False
  //pattern 1 ... patten[0] = Sheep, pattern[1] = sheep
  pattern[0] = true;
  pattern[1] = true;
  if (check_consistency(pattern, ans_vect)) {
    dump_res(pattern);
    return 0;
  }
  //pattern 2 ... patten[0] = Sheep, pattern[1] = wolf
  pattern[0] = true;
  pattern[1] = false;
  if (check_consistency(pattern, ans_vect)) {
    dump_res(pattern);
    return 0;
  }
  //pattern 3 ... patten[0] = wolf, pattern[1] = sheep
  pattern[0] = false;
  pattern[1] = true;
  if (check_consistency(pattern, ans_vect)) {
    dump_res(pattern);
    return 0;
  }
  //pattern 4 ... patten[0] = wolf, pattern[1] = wolf
  pattern[0] = false;
  pattern[1] = false;
  if (check_consistency(pattern, ans_vect)) {
    dump_res(pattern);
    return 0;
  }
  std::cout << -1 << std::endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e18)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))

class UnionFind{
public:
	vector<int> par,siz;
	//0-indexed
	UnionFind(int n){init(n);}
	void init(int n = 1) {
		par.resize(n);
		siz.resize(n,1);
		for (int i = 0; i < n; ++i) par[i] = i;
	}
	int root(int x = 1){
		if(par[x]==x)return x;
		return par[x] = root(par[x]);
	}
	void unite(int x = 1,int y = 1){
		x = root(x);
		y = root(y);
		if(x==y)return;
		if(siz[x]>siz[y]){
			siz[x] += siz[y];
			siz[y] = 0;
			par[y] = x;
		}else{
			siz[y] += siz[x];
			siz[x] = 0;
			par[x] = y;
		}
	}
	bool same(int x,int y){
		return root(x)==root(y);
	}
};


// なもりグラフ
// https://www.hamayanhamayan.com/entry/2019/08/25/090415

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N,H,W;
	ll ans = 0;
	cin >> N >> H >> W;
	UnionFind uf(H+W+6);
	priority_queue< pair<ll,P> > pq;
	FOR(i,0,N){
		int r,c,a;
		cin >> r >> c >> a;
		pq.push({a,{r,c}});
	}
	FOR(i,0,N){
		auto X = pq.top();
		int h = X.second.first;
		int w = X.second.second;
		int a = X.first;
		pq.pop();
		if(not uf.same(h,w+H)){
			ans += a;
			uf.unite(h,w+H);
		}else if(not uf.same(h,H+W+2)){
			ans += a;
			uf.unite(h,H+W+2);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 6388
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<cctype>
using namespace std;

int main() {
	string a, b, c;
	cin >> a >> b >> c;
	if (a.back() == b.front() && b.back() == c.front())
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	string s;
	cin >> s;
	int odd = 0, even = 0;
	int n = s.size();
	vector<int> res(n);
	rep (i, n - 1) {
	  if (s[i] == 'R' && s[i + 1] == 'L') {
		int pos = i + 2;
		while (pos < n && s[pos] == 'L') {
		  if (pos % 2) odd++;
		  else even++;
		  pos++;
		}
		if (i % 2) {
		  res[i] += odd + 1;
		  res[i + 1] += even + 1;
		} else {
		  res[i] += even + 1;
		  res[i + 1] += odd + 1;
		}
		i = pos - 1;
		odd = 0;
		even = 0;
	  } else {
		if (i % 2) odd++;
		else even++;
	  }
	}
	rep (i, n) {
	  cout << res[i];
	  if (i == n - 1) cout << endl;
	  else cout << " ";
	}
    
    return 0;
}



Measured memory_bytes: 3888
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;
int main(){


    int a=0;
    double d;
    string n,c="No";

    cin >> n;

    for(int i=0;i<n.size();i++){
      a+=n.at(i)-48;

    }
  if(a%9==0){
    c="Yes";
  }

  cout << c << endl;

}


Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    int n,hitcount,outcount,score;
    hitcount=0;
    outcount=0;
    score=0;
    cin>>n;
    for (int i=0;i<n;i++) {
        while(cin>>s) {
            if (s=="HIT") {
                hitcount++;
                if (hitcount==4) {
                    score++;
                    hitcount=3;
                }
            } else if (s=="HOMERUN") {
                score=score+hitcount+1;
                hitcount=0;
            } else if (s=="OUT") {
                outcount++;
                if (outcount==3) {
                    cout << score << endl;
                    score=0;
                    outcount=0;
                    hitcount=0;
                }
            }
        }
    }
}



Measured memory_bytes: 3160
N,K=map(int,input().split())
s=0
l=[]
L=[]
for i in range(N):
    h=int(input())
    l.append(h)
l=sorted(l)
for j in range(N-(K-1)):
    L.append(l[j+(K-1)]-l[j])
print(min(L))

Measured memory_bytes: 87332
#include <stdio.h>

int main(void){
    int m,d,ds=0,i;
    while(scanf("%d %d",&m,&d)!=EOF){
        if(m==0) break;
        ds=0;
        for(i=1;i<m;i++){
            if(i==2){
                ds+=29;
            }
            else if(i==4||i==6||i==9||i==11){
                ds+=30;
            }
            else{
                ds+=31;
            }
        }
        ds+=d;
        if(ds%7==5){
            printf("Monday\n");
        }
        else if(ds%7==6){
            printf("Tuesday\n");
        }
        else if(ds%7==0){
            printf("Wednesday\n");
        }
        else if(ds%7==1){
            printf("Thursday\n");
        }
        else if(ds%7==2){
            printf("Friday\n");
        }
        else if(ds%7==3){
            printf("Saturday\n");
        }
        else if(ds%7==4){
            printf("Sunday\n");
        }
    }
    return 0;
}

Measured memory_bytes: 584
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<cmath>
#include<cstring>
using namespace std;
#define maxn 1000010
#define llg int
#define yyj(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout);
llg n,m,c,k,ans;
llg a[maxn];
int main()
{
	//yyj("A");
	cin>>n>>c>>k;
	for (llg i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for (llg i=1;i<=n;i++)
	{
		llg x=i;
		llg res=c-1;
		while (res && a[x+1]<=a[i]+k)
		{
			x++; res--;
		}
		i=x;
		ans++;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
#define MAX_N 100000
const ll INF = 1LL << 60;
int N;
ll dp[MAX_N + 1];

int main() {
    cin >> N;
    int h[N + 1];
    for (int i = 0; i < N; i++) cin >> h[i];
    for (int i = 0; i < MAX_N; i++) dp[i] = INF;
    dp[0] = 0, dp[1] = abs(h[1] - h[0]);
    for (int i = 1; i < N; i++) {
        dp[i + 1] = min(dp[i] + abs(h[i + 1] - h[i]), dp[i - 1] + abs(h[i + 1] - h[i - 1]));
    }
    cout << dp[N - 1] << endl;
}

Measured memory_bytes: 1408
#include<stdio.h>
int main()
{
    int i,j;
    int c=1;
    char s[4];
    gets(s);
    for(i=0;i<4;i++){
            if((s[0]==s[1])||(s[1]==s[2])||(s[2]==s[3]))
            {
                c++;

            }
    }
    if(c>1)
        printf("Bad");
    else
        printf("Good");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;

int main(){
  int n,l;
  cin >> n >> l;
  int m = 1000000;
  int sum_taste = 0;
  rep(i,n){
    sum_taste += l + i;
    if(abs(m)>abs(l+i)){
      m = l+i;
    }
  }
  cout << sum_taste - m << endl;
}



Measured memory_bytes: 256
#include <iostream>
    #include <sstream>
    #include <vector>
    #include <cmath>
    #include <ctime>
    #include <cassert>
    #include <iomanip>
    #include <cstdio>
    #include <float.h>
    #include <queue>
    #include <set>
    #include <map>
    #include <fstream>
    #include <cstdlib>
    #include <string>
    #include <cstring>
    #include <algorithm>
    #include <numeric>
    #include <stack>
    #include <functional>
           
    using namespace std;
           
    #define endl '\n'
    #define MOD 1000000007
    #define INF 1ll<<30
     
    // #define MAX 100010
     
    #define eps 1e-11
    #define bit_max 1ll<<32
    #define _USE_MATH_DEFINES
     
    long long int fact[3000];
     
    void pre()
    {
        fact[0]=1;
        fact[1]=1;
        for(int i=2;i<2005;i++)
        {
            fact[i]= (fact[i-1]*i)%MOD;
        }
    }
     
    long long int poww(long long int a,long long int b)
    {
        if(b==0)
            return 1;
        long long int x = poww(a,b/2)%MOD;
        if(b%2==0)
        {
            return (x*x)%MOD;
        }
        else
        {
            return (((x*x)%MOD)*a)%MOD;
        }
    }

    map<int,int> m;

    int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        #ifndef ONLINE_JUDGE
            // freopen("input.txt","r",stdin);
            // freopen("output.txt","w",stdout);
        #endif
        int n,k,x,y;
        long long int ans = 0;
        cin>>n>>k>>x>>y;
        if(n>=k)
        {
            ans+=k*x;
            ans+=(n-k)*y;
        }
        else
        {
            ans+=n*x;
        }
        cout<<ans<<endl;
        return 0;
    }

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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MAX=2005;
const ll INF=0x3f3f3f3f;
const ll MOD=998244353;
ll T,A,B,C,D,ans;
ll gcd(ll x,ll y){
    if(y==0) return x;
    return gcd(y,x%y);
}
int main(){
    scanf("%lld",&T);
    for(ll test_case=0;test_case<T;test_case++){
        scanf("%lld%lld%lld%lld",&A,&B,&C,&D);
        if(B>D) ans=0;
        else if(B==D){
            ll t=max((A-C+B-1)/B,1ll);
            if(A>=B*t) ans=1;
            else ans=0;
        }
        else{
            ll t=max((A-C-1)/gcd(B,D),0ll);
            if(A-gcd(B,D)*t-B>=0) ans=1;
            else ans=0;
        }
        if(ans) printf("Yes\n");
        else printf("No\n");
    }
}


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

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

//#define _USE_MATH_DEFINES
//#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>
#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 1000000007; // 10000000000000007ll;

const double eps = 1e-8;

const i64 MAXN = 2'000'000 + 6;

i64 n, m;

i64 a[MAXN];

bool isp(string s) {
    string t = s;
    reverse(t.begin(), t.end());
    //cerr << s << " " << t << endl;
    return t == s;
}

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);


    i64 l;
    cin >> l;
    double R = l * l * l / 27.0;
    cout << R << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    N,Y = list(map(int,input().split()))

    flag = False

    loop_10000 = Y // 10000
    loop_5000 = Y // 5000
    loop_1000 = Y // 1000

    for i in range(loop_10000+1):
        for j in range(loop_5000+1):
            k = N - i - j
            if(k >= 0 and i+j+k == N and 10000 * i + 5000 * j + 1000 * k == Y):
                print(i,j,k)
                flag = True
                break
            #for k in range(loop_1000+1):
            #    if(i+j+k == N and 10000 * i + 5000 * j + 1000 * k == Y):
            #        print(i,j,k)
            #        flag = True
            #        break
            #if(flag):
            #    break
        if(flag):
            break
    if(not flag):
        print(-1,-1,-1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <stdio.h>

int		main()
{
	char	str[101];
	int		i;

	scanf("%s\n", str);
	i = 0;
	while ('a' <= str[i] && str[i] <= 'z')
	{
		str[i] = 'x';
		i++;
	}
	str[i] = '\0';
	printf("%s\n", str);
	return (0);
}


Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<functional>

using namespace std;


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

	int ans = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s.at(i) == '1') {
			ans++;
		}
	}

	cout << ans;

	return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;
 class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n,x = 0;
		int result[] = new int[100];
		while(true){
			n = sc.nextInt()/4;
			if(n == 0) break;
			for(int i = 0; i < n; i++){
				result[x] += sc.nextInt();
			}
			x++;
		}
		for(int i = 0; i < x; i++){
			System.out.println(result[i]);
		}
	}
}

Measured memory_bytes: 26240
#include<iostream>
#include<vector>
#include<set>
#include<iterator>
using namespace std;

int main(){
    vector<int>vec;
    set<int>s;
    int t,n;
    char c;
    while(cin>>t>>c>>n){
        if(t==0&&n==0)break;
        vec.push_back(n);
        s.insert(n);
    }
    while(cin>>t){
        long a=s.size()-distance(s.begin(),s.find(vec[t-1]));
        cout<<a<<endl;
    }
}

Measured memory_bytes: 1216