akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
 
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;
}
//constexpr int mod = 1e9+7;
constexpr long long inf = 3e18;

int mod_pow(int x,int y,int m){
	int res=1;
	while(y>0){
		if(y&1)res=(__int128_t(res)*x)%m;
		y>>=1;x=(__int128_t(x)*x)%m;
	}
	return res;
}

bool prime(int n){
	if(n<2||n%2==0)return n==2;
	int d=n-1;while(d%2==0)d>>=1;
	for(int x:{2,325,9375,28178,450775,9780504,1795265022}){
		if(n<=x)break;
		int t=d,y=mod_pow(x,t,n);
		while(t!=n-1&&y!=1&&y!=n-1){
			y=(__int128_t(y)*y)%n;t<<=1;
		}
		if(y!=n-1&&t%2==0)return false;
	}return true;
}
int rho(int n){
	if(n%2==0)return 2;
	int MOD=n;
	auto f=[&](int x){return ((__int128_t)x*x+1)%MOD;};
	auto g=[](int x,int y){
		if(x<y)return y-x;
		return x-y;
	};
	for(int x1=0;;x1++){
		for(int x=x1,y=f(x);;x=f(x),y=f(f(y))){
			int d=gcd(g(y,x),n);
			if(1<d&&d<n)return d;
			if(d==n)break;
		}
	}
}
vector<int>factor(int n){
	if(n==1)return {};
	if(prime(n))return {n};
	int d=rho(n);
	vector<int>res=factor(d);
	for(int i:factor(n/d))res.push_back(i);
	return res;
}

// 負の数にも対応した mod
// 例えば -17 を 5 で割った余りは本当は 3 (-17 ≡ 3 (mod. 5))
// しかし単に -17 % 5 では -2 になってしまう
inline long long mod(long long a, long long m) {
    return (a % m + m) % m;
}

// 拡張 Euclid の互除法
// ap + bq = gcd(a, b) となる (p, q) を求め、d = gcd(a, b) をリターンします
long long extGcd(long long a, long long b, long long &p, long long &q) {  
    if (b == 0) { p = 1; q = 0; return a; }  
    long long d = extGcd(b, a%b, q, p);  
    q -= a/b * p;  
    return d;  
}

// 中国剰余定理
// リターン値を (r, m) とすると解は x ≡ r (mod. m)
// 解なしの場合は (0, -1) をリターン
pair<long long, long long> ChineseRem(long long b1, long long m1, long long b2, long long m2) {
  long long p, q;
  long long d = extGcd(m1, m2, p, q); // p is inv of m1/d (mod. m2/d)
  if ((b2 - b1) % d != 0) return make_pair(0, -1);
  long long m = m1 * (m2/d); // lcm of (m1, m2)
  long long tmp = (b2 - b1) / d * p % (m2/d);
  long long r = mod(b1 + m1 * tmp, m);
  return make_pair(r, m);
}

signed main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int N;cin>>N;N*=2;
	vector<int>v=factor(N);sort(all(v));
	map<int,int>mp;
	for(int i:v)mp[i]++;
	int ans=N/2;
	rep(i,1<<len(mp)){
		int x=1,y=1;
		int j=0;
		for(auto k:mp){
			if(i>>j&1){
				x*=mod_pow(k.first,k.second,inf);
			}else {
				y*=mod_pow(k.first,k.second,inf);
			}
			j++;
		}
		if(x!=1){
			chmin(ans,ChineseRem(x-1,x,0,y).first);
		}
	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 3668
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

#include <cstdio>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

#define INF (20000000000000)

ll d[100][100];

int main()
{
	int V, E, s, t, c;
	bool negative = false;

	cin >> V >> E;

	rep(i, V) {
		rep(j, V) d[i][j] = (i == j) ? 0 : INF;
	}

	rep(i, E) {
		cin >> s >> t >> c;
		d[s][t] = c;
	}

	rep(k, V) {
		rep(i, V) {
			if (d[i][k] == INF) continue;
			rep(j, V) {
				if (d[k][j] == INF) continue;
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}

	rep(i, V) if (d[i][i] < 0) negative = true;

	if (negative) cout << "NEGATIVE CYCLE" << endl;
	else {
		rep(i, V) {
			if (d[i][0] == INF) cout << "INF";
			else cout << d[i][0];

			repc(j, 1, V - 1) {
				cout << ' ';

				if (d[i][j] == INF) cout << "INF";
				else cout << d[i][j];
			}
			cout << endl;
		}
	}

	return 0;
}


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

using namespace std;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,q;
	cin >> n >> q;
	string s;
	cin >> s;
	int count[s.length()]={0};
	for(int i=1; i<s.length(); i++){
		if(s[i]=='C' and s[i-1]=='A'){
			count[i]=count[i-1]+1;
		}
		else{
			count[i]=count[i-1];
		}
	}
	while(q--){
		int l,r;
		cin >> l >> r;
		cout << count[r-1] - count[max(l-1,0)] << endl;
	}
	return 0;
}

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

int main(){
    int lst[5];
    int k;
    for(int i=0;i<5;i++){
        cin >> lst[i];
    }
    cin >> k;
    for(int i=0;i<5;i++){
        for(int j=i+1;j<5;j++){
            if(lst[j]-lst[i]>k){
                cout << ":(";
                return EXIT_SUCCESS;
            }
        }
    }
    cout << "Yay!";
    return EXIT_SUCCESS;
}

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

int main() {
    int N; cin >> N;
    string S; cin >> S;
    int cnt = S.size();
    for (int i = 0; i < N - 1; i++) {
        if (S[i] == S[i+1]) cnt--;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3756
#include <stdio.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ld = long double;

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

  // Math.
  int a, b;
  cin >> a >> b;
  cout << ((b + a - 3) / (a - 1));
}


Measured memory_bytes: 256
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        mut a: [u64; n],
        mut b: [u64; n],
        mut c: [u64; n],
    }
    a.sort();
    b.sort();
    c.sort();

    let mut ans = 0;

    for b_ in b {
        let i = {
            let mut l = -1;
            let mut r = n as i64;

            while (r - l) > 1 {
                let m = (l + r) / 2;
                if a[m as usize] < b_ {
                    l = m;
                } else {
                    r = m;
                }
            }
            l
        };
        let j = {
            let mut l = -1;
            let mut r = n as i64;

            while (r - l) > 1 {
                let m = (l + r) / 2;
                if c[m as usize] > b_ {
                    r = m;
                } else {
                    l = m;
                }
            }
            r
        };
        ans += (i + 1) * (n as i64 - j);
    }
    println!("{}", ans);
}


Measured memory_bytes: 8444
#include <bits/stdc++.h>
#define base 1000000007LL
#define ll long long
#define ld double
#define X first
#define Y second
#define pb push_back
#define EPS 1e-22
#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++)
using namespace std;
typedef pair<int, int> II;
typedef pair<II, int> III;

int main()
{
    ios::sync_with_stdio(0);
    //freopen("inp.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    ll x, y;
    cin >> x >> y;
    if (abs(x-y) <= 1) cout << "Brown";
    else cout << "Alice";
    return 0;
}


Measured memory_bytes: 256
#include <ctype.h>
#include <stdio.h>
#include <string.h>

char
toswap(char c)
{
	if (islower(c)) return toupper(c);
	if (isupper(c)) return tolower(c);
	return c;
}

int
main()
{
	char s[1200];
	fgets(s, sizeof(s), stdin);

	int s_i;
	int s_len = strlen(s);
	for (s_i = 0; s_i < s_len; s_i++)
	{
		char c = toswap(s[s_i]);
		putchar(c);
	}

	return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
#include <stack>
#include <deque>
#include <bitset>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<n;++i)
#define FOR(i,s) for(int i=2;i<n;++i)

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

const ll INF = 1010101010;
const ll MOD = 1000000007;

int n, m, g, c, ans, A[101010], G[101010];
int gcd(int a, int b) {
	if (a < b) swap(a, b);
	int r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}
int main() {
	cin >> n >> m;
	rep(i, n) cin >> A[i];
	A[n] = m;
	sort(A, A + n + 1);
	if (n == 1) {
		cout << A[1] - A[0] << endl;
		return 0;
	}
	else {
		g = A[1] - A[0];
		c = gcd(g, A[2] - A[1]);
		FOR(i, n) {
			c = gcd(g, c);
			g = A[1 + i] - A[i];
		}
	}
	cout << c << endl;
	return 0;
}

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

int n, l;
string s[100];

int main() {
	cin >> n >> l;
	;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	sort(s, s + n);
	for (int i = 0; i < n; i++) {
		cout << s[i];
	}
	cout << endl;
}


Measured memory_bytes: 256
N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]

from collections import Counter
CS = Counter(S).most_common()
CT = Counter(T)

ans = 0
for cs in CS:
    k,v = cs
    ans = max(ans, v-CT[k])

print(ans)


Measured memory_bytes: 3316
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <map>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <vector> 
// #include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sp ' '
#define endl '\n'
#define inf  0x3f3f3f3f;
#define FOR(i,a,b) for( int i = a;i <= b;++i)
#define bug cout<<"--------------"<<endl
#define P pair<int, int>
#define fi first
#define se second
#define pb(x) push_back(x)
#define ppb() pop_back()
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define sca3(a,b,c) scanf("%d %d %d",&(a),&(b),&(c))
#define sca2(a,b) scanf("%d %d",&(a),&(b))
#define sca(a) scanf("%d",&(a));
#define sca3ll(a,b,c) scanf("%lld %lld %lld",&(a),&(b),&(c))
#define sca2ll(a,b) scanf("%lld %lld",&(a),&(b))
#define scall(a) scanf("%lld",&(a));


using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a, ll b, ll mod){ll sum = 1;while (b) {if (b & 1) {sum = (sum * a) % mod;b--;}b /= 2;a = a * a % mod;}return sum;}

const double Pi = acos(-1.0);
const double epsilon = Pi/180.0;
const int maxn = 2e5+10;
int main()
{
	char c;
	cin>>c;
	if(c >= 'a' && c <= 'z'){
		cout<<'a'<<endl;
	}
	else {
		cout<<'A'<<endl;
	}
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  double num =1.0;
  double den =0;
  vector<double> data(n);
  
  for(int i=0;i<n;i++)
    cin >> data.at(i);
  
  for(int i=0;i<n;i++)
    num *= data.at(i);

  for(int i=0;i<n;i++)
    den += num/data.at(i);

  cout << num/den << endl;
}

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

int main(int argc, char const *argv[])
{
  int N, L[100], X, i, k=1;
  int Data[100];
  scanf("%d", &N);
  scanf("%d", &X);
  
  
  for ( i = 0; i < N; i++)
  {
    scanf("%d", &L[i]);
  }


  if (L[0] <= X)
  {
    k++;
  }
  

  for ( i = 1; i < N; i++)
  {
    L[i] = L[i-1]+L[i];
    if (L[i] <= X)
    {
      k++;
    }
    
  }
  
  printf("%d\n", k);

  return 0;
}


Measured memory_bytes: 128
//Have a nice day:)
#include<bits/stdc++.h>
using namespace std;
#define LL long long

inline int read();

const int maxn=5e5+5;
const int mod=998244353;

int n, m, ans;
int fac[maxn], inv[maxn];
int Pow(int a, int b)
{
    int u=1;
    for(; b; b>>=1, a=1ll*a*a%mod) if(b&1) u=1ll*u*a%mod;
    return u;
}

void Init()
{
    fac[0]=inv[0]=1;
    for(int i=1; i<=maxn-5; ++i) fac[i]=1ll*fac[i-1]*i%mod;
    inv[maxn-5]=Pow(fac[maxn-5], mod-2);
    for(int i=maxn-6; i>=1; --i) inv[i]=1ll*inv[i+1]*(i+1)%mod;
}

int C(int a, int b) { return 1ll*fac[b]*inv[a]%mod*inv[b-a]%mod; }

void Work()
{    
    n=read(), m=read(); Init();
    for(int i=min(n, m); i>=0; --i)
    {
        ans=(ans+(i&1 ? -1ll : 1ll)*C(i, n)*C(i, m)%mod*fac[i]%mod
            *Pow(n+1, m-i)%mod*Pow(m+1, n-i)%mod)%mod;
    }
    printf("%d", (ans+mod)%mod);
}

int main()
{
  
    Work();

    return 0;
}

inline int read()
{
    char c; bool type=1;
    while((c=getchar())<'0' || c>'9')
        if(c=='-') type=0;
    int ans=c^48;
    while((c=getchar())>='0' && c<='9')
        ans=(ans<<3)+(ans<<1)+(c^48);
    return type?ans:-ans;
}



Measured memory_bytes: 4096
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 400005
#define inf 0x7fffffff
using namespace std;

struct E {int next, to, dis;} e[N];
int n, m, num, flag, cnt;
int h[N], a[N], pos[N], obj[N];
bool vis[N];

int read()
{
	int x = 0; char c = getchar();
	while(c < '0' || c > '9') c = getchar();
	while(c >= '0' && c <= '9') {x = x * 10 + c - '0'; c = getchar();}
	return x;
}

void add(int u, int v, int w)
{
	e[++num].next = h[u];
	e[num].to = v;
	e[num].dis = w;
	h[u] = num;
}

void dfs(int x)
{
	if(flag) return;
	vis[x] = 1;
	for(int i = h[x]; i != 0; i = e[i].next)
	{
		int t = pos[x] + e[i].dis;
		if(pos[e[i].to] == inf) pos[e[i].to] = t, dfs(e[i].to);
		else if(t != pos[e[i].to]) {flag = 1; return;}
	}
}

int main()
{
	cin >> n >> m;
	for(int i = 1; i <= m; i++)
	{
		int a = read(), b = read(), c = read();
		add(a, b, c), add(b, a, -c);
		pos[a] = pos[b] = inf;
		obj[++cnt] = a, obj[++cnt] = b;
	}
	sort(obj + 1, obj + 1 + cnt);
	cnt = unique(obj + 1, obj + 1 + cnt) - obj - 1;
	for(int i = 1; i <= cnt; i++)
		if(!vis[obj[i]])
		{
			flag = 0;
			pos[obj[i]] = 0;
			dfs(obj[i]);
			if(flag) {cout << "No"; return 0;}
		}
	cout << "Yes";
	return 0;
}


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

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

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

	for(int i=0;i<m+2;i++) cout<<"#";
	cout<<endl;
	for(int i=0;i<n;i++){
		cout<<"#"<<s[i]<<"#"<<"\n";
	}
	for(int i=0;i<m+2;i++) cout<<"#";

}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        a: i64,
        b: i64,
        c: i64,
        k: i64,
    };
    let x_a = std::cmp::min(k, a);
    let x_b = std::cmp::min(k - x_a, b);
    let x_c = std::cmp::min(k - x_a - x_b, c);
    let ans = 1 * x_a + 0 * x_b + -1 * x_c;
    println!("{}", ans);
}


Measured memory_bytes: 2136
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define SF scanf
#define PF printf
#define MAXN 100010
using namespace std;
int a[MAXN];
bool cmp(int x,int y){
	return x>y;
}
int main(){
	int n,m,q;
	SF("%d",&n);
	for(int i=1;i<=n;i++)
		SF("%d",&a[i]);
	sort(a+1,a+1+n,cmp);
	a[0]=a[1];
	for(int i=0;;i++)
		if(i+2>a[i+2]){
			int x=i;
			int len1=a[i+1]-x;
			int len2=1;
			for(;a[i+len2+1]>x;len2++);
			if(len1%2==1&&len2%2==1)
				PF("Second");
			else
				PF("First");
			break;
		}
}

Measured memory_bytes: 512
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;

    static void solve(InputReader in, PrintWriter out){
        int n = in.ni();
        int[] a = in.ni(n);
        ArrayList<Integer>[] bj = new ArrayList[n];
        for (int i = 0; i < n; i++) {
            bj[i] = new ArrayList<>();
        }
        for (int i = 0; i < n; i++) {
            if(i+a[i]>=0&&i+a[i]<n) bj[i+a[i]].add(i);
        }
        long ans = 0;
        for (int i = 0; i < n; i++) {
            int ai = i-a[i];
            if(ai<0 || ai>=n) continue;
            int l = -1, r = bj[ai].size();
            while(r-l>1){
                int mid = (l+r)/2;
                if(bj[ai].get(mid)>i){
                    r = mid;
                }else if(bj[ai].get(mid)<i){
                    l = mid;
                }else{
                    l = mid-1;
                    break;
                }
            }
            ans += l+1;
        }
        out.println(ans);
    }


    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}


Measured memory_bytes: 59256
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;

    if (a == b and b == c) return cout << (a % 2 ? 0 : -1) << endl, 0;

    int cnt = 0;
    while (++cnt) {
        if (a % 2 or b % 2 or c % 2) break;
        int ta, tb, tc;
        ta = a / 2; tb = b / 2; tc = c / 2;
        a = tb + tc; b = ta + tc; c = ta + tb;
    }
    cout << --cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define PER(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define INF ((int)1e9+5)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define BIT(x) (1LL << (x))
using namespace std;

int MOD;

LL modinv(LL a){
	LL b = MOD, u = 1, v = 0;
	while(b){
		LL t = a / b;
		a -= t * b;swap(a, b);
		u -= t * v;swap(u, v);
	}
	u%=MOD;
	if(u < 0) u += MOD;
	return u;

}
LL exp(int a, int b){
	LL res = 1;
	LL sum = a;
	while(b){
		if(b&1)res = (res * sum) % MOD;
		sum = (sum * sum) % MOD;
		b>>=1;
	}
	return res;
}

int main(){
	int H, W;
	cin >> H >> W;
	vector<vector<int>> coins(H, vector<int>(W));
	REP(i, H){
		REP(j, W){
			cin>>coins[i][j];
		}
	}
	vector<vector<int>> ans;
	REP(i, H){
		if(i&1){
			REP(j, W){
				if(coins[i][j]%2==0)continue;
				--coins[i][j];
				if(j+1==W){
					if(i+1==H)continue;
					ans.push_back({i, j, i+1, j});
					++coins[i+1][j];
				}else{
					ans.push_back({i, j, i, j+1});
					++coins[i][j+1];
				}
			}
		}else{
			PER(j, W){
				if(coins[i][j]%2==0)continue;
				--coins[i][j];
				if(j){
					ans.push_back({i, j, i, j-1});
					++coins[i][j-1];
				}else{
					if(i+1==H)continue;
					ans.push_back({i, j, i+1, j});
					++coins[i+1][j];
				}
			}
		}
	}
	cout << ans.size() << endl;
	foreach(i, ans){
		REP(j, 4){
			cout << i[j]+1 << (j==3?"\n":" ");
		}
	}
	return 0;
}


Measured memory_bytes: 10032
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
using namespace std;
typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e18;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll N, C; cin >> N >> C;
    vvl ds(C+1, vl(C+1, 0)), cs(N+1, vl(N+1, 0));
    REP(i, C) REP(j, C) cin >> ds[i+1][j+1];
    REP(i, N) REP(j, N) cin >> cs[i+1][j+1];
    
    vvpl dif(3, vpl(C+1, PL(0, LINF)));
    FOR(k,1,C+1){
        REP(i, 3) {dif[i][k].ff = k; dif[i][k].ss = 0LL;};
        FOR(i,1,N+1){
            FOR(j,1,N+1){
                dif[(i+j)%3][k].ss += ds[cs[i][j]][k];
            }
        }
    }
    REP(i, 3) sort(dif[i].begin(), dif[i].end(), p_comp_ss);

    
    ll ret = LINF;
    REP(i, 3) REP(j, 3) REP(k, 3){
        auto p0 = dif[0][i]; auto p1 = dif[1][j]; auto p2 = dif[2][k];
        if(p0.ff == p1.ff || p1.ff == p2.ff || p2.ff == p0.ff) continue;
        ret = min(ret, p0.ss + p1.ss + p2.ss);
    }
    cout << ret << endstr;
    return 0;
}


Measured memory_bytes: 2176
import java.math.BigInteger
import java.util.*

fun main(args: Array<String>) {
    val sc = java.util.Scanner(System.`in`)
    val n = sc.nextInt()
    val m = sc.nextInt()
    val map = TreeMap<Int, Int>()
    (1..m).forEach {
        val s = sc.nextInt()
        val c = sc.nextInt()
        if (map.containsKey(s) && map[s] != c) {
            println(-1)
            return
        }
        map[s] = c
    }
    var r = 0
    if (map[1] != null) {
        if (n != 1 && map[1] == 0) {
            println(-1)
            return
        }
        r += map[1]!! * Math.pow(10.0, (n - 1).toDouble()).toInt()
    } else if (n != 1) {
        r += 1 * Math.pow(10.0, (n - 1).toDouble()).toInt()
    }
    if (n >= 2 && map[2] != null) {
        r += map[2]!! * Math.pow(10.0, (n - 2).toDouble()).toInt()
    }
    if (n >= 3 && map[3] != null) {
        r += map[3]!!
    }
    println(r)
}


Measured memory_bytes: 31392
#include<bits/stdc++.h>
using namespace std;
int main(){

     long long int a,b,c,d,e,f,i,j,k,x,t=0;
     double y;
     vector<int> v;
     vector<int> v1;
     vector<int> v2;
     vector<int>::iterator it;
    cin>>a;
    x=log2(a);
    y=pow(2,x);
    k=y*2-1;
    cout<<k<<endl;
    //cout<<x<<endl;

    return 0;
}




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

int q,sum=0;
vector<pair<char,int> > v;
vector<char> f,b;
string s;

int main()
{
	cin >> s >> q;
	for(int i=0;i<q;i++)
	{
		int x;
		cin >> x;
		if(x == 1)
			sum++; 
		else
		{
			int y;
			char c;
			cin >> y >> c;
			y--;
			if((sum+y)%2)
				b.push_back(c);
			else
				f.push_back(c);
		}
	}
	if(sum%2)
	{
		for(int i=b.size()-1;i >= 0;i--)
			cout << b[i];
		for(int i=s.size()-1;i >= 0;i--)
			cout << s[i];
		for(int i=0;i<f.size();i++)
			cout << f[i];
	}
	else
	{ 
		for(int i=f.size()-1;i >= 0;i--)
			cout << f[i];
		for(int i=0;i<s.size();i++)
			cout << s[i];
		for(int i=0;i<b.size();i++)
			cout << b[i]; 	
	}	 
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iomanip>	// fixed setprecision
#include <numeric>	// accumulate
using namespace std;
using ll = long long;
using ld = long double;

int main() {
	cout << fixed << setprecision(10);	// https://qiita.com/a4rcvv/items/05febcf410c51009a29a

	int n, r;
	cin >> n >> r;

	if (n >= 10)
	{
		cout << r << endl;
	}
	else
	{
		cout << (((10 - n) * 100) + r) << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cfloat>
#include <ctgmath>

const int D_1 = 0;
const int D_2 = 1;
const int D_3 = 2;
const int D_INF = 3;

const int N = 100;
const int X = 0;
const int Y = 1;

int main(void) {
  int n = 0;
  double data[N][2] = {0};

  std::cin >> n;

  double sumD1 = 0.0;
  double sumD2 = 0.0;
  double sumD3 = 0.0;
  double sumDInf = DBL_MIN;

  for (int i = 0; i < n; i++) {
    std::cin >> data[i][X];
  }
  for (int i = 0; i < n; i++) {
    std::cin >> data[i][Y];
  }  

  for (int i = 0; i < n; i++) {
    double x = data[i][X];
    double y = data[i][Y];    

    double d = std::abs(x - y);

    sumD1 += d;
    sumD2 += std::pow(d, 2.0);
    sumD3 += std::pow(d, 3.0);

    if (d > sumDInf) {
      sumDInf = d;
    }
  }

  double d1 = sumD1;
  double d2 = std::sqrt(sumD2);
  double d3 = std::cbrt(sumD3);;
  double dInf = sumDInf;

  printf("%f\n", d1);
  printf("%f\n", d2);
  printf("%f\n", d3);
  printf("%f\n", dInf);  

  return 0;
}

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

int main(){
	int n, cnt[101], p[201][3];
	cin >> n;
	for( int i=0; i<n; i++ ){
		cin >> p[i][0] >> p[i][1] >> p[i][2];
	}
	for( int i=0; i<3; i++ ){
		memset( cnt, 0, sizeof(cnt) );
		for( int j=0; j<n; j++ ){
			cnt[p[j][i]]++;
		}
		for( int j=0; j<n; j++ ){
			if( cnt[p[j][i]] > 1 )
				p[j][i] = 0;
		}
	}
	for( int i=0; i<n; i++ ){
		int sum = p[i][0] + p[i][1] + p[i][2];
		cout << sum << endl;
	}
	return 0;
}

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

typedef long long ll;
typedef long double ld;
#define ii pair <int, int>
#define MP make_pair
#define endl "\n"
#define PB push_back
#define F first 
#define int long long 
#define S second
#define rise_up ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);;
#define all(v) v.begin(), v.end()
#define sz(a) signed((a).size())
#define forn(i,n) for(int i = 0; i < int(n); i++)
#define ford(i,n) for(int i = int(n) - 1; i >= 0; i--)


signed main()
{	
	rise_up
    int t=1; //cin>>t; 
    while(t--){
		string a, b; cin>>a>>b;
	//	cout<<a<<" "<<b.substr(0, sz(a))<<endl;
		if(sz(a) == sz(b)-1 && a == b.substr(0, sz(a)))
			cout<<"Yes";
			else cout<<"No";
	}
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))

typedef long long ll;

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin>>n;
  
  map<string,int> mp;
  
  rep(i,n) {
    string s;
    cin>>s;
    
    mp[s]++;
  }
  int c=0;
  
  for(auto a : mp) {
    c = max(c, a.second);
  }
  
  for(auto a : mp) {
    if(a.second == c) {
      cout<<a.first<<endl;
    }
  }
  
}

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

// Inserted snippets: euclid, io, modint, root
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
ll euclid(ll a, ll b, ll &x, ll &y) {
	if (b) { ll d = euclid(b, a % b, y, x);
		return y -= a/b * x, d; }
	return x = 1, y = 0, a;
}
template<ll MOD = 1'000'000'007>
struct Mod {
	ll val;
	Mod() : val(0) {}
	Mod(ll xx) {
		if (0 <= xx && xx < MOD) val = xx;
		else val = (xx % MOD + MOD) % MOD;
	}
	Mod operator+=(Mod b) { if ((val += b.val) >= MOD) val -= MOD; return *this; }
	Mod operator-=(Mod b) { if ((val += MOD - b.val) >= MOD) val -= MOD; return *this; }
	Mod operator*=(Mod b) { (val *= b.val) %= MOD; return *this; }
	Mod operator/=(Mod b) { (val *= b.inv().val) %= MOD; return *this; }
	Mod operator+(Mod b) const { Mod<MOD> tmp(*this); return tmp += b; }
	Mod operator-(Mod b) const { Mod<MOD> tmp(*this); return tmp -= b; }
	Mod operator*(Mod b) const { Mod<MOD> tmp(*this); return tmp *= b; }
	Mod operator/(Mod b) const { Mod<MOD> tmp(*this); return tmp /= b; }
	Mod& operator++() { *this += 1; return *this; }
	Mod& operator--() { *this -= 1; return *this; }
	Mod operator++(int) { Mod<MOD> tmp(*this); operator++(); return tmp; }
	Mod operator--(int) { Mod<MOD> tmp(*this); operator--(); return tmp; }
	Mod inv() const {
		ll v, y, g = euclid(val, MOD, v, y);
		assert(g == 1); return Mod((v + MOD) % MOD);
	}
	Mod operator^(ll p) const {
		ll r = 1, b = val;
		for (; p; p >>= 1, b = b * b % MOD) if (p & 1) r = r * b % MOD;
		return Mod(r);
	}
	friend istream& operator>>(istream &is, Mod& mod) {
		ll tmp; is >> tmp;
		mod = Mod<MOD>(tmp);
		return is;
	}
	friend ostream& operator<<(ostream &os, const Mod& mod) {
		return os << mod.val;
	}
};
// End snippets

typedef Mod<> modint;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int n; read(n);
	vector<int> x(n);
	rep(i, 0, n) read(x[i]);

	vector<modint> h(n + 1);
	h[0] = 0;
	rep(i, 1, n + 1)
		h[i] = h[i - 1] + modint(1) / i;

	modint sum;
	rep(i, 0, n - 1) {
		sum += h[i + 1] * (x[i + 1] - x[i]);
	}

	rep(i, 1, n) sum *= i;
	write(sum);
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int n;
    cin >> n;
    OP("ABC" + to_string(n));
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	N, K := getInt(), getInt()
	s := getString()

	lr := 0
	rl := 0
	rr := 0
	ll := 0
	l := 0
	r := 0
	for i := 1; i < N; i++ {
		if s[i] == 'R' {
			r++
		}
		if s[i] == 'L' {
			l++
		}
		if s[i-1] == 'L' && s[i] == 'R' {
			lr++
		}
		if s[i-1] == 'R' && s[i] == 'L' {
			rl++
		}
		if s[i-1] == 'R' && s[i] == 'R' {
			rr++
		}
		if s[i-1] == 'L' && s[i] == 'L' {
			ll++
		}
	}
	ans := min(K*2, lr+rl)
	ans += ll + rr
	//out(K, ll, rr)
	if K >= l && K >= r {
		ans = N - 1
	}
	out(ans)
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long int
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define pci pair<char,int
#define mii map<int,int>
#define mll map<long long int,long long int>
#define mci map<char,int>
#define umii unordered_map<int,int>
#define umll unordered_map<long long int,long long int>
#define umci unordered_map<char,int>
#define F first
#define S second
#define pb push_back
#define endl '\n'
#define mod 1000000007
using namespace std;
#define maxval 10003000

int main(){
   IOS;
ll t;t=1;//cin>>t;

while(t--){
ll n;cin>>n;ll x=1;ll a[n];ll ans[n];
for(ll i=0;i<n;i++){
    cin>>a[i];
}
for(ll i=0;i<n;i++) ans[i]=i+1;
ll a1;
while(1){ll y=0;
    for(ll i=0;i<n;i++) {
        if(a[i]!=ans[i]) {y=1;break;}
    }
    if(y==0) {
        a1=x;break;
    }
    x++;
    next_permutation(ans,ans+n);
}
x=1;ll b[n];//ll ans[n];
for(ll i=0;i<n;i++){
    cin>>b[i];
}
for(ll i=0;i<n;i++) ans[i]=i+1;
ll b1;x=1;
while(1){ll y=0;
    for(ll i=0;i<n;i++) {
        if(b[i]!=ans[i]) {y=1;break;}
    }
    if(y==0) {
        b1=x;break;
    }
    x++;
    next_permutation(ans,ans+n);
}
  cout<<abs(b1-a1)<<"\n";  
} 
    

    
return 0;    
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define maxn 2005
using namespace std;
typedef long long LL;
int read()
{
	char c=getchar();int f=1,sum=0;
	while(c<'0' || c>'9'){if(c=='-') f=-1;c=getchar();}
	while(c>='0' && c<='9'){sum=sum*10+c-'0';c=getchar();}
	return sum*f;
}
int gcd(int a,int b){return b==0?a:gcd(b,a%b);}
int n,a[maxn];
int head[maxn],to[maxn<<1],nex[maxn<<1],cnt;
bool li[maxn][maxn],vis[maxn];
int deg[maxn];
void add(int u,int v)
{
	deg[v]++;to[++cnt]=v;nex[cnt]=head[u];head[u]=cnt;
}
void dfs(int x)
{
	vis[x]=1;
	for(int i=1;i<=n;i++)
	if(li[x][i] && !vis[i])
	{
		add(x,i);
		dfs(i);
	}
}
struct node{
	int val,id;
    friend bool operator <(node a,node b){
        return a.val<b.val;
    }
};
priority_queue<node> q;
int main()
{
	n=read();
	for(int i=1;i<=n;i++) a[i]=read();
	sort(a+1,a+1+n);
	for(int i=1;i<n;i++)
	for(int j=i+1;j<=n;j++)
	if(gcd(a[i],a[j])>1) li[i][j]=li[j][i]=1;
	for(int i=1;i<=n;i++)
	if(!vis[i])
	dfs(i);
	for(int i=1;i<=n;i++)
	if(!deg[i])
	q.push((node){a[i],i});
	for(int i=1;i<=n;i++)
	{
		node now=q.top();
		q.pop();
		printf("%d ",a[now.id]);
		for(int j=head[now.id];j;j=nex[j])
		{
			deg[to[j]]--;
			if(!deg[to[j]])
			q.push((node){a[to[j]],to[j]});
		}
	}
	return 0;
}


Measured memory_bytes: 4480
solve n xs ys = 2 * n - (maximum $ map f [0..n])
  where
    f i = length $ filter id $ zipWith (==) as bs
      where
        as = drop (n-i) xs
        bs = take i ys

main = do
  n <- readLn :: IO Int
  xs <- getLine
  ys <- getLine
  print $ solve n xs ys


Measured memory_bytes: 764
@n = gets.to_f

a = gets.split.map(&:to_i)
c = [0,0,0,1]
3.times {|i| c[2-i] = c[3-i] + a.count(3-i)}

@memo = Array.new(c[0]) {Array.new(c[1]) {Array.new(c[2])}}
@memo[0][0][0] = 0.0

def calc(x, y, z)
    return @memo[x][y][z] if @memo[x][y][z]

    s = @n
    s += calc(x - 1, y, z) * x if x > 0
    s += calc(x + 1, y - 1, z) * y if y > 0
    s += calc(x, y + 1, z - 1) * z if z > 0
    @memo[x][y][z] = s / (x + y + z)
end

p calc(c[0] - c[1], c[1] - c[2], c[2] - 1)


Measured memory_bytes: 232632
#include<bits/stdc++.h>
using namespace std;
const int MAXN=20000+10;
int n,p[MAXN],a[MAXN],b[MAXN];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",&p[i]);
	for(int i=1;i<=n;++i)a[i]=a[i-1]+30000;
	for(int i=n;i>=1;--i)b[i]=b[i+1]+30000;
	for(int i=1;i<=n;++i)b[p[i]]-=n-i;
	for(int i=1;i<=n;++i)printf("%d ",a[i]);puts("");
	for(int i=1;i<=n;++i)printf("%d ",b[i]);puts("");
	return 0;
}

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

using namespace std;

#define ll long long
#define ull unsigned ll
#define all(x) x.begin(), x.end()
const int M = 1e9 + 7;


int main() {
    int x, a;
    cin >> x >> a;

    if (x < a)
        cout << 0 << endl;
    else cout << 10 << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

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

  vector<int> c(n);
  rep(i, n) c[i] = i + 1;

  int a = -1, b = -1, res = 0;
  while (a == -1 || b == -1) {
    if (a == -1) {
      rep(i, n + 1) {
        if (i == n) a = res;
        else if (p[i] != c[i]) break;
      }
    }
    if (b == -1) {
      rep(i, n + 1) {
        if (i == n) b = res;
        else if (q[i] != c[i]) break;
      }
    }

    next_permutation(c.begin(), c.end());
    res++;
  }
  cout << abs(a - b) << endl;


  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<int> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define e cout<<endl;
#define pe(x) cout<<x<<" ";
#define re(i,a,b) for(i=a;i<=b;i++)
 
ll i,j,k,l,ii,jj;
ll n,m;
ll x,y;
ll a,b,c;
ll h,w;
 
ll ans=0;
ll sum=0;
ll memo,num;
bool dame=false;
char s[55][55];
 
int main(){
	cin>>h>>w;
	for(i=0;i<h;i++){
		cin>>s[i];
	}
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			//s[i][j]
			if(s[i][j]=='#'){
				bool flag=false;
				for(k=0;k<4;k++){
					if(s[i+dx[k]][j+dy[k]]=='#')flag=true;
				}
				if(!flag){
					dame=true;
					break;
				}
			}
		}
	}
	if(dame){
		p("No");
	}else p("Yes");
	return 0;
				
}

Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>

const int MAX = 200000;
int64_t A[MAX];
int64_t F[MAX];
int64_t n, k;

int main()
{
    std::ios_base::sync_with_stdio(0);
    std::cin >> n >> k;
    for (int i=0;i<n;++i) std::cin >> A[i];
    for (int i=0;i<n;++i) std::cin >> F[i];
    std::sort(A, A+n, std::greater<int64_t>());
    std::sort(F, F+n);

    int64_t r = 0;
    int64_t l = 0;
    for (int i=0;i<n;++i) r = std::max(A[i]*F[i], r);

    while (l < r)
    {
        int64_t c = (l+r)/2;

        int64_t kk = 0;
        for (int i=0;i<n;++i) kk += A[i] - std::min(A[i], c / F[i]);
        if (kk <= k) r = c;
        else l = c+1;
    }
    std::cout << l;

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N), B(N);
  for (int i = 0; i < N; ++i)
    cin >> A[i] >> B[i];

  vector<pair<int, int>> task(N);
  for (int i = 0; i < N; ++i)
    task[i] = make_pair(B[i], A[i]);

  sort(task.begin(), task.end());
  for (int i = 0; i < N; ++i)
    swap(task[i].first, task[i].second);

  int t = 0;
  string ans = "Yes";
  for (int i = 0; i < N; ++i) {
    t += task[i].first;
    if (t > task[i].second)
      ans = "No";
  }

  cout << ans << endl;
}

Measured memory_bytes: 3328
S = input()

ctr = True
for i in range(len(S)):
    if i%2 ==0:
        # 奇数
        if S[i]!='R' and S[i]!='U' and S[i]!='D':
            ctr = False
            print('No')
            break
    else:
        # 偶数
        if S[i]!='L' and S[i]!='U' and S[i]!='D':
            ctr = False
            print('No')
            break

if(ctr):
    print('Yes')

Measured memory_bytes: 3060
//BISMILLAHIR RAHMANIR RAHIM
//ALLAH HU AKABR
#include <bits/stdc++.h>
#define ll  long long int
#define m  1000000007
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
   string s,s1,s2;
   cin>>s1>>s2;
   int l=s2.size()-1;
   s=s1+s2[l];
   if(s==s2)
   {
       cout<<"Yes"<<endl;
   }
   else
    cout<<"No"<<endl;
}



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

int main() {
  
  string str;
  cin >> str;
  
  vector<string> sub3(str.size()-2);

  for(int i=0; i<sub3.size(); i++){
    sub3.at(i) = str.substr(i,3);
  }
  
  int min=1000;
  vector<int> mar3(sub3.size());
  
  for(int i=0; i<sub3.size(); i++){
    mar3.at(i) = abs(753- atoi(sub3.at(i).c_str()));
    if(min>mar3.at(i)){min=mar3.at(i);}
  }
  
  cout << min << endl;

}


Measured memory_bytes: 256
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

a, b, c, x, y = na()
ct = 0
if a + b < 2 * c:
    print(a * x + b * y)
else:
    ct += 2 * c * min(x, y)
    if x < y:
        if b > 2 * c:
            ct += 2 * c * (y - x)
        else:
            ct += b  * (y - x)
    elif x > y:
        if a > 2 * c:
            ct += 2 * c * (x - y)
        else:
            ct += a  * (x - y)
    print(ct)

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func solve(N, M int, S, C []int) {
	k := make([]int, N+1)
	f := make([]int, N+1)
	ng := false
	for i := 0; i < M; i++ {
		s, c := S[i], C[i]
		if N < s {
			ng = true
			break
		}
		if f[s] == 1 && k[s] != c {
			ng = true
			break
		}
		if s == 1 && c == 0 && N != 1 {
			ng = true
			break
		}
		f[s] = 1
		k[s] = c
	}

	if k[1] == 0 && N != 1 {
		k[1] = 1
	}

	if ng == true {
		out(-1)
	} else {
		for i := 1; i <= N; i++ {
			fmt.Print(k[i])
		}
		out()
	}
}

func main() {
	sc.Split(bufio.ScanWords)
	N, M := getInt(), getInt()
	S := make([]int, M)
	C := make([]int, M)
	for i := 0; i < M; i++ {
		S[i], C[i] = getInt(), getInt()
	}
	solve(N, M, S, C)
}


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

int main() {

   ll n, m;
   cin >> n >> m;
   vector<pair<ll, ll> > cans(n);

   for(int i = 0; i < n; i++)
      cin >> cans[i].first >> cans[i].second;
   
   sort(cans.begin(), cans.end());
   ll money = 0l, can_buyed = 0;

   for(int i = 0; i < n; i++){
       ll temp = min(cans[i].second, m - can_buyed);
       money += temp * cans[i].first;
       can_buyed += temp;
   }

   cout << money;
   
   return 0;
}


Measured memory_bytes: 4824
#include <stdio.h>
#include <math.h>

int main() {
    
    int a[3];
    
    scanf("%d %d %d", &a[0], &a[1], &a[2]);
    int i,j;
    int tmp;
   
    for(i=0;i<2;i++){
        for(j=0;j<2;j++){
            if(a[j]>a[j+1]){
                tmp=a[j];
                a[j]=a[j+1];
                a[j+1]=tmp;
            }
            
        }
    }
    printf("%d %d %d\n",a[0], a[1],a[2]);
    return 0;
}



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

using namespace std;

int a[100005], b[100005], c[100005];
long long int dp[200000][3];
int main(){

    int N, d, e, f;
    cin >> N;
    for(int i = 1; i <= N; i++)
        cin >> a[i] >> b[i] >> c[i];

    dp[1][0] = a[1]; dp[1][1] = b[1]; dp[1][2] = c[1];
    for (int i = 2; i <= N; i++){
        dp[i][0] = a[i] + max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = b[i] + max(dp[i-1][0], dp[i-1][2]);
        dp[i][2] = c[i] + max(dp[i-1][0], dp[i-1][1]);
    }

    cout << max(dp[N][0], max(dp[N][1], dp[N][2])) ;
    return 0;
}


Measured memory_bytes: 5504
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        mut a: (i32, i32),
        mut b: (i32, i32),
    }
    let mut t = 0;
    while true {
        if t % 2 == 0 {
            b.0 -= a.1;
            if b.0 <= 0 {
                println!("Yes");
                return;
            }
        } else {
            a.0 -= b.1;
            if a.0 <= 0 {
                println!("No");
                return;
            }
        }
        t += 1;
    }
}


Measured memory_bytes: 2140
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>
#include <iomanip>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;


int main(){
    double a,b,x;
    cin >> a >> b >> x;

    double r, ans;
    double half = a*a*b/2.0;

    if(x < half){
        double e = 2.0*x/(a*b);
        r = atan(b/e);
        ans = r*360.0/(2.0*PI);
    } else {
        double c = 2*(a*a*b-x)/(a*a);
        double tan = a/c;
        r = atan(tan);
        ans = (PI/2.0-r)*360.0/(2.0*PI);
    }
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

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

int main() {
	// your code goes here
	ll n;
	 cin>>n;
	 if(n%1000==0)
	  cout<<"0"<<endl;
	 else 
	   cout<<((n/1000)+1)*1000-n<<endl;
	return 0;
}


Measured memory_bytes: 3628
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 6)
mod = 10**9+7
cnt = 1
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

x = k()

if x == 0:
    print(1)
else:
    print(0)



Measured memory_bytes: 10468
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int a, b;

        a = sc.nextInt();
        b = sc.nextInt();

        System.out.println( (a*b) + " " + (a*2 + b*2) );


    }
}


Measured memory_bytes: 26112
#include <iostream>
using namespace std;
int main(){
int n;
while(cin>>n){
int ans=0;
int a,b,c,d;
if(n<=36){
for(a=0;a<=9;a++)
	for(b=0;b<=9;b++)
		for(c=0;c<=9;c++)
			for(d=0;d<=9;d++)
				if(n==a+b+c+d) {ans=ans+1;}
cout<<ans<<endl;}
else if(n>36){ans=0;
cout<<ans<<endl;}}
return 0;
}

Measured memory_bytes: 1160