akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.IO;

class Solve {
    static void Main(string[] args) {
        var N = int.Parse(Console.ReadLine());
        var abc = new int[N, 3];
        for (int i = 0; i < N; i++) { 
           var arr = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
           for (int j = 0; j < 3; j++) {
               abc[i, j] = arr[j];
           }
        }
        var dp = new int[N, 3];
        for (int i = 0; i < 3; i++) dp[0, i] = abc[0, i];
        for (int i = 1; i < N; i++) {
            for (int j = 0; j < 3; j++) {
                for (int k = 0; k < 3; k++) {
                    if (j == k) continue;
                    dp[i, j] = Math.Max(dp[i, j], dp[i - 1, k] + abc[i, j]);
                }
            }
        }
        var answer = 0;
        for (int i = 0; i < 3; i++) {
            answer = Math.Max(answer, dp[N - 1, i]);
        }
        var writer = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();
    }
}

Measured memory_bytes: 48484
import java.util.*;
public class Main{
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int table[] = new int[N];
		int orgtab[] = new int[N];
		int parity = 0;
		for(int i = 0; i<N; i++) {
			table[i] = sc.nextInt();
			orgtab[i] = table[i];
		}
 
		Arrays.sort(table);
		HashMap<Integer,Integer> map = new HashMap<>();
		for(int i = 0; i<N; i++) {
			map.put(table[i],i);
		}
 
		for(int i = 0; i<N; i+=2) {
			int a = (map.get(orgtab[i]))%2;
			parity += a;
		}
		System.out.println(parity);
		
	}
}


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

int main()
{
  int r,c;
  for(;cin>>r>>c,r;)
    {
      bool tab[r][c];
      for(int i=0;i<r;i++)
        for(int j=0;j<c;j++)
          cin>>tab[i][j];
      int ans=0;

      for(int b=0;b<(1<<r);b++)
        {
          int sum=0;
          /*
            for(int i=0;i<r;i++)
            {
            cerr<<((b&(1<<i))==0);
            }
            cerr<<endl;
          */
          for(int j=0;j<c;j++)
            {
              int tmp[2]={0,0};
              for(int i=0;i<r;i++)
                {

                  if((b&(1<<i))==0)
                    {
                      //                    cerr<<!tab[i][j];
                      tmp[!tab[i][j]]++;
                    }
                  else
                    {
                      //  cerr<<tab[i][j];
                      tmp[tab[i][j]]++;
                    }
                }
              sum+=max(tmp[0],tmp[1]);
              //     cerr<<tmp[0]<<" "<<tmp[1]<<endl;
            }

          //                   cerr<<"b "<<b<<" "<<sum<<endl;

          ans=max(ans,sum);

        }
      cout<<ans<<endl;

    }


}

Measured memory_bytes: 1252
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <vector>

using namespace std;
typedef long long ll;


ll ans,mx,mn=1e8,sum,cnt;

int main(){
	ll n;
	cin>>n;
	vector<pair<ll,ll>> vec;
	for(ll i=0; i<n; i++){
		ll a,b;
		cin>>a>>b;
		vec.push_back(make_pair(b,a));
	}
	sort(vec.begin(),vec.end());
	for(ll i=0; i<n; i++){
		ans+=vec[i].second;
		if(ans > vec[i].first){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
}


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

#define sz(s) (ll)(s.size())
#define all(x) (x.begin(), x.end())
#define pb push_back
#define pf push_front
#define F first
#define S second
#define nl endl
#define ort1 exit(0);
#define db double
#define TL (double)clock()/CLOCKS_PER_SEC

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;


const double pi = acos(-1.0);
const double eps = 1e-9;
const int mod = 1e9 + 7;
const ll INF = 1e12 + 1;
const int N = 1e5 + 9;

string s;
int ans = 700;

int main(){
    

    cin >> s;
    for(int i = 0; i < s.size(); ++i){
        if(s[i] == 'o') ans+=100;
    }

    cout << ans;

ort1
}

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

using namespace std;

#define MAX_N 10000000

bool sosuu[MAX_N+1];
int main() {
//	vector<int> s;

	fill(&sosuu[0], &sosuu[MAX_N], true);
	sosuu[0] = sosuu[1] = false;

	for (int i = 2; i < MAX_N+1; ++i)
		if (sosuu[i]) {
//			s.push_back(i);
			for (int j = i*2; j < MAX_N+1; j += i)
				sosuu[j] = false;
		}

	int n;
	while (cin >> n, n) {
		for (int i = n; i >= 13; --i)
			if (sosuu[i] && sosuu[i-2] && sosuu[i-6] && sosuu[i-8]) {
				cout << i << endl;
				break;
			}
	}
}

Measured memory_bytes: 10000
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    ll a, b, n;
    cin >> a >> b >> n;
    ll c = min(n, b-1);
    int ans = 0;
    ll m = 0;
    rep(i, a){
        m += c;
        if(m >= b){
            ans++;
            m %= b;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3676
#include <stdio.h>

int main()
{
	int a=0, b=0;

	scanf("%d %d", &a, &b);

	if(a > b) {
		printf("a > b\n");
	}
	else if(a < b) {
		printf("a < b\n");
	}
	else {
		printf("a == b\n");
	}

	return 0;
}



Measured memory_bytes: 2612
from sys import stdin
import numpy as np
#from operator import itemgetter

#N = int(stdin.readline().rstrip().split()[0])
a,b,c = [int(x) for x in stdin.readline().rstrip().split()]
#A = [int(x) for x in stdin.readline().rstrip().split()]

MOD = 10**9 + 7
"""
sqrtab = np.sqrt(a*b)
if 2*sqrtab < c-a-b:
  print("Yes")
else:
  print("No")

sqrta = np.sqrt(a)
sqrtb = np.sqrt(b)
sqrtc = np.sqrt(c)
if sqrta+sqrtb < sqrtc:
  print("Yes")
else:
  print("No")
"""
if 4*a*b<(c-a-b)**2 and c-a-b>0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 12500
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define MOD 1000000007
#define INF 1000000007
#define PI 3.14159265358979323846
using namespace std;
//
long long N,A,X[51];
long long DP[51][51][3000];
int main(){
  cin>>N>>A;
  FOR(i,0,N){
    cin>>X[i];
  }
  DP[0][0][0]=1;
  FOR(i,0,N){
    FOR(j,0,N){
      FOR(k,0,3000){
        if(DP[i][j][k]==0){
          continue;
        }else{
          DP[i+1][j+1][k+X[i]]+=DP[i][j][k];
          DP[i+1][j][k]+=DP[i][j][k];
        }
      }
    }
  }
  long long sum=0;
  FOR(i,1,N+1){
    sum+=DP[N][i][i*A];
  }
  cout<<sum<<endl;
  return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }




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

    int ans = -1;
    double tmpans = 10000000;
    rep(i, n) {
        double tmp = t - (0.006 * h[i]);

        //cout << abs(a-tmp)  << endl;
        if(abs(a - tmp) < tmpans) {
            tmpans = abs(a - tmp);
            ans = i + 1;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <queue>
#define MAX 100000

using namespace std;

vector<int>graph[MAX + 5], graphT[MAX + 5];
int grad[MAX + 5], C[MAX + 5], dp[MAX + 5];

void sortareT(int n)
{
    for(int i = 1; i <= n; i++)
        if(!grad[i])
            C[++C[0]] = i;

    for(int i = 1; i <= n; i++)
        for(auto x : graph[C[i]])
        {
            grad[x]--;

            if(!grad[x])
                C[++C[0]] = x;
        }
}

int main()
{
    int n, m;

    cin >> n >> m;

    for(int i = 1; i <= m; i++)
    {
        int a, b;

        cin >> a >> b;

        graph[a].push_back(b);
        graphT[b].push_back(a);

        grad[b]++;
    }

    sortareT(n);

    int maxLength = 0;
    for(int i = 1; i <= n; i++)
    {
        for(int j = 0; j < graphT[C[i]].size(); j++)
            dp[C[i]] = max(dp[C[i]], dp[graphT[C[i]][j]] + 1);

        maxLength = max(maxLength, dp[C[i]]);
    }

    cout << maxLength;

    return 0;
}


Measured memory_bytes: 12416
K = int(input())
def gcd(x,y):
    if x<y:x,y = y,x
    while y!=0:
        r = x%y
        x = y
        y = r
    return x
s = 0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            s+=gcd(a,gcd(b,c))
print(s)

Measured memory_bytes: 69252
#include<iostream>
using namespace std;
 
using ll = long long;
const ll mod = 998244353;
 
 
ll dp[3030][3030][3];
int a[3030];
int main(){
    int n, k;
    cin >> n >> k;
    for(int i=0;i<n;i++)cin >> a[i];
    dp[0][0][0] = 1;
    for(int i=0;i<n;i++){
        for(int j=0;j<=k;j++){
            (dp[i+1][j][0] += dp[i][j][0]) %= mod;
            (dp[i+1][j][1] += dp[i][j][0] + dp[i][j][1]) %= mod;
            (dp[i+1][j][2] += dp[i][j][0] + dp[i][j][1] + dp[i][j][2]) %= mod;
            if(j + a[i] <= k){
                (dp[i+1][j+a[i]][1] += dp[i][j][0] + dp[i][j][1]) %= mod;
                (dp[i+1][j+a[i]][2] += dp[i][j][0] + dp[i][j][1]) %= mod;
            }
        }
    }
    /*for (int tx = 0; tx <= 2; tx++) {
      cout << "******\n" ;
      cout << "tx = " << tx << endl;
      cout << "******\n" ;
      for (int j = 0; j <= k; j++) {
        for (int i = 0; i <= n; i++) {
          cout << dp[i][j][tx] << ' ';
        }
        cout << endl;
      }
      cout << endl << endl;
    }*/
    long long sum = 0;
    for (int i = 0; i <= n; i++) {
      sum = (sum + dp[i][k][1]) % mod;
    }
    cout << sum << '\n';
    //cout << dp[n][k][2] << endl;
}

Measured memory_bytes: 215168
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

long long int N, M, K, Q, W, H, L, R;
long long int ans;


int main() {
	ios::sync_with_stdio(false);
	cin >> H >> W;
	while (H) {
		int num[10][10] = {};
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++)cin >> num[i][j];
		}
		ans = 0;
		for (int i = 0; i < H; i++) {
			for (int j = i + 2; j < H; j++) {
				for (int k = 0; k < W; k++) {
					for (int l = k + 2; l < W; l++) {
						int box = 0;
						int edge = 10;
						int pond = 0;
						for (int m = i; m <= j; m++) {
							edge = min(edge, num[m][k]);
							edge = min(edge, num[m][l]);
						}
						for (int m = k; m <= l; m++) {
							edge = min(edge, num[i][m]);
							edge = min(edge, num[j][m]);
						}

						for (int m = i + 1; m < j; m++) {
							for (int n = k + 1; n < l; n++) {
								pond = max(pond, num[m][n]);
								box += edge - num[m][n];
							}
						}
					//	cout << edge << " " << pond << endl;
						if (edge > pond) {
							ans = max((int)ans, box);
						}
					}
				}
			}
		}
		cout << ans << endl;
		cin >> H >> W;
	}
	return 0;
}

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

int main()
{
  int n,k;
  cin >> n >> k;
  
  ll h[n];
  rep(i,n) cin >> h[i];
  
  sort(h,h+n);
  
  ll ans = 1e9+1;
  for(int i = 0; i <= n-k; i++)
  {
    if(h[i+k-1] - h[i] < ans)
    {
      ans = h[i+k-1] - h[i];
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 4316
a, b = map(int, input().split())

d = 0
for i in range(a, b+1):
    c = str(i)
    e = True
    for j in range(len(c)//2):
        if c[j] != c[-j-1] and e:
            e = not e
    if e:
        d += 1
print(d)


Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

ll N,L,T;
vector<ll> X;
vector<int> W;

int main(){
  cin>>N>>L>>T;
  vector<ll> place;
  for(int i=0;i<N;i++){
      ll x,w;
      cin>>x>>w;
      X.push_back(x);
      W.push_back(w);
      if(w==1) place.push_back((x+T)%L);
      else place.push_back((x-T+T*L)%L);
  }

  ll count=0;
  for(int i=0;i<N;i++){
      if(W[i]==1){
          count-=(T-(L-X[i])+L)/L;
      }else{
          count+=(T-(X[i]+1)+L)/L;
      }
  }
  count=(count%N+N)%N;

  vector<ll> ans(N); 
  sort(place.begin(),place.end());
  for(int i=0;i<N;i++) ans[(i+count)%N]=place[i];
  for(int i=0;i<N;i++) cout<<ans[i]<<endl;

  return 0;
}


Measured memory_bytes: 4456
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr ll INF = 1ll << 55;

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

// multi-dimensional vector (require c++14)
template <typename T, typename U>
static inline vector<U> make_nd_vector(T &&n, U &&val) noexcept {
  static_assert(is_integral<T>::value,
                "[make_nd_vector] 1st argument must be an integer type");
  return vector<U>(forward<T>(n), forward<U>(val));
}
template <typename T, typename... Args>
static inline decltype(auto) make_nd_vector(T &&n, Args &&... args) noexcept {
  static_assert(is_integral<T>::value,
                "[make_nd_vector] 1st argument must be an integer type");
  return vector<decltype(make_nd_vector(forward<Args>(args)...))>(
      forward<T>(n), make_nd_vector(forward<Args>(args)...));
}
//
// Print from Iterator
template <typename ite>
void print_ite(ite start, ite end, char sp = ' ', char en = '\n') {
  for (auto i = start; i != end; i++)
    cout << *i << sp;
  cout << en;
}
//
inline void Yes(bool condition) { cout << (condition ? "Yes\n" : "No\n"); }

int main() {
  int x, y;
  cin >> x >> y;
  bool ok = false;
  for (int i = 0; i <= 100 && x - i >= 0; i++) {
    // i:=num of crane
    int leg = i * 2 + (x - i) * 4;
    if (leg == y)
      ok = true;
  }
  Yes(ok);
}


Measured memory_bytes: 3132
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#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(c) sort((c).begin(),(c).end())
#define INF 1000000000
#define mod 1000000007
int main(){
cin.tie(0);
ios::sync_with_stdio(false);

	ll N,K;
	cin>>N>>K;
	ll ans=0;
	for(int b=K+1;b<=N;b++){
		int n=N/b;
		ans+=n*max(b-K,0LL);
		ans+=max(N%b-K+1,0LL);
	}
	if(K==0)ans-=N;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	var S string
	fmt.Scan(&S)
	ans := 0
	for i := 0; i < 1000; i++ {
		v := fmt.Sprintf("%03d", i)
		// fmt.Printf("i %d, v %s\n", i, v)
		ok1, ok2, ok3 := false, false, false
		for i := 0; i < len(S); i++ {
			if !ok1 {
				if S[i] == v[0] {
					ok1 = true
				}
			} else { // ok1 == true
				if !ok2 {
					if S[i] == v[1] {
						ok2 = true
					}
				} else { // ok1 == true && ok2 == true
					if !ok3 {
						if S[i] == v[2] {
							ok3 = true
						}
					}
				}
			}
		}
		if ok1 && ok2 && ok3 {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define tam 300002

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <ll, ll> dl;
typedef pair <int, int> ii;
typedef vector <ii> vii;
typedef vector <vi> graph;

bool comp(string a, string b) {
	return a.size() < b.size();
}

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

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


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.BitSet;
import java.util.Scanner;

//implement a simple dictionary for [A,C,G,T] 1 ... 12
public class Main {
	public static final int max_size = (1 << 31) -1;
	
	public static BitSet dict = new BitSet(max_size);
	public static int translate(char c) {
		switch(c) {
		case 'A': return 1;
		case 'C': return 2;
		case 'G': return 3;
		case 'T':return 4;
		}
		
		return -1;
	}
	
	public static int translate(String c) {
		int code = 0;
		int base = 1;
		for(int i = 0; i < c.length(); i++) {
			code += translate(c.charAt(i))*base;
			base *= 5;
		}
		return code;
	}
	
	public static void insert(String gene) {
		dict.set(translate(gene));
	}
	
	public static boolean find(String gene) {
		return dict.get(translate(gene));
	}
	
	
	
	
	public static void main(String [] args) {
		Scanner cin = new Scanner(System.in);
		int len = cin.nextInt();
		String cmd, key;
		ArrayList<Boolean> answers = new ArrayList<Boolean>();
		
		for(int i = 0; i< len; i++){
			cmd = cin.next();
			key = cin.next();
			if(cmd.equals("insert")) {
				insert(key);
			}else if(cmd.equals("find")){
				answers.add(find(key));
			}
		}
		
		

		int i = 0;
		while(i < answers.size()) {
			System.out.println((answers.get(i))? "yes":"no");
			i++;
		}
		
		cin.close();
	}

}

Measured memory_bytes: 491384
N,K=map(int,input().split())
num=list(map(float,input().split()))
a=0
check=0
for i in range(N):
    num[i]=(num[i]+1)/2
    if i<K:
        check+=num[i]
a=check        
for i in range(N-K):
    ans=check-num[i]+num[K+i]
    if ans>a:
        a=ans
    check=ans  
print(a)


Measured memory_bytes: 23524
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

int v[101], w[101];
long long dp[101][100005];

int main(){
    int n, W;
    cin >> n >> W;
    for(int i = 0; i < n; i++){
        cin >> w[i] >> v[i];
    }
    //dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i-1]] + v[i-1])
    for(int i = 1; i <= n; i++){
        for(int j = 0; j <= W; j++){
            dp[i][j] = dp[i-1][j];
            if(j - w[i-1] >= 0){
                dp[i][j] = max(dp[i][j], dp[i-1][j-w[i-1]] + v[i-1]);
            }
        }
    }
    cout << dp[n][W] << endl;
    return 0;   
}

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

int main(){
  int W, a, b;
  cin >> W >> a >> b;
  
  if(a+W<b) cout << b-(a+W) << endl;
  else if(b+W<a) cout << a-(b+W) << endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 384
using System;
using System.Linq;

namespace abc130_c
{
    static class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine();
            var items = input.Split(' ');

            var w = items.ParseDouble(0);
            var h = items.ParseDouble(1);
            var x = items.ParseDouble(2);
            var y = items.ParseDouble(3);

            var face = w * h / 2;
            var hasPattern = (x == w / 2 && y == h / 2) ? 1 : 0;

            Console.WriteLine($"{face} {hasPattern}");
        }

        static double ParseDouble(this string[] items, int index)
        {
            var ret = 0d;

            if ((items?.Length ?? 0) > index)
            {
                if (!double.TryParse(items[index], out ret))
                {
                    ret = 0;
                }
            }

            return ret;
        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define FasterIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
const int MX=200000+5;
const int inf=1e9;
typedef long long ll;


int main()
{
    FasterIO;
    int n, k, m, p;
    string s[]={"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

    string s1;
    cin>>s1;
    for(int i=6, j=1; i>=0; i--, j++)
    {
        if(s[i]==s1)
        {
            cout<<j<<endl;
            break;
        }
    }
    return 0;
}


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

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

  int x = -1;
  int y = -1;
  for (int i = 0; i < N+1; i++) {
    for (int j = 0; j < N+1; j++) {
      if (Y/1000 == 9*i + 4*j + N) {
        x = i;
        y = j;
        break;
      } else {
        continue;
      }
    }
  }

  int z = N - x - y;

  if (x == -1 || z < 0) {
    cout << -1 << " " << -1 << " " << -1;
  } else {
    cout << x << " " << y << " " << N-x-y;
  }
}

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

int main(){
	int N, A, B, C, D, i;
	scanf("%d%d%d%d%d", &N, &A, &B, &C, &D);
	A--;
	B--;
	C--;
	D--;
	string S;
	cin >> S;
	for(i = A; i < C; i++){
		if(S[i] == '#' && S[i + 1] == '#'){
			printf("No\n");
			return 0;
		}
	}
	for(i = B; i < D; i++){
		if(S[i] == '#' && S[i + 1] == '#'){
			printf("No\n");
			return 0;
		}
	}
	if(C < D){
		printf("Yes\n");
		return 0;
	}
	for(i = B; i <= D; i++){
		if(S[i - 1] == '.' && S[i] == '.' && S[i + 1] == '.'){
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

map<long long, int> factorization(long long N) {
	map<long long, int> re;
	while (true) {
		if (N % 2 == 0) {
			N /= 2;
			re[2]++;
			if (N == 1) break;
		}
	}
	if (N > 1) re[N]++;
	for (int loop = 3; (long long)loop * (long long)loop <= N; loop += 2) {
		if (N % loop == 0) {
			N /= loop;
			re[loop]++;
			loop -= 2;
			if (N == 1) break;
		}
	}
	if (N > 1) re[N]++;
	return re;
}

struct Memo {
	long long fact = 0;
	long long fact_inv = 0;
	long long inv = 0;
};
class Combination1 {
private:
	int m_module = 1000000007;
	vector<struct Memo> memo;
public:
	int calculate(int, int);
	Combination1(int, int);
};
int Combination1::calculate(int n, int k) {
	return ((memo[n].fact * memo[k].fact_inv) % m_module * memo[n - k].fact_inv) % m_module;
}
Combination1::Combination1(int memo_max, int module = 1000000007) {
	m_module = module;
	memo.push_back({ 1,1,0 });
	memo.push_back({ 1,1,1 });
	for (int loop = 2; loop <= memo_max; loop++) {
		struct Memo temp;
		temp.fact = (memo[loop - 1].fact * loop) % m_module;
		temp.inv = m_module - (memo[m_module % loop].inv * int(m_module / loop)) % m_module;
		temp.fact_inv = (memo[loop - 1].fact_inv * temp.inv) % m_module;
		memo.push_back(temp);
	}
}

class Combination2 {
private:
	int size = 0;
	bool add(int);
public:
	vector<int> sequence;
	bool next_combination(void);
	Combination2(int, int);
};
bool Combination2::add(int index) {
	if (index == (int)sequence.size() - 1 && sequence[index] == size - 1
		|| index < (int)sequence.size() - 1 && sequence[index] == sequence[index + 1] - 1) {
		if (index == 0) {
			return false;
		}
		else {
			bool re = add(index - 1);
			sequence[index] = sequence[index - 1] + 1;
			return re;
		}
	}
	else {
		sequence[index]++;
		return true;
	}
}
bool Combination2::next_combination(void) {
	return (sequence.size() == 0) ? false : add(sequence.size() - 1);
}
Combination2::Combination2(int n, int r) {
	size = n;
	for (int loop = 0; loop < r; loop++) sequence.push_back(loop);
	return;
}

void A_The_Number_of_Even_Pairs(void) {

	int N, M; cin >> N >> M;
	cout << (N * (N - 1) + M * (M - 1)) * 0.5 << flush;
	return;
}

void B_String_Palindrome(void) {

	string S; cin >> S;
	int N = S.size();

	for (int loop = 0; loop < N; loop++) {
		if (S[loop] != S[N - loop - 1]) {
			cout << "No" << flush;
			return;
		}
	}
	for (int loop = 0; loop * 2 <= N - 3; loop++) {
		if (S[loop] != S[(N - 3) / 2 - loop]) {
			cout << "No" << flush;
			return;
		}
	}
	for (int loop = (N + 1) / 2; loop < N; loop++) {
		if (S[loop] != S[N - 1 + (N + 1) / 2 - loop]) {
			cout << "No" << flush;
			return;
		}
	}
	cout << "Yes" << flush;
	return;
}

int main(void) {

	//A_The_Number_of_Even_Pairs();
	B_String_Palindrome();
	return 0;
}


Measured memory_bytes: 256
n,m,q = map(int,input().split())

lr = [[0 for i in range(n+1)] for j in range(n+1)]


for i in range(m):
    l,r = map(int,input().split())
    lr[l][r] += 1

pq = [[int(i) for i in input().split()]for j in range(q)]

dp = [[0 for i in range(n+1)] for j in range(n+1)]

for i in range(1,n+1):
    for j in range(i,n+1):
        dp[i][j] = dp[i][j-1]+lr[i][j]

ans_dp = [[0 for i in range(n+1)] for j in range(n+1)]

for i in range(1,n+1):
    for j in range(i,n+1):
        tmp = 0
        for k in range(j-i+1):
            tmp += dp[i+k][j]
        ans_dp[i][j] = tmp

for i in range(q):
    print(ans_dp[pq[i][0]][pq[i][1]])


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

using namespace std;

#define PI          3.1415926535897932384626433832795l

#define pb push_back
#define mp make_pair
#define lb lower_bound // First element which is not less than val
#define ub upper_bound // First element greater than val
#define f first
#define s second

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using vpii = vector<pair<int,int>>;
using vpll = vector<pair<ll,ll>>;

using pii = pair<int,int>;
using pll = pair<ll,ll>;

#define endl '\n'
#define re return

#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define repz(i, a) for (ll i = 0; i < (a); i++)
#define repd(i,a,b) for (ll i = (a); i >= b; i--)
#define repdz(i,a) for (ll i = a; i >=0; i--)
#define trav(a, x) for (auto& a : x)

#define vecin(n,v) for(ll i = 0; i < n; i++) cin>>v[i];
#define llin(a) ll a; cin>>a;
#define llin2(a,b) ll a,b; cin >>a>>b;
#define llin3(a,b,c) ll a,b,c; cin>>a>>b>>c;
#define full(v) v.begin(),v.end()

void solve()
{
    llin2(s,w);
    if (w>=s) cout << "unsafe";
    else cout << "safe";
}

int main()
{
    ios_base::sync_with_stdio(false);
    //llin(t);
    //while (t--)
    //{
        solve();
    //}
}


Measured memory_bytes: 3568
from collections import Counter

def solve():
    MOD = 10**9 + 7

    N = int(input())
    As = list(map(int, input().split()))

    def getPrimeFactors(x):
        anss = []
        while x%2 == 0:
            anss.append(2)
            x //= 2
        for d in range(3, int(x**0.5)+1, 2):
            while x%d == 0:
                anss.append(d)
                x //= d
        if x != 1:
            anss.append(x)
        return anss

    maxCnt = Counter()
    for A in As:
        PFs = getPrimeFactors(A)
        cnt = Counter(PFs)
        maxCnt |= cnt

    LCM = 1
    for p, e in maxCnt.items():
        LCM *= pow(p, e, MOD)
        LCM %= MOD

    maxA = max(As)

    def getInvs(n, MOD):
        invs = [1] * (n+1)
        for x in range(2, n+1):
            invs[x] = (-(MOD//x) * invs[MOD%x]) % MOD
        return invs
    invs = getInvs(maxA, MOD)

    sumInv = 0
    for A in As:
        sumInv += invs[A]
        sumInv %= MOD

    ans = LCM * sumInv % MOD
    print(ans)


solve()


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

int main() {
    int n;
    string s, t;
    cin >> n >> s >> t;
    string ans;
    rep(i,n) {
        ans.push_back(s[i]);
        ans.push_back(t[i]);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(){
    string ans = "APPROVED";
    int N;
    cin >> N;
    for(int i = 0;i < N;i++){
        int A;
        cin >> A;
        if(A % 2 == 0)
            if(!(A % 3 == 0 || A % 5 == 0))
                ans = "DENIED";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,b,n) for(int i=b;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
typedef pair<int,int> P;
vector<vector<P>> g;
vector<int> res;
void dfs(int v,int p,int c){
    res[v]=c;
    for(auto k:g[v]){
        if(k.first==p)continue;
        if(k.second%2==0)dfs(k.first,v,c);
        else dfs(k.first,v,1-c);
    }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    g.assign(n,vector<P>());
    res=vector<int>(n);
    rep(i,n-1){
        int u,v,w;cin>>u>>v>>w;
        --u;--v;
        g[u].push_back(make_pair(v,w));
        g[v].push_back(make_pair(u,w));
    }
    dfs(0,-1,0);
    rep(i,n)cout<<res[i]<<endl;
    return 0;
}


Measured memory_bytes: 8960
// id: ALDS1_3_B
// CPU: 00:01sec  Memory: 3348KB
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

#define NAME_LEN 10

struct Process;
struct Node;
struct Queue_type;
typedef struct Process Item;
typedef struct Node *PtrToNode;
typedef PtrToNode Position;
typedef struct Queue_type *Queue;

struct Process {
	char pid[NAME_LEN + 1];
	int rest;
};

struct Node {
	Item data;
	Position next;
};

struct Queue_type {
	Position front;
	Position rear;
};

Queue create(void);
void destroy(Queue q);
void make_empty(Queue q);
bool is_empty(Queue q);
void enqueue(Queue q, Item i);
Item front(Queue q);
Item dequeue(Queue q);
static void terminate(const char *message);

int main(void)
{
	int n, slice;
	Queue processes = create();
	int time = 0;

	scanf("%d%d", &n, &slice);

	for ( int i = 0; i < n; ++i ) {
		Item process;

		scanf("%s%d", process.pid, &process.rest);
		enqueue(processes, process);
	}

	while ( !is_empty(processes) ) {
		Item process = dequeue(processes);

		if ( process.rest > slice ) {
			process.rest -= slice;
			time += slice;
			enqueue(processes, process);
		}
		else {
			time += process.rest;
			printf("%s %d\n", process.pid, time);
		}
	}

	destroy(processes);

	return 0;
}

Queue create(void)
{
	Queue q;

	q = malloc(sizeof(struct Queue_type));
	if ( q == NULL )
		terminate("Error in create: queue could not be created.");

	q->front = malloc(sizeof(struct Node));
	if ( q->front == NULL ) {
		free(q);
		terminate("Error in create: fail to allocate space for the header.");
	}

	q->front->next = NULL;

	q->rear = q->front;

	return q;
}

void destroy(Queue q)
{
	make_empty(q);

	free(q->front);
	free(q);
}

void make_empty(Queue q)
{
	while ( !is_empty(q) )
		dequeue(q);
}

bool is_empty(Queue q)
{
	return q->front->next == NULL;
}

void enqueue(Queue q, Item i)
{
	Position tmp = malloc(sizeof(struct Node));

	if ( tmp == NULL ) {
		destroy(q);
		terminate("Error in enqueue: fail to allocate space for new node.");
	}

	tmp->data = i;
	tmp->next = NULL;

	q->rear->next = tmp;
	q->rear = tmp;
}

Item front(Queue q)
{
	if ( is_empty(q) ) {
		destroy(q);
		terminate("Error in front: queue is empty.");
	}

	return q->front->next->data;
}

Item dequeue(Queue q)
{
	Item item;
	Position tmp;

	if ( is_empty(q) ) {
		destroy(q);
		terminate("Error in dequeue: queue is empty.");
	}

	tmp = q->front->next;
	item = tmp->data;
	q->front->next = tmp->next;

	if ( q->rear == tmp )
		q->rear = q->front;

	free(tmp);

	return item;
}

static void terminate(const char *message)
{
	printf("%s\n", message);
	exit(EXIT_FAILURE);
}


Measured memory_bytes: 3304
/*||>>>> Praveen Ojha <<<<>>>> 29 August 2019 <<<<>>>> 02:03:21 <<<<||*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
//Read Problems Carefully & Check for corner cases N=0,1 ?
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
const int N=(1<<21)+10;
int n;
int dp[21][N],a[22][22];
void add(int &aa,int b){
	aa+=b;
	if(aa>=mod)
		aa-=mod;
}
int solve(int ind,int mask){
	if(ind==n)
		return 1;

	int &ans=dp[ind][mask];
	if(ans!=-1)
		return ans;
	ans=0;
	for(int j=0;j<n;j++){
		if(a[ind][j] && !(mask&(1<<j))){
			add(ans,solve(ind+1,mask|(1<<j)));
		}
	}
	return ans;
}
int32_t main(){__
	cin>>n;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cin>>a[i][j];
		}
	}
	memset(dp,-1,sizeof dp);
	cout<<solve(0,0)<<"\n";
return 0;
}

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

void dfs(int i, string s, const int size)
{
    if(i == size){
        cout << s << endl;
        return;
    }
    int maxv = 0;
    for(int j = 0;j < i;++j)maxv = max(int(s[j]), maxv);
    for(char c = 'a';c <= maxv + 1;++c){
        dfs(i + 1, s + c, size);
        s.erase(i);
    }
}

int main(void)
{
    int N;
    cin >> N;
    dfs(1, "a", N);
}


Measured memory_bytes: 1536
#include <iostream>

using namespace std;

int n;
int h, w;

int main(void)
{
	cin >> n;
	cin >> h >> w;
	
	int ans = 0, a, b;
	for(int i = 0; i < n; i++){
		cin >> a >> b;
		if(a >= h && b >= w) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;

int main(void) {
    Int a, b;
    cin >> a >> b;
    if (a + b == 15) {
        cout << '+' << endl;
    } else if (a * b == 15) {
        cout << '*' << endl;
    } else {
        cout << 'x' << endl;
    }
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int N;
	string S;
	cin >> N >> S;
	int white = 0;
	for (int i = 0; i < N; i++) {
		if (S[i] == '.') {white++;}
	}
	int ans = min(white, N - white);
	int right_white = white;
	int left_black = 0;
	for (int i = 0; i < N; i++) {
		ans = min(ans, right_white + left_black);
		if (S[i] == '#') {left_black++;}
		else {right_white--;}
	}
	cout << ans << endl;
}

Measured memory_bytes: 720
#include<stdio.h>
#define NIL -1

typedef struct node{
  int p;
  int r;
  int k;
}Node;

Node T[25];

void Preorder(int u){
  if(u == NIL)return;
  printf(" %d",u);
  Preorder(T[u].k);
  Preorder(T[u].r);
  
}

void Inorder(int u){
  if(u == NIL)return;
  Inorder(T[u].k);
  printf(" %d",u);
  Inorder(T[u].r);
  
}

void Postorder(int u){
  if(u == NIL)return;
  Postorder(T[u].k);
  Postorder(T[u].r);
  printf(" %d",u);
  
}




int main(){
  int n,i,j;
  int v,k,r;
  int root;

  scanf("%d",&n);


  for(i=0;i<n;i++){
    T[i].p = NIL;
    T[i].k = NIL;
    T[i].r = NIL;
  }

  for(i=0;i<n;i++){
    scanf("%d%d%d",&v,&k,&r);
    T[v].k = k;
    T[v].r = r;
    if(k != NIL)T[k].p = v;
    if(r != NIL)T[r].p = v;
  }

  for (i=0;i<n;i++) {
    if (T[i].p == NIL) root = i;
  }
  

  printf("Preorder\n");
  Preorder(root);
  printf("\nInorder\n");
  Inorder(root);
  printf("\nPostorder\n");
  Postorder(root);
  puts("");
  return 0;

    
}



Measured memory_bytes: 2104
# -*- coding: utf-8 -*-
import sys 
from collections import deque
sys.setrecursionlimit(10**6)
MOD = 10**9+7 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
S = readline().decode().rstrip()
W_cnt = S.count('W')
R_cnt = S.count('R')
ans = 0
W_ind = []
R_ind = []
for i in range(N):
    if S[i] == 'W':
        W_ind.append(i)
    else:
        R_ind.append(i)
for w in W_ind:
    if len(R_ind) == 0:
        break
    r = R_ind.pop()
    if r < w:
        break
    ans += 1
print(ans)

Measured memory_bytes: 81756
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws IOException {
		Scanner scanner = new Scanner(System.in);
		//Scanner scanner = new Scanner("2");
		double r = scanner.nextDouble();
		System.out.println(String.format("%1.6f %1.6f", method01(r), method02(r)));
	}

	public static double method01(double r) {
		return (r * r * Math.PI);
	}

	public static double method02(double r) {
		return (r * 2 * Math.PI);
	}
}

Measured memory_bytes: 28148
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long min = (long) Math.pow(10, 9);
		boolean minus = false;
		boolean zero = false;
		long ans = 0;
		for(int i = 0; i < N; i++) {
			long tmp = sc.nextLong();
			ans += Math.abs(tmp);
			min = Math.min(min, Math.abs(tmp));
			if(tmp < 0) {
				minus = !minus;
			} else if(tmp == 0) {
				zero = true;
			}
		}
		if((!zero) && minus) {
			ans -= min * 2;
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 49608
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a,i=0;
    while(true){
      i++;
      a=sc.nextInt();
      if(a==0) break;
      System.out.println("Case "+i+": "+a);
    }
      sc.close();
  }
}


Measured memory_bytes: 41540
#include <cstdio>

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  bool any = false;
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    if (x % 2 == 1) {
      any = true;
    }
  }
  puts(any ? "first" : "second");
}


Measured memory_bytes: 128
#!/usr/bin python3
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline

def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()

    ret = 'YES'
    for i in range(1, N):
        if A[i]==A[i-1]:
            ret = 'NO'
            break
    print(ret)

if __name__ == '__main__':
    main()

Measured memory_bytes: 26812
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
const n = Number(lines[0]);
const str = "ACL";
console.log(str.repeat(n));
});

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

typedef long long ll;

vector<ll>pre, v;
vector<vector<ll> >dp;
int n;
int main(){
	cin >> n;
	v.resize(n); pre.resize(n, 0);
	dp.resize(n);
	for(auto &i : v) cin >> i;
	//for(auto x: v) cout << x << " ";
	pre[0] = v[0];
	for(int i=1; i<n; i++){
		pre[i] = pre[i-1]+v[i];
	}
	/*for(auto x:pre) cout << x << " ";
	cout << endl;*/
	for(int i=0; i<n; i++) dp[i].resize(n);
	for(int i=0; i<n; i++) dp[i][i] = 0LL;
	for(int length = 2; length <= n; length++){
		for(int i=0; i<n-length+1; i++){
			int j = i + length - 1;
			dp[i][j] = 1e14+1;
			ll sum = 0LL;
			for(int s = i; s<j; s++){
				if(i == 0) sum = pre[j];
				else sum = pre[j] - pre[i-1];
				//cout << sum << " ";
				dp[i][j] = min(dp[i][j], dp[i][s]+dp[s+1][j]+sum);
			}
		}
	}
	/*for(int i=0; i<n; i++){
		for(int j=0; j<n; j++) cout << dp[i][j] << " ";
		cout << endl;
	}*/
	cout << dp[0][n-1] << endl;
	return 0;
}


Measured memory_bytes: 1536
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 a = A+B;
		int b = A-B;
		int c = A*B;
		if (a>=b&&a>=c){
			System.out.println(a);
		}
		else if (b>=a&&b>=c){
			System.out.println(b);
		}
		else if (c>=b&&c>=a){
			System.out.println(c);
		}
	}
}


Measured memory_bytes: 23764
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	vector<pair<int, int> > jobs(n);
	int a, b;
	for (int i = 0; i < n; ++i) {
		cin >> a >> b;
		jobs[i] = {b, a};
	}

	sort(jobs.begin(), jobs.end());

	int curr_time = 0;
	for (int i = 0; i < n; ++i) {
		if (curr_time + jobs[i].second > jobs[i].first) {
			cout << "No\n";
			return 0;
		}

		curr_time += jobs[i].second;
	}

	cout << "Yes\n";

	return 0;

}

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

int main() {
    int n;
    string s;
    cin >> n >> s;
    int r=0, w=0;
    rep(i,n) if(s[i] == 'R') ++r;
    int ans=max(r,w);
    rep(i,n) {
        if (s[i] == 'R') --r;
        else ++w;
        int now=max(r,w);
        ans=min(ans,now);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3696
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		String a = "A";
		String t = "T";
		String c = "C";
		String g = "G";
		List<String> list = Arrays.asList(a, t, c, g);

		Scanner sc = new Scanner(System.in);

		String input = sc.nextLine();
		int maxlength = 0;
		int lentgh = input.length();
		// 探索
		for (int i = 0; i < lentgh; i++) {
			for (int j = i; j < lentgh+1; j++) {
				String temp = input.substring(i, j);
				List<String> strings = new ArrayList<>();
				for (char cha : temp.toCharArray()) {
					strings.add(Character.toString(cha));
				}
				if (list.containsAll(strings) && strings.size() >= maxlength) {
					maxlength = strings.size();
				}
			}
		}
		System.out.println(maxlength);
	}
}


Measured memory_bytes: 22612
module Main(main) where

-- | solve
--
-- >>> solve 1 3
-- 3
--
-- >>> solve 0 1
-- 0
--
-- >>> solve 32 21
-- 58
--
solve :: Int -> Int -> Int
solve a p = (a * 3 + p) `div` 2


main :: IO ()
main = do
    [a, p] <- map read . words <$> getLine
    let res = solve a p
    putStrLn $ show res


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

int main() {
    int n;
    cin >> n;
    long long h[n];
    for (int i=0; i<n; ++i) cin >> h[i];
    sort(h,h+n,greater<int>());
    int y=0;
    long long ans = 0;
    for (int i=0; i<n; ++i) {
        ans += max(0LL,h[i]-y);
        if ((i%4>=2||i==0) && h[i]>=y) ans++;
        if (i%4==1) y++;
    }
    cout << ans <<endl;
}

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

int main(){
  int n=0;
  cin >> n;
  string s;
  cin >> s;
  int ret=0, max=0;
  for(int i=0;i<s.size(); i++){
    char c = s[i];
    int now = ret;
    if(c == 'I')
      now++;
      if(now > max){
        max = now;
      }
    if(c == 'D')
      now--;
    ret = now;
  }
  cout << max << endl;
  return 0;
}

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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(x) ll t; cin >> t; x.push_back(t);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<string> vvs;

const static ll MOD = 1e9 + 7;

int main(int argc, char *argv[]) {
    string s;
    cin >> s;
    if (s == "SUN") {
        MSG(7)

    } else if (s == "MON") {
        MSG(6)

    } else if (s == "TUE") {
        MSG(5)
        
    } else if (s == "WED") {
        MSG(4)

    } else if (s == "THU") {
        MSG(3)

    } else if (s == "FRI") {
        MSG(2)

    } else if (s == "SAT") {
        MSG(1)

    }
}


Measured memory_bytes: 256