akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <queue>
#include <algorithm>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const ll inf=(ll)1<<60;
const ll mininf=(ll)1<<50;
const double pi=acos(-1);

class Graph{
	private:
	vvi Gpro;
	vector<vector<ll> > Gd;
	vvp Glist;
	int GV,GE;
	public:
	Graph(int x,int y,bool z){
		GV=x;
		GE=y;
		Gd=vector<vector<ll> >(x,vector<ll>(x,inf));
		if(z) Gpro=vvi(x,vi(x,inf));
		else Glist=vvp(x);
	}
/*	void Gpro_add(int x,int y,int z){
		Gpro[x][y]=z;
	}
	void Glist_add(int x,int y,int z){
		Glist[x].push_back(P(y,z));
	}*/
	void Gd_add(int x,int y,int z){
		Gd[x][y]=z;
	}
	ll open(int x,int y){
		return Gd[x][y];
	}
/*	void DIJplus(int x){
		priority_queue<P> que;
		Gd[x][x]=0;
		que.push(P(0,x));
		while(!que.empty()){
			P p=que.top();
			p.first*=-1;
			que.pop();
			int v=p.second;
			if(Gd[x][v]<p.first) continue;
			for(int i=0;i<Glist[v].size();i++){
				P e=Glist[v][i];
				if(Gd[x][e.first]>Gd[x][v]+e.second){
					Gd[x][e.first]=Gd[x][v]+e.second;
					que.push(P(-1*Gd[x][e.first],e.first));
				}
			}
		}
	}
	void BELLMAN(int x){
		Gd[x][x]=0;
		while(1){
			bool update=1;
			for(int i=0;i<GV;i++){
				for(int j=0;j<Glist[i].size();j++){
					P e=P(Glist[i][j].first,Glist[i][j].second);
					if(Gd[x][i]!=inf&&Gd[x][e.first]>Gd[x][i]+e.second){
						Gd[x][e.first]=Gd[x][i]+e.second;
						update=0;
					}
				}
			}
			if(update) break;
		}
	}
	bool FNL(int x){
		Gd[x][x]=0;
		for(int i=0;i<GV;i++){
			for(int j=0;j<GV;j++){
				for(int k=0;k<Glist[j].size();k++){
					P e=P(Glist[j][k].first,Glist[j][k].second);
					if(Gd[x][j]!=inf&&Gd[x][e.first]>Gd[x][j]+e.second){
						Gd[x][e.first]=Gd[x][j]+e.second;
						if(i==GV-1) return 1;
					}
				}
			}
		}
		Gd=vvi(GV,vi(GV,inf));
		return 0;
	}*/
	void WARSHALL(){
		for(int i=0;i<GV;i++) Gd[i][i]=0;
		for(int i=0;i<GV;i++){
			for(int j=0;j<GV;j++){
				for(int k=0;k<GV;k++) Gd[j][k]=min(Gd[j][k],Gd[j][i]+Gd[i][k]);
			}
		}
	}
/*	int PRIM(){
		int Gans=0;
		vi mincost(GV,inf);
		vector<bool> used(GV,1);
		mincost[0]=0;
		while(1){
			int v=-1;
			for(int i=0;i<GV;i++){
				if(used[i]&&(v==-1||mincost[i]<mincost[v])) v=i;
			}
			if(v==-1) break;
			used[v]=0;
			Gans+=mincost[v];
			for(int i=0;i<GV;i++){
				mincost[i]=min(mincost[i],Gpro[v][i]);
			}
		}
		return Gans;
	}*/
};

int V,E;

int main(){
	cin>>V>>E;
	Graph gra(V,E,0);
	for(int i=0;i<E;i++){
		int s,t,d;
		cin>>s>>t>>d;
		gra.Gd_add(s,t,d);
	}
	gra.WARSHALL();
	for(int i=0;i<V;i++){
		if(gra.open(i,i)<0){
			cout<<"NEGATIVE CYCLE"<<endl;
			return 0;
		}
	}
	for(int i=0;i<V;i++){
		for(int j=0;j<V-1;j++){
			if(gra.open(i,j)>=mininf) cout<<"INF"<<' ';
			else cout<<gra.open(i,j)<<' ';
		}
		if(gra.open(i,V-1)>=mininf) cout<<"INF"<<endl;
		else cout<<gra.open(i,V-1)<<endl;
	}
	return 0;
}

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

using namespace std;

int main(void) {
    int n, m, k;
    cin >> n >> m >> k;
    vector<bool> a(n * m + 1);

    for (int i = 0; i <= n * m; i++) a[i] = false;

    for (int i = 0; i <= n / 2; i++) {
        for (int j = 0; j <= m / 2; j++) {
            int p = m * i + n * j - 2 * i * j;
            a[p] = a[n * m - p] = true;
        }
    }

    cout << (a[k] ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=200015;
int k;
int c[N],n;
int b[N];
struct data{
	long long val; int num;
}sum[N];
inline bool cmp(data a,data b){
	return a.val<b.val||(a.val==b.val&&a.num<b.num);
}
inline int lowbit(int x){
	return x&(-x);
}
inline void change(int i){
	int j=i;
	while (j<=n){
		c[j]++;
		j+=lowbit(j);
	}
}
inline int getsum(int i){
	int zs=0; int j=i;
	while (j){
		zs+=c[j]; //out<<j<<endl;
		j-=lowbit(j);
	}
	return zs;
}
inline int read()//读入一个正数 
{
	int a=0;char ch=getchar();
	while(ch<'0'||ch>'9')ch=getchar();
	a=a*10+ch-'0';
	ch=getchar();
	while(ch>='0'&&ch<='9')
	{
		a=a*10+ch-'0';
		ch=getchar();
	}
	return a;
}
inline long long check(int x){
	for(int i=1;i<=n;i++)b[i]=read()-x;
	for(int i=1;i<=n;i++){sum[i].val=sum[i-1].val+b[i];sum[i].num=i;c[i]=0;}
	sort(&sum[1],&sum[n+1],cmp);
	long long zs=0;
	for(int i=1;i<=n;i++){
		if(sum[i].val>=0)zs++; 
		zs+=getsum(sum[i].num);//cout<<zs<<endl;
		change(sum[i].num);
	}
	return zs;
}
int main(){
	scanf("%d%d",&n,&k); 
	cout<<check(k)<<endl;
}

Measured memory_bytes: 4992
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
#include <cstdio>
using namespace std;
int main(int argc, char const *argv[]) {
int N;
cin>>N;
map<unsigned long long,unsigned long long> a;
vector <unsigned long long> a_list;
for(size_t i=0;i<N;i++){
  unsigned long long temp=0;
  cin>>temp;
  a[temp]++;
  if(a[temp]==1) a_list.push_back(temp);
}
sort(a_list.begin(),a_list.end());

if(a.empty()) {cout<<0<<endl;}
else{
  unsigned long long ans=0;

  for(size_t i=0;i<a_list.size();i++){
    if(a[a_list[i]]>=a_list[i]){
      ans+=a[a_list[i]]-a_list[i];
    }else{
      ans+=a[a_list[i]];

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


Measured memory_bytes: 7028
[n, d] = [int(i) for i in input().split()]
x = [[int(i) for i in input().split()] for j in range(n)]

cnt = 0
for i in range(n):
    for j in range(i + 1, n):
        r = sum([(x[i][k] - x[j][k]) ** 2 for k in range(d)])
        for k in range(130):
            if (r == k ** 2):
                cnt += 1
                break

print(cnt)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  ios_base::sync_with_stdio(false);
  cout.tie(NULL);
  cin.tie(NULL);
  ll i, n, flag = 0;
  cin >> n;
  vector<vector<ll> >A(n, vector<ll>(2));
  for (i = 0; i < n; i++)
  {
    cin >> A[i][0] >> A[i][1];
  }
  for (i = 0; i + 2 < n; i++)
  {
    if ((A[i][0] == A[i][1]) && (A[i + 1][0] == A[i + 1][1]) && (A[i + 2][0] == A[i + 2][1]))
    {
      flag = 1;
      break;
    }
  }
  if (flag == 1)
    cout << "Yes";
  else
    cout << "No";
  return (0);
}


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

namespace _0039
{
    public class Program

    {
        public static void Main(string[] args)
        {
            Dictionary<char, int> roman = new Dictionary<char, int>()
            {
                 {'I',1}
                ,{'V',5}
                ,{'X',10}
                ,{'L',50}
                ,{'C',100}
                ,{'D',500}
                ,{'M',1000}
            };

            while (true)
            {
                string line = Console.ReadLine();
                if (string.IsNullOrEmpty(line)) return;

                int res = 0;
                for (int i = 0 ; i < line.Length - 1 ; i++)
                {
                    if(roman[line[i]] < roman[line[i + 1]]) res -= roman[line[i]];
                    else res += roman[line[i]];

                }
                res += roman[line[line.Length - 1]];
                Console.WriteLine(res);
            }

        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



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

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

  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }

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

  int sum = 0;
  for (int i = 0; i < K; i++) {
    sum += vec.at(i);
  }

  cout << sum << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int A[200010], B[200010];
    rep(i, N) cin >> A[i] >> B[i];
    sort(A, A + N); sort(B, B + N);
    if(N % 2 == 0) {
        int lower = A[N / 2] + A[N / 2 - 1];
        int upper = B[N / 2] + B[N / 2 - 1];
        //cout << lower << " " << upper << endl;
        cout << upper - lower + 1 << endl;
    } else {
        int lower = A[N / 2];
        int upper = B[N / 2];
        //cout << lower << " " << upper << endl;
        cout << upper - lower + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 5208
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<list>
#include<numeric>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;
using namespace std;
template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
ll frac(ll n)
{
	if (n == 0) {
		return 1;
	}
	return (n * frac(n - 1)) % MOD;
}

/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/
int main() {
	ll N, A, B;
	ll ans = 0;
	ll x=0;
	cin >> N >> A >> B;
	for (ll u = 1;u <= N;u++) {
		x = 0;
		ll k = u;
		for (int i = 0;i <= 5;i++) {
			x += k%10;
			k /= 10;
		}
		if (x >= A && x <= B) ans += u;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;


int main() {
    int n, a, b, c;
    cin >> n >> a >> b >> c;
    vector<string> s(n), ans(n);
    rep(i, n)cin >> s[i];
    rep(i, n){
        if(s[i] == "AB"){
            if(a < b){
                a++;
                b--;
                ans[i] = "A";
            }
            else if(b < a){
                b++;
                a--;
                ans[i] = "B";
            }
            else{
                if(a == 0){cout << "No" << endl; return 0;}
                if(i == n-1)ans[i] = "A";
                if(s[i+1].find("A") != string::npos){
                    a++;
                    b--;
                    ans[i] = "A";
                }
                else{
                    b++;
                    a--;
                    ans[i] = "B";
                }
            }
        }
        if(s[i] == "AC"){
            if(a < c){
                a++;
                c--;
                ans[i] = "A";
            }
            else if(c < a){
                c++;
                a--;
                ans[i] = "C";
            }
            else{
                if(a == 0){cout << "No" << endl; return 0;}
                if(i == n-1)ans[i] = "A";
                if(s[i+1].find("A") != string::npos){
                    a++;
                    c--;
                    ans[i] = "A";
                }
                else{
                    c++;
                    a--;
                    ans[i] = "C";
                }
            }
        }
        if(s[i] == "BC"){
            if(b < c){
                b++;
                c--;
                ans[i] = "B";
            }
            else if(c < b){
                c++;
                b--;
                ans[i] = "C";
            }
            else{
                if(b == 0){cout << "No" << endl; return 0;}
                if(i == n-1)ans[i] = "B";
                if(s[i+1].find("B") != string::npos){
                    b++;
                    c--;
                    ans[i] = "B";
                }
                else{
                    c++;
                    b--;
                    ans[i] = "C";
                }
            }
        }
    }
    cout << "Yes" << endl;
    rep(i, n)cout << ans[i] << endl;
}   

Measured memory_bytes: 9588
from itertools import (
    accumulate,  # 累積和のイテレータ
    groupby,  # 値をkey,同じ値の集まりをgroup
    permutations,  # 順列
    combinations,  # 組み合わせ
    product,  # 重複あり順列（直積, 深いネストにも使える）
    combinations_with_replacement,  # 重複あり組み合わせ
)

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

def check(i, j, k):
    if i != j and j != k and k != i:
        maxi = max(i, j, k)
        total = i + j + k
        return maxi < total - maxi
    else:
        return 0


cnt = 0
for i, j, k in combinations(L, 3):
    cnt += check(i, j, k)

print(cnt)

Measured memory_bytes: 9104
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
//#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define mp make_pair
vector<char>v;
string ans;
void dfs(int index,string res,int sum){
    if(res.size()==0){
        sum+=v[0]-'0';
        res.push_back(v[0]);
        dfs(index+1,res+"+",sum);
        dfs(index+1,res+"-",sum);
        return;
    }else if(index==4){
        if(sum==7)ans=res;
        return;
    }
    if(res[(int)res.size()-1]=='+'){
        sum+=v[index]-'0';
        res.push_back(v[index]);
        dfs(index+1,res+"+",sum);
        dfs(index+1,res+"-",sum);
    }else{
        sum-=v[index]-'0';
        res.push_back(v[index]);
        dfs(index+1,res+"+",sum);
        dfs(index+1,res+"-",sum);
    }
    
}
signed main(){
    vector<char>temp(4);
    rep(i,4)cin>>temp[i];
    v=temp;
    string t;
    dfs(0,t,0);
    rep(i,ans.size()-1)cout<<ans[i];
    cout<<"=7";
    cout<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,m,M=1000010,i,j,a[50];
  char p[1000010]={1,1};
  for(i=2;i*i<M;i++){
    if(p[i])continue;
    for(j=i*i;j<M;j+=i)p[j]=1;
  }
  while(scanf("%d %d",&n,&m),n||m){
    for(i=0;i<n;i++)scanf("%d",&a[i]);
    int d[1000010]={1};
    for(i=0;i<m;i++){
      if(d[i]==0)continue;
      for(j=0;j<n;j++){
	if(i+a[j]<=m)d[i+a[j]]=1;
      }
    }
    for(i=m;i>0&&p[i]||d[i]==0;i--);
    i?printf("%d\n",i):printf("NA\n");
  }
  return 0;
}

Measured memory_bytes: 5504
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cmath>
#include<vector>
#include<string>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#pragma GCC target("avx")
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC diagnostic error "-std=c++14"

#define isNum(a) (a>='0'&&a<='9')
#define SP putchar(' ')
#define EL putchar('\n')
#define ri register int

template<class T>
inline void in(T&);
template<class T>
inline void out(const T&);

typedef long long ll;
using std::min;
using std::max;
using std::abs;
using std::sort;
using namespace std;

char s[100005];
int ans,l;

int main()
{
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    in(l);
    scanf("%s",s+1);
    for (ri i=1;i<=l;++i) if (s[i]!=s[i-1]) ++ans;
    out(ans);EL;
    return 0;
}

template<class T>
void in(T &Re)
{
    T k=0;
    char ch=getchar();
    int flag=1;
    while (!isNum(ch))
	{
        if (ch=='-')
		{
            flag=-1;
        }
        ch=getchar();
    }
    while (isNum(ch))
	{
        k=(k<<1)+(k<<3)+ch-'0';
        ch=getchar();
    }
    Re=flag*k;
}

template<class T>
void out(const T &Wr)
{
    if (Wr<0)
	{
        putchar('-');
        out(-Wr);
    }
	else
	{
        if (Wr<10)
		{
            putchar(Wr+'0');
        }
		else
		{
            out(Wr/10);
            putchar((Wr%10)+'0');
        }
    }
}




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

import javax.lang.model.util.ElementScanner6;

 
public class Main{
   public static void main(String[] args) {
      MyScanner sc = new MyScanner();
      out = new PrintWriter(new BufferedOutputStream(System.out));
      String s=sc.next();

      int l=s.charAt(s.length()-1)-'0';

      if(l==0 || l==1 || l==6 || l==8){
          out.println("pon");
      }else if(l==3){
          out.println("bon");
      }else{
          out.println("hon");
      }

      
      out.close();
   }

   //-----------PrintWriter for faster output---------------------------------
   public static PrintWriter out;
      
   //-----------MyScanner class for faster input----------
   public static class MyScanner {
      BufferedReader br;
      StringTokenizer st;
 
      public MyScanner() {
         br = new BufferedReader(new InputStreamReader(System.in));
      }
 
      String next() {
          while (st == null || !st.hasMoreElements()) {
              try {
                  st = new StringTokenizer(br.readLine());
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
          return st.nextToken();
      }
 
      int nextInt() {
          return Integer.parseInt(next());
      }
 
      long nextLong() {
          return Long.parseLong(next());
      }
 
      double nextDouble() {
          return Double.parseDouble(next());
      }
 
      String nextLine(){
          String str = "";
	  try {
	     str = br.readLine();
	  } catch (IOException e) {
	     e.printStackTrace();
	  }
	  return str;
      }
   }
}

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

int main() {
int N;
string S;
cin >> N >> S;
for(int i=0; i<S.size(); i++){
  S[i] = (S[i] - 'A' + N) %26 +'A';
 }
  cout << S << endl; 
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define INF 1e9
#define eps 1e-6
typedef long long ll;
using namespace std;

inline int max(int a, int b){
	return a > b ? a : b;
}

inline int min(int a, int b){
	return a < b ? a : b;
}

ll gcd(ll a, ll b){
	if(!b) return a;
	return gcd(b, a % b);
}

ll aa, bb;

int main(){

	cin >> aa >> bb;
	cout << aa / gcd(aa, bb) * bb << endl;

	return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll N;
    cin >> N;
    vector<P> A(N);
    rep(i, N) {
        ll a;
        cin >> a;
        A[i] = make_pair(a, i);
    }
    sort(A.rbegin(), A.rend());
    vector<vector<ll>> dp(N + 1, vector<ll>(N + 1, 0));
    rep(k, N) {
        P p = A[k];
        rep(j, k + 1) {
            ll i = k - j;
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + p.first * abs(p.second - i));
            dp[i][j + 1] = max(dp[i][j + 1], dp[i][j] + p.first * abs(p.second - (N - 1 - j)));
        }
    }
    ll ans = 0;
    rep(i, N + 1) {
        ans = max(ans, dp[i][N - i]);
    }
    cout << ans << '\n';
}

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


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


def solve(r: int):
    print(3*(r**2))
    return


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/abc076/tasks/abc076_c

int main() {
    string S; cin >> S;
    string T; cin >> T;

    if (S.length() < T.length()) {
        cout << "UNRESTORABLE" << "\n";
        return 0;
    }

    string ans = "~";
    REP(i, S.length() - T.length() + 1) {
        string sub = S.substr(i, T.length());

        bool can = true;
        REP(j, sub.length()) {
            if (sub[j] != T[j] && sub[j] != '?') can = false;
        }

        if (can) {
            string P = S;
            REP(j, T.length()) {
                P[i+j] = T[j];
            }
            REP(j, S.length()) {
                if (P[j] == '?') P[j] = 'a';
            }
            ans = std::min(ans, P);
        }
    }

    if (ans == "~") {
        cout << "UNRESTORABLE" << "\n";
    } else {
        cout << ans << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

import math

numbers = input().split(" ")
n = int(numbers[0])
d = int(numbers[1])

result = 0

for i in range(n):
    numbers = input().split(" ")
    x = int(numbers[0])
    y = int(numbers[1])
    if math.sqrt(x ** 2 + y ** 2) <= d:
        result += 1

print(result)

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

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int a = s.nextInt(), b = s.nextInt(), c = s.nextInt();
		int[] t = new int[] {a, b, c};
		Arrays.sort(t);
		if( (t[0] == t[1] && t[1] != t[2]) || (t[2] == t[1] && t[1] != t[0])) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21844
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  double sum=0,a;
  int N;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> a;
    sum+=1/a;
  }
  printf("%.6lf\n",1/sum);
  return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad

frame :: Int -> Int -> String
frame h w =
    unlines $ topOrBottom w : replicate (h - 2) (middle w) ++ [topOrBottom w]

topOrBottom :: Int -> String
topOrBottom w = replicate w '#'

middle :: Int -> String
middle w = '#' : replicate (w - 2) '.' ++ "#"

main :: IO ()
main = do
    xss <- fmap (fmap read . words) . lines <$> getContents :: IO [[Int]]
    forM_ (takeWhile (/= [0, 0]) xss) $ \[h, w] -> do
        putStrLn $ frame h w



Measured memory_bytes: 4300
import fractions
import sys
from functools import reduce
import math

input = sys.stdin.readline


def main():
    r, g, b, n = input_list()
    ans = 0
    for x in range(n+1):
        for y in range(n+1):
            z = n - (x*r) - (y*g)
            if z < 0:
                continue
            if z % b != 0:
                continue
            ans += 1
    print(ans)


def get_camulative(l):
    import itertools
    # 累積和
    return [0] + list(itertools.accumulate(l))

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


def input_list():
    return list(map(int, input().split()))


def input_list_str():
    return list(map(str, input().split()))


def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def gcd(*numbers):
    return reduce(fractions.gcd, numbers)


def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


if __name__ == "__main__":
    main()


Measured memory_bytes: 66924
#include <iostream>
#include <string>
#include <math.h>
using namespace std;

int main (){
    string s;
    int x = 700;
    cin >> s;
    for(int i=0;i<s.length();i++){
        if(s[i]=='o'){
            x+=100;
        }
    }
    cout << x;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int n; scanf ("%d",&n); long long a = 0;
  for (int i=1;i<=n;i++){
if (i % 3 == 0 ||  i % 5 == 0);
    else a += i;
  }
  printf ("%lld\n",a);
return 0;
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    string s;
    cin >> s;
    int absum = 0;
    int bsum = 0;
    rep(i, 0, n) {
        if (s[i] == 'c') {
            cout << "No" << endl;
        }
        if (s[i] == 'a') {
            if (absum < a + b) {
                cout << "Yes" << endl;
                absum++;
            }
            else cout << "No" << endl;
        }
        if (s[i] == 'b') {
            if (absum < a + b && bsum < b) {
                cout << "Yes" << endl;
                absum++;
                bsum++;
            }
            else cout << "No" << endl;
        }
    }
    return 0;
}


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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll t1, t2, a1, a2, b1, b2;
  cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
  
  if(t1 * a1 + t2 * a2 == t1 * b1 + t2 * b2){
    cout << "infinity" << "\n";
    return 0;
  }
  
  if(t1 * a1 + t2 * a2 < t1 * b1 + t2 * b2){
    swap(a1, b1);
    swap(a2, b2);
  }
  
  if(t1 * a1 > t1 * b1){
    cout << 0 << "\n";
    return 0;
  }
  
  ll check1, check2, ans;
  check1 = t1 * b1 - t1 * a1;
  check2 = t1 * a1 + t2 * a2 - (t1 * b1 + t2 * b2);
  ans = 2 * (check1 / check2);
  if(check1 % check2 != 0) ans++;
  
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0

for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if i*500 + j*100 + k*50 == x:
        count+=1

print(count)

Measured memory_bytes: 3060
N, A, B, C = map(int, input().split())
bamboo = [int(input()) for i in range(N)]
INF = 10**9

def dfs(i,a,b,c):
  #竹を全部巡ったら
  ##1つ上の関数の働きを考えながらベース式で何をするかを定める
  if i == N:
    #a,b,cは合成によって得られた竹の長さ
    if min(a,b,c) > 0:
      #差の絶対値が延長・短縮に必要なMP
      #a,b,c = 0 から竹の長さに値を与えるために1本ずつ竹を使っているため
      #10 * 3の分だけ余分に合成魔法のMPが使われているから、引く
      return abs(a - A) + abs(b - B) + abs (c - C) - 30
    #竹を1本も材料としなかった場合 = 却下のケース
    ##=無の竹に延長短縮魔法は使えない
    #i = N - 1で却下するためにINFを返す
    else:
      return INF
  
  else:
    #竹の長さをa,b,cに足してゆき、消費MP10を値に足す
    #使わない場合は竹の長さもMPも足さない
    ret0 = dfs(i + 1,a,b,c)
    ret1 = dfs(i + 1,a + bamboo[i],b,c) + 10
    ret2 = dfs(i + 1,a,b + bamboo[i],c) + 10
    ret3 = dfs(i + 1,a,b,c + bamboo[i]) + 10
    
    #次の再帰呼び出しの中で最小のものを選び値を返す
    #i = 4の関数で abs ~ -30を受け取る
    return min(ret0,ret1,ret2,ret3)
  
print(dfs(0,0,0,0))

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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll h, w;
  cin >> h >> w;
  
  if (h == 1 || w == 1) cout << 1 << '\n';
  else if (h % 2 == 1 && w % 2 == 1) cout << (h * w) / 2 + 1 << '\n';
  else cout << h * w / 2 << '\n';
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
# input = sys.stdin.r/eadline
def INT(): return int(input())
def MAP(): return map(int,input().split())
def LI(): return list(map(int,input().split()))

def main():
    N = INT()
    A = LI()
    A.sort()
    answer = 0
    for i in range(N):
        answer += A[N+2*i]
    print(answer)


if __name__ == '__main__':
    main()


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

#define FOR(s, i, n) for(int i = s; i n; i++)
typedef long long ll;
const int INF = 1e9;

#define onEdge(i, j) (i == 0 || i == n-1 || j == 0 || j == n-1)
#define inBound(i, j) !(i < 0 || i > n-1 || j < 0 || j > n-1)

vector<pair<int,int>> order;
vector<vector<int>> dist;
vector<vector<bool>> seats;
// vector<vector<bool>> inq;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {-1, 0, 1, 0};
int n;

void updDist(int x1, int y1){
	queue<pair<int,int>> q;
	q.push({x1, y1});
	// inq[x1][y1] = 1;
	while (!q.empty()){
		auto u = q.front();
		q.pop();
		int x = u.first; int y = u.second;
		// inq[x][y] = 0;
		for (int d = 0; d < 4; d++){
			int x2, y2;
			x2 = x + dx[d];
			y2 = y + dy[d];
			if (inBound(x2,y2)){
				int newDist = dist[x][y] + seats[x2][y2];
				if (newDist < dist[x2][y2]){
					dist[x2][y2] = newDist;
					// if (!inq[x2][y2]){
						// inq[x2][y2] = 1;
						q.push({x2, y2});
					// }
				}
			}
		}
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin>>n;
	order.resize(n*n);
	seats.assign(n, vector<bool>(n, 1));
	dist.assign(n, vector<int>(n, INF));
	// inq.assign(n, vector<bool>(n, 0));
	for (auto &it: order){
		int a;
		cin>>a;
		a--;
		int x = a/n;
		int y = a%n;
		it.first = x; it.second = y;
	}
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			// if (onEdge(i, j)){
			// 	dist[i][j] = 0;
			// 	updDist(i, j);
			// }
			dist[i][j] = min(min(i, j), min(n - 1 - i, n - 1 - j));
			// cout<<dist[i][j];
		}
		// cout<<'\n';
	}
	int ans = 0;
	for (auto u: order){
		ans += dist[u.first][u.second];
		dist[u.first][u.second]--;
		seats[u.first][u.second] = 0;
		updDist(u.first, u.second);
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 6364
var
  x1,x2,y1,y2,a,b:longint;
begin
  read(x1,y1,x2,y2);
  a:=abs(x1-x2);b:=abs(y1-y2);
  if (x1<=x2)and(y1>=y2) then
    write(x2+b,' ',y2+a,' ',x2+b-a,' ',y2+a+b) else
  if (x1<=x2)and(y1<=y2) then
   write(x2-b,' ',y2+a,' ',x2-b-a,' ',y2+a-b) else
  if (x1>=x2)and(y1<=y2) then
    write(x2-b,' ',y2-a,' ',x2-b+a,' ',y2-a-b) else
  write(x2+b,' ',y2-a,' ',x2+a+b,' ',y2-a+b);
end.


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  int n;
  cin >> n;
  vector<string> s(n);
  rep(i,n) cin >> s[i];

  vector<pair<int,int> > plq;
  vector<pair<int,int> > miq;
  vector<pair<int,int> > equ;

  rep(i,n){
    int lowmax = 0;
    int tot = 0;
    rep(j,s[i].size()){
      if(s[i][j]=='(') tot++;
      else tot--;
      lowmax = min(lowmax,tot);
    }
    if(tot>0) plq.push_back({lowmax,tot});
    else if(tot==0) equ.push_back({lowmax,tot});
    else miq.push_back({lowmax,tot});
  }

  sort(miq.begin(),miq.end(),[](pair<int,int> const& lef, pair<int,int> const& rig){
    return lef.second + rig.first > rig.second + lef.first;
  });
  sort(equ.rbegin(),equ.rend());
  sort(plq.rbegin(),plq.rend());
  ll ans = 0;
  rep(j,plq.size()){
    if(ans + plq[j].first < 0){
      cout << "No" << endl;
      return 0;
    }
    ans += plq[j].second;
  }
  rep(j,equ.size()){
    if(ans + equ[j].first < 0){
      cout << "No" << endl;
      return 0;
    }
    ans += equ[j].second;
  }
  rep(j,miq.size()){
    // cout << miq[j].first <<" " <<  miq[j].second << endl;
    if(ans + miq[j].first < 0){
      cout << "No" << endl;
      return 0;
    }
    ans += miq[j].second;
  }
  if(ans == 0)  cout << "Yes" << endl;
  else cout << "No" << endl;

  // cout << endl << endl;
  // cout << static_cast<double>(clock()) / CLOCKS_PER_SEC << "s"<<endl;
  return 0;
    

}


Measured memory_bytes: 42480
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
using ll =long long;
using namespace std;

int n,m,q;
vector<int> a,b,c,d;
int ans;

void dfs(vector<int> A){
//    for(auto it =A.begin();it!=A.end();++it){
//        cout<< *it <<" ";
//    }
    cout<<endl;
    if(A.size()==n+1){
        int now=0;
        rep(i,q){
            if(A[b[i]]-A[a[i]]==c[i])now+=d[i];
        }
        ans=max(ans,now);
        return;
    }
    A.push_back(A.back());
    while(A.back()<=m){
        dfs(A);
        A.back()++;
    }
}

                                        

int main(){
    cin>>n>>m>>q;
    a=b=c=d=vector<int>(q);
    rep(i,q){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
    }
    dfs(vector<int>(1,1));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main()
{
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  cout <<(char) (((int) s1[0]) - 32) << (char) (((int) s2[0]) - 32) <<(char) (((int) s3[0]) - 32);
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] ss = line.split(" ");
		int a = Integer.parseInt(ss[0]);
		int b = Integer.parseInt(ss[1]);
		System.out.println(a * b + " " + (2 * a + 2 * b));
	}

}

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

using i64 = int64_t;

int main(){
    int n;
    cin >> n;
    vector<pair<i64, i64>> v;
    for(int i=0;i<n;++i){
        i64 x, l;
        cin >> x >> l;
        v.emplace_back(x+l, x-l);
    }
    sort(v.begin(), v.end());
    for(auto e: v){
        cerr << e.second << " " << e.first << endl;
    }
    i64 ans = 1, right = v[0].first;
    for(int i=1;i<n;++i){
        if(v[i].second >= right){
            ans++;
            right = v[i].first;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2548
#include <iostream>
#include <algorithm>
using namespace std;
 
int main() {
    int N; 
    cin >> N;
    long long int P = 1; 
    for (int i = 1; i <= N; ++i){
     P = (P * i) % 1000000007;
    } 
     cout << P << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long x,k,d,ans;
    cin>>x>>k>>d;
    x=abs(x);
    long long c=x/d;
    ans=x-min(k,c)*d;
    if(k<=c || (k-c)%2==0){
         cout<<abs(ans);
    }
    else
        cout<<abs(ans-d);
}


Measured memory_bytes: 3636
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

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

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n; cin>>n;
    double ans;
    if(n % 2 == 0){
        ans = 0.5;
    }
    else{
        ans = 1. * (n / 2 + 1) / n;
    }

    printf("%.10f\n", ans);

    return 0;
}

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

using namespace std;

//bit全探索

void func_c() {
    string s;
    cin >> s;

    int n;
    istringstream ss;
    ss = istringstream(s);
    ss >> n;

    //桁数を調べる
    int keta = s.size();

    if (keta == 1) {
        cout << n;
        return;
    }
    int bin = pow(2, keta - 1) - 1;

    vector<int> plus(keta-1);
    unsigned long long  sum = 0;

    for (; bin >= 0; --bin) {

        int temp = bin;
        for (int i = 0; i < keta-1; ++i) {
            int temp2 = pow(2, keta - i - 2);
            plus[i] = temp / temp2;
            temp %= temp2;
        }

        /*
        for (int i = 0; i < keta-1; ++i) {
            cout << plus[i] << " ";
        }
        cout << "\n";
        */

        /*
       　文字列として扱いながら進める。
        頭から調べて
        +がある場所を取り出す->数字に変換してたす
        を繰り返し求める
        */

        string s_temp = s;
        string s_temp2;
        int count = 1;
        for (int i = 0; i < keta; ++i) {
            if (i == keta - 1 || plus[i] == 1) {
                //文字列を切りしてたす
                s_temp2 = s_temp.substr(0, count); //頭からcount文字数分取り出す
                s_temp.erase(0, count); //取り出した分文字列から削除
                ss = istringstream(s_temp2); //数字型に変換
                unsigned long long temp;
                ss >> temp;
                //cout << temp << "をたした\n";
                sum += temp; //たす
                count = 1; //countをリセット
            }
            else { //plus[i] == 0のとき
                ++count; //飛ばす分取り出す文字数が増える
            }
        }
    }
    
    cout << sum;

}

int main() {
    func_c();

    return 0;
}

Measured memory_bytes: 256
n,a,b = map(int,input().split(" "))
#print(n,a,b)

res = 0
for i in range(1, n + 1):
    p = list(str(i))
    p = list(map(int,p))
    total = 0
    for j in p:
        total += j
    if a <= total <= b:
        res += i
    
print(res)
        
        

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

H, W = list(map(int, input().split()))
data = [''] * H

for h in range(H):
    data[h] = input()

lights = [[-1 for _ in range(W)] for _ in range(H)]

for h in range(H):
    w = 0
    while w < W:
        if data[h][w] == '#':
            w += 1
            continue
        try:
            floor_count = data[h][w:].index('#')
        except ValueError:
            floor_count = W - w
        for k in range(floor_count):
            lights[h][w+k] += floor_count
        w += floor_count + 1

for w in range(W):
    h = 0
    while h < H:
        if data[h][w] == '#':
            h += 1
            continue
        floor_count = 1
        for i in range(1, H-h):
            if data[h+i][w] == '#':
                break
            floor_count += 1
        for k in range(floor_count):
            lights[h+k][w] += floor_count
        h += floor_count + 1

ans = -1
for h in range(H):
    m = max(lights[h])
    if ans < max(lights[h]):
        ans = m
print(ans)


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll a, b, c;
    cin >> a >> b >> c;
    if(b - a == c - b) cout << "YES";
    else cout << "NO";
    cout << endl;
    return 0;
}


Measured memory_bytes: 3576
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Integer> p = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			p.add(sc.nextInt());
		}
		int judge = 0;
		int count = 0;
		for (int i = 1; i < n - 1; i++) {
			judge = (p.get(i) - p.get(i - 1)) * (p.get(i) - p.get(i + 1)); 
			if (judge < 0) {
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const int INF=1e9;
ll pow1(ll a){
      ll res=1;
      REP(i,a)res*=-10;
      return res;
}
ll abs1(ll a){
      if(a<0)return -a;
      return a;
}
ll rec(int n,int k){
      if(n==0)return 0;
      ll t=n,s=pow1(k);
      for(int i=0;i<=9;i++){
            if((n-s*i)%(s*10)==0){
                  return rec(n-s*i,k+1)+abs(s*i);
            }
      }
}
int main(){
      ll n;
      while(1){
            cin>>n;
            if(n==0)break;
            cout<<rec(n,0)<<endl;
      }
}

Measured memory_bytes: 1156
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        while (true) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            if (H == 0 && W == 0) break;
            
            Rect rect = new Rect(H, W);
            Vector<Rect> v = new Vector<Rect>();
            
            for (int w = 2; w <= 150; w++) {
                for (int h = w-1; h > 0; h--) {
                    Rect r = new Rect(h, w);
                    if (rect.compareTo(r) < 0) {
                        v.add(r);
                    }
                }
            }
            
            Collections.sort(v);
            
            rect = v.get(0);
            System.out.println(rect.h + " " + rect.w);
        }
    }
    
    public static class Rect implements Comparable<Rect> {
       int w;
       int h;
       
       public Rect(int h, int w) {
           this.h = h;
           this.w = w;
       }
       
       public int compareTo(Rect r) {
           int diag1 = w * w + h * h;
           int diag2 = r.w * r.w + r.h * r.h;
           if (diag1 == diag2) {
               return h - r.h;
           }
           return diag1 - diag2;
       }
    }
}




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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;

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

    int n;
    cin >> n;
    int x = sqrt(n);
    cout << x * x << endl;

    return 0;
}



Measured memory_bytes: 256
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/

	coding: utf-8
	lang: C++ (GCC 5.4.1)
*/

#include <bits/stdc++.h>
using namespace std;

// utility of stdin,stdout
#define _CRT_SECURE_NO_WARNINGS
#define OUT cout << 
#define BR << endl
#define RET return 0
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	int n;
	int ans = 0,cnt = 0;
	cin >> n;

	std::vector<int> h(n);
	for (int i = 0; i < n; ++i)	cin >> h.at(i);
	for (int i = 0; i + 1 < n; ++i)
	{
		if(h.at(i) >= h.at(i + 1))	++cnt;
		else{
			ans = std::max(ans, cnt);
			cnt = 0;
		}
	}
	OUT(std::max(ans, cnt)) BR;
	RET;
}


Measured memory_bytes: 640
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	runes := []rune(s)
	runeLength := len(runes)

	fromA := runes[0] == 'A'

	var containsOneC bool
	cCount := 0
	for _, r := range runes[2 : runeLength-1] {
		if r == 'C' {
			cCount++
			containsOneC = true
		}
		if cCount == 2 {
			containsOneC = false
			break
		}
	}

	allSmall := true
	for _, r := range runes[1:runeLength] {
		if r != 'C' && (r < 'a' || r > 'z') {
			allSmall = false
			break
		}
	}

	if fromA && containsOneC && allSmall {
		fmt.Println("AC")
	} else {
		fmt.Println("WA")
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define inf 10000000000

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

    ll a, b, c;
    cin >> a >> b >> c;
    cout << ((a + b == c || b + c == a || c + a == b) ? "Yes" : "No") << endl;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
    return string(1, val);
}

int main(){
    int A, B, C, X; cin >> A >> B >> C >> X;
    int cnt = 0;
    for(int a = 0; a <= A; ++a) {
        for(int b = 0; b <= B; ++b) {
            for(int c = 0; c <= C; ++c) {
                int tmp = 500 * a + 100 * b + 50 * c;
                if(tmp == X) cnt++;
            }
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256