akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"fmt"
	"sort"
)

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

func main() {
	// set two int for number of cake being sold in shop and number of cake to eat
	var n, m int
	fmt.Scan(&n, &m)
	// set beauty[0], taste[1] and popularity[2] for all cakes being sold in shop
	scores := make([][]int, n)
	for i := 0; i < n; i++ {
		scores[i] = make([]int, 3)
	}
	for i := 0; i < n; i++ {
		fmt.Scan(&scores[i][0], &scores[i][1], &scores[i][2])
	}
	// we have 8 ways of chosing maxvalue
	// Max or Min of Beauty or Taste or Popularity
	var max int
	// bit全探索
	for bit := uint(0); bit < (1 << 3); bit++ {
		// store scores for each bit
		var tmpScores []int
		// store value of this bit
		var tmpMax int
		for i := 0; i < n; i++ {
			// a score of each cake in each bit
			eachScore := 0
			for j := uint(0); j < 3; j++ {
				if bit&(1<<j) == 1<<j {
					// if jth digit is 1
					eachScore += scores[i][j]
				} else {
					//if jth digit is 0
					eachScore -= scores[i][j]
				}
			}
			// append a score of a cake in that bit
			tmpScores = append(tmpScores, eachScore)
		}
		//sort cakes by their scores in descending order
		sort.Sort(sort.Reverse(sort.IntSlice(tmpScores)))
		// fetch scores from top to bottom till mth element and add them all to get the maximum value of that bit
		for i := 0; i < m; i++ {
			tmpMax += tmpScores[i]
		}
		// check this temporary max exceeds max that we held till this timepoint
		max = getLarge(max, tmpMax)
	}
	fmt.Printf("%d", max)
}


Measured memory_bytes: 768
#include<stdio.h>
int main(void)
{
    int a,b,c;
    int mem;
    scanf("%d %d %d",&a,&b,&c);
    if(a>b)
    {
        mem=a;
        a=b;
        b=mem;
    }
    if(b>c)
    {
        mem=b;
        b=c;
        c=mem;
    }
    if(a>b)
    {
        mem=a;
        a=b;
        b=mem;
    }
    printf("%d %d %d\n",a,b,c);
    return 0;
}

Measured memory_bytes: 2760
/*
	考虑新加进来的水与当前水的温度的关系
	大于当前温度, 我可以选择踢掉之前的水
	小于当前温度, 肯定是加进来这些水再一起踢更优
	那么这样子就可以维护一个水温度单调上升的队列
*/
#include <iostream>
#include <cstdio>
#define N 500005

using namespace std;

int n, lim;

pair<long long, double> que[N];

inline void read(int &x) {
	x = 0; char ch = getchar();
	while(!isdigit(ch)) ch = getchar();
	while(isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
}

int main() {
	read(n), read(lim);
	int hd = 0, tl = -1;
	int cur = 0; double sum = 0;
	for(int i = 1, v, t; i <= n; ++i) {
		read(t), read(v);
		cur += v, sum += 1LL * v * t;
		while(cur > lim) {
			int del = cur - lim;
			long long &u = que[hd].first;
			if(u > del) {
				u -= del;
				sum -= del * que[hd].second;
				cur = lim;
			} else {
				sum -= u * que[hd].second;
				cur -= u;
				++hd;
			}
		}
		que[++tl] = make_pair(v, t);
		while(hd < tl && que[tl - 1].second > que[tl].second) {
			long long v1 = que[tl - 1].first, v2 = que[tl].first;
			double t1 = que[tl - 1].second, t2 = que[tl].second;
			que[--tl] = make_pair(v1 + v2, (v1 * t1 + v2 * t2) / (v1 + v2));
		}
//		cerr << que[hd].first << ' ' << que[hd].second << endl;
		printf("%.7lf\n", sum / lim);
	}
	return 0;
}

Measured memory_bytes: 16896
#include <stdio.h>

int v[50];
int hand[50];

int pfor[51], pback[51];

int heap[50], hz = 0;
int temp[50], tz = 0;

void hpush(int n) {
	//printf("push:%d (%d)\n", n, hz);
	int i = hz++;
	heap[i] = n;
	while (i) {
		int p = (i-1)/2;
		if (heap[i] < heap[p]) {
			int t = heap[i];
			heap[i] = heap[p];
			heap[p] = t;
		} else break;
	}
}

int hpop(void) {
	if (!hz) return 0;
	int ret = heap[0];
	heap[0] = heap[--hz];
	int i = 0;
	while (i*2+1 < hz) {
		int c = i*2+1;
		if (c+1 < hz && heap[c] > heap[c+1]) c++;
		if (heap[i] > heap[c]) {
			int t = heap[i];
			heap[i] = heap[c];
			heap[c] = t;
		} else break;
	}
	return ret;
}

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

	pfor[0] = pback[0] = 0;
	for (int i = 1; i <= n; i++) {
		pfor[i] = pfor[i-1] + v[i-1];
		pback[i] = pback[i-1] + v[n-i];
	}

	int max = 0;
	for (int l = 0; l <= k && l <= n; l++) {
		if (l && v[l-1] < 0) hpush(v[l-1]);
		for (int r = 0; l+r <= k && l+r <= n; r++) {
			if (r && v[n-r] < 0) hpush(v[n-r]);
			int sum = pfor[l] + pback[r];
			//printf("l:%d r:%d = %d;", l, r, sum);
			int c;
			for (int rem = k-l-r; rem && (c = hpop()); rem--) {
				//printf(" %d", c);
				sum -= c;
				temp[tz++] = c;
			}
			//printf(" (%d)\n", sum);
			if (sum > max) max = sum;
			while (tz) hpush(temp[--tz]);
		}
		hz = 0;
		for (int i = 0; i < l; i++)
			if (v[i] < 0) hpush(v[i]);
	}
	printf("%d\n", max);
}


Measured memory_bytes: 128
N,K = map(int, input().split())
A = [int(a) for a in input().split()]
F = [int(f) for f in input().split()]

A.sort()
F.sort(reverse=True)

if K >= sum(A):
    ans = 0
else:
    u = 10**13
    l = 0
    while u-l > 1:
        x = (u+l)//2
        cnt = K
        for i in range(N):
            cnt -= max(0, A[i]-x//F[i])
        if cnt >= 0:
            u = x
        else:
            l = x
    cnt = K
    for i in range(N):
        cnt -= max(0, A[i]-l//F[i])
    if cnt >= 0:
        ans = l
    else:
        ans = u
        
print(ans)

Measured memory_bytes: 119884
#include<iostream>
int main(){
int n,m,b,c;
std::cin>>n>>m>>b;c=b;
for(int i=0;i<99;i++){
if(c%(n+m)<=n){goto a;}
c+=60;
}
c=-1;
a:
std::cout<<c<<"\n";return 0;}

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

#define for_(i,a,b) for(int i = (a);i < (b);i++)
#define rfor_(i,a,b) for(int i = (b)-1;i >= (a);i--)
#define rep(i,n) for_(i,0,(n))
#define rrep(i,n) rfor_(i,0,(n))

int n, m;

int main(){
	cin.tie(0);
	
	while(cin>>n>>m,n||m)cout<<(n<m?n:m)<<' '<<(m<n?n:m)<<endl;

	return 0;
}



Measured memory_bytes: 3052
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;
const double PI = 3.14159265358979323846;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define endl "\n"

int main() {
	int N;
	long long x;
	cin >> N >> x;
	vector<long long> A(N);
	vector<long long> B(N - 1, 0);
	for (int i = 0; i < N; ++i)cin >> A[i];

	long long count = 0;
	for (int i = 0; i < B.size(); ++i) {
		B[i] = A[i] + A[i + 1];
		if (x < B[i]) {
			long long buf = B[i] - x;
			count += buf;
			A[i + 1] = max(A[i + 1] - buf, 0ll);
		}
	}

	cout << count << endl;
	return 0;
}

Measured memory_bytes: 4816
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        final int N = sc.nextInt();
        int[] l = new int[N+1];
        int[] l2 = new int[N];
        for(int i = 0;i < N+1;i++)  l[i] = sc.nextInt();
        if(N == 1){
            System.out.println(Math.abs(l[0]-l[1]));
            return;
        }
        Arrays.sort(l);
        for(int i = 0;i < N;i++){
            l[i] = l[i+1]-l[i];
        }
        int d = 0;
        for(int i = 0;i < N-1;i++){
            if(i == 0)  d = l[0];
            int b = l[i+1];
            while(true){
                if(d%b == 0){
                    d = b;
                    break;
                }else{
                    int tmp = d;
                    d = b;
                    b = tmp%b;
                }
            }
            if(d == 1)  break;
        }
        System.out.println(d);
    }
}

Measured memory_bytes: 50432
#include<bits/stdc++.h>
using namespace std;
#define int long long int
int n, p;
string s;

int32_t main()
{
    cin >> n >> p;
    cin >> s;
    vector<int>v(p+5, 0);
    v[0] = 1;
    int ans = 0;
    if(p == 2 || p == 5)
    {
        for(int i=n-1; i>=0; i--)
        {
            if((s[i] - '0')%p == 0)
            {
                ans += i+1;
            }
        }
        cout << ans << endl;
        return 0;
    }
    int pw = 1;
    int rem = 0;
    for(int i=n-1; i>=0; i--)
    {
        int cur = s[i] - '0';
        rem = (rem + cur * pw) % p;
        pw = (pw * 10)%p;
        ans += v[rem];
        v[rem]++;
    }

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


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

n = int(input())
x = [int(i) for i in input().split()]
xm = min(x)
xmm = max(x)
min = 9999999999999
for p in range(xm,xmm+1):
    sum = 0
    for xi in x:
        sum += (xi-p)**2
    if sum < min:
        min = sum
print(min)

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

int main() {
  long long n; cin >> n; 
  vector<int>v(n);
  for(int i = 0; i<n; i++){
    cin >> v[i];
  }
  sort(v.begin(),v.end());
  long long a = n/2;
  cout << v[a]-v[a-1] << endl;
}

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

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 10000;
#define MAX 110
signed main() {
	int N, K; cin >> N >> K;
	int A[MAX] = {};
	fill(A, A + MAX, INF);
	rep(i, 0, K) {
		int a, b; cin >> a >> b;
		A[a] = --b;
	}
	int dp[MAX][3][2] = {};
	rep(j, 0, 3) {
		if (A[1] != INF&&A[1] != j)continue;
		dp[1][j][0] = 1;
	};
	rep(i, 1, N) {
		rep(j, 0, 3) {
			dp[i][j][0] %= MOD;
			dp[i][j][1] %= MOD;
			if (A[i] != INF&&A[i] != j)continue;
			rep(x, 0, 3) {
				int k = 0;
				if (x == j)k = 1;
				dp[i + 1][x][k] += dp[i][j][0];
				if (x != j)dp[i + 1][x][0] += dp[i][j][1];
			}
		}
	}
	//rep(i, 0, N) {
	//	cerr << i;
	//	rep(j, 0, 3) {
	//		int ans = 0;
	//		rep(k, 0, 2) {
	//			if (A[i] != INF&&A[i] != j)continue;
	//			ans += dp[i][j][k];
	//		}
	//		cerr << " " << ans;
	//	}
	//	cerr << endl;
	//}
	int ans = 0;
	rep(j, 0, 3)rep(k, 0, 2) {
		if (A[N] != INF&&A[N] != j)continue;
		ans += dp[N][j][k];
	}
	ans %= MOD;
	cout << ans << endl;
	return 0;
}

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

int		main(void)
{
	int		N;
	cin >> N;
	vector<int> h(N);
	vector<pair<int, int>> hVecPair(N);
	for (int i = 0; i < N; i++) cin >> h.at(i);
	for (int i = 0; i < N; i++) hVecPair.at(i) = make_pair(h.at(i), 0);
	int		counter = 0;
	for (int i = 0; i < N ;)
	{
		if (hVecPair.at(i).first != hVecPair.at(i).second)
		{
			for (int j = i; j < N; j++)
			{
				if (hVecPair.at(j).first == hVecPair.at(j).second)
					break ;
				else
					hVecPair.at(j).second++;
			}
			counter++;
		}
		else i++;
	}
	// cout << "--------------------------------Debug_VecPair--------------------------------" << endl;
	// for (auto i : hVecPair)
	// {
	// 	auto first = i.first;
	// 	auto second = i.second;
	// 	cout << "\thVecPair : first = " << first << ", second = " << second << ";" << endl;
	// }
	// cout << "-------------------------------------END-------------------------------------" << endl;
	cout << counter << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
 int main(){
	int a,b,c,ans,max=0;
	scanf("%d%d%d",&a,&b,&c);
	ans=a+b+c;
	if(max<a)
		{
			max=a;
		}
	if(max<b)
		{
			max=b;
		}
	if(max<c)
		{
			max=c;
		}
	printf("%d\n",ans-max);
}

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

int main() {

  int A,B;
  int n,d,s;

  cin >> n >> A >> B;
d = 0;
s = 0;
  for(int i = 1;i <= n; i++)
  {
    int x = i;
    d = 0;
    while(x)
    {
      d += x%10;
      x = x /10;
    }
    if ((A <= d) && (d <=B))
    {
      s += i;
    }
  }

cout << s;

  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
long long cost[101],cap[101],n;
long long dp[2][100005];
 
long long knap(int n,int c){
    
    for(int i=0;i<=n;i++){
        for(int j=0;j<=c;j++){
          
          if(i%2==0){
              if(i==0 || j==0) dp[0][j]=0;
            else if(cap[i-1]>j) dp[0][j]=dp[1][j];
            else{
                long long t1,t2;
                t1=dp[1][j];
                t2=dp[1][j-cap[i-1]]+cost[i-1];
                dp[0][j]=max(t1,t2);
            }
          } 
          
          else{
               if(i==0 || j==0) dp[1][j]=0;
            else if(cap[i-1]>j) dp[1][j]=dp[0][j];
            else{
                long long t1,t2;
                t1=dp[0][j];
                t2=dp[0][j-cap[i-1]]+cost[i-1];
                dp[1][j]=max(t1,t2);
            }
          }
        }
    }
    return (n%2 != 0)? dp[1][c] : dp[0][c]; 
}
int main(){
    
        memset(dp,-1,sizeof(dp));
      
        long long c;
        cin >> n >> c;
       
        for(int i=0;i<n;i++){
            cin >> cap[i] >> cost[i] ;
           
        }
        
        cout << knap(n,c) << endl;
    
}

Measured memory_bytes: 5144
object Main extends App {
  val input = io.Source.stdin.getLines.toIndexedSeq.tail.head.split(' ').map(_.toInt).toSeq
  val avg:Double = input.sum.toDouble / input.size
  
  val min:Double = input.foldLeft(Double.MaxValue){ (a,e) =>
    val dist = Math.abs(avg - e.toDouble)
    //println(dist)
    Math.min(a, dist)   
  }
  //println(min)
  val f = input.indexWhere(e => Math.abs(avg - e.toDouble) == min)
  println(f)
}


Measured memory_bytes: 25420
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

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

    int sum = 0;
    int res = 0;
    for (int i = 0; i < 5; ++i) {
        int t;
        cin >> t;
        sum += t + (10 - t % 10) % 10;
        res = max(res, (10 - t % 10) % 10);
    }
    cout << sum - res << endl;

    return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()

can = [0]*101
can[0] = 0

for i in range(26):
	for j in range(15):
		if i * 4 + j * 7 == N:
			print("Yes")
			sys.exit()
else:
	print("No")


Measured memory_bytes: 4088
#include <stdio.h>
int main()
{
	int W, H, x, y, r;
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
		
	if ((W >= x + r) && (H >= y + r) && (x - r >= 0) && (y - r >= 0))
		printf("Yes\n");
	else
		printf("No\n");

	return 0;
}


Measured memory_bytes: 2700
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const int inf = 1012345678;
int main() {
	vector<int> A(5);
	cin >> A[0] >> A[1] >> A[2] >> A[3] >> A[4];
	vector<int> P = { 0, 1, 2, 3, 4 };
	int final_answer = inf;
	do {
		int ans = 0;
		for (int i = 0; i < 5; ++i) {
			while (ans % 10 != 0) ans += 1;
			ans += A[P[i]];
		}
		final_answer = min(final_answer, ans);
	} while (next_permutation(P.begin(), P.end()));
	cout << final_answer << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        char[] cube = sc.next().toCharArray();
        int zero = 0,
        one = 0;
        for(int i = 0; i < cube.length; i++){
            switch(cube[i]){
                case '0':
                zero++;
                break;
                default :
                one++;
            }
        }
        System.out.println(Math.min(zero, one)*2);
    }
}

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

typedef pair<int,int> P;
typedef pair<P,int> P1;

const int INF = 1e9;

int n, m, used[100005];
map<int,vector<int> > G[100005];
map<P1,int> d;

queue<P> q;

set<P> memo;

void dfs(int x, int C, int cost){
  
  if( !used[x] ){
    used[x] = 1;
    q.push(P(x,cost + 1));
  }
  
  if( memo.count(P(x,C)) == 1 ) return;
  memo.insert(P(x,C));
  
  for(int p : G[x][C] ){
    
    int minn = min( x, p );
    int maxn = max( x, p );
    
    if( !used[p] ){
      used[p] = 1;
      q.push(P(p,cost + 1));
    }
    
    if( d.count(P1(P(minn,maxn),C)) == 0 ){
      d[P1(P(minn,maxn),C)] = cost;
      dfs(p,C,cost);
    }
    
  }
  
}

void solve(){

  q.push(P(0,1));
  
  while(!q.empty()){
    
    P tmp = q.front(); q.pop();
    
    int node = tmp.first;
    int cost = tmp.second;
        
    for(auto p : G[node] ){
      
      int C = p.first;
      
      for(int p2 : p.second ){
	
	int minn = min( node, p2 );
	int maxn = max( node, p2 );
	
	if( d.count(P1(P(minn,maxn),C)) == 0 ){
	  d[P1(P(minn,maxn),C)] = cost;
	  dfs(p2,C,cost);
	}
	
      }
      
    }
    
  }
  
  int ans = INF;
  
  for(auto p : d ){
    
    if( p.first.first.second == n - 1 ) ans = min( ans, p.second );
    
  }

  if( ans == INF ) cout<<-1<<endl;
  else cout<<ans<<endl;
  
}

int main(){
  
  cin>>n>>m;
  
  for(int i=0;i<m;i++){
    int p, q, c;
    cin>>p>>q>>c;
    G[p-1][c].push_back(q-1);
    G[q-1][c].push_back(p-1);
  }
  
  solve();
  
  return 0;
}


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

int main() {
  string s;
  bool flag;

  cin >> s;

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

  flag = (s[0]==s[1])&(s[1]!=s[2])&(s[2]==s[3]);

  cout << (flag?"Yes":"No") << endl;

  return 0;
}


Measured memory_bytes: 384
#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 um unordered_map<ll,ll>
#define ms(x) memset(x , 0 , so x)
#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 ;
    cin >> n ;
    string s ;
    cin >> s ;
    s.insert(0 , "%");
    ll arr[n+1];
    ms(arr);
    forn(i , 1 , n){
       if(s[i] == 'E'){
        arr[i] = 1 ;
       }
       else arr[i] = 0 ;
    }
    ll pref[n+1] , suff[n+1];
    ms(pref);
    forn(i ,1 , n ){
       if(i== 1 ) {
        pref[i] = arr[i];
       }
       else pref[i] = pref[i-1] + arr[i];
    }
    ll ans = 1e18;
    forn(i , 1 , n ){
       if(i == 1){
         ll foo = pref[n] - pref[1];
         ans = min(ans , foo);
         con;
       }
       if(i == n){
        ll foo = pref[n-1];
        ll ziz = abs(n-1 - foo ) ;
        ans= min(ans , ziz);
        con;
       }
       if(i > 1 and i < n ){
         ll foo = pref[i-1];
         ll ziz = abs(i-1 - foo );
         ll fiz = pref[n] - pref[i];
         ziz = ziz + fiz ;
         ans = min(ans , ziz );
       }

    }
    cout << ans << el ;
    ro ;
}

















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

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

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

int N, M, C[20], DP[20][int(5e4 + 1)];

int main(){
  scanf("%d%d", &N, &M);
  for (int i = 0; i < M; i++) scanf("%d", C + i);
  sort(C, C + M);

  for (int j = 0; j <= N; j++) DP[0][j] = j;

  for (int i = 1; i < M; i++){
    for (int j = 0; j <= N; j++) DP[i][j] = DP[i - 1][j];

    for (int j = C[i]; j <= N; j++){
      DP[i][j] = min(DP[i][j], DP[i][j - C[i]] + 1);
    }
  }
  cout << DP[M - 1][N] << endl;

  return 0;
}



Measured memory_bytes: 7156
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// const ll INF = 1LL <<60;
// const int INF = 10000;

//最大公約数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

const int MAX = 1e6+1;
const int MOD = 1e9+7;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}

long long modpow(long long res,long long a, long long n, long long mod) {
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//sieve(MAX);でベクトルIsPrimeに「MAXまでの数値の素数の真偽」を格納する。
vector<bool> IsPrime;
void sieve(size_t max){
    if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
        IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    } 
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない

    for(size_t i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(IsPrime[i]) // iが素数ならば
            for(size_t j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                IsPrime[i*j] = false;      // 素数ではない
}
// ここから開始
int main(){
  ll n;
  cin>>n;
  if(n%2==1){
    cout<<0<<endl;
  }
  
  else{
    ll a[100];
    int i = 1;
    a[0] = 1;
    while(1e18*5>=a[i-1]*5){
      a[i] = a[i-1]*5;
      // cout<<a[i]<<" ";
      i++;
    }
    // cout<<endl;
    // cout<<a[1]<<" "<<a[2]<<endl;
    i = 1;
    ll ans = 0;
    // cout<<pow(5,18)<<endl;
    while(n/2>=a[i]){
      ans+=(n/2)/a[i];
      // cout<<a[i]<<endl;
      i++;
    }
    cout<<ans<<endl;
  // cout<<100000000000000000/5<<endl;

  }
  return 0;
}



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

class Doubling {
private:
  const int n;
  vector<vector<int>> table;
public:
  Doubling(int sz, long mx) : n(64 - __builtin_clzll(mx)) {
    table.assign(n, vector<int>(sz, -1));
  }
  void set_next(int k, int x) {
    table.at(0).at(k) = x;
  }
  void build() {
    for(int k = 0; k + 1 < n; k++) {
      for(int i = 0; i < table.at(k).size(); i++) {
        if(table.at(k).at(i) == -1) table.at(k + 1).at(i) = -1;
        else table.at(k + 1).at(i) = table.at(k).at(table.at(k).at(i));
      }
    }
  }
  int query(int k, long t) {
    for(int i = n - 1; i >= 0; i--) {
      if((t >> i) & 1) k = table.at(i).at(k);
    }
    return k;
  }
};

int main() {
  long N, K;
  cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    A.at(i)--;
  }
  Doubling D(N, K);
  for (int i = 0; i < N; i++) {
    D.set_next(i, A.at(i));
  }
  D.build();
  cout << D.query(0, K) + 1 << "\n";
}

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

int main() {
	ll n;
	cin>>n;
	set<string> st;
	for(ll i=0;i<n;i++)
	{
		string s;
		cin>>s;
		st.insert(s);
	}
	cout<<st.size()<<endl;
	return 0;
}

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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

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

    cout << (x <= (500 * k) ? "Yes" : "No") << endl;

    return 0;
}


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

using namespace std;

int main(){
//    ios_base::sync_with_stdio(false);
//    cin.tie(0);
    ll n,a,b,t;
    int i;
    ll sum=0,digit_sum;
    cin >> n >> a >> b;
    for(i=0;i<=n;i++){
        digit_sum=0;
        t=i;
        while(t>0){
            digit_sum=digit_sum+(t%10);
            t/=10;
        }
        if(digit_sum<=b&&digit_sum>=a){
            sum+=i;
        }
    }
    cout << sum <<endl;
    return 0;
}

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

bool palindrome(string s){
    int n = s.length();
    string former = s.substr(0,n/2);
    reverse(s.begin(), s.end());
    string latter = s.substr(0,n/2);

    //cout << former << " " << latter << endl;

    if(former == latter) return true;
    else return false;
}

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

    int n = s.length();
    string s2 = s.substr(0,(n-1)/2);
    string s3 = s.substr((n+3)/2-1);

    //cout << s2 << " " << s3 << endl;

    if(palindrome(s) == true
    && palindrome(s2) == true
    && palindrome(s3) == true) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N;
    cin >> N;
    vec A(N);
    map<ll,ll> C;
    REP(i,0,N) {
        cin >> A[i];
        ++C[A[i]];
    }

    ll sum = 0;
    FORR(c,C) sum += c.second * (c.second-1) / 2;
    REP(i,0,N) PR(sum-C[A[i]]+1);

    return 0;
}

/*



*/

Measured memory_bytes: 12660
fun main(args: Array<String>) {
    val (H, W) = readLine()!!.split(" ").map(String::toInt)
    val src = Array(H) { readLine()!! }
    val desc: MutableList<String> = mutableListOf()
    desc.add("#".repeat(W + 2))
    src.forEach {
        desc.add("#$it#")
    }
    desc.add("#".repeat(W + 2))

    desc.forEach(::println)

}



Measured memory_bytes: 35976
#include<algorithm>
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	long n,t,a,tt,aa;
	cin>>n>>tt>>aa;
	for(int i=1;i<n;i++)
	{
		cin>>t>>a;
		for(long j=max(tt/t,aa/a)-1;;j++)
		{
			if(t*j>=tt&&a*j>=aa)
			{
				tt=t*j;
				aa=a*j;
				break;
			}
		}
	}
	cout<<tt+aa<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int putsmaller(int a, int b);

int main(void){
    
    int i, mincount = 100000, n, count;
    int array[200];
    
    scanf("%d",&n);
    
    for (i = 0; i<n; i++) {
        scanf("%d", &array[i]);
        count = 0;
        while (array[i] % 2 == 0) {
            array[i] /= 2;
            count++;
        }
        mincount = putsmaller(count, mincount);
    }
    
    printf("%d\n", mincount);
    
    return 0;
}

int putsmaller(int a, int b){
    if(a < b){
        return a;
    } else {
        return b;
    }
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    long long n;
    cin>>n;
    int
    long long m;
    cin>>m;
    if(m<2*n)
    cout<<m/2<<endl;
    else{
        long long ans=n;
        m=m-n*2;
        cout<<ans+(m/4)<<endl;
    }
}


Measured memory_bytes: 3608
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <ctype.h>

#define MAX 100

typedef struct{
  int data[MAX],top;
} Stack;

void init(Stack*);
int isEmpty(Stack*);
void push(Stack*,int);
int pop(Stack*);
int calc(int,int,char);

int main(){
  int a,b;
  char str[7];
  Stack stack;
  init(&stack);
  
  while(scanf("%s",str) != EOF){
    if(isdigit(str[0])){
      a = atoi(str);
      push(&stack,a);
    }else{
      b = pop(&stack);
      a = pop(&stack);
      push(&stack,calc(a,b,str[0]));
    }
  }
  printf("%d\n",pop(&stack));
  return 0;
}

void init(Stack *s){
  s->top = 0;
}

int isEmpty(Stack *s){
  return (s->top == 0);
}

void push(Stack *s,int value){
  if(s->top >= MAX){
    assert(0);
  }
  s->data[s->top++] = value;
}

int pop(Stack *s){
  if(isEmpty(s)){
    assert(0);
  }
  return s->data[--s->top];
}

int calc(int a,int b,char op){
  switch(op){
  case '+':
    return a + b;
  case '-':
    return a - b;
  case '*':
    return a * b;
  case '/':
    if(b == 0){
      assert(0);
    }
    return a / b;
  default:
    assert(0);
  }
}

Measured memory_bytes: 548
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define FOREACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIGN(x) (((x)>0)?1:(((x)<0)?-1:0))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
#define vv(t) vector< t > 
#define CHC(mp, x) if(mp.end() != mp.find(x))
#define CHCV(mp, x) if(mp.end() != find(ALL(mp), x))
template<typename T>
inline T lcm(T a, T b) {return a / __gcd(a, b) * b;}
#define fi first
#define se second
#define el endl
#pragma endregion


void Main();
void solve(long long N, long long K, std::vector<long long> a);

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

int abfind(const string& S){
    int cnt = 0;
    REP(i, S.length()-1){
        if(S[i]=='A' && S[i+1]=='B'){
            cnt++;
        }
    }
    return cnt;
}

void Main(){
    int N;
    cin >> N;
    int cnt = 0;
    int A=0, AB=0, B=0;
    REP(i, N){
        string S;
        cin >> S;
        cnt += abfind(S);
        if(S[0]=='B'&&S[S.length()-1]=='A'){
            AB++;
        }else if(S[0]=='B'){
            B++;
        }else if(S[S.length()-1]=='A'){
            A++;
        }
    }
    if(A+B>0){
        cnt += AB + min(A, B);
    }else if(AB > 0){
        cnt += AB - 1;
    }
    cout << cnt << el;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mx = 1e6;
int main() {
    int n;
    cin >> n;
    long long cur = 0;
    for (int i(1); i <= mx; ++i) {
        cur = cur * 10 + 7;
        cur %= n;
        if (cur == 0) {
            cout << i << endl;
            return 0;
        }

    }
    cout << -1 << endl;
}

Measured memory_bytes: 3576
import copy

h, w = map(int, input().split())
s = [input() for _ in range(h)]

a = []
for i in range(-1, 2):
    for j in range(-1, 2):
        a.append((i, j))

ans = [[0]*w for _ in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            ans[i][j] = '#'

for i in range(h):
    for j in range(w):
        if s[i][j] == '.':
            cnt = 0
            for y, x in a:
                iy, jx = i+y, j+x
                if 0 <= iy < h and 0 <= jx < w:
                    if s[iy][jx] == '#':
                        cnt += 1
            ans[i][j] = cnt
for i in ans:
    print(''.join(map(str, i)))

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

const LL N = 1000+9;
const LL MOD = 1000000007;

LL n,a,b,c,d,f[N][N],C[N][N],POW[N],REV[N];

inline LL read() {
	char c=getchar(); LL f=1,ret=0;
	while (c<'0'||c>'9') {if(c=='-')f=-1;c=getchar();}
	while (c<='9'&&c>='0') {ret=ret*10+c-'0';c=getchar();}
	return ret * f;
}

inline LL Pow(LL w, LL t) {
	LL ret = 1;
	while (t) {
		if (t & 1) ret = (LL)ret * w % MOD;
		w = (LL)w * w % MOD; t >>= 1;
	}
	return ret;
}

int main() {
	n = read(); 
	a = read(); b = read();
	c = read(); d = read();
	for (LL i=1;i<N;i++) C[i][1] = i, C[i][0] = 1;
	for (register LL i=2;i<N;i++) {
		for (register LL j=1;j<N;j++) {
			C[i][j] = (C[i-1][j-1] + C[i-1][j]) % MOD;
		}
	}
	POW[0] = 1;
	for (register LL i=1;i<N;i++) POW[i] = (LL)POW[i-1] * i % MOD;
	REV[N-1] = Pow(POW[N-1], MOD-2);
	for (register LL i=N-2;~i;i--) REV[i] = (LL)REV[i+1] * (i+1) % MOD;
	f[a-1][n] = 1;
	for (register LL i=a;i<=b;i++) {
		for (register LL j=0;j<=n;j++) {
			if (f[i-1][j]) {
				(f[i][j] += f[i-1][j]) %= MOD;
				if (i*(c-1) > j) continue;
				LL w = 1;
				for (register LL k=1;k<c;k++) 
					w = (LL)w * C[j-(k-1)*i][i] % MOD;
				for (register LL k=c;k<=d;k++) {
					if (i*k <= j) {
						w = (LL)w * C[j-(k-1)*i][i] % MOD;
						(f[i][j-i*k] += ((LL)f[i-1][j] * w % MOD) * REV[k] % MOD) %= MOD;
					} else break;
				}
			}
		}
	}
	printf("%d\n",f[b][0]);
	return 0;
}


Measured memory_bytes: 16128
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 30;

void compress(vi const& vec, map<int, int>& zip, vi& unzip){
    unzip = vec;

    sort(all(unzip));
    unzip.erase(unique(all(unzip)), unzip.end());
    unzip.pb(inf);

    rep(i, unzip.size()) zip[unzip[i]] = i;
}

int main(void){
    for(int n, m; cin >> n >> m;){
        vi xs(n), ys(n);
        rep(i, n) cin >> xs[i] >> ys[i];

        vi unzip_x, unzip_y;
        map<int, int> zip_x, zip_y;

        compress(xs, zip_x, unzip_x);
        compress(ys, zip_y, unzip_y);

        vvi sum(n + 2, vi(n + 2));

        rep(i, n) sum[zip_y[ys[i]] + 1][zip_x[xs[i]] + 1]++;
        rep(i, n + 1) rep(j, n + 1) sum[i + 1][j + 1] += sum[i + 1][j] + sum[i][j + 1] - sum[i][j];

        rep(i, m){
            int lux, luy, rdx, rdy; cin >> lux >> luy >> rdx >> rdy;

            lux = zip_x[*lower_bound(all(unzip_x), lux)];
            luy = zip_y[*lower_bound(all(unzip_y), luy)];
            rdx = zip_x[*upper_bound(all(unzip_x), rdx)];
            rdy = zip_y[*upper_bound(all(unzip_y), rdy)];

            cout << sum[rdy][rdx] - sum[rdy][lux] - sum[luy][rdx] + sum[luy][lux] << endl;
        }
    }

	return 0;
}

Measured memory_bytes: 99476
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int N=2e5+10,mod=1e9+7;
int first[N],n,siz[N],ans[N],tot,mul[N],fac[N];
int pew(int x,int b){
    int res=1;
    while(b){
        if(b%2==1){
            res=1ll*res*x%mod;
        }
        b/=2;
        x=1ll*x*x%mod;
    }
    return res;
}
struct edge{
    int to,next;
}e[N*2];
void add(int u,int v){
    e[++tot].next=first[u],first[u]=tot;
    e[tot].to=v;
}
void dfs(int x,int f){
    siz[x]=1;mul[x]=1;
    for(int i=first[x];i;i=e[i].next){
        int u=e[i].to;
        if(u==f)continue;
        dfs(u,x);siz[x]+=siz[u];
        mul[x]=1ll*mul[x]*mul[u]%mod;
    }
    mul[x]=1ll*mul[x]*siz[x]%mod;
}
void getans(int x,int f,int now){
    int down=now;
    for(int i=first[x];i;i=e[i].next){
        int u=e[i].to;
        if(u==f)continue;
        down=1ll*down*mul[u]%mod;
        now=1ll*now*mul[u]%mod;
    }
    ans[x]=1ll*fac[n-1]*pew(down,mod-2)%mod;
    for(int i=first[x];i;i=e[i].next){
        int u=e[i].to;
        if(u==f)continue;
        getans(u,x,1ll*now*pew(mul[u],mod-2)%mod*(n-siz[u])%mod);
    }
}
int main(){
    scanf("%d",&n);
    for(int i=1,u,v;i<n;i++){
        scanf("%d%d",&u,&v);
        add(u,v);add(v,u);
    }
    fac[0]=1;
    for(int i=1;i<=n;i++)
        fac[i]=1ll*fac[i-1]*i%mod;
    dfs(1,0);
    getans(1,0,1);
    for(int i=1;i<=n;i++)
        printf("%d\n",ans[i]);
}


Measured memory_bytes: 9344
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<10)
#define LLINF (1LL<<60)
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int a[3][3],n;
  bool c[3][3]={};
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin>>a[i][j];
    }
  }
  cin>>n;
  for(int k=0;k<n;k++){
    int t;
    cin>>t;
    for(int i=0;i<3;i++){
      for(int j=0;j<3;j++){
        if(a[i][j]==t)c[i][j]=1;
      }
    }
  }
  string s="No";
  for(int i=0;i<3;i++){
    if(c[i][0]&&c[i][1]&&c[i][2])s="Yes";
  }
  for(int j=0;j<3;j++){
    if(c[0][j]&&c[1][j]&&c[2][j])s="Yes";
  }
  if(c[0][0]&&c[1][1]&&c[2][2])s="Yes";
  if(c[0][2]&&c[1][1]&&c[2][0])s="Yes";
  cout<<s;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){

	float a, b, c, d, e, f, x, y;

	for(;scanf("%f %f %f %f %f %f", &a, &b, &c, &d, &e, &f) != EOF;){

		y = (a*f-c*d)/(a*e-b*d);
		x = (c-b*y)/a;

		printf("%.3f %.3f\n", x, y);

	}

	return 0;

}

Measured memory_bytes: 648
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#define LL long long
using namespace std;
inline int read()
{
	int f=1,x=0;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
inline void write(int x)
{
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);
	putchar(x%10+'0');	
}
int n,K;
int gg[200005];
int main()
{
	scanf("%d%d",&n,&K);
	for(int i=1;i<=n;i++)
	{
		if(i<K)gg[i]=K-i;
		else if(i==K)gg[i]=K;
		else gg[i]=K-(i%K);
	}
	LL ans=0;
	for(int i=1;i<=n;i++)
		if((2*gg[i])%K==0)
		{
			if(gg[i]>n)continue;
			int tmp=(n-gg[i])/K+1;
			ans+=(LL)tmp*tmp;
		}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 896
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int res = 0;
    // 1パターンだけに絞りたいので、a >= b >= c となるように並び替え
    if (a < b) {swap(a, b);}
    if (a < c) {swap(a, c);}
    if (b < c) {swap(b, c);}

    int d = a - max(b, c);
    res += d;
    b += d;
    c += d;
    if ((a - min(b, c)) % 2 == 0) {
        res += (a - min(b, c)) / 2;
    } else {
        res += (a - min(b, c) + 1) / 2 + 1;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))


using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
//template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
//template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll INF=1e9+7;

ll dp[2010][2010];

int main()
{
    ll n,x,y;
    cin >> n >> x >> y;
    x--;
    y--;
    rep(i,n){
        rep(j,n){
            dp[i][j]=abs(i-j);
        }
    }
    rep(i,n){
        rep(j,n){
            dp[i][j]=min(dp[i][j],dp[i][x]+1+dp[y][j]);
        }
    }
    vector<ll> ans(n,0);
    rep(i,n){
        rep(j,n){
            //cout << dp[i][j] << endl;
        }
    }
    rep(i,n){
        for(ll j=i+1;j<n;j++){
            ans[dp[i][j]]++;
        }
    }
    rep(i,n){
        if(i){
            cout << ans[i] << endl;
        }
    }
    return 0;
} 


Measured memory_bytes: 31616
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
//#define N 131072 //100000
#define MAXVAL ((long int) ((unsigned long) (1 << 31) - 1))  //*2
int min(int a, int b){return a>b?b:a;}
int data[2*131072+100];      //the size of array, for present the tree

//easy version of update 
//from bottom to top
void update(int index, int left_child, int right_child){
	if(index<0) return;
	data[index] = data[left_child]+data[right_child];
	//even : right, odd: left 
	if(index%2==1){//left
		update(index/2,index, index+1);
	}else if(index%2==0){
		update(index/2-1,index-1,index);
	}
	
}
//segment of thr last layer
//use 0-7 as segemnt and 1-4 as query segment
int search(int search_left,int search_right, int current_node, int node_left, int node_right){
	if(search_right < node_left || search_left > node_right){
        return 0;//not in the range
	}
	else if(search_left <= node_left && search_right >= node_right){
		return data[current_node];//for the folded node which parent present the minimal of their children 
	}else {
		int left = search(search_left, search_right,current_node*2+1, node_left,(node_left+node_right)/2);
		int right = search(search_left, search_right,current_node*2+2, (node_left+node_right)/2+1, node_right);
		return (left+right);
	}
	
}
int main(){
	int n, q;
	FILE *fp = fopen("in.txt","r");
	scanf("%d %d",&n,&q);
	int N = 1;
	while(N<n) N = N<<1;
	if(n==1) N=2;
	for(int i = 0; i<=2*N-2; i++){
		data[i] = 0;
	}
	for(int i = 0; i<q; i++){
		int temp = 0;
		scanf("%d", &temp);
		int a,b,c;
		scanf("%d %d",&a,&b);
		a=a-1;
		if(temp == 0) {  //add
			data[N-1+a] += b;
			if((N-1+a)%2==1) {//left
				update((N-1+a)/2,N-1+a,N+a);
			} else {
				update((N-1+a)/2-1,N-2+a,N-1+a);
			}
			//test print
			/*for(int i = 0 ;i<=2*N-2; i++){
				printf("%d ",data[i]);
			}printf("\n");*/
		} else if(temp == 1){ //search
			b = b-1;
			printf("%d\n",search(a,b,0,0,N-1));
		}
	}
	
	return 0;
}

Measured memory_bytes: 3780
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func max(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

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

	a := nextInt()
	b := nextInt()
	c := nextInt()
	x := nextInt()
	y := nextInt()

	min := math.Inf(1)

	for i := 0; i <= 100000; i++ {
		total := i*2*c + max(0, x-i)*a + max(0, y-i)*b
		if min > float64(total) {
			min = float64(total)
		}
	}

	fmt.Println(int(min))

	// if (a + b) < c*2 {
	// 	total = a*x + b*y
	// 	fmt.Println(total)
	// 	return
	// }

	// aPizzaOfseets := x
	// bPizzaOfseets := y

	// if c > y {
	// 	fmt.Println("x > y")
	// 	aPizzaOfseets = x - y
	// 	total += y * 2 * c
	// 	total += aPizzaOfseets * a
	// } else if x < y {
	// 	fmt.Println("x < y")
	// 	bPizzaOfseets = y - x
	// 	total += x * 2 * c
	// 	total += bPizzaOfseets * b
	// } else {
	// 	fmt.Println("x == y")
	// 	total += x * 2 * c
	// }

	// fmt.Println(total)

}


Measured memory_bytes: 640
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <bitset>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(int argc, const char * argv[]) {
    int N, X, Y; cin >> N >> X >> Y;
    X -= 1; Y -= 1;
    map<int, int> m;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            int tmp = abs(j - i);
            tmp = min(tmp, abs(j - X) + 1 + abs(Y - i));
            tmp = min(tmp, abs(i - X) + 1 + abs(Y - j));
            m[tmp] += 1;
        }
    }
    for (int i = 1; i < N; i++) {
        cout << m[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long a = sc.nextLong();
        long b = sc.nextLong();

        if (a - b >= 0) {
            System.out.println("delicious");
            return;
        }
        if (b - a <= x) {
            System.out.println("safe");
            return;
        }
        System.out.println("dangerous");
    }

}


Measured memory_bytes: 21460