akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 #define int long long

#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define fi first
#define se second


using namespace __gnu_pbds;
using namespace std;
const int mod=1e9+7;
 // const int mod=998244353;
 // const int mod=1e9+9;
const int INF=4e18+10;
// const int INF=4e18+10;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define read(n) int n; cin>>n;
#define readv(x, n) vector<int> x(n); for(auto &i:x) cin>>i;


typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

template<typename T1,typename T2>
void set_min(T1& a, T2 b)
{
    a=min(a, (T1)b);
}


int multiply(int a, int b, int in_mod){return (a*b)%in_mod;}
int mult_identity(int a){return 1;}


auto power(auto a, int b, int in_mod)
{
    auto prod=mult_identity(a);
    auto mult=a%in_mod;
    while(b!=0)
    {
        if(b%2)
        {
            prod=multiply(prod,mult, in_mod);

        }
        mult=multiply(mult, mult,in_mod);
        b/=2;
    }
    return prod;
}
int mod_inv(int q, int in_mod)
{

    return power(q, in_mod-2,in_mod);
}


void solve()
{
    for(int i=1;i<=5;i++)
    {
        int x;
        cin>>x;
        if(x==0)
        {
            cout<<i<<endl;
            return;
        }
    }
    assert(false);

}

signed main()

{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen("INPUT.txt", "r", stdin);
        freopen("OUTPUT.txt", "w", stdout);
    }
#endif
    auto clk = clock();
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // -------------------------------------Code starts here---------------------------------------------------------------------

    int t = 1;
    // cin>>t;

    for (int test = 1; test <= t; test++)
    {
        // cout<<"Case #"<<test<<": ";
        // cout<<endl;
        solve();
        // cout<<endl;
    }

    // -------------------------------------Code ends here------------------------------------------------------------------

    clk = clock() - clk;
    // cerr << fixed << setprecision(6) << "Time: " << ((long double)clk) / CLOCKS_PER_SEC << "\n";
    return 0;
}


Measured memory_bytes: 3652
#include<stdio.h>

int main(int argc,char *args[]){
  int N;
  scanf("%d",&N);  
  int A[N]; 
  double sum = 0;
  for(int i = 0;i < N;i++){
    scanf("%d",&A[i]);
    sum += 1 / (double)A[i];    
  }
  printf("%f",1 / sum);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    bool a[1000];
    memset(a, false, sizeof(a));
    for(int i = 1; i < 10; i++) {
        for(int j = 1; j < 10; j++) {
            a[i*j] = true;
        }
    }
    ll n;
    cin >> n;
    if(a[n]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
h,w,k=map(int,input().split())
moto=0
l=[]
for i in range(h):
  ll=input()
  l.append(ll)
  moto+=ll.count('#')
sa=moto-k

ans=0
import itertools
for p in itertools.product([0,1],repeat=h):
  for q in itertools.product([0,1],repeat=w):
    cnt=0
    for hh in range(h):
      if p[hh]==1:
        cnt+=l[hh].count('#')
    for ww in range(w):
      if q[ww]==1:
        for ll in l:
          if ll[ww]=='#':
            cnt+=1
    for hh in range(h):
      for ww in range(w):
        if p[hh]==q[ww]==1 and l[hh][ww]=='#':
          cnt-=1
    if cnt==sa:
      ans+=1
print(ans)

Measured memory_bytes: 9244
import java.util.Scanner;

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

	while(sc.hasNext()){
	    int n = sc.nextInt(), mx, mn;
	    if(n == 0) break;
	    mx = mn = -1;

	    for(int j = 0; j < n; j++){
		int tmp = 0;
		for(int i = 0; i < 5; i++)
		    tmp += sc.nextInt();
		if(mx == -1 || mx < tmp) mx = tmp;
		if(mn == -1 || mn > tmp) mn = tmp;
	    }

	    System.out.println(String.valueOf(mx) + " " + String.valueOf(mn));
	}
    }

    public static void main(String[] args){
	new Main();
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz size()
#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define mod 1000000007
#define forn(i, n) for (int i = 0; i < (int) (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a,b,c;
    cin >> a >> b >> c;
    if((a+b==c)||(a+c==b)||(b+c==a)){
        cout << "Yes";
        return 0;
    }
    cout << "No";
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long 
#define M 1000000007
#define P pair<int,int>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) FOR(i,0,n)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

string s;
int a[27];


int main(){
  cin>>s;
  if(s=="zyxwvutsrqponmlkjihgfedcba"){
    cout<<-1<<endl;
    return 0;
  }

  rep(i,s.size()){
    a[s[i]-'a']++;
  }

  if(s.size()!=26){
    cout<<s;
    rep(i,27){
      if(!a[i]){
        cout<<(char)(i+'a')<<endl;
        break;
      }
    }
  }
  else{
    string x=s;

    next_permutation(x.begin(),x.end());

    rep(i,s.size()){
      cout<<x[i];
      if(x[i]!=s[i]) break;
    }
    cout<<endl;
  }

  return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int N,a;
    int count=0;
    cin >> N;
    
    for (int i = 0; i < N; i++) {
        cin >> a;
        if( (i + 1) % 2 == 1 && a % 2 ==1){
            count++;
        }
    }
    cout << count << endl;
    
   return 0;
}	

Measured memory_bytes: 3156
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <map>
#include <queue>
#include <string>
using namespace std;

int n,f[15][15];

int main(){
	while(cin>>n){
		if(n==0)return 0;
		for(int i=0;i<15;i++)for(int j=0;j<15;j++)f[i][j]=0;
		int x=n/2,y=n/2+1;
		f[y][x]=1;
		for(int i=2;i<=n*n;i++){
			x++;y++;x%=n;y%=n;
			if(f[y][x]!=0){x--;y++;x=(x+n)%n;y%=n;}
			f[y][x]=i;
		}
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				cout<<" ";
				if(f[i][j]<100)cout<<" ";
				if(f[i][j]<10)cout<<" ";
				cout<<f[i][j];
			}
			cout<<endl;
		}
	}
}

Measured memory_bytes: 0
N, M = gets.chomp.split(" ").map(&:to_i)
V = Hash.new{|h, k| h[k] = Array.new}
M.times{|i|
  a, b = gets.chomp.split(" ").map(&:to_i)
  V[a] << b
}

def dfs
  lst = T[-1]
  V[lst].each{|v|
    if T.include?(v) then
      wk = T.index(v)
      (wk...T.size).each{|i| A << T[i]}
      A.all?{|a| V[a].select{|v| A.include?(v)}.size == 1} ? break : A.clear
    end
    next if C[v]
    T << v
    C[v] = true
    dfs
    T.pop
    break if not A.empty?
  }
end

T = []
A = []
C = Array.new(N + 1, false)
(1..N).each{|n|
  next if C[n]
  C[n] = true
  T << n
  dfs
  T.pop
  break if not A.empty?
}

if A.empty? then
  puts -1
else
  puts A.size
  puts A.join("\n")
end


Measured memory_bytes: 6012
#include <iostream>

using namespace std;

int main(){
	long long i,j,k,n,a,b;
	cin >> n >> a >> b;
	if(a+b>n+1 || a*b<n){
		cout << -1 << endl;
	}else if(a==1){
		for(i=n;i>0;i--){
			cout << i << " ";
			}
	}else if(b==1){
		for(i=1;i<=n;i++){
			cout << i << " ";
		}
	}else{
		for(i=a;i>0;i--){
			cout << n+1-i << " ";
		}
		int m = (n-a)/(b-1);
		if((n-a)%(b-1)==0){
			for(j=1;j<=b-1;j++){
				for(k=0;k<m;k++){
					cout << n+1-a+k-j*m<< " ";
				}
			}
		}else{
			m++;
			int l = (n-a)%(b-1);
			for(j=1;j<=l;j++){
				for(k=0;k<m;k++){
					cout << n+1-a+k-j*m << " ";
				}
			}
			m--;
			for(j=1;j<=b-1-l;j++){
				for(k=0;k<m;k++){
					cout << n+1-a-l*(m+1)+k-j*m <<" ";
				}
			}
		}
	}
}
			

Measured memory_bytes: 2176
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;

#define int long long
#define endl "\n"
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}

int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}


signed main() {
	int a,b=0,c=0,n;
	cin >> n;
	rep(i, n) {
		cin >> a;
		if (a >= b) {
			b = a;
			c++;
		}
	}
	cout << c << endl;
}





Measured memory_bytes: 256
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Collections;
import java.util.StringTokenizer;

public class Main {

	public static void solve() {
		int n=s.nextInt();
		int m=s.nextInt();
		int v=s.nextInt();
		int p=s.nextInt();
		Integer[] arr = new Integer[n];
		for(int i=0;i<n;i++) {
			arr[i]=s.nextInt();
		}
		Arrays.sort(arr,Collections.reverseOrder());
		long[] prefix_sum = new long[n];
		for(int i=0;i<n;i++) {
			prefix_sum[i]=arr[i];
			if(i!=0) {
				prefix_sum[i]+=prefix_sum[i-1];
			}
		}
//		int[] defeat = new int[n];
//		boolean[] helper = new boolean[n];
//		int pos = p<=v?0:p-v-1;
//		for(int i=0;i<n;i++) {
//			defeat[i]=bs(arr,arr[i]+m);
//			if(defeat[i]<=pos) {
//				helper[i]=true;
//			}
//		}
		int ans= p;
		for(int i=p;i<n;i++) {
			int before = i- p +1;
			before = n- before;
			if(before>=v) {
				int current = m + arr[i];
				if(current>=arr[p-1]) {
					ans++;
				}
			}else {
//				if(p-2<0)continue;
				int current = m + arr[i];
				if(current<arr[p-1]) {
					break;
				}
				long sum = prefix_sum[i-1]-(p-2>=0?prefix_sum[p-2]:0);
				long remaining = v-before;
				long temp = (long)(m+arr[i])*(long)(i-p+1)-sum;
				if(temp >= remaining* (long)m) {
					ans++;
				}
			}
		}
		out.println(ans);
	}

	public static int bs(Integer[] arr,int val) {
		int start = 0;
		int end = arr.length-1;
		int ans = arr.length-1;
		while(start<=end) {
			int mid  = (start+end)>>1;
			if(arr[mid]<=val) {
				ans = mid;
				end = mid-1;
			}else {
				start=mid+1;
			}
		}
		return ans;
	}
	
	public static void main(String[] args) {
		out = new PrintWriter(new BufferedOutputStream(System.out));
		s = new FastReader();
		solve();
		out.close();
	}

	public static FastReader s;
	public static PrintWriter out;

	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;

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

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

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

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

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

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

	
}


Measured memory_bytes: 45468
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	vector<int> v;
	cin>>n;
	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		v.push_back(a);
	}
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	int odd=0,even=0;
	for(int i=0;i<v.size();i+=2){
		odd+=v[i];
	}
	for(int i=1;i<v.size();i+=2){
		even+=v[i];
	}
	//cout<<odd<<even<<endl;
	int ans=abs(odd-even);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
import bisect
import itertools


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, m, v, p = list(map(int, readline().split()))
    a = list(map(int, readline().split()))
    a.sort()
    acm = list(itertools.accumulate(a))
    target = bisect.bisect_right(a, a[-p]) - 1
    for i in range(n - 1):
        bl = bisect.bisect_left(a, a[i])
        br = bisect.bisect_right(a, a[i])
        if br < n:
            dif = acm[target] - acm[br-1] - a[i] * (target - br + 1)
            #print(a[i], target, br, dif, a, acm)
            if dif <= min((n - v), (target - br) + 1) * m and a[target] - a[i] <= m:
                print(n - i)
                exit()
    print(n - bisect.bisect_left(a, a[target]))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 56816
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,k,sum,a[505];
bool chk(ll x){
    vector<ll> v;
    for(ll i=1;i<=n;i++)v.push_back(a[i]%x);
    sort(v.begin(),v.end());
    ll rem=0,reqd=0,l=0,r=v.size()-1;
    while(l<=r){
        if(rem<=0){
            rem+=v[l];
            reqd+=v[l];
            l++;
        }
        else{
            rem-=(x-v[r]);
            reqd+=(x-v[r]);
            r--;
        }
    }
    if(reqd>2*k || rem!=0)return 0;
    return 1;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>k;
    for(ll i=1;i<=n;i++)cin>>a[i],sum+=a[i];
    ll ans=1;
    for(ll i=1;i*i<=sum;i++){
        if(sum%i)continue;
        if(chk(i))ans=max(ans,i);
        if(chk(sum/i))ans=max(ans,sum/i);
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
struct stone{
    int color=0;
    int to_add=0;
};
int main(){
    int N;
    int mod=1e9+7;
    cin>>N;
    stone stones[200000];
    int out=1;
    int temp,last;
    int colors[N];
    for(int i=0;i<N;i++){
        cin>>colors[i];
    }
    for(int i=0;i<N;i++){
        temp=colors[i];
        if(i&&temp==last)
            continue;
        else
            last=temp;
        bool in=false;
        if(stones[temp].to_add)/*有记录*/{
            out+=stones[temp].to_add;
            out=out%mod;
            stones[temp].to_add=out;
            in = true;
        }
        else{
            stones[temp].color=temp;
            stones[temp].to_add=out;
        }//新颜色
    }
    cout<<out<<endl;
    return 0;
}

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

int main()
{
    ll c, s;
    cin >> s >> c;

    c /= 2;

    if (s >= c) cout << c;
    else {
        c = c - s;
        c /= 2;
        cout << s + c;
    }
}


Measured memory_bytes: 256
#pragma GCC optimize ("-O3","unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<cmath>
#include<cstdio>
#include<algorithm>
#include<bitset>
#include<complex>
#include<deque>
#include<fstream>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<typeinfo>
#include<typeindex>
#include<type_traits>
#include<utility>
#include<valarray>
#include<vector>
#include<array>
#include<forward_list>
#include<random>
#include<ratio>
#include<tuple>
#include<unordered_map>
#include<unordered_set>
#include<cstring>

using namespace std;
using Int = long long;
typedef pair<int,int> Pi; typedef pair<Int,Int> Pl;
const int mod = 1e9+7;
const Int Inf = 1e17;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define mp make_pair
#define Pr(t) priority_queue<t>
#define gPr(t) priority_queue<t,vector<t>,greater<t>>
#define V(t) vector<t>
#define rep1(i,n) for(int(i)=0; i<n; i++)
#define rep(i,n) for(unsigned int(i)=0; i!=n; ++i)
#define rer(i,l,r) for(int i=l; i<=r; i++)
#define gnr(i,l,r) for(int i=r; i>=l; i--)
#define eb emplace_back
#define pri1(a) cout<<(a)<<'\n'
#define pri2(a,n) {rep(pri2i,n-1)cout<<a[pri2i]<<' '; cout<<a[n-1]<<'\n';}
#define prip(p) cout<<p.fi<<' '<<p.se<<'\n'
#define var(type) valarray<type>
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long double PI = acos(-1.0);
long double n,m,_,x,y,q;
string s,sb;
bool ok;
char cf,cb;

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

  cout<<fixed<<setprecision(20);
  cin>>n>>m>>x; y=atan((2.0*x)/(m*m*n))*180.0/PI;
  q=atan((n*n*n)/(2.0*(m*n*n-x)))*180.0/PI;
  if(x<=n*n*m/2.0)pri1(90-y);
  else pri1(90-q);
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
bool isPrime(int n){
    if(n < 2) return false;
    else if(n == 2 || n == 3) return true;
    if(n % 2 == 0) return false;
    int limit = (int)sqrt((double)n) + 1;
    for(int i = 3; i <= limit; i += 2){
        if(n % i == 0) return false;
    }
    return true;
}
int main(){
    int n;
    cin >> n;
    int count = 0;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        if(isPrime(x)) count++;
    }
    cout << count << endl;
}



Measured memory_bytes: 3084
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	ll N, M, X; cin >> N >> M >> X;
	vector<ll> v(15);
	vector<vector<ll> > vv(15, vector<ll>(15));
	vector<ll> C(15);
	rep(i, N){
		cin >> C[i];
		rep(j, M){
			cin >> vv[i][j];
		}
	}

	ll ans = LLINF;
	rep(bit, 1 << N){
		vector<ll> tmp(15);
		ll res = 0;
		rep(j, N){
			if(bit >> j & 1){
				res += C[j];
				rep(k, M){
					tmp[k] += vv[j][k];
				}
			}
		}
		bool ok = true;
		rep(k, M){
			if(tmp[k] < X) ok = false;
		}
		if(!ok) continue;
		chmin(ans, res);
	}

	if(ans == LLINF){
		cout << -1 << endl;
	}
	else{
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3640
//author: dxm
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring> 
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
inline void Fail(){
	printf("0");
	exit(0);
}

const int maxn=11;
int n,ans;
int a[maxn],b[maxn];

void go(int k){
	if(k==n){
		int cur=1;
		rep(i,n)cur=cur*b[i]%2;
		if(!cur)ans++;
		return;
	}
	for(int i=-1;i<=1;i++)
	b[k]=a[k]+i,go(k+1);
}

int main(){
	scanf("%d",&n);
	rep(i,n)scanf("%d",&a[i]);
	go(0);
	printf("%d",ans);
	return 0;
}

/*
Input:
-----------------
Output:
*/

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

int main() {
    int n,w;cin>>n>>w;
    vector<ll> dp(w+1,0);
    for(int i=0;i<n;i++){
        int weight,value;
        cin>>weight>>value;
        for(int j=w-weight;j>=0;j--){
            dp[j+weight]=max(dp[j+weight],dp[j]+value);
        }
    }
    ll mx=0;
    for(int i=0;i<=w;i++)mx=max(mx,dp[i]);
    cout<<mx<<"\n";

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
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 ll mod = 1e9 + 7;
const ll inf = 1e18;

// 多倍長テンプレ
/* ---------------------- ここから ---------------------- */
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
/* ---------------------- ここまで ---------------------- */

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

    ll n, ub = 1e18;
    cin >> n;
    vector<Bint> a(n);
    REP(i, n) {
        cin >> a[i];
        if (a[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    Bint res = 1;
    REP(i, n) {
        res *= a[i];
        if (res > ub) {
            cout << - 1 << endl;
            return 0;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 6432
MOD = 10 ** 9 + 7

S = input()
N = len(S)

dp = [[0] * 13 for _ in range(N + 1)]
dp[0][0] = 1

mul = 1

for i, x in enumerate(S[::-1]):
  if x == "?":
    for k in range(10):
      for j in range(13):
        jj = (mul * k + j) % 13
        dp[i + 1][jj] += dp[i][j]
        dp[i + 1][jj] %= MOD
  else:
    k = int(x)
    for j in range(13):
      jj = (mul * k + j) % 13
      dp[i + 1][jj] += dp[i][j]
      dp[i + 1][jj] %= MOD

  mul = (mul * 10) % 13

print(dp[N][5])


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

#define x first
#define y second
#define y1 Y1
#define y2 Y2
#define mp make_pair
#define pb push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> pii;

template <typename T> inline int Chkmax (T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline int Chkmin (T &a, T b) { return a > b ? a = b, 1 : 0; }

inline void proc_status()
{
	ifstream t ("/proc/self/status");
	cerr << string (istreambuf_iterator <char> (t), istreambuf_iterator <char> ()) <<endl;
}

template <typename T> T read ()
{
	T sum = 0, fl = 1; char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fl = -1;
	for (; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - '0';
	return sum * fl;
}

const int Maxn = 3000 + 100;

int N, M, Dp[Maxn][Maxn];
char S[Maxn], T[Maxn];

stack <char> Stack;

inline void Solve ()
{
	for (int i = 1; i <= N; ++i)
		for (int j = 1; j <= M; ++j)
		{
			Dp[i][j] = max(Dp[i - 1][j], Dp[i][j - 1]);
			if (S[i] == T[j]) Chkmax(Dp[i][j], Dp[i - 1][j - 1] + 1);
		}
	int tmp = Dp[N][M];
	for (int i = N; i >= 1; --i)
		for (int j = M; j >= 1; --j)
		{
			if (S[i] == T[j] && Dp[i][j] == tmp)
			{
				--tmp, Stack.push(S[i]);
				break;
			}
		}
	while (!Stack.empty()) printf("%c", Stack.top()), Stack.pop();
}

inline void Input ()
{
	scanf("%s", S + 1); scanf("%s", T + 1);
	N = strlen(S + 1), M = strlen(T + 1);
}

int main()
{
#ifdef hk_cnyali
	freopen("F.in", "r", stdin);
	freopen("F.out", "w", stdout);
#endif
	Input();
	Solve();
	return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

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

    t += t;
    cout << ((t.find(s) != -1) ? "Yes" : "No") << endl;
    return (0);
}


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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int n; cin >> n;
    vector<P> c(n);
    vector<int> v(n);
    rep(i,n){
        int x, y; cin >> x >> y;
        c[i] = make_pair(x, y);
        v[i] = i;
    }

    double ans = 0;
    int cnt = 0;
    do{ 
        double sum = 0;
        rep(i,n-1){
            int x1 = c[v[i]].first, y1 = c[v[i]].second;
            int x2 = c[v[i+1]].first, y2 = c[v[i+1]].second;
            sum += sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
        }
        ans += sum;
        cnt++;
    }while(next_permutation(v.begin(), v.end()));

    printf("%.6f\n", ans/cnt);
}

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

using namespace std;

#define int 		long long
#define endl		"\n"
#define mod			1000000007
#define inf			1e12
#define IOS			ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)


int32_t main() {

	IOS;

	int n, k, x;
	cin >> n >> k;

	vector<int> dp(k + 1), a(n);

	for (int i = 0; i < n; i++) {
		cin >> a[i];
		dp[a[i]] = 1;
	}

	for (int i = 0; i <= k; i++) {
		if (dp[i])
			continue;
		for (int j = 0; j < n; j++) {
			if (i + a[j] <= k)
				dp[i + a[j]] = 1;
		}
	}

	if (dp[k])
		cout << "First\n";
	else
		cout << "Second\n";

	return 0;
}

Measured memory_bytes: 3988
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

class Myon{
    static void Main(string[] args){
        var myon = new Myon();
    }

    public Myon(){
        long N = long.Parse(Console.ReadLine());
        long[] size = new long[5];
        for(int i = 0;i < 5;i ++){
            size[i] = long.Parse(Console.ReadLine());
        }

        long A = 0;
        if(N%size[0] != 0)A = N/size[0] + 1;
        else A = N/size[0];
      
      	//Console.WriteLine(A);

        long B = 0;
        if(size[1] >= size[0])B+= A + 1;
        else if(N%size[1] != 0)B += N/size[1] + 1 + 1;
        else B += N/size[1] + 1;
        if(B <= A)B = A + 1;

      //Console.WriteLine(B);
      
        long C = 0;
        if(size[2] >= size[1])C+= B + 1;
        else if(N%size[2] != 0)C += N/size[2] + 1 + 2;
        else C += N/size[2] + 2;
        if(C<=B)C = B + 1;

        //Console.WriteLine(C);
      
        long D = 0;
        if(size[3] >= size[2])D+= C + 1;
        else if(N%size[3] != 0)D += N/size[3] + 1 + 3;
        else D += N/size[3] + 3;
        if(D <= C)D = C + 1;
      
        //Console.WriteLine(D);
      
        long E = 0;
        if(size[4] >= size[3])E+= D + 1;
        else if(N%size[4] != 0)E += N/size[4] + 1 + 4;
        else E += N/size[4] + 4;
        if(E <= D)E = D + 1;

        Console.WriteLine(E);
    }
}

Measured memory_bytes: 13140
N=int(input())
flag=0
for w in range(1,3501):
  if flag==1:
    break
  for n in range(1,3501):
    if 4*w*n-N*n-N*w<=0:
      continue
    if N*w*n%(4*w*n-N*n-N*w)==0:
      print(N*w*n//(4*w*n-N*n-N*w),w,n)
      flag=1
      break


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <iomanip>
#include <limits>
#include <utility>
#include <bitset>
#include <sstream>
#define ll long long
#define lint long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
#define INF 1e9

#define mod 1000000007
int i;
int main()
{
    int N,M;
    cin>>N>>M;
    vector<int> a(M);
    rep(i,M)cin>>a[i];

    // dp?

    int d[N+5];
    int k[N+5];

    for (i=0; i<=N;i++){
        d[i] = 0;
        k[i] = 1;
    }
    rep(i,M)k[a[i]-1] = 0;

    d[0] = 1;
    for (i=0; i<=N;i++){
        if (k[i]){
            d[i+1] += d[i] ;
            d[i+1] %= mod;
        }
        if (k[i+1]){
            d[i+2] += d[i] ;
            d[i+2] %= mod;
        }
    }
    
    //rep(i,N)cout<<d[i] <<"::";
    //cout<<endl;

    cout << d[N] << endl;


    return 0;
}

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

int main(){
  ll K;
  cin>>K;
  ll mod=0;
  ll i=1;
  if(K%2==0)cout<<-1<<endl;
  else if(K%5==0)cout<<-1<<endl;
  else{
    while(true){
      mod=((mod*10)+7)%K;
      if(mod==0){
        cout<<i<<endl;
        break;
      }
      i++;
    }
  }
}

Measured memory_bytes: 3624
import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;
public class Main {
	static String a;
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext()) {
			String[] tmp = stdIn.nextLine().split(",");
			double x1 = Double.parseDouble(tmp[0]);
			double y1 = Double.parseDouble(tmp[1]);
			double x2 = Double.parseDouble(tmp[2]);
			double y2 = Double.parseDouble(tmp[3]);
			double x3 = Double.parseDouble(tmp[4]);
			double y3 = Double.parseDouble(tmp[5]);
			double x4 = Double.parseDouble(tmp[6]);
			double y4 = Double.parseDouble(tmp[7]);
			double s1 = heron(x1,y1,x2,y2,x4,y4) + heron(x2,y2,x3,y3,x4,y4);
 			double s2 = heron(x1,y1,x2,y2,x3,y3) + heron(x1,y1,x3,y3,x4,y4);

 			if(Math.abs(s2 - s1) <= 1.0e-10) {
 				System.out.println("YES");
 			}
 			else {
 				System.out.println("NO");
 			}
		}
	}
	//??¢?????????
		public static double heron(double x1, double y1, double x2, double y2, double x3, double y3) {
			double ab,bc,ca;
		    double S,s;
		    ab=Math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
		    bc=Math.sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3));
		    ca=Math.sqrt((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1));
		    s=0.5*(ab+bc+ca);
		    S=Math.sqrt(s*(s-ab)*(s-bc)*(s-ca));
		    return S;
		}
	
}

Measured memory_bytes: 17168
#include <stdio.h>

/* プロトタイプ宣言 */
void initCardState(int list[4][13]);
void changeState(int suits, int ranks, int list[4][13]);
void printState(int list[4][13]);

/* main関数 */
int main() {
    int list_card[4][13];
    int kaisu;
    char suits;
    int ranks;

    initCardState(list_card);

    scanf("%d", &kaisu);

    for (int i = 0; i < kaisu; i++) {
        scanf("\n%c %d", &suits, &ranks);
        changeState(suits, ranks, list_card);
    }

    printState(list_card);

    return 0;
}

/* sub関数 */
void initCardState(int list[4][13])
{
    for (int i = 0; i < 4; i++){
        for (int j = 0; j < 13; j++){
            list[i][j] = 0;
        }
    }
}

void changeState(int suits, int ranks, int list[4][13])
{
    if (suits == 'S') {
        list[0][ranks - 1] = 1;
    }
    else if (suits == 'H') {
        list[1][ranks - 1] = 1;
    }
    else if (suits == 'C') {
        list[2][ranks - 1] = 1;
    }
    else if (suits == 'D') {
        list[3][ranks - 1] = 1;
    }
    else {
        /* NOP */
    }
}

void printState(int list[4][13])
{
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 13; j++) {
            if (list[i][j] == 0) {
                if (i == 0) {
                    printf("%c %d\n", 'S', j + 1);
                }
                else if (i == 1) {
                    printf("%c %d\n", 'H', j + 1);
                }      
                else if (i == 2) {
                    printf("%c %d\n", 'C', j + 1);
                }
                else if (i == 3) {
                    printf("%c %d\n", 'D', j + 1);
                }
                else {
                    /* NOP */
                }
            }
            else {
                /* NOP */
            }
        }
    }
}



Measured memory_bytes: 2120
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int int64_t
#define ALL(a) (a).begin(),(a).end()
signed main(){
  int N,K;
  cin>>N>>K;
  int sum=0,ans=N+1;
  REP(i,1,N){
    int X;
    cin>>X;
    sum+=X;
    if(sum>K){
      ans=i;
      break;
      }
    }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
while 1:
    N = int(raw_input())
    if N == 0: break
    a = raw_input().split()
    mn,mx = -10**10,10**10
    for i in range(1,N):
        if a[i-1] == a[i] == "x":
            print "none"
            break
        elif a[i-1] == "x":
            if (i+1)%2 == 0: mx = min(mx,int(a[i])-1)
            else           : mn = max(mn,int(a[i])+1)
        elif a[i] == "x":
            if (i+1)%2 == 0: mn = max(mn,int(a[i-1])+1)
            else           : mx = min(mx,int(a[i-1])-1)
        else:
            if   (i+1)%2 == 0 and int(a[i]) <= int(a[i-1]):
                print "none"
                break
            elif (i+1)%2 == 1 and int(a[i]) >= int(a[i-1]): 
                print "none"
                break
    else:
        if "x" not in a: 
            print "ambiguous"
        else:
            print mx if mn == mx else "ambiguous" if mn < mx else "none"

Measured memory_bytes: 4332
let list_init n f =
  let rec aux n f l = if n >= 0 then aux (n - 1) f (f n :: l) else l in
  aux (n - 1) f []

let () =
  let n, x = Scanf.scanf "%d %d" (fun n x -> (n, x)) in
  let ms = list_init n (fun _ -> Scanf.scanf " %d" (fun m -> m)) in
  let min_m = List.fold_left min (List.hd ms) ms in
  let sum_m = List.fold_left ( + ) 0 ms in
  let x = x - sum_m in
  let n = n + (x / min_m) in
  Printf.printf "%d\n" n

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

using namespace std;

int n,ans,p;
int a[15];

int main() {
	scanf("%d",&n); ans = 1;
	for(int i = 1; i <= n; i++) scanf("%d",&a[i]), ans *= 3;
	p = (a[1]%2) ? 1 : 2;
	for(int i = 2; i <= n; i++) p *= (a[i]%2) ? 1 : 2;
	ans -= p;
	cout << ans;
    return 0;
}


Measured memory_bytes: 256
N = gets.to_i 
A = gets.split.map(&:to_i) 

A.unshift 0
x = A.map.with_index{|a, i| i + a}.each_with_object(Hash.new(0)){|x, h| h[x] += 1}
x[0] -= 1
y = A.map.with_index{|a, i| i - a}.each_with_object(Hash.new(0)){|x, h| h[x] += 1}
y[0] -= 1
tot = 0
x.each do |k, v|
  tot += v * y[k]
end 
puts tot


Measured memory_bytes: 48588
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,A,B; cin >> N >> A >> B;
  int D = min(A,B);
  int S;
  if(N>=A+B) S=0;
  else S=A+B-N;
  
  cout << D << " " << S << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#include <numeric>
#include <iomanip>
#include <cmath>
#define ll long long
#define intm INT_MAX
#define llm LLONG_MAX

using namespace std;
int MOD = 998244353;
const int mxN = 40 + 9;

ll ar[mxN];

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll N;
	cin >> N;
	vector<ll> divisor;
	for(ll i=1; i <= sqrtl(N); i++){
        if( N % i == 0 ){
            if( N / i == i ) divisor.push_back(i);
            else{
                divisor.push_back(i);
                divisor.push_back(N/i);
            }
        }
	}
	sort(divisor.begin(), divisor.end());
	vector<ll> pow;
	for(auto &i: divisor){
        if( i != 1 ){
        ll cnt = 0;
        while( N % i == 0 ){
            N /= i;
            ++cnt;
        }
        if( cnt != 0 ) pow.push_back(cnt);
        }
	}
	/*for(auto &c: pow) cout << c << " ";
	cout << endl;*/
	ll ans = 0;
	ar[1] = 1;
	for(ll i=2; i <= 40; i++) ar[i] = ar[i-1] + i;
	for(auto c: pow){
        int L = 1; int R = 40;
        int tmpans = 1;
        while( L <= R ){
            int mid = (R+L)/2;
            //cout << "mid = " << mid  << " " << ar[mid] << endl;
            if( ar[mid] == c ){
                tmpans = mid; break;
            }
            else if( ar[mid] > c ) R = mid-1;
            else if( ar[mid] < c ){
                tmpans = mid;
                L = mid+1;
            }

        }
        //cout << tmpans << " ";
        ans += tmpans;
	}
	cout << ans;




}


Measured memory_bytes: 3668
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a = int(readline())
    b = int(readline())
    c = int(readline())
    d = int(readline())

    ans = min(a, b) + min(c, d)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61936
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define dd double
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define mp make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pll pair<ll,ll>
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<=n;i++)
ll mod=1000000007;
ll n,k,t,m,q,flag=0;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(a) -- no. of elements strictly less than a
// s.find_by_order(i) -- itertor to ith element (0 indexed)
ll min(ll a,ll b){if(a>b)return b;else return a;}
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll gcd(ll a , ll b){ if(b > a) return gcd(b , a) ; if(b == 0) return a ; return gcd(b , a%b) ;}
ll l1,r1,l2,r2;
char c[1001][1001];
ll is[1001][1001];
vector<pair<ll,ll>> v[1000001];

void dfs(ll l ,ll r , ll h){
    if(is[l][r]==-1)is[l][r]=h;
    else return ;
    if(l>0)if(c[l-1][r]=='.' && is[l-1][r]==-1){ dfs(l-1,r,h) ;}
    if(l<n-1)if(c[l+1][r]=='.' && is[l+1][r]==-1){ dfs(l+1,r,h) ;}
    if(r>0)if(c[l][r-1]=='.' && is[l][r-1]==-1){ dfs(l,r-1,h) ;}
    if(r<m-1)if(c[l][r+1]=='.' && is[l][r+1]==-1){ dfs(l,r+1,h) ;}

    for(int i=l-2;i<=l+2;i++)for(int j=r-2;j<=r+2;j++){
        if(i>=0 && i<n && j>=0 && j<m )if(is[i][j]==-1 && c[i][j]=='.'){v[h+1].pb(mp(i,j)) ;}
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #ifdef NOOBxCODER
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #else 
    #define NOOBxCODER 0
    #endif
    //cin>>t;
    t=1;
    while(t--){
        cin>>n>>m;
        
        cin>>l1>>r1>>l2>>r2;
        l1--;r1--;l2--;r2--;
        fo(i,n)fo(j,m){
            is[i][j]=-1;
            cin>>c[i][j];
        }
        if(c[l1][r1]=='#'){cout<<-1; return 0;}
        //is[l1][r1]=0;
        v[0].pb(mp(l1,r1));
        fo(i,1000000){
            fo(j,v[i].size()){  dfs(v[i][j].fi, v[i][j].se , i);}
        }
        cout<<is[l2][r2];





        
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}


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

int main()
{
    int n,k;
    std::cin >> n >> k;
    std::vector<long double> a(n);
    for(int i = 0; i < n; i++)std::cin >> a[i];
    for(int i = 0; i < n; i++){
        a[i] = (a[i] + 1.0) / 2;
    }
    long double max = 0,cur = 0;
    for(int i = 0; i < k; i++)max += a[i];
    cur = max;
    for(int i = k; i < n; i++){
        cur -= a[i - k];
        cur += a[i];
        max = std::max(max,cur);
    }
    std::cout << std::fixed <<std::setprecision(12) << max << std::endl; 
}

Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] str1 = sc.nextLine().split(" ");
		int a = Integer.parseInt(str1[0]);
		int b = Integer.parseInt(str1[1]);
		int count = 0;

		for (; a <= b; a++) {
			int tmp = a;
			int reverse = 0;
			while (tmp > 0) {
				int residue = tmp % 10;
				reverse = reverse * 10 + residue;
				tmp /= 10;
			}
			if (a == reverse)
				count++;
		}
		System.out.println(count);

		sc.close();

	}

}


Measured memory_bytes: 21844
#include<stdio.h>
 
int main(){
int H, W, i, j;
while(1){
	scanf("%d %d",&H, &W);
	if(H == 0 && W == 0) break;
	for(i = 1; i <= W; i++){
		printf("#");
	}
	printf("\n");
	for(j = 1; j <= H - 2; j++){
		printf("#");
		for(i = 1; i <= W - 2; i++){
			printf(".");
	}
		printf("#\n");
	}
		for(i = 1; i <= W; i++){
		printf("#");
	}
	printf("\n\n");
}
	return 0;
}

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

int main(){
  int n,t;
  cin >> n >> t;
  bool ok=false;
  int ans=1000,a,b;
  for(int i=0;i<n;i++){
    cin >> a >> b;
    if(b<=t){
      ans=min(ans,a);
      ok=true;
    }
  }
  if(ok)
    cout << ans << endl;
  else
    cout << "TLE" << endl;
  return 0;
}

Measured memory_bytes: 3584
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>

using namespace std;

typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> P;

const ll INF = 1e15;
const double eps = 1e-6;
const ll MOD = 1000000007;

int main() {
	string s;
	cin >> s;
	vector<int> cnt(3000);
	for (int i = 0;i < s.size();i++)
		cnt[s[i]]++;
	if (s.size() < 26) {
		char p = 'a';
		while (cnt[p] > 0)
			p++;
		cout << s << p << endl;
	}
	else {
		string ans = string(300, 'z');
		for (char base = 'b';base <= 'z';base++) {
			int p = 0;
			while (s[p] != base)
				p++;
			int q = p - 1;
			while (q >= 0 && s[q] >= base)
				q--;
			if (q < 0) {
				continue;
			}
			ans = min(ans, s.substr(0, q) + string(1, base));
		}
		if (ans == string(300, 'z'))
			cout << -1 << endl;
		else
			cout << ans << endl;
	}
	return 0;
}


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

const int DIM = 1e2 + 5;

deque<char> deq;

int main( void ) {
    
    int n; string str;
    cin >> n >> str;
    
    for( int i = 0, s = 0; i < n; i ++ ) {
        deq.push_back( str[i] );
        
        if( str[i] == '(' )
            s ++;
        else
            s --;
        
        if( s == -1 ) {
            deq.push_front( '(' );
            s = 0;
        }
        
        if( i == n - 1 ) {
            for( int i = 1; i <= s; i ++ )
                deq.push_back( ')' );
        }
    }
    
    for( char ch : deq )
        cout << ch;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC diagnostic ignored "-Wunused-result"
#define NDEBUG

#include <algorithm>
#include <cassert>
#include <cinttypes>
#include <cstdio>
#include <tuple>
#include <vector>

#ifdef NDEBUG
#  define debug(...)
#else
#  define debug(...)                                \
  do {                                              \
    fprintf(stderr, "%s:%d: ", __FILE__, __LINE__); \
    fprintf(stderr, __VA_ARGS__);                   \
    fputc('\n', stderr);                            \
  } while (false)
#endif

using namespace std;
using tii = tuple<int, int>;

const int N_MAX = 1e5;
int N, X, x[N_MAX+1];

int main() {
  scanf("%d %d", &N, &X);
  for (int i = 0; i < N; i++) scanf("%d", x+i);
  x[N] = X;
  sort(x, x+N+1);
  int ans = x[1] - x[0];
  for (int i = 2; i <= N; i++) {
    ans = __gcd(ans, x[i] - x[i-1]);
  }
  printf("%d\n", ans);
  return 0;
}


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

cum_A = [A[0]]
for i in range(N-1):
    cum_A.append(cum_A[i] + A[i+1])
cum_A.insert(0, 0)    

cum_A_dict = dict()
for i in range(N+1):
    if cum_A[i] in cum_A_dict:
        cum_A_dict[cum_A[i]] += 1
    else:
        cum_A_dict[cum_A[i]] = 1

ans = 0
for v in cum_A_dict.values():
    if v == 1:
        pass
    else:
        ans += v*(v-1) // 2
        
print(ans)

Measured memory_bytes: 43604
#include<bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;
//#define sz(x) int((x).size())
// lcm = a*(b/gcd) least common multiple
// gcd: greatest common divisor 
//
int gcd(int a, int b) {
  if(a < b) gcd(b, a);
  int r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
  }


int main() {
  int N;
  cin >>N;
  int A[N];
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  int gcd_ever[N];
  gcd_ever[0] = A[0];
  for(int i=1; i<N; i++){
    gcd_ever[i] = gcd(gcd_ever[i-1],A[i]);
  }
  int gcd_post[N];
  gcd_post[N-1] = A[N-1];
  for(int i=N-2; i>=0; i--){
    gcd_post[i] = gcd(gcd_post[i+1],A[i]);
    //    cout << gcd_post[i] << endl;
  }
  int ans = 1;
  for(int i=1; i<N-1; i++){
    //    cout << gcd_ever[i-1] << " " << gcd_post[i+1] << endl;
    ans = max(ans, gcd(gcd_ever[i-1], gcd_post[i+1]));
  }

  ans = max(ans, gcd_ever[N-2]);

  ans = max(ans, gcd_post[1]);

  cout << ans << endl;

}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	if(s=="SAT") cout<<"1"<<endl;
	else if(s=="SUN") cout<<"7"<<endl;
	else if(s=="MON") cout<<"6"<<endl;
	else if(s=="TUE") cout<<"5"<<endl;
	else if(s=="WED") cout<<"4"<<endl;
	else if(s=="THU") cout<<"3"<<endl;
	else if(s=="FRI") cout<<"2"<<endl;
	return 0;
}

Measured memory_bytes: 256