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

class Program
{
    static void Solve()
    {
        // . -> white, # -> black

        var N = ReadInt();
        var S = Read();

        var whites = new int[N];

        if (S[0] == '.') whites[0]++;

        for (var i = 1; i < N; i++)
        {
            whites[i] = whites[i - 1];
            if (S[i] == '.') whites[i]++;
        }

        var ans = whites[N - 1];
        for (var border = 0; border < N; border++) // end of whites
        {
            var diff = (border - whites[border] + 1) + (whites[N - 1] - whites[border]);
            if (diff < ans) ans = diff;
        }
        Console.WriteLine(ans);
    }

    static void Main(string[] args)
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }

    public static string Read() { return Console.ReadLine(); }
    public static int ReadInt() { return int.Parse(Read()); }
    public static long ReadLong() { return long.Parse(Read()); }
    public static double ReadDouble() { return double.Parse(Read()); }

    public static string[] Reads() { return Console.ReadLine().Split(' '); }
    public static int[] ReadInts() { return Reads().Select(_ => int.Parse(_)).ToArray(); }
    public static long[] ReadLongs() { return Reads().Select(_ => long.Parse(_)).ToArray(); }
    public static double[] ReadDoubles() { return Reads().Select(_ => double.Parse(_)).ToArray(); }
}

Measured memory_bytes: 13216
//#include <bits/stdc++.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int h,w; cin >> h >> w;
    vector<vector<char>> s(h+2,vector<char>(w+2,'#'));
    rep(i,h){
        rep(j,w){
            cin >> s[i+1][j+1];
        }
    }
    

    
    queue<P> que;
    for(int i=1; i<h+1; i++)for(int j=1; j<w+1; j++)if(s[i][j]=='#') que.push(MP(i,j));
    // rep(i,h+2){
    //     rep(j,w+2){
    //         cout<<s[i][j];
    //     }
    //     cout<<endl;
    // }
    int res=-1;
    bool update=true;
    while(update){
        res++;
        update=false;
        int num=que.size();
        rep(i,num){
            P p=que.front(); que.pop();
            rep(j,4){
                if(s[p.F+dy[j]][p.S+dx[j]]=='.'){
                    update=true;
                    s[p.F+dy[j]][p.S+dx[j]]='#';
                    que.push(MP(p.F+dy[j],p.S+dx[j]));
                }
            }
        }
        // rep(i,h+2){
        //     rep(j,w+2){
        //         cout<<s[i][j];
        //     }
        //     cout<<endl;
        // }
        // cout<<endl;
    }
    cout<<res<<endl;

}

Measured memory_bytes: 20440
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* class */
class DisjointSet {
public:
    // d[i] is root => d[i] < 0 & d[i] is the size of tree
    // d[i] is child => d[i] >= 0 & d[i] = i.parent
    vector<int> d;

    DisjointSet() {}
    DisjointSet(int size) : d(size, -1) {}

    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if ( d[x] > d[y] ) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) { return -d[find(x)]; }
};
/* function */
/* main */
int main(){
    int N, M;
    cin >> N >> M;
    vector<int> H(N);
    for (int i = 0; i < N; i++) cin >> H[i];

    vector<vector<int> > deg(N, vector<int>());
    int a, b;
    for (int i = 0; i < M; i++) {
        cin >> a >> b;
        a--, b--;
        deg[a].push_back(b);
        deg[b].push_back(a);
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
        vector<int> d = deg[i];
        bool can = true;
        for (int di : d) {
            if (H[di] >= H[i]) can = false;
        }
        ans += (int)can;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 8828
#include <stdio.h>

int main() {
  int n, cards[52] = {}, i, s, ic;
  char str[1], c;
  scanf("%d", &n);
  for(i = 0; i < n; ++i) {
    scanf("%s%d", str, &s);
    c = str[0];
    ic = 0;
    switch(c) {
      case 'D':
        ic += 13;
      case 'C':
        ic += 13;
      case 'H':
        ic += 13;
    }
    cards[ic + s - 1] = 1;
  }
  for(i = 0; i < 52; ++i) {
    if(!cards[i]) printf("%c %d\n", (char []){'S', 'H', 'C', 'D'}[i / 13], i % 13 + 1);
  }
  return 0;
}

Measured memory_bytes: 596
class UF():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
 
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
 
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
 
        if x == y:
            return
 
        if self.parents[x] > self.parents[y]:
            x, y = y, x
 
        self.parents[x] += self.parents[y]
        self.parents[y] = x
 
    def size(self, x):
        return -self.parents[self.find(x)]
 
    def same(self, x, y):
        return self.find(x) == self.find(y)
 
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
 
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
n,m,k = map(int,input().split())
uf=UF(n)
 
F=[set() for _ in range(n)]
for i in range(m):
   a,b=map(int,input().split())
   uf.union(a-1,b-1)
   F[a-1].add(b-1)
   F[b-1].add(a-1)
 
B=[0]*n
for i in range(k):
    c,d=map(int,input().split())
    if uf.same(c-1,d-1):
        B[c-1]-=1
        B[d-1]-=1
A=[]
for i in range(n):
    A.append(uf.size(i)-len(F[i])+B[i]-1)
print(*A)


Measured memory_bytes: 123552
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, int> pli;
typedef pair<lint, lint> pll;
typedef complex<double> xy_t;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

struct mint{
    using i64=int_fast64_t;
    i64 a;
    static constexpr i64 mod= 1e9+7;
    mint(const i64 a_=0): a(a_){}
    mint inv(){
        i64 t=1, n= mod - 2, x=a;
        while(n){
            if(n&1) (t*=x)%=mod;
            (x*=x)%=mod;
            n>>=1;
        }
        mint ret(t);
        return ret;
    }
    bool operator==(const mint &x){return a==x.a;}
    bool operator!=(const mint &x){return a!=x.a;}
    mint operator+(const mint &x){
        mint ret;
        ret.a=a+x.a;
        if(ret.a>mod) ret.a-=mod;
        return ret;
    }
    mint operator-(const mint &x){
        mint ret;
        ret.a=a-x.a;
        if(ret.a<0) ret.a+=mod;
        return ret;
    }
    mint operator*(const mint &x){
        mint ret;
        ret.a=a*x.a%mod;
        return ret;
    }
    mint operator/(mint &x){
        mint ret;
        ret.a=a*x.inv().a%mod;
        return ret;
    }
    mint operator^(lint n){
        mint ret=1, x=a;
        while(n){
            if(n&1) (ret.a*=x.a)%=mod;
            (x.a*=x.a)%=mod;
            n>>=1;
        }
        return ret;
    }
    mint &operator+=(const mint &x){
        a+=x.a;
        if(a>=mod) a-=mod;
        return *this;
    }
    mint &operator-=(const mint &x){
        a-=x.a;
        if(a<0) a+=mod;
        return *this;
    }
    mint &operator*=(const mint &x){
        (a*=x.a)%=mod;
        return *this;
    }
    mint &operator/=(mint &x){
        (a*=x.inv().a)%=mod;
        return *this;
    }
    mint &operator^=(lint n){
        lint ret=1;
        while(n){
            if(n&1) (ret*=a)%=mod;
            (a*=a)%=mod;
            n>>=1;
        }
        a=ret;
        return *this;
    }
};

vector<mint> fact;
vector<mint> revfact;

void setfact(int n){
    fact.resize(n+1); revfact.resize(n+1);
    fact[0] = 1;
    rep(i, n) fact[i+1] = fact[i] * mint(i+1);

    revfact[n] = fact[n].inv();
    for(int i=n-1; i>=0; i--) revfact[i] = revfact[i+1] * mint(i+1);
}

mint getC(int n, int r){
    if(n<r) return 0;
    return fact[n] * revfact[r] * revfact[n-r];
}

int main(){
    int n;
    scanf("%d", &n);
    mint c[n];
    rep(i, n) scanf("%lld", &c[i].a);
    sort(c, c+n, [](const mint &a, const mint &b){return a.a<b.a;});
    setfact(n);

    mint ans=0;
    rep(i, n){
        int K=n-i-1;
        mint low=mint(4)^i;
        mint high=mint(K+2)*(mint(2)^(2*K));
        ans+=low*c[i]*high;
    }
    printf("%lld\n", ans.a);
}

Measured memory_bytes: 4992
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

ans = b[a[0] - 1]
for i in range(1,n):
     ans += b[a[i] - 1]
     if a[i] == a[i - 1] + 1:
          ans += c[a[i] - 2]
print(ans)


Measured memory_bytes: 3316
#include<iostream>


using namespace std;

int main(void) {
	int size;
	cin >> size;
	int kyu[] = { 400,600,800,1000,1200,1400,1600,1800,2000 };
	for (int i = 0; i < 8; i++) {
		if (kyu[i] <= size&&size < kyu[i + 1])cout << 8 - i;
	}
}

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

if A + K > B - K:
    for num in range(A, B + 1):
        print(num)
else:
    for num in range(A, A + K):
        print(num)
    for num in range(B - K + 1, B + 1):
        print(num)

Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
    int N, a[100];
    int i, j, tmp, AliceSum, BobSum;
    AliceSum = 0;
    BobSum = 0;
    scanf("%d", &N);
    for (i=0; i<N; i++)
    {
        scanf("%d", &a[i]);
    }
    for (i=1; i<N; i++)
    {
        for (j=N-1; j>=i; j--)
        {
            if (a[j] > a[j-1]) {
                tmp = a[j-1];
                a[j-1] = a[j];
                a[j] = tmp;
            }
        }
    }
    for (i=0; i<N; i++)
    {
        if (i%2 == 0) {
            AliceSum += a[i];
        } else {
            BobSum += a[i];
        }
    }
    printf("%d\n", AliceSum - BobSum);
    return 0;
}


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

namespace std {

template<class Fun>
class y_combinator_result {
	Fun fun_;
public:
	template<class T>
	explicit y_combinator_result(T &&fun): fun_(std::forward<T>(fun)) {}

	template<class ...Args>
	decltype(auto) operator()(Args &&...args) {
		return fun_(std::ref(*this), std::forward<Args>(args)...);
	}
};

template<class Fun>
decltype(auto) y_combinator(Fun &&fun) {
	return y_combinator_result<std::decay_t<Fun>>(std::forward<Fun>(fun));
}

} // namespace std

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

	int N, M; cin >> N >> M;
	vector<vector<pair<int, int>>> adj(N+1);
	for (int e = 0; e < M; e++) {
		int x, y; cin >> x >> y;
		adj[x].emplace_back(e, y);
		adj[y].emplace_back(e, x);
	}

	vector<int> depth(N+1, -1);
	vector<int> bridgeParEdge(N+1, -1);
	vector<vector<int>> par(N+1, vector<int>(20, 0));

	vector<pair<int, int>> dir(M); // down by default

	depth[0] = 0;
	y_combinator([&](auto self, int cur = 1, int prv = 0) -> int {
		depth[cur] = depth[prv] + 1;
		par[cur][0] = prv;
		for (int i = 0; par[cur][i]; i++) {
			par[cur][i+1] = par[par[cur][i]][i];
		}
		int lowval = depth[cur];
		for (auto it : adj[cur]) {
			int e = it.first;
			int nxt = it.second;
			if (nxt == prv) continue;

			if (depth[nxt] == -1) {
				dir[e] = {cur, nxt};
				int nlowval = self(nxt, cur);
				if (nlowval == depth[nxt]) {
					bridgeParEdge[nxt] = e;
				}
				lowval = min(lowval, nlowval);
			} else if (depth[nxt] < depth[cur]) {
				dir[e] = {cur, nxt};
				lowval = min(lowval, depth[nxt]);
			}
		}
		return lowval;
	})();

	vector<vector<bool>> mustUp(N+1, vector<bool>(20,0));
	vector<vector<bool>> mustDown(N+1, vector<bool>(20,0));

	int K; cin >> K;
	for (int q = 0; q < K; q++) {
		int a, b; cin >> a >> b;
		for (int i = 0; (1<<i) <= abs(depth[a] - depth[b]); i++) {
			if ((1 << i) & abs(depth[a] - depth[b])) {
				if (depth[a] > depth[b]) {
					mustUp[a][i] = true;
					a = par[a][i];
				} else {
					mustDown[b][i] = true;
					b = par[b][i];
				}
			}
		}
		if (a != b) {
			int i = 0;
			while (par[a][i] != par[b][i]) i++;
			while (i) {
				--i;
				if (par[a][i] != par[b][i]) {
					mustUp[a][i] = true;
					a = par[a][i];
					mustDown[b][i] = true;
					b = par[b][i];
				}
			}
			assert(i == 0);
			mustUp[a][0] = true;
			mustDown[b][0] = true;
		}
	}

	y_combinator([&](auto self, int cur = 1) -> void {
		for (auto it : adj[cur]) {
			int nxt = it.second;
			if (depth[nxt] == depth[cur]+1) {
				self(nxt);
			}
		}
		for (int i = 19; i > 0; i--) {
			if (mustUp[cur][i]) {
				mustUp[cur][i-1] = true;
				mustUp[par[cur][i-1]][i-1] = true;
			}
			if (mustDown[cur][i]) {
				mustDown[cur][i-1] = true;
				mustDown[par[cur][i-1]][i-1] = true;
			}
		}

		if (bridgeParEdge[cur] != -1) {
			int e = bridgeParEdge[cur];
			if (mustUp[cur][0] && mustDown[cur][0]) {
				cout << "No" << '\n';
				exit(0);
			} else if (mustUp[cur][0]) {
				swap(dir[e].first, dir[e].second);
			}
		}
	})();
	cout << "Yes" << '\n';
	for (int e = 0; e < M; e++) {
		cout << dir[e].first << ' ' << dir[e].second << '\n';
	}

	return 0;
}



Measured memory_bytes: 8520
n = int(input())
line = list(map(int, input().split()))
line.sort()
line.reverse()
A = 0
B = 0
for i in range(1,n+1):
  if i % 2 != 0:
    A += line[i-1]
  else:
    B += line[i-1]
print(A-B)

Measured memory_bytes: 9124
#include <stdio.h>
#include <stdlib.h>
int main(void) {
    long long num,day,move,town=1,temp,road[100000]={0},sum=0,i,j;
    scanf("%lld %lld",&num,&day);
    sum=0;
    for (i=0; i<num-1; i++) {
        scanf("%lld",&temp);
        road[i+1]=road[i]+temp;
    }
    for (i=0; i<day; i++) {
        scanf("%lld",&move);
        if (move>0) {
            sum+=road[town+move-1]-road[town-1];
        } else {
            sum+=road[town-1]-road[town+move-1];
        }
        sum%=100000;
        town+=move;
    }
    printf("%lld\n",sum);
    return 0;
}

Measured memory_bytes: 1384
#include <iostream>
#include <iomanip>
#include <bits/stdc++.h>
#include <vector>
#include <iterator>
#include <string>
#define pan(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define vi vector<int>
#define pb push_back
using namespace std;


int main(){
	int n;
	cin>>n;
	int t[n];
	pan(i,n) cin>>t[i];
	ll ans=0;
	for(int i=0;i<n-1;i++){
	    for(int j=i+1;j<n;j++){
	        ans+=(t[i]*t[j]);
	        //cout<<t[i]*t[j]<<"  ";
	    }
	}
	cout<<ans;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

class Main{
    public static void main(String args[])throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while(true){
            String s = br.readLine();
            String[] str = s.split(" ");
            int x = Integer.parseInt(str[0]);
            int y = Integer.parseInt(str[1]);
            if(x==0 && y==0) break;
            if(x>y){
                int i=0;
                i = x;
                x = y;
                y = i;
                System.out.println(x+" "+y);
            }else if(x<y){
                System.out.println(x+" "+y);
            }else if(x==y){
                System.out.println(x+" "+y);
            }
            
        }
    }
}

Measured memory_bytes: 24444
#include<bits/stdc++.h>
using namespace std;
static const int N=100;
enum COLOR{WHITE,GRAY,BLACK};

int n,M[N][N];
int color[N],d[N],f[N],tt;
int nt[N];

int next(int u)
{
    for(int v=nt[u];v<n;v++)
    {
        nt[u]=v+1;
        if(M[u][v])return v;
    }
    return -1;
}
void dfs_visit(int r)
{
    for(int i=0;i<n;i++)
    {
        nt[i]=0;
    }
    stack<int> S;
    S.push(r);
    color[r]=GRAY;
    d[r]=++tt;

    while(!S.empty())
    {
        int u=S.top();
        int v=next(u);
        if(v!=-1)
        {
            if(color[v]==WHITE)
            {
                color[v]=GRAY;
                d[v]=++tt;
                S.push(v);
            }
        }
        else
        {
            S.pop();
            color[u]=BLACK;
            f[u]=++tt;
        }
    }
}
void dfs()
{
    for(int i=0;i<n;i++)
    {
        color[i]=WHITE;
        nt[i]=0;
    }
    tt=0;

    for(int u=0;u<n;u++)
    {
        if(color[u]==WHITE)dfs_visit(u);
    }
    for(int i=0;i<n;i++)
    {
        cout<<i+1<<" "<<d[i]<<" "<<f[i]<<endl;
    }
}

int main()
{
    int u,v,k,i,j;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)M[i][j]=0;
    }

    for(i=0;i<n;i++)
    {
        scanf("%d %d",&u,&k);
        u--;
        for(j=0;j<k;j++)
        {
            scanf("%d",&v);
            v--;
            M[u][v]=1;
        }
    }

    dfs();
 	return 0;
}


Measured memory_bytes: 3272
#include<bits/stdc++.h>
using namespace std;
int n,m;
int a[100005];
int ans,sum,maxx,mmax;
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=n;i>=1;i--)maxx=max(a[i],maxx),sum=max(maxx-a[i],sum);
    for(int i=n; i; i--){mmax=max(a[i],mmax);if(mmax-a[i]==sum)ans++;}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
#include <stack>
#include <functional>
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;
int ketasum(int n) {
	int ans = 0, x = 10, i = 1;
	while (n > 0) {
		ans += ((n % x) / i);
		n -= (n % x);
		x *= 10;
		i *= 10;
	}
	return ans;
}
int main() {
	ll n, m, l, ans = 0, A[101010];
	cin >> n >> m >> l;
	for (int i = 1; i <= n; i++) {
		if (ketasum(i) >= m && ketasum(i) <= l)
			ans += i;
	}
	cout << ans << endl;
	return 0;
}


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

int main(int argc, const char * argv[]) {
    long long n, a;
    vector<long long> v;
    
    long long cnt2, cnt4;
    
    //初期化
    cnt2 = 0;
    cnt4 = 0;
    
    //入力
    cin >> n;
    for (long long i = 0; i < n; i++) {
        cin >> a;
        v.push_back(a);
        if (a % 4 == 0) {           //4の倍数の場合
            cnt4++;
        }else if(a % 2 == 0){       //2の倍数の場合
            cnt2++;
        }
    }
    
    if (n % 2 == 0) {
        if (cnt4 + cnt2 / 2 >= n / 2) {
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        if (cnt4 + cnt2 / 2 >= n / 2 - 1) {
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    
    
    
    return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pii pair<ll,pair<ll,char>>
#define sorted(a_1) sort(a_1.begin(),a_1.end())
#define rsorted(a_1) sort(a_1.rbegin(),a_1.rend())
#define t1(a_1) cout<<a_1<<endl;
#define t2(a_1) for(auto it_test : a_1) cout<<it_test<<" ";
#define MOD 1000000007

ll dp[401][401];
ll topDown(vector<ll>&arr,vector<ll>&pref, int l, int r){
	// if(l>r) return 0;
	// cout<<l<<" "<<r<<endl;
	if(dp[l][r]>-1) return dp[l][r];
	if(r-l==1) return dp[l][r] =  arr[l]+arr[r];
	if(r==l) return dp[l][r] = 0;
	ll ans = 1e18 + 5;
	for(int i=l;i<r;i++){
		ans = min(ans, topDown(arr,pref,l,i) + topDown(arr,pref,i+1,r) + pref[r]-pref[l-1]);
	}
	dp[l][r] = ans;
	return ans;
}
void solve(){
    int n;
    cin>>n;
    vector<ll>arr(n+1),pref(n+1,0);
    for(int i=1;i<=n;i++) cin>>arr[i];
    pref[1] = arr[1];
    for(int i=2;i<=n;i++) pref[i]=pref[i-1] + arr[i];
    memset(dp,-1,sizeof(dp));
    ll ans = topDown(arr,pref,1,n);
    t1(ans)
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    while(t--){
        solve();
    }

return 0;
}

Measured memory_bytes: 4936
#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-1); i >= 0; --i)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

int main(){
    int N, C, K;
    cin >> N >> C >> K;

    vector<int> T(N);
    for (auto &i : T) cin >> i;

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

    ll ans = 1;
    int time = T[0], num = 1;
    for (int i = 1; i < N; ++i) {
        if (num < C && T[i] <= time + K) {
            num++;
        } else {
            ans++;
            time = T[i];
            num = 1;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return int(i)
}

func main() {
	n, m := nextInt(), nextInt()

	a := n + m
	b := n - m
	c := n * m

	fmt.Println(Max(a, b, c))
}

func Max(nums ...int) int {
	if len(nums) == 0 {
		panic("function max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}


Measured memory_bytes: 640
n,k=map(int,input().split())
p=[int(i) for i in input().split()]
d={"r":2,"s":0,"p":1}
T=[d[i] for i in input()]
flag=[True for _ in range(n)]

sum_=0
for i in range(n):
    if i >=k:
        if T[i] == T[i-k] and flag[i-k] :
            flag[i] = False
        else:
            sum_ += p[T[i]]
            
    else:
        sum_ += p[T[i]]
print(sum_)

Measured memory_bytes: 46644
#include <bits/stdc++.h>
using namespace std;
int main(){
	int A, B;
	cin >> A >> B;
	if((A + B) % 2 == 1){
		cout << "IMPOSSIBLE" << endl;
	}else{
		cout << max(A, B) - (abs(A - B) / 2) << endl;
	}
}

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

int main()
{
	int64_t n, m;
	cin >> n >> m;
	vector<int64_t> as(n);
	for (auto &&a : as)
	{
		cin >> a;
	}

	priority_queue<int64_t> pq;
	for (auto &&a : as)
	{
		pq.emplace(a);
	}

	for (int64_t i = 0; i < m; i++)
	{
		int64_t x = pq.top();
		pq.pop();
		pq.emplace(x / 2);
	}

	int64_t ans = 0;
	while (!pq.empty())
	{
		ans += pq.top();
		pq.pop();
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;


int main()
 {
 	long long int n,i,d,s=0,j,e;
 	cin>>n>>d;
 	long long int a[n][2];
 	for(i=0;i<n;i++)
 		for(j=0;j<2;j++)
 			cin>>a[i][j];
 	for(i=0;i<n;i++)
 		{
 		
 				e=(pow(a[i][0],2)+pow(a[i][1],2));
 			if(e<=pow(d,2))
 				s++;
		 }
 	cout<<s<<endl;
 }

Measured memory_bytes: 6708
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>vector<T> vec(int len, T elem) { return vector<T>(len, elem); } // auto dp = vec(52, vec(103, vec(103, INF)));
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<class T>inline int popcount(T a) {return __builtin_popcount(a);}
template<class T>inline T emod(T a, T p) { return (a%p + p) % p;}
//-------------------
int main() {
    cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15);
    int n,x,t; cin >> n >> x >> t;
    cout << t * ((n+(x-1))/x) << endl; 
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
const int INF = 114514810;
const int MOD = 1000000007;
const double EPS = 1e-10;
typedef int weight;
struct edge
{
	int to; weight cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
typedef vector<vector<edge>> Graph;
int dx[] = { -1, 0, 0, 1 }; int dy[] = { 0, -1, 1, 0 };
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
bool valid(int x, int y, int h, int w) { return (x >= 0 && y >= 0 && x < h&&y < w); }
int place(int x, int y, int w) { return w*x + y; }
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

double p, q, a, n;

int solve(int i, int t, int m, double sum)
{
	if (abs(sum - p / q) < EPS)
	{
		return 1;
	}
	if (sum - p / q>EPS || i == n || m*t > a) return 0;
	if (p / q - (sum + 1.0 / t*(n - i)) > EPS) return 0;
	return solve(i, t + 1, m, sum) + solve(i + 1, t, m*t, sum + 1.0 / t);
}


int main()
{
	while (cin >> p >> q >> a >> n, p)
	{
		cout << solve(0, 1, 1, 0.0) << endl;
	}
	return 0;
}

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

int main()
{

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n = 0, w = 0;
    cin >> n >> w;

    const int INF = 1e9 + 5;
    vector<long long> weight(n, 0), value(n, 0);
    for(int i = 0; i < n; i++) cin >> weight[i] >> value[i];
    long long sum = 0;
    for(long long x: value) {
        sum += x;
    }

    vector<long long> dp(sum + 1, INF);


    dp[0] = 0;
    long long a = 0, b = 0;
    for(int i = 0; i < n; i++) {
        for(long long value_so_far = sum - value[i]; value_so_far >= 0; value_so_far--) {
            dp[value_so_far + value[i]] = min(dp[value_so_far + value[i]], dp[value_so_far] + weight[i]);
        }
    } 


    long long ans = 0;
    for(long long i = 0; i < dp.size(); i++) {
        if(dp[i] <= w) ans = max(ans, i);
        // cout << dp[i] << endl;
    }

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

Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;
    
    int A, B;
    io.read(A, B);
    cout << A * B;

    return 0;
}

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

int main () {
    int a,b,c,A[5],B[5],C[5],i;
    for(i=0;i<6;i++)
        cin >> A[i];
    for(i=0;i<6;i++)
        cin >> B[i];
    for(i=0;i<6;i++)
        cin >> C[i];
    a=A[3]*3600+A[4]*60+A[5]-A[0]*3600-A[1]*60-A[2];
    b=B[3]*3600+B[4]*60+B[5]-B[0]*3600-B[1]*60-B[2];
    c=C[3]*3600+C[4]*60+C[5]-C[0]*3600-C[1]*60-C[2];
    cout << a/3600 << " " << (a%3600)/60 << " " << (a%3600)%60 << endl;
cout << b/3600 << " " << (b%3600)/60 << " " << (b%3600)%60 << endl;
cout << c/3600 << " " << (c%3600)/60 << " " << (c%3600)%60 << endl;
}

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

int main(){
int a;
cin >> a;
  while(a>10){
    a = a%10;
  }

  if( a==2 || a==4 || a==5 || a==7 || a==9){
    cout<<"hon"<<endl;}
  else if(a==0 || a==1 || a==6 || a==8){
    cout<<"pon"<<endl;}
  else
    cout<<"bon"<<endl;


} 


Measured memory_bytes: 3596
from bisect import bisect_left, bisect_right

N = int(input())
S = input()

R = []
G = []
B = []

res = 0

for i in range(N):
    if S[i] == 'R':
        R.append(i)
    elif S[i] == 'G':
        G.append(i)
    else:
        B.append(i)

for i in range(1, N - 1):
    if S[i] == 'R':
        res += bisect_left(G, i) * (len(B) - bisect_left(B, i))
        res += bisect_left(B, i) * (len(G) - bisect_left(G, i))
        for j in range(1, min(i, N - i - 1) + 1):
            if S[i - j] == 'G' and S[i + j] == 'B':
                res -= 1
            elif S[i - j] == 'B' and S[i + j] == 'G':
                res -= 1
    if S[i] == 'G':
        res += bisect_left(B, i) * (len(R) - bisect_left(R, i))
        res += bisect_left(R, i) * (len(B) - bisect_left(B, i))
        for j in range(1, min(i, N - i - 1) + 1):
            if S[i - j] == 'B' and S[i + j] == 'R':
                res -= 1
            elif S[i - j] == 'R' and S[i + j] == 'B':
                res -= 1
    if S[i] == 'B':
        res += bisect_left(R, i) * (len(G) - bisect_left(G, i))
        res += bisect_left(G, i) * (len(R) - bisect_left(R, i))
        for j in range(1, min(i, N - i - 1) + 1):
            if S[i - j] == 'G' and S[i + j] == 'R':
                res -= 1
            elif S[i - j] == 'R' and S[i + j] == 'G':
                res -= 1

print(res)

Measured memory_bytes: 76044
class RollingHash:

    def __init__(self, string, root, mod):
        self.root = root
        self.mod = mod
        self.hs = [0] * (len(string) + 1)
        self.pw = [1] * (len(string) + 1)
        for i in range(len(string)):
            self.hs[i + 1] = (self.hs[i] * self.root + ord(string[i])) % self.mod
            self.pw[i + 1] = self.pw[i] * self.root % self.mod

    def get_hash(self, l, r):
        "get the hash of s[l:r] (0 <= l <= r <= len(s))"
        return (self.hs[r] - self.hs[l] * self.pw[r - l]) % self.mod

    def __getitem__(self, index):
        if isinstance(index, slice):
            return self.get_hash(index.start, index.stop)
        else:
            return 0


RHMOD = 2 ** 61 - 1
POSITIVIZER = RHMOD << 20
class RollingHashMOD61:
    """
    MOD == 2 ** 61 - 1
    参考: https://qiita.com/keymoon/items/11fac5627672a6d6a9f6
    """


    def __init__(self, string, root):
        self.root = root
        self.hs = [0] * (len(string) + 1)
        self.pw = [1] * (len(string) + 1)
        for i in range(len(string)):
            tmp = self.hs[i] * self.root + ord(string[i])
            self.hs[i + 1] = tmp >> 61 + (tmp & RHMOD)
            tmp = self.pw[i] * self.root
            self.pw[i + 1] = tmp >> 61 + (tmp & RHMOD)

    def get_hash(self, l, r):
        "get the hash of s[l:r] (0 <= l <= r <= len(s))"
        ret = (self.hs[r] - self.hs[l] * self.pw[r - l] + POSITIVIZER)
        ret = ret >> 61 + (ret & RHMOD)
        return ret

    def __getitem__(self, index):
        if isinstance(index, slice):
            return self.get_hash(index.start, index.stop)
        else:
            return 0
        
if __name__ == "__main__":
    N = int(input())
    S = input()

    MOD = 2 ** 61 - 1
    root = 10000

    rh = RollingHash(S, root, MOD)

    ok = 0
    ng = N
    while ng - ok > 1:
        mid = (ok + ng) // 2
        hashes = dict()
        flg = False
        for i in range(N - mid + 1):
            hashofsub = rh[i:i+mid]
            if hashofsub in hashes:
                if i >= hashes[hashofsub] + mid:
                    flg = True
                    break
            else:
                hashes[hashofsub] = i
        
        if flg:
            ok = mid
        else:
            ng = mid

    print(ok)


Measured memory_bytes: 75944
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,m;
  cin >> n >> m;
  set<int> a;
  REP(i,m){
    int t;
    cin >> t;
    a.insert(t);
  }
  vi dp(n+3,0);
  dp[0] = 1;
  REP(i,n){
    if(a.find(i+1)==a.end()) dp[i+1]+=dp[i],dp[i+1]%=MOD;
    if(a.find(i+2)==a.end()) dp[i+2]+=dp[i],dp[i+2]%=MOD;
  }
  cout << dp[n] << endl;
}


Measured memory_bytes: 5376
from collections import Counter, defaultdict
a = defaultdict(int)
a[0] += 1
s = input()[::-1]
cur = 0
for i, x in enumerate(s):
    cur += (int(x)*pow(10, i, 2019))%2019
    cur %= 2019
    a[cur] += 1

def comb(a):
    return a*(a-1)//2

ans = 0
for x in a.values():
    if x >= 2:
        ans += comb(x)
print(ans)

Measured memory_bytes: 9664
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
//i64 mod = 998244353;
int int_max = 2147483647;
i64 INF = 1e16;
int max_n = 1e5;


int main(int argc, char **argv) {
    i64 n;
    cin >> n;

    vector<i64> v(n+1,0), money(n+1,0), stock(n+1,0);
    for (int i=1; i<=n; ++i) {
        cin >> v[i];
    }

    money[0]=1000;
    for (int i=1; i<=n-1; ++i) {


        if (v[i] < v[i+1]) {
            money[i] = money[i-1] + stock[i-1] * v[i];
            stock[i] = money[i] / v[i];
            money[i] = money[i] % v[i];
        } else {
            money[i] = money[i-1] + stock[i-1] * v[i];
            stock[i] = 0;
        }
    }

    money[n] = money[n-1] + stock[n-1] * v[n];

    cout << money[n] << endl;

    return 0;
}

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

using namespace std;

int main(){
    
    int H, N;
    cin>>H>>N;
    int tot_attack=0;
    
    for (int i=0; i<N; i++){
        int temp=0;
        cin>>temp;
        tot_attack+=temp;
    }
    if (tot_attack>=H){ cout<<"Yes\n";}
    else {cout<<"No\n";}
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#include <cassert>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define Cout(x) cout << x << endl;
#define check(v) rep(i,v.size()) cout << v[i] << endl;
#define vint(x) vector<int> x
#define vll(x) vector<long long> x
#define vstr(x) vector<string> x
const long long LLINF = 1LL<<60;
const int INF = 1e9;
const long long MOD = 1000000007;
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; }
typedef long long ll;
#define pint pair<int,int>
#define pll pair<ll,ll>
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a, b; cin >> a >> b;
    for(int i = 1; i <= 1500;i++) {
        if(int(i*0.08)==a && int(i*0.1)==b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;

    return 0;
}

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

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

    string S[110];

    for(int i = 0; i < N; i++) cin >> S[i];

    sort(S, S + N);

    string ans;
    for (int i = 0; i < N; i++)
    {
        ans += S[i];
    }
    
    cout << ans << endl;

    return 0;
}

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

int main() {
  int K;
  std::cin >> K;
  int val = 1, ans = -1;
  if (K % 2 == 0 || K % 5 == 0) {
    std::cout << -1 << std::endl;
    return 0;
  } else if (K % 7 == 0) {
    K /= 7;
  }

  for (int i = 0; i < 10000000; ++i) {
    if (val % K == 0) {
      ans = i + 1;
      break;
    }
    val = (val % K) * 10 + 1;
  }

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


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

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	char c;
	cin >> c;
	if (c >= 'a' && c <= 'z') cout << 'a'; else cout << 'A';
	return 0;
}

Measured memory_bytes: 3624
/*
  AOJ 1345
  Title:Bit String Reordering
  @kankichi573
*/
#include <stdio.h>
#include <string.h>

#define max(x,y) (((x)>(y))?(x):(y))
#define min(x,y) (((x)<(y))?(x):(y))
int M,N;
char b[15];
char b1[15];
int  p[15];
int  p1[15];

int solve(char bit[],int runlen[],int len,int runlenlen,char start)
{
  int pos;
  char *p;

  if(len==1)
    return(0);
  if(runlen[0]==0)
    return(solve(bit,runlen+1,len,runlenlen-1,start=='1'?'0':'1'));
  if(len==2)
    {
      if(bit[0]==start)
	return(0);
      else
	return(1);
    }
  else if(bit[0]==start)
    {
      runlen[0]--;
      return(solve(bit+1,runlen,len-1,runlenlen,start));
    }
  else if(start=='0')
    {
      p = strchr(bit,'0');
      pos =  p - bit;
      runlen[0]--;
      *p='1';
      return(pos+solve(bit+1,runlen,len-1,runlenlen,start));
    }
  else if(start=='1')
    {
      p = strchr(bit,'1');
      pos =  p - bit;
      runlen[0]--;
      *p='0';
      return(pos+solve(bit+1,runlen,len-1,runlenlen,start));
    }
}

main()
{
  int i,ret,c1,ce,ret1,ret2;
  
  scanf("%d %d ",&N,&M);

  for(i=c1=0;i<N;i++)
    {  
      scanf("%c ",&b[i]);
      if(b[i]=='1')
	c1++;
    }
  for(i=ce=0;i<M;i++)
    {
      scanf("%d",&p[i]);
      if((i & 1)==0)
	ce += p[i];
    }

    if(c1*2==N)
    {
      memcpy(b1,b,sizeof(b));
      memcpy(p1,p,sizeof(p));
      ret1=solve(b,p,N,M,'1');
      ret2=solve(b1,p1,N,M,'0');
      ret=min(ret1,ret2);
    }
  else if (ce==c1)
    ret=solve(b,p,N,M,'1');
  else
    ret=solve(b,p,N,M,'0');
  

  printf("%d\n",ret);
  
  return(0);
}

Measured memory_bytes: 600
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int a = sc.nextInt();
      	int b = sc.nextInt();
      	int[] result = {a+b, a-b, a*b};
      	Arrays.sort(result);
      	System.out.println(result[2]);
    }
}

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

namespace Miscelleneous {
   class Program {
      static Dictionary<char,string> Encode0 = new Dictionary<char,string>() 
      { { ' ',"101" },{'\'',"000000"},{',',"000011" },{'-',"10010001" },{'.',"010001" },{ '?',"000001"}
      };
      static void Main(string[] args) {
         string[] alphaomega = { "100101","10011010",
         "0101","0001","110","01001","10011011","010000","0111","10011000",
         "0110","00100","10011001","10011110","00101","111","10011111","1000",
         "00110","00111","10011100","10011101","000010","10010010","10010011","10010000"
         };
         for (int i=0;i<alphaomega.Length;i++) Encode0.Add((char)(i+65),alphaomega[i]);
         StringBuilder sb = new StringBuilder();
         List<char> Res = new List<char>();
         
         int j;
         string s1;
         int k;
         while (true) {
            string s = Console.ReadLine();
            if (string.IsNullOrEmpty(s)) return;
            foreach (char c in s) sb.Append(Encode0[c]);
            if (sb.Length%5!=0) sb.Append(new string('0',5-sb.Length%5));
            string ss = sb.ToString();
            for (j=0; 5*j<sb.Length; j++) { 
               s1=new string(ss.Skip(5*j).Take(5).ToArray());
               k=Convert.ToInt32(s1,2);
               Res.Add(Encode1(k));
            }
            Console.WriteLine(new string(Res.ToArray()));
            Res.Clear();sb.Remove(0,sb.Length);
         }
      }
      
      static char[] Symbols1 = { ' ','.',',','-','\'','?'};
      static char Encode1(int h) {
         return h<=25 ? (char)(h+65) : Symbols1[h-26];
      }
   }
}

Measured memory_bytes: 10040
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int S = sc.nextInt();
		int s = S % 60;
		S /= 60;
		int m = S % 60;
		int h = S / 60;
		System.out.println(h + ":" + m + ":" + s);
	}
}

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

int main(){

  string a[4] ={"dream", "dreamer", "erase", "eraser"};
  string S;
  cin >> S;
  reverse(S.begin(),S.end());
  for(int i=0; i<4; i++) reverse(a[i].begin(), a[i].end());

  bool flg2 = 1;
  for(int i=0; i<S.size();) {
    bool flg=0;
  	for(int j=0; j<4; j++){
    	string d = a[j];
      	if(S.substr(i,d.size()) == d){
        	i += d.size();
          	flg = 1;
        }
    }
    if(flg != 1){
    	flg2 = 0;
      	break;
    }
  }
     if(flg2 == 1){
     	cout << "YES" << endl;
     }
  	else {
    	cout << "NO" << endl;
    
    }
      
}

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

int cmp(const void* x,const void* y) {
	if(*((int*)x)>*((int*)y))return 1;
	if(*((int*)x)<*((int*)y))return -1;
	return 0;
}

int main(void) {
	int taroumoratta[200];
	int tarou[100];
	int hanako[100];
	int n;
	int i;
	int kazu;
	int ba;
	while(1) {
		scanf("%d",&n);
		if(n==0)break;
		for(i=0;i<200;i++)taroumoratta[i]=0;
		for(i=0;i<n;i++) {
			scanf("%d",&tarou[i]);
			taroumoratta[tarou[i]-1]=1;
		}
		kazu=0;
		for(i=0;i<n*2;i++) {
			if(!taroumoratta[i]) {
				hanako[kazu]=i+1;
				kazu++;
			}
		}
		qsort(tarou,n,sizeof(int),cmp);
		qsort(hanako,n,sizeof(int),cmp);
		ba=0;
		while(1) {
			/*¾YÌÔ*/ 
			for(i=0;i<n;i++) {
				if(tarou[i]>ba) {
					ba=tarou[i];
					tarou[i]=0;
					break;
				}
			}
			if(i>=n)ba=0;
			for(i=0;i<n;i++) {
				if(tarou[i]!=0)break;
			}
			if(i>=n)break;
			/*ÔqÌÔ*/
			for(i=0;i<n;i++) {
				if(hanako[i]>ba) {
					ba=hanako[i];
					hanako[i]=0;
					break;
				}
			}
			if(i>=n)ba=0;
			for(i=0;i<n;i++) {
				if(hanako[i]!=0)break;
			}
			if(i>=n)break;
		}
		kazu=0;
		for(i=0;i<n;i++) {
			if(hanako[i])kazu++;
		}
		printf("%d\n",kazu);
		kazu=0;
		for(i=0;i<n;i++) {
			if(tarou[i])kazu++;
		}
		printf("%d\n",kazu);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
vector<int>vt;
set<int>st;
map<int,int>mp;
unordered_map<string,int> umap; 
const long long MAX = 1e5;
const long long INF = 1e9;
const double pi = acos(-1);


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int r;
  cin>>r;
  cout<<2*pi*r<<endl;

    
   return 0;
}

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

using namespace std;

#define sqr(x) ((x) * (x))
#define pb push_back
#define mp make_pair
#define ins insert
#define er erase
#define bg begin()
#define ed end()
#define f first
#define s second
#define fin(name) freopen(name, "r", stdin)
#define fout(name) freopen(name, "w", stdout)
#define files(name) fin(name".in"); fout(name".out")
#define enter cout << "\n"
#define space cout << " "
#define endl "\n"
#define fi(st,n) for (int i = (st); i <= (n); ++i)
#define fj(st,n) for (int j = (st); j <= (n); ++j)
#define fk(st,n) for (int k = (st); k <= (n); ++k)
#define fq(st,n) for (int q = (st); q <= (n); ++q)
#define fw(st,n) for (int w = (st); w <= (n); ++w)
#define ff(i, st, n) for (int (i) = (st); (i) <= (n); ++(i))
#define ei(st,n) for (int i = (st); i >= (n); --i)
#define ej(st,n) for (int j = (st); j >= (n); --j)
#define ek(st,n) for (int k = (st); k >= (n); --k)
#define ef(i, st, n) for (int (i) = (st); (i) >= (n); --(i))
#define ri(st,n) for (int i = (st); i < (n); ++i)
#define rj(st,n) for (int j = (st); j < (n); ++j)
#define rk(st,n) for (int k = (st); k < (n); ++k)
#define rq(st,n) for (int q = (st); q < (n); ++q)
#define rf(i, st, n) for (int (i) = (st); (i) < (n); ++(i))
#define clean(a) memset((a),0,sizeof (a))
#define sync ios_base::sync_with_stdio(0);cin.tie(0)
#define y1 dsklmlvmd

typedef long long ll;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int inf = (int)1e9;
const dbl eps = (dbl) 1e-8;
const int mod = (int) 1e9 + 7;
const int maxn = (int) 1e5 + 5;
//const dbl M_PI = (dbl)2 * (dbl)acos(0);

//cout<<fixed<<setprecision(10);
//srand(time(0));

int a[maxn];
int ans, st;

int main() {
//    fin("t.in");
    sync;
    int n;
    cin >> n;
    fi(1, n) {
        cin >> a[i];
    }
    ans = 0;
    st = -1;
    fi(1, n) {
        st = i;
        ++ans;
        while (i <= n && a[i] == a[st])
            ++i;
        if (i > n)
            break;
        if (a[i] < a[st]) {
            while (i < n && a[i + 1] <= a[i])
                ++i;
        } else {
            while (i < n && a[i + 1] >= a[i])
                ++i;

        }
    }
    cout << min(ans, ans) << endl;
    return 0;
}

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

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
  int x, ans = 0;
  cin >> x;
  while(x > 0)
  {
    x -= ++ans;
  }
  cout << ans << "\n";
	return 0;
}



Measured memory_bytes: 256