akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <queue>
using namespace std;
int mp[100][100][4];
int dis[100][100];
int w,h;
struct ima{
  int x,y;
};

 queue <ima> Q;
  
void reset() {
  for(int i=0;i<h;i++) 
    for(int j=0;j<w;j++) {
      dis[i][j] = -1;
      for(int k=0;k<4;k++)
	mp[i][j][k] = 0;
    }
}


void bfs() {
  ima t;
  int dx[4] = {0,1,0,-1};
  int dy[4] = {-1,0,1,0};
  
  Q.push((ima){0,0});
  dis[0][0] = 0;
  
  while(!Q.empty()){
    t = Q.front();
    Q.pop();
    //   cout << t.x << t.y << endl;
    for(int i=0;i<4;i++) 
      if(t.y+dy[i] >= 0 && t.y+dy[i] < h && t.x+dx[i] >=0 && t.x+dx[i] < w)
	if(mp[t.y][t.x][i] ==0 && dis[t.y+dy[i]][t.x+dx[i]] == -1){
	  dis[t.y+dy[i]][t.x+dx[i]] = dis[t.y][t.x] + 1;
	  Q.push((ima){t.x+dx[i],t.y+dy[i]});	 
	}
  }
}

int main() {


  while(1) {
  cin >> w >> h;
  if(w == 0 && h == 0) break;

  reset();

  int a,b;
  for(int i=0;i<h;i++){
    
    for(int j=0;j<w-1;j++) {
      cin >> a ;
      if(a == 1)
      mp[i][j][1] = mp[i][j+1][3] = a;
    }
    
    if(i == h-1) continue;
    for(int j=0;j<w;j++) {
      cin >> a ;
      if(a == 1) 
      mp[i+1][j][0] = mp[i][j][2] = a;
    }
  }
  
  bfs();
  
  /* for(int i=0;i<h;i++){
    for(int j=0;j<w;j++)
      cout << dis[i][j] <<" ";
    cout << endl;
    }*/

  if(dis[h-1][w-1] == -1) cout << 0 << endl;
  else   cout << dis[h-1][w-1]+1 << endl;

  }
  
  return 0;

}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int n,m;
    string a[1000];
    cin>>n>>m;
    for(int i=0;i<n;i++)
    {
       cin>>a[i];
    }
    sort(a,a+n);
    for(int i=0;i<n;i++)
    {
        cout<<a[i];
    }
    return 0;
}


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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 2.01e18;
const double eps = 1e-9;

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

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

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

template<typename T, size_t size> void fill(T (&ary)[size], const T& val){
    fill_n((T*)ary, size, val);
}

void solve() {
    //const i64 mod = 1'000'000'007;

    i64 N;
    cin >> N;
    vector<long double> x(N),y(N);
    vector<char> d(N);
    rep(i,0,N) cin >> x[i] >> y[i] >> d[i];

    vector<pair<long double,long double>> intervals={make_pair(0,inf64)};

    random_device rnd;
    mt19937 mt(rnd());
    uniform_real_distribution<> rand(0, 4.1e8);
    i64 trial=1;
    while(intervals.size()<trial){
        auto l=rand(mt);
        auto r=rand(mt);
        if(l>r) swap(l,r);
        intervals.emplace_back(make_pair(l,r));
    }

    auto f=[&](long double t){
        long double xmin=inf64,xmax=-inf64,ymin=inf64,ymax=-inf64;
        rep(i,0,N){
            long double xx=x[i],yy=y[i];
            if(d[i]=='R') xx+=t;
            else if(d[i]=='L') xx-=t;
            else if(d[i]=='U') yy+=t;
            else yy-=t;
            chmin(xmin,xx);
            chmax(xmax,xx);
            chmin(ymin,yy);
            chmax(ymax,yy);
        }

        return (xmax-xmin)*(ymax-ymin);
    };

    auto ans=f(0);

    for(auto& p:intervals) {
        long double lb = p.first, ub = p.second;
        rep(i, 0, 200) {
            if(ub-lb<=1) break;
            auto a = (lb + lb + ub) / 3;
            auto b = (lb + ub + ub) / 3;
            if (f(a) > f(b)) {
                lb = a;
            } else {
                ub = b;
            }
        }
        i64 t=i64(lb);
        vector<long double> ts;
        rep(i,-3,4){
            auto s=t+0.5*i;
            if(s<0) continue;
            ts.emplace_back(s);
        }
        for(auto t:ts) chmin(ans,f(t));
    }

    cout << ans << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1000000007, INF = 1e9;

int main()
{
    int v[1010];
    v[0] = 1;
    for(int i = 1; i < 999; i++){
        v[i] = v[i-1]+(i+1);
    }
    int a, b;
    cin >> a >> b;
    int d = b-a;
    cout << (v[d-2]-a) << endl;
}

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

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;

int dp[10][1010];
int a[1010];
const int MOD=1e4+7;

int main(void){

	int N;
	string S;
	cin >> N >> S;
	REP(i,N){
		if(S[i]=='J') a[i+1]=1;
		else if(S[i]=='O') a[i+1]=2;
		else a[i+1]=4;
	}

	for(int i=1;i<=N;i++){
		REP(s,8){
				if(i==1){
					if((s&a[i])!=0 && (s&1)!=0) dp[s][i]++;
				}else{
				    REP(t,8){
				    if((s&a[i])!=0 && (s&t)!=0){
					dp[s][i]+=dp[t][i-1];
					dp[s][i]%=MOD;
				}
			}
		}
	}
	}

	int ans=0;
	REP(s,8) ans+=dp[s][N];

	cout << ans%MOD << endl;

	return 0;
}

Measured memory_bytes: 1240
#include<stdio.h>
#include<string.h>
int main(){
	int N;
	scanf("%d",&N);
	int AC,WA,TLE,RE;
	int b[4] = {0};
	while(N--){
		char a[4];
		scanf("%s",&a);
		
		if(strcmp(a,"AC")== 0){
			b[0]++;
		}else if(strcmp(a,"WA")== 0){
			b[1]++;
		}else if(strcmp(a,"TLE")== 0){
			b[2]++;
		}else if(strcmp(a,"RE")== 0){
			b[3]++;
		}
	}
	
	printf("AC x %d\n",b[0]);
	printf("WA x %d\n",b[1]);
	printf("TLE x %d\n",b[2]);
	printf("RE x %d\n",b[3]);
} 

Measured memory_bytes: 1708
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define REPS(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define RREP(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define RREPS(i, n) for (int i = ((int)(n)); i > 0; i--)
#define IREP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define IREPS(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVISORT(v) sort(v.begin(), v.end(), greater<int>());
#define ALL(v) v.begin(), v.end()
#define MP(n, m) make_pair(n, m);
#define COUT(d) cout<<std::setprecision(10)<<d<<endl;
#define CIN(n) getline(cin,n);
 
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using ll = long long;
using ul = unsigned long;
 
typedef long long ll;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
 
void printv(VI& v){
  REP(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vector<ll>& v){
  REP(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
 
int vtotal(VI& v){
  int total=0;
  REP(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
	
  //init(); // mint初期化
 
  int n;
  cin>>n;
 
  vector<ll> h;
  REP(i,n){
    ll a;cin>>a;
    h.push_back(a);
  }
 
  string ans="Yes";
  REP(i,n-1){
    ll now=h[i];
    ll next=h[i+1];
    ll before=0;
    if(i!=0)before=h[i-1];

    if(before<now){
      now--;
      h[i]=now;
    }

    if(now>next){
        ans="No";
        break;
    }

    if(before>now){
        ans="No";
        break;
    }
  }
  // printv(h);
  cout<<ans<<endl;
 
  return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
// #include <boost/lexical_cast.hpp>
using namespace std;

#define ll long long int
#define vll vector<ll>
#define vllv vector<vector<ll>> 
#define vpii vector<pair<ll,ll>>
#define pll  pair<ll,ll>
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll MOD=1000000000+7;
ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
ll factor(ll n){
    vll ans;
	if(n==2)ans.pb(2);
	else
    {for(ll i=2;i*i<=n;i++){if(n%i==0 && n%i!=i){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}ans.pb(n);}
    return ans.sz+1;
}
ll fact(ll n){ll res = 1;for (ll i = 2; i <= n; i++)res = res * i; 
    return res; } 
  
ll nCr(ll n, ll r){ return fact(n) / (fact(r) * fact(n - r)); } 
  
void dfs(vllv &v,ll k,vll &par,vll &dis,ll p)
{
    par[k]=p;
    dis[k]=dis[p]+1;
    for(ll i=0;i<v[k].sz;i++){
        if(v[k][i]!=p){
            dfs(v,v[k][i],par,dis,k);
        }
    }
}
bool sortbysec(const pair<string,int> &a,const pair<string,int> &b){return (a.second<b.second);} 

ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;}
bool prime(int n){
    int i,j;
    for(i=2;i<=sqrt(n);i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}
bool bserch(vector<string> a, string s){
	ll l=0,r=a.sz-1,mid;
	while(l<=r){
		mid=(l+r)/2;
		if(a[mid]==s)return true;
		if(a[mid]<s){
			l=mid+1;
		}else{
			r=mid-1;
		}
	}
	return false;
}

void solve()
{
	ll x,y;
	cin>>x>>y;
	ll a=0,b=0;
	ll arr[7]={1,3,5,7,8,10,12};
	ll ar2[4]={4,6,9,11};

	for(ll i=0;i<7;i++)
	{
		if(x==arr[i])
			a=1;
		if(y==arr[i])
			b=1;
	}
	// cout<<ar2[3]<<ar2[0];
	for(ll i=0;i<4;i++)
	{
		if(x==ar2[i])
			a=2;
		if(y==ar2[i])
			b=2;
	}
	if(x==y || a==b)
	{
		cout<<"Yes";
	}
	else
		cout<<"No";
	
    return;
}            
int main()
{
	fast;
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <map>

int main () {
    int64_t N;
    std::map<int64_t,int64_t> test_map;
    std::cin >> N;
    int64_t count = 0;
        
    for (int64_t i=0; i<N; i++) {
        int64_t height;
        std::cin >> height;
        // i - j = height[i] + height[j]
        // i - height[i] = j + height[j]
        count += test_map[i-height];
        test_map[i+height]++;
    }
    std::cout << count << std::endl;
}

Measured memory_bytes: 26328
#include<iostream>
using namespace std;
int main(){
	int n,m,x;
	int a[101]={0},t[101];
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>t[i];
	}
	for(int i=0;i<m;i++){
		for(int j=0;j<n;j++){
			cin>>x;
			if(x==t[i]){
				a[j]++;
			}
			else{
				a[t[i]-1]++;
			}
		}
	}
	for(int i=0;i<n;i++){
		cout<<a[i]<<endl;
	}
}

Measured memory_bytes: 3076
<?php
fscanf(STDIN, '%s', $str);
$word = 'keyence';
if (substr($str, 0, 7) === $word || substr($str, -7, 7) === $word) {
    echo 'YES';
} else {
    for ($i=1; $i < 7; $i++) { 
        $key = substr($str, 0, $i);
    }

    for ($i=1; $i < 7; $i++) { 
        $key  = substr($word, 0, $i);
        $ence = substr($word, $i-7);
        if (substr($str, 0, $i) === $key && substr($str, $i-7) === $ence) {
            echo "YES"."\n";
            exit;
        }
    }
    echo "NO";
}
echo "\n";

Measured memory_bytes: 4984
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const N = input[0][0];

  return N[0] === N[2] ? "Yes" : "No";
};

console.log(main(read()));


Measured memory_bytes: 29632
package main

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

func main() {
	n := readInt()
	v := make([]float64, n)
	for i := range v {
		v[i] = readFloat64()
	}
	sort.Float64s(v)

	var ans float64
	for i := range v {
		if i == 0 {
			ans = v[i]
		} else {
			ans = (ans + v[i]) / 2
		}
	}

	fmt.Println(ans)
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

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

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

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

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

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

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

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

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 640
def myAnswer(N:int,s:str,t:str) -> int:
   if(s == t): return N
   if(N == 1): return 2
   total = N * 2
   # sとtを比較して重なった文字数をtotalから引く
   for i in range(N):
      if(s[i:] == t[:N-i]):
         total -= len(s[i:])
         break
   return total

def modelAnswer():
   return
def main():
   N = int(input())
   s = input()
   t = input()
   print(myAnswer(N,s,t))
if __name__ == '__main__':
   main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;

void merge_sort (int array[], int left, int right) {
    int i, j, k, mid;
    int work[200010];
    if (left < right) {
        mid = (left + right)/2;
        merge_sort(array, left, mid);
        merge_sort(array, mid+1, right);
        for (i = mid; i >= left; i--) work[i] = array[i];
        for (j = mid+1; j <= right; j++) work[right-(j-(mid+1))] = array[j];
        i = left;
        j = right;
        for (k = left; k <= right; k++) {
            if (work[i] < work[j]) { array[k] = work[i++]; }
            else                   { array[k] = work[j--]; }
        }
    }
}

int main (void) {
    int n, k;
    int h[200010];
    int i;
    ll ans = 0;
    
    cin >> n >> k;
    
    rep(i, n){
        cin >> h[i];
    }
    
    merge_sort(h, 0, n-1);
    
    for(i=0; i<n-k; i++){
        ans += h[i];
    }
    
    cout << ans << endl;
    
    return 0;
}






Measured memory_bytes: 15104
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC120_A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] strs = Console.ReadLine().Split(' ');
            int a = int.Parse(strs[0]);
            int b = int.Parse(strs[1]);
            int c = int.Parse(strs[2]);

            int count = b / a;
            if (count > c) count = c;

            Console.WriteLine("{0}", count);
        }
    }
}


Measured memory_bytes: 13140
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s); sin>>v; return v;}
template<class T> inline string toString(T x){ostringstream sout; sout<<x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i, 0, n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI = acos(-1.0);

bool valid(bool on_left, int arrow, int l_pos, int r_pos)
{
	if (on_left) {
		if ((l_pos-1) % 3 > (arrow-1) % 3) {
			return false;
		}
	} else {
		if ((r_pos-1) % 3 < (arrow-1) % 3) {
			return false;
		}
	}
	return true;
}

int main(){
	bool on_left;
	int arrow, l_pos, r_pos, violation, ans;
	string s;
	while (cin >> s, s != "#") {
		
		// Left foot start
		on_left = false;
		violation = 0;
		l_pos = 4, r_pos = 6;
		FOR(i, 0, s.length()) {
			arrow = s[i] - '0';
			if (valid(on_left, arrow, l_pos, r_pos)) {
				if (on_left) r_pos = arrow;
				else l_pos = arrow;
				on_left = !on_left;
			} else {
				++violation;
				if (on_left) l_pos = arrow;
				else r_pos = arrow;
			}
		}
		ans = violation;

		// Right foot start
		on_left = true;
		violation = 0;
		l_pos = 4, r_pos = 6;
		FOR(i, 0, s.length()) {
			arrow = s[i] - '0';
			if (valid(on_left, arrow, l_pos, r_pos)) {
				if (on_left) r_pos = arrow;
				else l_pos = arrow;
				on_left = !on_left;
			} else {
				++violation;
				if (on_left) l_pos = arrow;
				else r_pos = arrow;
			}
		}

		ans = min(ans, violation);
		cout << ans << endl;
	}
}

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

using namespace std;

int main(){
  //入力
  double n;
  cin >> n;
  vector<pair<double,double>> p(n);
  for(int i=0;i<n;i++){
    double x,y;
    cin >> x >> y;
    p[i].first=x;
    p[i].second=y;
  }
  //(n-1)!を求める
  double s=1;
  for(int i=0;i<n-1;i++){
    s*=i+1;
  }
  //距離の合計を求める
  double d=0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      double a=p[i].first-p[j].first;
      double b=p[i].second-p[j].second;
      double t=sqrt(a*a+b*b);
      d += t*s;
    }
  }
  cout << fixed << setprecision(20);
  cout << 2*d/(s*n) << endl;
}


Measured memory_bytes: 764
#include <stdio.h>
int main() {
    int L,R;
    scanf("%d %d",&L,&R);
    int i,j;
    int smalli, smallj;
    int min=2018;
    if((R-L)>=2018){
        printf("0\n");
    }
    else if(((R%2019)*((R-1)%2019))<2019){
        printf("%d\n",(L%2019)*((L+1)%2019));
    }
    else{
        for(i=L; i<R; i++){
            smalli = i%2019;
            for(j=i+1; j<=R; j++){
                smallj = j%2019;
                if(((smalli*smallj)%2019)<min){
                    min = (smalli*smallj)%2019;
                }
            }
        }
        printf("%d\n",min);
            
    }
    return 0;
}

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

int main() {
	int h, w, n;
	cin >> h >> w >> n;
	int num = 0, count = 0;
	vector<vector<int>> ans(h);
	for (int i = 0; i < h; i++) {
		ans[i].resize(w);
		for (int _j = 0; _j < w; _j++) {
			int j = (i & 1) ? w - _j - 1 : _j;
			if (!count) {
				cin >> count;
				num++;
			}
			ans[i][j] = num;
			count--;
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cout << ans[i][j] << " ";
		}
		cout << endl;
	}
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
const int maxn=2e5;
int a[maxn+5];
int b[maxn+5];
int n,k;
bool f[maxn+5];
set<int> s;
int main()
{
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;++i) scanf("%d",&a[i]);
    for(int i=2;i<=n;++i) if(a[i]>a[i-1]) b[i]=1;
    for(int i=1;i<=n;++i) b[i]+=b[i-1];
    for(int i=k;i<=n;++i) f[i]=true;
    for(int i=k;i<=n;++i)
        if(b[i]-b[i-k+1]==k-1) f[i]=false;
    for(int i=k;i<=n;++i)
        if(b[i]-b[i-k+1]==k-1)
    {
        f[i]=true;
        break;
    }
    f[k]=true;
    for(int i=1;i<=n;++i)
    {
        if(i>k)
        {


            s.erase(a[i-k]);
        //if(i==4) cout<<*s.rbegin()<<" "<<*s.begin()<<endl;
        if(a[i]>*s.rbegin()&&a[i-k]<*s.begin()) f[i]=false;
        }
        s.insert(a[i]);
    }
    int ans=0;
    for(int i=k;i<=n;++i) if(f[i]) ++ans;
    //for(int i=k;i<=n;++i) cout<<i<<" : "<<f[i]<<endl;
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;
using ll = long long int;
constexpr ll M = 1e9 + 7;
inline ll sum_1(const ll n) { return ((n * (n + 1)) / 2) % M; }
inline ll sum_2(const ll n) { return ((n * (n + 1) * (2 * n + 1)) / 6) % M; }
inline ll sum_3(const ll n) { return (((n * (n + 1)) / 2) % M * ((n * (n + 1)) / 2) % M) % M; }
inline ll sum_1(const ll i, const ll j) { return (sum_1(j) - sum_1(i - 1) + M) % M; }
inline ll sum_2(const ll i, const ll j) { return (sum_2(j) - sum_2(i - 1) + M) % M; }
inline ll sum_3(const ll i, const ll j) { return (sum_3(j) - sum_3(i - 1) + M) % M; }

ll pow_f(ll b, ll e) {
    ll ans = 1;
    b = b % M;
    while (e) {
        if (e&1) {
            ans = (ans * b) % M;
        }
        b = (b * b) % M;
        e >>= 1;
    }
    return ans;
}

ll nCr(ll n, ll r) {
    if (r > n || n < 0 || r < 0) { return 0; }
    if (n == r || r == 0) { return 1; }
    r = min(r, n-r);
    ll ans = 1;
    for (ll i = 1; i <= r; ++i) {
        ans = (ans * (n-i+1))/(i); 
    }
    return ans;
}

ll nCr(tuple<ll,ll> t) {
    auto n = get<0>(t);
    auto k = get<1>(t);
    return nCr(n+k-1, k);
}

template<typename T>
void print(T v) {
    cout << v << " ";
}

template<typename T>
void print(vector<T> v) {
    for (auto &i : v) {
        print(i);
    }
    cout << endl;
}

void solve() {
    /**
     * 
     * 2*M + 1 <= N
     */ 

    ll n, m;
    cin >> n >> m;
    //start with biggest m diff
    for (ll i = 0; i < ceil(m/2.); ++i) {
        cout << i+1 << " " << m-i+1 << endl;
    }
    for (ll i = 0; i < m-ceil(m/2.); ++i) {
        cout << i+m+2 << " " << 2*m+1-i << endl;
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifdef D_LOCAL
        freopen("in.in", "r", stdin);
        freopen("out.out", "w", stdout);
    #endif

    solve();

    return 0;
}

Measured memory_bytes: 3656
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    _, b, c = LS()
    x = int(b[0] + c[0]) % 4
    if not x:
        print("YES")
    else:
        print("NO")
    return

#B
def B():
    n = II()
    a = LI()
    a.sort()
    print(a[-1]-a[0])
    return

#C
def C():
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    B()


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

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
// 昇順sort
#define sorti(x) sort(x.begin(), x.end())
// 降順sort
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

typedef pair<int, int> P;

int main() {
  int h,w,d;
  cin >> h >> w >> d;
  map<int, P> mp;
  rep(i,h)rep(j,w) {
    int l; cin >> l;
    mp[l] = make_pair(i+1,j+1);
  }
  ll q;
  cin >> q;

  int cost[h*w+1];
  rep(i,h*w+1) cost[i] = 0;

  // mod
  for (int i = 1; i <= d; ++i) {
    for (int j = i + d; j <= h*w; j += d) {
      P p1,p2;
      int tmp;
      p1 = mp[j-d], p2 = mp[j];
      tmp = abs(p2.first - p1.first) + abs(p2.second - p1.second);
      // cout << tmp << endl;
      cost[j] = cost[j-d] + tmp;
    }
  }


  for (int i = 0; i < q; ++i) {
    ll l,r;
    cin >> l >> r;

    ll ans = cost[r] - cost[l];
    cout << ans << endl;
  }
}


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

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  map<long long, long long> vals;
  int N, M; cin >> N >> M;
  for (int i = 0; i < N; i++) {
    long long v; cin >> v; vals[v] ++;
  }
  for (int i = 0; i < M; i++) {
    long long b, c; cin >> b >> c;
    while (b) {
      if (vals.begin()->first >= c) break;
      long long cur = min(b, vals.begin()->second);
      vals.begin()->second -= cur;
      if (!vals.begin()->second) {
        vals.erase(vals.begin());
      }
      b -= cur;
      vals[c] += cur;
    }
  }
  
  long long ans = 0;
  for (auto it : vals) ans += it.first * it.second;
  cout << ans << '\n';
}

Measured memory_bytes: 6528
#include<iostream>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;

    if((a+b)<=(a+c) && (a+b)<=(b+c))
    cout<<a+b<<endl;

    else if((a+c)<=(a+b) && (a+c)<=(b+c))
        cout<<a+c<<endl;

    else if((b+c)<=(a+b) && (b+c)<=(a+c))
    cout<<b+c<<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++)
typedef long long ll;
typedef pair<int,int> P;
 
int main(){
 string s; cin >> s;
 if (s.at(0) == s.at(1) && s.at(0) == s.at(2) && s.at(0) == s.at(3)) {
   cout << "No" << endl;
   return 0;
 }
 if (s.at(0) == s.at(1)) {
   if (s.at(2) == s.at(3)) {
     cout << "Yes" << endl;
     return 0;
   }
 }
 if (s.at(0) == s.at(2)) {
   if (s.at(1) == s.at(3)) {
     cout << "Yes" << endl;
     return 0;
   }
 }
 if (s.at(0) == s.at(3)) {
   if (s.at(2) == s.at(1)) {
     cout << "Yes" << endl;
     return 0;
   }
 }
 
 cout << "No" << endl;
}


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

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
# }}}

def solve():
    s = input()
    if s == "ABC":
        print("ARC")
    else:
        print("ABC")

    return 0

if __name__ == "__main__":# {{{
    solve()

# vim: set foldmethod=marker: }}}


Measured memory_bytes: 75292
#include <stdio.h>
int n, a;
int h[101];
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", h + i);
	}
	for (int i = 0; i < 100; i++) {
		if (h[i] < h[i + 1]) {
			a += h[i + 1] - h[i];
		}
	}
	printf("%d\n", a);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using  namespace std;
int main(){
    long long n, k, a, b, ans, check=0;
    cin >> n >> k;
    vector<pair<long long, long long>> S(n);
    for(int i=0;i<n;i++){
        cin >> a >> b;
        S[i] = make_pair(a, b);
    }
    sort(S.begin(), S.end());
    for(int i=0;i<n;i++){
        check += S[i].second;
        if(k<=check){
            ans = S[i].first;
            break;
        }
    }
    
    cout << ans << endl;
    return 0;
 
}


Measured memory_bytes: 1792
//#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define pb push_back
#define INF 93193111451418101
#define MIN -93193111451418101
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
//----------program from here----------

ll n,T;
ll t[200020];
ll sum;
ll ov;

int main(){
    cin>>n>>T;

    REP(i,n){
        cin>>t[i];
        sum+=T;
    }
    
    REP(i,n-1){
        ll d;
        d=t[i+1]-t[i]-T;
        if(0>d)sum+=d;
    }
    
    cout<<sum<<endl;




    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1<<30;
const ll MOD = 1000000007;

int main(void) {

    int n; cin >> n;
    n %= 10;
    if (n == 3) cout << "bon" << endl;
    else if (n == 0 || n == 1 || n == 6 || n == 8) cout << "pon" << endl;
    else cout << "hon" << endl;


    return 0;
}

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

int main(){
	int n;
	cin >> n;
	int total1 = 0,total2 = 0;
	string str1,str2;
	for(int i = 0; i < n; i++){
		cin >> str1 >> str2;
		if(str1 > str2){
			total1 += 3;
		}else if(str1 < str2){
			total2 += 3;
		}else{
			total1++;
			total2++;
		}
	}
	cout << total1 << " " << total2 << endl;
	return 0;
}

Measured memory_bytes: 3180
import java.io.*;
import static java.lang.Math.max;
import static java.lang.Integer.parseInt;

class Main {
   final static BufferedReader in =
         new BufferedReader( new InputStreamReader( System.in ) );

   static int lcs(char[] a, char[] b){
      final int alen = a.length;
      final int blen = b.length;
      int dp[][] = new int[alen+1][blen+1];

      for(int i=0; i<alen; ++i){
         for(int j=0; j<blen; ++j){
            if(a[i] == b[j])
               dp[i+1][j+1] = dp[i][j] + 1;
            else
               dp[i+1][j+1] = max( dp[i][j+1], dp[i+1][j] );
         }
      }
      return( dp[alen][blen] );
   }

   public static void main(String[] args) throws IOException {
      final int N = parseInt( in.readLine() );
      final StringBuilder sb = new StringBuilder("");
      for(int i=0; i<N; ++i){
         char[] a = in.readLine().toCharArray();
         char[] b = in.readLine().toCharArray();
         sb.append( lcs(a,b) );
         sb.append('\n');
      }
      System.out.print(sb);
   }
}




Measured memory_bytes: 63532
from collections import *
from heapq import *
from itertools import *
from fractions import gcd
import sys
from decimal import *
import copy
from bisect import *

input = lambda: sys.stdin.readline().rstrip()

N, X, Y = map(int, input().split())
data = [[] for i in range(N + 1)]
for i in range(1, N):
    a = i
    b = i + 1
    data[a].append(b)
    data[b].append(a)
data[X].append(Y)
data[Y].append(X)

dic = defaultdict(int)
for i in range(1,N+1):
    stack=deque([[i,0]])
    visited=set()
    visited.add(i)
    count=set()
    while stack:
        now, dist=stack.popleft()
        for j in data[now]:
            if not j in visited:
                #print(stack)
                visited.add(j)
                stack.append([j,dist+1])
                dic[dist+1]+=1
for k in range(1,N):
    print(dic[k]//2)


Measured memory_bytes: 93876
N = int(input())
A = list(map(int, input().split()))
 
x = A[0]
y = sum(A[1:])
ans = abs(x - y)
for i in range(1, N - 1):
    x += A[i]
    y -= A[i]
    ans = min(ans, abs(x - y))
print(ans)

Measured memory_bytes: 24832
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

conv_winhand = {'r':'p', 's':'r', 'p':'s'}
conv_score = {'r':R, 's':S, 'p':P}
poi = []

ans = 0
for i in range(N):
    if i < K:
        poi.append(conv_winhand[T[i]])
        ans += conv_score[conv_winhand[T[i]]]
    else:
        if conv_winhand[T[i]] == poi[i-K]:
            tmp = T[i]
            if i + K < N and tmp == conv_winhand[T[i+K]]: tmp = conv_winhand[poi[i-K]]
            poi.append(tmp)
        else:
            poi.append(conv_winhand[T[i]])
            ans += conv_score[conv_winhand[T[i]]]
print(ans)

Measured memory_bytes: 4212
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
int main() {
	string s;
	cin >> s;
	if (s[s.length() - 1] == 's')cout << s << "es" << endl;
	else cout << s << "s" << endl;

	return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[3] = {1,0,-1};
int dy[3] = {1,0,-1};
const int MOD = 1000000007;

bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  int H,W;
  char masu[101][101];
  cin >> H >> W;
  REP(i,H)cin >> masu[i];
  REP(i,W+2){
    cout << '#';
  }
  cout << endl;
  REP(i,H){
  cout << "#";
  cout << masu[i];
  cout << "#" << endl;
  }
  
  REP(i,W+2){
    cout << '#';
  }
  cout << endl;
  
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}

ll bpow(ll a, ll n,ll mod){
  int i = 0;
  ll res=1;
  while(n){
    if(n & 1)
      res = (res*a) % mod;
    a = (a*a) % mod;
    n >>= 1;
  }
  return res;
}
mat mul(mat &A, mat &B){
  mat C(A.size(),vec(B[0].size()));
    REP(i,A.size())REP(k,B.size())REP(j,B[0].size()){
    C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD;
  }
  return C;
}

mat pow(mat A,ll n)
{
  mat B(A.size(),vec(A.size()));
  REP(i,A.size()){
    B[i][i] = 1;
  }
  while(n > 0){
    if ( n & 1) B = mul(B,A);
    A = mul(A,A);
    n >>= 1;
  }
  return B;
}


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

using namespace std;


void solve() {
    int n,m,d;
    cin >> n >> m >> d;
    vector<pair<int, int>> a(n*m);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            int x; cin >> x; x--;
            a[x] = {i,j};
        }
    }
    vector<vector<int>> sum(d);
    for (int k = 0; k < d; k++) {
        sum[k].emplace_back(0);
        int crt = k;
        while (crt+d < n*m) {
            int cost = abs(a[crt+d].first-a[crt].first) + abs(a[crt+d].second-a[crt].second);
            sum[k].emplace_back(sum[k].back() + cost);
            crt += d;
        }
    }
    int q; cin >> q;
    while (q--) {
        int l, r;
        cin >> l >> r;
        l--; r--;
        int k = l%d;
        l/=d; r/=d;
        int res = sum[k][r] - sum[k][l];
        cout << res << "\n";
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 6144
N = int(input())
A = [0]*(1000001)
for a in list(map(int, input().split())):
    A[a] += 1

# MFPF = Most Frequent Prime Factor
MFPF_n = 0
seen_prime_factor = [0]*(1000001)
for i in range(2, 1000001):
    if seen_prime_factor[i]:
        continue
    n = i
    tmp = 0
    while n < 1000001:
        tmp += A[n]
        seen_prime_factor[n] = 1
        n += i
    MFPF_n = max(MFPF_n, tmp)

if MFPF_n < 2:
    print('pairwise coprime')
elif MFPF_n - A[1] < N:
    print('setwise coprime')
else:
    print('not coprime')

Measured memory_bytes: 202544
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		int H = sc.nextInt(), W = sc.nextInt();
		int grid[][] = new int[H+2][W+2];
		
		for(int i = 1; i<=H; i++) {
			String s = sc.next();
			for(int j = 1; j<=W; j++) {
				if(s.charAt(j-1) == '#') grid[i][j] = -1;
			}
		}
		
		for(int i = 1; i<=H; i++) {
			for(int j = 1; j<=W; j++) {
				if(grid[i][j] == -1) continue;
				
				int count = 0;
				if(grid[i-1][j-1] == -1) count++;
				if(grid[i-1][j] == -1) count++;
				if(grid[i-1][j+1] == -1) count++;
				if(grid[i][j+1] == -1) count++;
				if(grid[i+1][j+1] == -1) count++;
				if(grid[i+1][j] == -1) count++;
				if(grid[i+1][j-1] == -1) count++;
				if(grid[i][j-1] == -1) count++;
				
				grid[i][j] = count;

			}
		}
		
		for(int i = 1; i<=H; i++) {
			for(int j = 1; j<=W; j++) {
				if(grid[i][j] == -1) System.out.print('#');
				else System.out.print(grid[i][j]);
			}
			System.out.println();
		}
	}

}


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

#include <bits/stdc++.h>
using namespace std;

class UnionFind {
public:
    vector<int> parents;

    UnionFind(int N) : parents(N, -1) {}

    int find(int x) {
        if (this->parents[x] < 0)
            return x;
        return this->parents[x] = this->find(this->parents[x]);
    }

    int size(int x) {
        return -this->parents[this->find(x)];
    }

    void marge(int x, int y){
        x = this->find(x);
        y = this->find(y);
        if (x == y)
            return;
        if (this->parents[x] > this->parents[y])
            swap(this->parents[x], this->parents[y]);
        this->parents[x] += this->parents[y];
        this->parents[y] = x;
    }

    bool is_same(int x, int y) {
        return this->find(x) == this->find(y);
    }
};

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

    UnionFind uf(N);
    for(int ii=0; ii<M; ii++){
        int x, y, z;
        cin >> x >> y >> z;
        uf.marge(x-1, y-1);
    }
    int ans = 0;
    for(int ii=0; ii<N; ii++){
        if(uf.parents[ii] < 0) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
from itertools import product

n,m,x = map(int, input().split())

al = []
cl = []
for _ in range(n):
    row = list(map(int, input().split())) 
    cl.append(row[0])
    al.append(row[1:])


ans = 10**9
bit = 2
ite = list(product(range(bit),repeat=n))
for pattern in ite:
    skills = [0]*m
    cost = 0
    for i, v in enumerate(pattern):
        if v == 1:
            curr_al = al[i]
            cost += cl[i]
            for j, a in enumerate(curr_al):
                skills[j] += a
    if min(skills) >= x:
        ans = min(ans,cost)

if ans == 10**9: ans = -1
print(ans)

Measured memory_bytes: 74468
function gets(str){
  this._s = str.split("\n");
  this._y = 0;
};
gets.prototype = {
  a: function(f){
    var s = this._s, y = this._y, r;
    if(typeof s[y] === "string")s[y] = s[y].split(" ").reverse();
    r = s[y].pop();
    if(!s[y].length)this._y++;
    return f?r:+r;
  },
  l: function(f){
    var s = this._s[this._y++].split(" ");
    return f?s:s.map(a=>+a);
  },
  m: function(n,f){
    var s = this._s, y = this._y, r = [], i = 0;
    if(f)for(;i < n; i++)r[i] = s[y+i].split(" ");
    else for(;i < n; i++)r[i] = s[y+i].split(" ").map(a=>+a);
    this._y += n;
    return r;
  },
};
var o=new gets(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var n = o.a();
  var k = o.a();
  if(k % 2 === 1)return Math.pow(Math.floor(n/k),3);
  return Math.pow(Math.floor((2*n+k)/2/k),3)+Math.pow(Math.floor(n/k),3);
}

Measured memory_bytes: 21192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
  int x; cin>>x;
  int ans;
  for(int i=1; i<=100100100; i++){
    if(360*i%x==0){
      ans=360*i/x;
      break;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
#include <numeric>

typedef long long int llint;

int main(void){

  int a, b, c, d;
  std::cin >> a >> b >> c >> d;

  while(a>0 && c>0){
    c-=b;
    a-=d;
  }

  std::cout << (c<=0?"Yes":"No") << std::endl;
  
  return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<string>
using namespace std;
int main(){
	int n,m,l;
	int i,j,k;
	int a[100][100]={0};
	int b[100][100]={0};
	long c[100][100]={0};
	
	cin>>n>>m>>l;
	
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			cin>>a[i][j];
		}
	}
	for(i=0;i<m;i++){
		for(j=0;j<l;j++){
			cin>>b[i][j];
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<l;j++){
			for(k=0;k<m;k++){
				c[i][j]+=a[i][k]*b[k][j];
			}
		cout<<c[i][j];
		if(j<(l-1))
			cout<<" "; 
		}
		cout<<endl;
	}
}

Measured memory_bytes: 1324
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const int mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 2020; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j]);
//       }
//     }
//   }
//   return 0;
// }


int factorial(int n){
  if(n == 0) return 1;
  return n*factorial(n-1);
}

int divisor(int a){
  int cnt = 0;
  for(int i=1; i <= a; i++) if(a%i == 0) cnt++;
  return cnt;
}

int comb(int n, int k){
  return factorial(n) / (factorial(n-k)*factorial(k));
}

int answer(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}






int main(){
  int a[3];
  int d;
  cin >> a[0] >> a[1] >> a[2] >> d;
  bool f = false;
  if(abs(a[2] - a[0]) <= d) f = true;
  if(max(abs(a[2]-a[1]),abs(a[1]-a[0])) <= d) f = true;
  answer(f);
  
  

  
  return 0;
}









Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

int n;
int c[500], s[500], f[500];

void solve()
{
  for (int i = 0; i < n; i++) {
    int t = 0;
    for (int k = i; k < n - 1; k++) {
      if (t < s[k]) {
        t = s[k];
      } else if (t % f[k] != 0) {
        t += f[k] - (t % f[k]);
      }
      t += c[k];
    }
    cout << t << endl;
  }
}

int main()
{
  cin >> n;
  REP(i, n) cin >> c[i] >> s[i] >> f[i];
  solve();
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    vi yui(3);
    rep(i, 3) cin >> yui[i];
    int n = 0;
    rep(i, 3) n += yui[i];

    vvi data(n, vi(3));
    rep(i, n) {
        rep(j, 3) {
            cin >> data[i][j];
        }
    }

    sort(all(data), [&](vi &x, vi &y){return x[1] - x[0] < y[1] - y[0];});

    /*
    rep(i, n) {
        rep(j, data[i].size()) {
            cout << data[i][j] << " ";
        }
        cout << " : " << data[i][1] - data[i][0] << endl;
    }
    */

    vi ans(n+1, -INF);
    {
        priority_queue<int> pq;
        ans[yui[0]] = 0;
        rep(i, yui[0]) {
            pq.push(data[i][2] - data[i][0]);
            ans[yui[0]] += data[i][0];

        }
        for (int i = yui[0]+1; i < n-yui[1]+1; i++) {
            ans[i] = ans[i-1];
            ans[i] += data[i-1][0];
            pq.push(data[i-1][2] - data[i-1][0]);
            ans[i] += pq.top();
            pq.pop();
        }
    }
/*
    rep(i, n) 
        std::cout << ans[i] << " ";
    std::cout << std::endl;
*/
    reverse(all(data));

    int ret = -INF, tmp = 0;
    priority_queue<int> pq;
    rep(i, yui[1]) {
        pq.push(data[i][2] - data[i][1]);
        tmp += data[i][1];
    }
    ret = max(ret, tmp + ans[n-yui[1]]);
    for (int i = yui[1]+1; i < n-yui[0]+1; i++) {
        tmp += data[i-1][1];
        pq.push(data[i-1][2] - data[i-1][1]);
        tmp += pq.top();
        pq.pop();
        ret = max(ret, tmp + ans[n-i]);
    }
    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 7672
n = int(input())
s = [int(input()) for i in range(n)]
s.sort()
x = 0
y = 0

if sum(s)%10 != 0:
    print(sum(s))

else:
    while y == 0:
        if s[x]%10 != 0:
            s.pop(x)
            y = 1
            break
        else:
            x += 1
        
        if x >= len(s)-1:
            print(0)
            exit()

    print(sum(s))

Measured memory_bytes: 38384