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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

void solve(){
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(a,b)<<" "<<max(0,a+b-n)<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <climits>
#include <cstring>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

using namespace std;

const int N_MAX = 1000000;

struct Node{
  int data;
  Node* left = NULL;
  Node* right = NULL;
};

Node* insert(Node* root, int data){
  if(root==NULL){
    Node* new_node = new Node;
    new_node->data = data;
    return new_node;
  }  
  if(root->data > data) root->left = insert(root->left, data);
  if(root->data < data) root->right = insert(root->right, data);
  
  return root;
  
  // if root == NULL, return new node
  // root->data > data --> insert(root->right, data)
  // root->data < data --> insert(root->left,  data)  
}

void print_inorder(Node* root){
  if(root == NULL) return;
  print_inorder(root->left);
  cout << " " << root->data;
  print_inorder(root->right);
}

void print_preorder(Node* root){
  if(root == NULL) return;
  cout << " " << root->data;
  print_preorder(root->left);
  print_preorder(root->right);
}

bool find(Node* root, int data){
  if(root != NULL){
    if(root->data == data) return true;
    else if(root->data > data) return find(root->left, data);
    else if(root->data < data) return find(root->right, data);
  }
  return false;
}

int main(){
  int n;
  cin >> n;
  Node* root = NULL;

  typedef pair<string, int> P;
  vector<P> orders;
  
  rep(i, 0, n){
    string order;
    int data = -INT_MAX;
    
    cin >> order;
    if(order == "insert" || order == "find")cin >> data;
    P order_data = make_pair(order, data);
    orders.push_back(order_data);
  }

  rep(i, 0, orders.size()){
    string ord = orders[i].first;
    int data = orders[i].second;
    
    if(ord == "insert") root = insert(root, data);
    else if(ord == "find"){
      if(find(root, data)){
	cout << "yes" << endl;
      }
      else cout << "no" << endl;
    }
    else{
      print_inorder(root);
      cout << endl;
      print_preorder(root);
      cout << endl;
    }
  }
  return 0;
}



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

int main(){
    int n;
    cin >> n;
    ll m=0,a=0,r=0,c=0,h=0;
    for(int i=0; i<n; i++){
        string s;
        cin >> s;
        if(s.at(0) == 'M') m++;
        if(s.at(0) == 'A') a++;
        if(s.at(0) == 'R') r++;
        if(s.at(0) == 'C') c++;
        if(s.at(0) == 'H') h++;
    }
    ll ans=0;
    ans += m*a*r + m*a*c + m*a*h;
    ans += m*r*c + m*r*h + m*c*h;
    ans += a*r*c + a*r*h + a*c*h + r*c*h;
    cout << ans << endl;
}

Measured memory_bytes: 3576
/* 実行時間1s制限の場合
  10^6 1,000,000   : 余裕をもって間に合う
  10^7 10,000,000  : おそらく間に合う
  10^8 100,000,000 : 非常にシンプルな処理でないと厳しい
 */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#include <bits/stdc++.h>
using namespace std;

typedef long long ll; // long longはデータモデル(LLP64, LP64, ...)によらず64bit.
ll gcd(ll a, ll b) {return b ? gcd(b, a%b) : a;}  // Greatest Common Divisor ユークリッドの互除法（aが長辺）
vector<pair<ll,int>> factorize(ll n) {            // a,bの公約数 = GCD(a, b)の約数
    vector<pair<ll,int>> res;
    for (ll i = 2; i*i <= n; i++) { // √nまで探せばよい
        if (n%i) continue;
        res.emplace_back(i, 0);     // 割り切れたら
        while (n%i == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if (n != 1) res.emplace_back(n, 1); // この時点で1でなかったら、残りは素数.
    return res;
}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}         // Least Commont Multiple オーバーフローしないように先に割る
ll ceil(ll a, ll b) {return (a+b-1)/b;}

const ll INF = LONG_MAX;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(int argc, char* argv[])
{
#ifdef LOCAL
    // 以降 cin の入力元が 'xxx.txt' になる
    // std::ifstream in(argv[1]);
    //std::cin.rdbuf(in.rdbuf());
    std::ifstream in("b.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    int n;
    cin >> n;

    bool ans = false;
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            if (n == i*j) {
                ans = true;
            }
        }
    }

    if (ans) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }


    return 0;
}

/*
  - 1e9 : 10^9
  - container一般
    - 合計
      accumulate(a.begin(), a.end(), 0LL)  0LLはオーバーフロー用
  - vector
    vector<int> A(N, 0); // 0で初期化(省略可)
    - loop
      for  (int i = 0; i < A.size(); i++) {}
      for  (int elem : A) {}
    - sort
      std::sort(v.begin(), v.end());  // 昇順
      std::sort(v.begin(), v.end(), std::greater<int>()); //降順
      - vector<vector<int>> cnt(h, vector<int>(w))
    - sort(struct)
        struct st_t {
            string name;
            int p;
            bool operator<(const st_t& another) const {
                if (name == another.name)
                {
                    return p > another.p;
                }
                return name < another.name;
            }
        };
        vector<st_t> st(n);
        sort(st.begin(), st.end());
  - pair
    - pairのソートの定義 : firstが優先的に比較。同じだったらsecond。
    - pair<pair<string,int>,int> p[110];
      std::sort(p,p+a);
        こうすると、first.first -> first.second -> secondの順にソートされる
    - sort
      - sort(a.begin(), cb.end(), greater<pair<int, int>>());
  - map
    - for (auto x : map) {}  // x.first:key  x.second:value.
  - priority_queue<int> q;
    - q.top()に最大値が入っている
  - string
    - loop
      for (char& c : s) {}
 */



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

public class Main {
	static Scanner sc = new Scanner(System.in);
	static final int INF = Integer.MAX_VALUE;
	static int N = Integer.parseInt(sc.next());
	static int W = Integer.parseInt(sc.next());
	static int V = 1000 * N;
	static int[] w = new int[N];
	static int[] v = new int[N];
	static long[] dp = new long[V+1];
	static {
		Arrays.fill(dp, INF);
		dp[0] = 0;
	}
	public static void main(String[] args) {
		for (int i = 0; i < N; i++) {
			w[i] = Integer.parseInt(sc.next());
			v[i] = Integer.parseInt(sc.next());
		}
		for (int i = 0; i < N; i++) {
			for (int j = V; j >=0; j--) {
//				System.out.println(dp[j]);
				if (j-v[i]>=0) {
					dp[j] = Math.min(dp[j], dp[j-v[i]]+w[i]);
				}
			}
		}
//		System.out.println(Arrays.toString(dp));
		int ans = -1;
		for (int i = 0; i < V+1; i++) {
			if (dp[i] <= W) {
//				System.out.println(dp[i]);
				ans = i;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 24276
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

#define MAX_N 128
int order[MAX_N];

void q86() {
	int s, t;
	for (;cin >> s;) {
		cin >> t;
		int start = 1;
		int goal = 2;
		memset(order, 0, sizeof(order));
		for (;;) {
			if (!s) break;
			order[s]++;
			order[t]++;
			cin >> s >> t;
		}
		bool flag = true;
		bool tmp = order[start] & 1;
		if (!(order[start] & 1) || !(order[goal] & 1)) {
			flag = false;
		}
		for (int i = 3; i < MAX_N; i++) {
			if (order[i] & 1 == 1) flag = false;
		}

		cout << (flag ? "OK" : "NG") << endl;
		
	}
}

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

Measured memory_bytes: 3072
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.StringTokenizer;
import java.util.TreeSet;
import java.util.stream.Collectors;

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		
		int n = fs.nextInt();
		int[] aArr = new int[n];
		int[] bArr = new int[n];
		
		long aSum = 0;
		for(int i = 0; i < n; i++) {
			int a = fs.nextInt();
			aSum += a;
			aArr[i] = a;
		}
		
		long bSum = 0;
		for(int i = 0; i < n; i++) {
			int b = fs.nextInt();
			bSum += b;
			bArr[i] = b;
		}
		
		if(bSum > aSum) {
			System.out.println(-1);
			return;
		}
		
		
		ArrayList<Integer> diffPlusList = new ArrayList<>();
		ArrayList<Integer> diffMinusList = new ArrayList<>();
		
		for(int i = 0; i < n; i++) {
			
			int diff = aArr[i] - bArr[i];
			
			if(diff > 0) {
				diffPlusList.add(diff);
			}else if(diff < 0) {
				diffMinusList.add(diff);
			}
		}
		
		long minusDiffSum = 0;
		for(Integer minusDiff : diffMinusList) {
			minusDiffSum += minusDiff;
		}
		
		diffPlusList.sort((val1,val2) -> val2 - val1);
		int sumNum = 0;
		while(minusDiffSum < 0) {
			minusDiffSum += diffPlusList.get(sumNum++);
		}
		
		System.out.println(diffMinusList.size() + sumNum);
	}	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 56644
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int n;
    cin >> n;
    vector<pair<string, int>> s(n);
    rep(i, 0, n){
        cin >> s[i].first >> s[i].second;
    }
    string x;
    cin >> x;
    int count = 51;
    int sum = 0;
    rep(i, 0, n){
        if(s[i].first == x){
            count = i;
        }
        if(i > count){
            sum += s[i].second;
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include <string.h>
#include<math.h>
#include<iostream>
using namespace std;

int main()
{
    int N, D;
    double x, y;
    int count = 0;


    cin >> N >> D;

    for (int i = 0; i < N; i++) {
        cin >> x >> y;
        if (sqrt(x * x + y * y) <= D)
            count++;
    }

    cout << count << endl;


    return 0;
}

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

using namespace std;

const int N = 2e5 + 7;

int n;
long long sum;
int a[N];

int main()
{
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        //freopen("in.in" , "r" , stdin) ;
        cin >> n;
        for (int i = 0; i < n; i++)
        {
                cin >> a[i];
        }
        sort(a, a + n);
        int trn = 1 ; 
        int k = n -1  ; 

        for(int i = n -1 ; i>= 0 ; i--){
                int xtrn = trn ; 
                while(k && xtrn--){
                        sum+=a[i] ; 
                        k-- ;
                }

                trn = 2 ;
        }
        cout<< sum ; 
        return 0;
}

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

using namespace std;

int N;
vector<vector<int>> tree;
vector<pair<int,int>> times;

void stamp(int ind, int &time){
	//cout << ind << "," << time << endl;
	if(times[ind].first == 0) times[ind].first = time++;
	else return;
	if(tree[ind].size() == 0){
		times[ind].second = time++;
		//cout<<"break! " << ind << endl;
		return;
	}
	for(int i=0;i<tree[ind].size();i++){
		//cout << tree[ind][i] << endl;
		stamp(tree[ind][i],time);
	}
	//cout << ind << ":" << time << endl;
	times[ind].second = time++;
	if(ind == 1){
		for(int i=2;i<=N;i++){
			stamp(i,time);
		}
	}
}

int main(){
	cin >> N;
	tree = vector<vector<int>>(N+1);
	times = vector<pair<int,int>>(N+1,make_pair(0,0));

	for(int i=1;i<N+1;i++){
		int ind, branch;
		cin >> ind >> branch;
		vector<int> tmp(branch);
		for(int j=0;j<branch;j++){
			int in;
			cin >> in;
			tmp[j] =  in;
		}
		tree[ind] = tmp;
	}

	int time = 1;
	stamp(1,time);

	int i = 1;
	for(auto st:times){
		if(i<=N)
			cout << i << " " << times[i].first << " " << times[i].second << endl;
		i++;
	}

	return 0;
}

Measured memory_bytes: 3156
H, W = [int(x) for x in input().split()]
s_lst = [input() for i in range(H)]
for i in range(H):
    for j in range(W):
        if s_lst[i][j] == '.':
            cnt = 0
            for k in range(max(0, i-1), min(H, i + 2)):
                for l in range(max(0, j-1), min(W, j+2)):
                    if s_lst[k][l] == '#':
                        cnt += 1
            s_lst[i] = s_lst[i][:j] + str(cnt) + s_lst[i][j + 1:]
for i in range(H):
    print(s_lst[i])


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(v) v.begin(),v.end()
#define endll "\n"

#define fin             freopen("input.txt","r",stdin);
#define fout            freopen("output.txt","w",stdout);


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    for(int i=0;i<s.size();i++){
        if(s[i]==','){
            cout << " ";
        }
        else cout << s[i];
    }
    cout << endl;

    return 0;
}



Measured memory_bytes: 3596
import java.util.*;

class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    
    int k = sc.nextInt();
    String s = sc.next();
    
    int n = s.length();
    if(n <= k) {
      System.out.println(s);
    } else {
      String newS = s.substring(0, k);
      System.out.println(newS + "...");
    }
  }
}

Measured memory_bytes: 38784
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>

using ll = long long;
using namespace std;
#define modmod 1000000007

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


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

    int result = 1;
    int maxi = 100003;
    long double root = sqrt(N);
    ll root_N = (ll)root;
    ll yakusu1 = 100003;
    ll yakusu2 = 100003;
    //printf("%d\n",root_N);
    for(int i = root_N; i >= 2; i--){
        if(N%i == 0){
            yakusu1 = i;
            yakusu2 = N/i;
            break;
        }
    }

    //printf("%d,%d\n",yakusu1,yakusu2);

    maxi = max(yakusu1,yakusu2);

    if(maxi == 100003){
        maxi = N;
    }

    //printf("%d\n",maxi);

    while(1){
        if(maxi/10 == 0){
            break;
        }else{
            maxi = maxi/10;
            result++;
        }
    }

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();

		List<Integer> listCardLankS = new ArrayList<Integer>();
		List<Integer> listCardLankH = new ArrayList<Integer>();
		List<Integer> listCardLankC = new ArrayList<Integer>();
		List<Integer> listCardLankD = new ArrayList<Integer>();

		List<String> listEgaraS = new ArrayList<String>();
		List<String> listEgaraH = new ArrayList<String>();
		List<String> listEgaraC = new ArrayList<String>();
		List<String> listEgaraD = new ArrayList<String>();

		for(int i = 1; i < 14; i++) {
			listCardLankS.add(i);
			listCardLankH.add(i);
			listCardLankC.add(i);
			listCardLankD.add(i);

			listEgaraS.add("S");
			listEgaraH.add("H");
			listEgaraC.add("C");
			listEgaraD.add("D");
		}

		for(int i = 0; i < A; i++) {
			String strA = sc.next();
			int intA = sc.nextInt();

		//	System.out.println("?????? : "+strA);
		//	System.out.println("????????? : "+intA);
			if(listEgaraS.contains(strA) && listCardLankS.contains(intA)) {
		//		System.out.println("?????????????????????????????£?????????");
				listEgaraS.remove(strA);
				listCardLankS.remove((Integer)intA);
			}
			if(listEgaraH.contains(strA) && listCardLankH.contains(intA)) {
		//		System.out.println("?????????????????????????????£?????????");
				listEgaraH.remove(strA);
				listCardLankH.remove((Integer)intA);
			}
			if(listEgaraC.contains(strA) && listCardLankC.contains(intA)) {
		//		System.out.println("?????????????????????????????£?????????");
				listEgaraC.remove(strA);
				listCardLankC.remove((Integer)intA);
			}
			if(listEgaraD.contains(strA) && listCardLankD.contains(intA)) {
		//		System.out.println("?????????????????????????????£?????????");
				listEgaraD.remove(strA);
				listCardLankD.remove((Integer)intA);
			}

		}

		for(int j : listCardLankS) {
			System.out.println("S "+j);
		}
		for(int j : listCardLankH) {
			System.out.println("H "+j);
		}
		for(int j : listCardLankC) {
			System.out.println("C "+j);
		}
		for(int j : listCardLankD) {
			System.out.println("D "+j);
		}
	}
}

Measured memory_bytes: 26356
n=int(input())
a=list(map(int,input().split()))
if a[0]>=2:
    print(-1)

else:
    pN=1
    s=1
    l=[]
    S=sum(a)
    b=0
    z=1
    for k in range(len(a)):
        b+=a[k]
        l.append(b)

    for i in range(1,n+1):
        if a[i]>2*pN:
            print(-1)
            z=0
            break
        else:
            pN=min(2*pN-a[i],S-l[i])
            s+=pN
    s+=S
    if n==0:
        s=1
    if a[0]==1 and n>=1:
            print(-1)
            z=0

    if z:
        print(s)

Measured memory_bytes: 20132
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

using ll = long long;
ll mod_pow(ll x, ll n, ll mod)
{
    ll res = 1;
    while (n > 0)
    {
        if (n & 1)
            (res *= x) %= mod;
        (x *= x) %= mod;
        n >>= 1;
    }
    return res;
}

int main()
{
    ll m, n;
    cin >> m >> n;
    cout << mod_pow(m, n, mod) << endl;
}


Measured memory_bytes: 3088
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2727

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	string S, T;
	string t, t2;
	
	cin>>S>>T;
	
	for(int i = 0; i < S.size(); i++){
		if(i%2) t += S[i];
		else t2 += S[i];
	}

	bool flag = true, flag2 = true;;
	
	for(int i = 0, j = 0; i < t.size(); i++,j++){
		for(; j < T.size(); j++){
			if(T[j] == t[i]){
				break;
			}
		}
		if(j == T.size()){
			flag = false;
			break;
		}
	}
	for(int i = 0, j = 0; i < t2.size(); i++,j++){
		for(; j < T.size(); j++){
			if(T[j] == t2[i]){
				break;
			}
		}
		if(j == T.size()){
			flag2 = false;
			break;
		}
	}
	
	cout<<yn(flag||flag2)<<endl;
	
	return 0;
}


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

using namespace std;

const int H = 15;
const int W = 1e3 + 5;
const int INF = 2e9;

int h, w, k;
char a[H][W];
int sz[H][W];
int ans;
pair<int, int> v[H];

int sizes(int x1, int y1, int x2, int y2) {
  return sz[x2][y2] - sz[x1 - 1][y2] - sz[x2][y1 - 1] + sz[x1 - 1][y1 - 1];
}

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

  cin >> h >> w >> k;
  for (int i = 1; i <= h; i++) {
    int pre = 0;
    for (int j = 1; j <= w; j++) {
      cin >> a[i][j];
      pre += (a[i][j] == '1');
      sz[i][j] = pre + sz[i - 1][j];
    }
  }
  ans = INF;
  for (int mask = 0; mask < (1 << (h - 1)); mask++) {
    int res = 0;
    int lenz = 0;
    int cur = 1;
    for (int i = 1; i <= h - 1; i++) {
      bool onz = (mask & (1 << (i - 1)));
      if (onz) {
        res++;
        v[++lenz] = {cur, i};
        cur = i + 1;
      }
    }
    v[++lenz] = {cur, h};
    int startz = 1;
    bool flag = true;
    for (int j = 1; j <= w; j++) {
      bool change = false;
      for (int i = 1; i <= lenz; i++) {
        int cursize = sizes(v[i].first, startz, v[i].second, j);
        if (cursize > k) {
          startz = j;
          res++;
          change = true;
          break;
        }
      }
      if (!change) continue;
      for (int i = 1; i <= lenz; i++) {
        int cursize = sizes(v[i].first, startz, v[i].second, j);
        if (cursize > k) {
          flag = false;
          break;
        }
      }
      if (!flag) break;
    }
    if (flag) ans = min(ans, res);
  }
  cout << ans << '\n';

  return 0;
} 

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

#include <boost/range/adaptors.hpp>

int main() {
    std::string S;
    std::cin >> S;

    int Q;
    std::cin >> Q;

    std::vector<std::string> front;
    std::vector<std::string> back;
    bool is_reverse = false;
    for (int i = 0; i < Q; ++i) {
        int T;
        std::cin >> T;
        if (T == 1) {
            is_reverse = !is_reverse;
        } else {
            int F;
            std::string C;
            std::cin >> F >> C;
            if ((!is_reverse && F == 1) || (is_reverse && F == 2)) {
                front.push_back(C);
            } else {
                back.push_back(C);
            }
        }
    }
    if (!is_reverse) {
        for (const auto& C : boost::adaptors::reverse(front)) {
            std::cout << C;
        }
        std::cout << S;
        for (const auto& C : back) {
            std::cout << C;
        }
        std::cout << std::endl;
    } else {
        for (const auto& C : boost::adaptors::reverse(back)) {
            std::cout << C;
        }
        for (int i = S.size() - 1; i >= 0; --i) {
            std::cout << S[i];
        }
        for (const auto& C : front) {
            std::cout << C;
        }
        std::cout << std::endl;
    }
    return 0;
}

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

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define RREP(i,a) for(int i = a;i >= 0;i--)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define rrep(i,n) for(int i = n - 1;i >= 0;i--)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define range(x,min,max) ((min) <= (x) && (x) <= (max))
#define xyrange(x, minX, maxX, y, minY, maxY) (range(x, minX, maxX) && range(y, minY, maxY))

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef pair<int,int> PII;
typedef vector<PII> VPII;


const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};
const int INF = 0x3f3f3f3f;

int N, M;
VS A, B;

bool check(int y, int x) {
	rep (i, M) {
		rep (j, M) {
			if (A[y + i][x + j] != B[i][j]) return false;
		}
	}
	return true;
}

string solve() {
	rep (i, N - M + 1) {
		rep (j, N - M + 1) {
			if (check(i, j)) return "Yes";
		}
	}
	return "No";
}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	cin >> N >> M;
	rep (i, N) {
		string s;
		cin >> s;
		A.pb(s);
	}
	rep (i, M) {
		string s;
		cin >> s;
		B.pb(s);
	}
	cout << solve() << endl;
	return 0;
}




Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<set>
#include<vector>
#include<queue>
#include<map>
#include<stack>
#include<bitset>
#include<deque>
#define eps 1e-15
#define maxn 100010
#define maxm 200010
#define mod 1000000007
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int>pii;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int main()
{
    int a=read(),b=read(),c=read();
    if(a==b&&(a!=c))  puts("Yes");
    else if(a==c&&(a!=b))  puts("Yes");
    else if(b==c&&(a!=b))  puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
//#include <fstream>

using namespace std;

int main()
{
//	cut here before submit 
//	freopen("testcase.dat", "r", stdin);
	double vb;		

	while (cin >> vb ){
		int res = 0;

		for (int n = 1;; ++n ){
			int h = 5*n - 5;
			double tt = (double)h/4.9;
			double t = sqrt(tt );
			double v = 9.8*t;
			if (v < vb){
				continue;
			}else{
				res = n;
				break;
			} // end if
		} // end for
		cout << res << endl;
	} // end for

	return 0;
}

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

int main(){
  int N,M,X;
  cin >> N >> M >> X;
  vector<int> A(M);
  for (int i = 0; i < M; i++) {
    cin >> A.at(i);
  }
  int s=0, t=0;
  sort(A.begin(),A.end());
  for (int i = 0; i < M; i++) {
    if(A.at(i)>X) s++;
    else t++;
  }
  cout << min(s,t) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 100000000000000000LL
#define N 100005
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll n,m,k,s,p,q,c[N],a,b;
vector<int> e[N];
bool z[N];
bool z2[N];

void bfs(){
  queue <P> Q;
  for(int i=0;i<n;i++)if(z2[i])Q.push(P(i,0));
  
  while(!Q.empty()){
    P t=Q.front();Q.pop();
    int pos=t.first, dis=t.second;
    if(dis>s||z[pos]) continue;
    z[pos]=true;
    for(int i=0;i<(int)e[pos].size();i++)Q.push(P(e[pos][i],dis+1));
  }
}

ll dijkstra(){
  priority_queue<P,vector<P>,greater<P> > Q;
  ll d[N];
  for(int i=0;i<n;i++)d[i]=INF;
  Q.push(P(0,0));
  d[0]=0;
  while(!Q.empty()){
    P t=Q.top(); Q.pop();
    ll x=t.second,cost=t.first;
    if(d[x]<cost)continue;
    for(int i=0;i<(int)e[x].size();i++){
      ll nx=e[x][i],ncost;
      if(z2[nx])continue;
      if(nx==n-1)ncost=0;
      else if(!z[nx])ncost=p;
      else ncost=q;
      if(d[nx]>cost+ncost){
	d[nx]=cost+ncost;
	Q.push(P(d[nx],nx));
      }
    }
  }
  return d[n-1];
}

int main(){
  cin>>n>>m>>k>>s;
  cin>>p>>q;
  for(int i=0;i<k;i++){
    cin>>c[i];
    z2[--c[i]]=true;
  }
  for(int i=0;i<m;i++){
    cin>>a>>b;
    e[a-1].push_back(b-1);
    e[b-1].push_back(a-1);
  }
  bfs();
  cout<<dijkstra()<<endl;
  return 0;
}

Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define FOR(i,a,n) for(int i=a,i##_len=(int)(n);i<i##_len;++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i=(int)(n);i>=0;--i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
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;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

signed main() {
    int X;
    cin>>X;
    REP(i,X+1) {
        if(i*(i+1)/2>=X) {
            cout<<i<<endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N ;
  cin >> N;
  int p[12];
  for(int i = 0; i < N; i++) cin >> p[i];
  sort(p,p+N);
  reverse(p,p+N);
  int ans = 0;
  for(int i = 1; i< N; i++){
    ans+= p[i];
  }
  cout << (p[0]/2)+ans <<endl;
}

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

int main() {
  vector<char> alphabet(26);
  alphabet[0] = 'a';
  alphabet[1] = 'b';
  alphabet[2] = 'c';
  alphabet[3] = 'd';
  alphabet[4] = 'e';
  alphabet[5] = 'f';
  alphabet[6] = 'g';
  alphabet[7] = 'h';
  alphabet[8] = 'i';
  alphabet[9] = 'j';
  alphabet[10] = 'k';
  alphabet[11] = 'l';
  alphabet[12] = 'm';
  alphabet[13] = 'n';
  alphabet[14] = 'o';
  alphabet[15] = 'p';
  alphabet[16] = 'q';
  alphabet[17] = 'r';
  alphabet[18] = 's';
  alphabet[19] = 't';
  alphabet[20] = 'u';
  alphabet[21] = 'v';
  alphabet[22] = 'w';
  alphabet[23] = 'x';
  alphabet[24] = 'y';
  alphabet[25] = 'z';
  
  ll N; 
  cin >> N;
  string ans = "";
  for (int i = 0; i < 13; i++) {
    if (i == 0) continue;
    ll x = pow(26LL, i);
    if (N <= x) {
      N --;
      for (int j = 0; j < i; j++) {
        ans += alphabet[N % 26];
        N /= 26;
      }
      break;
    }
    else {
      N -= x;
    }
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
}

Measured memory_bytes: 4016
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<typename T> using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using vector2d = vector<vector<T>>;
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
int main() {
    const i64 INF = 1e8;
    int N;
    cin >> N;
    int P = 1 << N;
    multiset<int, greater<int>> s;
    for(int i = 0; i < P; i++) {
        int x;
        cin >> x;
        s.insert(x);
    }
    vector<int> v;
    v.push_back(*s.begin());
    s.erase(s.begin());
    for(int k = 0; k < N; k++) {
        for(int i = 0; i < (1 << k); i++) {
            auto itor = s.upper_bound(v[i]);
            if(itor == s.end()) {
                cout << "No" << endl;
                return 0;
            }
            v.push_back(*itor);
            s.erase(itor);
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 13692
#include<iostream>
#include<cstring>
using namespace std;
double eps = 1e-5;
int main() {
    long long a;
    double b;
    string s;
    cin >> a;
    cin >> b;
    cout <<  (long long)(a * (long long)(b*100 + eps * 100)) / 100;
   // system("pause");
}

Measured memory_bytes: 3196
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(a int) int {
	if a < 0 {
		return -a
	}

	return a
}

func main() {
	n := nextInt()
	l := make([]int, n+1)

	l[0], l[1] = 2, 1

	for i := 2; i <= n; i++ {
		l[i] = l[i-1] + l[i-2]
	}

	fmt.Println(l[n])
}


Measured memory_bytes: 640
import sys
import math

input = sys.stdin.readline

S = int(input())

if S == 10**18:
    print(0, 0, 0, 10**9, 10**9, 0)
    exit()
x2, y3 = int(math.sqrt(S)) + 1, int(math.sqrt(S)) + 1
diff = x2*y3 - S
print(0, 0, x2, diff, 1, y3)

Measured memory_bytes: 3064
# ABC079 C問題 Train Tickets
"""
切符に４つの0以上9以下の整数A,B, C, Dが整理番号として順にかかれている。
Aop1Bop2Cop3D = 7　となるように、op1,2,3,に'+'または'-'を入れて式を作る。
答が存在しない入力は与えられず、また答が複数ある場合はどれを出力してもよい。
＜制約＞
0 <= A,B,C,D<=9
入力は整数
答が存在しない入力は与えられない
"""
n = list(int(x) for x in input())
op_cnt = len(n) - 1 #隙間の数

l = []
for i in range(1 << op_cnt):
    op = ['-'] * op_cnt
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt - j -1] = '+'
            l.append(op)

for operators in l:
    expression = f"{n[0]}{operators[0]}{n[1]}{operators[1]}{n[2]}{operators[2]}{n[3]}"
    if eval(expression) == 7:
        print(f"{expression}=7")
        break






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

int main() {
  string S;
  cin >> S;
  int n = S.size();
  long long res = 0;
  for (int bit = 0; bit < (1<<(n-1)); bit++) {
    long long tmp = 0;
    for (int i = 0; i < n-1; i++) {
      tmp *= 10;
      tmp += S[i] - '0';
      if (bit & (1<<i)) {
        res += tmp;
        tmp = 0;
      }
    }
    tmp *= 10;
    tmp += S[n-1] - '0';
    res += tmp;
  }
  cout << res << endl;
}


Measured memory_bytes: 256
s = input()

if len(s)<3:
    print(0)
    exit()

i = 0
while True:
    if s[i:i+2]=='BC':
        s=s[:i]+'D'+s[i+2:]
    i+=1
    if i>=len(s):
        break


s1 = s.split('B')
s2 = []
for i in range(len(s1)):
    s2+= s1[i].split('C')


ans = 0

for i in range(len(s2)):
    d = s2[i].count('D')
    for j in range(len(s2[i])):
        if s2[i][j]=='A':
            ans += d
        else:
            d-=1


print(ans)

Measured memory_bytes: 6952
puts "39362"

$ptr = 3

def add(a, b)
  tmp = $ptr
  puts "+ #{a} #{b} #{tmp}"
  $ptr += 1
  tmp
end

def addmov(a, b)
  puts "+ #{a} #{b} #{a}"
end

def gt(a, b)
  tmp = $ptr
  puts "< #{a} #{b} #{tmp}"
  $ptr += 1
  tmp
end

def _and(a, b)
  gt(gt(a, b), b)
end

def _or(a, b)
  add(gt(a, b), a)
end

def _not(a)
  gt(a, $one)
end

def xor(a, b)
  _or(_and(_not(a), b), _and(a, _not(b)))
end

def _if(a, v)
  tmp = add($zero, $zero)
  n = a
  r = v
  until r == 0
    if r % 2 == 1
      tmp = add(tmp, n)
    end
    n = add(n, n)
    r /= 2
  end
  tmp
end

a = 0
b = 1
$zero = gt(0, 2)
$one = gt(2, 0)

pow2 = [$one]
32.times do |i|
  pow2 << add(pow2.last, pow2.last)
end

pow2m1 = [$zero]
32.times do |i|
  pow2m1 << add(add(pow2m1.last, pow2m1.last), $one)
end

a_bits = []
ret = $zero
31.downto(0) do |i|
  bit = gt(add(ret, pow2m1[i]), a)
  ret = add(ret, _if(bit, 2 ** i))
  a_bits << bit
end
a_bits.reverse!

b_bits = []
ret = $zero
31.downto(0) do |i|
  bit = gt(add(ret, pow2m1[i]), b)
  ret = add(ret, _if(bit, 2 ** i))
  b_bits << bit
end
b_bits.reverse!

32.times do |ai|
  32.times do |bi|
    addmov(2, _if(_and(a_bits[ai], b_bits[bi]), 2 ** (ai + bi)))
  end
end



Measured memory_bytes: 14212
#include <bits/stdc++.h>
using namespace std;
int n, k;
const int N = 2010;
const int MOD = 924844033;
int f[N][N][2][2];
int S[N], T[N];
int fac[N], inv[N], ans;
void ADD(int &t, int d)
{
    t += d; if (t >= MOD) t -= MOD;
}
int powi(int a, int b)
{
    int c = 1;
    for (; b; b >>= 1, a = 1ll * a * a % MOD)
        if (b & 1) c = 1ll * c * a % MOD;
    return c;
}
int C(int a, int b)
{
    return 1ll * fac[a] * inv[b] % MOD * inv[a - b] % MOD;
}
int main()
{
    cin >> n >> k;
    fac[0] = 1;
    for (int i = 1; i <= n; ++ i) fac[i] = 1ll * fac[i - 1] * i % MOD;
    inv[n] = powi(fac[n], MOD - 2);
    for (int i = n - 1; ~i; -- i) inv[i] = 1ll * inv[i + 1] * (i + 1) % MOD;
    for (int i = 1, s = 0; i <= k; ++ i)
    {
        S[s + 1] = 1;
        s += n / k + (i <= n % k);
        T[s] = 1;
    }
    f[0][0][0][0] = 1;
    for (int i = 0; i < n; ++ i)
        for (int j = 0; j < n; ++ j)
            for (int l = 0; l < 2; ++ l)
                for (int r = 0; r < 2; ++ r)
                    if (f[i][j][l][r])
                    {
                        // cerr << i << " " << j << " " << l << " " << r << " : " << f[i][j][l][r] << endl;
                        for (int w = -1; w <= 1; ++ w)
                        {
                            if (w == -1 && S[i + 1]) continue;
                            if (w == 1 && T[i + 1]) continue;
                            if (l == 1 && w == -1) continue;
                            // cerr << w << endl;
                            ADD(f[i + 1][j + (w != 0)][r && !T[i + 1]][w == 1], f[i][j][l][r]);
                        }
                    }
    // for (int i = 0; i <= n; ++ i) cerr << f[n][i][0][0] << endl;
    for (int i = 0; i <= n; ++ i)
        ADD(ans, 1ll * f[n][i][0][0] * (i & 1? MOD - 1: 1) % MOD * fac[n - i] % MOD);
    cout << ans << endl;
}


Measured memory_bytes: 61440
import java.util.Scanner;

public class Main {

    
    public static void main(String[] args) {
        Scanner tc = new Scanner (System.in);
        int a,b,c,d,e,k, soma1, soma2, soma3,soma4,soma5, soma6,soma7,soma8, soma9, soma10;
        a=tc.nextInt();
                b=tc.nextInt();

                        c=tc.nextInt();

                                d=tc.nextInt();

                                        e=tc.nextInt();

                                              k  =tc.nextInt();

        if((a<b) && (b<c) && (c<d) && (d<e)){
            soma1= b-a;
            soma2= c-a;
            soma3= d-a;
            soma4= e-a;
            soma5=  c-b;
            soma6= d-b;
            soma7= e-b;
            soma8= d- c;
            soma9= e-c;
            soma10= e-d;
            if((soma1<=k) && (soma2<=k)&& (soma3<=k) && (soma4<=k) && (soma5<=k) && (soma6<=k) && (soma7<=k) && (soma8<=k) && (soma9<=k) && (soma10<=k) ){
                System.out.println("Yay!");
    }else{
                System.out.println(":(");
            }
        }
    }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1ll<<60;

int main(int argc, char **argv)
{
	ll N, M; cin >> N >> M;

	ll res;

	auto f = [](ll num)
			 {
				 ll res{1};
				 for (ll i = 2; i <= num; ++i)
					 (res *= i) %= MOD;
				 return res;
			 };

	if (abs(N - M) > 1) res = 0;
	else 
	{
		res = (f(N) * f(M)) % MOD;
		if (N == M)
			(res *= 2) %= MOD;
	}
	
	std::cout << res << std::endl;
}


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

using namespace std;

using ll = long long;

ll dp[40];

ll solve(ll x, int cur, int n, vector<int>& cnt) {
    if (cur < 0) return 0;
    if (x < (1LL << cur)) {
        return solve(x, cur-1, n, cnt) + (1LL<<cur)*cnt[cur];
    }

    ll y = x - (1LL << cur);
    ll res = solve(y, cur-1, n, cnt)+(1LL<<cur)*(n-cnt[cur]);
    res = max(res, dp[cur]+(1LL<<cur)*cnt[cur]);
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    ll K;
    cin >> K;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    vector<int> cnt(40, 0);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 40; j++) {
            if (a[i] < (1LL<<j)) break;
            if (a[i] & (1LL<<j)) cnt[j]++;
        }
    }
    
    for (int i = 0; i < 39; i++) {
        dp[i+1] = (1LL<<i)*max(n-cnt[i], cnt[i]) + dp[i];
    }

    cout << solve(K, 39, n, cnt) << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
 
int main(){
	int i,N,K,ans=1,cnt=0,len=0;
	char S[100001];
	scanf("%d",&N);
	scanf("%d",&K);
	scanf("%s",S);
 
	for(i=0;i<N;++i){
		if(S[i]=='0'){
			if(i==0 || S[i-1]=='1'){
				cnt++;
			}
			if(cnt>K){
				while(S[len]=='1'){
					len++;
				}
				while(S[len]=='0'){
					len++;
				}
				cnt--;
			}
		}
		if(ans<i-len+1)ans=i-len+1;
	}
 
 
	printf("%d\n",ans);
}

Measured memory_bytes: 256
#include <stdio.h>
int main() {
  int x, i = 1;
  while (1) {
    scanf("%d", &x);
    if (x == 0) {
      break;
    } else {
      printf("Case %d: %d\n", i, x);
    }
    i++;
  }
  return 0;
}

Measured memory_bytes: 1812
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
using namespace std;

long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }
//--------------------

int main() {

	long res = 0;
	long tourist = 0;
	long N; cin >> N;
	long a[1000]; for (int i = 1; i <= N; i++) cin >> a[i];
	bool flag[5000] = {};

	sort(a + 1, a + N + 1);

	for (int i = 1; i <= N; i++) {

		if (1 <= a[i] && a[i] < 400 && flag[0] == 0) { res++; flag[0] = 1; continue; }
		if (400 <= a[i] && a[i] < 800 && flag[400] == 0) { res++; flag[400] = 1; continue; }
		if (800 <= a[i] && a[i] < 1200 && flag[800] == 0) { res++; flag[800] = 1; continue; }
		if (1200 <= a[i] && a[i] < 1600 && flag[1200] == 0) { res++; flag[1200] = 1; continue; }
		if (1600 <= a[i] && a[i] < 2000 && flag[1600] == 0) { res++; flag[1600] = 1; continue; }
		if (2000 <= a[i] && a[i] < 2400 && flag[2000] == 0) { res++; flag[2000] = 1; continue; }
		if (2400 <= a[i] && a[i] < 2800 && flag[2400] == 0) { res++; flag[2400] = 1; continue; }
		if (2800 <= a[i] && a[i] < 3200 && flag[2800] == 0) { res++; flag[2800] = 1; continue; }
		if (3200 <= a[i]) tourist++;

	}

	cout << max((long)1, res) << " " << res + tourist << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<unordered_map>
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define vii         vector<pair<ll,ll> >
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define rep1(i,a,b) for(ll i=a;i<= b;i++)
#define PI          3.14159
#define MAX         1000001
#define fast_io      ios_base::sync_with_stdio(false);  cin.tie(0); cout.tie(0);
#define scan(var)    scanf("%lld",&var)
#define print(var)   printf("%lld\n", var);
#define BLOCK 317
#define double       long double
#define mod          998244353
#define levelo        31
#define hell1        1000000009
using namespace std;
ll dp[3001][3001];
vector<ll> v1;
ll solvedp(ll index,ll val)
{
  if(index == 0 && val == 0)
  {
    return 1;
  }
  if(index == 0)
  {
    return 0;
  }
  if(dp[index][val] != -1)
  {
    return dp[index][val];
  }
  ll num = (2*solvedp(index - 1,val))%mod;
  if(v1[index] <= val)
  {
    num = (num + solvedp(index - 1,val - v1[index]))%mod;
  }
  dp[index][val] = num;
  return num;
}
int main()
{
  fast_io
  ll t;
  t = 1;
  while(t--)
  {
    ll n,s;
    cin >> n >> s;
    memset(dp,-1,sizeof(dp));
    v1.pb(-1);
    rep(i,0,n)
    {
      ll num;
      cin >> num;
      v1.pb(num);
    }
    cout << solvedp(n,s);
  }
  return 0;
}

Measured memory_bytes: 74228
x=int(input())
a=0
while True:
    b=a**5-x
    if b<0:
        b=-((-b)**(1/5))
    else:
        b=b**(1/5)
    c=int(b)
    if (a**5-c**5)==x:
        print(str(a)+" "+str(c))
        break
    a+=1

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a[ohara],b[ohara],c,d,cmp,cmpp,m,h,w,x,y,sum[ohara],pos,pp,btotal;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>n>>pp;
      pair<ll,ll> p[ohara];
      rep(i,n){
        cin>>a[i]>>b[i];
        btotal-=b[i]*pp;
        p[i]=make_pair((100-pp)*a[i]+pp*b[i],i);
      }
      sort(p,p+n);
      reverse(p,p+n);
      ll san=0,han=btotal,total;
      rep(i,n){
       btotal+=p[i].first;
        ans++;
        if(btotal>=0)break;
      }
      Cout(ans);
     

       
return 0;
}


Measured memory_bytes: 24064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  
  int count = 0;
  for (int i = 1; i < s.size(); i++) {
    if(s.at(i-1) != s.at(i)){
    count++;
    }
  }
  
  cout << count << endl;
  
 
}

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

int main(){
    int n,k,ele;
    cin>>n>>k;
    vector<int> v;
    //v.reserve(n+1);
    for(int i=0;i<n;i++){
        cin>>ele;
        v.push_back(ele);
    }
    int dp[k+1]={0};
    //dp[0]=0;
    for(int i=1;i<=k;i++){
        for(int mov: v){
            if(mov>i)
                continue;
            if(dp[i-mov]==0){
                dp[i]=1;
                break;
            }
        }
    }
    if(dp[k]==1){
        cout<<"First\n";
    }else{
        cout<<"Second\n";
    }
    return 0;
}


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


int main(){
  int A,B;
  cin >> A >> B;
  
  int total=0;
  
  for(int i=0;i<2;i++){
    if(A>=B){
      total += A;
      A--;
    }else{
      total += B;
      B--;
    }
  }
  
  cout << total << endl;
}

Measured memory_bytes: 256