akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 100;
pair<int, int> red[MAXN];
pair<int, int> blue[MAXN];

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> red[i].first >> red[i].second;
    for (int i = 0; i < n; i++)
        cin >> blue[i].first >> blue[i].second;
    sort(red, red + n);
    sort(blue, blue + n);
    int ptr1 = 0;
    int ptr2 = 0;
    vector<pair<int, int>> vec;
    int ans = 0;
    while (ptr1 < n)
    {
        pair<int, int> pt = blue[ptr1];
        while (ptr2 < n && red[ptr2].first < pt.first)
        {
            vec.push_back(red[ptr2]);
            ptr2++;
        }
        int maxY = -1;
        auto loc = vec.begin();
        for (auto it = vec.begin(); it != vec.end(); it++)
        {
            pair<int, int> pr = *it;
            if (pr.second <= pt.second && pr.second > maxY)
            {
                maxY = max(maxY, pr.second);
                loc = it;
            }
        }
        if (maxY != -1)
        {
            ans++;
            vec.erase(loc);
        }
        ptr1++;
    }
    cout << ans << endl;
    return 0;
}


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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define repp(i, start, to) for (li i = (li)(start); i < ((li)(to)); i++)
#define allof(v) (v).begin(), (v).end()

int main(void)
{
	li n;
	cin >> n;

	bool res = false;
	rep(i, 26) {
		if ((n - 4 * i) < 0)break;
		if ((n - 4 * i) % 7 == 0) {
			res = true;
		}
	}
	cout << (res ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
import collections

N,K = map(int, input().split())
arr = list(map(int, input().split()))
c = collections.Counter(arr)

counts = list(c.values())[::-1]

if len(counts)==1:
  print(0)
else:
  value = 0
  for num in arr:
    value += len([1 for x in arr if x<num])
  out_arr = value*K*(K-1)//2
  
  in_arr = 0
  for j,num in enumerate(arr):
    in_arr += len([1 for x in arr[j+1:] if x<num])
  in_arr = in_arr*K
  print((out_arr+in_arr)%1000000007)
  
  
  

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


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    vector<ll> x(n),y(n),h(n);
    rep(i,n)cin>>x[i]>>y[i]>>h[i];
    ll ansx,ansy,ansh;
    rep(cx,101)rep(cy,101){
        ll H=0;
        bool flag = true;
        rep(i,n){
            if(h[i]==0)continue;
            ll HH = h[i]+abs(x[i]-cx)+abs(y[i]-cy);
            if(H!=0&&H!=HH){flag=false;break;}
            H=HH;
        }
        if(!flag)continue;
        rep(i,n){
            if(h[i]!=0)continue;
            ll HH = H-abs(x[i]-cx)-abs(y[i]-cy);
            if(HH>0){flag=false;break;}
        }
        if(!flag)continue;
        ansx=cx;
        ansy=cy;
        ansh=H;
        break;
    }
    cout<<ansx<<" "<<ansy<<" "<<ansh;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX 1000005
#define ll long long
#define upperlimit 1000100
#define INF 1e18
#define eps 1e-8
#define endl '\n'
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define MOD 1000000007
#define slld(t) scanf("%lld",&t)
#define sd(t) scanf("%d",&t)
#define pd(t) printf("%d\n",t)
#define plld(t) printf("%lld\n",t)
#define mp(a,b) make_pair(a,b)
#define FF first
#define SS second
#define pb(x) push_back(x)
#define vi vector<int>
#define vll vector<ll>
#define clr(a) memset(a,0,sizeof(a))
#define debug(a) printf("check%d\n",a)
#define csl ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
 
ll gcd(ll n1,ll n2){
	if(n2==0)
		return n1;
	if(n1%n2==0)return n2;
	return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent)
{
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%MOD;
		base=(base*base)%MOD;
		exponent/=2;
	}
	return ans;
}
int arr[MAX];
int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>arr[i];
	sort(arr,arr+n);
	int g=0;
	for(int i=0;i<n;i++)
	{
		g=gcd(g,arr[i]);
	}
	if(k<=arr[n-1]&&k%g==0)
	{
		cout<<"POSSIBLE"<<endl;
	}
	else
		cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#include <string.h>
#include <vector>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a; i<n; i++)
#define r0 return 0
#define INF (int)1e15
#define MOD 1000000007

 int main(){

  int x;
  cin>>x;

 while(true){

  bool is_prime = true;

   for(int i=2,n=x;i<n;i++){
     if(x%i == 0){
        is_prime = false;
        break; }
   }

    if(is_prime)
    break;
    else
        x++;

 }

 cout<<x<<endl;

 return 0;
 }


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

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int n;
  scanf("%d",&n);
  int *a=(int *)calloc(n,sizeof(int));
  int i;
  for(i=0;i<n;i++) scanf("%d",a+i);
  int64 p=0;
  int64 q=a[0]+a[1];
  int64 r=0;
  int64 s=0;
  for(i=2;i<n;i++) s+=a[i];
  int64 min=1000000000LL*n;
  int j=0;
  int k=2;
  for(i=2;i<n-1;i++){
    while(j<i-1 && ABS(p-q)>ABS((p+a[j])-(q-a[j]))){
      p+=a[j];
      q-=a[j];
      j++;
    }
    while(k<n-1 && ABS(r-s)>ABS((r+a[k])-(s-a[k]))){
      r+=a[k];
      s-=a[k];
      k++;
    }
    min=MIN(min,MAX(p,MAX(q,MAX(r,s)))-MIN(p,MIN(q,MIN(r,s))));
    q+=a[i];
    r-=a[i];
  }
  printf("%lld\n",min);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <cstdint>
#include <vector>

using namespace std;

uint32_t merge(uint32_t* A, const uint32_t left, const uint32_t mid, const uint32_t right);
uint32_t mergeSort(uint32_t* A, const uint32_t left, const uint32_t right);

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

	uint32_t n;
	vector<uint32_t> A;
	cin >> n;
	A.reserve(n);
	uint32_t input;
	for(uint32_t i = 0; i < n; i++) {
		cin >> input;
		A.push_back(input);
	}
	uint32_t compareCount = mergeSort(A.data(), 0, A.size());
	for(uint32_t i = 0; i < n; i++) {
		cout << A[i] << ((i == n - 1) ? "\n" : " ");
	}
	cout << compareCount << endl;

	return 0;
}

uint32_t merge(uint32_t* A, const uint32_t left, const uint32_t mid, const uint32_t right) {
	const uint32_t n1 = mid - left;
	const uint32_t n2 = right - mid;
	uint32_t L[n1 + 1], R[n2 + 1];
	uint32_t count = 0;

	for(uint32_t i = 0; i < n1; i++) {
		L[i] = A[left + i];
	}
	for(uint32_t i = 0; i < n2; i++) {
		R[i] = A[mid + i];
	}
	L[n1] = (uint32_t)-1;
	R[n2] = (uint32_t)-1;

	uint32_t i = 0;
	uint32_t j = 0;
	for(uint32_t k = left; k < right; k++) {
		if(L[i] <= R[j]) {
			A[k] = L[i];
			i++;
		} else {
			A[k] = R[j];
			j++;
		}
		count++;
	}
	return count;
}

uint32_t mergeSort(uint32_t* A, const uint32_t left, const uint32_t right) {
	uint32_t count = 0;
	if(left + 1 < right) {
		uint32_t mid = (left + right) / 2;
		count += mergeSort(A, left, mid);
		count += mergeSort(A, mid, right);
		count += merge(A, left, mid, right);
	}
	return count;
}



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

void insertSort(vector<int> &A, int N, int g, int &cnt) {
	for (int i = g; i < N; i++) {
		int v = A[i];
		int j = i - g;
		while (j >= 0 && A[j] > v) {
			A[j + g] = A[j];
			j = j - g;
			A[j + g] = v;
			cnt++;
		}
		A[j + g] = v;
	}
}

void shellSort(vector<int> &A, int n ) {
	int cnt = 0;
	int m = 1;
	int s = n-1;
	while ( s/2 > 1) {
		m++;
		s = s / 2;
	}

	cout << m << endl;

	vector<int> g(m);
	for (int i = 0; i < m; i++) {
		if (i == 0) g[i] = 1;
		else if (i == 1) g[i] = 4;
		else {
			g[i] = g[i - 1] * 2;
		}
	}
	for (int i = 0; i < m; i++) {
		if (i == m - 1) cout << g[m - i - 1] << endl;
		else cout << g[m - i - 1] << " ";
		insertSort(A, n, g[m - i - 1], cnt);
	}
	cout << cnt << endl;
	for (int i = 0; i < n; i++) {
		cout << A[i] << endl;
	}

}

int main() {
	int N; cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	shellSort(A, N);
}


Measured memory_bytes: 6680
sx,sy,tx,ty=map(int,input().split())

r1=["R"]*(tx-sx)

r1.append("U"*(ty-sy))

r1.append("L"*(tx - sx))

r1.append("D"*(ty - sy))

r1.append("D")

r1.append("R"*(tx-sx+1))

r1.append("U"*(ty-sy+1))

r1.append("LU")

r1.append("L"*(tx-sx+1))

r1.append("D"*(ty-sy+1))

r1.append("R")

print("".join(r1))


Measured memory_bytes: 3064
#
# smbc2019 d
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """4
0224"""
        output = """3"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """6
123123"""
        output = """17"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """19
3141592653589793238"""
        output = """329"""
        self.assertIO(input, output)


def resolve():
    N = int(input())
    S = input()

    ans = 0
    o = []
    for i in range(10):
        ip = S.find(str(i))
        if ip >= N-2 or ip == -1:
            continue
        for j in range(10):
            jp = S[ip+1:].find(str(j))
            if jp == -1:
                continue
            if ip + 1 + jp >= N-1:
                continue
            jp += ip+1
            for k in range(10):
                kp = S[jp+1:].find(str(k))
                if kp == -1:
                    continue
                t = str(i)+str(j)+str(k)
                if t not in o:
                    ans += 1
                    o.append(t)
    print(ans)


if __name__ == "__main__":
     # unittest.main()
     resolve()


Measured memory_bytes: 16368
import java.util.Scanner;

//Surrounding Area
public class Main{

	int w, h;
	char[][] m;
	int[][] move = {{-1,0}, {0,1}, {1,0}, {0,-1}};
	boolean[][] white, black;

	void fw(int i, int j){
		if(white[i][j]||m[i][j]!='.')return;
		white[i][j] = true;
		for(int k=0;k<4;k++){
			int ni = i+move[k][0], nj = j+move[k][1];
			if(0<=ni&&ni<h&&0<=nj&&nj<w)fw(ni, nj);
		}
	}
	void fb(int i, int j){
		if(black[i][j]||m[i][j]!='.')return;
		black[i][j] = true;
		for(int k=0;k<4;k++){
			int ni = i+move[k][0], nj = j+move[k][1];
			if(0<=ni&&ni<h&&0<=nj&&nj<w)fb(ni, nj);
		}
	}

	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			w = sc.nextInt(); h = sc.nextInt();
			if((w|h)==0)break;
			m = new char[h][];
			for(int i=0;i<h;i++)m[i]=sc.next().toCharArray();
			white = new boolean[h][w]; black = new boolean[h][w];
			for(int i=0;i<h;i++)for(int j=0;j<w;j++){
				if(m[i][j]=='W'){
					for(int k=0;k<4;k++){
						int ni = i+move[k][0], nj = j+move[k][1];
						if(0<=ni&&ni<h&&0<=nj&&nj<w)fw(ni, nj);
					}
				}
				if(m[i][j]=='B'){
					for(int k=0;k<4;k++){
						int ni = i+move[k][0], nj = j+move[k][1];
						if(0<=ni&&ni<h&&0<=nj&&nj<w)fb(ni, nj);
					}
				}
			}
			int cw = 0, cb = 0;
			for(int i=0;i<h;i++)for(int j=0;j<w;j++){
				if(m[i][j]!='.'||white[i][j]&&black[i][j]||!white[i][j]&&!black[i][j])continue;
				if(white[i][j])cw++;
				else cb++;
			}
			System.out.println(cb+" "+cw);
		}
	}

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

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define speedio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;

typedef long long       ll;
typedef long double     ld;

typedef vector<int>     vi;
typedef vector<bool>    vb;
typedef vector<ll>      vll;
typedef vector<vi>      vvi;
typedef vector<vll>     vvll;
typedef vector<string>  vs;

typedef pair<int, int>  pii;
typedef pair<ll, int>   pli;
typedef pair<ll, ll>    pll;
typedef vector< pii >   vpi;
typedef vector< pll >   vpll;

// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;

#define pb           push_back
#define mod          1000000007
#define INF          1e17
#define mini         INT_MIN
#define maxo         INT_MAX
#define eb           emplace_back
#define ff           first
#define ss           second
#define re           return 
#define endl         "\n" 

#define all(c)       c.begin(),c.end()
#define be           begin()
#define en           end()
#define sz(x)        (ll)x.size()
#define mem(a,val)   memset(a,val,sizeof(a))
#define mk(x,y)      make_pair(x,y)
#define mid(s,e)     ((s)+((e)-(s))/2) 

#define fo(i,a,b)     for(ll i = (ll)(a); i <= (ll)(b); i++)
#define rf(i,a,b)    for(ll i = (ll)(a); i >= (ll)(b); i--)
#define read(a,n)    for(int i=0;i<n;i++)cin>>a[i];
#define show(a,n)    for(int i=0;i<n;i++)cout<<a[i]<<' ';cout<<endl;
#define p2(n)        (1LL << (n))
#define deb(x) cout <<#x << " = " << x << " | " << "LINE: "<<__LINE__<< endl;
template<typename... T> void rd(T&... args) { ((cin >> args), ...); }
template<typename... T> void pp(T... args) { ((cout << args << " "), ...); cout<<"\n"; }

void add(ll &x, ll y){ x += y; if(x>=mod) x %= mod; if(x<0) x = x%mod + mod; }

//============== *** START OF CODE ***


const ll maxn = 2e5+5;
ll ans = -1e17;
ll a[maxn]; 

unordered_map<string,ll> mp;

ll go(int n,int left){
    if(left==0) re 0;
    if(n==1) re a[1];
    if(n==2) re max(a[1],a[2]);
    string temp = to_string(n) + "|" + to_string(left);
    if(mp.count(temp))return mp[temp];

    if(n&1 and left==(n+1)/2) return mp[temp] = a[n]+go(n-2,left-1);
    return mp[temp]=max(a[n]+go(n-2,left-1),go(n-1,left));
}
void solve()
{
    int n;rd(n);   
    read((a+1),n);
   
    ans = go(n,n/2);
    pp(ans);
}


void prep(){}

//=============== *** END OF CODE ***

int main(){
    speedio; cout<<fixed<<setprecision(12);

// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif

    prep();
    int t = 1;
    // cin >> t;
    while(t--)
        solve();

    return 0;
}

Measured memory_bytes: 48004
n = int(input())
a = sorted(list(map(int,input().split())))
b = a[:]
for i in range(1,n):
  b[i] = b[i]+b[i-1]

a = a[::-1]
b = b[::-1]

cnt=1
for i in range(1,n):
  if b[i]*2>=a[i-1]:
    cnt+=1
  else:
    break
print(cnt)

Measured memory_bytes: 20236
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc;

	static final int INF=1<<28;
	static final double EPS=1e-9;

	void run(){
		sc=new Scanner(System.in);
		for(;;){
			int n=sc.nextInt();
			if(n==0)
				break;
			int[] a=new int[n];
			for(int i=0; i<n; i++)
				a[i]=sc.nextInt();
			int ans=Integer.MIN_VALUE;
			for(int i=0; i<n; i++){
				int sum=0;
				for(int j=i; j<n; j++){
					ans=max(ans, sum+=a[j]);
				}
			}
			println(ans+"");
		}
		sc.close();
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

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

Measured memory_bytes: 13000
# 整数 N が与えられます。ここで、2 つの正の整数 A,B に対して、
# F(A,B) を「10 進表記における、A の桁数と B の桁数のうち大きい方」と定義します。
# 例えば、F(3,11) の値は、3 は 1 桁、11 は 2 桁であるため、F(3,11)=2 となります。
# 2 つの正の整数の組 (A,B) が N=A×B を満たすように動くとき、F(A,B) の最小値を求めてください。

n = gets.to_i

def comparison(i, j)
    return  i.to_s.length >= j.to_s.length ? i.to_s.length : j.to_s.length
end

if Math.sqrt(n) % 1 == 0
    puts Math.sqrt(n).to_i.to_s.length
else
    num = Math.sqrt(n).to_i
    while n % num != 0
        num -= 1
    end
    puts (n / num).to_s.length >= num.to_s.length ? (n / num).to_s.length : num.to_s.length
end

Measured memory_bytes: 1788
//start of jonathanirvings' template v3.0.3 (BETA)

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

typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<LL> vl;
typedef vector<vl> vvl;

double EPS = 1e-9;
int INF = 1000000005;
long long INFF = 1000000000000000005LL;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

#ifdef TESTING
  #define DEBUG fprintf(stderr,"====TESTING====\n")
  #define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
  #define debug(...) fprintf(stderr, __VA_ARGS__)
#else
  #define DEBUG 
  #define VALUE(x)
  #define debug(...)
#endif

#define FOR(a,b,c) for (int (a)=(b);(a)<(c);++(a))
#define FORN(a,b,c) for (int (a)=(b);(a)<=(c);++(a))
#define FORD(a,b,c) for (int (a)=(b);(a)>=(c);--(a))
#define FORSQ(a,b,c) for (int (a)=(b);(a)*(a)<=(c);++(a))
#define FORC(a,b,c) for (char (a)=(b);(a)<=(c);++(a))
#define FOREACH(a,b) for (auto &(a) : (b))
#define REP(i,n) FOR(i,0,n)
#define REPN(i,n) FORN(i,1,n)
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define SQR(x) ((LL)(x) * (x))
#define RESET(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(),v.end()
#define ALLA(arr,sz) arr,arr+sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr,sz) sort(ALLA(arr,sz))
#define REVERSEA(arr,sz) reverse(ALLA(arr,sz))
#define PERMUTE next_permutation
#define TC(t) while(t--)

inline string IntToString(LL a){
  char x[100];
  sprintf(x,"%lld",a); string s = x;
  return s;
}

inline LL StringToInt(string a){
  char x[100]; LL res;
  strcpy(x,a.c_str()); sscanf(x,"%lld",&res);
  return res;
}

inline string GetString(void){
  char x[1000005];
  scanf("%s",x); string s = x;
  return s;
}

inline string uppercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'a' && s[i] <= 'z') s[i] = s[i] - 'a' + 'A';
  return s;
}

inline string lowercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
  return s;
}

inline void OPEN (string s) {
  #ifndef TESTING
  freopen ((s + ".in").c_str (), "r", stdin);
  freopen ((s + ".out").c_str (), "w", stdout);
  #endif
}

//end of jonathanirvings' template v3.0.3 (BETA)

int n;
int data[200005];
LL jum;

int main()
{
  scanf("%d",&n);
  REP(i,n)
  {
    scanf("%d",&data[i]);
    jum += data[i];
  }
  LL risan = INFF;
  LL now = 0;
  REP(i,n-1)
  {
    now += data[i];
    MIN(risan,llabs(now - (jum - now)));
  }
  printf("%lld\n",risan);
  return 0;
}










Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTG(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define ENDL cout << endl;
using namespace std;
using ll = long long;
using ld = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VI = vector<int>;
using VVI = vector<VI>;
using Vll = vector<ll>;
using VVll = vector<Vll>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const ll rem = 200;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N, A;
  cin >> N >> A;
  Vll x(N+1);
  ll X = A;
  REP2(i, 1, N+1)
  {
    cin >> x[i];
    X = max(X, x[i]);
    x[i] -= A;
  }
  VVll dp(N+1, Vll(2*N*X+1, 0));
  dp[0][N*X] = 1;
  REP2(j, 1, N+1) REP(t, 2*N*X+1)
  {
    dp[j][t] = dp[j-1][t];
    if (t - x[j] < 0 || t - x[j] > 2*N*X) continue;
    dp[j][t] += dp[j-1][t-x[j]];
  }
  cout << dp[N][N*X] - 1 << endl;

  return 0;
}

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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    string s;
    char ch;
    cin >> n >> k;
    cin >> s;

    for(int i = 0; i < n; i++){
        if(i+1 == k){
            ch = tolower(s[i]);
            cout << ch;
        }
        else{
            cout << s[i];
        }
    }



    return 0;
}


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

typedef struct Process{
	string name;
	int time;
	Process(string n,int t){ 
		name = n; 
		time = t;
	};
	Process() {
		name = " ";
		time = 0;
	};
};

template<class Type> class Queue{
private:
	int head=0, tail=0;
	Type queue[100009];
public:
	Queue( ) { }; 
	
	void push(const Type& p) {
		queue[tail] = p;
		tail++;
		tail=(tail+1) % 100009;
	}

	Type pop() {
		Type x = queue[head];
		head++;
		head=(head+1)%100009;
		return x;
	}

	Type front() {
		return queue[head];
	}

};

int main() {
	int n, q,allTime=0;
	cin >> n >> q;
	Process p;
	Queue<Process> Q;
	for (int i = 0;i < n;i++) {
		cin >> p.name; cin >> p.time;
		Q.push(p);
	}
	while (n>0) {
		if (Q.front().time <= q) {
			allTime+=Q.front().time;
			cout << Q.front().name << " " <<allTime<< endl;
			Q.pop();
			n--;
		}
		else {
			allTime += q;
			Q.push(Process(Q.front().name,Q.front().time-q));
			Q.pop();
		}
	}

}

Measured memory_bytes: 9432
#include<stdio.h>

    int main(){
    	int A,B,C,D,left=0,right=0;

    	scanf("%d %d %d %d",&A,&B,&C,&D);

    	left=A+B;
    	right=C+D;
    	if(left>right){
                printf("Left\n");
        }
    	else if(left==right){
                printf("Balanced\n");
        }
    	else{
                printf("Right\n");
        }

    	return 0;
    }


Measured memory_bytes: 128
n = gets.to_i
as = gets.chomp.split.map(&:to_i)
as.unshift(0);as.push(0);
sum = as.each_cons(2).map{|a,b| (a-b).abs}.inject(:+)
(1..n).each do |i|
	ans = sum
	ans -= (as[i-1] - as[i]).abs
	ans -= (as[i+1] - as[i]).abs
	ans += (as[i+1] - as[i-1]).abs
	puts ans
end

Measured memory_bytes: 13316
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    vector<pair<int, int>> Aidx(N + 1);
    rep(i, N) {
        Aidx[i] = { A[i], i };
    }
    Aidx[N] = { 0, 0 };
    sort(all(Aidx), [](auto&& l, auto&& r) { return l.first == r.first ? l.second < r.second : l.first > r.first; });

    vector<ll> ans(N);
    for (int i = 0, j, k; i < N; i = j) {
        ll sum = 0;

        for (j = i; j < N && Aidx[j].second >= Aidx[i].second; ) {
            for (k = j + 1; k <= N; ++k) {
                if (Aidx[k].first != Aidx[j].first) break;
            }

            sum += (ll)k * (Aidx[j].first - Aidx[k].first);

            j = k;
        }

        ans[Aidx[i].second] = sum;
    }

    for (ll a : ans) {
        write(a);
    }
}

Measured memory_bytes: 3072
a,b,c=list(map(int,input().split()))
if a == b and a == c and a % 2 == 0:
    ans = -1
else:
    ans = int(0)
    while a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
        ta = b/2 + c/2
        tb = a/2 + c/2
        tc = a/2 + b/2
        a = ta
        b = tb
        c = tc
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};

int main() {
  int H, N;
  cin >> H >> N;
  vector<int> A(N), B(N);
  for (int i=0; i<N; i++) cin >> A[i] >> B[i];
  vector<vector<ll>> dp(N+1, vector<ll>(H+1, INT_MAX));
  dp[0][0] = 0;
  for (int i=0; i<N; i++) {
    for (int j=0; j<=H; j++) {
      dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
      dp[i+1][min(j+A[i], H)] = min(dp[i+1][min(j+A[i], H)], dp[i+1][j]+B[i]);
    }
  }
  cout << dp[N][H] << endl;
  return 0;
}

Measured memory_bytes: 81648
/* コイン問題 */

#include <stdio.h>

int main(void)
{
	int n, m;
  int coin[20];
  int num[50001];
  int i, j, new_num;

  scanf("%d %d", &n, &m);
  for (i = 0; i < m; i++) {
    scanf("%d", &coin[i]);
  }

	for (i = 0; i < n + 1; i++) {
    num[i] = i;
  }

  /* 扱うコインの種類を１枚ずつ増やしていく */
  for (i = 1; i < m; i++) {
    /* 払うお金がj円のときに、コインiで払ってみる */
		for (j = coin[i]; j < n + 1; j++) {
      /* コインiで払ってみた時、コインの枚数がどう変わるか */
      new_num = num[j - coin[i]] + 1;

      if (new_num < num[j]) {
        num[j] = new_num;
      }
    }
  }

  printf("%d\n", num[n]);

  return 0;
}

Measured memory_bytes: 792
#include<bits/stdc++.h>
using namespace std;
#define  vi vector<long long int>
#define  set1 set<long long int>
#define  pb push_back
#define  map1 map<long long int,long long int>
#define  ll long long int
#define  mp make_pair
#define  inf 1e17
#define  minf INT_MIN
#define  setbits(x) __builtin_popcountll(x)
#define  pres(x,y) fixed<<setprecision(y)<<x
#define  pair1 pair<long long int,long long int>
#define  mk(arr,n,type) type *arr=new type[n];
#define  mod 1000000007
#define  pi  3.1415926535897932384626433832
#define  ins insert
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
//find_by_order() --> returns an iterator to the k-th largest element (counting from zero)
//order_of_key()  --> the number of items in a set that are strictly smaller than our item.
#define  w(t) long long int t;t=1;while(t--)

ll dp[100005];


ll solve1(ll a[], ll i) {


	if (i == 1) {
		return 0;
	}

	if (dp[i] != -1) {
		return dp[i];
	}

	ll opt1 = abs(a[i] - a[i - 1]) + solve1(a, i - 1);
	ll opt2 = (i == 2) ? inf : abs(a[i] - a[i - 2]) + solve1(a, i - 2);
	return dp[i] = min(opt1, opt2);

}
void solve() {

	ll n;
	cin >> n;
	ll a[n + 1];
	for (ll i = 1; i <= n; i++) {
		cin >> a[i];
	}
	memset(dp, -1, sizeof(dp));
	cout << solve1(a, n);

}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("inp.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	w(t) {
		solve();
	}
	return 0;
}

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

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; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

int main() {
    int X,Y,A,B,C; cin>>X>>Y>>A>>B>>C;
    vector<ll> red(A),green(B),mu(C);
    for (int i = 0; i < A; ++i) {
        cin>>red[i];
    }
    for (int i = 0; i < B; ++i) {
        cin>>green[i];
    }
    for (int i = 0; i < C; ++i) {
        cin>>mu[i];
    }

    sort(red.rbegin(),red.rend());
    sort(green.rbegin(),green.rend());
    sort(mu.rbegin(),mu.rend());

    ll ans=0ll;
    for (int i = 0; i < X; ++i) {
        ans+=(ll)red[i];
    }
    for (int i = 0; i < Y; ++i) {
        ans+=(ll)green[i];
    }

    int itrr=X-1,itrg=Y-1;




    for (int i = 0; i < min(C,X+Y); ++i) {
        //cout<<i<<" "<<red[itrr]<<" "<<green[itrg]<<endl;
        bool swap= false;
        if(itrr==-1){
            if(mu[i]>green[itrg]){
                ans+=(ll)mu[i]-green[itrg];
                itrg--;
            }else break;
        }else if(itrg==-1){
            if(mu[i]>red[itrr]){
                ans+=(ll)mu[i]-red[itrr];
                itrr--;
            }else break;
        }else {
            if (red[itrr] < green[itrg]) {
                if (mu[i] > red[itrr]) {
                    ans += (ll) mu[i] - red[itrr];
                    itrr--;
                } else break;
            } else {
                if (mu[i] > green[itrg]) {
                    ans += (ll) mu[i] - green[itrg];
                    itrg--;
                } else break;
            }
        }
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int ar[n];
    for (int i=0;i<n;i++)
    {
        cin>>ar[i];
    }
    sort(ar,ar+n);
    int m=0;
    for (int i=n-1;i>=0;i--)
    {
        if (i%2==0)m+=ar[i];
        else m-=ar[i];
    }
    printf ("%d\n",max(m,-m));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef DEBBY
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define ll long long
#define rep(i,a,b) for(int i=int(a); i<=int(b); i++)
#define sz(v)  (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pi>
#define fs first
#define sd second
#define pb push_back

void solve(){
    int k,x;
    cin >> k >> x;
    rep(i,x-k+1,x+k-1)
        cout << i << " ";
     
    
} 

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}
    





Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx2,tune=native")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("trapv")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using pi = pair<ll, ll>;
const ll mod = 7 * 17 * (1 << 23) + 1;
const ll inf = 1e18;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() { //DINIC ORZ
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	int ok = 0;
	for(int i = 1; i <= 9; i++)
		for(int j = 1; j <= 9; j++)
			if(i*j==n) ok = 1;
	cout << (ok?"Yes":"No");
}


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


int main()
{
    int K;
    string S;
    cin >> K >> S;
    if(S.size() <= K){
        cout << S << endl;
    }else{
        cout << S.substr(0, K) << "..." << endl;
    }
}

Measured memory_bytes: 3632
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const ll INF=1ll<<50;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;

int h,w;
vvc a;

int main(){
	cin>>h>>w;
	a=vvc(h,vc(w));
	for(int i=0;i<h;i++) for(int j=0;j<w;j++) cin>>a[i][j];
	int x=0,y=0;
	if(a[x][y]=='#') a[0][0]='.';
	else{
		cout<<"Impossible"<<endl;
		return 0;
	}
	for(int i=2;i<h+w;i++){
		if(x+1<h&&a[x+1][y]=='#'){
			a[x+1][y]='.';
			x++;
		}
		else if(y+1<w&&a[x][y+1]=='#'){
			a[x][y+1]='.';
			y++;
		}
		else{
			cout<<"Impossible"<<endl;
			return 0;
		}
	}
	for(int i=0;i<h;i++) for(int j=0;j<w;j++){
		if(a[i][j]=='#'){
			cout<<"Impossible"<<endl;
			return 0;
		}
	}
/*	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++) cout<<a[i][j];
		cout<<endl;
	}*/
	cout<<"Possible"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

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


signed main(void) {
    int n;
    cin >> n;
    vi a(n);
    rep(i,n)cin >> a[i];
    int ma = 0;
    rep(i,n)if(abs(a[ma]) < abs(a[i]))ma = i;
    vp v;
    rep(i,n)if(i!=ma){
        v.push_back(pii(ma,i));
        a[i] += a[ma];
    }
    //rep(i,n)cout << " " << a[i];cout << endl;
    if(a[ma] > 0){
        rep(i,n-1){
            v.push_back(pii(i,i+1));
            a[i+1] += a[i];
        }
    }else{
        for(int i = n-1; i > 0; i--){
            v.push_back(pii(i,i-1));
            a[i-1] += a[i];
        }
    }
    cout << v.size() << endl;
    rep(i,v.size())cout << v[i].first+1 << " " << v[i].second+1 << endl;
    //rep(i,n)cout << " " << a[i];cout << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
char s[200];
int l,i,cnt[30],ans,k,now,a[200];
int main()
{
	scanf("%s",s);
	l=strlen(s);
	for (i=0;i<l;i++)
	{
		cnt[s[i]-'a'+1]++;
	}
	ans=l;
	for (k=1;k<=26;k++)
	{
		if (cnt[k]>=1)
		{
			now=0;
			for (i=0;i<l;i++)
			{
				if (s[i]-'a'+1==k) a[++now]=i;
			}
			int c=0,d=l;
			while (c<d)
			{
				int mid=(c+d)/2;
				bool flag=1;
				int m=1;
				for (i=0;i<l-mid;i++)
				  {
				  	if (s[i]-'a'+1==k) continue;
				  	while (i>a[m]&&m<=now) m++;
				  	if (m>now)
				  	{
				  		flag=0;
				  		break;
					}
				  	if (i+mid<a[m]) 
				  	{
				  		flag=0;
				  		break;
				    }
				  }
				if (flag) d=mid;
				else c=mid+1;
			}
			if (c<ans) ans=c;
		}
	}
	printf("%d\n",ans);
}
//xxxaxxxxxaxxxxaaaxxx
//axxx
///xxxxaxxxxxa

Measured memory_bytes: 128
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();
  
function main(){
  var read = 0;
  var resultCase = 1;
  while(true){
    var maxWeight = +input[read++];
    if(!maxWeight){
      break;
    }
      
    var treasures = +input[read++];
    var pdp = new Int16Array(maxWeight + 1);
    for(var i = treasures; i--;){
      var c = input[read++].split(",");
      var tv = +c[0];
      var tw = +c[1];
  
      var dp = new Int16Array(maxWeight + 1);
      for(var w = 1; w <= maxWeight; w++){
        var pdpw = pdp[w];
        dp[w] = (w-tw < 0) ? pdpw : max(pdp[w-tw] + tv, pdpw);
      }
      pdp = dp;
    }
  
    var resultWeight = 1001;
    var resultCost = 0;
    for(var i = 0; i <= maxWeight; i++){
      var pdpi = pdp[i];
      if(pdpi > resultCost){
        resultCost = pdpi;
        resultWeight = i;
      }
    }
      
    console.log("Case " + resultCase++ + ":\n" + resultCost + "\n" + resultWeight);
  }
}
 
 
function max(a, b) {
  var t = a - b;
  return a - (t & (t >> 31));
}

Measured memory_bytes: 12380
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
//#include"testlib.h"
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define sz(s)    (int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	//freopen("street.in", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}
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...);
}


int main() {
	file();
	fast();
	int n, m, x;
	cin >> n >> m >> x;
	vector<vi> v1(n);
	for (auto& it : v1) {
		int c; cin >> c;
		for (int j = 0; j < m; j++) {
			int x; cin >> x;
			it.push_back(x);
		}
		it.push_back(c);
	}
	int ans = INT_MAX;
	for (int i = 0; i < (1 << n); i++) {
		vi tmp(m);
		int cnt = 0;
		for (int j = 0; j < n; j++) {
			if (!(i & (1 << j))) continue;
			cnt += v1[j].back();
			for (int k = 0; k < m; k++)
				tmp[k] += v1[j][k];
		}
		bool ok = 1;
		for (auto& it : tmp) 
			if (it < x) ok = 0;
		if (ok) ans = min(cnt, ans);
	}
	cout << (ans == INT_MAX ? -1 : ans) << endl;
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main(){
    int a,b,c,d,p;
    cin>>a>>b>>c>>d>>p;
    int A=a*p;
    int B=b+((p<=c)?0:(p-c)*d);
    cout<<((A>B)?B:A)<<endl;
    
    return 0;
}



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

using namespace std;

const int N = 12;

vector < int > a[N];
int p[N];

main(){

    int n , m;

    scanf("%d %d" , &n , &m);

    for(int i = 0 ; i < m ; i ++){
        int k;
        scanf("%d" , &k);
        for(int j = 0 ; j < k ; j ++){
            int x;
            scanf("%d" , &x);
            a[i].push_back(x-1);
        }
    }
    for(int i = 0 ; i < m ; i ++)scanf("%d" , &p[i]);

    int ans = 0;
    for(int mask = 0 ; mask < (1 << n) ; mask ++){
        int on = 0;
        for(int i = 0 ; i < m ; i ++){
            int sum = 0;
            for(auto A : a[i])if(mask & (1 << A))sum ++;
            if(sum % 2 == p[i])on ++;
        }
        if(on == m)ans ++;
    }

    printf("%d\n" , ans);

    return 0;
}



Measured memory_bytes: 256
a[100],l,r,p,n;main(c){for(;l=scanf("%d",&r)*r;printf("%d\n",c)){for(;c=l;)scanf("%d",a+--l);for(scanf("%d",&n);l<r&&!++c|a[p=l+r>>1]-n;)a[p]<n?r=p:(l=p+1);}exit(0);}

Measured memory_bytes: 0
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define RALL(x) (x).rbegin(), (x).rend()
# define SZ(x) ((int)(x).size())
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define debug(x) std::cerr<<#x<<": "<<(x)<<endl;
using namespace std;
using lint = long long;
template<class T> using grid = vector<vector<T>>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
static const lint MOD = (lint)1e9+7;

vector<int> divisors(int a, int b) {
    vector<int> res;
    int c = a;
    if (a > b)
    {
        c = b;
    }
    for (int i = 1; i*i <= c; ++i)
    {
        if (a%i == 0 && b%i == 0)
        {
            res.push_back(i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}
map< lint, lint > prime_factor(lint n) {
  map< lint, lint > ret;
  for(lint i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

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

    map<lint, lint> Amp = prime_factor(A);
    map<lint, lint> Bmp = prime_factor(B);

    lint cnt = 0 + 1;
    for (auto& ap : Amp)
    {
        for (auto& pb : Bmp)
        {
            if (ap.first == pb.first)
            {
                cnt += 1;
                break;
            }
            else if (ap.first < pb.first)
            {
                break;
            }
        }
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int x;
  int point;
  int n, m;
  //500円　1000
  //5円　　5
  
  scanf("%d", &x);
  
  n = x%500;
  point = 1000 * (x - n) / 500;
  
  m = n%5;
  
  point = point + 5 * (n - m)/5;
  
  printf("%d\n", point);
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int N;
	cin >> N;
	int a[N];
	for(int i = 0; i < N; i++){
	cin >> a[i];
}
	int c=0;
	for(int j = 0; j < N; j++){
	for(int k = 0; k < j; k++){
	if(a[k]==a[j]){a[j]=0;}
}
	if(a[j] != 0){c=c+1;}
}
		cout << c <<  endl;
return 0;
}






Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define F(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define i64 int64_t
#define fi first
#define se second
using namespace std;
int solve(ll n,ll k)
{
	int res=0;
	while(n!=0)
	{
		res++;
		n/=k;
	}
	return res;
}
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	ll n,k;
	cin>>n>>k;
	cout<<solve(n,k);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] p = new int[n];
		int count = 0;

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

		for (int i = 1; i < n - 1; i++) {
			if (((p[i] > p[i - 1]) && (p[i] < p[i + 1])) || ((p[i] < p[i - 1]) && (p[i] > p[i + 1]))) {
				count++;
			}
		}
		System.out.println(count);

		sc.close();

	}
}


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

const int N = 200005;
const int md = 1e9 + 7;

int pw2[N];
int n;
int ans, res;
vector<int> G[N];
int par[N][18], dep[N], t[N], TIME;
vector<int> level[N];

// -----------------------------------------------------
void dfs(int u) {
	t[u] = ++TIME;
	level[dep[u]].push_back(u);
	for (int v : G[u]) {
		dep[v] = dep[u] + 1;
		par[v][0] = u;
		dfs(v);
	}
}
int lca(int u, int v) {
	if (dep[u] < dep[v]) swap(u, v);
	for (int i = 17; i >= 0; --i) if (dep[par[u][i]] >= dep[v]) u = par[u][i];
	for (int i = 17; i >= 0; --i) if (par[u][i] != par[v][i]) u = par[u][i], v = par[v][i];
	return u == v ? u : par[u][0];
}
// -----------------------------------------------------

bool leaf[N];
int dp[N][2];
int nleaf[N];
vector<int> T[N];
void calc(int u) { // new tree
	if (leaf[u]) {
		dp[u][0] = dp[u][1] = nleaf[u] = 1;
		return;
	}
	nleaf[u] = 0; // we don't need to reset nleaf[u]
	for (int v : T[u]) {
		calc(v);
		nleaf[u] += nleaf[v];
	}

	int f[3] = {1, 0, 0};
	// compute dp for u
	for (int v : T[u]) {
		f[2] = (1LL * dp[v][0] * f[2] + 1LL * dp[v][1] * f[2] + 1LL * dp[v][1] * f[1]) % md;
		f[1] = (1LL * dp[v][0] * f[1] + 1LL * dp[v][1] * f[0]) % md;
		f[0] = (1LL * dp[v][0] * f[0]) % md;
	}
	dp[u][0] = (f[0] + f[2]) % md;
	dp[u][1] = f[1];
}
void solve(int lvl) {
	if (level[lvl].empty()) return;
	if (level[lvl].size() == 1) { res = 1; return; }
	
	sort(level[lvl].begin(), level[lvl].end(), [&](int x, int y) { return t[x] < t[y]; });
	vector<int> ver;
	for (int u : level[lvl]) ver.push_back(u), leaf[u] = true;

	// build a new tree with LCAs
	int sz = ver.size();
	for (int i = 1; i < sz; ++i) {
		ver.push_back(lca(ver[i-1], ver[i]));
	}
	sort(ver.begin(), ver.end(), [&](int x, int y) { return t[x] < t[y]; });
	ver.resize(distance(ver.begin(), unique(ver.begin(), ver.end())));
	for (int i = 1; i < ver.size(); ++i) {
		int p = lca(ver[i-1], ver[i]);
		T[p].push_back(ver[i]);
	}
	for (int u : ver) dp[u][0] = dp[u][1] = 0; // reset dp

	// solve
	calc(ver[0]);
	res = dp[ver[0]][1];

	// reset
	for (int u : ver) T[u].clear(), leaf[u] = false;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	pw2[0] = 1; for (int i = 1; i < N; ++i) pw2[i] = 2LL * pw2[i-1] % md;
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		int p; cin >> p; G[p].push_back(i);
	}
	dfs(0);
	for (int j = 1; j < 18; ++j) {
		for (int i = 1; i <= n; ++i) par[i][j] = par[par[i][j-1]][j-1];
	}

	for (int i = 0; i <= n; ++i) {
		solve(i);
		ans = (ans + 1LL * res * pw2[n + 1 - level[i].size()]) % md;
		res = 0;
	}
	cout << ans << endl;
}

Measured memory_bytes: 55168
//#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<numeric>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<ctype.h>
#include <fstream>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}
int dy[4]={0,1,0,-1};
//----------program from here----------

int main(){
  int A=0,B=0,C=0,D=0;

  cin >> A >> B >> C >> D;
  cout << (A*B>C*D?A*B:C*D) << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
        public static void main(String args[]){
                Scanner scan =new Scanner(System.in);
                int w=scan.nextInt();
                int h=scan.nextInt();
                int x=scan.nextInt();
                int y=scan.nextInt();
                int r=scan.nextInt();
                if(x-r>=0&&x+r<=w&&y-r>=0&&y+r<=h){
                        System.out.println("Yes");
                }else{
                        System.out.println("No");
                }
        }
}

Measured memory_bytes: 26396