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

class Solver {
    void solve(Scanner sc) {
        String s = sc.next();
        switch (s) {
            case "Sunny":
                System.out.println("Cloudy");
                return;
            case "Cloudy":
                System.out.println("Rainy");
                return;
            case "Rainy":
                System.out.println("Sunny");
        }
    }
}

class Main {
    public static void main(String... args) {
        Scanner in = new Scanner(System.in);

        new Solver().solve(in);

        in.close();
    }
}

Measured memory_bytes: 20948
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		var a = ria();
		for(int i=0;i<5;i++){
			if(a[i] != i + 1){
				Console.WriteLine(i + 1);
				return;
			}
		}
	}

	public Sol(){
		
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 17916
//********rev 2;
#include <iostream>
#include <list>
#include <cctype>

using namespace std;

// data class
class D {
public:
	int n;
	int sets;

	list<D*> child;

	D() :child() {
		n = 0;
		sets = 0;
	};
};

// global var for input
char c[10002];

// get inputs
int get(D *d, int &l) {
	int sum = 0;
	if (c[l] == '[') { // if has datasets
		// loop for all sets
		list<int> ilist;
		while (c[l] == '[') {
			D *dd = new D();
			++l; // INFO: skip '['
			// INFO: rec.
			ilist.push_back(get(dd, l));
			// add to childlen
			d->child.push_back(dd);
			// inc. sets
			d->sets++;
			l++; // INFO: skip ']'
		}
		// create sum of win half groups
		ilist.sort([](int &i1, int &i2){return i1 < i2;});
		auto iter = ilist.begin();
		for (int i = 0; i < d->sets / 2 + 1; i++) {
			sum += *iter;
			iter++;
		}
		d->n = sum;
		return sum;
	} else { // if has NO datasets (== only num)
		// char[] to num
		int num = c[l] - '0';
		for (l++; isdigit(c[l]); l++) {
			num = num * 10 + (c[l] - '0');
		}
		// return: HALF OF num for win
		d->n = num / 2 + 1;
		return d->n;
	}
}

// solve
void solve() {
	int n;
	// input dataset length
	cin >> n;
	for (int i = 0; i < n; i++) {
		// input dataset
		cin >> c;
		D *d = new D();
		// INFO: 1: skip first '['
		int l = 1;
		// string to dataobj;
		get(d, l);
		// get answer
		//cout << ans(d) << endl;
		cout << d->n << endl;
		delete d;
	}
}



//----main----
int main(void) {
	solve();
}

Measured memory_bytes: 3256
//
//AtCoder Beginner Contest 178
//B
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>
#include <bitset>
#include <numeric>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

const double PI = 3.14159265358979323846;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int main()
{
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll ans = a*c;
    ans = max(ans, a*d);
    ans = max(ans, b*c);
    ans = max(ans, b*d);
    cout << ans << endl;
    return 0;
}


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

unordered_map<int, int> memo;

int solve(vector<int> &h, int k, int i)
{
	if (memo.count(i) == 0) {
		int result;
		if (i == 0) {
			result = 0;
		}
		else if (i == 1) {
			result = abs(h[0] - h[1]);
		}
		else {
			result = INT_MAX;
			for (int x = 1; x <= k && (i - x) >= 0; ++x) {
				result = min(abs(h[i] - h[i - x]) + solve(h, k, i - x), result);
			}
		}
		memo[i] = result;
		return result;
	}
	else {
		return memo[i];
	}
}

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

	vector<int> h(n);
	for (auto &hi : h) {
		cin >> hi;
	}
	
	cout << solve(h, k, n - 1) << endl;

    return 0;
}



Measured memory_bytes: 11044
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  int d;
  map<int,string> mp;
  mp[25]="Christmas";
  mp[24]="Christmas Eve";
  mp[23] = "Christmas Eve Eve";
  mp[22]="Christmas Eve Eve Eve";
  cin>>d;
  cout << mp[d] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
char arr[500010], s[10010], ch;
int main(void) {
	int n, i, j, h, t, idx=0, num, temp, num1;
	scanf("%s", s);
	scanf("%d", &n);
	h=250000; 
	t=h+strlen(s)-1;
	for(i=h; i<=t; i++)
		arr[i]=s[idx++];
	for(i=0; i<n; i++){
		scanf("%d", &num);
		if(num==1){
			temp=h;
			h=t;
			t=temp;		
		}
		else{
			scanf("%d", &num1);
			scanf(" %c", &ch);
			if(num1==1){
				if(h>t){
					arr[h+1]=ch;
					h++;
				}
				else{
					arr[h-1]=ch;
					h--;
				}
			}
			else{
				if(h>t){
					arr[t-1]=ch;
					t--;
				}
				else{
					arr[t+1]=ch;
					t++;
				}
			}
		}
	}
	if(h<t){
		for(i=h; i<=t; i++)	
			printf("%c", arr[i]);	
	}
	else{
		for(i=h; i>=t; i--)
			printf("%c", arr[i]);
	}
	return 0;
}

Measured memory_bytes: 896
def abc():
    n = int(input().rstrip())
    ball_list = list(map(int, input().rstrip().split()))

    min_abs = 10000
    for i in range(n):
        s1 = sum([x for j, x in enumerate(ball_list) if j <= i])
        s2 = sum([x for j, x in enumerate(ball_list) if j > i])
        min_abs = min(min_abs, abs(s1 - s2))
    print(min_abs)


abc()


Measured memory_bytes: 3060
t1, t2 = map(int, input().split())
a1, a2 = map(int, input().split())
b1, b2 = map(int, input().split())
c1 = t1*(a1-b1)
c2 = t2*(a2-b2)
d = c1 + c2
if d == 0:
  print("infinity")
elif c1*c2 > 0 or c1*d > 0:
  print(0)
else:
  if abs(c1)%abs(d)==0:
    print((abs(c1)//abs(d))*2)
  else:
    print((abs(c1)//abs(d))*2+1)

Measured memory_bytes: 38500
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  double A,B,H,M,Hx,Hy,Mx,My;
  cin >> A >> B >> H >> M;
  Hx = A*cos((30*H+0.5*M)*M_PI/180);
  Hy = A*sin(-(30*H+0.5*M)*M_PI/180);
  Mx = B*cos(6*M*M_PI/180);
  My = B*sin(-6*M*M_PI/180);
  cout << fixed;
  cout << setprecision(9) << sqrt((Hx - Mx) * (Hx - Mx) + (Hy - My) * (Hy - My))<<endl;
}

Measured memory_bytes: 4252
#include<stdio.h>

int main() {
	int n, a;
	int max = 0, min = 1000000000;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a);
		if (max < a)max = a;
		if (min > a)min = a;
	}
	printf("%d\n", max - min);
	return 0;
}

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

long long int modpow(ll a, ll n){
  ll ans = 1;
  for(int i = 1; i <= n; i++){
    ans = ans*a % MOD;
  }
  return ans;
}


int main() {
  ll n;
  cin >> n;
  ll ans = modpow(10,n) - modpow(9,n) - modpow(9,n) + modpow(8,n);
  ans %= MOD;
  ans = (ans+MOD)%MOD;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
const int maxn=2002;
int c[maxn][maxn];
int main()
{
    c[0][0]=1;
    for(int i=1;i<maxn;i++)
    {
        c[i][0]=1;
        for(int j=1;j<=i;j++)
            c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
    }
    int n,k;scanf("%d%d",&n,&k);
    for(int i=1;i<=k;i++)
    {
        printf("%lld\n",1LL*c[k-1][i-1]*c[n-k+1][i]%mod);
    }
    return 0;
}


Measured memory_bytes: 15104
package main
 
import (
  "fmt"
)
 
func main() {
  var k, a, b int
  fmt.Scanf("%d", &k)
  fmt.Scanf("%d %d", &a, &b)
  
  ans := "NG"
  if a % k == 0 {
    ans = "OK"
  }
  if (a/k) < (b/k) {
    ans = "OK"
  }
  fmt.Printf("%s\n", ans)
}

Measured memory_bytes: 1832
n, q = list(map(int, input().split(' ')))
stacks = [[] for i in range(n)]
 
for i in range(q):
    op = list(map(int, input().split(' ')))
    if op[0] == 0:
        stacks[op[1]].append(op[2])
    elif op[0] == 1:
        if len(stacks[op[1]]) != 0:
            print(stacks[op[1]][-1])
    elif op[0] == 2:
        if len(stacks[op[1]]) != 0:
            stacks[op[1]].pop()


Measured memory_bytes: 13696
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<(S)<<endl
#define F first
#define S second
using namespace std;

int main(){
	int N;
	while(cin>>N,N){
		int P,A,B,C,D,E,F,S,M;
		pair<double ,string> L[N];
		REP(i,0,N){
			cin>>L[i].S>>P>>A>>B>>C>>D>>E>>F>>S>>M;
			L[i].F= (double) - (S*F*M-P)/(A+B+C+(D+E)*M);
		}
		sort(L,L+N);
		REP(i,0,N){
			p(L[i].S);
		}
		p("#");
	}
	return 0;
}

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

const int INF = 1001001001;
vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,1,0,-1};

int h,w;
vector<string> s;
vector<int> steps;

void bfs( pair<int,int> st, pair<int,int> gl ){
  //stからの距離
  vector<vector<int>> dist(h,vector<int>(w,INF));
  queue<pair<int,int>> q;

  auto push = [&]( pair<int,int> now , int d ){
    int y = now.first;
    int x = now.second;
    if( dist.at(y).at(x) != INF ) return;
    dist.at(y).at(x) = d;
    q.push(now);
  };
  push(st,0);
  while( !q.empty() ){
    pair<int,int> now = q.front();
    q.pop();

    int y = now.first;
    int x = now.second;
    int d = dist.at(y).at(x);

    rep(i,4){
      int nowy = y + dy.at(i);
      int nowx = x + dx.at(i);
      if( nowy >=0 && nowy < h && nowx >= 0 && nowx < w && s.at(nowy).at(nowx) != '#' ){
        push(make_pair(nowy,nowx),d+1);
      }
    }
    int gy = gl.first;
    int gx = gl.second;
    if( dist.at(gy).at(gx) != INF ){
      steps.push_back(dist.at(gy).at(gx));
      return;
    }
  }
  
}


int main(){
  cin >> h >> w;
  s.resize(h);
  rep(i,h) cin >> s.at(i);

  for(int i=0;i<h;++i){
    for(int j=0;j<w;++j){
      if( s.at(i).at(j) == '.' ){
        for(int k=0;k<h;++k){
          for(int l=0;l<w;++l){
            if( k == i && l == j ) continue; //スタートとゴールは一致しない
            if( s.at(k).at(l) == '#' ) continue; //壁はゴールにならない
            pair<int,int> st = make_pair(i,j);
            pair<int,int> gl = make_pair(k,l);
            bfs(st,gl);
          }
        }
      }
    }
  }
  sort(steps.begin(),steps.end());
  cout << steps.back() << endl;
  return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define in insert
#define PI 3.1415926535897932384626433832795
#define MOD 100000007
#define F first
#define S second
#define aLL(str) (str).begin(), (str).end()
#define IOS                  \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0)
#define ll long long
#define ld long double
#define lcm(a, b) (a * b) / __gcd(a, b)
#define tr(s)                                      \
	for (auto it = v.begin(); it != v.end(); it++) \
		cout << *it << " ";
#define pv(a)                         \
	for (ll i = 0; i < a.size(); i++) \
		cout << a[i] << " ";
#define flu(i, a, b) for (ll i = a; i < b; i++)
#define blu(i, a, b) for (ll i = a; i >= b; i--)
#define mod 1000000000
typedef vector<ll> vl;
typedef map<ll, ll> ml;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
char e = '\n';
ll i, j, le;
int main()
{
	IOS;
	int t;
t=1;
while (t--)
	{
	ll n, mx, bot=0,got;
	cin>>n;
	vl a(n);
	flu(i,0,n)
	cin>>a[i];
   i=0;
	got=1000;
	while(i<n-1)
	{  bot=0;
		if(a[i+1] > a[i])
           bot = got/a[i];
		
			got+=((a[i+1]-a[i])*bot);
		
		i++;
	}
	cout<<got<<e;
	
	}
	return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;
	VAR(int,n,q);
	VAR(string,s);

	vector<int> sm(n+1,0),sm_r(n+1,0);
	FOR(i,1,n){
		if(s.substr(i-1,2) == "AC") {
			++sm[i];
			++sm_r[i+1];
		}
	}
	REP(i,n){
		sm[i+1] += sm[i];
		sm_r[i+1] += sm_r[i];
		//debug(sm[i]);
		//debug(sm_r[i]);
	}

	while(q--){
		VAR(int,l,r);
		//debug(sm_r[r]);
		//debug(sm[l-1]);
		OUT(sm_r[r]-sm[l-1])BR;
	}
	
  
  return 0;
}


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

#define pb push_back
#define all(a) (a).begin(), (a).end()

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

int main() {
	ios::sync_with_stdio(false);cin.tie(nullptr);
	int n; cin >> n;
	set<string> s;

	while (n--) {
		string si; cin >> si;
		s.insert(si);
	}

	cout << s.size() << '\n';
}
 


Measured memory_bytes: 19220
/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 2000000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(10)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 998244353;

// typedef long long ll;
#define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  int N, v[20], c[20];
  cin >> N;
  REP(i, N) cin >> v[i];
  REP(i, N) cin >> c[i];

  int ans = 0;
  REP(i, N){
    if(v[i] > c[i]) ans += v[i]-c[i];
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;
import java.lang.Math;

// ALDS1_7_B
public class Main {
	void searchDepth(Node[] tree, int i, int n) {
		tree[i].depth = n;
		if (tree[i].left != -1) searchDepth(tree, tree[i].left, n+1);
		if (tree[i].right != -1) searchDepth(tree, tree[i].right, n+1);
	}
	
	int searchHeight(Node[] tree, int i) {
		if (i == -1) return 0;
		tree[i].height = Math.max(searchHeight(tree, tree[i].left), searchHeight(tree, tree[i].right));
		return tree[i].height + 1;
	}
	
	void run() throws IOException {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Node[] tree = new Node[n];
		for (int i = 0; i < n; i++) {
			tree[i] = new Node(i);
		}
		for (int i = 0; i < n; i++) {
			int number = sc.nextInt();
			int left = sc.nextInt();
			int right = sc.nextInt();
			tree[number].left = left;
			tree[number].right = right;
			if (left != -1 && right != -1) {
				tree[number].degree = 2;
				tree[number].type = "internal node";
				tree[left].parent = number;
				tree[left].sibling = right;
				tree[right].parent = number;
				tree[right].sibling = left;
			} else if (left != -1 || right != -1) {
				tree[number].degree = 1;
				tree[number].type = "internal node";
				if (left != -1) tree[left].parent = number;
				if (right != -1) tree[right].parent = number;
			} else {
				tree[number].degree = 0;
				tree[number].type = "leaf";
			}
		}
		// search root
		int root = 0;
		for (int i = 0; i < tree.length; i++) {
			if (tree[i].parent == -1) {
				tree[i].type = "root";
				root = i;
			}
		}
		searchDepth(tree, root, 0);
		searchHeight(tree, root);
		for (int i = 0; i < n; i++) {
			tree[i].print();
		}
		sc.close();
	}
	
	public static void main(String[] args) throws IOException {
		new Main().run();
	}
}

class Node {
	int number;
	int parent = -1;
	int sibling = -1;
	int degree;
	int left;
	int right;
	int depth;
	int height = 0;
	String type;
	Node(int number) {
		this.number = number;
	}
	
	void print() {
		System.out.println("node " + number + ": parent = " + parent + ", sibling = " + sibling + ", degree = " + degree + 
				", depth = " + depth + ", height = " + height + ", " + type);
	}
}


Measured memory_bytes: 26404
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ld long double
#define mx 200005
#define fr first
#define se second
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

struct hello
{
    ll first, second;
}coin[105];

ll n,k;
ll dp[105][100005];
ll func(ll i, ll make)
{
   if(i>n || make == 0) return 0;
   if(dp[i][make]!=-1) return dp[i][make];
   ll ans1=0,ans2=0;
   if(make-coin[i].first>=0){
      ans1+=coin[i].second+func(i+1,make-coin[i].first);
   }
   ans2 = func(i+1,make);
   return dp[i][make]=max(ans1,ans2);
}

int main()
{
   fast;
   cin >> n >> k;
   memset(dp,-1,sizeof dp);
   for(int i=1; i<=n; i++) cin >> coin[i].first >> coin[i].second;
   cout << func(1,k) << "\n";

   return 0;
}


Measured memory_bytes: 82304
import scala.io.{StdIn => in}

object Main extends App {
  val n = in.readInt
  val a = in.readLine.split(" ").map(_.toLong)

  def solve(isEven: Boolean) = {
    val even_odd = if(isEven) 0 else 1
    a./:((0L, 0L, 0)) { (acc, e) =>
      val (count, sum, i) = acc
      val v = sum + e
      if(i % 2 == even_odd) {
        if(v > 0) (count, v, i+1)
        else (count + v.abs + 1L, 1, i+1)
      }
      else {
        if(v < 0) (count, v, i+1)
        else (count + v.abs + 1L, -1, i+1)
      }
    }._1
  }

  val ans = solve(true) min solve(false)
  println(ans)
}

Measured memory_bytes: 51852
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
bool check(ll mid, ll k, ll n, vector<ld> &a){

    ll cnt = 0;
    rep(i, n){
        if(a[i] > mid) cnt += (a[i] / mid);
    }

    return cnt <= k;
}
int main(void){
    ll n, k;
    cin >> n >> k;

    vector<ld> a(n);
    rep(i, n){
        cin >> a[i];
    }

    ll ok = 1e9 + 1;
    ll ng = 0;
    
    while(abs(ok - ng) > 1){
        ll mid = (ok + ng) / 2;
        if(check(mid, k, n, a)){
            ok = mid;
        } else {
            ng = mid;
        }
    }
    cout << ok << endl;
}



Measured memory_bytes: 6428
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll i=0,i##_len=(n);i<i##_len;i++)
#define rep2(i,a,b) for(ll i=(a),i##_len=(b);i<=i##_len;i++)
#define rrep(i,n) ll i=(n);ll now=-1;while(i--&&(now++||1))
#define Yes(n) cout<<((n)?Yes:No)<<"\n"
#define vll vector<ll>
#define pb push_back

using namespace std;
using ll = long long;

static inline void ignore_ret(int x) {x++;}
template<class T> bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
template<class T> T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm(r,v.at(i));return r;}
template<class T> T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> T nCr(T n,T k){return factorial<T>(n)/(factorial<T>(k)*factorial<T>(n-k));}
template<class T> T dot_product(vector<T>u,vector<T>v){T r=0;for(T i=0;i<u.size();i++)r+=u.at(i)*v.at(i);return r;}
template<class T> T sum(vector<T>v){return reduce(all(v),0LL);}

// Template ends here

void solve(ll A, ll B){
    ll cnt = 0;

    rep2(i, A, B) {
        string S = to_string(i);
        bool flag = true;
        rep(j, S.size() / 2) {
            if (S.at(j) == S.at(int(S.size()) - j - 1)) continue;
            else {
                flag = false;
                break;
            }
        }
        cnt += flag;
    }

    printf("%lld\n", cnt);
}

int main() {
    ll A;
    ignore_ret(scanf("%lld",&A));
    ll B;
    ignore_ret(scanf("%lld",&B));
    solve(A, B);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

//素因数分解
vector<pair<ll, ll>> prime_factorize(ll n) {
    vector<pair<ll, ll>> res;
    for(ll i = 2; i * i <= n; i++) {
        if(n % i != 0) continue;
        ll ex = 0;

        while(n % i == 0) {
            ex++;
            n /= i;
        }

        res.push_back({i, ex});
    }

    if(n != 1) res.push_back({n, 1});
    return res;
}
//const auto &res = prime_factorize(n);

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

    int ans = 0;
    for(int i = 1; i <= n; i++) {
        if(i % 2 == 0) continue;
        const auto &res = prime_factorize(i);
        int t = 1;
        for(auto p : res) {
            t *= p.second + 1;
        }
        if(t == 8) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007
using namespace std;



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
	string s,t;
	cin >> s >> t;
	cout << t << s << "\n";
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define IN freopen("nocross.in","r",stdin)
#define OUT freopen("nocross.out","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 2000000000000000000LL
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define LOG 19
#define off 2

#define mod 1000000007LL

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less< i64 >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define maxn 200005

vector <int> a[2] ;
vector <int> g[maxn] ;

void dfs(int u, int par, int fl)
{
    a[fl].pb(u) ;
    for(int v:g[u])
    {
        if(v==par) continue ;
        dfs(v,u,(fl^1)) ;
    }
}

int ans[maxn] ;

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

    for(int i=1 ; i<n ; i++)
    {
        int u , v ;
        scanf("%d %d",&u,&v) ;
        g[u].pb(v) ; g[v].pb(u) ;
    }


    dfs(1,0,0) ;

    if( a[0].size() > a[1].size() ) swap( a[0] , a[1] ) ;

    for(int i=1 ; i<=n ; i+=3)
    {
        ans[ a[1].back() ] = i ;
        a[1].pop_back() ;
    }

    int fl ;
    if( a[1].size() < (n/3) + ((n%3) == 2) ) fl = 0 ;
    else fl = 1;

    for(int i=2; i<=n ; i+=3)
    {
        ans[ a[fl].back() ] = i ;
        a[fl].pop_back() ;
    }

    for(int i=1 , k=3 ; i<=n ; i++)
    {
        if( ans[i]==0 )
        {
            ans[i] = k ;
            k+= 3;
        }
    }

    for(int i=1 ; i<=n ; i++) printf("%d ",ans[i]) ;
    printf("\n") ;

    return 0 ;
}


Measured memory_bytes: 21620
#include<bits/stdc++.h>
using namespace std;
const long long MAX_n = 120, MAX_v = 120 * 1000;
long long N, W, dp[MAX_n][MAX_v], w[120], v[120], sum_v[MAX_v], zero = 0;
int main() {
	cin >> N >> W;
	for(long long i = 0; i < N; i++) {
		cin >> w[i] >> v[i];
		sum_v[i + 1] = sum_v[i] + v[i];
	}
	for(long long i = 1; i < MAX_v; i++) {
		dp[0][i] = -1;
	}
	for(long long i = 0; i < N; i++) {
		for(long long j = 0; j <= sum_v[N]; j++) {
			if(dp[i][j] == -1) {
				if(dp[i][max(zero, j - v[i])] == -1) {
					dp[i + 1][j] = -1;
				}
				else {
					dp[i + 1][j] = w[i] + dp[i][max(zero, j - v[i])];
				}
			}
			else {
				dp[i + 1][j] = min(dp[i][j], w[i] + dp[i][max(zero, j - v[i])]);
			}
		}
	}
	for(long long i = sum_v[N]; i > -1; i--) {
		if(dp[N][i] != -1 && dp[N][i] <= W) {
			cout << i;
			return 0;
		}
	} 
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0;}
template<class T>bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0;}

using ll = long long;
using R = long double;
const R EPS = 1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r) {return (r > EPS) - (r < -EPS);}
inline R sq(R x) {return sqrt(max(x, 0.0L));}

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

// Problem Specific Parameter:

ll a[100010];

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

	rep(i, 1, n + 1) cin >> a[i];

	ll total = 0LL;
	rep(i, n + 1) total += abs(a[i + 1] - a[i]);

	rep(i, 1, n + 1) {
		ll ans = total;
		ans -= abs(a[i] - a[i - 1]);
		ans -= abs(a[i + 1] - a[i]);
		ans += abs(a[i + 1] - a[i - 1]);
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) for(auto x:obj)cout<<x<<' ';cout<<endl;
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int a,b,c;cin>>a>>b>>c;
	if(a==b && b==c && !(a%2)){cout<<-1<<endl; return 0;}
	bool ok = true;
	int ans = 0;
	if(a%2 || b%2 || c%2)ok = false;
	a /= 2; b /= 2; c /= 2;
	while(ok){
		int x = a+b, y = b+c, z = c+a;
		a = x; b = y; c = z;
		++ans;
		if(a%2 || b%2 || c%2)ok = false;
		a /= 2; b /= 2; c /= 2;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

	string s;
	cin >> s;
	if(s[5]=='0'){
		if(s[6]=='1' || s[6]=='2' || s[6]=='3' || s[6]=='4'){
			cout << "Heisei" << endl;
		} else {
			cout << "TBD" << endl;
		}
	} else {
		cout << "TBD" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<long double,long double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<61;
const double pi=acos(-1);
const double eps=1e-10;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n;
vi p,b;
vvi g;
vd dp,a;

void dfs(int v,int u){
	p[v]=u;
	int t=0;
	for(int i=0;i<g[v].size();i++){
		int w=g[v][i];
		if(p[w]==-2){
			dfs(w,v);
			dp[v]+=dp[w];
			t++;
		}
	}
	if(t) dp[v]=dp[v]/t+1;
	b[v]=t;
}

void DFS(int v,double d){
	a[v]=(dp[v]*b[v]+d+1)/(b[v]+1);
	for(int i=0;i<g[v].size();i++){
		int u=g[v][i];
		if(u!=p[v]) DFS(u,(d-dp[u])/b[v]+dp[v]);
	}
}

int main(){
	cin>>n;
	p=b=vi(n,-2);
	g=vvi(n);
	dp=a=vd(n);
	for(int i=1;i<n;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(0,-1);
	a[0]=dp[0];
	for(int i=0;i<g[0].size();i++){
		int u=g[0][i];
		DFS(u,(b[0]==1?0:(dp[0]*b[0]-dp[u]-1)/(b[0]-1)));
	}
	for(int i=0;i<n;i++) cout<<syosu(9)<<a[i]<<endl;
}

Measured memory_bytes: 21888
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(auto i=0;i<n;++i)
#define REPR(i,n) for(auto i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(auto i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  string s;
  cin >> s;

  int len = s.length();
  int ans = 0, l = 0;
  REP(i,len){
    if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
      l++;
    }else{
      ans = max(ans, l);
      l = 0;
    }
  }
  ans = max(ans, l);

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<numeric>
#include<cctype>
using namespace std;

int kakuketanosum(int n) {
	int s = 0;
	while (n > 0) {
		s += n % 10;
		n = n / 10;
	}
	/*if (s >= 10)
		s = kakuketanosum(s);
	else*/
		return s;
}
void kazusout(double* a, int n) {
	for (int i = 0; i < n-1 ; i++) {
		if (*(a+i) > * (a + i+1)) {
			int temp = *(a + i);
			*(a + i) = *(a + i + 1);
			*(a + i + 1) = temp;
		}
	}
}
int main(void) {
	int n;
	double a[50];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < 2*n; i++) {
		kazusout(&a[0],n);
	}
	double s = a[0];
	for (int i = 1; i < n ; i++) {
		s = (s + a[i]) / (2.0);
	}
	cout << s << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int W, H, N;
  cin >> W >> H >> N;
  vector<vector<int>> v(N, vector<int>(3));
  int x, y, a;
  int x_max = W;
  int x_min = 0;
  int y_max = H;
  int y_min = 0;

  for (int i = 0; i < N; i++) {
    cin >> x >> y >> a;
    switch (a) {
      case 1:
        x_min = max(x, x_min);
        break;
      case 2:
        x_max = min(x, x_max);
        break;
      case 3:
        y_min = max(y, y_min);
        break;
      case 4:
        y_max = min(y, y_max);
        break;

      default:
        break;
    }
  }
  if (x_max < x_min || y_max < y_min) {
    cout << 0 << endl;
  } else {
    cout << (x_max - x_min) * (y_max - y_min) << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int N,M,X;
int c[100000];
struct stu
{
	int a;
	int b[100000];
}book[15];
int main()
{
	scanf("%d%d%d\n",&N,&M,&X);
	int i,j,k;
	int sum,ans=2e9;
	for(i=0;i<N;i++)
	{
		scanf("%d",&book[i].a);
		for(j=0;j<M;j++)
			scanf("%d",&book[i].b[j]);
	}
	for(i=0;i<pow(2,(float)N);i++)
	{
		memset(c,0,sizeof c);
		sum=0;
		for(j=0;j<N;j++)
		{
			if(i>>j&1)
			{
				sum+=book[j].a;
				for(k=0;k<M;k++)
					c[k]+=book[j].b[k];
			}
		}
		bool flag=1;
		for(j=0;j<M;j++)
		if(c[j]<X) flag=0;
		if(flag) ans=min(ans,sum);
	}
	if(ans==2e9) cout<<"-1";
	else cout<<ans;

}

Measured memory_bytes: 3792
N, Q = map(int,input().split())
S = input()

t = [0]*(N+1)
for i in range(N):
  if(S[i:i+2] == "AC"):
    t[i+1] += t[i]+1
  else:
    t[i+1] += t[i]
    
for _ in range(Q):
  l, r = map(int,input().split())
  print(t[r-1] - t[l-1])

Measured memory_bytes: 7668
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll MOD = 1000000007;
int main() {
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<>());
  printf(t > s ? "Yes\n" : "No\n");
}

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

int main(){
  int D,G;
  cin>>D>>G;
  vector<vector<int>> A(D,vector<int>(2));
  int l=0;
  for(vector<int> &i:A){
    cin>>i.at(0)>>i.at(1);
    l+=i.at(0);
  }
  for(int tmp=0;tmp<(1<<A.size());tmp++){
    bitset<10> s(tmp);
    int j=0,p=0;
    for(int i=0;i<A.size();i++)
      if(s.test(i)){
        j+=(i+1)*A.at(i).at(0)*100+A.at(i).at(1);
        p+=A.at(i).at(0);
      }
    int o=0;
    int i=D-1;
    for(;s.test(i);i--)
      if(i==0){
        i=-1;
        break;
      }
    if(i==-1){
      l=min(l,p);
      continue;
    }
    int k=0;
    for(;k*(i+1)*100+j<G;k++){}
    if(k>=A.at(i).at(0))
      continue;
    l=min(l,k+p);
  }
  cout<<l<<endl;
}

Measured memory_bytes: 256
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define inf 20021225
#define mdn 1000000007
#define lowbit(x) (x&-x)
#define N 100010
using namespace std;
int read()
{
	int s=0,t=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')	t=-1; ch=getchar();}
	while(ch>='0' && ch<='9')	s=s*10+ch-'0',ch=getchar();
	return s*t;
}
int n,tr[N],m;
void upd(int &x,int y){x+=x+y>=mdn?y-mdn:y;}
void add(int x,int v){while(x<=n) upd(tr[x],v),x+=lowbit(x);}
int ask(int x){int a=0; while(x) upd(a,tr[x]),x-=lowbit(x); return a;}
int x[N],y[N],v[N],f[N]; struct node{int x,y;}a[N];
bool operator<(node f,node g){return f.x==g.x?f.y<g.y:f.x<g.x;}
bool operator!=(node f,node g){return f.x!=g.x||f.y!=g.y;}
int main()
{
	n=read(),m=read();
	for(int i=1;i<=n;i++)	x[i]=read();
	for(int i=1;i<=m;i++)	y[i]=read();
	int pt=0,tot=0;
	for(int i=1;i<=n;i++)
	{
		while(pt<m&&y[pt+1]<x[i])	pt++;
		if(pt&&pt<m)	a[++tot]=(node){x[i]-y[pt],y[pt+1]-x[i]},v[tot]=y[pt+1]-x[i];
	}
	sort(v+1,v+tot+1); n=unique(v+1,v+tot+1)-v-1;
	for(int i=1;i<=tot;i++)	a[i].y=lower_bound(v+1,v+n+1,a[i].y)-v;
	sort(a+1,a+tot+1);
	int ans=0;
	for(int i=1;i<=tot;i++)
	{
		int rem=i;
		while(i<=tot&&a[i].x==a[rem].x)
		{
			if(a[i]!=a[i-1])
				f[i]=ask(a[i].y-1)+1;
			i++;
		}
		i--;
		while(rem<=i)
		{
			if(a[rem]!=a[rem-1])
				add(a[rem].y,f[rem]),upd(ans,f[rem]);
			rem++;
		}
	}
	printf("%d\n",(ans+1)%mdn);
	return 0;
}


Measured memory_bytes: 2688
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30

def main():
    n, m = list(map(int, input().strip().split()))
    a = []
    b = []
    for i in range(n):
        a.append(input().strip())
    for i in range(m):
        b.append(input().strip())
    for i in range(n):
        if i + m > n:
            break
        for j in range(n):
            if j + m > n:
                break
            flag = False
            for p in range(m):
                for q in range(m):
                    if b[p][q] != a[i+p][j+q]:
                        flag = True
                        break 
            if flag:
                continue
            else:
                print('Yes')
                return
    print('No')

if __name__ == '__main__':
    main()


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

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

	if (true == ((a < b) ? ((b < c) ? true : false) : false)) {
				cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

    return 0;

}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    ll ans = 1;
    for(int i = 1; i <= n; i++){
        ans *= i;
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)
dp = Array.new(n+1){[-10**15]*3}

if n <= 3
  p a.max
  exit
end

dp[1][0] = a[0]
dp[2][1] = a[1]
dp[3][0] = a[0] + a[2]
dp[3][2] = a[2]

4.upto(n) do |i|
  x = a[i-1]
  dp[i][0] = dp[i-2][0] + x
  dp[i][1] = [dp[i-2][1], dp[i-3][0]].max + x
  dp[i][2] = [dp[i-2][2], dp[i-3][1], dp[i-4][0]].max + x
end

if n.odd?
  p [dp[n][2], dp[n-1][1], dp[n-2][0]].max
else
  p [dp[n][1], dp[n-1][0]].max
end

Measured memory_bytes: 41296
#include<cstdio> // 有向图最长路  !! 有向图 
#include<vector>
#include<algorithm>
#include<cstring>
using namespace std;

const int maxn=1e5+5;

vector<int> edge[maxn];

int vis[maxn];

int d[maxn]; 

int dp(int);

int n,m; 

int main(){
	
	scanf("%d %d",&n,&m);
	
	for(int i=0;i<m;i++){
	
		int s,t; scanf("%d %d",&s,&t);

		edge[s].push_back(t);
	}
	
	int ans=0; memset(d,-1,sizeof(d));

	memset(vis,0,sizeof(vis));

	for(int i=1;i<=n;i++){
	
		vis[i]=1;
	
		ans=max(ans,dp(i));

		vis[i]=0;
	}

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

	return 0;

}

int dp(int u){
	
	int &ans=d[u];

	if(ans!=-1) return ans;

	else {
	
		ans=0;
	
		for(int i=0;i<edge[u].size();i++){
	
			int v=edge[u][i];

			if(!vis[v]){

			vis[v]=1;

			ans=max(ans,dp(v)+1);

			vis[v]=0;

			}
		}

		return ans;
	}

	
}

Measured memory_bytes: 8576
def print_list(A):
    print(*A, sep=" ")

def insertion_sort(A, n):
    print_list(A)
    for i in range(1, n):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
        print_list(A)

n = int(input())
A = list(map(int,input().split()))

insertion_sort(A, n)


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

using namespace std;

typedef long long LL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<LL> vl;
typedef vector<vector<LL>> vvl;
typedef vector<vector<vector<LL>>> vvvl;


const int inf = 1e9+7;
const LL INF = 1e18+5;
const int mod = 1e9+7;
const int mxN = 1e5+5;
const int mxM = 1e5+5;

int main(){
    #ifndef ONLINE_JUDGE
    freopen("E:\\Coding\\Programming\\input.txt", "r", stdin);
    freopen("E:\\Coding\\Programming\\output.txt", "w", stdout);
    #endif
    int n;
    cin>>n;
    vi l(n);
    int c = 0;
    for(int i=0;i<n;i++) cin>>l[i];
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++){
                if((l[i]!=l[j])&&(l[j]!=l[k])&&(l[i]!=l[k])){
                    if((l[i]+l[j]>l[k])&&(l[i]+l[k]>l[j])&&(l[j]+l[k]>l[i])) c++;
                }
            }
        }
    }
    cout<<c<<endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define int long long
inline void read (int &x) {
	char ch = getchar(); x = 0;
	while (!isdigit(ch)) ch = getchar();
	while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
} map<int, int> mp; int a, b, c, d;
inline int work (int n) {
	if (n == 0) return 0;
	if (n == 1) return d;
	if (mp[n]) return mp[n];
	int res = 8e18, l, r;
	if (n < res / d) res = n * d;
	l = (n / 2) * 2, r = ((n + 1) / 2) * 2;
	res = min (res, (n - l) * d + a + work (l / 2));
	res = min (res, (r - n) * d + a + work (r / 2));
	l = (n / 3) * 3, r = ((n + 2) / 3) * 3;
	res = min (res, (n - l) * d + b + work (l / 3));
	res = min (res, (r - n) * d + b + work (r / 3));
	l = (n / 5) * 5, r = ((n + 4) / 5) * 5;
	res = min (res, (n - l) * d + c + work (l / 5));
	res = min (res, (r - n) * d + c + work (r / 5));
	mp[n] = res; return res;
}
signed main() {
	int T; read (T);
	while (T--) {
		int n; read (n); mp.clear();
		read (a), read (b), read (c), read (d);
		printf ("%lld\n", work (n));
	}
}

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

struct RS {
	using t1 = int;
	using t2 = int;
	static t2 id2() { return 0; }
	static t1 op2(const t1& l, const t2& r) { return l + r; }
	static t2 op3(const t2& l, const t2& r) { return l + r; }
};

template <typename M>
class lazy_segment_tree {
	using T1 = typename M::t1;
	using T2 = typename M::t2;
	const int h, n;
	vector<T1> data;
	vector<T2> lazy;
	void push(int node) {
		if (lazy[node] == M::id2()) return;
		if (node < n) {
			lazy[node << 1] = M::op3(lazy[node << 1], lazy[node]);
			lazy[(node << 1) + 1] = M::op3(lazy[(node << 1) + 1], lazy[node]);
		}
		lazy[node] = M::id2();
	}
public:
	lazy_segment_tree(int n_, T1 v1)
		: h(ceil(log2(n_))), n(1 << h), data(n, v1), lazy(n << 1, M::id2()) {}
	lazy_segment_tree(const vector<T1>& data_)
		: h(ceil(log2(data_.size()))), n(1 << h), data(data_), lazy(n << 1, M::id2()) {}
	void update(int l, int r, T2 val) {
		l += n, r += n;
		for (int i = h; i > 0; i--) push(l >> i), push(r >> i);
		r++;
		while (l < r) {
			if (l & 1) lazy[l] = M::op3(lazy[l], val), l++;
			if (r & 1) r--, lazy[r] = M::op3(lazy[r], val);
			l >>= 1; r >>= 1;
		}
	}
	T1 find(int p) {
		T1 res = data[p]; p += n;
		while (p) res = M::op2(res, lazy[p]), p >>= 1;
		return res;
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q;
	cin >> n >> q;
	lazy_segment_tree<RS> lst(n, 0);
	while (q--) {
		int com;
		cin >> com;
		if (com == 0) {
			int s, t, x;
			cin >> s >> t >> x; s--, t--;
			lst.update(s, t, x);
		}
		else {
			int p;
			cin >> p; p--;
			printf("%d\n", lst.find(p));
		}
	}
	return 0;
}



Measured memory_bytes: 4488
a,b = map(int,input().split())
lis = [0]*a
for i in range(b):
  c = int(input())
  d = input().split()
  
  for l in range(c):
    lis[int(d[l])-1] += 1
    
count = 0
for i in range(a):
  if(lis[i] == 0):
    count += 1

print(count)

Measured memory_bytes: 9204