akhauriyash/Code-Regression huggingface dataset:
import           Data.Maybe
import qualified Data.ByteString.Char8         as C8

getInts :: IO [Int]
getInts = fmap (map (fst . fromJust . C8.readInt) . C8.words) C8.getLine

main :: IO ()
main = do
    _  <- getLine
    hs <- getInts
    print $ solve hs - 1

solve :: [Int] -> Int
solve [] = 0
solve hs = (1 +) . sum . map (solve . map (subtract 1)) . splitOn 0 $ hs

splitOn :: Eq a => a -> [a] -> [[a]]
splitOn _ [] = [[]]
splitOn a (x : xs) | x == a    = [] : res
                   | otherwise = (x : h) : hs
    where res@(h : hs) = splitOn a xs


Measured memory_bytes: 1020
//tokyokaijyo2020_a.cpp
//Sat Jul 11 09:59:50 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i,n) for (int i=0;i<(n);++i)

using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	rep(i,3) cout << s[i];
	printf("\n");
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 3628
N = int(input())
A = list(map(int,input().split()))

if N ==1 or N ==2:
    print(1)
    exit()
t = 0
c =1
for i in range(1,N):

    if A[i]-A[i-1]>0:
        if t == -1:
            c +=1
            t = 0
        else:
            t = 1
    elif A[i]-A[i-1]<0:
        if t == 1:
            c +=1
            t = 0
        else:
            t = -1    
print(c)

Measured memory_bytes: 14252
fun main(args: Array<String>) {
    var (k, s) = readLine()!!.split(" ").map{it.toInt()}

    var r = 0
    for(i in 0..k) {
        for( j in 0..k) {
            if(s - i - j in 0..k) r++
        }
    }
    println(r)
}

Measured memory_bytes: 36380
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
int main() {


  
 ll n,k; cin>>n>>k;
  vector<ll>a(n);
  rep(i,n){cin>>a.at(i);}
  
  rep(j,n-k){if(a.at(j)<a.at(j+k)){cout<<"Yes"<<endl;}
            else{cout<<"No"<<endl;}}
  
    

 
  
}


Measured memory_bytes: 4840
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>

#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long LL;
using namespace std;

int main() {
	string c;
	stack<int> s;

	int a, b;
	while (cin >> c) {
		if (c == "+") {
			a = s.top(); s.pop();
			b = s.top(); s.pop();
			s.push(b + a);
		}
		else if (c == "-") {
			a = s.top(); s.pop();
			b = s.top(); s.pop();
			s.push(b - a);
		}
		else if (c == "*") {
			a = s.top(); s.pop();
			b = s.top(); s.pop();
			s.push(a * b);
		}
		else {
			s.push(stoi(c));
		}

	}
	cout << s.top() << endl;

	return 0;
}


Measured memory_bytes: 3184
import java.util.*;

public class Main {
    static int N;
    static int M;
    static int K;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        M = sc.nextInt();
        K = sc.nextInt();
        int pow2M =(int) Math.pow(2,M);
        if (K >= pow2M) {
            System.out.println(-1);
            return;
        } 
        if (M == 1 && K == 1) {
            System.out.println(-1);
            return;
        }
        if (M == 1 && K == 0) {
            System.out.print(0);
            System.out.print(" ");
            System.out.print(0);
            System.out.print(" ");
            System.out.print(1);
            System.out.print(" ");
            System.out.println(1);
            return;
        }
        for (int i = 0; i < pow2M; i++) {
            if (i != K) {
                System.out.print(i);
                System.out.print(" ");
            }
        }
        System.out.print(K);
        System.out.print(" ");
        for (int i = pow2M - 1; i >= 0; i--) {
            if (i != K) {
                System.out.print(i);
                System.out.print(" ");
            }
        }
        System.out.println(K);
   }
}

Measured memory_bytes: 46276
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int l = scan.nextInt();
		
		long a[][] = new long[n][m];
		long b[][] = new long[m][l];
		long c[][] = new long[n][l];
		
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				a[i][j] = scan.nextLong();
			}
		}
		
		for(int h = 0; h < m; h++){
			for(int k = 0; k < l; k++){
				b[h][k] = scan.nextLong();
			}
		}
		
		for(int p = 0; p < n; p++){
			for(int q = 0; q < l; q++){
				long s = 0;
				for(int r = 0; r < m; r++){
					s = s + a[p][r] * b[r][q];
					c[p][q] = s;
				}
			}
		}
		
		for(int s = 0; s < n; s++){
			for(int t = 0; t < l; t++){
				System.out.print(c[s][t]);
				if(t != l - 1){
					System.out.print(" ");
				}
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 52188
/*
このコード、と～おれ!
Be accepted!
  ∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define printyn(a) printf(a ? "Yes\n" : "No\n");
#define printYN(a) printf(a ? "YES\n" : "NO\n");
#define all(x) (x).begin(), (x).end()

using ll = long long;

//マクロとかここまで

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
//#include <vector>

using namespace std;

int main() {

	int n, k, tmp;
	bool dislike[10] = {}, isgood = true;
	scanf("%d%d", &n, &k);
	rep(i, k) {
		scanf("%d", &tmp);
		dislike[tmp] = true;
	}
	rep(i, to_string(n).length()) {
		if (dislike[/*i桁目*/int(to_string(n)[i] - 48)])isgood = false;
	}
	if (isgood) {
		printf("%d\n", n);
		return 0;
	}
	while (!isgood) {
		++n;
		isgood = true;
		rep(i, to_string(n).length()) {
			if (dislike[int(to_string(n)[i] - 48)])isgood = false;
		}
	}
	printf("%d\n", n);

	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int L = Integer.parseInt(sc.next());
		String[] S = new String[N];
		for(int i = 0;i < N;i++) {
			S[i] = sc.next();
		}
		sc.close();
		Arrays.sort(S);
		StringBuilder sb = new StringBuilder();
		for(String s : S) {
			sb.append(s);
		}
		System.out.println(sb.toString());
	}
}

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

struct info
{
    int x, y, v;
};

int main()
{
    int n, b, c;

    while( cin >> n )
    {
        if( !n )
            break;

        info a[n];
        a[0].x = 0;
        a[0].y = 0;
        a[0].v = 0;
        int cnt = 1;
        for( int i = 1; i < n; i++ )
        {
            cin >> b >> c;
            for( int j = 0; j < i; j++ )
            {
                if( b == a[j].v )
                {
                    switch( c )
                    {
                        case 0:
                            a[i].x = a[j].x - 1;
                            a[i].y = a[j].y;
                            a[i].v = cnt++;
                            break;
                        case 1:
                            a[i].x = a[j].x;
                            a[i].y = a[j].y + 1;
                            a[i].v = cnt++;
                            break;
                        case 2:
                            a[i].x = a[j].x + 1;
                            a[i].y = a[j].y;
                            a[i].v = cnt++;
                            break;
                        case 3:
                            a[i].x = a[j].x;
                            a[i].y = a[j].y - 1;
                            a[i].v = cnt++;
                            break;
                    }
                    break;
                }
            }
        }
        int minx = 1000, miny = 1000, maxx = 0, maxy = 0;
        for( int i = 0; i < n; i++ )
        {
            if( a[i].x < minx )
                minx = a[i].x;
            if( a[i].y < miny )
                miny = a[i].y;
            if( a[i].x > maxx )
                maxx = a[i].x;
            if( a[i].y > maxy )
                maxy = a[i].y;
        }

        cout << maxx - minx + 1 << " " << maxy - miny + 1 << endl;

    }
    return 0;
}


Measured memory_bytes: 3072
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <memory.h>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <ctime>
#include <iostream>
#include <functional>
#include <complex>
#include <stdlib.h>
#include <random>
#include <fstream>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<pii, int> p3i;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<p3i> v3i;
typedef vector<vii> vvii;
typedef vector<p3i> vp3i;
typedef long double ld;
typedef vector<ld> vld;

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define REPD(i, n) for (int (i) = (n) - 1; (i) >= 0; (i)--)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define FORD(i,a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define sz(v) (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define rv(v) reverse(all(v))
#define CL(v, val) memset((v), (val), sizeof((v)))
#define SORT(a) sort(all(a))
#define un(v) SORT(v), (v).resize(unique(all(v)) - (v).begin())
#define eps 1.0e-9
#define X first
#define Y second
#define bit(n) (1 << (n))
#define bit64(n) (ll(1) << (n))
#define sqr(x) ((x) * (x))
#define sq5(x) ((x) * (x) * (x) * (x) * (x))

int main(void) {
	ll a;
	scanf("%lld", &a);
	if (a == 1) {
		printf("0\n");
		return 0;
	}
	int ans = 0;
	for (ll x = 2; x * x <= a; x++) {
		if (a % x == 0) {
			int cnt = 0;
			while (a % x == 0) {
				cnt++;
				a /= x;
			}

			int st = 1;
			while (cnt >= st) {
				ans++;
				cnt -= st;
				st++;
			}
		}
	}

	if (a != 1) {
		ans++;
	}

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

Measured memory_bytes: 3840
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main()
{
  long long a;
  scanf("%lld", &a);
  long long b;
  scanf("%lld", &b);
  long long c;
  scanf("%lld", &c);
  long long d;
  scanf("%lld", &d);

  ll ans = max({a * c, a * d, b * c, b * d});
  if ((a < 0 && b > 0) || (c < 0 && d > 0))
    cout << max(ans, 0LL) << endl;
  else
    cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3760
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cmath>
#include <map>
#include <set>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout<<#x<<": "<<x<<endl
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
  int h,w;
  char c[105][105]={};
  cin>>h>>w;
  rep(i,0,h){
    rep(j,0,w){
        cin>>c[i][j];
    }
  }

  rep(i,0,h){
      rep(j,0,w){
          cout<<c[i][j];
      }
      cout<<endl;
      rep(j,0,w){
          cout<<c[i][j];
      }
      cout<<endl;
  }


}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{
public void yatary(){
    Scanner sc = new Scanner(System.in);
    int x,y,a,b;
    x = sc.nextInt();
    y = sc.nextInt();
    while(x!=0 || y!=0){
        for(a = 1; a <= x; a++){
            for(b = 1; b <= y; b++){
            System.out.print("#");
                if(b == y){
                    System.out.println();
                }
            }
        }
    System.out.println();
    x = sc.nextInt();
    y = sc.nextInt();
    }
}
public static void main(String[]args){
   new Main().yatary();
  }
}

Measured memory_bytes: 27008
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int P=1e9+7;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int add(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
	return res;
}
const int N=1e5+5;
int to[N],deg[N],cir[N],cnt[N],dp[N],col[N],len[N];
int n,res,tim;
inline int calc(R int x,R int y){return (x<y)+(x<=y);}
int main(){
//    freopen("testdata.in","r",stdin);
	scanf("%d",&n),res=1;
	fp(i,1,n)scanf("%d",&to[i]),++deg[to[i]];
	fp(i,1,n)if(!col[i]){
		R int u=i;
		for(++tim;!col[u];u=to[u])col[u]=tim;
		if(col[u]==tim)for(;!cir[u];u=to[u])cir[u]=1;
	}
	fp(i,1,n)if(deg[i]>cir[i]+1)return puts("0"),0;
	fp(i,1,n)if(!deg[i])
		for(R int u=i,l=0;!cir[u];len[to[u]]=++l,u=to[u]);
	fp(i,1,n)if(cir[i]){
		R int u=i,fir=0,firlen=0,k=0,las=0;
		for(;cir[u];cir[u]=0,u=to[u])
			if(++k,len[u]){
				if(!fir){fir=las=k,firlen=len[u];continue;}
				res=mul(res,calc(len[u],k-las)),las=k;
			}
		fir?res=mul(res,calc(firlen,fir+k-las)):++cnt[k];
	}
	fp(i,1,n)if(cnt[i]){
		R int op=(i&1)+(i>1);
		dp[0]=1;
		fp(j,1,cnt[i]){
			dp[j]=mul(dp[j-1],op);
			if(j>1)upd(dp[j],1ll*i*(j-1)%P*dp[j-2]%P);
		}
		res=mul(res,dp[cnt[i]]);
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 2176
import numpy as np

n = input()
array = np.array(list(map(int, input().split())))

count = 0
def recur(array):
    global count
    if len(array) == 0 :
        pass
    else:
        count += min(array)
        array = array - min(array)
        for i in range(len(array)):
            if array[i] == 0:
                array_1 = array[:i]
                array_2 = array[i+1:]
                break
        recur(array_1)
        recur(array_2)
    return count

print(recur(array))

Measured memory_bytes: 20868
lis = list(map(int, input().split()))
k,mmm,all_=lis[3],[1,0,-1],0
sum_=[0]*3
for i in range(3):
  #print('%d %d'%(k, lis[i]))
  if lis[i]<k:
    sum_[i]+=lis[i]
    k-=lis[i]
  elif lis[i]>=k:
    sum_[i]+=k
    k=0

#print(sum_)
for j in range(3):
  all_+=mmm[j]*sum_[j]
print(all_)

Measured memory_bytes: 9136
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt,ans,a,b,c,d,e,f,g,tmp,tmpp,m,h,w,x,y,sum,pos,k,ziyuu;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n;
    rep(i,n){
        cin>>tmp;
        if(1<=tmp&&tmp<=399)a=1;
        else if(400<=tmp&&tmp<=799)b=1;
        else if(800<=tmp&&tmp<=1199)c=1;
        else if(1200<=tmp&&tmp<=1599)d=1;
        else if(1600<=tmp&&tmp<=1999)e=1;
        else if(2000<=tmp&&tmp<=2399)f=1;
        else if(2400<=tmp&&tmp<=2799)g=1;
        else if(2800<=tmp&&tmp<=3199)h=1;
        else ziyuu++;
    }
    if(a||b||c||d||e||f||g||h){
        ans=a+b+c+d+e+f+g+h;
        cout<<ans<<" "<<ans+ziyuu<<"\n";
    }
    else{
        cout<<1<<" "<<n<<"\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <bitset>
#include <algorithm>
using namespace std;

int n,m,i,j,k,u,v;
bitset<200005> B1,B2;

int main()
{
	scanf("%d%d",&n,&m);
	for(;m;--m)
	{
		scanf("%d%d",&u,&v);
		if(u>v)swap(u,v);
		if(u==1)B1[v]=1;
		if(v==n)B2[u]=1;
	}
	if((B1&B2).count())printf("POSSIBLE\n");
	else printf("IMPOSSIBLE\n");
}

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

using namespace std;

int main() {
   string N;
 
    cin>>N;
    if(N[0]==N[2]){
    cout<<"Yes"<<endl;
    }
    else if(N[0]==N[1]==N[2]){
    cout<<"Yes"<<endl;
    }else{
    cout<<"No"<<endl;
    }
    
	return 0;
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll q,b,c1,c2,q2;
  while(cin >> q && q){
    cin >> b >> c1 >> c2 >> q2;
    ll A=0,B=0,C = b;
    A = min(q2,b / c1);
    b -= A * c1;
    B = b / c2;
    b = C;
    while(A+B<q){
      --A;
      b -= A * c1;
      B = b / c2;
      b = C;
      if(A==0) break;
    }
    if(A == 0){
      cout << "NA"<<endl;
    }
    else{
      cout << A << " " << B <<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3120
/* * * * * * * * * * * **
*                      *
*	   saurabh8522	   *
*	  I will handle	   *
*		   IT.		   *
*                      *
* * * * * * * * * * * **/
#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define ld long double
#define zero(a) memset((a),0,sizeof((a)))
#define one(a) memset((a),1,sizeof((a)))
#define minus(a) memset((a),-1,sizeof((a)))
#define all(g) g.begin(),g.end()
#define ppb pop_back
using namespace std;
typedef long long int ll;
#define MOD 1000000007
ll extgcd(ll a,ll b,ll& x,ll& y){if(b==0){x=1;y=0;return a;}else{int g=extgcd(b,a%b,y,x);y-=a/b*x;return g;}}
ll modpow(ll a,ll b) {ll res=1;a%=MOD;for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}
ll numdigit(ll n){return floor(log10(n)) + 1;}
bool isPowerTwo (ll x) { return x && (!(x&(x-1))); } 
int  main(){
	FastRead;
	ll t=1;
	// cin>>t;
	while(t--){
		ll n;
		cin>>n;
		string s;cin>>s;
		ll dp[n+5][n+5];
		zero(dp);
		dp[1][1]=1;
		for(int i=2;i<=n;i++){
			vector<ll>sum(n,0);
			// cout<<"i="<<i<<" "<<endl;
			for(int j=1;j<=i-1;j++){
				sum[j]=(sum[j-1]+dp[i-1][j])%MOD;
				// cout<<"j="<<j<<"sum="<<sum[j]<<endl;
			}
			for(int j=1;j<=i;j++){
				int l,r;
				if(s[i-2]=='<'){
					l=1,r=j-1;
				}
				else{
					l=j,r=i-1;
				}
				// cout<<"j="<<j<<"l="<<l<<"r="<<r<<endl;
				if(l<=r){
					dp[i][j]=(dp[i][j]+(sum[r]-sum[l-1]+MOD)%MOD)%MOD;
				}
			}
		}
		ll res=0;
		for(int i=1;i<=n;i++){
			res=(res+dp[n][i])%MOD;
			// cout<<i<<" "<<dp[n][i]<<endl;
		}
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				// cout<<dp[i][j]<<" ";
			}
			// cout<<endl;
		}
		cout<<res<<endl;
	}
}

Measured memory_bytes: 70912
#include<iostream>
#include<algorithm>
using namespace std;
long long a[1005],b[1005],c[1005],d[1000005],ans[3000005];
bool cmp(long long x,long long y){
	return x>y;
}
int main()
{
	int x,y,z,k,i,j,s;
	cin>>x>>y>>z>>k;
	for(i=1;i<=x;i++) cin>>a[i];
	for(i=1;i<=y;i++) cin>>b[i];
	for(i=1;i<=z;i++) cin>>c[i];
	
	int t=0;
	for(i=1;i<=x;i++)
		for(j=1;j<=y;j++){
			d[++t]=a[i]+b[j];
		}
	
	sort(d+1,d+t+1,cmp);
	
	s=0;
	for(i=1;i<=z;i++)
		for(j=1;j<=k;j++)
			ans[++s]=c[i]+d[j];
	
	sort(ans+1,ans+s+1,cmp);
	
	for(i=1;i<=k;i++)
		cout<<ans[i]<<endl;
	return 0;
}


Measured memory_bytes: 31488
a,b,c,d = map(int,input().split())
from fractions import gcd

lcm = c*d//gcd(c,d)

num_b_c = b//c
num_b_d = b//d
num_b_cd = b//lcm

if a%c==0:
    num_a_c = a//c - 1
else:
    num_a_c = a//c

if a%d==0:
    num_a_d = a//d - 1
else:
    num_a_d = a//d

if a%lcm==0:
    num_a_cd = a//lcm - 1 
else:

    num_a_cd = a//lcm


alls = b - a + 1


c_div = num_b_c - num_a_c
d_div = num_b_d - num_a_d

cd_div = num_b_cd -num_a_cd


print(alls - ( c_div + d_div - cd_div))



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

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    vector<bool> ok(n, true);
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }

    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        if(h[a] <= h[b]) ok[a] = false;
        if(h[b] <= h[a]) ok[b] = false;
    }

    int ans = 0;
    for(int i = 0; i < n; i++){
        if(ok[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3748
#pragma GCC optimize("O3")

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz size
#define f first
#define s second

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int x, a;
    cin >> x >> a;
    if(x<a)
        cout << 0;
    else
        cout << 10;

    return 0;
}


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

int count(bitset<26> bs) {
    int ans = 0;
    for (int i = 0; i < 26; ++i) {
        ans += bs.test(i);
    }
    return ans;
}

int main() {
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    for (int i = 1; i < n; ++i) {
        string a = s.substr(0, i);
        string b = s.substr(i);
        bitset<26> bsa;
        bitset<26> bsb;
        for (char c : a) bsa.set(c - 'a');
        for (char c : b) bsb.set(c - 'a');
        bitset<26> c = bsa & bsb;
        ans = max(count(c), ans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func condAB(c bool, a, b int) int {
	if c {
		return a
	}
	return b
}

func main() {
	sc.Split(bufio.ScanWords)

	s := getString()
	k := getInt()

	nbits := len(s)
	d := make([]int, nbits)
	for i := 0; i < nbits; i++ {
		d[i] = int(s[i] - '0')
	}

	//  [digit][smaller][cond1]
	//  cond1 ... 3である
	var dp [101][2][5]int

	dp[0][0][0] = 1
	for i := 0; i < nbits; i++ {
		for m := 0; m < 2; m++ {
			for a := 0; a <= condAB(m != 0, 9, d[i]); a++ {
				mm := m
				if a < d[i] {
					mm = 1
				}
				// cond1
				if a != 0 {
					for k := 1; k < 5; k++ {
						dp[i+1][mm][k] += dp[i][m][k-1]
					}
				} else {
					for k := 0; k < 5; k++ {
						dp[i+1][mm][k] += dp[i][m][k]
					}
				}
			}
		}
	}

	// for i := 0; i <= nbits; i++ {
	// 	out(dp[i], k)
	// }
	out(dp[nbits][1][k] + dp[nbits][0][k])

}


Measured memory_bytes: 640
(function(stdin){
	var lines = stdin.toString().split('\n').map(Number);
	var resolt = (function(a){
		return [(Math.pow(a,2)*Math.PI).toFixed(6),(a * 2 * Math.PI).toFixed(6)];
	}(lines[0])).join(' ');
	console.log(resolt);
}(require('fs').readFileSync('/dev/stdin','utf8')));

Measured memory_bytes: 7648
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (n) - 1; i >= (s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(), a.end()
const long long MOD = 1e9 + 7, INF = 1e18;
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;}



signed main(){
	int N,M;
	cin>>N>>M;
	vector<int> a(N); for(auto& e:a)cin >> e;
	vector<int> b(M); for(auto& e:b)cin >> e;
	int dp[N+1][M+1] = {};
	REP(i,N+1){
		REP(j,M+1){
			if(i==0||j==0)dp[i][j] = 1;
		}
	}
	REP(i,N){
		REP(j,M){
			if(a[i]==b[j])dp[i+1][j+1] += dp[i][j+1] + dp[i+1][j];
			else dp[i+1][j+1] += dp[i+1][j] + dp[i][j+1] - dp[i][j] + MOD;
			dp[i+1][j+1] %= MOD;
		}
	}
	cout<<dp[N][M]<<endl;
}


Measured memory_bytes: 31616
/*
 * 	The way if it's all predetermined
 * 		And the way i should go all my life
 * 			I swear to go wherever will be
 * 				'Cause there'll be something to see and to find
 */
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#ifdef rd
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
#else
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef double f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
const ll infl=4e18;
const int infi=1e9;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
auto clk=clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
int powm(ll a, ll b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

void solve() {
	int n,l;
	cin>>n>>l;
	int ori=0;
	int mini=infl;
	fr(i,1,n) {
		ori+=l+i-1;
		if(abs(mini)>abs(l+i-1))
			mini=l+i-1;
	}
	ori-=mini;
	cout<<ori<<endl;

}

signed main() {
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	cout<<fixed<<setprecision(10);
	int t=1;
//	cin>>t;
	fr(i,1,t)
		solve();
#ifdef rd
	cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
#endif
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <vector>

using namespace std;

#define ll long long

struct node {
    int num, dist;
    node(int n, int d) {
        num = n;
        dist = d;
    }

    bool operator<(const node &right) const {
        return dist >= right.dist;
    }
};

int main() {
    int V, E, r;
    cin >> V >> E >> r;
    vector<vector<int>> ro(V);
    vector<vector<int>> di(V);
    for (int i = 0; i < E; i++) {
        int s, t, d;
        cin >> s >> t >> d;
        ro[s].push_back(t);
        di[s].push_back(d);
    }
    vector<int> dist(V, INT_MAX);
    vector<bool> c(V, false);
    priority_queue<node> pq;
    pq.push(node(r, 0));
    dist[r] = 0;
    while (pq.size() > 0) {
        auto n = pq.top();
        pq.pop();
        if (!c[n.num]) {
            c[n.num] = true;
            for (int i = 0; i < ro[n.num].size(); i++) {
                if (dist[ro[n.num][i]] > n.dist + di[n.num][i]) {
                    pq.push(node(ro[n.num][i], n.dist + di[n.num][i]));
                    dist[ro[n.num][i]] = n.dist + di[n.num][i];
                }
            }
        }
    }
    for (int i : dist) {
        if (i == INT_MAX) {
            cout << "INF" << endl;
        } else {
            cout << i << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 16864
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
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;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	int n,m;
	map<string, int> ma;
	cin>>n;
	rep(i, n){
		string s;
		cin>>s;
		int z = ma[s];
		ma[s]++;
	}
	cin>>m;
	rep(i, m){
		string s;
		cin>>s;
		int z = ma[s];
		ma[s]--;
	}
	int ans = 0;
	for(auto itr = ma.begin(); itr!=ma.end();itr++){
		chmax(ans, itr->second);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

int main() {
	int t[51][11][3] = {};//?§£????????? ??????????????£ ??????
	for (int T, P, R; cin >> T >> P >> R&&T;) {
		memset(t, 0, sizeof(t));
		int tID, pID, time; string message;
		for (int i = 0; i < R; i++) {
			cin >> tID >> pID >> time >> message;
			if (message[0] == 'C') {
				t[tID][pID][0] = 1;
				t[tID][pID][2] = time;
			}
			else {
				t[tID][pID][1]++;
			}
		}
		vector<pair<int, int> > a[11];
		for (int i = 1; i <= T; i++) {
			int cnt = 0,time=0;
			for (int j = 1; j <= P; j++) {
				if (t[i][j][0]) {
					time += t[i][j][2] + t[i][j][1] * 1200;
					cnt++;
				}
			}
			a[cnt].push_back( make_pair(time, i));
		}
		for (int i = 10; i >= 0; i--) {
			sort(a[i].begin(), a[i].end());
			for (size_t j = 0; j < a[i].size(); j++) {
				cout << a[i][j].second << " " << i << " " << a[i][j].first << endl;
			}
		}
	}
	return 0;
}

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

using namespace std;
typedef long long ll;

int main(){
  int n,flg=0;
  cin >> n;
  for(int i=1;i<=9;i++) {
    if(n%i==0 and n/i<=9) {
      flg=1;
      break;
    }
  }
  if(flg){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
N = list(input())
l = len(N)
if N[l-1] == '2' or N[l-1] == '4' or N[l-1] == '5' or N[l-1] == '7' or N[l-1] == '9':
    print('hon')
elif N[l-1] == '0' or N[l-1] == '1' or N[l-1] == '6' or N[l-1] == '8':
    print('pon')
elif N[l-1] == '3':
    print('bon')

Measured memory_bytes: 9140
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18

N = input()
ans = 0.0
for i in range(N):
  x, u = raw_input().split()
  x = float(x)
  if u == 'BTC':
    x *= 380000
  ans += x

print "{:.10f}".format(ans)

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

int main()
{
    int A, P;
    cin >> A >> P;

    cout << (A * 3 + P) / 2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int mod = 1000000007;

int main(){
    ll x, a, b;
    cin >> x;

    for(ll i=-200;i<=200;i++){
        for(ll j=-200;j<=200;j++){
            if(pow(i, 5) - pow(j, 5)==x){
                a = i;
                b = j;
                break;
            }
        }
    }

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

    return 0;
}

Measured memory_bytes: 4000
#include <bits/stdc++.h>
#define ll long long
#define fort(i,n) for (int i = 1; i <= n; ++i)
#define pi pair<int,int>
#define vi vector<int>
#define pb push_back
#define sz size()
#define er erase
#define fr first
#define sc second
#define rc(x) return cout << x, 0
using namespace std;

ll n,m,a[105],b[105],ans,dp[105][100005];

int32_t main()
{
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n >> m;
    fort (i,n)
        cin >> a[i] >> b[i];
    for (int i = 0; i <= n; ++i)
        for (int j = 0; j <= 100000; ++j)
            dp[i][j]=1000000001;
    dp[0][0]=0;
    fort (i,n)
    {
        for (ll j = 0; j <= 100000; ++j)
        {
            if (j<b[i]) dp[i][j]=dp[i-1][j];
            else dp[i][j]=min(dp[i-1][j], dp[i-1][j-b[i]]+a[i]);
            if (dp[i][j]<=m) ans=max(ans,j);
        }
    }
    cout << ans;
}


Measured memory_bytes: 80128
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define ALL(x) ::std::begin(x), ::std::end(x)
using namespace std;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;

constexpr int64_t MOD = 1000000007;
int64_t solve(int N, const vector<int64_t> & A) {
    ll ans = 0;
    ll left = 0;
    REP(i, N - 1) {
        left = (left + A[i]) % MOD;
        ans = (ans + left * A[i + 1]) % MOD;
    }
    return ans;
}

// generated by online-judge-template-generator v4.6.0 (https://github.com/kmyk/online-judge-template-generator)
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    constexpr char endl = '\n';
    int N;
    cin >> N;
    vector<int64_t> A(N);
    REP (i, N) {
        cin >> A[i];
    }
    auto ans = solve(N, A);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4696
package main

import "fmt"

func main(){
  var N int
  var A int
  var B int
  
  fmt.Scan(&N)
  fmt.Scan(&A)
  fmt.Scan(&B)
  
  if (A*N <= B){
    fmt.Print(A*N)
  }else{
    fmt.Print(B)
  }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
typedef long l;
const ll l_INF = 1010101010101010;
const int INF = 1010101010;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(){
  string s; cin>>s;
  int cnt=0;
  if(s=="RRS"||s=="SRR") cout<<2<<endl;
  else if(s=="RRR") cout<<3<<endl;
  else if(s=="SSS")cout<<0<<endl;
  else cout<<1<<endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long LL;
LL f[1000001];
int n,cnt=0,ans[1000001],an[1000001],a[1000001],fa[1000001];
void output(int n) {
    if (n==0) return;
    ans[n]=1;
    output(fa[n]);
}
void work(int x) {
    if (x==n) {
	n--;
	return;
    }
    if (x==1) {
	for (int i=1;i<n;i++) ans[i]=ans[i+1];
	n--;
	return;
    }
    for (int i=x;i<=n-2;i++) ans[i]=ans[i+2];
    n-=2;
}
int main() {
    scanf("%d",&n);
    for (int i=1;i<=n;i++) scanf("%d",&a[i]);
    for (int i=0;i<=n;i++) f[i]=-1e18;
    for (int i=1;i<=n;i++) {
	f[i]=a[i];
	fa[i]=0;
	for (int j=1;j<i;j++) {
	    if ((i-j)%2) continue;
	    if (f[j]+a[i]>f[i]) {		
		f[i]=f[j]+a[i];
		fa[i]=j;
	    }
	}
    }
    int max0=n;
    for (int i=1;i<n;i++) if (f[i]>f[max0]) max0=i;
    printf("%lld\n",f[max0]);
    output(max0);
    int cnt=0;
    while (ans[1]==0&&n>1) {
	an[++cnt]=1;
	work(1);
    }
    while (ans[n]==0&&n>1) {
	an[++cnt]=n;
	work(n);	
    }
    while (n>1) {
	int k=2;
	while (ans[k]==0) k++;
	k--;
	int mid=(2+k)/2;
	for (int i=mid;i>=2;i--) {
	    an[++cnt]=i;
	    work(i);
	}
    }
    printf("%d\n",cnt);
    for (int i=1;i<=cnt;i++) printf("%d\n",an[i]);
    return 0;
}


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

using namespace std;

int main()
{
	int num=0,pos=0;
	
	for(int i=1;i<=5;i++)
	{
		cin>>num;
		
		if(num==0) pos = i;
	}
	
	cout<<pos<<endl;
	
	return 0;
}

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

int main(){
  int N, A, B;
  int S = 0;
  int res = 0;
  int ANS = 0;
  cin >>N >>A >>B;
  for(int i = 1; i <= N; ++i){
    S += (i%10);
    S += (i/10)%10;
    S += (i/100)%10;
    S += (i/1000)%10;
    S += (i/10000)%10;
    if(A <= S && S <= B) ANS +=i;
    S = 0;
  }
  cout << ANS <<endl;
}


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

n, k = map(int, input().split())
X = list(map(int, input().split()))
ans = 10**10
for i in range(n-k+1):
    left = X[i]
    right = X[i+k-1]
    ans = min(ans, abs(left)+abs(left-right), abs(right)+abs(right-left))
print(ans)


Measured memory_bytes: 14252
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int kei = 100000;
		for(int i=1; i<=n; i++){
			kei *= 1.05;
			if(kei%1000 > 0){
				kei = ((kei - kei%1000)+ 1000);
			}
		}
		System.out.println(kei);
	}
}

Measured memory_bytes: 26052
#include<stdio.h>
int n,r,l,lhy,i;
int main()
{
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {scanf("%d%d",&l,&r);
    lhy+=r-l+1;}
    printf("%d\n",lhy);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define benfero freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define mm ' '
#define nl '\n'
#define MOD 1000007
typedef unsigned long long int ull;
typedef long long int ll;
int main()
{
    //benfero
    ll n, w;
    cin>>n>>w;
    ll dp[n+1][w+1]={0};
    ll wt[n];
    ll val[n];
    int i;
    for(i=0;i<n;i++){
        cin>>wt[i]>>val[i];
    }
    ll e;
    for(i=0;i<=n;i++){
        for(e=0;e<=w;e++){
            if(e==0 || i==0){
                dp[i][e]=0;
            }
            else if(wt[i-1]<=e){
                dp[i][e]=max(val[i-1]+dp[i-1][e-wt[i-1]],dp[i-1][e]);
            }
            else{
                dp[i][e]=dp[i-1][e];
            }
        }
    }
    cout<<dp[n][w];

    
    return 0;
}


Measured memory_bytes: 79104
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>

using namespace std;

int main() {
	double a, b, x;
	cin >> a >> b >> x;

	double ans;
	if (x / a > 0.5 * a * b) {
		double tan_theata = (b / a - x / (a * a * a)) * 2.0;
		double theata = atan(tan_theata);
		ans = theata * 180 / M_PI;
	} else {
		double tan_phi = 2.0 * x / (a * b * b);
		double phi = atan(tan_phi);
		double theata = M_PI / 2 - phi;
		ans = theata * 180 / M_PI;
	}

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main(){
  int N,M;
  cin>>N>>M;
  VI A(N),B(N);
  rep(i,N) B[i]=-1;
  VI P(M);
  vector<string> S(M);
  rep(i,M) cin>>P[i]>>S[i];
  rep(i,M){
    if(S[i]=="AC") B[P[i]-1]=A[P[i]-1];
    else if(B[P[i]-1]==-1) A[P[i]-1]++;
  }
  int ans1=0,ans2=0;
  rep(i,N){
    if(B[i]!=-1) ans1++;
    ans2+=max(0,B[i]);
  }
  cout<<ans1<<" "<<ans2<<endl;
}

Measured memory_bytes: 6912
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <functional>
#include <string.h>

using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a,0,sizeof(a))
#define minus(a) memset(a,0xff,sizeof(a))
#define chmax(a,b) a=min((a),(b))
#define chmin(a,b) a=max((a),(b))


string s, t;
int q;
char stmp[100005];
char ttmp[100005];

int main(){
	scanf("%s %s %d ", stmp, ttmp, &q);
	s = string(stmp); t = string(ttmp);
	int a, b, c, d;
	vector<int> ss(s.size()+5), tt(t.size()+5);
	for(int i=0;i<s.size();i++){
		ss[i] = (s[i] == 'A') ? 1 : 2;
	}
	for (int i = 0; i < t.size(); i++) {
		tt[i] = (t[i] == 'A') ? 1 : 2;
	}
	for (int i = 0; i < s.size()-1; i++) {
		ss[i + 1] += ss[i];
	}
	for (int i = 0; i < t.size()-1; i++) {
		tt[i + 1] += tt[i];
	}
	ss.insert(ss.begin(), 0);
	tt.insert(tt.begin(), 0);
	int l, r;
	rep(i, q) {
		scanf("%d %d %d %d ", &a, &b, &c, &d);
		l = ss[b] - ss[a - 1];
		r = tt[d] - tt[c - 1];
		if (l % 3 == r % 3) {
			puts("YES");
		}
		else {
			puts("NO");
		}
	}
	return 0;
}


Measured memory_bytes: 1792
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, C;
bool R[35][int(1e5 + 5)];

int main(){
  scanf("%d%d", &N, &C);
  for (int i = 0; i < N; i++){
    int s, t, c; scanf("%d%d%d", &s, &t, &c);
    for (int j = s-1; j < t; j++) R[c][j] = true;
  }

  int ans = 0;
  for (int j = 0; j <= int(1e5); j++){
    int cnt = 0;
    for (int i = 0; i <= C; i++){
      if (R[i][j]) cnt++;
    }
    ans = max(ans, cnt);
  }
  cout << ans << endl;

  return 0;
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  bool d = true;
  
  if (a == b && a != c ){
    d = false;
  }
  else if ( b == c && b != a ){
    d = false;
  }
  else if (c == a && c != b ){
    d = false;
  }
  
  if (d){
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner a = new Scanner(System.in);		
		int A = a.nextInt();
		int B = a.nextInt();
		int sum = 0;
		sum = A * B;
		System.out.println(sum);
		
		
	}
}

Measured memory_bytes: 35756
N = int(input())
S =  ["".join(sorted(input())) for _ in range(N)]

Sdic = {}
ans = 0

for i in range(N):
    if S[i] not in Sdic.keys():
        Sdic[S[i]] = 1
    else:
        ans += Sdic[S[i]]
        Sdic[S[i]] += 1
print(ans)

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

int main(){
  ll N, A, B;
  cin >> N >> A >> B;
  vector<ll> X(N);
  REP(i, N){
    cin >> X[i];
  }
  ll ans = 0;
  FOR(i, 1, N){
    ll cost = A * (X[i] - X[i-1]);
    if(cost > B){
      cost = B;
    }
    ans += cost;
  }

  cout << ans << endl;

  return 0;
}


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

class Program {
  static void Main() {
    Console.ReadLine();
    var a = Console.ReadLine().Split().Select(int.Parse);
    int cnt = 0;
    while (a.All(x => x % 2 == 0)) {
      a = a.Select(x => x / 2);
      cnt++;
    }
    Console.WriteLine(cnt);
  }
}

Measured memory_bytes: 13268