akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    long a[5];
    scanf("%ld%ld%ld%ld%ld", &a[0], &a[1], &a[2], &a[3], &a[4]);

    long sum=0;
    long min=10;
    long i;
    for(i=0; i<5; i++) {
        if(a[i]%10) {
            min = MIN(min, a[i]%10);
        }
        sum += ((a[i]-1)/10*10+10);
    }
    printf("%ld\n", sum-(10-min));

    return 0;
}


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

#define int long long int
#define ff first
#define ss second
#define pb push_back


int bexp(int a, int b)
{
	int res = 1;

	while (b)
	{
		if (b & 1) res = (res * a);

		a = (a * a); 
		b >>= 1;
	}
	return res;
}

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

#define N 2000100
#define MOD 1000000007

int fac[N], inv[N], faci[N];
void comp()
{
	fac[0] = fac[1] = 1;
	faci[0] = faci[1] = 1;
	inv[1] = 1;

	for (int i = 2; i < N; ++i)
	{
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = (MOD - (MOD / i) * inv[MOD % i] % MOD);
		faci[i] = faci[i - 1] * inv[i] % MOD;
	}
}

int ncr(int n, int r)
{
	if (n < r)
		return 0;
	return fac[n] * faci[r] % MOD * faci[n - r] % MOD; 
}


int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(10);

	comp();
	int r1, c1, r2, c2;
	cin >> r1 >> c1 >> r2 >> c2;

	int ans = 0;

	for (int i = r1; i <= r2; ++i)
	{
		// cout << ncr(i + c2 + 1, i + 1) << " " << i + c2 + 1 << "\n" ;
		ans = (ans + (ncr(i + c2 + 1, i + 1) - ncr(i + c1, i + 1) + MOD) % MOD) % MOD;
	}

	cout << ans << "\n"; 
	return 0;
}

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

int main(){
     int time[5];
     for(int i = 0; i < 5; i++){
          cin >> time[i];
     }
     int last = 129;
     for(int i = 0; i < 5; i++){
          if(time[i] % 10 == 0) continue;
          if(time[i] % 10 <= last % 10) last = time[i];
     }
     int ans = 0;
     for(int i = 0; i < 5; i++){
          if(time[i] % 10 == 0) ans += time[i];
          else ans += time[i] + (10 - (time[i] % 10));
     }
     if(last != 129) cout << ans - (10 - (last % 10)) << endl;
     else cout << ans << endl;
     
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
using ll = long long;
constexpr long long INF = 1LL << 62;
constexpr int MOD = 1e9 + 7;
 
double dp[55][55];
long long table[55][55];
 
void make_pascal() {
    for(int i = 0; i < 55; ++i) {
        table[i][0] = 1;
        for (int j = 1; j < i; j++) {
            table[i][j] = table[i-1][j-1] + table[i-1][j];
        }
        table[i][i] = 1;
    }
}
 
int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N,A,B; cin >> N >> A >> B;
    double v[50]; REP(i,N) cin >> v[i];
    make_pascal();
 
 
    double ans = 0.0;
    sort(v, v + N, greater<double>());
    for(int i=0; i<A; ++i) ans += v[i];
    ans /= A;

    int num = 0, pos = 0;
    // num := 
    for(int i=0;i<N;++i){
        if(v[i] == v[A-1]) {
            ++num;
            if(i < A) ++pos;
        }
    }
 
    ll cnt = 0LL;
    if(pos == A){
        for(pos = A; pos <= B; ++pos) cnt += table[num][pos];
    } else {
        cnt += table[num][pos];
    }
 
    
    cout << fixed << setprecision(10) << ans << '\n';
    cout << cnt << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>

char a[1005];
char b[1005];
int cnt = 1;
int main(){
	scanf(" %s", a + 1);
	scanf(" %s", b + 1);
	int a1 = strlen(a + 1);
	int b1 = strlen(b + 1);
	if(a1 > b1)printf("GREATER\n");
	if(a1 < b1) printf("LESS\n");
	if(a1 == b1){
		for(int i = 1; i <= a1; i++){
			if(cnt == i){
				if(a[i] > b[i]) printf("GREATER\n");	
				if(a[i] < b[i]) printf("LESS\n");	
				if(a[i] == b[i]) cnt = i + 1;}
		}	
	}
	if(cnt == a1 + 1) printf("EQUAL\n");
}

Measured memory_bytes: 128
import std.algorithm;
import std.range;
import std.stdio;
import std.math;
import std.array;
import std.string;
import std.conv;

/// 数列の読み込み
auto readNums(T = int)() {
	return readln().chomp.split.map!(to!T).array;
}

auto minElement(R)(R r) {
    return r.reduce!((a, b) => min(a, b));
}

void main() {
	immutable n = readNums()[0];
	auto monsters = readNums();
	int min = 0;
	while(monsters.length > 1) {
		min = monsters.minElement;
		monsters = monsters.map!((a) => a % min).filter!"a != 0".array;
		monsters ~= min;
	}
	writefln("%s", min);
}

Measured memory_bytes: 4264
while True:
	m,n=map(int,input().split())
	if m==0:break
	m**=n
	s=""
	d=68
	ls=['Mts','Fks','Nyt','Asg','Ggs','Gok','Sai','Sei','Kan','Ko','Jou','Jo','Gai','Kei','Cho','Oku','Man'][::-1]
	while d:
		if int(m/10**d)>=1:
			s+=str(int(m/10**d))+ls[int((d-4)/4)]
			m%=10**d
		d-=4
	if m:s+=str(m)
	print(s)

Measured memory_bytes: 7632
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}
const int INF = 1e18;

signed main() {
    int N;
    cin >> N;
    map<int, int> mp;
    rep(i, N) {
        int a;
        cin >> a;
        mp[a]++;
    }

    int res = INF;
    for(int i=-100; i<=100; i++) {
        int temp = 0;
        for(auto &p : mp) {
            int t = abs(p.fi-i);
            temp += t*t*p.se;
        }
        res = min(res, temp);
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = input()
B = input()
C = input()
count = 0

for i in range(N):
    if A[i] == B[i] == C[i]:
        count += 0
    elif A[i] == B[i] and A[i] != C[i]:
        count += 1
    elif A[i] == C[i] and A[i] != B[i]:
        count += 1
    elif B[i] == C[i] and B[i] != A[i]:
        count += 1
    else:
        count += 2

print(count)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

using ll = long long;

int main() {
    int n, q, T, C = 0;
    cin >> n;
    vector<int> S(n);
    rep(i, n) scanf("%d", &S[i]);
    cin >> q;
    rep(i, q) {
        cin >> T;
        if (T < S[0] || T > S[n - 1]) continue;
        if (T == S[n - 1]) {
            C++;
            continue;
        }
        int l = 0, h = n - 1;
        while (l + 1 < h) {
            int m = (l + h) / 2;
            if (T < S[m]) h = m;
            else l = m;
        }
        if (S[l] == T) C++;
    }
    cout << C << "\n";
}


Measured memory_bytes: 3276
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, s, n)    for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define VAR(type, ...)  type __VA_ARGS__; read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream& operator>> (istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}
// }}} End Header

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

    int a[] {
        1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
    };

    VAR(int, K);
    print(a[K - 1]);

    return 0;
}


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] memo = new int[4];

            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                string[] data = input.Split(',');

                switch (data[1])
                {
                    case "A":
                        memo[0]++;
                        break;
                    case "B":
                        memo[1]++;
                        break;
                    case "AB":
                        memo[2]++;
                        break;
                    case "O":
                        memo[3]++;
                        break;
                }
            }
            Console.WriteLine("{0}\n{1}\n{2}\n{3}",
                memo[0], memo[1], memo[2], memo[3]);
        }
    }
}

Measured memory_bytes: 9112
#include <stdio.h>
int main(void)
{
    int r,c,hyou[101][101]={},i,j;

    
    scanf("%d %d",&r,&c);
    for(i=0;i<r;i++)
    {
        for(j=0;j<c;j++)
        {
            scanf("%d",&hyou[i][j]);
            hyou[i][c]=hyou[i][c]+hyou[i][j];
            hyou[r][j]=hyou[r][j]+hyou[i][j];
        }
    }
    
    for(i=0;i<r;i++)
    {
        hyou[r][c]=hyou[r][c]+hyou[i][c];
    }
    
    for(i=0;i<=r;i++)
    {
        for(j=0;j<=c;j++)
        {
            if(j==0) printf("%d",hyou[i][j]);
            else printf(" %d",hyou[i][j]);
        }
        printf("\n");
    }
    
    return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

int dp[1100010][2];

signed main(){
    
    int n; cin >> n;
    string s; cin >> s;
    int ans = INF;
    vector<int> a(n + 1, 0);
    vector<int> b(n + 1, 0);
    for(int i = 1; i <= n; i++){
        if(s[i- 1] == '.') a[i] = 1;
        else b[i] = 1;
        a[i] += a[i - 1];
        b[i] += b[i - 1];
    }

    for(int i = 0; i <= n; i++){
        int tmp = b[i] - b[0];
        tmp += a[n] - a[i];
        ans = min(ans, tmp);
        
    }
    cout << ans << endl;

    
    return 0;
}



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

int main(){
  int r,c;
  int table[105][105]={{0}};
  int sum[2][105]={{0}};
  cin>>r>>c;
  for(int i=0;i<r;i++){
    for(int j=0;j<c;j++){
      cin>>table[i][j];
      sum[0][j] += table[i][j];
      sum[1][i] += table[i][j];
    }
  }
  for(int i=0;i<r;i++){
    for(int j=0;j<c;j++){
      cout<<table[i][j]<<" ";
    }
    cout<<sum[1][i]<<endl;
  }
  int s = 0;
  for(int i=0;i<c;i++){
    cout<<sum[0][i]<<" ";
    s += sum[0][i];
  }
  cout<<s<<endl;
  return 0;
}

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

int main()
{
    string N;
    cin >> N;
    char ichi = N.at(N.size() - 1);
    if (ichi == '3')
    {
        cout << "bon" << endl;
    }
    else if (ichi == '8')
    {
        cout << "pon" << endl;
    }
    else if (ichi == '6')
    {
        cout << "pon" << endl;
    }
    else if (ichi == '0')
    {
        cout << "pon" << endl;
    }
    else if (ichi == '1')
    {
        cout << "pon" << endl;
    }
    else
    {
        cout << "hon" << endl;
    }
}


Measured memory_bytes: 3592
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque,BinaryHeap};

// Functions

// Main
fn main(){
    input!{
        N: u64,
    }
    println!("{}", N.pow(3));
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int64_t H,W;

  cin >> H >> W;

  int64_t ans;

  if(H==1||W==1) ans=1;

  else ans=(H*W+1)/2;//{(H*W)+1}/2+1={(H*W)+2-1}/2
  
  cout << ans << endl;

  return 0;
}

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

char s[5];
int n,flag;

int main()
{
	scanf("%s",s);
	n=strlen(s);
	for(int i=0;i<n;i++)
		{
			if(s[i]=='7')
				{
					printf("Yes");
					flag++;
					break;
				}
			
		}
	if(flag==0)printf("No");
	return 0;

	return 0;
}

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

void solve() 
{
    int n;string s;int k;cin>>n>>s>>k;
    char j=s[k-1];
    REP(i,s.size()){
        if(s[i]!=j)s[i]='*';
    }cout<<s<<endl;
}

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

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

int main(){
    int a, b;
    cin >> a >> b;
    int i = 1, x, y;
    while(true){
		x = i * 0.08; 
		y = i * 0.1;
		
		if(x == a && y == b){
			cout << i << "\n";
			return 0;
		}
		if(x > a || y > b){
			cout << "-1" << "\n";
			return 0;
		}
		
		i++;
	} 
		
			
}


Measured memory_bytes: 256
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1356
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
using ll = long long;
using namespace std;

int const MOD = 1e9 + 7;

int main(void)
{
    vector<string> v;
    for (int i = 0; i <= 9; ++i)
    {
        string n;
        n.push_back(('0' + i));
        for (int j = 0; j <= 9; ++j)
        {
            string m;
            m.push_back(('0' + j));
            for (int k = 0; k <= 9; ++k)
            {
                string l;
                l.push_back(('0' + k));
                string s = "";
                if (i == 0 && j == 0)
                    s = l;
                else if (i == 0)
                {
                    s = m + l;
                }
                else
                {
                    s = n + m + l;
                }
                v.push_back(s);
            }
        }
    }
    v.push_back("1000");

    int n;
    string d = "";
    cin >> n;
    for (int i = 0; i < n; ++i)
    {
        string s;
        cin >> s;
        d += s;
    }
    for (int i = 0;; ++i)
    {
        if (d.find(v[i]) == -1)
        {
            cout << v[i] << endl;
            return 0;
        }
    }

    return 0;
}


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

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1e9
using namespace std;
typedef long long ll;

int n;
int t[100100],x[100100],y[100100];

bool judge(int delta_t, int src_x,int src_y, int dst_x, int dst_y){
  int min_distance = abs(dst_x-src_x)+abs(dst_y-src_y);
  // cout << dst_x << src_x << dst_y << src_y<<endl;
  // cout << min_distance <<' ' << delta_t << endl;
  if(min_distance > delta_t)return false;
  if(min_distance%2!=0){
    if(delta_t%2!=0)return true;
  }else{
    if(delta_t%2==0)return true;
  }
  return false;
}

int main(){
  std::cin >> n;
  rep(i,1,n+1)std::cin >> t[i] >> x[i] >> y[i];
  t[0] = 0;x[0]=0;y[0]=0;
  string ans = "Yes";
  rep(i,1,n+1){
    if(!judge(t[i]-t[i-1], x[i-1],y[i-1], x[i],y[i]))ans="No";
  }
  cout << ans<<endl;

}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size()){cout << a[i];cout << (i == a.size() - 1 ? "\n":" ");}
#define rep(i,x) for(ll i = 0;i<x;i++)
#define REP(i,x) for(ll i = 1;i<=x;i++)
#define mp make_pair
#define debug(x) cerr << #x << ": " << x << "\n"
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const dou pi = 3.14159265358;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T, class U> inline bool chmin(T& a, const U& b){ if(a > b){ a = b; return 1; } return 0; }
template<class T, class U> inline bool chmax(T& a, const U& b){ if(a < b){ a = b; return 1; } return 0; }
template<class T, class U> inline bool change(T& a,U& b){if(a > b){swap(a,b);return 1;}return 0;}
//0の場合のアレンジに注意
template<class T>
T gcd(T a,T b){
    if(a == 0)return b;
    else if(b == 0)return a;
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
template<class T>
T lcm(T a,T b){
    return a / gcd(a,b) * b;
}

//素数判定O(sqrt(N))
template<class T>
inline bool isp(T n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
vector<ll> fac(cmax),finv(cmax),inv(cmax);

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if(fac[0] == 0)COMinit();
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logm)
ll modpow(ll n,ll m,ll MOD){
    if(m == 0)return 1;
    if(m < 0)return -1;
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}
ll mypow(ll n,ll m){
    if(m == 0)return 1;
    if(m < 0)return -1;
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n);
        m >>= 1;
        n *= n;
    }
    return res;
}
template<class T = ll>
T in(){T x;cin >> x;return x;}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll N;
    cin >> N;
    vector<ll> vec(N);
    ll neg = 0,wa = 0;
    rep(i,N){
        cin >> vec[i];
        wa += abs(vec[i]);
        if(vec[i] < 0)neg++;
    }
    if(neg % 2 == 0){
        cout << wa << "\n";
    }
    else{
        ll small = INF;
        rep(i,N){
            chmin(small,abs(vec[i]));
        }
        cout << wa - small * 2 << "\n";
    }
}

Measured memory_bytes: 27476
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

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

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

long long int DP[110][110000] = {};

int main(){
	
	int N, K;
	cin >> N >> K;
	
	int a[110];
	for(int i = 0; i < N; i++){
		cin >> a[i];
	}
	
	DP[0][0] = 1;
	for(int i = 0; i < N; i++){
		long long int S = 0;
		for(int j = 0; j <= a[i]; j++){
			S += DP[i][j];
			S %= MOD;
			DP[i + 1][j] = S;
		}
		for(int j = a[i] + 1; j <= K; j++){
			S += DP[i][j];
			S -= DP[i][j - a[i] - 1];
			S += MOD;
			S %= MOD;
			DP[i + 1][j] = S;
		}
	}
	
	cout << DP[N][K] << endl;
	
	return 0;
}


Measured memory_bytes: 87424
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] arya = new int[n];
        int[] aryb = new int[n];
        int[] aryc = new int[n-1];
        for (int i = 0; i < n; i++) {
            int a = Integer.parseInt(sc.next());
            arya[i] = a;
        }
        for (int i = 0; i < n; i++) {
            int b = Integer.parseInt(sc.next());
            aryb[i] = b;
        }
        for (int i = 0; i < n - 1; i++) {
            int c = Integer.parseInt(sc.next());
            aryc[i] = c;
        }
        int temp = -1;
        int ans = 0;
        for (int i = 0; i < n; i++) {
            ans += aryb[arya[i] - 1];
            if (temp - arya[i] == -1) {
                ans += aryc[temp - 1];
            }
            temp = arya[i];
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23764
#include <atcoder/all>
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
using namespace atcoder;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int op(int a,int b) {return max(a,b);}

int e() {return -1;};

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n)cin >> a[i];

  vector<int> v(300105,0);
  segtree<int,op,e> seg(v);

  rep(i,n){
    int l = max(0,a[i]-k);
    int r = min(300100,a[i]+k+1);
    int mx = seg.prod(l,r);
    seg.set(a[i],mx+1);
  }
  cout << seg.all_prod() << endl;
}

Measured memory_bytes: 9620
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }
    static class TaskC {
        static long modpow(long a , int b){
            a%=1000000007;
            long ans = 1;
            while (b>0){
                if ((b&1)>0) ans=ans*a%1000000007;
                b>>=1;
                a=a*a%1000000007;
            }
            return ans;
        }
        static long sol(long a){
            if (a==1) return 1;
            long ans = sol(a/2);
            return ans+ans+1;
        }
        public void solve(int testNumber, InputReader in, PrintWriter out){
            long h = in.nextLong();
            System.out.println(sol(h));
        }




    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt(){return  Integer.parseInt(next());}
        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int n, a, b, c, d; // a<b && a<c && b<d
    cin >> n >> a >> b >> c >> d;
    string s;
    cin >> s;
    a--;
    b--;
    c--;
    d--;
    bool f = true;
    for (int i = a + 1; i < c - 1; i++)
    {
        if (s[i] == '#' && s[i + 1] == '#')
            f = false;
    }
    for (int i = b + 1; i < d - 1; i++)
    {
        if (s[i] == '#' && s[i + 1] == '#')
            f = false;
    }
    if (d < c)
    {
        bool check = false;
        for (int i = max(1, b); i <= d; i++)
        {
            if (s[i] == '.' && s[i + 1] == '.' && s[i - 1] == '.')
                check = true;
        }
        if (!check)
            f = false;
    }
    cout << (f ? "Yes" : "No") << endl;
}


Measured memory_bytes: 592
#include <iostream>

using namespace std;

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

	for(auto i : s)
		if(i == 'C') ok = 1;
		else if(i == 'F' && ok) return cout << "Yes\n", 0;

	cout << "No\n";
	
	return 0;
}

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

int main() {

    int N;
    cin >> N;

    vector<ll> L(N);

    rep(i, N) {
        cin >> L[i];
    }

    int ans = 0;
    rep(i, N-2) {
        FOR(j, i+1, N-1) {
            FOR(k, j+1, N) {
                if(L[i] + L[j] > L[k] && L[j] + L[k] > L[i] && L[k] + L[i] > L[j]
                    && L[i] != L[j] && L[j] != L[k]&& L[k] != L[i]) ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3636
n = int(input())
a = [0 for i in range(n)]
c = 0
total = n
for x in range(1, n//2):
    for y in range(x, n//2):
        for z in range(y, n//2):
            total = int(((x+y)**2 + (z+y)**2 + (x+z)**2) / 2)
            try:
                if x == y == z:
                    a[total-1] += 1
                elif x == y or y == z:
                    a[total-1] += 3
                else:
                    a[total-1] += 6
            except:
                break
for i in a:
    print(i)


Measured memory_bytes: 69756
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

S = input()

last = ""
tmp = ""
ans = 0
for s in S:
    tmp += s
    if tmp == last:
        continue
    # print(tmp)
    last = tmp
    tmp = ""
    ans += 1
print(ans)

Measured memory_bytes: 9124
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <memory.h>
#include <deque>
#include <stdlib.h>
#include <time.h>
using namespace std;
typedef long long ll;
#define mp make_pair
const int M=100005;
const int N=1000001;
const int K=1000000007;
const ll MAX=1000000000000000000ll;
int n,m;
char a[1002][1002];
ll dp[1002][1002];
ll calc(int x,int y)
{
	if(x==n-1&&y==m-1)
		return 1;
	ll &ret=dp[x][y];
	if(ret!=-1)
		return ret;
	ret=0;
	if(x<n&&a[x+1][y]=='.')
		ret=calc(x+1,y)%K;
	if(y<m&&a[x][y+1]=='.')
		ret+=calc(x,y+1)%K;
	ret%=K;
	return ret;
}
int main(){
    cin>>n>>m;
    for(int i=0;i<n;i++)
    	scanf("%s",a[i]);
    memset(dp,-1,sizeof(dp));
    cout<<calc(0,0)%K;
}

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

public class Solution
{
    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var n = vals[0];
        var k = vals[1];

        Console.WriteLine(n - k + 1);
    }
}

Measured memory_bytes: 11220
import sys
from scipy.sparse.csgraph import csgraph_from_dense
from scipy.sparse.csgraph import floyd_warshall
input = sys.stdin.readline


n, m, energy = map(int, input().split())
edges = [[float('INF')]*n for _ in range(n)]

for i in range(m):
    a, b, c = map(int, input().split())
    edges[a-1][b-1] = c
    edges[b-1][a-1] = c

G = csgraph_from_dense(edges, null_value=float('INF'))
dist = floyd_warshall(G)  # dist[i][j] = min_distance between i and j

L_edges = [[0]*n for _ in range(n)]
for i in range(n-1):
    for j in range(i, n):
        if dist[i][j] <= energy:
            L_edges[i][j] = 1
            L_edges[j][i] = 1

G = csgraph_from_dense(L_edges, null_value=0)
answers = floyd_warshall(G)
for i in range(n):
    for j in range(n):
        if answers[i][j] == float('INF'):
            answers[i][j] = 0
            answers[j][i] = 0

Q = int(input())
for i in range(Q):
    s, t = map(int, input().split())
    ans = answers[s-1][t-1] - 1
    print(int(ans))

Measured memory_bytes: 20720
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int A, B, C, D;

int main() {

	cin >> A >> B >> C >> D;

	for (;;) {
		C -= B;
		if (C <= 0) {
			cout << "Yes" << endl;
			return 0;
		}
		A -= D;
		if (A <= 0) {
			cout << "No" << endl;
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;
import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int n = scan.nextInt();
			if(n == 0){
				break;
			}
			int[] score = new int[n];
			for(int i = 0;i < n;i++){
				score[i] = scan.nextInt();
			}
			Arrays.sort(score);
			int sum = 0;
			for(int i = 1;i < n-1;i++){
				sum += score[i];
			}
			System.out.println(sum/(n-2));
		}
	}
}

Measured memory_bytes: 20948
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N = INT()
S, T = input().split()
S = list(S)
T = list(T)

ans = []
for i in range(N):
    ans.append(S[i])
    ans.append(T[i])
print(''.join(ans))


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

int main() {
	int n,max,a;
	std::cin >> n;

	std::vector<int> v;
	std::vector<int> ori;
	for (int i = 0; i < n; i++) {
		std::cin >> a;
		v.push_back(a);
		ori.push_back(a);
	}

	std::sort(v.begin(), v.end());

	max = v[n - 1];

	for (int i = 0; i < n; i++) {
		if (ori[i] != max) {
			std::cout << v[n-1] << std::endl;
		}
		else if (ori[i] == max) {
			std::cout << v[n-2] << std::endl;
		}
	}

	//std::cout << n << std::endl;
	return 0;
}

Measured memory_bytes: 3436
#include <bits/stdc++.h>
#define INF 1e9
#define MOD 1000000007
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main(void) {
    string sdash, t;
    cin >> sdash;
    cin >> t;

    vector<string> strSet;

    int slen = sdash.size();
    int tlen = t.size();

    for (int i = 0; i < slen; i++)
    {
        if(i + tlen > slen) break;
        string s = sdash;
        bool match = true;
        for (int j = 0; j < tlen; j++)
        {
            if(s[i+j] != t[j]){
                if(s[i+j] == '?'){
                    s[i+j] = t[j];
                } else {
                    match = false;
                    break;
                }
            }
        }
        if(match) {
            for (int j = 0; j < slen; j++)
            {
                if(s[j] == '?') s[j] = 'a';
            }
            strSet.push_back(s);
            //strSet.emplace_back(s);
        }
    }

    if(strSet.empty()){
        cout << "UNRESTORABLE" << endl;
    } else {
        sort(strSet.begin(), strSet.end());
        cout << *strSet.begin() << endl;
    }
    return 0;
}


Measured memory_bytes: 3612
import sys
from heapq import heappush, heappop

INF = 10 ** 7

n, m = map(int, sys.stdin.readline().split())
abc = map(int, sys.stdin.read().split())
abc = zip(*[abc] * 3)
graph = [[] for _ in range(n)]
for a, b, c in abc:
    graph[a-1].append((b-1, c))
    graph[b-1].append((a-1, c))

def dijkstra(v):
    used_edges = [set() for _ in range(n)]
    hq = []
    heappush(hq, (0, v, None))
    dist = [INF] * n
    parents = [set() for _ in range(n)]
    while hq:
        d, cur, prev = heappop(hq)
        if dist[cur] != INF:
            if d == dist[cur]:
                parents[cur].add(prev)
                used_edges[cur] |= used_edges[prev]
                if prev < cur:
                    used_edges[cur].add((prev, cur))
                else:
                    used_edges[cur].add((cur, prev))
            continue   
        
        dist[cur] = d
        if cur != v:
            used_edges[cur] |= used_edges[prev]
            parents[cur].add(prev)
            if prev < cur:
                used_edges[cur].add((prev, cur))
            else:
                used_edges[cur].add((cur, prev))

        for (u, c) in graph[cur]:
            if u in parents[cur] or parents[u]:
                continue
            nex = u
            heappush(hq, (d+c, nex, cur))

    res = set()
    for i in range(n):
        res |= used_edges[i]
    return res

def main():
    res = set()
    for v in range(n):
        res |= dijkstra(v)
    
    ans = m - len(res)
    return ans

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3572
#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;
const long long MOD = 1e9 + 7;
typedef pair<int, int> P;

map<ll, ll> prime;

void prime_fuctor(int N)
{
    for (int i = 2; i * i <= N; i++) {
        while (N % i == 0) {
            prime[i]++;
            N /= i;
        }
    }
    if (N != 1) prime[N]++;
}

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

    repd(i, 2, N + 1) {
        prime_fuctor(i);
    }

    ll ans = 1;
    for (auto itr = prime.begin(); itr != prime.end(); itr++) {
        ans *= (itr->second + 1LL);
        ans %= MOD;
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
ull A=9999973,B=950527;
 
int H,W;
char T[1005][1005];
ull t[1005][1005];
ull t2[1005][1005];
int h,w;
char U[1005][1005];
 
 
int main(){
  scanf("%d %d",&H,&W);
  for(int i=0;i<H;i++)scanf("%s",T[i]);
  scanf("%d %d",&h,&w);
  for(int i=0;i<h;i++)scanf("%s",U[i]);
   
  ull target=0;  
  for(int i=0;i<h;i++){
    ull key=0;
    for(int j=0;j<w;j++){
      key=key*B+U[i][j];
    }
    target=target*A+key;
  }
 
  ull C=1;
  for(int i=0;i<w;i++)C*=B;
   
  for(int i=0;i<H;i++){
    ull key=0;
    for(int j=0;j<W;j++){
      key=key*B+T[i][j];
      if(j-w>=0)key-=T[i][j-w]*C;
      t[i][j]=key;
      t2[i][j]=t[i][j];
    }
  }
   
  C=1;
  for(int i=0;i<h;i++)C*=A;
   
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(i)t[i][j]+=t[i-1][j]*A;
      if(i-h>=0)t[i][j]-=t2[i-h][j]*C;
      if(t[i][j]==target){
        if(i-h+1>=0&&j-w+1>=0)
          printf("%d %d\n",i-h+1,j-w+1);
      }
    }
  }
 
 
  return 0;
}

Measured memory_bytes: 20780
using System;
using System.IO;
using System.Collections.Generic;
using System.Numerics;

namespace abc138
{
    class Program
    {
        static void Main(string[] args)
        {
            //Console.SetIn(new StreamReader("input.txt"));
            solve_abc138B();
        }

        public static void solve_abc138B()
        {
            int n = Convert.ToInt32(Console.ReadLine());
            string[] a = Console.ReadLine().Split(' ');

            decimal sum = 0;
            for (int i = 0; i < n; i++)
            {
                sum += 1 / Convert.ToDecimal(a[i]);
            }

            sum = 1 / sum;

            Console.WriteLine(Math.Round(sum, 14));
        }

        public static void solve_abc138A()
        {
            int a = Convert.ToInt32(Console.ReadLine());
            string s = Console.ReadLine();

            Console.WriteLine(a >= 3200 ? s : "red");
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int x,a,b;
  cin >> x >> a >> b;
  if(abs(x-a)<abs(x-b)) cout << "A" << endl;
  else cout << "B" << endl;
  return 0;
}


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

typedef long long ll;

#define REP(var,n) for(int var=0;var<(n);var++)
#define REPP(var,n) for(int var=1;var<(n);var++)
#define ALL(c) (c).begin(),(c).end()

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

  int a[N];
  int b[N];

  REP(i, N){
    cin >> a[i];
    cin >> b[i];
  }

  int tmpCost = 1001;

  REP(i, N){
    if(b[i] <= T && a[i] < tmpCost){
      tmpCost = a[i]; 
    }                   
  }          
             
  if(tmpCost == 1001){
    cout << "TLE" << endl;
  }else{
    cout << tmpCost << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <deque>

int getcount(long long x){
  int retval = 0;
  while (x%2==0){
    retval++;
    x=x/2;
  }
  return retval;
}

int main(){
  int N;
  scanf("%d", &N);
  std::vector<long long > a(N);
  int ans = 0;
  for (int i=0; i<N; i++){
    scanf("%lld", &a[i]);
    ans += getcount(a[i]);
  }
  printf("%d\n", ans);
  return 0;
}


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

const int inf = 1e17;
const int Max = 3010;
int arr[Max];
int memo[Max][Max];
int solve(int l, int r, bool First) {//inclusive, inclusive
    if(l > r) return 0;
    if(memo[l][r] != inf) return memo[l][r];
    if(First) {
        return memo[l][r] = max(arr[l] + solve(l+1,r, !First), arr[r] + solve(l,r-1,!First));
    }
    return memo[l][r] = min(-arr[l] + solve(l+1,r,!First), -arr[r] + solve(l,r-1,!First));
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    for(int i = 0; i < n; ++i) {
        cin >> arr[i];
        for(int j = 0; j < n; ++j) {
            memo[i][j] = inf;
        }
    }
    cout << solve(0, n-1, true) << '\n';
    return 0;
}


























Measured memory_bytes: 70912
r, g, b, n = gets().split().map(&:to_i)

m = [r, g, b].sort

i = 0
j = 0
k = 0

c = 0

r0 = n - i * m[0]

loop do 
  j = 0
  g0 = r0 - j * m[1]
  loop do
    if g0 % m[2] == 0
      c += 1
    end

    j += 1
    g0 = r0 - j * m[1]
    break if g0 < 0
  end

  i += 1
  r0 = n - i * m[0]
  break if r0 < 0
end

puts c

Measured memory_bytes: 1788
#include<iostream>
#include<map>
#include<string>
using namespace std;
int main() {
	long long int n,m=0,a=0,r=0,c=0,h=0;
	string name;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> name;
		if(name.front()=='M'){
			m++;
		}
		else if (name.front() == 'A') {
			a++;
		}
		else if (name.front() == 'R') {
			r++;
		}
		else if (name.front() == 'C') {
			c++;
		}
		else if (name.front() == 'H') {
			h++;
		}
	}
	cout << m*(a*(r+c+h)+r*(c+h)+c*h)+ a*(r*(c+h)+c*h) + r*c*h<< endl;
	return 0;
}

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

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

ld toRad(ld x) {
    return x * (acos(-1) / 180.);
}

ld toDeg(ld x) {
    return x * (180. / acos(-1));
}

int main() {
//    ios::sync_with_stdio(false);
//    cin.tie(nullptr);
    ld a, b, x;
    cin >> a >> b >> x;
    ld angle = toDeg(atan2(b, a));
    ld low = 0., high = 90.;
    for (int i = 0; i < 200; i++) {
        ld mid = (low + high) / 2.;
        if (mid < angle) {
            ld opp = tan(toRad(mid)) * a;
            ld trArea = opp * a / 2.;
            if ((a * b - trArea) * a >= x) {
                low = mid;
            } else {
                high = mid;
            }
        } else {
            ld opp = tan(toRad(90. - mid)) * b;
            ld trArea = opp * b / 2.;
            if (trArea * a >= x) {
                low = mid;
            } else {
                high = mid;
            }
        }
    }
    cout << fixed << setprecision(10) << low;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
      public static void main(String[] args){
          Scanner sc =new Scanner (System.in);
          String a;
          int n ;
          a = sc.nextLine();
          int l =a.length();
          for (n=0;n<l;n++){
              char b =a.charAt(n);
              if(Character.isLowerCase(b)){
                  System.out.print(Character.toUpperCase(b));
              }else if(Character.isUpperCase(b)){
                  System.out.print(Character.toLowerCase(b));
              }else{
                  System.out.print(b);
              }
             }
          
          System.out.printf("\n");
            }


          

    

}


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

using namespace std;

int main(){
  int N;
  cin >> N;
  //vector<int> a(N);
  vector<int> b(N);
  for(int i=0;i<N;i++){
    int k=0;
    cin >> k;
    b[k-1]=i+1;
  }
  for(int i=0;i<N;i++){
    cout << b.at(i) << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 1152
from math import atan, degrees

a, b, x = map(int, input().split())

theta = 0
if x < a ** 2 * b / 2:
    theta = atan(a * b ** 2 / 2 / x)
else:
    theta = atan(2 * b / a - 2 * x / a ** 3)

print(degrees(theta))


Measured memory_bytes: 2940
#include <stdio.h>
#include <iostream>
#include <cassert>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <deque>

#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define irep(i,a,b) for(int i=(a);i>=(b);i--)

using namespace std;
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;

int cc[2000][2000];
int rr[2000][2000];

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


  int H, W;
  cin >> H >> W;
  string ss[H];

  rep(i, 0, H-1) cin >> ss[i];


  int ans = 0;
  rep(i, 0, H-1) {
    rep(j, 0, W-1) {
      if (ss[i][j] == '.') {
        int r = 1;
        if (rr[i][j] > 0) r = rr[i][j];
        else {
        irep(k, j-1,0) if (ss[i][k] =='.') r++; else break;
        rep(k, j+1,W-1) if (ss[i][k] =='.') r++; else break;

        irep(k, j-1,0) if (ss[i][k] =='.') rr[i][k] = r; else break;
        rep(k, j+1,W-1) if (ss[i][k] =='.') rr[i][k] = r; else break;
        }
        int c = 1;
        if (cc[i][j] > 0) c = cc[i][j];
        else {

        irep(k, i-1,0)  if (ss[k][j] =='.') c++; else break;
        rep(k, i+1,H-1) if (ss[k][j] =='.') c++; else break;

        irep(k, i-1,0)  if (ss[k][j] =='.') cc[k][j] = c; else break;
        rep(k, i+1,H-1) if (ss[k][j] =='.') cc[k][j] = c;  else break;
        }

        ans = max(ans, c + r - 1);
      }
    }
  }

  cout << ans << endl;

}


Measured memory_bytes: 35840