akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> l(n);
  rep(i, n) cin >> l[i];
  sort(l.begin(), l.end());
  ll ans = 0;
  rep(i, n) rep(j, i) {
    auto low = upper_bound(l.begin(), l.end(), l[i]-l[j]); //これ以上
    auto high = lower_bound(l.begin(), l.end(), l[i]+l[j]); //これ未満
    int tmp = min(high-low, high-(l.begin()+i+1));
    ans += max(tmp, 0); //2辺より長い辺だけ取る
  }
  cout << ans << endl;
  return 0;
}

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

public class Main {
    public static void main(String[] args) throws IOException {
        OutputStream outputStream = System.out;
        PrintWriter out = new PrintWriter(outputStream);
        FastReader in = new FastReader();
        test a=new test();
        a.solve(in,out);
        out.close();
    }
}
class test{
    public void solve(FastReader in, PrintWriter out){
        int k=in.nextInt();
        int a=in.nextInt();
        int b=in.nextInt();
        boolean f =true;
        for(int i=a;i<=b;i++){
            if(i%k==0){
                out.println("OK");
                f=false;
                break;
            }
        }
        if(f){
            out.println("NG");
        }
    }
    public boolean src(int a[],int b[],int k,int l){
        for(int i=0;i<a.length;i++){
            if(a[i]==k && b[i]==l){
                return true;
            }
        }
        return false;
    }
    public int search(ArrayList<Integer> my){
        int max=my.get(0);
        int k=0;
        for(int i=1;i<my.size();i++){
            if(my.get(i)>max){
                max=my.get(i);
                k=i;
            }
        }
        return k;
    }
}

class FastReader{
    BufferedReader br;
    StringTokenizer st;

    public FastReader(){
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next(){
        while(st==null || !st.hasMoreElements()){
            try{
                st=new StringTokenizer(br.readLine());
            }
            catch(IOException e){
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt(){
        return Integer.parseInt(next());
    }

    Long nextLong(){
        return Long.parseLong(next());
    }

    double nextDouble(){
        return Double.parseDouble(next());
    }
    String nextLine(){
        String str="";
        try{
            str=br.readLine();
        }
        catch(IOException e){
            e.printStackTrace();
        }
        return str;
    }
}



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

using namespace std;

int main(){
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1;i<=n;i++){
        int temp;
        cin >> temp;
        if(i%2 && temp %2)ans++;
    }
    cout << ans << endl;
    // system("pause");
}

Measured memory_bytes: 3616
#define SUBMIT

#include <bits/stdc++.h>

using namespace std;

int main() {
#ifdef SUBMIT
    auto& in = cin;
#else
    stringstream in(R"(1 1
z
)");
#endif
    int h, w;
    in >> h >> w;

    string head_tail(w + 2, '#');
    cout << head_tail << endl;
    for (int i = 0; i < h; ++i) {
        string s;
        in >> s;
        cout << "#" << s << "#" << endl;
    }
    cout << head_tail << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input=lambda: sys.stdin.readline().rstrip()
n,a,b,c=map(int,input().split())
S=[input() for _ in range(n)]
if a==0 and b==0 and S[0]=="AB":
  print("No")
elif b==0 and c==0 and S[0]=="BC":
  print("No")
elif a==0 and c==0 and S[0]=="AC":
  print("No")
else:
  if a+b+c==1:
    chk=True
    Ans=[]
    for s in S:
      if s=="AB":
        if c==1:
          chk=False
        elif a==1:
          Ans.append("B")
          a,b=0,1
        else:
          Ans.append("A")
          a,b=1,0
      if s=="BC":
        if a==1:
          chk=False
        elif b==1:
          Ans.append("C")
          b,c=0,1
        else:
          Ans.append("B")
          b,c=1,0
      if s=="AC":
        if b==1:
          chk=False
        elif a==1:
          Ans.append("C")
          a,c=0,1
        else:
          Ans.append("A")
          a,c=1,0
    if not chk:
      print("No")
    else:
      print("Yes")
      for ans in Ans:
        print(ans)
  else:
    print("Yes")
    Ans=[]
    for i in range(n):
      if i==n-1:
        if S[i]=="AB":
          if a<=b:
            Ans.append("A")
          else:
            Ans.append("B")
        if S[i]=="BC":
          if b<=c:
            Ans.append("B")
          else:
            Ans.append("C")
        if S[i]=="AC":
          if a<=c:
            Ans.append("A")
          else:
            Ans.append("C")

      else:
        if S[i]=="AB":
          if a==1 and b==1 and c==0:
            if S[i+1]=="BC":
              Ans.append("B")
              a,b=0,2
            else:
              Ans.append("A")
              a,b=2,0
          elif a<=b:
            Ans.append("A")
            a+=1
            b-=1
          else:
            Ans.append("B")
            a-=1
            b+=1
        if S[i]=="BC":
          if a==0 and b==1 and c==1:
            if S[i+1]=="AB":
              Ans.append("B")
              b,c=2,0
            else:
              Ans.append("C")
              b,c=0,2
          elif b<=c:
            Ans.append("B")
            b+=1
            c-=1
          else:
            Ans.append("C")
            b-=1
            c+=1
        if S[i]=="AC":
          if a==1 and b==0 and c==1:
            if S[i+1]=="AB":
              Ans.append("A")
              a,c=2,0
            else:
              Ans.append("C")
              a,c=0,2
          elif a<=c:
            Ans.append("A")
            a+=1
            c-=1
          else:
            Ans.append("C")
            a-=1
            c+=1
    for ans in Ans:
      print(ans)
      

Measured memory_bytes: 17120
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
#define REP(i,n) for(int i=0;i<(int)n;++i)
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

ll Euclid(ll A, ll B){
    if(A<B) swap(A, B);
    ll C = B;
    while(C != 0){
        C = A%B;
        A = B;
        B = C;
    }
    return A;
}

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

    ll K;
    cin >> K;

    ll res = 0;
    REP(i, K){
        REP(j, K){
            REP(k, K){
                res += Euclid(i+1, Euclid(j+1, k+1));
            }
        }
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3656
parseInt(x::SubString{String}) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function hpush(h::Array{Tuple{Int,Int},1},x::Tuple{Int,Int})
	push!(h,x)
	if length(h) > 1
		l = length(h)
		k = div(l,2)
		while h[k][2]>x[2]&&k>=1
			tmp = h[k]
			h[k] = x
			h[l] = tmp
			k = max(div(k,2),1)
			l = div(l,2)
		end
	end
end

function hpop(h::Array{Tuple{Int,Int},1})
	x = h[1]
	z = pop!(h)
	if !isempty(h)
		h[1] = z
		k = 1
		l = length(h)
		while k <= l
			if 2*k>=l
				break
			elseif 2*k+1>=l
				if h[2*k][2]>=z[2]
					break
				else
					tmp = h[2*k]
					h[2*k] = z
					h[k] = tmp
					k = 2*k
				end
			else
				if h[2*k][2]>=z[2]&&h[2*k+1][2]>=z[2]
					break
				else
					t = h[2*k][2]<h[2*k+1][2]?2*k:2*k+1
					tmp = h[t]
					h[t] = z
					h[k] = tmp
					k = t
				end
			end
		end
	end
	x
end


function main()
	n,m = readline() |> split |> parseMap
	e = [Int[] for i in 1:3*n]
	for i in 1:m
		u,v = readline() |> split |> parseMap
		push!(e[u],n+v)
		push!(e[n+u],2*n+v)
		push!(e[2*n+u],v)
	end
	s,t = readline() |> split |> parseMap
	dis = -ones(Int,3*n)
	h = Array{Tuple{Int,Int},1}()
	push!(h,(s,0))
	while !isempty(h)
		v,w = hpop(h)
		if v == t
			break
		end
		for i in 1:length(e[v])
			if dis[e[v][i]]<0　|| dis[e[v][i]]>w+1
				dis[e[v][i]] = w+1
				hpush(h,(e[v][i],w+1))
			end
		end
	end
	println(dis[t]>=0?div(dis[t],3):-1)

end

main()

Measured memory_bytes: 222832
package main

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

func main() {
	A, B := ReadInt(), ReadInt()
	fmt.Println(A * B / GCD(A, B))
}

func GCD(a, b int) int {
	if b == 0 {
		return a
	}
	return GCD(b, a%b)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1844
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define pb push_back
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a.begin(), a.end());
	ll ans = 0;
	queue<int> q;
	q.push(a[n - 1]);
	for (int i = n - 2; i >= 0; i--) {
		ans += q.front();
		q.pop();
		q.push(a[i]);
		q.push(a[i]);
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 4764
from math import sqrt
from itertools import combinations
N = int(input())
matrix = [list(map(int, input().split())) for _ in range(N)]

def dist(A, B):
    return sqrt((A[0] - B[0])**2 + (A[1] - B[1])**2)

tot = 0
for combo in combinations(matrix, 2):
    tot += dist(*combo)

print(tot*2/N)

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 100010
#define rep(i,n) for (int i = 0; i < (n); ++i)
const ll mod = 1e9+7;

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; }

int a[MAXN][3];
int h[MAXN][3];
int main() {
    int N;
    cin >> N;
    for(int i=0; i<N; ++i) {
        for(int j=0; j<3; ++j) {
            cin >> a[i][j];
        }
    }

    for(int i=0; i<N; ++i){
        for(int j=0; j<3; ++j) {
            for(int k=0; k<3; ++k) {
                if(j!=k) chmax(h[i+1][j], h[i][k]+a[i][j]);
            }
        }
    }

    cout << max(h[N][0], max(h[N][1], h[N][2])) << endl;
}


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

using namespace std;
using ll = long long;

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

	string t = "";
	int idx = 0;
	int n = s.size();
	while (idx < n) {
		if (idx + 1 < n && s[idx] == 'B' && s[idx+1] == 'C') {
			t += "D";
			idx += 2;
		} else {
			t += s[idx];
			idx += 1;
		}
	}

	ll res = 0;
	ll cntA = 0;
	for (int i = 0; i < t.size(); ++i) {
		if (t[i] == 'D') { res += cntA; }
		else if (t[i] == 'A') { ++cntA; }
		else { cntA = 0; }
	}
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 776
#include <iostream>

using namespace std;

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

	for (int i = 0; i < m; ++i) {
		++city[a[i]];
		++city[b[i]];
	}
	for (int i = 1; i <= n; ++i) {
		cout << city[i] << endl;
	}
}

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

using namespace std;

#define INF 0x7FFFFFFF

int main() {
  int N, K, h_min = INF;
  vector<int> trees;
  
  cin >> N >> K;
  
  for (int i = 0; i < N; i++) {
    int in;
    
    cin >> in;
    
    trees.push_back(in);
  }
  
  sort(trees.begin(), trees.end());
  
  for (int i = 0; i < N - K + 1; i++) {
    h_min = min(h_min, trees[i + K - 1] - trees[i]);
  }
  
  cout << h_min << endl;
  
  return 0;
}

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

#ifndef __TOPCYBERFLOWER
#define debug(...) 0
#else
#define debug(...) cout << " [-] ", _dbg(#__VA_ARGS__, __VA_ARGS__)
template<class TH> void _dbg(const char *sdbg, TH h){ cout << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg != ',') cout << *sdbg++;
    cout << '=' << (h) << ','; 
    _dbg(sdbg+1, a...);
}
#endif

#define TYPEMAX(type)   numeric_limits<type>::max()
#define TYPEMIN(type)   numeric_limits<type>::min()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

int main(void){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n,m; cin>>n>>m;
    for(int i=0;i<m;i++){
        int x; cin>>x;
        n-=x;
    }
    cout<<(n<0?-1:n);
    return 0;
}

Measured memory_bytes: 3656
x = []
x << gets.chomp.to_f
x << gets.chomp.to_f
x << gets.chomp.to_f
x << gets.chomp.to_f
x << gets.chomp.to_f
y = []
z = []
for a in 0..4
  y << (x[a] / 10).ceil * 10
  z << y[a] - x[a]
end
ss = z.index(z.max)
result = y.inject(0) { |sum, x| sum + x } - y[ss] + x[ss]
result = result.to_i
puts result


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

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
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;
}

void solve(std::string S) {
  int ans = 0;
  for(int i = 0 ; i < S.size() / 2; i++){
    if( S[i] != S[S.size()-i-1]) ans++;
  }
  cout << ans << endl;
}

int main() {
  std::string S;
  std::cin >> S;
  solve(S);
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int inf = 999999999;
const double pi = acos(-1);

#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}

///////////////////////////////////////////////////////////////////////////

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if( a <= c && c <= b)cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

void main()
{
    long[string] d;
    foreach (_; 0 .. lread())
    {
        auto s = sread();
        if (s !in d)
        {
            d[s] = 0;
        }
        d[s]++;
    }
    foreach (_; 0 .. lread())
    {
        auto s = sread();
        if (s !in d)
        {
            d[s] = 0;
        }
        d[s]--;
    }
    d.values.reduce!max().max(0).writeln();
}


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

 
int main()
{ 
    ll t;
    t=1;
    while(t--)
    {
        string s,t;
        cin>>s>>t;
        ll count=0;
        for(ll i=0;i<s.length();i++)
        {
            if(s[i]==t[i])
            {
                continue;
            }
            else
            {
                count++;
            }
        }
        cout<<count<<endl;
    }
           
        
 return 0;
}

Measured memory_bytes: 3832
s = list(input())
key = ['A','T','G','C']
count = 0
flag = False
ans = 0
for i in range(len(s)):
  if s[i] in key:
    count += 1
    flag = True
  if flag==True and (s[i] not in key):
    ans = max(ans,count)
    count = 0
    flag = False
ans = max(ans,count)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
const long long INF = 1LL << 60;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  ll D;
  cin >> D;
  vector<ll> c(26);
  rep(i,26) cin >> c[i];
  vector<vector<ll>> s(D,vector<ll>(26));
  rep(i,D)
  {
    rep(j,26)
    {
      cin >> s[i][j];
    }
  }
  vector<int> t(D);
  vector<int> lastday(26);
  rep(i,26) lastday[i] = -1;
  rep(i,D)
  {
    ll M = 0;
    ll m = 0;
    rep(j,26)
    {
      if(i - lastday[j]>=26)
      {
        t[i] = j;
        break;
      }
      M = max(M,s[i][j]);
      if(M!=m)
      {
        t[i] = j;
      }
      m = M;
    } 
  }
  ll satisfy = 0;
  rep(i,D)
  {
    ll dissatisfy = 0;
    satisfy += s[i][t[i]];
    lastday[t[i]] = i;
    rep(j,26)
    {
      dissatisfy += c[j] * (i-lastday[j]);
    }
    satisfy -= dissatisfy;
    cout << t[i] + 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 3692
let rec range s t = if s > t then [] else s :: range (s + 1) t

let _ =
  let lst = range 0 9999 in
  let rec sum n r x =
    if n = 0 then r
    else sum (n - 1) (r + (x mod 10)) (x / 10) in
  try
    while true do
      let n = Scanf.scanf "%d\n" (fun x -> x) in
      Printf.printf "%d\n" (List.length (List.filter (fun x -> (sum 4 0 x) = n) lst))
    done
  with
    End_of_file -> ()

Measured memory_bytes: 3108
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
 
using namespace std;
 
int main() {
	// 入力
    int N;
    cin >> N;
    
    if (N<=999) cout << "ABC";
    else cout << "ABD";
}

Measured memory_bytes: 256
// D - Make Them Even
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)
using I4 = tuple<int,int,int,int>;
using VI4 = vector<I4>;

int main(){
	int H,W; cin>>H>>W;
	vvi A(H, vi(W)); rpz(i,H) rpz(j,W)cin>>A[i][j];

	VI4 YX;//[i]:{y,x,y',x'}
	int y1,x1,x2,y2;
	rpz(h, H) rpz(w, W){
		if(A[h][w] == 0) continue;
		if(A[h][w]%2 == 0) continue;
		y1 = y2 = h, x1 = x2 = w;
		if(w+1 == W) y2++; else x2++;
		y2 = min(H-1, y2), x2 = min(W-1, x2);
		if(y1==y2 && x1==x2) continue;
		A[y1][x1]--, A[y2][x2]++;
		YX.emplace_back(y1,x1,y2,x2);
	}

	cout<< YX.size() <<endl;
	for(auto t:YX){
		tie(y1,x1,y2,x2) = t;
		printf("%d %d %d %d\n",y1+1,x1+1,y2+1,x2+1);
	}
}

Measured memory_bytes: 5232
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 
  int n;
  cin >> n;
  vector<int> a(n);
  
 for(int i =0;i<n;i++){
   cin >> a.at(i);
 }
  sort(a.begin(),a.end());
  cout <<a.at(n/2)-a.at(n/2-1)<<endl;

}

Measured memory_bytes: 640
# 重さとしてありうるのは4種類
# 重さ0：x個,...
# x+y+z <= N. O(N^3)

N,W = map(int,input().split())
WV = [[int(x) for x in input().split()] for _ in range(N)]
w1 = WV[0][0]
V = [[],[],[],[]]
Vcum = [[0],[0],[0],[0]]

for w,v in WV:
  V[w-w1].append(v)

for i in range(4):
  s = 0
  V[i].sort(reverse = True) # desc
  for x in V[i]:
    s += x
    Vcum[i].append(s)
    

answer = 0
for a in range(len(V[0])+1):
  for b in range(len(V[1])+1):
    for c in range(len(V[2])+1):
      w = w1*a + (w1+1)*b + (w1+2)*c
      if w > W:
        break
      d = min((W-w)//(w1+3),len(V[3]))
      x = Vcum[0][a] + Vcum[1][b] + Vcum[2][c] + Vcum[3][d]
      answer = max(answer,x)
print(answer)      
      

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

int main()
{
	int N, K;
	string S;
	cin >> N >> K >> S;

	int cnt = 0;
	for( int i = 0; i < N - 1; i++ ) {
		if( S[i] == S[i + 1] ) cnt++;
	}
	int ans = min( N - 1, cnt + 2 * K );

	cout << ans << endl;

}

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

const long long M = 998244353;

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

    long long dp[c][d];
    for(int i = 0; i<c; i++){
        for(int j = 0; j<d; j++){
            dp[i][j] = 0;
        }
    }

    dp[a - 1][b - 1] = 1;

    for(long long i = a - 1; i<c; i++){
        for(long long j = b - 1; j<d; j++){
            if(i - 1 >= a - 1){
                dp[i][j] += dp[i - 1][j] * (j + 1);

                dp[i][j] %= M;
            }

            if(j - 1 >= b - 1){
                dp[i][j] += dp[i][j - 1] * (i + 1);

                dp[i][j] %= M;
            }

            if(i - 1 >= a - 1 && j - 1 >= b - 1){
                dp[i][j] -= (i) * (j) * dp[i - 1][j - 1];
                dp[i][j] %= M;
            }
        }
    }

    cout << (dp[c - 1][d - 1] + M) % M;

}


Measured memory_bytes: 73896
import sys
def check(here, count):
	return ((abs(here[0]-s[count][0]))**2 + (abs(here[1]-s[count][1]))**2 <= 2)
		
def dfs(here, count):
	if count == n:
		result = True
	else:
		result = False
		for dx, dy in delta:
			next = (here[0]+dx,here[1]+dy)
			if lb[0] <= next[0] <= ub[0] and lb[1] <= next[1] <= ub[1] and check(next, count):
				result |= dfs(next, count+1)
	return result
delta = ((2, 0), (2, 1), (2, -1), (0, 2), (1, 2), (-1, 2), 
	(-2, 0), (-2, 1), (-2, -1), (0, -2), (1, -2), (-1, -2)) 

sys.setrecursionlimit = 1000000
lb = (0,0)
ub = (9,9)
while 1:
	here = map(int,raw_input().split(" "))
	if here == [0,0]:
		break
	n = int(raw_input())
	s = map(int,raw_input().split(" "))
	s = [(s[i*2],s[i*2+1]) for i in range(n)]
	if dfs(here, 0):
		print "OK"
	else:
		print "NA"

Measured memory_bytes: 4304
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
double pi=acos(-1);
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    ll sum=0;
    ll a[1006];
    ll b[1006];
    ll c[1006];



    for (int i=0;i<n;i++)
        {
            cin>>a[i];
            //sum+=a[i];
        }
        for (int i=0;i<n;i++)
        {
            cin>>b[i];

            sum+=b[i];
        }
        for (int i=0;i<n-1;i++)
        {
            cin>>c[i];
            //sum+=a[i];
        }
        for (int i=0;i<n-1;i++)
        {
            if (a[i]+1==a[i+1])
                sum+=c[a[i]-1];
        }
        cout<<sum<<endl;




    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
	
	int a, b;
	cin >> a >> b;
	for(int i=1; i<=1e4; ++i) {
		int a2=i*8/100, b2=i*10/100;
		if(a2==a&&b2==b) {
			cout << i;
			return 0;
		}
	}
	cout << -1;
}




Measured memory_bytes: 256
package main

import (
	. "fmt"
)

// func init() { Println("----------------------------------------") }

func main() {
    var n, d, x int
    Scanf("%d", &n)
    Scanf("%d %d", &d, &x)
    A := make([]int, 0, 100)
    for i := 0; i < n; i++ {
        a := 0
        Scanf("%d", &a)
        A = append(A, a)
    }

    ans := 0
    for i := 0; i < n; i++ {
        a := 1

        for a <= d {
            a += A[i]
            ans++
        }
    }

    Println(ans + x)
}


Measured memory_bytes: 512
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect, string
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**7)
inf = float('inf')
mod = 10**9+7
ans = inf ;count = 0 ;pro = 1

n=int(input())
A=list(map(int,input().split()))
C=collections.Counter(A)
for k,w in C.items():
    if k<w:
        count+=w-k
    elif k>w:
        count+=w
print(count)

Measured memory_bytes: 71408
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);

    int x;
    cin >> x;
    for (int i=-125;i<=125;i++)
    {
        for (int j=-125;j<=125;j++)
        {
            int a=pow(i,5)-pow(j,5);
            if (a==x)
            {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 4104
#include "bits/stdc++.h"
using namespace std;

#ifdef GCC
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

#define eb emplace_back
#define all(x) begin(x), end(x)
#define len(x) ((int)(x).size())
#define log(x) cout << (x) << "\n"
#define loop(i, begin, end)for(__typeof(end) i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define rep(i, n) loop(i, 0, n)

using ll = long long;
using vll = vector<ll>;

int main() {

    ll x, y, z, k;
    cin >> x >> y >> z >> k;
    vll A(x), B(y), C(z), XY, KZ;
    rep (i, x) cin >> A[i];
    rep (i, y) cin >> B[i];
    rep (i, z) cin >> C[i];

    rep(i,x) rep(j,y) XY.eb(A[i] + B[j]);
    sort(all(XY), greater<>());
    XY.resize(k);

    rep (i, z) rep (j, k) KZ.eb(C[i]+XY[j]);
    sort(all(KZ), greater<>());

    rep (i, k) log(KZ[i]);
}


Measured memory_bytes: 43240
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>

#define f first
#define s second
#define mp make_pair

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

using namespace std;

typedef unsigned int uint;
typedef long long ll;

int main(){
  char buff[2000];
  while(fgets(buff,sizeof(buff),stdin)){
    int len = strlen(buff);
    REP(i,len-5)
      if(strncmp(buff+i, "apple", 5) == 0) strncpy(buff+i, "peach", 5);
      else if(strncmp(buff+i, "peach", 5) == 0) strncpy(buff+i, "apple", 5);
    printf("%s",buff);
  }
  return 0;
}

Measured memory_bytes: 0
s = input()
if s[0] == "A":
    s = s[1:]
else:
    print('WA')
    exit()
flag = 1
for i in range(1,len(s)-1):
    if s[i] == "C":
        s = s[:i]+s[i+1:]
        flag = 0
        break
# print(s)
if flag:
    print("WA")
    exit()
if s.islower():
    print('AC')
else:
    print("WA")

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


int main(void) {

    int d,n;
    cin>>d>>n;
    if(n==100)n++;
    printf("%d\n",(int)(n*pow(100,d)));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define re register
using namespace std;
char s[100002],s1[2][200002];
int n,q,x,y,t,tmp,cnt[2];
char c;
int main(){
scanf("%s",s+1);
scanf("%d",&q);
while(q--){
	scanf("%d",&t);
	if(t==1){
		tmp^=1;
	}
	else{
		scanf("%d %c",&x,&c);
		s1[(x-1)^tmp][++cnt[(x-1)^tmp]]=c;
	}
}
reverse(s1[tmp]+1,s1[tmp]+cnt[tmp]+1);
if(tmp)reverse(s+1,s+strlen(s+1)+1);
printf("%s%s%s",s1[tmp]+1,s+1,s1[tmp^1]+1);
}

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

int Q;int A[100000];

int main() {
  for (int k=1;k<25000;k++) {
    bool sosu=true;
    int x=4*k+1;int y=2*k+1;
    for (int i=2;i<=int(sqrt(x));i++) {
      if (x%(i)==0 || y%(i)==0) {
        sosu=false;
        break;
      }
    }
    if (sosu) A[4*k]=1;
  }
  A[2]=1;
  for (int i=0;i<100000;i++) {
    A[i+1]+=A[i];
  }
  cin >> Q;
  for (int i=0;i<Q;i++) {
    int a,b;cin >> a >> b;a--;b--;
    cout << A[b]-A[a-1] << endl;
  }
}

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

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

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

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

void solve() {
    int n,k;
    cin >> n >> k;
    LL ans = 0;
    REP(b,k+1,n+1) {
        ans += max(0, n % b - max(0, k - 1));
        ans += n / b * (b - k);
    }
    cout << ans << endl;
}

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//const ll mod = 1e10;
typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;


int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    if (c - a - b <= 0) {
        cout << "No" << endl;
        ret();
    }
    ll aa = a * a;
    ll bb = b * b;
    ll cc = c * c;
    ll ab = a * b;
    ll bc = b * c;
    ll ca = c * a;

    ll l = ab * 4;
    ll r = aa + ab + ab - ca - ca + bb - bc - bc + cc;
    if (l < r) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll countDigit(ll n) { return floor(log10(n) + 1); } 
typedef pair <ll,ll> P;
static const ll dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) os << v[i] << " ";  
    return os; 
}

template <typename T1, typename T2> 
ostream& operator<<(ostream& os, const map<T1, T2>& m) 
{ 
    for (auto p : m) os << "<" << p.first << ", " << p.second << "> "; 
    return os; 
}

int main()
{
    string S;
    cin >> S;
    if (S.length() % 2 != 0) {
        cout << "No" << endl;
    } else {
        bool flag = true;
        rep(i, S.length() / 2) {
            if (S[2 * i] != 'h' || S[2 * i + 1] != 'i') {
                flag = false;
            }
        }
        if (flag) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
} 

Measured memory_bytes: 256
import java.util.*;

public class Main {

	int N, M, r;
	int[] ts, ns, ms, ss;

	void run(){
		Scanner in = new Scanner(System.in);
		for(;;){
			N = in.nextInt();
			M = in.nextInt();
			if(N==0 && M==0) return ;
			r = in.nextInt();
			ts = new int[r];
			ns = new int[r];
			ms = new int[r];
			ss = new int[r];
			for(int i=0; i<r; i++){
				ts[i] = in.nextInt();
				ns[i] = in.nextInt();
				ms[i] = in.nextInt();
				ss[i] = in.nextInt();
			}
			int q = in.nextInt();
			for(int i=0; i<q; i++){
				int start = in.nextInt(),
					end = in.nextInt(),
					m = in.nextInt();
				System.out.println(solve(start, end, m));
			}
		}
	}

	int solve(int start, int end, int m){
		int[] accum = new int[1300];
		for(int i=0; i<r; i++)if(ms[i] == m){
			if(ss[i] == 1) accum[ts[i]]++;
			else accum[ts[i]]--;
		}
		for(int t=1; t<1300; t++)
			accum[t] = accum[t] + accum[t-1];
		int ans = 0;
		for(int t=start; t<end; t++)
			if(accum[t] > 0) ans++;
		return ans;
	}

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

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

int main(){
    int N,K;cin>>N>>K;
    double ans = 0;

    for(int i = 1; i <= N ; i++){
        double tmp = i;
        double l = 1;
        while(tmp < K){
            tmp *= 2;
            l /=2;
        }
        ans += l/N;
    }
    printf("%.12f\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)

using namespace std;

int main() {
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    int A = int(n / a) * b;
    if(n % a != 0) A += b; 
    int C = int(n / c) * d;
    if(n % c != 0) C += d;
    cout << min(A,C) << endl;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

void bfs(queue<ll> que, vector<ll> &isVisited, vector<vector<ll> > &vec, ll K, vector<vector<pair<ll,ll> > > &length){
    que.push(K);
    isVisited[K] = 0;
    while(que.size() != 0){
        int q = que.front();
        rep(i,vec[q].size()){
            if (isVisited[vec[q][i]] == -1){
                que.push(vec[q][i]);
                isVisited[vec[q][i]] = isVisited[q] + length[q][i].second;
            }
        }
        que.pop();
    }
}

int main(){
    ll N;
    cin >> N;
    vector<ll> a(N - 1);
    vector<ll> b(N - 1);
    vector<ll> c(N - 1);
    rep(i,N - 1){
        cin >> a[i] >> b[i] >> c[i];
        a[i]--;
        b[i]--;
    }
    ll Q,K;
    cin >> Q >> K;
    K--;
    vector<ll> x(Q);
    vector<ll> y(Q);
    rep(i,Q){
        cin >> x[i] >> y[i];
        x[i]--;
        y[i]--;
    }
    vector<vector<ll> > connection(N, vector<ll> (0));
    rep(i,N - 1){
        connection[a[i]].push_back(b[i]);
        connection[b[i]].push_back(a[i]);
    }
    vector<ll> isVisited(N, -1);
    vector<vector<pair<ll,ll> > > length(N, vector<pair<ll,ll> > (0));
    rep(i,N - 1){
        length[a[i]].push_back(pair<ll,ll> (b[i], c[i]));
        length[b[i]].push_back(pair<ll,ll> (a[i], c[i]));
    }
    queue<ll> que;
    bfs(que, isVisited, connection, K, length);
    rep(i,Q){
        cout << isVisited[x[i]] + isVisited[y[i]] << endl;
    }
}


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

memo=[[0]*10 for i in range(10)]
for i in range(1,n+1):
  a = int(str(i)[0])
  b = int(str(i)[-1])
  memo[a][b]+=1
ans=0
for i in range(1,n+1):
  a = int(str(i)[0])
  b = int(str(i)[-1])
  ans+=memo[b][a]
print(ans)
    

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <math.h>
#include <queue>
using namespace std;
typedef long long int ll;

int main(){
	int a,b,q; cin >> a >> b >> q;
	vector<ll> s(a),t(b),x(q);
	for(int i=0;i<a;i++){
		cin >> s[i];
	}
	for(int i=0;i<b;i++){
		cin >> t[i];
	}
	for(int i=0;i<q;i++){
		cin >> x[i];
	}
	for(int i=0;i<q;i++){
		ll key=x[i];
		int left=-1; int right=s.size();
		while(right-left>1){
			int mid=(right+left)/2;
			if(s[mid]>=key){
				right=mid;
			}
			else{
				left=mid;
			}
		}
		ll mins1=(right!=s.size()?s[right]:1e18);
		ll mins2=(right!=0?s[right-1]:-1e18);

		left=-1; right=t.size();
		while(right-left>1){
			int mid=(right+left)/2;
			if(t[mid]>=key){
				right=mid;
			}
			else{
				left=mid;
			}
		}
		ll mint1=(right!=t.size()?t[right]:1e18);
		ll mint2=(right!=0?t[right-1]:-1e18);
		ll ans=min(max(mint1,mins1)-key,key-min(mint2,mins2));
		ans=min(ans,mins1-key+(mins1-mint2));
		ans=min(ans,mint1-key+(mint1-mins2));
		ans=min(ans,key-mins2+(mint1-mins2));
		ans=min(ans,key-mint2+(mins1-mint2));
		cout << ans << endl;
	}
}

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

ll dist(ll a, ll b) {
    if (a * b >= 0) {
        return max(abs(a), abs(b));
    } else {
        return min(abs(a), abs(b)) * 2 + max(abs(a), abs(b));
    }
}

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

    vector<ll> x(N);
    for (ll i = 0; i < N; i++) cin >> x[i];

    ll ans = 1e15;
    for (ll i = 0; i < N - K + 1; i++) {
        ans = min(ans, dist(x[i], x[i+K-1]));
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000
#define endl '\n'
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; }
using namespace std;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    string s; cin>>s;
    int a=0,b=0;
    rep(i,s.size()){
        if(s.at(i)=='(')a++;
        else b++;
        if(b>a){
            s='('+s;
            a++;
            i++;
        }
    }
    rep(i,max<int>(0,a-b))s+=')';
    cout<<s<<endl;
}

Measured memory_bytes: 256
I, O, T, J, L, S, Z = map(int, input().split())
ans = O
d = min(I, J, L)
a1 = 3 * d + (I - d) // 2 * 2 + (J - d) // 2 * 2 + (L - d) // 2 * 2
d -= 1
a2 = 0
if d >= 0:
    a2 = 3 * d + (I - d) // 2 * 2 + (J - d) // 2 * 2 + (L - d) // 2 * 2
ans += max(a1, a2)
print(ans)

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

int main()
{
    // 変数の宣言
    int p = 0;
    int g = 0;
    int r = 0;

    // 変数の入力を受け取る
    cin >> r;
    cin >> g;

    // 出力
    cout << 2 * g - r << endl;
}


Measured memory_bytes: 3612
import sys


def levenshtein_dist(s1: str, s2: str) -> int:
    m = len(s1)
    n = len(s2)
    table = [[sys.maxsize for j in range(n + 1)] for i in range(m + 1)]
    for i in range(m + 1):
        table[i][0] = i
    for j in range(n + 1):
        table[0][j] = j
    for i in range(1, m + 1):
        for j in range(1, n + 1):
            table[i][j] = min(table[i - 1][j] + 1,
                              table[i][j - 1] + 1,
                              table[i - 1][j - 1] + (s1[i - 1] != s2[j - 1]))
    return table[m][n]


if __name__ == "__main__":
    s1: str = input()
    s2: str = input()

    print(f"{levenshtein_dist(s1, s2)}")



Measured memory_bytes: 44032
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

#define REP(i, a) for (int i = 0; i < (a); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond, yes, no) \
    { cout << ((cond) ? (yes) : (no)) << endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(), (list).rend())
#define ASSERT(cond, mes) assert(cond&& mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())
    is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a) n = a;
    if (n > b) n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<ll> enum_div(ll n) {
    std::vector<ll> ret;
    for (ll i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i != 1 && i * i != n) { ret.push_back(n / i); }
        }
    }
    return ret;
}

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

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

struct ToUpper {
    char operator()(char c) {
        return toupper(c);
    }
};

struct ToLower {
    char operator()(char c) {
        return tolower(c);
    }
};

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

    int N, M;
    cin >> N >> M;
    priority_queue<int> A;
    REP(i, N) {
        int a;
        cin >> a;
        A.emplace(a);
    }

    REP(i, M) {
        int t = A.top();
        t /= 2;
        A.pop();
        A.push(t);
    }

    ll ans = 0;
    REP(i, N) {
        ans += A.top();
        A.pop();
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 892
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#pragma endregion

inline ll CEIL(ll a, ll b)
{
  return (a + b - 1) / b;
}

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

  int n;
  cin >> n;
  vector<pll> v;
  rep(i, n)
  {
    ll a, b;
    cin >> a >> b;
    v.push_back(MP(b, a));
  }
  sort(all(v));
  ll now = 0;
  for (auto p : v)
  {
    now += p.second;
    if (now > p.first)
    {
      Yes(false);
      return 0;
    }
  }
  Yes(true);
  return 0;
}


Measured memory_bytes: 6384
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

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

    int x, y;
    cin >> x >> y;

    cout << x + y / 2 << endl;

    return 0;
}


Measured memory_bytes: 888
#include <stdio.h>
#include <math.h>
#include <algorithm>
using namespace std;
 
int main(){
    double x1,x2,xp,y1,y2,yp1,yp,naiseki,norm1,norm2,gaiseki;
    int q;
 
    scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
    scanf("%d",&q);
 
    for(int i=0; i < q; i++){
        scanf("%lf %lf",&xp,&yp);
        norm1 = sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
        norm2 = sqrt((xp-x1)*(xp-x1)+(yp-y1)*(yp-y1));
        naiseki = (xp-x1)*(x2-x1)+(yp-y1)*(y2-y1);
        gaiseki = (x2-x1)*(yp-y1)-(xp-x1)*(y2-y1);
        if(fabs(naiseki/(norm1*norm2)+1) < 0.00000001){
            printf("ONLINE_BACK\n");
        }else if(fabs(naiseki-norm1*norm2)< 0.00000001){
            if(norm1 >= norm2){
                printf("ON_SEGMENT\n");
            }else{
                printf("ONLINE_FRONT\n");
            }
        }else if(gaiseki > 0){
            printf("COUNTER_CLOCKWISE\n");
        }else{
            printf("CLOCKWISE\n");
        }
    }
 
    return 0;
}


Measured memory_bytes: 2720