akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

/* include file*/
#include <functional>
#include <vector>
using namespace std;

template <class Monoid>
struct Segment {
  using Func = function<Monoid(Monoid, Monoid)>;

  vector<Monoid> node;
  Monoid ide;
  int n = 1;

  Func bin_f;
  Func update_f;

  Segment(const vector<Monoid>& init, Monoid ide_, Func f_, Func u_f)
      : bin_f(f_), ide(ide_), update_f(u_f) {
    int sz = init.size();
    while (n < sz) n *= 2;
    node.assign(n * 2 - 1, ide);
    for (int i = 0; i < sz; i++) node[i + n - 1] = init[i];
    for (int i = n - 2; i >= 0; i--)
      node[i] = bin_f(node[i * 2 + 1], node[i * 2 + 2]);
  }

  void update(int i, Monoid x) {
    i += n - 1;
    node[i] = update_f(node[i], x);
    while (i) {
      i = (i - 1) / 2;
      node[i] = bin_f(node[i * 2 + 1], node[i * 2 + 2]);
    }
  }

  Monoid get_inter(int a, int b, int k = 0, int l = 0, int r = -1) {
    if (r < 0) r = n;
    if (a <= l && r <= b) return node[k];
    if (r <= a || b <= l) return ide;

    Monoid lm = get_inter(a, b, k * 2 + 1, l, (l + r) / 2);
    Monoid rm = get_inter(a, b, k * 2 + 2, (l + r) / 2, r);
    return bin_f(lm, rm);
  }
};

// http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2730414#1
// http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2730425#1
int main(){
  i64 N;
  cin >> N;
  vector<i64> A(N);
  rep(i,0,N - 1) cin >> A[i];
  i64 ng = 0;
  i64 ok = 1e9 + 1;

  while(abs(ok - ng) > 1){
    i64 mid = (ok + ng) / 2;
    i64 sum = 0;
    Segment<i64> seg(vector<i64>(202020,0),0,[](i64 a,i64 b){return a + b;},[](i64 a,i64 b){return a + b;});
    seg.update(101010,1);
    i64 cnt = 0;
    rep(i,0,N - 1){
      if(A[i] <= mid) sum++;
      else sum--;
      cnt += seg.get_inter(0,101010 + sum - 1 + 1);
      seg.update(101010 + sum , 1);
    }
    if(cnt >= N * (N + 1) / 4 + 1) ok = mid;
    else ng = mid;
  }
  cout << ok << endl;

}


Measured memory_bytes: 8784
// #define CPP_IO

#pragma region

#include <bits/stdc++.h>
using namespace std;
using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
template <typename T>
using minheap = priority_queue<T, vector<T>, greater<T>>;
template <typename T>
using maxheap = priority_queue<T>;

#define f first
#define s second

#ifdef LOCAL
#define debug cout
#define debugf(format, ...) printf(format, ##__VA_ARGS__)
#else
#define debug \
    if (0) cout
#define debugf(format, ...) 42
#endif

#define DUMP(a) debug << #a " = " << (a) << "\n";
#define DUMP2(a, b) debug << #a " = " << (a) << " " #b " = " << (b) << "\n";
#define DUMP3(a, b, c) debug << #a " = " << (a) << " " #b " = " << (b) << " " #c " = " << (c) << "\n";
#define DUMP4(a, b, c, d) debug << #a " = " << (a) << " " #b " = " << (b) << " " #c " = " << (c) << " " #d " = " << (d) << "\n";

template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "[ ";
    for (auto e : v) os << e << " ";
    return os << "]";
}

template <typename T, typename V>
ostream& operator<<(ostream& os, set<T, V> v) {
    os << "{ ";
    for (auto e : v) os << e << " ";
    return os << "}";
}

template <typename T, typename V, typename S>
ostream& operator<<(ostream& os, map<T, V, S> v) {
    os << "{ ";
    for (auto e : v) os << e << " ";
    return os << "}";
}

template <typename T, typename V>
ostream& operator<<(ostream& os, pair<T, V> x) {
    return os << "( " << x.first << ", " << x.second << " )";
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    for (auto& e : v) is >> e;
    return is;
}

template <typename T, typename V>
istream& operator>>(istream& is, pair<T, V>& x) {
    return is >> x.first >> x.second;
}

void solve();

int main() {
#ifdef LOCAL
    freopen("data.txt", "r", stdin);
#else
#ifdef CPP_IO
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
#endif
    solve();
}

#pragma endregion

void solve() {
    int n;
    cin >> n;
    cout << n * n * n << "\n";
}

Measured memory_bytes: 256
/*
String[]の初期化、整数の型がlongになっているか
関数（splitとかcontainsとか）内では"+"とかは正規表現となされるので"\\+"とする
配列のコピーはarr1=arr.clone()
HashSet<>[]はおのおの初期化した？？？？？
負の数の割り算は絶対値が小さいほうに切り捨てられるex.-1/2=0ので、ある値>kみたいな式だとバグらせやすいので注意
ある値>=kとして、切り上げた値をとるべき
toLowerCase()はアルファベット以外に対して行ってもエラーにはならない
ArrayDequeではpopとpushはStackと同じ操作になる
*/
//入力終了→Ctrl+D
import java.time.Year;
import java.util.*;
import java.awt.*;
import java.awt.geom.Point2D;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        int two = 0, four = 0, other = 0;
        for (int i = 0; i < n; i++) {
            if (a[i] % 2 == 0 && a[i] % 4 != 0) {
                two++;
            } else if (a[i] % 4 == 0) {
                four++;
            }
        }
        other = n - two - four;
        if (two == 0) {
            out.println(other <= four + 1 ? "Yes" : "No");
        } else {
            out.println(other <= four ? "Yes" : "No");
        }
    }

    static class sc {
        static Scanner s = new Scanner(in);

        static String next() {
            return s.next();
        }

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

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

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

Measured memory_bytes: 50700
n = gets.to_i
a = Array.new(n)
b = gets.chomp.split(' ').map(&:to_i)
a[0] = b[0]
a[n - 1] = b[n - 2]
(0..(n - 3)).each do |i|
  a[i + 1] = [b[i], b[i + 1]].min
end
sum = 0
a.each do |i|
  sum += i
end
puts sum

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

string dp[205][101][102];
//i文字で、j文字を使って値kを作る辞書順最小
string Min(string a, string b) {
	if (a.size() != b.size())return (a.size() < b.size() ? a : b);
	return min(a, b);
}
signed main() {
	int n; string s; cin >> n >> s;
	fill(dp[0][0], dp[205][0], string(500, 'z'));
	dp[0][0][0] = "";
	rep(i, 204)rep(j, n + 1)rep(k, 101) {
		//'('
		dp[i + 1][j][k + 1] = Min(dp[i + 1][j][k + 1], dp[i][j][k] + '(');
		//')'
		if (k)dp[i + 1][j][k - 1] = Min(dp[i + 1][j][k - 1], dp[i][j][k] + ')');
		//s[j]
		if (j < n) {
			if (s[j] == '(') {
				dp[i + 1][j + 1][k + 1] = Min(dp[i + 1][j + 1][k + 1], dp[i][j][k] + '(');
			}
			else if (k) {
				dp[i + 1][j + 1][k - 1] = Min(dp[i + 1][j + 1][k - 1], dp[i][j][k] + ')');
			}
		}
	}
	string ans(500, 'z');
	rep(i, 205) {
		ans = Min(ans, dp[i][s.size()][0]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 167936
T = list(map(int, input().split()))
S = list(map(int, input().split()))

X = T[0]
N = T[1]

cntup = X
cntdown = X
if N == 0:
    print(X)
    
else:
    for i in range(1,100):
        if cntup in S and cntdown in S:
            cntup += 1
            cntdown -=1
        elif cntup not in S and cntdown not in S:
            print(min(cntup,cntdown))
            break
        elif cntup in S and cntdown not in S:
            print(cntdown)
            break
        elif cntup not in S and cntdown in S:
            print(cntup)
            break

Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second
int n, m;
int par[100010];
int r(int x){ return (x==par[x])?x:(par[x]=r(par[x])); }
priority_queue<int> pq[100010];
bool join(int a, int b){
	a=r(a); b=r(b);
	if(a==b) return 0;
	par[a]=b;
	if(pq[a].size()>pq[b].size()) swap(pq[a], pq[b]);
	while(pq[a].size()){
		pq[b].push(pq[a].top()); pq[a].pop();
	}
	return 1;
}
int pc[100010];
inline void dame(){ puts("Impossible"); exit(0); }
int main()
{
	read(n, m);
	for(int i=0; i<n; ++i){
		par[i]=i;
		int x; read(x);
		pq[i].push(-x);
	}
	for(int i=1; i<=m; ++i){
		int a, b; read(a, b); join(a, b);
	}
	priority_queue<int> q;
	ll ans = 0;
	int c=0, o=0;
	for(int i=0; i<n; ++i) if(par[i] == i){
		ans += pq[i].top(); pq[i].pop();
		if(pq[i].empty()) ++o;
		++c;
		while(pq[i].size()){
			q.push(pq[i].top());
			pq[i].pop();
		}
	}
	if(c==1){
		puts("0"); return 0;
	}
	for(int i=0; i<c-2; ++i){
		if(q.empty()){
			puts("Impossible");
			return 0;
		}
		ans += q.top(); q.pop();
	}
	printf("%lld\n", -ans);
	return 0;
}


Measured memory_bytes: 8572
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int N, M, X, Y;
	cin >> N >> M >> X >> Y;
	int A[110];
	int B[110];
	rep(i, N) cin >> A[i];
	rep(i, M) cin >> B[i];
	REP(Z, X + 1, Y) {
		//cout << Z << endl;
		bool f = true;
		rep(j, N) {
			if (A[j] >= Z) {
				f = false;
				break;
			}
		}
		if (!f) continue;
		rep(j, M) {
			if (B[j] < Z) {
				f = false;
				break;
			}
		}
		if (!f) continue;
		cout << "No War" << endl;
		return 0;
	}
	cout << "War" << endl;

    return 0;
}


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

void solve() {
    int n;
    cin >> n;
    vector<int> vt(2 * n);
    for (int i = 0; i < 2 * n; i++)
        cin >> vt[i];
    sort(vt.begin(), vt.end());
    int ans = 0;
    for (int i = 0; i < 2 * n; i += 2)
        ans += vt[i];
    cout << ans;
}

int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(20);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    ll n; cin >> n;
    ll a[n]; zep(i, 0, n)cin >> a[i];
    sort(a, a+n, greater<>());

    ll ans = 0;
    zep(i, 0, n){
        if(i%2 == 0){
            ans += a[i];
        }
        else{
            ans -= a[i];
        }
    }
    print(ans)
    return 0;
}

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

using namespace std;

int main() {
  int n, t, a;
  cin >> n >> t >> a;
  int ans = -1;
  double diff = 1e100;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    if (ans == -1 || fabs(t - x * 0.006 - a) < diff) {
      ans = i;
      diff = fabs(t - x * 0.006 - a);
    }
  }
  cout << ans + 1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

using P = pair<s64, s64>;

void dijkstra(const vector< vector< P > >& g, vs64& d, int s)
{
    rep (i, d.size()) d[i] = 1e18;
    d[s] = 0;

    priority_queue<P, vector<P>, greater<P> > pq;
    pq.push(P{d[s], s});

    while (!pq.empty())
    {
        auto p = pq.top(); pq.pop();
        s64 from = p.second;
        s64 d1 = p.first;
        if (d[from] < d1) continue;

        for (auto& x : g[from])
        {
            s64 to = x.first;
            s64 d2 = x.second;
            if (d[to] > d1 + d2)
            {
                d[to] = d1 + d2;
                pq.push(P{d[to], to});
            }
        }
    }
}

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

    int n, m, s, t;
    cin >> n >> m >> s >> t;
    --s, --t;

    vector< vector< P > > g1(n), g2(n);
    rep (i, m)
    {
        int u, v;
        s64 a, b;
        cin >> u >> v >> a >> b;
        --u, --v;
        g1[u].emplace_back(v, a);
        g1[v].emplace_back(u, a);
        g2[u].emplace_back(v, b);
        g2[v].emplace_back(u, b);
    }

    vs64 d1(n), d2(n);
    dijkstra(g1, d1, s);
    dijkstra(g2, d2, t);

    vs64 d(n, 1e15);
    d[n - 1] -= d1[n - 1] + d2[n - 1];

    for (int i = n - 2; i >= 0; --i)
    {
        d[i] = MAX(d[i] - d1[i] - d2[i], d[i + 1]);
    }

    rep (i, n)
    {
        cout << d[i] << "\n";
    }
    return 0;
}



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

#define ms(s, n) memset(s, n, sizeof(s))
#define f(i, a, b) for (int i = (a); i <=(b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<ll> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int MOD2 = MOD + 2; //1007681537;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) - 1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
int modulo(int a, int b) { return (a % b + b) % b; }
#define db(x) cerr << #x << " = " << (x) << " ";
#define endln cerr << "\n";

int main()
{
	IOS;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll n;
	cin >> n;
	vi a(n);
	ll curxor = 0;
	f(i, 0, n - 1) {
		cin >> a[i];
		curxor ^= a[i];
	}
	f(i, 0, n - 1) {
		cout << (curxor ^ a[i]) << " ";
	}
	//cout << sum << endl;
	// read the stuff at the bottom
	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
	* use int when constraints limits are tight
	* Time taken : global variable < pass by refernce < pass by value
	* It takes significant amt. of time in pass by value
*/





























Measured memory_bytes: 4712
N = int(input())

red = []
blue = []

for i in range(N):
    a, b = map(int, input().split())
    red.append([a, b, True])

for i in range(N):
    c, d = map(int, input().split())
    blue.append((c, d))

ans = 0
for c, d in sorted(blue, key=lambda x: x[0]):
    candidate = sorted([x for x in red if x[0] < c and x[1] < d and x[2]], key=lambda x: -x[1])
    if candidate:
        candidate[0][2] = False
        ans += 1

print(ans)

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

int main(void)
{
    for(int i = 1; i <= 9; i++)
    {
        for(int j = 1; j <= 9; j++)
        {
            printf("%dx%d=%d\n", i, j, i*j);
        }
    }
}



Measured memory_bytes: 2120
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl "\n"
const int MAX= 100005 ;
const long long mod = 1.0e9+7;
ll ceil(ll a,ll b)
{
    if(a%b==0)
    {
        return a/b;
    }
    else
    {
        return a/b+1;
    }
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif
    int t;
    t=1;
    while(t--)
    {
        int n,m,i,x,y,z;
        cin>>n;
        n-=400;
        cout<<8-(n/200)<<endl;
    }
    return 0;
}

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

int n;
int d[110];

int main(){
  cin >> n;
  for (int i = 0; i < (n); ++i) cin >> d[i];
  
  int ans = 0;
  for (int i = 0; i < (n); ++i){
    for (int j = 0; j < (n); ++j){
      if (i==j) continue;
      ans += d[i]*d[j];
    }
  }
  cout << ans /2 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char>cvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
int main()	{
  int n,k,q;
  cin>>n>>k>>q;
  vector<int>a(q),d(n,k);
  rep(i,q) {
    cin>>a[i];
    a[i]--;
  }
  rep(i,n){
    d[i]-=q;
  }
  rep(i,q){
    d[a[i]]++;
  }
  rep(i,n){
    if(d[i]>0)
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
  }
}

Measured memory_bytes: 1408
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import permutations,combinations
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

def myinput():
    return map(int,input().split())

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

a,b,n = myinput()

if b==1:
    print(0)
    exit()
    
def mycalc(a,b,x):
    return floor((a*x)/b) - a*floor(x/b)

if n<b:
    ans = mycalc(a,b,n)
else:
    ans = mycalc(a,b,b-1)

print(ans)

Measured memory_bytes: 85568
N, M = map(int, input().split())
pLst = [list(map(int, input().split())) for i in range(M)]

for i in range(len(pLst)):
    pLst[i].append(i)
nLst = [''] * N

for i in range(N):
    nLst[i] = str(i + 1).zfill(6)
tLst = sorted(pLst, key=lambda x: (x[0], x[1]))
ansLst = [''] * M
tmp = nLst[tLst[0][0] - 1]
index = 1
for i in range(M):
    if tmp == nLst[tLst[i][0] - 1]:
        ansLst[tLst[i][2]] = nLst[tLst[i][0] - 1] + str(index).zfill(6)
        index += 1
    else:
        index = 1
        tmp = nLst[tLst[i][0] - 1]
        ansLst[tLst[i][2]] = nLst[tLst[i][0] - 1] + str(index).zfill(6)
        index += 1

for i in ansLst:
    print(i)

Measured memory_bytes: 46356
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int h,w;
    cin >> h >> w;
    string given[h], a[h], b[h];
    string s;
    for(int i=0;i<h;i++){
        cin >> s;
        given[i]=s;
        a[i]=s; 
        b[i]=s;
    }
    
    for(int i=0;i<h;i++){
        a[i][0]='#';
        b[i][w-1]='#';
        if(i%2==0){
            for(int j=1;j<w-1;j++)
                a[i][j]='#';
        }else{
            for(int j=1;j<w-1;j++)
                b[i][j]='#';
        }
    }
    
    for(int i=0;i<h;i++){
        cout << a[i] << endl;
    }
    cout << endl;
    for(int i=0;i<h;i++){
        cout << b[i] << endl;
    }    
    
}

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://cppreference.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   https://www.boost.org/doc/


Measured memory_bytes: 1536
N=int(input())
T,A=map(int,input().strip().split(" "))
H=input().strip().split(" ")
H=[int(i) for i in H]

ab=10000
titen=0

for i in range(N):
    H[i]=T-(H[i]*6/1000)
    temp=abs(H[i]-A)
    if(ab>temp):
        titen=i+1
        ab=temp
print(titen)


Measured memory_bytes: 3060
while True:
    a, op, b= input().split()
    
    if op == '?':
       break
    if op == '+':
        print(int(a) +int(b))
    elif op == '-':
        print(int(a) - int(b))
    elif op == '*':
        print(int(a) * int(b))
    elif op == '/':
        print(int(int(a) /int(b)))
    


Measured memory_bytes: 5600
#include<stdio.h>

int main(void){
    int n,d;
    scanf("%d %d",&n,&d);
    int ans = n / (d * 2 + 1);
    if(n % (d * 2 + 1) > 0){
        ans++;
    }
    printf("%d\n",ans);
    return 0;
}

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

int main() {
    long long N, K;
    cin >> N >> K;
    
    double res = 0.0;
    for (long long n = 1; n <= N; ++n) {
        double tmp = 1.0;
        long long nn = n;
        while (nn < K) nn *= 2, tmp /= 2.0;
        res += tmp;
    }
    res /= N;
    cout << fixed << setprecision(10) << res << endl;
}

Measured memory_bytes: 3728
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int ans = 0;
    map<int, int> mp;
    REP(i,n){
        int a;
        cin >> a;
        mp[a] = mp[a]+1;
    }
    auto itr = mp.end();
    itr--;
    while(true){
        int now = (*itr).fi;
        if(mp[now]==0){
            if(itr==mp.begin()) break;
            itr--;
            continue;
        }
        mp[now] = mp[now]-1;
        int t=1;
        while(t<=now){
            t<<=1;
        }
        int x = t-now;
        if(mp[x]>0){
            mp[x] = mp[x]-1;
            ans++;
        }
        if(mp[now]>0) continue;
        if(itr==mp.begin()) break;
        itr--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 19072
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;
using ll=long long;
void Yes(bool cnd){
    if(cnd)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}
int main(){
    int n,k;
    cin>>n>>k;
    ll cnt=0;
    const int mod=1e9+7;
    vector<ll> a(n+1);
    for(int i=0;i<=n;i++){
        a[i]=i;
        if(i!=0)a[i]=a[i-1]+a[i]%mod;
    }
    for(int i=k;i<=n+1;i++){
        if(i==n+1)cnt+=1;
        else cnt+=((a[n]-a[n-i])%mod-a[i-1])%mod+1;
        cnt+=mod;
        cnt%=mod;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 4772
x = int(input())
#最初に5を上にした状態で、6にする→5にする→6にする・・をするのが一番効率的
#つまり、11で割ったあまりに応じるのがよい
if x % 11 == 0:
  ans = x // 11 * 2
elif x % 11 <= 6:
  ans = x // 11 * 2 + 1
elif x % 11 >= 7:
  ans = x // 11 * 2 + 2


print(ans)

Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner src = new Scanner(System.in);
		int n = src.nextInt();
		int a[] = new int[n];
		for (int i = 0; i < n; i++) {
			int m = src.nextInt();
			a[i] = m;
		}
		int time = 0, p = 0;
		for (int i = 0; i < n - 1; i++) {
			if (a[i] >= a[i + 1]) {
				p++;
			}
			if (time <= p) {
				time = p;
			}
			if (a[i] < a[i + 1]) {

				p = 0;
			}

		}
		System.out.println(time);

	}

}


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

int main(void) {
	int H, W;
	vector<string> C;

	cin >> H >> W;
	C.resize(H);
	for (int j = 0; j < H; ++j)
		cin >> C[j];

	for (int j = 0; j < H; ++j) {
		cout << C[j] << '\n';
		cout << C[j] << '\n';
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
void call(int n){
  int i = 1;
 CHECK_NUM:
  int x = i;
  if ( x % 3 == 0 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
 INCLUDE3:
  if ( x % 10 == 3 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
  x /= 10;
  if ( x ) goto INCLUDE3;
 END_CHECK_NUM:
  if ( ++i <= n ) goto CHECK_NUM;

  cout << endl;
}
int main(){
	int n;
	cin>>n;
	call(n);
	return 0;
}

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


class UnionFind {
private:
	unsigned size_; vector<unsigned> par, rank;
public:
	UnionFind() : size_(0), par(vector<unsigned>()), rank(vector<unsigned>()) {};
	UnionFind(unsigned size__) : size_(size__) {
		par.resize(size_); rank.resize(size_);
		for (unsigned i = 0; i < size_; i++) par[i] = i, rank[i] = 0;
	}
	unsigned size() { return size_; }
	unsigned root(unsigned x) { return par[x] == x ? x : par[x] = root(par[x]); }
	bool same(unsigned x, unsigned y) { return root(x) == root(y); }
	void unite(unsigned x, unsigned y) {
		x = root(x), y = root(y);
		if (x == y) return;
		if (rank[x] < rank[y]) par[x] = y;
		else if (rank[x] == rank[y]) par[y] = x, rank[x]++;
		else par[y] = x;
	}
	bool operator==(const UnionFind &u) { return par == u.par; }
	bool operator!=(const UnionFind &u) { return par != u.par; }
};


int N, K, L, p, q;
int main() {
	scanf("%d%d%d", &N, &K, &L);
	UnionFind uf1(N+1), uf2(N+1);
	
	for(int i=0;i<K;i++){
		scanf("%d%d", &p, &q);
		uf1.unite(p, q);
	}
	for(int i=0;i<L;i++){
		scanf("%d%d", &p, &q);
		uf2.unite(p, q);
	}
	
	map<pair<int, int>, int> cnt;
	for (int i=1;i<=N;i++){
		cnt[make_pair(uf1.root(i), uf2.root(i))]++;
	}
	for (int i=1;i<=N;i++) {
		if(i>1) printf(" ");
		printf("%d", cnt[make_pair(uf1.root(i), uf2.root(i))]);
	}
	printf("\n");
	return 0;
}

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

using i64 = long long;
using P = pair<i64, i64>;

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()

const string YES = "Yes";
const string NO = "No";

int main(){
    string s;
    cin >> s;
    bool flag = false;
    rep(i, 3) if(s[i] == '7') flag = true;
    if(flag) cout << YES << endl;
    else cout << NO << endl;
}


Measured memory_bytes: 3628
a = list(map(int,input().split()))
N = a[0]
M = a[1]
C = a[2]
A = [[] for i in range(N)]
B = list(map(int,input().split()))
ans = 0
for i in range(N):
    temp = list(map(int,input().split()))
    for j in range(M):
        A[i].append(temp[j])

for i in range(N):
    cnt = 0
    for j in range(M):
        cnt += A[i][j]*B[j]
    if cnt + C > 0:
        ans += 1
print(str(ans))

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

#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
int main(){
    int n;
    cin >> n;
    ll sum=0;
    for(int i=1; i<=n; i++){
        if(i%3!=0 && i%5!=0) sum+=i;
    }
    cout << sum << endl;
}


Measured memory_bytes: 3620
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ld long double
#define ll long long
//#define int ll
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
int32_t main(){
	boost;
	int n;
	cin>>n;
	cout<<n*n;
	return 0;
}
//long long
//array bounds
//special cases
//binary search

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

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int a[501][501];
int s[501][501];

int main(){
    int n,m,q;
    cin >> n >> m >> q;
    for(int i=0;i<m;i++){
        int l,r;
        cin >> l >>r;
        a[l][r]++;
    }
    for(int i=0;i<=n;i++){
        for(int j=i;j<=n;j++){
            for(int k=i;k<=j;k++){
                for(int l=i;l<=j;l++){
                    s[i][j] += a[k][l];
                }
            }
        }
    }
    for(int i=0;i<q;i++){
        int p,q;
        cin >> p >> q;
        cout << s[p][q] << "\n";
    }
    return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

ull N, ans;
int main(){
    scanf("%llu", &N);
    if(N%2==0 && N!= 0){
        ull count = 0;
        for (ull i = 5LL; N/i >= 1; i*=5LL){
            count += (N/i);
        }
        ull subtr = 0;
        ull curpow = 5;
        while(curpow <= N){
            subtr += ((N+curpow)/(2LL*curpow));
            curpow*=5LL;
        }
        count -=subtr;
        printf("%llu\n", count);
    } else{
        printf("0\n");
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n;
    cin>>n;
    ll t;
    cin>>t;
    ll sum=0;
    int ma=0;
    rep(i,n){
        int x;cin>>x;
        ma = max(ma,x);
        sum+=x;
        if(sum>t){
            cout<<1<<endl;
        }
        else cout<<2+(t-sum)/ma<<endl;
    }
    return 0;
}


Measured memory_bytes: 3100
#define ll long long int
#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
void solve(){
    int n, w;
    cin >> n >> w;
    vector<vector<ll>> dp(n+1, vector<ll>(w+1, 0));
    vector<ll> weight(n+1, 0), val(n+1, 0);
    for(int i=1; i<=n; i++){
        cin >> weight[i];
        cin >> val[i];
    }
    ll mx = INT_MIN;
    for(int i=1; i<=n; i++){
        for(int j=1; j<=w; j++){
            if(j-weight[i] < 0){dp[i][j] = dp[i-1][j];}
            else{
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-weight[i]]+val[i]);
            }
            mx = max(mx, dp[i][j]);
            // cout << dp[i][j] << " ";
        }
        // cout << "\n";
    }
    cout << mx;
}

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


Measured memory_bytes: 83156
#include <map>
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;



int main(){
  int h,w,n = 0;
  int ans = 0;
  int ans1 = 0;
  cin >> h >> w >> n;
  ans = max(h,w);
  if(n % ans == 0){
    ans1 = n / ans;
    cout << ans1;
  }
  else{
    ans1 = (n / ans) + 1;
    cout << ans1;
  }

}




Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    string s;
    cin >> s;
    bool g_success = false;
    for (char ch = 'a'; ch <= 'z'; ch++)
    {
        bool success = true;
        for (auto c : s)
        {
            if (c == ch)
            {
                success = false;
                break;
            }
        }
        if (success)
        {
            cout << ch << endl;
            g_success = true;
            break;
        }
    }
    if (!g_success)
    {
        cout << "None" << endl;
    }
}


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

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

const int INF = 114514810;
int n, ma, mb;
vector<int> a, b, c;

int dp[44][444][444];

int rec(int i, int wa, int wb) {
    int &r = dp[i][wa][wb];
    if (r < INF) return r;
    if (i == n) {
        if (wa * mb != wb * ma || wa == 0 || wb == 0) return r = INF - 1;
        return r = 0;
    }
    return r = min(rec(i + 1, wa + a[i], wb + b[i]) + c[i], rec(i + 1, wa, wb));
}

int main() {
    cin >> n >> ma >> mb;
    a.resize(n); b.resize(n); c.resize(n);
    rep(i, n) cin >> a[i] >> b[i] >> c[i];

    rep(i, 44) rep(j, 444) rep(k, 444) dp[i][j][k] = INF;
    int ans = rec(0, 0, 0);
    cout << (ans == INF - 1 ? -1 : ans) << endl;

    return 0;
}

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

int main() {
	 ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    
    ll n;
    cin>>n;
    
    ll a[n];
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    
    ll sum=a[n-1];
    
    ll x=n-2;
    if(x>0)
    {
        for(ll i=n-2;i>=0;i--)
        {
            sum+=(a[i]);
            x--;
            if(x<=0)
            {
                break;
            }
            sum+=(a[i]);
             x--;
            if(x<=0)
            {
                break;
            }
        }
    }
    cout<<sum<<endl;
    
    
	return 0;
}


Measured memory_bytes: 5196
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        if (n + m == 15) {
            System.out.println("+");
        } else if (n * m == 15) {
            System.out.println("*");
        } else {
            System.out.println("x");
        }
    }    
}


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

using namespace std;

typedef long long ll;

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

	int n;
	ll k;
	cin >> n >> k;

	vector<ll> a(n);
	rep(i, n) cin >> a[i];

	vector<ll> s(n+1, 0);
	rep(i, n) s[i+1] = (s[i] + (a[i] - 1)) % k;
	
	map<ll, ll> mp;
	mp[s[0]] = 1;

	ll ans = 0;
	for(int i = 0; i < n; i++){
		if(i+1 >= k) mp[s[i+1-k]]--;
		
		if(mp.count(s[i+1]) > 0){
			ans += mp[s[i+1]];
		}else{
			mp[s[i+1]] = 0;
		}
		mp[s[i+1]]++;
	}

	cout << ans << endl;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=3e5+20;
const double eps=1e-10;
//题意:两个人A,B都有string,长度为n,从A开始,每次轮流从中取出一个,A想让字典序小,B想让字典序尽量大,问最后组成长度为n的string?
//n/2轮,A肯定从前n/2小选,B肯定从前n/2大选
//情况1:如果a最小比b最大还小,则b肯定先用最小的占高位
//情况1:如果a最小比b最大还大,则a用最大的占领最低位 
ll a,b,c,sum[N];
int main()
{
	int n;
	ll k;
	while(cin>>n>>k)
	{
		memset(sum,0,sizeof(sum));
		while(n--)
		{
			int u,v;
			cin>>u>>v;
			sum[u]+=v;
		}
		//sum[i]有多少个i
		for(int i=1;i<=100000;i++)
		{
			k-=sum[i];
			if(k<=0)
			{
				cout<<i<<endl;
				break;	
			}	
		} 
		
	} 
	
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <bitset>
#include <fstream>

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair <int, int>
#define pll pair <long long, long long>
#define vi vector <int>
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

int n, a, x, y;

bool check()
{
	if(2 * x>= n - 1)
		return true;
	if(2 * x + y >= n)
		return true;
	return false;
}

int main()
{
	ios:: sync_with_stdio(false);
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		cin >> a;
		if(a % 4 == 0)
			x++;
		else
			if(a % 2 == 0)
				y++;
	}
	if(check())
		cout << "Yes";
	else
		cout << "No";
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18,MOD = 1e9 + 7;
const int INT_INF = 1e9,INT_MOD=1e9+7;
#define rep(i, N) for(ll i = 0; i < N; i++)
#define REP(i, n) for(int i = 0; i <= n; i++)
#define rrep(i,n) for(int i=n;i>0;i--)
#define RREP(i,n) for(int i=n;i>=0;i--)
typedef pair<int, int> Pi;
typedef pair<double, double> P;
signed main(){
    int a,b;cin>>a>>b;
    if(a<10 and b<10) cout<<a*b<<endl;
    else cout<<"-1"<<endl;
    return 0;
}

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

using namespace std;

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

typedef pair<int,int> pii;
#define x first
#define y second

const int D=365,A=26;

int d;
int c[A],s[D][A],last[A];

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

    cin>>d;
    for(int j=0;j<A;j++)
        cin>>c[j],
        last[j]=-1;
    for(int i=0;i<d;i++)
        for(int j=0;j<A;j++)
            cin>>s[i][j];
    for(int i=0;i<d;i++)
    {
        int best=0;
        for(int j=0;j<A;j++)
            if(s[i][j]+c[j]*(i-last[j])*min(A,d-i)>
               s[i][best]+c[best]*(i-last[best])*min(A,d-i))
                best=j;
        last[best]=i;
        cout<<best+1<<"\n";
    }
}


Measured memory_bytes: 3700
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <stack>
#include <string>
#include <math.h>
#define MAX 16777216//pow(4,12)
using namespace std;
//常に心してかかれ
//簡単なことを簡単にできるように練習する
//びっくりするくらいつまらないことで詰まってることも多い
//focus on
//度正直に

bool dct[MAX+1];

int fourToTen(string key){
	string::iterator itr;
	int number=0;
	itr = key.begin();
	for(int i=0;;i++){

		if(itr == key.end())//end関数は、最後の要素の１つ後ろを参照するイテレータを返します!
			return number;

		if(*itr == 'A'){
			number+=1*(int)pow((double)4,(double)i);
		}else if(*itr == 'C'){
			number+=2*(int)pow((double)4,(double)i);
		}else if(*itr == 'G'){
			number+=3*(int)pow((double)4,(double)i);
		}else if(*itr == 'T'){
			number+=4*(int)pow((double)4,(double)i);
		}else
			cout <<"error" <<endl;

		itr++;
	}
}

bool find(string key){
	if(dct[fourToTen(key)] == true)
		return true;
	else
		return false;
}

void insert(string key){
	dct[fourToTen(key)] = true;
}



int main(){
	/*A→0,C→1，G→2，T→3と対応させてみると
	条件は「4進数で0?333...3までに対するハッシュ」となる*/

	/*ポイント:AとAAを区別できてるか？*/

	int numinput;
	string command,key;

	for(int i=0;i<MAX;i++){
		dct[i] = false;
	}
	
	//cout <<fourToTen("AACC");//動作確認用80

	cin >>numinput;
	for(int i=0;i<numinput;i++){
		cin >>command;
		cin >>key;
		if(command == "find"){
			if(find(key))
				cout <<"yes" <<endl;
			else
				cout <<"no" <<endl;
		}else if(command =="insert"){
			insert(key);
		}
	}
	return 0;
}

/*混乱して間違っている例
#define MAX pow(4,13)
int fourToTen(string key){
	string::iterator itr;
	int number=0;
	itr = key.begin();
	for(int i=0;;i++){

		if(itr == key.end())//end関数は、最後の要素の１つ後ろを参照するイテレータを返します!
			return number;

		if(*itr == 'A'){
			number+=1*(int)pow((double)4,(double)i);
		}else if(*itr == 'C'){
			number+=2*(int)pow((double)4,(double)i);
		}else if(*itr == 'G'){
			number+=2*(int)pow((double)4,(double)i);
		}else if(*itr == 'T'){
			number+=3*(int)pow((double)4,(double)i);
		}else
			cout <<"error" <<endl;

		itr++;
	}
}
*/

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n0,n) for(int i=n0;i<n;i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)
const long long INF = 1e10;
const int MOD = (int)1e9+7;
const double EPS = 1e-9;
typedef long long ll;
typedef long li;
#define pb push_back
#define mp make_pair

signed main (){
  ll n,m,l;
  cin >> n >> m >> l ;

  ll wf1[n][n], wf2[n][n];
  rep(i,n) {
    rep(j,n) {
      if (i == j) wf1[i][i] = wf2[i][j] = 0;
      else wf1[i][j] = wf2[i][j] = INF;
    }
  }
  ll a,b,c;
  rep(i, m) {
    cin >> a >> b >> c ;
    wf1[a-1][b-1] = wf1[b-1][a-1] = c;
  }
  rep(i,n){
    rep(j,n) {
      rep(k,n) {
        if (j==k || wf1[j][k] <= wf1[j][i] + wf1[i][k]) continue;
        wf1[j][k] = wf1[k][j] = wf1[j][i] + wf1[i][k];
      }
    }
  }
  rep(i,n) {
    rep(j,n) {
      if (wf1[i][j] <= l) wf2[i][j] = wf2[j][i] = 1;
    }
  }
  rep(i,n){
    rep(j,n) {
      rep(k,n) {
        if (j==k || wf2[j][k] <= wf2[j][i] + wf2[i][k]) continue;
        wf2[j][k] = wf2[k][j] = wf2[j][i] + wf2[i][k];
      }
    }
  }
  ll q;
  cin >> q;
  rep(i, q) {
    cin >> a >> b;
    if (wf2[a-1][b-1] >= INF) cout << -1 << endl;
    else cout << wf2[a-1][b-1] -1 << endl;
  }
  return 0;
}


Measured memory_bytes: 1920
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main(void)
{
	int a[3],i, j;
	for (i = 0; i <= 2; i++)
	{
		scanf("%d", &a[i]);
	}
	sort(a, a + 3);
	for (i = 0; i <= 2; i++)
	{
		if (i == 2)
		{ 
			printf("%d\n", a[i]); 
		}
		else
		{
			printf("%d ", a[i]);
		}
	}
		return 0;
}


Measured memory_bytes: 3204
x,k,d=gets.split.map(&:to_i)

n=0
if k*d<x.abs
    puts x.abs-k*d
else
    n=x.abs/d
    if (d-x.abs%d)<x.abs%d
        n+=1
    end
    if (k-n)%2==0
        puts (x.abs-n*d).abs
    else
        puts d-(x.abs-n*d).abs
    end
end


Measured memory_bytes: 14264
#include <iostream>
using namespace std;
using ll = long long;

int main(){
    ll x; cin >> x;
    ll y = 100.0;
    int year;
    for(year = 0; ; year++){
        if(y >= x) break;
        y *= 1.01;
    }
    cout << year;
    return 0;
}

Measured memory_bytes: 3684
N = int(input())
A = list(map(int, input().split()))

ans = [0 for _ in range(N)]
for i, a in enumerate(A):
    ans[i] = [i+1, a]

ans.sort(key=lambda x: x[1])

ans2 = [x[0] for x in ans]
print(*ans2)

Measured memory_bytes: 23616
#include<iostream>
#include<string>
using namespace std;
int main(){
	string a;
	cin>>a;
	if(a[0]=='Y'&&a[1]=='A'&&a[2]=='K'&&a[3]=='I'){
		cout<<"Yes\n";
	}
	else cout<<"No\n";
	return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		Integer[] ary = new Integer[n];
		int total = 0;
		for(int i=0; i<n; i++){
			ary[i] = sc.nextInt();
			total += ary[i];
		}
		Arrays.sort(ary, Comparator.reverseOrder());
		if(ary[m-1] < total/(4.0*m)){
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}

	}
}


Measured memory_bytes: 22612
#include <iostream>
#include <cmath>

using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    int dig=to_string(b).length();
    a=a*pow(10,dig)+b;
//    cout << a <<"\n";
    if(a == (int)sqrt(a)*(int)sqrt(a)) cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<bitset>
#include<stack>
#include<cctype>
#define key_value (ch[ch[root][1]][0])
#define PR(x) cout<<#x<<": "<<x<<endl;
using namespace std;
typedef long long ll;
const double eps = 1e-4;
const int mod = 1e9+7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 3e5+7;
const int maxm = 1e6+7;
const double pi = acos(-1.0);

int main(){
	int cnt=0;
	int n; cin>>n;
	while(n){
		n>>=1;
		cnt++;
	}
	printf("%d\n",(1<<(cnt-1)));
} 

Measured memory_bytes: 256
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn main() {
    let n: usize = read_line().trim().parse().unwrap();
    let mut a: Vec<u64> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let mut memo: Vec<u64> = vec![0; n+1];

    let mut tmp = 0u64;
    for i in 0..n {
        tmp += a[i];
        memo[i+1] = tmp;
    }

    let mut ans = memo[n];
    for i in 2..n-1 {
        let mut min1 = 0;
        let mut max1 = memo[i];
        let mut l = 0;
        let mut r = i;

        while r-l > 1 {
            let mid = (l+r)/2;
            let lsum = memo[mid];
            let rsum = memo[i] - memo[mid];

            min1 = cmp::max(min1, cmp::min(lsum, rsum));
            max1 = cmp::min(max1, cmp::max(lsum, rsum));

            if lsum > rsum {
                r = mid;
            } else {
                l = mid;
            }
        }
        
        let mut min2 = 0;
        let mut max2 = memo[n] - memo[i];

        l = i;
        r = n;
        
        while r-l > 1 {
            let mid = (l+r)/2;
            let lsum = memo[mid] - memo[i];
            let rsum = memo[n] - memo[mid];

            min2 = cmp::max(min2, cmp::min(lsum, rsum));
            max2 = cmp::min(max2, cmp::max(lsum, rsum));

            if lsum > rsum {
                r = mid;
            } else {
                l = mid;
            }
        }
        ans = cmp::min(ans, cmp::max(max2, max1) - cmp::min(min1, min2));
    }

    println!("{}", ans);
}


Measured memory_bytes: 10492