akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef pair <int, int> ii;
typedef long long ll;

const int Maxn = 100005;
const ll Inf = 4000000000000000000ll;

int n, m;
vector <ii> neigh[Maxn];
bool was[Maxn][2];
ll has[Maxn][2];

bool Good(int v, int f, ll val)
{
	if (was[v][f]) return has[v][f] == val;
	was[v][f] = true; has[v][f] = val;
	for (int i = 0; i < neigh[v].size(); i++) {
		ii u = neigh[v][i];
		if (!Good(u.first, 1 - f, u.second - val))
			return false;
	}
	return true;
}

int main()
{
	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; i++) {
		int a, b, c; scanf("%d %d %d", &a, &b, &c);
		neigh[a].push_back(ii(b, c));
		neigh[b].push_back(ii(a, c));
	}
	if (!Good(1, 0, 0)) { printf("0\n"); return 0; }
	bool found = false;
	ll X;
	for (int i = 1; i <= n; i++)
		if (was[i][0] && was[i][1]) {
			ll x2 = has[i][1] - has[i][0];
			if (x2 % 2) { printf("0\n"); return 0; }
			X = x2 / 2; found = true; break;
		}
	if (found) {
		for (int i = 1; i <= n; i++)
			if (was[i][0] && has[i][0] + X <= 0 ||
				was[i][1] && has[i][1] - X <= 0 ||
				was[i][0] && was[i][1] && has[i][0] + X != has[i][1] - X) { printf("0\n"); return 0; }
		printf("1\n"); return 0;
	}
	ll lef = -Inf, rig = Inf;
	for (int i = 1; i <= n; i++) {
		if (was[i][0]) lef = max(lef, -has[i][0] + 1);
		if (was[i][1]) rig = min(rig, has[i][1] - 1);
	}
	ll res = rig - lef + 1;
	if (res < 0) res = 0;
	cout << res << endl; 
	return 0;
}

Measured memory_bytes: 14592
#include<stdio.h>
int x[51];
int y[51];
int main(){
	int a;
	scanf("%d",&a);
	if(a%2){
		printf("NA\n");
		return 0;
	}
	for(int i=0;i<a;i++){
		scanf("%d%d",x+i,y+i);
	}
	x[a]=x[0];
	y[a]=y[0];
	bool ok=true;
	for(int i=0;i<a/2;i++){
		int ax=x[i+1]-x[i];
		int ay=y[i+1]-y[i];
		int bx=x[i+a/2+1]-x[i+a/2];
		int by=y[i+a/2+1]-y[i+a/2];
		if(ax+bx||ay+by)ok=false;
	}
	if(!ok)printf("NA\n");
	else{
		double X=0;
		double Y=0;
		for(int i=0;i<a;i++){
			X+=x[i];
			Y+=y[i];
		}
		printf("%f %f\n",X/a,Y/a);
	}
}

Measured memory_bytes: 1060
#include <algorithm>
#include <cstdio>
#include <cstring>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
	#define debug(...) printf(__VA_ARGS__)
#else
	#define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;

#define N 101

char grid[N][N];

int dp[N][N];

int main() {
	int h, w;
	scanf("%d%d", &h, &w);
	for(int i=0; i<h; i++)
		scanf("%s", grid[i]);
	memset(dp, 0, sizeof(dp));
	for(int i=0; i<h; i++)
		for(int j=0; j<w; j++) {
			if(i==0 and j==0) {
				dp[i][j] = (grid[i][j] == '#');
				continue;
			}
			dp[i][j] = w*h;
			if(i>0)
				dp[i][j] = min(dp[i][j], dp[i-1][j]+(grid[i][j] == '#' and grid[i-1][j] == '.'));
			if(j>0)
				dp[i][j] = min(dp[i][j], dp[i][j-1]+(grid[i][j] == '#' and grid[i][j-1] == '.'));
		}
	printf("%d\n", dp[h-1][w-1]);
	return 0;
}


Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  ll h,n,s=0;
  cin >> h >> n;
  ll a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
    s += a[i];
  }
  if(s>=h) cout <<"Yes\n";
  else cout<<"No\n";
}


Measured memory_bytes: 1024
main = do
  inputs <- map(read::[Char]->Int) <$> words <$> getLine
  let a = head inputs
      b = last inputs
  putStr $ judge a b

judge::Int->Int->String
judge x y | x <= 0 && y >= 0 = "Zero"
          | x > 0 && y > 0 = "Positive"
          | odd (y - x) = "Positive"
          | otherwise = "Negative"


Measured memory_bytes: 508
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2　//1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) (max(x,y)-min(x,y))
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int,int>;
typedef vector<int> vit;
 
signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int a, b, c;
  cin >> a >> b >> c;
  cout << c << " "<<a << " "<< b << '\n';
  return 0;
}


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

using namespace std;

const int kMax = 200000;
bool used[kMax];

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

  vector<pair<int, int>> even;
  vector<pair<int, int>> odd;
  for (int i = 0; i < M; ++i) {
    if (i % 2 == 0) {
      if (even.empty()) {
        even.push_back(make_pair(0, 1));
      } else {
        pair<int, int> last = even.back();
        even.push_back(make_pair(last.first - 1, last.second + 1));
      }
    } else {
      if (odd.empty()) {
        odd.push_back(make_pair(0, 2));
      } else {
        pair<int, int> last = odd.back();
        odd.push_back(make_pair(last.first - 1, last.second + 1));
      }
    }
  }
  for (int i = 0; i < M; ++i) {
    if (i % 2 == 0) {
      pair<int, int> p = even[i / 2];
      int even_min = even.back().first;
      cout << (p.first - even_min + 1) << " " << (p.second - even_min + 1) << endl;
    } else {
      pair<int ,int> p = odd[i / 2];
      int odd_min = odd.back().first;
      int even_max = even.back().second - even.back().first;
      int adjust = -odd_min + even_max + 1;
      cout << (p.first + adjust + 1) << " " << (p.second + adjust + 1) << endl;
    }
  }
}

Measured memory_bytes: 3988
#include <bits/stdc++.h>
#define range(i, l, r) for(int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

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

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    string S;
    cin >> S;
    lint ans = 0;
    range(i, 0, S.size()) {
        char t = S.at(i);
        char a = (i % 2 == 0 ? 'g' : 'p');
        if (t != a and a > t) ans += 1;
        else if (t != a and a < t) ans -= 1;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 512
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	static final int MOD = (int)1e9+7;
	int N,M;
	long[] x,y;

	public void solve() {
		N = nextInt();
		M = nextInt();

		x = new long[N];
		y = new long[M];

		for(int i = 0;i < N;i++){
			x[i] = nextInt();
		}

		for(int i = 0;i < M;i++){
			y[i] = nextInt();
		}

		long xsum = 0L,ysum = 0L;

		for(int i = 0;i < N;i++){
			xsum += (x[i] * i) - (x[i] * (N-i-1));
			xsum %= MOD;
		}

		for(int i = 0;i < M;i++){
			ysum += (y[i] * i) - (y[i] * (M-i-1));
			ysum %= MOD;
		}

		out.println(xsum * ysum % MOD);
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

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

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

Measured memory_bytes: 45192
#include<bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
#define fil(x) memset(x, 0, sizeof(x))
#define fillb(x) memset(x,false,sizeof(x))
#define fillm(x) memset(x, -1, sizeof(x))
#define mp make_pair
#define pll pair<int, int>
#define pf printf
#define sf scanf
#define all(x) x.begin(),x.end()
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<n;i++)
#define fof(i,a,b) for(int i=a;i<=b;i++)
#define off(i,a,b) for(int i=a;i>=b;i--)
#define of(i,n) for(int i=n-1;i>=0;i--)
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define nl endl

typedef unsigned long long lll;
typedef long long ll;
int knigtx8[] = {2, 2, -2, -2, 1, 1, -1, -1}; ///knight move in chess
int knigty8[] = {1, -1, 1, -1, 2, -2, 2, -2}; ///knight move in chess
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}; ///for 8 directions
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1}; ///for 8 directions
int dx4[] = {0, 0, 1, -1}; ///for 4 directions
int dy4[] = {1, -1, 0, 0}; ///for 4 directions
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}
ll pw(ll a, ll b)
{
    ll ans = 1;
    for(ll i = 1; i <= b; ++i)
        ans = (ans * a);
    return ans;
}
template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

int main()
{
    IOS;
    int n,x;
    cin>>x>>n;
    int a[n],ache[115];
    fil(ache);
    //int mn = 1000;
    vector<pair<int,int>>v;
    fo(i,n)
    {
        cin>>a[i];
        ache[a[i]]=1;
        //v.pb({abs(a[i]-x), a[i]});
    }
    fo(i,110)
    {
        if(!ache[i]){
            v.pb({abs(i-x), i});
        }
    }
    sort(all(v));
    cout<<v[0].second<<endl;
}

///Alhamdulillah


Measured memory_bytes: 3648
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <array>
#include <cassert>
#include <utility>
#include <vector>
#include <atcoder/all>

template <class InputIterator>
std::ostream& range_output(std::ostream& os_arg, InputIterator first_arg, InputIterator last_arg){ if(first_arg != last_arg){ do{ os_arg << *(first_arg++); if(first_arg == last_arg) break; os_arg << ' '; } while(true); }  return os_arg; }
template <class Tp> std::ostream& operator << (std::ostream& os_arg, const std::vector<Tp>& arr_arg){ return range_output(os_arg, arr_arg.cbegin(), arr_arg.cend()); }
template <class Tp, std::size_t Size> std::ostream& operator << (std::ostream& os_arg, const std::array<Tp, Size>& arr_arg){ return range_output(os_arg, arr_arg.cbegin(), arr_arg.cend()); }
template <class S, class T> std::ostream& operator << (std::ostream& os_arg, const std::pair<S, T>& pair_arg){ return os_arg << '(' << pair_arg.first << ", " << pair_arg.second << ')'; }

#ifndef ONLINE_JUDGE
    template <typename Head> void dump_out(Head head_arg){ std::cerr << head_arg << '\n'; }
    template <typename Head, typename... Tail>
    void dump_out(Head head_arg, Tail... tail_args){ std::cerr << head_arg << ", "; dump_out(tail_args...); }
    #define dump(...) do { std::cerr << "[in line " << __LINE__ << "] " << #__VA_ARGS__ << " : "; dump_out(__VA_ARGS__); } while(false)
#else
    #define dump(...) (void(0))
#endif

char S[50][55];

constexpr long long int inf = 1LL << 50;

int main(void){
    std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); 
    std::cout << std::fixed << std::setprecision(16);
    int n, k; std::cin >> n >> k;
    std::vector<std::vector<int>> A(n, std::vector<int>(n));
    for(auto& vec : A) for(auto& itr : vec) std::cin >> itr;
    atcoder::mcf_graph<int, long long int> graph(2 * n + 2);
    const int s = 0, t = 2 * n + 1;
    for(int i = 1; i <= n; ++i) graph.add_edge(s, i, k, 0);
    for(int i = n + 1; i <= 2 * n; ++i) graph.add_edge(i, t, k, 0);
    graph.add_edge(s, t, n * k, inf);

    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j){
            graph.add_edge(i + 1, j + 1 + n, 1, inf - A[i][j]);
        }
    }

    std::cout << inf * n * k - graph.flow(s, t, n * k).second << '\n';
    for(int i = 0; i < n; ++i) for(int j = 0; j < n; ++j) S[i][j] = '.';
    const auto v = graph.edges();
    for(const auto& e : v){
        if(not (1 <= e.from and e.from <= n and n + 1 <= e.to and e.to <= 2 * n) or e.flow == 0) continue;
        S[e.from - 1][e.to - n - 1] = 'X';
    }
    for(int i = 0; i < n; ++i) std::cout << S[i] << '\n';
    return 0;
}

Measured memory_bytes: 3884
/********************************************
 *Author*        :ZZZZone
 *Created Time*  : 日  3/25 21:57:53 2018
 * Ended  Time*  : 日  3/25 22:03:40 2018
*********************************************/

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <stack>
using namespace std;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

inline void OPEN(string s){
	freopen((s + ".in").c_str(), "r", stdin);
	freopen((s + ".out").c_str(), "w", stdout);
}

char a[105][105];
int A, B;

int main()
{
	//OPEN("D");
	scanf("%d %d", &A, &B);
	for(int i = 1; i <= 50; i++){
		for(int j = 1; j <= 100; j++){
			a[i][j] = '.';
			if((i&1) && (j&1) && B > 1){
				B--;
				a[i][j] = '#';
			}
		}
	}
	for(int i = 51; i <= 100; i++){
		for(int j = 1; j <= 100; j++){
			a[i][j] = '#';
			if((!(i&1)) &&(j&1) && A > 1){
				A--;
				a[i][j] = '.';
			}
		}
	}
	printf("100 100\n");
	for(int i = 1; i <= 100; i++){
		for(int j = 1; j <= 100; j++){
			printf("%c", a[i][j]);
		}
		cout << endl;
	}
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000000007
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);

int main() {
	// your code goes here
	long long int n,i,t=0;
	cin>>n;
	for(i=(long int)sqrt(n);;i--)
    {
      if(i*(n/i)==n )
      {
        t=n/i;
        break;
      }
    }
  	cout<<t+n/t-2;
	
	
   
	return 0;
}


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

#define MAX_V 10000

using namespace std;


struct vertex {
	vector<int> to;
	vector<int> from;
};

vertex vertices[MAX_V];

struct union_find {
	int group[MAX_V];
	union_find() {
		for (int i = 0; i < MAX_V; i++) group[i] = i;
	}
	int root(int k) {
		if (group[k] == k) return k;
		else return group[k] = root(group[k]);
	}
	bool same(int i, int j) {
		return root(i) == root(j);
	}

	void unite(int i, int j) {
		int x = root(i);
		int y = root(j);
		if (x != y) group[x] = y;
	}
};

union_find uf;
vector<int> order;
bool flag[MAX_V];

void forward(int i) {
	if (flag[i]) return;
	flag[i] = true;
	for (vector<int>::iterator itr = vertices[i].to.begin(); itr != vertices[i].to.end(); itr++) {
		forward(*itr);
	}
	order.push_back(i);
}

void backward(int i, int root) {
	if (!flag[i]) return;
	flag[i] = false;
	uf.unite(i, root);
	for (vector<int>::iterator itr = vertices[i].from.begin(); itr != vertices[i].from.end(); itr++) {
		backward(*itr, root);
	}
}

int main()
{
	int v, e, q;
	cin >> v >> e;
	for (int i = 0; i < e; i++) {
		int s, t;
		cin >> s >> t;
		vertices[s].to.push_back(t);
		vertices[t].from.push_back(s);
	}

	for (int i = 0; i < v; i++) {
		forward(i);
	}

	while (!order.empty()) {
		int v = order.back();
		order.pop_back();
		backward(v, v);
	}

	cin >> q;
	for (int i = 0; i < q; i++) {
		int u, v;
		cin >> u >> v;
		cout << (uf.same(u, v) ? 1 : 0) << endl;
	}

}

Measured memory_bytes: 4972
//
//  main.cpp
//  AC
//
//  Created by makinofuya on 2019/07/08.
//  Copyright © 2019 makinofuya. All rights reserved.
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <math.h>

typedef long long ll;
using namespace std;
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define out(s) cout << s << endl


int main(){
    string s;cin >> s;
    string ans="AC";
    if(s[0]!='A')ans="WA";
    int d=s.size();
    int cnt = 0;
    for(int i = 1; i < d; ++i){
        if(isupper(s[i])){
            if(i == 1 || i == d - 1 || s[i] != 'C'){
                ans = "WA";
            }
        cnt++;
        }
    }
    if(cnt != 1){
        ans = "WA";
    }
    cout << ans << endl;

    return 0;
}




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

using namespace std;

int main() {
  int K, S;
  scanf("%d %d", &K, &S);

  int ans = 0;
  for (int i = 0; i <= K; ++i) {
    for (int j = 0; j <= K; ++j) {
      int remain = S - (i + j);
      if (remain >= 0 && remain <= K) ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}


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

using namespace std;

int main(void){
	int n, x, bal = 0, plus, i;
	char ans[4];
	strcpy(ans,"YES");
	scanf("%d%*c",&n);
	for(i = 0;i < n;i++){
		if(getchar() == '('){
			plus = 1;
		}else{
			plus = -1;
		}
		scanf("%d%*c",&x);
		bal += plus * x;
		if(bal < 0){
			strcpy(ans,"NO");
		}
	}
	if(bal != 0){
		strcpy(ans,"NO");
	}
	printf("%s\n",ans);
	return 0;
}

Measured memory_bytes: 1016
#include<bits/stdc++.h>
using namespace std;
#define int unsigned long long
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define all(C) (C).begin(),(C).end()
const int MAX=10;
int n;
int d[MAX],v[MAX];

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

void solve(){
    rep(i,n){
        cin>>d[i]>>v[i];
        int g=gcd(d[i],v[i]);
        d[i]/=g;v[i]/=g;
    }
    int base=d[0];
    rep(i,n)base=lcm(base,d[i]);
    rep(i,n)v[i]*=(base/d[i]);
    base=v[0];
    rep(i,n)base=gcd(base,v[i]);
    rep(i,n)cout<<v[i]/base<<endl;
}
signed main(){
    cin.tie(0);ios_base::sync_with_stdio(0);
    while(cin>>n&&n)solve();
    return 0;
}

Measured memory_bytes: 1188
a, b, c= map(int,input().split())

if a > b:
    if a > c:
        if b > c:
            print(c,b,a)
        else:
            print(b,c,a)
    else:
        print(b,a,c)
else:
    if a > c:
        print(c,a,b)
    else:
        if b > c:
            print(a,c,b)
        else:
            print(a,b,c)


Measured memory_bytes: 5592
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)

struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(13);
    }
}INIT;

int n, m;
vector<LL> reward[101010];
priority_queue<LL> jobs;

int main(){
    cin >> n >> m;
    int a, b;
    REP(i, n){
        cin >> a >> b;
        reward[a].emplace_back(b);
    }
    LL ans = 0;
    REP(i, m + 1){
        for(auto job : reward[i])jobs.push(job);
        if(!jobs.empty()){
            ans += jobs.top();
            jobs.pop();
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5760
#include<stdio.h>
int main()
{
      int n,m;
      scanf("%d%d",&n,&m);
      int a[n],i;
      for(i=0;i<n;i++){
            scanf("%d",&a[i]);
      }
      int j,tm;
      for(i=0;i<n;i++){
            for(j=i+1;j<n;j++){
                  if(a[i]>a[j]){
                        tm=a[i];
                        a[i]=a[j];
                        a[j]=tm;
                  }
            }
      }
      int ans=0;
      for(i=0;i<m;i++){
            ans+=a[i];
      }
      printf("%d\n",ans);

      return 0;
}


Measured memory_bytes: 1736
n = gets.to_i
a = gets.split.map(&:to_i)

x = Array.new n
y = Array.new n

x[0] = a[0]
y[-1] = a[-1]
(1..n-1).each{|i| x[i] = a[i].gcd x[i-1]}
(0..n-2).reverse_each{|i|y[i] = a[i].gcd y[i+1]}

ret = (1..n-2).map{|i|x[i-1].gcd y[i+1]}.max
p [ret,x[n-2],y[1]].compact.max

Measured memory_bytes: 11788
num=input()
moji=num.split(" ")

if int(moji[0])==7 or int(moji[0])==5:
    pass
else:
    print("NO")

if int(moji[1])==7 or int(moji[1])==5:
	if int(moji[0])+int(moji[1])+int(moji[2])==17:
		print("YES")
	else:
		print("NO")
else:
	print("NO")

Measured memory_bytes: 3316
//==========================================
// ABC131c
//
// 2019/08/20
//==========================================

#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

int gcd(int a, int b)
{
  long long temp;
  if(a<b)
  {
    temp = a;
    a = b; 
    b = temp;
  }

  long long r;
  r = a%b;
  while (r!=0)
  {
    a = b;
    b = r;
    r = a%b;
  }

  return b;
}

int main(int argc, char* argv[])
{
  long long a, b, c, d;
  cin >> a >> b >> c >> d;

  long long ans;
  long long t1, t2, t3;
  ans = b -a + 1;
  t1 = b/c - (a-1)/c;
  t2 = b/d - (a-1)/d;
  long long lcm;
  lcm = c*d/gcd(c, d);
  t3 = b/lcm - (a-1)/lcm;
  ans = ans - t1 - t2 + t3; 

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static Scanner scanner;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int a=gi();
	    int b=gi();
	    //int c=gi();

	   
	    System.out.print(Math.max(a+b, Math.max(a-b, a*b)));

//        if ((x.charAt(0)==x.charAt(1) && x.charAt(2)==x.charAt(3) && x.charAt(0)!=x.charAt(2))
//        || (x.charAt(0)==x.charAt(2) && x.charAt(1)==x.charAt(3) && x.charAt(0)!=x.charAt(1))
//        || (x.charAt(0)==x.charAt(3) && x.charAt(2)==x.charAt(1) && x.charAt(0)!=x.charAt(2))) {
//        	System.out.print("Yes");
//        }else {
//        	System.out.print("No");
//        }


	}
	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35532
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cmath>

using namespace std;

int main(void){
    int N;
    vector <int> t, x, y;
    int sub;
    bool judge = true;
    
    t.push_back(0);
    x.push_back(0);
    y.push_back(0);
    
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> sub;
        t.push_back(sub);
        cin >> sub;
        x.push_back(sub);
        cin >> sub;
        y.push_back(sub);
    }
    
    for(int i = 0; i < N; i++){
        int a1 = abs(x[i + 1] - x[i]);
        int a2 = abs(y[i + 1] - y[i]);
        int a3 = t[i + 1] - t[i];
        
        if(a1 + a2 > a3){
            judge = false;
            break;
        }
        
        int cnt = a3;
        cnt -= a1 + a2;
        if(cnt % 2 != 0){
            judge = false;
            break;
        }
    }
    
    if(judge){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
}

Measured memory_bytes: 1644
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll n, k;
    cin >> n >> k;
    ll t = 0;
    ll s = 1;
    ll ans = 0;
    while (0 < n)
    {
        n /= k;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	ll N;
	cin>>N;
	vector<ll> a(N);
	ll ans = 0LL;
	rep(i,N){
		cin>>a[i];
		ans +=a[i];
	}	cout<<ans-N<<endl;
	return 0;
}

Measured memory_bytes: 256
/// Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

using namespace std;

const long long MOD = 1000000007;
#define SET(x) memset(x, 0, sizeof(x))
#define SET2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define SETBOOL(x) memset(x,false,sizeof(x))
#define CLR(x) memset(x, -1, sizeof(x))
#define mp make_pair
#define PII pair<int, int>
#define pf printf

#define sf scanf

#define ALL(x) x.begin(),x.end()
#define pb push_back

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define for0(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=n-1;i>=0;i--)
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define no1 __builtin_popcount
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long long ll;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}
double sq(double x) {return x*x;}

int main()

{
    IOS;
    //freopen("input.txt", "r", stdin);
     //freopen("output.txt", "w", stdout);
     int n,x,y;
     while(cin>>n>>x>>y){
        vector<int>edg[n+1];
        for(int i=1;i+1<=n;i++){
            edg[i].pb(i+1);
            edg[i+1].pb(i);
        }
     edg[x].pb(y);
     edg[y].pb(y);
     int arr[n+1];
     SET(arr);
     for(int i=1;i<=n;i++){
        int vis[n+1];
        SET(vis);
        int cost[n+1];
        SET(cost);
        queue<int>q;
        q.push(i);
        vis[i]=1;

        while(!q.empty()){
            int u=q.front();
            q.pop();
            for(int j=0;j<edg[u].size();j++){
                int v=edg[u][j];
                if(!vis[v]){
                    vis[v]=1;
                    q.push(v);
                    cost[v]=cost[u]+1;
                   // cout<<v<<" "<<cost[v]<<endl;
                    if(v>i) arr[cost[v]]++;
                }
            }
        }

     }
     for(int i=1;i<=n-1;i++)
    {
        cout<<arr[i]<<endl;
    }
     }

     return 0;

}
///Alhamdulillah


Measured memory_bytes: 384
n = int(input())
input_lis = list(map(int,input().split()))

input_lis.sort(reverse=True)
a,b = 0,0
for i in range(len(input_lis)):
    if i % 2 == 0:
        a += input_lis[i]
    else:
        b += input_lis[i]
        
print(a-b)

Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	LL n,qn;
    cin>>n>>qn;
    LL ans=(n-2)*(n-2);
    vii b(2,vi(n,n-2));
    vi mn(2,n-1);
    FOR(qi,0,qn){
        int t,x;
        cin>>t>>x;
        t--;x--;
        int o=1-t;
        if(x<mn[t]){
            FOR(i,x,mn[t]){
                b[t][i]=mn[o]-1;
            }
            mn[t]=x;
        }
        ans-=b[t][x];
        //cerr<<ans<<endl;


    }

    cout<<ans<<endl;
}


Measured memory_bytes: 5576
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		
		while(true){
		    String line = sc.nextLine();
		    
		    if (line.equals("0")){
		        break;
		    }
		    
		    char []nums = line.toCharArray();
		    int total = 0;
		    
		    for (char c: nums){
		        total += Character.getNumericValue(c);
		    } 
		    
		    System.out.println(total);
		}
	}
}


Measured memory_bytes: 26404
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<vector>
using namespace std;
int main() {
	int W, H, N;	cin >> W >> H >> N;
	vector<vector<int>> grid(H, vector<int>(W, 0));
	vector<int> x(N), y(N), a(N);
	for (int i = 0; i < N; ++i) {
		cin >> x[i] >> y[i] >> a[i];
	}
	for (int i = 0; i < N; ++i) {
		if (a[i] == 1) {
			for (int j = 0; j < H; ++j) {
				for (int k = 0; k < x[i]; ++k) {
					grid[j][k] = 1;
				}
			}
		}
		if (a[i] == 2) {
			for (int j = 0; j < H; ++j) {
				for (int k = x[i]; k < W; ++k) {
					grid[j][k] = 1;
				}
			}
		}
		if (a[i] == 3) {
			for (int j = 0; j < y[i]; ++j) {
				for (int k = 0; k < W; ++k) {
					grid[j][k] = 1;
				}
			}
		}
		if (a[i] == 4) {
			for (int j = y[i]; j < H; ++j) {
				for (int k = 0; k < W; ++k) {
					grid[j][k] = 1;
				}
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			if (grid[i][j] == 0) {
				++ans;
			}
		}
	}
	cout << ans << endl;
	cin >> W;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
# input = sys.stdin.readline
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
    n=ii()
    S=list(input())
    for s in S: print(chr(ord(s)+n-26) if ord(s)+n>90 else chr(ord(s)+n), end='')
    print()

if __name__ == "__main__":
    main()

Measured memory_bytes: 4596
using System;

namespace LevelA
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = Console.ReadLine();

            var _x = x[0]-'0';
            var __x = x[1]-'0';
            var ___x = x[2]-'0';

            if (_x % 7 == 0 || (__x!=0&& __x%7==0)||(___x!=0&&___x%7==0))
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 25880
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; ++i)
#define repe(i, n) for(int i=0; i <= n; ++i)
#define repr(i, n) for(int i=n-1; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define PI 3.14159265359
using namespace std;
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 <class T> using V=vector<T>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007;
const ll MAX = 510000;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
vector<int> Eratosthenes(const int N)
{
    vector<bool> is_prime(N+1, true);
    vector<int> P;
    for(int i=2; i<=N; i++) {
        if (is_prime[i]) {
            for(int j=2*i; j<=N; j+=i) {
                is_prime[j] = false;
            }
            P.emplace_back(i);
        }
    }
    return P;
}
 
int main() {
    ll n,T;
    cin >> n >> T;
    vector<ll> t(n);
    ll res = 0;
    rep(i,n) {
        cin >> t[i];
    }
    rep(i,n) {
        if (i>0) {
            if (abs(t[i]-t[i-1])<T) {
                res += abs(t[i]-t[i-1]);
            } else {
                res += T;
            }
        }
    }
    res += T;
    cout << res << "\n";
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
    int n,l,i;

    cin >> n >> l;

    vector<string>s(n);

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

    sort(s.begin(),s.end());

    for(i=0; i<n; i++)
        cout << s[i];

    cout << endl;
}


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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::bitset;

#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define reps(i,s,e) for(int i=s; i<(int)e; i++)
#define coutd(i) cout << std::fixed << std::setprecision(i)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

template<class T>
using Set = std::set<T>;
template<class T, class U>
using Map = std::map<T, U>;

template<class T>
using Graph = vector<vector<T>>;

const int INT_BIG = 1<<28;

int main() {
    int N;
    cin >> N;
    vll cats(N);
    vll catxor(N);
    ll maxxor = 0;
    rep(i, N) {
        cin >> catxor[i];
        if (maxxor < catxor[i]) {
            maxxor = catxor[i];
        }
    }

    // int now = catxor[0];
    ll sumxor = 0;
    reps(i, 1, N) {
        ll nextxor = catxor[i-1] ^ catxor[i];
        cats[i] = nextxor ^ cats[i-1];
        sumxor ^= cats[i];
    }
    rep(i, N) {
        // cout << cats[i]
        cout << (cats[i] ^ sumxor ^ catxor[0]);
        if (i != N - 1 ) {
            cout << " ";
        }
    }
    cout << endl;
}

Measured memory_bytes: 6412
MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)

def main():
    s,w  =map(int,input().split())
    if s <= w:
        print('unsafe')
    else:
        print('safe') 
if __name__ == '__main__':
    main()

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

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  reverse(ALL(a));
  repz(i, 1, n) {
    if (a[i] > a[i - 1]) a[i]--;
    if (a[i] > a[i - 1]) {
      PNO return 0;
    }
  }
  PYES return 0;
}


Measured memory_bytes: 640
private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints

fun max(a: Int, b: Int): Int = Math.max(a, b)
fun min(a: Int, b: Int): Int = Math.min(a, b)

fun main(args: Array<String>) {
    val (n,m) =  readInts()

    var (ansL,ansR) = readInts()

    for (i in 1 until m){
        val (l,r) = readInts()
        ansL = max(l,ansL)
        ansR = min(r,ansR)
    }

    if (min(n,ansR) - ansL < 0){
        println(0)
    }else {
        println(min(n,ansR) - ansL + 1)
    }
}

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

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

    ll n;
    cin >> n;

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

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());

    ll res = 0;
    rep(i, n){
        ll mid = b[i];
        int l = 0;
        int r = n;
        
        while(l < r){
            int m = (l + r) / 2;
            
            if(a[m] < mid) l = m+1;
            else r = m;
        }
        ll upper = l;

        l = 0;
        r = n;
        while(l < r){
            int m = (l + r) / 2;

            if(mid < c[m]) r = m;
            else l = m+1;
        }
        ll lower = n - l;
        
        res += upper * lower;
    }

    cout << res << endl;

    return 0;
}

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

typedef long long lint;
typedef unsigned long long ulint;
const int MOD=1000000007;

int main(){
    string S;
    cin >> S;
    while(S!=""){
        if(S.size()<5){
            cout << "NO" << endl;
            return 0;
        }
        string last="";
        last+=S[S.size()-5];
        last+=S[S.size()-4];
        last+=S[S.size()-3];
        last+=S[S.size()-2];
        last+=S[S.size()-1];

        if(last=="dream" || last=="erase"){
            S=S.substr(0,S.size()-5);
        }else if(last=="eamer"){
            S=S.substr(0,S.size()-2);
        }else if(last=="raser"){
            S=S.substr(0,S.size()-1);
        }else{
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
#define int ll
#define INF LLONG_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[100100];

signed main() {
  int N; cin >> N;
  int m = INF;
  for (int i = 0; i < 5; i++) {
    int a; cin >> a;
    m = min(m, a);
  }

  cout << (N+m-1)/m + 5 - 1 <<endl;
}


Measured memory_bytes: 256
s = list(i for i in input())
x,y = int(s[0] + s[1]),int(s[2] + s[3])
if x < 13 and x > 0 and y < 13 and y > 0:
  print('AMBIGUOUS')
elif (x >= 13 or x == 0) and y < 13 and y > 0:
  print('YYMM')
elif x < 13 and x > 0 and (y >= 13 or y == 0):
  print('MMYY')
else:
  print('NA')


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

int a, b;

main()
{
    cin >> a >> b;
    if (a > 0 || ((b - a + 1) % 2 == 0 && b < 0))
        cout << "Positive" << endl;
    else if (a <= 0 && b >= 0)
        cout << "Zero" << endl;
    else
        cout << "Negative" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int gcd(int x,int y);
int main()
{
  int x,y;

  scanf("%d",&x);
  scanf("%d",&y);
  printf("%d\n",gcd(x,y));

  return 0;
}
gcd(int x, int y){
  int r,tmp;
  if (x < y){
    tmp = x;
    x = y;
    y = tmp;
  }
    while (y > 0){
    r = x % y;
    x = y;
    y = r;
  }
  return x;
}

Measured memory_bytes: 592
#pragma GCC optimize ("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define FORD(i, a, b) for (int i=(a); i>(b); i--)
#define PPC(x) __builtin_popcount(x)
#define MSB(x) (31 - __builtin_clz(x))
#define SZ(x) ((int)(x).size())
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ithBit(m, i) ((m) >> (i) & 1)
#define ft first
#define sd second
#define kw(a) ((a) * (a))
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;

const int maxN = 1 << 18;
const long long INF = 1000000000000ll;

template <class T1, class T2> inline void remin(T1& a, T2 b)	{   a = min(a, (T1)b);  }

unordered_map <long long, long long> M;
long long cost[6], d;

long long go(long long n)
{
	auto it = M.find(n);
	if (it != M.end())
		return it->sd;
		
	long long ret = INF;
		
	FOR(i, 0, 5) for (int j : {2, 3, 5}) if (i < j)
	{
		long long dx = cost[j] + d*i;
		
		long long u = n - i;
		if (u % j == 0)
			remin(ret, go(u/j) + dx);
		u = n + i;
		if (u % j == 0)
			remin(ret, go(u/j) + dx);
	}
	
	if (ret / d >= n)
		ret = d * n;
	
	return M[n] = ret;
}

void solve()
{
	long long n;
	scanf ("%lld%lld%lld%lld%lld", &n, cost+2, cost+3, cost+5, &d);
	M.clear();
	FOR(i, 1, 6)
		M[-i] = INF;
	M[0] = 0;
	M[1] = d;
	printf("%lld\n", go(n));	
}

int main()
{
	int t = 1;
	scanf ("%d", &t);
	while (t--)
		solve();
	return 0;
}





Measured memory_bytes: 4280
# coding: utf-8
# Your code here!

x = int(input())
ans = 1
for a in range(1,x+1):
    for b in range(2,11):
        c = a ** b 
        if c > x:
            break
        else:
            #print(ans,c)
            ans = max(c,ans)
print(ans)

Measured memory_bytes: 2940