akhauriyash/Code-Regression huggingface dataset:
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	a := getNextInt64(scanner)
	b := getNextInt64(scanner)
	k := getNextInt64(scanner)

	a -= k

	if a < 0 {
		b += a
		a = 0
	}
	if b < 0 {
		b = 0
	}

	fmt.Fprintf(writer, "%d %d\n", a, b)

	writer.Flush()
}


Measured memory_bytes: 640
use List::Util qw(max);
my $N = <STDIN>;
chomp $N;
$input = <STDIN>;
chomp $input;
my @v = split / /, $input;
my $res;
my $n = $N/2;
my %hash1 = ();
my %hash2 = ();
my @key1 = (-1, -1);
my @key2 = (-1, -1);
my @num1 = (0, 0);
my @num2 = (0, 0);
for ($i=0; $i<$n; $i++) {
  if (exists $hash1{$v[$i*2]}) {
    $hash1{$v[$i*2]}++;
  } else {
    $hash1{$v[$i*2]}=1;
  }
  if ($hash1{$v[$i*2]}>$num1[0]) {
    if ($key1[0] == $v[$i*2]) {
      $num1[0] = $hash1{$v[$i*2]};
    } else {
      $key1[1] = $key1[0];
      $num1[1] = $num1[0];
      $key1[0] = $v[$i*2];
      $num1[0] = $hash1{$v[$i*2]};
    }
  } elsif ($hash1{$v[$i*2]}>$num1[1]) {
    $key1[1] = $v[$i*2];
    $num1[1] = $hash1{$v[$i*2]};
  }
  if (exists $hash2{$v[$i*2+1]}) {
    $hash2{$v[$i*2+1]}++;
  } else {
    $hash2{$v[$i*2+1]}=1;
  }
  if ($hash2{$v[$i*2+1]}>$num2[0]) {
    if ($key2[0] == $v[$i*2+1]) {
      $num2[0] = $hash2{$v[$i*2+1]};
    } else {
      $key2[1] = $key2[0];
      $num2[1] = $num2[0];
      $key2[0] = $v[$i*2+1];
      $num2[0] = $hash2{$v[$i*2+1]};
    }
  } elsif ($hash2{$v[$i*2+1]}>$num2[1]) {
    $key2[1] = $v[$i*2+1];
    $num2[1] = $hash2{$v[$i*2+1]};
  }
}
if ($key1[0]!=$key2[0]) {
  $res = $N - $num1[0] - $num2[0];
} else {
  my $max = max ($num1[1]+$num2[0], $num1[0]+$num2[1]);
  $res = $N - $max;
}
print $res;

Measured memory_bytes: 23716
#include<bits/stdc++.h>
#define tmp(x) std::cout<<"& "<<(x)<<" &\n"
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
typedef long long ll;
using namespace std;
const int maxn=1e3+10;
const int maxm=1e6+100;
int h,w;
char a[maxn][maxn];
int d[maxn][maxn];
bool vis[maxn][maxn];

int cx,cy,dx,dy,ans;
int xx[20]={-2,-2,-2,-2,-2,-1,-1,-1,-1,0,0,1,1,1,1,2,2,2,2,2},yy[20]={-2,-1,0,1,2,-2,-1,1,2,-2,2,-2,-1,1,2,-2,-1,0,1,2};
inline bool check(int x,int y){
    return x>=1&&x<=h&&y>=1&&y<=w&&a[x][y]=='.';
}
void work(){
    deque<pair<int,int> > q;
    q.push_back(make_pair(cx,cy));
    d[cx][cy]=0;
    while(!q.empty()){
        int x=q.front().first,y=q.front().second;q.pop_front();
        if(d[x-1][y]>d[x][y]&&check(x-1,y))q.push_front({x-1,y}),d[x-1][y]=d[x][y];
        if(d[x+1][y]>d[x][y]&&check(x+1,y))q.push_front({x+1,y}),d[x+1][y]=d[x][y];
        if(d[x][y-1]>d[x][y]&&check(x,y-1))q.push_front({x,y-1}),d[x][y-1]=d[x][y];
        if(d[x][y+1]>d[x][y]&&check(x,y+1))q.push_front({x,y+1}),d[x][y+1]=d[x][y];
        for(int i=0;i<20;++i){
            int nx=x+xx[i],ny=y+yy[i];
            if(check(nx,ny)){
                if(d[nx][ny]>d[x][y]+1)d[nx][ny]=d[x][y]+1,q.push_back({nx,ny});
            }
        }
    }
}
int main(){
    scanf("%d%d",&h,&w);
    scanf("%d%d",&cx,&cy);
    scanf("%d%d",&dx,&dy);
    rep(i,1,h){
        scanf("%s",a[i]+1);
    }
    rep(i,1,h)rep(j,1,w)d[i][j]=maxm;
    work();
    if(d[dx][dy]==maxm)cout<<-1;
    else cout<<d[dx][dy];

    return 0;
}


Measured memory_bytes: 8516
#include<stdio.h>
int sosu(int);

int main(){
  int a,b,i;
  int count=0;
  scanf("%d", &a);
  for(i = 0; i < a; i++){
    scanf("%d", &b);
    if( sosu(b) )
      count++;
  }

  printf("%d\n", count);

  return 0;
}

int sosu(int b){
  int i;
  if ( b < 2 )
    return 0;
  else if ( b == 2 )
    return 1;
  if ( b % 2 == 0 )
    return 0;
  
  for ( i = 3; i * i <= b; i+=2 ){
    if ( b % i == 0 )
      return 0;
  }
  return 1;
}



Measured memory_bytes: 2048
n=int(input())
s=tuple(input())

pin=set()

m=[[] for i in range(10)]
for i in range(n):
    m[int(s[i])].append(i)

    yn=""
for i in range(0,1000):
    yn=""
    stri=format(i,"03d")
    mo=[0]*10
    if len(m[int(stri[0])])>0:
        m01=m[int(stri[0])][0]
    else:
        continue
    if len(m[int(stri[1])])>0:
        for ii in range(len(m[int(stri[1])])):
            if m01<m[int(stri[1])][ii]:
                m02=m[int(stri[1])][ii]
                yn="yes2"
                break
    if yn!="yes2":
        continue

    if len(m[int(stri[2])])>0:
        for ii in range(len(m[int(stri[2])])):
            if m02<m[int(stri[2])][ii]:
                m03=m[int(stri[2])][ii]
                yn="yes3"
                break
    if yn!="yes3":
        continue
    else:
        pin.add(stri)

print(len(pin))        

Measured memory_bytes: 4584
import Data.Char

main = do
  [n, k] <- map read . words <$> getLine
  s <- getLine
  putStrLn $ func (k - 1) s

func :: Int -> String -> String
func _ [] = []
func 0 (x:xs) = toLower x : func (0 - 1) xs
func n (x:xs) = x : func (n - 1) xs

Measured memory_bytes: 508
import sys
from collections import Counter

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    _ = int(rl())
    A = list(map(int, rl().split()))
    
    counter = Counter(A)
    A.sort()
    B = [True] * (10 ** 6 + 1)
    ans = 0
    for ai in A:
        if B[ai]:
            for i in range(ai, 10 ** 6 + 1, ai):
                B[i] = False
            if counter[ai] == 1:
                ans += 1
    print(ans)


if __name__ == '__main__':
    solve()


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

using namespace std;

int main()
{
    int a,b,c,x;

    cin >> a >> b >> c >> x;    

    int count = 0;
    int sum = 0;
    for(int i=0;i<a+1;i++)
    {   
        for(int j=0;j<b+1;j++)
        {
            for(int k=0;k<c+1;k++)
            {
                sum = (500*i)+(100*j)+(50*k);
                if(x==sum)
                {   
                    count += 1;
                }
            }
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int A,B;
    cin >> A >> B;
    int k = abs(A - B);
    if(k % 2 == 1){
        cout << "IMPOSSIBLE" << endl;
    }else{
        k /= 2;
        cout << min(A,B) + k << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define all(v) v.begin(), v.end()
//
int main(){
   int N,M;
   vector<string> blue,red;
   map<string,int> p;
   cin>>N;
   rep(i,N){
      string s;
      cin>>s;
      blue.push_back(s);
   }
   cin>>M;
   rep(i,M){
      string s;
      cin>>s;
      red.push_back(s);
   }
   rep(i,N){
      p[blue[i]]++;
   }
   rep(i,M){
      p[red[i]]--;
   }
   int ans=0;
   for(auto e:blue){
      ans=max(ans,p[e]);
   }
   cout<<ans<<endl;
}



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

int main(void)
{
  int a, b;
  cin >> a >> b;

  if (a <= 2 * b)
  {
    cout << 0 << "\n";
  }
  else
  {
    cout << a - 2 * b << "\n";
  }

  return 0;
}

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

using namespace std;

int ufd[101010];

// find checks whether both a and b belong to the same set. If not, it creates an edge between them.
int find (int x)
{
    if (x == ufd[x])
        {
            return x;        
        }
    return ufd[x] = find(ufd[x]);
}


void Union (int a, int b)
{
    ufd[find(a)] = find(b);
}

// Initially, all n elements are disjoint but as we get new inputs, we are able to create sets for them. if i != ufd[i], implies (i, ufd[i]) have an edge between them.

int main() 
{
    int n, m;
    scanf("%d%d", &n, &m);
    
    for (int i = 1; i <= n; i++)
        {
            ufd[i] = i;        
        }
    
    for (int i = 0; i < m; i++)
        {
            int x, y;
            scanf("%d%d%*d", &x, &y);
            
            // Perform disjoint set union of the two inputs
            Union(x, y);         
        }

    int ans = 0;
    for (int i = 1; i <= n; i++)
        {
            if (i == find(i))
                {
                    ++ans;
                }        
        }    
    printf("%d\n", ans);
    
    return 0;
}

Measured memory_bytes: 1152
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

int main(){
  string s;
  cin >> s;
  int N = s.size();

  for(int i=2;;i+=2){
    int sz = N - i;
    bool isok = true;
    for(int j=0;j<sz/2;j++){
      if(s[j] != s[j+sz/2]) isok = false;
    }

    if(isok){
      cout << sz << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
int m[2000][2000];
main(){
	int N,K;
	for(scanf("%d%d",&N,&K);N--;){
		int x,y;char c;
		scanf("%d%d%*c%c",&x,&y,&c);
		if(c=='W'){x+=K;}
		for(int i=0;i<2;++i){
			x%=2*K;
			y%=2*K;
			++m[y][x];
			--m[y][(x+K)%(2*K)];
			--m[(y+K)%(2*K)][x];
			++m[(y+K)%(2*K)][(x+K)%(2*K)];
			if(x>=K){
				++m[y][0];
				--m[(y+K)%(2*K)][0];
			}
			if(y>=K){
				++m[0][x];
				--m[0][(x+K)%(2*K)];
			}
			if(x>=K&&y>=K){
				++m[0][0];
			}
			x+=K;
			y+=K;
		}
	}
	for(int y=0;y<2*K;++y){
		for(int x=1;x<K;++x){
			m[y][x]+=m[y][x-1];
		}
	}
	int z=0;
	for(int x=0;x<K;++x){
		for(int y=0;y<2*K;++y){
			if(y){
				m[y][x]+=m[y-1][x];
			}
			if(m[y][x]>z){
				z=m[y][x];
			}
		}
	}
	printf("%d",z);
}


Measured memory_bytes: 15744
#include <vector>
#include <cmath>
#include <iostream>
#include <algorithm>

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

using namespace std;

int main() {

	SINT64 N = 0;
	SINT64 W = 0;

	cin >> N;
	cin >> W;
	vector<vector<SINT64>> DATA(N,vector<SINT64>(2,0));

	vector<vector<SINT64>> DP(N+1,vector<SINT64>(W+1,0));
	
	for (SINT64 i = 0; i < N; i++) {
		cin >> DATA[i][0];
		cin >> DATA[i][1];
	}

	for (SINT64 i = 1; i < N+1; i++) {
		for (SINT64 j = 1; j < W+1; j++) {
			SINT64 BUF = 0;
			if ((j-DATA[i-1][0]) >= 0) {
				DP[i][j] = MAX(DP[i-1][j],DP[i-1][j-DATA[i-1][0]] + DATA[i-1][1]);
			} else {
				DP[i][j] = DP[i-1][j];
			}
		}
	}
	SINT64 ANS = 0;
	for (SINT64 j = 0; j < W+1; j++) {
		ANS = MAX(ANS, DP[N][j]);
	}


	cout << ANS << endl;
	return 0;
}

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

//	// DATA.emplace_back(BUF);	//後ろに追加

//  DATA.erase(std::unique(DATA.begin(), DATA.end()), DATA.end());

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

// 	vector<pair<int,pair<int,int>>> DATA(M);
//	cin >> DATA[i].first;
//	cin >> DATA[i].second.first;
//	cin >> DATA[i].second.second;


//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();


/* 文字列回転
	string N;
	cin >> N;
	N = N[N.length()-1] + N.substr(0,N.length()-1);
*/

Measured memory_bytes: 80256
h,w=map(int,input().split())
a=[list(map(int,input().split())) for i in range(h)]
b=[list(map(int,input().split())) for i in range(h)]
dp=[[[0]*(80*(h+w+1)+1) for i in range(w)] for j in range(h)]
dp[0][0][abs(a[0][0]-b[0][0])]=1
for i in range(h):
  for j in range(w):
    c=abs(a[i][j]-b[i][j])
    if i!=0 or j!=0:
      for k in range(80*(i+j+1)+1):
        dp[i][j][k]=dp[i-1][j][abs(k-c)]|dp[i-1][j][k+c]|dp[i][j-1][abs(k-c)]|dp[i][j-1][k+c]
for i in range(80*(h+w+1)+1):
  if dp[h-1][w-1][i]==1:
    print(i)
    break


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


def main():
    n = int(input())
    vote_t, vote_a = 1, 1

    # See:
    # http://arc062.contest.atcoder.jp/data/arc/062/editorial.pdf
    # KeyInsight：各状態で，できるだけ得票数が少ないほうがよい
    # 高橋君にA票，青木君にB票あるとき，満たすべき比率がx：yだとすると，
    # A <= m * x ^ B <= m * yとなるような最小の自然数mを取ればよい
    for i in range(n):
        ti, ai = map(int, input().split())

        # 小数点の処理に注意
        m = max((vote_t - 1) // ti + 1, (vote_a - 1) // ai + 1)
        vote_t = ti * m
        vote_a = ai * m

    print(vote_t + vote_a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
	int n, d, x;
	cin >> n >> d >> x;
	int ans = 0;
	vector<int> a(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		ans += (d -1) /a[i] + 1;
	}
	cout << x + ans;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  vector<int> dp(n, 1 << 30);
  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);
  for (int i = 2; i < n; i++) {
    dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i -1]));
    dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
  }
  cout << dp[n - 1] << endl;
  return 0;
}

Measured memory_bytes: 1024
mod = 10 ** 9 + 7
n, k = map(int, input().split())
if n == 1:
    print(k)
    quit()

ans = k * (k - 1)
branch_n = [0] * n
for _ in range(n-1):
     nodes = map(lambda x : int(x) - 1, input().split())
     for i in nodes:
        branch_n[i] += 1
        if branch_n[i] > 1:
            ans = ans * (k - branch_n[i]) % mod
print(ans)

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

using namespace std;
using ll = long long;

template <typename K,typename V>
using umap = unordered_map<K,V>;
template <typename V>
using uset = unordered_set<V>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i,n) for(int i=0;i<n;i++)
#define REPD(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(v) v.begin(),v.end()

#define endl "\n"
#define INF 1'000'000'000'000 //10^12
#define MOD 1'000'000'007

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

  string s,t;

  cin >> s >> t;

  int n = (int)s.length();
  int m = (int)t.length();

  vector<vector<int>> dp(n+1,vector<int>(m+1,0));

  REP(i,n){
    REP(j,m){
      dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1]);
      if(s[i] == t[j]){
        chmax(dp[i+1][j+1] , dp[i][j] + 1);
      }
    }
  }
  int len = dp[n][m];
  int i = n-1;
  int j = m-1;
  string lcs = "";
  while(len > 0){
    if(s[i] == t[j]){
      lcs += s[i];
      i--;j--;len--;
    }else if(dp[i+1][j+1] == dp[i+1][j]){
      j--;
    }else{
      i--;
    }
  }

  reverse(ALL(lcs));

  cout << lcs << endl;

  return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, x;  cin >> a >> b >> x;
    if (a == 0) {
      cout << b / x + 1 << endl;
    } else {
      cout << b / x - (a - 1) / x << endl;
    }

    return 0;
}


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

# AtCoder Grand Contest
# Problem A


def sum_digit(number):
    string = str(number)
    array = list(map(int, list(string)))
    return sum(array)


if __name__ == '__main__':
    n = int(input())
    a = 0
    digit_sum_min = 1000000

    for i in range(1, n):
        a = i
        b = n - a

        sum_a = sum_digit(a)
        sum_b = sum_digit(b)
        digit_sum_min = min(digit_sum_min, sum_a + sum_b)

    print(digit_sum_min)


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	string sa;
	cin>>sa;
	if(sa[2]==sa[3] && sa[4]==sa[5])cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map>       // pair
#include <string>
#include<stdio.h>
using namespace std;

int main(int argc, const char *argv[])
{
    int a[5];
    int k;
    cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4]>>k;

    int diff = 0;
    int check = 0;
    for(int i = 0; i < 5; i ++)
    {
        for(int j = i; j < 5 ; j ++)
        {
            diff = a[j] - a[i];
            if(diff > k)
            {
                check = 1;
            }
        }
    }
    if(check == 1)
    {
    cout << ":(";
    }
    else
    {
        cout << "Yay!";
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    vector<int> x(3, 0);
    cin >> x[0] >> x[1] >> x[2];
    sort(x.begin(), x.end());
    if (x[0] == 5 && x[1] == 5 && x[2] == 7) printf("%s\n", "YES");
    else printf("%s\n", "NO");
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
int main() {
    bool arr[31];
    std::memset(arr, 0, sizeof (arr));
    int t;
    for (int i = 0; i < 28; i++) {
        std::scanf("%d", &t);
        arr[t] = true;
    }
    for (int i = 1; i <= 30; i++) {
        if (!arr[i]) std::printf("%d\n", i);
    }
    return 0;
}


Measured memory_bytes: 3216
// 最長距離を求める。並び替えて、端だけ特別処理
let k, n = stdin.ReadLine().Split() |> fun x -> int x.[0], int x.[1]
let aArrSorted = stdin.ReadLine().Split() |> Array.map (int) |> Array.sort

let mightA =
    aArrSorted
    |> Seq.pairwise
    |> Seq.map (fun (a,b) -> b-a)
    |> Seq.max

let mightB = 
    aArrSorted.[0] + (k - (aArrSorted |> Array.last))

max mightA mightB
|> fun x -> k - x
|> stdout.WriteLine

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

Achange = []
Bchange = []

for i in range(3):
  if A[i] > B[i]:
    Bchange.append(i)
  elif A[i] < B[i]:
    Achange.append(i)

#print(Achange, Bchange)

# 最初のA交換所→B交換所
Dmax1 = N
if Achange:
  if len(Achange)==3:
    i = Achange[0]
    j = Achange[1]
    k = Achange[2]
    for x in range(N+1):
      for y in range(N+1):
        if A[i]*x+A[j]*y <= N:
          Dmax1 = max(Dmax1, B[i]*x + B[j]*y + (N-A[i]*x-A[j]*y)%A[k] + (N-A[i]*x-A[j]*y)//A[k] * B[k])
    
  if len(Achange)==2:
    i = Achange[0]
    j = Achange[1]
    for x in range(N+1):
      if A[i]*x <= N:
          Dmax1 = max(Dmax1, B[i]*x + (N-A[i]*x)%A[j] + (N-A[i]*x)//A[j] * B[j])
    
  if len(Achange)==1:
    i = Achange[0]
    Dmax1 = max(Dmax1, N%A[i] + (N//A[i] * B[i]))
    
#print(Dmax1)
#print(Achange, Bchange)
#次のB交換所→A交換所
Achange = Bchange
A,B=B,A
N = Dmax1
#print(Achange, Bchange)

if Achange:
  if len(Achange)==3:
    i = Achange[0]
    j = Achange[1]
    k = Achange[2]
    for x in range(N+1):
      for y in range(N+1):
        if A[i]*x+A[j]*y <= N:
          Dmax1 = max(Dmax1, B[i]*x + B[j]*y + (N-A[i]*x-A[j]*y)%A[k] + (N-A[i]*x-A[j]*y)//A[k] * B[k])
    
  if len(Achange)==2:
    i = Achange[0]
    j = Achange[1]
    for x in range(N+1):
      if A[i]*x <= N:
          Dmax1 = max(Dmax1, B[i]*x + (N-A[i]*x)%A[j] + (N-A[i]*x)//A[j] * B[j])
    
  if len(Achange)==1:
    i = Achange[0]
    Dmax1 = max(Dmax1, N%A[i] + (N//A[i] * B[i]))
    
print(Dmax1)
 

Measured memory_bytes: 43144
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
int N;
const int MAX_N=3e5;
const ll MOD=998244353;
typedef pair<int,int> P;
vector<P> org;
int psm[MAX_N+1];
int main(){
	cin>>N;
	REP(i,N){
		int a;
		cin>>a;
		if (i==0 || org.back().first!=a){
			org.push_back(P(a,1));
		}else{
			org.back().second++;
		}
	}
	ll ans=1;
	if (org[0].second==N){
		if (org[0].first!=1){
			ans=0;
		}else{
			ans=1;
		}
		REP(i,N){
			ans*=(i+1);
			ans%=MOD;
		}
	}else{
		if (org[0].first==org.back().first){
			org[0].second+=org.back().second;
			org.pop_back();
		}
		{
			set<int> st;
			for(auto p:org){
				if (st.find(p.first)!=st.end()){
					ans=0;
					goto BREAK;
				}
				st.insert(p.first);
			}
		}
		REP(i,(int)org.size()){
			psm[i+1]=psm[i]+org[i].second;
		}
		map<int,int> mp;
		{
			int cnt=0;
			for(auto p:org){
				mp[p.first]=cnt++;
			}
		}
		map<int,int> inx;
		int cap=0,len;
		if (mp.find(1)!=mp.end()){
			inx[psm[mp[1]]]=1;
			len=org[mp[1]].second;
		}else{
			ans=0;
			len=0;
			goto BREAK;
		}
		FOR(i,2,N+1){
			if (mp.find(i)==mp.end()){
				ans*=cap;
				ans%=MOD;
				cap--;
			}else{
				int j=mp[i];
				if (!(0<=j && j<(int)org.size())){
					return 0;
				}
				if (org[j].second>len){
					ans=0;
					goto BREAK;
				}
				int prej;
				if (j>0){
					prej=j-1;
				}else{
					prej=(int)org.size()-1;
				}
				int nexj;
				if (j<(int)org.size()-1){
					nexj=j+1;
				}else{
					nexj=0;
				}
				if (!(0<=prej && prej<(int)org.size())){
					return 0;
				}
				if (!(0<=nexj && nexj<(int)org.size())){
					return 0;
				}
				int iinx;
				if (org[prej].first<i && org[nexj].first<i){
					iinx=psm[j];
					ans*=len-org[j].second+1;
					ans%=MOD;
				}else if(org[prej].first<i){
					iinx=psm[j]-(len-org[j].second);
				}else if (org[nexj].first<i){
					iinx=psm[j];
				}else{
					iinx=psm[j];
					if (org[j].second!=len){
						ans=0;
						goto BREAK;
					}
				}
				int gap;
				map<int,int>::iterator low,upp;
				upp=inx.upper_bound(iinx);
				if (upp==inx.end()){
					upp=inx.begin();
					gap=N-iinx-1+upp->first;
				}else{
					gap=upp->first-iinx-1;
				}
				if (gap<len){
					cap+=gap;
				}
				low=upp;
				if (upp==inx.begin()){
					low=inx.end();
				}
				low--;
				if (low->first<iinx){
					gap=iinx-low->first-1;
				}else{
					gap=iinx+N-low->first-1;
				}
				if (gap<len){
					cap+=gap;
				}
				inx[iinx]=i;
			}
		}
	}
	BREAK:
	cout<<ans<<endl;				
	return 0;
}

Measured memory_bytes: 33516
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int ans = -1;
    if(A < 10 && B < 10){
      ans = A*B;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define ll long long
ll f(ll x,ll y)
{
	if(y/2<=x) return y/2;
	ll ans=x;
	y-=2*x,x=0;
	return ans+y/4;
}
int main()
{
	ll s,c;
	scanf("%lld %lld",&s,&c);
	cout<<f(s,c)<<endl;
	return 0;
}

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

int main(){

  int n,m,a;
  int dat[100];
  int line[1000][3];
  while(cin >> n >> m >> a && n && m && a){
//reset
    for(int i=0; i<n; i++){
      dat[i]=i+1;
    }

//input
    for(int i=0; i<m; i++){
      cin >> line[i][0] >> line[i][1] >> line[i][2];
    }


//sort
    for(int i=0; i<m-1; i++){
      int min=i;
      for(int j=i; j<m; j++){
        if(line[min][0] < line[j][0])
          min = j;
      }

      int tmp;
      tmp=line[i][0]; line[i][0]=line[min][0]; line[min][0]=tmp;
      tmp=line[i][1]; line[i][1]=line[min][1]; line[min][1]=tmp;
      tmp=line[i][2]; line[i][2]=line[min][2]; line[min][2]=tmp;
    }

    for(int i=0; i<m; i++){
      int tmp=dat[line[i][1]-1];
      dat[line[i][1]-1] = dat[line[i][2]-1];
      dat[line[i][2]-1] = tmp;
    }


    //test
  //  for(int i=0; i<n; i++) cout << dat[i] << " " ;
    //cout << endl;

    for(int i=0; i<n; i++){
      if(dat[i]==a){
        cout << i+1 << endl;
        break;
      }
    }


  }

  return 0;
}

Measured memory_bytes: 1172
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define FIND(x, target) find(x.begin(),x.end(),target)
#define pb(x) push_back(x)
#define pob(x) pop_back(x)
#define output(x) cout<<x<<endl
#define ERASE(x, n) x.erase(x.begin()+n)
// #define int long long
// #define P pair<int, int>
typedef long long ll;

const long long int MOD = 1e9+7;
const int INF = -1;
ll dp[100005][13];

signed main(void) {
	int N, M;
	cin >> N >> M;

	int ans = N - 2*M;
	if (ans <= 0) {
		ans = 0;
	}

	cout << ans << endl;

}


Measured memory_bytes: 256
from sys import stdin


n = int(stdin.readline().rstrip())
arr = [int(x) for x in stdin.readline().rstrip().split()]

rslt = []

ex = 0
cntr = 1
bb = 0

for a,j in enumerate(arr):
    if j == cntr:
        cntr += 1
    else:
        bb += 1


if bb == n:
    print(-1)
else:
    print(bb)



Measured memory_bytes: 26012
#include<stdio.h>
int main(){
  int n,l,s,a;
  scanf("%d %d",&n,&l);
  s=n*(l-1)+n*(n+1)/2;
  if(l+n-1<=0) a=l+n-1;
  if(l<0&&l+n-1>0) a=0;
  if(l>=0) a=l;
  printf("%d",s-a);
  return 0;
}
  


Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

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


Measured memory_bytes: 3572
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();

		System.out.print(Math.max(Math.min(b, d) - (Math.max(a, c)), 0));

	}
}

Measured memory_bytes: 21844
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	int n;
	cin>>n;
	cout<<((n+1)/2)-1;
	
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
int n,a[200000],dlt;

int gcd(int a, int b) {
  if(a<b)gcd(b,a);
  int r;
  while((r=a%b)){
    a=b;
    b=r;
  }
  return b;
}

int  main()
{
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    dlt=gcd(a[0],a[1]);
    for(int i=1;i<n;i++){
        dlt=gcd(dlt,a[i]);
    }
    cout<<dlt<<endl;


}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
typedef long long ll;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define bit(k) (1LL<<(k))
#define SUM(v) accumulate(all(v), 0LL)

typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
struct fast_ios{ fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; }fast_ios_;

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

#define TOSTRING(x) string(#x)
template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (T &x : vec) is >> x; return is; }
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os  << "["; for(auto _: v) os << _ << ", "; os << "]"; return os; };
template <typename T> ostream &operator<<(ostream &os, set<T> &st) { os << "("; for(auto _: st) { os << _ << ", "; } os << ")";return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair< T, U >& p){os << "{" <<p.first << ", " << p.second << "}";return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &mp){ os << "["; for(auto _: mp){ os << _ << ", "; } os << "]" << endl; return os; }

#define DUMPOUT cerr
void dump_func(){ DUMPOUT << endl; }
template <class Head, class... Tail> void dump_func(Head &&head, Tail &&... tail) { DUMPOUT << head; if (sizeof...(Tail) > 0) { DUMPOUT << ", "; } dump_func(std::move(tail)...); }

#ifdef DEBUG
#define dbg(...) dump_func(__VA_ARGS__)
#define dump(...) DUMPOUT << string(#__VA_ARGS__) << ": "; dump_func(__VA_ARGS__)
#else
#define dbg(...)
#define dump(...)
#endif

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = 1000000007;
// const ll MOD = 998244353;
const long double PI = acos(-1.0);

/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/


int main() {
    int N, Q;
    cin >> N >> Q;
    atcoder::fenwick_tree<ll> Tree(N);
    rep(i,N){
        ll a;
        cin >> a;
        Tree.add(i, a);
    }
    while(Q--){
        int type;
        cin >> type;
        if(type == 0){
            int idx;
            ll x;
            cin >> idx >> x;
            Tree.add(idx, x);
        }
        else{
            int l, r;
            cin >> l >> r;
            cout << Tree.sum(l, r) << endl;
        }
    }
}


Measured memory_bytes: 8244
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		Obj[] arr = new Obj[n];
		for (int i = 0; i < n; i++) {
			String[] sa = br.readLine().split(" ");
			Obj o = new Obj();
			int x = Integer.parseInt(sa[0]);
			int l = Integer.parseInt(sa[1]);
			o.x = x;
			o.l = x - l;
			o.r = x + l;
			arr[i] = o;
		}
		br.close();

		Arrays.parallelSort(arr, (o1, o2) -> o1.r - o2.r);
		int ans = 0;
		int now = Integer.MIN_VALUE;
		for (int i = 0; i < arr.length; i++) {
			if (now <= arr[i].l) {
				ans++;
				now = arr[i].r;
			}
		}
		System.out.println(ans);
	}

	static class Obj {
		int x, l, r;
	}
}


Measured memory_bytes: 47472
#include <bits/stdc++.h>
#define rep(i, l, r) for (register int i = l; i <= r; i++)
#define per(i, r, l) for (register int i = r; i >= l; i--)
#define srep(i, l, r) for (register int i = l; i < r; i++)
#define sper(i, r, l) for (register int i = r; i > l; i--)
#define erep(i, x) for (register int i = h[x]; i; i = e[i].next)
#define maxn 3020
#define maxm 30020
#define ll long long int 
using namespace std;

const int inf = 2000000020;

int n, m, s, t;
struct edge{
	int next, to, flow, cost;
	edge(int next, int to, int flow, ll cost) : next(next), to(to), flow(flow), cost(cost){}
	edge(){}
}e[maxm << 1];
int cnt = 1, h[maxn];
void Add_Edge(int x, int y, int z, ll w){
	e[++cnt] = edge(h[x], y, z, w);
	h[x] = cnt;
	e[++cnt] = edge(h[y], x, 0, -w);
	h[y] = cnt;
}
int p[maxn];
ll d[maxn];
bool und[maxn];
int spfa[maxn];
bool vis[maxn];
int head = 0, tail = 0;
bool SPFA(){
	rep(i, s, t) und[i] = 1;
	d[s] = 0, und[s] = 0;
	head = tail = 0;
	spfa[++head] = s;
	vis[s] = 1;
	while (head != tail){
		int x = spfa[++tail];
		tail = (tail == maxn - 1) ? 0 : tail;
		erep(i, x){
			if (!e[i].flow) continue;
			int op = e[i].to;
			if (d[op] > d[x] + e[i].cost || und[op]){
				p[op] = i;
				und[op] = 0;
				d[op] = d[x] + e[i].cost;
				if (!vis[op]) {
					vis[op] = 1;
					spfa[++head] = op;
					head = (head == maxn - 1) ? 0 : head;
				}
			}
		}
		vis[x] = 0;
	}
	return !und[t];
}
void Augment(int& maxflow, ll& mincost){
	int now = t, flow = inf;
	while (now != s){
		int k = p[now];
		flow = min(flow, e[k].flow);
		now = e[k ^ 1].to;
	}
	now = t;
	while (now != s){
		int k = p[now];
		e[k].flow -= flow, e[k ^ 1].flow += flow;
		now = e[k ^ 1].to;
	}
	maxflow += flow, mincost += (d[t] - d[s]) * flow;
}
void MCMF(int& maxflow, ll& mincost){
	while (SPFA()) Augment(maxflow, mincost);
}
//     R      B
// 1  + +    - -
// 2  + -    - +
// 3  - +    + -
// 4  - -    + +

int main(){
	int T, sum = 0;
	ll x, y, z;
	scanf("%d", &T);
	s = 0, t = 2 * T + 5;
	rep(TT, 1, T){ //4 + TT
		scanf("%lld%lld%lld", &x, &y, &z);
		Add_Edge(s, 4 + TT, z, 0);
		Add_Edge(4 + TT, 1, z, -(+ x + y));
		Add_Edge(4 + TT, 2, z, -(+ x - y));
		Add_Edge(4 + TT, 3, z, -(- x + y));
		Add_Edge(4 + TT, 4, z, -(- x - y));
		sum += z;
	}
	rep(TT, 1, T){ //4 + TT + T
		scanf("%lld%lld%lld", &x, &y, &z);
		Add_Edge(4 + TT + T, t, z, 0);
		Add_Edge(1, 4 + TT + T, z, +(+ x + y));
		Add_Edge(2, 4 + TT + T, z, +(+ x - y));
		Add_Edge(3, 4 + TT + T, z, +(- x + y));
		Add_Edge(4, 4 + TT + T, z, +(- x - y));
	}
	int maxflow = 0;
	ll mincost = 0;
	MCMF(maxflow, mincost);
	assert(maxflow == sum);
	printf("%lld\n", -mincost);
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
int main() {
  int a, b;
  std::cin >> a >> b;
  if (a < b) {
    std::cout << "a < b" << std::endl;
  } else if (a > b) {
    std::cout << "a > b" << std::endl;
  } else {
    std::cout << "a == b" << std::endl;
  }
}

Measured memory_bytes: 1156
program ABC168_C
  double precision::A,B,H,M
  double precision::pi,radH,radM,rad,ans
  read(*,*)A,B,H,M
  pi=datan(1.0d0)*4.0d0
  radH=(3.0d1*H+5.0d-1*M)*pi/1.8d2
  radM=6.0q0*M*pi/1.8d2
  rad=dabs(radH-radM)
  ans=sqrt(A*A+B*B-2.0d0*A*B*dcos(rad))
  write(*,*)ans
end program ABC168_C

Measured memory_bytes: 3396
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define N 505
typedef long long ll;
const ll inf=0x3f3f3f3f3f3f3f3fll;
inline ll read(){
	ll x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int a[N][N],n;
ll dp[N][N],s[2][N][N],ans;
inline ll calc(int i,int X1,int Y1,int X2,int Y2){
	return s[i][X2][Y2]-s[i][X1-1][Y2]-s[i][X2][Y1-1]+s[i][X1-1][Y1-1];
}
int main(){
	n=read();
	for(int i=1;i<=n;++i){
		for(int j=1;j<=n;++j){
			if(i==j)continue;
			a[i][j]=read();
		}
	}
	ans=inf;
	for(int i=1;i<=n;++i){
		for(int j=1;j<=n;++j){
			s[0][i][j]=s[0][i-1][j]+s[0][i][j-1]-s[0][i-1][j-1]+(i<j?a[i][j]:0);
			s[1][i][j]=s[1][i-1][j]+s[1][i][j-1]-s[1][i-1][j-1]+(j<i?a[i][j]:0);
		}
	}
	memset(dp,0x3f,sizeof(dp));
	dp[0][0]=0;
	for(int i=0;i<n;++i){
		for(int j=0;j<=i;++j){
			for(int k=i+1;k<=n;++k){
				dp[k][i]=min(dp[k][i],dp[i][j]+calc(0,i+1,i+1,k,k)+calc(1,i+1,1,k,j));
			}
		}
	}
	for(int i=0;i<n;++i){
		ans=min(ans,dp[n][i]);
	}
	printf("%lld\n",ans);
	return 0;
}




Measured memory_bytes: 10704
#include <iostream>
#include <cmath>

using namespace std;
typedef long long ll;
  int main(void){
  ll a,b,c;

  cin >> a >> b >> c;

  ll d = c - a - b;
  if(d > 0 && d * d > 4 * a * b){
  cout << "Yes" << endl;
  } else {
  cout << "No" << endl;
  }
 
  return 0;
  }

Measured memory_bytes: 3584
n,m=map(int,input().split())
a=list(map(int,input().split()))
price=sum(a)*(1/4/m)
ans=[]

for i in range(n):
  if a[i]>=price:
    ans.append(a[i])
    
if len(ans)>=m:
  print("Yes")
  
else:
  print("No")

Measured memory_bytes: 3060
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  ll n,m;
  cin>>n>>m;
  vector<ll>a(n,0);
  for(ll i=0;i<m;i++){
    cin>>a[i];
  }
  vector<ll>v(n+1,0);
  v[0]=1;
  ll j=0;
  if(j<m&&a[j]==1){
    j++;
  }else{
    v[1]=1;
  }
  for(ll i=2;i<=n;i++){
    if(j<m&&a[j]==i){
      j++;
    }else{
      v[i]=(v[i-1]+v[i-2])%MOD;
    }
  }
  cout<<v[n]<<endl;
}


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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
using tp = tuple<ll, ll, ll>;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
//constexpr long long MOD = (ll)1e9 + 7;
constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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;
}

//グラフ関連
struct Edge {
    ll to, cap, rev;
    Edge(ll _to, ll _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph &G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    ll n;
    cin >> n;
    ll pre = 0;
    ll con = 0;
    REP(i, n) {
        ll a;
        cin >> a;
        if(pre <= a)
            pre = a;
        else {
            con += pre - a;
        }
    }
    cout << con << en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*
    ll t;
    cin >> t;
    while(t--)*/
    solve();

    return 0;
}


Measured memory_bytes: 3612
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

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

func main() {
	defer stdout.Flush()
	r := readInt()
	g := readInt()
	b := readInt()
	n := readInt()

	var ans int64
	for i := 0; i <= n; i += r {
		for j := 0; i+j <= n; j += g {
			k := n - i - j
			if k%b != 0 {
				continue
			}
			//eprintln(i, j, k)
			ans++
		}
	}
	println(ans)
}

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


Measured memory_bytes: 640
package main

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

var scanner = bufio.NewScanner(os.Stdin)

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

	n := nextInt()
	m := make(map[string]int)
	a := []string{"M", "A", "R", "C", "H"}
	for i := 0; i < n; i++ {
		name := next()
		for _, v := range a {
			if string(name[0]) == v {
				m[v]++
				break
			}
		}
	}

	if len(m) < 3 {
		fmt.Println(0)
	} else {
		var keys []string
		for k := range m {
			keys = append(keys, k)
		}
		ans := 0
		for i := 0; i < len(keys)-2; i++ {
			for j := i + 1; j < len(keys)-1; j++ {
				for k := j + 1; k < len(keys); k++ {
					ans += m[keys[i]] * m[keys[j]] * m[keys[k]]
				}
			}
		}
		fmt.Println(ans)
	}
}

func next() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	i, err := strconv.Atoi(next())
	if err != nil {
		fmt.Println(err)
	}
	return i
}


Measured memory_bytes: 1536
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>

#define MOD 1e9+7;
#define INF 1e17+9;
#define PI acos(-1);

using namespace std;

int main() {

	int R,G,B,N;
	cin >> R >> G >> B >> N;
	
	long long cnt=0;
	for(int r=0;r<=3000/R;r++){
		for(int g=0;g<=3000/G;g++){
			long long x=r*R+g*G;
			if(N>=x && (N-x)%B==0){
				cnt++;
				//break;
			}
		}
	}
    cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int a,b;
    for(int i=0;i<100000;i++){
        cin >> a >> b;
        if(a==0&&b==0){
            break;
        }
        for (int j=0;j<a;j++){
            for(int k=0;k<b;k++){
                if((j>=1&&j<a-1)&&(k>=1&&k<b-1)){
                    cout << ".";
                }
                else {
                    cout << "#";
                }
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <ctype.h>
 
 
 
int main(int argc, const char * argv[]) {
    // insert code here...
     
    while (1) {
        char yama[201];
        scanf("%s",yama);
        if(yama[0] == '-'){
            break;
        }
 
        int m;
        scanf("%d",&m);
         
        int i;
        for(i=0;i<m;i++){
            int h;
            scanf("%d",&h);
             
            char head[201] = {},tail[201] = {};
            strncpy(tail, yama, h);
            strcpy(head, yama+h);
             
            char *sum = strcat(head, tail);
            strcpy(yama, sum);
             
        }
         
        printf("%s\n",yama);
         
    }
 
     
    return 0;
}


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

int main()
{
    int n, k;
    cin >> n >> k;

    vector<int> pileSumList(1, 1);
    for (int i = 2; i <= 1000; ++i)
    {
        pileSumList.push_back(pileSumList.at(i - 2) + i);
    }

    vector<double> expectancySumList;
    double expectancySum = 0;

    for (int i = 0; i < n; ++i)
    {
        int input;
        cin >> input;

        double singleExpectancy = (double)pileSumList.at(input - 1) / (double)input;
        expectancySum += singleExpectancy;

        expectancySumList.push_back(expectancySum);
    }

    double maxExpectancy = expectancySumList.at(k - 1);

    for (int i = k; i < n; ++i)
    {
        maxExpectancy = max(maxExpectancy, expectancySumList.at(i) - expectancySumList.at(i - k));
    }

    cout << fixed << setprecision(10) << maxExpectancy << endl;
}

Measured memory_bytes: 2428
#include <bits/stdc++.h>    
    
using namespace std;    
    
typedef unsigned int ui;    
typedef long long ll;    
typedef unsigned long long ull;    
    
int main() {    
    int A, B;    
    cin >> A >> B;    
    cout << (max(A + B, max(A, B) * 2 - 1)) << endl;    
}

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

int main(){
    unsigned long long n;
    cin >> n;

    unsigned long long tmp = n;
    unsigned long long fx = 0;
    while(tmp!=0){
        fx += tmp % 10;
        tmp /= 10;
    }

    if(n%fx==0)cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 384
#include"bits/stdc++.h"
using namespace std;
int main(){
	char chh[500005];
	string a;
	cin>>a;
	int head=200001,tail=200001;
	for(int i=0,j=200001;i<a.length();j++,i++){
		chh[j]=a[i];
		tail++;
	}
	tail--;
	int n;
	scanf("%d",&n);
	int num,amount=0;
	while(n--){
		scanf("%d",&num);
		if(num==1){
			swap(tail,head);
		}else {
			int tnum;char tt,jia;
			scanf("%d%c%c",&tnum,&tt,&jia);
			if(tnum==1){
				if(head<=tail)chh[--head]=jia;
				else chh[++head]=jia;
				//cout<<"--------"<<head<<tail<<endl;
			}else {
				if(head<=tail)chh[++tail]=jia;
				else chh[--tail]=jia;
				//cout<<chh[200003]<<endl<<chh[200002]<<endl;
				//cout<<"---+++++"<<head<<tail<<endl;
			}//00 02
		}
	}
	if(head<=tail){
		for(int i=head;i<=tail;i++){
			printf("%c",chh[i]);
		}
	}else {
		for(int i=head;i>=tail;i--){
			printf("%c",chh[i]);
		}
	}
	
	cout<<endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int tH,tS,aH,aS,i;
    scanf("%d %d %d %d",&tH,&tS,&aH,&aS);
    i=0;
    while(1)
    {
        if(tH<=0)
        {

            printf("No");
            break;
        }
        else if(aH<=0)
        {
            printf("Yes");
            break;
        }
        else
        {
            if(i==0)
            {
             aH=aH-tS;
             i=1;
            }
            else if(i==1)
            {
                tH=tH-aS;
                i=0;
            }
        }
    }
}


Measured memory_bytes: 1708