akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define EPS (1e-10)
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	vector<vector<int>>a(n, vector<int>(n - 1));
	rep(i, n) {
		rep(j, n - 1) {
			cin >> a[i][j];
			a[i][j]--;
		}
		reverse(a[i].begin(), a[i].end());
	}
	vector<P>q;
	auto check = [&](int i) {
		if (a[i].size() == 0)return;
		int j = a[i].back();
		if (a[j].size() == 0)return;
		if (a[j].back() == i) {
			P p(i, j);
			if (p.second < p.first)swap(p.first, p.second);
			q.push_back(p);
		}
	};
	rep(i, n) {
		check(i);
	}
	int day = 0;
	while (!q.empty()) {
		day++;
		sort(q.begin(), q.end());
		q.erase(unique(q.begin(), q.end()), q.end());
		vector<P>prevQ;
		swap(prevQ, q);
		for (P p : prevQ) {
			int i = p.first, j = p.second;
			a[i].pop_back();
			a[j].pop_back();
		}
		for (P p : prevQ) {
			int i = p.first, j = p.second;
			check(i);
			check(j);
		}
	}
	rep(i, n) {
		if (a[i].size() != 0) {
			puts("-1"); return 0;
		}
	}
	cout << day << endl;
	return 0;
}

Measured memory_bytes: 8192
while True:
    lis = input().split()
    a = int(lis[0])
    b = lis[1]
    c = int(lis[2])
    if b == '?' :
        break
    if b == '+':
        print(a+c)
    if b == '-':
        print(a-c)
    if b == '*':
        print(a*c)
    if b== '/':
        print(a//c)
        


Measured memory_bytes: 5596
from itertools import combinations
def main():
    N, K = map(int, input().split())
    P = [list(map(int, input().split())) for _ in range(N)]
    ans = 1<<62
    for t in combinations(P, min(4, K)):
        xs, ys = zip(*t)
        xmin = min(xs)
        xmax = max(xs)
        ymin = min(ys)
        ymax = max(ys)
        area = (xmax-xmin) * (ymax-ymin)
        if ans < area:
            continue
        k = 0
        for x, y in P:
            if xmin <= x <= xmax and ymin <= y <= ymax:
                k += 1
        if k >= K:
            ans = area
    print(ans)

main()


Measured memory_bytes: 9208
N = int(input())
A = list(map(int,input().split()))
suma = 0
left = 0
right = 0
count = 0
while left != N:
    if right == N:
        count += right-left
        suma -= A[left]
        left += 1
    elif suma+A[right] == suma^A[right]:
        suma += A[right]
        right += 1
    else:
        count += right - left
        suma -= A[left]
        left += 1
print(count)

Measured memory_bytes: 23560
import java.io.*;
import java.util.*;
import java.lang.*;

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

        int t=1;
//        int t=scan.nextInt();
        while(t-->0) {

            int h=scan.nextInt(),w=scan.nextInt(),m=scan.nextInt();
            int[] row=new int[h],col=new int[w];
            HashSet<String> points=new HashSet<>();
            while(m-->0) {
                int r=scan.nextInt()-1,c=scan.nextInt()-1;
                points.add(r+" "+c);
                row[r]++;
                col[c]++;
            }

            int maxX=0,maxY=0;
            for(int c=1;c<h;c++) if(row[c]>row[maxX]) maxX=c;
            for(int c=1;c<w;c++) if(col[c]>col[maxY]) maxY=c;
            ArrayList<Integer> maxXX=new ArrayList<>(),maxYY=new ArrayList<>();
            int ans=row[maxX]+col[maxY]-1;
            for(int c=0;c<h;c++) if(row[c]==row[maxX]) maxXX.add(c);
            for(int c=0;c<w;c++) if(col[c]==col[maxY]) maxYY.add(c);

            o: for(int i=0;i<maxXX.size();i++) {
                for(int j=0;j<maxYY.size();j++) {
                    if(!points.contains(maxXX.get(i)+" "+maxYY.get(j))) {
                        ans++;
                        break o;
                    }
                }
            }
            out.println(ans);
        }
        out.close();
    }

    //scanner
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 92796
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
#define INF 1007654321
#define PI 3.14159265358979
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repp(i, s, e) for(int i = (s); i <= (e); ++i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0)
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) { for (auto x : v) os << x << " "; return os << "\n"; }

const int MOD = 1e9 + 7;
const int MAXV = 1e5;

int main() {
    FAST_IO();
    int N; cin >> N;
    vector<pii> X(N);
    rep(i, N) {
        cin >> X[i].first;
        X[i].second = i;
    }
    sort(all(X));
    vector<int> ans(N);
    rep(i, N) {
        if(i <= (N - 1) / 2) {
            ans[X[i].second] = X[N / 2].first;
        } else {
            ans[X[i].second] = X[(N - 1) / 2].first;
        }
    }
    for(auto &x : ans) cout << x << "\n";
    return 0;
}

Measured memory_bytes: 4608
n,k = (int(x) for x in input().split())
"""cnt=0
for a in range(1,n+1):
	for b in range(1,n+1):
		for c in range(1,n+1):
			if a<= b & b<=c:
				#print(a,b,c)
				if (a+b)%k is 0 and (b+c)%k is 0 and (c+a)%k is 0:
					if a is b and b is c and c is a:
						cnt += 1
					elif a is b or b is c or c is a:
						cnt += 3
					elif a is not b and b is not c and c is not a:
						cnt += 6
					else: 
						print(f**k)

print(cnt)
"""
cnt=0
cnt2=0
for i in range(1,n+1):
  if k % 2 is 1:
  	if i % k is 0:
  		cnt += 1
  else:
  	if i % k is 0:
  		cnt += 1
  	elif i % k == int(k/2):
  		cnt2 += 1

#print(cnt,cnt2)
tmp = cnt*cnt*cnt +cnt2*cnt2*cnt2
print(tmp)

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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(lint i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(lint i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

int main(){
    lint n, h;
    cin >> n >> h;
    lint a = 0;
    vector<lint> b(n);
    rep(i, n){
        lint ai;
        cin >> ai >> b[i];
        a = max(a, ai);
    }
    sort(b.rbegin(), b.rend());
    int j = 0;
    lint ans = 0;
    while(h > 0 && b[j] > a && j < n){
        h -= b[j];
        ans++;
        j++;
    }
    if(h > 0){
        ans += (h - 1) / a + 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
A=[list(map(int,input().split())) for i in range(N)]
count=0
for i in range(N):
  sum=0
  for j in range(M):
    sum+=A[i][j]*B[j]
  if sum+C>0:count+=1
print(count)

Measured memory_bytes: 3064
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
		int count = int.Parse(Reader.ReadLine());
		int[] primeList = this.GetPrimeList();
		primeList = primeList.Where(a => a % 5 == 1).ToArray();
		Console.WriteLine(string.Join(" ", primeList.Take(count)));
	}

	private int[] GetPrimeList() {
		bool[] flags = new bool[55555 + 1];
		List<int> ans = new List<int>();
		for (int i = 2; i < flags.Length; i++) {
			if(flags[i]) {
				continue;
			}
			ans.Add(i);
			int max = 55555 / i;
			for (int j = 1; j <= max; j++) {
				flags[i * j] = true;
			}
		}
		return ans.ToArray();
	}

	public class Reader
    {
        static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"


8


";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}

Measured memory_bytes: 11308
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
const LL INF=1e18;
const int MAXN=2e5+100;
const double eps=1e-10;
bool vis[MAXN];

int main()
{
    int n,m;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        int u,v;
        bool flag=false;
        for(int i=1;i<=n;i++)
            vis[i]=false;
        for(int i=1;i<=m;i++)
        {
            scanf("%d%d",&u,&v);
            if(flag) continue;
            if(u==1)
            {
                if(vis[v])
                {
                    flag=true;
                }
                vis[v]=true;
            }else if(v==n)
            {
                if(vis[u])
                {
                    flag=true;
                }
                vis[u]=true;
            }
        }
        if(flag) printf("POSSIBLE\n");
        else printf("IMPOSSIBLE\n");
    }
	return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <iostream>

typedef long long ll;
using namespace std;
const int mod = 1e9 + 7;

ll quickpower(ll a, ll b) {
  ll res = 1;
  ll mod = 1e9 + 7;
  while (b) {
    if (b & 1) {
      res = (res * a) % mod;
    }
    b = b >> 1;
    a = (a * a) % mod;
  }
  return res % mod;
}

long long mfact(long long x) {
  //返回的是 x！mod 1e9 + 7
  long long res = 1;
  for (long long i = 1; i <= x; i++) {
    res = res * i % mod;
  }
  return res;
}

long long combine(long long a, long long b) {
  //返回的是 aCb mod 1e9 + 7；
  return mfact(a) * quickpower((mfact(b) * mfact(a - b) % mod), mod - 2) % mod %
         mod;
}

int main() {
  int x, y;
  cin >> x >> y;
  if ((x + y) % 3 != 0) {
    cout << 0 << endl;
  } else {
    long long m, n;
    m = x - (x + y) / 3;  // 解方程
    n = y - (x + y) / 3;
    if ((m < 0) || (n < 0))
      cout << 0 << endl;
    else
      cout << combine(m + n, m) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
using namespace std;
 
 
int main()
{
  string a;
  int b;
  cin>>b;
  cin>>a;
  int tem1=0;
  if(b%2!=0)
  {
    tem1=1;  
  }
  else
  {
      for(int g=0;g<b/2;g++)
   {
    if(a[g]!=a[g+b/2])
    {
      tem1=1;
      break;
    }
   }
  }
  if(tem1)
  cout<<"No";
  else
  cout<<"Yes";
}

Measured memory_bytes: 256
let to_array s =
  Str.split (Str.regexp_string " ") s
  |> List.map int_of_string
  |> Array.of_list;;

let print_array l =
  Array.map string_of_int l
  |> Array.to_list
  |> String.concat " "
  |> print_endline;;

let merge (a:int array) left mid right =
  let n1 = mid - left and
      n2 = right - mid in
  let l = Array.init (n1+1) (fun i -> if i < n1 then a.(left+i) else max_int) and
      r = Array.init (n2+1) (fun i -> if i < n2 then a.(mid+i) else max_int) and
      i = ref 0 and
      j = ref 0 and
      count = ref 0
  in
  for k = left to right-1 do
    if l.(!i) <= r.(!j) then
      begin
        a.(k) <- l.(!i); i := !i+1
      end
    else
      begin
        a.(k) <- r.(!j); j := !j+1
      end;
    count := !count+1
  done;
  !count

let rec merge_sort a left right count =
  if left + 1 < right then
    let mid = (left+right)/2 in
    let count1 = merge_sort a left mid count and
        count2 = merge_sort a mid right count in
    count1 + count2 + (merge a left mid right)
  else count
;;

let () =
  let _ = read_int () and
      a = read_line () |> to_array in
  let count = merge_sort a 0 (Array.length a) 0 in
  print_array a;
  print_int count;
  print_newline ()
;;

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

Measured memory_bytes: 1008
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

a = int(arr_data[0][0])
b = int(arr_data[0][1])

print(math.ceil((a+b)/2))




Measured memory_bytes: 3060
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<cstring>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REV(i,a,b) for(int i=(a)-1;i>=(b);i--)

using namespace std;

typedef long long ll;

int H,W;
char board[50][50];

bool hantei(int i,int j){
  if(i==0 && j ==0){
    if(board[i][j+1]=='#' || board[i+1][j]=='#') return true;
    else return false;
  }
  else if(i==0 && j == W-1){
    if(board[i][j-1]=='#' || board[i+1][j]=='#') return true;
    else return false;
  }
  else if(i==0){
    if(board[i][j-1]=='#' || board[i+1][j]=='#' || board[i][j+1] == '#') return true;
    else return false;
  }
  else if(i==H-1 && j == 0){
    if(board[i][j+1]=='#' || board[i-1][j]=='#') return true;
    else return false;
  }
  else if(i==H-1 && j == W-1){
    if(board[i][j-1]=='#' || board[i-1][j]=='#') return true;
    else return false;
  }
  else if(i==H-1){
    if(board[i][j-1]=='#' || board[i-1][j]=='#' || board[i][j+1] == '#') return true;
    else return false;
  }
  else if(j==0){
    if(board[i-1][j]=='#' || board[i+1][j]=='#' || board[i][j+1] == '#') return true;
    else return false;
  }
  else if(j==W-1){
    if(board[i][j-1]=='#' || board[i-1][j]=='#' || board[i+1][j] == '#') return true;
    else return false;
  }
  else{
    if(board[i][j-1]=='#' || board[i][j+1]=='#' || board[i-1][j] == '#' || board[i+1][j]=='#') return true;
    else return false;
  }
}

int main(){
  cin >> H >> W;
  REP(i,H) REP(j,W) cin >> board[i][j];

  REP(i,H) REP(j,W){
    if(board[i][j]=='.')continue;
    if(!hantei(i,j)){
      cout << "No"<< endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

bool is_ok(ll &n, ll &k, vll &a, vll &f, ll &m) {
  ll ans = 0;
  for (ll i = 0; i < n; i++) {
    ll score = a[i] * f[n - 1 - i];
    ll train = ceil((double)(score - m) / f[n - 1 - i]);
    ans += max(0LL, train);
  }
  return (ans <= k);
}

//二分探索
ll binary_search(ll &min, ll &max, ll &n, ll &k, vll &a, vll &f) {
  if (min == max) { //main関数から呼び出した時点でmin == maxである場合の処理
    if (0/*maxが条件を満たす*/) return max;
    else {
      //適宜処理
    }
  }

  if (min + 1 == max) { //解近傍の処理
    if (is_ok(n, k, a, f, min)) return min;
    if (is_ok(n, k, a, f, max)) return max;
  }

  ll med = (min + max) / 2;
  if (is_ok(n, k, a, f, med)) return binary_search(min, med, n, k, a, f);
  else return binary_search(med, max, n, k, a, f);
}

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

  vll a(n), f(n);
  for (ll i = 0; i < n; i++) cin >> a[i];
  for (ll i = 0; i < n; i++) cin >> f[i];
  sort(all(a));
  sort(all(f));

  ll min = 0, max = 1e12;
  if (is_ok(n, k, a, f, min)) {
    cout << min << endl;
    return 0;
  }
  cout << binary_search(min, max, n, k, a, f) << endl;
}

Measured memory_bytes: 3328
def main():
	N, M, X = [int(x) for x in input().split(" ")]
	# data[i] = List, data[i][0] = price, data[i][j(1:M)] = skill up of algorithm j
	data = [[int(a) for a in input().split(" ")] for i in range(N)]

	price = []
	for i in range(2 ** N):
		bit_book = list(zero_pad(format(i, 'b'), N))
		p = 0
		level = [0] * M
		for j in range(len(bit_book)):
			if bit_book[j] == "1":
				d = data[j]
				p += d[0]
				level = [l + b for (l, b) in zip(level, d[1:])]
		if min(level) >= X:
			price.append(p)
	if len(price) > 0:
		print(min(price))
	else:
		print(-1)

def zero_pad(s, n):
	s = str(s)
	return ("0" * n + s)[-n:]

main()

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

using namespace std;

int main(){
    int a,b;
    char op;
    int wa,sa,seki,syou;

    while(cin >> a >> op >> b){
        if(op == '+'){
            wa = a + b;
            cout << wa << endl;
        }else if(op == '-'){
            sa = a - b;
            cout << sa << endl;
        }else if(op == '*'){
            seki = a * b;
            cout << seki << endl;
        }else if(op == '/'){
            syou = a / b;
            cout << syou << endl;
        }else{
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define MIN(a,b) ((a) <= (b) ? (a) : (b))
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort( ALL(v) )

using namespace std;
using ll = long long;
using P = pair<int,int>;


int main()
{

    ll mx  = 10000000;
    int A,B; cin >>A>>B;
    ll ans = 100000000000;
    for(int i = 1 ; i<= mx ; i++)
    {
        ll A1 = i*0.08;
        ll B1 = i*0.1;

        if(A1 == A && B1==B)
        {
            cout << i << endl;
            return 0;

        }
    }

    cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 256
/**
*	created: 24.08.2020 17:55:05
**/
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
using ll = long long;
using P = pair<int,int>;
// #define endl '\n'
#define int long long
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define rep2(i,s,n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
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;}
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1ll << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

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

    int n, wei; cin >> n >> wei;
    vector<int> w(n), v(n);
    rep(i,n) cin >> w[i] >> v[i];
    vector<int> w1, w2, w3, w4;
    w1.push_back(INF); w2.push_back(INF); w3.push_back(INF); w4.push_back(INF);
    rep(i,n) {
        if (w[i] == w[0]) w1.push_back(v[i]);
        if (w[i] == w[0] + 1) w2.push_back(v[i]);
        if (w[i] == w[0] + 2) w3.push_back(v[i]);
        if (w[i] == w[0] + 3) w4.push_back(v[i]);
    }
    sort(rall(w1)); sort(rall(w2)); sort(rall(w3)); sort(rall(w4));
    rep2(i,2,w1.size()) w1[i] += w1[i-1];
    rep2(i,2,w2.size()) w2[i] += w2[i-1];
    rep2(i,2,w3.size()) w3[i] += w3[i-1];
    rep2(i,2,w4.size()) w4[i] += w4[i-1];
    int ans = 0;
    rep(i,w1.size()) rep(j,w2.size()) rep(k,w3.size()) rep(l,w4.size()) {
        int vsum = w1[i] + w2[j] + w3[k] + w4[l];
        int wsum = w[0]*i + (w[0]+1)*j + (w[0]+2)*k + (w[0]+3)*l;
        if (w1[i] == INF) vsum -= w1[i];
        if (w2[j] == INF) vsum -= w2[j];
        if (w3[k] == INF) vsum -= w3[k];
        if (w4[l] == INF) vsum -= w4[l];
        if (wsum <= wei) chmax(ans,vsum);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3668
#include<cstdio>
#include<algorithm>
using namespace std;

int n;
int a;
int four;
int cnt;

int main(){

  scanf(" %d",&n);
  for(int i=0;i<n;i++){
    scanf(" %d",&a);

    if(a%4 == 0){
      four++;
      continue;
    }
    if(a%2){
      cnt++;
    }
  }

  if(n/2 <= four){
    printf("Yes\n");
  } else if(four == cnt){
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}

Measured memory_bytes: 128
def f(s):
  a=[-c]
  for i,s in enumerate(s,1):
    if s<'x'and a[-1]+c<i:a+=i,
  return a[1:k+1]
n,s=open(0)
n,k,c=map(int,n.split())
for a,b in zip(f(s[:n]),f(s[-2::-1])[::-1]):
  if a==n+1-b:print(a)

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

using namespace std;

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

typedef long long ll;
typedef long double ld;

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int h, w;
    cin >> h >> w;
    vector<vector<int> > a(h, vector<int>(w));
    rep (i, h) rep (j, w) cin >> a[i][j];
    int res = 0;
    vector<pair<int, int> > base, next;
    rep (i, h) {
        if (i % 2) {
            rrep (j, w) {
                if (a[i][j] % 2 == 0) continue;
                if (i + 1 == h && j - 1 < 0) continue;
                base.emplace_back(i, j);
                if (j - 1 >= 0) {
                    a[i][j - 1]++;
                    next.emplace_back(i, j - 1);
                } else if (i + 1 != h) {
                    a[i + 1][j]++;
                    next.emplace_back(i + 1, j);
                }
                a[i][j]--;
                res++;
            }
        } else {
            rep (j, w) {
                if (a[i][j] % 2 == 0) continue;
                if (i + 1 == h && j + 1 == w) continue;
                base.emplace_back(i, j);
                if (j + 1 != w) {
                    a[i][j + 1]++;
                    next.emplace_back(i, j + 1);
                } else if(i + 1 != h) {
                    a[i + 1][j]++;
                    next.emplace_back(i + 1, j);
                }
                a[i][j]--;
                res++;
            }
        }
    }
    cout << res << endl;
    rep (i, res) {
        cout << base[i].first + 1 << " " << base[i].second + 1 << " ";
        cout << next[i].first + 1 << " " << next[i].second + 1 << endl;
    }
    
    return 0;
}



Measured memory_bytes: 5356
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL;
  typedef pair<ll,char> PLC;
  typedef pair<char,ll> PCL;

int main(void){
  int N;cin >> N;
  ll XOR[N+1],SUM[N+1];
  XOR[0] = SUM[0] = 0;
  int i;
  REP(i,N){
    ll x;
    cin >> x;
    XOR[i+1] = XOR[i]^x;
    SUM[i+1] = SUM[i]+x;
  }
  ll count = 0;
  REP(i,N){
    int s=-1,e=i+1,mid;
    while(e-s>1){
      mid = (e+s)/2;
      if((XOR[i+1]^XOR[mid]) == SUM[i+1]-SUM[mid]){
        e=mid;
      }
      else s=mid;
    }
    count += i+1-e;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 3328
from __future__ import print_function

import sys
sys.setrecursionlimit(500000)


input = sys.stdin.readline


def judge(s, g):
    t = g[0] - s[0]
    x = g[1] - s[1]
    y = g[2] - s[2]
    if (abs(x)+abs(y)) % 2 == t % 2 and (abs(x)+abs(y)) <= t:
        return True
    else:
        return False


def main():
    # inputs
    n = int(input().strip())
    txy = [(0, 0, 0)]
    for i in range(n):
        tmp1, tmp2, tmp3 = map(int, input().strip().split())
        txy.append((tmp1, tmp2, tmp3))
    txy.sort()
    n += 1

    # procedure and output
    for i in range(0, n-1):
        if judge(txy[i], txy[i+1]) != True:
            print("No")
            return
    print("Yes")


if __name__ == '__main__':
    main()


Measured memory_bytes: 56796
from itertools import permutations 
N = int(input())

point = [] 
for i in range(N):
    x,y = map(int, input().split())
    point.append([x,y])


perm = list(range(N))

count = 0
distsum = 0
for i in permutations(perm):
    for j, k in zip(i, i[1:]):
        x1, y1 = point[j]
        x2, y2 = point[k]
        distsum += ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5
    count += 1

print(distsum / count)

Measured memory_bytes: 3188
// @ts-ignore
const main = (input: string) => {
  console.log(/7/.test(input) ? 'Yes' : 'No');
}

// *この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29612
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n, k;
int a[200100];

void solve() {
    for (int i = 0; i < n-k; i++) {
        if (a[i] < a[i+k]) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}

void input() {
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> a[i];
}

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

    input();
    solve();
}


Measured memory_bytes: 3876
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define ft first
#define sd second
#define mp make_pair
#define fr(i,n) for(int i=0;i<(n);i++)
#define Fr(i,n) for(int i=0;i++<(n);)
#define ifr(i,n) for(int i=(n)-1;i>=0;i--)
#define iFr(i,n) for(int i=(n);i>0;i--)

template<class T>
T gcd(T n,T m){
    if(n>m) return gcd(m,n);
    else if(n==0) return m;
    else return gcd(m-n*(m/n),n);
}

int main(){
    ll n,x,a[10010],b[100010],q=0;
    cin>>n;
    ifr(i,n+1){
        cin>>a[i];
        q=gcd(q,abs(a[i]));
    }
    ll m=0,p[10010];
    bool B[10010]={};
    for(ll i=2;i*i<=n;i++) if(!B[i]) for(ll j=i*i;j<=n;j+=i) B[j]=1;
    for(ll i=2;i<=n;i++) if(!B[i]) p[m++]=i;
    fr(i,m){
        bool f=1;
        fr(j,n+1) b[j]=a[j];
        for (int j = n; j >= p[i]; --j) b[j-p[i]+1]+=b[j];
        fr(j,p[i]) if(b[j]%p[i]!=0) f=0;
        if(f) cout<<p[i]<<endl;
    }
    vector<ll> fcn;
    for(ll i=2;i*i<=q;i++){
        if(q%i==0){
            int cnt=0;
            while(q%i==0){
                cnt++;
                q/=i;
            }
            fcn.pb(i);
        }
    }
    if(q>1) fcn.pb(q);
    fr(i,fcn.size()) if(fcn[i]>n) cout<<fcn[i]<<endl;
}

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

#define MOD 1000000007
#define N 100000

string s;
long long dp[N+1][4];

int main()
{
	long long ans = 0;

	cin >> s;

	dp[0][0] = 1;
	int sz = s.size();
	for( int i = 0; i < sz; i++ ) {
		for( int j = 0; j < 4; j++ ) {
			int m = 1;
			if( s[i] == '?' ) {
				m = 3;
			}
			dp[i+1][j] = dp[i][j] * m;
		}
		if( s[i] == 'A' || s[i] == '?' ) {
			dp[i+1][1] +=  dp[i][0];
		}
		if( s[i] == 'B' || s[i] == '?' ) {
			dp[i+1][2] += dp[i][1];
		}
		if( s[i] == 'C' || s[i] == '?' ) {
			dp[i+1][3] += dp[i][2];
		}
		dp[i+1][0] %= MOD;
		dp[i+1][1] %= MOD;
		dp[i+1][2] %= MOD;
		dp[i+1][3] %= MOD;
	}
	ans = dp[sz][3] % MOD;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3584
#include <stdio.h>
#define N_MAX 100
#define PRICE 100

int vote[N_MAX + 1];

int main(void)
{
    int i, n, m, p, t, count, winners;

    while(scanf("%d %d %d", &n, &m, &p), n+m+p)
    {
        count = 0;

        /* 1 ... m-1 */
        for(i=1; i<m; i++)
        {
            scanf("%d", &t);
            count += t;
        }

        /* m */
        scanf("%d", &winners);
        count += winners;

        /* m+1 ... n */
        for(i=m+1; i<=n; i++)
        {
            scanf("%d", &t);
            count += t;
        }

        /* result */
        if(winners)
            printf("%d\n", (count * PRICE * (100 - p)) / (winners * 100));
        else
            puts("0");
    }

    return 0;
}

Measured memory_bytes: 612
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#include<functional>
#include<list>
#include<map>
#include<unordered_map>
#define int long long
using namespace std;

signed main() {
	int a;
	cin >> a;
	int s = 0;
	for (int b = 0; b < a; b++) {
		int c; scanf("%lld", &c);
		bool k = true;
		for (int d = 1; d*d <= c; d++) {
			if ((c - d) % (2 * d + 1) == 0) { k = false; break; }
		}
		if (k)s++;
	}
	cout << s << endl;
}

Measured memory_bytes: 3080
// 2019/05/26 Tazoe

#include <iostream>
using namespace std;

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

	int P;

	if(A>=2*B){			// 500ミリリットルのほうが割安
		P = (X/500)*B;

		if(X%500!=0){
			P += B;
		}
	}
	else{				// 1リットルのほうが割安
		P = (X/1000)*A;

		if(X%1000!=0){
			if(X%1000<=500 && A>B){		// 余り500以下で，500のほうが安い
				P += B;
			}
			else{
				P += A;
			}
		}
	}

	cout << P << endl;

	return 0;
}



Measured memory_bytes: 3108
#include<iostream>
//#include<CastingInterop.h>
#include<string>
using namespace std;

int main()
{
	int n, a, b, c,f;
	cin >> n;
	a = n / 15;
	b = a * 200;
	c = n * 800;
	f = c - b;
	cout << f;
}

Measured memory_bytes: 3500
#include<iostream>
#include<string>
#include<cstdio>
using namespace std;
int main(){
	string s;
	while(getline(cin,s)){
		if(s=="END OF INPUT")break;
		int count=0;
		for(int i=0;i<s.size();i++){
			count++;
			if(s[i]==' '){
				printf("%d",count-1);
				count=0;
			}
		}
		cout<<count<<endl;
	}
	return 0;
}

Measured memory_bytes: 1212
A, B, C, X, Y = map(int, input().split())
ans = 0

if A + B <= 2*C:
    ans = A*X + B*Y
else:
    ans += 2*C*min(X, Y)

    if X >= Y:
        ans += min(A, 2*C) * (X-Y)
    else:
        ans += min(B, 2*C) * (Y-X)

print (ans)


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

// templates -------------------------------------

#define ULL unsigned long long
#define LL long long
#define LLD long long double
#define REP(i, n) for(LL i = 0; i < n; i++)
#define INV_REP(i, n) for(LL i = n; 0 <= i; i--)

LL combination(LL n, LL m)
{
  LL nume = 1;
  REP(i, m) nume *= (n-i);
  LL demo = 1;
  for(int i = 1; i <= m; i++) demo *= i;
  return nume / demo;
}

template<class T>
class UnionFind
{
private:
  vector<T> par;
  vector<T> rank;
  vector<T> size;

public:
  UnionFind(T N) :
    par(N, T()), rank(N, T()), size(N, T())
  {
    REP(i, N)
    {
      par[i] = i;
      rank[i] = 0;
      size[i] = 1;
    }
  }

  inline T root(T x)
  {
    return par[x] == x ? x : par[x] = root(par[x]);
  }

  inline bool same(T x, T y)
  {
    return root(x) == root(y);
  }

  inline T getSize(T x)
  {
    return size[root(x)];
  }

  void unite(T x, T y)
  {
    T r1 = root(x);
    T r2 = root(y);
    if(r1 == r2) return;

    if(rank[r1] < rank[r2]) swap(r1, r2);
    if(rank[r1] == rank[r2]) rank[r1]++;
    par[r2] = r1;
    size[r1] += size[r2];
  }
};

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

int n, k;
string s;

void input()
{
  cin >> n >> k >> s;
}

void solve()
{
  s[k-1] = (char)tolower(s[k-1]);
  cout << s;
}

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

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

int main() {
  int K, S; cin >> K >> S;
  int ans = 0;
  int C;
  
  for(int A=0; A<=K; A++) {
    for(int B=0; B<=K; B++) {
      C = S - A - B;
        if(0<= C && C <= K){
          ans++;
        }
    }
  }
  cout << ans << endl;
}


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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
const double INF = 1e10;
//const ll INF = LONG_LONG_MAX / 10;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef pair<double, double> P;

void print_line(vector<bool> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;
const int mod = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<vector<bool>> matrix(n, vector<bool>(n, false));
    rep(i, n) {
        int j, k;
        cin >> j >> k;
        j--;
        rep(l, k) {
            int m;
            cin >> m;
            m--;
            matrix[j][m] = true;
        }
    }

    rep(i, n) print_line(matrix[i]);

}




Measured memory_bytes: 3120
import sys
input = sys.stdin.buffer.readline
from numba import njit, prange
import numpy as np
INF = 10**18

@njit('(i8, i8[:,:])')
def solve(N, XYP):
    X = XYP[:, 0]
    Y = XYP[:, 1]

    def calcCost(sign, A):
        ret = np.ones((1 << N, N), dtype=np.int64) * INF
        for state in range(1 << N):
            useA = [a for i, a in enumerate(A) if (state & (1 << i)) != 0]
            for i in range(N):
                xyp = XYP[i]
                cost = abs(xyp[sign])
                for z in useA:
                    cost = min(cost, abs(xyp[sign] - z))
                ret[state][i] = cost * xyp[2]
        return ret

    costX = calcCost(0, X)
    costY = calcCost(1, Y)
    ans = np.ones(N + 1, dtype=np.int64) * INF

    for state in range(pow(3, N)):
        stateX = 0
        stateY = 0
        M = N
        for _ in range(N):
            state, r = divmod(state, 3)
            stateX <<= 1
            stateY <<= 1
            if r == 0: M -= 1
            if r == 1: stateX |= 1
            if r == 2: stateY |= 1

        cx, cy = costX[stateX], costY[stateY]
        cost = 0
        for i in prange(N):
            cost += min(cx[i], cy[i])
        ans[M] = min(ans[M], cost)

    for a in ans:
        print(a)

def sol():
    N = int(input())
    XYP = np.asarray([list(map(int, input().split())) for _ in range(N)])
    solve(N, XYP)

sol()


Measured memory_bytes: 139168
import java.io.DataInputStream;
import java.io.IOException;

class Main {

    final private static int BUFFER_SIZE = 1 << 16;
    private static DataInputStream din;
    private static byte[] buffer;
    private static int bufferPointer, bytesRead;

    public static void main(String[] args) throws IOException {
        Reader reader = new Reader();
        int n = reader.nextInt();
        int counter = 0;
        boolean status = false;

        for (int i = 0; i < n; i++) {
            int a = reader.nextInt();
            int b = reader.nextInt();

            if (counter >= 2 && (a == b)) {
                status = true;
                continue;
            } else if (a != b) {
                counter = 0;
            } else {
                counter++;
            }
        }

        if (status) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    static class Reader {

        public Reader() {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public int nextInt() throws IOException {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public String readLine() throws IOException {
            byte[] buf = new byte[1000]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1) {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        private void fillBuffer() throws IOException {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException {
            if (din == null)
                return;
            din.close();
        }

    }
}

Measured memory_bytes: 32368
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

char s[200010];
int main(){
	scanf("%s",s);
	ll n=strlen(s);
	ll l=0,r=n;
	while(s[l]!='A')l++;
	while(s[r-1]!='Z')r--;
	printf("%lld",r-l);
}

Measured memory_bytes: 384
#include <cstdio>
#include <cctype>
#include <utility>
#include <array>
#include <vector>
#include <algorithm>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;while(isspace(c)){c=gcu();}if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m?-n:n;}
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}


int main() {
	array<vector<int>, 5> a;
	for (int H; (H = in());) {
		int s = 0, t;
		for (auto &x: a)
			x.resize(H);
		while (H--)
			for (auto &x: a)
				x[H] = in();
		do {
			t = 0;
			for (size_t i = 0; i < a[2].size(); i++) {
				int u = a[2][i], c = 1;
				auto all = [&](auto f) {
					auto each = [&](array<int, 2> b) {
						for (auto j: b)
							if (a[j][i] == u)
								f(j);
							else
								break;
					};
					each({1, 0});
					each({3, 4});
				};
				all([&c](...) {c++;});
				if (c >= 3) {
					t += u;
					a[2][i] = 0;
					all([&](int j) {a[j][i] = 0, t += u;});
				}
			}
			for (auto &x: a) {
				auto r = remove(x.begin(), x.end(), 0);
				x.erase(r, x.end());
			}
			s += t;
		} while(t);
		outl(s);
	}
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/14  Problem: 064_abc_c / Link: https://abc064.contest.atcoder.jp/tasks/abc064_c?lang=en  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N;

LL ans = 0LL;

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

	cin >> N;
	VI a(N);
	VI c(8,0);
	int god = 0;
	FOR(i, 0, N) {
		cin >> a[i];
		if (a[i] >= 3200)god++;
	}
	FOR(i, 0, 8) {
		FOR(k, 0, N) {
			if (i * 400 <= a[k] && a[k] < (i + 1) * 400) {
				c[i]++;
			}
		}
	}
	int m = 0;
	int M = 0;
	FOR(i, 0, 8) {
		if (c[i])m++;
	}
	if (m == 0 && god)m = 1,M=god;
	else M = m + god;
	cout << m << " " << M << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;   
int a[4];
int main(){
	fastIO;         
	int sx,sy,tx,ty;
	cin>>sx>>sy>>tx>>ty;	
	string prim="",prim2="",prim3="L",prim4="R";
	for(int i=0;i<ty-sy;i++){
		prim+='U';
		prim2+='D';
		prim3+='U';
		prim4+='D';
	}
	prim3+='U';
	prim4+='D';
	for(int i=0;i<tx-sx;i++){
		prim+='R';
		prim2+='L';
		prim3+='R';
		prim4+='L';
	}
	prim3+="RD";
	prim4+="LU";
	cout<<prim+prim2+prim3+prim4<<'\n';
	return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <string>
using namespace std;
int main (){
	string s;
	cin >> s;
	if (s=="SUN") cout << "7\n";
	else if (s=="MON") cout << "6\n";
	else if (s=="TUE") cout << "5\n";
	else if (s=="WED") cout << "4\n";
	else if (s=="THU") cout << "3\n";
	else if (s=="FRI") cout << "2\n";
	else if (s=="SAT") cout << "1\n";
}

Measured memory_bytes: 256
require 'bigdecimal'

n, k = gets.strip.split.map(&:to_i)

ans = (1..n).map { |i|
  count = 0
  point = i
  while k > point
    point *= 2
    count += 1
  end
  BigDecimal(1) / BigDecimal(2 ** count)
}.sum / BigDecimal(n)

puts(ans.to_f)


Measured memory_bytes: 31364
//Name : Rupa Dey
  //Date : 19 September 2020
//joi sri gour hori gobindo...
//gobindo ja hobe vlor jonnoi hobe..
#include<bits/stdc++.h>
#define ll long long
#define d double
#define ld long double
#define vi vector<int>
#define vul vector<ull>
#define vl vector<ll>
#define pb push_back
#define si set<int>
#define sl set<ll>
#define yes cout<<"YES\n"<<endl
#define no cout<<"NO\n"<<endl
#define ys cout<<"Yes\n"<<endl
#define n0 cout<<"No\n"<<endl
#define test cin>>t; while(t--)
#define for(i,a,n) for(i=a;i<n;i++)
#define mp make_pair
#define ft first
#define sc second
#define gp ' ';
#define MAX 9999999
#define MOD 1000000007
#define nd endl
using namespace std;
int main()
{
   ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin>>s;
    int len = s.size()-1;
    if(s[len]=='s') cout<<s<<"es";
    else cout<<s<<"s";

}
//hare krishna...
//hey gobindo kripa koro......
//only gobindo exists..^..


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

#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define int long long
using namespace std;
const int INF = 2e16;
const int MOD = 1e9 + 7;
const int MB = 20;
const int K = 500;
const int maxN = 50;

void solve() {
	int n, m;
	cin >> n >> m;
	vector<bool> good(n);
	vector<int> plus(n);
	int cnt1 = 0, cnt2 = 0;
	for (int i = 0; i < m; i++) {
		int x;
		string s;
		cin >> x >> s;
		x--;
		if (s == "AC") {
			if (!good[x]) {
				cnt1++;
				cnt2 += plus[x];
			}
			good[x] = true;
		}
		else {
			plus[x]++;
		}
	}
	cout << cnt1 << " " << cnt2;
}

signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	solve();
}

Measured memory_bytes: 1024
n = int(input())
l = list(map(int, input().split()))
l.sort()
 
from bisect import bisect_left
ans = 0
for i in range(n):
  for j in range(i+1, n):
    t = l[i]+l[j]
    idx = bisect_left(l, t, j+1)
    ans += max(0, idx-j-1)
print(ans)

Measured memory_bytes: 3316
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;

#define BIG_NUM 2000000000

using namespace std;

struct Info{
	Info(int arg_number){
		number = arg_number;
	}

	bool operator<(const struct Info &arg) const{
			return number > arg.number;
	};

	int number;
};

int main(){

	int N,tmp,sum;
	priority_queue<Info> Q;

	while(scanf("%d",&N) != EOF){
		for(int i = 0; i < N; i++){
			scanf("%d",&tmp);
			Q.push(Info(tmp));
		}

		sum = 0;

		for(int i = N; i >= 1; i--){
			sum += i*Q.top().number;
			Q.pop();
		}

		printf("%d\n",sum);
	}
	return 0;
}

Measured memory_bytes: 2604