akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>


ll h, w, n, nowx, nowy, x, y;
string a, b;
int main() {
	cin >> h >> w >> n;
	cin >> x >> y;
	x--;
	y--;
	cin >> b;
	cin >> a;
	
	nowx = x;
	nowy = y;
	REP(i, n) {
		if (b[i] == 'R')nowy++;
		if (nowy >= w) {
			cout << "NO" << endl;
			return 0;
		}
		if (a[i] == 'L' and nowy != 0)nowy--;
	}
	nowx = x;
	nowy = y;
	REP(i, n) {
		if (b[i] == 'L')nowy--;
		if (nowy < 0) {
			cout << "NO" << endl;
			return 0;
		}
		if (a[i] == 'R' and nowy != w - 1)nowy++;
	}
	nowx = x;
	nowy = y;
	REP(i, n) {
		if (b[i] == 'D')nowx++;
		if (nowx >= h) {
			cout << "NO" << endl;
			return 0;
		}
		if (a[i] == 'U' and nowx != 0)nowx--;
	}
	nowx = x;
	nowy = y;
	REP(i, n) {
		if (b[i] == 'U')nowx--;
		if (nowx < 0) {
			cout << "NO" << endl;
			return 0;
		}
		if (a[i] == 'D' and nowx != h - 1)nowx++;
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 776
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int fib[100];
int main(){
	int n;
	cin>>n;
	fib[0]=1;
	fib[1]=1;
	//fib[2]=1;
	for(int i =2;i <= n;i++){
		fib[i]=fib[i-1]+fib[i-2];
	}
	cout <<fib[n]<<endl;
	return 0;
}

Measured memory_bytes: 1164
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <string.h>
using namespace std;

#define ISEQ(c) (c).begin(), (c).end()
typedef long long ll;

int main() {
  int w, n;
  cin >> w >> n;
  int c[w];
  for (int i = 1; i <= w; i++)
    c[i-1] = i;

  for (int i = 0; i < n; i++) {
    int a, b;
    scanf("%d,%d", &a, &b);
    swap(c[a-1], c[b-1]);
  }

  for (int i = 0; i < w; i++)
    cout << c[i] << endl;
}

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

fn parse_line<T: FromStr>() -> T {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn parse_line_vec<T: FromStr>() -> Vec<T> {
    let line = parse_line::<String>();
    line.split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

fn println<T: ToString>(s: T) {
    println!("{}", s.to_string());
}

// ------------------------------------------------------------------------

fn main() {
    let _n = parse_line::<usize>();
    let a = parse_line_vec::<f64>();

    let result = 1.0 / a.into_iter().map(|n| 1.0 / n).sum::<f64>();

    println(result);
}


Measured memory_bytes: 4352
#cited from ppunchi
X, N = map(int, input().split())
p = list(map(int, input().split()))
l = X - 1
r = X + 1
if not X in p:
    print(X)
    exit()
while True:
    if not l in p:
        print(l)
        break
    elif not r in p:
        print(r)
        break
    l -= 1
    r += 1


Measured memory_bytes: 9176
// AOJ 0220
#include <iostream>
#include <string>
#include <algorithm>
#include <map>

using namespace std;

int main()
{
	double n;
	while (cin >> n, n >= 0){
		string ret;
		int a = (int)n;
		while (a != 0){
			if (a == 1){
				ret += '1';
				break;
			}
			if (a % 2 == 0){
				a /= 2;
				ret += '0';
			}
			else {
				a /= 2;
				ret += '1';
			}
		}
		// cout << ret.length() << endl;
		for (int i = ret.length(); i < 8; i++) ret += '0';
		// cout << ret.length() << endl;
		reverse(ret.begin(), ret.end());
		ret += '.';

		string ret2;
		int cnt = 0;
		bool f = true;
		n -= (int)n;
		while (n != 0){
			if (cnt > 4){
				f = false;
				break;
			}
			n *= 2.0;
			if (n >= 1.0){
				ret2 += '1';
				n -= 1.0;
			}
			else {
				ret2 += '0';
			}
			// cout << n << endl;
			cnt++;
		}
		for (int i = ret2.length(); i < 4; i++) ret2 += '0';
		// reverse(ret2.begin(), ret2.end());

		// cout << ret << ret2 << endl;
		if (!f){
			cout << "NA" << endl;
		}
		else {
			cout << ret << ret2 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1224
#include <stdio.h>

long long int gcd(long long int m, long long int n)
{
        if(n == 0)
                return m;
        else
                return gcd(n, m%n);
}

long long int lcm(long long int m, long long int n)
{
        return m * n / gcd(m,n);
}


int main()
{
        long long int m, n;
        while(scanf("%lld%lld", &m, &n) != EOF) {
                printf("%lld %lld\n", gcd(m,n), lcm(m,n));
        }
        return 0;
}

Measured memory_bytes: 596
/*
ID: markusz1
TASK: template
PROG: template
LANG: C++
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ul;
typedef priority_queue<int> p_int_max; // top is max
typedef priority_queue<int, vector<int>, greater<int> >p_int_min; // top is min
typedef priority_queue<ll> p_ll;
typedef priority_queue<double> p_double;

int n,m, temp;
ll sum;
p_int_max a;

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

	cin >> n >> m;
	for (int i=0;i<n;i++){
		cin >> temp;
		a.push(temp);
	}
	for (int i=0;i<m;i++){
		temp = a.top();
		a.pop();
		a.push(temp/2);
	}
	for (int i=0;i<n;i++){
		sum += a.top();
		a.pop();
	}
	cout << sum << endl;

}

Measured memory_bytes: 892
#pragma GCC optimize("Ofast")
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <functional>
#include <math.h> 
#define enld '\n'
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
// constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
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; }
// ---------------------------------------------------------------------------



int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<ll> A(N);
  for(int i=0; i<N; i++) cin >> A[i];
  ll ans = 0;
  for(int i=0; i<N; i++){
    for(int j=i+1; j<N; j++){
      for(int k=j+1; k<N; k++){
        if(A[i]==A[j] || A[j]==A[k] || A[k]==A[i]) continue;
        ll mx = max({A[i],A[j],A[k]});
        ll sum = A[i] + A[j] + A[k];
        if(sum-mx > mx){
          ans++;
        }
      }
    }
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 3660
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

n = ri()
ls = ril()
if 1 not in ls:
    print(-1)
    exit()
res = 0
prev = 0
for x in ls:
    if x == prev + 1:
        prev = x
    else:
        res += 1
print(res)

Measured memory_bytes: 25456
#include<iostream>
#include<vector>
using namespace std;
#define rep(N) for(int i=0;i<N;i++)
#define p(num) printf("%d",num)
#define s(in) scanf("%d",&in)

int main() {
	int A, B, C, K,c=0;
	bool judge = false;
	cin >> A >> B >> C >> K;
	for (;c < K;) {

		if (C >= B) {
			if (C == B) {
				C *= 2;
				c++;
			}
			else if (B <= A) {
				B *= 2;
				c++;
			}
		}
		else if (B > C) {
			C *= 2;
			c++;
		}
		else if (B < A) {
			B *= 2;
			c++;
		}

		if (B > A && C > B) {
			cout << "Yes" << endl;
			judge = true;
			break;
		}
	}
	if (!judge)cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3588
#include <cstdio>

int
solve(int n, int x)
{
  int i, j, k, cnt;

  cnt = 0;
  for (i = 1; i <= n - 2; i++) {
    for (j = i + 1; j <= n - 1; j++) {
      for (k = j + 1; k <= n; k++) {
        if (i + j + k == x) cnt++;
      }
    }
  }

  return cnt;
}

int
main(void)
{
  int n, x, result;

  while (std::scanf("%d %d", &n, &x) != EOF) {
    if (n == 0 && x == 0) break;
    result = solve(n, x);
    std::printf("%d\n", result);
  }

  return 0;
}



Measured memory_bytes: 2712
while True:
    
    H,W = map(int,input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        for k in range(W):
            if(i+k)%2 == 0 :
                print("#",end = "")
            else :
                print(".",end = "")
        print()
    print()


Measured memory_bytes: 7000
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
#include<cstdlib>
#include<ctime>
#include<vector>
#include<map>
using namespace std;

int main(){
//srandom((unsigned long)time(NULL));

int k,s;
cin>>k>>s;

int cnt=0;

for(int x=0;x<=k;x++){
    for(int y=0;y<=k;y++){
        if(0<=s-x-y && s-x-y<=k)cnt+=1;
    }
}

cout<<cnt<<endl;

return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sz(x) ((int)(x).size())
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
using namespace std;
 
typedef long long lld;
typedef vector<lld> vlld;
typedef pair<lld,lld> pi;
typedef tuple<lld,lld,lld> tup;
const lld mod=(lld)1e9+7,maxN=1e5+5,inf=1e18;
 

 void solve()
 {
 	lld n,W;
 	cin>>n>>W;
 	lld w[n],v[n];
 	forn(i,n)
 	cin>>w[i]>>v[i];
    lld dp[maxN];
    forn(i,maxN)dp[i]=inf;
    dp[0]=0;
    lld ans=0;
    for(lld i=0;i<n;i++)
    {
    	 for(lld j=maxN-1;j>=v[i];j--)
    	 {
    	 	if(dp[j-v[i]]+w[i]<=W)
    	 	{
    	 	dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
    	 	ans=max(ans,j);
    	     }
    	 }
    }
    cout<<ans<<"\n";
 }
 
int main() {

	lld t;
	t=1;
	// cin>>t;
	while(t--)
	{
    
    solve();

	}
  
  return 0;
}

Measured memory_bytes: 4416
N, M= map(int, input().split())
ABC = [list(map(int,input().split())) for _ in range(M)]
# 最短距離を求めるのでワーシャルフロイド法(O(N^3))

inf = float("inf")
dist = [[inf] * N for _ in range(N)]

for a,b,c in ABC:
  a,b = a-1, b-1
  dist[a][b] = c
  dist[b][a] = c

for mid in range(N):
  for start in range(N):
    for end in range(N):
      dist[start][end] = min(dist[start][end],
                 dist[start][mid] + dist[mid][end])
# すべての辺を見て、一致しない辺の個数
ans = 0
for a,b,c in ABC:
  a,b = a-1, b-1
  if dist[a][b] != c:
    ans += 1
print(ans)
                              

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

using namespace std;

typedef long long ll;
#define INF 100000000
#define MOD 1000000007

int main()
{
	const int N = 100;
	int n, k, sum = 0;
	int x[N];
	
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}

	for (int i = 0; i < n; i++) {
		if (x[i] <= k / 2) {
			sum += 2 * x[i];
		} else {
			sum += 2 * (k - x[i]);
		}
	}
	cout << sum << endl;

	return (0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long int pow107 = (int)pow(10, 9) + 7;

bool comp(pair<int, string> a, pair<int, string> b){
    if(a.first != b.first) return a.first > b.first;
    else return a.second < b.second;
}

long int jou(long int x, long int y){
    long int f = 1;
    for(int i = 0; i < y; ++i){
        f = f * x % pow107;
    }
    return f;
}

bool pn(long int x){
    if(x != 2 && x % 2 == 0)
        return false;
    for(int i = 3; i < x; ++i){
        if(x != i && x % i == 0)
            return false;
    }
    return true;
}

long int factorial(long int n){
    long int f = 1;
    for(long int i = 1; i <= n; ++i){
        f = f * i % pow107;
    }
    return f;
}


int main(){
    string a,b;
    cin >> a >> b;
    cout << (a == b ? 'H' : 'D') << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
float a,b,c,d,e,f,x,y;
int main(void)
{
	//freopen("in.txt","rb",stdin);
	while(scanf("%f %f %f %f %f %f",&a,&b,&c,&d,&e,&f)!=EOF)
	{
		y=((c*d)-(a*f))/((b*d)-(a*e));
		x=(c-(b*y))/a;
		printf("%.3f %.3f\n",x,y);
	}
	
	
	return 0;
}

Measured memory_bytes: 648
open Scanf
open Printf

let readInt () = scanf " %d" (fun x -> x)

let divisors x =
  let l = ref [] in
  let r = ref [] in
  let y = ref 1 in
  while !y * !y <= x do
    if x mod !y = 0 then begin
      l := !y :: !l;
      if x <> !y * !y then r := (x / !y) :: !r
    end;
    incr y
  done;
  List.rev !l @ !r

let cost n a d =
  let open Array in
  let a = map (fun x -> x mod d) a in
  fast_sort compare a;
  let tot = fold_left (+) 0 a in
  assert (tot mod d = 0);
  let m = tot / d in
  let def = ref 0 in
  for i=n-m to n-1 do def := !def + d - a.(i) done;
  !def

let solve n k a =
  let tot = Array.fold_left (+) 0 a in
  let divs = divisors tot in
  List.fold_left (fun cur d -> if cost n a d <= k then d else cur) 1 divs

let main () =
  let n = readInt () in
  let k = readInt () in
  let a = Array.init n (fun _ -> readInt ()) in
  printf "%d\n" (solve n k a)

let () = main ()


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

int main() {
  int n;
  string s;
  cin >> n >> s;
  int w_sum = 0, b_sum = 0;
  int i;
  for (i = 0; i < n; i++) {
    if (s.at(i) == '#') {
      b_sum++;
    } else {
      w_sum++;
    }
  }

  int left_b = 0, right_w = w_sum;
  int result = min(b_sum, w_sum);


  for (i = 0; i < n; i++) {;
    if (s.at(i) == '#') {
      left_b++;
    } else {
      right_w--;
    }
    result = min(result, (left_b + right_w));
  }
  cout << result << endl;
  return 0;
}


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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    map<int, int> memo;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        memo[a]++;
    }

    ll ans = 0;
    for (auto& p : memo) {
        if (p.second < p.first) ans += p.second;
        else ans += p.second - p.first;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4736
#!/usr/bin/env python3
n, h, *A = map(int, open(0).read().split())
a = max(A[::2])
b = sorted(A[1::2])[::-1]
for i in range(n):
    if h <= 0:
        print(i)
        exit()
    if b[i] < a:
        print(i - (-h // a))
        exit()
    h -= b[i]
print(n - (-h // a))


Measured memory_bytes: 110392
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 998244353;



///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

int N;
int D[112345];
int cnt[112345];
int num = 1;
ll ans = 1;

int main(){
    
    cin>>N;
    
    REP( i, N ) scanf("%d", D+i );
    
    if( D[0] == 0 ){
        REP( i, N ) cnt[D[i]]++;
        if( cnt[0] == 1 ){
            FOR( i, 1, N ){
                REP( j, cnt[i] ){
                    ans = (ans*cnt[i-1])%mod;
                }
            }
            cout<<ans<<endl;
        }
        else{
            puts("0");
        }
    }
    else{
        puts("0");
    }


    return 0;
}


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

t = [0] * 110000

for i in range(N):
    a = A[i]
    t[a] += 1

a = sum(A)

B = [0] * Q
C = [0] * Q
for i in range(Q):
    B[i], C[i] = map(int, input().split())

for i in range(Q):
    a = a + (C[i] - B[i]) * t[B[i]]
    t[C[i]] = t[C[i]] + t[B[i]]
    t[B[i]] = 0
    print(a)

Measured memory_bytes: 22120
n,m=map(int,input().split())

a=list(map(int,input().split()))

union=[-1]*n

tree=[[] for _ in range(n)]
for _ in range(m):
    x,y=map(int,input().split())
    tree[x].append(y)
    tree[y].append(x)

cnt=-1
for i in range(n):
    if union[i]==-1:
        stack=[i]
        cnt+=1
        while len(stack)>0:
            tmp=stack.pop()
            union[tmp]=cnt
            for item in tree[tmp]:
                if union[item]==-1:
                    union[item]=cnt
                    stack.append(item)

if cnt==0:
    print(0)
    exit()

cost=[[] for _ in range(cnt+1)]
#print(union)
for i,aa in enumerate(a):
    cost[union[i]].append(aa)

import heapq

del_list=[]
kouho_list=[]

ans=0

#print(cost)
for i in range(cnt+1):
    tmp=min(cost[i])
    ans+=tmp
    del_list.append(tmp)
    kouho_list+=cost[i]
    #print(cost)

#print(cost)
heapq.heapify(kouho_list)
heapq.heapify(del_list)

for _ in range(2*(n-m-1)-(cnt+1)):
    #print(kouho_list,del_list)
    while 1:
        #print(kouho_list,del_list)
        if len(kouho_list)>0:
            tmp=heapq.heappop(kouho_list)
        else:
            print("Impossible")
            exit()
        
        if len(del_list)>0:
            if del_list[0]!=tmp:
                break
            else:
                heapq.heappop(del_list)
        else:
            break
        
    ans+=tmp

print(ans)



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

typedef long long ll;
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)


int main()
{
    optimize();
    long double r, c;
    cin>> r;
    cout<< fixed<< setprecision(20);
    cout<< 2*r*3.1416;
    nl;


    return 0;
}



Measured memory_bytes: 3800
import java.util.HashSet;
import java.util.Scanner;

class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		String ss = sc.next();
		HashSet<Character> set = new HashSet<Character>();
		set.add('A');
		set.add('C');
		set.add('G');
		set.add('T');

		
		int ans = 0;
		int left = 0;
		int right = 1;
		
		while(left <= ss.length()){
			while(!set.contains(ss.charAt(left))){		//左端を動かす
				left++;
				if(left == ss.length()){
					break;
				}

			}

			if(left == ss.length()){
				break;
			}
			right = left;
			while(set.contains(ss.charAt(right))){
				right++;
				if(right == ss.length()){
					break;
				}
			}
			ans = Math.max(ans, right-left);
			
			left = right;
			if(left == ss.length()){
				break;
			}
			
		}
		
		System.out.print(ans);

	}


}


class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return from - otherpair.from;
	}
}




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

using namespace std;

int main(){
  long long H;
  cin >> H;
  
  int count = 0;
  while(H != 1){
    H = H/2;
    ++count;
  }
  ++count;
  
  long long ret = 0;
  for(int i=0; i<count; i++){
    ret = ret * 2 + 1;
  }
  
  cout << ret;
  return 0;
}

Measured memory_bytes: 256
using System;

namespace Abc138
{
    public class QuestionB
    {
        public static void Main(string[] args)
        {
            // 整数の入力
            string[] input = Console.ReadLine().Split(' ');

            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);

            if(b == 1)
            {
                Console.WriteLine(0);
                return;
            }

            int result = 1;
            while (true)
            {
                int count = a;
                count += (a - 1) * (result - 1);
                if (count >= b)
                {
                    break;
                }
                result++;
            }

            Console.WriteLine(result);
        }
    }
}

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

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1e9+7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

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;
}
///////////////////////////////////////////////
/*(._.)*/
int main(){
	string s;
	cin >> s;
	int N = s.length();
	vector<int> dp1(200002);
	vector<int> dp2(200002);

	if (N == 1){
		cout << 1 << endl;
		return 0;
	}

	if (s[0] == s[1]){
		dp1[0] = 1;
		dp2[0] = 0;
		dp1[1] = 1;
		dp2[1] = 1;
	}else{
		dp1[0] = 1;
		dp2[0] = 0;
		dp1[1] = 2;
		dp2[1] = 1;
	}

	FORq(i,2,N-1){
		if (s[i] == s[i-1]){
			dp1[i] = dp2[i-1] + 1;
			dp2[i] = dp1[i-2] + 1;
		}else{
			dp1[i] = dp1[i-1] + 1;
			dp2[i] = dp1[i-2] + 1;
		}
	}

	cout << max(dp1[N-1],dp2[N-1]) << endl;
}


Measured memory_bytes: 2180
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

//ここから編集

const int MAX = 2000010;
long long fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(5);
  
  int N; cin >> N;
  vector<ll> x(N);
  REP(i,N) cin >> x[i];

  COMinit();
  ll ans = 0;
  vector<ll> xx;
  for(int i=0; i<N-1; i++){
    xx.push_back(x[i+1]-x[i]);
  }

  vector<ll> t{1,1,1,3};
  for(ll i=4; i<=N; i++){
    t.push_back((fac[i-2] + (i-1)*t[i-1] % MOD ) % MOD);
  }
  //for(auto e: t) cout << e << endl;

  for(ll i=2; i<=N; i++){
    //cout << t[i] << endl;

    ans += ( (xx[i-2] * t[i]) % MOD * fac[N-1]) % MOD * finv[i-1] % MOD;
    ans %= MOD;
  }
  cout << ans << endl;


}

Measured memory_bytes: 53260
from collections import Counter

def main():
    n=int(input())
    s=Counter(input() for _ in range(n))
    print("AC x", s["AC"])
    print("WA x", s["WA"])
    print("TLE x", s["TLE"])
    print("RE x", s["RE"])

if __name__ == '__main__':
    main()

Measured memory_bytes: 9468
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <complex>

// calculate x%m for x "properly" for all x
long long int mod(long long int x, long long int m);

// calculate inverse of x in mod m
// if there is inverse of x   : return (inverse of x)
// if there is no inverse of x: return 0
long long int mod_inverse(long long int x, long long int m);

// calculate inverse of x in mod m for PRIME m
long long int mod_inverse_Fermat(long long int x, long long int m);

// calculate x^n mod m
long long int fast_power(long long int x, long long int n, long long int m);

// extended euclid gojjohou
long long int euclid_extended(long long int a, long long int b, long long int &x, long long int &y);



long long int MOD = 998244353;

int main(){

  long long int N, tmp;
  std::vector<long long int> D;

  scanf("%lld", &N);
  for(long long int i = 0; i < N; i++){
    scanf("%lld", &tmp);
    D.push_back(tmp);
  }

  // solve problem
  std::vector<long long int> count(N);

  for(long long int i = 0; i < N; i++){
    count[D[i]]++;
  }
  /*std::cerr << "count" << std::endl;
  for(long long int i = 0; i < 10; i++){
    std::cerr << count[i] << " ";
  }std::cerr << std::endl;*/

  if(D[0] > 0 || count[0] > 1){
    std::cerr << "Answer: impossible" << std::endl;
    std::cout << 0 << std::endl;
    return 0;
  }

  long long int ans = 1;
  for(long long int i = 1; i < N; i++){
    for(long long int j = 0; j < count[i]; j++){
      ans *= count[i-1];
      ans = (ans+MOD)%MOD;
    }
    
    /*if(count[i] != 0){
      ans *= fast_power(count[i-1], count[i], MOD);
      ans = (ans+MOD)%MOD;
    }*/
  }

  std::cerr << "Answer: " << std::endl;
  std::cout << ans << std::endl;
  
  return 0;
}


long long int mod(long long int x, long long int m){
  if(x>0){
    return x%m;
  }
  else if(x==0){
    return 0;
  }
  else if((-x)%m == 0){
    return 0;
  }
  else{
    return m - (-x)%m;
  }
}


long long int euclid_extended(long long int a, long long int b, long long int &x, long long int &y){
  long long int d = a;
  if(b != 0){
    d = euclid_extended(b, a%b, y, x);
    y -= (a/b)*x;
  }
  else{
    x = 1;
    y = 0;
  }
  
  return d;
}

long long int mod_inverse(long long int x, long long int m){
  long long int tmp, x_inv, gcd_xm;
  gcd_xm = euclid_extended(x, m, x_inv, tmp);
  // if the inverse is calculate properly
  if(gcd_xm == 1){
    return mod(x_inv, m);
  }
  else{
    //std::cerr << "Error in mod_inverse: there is no inverse of x in mod m" << std::endl;
    return 0;
  }
}

long long int mod_inverse_Fermat(long long int x, long long int m){
  return fast_power(x, m-2, m);
}

long long int fast_power(long long int x, long long int n, long long int m){
  long long int ans = 1;
  
  while(n > 0){
    if(n&1){
      ans = ans * x;
      ans = mod(ans, m);
    }
    x = x*x;
    x = mod(x, m);
    n = n>>1;
  }
  
  return ans;
}


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

if(A.count(A[0]) == N):
  print(0)
  exit()
  
num = []
x = 0
for i in range(min(A),max(A)):
  for a in A:
    x += (a - i)**2
  num.append(x)
  x = 0
print(min(num))

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

#define vi vector<int>
#define pb push_back


bool start[200010]={},goal[200010]={};
int main(){
    int n, m, a, b;
    cin >> n >> m;
    rep(i,m){
        cin >> a >> b;
        if (a == 1){
            start[b]=true;
        }
        if (b == n){
            goal[a]=true;
        }
    }
    rep(i,n+1){
        if (start[i] == true && goal[i] == true){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
        cout << "IMPOSSIBLE" << endl;
        return 0;
}

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

using namespace std;

int main() {
	cin.sync_with_stdio(false);

	string s,t,u;
	getline(cin, s, ',');
	getline(cin, t, ',');
	cin >> u;
	cout << s << " " << t << " " << u << endl;
	return 0;
	
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cstddef>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <iostream>
#include <iomanip>

#define ASDF (1000000007)
#define MODADD(A, B) (A = (A + B) % ASDF)

long modpow(long src, long pow, long mod)
{
    long res = 1;
    while (0 < pow) {
        if (pow % 2 == 1) {
            res = (res * src) % mod;
            pow--;
        }
        src = (src * src) % mod;
        pow /= 2;
    }
    return res;
}

long modinv(long src, long mod)
{
    return modpow(src, mod - 2, mod);
}

long getgcd(long a, long b) {
    while (0 < a && 0 < b) {
        if (a < b)
            b = b % a;
        else
            a = a % b;
    }
    return std::max(a, b);
}
struct mise{
    long a;
    long b;
};
int main(void)
{
    long long tot = 0;
    int i;
    int n;
    long long m;
    std::cin >> n >> m;
    std::vector<mise> miselist;
    for (i = 0; i < n; i++) {
        long a, b;
        std::cin >> a >> b;
        mise mi;
        mi.a = a; mi.b = b;
        miselist.push_back(mi);
    }
    std::sort(miselist.begin(), miselist.end(), [](const mise& m1, const mise& m2) {
        return m1.a < m2.a;
    });
    long long kane = 0;
    for (const mise& mi : miselist) {
        if (m <= mi.b) {
            kane += m * mi.a;
            break;
        }
        kane += mi.a * mi.b;
        m -= mi.b;
    }
    std::cout << kane << std::endl;
    return 0;
}


Measured memory_bytes: 2420
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#define ll long long
#define rep(i, a, b) for(int i = a; i < b; i++)
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i, 0, n) cin >> v[i];
  sort(v.begin(), v.end());
  int sum = 0;
  rep(i, 0, n-1) sum += v[i];
  if(sum <= v[n-1]) cout << "No\n";
  else cout << "Yes\n";
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>
#include <fstream>

using namespace std;
using ll = long long;

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

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

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<int> enum_div(int n) {
    std::vector<int> ret;
    for (int i = 1; i*i <= n; ++i) {
        if (n%i == 0) {
            ret.push_back(i);
            if (i != 1 && i*i != n) {
                ret.push_back(n / i);
            }
        }
    }
    return ret;
}

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

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

struct ToUpper {
    char operator()(char c) { return toupper(c); }
};

struct ToLower {
    char operator()(char c) { return tolower(c); }
};

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

    int N;
    cin >> N;
    vector<double> A(N);
    cin >> A;


    auto solve = [&]() {
        double sum = 0.0;
        REP(i, N) {
            sum += 1.0 / A[i];
        }
        return 1.0 / sum;
    };

    cout << solve() << endl;
    return 0;
}

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

int main()
{
    string num;
    cin >> num;
    int sum = 0;
    for(int i=0; i<num.size(); i++){
        sum += num[i]-'0';
    }
    int n = stoi(num);
    if(n%sum){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int main() {
    int N, M;
    cin >> N >> M;
    int a = min(N, M);
    int b = max(N, M);
    if (a == 1 && b == 1) cout << 1 << endl;
    else if (a == 1) cout << b - 2 << endl;
    else cout << (ll)(a - 2)*(b - 2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 1000000000

void merge(int*,int,int,int,int);
void mergesort(int*,int,int,int);

int L[500000], R[500000], count;

int main()
{
  int n, S[500000], i;
  count = 0;
  scanf("%d",&n);
  for (i = 0; i < n; i++)
    scanf("%d",&S[i]);
  mergesort(S,n,0,n);
  for (i = 0; i < n; i++){
    printf("%d",S[i]);
    if (i < n-1)
      printf(" ");
  }
  printf("\n%d\n",count);
  
  return 0;
}

void merge(int A[], int n, int left, int mid, int right)
{
  int i, j, k;

  for (i = 0; i < mid-left; i++)
    L[i] = A[left+i];
  for (i = 0; i < right-mid; i++)
    R[i] = A[mid+i];
  L[mid-left] = R[right-mid] = N;
  i = j = 0;
  for (k = left; k < right; k++){
    count++;
    if (L[i] <= R[j]){
      A[k] = L[i];
      i++;
    }
    else{
      A[k] = R[j];
      j++;
    }
  }
}

void mergesort(int A[], int n, int left, int right)
{
  int mid;
  if (left+1 < right){
    mid = (left+right)/2;
    mergesort(A,n,left,mid);
    mergesort(A,n,mid,right);
    merge(A,n,left,mid,right);
  }
}



Measured memory_bytes: 5764
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    a, b, k = LI()
    v = []
    for i in range(1, 101):
        if a % i == 0 and b % i == 0:
            v.append(i)
    v = v[::-1]
    print(v[k-1])


main()



Measured memory_bytes: 83720
// class point	の練習（クラスの高度な実装）
#include <iostream>
#include <vector>
#include <algorithm>

typedef long long llong;
using namespace std;



int main() {
	int ans = 0;
	int n, x;

	while (1) {
		cin >> n >> x;
		if (n == 0 && x == 0)break;
		ans = 0;
		for (int i = 1; i <= n - 2; i++) {
			for (int j = i + 1; j <= n - 1; j++) {
				for (int k = j + 1; k <= n; k++) {
					if (i + j + k == x)ans++;
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}



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

int main() {
  ll n;
  cin >> n;
  ll a;
  ll ans[n+1]={};
    for (ll x=1;x<=sqrtl(n-5);x++) {
      for (ll y=1;y<=sqrtl(n-x*x-x-3);y++) {
        for (ll z=1;z<=sqrtl(n-x*x-y*y-x*y-x-y);z++) {
          if (x*x+y*y+z*z+x*y+y*z+z*x<=n) {
            ans[x*x+y*y+z*z+x*y+y*z+z*x]++;
          }
        }
      }
    }
  for (ll i=1;i<=n;i++) {
    cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 3760
n=int(input())
s=set()
yn=1
w=input()
s.add(w)
for i in range(n-1):
    a=w[-1]
    w=input()
    
    if a!=w[0] or w in s:
        yn=0
        break
    s.add(w)
if yn==1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
import sys,collections as cl,bisect as bs,math
sys.setrecursionlimit(100000)
import numpy as np

input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""
np.set_printoptions(precision=20)
a,b,h,k = m()

a = [0,a]

b = [0,b]

degb = np.deg2rad(90-(6 * k))
dega = np.deg2rad(90-(30 * h + 30*(k/60)))



cosb = np.cos(degb)
sinb = np.sin(degb)
cosa = np.cos(dega)
sina = np.sin(dega)



aa = [0,0]
bb = [0,0]

aa[0] = a[0] * cosa - a[1] * sina
aa[1] = a[0] * sina + a[1] * cosa
bb[0] = b[0] * cosb - b[1] * sinb
bb[1] = b[0] * sinb + b[1] * cosb




print(math.sqrt((aa[0]-bb[0])**2 + (aa[1]-bb[1])**2))










Measured memory_bytes: 27252
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  vector<int> a(n),b(n);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];

  vector<int> s(n+1),t(n+1);
  rep(i,n) s[a[i]]++, t[b[i]]++;
  rep(i,n+1){
    if(s[i]+t[i]>n){
      cout << "No" << endl;
      return 0;
    }
  }
  rep(i,n) s[i+1]+=s[i], t[i+1]+=t[i];

  int x=0;
  rep(i,n) x = max(x,s[i+1]-t[i]);

  cout << "Yes\n";
  rep(i,n) cout << b[(i+n-x)%n] << (i==n-1?"\n":" ");
}


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

def gcd(a, b):
     if b == 0:
         return a
     return gcd(b, a%b)
 
def lcm(a, b):
    return a * b // gcd(a, b)


print((b-a+1) - ((b//c - (a-1)//c) + (b//d - (a-1)//d) - (b//lcm(c, d) - (a-1)//lcm(c, d))))

Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
using namespace std;
const long long mo=1000000007;
const int maxn=55;
int n;
char s[2][maxn];
void scanff()
{
	scanf("%d",&n);
	scanf("%s",s[0]+1);
	scanf("%s",s[1]+1);
}
long long sta[maxn];
int Get_sta(int x)
{
	if(s[0][x]==s[1][x])
	{
		return 1;
	}else return 2;
}
void work()
{
	sta[0]=0;
	long long ans=1;
	for(int i=1;i<=n;)
	{
		int x=Get_sta(i);
		sta[i]=x;
		if(x==1)
		{
			if(sta[i-1]==0)
			{
				ans=ans*3%mo;
			}else if(sta[i-1]==1)
			{
				ans=ans*2%mo;
			}else if(sta[i-1]==2)
			{
				ans=ans%mo;
			}
			i++;
		}else
		{
			if(sta[i-1]==0)
			{
				ans=ans*6%mo;
			}else if(sta[i-1]==1)
			{
				ans=ans*2%mo;
			}else if(sta[i-1]==2)
			{
				ans=ans*3%mo;
			}
			sta[i+1]=sta[i];
			i+=2;
		}
	}
	printf("%lld",ans);
}

int main()
{
	scanff();
	work();
	return 0;
}


Measured memory_bytes: 128
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigDecimal;

class Main{
    // returns x! / (y! * z!)
    static String permutation(int x, int y, int z){
        // make y bigger than z
        if(z > y){
            int tmp = y;
            y = z;
            z = tmp;
        }

        BigDecimal result = BigDecimal.ONE;

        int counter = 1;

        for(int i = y+1; i <= x; i++){
            result = result.multiply(new BigDecimal(String.valueOf(i)));
            if(counter <= z){
                result = result.divide(new BigDecimal(String.valueOf(counter)));
                counter++;
            }
        }

        for(int i = counter; i <= z; i++){
            result = result.divide(new BigDecimal(String.valueOf(counter)));
        }

        return result.toString();
    }

    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String[] input = br.readLine().split(" ");

        int n = Integer.parseInt(input[0]);
        int m = Integer.parseInt(input[1]);
        int r = Integer.parseInt(input[2]);

        int nm = n*m;

        if(r < nm){
            System.out.println("0");
            return;
        }

        int beads = r - nm;
        System.out.println(permutation(beads+n-1, beads, n-1));
    }
}


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

int n;
int a[110];

int main() {
  cin >> n;
  for (int i=0; i < n; ++i) {
    cin >> a[i];
  }
  
  sort(a, a + n, greater<int>());
  int Alice = 0;
  int Bob = 0;
  for (int i=0; i < n; ++i) {
    if (i % 2 == 0) {
      Alice += a[i];
    } else {
      Bob += a[i];
    }
  }
  cout << Alice - Bob << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define intt long long int
#define intu unsigned long long int
#define vi vector<int>
#define ii pair<int,int>
#define pb push_back
//#define mp make_pair
#define ff first
#define ss second
#define fast_io ios::sync_with_stdio(0);cin.tie(NULL);std::cout.tie(NULL);
# define PI           3.14159265358979323846 
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
int mod = 1000000007;
int gcd(int a, int b) {return b ? gcd(b, a % b) : a;}
int lcm(int a, int b) {return a * b / gcd(a, b); }
long long bpow(long long a, long long b, long long m) 
{
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)res = res * a % m;
      a = a * a % m;
      b >>= 1;
  }
  return res;
}
void go()
{
#ifndef ONLINE_JUDGE
  freopen("in.txt","r",stdin);
  freopen("out.txt","w",stdout);
  #endif
}
template<typename P> struct Cmp
{
    bool operator()(const P &p1, const P &p2)
    {
        return (p1.ss < p2.ss); 
    }
};

int main() 
{ 
    fast_io
    go();
    int X,Y;cin>>X>>Y;
    int yo=Y-2*X;
    yo/=2;
    int bol=X-yo;
    if(yo*4+bol*2==Y && yo+bol==X && yo>=0 && bol>=0)
    {
      cout << "Yes";
    }
    else
    cout << "No";
} 























Measured memory_bytes: 3652
#include <iostream>
#include <iomanip>
#include <stdlib.h>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;


int main(){
    int n;
    cin >> n;
    vector<int> X(n,0);
    vector<int> Y(n,0);
    rep(i,n) cin >> X[i] >> Y[i];
    int mi = 1e9;
    for(int fix = 0; fix<n; fix++){
        for(int target=0; target<n; target++){
            // cout << "fix|target " << fix << "|" <<target << endl;
            if(target==fix) break;
            int p = X[target] - X[fix];
            int q = Y[target] - Y[fix];

            int cost=0;
            vector<int> check(n,-1);
                for(int point = 0; point<n; point++){
                    if(check[point]!=-1) continue;
                    check[point]=1;
                    int nx = X[point];
                    int ny = Y[point];
                    while(1){
                        nx+=p;
                        ny+=q;
                        bool find = false;
                        for(int next = 0; next<n; next++){
                            if( (nx == X[next]) and (ny == Y[next]) ){
                                check[next] = 1;
                                find = true;
                            }
                        }
                        if(!find) break;
                    }
                    nx = X[point];
                    ny = Y[point];
                    while(1){
                        nx-=p;
                        ny-=q;
                        bool find = false;
                        for(int next = 0; next<n; next++){
                            if( (nx == X[next]) and (ny == Y[next]) ){
                                check[next] = 1;
                                find = true;
                            }
                        }
                        if(!find) break;
                    }
                    cost+=1;
                }
            // cout << "this case cost is " << cost << endl;
            if(cost < mi) mi = cost;
        }
    }
    if(n==1) mi =1;
    cout << mi << endl;
    return 0;
}

Measured memory_bytes: 256