akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>

#define	mp	make_pair
#define	X	first
#define	SL	second

using namespace std;

typedef	pair<int,int>	pii;

const int inf=1000000000;
pii river[150][11];
int memo[150][10][76];

int main()
{
	for(int n,m;scanf("%d%d",&n,&m),n;){
		for(int i=0;i<n;i++){
			int k;	scanf("%d",&k);
			for(int j=0;j<k;j++){
				int x,slip;	scanf("%d%d",&x,&slip);
				river[i][j]=mp(x,slip);
			}
			river[i][k]=mp(-1,-1);
		}

		for(int i=0;i<n;i++)for(int j=0;~river[i][j].X;j++)for(int k=0;k<=m;k++)
			memo[i][j][k]=inf;

		for(int j=0;~river[0][j].X;j++)	memo[0][j][0]=0;
		for(int j=0;~river[1][j].X;j++)	memo[1][j][1]=0;

		for(int i=1;i<n;i++){
			for(int j=0;~river[i][j].X;j++){
				int cost;
				for(int k=0;k<=m;k++){
					for(int b=0;~river[i-1][b].X;b++){
						if(river[i-1][b].X==inf)	continue;
						cost=(river[i][j].SL+river[i-1][b].SL)*abs(river[i][j].X-river[i-1][b].X);
						memo[i][j][k]=min(memo[i][j][k],cost+memo[i-1][b][k]);
					}
				}
				for(int k=1;k<=m;k++){
					if(i-2<0)	continue;
					for(int b=0;~river[i-2][b].X;b++){
						if(river[i-2][b].X==inf)	continue;
						cost=(river[i][j].SL+river[i-2][b].SL)*abs(river[i][j].X-river[i-2][b].X);
						memo[i][j][k]=min(memo[i][j][k],cost+memo[i-2][b][k-1]);
					}
				}
			}
		}

		int mincost=inf;
		for(int j=0;~river[n-1][j].X;j++)for(int k=0;k<=m;k++)	mincost=min(mincost,memo[n-1][j][k]);
		for(int j=0;~river[n-2][j].X;j++)for(int k=0;k<m;k++)	mincost=min(mincost,memo[n-2][j][k]);
		printf("%d\n",mincost);
	}

	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
char a[2][200];
int main()
{
	int n,i,j,k;
	
	scanf("%d",&n);
	getchar();
	for(i=0;i<n;i++)
	scanf("%c",&a[0][i]);
	getchar();
	for(i=0;i<n;i++)
	scanf("%c",&a[1][i]);
	//puts(a[0]);
	//puts(a[1]);
	for(i=0;i<n;i++)
	{
		if(a[0][i]==a[1][0])
		{
			for(j=i,k=0;j<n;j++,k++)
			{
				if(a[0][j]!=a[1][k])
				{
					break;
					j--;
				}
			}
			if(j==n)
			{
				printf("%d\n",n+(n-k));
				return 0;
		    }
	    } 
    }
	if(i==n)
	printf("%d\n",n*2); 
	return 0;
}

Measured memory_bytes: 128
/*----------------
     Smit Patel
     DA-IICT
----------------*/
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
// https://atcoder.jp/contests/dp/tasks/dp_c
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ins insert
#define fori(i,a,n) for(int i=a; i<n; i++)
#define ford(i,a,n) for(int i=a; i>n; i--)
#define clr(a,b) memset(a,b,sizeof(a))
#define deb(x) cout<<#x<<" : "<<x<<endl;
#define debug(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define bp __builtin_popcount
#define mod 1000000007
#define eps 1e-6
#define infi 1000000002
#define infll 1e18+5
#define N 200005
#define LN 20

typedef long double ld;
typedef long long ll;
typedef map<ll,ll> mll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef set<ll> sll;

ll choose(ll n,ll k);
bool isprime(ll n);
ll power(ll x,ll y,ll p);
ll power(ll x,ll y);
ll gcd(ll a,ll b);

int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ll n;
  cin>>n;
  ll a[n][3];
  fori(i,0,n)
  {
    fori(j,0,3) cin>>a[i][j];
  }
  ll dp[n][3]={};
  dp[0][0]=a[0][0];
  dp[0][1]=a[0][1];
  dp[0][2]=a[0][2];
  fori(i,1,n)
  {
    dp[i][0]=max(dp[i-1][1]+a[i][0],dp[i-1][2]+a[i][0]);
    dp[i][1]=max(dp[i-1][0]+a[i][1],dp[i-1][2]+a[i][1]);
    dp[i][2]=max(dp[i-1][1]+a[i][2],dp[i-1][0]+a[i][2]);
  }
  cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
  return 0;
}

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

ll choose(ll n,ll k)
{
  if(k==0)
    return 1;
  return (n* choose(n-1,k-1))/k;
}

bool isprime(ll n)
{
  for(ll i=2;i*i<=n;i++)
  {
    if(n%i==0)
      return false;
  }
  return true;
}

ll power(ll x,ll y,ll p)
{
  ll res=1;
  x=x%p;
  while(y>0)
  {
    if(y&1)
      res=(res*x)%p;
    y=y>>1;
    x=(x*x)%p;
  }
  return res;
}

ll power(ll x,ll y)
{
  ll res=1;
  while(y>0)
  {
    if(y&1)
      res=res*x;
    y=y>>1;
    x=x*x;
  }
  return res;
}


Measured memory_bytes: 4992
import sys
import collections
ri = lambda: int(sys.stdin.readline())
rl = lambda: list(map(int, sys.stdin.readline().split()))

n = ri()
li = sorted(rl(), reverse=True)
q = collections.deque([max(li)])
score = 0
for i in li[1:]:
    a = q.popleft()
    score += a
    q.append(i)
    q.append(i)
print(score)


Measured memory_bytes: 32636
#include <algorithm>
#include <iostream>
#include <string>

int main(int argc, char** argv) {
  std::string s, t;
  std::cin >> s;
  std::cin >> t;
  
  bool flag = false;
  for (size_t i = 0; i < s.size(); ++i) {
    std::rotate(std::begin(s), std::begin(s) + 1, std::end(s));
    if (s == t) {
      flag = true;
    }
  }
  if (flag) {
    std::cout << "Yes";
  } else {
    std::cout << "No";
  }
  return 0;
}

Measured memory_bytes: 256
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <iostream>

using namespace std;

int A, B, C, X;

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

    cin >> A >> B >> C >> X;

    X /= 50;

    int ans = 0;
    for (int a = 0; a <= min(A, X / 10); a++) {
        int rem = X - 10 * a;
        int bmax = min(B, rem / 2) + 1;
        int bmin = max(0, min(B + 1, (rem - C + 1) / 2));
        ans += bmax - bmin;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3592
#ifndef _WIN32
#include<iostream>
#endif
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long LL;
#define FOR(i,bg,ed) for(int (i)=(bg);(i)<(ed);(i)++)
#define REP(i,n) FOR(i,0,n)
struct cww {
	cww() {
		ios::sync_with_stdio(false);
		cin.tie(0);
	}
};

int main() {
	string s, t;
	cin >> s >> t;
	int n = s.size();
	int m = t.size();
	REP(i, n)if (i + m <= n) {
		bool f = true;
		REP(j,m)if (s[i+j] == t[j] || t[j] == '_');
		else f = false;
		if (f) {
			cout << "Yes" << endl;
			return 0;
		}
		
	}
	cout << "No" << endl;

}


Measured memory_bytes: 3200
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    return


def main():
    S = input()
    ans1, ans2 = 0, 0
    for i in range(len(S)):
        if i % 2 == 0:
            ans1 += S[i] != '0'
            ans2 += S[i] != '1'
        else:
            ans1 += S[i] != '1'
            ans2 += S[i] != '0'

    print(min(ans1, ans2))


if __name__ == '__main__':
    main()


Measured memory_bytes: 4076
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

int main()
{
        ll A, B; cin >> A >> B;


        for (int i = 1; i <= 1250; ++i) {

                ll eight = i / 100.0 * 8.0;
                ll ten = i / 100.0 * 10.0;
                if (eight == A && ten == B) {
                        cout << i << endl;
                        exit(0);
                }

        }
        cout << -1 << endl;


}


Measured memory_bytes: 256
c = ([list(map(int, input().split())) for i in range(3)])

ok = True
 
for x in range(2):
  ok = ok and (c[x][0]-c[x+1][0] == c[x][1]-c[x+1][1] == c[x][2]-c[x+1][2])
 
for x in range(2):
  ok = ok and (c[0][x]-c[0][x+1] == c[1][x]-c[1][x+1] == c[2][x]-c[2][x+1])
 
print ("Yes" if ok else "No")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main()
{
long long  a,b;
  cin>>a>>b;
  long long s=a+b;
if(s % 2 == 0){
  cout << s/2 << endl;
}else{
  cout <<  "IMPOSSIBLE" << endl;

}
return 0;
}


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int CM = 2017;
int N,M,Q;
bool S[CM][CM];
int b[CM][CM],c[CM][CM];
int dx[CM][CM],dy[CM][CM];

int main(){
	scanf("%d%d%d" , &N , &M , &Q);
	repp(i,1,N+1){
		repp(j,1,M+1){
			char a;
			scanf(" %c" , &a);
			S[i][j] = a == '1';
			b[i][j] = a - '0';
			if(S[i][j] && S[i-1][j]){
				++c[i][j];
				++c[i-1][j];
				++dy[i][j];
			}
			if(S[i][j] && S[i][j-1]){
				++c[i][j];
				++c[i][j-1];
				++dx[i][j];
			}
		}
	}
	repp(i,0,N+2){
		repp(j,1,M+2){
			b[i][j] += b[i][j-1];
			c[i][j] += c[i][j-1];
			dy[i][j] += dy[i][j-1];
		}
	}
	repp(j,0,M+2){
		repp(i,1,N+2){
			b[i][j] += b[i-1][j];
			c[i][j] += c[i-1][j];
			dx[i][j] += dx[i-1][j];
		}
	}
	repp(k,0,Q){
		int x1,y1,x2,y2;
		scanf("%d%d%d%d" , &x1 , &y1 , &x2 , &y2);
		int ans = b[x2][y2] - b[x2][y1-1] - b[x1-1][y2] + b[x1-1][y1-1];
		int w = c[x2][y2] - c[x2][y1-1] - c[x1-1][y2] + c[x1-1][y1-1];
		w -= dx[x2][y1] - dx[x1-1][y1];
		w -= dx[x2][y2+1] - dx[x1-1][y2+1];
		w -= dy[x1][y2] - dy[x1][y1-1];
		w -= dy[x2+1][y2] - dy[x2+1][y1-1];
		printf("%d\n" , ans - w/2);
	}
	return 0;
}


Measured memory_bytes: 69376
N = int(input())
work = []

for i in range(N):
  a,b = map(int,input().split())
  work.append([a,b])

work = sorted(work, key=lambda x: x[1]) #二番目の要素でソート

sum_time = 0
judge = 1 #可
for i in range(N):
  sum_time += work[i][0]
  if(sum_time > work[i][1]):
    judge = 0
    break

if(judge == 0): print('No')
else: print('Yes')

Measured memory_bytes: 39592
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/**
 *
 * @author k16069kk
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        int H = 0;
        int W = 0;
        while ((line = br.readLine()) != null) {
            java.util.StringTokenizer st = new StringTokenizer(line, " ");
            while (st.hasMoreTokens()) {
                H = Integer.parseInt(st.nextToken());
                W = Integer.parseInt(st.nextToken());
                for (int i = 0; i < H; i++) {
                    for (int j = 0; j < W; j++) {
                        System.out.print("#");
                    }
                    System.out.println();
                }
                if(H == 0 && W == 0) break;
                System.out.println("");
                
            }
            if(H == 0 && W == 0) break;
        }
        
    }

}



Measured memory_bytes: 33180
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n);
    vc<pair<int, int>> a(n);
    For(i, n){
        cin >> a[i].first;
        a[i].second = i;
    }
    Sort(a);
    For(i, n) a[i].first = i;
    sort(Range(a), [](auto x, auto y){ return x.second < y.second; });

    int ans = 0;
    For(i, n/2){
        if(a[2*i+1].first % 2 == 0) ans ++;
    }
    Cout(ans);
}




Measured memory_bytes: 1024
using System.Collections.Generic;
using System;

public class hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = int.Parse(Console.ReadLine().Trim());
        Array.Sort(a);
        var b = new List<int>();
        for (int i = 0; i < 4; i++)
            for (int j = i+1; j < 4; j++)
            {
                b.Add(int.Parse(a[i].ToString() + a[j].ToString()));
                b.Add(int.Parse(a[j].ToString() + a[i].ToString()));
            }
        b.Sort();
        Console.WriteLine(b[2]);
    }
}

Measured memory_bytes: 9340
#include<bits/stdc++.h>
using namespace std;
stringstream ss;
bool check(int x){
	ss.str("");
	ss.clear();
	string s;
	ss<<x;
	ss>>s;
	if(s.size()%2==1) return true;
	return false;
}
int main(){
	int n,cnt=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		if(check(i)) cnt++;
	}
	cout<<cnt;
	return 0;
}


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

int main(){
    long long n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    long long ans=0;

    
    vector<int> v;
    vector<int> zero;
    int cnt=1;
    zero.push_back(0);    
    v.push_back(-1);
    long long res=1;
    for(int i=1;i<n;i++){
        if(s[i]!=s[i-1] && s[i]=='1'){
            v.push_back(i-1);
            zero.push_back(cnt);
            cnt=1;
            res=1;
        }
        if(s[i]==s[i-1] && s[i]=='1') res++,ans=max(res,ans);
        if(s[i]==s[i-1] && s[i-1]=='0') cnt++;
    }
    if(s[n-1]=='0') zero.push_back(cnt),v.push_back(n-1);
    v.push_back(n-1);
    zero.push_back(0);
    if(n==1 && s[n-1]=='1') ans++;
    if(v.size()<=k+1){
        cout<<n<<endl;
        return 0;
    }
    //cerr<<v.size();

    if(v.size()-k-1>=0) ans=n-v[v.size()-k-1];
    //cerr<<ans<<endl;


    for(int i=v.size()-1;i-1-k>=0;i--){
        ans=max(ans,(long long)v[i] - v[i-1-k]-zero[i]);
        cerr<<i<<" "<<ans<<" "<<v[i]<<" "<<v[i-1-k]<<" "<<zero[i]<<endl;
    }
    cout<<ans<<endl;
  
}

Measured memory_bytes: 1020
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<algorithm>
#include<vector>
#include<queue>
#define ll long long
ll read()
{
	ll tmp=0;char c=getchar(),f=1;
	while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();}
	while('0'<=c&&c<='9'){tmp=tmp*10+c-48;c=getchar();}
	return tmp*f;
}
using namespace std;
int cnt[100010];
int n;
int main()
{
	int i;
	n=read();
	for(i=1;i<=n;i++)++cnt[read()];
	int ans=0;
	for(i=1;i<=100000;i++)ans=max(ans,cnt[i-1]+cnt[i]+cnt[i+1]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#pragma warning( disable:4996 )
#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define MIN(a, b) ((a) < (b) ? (a) : (b))


int main(void) {
	int s;
	scanf("%d", &s);
	if (s % 10 == s % 100 / 10 || s % 100 / 10 == s % 1000 / 100 || s / 1000 == s % 1000 / 100) {
		printf("Bad\n");
	}
	else {
		printf("Good\n");
	}
	return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){

  int n;
  cin >> n;
  ll res = 0;
  for(ll i = 1;i <= n;i++)res += i*(i+1)/2;
  rep(i,n-1){
    ll u,v;cin >> u >> v;
    if(u > v)swap(u,v);
    res -= u*(n-v+1);
  }
  cout << res << endl;



  return 0;
}

Measured memory_bytes: 3624
#input = sys.stdin.readline
 
S = input()
T = input()
 
result = float('inf')
for i in range(len(S) - len(T) + 1):
    t = 0
    for j in range(len(T)):
        if S[i + j] != T[j]:
            t += 1
    result = min(result, t)
print(result)

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

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

int n, a, b;

signed main() {
  cin >> n >> a >> b;
  vec<int> v(n);
  vec<int> x, y, z;
  int cnt = 0;
  rep (i, n) {
    cin >> v[i];
    if (v[i] <= a) {
      x.push_back(v[i]);
    } else if (v[i] >= b + 1) {
      z.push_back(v[i]);
    } else {
      y.push_back(v[i]);
    }
  }

  // dbg3(x.size(), y.size(), z.size())
  cout << min({x.size(), y.size(), z.size()}) << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<cmath>
#include<ctime>
#include<complex>

using namespace std;

#define REP(i,s,e) for(int i=int(s);i<=int(e);i++)
#define rep(i,n) for(int i=0;i<int(n);i++)

int main(){

	int x,y,z,s,a=0,b=0,c=0;
	for(;;){
	cin >> x >> y >> z;

	if(abs(x-z)<y && y<x+z){
	vector<int>t(3);
	t[0]=x; t[1]=y; t[2]=z;
	sort(t.begin(),t.end());

	if(t[0]*t[0]+t[1]*t[1]>t[2]*t[2])  b++;
	if(t[0]*t[0]+t[1]*t[1]==t[2]*t[2]) a++;
	if(t[0]*t[0]+t[1]*t[1]<t[2]*t[2])  c++;

	}
	else{

		s=a+b+c;
		cout << s << " " << a << " " << b << " " << c << endl;
		break;
	}
	}

	return 0;
}

Measured memory_bytes: 1212
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

if __name__ == '__main__':
    a = [int(i) for i in input().split()]

    if a[0] <= a[2] and a[2] <=a[0] + a[1]:
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 3828
import java.io.InputStreamReader
import java.io.BufferedReader

fun main(args: Array<String>) {
  val br = BufferedReader(InputStreamReader(System.`in`))

  val (n, d) = br.readLine().split(" ").map { it.toInt() }
  val x = (1..n).map { br.readLine().split(" ").map { it.toInt() }.toIntArray() }

  var cnt = 0
  for(i in 0 until n) {
    for(j in i until n) {
      var v = 0
      for(k in 0 until d) {
        v += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k])
      }
      if((v % Math.sqrt(v.toDouble())) == 0.0) {
        cnt++
      }
    }
  }

  val ans = cnt
  println(ans)
}

Measured memory_bytes: 35768
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
typedef pair<ll,ll> P;
#define rep(i,n) for(ll (i)=0; i<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,d,a,x,h,bomb=0,tot=0,ans=0;cin>>n>>d>>a;d*=2;
  vector<P> v(n);
  rep(i,n) { cin>>x>>h; v[i]=P{x,(h+a-1)/a}; }
  sort(v.begin(),v.end());
  queue<P> q;
  rep(i,n) {
    while(q.size() && q.front().first<v[i].first) {
      tot-=q.front().second;
      q.pop();
    }
    v[i].second-=tot;
    if(v[i].second>0) {
      bomb=v[i].second;
      ans+=bomb;
      tot+=bomb;
      q.emplace(v[i].first+d,bomb);
    }
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 4992
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<functional>
#include<vector>
#include<map>

using namespace std;
#define endl '\n'
#define pb push_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define REP(i,n) for(int i = 0;i < (n);i++)
#define FOR(i,a,b) for(int i = (a);i <= (b);i++)
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

constexpr int MOD = 1000000007;

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

template <class T = int> T in() { T x; cin >> x; return (x); }
template <class T = int> void out(T x) { cout << (x) << endl; }

int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

void solve() {

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

	vi A(N);
	int p1;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		if (A[i] == 1) {
			p1 = i;
		}
	}
	int ans = 1e5;
	for (int i = 0; i < K; i++) {
		int l = p1 - K + 1 + i, r = p1 + i;
		int cnt = 1;
		while (l > 0) {
			l -= K - 1;
			cnt++;
		}
		while (r < N - 1) {
			r += K - 1;
			cnt++;
		}
		ans = min(ans, cnt);
	}

	cout << ans << endl;

	return;

}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	solve();

	return 0;

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
//#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (10);   小数点以下１０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);

int main() {
  int a,b,c;
  cin >>a>>b>>c;
  
  cout << ((a==b && b!=c) ||(b==c && c!=a) ||(c==a && a!=b)? "Yes":"No") << endl;
  
}

Measured memory_bytes: 384
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		int dartenc = Integer.parseInt(line);
		String[] k = new String[dartenc];
		int[][][] darten = new int[4][3][10];

		for (int i = 0; i < darten.length; i++) {
			for (int j = 0; j < darten[1].length; j++) {
				for (int j2 = 0; j2 < darten[0].length; j2++) {
					darten[i][j][j2] = 0;
				}
			}
		}
		for (int i = 0; i < k.length; i++) {
			k[i] = sc.nextLine();
			String[] v = k[i].split(" ");
			int[] a = new int[4];
			for (int j = 0; j < a.length; j++) {
				a[j] = Integer.parseInt(v[j]);
			}
			darten[a[0] - 1][a[1] - 1][a[2] - 1] += a[3];// ?????¢...b?£?f??????r?????????????????§??\???

		}

		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 3; j++) {
				for (int j2 = 0; j2 < 10; j2++) {
					System.out.print(" "+darten[i][j][j2]);
				}
				System.out.println("");
				
			}if (i!=3) {
				System.out.println("####################");
			
			}
			
		}

	}

}

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

using ll = long long;
static const ll MOD = 1e9 + 7;

// 組合せを素数で割った値を求める
const int MAX = 510000;
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;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int h, w, a, b;
  cin >> h >> w >> a >> b;
  
  COMinit();
  
  ll ans = COM(h + w - 2, h - 1);
  
  for(int i = 1; i <= b; i++){
    ans += MOD * MOD;
    ans -= COM((h - a - 1) + (i - 1), i - 1) * COM((a - 1) + (w - i), a - 1);
    ans %= MOD;
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 12160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
ll a,b,v,w,t;
ll gao(ll x,ll y){
	if(x%y==0)return x/y;
	else return x/y+1;
}
int main(){
	cin >> a >> v >> b >> w >> t;
	if(a==b)return puts("YES"),0;
	if(v>w and gao(abs(a-b),v-w)<=t)
		puts("YES");
	else puts("NO");
	return 0;
}

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

const string YES = "Yes";
const string NO = "No";

void solve(std::vector<std::vector<long long>> c){
    ll left = c[0][0] + c[1][1] + c[2][2];
    ll right = c[0][2] + c[1][1] + c[2][0];
    ll all = (c[0][0] + c[0][1] + c[0][2] + c[1][0] + c[1][1] + c[1][2] + c[2][0] + c[2][1] + c[2][2]) % 3;
    if(left == right && all == 0) cout << YES << endl;
    else cout << NO << endl;
}

int main(){
    std::vector<std::vector<long long>> c(3, std::vector<long long>(3));
    for(int i = 0 ; i < 3 ; i++){
        for(int j = 0 ; j < 3 ; j++){
            scanf("%lld",&c[i][j]);
        }
    }
    solve(std::move(c));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
    int n = 0;
    int k = 0;
    std::cin >> n >> k;
    if (n % k == 0) {
        std::cout << "0" << std::endl;
    } else {
        std::cout << "1" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }

int main() {
	int A; int B; int C;
	while(~scanf("%d%d%d", &A, &B, &C)) {
		int X[3][3] = {};
		rer(sum, 0, 300) {
			X[0][0] = A;
			X[0][1] = B;
			X[1][1] = C;
			X[0][2] = sum - A - B;
			X[2][2] = sum - A - C;
			X[2][1] = sum - B - C;
			X[1][2] = sum - X[0][2] - X[2][2];
			X[1][0] = sum - C - X[1][2];
			X[2][0] = sum - X[2][1] - X[2][2];
			bool ok = true;
			rep(i, 3) {
				ok &= X[i][0] + X[i][1] + X[i][2] == sum;
				ok &= X[0][i] + X[1][i] + X[2][i] == sum;
			}
			ok &= X[0][0] + X[1][1] + X[2][2] == sum;
			ok &= X[0][2] + X[1][1] + X[2][0] == sum;
			if(ok) {
				rep(i, 3) {
					for(int j = 0; j < 3; ++ j) {
						if(j != 0) putchar(' ');
						printf("%d", X[i][j]);
					}
					puts("");
				}
			}
		}
	}
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
 
using namespace std;
typedef unsigned long long int ll;
const ll hell = 100005; 
bool comp(vector<ll> a, vector<ll> b)
{
    return a[0]<b[0];
}
ll binpow(ll a,ll b) 
{
    ll res = 1;
    while (b > 0)
    {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
int main()
{   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n ,a , b;
    cin>>n>>a>>b;
    if(n==0)
        cout<<"0";
    else
    {
        ll ans=0;
        ans=(n/(a+b))*a;
        if(n%(a+b)>=a)
            ans+=a;
        else
            ans+=n%(a+b);
        cout<<ans;
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
//        DecimalFormat df = new DecimalFormat("0.00000000");

        int s = Integer.parseInt(sc.next());
        int ans = 1;
        while (true) {
            if (s == 4 || s == 2 || s == 1) {
                ans += 3;
                break;
            }
            ans++;
            if (s % 2 == 0) {
                s = s / 2;
            } else {
                s = 3 * s + 1;
            }
        }
        out.println(ans);
        
        out.flush();
    }
}

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

const int lim = 80 * 80;

int A[81][81], B[81][81], C[81][81];
bool dp[81][81][lim + 1];

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

    int H, W;
    cin >> H >> W;

    for(int i=1; i<=H; i++)
        for(int j=1; j<=W; j++)
            cin >> A[i][j];
    
    for(int i=1; i<=H; i++)
        for(int j=1; j<=W; j++)
            cin >> B[i][j];
    
    for(int i=1; i<=H; i++)
        for(int j=1; j<=W; j++)
            C[i][j] = A[i][j] - B[i][j];

    dp[1][1][abs(C[1][1])] = true;

    for(int i=1; i<=H; i++)
        for(int j=1; j<=W; j++)
        {
            if(i == 1 && j == 1)
                continue;

            for(int k=0; k<=lim; k++)
            {
                bool ans = false;

                if(abs(k + C[i][j]) <= lim)
                {
                    ans |= dp[i-1][j][abs(k + C[i][j])];
                    ans |= dp[i][j-1][abs(k + C[i][j])];
                }

                if(abs(k - C[i][j]) <= lim)
                {
                    ans |= dp[i-1][j][abs(k - C[i][j])];
                    ans |= dp[i][j-1][abs(k - C[i][j])];
                }

                dp[i][j][k] = ans;
            }
        }

    for(int i=0; i<=lim; i++)
        if(dp[H][W][i])
        {
            cout << i << "\n";
            break;
        }

    return 0;
}


Measured memory_bytes: 40832
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
using namespace std;

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
	int xx = x2 - x1, yy = y2 - y1;
	cout << x2 - yy << " " << y2 + xx << " " << x1 - yy << " " << y1 + xx << '\n';
}

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

ll a, b, c, d;
ll solve(ll x) {
  ll lcm = (__gcd(c, d))*(c/__gcd(c, d))*(d/__gcd(c, d));
  return max(0LL, x-((x/c)+(x/d)-(x/lcm)));
}

int main() {
  cin >> a >> b >> c >> d;
  cout << solve(b)-solve(a-1) << "\n";
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
using namespace std;
int N=0;
int main(void){
	cin>>N;
	if(65<=N&&N<=90){
		cout<<1<<endl;
	}
	else if(97<=N&&N<=122){
		cout<<2<<endl;
	}
	else cout<<0<<endl;
	return 0;
}


Measured memory_bytes: 3096
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
9
0 1 4
1 2 3
2 -1 -1
3 -1 -1
4 5 8
5 6 7
6 -1 -1
7 -1 -1
8 -1 -1

output:
Preorder
 0 1 2 3 4 5 6 7 8
Inorder
 2 1 3 0 6 5 7 4 8
Postorder
 2 3 1 6 7 5 8 4 0
"""

import sys


class Node(object):
    def __init__(self):
        # init node as a single leaf node.
        self.parent = -1
        self.children = []
        self.index = -1


def pre_parse(v):
    print(' ' + str(v.index), end='')

    left_child_idx = v.children[0]
    right_child_idx = v.children[1]

    if left_child_idx != -1:
        pre_parse(node_list[left_child_idx])

    if right_child_idx != -1:
        pre_parse(node_list[right_child_idx])

    return v.index


def in_parse(v):
    left_child_idx = v.children[0]
    right_child_idx = v.children[1]

    if left_child_idx != -1:
        in_parse(node_list[left_child_idx])

    print(' ' + str(v.index), end='')

    if right_child_idx != -1:
        in_parse(node_list[right_child_idx])

    return v.index


def post_parse(v):
    left_child_idx = v.children[0]
    right_child_idx = v.children[1]

    if left_child_idx != -1:
        post_parse(node_list[left_child_idx])

    if right_child_idx != -1:
        post_parse(node_list[right_child_idx])

    print(' ' + str(v.index), end='')

    return v.index


def generate_tree(_array):
    # add info of each node of a ordered tree
    for each in _array:
        idx, *children = [int(x) for x in each]
        # assert len(children) == 2 and idx >= 0
        node_list[idx].index = idx
        node_list[idx].children = children

        for child_idx in children:
            # non-existent node: no parent
            if child_idx == -1:
                continue
            node_list[child_idx].parent = idx

    # find root node
    root_idx = [x.index for x in node_list if x.parent == -1][0]
    root_node = node_list[root_idx]

    # tree walk in 3 ways
    print('Preorder')
    pre_parse(root_node)
    print('\n' + 'Inorder')
    in_parse(root_node)
    print('\n' + 'Postorder')
    post_parse(root_node)
    print('')

    return node_list


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    array_length = int(_input[0])
    array = list(map(lambda x: x.split(), _input[1:]))
    # assert len(array) == array_length

    node_list = [Node() for _ in range(array_length)]
    ans = generate_tree(_array=array)

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

struct UnionFind
{
    std::vector<std::size_t> _par;
    std::vector<std::size_t> _size;
    std::vector<std::size_t> _rank;

    UnionFind(std::size_t N)
        : _par(N)
        , _size(N, 1)
        , _rank(N, 0)
    {
        for (std::size_t i = 0; i < N; i++)
        {
            _par[i] = i;
        }
    }

    std::size_t Root(std::size_t x)
    {
        if (_par[x] == x)
        {
            return x;
        }
        return _par[x] = Root(_par[x]);
    }

    void Unite(std::size_t x, std::size_t y)
    {
        auto rx = Root(x);
        auto ry = Root(y);
        if (rx != ry)
        {
            if (_rank[rx] < _rank[ry])
            {
                _par[rx] = ry;
                _size[ry] += _size[rx];
            }
            else
            {
                _par[ry] = rx;
                _size[rx] += _size[ry];
                if (_rank[rx] == _rank[ry])
                {
                    _rank[ry]++;
                }
            }
        }
    }

    size_t Size(std::size_t x)
    {
        return _size[Root(x)];
    }

    bool Same(std::size_t x, std::size_t y)
    {
        auto rx = Root(x);
        auto ry = Root(y);
        return rx == ry;
    }
};

using namespace std;

int main()
{
    int n, q;
    cin >> n >> q;
    UnionFind uf(n);
    for (int i = 0; i < q; i++)
    {
        int com, x, y;
        cin >> com >> x >> y;
        if (com == 0)
        {
            uf.Unite(x, y);
        }
        else
        {
            cout << (uf.Same(x, y) ? 1 : 0) << endl;
        }
    }
}


Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()
struct revran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { --i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr revran(const i64 e) noexcept: b(0), e(e) {}
  constexpr revran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(e - 1); }
  constexpr iter end() const noexcept { return iter(b - 1); }
};

struct ran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { ++i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr ran(const i64 e) noexcept: b(0), e(e) {}
  constexpr ran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(b); }
  constexpr iter end() const noexcept { return iter(e); }
  constexpr revran rev() const noexcept { return revran(b, e); }
};

constexpr ran rin(const i64 e) noexcept { return ran(1, e + 1); }
constexpr ran rin(const i64 b, const i64 e) noexcept { return ran(b, e + 1); }

int main() {
  int n;
  cin >> n;
  array<i64, 4> p;
  array<i64, 4> t;
  for(int i = 0;i < 4;i++) cin >> p[i];
  for(int i = 0;i < 4;i++) cin >> t[i];
  vector<vector<i64>> dp(5, vector<i64>(n + 1, 1e9));
  dp[0][0] = 0;
  for(int i = 0;i < 4;i++) {
    for(int j = 0;j <= n;j++) {
      dp[i + 1][j] = dp[i][j];
      dp[i + 1][j] = min(dp[i + 1][j], dp[i][max(j - t[i], 0ll)] + p[i]);
      dp[i + 1][j] = min(dp[i + 1][j], dp[i + 1][max(j - t[i], 0ll)] + p[i]);
    }
  }
  cout << dp[4][n] << endl;
}



Measured memory_bytes: 3148
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        int d = scan.nextInt();
        if ((a == b && c == d)|| (a==d && b==c)  ) {
            System.out.println("yes");
        }else{
            System.out.println("no");
        }

    }
}



Measured memory_bytes: 26228
#include <bits/stdc++.h>
#define n 5
using namespace std;

int main(){
    int a[5];
    int b[5];
    int min=10;
    int final_i;
    for(int i=0;i<n;i++) {
        cin >> a[i];
        int tmp=a[i]%10;
        if(tmp<min&&tmp!=0){
            min=tmp;
            final_i=i;
        }
        if(tmp==0) b[i]=a[i];
        else b[i]=((a[i]/10)+1)*10;
    }
    int time=0;
    for(int i=0;i<n;i++){
        if(i!=final_i) time+=b[i];
    }
    if(min!=10) time+=a[final_i];
    cout<<time<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;

int main() {
  int A,B,C,X,Y,kingaku;
  scanf("%d %d %d %d %d",&A,&B,&C,&X,&Y);
  if (A + B < 2*C) kingaku = A*X + B*Y;
  else {
    int tmp;
    kingaku = C * 2 * min(X,Y);
    if (min(X,Y) == X) {
      tmp = min(B,2*C)*(Y-X);
      kingaku += tmp;
    } else {
      tmp = min(A,2*C)*(X-Y);
      kingaku += tmp;
    }
  }
  printf("%d\n",kingaku);
  return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  int x = 0;
  for (int i = 0; i < n; ++i) {
    x ^= a[i];
  }
  for (int i = 0; i < n; ++i) {
    cout << (x ^ a[i]) << (i == n - 1 ? '\n' : ' ');
  }
  return 0;
}

Measured memory_bytes: 3924
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
ll gcd(ll a, ll b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

#include <map>

int main(void){
    map<pair<int, int>, bool> m;
    pair<int, int> p {-2e9, -1};
    ll ans = 0;
    bool hasFlat = true;
    
    Cin(int, q);
    Rep(q){
        Cin(int, type);
        
        if(type == 1){
            Cin(int, a, b);
            auto x = make_pair(a, _);
            ans += b;
            m[x] = true;
            
            //for(auto e : m) cout << e.first.first << " " << e.first.second << "; ";
            if(hasFlat){
                if(x > p){
                    p = m.upper_bound(p)->first;
                }
            }
            else{
                if(x < p){
                    ans += p.first;
                    p = (--m.lower_bound(p))->first;
                    ans -= p.first;
                }
            }
            ans += abs(p.first - a);
            
            hasFlat ^= true;
            //printf("[%d, %lld]\n", p.first, ans);
        }
        
        else{
            Cout(p.first, " ", ans);
        }
    }
}


Measured memory_bytes: 12800
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int preT = 0;
        int preX = 0;
        int preY = 0;

        for (int i=0; i<N; i++) {
            int postT = sc.nextInt();
            int postX = sc.nextInt();
            int postY = sc.nextInt();

            int dt = postT - preT;
            int dist = Math.abs(postX - preX) + Math.abs(postY - preY);
            if ((dt < dist) || ((dist - dt) % 2 != 0)) {
                System.out.println("No");
                return;
            }

            preT = postT;
            preX = postX;
            preY = postY;
        }

        System.out.println("Yes");
    }
}

Measured memory_bytes: 85076
#include<cstdio>
#include<cstring>
#define N 300003
#define p 1000000007
inline int mod(int x){return x>p?x-p:x;}
char c[N];int f[8],g[8],i,j,k,n,x;const int a[8]={1,3,5,1,1,7,6,5},b[8]={2,4,6,1,2,2,6,5};
int main()
{
	scanf("%s",c+1),n=strlen(c+1),*f=1;
	for(i=1;i<=n;i++,memcpy(f,g,32),memset(g,0,32))
	{
		if(c[i]!=48)for(j=0;j<8;j++)g[b[j]]=mod(g[b[j]]+f[j]);
		if(c[i]!=49)for(j=0;j<8;j++)g[a[j]]=mod(g[a[j]]+f[j]);
	}
	return 0*printf("%d\n",mod(f[2]+f[6]));
}

Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std;

struct Node{
    int key;
    Node *right,*left,*parent;
};

Node *root,*NIL;

Node * treeM(Node *x){
    while(x->left!=NIL)x=x->left;
    return x;
}

Node * find(Node *u,int k){
    while(u!=NIL && k!=u->key){
        if(k<u->key)u=u->left;
        else u=u->right;
    }
    return u;
    
}

Node * treeS(Node *x){
    if(x->right!=NIL)return treeM(x->right);
    Node *y=x->parent;
    while(y!=NIL&&x==y->right){
        x=y;
        y=y->parent;
    }
    return y;
}

void treeD(Node *z){
    Node *y;
    Node *x;
    
    if(z->left==NIL||z->right==NIL)y=z;
    else y=treeS(z);
    
    if(y->left!=NIL){
        x=y->left;
    }
    else{
        x=y->right;
    }
    
    if(x!=NIL){
        x->parent=y->parent;
    }
    if(y->parent==NIL){
        root = x;
    }
    else{
        if(y==y->parent->left){
            y->parent->left=x;
        }
        else{
            y->parent->right=x;
        }
    }
    if(y!=z){
        z->key=y->key;
    }
    free(y);
}
void insert(int k){
    Node *y=NIL;
    Node *x=root;
    Node *z;
    z=(Node *)malloc(sizeof(Node));
    z->key=k;
    z->left=NIL;
    z->right=NIL;
    
    while(x!=NIL){
        y=x;
        if(z->key<x->key){
            x=x->left;
        }
        else{
            x=x->right;
        }
    }
    z->parent = y;
    if(y==NIL){
        root=z;
    }
    else{
        if(z->key<y->key){
            y->left=z;
        }
        else{
            y->right=z;
        }
    }
}
void inorder(Node *u){
    if(u==NIL)return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
void preorder(Node *u){
    if(u==NIL)return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}
int main(){
    int n,i,x;
    string com;
    
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        cin >> com;
        if(com[0]=='f'){
            scanf("%d",&x);
            Node *t=find(root,x);
            if(t!=NIL)printf("yes\n"); 
            else printf("no\n");
        }
        else if(com=="insert"){
            scanf("%d",&x);
        insert(x);
        }
        else if(com=="print"){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
        else if(com=="delete"){
            scanf("%d",&x);
            treeD(find(root,x));
        }
    }
    return 0;
}


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

ll mod = 1e9+7;

ll power(ll n, ll x)
{
	if(x==0) return 1ll;
	ll p = 1;
	for(int i=0;i<x;i++)
	{
		p = (p*n)%mod;
	}
	return p;
}

int main()
{
	ll i,j,n;
	cin>>n;
	if(n==1) {cout<<0;return 0;}
	ll ch = power(10,n);
    ch -= 2*power(9,n);
    ch += power(8,n);
    ch%=mod;
	ch = ch+mod;
	ch%=mod;
	cout<<ch<<"\n";
}

Measured memory_bytes: 3636
import java.util.*;
class Main{
	public static void main(String[] args) {
		Scanner sn=new Scanner(System.in);
		int n=sn.nextInt();
		int a=0;
		int cnt=0;
		int cnt4=0;
		int cnt2=0;
		do{
			a=sn.nextInt();
			if(a%4==0)
				cnt4++;
			else if(a%2==0)
				cnt2++;
			cnt++;
	}while(cnt<n);
	cnt4+=cnt2/2;
		if(cnt4>=n/2)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}

Measured memory_bytes: 47060