akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>

using namespace std;
#define ll long long
#define ld long double
#define int long long
#define all(a) (a).begin(),(a).end()
#define EPS (1e-13)
#define fs first
#define sc second
#define xx first
#define yy second.first
#define zz second.second
#define H pair<int, int>
#define P pair<int, pair<int, int>>
#define Q(i,j,k) mkp(i,mkp(j,k))
#define rep(i,n) for(int (i) = 0 ; (i) < (n) ; (i)++)
#define mkp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define crdcomp(b) sort(all((b)));(b).erase(unique(all((b))),(b).end())
const int mod = 1e9 + 7;
const int Mod = 998244353;
const ll Inf = 3 * 1e18;
const int inf = 15 * 1e8;
ll read() {
	ll u, k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}
ll bcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
const int fn_ = 2000000;
ll fact_[fn_], comp_[fn_];
ll comb(ll x, ll y, ll Mod = mod) {
	if (!fact_[0]) {
		fact_[0] = 1; comp_[0] = 1;
		for (int i = 1; i < fn_; i++) {
			fact_[i] = fact_[i - 1] * i % Mod;
			comp_[i] = mod_pow(fact_[i], Mod - 2, Mod);
		}
	}
	if (x < y) return 0;
	return fact_[x] * comp_[x - y] % Mod * comp_[y] % Mod;
}
//---------------------------------------------------

signed main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			for (int z = 0; z < 30; z++) {
				if ((i >> z & 1) != (j >> z & 1)) {
					cout << z + 1 << (j == n - 1 ? "\n" : " ");
					break;
				}
			}
		}
	}
}

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

int main(void){
    int n;
    cin >> n;
    
    int cpy_n = n;
    int sum = 0;
    while(cpy_n){
        sum += cpy_n % 10;
        cpy_n /= 10;
    }
    
    if(n % sum == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

const ll lim=1e18;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	ll ret=1;
	int N; cin>>N;
	double res=1;
	for (int i=0; i<N; i++) {
		ll A; cin>>A;
		ret*=A;
		res*=A;
	}
	if(res>2e18) {
		cout<<-1<<"\n";
		return 0;
	}
	cout<<((ret<=lim) ? ret : -1)<<"\n";
	return 0;
}

Measured memory_bytes: 3640
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
        String s = sc.next();
        int k = sc.nextInt();
        char c = s.charAt(k - 1);
        for(int i = 0; i < n; i++){
        	if(s.charAt(i) == c){
            	System.out.print(c);
            }else{
            	System.out.print("*");
            }
        }
    }
}

Measured memory_bytes: 35760
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

#define MOD 2019

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N;
	vector<int> A, B;

	cin >> N;
	for(int i=0; i<N; i++){
		int  a;
		cin >> a;
		A.push_back(a);
		B.push_back(a);
	}

	sort(B.begin(), B.end());

	for(int i=0; i<N; i++){
		if(A[i] == B[N - 1]){
			printf("%d\n", B[N - 2]);
		}
		else{
			printf("%d\n", B[N - 1]);
		}
	}
	return 0;
}

Measured memory_bytes: 3436
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i, n) for(ll i=(ll)(n-1);i>=0;i--)
#define FOR(i, a, b) for(ll i=(ll)(a); i<=(ll)(b); i++)
#define RFOR(i, a, b) for(ll i=(ll)(a);i>=(ll)(b); i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

signed main()
{
	ll N;
	cin >> N;
	vector<ll> A(N);
	REP(i, N){
		cin >> A[i];
	}
	sort(ALL(A));
	ll ans = 0;
	for(int i=1; i<N; i++){
		ans += A[N-1-i/2];
	}
	cout << ans << endl;
}


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

int main(){
    int a,b;
    cin>>a>>b;
    int ans=0;
    for(int i=a;i<=b;i++){
        if(i/10000==i%10&&(i/1000)%10==(i/10)%10)ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <queue>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <sstream>
#include <cassert>
#include <functional>
#include <cfloat>
#include <climits>
#include <cstring>
#include <stack>
#include <time.h>
#include <complex>
using namespace std;
typedef long long int64;
#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define ford(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define fore(i,a,n) for(int i=(int)(a);i<(int)(n);i++)
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define last(a) (int(a.size())-1)
#define all(a) a.begin(),a.end()
const double EPS=1E-9;
const int INF=1000000000;
const int64 INF64=(int64) 1E18;
const double PI=3.1415926535897932384626433832;
int main()
{
	int n;
	cin>>n;
	if(n%10==9||n/10==9)
	cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
void swap(int[], int);
void trace(int[], int);
int main(void){
    int N, i;
    int a[100];
    scanf("%d", &N);
    for(i = 0; i < N; i++){
        scanf("%d", &a[i]);
    }
    trace(a, N);
    swap(a, N);
}
void swap(int a[],int N){
    int i, j, v;
    for(i  = 1; i < N; i++){
        v = a[i];
        for(j = i -1; j >= 0 && a[j] > v; j--){
            a[j + 1] = a[j];
        }
        a[j + 1] = v;
        trace(a, N);
    }
    return;
}
void trace(int a[], int N){
    int i;
    for(i = 0; i < N - 1; i++){
        printf("%d ", a[i]);
    }
    printf("%d\n", a[i++]);
    return;
}



Measured memory_bytes: 2104
#include<stdio.h>
#include<stdlib.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

int main(void){
    int N;
    scanf("%d",&N);

    //A[0]~A[N-1]に格納する
    int* A;
    NEW(A,N);
    for(int i=0;i<N;i++){
        scanf("%d",&A[i]);
    }

    int first;
    int second;
    int fi; //一番大きい数がA[fi]に入る

    //first,second,fiの初期値
    if(A[0]>A[1]){first=A[0];second=A[1];fi=0;}
    else{first=A[1];second=A[0];fi=1;}
    //更新
    for(int i=2;i<N;i++){
        if(A[i]>first){
            second=first;
            first=A[i];
            fi=i;
        }
        else if(first>=A[i]&&A[i]>second){
            second=A[i];
        }
    }

    for(int i=0;i<N;i++){
        if(i==fi) printf("%d\n",second);
        else printf("%d\n",first);
    }

    return 0;
}

Measured memory_bytes: 2304
if __name__ == '__main__':

    """prepairing"""

    amount = input()
    factor = amount.split(' ')
    N = int(factor[0])
    W = int(factor[1])

    v = []
    w = []
    v.append(0)
    w.append(0)
    inputs = []

    d = []

    for i in range(W + 1):
        temp = [0] * (N + 1)
        d.append(temp)

    """getting inputs and initializing arrays"""

    for x in range(N):
        inputs[:] = []
        inputs = input().split(' ')
        v.append(int(inputs[0]))
        w.append(int(inputs[1]))



    """make array"""

    for row in range(W + 1):
        for column in range(N + 1):
            if row != 0 and column != 0:
                if w[column] > row:
                    d[row][column] = d[row][column - 1]
                else:
                    d[row][column] = max(d[row - w[column]][column - 1] + v[column], d[row][column - 1])

    print(d[W][N])

Measured memory_bytes: 44784
N = int(input())
x_list = list(map(int,input().split()))
sorted_list = sorted(x_list)
median_idx = N//2 -1
for x in x_list:
    if x>sorted_list[median_idx]:
        print(sorted_list[median_idx])
    else:
        print(sorted_list[median_idx+1])

Measured memory_bytes: 93780
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <tuple>

using ll = long long;
using namespace std;

char alphabet[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

tuple<int, ll> charCount(ll N){
    ll N_int = N;
    int n = -1;
    ll ar = 26;
    while(N_int > 0){
        N_int -= ar;
        ar *= 26;
        n++;
    }
    return make_tuple(n, N_int + ar/26);
}

string constructName(tuple<int, ll> count, ll blkSize){
    int n = get<0>(count);
    ll rest = get<1>(count);
    //cout << "n=" << n << " " << "rest=" << rest << endl;
    
    if(n > 0){
        ll blockPos = (rest - 1)/ blkSize;

        //cout << "block:" << blockPos << endl;
        int leftLen = n - 1;

        rest -= blockPos * blkSize;
        return alphabet[blockPos] + constructName(make_tuple(leftLen, rest), blkSize/26);
    } else if(n == 0){
        return {alphabet[rest - 1]};
    } else{
        return {'1'};
    }
}

int main(void)
{
    
    ll N;
    cin >> N;
    tuple<int, ll> pos = charCount(N);
    int n = get<0>(pos);
    ll rest = get<1>(pos);
    ll blkSize = pow(26, n);
    //cout << n << ' ' << rest << endl;
    //cout << blkSize << endl;
    cout << constructName(pos, blkSize) << endl;
    return 0;
}


Measured memory_bytes: 4128
#include"bits/stdc++.h"
using namespace std;
namespace ORIGIN {
	#define LL long long
	#define VLL vector<long long>
	#define SORT(x) sort(x.begin(),x.end())
	#define REVE(x) reverse(x.begin(),x.end())
	#define rep(i,n) for(int i=0;i<n;i++)
	#define COUT(x) cout<<x<<endl
	double pai = 3.1415926535;
	string atc = "atcoder";
	typedef pair<long long, long long> data_t;
	string strnum = "0123456789";
	string alpS = "abcdefghijklmnopqrstuvwxyz";
	string alpL = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	int sizealp = (int)(alpS.size());
	int mod = 1e9 + 7;
	bool test = false;
}
using namespace ORIGIN;

void Test(char a) {
	if (test) {
		printf("%c", a);
	}
}
int gcd(LL a, LL b) {
	if (a == 0 || b == 0)return 0;
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	else gcd(b, a % b);
}

int main() {
	int k, n;
	cin >> n >> k;
	cout << n - k + 1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0; i<N; i++)

using namespace std;

int main(){
  int n,k,q; 
  cin >> n;
  cin >> k;
  cin >> q;
  
  vector<int> a(q);
  rep(i,q) { cin >> a[i];}

  vector<int> score(n);
  rep(i,n) { score[i] = 0;}

  int total_cnt = 0;
  for(int i=0;i<q;i++) {
    int win = a[i] - 1;
    score[win]++;
    total_cnt++;
  }

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

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

using namespace std;

const int MOD = 1E9 + 7;
const int MAXN = 1E5;
int x[MAXN + 1];
int y[MAXN + 1];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        cin >> x[i];
    for (int i = 1; i <= m; i++)
        cin >> y[i];
    int a, b;
    a = b = 0;
    for (int i = 2; i <= n; i++)
    {
        a = (int) ((a + (long long) (i - 1) * x[i]) % MOD);
    }
    for (int i = 1; i <= n; i++)
    {
        a = (int) ((a - ((long long) (n - i) * x[i]) % MOD + MOD) % MOD);
    }
    for (int i = 2; i <= m; i++)
    {
        b = (int) ((b + (long long) (i - 1) * y[i]) % MOD);
    }
    for (int i = 1; i <= m; i++)
    {
        b = (int) ((b - ((long long) (m - i) * y[i]) % MOD + MOD) % MOD);
    }
    cout << (long long) a * b % MOD << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
long long a,b,n,ans=0,x;
int main()
{
	scanf("%lld%lld%lld",&a,&b,&n);
	x=n/b*b-1;
	ans=a*n/b-n/b*a;
	if(a*x/b-x/b*a>ans)ans=a*x/b-x/b*a;
	printf("%lld",ans);
}

Measured memory_bytes: 1708
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int N, K;
  cin >> N >> K;
  set<int> se;
  rep(i, N) se.insert(i);
  rep(i, K) {
    int d;
    cin >> d;
    rep(j, d) {
      int a;
      cin >> a;
      se.erase(--a);
    }
  }
  cout << se.size() << endl;
  return 0;
}


Measured memory_bytes: 3644
def main():
    a, b, c, x, y = map(int, input().split())

    total_min = a * x + b * y

    for i in range(1, max(x, y)+1):
        total = a * max(x - i, 0) + b * max(y - i, 0) + c * i * 2
        total_min = min(total, total_min)
    print(total_min)

if __name__ == "__main__":
    main()

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

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

int w,h;
int t[31][31],s[31][31];
int di[] = {-1,0,1,0};
int dj[] = {0,1,0,-1};

void chDir(void){
	rep(i,h)rep(j,w)if(t[i][j]>=0)for(int k=1;k>=-2;k--){
		int nd = (t[i][j] + 4 + k) % 4;
		int ni = i + di[nd];
		int nj = j + dj[nd];

		if(t[ni][nj] == -1 || t[ni][nj] == -2){
			t[i][j] = nd;
			break;
		}
	}
}

void printMapT(void){
	rep(i,h){
		rep(j,w){
			if(t[i][j] == 0) cout<<"N";
			if(t[i][j] == 1) cout<<"E";
			if(t[i][j] == 2) cout<<"S";
			if(t[i][j] == 3) cout<<"W";
			if(t[i][j] == -1) cout<<"X";
			if(t[i][j] == -2) cout<<".";
			if(t[i][j] == -3) cout<<"#";
		}
		cout<<endl;
	}
	cout<<endl;
}

void printMapS(void){
	rep(i,h){
		rep(j,w){
			if(s[i][j] == 0) cout<<"N";
			if(s[i][j] == 1) cout<<"E";
			if(s[i][j] == 2) cout<<"S";
			if(s[i][j] == 3) cout<<"W";
			if(s[i][j] == -1) cout<<"X";
			if(s[i][j] == -2) cout<<".";
			if(s[i][j] == -3) cout<<"#";
		}
		cout<<endl;
	}
	cout<<endl;
}

int move(void){
	int res = 0;

	rep(i,h)rep(j,w)s[i][j] = t[i][j];

	rep(i,h)rep(j,w)if(t[i][j] == -1 || t[i][j] == -2)for(int k=1;k>=-2;k--){
		int nd = (k + 4) % 4;
		int ni = i + di[nd];
		int nj = j + dj[nd];

		if(ni>=0 && ni<h && nj>=0 && nj<w && t[ni][nj]>=0 && t[ni][nj]==(nd+2)%4){
			if(t[i][j] == -1) res++;
			else s[i][j] = t[ni][nj];
			s[ni][nj] = -2;
			break;
		}
	}

	rep(i,h)rep(j,w)t[i][j] = s[i][j];

	return res;
}

int main(void){
	while(cin>>w>>h && (w || h)){
		int rem = 0;
		char ch;

		rep(i,h){
			rep(j,w){
				cin>>ch;
				if(ch == 'X') t[i][j] = -1;
				else if(ch == '.') t[i][j] = -2;
				else if(ch == '#') t[i][j] = -3;
				else if(ch == 'N'){t[i][j] = 0; rem++;}
				else if(ch == 'E'){t[i][j] = 1; rem++;}
				else if(ch == 'S'){t[i][j] = 2; rem++;}
				else if(ch == 'W'){t[i][j] = 3; rem++;}
			}
		}

		int ans;
		for(ans=0;ans<180 && rem!=0;ans++){
			chDir();
			rem -= move();
		}
		if(ans == 180) cout<<"NA\n";
		else cout<<ans<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>

using namespace std;

int main(){

    int x,a, b;
    cin >> x >> a >> b;

    if(a >= b ){
        cout << "delicious" << endl;
    }else if(b-a <= x){
        cout << "safe" << endl;
    }else{
        cout << "dangerous" << 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 main(){
    int H,W;
    cin >> H >> W;
    vector<vector<char>> graph(H+2,vector<char>(W+2));
    vector<vector<int>> graphCount(H+2,vector<int>(W+2, 0));

    for(int i=0;i<H+2;i++)
    {
        if(i<1 || i>H)
        {
            continue;
        }
        for(int j=0;j<W+2;j++)
        {
            if(j<1 || j>W)
            {
                continue;
            }
            cin >> graph[i][j];
        }
    }




    for(int i=0;i<H+2;i++)
    {
        if(i<1 || i>H)
        {
            continue;
        }
        for(int j=0;j<W+2;j++)
        {
            if(j<1 || j>W)
            {
                continue;
            }

            if(graph[i][j] == '#')
            {
                graphCount[i][j]=-100;
                graphCount[i-1][j-1]++;
                graphCount[i-1][j]++;
                graphCount[i-1][j+1]++;
                graphCount[i][j-1]++;
                graphCount[i][j+1]++;
                graphCount[i+1][j-1]++;
                graphCount[i+1][j]++;
                graphCount[i+1][j+1]++;
            }
        }
    }

    for(int i=0;i<H+2;i++)
    {
        if(i<1 || i>H)
        {
            continue;
        }
        for(int j=0;j<W+2;j++)
        {
            if(j<1 || j>W)
            {
                continue;
            }

            if(graphCount[i][j] <0)
            {
                cout << "#";
            }else
            {
                cout << graphCount[i][j];
            }
            
        }
        cout << std::endl;
    }


    return 0;
}




Measured memory_bytes: 256
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy

# import heapq
# from collections import deque
# import decimal

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    s = input()
    t = input()

    if s==t[:-1]:
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()


Measured memory_bytes: 10420
/* ****revpro**** */
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl	   '\n'
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)    
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define mii	    map<ll,ll>
using namespace std;

#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define N  100005
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;  
#define ordered_set tree<double, null_type,less<double>, rb_tree_tag,tree_order_statistics_node_update> 
void solve()
{
	ll n,m,x;
	cin>>n>>m>>x;
	ll c[n];
	ll a[n][m];
	rep(i,0,n) {
		cin>>c[i];
		rep(j,0,m) cin>>a[i][j];
	}	
	ll ans=1e18;
	rep(i,0,1<<n){
		ll cnt[m]={0},cost=0;
		rep(j,0,n){
			if(i&(1<<j)){
				rep(k,0,m) cnt[k]+=a[j][k];
				cost+=c[j];
 			}
		}
		ll f=1;
		rep(j,0,m) if(cnt[j]<x) f=0;
		if(f) ans=min(ans,cost);
	}
	if(ans!=1e18) cout<<ans;
	else cout<<-1;

}
signed main()
{
	
		/***********************************/
    unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
    mt19937_64 generator (seed);
    /***********************************/
 
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
		
	}
	TIME
	return 0;
}

Measured memory_bytes: 3812
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A[3];
  cin>>A[0]>>A[1]>>A[2];
  
  swap(A[0],A[1]);
  swap(A[0],A[2]);
  cout<<A[0]<<" "<<A[1]<<" "<<A[2];
}

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

int N;

int func(int sum){
    if(sum==N){
        return 1;
    }
    else if(sum>N){
        return 0;
    }
    
    return func(sum+4) || func(sum+7);
}

int main(){
    cin >> N;
    
    int ans;
    ans = func(0);
    
    cout << ((ans)?"Yes":"No") << endl;
}


Measured memory_bytes: 256
n,t=gets.split.map(&:to_i)
keiro=[]
n.times do
    keiro << gets.split.map(&:to_i)
end
 oks=keiro.select{|a|a[1]<=t}
 if oks==[]
    puts :TLE
else
    p oks.min_by{|a|a[0]}[0]
end

Measured memory_bytes: 1788
#include <stdlib.h>
#include <iostream>
using namespace std;

bool binary_search(int *array, int left, int right, int num);
void print_array(int *array, int size);
int main(){
	int s_num;
	int t_num;

	cin >> s_num;

	int* array_s = (int*)malloc(s_num * sizeof(int));

	for(int i = 0; i < s_num; ++i){
		cin >> array_s[i];
	}

	cin >> t_num;

	int* array_t = (int*)malloc(t_num * sizeof(int));

	for(int i = 0; i < t_num; ++i){
		cin >> array_t[i];
	}

	int result_size = 0;

	for(int i = 0; i < t_num; ++i){
		if(binary_search(array_s, 0, s_num-1, array_t[i])){
			++result_size;
		}
	}

	cout << result_size << endl;
	return 0;
}

bool binary_search(int *array, int left, int right, int num){
	while(left <= right){
		int mid = (left + right) >> 1;
		if(array[mid] == num){
			return true;
		}else if (array[mid] < num){
			left = mid+1;
		}else{
			right = mid-1;
		}
	}
	return false;
}

Measured memory_bytes: 1764
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Linq;
using static System.Math;

class MainClass
{

    public static void Main(string[] args)
    {
        long Q = (long)Pow(10, 9) + 7;
        var _ = LnLngs();
        var H = _[0]; var W = _[1];
        var grid = new string[H]; for (int i = 0; i < grid.Length; i++) { grid[i] = LnStr(); }

        var dp = new long[H][]; for (int i = 0; i < dp.Length; i++) { dp[i] = new long[W]; }

        for (int h = 0; h < H - 1; h++)
        {
            dp[h][0] = grid[h][0] == '#' ? 0 : h > 0 ? dp[h - 1][0] : 1;
            for (int w = 0; w < W - 1; w++)
            {
                if (grid[h + 1][w] == '#' && grid[h][w + 1] == '#')
                {
                    dp[h + 1][w] = 0;
                    dp[h][w + 1] = 0;
                }
                else if (grid[h + 1][w] == '#')
                {
                    dp[h + 1][w] = 0;
                    dp[h][w + 1] = (dp[h][w] + (h > 0 ? dp[h - 1][w + 1] : 0))%Q;
                }
                else if (grid[h][w + 1] == '#')
                {
                    dp[h + 1][w] = (dp[h][w] + (w > 0 ? dp[h + 1][w - 1] : 0))%Q;
                    dp[h][w + 1] = 0;
                }
                else
                {
                    dp[h][w + 1] = (dp[h][w] + (h > 0 ? dp[h - 1][w + 1] : 0))%Q;
                    dp[h + 1][w] = (dp[h][w] + (w > 0 ? dp[h + 1][w - 1] : 0))%Q;
                }
            }
        }
        dp[H - 1][W - 1] = (dp[H - 1][W - 2] + dp[H - 2][W - 1])%Q;
        Console.WriteLine(dp[H - 1][W - 1]);
    }
   

public static long Gcd(long a, long b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
    public static int Gcd(int a, int b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
    public static int[] LnInts() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new int[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = int.Parse(vs[i]); return ins; }
    public static int LnInt() { var vs = Console.ReadLine().Trim(); return int.Parse(vs); }
    public static long[] LnLngs() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new long[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = long.Parse(vs[i]); return ins; }
    public static long LnLng() { var vs = Console.ReadLine().Trim(); return long.Parse(vs); }
    public static string[] LnStrs() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); return vs; }
    public static string LnStr() { var vs = Console.ReadLine().Trim(); return vs; }
}



Measured memory_bytes: 25648
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <queue>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int> ;
using vl = vector<ll>;

int main(){
    int n;
    cin >> n;
    string s;
    int cnt =0;
    reps(i,1,n+1){
        s = to_string(i);
        if(s.length() % 2 == 1){
            cnt++;
        }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  int n; cin >> n;
  vector<int> a(n);
  for (int& x: a) cin >> x;
  sort(a.begin(), a.end());
  double cur = a[0];
  for (int i = 1; i < n; i++) {
    cur = (cur + a[i]) / 2;
  }
  cout << fixed << setprecision(10) << cur << endl;

  return 0;
}


Measured memory_bytes: 3768
#include<iostream>
#include<string>
#include <algorithm>
using namespace std;
int main()
{
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if((A*B) > (C*D)){
    cout << A*B << endl;
  }else{
    cout << C*D << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll  long long int
#define ull unsigned long long int 
#define pb  push_back
#define mp  make_pair
#define pii pair<int, int>
using namespace std;

const ll mod = 1e9+7;
const int N = 1e5;

int dp[N+1] = {0};
bool check[N+1] = {0};
int n;
int arr[N+1] = {0};

int dp_recurse(int ind){

	if(check[ind] == 1){
		return dp[ind];
	}

	if(ind == n-1){
		return 0;
	}

	if(ind == n-2){
		return abs(arr[ind] - arr[n-1]);
	}

	int skip = abs(arr[ind] - arr[ind+2]) + dp_recurse(ind+2);
	int dont_skip = abs(arr[ind] - arr[ind+1]) + dp_recurse(ind+1);

	dp[ind] = min(skip, dont_skip);
	check[ind] = 1;

	return dp[ind];

}


void solve(){
    //solve here//
	cin >> n;

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

	cout << dp_recurse(0) << endl;
}


int main(){
    ll t=1;
    //cin >> t;
    while(t--){
        solve();
    }
}



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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
int n;

struct Node {
    int k;
    Node *l, *r, *p;
};

Node *root = nullptr;


void insert(Node* inode) {
    if (root == nullptr) {
        root = inode;
        return;
    }
    Node* tgt = root;
    while (true) {
        if (inode->k < tgt->k) {
            if (tgt->l == nullptr) {
                tgt->l = inode;
                break;
            }else{
                tgt = tgt->l;
            }
        }else{
            if (tgt->r == nullptr) {
                tgt->r = inode;
                break;
            }else{
                tgt = tgt->r;
            }
        }
    }
}

void Preorder(Node* n) {
    if (n == nullptr) {
        return;
    }
    std::cout << " " << n->k;
    Preorder(n->l);
    Preorder(n->r);
}
void Inorder(Node* n) {
    if (n == nullptr) {
        return;
    }
    Inorder(n->l);
    std::cout << " " << n->k;
    Inorder(n->r);
}

int main() {
    std::cin >> n;
    std::vector<Node> T;
    T.reserve(n);

    FOR(i, 0, n){
        std::string instruction;
        std::cin >> instruction;
        if (instruction == "insert") {
            Node n{0, nullptr, nullptr, nullptr};
            std::cin >> n.k;
            T.push_back(n);
            insert(&T[T.size() - 1]);
        }else if(instruction == "print") {
            Inorder(root);
            std::cout << std::endl;
            Preorder(root);
            std::cout << std::endl;
        }
    }

}


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

int main() {
  string S;
  cin >> S;
  ll N = S.size() + 1;
  vector<ll> A;
  ll count = 1;
  
  for (ll i = 1; i < N-1; i++) {
    if (S[i-1] != S[i]) {
      A.push_back(count);
      count = 1;
      continue;
    }
    count += 1;
  }
  A.push_back(count);
  
  ll sum = 0;
  ll AS = A.size();
  for (ll i = 0; i < AS; i += 2) {
    if (S[0] == '<') {
      if (i == AS -1) {
        sum += A[i];
        continue;
      }
      sum += max(A[i], A[i+1]);
    }
    if (S[0] == '>') {
      if (i == 0) {
        sum += A[i];
        i--;
        continue;
      }
      if (i == AS -1) {
        sum += A[i];
        continue;
      }
      sum += max(A[i], A[i+1]);
    }
  }
  
  for (ll i = 0; i < AS; i++) {
    sum += ((A[i]-1) * A[i] / 2);
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  string s;
  R s;
  sort(all(s));
  if(s[0]!=s[2]) pr("Yes");
  else pr("No");
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
/*



*/
int main(){
  ll N,K; cin>>N>>K;
  vector<ll> A(N,0);
  rep(i,N) cin>>A[i];
  ll high = 1e9, low = 1, mid = (high + low)/2;
  while (high > low){
  ll work = 0;
  rep(i,N) work += (A[i]-1)/mid;
    if (work <= K)
      high = mid;
    else
      low = mid+1;
    mid = (high + low)/2;
//printf("high:%lld, low:%lld, mid:%lld, work:%lld\n",high,low,mid,work);    
  }
  //check
  ll check = 0;
  rep(i,N) check += (A[i]-1)/mid;
  if (check > K)
    mid--;
  cout << mid <<endl;
}

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

int main(){
  int N;
  cin >> N;
  vector<P> red, blue;
  rep(i, N){
    int a, b;
    cin >> a >> b;
    red.push_back(P(a, b));
  }
  rep(i, N){
    int c, d;
    cin >> c >> d;
    blue.push_back(P(c, d));
  }
  sort(blue.begin(), blue.end());
  int ans = 0;
  bool use[N];
  rep(i, N) use[i] = false;
  rep(i, N){
    int m = -1, pos = -1;
    rep(j, N){
      if(blue[i].first > red[j].first && red[j].second < blue[i].second && !use[j]){
        if(red[j].second > m){
          pos = j;
          m = red[j].second;
        }
      }
    }
    if(pos != -1){
      use[pos] = true;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  int n, m;
  while (cin >> n >> m) {
    if (n == 0) break;
    vector<int> mx(n, 0), mn(n, 0);
    for (int i = 0; i < m; i++) {
      int s, k;
      cin >> s >> k;
      for (int j = 0; j < k; j++) {
        int c;
        cin >> c, c--;
        if (k == 1) mn[c] += s;
        mx[c] += s;
      }
    }

    pair<int, int> pmx(-1, -1), pmn(-1, 1e9);
    for (int i = 0; i < n; i++) {
      if (mx[i] > pmx.second) pmx = {i, mx[i]};
      if (mn[i] < pmn.second) pmn = {i, mn[i]};
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
      if (i != pmx.first) ans = max(ans, mx[pmx.first] - mn[i]);
      if (i != pmn.first) ans = max(ans, mx[i] - mn[pmn.first]);
    }

    cout << ans + 1 << endl;
  }
}



Measured memory_bytes: 3152
#include<iostream>
#include<cstdio>
using namespace std;
int main(void)
{
    long long n, a, b;
    cin >> n >> a >> b;
    long long t = n / (a + b);
    long long p = n % (a + b);
    if(p>a)
        p = a;
    cout << t * a + p << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repeq(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define rep1eq(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using Int = long long;

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
typedef pair<int,int> P;
typedef std::priority_queue<int> IntPrioQueue;
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue;

//少数点表示
//cout << std::fixed << std::setprecision(14) << 値

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

    int n;
    cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    bool ok = true;
    int max_ = h[0];
    rep1(i,1,n){
        max_ = max(max_,h[i]);
        if(h[i]>=h[i-1]){
            continue;
        }else{
            if(max_-h[i] > 1) ok = false;
        }
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;

}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9


int main(){
	int v,e;
	cin>>v>>e;
	vector<vector<mp> > g(v);
	for(int i=0;i<e;i++){
		int s,t,d;
		cin>>s>>t>>d;
		g[s].push_back(mp(d,t) );
		g[t].push_back(mp(d,s) );
	}
	vector<bool > used(v,false);
	used[0] = true;
	priority_queue<mp,vector<mp>,greater<mp> > q;
	for(int i=0;i<g[0].size();i++)q.push( g[0][i] );
	ll ans =0;
	while(!q.empty() ){
		mp now = q.top();
		q.pop();
		ll nn = now.second;
		ll cost = now.first;
		if(used[nn])continue;
		ans += cost;
		used[nn] = true;
		for(int i=0;i<g[nn].size();i++){
			q.push(g[nn][i]);
		}
	}
	cout<<ans<<endl;
	return 0;
}



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

template <class T>
class SegmentTree{
private:
    int n;
    vector<T> dat;
    T def;
    function<T(T, T)> operation;
    function<T(T, T)> update;

    T _query(int a, int b, int k, int l, int r){
        // [a, b), [l, r)
        if(r<=a or b<=l) return def;
        else if(a<=l and r<=b) return dat[k];
        else{
            T c1 = _query(a, b, 2*k+1, l, (l+r)/2);
            T c2 = _query(a, b, 2*k+2, (l+r)/2, r);
            return operation(c1, c2);
        }
    }

    void _change(int i, T x){
        i += n - 1;
        dat[i] = update(dat[i], x);
        while(i){
            i = (i-1) / 2;
            dat[i] = operation(dat[2*i+1], dat[2*i+2]);
        }
    }

public:
    T query(int a, int b){
        return _query(a, b, 0, 0, n);
    }

    void change(int i, T x){
        _change(i, x);
    }

    T operator[](int i){
        return dat[i+n-1];
    }

    SegmentTree(size_t _n, T _def, function<T(T, T)> _operation,
                function<T(T, T)> _update)
            : def(_def), operation(_operation), update(_update){
        n = 1;
        while(n < _n){
            n *= 2;
        }
        dat = vector<T>(2*n-1, def);
    }
};

int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int N, Q;
    cin>>N>>Q;
    SegmentTree<lint> dat(N, INT_MAX,
                       [](lint a, lint b){return min(a, b);},
                       [](lint a, lint b){return b;});

    for(int i=0;i<Q;i++){
        int c, x, y;
        cin>>c>>x>>y;
        if(c==0) dat.change(x, y);
        else printf("%lld\n", dat.query(x, y+1));
    }
    return 0;
}


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

int main() {
	int n,c2=0,c3=0;
	long long int m=0,s=0,s1=0,s2;
	long long int a[100000];
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a[i];
		s+=a[i];
	}
	for(int c1=0;c1<n;c1++){
		while(s1*3<s){
			s1+=a[c2%n];
			s2-=a[c2%n];
			c2++;
		}
		if(c3<=c2){
			c3=c2+1;
			s2=a[c2%n];
		}
		while(s2*2<(s-s1)){
			s2+=a[c3%n];
			c3++;
		}
		if(m<s-s1-s2){
			m=s-s1-s2;
		}
		c3--;
		s2-=a[c3%n];
		if(m<s2){
			m=s2;
		}
		s1-=a[c1%n];
	}
	cout << m << endl;
	return 0;
}

Measured memory_bytes: 1944
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>
#include <fstream> 
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <math.h>
#include <cmath>
using namespace std;
int main(){
    char s[100000];
    int sub = 0;
    int i = 0;
    while(cin >> s[i]){
    i++;
    }
    for(int j=0;j<i-1;j++){
    if(s[j] == s[j+1]){
    cout << j+1 << " " << j+2 << endl;
    sub++;
    break;	
    }	
    }
    if(sub == 0){
    for(int k=0;k<i-2;k++){
    if(s[k] == s[k+2]){
    cout << k+1 << " " << k+3 << endl;
    sub++;
    break;
    }	
    }
    }
    if(sub == 0){
    cout << -1 << " " << -1 << endl;
    }	
}

Measured memory_bytes: 384
#include<stdio.h>

int main()
{
   int N,K,X,Y,sum;

   scanf("%d%d%d%d",&N,&K,&X,&Y);

   if(N > K)
   {
   	   sum = X * K + (N - K) * Y;
   }
   else
   {
   	   sum = X * N;   
   }

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

Measured memory_bytes: 128
N,W=map(int,input().split())
w=[0 for i in range(N)]
v=[0 for i in range(N)]
for i in range(N):
    w[i],v[i]=map(int,input().split())
dp=[[0 for i in range(W+1)] for i in range(N+1)]
for j in range(W+1):
    dp[0][j]=0
for i in range(N):
    for j in range(W+1):
        dp[i+1][j]=dp[i][j]
        if j-w[i]>=0:
            if dp[i][j]<dp[i][j-w[i]]+v[i]:
                dp[i+1][j]=dp[i][j-w[i]]+v[i]
print(dp[N][W])


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

/* #pragma */
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
int32_t GCD(int32_t a, int32_t b){return b ? GCD(b, a%b) : a;}
int64_t GCD(int64_t a, int64_t b){return b ? GCD(b, a%b) : a;}
int32_t LCM(int32_t a, int32_t b){return a * b / GCD(a, b);}
int64_t LCM(int64_t a, int64_t b){return a * b / GCD(a, b);}

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
constexpr int32_t INF = 1001001001;
constexpr int64_t LINF = 1001001001001001001ll;
constexpr int32_t MOD = 1e9 + 7; //10^9
constexpr int64_t EPS = 1e-9;
constexpr int32_t dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//constexpr int32_t dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right


//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//g++ -std=c++14 -Wall --pedantic-errors template.cpp
//chcp 65001

/*global*/



#define int int64_t
signed main()
{
	int M,D; cin >> M >> D;
	int cnt{};
	for(int m = 1; m <= M; ++m){
		for(int d = 10; d <= D; ++d){
			int d0 = d;
				int d1 = d0%10;
				d0/=10;
				int d10 = d0%10;
				if(d1 >= 2 && d10 >= 2 && (d1*d10 == m)){
					cnt++;
				}
		}
	}

	cout << cnt;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Library;
using static Library.Input;

namespace AtCoderTemplate
{
    class ProgramC
    {
        static void Main()
        {
            int n = NextInt, k = NextInt;
            int div = 1, tmp = n;
            double result = 0;

            while (tmp >= 1)
            {
                result += (double)Math.Max(tmp - k + 1, 0) / div;
                div *= 2;
                tmp = Math.Min(k - 1, tmp);
                k = (k - 1) / 2 + 1;
            }

            System.Console.WriteLine(result / n);
        }
    }
}

namespace Library
{
    class Input
    {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line => Console.ReadLine();

        public static string[] StrArr => Line.Split(' ');

        public static int NextInt => int.Parse(NextWord());

        public static long NextLong => long.Parse(NextWord());

        public static List<int> IntList => StrArr.Select(int.Parse).ToList();

        public static List<long> LongList => StrArr.Select(long.Parse).ToList();

        public static IEnumerable<long[]> TakeLine(int N)
        {
            return Enumerable.Repeat(0, N).Select(_ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray());
        }

        public static string NextWord()
        {
            while (!enumerator.MoveNext())
            {
                enumerator = StrArr.AsEnumerable().GetEnumerator();
            }
            return enumerator.Current;
        }
    }
}


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

struct SegmentTree {
    using T = int;
    static T op(const T& a, const T& b) { return min(a, b); }
    static constexpr T e() { return numeric_limits<int>::max(); }
    const int n;
    vector<T> t;
    SegmentTree(int _n) : n(_n), t(2 * n, e()) {}
    T& operator[](int i) { return t[i + n]; }
    T query(int l, int r) const {
        T resl = e(), resr = e();
        for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
            if (l & 1) resl = op(resl, t[l++]);
            if (r & 1) resr = op(t[--r], resr);
        }
        return op(resl, resr);
    }
    void update(int i, const T& a) {
        t[i += n] = a;
        while (i >>= 1) t[i] = op(t[2 * i], t[2 * i + 1]);
    }
};

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

    int n;
    cin >> n;
    vector<pair<int, int>> as;
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        as.emplace_back(a, b);
    }
    sort(as.begin(), as.end());
    SegmentTree seg(n);
    for (int i = 0; i < n; i++) {
        seg.update(i, as[i].second);
    }

    int ans = 0;
    for (int i = 1; i < n; i++) {
        int ll = as[i - 1].first;
        int lr = seg.query(0, i);
        int L = max(lr - ll + 1, 0);
        int rl = as[n - 1].first;
        int rr = seg.query(i, n);
        int R = max(rr - rl + 1, 0);
        ans = max(ans, L + R);
    }

    sort(as.rbegin(), as.rend(), [](auto& a, auto& b) { return a.second - a.first < b.second - b.first; });
    int L = 0, R = 1e9;
    for (int i = 1; i < n; i++) {
        L = max(L, as[i].first);
        R = min(R, as[i].second);
    }
    cout << max(ans, as[0].second - as[0].first + 1 + max(R - L + 1, 0)) << endl;
}


Measured memory_bytes: 2036
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<array>
#include<bitset>
#include<cmath>

using namespace std;

#define square(s) ((s)*(s))
#define scast(type,e) static_cast<type>(e)
#define rep(i,n) for(decltype(n) i = 0; i < n;i++)
#define repp(i,s,u) for(decltype(s) i = s; i < u;i++)
#define range(a) a.begin(),a.end()
#define pr(l,r) make_pair((l),(r))
#define INF (1145141919)


template<class T>
using vec = vector<T>;
template<class T, size_t S>
using arr = array<T, S>;
template<class T1, class T2>
using pr = pair<T1, T2>;

using ll = long long;
using ull = unsigned long long;

template<class T>
void chmax(T& dest, const T& target) {
	dest = max(dest, target);
}
template<class T>
void chmin(T& dest, const T& with) {
	dest = min(dest, with);
}


int main() {
	int N, M;
	cin >> N >> M;
	vec<vec<int>> dist(N, vec<int>(N, 114514));
	vec<vec<int>> edge(N,vec<int>(N, -1));

	rep(i, M) {
		int a, b, c;
		cin >> a >> b >> c; a--; b--;
		dist[a][b] = c;
		dist[b][a] = c;
		edge[a][b] = c;
		edge[b][a] = c;
	}
	rep(i, N) {
		dist[i][i] = 0;
	}


	rep(i, N) {
		rep(j, N) {
			rep(k, N) {
				chmin(dist[j][k], dist[j][i] + dist[i][k]);
			}
		}
	}

	int cnt = 0;
	rep(i, N) {
		rep(j, i) {
			if (edge[i][j] != -1 && dist[i][j] < edge[i][j]) {
				cnt++;
			}
		}
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    string st;
    cin>>st;
    int n=st.size();
    string a;
    REP(i,n){
        if(!a.size()||a.back()==st[i]){
            a.push_back(st[i]);
        }else{
            a.pop_back();
        }
    }
    cout<<n-a.size()<<endl;
    return 0;
}

Measured memory_bytes: 640
N = int(input())
X = list(map(int,input().split()))
min_tairyoku_sum = float("inf")
for i in range(1,101):
    tairyoku_sum = 0
    for x in X:
        tairyoku_sum += (x - i) ** 2
    min_tairyoku_sum = min(tairyoku_sum, min_tairyoku_sum)
print(min_tairyoku_sum)

Measured memory_bytes: 3060
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int max = sc.nextInt();
    int min = max;
    for(int i = 1; i<n; i++) {
      int a = sc.nextInt();
      if(a > max){
        max = a;
      }
      if(a < min){
        min = a;
      }
    }
    System.out.println(max - min);
  }
}


Measured memory_bytes: 21972
# -*- coding: utf-8 -*-

import math

x = y = 0
tsum = 90
while True:
    d, t = map(int, raw_input().split(','))
    if d == t == 0:
        break
    x += math.cos(math.radians(tsum))*d
    y += math.sin(math.radians(tsum))*d
    tsum -= t
print int(x)
print int(y)

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

using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> q;
    for(int i=1; i<=n; i++) {
        if(n%i==0) q.push_back(i);
    }
    int size = q.size();
    if(size%2){
        if (q[size/2]<=9) {
            cout << "Yes" << endl;
            return 0;
        }
    } else {
        if (q[size/2]<=9 && q[size/2-1]<=9) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3628