akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
//#include <math.h>
using namespace std;
typedef long long LL;

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

	bool res = true;
	string buf = "abc";
	for (int i = 0; i < 3; i++) {
		if (str.find(buf[i]) == string::npos)
			res = false;
	}

	cout << (res ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
number = int(input())
 
ac = 0
wa = 0
tle = 0
re = 0
for i in range(number):
  character = input()
  if character == 'AC':
    ac += 1
  if character == 'WA':
    wa += 1
  if character == 'TLE':
    tle += 1
  if character == 'RE':
    re += 1
 
print("AC x " + str(ac))
print("WA x " + str(wa))
print("TLE x " + str(tle))
print("RE x " + str(re))

Measured memory_bytes: 9224
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX 100001
#define MAXN 1000000007
#define pb push_back
#define f first
#define s second

int main()
{
    int n; cin>>n; 
    ll arr[n];
    for(int i=0; i<n; i++)cin>>arr[i];
    ll ans=0;
    for(int i=1; i<n; i++)
    {
        if(arr[i]<arr[i-1])
        {
            ans+=arr[i-1]-arr[i];
            arr[i] = arr[i-1];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 5196
import Control.Monad
import Data.List
import qualified Data.Set as S

main = do
    [x, y, z, k] <- map read <$> words <$> getLine
    a   <- sort <$> map read <$> words <$> getLine
    b   <- sort <$> map read <$> words <$> getLine
    c   <- sort <$> map read <$> words <$> getLine
    forM_ (solve k a b c) $ \ret -> putStrLn (show ret)

solve :: Int -> [Integer] -> [Integer] -> [Integer] -> [Integer]
solve k a b c = doit q m k
  where
    (q, m) = qpush S.empty S.empty (length a - 1) (length b - 1) (length c - 1)
    qpush q m ai bi ci | ai < 0 || bi < 0 || ci < 0 = (q, m)
                       | S.member (ai, bi, ci) m    = (q, m)
                       | otherwise                  = (newq, newm)
      where
        newq = S.insert (a !! ai + b !! bi + c !! ci, ai, bi, ci) q
        newm = S.insert (ai, bi, ci) m
    doit q m 0 = []
    doit q m k = s : doit q3 m3 (k - 1)
      where
        ((s, ai, bi, ci), q0) = S.deleteFindMax q
        (q1, m1) = qpush q0 m  (ai - 1) bi ci
        (q2, m2) = qpush q1 m1 ai (bi - 1) ci
        (q3, m3) = qpush q2 m2 ai bi (ci - 1)

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

using namespace std;

int main(void) {
  string s;
  cin >> s;
  vector<int> v(4);
  for (int i = 0; i < s.size(); i++) {
    v[i] = s[i] - '0';
  }
  for (int i = 0; i < (1 << 3); i++) {
    bitset<3> b(i);
    int ans = v[0];
    string m;
    for (int j = 0; j < 3; j++) {
      if (b.test(j)) {
        ans += v[j + 1];
        m[j] = '+';
      } else {
        ans -= v[j + 1];
        m[j] = '-';
      } 
    }
    if (ans == 7) {
      for (int i = 0; i < 3; i++) {
        cout << v[i] << m[i]; 
      }
      cout << v[3] << "=7" << endl;
      return 0;
    }
  }
  return 0;
}


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

int main() {
    int l;
    cin >> l;
    long double ans = 0;
    
    if (l < 10) {
        for (long double i=0.001; i<l; i+=0.001) {
            
            for (long double j=0.001; j<l; j+=0.001) {
                if (l <= i+j) continue;
                if (ans < (l-(i+j))*i*j) ans = (l-(i+j))*i*j;
            }
        }
    }

    else if (l < 100) {
        for (long double i=0.01; i<l; i+=0.01) {
            
            for (long double j=0.01; j<l; j+=0.01) {
                if (l <= i+j) continue;
                if (ans < (l-(i+j))*i*j) ans = (l-(i+j))*i*j;
            }
        }
    }

    else {
        for (long double i=0.1; i<l/2; i+=0.1) {
            for (long double j=0.1; j<l/2; j+=0.1) {
                if (l <= i+j) continue;
                if (ans < (l-(i+j))*i*j) ans = (l-(i+j))*i*j;
            }
        }
    }


    printf("%.12Lf\n", ans);
    return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace WelcomeAtcordet
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string input = Console.ReadLine();
            List<int> ans = new List<int>();
            ans.Add(0);

            foreach(char c in input)
            {
                if (c.Equals('I'))
                {
                    ans.Add((ans[ans.Count-1])+1);
                }
                else
                {
                    ans.Add((ans[ans.Count - 1]) - 1);
                }
            }

            Console.WriteLine(ans.Max());
        }
    }
}


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

using namespace std;

int calcAny(int n, int cnt) {
    if (cnt > n) {
        return 0;
    }
    int res = 1;
    int div = 1;
    for (int i = 0; i < cnt; i++) {
        div *= i+1;
        res *= 9*(n-i);
    }
    return res / div;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    string s;
    int k;
    cin >> s >> k;
    int n = s.length();
    vector<vector<int>> dp(k+1, vector<int>(n+1));
    dp[0].assign(n+1, 1);
    for (int d = 1; d <= k; d++) {
        for (int i = n-1; i >= 0; i--) {
            int cur = 0;
            int ls = s[i] - '0';
            if (ls > 0) {
                int rem = n-1-i;
                cur = (ls-1)*calcAny(rem, d-1) + calcAny(rem, d) + dp[d-1][i+1];
            } else {
                cur = dp[d][i+1];
            }
            dp[d][i] = cur;
        }
    }
    cout << dp[k][0] << endl;
}




Measured memory_bytes: 256
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

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

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

    ll arr[4][4][101] = {}; // A:0,C:1,G:2,T:3
    FOR(i, 0, 4)
    FOR(j, 0, 4)
    arr[i][j][2] = 1;

    FOR(i, 3, n + 1)
    {
        arr[0][0][i] = (arr[0][0][i - 1] + arr[0][1][i - 1] + arr[0][2][i - 1] + arr[0][3][i - 1]) % INF;
        arr[0][1][i] = (arr[1][0][i - 1] + arr[1][1][i - 1] + arr[1][3][i - 1]) % INF;
        arr[0][2][i] = (arr[2][0][i - 1] + arr[2][2][i - 1] - arr[3][1][i - 2] - arr[2][1][i - 2] + arr[2][3][i - 1]) % INF;
        arr[0][3][i] = (arr[3][0][i - 1] + arr[3][1][i - 1] + arr[3][2][i - 1] + arr[3][3][i - 1] - arr[2][1][i - 2]) % INF;

        arr[1][0][i] = (arr[0][0][i - 1] + arr[0][1][i - 1] + arr[0][2][i - 1] + arr[0][3][i - 1]) % INF;
        arr[1][1][i] = (arr[1][0][i - 1] + arr[1][1][i - 1] + arr[1][2][i - 1] + arr[1][3][i - 1]) % INF;
        arr[1][2][i] = (arr[2][0][i - 1] + arr[2][1][i - 1] + arr[2][2][i - 1] + arr[2][3][i - 1]) % INF;
        arr[1][3][i] = (arr[3][0][i - 1] + arr[3][1][i - 1] + arr[3][2][i - 1] + arr[3][3][i - 1]) % INF;

        arr[2][0][i] = (arr[0][0][i - 1] + arr[0][2][i - 1] + arr[0][3][i - 1]) % INF;
        arr[2][1][i] = (arr[1][0][i - 1] + arr[1][1][i - 1] + arr[1][2][i - 1] + arr[1][3][i - 1]) % INF;
        arr[2][2][i] = (arr[2][0][i - 1] + arr[2][1][i - 1] + arr[2][2][i - 1] + arr[2][3][i - 1]) % INF;
        arr[2][3][i] = (arr[3][0][i - 1] + arr[3][1][i - 1] + arr[3][2][i - 1] + arr[3][3][i - 1]) % INF;

        arr[3][0][i] = (arr[0][0][i - 1] + arr[0][1][i - 1] + arr[0][2][i - 1] + arr[0][3][i - 1]) % INF;
        arr[3][1][i] = (arr[1][0][i - 1] + arr[1][1][i - 1] + arr[1][2][i - 1] + arr[1][3][i - 1]) % INF;
        arr[3][2][i] = (arr[2][0][i - 1] + arr[2][1][i - 1] + arr[2][2][i - 1] + arr[2][3][i - 1]) % INF;
        arr[3][3][i] = (arr[3][0][i - 1] + arr[3][1][i - 1] + arr[3][2][i - 1] + arr[3][3][i - 1]) % INF;
    }

    ll res = 0;
    FOR(i, 0, 4)
    FOR(j, 0, 4)
    res = (res + arr[i][j][n]) % INF;

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
const int N = 1e5 + 3;

int a[N];

signed main() {

    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    int n;
    cin >> n;

    for (int i = 1; i <= n; i++) cin >> a[i];
    int now = 0, ans = 0;
    for (int i = n - 1; i; i--) {
        if(a[i] >= a[i + 1]) {
            now++;
            ans = max(ans, now);
        }
        else now = 0;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
char changer(char c,int k){
    for(int i=0;i<k;i++){
        if(c!='Z'){
            c+=1;
        }
        else
        {
            c='A';
        }
        
    }
    printf("%c",c);
}
int main(){
    int n;
    char s[10004];
    scanf("%d",&n);
    scanf("%s",s);
    int l;
    l=strlen(s);

    for(int i=0;i<l;i++){
        changer(s[i],n);
    }
}

Measured memory_bytes: 1668
a,b,c,d,e,f=map(int,input().split())
a100=a*100
b100=b*100
ok=[]
for ai in range(31):
  for bi in range(31):
    for ci in range(101):
      for di in range(101):
        ab= ai*a100+bi*b100
        cd= ci*c+di*d
        if ab + cd >f:
          break
        else:
          if (ab/100)*e>=cd:
            ok.append([ab+cd,cd])
#塩分濃度をキーとしてソートしている
print(*sorted(ok, key=lambda x: (100*x[1] / x[0] if x[0] else 0))[-1])

Measured memory_bytes: 45316
ls1 = list(map(int, input().split()))
ls2 = list(map(int, input().split()))
ls3 = list(map(int, input().split()))
n = int(input())

for i in range(n):
    b = int(input())
    if b in ls1:
        x = ls1.index(b)
        ls1[x] = 0
    if b in ls2:
        x = ls2.index(b)
        ls2[x] = 0
    if b in ls3:
        x = ls3.index(b)
        ls3[x] = 0

if ls1[0] + ls2[0] + ls3[0] == 0 or \
    ls1[1] + ls2[1] + ls3[1] == 0 or \
    ls1[2] + ls2[2] + ls3[2] == 0 or \
    ls1[0] + ls1[1] + ls1[2] == 0 or \
    ls2[0] + ls2[1] + ls2[2] == 0 or \
    ls3[0] + ls3[1] + ls3[2] == 0 or \
    ls1[0] + ls2[1] + ls3[2] == 0 or \
    ls3[0] + ls2[1] + ls1[2] == 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(n):
    a.append(a[i] + A[i])
for j in range(m):
    b.append(b[j] + B[j])

ans, j = 0, m
for i in range(n + 1):
    if a[i] > k:
        break
    while b[j] > k - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)



Measured memory_bytes: 47540
#include<bits/stdc++.h>
using namespace std;
int main(){
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s; cin>>s;
	int sz=s.size(),cnt=0;
	for(int i=0;i<sz/2;i++)
		if(s[sz-1-i]!=s[i]) cnt++;
	cout<<cnt<<'\n';
	return 0;
}

Measured memory_bytes: 384
use std::io;
fn read() -> i32 {
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    input.trim().parse().ok().unwrap()
}
fn add() -> i32 {
    (0..2).map(|_| read()).fold(0, |sum, a| sum + a)
}
fn main() {
    let input1 = read();

    match input1 {
        1 => println!("Hello World"),
        2 => println!("{}", add()),
        _ => {}
    };
}



Measured memory_bytes: 4352
N = int(input())
D, X = map(int, input().split())
A = []
for _ in range(N):
    A.append(int(input()))

for day in range(1, D+1):
    for person in A:
        if person == 1:
            X += 1
        else:
            if day % person == 1:
                X += 1
print(X)

Measured memory_bytes: 38768
#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    int b=0;
    int t=n;
    while(n)
    {
        b+=n%10;
        n/=10;
    }
    if(t%b==0)
        printf("Yes");
    else
        printf("No");
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
string a,b;
int x,y;
int main(){
    cin>>a>>b;
    x=a.size(); y=b.size();
    for(int i=0;i<y;i++)
        cout<<a[i]<<b[i];
    if(x>y)
        cout<<a[x-1];
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
	char c;cin>>c;
  	switch(c){
      case 'A':cout<<'T';break;
      case 'T':cout<<'A';break;
      case 'C':cout<<'G';break;
      case 'G':cout<<'C';break;
      default:;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int MOD=1000000007;
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    vector<pair<int,int>> ab(n);
    rep(i,0,n){
        int a,b;
        cin>>a>>b;
        ab.at(i)=make_pair(a,b);
    }
    
    sort(all(ab));
    priority_queue<int> q;
    int now=0;
    int ans=0;
    rep(i,1,m+1){
        while(now<n && ab.at(now).first==i){
            q.push(ab.at(now).second);
            now++;
        }
        if(!q.empty()){
            ans+=q.top();
            q.pop();
        }
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 1660
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int K, X; cin >> K >> X;
  rep(i, 2*K-1){
    cout << X-K+1+i << endl;
  }
}

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

int main(void){
  int x;
  int i;
  scanf("%d", &x);
  
  for(i=1; i<360*x; i++){
    if(360*i%x==0){
      printf("%d\n", 360*i/x);
      return 0;
    }
  }
}

Measured memory_bytes: 1732
require 'set'

class Heap
    def initialize
        @array = []
        @index = {}
    end

    def empty?
      @array.empty?
    end

    def add(obj, key)
        if @index[obj]
          return update(obj, key)
        end
        @array << [obj, key]
        @index[obj] = @array.size - 1
        lift_up(@array.size - 1)
    end

    def swap(i, j)
        u = @array[i]
        v = @array[j]
        @index[u[0]], @index[v[0]] = j, i
        @array[i], @array[j] = v, u
    end

    def lift_up(i)
        return if i == 0
        j = (i - 1) / 2
        if @array[i][1] < @array[j][1]
            swap(i, j)
            lift_up(j)
        end
    end

    def del_min
        raise "heap is empty!" if empty?
        min = @array[0]
        if @array.size > 1
            swap(0, @array.size - 1)
            @array.pop
            lift_down(0)
        else
            @array.pop
        end
        @index.delete(min[0])
        min
    end

    def update(obj, new_key)
        i = @index[obj]
        return unless i
        old_key = @array[i][1]
        return if old_key <= new_key
        @array[i][1] = new_key
        if new_key > old_key
            @array[i][1] = new_key
            lift_down(i)
        else
            @array[i][1] = new_key
            lift_up(i)
        end
    end

    def lift_down(i)
        j = 2 * i + 1
        k = j + 1
        if k >= @array.size
            return if j >= @array.size
            if @array[i][1] > @array[j][1]
                swap(i, j)
                lift_down(j)
            end
        else
            l = (@array[j][1] < @array[k][1] ? j : k)
            if @array[i][1] > @array[l][1]
                swap(i, l)
                lift_down(l)
            end
        end
    end
end

loop do
  n, m, c = gets.split.map(&:to_i)
  break if n == 0

  orig_graph = {}
  (0..n-1).each do |i|
    orig_graph[i] = {}
  end
  m.times do
    i, j, w = gets.split.map(&:to_i)
    i -= 1
    j -= 1
    orig_graph[i][j] = w
  end

  graph = Marshal.load(Marshal.dump(orig_graph))
  (1..n-1).each do |k|
    (0..n-1).each do |i|
      graph[k * n + i] = {}
      orig_graph[i].each do |j, w|
        graph[(k - 1) * n + i][k * n + j] = 0
        graph[k * n + i][k * n + j] = w
      end
    end
  end

  # Dijkstra
  pq = Heap.new
  pq.add(0, 0)
  fixed = Set.new
  dist = { 0 => 0 }
  until pq.empty?
    i, d = pq.del_min
    fixed << i
    dist[i] = d
    graph[i].each do |j, w|
      next if fixed.include?(j)
      pq.add(j, d + w)
    end
  end

  (1..n).each do |k|
    i = k * n + n - 1
    if dist[i] < c
      puts k
      break
    end
  end
end



Measured memory_bytes: 28384
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
#define inf 0x3f3f3f3f
const ll N = 500030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    998244353;
vector<ll> va,vb,co;
ll a,b,ra,ga,c;
int main()
{
	ios_base::sync_with_stdio(false);
	    cin.tie(NULL);
  cin>>a>>b>>ra>>ga>>c;
  for(int i=0;i<ra;i++)
  {
	ll x;
	cin>>x;
	va.push_back(x);
}
for(int i=0;i<ga;i++)
{
	ll y;
	cin>>y;
	vb.push_back(y);
}
sort(va.begin(),va.end());
sort(vb.begin(),vb.end());
for(int i=0;i<c;i++)
{
	ll x;
	cin>>x;
	co.push_back(x);
}
sort(co.begin(),co.end());
reverse(co.begin(),co.end());

ll sum=0;
vector<ll> ans;
for(int i=ra-a;i<ra;i++)
ans.push_back(va[i]);
for(int i=ga-b;i<ga;i++)
ans.push_back(vb[i]);
sort(ans.begin(),ans.end());
int idx=0;
int u=0;
while(idx<c&&u<(a+b)&&co[idx]>ans[u])
{
	ans[u]=co[idx];
	u++;
	idx++;
}
for(int i=0;i<a+b;i++)
sum+=ans[i];
cout<<sum;

}


Measured memory_bytes: 4852
use text_io::*;
use std::collections::*;
use std::process::exit;

fn main() {
    let mut n:usize = read!();
    let mut sum:f64 = 0.0;
    for i in 0..n {
        let mut a:f64 = read!();
        sum += 1.0/a;
    }
    println!("{}",1.0/sum);
}

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

int main(){
  int mon;
  while(cin >> mon,mon){
    int sum = 0;
    mon = 1000 - mon;
    sum += mon / 500;
    mon %= 500;
    
    sum += mon / 100;
    mon %= 100;
    
    sum += mon / 50;
    mon %= 50;
    
    sum += mon / 10;
    mon %= 10;
    
    sum += mon / 5;
    mon %= 5;
    
    cout << sum + mon << endl;
  }
}

Measured memory_bytes: 1160
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
#include<map>
using std::cin;using std::cerr;
using std::max;using std::min;
#define N 400
#define inf 1e18
#define ll long long
#define db double
#define dbg1(x) cerr<<#x<<"="<<(x)<<" "
#define dbg2(x) cerr<<#x<<"="<<(x)<<"\n"
int n,m,L[N],R[N],D[N],U[N];ll ans;
struct point{int x,y;ll v;}A[N];
struct info{char op;int x,y;}B[N];
class Flow
{
	std::queue<int>q;
	int ecnt,last[N],S,T,inq[N],from[N];ll dist[N];
	struct road{int to,f,nex;ll v;}e[N*N];
	void adde(int u,int v,int w,ll co)
	{
		e[++ecnt]=(road){v,w,last[u],co},last[u]=ecnt;
		e[++ecnt]=(road){u,0,last[v],-co},last[v]=ecnt;
	}
	bool spfa()
	{
		for(int i=S;i<=T;i++) dist[i]=-inf,inq[i]=0;
		for(q.push(S),dist[S]=0;!q.empty();)
		{
			int top=q.front();inq[top]=0,q.pop();
			for(int k=last[top];k;k=e[k].nex)
				if(dist[e[k].to]<dist[top]+e[k].v&&e[k].f)
				{
					dist[e[k].to]=dist[top]+e[k].v,from[e[k].to]=k;
					if(!inq[e[k].to]) inq[e[k].to]=1,q.push(e[k].to);
				}
		}
		return dist[T]>-inf;
	}
	ll mcf()
	{
		for(int k=from[T];k;k=from[e[k^1].to]) e[k].f-=1,e[k^1].f+=1;
		return dist[T];
	}
public:
	void setmap(int x)
	{
		S=0,T=x+n<<1|1,ecnt=1;
		for(int i=S;i<=T;i++) last[i]=0;
		for(int i=1;i<=x;i++)
		{
			adde(S,i,1,0),adde(x+n+n+i,T,1,0);
			for(int j=1;j<=n;j++)
			{
				if(A[j].x>=L[i]&&A[j].x<=R[i]) adde(i,x+j,1,0);
				if(A[j].y>=D[i]&&A[j].y<=U[i]) adde(x+n+j,x+n+n+i,1,0);
			}
		}
		for(int i=1;i<=n;i++) adde(x+i,x+n+i,1,A[i].v);
	}
	ll MaxcostMaxflow() {ll res=0;while(spfa()) res+=mcf();return res;}
}F;
ll Solve(int x)
{
	for(int i=1;i<=x;i++) L[i]=D[i]=0,R[i]=U[i]=999;
	for(int i=1;i<=m;i++) if(B[i].y<x)
	{
		if(B[i].op=='L') L[B[i].y+1]=max(L[B[i].y+1],B[i].x+1);
		if(B[i].op=='R') R[x-B[i].y]=min(R[x-B[i].y],B[i].x-1);
		if(B[i].op=='D') D[B[i].y+1]=max(D[B[i].y+1],B[i].x+1);
		if(B[i].op=='U') U[x-B[i].y]=min(U[x-B[i].y],B[i].x-1);
	}
	for(int i=1;i<=x;i++) L[i]=max(L[i],L[i-1]),D[i]=max(D[i],D[i-1]);
	for(int i=x-1;i;i--) R[i]=min(R[i],R[i+1]),U[i]=min(U[i],U[i+1]);
	for(int i=1;i<=x;i++) if(L[i]>R[i]||D[i]>U[i]) return -inf;
	F.setmap(x);
	return F.MaxcostMaxflow();
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d%d%lld",&A[i].x,&A[i].y,&A[i].v);
	scanf("%d",&m);
	for(int i=1;i<=m;i++) scanf(" %c%d%d",&B[i].op,&B[i].x,&B[i].y);
	for(int i=1;i<=n;i++) ans=max(ans,Solve(i));
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 768
def kaibun(a):
    for i in range(int(len(a)/2)):
        if a[i]!=a[-(i+1)]:
            return False
    return True
            

S=input()
if kaibun(S):
    a=S[0:int(len(S)/2)]
    b=S[int(len(S)/2)+1:len(S)]
    if kaibun(a) and kaibun(b):
        print('Yes')
    else:
        print('No')
else:
    print('No')

Measured memory_bytes: 9000
'use strict';

var fs = require('fs');

var input = Buffer.alloc(0x100000);
var length = fs.readSync(0, input, 0, 0x100000);

var text = input.toString().slice(0, length).trim();
var dp = Array(text.length + 1).fill(false);
dp[0] = true;

for (var index = 5; index <= text.length; index++) {
    if (dp[index - 5] === true && text.slice(index - 5, index) === 'dream') {
        dp[index] = true;
        continue;
    }

    if (dp[index - 7] === true && text.slice(index - 7, index) === 'dreamer') {
        dp[index] = true;
        continue;
    }

    if (dp[index - 5] === true && text.slice(index - 5, index) === 'erase') {
        dp[index] = true;
        continue;
    }

    if (dp[index - 6] === true && text.slice(index - 6, index) === 'eraser') {
        dp[index] = true;
        continue;
    }
}

console.log(dp[text.length] ? 'YES' : 'NO');

Measured memory_bytes: 22088
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <utility>
#include <functional>
#include <cstring>
#include <cmath>
#include <cctype>
#include <climits>
using namespace std;
#define		ll		long long
#define		ull		unsigned long long
#define		vi		vector<int>
#define 	vll		vector<long long>
#define		pii		pair<int,int>
#define		pll		pair<long long,long long>
#define		mii		map<int,int>
#define		mll		map<long long,long long>
#define		PB		push_back
#define		MP		make_pair
#define 	ff		first
#define		ss		second
#define		IT		iterator
#define		IOS		ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
#define		DB		cout<<"DEBUG "
#define		CS		<<" "<<
#define		LB		cout<<"\n"
#define		endl	"\n"

ll n;
ll a[10001],b;
ll m,l;

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

	for(int i=0; i<n; i++){
		cin >> b;
		if(a[i]>b) l+=a[i]-b;
		else m+=(b-a[i])/2;
	}
	//cout << m CS l << endl;
	if(m>=l) cout << "Yes\n";
	else cout << "No\n";
}

Measured memory_bytes: 384
import java.util.*;

public class Main {
    String[] bubbleSort(String[] s){
		int n=s.length;
		int[] lst=new int[n];
		for(int i=0;i<n;i++){
		    char[] c = s[i].toCharArray();
		    lst[i]=Character.getNumericValue(c[1]);}
		for(int i=0;i<n-1;i++){
			for(int j=n-1;j>i;j--){
				if(lst[j]<lst[j-1]){
					int x=lst[j];
					lst[j]=lst[j-1];lst[j-1]=x;
					String y=s[j];
					s[j]=s[j-1];s[j-1]=y;
				}
			}
		}
		return s;
	}
	
	String[] selectionSort(String[] s){
		int n=s.length;
		int[] lst=new int[n];
		for(int i=0;i<n;i++){
		    char[] c = s[i].toCharArray();
		    lst[i]=Character.getNumericValue(c[1]);}
		for(int i=0;i<n-1;i++){
			int min=Integer.MAX_VALUE;
			for(int j=i;j<n;j++){min=Math.min(min, lst[j]);}
			if(min==lst[i])continue;
			for(int j=i+1;j<n;j++){
				if(min==lst[j]){
					int x=lst[i];
					lst[i]=lst[j];lst[j]=x;
					String y=s[i];
					s[i]=s[j];s[j]=y;
					break;
				}
			}
		}
		return s;
	}
    public static void main(String[] args) throws Exception {
        Main m=new Main();
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();String s;
        String[] lst=new String[n];
        String[] lst1=new String[n];
        for(int i=0;i<n;i++){s=sc.next();lst[i]=s;lst1[i]=s;}
        m.listPrint(m.bubbleSort(lst));
        System.out.println("Stable");
        m.listPrint(m.selectionSort(lst1));
        m.print(lst,lst1);
    }
    void listPrint(String[]x){
		for(int i=0;i<x.length;i++){
	        if(i==0){System.out.printf("%s",x[i]);continue;}
	        System.out.printf(" %s",x[i]);
		}
		System.out.println();
	}
	void print(String[] a,String[] b){
	    for(int i=0;i<a.length;i++){
	        if(a[i]!=b[i]){System.out.println("Not stable");return;}
	    }
	    System.out.println("Stable");
	}
}


Measured memory_bytes: 26444
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
ll MOD = 1000000007;
ll INF = 200000000000000000;
double EPS = 1e-12;
double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

int main(){
  ll A,B,C;
  cin >> A >> B >> C;
  if(A != B || B != C || A != C){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

typedef long long ll;

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; }
const ll INF = 1e9;
const long long INFL = 1LL<<60;

int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  rep(i, n) {
    cin >> l[i];
  }
  sort(ALL(l));
  ll ans = 0;
  for (int i = 0; i < n-2; i++) {
    for (int j = i+1; j < n-1; j++) {
      // c は l[i] + l[j] 未満 かつ a[j+1] 以降
      auto itr = lower_bound(ALL(l), l[i] + l[j]);
      int idx = itr - l.begin() - 1;
      // cerr << "i: " << i << "  j: " << j << "  idx: " << idx << endl;
      ans += idx - j;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

    int n = sc.nextInt();

    int min = 1000000, max = -1000000;
    long sum = 0;

    for (int i = 0; i < n; i++) {
      int a = sc.nextInt();

      min = Math.min(a, min);
      max = Math.max(a, max);
      sum += a;
    }
    sc.close();

    System.out.printf("%d %d %d\n", min, max, sum);
  }
}


Measured memory_bytes: 41260
//ProblemD

//#define USE_STDIO
//#define USE_LOG
//#define FILE_ERR

#ifdef _MYPC
#include "mypc.h"
#endif // _MYPC

#ifndef debug
#define debug(...)
#endif // !LOG

//include
#include <iostream>
#include <string>
#include <vector>
#include <bitset>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <memory>
#include <complex>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iomanip>

using namespace std;

//for
#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define forbe(i, begin, end) for(decltype(begin) i = (begin); i != (end); ++i)
#define forbes(i, begin, end, step) for(decltype(begin) i = (begin); i != (end); i += (step))

//int
using ll = long long;
using ull = unsigned long long;
using uint = unsigned;

//pair
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;
#define fi first
#define se second

//vector
template <typename Value>
static inline void fillv(Value& x, const Value& val) { x = val; }
template <typename Vector, typename Value>
static inline void fillv(Vector& v, const Value& val) { for (auto& x : v) fillv(x, val); }

static inline void Solve();

int main(int argc, char* argv[]) {
#ifdef REDIRECT_STDIO
	REDIRECT_STDIO;
#endif // REDIRECT_STDIO

	Solve();
	return 0;
}

struct Edge {
	int next;
	ll cost;
};

constexpr ll INIT = ll(1e15);
constexpr ll MAXCOST = ll(1e15);

auto get_mincost(const vector<vector<Edge>>& edges, int start) {
	const int n = int(edges.size());
	vector<ll> minc(n, MAXCOST);
	vector<bool> used(n, false);
	minc[start] = 0;
	priority_queue<pair<ll, int>> pq;
	for (auto& e : edges[start]) {
		pq.push({ -e.cost, e.next });
	}

	while (!pq.empty()) {
		auto top = pq.top(); pq.pop();
		auto cost = -top.first;
		auto j = top.second;

		if (minc[j] <= cost) continue;
		minc[j] = cost;

		for (auto e : edges[j]) {
			pq.push({ -e.cost - cost, e.next });
		}
	}

	return minc;
}

//ProblemD
void Solve() {
	int n, m, s, t;
	cin >> n >> m >> s >> t;
	s--, t--;

	vector<vector<Edge>> edges_a(n);
	vector<vector<Edge>> edges_b(n);
	for (int i = 0; i < m; i++) {
		int u, v;
		ll a, b;
		cin >> u >> v >> a >> b;
		u--, v--;
		edges_a[u].push_back({ v, a });
		edges_a[v].push_back({ u, a });
		edges_b[u].push_back({ v, b });
		edges_b[v].push_back({ u, b });
	}

	auto mina = get_mincost(edges_a, s);
	auto minb = get_mincost(edges_b, t);

	vector<ll> ans(n);
	ans[n - 1] = mina[n - 1] + minb[n - 1];
	for (int i = n - 2; i >= 0; i--) {
		ans[i] = min(ans[i + 1], mina[i] + minb[i]);
	}

	for (auto a : ans) {
		cout << INIT - a << '\n';
	}
	cout << flush;
}


Measured memory_bytes: 18972
#include <bits/stdc++.h>
using namespace std;
double PI = acos(-1);
int main(){
  double a, b, x;
  cin>>a>>b>>x;
  double t, p;
  //cout<<"all = "<<a*a*b<<endl;
  if(a*a*b<2*x){//半分より多い
    //cout<<a*a*b-x<<" = a*a*tan(t)/2 *a"<<endl;
    //cout<<"tan(t) = "<<(2*b/a - 2*x/a/a/a)<<endl;;
    t = atan(2*b/a - 2*x/a/a/a);
  }else{
    //cout<<x<<" = b*b*tan(p)/2 *a"<<endl;
    //cout<<"tan(p) = "<<(2*x/a/b/b)<<endl;
    p = atan(2*x/a/b/b);
    t = PI/2 - p;
  }
  cout<<fixed<<setprecision(10);
  cout<<t*180/PI<<endl;
}

Measured memory_bytes: 384
/* Author: topcoderme123
   Date: 5th july 
*/

#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
#define F first
#define S second
#define all(v) (v).begin(),(v).end()
#define np next_permutation
using namespace std;
using vi=vector<int>;
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)
#define vii vector<vi>
#define vb vector<bool>
#define pr pair<int,int>
#define vl vector<ll>
#define vs vector<string>
#define us unordered_map<int,int>
#define Mpq priority_queue<int>
#define mpq priority_queue<int,vi,greater<int>> 
#define eb emplace_back
#define prl pair<ll,ll>
#define vp vector<pr>
#define inf 1000000000000000008
#define ld long double
const ll N=2e5+23;

ll n,sum,j;

ll a[N];
unordered_map<ll,ll> dp;

void solve(){
   cin>>n;
   lp(i,n) cin>>a[i],dp[a[i]]=1;
   sort(a,a+n,greater<int>());

   lps(i,1,n){
     if(i==1) sum+=a[j++],dp[a[i]]<<=1;
     else{
       sum+=a[j];
       if(dp[a[i]]!=N) dp[a[i]]=min(N,dp[a[i]]*2);
       dp[a[j]]--;
       while(!dp[a[j]] and j<n) j++;
     }
   }
   cout<<sum<<"\n";
}

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

   //assert(freopen("input.txt", "r", stdin));
   //assert(freopen("output.txt", "w", stdout));   

   solve();
   return 0;   	
}



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

#include <iostream>
#include <vector>
#include <string>
using namespace std;

int N;
vector<int> V;
vector<int> C;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N;
	for(int i=0; i<N; i++){
		long long v;
		cin >> v;
		V.push_back(v);
	}
	for(int i=0; i<N; i++){
		long long c;
		cin >> c;
		C.push_back(c);
	}

	int ans = 0;
	for(int b=0; b < (1<<N); b++){
		int X = 0, Y = 0;
		for(int i=0; i < N; i++){
			if(b & (1<<i)){
				X += V[i];
				Y += C[i];
			}
		}
		if(ans < (X - Y)){
			ans = X - Y;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3732
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,a,b = map(int,input().split())
ans = ((n-1)*b + a) - (b + (n-1)*a) + 1
print(max(ans,0))

Measured memory_bytes: 65484
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long int N,i,a = 0;
    cin >> N;
    long long int A[N],P[N + 1];
    P[N] = 0;
    for(i = 0;i < N;i++){
        cin >> A[i];
    }
    for(i = N - 1;i >= 0;i--){
        P[i] = (P[i + 1] + A[i]) % 1000000007;
        A[i] = A[i] % 1000000007;
    }
    for(i = 0;i < N;i++){
        a = (a + ((A[i] * (P[i + 1]))) % 1000000007) % 1000000007;
    }
    cout << a % 1000000007 << endl;
}

Measured memory_bytes: 6720
#include <bits/stdc++.h>
#define MAXN 100005
#define mod 1000000007
#define inf LLONG_MAX/3
using namespace std;

typedef long long ll; 
typedef pair<ll,ll> pll;

ll power(ll x,ll y,ll m=mod)
{
  ll ans = 1;
  while(y>0)
  {
    if(y&1)
    {
      ans = (ans*x)%m;
    }
    x = (x*x)%m;  
    y /= 2;
  }
  return ans%m;
}

ll modInverse(ll a, ll m=mod) 
{ 
    ll m0 = m; 
    ll y = 0, x = 1; 
  
    if (m == 1) 
      return 0; 
  
    while (a > 1) 
    { 
        // q is quotient 
        ll q = a / m; 
        ll t = m; 
  
        // m is remainder now, process same as 
        // Euclid's algo 
        m = a % m, a = t; 
        t = y; 
  
        // Update y and x 
        y = x - q * y; 
        x = t; 
    } 
  
    // Make x positive 
    if (x < 0) 
       x += m0; 
  
    return x; 
} 

ll get(string s)
{
  ll res = 0;
  for(int i=0;i<s.length();i++)
  {
    res += s[i]-'0';
    res *= 10;
  }
  return res/10;
}

ll dig(ll n,ll j)
{
  string s = to_string(n);
  return s[j-1]-'0';
}

int main()
{
  /*#ifndef ONLINE_JUDGE 
  freopen("input.txt", "r", stdin); 
  #endif*/
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll t=1;
  // cin>>t;
  while(t--)
  {
    ll n,m,i,j,ans=0;
    cin>>n>>m;
    ll s[m],c[m];
    for(i=0;i<m;i++)
    {
      cin>>s[i]>>c[i];
    }
    ans = -1;
    for(i=0;i<1000;i++)
    {
      if(to_string(i).length() == n)
      {
        for(j=0;j<m;j++)
        {
          if(dig(i,s[j]) != c[j])
          {
            break;
          }
        }
        if(j==m)
        {
          cout<<i;
          return 0;
        }
      }
    }
    cout<<ans;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define eb          emplace_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define mp(x,y)     make_pair(x,y) 
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,a,n)   for(ll i=a;i<n;i++)
#define frr(i,a,n)  for(ll i=n-1;i>=a;i--)


const ll N   =  500005;
const ll mod = 1e9 + 7;

using namespace std;


void solve()
{
// string s;
  ll n,m,k = 1,x=1e18,y=1e18,c=0,q,ans=0,l;
  cin>>n>>l;
  ll a[n+1];
  for (ll i = 1; i <= n; ++i)
  {
    a[i] = l + i -1; 

    c+=a[i];
  }
  for (int i = 1; i <= n; ++i)
  {
     x = c - a[i];

     if(abs(c - x)<y)
     {
      
      y = abs(c-x);
      if((c-x)>0)
        k = -1;
     }
  }
  //c(x);
  c(c + k*y);

}

signed main(){

      ios_base::sync_with_stdio(false);   
      cin.tie(NULL);
      ll T=1;
      //cin>>T;
      while(T--)
      {
      solve();
      }
      return 0;
    }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    string S, T;
    cin >> S >> T;

    bool flg = true;
    map<char, char> s, t;
    rep(i, S.size()) {
        if (s.count(S[i])) {
            if (s[S[i]] != T[i]) flg = false;
        }
        if (t.count(T[i])) {
            if (t[T[i]] != S[i]) flg = false;
        }
        s[S[i]] = T[i];
        t[T[i]] = S[i];
    }

    if (flg) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 776
s = input()
s = list(s)
if s[0] == '1':
  s[0] = '9'
else:
  s[0] = '1'
if s[1] == '1':
  s[1] = '9'
else:
  s[1] = '1'
if s[2] == '1':
  s[2] = '9'
else:
  s[2] = '1'

print(''.join(s))


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <iomanip>
using namespace std;


struct dot
{
  int x;
  int y;
};
int main()
{
  int a;
  cin>>a;
  dot ans[a];
  double sol=0;
  for(int t=0;t<a;t++)
  cin>>ans[t].x>>ans[t].y;
  for(int t=0;t<a;t++)
  {
    for(int r=t+1;r<a;r++)
    {
      float p;
      p=sqrt((ans[t].x-ans[r].x)*(ans[t].x-ans[r].x)+(ans[t].y-ans[r].y)*(ans[t].y-ans[r].y));
      sol=sol+p;
    }
  }
  cout<<setprecision(15)<<sol*2/a;
}


Measured memory_bytes: 256
#include <stdio.h>

using namespace std;

int main(){
	int n,m,tmp;
	scanf("%d %d",&n,&m);
	int** A = new int*[n];
	for(int i = 0; i < n; i++) A[i] = new int[m];
	int b[m];

	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			scanf("%d",&tmp);
			A[i][j] = tmp;
		}
	}
	for(int i = 0; i < m; i++){
		scanf("%d",&tmp);
		b[i] = tmp;
	}
	long long int sum;
	for(int i = 0; i < n; i++){
		sum = 0;
		for(int j = 0; j < m; j++){
			sum += A[i][j] * b[j];
		}
		printf("%lld\n",sum);
	}

	for(int i = 0; i < n; i++){
		delete[] A[i];
	}
	delete A;
}

Measured memory_bytes: 1068
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef tree < int, null_type, less < int >, rb_tree_tag, tree_order_statistics_node_update > ordered_set;
#define f first
#define s second
#define CS ios_base::sync_with_stdio(0);cin.tie(0);
#define PI acos(-1)
typedef long long ll;
typedef long double ld;
const int mod = ( int ) 1e9 + 7;
const int mod2 = ( int ) 1e9 + 9;
const ll inf = 1e18 + 100;
const int INF = 2000000000;
const int N = 1e6 + 100;
const long double EPS = 1e-12;
typedef complex < double > pt;



int main(){
	CS;

	int n;
	cin >> n;
	int t[n + 5], v[n + 5], d[N];
	for(int i = 1; i <= n; i++)
		cin >> t[i], t[i] *= 2;
	for(int i = 1; i <= n; i++)
		cin >> v[i], v[i] *= 2;
	int nw = 0, tot = 0;
	for(int i = 1; i <= n; i++)
	{
		tot += t[i];
		d[nw] = min(d[nw], v[i]);
		nw++;
		for(;nw <= tot; nw++)
			d[nw] = min(d[nw - 1] + 1, v[i]);
		nw--;
	}
	int s = 0, mn = 0;
	for(int i = nw - 1; i > 0; i--)
	{
		mn = min(mn + 1, d[i]);
		s += mn;
	}
	cout << fixed << setprecision (12) << double(s) / 4.;

	return 0;
}

Measured memory_bytes: 2304
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
A.insert(0,0)
B.insert(0,0)
cnt = 0
a = 0
for i in range(N+1):
    a = i
    if cnt + A[i] > K:
        a = i-1
        break
    cnt += A[i]
ans = a
#print(a)

flg = True
for i in range(M+1):
    cnt += B[i]
    if cnt > K:
        while cnt > K:
            if a < 1:
                flg = False
                break
            cnt -= A[a]
            a -= 1
    if flg == True:
        ans = max(ans,a+i)
    if flg == False:
        break
print(ans)


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

main()
{
    string s; cin>>s;
    int k; cin>>k;
    long long dp[111][2][5]={};
    int len=s.size();
    dp[0][0][0]=1;
    for(int i=0; i<len; ++i)
    {
        for(int x=0; x<=k; ++x)
        {
            dp[i+1][1][x+1]+=9*dp[i][1][x];
            dp[i+1][1][x]+=dp[i][1][x];
            dp[i+1][s[i]>'0'][x]+=dp[i][0][x];
            if(s[i]>'0')
            {
                dp[i+1][1][x+1]+=(s[i]-'1')*dp[i][0][x];
                dp[i+1][0][x+1]+=dp[i][0][x];
            }
        }
    }
    cout << dp[len][0][k]+dp[len][1][k] << "\n";
}

Measured memory_bytes: 256
/*
数据不清空，爆零两行泪。
多测不读完，爆零两行泪。
边界不特判，爆零两行泪。
贪心不证明，爆零两行泪。
D P 顺序错，爆零两行泪。
大小少等号，爆零两行泪。
变量不统一，爆零两行泪。
越界不判断，爆零两行泪。
调试不注释，爆零两行泪。
溢出不 l l，爆零两行泪。
*/
#include<bits/stdc++.h>
using namespace std;
const int mod=1000000007;
const int N=10000,M=100;
int n,m;
char a[N+1];
int dp[N+1][M];
int main(){
	cin>>a+1>>m;
	n=strlen(a+1);
	dp[0][0]=1;
	for(int i=1;i<=n;i++)for(int j=0;j<m;j++)
		for(int k=0;k<=9;k++)
			(dp[i][j]+=dp[i-1][(j-k+10000*m)%m])%=mod;
	int ans=dp[n-1][0]-1;
	int now=0;
	for(int i=1;i<=n;i++){
		if(i>1)(now+=a[i-1]^48)%=m;
		for(int j=i==1;j<=(a[i]^48)-(i<n);j++)(ans+=dp[n-i][(-now-j+10000*m)%m])%=mod;
	}
	cout<<ans;
	return 0;
}
/*1
30
4
*/
/*2
1000000009
1
*/
/*3
98765432109876543210
58
*/

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

      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();
      int d = sc.nextInt();

      if(Math.abs(c-a)<=d){
        System.out.println("Yes");
        System.exit(0);
      }

      if(Math.abs(b-a)<=d&&Math.abs(c-b)<=d){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }

  }
}

Measured memory_bytes: 20820
#include<cstdio>
	#include<iostream>
	#include<map>
	#include<set>
	#include<vector>
	#include<cstring>
	#include<cassert>
	#include<sstream>
	#include<cmath>
	#include<algorithm>
	#include<queue>
	#include<limits>
	#include<ctime>
	#include<stack>
	#include<bits/stdc++.h>
	#include<string>
	#include<stdlib.h>
	#include<stdio.h>
	
	typedef long long ll;
	using namespace std;
	const ll x=1000000007;
	int mod(ll a){
		return a%x;
	}
	int main(){
		ll a,b;
		cin>>a>>b;
		string c[a];
		for(int i=0;i<a;i++){
			cin>>c[i];
		}
		for(int i=0;i<b+2;i++){
			cout<<'#';
		}
		cout<<endl;
		for(int i=0;i<a;i++){
			cout<<'#';
			for(int j=0;j<b;j++){
				cout<<c[i][j];
			}
			cout<<'#'<<endl;
		}
		for(int i=0;i<b+2;i++){
			cout<<'#';
		}
	}

Measured memory_bytes: 3588
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple


int main(void)
{
  ll N, K, Q, tmp;
  cin >> N >> K >> Q;
  ll score[N];
  for(ll i=0;i<N;i++){
    score[i] = 0;
  }
  for(ll i=0;i<Q;i++){
    cin >> tmp;
    score[tmp-1]++;
  }
  for(ll i=0;i<N;i++){
    if(K-Q+score[i] > 0){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 1408
#include <iostream>

using namespace std;

inline int normalize(int y) {
    return min(255, max(0, y));
}

inline int get_error(int y, int y0) {
    y -= y0;
    return y * y;
}

int errors[20001][256];
int solve(int n, int m, int c[], int x[]) {
    int min_error = -1;
    for (int t = 0; t <= n; ++t) {
        for (int y = 0; y < 256; ++y) {
            errors[t][y] = -1;
        }
    }
    errors[0][128] = 0;
    for (int t = 0; t < n; ++t) {
        for (int y = 0; y < 256; ++y) {
            if (errors[t][y] < 0) {
                continue;
            }
            for (int i = 0; i < m; ++i) {
                int yn = normalize(y + c[i]);
                int e = errors[t][y] + get_error(yn, x[t]);
                if (errors[t + 1][yn] < 0 || e < errors[t + 1][yn]) {
                    errors[t + 1][yn] = e;
                }
            }
        }
    }
    for (int y = 0; y < 256; ++y) {
        if (errors[n][y] < 0) {
            continue;
        }
        if (min_error < 0 || errors[n][y] < min_error) {
            min_error = errors[n][y];
        }
    }
    return min_error;
}

int main() {
    int n, m;
    int c[16], x[20000];
    while (true) {
        cin >> n >> m;
        if (n == 0) {
            return 0;
        }
        for (int i = 0; i < m; ++i) {
            cin >> c[i];
        }
        for (int i = 0; i < n; ++i) {
            cin >> x[i];
        }
        cout << solve(n, m, c, x) << endl;
    }
}

Measured memory_bytes: 21236
#include <stdio.h>
#include <math.h>

#define PI 3.14159265359

int main(){
  double a, b, c;
  scanf("%lf%lf%lf", &a, &b, &c);
  printf("%.8f\n", a * b * sin(c * PI /180) / 2);
  printf("%.8f\n", a + b + sqrt(a * a + b * b - 2 * a * b * cos(c * PI/ 180)));
  printf("%.8f\n",  b * sin(c * PI / 180));
  return 0;
}

Measured memory_bytes: 680
#include <bits/stdc++.h>
using namespace std;
// #define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
#define ITR(v,c) for(auto v=begin(c);v!=end(c);v++)
#define FOR(v,a,n) for(int v=a;v<(int)(n);v++)
#define FORE(x,arr) for(auto &x:arr)
#define REP(v,n) FOR(v,0,n)
#define RREP(v,n) for(int v=((int)(n)-1);v>=0;v--)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define SZ(c) ((int)c.size())
#define DUMP(x) cerr<<#x<<":="<<(x)<<endl
const int DX[9]={0,1,0,-1,1,1,-1,-1,0}, DY[9]={-1,0,1,0,-1,1,1,-1,0};
const int INF=1e9; const long long INFLL=1e18;
template<class T,class U>ostream&operator<<(ostream &os,const pair<T,U> &p){
    os<<"("<<p.first<<" "<<p.second<<")";return os;}
template<class T>ostream&operator<<(ostream &os,const vector<T> &v){
    ITR(i,v)os<<*i<<(i==end(v)-1?"":"\n");return os;}
//------------------------------------------------------------------------------

signed main() {
    string s;
    cin>>s;
    int n=SZ(s);
    int p=count(ALL(s),'p');
    cout<<n/2-p<<endl;
    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int main()
{
	int a[101][101], b[101][101];
	long long c[101][101], s;
	int i, j, k;
	int n, m, l;

	scanf("%d%d%d", &n, &m, &l);
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) scanf("%d", &a[i][j]);
	}
	for (i = 0; i < m; i++) {
		for (j = 0; j < l; j++) scanf("%d", &b[i][j]);
	}

	for (i = 0; i < n; i++) {
		for (j = 0; j < l; j++) {
			s = 0;
			for (k = 0; k < m; k++) {
				s += a[i][k] * b[k][j];
			}
			c[i][j] = s;
		}
	}

	for (i = 0; i < n; i++) {
		printf("%lld", c[i][0]);
		for (j = 1; j < l; j++) printf(" %lld", c[i][j]);
		printf("\n");;
	}
	return 0;
}


Measured memory_bytes: 2092
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <cmath>
 
using namespace std;
 
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back
 
typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, x;
    cin >> a >> b >> x;
    ll ansx, ansy;
    if(a==0)
        ansx = 0;
        else{
            ansx = (a - 1) / x + 1;
        }
        ansy = b / x + 1;
        cout << ansy - ansx << endl;
        return 0;
}

Measured memory_bytes: 256
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    S = input()

    flag = 0
    n = len(S)
    if S == S[::-1]:
        flag += 1
    s = S[:n//2]
    if s == s[::-1]:
        flag += 1
    s = S[(n+3)//2-1:]
    if s == s[::-1]:
        flag += 1
    if flag == 3:
        print('Yes')
    else:
        print('No')


main()


Measured memory_bytes: 3064