akhauriyash/Code-Regression huggingface dataset:
// https://atcoder.jp/contests/abc122/tasks/abc122_d

#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <regex>
#include <set>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

#define EPS (1e-7)
#define INF (1e9)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

// long gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// long lcm(long a, long b) { return a * b / gcd(a, b); }
regex re(".*(A.?GC|AG.?C|GAC|ACG)");
map<string, ll> mp;
// 文字列長、今までの文字列
ll rec(int n, string s) {
    bool result = regex_match(s, re);
    if (result) {
        return 0;
    }
    if (n == 0) {
        // cout << s << endl;
        return 1;
    }
    ll ret = 0;
    //末尾から3桁の文字列 + ":" + 残り文字数
    int pos = max(0, (int)s.length() - 3);
    string ends = s.substr(pos) + ":" + to_string(n);
    if (mp.count(ends) == 0) {
        ret = rec(n - 1, s + "A") + rec(n - 1, s + "G") + rec(n - 1, s + "C") +
              rec(n - 1, s + "T");
        mp[ends] = ret;
    } else {
        ret = mp[ends];
    }
    return ret % MOD;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;

    cout << rec(n, "") << endl;

    return 0;
}


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

using ll = long long;
const int INF = 1e9+7;

void solve()
{
	int a,b;cin >> a >> b;
	cout << a*b;
}

int main()
{
	int t=1;
	//int t;cin >> t;
	while(t--) solve();
}	


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

const double EPS = 1e-8;

int main(){
  int v[3],ans[3],ansn=0;
  bool f = false;
  fill(ans,ans+3,0);
  while(cin >> v[0] >> v[1] >> v[2]){
    if(f) continue;
    sort(v,v+3);
    if(v[2] >= v[1] + v[0]){
      cout << ansn;
      for(int i=0;i<3;i++) cout << ' ' << ans[i];
      cout << endl;
      f = true;
    } else {
      double w[3];
      for(int i=0;i<3;i++) w[i] = (double)v[i];
      double a = (w[0]*w[0] + w[1]*w[1] - w[2]*w[2]) / (2 * w[0] * w[1]);

      ansn++;
      if(a > EPS) ans[1]++;
      else if(a < -EPS) ans[2]++;
      else ans[0]++;
    }
  }
}

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

using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;


#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pf push_front
#define mp make_pair
#define pii pair<int,int>
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define SIZE 200010
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%d",&t)
#define p(t) printf("%d\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define print(x) for(auto el: x) cout<<el<<" ";cout<<endl
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<int>
#define pqsmall priority_queue<int,vector<int>,greater<int> >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define mitr map<int,int>:: iterator


#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

const int N=2e3+5;
int dp[N][N];
int arr[N];
int brr[N];
int n,m;

int32_t main()
{
    fast;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        cin>>arr[i];
    for(int i=1;i<=m;i++)
        cin>>brr[i];

    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(arr[i]==brr[j])
            {
                dp[i][j]=1+dp[i-1][j-1],dp[i][j]%=mod;
                dp[i][j]+=dp[i-1][j],dp[i][j]%=mod;
                dp[i][j]+=dp[i][j-1],dp[i][j]%=mod;
                dp[i][j]-=dp[i-1][j-1],dp[i][j]+=mod,dp[i][j]%=mod;
            }
            else
            {
                dp[i][j]=dp[i-1][j]+dp[i][j-1];dp[i][j]%=mod;
                dp[i][j]-=dp[i-1][j-1];
                dp[i][j]+=mod;
                dp[i][j]%=mod;
            }
        }
    }

    cout<<(dp[n][m]+1)%mod;
}

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

int main() {

	ll x; cin >> x;
	ll quo = x / 11;
	ll mod = x % 11;
	ll ans;
	ans += 2 * quo;
	if (1 <= mod && mod <= 6) ans++;
	else if (6 < mod) ans += 2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

int N, K;
vector<vector<int>> adj;
map<pair<int, int>, int> color;
vector<int> a, b;

void input() {
    cin >> N;
    K = 0;
    adj.resize(N); a.resize(N); b.resize(N);
    rep(i, N-1) {
        cin >> a[i] >> b[i]; --a[i]; --b[i];
        adj[a[i]].push_back(b[i]);
        adj[b[i]].push_back(a[i]);
    }
    rep(i, N) chmax(K, (int)adj[i].size());
}

void dfs(int now, int from) {
    int c = 1;
    for(auto to: adj[now]) {
        if (to == from) continue;
        if (c == color[make_pair(now, from)]) ++c;
        color[make_pair(now, to)] = color[make_pair(to, now)] = c++;
    }
    for(auto to: adj[now]) {
        if (to == from) continue;
        dfs(to, now);
    }
}

void solve() {
    dfs(0, -1);

    cout << K << endl;
    rep(i, N-1) cout << color[make_pair(a[i], b[i])] << endl;
}

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

    input();
    solve();
    
    return 0;
}




Measured memory_bytes: 20480
#include <iostream>
#include <cmath>
#include <array>
using namespace std;
int main(int argc, const char * argv[]) {
    int A, B, C, X;
    int cnt = 0;
    cin >> A >> B >> C >> X;
    
    for(int a = 0; a <= A; ++a){
        for(int b = 0; b <= B ; ++b){
            for(int c = 0; c <= C; ++c){
                int sum = 500 * a + 100 * b + 50 * c;
                if(sum == X){
                    cnt++;
                }
            }
        }
    }
    cout << cnt;
    return 0;
}

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

const int MAX=100;
const int INF=(1<<21);

int main(){

  int n,m;
  int a,b,cost,time;
  int p,q,r;
  int rail_cost[MAX][MAX];
  int rail_time[MAX][MAX];
  int k;
  while(1){
    cin>> n>> m;
    if(n==0 && m==0) break;
  
  for(int i=0;i<m;i++){
    for(int j=0;j<m;j++){
      rail_cost[i][j]=INF;
      rail_time[i][j]=INF;
    }
  }

  for(int i=0;i<n;i++){
    cin>> a>> b>> cost>> time; 
    rail_cost[a-1][b-1]=rail_cost[b-1][a-1]=cost;
    rail_time[a-1][b-1]=rail_time[b-1][a-1]=time;
  }

  for(int i=0;i<m;i++){
    for(int j=0;j<m;j++){
      for(int k=0;k<m;k++){
	rail_cost[j][k]=min(rail_cost[j][k],rail_cost[j][i]+rail_cost[i][k]);
	rail_time[j][k]=min(rail_time[j][k],rail_time[j][i]+rail_time[i][k]);
      }
    }
  }

  cin>> k;
  for(int i=0;i<k;i++){
    cin>> p>> q>> r;
    if(r==0){
      cout<< rail_cost[p-1][q-1]<< endl;
    }else{
      cout<< rail_time[p-1][q-1]<< endl;
    }
  }

  }
}

Measured memory_bytes: 1236
#include <iostream>
using namespace std;
int main(){
int H,W;
int x,a,b;
for (;;){
    cin >> H >> W;
    if (H == 0 && W == 0) break;

    for (b = 1; b <= H; b++){

        for (a = 1; a <= W; a++){

            x = a + b;
            
            if (x % 2 == 0){
                cout << "#"; 

            }
          
            if (x % 2 != 0){
                cout << ".";

            }
        }
        cout << endl;
    } 
    cout << endl;
}

    return 0;


}

Measured memory_bytes: 3108
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#pragma warning (disable: 4996)
using namespace std;

int main() {
	int x;
	cin >> x;
	cout << (1 ^ x) << endl;
	return 0;
}

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

class Program
{
    static void Main()
    {
        //Console.WriteLine(Solve());
        Solve();
        return;
    }

    public static string Solve()
    {
        int[] input = ReadInts();
        int N = input[0];
        int Q = input[1];
        string S = Read();
        int[] acCnt = new int[N];
        int cnt = 0;
        for(int i=1;i<N;i++)
        {
            if(S[i] == 'C')
            {
                if(S[i-1]=='A')
                {
                    cnt++;
                }
            }
            acCnt[i] = cnt;
        }

        for (int i=0;i<Q;i++)
        {
            input = ReadInts();
            int l = input[0];
            int r = input[1];
            Console.WriteLine(acCnt[r-1]-acCnt[l-1]);
        }
        int ans = 0;

        return ans.ToString();
    }

    private static string Read() { return Console.ReadLine(); }
    private static int ReadInt() { return int.Parse(Read()); }
    private static long ReadLong() { return long.Parse(Read()); }
    private static double ReadDouble() { return double.Parse(Read()); }
    private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
    private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
    private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
}


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

int main() {
  int n,m;
  while(cin >> n >> m) {
    int dp[n+2];
    dp[0]=dp[1]=1;
    for(int i=2; i<=n+1; i++) {
      dp[i]=(dp[i-1]+dp[i-2])%1001;
    }
    sort(dp,dp+n+2);
    int cnt=1;
    for(int i=3; i<=n+1; i++) {
      if(dp[i]-dp[i-1]>=m) cnt++;
    }
    cout << cnt << endl;
  }
  return 0;
}


Measured memory_bytes: 1184
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

import math

# 反転で同心円に帰着する

T = int(input())
query = [[int(x) for x in input().split()] for _ in range(T)]

def solve_2_eq(a,b,c):
    return (-b + (b*b-4*a*c)**.5) / (2*a)

def F(r,R,d):
    # 複比
    ratio = ((d+r+R)*(d-R-r)) / (4*r*R)
    
    R = solve_2_eq(1,-2-4*ratio, 1)
    # 内側の円が1, 外側の円が半径Rであるような同心円に帰着
    r = (R-1)/2
    theta = math.asin(r/(1+r))
    return int(math.pi // theta)

answer = []
for data in query:
    d = ((data[3]-data[0])**2 + (data[4]-data[1])**2) ** .5
    answer.append(str(F(data[2],data[5],d)))

print('\n'.join(answer))

Measured memory_bytes: 23752
N, M = map(int, input().split())
High = list(map(int, input().split()))
Road =[[]for i in range(N)]
ans = 0

for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if a in Road[b]:
        continue
    Road[a].append(b)
    Road[b].append(a)

for i in range(N):
    now = High[i]
    flag = True
    for j in Road[i]:
        if now <= High[j]:
            flag = False
            break
    if flag:
        ans += 1

print(ans)

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

#define ioso ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define kholo freopen("input.txt","r",stdin), freopen("output.txt","w",stdout);
#define laglo cerr << "Ti : " << clock() * 1.0 / CLOCKS_PER_SEC  << endl;
#define endl '\n';
#define ll long long
map<string,int> k;
int main() {
	ioso; //kholo;
	string a,b,gone;
	ll a1,b1;
	cin >> a >> b >> a1 >> b1 >> gone;
	k[a] = a1;
	k[b] = b1;
	k[gone]--;
	cout << k[a] << " " << k[b] << endl;
	//laglo;
}

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


typedef long long ll;

int N;
ll A[100010];


int main()
{
    cin >> N;
    int mnsnum = 0;
    ll absmin = 1e10;
    ll res = 0;
    for(int i = 0; i < N; i++)
    {
        ll tmp;
        cin >> tmp;
        if(tmp < 0) mnsnum++;
        absmin = min(absmin, (tmp < 0? -1 * tmp: tmp));
        res += tmp < 0 ? -1*tmp : tmp;
    }
    if(mnsnum % 2 == 1)
    {
        res -= 2 * absmin;
    }

    cout << res << endl;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
class Program
{
        static void Main(string[] args)
        {
                // スペース区切りの整数の入力
                string[] input = Console.ReadLine().Split(' ');
int N=int.Parse(input[0]);
            //Console.WriteLine(input[0]);

int L=int.Parse(input[1]);
            //Console.WriteLine(input[1]);
            var list = new List<string>();
                      for (int i = 0; i < N; ++i)	
            {	
                 string z=Console.ReadLine();
            //Console.WriteLine(z);
                        list.Add(z);
            }	
list.Sort();
          Console.WriteLine("{0}", string.Join("", list));
        }
}


Measured memory_bytes: 11360
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll mod = 1000000007;
ll INF = 1000000009;

/*
全探索？
aNまでの全ての数の最小公倍数で1ループするので、1からその数まで調べれば良い
→時間が厳しそう。
最小公倍数-1?
6+45+10+19+10=90なのでそれっぽい
*/

void solve(){
    int n;
    cin >> n;
    int a[n+10];
    ll ans = 0;
    rep(i,n){
        cin >> a[i];
        ans += a[i]-1;
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 256
from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import statistics # Pythonのみ
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    def main():

        N, K = map(int, input().split())
        s = input()
        S = [int(c) for c in s]
        runlen = []
        if S[0] != 1:
            runlen.append(0)
        flag = False
        if S[-1] != 1:
            flag = True
        gr = groupby(S)
        cnt = 0
        for key, group in gr:  # groupはイテレータ。list(group)でリスト化
            runlen.append(len(list(group)))
            cnt += 1
        if flag:
            runlen.append(0)
        if cnt == 1:
            return N

        runlen = [0] + runlen
        # 累積和を格納したリスト．A[l:r]の総和はB[r] - B[l]
        runlen = list(accumulate(runlen))

        ans = 0
        for i in range(0,len(runlen),2):
            r = K*2+i+1
            l = i
            if r >= len(runlen):
                r = len(runlen)-1
            ans = max(ans, runlen[r]-runlen[l])

        return ans
    print(main())


resolve()

Measured memory_bytes: 52444
# -*- coding: utf-8 -*-
from itertools import permutations, combinations
from fractions import gcd
from collections import Counter
from math import sqrt
import sys
input = sys.stdin.readline
def lcm(x, y):
    return (x*y//gcd(x, y))
def small_letters():
    return [chr(i) for i in range(97, 97+26)]
def capital_letters():
    return [chr(i) for i in range(65, 65+26)]
def continual_letters(list_x):
    """example"""
    """[2,2,2,2,4,4,5,5,5,8,8,8,8,8] => [4,2,3,5]"""
    i,j = 0,0
    result = []
    k = len(list_x) - 1
    while(True):
        A = list_x[i]
        while(True):
            print(j)
            if list_x[j] != A:
                break
            if j >= k:
                break
            j += 1
        result.append(j-i)
        if i >= k:
            break
        i = j
    result[-1] += 1
    return result


def main():
    """ここに書いてね"""
    H,A = map(int,input().split())
    print(-(-H//A))

if __name__ == '__main__':
    main()


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

int main(){
	int x;
	cin>>x;
	int mx=1;
	rep(i,sqrt(x)+1){
		if(i==0||i==1)continue;
		int num=1,count=0;
		while(num<=x){
			num*=i;
			count++;
		}
		if(count>1)mx=max(mx,num/i);
	}
	puts(mx);
}

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

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s[] = br.readLine().split(" ");
		int a = Integer.parseInt(s[0]);
		int b = Integer.parseInt(s[1]);
		String as= "" , bs = "";
		for(int i = 0 ; i < b ; i++) {
			as += s[0];
		}
		for(int i = 0 ; i < a ; i++) {
			bs += s[1];
		}
		if(as.compareTo(bs) > 0 ) {
			System.out.println(bs);
		}else {
			System.out.println(as);
		}
	}

}


Measured memory_bytes: 21204
#include <cstdio>
#include <cstring>
#include <cmath>
#define EPS 1e-9
int m,n;
double v[1000];
double s[2];

int check(){
	if(s[0]>s[1]+EPS)return 1;
	if(s[1]>s[0]+EPS)return 2;
	return 0;
}

int main(void){
	while(1){
		scanf("%d",&m);
		if(m==0)break;
		s[0]=s[1]=0.0;
		double rest=360.0;
		for(int i=0;i<m-1;i++){
			scanf("%lf",&v[i]);
			rest-=v[i];
			v[i]=v[i]/180.0*M_PI;
			s[0]+=sin(v[i]);
		}
		s[0]+=sin(rest/180.0*M_PI);
		scanf("%d",&n);
		rest=360.0;
		for(int i=0;i<n-1;i++){
			scanf("%lf",&v[i]);
			rest-=v[i];
			v[i]=v[i]/180.0*M_PI;
			s[1]+=sin(v[i]);
		}
		s[1]+=sin(rest/180.0*M_PI);
		printf("%d\n",check());
	}
	return 0;
}

Measured memory_bytes: 1096
#include<bits/stdc++.h>
#define ll long long int
#define db long double
#define ull unsigned long long int
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define all(a) a.begin(),a.end()
#define Nmax 1000005
#define INF 1000000000
#define MOD 1000000007
#define MAXN 1000005
 
using namespace std;

ll dp[3001][3001];
ll a[3001];
ll n;

ll recur(ll i,ll j)
{
	if(i>j) return 0;
	if(i==j) return a[i];
	if(dp[i][j]!=-INF) return dp[i][j];
	ll sum1=0,sum2=0;
	sum1=recur(i+1,j);
	sum2=recur(i,j-1);
	return dp[i][j]=max(a[i]-sum1,a[j]-sum2);

}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int tests=1;
    // cin>>tests;
    while(tests--)
    {	
    	ll i,j;
    	cin>>n;
    	rep(i,1,n) cin>>a[i];
    	rep(i,0,n)
    	{
    		rep(j,0,n)
    		dp[i][j]=-INF;
    	}
    	cout<<recur(1,n);
    }
    	return 0;
    
}

Measured memory_bytes: 74176
PQR = list(map(int, input().split()))

A = PQR[0] + PQR[1]
B = PQR[1] + PQR[2]
C = PQR[2] + PQR[0]

fly = []
fly.append(A)
fly.append(B)
fly.append(C)

print(min(fly))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl

String to integer:
stringstream dark(s);
int x = 0; dark >> x;
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


string s;

void solve()
{
    cin >> s;
    for (int i=0; i<s.size(); i++) {
        cout << "x";
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

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

int main(){
	int n,q,k;
	scanf("%d%d%d",&n,&k,&q);
	int* a = new int[q];

	int* score = new int[n];
	for(int i=0;i<n;i++){
		score[i]=k-q;
	}

	for(int i=0;i<q;i++){
		scanf("%d",&a[i]);
		score[a[i]-1] += 1;
	}

	for(int i=0;i<n;i++){
		if(score[i]>0){
			printf("Yes\n");
		}else{
			printf("No\n");
		}
	}

	return 0;
}

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

using namespace std;

typedef long long ll;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;
  n *= 3;
  vector<ll> a(n), b(n), c(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  ll sum = 0;
  priority_queue<ll> q;
  for (int i = 0; i < n; i++) {
    sum += a[i];
    q.push(-a[i]);
    if (q.size() > n / 3) {
      sum += q.top();
      q.pop();
    }
    b[i] = sum;
  }
  sum = 0;
  q = priority_queue<ll>();
  for (int i = n - 1; i >= 0; i--) {
    sum += a[i];
    q.push(a[i]);
    if (q.size() > n / 3) {
      sum -= q.top();
      q.pop();
    }
    c[i] = sum;
  }
  ll ans = -1e18;
  for (int i = n / 3 - 1; i < n / 3 * 2; i++) {
    ans = max(ans, b[i] - c[i + 1]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 9068
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;

const int N=1009;

char s[N];
int f[4];

int main()
{
	scanf("%s",s+1);
	int len=strlen(s+1);
	for(int i=0;i<=3;i++)f[i]=0;
	for(int i=1;i<=len;i++)
	{
		if(s[i]=='N')
			f[0]=1;
		else if(s[i]=='S')
			f[1]=1;
		else if(s[i]=='W')
			f[2]=1;
		else if(s[i]=='E')
			f[3]=1;
	}

	if((f[0]^f[1]) || (f[2]^f[3]))
		puts("No");
	else
		puts("Yes");

	return 0;
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()


def main():
    n = int(input())
    A = []
    for _ in range(n):
        A.append(int(input()))
    mae = -1
    ans = -1
    for AA in A:
        if AA > mae+1:
            print(-1)
            break
        elif AA == mae+1:
            ans += 1
        else:
            ans += AA
        mae = AA
    else:
        print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 17004
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 998244353LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef int_fast64_t ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
inline void fastio(){cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15);}
ll gcd(ll a,ll b){ll c=max(a,b);ll d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}

template<int N, typename T, T M>
struct ModFact {
    T fact[N+1];
    T ifact[N+1];
    constexpr ModFact() : fact(), ifact() {
        fact[0] = 1;
        for (int i=0; i<N; ++i)
            fact[i+1] = (fact[i]*(i+1))%M;
        ifact[N] = power(fact[N], M-2);
        for (int i=N-1; i >= 0; --i)
            ifact[i] = (ifact[i+1]*(i+1))%M;
    }
    constexpr T power(T a, T b) {
        T r = 1;
        while (b>0) {
            if((b&1)!=0) r = (r*a)%M;
            a = (a*a)%M;
            b >>= 1;
        }
        return r;
    }
    constexpr T comb(T n, T r) {
        if (n<r||n<0||r<0) return 0;
        return (((fact[n]*ifact[r])%M)*ifact[n-r])%M;
    }
};
 
ModFact<300000, ll, MOD> fact;

int main() {
    fastio();
    ll N, A, B, K, ans = 0;
	cin >> N >> A >> B >> K;
    ll g = gcd(A, B);
    if(K%g==0) {
        ll ca=B/g, cb=A/g;
        size_t i=0, j;
        while((K-A*i)%B && i<=N) i++;
        j = (K-A*i)/B;
        while(i <= N && j >= 0) {
            ans = (ans+fact.comb(N,i)*fact.comb(N,j))%MOD;
            i += ca; j -= cb;
        }
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n,t;
  cin >> n >> t;
  vector<int> v(n);
  int i;
  for(i=0;i<n;i++) cin >> v[i];
  long long cnt = 0;
  for(i=0;i<n-1;i++){
    if(v[i+1]-v[i]<=t) cnt+= v[i+1]-v[i];
    else cnt += t;
  }
  cnt += t;
  cout << cnt << "\n";
  return 0;
}


Measured memory_bytes: 4044
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int as,aend,bs,bend;
cin >> as >> aend >> bs >> bend;
// A:0-50 B: 40-80 etc
int ds;
if (bs-aend>0||as-bend>0)
{
  cout << 0 << endl;
  return 0;
}

else if(as < bs) //bが後から始まる時
{
 ds=bs;
}
else if(as >= bs)
{
  ds=as;
}
int dend;
if(aend<bend)
{dend=aend;}
else if(aend >= bend)
{dend=bend;}
cout << dend - ds << endl;

}

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

using namespace std;

void col(int n,int m,bool p[][605]) {
  int d=0;
  while (m%(1<<(2*(d+1)))==0) d++;
  d=(1<<d);
  int v=(m/(d*d))%4;
  if (v==0||v==3) return;
  if (v==1) {
  	for(int i=0;i<n;i++)
  	  for(int j=0;j<n;j++) p[i][j]=(((i/d)+(j/d))&1);
  }
  else {
  	for(int i=0;i<n;i++)
  	  for(int j=0;j<n;j++) p[i][j]=((i/d)&1);
  }
}

bool f[605][605],g[605][605];

int main() {
  int n,D1,D2;
  scanf("%d%d%d",&n,&D1,&D2);
  col(n<<1,D1,f);
  col(n<<1,D2,g);
  int sz[2][2]={0};
  for(int i=0;i<(n<<1);i++)
    for(int j=0;j<(n<<1);j++) sz[f[i][j]][g[i][j]]++;
  int id1=0,id2=0;
  for(int i=0;i<2;i++)
    for(int j=0;j<2;j++)
      if (sz[i][j]>sz[id1][id2]) {
      	id1=i;
      	id2=j;
	  }
  int cnt=0;
  for(int i=0;i<(n<<1);i++) {
    for(int j=0;j<(n<<1);j++)
      if (f[i][j]==id1&&g[i][j]==id2) {
      	printf("%d %d\n",i,j);
      	cnt++;
      	if (cnt>=n*n) break;
	  }
	if (cnt>=n*n) break;
  }
  return 0;
}



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

int main() 
{
    int H, W;           //Hight, Width

    while( cin >> H >> W )
    {
        if( H == 0 && W == 0 )
            break;
        for( int i = 0; i < H; i++ )
        {
            for( int j = 0; j < W; j++ )
                cout << '#';
            
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, string> P;

int N;
vector<string> S;
vector<P> nS;

int main(){
  cin >> N;

  string s;
  for(int i = 0; i < N; i++){ cin >> s; S.push_back(s); }
  sort(S.begin(), S.end());

  int i = 0;
  while(i < N){
    int j = 0;
    while(i + j < N && S[i] == S[i+j]) j++;
    nS.push_back(make_pair(j, S[i]));
    i += j;
  }

  sort(nS.begin(), nS.end());
  int len = nS.size();
  int m = nS[len-1].first;  //最大数
  for(i = 0; i < len; i++){
    if(nS[i].first != m) continue;
    cout << nS[i].second << endl;
  }
  return 0;
}

Measured memory_bytes: 18800
#include<bits/stdc++.h>
#define INF 2000000000
#define int long long int
#define MOD 1000000007
#define pb push_back
#define cin1(n) (cin >> n)
#define cin2(a,b) (cin >> a >> b)
#define cin3(a,b,c) (cin >> a >> b >> c)
#define cout(n) (cout << n << endl)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define fr first 
#define sc second 
#define EPS (1e-10)

using namespace std;

typedef vector<int> vi;
typedef vector< vector<int> > vvi;
typedef vector<pair<int,int>> vpii;
typedef vector<string> vs;
typedef vector<vector<string>> vss;
typedef pair<int,int> pii;

int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
int n,m;
int a,b;
int p,q;


void kuru(vi &d, char str) {
		if (str == 'N') {
			swap(d[0],d[4]);		
			swap(d[0],d[3]);		
			swap(d[0],d[1]);		
		}else if(str == 'W') {
			swap(d[0],d[5]);		
			swap(d[0],d[3]);		
			swap(d[0],d[2]);		
		}else if(str == 'S') {
			swap(d[0],d[1]);		
			swap(d[0],d[3]);		
			swap(d[0],d[4]);		
		}else if(str == 'E') {
			swap(d[0],d[2]);		
			swap(d[0],d[3]);		
			swap(d[0],d[5]);		
		}else if(str == 'R') {
			swap(d[1],d[5]);		
			swap(d[1],d[4]);		
			swap(d[1],d[2]);		
		}else if(str == 'L') {
			swap(d[1],d[2]);		
			swap(d[1],d[4]);		
			swap(d[1],d[5]);		
		}
		return ;
	
}
signed main() {

	while(1) {
	vi dice = {1,2,3,6,5,4};
	cin1(n);
	if (n == 0) break;
	int ans = 1;
	rep(i,0,n) {
		string str; cin1(str);
		kuru(dice,str[0]);
		ans += dice[0];
	}
	cout(ans);
	}
	return 0;
}

Measured memory_bytes: 3024
import sys
import math
import bisect

def main():
    a, b = map(int, input().split())
    ans = 0
    for i in range(a, b + 1):
        s = str(i)
        if s == s[::-1]:
            ans += 1
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 41580
#ifdef BUILT_LOCAL

#include "niklib.h"

#endif

#include <iostream>
#include <utility>
#include <numeric>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <cstdio>
#include <map>
#include <cmath>
#include <set>
#include <list>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef __int128 lll;
constexpr ll mod = 1000000007;

#define bs(n) (1ull<<(ull)(n))
#define rep(i, n) for(ll (i) = 0;(i) < (n);(i)++)
#define rrep(i, n) for(ll (i) = 1;(i) <= (n);(i)++)

ll fd[2000005], ifd[2000005];

void extgcd(ll a, ll b, ll &ra, ll &rb) {
    if (b == 0) {
        ra = a;
        rb = 0;
    } else {
        ll ta, tb;
        extgcd(b, a % b, ta, tb);
        ra = tb;
        rb = ta - tb * (a / b);
    }
}

ll im(ll n) {
    ll ta, tb;
    extgcd(n, mod, ta, tb);
    return ((ta % mod) + mod) % mod;
}

ll ff(ll s, ll t) {
    return (((fd[s + t] * ifd[s]) % mod) * ifd[t]) % mod;
}

int main() {
    fd[0] = ifd[0] = 1;
    for (ll i = 1; i < 2000005; i++) {
        fd[i] = (fd[i - 1] * i) % mod;
        ifd[i] = (ifd[i - 1] * im(i)) % mod;
    }
    ll r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    cout << (((ff(r2 + 1, c2 + 1) + ff(r1, c1) - ff(r2 + 1, c1) - ff(r1, c2 + 1)) % mod) + mod) % mod << endl;
}


Measured memory_bytes: 31488
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
typedef long long ll;
typedef long double ld;
int main()
{
  int t; cin >> t;
  vector<ll> n(t), a(t), b(t), c(t), d(t);
  rep(i,t) {
    cin >> n[i] >> a[i] >> b[i] >> c[i] >> d[i];
  }
  ll inf = (1LL << 60);


  rep(i,t) {
    vector<ll> num = {2, 3, 5};
    vector<ll> cost = {a[i], b[i], c[i]};    
    map<ll,ll> dp;
    dp[0] = 0;
    dp[1] = d[i];
    auto rec = [&](auto f, ll nn)-> ll{
		 if(dp.find(nn) != dp.end()) return dp[nn];
		 ll res = inf;
		 if(((ld)nn * (ld)d[i]) < inf) {
		   res = nn * d[i];
		 }
		 rep(j,3) {
		   if(nn % num[j] == 0) chmin(res, f(f, nn/num[j]) + cost[j]);
		   else {
		     chmin(res, f(f, nn/num[j]) + cost[j] + d[i]*(nn % num[j]));
		     chmin(res, f(f, nn/num[j] + 1) + cost[j] + d[i]*(num[j] - nn % num[j]));	   
		   }		   
		 }
		 return dp[nn] = res;
	       };
    cout << rec(rec, n[i]) << "\n";
  }
  
  return 0;
}


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

using namespace std;
int a, b, c, k;
int main()
{
    //freopen("test.inp","r", stdin);
    cin >> a >> b >> c >> k;
    for (int i = 1; i <= k;)
    {
        if (c <= b)
        {
            c *= 2;
            k--;
        }
        if (b <= a)
        {
            k--;
            b *= 2;
        }
        if (c > b && b > a) break;
    }
    if (c > b && b > a) cout <<"Yes";
    else cout << "No";
    return 0;
}


Measured memory_bytes: 3588
#include "bits/stdc++.h"
#include "sstream"
#define EPS 1e-9
using namespace std;
const int N=1e5,OO=0x3f3f3f3f;
typedef long long ll;
int arr[N][3],dp[N][4];
int solve(int idx,int lst){
    if(!~idx)
        return 0;
    int &ret=dp[idx][lst];
    if(~ret)
        return ret;
    for(int j=0;j<3;j++){
        if(lst!=j){
          ret=max(ret,arr[idx][j]+solve(idx-1,j));}
        }
    return ret;
}
int main() {
  int n; scanf("%d",&n);
   for(int i=0;i<n;i++)
       for(int j=0;j<3;j++)
           scanf("%d",&arr[i][j]);
       memset(dp,-1, sizeof(dp));
   cout<<solve(n-1,3);
}

Measured memory_bytes: 10752
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n)  RFOR(i,0,n)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
 
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979
#define P pair<int,int>
#define PPi pair<P,int>
 
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

int main(void){
	int H,W,N,a,result[100][100];
	cin>>H>>W>>N;

	int cn=0;
	FOR(i,1,N+1){
		cin>>a;
		FOR(j,cn,cn+a) result[j/W][j%W]=i;
		cn+=a;
	}

	REP(i,H){
		if(i%2) reverse(result[i],result[i]+W);
		printf("%d",result[i][0]);
		FOR(j,1,W) printf(" %d",result[i][j]);
		print();
	}
	return 0;
}




Measured memory_bytes: 384
H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

for i in range(H):
    for j in range(W):
        if S[i][j] != "#":
            cnt = 0
            if i != 0:
                if j != 0:
                    if S[i-1][j-1] == "#":
                        cnt += 1
                if S[i-1][j] == "#":
                    cnt += 1
                if j != W-1:
                    if S[i-1][j+1] == "#":
                        cnt += 1
            if j != 0:
                if S[i][j-1] == "#":
                    cnt += 1
            if j != W-1:
                if S[i][j+1] == "#":
                    cnt += 1
            if i != H-1:
                if j != 0:
                    if S[i+1][j-1] == "#":
                        cnt += 1
                if S[i+1][j] == "#":
                    cnt += 1
                if j != W-1:
                    if S[i+1][j+1] == "#":
                        cnt += 1
            S[i][j] = str(cnt)
    S_str = "".join(S[i])
    print(S_str)
    S_str = ""

Measured memory_bytes: 3188
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

#define ft first
#define sd second
#define mp make_pair
#define pb push_back

using namespace std;

typedef long long int ll;

const int MAXN = 2000000;
const int INF = 1e9 + 10;
const ll MOD = 1e9 + 7;

map<pair<ll, ll>, int> num;

int getNum(ll x, ll y) {
    if (x < y)
        swap(x ,y);

    if (num.count(mp(x, y)))
        return num[mp(x, y)];

    unordered_set<int> mexs;
    for (ll i = 1; i <= x / 2; ++i) {
        mexs.insert(getNum(x - 2 * i, y + i));
    }
    for (ll i = 1; i <= y / 2; ++i) {
        mexs.insert(getNum(x + i, y - 2 * i));
    }

    int result = 0;
    while (mexs.count(result)) {
        ++result;
    }
    return num[mp(x, y)] = result;
}

int main() {
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
#endif

    ll x, y;
    scanf("%lld %lld", &x, &y);
    if (llabs(x - y) <= 1) {
        puts("Brown");
    } else {
        puts("Alice");
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589
#define MOD 1000000007

using namespace std;

template<typename T> T gcd(T a, T b){return (a % b)? gcd(b, a % b) : b;}
template<typename T> T lcm(T a, T b){return a * b / gcd(a, b);}

void solve_A(){
    char s;
    cin >> s;
    if(isupper(s)){
        cout << "A" << endl;
    } else cout << "a" << endl;
}

int main(void){
    solve_A();
    
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,A,S,M;
	cin>>a>>b;
	A=a+b;
	S=a-b;
	M=a*b;
	if(A>=S&&A>=M){cout<<A;return 0;}
	if(S>=A&&S>=M){cout<<S;return 0;}
	if(M>=A&&M>=S){cout<<M;return 0;}
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int N,W,i,j,k;
	cin>>N>>W;
	long long int value[N];
	int weight[N];
	
	for(i=0;i<N;i++)
	cin>>weight[i]>>value[i];
	
	long long int dp[N+1][W+1];
	
	for(i=0;i<=N;i++)
	{
		for(j=0;j<=W;j++)
		{
			if(i==0||j==0)
			dp[i][j]=0;
			else if(weight[i-1]>j)
			dp[i][j]=dp[i-1][j];
			else
			{
				dp[i][j]=max(dp[i-1][j],value[i-1]+dp[i-1][j-weight[i-1]]);
			}
		}
	}
	cout<<dp[N][W];
	return 0;
}

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

using namespace std;

// int nc3(int n){
//   int kei=0;
//   kei=
// }

int main(){
  int n;
  int ans=0;
  cin >> n;
  vector<int> l(n);
  for(int i=0;i<n;i++){
    cin >> l.at(i);
  }
  sort(l.begin(),l.end());

  for(int i=0;i<n-2;i++){
    int a=l.at(i);
    for(int j=i+1;j<n-1;j++){
      int b=l.at(j);
      for(int z=j+1;z<n;z++){
        int c=l.at(z);
        if(c<a+b){
          ans++;
        }
        else{
          break;
        }
      }
    }
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
typedef long long ll;
const int INF=1000000000;
const int MOD=1000000007;

int main()
{
 int a1,a2,a3;
 cin >> a1 >> a2 >> a3;
 if(a1+a2+a3>21) cout << "bust";
 else if(a1+a2+a3<=21) cout << "win";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<int>> v(h+2, vector<int>(w+2, INF<int>));
    auto dist = v;
    for (int i = 0; i < h; ++i) {
        string s;
        cin >> s;
        for (int j = 0; j < w; ++j) {
            v[i+1][j+1] = s[j] == '.';
        }
    }
    dist[1][1] = 1-v[1][1];
    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= w; ++j) {
            if(i != 1) chmin(dist[i][j], dist[i-1][j]+(v[i][j] != v[i-1][j]));
            if(j != 1) chmin(dist[i][j], dist[i][j-1]+(v[i][j] != v[i][j-1]));
        }
    }
    cout << (dist[h][w]+1)/2 << "\n";
    return 0;
}

Measured memory_bytes: 384
s = input()
t = input()


def lcs(s, t)->list:
    sn = len(s)
    tn = len(t)
    dp = [[0 for _ in range(tn+1)] for _ in range(sn+1)]
    for i in range(sn):
        for j in range(tn):
            if s[i] == t[j]: dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j]+1)
            else: dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1])
    #[print(val) for val in dp]
    return dp


def restore_str(lcs_dp)->str:
    restore = str()
    i = len(s)
    j = len(t)

    while i > 0 and j > 0:
        #print(i, j, restore, lcs_dp[i])
        if lcs_dp[i][j] == lcs_dp[i-1][j]: i -= 1
        elif lcs_dp[i][j] == lcs_dp[i][j-1]: j -= 1
        else: 
            restore = s[i-1] + restore
            i -= 1
            j -= 1

    return restore


def main():
    lcs_dp = lcs(s, t)
    ans = restore_str(lcs_dp)
    return print(ans)


if __name__ == '__main__':
    main()

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

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

int main(){
int N,j,b,max;
  j=0;
  string a;
  cin>>N;
  vector<int> s(N);
  vector<pair<string,int>>S(N),F(N);
  for(int i=0;i<N;i++){
cin>>a>>b;
  S[i]=make_pair(a,b);
  }
  F=S;
  sort(F.begin(),F.end());
  for(int i=0;i<N;i++){
if(i!=N-1&&F[i].first==F[i+1].first){
  continue;
}
    else{
for(int u=j;u<i+1;u++){
  max=u;
  for(int p=u;p<i+1;p++){
   if(F[p].second>F[max].second){
     max=p;
   }
  }
  swap(F[u].second,F[max].second);
}
      j=i+1;
  }
  }
      for(int i=0;i<N;i++){
          for(int u=0;u<N;u++){
            if(F[i]==S[u]){
             s[i]=u+1;
              break;
            }
          }
      }
      for(int i=0;i<N;i++){
        
              cout<<s[i]<<endl;
      }

}


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

int main(){
  int N;
  cin >> N;
  
  vector<int> digit(10);
  
  int div=1;
  for(int i=0; i<10; i++){
    div *= 10;
    digit[i] = (N%div)/(div/10);
  }
  
  int sum=0;
  for(int i=0; i<10; i++){
    sum += digit[i];
  }
  
  if(N%sum==0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

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

	int32_t res = A + B;
	if (res >= 10)
		printf("error\n");
	else
		printf("%d\n", res);

	return 0;
}

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

using namespace std;

int main() {
    list<int> ls;
    auto it = ls.end();

    int q;
    cin >> q;
    while (q--) {
        int n;
        cin >> n;

        if (n == 0) {
            int x;
            cin >> x;
            it = ls.insert(it, x);
        } else if (n == 1) {
            int d;
            cin >> d;
            if (d > 0) {
                for (int i = 0; i < d; ++i) {
                    it++;
                }
            } else {
                for (int i = 0; i < -d; ++i) {
                    it--;
                }
            }
        } else if (n == 2) {
            it = ls.erase(it);
        }
    }

    for (auto x:ls) {
        cout << x << endl;
    }
    return 0;
}


Measured memory_bytes: 18652
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007

#define ll long long

//printf("%.10f", );
//cout << fixed << setprecision(10) << heikin << endl;

using namespace std;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };

vector<edge>tree[100010];
vector<P> connect[100005];
long long cost[100005];

int dp[40][500][500];

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

int main() {

	int A, B;
	cin >> A >> B;

	int sum = B * 2;
	int ans = (A <= sum) ? 0 : A - sum;
	
	cout << ans << endl;
}

Measured memory_bytes: 5888
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	if(a<=c && c<=b) cout << min(b,d)-c << endl;
	else if(c<=a && a<=d) cout << min(b,d)-a << endl;
	else cout << 0 << endl;
}


Measured memory_bytes: 256
#include <deque>
#include <fstream>
#include <iostream>
#include <list>
using namespace std;
enum ProcessNum { push = 0, randomAccess = 1, pop = 2 };

ProcessNum processNum(int query) {
    if (query == 0)
        return push;
    else if (query == 1)
        return randomAccess;
    else if (query == 2)
        return pop;
}

int main() {
    // ifstream in("1_B.txt");
    // streambuf *cinbuf = cin.rdbuf();
    // cin.rdbuf(in.rdbuf());
    deque<int> queue;
    int loop, query, d, x;
    cin >> loop;
    while (loop--) {
        cin >> query;
        switch (processNum(query)) {
        case push:
            cin >> d;
            cin >> x;

            if (d == 0) {
                // push_front
                queue.push_front(x);
            } else if (d == 1) {
                // push_back
                queue.push_back(x);
            }
            break;

        case randomAccess:
            cin >> d;
            cout << queue[d] << endl;
            break;

        case pop:
            cin >> d;
            if (d == 0)
                queue.pop_front();
            else
                queue.pop_back();
            break;
        }
    }
}


Measured memory_bytes: 4640