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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return (rng() % (y+1-x)) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

typedef long long ll; 
typedef long double ld;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
typedef pair<ll,ll>pi; typedef pair<ll,pi>spi; typedef pair<pi,pi>dpi;

#define LLINF ((long long)1e18)
#define INF int(1e9+1e6)
#define MAXN (1000006)
ll n,f[MAXN],inv[MAXN],mod=1e9+7,ans;
int main(){
	FAST
	cin>>n;
	auto qexp=[&](ll x,ll e){
		ll sum=1;
		while(e){
			if(e&1) sum*=x, sum%=mod;
			x*=x,x%=mod;
			e>>=1;
		}
		return sum;
	};
	auto C=[&](ll n,ll k){
		return n < k ? 0 : f[n]*inv[k]%mod*inv[n-k]%mod;
	};
	f[0]=1; FOR(i,1,MAXN-1) f[i]=f[i-1]*i%mod;
	inv[MAXN-1] = qexp(f[MAXN-1], mod-2); DEC(i,MAXN-2,0) inv[i]=inv[i+1] * (i+1) % mod;
	FOR(k,2,n-2){
		ans -= C(k-1,n-k-1) * f[k] % mod * f[n-1-k] % mod, ans %= mod;
	}
	ans += f[n-1] * (n-1) % mod + mod, ans %= mod;
	cout<<ans<<'\n';
}


Measured memory_bytes: 15872
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

int main(){

  int n;
  cin >> n;

  int a, b, c, d, e, f, g;
  int min1 = 10000;
  // for(int j = 1; j < n; j++){
  // for (int i = 1; i < j; i++){
  //   c = i % 10;
  //   d = (j - i) % 10;
  //   //cout << i / 10 + c + (27 - i) / 10 + d << endl;
  //   min1 = min(min1, i / 10 + c + (j - i) / 10 + d);
  // }
  //
  // cout << j << ": " << min1 << endl;
  // min1 = 10000;
  //
  // }


  a = n % 10;
  b = (n % 100) / 10;
  c = (n % 1000) / 100;
  d = (n % 10000) / 1000;
  e = (n % 100000) / 10000;
  g = (n % 1000000) / 100000;

  if (a+b+c+d+e+g == 1){
    f = 10;
  }else{
    f = a+b+c+d+e+g;
  }

  cout << f<< endl;



  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <utility>
#include <algorithm>
using namespace std;

int main(void) {
  int i, j, k, n;
  scanf("%d", &n);
  int t[n + 1], v[n + 1], st[n + 1];
  pair<int, int> vs[n + 1];
  t[0] = 0, st[0] = 0, v[0] = 0, vs[0] = make_pair(0, 0);
  for(i = 1; i <= n; ++i) {
    scanf("%d", &t[i]);
    st[i] = t[i];
    st[i] += st[i - 1];
  }
  for(i = 1; i <= n; ++i) {
    scanf("%d", &v[i]);
    vs[i] = make_pair(v[i], i);
  }
  sort(vs, vs + n + 1);
  double max[st[n] * 2 + 1], ans = 0.0;
  for(i = st[n] * 2; i >= 0; --i) max[i] = (double)(st[n] * 2 - i) / 2.0;
  for(i = 0; i < st[n] * 2 && max[i] > (double)i / 2.0; ++i) max[i] = (double)i / 2.0;
  for(i = 1; i <= n; ++i) {
    int tmp = vs[i].second;
    for(j = st[tmp - 1] * 2; j <= st[tmp] * 2; ++j) if(max[j] > v[tmp]) max[j] = (double)v[tmp];
    for(j = st[tmp] * 2; j <= st[n] * 2 && max[j] >= v[tmp] + (double)(j - st[tmp] * 2) / 2.0; ++j) max[j] = v[tmp] + (double)(j - st[tmp] * 2) / 2.0;
    for(j = st[tmp - 1] * 2; j >= 0 && max[j] >= v[tmp] + (double)(-j + st[tmp - 1] * 2) / 2.0; --j) max[j] = v[tmp] + (double)(-j + st[tmp - 1] * 2) / 2.0;
  }
  for(i = 1; i <= 2 * st[n]; ++i) ans += max[i] + max[i - 1];
  printf("%lf", (double)ans / 4.0);
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdlib>
#include <vector>

struct Game {
    int M;
    int N;
    int P;
    std::vector<int> betNum;
};

void cost(Game game); 

int main(void) {
    int M;
    int N;
    int P;

    std::cin >> M >> N >> P;
    while (M != 0 || N != 0 || P != 0) {
        Game game;
        game.M = M;
        game.N = N;
        game.P = P;

        for (int i = 0; i < game.M; i++) {
            int num;
            std::cin >> num;
            game.betNum.push_back(num); 
        }
        cost(game);
        std::cin >> M >> N >> P;
    }
    return EXIT_SUCCESS;
}

void cost(Game game) {
    int total = 0;
    std::vector<int> v = game.betNum;
    for (int i = 0; i < (int)(v.size()); i ++) {
        total += v[i]; 
    }
    int winner = v[game.N - 1];
    if (winner == 0) {
        std::cout << "0" << std::endl;
    } else {
        std::cout << 100 * total * (100 - game.P) / 100 / winner << std::endl;
    }
    return;
}

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

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

    int ans = 10000;
    for(int i = 0; i <= s.size() - t.size(); i++){
        string str = s.substr(i,t.size());
        int cnt = 0;
        for(int j = 0; j < str.size(); j++){
            if(str[j] != t[j])
                cnt++;
        }
        ans = min(ans,cnt);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3576
#include <stdio.h>
#include <string.h>

int main(void)
{
    char date[4];
    int  next_sun_day;

    scanf("%s", date);

    if(strcmp("SUN", date)==0){
        printf("7\n");
    }
    else if(strcmp("MON", date)==0){
        printf("6\n");
    }
    else if(strcmp("TUE", date)==0){
        printf("5\n");
    }
    else if(strcmp("WED", date)==0){
        printf("4\n");
    }
    else if(strcmp("THU", date)==0){
        printf("3\n");
    }
    else if(strcmp("FRI", date)==0){
        printf("2\n");
    }
    else if(strcmp("SAT", date)==0){
        printf("1\n");
    }
    else{
        ;
    }
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pii pair<int,int>
#define pb push_back
#define r1 rt<<1
#define r2 rt<<1|1
#define fi first
#define se second
#define ri register int
#define rep(i,a,b) for(ri i=(a);i<=(b);++i)
#define rep2(i,a,b,c) for(ri i=(a);i<=(b);i+=(c))
#define REP(i,a,b) for(ri i=(a);i>=(b);--i)
#define REP2(i,a,b,c) for(ri i=(a);i>=(b);i-=(c))
using namespace std;

inline ll read(){
	ll x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^'0'),c=getchar();
	return x*f;
}
inline void write(ll x){
	if(x<0) putchar('-'),x=-x;
	if(x>9) write(x/10);
	putchar(x%10+'0');
}

int main()
{
	ri a=read(),b=read(),c=read(),d=read();
	cout<<(d==1);
	return 0; 
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner in = new Scanner(System.in)) {
			int A = in.nextInt();
			int B = in.nextInt();
			int ans = 0;
			for (int i = 0; i < 2; i++) {
				if (A <= B) {
					ans += B;
					B--;
				} else {
					ans += A;
					A--;
				}
			}
			
			System.out.println(ans);
		} catch (Exception e) {
			// TODO: handle exception
		}
	}

}


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

int main(){
  string a,b;
  cin>>a>>b;
  string ss=a+b;
  int num=stoi(ss);
  int n=sqrt(num);
  if (n*n==num){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
  
}
  

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <unordered_map>
#include <map>
#include <set>
#include <unordered_set>
#include <sstream>
typedef long long ll;
#define F first
#define S second
#define PB push_back
#define MP make_pair

using namespace std;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    //for writing to files
    //freopen('input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int A, B, C;
    cin >> A>> B >> C;
    if (A == 7 && B == 5 && C == 5)
        cout << "YES" << endl;
    else if (A == 5 && B == 7 && C == 5)
        cout << "YES" << endl;
    else if (A == 5 && B == 5 && C == 7)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int N = 1e5 + 10;

typedef struct pp
{
    char name[100];
    int t;
} p;

p Q[N];

int n, q;

int head, tail, elaps = 0;

void enqueue(p x)
{
    Q[tail] = x;
    tail = (tail + 1) % N;
}

p dequeue()
{
    p x = Q[head];
    head = (head + 1) % N;
    return x;
}

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

    cin >> n >> q;

    head = 1, tail = n + 1;

    for(int i = 1; i <= n; i++) cin >> Q[i].name >> Q[i].t;

    p u;
    int c;

    while(head != tail)
    {
        u = dequeue();
        c = min(q, u.t);
        u.t -= c;
        elaps += c;
        if(u.t > 0)
            enqueue(u);
        else
            cout << u.name << " " << elaps << endl;
    }

    return 0;
}


Measured memory_bytes: 13300
#include <iostream>

using namespace std;

int main() {
  int arr[4] = { 0, 0, 0, 0 };
  int a, b;
  for (int i = 0; i < 3; ++i) {
    cin >> a >> b;
    ++arr[a - 1];
    ++arr[b - 1];
  }
  for (int i = 0; i < 4; ++i) {
    if (arr[i] >= 3) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	static final Scanner s = new Scanner(System.in);
	public static void main(String args[]) {
		long sum=0,t=s.nextLong(),i=0;
		while(sum<t) {
			i++;
			sum+=i;
		}
		System.out.println(i);
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>   //PBDS
#include <ext/pb_ds/tree_policy.hpp>       //PBDS
#define int long long int
#define vi vector<int>
#define vii vector<pair<int,int>>
#define pi pair<int,int>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define mi map<int,int>
#define PI   3.141592653589
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define f(i,x,n) for(int i=x;i<n;i++)
#define rf(i,x,n) for(int i=n-1;i>=x;i--)
#define check(x)   cerr<<#x<<" : "<<x<<endl;
#define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
#define fbo find_by_order                    //return iterator PBDS
#define ook order_of_key                     //return number :)) PBDS
#define baar exit(0)
#define INF 1000000000000000000
using namespace __gnu_pbds;
using namespace std;
int powmod(int base,int exponent,int mod)
{
	int ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
signed main()
{
	fast
	int n;
	cin>>n;
	int x,y,z;
	cin>>x>>y>>z;
	int dp[n][3];
	dp[0][0]=x;
	dp[0][1]=y;
	dp[0][2]=z;
	f(i,1,n)
	{
		int x,y,z;
		cin>>x>>y>>z;
		dp[i][0]=x+max(dp[i-1][1],dp[i-1][2]);
		dp[i][1]=y+max(dp[i-1][0],dp[i-1][2]);
		dp[i][2]=z+max(dp[i-1][0],dp[i-1][1]);
	}
	cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
	return 0;
}

Measured memory_bytes: 5952
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> inline bool chmin(T&x,T y){if(x>y){x=y;return true;}return false;}
template<class T> inline bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
 ll x,y,z,a,b,c;
 cin>>x;
 y=100;
 z=0;
 while (y<x){
     a = y/100;
     y = y+a;
     ++z;
 }
 cout<<z;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T&a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T&a,T b){if(a>b){a=b;return 1;}return 0;}
using ll = long long;
using P = pair<int,int>;

ll n,m,sum;
string s,t;

int main() {
  cin >> n >> m;
  if(n<abs(n-m)) 
  cout << n << endl;
  else if(n%m==0)
  cout << 0 << endl;
  else{
    n=n%m;
    cout << (n<abs(n-m) ? n : abs(n-m)) << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int R; cin >>R;
  double ans = R*2*M_PI;
  printf("%.10f\n", ans);
  return 0;
}

Measured memory_bytes: 3760
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#include<stdio.h>
#include<functional>
#include<queue>

using ll = long long;

using namespace std;

ll mod = 1000000007;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	t %= mod;
	if (n % 2 == 1)t *= a;
	return t % mod;
}

const int INF = 1001001001;
//const ll INF = 1e18;

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


int main() {
	int n;
	cin >> n;
	vector<double>p(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	vector<vector<double>>dp(n + 1, vector<double>(n + 1, 0));
	dp[0][0] = 1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < i + 1; j++) {
			dp[i + 1][j] += dp[i][j] * (1 - p[i]);
			if (j + 1 < n + 1)dp[i + 1][j + 1] += dp[i][j] * p[i];
		}
	}
	double ans = 0;
	for (int i = n / 2 + 1; i <= n; i++) {
		ans += dp[n][i];
	}
	printf("%.10f\n", ans);
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define sz(c) int((c).size())
#define all(c) (c).begin(), (c).end()
#define pb push_back

#define INF int(1e9)
#define EPS 1e-9
#define MOD int(1e9 + 7)

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int r;
	cin >> r;
	cout << (r * r * 3) << '\n';
	return 0;
}


Measured memory_bytes: 384
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto a = RD;

	writeln(a + a^^2 + a^^3);
	stdout.flush;
	debug readln;
}


Measured memory_bytes: 2716
def main():
    from itertools import accumulate

    n, *a = map(int, open(0).read().split())
    x = list(accumulate(a[:n]))
    y = list(accumulate(a[n:][::-1]))
    ans = max(x[i] + y[n - i - 1] for i in range(n))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

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

  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];

  int answer {};
  vector<int> B = A;
  rep(i, N) {
    while (B[i]%2==0) {
      B[i]/=2;
      ++answer;
    }
  }
  cout << answer << '\n';
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int N; cin >> N;

    rep(h, 1, 3501){
        rep(w, 1, 3501){
            if(4LL * h * w - N * w - N * h > 0){
                double n = 1.0 * N * h * w / (4.0 * h * w - N * w - N * h);
                if((ll)(n) > n - EPS){
                    cout << h << " " << (ll)n << " " << w << endl;
                    return 0;
                }
            }
        }
    }
    assert(false);
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF LLONG_MAX/10
#define rep(i,n) for(int i=0;i<n;i++)
#define krep(i,k,n,m) for(int i=k;i<n;i+=m)
#define erep(i,k,n) for(int i=k;i<n;i++)
#define mod 1000000007
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
    int n;
    cin>>n;
    int w=1,ans=0;
    if(n==1){
        cout<<1<<endl;
        return 0;
    }
    while(1){
        ans+=w;
        w=w*2;
        n=n/2;
        if(n==1){
            break;
        }
    }
    cout<<ans+w<<endl;
}


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

int main(){
    int X;
    cin>>X;
    if(X<0)X=-X;
    int ans=0;
    int sum=0;
    for(int i=1;sum<X;i++){
        sum+=i;
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  ll K,A,B;
  cin >> K >> A >> B;
  if(B-A<=2 || K<=A) {
    cout << K+1<<endl;
    return 0;
  }
  K -= A-1;
  ll ans = (B-A)*(K/2) + A;
  if(K%2 != 0) {
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	cin >> N;
	map<int,int> a;
	for (int i = 1; i < 50000; ++ i) {
		int j = i * 108 / 100;
		a[j] = i;
	}
	if (a.count(N)) {
		cout << a[N] << endl;
	} else {
		cout << ":(" << endl;
	}
}


Measured memory_bytes: 2560
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

def LI(): return list(map(int, stdin.readline().split()))
def LS(): return list(stdin.readline())

k = int(input())
a,b = LI()

for i in range(a, b+1):
    if i%k==0:
        print('OK')
        sys.exit()
    else:
        pass
print('NG')

Measured memory_bytes: 9132
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a[] = new int[n];
    int ans = 0;

    for(int i=0 ; i<n ; i++){
      a[i] = sc.nextInt();
    }
    Arrays.sort(a);
    ans = Math.abs(a[0]-a[n-1]);
    System.out.println(ans);
  }
}


Measured memory_bytes: 21844
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
b.append(0)
res=0
ans=0
for i in range(n+1):
  if res >= a[i]:
    ans += a[i]
    res = b[i]
  elif res + b[i] >= a[i]:
    ans += a[i]
    res += b[i]
    res -= a[i]
  else:
    ans += res + b[i]
    res = 0
print(ans)


Measured memory_bytes: 18476
from sys import stdin
def stdinput():
    return stdin.readline().strip()

def main():
    altitutes = load_data()

    edges = create_edges(altitutes)

    # print(*edges)

    areas = calc_areas(altitutes, edges)

    print(int(sum(areas)))
    print(*([len(areas)] + [*map(int, areas)]))

def load_data():
    A = [0]
    for s in stdinput():
        if s == '\\':
            A.append(A[-1] - 1)
        elif s == '_':
            A.append(A[-1])
        elif s == '/':
            A.append(A[-1] + 1) 
    return A

def create_edges(A):
    st = [(0, None, 0)]
    highest = 0
    for i, a in enumerate(A[1:], 1):
        if st[-1][0] >= a:
            st.append((a, st[-1][2], i))
        else:
            begin = i - 1
            # NOTE: concat edges
            # this operation is performed every upforward(/) step,
            # and previous concated edges have altitute of (a - 1).
            while st[-1][1] != None and st[-1][0] == a - 1 and highest >= a:
                lev, begin, j = st.pop()
            highest = max(highest, a)
            st.append((a, begin, i))
        # print(*st)
    return [*map(lambda e: e[1:], st[1:])]

def calc_areas(A, edges):
    areas = []
    for begin, end in edges:
        area = calc_area(A, begin, end)
        if area > 0:
            areas.append(area)
    return areas    

def calc_area(A, begin, end):
    if A[begin] != A[end]:
        return 0
    b_level = A[begin]
    area = 0
    for l1, l2 in zip(range(begin, end), range(begin+1, end + 1)):
        a1 = A[l1]
        a2 = A[l2]
        area += (b_level - a1 + b_level - a2) * 1 / 2
    return area

if __name__ == '__main__':
    main()
    # import cProfile
    # cProfile.run('main()')


Measured memory_bytes: 10640
#include <stdio.h>
#define N 100000

typedef struct pp{
    char name[100];
    int time;
}P;

P Q[N];
int head, tail,n;

void enqueue(P x){
    Q[tail]=x;
    tail=(tail+1)%N;
}

P dequeue(){
    P x=Q[head];
    head =(head+1)%N;
    return x;
}

int min(int a, int b){ return a<b ?a:b;} //最小返す
    
int main(){
    int elaps=0,c;
    int i,q;
    P u;
    scanf("%d%d",&n,&q);

//全プロセスをキューに順に追加
    

for(i=1;i<=n;i++){
    scanf("%s %d",Q[i].name,&Q[i].time);
}
    head=1;
    tail=n+1;
    
    while(head != tail){
        u=dequeue();
        c=min(q,u.time); //qまたは必要な時間u.timeだけ処理する
        u.time-=c;//残りの必要時間
        elaps+=c;//経過時間たす
        if(u.time>0) enqueue(u);
        else{
            printf("%s %d\n",u.name,elaps);
        }
    }
    return 0;
}


Measured memory_bytes: 11948
#include<bits/stdc++.h>
using namespace std;
int main (){
  int n,k;
  cin >> n >> k;
  vector<int> l(n);
  for(int i = 0;i<n;i++){
    cin >> l[i];
  }
  sort(l.rbegin(),l.rend());
  int ans;
  ans = 0;
  for(int i=0;i<k;i++){
    ans+=l[i];
  }
  cout<<ans<<endl;
  return 0;
}

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

const int maxn=2e5;
int n,m,t,h[maxn],f[maxn];
bool mark[maxn],ans[maxn];
vector<int>G[maxn];

void dfs(int v)
{
  mark[v]=true;
  f[v]=h[v];
  for(int i=0;i<G[v].size();i++)
    {
      int u=G[v][i];
      if(!mark[u])
	{
	  h[u]=h[v]+1;
	  dfs(u);
	  if(v==0) t++;
	  if(v!=0 && f[u]>=h[v])
	    ans[v]=true;
	  f[v]=min(f[v],f[u]);
	}
      else if(h[u]<h[v]-1)
	f[v]=min(f[v],h[u]);
    }
}

int main()
{
  ios_base::sync_with_stdio(false);cin.tie(0);
  cin>>n>>m;
  for(int i=0;i<m;i++)
    {
      int v,u;
      cin>>v>>u;
      G[v].push_back(u);
      G[u].push_back(v);
    }
  dfs(0);
  if(t>1) ans[0]=true;
  for(int i=0;i<n;i++)
    if(ans[i]) cout<<i<<endl;
}

Measured memory_bytes: 9196
// Author - Vennu_Mallesh 
// When you fire the fire, fire will be fired, I am fire (x3) I am the fire

#include <bits/stdc++.h>

using namespace std;

vector <int> primes;
bool prime[15000001];
int ans;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,in;
    cin >> n;
    int counte[100001]={0};
    int counto[100001]={0};
    vector <pair<int,int>> refo,refe;
    for(int i = 0 ; i < n ; i++)
    {
        cin >> in;
        if(i%2==0)
        {
            counte[in]++;
            //cout << counte[in] << "\n";
        } 
        else
        {
            counto[in]++;
            //cout << counto[in] << "\n";
        }
    }
    for(int i = 1 ; i < 100001 ; i++)
    {
        refo.push_back(make_pair(counto[i],i));
        refe.push_back(make_pair(counte[i],i));
    }
    sort(refo.begin(),refo.end());
    sort(refe.begin(),refe.end());
    //cout << refo[100000].second << " " << refe[100000].second << "\n";
    if(refo[99999].second!=refe[99999].second)
    {
        //cout << "lol";
        cout << (n)-(refo[100000-1].first + refe[100000-1].first) << "\n";
    }
    else if(n==2)
    {
        cout << "1" << "\n";
    }
    else
    {
        cout << min((n)-(refo[99999-1].first + refe[100000-1].first),(n)-(refo[100000-1].first + refe[99999-1].first)) << "\n";
    }
    return 0;
}

Measured memory_bytes: 2804
#include<cstdio>
#include<cstring>
#include<algorithm>
const int N=500005;
int n,ans,a[N];
char s[N];
void gao(int up){
	ans++;
	for(int i=1;i<up;i++){
		if(a[i]<10){
			break;
		}
		a[i+1]+=a[i]/10;
		a[i]%=10;
	}
}
int main(){
	fread(s+1,500000,1,stdin);
	n=strlen(s+1);
	while(s[n]=='\r'||s[n]=='\n'){
		n--;
	}
	for(int i=1;i<=n;i++){
		a[i]=s[n-i+1]-'0';
	}
	for(int i=n,j=n,tot=0;i>1;i--){
		if(a[i]==a[i+1]){
			tot++;
		}else{
			tot=1;
		}
		if(a[i]>a[i-1]){
			if(tot==1){
				a[1]++;
				j=i-1;
				gao(j);
			}else if(i+tot-1==j){
				while(j>=i){
					if(a[i-1]>=a[i]){
						break;
					}
					a[1]++;
					j--;
					gao(j);
				}
				a[j+1]=0;
				i=j+1;
			}else{
				j=i+tot-2;
				a[1]++;
				gao(j);
				a[j+1]=0;
				i=j+1;
			}
		}
	}
	printf("%d\n",ans+1);
	return 0;
}

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

using ll=long long;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<ll> A(n);
  rep(i,n) cin >> A[i];
  ll ans = 0;
  rep(i,n)rep(j,n) ans = max(ans,abs(A[i]-A[j]));
  cout << ans << endl;
}

Measured memory_bytes: 256
def str_to_ary str
  appeared = ""
  ans = []
  str.chars.each do|ch|
    if appeared.include?(ch)
      ans << appeared.index(ch)
    else
      appeared += ch
      ans << appeared.index(ch)
    end
  end
  return ans
end

s = gets
t = gets

ans = "No"
ans = "Yes" if str_to_ary(s)==str_to_ary(t)
puts ans

Measured memory_bytes: 25588
#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;
#define int long long int
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define ff first
#define endl "\n"
#define ss second
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res % p;
}
int n, q;
int fn[1000005];
void update(int i, int add)
{
    while (i > 0 && i < n+1)
    {
        fn[i] += add;
        i = i + (i & (-i));
    }
}
int sum(int i)
{
    int s = 0;
    while (i > 0)
    {
        s = s + fn[i];
        i = i - (i & (-i));
    }
    return s;
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tc;
    tc = 1; // cin >> tc;
    while (tc--)
    {
        int r, c;
        cin >> r >> c;
        int dp[r][c];
        string s[r];
        for (int i = 0; i < r;i++){
            cin >> s[i];
        }
        dp[0][0] = 0;
        if(s[0][0]=='#'){
            dp[0][0] = 1;
        }
        for (int i = 1; i < c;i++){
            int f = 0;
            if(s[0][i]=='#'&&s[0][i-1]=='.')
                f = 1;
            dp[0][i] = dp[0][i - 1] + f;
        }
        for (int i = 1; i < r;i++){
            int f = 0;
            if (s[i][0] == '#'&&s[i-1][0]=='.')
                f = 1;
            dp[i][0] = dp[i - 1][0] + f;
        }
        for (int i = 1; i <r;i++){
            for (int j = 1; j <c;j++){
                int f = 0;
                if(s[i][j]=='.')
                dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]) + f;
                else
                    dp[i][j] = min(dp[i - 1][j] + (s[i - 1][j] == '.'), dp[i][j - 1] + (s[i][j - 1] == '.'));
            }
        }
        // for (int i = 0; i < r; i++)
        // {
        //     for (int j = 0; j < c; j++)
        //     {
        //         cout << dp[i][j] << " ";
        //     }
        //     cout << endl;
        // }
        cout << dp[r - 1][c - 1] << endl;
    }

    return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}



void _main() {
        ll n, m; cin >> n >> m;
        auto solve2r = [](ll n, ll m) -> array<ll, 2> {
                int a = n / 2, b = n - n / 2;
                return array<ll, 2>{(ll)a * m, (ll)b * m};
        };


        auto solve3 = [&](ll n, ll m) -> ll {
                ll ans = n * m;
                for (ll row = 1; row <= n-1; row++) {
                        ll up = row * m;
                        ll d1 = solve2r(n - row, m)[0], d2 = solve2r(n - row, m)[1];
                        ans = min(ans, max({up, d1, d2}) - min({up, d1, d2}));
                        assert(up + d1 + d2 == (ll)n * m);
                        d1 = solve2r(m, n - row)[0], d2 = solve2r(m, n - row)[1];
                        ans = min(ans, max({up, d1, d2}) - min({up, d1, d2}));
                        assert(up + d1 + d2 == (ll)n * m);
                }
                return ans;
        };


        cout << min(solve3(m, n), solve3(n, m)) << '\n';
}




signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
		
		int n = Integer.parseInt(input.readLine());
		int i = 0 , taroPo = 0 , hanakoPo = 0 ;
		while(i != n){
			i++;
			String str = input.readLine();
			String taro = str.substring(0,str.indexOf(' '));
			String hanako = str.substring(str.indexOf(' ') +1);
			
			if(taro.compareTo(hanako) < 0) hanakoPo += 3;
			else if(taro.compareTo(hanako) > 0) taroPo += 3;
			else { 
				taroPo ++;
				hanakoPo ++;
			}
		}
		
		System.out.println(taroPo + " " + hanakoPo);
		
	}

}

Measured memory_bytes: 16992
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main(void){
    int n, s[1010];
    while(cin >> n){
        if(n == 0)  break;
        double sum = 0, m = 0;
        for(int i = 1; i<=n; i++){
            cin >> s[i];
            m += s[i];
        }
        m = m/n;
        for(int i = 1; i<=n; i++){
            sum += (s[i] - m)*(s[i] - m);
        }
        cout << fixed;
        cout << setprecision(9) << sqrt(sum/n) << endl;
    }
    return 0;
}



Measured memory_bytes: 3228
N = gets.to_i
z = readlines(chomp:true).map{|line| line.split.map(&:to_i)}
num = (1..N).to_a    #必ずこれを作ってからpermutation
per = num.permutation(N).to_a     #これで各順列を全て配列perに格納した
dis = 0
for i in 0.. per.size-1
  new = per[i]
  for k in 0..N-2
    x = z[(new[k]-1)][0]-z[(new[k+1]-1)][0]
    y = z[(new[k]-1)][1]-z[(new[k+1]-1)][1]
    dis += Math.sqrt(x**2+y**2)
  end
end
puts dis.to_f/per.size

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

using namespace std;

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

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

  for (int i=0; i<n; i++) {
    a[i] -= i+1;
  }

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

  int b_idx = a.size() / 2;
  int b = a[b_idx];

  int64_t ans = 0;
  for (int i=0; i<n; i++) {
    ans += abs(a[i] - b);
  }

  if (a.size() % 2 == 0) {
    int64_t sum = 0;
    b = a[b_idx-1];
    for (int i=0; i<n; i++) {
      sum += abs(a[i] - b);
    }
    if (ans > sum) {
      ans = sum;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
def Partition(A, p, r):
    x = A[r]
    i = p - 1

    for j in range(p, r):
        if A[j] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]

    A[i + 1], A[r] = A[r], A[i + 1]

    return i + 1

def Main():
    n = int(input())
    A = [int(a) for a in input().split()]

    idx = Partition(A, 0, n - 1)
    s_A = [str(a) for a in A]
    
    res = " ".join(s_A[:idx]) + " [" + s_A[idx] + "] " + " ".join(s_A[idx + 1:])
    print(res)

Main()


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

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        double A[2], B[2], C[2], D[2];
        cin >> A[0] >> A[1] >> B[0] >> B[1] >> C[0] >> C[1] >> D[0] >> D[1];
        double AB[2] = {A[0] - B[0], A[1] - B[1], };
        double CD[2] = {C[0] - D[0], C[1] - D[1], };
        double outerProduct = AB[0] * CD[1] - AB[1] * CD[0];
        if (outerProduct == 0) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
}

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

ls = [0]*N
for i in range(N):
    ls[A[i]-1] += 1
s = 0
for i in range(N):
    s += ls[i]*(ls[i]-1)//2
ans = [0]*N
for i in range(N):
    ans[i] = s-ls[A[i]-1] + 1

print(*ans,sep='\n')
    


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

int main(){
    int S,h,m,s;
    
    cin >> S;
    
    h = S/3600;
    m = S%3600 / 60;
    s = (S%3600)%60;
    
    cout << h<<":"<<m<<":"<<s<<endl;
    
    return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
#define getbit(n, i) (((n) & (1LL << (i))) != 0) 
#define setbit0(n, i) ((n) & (~(1LL << (i)))) 
#define setbit1(n, i) ((n) | (1LL << (i))) 
#define togglebit(n, i) ((n) ^ (1LL << (i))) 
#define lastone(n) ((n) & (-(n))) 
char gap = 32;
template<typename T> 
ostream& operator<<(ostream &os, const vector<T> &v) { 
    os << '{'; 
    for (const auto &x : v) os << gap << x;
        return os << '}'; 
}
template<typename A, typename B> 
ostream& operator<<(ostream &os, const pair<A, B> &p) {
        return os << '(' << p.first << gap << p.second << ')';
}

template <class T>
void read(T &x) {
    char c;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        ;
    for (x = 0; c <= '9' && c >= '0'; c = getchar()) x = x * 10 + (c & 15);
}
#define ll long long 
#define lll __int128_t
#define pb push_back
#define mp make_pair
typedef pair < int,int> ii;
typedef vector<ii> vii;
typedef vector<ll>vl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll hashPrime = 1610612741;
ll cumsum[200005];
ll FirstApp[200005];
ll LastApp[200005];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll i, j, k, l, n, m;
    cin>>n;
    ll data1[n+1],data2[n+1];
    for (i = 1; i <= n;i++)
        cin >> data1[i];
    for (i = 1; i <= n;i++)
        cin >> data2[i];
    for (i = 1; i <= n;i++){
        if(FirstApp[data1[i]]==0){
            FirstApp[data1[i]] = i;
        }
        LastApp[data1[i]] = i;
    }
    for (i = 1; i <= n;i++){
        if(FirstApp[data2[i]]==0)
            continue;
        ll temp1 = (FirstApp[data2[i]] - i + n) % n;
        ll temp2 = (LastApp[data2[i]] - i + n) % n;
        if(temp1<=temp2){
            cumsum[temp1]++;
            cumsum[temp2 + 1]--;
        }
        else{
            cumsum[0]++;
            cumsum[temp2 + 1]--;
            cumsum[temp1]++;
        }
    }
    for (i = 0; i < n;i++)
        cumsum[i] += cumsum[i - 1];
    int flag = 0;
    ll Rsh = -1;
    for (i = 0; i < n;i++){
        if(cumsum[i]==0){
            flag = 1;
            Rsh = i;
            break;
        }
    }
    if(flag==0){
        cout << "No\n";
    }
    else{
        cout << "Yes\n";
        ll res[n + 1];
        for (i = 1; i <= n;i++){
            res[(i - 1 + Rsh) % n] = data2[i];
        }
        for (i = 0; i < n;i++)
            cout << res[i] << " ";
        cout << "\n";
    }
    return 0;
}

Measured memory_bytes: 12912
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
using namespace std;
using i32 = int; using i64 = long long int; using f64 = double; using str = string;
template <typename T> using vec = vector<T>;
template <typename T> using heap = priority_queue<T, vec<T>, greater<T>>;
#define times(n, i) for (i32 i = 0; i < (n); ++i)
#define range(a, b, i) for (i32 i = (a); i < (b); ++i)
#define upto(a, b, i) for (i32 i = (a); i <= (b); ++i)
#define downto(a, b, i) for (i32 i = (a); i >= (b); --i)
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define uniqueall(xs) (xs).erase(unique(all(xs)), (xs).end())
#define even(x) (((x) & 1) == 0)
#define odd(x) (((x) & 1) == 1)
#define head(xs) *(xs).begin()
#define last(xs) *(xs).rbegin()
#define append emplace_back
#define findge lower_bound
#define findgt upper_bound
const i64 MOD = 1000000007;
const f64 EPS = 1e-10;

i64 n, w;
i64 c[100], v[100];
vec<i64> vs[4];
vec<i64> vv[4];

i32 main()
{
    cin >> n >> w;
    times(n, i) {
        cin >> c[i] >> v[i];
    }
    times(n, i) {
        vs[c[i]-c[0]].append(v[i]);
    }
    times(4, i) {
        sortall(vs[i]);
        reverseall(vs[i]);
    }
    times(4, i) {
        vv[i].append(0);
        range(1, 101, j) {
            if (vs[i].size() < j) {
                break;
            }
            else {
                vv[i].append(vv[i][j - 1] + vs[i][j - 1]);
            }
        }
    }
    i64 ans = 0;
    times(vv[0].size(), i) {
        times(vv[1].size(), j) {
            times(vv[2].size(), k) {
                times(vv[3].size(), l) {
                    if (c[0]*i + (c[0]+1)*j + (c[0]+2)*k + (c[0]+3)*l > w) break;
                    ans = max(ans, vv[0][i] + vv[1][j] + vv[2][k] + vv[3][l]);
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<ll, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 400010;
const int MAXM = 100010;
const int MAXK = 510;

int n, m, k;
ll gt[MAXN], rev[MAXN];

ll getK(ll k) {
    return k * (k - 1) / 2 % MODBASE;
}

ll mu(ll a, ll b) {
    if (b == 0) return 1;
    if (b == 1) return a % MODBASE;
    ll g = mu(a, b/2);
    if (b % 2) return g * g % MODBASE * a % MODBASE;
    return g * g % MODBASE;
}

ll C(ll n, ll k) {
    if (k > n) return 0;
    if (n < 0) return 0;
    return gt[n] * rev[n-k] % MODBASE * rev[k] % MODBASE;
}

ll tinh(ll g) {
    return g * (g + 1) / 2 % MODBASE;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> m >> k;
    ll calc = getK(k);
    
    gt[0] = 1;
    rev[0] = mu(gt[0], MODBASE-2);
    FOR(i,1,400000) {
        gt[i] = gt[i-1] * i % MODBASE;
        rev[i] = mu(gt[i], MODBASE-2);
    }

    ll other = C(n * m - 2, k - 2);

    ll res = 0;
    FOR(i,1,n) {
        ll h = tinh(n-i);
        ll z = h * m % MODBASE;
        res = (res + z * other % MODBASE * m % MODBASE) % MODBASE;
    }
    FOR(i,1,m) {
        ll h = tinh(m-i);
        ll z = h * n % MODBASE;
        res = (res + z * other % MODBASE * n % MODBASE) % MODBASE;
    }

    cout << res;
    return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
int LCD(int a,int b){
	if(a<b) swap(a,b);
	while(b){
		int t = a%b;
		a = b;
		b = t;
	}
	return a;
}
int main(){
	int n,x;
	cin>>n>>x;
	vector<int>arr(n);
	for(int i=0; i<n; i++) cin>>arr[i];
	arr.push_back(x);
	sort(arr.begin(),arr.end());
	vector<int>diff;
	for(int i=1; i<arr.size(); i++) diff.push_back(arr[i]-arr[i-1]);
	int lcd = diff[0];
	for(int i=1; i<diff.size(); i++) lcd = LCD(lcd,diff[i]);
	cout<<lcd;
}

Measured memory_bytes: 4552
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main() {
  auto n = readln.strip.to!int;
  Tuple!(string, int)[] a;
  foreach (i; 0 .. n) {
    auto s = readln.splitter;
    auto z = s.front;
    s.popFront ();
    a ~= tuple (z, s.front.to!int);
  }
  auto t = readln.strip;
  int res;
  foreach_reverse (i; 0 .. n) {
    if (a[i][0] == t) break;
    res += a[i][1];
  }
  writeln (res);
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int h, w;
    int lh, lw;

    scanf("%d %d", &lh, &lw);
    scanf("%d %d", &h, &w);

    printf("%d", lh*lw - (h*lw + w*lh - (h*w)));

    return 0;

}

Measured memory_bytes: 128
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template<typename T,typename Y>
ostream& operator<<(ostream& os,const pair<T,Y>& p){
   return os<<"{"<<p.fs<<","<<p.sc<<"}";
}
template<typename T> ostream& operator<<(ostream& os,const V<T>& v){
   os<<"{";
  for(auto e:v)os<<e<<",";
  return os<<"}";
}
template<typename ...Args>
void debug(Args&... args){
  for(auto const& x:{args...}){
    cerr<<x<<' ';
  }
  cerr<<ENDL;
}



signed main(){
  cin.tie(0);cerr.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll n;cin>>n;

  V<ll> v(4,0);
  V<string> s={"AC","WA","TLE","RE"};
  rep(i,0,n){
    string t;cin>>t;
    rep(j,0,4){
      if(s[j]==t){
        v[j]++;
        break;
      }
    }
  }

  rep(i,0,4){
    cout<<s[i]<<" x "<<v[i]<<ENDL;
  }

  
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 3660