akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
const ll INF =1001001001;

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}



//階乗　20くらいが限界
ll factorial(ll n){
  ll a=1;ll b=n;
  for(int i=0;i<n;i++){
    a*=b;
    b--;
  }
  return a;
}

//組み合わせ　nCr
ll comb(ll a,ll b){
  ll c;
  c=factorial(a)/(factorial(a-b)*factorial(b));
  return c; 
}




/*10億7。　　　100000007
2*2行列 H*W
vector<vector<int>> vec(H,vector<int>(W));
for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
cin>>vec[i][j];
  }
}

文字列→数列
string S;int A=atoi(S.c_str());
数列→文字列
int A;string S=to_string(A);
数字判定　isdigit(a)
pair宣言　pair<int,int> p(5,7);
ソート　sort(vec.begin(),vec.end());
キュー　queue<int> q;
   q.push(7);　//７が入る
   cout << q.front() << endl;  // 先頭の値を出力
   q.pop();  // 先頭の値を削除
*/



int main(void){
cout<<fixed<<setprecision(14);
//cin.tie(0); ios::sync_with_stdio(false);

ll N,D;
  cin>>N>>D;
  vector<ll> vecX(N);
  vector<ll> vecY(N);
  for(int i=0;i<N;i++){
    cin>>vecX[i];
    cin>>vecY[i];
  }
  ll sum=0;
  for(int i=0;i<N;i++){
    if(vecX[i]*vecX[i]+vecY[i]*vecY[i]<=D*D){
      sum++;
    }
  }
  cout<<sum<<endl;

}




Measured memory_bytes: 6424
from collections import Counter

H, W = map(int, input().split())
S = Counter()
for _ in range(H):
    S.update(list(input()))

val1, val2 = 0, 0
for v in S.values():
    if v % 2:
        val1 += 1
    elif v % 4:
        val2 += 1

val1_lim = 1 if (H % 2 and W % 2) else 0
val2_lim = 0
if H % 2:
    val2_lim += W // 2
if W % 2:
    val2_lim += H // 2

print('Yes' if val1 <= val1_lim and val2 <= val2_lim else 'No')


Measured memory_bytes: 9436
s = input()
a = int(s[:2])
b = int(s[2:])
if 0 < a and a<13:
    if 0<b and b<13:
        print('AMBIGUOUS')
    else:
        print('MMYY')
elif 0<b and b<13:
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 9120
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>

#define int long long

using namespace std;

signed main() {
	int n, k;
	cin >> n >> k;
	int c = 0;
	for (int i = 0; i < n - k; i++) {
		c += 100;
	}
	for (int i = 0; i < k; i++) {
		c += 1900;
	}
	c <<= k;
	cout << c;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define int long long
#define all(c) (c).begin(),(c).end()
#define endl '\n'
using namespace std;

//                                      mdsaqib
signed main(){
    fast;
    int t=1;
    //cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector <int> A(n,0);
        for(int i=0;i<n;i++){
            cin >> A[i];
        }
        int xsum=0;
        for(int i=0;i<n;i++){
            xsum^=A[i];
            //cout << xsum << " ";
        }
        //cout <<endl <<  xsum << endl;
        vector <int> B(n,0);
        for(int i=0;i<n;i++){
            B[i]=xsum^A[i];
        }
        for(int i=0;i<n;i++){
            cout << B[i] << " ";
        }
    }
}


Measured memory_bytes: 6268
#include<bits/stdc++.h>
#define ll long long
const long double pi=acos(-1);
const int N=2e5+10;
using namespace std;
int arr[N];
int main()
{
  	ll n;
  	ll sum1=0,sum=0;
  	cin>>n;
  	for(int i=0;i<n;i++)
  	{
  		cin>>arr[i];
		sum+=arr[i];	
	}
	ll tmp=sum/n;
	for(int i=0;i<n;i++)
	{
		ll k=(arr[i]-tmp);
		sum1+=k*k;
	} 

	tmp++;
	ll sum2=0;
	for(int i=0;i<n;i++)
	{
		ll k=(arr[i]-tmp);
		sum2+=k*k;
	} 
	sum1=min(sum1,sum2);
	cout<<sum1<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ld = long double;
const ld eps = 1e-9;

int main() {
    ld w, h, x, y;
    cin >> w >> h >> x >> y;
    ld temp = w * h * 0.5;
    cout << temp << " ";
    cout << (abs(w/2 - x) <= eps && abs(h/2 - y) <= eps) << endl;
}

Measured memory_bytes: 3736
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int t = Integer.parseInt(sc.next());
		sc.close();
		sc = null;
		System.out.println((t/a)*b);
	}
}

Measured memory_bytes: 23124
import bisect
import copy
import heapq
import sys
import itertools
import queue
input = sys.stdin.readline
sys.setrecursionlimit(100000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if n is None:
            return

        if self.v is None:
            self.v = n
            return
        self.v = self.f(self.v, n) 


def main():
    N, K = read_values()
    C = [0] * (K + 1)

    for M in range(K, 1, -1):
        c = K // M
        C[M] = pow(c, N, mod)
        for r in range(2 * M, K + 1, M):
            C[M] -= C[r]
            C[M] %= mod

    C[1] = pow(K, N, mod) - sum(C) % mod
    C[1] %= mod
    print(sum(i * k for i, k in enumerate(C)) % mod) 


if __name__ == "__main__":
    main()


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef tuple<int,int,int> iii;
typedef vector<iii> viii;

#define umap unordered_map
#define uset unordered_set
#define pb push_back
#define LSOne(x) (x & (-x))
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

const int iinf = 1e9+7;
const ll inf = 1e18+7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n; cin >> n;
    vector<double> dp(n+1);
    dp[0] = 1;
    for (int coin = 0; coin < n; ++coin) {
        double p; cin >> p;
        for (int i = coin + 1; i >= 0; --i)
            dp[i] = (i == 0 ? 0 : dp[i - 1] * p) + dp[i] * (1 - p);
    }
    double ret = 0;
    for (int i = ceil(n*1.0/2); i <= n; ++i) ret += dp[i];
    cout.precision(10);
    cout << ret << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using u32 = uint32_t;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define MAXC(c, x) (c = max(c, x))
#define MINC(c, x) (c = min(c, x))

#define REP(i,n) for(auto i = 0 * (n), i##_len = (n); i < i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

const ll INF = 1e9;
// 最大流・最小カット問題
// Dinic法 : O(v^2 E)
// require  : なし
// verified : 
// TODO : もう少し簡略化する
// TODO : コメントを足す
template<class T, class U = size_t>
class Dinic {
	struct E { U to, rev_edge_index; T c; };
	U n;
	vector<vector<E>> g;
public:
	explicit Dinic(U n) : n(n), g(n) {}
	void add_undirected_edge(U from, U to, T c) { add_edge(from, to, c, c); }
	void add_edge(U from, U to, T c, T c2 = 0) {
		if (from != to) {
			g[from].push_back({ to,   g[to].size(),       c });
			g[to].push_back({ from, g[from].size() - 1, c2 });
		}
	}

	T max_flow(U in, U out) {
		vector<U> d(n);
		auto bfs = [&]() {
			d.assign(n, 0);
			d[in] = 1;
			queue<U> q; q.push(in);
			while (!q.empty()) {
				U v = q.front(); q.pop();
				for (E e : g[v]) {
					if (e.c > 0 && !d[e.to]) {
						d[e.to] = d[v] + 1;
						q.push(e.to);
					}
				}
			}
			return d[out] > 0;
		};

		vector<U> ptr(n); // 各頂点について何処まで探索したかを保持
		function<T(U, T)> dfs = [&](U v, T lim) {
			if (in == v || !lim) return lim;
			T sum = 0;
			for (U &i = ptr[v]; i < g[v].size(); ++i) {
				E &e = g[v][i], &re = g[e.to][e.rev_edge_index];
				if (d[e.to] >= d[v] || re.c <= 0) continue;
				T f = dfs(e.to, min(lim - sum, re.c));
				if (f <= 0) continue;
				re.c -= f;
				e.c += f;
				sum += f;
				if (sum == lim) break;
			}
			return sum;
		};

		T ans = 0;
		while (bfs()) {
			ptr.assign(n, 0);
			ans += dfs(out, numeric_limits<T>::max() / 8);
		}
		return ans;
	}
};

int main() {
	#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
	#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);

	ll h, w; cin >> h >> w;
	vector<string> a(h);
	REP(i, h) cin >> a[i];
	ll sx, sy, tx, ty;
	REP(i, h) REP(j, w) {
		if (a[i][j] == 'S') {
			sx = i; sy = j;
		}
		if (a[i][j] == 'T') {
			tx = i; ty = j;
		}
	}
	if (sx == tx || sy == ty) {
		cout << -1 << endl;
		return 0;
	}

	Dinic<ll> dn(h + w + 2);
	REP(i, h) REP(j, w) {
		if (a[i][j] != '.') {
			dn.add_undirected_edge(i, h + j, 1);
		}
		if (a[i][j] == 'S') {
			dn.add_undirected_edge(h + w, i,     h + w + 10);
			dn.add_undirected_edge(h + w, j + h, h + w + 10);
		}
		if (a[i][j] == 'T') {
			dn.add_undirected_edge(h + w + 1, i,     h + w + 10);
			dn.add_undirected_edge(h + w + 1, j + h, h + w + 10);
		}
	}

	cout << min(h + w - 2, dn.max_flow(h + w, h + w + 1)) << endl;

	return 0;
}


Measured memory_bytes: 896
import copy

n = int(input())
p = list(map(int, input().split()))
p_test = sorted(copy.copy(p))
count = 0

for i, j in zip(p, p_test):
  if(i != j):
    count += 1

if(count == 2 or count == 0):
  print('YES')
else:
  print('NO')


Measured memory_bytes: 3444
import std.stdio, std.conv, std.string, std.random, std.range, std.typecons, std.math;
import std.algorithm.comparison, std.algorithm.iteration;
import std.algorithm.mutation, std.algorithm.searching, std.algorithm.sorting;

void main()
{
    auto input = readln().strip.split.to!(int[]);
    auto A = input[0];
    auto B = input[1];
    auto C = input[2];
    writeln(min(B / A, C));
}


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

using namespace std;

vector<string> normal(int i){
    vector<string> ans, tmp;
    if(i == 1){
        ans.push_back("a");
        return ans;
    }

    tmp = normal(i-1);
    for(const string& str : tmp){
        char max = 'a';
        for(char c : str)
            if(c > max) max = c;
        for(char c = 'a'; c <= max+1; c++){
            ans.push_back(str + c);
        }
    }
    return ans;
}

int main(){
    int n;

    cin >> n;

    vector<string> v;
    v = normal(n);
    for(string str : v){
        cout << str << endl;
    }
}

Measured memory_bytes: 9164
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000000000000


int main(){
	
	int N;
	cin>>N;
	N = 2*N-1;
	
	vector<int> a(N);
	for(int i=0;i<N;i++){
		cin>>a[i];
		a[i]--;
	}
	
	int ok = 0;
	int ng = N;
	
	while(ng-ok>1){
		int mid = (ok+ng)/2;
		vector<bool> B(N);
		for(int i=0;i<N;i++){
			if(mid<=a[i])B[i]=true;
			else B[i]=false;
		}
		int mini = 1000000;
		bool F = false;
		for(int i=0;i<N;i++){
			if((i!=0&&B[i]==B[i-1])||(i!=N-1&&B[i]==B[i+1])){
				int t = abs(i-N/2);
				if(mini>t){
					mini = t;
					F = B[i];
				}
			}
		}
		if(mini==1000000){
			F = B[N/2];
			int t = ((N-1)/2)%2;
			if(F){
				if(t==0)ok = mid;
				else ng = mid;
			}
			else{
				if(t==0)ng = mid;
				else ok = mid;
			}				
		}
		else{
			if(F)ok = mid;
			else ng = mid;
		}
	}
	
	cout<<ok+1<<endl;
	
	return 0;
}


Measured memory_bytes: 4056
'use strict';
function main(input) {
  const args = input.split('\n');
  const N = parseInt(args[0]),
        P = args[1].split(' '),
        Q = args[2].split(' ');
  var orderOfP = 0,
      orderOfQ = 0;
  var numbersOfP = [],
      numbersOfQ = [];
  for (let i = 1; i <= N; ++i) {
    numbersOfP.push(i);
    numbersOfQ.push(i);
  }
  for (let i = 0; i < N; ++i) {
    var p = parseInt(P[i]),
        q = parseInt(Q[i]);
    orderOfP += numbersOfP.indexOf(p) * factorial(N-1-i);
    orderOfQ += numbersOfQ.indexOf(q) * factorial(N-1-i);
    numbersOfP = numbersOfP.filter(number => number !== p);
    numbersOfQ = numbersOfQ.filter(number => number !== q);
  }
  console.log(Math.abs(orderOfQ - orderOfP));
}

function factorial(n) {
  var ans = 1;
  if (n > 1) {
    for (let i = 2; i <= n; ++i) {
      ans *= i;
    }
  }
  return ans;
}

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

Measured memory_bytes: 21192
S = input()
Q = int(input())
bgn = ''
end = ''
is_inversion = False

for _ in range(Q):
    query = input().split()
    if query[0] == '1':
        if is_inversion:
            is_inversion = False
        else:
            is_inversion = True
    elif query[0] == '2':
        if query[1] == '1':
            if is_inversion:
                end += query[2]
            else:
                bgn += query[2]
        elif query[1] == '2':
            if is_inversion:
                bgn += query[2]
            else:
                end += query[2]
    


if is_inversion:
    ans = end[::-1] + S[::-1] + bgn
else:
    ans = bgn[::-1] + S + end

print(ans)

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

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

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


int main() {

    ll n,x; cin >> n >> x;
    ll ans = 0;
    ll tmp;

    cin >> tmp;
    ans = abs(tmp-x);
    for(int i = 1; i < n; i ++){
         cin >> tmp;
        ans = gcd(ans,abs(tmp-x));
    }
    cout << ans;
    return 0;
}











Measured memory_bytes: 3632
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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (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!{
        a: usize,
        b: usize
    }
    let mut ans = 0;
    let mut m = 1;
    while m <= b {
        let mut nb = b / (m << 1) * m;
        let bt = b % (m << 1);
        if bt >= m - 1 {
            nb += bt + 1 - m;
        }
        let na = if a == 0 {
            0
        } else {
            let at = (a - 1) % (m << 1);
            (a - 1) / (m << 1) * m + if at >= m - 1 {at + 1 - m} else {0}};
        if (nb - na) % 2 == 1 {
            ans |= m;
        }
        m <<= 1;
    }
    println!("{}", ans);
}


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

int main(){
    int n;
    cin>>n;
    vector<int> t(n+1),x(n+1),y(n+1);
    for(int i=1;i<=n;i++) cin>>t[i]>>x[i]>>y[i];

    for(int i=1;i<=n;i++){
        int dt=abs(t[i]-t[i-1]);
        int dx=abs(x[i]-x[i-1]);
        int dy=abs(y[i]-y[i-1]);
        if(dx+dy>dt || (dx+dy)%2!=dt%2){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 4080
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
using ll=long long;
const ll MOD=1000000007,MOD2=998244353,INF=9223372036854775807;//INFはllの最大値で19桁



int main() {
    ll N,M;
    cin>>N>>M;
    vector<ll> A(M);
    ll ans=0;
    rep(i,M){
        cin>>A.at(i);
        ans+=A.at(i);
    }
    if(ans>N){cout<<-1<<endl;}
    else{cout<<N-ans<<endl;}
}


Measured memory_bytes: 3644
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<random>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    if(n == 1){
        cout << m << '\n';
        return 0;
    }
    int ans = 1;
    for(int i = 1; i * i <= m; i++){
        int cand = i;
        if(m % cand == 0 && m / cand >= n){
            ans = max(ans, cand);
        }
        cand = m / i;
        if(m % i == 0 && i >= n){
            ans = max(ans, cand);
        }
    }
    cout << ans << '\n';
}


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

using namespace std;

const int INF = 1000000000;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K;
  cin >> N >> K;
  vector<int> H(N);
  for (int i = 0; i < N; i++)
    cin >> H[i];
  vector<int> costs(N, INF);
  costs[0] = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < min(i + K + 1, N); j++) {
      costs[j] = min(costs[j], costs[i] + abs(H[j] - H[i]));
    }
  }
  cout << costs[N - 1] << '\n';
  return 0;
}


Measured memory_bytes: 1024
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if (a > 8 || b > 8) {
			System.out.println(":(");
		}else {
			System.out.println("Yay!");
		}
	}
}


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

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

    if (S.at(S.size() - 1) == 's')
    {
        S += "es";
    }
    else
    {
        S += "s";
    }

    cout << S << endl;
    return 0;
}

Measured memory_bytes: 3644
C = {i:0 for i in range(9)}
N = int(input())
A = list(map(int,input().split()))
for i in range(N):
    a = A[i]
    if a<400:
        C[0] += 1
    elif a<800:
        C[1] += 1
    elif a<1200:
        C[2] += 1
    elif a<1600:
        C[3] += 1
    elif a<2000:
        C[4] += 1
    elif a<2400:
        C[5] += 1
    elif a<2800:
        C[6] += 1
    elif a<3200:
        C[7] += 1
    else:
        C[8] += 1
cmin = 0
for i in range(8):
    if C[i]>0:
        cmin += 1
if cmin==0:
    cmin = 1
    cmax = C[8]
else:
    cmax = cmin+C[8]
print(cmin,cmax)

Measured memory_bytes: 38256
#include <iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
    for(int i=0;i<=25;i++){
      for(int j=0;j<=14;j++){
        if(i*4+j*7==n){
          cout <<"Yes"<<endl;
          return 0;
        }
      }
    }
    cout <<"No"<<endl;
  }


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef long double ld;

int main() {
	int A, B;
	cin >> A >> B;
	int K = (A+B)/2;
	if (abs(A - K) == abs(B - K)) cout << K << endl;
	else cout << "IMPOSSIBLE" << endl;

	return 0;
}

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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

int main(){
    map<ll,int> mp;

    int ans(0);
    for(int i=1;i<101;i++){
        for(int j=1;j<101;j++){
            for(int k=1;k<101;k++){
                mp[i*i+j*j+k*k+i*j+j*k+k*i]++;
            }
        }
    }

    int n;  cin >> n;
    rep(i,n){
        cout << mp[i+1] << endl;
    }

    return 0;
}

Measured memory_bytes: 5956
#include "bits/stdc++.h"
using namespace std;

const long long INF = -1e18;

void solve() {
    int N, M;
    cin >> N >> M;
    vector<int> a(M), b(M), c(M), p(N, -1);
    vector<long long> d(N, INF);
    for (int i = 0; i < M; i++) {
        cin >> a.at(i) >> b.at(i) >> c.at(i);
        a.at(i)--;
        b.at(i)--;
    }
    d.at(0) = 0;
    for (int i = 1; i < N; i++) {
        for (int j = 0; j < M; j++) {
            if (d.at(b.at(j)) < d.at(a.at(j)) + c.at(j)) {
                d.at(b.at(j)) = d.at(a.at(j)) + c.at(j);
                p.at(b.at(j)) = a.at(j);
            }
        }
    }
    long long ans = d.at(N - 1);
    for (int i = 1; i < N; i++) {
        for (int j = 0; j < M; j++) {
            if (d.at(b.at(j)) < d.at(a.at(j)) + c.at(j)) {
                d.at(b.at(j)) = d.at(a.at(j)) + c.at(j);
                p.at(b.at(j)) = a.at(j);
            }
        }
    }
    if (d.at(N - 1) > ans) {
        cout << "inf" << endl;
        return;
    }
    cout << ans << endl;
    return;
}

int main() {
    solve();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
using namespace std;
int main(){
  int n,m,x;
  cin>>n>>m>>x;
  int l=0,r=0;
  rep(i,m){
    int t;
    cin>>t;
    if(t<x) r++;else l++;
  }
  cout<<min(l,r)<<endl;
  return 0;
}


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

int main() {
	int n,k,ans=0;
	cin>>n>>k;
	int dp[n+1];
	for(int i=1;i<=n;i++)
		dp[i]=0;
	while(k--){
		int d;
		cin>>d;
		for(int i=0,x;i<d;i++){
			cin>>x;
			dp[x]++;
		}
	}
    /*
    while(k--){
		int d;
		cin>>d;
		for(int i=0,x;i<d;i++){
			cin>>x;
			dp[x]++;
		}
	}
    */
	for(int i=1;i<=n;i++)
		if(!dp[i])
			ans++;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3596
#include <stdio.h>

#define max(a, b) ((a) > (b) ? (a) : (b))

int main(void) {
	int a, b, c, d;

	scanf("%d %d %d %d", &a, &b, &c, &d);

	printf("%d\n", max(a * b, c * d));

	return 0;
}


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

#define endl '\n'

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

    int a,b; cin >> a >> b;
    if (a > b ) swap(a,b);
    if (a == 1 && b == 2) cout << 3 << endl;
    else if (a == 1 && b == 3) cout << 2 << endl;
    else cout << 1 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int prim(void); 
int A[101][101];
int B[101][101];
int n;
int main() {
	
	int i,j;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++) {
		for(j=0;j<n;j++) {
			scanf("%d",&A[i][j]);
			if(A[i][j]==-1) A[i][j]=1000000;
		}
	}
	printf("%d\n",prim());
	
	return 0;
}

int prim(void) {
	int d[101],pi[101],mincost;
		int Color[101],u,i,j,t=0;;
		
	
	for(i=0;i<n;i++) {
		Color[i]=0;
	d[i]=1000000;
	pi[i]=1000000;
	}
	d[0]=0;
	
	while(1) {
mincost=1000000;
u=-1;
for(i=0;i<n;i++) {
		if(Color[i]!=1 && d[i]<mincost) {
			mincost=d[i];
	u=i;
	}
}
	if(mincost==1000000) break;

Color[u]=1;
for(j=0;j<n;j++) {
	if(Color[j]!=1 && A[u][j]!=1000000) {
		if(d[j]> A[u][j]) {
			pi[j]=u;
			d[j]=A[u][j];
			Color[j]=2;
		}
	}
}
}

for(i=0;i<n;i++) {
	if(pi[i]!=1000000) {
		t+=A[i][pi[i]];
	}
}
return t;
}
			


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

struct Problem {
public:

	void Solve() {
		UL S, T;
		UL H, M;
		cin >> H >> M;
		S = H * 60 + M;
		cin >> H >> M;
		T = H * 60 + M;
		UL X; cin >> X;
		cout << (T - S - X) << endl;
	}
};

int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}


Measured memory_bytes: 3632
n, m = map(int,input().split())
k = []
s = []
for i in range(m):
    K, *S = map(int,input().split())
    k.append(K)
    s.append(S)
p = list(map(int,input().split()))

rec = 0
for i in range(2**n):
    on_off = [0] * n

    for j in range(n):
        #j桁目が1の時
        if (i>>j)&1:on_off[j] = 1

    for j in range(m):
        on_cnt = 0
        for sj in s[j]:
            if on_off[sj - 1]:on_cnt = on_cnt^1

        if on_cnt != p[j]:break
    else:
        rec += 1
print(rec)

Measured memory_bytes: 40816
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;

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

const long long INF = 1LL << 60;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

ll dp[110][100100] = {0};

int main(void){
    ll n, w;
    cin >> n >> w;

    ll weight[110];
    ll value[110];

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


    for(int i = 0; i < n; i++){
        for(int j = 0; j <= w; j++){
            if(j - weight[i] >= 0){
                if(dp[i + 1][j] < dp[i][j - weight[i]] + value[i]){
                    dp[i + 1][j] = dp[i][j - weight[i]] + value[i];
                }
                // dp[i + 1][j] = max((ll)dp[i + 1][j], (ll)dp[i][j - weight[i]] + value[i]);
            }
            if(dp[i + 1][j] < dp[i][j]){
                dp[i + 1][j] = dp[i][j];
            }
            // dp[i + 1][j] = max((ll)dp[i + 1][j], (ll)dp[i][j]);
        }
    }

    cout << dp[n][w] << endl;
}


Measured memory_bytes: 79360
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll a, b;
    cin >> a >> b;
    ll n = b-a;
    print(n*(n+1)/2 - b);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
using namespace std;

int main(){
    int X;
    cin >> X;
    long long ans = 0;
    long long POW;
    if(X==1){
        cout << 1 << endl;
        return 0;
    }else{
        for(int i=0;i<X;i++){
            for(int j=2;j<X;j++){
                POW = pow(i,j);
                if(POW<=X){
                    ans = max(ans,POW);
                }
            }
        }
    }
        cout << ans <<endl;
        return 0;
    }
    


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

int main( int argc, char *argv[] )
{
int i;
int N;
int K;
int X;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> N;
	cin >> K;

	X = 1;
	for( i = 0; i < N; i++ )
	{
		if( X < K )
			X *= 2;
		else
			X += K;
	}

	cout << X << endl;

	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
    vector<int> s;
    vector<int> t;
    int n, q, temp;
    int num = 0;
    cin >> n;
    for (int i = 0; i < n; ++i){
        cin >> temp;
        s.push_back(temp);
    }
    cin >> q;
    for (int i = 0; i < q; ++i){
        cin >> temp;
        t.push_back(temp);
    }
    int res = 0;
    for (int i = 0; i < q; ++i){
        for (int j = 0; j < n; ++j){
            if (t[i] == s[j]){
                num++;
                break;
            }
        }
    }
    cout << num << endl;
    return 0;
}



Measured memory_bytes: 3228
#include <iostream>
#include <cmath>
#include <map>

#define MOD 998244353

int map[100000];

int main(void){
    int N;
    std::cin >> N;
    std::map<int, int> map;
    int d;
    for(int i = 0; i < N; ++i){
        std::cin >> d;
        if((i == 0 && d != 0) || (i != 0 && d == 0)){
            std::cout << 0;
            return 0;
        }
        ++map[d];
    }

    long long sum = 1;
    for(int i = 0; i < N-1; ++i){
        for(int j = 0; j < map[i+1]; ++j){
            sum = (sum * map[i])%MOD;
        }
    }

    std::cout << sum;
    return 0;
}

Measured memory_bytes: 4992
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

using ll = uint_fast64_t;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;

constexpr int inf = ~(1 << 31);
constexpr ll llinf = ~(1LL << 63);
constexpr int mod = 1e9 + 7;
constexpr ld pi = 3.14159265358979323846L;

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

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()
#define DEBUG cerr << "DEBUG: DONE" << endl;

struct Pos {
    int h, w;
};

int main(){
    ios::sync_with_stdio(false); cin.tie(nullptr);
    //cout << fixed << setprecision(6);
    int H,  W;
    cin >> H >> W;
    vector<string> s(H);
    rep (i, H) cin >> s[i];

    vector<vector<int>> dist(H, vector<int>(W, -1));
    queue<Pos> que;
    dist[0][0] = 0;
    que.emplace(Pos({0, 0}));
    while (not que.empty()) {
        const Pos now = que.front(); que.pop();
        rep (i, 4) {
            const int nh = now.h + dy[i];
            const int nw = now.w + dx[i];
            if (nh < 0 or nh >= H or nw < 0 or nw >= W) continue; 
            if (s[nh][nw] == '#') continue;
            if (dist[nh][nw] != -1) continue;
            dist[nh][nw] = dist[now.h][now.w] + 1;
            que.emplace(Pos({nh, nw}));
        }
    }
    int black = 0;
    rep(i, H) rep(j, W) if(s[i][j] == '#') ++black;
    int ans = H * W - black - dist[H-1][W-1] - 1;

    if (dist[H-1][W-1] == -1) {
        cout << -1 << endl;
        return 0;
    }
    cout << ans << endl;
    return 0; 
}


Measured memory_bytes: 3688
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdio>
using namespace std;

string s;
int i;

int main()
{
	cin>>s;
	for (i=0;i<s.length()-8;i++) cout<<s[i];
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		double h = Double.parseDouble(str);
		str = input.readLine( );
		double w = Double.parseDouble(str);
		str = input.readLine( );
		double n = Double.parseDouble(str);
		double ans = n / Math.max(h, w);

		System.out.println((int)Math.ceil(ans));
	}

}


Measured memory_bytes: 21076
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>

//using namespace std;
using std::cin, std::cout, std::endl, std::string;
using ll = long long;

#define rep(countName, left, right, up) for (auto countName = left; countName < right; countName += up)
#define REP(countName, end) for (auto countName = 0; countName < end; countName++)
#define rev(countName, right, left, down) for (auto countName = right; countName >= left; countName -= down)
#define REV(countName, end) for (auto countName = end; countName >= 0; countName--)

auto solve1(ll n)
{
    std::stack<char> st;
    ll num = n;
    string str;

    do
    {
        ll mod = num % 26;

        if (mod == 0)
        {
            st.push('z');
            num -= 26;
        }
        else
        {
            st.push(char(mod + 'a' - 1));
            num -= mod;
        }

        num /= 26;
        //cout << num << " " << mod << " " << st.top() << endl;
    } while (num != 0);

    while (!st.empty())
    {
        //cout << "[" << st.top() << "]";
        str += st.top();
        st.pop();
    }

    return str;
}

int main(void)
{
    ll n;
    cin >> n;
    std::cout << solve1(n) << std::endl;

    return 0;
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.txt"
 
#include<vector>
#include<map>
#include<algorithm>
#include <string>
using namespace std;
long long int powint(long long int a, int b) {
	if (b == 0)return 1;
	if (b == 1)return a;
	else {
		long long int ans = 1;
		long long int c = powint(a, b / 2);
		ans *= c*c;
		ans *= (b % 2) ? a : 1;
		return ans;
	}

}
long long int gcd(long long int l, long long int r) {
	if (l > r)return gcd(r, l);
	else {
		if (r%l) {
			return gcd(l, r%l);

		}
		else {
			return l;
		}
	}
}

map<long long int, int>soinnsuu(long long int a) {
	map<long long int, int>ans;
	for (long long i = 2; i*i <= a; ++i) {
		while (a%i == 0) {
			ans[i]++;
			a /= i;
		}
	}
	if (a != 1)ans[a]++;


	return ans;
}
vector<int>primes;
void hurui(const int amax) {
	static bool flag = false;
	if (flag)return;
	vector<int>sos;
	sos = vector<int>(amax + 1, true);
	sos[0] = false; sos[1] = false;
	for (int i = 2; i <= amax; ++i) {
		if (sos[i]) {
			for (int j = 2 * i; j <= amax; j += i)sos[j] = false;
		}
	}
	for (int i = 0; i <= amax; ++i) {
		if (sos[i]) {
			primes.push_back(i);
		}
	}
	flag = true;
}


bool isso(long long int a) {
	if (a == 1 || a == 0)return false;
	for (long long int i = 2; i*i <= a; ++i) {
		if ((a%i)) {
		}
		else {
			return false;
		}
	}
	return true;
}
vector<long long int> divisor(map<long long int, int> s) {
	vector<long long int> res;
	int num = 1;
	for (auto it = s.begin(); it != s.end(); ++it) {
		num *= (*it).second + 1;
	}
	for (int i = 0; i < num; ++i) {
		int bs = i;
		long long int p = 1;
		for (auto it = s.begin(); it != s.end(); ++it) {
			int a = bs % ((*it).second + 1);
			p *= powint((*it).first, a);
			bs /= ((*it).second + 1);
		}
		res.push_back(p);
	}
	return res;
}


long long int powmod(long long int a, long long int b, const int mod) {
	assert(b >= 0);
	if (b == 0)return 1;
	if (b == 1)return a;
	long long int ans = 1;
	long long int aa = powmod(a, b / 2, mod);
	ans *= aa*aa;
	ans %= mod;
	if (b % 2)ans *= a;
	ans %= mod;
	return ans;
}



int main() {
	int N; cin >> N;
	long long int a = 1;
	while (N--) {
		long long int b; cin >> b;
		a = a*b / (gcd(a, b));
	}
	cout << a << endl;
	return 0;
}

Measured memory_bytes: 3116
from bisect import bisect_left, bisect_right  # return index


N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

ans = 0

for i in range(N):
    b = B[i]
    a_ix = bisect_left(A, b)
    c_ix = bisect_right(C, b)
    ans += a_ix * (N - c_ix)

print(ans)

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

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

    return gcd(b,a%b);
}

void solve()
{
   long long n,res=0;
   cin>>n;

   if(n/500)
    {
        res+=(n/500)*1000;
        n%=500;
    }

   if(n/5)
    {
        res+=(n/5)*5;
        n/=5;
    }

   cout<<res<<endl;
}

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

    
    solve();
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int a = sc.nextInt();
        // スペース区切りの整数の入力
        int b = sc.nextInt();
        int i = 0;

        if ((1 <= a && a <= 12) && (1 <= b && b <= 31)) {
            if (b < a) {
                i = a - 1;
                System.out.println(i);
            } else {
                i = a;
                System.out.println(i);
            }
        }
    }
}

Measured memory_bytes: 21716
#include <iostream>


using namespace std;

int main()
{
    int n,sum;
    string s;
    cin >>n>>s;
    sum=0;
    int i=0;
    while(i<n){
        if (s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C' ){
            sum++;
        }
        i++;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int main(void)

{

   int a,b;

   scanf("%d %d",&a,&b);

   if(a==b){

      printf("a == b\n");

   }

     else{

      if(a<b){

         printf("a < b\n");

      }

      else{

         printf("a > b\n");

      }

     }

   return 0;

}
  

Measured memory_bytes: 580
import sys
input = sys.stdin.readline

INF = float('inf')


def number2digits(number):
    return list(map(int, str(number)))


def sum_of_digits(number):
    sum = 0
    while number > 0:
        sum += number % 10
        number //= 10
    return sum


def main():
    N, A, B = map(int, input().split())
    ans = 0
    for number in range(1, N+1):
        total = sum_of_digits(number)
        if A <= total <= B:
            ans += number

    print(ans)


if __name__ == '__main__':
    main()


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 A, B; cin >> A >> B;
    if (B >= A) cout << "unsafe" << endl;
    else cout << "safe" << endl;

    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(long long int i = K; i < N; i++)
#define ll long long int
using namespace std;

ll F(ll A){
ll countA = 0;

while(A > 0){
A /=10;
countA++;}
return countA;
}

int main() {
ll N, M;cin >> N >> M;
vector<pair<ll, pair<ll, ll>>> V(M);
vector<pair<ll, ll>> A(M);
map<ll, ll> P;

rep(i, 0, M){

    cin >> V[i].second.first >> V[i].first ;

    V[i].second.second = i + 1;

}

sort(ALL(V));
  
  //for(auto v : V )
    //cout << v.first << " " << v.second.first << " " << v.second.second << endl;

rep(i, 0 , M){

    P[V[i].second.first]++;

    V[i].first = P[V[i].second.first];
 
}
  
 //for(auto v : V )
    //cout << v.first << " " << v.second.first << " " << v.second.second << endl;

rep(i, 0, M){

    A[V[i].second.second - 1].first = V[i].second.first;
  
    A[V[i].second.second - 1].second = V[i].first;

}

for(auto a : A ){

    rep(i, 0, 6 - F(a.first)){

        cout << 0;

    }

    cout << a.first;

    rep(i, 0, 6 - F(a.second)){

        cout << 0;

    }

    cout << a.second << endl;
    
}

}

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


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
# define M_PI    3.14159265358979323846
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define w(x)  int x; cin>>x; while(x--)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"
#define watch4(x,y,z,q) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<" and "<<(#q)<<" is "<<(q)<<"\n"
#define MOD 1000000007
#define INF 1000000007;
#define F first
#define S second
#define pb(x) push_back(x);


#define ll  long long
#define all(c) (c).begin(),(c).end()
#define endl "\n"

typedef vector<int> vl;
typedef vector< vl > vvl;
typedef pair< int, int> pll;
typedef map< int, int> mll;


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif





void c_p_c()
{
#ifndef ONLINE_JUDGE
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
void parray(int a[], int n) {
	for (int i = 0; i < n; i++) {
		cout << a[i] << " ";
	}
	cout << endl;
}

int main() {
	int i, m, k, n;
	long long int sum = 0;
	c_p_c();
	ll a, b;
	cin >> a >> b;
	if ((a * 2) <= b) {

		sum += a;
		b -= (a * 2);
		sum += b / 4 ;
		cout<<sum<<endl;



	} else {
		cout<<b/2<<endl;



	}

}


Measured memory_bytes: 3564
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <bitset>
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define rrep(i,a,n) for(ll i=n;i>=a;i--)
#define elif else if
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF = 1e+17;
const ll MODcdf = 998244353;
bool pairCompare(const P& firstElof,const P& secondElof){
    return firstElof.first<secondElof.first;
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll n,q;cin>>n>>q;
    string s;cin>>s;
    ll l[q],r[q];
    rep(i,0,q)cin>>l[i]>>r[i];
    ll dp[n];
    rep(i,0,n){
        dp[i]=dp[i-1];
        if(s[i-1]=='A'&&s[i]=='C')dp[i]++;
    }
    ll ans;
    rep(i,0,q){
        ans=dp[r[i]-1]-dp[l[i]-1];
        cout<<ans<<endl;
    }
}

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

struct BIT{
  int n;
  vector<int> bit; //[1,N]

  void init(int _n){
    n = _n+2;
    bit.resize(n);
  }

  int sum(int i){
    int sum = 0;
    while(i > 0){
      sum += bit[i];
      i -= i & -i;
    }
    return sum;
  }

  void add(int i,int x){
    while(i <= n){
      bit[i] += x;
      i += i & -i;
    }
  }
}bit;

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

  int n; cin >> n;
  bit.init(n);
  vector<int> v(n),w(n);
  for(int i = 0; i < n; i++){
    cin >> v[i];
    w[i] = v[i];
  }
  sort(w.begin(),w.end());

  map<int,int> mp;
  for(int i = 0; i < n; i++){
    mp[w[i]] = i+1;
  }

  // 反転数
  int ans = 0;
  for(int i = 0; i < n; i++){
    ans += i - bit.sum(mp[v[i]]);
    bit.add(mp[v[i]],1);
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 20048
import Text.Printf

main = do
  s <- getContents
  let ss = init . filter (not . null) . lines $ s
  mapM_ (mapM_ putStrLn . reverse . (:) "" . solve . map read . words) ss
  
solve :: [Int] -> [String]
solve [x,y] = lid : (replicate (x - 2) ('#' : (replicate (y - 2) '.') ++ ['#'])) ++ [lid]
  where lid = (replicate y '#')

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

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

    int n;
    cin >> n;

    vector<vector<int> > a(2, vector<int>(n, 0));
    REP(i, 2) REP(j, n) cin >> a[i][j];

    int maxi = 0;
    REP(i, n) {
        int sum = 0;
        REP(j, n - i) // 1行目の前からの合計
            sum += a[0][j];
        REP(j, i + 1) // 2行目の後ろからの合計
            sum += a[1][n - 1 - j];
        maxi = max(maxi, sum);
    }

    cout << maxi << '\n';
    return 0;
}


Measured memory_bytes: 256
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>
#include <array>
// ===============================================================
//using系
#pragma region header
using namespace std;
using lint = long long;
using ld = long double;
using ulint = unsigned long long;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
constexpr lint mod = 1000000007;
constexpr long double pi = 3.141592653589793238462643383279;
#pragma endregion
// ========================================================================
//define
#define INF (lint)10000000000000000;
#define mod (int)1000000007
#pragma region header
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
#pragma endregion
#pragma endregion



int main(void) {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	vector<lint> d(n);
	for (int i = 0; i < n; i++) cin >> d[i];
	lint ans = 0;
	for (int i = 0; i < n; i++) {
		if (d[i] >= 2) {
			ans += d[i] / 2;
			d[i] %= 2;
		}
		if (i != n - 1) {
			if (d[i] == 1 && d[i + 1] != 0) {
				ans++;
				d[i] = 0;
				d[i + 1]--;
			}
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3940