akhauriyash/Code-Regression huggingface dataset:
def D():
    N, K = map(int, input().split())
    P = [int(n) for n in input().split()]
    C = [int(n) for n in input().split()]
    cycle_sums = [float('-inf')]*N
    cycle_length = [-1]*N
    for i in range(N):
        # every element is guaranteed to be in a cycle
        if cycle_sums[i] == float('-inf'): #have not been processed, g
            points = 0
            visited_set = set()
            visited_order = []
            while P[i] not in visited_set:
                visited_set.add(P[i])
                visited_order.append(P[i])
                i = P[i]-1
            _sum = 0
            for j in range(len(visited_order)):
                _sum += C[visited_order[j]-1]
            for j in range(len(visited_order)):
                cycle_sums[visited_order[j]-1] = _sum
                cycle_length[visited_order[j]-1] = len(visited_order)
    #print(cycle_sums, cycle_length)

    ans = float('-inf')
    for j in range(N):
        i = j
        k = K
        points = 0
        if cycle_sums[i] > 0:
            num_cycles, remainder = divmod(k, cycle_length[i])
            if num_cycles > 0:
                num_cycles -= 1
                remainder += cycle_length[i]
            points += cycle_sums[i] * num_cycles
            k = remainder
        else:
            #make at least one move
            i = P[i]-1
            points += C[i]
            k = min(k, cycle_length[i]-1)
        #print(j, points)
        _sum = points

        while k > 0:
            i = P[i]-1
            _sum += C[i]
            points = max(points, _sum)
            k -= 1
        #print(j, points)
        ans = max(ans, points)

    return ans
        # visited_dict = {}
        # visited_order = []
        # while K > 0 and P[i] not in visited_dict:
        #     visited_dict[P[i]] = len(visited_order)
        #     visited_order.append(P[i])
        #     i = P[i]-1
        #     points += C[i]
        # if K > 0: #cycle found
        #     cycle_len = len(visited_order) - visited_dict(P[i])
        #     num_cycles_left, remainder = divmod(K, cycle_len)
        #     _sum = 0
        #     for j in range(visited_dict(P[i]), len(visited_order)):
        #         _sum += C[visited_order[j]]
        #         if j - visited_dict(P[i]) == remainder-1:
        #             points += _sum
        #     points += num_cycles_left*_sum

print(D())

Measured memory_bytes: 74580
#include <stdio.h>
#include <iostream>
#include <string>
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
 
int long long dp[110][100010];
int long long c[110][2];
int main(){
  	int long long n, w;
  	cin >> n >> w;
	rep(i,n)rep(j,2)cin>>c[i][j];//scanf("%d",&c[i][j]);
	//memset(dp,0x3f,sizeof(dp));
for(int long long i = 0; i < 100; i++){
    for(int long long j = 0; j < 100001; j++){
      if(j == 0){
        dp[i][j] = 0;
      }
      else{
        dp[i][j] = INF;
      }
    }
}

dp[0][c[0][1]] = c[0][0];
//dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - c[i][0](w)] + c[i][1](v))//
for(int long long i = 1; i < n; i++){
    for(int long long j = 0; j < 100001; j++){
          if(j - c[i][1] >= 0){
           	dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - c[i][1]] + c[i][0]);
          }
          else{
              dp[i][j] = dp[i - 1][j];
          }
    }
}
 int long long ans = 0;
 for(int long long j = 1; j < 100001; j++){
   if(w >= dp[n - 1][j]){
     ans = j;
   }
 }
	cout<<(ans)<<endl;
  //cout<<(dp[n - 1][100000])<<endl;
}

Measured memory_bytes: 80128
n=int(input())
l=list(map(int,input().split()))
l1=[];l2=[]
for i in range(n):
  if i%2==n%2:l1.append(l[i])
  else:l2.append(l[i])
l2.reverse()
for j in range(len(l1)):
  l2.append(l1[j])
for j in range(n):
  print(l2[j],end=' ')

Measured memory_bytes: 26180
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0;i < n;++i){
    cin >> a[i];
  }
  long long ans = LLONG_MAX, cum = 0, tmp = 0;
  for (int i = 0; i < n; ++i){
    cum += a[i];
    if (i % 2 == 0){
      if (cum <= 0){
        tmp += -cum + 1;
        cum = 1;
      }
    }else{
      if (cum >=0){
        tmp += cum + 1;
        cum = -1;
      }
    }
  }
  ans = min(ans,tmp);
  cum = tmp = 0;
  for (int i = 0; i < n; ++i){
    cum += a[i];
    if (i % 2 == 1){
      if (cum <= 0){
        tmp += -cum + 1;
        cum = 1;
      }
    }else{
      if (cum >=0){
        tmp += cum + 1;
        cum = -1;
      }
    }
  }
  ans = min(ans, tmp);
  cout << ans << endl;
}

Measured memory_bytes: 1024
# coding:utf-8

import sys
import heapq
import itertools
from collections import defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def dijkstra(start: int, size: int, graph: dict) -> list:
    costs = [INF] * size
    costs[start] = 0
    hp = []
    heapq.heappush(hp, (0, start))
    while hp:
        hc, hv = heapq.heappop(hp)
        for to, move_cost in graph[hv]:
            if hc + move_cost >= costs[to]:
                continue
            costs[to] = hc + move_cost
            heapq.heappush(hp, (costs[to], to))

    return costs


n, m, r = LI()
R = LI_()

G = defaultdict(list)
for i in range(m):
    a, b, c = LI()
    a -= 1
    b -= 1
    G[a].append((b, c))
    G[b].append((a, c))

C = {}
for ri in R:
    C[ri] = dijkstra(ri, n, G)

ans = INF
for root in itertools.permutations(R):
    tmp = 0
    for i in range(r - 1):
        tmp += C[root[i]][root[i + 1]]
    ans = min(ans, tmp)

print(ans)


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

Measured memory_bytes: 4392
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
 
using namespace std;
 
class Car{
public:
  int id, in_time, rem_time;
  Car(){}
  Car(int a, int b, int c): id(a), in_time(b), rem_time(c){}
};
 
const int INF = (1<<28);
 
int m, n;
queue<Car> que;
Car pa[20];
vector<int> ans;
 
void init(){
  for(int i=0;i<m*2;i++) pa[i] = Car(-1, -1, -1);
  while(!que.empty()) que.pop();
  ans.clear();
}
 
bool is_full(){
  for(int i=0;i<m*2;i++) if(pa[i].id == -1) return false;
  return true;
}

void put_in(int t){
  while(!que.empty()){
    Car c = que.front();
    if(c.in_time > t || is_full()) break;
    int pos = -1;
    for(int i=1;i<m*2;i+=2){
      if(pos == -1 && pa[i].id == -1 && pa[i-1].id == -1) pos = i;
    }
    if(pos != -1){
      pa[pos] = c;
      que.pop();
      continue;
    }
    int valm = INF;
    pos = -1;
    for(int i=0;i<m*2;i+=2){
      if(pa[i].id != -1) continue;
      if(pa[i+1].rem_time >= c.rem_time){
        if(valm > abs(pa[i+1].rem_time - c.rem_time)){
          valm = abs(pa[i+1].rem_time - c.rem_time);
          pos = i;
        }
      }
    }
    if(pos != -1){
      pa[pos] = c;
      que.pop();
      continue;
    }
    valm = INF;
    pos = -1;
    for(int i=0;i<m*2;i+=2){
      if(pa[i].id != -1) continue;
      if(valm > abs(pa[i+1].rem_time - c.rem_time)){
        valm = abs(pa[i+1].rem_time - c.rem_time);
        pos = i;
      }
    }
    if(pos != -1){
      pa[pos+1].rem_time = c.rem_time;
      pa[pos] = c;
      que.pop();
      continue;
    }
  }
}

void put_out(int t){
  while(1){
    int valm = INF;
    int ex_pos = -1;
    for(int i=0;i<m*2;i++){
      if(pa[i].id == -1) continue;
      if(pa[i].rem_time > 0) continue;
      if(valm > pa[i].rem_time){
        valm = pa[i].rem_time;
        ex_pos = i;
      }
    }
    if(ex_pos == -1) break;
    ans.push_back(pa[ex_pos].id);
    pa[ex_pos] = Car(-1, -1, -1);
  }
}

bool is_empty(){
  for(int i=0;i<m*2;i++) if(pa[i].id != -1) return false;
  return true;
}

main(){
  while(cin >> m >> n && (m|n)){
    init();
    for(int i=0;i<n;i++){
      Car in = Car(i+1, i*10, 0);
      cin >> in.rem_time;
      que.push(in);
    }
    for(int t=0;;t+=1){
      if(t > 0 && is_empty()) break;
      for(int i=0;i<m*2;i++){
        if(pa[i].id == -1) continue;
        pa[i].rem_time -= 1;
      }
      put_out(t);
      put_in(t);
    }
    cout << ans[0];
    for(int i=1;i<ans.size();i++) cout << " " << ans[i];
    cout << endl;
  }
}

Measured memory_bytes: 1216
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<int, pair<int, int>> PP;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const ll mod = 1e+9 + 7;
const int INF = 1001001001;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    int n;
    cin >> n;
    vector<ll> sum(n+1, 0);
    for(int i = 0; i < n; ++i){
        ll a;
        cin >> a;
        sum[i+1] = sum[i] + a;
    }
    ll res = 1e+18;
    for(int i = 1; i < n; ++i){
        ll snuke = sum[i];
        ll araiguma = sum[n] - sum[i];
        chmin(res, abs(snuke - araiguma));
    }
    cout << res << endl;
}

Measured memory_bytes: 1792
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */

using namespace std;
using ll = long long;
template <typename T>
T gcd(T a, T b) {
    if (a > b) return gcd(b, a);
    return a == 0 ? b : gcd(b % a, a);
}

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

    ll ans;
    cin >> ans;

    for (int i = 0; i < N - 1; ++i) {
        ll t;
        cin >> t;
        ans = t / gcd(ans, t) * ans;
    }

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


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007

int main(){
	long long int n, m;
	scanf("%lld%lld", &n, &m);
	long  long int answer = 0;
	if(m<=n*2) answer = (long long int) m/2;
	else{
		answer += n;
		m = m - n*2;
		answer += (long long int) m/4;
	}
	printf("%lld\n", answer);

	return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class D { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		long X = GetLong();
		long Y = GetLong();
		long Z = GetLong();
		long K = GetLong();
		var A = GetLongs(X);
		var B = GetLongs(Y);
		var C = GetLongs(Z);

		var AB = new List<long>((int)(X * Y));
		for(long i = 0; i < X; i++)
		{
			for(long j = 0; j < Y; j++)
				AB.Add(A[i] + B[j]);
		}
		AB.Sort((x, y) => y.CompareTo(x));

		var ABC = new List<long>((int)Min(K, AB.Count));
		for(int i = 0, E = (int)Min(K, AB.Count); i < E; i++)
		{
			for(int j = 0; j < Z; j++)
				ABC.Add(AB[i] + C[j]);
		}
		ABC.Sort((x, y) => y.CompareTo(x));
		WriteLine(string.Join("\n", ABC.Take((int)K)));
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


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

using namespace std;

typedef long long LL;

struct cww{cww(){
    ios::sync_with_stdio(false);cin.tie(0);
}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)

#define fi first
#define se second
#define pb push_back

template <typename T>inline void chmin(T &l,T r){l=min(l,r);}
template <typename T>inline void chmax(T &l,T r){l=max(l,r);}

template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}

typedef vector<LL> V;
typedef vector<V> VV;
typedef VV Graph;
Graph g;
V cost;
typedef pair<LL,LL> P;
typedef vector<P> RET;
RET opt_sort(vector<RET>& z){
    int rest=0;
    for(auto &it:z){
        it.pb(P(1145141919,0));
        rest+=it.size();
        reverse(it.begin(),it.end());
    }
    RET ret;
    while(rest>8){
        int id=0;
        REP(i,8)if(z[id].back()>z[i].back())id=i;
        if(ret.size()==0||ret.back().se>z[id].back().se)
            ret.pb(z[id].back());
        z[id].pop_back();
        rest--;
    }
    return ret;
}
RET dfs(int v,const LL lim){
    if(g[v].size()==0)return {P(cost[v],cost[v])};
    auto l=dfs(g[v][0],lim);
    auto r=dfs(g[v][1],lim);
    int n=l.size(),m=r.size();
    if(n==0||m==0)return RET();
    vector<RET> z(8);
    //l.fi+r.se
    for(int i=0,j=0;i<n;i++){
        while(j+1<m&&l[i].se+r[j+1].fi<=lim)j++;     
        if(l[i].se+r[j].fi<=lim)
            if(l[i].fi<=r[j].se)z[0].pb(P(l[i].fi,r[j].se));
            else z[1].pb(P(r[j].se,l[i].fi));
    }
    //r.fi+l.se
    for(int i=0,j=0;i<m;i++){
        while(j+1<n&&r[i].se+l[j+1].fi<=lim)j++;
        if(r[i].se+l[j].fi<=lim)
            if(r[i].fi<=l[j].se)z[2].pb(P(r[i].fi,l[j].se));
            else z[3].pb(P(l[j].se,r[i].fi));
    }
    //l.se+r.se
    for(int i=n-1,j=0;i>=0;i--){
        while(j+1<m&&l[i].fi+r[j+1].fi<=lim)j++;     
        if(l[i].fi+r[j].fi<=lim)
            if(l[i].se<=r[j].se)z[4].pb(P(l[i].se,r[j].se));
            else z[5].pb(P(r[j].se,l[i].se));
    }
    //l.fi+r.fi
    for(int i=0,j=m-1;i<n;i++){
        while(j>0&&l[i].se+r[j-1].se<=lim)j--;     
        if(l[i].se+r[j].se<=lim)
            if(l[i].fi<=r[j].fi)z[6].pb(P(l[i].fi,r[j].fi));
            else z[7].pb(P(r[j].fi,l[i].fi));
    }
    REP(i,8)for(auto &it:z[i]){
        it.fi+=cost[v];
        it.se+=cost[v];
    }
    REP(i,4)reverse(z[i*2+1].begin(),z[i*2+1].end());
    // cout<<v<<endl;
    return opt_sort(z);
}
int main(){
    int N;
    cin>>N;
    g.resize(N);
    cost.resize(N,0);
    FOR(i,1,N){
        int a;cin>>a>>cost[i];
        g[a-1].pb(i);
    }
    LL ok=1e12,ng=-1;
    while(abs(ok-ng)>1){
        const LL mid=(ok+ng)/2;
        if(dfs(0,mid).size())
            ok=mid;
        else
            ng=mid;
        //   cout<<ok<<" "<<ng<<endl;
    }
    cout<<ok<<endl;
    return 0;
}


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

int main() {
  int a[3];
  for ( int i=0; i<3; i++ ) cin >> a[i];
  int x=a[2];
  sort(a,a+3);
  if ( a[1]==x ) cout << "Yes" << '\n';
  else cout << "No" << '\n';
  return 0;
}

Measured memory_bytes: 3608
import java.io.File;
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);
		// Scanner scan = new Scanner(new
		// File("D:\\UserArea\\J0124567\\Downloads\\ALDS1_5_D-in19.txt"));
		// while (scan.hasNext()) {

		int n = scan.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = scan.nextInt();

		msort(a, 0, n);

		System.out.println(cnt2);

		scan.close();
		System.exit(0);
	}

	static int cnt;
	static long cnt2;

	private static void msort(int[] a, int st, int max) {
		if (max - st < 2)
			return;
		int mid = (max + st) / 2;
		msort(a, st, mid);
		msort(a, mid, max);
		marge(a, st, mid, max);
	}

	private static void marge(int[] a, int st, int mid, int max) {
		int[] m1 = new int[mid - st + 1];
		int[] m2 = new int[max - mid + 1];

		for (int p = st, i = 0; p < mid; p++, i++)
			m1[i] = a[p];
		m1[m1.length - 1] = Integer.MAX_VALUE;

		for (int p = mid, i = 0; p < max; p++, i++)
			m2[i] = a[p];
		m2[m2.length - 1] = Integer.MAX_VALUE;

		int p1 = 0, p2 = 0;
		for (int i = st; i < max; i++)
			if (m1[p1] > m2[p2]) {
				a[i] = m2[p2++];
				cnt2 += (mid - st - p1);
			} else
				a[i] = m1[p1++];
		cnt += (max - st);
	}

}

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

int main() {
  int n;
  cin>>n;
  int memo=2*(1e5);
  int ans=0;
  for(int i=0;i<n;i++){
    int c;
    cin>>c;
    if(memo>=c){
      memo=c;
      ans++;
    }
  }
  cout<<ans<<endl;
}

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

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

  string o, e;
  cin >> o >> e;

  rep(i, o.length()+e.length()) {
    cout << (i&1 ? e[i/2] : o[i/2]);
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <math.h>
#include <map>
using namespace std;
static const int INF = 1e9+7;
// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, a, b) for (int i =a; i < b; i++)
#define all(a) a.begin(), a.end()
#define PI 3.14159265359

int main(){
    int n, l; cin >> n >> l;
    vector<string>s(n);
    rep(i, n){
        cin >> s[i];
    }
    sort(all(s));
    rep(i, n){
        cout << s[i];
    }
    cout << endl;
    return 0;
}   


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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

typedef long long ll;


int main(){
  int N, K;
  cin >> N >> K;
  if(K==1){
    cout << 0 << endl;
    return 0;
  }
  cout << N - K<< endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;


int main(){
  string s; cin>>s;
  set<int> se;
  rep(i,s.size()){
    se.insert(s[i]-'a');
  }
  rep(i,26){
    if(!(se.count(i))){
      char ans=i+'a';
      cout<<ans<<endl;
      return 0;
    }
  }
  cout<<"None"<<endl;

  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
using namespace std;

	long long dp[2000][2000] = {};
int main(){
	string t,b;
	cin >> t >> b;
	dp[0][0] = 1LL;

	for(int i=0; i<t.size(); i++){
		for(int j=0; j<b.size(); j++){
			dp[i+1][j] += dp[i][j];
			if(t[i] == b[j]){
				dp[i+1][j+1] += dp[i][j];
			}
			dp[i+1][j] %= 1000000007;
			dp[i+1][j+1] %= 1000000007;
		}
		dp[i+1][b.size()] += dp[i][b.size()];
	}

	cout << dp[t.size()][b.size()]%1000000007 << endl;

	return 0;
}



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

int main() {
    int N;
    cin >> N;
    int a[N];
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    vector<int> v;
    for(int i = 0; i < N; i++){
        v.push_back(a[i]);
        v.push_back(a[i]+1);
        v.push_back(a[i]-1);
    }

    map<int, int> mp;
    for(auto vv: v){
        mp[vv]++;
    }

    int MAX = -1;
    for(auto mmp:mp){
        MAX = max(MAX, mmp.second);
    }
    cout << MAX << endl;



    // int max_ans = -1;
    // for(int i = 0; i < 1e5 + 5; i++){
    //     int X = i;

    //     max_ans = max(ans, max_ans)
    // }



    // set<int> s;
    // for(int i = 0; i < N; i++){
    //     cin >> a[i];
    //     s.insert(a[i]);
    // }

    // int max_ans = -1;
    // for(auto ss: s){
    //     int ans = 0;
    //     for(int i = 0; i < N; i++){
    //         if(ss == a[i] || ss == (a[i]-1)  || ss == a[i]+1){
    //             ans++;
    //         }
    //     }
    //     max_ans = max(ans, max_ans);
    // }
    // cout << max_ans << endl;

    return 0;
}

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

#define BUF_SIZE 20

int get_int(void) {
  int num;
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return 0;
  sscanf(line, "%d", &num);
#else
#error
#endif
  return num;
}

int get_int2(int *a1, int *a2) {
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return -1;
  sscanf(line, "%d %d", a1, a2);
#else
#error
#endif
  return 0;
}

struct mat {
    int row;
    int col;
};

#define ROW_MAX 100
#define COL_MAX 100
#define NUM_MAX 100
#define DP_SIZE (NUM_MAX+1)*(NUM_MAX+1)
#define min(a,b) ((a) > (b) ? (b) : (a))

int calc_mult_cnt(struct mat *m1, struct mat *m2) {
    return m1->row * m1->col * m2->col;
}

int main(void) {
    int num = get_int();
    struct mat mat[NUM_MAX];

    int i;
    for(i = 0; i < num; i++) {
        get_int2(&mat[i].row, &mat[i].col);
    }
    // [size][start]
    int dp[NUM_MAX+1][NUM_MAX+1];
    memset(dp, 0x7f, sizeof(int)*DP_SIZE);
    // size = 0, 1
    for(i = 0; i < num; i++) {
        dp[0][i] = dp[1][i] = 0;
    }
    int size, start;
    // size >= 2
    for(size = 2; size <= num; size++) {
        for(start = 0; start < num-size+1; start++) {
            int size1;
            for(size1 = 1; size1 < size; size1++) {
                int size2 = size - size1;
                int start1 = start; int end1 = start+size1-1;
                int start2 = start+size1; int end2 = start+size-1;
                struct mat m1 = {mat[start1].row, mat[end1].col};
                struct mat m2 = {mat[start2].row, mat[end2].col};
                // dp[size1][start1] and dp[size2][start2] were calcurated before.
                dp[size][start] = min(
                    dp[size][start],
                    calc_mult_cnt(&m1, &m2) + dp[size1][start1] + dp[size2][start2]
                );
            }
        }
    }

    printf("%d\n", dp[num][0]);
    return 0;
}


Measured memory_bytes: 2096
H, W = map(int, input().split())
N = int(input())
a = list(map(int, input().split()))
ans = [['' for i in range(W)] for i in range(H)]
indexH = 0
indexW = 0
cnt = 0
for i in range(N):
    for j in range(a[i]):
        ans[indexH][indexW] = i + 1
        if cnt % 2 == 0:
            if indexW == W - 1:
                indexW = -1
                indexH += 1
                cnt += 1
            else:
                indexW += 1
        else:
            if indexW == -W:
                indexW = 0
                indexH += 1
                cnt += 1
            else:
                indexW -= 1

for i in ans:
    print(*i)

Measured memory_bytes: 3916
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;

int main(){

    int a,b,c,d;
  	cin >> a;
  cin >> b;
  cin >> c;
  cin >> d;
    if(a+b > c+d){
        cout << "Left";
    }else if (a+b == c+d){
        cout << "Balanced";
    }else  cout << "Right";

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# coding: utf-8
# Last Modified: 16/Nov/19 05:44:05 PM


import sys


def main():
    from math import factorial, sqrt
    from itertools import permutations

    n = int(input())
    arr = [get_array() for _ in range(n)]

    x = [i for i in range(n)]
    p = list(permutations(x))

    def dis(x1, y1, x2, y2):
        return sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)

    distance = 0
    for j in p:
        for i in range(1, len(j)):
            distance += dis(
                arr[j[i]][0], arr[j[i]][1], arr[j[i - 1]][0], arr[j[i - 1]][1]
            )
    print(distance / factorial(n))


get_array = lambda: list(map(int, sys.stdin.readline().split()))


get_ints = lambda: map(int, sys.stdin.readline().split())


input = lambda: sys.stdin.readline().strip()


if __name__ == "__main__":
    main()


Measured memory_bytes: 8052
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>

using namespace std;



int main() {
	int h, w;
	cin >> h >> w;

	vector<string> s(50);
	for (int i = 0; i < h; i++) {
		cin >> s.at(i);
	}

	vector<int> x{ 1, -1, 0, 0};
	vector<int> y{ 0, 0, 1, -1};
	bool flag1 = true;

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			bool flag2 = false;
			if (s.at(i).at(j) == '.') continue;

			for (int k = 0; k < 4; k++) {
				int dx = i + x.at(k);
				int dy = j + y.at(k);

				if (dx >= h || dx < 0) continue;
				if (dy >= w || dy < 0) continue;
				if (s.at(dx).at(dy) == '#') flag2 = true;
			}
			if (!flag2) {
				flag1 = false;
				break;
			}
		}
	}

	if (flag1) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long x;
  cin>>x;
  if(x<2){
    cout<<0;
    return 0;
  }
  long long n=1,n8=1,n9=1;
  for(int i=0;i<x;i++){
    n*=10;
    n%=1000000007;
  }
  for(int i=0;i<x;i++){
    n9*=9;
    n9%=1000000007;
  }
  for(int i=0;i<x;i++){
    n8*=8;
    n8%=1000000007;
  }
  n+=1000000007*2;
  n=n-n9-n9+n8;
  n%=1000000007;
  cout<<n;
  return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>

int main() {
  int wid = 0, hei = 0, w = 0, h = 0;
  scanf("%d %d\n%d %d", &wid, &hei, &w, &h);
  printf("%d\n", (wid-w)*(hei-h));
  return 0;
}


Measured memory_bytes: 128
N_str = input()
N = int(N_str)
ans = 0
for i in range(1,len(N_str),2):
  ans += 10**(i) -10**(i-1)
if len(N_str)%2 == 1:
  ans += 1+N-10**(len(N_str)-1)
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    string a[100];
    int n,l;
    cin>>n>>l;
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    for(int i=0;i<n;i++)
        cout<<a[i];
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
const int INF = 1e9;
const int EPS = 1e-9; 

int main() {
  int K;
  string S;
  cin >> K >> S;
  
  string S_K;
  if(S.size() <= K) cout << S << endl;
  else {
    for(int i = 0; i < K; ++i) S_K.push_back(S.at(i));
    S_K.push_back('.');
    S_K.push_back('.');
    S_K.push_back('.');
    
    cout << S_K << endl;
  }
}

Measured memory_bytes: 3580
from functools import reduce

def cmb(n, r, p):
    r = min(n - r, r)
    if r == 0:
        return 1
    numer = reduce(lambda x, y: (x*y)%p, range(n, n - r, -1))
    denom = reduce(lambda x, y: (x*y)%p, range(1, r + 1))
    return (numer * pow(denom, p-2, p)) % p

p = 10 ** 9 + 7
n, a, b = map(int, input().split())

ans = pow(2, n, p) - 1
ans -= cmb(n, a, p) + cmb(n, b, p)
print(ans % p)

Measured memory_bytes: 39664
N = int(input())
A = sorted(list(map(int, input().split())))

m_a = max(A)+1
dp = [0]*m_a

for i in A:
    dp[i] += 1
    if dp[i]==1:
        for j in range(i*2, m_a, i):
            dp[j] += 2
    # print(dp)
print(dp.count(1))

Measured memory_bytes: 32252
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;

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

int func(int a, int b, int c){ //交換の操作を1回行うことができれば1を、行えなければ0を返す関数
    if(a % 2 == 1 || b % 2 == 1 || c % 2 == 1) return 0;
    if(a == b && b == c) return -1;
    return func((b + c) / 2, (a + c) / 2, (a + b) / 2) + 1;
}

int main(){
    long long A, B, C;
    cin >> A >> B >> C;
    long long  ans = func(A, B, C);
    cout << ans << endl;
    return 0;
}

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

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

    if(n>63)cout <<64 << endl;
    else if(n>31)cout << 32<< endl;
    else if(n>15)cout <<16 << endl;
    else if(n>7)cout <<8 << endl;
    else if(n>3)cout <<4 << endl;
    else if(n>1)cout <<2 << endl;
    else cout << 1 << endl;
    return 0;
    
}

Measured memory_bytes: 256
require "set"

h, w = gets.to_s.split.map &:to_i
w += 2
cells = ("#" * w + h.times.map {'#' + gets.chomp + '#'}.join("") + "#" * w).chars
h += 2
whites = cells.count '.'

def bfs(cells, w, h, to)
  q = [[w+1, 0]]
  cells[w+1] = '#'
  until q.empty?
    i, d = q.shift
    return d if i == to
    [-1, 1, -w, w].each do |j|
      if cells[i+j] == '.'
        cells[i+j] = '#'
        q << [i+j, d+1]
      end
    end
  end
  nil
end

dist = bfs(cells, w, h, w*(h-2)+w-2)
if dist
  p whites - dist - 1
else
  p -1
end

Measured memory_bytes: 14504
#include<stdio.h>
#include<stdlib.h>
#include <string.h>
#define MAX 100001



typedef struct {
  int parentno;
  int depth;
  char type[20];
  int *children;
  int degree;
} node ;

node x[MAX];


int countDepth(node y, int depth){
  if(y.parentno == -1) return depth;
  return countDepth(x[y.parentno],depth+1);
}

int main(){
  int i,j,n,num,r[MAX],no;



  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    x[i].parentno=-1;
  }
  for(i=0;i<n;i++){

    scanf("%d",&no);//printf("\nDEBUG: %d\n",x[no].degree);
    scanf("%d",&x[no].degree);
    x[no].children = (int *)malloc(sizeof(int)*x[no].degree);
    for(j=0;j<x[no].degree;j++){
      scanf("%d",&x[no].children[j]);//printf("DEBUG: %d\n",x[no].children[j]);
      
      x[x[no].children[j]].parentno = no;
    }
  }
  
  for(i=0;i<n;i++){
    x[i].depth = countDepth(x[i],0);
    if(x[i].depth == 0)
      strcpy(x[i].type,"root");
    else if(x[i].degree > 0)
      strcpy(x[i].type,"internal node");
    else
      strcpy(x[i].type,"leaf");
  }
  // 出力
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, %s, [",i,x[i].parentno,x[i].depth,x[i].type);
    //printf("\nDEBUG: %d\n",x[i].degree);
    for(j=0;j<x[i].degree;j++){
      if(j>0) printf(", ");
      printf("%d",x[i].children[j]);
    }
    printf("]\n");
  }
  
  for(i=0;i<n;i++)
    free(x[i].children);
  
  return 0;
}

Measured memory_bytes: 8708
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll ans;
int n,m,q;
int A[55];
int a[55];
int b[55];
int c[55];
int d[55];
void dfs(int step,int lim)
{
	if(step==n+1)
	{
		ll res=0;
		for(int i=1;i<=q;i++)
		{
			if(A[b[i]]-A[a[i]]==c[i])
				res+=d[i];
		}
		ans = max(ans,res);
		return ;
	}
	for(int i=lim;i<=m;i++)
	{
		A[step]=i;
		dfs(step+1,i);
	}
}
int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>m>>q;
	for(int i=1;i<=q;i++)
		cin>>a[i]>>b[i]>>c[i]>>d[i];
	dfs(1,1);
	cout<<ans;
}


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

using namespace std;

const int MAX_N = 1e5 + 5;
const int MAX_L = 20;
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;

int n, m;
int cnt[MAX_N];

void solve() {
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int l, r; cin >> l >> r;
        cnt[l]++;
        cnt[r + 1]--;
    }
    int ans = 0, cur = 0;
    for (int i = 1; i < MAX_N; i++) {
        cur += cnt[i];
        ans += (cur == m);
    }
    cout << ans;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int tc; tc = 1;
    for (int t = 1; t <= tc; t++) {
        //cout << "Case #" << t  << ": ";
        solve();
    }
}


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

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

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

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

ll combination(ll n, ll r) {
	if (n < 0 || r < 0 || r > n) return -1;

	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> num(r);
	vector<ll> den(r);

	for (ll i = 0; i < r; i++) {
		num[i] = n - r + i + 1;
		den[i] = i + 1;
	}

	for (ll p = 2; p <= r; p++) {
		ll pivot = den[p - 1];
		if (pivot > 1) {
			ll offset = (n - r) % p;
			for (ll k = p - 1; k < r; k += p) {
				num[k - offset] /= pivot;
				den[k] /= pivot;
			}
		}
	}
	ll result = 1;
	for (ll k = 0; k < r; k++) {
		if (num[k] > 1) result *= num[k];
	}
	return result;
}

int main() {
	int n, i, j;
	cin >> n;
	vector<vector<int>> a(2, vector<int>(n));
	for (i = 0; i < 2; i++) {
		for (int j = 0; j < n; j++) {
			cin >> a[i][j];
		}
	}
	int count = 0;
	int ma = 0;
	for (j = 1; j <= n; j++) {
		for (i = 0; i < j; i++) {
			count += a[0][i];
		}
		for (i = j-1; i < n; i++) {
			count += a[1][i];
		}
		ma = max(count, ma);
		count = 0;
	}
	cout << ma << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 10000;

int main() {
    int n, ma, mb;
    cin >> n >> ma >> mb;

    vector<int> a(n), b(n), c(n);
    int suma = 0, sumb = 0; 
    rep(i, n) {
        cin >> a[i] >> b[i] >> c[i];
        suma += a[i];
        sumb += b[i];
    }

    int dp[n+1][suma+1][sumb+1];  // dp[i+1][j][k] : i番目(iは0-index)までの薬品でAをjグラム,Bをkグラムとするときに必要な予算の最小値

    rep(i, n+1) {
        rep(j, suma+1) {
            rep(k, sumb+1) {
                dp[i][j][k] = INF;
            }
        }
    }

    dp[0][0][0] = 0;
    rep(i, n) {
        rep(j, suma+1) {
            rep(k, sumb+1) {
                if(j >= a[i] && k >= b[i]) {
                    dp[i+1][j][k] = min(dp[i][j][k], dp[i][j-a[i]][k-b[i]] + c[i]);
                }
                else {
                    dp[i+1][j][k] = dp[i][j][k];
                }
            }
        }
    }
    
    int ans = INF;
    for(int j = 1; j <= suma; j++) {
        for(int k = 1; k <= sumb; k++) {
            if(mb*j == ma*k) {
                ans = min(ans, dp[n][j][k]);
            }
        }
    }

    if(ans == INF) {
        cout << -1;
    }
    else {
        cout << ans;
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 9344
#include <iostream>
using std::cin;
using std::cout;

int main (){
  int n;
  cin >> n;
  if(n%2 == 0){
    cout << 0.5 << std::endl;
  }else{
    cout << (float)((n+1) / 2) / n << std::endl;
  }
  return 0; 
}

Measured memory_bytes: 256
def fill(v,cnt,num):
    global r
    global c

    #　ここの処理で
    # 死んでる最初の形式に戻した方が良いな
    # 数を詰める
    while cnt:
        if r%2==0:
            while c<w:
                if cnt==0:
                    return
                v[r][c] = num
                cnt-=1
                c+=1
            c-=1
            r+=1
        else:
            while c>=0:
                if cnt==0:
                    return
                v[r][c]=num
                cnt-=1
                c-=1
            c+=1
            r+=1
    return

h,w = map(int,input().split())
n = int(input())
a = list(map(int,input().split()))
ans = [[0 for _ in range(w)] for _ in range(h)]
r,c = 0,0
for i in range(n):
    fill(ans,a[i],i+1)
for i in range(h):
    for j in range(w):
        print(ans[i][j],end=' ')
    print('')

Measured memory_bytes: 3912
#include <bits/stdc++.h>
#define ll          long long
#define int 		long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define ff           first
#define ss           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

double dist(double x,double y){
	//write here
	return sqrt((x*x) + (y*y));
}

int32_t main(){
	cin.tie(NULL);
	ios::sync_with_stdio(false);
	//insert code
	int n;
	double d;
	cin>>n>>d;
	double x,y;
	int ans = 0;
	while(n--){
		cin>>x>>y;
		if (dist(x,y)<=d)ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

int main() {
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m, q;
  cin >> n >> m >> q;
  vector<int> a(q), b(q), c(q), d(q);
  for (int i = 0; i < q; ++i) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  function<int(vector<int>)> go = [&] (vector<int> v) {
    if ((int) v.size() == n) {
      int res = 0;
      for (int j = 0; j < q; ++j) {
        if (v[b[j] - 1] - v[a[j] - 1] == c[j]) {
          res += d[j];
        }
      }
      return res;
    }
    int res = 0;
    for (int j = v.empty() ? 1 : v.back(); j <= m; ++j) {
      v.push_back(j);
      res = max(res, go(v));
      v.pop_back();
    }
    return res;
  };
  cout << go({}) << "\n";
  return 0;
}

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

int main() {
    int A,B,C;
    cin >> A >> B >> C;

    int ans = 0;
    if (A + B >= C - 1){
    	ans = B + C;
    }else{
    	ans = (A + B + 1) + B;
    }
    cout << ans << endl;
}

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

int A[101];

void output(int n){
  for(int i=0;i<n;i++){
    cout << A[i];
    if(i<n-1) cout << " ";
    else cout << endl;
  }
}

void insertsort(int n){
  for(int i=0;i<n;i++){
    int v=A[i];
    int j=i-1;

    while(j>-1 && A[j]>v){
      A[j+1]=A[j];
      j--;
      A[j+1]=v;
    }
    output(n);
  }
}

int main()
{
  int n;
  cin >> n;
  for(int i=0;i<n;i++) cin >> A[i];
  insertsort(n);
  return 0;
}

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

int main(){
  long n, m, k, tmp;  cin >> n >> m >> k;
  vector<long> a(n+1, 0), b(m+1, 0);
  for(int i=1; i<=n; i++){
    cin >> tmp;
    a[i] = a[i-1] + tmp;
  }
  for(int i=1; i<=m; i++){
    cin >> tmp;
    b[i] = b[i-1] + tmp;
  }
  int b_idx = m, ans = 0;
  for(int i=0; i<=n; i++){
    if(a[i] > k)  break;
    while(a[i] + b[b_idx] > k)  b_idx--;
    ans = max(ans, i+b_idx);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6448
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int n,a;
  cin>>n>>a;
  cout << n * n - a << endl;

  return 0;
}


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

int main() {
    int x, y, t;

    for(int i = 0; ; i++) {
        cin >> x >> y;

        if(x == 0 && y == 0) {
            break;
        }

        if(y < x) {
            t = x;  x = y;  y = t; 
        }

        cout << x << " " << y << endl;
    }

    return 0;
}


Measured memory_bytes: 3060
import sys
from collections import defaultdict
from typing import Callable


def main():
    readline: Callable[[], str] = sys.stdin.readline

    memory: defaultdict = defaultdict(int)

    n: int = int(readline().rstrip())
    for _ in range(n):
        s: str = readline().rstrip()
        memory[s] += 1

    for judge in ("AC", "WA", "TLE", "RE"):
        print(f"{judge} x {memory[judge]}")

if __name__ == '__main__':
    main()


Measured memory_bytes: 10260
#include <iostream>
using namespace std;
typedef long long ll;
int t[20][20];
int main() {
  int n;
  cin>>n;
  ll ans = 0;
  for(int i = 0; i < n; ++i) {
    string s;
    cin>>s;
    int has_dot = 0;
    for(int i = 0; i < s.size(); ++i) {
      if(s[i] == '.') has_dot = 1;
    }
    if(!has_dot) {
      s.push_back('.');
    }
    while(s.size() < 10 || s[s.size()-10] != '.') {
      s.push_back('0');
    }
    ll y = 0;
    for(int i = 0; i < s.size(); ++i) {
      if(s[i] == '.') continue;
      y *= 10;
      y += s[i] - '0';
    }
    // cout<<s<<' '<<y;

    int d2 = 0;
    int d5 = 0;
    while(y % 2 == 0) {
      y /= 2;
      ++d2;
    }
    while(y % 5 == 0) {
      y /= 5;
      ++d5;
    }
    d2 = min(19, d2);
    d5 = min(19, d5);
    for(int p2 = 0; p2 < 20; ++p2) {
      for(int p5 = 0; p5 < 20; ++p5) {
        if(d2 + p2 >= 18 && d5 + p5 >= 18) {
          ans += t[p2][p5];
        }
      }
    }
    // cout<<' '<<d2<<' '<<d5<<endl;
    ++t[d2][d5];
  }
  cout<<ans<<endl;
}


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

using namespace std;

using ll = long long;
using ull = unsigned long long;
using D = double;
using ld = long double;
using ii = pair<int, int>;
using vi = vector <int>;
using vii = vector <ii>;

#define pb push_back
#define re return 
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fi first
#define se second
#define re return
#define sz(x) ((int) x.size())
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rei(i, n) for (int i = 0; i < (n); i++) 

const int inf = 2e9;

int main() {
 	ios::sync_with_stdio(0);
 	cin.tie(NULL);
 	cout.tie(NULL);
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
     	if (s[i] == 'R' && (i + 1) % 2 == 0) re cout << "No", 0;
     	if (s[i] == 'L' && (i + 1) % 2 != 0) re cout << "No", 0;
    }
    cout << "Yes";
 	re 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <stdlib.h>
#define ll long long
#define MOD_P 1000000007
using namespace std;

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

int main()
{
	int n, sum = 0;
	cin >> n;
	vector<int> seq(n);
	vector<int> gcdr;
	vector<int> gcdl;

	for (int i = 0; i < n; i++) {
		cin >> seq[i];
	}

	gcdr.emplace_back(0);
	gcdl.emplace_back(0);

	for (int i = 0; i < n; i++) {
		gcdl.emplace_back(gcd(gcdl[i], seq[i]));
		gcdr.emplace_back(gcd(gcdr[i], seq[n - i - 1]));
	}

	for (int i = 0; i < n; i++) {
		int tmp = gcd(gcdr[i], gcdl[n - i - 1]);
		if (tmp > sum) {
			sum = tmp;
		}
	}

	printf("%d", sum);


	return 0;
}

Measured memory_bytes: 1660
while True:
    A, op, B = input().split()   # 3変数ともに文字列として読み込む
    A =int(A)                   # a を整数に変換
    B = int(B)                   # b を整数に変換


    if op=="?": # opが"?"の時は終了
        break
    else:    #opが"?"以外の時
        if op=="+":
            print(A + B)
        elif op=="-":
            print(A - B)
        elif op=="*":
            print(A * B)
        elif op=="/":
            print(A // B)
        # ここ処理を書いてください
        # else のなかです。この通りのインデントを付けてください。


Measured memory_bytes: 5592
#include <iostream>
#include<map>
#include<vector>
#include<algorithm>
#include <stdio.h>
#include<set>
#include<string>
#include<math.h>
#include<cmath>
#include<iomanip>
#include<queue>
#include<stack>
#define ll long long
using namespace std;
long double pi = 3.14159265358979323846;
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);



int main()
{
	int n;  cin >> n;
	bool b = 0;
	while (n != 0) {
		b =b|| n % 10 == 7;
		n/= 10;
	}
	if (b)
		cout << "Yes";
	else
		cout << "No";
	/*for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			for (int k = 1; k <= n; k++)
				if (i == j && j == k)
					sum += i;
				else
					sum += gcd(i, j, k);*/
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  bool b=true;
  if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3]){
    cout << "Bad" << endl;
  }
  else {
    cout << "Good" << endl;
  }
}

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

public class Main {

	public static void main(String[] args)throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int a = Integer.parseInt(br.readLine());
		System.out.println(a/3);

	}

}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()

const int MAX = 2e5+10;
const int INF = 2e9;

int N, Q;
ll S[MAX], T[MAX], X[MAX];
ll D[MAX];

vi solve() {
    viii cs;
    REP (i, N) cs.PB(MT(X[i], S[i], T[i]));
    sort(ALL(cs));

    vi res(Q, -1);
    set<ii> d;
    REP (q, Q) d.insert(MP(D[q], q));
    d.insert(MP(-INF, -1));
    d.insert(MP(INF, -1));
    FORE (c, cs) {
        int x = get<0>(c), s = get<1>(c), t = get<2>(c);
        auto l = d.lower_bound(MP(s-x, -INF));
        auto r = d.lower_bound(MP(t-x-1, INF));
        for (auto it = l; it != r; it++) res[(*it).second] = x;
        d.erase(l, r);
    }
    return res;
}

int main() {
    cin >> N >> Q;
    REP (i, N) cin >> S[i] >> T[i] >> X[i];
    REP (i, Q) cin >> D[i];
    FORE (x, solve()) {
        cout << x << endl;
    }
}

Measured memory_bytes: 26604
#include<iostream>
using namespace std;
 
int main(){
    int a, b;
     
    cin>> a >> b;
     
    if ( a < b ) cout << "a < b" << endl;
    else if ( a > b ) cout << "a > b" << endl;
    else cout << "a == b" << endl;
 
    return 0;
}

Measured memory_bytes: 3088