akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] center = new long[N];
		PriorityQueue<Long> apq = new PriorityQueue<>();
		PriorityQueue<Long> bpq = new PriorityQueue<>(Comparator.reverseOrder());
		long asum = 0;
		for(int i=0; i<N; i++) {
			long a = sc.nextLong();
			apq.add(a);
			asum += a;
		}
		for(int i=0; i<N; i++) {
			center[i] = sc.nextLong();
		}
		long bsum = 0;
		for(int i=0; i<N; i++) {
			long b = sc.nextLong();
			bpq.add(b);
			bsum += b;
		}
		long[] amax = new long[N+1];
		amax[0] = asum;
		for(int i=0; i<N; i++) {
			asum += center[i];
			apq.add(center[i]);
			asum -= apq.poll();
			amax[i+1] = asum;
		}
		long[] bmin = new long[N+1];
		bmin[N] = bsum;
		for(int i=N-1; i>=0; i--) {
			bsum += center[i];
			bpq.add(center[i]);
			bsum -= bpq.poll();
			bmin[i] = bsum;
		}
		long ans = -Long.MAX_VALUE;
		for(int i=0; i<=N; i++) {
			ans = Math.max(ans, amax[i] - bmin[i]);
		}
		System.out.println(ans);
	}
	
	// print
	static void print(String s) {
		System.out.println(s);
	}
	
	// union find lib
	// usage:
	// 最初にinitを呼ぶ
	// root: 直接は呼ばないで
	// unite: まとめる
	// same: グループ判定
	static void init(int par[], int N) {
		for(int i=0; i<N; i++) {
			par[i] = i;
		}
	}
	
	static int root(int x, int [] par) {
		if(par[x] == x) {
			return x;
		} else {
			return (par[x] = root(par[x], par));
		}
	}
	
	static boolean same(int x, int y, int[] par) {
		return root(x, par) == root(y, par);
	}
	
	static void unite(int x, int y, int[] par) {
		x = root(x, par);
		y = root(y, par);
		if(x == y) return;
		par[x] = y;
	}
	
	// end union find lib
	
	// number lib
	
	static long lcm(long a, long b) {
		return a*(b/gcd(a, b));
	}
	
	static long gcd(long a, long b) {
		long ta = Math.max(a, b);
		long tb = Math.min(a, b);
		long tmp;
		while((tmp = ta%tb) != 0) {
			ta = tb;
			tb = tmp;
		}
		return tb;
	}
	
	static long modcomb(long n, long k, long mod) {
		if(k==1) {
			return n;
		}
		
		long ans = 1;
		for(long i=n; i>=n-k+1; i--) {
			ans = (ans * i)%mod;
		}
		for(long i=k; 0<i; i--) {
			ans = (ans * modpow(i, mod-2, mod)) % mod;
		}
		return ans;
	}
	
	static long modpow(long a, long b, long mod) {
		if(b==0) return 1;
		if(b%2==0) {
			long d = modpow(a, b/2, mod);
			return (d*d)%mod;
		} else {
			return (a*modpow(a, b-1, mod))%mod;
		}
	}
	
	static int disit(long a, long d) {
		int count = 0;
		while(a!=0) {
			a = a/d;
			count++;
		}
		return count;
	}
	
	// end number lib
}

Measured memory_bytes: 100884
#include<stdio.h>
   int main(void)
   {
   	 int W ,H ,x ,y ,r ;
   	 
   	 scanf("%d %d %d %d %d", &W ,&H ,&x ,&y ,&r);
   	 
   	 if((x+r<=W && x-r>=0)&&(y+r<=H && y-r>=0))
	{
			printf("Yes\n");
	 } 
    else
    {
    	printf("No\n");
	}
		
	} 


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n,k; cin >> n >> k;
  vector<int> l(k),r(k);
  for(int i = 0; i < k; ++i)cin >> l[i] >> r[i];
  vector<ll> dp(n+1);
  dp[n] = 1;
  int pre = 0;
  for(int i = n-1; i >= 0; --i){
    dp[i] = pre;
    for(int j = 0; j < k; ++j){
      if(i+r[j]+1 <= n)dp[i] -= dp[i+r[j]+1];
      if(i+l[j] <= n)dp[i] += dp[i+l[j]];      
      dp[i] = (dp[i] + 998244353) % 998244353;      
    }
    pre = dp[i];
  }
  cout << dp[1] << endl;
  return 0;
}


Measured memory_bytes: 4840
import scala.io.StdIn.{readInt,readLine}
/**
  * AOJ
  */

object Main {

  def main(args: Array[String]): Unit = {

    val n = readInt()
    var dices = List.empty[Array[Int]]
    for(_ <- 1 to n){
      dices :+= readLine().split(" ").map(_.toInt)
    }
    println(if(differentFromEachOther(dices)) "Yes" else "No")
  }

  def differentFromEachOther(dices:List[Array[Int]]): Boolean ={
    for(i <- 0 until dices.size){
      val dice1List = createDiceArray(dices(i))
      for(j <- (i + 1) until dices.size) {
        if (dice1List.exists(_ sameElements dices(j))) return false
      }
    }
    return true
  }

  def createDiceArray(dice:Array[Int]) : List[Array[Int]] = {
    var dices = List.empty[Array[Int]]
    for(i <- createDiceArray(dice,"WNNNW"); j <- createDiceArray(i,"HHH")){
      dices +:= j
    }
    dices
  }

  def createDiceArray(dice:Array[Int],commands:String) : List[Array[Int]] = {
    var dices = List(dice)
    for(cmd <- commands.toCharArray){
      dices :+= getNextStatus(cmd,dices.last)
    }
    dices
  }

  def getNextStatus(cmd:Char,dice:Array[Int]): Array[Int] = cmd match {
    case 'N' => Array(dice(1), dice(5), dice(2), dice(3), dice(0), dice(4))
    case 'H' => Array(dice(0), dice(2), dice(4), dice(1), dice(3), dice(5))
    case 'W' => Array(dice(2), dice(1), dice(5), dice(0), dice(4), dice(3))
  }
}

Measured memory_bytes: 50624
import java.util.*;

public class Main {    
    public static void main(String[] args){

       Scanner sc = new Scanner(System.in);
                
        String S = sc.next();
		int N = S.length();
	
		int current = N;
	
		while(current > 0){
			if(current >= 7){
				String sub = S.substring(current-7, current);
				if(sub.equals("dreamer")){
					current -= 7;
					continue;
				}
			}
			
			if(current >= 6){
				String sub = S.substring(current-6, current);
				if(sub.equals("eraser")){
					current -= 6;
					continue;
				}
			}
			
			if(current >= 5){
				String sub = S.substring(current-5, current);
				if(sub.equals("dream") || sub.equals("erase")){
					current -= 5;
					continue;
				}
			}
			
			System.out.println("NO");
                        return;
		}
		
		System.out.println("YES");      
                
      
  }                                      
}
        
        
        

Measured memory_bytes: 27760
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define vi vector<int>
#define nl endl
#define tc    \
    ll t;     \
    cin >> t; \
    while (t--)
#define fastio                       \
    ios_base::sync_with_stdio(NULL); \
    cin.tie(NULL);                   \
    cout.tie(NULL);
using namespace std;
int main()
{
    fastio;
    int n,k=0;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        if(a[i]!=i+1)
            k++;
    }
    if(k==0||k==2)
        cout<<"YES";
    else
    {
        cout<<"NO";
    }
    
}

Measured memory_bytes: 3624
n, y = map(int, input().split(" "))

for i in range(n+1):
	for j in range(n+1-i):
		k = n-i-j
		if 10000*i + 5000*j + 1000*k == y:
			print(i, j, k)
			exit()

print(-1, -1, -1)

Measured memory_bytes: 3060
import java.util.*;
public class Main {
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int count = 0;
    for (int i=0; i<N; i++) {
      int num = sc.nextInt();
      if ((i+1)%2 != 0 && num%2 != 0)
        count++;
    }
    System.out.println(count);
  }
}

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

using namespace std;


int main()
{
  int N, M;
  string S[50];
  string T[50];

  cin >> N >> M;
  for(int i = 0; i < N; i++) cin >> S[i];
  for(int i = 0; i < M; i++) cin >> T[i];

  for(int i = 0; i <= N - M; i++) {
    for(int j = 0; j <= N - M; j++) {
      bool match = true;
      for(int k = 0; k < M; k++) {
        for(int l = 0; l < M; l++) {
          match &= S[i + k][j + l] == T[k][l];
        }
      }
      if(match) {
        cout << "Yes" << endl;
        return (0);
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define rept(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(v) v.bigin(),v.end()
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a<b?a:b
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int main(){
    ll n;
    double d;
    ll ans=0;
    double z;
    cin>>n>>d;
    ll x[n],y[n];
    rep(i,n){
        cin>>x[i]>>y[i];
        x[i]=pow(x[i],2);
        y[i]=pow(y[i],2);
        z=sqrt(x[i]+y[i]);
        if(d-z>=0){
            ans++;
        }
        z=0;
    }
    cout<<ans;
    
}



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

using namespace std;

#define int long long
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF 1e9
#define LINF 1e18

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;
typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

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

    int R;
    cin >> R;
    if(R < 1200) cout << "ABC";
    else if(R < 2800) cout << "ARC";
    else cout << "AGC";
    cout << endl;
    return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
long long a[200001],d[200001];
long long mod=1000000007;
int main()
{
	long long n;
	scanf("%lld",&n);
	for(long long i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		d[i]=(d[i-1]+a[i])%mod;
	}
	long long sum=0;
	for(long long i=n;i>=2;i--)
	{
		sum=(sum+(a[i]*d[i-1])%mod)%mod;
	}
	printf("%lld\n",sum%mod);
	return 0;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

int main() {
  ll n; cin >> n;
  ll x = std::numeric_limits<ll>::max();
  rep(i, 5) {
    ll y; cin >> y;
    x = min(x, y);
  }
  cout << 5 + (n - 1) / x << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> vec(n,0);
for(int i=0;i<n;i++){
    int a;
    cin>>a;
    vec.at(a-1)=i+1;
}
    for(int i=0;i<n;i++){
        cout<<vec.at(i)<<" ";
    }
}


Measured memory_bytes: 1280
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  string S;
  cin>>S;
  for(int i=0;i<S.size();++i){
    cout<<'x';
  }
  cout<<endl;
}



Measured memory_bytes: 3632
n,k = (int(i) for i in input().split())
p = (n-1)*(n-2)//2-k
if p<0: print(-1)
else:
    print(n+p-1)
    for i in range(n-1): print(1,i+2)
    for i in range(2,n+1):
        if n-i>p: break
        else:
            for j in range(n-i): print(i,i+j+1)
            p+=i-n
    for j in range(p): print(i+1,i+j+2)

Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {
 public static void main(String[] args) {
	Scanner in = new Scanner(System.in);
	int[] a = new int[100];
	int max = 0;
	while (in.hasNextInt()) {
	 int read = in.nextInt() - 1;
	 a[read]++;
	 if (max < a[read]) {
		max++;
	 }
	}
	for (int i = 0; i < a.length; i++) {
	 if (a[i] == max) {
		System.out.println(i + 1);
	 }
	}
 }
}

Measured memory_bytes: 12000
// review
#include <iostream>

using namespace std;
typedef long long ll;
const int MAXN = 10;

int n, m;
bool graph[MAXN][MAXN];
bool visited[MAXN];
ll cnt = 0;

void dfs(int s) {
  bool done = true;
  for (int i=0;i<n;i++) {
    done &= visited[i];
  }
  if (done) {
    cnt++;
    return;
  }
  for (int i=0;i<n;i++) {
    if (graph[s][i] && !visited[i]) {
      visited[i] = true;
      dfs(i);
      visited[i] = false;
    }
  }
}

void solve() {
  visited[0] = true;
  dfs(0);
  cout << cnt << endl;
}


int main() {
  cin >> n >> m;
  int a, b;
  for (int i=0;i<m;i++) {
    cin >> a >> b;
    graph[--a][--b] = true;
    graph[b][a] = true;
  }
  solve();
}


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

int main(void){
	int n,i,len;
  	char c[10001];
  	scanf("%d",&n);
  	scanf("%s",c);
  	len = strlen(c);
  	for(i=0;i<len;i++){
    	c[i]+=n;
      	if(c[i]>'Z'){
        	c[i] = c[i]-'Z'+'A'-1;
        }
    }
  	printf("%s\n",c);
}


Measured memory_bytes: 128
using System;

namespace A___Two_Rectangles
{
    class Program
    {
        static void Main (string[] args)
        {
            var input = Console.ReadLine ().Split (' ');
            var a = int.Parse (input[0]);
            var b = int.Parse (input[1]);
            var c = int.Parse (input[2]);
            var d = int.Parse (input[3]);
            Console.WriteLine (Math.Max (a * b, c * d));
        }
    }
}

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

#define swap(type,a,b) {type t; t=a; a=b; b=t;}
#define forN(i,n) for(int i=0;i<n;i++)
#define forS(i,start,n) for(int i=start;i<n;i++)
#define ll long long
#define pb(t,d,n) {t p;int i;forN(i,n){cin>>p;d.push_back(p);}}
#define DOUBLE fixed << setprecision(15)
#define c2i(c) {i-48;}
#define i2c(n) {n+48;}

using namespace std;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;

int main(){
    int m,n,cnt=0;
    string s;

    cin >> s;
    int res;
    if(s=="SUN") res=7;
    else if(s=="MON") res=6;
    else if(s=="TUE") res=5;
    else if(s=="WED") res=4;
    else if(s=="THU") res=3;
    else if(s=="FRI") res=2;
    else if(s=="SAT") res=1;
    cout << res << endl;
}


Measured memory_bytes: 3624
#include <stdio.h>
#include <stdlib.h>
int main(void) {
	char s[1];
	int stack[100]; /* 2<= op <= 100 */
	int sp = 0;
	while (scanf("%s", s) != EOF) {
		if (s[0] == '+') {
			stack[sp - 2] = stack[sp - 2] + stack[sp - 1];
			sp--;
		}
		else if (s[0] == '-') {
			stack[sp - 2] = stack[sp - 2] - stack[sp - 1];
			sp--;
		}
		else if (s[0] == '*') {
			stack[sp - 2] = stack[sp - 2] * stack[sp - 1];
			sp--;
		}
		else {
			stack[sp] = atoi(s);
			sp++;
		}
	}
	printf("%d\n", stack[sp - 1]);
	return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
//typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

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; }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

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

    ll N;
    cin >> N;

    vector<string> S(N);
    REP(i, N) cin >> S[i];
    vl A(N);

    REP(i, N){
        ll pos = 0;
        ll val = 0;
        ll bai = 1;
        ll sz = S[i].size();
        REP(j, sz){
            if(S[i][sz-1-j]=='.'){
                pos = j;
            }else{
                val += (S[i][sz-1-j]-'0') * bai;
                bai *= 10;
            }
        }
        REP(j, 9-pos) val *= 10;
        A[i] = val;
    }
    
    //out << A << endl;

    vvl cnt(19, vl(19, 0));
    REP(i, N){
        ll x=0, y=0;
        while(A[i]%2==0){
            x++;
            A[i]/=2;
        }
        while(A[i]%5==0){
            y++;
            A[i]/=5;
        }
        x = min(x, 18ll);
        y = min(y, 18ll);
        cnt[x][y]++;
    }

    //cout << cnt << endl;

    ll res = 0;
    REP(i, 19){
        REP(j, 19){
            REP(k, 19){
                REP(l, 19){
                    if(i+k>=18 and j+l>=18){
                        res += cnt[i][j] * cnt[k][l];
                    }
                }
            }
            if(i>=9 and j>=9 )res -= cnt[i][j];
        }
    }

    res /= 2;

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 10992
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> p;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, n) for(int i = 1; i <= (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define srep(i, from, to) for(int i = from; i < (int)(to); i++)
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
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;
}

int main() {
  int n, W;
  cin >> n >> W;
  vector<int> w = vector<int>(n);
  vector<int> v = vector<int>(n);
  rep(i, n) {
    cin >> w[i] >> v[i];
  }

  vector<vector<ll>> dp = vector<vector<ll>>(n + 1, vector<ll>(100001, LINF));
  dp[0][0] = 0;
  rep(i, n) {
    rep(j, 100000) {
      if(dp[i][j] == LINF) continue;
      chmin(dp[i + 1][j], dp[i][j]);
      ll nw = dp[i][j] + w[i];
      chmin(dp[i + 1][j + v[i]], nw);
    }
  }

  ll ans = 0;
  rep(i, dp[0].size()) {
    if(dp[n][i] <= W && dp[n][i] > 0) ans = i;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 80256
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        for(int i = 1; i < a+1; i++){
            int x = i;
            if (x % 3 == 0) {
                System.out.print(" "+i);
            } else {
                while(true){
                    if(x % 10 == 3){
                        System.out.print(" "+i);
                    break;
                    }
                    x /= 10;
                    if(x != 0){
                        continue;
                    }else{
                        break;
                    }
                }
            }
        }
        System.out.print("\n");
    }
}



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

using namespace std;

int solve(int n, vector<int> &vn, vector<int> &memo) {
  if (n < 6) {
    return n;
  }

  if (memo[n] < 0) {
    int ans = n;
    for (auto nn : vn) {
      if (n < nn) {
        break;
      }

      ans = min(ans, solve(n - nn, vn, memo) + 1);
    }

    memo[n] = ans;
  }

  return memo[n];
}

int main(int argc, const char *argv[]) {
  int n = 0;
  cin >> n;

  vector<int> vn;
  for (int pow6 = 6; pow6 <= n; pow6 *= 6) {
    vn.push_back(pow6);
  }

  for (int pow9 = 9; pow9 <= n; pow9 *= 9) {
    vn.push_back(pow9);
  }

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

  vector<int> memo(n + 1, -1);
  cout << solve(n, vn, memo) << '\n';
  return 0;
}

Measured memory_bytes: 1920
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    m=int(input())
    D=[0]*m;C=[0]*m
    for i in range(m):
        D[i],C[i]=map(int,input().split())

    digit=sum(D[i]*C[i] for i in range(m))
    print(sum(C)+(digit-1)//9-1)
resolve()

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

int main() {
  long long N,A,B;
  cin >> N >> A >> B;
  if (A%2 == B%2) {
    cout << (B-A)/2 << endl;
  }
  else {
    long long step = 0;
    step += min(A-1,N-B); //端まで移動
    step++; //端で一回片方がとどまり、もう片方が移動
    step += (B-A-1)/2;
    cout << step << endl;
  }
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

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

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

struct UnionFind {
    int n, cnt;
    vector<int> par, rank, sz;

    UnionFind(int n) : n(n), cnt(n), par(n), rank(n), sz(n, 1) { iota(par.begin(), par.end(), 0); }

    int find(int x) {
        if (x == par[x]) return x;
        return par[x] = find(par[x]);
    }

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

    int size(int x) { return sz[find(x)]; }

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    for (i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        uf.unite(--a, --b);
    }
    int ans = 0;
    for (i = 0; i < n; i++) chmax(ans, uf.size(i));
    cout << ans << endl;
}

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

int main() {
  int n;
  cin >> n;
  int cnt = 0;
  for(int i = 1; i <= n; i++) {
    string s = to_string(i);
    int cmp = s.length();
    if(cmp % 2 == 1) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3752
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[] input = br.readLine().split(" ");

        int n = Integer.parseInt(input[0]);
        int a = Integer.parseInt(input[1]);
        int b = Integer.parseInt(input[2]);
        int c = Integer.parseInt(input[3]);
        int d = Integer.parseInt(input[4]);

        System.out.println(Math.min(n / a * b + (n % a == 0 ? 0 : b), n / c * d + (n % c == 0 ? 0 : d)));

    }
}


Measured memory_bytes: 24472
def do(lv, dan):
    res = 0
    #print("do({0}, {1})".format(lv, dan))
    if lv == 0:
        if dan == 0:
            return 0
        elif dan == 1:
            return 1
        else:
            print("!!!!!!!!!!!!!!!!!!!!!!!!!!")
    if dan == 0:
        return 0

    dan -= 1

    if dan == 0:
        return 0

    if burgersize[lv-1] <= dan:
        res += pnum[lv-1]
        dan -= burgersize[lv-1]
    else:
        res = do(lv-1, dan)
        dan = 0

    if dan >= 1:
        res += 1
        dan -= 1
    else:
        return res

    if burgersize[lv-1] <= dan:
        res += pnum[lv-1]
        dan -= burgersize[lv-1]
    else:
        res += do(lv-1, dan)
        dan = 0


    return res

burgersize = [1] * 51
pnum = [1] * 51
for i in range(1, 51):
    burgersize[i] = burgersize[i-1] * 2 + 3
    pnum[i] = pnum[i-1] * 2 + 1
#print(burgersize[:10])
#print(pnum[:10])
a,b = map(int, input().split())
print(do(a, b))


Measured memory_bytes: 38256
#include <iostream>
using namespace std;
#define MIN(X,Y) ((X)<(Y)?(X):(Y))

int main(void){
  int na, nb, m;
  int a[100000], b[100000];
  int mn,ans;
  
  cin >> na >> nb >> m;
  mn=1001001;
  for (int i=0; i<na; i++){
    cin >> a[i];
    mn = MIN(mn,a[i]);
  }
  ans = mn; mn=1001001;
  for (int i=0; i<nb; i++){
    cin >> b[i];
    mn = MIN(mn,b[i]);
  }
  ans += mn;
  for (int i=0; i<m; i++){
    int x,y,c;
    cin >> x >> y >> c;
    ans = MIN(ans,a[x-1]+b[y-1]-c);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
import java.util.*;
import java.io.PrintWriter;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
		long mod=1000000007;
		long ans=1;
		long[] front=new long[n+1];
		long[] back=new long[n+1];
		for(int i=1; i<n+1; i++){
			front[i]=i+front[i-1];
			front[i]%=mod;
		}
		back[0]=n;
		for(int i=1; i<n; i++){
			back[i]+=n-i+back[i-1];
			back[i]%=mod;
		}
		for(int i=k; i<=n; i++){
			ans=(ans+back[i-1]-front[i-1]+1+mod)%mod;
		}
		System.out.println(ans);
	}
}


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);
  int n, l;
  cin >> n >> l;
  int l_max = l + n - 1;
  if (l <= 0 && 0 <= l_max) {
    cout << (l+l_max) * n/2 << endl;
  } else if (l_max < 0) {
    cout << (l + l_max - 1) * (n - 1)/2 << endl; 
  } else {
    cout << (l + 1 + l_max) * (n - 1)/2 << endl; 
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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; }
template<class T, class U>T rem(T a, U b) { return a - b*floor(a/b); }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N;
        ll K;
        cin >> N >> K;
        ll mn = inf;
        rep(a, 0, N+1) {
                ll b = N - a;
                ll tmp = round(pow(2, a) + (b * K));
                chmin(mn, tmp);
        }
        cout << mn << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
signed main() {
  int n;
  cin >> n;

  int res = 0, ai;
  for (int i = 0; i < n; i++) {
    cin >> ai;
    res += ai - 1;
  }
  cout << res << "\n";
}


Measured memory_bytes: 256
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1] * n

  def find(self, x):
    if self.parents[x] < 0:
      return x
    else:
      self.parents[x] = self.find(self.parents[x])
    return self.parents[x]

  def union(self, x, y):
    x = self.find(x)
    y = self.find(y)

    if x == y:
      return

    if self.parents[x] > self.parents[y]:
          x, y = y, x

    self.parents[x] += self.parents[y]
    self.parents[y] = x

  def same(self, x, y):
    return self.find(x) == self.find(y)

  def roots(self):
    return [i for i, x in enumerate(self.parents) if x < 0]

  def num_roots(self):
    return len([i for i, x in enumerate(self.parents) if x < 0])

  def members(self, x):
    root = self.find(x)
    return [i for i in range(self.n) if self.find(i) == root]

  def num_members(self,x):
    return abs(self.parents[self.find(x)])

  def __str__(self):
    return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

import sys
input = sys.stdin.readline
N, Q = map(int, input().split())
uf = UnionFind(N)
ans = []
for i in range(Q):
  t,u,v = map(int, input().split())
  if t:
    ans.append(int(uf.same(u,v)))
  else:
    uf.union(u,v)
print(*ans, sep='\n')

Measured memory_bytes: 83236
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    int n, h, ans, acnt, bcnt, a[100000], b[100000];

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

    sort(a, a + n);
    sort(b, b + n);

    ans = 0;
    acnt = n - 1;
    bcnt = n - 1;
    while (h > 0)
    {
        if (bcnt < 0 || a[n - 1] > b[bcnt])
        {
            ans += h / a[acnt];
            if (h % a[acnt] != 0)
                ans++;
            h = 0;
        }
        else
        {
            h -= b[bcnt];
            ans++;
            bcnt--;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define maxn   200005
#define ll long long
#define mod 1000000007

ll n,m;

int main()
{
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
    cin>>n>>m;
    ll i,j;
    ll dp[n][m]={0};
    string str[n];
    for(i=0;i<n;i++)
    cin>>str[i];
    for(i=0;i<n;i++)
    {
    	if(str[i][0]=='#')
    	{
    		while(i<n)
    		{dp[i][0]=0;i++;}
    		
    		break;
		}
    	dp[i][0]=1;
    }
    for(i=0;i<m;i++)
    {
    	if(str[0][i]=='#')
    	{
    		while(i<m)
    		{dp[0][i]=0;i++;}
    		break;
		}
    	dp[0][i]=1;
    }
    for(i=1;i<n;i++)
    {
    	for(j=1;j<m;j++)
    	{
    		if(str[i][j]=='#')
    		dp[i][j]=0;
    		else
    		dp[i][j]=(dp[i][j-1]+dp[i-1][j])%mod;
		}
	}
	cout<<dp[n-1][m-1];
}

Measured memory_bytes: 9088
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>


#define REP(i,N) for(auto i = 0; i <N; i++)
const int MAX = INT_MAX;
using namespace std;
typedef long long ll;


int in(){
    int temp;
    scanf("%d",&temp);
    return temp;
}

ll lin(){
    ll temp;
    scanf("%lld",&temp);
    return temp;
}



int main() {

    ll N = lin();
    
    ll namecount[5] = {0};
    string temp;
    
    for(auto i = 0; i <N; i++){
        cin >> temp;
        
        if (temp[0] == 'M'){
            namecount[0]++;
        }
        if (temp[0] == 'A'){
            namecount[1]++;
        }
        if (temp[0] == 'R'){
            namecount[2]++;
        }
        if (temp[0] == 'C'){
            namecount[3]++;
        }
        if (temp[0] == 'H'){
            namecount[4]++;
        }

    }
    
    ll ans = 0;
    
    for(auto i = 0; i < 5; i++){
        for(auto j = i+1; j < 5; j++){
            for(auto k = j+1; k < 5; k++){
                ans += namecount[i]*namecount[j]*namecount[k];
            }
        }
    }
    
    cout << ans << endl;
    
    
    
    return 0;
}




                          




Measured memory_bytes: 256
#include<iostream>
#include<math.h>
using namespace std;
int main(){
  int pos[3];
  int d;
  int ii;
  int dd[3];
  for(ii=0;ii<3;ii++){
	cin >> pos[ii];
  }
  cin >> d;
  dd[0] = abs(pos[0] - pos[2]); //AとCの距離
  dd[1] = abs(pos[0] - pos[1]); //AとBの距離
  dd[2] = abs(pos[1] - pos[2]); //BとCの距離
  if(dd[0] <= d || (dd[1] <= d && dd[2] <= d)){
	cout << "Yes" << endl;
  }
  else{
	cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
n=int(input())
S=str(input())
r=S.count('R')
g=S.count('G')
b=S.count('B')
cnt=r*g*b
for i in range(n):
    for a in range(1,n):
        j=i+a
        k=j+a
        if k>=n:
            break
        if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
            cnt-=1

print(cnt)

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

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

  bool flag = false;
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      if ((i * j) == N) {
        flag = true;
        break;
      }
    }
    if (flag == true) break;
  }

  if (flag == true) cout << "Yes" << endl;
  if (flag == false) cout << "No" << endl;  
}


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

#define FileIO freopen("input.txt", "r", stdin);  freopen("output.txt", "w", stdout);  ios_base::sync_with_stdio(0);
#define IO ios_base::sync_with_stdio(0);  cin.tie(0);  cout.tie(0); 
#define ll long long
#define endl "\n"
#define mod 1000000007

int main()
{
    IO;
    int x, y;
    cin>>x>>y;
    // 2a + 4b = y
    bool ok = false;
    for(int i = 0; i <= 100; i++)
    {
        for(int j = 0; j <= 100; j++)
        {
            if((2*i + 4*j) == y && (i+j) == x)
            {
                ok = true;
                break;
            }
        }
    }
    cout<<(ok ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 3644
from collections import deque
inf = 10 ** 9 + 7
h, w, k = map(int, input().split())
a = [list(input()) for i in range(h)]
for i in range(h):
    for j in range(w):
        if a[i][j] == "S":
            sx, sy = i, j
d = [(1, 0), (-1, 0), (0, 1), (0, -1)]
l = [[inf] * w for i in range(h)]
l[sx][sy] = 0
s = set()
s.add((sx, sy))
que = deque([[sx, sy]])
ans = inf
while que:
    x, y = que.popleft()
    if x == 0 or x == h - 1 or y == 0 or y == w - 1:
        ans = 1
        break
    if l[x][y] == k:
        continue
    for i in range(4):
        nx, ny = x + d[i][0], y + d[i][1]
        if nx < 0 or nx >= h or ny < 0 or ny >= w or a[nx][ny] == "#" or l[nx][ny] != inf:
            continue
        s.add((nx, ny))
        l[nx][ny] = l[x][y] + 1
        que.append([nx, ny])
for i in s:
    c = (min(i[0], h - i[0] - 1, i[1], w - i[1] - 1) + k - 1) // k + 1
    ans = min(ans, c)
print(ans)

Measured memory_bytes: 27552
#include <iostream>
#include <string>

using namespace std;

int main()
{
    int n;
    string s;
    cin >> n;
    cin >> s;

    int num = 0;
    for(int i=0, buf=0; i < n - 2; buf = ++i){
        if(s[buf] == 'A' && s[++buf] == 'B' && s[++buf] == 'C'){
            num++;
        }
    }

    cout << num;
    return 0;
}

Measured memory_bytes: 256
n,k = map(int,input().split(" "))

sum = 0
for i in range(k,n+2):
    maxsum = (2*n-i+1)*i/2
    minsum = (i-1)*i/2

    num = maxsum-minsum +1
    sum += num
    sum = sum % (10**9+7)

print(int(sum))


Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(ll i=0;i<N;++i)
typedef long long int ll;
ll INF = 1LL<<60;

vector<vector<int> > G(100010);
vector<int> color(100010,-1);
int n,m; 

// sからたどり着く頂点の色をcに塗り替える
void dfs(int v, int c){
    stack<int> s;
    s.push(v);
    color[v] = c;
    while(!s.empty()){
        int u = s.top(); s.pop();
        for(auto nv : G[u]){
            if(color[nv] == -1){
                color[nv] = c;
                s.push(nv);
            }
        }
    }
}

void assignColor(){
    int number = 1;
    rep(i,n){
        if(color[i] == -1) dfs(i, number++);
    }
}

int main(){
        cin >> n >> m;
    rep(i,m){
        int x,y; cin >> x >> y;
        G[x].push_back(y);
        G[y].push_back(x);
    }

    assignColor();
    int q; cin >> q;
    rep(i,q){
        int x,y; cin >> x >> y;
        if(color[x] == color[y]) cout << "yes" << endl;
        else cout << "no" << endl;
    }
}


Measured memory_bytes: 8616
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int N=100005;
int val[N],cnt[N],sxr[1<<17];
int a[17];
int dp[1<<17];
inline int read(){
	int x=0;char e=getchar();
	for (;e<'0'||e>'9';e=getchar());
	for (;e>='0'&&e<='9';e=getchar()) x=(x<<1)+(x<<3)+(e^48);
	return x;
}
inline int Min(int a,int b){
	return a<b?a:b;
}
int main (){
	int n=read();
	for (int i=1;i<n;i++){
		int u=read()+1,v=read()+1,w=read();
		val[u]^=w,val[v]^=w;
	}
	for (int i=1;i<=n;i++) cnt[val[i]]++;
	int ans=0,to=0;
	for (int i=1;i<16;i++){
		ans+=(cnt[i]>>1);
		if (cnt[i]&1) to|=(1<<i);
	}
	for (int i=0;i<(1<<16);i++)
		for (int j=0;j<16;j++)
			if (i&(1<<j)) sxr[i]^=j;
	for(int i=0;i<(1<<16);i++) dp[i]=dp[i>>1]+(i&1);
    for(int i=1;i<(1<<16);i++) dp[i]--;
	for (int i=0;i<(1<<16);i++){
        if (sxr[i]) continue;
        for (int k=(i-1)&i;k;k=(k-1)&i)
            if (!sxr[k]) dp[i]=Min(dp[i],dp[k]+dp[i^k]);
	}
	printf ("%d",dp[to]+ans);
	return 0;
}

Measured memory_bytes: 1152
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
const int MAXN=10000005;
const int mod=998244353;
int pow_mod(int a,int b)
{
	int ret=1;
	for(;b;b>>=1,a=1LL*a*a%mod)if(b&1)ret=1LL*ret*a%mod;
	return ret;
}
int pre[MAXN],inv[MAXN],n,bin[MAXN];
int C(int n,int m){return 1LL*pre[n]*inv[m]%mod*inv[n-m]%mod;}
void dl(int &x,int y){x-=y;if(x<0)x+=mod;}
int main()
{
	pre[0]=1;for(int i=1;i<MAXN;i++)pre[i]=1LL*pre[i-1]*i%mod;
	inv[MAXN-1]=pow_mod(pre[MAXN-1],mod-2);
	for(int i=MAXN-2;i>=0;i--)inv[i]=1LL*inv[i+1]*(i+1)%mod;
	bin[0]=1;for(int i=1;i<MAXN;i++)bin[i]=(bin[i-1]<<1)%mod;
	n=read();int ans=pow_mod(3,n);
	for(int i=n/2+1;i<=n;i++)dl(ans,2LL*C(n,i)*bin[n-i]%mod);
	pr2(ans);
	return 0;
}


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

const int MAXn = 1e7+8;

int main(){
	int n, m ,x;
	cin >> n >> m >> x;
	vector<int> c(n+1);
	vector<int> a[n+1];
	int tmp;
	for(int i = 0; i<n; i++){
		cin >> c[i];
		for(int j = 0; j<m; j++){
			cin >> tmp;
			a[i].push_back(tmp);
		}
	}
	
	int mcost = MAXn;
	for(int i=1; i<(1 << n); i++){
		vector<int> ans(m,0);
		int cost = 0;
		for(int j = 0; j < n; j++){
			if(i & (1 << j)){
				for(int k = 0; k<m; k++){
					ans[k] += a[j][k];
				}
				cost += c[j];
			}
		}
		bool flag = 1;
		for(int j = 0; j<m; j++){
			if(ans[j] < x){
				flag = 0;
				break;
			}
		}
		if(flag){
			mcost = min(mcost, cost);
		}
	}
	if(mcost == MAXn){
		cout << -1;
	}
	else{
		cout << mcost;
	}
	return 0;
} 

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/













string S;
int N;
int dp[201010][3];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> S;
	N = S.length();
	S += "####";

	rep(i, 0, N + 1) rep(pre, 0, 3) dp[i][pre] = -inf;
	dp[0][0] = 0;

	rep(i, 0, N) rep(pre, 0, 3) rep(d, 1, 3) if(0 <= dp[i][pre]) {
		if (pre == d) {
			if (d == 1) {
				if (S[i - 1] == S[i]) continue;
			}
			else {
				if (S[i - 2] == S[i] and S[i - 1] == S[i + 1]) continue;
			}
		}
		chmax(dp[i + d][d], dp[i][pre] + 1);
	}

	cout << max(dp[N][1], dp[N][2]) << endl;
}


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

string s;
string s1;

int main()
{
    cin>>s;
    char a;
    a=s[s.length()-1];
    if(a=='s')
        cout<<s<<"es";
    else
        cout<<s<<"s";

    system("pause");
    return 0;
}

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

void solve(){
  int N;
  int ans=0;
  cin>>N;
  vector<int> V,C;
  for(int i=0; i<N; i++){
    int k;
    cin >> k;
    V.push_back(k);
  }
   for(int i=0; i<N; i++){
    int l;
    cin >> l;
    C.push_back(l);
  }
  
  for(int i=0; i<N; i++){
    if(V[i]-C[i]>0){
    ans=ans+V[i]-C[i];
    }   
  }
  
   cout << ans << endl;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
using namespace std;
int main()
{
	bool c=false,f=false;
	string s;
	cin>>s;
	int len=s.size();
	for(int i=0;i<len;i++){
		if(s[i]=='C')	c=true;
		if(s[i]=='F'&&c==true)
			f=true;
	}
	if(c==true&&f==true)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

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

#define long long long
#define INF 0x3f3f3f3f
#define MAX_N 1000010

int dp[MAX_N], a[MAX_N];

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

    int n;

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

        int len = 1;
        dp[len] = a[1];
        for(int i = 2; i <= n; i++)
        {
            if(a[i] >= dp[len])
            {
                dp[++len] = a[i];
            }
            else
            {
                int pos = upper_bound(dp+1, dp + len+1, a[i]) - dp;
                dp[pos] = a[i];
            }
        }
        cout << len << endl;
        break;
    }

    return 0;
}


Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
const int mod = 998244353, nax = 3005;


void plusle (int &a, int b) {
    if ((a += b) >= mod) a -= mod;
}

int dp[nax], f[nax];
int n, s;

int main () {
    scanf("%d %d", &n, &s);
    f[0] = 1;
    int ans = 0;

    for (int i = 1 ; i <= n; ++ i) {
        int x;
        scanf("%d", &x);
        for (int j = s ; j >= x ; -- j) {
            plusle(f[j], f[j - x]);
        }
        ++ f[0];

        plusle(ans, f[s]);
    }

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



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>

#define FOR(i, a, b) for(decltype(b) i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

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

	ll s = 0;
	int m = 1 << 30;

	REP(i, n)
	{
		ll a, b;
		cin >> a >> b;
		s += a;
		if (b < a && b < m)
			m = b;
	}

	cout << (m == 1 << 30 ? 0 : s - m) << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  while(getline(cin,str)){
    while(str.find("the")==-1&&
	  str.find("this")==-1&&
	  str.find("that")==-1){
      int i;
      for(i=0;i<str.size();i++){
	if('a'<=str[i]&&str[i]<'z') str[i]++;
	else if(str[i]=='z') str[i]='a';
      }
    }
    cout << str << endl;
  }
  return 0;
}

Measured memory_bytes: 1172
#include<bits/stdc++.h>
#define ri register int
#define pb push_back
#define fi first
#define se second
using namespace std;
const int rlen=1<<18|1;
char buf[rlen],*ib=buf,*ob=buf;
#define gc() (((ib==ob)&&(ob=(ib=buf)+fread(buf,1,rlen,stdin)),ib==ob)?-1:*ib++)
typedef long long ll;
typedef pair<int,int> pii;
inline int read(){
	int ans=0;
	char ch=gc();
	while(!isdigit(ch))ch=gc();
	while(isdigit(ch))ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
	return ans;
}
namespace modular{
	int mod=1e9+7;
	inline int add(int a,int b){return (a+=b)<mod?a:a-mod;}
	inline void Add(int&a,int b){a=add(a,b);}
	inline int dec(int a,int b){return (a-=b)<0?a+mod:a;}
	inline void Dec(int&a,int b){a=dec(a,b);}
	inline int mul(int a,int b){return (ll)a*b%mod;}
	inline void Mul(int&a,int b){a=(ll)a*b%mod;}
	inline int ksm(int a,int p){int ret=1;for(;p;p>>=1,Mul(a,a))(p&1)&&(Mul(ret,a),1);return ret;}
}
using namespace modular;
const int N=105;
int n,m,L,f[N][N][N][2],C[N][N],pw[4][N];
inline void init(){
	for(ri i=0,up=max(n,m);i<=up;++i){
		C[i][0]=1;
		for(ri j=1;j<=i;++j)C[i][j]=add(C[i-1][j-1],C[i-1][j]);
	}
}
int main(){
	#ifdef ldxcaicai
	freopen("lx.in","r",stdin);
	#endif
	n=read(),m=read(),L=read(),mod=read();
	init();
	f[0][0][0][0]=1;
	for(ri i=0;i<4;++i)pw[i][0]=1;
	for(ri vl=0;vl<L;++vl){
		for(ri i=1,up=max(n,m);i<=up;++i){
			pw[0][i]=pw[1][i];
			pw[1][i]=mul(pw[1][i-1],vl+1);
			pw[2][i]=mul(pw[2][i-1],L-vl);
			pw[3][i]=mul(pw[3][i-1],L-vl-1);
		}
		for(ri mt,mlt,a=0;a<=n;++a)for(ri b=0;b<=m;++b)if(f[vl][a][b][0]){
			mt=1,mlt=mul(pw[2][b],dec(pw[1][m-b],pw[0][m-b]));
			for(ri t=0;a+t<=n;++t,Mul(mt,mlt))
			Add(f[vl][a+t][b][1],mul(f[vl][a][b][0],mul(mt,C[n-a][t])));
		}
		for(ri mt,mlt,a=0;a<=n;++a)for(ri b=0;b<=m;++b)if(f[vl][a][b][1]){
			mt=1,mlt=mul(pw[1][n-a],dec(pw[2][a],pw[3][a]));
			for(ri t=0;b+t<=m;++t,Mul(mt,mlt))
			Add(f[vl+1][a][b+t][0],mul(f[vl][a][b][1],mul(mt,C[m-b][t])));
		}
	}
	cout<<f[L][n][m][0];
	return 0;
}

Measured memory_bytes: 8960
import sys

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

a = list(map(int, input().split()))

a.sort()

# cnt_children = 0
# for i in range(n):
#     if x >= a[i]:
#         cnt_children += 1
#         x -= a[i]
#     else:
#         break

# if x > 0 and cnt_children != 0:
#     cnt_children -= 1

# print("{}".format(cnt_children))

cnt_candy = 0
cnt_children = 0
for item in a:
    if cnt_candy < x:
        cnt_candy += item
        cnt_children += 1

if cnt_candy != x:
    cnt_children -= 1

print("{}".format(cnt_children))

Measured memory_bytes: 3060