akhauriyash/Code-Regression huggingface dataset:
use std::collections::BTreeSet;
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { reader: s.lock() };

    let mut a: usize = sc.read();
    let mut set = BTreeSet::new();
    for i in 1.. {
        if set.contains(&a) {
            println!("{}", i);
            return;
        }
        set.insert(a);
        if a % 2 == 0 {
            a /= 2;
        } else {
            a = 3 * a + 1;
        }
    }
}

pub struct Scanner<R> {
    reader: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mod = 1000000007;
const ll INF = LLONG_MAX;

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> x(n), y(n);
  rep(i, n) cin >> x[i] >> y[i];
  ll ans = INF;
  
  rep(sx, n)rep(sy, n)rep(i, n) rep(j, n) {
    ll cnt = 0;
    ll startx = x[sx], starty = y[sy];
    ll endx = x[i], endy = y[j];
    if(startx > endx) swap(startx, endx);
    if(starty > endy) swap(starty, endy);
    rep(k, n) {
      ll nx = x[k], ny = y[k];
      if(startx <= nx && nx <= endx && starty <= ny && ny <= endy) cnt++;
    }
    if (cnt >= k) chmin(ans, (endx - startx) * (endy - starty));

  }
  cout << ans << endl;
}

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

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

    int N; cin >> N;
    vector<int> C(13);
    C[0] = 1;
    for (int i = 0; i < N; i++) {
        int d; cin >> d;
        C[d]++;
    }

    if (any_of(C.begin(), C.end(), [](int c){return c>=3;}) || C[0]==2 || C[12]==2) {
        cout << 0 << endl;
        return 0;
    }

    int ans = 0;
    int absent = 0;
    for (int i = 1; i <= 11; i++) {
        if (C[i] == 0) absent |= (1<<(i-1));
    }
    for (int b = 0; b < (1<<11); b++) {
        if (b & absent) continue;
        vector<int> D;
        for (int i = 1; i <= 11; i++) {
            if (C[i] == 2) {
                D.push_back(i);
                D.push_back(24-i);
            } else if (C[i] == 1) {
                D.push_back((b & (1 << (i-1))) ? 24-i : i);
            }
        }
        if (C[12] > 0) D.push_back(12);
        D.push_back(24);
        sort(D.begin(), D.end());

        vector<int> diffs(D.size());
        adjacent_difference(D.begin(), D.end(), diffs.begin());

        ans = max(ans, *min_element(diffs.begin(), diffs.end()));
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    //ifstream cin("input.txt");
    //ofstream cout("output.txt");
    int n;
    cin >> n;
    map <int, int> a;
    for (int i = 0; i < n; i++)
    {
        int t;
        cin >> t;
        a[t] = 1;
    }
    if (a.size() < n)
        cout << "NO";
    else
        cout << "YES";
    //cin.close();
    //cout.close();
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  map<int, int> mp;
  for(int i=0; i<N; i++) {
    int tmp;
    cin >> tmp;
    mp[tmp]++;
  }
  int ans = 0;
  for(const auto& e : mp) {
    if(e.first < e.second)
      ans += e.second-e.first;
    else if(e.first > e.second)
      ans += e.second;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    char c;cin>>c;
    if (c=='a'||c=='e'||c=='i'||c=='o'||c=='u'){
        cout<<"vowel"<<endl;
    }else cout<<"consonant"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll u_int64_t
#define rep(i, n) for (int i=0; i<n; i++)
 
using namespace std;
 
int main() {
	int k;
	string s;
	cin >> k >> s;
	if (s.length() <= k)
	{
		cout << s << endl;
		return 0;
	}
	rep(i, k)
	{
		cout << s[i];
	}
	cout << "..." << endl;
	return 0;
}

Measured memory_bytes: 3620
function main(input) {
  const args = input.split("\n");
  let n, m, l;
  [n, m, l] = args[0].split(" ").map((x) => Number(x));

  let A = Array.from(new Array(n), () => new Array(m).fill(0));
  let B = Array.from(new Array(m), () => new Array(l).fill(0));

  for (let y = 0; y < n; y++) {
    let tmp = args[y + 1].split(" ");
    for (let x = 0; x < m; x++) {
      A[y][x] = Number(tmp[x]);
    }
  }

  for (let y = 0; y < m; y++) {
    let tmp = args[y + n + 1].split(" ");
    for (let x = 0; x < l; x++) {
      B[y][x] = Number(tmp[x]);
    }
  }

  for (let y = 0; y < n; y++) {
    let output = "";
    for (let x = 0; x < l; x++) {
      let sum = 0;
      for (let i = 0; i < m; i++) {
        sum += A[y][i] * B[i][x];
      }
      output += String(sum);
      if (x != l - 1) {
        output += " ";
      }
    }
    console.log(output);
  }
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 19596
#include <bits/stdc++.h>
#define sc1(x) scanf("%lld",&x)
#define sc2(x,y) scanf("%lld%lld",&x,&y)
#define sc3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define pb push_back
#define MX 400005
using namespace std;

typedef long long int ll;

map<string,ll>mp;
vector<string>V;
int main()
{
    ll n;
    cin>>n;
    ll mx=0;
    for(ll i=1;i<=n;i++)
    {
        string str;
        cin>>str;
        mp[str]++;
        mx=max(mx,mp[str]);
    }
    auto it=mp.begin();
    while(it!=mp.end())
    {
        if(it->second == mx)
        {
            V.pb(it->first);
        }
        it++;
    }
    sort(V.begin(),V.end());
    for(ll i=0;i<V.size();i++)
    {
        cout<<V[i]<<endl;
    }

    return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

typedef long long ll;

void solve(long long N, std::string S)
{
    int ans = 0;
    char pre = '0';
    rep(i, S.length())
    {
        if (pre != S[i])
        {
            ans++;
            pre = S[i];
        }
    }
    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main()
{
    long long N;
    scanf("%lld", &N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=2019;

int N;
char dir[]={'U', 'R', 'D', 'L'};
vector<char> u;
vi x, y;
vii xx(200005), xy(400005);

void rotate(){
    for(int j=0; j<N; j++){
        for(int k=0; k<4; k++){
            if(u[j] == dir[k]){
                u[j]=dir[(k+1)%4];
                break;
            }
        }
    }
    for(int i=0; i<N; i++){
        int tmp=x[i];
        x[i]=y[i];
        y[i]=200000-tmp;
    }
    for(int i=0; i<N; i++){
        xx[x[i]].push_back(i);
        xy[x[i]+y[i]].push_back(i);
    }
}

int main(){
    cin >> N;
    x.resize(N), y.resize(N);
    u.resize(N);
    for(int i=0; i<N; i++){
        cin >> x[i] >> y[i] >> u[i];
    }
    int res=INF;
    for(int i=0; i<4; i++){
        xx.assign(200005, vi(0));
        xy.assign(400005, vi(0));
        rotate();
        for(int j=0; j<(int)xx.size(); j++){
            vi ids;
            for(auto num : xx[j]){
                ids.push_back(num);
            }
            sort(all(ids), [&](int i, int j){return y[i] < y[j];});
            for(int k=0; k<(int)ids.size()-1; k++){
                if(u[ids[k]] == 'U' && u[ids[k+1]] == 'D'){
                    res=min(res, (y[ids[k+1]]-y[ids[k]])*5);
                }
            }
        }
        for(int j=0; j<(int)xy.size(); j++){
            vi ids;
            for(auto num : xy[j]){
                ids.push_back(num);
            }
            sort(all(ids), [&](int i, int j){return y[i] < y[j];});
            for(int k=0; k<(int)ids.size()-1; k++){
                if(u[ids[k]] == 'U' && u[ids[k+1]] == 'R'){
                    res=min(res, (y[ids[k+1]]-y[ids[k]])*10);
                }
            }
        }
    }
    if(res == INF) cout << "SAFE" << endl;
    else cout << res << endl;
    return 0;
}

Measured memory_bytes: 41456
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		// solver.readHead(in.readLine());
		for (; solver.hasNext();) {
			solver.readBody(in.readLine());
		}
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		// String[] strArr = str.split(" ");
		// N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
	}

	public boolean hasNext() {
		return cnt < 2;
	}

	BigInteger A;
	BigInteger B;

	public void readBody(String str) {
		// System.out.println(str);]
		if (cnt == 0) {
			A = new BigInteger(str);
		} else {
			B = new BigInteger(str);
			int c = A.compareTo(B);
			if (c == -1)
				System.out.println("LESS");
			else if (c == 1)
				System.out.println("GREATER");
			else
				System.out.println("EQUAL");
		}
		cnt++;
	}
}


Measured memory_bytes: 22612
# coding: utf-8
# Your code here!
nums = list(map(int, input().split()))  # n個の数字がリストに格納される
cnt_5 = 0
cnt_7 = 0
for i in nums:
    if i == 5:
        cnt_5 += 1
    if i == 7:
        cnt_7 += 1
if cnt_5 == 2 and cnt_7 == 1:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 9044
// abc127_a
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int A, B;
    cin >> A >> B;

    if (A <= 5){
        print(0);
    } else if (A <= 12){
        print(B/2);
    } else {
        print(B);
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(a) int((a).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
template<class T, class U> inline void add_self(T &a, U b){a += b;if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void min_self(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void max_self(T &x, U y) { if (y > x) x = y; }

#define _deb(x) cout<<x;
void _print() {cerr << "]\n";} template <typename T, typename... V>void _print(T t, V... v) {_deb(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
template <class T, class U> void print_m(const map<T,U> &m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}
template<class T, class U>void debp(const pair<T, U> &pr, bool end_line=1){cout<<"{"<<pr.first<<" "<<pr.second<<"}"; cout<<(end_line ? "\n" : ", ");}
template <class T> void print_vp(const T &vp, int sep_line=0){if(vp.empty()){cout<<"Empty"<<endl; return;}if(!sep_line) cout<<"{ ";for(auto x: vp) debp(x,sep_line);if(!sep_line) cout<<"}\n";cout<<endl;}
template <typename T>void print(const T &v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<sz(v); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto &el: v) cout<<setw(w)<<el<<" ";cout<<endl;}
template <typename T>void print_vv(const T &vv){if(sz(vv)==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<sz(*vv.begin()); j++)cout<<setw(w)<<j<<" ";cout<<endl;int i = 0;for(auto &v: vv){cout<<i++<<" {";for(auto &el: v) cout<<setw(w)<<el<<" ";cout<<"},\n";}cout<<endl;}

const int N = 1e7+10;
vl lp(N+1);

void calcLp(){ //lowest prime
    for(int i=2; i<=N; i++){
        if(!lp[i]){
            for(int j=i; j<=N; j+=i)
                if(!lp[j]) // comment this line to find Largest Prime factor
                    lp[j] = i;
        }
    }
}


int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    calcLp();
    int n; 
    while(cin>>n){
        ll ans = 0;
        
        fore(i,1,n+1){
            int m = i;
            ll num_divs = 1;
            while(m>1){
                int p = lp[m];
                int pc = 0;
                while(m%p==0){
                    m/=p;
                    pc++;
                }
                num_divs*=(pc+1);
            }
            ans+=i*num_divs;
        }

        cout<<ans<<"\n";

    }
    return 0;
}

Measured memory_bytes: 81192
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
	int A;
	int B;
	cin >> A;
	cin >> B;
	int tmp;
	int emp;
	
	if(A>B){
		for(int K=B; K<A; K++){
			tmp=abs(A-K);
			emp=abs(B-K);
			if(tmp==emp){
				cout << K << endl;
				return 0;
			}
		}
		cout << "IMPOSSIBLE" << endl;
	} else {
		for(int K=A; K<B; K++){
			tmp=abs(A-K);
			emp=abs(B-K);
			if(tmp==emp){
				cout << K << endl;
				return 0;
			}
		}
		cout << "IMPOSSIBLE" << endl;
	} 
	return 0;
}		

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

#define MAX(a, b) ((a>b) ? a : b)
#define MAX3(a, b, c) (MAX(MAX(a, b), c))

int main() {
  int a, b, c, k;
  scanf("%d%d%d", &a, &b, &c);
  scanf("%d", &k);
  int ans = a+b+c, max = MAX3(a, b, c);
  ans += -max + max*(1<<k);
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
N = int(input())
X = list(map(int, input().split()))
max_N = max(X)
ans = 10000000000

for p in range(1, max_N+1):
    tmp = sum([(x-p)**2 for x in X])
    if tmp <= ans:
        ans = tmp
    else:
        break
print(ans)


Measured memory_bytes: 2940
import java.util.*;

class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int n;
		n=sc.nextInt();
		int ans=Integer.numberOfTrailingZeros(sc.nextInt());
		for(int i=1;i<n;i++)
		{
			ans=Math.min(ans,Integer.numberOfTrailingZeros(sc.nextInt()));
		}
		System.out.println(ans);
	}
}

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

int main(){
    int n, a;
    int cr = 0;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a;
        if(((a>>1)<<1) == a){
            if(a%3 && a%5) cr++;
            //cout << a << a%3 << a%5;
        }
    }
    if(!cr) cout << "APPROVED";
    if(cr) cout << "DENIED";
    return 0;
}

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

int main() {
    
    string s, t; cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.rbegin(), t.rend());
    if (s < t) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3636
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    S = input()
    l = len(S)-1
    ret = 0
    for i in range(2**l):
        fs = S[0]
        for j in range(l):
            if (i>>j & 1) == 1:
                fs += '+'
            fs += S[j+1]
        ret += eval(fs)
    print(ret)

if __name__ == '__main__':
    main()

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

int main()
{
    int N, M;
    cin >> N >> M;
    vector<bool> edges(N + 1, false);
    for (int i = 0; i < M; i++)
    {
        int a, b;
        cin >> a >> b;
        edges.at(a) = !edges.at(a);
        edges.at(b) = !edges.at(b);
    }
    for (int i = 1; i <= N; i++)
    {
        if(edges.at(i))
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
		int s=sc.nextInt();
		for(int i=0; i<n; i++){
			if(k>0){
				k--;
				System.out.print(s+" ");
			}else{
				if(s==2 || s==1){
					System.out.print(s+1+" ");
				}else{
					System.out.print(s-1+" ");
				}
			}
		}
	}
}


Measured memory_bytes: 42588
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=1e9+7;
signed main()
{
	ios::sync_with_stdio(false);
	int n,k,ans=0;
	cin>>n>>k;
	for(int i=k;i<=n+1;i++)
	{
		int a=0,b=i-1,c=n-i+1,d=n;
		int x=(a+b)*i/2,y=(c+d)*i/2;
		ans=(ans+y-x+1)%mod;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3664
using System;

namespace Kyopuro
{
    class Program
    {
        static void Main(string[] args)
        {
            int i = 0;
            string c = (Console.ReadLine());

            int length = c.Length;

            string output = "";


            for (i = 0; i < length; i++)
            {
                output = output + "x";

            }


            Console.WriteLine(output);


        }
    }
}

Measured memory_bytes: 13140
n=int(input())
A=[]
for index in range(n):
    A.append(list(map(int,input().split())))

def warshall_floyd(G):
    h=len(G)

    res=0
    for x in range(h):
        for y in range(x+1,h):
            res+=G[x][y]

    check=[[0]*h for z in range(h)]
    for k in range(h):
        for i in range(h):
            for j in range(h):
                temp=G[i][k]+G[k][j]
                if temp==G[i][j]:
                   if i!=j and j!=k and k!=i:
                       check[i][j]=1
                elif temp<G[i][j]:
                    if i!=j and j!=k and k!=i:
                        check[i][j]=-1
    decrease=0             
    for p in range(h):
        for q in range(h):
            if check[p][q]==-1:
                return [False]
            elif check[p][q]==1:
                decrease+=G[p][q]
    else:
        return [True,res-decrease//2]


ans=warshall_floyd(A)
if not ans[0]:
    print(-1)
else:
    print(ans[1])



Measured memory_bytes: 44380
#include<iostream>
#include<math.h>
#include<string.h>
#include<vector>
#include<algorithm>
#include<iomanip>
using namespace std;

int main(){
	long n;
	cin >> n;
	vector<long long> a(n,0);
	
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	
	sort(a.begin(),a.end(),greater<int>());
	
	for(int i=0;i<a.size();i++){
		if(a[i]==a[i+1]){
			a[i]=0;
			a[i+1]=0;
		}
	}

	int cnt=0;
	for(int i=0;i<n;i++){
		if(a[i]!=0)cnt++;
	}		
	cout << cnt << endl;
	return 0;
}


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

using namespace std;

int main(){
  int h, w;
  string s[109];
  map<char, int> mp;
  cin >> h >> w;
  for(int i=0;i<h;i++)cin >> s[i];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++)mp[s[i][j]]++;
  }
  int corner=4*(h/2)*(w/2);
  int center=(h-(h/2)*2)*(w-(w/2)*2);
  int cross=h*w-corner-center;
  while(corner>0){
    bool is_ok=false;
    for(auto& p: mp){
      int tmp=min(corner, p.second/4*4);
      if(tmp>0)is_ok=true;
      p.second-=tmp;
      corner-=tmp;
    }
    if(!is_ok){
      cout << "No" << endl;
      return 0;
    }
  }
  while(cross>0){
    bool is_ok=false;
    for(auto& p: mp){
      int tmp=min(cross, p.second/2*2);
      if(tmp>0)is_ok=true;
      p.second-=tmp;
      cross-=tmp;
    }
    if(!is_ok){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}




Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n ,w;
    cin >> n >> w;
    vector<pair<long ,long>>c;
    for(int i=0;i<n;i++){
        long a,b;
        cin >> a >> b;
        c.push_back(make_pair(a,b));
    }
    sort(c.begin(),c.end());
    long long dp[w+1][n+1];
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=w;i++){
        for(int j=0;j<n;j++){
            if(i >= c[j].first){
                dp[i][j+1] = max(dp[i][j], dp[i - c[j].first][j] + c[j].second) ;
            }
            else
            {
                dp[i][j+1] = dp[i][j];
            }
            
        }
    }
    cout<<dp[w][n]<<endl;
}

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

using namespace std;

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

  int prevItem;
  int prevDelta = 0;
  cin >> prevItem;

  int answer = 1;

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

    int currentDelta = prevItem - currentItem;

    if ((prevDelta > 0 && currentDelta < 0) ||
        (prevDelta < 0 && currentDelta > 0)) {
      answer += 1;
      prevDelta = 0;
    } else if (prevDelta == 0) {
      prevDelta = currentDelta;
    }

    prevItem = currentItem;
  }

  cout << answer << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	char ss[1100],ho[]="Hoshino";
	int i,j,flag,n;
	scanf("%d ",&n);
	while(n--){
		fgets(ss,sizeof(ss),stdin);
		
		for(i=0;i<1006;i++){
			
			flag=0;
			for(j=0;j<7;j++){
				if(ss[i+j]!=ho[j])flag=1;
			}
			if(flag==0)ss[i+j-1]='a';
		}
		
		printf("%s",ss);
	}
	return 0;
}

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

int main() {
    ll n,k;
    cin >> n >> k;
    vector<ll> p(n+1),c(n+1);
    REP(i,n) cin >> p[i];
    REP(i,n) cin >> c[i];
    ll ans = -10000000000;
    REP(i,n){
        ll now = 0;
        ll place = i;
        bool unloop = true;
        REP(j,k){
            if(unloop){
                place=p[place];
                now+=c[place];
                ans = max(ans,now);
                if(place==i){
                    now*=(k/j-1);
                    REP(t,k%j+j){
                        place=p[place];
                        now+=c[place];
                        ans=max(ans,now);
                    }
                    unloop = false;
                }
            }
        }
        //cout << i << " " << place << " " << now << endl;
        ans = max(ans,now);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3700
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n)  { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x)         { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

int main() {
	string s;
	while (cin >> s, s != "#") {
		int y1, x1, y2, x2;
		cin >> y1 >> x1 >> y2 >> x2;
		int w=0, h=1;
		REP(i, s.length()) {
			if (s[i] == 'b') {
				if (h == 1)
					w++;
			}
			if (isdigit(s[i])) {
				if (h == 1)
					w+=s[i]-'0';
			}
			if (s[i]=='/') {
				h++;
			}
		}
		vvb cell(h,vb(w,false));
		int x = 0, y = 0;
		REP(i, s.length()) {
			if (s[i] == 'b') {
				cell[y][x] = true;
				x++;
			}
			if (isdigit(s[i])) {
					x += s[i] - '0';
			}
			if (s[i] == '/') {
				x = 0;
				y++;
			}
		}
		cell[y1 - 1][x1 - 1] = false;
		cell[y2 - 1][x2 - 1] = true;
		REP(i, h) {
			int cnt = 0;
			REP(j, w) {
				if (cell[i][j] == false)
					cnt++;
				if (cell[i][j] == true) {
					if (cnt != 0)
						cout << cnt;
					cnt=0;
					cout << 'b';
				}
			}
			if(cnt!=0)
				cout << cnt;
			if (i != h - 1)
				cout << '/';
		}
		cout << endl;
	}
}

Measured memory_bytes: 3120
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]

h,w,k=map(int,input().split())
s=[input() for i in range(h)]
# print(s)
ans=float('inf')
for i in range(2**(h-1)):
    tmp=1
    for j in range(h-1):
        if 1 & (i>>j):
            tmp+=1
    lst=[[0]*tmp for j in range(w)]

    for j in range(w):
        now=0
        for l in range(h):
            if s[l][j]=="1":
                lst[j][now]+=1
            if 1 & (i>>l):
                now+=1

    cnt=[0]*tmp
    cutcnt=0
    for j in range(w):
        flag=0
        for l in range(tmp):
            if cnt[l]+lst[j][l]>k:
                flag=1
    
        if flag==0:
            for l in range(tmp):
                cnt[l]+=lst[j][l]
        else:
            cutcnt+=1
            for l in range(tmp):
                cnt[l]=lst[j][l]
                if cnt[l]>k:
                    cutcnt=float('inf')
        # print(cnt)
    ans=min(cutcnt+tmp-1,ans)
    # print(lst)
    # print(cutcnt,tmp-1)
print(ans)

Measured memory_bytes: 80856
/*
ID: wangjun30
TASK:
LANG: C++
*/
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n;
	cin>>n;
	int num[n];
	double res=0;
	for(int i=0;i<n;i++)
		cin>>num[i];
	sort(num,num+n);
	res=num[0];
	for(int i=1;i<n;i++)
		res=(res+num[i])/2;
	cout<<res;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>
#include <climits>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  vector<ll> vec;
  for(int i = 0; i < 3 * n; i++){
    ll x;
    cin >> x;
    vec.pb(x);
  }
  sort(vec.begin(), vec.end());
  deque<ll> q;
  for(int i = 0; i < 3 * n; i++){
    q.pb(vec[i]);
  }
  ll res = 0;
  for(int i = 0; i < n; i++){
    q.pop_front();
    q.pop_back();
    res += q.back();
    q.pop_back();
  }
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 6252
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <math.h>
using namespace std;
typedef long long int ll;

int main(){
	string s; cin >> s;
	int a=0,b=0,c=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='a')a++;
		else if(s[i]=='b')b++;
		else c++;
	}
	if(a>b)swap(a,b);
	if(a>c)swap(a,c);
	if(b>c)swap(b,c);
	if(a>=c-1&&b>=c-1){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}
}

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

int main(){
    int n;
    cin >> n;
    int h[n];
    int dp[100010];
    rep(i,n) cin >> h[i];

    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);

    for(int i=2; i<n; ++i){
        dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),(dp[i-1]+abs(h[i]-h[i-1])));
    }

    cout << dp[n-1] << "\n";
}

Measured memory_bytes: 4412
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef long double DD;
const int inf = 1e9;
const int mo= 1e9+7;
const int N = 101010;
int n;
LL T, E, f[N], p[N];

struct sta{
	LL f,d;
	sta(){}
	sta(LL x, LL y){
		f = x;
		d = y;
	}
	friend bool operator <(sta a, sta b){
		if(a.f == b.f)
			return a.d<b.d;
		else 
			return a.f < b.f;
	}
};
set<sta> s1,s2;

int main(){
	scanf("%d%lld%lld",&n, &E, &T);
	for(int i = 1; i <= n; i++)
		scanf("%lld", p + i);
	sort(p + 1, p + n + 1);
	s1.insert(sta(T, p[1]));
	for(int i = 1; i <= n; i++){
		while(!s1.empty() && (p[i] - (*s1.begin()).d) * 2 > T){
			sta t = *s1.begin();
			s1.erase(s1.begin());
			s2.insert( sta(t.f - T - t.d * 2, t.d) );
		}
		f[i]=1ll << 62;
		if(!s2.empty())
			f[i]=(*s2.begin()).f + p[i] * 3;
		if(!s1.empty())
			f[i] = min(f[i], (*s1.begin()).f + p[i]);
		s1.insert(sta(f[i] - p[i] + T, p[i + 1]));
	}
//	for(int i = 1; i<= n; i++)
//		printf("%lld\n", f[i]);
	printf("%lld\n", f[n] + abs(E - p[n]));
	return 0;
}




Measured memory_bytes: 8064
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    a=int(input())
    b = int(input())
    print(6-a-b)
main()

Measured memory_bytes: 3060
#include<stdio.h>

int main(void){
  int prim[1000000],i,j,n,a,b,count;

  for(i=0;i<1000000;i++)prim[i]=0;
  prim[0]=prim[1]=1;  

  for(i=2;i*i<1000000;i++){
    if(prim[i]==0){
      for(j=2*i;j<1000000;j+=i){
	prim[j]=1;
      }
    }
  }

  while(scanf("%d %d %d",&a,&b,&n),a,b,n){

    count=0;
    for(;;){
      if(prim[a]==0){
	count++;
	if(count==n)break;
      }
      a+=b;
    }
    printf("%d\n",a);
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
#define N 1000010

int main(){
	long long f[N] = {0};
	int i,j,n,s;

	f[0] = f[1] = 0;
	for(i = 2; i < N; i++) f[i] = i;
	for(i = 2; i < N; i++){
		if(f[i] == i){
			for(j = i; j < N; j += i) f[j] -= (f[j]/i);
		}
	}
	
	f[0] = f[1] = 2;
	for(i = 2; i < N; i++) f[i] += f[i-1];

	cin >> n;
	while(n--)
		cout << f[(cin >> s),s] << endl;

	return 0;
}

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

int main(){
    int n,m,l;
    cin>>n>>m>>l;
    long a[n][m];
    long b[m][l];

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

    for(int i=0;i<m;i++){
        for(int j=0;j<l;j++){
            cin>>b[i][j];
        }
    }

    long c[n][l];
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            c[i][j]=0;
        }
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            for(int k=0;k<m;k++){
                c[i][j]+= a[i][k]*b[k][j];
            }
        }
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            cout<<c[i][j];
            if(j<l-1)cout<<" ";
        }
        cout<<endl;
    }


    return 0;
}


Measured memory_bytes: 3332
N=int(input())
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            upper_divisors.append(n//i)
        i += 1
    return lower_divisors,upper_divisors
a,b=make_divisors(N)
print(a[-1]+b[-1]-2)

Measured memory_bytes: 3292
#include<stdio.h>
#include<iostream>
using namespace std;

int main()
{
    int n, t;
    scanf("%d %d", &n, &t);
    int a = 0;
    int b = 0;
    for(int i = 1;i <= n; i++)
    {
        int x;
        scanf("%d", &x);
        a += (x + t);
        a -= max(x, b);
        b = x + t;
    }
    printf("%d\n", a);
    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;

    int[] e;
    e.length = N+1;
    foreach (i; 2..N+1) {
        auto cur = i;
        foreach (j; 2..i+1) {
            while (cur % j == 0) {
                ++e[j];
                cur /= j;
            }
        }
    }

    int num(int m) {
        int cnt;
        foreach (x; e) {
            if (x >= m-1) ++cnt;
        }
        return cnt;
    }

    writeln(
        num(75) +
        num(25) * (num(3) - 1) +
        num(15) * (num(5) - 1) +
        num(5) * (num(5) - 1) * (num(3) - 2) / 2
    );
}

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

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: 
      return 1
    over = reduce(mul, range(n,n-r,-1))
    under = reduce(mul, range(1,r+1))
    return over//under

def out(num):
    print(num%1000000007)

for i in range(1,k+1):
    if n-k+1 < i :
      print("0")
    else:
      out(cmb(k-1,i-1)*cmb(n-k+1,i))
    

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

int64 SolvePart(vector<pair<int, int64>> pairs) {
  int m = pairs.size();
  set<int> s;
  for (int i = 1; i <= m; i++) {
    s.insert(i);
  }

  sort(pairs.begin(), pairs.end(), [](const auto& p1, const auto& p2) {
    return p1.second > p2.second;
  });

  int64 score = 0;
  for (const auto [k, val] : pairs) {
    if (*s.begin() > k) {
      continue;
    }
    auto it = s.upper_bound(k);
    it--;
    s.erase(it);
    score += val;
  }
  return score;
}

void SolveCase() {
  int n;
  cin >> n;
  vector<pair<int, int64>> pairs_1, pairs_2;
  int64 base = 0;
  for (int i = 0; i < n; i++) {
    int k;
    int64 l, r;
    cin >> k >> l >> r;
    if (l == r) {
      base += l;
    } else if (k == n) {
      base += l;
    } else {
      if (l > r) {
        pairs_1.push_back({k, l - r});
        base += r;
      } else {
        pairs_2.push_back({n - k, r - l});
        base += l;
      }
    }
  }
  int64 score = base;
  score += SolvePart(pairs_1);
  score += SolvePart(pairs_2);
  cout << score << endl;
}

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

  int num_cases;
  cin >> num_cases;
  for (int i = 0; i < num_cases; i++) {
    SolveCase();
  }
}

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

int need(int N, vector<int> &A, vector<int> &F, int Z){
  int ans = 0, i;
  for(i = 0; i < N; i++){
    ans += max(0ll, A[i] - Z / F[i]);
  }
  return ans;
}

signed main(){
  int N, K, i;
  scanf("%lld%lld", &N, &K);
  vector<int> A(N), F(N);
  for(i = 0; i < N; i++){
    scanf("%lld", &A[i]);
  }
  for(i = 0; i < N; i++){
    scanf("%lld", &F[i]);
  }
  sort(A.begin(), A.end());
  sort(F.begin(), F.end(), greater<int>());
  int l = -1, h, r = (int)(1e13);
  while(r - l > 1){
    h = (l + r) / 2;
    if(need(N, A, F, h) > K){
      l = h;
    }
    else{
      r = h;
    }
  }
  printf("%lld\n", r);
  return 0;
}

Measured memory_bytes: 3328
using System;
using System.Linq;

class Program {
  static void Main(string[] args) {
    var s = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    int r = s[0];
    int D = s[1];
    int x = s[2];
    for (int i = 0; i < 10; ++i) {
      x = x * r - D;
      Console.WriteLine(x);
    }
  }
}

Measured memory_bytes: 13268
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		String input1 = sc.nextLine();
		String input2 = "";
		String[] NM = input1.split(" ");

		int n = Integer.parseInt(NM[0]);
		int m = Integer.parseInt(NM[1]);
		boolean judge = true;
		int value = 0; // 入力された行列Aと列Bの数値を一時的に保持するための変数

		if ((n >= 1 && n <= 100) && (m >= 1 && m <= 100)) {

			int[][] A = new int[n][m];
			int[] b = new int[m];
			int[] c = new int[n];

			String[] AString = new String[m];
			String[] BString = new String[m];

			out: for (int i = 0; i < n; i++) {
				input2 = sc.nextLine();
				AString = input2.split(" ");
				for (int j = 0; j < AString.length; j++) {
					value = Integer.parseInt(AString[j]);
					if (value < 0 || value > 1000) {
						judge = false;
						break out;

					}
					A[i][j] = value;
				}
			}

			if (judge == true) {

				out: for (int i = 0; i < m; i++) {
					BString[i] = sc.nextLine();
					value = Integer.parseInt(BString[i]);
					if (value < 0 || value > 1000) {
						judge = false;
						break out;
					}
					b[i] = value;
				}
			}

			if (judge == true) {
				for (int i = 0; i < n; i++) {
					for (int j = 0; j < m; j++) {
						c[i] += A[i][j] * b[j];

					}

				}

				for (int k = 0; k < n; k++) {
					System.out.println(c[k]);

				}

			}
		}

	}

}



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

int main(){
	int a, b, i;
	int e_num[4] = {0, 0, 0, 0};
	for(i = 0; i < 3; i++){
		scanf("%d%d", &a, &b);
		e_num[a - 1]++;
		e_num[b - 1]++;
	}
	for(i = 0; i < 4; i++){
		if(e_num[i] > 2){
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int f_min(int a,int b)
{
    if(a<0)
        return b;
    else if(b<0)
        return a;
    else if(a<b)
        return a;
    else
        return b;
}
int seg[1000006],m;
void set(int l,int r,int x)
{
    l+=m-1;
    r+=m-1;
    while(l<=r)
    {
        if(l%2==0)
            seg[l]=f_min(seg[l],x);
        if(r%2>0)
            seg[r]=f_min(seg[r],x);
        l/=2;
        r=(r-2)/2;
        if(l==r)
        {
            seg[l]=f_min(seg[l],x);
            break;
        }
    }
    return;
}
int main()
{
    int n,q;
    scanf("%d %d",&n,&q);
    int s[200005],t[200005],x[200005];
    int i;
    for(i=0;i<n;i++)
        scanf("%d %d %d",&s[i],&t[i],&x[i]);
    int d[200005];
    for(i=0;i<q;i++)
        scanf("%d",&d[i]);
    m=1;
    while(m<q)
        m*=2;
    for(i=0;i<2*m-1;i++)
        seg[i]=-1;
    int a,b;
    int min,mid,max;
    for(i=0;i<n;i++)
    {
        min=-1;
        max=q;
        while(max-min>1)
        {
            mid=(max+min)/2;
            if(d[mid]<s[i]-x[i])
                min=mid;
            else
                max=mid;
        }
        a=max;
        min=-1;
        max=q;
        while(max-min>1)
        {
            mid=(max+min)/2;
            if(d[mid]>=t[i]-x[i])
                max=mid;
            else
                min=mid;
        }
        b=min;
        set(a,b,x[i]);
    }
    for(i=0;i<m-1;i++)
    {
        seg[2*i+1]=f_min(seg[2*i+1],seg[i]);
        seg[2*i+2]=f_min(seg[2*i+2],seg[i]);
    }
    for(i=0;i<q;i++)
        printf("%d\n",seg[i+m-1]);
    return 0;
}

Measured memory_bytes: 7040
import java.util.Scanner;

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

      Scanner scan = new Scanner(System.in);


      int[] input = new int[10];
      int x;
      for( int i = 0; i < 10; i++ ) {
        input[i] = scan.nextInt();
      }

      for( int i = 0; i < 10; i++ ) {
        for( int r = i+1; r < 10; r++ ) {
          if( input[i] < input[r] ) {
            x = input[i];
            input[i] = input[r];
            input[r] = x;
          }
        }
      }

      System.out.println( input[0] );
      System.out.println( input[1] );
      System.out.println( input[2] );

    }
}

Measured memory_bytes: 26184
s1 = []
s2 = []
sum = 0

ch = gets.chomp!.split('').map(&:to_s)


ch.length.times do |i|
	if ch[i] == "\\"
		s1 << i

	elsif ch[i] == "/" && s1.size > 0
		j = s1.pop
		sum += i - j
		a = i - j
		while s2.size > 0 && s2.last[0] > j 
			a += s2.last[1]
			s2.pop
		end
		s2 << [j,a]
	end
end


ans = []

while s2.size >0 
	ans << s2.pop[1]
end

puts sum
ans.reverse!
print ans.size
if ans.size > 0
	puts " #{ans.join(" ")}"
else
	print "\n"
end

Measured memory_bytes: 10236
def LIS(seq: list) -> int:
    from bisect import bisect_left

    L = [seq[0]]
    for i in range(len(seq)):
        if seq[i] > L[-1]:
            L.append(seq[i])
        else:
            idx = bisect_left(L, seq[i])
            L[idx] = seq[i]
    return len(L)


N = int(input())
A = [int(input()) for _ in range(N)]
print(LIS(A))



Measured memory_bytes: 10356
import collections
import math


class Dinic:
    """Dinic Algorithm: find max-flow
       complexity: O(EV^2)
       used in GRL6A(AOJ)
    """
    class edge:
        def __init__(self, to, cap, rev):
            self.to, self.cap, self.rev = to, cap, rev

    def __init__(self, V, E, source, sink):
        """ V: the number of vertexes
            E: adjacency list
            source: start point
            sink: goal point
        """
        self.V = V
        self.E = [[] for _ in range(V)]
        for fr in range(V):
            for to, cap in E[fr]:
                self.E[fr].append(self.edge(to, cap, len(self.E[to])))
                self.E[to].append(self.edge(fr, 0, len(self.E[fr])-1))
        self.maxflow = self.dinic(source, sink)

    def dinic(self, source, sink):
        """find max-flow"""
        INF = float('inf')
        maxflow = 0
        while True:
            self.bfs(source)
            if self.level[sink] < 0:
                return maxflow
            self.itr = [0] * self.V
            while True:
                flow = self.dfs(source, sink, INF)
                if flow > 0:
                    maxflow += flow
                else:
                    break

    def dfs(self, vertex, sink, flow):
        """find augmenting path"""
        if vertex == sink:
            return flow
        for i in range(self.itr[vertex], len(self.E[vertex])):
            self.itr[vertex] = i
            e = self.E[vertex][i]
            if e.cap > 0 and self.level[vertex] < self.level[e.to]:
                d = self.dfs(e.to, sink, min(flow, e.cap))
                if d > 0:
                    e.cap -= d
                    self.E[e.to][e.rev].cap += d
                    return d
        return 0

    def bfs(self, start):
        """find shortest path from start"""
        que = collections.deque()
        self.level = [-1] * self.V
        que.append(start)
        self.level[start] = 0

        while que:
            fr = que.popleft()
            for e in self.E[fr]:
                if e.cap > 0 and self.level[e.to] < 0:
                    self.level[e.to] = self.level[fr] + 1
                    que.append(e.to)

while True:
    M, N = map(int, input().split())
    if M == 0 and N == 0:
        break
    blue, red = [], []
    while True:
        for x in input().split():
            blue.append(int(x))
        if len(blue) == M:
            break
    while True:
        for x in input().split():
            red.append(int(x))
        if len(red) == N:
            break
    V = M + N + 2
    edge = [set() for _ in range(V)]
    for i, b in enumerate(blue):
        if b != 1:
            for j, r in enumerate(red):
                if r % b == 0:
                    edge[i].add((M+j, 1))
        for j in range(2, int(math.sqrt(b)) + 1):
            if b % j == 0:
                for k, r in enumerate(red):
                    if r % j == 0 or r % (b // j) == 0:
                        edge[i].add((M+k, 1))
    for i in range(M):
        edge[M+N].add((i, 1))
    for j in range(N):
        edge[M+j].add((M+N+1, 1))
    d = Dinic(V, edge, M+N, M+N+1)
    print(d.maxflow)

Measured memory_bytes: 106708
A,B,C,D,E,F=map(int, input().split())
ans=[A*100,0]
con=0
for a in range(F//100//A+1):
    for b in range(F//100//B+1):
        for c in range(F//C+1):
            for d in range(F//D+1):
                w = a*A+b*B
                s = c*C+d*D
                if s+w==0: continue
                if 100*w+s>F: break
                if s>E*w: break
                t=s/(s+100*w)
                if con<t:
                    con=t
                    ans[0]=s+100*w
                    ans[1]=s
print(*ans)


Measured memory_bytes: 3188
#include <iostream>

using namespace std;

void solve()
{
	int N;
	cin >> N;
	int sum = 100000;
	for(int i = 0; i < N; ++i)
	{
		sum *= 1.05;
		if(sum % 1000 != 0)
		{
			sum += 1000 - (sum % 1000); 
		}
	}
	cout << sum << endl;
}

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

Measured memory_bytes: 0
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define cases long long test;cin>>test;while(test--)
#define f_io ios::sync_with_stdio(false); cin.tie(0)
#define foi(a,n) for(long long i=a;i<n;i++)
#define foj(a,n) for(long long j=a;j<n;j++)
#define fok(a,n) for(long long k=a;k<n;k++)
#define ll long long
#define MOD 1000000007
#define INF 1000000000
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

int main()
{
    f_io;
    ll n;
    cin >> n;
    vector<vector<ll> > dp(3,vector<ll>(n));
    foi(0,3)
        cin >> dp[i][0];
    foi(1,n)
    {
        ll a,b,c;
        cin >> a >> b >> c;
        dp[0][i] = max(dp[1][i-1]+a,dp[2][i-1]+a);
        dp[1][i] = max(dp[0][i-1]+b,dp[2][i-1]+b);
        dp[2][i] = max(dp[1][i-1]+c,dp[0][i-1]+c);
    }
    cout << max(dp[0][n-1],max(dp[1][n-1],dp[2][n-1]));
    return 0;
}


Measured memory_bytes: 6368
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...)
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fls(x) (64 - __builtin_clzll(x))
#define pcnt(x) __builtin_popcountll(x)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, x; cin >> n >> x;
    ll t; cin >> t;
    cout << (((n - 1) / x) + 1) * t << "\n";
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int n;
    cin >> n;
    int d[100];
    for (size_t i = 0; i < n; ++i) {
        cin >> d[i];
    }
    
    int ret = 0;
    for (size_t i = 0; i < n - 1; ++i) {
        for (size_t j = i + 1; j < n; ++j) {
            ret += d[i] * d[j];
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256