akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll N = 1e9+7;
const int n_max = 1e5+10;

int main(){
    int n;cin >> n;
    priority_queue<ll> pq_min;
    priority_queue<ll,vector<ll>,greater<ll> > pq_max;
    ll a[n*3];
    ll sum_max = 0,sum_min = 0;
    rep(i,3*n){
        // ll a;cin >> a;
        cin >> a[i];
        if(i < n){
            pq_max.push(a[i]);
            sum_max += a[i];
        }
        
        if(i >= 2 * n){
            pq_min.push(a[i]);
            sum_min += a[i];
        }
    }
    assert(pq_max.size() == n);assert(pq_min.size() == n);
    // ll ans = sum_max - sum_min;
    Pll psmax[n+1],psmin[n+1];
    psmax[0] = Pll(sum_max,n-1);
    psmin[n] = Pll(sum_min,2*n-1);
    rep(i,n+1){
        ll k = i + n -1;
        if(!i)continue;
        sum_max += a[k];
        pq_max.push(a[k]);
        ll temp_min = pq_max.top();pq_max.pop();
        sum_max -= temp_min;
        psmax[i] = Pll(sum_max,k);
    }
    for(int i = n; i >= 0;i--){
        ll k = i + n;
        if(i ==n)continue;
        sum_min += a[k];
        pq_min.push(a[k]);
        ll temp_max = pq_min.top();pq_min.pop();
        sum_min -= temp_max;
        psmin[i] = Pll(sum_min,k);
    }
    ll ans = LLONG_MIN;
    rep(i,n+1){
        ans = max(psmax[i].first - psmin[i].first, ans);
        // cout << i << " " << psmax[i].first << " " << psmin[i].first << endl;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7412
#include<stdio.h>
#include<memory.h>
char prime[1000000];
int main()
{
	int n, m, c, i;
	while (scanf("%d", &n)>0) {
		memset(prime, 1, sizeof(prime));
		c = 0;
		for (m = 2; m <= n; m ++) {
			if (prime[m])
				c ++;
			for (i = m; i <= n; i += m)
				prime[i] = 0;
		}
		printf("%d\n", c);
	}
	return 0;
}

Measured memory_bytes: 1388
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
local function array(dimension, default_val) assert(type(default_val) ~= 'table') local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end
----
local a,b,c = read.nnn()
if c - a - b <= 0 then
    print("No")
else
    local r = (c-a-b)*(c-a-b)
    local l = 4 * a * b
    if l < r then
        print('Yes')
    else
        print('No')
    end
end

Measured memory_bytes: 888
import math

a, b, C = map(int,input().split())

S = (1/2)*a*b*math.sin(math.radians(C))
L = (a**2+b**2-2*a*b*math.cos(math.radians(C)))**(1/2)+a+b
h = 2*S/a
print(S)
print(L)
print(h)



Measured memory_bytes: 5716
N = str(input())

str_len = len(N)
n = list(N)
for i in range(str_len):
    if n[i] is "9":
        n[i] = "1"
    elif n[i] is "1":
        n[i] = "9"

moji = str()
for i in n:
    moji += i

print(moji)

Measured memory_bytes: 3060
import java.util.Scanner;

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

	int N = scan.nextInt();

	int four = N/4;
	int seven = N/7;

	int count = 0;
	for(int i = 0; i <= four; i++){
	    for(int j = 0; j <= seven; j++){
		if(N == i*4+j*7)
		    count = 1;
	    }
	}
	if(count == 1)
	    System.out.println("Yes");
	else
	    System.out.println("No");
    }
}


Measured memory_bytes: 22996
mod=10**9+7

def add(a, b):
    return (a + b) % mod

def sub(a, b):
    return (a + mod - b) % mod

def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def power(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % mod
#    else            : return power(x, y-1)* x % mod
    
    elif y % 2 == 0 : return power(x, y//2)**2 % mod
    else            : return power(x, y//2)**2 * x % mod

def div(a, b):
    return mul(a, power(b, mod-2))

n,a,b=map(int,input().split())


n2=power(2,n)
#n2=1
#for i in range(n):
#    n2=mul(n2,2)
n2=sub(n2,1)
#print(n2)
    
na=1
pna=1
for i in range(a):
    na=mul(na,(n-i))
    pna=mul(pna,(i+1))    
#print(na,pna)
na=div(na,pna)
       
nb=1
pnb=1
for i in range(b):
    nb=mul(nb,(n-i))
    pnb=mul(pnb,(i+1))    
#print(nb,pnb)
nb=div(nb,pnb)

#print(na,nb)

n2=sub(n2,na)
n2=sub(n2,nb)
print(n2)

Measured memory_bytes: 3064
def main():
    from collections import Counter
    n, *a = map(int, open(0).read().split())
    c = Counter(a)
    if n % 2 == 0:
        f = all(x == 2 for x in c.values())
    else:
        g = c.pop(0) == 1
        f = all(x == 2 for x in c.values()) and g
    ans = 2 ** (n // 2) % 1000000007 if f is True else 0
    print(ans)


if __name__ == '__main__':
    main()


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

int main(int argc, char *argv[])
{
    string s, str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    string::iterator itr;
    int n, k, index;
    while (cin >> n, n) {
        int key[n];
        for (int i = 0; i < n; ++i)
            cin >> key[i];
        cin >> s;
        for (int i = 0; i < s.length(); ++i) {
            itr = find(str.begin(), str.end(), s[i]);
            index = itr - str.begin();
            s[i] = str[(index - key[i % n] + 52) % 52];
        }
        cout << s << endl;
    }
    return 0;
}

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

#define ll long long
#define endl "\n"
#define vi vector<int>
#define pb push_back
#define F first
#define S second
#define mod 1000000007
int N, M;
char arr[1009][1009];
void solve() {
	cin >> N >> M;

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			cin >> arr[i][j];
		}
	}
	ll dp[N + 1][M + 1];
	dp[0][0] = 1;
	for (int i = 1; i < M; i++) {
		if (arr[0][i] == '#') {
			dp[0][i] = 0;
		}
		else {
			dp[0][i] = dp[0][i - 1];
		}
	}

	for (int i = 1; i < N; i++) {
		if (arr[i][0] == '#') {
			dp[i][0] = 0;
		}
		else {
			dp[i][0] = dp[i - 1][0];
		}
	}

	for (int i = 1; i < N; i++) {
		for (int j = 1; j < M; j++) {
			if (arr[i][j] == '#') {
				dp[i][j] = 0;
			}
			else {
				dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
			}
		}
	}

	cout << dp[N - 1][M - 1] << endl;
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("manish.txt", "r", stdin);
	//freopen("ps.txt", "w", stdout);
#endif
	int t;
	//cin >> t;
	t = 1;
	while (t--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 12256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define si(x) int(x.size())
const int mod=1000000007,MAX=200005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string S;cin>>S;
    if(S[1]=='B') cout<<"ARC\n";
    else cout<<"ABC\n";
}



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

int main(void){
  int n, k, a = 1;
  cin >> n >> k;
  
  for( int i = 0 ; i < n ; i++ ) {
    int b;
    b = a*2 - a;
    if( b <= k ){
	  a *= 2;
    }
    else{
      a += k;
    }
    //cout << a << endl;
  }
  cout << a << endl;
}

Measured memory_bytes: 3612
n = int(input())
a = list(map(int,input().split()))
c = 0
flag = True

while flag:
    for i in range(n):
        if a[i] % 2 != 0:
            flag = False
            break
        else:
            a[i] /= 2
    c += 1

print(c-1)

Measured memory_bytes: 3060
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<LL> PQ_DESC;
typedef priority_queue<LL, VL, greater<LL>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    int l,r,d;cin>>l>>r>>d;
    LL result = 0;
    FOR(i,l,r+1){
        if(i%d==0){
            result++;
        }
    }
    cout<<result<<endl;
    
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;
constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

int n, k;
ll a[1009];
V<ll> b;

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

    cin >> n >> k;
    FOR(i, 1, n + 1) {
        cin >> a[i];
        a[i] += a[i - 1];
        rep(j, i) b.push_back(a[i] - a[j]);
    }

    ll ans = 0;
    FORR(d, 40) {
        int cnt = 0;
        ll p = ans | 1LL << d;
        for(auto &&x : b)
            if((p & x) == p) cnt++;
        if(cnt >= k) ans = p;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6512
n, k = map(int, input().split())
r, s, p = map(int, input().split())
T = list(input())
dp = [[0]*3 for _ in range(n)]
for i, t in enumerate(T):
    if t == "r":
        if i < k:
            dp[i][0] += 0
            dp[i][1] += 0
            dp[i][2] += p
        else:
            dp[i][0] = max(dp[i-k][1], dp[i-k][2])
            dp[i][1] = max(dp[i-k][0], dp[i-k][2])
            dp[i][2] = max(dp[i-k][0], dp[i-k][1]) + p
    elif t == "s":
        if i < k:
            dp[i][0] += r
            dp[i][1] += 0
            dp[i][2] += 0
        else:
            dp[i][0] = max(dp[i-k][1], dp[i-k][2]) + r
            dp[i][1] = max(dp[i-k][0], dp[i-k][2])
            dp[i][2] = max(dp[i-k][0], dp[i-k][1])
    else:
        if i < k:
            dp[i][0] += 0
            dp[i][1] += s
            dp[i][2] += 0
        else:
            dp[i][0] = max(dp[i-k][1], dp[i-k][2])
            dp[i][1] = max(dp[i-k][0], dp[i-k][2]) + s
            dp[i][2] = max(dp[i-k][0], dp[i-k][1])
ans = 0
for i in range(k):
    ans += max(dp[n-i-1])
print(ans)


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

using namespace std;
using i64 = std::int_fast64_t;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  priority_queue<pair<i64, i64>, vector<pair<i64, i64>>,
                 greater<pair<i64, i64>>>
      que;

  map<i64, i64> A;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    A[a]++;
  }

  for (auto itr = A.begin(); itr != A.end(); itr++) {
    que.push(make_pair(itr->first, itr->second));
  }

  for (int i = 0; i < M; i++) {
    i64 b, c;
    cin >> b >> c;

    que.push(make_pair(c, b));

    while (b > 0) {
      auto q = que.top();
      que.pop();

      if (q.second > b) {
        que.push(make_pair(q.first, q.second - b));
      }
      b -= q.second;
    }
  }

  priority_queue<pair<i64, i64>> gque;
  while (!que.empty()) {
    gque.push(que.top());
    que.pop();
  }

  i64 res = 0;
  while (N > 0) {
    auto q = gque.top();
    gque.pop();

    if (q.second > N) {
      res += q.first * N;
    } else {
      res += q.first * q.second;
    }
    N -= q.second;
  }

  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 11124
#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define ld long double
#define pb push_back

using namespace std;

ll x,y,lcm,gcd;

int main()
{
    cin >> x >> y;
    gcd=__gcd(x,y);
    lcm=x/gcd*y;
    cout << lcm << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORC(i,a,b,c) for(ll i=(a);i<(b);i+=(c))
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define ff first
#define ss second
#define dd long double
#define mod 1000000007
const ll N=1e6+1;
ll dp[N];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    for(ll i=1;i<N;i++){
        for(ll j=i;j<N;j+=i){
            dp[j]++;
        }
    }
    ll n;
    cin>>n;
    ll ans=0;
    for(ll i=1;i<n;i++){
        ans+=dp[n-i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 11448
#include <stdio.h>

int main(void)
{
  int a;
  int b;
  int c;
  int ans = 0;
  
  if (scanf("%d", &a) < 1) {
    return 1;
  }
  if (scanf("%d", &b) < 1) {
    return 1;
  }
  if (scanf("%d", &c) < 1) {
    return 1;
  }
  
  if (a == b && a == c) {
    ans = 1;
  } else if (b == c || a == b || a == c) {
    ans = 2;
  } else {
    ans = 3;
  }
  printf("%d", ans);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define sz(x) (int)(x.size())

signed main() {
    int a, b;
    cin >> a >> b;
    if (a <= 0 && 0 <= b) {
        cout << "Zero\n";
    } else if (0 < a) {
        cout << "Positive\n";
    } else {
        int tedad = b - a + 1;
        if (tedad % 2)
            cout << "Negative\n";
        else 
            cout << "Positive\n";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
  double w,h,x,y,l=2;
  cin >>w>>h>>x>>y;
  printf("%.16f ",(w*h)/l);
  if((w/l==x)&&(h/l==y)) cout <<1<<endl;
  else cout <<0<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;cin>>s;int len=s.length();int ans=0;long long k;cin>>k;
	if(s[0]!=s[len-1])
	{
		int id=0;int tmp=0;
		while(id<len)
		{
			tmp=1;
			while(id<len-1&&s[id]==s[id+1]) id++,tmp++;
			ans+=(tmp/2);
			id++;
		}
		cout<<1ll*ans*k<<endl;
	}
	else
	{
		int id=0;int tmp=1;int a=1,b=1;
		while(id<len-1&&s[id]==s[id+1]) id++,a++;
		id++;//cout<<id<<" "<<a<<endl;
		if(id==len)
		{
			cout<<(1ll*len*k)/2<<endl;
			return 0;
		}
		while(id<len)
		{
			tmp=1;
			while(id<len-1&&s[id]==s[id+1]) id++,tmp++;
			if(id==len-1)
			{
				b=tmp;
			}
			else ans+=(tmp/2);
			id++;
		}
		//cout<<a<<" "<<b<<endl;
		cout<<1ll*ans*k+1ll*(a+b)/2*(k-1)+1ll*b/2+1ll*a/2<<endl;
	}
 } 

Measured memory_bytes: 256
N, M = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(M)]
count = 0
current_bridge = float('inf')
AB.sort(key=lambda x:-x[0])

for a,b in AB:
    #print(count,a,b,current_bridge)
    if b < current_bridge:
        count += 1
        current_bridge = a + 0.5
print(count)


Measured memory_bytes: 32268
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <iomanip>

typedef long double ld;
typedef long long ll;

using namespace std;


/* TEMPLATE ENDS HERE */

int main() {
	cout << fixed << setprecision(12);	
	vector<ll> a;
	ll n;
	cin >> n;
	a.push_back(0);
	for (ll i = 0; i < n; i++) {
		ll t;
		cin >> t;
		a.push_back(t);
	}
	vector<ll> ret(n + 1, 1000);
	for (ll i = 1; i <= n; i++) {
		ret[i] = max(ret[i], ret[i - 1]);
		for (ll j = i; j <= n; j++) {
			for (ll k = j + 1; k <= n; k++) {
				ll cur = ret[i - 1];
				ll s = cur / a[j];
				ll nnext = s * a[k] + cur % a[j];
				ret[k] = max(ret[k], nnext);
			}
		}
	}
	cout << ret[n] << endl;
	return 0;
}


ll MOD = ((ll)1e9 + 7);

struct mod {
	ll x;

	mod(ll tx = 0) {
		x = tx;
		x %= MOD;
	}
	
	mod& operator=(const ll & tx) {
		x = tx % MOD;
		return *this;
	}
	
	mod& operator=(const mod & m2) {
		x = m2.x;
		return *this;
	}

	mod operator+(const mod& m2) const {
		return mod((x + m2.x) % MOD);
	}

	mod& operator+=(const mod& m2) {
		x += m2.x;
		x %= MOD;
		return *this;
	}

	mod operator-(const mod & m2) const {
		return mod((x - m2.x + MOD) % MOD);
	}

	mod& operator-=(const mod & m2) {
		x -= m2.x;
		x = (x + MOD) % MOD;
		return *this;
	}

	mod operator*(const mod & m2) const {
		return mod((x * m2.x) % MOD);
	}

	mod& operator*=(const mod & m2) {
		x *= m2.x;
		x %= MOD;
		return *this;
	}

	mod mypow(ll k) const {
		mod ret = 1;
		mod cur = x;
		while (k) {
			if (k & 1) {
				ret *= cur;
			}
			cur *= cur;
			k >>= 1;
		}
		return ret;
	}

	mod inv() const {
		return mypow(MOD - 2);
	}

	mod operator/(const mod & m2) const {
		return (*this) * m2.inv();
	}

	mod& operator/=(const mod & m2) {
		x *= m2.inv().x;
		x %= MOD;
		return *this;
	}

	bool operator<(const mod & m2) const {
		return x < m2.x;
	}
};

ostream &operator<<(ostream & os, const mod & m) {
	return os << m.x;
}



Measured memory_bytes: 3620
def main():
  p=10**9+7
  def modpfac(n):
    ret=1
    for i in range(1,n+1):
      ret=ret*i % p
    return ret
  n,m=map(int,input().split())
  if abs(m-n)>1:
    return print(0)
  elif abs(m-n)==1:
    return print(modpfac(n)*modpfac(m)%p)
  else:
    return print(2*modpfac(n)*modpfac(m)%p)
 
main()

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

int main(){
  int N,K;
  cin>>N>>K;
  int X[N+100];
  for (int i=0;i<N;i++){
    cin>>X[i];
  }
  
  int total=0;
  
  for (int i=0;i<N;i++){
    if(X[i]<=abs(K-X[i])){
      total=total+2*X[i];
    }
    else total=total+2*abs(K-X[i]);
  }
  
  cout<<total<<endl;
  return 0;
}

    
    

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

int main(){
  int a,b;
  cin >> a >> b;
  if(a>12){
    cout << b << endl;
  }else if(12>=a && a>=6){
    cout << b/2 << endl;
  }else{
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
# b, c =
# a = int(input())
#n = str(input())
N, A, B = [int(i) for i in input().split()]

# 判定
q = (N // (A+B)) * A
m = min((N % (A+B)),A)
print(q+m)

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <map>
#include <unordered_set>
#include <tuple>
#include <queue>
#include <set>
#include <cstring>
#include <functional>
#include <random>
#include <chrono>

#define ar array
#define all(arr) (arr).begin(), (arr).end()
#define range(i, n) for (int i=0; i < n; ++i)
#define rall(arr) (arr).rbegin(), (arr).rend()

typedef long long ll;
typedef long double ld;

using namespace std;

const ll INF = 1e18;
const int INFi = 2e9;
const int maxN = 1e5 + 5;
const int md2 = 998244353;
const int md = 1e9 + 7;

double getTime() { return clock() / (double) CLOCKS_PER_SEC; };

void solve() {
    ll a, b, c, d; cin >> a >> b >> c >> d;
    cout << max(max(a * c, a * d), max(b * c, b * d)) << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //cout << setprecision(15) << fixed;
    int tests = 1;
    //cin >> tests;
    range(_, tests) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=1e6+5;
int tab[MAXN];

int main(){
    ios::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
    ll x,y,res=0;
    cin >> x >> y;
    while(x<=y){
		x*=2;
		res++;
	}
	cout << res;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int N, M; cin >> N >> M;
    vector<int> As(N); for (auto &Ai : As) cin >> Ai;
    int sum = accumulate(As.begin(), As.end(), 0);
    int count = 0;
    for (int i = 0; i < N; ++i)
    {
        if (As[i] * 4 * M >= sum) ++count;
    }
    cout << (count >= M ? "Yes\n" : "No\n");
}


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;
int mod = 1000000007;

void solve();

int main(void){
    ll a, b, c; cin >> a >> b >> c;
    if(a % 2 == 1 && b % 2 == 1 && c % 2 == 1){
        cout << min(a*b, min(a*c, b*c)) << endl;
    }
    else cout << 0 << endl;
    return 0;
}

void solve(){}

Measured memory_bytes: 256
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N, K = get_ints
H = []
N.times do |i|
  H[i] = get_int
end

H.sort!

ans = 10 ** 9 + 1
i = K-1
while i < N
  stock = H[i] - H[i-(K-1)]
  ans = stock if stock < ans

  i += 1
end

puts ans


Measured memory_bytes: 16276
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long ll;
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;}
typedef pair<ll,ll> P;

int main(){
    int n; cin >> n;
    vector<int> p(n);
    rep(i,n)cin >> p[i];
    int cnt=0;
    rep(i,n-2){
        if((p[i]>p[i+1]&&p[i+1]>p[i+2])||(p[i]<p[i+1]&&p[i+1]<p[i+2]))cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
/* ex3_2
        fmuacshai */
 
#include<stdio.h>
int main(void){
    //整数numberとnumberの1の位ones_placeを定義
    int number,ones_place;
    //numberを入力
    scanf("%d",&number);
    //numberの1の位を計算
    ones_place=number%10;
    //nの1の位によって場合分け
    if(ones_place==3){
        //bonの場合
        printf("bon\n");
    }else if(ones_place==0 || ones_place==1 || ones_place==6 || ones_place==8){
        //ponの場合
        printf("pon\n");
    }else{
        //honの場合
        printf("hon\n");
    }
    return 0;
}


Measured memory_bytes: 1632
#include<stdio.h>

int main(){
	int n,a,b,c,x,i,t,y[101];
	for( ; scanf("%d%d%d%d%d",&n,&a,&b,&c,&x),n; printf("%d\n",t>10000?-1:t) ){
		for(i=0;i<n;)
			scanf("%d",y+i++);
		for(t=i=0;t<10001&i<n;x=(a*x+b)%c,t++)
			if(y[i]==x&&++i==n)break;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
template<typename T>
ostream& operator<<(ostream &s, vector<T> A){ for(int i=0;i<A.size();i++){if(i)s<<" ";s<<A[i];} return s;}

int main(){
    int N, M; cin>>N>>M;
    vector<vector<int>> A(N, vector<int>(M));
    REP(i, N){
        REP(j, M) cin>>A[i][j], A[i][j]--;
    }
    vector<int> num(M);
    vector<int> index(N);
    REP(i, N) num[A[i][0]]++;
    int argmax = 0;
    REP(i, M) if(num[argmax]<num[i]) argmax = i;
    int cnt = M;
    int res = num[argmax];
    set<int> deleted;
    //cout << "=======" << endl;
    //cout << num << endl;
    //cout << argmax << endl;
    //cout << res << endl;
    //cout << "=======" << endl;
    while(cnt>1){
        deleted.insert(argmax);
        num[argmax] = 0;
        cnt--;
        for(int i=0; i<N; i++){
            if(!deleted.count(A[i][index[i]])) continue;
            while(deleted.count(A[i][index[i]])){
                index[i]++;
            }
            num[A[i][index[i]]]++;
        }
        REP(i, M) if(num[argmax]<num[i]) argmax = i;
        res = min(res, num[argmax]);
    //cout << "=======" << endl;
        //cout << num << endl;
        //cout << index << endl;
    //cout << "=======" << endl;
    }    
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
using namespace std;
 
int main() {
    vector<string> a;
    string b;
    int n,m;
    cin >> n;
    for(int i = 0;i < n;i++){
        cin >> b;
        a.push_back(b);
    }
    cin >> m;
    int flag;
    int tobira = 0;
    for(int i = 0;i < m;i++){
        flag = 0;
        cin >> b;
        for(int j = 0;j < a.size();j++){
            if(b == a[j]){
                flag = 1;
                break;
            }
        }
        if(flag == 1){
            if(tobira == 0){
                cout << "Opened by " << b <<endl;
                tobira = 1;
            }
            else if(tobira == 1){
                cout << "Closed by " << b <<endl;
                tobira = 0;
            }
        }
        else if(flag == 0){
            cout << "Unknown " << b << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

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

int main() {
  int N;
  cin >> N;
  vector<double> x(N);
  vector<string> u(N);
  rep(i, N) cin >> x[i] >> u[i];

  double ans = 0.0;
  rep(i, N) {
    if (u[i] == "JPY") {
      ans += x[i];
    } else {
      ans += x[i] * 380000.0;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(i,a,n) for(int i=a;i<n;++i)
#define per(i,a,n) for(int i=n-1;i>=a;--i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) ((int)x.size())
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
const ll linf=1e18;
const int inf=1001001001;
const ll mod=1e9+7; // 998244353 = (119<<23)+1
// head
const int nax=15;
int n,m;
vi s[nax];
int p[nax];
bool chk(int a) {
	rep(i,0,m) {
		int c=0;
		for(auto b:s[i+1]) if(a&(1<<(b-1))) c++;
		if(c%2!=p[i+1]) return false;
	}
	return true;
}
int main() {
	  ios::sync_with_stdio(false);
  	cin.tie(0);
		cin>>n>>m;
		rep(i,0,m) {
			int k;
			cin>>k;
			rep(j,0,k) {
				int a;
				cin>>a;
				s[i+1].pb(a);
			}
		}
		rep(i,0,m) cin>>p[i+1];
		int count=0;
		rep(i,0,(1<<n)) {
			if(chk(i)) count++;
//			cout<<i<<' '<<chk(i)<<'\n';
		}
		cout<<count;
		return 0;
}

Measured memory_bytes: 256
from collections import Counter

n=int(input())
A=Counter(sorted(list(map(int,input().split()))))
number=[True for i in range(10**6+1)]

cnt=0
for v,m in A.items():
    if m!=1:
        for i in range(v,10**6+1,v):
            number[i]=False
    else:
        if number[v]==True:
            cnt +=1
            for i in range(v,10**6+1,v):
                number[i]=False
print(cnt)

Measured memory_bytes: 169684
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        boolean ans = true;
        
        int digit = Integer.parseInt(sc.next());
        
        int[] num = new int[digit];
        
        for(int t = 0; t < digit; t++) {
            num[t] = -1;
        }
        
        int n_cmd = Integer.parseInt(sc.next());
        
        int ad = -1, fig = -1;
        
        for(int t = 0; t < n_cmd; t++) {
            ad = Integer.parseInt(sc.next());
            ad--;
            fig = Integer.parseInt(sc.next());
            if((num[ad] == -1) || (num[ad] == fig)) {
                num[ad] = fig;
            } else {
                ans = false;
            }
        }
        
        if(digit > 1) {
            if(num[0] == -1) {
                num[0] = 1;
            } else if(num[0] == 0) {
                ans = false;
            }
        } else {
            if(num[0] == -1) {
                num[0] = 0;
            }
        }
        
        for(int t = 1; t < digit; t++) {
            if(num[t] == -1) {
                num[t] = 0;
            }
        }
        
        if(ans) {
            int sum = 0;
            for(int t = 0; t < digit; t++) {
                num[t] *= Math.pow(10,(digit-t-1));
                sum += num[t];
            }
            System.out.println(sum);
        } else {
            System.out.println("-1");
        }
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    if (A + B >= 10) {
        cout << "error" << endl;
        return 0;
    }
    cout << A + B << endl;
    return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#include <deque>
typedef long long ll;
typedef long double ld;

#define REP(i,s,n)for(ll i=s;i<(n);++i)
#define rep(i,n) REP(i,0,n)
using namespace std;
int S[1000] = { 0 };


int main() {
	ll Q;
	cin >>Q;
	deque<ll>Y;
	rep(i,Q) {
		int a;
		cin >> a;
		if (a==0) {
			int b,c;
			cin >> b>>c;
			if (b==0) {
				Y.push_front(c);
			}
			else {
				Y.push_back(c);
			}
		}
		else if(a==1){
			int b;
			cin >> b;
			cout << Y.at(b) << endl;
		}
		else {
			int b;
			cin >> b;
			if (b==0) {
				Y.pop_front();
			}
			else {
				Y.pop_back();
			}
		}
	}
	return 0;
}





Measured memory_bytes: 6200
// ~maqsat~

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

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define F first
#define S second
#define in insert
#define pb push_back
#define eb emplace_back
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define count1 __builtin_popcountl
#define debug(x) cerr << (#x) << " = " << (x) << "\n"
#define ACCELERATE ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout)
#define ever ;;

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
using db = double;
using ld = long double;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> inline void cmin(T &a, T b) { a = min(a, b); }
template <class T> inline void cmax(T &a, T b) { a = max(a, b); }

const int oo = 0x3f3f3f3f;
const ll N = 1e5 + 123;
const ll MOD = 1e9 + 7;
const ll INF = 1e15 + 9;
const db EPS = 1e-9;
const db PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

main() {
#ifdef ziel
	freopen("input.in", "r", stdin);
#else
	fre("");
#endif
	ACCELERATE;

	int n;
	cin >> n;

	int a[N];

	int mn = n * 2, mx = -1;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		cmin(mn, a[i]);
		cmax(mx, a[i]);
	}

	if (mn == mx) {
		if (mn == n - 1) cout << "Yes";
		else if (2 * mx <= n) cout << "Yes";
		else cout << "No";
		return 0;
	}
	else if (mn + 1 == mx) {
		int x = 0, y = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] == mn) x++;
			else y++;
		}

		if (mx > x && x + y / 2 >= mx) cout << "Yes";
		else cout << "No";
		return 0;
	}
	else {
		cout << "No";
		return 0;
	}
	
	return 0;
}
/*
 
*/


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <limits>
using ll = long long;
using ld = long double;
ll MOD = 1e9 + 7;
using namespace std;
struct UnionFind
{
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N)
    { //最初は全てが根であるとして初期化
        for (int i = 0; i < N; i++)
            par[i] = i;
    }

    int root(int x)
    { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y)
    {                     // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry)
            return;   //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y)
    { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main()
{
    ll n;
    cin >> n;
    if (n == 2)
    {
        ll x, y;
        cin >> x >> y;
        cout << abs(x - y) << endl;
        return 0;
    }
    vector<ll> vec(n);
    for (int i = 1; i <= n; i++)
    {
        ll x;
        cin >> x;
        vec[i] = vec[i - 1] + x;
    }
    ll MIN = 1e9;
    for (int i = 1; i < n ; i++)
    {
        MIN = min(MIN, abs(vec[n ] - vec[i] * 2));
    }
    cout << MIN << endl;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  for(int i = 0; i < N; i++) cin >> d[i];
  sort(d.begin(), d.end());
  cout << d[N/2] - d[N/2 - 1] << endl;
}


Measured memory_bytes: 640
let n = stdin.ReadLine() |> int
let s = stdin.ReadLine()

s.ToCharArray() 
|> Seq.fold (fun (count, beforeC) c ->
    match c = beforeC with
    | true -> count, c
    | false -> count+1, c) 
    (0,'#')
|> fun (count, _) -> stdout.WriteLine(count)

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

string shuffle(string &s, int idx) {
    string after = "";
    for (int i = idx; i < s.size(); i++) after += s[i];
    for (int i = 0; i < idx; i++) after += s[i];
    return after;
}

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

    while (true) {
        string s;
        cin >> s;
        if (s == "-")
            break;

        int loop;
        cin >> loop;
        rep(qi, loop) {
            int idx;
            cin >> idx;
            s = shuffle(s, idx);
        }
        cout << s << endl;
    }
    return 0;
}


Measured memory_bytes: 3232
n,k = map(int,input().split())
a = list(map(int,input().split()))
t=[[0 for i in range(n)] for j in range(64)]
for i in range(64):
    for j in range(n):
        if i == 0:
            t[i][j]=a[j]
        else:
            t[i][j]=t[i-1][t[i-1][j]-1]
ans=1
for i in range(64):
    r = k%2
    k = k//2
    if r == 1:
        ans = t[i][ans-1]
    if k == 0:
        print(ans)
        exit()


Measured memory_bytes: 218808
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}
struct edge {
    ll to,cost;
};
/*
const int COM_MAX = 500500;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_MAX; i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
}
long long COM(int n,int k){
    if(n < k || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
*/
int main(){
    while(true){
        int sum; cin >> sum;
        if (sum == 0){
            break;
        }
        int res = 0;
        for (int i = 0; i < 9; i++){
            int a; cin >> a;
            res += a;
        }
        cout << sum-res << endl;
    }
}


Measured memory_bytes: 3080
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll n,m; cin >> n >> m;
    vl c(m);
    rep(i,m) cin >> c[i];
    vl dp(n+1,INF);
    dp[0] = 0;
    rep(i,m){
        for(ll j=c[i]; j<n+1; j++){
            dp[j] = min(dp[j], dp[j-c[i]] + 1);
        }
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 3092
import numpy as np
nlis = []
for i in range(3):
    nlis.append(list(map(int, input().split())))

nlis = np.array(nlis)
for i in [nlis[2] - nlis[1],nlis[1] - nlis[0],nlis.T[2] - nlis.T[1],nlis.T[1] - nlis.T[0]]:
    if not (i[0] == i[1] and i[1] == i[2]):
        print('No')
        exit()
print('Yes')


Measured memory_bytes: 12508
N,M,Q=map(int,input().split())
query = []
for _ in range(Q):
    a,b,c,d=map(int,input().split())
    a-=1
    b-=1
    query.append([a,b,c,d])

def dfs(q):
    if len(q) == N:
        sum = 0
        for a,b,c,d in query:
            if q[b]-q[a] == c:
                sum+=d
        return sum
    
    if len(q) > 0:
        last = q[-1]
    else:
        last = 1

    ans = 0
    for i in range(last, M+1):
        q.append(i)
        ans = max(ans,dfs(q))
        q.pop()
    return ans

print(dfs([]))

Measured memory_bytes: 75080
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for(ll i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(ll i=(begin)-1;i>=(end);i--)
#define IREP(i, n) IFOR(i,n,0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(),greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=(" << v[0]; FOR(i_debug, 1, v.size()){ cout << "," << v[i_debug]; } cout << ")" << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
// #define f first
// #define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;


template<typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) { REP(i, a.size()) {cin >> a[i]; a[i]--;} }

ll mod = 1000000007;

// https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a#4-%E7%B4%AF%E4%B9%97-an
ll modpow(ll a, ll n, ll mod) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int main()
{
	ll N;
	ll ans = 0;
	cin >> N;
	// vec A(N, -1);
	mat num(2, vec(65, 0));
	REP(i, N) {
		ll A;
		cin >> A;
		ll counter = 0;
		while (A > 0) {
			if (A & 1) num[1][counter]++;
			// else num[0][counter]++;
			counter++;
			A >>= 1;
		}
	}
	// vdebug(num[0]);
	// vdebug(num[1]);
	REP(i, 65) {
		if (num[1][i] > 0) num[0][i] = N - num[1][i];
		num[0][i] %= mod;
		num[1][i] %= mod;
		ans += (num[0][i] * num[1][i]) % mod * modpow(2, i, mod) % mod;
	}



	cout << ans % mod << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char const *argv[])
{
    unsigned long N, D;
    scanf("%lu %lu", &N, &D);

    unsigned long D2 = D * D;

    unsigned long c = 0;
    for (size_t i = 0; i < N; i++)
    {
        long x, y;
        scanf("%ld %ld", &x, &y);
        if (x * x + y * y <= D2)
        {
            c++;
        }
    }

    printf("%lu\n", c);

    return 0;
}


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

using namespace std;

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

    int n, m;

    cin >> n >> m;

    cout << (n * (n - 1) / 2) + (m * (m - 1) / 2) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, n) for (int i = (s); i < (int)(n); i++)
#define INF 100000000

using namespace std;

int main() {
   int a,b;
   cin >> a >> b;
   cout << (a+b)%24 << endl;
 }

Measured memory_bytes: 256
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle
using ll = long long ;
int main() {
    int n;
    cin >> n;

    int a[n][3];
    for(int i = 0; i < n; i++)
        cin >> a[i][0] >> a[i][1] >> a[i][2];

    int dp[n][3];
    dp[n-1][0] = a[n-1][0];
    dp[n-1][1] = a[n-1][1];
    dp[n-1][2] = a[n-1][2]; 

    int ans = 0;
    for(int i = n-2; i >= 0; i--) {
        dp[i][0] = a[i][0] + max(dp[i+1][1], dp[i+1][2]);
        dp[i][1] = a[i][1] + max(dp[i+1][0], dp[i+1][2]);
        dp[i][2] = a[i][2] + max(dp[i+1][0], dp[i+1][1]);
        
    }   
    ans = max(ans, max(dp[0][0], max(dp[0][1], dp[0][2])));
    cout << ans;
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int n;
char s[N];
int main()
{
    scanf("%s",s+1);
    int n=strlen(s+1);
    if(s[1]=='0'||s[n]=='1'){
        puts("-1");return 0;
    }
    for(int i=1;i<n;i++){
        if(s[i]!=s[n-i]){
            puts("-1");return 0;
        }
    }
    int rt=1;
    for(int i=2;i<=n;i++){
        cout<<rt<<" "<<i<<endl;
        if(s[i-1]=='1')rt=i;
    }
    return 0;
}


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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    
    long long count;
    count = A[0] - 1;
    long long initial = 2;
    for (int i = 1; i < N; i++){
        if (A[i] == initial) initial += 1;
        else count += (A[i] - 1) / initial;
    }
    cout << count << '\n';

    return 0;
}

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

using str = string;
using ss = stringstream;

int p[8][3]={
    {0,0,0},
    {1,0,0},
    {0,1,0},
    {0,0,1},
    {1,1,0},
    {1,0,1},
    {0,1,1},
    {1,1,1},
};

char pc[2]={'+','-'};

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

    str s;
    cin>>s;

    int a,b,c,d;
    a=s[0]-'0';
    b=s[1]-'0';
    c=s[2]-'0';
    d=s[3]-'0';

    for(int i=0;i<8;i++)
    {
        int n=a;
        if(p[i][0])n-=b;
        else n+=b;
        if(p[i][1])n-=c;
        else n+=c;
        if(p[i][2])n-=d;
        else n+=d;

        if(n==7)
        {
            cout<<a<<pc[p[i][0]]<<b<<pc[p[i][1]]<<c<<pc[p[i][2]]<<d<<"=7";
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 3624
//by xiqiao
#include<bits/stdc++.h>
#define maxn 200005
using namespace std;
typedef long long ll;
int q[maxn],t[maxn],f[maxn];
int n;
bool check(int x,int y,int z){
	if(x<y && y<z)return 1;
	if(y<z && z<x)return 1;
	if(z<x && x<y)return 1;
	return 0;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int x;scanf("%d",&x);q[x]=i;
	}
	for(int i=n-1;i;i--){
		if(t[i+1]==0){
			if(q[i]>q[i+1]){
				t[i]=1;f[i]=i+1;
			}
		}
		else if(check(q[f[i+1]],q[i],q[i+1])){
			t[i]=t[i+1];f[i]=f[i+1];
		}
		else {
			t[i]=t[i+1]+1;f[i]=i+1;
		}
	}
	printf("%d\n",t[1]);
	return 0;
}

Measured memory_bytes: 2688