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

public class Main {
	private static int[] heap;
	private static int n;
	public static void main(String[] atgs){
		final Scanner sc=new Scanner(System.in);
		n=sc.nextInt();
		heap=new int[n+1];
		for(int i=1;i<=n;i++) heap[i]=sc.nextInt();
		
		for(int i=n/2;i>=1;i--) maxHeap(i);
		
		for(int i=1;i<=n;i++) System.out.print(" " +heap[i]);	
		System.out.println("");
	}
	
	private static void maxHeap(int i){
		int l=2*i;
		int r=2*i+1;
		int max;
		if(l<=n && heap[l]>heap[i]) max=l;
		else max=i;
		if(r<=n && heap[r]>heap[max]) max=r;
		
		if(max!=i){
			int tmp=heap[i];
			heap[i]=heap[max];
			heap[max]=tmp;
			maxHeap(max);
		}
	}

}

Measured memory_bytes: 170440
/*
これを入れて実行
g++ code.cpp
./a.out
*/

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = { -1, 0, +1, 0 };
int dx4[4] = { 0, +1, 0, -1 };
int dy8[8] = { -1, -1, 0, 1, 1, 1, 0, -1 };
int dx8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
	return f.second > s.second;
}

ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b){
	return a / gcd(a, b) * b;
}

ll nCr(ll n, ll r){
	if (r == 0 || r == n){
		return 1;
	}
	else if (r == 1){
		return n;
	}
	return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
	r = n - r;
	ll ret = 1;
	for (ll i = n; i >= r + 1; i--) ret *= i;
	return ret;
}

//-----------------------ここから-----------

int main(void){
	int n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	a--;
	b--;
	c--;
	d--;

	string s;
	cin >> s;

	int dcnt = 0;
	bool overtake = false;

	for (int i = b - 1; i <= min(d, c) + 1; i++){
		if (s[i] == '.'){
			dcnt++;
		} else {
			dcnt = 0;
		}
		if (dcnt > 2){
			overtake = true;
		}
	}

	for (int i = a; i < max(d, c) - 1; i++){
		if (s[i] == '#' && s[i + 1] == '#'){
			cout << "No" << endl;
			return 0;
		}
	}

	if (!overtake){
		if (c > d){
			cout << "No" << endl;
			return 0;
		}
	}
		

	cout << "Yes" << endl;
} 


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;

ll MOD = 1000000007;

ll p(ll x, ll y) {
  ll ret = 1;
  for (ll i = 0; i < y; i++) {
    ret = ret * (x - i) % MOD;
  }
  return ret;
}

int main() {
  ll N, K;
  cin >> N >> K;

  vi P(K - 1);
  ll tmp = 1;
  for (ll i = 0; i <= K - 2; i++) {
    P[i] = tmp;
    tmp = tmp * (K - 2 - i) % MOD;
  }

  vvi G(N);

  vi a(N - 1), b(N - 1);
  for (int i = 0; i < N - 1; i++) {
    cin >> a[i] >> b[i];
    a[i] -= 1;
    b[i] -= 1;
    G[a[i]].push_back(b[i]);
    G[b[i]].push_back(a[i]);
  }

  vi visited(N);
  visited[0] = 1;

  ll ans = K;
  queue<ll> q;
  q.push(0);

  while(q.size()) {
    ll fr = q.front();
    q.pop();
    visited[fr] = 1;

    if (fr == 0) {
      if (G[fr].size() > K - 1) {
        cout << 0 << endl;
        return 0;
      }
      ans = ans * p(K - 1, G[fr].size()) % MOD;
    } else {
      if (G[fr].size() - 1 > K - 2) {
        cout << 0 << endl;
        return 0;
      }
      ans = ans * P[G[fr].size() - 1] % MOD;
    }

    for (ll to: G[fr]) {
      if (visited[to] == 0)
        q.push(to);
    }
  }

  cout << ans << endl;
}


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

#define REP(i, s, e) for(int i = (int)(s); i < (int)(e); ++i)
#define rep(i, n) REP(i, 0, n)

int main() {
    int ans = 0;
    string s, t;
    cin >> s >> t;
    const int n = s.size();
    rep(i, n) ans += (s[i] == t[i]) ? 1 : 0;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = [0]*N
AC = 0
WA = 0
TLE = 0
RE = 0

for n in range(N):
  S[n] = str(input())
  if S[n] == "AC":
    AC = AC + 1
  elif S[n] == "WA":
    WA = WA + 1
  elif S[n] == "TLE":
    TLE = TLE + 1
  elif S[n] == "RE":
    RE = RE + 1
    
print("AC x {}\nWA x {}\nTLE x {}\nRE x {}".format(AC,WA,TLE,RE))

Measured memory_bytes: 16048
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;

int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	long long n, w;
	cin >> n >> w;
	vector<long long> wt(n), val(n);
	vector<vector<long long>> dp(n + 1, vector<long long> (w + 1, 0));

	for (long long i = 0; i < n; i++)
		cin >> wt[i] >> val[i];
	for (long long i = 0; i <= n; i++)
		for (long long j = 0; j <= w; j++) {
			if (i == 0 || j == 0)
				dp[i][j] = 0;
			else if (wt[i - 1] <= j)
				dp[i][j] = max(val[i - 1] + dp[i - 1][j - wt[i - 1]], dp[i - 1][j]);
			else
				dp[i][j] = dp[i - 1][j];
		}
	cout << dp[n][w] << endl;
}

Measured memory_bytes: 83060
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end

n=gets.to_i
abc=Array.new(n)

n.times do|i|
  abc[i]=get_i
end
dp=Array.new(3).map{Array.new(n)}

dp[0][0]=abc[0][0]
dp[1][0]=abc[0][1]
dp[2][0]=abc[0][2]
for i in 1..n-1
  3.times do|j|
    dp[j][i]=abc[i][j]
    dp[j][i]+=[dp[(j+1)%3][i-1],dp[(j+2)%3][i-1]].max
  end
end
puts [dp[0][n-1],dp[1][n-1],dp[2][n-1]].max

Measured memory_bytes: 11900
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<limits>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i = 0;i < (n); ++i)

int main() {
	int n;
	cin >> n;
	vector<int>x(n);
	rep(i, n)cin >> x[i];
	vector<int> resurve(100,0);
	sort(x.begin(), x.end());
	int ans = 1000000000;
	
	if (n == 1) {
		cout << 0 << endl; 
		return 0;
	}
	for (int i = 1; i <=100; i++) {
		for (int j = 0; j < n; j++) {
			resurve[i] += (x[j]-i)*(x[j]-i);
		}
		ans = min(ans, resurve[i]);
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
  int N, M;
  int a[51], b[51], c[51], d[51];
  int res[51];
  cin >> N >> M;

  rep(i,N) cin >> a[i] >> b[i];
  rep(i,M) cin >> c[i] >> d[i];

  rep(i,N){
    int minmd = INF;
    rep(j,M){
      int md = abs(a[i]-c[j])+abs(b[i]-d[j]);
      if(minmd > md) {
        res[i]=j+1;
        minmd = md;
      }
    }
  }

  rep(i,N){
    cout << res[i] << endl;
  }
}

Measured memory_bytes: 256
def solve(a, b, c, k):
    val = a
    for x in [b, c]:
        if val < x:
            val = x
    remain = a + b + c - val
    for i in range(k):
        val *= 2
    return val + remain

def readQuestion():
    import sys
    line = sys.stdin.readline()
    sline = line.rstrip()
    str_a, str_b, str_c = sline.split(' ')
    a = int(str_a)
    b = int(str_b)
    c = int(str_c)
    line = sys.stdin.readline()
    str_k = line.rstrip()
    k = int(str_k)
    return a, b, c, k

def main():
    a, b, c, k = readQuestion()
    ans = solve(a, b, c, k)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
#include<queue>
using namespace std;
typedef long long LL;
#define sqr(x) ((x)*(x))
#define mp make_pair
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
	write(a); puts("");
}
const int N=200005;
int n,arr[N];
struct seg{
	int tree[N<<2];
	inline int cmp(int a,int b){
		return arr[a]<arr[b]?a:b;
	}
	int ask(int l,int r,int i,int j,int nod){
		if(i>j)return 0;
		if(l==i&&r==j)return tree[nod];
		int mid=(l+r)>>1;
		if(j<=mid)return ask(l,mid,i,j,nod<<1);
		else if(i>mid)return ask(mid+1,r,i,j,nod<<1|1);
		else return cmp(ask(l,mid,i,mid,nod<<1),ask(mid+1,r,mid+1,j,nod<<1|1));
	}
	void insert(int l,int r,int pos,int nod){
		if(l==r){
			tree[nod]=pos; return;
		}
		int mid=(l+r)>>1;
		if(pos<=mid)insert(l,mid,pos,nod<<1); else insert(mid+1,r,pos,nod<<1|1);
		tree[nod]=cmp(tree[nod<<1],tree[nod<<1|1]);
	}
}T[2];
inline pair<int,pair<int,int> > gao(int l,int r){
	return mp(-arr[T[l&1].ask(1,n,l,r-1,1)],mp(l,r));
}
priority_queue<pair<int,pair<int,int> > > q;
int main(){
	n=read();
	arr[0]=1e9;
	for(int i=1;i<=n;i++)arr[i]=read();
	for(int i=1;i<=n;i+=2)T[1].insert(1,n,i,1);
	for(int i=2;i<=n;i+=2)T[0].insert(1,n,i,1); 
	q.push(gao(1,n));
	while(q.size()){
		pair<int,pair<int,int> > t=q.top(); q.pop();
		int l=t.second.first,r=t.second.second;
		if(l>r)continue;
		int L=T[l&1].ask(1,n,l,r-1,1);
		int R=T[l&1^1].ask(1,n,L+1,r,1);
		write(arr[L]); putchar(' '); write(arr[R]); putchar(' ');
		q.push(gao(l,L-1)); q.push(gao(L+1,R-1)); q.push(gao(R+1,r));
	}
}


Measured memory_bytes: 12532
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;

int main(){

    int ant[5];

    for(int i = 0; i < 5; ++i){

        cin >> ant[i];

    }

    int k;
    cin >> k;

    if(ant[4]-ant[0] > k)cout << ":(\n";
    else cout << "Yay!\n";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int main(){
	string s;
	int K;
	cin>>s>>K;
	int N = s.size();
	vector<string> vec;
	rep1(len,K){
		rep(i,N+1-len){
			vec.pb(s.substr(i,len));
		}
	}
	sort(all(vec));
	vec.erase(unique(vec.begin(),vec.end()),vec.end());
	cout<<vec[K-1]<<endl;
}

Measured memory_bytes: 1660
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class B
{
	public static void Main()
	{
		int N = GetInt();
		int[] a = Enumerable.Repeat(1, N).Select(_ => (GetInt() - 1)).ToArray();
		int ans = 0;
		for(int i = 0; i < N; i++)
		{
			if(a[a[i]] == i)
				ans++;
		}
		Console.WriteLine(ans / 2);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 23264
#include<bits/stdc++.h>
using namespace std;
#pragma optimize("-O3")
#define int long long int
#define f first
#define s second
#define pb push_back

main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	if(n>=400 && n<=599){
		cout<<8;
	}
	if(n>=600 && n<=799){
		cout<<7;
	}
	if(n>=800 && n<=999){
		cout<<6;
	}
	if(n>=1000 && n<=1199){
		cout<<5;
	}
	if(n>=1200 && n<=1399){
		cout<<4;
	}
	if(n>=1400 && n<=1599){
		cout<<3;
	}
	if(n>=1600 && n<=1799){
		cout<<2;
	}
	if(n>=1800 && n<=1999){
		cout<<1;
	}
	return 0;
}

Measured memory_bytes: 3636
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  vector<vector<bool>> bingo(3,vector<bool>(3));
  vector<vector<int>> num(3,vector<int>(3));
  rep(i,3){
    rep(j,3){
      cin >> num.at(i).at(j);
    }
  }
  int n;
  cin >> n;
  set<int> b;
  int pre;
  rep(i,n){
    cin >> pre;
    b.insert(pre);
  }

  rep(i,3){
    rep(j,3){
      if(b.count(num.at(i).at(j))) bingo.at(i).at(j) = true;
      else bingo.at(i).at(j) = false;
    }
  }

  bool flag = true;
  rep(i,3){
    rep(j,3){
      if(!bingo.at(i).at(j)) flag = false;
    }
    if(flag){
      printf("Yes\n");
      return 0;
    }
    flag = true;
  }

  flag = true;
  rep(i,3){
    rep(j,3){
      if(!bingo.at(j).at(i)) flag = false;
    }
    if(flag){
      printf("Yes\n");
      return 0;
    }
    flag = true;
  }

  if(bingo.at(0).at(0)&&bingo.at(1).at(1)&&bingo.at(2).at(2)){
    printf("Yes\n");
    return 0;
  }
  if(bingo.at(0).at(2)&&bingo.at(1).at(1)&&bingo.at(2).at(0)){
    printf("Yes\n");
    return 0;
  }
  printf("No\n");

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <numeric>

#define roop(i, n) for(int i=0;i<n;i++)

using namespace std;
using ll = long long int;
using ull = unsigned long long;

constexpr ull mod = 1e9+7;
constexpr int N = 13;
ull dp[100010][N];

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

int main() {
	string s;
	cin >> s;
	if (s.size() % 2 != 0) {
		cout << "No" << endl;
		return 0;
	}
	sort(s.begin(), s.end());
	int count = 0;
	for (int i = 0; i < s.size() - 1; i++) {
		if (s[i] == s[i+1]) {
			count++;
		} else {
			if (count % 2 == 0) {
				cout << "No" << endl;
				return 0;
			} else {
				count = 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000)
input = sys.stdin.readline

def chkprint(a):
	a_name = ''
	for k, v in globals().items():
		if id(v) == id(a):
			a_name = k
			break
	print(a_name+' = '+str(a), file=sys.stderr)

def mt(f):
	import time
	def wrap(*args, **kwargs):
		s = time.time()
		ret = f(*args, **kwargs)
		e = time.time()
		print(e - s, 'sec', file=sys.stderr)
		return ret
	return wrap

@mt
def slv(N, A):
	flag = True
	while len(A) > 1:
		m = min(A)
		A = [a % m for a in A if a % m != 0]
		A.append(m)
		print(A, file=sys.stderr)
	return m


N = int(input())
A = [int(i) for i in input().split()]
'''
N = 5
A = [13, 5, 18, 100000000]
'''
print(slv(N, A))

Measured memory_bytes: 72852
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    ll ans = 1000;
    ll pos = 0;

    for (ll i = 0; i < n - 1; i++)
    {
        ll _max = a[i];
        // ll max_index = i;
        // cout << ans << endl;

        for (ll k = i + 1; k < n; k++)
        {
            // cout << i << " " << k << endl;



            if (a[k] < _max)
            {
                ans += (_max - a[i]) * (ans / a[i]);
                i = k - 1;
                break;
            }
            else if(_max < a[k])
            {
                _max = a[k];
            }

            if (k == n - 1)
            {
                ans += (_max - a[i]) * (ans / a[i]);
                i = k - 1;
                break;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3580
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

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

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	llint ans = 0;
	rep(i, 3001) {
		rep(j, 3001) {
			if (i * a + j * b <= d && (d - i * a - b * j) % c == 0) {
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
    int a, b;
    cin >> a >> b;
    cout << max({a - b, a + b, a * b}) << endl;
    return 0;
}

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


public class Main{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		 int a=0;
		 int b=0;
		 for(int i=0;i<s.length();i++)
		 {
			 if(s.charAt(i)=='A')
			 {
				 a++;
			 }
			 else if(s.charAt(i)=='B')
			 {
				 b++;
			 }
			 
		 }
		 
		 
		 
		 
		 if((a>1||b>1) && (a!=s.length() && b!=s.length()))
		 {
			 System.out.println(" Yes ");
		 }
		 else
		 {
			 System.out.println(" No ");
		 }
		
		
	}



	}









Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007ll)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}
void OUT(bool b){cout<<(b?"YES":"NO")<<endl;}
void Out(bool b){cout<<(b?"Yes":"No")<<endl;}
void out(bool b){cout<<(b?"yes":"no")<<endl;}
int popcnt(int x) { return __builtin_popcount(x); }
int popcnt(ll x) { return __builtin_popcountll(x); }
int clz(int x) { return 31 - __builtin_clz(x); }
int clz(ll x) { return 63 - __builtin_clzll(x); }
int ctz(int x) { return __builtin_ctz(x); }
int ctz(ll x) { return __builtin_ctzll(x); }

class compare {
public:
	bool operator()(tuple<ll, ll> a, tuple<ll, ll> b) {
		return (get<1>(a) > get<1>(b));
	}
};

ll dp[3001][3001];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;
	string ans;
	string a,b;
	cin>>a>>b;
	n=a.size();
	m=b.size();
	rep(i,n){
		rep(j,m){
			if(a[i]==b[j])dp[i+1][j+1]=dp[i][j]+1;
			else dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
		}
	}
	while(n!=0&&m!=0){
		if(dp[n][m]==0)break;
		else if(dp[n][m]==dp[n][m-1]&&dp[n][m]==dp[n-1][m])n--;
		else if(dp[n-1][m]>dp[n][m-1])n--;
		else if(dp[n][m-1]>dp[n-1][m])m--;
		else {
			ans.push_back(a[n-1]);
			n--;m--;
		}
	}
	reverse(all(ans));
	cout<<ans<<endl;;
}

Measured memory_bytes: 70656
#include<iostream>
#include<cmath>

using namespace std;

int main(){
  int n=0;
  cin>>n;
  int a[n];
  double sum=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    sum+=a[i];
  }
  double ave=sum/n;
  for(int i=0;i<n;i++){
    if(a[i]==ave){
      cout<<i<<endl;
      exit(0);
    }
  }
  double b[n];
  for(int i=0;i<n;i++){
    b[i]=abs(ave-a[i]);
  }
  double min=b[0];
  int min_num=0;
  for(int i=0;i<n;i++){
    if(min>b[i]){
      min=b[i];
      min_num=i;
    }
  }
  cout<<min_num<<endl;
}


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	string s;
	cin >> s;
	if(s.size() >= 4 && s.substr(0, 4) == "YAKI"){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}

}


Measured memory_bytes: 768
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let a = v[0];
	let b = v[1];
	let c = v[2];
	if a+b == c || a+c == b || b+c == a {
		println!("Yes");
	}else{
		println!("No");
	}
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << b * (c / a) << endl;
	return 0;
}

Measured memory_bytes: 256
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
#pragma GCC optimize("Os")
#pragma GCC target("avx2,fma")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("Os")
*/
#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld; 

#define X first
#define Y second
#define MP make_pair

using namespace std;
    
const int N = 3e3 + 123;
const ll mod = 1e9 + 7;
const ll INF = 1e18;

ll dp[2][N][N], was[2][N][N], a[N];
ll rec(int v, int l, int r){
	if(l > r)
		return 0;
	if(was[v][l][r])
		return dp[v][l][r];
	was[v][l][r] = 1;
	if(v == 0){
		dp[v][l][r] = max(rec(1 - v, l + 1, r) + a[l], rec(1 - v, l, r - 1) + a[r]);
	}
	else{
	    dp[v][l][r] = min(rec(1 - v, l + 1, r) - a[l], rec(1 - v, l, r - 1) - a[r]);
	}
	return dp[v][l][r];
}

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

	int n;
	cin >> n;
	for(int i = 1;i <= n;i++)
		cin >> a[i];
	cout << rec(0, 1, n);
	return 0;
}

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

int main() {
  int64_t n, k, ans = 0;
  cin >> n >> k;
  for (int64_t i = k; i <= n + 1; i++) {
    ans += ((i*(2*n - i + 1))/2) - ((i*(i - 1))/2) + 1;
    if (ans > 1000000007) {
      ans %= 1000000007;
    }
  }
  cout << ans % 1000000007 << endl;
}

Measured memory_bytes: 3616
import java.util.Scanner;
public class Main {
 public static void main(String[] args) {
 // 標準入力からデータを読み込む準備
 Scanner sc = new Scanner(System.in);
 // 3つの文字の固まりをそれぞれ整数値と想定して読み込む
 int a = sc.nextInt();
 int b = sc.nextInt();
 int c = sc.nextInt();
 if (a < b) {
  if (b < c) {
   System.out.printf("%d %d %d", a, b, c);
   System.out.println();
  } else if (a < c) {
  System.out.printf("%d %d %d", a, c, b);
   System.out.println();
  } else {
  System.out.printf("%d %d %d", c, a, b);
   System.out.println();
  }
 }
 else {
  if (a < c) {
   System.out.printf("%d %d %d", b, a, c);
   System.out.println();
  }
  else if (b < c) {
  System.out.printf("%d %d %d", b, c, a);
  System.out.println();
  }
  else {
  System.out.printf("%d %d %d", c, b, a);
  System.out.println();
  }
 }
}
}


Measured memory_bytes: 26248
<?php
	$n = trim(fgets(STDIN));
	
	for ($i = 1; $i <= $n; $i++) {
		$x = $i;
		if ($x % 3 == 0) {
			print " $i";
			continue;
		}

		if ($x % 10 == 3) {
			print " $i";
			continue;
		}

		while ($x) {
			$x /= 10;
			if ($x % 10 == 3) {
				print " $i";
				break;
			}
		}
	}

	print "\n";

Measured memory_bytes: 6568
module Main where

import Numeric
import Data.Functor

main :: IO ()
main = do
  { [a,b] <- getInts
  ; let (q,r) = divMod a b
  ; let s = fromIntegral a / fromIntegral b
  ; putStrLn . unwords $ [show q, show r, showFFloat Nothing s ""] 
  }

getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords . map show

done :: IO ()
done = return ()

Measured memory_bytes: 3932
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn gcd(a: usize, b: usize) -> usize {
    if b > a {
        return gcd(b, a);
    }
    if a % b == 0 {
        return b;
    }
    gcd(b, a % b)
}

fn main() {
    input! {
        n: usize,
        t: [usize; n],
    }
    let mut ans = 1;
    for ti in t {
        let a = gcd(ans, ti);
        ans = ans / a * ti;
    }
    println!("{}", ans);
}


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

using namespace std;

#define int long long

const int MAXN = 3e5 + 7;
const int ADD = 150001;
const int INF = 1e9 + 7;

int n, k, want;
int a[MAXN];
int t[MAXN];
int f0[MAXN], f1[MAXN];

void add0(int i) {
    i += ADD;
    for (; i < MAXN; i |= (i + 1)) ++f0[i];
}

int get0(int i) {
    i += ADD;
    int ans = 0;
    for (; i >= 0; i = (i & (i + 1)) - 1) ans += f0[i];
    return ans;
}

void add1(int i) {
    i += ADD;
    for (; i < MAXN; i |= (i + 1)) ++f1[i];
}

int get1(int i) {
    i += ADD;
    int ans = 0;
    for (; i >= 0; i = (i & (i + 1)) - 1) ans += f1[i];
    return ans;
}

int get(int x) {
    for (int i = 0; i < MAXN; ++i) f0[i] = f1[i] = 0;
    for (int i = 0; i < n; ++i) {
        if (a[i] <= x) t[i] = 1;
        else t[i] = -1;
    }
    add0(0);
    int curr = 0;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        curr += t[i];
        //pref <= curr - 2
        if ((i + 1) % 2 == 0) {
            int add = get0(curr - 2) + get1(curr - 1);
            //cout << add << '\n';
            ans += add;
            add0(curr);
        }
        else {
            int add = get0(curr - 1) + get1(curr - 2);
            //cout << add << '\n';
            ans += add;
            add1(curr);
        }
    }
    return ans;
}

bool check(int x) {
    return want <= get(x);
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

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

    k = n * (n + 1) / 2;
    want = k / 2 + 1;

    //cout << get(INF) << '\n';
    //exit(0);

    int l = -1;
    int r = INF;
    while (l < r - 1) {
        int m = (l + r) / 2;
        if (!check(m)) l = m;
        else r = m;
    }

    cout << r << '\n';
    return 0;
}

Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string n;
    long ans =0;
    cin >> n;
    for(int i=0;i<n.size();i++){
        ans += n[i]-'0';
    }
    if(ans%9==0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3724
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>

#define rep(i, a) REP(i, 0, a)
#define REP(i, a, b) for(int i = a; i < b; ++i)

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> P;
typedef std::pair<P, int> PP;
const double esp = 1e-9;
const int infi = (int)1e+9 + 10;
const ll infll = (ll)1e+17 + 10;

int main(){
	std::string str;
	int n;
	std::cin >> str >> n;
	rep(i, n){
		int a, b;
		std::string s;
		std::cin >> s >> a >> b;
		if (s == "print")std::cout << str.substr(a, b - a + 1) << std::endl;
		else if (s == "reverse")std::reverse(str.begin() + a, str.begin() + b + 1);
		else {
			std::string c;
			std::cin >> c;
			rep(i, c.size())str[a + i] = c[i];
		}
	}
	return 0;
}

Measured memory_bytes: 1220
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
static const double EPS = 1e-8;
typedef long long ll;

template <class T>
T gcd(T a, T b)
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
template <class T>
T lcm(T a, T b)
{
	return a / gcd(a, b) * b;
}
int main()
{
	int n, m, p[20];
	while (scanf("%d%d", &n, &m), n || m)
	{
		for (int i = 0; i < m; ++i)
			scanf("%d", p + i);
		sort(p, p+m);
		m = unique(p, p+m) - p;

		int num = n;
		ll sum = (ll)n*(n+1)/2;
		for (int i = 1; i < 1 << m; ++i)
		{
			int bits = 0;
			for (int j = i; j; j >>= 1)
				bits += j & 1;

			ll _lcm = 1;
			for (int j = 0; j < m; ++j)
			{
				if (i >> j & 1)
				{
					_lcm = lcm(_lcm, (ll)p[j]);
					if (_lcm > n)
						break;
				}
			}
			ll t = n / _lcm;
			int s = bits & 1 ? -1 : 1;
			num += s * t;
			sum += s * _lcm * t*(t+1)/2;
		}

		printf("%.10f\n", num ? (double)sum / num : 0);
	}

	return 0;
}

Measured memory_bytes: 912
#include <stdio.h>

int main(void)
{
    int n;
    scanf("%d", &n);
    
    int a[2][n];
    int i, j, k;
    for (i = 0; i < n; i++)
        scanf("%d", &a[0][i]);
    for (i = 0; i < n; i++)
        scanf("%d", &a[1][i]);
    
    k = 0;
    int sum = 0;
    for (i = 0; i < n; i++) {
        int tmp = 0;
        k = 0;
        for (j = 0; j < n; j++) {
            tmp += a[k][j];
            if (i == j) {
                k = 1;
                tmp += a[k][j];
            }
        }
        if (sum < tmp)
            sum = tmp;
    }
    printf("%d\n", sum);
    return 0;
}

Measured memory_bytes: 128
n = int(input())
s = [input() for i in range(n)]
s.sort()
count = 1
ma = 0
for i in range(1,n):
    if s[i] == s[i-1]:
        count+=1
    else:
        ma = max(ma,count)
        count=1
ma = max(ma,count)
count=1
ans = []
for i in range(1,n):
    if s[i] == s[i-1]:
        count+=1
    else:
        if count == ma:
            ans.append(s[i-1])
        count=1
if count == ma:
    ans.append(s[-1])
for i in ans:
    print(i)

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

int main()
{
    int i,j,m;int a[10];
    scanf("%d",&m);
        memset(a,0,sizeof(a));
        a[0]=m/1000;
        m%=1000;
        a[1]=m/100;
        m%=100;
        a[2]=m/10;
        a[3]=m%10;
        
        if((a[0]==a[1]&&a[0]==a[2])||(a[3]==a[1]&&a[3]==a[2])) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
queue = []
for i in range(m):
    c, y= map(int, input().split())
    queue.append([c, y, i])

queue = sorted(queue)

index = 0
keep = queue[0][0]
for i in range(m):
    if keep != queue[i][0]:
        index = 0
        keep = queue[i][0]
    index += 1
    queue[i][0] = str(queue[i][0]).zfill(6)
    queue[i][1] = str(index).zfill(6)

queue.sort(key=lambda x: x[2])

for data in queue:
    cn, yn, i = data
    print(cn + yn)

Measured memory_bytes: 35372
#include<iostream>

using namespace std;

int main(){
  int n,m;
  cin>>n>>m;
  int A[n+1][m+1],b[m+1];
  // ここからインプット（まず、配列Aについて）
  for(int i=1;i<=n;i++){
    for(int j=1;j<=m;j++){
      cin>>A[i][j];
    }
  }
  //配列ｂについて
  for(int j=1;j<=m;j++){
    cin>>b[j];
  }
  //ここからCiについてインプット
  int C[n+1];
  //いったん初期化
  for(int i=1;i<=n;i++){
    C[i]=0;
  }
  for(int i=1;i<=n;i++){
    for(int j=1;j<=m;j++){
      C[i]+=A[i][j]*b[j];
    }
  }
  // ここから出力
  for(int i=1;i<=n;i++){
    cout<<C[i]<<endl;
  }
  return 0;
}



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

int main()
{
	double N, K;
	double m = 0, e = 0;
	cin >> N >> K;
	vector<double> p(N);
	for (int i = 0; i < N; i++) {
    double a;
		cin >> a;
    p[i] = (a+1.0)/2.0;
	}
	for (int s = 0; s < N; s++) {	//s -> start index
		if (s < K) {
			e += p[s];
		}else {
			e = e - p[s - K] + p[s];
		}
    if (m < e) {
			  m = e ;
		  }
	}
    cout << fixed << setprecision(10);
	cout << m << endl;
}



Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.D
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var inputs = ReadLongs();
            var X = inputs[0];
            var Y = inputs[1];

            var b = (2D * X - Y) / 3D;
            if (b < 0) return 0;
            if ((int)b != b) return 0;

            var a = X - 2 * b;
            if (a < 0) return 0;
            if ((int)a != a) return 0;

            return Modular.Combination((long)a + (long)b, (long)a);
        }

        #region Console

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
    public class Modular
    {
        public long Value { get; private set; }

        private static readonly long _mod = (long)Math.Pow(10, 9) + 7;
        private static readonly List<int> _facCache = new List<int> { 1 };

        public static explicit operator long(Modular m) => m.Value;
        public static implicit operator Modular(long a)
        {
            var m = a % _mod;

            return new Modular
            {
                Value = (m < 0) ? m + _mod : m
            };
        }

        public static Modular operator +(Modular a, Modular b) => a.Value + b.Value;
        public static Modular operator -(Modular a, Modular b) => a.Value - b.Value;
        public static Modular operator *(Modular a, Modular b) => a.Value * b.Value;
        public static Modular operator /(Modular a, Modular b) => a * Pow(b, _mod - 2);
        public static Modular Pow(Modular a, long n)
        {
            switch (n)
            {
                case 0:
                    return 1;
                case 1:
                    return a;
                default:
                    var p = Pow(a, n / 2);
                    return p * p * Pow(a, n % 2);
            }
        }
        public static Modular Factorial(long n)
        {
            for (int i = _facCache.Count; i <= n; ++i)
            {
                var fac = (int)(Math.BigMul(_facCache.Last(), i) % _mod);
                _facCache.Add(fac);
            }
            return _facCache[(int)n];
        }
        public static Modular Combination(long n, long r)
        {
            Modular ans = 1;
            for (var i = 0; i < r; i++)
            {
                ans *= n - i;
            }
            for (var i = 1; i <= r; i++)
            {
                ans /= i;
            }

            return ans;
        }
        public override string ToString()
        {
            return Value.ToString();
        }
    }
}


Measured memory_bytes: 17416
n=int(input())

nums=list(map(int,input().split()))
nums.sort(reverse=True)
#print(nums)

alice=[]
bob=[]

for i in range(n):
    if i%2==0:
        alice.append(nums[i])

    else:
        bob.append(nums[i])

print(sum(alice)-sum(bob))


Measured memory_bytes: 3060
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#define RG register
#define LL long long
using namespace std;
const int N=2e5+10;
struct node{ LL scr; int flg; }pt[N];
int n,m,tot;
LL ans;
template<typename I> inline void read(I &ot){
	I ch=getchar(), x=0, f=1;
	while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();	}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0'; ch=getchar();	}
	ot=x*f;}
template<typename I, typename... U> inline void read(I &x,U&... y){read(x); read(y...);}
inline bool cmp(node a,node b){return a.scr<b.scr;}
int main()
{
	//freopen("Gr-idian MST.in","r",stdin);
	//freopen(".out","w",stdout);
	read(n,m); tot=n+m;
	for(int i=1;i<=n;i++) read(pt[i].scr);
	for(int i=1;i<=m;i++) read(pt[i+n].scr), pt[i+n].flg=1;
	sort(pt+1,pt+1+tot,cmp);
	n++; m++;
	for(int i=1;i<=tot && n && m;i++)
	{
		ans+=pt[i].scr*(pt[i].flg ? n : m);
		if(pt[i].flg) m--; else n--;
	}
	printf("%lld\n",ans);
	//fclose(stdin); fclose(stdout);
	return 0;
}

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

using namespace std;

using ll = long long;

int main() {
    ll x, y;
    cin >> x >> y;
    if(x >= 0 && y >= 0){
        if(x <= y)cout << y - x << endl;
        else {
            if(y == 0)cout << x - y + 1 << endl;
            else cout << x - y + 2 << endl;
        }
    }else if(x >= 0 && y < 0){
        if(x < abs(y))cout << abs(y) - x + 1<< endl;
        else cout << x - abs(y) + 1 << endl;
    }else if(x < 0 && y >= 0){
        if(abs(x) < y)cout << y - abs(x) + 1 << endl;
        else if(y == 0)cout << abs(x) << endl;
        else cout << abs(x) - y + 1 << endl;
    }else{
        if(abs(x) < abs(y))cout << abs(y) - abs(x) + 2 << endl;
        else cout << abs(x) - abs(y) << endl;
    }
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int a[100];
int main(){
	int n;
	cin>>n;
	for(int i=n-1;i>=0;i--){
		cin>>a[i];
	}
	for(int j=0;j<n-1;j++){
		cout<<a[j]<<' ';
	}
	cout<<a[n-1]<<endl;
}


Measured memory_bytes: 3096
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001; // > 10^9
const int MOD = (int)1e9 + 7;
const ll INFLL = 1001001001001001001;  // > 10^18
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

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

    double ans = (n/2)+ (n % 2);
    ans /= n;

    cout << setprecision(12) << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
class SegmentTree():
    def __init__(self,n):
        self.e = 0
        self.r = 0 #ノードの段数
        cnt = 0
        while cnt<n:
            cnt=2**self.r
            self.r +=1
        self.tree = [self.e]*(2**self.r -1)# 0-index
        self.n = 2**(self.r-1) #一番下のnodeの数
    def func(self,a,b): #適宜書き換え
        return a|b
    def update(self,i,val):
        i += self.n -1
        self.tree[i] = val
        while i>0:
            i = (i-1)//2
            self.tree[i] = self.func(self.tree[i*2+1],self.tree[i*2+2])

    def query(self,l,r):
        l += self.n -1
        r += self.n -1 #開区間 idxはr-1
        lval = self.e
        rval = self.e
        while r>l:
            if l%2 == 0:
                lval = self.func(lval,self.tree[l])
                l+=1
            if r%2==0:
                rval = self.func(rval,self.tree[r-1])
                r-=1
            r//=2
            l//=2
        return self.func(lval,rval)
    def index(self,i):
        return i+self.n -1
def sid(s):
    return ord(s)-ord("a") #chr("a") == 0

import sys
input = sys.stdin.readline
n = int(input())
S = input()[:-1]
Q = int(input())
seg = SegmentTree(n)
for i in range(n):
    s = S[i]
    seg.update(i,2**(sid(s)))
for q in range(Q):
    num,a,b = input().split()
    if num=="1":
        seg.update(int(a)-1,2**sid(b))
        #print(a,b,list(map(lambda x:bin(x)[2:],seg.tree)))
    else:
        print(bin(seg.query(int(a)-1,int(b))).count("1"))


Measured memory_bytes: 70216
fun main(){
    val (n, k) = readLine()!!.split(" ").map{it.toInt()}
    val p = readLine()!!.split(" ").map{it.toDouble()}
    val expectedValue = p.map{(it + 1) /2}

    val expectedValueTotal = mutableListOf<Double>()
    var tmp = 0.0
    expectedValueTotal.add(0.0)
    expectedValue.forEach{
        tmp += it
        expectedValueTotal.add(tmp)
    }
    //println(expectedValueTotal)
    var max = 0.0
    for(i in 1 .. expectedValueTotal.size - k){
        (expectedValueTotal[i + k - 1] - expectedValueTotal[i-1]).let{
            if(it > max) max = it
        }
    }
    println(max)
}

Measured memory_bytes: 73448
#include<bits/stdc++.h>
using namespace std;
int a[3],N,ans[100010];
char s[100010][3];
int main(){
	cin>>N>>a[0]>>a[1]>>a[2];
	for (int i=1; i<=N; i++) scanf("%s",s[i]);
	int flag = 1;
	for (int i=1; i<=N; i++){
		int x = s[i][0]-'A', y = s[i][1]-'A';
		if (!a[x] && !a[y]){
			flag = 0;
			break;
		}
		if (a[x] > a[y]) ans[i] = y, a[x]--, a[y]++;
		else if (a[x] < a[y]) ans[i] = x, a[x]++, a[y]--;
		else {
			int x2 = s[i+1][0] - 'A', y2 = s[i+1][1] - 'A';
			if (x == x2 || x == y2) ans[i] = x, a[x]++, a[y]--;
			else ans[i] = y, a[y]++, a[x]--;
		}
	}
	if (!flag) puts("No");
	else {
		puts("Yes");
		for (int i=1; i<=N; i++) printf("%c\n",ans[i]+'A');
	}
	return 0;
}

Measured memory_bytes: 4432
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n;
	string a;
	int cnt=0;
	cin>>n;
	cin>>a;
	int i,j,k;
	for(i=0;i<n;i++){
		string h;
		cin>>h;
		int l=0;
		bool flg=false;
		for(j=0;j<h.size();j++){
			if(h[j]==a[l]){
				l++;
			}
			if(a.size()==l){
				flg=true;
				break;
			}
		}
		if(flg){
			bool flg1=false;
			for(j=0;j<h.size();j++){
				if(h[j]==a[0]){
					//cout<<h[j]<<endl;
					for(k=1;k<h.size();k++){
						int x=j;
						int y=1;
						while(1){
							x+=k;
							if(x>=h.size()){
								break;
							}
							if(h[x]==a[y]){
								y++;
							}
							else{
								break;
							}
							if(y==a.size()){
								flg1=true;
							}
						}
					}
					if(flg1){
						//cout<<"I="<<i<<endl;
						cnt++;
						break;
					}
				}
			}
		}
	}
	cout<<cnt<<endl;
	return 0;
}
								
								
						
						
						
			
				


Measured memory_bytes: 3180
/*
* @author:  codancer
* @createTime:  2020-03-28, 20:47:29
*/
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define fep(i,a,b) for(int i=(a);i>=(b);i--)
typedef vector<int> VI;
typedef vector<ll> VII;
typedef pair<int,int> pii;
priority_queue<ll> C;
priority_queue<ll,vector<ll>,greater<ll>> R,G;

int main(){
	ll x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;

	ll t;
	rep(i,1,a){
		cin>>t;
		R.push(t);
	}
	rep(i,1,b){
		cin>>t;
		G.push(t);
	}
	rep(i,1,c){
		cin>>t;
		C.push(t);
	}

	while(R.size()>x){
		 R.pop();
	}
	while(G.size()>y){
		 G.pop();
	}

	while(!C.empty()&&C.top()>=min(R.top(),G.top())){
		ll aminn=R.top();
		ll bminn=G.top();
		if(aminn<=bminn){
			R.pop();
			R.push(C.top());
			C.pop();
			continue;
		}else{
			G.pop();
			G.push(C.top());
			C.pop();
		}
	}
	ll ans=0;
	while(!R.empty()){
		ans+=R.top();
		R.pop();
	}
	while(!G.empty()){
		ans+=G.top();
		G.pop();
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

int main(int argc, char *argv[])
{
    // input from txt （提出時にこの箇所は削除すること）
    //std::ifstream in("in.txt");
    //std::cin.rdbuf(in.rdbuf());
    
    
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);

    int a, b, area, length;
    cin >> a >> b;
    area = a*b;
    length = 2*(a+b);
    cout << area << ' ' << length << endl;
    return 0;
}



Measured memory_bytes: 3104
import java.util.Arrays;
import java.util.Scanner;


public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(); sc.nextLine();
		
		for(int i = 0; i < n; i++) {
			String str = sc.nextLine();
			int[] in = new int[8];
			for(int j = 0; j < 8; j++) in[j] = Integer.parseInt(str.substring(j, j+1));
			
			int max = max(in);
			int min = min(in);
			System.out.println(max-min);
		}
		sc.close();
	}
	
	static int min(int[] n) {
		int[] copy = Arrays.copyOf(n, n.length);
		Arrays.sort(copy);
		int result = 0;
		int digit = 1;
		for(int i = copy.length - 1; i >= 0; i--) {
			result += digit * copy[i];
			digit = digit * 10;
		}
		return result;
	}
	
	static int max(int[] n) {
		int[] copy = Arrays.copyOf(n, n.length);
		Arrays.sort(copy);
		int result = 0;
		int digit = 1;
		for(int i = 0; i < copy.length; i++) {
			result += digit * copy[i];
			digit = digit * 10;
		}
		return result;
	}
	
}

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;


int main() {
  ll n; cin>>n;
  ll k; cin>>k;
  cout<<(n-1+k-2)/(k-1)<<endl;
}

Measured memory_bytes: 256