akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll MOD=998244353;
#define INF 1e9+7
#define N 310000
#define MAX_V 400010
#define vec vector<int>
using namespace std;
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umap unordered_map<ll,int,custom_hash>
struct pair_hash
{
    template<class T1,class T2>
    size_t operator() (const pair<T1,T2> &p)const{
        return hash<T1>()(p.first)^hash<T2>()(p.second);
    }
};
main(){
    int n;cin>>n;
    int a[N];
    rep(i,n)cin>>a[i];
    sort(a,a+n);
    if(n%2){
        ll sum=0;
        rep(i,n/2){
            sum+=2*a[n-1-i];
        }
        rep(i,n/2-1){
            sum-=a[i]*2;
        }
        sum-=a[n/2-1];
        sum-=a[n/2];
        ll sum2=0;
        rep(i,n/2){
            sum2-=2*a[i];
        }
        rep(i,n/2-1){
            sum2+=2*a[n-1-i];
        }
        sum2+=a[n/2];
        sum2+=a[n/2+1];
        cout<<max(sum,sum2);
    }
    else{
        ll sum=0;
        rep(i,n/2-1){
            sum+=2*a[n-1-i];
            sum-=2*a[i];
        }
        sum-=a[n/2-1];
        sum+=a[n/2];
        cout<<sum;
    }
}


Measured memory_bytes: 640
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;
struct Edge{ll from, to, cost;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll A, B;
  cin >> A >> B;
  ll ans  = 0;
  
  //ans += (((B+1)/2  - A/2) % 2 == 1? 1: 0 );
  rep(i, 41){
    if(i == 0){
      ll tmp1 = (B+1)/2;
      ll tmp2 = A/2;
      if((tmp1 - tmp2)%2 == 1)ans += 1;
      continue;
    }
    ll n = pow(2, i);
    ll flag1=0, flag2=0;
    if((A/n)%2==1){
      flag1 = (A%n)%2;
    }
    if((B/n)%2==1){
      flag2 = 1 - (B%n)%2;
    }
    //cout << n << " " << flag1 << " " << flag2 << endl;
    ans += n * (flag1 xor flag2);
  }

  cout << ans;
  /*
  rep(i, N){
    ll n=0;
    cout << i << "\t";
    while(pow(2, n)<=N){
      cout << ((i>>n) & 1) << " ";
      n++;
    }cout << endl;
    }
  */
  return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
	 
	int n;
	
	while( cin >> n ) {
		
	if( n == 0) {
		cout << "0\n";
		break;
	}
	
	double cm;
	string a1 = "" ;
	string a2 = "" ;
	string a3 = "" ;
	string a4 = "" ;
	string a5 = "" ;
	string a6 = "" ;
	
	while(n--) {
		
		cin >> cm;
		
		if( cm < 165.0 )
		a1 += "*";
		
		if( 165.0 <= cm && cm < 170.0 )
		a2 += "*";
		
		if( 170.0 <= cm && cm < 175.0 )
		a3 += "*";
		
		if( 175.0 <= cm && cm < 180.0 )
		a4 += "*";
		
		if( 180.0 <= cm && cm < 185.0 )
		a5 += "*";
		
		if(  cm > 185 )
		a6 += "*";
		
	}
	cout << "1:" << a1 << "\n";
	cout << "2:" << a2 << "\n";
	cout << "3:" << a3 << "\n";
	cout << "4:" << a4 << "\n";
	cout << "5:" << a5 << "\n";
	cout << "6:" << a6 << "\n";
}
  	return 0;
}


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

int n;
int a[100005];
int cnt[16];
int ok[1 << 16], f[1 << 16];
int ans = 0;

int main() {
	ios_base::sync_with_stdio(false);
	cin >> n;
	for (int i = 1; i < n; ++i) {
		int u, v, w; cin >> u >> v >> w;
		a[u] ^= w, a[v] ^= w;
	}
	for (int i = 0; i < n; ++i) {
		ans += cnt[a[i]] && a[i];
		cnt[a[i]] ^= 1;
	}
	int all = 0;
	for (int i = 1; i < 16; ++i) if (cnt[i]) {
		all |= (1 << i);
	}
	for (int mask = 0; mask < (1 << 16); ++mask) {
		int sum = 0;
		for (int i = 1; i < 16; ++i) if ((mask >> i) & 1) {
			sum ^= i;
		} 
		ok[mask] = sum == 0;
	} 
	for (int mask = 0; mask < (1 << 16); ++mask) {
		int cur = mask;
		while (cur) {
			if (ok[cur]) f[mask] = max(f[mask], f[mask ^ cur] + 1);
			cur = (cur - 1) & mask;
		}
	}
	cout << (ans + __builtin_popcount(all) - f[all]) << '\n';
}

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

#define LL long long
const int mod = 998244353;
int n, s, dp[6005], x;
vector<int> v;

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    
    cin >> n >> s;
    dp[0] = 1;

    while(n--) {
        cin >> x;
        for(int i = s; i >= 0; i--) {
            (dp[i + x] += dp[i]) %= mod;
            dp[i] *= 2;
            dp[i] %= mod;
        }
    }
    cout << dp[s];
}

Measured memory_bytes: 3672
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {
	
	public static void main(String[] args) throws IOException {
		final Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		
		long[] As = new long[N];
		for(int i = 0; i < N; i++){
			As[i] = sc.nextLong();
		}
		Arrays.sort(As);
		//System.out.println(Arrays.toString(As));
		for(int i = 1; i < N; i++){
			As[i] += As[i - 1];
		}
		
		int count = 1;
		for(int i = N - 2; i >= 0; i--){
			if((As[i + 1] - As[i]) > As[i] * 2){
				break;
			}else{
				count++;
			}
		}
		
		//System.out.println(Arrays.toString(As));
		System.out.println(count);
	}
	
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}
 
		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
		
		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}
		
		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
}

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

int main() {
  int input, s1, s2, s3;
  cin >> input;
  s1 = input / 100;
  s2 = (input - (s1 * 100)) / 10;
  s3 = (input - (s1 * 100) - (s2 * 10));
  cout << s1 + s2 + s3 << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define H 250

int parent(int);
  
int left(int);

int right(int);


main(){

  int i,n,A[H+1],l,r;

  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
  }
  
  for(i=1;i<=n;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(i>=1){
      if(i!=1)printf("parent key = %d, ",A[parent(i)]);
      l=left(i);
      r=right(i);
    }
    if(l<=n){
      printf("left key = %d, ",A[l]);
    }
    if(r<=n){
      printf("right key = %d, ",A[r]);
      
    }
    printf("\n");
  }
  return 0;
}

int parent(int i){
  return i/2;
}
int left(int i){
  return i*2;
}
int right(int i){
  return 2*i+1;
}

Measured memory_bytes: 600
#include"bits/stdc++.h"
using namespace std;

#define ll long long int
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(i,x,n)  for(int i=x;i<n;i++)
#define FASTIO cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define eb(x) emplace_back(x)
#define mp(a,b) make_pair(a,b)
#define sz(a) int((a).size())
#define mod 1000000007
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define inf LLONG_MAX
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }


void seethis(vector<ll>vect)
{
    for(ll x:vect)
        cout<<x<<" ";
    cout<<"\n";
}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
//LCM
int lcm(int a, int b) {  return a * (b / __gcd(a, b)); }

//For sort by second
bool cmp(const pair<int,int> &a)
{ return a.first<a.second; }

//Tree
/* const int MAXN = 1e5 + 5;
vector<ll> adj[MAXN];*/

//ModPower
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}

int main()
{
	FASTIO;
	/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif*/
	ll a,b;
	 cin>>a>>b;

	 ll x= a + (b-a)/2;

	 if(abs(a-x)!=abs(b-x))
	 	cout<<"IMPOSSIBLE\n";
	 else
	 	cout<<x<<"\n";

	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fo(i,n) for(int i=0;i<n;i++)
#define INF 1000000009
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

int main()
{
  fastio; 
  ll n,t,m,j;
  cin>>n>>m;
  cout<<(n*3 + m)/2<<"\n";
  return 0;
}
       

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

const int N = 1e5 + 10;
const long long mod = 1e9 + 7;

long long a[N], pre[N], inv[N];

long long extgcd(long long a, long long b, long long& x, long long& y){
	long long d = a;
	if (b != 0){
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else{
		x = 1;
		y = 0;
	}
	return d;
}

long long mod_inverse(long long a){
	long long x, y, m;
	m = mod;
	extgcd(a, m, x, y);
	return (m + x % m) % m;
}

int main(){
	int n;
	long long ans, jc;
	scanf("%d",&n);
	for (int i = 1; i <= n; i++) scanf("%lld",&a[i]);
	for (int i = 1; i <= n; i++) inv[i] = mod_inverse(1LL * i);
	pre[0] = 0;
	for (int i = 1; i <= n; i++) pre[i] = (pre[i - 1] + inv[i]) % mod;
	ans = 0;
	for (int i = 1; i <= n; i++){
		ans += ((pre[i] + pre[n - i + 1] - 1) % mod) * a[i] % mod;
		ans %= mod;
	}
	for (int i = 1; i <= n; i++){
		ans *= i;
		ans %= mod;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2560
N = int(input())
P = [i for i in map(int, input().split())]

"""
count = 0
for i in range(N):
	flag = 1
	for j in range(i):
		if P[i] <= P[j]:
			flag = 1
		else:
			flag = -1
			break

	if flag == 1:
		count += 1

print(count)
"""
count = 0
min_ = P[0]
for p in P:
	if p <= min_:
		count += 1
		min_ = p

print(count)
	
		



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

int main(){
  string s;
  cin>>s;
  int size=s.size();
  bool isdifferent=true;
  for(int i=0;i<s.size();i++){
    for(int j=0;j<s.size();j++){
      if(s.at(j)==s.at(i)&&j!=i)isdifferent=false;
    }
  }
  if(isdifferent)cout<<"yes"<<endl;
  else cout<<"no"<<endl;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
//#include <bits/stdc++.h>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAX 9223372036854775800

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

constexpr ll max(ll a,ll b){
if(a>=b)return a;
if(a<b)return b;
}

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};



int main() {
  ll N;
  cin >> N;
	ll A[N];
	ll B[N];
	ll C[N];  
  ll dp[N][3];
  ll ans=0;
 
	FOR(i,0,N-1){
		cin>>A[i]>>B[i]>>C[i];
    dp[i][0]=-LLONG_MAX;
    dp[i][1]=-LLONG_MAX;
    dp[i][2]=-LLONG_MAX;
	}
 
    dp[0][0]=A[0];
    dp[0][1]=B[0];
    dp[0][2]=C[0];

	FOR(i,1,N-1){
    dp[i][0]=max(dp[i-1][1],dp[i-1][2])+A[i];
    dp[i][1]=max(dp[i-1][2],dp[i-1][0])+B[i];
    dp[i][2]=max(dp[i-1][0],dp[i-1][1])+C[i];
	}
  ans=max(dp[N-1][0],dp[N-1][1]);
  ans=max(ans,dp[N-1][2]);
  cout<<ans<<endl;
 
	FOR(i,0,N-1){
  //cout<<dp[i]<<endl;
	}
 
}
 


Measured memory_bytes: 4992
let rec f i x a=let w=truncate(2.**float i)in if w=x then w::a else if w<x then f(i-1)(x-w)(w::a)else f(i-1)x a and q()=q(List.iteri(fun i e->Printf.printf(if i=0then"%d"else" %d")e)(f 9(read_int())[]);print_newline());;try q()with _->()

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

const int MOD = (int)1e9+7;

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

int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	for(int i=0;i<N;i++)	cin >> A.at(i);

	vector<int> left(N+1);
	vector<int> right(N+1);
	left.at(0)=0;
	right.at(N)=0;
	for(int i=0;i<N;i++){
		left.at(i+1)=gcd(left.at(i),A.at(i));
	}
	for(int i=N-1;i>=0;i--){
		right.at(i)=gcd(right.at(i+1),A.at(i));
	}
	
	int ans=0;
	for(int i=0;i<N;i++){
		ans=max(ans,gcd(left.at(i),right.at(i+1)));
	}
	cout << ans << endl;
	
	return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,W;
    cin>>n>>W;
    ll dp[W+1];
for(int i=0;i<=W;i++){
dp[i]=0;
}
for(int i=0;i<n;i++){
ll w,v;
cin>>w>>v;
for(int j=0;(j+w)<=W;j++){
dp[j]=max(dp[j+w]+v,dp[j]);
}

}

ll ans=0;
for(int i=0;i<=W;i++)
ans=max(ans,dp[i]);
cout<<ans;

    return 0;}


Measured memory_bytes: 4396
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int n = ni();
		int p[] = new int[n];

		for (int i = 0; i < n; i++) {
			p[i] = ni();
		}

		p = sort(p);

		int cost = 0;

		for (int i = 0; i < n - 1; i++) {
			cost += p[i];
		}

		cost += p[n - 1] / 2;

		out(cost);
	}

	/*
	 * 以下メソッド集
	 */
	static int[] sort(int[] n) {
		Arrays.sort(n);
		return n;
	}

	static long[] sort(long[] n) {
		Arrays.sort(n);
		return n;
	}

	static int ketasuu(int n) {
		String str = "" + n;
		return str.length();
	}

	static int abcount(String str) {
		int count = 0;
		int len = str.length();
		for (int i = 0; i < len - 1; i++) {
			if ("AB".equals(str.substring(i, i + "AB".length()))) {
				count++;
			}
		}
		return count;
	}

	static int ni() {
		return sc.nextInt();
	}

	static long nl() {
		return sc.nextLong();
	}

	static double nd() {
		return sc.nextDouble();
	}

	static String n() {
		return sc.next();
	}

	static char[] nc() {
		return sc.next().toCharArray();
	}

	static int kaijo(int n) {
		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {
		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

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

	static void out(String info) {
		System.out.println(info);
	}

	static void out(int info) {
		System.out.println(info);
	}

	static void out(double info) {
		System.out.println(info);
	}

	static void out(long info) {
		System.out.println(info);
	}

	static void out(char info) {
		System.out.println(info);
	}

	static void out(Object obj) {
		System.out.println(obj.toString());
	}

	static void outn(String info) {
		System.out.print(info);
	}

	static void outn(int info) {
		System.out.print(info);
	}

	static void outn(double info) {
		System.out.print(info);
	}

	static void outn(long info) {
		System.out.print(info);
	}

	static void outn(char info) {
		System.out.print(info);
	}

	static double max(double d, double e) {
		return Math.max(d, e);
	}

	static long max(long a, long b) {
		return Math.max(a, b);
	}

	static double min(double d, double e) {
		return Math.min(d, e);
	}

	static int min(int a, int b) {
		return (int) Math.min(a, b);
	}
}

class XY {
	int h;
	int c;

	XY(int h, int c) {
		this.h = h;
		this.c = c;
	}
}


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

import pdb
import sys
import math
F = sys.stdin

N = int(F.readline().rstrip())
P = list(map(int,F.readline().rstrip().split()))
Q = list(map(int,F.readline().rstrip().split()))
p_used = []
q_used = []
p_ans = 0
q_ans = 0

for n in range(N):
    p_used.append(P[n])
    for i in range(P[n] - 1):
        if i+1 in p_used:
            continue
        p_ans += math.factorial(N - n - 1)

    q_used.append(Q[n])
    for i in range(Q[n] - 1):
        if i+1 in q_used:
            continue
        q_ans += math.factorial(N - n - 1)


ans = abs(p_ans - q_ans)
# print(p_ans, q_ans)
print(ans)


Measured memory_bytes: 5508
n,m,x = map(int,input().split())
a = []
for i in range(n):
    a.append(list(map(int,input().split())))
ans = 10**9
for i in range(2**n):
    book_list = [0] * (m+1)
    for j in range(n):
        if i>>j&1:
            for q,p in enumerate(a[j]):
                if q == 0:continue
                book_list[q-1] += p
            book_list[-1] += a[j][0]
    f = 1
    for y in range(m):
        if book_list[y] < x:
            f = 0
            break
    if f == 1:
        ans = min(ans,book_list[-1])
if ans == 10**9:
    print(-1);exit()
print(ans)


Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pc __builtin_popcount

int32_t main(){
	int n,m;
	cin>>n>>m;
	cout<<(n*(n-1))/2+(m*(m-1))/2;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef long long int lli;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<pll> vop;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define REP(i,a,b) for( int i=a;i<b;i++)
#define REPR(i,a,b) for(int i=a;i>=b;i--)
#define adb(a) for(auto i:a) cout << i << " "; cout << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define endl "\n"
#define mem(a,b) memset(a,b,sizeof(a))
#define mod (ll)1e9+7;
#define PI 3.14159265358979323846

int main()
{


    fastIO;
    int test = 1;
    //cin >> test;
    while (test--)
    {
        ll n;
        cin >> n;
        set<ll>s;
        map<ll, ll>m;
        while (n % 2 == 0) {
            s.insert(2);
            m[2]++;
            n /= 2;
        }
        REP(i, 3, floor(sqrt(n)) + 1) {
            while (n % i == 0) {
                n /= i;
                s.insert(i);
                m[i]++;
            }
            i++;
        }
        if (n > 2) {
            s.insert(n);
            m[n]++;
        }
        if (s.size() == 0) {
            if (n == 1) cout << 0 << endl;
            else
                cout << 1 << endl;
            return 0;
        }
        ll ans = 0;
        for (auto x : s) {
            ll c = 1;
            ll sum = 0;
            sum += c;
            //cout << x << " " << m[x] << " ";
            while (m[x] >= sum) {
                ans++;
                c++;
                sum += c;
            }
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define MOD 998244353
#define INF 10000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
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;
}
void allcout(auto V) {
    for(auto x : V) cout << x << ' ';
    cout << endl;
}

signed main() {
    int M, N;
    cin >> N >> M;
    vector<int> V(N);
    int sum = 0;
    rep(i, N) {
        cin >> V[i];
        sum += V[i];
    }
    sort(all(V), greater<int>());
    rep(i, M) {
        if(V[i] * 4 * M < sum) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if 500 * i + 100 * j + 50 * k == X:
                ans += 1
print(ans)

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

sum=0

for i in range(N):
    if B[i]>=A[i]:
        if A[i+1]>=B[i]-A[i]:
            sum+=B[i]
            A[i+1]-=B[i]-A[i]
        else:
            sum+=A[i+1]+A[i]
            A[i+1]=0
    else:
        sum+=B[i]
print(sum)

Measured memory_bytes: 18624
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;
ul over = 1000000007;

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int n;
  cin >> n;
  unordered_map< string, bool > said;
  string prev, next;
  cin >> prev;
  said[prev] = true;
  for (int i=1; i<n; ++i) {
    cin >> next;
    if (said.count(next) > 0 || prev[prev.size()-1]!=next[0]) {
      cout << "No" << endl;
      return 0;
    }
    said[next] = true;
    prev = next;
  }
  cout << "Yes" << endl;
  return 0;
}


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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

void solve();

int main(void){
    double x1, x2, x3, y1, y2, y3;
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    double a1, b1, a2, b2;
    a1 = x2-x1; a2 = x3-x1;
    b1 = y2-y1; b2 = y3-y1;
    double S = fabs(a1*b2-a2*b1)/2;
    double A = sqrt(a1*a1 + b1*b1), B = sqrt(a2*a2 + b2*b2), C = sqrt((a2-a1)*(a2-a1) + (b2-b1)*(b2-b1));
    double r = 2.0*S/(A+B+C);
    double max_edge = max(max(A, B), C);
    printf("%.12f\n", (max_edge*r)/(max_edge + 2.0*r));
    return 0;
}

void solve(){}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

int main() {
    string S, T;
    cin >> S >> T;

    int ls = S.length();
    int lt = T.length();

    int res = 0, pos = 1e+9;
    REP(i, ls - lt + 1){

        res = 0;
        REP(j, lt){
            if(S[i+j] != T[j]){
                res++;
            }
        }

        pos = min(pos, res);
    }

    cout << pos << endl;

    return 0;
}

Measured memory_bytes: 3616
import random
import time
import copy
import math
start=time.time()
d=int(input())
c=list(map(int,input().split()))
s=[]
cli=[]
for i in range(d+1):
  ch=[]
  for j in c:
    ch.append(i*j)
  cli.append(ch)
for i in range(d):
  s.append(list(map(int,input().split())))
last=[0]*26
score=0
solution=[]
for day in range(1,d+1):
  co=[]
  dla=[]
  down=0
  for (i,j) in zip(last,c):
    down+=(day-i)*j
  for (i,j) in zip(last,c):
    dla.append(down-(j*(day-i)))
  for con in range(26):
    co.append(s[day-1][con]-dla[con])
  choice=co.index(max(co))
  score+=co[choice]
  last[choice]=day
  #print(choice+1)
  #print(score)
  solution.append(choice)
#print(score)
stemp=100000
etemp=1
def tem():
  return stemp-((stemp-etemp)*(time.time()-start)/1.9)
while time.time()-start<1.9:
  
  sc=0
  sol=copy.deepcopy(solution)
  for x in [random.randrange(d) for i in range(5)]:
    sol[x]=random.randrange(26)
  last=[0]*26
  for (day,i) in zip(range(1,d+1),sol):
    sc+=s[day-1][i]
    last[i]=day
    for (i,j) in zip(last,range(26)):
      sc-=cli[day-i][j]
  try:
    prob = math.exp((sc-score)/tem())
  except:
    prob=0
  #print("{} {}".format(sc,prob))
  if prob>random.random():
    solution=copy.deepcopy(sol)
    score=sc
    #print(score)
for i in solution:
  print(i+1)
#print(sco)


Measured memory_bytes: 10444
/**
 * code generated by Junayed Kader
 * Student of Computer Science
 * @author
 */
///Bismillahir Rahmanir Rahim///
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

using namespace std;
using namespace __gnu_pbds;


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;

#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007


template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;//*(x.find_by_order(i)),x.order_of_key(k)

/*************** #Template FUNCTIONS# **************/


#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

/// Check all 8 direction co-ordinates.
/// N, NE, E, SE, S, SW, W, NW
static int dx[] = {-1, -1, 0, 1, 1, 1, 0, -1};
static int dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu ()
{
    cerr << endl;
}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest)
{
    cerr << arg << ' ';
    faltu(rest...);
}

ll gcd ( ll a, ll b )
{
    return __gcd ( a, b );
}
ll lcm ( ll a, ll b )
{
    return a * ( b / gcd ( a, b ) );
}
ll max(ll a,ll b)
{
    return a>b?a:b;
}
ll min(ll a,ll b)
{
    return a<b?a:b;
}
/********************** START **********************/

void _case()
{
    string s;
    cin>>s;
    int first_portion, second_portion;
    first_portion = s[0]-'0';
    first_portion = (first_portion*10)+(s[1]-'0');
  //  dbg(first_portion);
    second_portion = s[2]-'0';
    second_portion = (second_portion*10)+(s[3]-'0');
   // dbg(second_portion);
    if(first_portion<=12&&first_portion>0 && second_portion<=12&& second_portion>0 )
    {
        cout<<"AMBIGUOUS"<<endl;
    }
    else if(first_portion<=12&&first_portion>0 )
    {
        cout<<"MMYY"<<endl;
    }
    else if(second_portion<=12&& second_portion>0)
    {
         cout<<"YYMM"<<endl;
    }
    else{
        cout<<"NA"<<endl;
    }
}

int main()
{
    optimize();

    _case();

    return 0;
}
/*****************  ALHAMDULILLAH  *****************/


Measured memory_bytes: 3568
#!/usr/bin/env python3
import sys
import numpy as np

YES = "Yes"  # type: str
NO = "No"  # type: str

def judge(A, B, C):
    return (B>A and C>B)

def solve(A: int, B: int, C: int, K: int):

    for i in range(K+1):
        for j in range(K-i+1):
            for k in range(K-i-j+1):
                aa = A*(2**i)
                bb = B*(2**j)
                cc = C*(2**k)
                if judge(aa,bb,cc):
                    print(YES)
                    return

    print(NO)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(A, B, C, K)

if __name__ == '__main__':
    main()


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

#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    int n,k;
    cin >> n >> k;

    vector<ll> h(n);
    rep(i,n)
    {
        cin >> h[i];
    }
    sort(h.begin(),h.end(),greater<int>());
    ll sum = 0;
    for (int i = k; i < n; i++)
    {
        sum += h[i];
    }
    cout << sum << endl;
    

}

Measured memory_bytes: 1792
import java.io.*;
import java.math.*;
import java.util.*;
import java.util.stream.*;

class Main {
    static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static final PrintWriter pw = new PrintWriter(System.out);
    public static void main(String[] args) throws IOException {
        String[] inputs = br.readLine().split(" ");
        long n = Long.parseLong(inputs[0]);
        long k = Long.parseLong(inputs[1]);

        n -= (long)(n/k) * k;
        n = Math.min(n, k-n);

        pw.println(n);
        pw.flush();
    }
}

Measured memory_bytes: 21076
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }

};


int main(){
  int n; cin >> n;
  vi p(n); rep(i,n) cin >> p[i];
  if(p[0] > 0){
    cout << -1 << endl;
    return 0;
  }
  rep(i,n-1) {
    if(p[i+1]-p[i] > 1){
      cout << -1 << endl;
      return 0;
    }
  }

  p.pb(0);
  ll ans = 0;
  for(int i = n-1; i >= 0; i--) {
    if(p[i] >= p[i+1]) ans += p[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long A = long.Parse(str[0]);
		long B = long.Parse(str[1]);
		long ans = A-B+1;
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 13140
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int nums[] = new int[in.nextInt()];
        for (int i = 0; i < nums.length; i++)
            nums[i] = in.nextInt();
        in.close();

        int count = 0;

        outerloop:
        for (int num : nums) {
            for (int i = 2; i <= Math.sqrt(num); i++)
                if (num % i == 0)
                    continue outerloop;
            ++count;
        }
        System.out.println(count);
    }
}



Measured memory_bytes: 41056
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};



int main(){
    int n;cin >> n;
    vector<int> h(n+1);
    for (int i = 0; i < n; i++) {
        cin >> h[i+1];
    }
    int ans = 0;
    h[0]=0;
    for (int i = 0; i < n; i++) {
        if(h[i]<h[i+1]) ans+= h[i+1]-h[i];
    }
    cout << ans << endl;
    return 0;
}


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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;



template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7ll;
const double PI=3.14159265358979323846;


int main() {
    int N;
    cin >> N;
    vector<int> A;
    vector<ll> count(N+10);
    rp(i, 0, N) {
        int a;
        cin >> a;
        count[a]++;
        A.emplace_back(a);
    }
    ll res = 0ll;
    rp(i, 0, N+1) {
        if(count[i] != 0) res += count[i] * (count[i] - 1ll) / 2ll;
    }
    for(auto x: A) {
        printf("%lld\n", res - count[x] + 1);
    }
    return 0;

}

Measured memory_bytes: 5864
#include <stdio.h>
#include <string.h>

int print(int a,int b);
int reverse(int a,int b);
int replace(int a,int b,char str2[]);

char str1[1001];

int main(void)
{
	int num,a,b,i;
	gets(str1);
	scanf(" %d",&num);
	for(i=0;i<num;i++){
		char command[10];
		scanf("%s  %d %d",command,&a,&b);
		if(strcmp(command,"print")==0){
			print(a,b);
		}
		else if(strcmp(command,"reverse")==0){
			reverse(a,b);
		}
		else if(strcmp(command,"replace")==0){
			char str2[1001];
			scanf("%s",str2);
			replace(a,b,str2);
		}
	}
	
	return 0;
}

int print(int a,int b)
{
	int i;
	for(i=a;i<=b;i++){
		printf("%c",str1[i]);
	}
	printf("\n");
	return 0;
}

int reverse(int a,int b)
{
	char temp[1001];
	int i,j=a;
	for(i=b;i>=a;i--){
		temp[j]=str1[i];
		j++;
	}
	for(j=a;j<=b;j++){
		str1[j]=temp[j];
	}
	return 0;
}

int replace(int a,int b,char str2[])
{
	int j,i;
	for(i=a,j=0;i<=b;i++,j++){
		str1[i]=str2[j];
	}
	return 0;
}

Measured memory_bytes: 576
from itertools import product


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

switch = []

for i in range(m):
  k, *s = map(int, input().split())
  s = list(s)
  switch.append(s)

p = list(map(int, input().split()))
ans = 0

for i in product(range(2), repeat=n):
  flag = True
  for s in range(m):
    cnt = 0
    for t in switch[s]:
      if i[t-1] == 1:
        cnt += 1
    if cnt % 2 != p[s]:
      flag = False
      break
  if flag == True:
    ans += 1

print(ans)

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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
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 (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin>>n;
vector<ll>a(n);
ll ans=1;
ll st=(ll)1e18;
rep(i,n){
    cin>>a[i];
    if(a[i]==0){
        ans=0;
        break;
    }
}
if(ans!=0){
    rep(i,n){
        if(ans>(st/a[i])){
            ans=-1;
            break;
        }
        ans*=a[i];
    }
}
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 3992
#include<bits/stdc++.h>
#define int long long
using namespace std;
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; }


signed main()
{
    int N; cin>>N;
    vector<int> a(N),b(N),c(N);
    for(int i=0;i<N;i++){
        cin>>a[i]>>b[i]>>c[i];
    }

    vector<vector<int> > dp(N,vector<int>(3));
    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];

    for(int i=1;i<N;i++){
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c[i];
    }
    int ans=0;
    for(int i=0;i<3;i++) chmax(ans,dp[N-1][i]);
    cout<<ans<<endl;
}


Measured memory_bytes: 8064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

//verified AOJ GRL_1
#define MAX_V 100000
struct edge{int to,cost;};

void dijkstra(int s, vector<int> &d, vector<edge> G[MAX_V]){
    priority_queue< pii,vector<pii>,greater<pii> > que;
    rep( i,d.size() )d[i]=INF;
    d[s] = 0;
    que.push( pii(0,s) );
    
    while( que.size() ){
        pii p=que.top();
        que.pop();
        
        int v=p.second;
        if(d[v]<p.first)continue;
        
        rep(i,G[v].size()){
            edge e=G[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                que.push(pii(d[e.to],e.to));
            }
        }
    }
}

int main(){
    int k;
    cin>>k;
    if(k==1){
        cout<<1<<endl;
        return 0;
    }
    
    vector<edge> G[MAX_V];
    for(int i=1;i<k;i++){
        G[i].pb(edge{(i+1)%k,1});
        G[i].pb(edge{(i*10)%k,0});
    }
    
    vector<int> d(MAX_V);
    dijkstra(1,d,G);
    cout<<d[0]+1<<endl;
}


Measured memory_bytes: 6780
a,b = map(int,input().split())
c,d = map(int,input().split())
m31 = [1,3,5,7,8,10,12]
m30 = [4,6,9,11]

if a in m31 and b == 31:
    print(1)
elif a in m30 and b == 30:
    print(1)
elif a == 2 and b == 28:
    print(1)
else:
    print(0) 

Measured memory_bytes: 38468
#include<bits/stdc++.h>
using namespace std; 
#define max(a, b) (a < b ? b : a) 
#define min(a, b) ((a > b) ? b : a) 
#define mod 1e9 + 7 
#define FOR(a, c) for (int(a) = 0; (a) < (c); (a)++) 
#define FORL(a, b, c) for (int(a) = (b); (a) <= (c); (a)++) 
#define FORR(a, b, c) for (int(a) = (b); (a) >= (c); (a)--) 
#define INF 1000000000000000003 
typedef long long int ll; 
typedef vector<int> vi; 
typedef vector<long long int> vl; 
typedef pair<int, int> pi; 
#define F first 
#define S second 
#define pb push_back 
#define POB pop_back 
#define MP make_pair 
 
int main()

{
int t;
cin>>t;

///while(t--)
if(t%1000==0)
cout<<0<<endl;
else
cout<<1000-(t%1000)<<endl;




  return 0;
}


  



Measured memory_bytes: 3632
#include <iostream>

using namespace std;
#define rep2(x,from,to) for(int x=(from); x<(to); (x)++)
#define rep(x,to) rep2(x,0,to)
int main() {
	int n, a[101];
	rep2(i,1,100) {
		a[i] = 0;
	}
	while(cin >> n) {
		a[n]++;
	}
	int max = 0;
	rep2(i,1,100) {
		if(max < a[i]) max = a[i];
	}
	rep2(i,1,100) {
		if(a[i] == max) {
			cout << i << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using P = pair<int,int>;
const int INF = 1e9;

int main(){
    string s;
    cin >> s;
    if (s[s.size()-1] == 's') s += "es";
    else s += 's';
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;

int main() {
    int N,M,L; cin>>N>>M>>L;
    vector<vector<ll>> dist(N,vector<ll>(N,INF));
    for (int i = 0; i < N; ++i) {
        dist[i][i]=0;
    }
    int a,b,c;
    for (int i = 0; i < M; ++i) {
        cin>>a>>b>>c; --a; --b;
        dist[a][b]=c;
        dist[b][a]=c;
    }

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            for (int k = 0; k < N; ++k) {
                dist[j][k]=min(dist[j][k],dist[j][i]+dist[i][k]);
                //dist[k][j]=dist[j][k];
            }
        }
    }


    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            if(dist[i][j]<=L) dist[i][j]=1;
            else dist[i][j]=INF;
        }
    }

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            for (int k = 0; k < N; ++k) {
                dist[j][k]=min(dist[j][k],dist[i][j]+dist[i][k]);
                //dist[k][j]=dist[j][k];
            }
        }
    }

    int Q; cin>>Q;
    for (int i = 0; i < Q; ++i) {
        cin>>a>>b; --a; --b;
        if(dist[a][b]==INF)  cout<<-1<<endl;
        else cout<<dist[a][b]-1<<endl;
    }

    return 0;
}


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  if ( abs(a-c)<=d ) {
    cout << "Yes" << endl;
  }
  else if ( abs(a-b)<=d && abs(b-c)<=d ) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  // ここにプログラムを追記
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stdlib.h>

using namespace std;

/* ソート関数 */
int int_sort( const void * a , const void * b ) {
    if( *( int * )a < *( int * )b ) {
        return -1;
    }
    else
        if( *( int * )a == *( int * )b ) {
            return 0;
        }
    return 1;
}

int main() {
    int n,k;
    cin >> n >> k;
    long int h[n];
    long int sum = 0;
    for(int i = 0; i < n; i++) {
        cin >> h[i];
    }
    qsort((void*)h,n,sizeof(h[0]),int_sort);
    for(int i = 0; i < n-k; i++) {
        sum += h[i];
    }
    cout << sum;
    return 0;
}

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

int main() {
	long long int n;
	long long int k;
	while (cin >> n >> k && n != 0 && k != 0) {
		vector<long long int> v;
		v.push_back(0);

		for (long long int i = 1; i <= n; ++i) {
			long long int m;
			cin >> m;
			v.push_back(m);
			v[i] += v[i - 1];
		}

		long long int sum = 0;
		for (long long int i = 1; i + k <= n; ++i) {
			sum = max(sum, v[i + k] - v[i]);
		}

		cout << sum << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3920
/*
 ▓█████▄  ▄████▄  ▓██   ██▓ ██▓███   ██░ ██ ▓█████  ██▀███
▒██▀ ██▌▒██▀ ▀█   ▒██  ██▒▓██░  ██▒▓██░ ██▒▓█   ▀ ▓██ ▒ ██▒
 ░██   █▌▒▓█    ▄   ▒██ ██░▓██░ ██▓▒▒██▀▀██░▒███   ▓██ ░▄█ ▒
 ░▓█▄   ▌▒▓▓▄ ▄██▒  ░ ▐██▓░▒██▄█▓▒ ▒░▓█ ░██ ▒▓█  ▄ ▒██▀▀█▄
 ░▒████▓ ▒ ▓███▀ ░  ░ ██▒▓░▒██▒ ░  ░░▓█▒░██▓░▒████▒░██▓ ▒██▒
  ▒▒▓  ▒ ░ ░▒ ▒  ░   ██▒▒▒ ▒▓▒░ ░  ░ ▒ ░░▒░▒░░ ▒░ ░░ ▒▓ ░▒▓░
  ░ ▒  ▒   ░  ▒    ▓██ ░▒░ ░▒ ░      ▒ ░▒░ ░ ░ ░  ░  ░▒ ░ ▒░
  ░ ░  ░ ░         ▒ ▒ ░░  ░░        ░  ░░ ░   ░     ░░   ░
    ░    ░ ░       ░ ░               ░  ░  ░   ░  ░   ░
  ░      ░         ░ ░
*/
//focus less on how much problem you should solve within a fixed time and focus more on getting the problem solved and
//learning something from it
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define per(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define sedes set <ll, greater <ll> >
#define seasc set <ll>
#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define MOD 1000000007
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define umap unordered_map<ll, ll>
#define map map<ll, ll>
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define mems(a, i) memset(a, i, sizeof(a))
#define endl '\n'
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define deba(a) cout << #a << " " <<a << endl;
int main()
{
	fast;
#ifndef ONLINE_JUDGE
	freopen("D:\\input.txt", "r", stdin);
	freopen("D:\\output.txt", "w", stdout);
#endif
	int t = 1;
	// cin >> t;
	while (t--)
	{
		ll n;
		cin >> n;

		if (n == 0)
			cout << 1;
		else
			cout << 0;
	}
	return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;

int main(){
    ll n,m; cin >> n >> m;
    cout << (n == m ? "Yes" : "No") << endl; 
}

Measured memory_bytes: 256