akhauriyash/Code-Regression huggingface dataset:
n=int(input())
A=list(int(i) for i in input().split())
prefixsum=[0 for i in range(n+1)]
for i in range(1,n+1):
    prefixsum[i]=A[i-1]+prefixsum[i-1]
#print(prefixsum)
dp=[[0 for i in range(n)] for j in range(n)]
for i in range(n-1,-1,-1):
    for j in range(i,n):
        #starting index i and ending j
        #finally we need to print first row last column
        #which represent the cost of all the elements
        if i==j:
            dp[i][j]=0
        else:
            dp[i][j]=10**18
            for k in range(i,j):
                dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]+prefixsum[j+1]-prefixsum[i])
print(dp[0][-1])


Measured memory_bytes: 44124
#include <bits/stdc++.h>
#define mov(x) (1<<(x))

using namespace std;

typedef long long ll;

const ll MOD = 998244353;
const int MX = 262144;

template <typename T> void cmin(T &x, const T &y)
{
	if(y < x) x = y;
}

template <typename T> void cmax(T &x, const T &y)
{
	if(y > x) x = y;
}

template <typename T> void read(T &x)
{
	x = 0; char c = getchar(); bool f = 0;
	while(!isdigit(c) && c!='-') c = getchar();
	if(c == '-') f = 1, c = getchar();
	while(isdigit(c)) x = x*10+c-'0', c = getchar();
	if(f) x = -x;
}

ll qpow(ll x, ll t)
{
	ll ans = 1;
	while(t)
	{
		if(t & 1) ans = ans * x % MOD;
		x = x * x % MOD;
		t >>= 1;
	}
	return ans;
}

ll inv(ll x)
{
	return qpow(x, MOD-2);
}

void fwt(ll *f, int bit)
{
	for(int i=1; i<mov(bit); i<<=1)
		for(int j=0; j<mov(bit); j+=(i<<1))
			for(int k=0; k<i; k++)
			{
				ll x = f[j+k], y = f[j+k+i];
				f[j+k] = (x+y) % MOD;
				f[j+k+i] = (x-y+MOD) % MOD;
			}
}

int n;
ll p[MX], rgt[MX], lft[MX];

void input()
{
	read(n);
	for(int i=0; i<mov(n); i++) read(p[i]);
}

void work()
{
	ll sum_i = inv(accumulate(p, p+mov(n), 0));
	for_each(p, p+mov(n), [=](ll &x){x = x*sum_i%MOD;}), p[0] = (p[0]-1+MOD) % MOD;
	fill(rgt, rgt+mov(n), MOD-1), rgt[0] = mov(n)-1;
	fwt(rgt, n), fwt(p, n);
	for_each(p, p+mov(n), [=](ll &x){x = inv(x);});
	for(int i=0; i<mov(n); i++) lft[i] = rgt[i] * p[i] % MOD;
	fwt(lft, n);
	ll iv = inv(mov(n));
	for_each(lft, lft+mov(n), [=](ll &x){x = x*iv%MOD;});
	for_each(lft, lft+mov(n), [=](ll x){printf("%lld\n", (x-lft[0]+MOD)%MOD);});
}

int main()
{
	input();
	work();
	return 0;
}


Measured memory_bytes: 8960
import sys
from collections import Counter

n, m = map(int, input().split())
ab_list = [ list(map(int, input().split())) for i in range(n)]
cd_list = [ list(map(int, input().split())) for i in range(m)]
ans_list = [[None, None] for i in range(n)]

for i in range(n):
    for j in range(m):
        x_dist = abs(ab_list[i][0] - cd_list[j][0])
        y_dist = abs(ab_list[i][1] - cd_list[j][1])
        tmp = x_dist + y_dist
        if ans_list[i][0] == None or tmp < ans_list[i][1]:
            ans_list[i] = [j+1, tmp]

for i in range(n):
    print(ans_list[i][0])


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) (V).begin(),(V).end()

int dp[5010][5010];

int main(){
	int ss;
	cin >> ss;
	string S;
	cin >> S;
	int mx = 0;
	for (int i = 1;i <= ss;i++) {
		for (int j = i + 1;j <= ss;j++) {
			if (S[i - 1] == S[j - 1]) {
				dp[i][j] = dp[i - 1][j - 1] + 1;
			}
			if (j - i < dp[i][j])dp[i][j] = 0;
			mx = max(mx, dp[i][j]);

		}
	}
	cout << mx << endl;
}

Measured memory_bytes: 96768
#include <stdio.h>

int main(int argc, const char * argv[])
{
    int month,day;
    int i,cnt = 0;
    scanf("%d %d",&month,&day);
    while(month != 0){
        for(i = 1;i < month;i++){
            if(i==1||i==3||i==5||i==7||i==8||i==10)cnt+=31;
            if(i==4||i==6||i==9||i==11)cnt+=30;
            if(i==2)cnt+=29;
        }
        cnt += day;
        if(cnt % 7 == 0)printf("Wednesday\n");
        if(cnt % 7 == 1)printf("Thursday\n");
        if(cnt % 7 == 2)printf("Friday\n");
        if(cnt % 7 == 3)printf("Saturday\n");
        if(cnt % 7 == 4)printf("Sunday\n");
        if(cnt % 7 == 5)printf("Monday\n");
        if(cnt % 7 == 6)printf("Tuesday\n");
        cnt=0;
        scanf("%d %d",&month,&day);
    }
    
    return 0;
}

Measured memory_bytes: 584
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

// Self settings
// clang-format off
#define MAX_N 10000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
// clang-format on

int N, X;
int L[MAX_N];
int D[MAX_N + 1];

void solve()
{
  REP(i, N) D[i + 1] = D[i] + L[i];
  int cnt = 0;
  for (int i = 0; i <= N; ++i) {
    if (D[i] > X) {
      break;
    }
    cnt++;
  }
  cout << cnt << endl;
}

int main(void)
{
  cin >> N >> X;
  REP(i, N) cin >> L[i];
  solve();
  return 0;
}


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

int main(){
    int H, W;
    cin >> H >> W;
    while( H != 0 ){
        int i, n;
        for( i = 0; i < H; i ++ ){
            for( n = 0; n < W; n ++ ){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
        cin >> H >> W;
    }
    return 0;
}


Measured memory_bytes: 3120
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(lint)(n);i++)
#define REP(i,n) for(int i=1;i<=(lint)(n);i++)
#define all(V) V.begin(),V.end()
typedef long long lint;
typedef std::pair<lint, lint> P;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = 1e-9;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
lint mypow(lint a, lint b) {
	if (!b)return 1;
	if (b & 1)return mypow(a, b - 1) * a;
	lint memo = mypow(a, b >> 1);
	return memo * memo;
}
lint modpow(lint a, lint b, lint m) {
	if (!b)return 1;
	if (b & 1)return modpow(a, b - 1, m) * a % m;
	lint memo = modpow(a, b >> 1, m);
	return memo * memo % m;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, vec.size() - 1)std::cout << vec[i] << " ";
	std::cout << vec.back() << std::endl;
}
template<typename T>
void printArray(T l, T r) {
	T rprev = r;
	rprev--;
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
std::string to_string(std::vector<int>& vec) {
	std::string res = "[";
	rep(i, vec.size() - 1)res += std::to_string(vec[i]) + ", ";
	res += std::to_string(vec.back()) + "]";
	return res;
}
int n,a[100010],memo[100010],deg[100010];
std::vector<int> vec[100010];
bool used[100010];
int main(){
	std::cin>>n;
	REP(i,n){
		std::cin>>a[i];
		memo[i]=a[i];
	}
	rep(i,n-1){
		int u,v;
		std::cin>>u>>v;
		vec[u].push_back(v);
		vec[v].push_back(u);
		deg[u]++;deg[v]++;
	}
	std::queue<int> que;
	REP(i,n){
		if(deg[i]==1){
			que.push(i);
		}
		else a[i]*=2;
	}
	while(!que.empty()){
		int node=que.front();
		que.pop();
		used[node]=true;
		if(deg[node]==0&&a[node]||memo[node]<a[node]){
			puts("NO");
			return 0;
		}
		for(int i:vec[node]){
			if(!used[i]){
				a[i]-=a[node];
				if(memo[i]<a[node]){
					puts("NO");
					return 0;
				}
				if(a[i]<0){
					puts("NO");
					return 0;
				}
				deg[i]--;
				if(deg[i]==1)que.push(i);
			}
		}
	}
	puts("YES");
	return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<string> strs(N);
  for(int i = 0; i < N;i++){
    cin >> strs.at(i);
    sort(strs.at(i).begin(), strs.at(i).end());
  }
  
  sort(strs.begin(), strs.end());
  
  unsigned long long int ans = 0;
  int count  = 0;
  for(int i = 1; i < N;i++){
    if(strs[i] == strs[i-1]){
      count ++;
      ans += count;
    }
    else{count=0;}
  }
  
  cout << ans << endl;
  
  
  return 0;
}


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

namespace abc138_d
{
  class Program
  {
    static void Main(string[] args)
    {
      var n = CIn.ReadInt();
      var q = CIn.ReadInt();
      var a = new int[n - 1];
      var b = new int[n - 1];
      var x = new int[n];

      for (var i = 0; i < n - 1; i++)
      {
        a[i] = CIn.ReadInt() - 1;
        b[i] = CIn.ReadInt() - 1;
      }

      for (var i = 0; i < q; i++)
      {
        var p = CIn.ReadInt() - 1;
        x[p] += CIn.ReadInt();
      }

      var wuf = new WUF(n);

      for (var i = 0; i < n - 1; i++)
      {
        wuf.Merge(a[i], b[i], x[b[i]]);
      }

      Console.WriteLine(String.Join(" ", Enumerable.Range(0, n).Select(e => wuf.GetWeight(e) + x[0])));
    }
  }

  class WUF
  {
    private int[] parent;
    private int[] weight;

    public WUF(int n)
    {
      parent = new int[n];
      weight = new int[n];

      for (int i = 0; i < n; i++)
      {
        parent[i] = i;
      }
    }

    public int GetRoot(int x)
    {
      if (parent[x] == x)
      {
        return x;
      }
      else
      {
        var root = GetRoot(parent[x]);
        weight[x] += weight[parent[x]];
        parent[x] = root;
        return root;
      }
    }

    public int GetWeight(int x)
    {
      GetRoot(x);
      return weight[x];
    }

    public void Merge(int x, int y, int w)
    {
      if (GetRoot(x) == GetRoot(y)) return;

      w += GetWeight(x) - GetWeight(y);

      parent[y] = GetRoot(x);

      weight[y] = w;
    }
  }

  class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }

      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(long n)
    {
      var array = new string[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }

      return array;
    }

    public static int[] ReadIntArray(long n)
    {
      var array = new int[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }

      return array;
    }

    public static long[] ReadLongArray(long n)
    {
      var array = new long[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }

      return array;
    }
    public static double[] ReadDoubleArray(long n)
    {
      var array = new double[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }

      return array;
    }
  }
}

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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    vector<int> vec(3);
    int sum = 0;
    rep(i,3){
        cin >> vec.at(i);
        sum += vec.at(i);
    }
    if(sum >= 22){
        cout << "bust" << endl;
    }else{
        cout << "win" << endl;
    }
    
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef vector<pll> vpll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  ll N;
  IN(N);
  string S;
  IN(S);
  ll ans = 0;
  char prev = 'A';
  REP(i,N){
    if(prev==S[i]) continue;
    ans++;
    prev=S[i];
  }
  OUT(ans);

  return 0;
}

Measured memory_bytes: 512
N=int(input())
p=len(str(N))
if p%2==0:
  answer=0
  for i in range(0,p,2):
    answer +=9*(10**i)
else:
  answer=0
  for i in range(0,p-1,2):
    answer +=9*(10**i)
  answer += N-10**(p-1)+1
print(answer)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define _GLIBCXX_DEBUG
#define rep(i, a, b) for(int i = a; i < b; i++)
#define ALL(v) v.begin(), v.end()

int main(){
    int r; cin >> r;
    cout << r*r << endl;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int x;
  cin >> x;
  int ans = 0;
  for (int i = 0; i <= a; i++)
    for (int j = 0; j <= b; j++)
      for (int k = 0; k <= c; k++)
        if (i * 500 + j * 100 + k * 50 == x)
          ans++;
  cout << ans << endl;
}

Measured memory_bytes: 256
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 
 
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}
//}}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,c,x,y;
	cin >> a >> b >> c >> x >> y;
	c *= 2;
	if(x > y) cout << min({a*x + b*y,x * c,y*c + (x-y) * a}) << '\n';
	else cout << min({a*x + b*y,y * c,x*c + (y-x) * b}) << '\n';
	return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	n := getInt()
	m := getInt()

	if abs(n-m) > 1 {
		fmt.Println(0)
		return
	}

	ans := 1
	for i := 1; i <= n; i++ {
		ans = (ans * i) % 1000000007
	}
	for i := 1; i <= m; i++ {
		ans = (ans * i) % 1000000007
	}

	if abs(n-m) == 0 {
		ans = (ans * 2) % 1000000007
	}

	fmt.Println(ans)
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

// -----------------------------------------

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

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

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


Measured memory_bytes: 640
n, m = list(map(int, input().split(" ")))
ab = []
for i in range(n):
    ab.append(list(map(int, input().split(" "))))

ab.sort()

ans = 0
for i in range(n):
    if(ab[i][1] >= m):
        print(ans + ab[i][0] * m)
        exit()

    ans += ab[i][0] * ab[i][1]
    m -= ab[i][1]

Measured memory_bytes: 27760
List = list(map(int, input().split()))
X = []
for i in range(0,List[1]):
    X.append(list(map(int, input().split())))

d = 0
e = 0
x = []
if List[0] == 1:
    for i in range(0,10):
        c = 0
        for j in range(0,List[1]):
            if i != X[j][1]:
                c += 1
        if c == 0:
            x.append(i)
elif List[0] == 2:
    for i in range(10,100):
        c = 0
        for j in range(0,List[1]):
            if int(list(str(i))[X[j][0]-1]) != X[j][1]:
                c += 1
        if c == 0:
            x.append(i)
elif List[0] == 3:
    for i in range(100,1000):
        c = 0
        for j in range(0,List[1]):
            if int(list(str(i))[X[j][0]-1]) != X[j][1]:
                c += 1
        if c == 0:
            x.append(i)

if len(x) > 0:
    print(min(x))
else:
    print('-1')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<int> b(n);
  rep(i,n) cin >> b[i];
  vector<int> c(n-1);
  rep(i,n-1) cin >> c[i];
  rep(i,n) a[i]--;
 
  int ans = 0;
  rep(i,n) {
    ans += b[a[i]];
  }
 
  rep(i,n-1) {
    if (a[i]+1 == a[i+1]) {
      ans += c[a[i]];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io._

//import scala.io.StdIn._
import scala.math._

object Main {
	def main(args: Array[String]) {
		val cin = new java.util.Scanner(System.in)
		val N = cin.nextInt()
		val A = cin.nextInt()
		val B = cin.nextInt()
		val h = new Array[Int](N)
		for (i <- 0 until N){
			h(i) = cin.nextInt()
		}
		var lo = h.max / B + 1
//		var hi = h.sum / (A+B*(N-1))  // sum may overflow
		var hi = h.max / A
		while (hi<lo){
			val mi = (hi+lo)/2
			val acc:Long = mi*B  // 看别人code想到的
			var cnt:Long = 0
			for (i<-0 until N){
				val res = h(i) - acc
				if (res<=0){
					;
				}
				else{
					cnt += (res-1) / (A-B) + 1
				}
			}
			val flagCover = cnt <= mi
			if (flagCover)
				lo = mi
			else
				hi = mi+1
		}
		println(hi)
	}
}

Measured memory_bytes: 53876
(n,),a = [list(map(int, s.split())) for s in open(0)]
s2 = 0
mod = int(1e9+7)
inv_2 = pow(2, mod-2, mod)
for x in a:
    s2 += pow(x, 2, mod)
    s2 %= mod
a2 = pow(sum(a), 2, mod)
ans = ((a2 - s2) * inv_2) % mod
print(ans)

Measured memory_bytes: 34356
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cstring>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <cstdlib>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
typedef long long int ll;
#define forn for(int i=0;i<n;i++) 
#define form for(int j=0;j<n;j++) 
#define fora(i,a,b) for(int i = a; i < (b); i++)
#define pb push_back 
#define mp make_pair 
#define sc second 
#define f first 
#define kek cout<<"\n" 
#define all(v) ((v).begin()), ((v).end()) 
#define pob pop_back() 
const ll MOD = 1e9 + 7;
const int N = 1005;
const ll INF = 1e9;
using namespace std;
int main()
{
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
   int n;
   cin>>n;
   map<string,int> m;
   string s;
   int ans=0;
   vector<string> ve;
   forn 
   {
             cin>>s;
             m[s]++;
             ve.pb(s);
   }
   for(auto x:ve) ans=max(ans,m[x]);
   set <string> v;
   for(auto x:ve) if(m[x]==ans) v.insert(x);
  
   for(auto x:v) cout<<x<<endl;
     
      
        
        
        
        
        
        return 0;
        
        
        
        
        
}

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

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
	ll a,b,q;
	cin>>a>>b>>q;
	ll S[a],T[b],X[q];
	vector<ll> s,t,x;
	s.push_back(-pow(10,18));
	t.push_back(-pow(10,18));
	for(ll i=0;i<a;i++){
		cin>>S[i];s.push_back(S[i]);
	}
	for(ll i=0;i<b;i++){
		cin>>T[i];t.push_back(T[i]);
	}
	for(ll i=0;i<q;i++){
		cin>>X[i];x.push_back(X[i]);
	}
 
	s.push_back(pow(10,18));
	t.push_back(pow(10,18));
	ll s_w,s_e,t_w,t_e;
	ll res = pow(10,18);
	for(ll i=0;i<q;i++){
		res = pow(10,18);
		s_e = lower_bound(s.begin(),s.end(),X[i])-s.begin();
		s_w = s_e - 1;
		t_e = lower_bound(t.begin(),t.end(),X[i])-t.begin();
		t_w = t_e - 1;
		for(int j=0;j<2;j++){
			t_w = t_e-1;
			for(int k=0;k<2;k++){
				res = min(abs(s[s_w]-X[i])+abs(s[s_w]-t[t_w]),res);
				res = min(abs(t[t_w]-X[i])+abs(t[t_w]-s[s_w]),res);
				t_w++;
			}
			s_w++;
		}
		cout<<res<<endl;
	}
}

Measured memory_bytes: 6132
#include <bits/stdc++.h>
using namespace std;
#define rep(i,b) for(int i=0; i<int(b);i++)
#define eb emplace_back

using Weight = int;
struct Edge {
    int src, dst;
    Weight weight;
    Edge(int src_, int dst_, Weight weight_) :
        src(src_), dst(dst_), weight(weight_) { }
};
bool operator < (const Edge &e, const Edge &f) {
    return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
        e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

int const MAX_V = 10010;

void stronglyConnectedComponents(const Graph &g, int cmp[MAX_V]){
    int n = g.size(); Graph rg(n);
    for(const Edges &es : g) for(const Edge &e : es) rg[e.dst].eb(e.dst, e.src, e.weight);
    static int added[MAX_V], visited[MAX_V], ord[MAX_V], S[MAX_V];
    for(int i = 0; i < n; i++){
        added[i] = visited[i] = 0;
        cmp[i] = -1;
    }
    int sz = 0;
    for(int i = 0; i < n; i++)if(!visited[i]){
        int s = 0;
        S[s++] = i;
        while(s){
            int v = S[s-1]; visited[v] = true;
            bool pushed = false;
            for(auto & e : g[v]){
                int dst = e.dst;
                if(!visited[dst]){ S[s++] = dst; pushed = true; }
            }
            if(pushed) continue;
            int t = S[s-1];
            if(!added[t]){ added[t] = true; ord[sz++] = t; }
            --s;
        }
    }
    int k = 0;
    for(int i = 0; i < n; i++){
        int u = ord[n-i-1];
        if(cmp[u] != -1) continue;
        int s = 0; S[s++] = u;
        while(s){
            int v = S[--s]; cmp[v] = k;
            for(auto & e : rg[v]){
                int d = e.dst;
                if(cmp[d] == -1) S[s++] = d;
            }
        }
        ++k;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n,m;
    cin >> n >> m;
    Graph g(n);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        g[a].eb(a,b,0);
    }
    int c[MAX_V];
    stronglyConnectedComponents(g,c);
    int q; cin >> q;
    rep(i,q){
        int a,b;
        cin >> a >> b;
        cout << (c[a]==c[b]) << endl;
    }
}

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

using namespace std;

#define sp(x) cout<<setprecision(x);
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define yes "Yes"
#define no "No"
#define divs 1000000007
#define dive 1000000009
#define pi 3.141592653589793238

typedef pair<int, int> P;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
 
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
	int n, m; cin>>n>>m;
	vector<int> a(n); 
	int all = 0;
	REP(i,n){
		cin>>a[i];
		all += a[i];
	}
	int chosen = 0;
	REP(i,n){
		if(a[i]*4*m>=all) chosen++;
	}
	if(chosen>=m) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ull unsigned long long
# define ll long long
# define mod 1000000007LL 
using namespace std;
int main()
{
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    cout<<s;
    ll n=s.length();
    if(s[n-1]=='s')
    cout<<"es";
    else
    {
        cout<<"s";
    }
    
    
    
    return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>
#define M 1000000
int main(){
  char p[M]={1,1};
  int c[M]={0};
  int i,j,cc,n;
  for(i=2;i*i<M;i++){
    if(p[i])continue;
    for(j=i*i;j<M;j+=i)p[j]=1;
  }
  for(i=cc=0;i<M;i++){
    cc+=1-p[i];
    c[i]=cc;
  }
  while(scanf("%d",&n)!=EOF)printf("%d\n",c[n]);
  return 0;
}
    

Measured memory_bytes: 5484
using System;
class ProgramC
    {
        static void Main(string[] args)
        {
            
            //入力
            string[] s = Console.ReadLine().Split(' ');
            long k = long.Parse(s[0]);
            long n = long.Parse(s[1]);

            string[] a = Console.ReadLine().Split(' ');
            long ans = 10000000000;
            for(long i = 0; i < n - 1;i++)
            {
                long dis = k -(long.Parse(a[i + 1]) - long.Parse(a[i]));
                ans = Math.Min(dis, ans);
            }

            long dis2 = long.Parse(a[n -1]) - long.Parse(a[0]);
            ans = Math.Min(dis2, ans);

            Console.WriteLine(ans);
        } 
    } 

Measured memory_bytes: 30940
#include<stdio.h>
int main(){
    int n;
    int i, j;
    int count[4][14]={0};
    int smark[4]={'S', 'H', 'C', 'D'};
    scanf("%d",&n);
    for(i=0; i<n; i++){
        int num;
        int mark;
        scanf(" %c %d", &mark, &num);//http:
        if(mark=='S')count[0][num]=1;
        else if(mark=='H')count[1][num]=1;
        else if(mark=='C')count[2][num]=1;
        else if(mark=='D')count[3][num]=1;
    }
    for(i=0; i<4; i++)for(j=1; j<=13; j++){
        if(count[i][j]==0){
            printf("%c %d\n", smark[i], j);
        }
    }
    return 0;
}

Measured memory_bytes: 2692
A, B, C, X, Y = map(int, input().split())
min_p = 10**18
start = X*A + Y*B
if (A+B)<=2*C:
  print(A*X+B*Y)
else:
  if X <= Y:
    X, Y = Y, X
    A, B = B, A
  if A>=C*2:
    print(X*C*2)
  else:
    print(Y*C*2+(X-Y)*A)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
   int N;
   cin>>N;
   vector<int> H(N);
   for(int i=0;i<N;i++){
      cin>>H.at(i);
   }

   int count=0,max_count=0;
   for(int i=1;i<N;i++){
      if(H.at(i-1)>=H.at(i))
         count++;
      else{
         max_count=max(max_count,count);
         count=0;
      }
   }
   max_count=max(count,max_count);
   cout<<max_count<<endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

import static java.lang.Math.pow;
import static java.lang.Math.sqrt;
import static java.lang.Math.cbrt;
import static java.lang.Math.abs;

class Main{
    
    public static void main(String[] arg){

        Scanner in = new Scanner(System.in);

        String input = in.nextLine();
        int n = Integer.parseInt(input);

        int[] x = new int[n];
        int[] y = new int[n];
        int[] x_y = new int[n];

        input = in.nextLine();
        String [] param_line = input.split(" ", 0);
        for(int i=0; i<x.length; i++){
            x[i] = Integer.parseInt(param_line[i]);
        }

        input = in.nextLine();
        param_line = input.split(" ", 0);
        for(int i=0; i<y.length; i++){
            y[i] = Integer.parseInt(param_line[i]);
        }

        for(int i=0; i<x_y.length; i++)
            x_y[i] = abs(x[i] - y[i]);

        double tmp = 0.0;
        for(int i=0; i<x_y.length; i++){
            tmp += x_y[i];
        }
        double p1 = tmp;
        System.out.printf("%.6f\n",p1);

        tmp = 0.0;
        for(int i=0; i<x_y.length; i++){
            tmp += pow(x_y[i], 2);
        }
        double p2 = sqrt(tmp);
        System.out.printf("%.6f\n",p2);

        tmp = 0.0;
        for(int i=0; i<x_y.length; i++){
            tmp += pow(x_y[i], 3);
        }
        double p3 = cbrt(tmp);
        System.out.printf("%.6f\n",p3);

        tmp = 0.0;
        for(int i=0; i<x_y.length; i++){
            if(tmp<x_y[i]) tmp = x_y[i];
        }
        double pm = tmp;
        System.out.printf("%.6f\n",pm);

    }
}

Measured memory_bytes: 26264
n,h=map(int,input().split())
p,x,y=[],[],[]
z=float("inf")
for i in range(n):
  a,b=map(int,input().split())
  p.append((a,b))
  x.append(a)
  y.append(b)
x.sort()
y.sort()
for i in range(n-1):
  for j in range(i,n):
    for k in range(n-1):
      lx,rx,dy=x[i],x[j],y[k]
      c=0
      t=[]
      for a,b in p:
        if x[i]<=a<=x[j] and y[k]<=b:c+=1;t.append(b)
      if h<=c:z=min(z,(x[j]-x[i])*(sorted(t)[h-1]-y[k]))
print(z)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(){
  string a , b;
  cin >> a >> b;
  int c,d;
  cin >> c >> d;
  string e;
  cin >> e;
  if(a == e)
    cout << c-1 << " " << d;
  else
    cout << c << " " << d-1;
  return 0;
}

Measured memory_bytes: 256
namespace sample {
  class Scanner {
    private buffer = '';
    private stdinQueue: any = [];

    constructor() {
      process.stdin.resume();
      process.stdin.setEncoding('utf8');
      process.stdin.on(
        'data',
        (chunk): void => {
          this.buffer += chunk;
          while (this.stdinQueue.length > 0) {
            const i = this.buffer.indexOf('\n');
            if (i < 0) {
              break;
            }
            let line = this.buffer.substr(0, i);
            if (line.endsWith('\r')) {
              line = line.slice(0, -1);
            }
            this.buffer = this.buffer.substr(i + 1);
            this.stdinQueue.shift()(line);
          }
        },
      );
    }
    public getLine(): Promise<string> {
      return new Promise((resolve, reject) => {
        const i = this.buffer.indexOf('\n');
        if (i >= 0 && this.stdinQueue.length == 0) {
          let line = this.buffer.substr(0, i);
          if (line.endsWith('\r')) {
            line = line.slice(0, -1);
          }
          this.buffer = this.buffer.substr(i + 1);
          resolve(line);
        } else {
          this.stdinQueue.push(resolve);
        }
      });
    }

    public close(): void {
      process.stdin.pause();
    }
  }

  async function slove() {
    const sc = new Scanner();
    const [a, b]: number[] = (await sc.getLine()).split(' ').map((x) => +x);
    if (a > b) {
      console.log(a - 1);
    } else {
      console.log(a);
    }
    sc.close();
  }

  slove();
}


Measured memory_bytes: 7500
#include <bits/stdc++.h>
#define reps(i,j,k) for(int i=j;i<k;++i)
#define rep(i,j) reps(i,0,j)
#define fr first
#define sc second
#define fs fr
#define pb push_back

using namespace std;
typedef vector<int> vi;
typedef long long ll;

int p,q,a,n;
double r;
int solve(int depth,int seki, double value, int last){
	if(depth == n+1){
		return 0;
	}
	//rep(i,depth)cout << "  ";
	//cout << depth << ", " << seki << ", " << value << ", " << last << (fabs(r - value) < 1e-8 ? "**" : "  ") << endl;
	if( fabs(r - value) < 1e-8){
	//	cout << depth << ", " << seki << ", " << value << ", " << last << (fabs(r - value) < 1e-8 ? "**" : "  ") << endl;
		return 1;
	}
	
	int sum = 0;
	reps(i,last,a+1){
		if(seki*i > a){
			break;
		}
		double t = value + (double)1/(double)i;
		if( t-r < 1e-8){
			sum += solve(depth+1, seki*i,t,i); 	
		}
	}
	return sum;
}
int main(){
	while(cin >> p >> q >> a >> n,p){
		r = (double)p/(double)q;		
		cout << solve(0,1,0,1) << endl;
	}
	return 0;
}

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

int main(){
    ll L,R,l,r,ans = 2018;
    cin >> L >> R;
    if(L/2019 < R/2019){
        cout << 0 << endl;
        return 0;
    }
    l = L%2019,r = R%2019;
    for(int i = l;i <= r;i ++){
        for(int j = i+1;j <= r;j ++){
            ans = min((int)ans,(i*j)%2019);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
c = [list(map(int, input().split())) for i in range(m)]
for i in range(n):
    dim, num = 10**10, -1
    for j in range(m):
        if abs(a[i][0] - c[j][0]) + abs(a[i][1] - c[j][1]) < dim:
            dim = abs(a[i][0] - c[j][0]) + abs(a[i][1] - c[j][1])
            num = j
    print(num+1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  vector<tuple<string, int, int>> r;
  for (int i = 0; i < n; i++) {
    string s;
    int x;
    cin >> s >> x;
    r.push_back(make_tuple(s, -x, i + 1));
  }
  sort(all(r));
  for (int i = 0; i < n; i++) {
    cout << get<2>(r[i]) << endl;
  }
  return 0;
}

Measured memory_bytes: 3596
//#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

template<typename T>
struct BIT {
    int N;
    vector<T> dat;

    // 0-indexing
    explicit BIT(int n): N(n), dat(N + 1, 0) {}

    T sum(int i) {
        T s = T();
        for(++i; i > 0; i -= i & -i) s += dat[i];
        return s;
    }

    void add(int i, const T& x) {
        for (++i; i <= N; i += i & -i) dat[i] += x;
    }

    // min_x {x | v1 + v2 + ⋯ + vx ≧ w}
    // Assuming v_q >= 0
    int lower_bound(T w) {
        if (w <= 0) return 0;

        int x = 0; T k = 1;
        while (k * 2 <= N) k <<= 1;
        for (; k > 0; k /= 2) {
            if (x + k <= N && dat[x + k] < w) {
                w -= dat[x + k];
                x += k;
            }
        }
        return x + 1;
    }
};

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N, Q;
    cin >> N >> Q;

    vll c(N);
    REP(i, N) cin >> c[i], c[i]--;

    vector<vector<pair<int, int>>> query(N);
    REP(i, Q) {
        int l, r; cin >> l >> r;
        --l; --r;
        query[r].eb(l, i);
    }

    vector<int> last(N, -1);
    BIT<int> bit(N);
    vector<int> ans(Q);
    REP(i, N) {
        if (~last[c[i]]) bit.add(last[c[i]], -1);
        last[c[i]] = i;
        bit.add(i, 1);

        for(auto &p: query[i]) {
            ans[p.se] = bit.sum(i) - bit.sum(p.fi-1);
        }
    }

    for (auto &e: ans) {
        print(e);
    }
    
}


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

int main(){
    int N;
    cin >> N;
    int C[13];
    for(int i=0;i<=12;i++) C[i]=0;
    for(int i=0;i<N;i++){
        int D;
        cin >> D;
        C[D]++;
        if(D==0){
            cout << 0 << endl;
            return 0;
        }
    }
    //chokudai を12として
    bool E[50];
    for(int i=0;i<=24;i++) E[i]=false;
    E[12]=true;

    bool p=true;
    for(int i=1;i<=12;i++){
        if(C[i]>=3){
            cout << 0 << endl;
            return 0;
        }else if(C[i]==2){
            E[12+i]=true;
            E[12-i]=true;
        }else if(C[i]==1){
            if(p) E[12+i]=true;
            else E[12-i]=true;

            p=!p;
        }
    }
    if(E[0] && E[24]){
        cout << 0 << endl;
        return 0;
    }
    E[0]=(E[0] || E[24]);

    for(int i=24;i<=48;i++) E[i]=E[i-24];
    int min=100;
    int prev=-100;
    for(int i=0;i<=48;i++){
        if(E[i]){
            int d=i-prev;
            if(min>d) min=d;
            prev=i;
        }
    }

    cout << min << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include <climits>
#include<fstream>
using namespace std;
//---------------------------------------------------
//library zone!!!!!
typedef long long ll;
typedef long double ld;
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld mod_pow(ld x, ll n, ll p) {
	ld res = 1;
	while (n > 0) {
		if (n & 1) res = res * x;
		x = x * x;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int r;
	cin>>r;
	if(r<1200) cout<<"ABC\n";
	else if(r<2800) cout<<"ARC\n";
	else cout<<"AGC\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define vl vector<ll>
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define sz size()
#define en end()
#define ro return 0
#define br break
#define con continue;
#define all(x) (x).be , (x).en
#define rall(x) (x).rbegin() , (x).rend()
#define acc(x) accumulate((x).be , (x).en , 0)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define forr(i,a,b) for(ll i=a;i<b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
int main()
{
    ios;
    ll n , m , c;
    cin >> n >> m >> c;
    vl b;
    b.pb(-9999999);
    forn(i , 1 , m){
       ll x;
       cin >>x;
       b.pb(x);
    }
    ll cnt = 0 ;
    forn(i , 1, n){
       vl a ;
       a.clear();
       a.pb(-9999);
       forn(j , 1 , m){
         ll x;
         cin >> x;
         a.pb(x);
       }
      ll foo = 0 ;
       forn(k , 1 , m){
          foo = foo + a[k]*b[k];
       }
       foo = foo + c;
       if(foo > 0){
        ++cnt;
       }
    }
    cout << cnt << el ;
}








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

long long N, A[1 << 18];
long long M, B[1 << 18], C[1 << 18];
vector<pair<long long, long long>> vec;

int main() {
	cin >> N >> M;
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = 0; i < M; i++) { cin >> B[i] >> C[i]; vec.push_back(make_pair(C[i], B[i])); }
	sort(vec.begin(), vec.end());
	reverse(vec.begin(), vec.end());
	sort(A, A + N);

	int idx = 0;
	for (int i = 0; i < vec.size(); i++) {
		for (int j = 0; j < vec[i].second; j++) {
			if (A[idx] < vec[i].first) A[idx] = vec[i].first;
			idx++; if (idx == N) break;
		}
		if (idx == N) break;
	}

	long long ans = 0;
	for (int i = 0; i < N; i++) ans += A[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 7028
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstring>
#include<set>
#include<queue>
#include<stack>
#include<map>
#include<ctime>
#define rep(i,a,b) for(int i=a;i<=b;i++)
typedef long long ll;
using namespace std;
const int N=1e5+10;
const int INF=0x3f3f3f3f;
int ans1[1010][1010],ans0[1010][1010];
int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("in.txt","r",stdin);
    #endif // ONLINE_JUDGE
    int h,w,A,B;
    scanf("%d%d%d%d",&h,&w,&A,&B);
//    cout<<B<<endl;
    for(int i=1;i<=B;i++)
        for(int j=1;j<=A;j++)
            ans0[i][j]=1;

    for(int i=1+B;i<=h;i++)
        for(int j=1+A;j<=w;j++)
            ans0[i][j]=1;

    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++)
            printf("%d",ans0[i][j]);
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll n;
    ll a[200050]={};
    cin >> n;
    for(ll i = 1;i <= n;i++){
        cin >> a[i];
        a[i] += a[i-1];
    }
    ll ans = 1e14;
    for(ll i = 1;i < n;i++){
        ll cand = llabs(a[n] - a[i] - a[i]);
        ans = min(ans, cand);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    IN(ll, M);
    A2IN(ll, a, ll, b, M);
    vi d(N + 1);
    REP(i, M)
    {
        ++d[a[i]];
        ++d[b[i]];
    }
    FOR(x, d)
    {
        if (x & 1)
        {
            OUT("NO");
            return 0;
        }
    }
    OUT("YES");
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ll = long long int;
using vec = vector<int>;
using P = pair<int,int>;
const int INF = 1e9+7;

int main() {
  ll a, v, b, w, t;
  cin >> a >> v >> b >> w >> t;

  if ((v-w) * t >= abs(a-b)) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 3592
#include <stdio.h>


int main()
{
    int i, n, s=0;
    scanf("%d", &n);
    int ara[n];
    for(i=0; i<n; i++){
        scanf("%d", &ara[i]);
        s += ara[i]-1;
    }
   
    printf("%d", s);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
int n,m;
int x[200000];
int def[200000];
int ans;
int main(){
    cin>>n>>m;
    rep(i,m)cin>>x[i];
    sort(x,x+m);
    ans=x[m-1]-x[0];
    rep(i,m-1){
        def[i]=x[i+1]-x[i];
    }
    sort(def,def+m-1);
    reverse(def,def+m-1);
    rep(i,n-1){
        ans-=def[i];
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

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

  int N, K;
  cin >> N >> K;

  int count = 0;
  while (N) {
    N /= K;
    count++;
  }
  cout << count << endl;

	return 0;
}



Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <utility>
#include <stack>
#include <numeric>
#include <random>
#include <algorithm>
#include <queue>
#include <functional>
#include <iterator>
#include <list>
#include <unordered_map>
#include <deque>
#include <math.h>
#include <tgmath.h>
using namespace std;

#define rep(i, b, e) for(i = b; i < e; ++i)
#define repr(i, b, e) for (i = b; i >= e; --i)
#define ull unsigned long long int
#define ll long long int
#define pint pair<int, int>

#define M_DEBUG 1
#define PI 3.141592653589793

#define E '\n'

#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << "\n";}
#define INF (1e18)

const ll MAX = 1000000000;
const ll MOD = 1e9 + 7;

ull a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

ll aabs(ll a) {
    if (a < 0) return -a;
    return a;
}

//fast power
ll calc(ll a, ll b) {
    if (b == 0) return 1;
    else if (b % 2 == 0) {
        ll d = calc(a, b / 2);
        return (d * d) % MOD;
    }
    else return (a * calc(a, b - 1)) % MOD;
}

//fast combination
ll comb(ll n, ll a) {
    ll b = 1, c = 1;
    for (ll i = 1; i <= a; ++i) {
        b = b * i % MOD;
        c = c * (n - i + 1) % MOD;
    }

    return c * calc(b, MOD - 2) % MOD;
}

int kyotsu(string ss, int st, int ed, string ss2) {
    int ans = 0;
    for ( int i = st; i < ed; ++i ) {
        if (i - st >= ss2.size()) return ans;
        if (ss[i] == ss2[i - st] || ss[i] == '?') {
            ans++;
        } else {
            return -1;
        }
    }
    return ans;
}

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> m;

    cout << comb(n, 2) + comb(m, 2) << endl;


 
    return 0;
}

Measured memory_bytes: 256