akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1001001001;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
//printf("%.10f\n", N);
/*
ll memo[100000];
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/
int main() {
    ll A,B,C;
    cin >> A>> B >>C;
    ll left = 4 * A * B;
    ll right = A * A + B * B + C * C - 2 * (A * C + C * B - A * B);
    if(left < right && C - A - B > 0)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)

int main()
{
    long n;
    cin >> n;
    long a,cnt=0;
    F(i,0,n){
        cin >> a;
        if(a==cnt+1) ++cnt;
    }
    if(cnt!=0) cout << n-cnt << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

if __name__ == "__main__":
    N, M = map(int, sys.stdin.readline().split())
    P = [0] * (N + 1)
    C = [0] * M

    for m in range(M):
        p, y = map(int, input().split())
        C[m] = [m, p, y, 0]
    C.sort(key=lambda x :x[2])

    for c in C:
        P[c[1]] += 1
        c[3] = P[c[1]]
    C.sort(key=lambda x :x[0])

    for c in C:
        print("{}{}".format(str(c[1]).zfill(6), str(c[3]).zfill(6)))

Measured memory_bytes: 29748
n=int(input())
money=[1]
dp=[0]*(n+1)
dp[1]=1
m=6
i=1
while m<=n:
  money.append(m)
  i+=1
  m=6**i
m=9
i=1
while m<=n:
  money.append(m)
  i+=1
  m=9**i

for m in money:
  dp[m]=1

money.sort()
for i in range(1,n+1):
  for m in money:
    if i+m>=n+1:
      continue
    if dp[i]+1<=dp[i+m] or dp[i+m]==0:
      dp[i+m]=dp[i]+1
      
print(dp[n])

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

using namespace std;

inline int read(){
	char ch=getchar();int x=0,f=1;
    while(ch<'0' || ch>'9') {
       if(ch=='-') f=-1;
	  	  ch=getchar();
	}
    while(ch<='9' && ch>='0') {
	   x=x*10+ch-'0';
	   ch=getchar();
	}
    return x*f;
}

int a[1010101];

int main(){
	int n=read(),m=read();
	for(int i=1;i<=n;i++){
		a[i]=read();
	}
	sort(a+1,a+n+1);
	int s=0;
	for(int i=1;i<=n;i++){
		if(m>=a[i]){
			m-=a[i];
			s++;
		}
		else {
			printf("%d\n",s);
			return 0;
		}
	}
	if(m!=0) s--;
	cout<<s;

	return 0;
}


Measured memory_bytes: 256
import math
import sys

def insertion_sort(a, n, g):
    ct = 0
    for i in range(g,n):
        v = a[i]
        j = i-g
        while j >= 0 and a[j] > v:
            a[j+g] = a[j]
            j = j-g
            ct += 1
        a[j+g] = v
    return ct

n = int(input())
a = list(map(int, sys.stdin.readlines()))
m = 0
b = 0
ct= 0
g = []
while True:
    b = 2.25*b+1
    if b > n:
        break
    g.append(int(b))
    m += 1
g = g[::-1]

for i in g:
    ct += insertion_sort(a, n, i)

print(m)
print(*g, sep=" ")
print(ct)
print(*a, sep="\n")

Measured memory_bytes: 118572
N,M=map(int,input().split())

AC={}
WA={}
pe=0
ac=0

for i in range(M):
    p,S=map(str,input().split())
    if S=="AC":
        if p in AC.keys():
            pass
        else:
            AC[p]=1
            if p in WA.keys():
                pe+=WA[p]
            ac+=1
    else:
        if p in WA.keys():
            WA[p]+=1
        else:
            WA[p]=1
print(ac,pe)

Measured memory_bytes: 17096
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
int getDigit(int n);            // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;

// code
// ------------------------------------------------
int main() {

  ll n,m;
  ll mo = 1000000007;
  cin >> n >> m;
  set<ll> a;
  rep(i,m)
  {
    ll aa;
    cin >> aa;
    a.insert(aa);
  }

  vector<ll> dp(n+1,0);

  dp[0] = 1;

  rep(i,n)
  {
    if(i < n && a.count(i+1) == 0)
    {
      dp[i+1] += dp[i];
      dp[i+1] = dp[i+1] % mo;
    }
    if(i < n - 1 && a.count(i+2) == 0)
    {
      dp[i+2] += dp[i];
      dp[i+2] = dp[i+2] % mo;
    }
  }

  cout << dp[n] << endl;
  return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(int n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 1)
      break;
    i++;
  }
  return i;
}
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


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

using namespace std;

int main(){
    
    int n=0;
    int k=0;
    cin>>n; 
    cin>>k;
    int arr[n+1]={0};
    for(int i=1;i<=n;i++){
        cin>>arr[i];
    }
    int dp[n+1]={0};
    dp[0]=10e6;
    for(int i=2;i<=n;i++){
        dp[i]=dp[i-1]+abs(arr[i-1]-arr[i]);
        for(int j=2;j<=k && i-j>0;j++){
            dp[i]=min(dp[i-j]+abs(arr[i-j]-arr[i]),dp[i]);            
        }
    }
    cout<<dp[n]<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
#define int long long

void solve() {
	ll a, b, k; cin >> a >> b >> k;
    if(a >= k) {
        cout << a - k << " " << b << endl;
    } else if((a + b) >= k) {
        cout << 0 << " " << b - (k - a) << endl;
    } else {
        cout << 0 << " " << 0 << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <numeric>

using namespace std;

typedef long long int ll;
typedef long int li;

ll gcd(ll x, ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

int main(void){
    ll ans=0;
    ll n;
    cin >> n;
    ll a[n];
    for(ll i=0;i<n;i++)cin >> a[i];
    ans = a[0];
    for(ll i=0;i<n;i++){ans=gcd(ans,a[i]);}
    
    cout << ans << endl;
}



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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define step(i,s,n,c) for(int i=(s);i<(n);i+=(c))
#define REP(i,s,n) for(int i=(s);i<(n);++i)
#define each(i,vec) for(auto i:vec)
#define cinv(n,vec) VL vec(n);for(auto&v:vec)cin>>v;
#define int long long
#define itn int
#define pb push_back
#define eb emplace_back
#define m_p make_pair
#define m_t make_tuple
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a),greater<>())
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define SZ(a) (signed)(a.size())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define debgp(a) cout<<#a<<" "<<a.fi<<" : "<<a.se<<endl
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define callp(a) for(auto [k,v]:a)cout<<k<<":"<<v<<endl
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define out(a) cout<<(a)<<endl
#define ENDL cout<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define fi first
#define se second
#define V vector
#define P pair
#define T tuple
#define PQ priority_queue
#define cont const auto
#define VV(type,name,y,x,a) vector<vector<type>> name = vector<vector<type>>(y,vector<type>(x,a))
typedef long long ll;
typedef double D;
typedef long double LD;
typedef string str;
typedef vector<ll> VL;
typedef pair<ll,ll> PL;
typedef vector<pair<ll,ll>> VP;
typedef tuple<ll,ll,ll> T3;
typedef tuple<ll,ll,ll,ll> T4;
const signed INF = (1LL<<30);
const long long MOD = (1e9+7);
const long long LINF = (1LL<<60);
const long long LMAX = LLONG_MAX;
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(10);
  
  int n,l;
  cin>>n>>l;
  VL apl(n);
  rep(i,n)apl[i]=l+i;
  int sum=0;
  rep(i,n)sum+=apl[i];
  int d=INF,azi=0;
  rep(i,n){
    int x=0;
    rep(j,n){
      if(i==j)continue;
      x+=apl[j];
    }
    //debg(x);
    int D=abs(sum-x);
    if( chmin(d,D) )azi=x;
  }
  out(azi);
  
  
  return 0;
}

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

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    ll a,b,c;
    cin >> a>>b>>c;
    int ans=0;
    for(int i=a; i<=b; i++){
        if(c%i==0)ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;
  vector<int> dp(n + 1, 1e9 + 7);

  dp[0] = 0;
  rep(i, 1, n + 1) {
    for (auto six = 1; six <= i; six *= 6)
      dp[i] = min(dp[i], dp[i - six] + 1);
    for (auto nine = 1; nine <= i; nine *= 9)
      dp[i] = min(dp[i], dp[i - nine] + 1);
  }
  cout << dp[n] << endl;
}


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


int main(){
    ll n, s;
    cin >> n >> s;
    int r = sqrt(n);
    for (int i = 2; i <= r; i++) {
        ll f = 0;
        ll t = n;
        while (t > 0) {
            f += (t % i);
            t /= i;
        }
        if (f == s) {
            cout << i << endl;
            return 0;
        }
    }
    
    for (int i = r; i >= 1; i--) {
        ll a = n/i;
        if (n/a + n%a > s) continue;
        if ((s - (n/a + n%a)) % i == 0) {
            ll b = a - (s - (n/a + n%a)) / i;
            if (b > r && n/b == i) {
                cout << b << endl;
                return 0;
            }
        }
    }
    if (n == s) cout << n+1 << endl;
    else cout << -1 << endl;
    
    return 0;
}

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

#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() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n; cin >> n;
  vector<int> r(n+1, 0), g(n+1, 0), b(n+1, 0);
  vector<char> c(n);
  for(int i = 1; i <= n; ++i) {
    char ch; cin >> ch;
    c[i-1] = ch;
    r[i] = (r[i-1] + (ch == 'R'));
    g[i] = (g[i-1] + (ch == 'G'));
    b[i] = (b[i-1] + (ch == 'B'));;
  }  
  ll ans = 0;
  rep(i, n-1) {
    for(int j = i+1; j < n; ++j) {
	  auto calc = [&](int a, int b, vector<int>& v) {
		       return v[a] - v[b];
		     };
	  
	  if(c[i] == 'R') if(c[j] == 'G') {
	      ans += calc(n, j+1, b);
	    }
	  if(c[i] == 'G') if(c[j] == 'R') {
	      ans += calc(n, j+1, b);
	    }
	  if(c[i] == 'R') if(c[j] == 'B') {
	      ans += calc(n, j+1, g);
	    }
	  if(c[i] == 'B') if(c[j] == 'R') {
	      ans += calc(n, j+1, g);
	    }
	  if(c[i] == 'G') if(c[j] == 'B') {
	      ans += calc(n, j+1, r);
	    }
	  if(c[i] == 'B') if(c[j] == 'G') {
	      ans += calc(n, j+1, r);
	    }
	  if(j+(j-i) <n) {
	    if((c[i] != c[j]) && (c[i] != c[j+(j-i)]) && (c[j] != c[j+(j-i)])) {
	      --ans;
	    }
	  }
    }
  }
  cout << ans << endl;
}
  
    
    
  


Measured memory_bytes: 3660
#include<iostream>
#include<math.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<list>
#define rep(i,n) for(i = 0; i < n; i++)
#define rep2(i,s,l) for(i = s; i < l; i++)

using namespace std;

bool dfs(int, int);

int main() {
	int i, j,k;
	int n; cin >> n;
	vector<int> d(n);
	rep(i, n) cin >> d[i];
	long long ans = 0;
	rep(i, n) {
		for (j = i + 1; j < n; j++) {
			ans += d[i] * d[j];
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define forinc(i,a,b) for(int i=a;i<=b;++i)
using namespace std;
const int N=1e5;
int n,w,f[101][100001];
int we[101],v[101];
int main()
{
    cin >>n>>w;
    forinc(i,1,n) cin >>we[i]>>v[i];
    forinc(i,0,n)
    forinc(t,0,N) f[i][t]=INT_MAX;
    f[0][0]=0;
    forinc(i,0,n-1)
    forinc(t,0,N) if(f[i][t]<INT_MAX)
    {
        if(f[i][t]+we[i+1]<=w) f[i+1][t+v[i+1]]=min(f[i][t]+we[i+1],f[i+1][t+v[i+1]]);
        f[i+1][t]=min(f[i+1][t],f[i][t]);
    }
    for(int i=N;i>=0;--i)
    {
        if(f[n][i]<INT_MAX)
        {
            cout <<i;
            return 0;
        }
    }
}


Measured memory_bytes: 39680
use std::collections::VecDeque;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let mut graph = vec![vec![]; n];
    for _ in 1..n {
        let a = sc.read::<usize>() - 1;
        let b = sc.read::<usize>() - 1;
        graph[a].push(b);
        graph[b].push(a);
    }

    let mut min = vec![-(1 << 60); n];
    let mut max = vec![1 << 60; n];
    let k: usize = sc.read();
    for _ in 0..k {
        let v = sc.read::<usize>() - 1;
        let p: i64 = sc.read();
        min[v] = p;
        max[v] = p;
    }

    let mut q = (0..n).collect::<VecDeque<_>>();
    while let Some(v) = q.pop_front() {
        for &next in graph[v].iter() {
            if min[next] < min[v] - 1 {
                min[next] = min[v] - 1;
                q.push_back(next);
            }
        }
    }
    let mut q = (0..n).collect::<VecDeque<_>>();
    while let Some(v) = q.pop_front() {
        for &next in graph[v].iter() {
            if max[next] > max[v] + 1 {
                max[next] = max[v] + 1;
                q.push_back(next);
            }
        }
    }

    if (0..n).any(|i| max[i] < min[i]) {
        println!("No");
        return;
    }

    let mut ans = vec![None; n];
    ans[0] = Some(max[0]);
    let mut q = VecDeque::new();
    q.push_back(0);
    while let Some(v) = q.pop_front() {
        let va = ans[v].unwrap();
        for &next in graph[v].iter() {
            if ans[next].is_some() {
                continue;
            }

            if min[next] <= va + 1 && va + 1 <= max[next] {
                ans[next] = Some(va + 1);
            } else if min[next] <= va - 1 && va - 1 <= max[next] {
                ans[next] = Some(va - 1);
            } else {
                println!("No");
                return;
            }
            q.push_back(next);
        }
    }

    println!("Yes");
    for ans in ans.into_iter() {
        println!("{}", ans.unwrap());
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 23420
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;


public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		
		int 	countMax;
		int[]		idata = new int[3];
		String[]	data;
		List<Boolean> list = new ArrayList<Boolean>();
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		
		countMax = Integer.parseInt(reader.readLine());
		for(int i = 0; i < countMax; i++){
			data = reader.readLine().split(" ");
			for(int j = 0; j < 3; j++) idata[j] = Integer.parseInt(data[j]);
			
			for(int j = 0; j < 3; j++){
				for(int k = 0; k < 3; k++){
					if(idata[j] < idata[k]){
						int tmp = idata[j];
						idata[j] = idata[k];
						idata[k] = tmp;
					}
				}
			}
			list.add(((idata[2] * idata[2]) == (idata[0] * idata[0] + idata[1] * idata[1])));
		}
		
		for(Boolean bool : list)	System.out.println(bool.booleanValue() ? "YES" : "NO");

	}
}

Measured memory_bytes: 10000
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
#define endl '\n'
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

signed main(){
    int n; cin>>n;
    int f[n][10],p[n][11];
    rep(i,n)rep(j,10)cin>>f[i][j];
    rep(i,n)rep(j,11)cin>>p[i][j];
    int ans=-INF;
    for(int bit=1; bit<(1<<10); bit++){
        int cc=0;
        rep(i,n){
            int c=0;
            rep(j,10){
                if(bit&(1<<j) and f[i][j]==1)c++;
            }
            cc+=p[i][c];
        }
        chmax(ans, cc);
    }
    cout<<ans<<endl;
}

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int V, d;
vector< vector< int > > adj;
vector< bool > vis;
vector< int > F;

void dfs(int v) {
	vis[v] = true;
	for (int u : adj[v]) if (!vis[u]) dfs(u);
}

int main() {
	vector< int > F(1001);
	F[0] = 1; F[1] = 2;
	
	for_(i,2,1001) F[i] = (F[i - 1] + F[i - 2]) % 1001;
	
	while (cin >> V >> d) {
		adj.assign(V + 1, vector< int >());
		
		for_(u,1,V+1) for_(v,u+1,V+1) {
			if (abs(F[u] - F[v]) < d) {
				adj[u].push_back(v);
				adj[v].push_back(u);
			}
		}
		
		vis.assign(V + 1, false);
		
		int ans = 0;
		
		for_(v,1,V+1) {
			if (vis[v]) continue;
			dfs(v);
			++ans;
		}
		
		cout << ans << endl;
	}
}

Measured memory_bytes: 4976
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 100005
#define SIZE 26

struct Info{
	Info(){

		node_index = 0;
		value = 0;
	}
	Info(int arg_node_index,ll arg_value){
		node_index = arg_node_index;
		value = arg_value;
	}
	bool operator<(const struct Info &arg) const{
		return value > arg.value; //valueの昇順(PQ)
	}
	int node_index;
	ll value;
};

struct Node{

	int ch,left_child,right_child;
	ll value,depth;
};

char buf[NUM];
ll table[SIZE];
int node_index;
Node nodes[2*SIZE];

void calcDepth(int node_id,ll DEPTH){

	nodes[node_id].depth = DEPTH;

	if(nodes[node_id].left_child == -1)return;

	calcDepth(nodes[node_id].left_child,DEPTH+1);
	calcDepth(nodes[node_id].right_child,DEPTH+1);
}

int main(){

	for(int i = 0; i < SIZE; i++){

		table[i] = 0;
	}

	scanf("%s",buf);

	//文字の出現数を数える
	for(int i = 0; buf[i] != '\0'; i++){

		table[buf[i]-'a']++;
	}

	node_index = 0;

	priority_queue<Info> Q;

	for(int i = 0; i < SIZE; i++){
		if(table[i] == 0)continue;

		nodes[node_index].ch = i;
		nodes[node_index].left_child = -1;
		nodes[node_index].right_child = -1;
		nodes[node_index].value = table[i];

		Q.push(Info(node_index,table[i]));
		node_index++;
	}

	if(Q.size() == 1){

		printf("%lld\n",Q.top().value);
		return 0;
	}

	Info left,right;

	while(Q.size() > 1){

		right = Q.top();
		Q.pop();

		left = Q.top();
		Q.pop();

		nodes[node_index].ch = -1; //節点であることを表す
		nodes[node_index].value = left.value+right.value;
		nodes[node_index].left_child = left.node_index;
		nodes[node_index].right_child = right.node_index;

		Q.push(Info(node_index,nodes[node_index].value));

		node_index++;
	}

	calcDepth(node_index-1,0);

	ll ans = 0;

	for(int i = 0; i < node_index; i++){
		if(nodes[i].ch == -1)continue;

		ans += nodes[i].depth*table[nodes[i].ch]; //出現文字数分を計上する
	}

	printf("%lld\n",ans);

	return 0;
}



Measured memory_bytes: 3328
#include<bits/stdc++.h>
#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()
{
  ll A;
  double B;
  cin >> A >> B;
  ll new_B = B * 100 + 0.5;
  ll ans = A * new_B / 100;
  
  printf("%lld\n", ans);
  
  return 0;
}

Measured memory_bytes: 3760
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A - Coffee
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  char s[8];
  scanf("%s", s);

  if (s[2] == s[3] && s[4] == s[5]) puts("Yes");
  else puts("No");
  return 0;
}


Measured memory_bytes: 256
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

from collections import defaultdict, deque
from sys import exit
import math
import copy
from bisect import bisect_left

import sys
# sys.setrecursionlimit(1000000)
INF = 10 ** 17
MOD = 998244353

def main():
    n,m,kk = getList()

    k = m - 1
    ans = 0
    nck = 1
    rui = m
    for itr in range(1, n+1):
        if n - itr <= kk:
            # print(nck, rui)
            ans += (rui*nck) % MOD
            ans %= MOD
            # print(nck, n, itr)
        nck *= (n - itr)
        nck *= pow(itr, MOD-2, MOD)
        nck %= MOD
        rui *= k
        rui %= MOD
        # print(nck, rui)
    print(ans)


if __name__ == "__main__":
    main()



Measured memory_bytes: 69136
#python3
def main():
    h, w = map(int, input().split())
    if h == 1 or w == 1:
        print(1)
        return
    ans = 0
    if h%2 == 0:
        ans = h//2 * w 
    else:
        if w%2 == 0:
            ans = ((h+1)//2) * w//2 + (h//2) * w//2
        else:
            ans = ((h+1)//2) * ((w+1)//2) + (h//2) * (w//2)
    print(ans)
main()


Measured memory_bytes: 2940
#include <iostream>
using namespace std;
 
int main(){
int N;
cin >> N;
for(int i=1; i<10; i++ ){
	for(int k=1;k<10;k++){
		if(i*k==N){
			cout << "Yes";
			return 0;
		}
	}
}
cout << "No";	
return 0;	
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n;
    string a,b;
    char s[200];
    scanf("%d",&n);
    scanf("%s",s);
    if(n&1)
        puts("No");
    else
    {
        for(int i=0;i<n/2;i++)
            a+=s[i];
        for(int i=n/2;i<n;i++)
            b+=s[i];
        if(a==b)
            puts("Yes");
        else puts("No");
    }
    return 0;
}


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

typedef struct{
  int x,y;
} pos;

inline int abs(int x){return x<0?-x:x;}
int dist(pos a, pos b){
  return abs(a.x-b.x)+abs(a.y-b.y);
}

int main(void){
  int n,m;
  pos st[55], cp[55];
  
  cin >> n >> m;
  for (int i=0; i<n; i++){
    cin >> st[i].x >> st[i].y;
  }
  for (int i=0; i<m; i++){
    cin >> cp[i].x >> cp[i].y;
  }
  for (int i=0; i<n; i++){
    int minidx=-1, mind=1000000000, tmpd;
    for (int j=0; j<m; j++){
      if ((tmpd=dist(st[i], cp[j]))<mind){
        minidx = j; mind = tmpd;
      }
    }
    cout << (minidx+1) << endl;
  }
  return 0;
}
    

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
const int INF = 1e6;
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uld = unsigned long long;
using P = pair<int,int>;
const ll mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    int a,b,c,x;
    cin >> a >> b >> c >> x;
    int ans = 0;
    rep(i,a+1){
        rep(j,b+1){
            rep(k,c+1){
                if(500*i + 100*j + 50*k == x) ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=1e9+7;
int dy[]={1,-1,0,0};
int dx[]={0,0,1,-1};

int main(){
    int N;
    cin>>N;
    cout<<3*N*N<<endl;
    return 0;
}


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

#ifdef LOCAL
#include "contest.h"
#else
#define error(args...) 
#endif

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool valid(int x, int w) { return 0 <= x && x < w; }

void iostream_init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    cout.precision(12);
}
//}}}

LL rest(LL H, LL W, LL S) {
    LL S1 = (H/2) * W;
    LL S2 = (H - (H/2)) * W;
    LL T1 = (W/2) * H;
    LL T2 = (W - W/2) * H;
    return min(max({S1, S2, S}) - min({S1, S2, S}),
               max({T1, T2, S}) - min({T1, T2, S}));
}
int main(){
    iostream_init();
    LL H, W;
    cin >> H >> W;
    LL ans = LLONG_MAX;
    for(LL h1 = 1; h1 < H; h1++) {
        LL s = h1 * W;
        ans = min(ans, rest(H-h1, W, s));
    }
    for(LL w1 = 1; w1 < W; w1++) {
        LL s = w1 * H;
        ans = min(ans, rest(H, W-w1, s));
    }
    cout << ans << endl;
    return 0;
}



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

int main() {
	string S;

	cin >> S;

	int sz = S.size();
	long long ans = 0;
	int bcnt = 0;
	for( int i = 0; i < sz; i++ ) {
		if( S[i] == 'B' ) {
			bcnt++;
		}
		else {
			ans += bcnt;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
//IOI 2021

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

#define pb push_back
#define ff first
#define ss second

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

const int MAXN = 100 + 17;

ll n, k, dp[MAXN][2], pd[MAXN][2];
string s;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> s >> k;
	n = s.size();
	dp[1][1] = 1;
	pd[1][1] = 1;
	pd[1][0] = MAXN;
	for (int i = 2; i <= n; i++) {
		if (s[i - 1] == s[i - 2])
			dp[i][0] = dp[i - 1][1], pd[i][0] = pd[i - 1][1];
		else
			dp[i][0] = min(dp[i - 1][1], dp[i - 1][0]), pd[i][0] = min(pd[i - 1][1], pd[i - 1][0]);
		dp[i][1] = min(dp[i - 1][1], dp[i - 1][0]) + 1, pd[i][1] = min(pd[i - 1][1], pd[i - 1][0]) + 1;
	}
	if (k > 1 && s.back() == s[0])
		cout << min(min(dp[n][1], min(pd[n][0], pd[n][1])) * (k - 1) + min(dp[n][0], dp[n][1]), (k / 2) * pd[n][1] + ((k + 1) / 2) * min(dp[n][0], dp[n][1])) << endl;
	else
		cout << min(dp[n][0], dp[n][1]) * k << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P std::pair<int,int>
#define PiP std::pair<int,std::pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp std::make_pair
#define prique(T) std::priority_queue<T,vector<T>,greater<T>>
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = std::max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = std::min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	std::random_device rnd;
	std::mt19937 mt32(rnd());
	std::uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt32);
}
/*--------Library Zone!--------*/

int m;
signed main() {
	cin >> m;
	int cnt = 0, sum = 0;
	rep(i, m) {
		int a, b; cin >> a >> b;
		cnt += b;
		sum += a * b;
	}
	cout << cnt - 1 + (sum - 1) / 9 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N;
    cin >> N;
    if (N % 2 == 0) cout << N << endl;
    else cout << N * 2 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 100005
#define K 55
#define int long long
#define pb push_back
#define x first
#define y second
#define all(v) v.begin(),v.end()
#define coffee prince
#define sz(a) (int)a.size()
#define ll long long
#define SIZE N
using namespace std;
int n,ar[N],su[N];
int inf = 1e17;
int ans = 0;
signed main() {
    ios::sync_with_stdio(0); 
    cin.tie(NULL); cout.tie(NULL);
    cin>>n;
    for(int i=0;i<=n;i++){
        cin>>ar[i];
    }
    for(int i=n;i>=0;i--){
        su[i] += ar[i] + su[i+1];
    }
    int cur = 1;
    for(int i=0;i<=n;i++){
        if(cur>=su[i])cur = su[i];
        ans += cur;
        if(ar[i]>cur){
            cout<<"-1";
            return 0;
        }
        cur -= ar[i];
        cur += cur;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 5216
#include <iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#define ll long long
using namespace std;
static const long long MOD=1000000007;
static const int MAX = 2010;

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;
    }
}

ll COM(ll n, ll r){
    
    if(n<r || n<0 || r<0)
        return 0;
    
    return fac[n]*(finv[r]*finv[n-r]%MOD) % MOD;
}


int main(void){
    COMinit();   
    ll n,k;
    cin>>n>>k;

for(ll i=1;i<=k;i++){
    cout<< COM(n-k+1,i)*COM(k-1, i-1)%MOD<<endl;
    
}

    
}


Measured memory_bytes: 3620
package main

import (
	"fmt"
)

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	result := "Yes"
	if a == b && b == c && a == c ||
		a != b && b != c && a != c {
		result = "No"
	}
	fmt.Println(result)
}


Measured memory_bytes: 512
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC
{
    class ProgramD
    {
        static void Main(string[] args)
        {
            var n = long.Parse(Console.ReadLine());
            var list = new List<(int, int)>();
            for (var i = 0; i < n; i++)
            {
                var inputs = Console.ReadLine().Split(" ");
                list.Add((int.Parse(inputs[0]), int.Parse(inputs[1])));
            }

            var result = true;

            list = list.OrderBy(a => a.Item2).ToList();

            var time = 0;
            for (var i = 0; i < n; i++)
            {
                time += list[i].Item1;
                if (time > list[i].Item2)
                {
                    result = false;
                    break;
                }
            }

            Console.WriteLine(result ? "Yes" : "No");
        }

    }
}


Measured memory_bytes: 53656
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define endl '\n'

using namespace std;

main()
{
  fast;
  int n,i;
  double m;
  cin>>n>>m;
  double a[n],tot=0;
  for (i=0;i<n;i++)
  {
    cin>>a[i];
    tot+=a[i];
  }
  int ans=0;
  for (i=0;i<n;i++)
  {
    if (a[i]/tot>=1/(4*m))
      ans++;
  }
  if (ans>=m)
    cout<<"Yes\n";
  else
    cout<<"No\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <vector>
/* 変数i を n回繰り返すマクロ */
#define rep(i,n) for (int i = 0;i < (n);i++)
/* 配列の初期化 fill(array, 0); すべて0に初期化 */
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){std::fill( (T*)array, (T*)(array+N), val );}
using namespace std;
int main()
{
    int n,r;
    cin >> n >> r;
    if(n < 10){
        int tmp = 100 * (10 - n);
        cout << tmp + r << endl;
    }else{
        cout << r << endl;
    }
    return 0;
}

Measured memory_bytes: 256
//#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>

using namespace std;

#define ll long long

void solve()
{
    vector<vector<ll>> A(3, vector<ll>(3));
    for (ll i = 0; i < 3; i++)
    {
        for (ll j = 0; j < 3; j++)
        {
            cin >> A.at(i).at(j);
        }
    }

    ll N;
    cin >> N;
    vector<ll> B(N);
    for (ll k = 0; k < N; k++)
    {
        cin >> B.at(k);
        for (ll i = 0; i < 3; i++)
        {
            for (ll j = 0; j < 3; j++)
            {
                if (A.at(i).at(j) == B.at(k))
                {
                    A.at(i).at(j) = -1;
                }
            }
        }
    }
    for (ll i = 0; i < 3; i++)
    {
        if (A.at(0).at(i) == -1 && A.at(1).at(i) == -1 && A.at(2).at(i) == -1)
        {
            cout << "Yes" << endl;
            return;
        }
    }

    for (ll i = 0; i < 3; i++)
    {
        if (A.at(i).at(0) == -1 && A.at(i).at(1) == -1 && A.at(i).at(2) == -1)
        {
            cout << "Yes" << endl;
            return;
        }
    }

    if (A.at(0).at(0) == -1 && A.at(1).at(1) == -1 && A.at(2).at(2) == -1)
    {
        cout << "Yes" << endl;
        return;
    }

    if (A.at(0).at(2) == -1 && A.at(1).at(1) == -1 && A.at(2).at(0) == -1)
    {
        cout << "Yes" << endl;
        return;
    }

    cout << "No" << endl;
    return;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
using namespace std;

int main() {
    int n, k; cin >> n >> k;
    vector<int> h(n);
    for (auto &e : h) cin >> e;

    vector<int> dp(n, INT_MAX);
    dp[0] = 0;
    dp[1] = abs(h[0] - h[1]);

    // O(nk) = 10^7
    for (int i = 2; i < n; ++i) {
        for (int j = 1; j <= k && 0 <= i - j; ++j) {
            dp[i] = min(dp[i], dp[i - j] + abs(h[i - j] - h[i]));
        }
    }

    cout << dp[n - 1] << endl;
}

#if false

// メモ化再帰による解法

int solve(vector<int> &memo, const vector<int> &h, int k, int i) {
    if (i == 0) return 0;
    if (i == 1) return abs(h[0] - h[1]);
    if (memo[i] != -1) return memo[i];

    memo[i] = INT_MAX;
    for (int j = 1; j <= k; ++j) {
        if (i - j < 0) break;
        memo[i] = min(memo[i], solve(memo, h, k, i - j) + abs(h[i - j] - h[i]));
    }

    return memo[i];
}

int main() {
    int n, k; cin >> n >> k;
    vector<int> h(n);
    for (auto &e : h) cin >> e;

    vector<int> memo(n, -1);
    cout << solve(memo, h, k, n - 1) << endl;
}

#endif



Measured memory_bytes: 4044
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
/* テンプレートここまで */

int main() {
  ll N; cin >> N;
  deque<ll> a(N); REP(i, N) cin >> a[i];
  sort(ALL(a));
  vector<ll> b(2);
  ll ans = a.back() - a.front();
  b[0] = a.front();
  b[1] = a.back();
  a.pop_back(); a.pop_front();
  
  while(!a.empty()){
    vector<ll> tmp(4);
    tmp[0] = abs(a.back() - b[0]);
    tmp[1] = abs(a.back() - b[1]);
    tmp[2] = abs(b[0] - a.front());
    tmp[3] = abs(b[1] - a.front());
    auto it = max_element(ALL(tmp));
    ans += *it;
    ll i = it - tmp.begin();
    if(i==0){
      b[0] = a.back();
      a.pop_back();
    }else if(i==1){
      b[1] = a.back();
      a.pop_back();
    }else if(i==2){
      b[0] = a.front();
      a.pop_front();
    }else{
      b[1] = a.front();
      a.pop_front();
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    #N = int(input())
    N, M = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    A = tuple(int(input()) for i in range(M)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    aset=set(A)
    dp=[0]*(N+1)
    dp[0]=1
    for i in range(1,N+1):
        if i in aset:
            continue
        if i>=2:
            dp[i]=(dp[i-1]+dp[i-2])%mod
        else:
            dp[i]=(dp[i-1])%mod

    #printe(dp)
    print(dp[-1])



if __name__ == "__main__":
    main()

Measured memory_bytes: 97952
import sys
#from me.io import dup_file_stdin

#@dup_file_stdin
def solve():
    while True:
        n = int(sys.stdin.readline())
        if n == 0 : return
        a = list(map(int,sys.stdin.readline().split(' ')))
        ops = 0
        while True:
            cnt = dict()
            for x in a:
                cnt[x] = cnt.get(x,0) + 1
            changed = False
            for x in a:
                if x != cnt[x]:
                    changed = True
                    break
            if changed:
                a = [cnt[x] for x in a]
                ops += 1
            else:
                print(ops)
                print(' '.join(map(str,a)))
                break
solve()

Measured memory_bytes: 7716
package main

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

func main() {
	sc := NewScanner()
	R1 := float64(sc.NextInt())
	R2 := float64(sc.NextInt())

	fmt.Println(R1 * R2 / (R1 + R2))

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r:rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;



int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n, x;
    cin >> n >> x;
    cout << n / x + (n % x != 0);

    return 0;
}


Measured memory_bytes: 3616
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc169_c
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            decimal A= decimal.Parse(input[0]);
            decimal B = decimal.Parse(input[1]);
            Console.WriteLine(Decimal.Floor(A * B));
            Console.Read();
        }
    }
}


Measured memory_bytes: 27208
#include<bits/stdc++.h>
using namespace std;
int main(){
  char S[4];
  int i;
  int x=0,M=0;
  for(i=1;i<=3;i++){
    cin >> S[i];
    if(S[i]=='R'){
      x+=1;
      if(M<x) M=x;
    }else{
      x=0;
    }
  }
  cout << M << endl;
  return 0;
}


Measured memory_bytes: 3620
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main()
    {
        var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
        var alice = input[0];
        var bob = input[1];

        if (alice == bob)
        {
            Console.WriteLine("Draw");
        }
        else
        {
            if (alice > bob)
            {
                if (bob == 1)
                {
                    Console.WriteLine("Bob");
                }
                else
                {
                    Console.WriteLine("Alice");
                }
            }
            else
            {
                if (alice == 1)
                {
                    Console.WriteLine("Alice");
                }
                else
                {
                    Console.WriteLine("Bob");
                }
            }
        }
    }
}

Measured memory_bytes: 13268
// atcoder arc70
#include <bits/stdc++.h>
#define debug 0

using namespace std;

typedef long long ll;

/*
for every number, find the left and right bound
*/

priority_queue<ll> l;
priority_queue<ll, vector<ll>, greater<ll>> r;

ll lo = 0;
ll ro = 0;
void printpq(){
	vector<ll> temp;
	printf("L: ");
	while(!l.empty()){
		temp.push_back(l.top());
		printf("%d ", l.top()-lo);
		l.pop();
	}
	printf("\n");
	for(auto i : temp) l.push(i);
	temp.clear();
	printf("R: ");
	while(!r.empty()){
		temp.push_back(r.top());
		printf("%d ", r.top()+ro);
		r.pop();
	}
	for(auto i : temp) r.push(i);
	temp.clear();
	printf("\n");
	printf("\n");
}
ll n;
int main(){
	if(debug) freopen("narrowrectangles.in", "r", stdin);
	cin >> n;
	ll a,b; cin >> a >> b;
	l.push(a);
	r.push(a);
	ll prvlen = b-a;
	ll ans = 0;
	for(ll i = 1; i<n; i++){
		cin >> a >> b;
		ll len = b-a;
		lo += len;
		ro += prvlen;
		if(a <= l.top()-lo){
			ans += l.top()-lo -a;
			l.push(a+lo);
			l.push(a+lo);
			r.push(l.top()-lo-ro);
			l.pop();
		}else if(a >= r.top()+ro){	
			ans +=a-(r.top()+ro);
			r.push(a-ro);
			r.push(a-ro);
			l.push(r.top()+ro+lo);
			r.pop();
		}else{
			l.push(a+lo);
			r.push(a-ro);
		}
		prvlen = len;
		if(debug) printpq();
	}
	cout << ans;
}


Measured memory_bytes: 2036