akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    if (a>=b)
    {
        // bbb
        rep(i,a) cout << b;
        cout << endl;
    }
    else
    {
        rep(i,b) cout << a;
        cout << endl;
    }
    
    
    
}




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

using namespace std;

vector<long long> a;

bool check(int k){
    map<int, int> mp;
    for(int i = 1; i < a.size(); i++){
        if(a[i] > a[i - 1]) continue;
        if(k == 1) return false;
        if(a[i] <= a[i - 1]){
            int p = a[i];
            mp.erase(mp.upper_bound(p), mp.end());
            while(mp[p] == k - 1){
                p--;
                if(p == 0) return false;
            }
            mp[p]++;
            mp.erase(mp.upper_bound(p), mp.end());
        }
    }
    return true;
}

int main(){
    int n;
    cin >> n;
    a.resize(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int l = 0, r = 200010;
    while(r - l > 1){
        int mid = (l + r) / 2;
        if(check(mid))
            r = mid;
        else
            l = mid; 
    }
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (a % b == 0) return b;
    return gcd(b, a % b);

}

ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

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

    ll N, M;
    cin >> N >> M;

    ll L = lcm(N, M);

    string s, t;
    cin >> s >> t;

    ll n = L / N;
    ll m = L / M;

    string ss,tt;

    for(ll i = 0; i < N; i += m){
        ss += s[i];
    }

    for(ll i = 0; i < M; i += n){
        tt += t[i];
    }

    if(ss != tt){
        cout << -1 << endl;
        return 0;
    }


    cout << L << endl;
    return 0;


//    vector<char> vc1(L, '0'), vc2(L, '0');
//
//    for (ll i = 0; i < L; i += L / N) {
//        vc1[i] = s[i / (L / N)];
//    }
//
//    for (ll i = 0; i < L; i += L / M) {
//        vc2[i] = t[i / (L / M)];
//    }
//
//    for (int i = 0; i < L; ++i) {
//        if (vc1[i] == '0') continue;
//        if (vc2[i] == '0') continue;
//        if (vc1[i] == vc2[i]) continue;
//        cout << -1 << endl;
//        return 0;
//    }
//
//    cout << L << endl;

    return 0;
}


Measured memory_bytes: 888
#include<stdio.h>

int main(){
  int l,f,i,buf,count,a[100];

  f = 1;
  count = 0;
  
  scanf("%d",&l);
  for(i = 0; i < l; i++)
    scanf("%d",&a[i]);
  
  while(f){
    f = 0;
    for(i = l - 1; i != 0; i--){
      if(a[i] < a[i - 1]){
	buf = a[i];
	a[i] = a[i - 1];
	a[i - 1] = buf;
	f = 1;
	count++;
	break;
      }
    }
  }
  for(i = 0; i < l - 1; i++)
    printf("%d ",a[i]);
  printf("%d\n%d\n",a[l-1],count);
  
  return 0;
}



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

int main(int argc, char** argv) {
	int k;
	cin >> k;

	if (k % 2 == 0) {
		cout << (k/2)*(k/2) << endl;
	} else {
		cout << ((k+1)/2)*(k/2) << endl;
	}
}

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

int main(){

while(1){
int a ,b; cin >> a >> b;
if(a==0 && b==0)break;
if(a >b) cout << b << " " << a << "\n";
else  cout << a << " " << b<< "\n";
}



}

Measured memory_bytes: 1160
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		String a = sc.next();
        String b[] = a.split("");
        String ans = "";
     
        for(int i = 0; i < a.length();i++){
			if(ans.equals("") && b[i].equals("B")){
              
            }else{
              if(b[i].equals("0")){
                ans += "0";
              }else if(b[i].equals("1")){
                ans += "1";
              }else{
                ans = ans.substring(0, ans.length()-1);
              }
            }
        }
      	System.out.println(ans);
 
    }
}

Measured memory_bytes: 38512
#include<iostream>
#include<vector>
using namespace std;
void cs(vector<int> &a,vector<int> &b,vector<int> &c,int n){
    for(int i=1;i<10001;++i) c[i]=c[i]+c[i-1];
    for(int i=n-1;i>=0;--i){
        b[c[a[i]]-1]=a[i];
        c[a[i]]--;
    }
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int> a(n), b(n), c(10001, 0);
    for(int i=0;i<n;++i) cin>>a[i],++c[a[i]];
    cs(a,b,c,n);
    for(int i=0;i<n;++i) cout<<(i?" ":"")<<b[i];
    cout<<endl;
}

Measured memory_bytes: 18760
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

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

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func dump(dp [][]bool) {
	for i := range dp {
		for j := range dp[i] {
			var v int
			if dp[i][j] {
				v = 1
			}
			printf("%d", v)
		}
		println()
	}
}

func main() {
	defer stdout.Flush()
	N := readInt()
	Y := readInt()
	Y /= 1000

	dp := make([][]bool, Y+1)
	for i := range dp {
		dp[i] = make([]bool, N+1)
	}
	dp[0][0] = true
	for i := 1; i <= Y; i++ {
		for j := 1; j <= N; j++ {
			dp[i][j] = dp[i-1][j-1]
			if i < 5 {
				continue
			}
			dp[i][j] = dp[i][j] || dp[i-5][j-1]
			if i < 10 {
				continue
			}
			dp[i][j] = dp[i][j] || dp[i-10][j-1]
		}
	}
	//dump(dp)
	if !dp[Y][N] {
		println(-1, -1, -1)
		return
	}
	var c10, c5 int
	v := Y
	n := N
	for v-10 >= 0 && n-1 >= 0 && dp[v-10][n-1] {
		c10++
		v -= 10
		n--
	}
	for v-5 >= 0 && n-1 >= 0 && dp[v-5][n-1] {
		c5++
		v -= 5
		n--
	}
	println(c10, c5, N-c10-c5)

}


Measured memory_bytes: 43008
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
using namespace std;

#define REP(i,n) for(int i=0;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"

typedef long long ll;
typedef tuple<int,int,bool> Tb;

int atcoder(){
    int n,k;
    cin >> n >> k;
    map<int,int> mp;
    REP(i,n){
        int a;
        cin >> a;
        mp[a]++;
    }
    int ans = n;
    vector<int> v;

    for(auto p : mp) v.push_back(p.second);
    
    sort(v.begin(),v.end(),greater<int>());
    k = min((int)v.size(),k);
    REP(i,k) ans -= v[i];

    cout << ans << ENT;
    return 0;
}

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


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

int main() {
  int n;
  cin >> n;
  int ans = 100000;
  for (int i=0;i<n;i++) {
    int a = 0.05*ans;
    if (a%1000)
      a = (a / 1000 +1) * 1000;
    ans += a;
  }
  cout << ans << endl;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
#define print(n) cout<<n<<endl
const int M=100111;
const int inf=1000000007;
const long long INF=1000000000000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};

int main(){
	int n,a[M],b[M];
	ll suma=0,sumb=0;
	ll lack=0;
	int ans=0;
	vi over;
	cin>>n;
	rep(i,0,n)cin>>a[i],suma+=a[i];
	rep(i,0,n){
		cin>>b[i],sumb+=b[i];
		if(a[i]>b[i])over.push_back(a[i]-b[i]);
		if(a[i]<b[i]){
			lack+=b[i]-a[i];
			ans++;
		}
	}
	sort(ALL(over),greater<>());
	if(suma<sumb){
		print(-1);
		return 0;
	}
	int cnt=0;
	while(lack>0){
		ans++;
		lack-=over[cnt];
		cnt++;
	}
	print(ans);
}

Measured memory_bytes: 1404
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i=0;i<(n);++i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(n)-1;i>= 0;--i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.141592653589793238
#define dcout cout<<fixed<<setprecision(50)

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

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

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

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

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

  int T[2], A[2], B[2]; cin >> T[0] >> T[1];
  cin >> A[0] >> A[1] >> B[0] >> B[1];
  int Asum = A[0]*T[0] + A[1]*T[1];
  int Bsum = B[0]*T[0] + B[1]*T[1];
  int Agreater = 2; // 1...greater, 0...less, 2...equal
  int cnt = 0;
  int posa = 0, posb = 0;
  int diff;
  for(int t = 1; t <= T[0]+T[1]; t++){
  	if(t <= T[0]){
  		posa += A[0]; posb += B[0];
  	} else {
  		posa += A[1]; posb += B[1];
  	}
  	if(t == T[0]) diff = posa - posb;
  	if(Agreater == 1 and posa < posb) {
  		cerr << t-1 << ' ' << t << endl;
  		cnt++;
  	}
  	if(Agreater == 0 and posa > posb) {
  		cerr << t-1 << ' ' << t << endl;
  		cnt++;
  	}
  	if(posa == posb){
  		cerr << t << endl;
  		Agreater = 2;
  		cnt++;
  	} else {
  		Agreater = (posa > posb);
  	}
  }
  if(cnt > 0 and Asum == Bsum){
  	cout << "infinity" << endl;
  	return 0;
  }
  if(cnt == 0){
  	cout << 0 << endl;
  	return 0;
  }
  cerr << diff << ' ' << Asum << ' ' << Bsum << endl;
  int adj = 0;
  if(abs(diff) % abs(Asum-Bsum) == 0) adj--;
  cout << adj + 1 + abs(diff) / abs(Asum-Bsum) * 2 << endl;
}


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

int main(void){
	int i;
	char s[103], c;
	while(1){
		i = 0;
		while((s[i++] = getchar()) != '\n');
		s[i - 1] = '\0';
		c = s[strlen(s) - 1];
		s[strlen(s) - 2] = '\0';
		if(c == 'X') break;
		else if(c == 'U'){
			printf("%c",isupper(s[0])?s[0]:'A' + s[0] - 'a');
			for(i = 1;i < strlen(s);i++){
				if(s[i] == '_')
					printf("%c",'A' + s[++i] - 'a');
				else
					printf("%c",s[i]);
			}
		}
		else if(c == 'L'){
			printf("%c",islower(s[0])?s[0]:'a' + s[0] - 'A');
			for(i = 1;i < strlen(s);i++){
				if(s[i] == '_')
					printf("%c",'A' + s[++i] - 'a');
				else
					printf("%c",s[i]);
			}
		}
		else{
			printf("%c",islower(s[0])?s[0]:'a' + s[0] - 'A');
			for(i = 1;i < strlen(s);i++){
				if(isupper(s[i]))
					printf("_%c",'a' + s[i] - 'A');
				else if(s[i] == '_')
					printf("_%c",s[++i]);
				else
					printf("%c",s[i]);
			}
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 940
#include<iostream>

using namespace std;

int tb[60][60];

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

void count (int y, int x){
     for(int i=0; i<8; i++) {
        int ny = y + dy[i];
        int nx = x + dx[i];

        if( tb[ny][nx] >= 0 ) tb[ny][nx]++;
     }
}

int H,W;
int main () {
    for(int i=0; i<55; i++) {
        for(int j=0; j<55; j++) tb[i][j] = -2;
    }

    cin >> H >> W;
    for(int i=1; i<=H; i++) {
        for(int j=1; j<=W; j++) {
            char c;
            cin >> c;
            if( c == '.') tb[i][j] = 0;
            if( c == '#') tb[i][j] = -1;
        }
    }
    for(int i=1; i<=H; i++) {
        for(int j=1; j<=W; j++) {
            if( tb[i][j] == -1 ) {
                count(i,j);
            }
        }
    }
    for(int i=1; i<=H; i++) {
        for(int j=1; j<=W; j++) {
            if( tb[i][j] == -1 ) cout << '#';
            else cout << tb[i][j];
        }
        cout << endl;
    }
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N;
    cin >> N;
    int result[10001];
    REP(i, 10001) result[i] = 0;
    FOR(x, 1, 101) FOR(y, 1, 101) FOR(z, 1, 101) {
        int n = x * x + y * y + z * z + x * y + y * z + z * x;
        if (n > 10000) break;
        result[n]++;
    }
    FOR(i, 1, N + 1) cout << result[i] << endl;
    return 0;
}

Measured memory_bytes: 3544
import itertools

N = int(input())
P = []
L_total = []
for i in range(N):
    p = list(map(int, input().split()))
    P.append(p)
for v in itertools.permutations(P, N):
    L = []
    for i in range(N - 1):
        l = ((v[i][0] - v[i + 1][0]) ** 2 + (v[i][1] - v[i + 1][1]) ** 2) ** 0.5
        L.append(l)
    L_total.append(sum(L))
ans = sum(L_total) / (len(L_total))
print(ans)

Measured memory_bytes: 4504
n = int(input())
ls = []
for i in range(n):
    x,l = map(int,input().split())
    ls.append([x-l,l+x])

ls = sorted(ls, key=lambda x: x[1])
ans = n

for i in range(1,n):
    if ls[i][0] < ls[i-1][1]:
      ls[i][1] = ls[i-1][1]
      ans -=1

print(ans)

Measured memory_bytes: 22100
import collections


S = input()
T = input()
cnt_S = collections.Counter(S)
cnt_T = collections.Counter(T)
S_values, S_counts = zip(*cnt_S.most_common())
T_values, T_counts = zip(*cnt_T.most_common())
if S_counts == T_counts:
    print('Yes')
else:
    print('No')

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

int tile[140][140];
using vpii = vector<pair<int,int>>;
int dx[] = {1,-1,0,0,-1,1};
int dy[] = {1,-1,1,-1,0,0};


int main()
{
  int t,n;
  while(cin >> t >> n,t+n){
    REP(i,140){
      REP(j,140){
        tile[i][j] = 0;
      }
    }
    vpii pii;
    REP(i,n){
      int c,k;
      cin >> c >> k;
      pii.push_back({k,c});
    }
    int sx,sy;
    cin >> sx >> sy;
    tile[70][70] = 1;
    for(auto x : pii){
      tile[x.first-sy+70][x.second-sx+70] = 2;
    }
    REP(_t,t){
      REP(i,140){
        REP(j,140){
          if(tile[i][j] == 1){
           REP(k,6){
            auto ny = max(0,min(139,i + dy[k]));
            auto nx = max(0,min(139,j+dx[k]));
            if(tile[ny][nx]==0){
              tile[ny][nx] = -1;
            }
           }
          }
        }
      }
      REP(i,140){
        REP(j,140){
          if(tile[i][j]==-1){
            tile[i][j] = 1;
          }
        }
      }
    }
    int ans = 0;
    REP(i,140){
      REP(j,140){
        if(tile[i][j]==1){
          ans++;
        }
      }
    }
    cout << ans<< endl;
  }

}

Measured memory_bytes: 3212
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

A, B ,K = mi()

for i in reversed(range(1, min(A, B)+1)):
    if not A%i and not B%i:
        K -= 1
        if K == 0:
            print(i)
            exit()


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

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb(x)	cout << #x << " " << x << endl;

typedef long long int ll;

void printst(stack<int> a) {

	string astr = "";
	while (!a.empty()) {
		astr = to_string(a.top()) + " " + astr;
		a.pop();
	}

	cout << astr << endl;
}

void printStack(stack<int> a, stack<int> b) {
	cout << "a : ";
	printst(a);

	cout << "b : ";
	printst(b);
}

int main() {

	IOS

	int n, m, k;
	cin >> n >> m >> k;

	stack<int> a, b;
	int ip;

	int a_arr[n], b_arr[m];

	for (int i = 0; i < n; i++)
		cin >> a_arr[i];

	for (int i = 0; i < m; i++)
		cin >> b_arr[i];

	for (int i = n-1; i >= 0; i--) {
		a.push(a_arr[i]);
	}

	for (int i = m-1; i >= 0; i--) {
		b.push(b_arr[i]);
	}

	stack<int> sta, stb;

	int kk = k;

	while (!a.empty() && kk > 0) {
		if (kk - a.top() >= 0) {
			sta.push(a.top());
			kk -= a.top();
			a.pop();

		} else
			break;
	}

	while (!b.empty() && kk > 0) {
		if (kk - b.top() >= 0) {
			stb.push(b.top());
			kk -= b.top();
			b.pop();
		
		} else
			break;
	}

	int taken = sta.size() + stb.size();
	int max_taken = taken;

	// printStack(sta, stb);

	while (!sta.empty()) {
		int popped = sta.top();
		sta.pop();

		kk += popped;

		while (!b.empty() && kk > 0) {
			if (kk - b.top() >= 0) {
				stb.push(b.top());
				kk -= b.top();
				b.pop();

			} else
				break;
		}

		// printStack(sta, stb);

		max_taken = max(max_taken, (int)sta.size() + (int)stb.size());
	}

	cout << max_taken;

	return 0;
}

Measured memory_bytes: 6888
#include<iostream>

using namespace std;

bool process();
int main(){
    if(process())
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
    return 0;
}
bool process(){
    int N,A,B,C,D;
    int temp;
    string s;
    int i;
    bool jump;
    bool jumpOK;
    bool ok;
    
    cin >> N >> A >> B >> C >> D;
    cin >> s;
    ok = true;
    if( C < D){
        for(i=B-1;i<D-1;i++){
            if( s[i] == '#' && s[i+1] == '#')
                return false;
        }
        for(i=A-1;i<C-1;i++){
            if( s[i] == '#' && s[i+1] == '#')
                return false;
        }
    }else{
        ok = false;
        for(i=B-1;i<D-1;i++){
            if( s[i] == '#' && s[i+1] == '#')
                    return false;
        }
        for(i=B-1;i<D;i++){
            if(s[i] == '.' && s[i-1] == '.' && s[i+1] == '.'){
                ok = true;
                break;
            }
        }
        for(i=A-1;i<C-1;i++){
            if( s[i] == '#' && s[i+1] == '#')
                return false;
        }
        
        return ok;
        
    }
    
    return true;
}



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


signed main(){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	int x = (b/c) - (a/c + (a%c != 0)) + 1;
	int y = (b/d) - (a/d + (a%d != 0)) + 1;
	int e = c*d/(__gcd(c,d));
	int z = (b/e) - (a/e + (a%e != 0)) + 1;
	//cout << x << ' ' << y << " " << z << endl;
	cout << b - a + 1 - x - y + z;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <fstream>
#include <cstdlib>
#include <ctime>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <tuple>
#include <climits>
#include <unordered_map>

using namespace std;

int main() {
    int n;
    cin>>n;
    int total_diff = 0;
    int left = 0;
    vector<pair<int,int>> inc, desc;
    for (int i=0; i<n; i++) {
        string s;
        cin>>s;
        int right = 0, diff = 0;
        for (auto ch: s) {
            diff += (ch == '(') ? 1 : -1;
            right = min(right, diff);
        }
        total_diff += diff;
        if (right == 0) left += diff;
        else if (diff > 0) inc.push_back({right, diff});
        else desc.push_back({right, diff});
    }

    if (total_diff != 0) {
        cout<<"No\n";
        return 0;
    }
    sort(inc.begin(), inc.end());
    for (int i=inc.size()-1; i>=0; i--) {
        if (left + inc[i].first < 0) {
            cout<<"No\n";
            return 0;
        }
        left += inc[i].second;
    }
    sort(desc.begin(), desc.end(), [](const pair<int,int>&p1, const pair<int,int>& p2)->bool {
        return p1.first + p2.second < p2.first + p1.second;
    });
    for (int i=0; i<desc.size(); i++) {
        if (left + desc[i].first < 0) {
            cout<<"No\n";
            return 0;
        }
        left += desc[i].second;
    }
    cout<<"Yes\n";
}


Measured memory_bytes: 7196
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Array.Unboxed
import Data.Array.ST
import qualified Data.ByteString.Char8 as BS

makeTable :: BS.ByteString -> BS.ByteString -> UArray (Int,Int) Int
makeTable xs ys =
  runSTUArray $ do
    dp <- newArray ((0,0),(BS.length xs, BS.length ys)) 0
    forM_ [0..BS.length xs -1] $ \i ->
      forM_ [0..BS.length ys - 1] $ \j ->
        if BS.index xs i == BS.index ys j 
           then do
             rd <- readArray dp (i,j)
             writeArray dp (i+1,j+1) $! rd+1 
           else do
             rd1 <- readArray dp (i+1,j)
             rd2 <- readArray dp (i,j+1)
             writeArray dp (i+1,j+1) $! max rd1 rd2
    return dp

construct :: UArray (Int,Int) Int -> BS.ByteString -> BS.ByteString -> (Int,Int) -> BS.ByteString -> BS.ByteString
construct dp xs ys (n,m) bs
  | n == 0 || m == 0 = bs
  | BS.index xs (n-1) == BS.index ys (m-1) = construct dp xs ys (n-1,m-1) (BS.cons (BS.index xs (n-1)) bs)
  | otherwise =
    let
      a = dp ! (n-1,m)
      b = dp ! (n,m-1)
    in
      if a >= b then construct dp xs ys (n-1,m) bs
                else construct dp xs ys (n,m-1) bs
main = do 
  xs <- BS.getLine
  ys <- BS.getLine
  let n = BS.length xs
  let m = BS.length ys
  let dp = makeTable xs ys
  putStrLn $ BS.unpack $ construct dp xs ys (n,m) BS.empty



Measured memory_bytes: 71676
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;
int main(void){
  int A,B,C,c1=0,c2=0,c3=0;
  cin>>A>>B>>C;
  while(1){
  	c1+=A;
    c2++;c3++;
    if(c2>=7){c1+=B;c2-=7;}
    if(c1>=C){break;}
  }
  cout<<c3<<endl;
  return 0;
}


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

const long long MOD=1000000007;

long long modmypower(long long a, long long b){
  if(a==0) return 0;
  if(b==1){
    return a;
  }else if(b%2==0){
    long long c=modmypower(a,b/2);
    return (c*c)%MOD;
  }else{
    long long c=modmypower(a,(b-1)/2);
    return (((c*c)%MOD)*a)%MOD;
  }
}   

int main(){
  int N,K; cin >> N >> K;
  long long result=0;
  long long tr[100010];
  for(int i=K; i>=1; i--){
    long long t=modmypower(K/i,N);
    for(int j=1; j<K/i; j++){
      t=t+MOD-tr[i*(j+1)];
      t%=MOD;
    }
    tr[i]=t;
    result+=((i*t)%MOD);
    result%=MOD;
  }
  cout << result << endl;
}

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

using namespace std;

int N;
int arr[400005], brr[400005];
int lps[400005];
bool ok[35][400005];

int main(){
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> N;	
	for(int i = 1; i<=N; i++){
		cin >> arr[i];
	}
	for(int i = 1; i<=N; i++){
		cin >> brr[i];
		brr[i+N] = brr[i];
	}
	lps[1] = 1;
	for(int b = 0; b<30; b++){
		for(int k = 0; k<=1; k++){
			for(int i = 2, j = 1; i<=N; ){
				if((arr[i]&(1<<b)) == (arr[j]&(1<<b))){
					lps[i++] = ++j;
				}
				else if(j-1){
					j = lps[j-1];
				}
				else{
					lps[i++] = j;
				}	
			}
			for(int i = 1, j = 1; i<2*N; ){
				if((brr[i]&(1<<b)) == ((arr[j]&(1<<b))^(k<<b))){
					i++, j++;
					if(j == N+1){
						j = lps[N];
						//cout << b << " " << (i-N) << endl;
						ok[b][i-N] = 1;
					}
				}
				else if(j-1){
					j = lps[j-1];
				}
				else{
					i++;
				}
			}
		}
	}
	vector<pair<int, int>> v;
	for(int i = 1; i<=N; i++){
		int cnt = 0;
		for(int b = 0; b<30; b++){
			cnt += ok[b][i];
		}
		if(cnt == 30){
			v.push_back({(N-i+1)%N, (arr[1]^brr[i])});
		}
	}
	sort(v.begin(), v.end());
	for(auto p : v){
		cout << p.first << " " << p.second << "\n";
	}
}

/*

*/

Measured memory_bytes: 21744
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <time.h>
#include <vector>

using namespace std;
typedef long long ll;
template <class T = ll>
T in() {
    T x;
    cin >> x;
    return (x);
}
template <class T>
void print(T x) {
    cout << x << "\n";
}
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define reps(x, c) for (auto x : c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a)
#define mp(a, b) make_pair((a), (b))
#define pl pair<ll, ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cerr << #x "=" << (x) << "\n"
#define dbgv(x) \
    cerr << #x << "\n"; \
    reps(y, x) { cerr << y << " "; } \
    cerr << "\n"

int main() {
    int n = in();
    vector<ll> h(n);
    rep(i, n) cin >> h[i];
    ll ans = 0;
    bool flg;
    rep(i, n) {
        flg = true;
        rep(j, i) {
            if (h[i] < h[j]) {
                flg = false;
            }
        }
        if (flg) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>

int sumPrime[10000];

void makePrime(){
	const int max=1000000;
	bool sieve[max];
	int k=0;
	memset(sieve,true,sizeof(sieve));
	for(int i=0;i<max&&k<10000;++i){
		if(sieve[i]){
			sumPrime[k]=i+2+(k>0?sumPrime[k-1]:0);
			++k;
			for(int j=i*2+2;j<max;j+=i+2){
				sieve[j]=false;
			}
		}
	}
}

int main(){
	int n;
	makePrime();
	while(1){
		std::cin>>n;
		if(n==0)break;
		std::cout<<sumPrime[n-1]<<std::endl;
	}
	return 0;
}

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

int main()
{
	long long int total1[21],total2[21];
	int n;
	for(int i=0;i<21;i++){
		total1[i]=0;
		total2[i]=0;
	}
	
	cin>>n;
	for(int i=0;i<n;i++){
		int k;
		cin>>k;
		
		if(!i){total1[k]++;}
		
		else if(i<n-1){
			for(int j=0;j<21;j++){
				if(j+k<=20){
					total2[j+k]+=total1[j];
				}
				if(j-k>=0){
					total2[j-k]+=total1[j];
				}
			}
			for(int j=0;j<21;j++){
				total1[j]=total2[j];
				total2[j]=0;
			}
		}
		else{
			cout<<total1[k]<<endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1160
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)

def main():
    n = int(input().strip())
    dp = [[0] * (n+1) for _ in range(15)]
    coins = [0] + [6**i for i in range(8)] + [9 ** i for i in range(1, 7)]
    for i in range(1, n+1):
        dp[0][i] = 10**10
    for i in range(1, 15):
        for j in range(n+1):
            if j - coins[i] < 0:
                dp[i][j] = dp[i-1][j]
            else:
                dp[i][j] = min(dp[i-1][j], dp[i][j-coins[i]] + 1)
    print(dp[14][n])
if __name__ == '__main__':
    main()


Measured memory_bytes: 51184
/**
 * @author yuzining
 * @date 2020/08/02 20:01
 */

#ifdef local
#include "D:\vscode\acm\local.hpp"
#else
#include<bits/stdc++.h>
using namespace std;
#define debug(...) do { } while(false)
void Main();
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  Main();
  return 0;
}
#endif

void Main() {
  int n;
  long long d; cin >> n >> d;
  d = d * d;
  int ans = 0;
  for(int i = 0; i < n; i++) {
    long long x, y; cin >> x >> y;
    if(x * x + y * y <= d) {
      ans++;
    }
  }
  cout << ans << '\n';
}

Measured memory_bytes: 3668
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return ~n & 1; }
template<typename T> int len(const T &v) { return v.size(); }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

main() {
  int n = in();
  if (n == 0) cout << 1 << endl;
  if (n == 1) cout << 2 << endl;
  if (n == 2) cout << 1 << endl;
  if (n >= 3) cout << 0 << endl;
}



Measured memory_bytes: 3088
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main()
{
    int N;
    cin >> N;
    // int a[N+1],b[N+1],c[N+1],dp[N+1][3];
    ll x[N][3],dp[N+1][3];

    for (int i=0; i<N; ++i)
    {
        for (int j=0; j<3; ++j)
        {
            cin >> x[i][j];
            // dp[i][j] = 0;
        }
        // cin >> a[i] >> b[i] >> c[i];
    }
    
    for (int i=0; i<N+1; ++i)
    {
        for (int j=0; j<3; ++j)
        {
            dp[i][j] = 0;
        }
    }

    for (int i=0; i<N; ++i)
    {
        for (int j=0; j<3; ++j)
        {
            for (int k=0; k<3; ++k)
            {
                if(j==k) continue;
                if(dp[i+1][k] <= dp[i][j] + x[i][k])
                {
                    dp[i+1][k] = dp[i][j] + x[i][k];
                }
            }
        }
    }

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

Measured memory_bytes: 4992
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

int main() {
  int X; cin >> X;
  LL a = X / 500;
  LL b = (X - 500*a) / 5;
  cout  << 1000LL*a + 5LL*b << endl;
}


Measured memory_bytes: 256
h1, m1, h2, m2, k = map(int, input().split())
t1 = h1 * 60 + m1
t2 = h2 * 60 + m2

if t1 > t2:
    print(720 - t1 + t2 - k)
else:
    print(t2 - t1 - k)

Measured memory_bytes: 9168
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
#include <queue>
#include <iomanip>
#include <float.h>
#include <set>
#include<functional>
#include <stack>
#include <time.h>
#include <climits>
#include <bitset>
#include <fstream>
#include<map>
#include <cassert>
#include<sstream>
#include<fstream>
#include <cstring>
using namespace std;
typedef pair<int, string>p;
map< int64_t, int > prime_factor(int64_t n) {
	map< int64_t, int > ret;
	for (int64_t i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}
const int MAX =1;
const int MOD = 998244353;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	string s;
	cin >> s;
	int cnt[4005][3];
	cnt[0][0] = cnt[0][1] = cnt[0][2] = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < 3; j++) {
			cnt[i][j] = cnt[i - 1][j];
		}
		if (s[i - 1] == 'R')cnt[i][0] += 1;
		if (s[i - 1] == 'G')cnt[i][1] += 1;
		if (s[i - 1] == 'B')cnt[i][2] += 1;
	}
	long long ans = 0;
	for (int j = 1; j < n; j++) {
		for (int k = j + 1; k < n; k++) {
			if (s[j] == s[k])continue;
			if (s[j] != 'R'&&s[k] != 'R') {
				ans += cnt[j][0];
				if (j-(k-j)>=0&&s[j - (k - j)] == 'R')ans -= 1;
			}
			if (s[j] != 'G'&&s[k] != 'G') {
				ans += cnt[j][1];
				if (j - (k - j) >= 0 && s[j - (k - j)] == 'G')ans -= 1;
			}
			if (s[j] != 'B'&&s[k] != 'B') {
				ans += cnt[j][2];
				if (j - (k - j) >= 0 && s[j - (k - j)] == 'B')ans -= 1;
			}
		}
	}
	cout << ans;
}



Measured memory_bytes: 3680
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int n;
    int[] a;
    int i, j, k, tmp;

    n = sc.nextInt();
    a = new int[n];

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

    for(i = 0;i < n;i++){
      for(j = 0;j < i;j++){
        if(a[j] > a[i]){
          tmp = a[i];
          for(k = 0;k < (i - j);k++){
            a[i - k] = a[i - k - 1];
          }
          a[j] = tmp;
        }
      }
      System.out.print(a[0]);
      for(j = 1;j < n;j++){
        System.out.print(" " + a[j]);
      }
      System.out.println();
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 24244
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=LLONG_MAX;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  int n,k;
  cin>>n>>k;
  long long x[n],y[n];
  REP(i,n){
    cin>>x[i]>>y[i];
  }
  
  vector<pair<long long,long long>> pos;
  REP(i,n){
    pos.push_back(make_pair(x[i],y[i]));
  }
  sort(pos.begin(),pos.end());
  long long dx;
  //vector<long long> temp;
  //long long u,d;
  long long ans=INF;
  vector<long long> ytemp;
  REP(i,n-k+1){
    for(int j=i+k-1;j<n;j++){
      dx = pos[j].first-pos[i].first;
      //u = LLONG_MIN;
      //d = INF; 
      ytemp.clear();
      for(int l=i;l<=j;l++){
        ytemp.push_back(pos[l].second);
      }
      sort(ytemp.begin(),ytemp.end());
      for(int l=0;l+k-1<=j-i;l++){
        ans = min(ans,dx*(ytemp[l+k-1]-ytemp[l]));
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)
#define rrep(i,a,b) for(int (i)=int(a);(i)>=int(b);(i)--)

#define put(a) cout << (a) << endl
#define puts(a) cout << (a) << " "

#define llint long long int

int main (void)
{
	//INPUT
	llint T1,T2,A1,A2,B1,B2;
	cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;
	
	//SOLVE
	llint x1,x2;
	
	if (A1 < B1 ) {
		if (A2 < B2) {
			put("0");
			return 0;
		}
		
		//A1 < B1   A2 > B2
		x1 = B1 - A1;	//+
		x2 = B2 - A2;	//-
		
		
		
	} else {
		if (A2 > B2) {
			put("0");
			return 0;
		}
		
		//A1 > B1   A2 < B2
		x1 = A1 - B1;	//+
		x2 = A2 - B2;	//-
		
	}
	
	//SOLVE
	llint P = x1*T1;
	llint Q = x2*T2;
	llint PpQ = P+Q;
	
	// put(P);
	// put(Q);
	
	if (PpQ == 0) {
		put("infinity");
		return 0;
	} else if (PpQ > 0) {
		put("0");
		return 0;
	} else {
		//PpQ < 0
		llint N = (-P / PpQ);
		if ( -P % PpQ == 0) {
			put(2*N);
			return 0;
		} else {
			put(2*N+1);
			return 0;
		}
	}
	
	return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.function.BiConsumer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			String s = in.next();
			for (int i = 0; i < s.length(); i++) {
				out.print('x');
			}
			out.println();
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public char nextChar() {
			return next().charAt(0);
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

	}
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
#define ll           long long
#define rep(i,j,n)   for(ll i=j;i<n;i++)
#define scn(a)       scanf("%lld",&a)
#define nl           printf("\n")
#define scns(a,b)    scanf("%lld %lld",&a,&b)
#define print(a)     printf("%lld",a)
#define tc           ll t; scn(t); while(t--)
#define vec          vector<ll>
#define pb           push_back
#define pairs        pair<ll,ll>
#define fi           first
#define se           second
#define all(v)       v.begin(),v.end()
#define srt(v)       sort(v.rbegin(),v.rend())
#define mem(a,b)     memset(a,b,sizeof(a))
#define maxx         5000005
#define inf          LLONG_MAX
#define zer          LLONG_MIN
#define dbug(a)      cout<<"dbug : "<<a<<endl
#define debug(a,b)   cout<<a<<" "<<b<<endl
#define read(v)      vec v(n,0); rep(i,0,n) {cin>>v[i];}
#define write(a,n)   rep(i,0,n) {cout<<a[i]<<" ";}
#define All          rep(i,0,n) 
ll zero = 0;




int main()
{
	
	ll n,m,k;
	scns(n,m);
	scn(k);
	
	vector<pairs> v;
	rep(i,0,k){
		ll x;
		ll y;
		scns(x,y);
		v.pb({x,y});
	}
	
	map<ll,ll> mp1,mp2;
    set<pairs> s;
	
	rep(i,0,k)
	{
		mp1[v[i].fi]++;
		mp2[v[i].se]++;
		s.insert({v[i].fi, v[i].se});
	}
	
	ll mx1=0;
	ll mx2=0;
	vec row;
	vec col;
	for(auto it : mp1)
	{
		if(it.se > mx1)
		{
			mx1 = it.se;
		}
	}
	
	for(auto it: mp2)
	{
		if(it.se > mx2)
		{
			mx2 = it.se;
		}
	}
	
	for(auto it : mp1)
	{
		if(it.se == mx1) row.pb(it.fi);
	}
	
	for(auto it : mp2)
	{
		if(it.se == mx2) col.pb(it.fi);
	}
	
	ll ans = mx1 + mx2 -1;
	
	bool fg = false;
	for(int i=0;i<int(row.size()) && fg ==false;i++)
	{
		for(int j=0;j<int(col.size()) && fg == false;j++)
		{
			ll x = row[i];
			ll y = col[j];
			if(s.count({x,y})==0)
			{
				ans++;
				fg = true;
			}
		}
	}
	
	cout<<ans;

	
	
return 0;
}

Measured memory_bytes: 73084
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cstring>
#include <stack>
#define INT long long
#define oo 99999987654321LL
using namespace std;

stack<char> st;
string s;
int n;

int main()
{
    cin>>s;
    n = s.size();
    for(int i = 0 ; i < n ; i++ )
    {
        if( s[i] == 'S' ) st.push('S');
        else
        {
            if( !st.empty() && st.top() == 'S' ) st.pop();
            else st.push('T');
        }
    }
    cout<<st.size()<<endl;
    return 0;
}


Measured memory_bytes: 768
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner kbscanner = new Scanner(System.in);
		int a = kbscanner.nextInt();
		int b = kbscanner.nextInt();
		int c = kbscanner.nextInt();
		
		kbscanner.close();
		
		int nextA, nextB, nextC;
		nextA = nextB = nextC = 0;
		
		int times = 0;
		
		while(true){
			nextB += a / 2;
			nextC += a / 2;
			
			nextC += b / 2;
			nextA += b / 2;
			
			nextA += c / 2;
			nextB += c / 2;
			
			if(a % 2 != 0 || b % 2 != 0 || c % 2 != 0){
				break;
			}
			else if(nextA == nextB && nextB == nextC){
				times = -1;
				break;
			}
			
			a = nextA;
			b = nextB;
			c = nextC;
			
			nextA = nextB = nextC = 0;
			
			times++;
			
		}
		
		System.out.print(times);

	}

}

Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n,m;cin >> n >>m;
    vvpl g(n);
    rep(i,m){
        ll a,b,c;cin >> a >>b >>c;a--;b--;
        g[a].pb({b,c});
        g[b].pb({a,-c});
    }
    bool check=true;
    vl seen(n,0);
    vl dist(n,0);
    ll s=0;
    while(s<n){
        queue<ll> que;
        que.push(s);
        seen[s]=1;
        dist[s]=0;
        while(!que.empty()){
            ll v=que.front();
            que.pop();
            for(auto p:g[v]){
                ll nv=p.fi;
                ll to=p.se;
                if(seen[nv]==1){
                    if(dist[nv]!=dist[v]+to)check=false;
                }
                else{
                    seen[nv]=1;
                    dist[nv]=dist[v]+to;
                    que.push(nv);
                }
             }
        }
        while(seen[s]&&s<n){
            s++;
            if(s==n)break;
        }
    }
    if(check)cout << "Yes" <<endl;
    else cout <<"No" <<endl;
}

Measured memory_bytes: 14848
#include<stdio.h>
int main(){
	int a,b,i,s;
	scanf("%d",&a);
	while(a!=0){
		s=0;
		for(i=0;i<9;i++){
			scanf("%d",&b);
			s+=b;
		}
		printf("%d\n",a-s);
		scanf("%d",&a);
	}
}

Measured memory_bytes: 2552