akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
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; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int H,W,K;
vector<vector<int>> ans;
vector<string> s;

void left(int p,int q){
    for(int i = q+1;i < W;i++){
        if(ans[p][i] == 0)ans[p][i] = ans[p][i-1];
    }
}

void right(int p,int q){
    for(int i = q-1;i >= 0;i--){
        if(ans[p][i] == 0)ans[p][i] = ans[p][i+1];
    }
}

void up(int p,int q){
    for(int i = p-1;i >= 0;i--){
        if(ans[i][q] == 0)ans[i][q] = ans[i+1][q];
    }
}

void down(int p,int q){
    for(int i = p+1;i < H;i++){
        if(ans[i][q] == 0)ans[i][q] = ans[i-1][q];
    }
}

int main() {
    cin >> H >> W >> K;
    s.resize(H);rep(i,H)cin >> s[i];

    ans.resize(H,vector<int>(W,0));

    int ind = 1;
    rep(i,H)rep(j,W){
        if(s[i][j] == '#'){
            ans[i][j] = ind;
            ind++;
        }
    }

    rep(i,H)left(i,0);

    rep(i,H)right(i,W-1);

    rep(j,W)up(H-1,j);

    rep(j,W)down(0,j);
    
    rep(i,H){
        rep(j,W){
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 1280
#include <algorithm>
#include <bitset>
#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
#include<iomanip>
namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
using lll = boost::multiprecision::cpp_int;
using ll = long long;
#define FOR(i, N) for(ll i = 0; i < N; ++i)

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
// using int = ll;
ll gcd(ll m, ll n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
ll combi(ll n, ll k) {
    ll r = 1, rr = 1;
    for(ll i = 0; i < k; ++i) {
        r *= (n - i);
        rr *= (i + 1);
        // r %= 1000000007;
        // rr %= 1000000007;
    }
    r /= rr;
    // r %= 1000000007;
    return r;
}
int main(){
  ll N;
  cin>>N;
  vector<ll> A(81,0),B(81,0);
  FOR(i,N){
    string s = std::to_string(i+1);
    char a = s.front();
    char b = s.back();
    if(b=='0')continue;
    A[(a-'0'-1)*9+(b-'0'-1)]++;
    B[(b-'0'-1)*9+(a-'0'-1)]++;
  }
  ll sum=0;
  FOR(i,81){
    sum+=A[i]*B[i];
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

int32_t main(){
	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++)
		cin >> a[i];
	
	map<int,int> m;
	int ans = 0;
	for(int i = n-1; i >= 0; i--){
		ans += m[i+a[i]];
		m[i-a[i]]++;
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 27832
#include <stdio.h>

int n, A[11234], B[11234];
int ans[2];

int main(void) {
	while (true) {
		ans[0] = ans[1] = 0;
		scanf("%d", &n);
		if (n == 0) { break; }
		for (int i = 0; i < n; ++i) { scanf("%d%d", &A[i], &B[i]); }

		for (int i = 0; i < n; ++i) {
			if (A[i] > B[i]) { ans[0] += A[i] + B[i]; }
			else if (A[i] < B[i]) { ans[1] += A[i] + B[i]; }
			else { ans[0] += A[i], ans[1] += B[i]; }
		}

		printf("%d %d\n", ans[0], ans[1]);
	}
	return 0;
}

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

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        //処理の関係で添え字0は使わない(0-originだとコードの可読性が下がる)
        int[] days = { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
        String[] answer = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" };

        String input;
        while ((input = br.readLine()) != null) {
            String[] line = input.split(" ");
            
            if(line[0].equals("0")) break;

            int month = Integer.parseInt(line[0]);
            int day = Integer.parseInt(line[1]);

            for (int i = 1; i < month; i++) {
                day += days[i];
            }

            System.out.println(answer[(day + 2) % 7]);

        }
    }
}


Measured memory_bytes: 24140
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            String s = reader.readLine();

            final String[] sl = s.split(" ");

            s = reader.readLine();
            int K = Integer.parseInt(s);

            int mx = 0;
            int sm = 0;
            for (int i = 0; i < sl.length; i++) {
                int tmp = Integer.parseInt(sl[i]);
                if (mx < tmp) mx = tmp;
                sm += tmp;
            }

            System.out.println(sm - mx + (int)Math.pow(2, K) * mx);
        }
    }
}


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

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

	int k;
	cin>>k;

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

		if(x > n/2){
			int width = n - x + 1;

			//テδ」テつつ療δ」テつつセテδ」テつつ療δ」テつつセ
			if(y < width || y > n-width){
				int hight = y;
				if(y > n/2) hight = n - y + 1;
				cout<<(hight-1)%3+1<<endl;
			}
			else{
				cout<<(width-1)%3+1<<endl;
			}
		}
		else{
			int width = x;

			//テδ」テつつ療δ」テつつセテδ」テつつ療δ」テつつセ
			if(y < width || y > n-width){
				int hight = y;
				if(y > n/2) hight = n - y + 1;
				cout<<(hight-1)%3+1<<endl;
			}
			else{
				cout<<(width-1)%3+1<<endl;
			}
		}

	}

	return 0;
}

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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if (a+b-c-d>0){
    cout << "Left" << endl;
  }else if (a+b-c-d == 0){
    cout << "Balanced" << endl;
  }else{
    cout << "Right" << endl;
  }
  return  0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
using P = pair<ll,ll>;
#define fl cout<<flush;
#define endl '\n'
template <typename T> inline void prt(T v){cout<<v<<'\n';}
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1e9+7;
const ll MOD2=998244353;
const ld pi=3.14159265358979323846;
const ld eps=1e-10;

vector<long long> divisor(long long n) {
vector<long long> ret;
for (long long i = 1; i * i <= n; ++i) {
if (n % i == 0) {
ret.push_back(i);
if (i * i != n) ret.push_back(n / i);
}
}
sort(ret.begin(), ret.end()); // 昇順に並べる
return ret;
}

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll s;
    cin >> s;
    function<ll(ll,ll)> F = [&](ll b, ll n){
        if(n<b)return n;
        else return F(b,n/b)+n%b;
    };
    vl A=divisor(llabs(n-s));
    for(auto p: A){
        ll b=p+1;
        if(F(b,n)==s){
            prt(b);return 0;
        }
    }
    if(n==s){prt(n+1);return 0;}
    prt(-1);



    return 0;
}



Measured memory_bytes: 3632
#include<iostream>
    using namespace std;
     
    bool is_palindrome(string s){
        string t(s.rbegin(),s.rend());
        return s == t;
    }
     
    int main(){
        string s;
        cin>>s;
        int n=s.size();
        if(is_palindrome(s) && is_palindrome(s.substr(0,(n-1)/2)) && is_palindrome(s.substr((n+1)/2))){
            cout<<"Yes"<<endl;
        }
        else cout<<"No"<<endl;
    }

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

using namespace std;

template <int base>
int digit_sum(int n)
{
	int sum = 0;
	while (n > 0) {
		sum += n % base;
		n /= base;
	}
	return sum;
}

using ivec = vector<int>;

ivec read_int_args()
{
	int N;
	cin >> N;
	ivec v(N);
	for (auto& e : v) {
		cin >> e;
	}
	return v;
}

int compar(const void * b, const void* a)
{
	return (*(int*)a - *(int*)b );
}

int main()
{
	string s;
	cin >> s;
	int n = 1;
	bool ok = true;
	for (auto c : s) {
		if (n % 2 == 1 && c == 'L') {
			cout << "No" << endl;
			return 0;
		}
		if (n % 2 == 0 && c == 'R') {
			cout << "No" << endl;
			return 0;
		}
		n++;
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 888
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			int n = sc.nextInt();
			char[] s = sc.next().toCharArray();
			int count = 0;
			boolean flag;
			for(int i=0;i<n;i++){
				char[] t = sc.next().toCharArray();
				
				for(int p=0;p<t.length;p++){
					for(int q=1;;q++){
						if(p+q*(s.length-1)>=t.length) break;
						flag = true;
						for(int r=0;r<s.length;r++){
							if(s[r]!=t[p+q*r]){
								flag = false;
								break;
							}
						}
						if(flag==true){
							count++;
							p = t.length;
							break;
						}
					}
				}		
			}
			System.out.println(count);	
		}
	}	
}

Measured memory_bytes: 20256
#include <bits/stdc++.h>
#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;
typedef pair<int,int> PII;
typedef vector<int> VI;
 
const int N_MAX = 1e5 + 10;
const int INF = 1e9;
vector<PII> gra[N_MAX];
 
int ans[N_MAX];
 
set<PII> used;
void dfs(int v, const int &c) {
	used.insert(MP(v, c));
	for(PII e:gra[v]) {
		if(e.S != c || ans[e.F] != INF || used.count(MP(e.F, c)) )
			continue;
		dfs(e.F, c);
	}
}
 
int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	for(int i = 0; i < m; i++) {
		int st, ed, c;
		scanf("%d%d%d", &st, &ed, &c);
		gra[st].PB(MP(ed, c));
		gra[ed].PB(MP(st, c));
	}
 
	fill(ans, ans+N_MAX, INF);
	ans[1] = 0;
	int now = 1;
	VI vec;
	vec.PB(1);
	while(!vec.empty()) {
		for(int u:vec) {
			for(PII e : gra[u]) {
				if(used.count(e) || ans[e.F] != INF)
					continue;
				dfs(e.F, e.S);
			}
			debug("+++++\n");
		}
		debug("QQQQQ\n");
		vec.clear();
		for(auto it = used.begin(); it != used.end(); it++)
			if(!SZ(vec) || vec[SZ(vec)-1] != it->F) {
				vec.PB(it->F);
				ans[it->F] = now;
			}
		for(int i = 1; i <= n; i++)
			debug("%d\n", ans[i]);
		used.clear();
		now++;
	}
	if(ans[n] == INF)
		puts("-1");
	else
		printf("%d\n", ans[n]);
	return 0;
}


Measured memory_bytes: 17404
n = int(input())
x = str(input())
outp = []

word = {
        "A":0,
        "B":1,
        "C":2,
        "D":3,
        "E":4,
        "F":5,
        "G":6,
        "H":7,
        "I":8,
        "J":9,
        "K":10,
        "L":11,
        "M":12,
        "N":13,
        "O":14,
        "P":15,
        "Q":16,
        "R":17,
        "S":18,
        "T":19,
        "U":20,
        "V":21,
        "W":22,
        "X":23,
        "Y":24,
        "Z":25
        }

for w in x:
    new = (word[w] + n) % 26
    for key, value in word.items():
        if new == value:
            outp.append(key)

print("".join(outp))


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

int main() {
  int n, h, mh, c = 1;
  cin >> n >> mh;
  REP(i, n - 1) {
    cin >> h;
    if (h >= mh) ++c;
    mh = max(h, mh);
  }
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 256
MOD = 10**9 + 7
n = int(input())
x, y, z = 0, 0, 0
ans = 1
for a in map(int, input().split()):
    if a == x:
        if x != y:
            x += 1
        elif y != z:
            ans = ans * 2 % MOD
            y += 1
        else:
            ans = ans * 3 % MOD
            z += 1
    elif a == y:
        if y != z:
            y += 1
        else:
            ans = ans * 2 % MOD
            z += 1
    elif a == z:
        z += 1
    else:
        ans = 0
print(ans)

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    cout << ( (s<t) ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
// Do you knOW what it feels like?

		// To be TorTured by your own MinD?
	
	// I don't wanna feel the PAIN.

// I BeG you to KILL me, pleASE...

#include <bits/stdc++.h>
using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("Os")

#define F first
#define S second
#define pb push_back
#define SZ(x) (ll)(x.size())
#define all(x) x.begin(),x.end()

typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn=1e6+10, lg=21, mod=1e9+7, inf=1e18;

ll n,we[maxn];

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

    cin>>n;
	for(int i=1;i<=n;i++){
 		ll x; cin>>x;
 		we[x]=i;
    }
	set<ll> s; s.insert(0), s.insert(n+1);
	ll ans=0;
    for(int j=1;j<=n;j++){ int i=we[j];
        auto it2=s.upper_bound(i);
        auto it1=it2; it1--;
        ans+=(i-*it1)*(*it2-i)*j;
        s.insert(i);
    }
    cout<<ans<<endl;

	return 0;
}



























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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N-1);
  int point=0;
  int pre=-1;
  for (int i=0; i < N;i++){
      cin >> A.at(i);
  }
  for (int i=0; i < N;i++){
      cin >> B.at(i);
  }
  for (int i=0; i < N-1;i++){
      cin >> C.at(i);
  }
  for (int i=0; i < N;i++){
      point+=B.at(A.at(i)-1);
      if (pre+1==A.at(i)){
        point+=C.at(pre-1);
      }
      pre=A.at(i);
  }
  cout << point << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<cd> vcd;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef unordered_map<int, int> umpii;
typedef unordered_map<ll, ll> umpll;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1000000007;
const ll INF = 1e18;
const int inf = 1e9;
const int MX = 100001; //check the limits, dummy

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

    int n, k; cin >> n >> k;
    int res = 0;
    F0R(i, n) {
        int tmp; cin >> tmp;
        if(tmp >= k) res++;
    }

    cout << res << endl;
}

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

const ll MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

ll ppow(ll a,ll b){
	a%=MOD;
	ll res=1;
	while(b){
		if(b&1)res=(res*a)%MOD;
		a=(a*a)%MOD;
		b>>=1;
	}
	return res;
}
map<ll,int>prime_factor(ll n){
	map<ll,int>res;
	for(ll i=2;i*i<=n;i++){
		while(n%i==0){
			res[i]++;
			n/=i;
		}
	}
	if(n!=1)res[n]++;
	return res;
}

int a[20000];
//~ ll Pow[20000];

int main(){
	int n;cin>>n;
	map<int,int>L;
	rep(i,n){
		scanf("%d",&a[i]);
		auto mp=prime_factor(a[i]);
		for(auto&p:mp)L[p.first]=max(L[p.first],p.second);
	}
	ll A=1;
	for(auto&p:L){
		(A*=ppow(p.first,p.second))%=MOD;
	}
	ll ans=0;
	rep(i,n){
		(ans+=A*ppow(a[i],MOD-2))%=MOD;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 768
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
std::random_device rd;
std::mt19937 mt(rd());
constexpr int MOD = 1e9 + 7; constexpr int MAX = 200020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e18;



void solve() {
	int N, A, B; cin >> N >> A >> B;
	int c = N / (A + B);
	ll ans = c * A;
	int rem = N - c * (A + B);
	ans += min(rem, A);
	print(ans);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int Q;
ll A, B;

int main() {
	cin >> Q;
	for (int i = 0; i != Q; ++i) {
		cin >> A >> B;
		if (A == B)
			cout << (A - 1) * 2 << endl;
		else {
			ll C = sqrt(A*B);
			cerr << nyan << sp << C << sp << nyan << endl;
			if (C*C == A*B)
				cout << C * 2 - 3 << endl;
			else if (C*(C + 1) < A*B)
				cout << C * 2 - 1 << endl;
			else
				cout << C * 2 - 2 << endl;
		}
	}
	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;
using lli = long long int;

#define PI 3.14159265358979323846264338327950L

int main(){
  int X, Y;
  int i, j;

  cin >> X >> Y;
  
  for(i=0; i<=X; i++){
    for (j=0; j<=X-i; j++){
        // cout << "i, j" << i << ", " << j << endl;
      if( (i+j == X) && (((2*i)+(4*j)) == Y) ){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;        
  return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)

int N;
int A[100010];
int M;
int B[100010],C[100010];
P p[100010];

signed main(){
	int Max=0,Max2=0;
	cin>>N>>M;
	REP(i,N){
		cin>>A[i];
	}
	REP(i,M){
		cin>>B[i]>>C[i];
		p[i]=make_pair(C[i],B[i]);
	}
	sort(A,A+N);
	sort(p,p+M,greater<>());
	vector<int> v;
	REP(i,N){
		v.push_back(A[i]);
	}
	bool flag=false;
	for(int i=0;i<M;i++){
		REP(j,p[i].second){
			v.push_back(p[i].first);
			if(v.size()>=2*N){
				flag=true;
				break;
			}
		}
		if(flag)break;
	}
	int ans=0;
	sort(v.begin(),v.end(),greater<>());
	REP(i,N){
		ans+=v[i];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 6388
from fractions import gcd
a, b, c, d = map(int, input().split())

cnt = 0
s = b - a + 1
cd = (c*d) // gcd(c,d)

m1 = int((a-1) // c)
m2 = int(b // c)
cnt += (m2-m1)
#print(cnt)

m1 = int((a-1) // d)
m2 = int(b // d)
cnt += (m2-m1)
#print(cnt)

m1 = int((a-1) // cd)
m2 = int(b // cd)
cnt -= (m2-m1)
#print(cnt)

#print(cnt)
print(s - cnt)

Measured memory_bytes: 5048
import java.util.Scanner;
public class Main {
	static Scanner scan=new Scanner(System.in);
	static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
	static long lcm (int a, int b) {return a*b/gcd(a,b);}
	static int max(int a,int b) {return a>b?a:b;}
	static int min(int a,int b) {return a<b?a:b;}
	static long factorial(int i) {return i==1?1:i*factorial(i-1);}
	static int lower_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<=key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static int upper_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2)if(n%i==0){return false;}
		return true;
	}
	static int upper_division(int a,int b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lupper_division(long a,long b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lmax(long a,long b) {return Math.max(a, b);}
	static long lmin(long a,long b) {return Math.min(a, b);}
	static int[] setArray(int a) {
		int b[]=new int[a];
		for(int i=0;i<a;i++) {
			b[i]=scan.nextInt();
		}
		return b;
	}
	static String reverce(String str) {
		String strr="";
		for(int i=str.length()-1;i>=0;i--) {
			strr+=str.charAt(i);
		}
		return strr;
	}
	public static void main(String[] args) {
		int a=scan.nextInt();
		int b=scan.nextInt();
		int c=a*-1;
		int d=b*-1;//a-b,a-d,c-b,c-d
		int min=1145141919;
		if(a<=b&&b-a>=0) {
			min=min(min,b-a);
		}
		if(a<=d&&d-a>=0) {
			min=min(min,d-a+1);
		}
		if(c<=b&&b-c>=0) {
			min=min(min,b-c+1);
		}
		if(c<=d&&d-c>=0) {
			min=min(min,d-c+2);
		}
		System.out.println(min);
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first 
#define se second
#define pi pair<ll,ll> 
#define pb push_back
#define mk make_pair
int main(){ 
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
   ll a,b,n;
  cin>>a>>b>>n;
  ll t=b-1;
  ll z=floor(a*t/b)-a*floor(t/b);
  if(n/b>=1)
  cout<<z<<endl;
  else
  {
	  cout<<floor(n*a/b)-a*floor(n/b)<<endl;
  }
}


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

int main(void)
{
    int x, y;
    while(cin >> x >> y && x != 0)
    {
        int sum = 0;
        if(x/1000 == y/1000)
        {
            int temp = x/1000;
            temp = temp%10*10 + temp/10;
           // cout << "te=" << temp << endl;
            if(x%100 > temp)
            {
                x = (x/100+1)*100 + temp;
            }
            else
                x = (x/100)*100 + temp;
            while(x <= y)
            {
             //   cout << "1x=" << x <<", y=" <<y << endl;
                sum++;
                if((x/100)%10 == 9)
                    x = (x/1000+1)*1000 + x/1000+1;
                else
                    x += 100;

            }
        }
        else
        {
            int temp = x/1000;
            temp = temp%10*10 + temp/10;
           // cout << "te=" << temp << endl;
            if(temp < x%100)
            {
                if((x%100)/100 == 9)
                {
                    x = (x + 1000)/1000*1000;
                    int k = x/1000;
                    k = k%10*10 + k/10;
                    x = x + k;
                }
                else
                {
                    x = (x + 100)/100*100;
                    x = x + temp;
                }
            }
            else
            {
                x = x /100*100;
              //  cout << "x=" << x <<", y=" <<y << endl;
                x = x + temp;
            }
            while(x <= y)
            {
              //  cout << "x=" << x <<", y=" <<y << endl;
                sum++;
                if((x/100)%10 == 9)
                {
                     x = (x + 1000)/1000*1000;
                    int k = x/1000;
                    k = k%10*10 + k/10;
                    x = x + k;
                }
                else
                    x += 100;

            }
        }
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
    int A, B;
    
    cin >> A >> B;
    if(A > B){
        if((A-B)%2==0){
            cout << (A-B)/2 + B << endl;
        }else{
            cout << "IMPOSSIBLE" << endl;
        }
    }else{

        if((B-A)%2==0){
            cout << (B-A)/2 + A<< endl;
        }else{
            cout << "IMPOSSIBLE" << endl;
        }
    }
    return 0;
}

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

#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define f(i, a, b) for (int i=a; i<(signed)(b); ++i)
#define pc __builtin_popcount // counts number of 1's in bin(num)
#define pb push_back
#define mp make_pair

const double pi = 2*acos(0.0);
//__gcd(n1, n2);
//cout << fixed;
//cout << setprecision(6); //fixes # of dp
//tgamma(i+1) is 1!
void solve(){
    int x,y,z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y;
}

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








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

const ll MOD = 1000000007;

template<class T>
T pow(long long a, long long b, T mod){
    if(b == 0) return 1;
    if(b % 2 == 0){
        T d = pow(a,b/2,mod);
        return (d*d)%mod;
    }else return a%mod*pow(a,b-1,mod)%mod;
}


template<class T>
ll comb(long long n,long long r,T mod){
    if(r > n) return 0;
    if(n == r || r == 0) return 1;
    long long fact1 = 1,fact2 = 1;
    for(long long i = n; i >= n-r+1; --i) fact1 = fact1*i%mod;
    for(long long i = r; i >= 1; --i) fact2 = fact2*i%mod;
    return fact1*pow(fact2,mod-2,mod)%mod;
}

int main(){
    int h,w,a,b; cin >> h >> w >> a >> b;
    ll ans = comb(h+w-2,h-1,MOD);
    ll comb1[h+w], comb2[h+w];
    comb1[b-1] = 1LL;
    comb2[w-b-1] = 1LL;
    for(int i = b-1; i < h+w-1; ++i){
        comb1[i+1] = (((ll(i+1))*pow(i+1-(b-1),MOD-2,MOD))%MOD)*comb1[i];
        comb1[i+1] %= MOD;
    }
    for(int i = w-b-1; i < h+w-1; ++i){
        comb2[i+1] = (((ll(i+1))*pow(i+1-(w-b-1),MOD-2,MOD))%MOD)*comb2[i];
        comb2[i+1] %= MOD;
    }
    rep(i,a){
        ans -= (comb1[h-a+i+b-1]*comb2[a-i+w-b-2])%MOD;
        if(ans < 0) ans += MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
#define L long long
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define pii pair<pi,int>
#define aa first
#define bb second
#define xx aa.aa
#define yy aa.bb
#define zz bb
#define mp make_pair
#define mpp(a,b,c) mp(mp(a,b),c)
using namespace std;
int n,m,p;
L f[600000],g[600000],q,ans;
inline void modify(L f[],int i,int j,int k,int x,L p)
{
	f[i]=min(f[i],p);
	if(j<k)
	  if(x<=(j+k>>1))
	    modify(f,i<<1,j,j+k>>1,x,p);
	  else
	    modify(f,i<<1|1,(j+k>>1)+1,k,x,p);
}
inline L minn(L f[],int i,int j,int k,int l,int r)
{
	if(l<=j && k<=r)
	  return f[i];
	else
	  {
	   L p=1e18;;
	   if(l<=(j+k>>1))
	     p=min(p,minn(f,i<<1,j,j+k>>1,l,r));
	   if(r>(j+k>>1))
	     p=min(p,minn(f,i<<1|1,(j+k>>1)+1,k,l,r));
	   return p;
	  }
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i,j;
	L k;
	scanf("%d%d",&n,&m);
	for(p=1;p<n;p<<=1);
	for(i=1;i<2*p;i++)
	  f[i]=g[i]=1e18;
	scanf("%d%d",&i,&j);
	modify(f,1,1,p,i,-i);
	modify(g,1,1,p,i,i);
	while(m--)
	  {
	   scanf("%d",&i);
	   q+=abs(i-j);
	   ans+=abs(i-j);
	   k=min(minn(f,1,1,p,1,i)+i,minn(g,1,1,p,i,n)-i)-abs(i-j);
	   modify(f,1,1,p,j,k-j);
	   modify(g,1,1,p,j,k+j);
	   ans=min(ans,q+k);
	   j=i;
	  }
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 9088
use std::io::*;
use std::str::FromStr;

fn main() {
    let s: Vec<char> = read::<String>().chars().collect();
    let t: Vec<char> = read::<String>().chars().collect();

    let mut data: Vec<Vec<usize>> = vec![vec![]; 26];
    for i in 0..s.len() {
        let c = s[i] as usize;
        data[c - ('a' as usize)].push(i);
    }
    
    let mut ans: usize = 0;
    let mut last = 0;
    let mut check = false;
    for i in 0..t.len() {
        let c = t[i] as usize;
        let po = &data[c - ('a' as usize)];
        if po.len() == 0 {
            check = true;
            break;
        }

        if i == 0 {
            ans += po[0]+1;
            last = po[0];
            continue;
        }

        let mut ok = po.len() as isize;
        let mut ng = -1;
        while ok - ng > 1 {
            let mid = ((ok + ng) / 2) as usize;
            if po[mid] <= last {
                ng = mid as isize;
            } else {
                ok = mid as isize;
            }
        }
        let ok = ok as usize;
        if ok == po.len() {
            ans += s.len() - last + po[0];
            last = po[0];
        } else {
            ans += po[ok] - last;
            last = po[ok];
        }
    }
    if check {
        println!("-1");
    } else {
        println!("{}", ans);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

int main(){
	double a, b, x;
	scanf("%lf%lf%lf", &a, &b, &x);
	double v = a * a * b;
	if(x < v / 2) {
		printf("%.12lf\n", 90 - atan(2*x / (a*b*b)) * 180 / acos(-1.0));
	}else{
		double rem = v - x;
		printf("%.12lf\n", atan(2*rem / (a*a*a)) * 180 / acos(-1.0));
	}
}


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

#define ll long long
#define MOD 1000000007


int main(){
    ll n;
    cin>>n;
    ll size = n;
    queue<int> a;
    for(ll i=2;i*i<=size;i++){
        if(n%i!=0)continue;
        int co=0;
        while(n%i==0){
            n /= i;
            co++;
        }
        if(co==0)continue;
        a.push(co);
        if(n==1)break;
    }
    if(n!=1)a.push(1);

    ll ans=0;
    while(!a.empty()){
        for(ll i=1;;i++){
            if(i*(i+1)>2*a.front()){
                ans += i-1;
                a.pop();
                break;
            }
        }
    }

    cout<<ans<<endl;


}


Measured memory_bytes: 3632
/* Filename: ARC063D.java
 * Author: Mushiyo
 */

import java.util.Scanner;

public class Main{

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

		while (input.hasNext()) {
			int N = input.nextInt();
			int T = input.nextInt();
			int[] A = new int[N];

			for (int i = 0; i < A.length; ++i) {
				A[i] = input.nextInt();
			}

			int max = Integer.MIN_VALUE;
			int currentMin = A[0];
			for (int i = 1; i < A.length; ++i) {
				max = Math.max(max, A[i] - currentMin);
				currentMin = Math.min(currentMin, A[i]);
			}

			int countMax = 0;
			currentMin = A[0];
			for (int i = 1; i < A.length; ++i) {
				if (A[i] - currentMin == max) {
					++countMax;
				}

				currentMin = Math.min(currentMin, A[i]);
			}

			System.out.println(countMax);
		}
	}

}


Measured memory_bytes: 31612
#include<bits/stdc++.h>
#define int long long
using namespace std;
main(){
int a,now=-1,n;
cin>>n;
int res=-1;
while(n--){
cin>>a;
if(a>now+1){
cout<<-1<<endl;
return 0;
}
if(a>now)res++;
else res+=a;
now=a;
}
cout<<res<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#define ll long long
using namespace std;
int main(){
    ll a,b,x;
    cin>>a>>b>>x;
    ll q_a=a/x;
    ll q_b=b/x;
    ll ret=q_b-q_a;
    if(0==a%x){
        ret++;
    }
    cout<<ret;
    return 0;
}

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

using namespace std;

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

int main() {
	int p, q;
	
	while (cin >> p >> q) {
		string ans;
		map<int, int> m;
		int pos = -1;
		
		m[p % q] = 0;
		p *= 10;
		FOR(i, 1, 100) {
			int a = p / q, b = p % q;
			
			ans += (char)(a + '0');
			
			if (b == 0) break;
			if (m.find(b) != m.end()) {
				pos = m[b];
				break;
			}
			m[b] = i;
			
			p = b * 10;
		}
		
		cout << ans << endl;
		
		if (pos != -1) {
			REP(i, pos) putchar(' ');
			FOR(i, pos, ans.size()) putchar('^');
			puts("");
		}
		
	}
	return 0;
}

Measured memory_bytes: 1200
while(1):
  aaa=map(int,raw_input().split(" "))
  if aaa[0]==0 and aaa[1]== 0 and aaa[2]==0:
    break
  cnt=0
  sum=0
  for i in range(aaa[0]):
    tmp=input()
    if i+1==aaa[1]:
      cnt=tmp
    sum+=tmp
  if cnt!=0:
    print int((100.0*sum*(100-aaa[2])/100)/cnt)
  else:
    print 0

Measured memory_bytes: 6288
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val n1 = sc.nextInt
  val n2 = sc.nextInt
  val n3 = sc.nextInt
  val n4 = sc.nextInt

  val res = if(Set(n1,n2,n3,n4) == Set(1,9,7,4)) "YES" else "NO"

  println(res)
}

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

long long n;
vector<long long> v[3];
string s, x = "RGB";

long long solve();

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

long long solve() {
  long long res = 0;
  for (int i = 0; i < 3; ++i) v[i].assign(n + 1, 0);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 3; ++j) v[j][i + 1] += v[j][i];
    if (s[i] == 'R') ++v[0][i + 1];
    if (s[i] == 'G') ++v[1][i + 1];
    if (s[i] == 'B') ++v[2][i + 1];
  }
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j)
      if (s[i] != s[j]) {
        int now = -1;
        if (s[i] != 'R' && s[j] != 'R')
          now = 0;
        else if (s[i] != 'G' && s[j] != 'G')
          now = 1;
        else
          now = 2;
        long long p = v[now][n] - v[now][j];
        if (j + (j - i) < n && s[j + (j - i)] == x[now]) --p;
        res += p;
      }
  }
  return res;
}

Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N; i >= 0; i--)
const ll INF = 1000000000000000000;
#define PI 3.1415926535
using Graph = vector<vector<int>>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true;} return false;}
bool seen[100000];
void dfs(const Graph &G, int v) {
    seen[v] = true; // v を訪問済にする

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

//dpTable
int dp[100050];
int main(){
    int A,B,C;
    cin >> A >> B >> C;
    cout << ((C > A && C < B) || (C > B && C < A) ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 3604
#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;
template<typename T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define sz(v) (int)(v.size())
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define prec fixed << setprecision(12)
#define test int t; cin >> t; while (t--)
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int, int> mii;
typedef vector<pii> vpi;

void solve() {
	int n, m;
	cin >> n >> m;
	int ll = 1, rr = n;
	for (int i = 0; i < m; ++i) {
		int l, r;
		cin >> l >> r;
		ll = max(l, ll);
		rr = min(r, rr);
	}
	cout << max(rr - ll + 1, 0ll) << "\n";
}

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	// test
	solve();
	return 0;
}


Measured memory_bytes: 3644
<?php
while (true) {
    $line = trim(fgets(STDIN));
    list($H, $W) = explode(' ', $line);
    if ($W == 0 && $H == 0) {
        break;
    }
    $room = array();
    for ($i = 0; $i < $H; $i++) {
        $room[$i] = trim(fgets(STDIN));
    }
    $visited = array();
    for ($i = 0; $i < $H; $i++) {
        for ($j = 0; $j < $W; $j++) {
            $visited[$i][$j] = false;
        }
    }
    $x = 0; $y = 0;
    $isLoop = false;
    while (true) {
        $line = $room[$y];
        $dir = $line[$x];
        if ($dir == '.') {
            break;
        }
        $visited[$y][$x] = true;
        switch ($dir) {
            case '>':
                $x++;
                break;
            case '<':
                $x--;
                break;
            case 'v':
                $y++;
                break;
            case '^':
                $y--;
                break;
        }
        if ($visited[$y][$x]) {
            $isLoop = true;
            break;
        }
    }
    if ($isLoop) {
        echo "LOOP\n";
    } else {
        echo "$x $y\n";
    }
}

Measured memory_bytes: 16528
#include <stdio.h>
#define N (300010)
int n,a, b;
int ans[N];
int main(){
    scanf("%d%d%d", &n, &a, &b);
    if (a+b-1 > n || 1ll*a*b < n){
        printf("-1\n");
        return 0;
    }
    for (int t = 1; t <= b; ++t){
        int c = n-1ll*t*a-(b-t-1);
        if (c >= 1 && c <= a){
            int cnt = n, pos = 0;
            for (int i = 1; i <= t; ++i){
                for (int j = a; j; --j){
                    ans[pos + j] = cnt--;
                }
                pos += a;
            }
            for (int i = 1; i <= b-t-1; ++i){
                ans[++pos] = cnt--;
            }
            for (int i = c; i; --i){
                ans[pos+i] = cnt--;
            }
            break;
        }
    }
    for (int i = 1; i <= n; ++i){
        printf("%d%c", ans[i], " \n"[i == n]);
    }
}

Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
using namespace std;
int main() {
  string x,y,z;
  cin>>x>>z>>y;
  if (z == "+") cout<<stoi(x)+stoi(y)<<endl;
  else cout<<stoi(x)-stoi(y)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

void insertionSort(int A[], const int N)
{
    int i, j;

    for( i = 0; i < N; ++i ){
        int tmp = A[i];
        for( j = i-1; -1 < j && tmp < A[j]; --j ){
            A[j+1] = A[j];
        }
        A[j+1] = tmp;
        for( j = 0; j < N; ++j ){
            printf("%d", A[j]);
            if( j != N-1 ) printf(" ");
        }
        printf("\n");
    }
}

int main()
{
    int i;
    int N;
    scanf("%d", &N);
    int A[N];
    for( i = 0; i < N; ++i )
        scanf("%d", &A[i]);

    insertionSort(A, N);

    return 0;
}


Measured memory_bytes: 2044
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
int cnt[7];
int main(){
    int i,ans=0;
    string str;
    cin>>str;
    for(i=0;i<str.length();i++){
        if(str[i]=='+') ans++;
        else ans--;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>




using namespace std;
int main() {

	int n, a;
	cin >> n >> a;
	n %= 500;
	if (a >= n)cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
   long long n;
   long long i;
   long long j;
   scanf("%lld",&n);
   for(i=0;;i++)
   {
       if(n-i*i<0)
       {
           printf("%lld",(i-1)*(i-1));
           break;
       }
   }
    return 0;
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000009
#define EPS 1E-9

const int n = 10;
int t;
int a, b, c;

int main()
{
  cin >> t;

  while(t--){
    bool ok = true;
    b = c = 0;
    rep(i, n){
      cin >> a;
      if(b > c) swap(b, c);
      if(a > c){ c = a;  continue; }
      if(a > b){ b = a;  continue; }
      ok = false;
      //break;
    }
    puts(ok ? "YES" : "NO");
  }

  return 0;
}

Measured memory_bytes: 1116
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+50;

int n,c[maxn],d[maxn],kd[maxn],f[maxn],res[maxn];

int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;++i){
        int ai;
        scanf("%d",&ai);
        ++c[ai];
    }
    for(int i=1;i<=n;++i) ++d[c[i]];
    for(int i=0;i<=n;++i) kd[i]=i*d[i];
    for(int i=1;i<=n;++i){
        d[i]+=d[i-1];
        kd[i]+=kd[i-1];
    }
    for(int i=1;i<=n;++i){
        f[i]=(kd[i]+i*(d[n]-d[i]))/i;
    }
    int pos=n,ans=0,i=1;
    while(pos){
        while(pos<=f[i]) ++ans,++i;
        res[pos--]=ans;
    }
    for(int i=1;i<=n;++i) printf("%d\n",res[i]);
    return 0;
}

Measured memory_bytes: 6656
#include<bits/stdc++.h>
using namespace std;
int main() {
	long long n, a, b; cin >> n >> a >> b;
	long long res;
	if((b - a) % 2 == 0) res = (b - a) / 2;
	else {
		long long  res1, res2;
		res1 = (b - a - 1) / 2 + a;
		res2 = (b - a - 1) / 2 + (n - b) + 1;
		res = min(res1, res2);
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 3536
#include<bits/stdc++.h>
    #define F first
    #define S second
    using ll = long long;
    const ll mod = 1000000007;
    const ll infi = 1000000000000000;
    const ll md = 998244353;
    using namespace std;
    using vl = vector<ll>;
    using pll =  pair<ll,ll>;
    
  
   
    void solve(){
        string s[14];
        s[0] = "SUN";
        s[1] = "MON";
        s[2] = "TUE";
        s[3] = "WED";
        s[4] = "THU";
        s[5] = "FRI"; 
        s[6] = "SAT";
        for(int i=7;i<14;i++) s[i] = s[i-7];
        int i=0;
        string a;
        cin>>a;
        for(i=0;i<7;i++) if(a==s[i]) break;
        i++;
        int j=i-1;
        for(;i<14;i++) if(s[i]=="SUN") break;
        cout<<i-j;
        
        //vl a(n);for(int i=0;i<n;i++) cin>>a[i];
    }
     
    int main() {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
       // int n; cin>>n; for(int i=0;i<n;i++)
        solve();
        return 0;
    } 
    

Measured memory_bytes: 256
# -*- coding:utf-8 -*-
import copy

def solve():
    K = int(input())

    if K <= 9:
        print(K)
        return

    que = [i for i in range(1, 10)]
    cnt = 9

    while True:
        tmp_que = copy.deepcopy(que)
        que = []
        for i in tmp_que:
            a = i%10
            if 0 <= (a-1) <= 9:
                cnt += 1
                new = i*10 + (a-1)
                if K == cnt:
                    print(new)
                    return
                que.append(new)
            if 0 <= a <= 9:
                cnt += 1
                new = i*10 + a
                if K == cnt:
                    print(new)
                    return
                que.append(new)
            if 0 <= (a+1) <= 9:
                cnt += 1
                new = i*10 + (a+1)
                if K == cnt:
                    print(new)
                    return
                que.append(new)



if __name__ == "__main__":
    solve()


Measured memory_bytes: 6944
use std::io::*;
use std::str::FromStr;
//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut a: Vec<i64> = (0..n).map(|_| read()).collect();
    a.sort_by(|x,y| y.cmp(x));

    if n % 2 == 0 {
        let mut sum = 0;
        for i in 0..n/2 - 1{
            sum += a[i]*2;
        }
        sum += a[n/2-1];
        sum -= a[n/2];
        for i in n/2+1..n{
            sum -= a[i]*2;
        }
        println!("{}",sum);
    }else{
        let mut sum1 = 0;
        let mut sum2 = 0;
        for i in 0..n/2 - 1{
            sum1 += a[i]*2;
        }
        sum1 += a[n/2-1];
        sum1 += a[n/2];
        for i in n/2+1..n{
            sum1 -= a[i]*2;
        }

        for i in 0..n/2{
            sum2 += a[i]*2;
        }
        sum2 -= a[n/2];
        sum2 -= a[n/2+1];
        for i in n/2+2..n{
            sum2 -= a[i]*2;
        }
        println!("{}",std::cmp::max(sum1,sum2));

    }
}


Measured memory_bytes: 3100