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

using namespace std;

#define int long long
#define ar array
#define vt vector
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)

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

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

template<class A>
void read(vt<A> &v);

template<class A, size_t S>
void read(ar<A, S> &a);

template<class T>
void read(T &x) {
    cin >> x;
}

void read(double &d) {
    string t;
    read(t);
    d = stod(t);
}

void read(long double &d) {
    string t;
    read(t);
    d = stold(t);
}

template<class H, class... T>
void read(H &h, T &... t) {
    read(h);
    read(t...);
}

template<class A>
void read(vt<A> &x) {
    EACH(a, x)read(a);
}

template<class A, size_t S>
void read(array<A, S> &x) {
    EACH(a, x)read(a);
}

string to_string(char c) {
    return string(1, c);
}

string to_string(bool b) {
    return b ? "true" : "false";
}

string to_string(const char *s) {
    return string(s);
}

string to_string(string s) {
    return s;
}

string to_string(vt<bool> v) {
    string res;
    FOR(sz(v))res += char('0' + v[i]);
    return res;
}

template<size_t S>
string to_string(bitset<S> b) {
    string res;
    FOR(S)res += char('0' + b[i]);
    return res;
}

template<class T>
string to_string(T v) {
    bool f = 1;
    string res;
    EACH(x, v) {
        if (!f)
            res += ' ';
        f = 0;
        res += to_string(x);
    }
    return res;
}

template<class A>
void write(A x) {
    cout << to_string(x);
}

template<class H, class... T>
void write(const H &h, const T &... t) {
    write(h);
    write(t...);
}

void print() {
    write("\n");
}

template<class H, class... T>
void print(const H &h, const T &... t) {
    write(h);
    if (sizeof...(t))
        write(' ');
    print(t...);
}

template<class T, class U>
void vti(vt<T> &v, U x, size_t n) {
    v = vt<T>(n, x);
}

template<class T, class U>
void vti(vt<T> &v, U x, size_t n, size_t m...) {
    v = vt<T>(n);
    EACH(a, v)vti(a, x, m);
}

void solve() {
    int k, s;
    read(k, s);
    int ans = 0;
    FOR(k + 1) {
        FOR(j, k + 1) {
            int x = s - i - j;
            if (x >= 0 && x <= k) {
                ans++;
            }
        }
    }
    
    print(ans);
}

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int tt = 1;
//    read(tt);
    FOR(tt) {
//        write("Case #", i + 1, ": ");
        solve();
    }
    
}



Measured memory_bytes: 3636
/**
 * Title:
 * Url:
 */
#include<bits/stdc++.h>

using namespace std;

#define ll long long

int main() {
    int n, m; cin >> n >> m;
    vector<vector<int>> t(n+1);
    vector<int> h(n+1);
    for(int i=1; i<=n; i++) cin >> h[i];
    for(int i=0; i<m; i++) {
        int ai, bi; cin >> ai >> bi;
        t[ai].push_back(bi);
        t[bi].push_back(ai);
    }
    int ans = 0;
    for(int i=1; i<=n; i++) {
        bool flag = true;
        for(auto ti:t[i]) {
            if(h[i]<=h[ti]) {
                flag = false;
                break;
            }
        }
        if(flag) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
#define mem(a,b) memset(a,b,sizeof(a))
#define shutdown ios::sync_with_stdio(false)
#define MAX 10e18+1000
#define INF 0x3f3f3f3f
#define FOR(x,k) for(int x=1;x<=k;x++)

struct ss{
    int locat;
    int len;
}slocat[100];

int main() {
    shutdown;
    mem(slocat,0);
    string s,t;
    int flag;
    cin>>s>>t;
    for(int i=s.length()-t.length();i>=0;i--){
        flag=1;
        for(int j=i,k=0;k<t.length();k++,j++){
            if(s[j]=='?');
            else if(s[j]==t[k]);
            else
                flag=0;
        }
        if(flag){
            for(int j=i,k=0;k<t.length();k++,j++) s[j]=t[k];
            for(int j=0;j<s.length();j++){
                if(s[j]=='?')
                    cout<<"a";
                else
                    cout<<s[j];
            }
            cout<<endl;
            return 0;
        }
    }
    cout<<"UNRESTORABLE"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<pii>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;

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

    int N, K, S, ma = 1e9;
    cin >> N >> K >> S;
    for (int i = 0; i < K; ++i)
        cout << S << " ";
    for (int i = K; i < N; ++i)
        cout << (S == ma ? ma - 1 : ma) << " ";
    cout << endl;

    return 0;
}


Measured memory_bytes: 1280
import math
import collections
import fractions
import itertools

def solve():
    n = int(input())
    a = list(map(int, input().split()))
    ruiseki = [0]
    ans = 0
    for i in range(n):
        ruiseki.append(ruiseki[i]+a[i])
    c = collections.Counter(ruiseki)
    for i in c:
        ans += (c[i]*(c[i]-1)//2)
    print(ans)
    return 0

if __name__ == '__main__':
    solve()

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

#define endl "\n"
#define all(x) x.begin(),x.end()
#define pb push_back
#define ff first 
#define ss second 
#define pii pair<int,int>
#define vi vector<int>
#define vc vector<char>
#define vii vector<pii>
#define vvi vector<vi>
#define fori(i,n) for(int i=1;i<=n;++i)
#define forn(i,n) for(int i=0;i<n;++i)
#define sz(x) int(x.size())
#define error(x) cout<<#x<<" "<<x<<endl
#define IOS  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const int N=100*1000;
const int mod=1e9+7;

int min3(int a,int b,int c){return min(a,min(b,c));}
int max3(int a,int b,int c){return max(a,max(b,c));}
int min4(int a,int b,int c,int d){return min(min(a,b),min(c,d));}
int max4(int a,int b,int c,int d){return max(max(a,b),max(c,d));}


int32_t  main(){
	IOS;
  int n,k;cin>>n>>k;
  if(k>(n-n/2))puts("NO");
  else{
    puts("YES");
  }

  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n,m,k,d,t,ar[31]={0}, i, count =0;
	scanf("%d %d", &n, &m);
	t=n;
	while(n--)
	{
		scanf("%d", &k);
		while(k--)
		{
			scanf("%d", &d);
			ar[d]++;
		}
	}
	for(i=1; i<=m; i++)
		if(ar[i]==t)
			count++;
	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var h, w int

	for {
		fmt.Scan(&h, &w)

		if h == 0 && w == 0 {
			break
		}

		for ih := 0; ih < h; ih++ {
			for iw := 0; iw < w; iw++ {
				fmt.Print("#")
			}
			fmt.Println()
		}

		fmt.Println()
	}
}



Measured memory_bytes: 1128
#include<stdio.h>
#define MAX 2000000

int size, A[MAX];

void maxHeapify(int);


int main(){
  
  int i;
  
  
  scanf("%d", &size);
  
  
  for ( i = 1; i <= size; i++ ) {

    scanf("%d", &A[i]);

  }
  
  for ( i = size/2; i >= 1; i-- ) maxHeapify(i);

  for ( i = 1; i <= size; i++ ) {
    
    printf(" %d", A[i]);

  }
  printf("\n");
  

  
  return 0;
}


void maxHeapify(int i){
  
  int l, r;
  int largest;
  int t;
  
  l = 2 * i;
  r = 2 * i + 1;

  if ( l <= size && A[l] > A[i] ) largest = l;
  else largest = i;
  if ( r <= size && A[r] > A[largest] ) largest = r;
  if ( largest != i ){
    
    t = A[i];
    A[i] = A[largest];
    A[largest] = t;

    maxHeapify(largest);
    
  }
}

Measured memory_bytes: 2552
import java.util.Scanner;	//Scannerクラス：Java標準入力を取得する

class Main {
	public static void main(String[] args){		//メソッド宣言
		try(Scanner sc = new Scanner(System.in)){
			for(;;) {
				int a = sc.nextInt();
				String op = sc.next();
				int b = sc.nextInt();
				int ans = 0;
				
				if(op.equals("?")) {
					break;
				}else if(op.equals("+")) {
					ans = a + b;
				}else if(op.equals("-")) {
					ans = a - b;
				}else if(op.equals("*")) {
					ans = a * b;
				}else if(op.equals("/")) {
					ans = a / b;
				}

				System.out.println(ans);
			}
		}
	}
}



Measured memory_bytes: 26364
xx = gets.to_i
hh = gets.to_i
until xx == 0 && hh == 0
 x = xx.to_f
 h = hh.to_f
 teihenn = x * x
 sokumennhigh = (h**2) + (x/2)**2
 sokumennhigh2 = sokumennhigh**(1/2.0) 
 sokumenn = x * sokumennhigh2 / 2
 sum = sokumenn * 4
 test = sum + teihenn
 puts sprintf("%.6f", test)
 xx = gets.to_i
 hh= gets.to_i
end


Measured memory_bytes: 6908
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static class Card {
		private String design;
		private int number;
		private int inputIndex;

		public Card(String design, int number, int inputIndex) {
			this.design = design;
			this.number = number;
			this.inputIndex = inputIndex;
		}

		public String getDesign() {
			return this.design;
		}

		public int getNumber() {
			return this.number;
		}

		public int getInputIndex() {
			return this.inputIndex;
		}
	}

	public static int partition(Card[] a, int p, int r) {
		Card tmp;

		int x = a[r].getNumber();
		int i = p - 1;

		for(int j = p; j < r; j++) {
			if (a[j].getNumber() <= x) {
				i = i + 1;
				tmp = a[i];
				a[i]= a[j];
				a[j] = tmp;
			}
		}

		tmp = a[i + 1];
		a[i + 1] = a[r];
		a[r] = tmp;

		return i + 1;
	}

	public static void quickSort(Card[] a, int p, int r ) {
		if(p < r) {
			int q = partition(a, p, r);
			quickSort(a, p, q - 1);
			quickSort(a, q + 1, r);
		}
	}


	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int cardOfNumber = Integer.parseInt(br.readLine());

		Card[] cards = new Card[cardOfNumber];

		for(int i = 0; i < cardOfNumber; i++) {
			String cardElement = br.readLine();
			String design = String.valueOf(cardElement.charAt(0));

			String cardElementSplit[] = cardElement.split(" ");
			int number = Integer.parseInt(cardElementSplit[1]);

			int index = i + 1;

			Card card = new Card(design, number, index);
			cards[i] = card;

		}

		/*
		------------------------------
		Scanner scan = new Scanner(new InputStreamReader(System.in));
		------------------------------

		int matrixLength = scan.nextInt();

		int[] a = new int[matrixLength];

		for(int i = 0; i < matrixLength; i++) {
		------------------------------
			a[i] = scan.nextInt();
		------------------------------
		}
		 */

		quickSort(cards, 0, cardOfNumber - 1);
		
		boolean isStable = true;
		for(int i = 0; i < cardOfNumber - 1; i++) {
			if(cards[i].getNumber() == cards[i + 1].getNumber()) {
				if(cards[i].getInputIndex() > cards[i + 1].getInputIndex()) {
					isStable = false;
					break;
				}
			}
		}
		if(isStable) {
			System.out.println("Stable");
		} else {
			System.out.println("Not stable");
		}
		
		for(int i = 0; i < cardOfNumber; i++) {
			System.out.print(cards[i].getDesign());
			System.out.print(" ");
			System.out.print(cards[i].getNumber());
			System.out.println();
		}
	}
}

Measured memory_bytes: 91876
local function query(i)
    print(i)
    io.flush()
    local a = io.read()
    if a == 'Vacant' then
        os.exit()
    else
        return a:sub(1,1)
    end
end

local function available(a, s_a, b, s_b)
    if a % 2 == b % 2 then
        return s_a ~= s_b
    else
        return s_a == s_b
    end
end

local N = io.read("n","l")
local left = 0
local right = N - 1
local s_left = query(left)
local s_right = query(right)
while true do
    local mid = (left + right) // 2
    local s_mid = query(mid)
    if available(left, s_left, mid, s_mid) then
        right = mid
        s_right = s_mid
    else
        left = mid
        s_left = s_mid
    end
end


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

int main() {
  int a,b,c,d,e;
  cin >> a;
  b = a/1000;
  c = (a%1000)/100;
  d = (a%100)/10;
  e = (a%10);
  if(b == c && c == d){
    cout << "Yes" << endl;
  }
  else if (c == d && c == e){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		String s = sc.next();
		int b = sc.nextInt();
		if (s.equals("-")) {
			b *= -1;
		}
		System.out.println(a + b);
	}
}


Measured memory_bytes: 21844
#include <iostream>

using namespace std;

int main() {
    int n, m, c;
    cin >> n >> m >> c;
    int b[m];
    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        int s = c;
        for (int j = 0; j < m; j++) {
            int a;
            cin >> a;
            s += a * b[j];
        }

        if (s > 0) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n,x = map(int,input().split())

if(x==1)|(x==2*n-1):
    print('No')
    exit()

if(n==2):
    print('Yes')
    print('\n'.join(map(str,[1,2,3])))
    exit()

m = 2*n-1
ans = list(range(1,m+1))
ans = ans + ans
center = m//2
if(x-1 < center):
    ans = ans[m+x-1-center : m+m+x-1-center]
else:
    ans = ans[x-1-center : m+x-1-center]

if not ((x==2)|(x==m-1)):
    ans[center-2],ans[center+2] = ans[center+2],ans[center-2]

print('Yes')
print('\n'.join(map(str,ans)))

Measured memory_bytes: 78100
'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf8');

// Your code here!
const max = (a)=>{
    let i = a.length;
    let max=-Infinity;
    while (i--) {
        if (a[i] > max)max = a[i];
    }
    return max;
}
const min = (a)=>{
    let i = a.length;
    let max=Infinity;
    while (i--) {
        if (a[i] < max)max = a[i];
    }
    return max;
}
const Main = (p)=>{
	p = p.split("\n");//2 or more
	//let N = parseInt(p[0]);//N
	const N = parseInt(p[0].split(" ")[0]);//N M
	const W = parseInt(p[0].split(" ")[1]);//N M
	//let h = (p[1].split(" ").map(Number));//a1 a2 a3...
	
	let w = new Array(N);
	let v = new Array(N);
	//let c=new Array(N);
    //let z=new Array(N);
    for(let i=0;i<N;i++){
        let h = (p[i+1].split(" ").map(Number));
        w[i]=h[0];
        v[i]=h[1];
    }
    
    const maxv=100000;
	let m = new Array(N+1);
    //console.log(N,W,w,v);return;
    m[0]=new Array(maxv+1).fill(Infinity);
    m[0][0]=0;
    for(let i=0;i<=N;i++){
        m[i+1]=m[i].concat();
        for(let j=0;j<=maxv;j++){
            if(j-v[i]>=0){
                //console.log(m[i][j-w[i]]+v[i],m[i][j])
                m[i+1][j]=Math.min(m[i][j-v[i]]+w[i],m[i][j]);
            }
            
        }
        //console.log(i,m[i])
    }
	//console.log(m[N][maxv-1]);
	let i=maxv;
	while(m[N][i--]>W);//console.log(m[N][i--]);
	console.log(i+1);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


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

template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar.size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}


int main(int argc, char const* argv[])
{
    string s;
    cin >> s;

    int k;
    cin >> k;

    vector<string> strs;
    for (int i = 0; i < s.size(); i++) {
        for (int j = 1; j <= 5; j++) {
            strs.push_back(s.substr(i, j));
        }
    }

    // printvector(strs);

    sort(strs.begin(), strs.end());
    strs.erase(unique(strs.begin(), strs.end()), strs.end());
    // printvector(strs);

    cout << strs[k-1] << endl;

    return 0;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	string s; cin >> s;
	if(s[2] != s[3] or s[4] != s[5]) {
		cout << "No" << '\n';
	} else {
		cout << "Yes" << '\n';
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define no cout<<"NO"<<endl;
#define pb push_back
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define mod 1000000007
#define f first
#define sec second
#define gcd(x,y) __gcd(x, y)
using namespace std;
int main()
{
	ll t;
	cin>>t;
	/*while(t--)
	{
		
	}*/
	cout<<t+t*t+t*t*t<<endl;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define MEM 100001
#define sanic ios_base::sync_with_stdio(0)
using namespace std;
typedef unsigned long long ull;
int n,m;
main()
{
    sanic; cin.tie(0);
    cin >> n >> m;
    for(int i=0,q; i<m; i++){
        cin >> q;
        n -= q;
    }
    cout << (n>=0 ? n:-1);
}


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

int main(void)
{
  int max, sum, n, i;
  int *num;

  scanf("%d", &n);

  while(n != 0){
    num = malloc(sizeof(int)*n);
    scanf("%d", &num[0]);
    sum = max = num[0];
    for(i = 1; i < n; i++){
      scanf("%d", &num[i]);
      if(max < num[i]) max = num[i];
      sum += num[i];
      if(max < sum) max = sum;
      if(sum < 0) sum = 0;
    }
    printf("%d\n", max);
    free(num);
    scanf("%d", &n);
  }
  return 0;
}

Measured memory_bytes: 612
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
#include<map>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll p, ll n, ll m) {
	if (n == 0) return 1;
	else if (n == 1) return p % m;
	else if (n % 2 == 1) return p * pow_mod(p, n - 1, m) % m;
	else {
		ll tmp = pow_mod(p, n / 2, m);
		return (tmp * tmp) % m;
	}
}

ll gcd(ll x, ll y) {
	if (y == 0) {
		return x;
	}
	return gcd(y, x % y);
}

ll com_mod(ll n, ll k, ll m) {
	if (k == 0) return 1;
	else {
		ll x = 1;
		ll y = 1;
		for (ll i = 0; i < k; i++) {
			x = (x * (n - i)) % m;
			y = (y * (i + 1)) % m;
		}
		ll res = (x * pow_mod(y, m - 2, m)) % m;
		return res;
	}
}

int main() {
	int n, m;
	cin >> n >> m;
	cout << (n - 1) * (m - 1) << endl;
	return 0;
}

Measured memory_bytes: 3508
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
const int MX = 100005;
int n, k, a[MX], b[MX];
ll ans;
int main(){
	scanf("%d%d", &n, &k);
	rep(i,n){
		scanf("%d%d", a+i, b+i);
		if((k|a[i])==k) ans += b[i];
	}
	rep(i,30) if(k>>i&1){
		int t = (k>>i<<i)-1;
		ll tmp = 0;
		rep(j,n) if((t|a[j])==t) tmp += b[j];
		ans = max(ans, tmp);
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 1152
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<cmath>
#define cl(x) memset(x,0,sizeof(x))
#define read(x) scanf("%d",&(x));
using namespace std;

inline double sqr(int x){ return x*x; }

const int N=305;

struct PP{
  int x,y;
  friend double dist(PP A,PP B){
    return sqrt(sqr(A.x-B.x)+sqr(A.y-B.y));
  }
}s[N],t[N];

int n; double w[N][N];
int boy[N]; double sla[N],lx[N],ly[N];
int S[N],T[N];

inline bool match(int u){
  S[u]=1;
  for (int v=1;v<=n;v++){
    if (T[v]) continue;
    if (fabs(lx[u]+ly[v]-w[u][v])<1e-10){
      T[v]=1;
      if (!boy[v] || match(boy[v]))
	return boy[v]=u,1;
    }else
      sla[v]=min(sla[v],lx[u]+ly[v]-w[u][v]);
  }return 0;
}

inline double KM(){
  for (int i=1;i<=n;i++){
    lx[i]=-1<<30;
    for (int j=1;j<=n;j++)
      lx[i]=max(lx[i],w[i][j]);
  }
  for (int i=1;i<=n;i++){
    for (int j=1;j<=n;j++) sla[j]=1<<30;
    while (1){
      cl(S); cl(T); if (match(i)) break;
      double a=1<<30;
      for (int j=1;j<=n;j++) if (!T[j]) a=min(a,sla[j]);
      for (int j=1;j<=n;j++) if (S[j]) lx[j]-=a;
      for (int j=1;j<=n;j++) if (T[j]) ly[j]+=a; else sla[j]-=a;
    }
  }
  double ret=0;  
  for (int i=1;i<=n;i++) if (boy[i]) ret-=w[boy[i]][i];  
  return ret;
}

double ans=0;

int main(){
  read(n); read(s[1].x); read(s[1].y);
  for (int i=1;i<=n;i++){
    read(s[i].x); read(s[i].y);
    read(t[i].x); read(t[i].y);
    ans+=dist(s[i],t[i]);
  }
  for (int i=1;i<=n;i++)
    for (int j=1;j<=n;j++)
      w[i][j]=-dist(t[i],s[j]);
  ans+=KM();
  printf("%.10lf\n",ans);
  return 0;
}

Measured memory_bytes: 3448
while True:
    z = input()
    
    if z == "-":
        break
    
    z =list(z)
    
    y = int(input())

    for i in range(0, y):
        x = int(input())
        moji = z[0:x]
        del z[0:x]
        z.extend(moji)

    ans = "".join(z)

    print(ans)


Measured memory_bytes: 5592
import re
S = input()
ans = ['']
for i in range(len(S)):
    for k in range(i, len(S)):
        ans.append(S[i:k+1])
ans = sorted(ans,key=lambda x:len(x),reverse=True)
for i in ans:
    if len(re.sub("[ACGTacgt]", "", i)) == 0:
        print(len(i))
        break

Measured memory_bytes: 3316
// https://atcoder.jp/contests/nomura2020/tasks/nomura2020_a

#include<iostream>
#include<vector>//可変長配列
#include<algorithm>//sort,二分探索,など
#include<map>//map(辞書)

using namespace std;

int main(void){
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int wake = h1 * 60 + m1;
    int sleep = h2 * 60 + m2;
    int diff = sleep - wake - k;
    cout << diff << endl;
    return 0;
}

Measured memory_bytes: 3600
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

inline int topbit(unsigned long long x){
	return x?63-__builtin_clzll(x):-1;
}

inline int popcount(unsigned long long x){
	return __builtin_popcountll(x);
}

inline int parity(unsigned long long x){//popcount%2
	return __builtin_parity(x);
}



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

const ll INF=1e15;

const ll mod=1e9+7;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(ll n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (ll i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (ll i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(ll n, ll k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
  mint p(ll n, ll k) {
    return fact[n]*ifact[n-k];
  }
} c(1000005);

int main(){
   ll n;
   cin >> n;
   vector<mint> a(n);
   mint sum=0;
   rep(i,n){
       cin >> a[i];
       sum+=a[i];
   }
   mint ans=0;
   rep(i,n){
       sum-=a[i];
       ans+=a[i]*sum;
   }
   cout << ans << endl;
    return 0;
}

Measured memory_bytes: 20416
def solve(n, k):
    if k == 1:
        return 1

    MOD = 10 ** 9 + 7

    ans = (k // 2 + 1 + k) * (k - k // 2) // 2 % MOD  # k/2～k の和
    cnt = {1: 1}

    def get(d):
        if d in cnt:
            return cnt[d]
        result = pow(d, n, MOD)
        result -= d - d // 2
        for i in range(2, d // 2 + 1):
            result -= get(d // i)
        result %= MOD
        cnt[d] = result
        return result

    for i in range(1, k // 2 + 1):
        ans += i * get(k // i)
        ans %= MOD

    return ans


n, k = map(int, input().split())
print(solve(n, k))


Measured memory_bytes: 9236
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      String s=sc.nextLine();

int a=Integer.parseInt(s);
      String[] sn=sc.nextLine().split(" ");
String[] mae=sn[0].split("");      
String[] usi=sn[1].split("");      


String result="";

for(int i=0;i<a;i++){
result+=mae[i];
result+=usi[i];

}


System.out.println(result);



	}
}

Measured memory_bytes: 21712
#include <bits/stdc++.h>
#define range(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, b) for (int i = 0; i < (b); i++)
#define ranger(i, a, b) for (int i = (a)-1; i >= (b); i--)
#define repr(i, b) for (int i = (b)-1; i >= 0; i--)
#define all(a) (a).begin(), (a).end()
#define show(x) cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}
template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
	rep(i, v.size()) { os << v[i] << (i == v.size() - 1 ? "" : " "); }
	return os;
}
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S>& p) {
	os << '(' << p.first << ',' << p.second << ')';
	return os;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
	for (T& x : v) { is >> x; }
	return is;
}

signed main() {
	int n;
	cin >> n;

	vector<string> s(n);
	vector<int> t(n);
	rep(i, n) { cin >> s[i] >> t[i]; }

	string x;
	cin >> x;

	bool f = false;
	int sum = 0;
	rep(i, n) {
		if (f) sum += t[i];
		if (s[i] == x) { f = true; }
	}
	cout << sum << endl;
}


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

using namespace std;

bool CompareMin(int a, int b) {
	return a > b;  
}

int main(){
    int n,c=0,m2,m3;
    //string str;
    cin >> n;
    //cin >> str;
    
    
    m2 = n /100;
    m3 = n - (m2*100);

    if(m2 <= 12 && m2 >0 && (m3==0||m3>12)){
        cout << "MMYY" << endl; 
    }
    else if(m3 <= 12 && m3 >0 && (m2==0||m2>12)){
        cout << "YYMM" << endl;
    }
    else if ((m3 > 12 || m3  == 0 )&& (m2 > 12 || m2  == 0)){
        cout << "NA" << endl;
    }
    else{
        cout << "AMBIGUOUS" << endl;
    }
    
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <sstream>

using namespace std;


int main(int argc, const char * argv[]) {
    int N;
    cin >> N;
    
    vector<vector<int>> tasks;
    for (int i = 0; i < N; i++) {
        int A, B;
        cin >> A >> B;
        tasks.push_back(vector<int>{A, B});
    }
    sort(tasks.begin(), tasks.end(), [](vector<int> &t1, vector<int> &t2) {
        return t1[1] < t2[1];
    });
    
    int t_time = 0;
    string result = "Yes";
    for (int i = 0; i < N; i++) {
        t_time += tasks[i][0];
        if (t_time > tasks[i][1]) {
            result = "No";
            break;
        }
    }
    
    cout << result << endl;
    
    return 0;
}



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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}

class Solution {
public:
	void solve() {
		long long n;
		cin >> n;
		cout << (n * (n-1))/2 << "\n";
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
 public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int n=sc.nextInt(); long r=0;
	LinkedList<Integer> stok = new LinkedList<Integer>();
	stok.add(Integer.MAX_VALUE);
    for(int i=1;i<n;i++){
		stok.add(sc.nextInt());
		r+=Math.min(stok.get(0),stok.get(1));
		stok.remove(0);
	}
	System.out.println(r+stok.get(0));
 }
}

Measured memory_bytes: 23892
#!/usr/bin/env python3
import sys
# from functools import total_ordering
import heapq

from collections import Counter as cl

def solve(N: int, X: int, Y: int):

    def dis(a,b):
        fw = abs(a-b)
        bw1 = abs(X-a)+abs(Y-b)+1
        bw2 = abs(X-b)+abs(Y-a)+1
        bw = min(bw1,bw2)
        return min(fw, bw)
    
    dist_l = [0]*(N-1)
    for i in range(1,N+1):
        for j in range(i+1,N+1):
            dist_l[dis(i,j)-1] += 1


    print("\n".join(map(str, dist_l)))




def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(N, X, Y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3564
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.StringTokenizer;
 
public class Main {
	
	public static void main(String[] args) throws IOException {
		final Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		final int L = sc.nextInt();
		
		String[] strs = new String[N];
		for(int i = 0; i < N; i++){
			strs[i] = sc.next();
		}
		
		Arrays.sort(strs);
		for(final String str : strs){
			System.out.print(str);
		}
		System.out.println();
	}
 
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}
 
		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 8148
import java.util.Scanner;

public class Main {

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

	Scanner sc = new Scanner(System.in);

	void run() {
		for (;;) {
			int n = sc.nextInt();

			if (n == 0) {
				break;
			}

			int a[] = new int[n];
			long sum = 0;
			for (int i = 0; i < n; i++) {
				a[i] = sc.nextInt();
				sum += a[i];
			}

			int count = 0;
			for (int i = 0; i < n; i++) {
				if (sum >= (long) a[i] * n) {
					count++;
				}
			}
			System.out.println(count);
		}

	}
}



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

int main() {
	
	string s;
	cin >> s;
	
	const int n = 13;
	vector<vector<ll>> dp(100001, vector<ll>(n));
	
	ll mod = 1000000007;
	int mul = 1;
	
	dp[s.length()][0] = 1;
	for(int i=s.length() - 1; i >= 0; i--){
		if(s[i] == '?'){
			for(int k = 0; k<10; k++){
				for(int j = 0; j < n; j++){
					dp[i][(k*mul + j) % n] += dp[i+1][j];
					dp[i][(k*mul + j) % n] %= mod;
				}
			}
		}else{
			int k = (int)(s[i] - '0');
			for(int j = 0; j < n; j++){
					dp[i][(k*mul + j) % n] += dp[i+1][j];
					dp[i][(k*mul + j) % n] %= mod;
			}
		}
		mul *= 10;
		mul %= n;
	}
	
	cout << dp[0][5] << endl;
	return 0;
}

Measured memory_bytes: 13696
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iomanip>
#include<map>
#include<cstring>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vivi vector<vi>
const int INF = int(1e9);
typedef long long int ll;
/* -- template -- */

bool Prime[100000];

void initPrime(){
    Prime[0] = Prime[1] = true;
    for(int i = 2;i < 100000;++i){
        if(Prime[i])continue;
        Prime[i] = false;
        int k = 2;
        while(k * i < 100000){
            Prime[k * i] = true;
            ++k;
        }
    }
}

bool isPrime(int x){
    return !Prime[x];
}

int main(){
    initPrime();
    int dp[100000];
    dp[1] = 0;
    for(int i = 3;i < 100000; i += 2){
        dp[i] = dp[i - 2];
        if(isPrime(i) && isPrime((i + 1) / 2)){
            dp[i] += 1;
        }
    }
    int Q; cin >> Q;
    int l[Q], r[Q];
    rep(i, Q){
        cin >> l[i] >> r[i];
    }
    rep(i, Q)
        cout << dp[r[i]] - dp[((l[i] - 2) > 0 ? l[i] - 2 : 1)] << endl;
}


Measured memory_bytes: 1920
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

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

  public void run() {

    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      String[] lines = in.readLine().split(" ");
      int a = Integer.parseInt(lines[0]);
      int b = Integer.parseInt(lines[1]);
      int k = Integer.parseInt(lines[2]);

      for(int i=0; i<k; i++) {
        if((i & 1) == 0) {
          if((a & 1) == 1) a--;
          b += (a /= 2);
        }
        else {
          if((b & 1) == 1) b--;
          a += (b /= 2);
        }
      }

      System.out.println(a + " " + b);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

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

int main() {
  int h, w;
  cin >> h >> w;
  
  char s[h+2][w+2];
  for(int i=0; i<h+2; i++){
    for(int j=0; j<w+2; j++){
      if(i==0||i==h+1||j==0||j==w+1) s[i][j] = '0';
      else cin >> s[i][j];
    }
  }
  
  for(int i=1; i<h+1; i++){
    for(int j=1; j<w+1; j++){
      if(s[i][j]=='.'){
        int t =(s[i-1][j-1]=='#')+(s[i][j-1]=='#')+(s[i+1][j-1]=='#')
          +(s[i-1][j]=='#')+(s[i+1][j]=='#')
          +(s[i-1][j+1]=='#')+(s[i][j+1]=='#')+(s[i+1][j+1]=='#');
        s[i][j] = '0' + t;
      }
      if(j==w) cout << s[i][j] << endl;
      else cout << s[i][j];
    }
  }
}

Measured memory_bytes: 256
n = gets.chomp.to_i

answer = n * (n + 1) * (n + 2) / 6

(n - 1).times do
  u, v = gets.chomp.split(' ').map(&:to_i)
  u, v = v, u if u > v

  answer -= u * (n - v + 1)
end

puts answer

Measured memory_bytes: 14324
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int a,b,c,d;
  cin>>a>>b>>c>>d;
  for(int i=a;i<c;i++){
    cout<<'R';
  }
  for(int j=b;j<d;j++){
    cout<<'U';
  }
  for(int k=a;k<c;k++){
    cout<<'L';
  }
  for(int l=b;l<d;l++){
    cout<<'D';
  }
  cout<<'D';
  for(int m=a;m<=c;m++){
    cout<<'R';
  }
  for(int n=b;n<=d;n++){
    cout<<'U';
  }
  cout<<'L';
  cout<<'U';
  for(int o=a; o<=c;o++){
    cout<<'L';
  }
  for(int p=b; p<=d;p++){
    cout<<'D';
  }
  cout<<'R';
}


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

int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
string grid[8];

void dfs(int x,int y){
  for(int i=0;i<4;i++){
    for(int j=1;j<4;j++){
      int nx,ny;
      nx=x+dx[i]*j;ny=y+dy[i]*j;
      if(0<=nx && nx<8 && 
	 0<=ny && ny<8 && 
	 grid[ny][nx]=='1'){
	grid[ny][nx]='0';
	dfs(nx,ny);
      }
    }
  }
}

int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    
    for(int j=0;j<8;j++)
      cin>>grid[j];
    int x,y;
    cin>>x>>y;
    x--;y--;
    grid[y][x]='0';
    dfs(x,y);
    cout << "Data " << i+1 << ":" << endl;
    for(int j=0;j<8;j++)
      cout << grid[j] << endl;
  }
  return 0;
}

Measured memory_bytes: 1208
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<ld, ld> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int,int,int,int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const ll MOD = 1000000007;
ll POW(ll a, ll b, ll MMM = MOD) {ll ret=1; for(;b;b>>=1,a=(a*a)%MMM)if(b&1)ret=(ret*a)% MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };
int ddx[]={2,2,-2,-2,1,1,-1,-1},ddy[]={1,-1,1,-1,2,-2,2,-2};

Vi v[100000];
int dfs(int N,int p)
{
	int tot=0,cnt=0;
	int res=0;
	for(int next:v[N])
	{
		if(next==p)continue;
		tot++;
		int t=dfs(next,N);
		res+=t;
		if(t>0)cnt++;
	}
	if(tot-cnt>1)res+=tot-cnt-1;
	return res;
}
int main(){
	int n;
	scanf("%d",&n);
	fup(i,1,n-1,1)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		v[x].pb(y);
		v[y].pb(x);
	}
	int r=-1;
	fup(i,0,n-1,1)if(v[i].size()>2)r=i;
	if(r==-1)return !printf("1");
	printf("%d",dfs(r,-1));
}

Measured memory_bytes: 10112
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {

    int N;
    cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];

    vector<long long> from(N, 0), to(N, 0);
    from[0] = abs(A[0]);
    to[N - 1] = abs(A[N - 1]);
    for (int i = 1; i < N; i++) {
        from[i] = from[i - 1] + abs(A[i] - A[i - 1]);
        to[N - 1 - i] = to[N - i] + abs(A[N - i] - A[N - i - 1]);
    }
    rep(i,N) {
        if (i == 0) cout << abs(A[1]) + to[1] << endl;
        else if (i == N - 1) cout << from[N - 2] + abs(A[N - 2]) << endl;
        else cout << from[i - 1] + abs(A[i + 1] - A[i - 1]) + to[i + 1] << endl;
    }
    
    return 0;
}

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

public class Main {

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
	boolean eof;

	static boolean nextPermutation(int[] a) {
		int n = a.length;
		int ptr = n - 2;
		while (ptr >= 0 && a[ptr] > a[ptr + 1]) {
			ptr--;
		}
		if (ptr < 0) {
			return false;
		}

		for (int i = ptr + 1, j = n - 1; i < j; i++, j--) {
			int tmp = a[i];
			a[i] = a[j];
			a[j] = tmp;
		}

		for (int i = ptr + 1;; i++) {
			if (a[ptr] < a[i]) {
				int tmp = a[ptr];
				a[ptr] = a[i];
				a[i] = tmp;
				return true;
			}
		}
	}

	int[] solve(int n, int x) {

		if (x == 1 || x == 2 * n - 1) {
			return null;
		}

		if (n == 2) {
			return new int[] { 1, 2, 3 };
		}

		int[] a = new int[2 * n - 1];
		int mid = n - 1;
		
		int delta = x == 2 * n - 2 ? -1 : 1;

		boolean[] used = new boolean[2 * n + 2];

		a[mid] = x;
		a[mid - 1] = x + delta;
		a[mid + 1] = x - delta;
		a[mid + 2] = x + 2 * delta;

		used[x] = used[x + delta] = used[x - delta] = used[x + 2 * delta] = true;

		int ptr = 1;
		for (int i = 0; i < mid - 1; i++) {
			while (used[ptr]) {
				ptr++;
			}
			a[i] = ptr;
			used[ptr] = true;
		}

		for (int i = mid + 3; i < 2 * n - 1; i++) {
			while (used[ptr]) {
				ptr++;
			}
			a[i] = ptr;
			used[ptr] = true;
		}

		return a;
	}

	int median(int a, int b, int c) {
		int[] tmp = { a, b, c };
		Arrays.sort(tmp);
		return tmp[1];
	}

	int go(int[] a) {
		while (a.length > 1) {
			int[] b = new int[a.length - 2];
			for (int i = 0; i < b.length; i++) {
				b[i] = median(a[i], a[i + 1], a[i + 2]);
			}
			a = b;
		}
		return a[0];
	}

	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);

//		for (int n = 2; n <= 10; n++) {
//			for (int x = 2; x < 2 * n - 1; x++) {
//				int[] a = solve(n, x);
//				if (go(a) != x) {
//					throw new AssertionError(n + " " + x);
//				}
//			}
//		}
		
		int n = nextInt();
		int x = nextInt();

		int[] a = solve(n, x);
		if (a == null) {
			out.println("No");
		} else {
			out.println("Yes");
			for (int y : a) {
				out.println(y);
			}
		}
		out.close();
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return null;
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			eof = true;
			return null;
		}
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 23408
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in); 
		double r = sc.nextDouble();
		
		double s = Math.PI * r * r;
		double l = Math.PI * 2 * r;

		System.out.println(String.format("%.5f", s) + " " + String.format("%.5f", l));
	}
}

Measured memory_bytes: 18936
import numpy as np
import sys

n, m, q = map(int, input().split())
ab = np.array(sys.stdin.read().split(), np.int)
a = ab[:m*2].reshape(m, 2)
b = ab[m*2:].reshape(q, 2)

x=np.zeros((501, 501), dtype=np.int)

np.add.at(x, (a[:, 0], a[:, 1]), 1)

np.cumsum(x, axis=0, out=x)
np.cumsum(x, axis=1, out=x)

ans = x[b[:, 1], b[:, 1]] - x[b[:, 1], b[:, 0]-1] - x[b[:, 0]-1, b[:, 1]] + x[b[:, 0]-1, b[:, 0]-1]
for i in range(q):
    print(ans[i])


Measured memory_bytes: 66896
import numpy as np

n, m = map(int, input().split())
a = np.zeros(n)
b = np.zeros(n)
for i in range(n):
  a[i], b[i] = map(int, input().split())
idx = np.argsort(a)
a = a[idx]
b = b[idx]
price = 0
for i in range(n):
  if m <= b[i]:
    price += m * a[i]
    m = 0
  else:
    price += b[i] * a[i]
    m -= b[i]
  if m == 0:
    break
print(int(price))

Measured memory_bytes: 15596
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

typedef long long ll;
using namespace std;

int main() {
    int a = 0, b = 0, c = 0, x = 0;
    cin >> a >> b >> c >> x;
    int count = 0;
    for (int i=0; i<=a; i++) {
        for (int j=0; j<=b; j++) {
            for (int k=0; k<=c; k++) {
                if (500*i + 100*j + 50*k == x) count++;
            }
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define INF (1<<30)
 
int W;
int A[100001];
 
int Fa[100001];
int Fb[100001];
int main(){
  cin >> W;
  for(int i=0;i<W;i++) cin >> A[i];
 
  for(int i=0;i<W;i++){
    if( A[i] == 0 ) Fa[i] = INF;
    else if( A[i] < 0 )
      Fa[i] = min( Fa[i], -A[i] );
    Fa[i+1] = Fa[i]-1;
  }
 
  for(int i=W-1;i>=0;i--){
    if( A[i] == 0 ) Fb[i] = INF;
    else if( A[i] < 0 )
      Fb[i] = min( Fb[i], -A[i] );
    if( i == 0 ) break;
    Fb[i-1] = Fb[i]-1;
  }
   
 
  long long res = 0;
  for(int i=0;i<W;i++){
    if( A[i] > 0 ){
      int ret1=0, ret2=0;
      if( Fa[i] >  0 ) ret1 = min( Fa[i], A[i] );
      if( Fb[i] >  0 ) ret2 = min( Fb[i], A[i] );
      res += (long long)max(ret1,ret2);     
    }
  }
  cout << res << endl;
   
   
}

Measured memory_bytes: 2328
n,m=(int(i) for i in input().split())
l=[[] for i in range(n+1)]
for i in range(m):
  a,b=(int(i) for i in input().split())
  l[a].append(b)
  l[b].append(a)
queue = []
visited = [] 
visited = [0 for i in range(n+1)]
ans=[None for i in range(n+1)]
queue.append([1,0])
visited[1]=1
while len(queue)>0:
  now=queue.pop(0)
  for i in l[now[0]]:
    if visited[i]==0:
      visited[i]=1
      queue.append([i,now[0]])
  ans[now[0]]=now[1]
print('Yes')
for i in range(n-1):
  print(ans[i+2])

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

int main()
{
	long long int i,n,c=0,c1=0,c2=0,c3=0;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		string s="";
		cin>>s;
		if(s=="AC")
		{
			c++;
		}
		else if(s=="WA")
		{
			c1++;
		}
		else if(s=="TLE")
		{
			c2++;
		}
		else if(s=="RE")
		{ 
			c3++;
		}	
	}
	cout<<"AC"<<" "<<"x"<<" "<<c<<endl;
	cout<<"WA"<<" "<<"x"<<" "<<c1<<endl;
	cout<<"TLE"<<" "<<"x"<<" "<<c2<<endl;
	cout<<"RE"<<" "<<"x"<<" "<<c3<<endl;
	return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <tuple>
#include <numeric>
#include <cstdio>
#include <cmath>
using namespace std;
using ll = long long;
const int INF = 1e9;

int main() {
    string s; cin >> s;
    if (s == "ABC") {
        cout << "ARC\n";
    } else {
        cout << "ABC\n";
    }
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
int mincost(int i,int n,int a[],int dp[],int k)
{
    if (i==n)
    return 0;
    if(dp[i]!=-1)
    return dp[i];
   dp[i]=INT_MAX;
  for(int j=1;j<=k;j++)
  {      if(i+j<=n)
      dp[i]=min(dp[i],mincost(i+j,n,a,dp,k)+abs(a[i+j]-a[i]));
  }
  return dp[i];
}
int main() {
    int i,j,k,n;
    cin>>n>>k;
    int a[n+1];
    int dp[n+1];
  for(i=1;i<=n;i++)
    dp[i]=-1;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    cout<<mincost(1,n,a,dp,k);
}


Measured memory_bytes: 10368
aw,bw,cs,ds,ep,fm=map(int,input().split())

na=fm//(aw*100)
nb=fm//(bw*100)

ans=0
li=[]
for ia in range(na+1):
    for ib in range(nb+1):
        total_water=ia*aw*100+ib*bw*100       
        
        if total_water>fm:
            break
        if total_water==0:
            break
        
        if total_water in li:
            break
        li.append(total_water)
        
        for ic in range((((total_water//100)*ep)//cs)+1):
            for id in range((((total_water//100)*ep)//ds)+1):

                total=total_water+ic*cs+id*ds
                if total>fm:
                    break
                if (ic*cs+id*ds)/total>=ans and ic*cs+id*ds<=total_water//100*ep:
                    ans_total=total
                    ans_sugar=ic*cs+id*ds
                    ans=(ic*cs+id*ds)/total
print(ans_total,ans_sugar)


Measured memory_bytes: 3064