akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,m=map(int,input().split())
    E=[[] for _ in range(n)]
    for _ in range(m):
        x,y,z=map(int,input().split())
        x-=1; y-=1
        E[x].append(y)
        E[y].append(x)

    visited=[0]*n
    def dfs(v)->bool:
        if(visited[v]):
            return False
        visited[v]=1
        for nv in E[v]:
            dfs(nv)
        return True

    ans=0
    for v in range(n):
        ans+=dfs(v)
    print(ans)
resolve()

Measured memory_bytes: 129016
a, b, h, m = map(int, input().split())
aka = 360 * (h / 12) + 30 * (m / 60)
ao = 360 * (m / 60)
seta = aka - ao
import math
seta = math.radians(seta)
ans = a ** 2 + b ** 2 - 2 * a * b * math.cos(seta)
print(math.sqrt(ans))

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

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

using namespace std;

int main(){
	int n; cin>>n;
	bool dp[10001]={true};
	rep(i,n){
		int a; cin>>a;
		for(int w=10000;w>=a;w--) dp[w]|=dp[w-a];
	}

	int ans=0;
	rep(w,10001) if(dp[w] && w%10!=0) ans=max(ans,w);
	cout<<ans<<endl;

	return 0;
}


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

int main() {
  int N=0;
  vector<int> szamok;
  int seged=0;
  cin>>N;
  for(int i=0;i<N;i++){
    cin >>seged;
    szamok.push_back(seged);
  }
  bool vane=true;
  seged=1;
  for(int i=1; i<N;i++){
     for(int j=0; j<i; j++){
       if(szamok[j]>szamok[i]){
         vane=false;
         break;
       }
     }
       if(vane){
         seged++;
       }
       vane=true;
  }
  
  cout<<seged;
	return 0;
}


Measured memory_bytes: 3580
#include <stdio.h>
#include <cstdio>
#include <string>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>



int main()
{

	int H, W, K;

	scanf("%d%d%d", &H, &W, &K);

	for (int a = 0; a <= H; ++a)
	{
		for (int b = 0; b <= W; ++b)
		{
			if ((H * W) - (a * W) - (b * H) + (a * b * 2) == K)
			{
				puts("Yes");
				return 0;
			}
		}
	}

	puts("No");

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include <cctype>
#include<math.h>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	b = b * 2 + 1;
	if (a%b == 0)cout << a / b << endl;
	else cout << a / b + 1 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int x,y;
	scanf("%d %d",&x,&y);
	if(x>=13)
	{
		printf("%d",y);
	}
	if(x<13&&x>5)
	{
		printf("%d\n",y/2);
	}
	if(x<=5)
	{
		printf("%d\n",0);
	}
	return 0;
}

Measured memory_bytes: 128
let readCharArray () = stdin.ReadLine().ToCharArray()

let rec solve min query target =
    if (target |> List.length) < (query |> List.length) then
        min
    else
        target
        |> List.take (query |> List.length)
        |> List.zip query
        |> List.filter (fun (a, b) -> a <> b)
        |> List.length
        |> fun x -> if min <= x then min else x
        |> fun x -> solve x query (target |> List.tail)

let target = readCharArray () |> Array.toList

readCharArray ()
|> Array.toList
|> fun query -> solve (query |> List.length) query target
|> printfn "%d"


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

void solve() {
	ios_base :: sync_with_stdio(false);
	cin.tie(NULL);

	int n; cin >> n;
	vector<vector<int>> cnt(n, vector<int>(26, 0));
	for(int i = 0; i < n; ++i) {
		string s; cin >> s;
		
		for(int j = 0; j < (int) s.size(); ++j) {
			cnt[i][s[j] - 'a']++;
		}
	}
	vector<int> ans(26, 0);
	for(int i = 0; i < 26; ++i) {
		ans[i] = cnt[0][i];
		for(int j = 1; j < n; ++j) 
			ans[i] = min(ans[i], cnt[j][i]);
	}
	string res = "";
	for(int i = 0; i < 26; ++i) 
		for(int j = 1; j <= ans[i]; ++j)
			res += (char) (i + 'a');
	cout << res << '\n';
}

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

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

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

  ll a=2,b=1;
  int n;cin>>n;
  ll t=0;
  if(n==1){
    cout<<(b)<<endl;
  } else {
    for(int i=2;i<=n;i++){
      t=a+b;
      a=b;
      b=t;
    }
    cout<<(t)<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N ;
    cin >> N ;
    
    ld ans = 0.0;
    rep(i, N){
        if(i%2 == 0) ans += 1.0;
    }

    cout << fixed << setprecision(16) << (ld)ans / (ld)N  << endl;


    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
lint H, W, MOD = 1e9+7;

signed main(){
  lint H, W; cin >> H >> W;
  vector<vector<lint> > dp(1010, vector<lint> (1010, 0));
  vector<vector<char> > field(H, vector<char> (W));
  for(lint i = 0; i < H; i++){
    for(lint j = 0; j <W; j++) cin >> field[i][j];
  }
  dp[0][0] = 1;
  for(lint i = 0; i < H; i++){
    for(lint j = 0; j < W; j++){
      if(i + 1 < H && field[i + 1][j] == '.') {
        dp[i + 1][j] += dp[i][j];
        dp[i + 1][j] %= MOD;
      }
      if(j + 1 < W && field[i][j + 1] == '.'){
        dp[i][j + 1] += dp[i][j];
        dp[i][j + 1] %= MOD;
      }
    }
  }
  cout << dp[H - 1][W - 1] << endl;
}

Measured memory_bytes: 9216
n=input()
nn=len(n)
if nn==1:
    print(n)
    exit()
flg=True
for i in range(1,nn):
    if n[i]!="9":
        flg=False
ans=0
if flg:
    for i in range(nn):
        ans+=int(n[i])
    print(ans)
    exit()
if flg==False:
    if n[0]!="1":
        print(int(n[0])-1+9*(nn-1))
    if n[0]=="1":
        print(9*(nn-1))

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

using namespace std;

using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, x, y;
  cin >> n >> x >> y;
  x--, y--;
  vector<int> ans(n, 0);
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      int d = min(j - i, abs(x - i) + 1 + abs(y - j));
      ans[d]++;
    }
  }
  for (int i = 1; i < n; i++) {
    cout << ans[i] << '\n';
  }
  return 0;
}


Measured memory_bytes: 3672
N = int(input())
H = list(map(int,input().split()))
var = 0
for k in range(N):
  if k == N-1:
    aaa = 2  
  elif k == 0:
    H[k] = H[k] - 1
  elif H[k+1] - H[k] >= -1 and  H[k] - H[k-1] > 0:
    H[k] = H[k] - 1
  elif H[k+1] - H[k] >= 0:
    aaa = 4
  else:
    var = 1
    break
if var == 0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 14396
n = gets.to_i
arr = gets.split(' ').map(&:to_i)
answer = arr[n-1]

dp = n.times.map { [0]*21 }
dp[0][arr[0]] = 1
1.upto(n-2) do |i|
  0.upto(20) do |j|
    next if dp[i-1][j] <= 0
    cp = j + arr[i]
    cm = j - arr[i]

    dp[i][cp] += dp[i-1][j] if cp <= 20
    dp[i][cm] += dp[i-1][j] if cm >= 0
  end
end

puts dp[n-2][answer]

Measured memory_bytes: 6132
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 200005;
int n;
int main()
{
    ios::sync_with_stdio(false);
    cout.tie(nullptr);
    cin.tie(nullptr);
    cin >> n;
    ll rez = 0;
    for(int a=1;a<=n;a++){
//        if(n % a)continue;
        rez += (ll)(n - 1) / a;
    }
    cout << rez << endl;
    return 0;
}


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

int main() {
	string t;
	cin >> t;
	char s[100001];
	int n = 0;
	while (t[n] != '\0') {
		n++;
	}
	for (int i = 0; i < n; i++) {
		s[i] = t[i];
	}
	char sample[100001];
	sample[0] = '0';

	for (int i = 1; i < n; i++) {
		if (sample[i - 1] == '0') sample[i] = '1';
		else sample[i] = '0';
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] != sample[i]) ans++;
	}
	int ans2;
	ans2 = n - ans;
	if (ans < ans2) cout << ans << endl;
	else cout << ans2 << endl;

	return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
      Scanner scanner = new Scanner(System.in);
      int a = scanner.nextInt();
      int b = scanner.nextInt();
      scanner.close();
      if (a < 1 || a > 9 || b < 1 || b > 9) {
          System.out.print("-1");
          return;
      }
      System.out.printf("%d", a * b);
  }
}


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

typedef long long ll;
typedef pair<int, int> pi;

int main() {
    //freopen("in.txt", "r",stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, m;
    cin>>n>>m;
    multiset<pi, greater<> > s;

    int a;
    for (int i=0;i<n;++i){
        cin>>a;
        s.insert(make_pair(a, 1));
    }

    int b, c;
    while (m--){
        cin>>b>>c;
        s.insert(make_pair(c, b));
    }

    int cnt = 0;
    ll sum = 0;
    for (auto e : s){
        if (cnt == n) break;
        if (cnt + e.second <=n){
            sum += ((ll)e.second)*((ll)e.first);
            cnt += e.second;
        }
        else {
            int nn = n-cnt;
            sum += ((ll)nn)*(ll)(e.first);
            cnt = n;
        }
    }  
    cout<<sum<<endl;

    return 0;
}

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

#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007 
#define pb push_back
#define mp make_pair
#define MP ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define IG cin.ignore(numeric_limits<streamsize>::max(),'\n');
#define ll long long int
#define N 1378
#define maxn 1000003
#define FP ff.open("output.txt")
#define FR ff.open("input.txt")
#define valid(a,b) if(a>=1 && a<row-1 && b>=1 && b<col-1)
fstream ff;

ll a, q, b, c, d, k, h, e, f, t, m, n, i, j, x, y, count, tcase = 0, l, r;

string s1, s2, s;

int main() {
	cin>>n;
	ll sum = 0;
	unsigned ll v[n];
	for(int i = 0;i<n;i++){
		cin>>v[i];
		sum+=v[i];
	}
	unsigned ll ans = 0,sum2=0;
	for(int i = 0;i<n;i++){
		sum2+=v[i];
		unsigned ll x = ((sum-sum2)%mod * v[i] %mod)%mod;
		ans = (ans + x)%mod;
	}
	cout<<(ans)<<endl;
	return 0;
}


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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
vector<int>edge[1000];
vector<int>edge2[1000];
bool e[1000][1000]={};
int visited[1000]={};
int n,m;
bool flag=true;
int bma=0,wma=0;
void dfs(int now,int color){
  if(visited[now]==-color){
    flag=false;
    return;
  }
  if(visited[now]==color){
    return;
  }
  visited[now]=color;
  if(color<0)bma++;
  else wma++;
  for(int i=0;i<edge2[now].size();i++){
    dfs(edge2[now][i],-color);
  }
  return;
}
int main(){
  cin>>n>>m;
  for(int i=0;i<m;i++){
    int a,b;cin>>a>>b;
    edge[--a].pb(--b);
    edge[b].pb(a);
    e[a][b]=true;
    e[b][a]=true;
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if((i==j)||(e[i][j]))continue;
      edge2[i].pb(j);
      //cout<<i<<" "<<j<<endl;
    }
  }
  vector<pair<int,int> >vpii;
  for(int i=0;i<n;i++){
    if(visited[i]==0){
      // cout<<i<<endl;
      dfs(i,1);
      vpii.pb(mp(bma,wma));
      bma=0;
      wma=0;
    }
  }
  //cout<<vpii.size()<<endl;
  if(flag==false){
    cout<<-1<<endl;
  }else{
    bool dp[2][n+700];
    for(int i=0;i<2;i++)
      for(int j=0;j<n+700;j++)
	dp[i][j]=false;
    dp[0][0]=true;
    for(int i=1;i<=vpii.size();i++){
      for(int j=0;j<=n;j++){
	if(dp[(i+1)%2][j]){
	  //  cout<<i<<" "<<j<<endl;
	  dp[i%2][j+vpii[i-1].F]=true;
	  dp[i%2][j+vpii[i-1].S]=true;
	}
	dp[(i+1)%2][j]=false;
      }
    }
    int ans=INF;
    for(int i=0;i<=n;i++){
      if(dp[vpii.size()%2][i]){
	ans=min(ans,((i-1)*i/2)+((n-i)*(n-i-1))/2);
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 4096
from bisect import bisect_left, bisect_right

def LIS(arr):  #bisect.bisect_left
    n = len(arr)
    lis = [arr[0]]
    for a in arr:
        if a > lis[-1]:
            lis.append(a)
        else:
            lis[bisect_left(lis, a)] = a
    return len(lis)

import sys
input = sys.stdin.readline

N = int(input())

A = []
for i in range(N):
    A.append((-int(input()), i))

print(LIS(A))


Measured memory_bytes: 85372
// https://atcoder.jp/contests/abc171/tasks/abc171_a
#include<bits/stdc++.h>
using namespace std;

int main(int argc, char* argv[]) {
	char c;
	cin >> c;
	if (c >= 'a' && c <= 'z') {
		cout << "a" << endl;
	} else if (c >= 'A' && c <= 'Z') {
		cout << "A" << endl;
	}
	return 0;
}

Measured memory_bytes: 3616
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
c = 0
for i in range(N-1):
    if A[i] == A[i+1] -1:
        c += C[A[i]-1]
for i in range(N):
  c += B[i]
print(c)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string yesno(bool ans){
  return (ans?"Yes":"No");
}
bool isPalindrome(string s){
  bool res=true;
  int n=s.size();
  rep(i,n/2){
    if(s[i]!=s[n-1-i]){
      res=false;
      break;
    }
  }
  return res;
}
int main() {
  string s;cin>>s;
  bool ans=false;
  int n=s.size();
  if(isPalindrome(s)){
    if(isPalindrome(s.substr(0,(n-1)/2))){
      if(isPalindrome(s.substr((n+3)/2-1))){
        ans=true;
      }
    }
  }

  cout<<yesno(ans)<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _  << ' ' <<
#define squ(x)  ((x) * (x))
#define VAR_NAME(var)  cout << #var << " : ";
#define debug(var)  VAR_NAME(var); view(var);
template <class T>
using V = vector<T>;
template <class T>
using VV = vector<vector<T>>;
template <class T>
using VVV = vector<vector<vector<T>>>;

int main(){
  int i, j;
  int N, K;
//  cin >> N >> K;
  int a, b;
  cin >> a >> b;
  cout << (13<=a? b : (5<a? b/2 : 0)) << endl;
  return 0;
}


Measured memory_bytes: 384
k, = (int(x) for x in input().split())
 
n = 3
c = {} 
t = 0
for x in range(k, 0, -1):
    c[x] = (k // x) ** n
    c[x] = c[x] - sum(c[x * y] for y in range(2, k // x + 1))
    s = c[x] * x
    t += s
    # t = t % 1000000007
 
print(t)

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


using namespace std;
//using namespace __gnu_cxx;

const int MAXN = (int)1e3 + 5;
const int MAXM = (int)1e4 + 5;


int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(10), cout << fixed;

    int n, d, a;
    cin >> n >> d >> a;
    vector<pair<int, long long>> arr(n);
    for (int i = 0; i < n; ++i) {
        cin >> arr[i].first >> arr[i].second;
    }
    sort(arr.begin(), arr.end());
    set<pair<long long, long long>> st;
    long long neg = 0;
    long long ans = 0;
    for (int i = 0; i < n; ++i) {
        int pos = arr[i].first;
        while (!st.empty() && (*st.begin()).first <= pos) {
            neg -= (*st.begin()).second;
            st.erase(st.begin());
        }
        arr[i].second -= neg;
        if (arr[i].second > 0) {
            ans += (arr[i].second + a - 1) / a;
            long long x = (arr[i].second + a - 1) / a * a;
            neg += x;
            st.insert({pos + 2LL*d + 1, x});
        }
//        cout << i << endl;
    }

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

Measured memory_bytes: 12636
#include<iostream>
using namespace std ;
int main()
{
	int n=0 , x=0 , a=0 ;
	while(true)
	{
		cin >> n >> x ;
		if(n==0&&x==0) break  ;
		for(int i=1;i<=n;i++)
		{
			for(int ia=i;ia<=n;ia++)
			{
				for(int ib=ia;ib<=n;ib++)
				{
					if(i!=ia&&i!=ib&&ia!=ib)
					{
						if(i+ia+ib==x)
						{
							a++ ;
						}
					}
				}
			}
		}
		cout << a << endl ;
		a=0 ;
	}
	return 0 ;
}



Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<algorithm> 
#include<functional> 
#include<cassert>
#include<numeric> // std::accumulate(vec.begin(),vec.end(),0) sum of element
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<map>
#include<set>


using namespace std;


typedef long long ll;
typedef std::pair<int, int> P;
typedef vector<int> vi;


#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(c) c.begin(),c.end()
#define show(x) cout << #x << " = " << x << endl

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



#define DEBUG


// void print_vector(const std::vector<int> &t);
// void unique_vector(std:: vector<int> &t);

template <class X>
void print_vector(const std::vector<X> &t);
template <class X>
void unique_vector(std:: vector<X> &t);


int n, m;

int main(){

  int n;
  vi ans;
  while(true){
    cin >> n;
    if(n == 0) break;
    vi sc(n);
    for(auto &i : sc) cin >> i;
    sort(sc.begin(), sc.end());
    sc.erase(sc.begin());
    sc.erase(sc.end()-1);
    int t = accumulate(sc.begin(), sc.end(), 0) / (n-2);
    ans.pb(t);
  }
  for(auto &i : ans) cout << i << endl;
}

template <class X>
void unique_vector(std::vector<X> &t)
{
  std::sort(t.begin(), t.end());
  t.erase( std::unique(t.begin(), t.end()), t.end() );
}

template <class X>
void print_vector(const std::vector<X> &t){
  for(auto itr=t.begin(); itr != t.end(); itr++){
    std::cout << *itr;
    if(itr != t.end()-1) std::cout << ' ';
  }
  std::cout << std::endl;
}

Measured memory_bytes: 3048
#include<iostream>
#include<vector>
#include<algorithm>
#define pb push_back
#define LL long long
using namespace std ;

int n ;
vector<LL> a ;

int main(){
	
	cin >> n ;
	a.pb(0) ;
	
	for( int i=0 ; i<n ; i++ ){
		int b ;
		cin >> b ;
		a.pb(b) ;
	}
	for( int i=1 ; i<=n ; i++ ) a.pb( a[i] ) ;
	for( int i=1 ; i<a.size() ; i++ ) a[i] += a[i-1] ;
	
	LL X = a[n]/3 ;
	LL Y = 1 ;
	
	vector<LL>::iterator IT = a.begin()+1 ;
	
	for( int i=1; i<=n ; i++ , IT++ ){
		LL x = X , y = Y ;
		LL p ;
		while( x-y > 1 ){
			p = (x+y)/2;
			vector<LL>::iterator it1 = lower_bound( IT , IT+n-1 , *(IT-1) + p ) ;
			vector<LL>::iterator it2 = lower_bound( it1+1 , IT+n-1 , *it1 + p ) ;
			vector<LL>::iterator it3 = lower_bound( it2+1 , IT+n-1 , *it2 + p ) ;
			
			if( *it3 <= *(IT+n-1) && p <= *it3 - *it2 ) y = p ;
			else x = p ;
		}
		Y = max( Y , y ) ;
	}
	
	cout << Y << endl ;
	
return 0 ;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int l, r, d, dd;
  cin >> l >> r >> d;
  int ans = 0;
  for(int i = l; i <= r; i++) {
    if(i%d == 0) {
      ans++;
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <cstring>
#include <string.h>
#include <sstream>
#include <iomanip>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <tuple>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using vec = vector<T>;
template<typename T> using prior = priority_queue<T>;;

const ll MOD = 1e9+7;
const ll SPMOD = 998244353;
const double PI  = 3.14159265358;
const double EPS = 1e-8;
 
#define INT_MX 2147483647
#define INF ((int)1e9)
#define LLINF ((ll)1e18)
#define F first
#define S second
#define MP(x,y) make_pair(x,y)
#define siz(v) ((int)v.size())
#define rs(n) resize(n)
#define ALL(v) v.begin(),v.end()
#define reset(v) memset((v),0,sizeof(v))
#define Unique(v) v.rs(unique(ALL(v))-v.begin())
#define EB emplace_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define __ <<' '<<
#define kiyohime ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

// template
ll POW();
int gcd(int a, int b);
// end of template

#define N 100010

void solve(){
    int n, m;
    
    cin >> n >> m;
    cout << n*(n-1)/2 + m*(m-1)/2 << '\n';
}

int main(){
    kiyohime
    int T = 1;
    
    while(T--){
        solve();
    }
}


// templates

ll POW(ll a, ll b, ll m = MOD){
    ll res = 1;
    while(b){
        if(b&1) res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

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



/*
 
 10 20
 
 1 0 1 1 1 1 1 1 0 0
 1 1 0 0 0 0 1 1 0 0
 0 1 1 1
 
 
 */


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

using namespace std;

int v[100005];
int n;

int main(){

	scanf("%d", &n);

	for(int i = 0; i < n; i++)
		scanf("%d", v+i);

	int ans = 1;

	int inc = 1, dec = 1;

	for(int i = 1; i < n; i++){
		if(v[i] > v[i-1]) dec = 0;
		if(v[i] < v[i-1]) inc = 0;
		if(!dec && !inc){
			ans++;
			inc = dec = 1;
		}
	}

	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 640
package main

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

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func main() {
	//sc.Split(bufio.ScanWords)
	S := readLine()

	fmt.Printf("%d\n", AGC040A(S))
}

// AGC040A ...
func AGC040A(S string) int {
	v := make([]int, len(S)+1)

	for i := 0; i < len(S); i++ {
		if S[i] == '<' {
			v[i+1] = v[i] + 1
		}
	}

	for i := len(S) - 1; i >= 0; i-- {
		if S[i] == '>' {
			v[i] = int(math.Max(float64(v[i]), float64(v[i+1]+1)))
		}
	}

	res := 0
	for i := 0; i < len(S)+1; i++ {
		res += v[i]
	}

	return res
}


Measured memory_bytes: 7412
s = input()


def main():
    for i, c in enumerate(s):
        if i % 2 == 0:
            if c in {'R', 'U', 'D'}:
                pass
            else:
                return False
        if i % 2 == 1:
            if c in {'L', 'U', 'D'}:
                pass
            else:
                return False
    return True


if main():
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<cmath>

using namespace std;

template<class T>
T gcd(T x, T y) {
	return y ? gcd(y, x % y) : x;
}

int main() {
	int N;
	cin >> N;
	vector<long long> y(N);
	int ans = 0;

	for (int i = 0; i < N; ++i) {
		cin >> y[i];
		ans += y[i] - 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue> //priority_queue
#include <map>
#include <set> //multiset set<int,greater<int>>大到小
#include <vector>// ::iterator it;
#include <stack>
#include <cmath> // auto &Name : STLName  Name.
#include <utility>
#include <sstream>
#include <string>
#define mod 1000000007
#define mod9 998244353
typedef unsigned long long ull;
typedef long long ll;
typedef double db;
typedef long double ld;
const db eps=1e-10;
const int INF = 0x3f3f3f3f;
const ll inf=0x3f3f3f3f3f3f3f3f;
const int N=1e5+5;
using namespace std;

int t,n,m,k;

int main(){
    scanf("%d%d%d",&t,&n,&m);
    printf("%d %d %d\n",m,t,n);
    return 0;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

using i64=int64_t;

bool dfs(int x,int i,int s,int n){
    if(i==n+1) return s==x;
    rep(j,-1,2) if(dfs(x,i+1,s+i*j,n)) return true;
    return false;
}

void solve(){
    i64 x;
    cin >> x;
    for(i64 i=0;; ++i){
        if(i*(i+1)/2>=x){
            cout << i << endl;
            return;
        }
    }
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
int main()
{
    string s,t;
    cin>>s>>t;
    int n=s.length();
    int ans=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]!=t[i]) ans++;
    }
    cout<<ans<<endl;


}

Measured memory_bytes: 3852
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
typedef pair<ll,ll> ipair;
#define F first
#define S second

int main() {
	ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);
    
    
	ll n,i,j,p,k,m,ans=0,a,b,c;
    cin>>a>>b>>c;
    
    k =a+b+c;
    p =max(max(a,b),c);
    if((3*p)%2==k%2)
    {
        cout<<(3*p-k)/2<<endl;
    }
    else
    {
        cout<<(3*(p+1) - k)/2<<endl;
    }
    
	return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <map>
#include <tuple>
#include <stdlib.h>
#include <math.h>
#include <iomanip>
using namespace std;
#define _GLIBCXX_DEBUG

int main(void){

    double A, B ,H, M;


    cin >> A >> B >> H >>M;

    double kakudo_choushin = M * 6 * M_PI / 180;
    double kakudo_tannshin = (H * 60 + M) * 360 / (12 * 60) * M_PI / 180;

    double kakudo;

    if(kakudo_choushin >= kakudo_tannshin){
        kakudo = kakudo_choushin - kakudo_tannshin;
    }

    else{
        kakudo = kakudo_tannshin -kakudo_choushin;
    }


    double ans;

    ans = A * A + B * B - 2 * A * B * cos(kakudo);
    
    ans = sqrt(ans);

    cout << fixed << setprecision(15) << ans << endl;



}

Measured memory_bytes: 4212
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;


inline int64 _5(int64 x) {
    return x*x*x*x*x;
}


int main() {
    int64 x;
    cin >> x;

    int64 a = -118;
    int64 b = -119;
    for (; a<=119; a++) {
        int64 a5 = _5(a);
        b = -119;
        int64 b5 = 0;
        for (; b<=118; b++) {
            b5 = _5(b);
            if (a5 - b5 == x) break;
        }
        if (a5 - b5 == x) break;
    }

    cout << a << " " << b << endl;
}

Measured memory_bytes: 3188
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>


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

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)









int main(){
    ll a, b, t;
    cin >> a >> b >> t;
    cout << t / a * b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long int dp[110][100010];
int main() {
    long long int n,weight,v[110],w[110],i,j,l;
    cin>>n>>weight;
    w[0]=v[0]=0;
    for(i=1;i<n+1;i++){
        cin>>w[i]>>v[i];
    }
    for(i=0;i<n+1;i++) dp[i][0]=0;
    for(i=0;i<weight+1;i++) dp[0][i]=0;
    for(i=1;i<n+1;i++){
        for(j=1;j<weight+1;j++){
            if(j<w[i]) dp[i][j]=dp[i-1][j];
            else dp[i][j]=max(dp[i-1][j],v[i]+dp[i-1][j-w[i]]);
        }
    }
    cout<<dp[n][weight];
}

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

int main(){
  int d;
  while(cin >> d){
    int ans = 0;
    int cou=1;
    while(d*cou <= 600-d){
      ans += (d*cou)*(d*cou)*d;
      cou++;
    }
    cout << ans << endl;
  }
}

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

const int INF = 1e9;

int main() {
  int N;
  cin >> N;
  int ans = INF;
  for (int n = 0; n <= N; ++n) {
    int A = n;
    int ans1 = 0;
    for (int i = 7; i >= 0; --i) {
      ans1 += A / (int)pow(6, i);
      A %= (int)pow(6, i);
    }
    int B = N - n;
    int ans2 = 0;
    for (int i = 6; i >= 0; --i) {
      ans2 += B / (int)pow(9, i);
      B %= (int)pow(9, i);
    }
    ans = min(ans, ans1 + ans2);
  }
  cout << ans << endl;
  return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
#define pb push_back
 const ll mod = 1000000007;

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

	cout << min(A * N, B) << endl;

	return 0;
 }

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

// N % m >= ceiling(sqrt(N))のとき
// (商)>(剰余)より m > ceiling(sqrt(N)) >= sqrt(N)
// このとき floor(N/m) < floor(sqrt(N))
// 以上より探索範囲は N % m < ceiling(sqrt(N))
int main(){
  int64_t N;
  cin >> N;

  int64_t ans= 0;
  int64_t rem= 1;
  while(rem* rem < N){
    if((N- rem)% rem==0){
      int64_t div= (N- rem)/ rem;
      if(N/div==rem){
        ans+= div;
      }
    }

    rem++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 3488
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
vi d1 = {1, 0, -1, 0}, d2 = {0, 1, 0, -1};
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}

int main() {
  ll n, k;
  cin >> n >> k;
  priority_queue<ll> h;
  for (ll i = 0; i < n; i++) {
    ll x;
    cin >> x;
    h.push(x);
  }
  for (ll i = 0; i < k; i++) {
    h.pop();
    if (h.size() == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  ll sum = 0;
  while (h.size() > 0) {
    sum += h.top();
    h.pop();
  }
  cout << sum << endl;
}

Measured memory_bytes: 2420
#include<iostream>
int main(){
  int r,D,x[11];
  std::cin>>r>>D>>x[0];
  for(int i=1;i<11;i++){
    x[i]=r*x[i-1]-D;
  }
  for(int i=1;i<11;i++){
    std::cout<<x[i]<<std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
	// write your code here
        final int size=99999;
        int[] numList=new int[size];
        boolean[] isPrimeList=new boolean[size];
        boolean[] simu2017List=new boolean[size];
        int[] cumuList=new int[size];
        for(int i=0;i<size;i++){
            numList[i]=i+2;
            isPrimeList[i]=true;
            simu2017List[i]=false;
        }
        for(int i=0;i<size;i++){
            int oriNum=i+2;
            if(isPrimeList[i]==true){
                for(int j=i+oriNum;j<size;j=j+oriNum){
                    isPrimeList[j]=false;
                }
            }
        }
        for(int i=0;i<size;i++){
            int oriNum=i+2;
            if(oriNum%2==0) continue;
            int index=(oriNum+1)/2-2;
            if(isPrimeList[i]){
                if(isPrimeList[index]){
                    simu2017List[i]=true;
                }
            }
        }
        cumuList[0]=0;
        for(int i=1;i<size;i++){
            cumuList[i]=simu2017List[i]?cumuList[i-1]+1:cumuList[i-1];
        }
/*
        System.out.println("numList");
        Arrays.stream(numList).forEach((a)->{
                System.out.print(a+" ");
        });
        System.out.println();
        System.out.println("isPrimeList");
        for(int i=0;i<isPrimeList.length;i++){
            System.out.print(isPrimeList[i]+" ");
        }
        System.out.println();
        System.out.println("simu2017List");
        for(int i=0;i<simu2017List.length;i++){
            System.out.print(simu2017List[i]+" ");
        }
        System.out.println();
        System.out.println("cumuList");
        Arrays.stream(cumuList).forEach((a)->{
            System.out.print(a+" ");
        });
        System.out.println();
*/

        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();
        for(int i=0;i<n;i++){
            int l=scanner.nextInt();
            int r=scanner.nextInt();
            if(simu2017List[l==1?0:l-2]){
                System.out.println(cumuList[r-2]-cumuList[l==1?0:l-2]+1);
            }else{
                System.out.println(cumuList[r-2]-cumuList[l==1?0:l-2]);

            }
        }

    }
}


Measured memory_bytes: 65396
use proconio::{input, fastout};
use std::process::exit;
#[fastout]
fn main() {
  input!{
    n:i64,
    mut a:[i128;n]
  }
  let mut ans : i128 = 1;
  a.sort();
  for a in a{
    ans *= a;  
    if ans > 10_i128.pow(18){
        ans = -1;
        break;
    }
  }
  println!("{}",ans);
}


Measured memory_bytes: 6172
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

vector<int> r[200001];
int total[200001];

int main()
{
	int N;
	cin >> N;
	vector<int> a(N);
	for (auto i = 0; i < N; ++i)
	{
		cin >> a[i];
	}

	for (auto i = 1; i < N; ++i)
	{
		for (auto j = i + i; j <= N; j += i)
		{
			r[j].push_back(i);
		}
	}

	vector<int> result;
	for (auto i = N; i > 0; --i)
	{
		if (a[i - 1] == 0)
		{
			if (total[i] % 2 == 0)
			{
				continue;
			}
		}
		else if (total[i] % 2 == 1)
		{
			continue;
		}

		result.push_back(i);
		auto& list = r[i];
		for (auto j = 0; j < list.size(); ++j)
		{
			++total[list[j]];
		}
	}

	cout << result.size() << endl;
	for (auto i = 0; i < result.size(); ++i)
	{
		cout << result[i] << endl;
	}

	return 0;
}

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

int main(){
    string s;
    int alp[26]={0};

    while(cin >> s){
        for(int i = 0; i < s.length(); i++){
            if(s[i] >= 'A' && s[i] <= 'Z'){
                s[i] = s[i] + 32;
            }
        }
        for(int i = 0; i < s.length(); i++){
            for(int j = 0 ; j <26 ; j++){
                if(s[i] - 'a' == j ){
                    alp[j] += 1;
                }                
            }
        }
    }
    for(int i = 0 ; i < 26 ; i++){
        cout << (char)(i + 'a') << " : " << alp[i] << endl;
    } 
}



Measured memory_bytes: 3172
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    count_plug = 0
    count_available = 1
    if B==1:
        print(0)
        return
    while True:
        count_plug += 1
        count_available -= 1
        count_available += A
        if count_available >= B:
            break
    print(count_plug)
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {
    ll N;
    cin >> N;
    ll ans = N / 500;
    ll tmp = N % 500;
    ans = ans * 1000 + (tmp / 5) * 5;
    cout << ans << endl;
    return 0;
}


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

using namespace std;

/* * * *   * * *   	* * * */
typedef long long ll;
const int oo = 1e9;
const ll mod = 100000000;
typedef complex<ll> P;
#define X real()
#define Y imag()
/* * * *   * * *   	* * * */

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, q; cin>>n>>q;
	string  s; cin>>s;
	vector<int> a(n,0);
	for (int i=1; i<n; ++i){
		if (s[i] == 'C' && s[i-1] == 'A')a[i] = a[i-1] + 1;
		else a[i] = a[i-1];
	}
	while (q--){
		int l, r; cin>>l>>r;
		cout<<a[r-1] - a[l-1]<<"\n";
	}
	return 0;
}


Measured memory_bytes: 1488
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
  int w,n,a,b,ca=0;
  
  while(scanf("%d",&w) && w != 0){
    scanf("%d",&n);
    int dp[n+1][w+1];
    fill_n(*dp,(n+1)*(w+1),0);

    for(int i = 1;i <= n;i++){
      scanf("%d,%d",&a,&b);
	for(int j = 0;j <= w;j++){
	  if(j < b) dp[i][j] = dp[i-1][j];
	  else dp[i][j] = max(dp[i-1][j],dp[i-1][j-b]+a);
	}
      }
    
    ca++;
    printf("Case %d:\n",ca);
    printf("%d\n",dp[n][w]);
    for(int i = w-1;i >= 0;i--){
      if(dp[n][w] != dp[n][i]){
	printf("%d\n",i+1);
	break;
      }
    }
  }    
  
  return (0);
}

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

int main(void){

        int N;
        cin >> N;
        int A[N], B[N],C[N-1];
        int sum = 0, tmp = -1;
        for (int i = 0; i < N; i++){
            cin >> A[i];
        }
        for (int i = 0; i < N; i++){
            cin >> B[i];
        }
        for (int i = 0; i < N-1; i++){
            cin >> C[i];
        }
        
        for (int i = 0; i < N; i++){
            sum += B[i];
            if (tmp + 1 == A[i]){
                sum += C[tmp-1];
            }
            tmp = A[i];
            // cout << "sum is" << sum << endl;
        }   
        cout << sum << endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;
 
int main(){
    int D, G; vector<int> P(15), C(15);
 
    cin >> D >> G; G /= 100;
    rep1(i, D){
        cin >> P[i] >> C[i];
        C[i] /= 100;
    }
 
    //どの難易度を全問解くかについて全探索
    int ans = 1e8;
    rep(bits, 1<<D){
        vector<bool> solve(D);
        rep(i, D) solve[i+1] = bits & (1<<i); 
        
        int points = 0, problems = 0;
        rep1(i,D){
            if (solve[i]) {
                points += i*P[i] + C[i];
                problems += P[i];
            }
        }
 
        if(points >= G){ ans = min(ans, problems); continue; }
 
        // 残りを点数の高い方から順に解いていく
        for(int i = D; i>=1; i--){
            if(!solve[i]){
                if(G - points <= (P[i]-1)*i){
                    problems += (G - points + (i-1)) / i;
                    ans = min(ans, problems); break;
                } else {
                    points += i*(P[i]-1);
                    problems += P[i]-1;
                }
            }
        }
    }
 
    cout << ans << endl;
 
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	private static Scanner s;

	public static void main(String[] args) {
		s = new Scanner(System.in);
		
		int a = s.nextInt();
		int b = s.nextInt();
		int h = s.nextInt();
		
		int result = (a+b)*h/2;
		System.out.println(result);
	}	
}

Measured memory_bytes: 9808
def main():
    M = int(input())
    S = [list(input().split()) for i in range(M)]
    print("AC x " + str(S.count(["AC"])))
    print("WA x " + str(S.count(["WA"])))
    print("TLE x " + str(S.count(["TLE"])))
    print("RE x " + str(S.count(["RE"])))

if __name__ == '__main__':
    main()

Measured memory_bytes: 86108
N = int(input())
S = [input() for i in range(N)]
AC, WA, TLE, RE = (0, 0, 0, 0)

for i in range(N):
    if S[i] == 'AC':
        AC += 1
    elif S[i] == 'WA':
        WA += 1
    elif S[i] == 'TLE':
        TLE += 1
    elif S[i] == 'RE':
        RE += 1

print('AC x {0}'.format(AC))
print('WA x {0}'.format(WA))
print('TLE x {0}'.format(TLE))
print('RE x {0}'.format(RE))

Measured memory_bytes: 16144
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define cy cout << "Yes" << endl
#define cn cout << "No" << endl
typedef long long ll;

void Main()
{
	int n;
  	cin >> n;
  	vector<int> a(n);
  	rep(i,n) cin >> a[i];
  
  	// lmax[i] : a[0] から a[i] の max
  	// rmax[i] : a[i] から a[n-1] の max
  	vector<int> lmax(n), rmax(n);
	lmax[0] = a[0];
  	rmax[n-1] = a[n-1];
  	rep(i,n-1){
  		lmax[i+1] = max(lmax[i], a[i+1]);
      	rmax[n-i-2] = max(rmax[n-i-1], a[n-i-2]);
    }
  	
  	cout << rmax[1] << endl;
  	rep3(i,1,n-2){
  		cout << max(lmax[i-1], rmax[i+1]) << endl;
    }
  	cout << lmax[n-2] << endl;
  return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 3968
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#define mem(a) memset(a, 0, sizeof(a))
using namespace std;
const int MAXN = 200005;
int n, t;
int a[MAXN];
int main()
{
    while(~scanf("%d %d", &n, &t))
    {
        for(int i=1;i<=n;++i)
            scanf("%d", &a[i]);
        int T=0;
        for(int i=2;i<=n;++i)
        {
            if(a[i]-a[i-1]<=t)
            {
                T+=a[i]-a[i-1];
            }
            else
                T+=t;
        }
        printf("%d\n", T+t);
    }
    return 0;
}


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

using namespace std;
constexpr int64_t MOD = 1'000'000'007;

template< typename T >
T mod_pow(T x, T n) {
    T ret = 1;
    while(n > 0) {
        if(n & 1) (ret *= x) %= MOD;
        (x *= x) %= MOD;
        n >>= 1;
    }
    return ret;
}

int main(void) {
    int64_t N, C;
    cin >> N >> C;
    vector<int64_t> A(N), B(N);
    for(int i=0; i<N; i++) {
        cin >> A[i];
    }
    for(int i=0; i<N; i++) {
        cin >> B[i];
    }

    vector< vector<int64_t> > dp(N+1, vector<int64_t>(C+1));
    dp[0][0] = 1;
    for(int i=0; i<N; i++) {
        vector<int64_t> v(C+1);
        for(int64_t j=0; j<=C; j++) {
            for(int64_t x=A[i]; x<=B[i]; x++) {
                v[j] += mod_pow(x, j);
                v[j] %= MOD;
            }
        }
        for(int c=0; c<=C; c++) {
            for(int j=0; c+j<=C; j++) {
                dp[i+1][c+j] += dp[i][c] * v[j];
                dp[i+1][c+j] %= MOD;
            }
        }
    }


    cout << dp[N][C] << endl;
    return 0;
}


Measured memory_bytes: 4884
N = int(input())
H = []
for _ in range(N):
    H.append(list(map(int, input().split())))
dp = [[0, 0, 0] for _ in range(N)]
dp[0] = H[0]
for i,h in enumerate(H[1:], start=1):
    dp[i][0] = h[0]+max(dp[i-1][1], dp[i-1][2])
    dp[i][1] = h[1]+max(dp[i-1][0], dp[i-1][2])
    dp[i][2] = h[2]+max(dp[i-1][0], dp[i-1][1])
print(max(dp[-1]))

Measured memory_bytes: 48120
#include <stdio.h>
#include <stdlib.h>

void printMatrix(int s,int[s][s]);

int main(int argc, char** argv) {
    int size;
    scanf("%d", &size);
    int matrix[size][size];
    for(int i = 0; i < size; i++)
        for(int j = 0; j < size; j++)
            matrix[i][j] = 0;
    int loc, count, adjacent;
    for(int i = 0; i < size; i++){
        scanf("%d %d",&loc, &count);
        if(count > 0)
            for(int j = 0; j < count; j++){
                scanf("%d", &adjacent);
                matrix[loc-1][--adjacent] = 1;
            }
    }
    printMatrix(size,matrix);
    return (EXIT_SUCCESS);
}

void printMatrix(int size, int mat[size][size]){
    for(int i = 0; i < size; i++){
        for(int j = 0; j < size; j++){
            printf("%d", mat[i][j]);
            if(j != size-1)
                printf(" ");
        }
        printf("\n");
    }
}



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

int main(){
    
    int N;
    int A[100];
    
    cin >> N;
    for ( int i = 0; i < N; i++) cin >> A[i];
    
    int a, flag = 1, count = 0;
    while ( flag ){
        flag = 0;
        for ( int j = N-1; j > 0; j--){
            if ( A[j] < A[j-1] ){
                a = A[j];
                A[j] = A[j-1];
                A[j-1] = a;
                count++;
                flag = 1;
            }
        }
    }
    for ( int i = 0; i < N; i++){
        if ( i == N-1) {
            cout << A[i] << endl;
            break;
        }    
        cout << A[i] << " " ;
    }
    cout << count <<endl;
    
}



Measured memory_bytes: 3100