akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
//#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair <ll, ll > pll;

bool comp(const pll& a, const pll& b) {
	return a.first < b.first;
}
std::vector<int> enum_div(int n)//nの約数を列挙
{
	std::vector<int> ret;
	for (int i = 1; i * i <= n; ++i)
	{
		if (n % i == 0)
		{
			ret.push_back(i);
			if (i != 1 && i * i != n)
			{
				ret.push_back(n / i);
			}
		}
	}
	return ret;
}


template<int N>
int factorial() {
	return factorial<N - 1>() * N;
}
ll nCr(ll n, ll r);//コンビネーション
int permutation(int n, int r);//nPk パーミュテーション
int factorial(int k);//階乗

template<>  /// 特殊化：factorial<N=”1”>だったら，値を返す
int factorial<1>() {
	return 1;
}
int main()
{
	//priority_queue<int> q;
	string s = {};
	ll h = 0, w = 0, k = 0, a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, ans = 0;
	ll x[100005] = {};
	ll y[100005] = {};
	string str[200005] = {};
	//char* ch[200005] = {};
	char* ch1 = {};
	//ll z[302][302] = {};
	//std::vector<string> data;
	//sort(data.begin(), data.end());//昇順ソート

	cin >> s;
	for (int i = s.size()-1; i >= 0; i--)
	{
		if (b==1)
		{
			if (s[i]=='9')
			{
				s[i] = '0';
				continue;
			}
			s[i] = s[i] + 1;
			b = 0;
		}

		if (s[i]>='6')
		{
			ans += '0'+10 - (s[i]);
			b = 1;
			s[i] = '0';
		}
		else if (i>=1&&s[i] == '5'&& s[i-1] >= '5')
		{
			ans += '0' + 10 - (s[i]);
			b = 1;
			s[i] = '0';
		}

	}
	if (b==1)
	{
		ans++;
		b = 0;
	}

	for (int i = 0; i < s.size(); i++)
	{
		if (s[i]<='5')
		{
			ans += s[i] - '0';
		}
		else
		{
			ans += 11-(s[i] - '0');

		}
	}
	//cout << s << endl;
	cout << ans << endl;

	//return 0;

	/*cout << c << endl;
	cout << b << endl;*/
	//cout << fixed << setprecision(10) <<tmp << endl;
	//cout<<factorial<10><<endl;
	return 0;
}
//2つの組の数をソートしたりするやつ
//vector<pair<ll, ll> > hoges(a);
//for (int i = 1; i <= a; i++)
//{
//	cin >> h;
//	hoges[i - 1] = make_pair(h, i);
//}
//sort(hoges.begin(), hoges.end(), comp);
//for (int i = 0; i < a; i++)
//{
//	cout << hoges[i].second << endl;
//}

int permutation(int n, int r) {
	int n_sum, r_sum;
	int i;
	r = n - r;
	n_sum = factorial(n);
	r_sum = factorial(r);
	return n_sum / r_sum;
}

ll nCr(ll n, ll r) {
	ll ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
int factorial(int k) {
	int sum = 1;
	for (int i = 1; i <= k; ++i)
	{
		sum *= i;
	}
	return sum;
}

Measured memory_bytes: 2948
#include <bits/stdc++.h>
using namespace std;
#define rep(it,st,en) for(int it=(st);it<(int)(en);++it)
#define all(c) (c).begin(), (c).end()
#define debug(x) cerr << #x << " = " << x << endl
#define eb emplace_back
#define X first
#define Y second
typedef long long int ll; 
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, x;
    cin>>n>>x;
    vector<ll> a(n);
    rep(i,0,n) cin >> a[i];
    sort(all(a));
    ll left = x;
    ll cnt = 0;
    rep(i,0,n-1) {
      if(a[i] <= left) left -= a[i], ++cnt;
    }
    if(a.back() == left) ++cnt;
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
import itertools
N, M = map(int, input().split())
d = [[] for i in range(N)]
for i in range(M):
  a, b = map(int, input().split())
  d[a-1].append(b-1)
  d[b-1].append(a-1)

r = 0
for path in itertools.permutations(range(1, N)):
  path = tuple([0]) + path
  for i in range(1, N):
    if(path[i] not in d[path[i-1]]):
      break
  else:
    r += 1
print(r)

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

using namespace std;

int a[10000010];
 
int main() {
    int n;
    cin>>n;
    long long ans=0;
    
    for(int i=0;i<n; i++) {
        int x,y;
        cin>>x>>y;
        a[i]=x+y;
        ans=ans-y;
    }
    
    sort(a,a+n);
    int cur=1;
    
    for(int i=n-1;i>=0;i--) 
	{
        if(cur) ans+=a[i];
        cur^= 1;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
x, k, d = map(int, input().split())

pm = 1 if x >= 0 else -1
a = abs(x)//d
b = a if abs(x-pm*a*d) < abs(x-pm*(a+1)*d) else a+1
c = min(b, k)
e = x-pm*c*d
if k < b or (k-b) % 2 == 0:
    print(abs(e))
else:
    print(min(abs(e+d), abs(e-d)))

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

int main() {
    int a;
    cin >> a;
    int test[a];
  	for(int i = 0;i < a;i++){
    	cin >> test[i];
    }
  	int tmp,k;
  	for(int j = 0;j < a;j++){
    	for(k = j + 1;k < a;k++){
        	if(test[j] > test[k]){
            	tmp = test[j];
              	test[j] = test[k];
              	test[k] = tmp;
            }
        }
    }
  	a = a-1;
  	int ans = test[a] - test[0];
  	cout << ans << endl;
  	
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cctype>
#include<cmath>
#include<algorithm>
#define ll long long
using namespace std;
int read(){
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
int min(int a,int b){return a<b?a:b;}
int max(int a,int b){return a<b?b:a;}
int abs(int x){return x>0?x:-x;}
void mins(int &a,int b){if(a>b)a=b;}
void maxs(int &a,int b){if(a<b)a=b;}
//void insert(int u,int v){tot++;e[tot].v=v;e[tot].from=first[u];first[u]=tot;}
/*------------------------------------------------------------*/
const int inf=0x3f3f3f3f;

int n;
char s[10];
int main(){
    scanf("%s",s);
    int n=strlen(s);
    bool ok=0;
    for(int i=0;i<n-1;i++)if(s[i]=='A'&&s[i+1]=='C'){ok=1;break;}
    if(ok)printf("Yes");else printf("No");
    
    return 0;
}

Measured memory_bytes: 128
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    }

    private void solve(InputStreamScanner in, PrintWriter out) {
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();

        out.println(c >= a && c <= b ? "Yes" : "No");
    }

    static class InputStreamScanner {

        private InputStream in;

        private byte[] buf = new byte[1024];
        private int len = 0;
        private int off = 0;

        InputStreamScanner(InputStream in)	{
            this.in = in;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        }

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

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

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

        char nextChar() {
            return (char)skip();
        }

        int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        }

        private boolean isSpace(int c) {
            return c < 33 || c > 126;
        }

        private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        }
    }
}

Measured memory_bytes: 21460
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int min(int x, int y){return x<y?x:y;}
int max(int x, int y){return x<y?y:x;}
int main(void){
	int w,h,n,i,ans;
	scanf("%d %d %d",&w,&h,&n);
	int x,y,a;
	int l=0,r=w,b=0,t=h;
	for(i=0;i<n;i++){
		scanf("%d%d%d",&x,&y,&a);
		if(a==1)l=max(l,x);
		else if(a==2)r=min(r,x);
		else if(a==3)b=max(b,y);
		else if(a==4)t=min(t,y);
	}
	ans=(r-l)*(t-b);
	if(r-l<0)ans=0;
	if(t-b<0)ans=0;
	printf("%d",ans);
	return 0;
}

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

using namespace std;
typedef long long ll;

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

    int n, k, a, s=0;
    vector<int> f;
    cin >> n >> k;
    for(int i=0; i<n; ++i) {
        cin >> a;
        f.push_back(a);
    }
    sort(f.begin(), f.end());
    for(int j=0; j<k; ++j) {
        s += f[j];
    }
    cout << s;
    return 0;
} 
 


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

int main(){
    string s;
    cin >> s;
    
    int ans = 0;
    for(int i = 0; i < s.length() / 2; i++){
        if(s[i] != s[s.length() - i - 1]) ans++;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)(x).size())
#define mset(a,v) memset(a,v,sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(a))
using namespace std;
typedef long long ll;

#define O 100005

int d0[200050],d1[200050];
int n;

int main(){
	scanf("%d",&n);
	fore(_,0,n){
		int l,r;
		scanf("%d%d",&l,&r);
		d0[l+O]++;
		d1[r+O]++;
	}
	d0[O]++;d1[O]++;
	ll r=0;
	int q0=0,q1=n+1;
	fore(i,0,200050)q0+=d1[i],q1-=d0[i],r+=min(q0,q1);
	printf("%lld\n",r*2);
	return 0;
}

Measured memory_bytes: 1792
package main

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

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var N int
	con.Scan(&N)
	m := map[int]int{}
	for i := 0; i < N; i++ {
		var a int
		con.Scan(&a)
		m[a]++
	}
	d := 0
	for _, v := range m {
		d += v - 1
	}
	c := len(m)
	if d%2 == 1 {
		c--
	}
	con.Println(c)
	return nil
}


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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    int v = 0;
    cin >> n;
    map<int, int> mp;
    rep (i, n) {
        int a;
        cin >> a;
        if (mp[a] == 0) v++;
        mp[a]++;
    }
    int cnt = 0;
    for (auto const& entry: mp) {
        if (entry.second % 2 == 0) cnt++;
    }
    if (cnt % 2) v--;
    cout << v << endl;
    
    return 0;
}



Measured memory_bytes: 4992
#include"bits/stdc++.h"

#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)

using namespace std;
using ll = long long;
using pos = pair<ll, ll>;

ll n;
vector<ll> a;

void solve();

int main() {

   solve();
   return 0;

}

void solve() {

    cin >>n;
    a.resize(n);
    REP(i,n){
        cin >>a[i];
    }
    sort(a.begin(),a.end());
    cout << a[n-1]-a[0] << endl;

}

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

int main() {
    int n, m, ans = 0;
    cin >> n;
    map<string, int> mp;
    rep(i, n) {
        string blue;
        cin >> blue;
        mp[blue]++;
    }
    cin >> m;
    rep(i, m) {
        string red;
        cin >> red;
        mp[red]--;
    }
    for(pair<string, int> p : mp) ans = max(ans, p.second);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <cmath>
#include <functional>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>
#include <set>
#ifdef XLor
  #define dbg(args...) do { cout << #args << " -> "; err(args); } while (0)
  void err() { std::cout << std::endl; }
  template<typename T, typename...Args>
  void err(T a, Args...args) { std::cout << a << ' '; err(args...); }
#else
  #define dbg(...)
#endif
#define ms(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int mod = 998244353;
const int inf = 1 << 30;
const int maxn = 300 + 5;

int n, k, h[maxn];
ll dp[maxn][maxn];

int main() {
  scanf("%d%d", &n, &k);
  if (n == k) return puts("0"), 0;
  for (int i = 1; i <= n; i++) scanf("%d", h + i);
  for (int i = 1; i <= n; i++) {
    dp[i][1] = h[i];
    // dbg(i, 1, dp[i][1]);
    for (int j = 2; j <= n - k; j++) {
      dp[i][j] = 1ll << 61;
      for (int k = j - 1; k < i; k++) {
        dp[i][j] = min(dp[i][j], dp[k][j - 1] + max(h[i] - h[k], 0));
      }
      // dbg(i, j, dp[i][j]);
    }
  }
  ll ans = 1ll << 61;
  for (int i = 1; i <= n; i++) {
    ans = min(ans, dp[i][n - k]);
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
long long int n;
  cin >>n;
  long long int a[n+1],b[n],count;
  for(int i=0;i<n+1;i++){
    cin >>a[i];
  }
  for(int i=0;i<n;i++){
    cin >>b[i];
  }
  for(int i=0;i<n;i++){
     if(a[i]>b[i])count+=b[i];
    else{
      if(a[i]+a[i+1]<=b[i]){
        count+=(a[i]+a[i+1]);
        a[i+1]=0;
      }
      else{
        count+=b[i];
        a[i+1]-=(b[i]-a[i]);
      }
    }
  }
  cout <<count<<endl;
}

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

using namespace std;

#define rep(i,m,n) for(long i=m;i<n;i++)
#define repr(i,m,n) for(long i=n-1;i>=m;i--)

struct UnionFind {
    vector<int> par,si; 

    UnionFind(int N) : par(N), si(N,1) { 
        rep(i,0,N) par[i] = i;
    }

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

    void unite(int x, int y) {
        x = root(x); 
        y = root(y); 
        if (x == y) return; 
        si[y]+=si[x];
        par[x] = y; 
    }

    bool same(int x, int y) { 
      return root(x)== root(y);
    }
    int size(int x){
       return si[root(x)];
    }

};

int main(){
  long n,m;
  cin >> n >> m;
  UnionFind u(n+m);
  rep(i,0,n) {
    long k;
    cin >> k;
    rep(j,0,k){
      long l;
      cin >> l;
      l--;
      u.unite(i,n+l);
    }
  }
 bool flag=true;
 
  rep(i,1,n) if(u.root(i)!=u.root(0)) flag=false;
  rep(i,n,n+m) if(u.root(i)!=u.root(0)&&u.root(i)!=i) flag=false;
  
  if(flag) cout << "YES" << endl;
  else cout << "NO" << endl;

  
}

Measured memory_bytes: 1792
#include <stdio.h>

void dividing_students(int n);

int main(void)
{
    int n;
    scanf("%d", &n);
    while (n != 0) {
        dividing_students(n);
        scanf("%d",&n);
    }
    return 0;
}

void dividing_students(int n)
{
    for (int i = 1; i <= n; ++i) {
        int math, english, japanese;
        scanf("%d %d %d", &math, &english, &japanese);
        if (math == 100 || english == 100 || japanese == 100) {
            printf("A\n");
        } else if (math + english >= 180) {
            printf("A\n");
        } else if (math + english + japanese >= 240) {
            printf("A\n");
        } else if (math + english + japanese >= 210) {
            printf("B\n");
        } else if ((math + english + japanese >= 150) && (math >= 80 || english >= 80)) {
            printf("B\n");
        } else {
            printf("C\n");
        }
    }
}

Measured memory_bytes: 1012
import numpy as np

n, d = map(int, input().split())
x = [list(map(int, input().split())) for i in range(n)]
ans = 0

for i in range(n):
    if i < n-1:
        for j in range(i+1, n):
            s = 0
            for t in range(d):
                s += np.power((x[j][t]-x[i][t]), 2)
            if np.sqrt(s).is_integer():
                ans += 1

print(ans)

Measured memory_bytes: 21184
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define rv(s) reverse(s.begin(),s.end());
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }

void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}

int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  int h,w;cin>>h>>w;
  
  if(h%3==0||w%3==0){
    cout(0);
    return 0;
  }
  
  ll tw=w/3;
  ll th=h/2;
  
  // 横 → 縦
  ll ma=max(tw*h,max((w-tw)*th,(w-tw)*(h-th)));
  ll mi=min(tw*h,min((w-tw)*th,(w-tw)*(h-th)));
  ll ans=ma-mi;
  tw++;
  ma=max(tw*h,max((w-tw)*th,(w-tw)*(h-th)));
  mi=min(tw*h,min((w-tw)*th,(w-tw)*(h-th)));
  chmin(ans,ma-mi);
  
  // 縦 → 横
  tw=h/3;
  th=w/2;
  ma=max(tw*w,max((h-tw)*th,(h-tw)*(w-th)));
  mi=min(tw*w,min((h-tw)*th,(h-tw)*(w-th)));
  chmin(ans,ma-mi);
  tw++;
  ma=max(tw*w,max((h-tw)*th,(h-tw)*(w-th)));
  mi=min(tw*w,min((h-tw)*th,(h-tw)*(w-th)));
  chmin(ans,ma-mi);
  
  // 縦 → 縦
  ll w1=(w+2)/3;
  ll w2=(w-w1)/2;
  chmin(ans,w1*h-w2*h);
  
  // 横 → 横
  ll h1=(h+2)/3;
  ll h2=(h-h1)/2;
  chmin(ans,h1*w-h2*w);
  
  cout(ans);
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#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>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, ans;
    cin >> n;
    vector<int> a(n);
    rep(i, n) {
      cin >> a[i];
    }
    sort(a.begin(), a.end());
    ans = a[n - 1] - a[0];
    cout << ans << '\n';

    return 0;
}


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

int main()
{
    long long target = 0;
    cin >> target;

    long long temp = 100;
    int ans = 1;

    long long yokin = 100;


    while(1)
    {
        
        yokin = yokin * 1.01;
        if(yokin >= target)
        {
            break;
        }

        ans++;

    }

    cout << ans << endl;
}

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

#define F first
#define S second

using namespace std;
typedef long double ld;
typedef long long ll;

const int max_n = 100011, inf = 1000111222;
const ll inff = 1000111222333444;

int n, a[max_n], c[max_n];
map<int, int> mp;
map<int, vector<int> > mp1;

bool check(int st) {
    //cout << "check " << st << endl;
    mp.clear();
    for (int i = 0; i < n; ++i) {
        ++mp[a[i]];
    }
    c[0] = st;
    int x = 2;
    for (int i = 0; i < n; ++i) {
        c[x] = c[(x - 2 + n) % n] ^ x;
        --mp[c[x]];
        x = (x + 2) % n;
    }
    if (c[0] != st) return false;
    /*for (int i = 0; i < n; ++i) {
        cout << c[i] << " ";
    } cout << endl;*/
    for (auto a : mp) {
        if (a.S != 0) return false;
    }
    return true;
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n;
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
        ++mp[a[i]];
    }
    if (mp.size() == 1 && mp[0]) {
        cout << "Yes\n";
        return 0;
    } else if (n % 3 != 0) {
    cout << "No\n"; return 0;
    }
    int x = 0;
    for (auto a : mp) {
        if (a.S % (n / 3) != 0) {
            cout << "No";
            return 0;
        }
        for (int q = 0; q < a.S / (n / 3); ++q) {
            x ^= a.F;
        }
    }
    if (x == 0) {
        cout << "Yes";
        return 0;
    }
    cout << "No";
    return 0;
    if ((--mp1.end())->S.size() > 3) {
        cout << "No\n";
        return 0;
    }
    for (int k : (--mp1.end())->S) {
        if (check(k)) {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
    return 0;
}


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

using namespace std;

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


    int res = 1e8;
    for(int i=0;i<s.size()-2;i++){
        int num=0;
        num += (s[i]-'0')*100;
        num += (s[i+1]-'0')*10;
        num += (s[i+2]-'0');

        res = min(res,abs(num-753));
    }
    cout<<res;
}


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

int main() {
    int x; cin >> x;
    int maxv = -1;
    for (int i = 0; i <= x; i++)
    {
        for (int j = 2; j < 11; j++)
        {
            int a = pow(i, j);
            
            if (a > x)
            {
                break;
            }
            maxv = max(maxv, a);
        }
    }
    cout << maxv << endl;
}

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

using namespace std;

int a[110];

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

    int sum = 0;

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

    int m;
    cin >> m;

    while(m--)
    {
        int x,y;
        cin >> x >> y;

        cout << sum + y - a[x-1] << endl;
    }
}

Measured memory_bytes: 256
from sys import setrecursionlimit, exit
setrecursionlimit(1000000000)


def main():
    K = int(input()) + 1
    ans = 0
    for i in range(1, K):
        ans += i
        for j in range(i + 1, K):
            def GCD(x, y):
                return GCD(y, x%y) if y else x
            ans += GCD(i, j) * 6
            for k in range(j + 1, K):
                gcd = 1
                mx = min(i, j, k)
                for l in range(2, K):
                    if i % l == 0 and j % l == 0 and k % l == 0:
                        gcd = l
                    if l == mx:
                        break
                ans += gcd * 6
    print(ans)

main()

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll a;
    double b;
    cin >> a >> b;
    ll b1 = round(b*100);
    ll c = a*b1;
    cout << c/100 << endl;

    return 0;
}


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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'


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

  int cnt = n;
  rep (i, n) {
    if (s[i] == 'R') {
      if (i == n - 1) cnt--;
      else {
        if (s[i] != s[i + 1]) cnt--;
      }
    }
    else {
      if (i == 0) cnt--;
      else {
        if (s[i] != s[i - 1]) cnt--;
      }
    }
  }
  DEBUG(cnt);
  cnt += 2*k;
  cout << min(cnt, n - 1) << endl;
}


Measured memory_bytes: 512
p = [1]
n = [0,0]
c = 0
for i in range(1,1000000):
    p.append(0)
for i in range(2,1000000):
    if p[i]==1 :
        n.append(c)
        continue
    c += 1
    n.append(c)
    for j in range(i*i,1000000,i):
        if p[j]==0 : p[j]=1
while True:
    try:
        nn = int(raw_input())
        print n[nn]
    except(EOFError) : break

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

template <class type> class SegmentTree{
public:
    int size;
    vector<type> tree;
    type def;
    type (*marge)(type, type);

    SegmentTree(int n, type d, type (*m)(type, type)){
        size = 1;
        def = d;
        marge = m;
        n++;

        while(size < n){
            size *= 2;
        }

        tree.resize(2*size);

        for(int i = 0;i < size;i++){
            tree[size-1+i] = def;
        }

        for(int i = size-2;i >= 0;i--){
            tree[i] = marge(tree[i*2+1], tree[i*2+2]);
        }

        return;
    }

    SegmentTree(int n, type array[], type d, type (*m)(type, type)){
        size = 1;
        def = d;
        marge = m;
        n++;

        while(size < n){
            size *= 2;
        }

        tree.resize(2*size);

        for(int i = 0;i < size;i++){
            if(i < n) tree[size-1+i] = array[i];
            else tree[size-1+i] = def;
        }

        for(int i = size-2;i >= 0;i--){
            tree[i] = marge(tree[i*2+1], tree[i*2+2]);
        }

        return;
    }

    void update(int i, type val){
        i = size-1+i;
        tree[i] = val;

        while(i > 0){
            i = (i-1)/2;
            tree[i] = marge(tree[i*2+1], tree[i*2+2]);
        }

        return;
    }

    void add(int i, type val){
        i = size-1+i;
        tree[i] = tree[i] + val;

        while(i > 0){
            i = (i-1)/2;
            tree[i] = marge(tree[i*2+1], tree[i*2+2]);
        }

        return;
    }

    type get(int a, int b, int k, int l, int r){
        if(r <= a || b <= l) return def;
        if(a <= l && r <= b) return tree[k];

        type vl = get(a, b, 2*k+1, l, (l+r)/2);
        type vr = get(a, b, 2*k+2, (l+r)/2, r);

        return marge(vl, vr);
    }

    type get(int a, int b){
        return get(a, b, 0, 0, size);
    }
};

int marge(int a, int b){
    return a + b;
}

int main(){
    int n, q;
    cin >> n >> q;
    SegmentTree<int> tree(n, 0, marge);

    int com, a, b;
    for(int i = 0;i < q;i++){
        cin >> com >> a >> b;
        if(com == 0){
            tree.add(a, b);
        }else{
            cout << tree.get(a, b+1) << endl;
        }
    }

    return 0;
}


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

using namespace std;
const int Nmax = 1e3 + 100;
const int MOD = 1e9 + 7;

int n, cnt[Nmax];
long long ans = 1;

int main() {
    cin >> n;
    for(int i = 1; i <= n; ++i) {
        int tmp = i;
        for(int j = 2; j <= i; ++j) {
            if (tmp%j == 0) {
                while(tmp%j == 0) {
                    tmp /= j;
                    cnt[j]++;
                }
            }
        }
    }
    for(int i = 2; i <= n; ++i) {
        ans = (ans * (cnt[i]+1))%MOD;
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int i, N, M[2], a[41], b[41], c[41];
	scanf("%d %d %d", &N, &(M[0]), &(M[1]));
	for (i = 1; i <= N; i++) scanf("%d %d %d", &(a[i]), &(b[i]), &(c[i]));

	int j, k, dp[401][401];
	for (i = 0; i <= 400; i++) {
		for (j = 0; j <= 400; j++) dp[i][j] = 1 << 30;
	}
	dp[0][0] = 0;
	for (k = 1; k <= N; k++) {
		for (i = 400 - a[k]; i >= 0; i--) {
			for (j = 400 - b[k]; j >= 0; j--) if (dp[i][j] + c[k] < dp[i+a[k]][j+b[k]]) dp[i+a[k]][j+b[k]] = dp[i][j] + c[k];
		}
	}
	
	int ans = 1 << 30;
	for (i = 1; i <= 400; i++) {
		if (i % M[0] != 0) continue;
		else if (i / M[0] * M[1] > 400) break;
		else if (dp[i][i/M[0]*M[1]] < ans) ans = dp[i][i/M[0]*M[1]];
	}
	if (ans == 1 << 30) printf("-1\n");
	else printf("%d\n", ans);
	fflush(stdout);
	return 0;
}


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

using ll = long long;

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i{}; i < N; ++i)
    cin >> a[i];

  // 累積和
  vector<ll> s(N+1);
  for (int i{}; i < N; ++i) {
    s[i + 1] = s[i] + a[i];
  }
  map<ll, ll> num;
  for (int i{}; i <= N; ++i) {
    ++num[s[i]];
  }

  ll ans{};
  for (const auto& p : num) {
    if (p.second <= 1) continue;
    ans += p.second * (p.second - 1) / 2;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 15104
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <cassert>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const ll MOD = 1e9+7;
const double EPS = 1e-9;


int main(int argc, const char * argv[]) {
  int a, b; cin >> a >> b;
  if(a <= 9 && b <= 9){
    cout << a * b << endl;
  }else
    cout << -1 << endl;
  
  return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    for(int i = 0;i < n;i ++){
        cin >> h.at(i);
    }

    int ans = 1;
    for(int i = 0;i < n;i ++){
        for(int j = 0;j < i;j ++){
            if(h.at(j) > h.at(i)){
                break;
            }
            if(j == i-1){
                ans ++;
            }
        }
    }

    cout << ans << endl;
}

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

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

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

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

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

    string s, t;
    cin >> s >> t;
    int ssize = s.size(), tsize = t.size();
    for(int i = ssize - tsize; i >= 0; i--){
        bool flag = true;
        REP(j, tsize){
            if(s[i+j] != t[j] && s[i+j] != '?'){
                flag = false; 
                break;
            }
        }
        if(flag){
            REP(j, ssize){
                if(j < i || j >= i + tsize) cout << (s[j] != '?' ? s[j] : 'a');
                else{
                    cout << t;
                    j += tsize-1;
                }
            }
            cout << endl;
            return 0;
        }
    }
    cout << "UNRESTORABLE" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string S;
int i,L,cnt[2];
int main(){
  cin>>S;
  L=S.size();
  for(i=0;i<L;i++)cnt[S[i]-'0']++;
  cout<<min(cnt[0],cnt[1])*2<<endl;
  return 0;
}


Measured memory_bytes: 512
N, M = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
MOD = 10 ** 9 + 7
numx = 0
for i in range(N):
    numx += -(N - i - 1) * X[i] + i * X[i]
numy = 0
for i in range(M):
    numy += -(M - i - 1) * Y[i] + i * Y[i]

print(numy * numx % MOD)

Measured memory_bytes: 18624
num = int(input())
nine = [1,2,3,4,5,6,7,8,9]
flag = 0
for i in nine:
    amari = num % i 
    if amari == 0:
        if num // i in nine:
            print("Yes")
            flag = 1
            break
if flag == 0:
    print('No')


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

int main(){
  int n;
  cin>> n;
  vector<int> a(n);
  for (int i=0; i<n; i++) cin>> a.at(i);
  
  int var=a.at(0);
  for (int i=1; i<n; i+=2) var+=a.at(i+1)-a.at(i);
  vector<int> ans(n);
  for (int i=0; i<n; i++){
    ans.at(i)=var;
    var=a.at(i)*2-var;
  }
  for (int i=0; i<n; i++){
    cout<< ans.at(i);
    if (i==n-1) cout<<endl;
    else cout<<" ";
  }
}

Measured memory_bytes: 2048
import java.util.Scanner;

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

		for(int i=0; i<ary; i++) {
			boxies[i]=sc.nextInt();
		}

		int[] boxies_copy=new int[ary];
		int mae_ary=boxies[0];
		int kosu=0;
		int renzoku=1;
		for(int i=1; i<ary; i++) {
			if(boxies[i]==mae_ary) {
				renzoku++;
			}
			else if(mae_ary!=boxies[i]) {
				kosu+=renzoku/2;
				renzoku=1;
				mae_ary=boxies[i];
			}

			if(i==ary-1) {
				kosu+=renzoku/2;
			}
		}
		System.out.println(kosu);
	}
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define co(x) cout << x
#define coe(x) cout << x << endl

int main() {
  int ans;
  rep(i, 5){
    int A; cin >> A;
    if (A == 0) {
      ans = i+1;
      break;
    }
  }
  co(ans);
}

Measured memory_bytes: 3612
#include<iostream>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	int add,sub,mul;
	add=a+b;
	sub=a-b;
	mul=a*b;
	if(add>=sub&&add>=mul)
	   cout<<add<<endl;
	else if(sub>=add&&sub>=mul)
	   cout<<sub<<endl;
	else
	   cout<<mul<<endl;
	return 0;
}

Measured memory_bytes: 256
use std::cmp::max;
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
    n: usize,
    k: usize,
    s: chars
    }
    let mut c = vec![0, 1];
    for i in 0..n - 1 {
        let lc = c.len() - 1;
        if s[i] == s[i + 1] {
            c[lc] += 1;
        } else {
            let k = c[lc] + 1;
            c.push(k);
        }
    }
    let mut ans = 0;
    let cn = c.len();
    if 2 * k >= cn {
        println!("{}", n);
        return
    }
    for i in 0..cn {
        let mut l = i + 2 * k;
        if l >= cn { break; }
        if c[i] != n && s[c[i]] == '1' && l != cn - 1 { l += 1 }
        ans = max(ans, c[l] - c[i]);
    }
    println!("{}", ans);
}



Measured memory_bytes: 4352
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <vector>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

int n;

int main()
{
	scanf("%d", &n);
	int tot = 0;
	for(int i = 1; i <= n; i++)
	{
		int x;
		scanf("%d", &x);
		if(x & 1) tot++;
	}
	if(tot & 1) printf("NO\n");
	else printf("YES\n");
}

Measured memory_bytes: 384
N = gets.to_i
array=gets.chomp.split(" ").map(&:to_i)

ctn = 0
(0..(N-1)).each do |i|
    mini = i
    (i..N-1).each do |j|
        mini = j if array[j] < array[mini]
    end
    if i != mini
        tmp = array[i]
        array[i] = array[mini]
        array[mini] = tmp
        ctn += 1
    end
end

puts array.join(" ")
puts ctn


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

int main(){
  int a[3], b[3], sum, sum3;
  while(cin >> a[0] >> a[1] >> a[2] && a[0] >= 0) {
    sum = 120*60 - a[0]*60*60 - a[1]*60 - a[2];
    sum3 = sum*3;
    
    a[0] = sum/60/60;
    a[1] = sum/60 - a[0]*60;
    a[2] = sum - a[0]*60*60 - a[1]*60;
    
    b[0] = sum3/60/60;
    b[1] = sum3/60 - b[0]*60;
    b[2] = sum3 - b[0]*60*60 - b[1]*60;

    printf("%02d:%02d:%02d\n", a[0], a[1], a[2]);
    printf("%02d:%02d:%02d\n", b[0], b[1], b[2]);
  }
  return 0;
}
  
  

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
//#include <cmath>
//#include <iomanip>
//#include <map>
//#include <unordered_map>
//#include <cstring>
#include <queue>

using namespace std;
using ll = long long;
// using pint = pair<int, int>;
// ll INF = 1LL << 60;

int main() {
	int N, W;
	cin >> N >> W;
	vector<int> value(N), weight(N);
	for (int i = 0; i < N; i++) cin >> value[i] >> weight[i];
	vector<vector<int>> dp(N + 1, vector<int>(W + 1));
	
	for (int w = 0; w <= W; w++) dp[0][w] = 0;

	for (int i = 0; i < N; i++) {
		for (int w = 0; w <= W; w++) {
			if (weight[i] <= w) dp[i + 1][w] = max(dp[i][w - weight[i]] + value[i], dp[i][w]);
			else dp[i + 1][w] = dp[i][w];
		}
	}
	cout << dp[N][W] << endl;
	return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define SZ(a) int((a).size())
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(int i=x;i<y;i++)
#define frr(i,x,y) for(int i=x-1;i>=y;i--)
#define inf 1e18+1
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;}a=a*a;b>>=1;}return ans;}
ll powerm(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;ans%=mod;}a=a*a;a%=mod;b>>=1;}return ans%mod;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
ll val(ll x,ll y,ll z)
{
    return x*x+y*y+z*z+x*y+y*z+x*z;
}
void solve()
{
    ll n;
    cin>>n;
    VL ans(n+1,0);
    fr(i,1,1e4+1)
    {
        fr(j,1,1e4+1)
        {
            fr(k,1,1e4+1)
            {
                ll p=val(i,j,k);
                if(p>n)
                    break;
                else
                    ans[p]++;
            }
        }
    }
    fr(i,1,n+1)
    {
        cout<<ans[i]<<endl;
    }
    return;
}
int main()
{
    IOS;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}
/* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
*/
// BITMASK:
// 1)When some constrall is of the order of 15-20, think of bitmask DP.
// 2)When some constrall is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algorithm

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0; i<n; i++)
int main()
{
	int N,X,T;
	cin >> N >> X >> T;

	if(N%X==0)
		cout << T*N/X;
	else
		cout << ((N/X)+1)*T;

	cin >> N;
	
	return 0;	
}


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

#define all(v) v.begin(), v.end()
#define mp make_pair
#define EPS (int)1e-9
#define PI acos(-1)
#define endl '\n'
#define pb push_back
#define fi first
#define se second

using namespace std;
using ld = long double;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;

const int mod = 1000000007;


int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n, m;
	cin >> n >> m;
	cout << (n-1)*(m-1) << endl;
	return 0;	
}

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

int main(void){
    int n;
    cin >> n;
    int x[n],l[n];
    for(int i = 0;i < n;i++)cin >> x[i] >> l[i];
    
    P p[n];
    for(int i = 0;i < n;i++){
        p[i].first = x[i]+l[i];
        p[i].second = x[i]-l[i];
    }
    
    sort(p,p+n);
    ll alina = 0,gray = -1e18;
    for(int i = 0;i < n;i++){
        //cout << p[i].first << endl;
        if(gray <= p[i].second){
            //cout << i << endl;
            alina++;
            gray = p[i].first;
        }
    }
    cout << alina << endl;
}

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


int main() {

    int a, p;
    cin >> a >> p;
    cout << (3*a+p) / 2 << endl;
    return 0;
}

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

int main(){
  string a,b,c;
  cin>>a>>b>>c;
  if(a.at(a.size()-1)==b.at(0)){
    if(b.at(b.size()-1)==c.at(0))
      cout<<"YES"<<endl;
    else
      cout<<"NO"<<endl;
  }
  else
    cout<<"NO"<<endl;
}

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

int main() {
	int N, x;
	cin >> N >> x;
	int a[100];
	for (int i = 0; i < N; ++i) cin >> a[i];
	sort(a, a + N);
	int res = 0;
	for (int i = 0; i < N; ++i) {
		if (a[i] <= x) {
			if (i + 1 == N && x > a[i]) break;
			x -= a[i];
			++res;
		}
		else break;
	}

	cout << res << endl;
}

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

long long gcd(long long a,long long b){
	while(1){
		if(a<b) swap(a,b);
		if(!b) break;
		a %= b;
	}
	return a;
}

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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,m; cin >> n >> m;
    string s,t; cin >> s >> t;
    bool ok = true;
    ll i=0;
    ll ans = lcm(n,m);
    ll sn = ans/n;
    ll mn = ans/m;
    for(ll i=0;i<ans;i+=lcm(sn,mn)){
        if(s[i/sn] != t[i/mn]){
            cout << "-1" << endl;
            return 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
    
	int n,i,a[4][3][10]={0},b,f,r,v,h,o,w,p,l,c,q,d;
    cin>>n;

    for(i=0;i<n;i++)
    {
        cin>>b>>f>>r>>v;

		a[b-1][f-1][r-1]+=v;
      
	}
				
   
                   for(o=0;o<3;o++)//棟
                    {
                        for(h=0;h<3;h++)//階
                        {    
                            for(w=0;w<10;w++)//部屋
                            {
                               
                                    cout<<" "<<a[o][h][w];
								
						
							

                            }
							cout<<endl;
							
                        }
                 
                         cout<<"####################"<<endl; 

				   }
				
                        for(h=0;h<3;h++)//階
                        {    
                            for(w=0;w<10;w++)//部屋
                            {     
                                cout<<" "<<a[o][h][w];
							}
							cout<<endl;
						}
				   

                      
    
    

    
    
    
    return 0;
    }


Measured memory_bytes: 3112