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

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> x(N);
  for(int i=0; i<N; i++) cin >> x.at(i);
  int ans=300000001;
  for(int i=0; i<N-K+1; i++){
    if(x.at(i)>=0){
      ans=min(ans, x.at(i+K-1));
    }
    else if(x.at(i+K-1)<=0){
      ans=min(ans,abs(x.at(i)));
    }
    else{
      ans=min({ans,abs(x.at(i))*2+x.at(i+K-1),abs(x.at(i))+x.at(i+K-1)*2});
    }
  }
  if(N==1) ans=x.at(0);
  cout << ans << endl;
}

Measured memory_bytes: 640
/************************************************
   Start coding only after you have clear idea. 
*************************************************/
 
#include <bits/stdc++.h>
 
#define x first
#define y second
#define pii pair<int,int>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long LL;
const int maxm = 2e3+23;
const int maxn = 2e5+35;
const LL inf = 1000000000000000000;
int main(){
    long long n,v; LL sum = 1; cin >> n; int f = 1;
    for(int i = 1;i <= n; ++i){
        cin >> v; if(v == 0) f = 0;
        if(sum == -1) continue;
        if((__int128)sum*v>inf) sum = -1;
        else sum = sum*v;
    }
    cout << sum * f << endl;
    return 0;
}

Measured memory_bytes: 3592
d=[0,2,5,5,4,5,6,3,7,6]
N,M=map(int,input().split())
A=list(map(int,input().split()))

dp = [-1 for i in range(N+1)]
dp[0] = 0


for i in range(1,N+1):
    tmp = -1
    for a in A:
        if i-d[a]>=0 and dp[i-d[a]] != -1:
            tmp = max(tmp,dp[i-d[a]]+1)
    dp[i] = tmp


A.sort(reverse=True)
ans = ''
while N>0:
    for a in A:
        if N-d[a]>=0 and dp[N-d[a]] == dp[N]-1:
            ans += str(a)
            N -= d[a]
            break
print(ans)





Measured memory_bytes: 3320
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    lli N;
    cin >> N;
    lli sum = 0;
    for (lli i = 1; i <= N; i++)
    {
        sum += i - 1;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
n, m, x = list(map(int, input().split()))

c_list = []
a_matrix = []

for i in range(n):
    items = list(map(int, input().split()))
    c_list.append(items[0])
    a_matrix.append(items[1:])

min_cost = 1000000 * (n+1)

for i in range(2**n):
    cost = 0
    skill_sum = [0 for _ in range(m)]
    bit_pattern = format(i, '0' + str(n) + 'b')[::-1]
    for i, a_line in enumerate(a_matrix):
        if bit_pattern[i] == "1":
            cost += c_list[i]
            for j, a in enumerate(a_line):
                skill_sum[j] += a
    
    if all(map(lambda skill_s: skill_s >= x, skill_sum)) and cost < min_cost:
        min_cost = cost

if min_cost >= 1000000 * (n+1):
    print(-1)
else:
    print(min_cost)

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


int main() {
    int n; cin >> n;
    V<int> b(n);
    for(int i = 0; i < n - 1; i++) cin >> b[i];

    int ans = b[0];
    for(int i = 1; i < n; i++){
        ans += min(b[i - 1], b[i]);
    }
    ans += b[n - 2];
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <functional>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define MP make_pair
#define X first
#define Y second
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()

using namespace std;

typedef pair<int, int> P;

int main(){
	int T;
	cin >> T;
	rep(sets, T){
		int n, k;
		cin >> n >> k;
		vector<int> v(n);
		rep(i, n) cin >> v[i];
		vector<int> diff(n);
		adjacent_difference(all(v), diff.begin());
		diff.erase(diff.begin());
		sort(rev(diff));
		int sum = v[n-1]-v[0];
		rep(i, min(n-1, k-1)) sum -= diff[i];
		cout << sum << endl;
	}

	return 0;
}

Measured memory_bytes: 1864
def selectionSort(n, A):
    cnt = 0
    for i in range(n):
        minj = i
        for j in range(i, n):
            if A[minj][1] > A[j][1]:
                minj = j
        if i != minj:
            A[i], A[minj] = A[minj], A[i]
            cnt += 1
    return A


def bubbleSort(n, A):
    flag = True
    cnt = 0
    while flag:
        flag = False
        for j in range(n - 1, 0, -1):
            if A[j - 1][1] > A[j][1]:
                A[j - 1], A[j] = A[j], A[j - 1]
                cnt += 1
                flag = True
    return A


def stableSort(input, output):
    n = len(input)
    for i in range(n):
        for j in range(i + 1, n):
            for a in range(n):
                for b in range(a + 1, n):
                    if input[i][1] == input[j][1] and input[i] == output[b] and input[j] == output[a]:
                        return print("Not stable")
    return print("Stable")


if __name__ == '__main__':
    n = int(input())
    R = list(map(str, input().split()))
    C = R[:]
    D = R[:]  #????????¨?????????
    SR = selectionSort(n, R)
    BR = bubbleSort(n, C)
    print(*BR)
    stableSort(D,BR)
    print(*SR)
    stableSort(D,SR)

Measured memory_bytes: 7848
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;

ll d, w, e[11][11];

int main() {
  while (scanf("%lld%lld", &d, &w), d) {
    for (ll i = 0; i < d; i++) for (ll j = 0; j < w; j++) scanf("%lld", &e[i][j]);
    ll ans = 0;
    for (ll i = 0; i < d; i++) for (ll j = i+2; j < d; j++) {
      for (ll k = 0; k < w; k++) for (ll r = k+2; r < w; r++) {
        ll mn = 100000, mx = 0, temp = 0;
        for (ll x = i; x <= j; x++) for (ll y = k; y <= r; y++) {
          if (x == i || x == j || y == k || y == r) mn = min(mn, e[x][y]);
          else mx = max(e[x][y], mx), temp += e[x][y];
        }
        if (mn > mx) ans = max(ans, (j-i-1) * (r-k-1) * mn - temp);
        //if (mn > mx) printf("%lld, %lld, %lld, %lld(mn: %lld, mx: %lld)ok\n", i, j, k, r, mn, mx);
      }
    }
    printf("%lld\n", ans);
  }
}



Measured memory_bytes: 2676
n,x=map(int,input().split())
l=[int(i) for i in input().split()]
dp = [[[0 for k in range(55)] for j in range(3000)] for i in range(55)]

for i in range(n+1):
    dp[i][0][0]=1 
sm=sum(l)
for i in range(1,n+1):
    for j in range(sm+5):
        for k in range(1,n+1):
            curr=l[i-1]
            if curr<=j:
                dp[i][j][k]=dp[i-1][j][k]+dp[i-1][j-curr][k-1]
            else:
                dp[i][j][k]=dp[i-1][j][k]

ans=0 
for k in range(1,n+1):
    ans+=dp[n][k*x][k]
print(ans)

Measured memory_bytes: 132572
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a;
    b=a;
    while(1){
    if(b%2==0 && b%a==0)
    {
        cout<<b<<endl;
        break;
    }
    else
        b++;

    }


    return 0;
}


Measured memory_bytes: 3616
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define _GLIBCXX_DEBUG

using _loop_ll = long long;
#define REP(i,n) for(_loop_ll (i)=0; (i)<(_loop_ll)(n); (i)++)
#define FOR(i,a,b) for(_loop_ll (i)=(_loop_ll)(a); (i)<(_loop_ll)(b); (i)++)
#define FORR(i,a,b) for(_loop_ll (i)=(_loop_ll)(b)-1; (i)>=(_loop_ll)(a); (i)--)
 
#define ALL(v) (v).begin(),(v).end()
 
#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;

constexpr long long int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll n, m;
    cin >> n >> m;
    if(n == m){ 
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    

    

    return 0;
};


Measured memory_bytes: 256
//file_name:ABC72_C.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    int n;
    scanf("%d",&n);
    int a[100001] = {};
    rep(i,n){
        int c;
        cin >> c;
        a[c]++;
    }


    int ans = 0;

    srep(i,1,100000){
        maxs(ans,a[i-1]+a[i]+a[i+1]);
    }

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



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

template<typename T>
struct BellmanFord {
	struct Edge {
		const int from;
		const int to;
		const T cost;
		Edge(const int from, const int to, const T cost) :
			from(from),
			to(to),
			cost(cost)
			{}
	};
	const int V;
	vector<vector<Edge>> G;
	int start;
	const T INF = numeric_limits<T>::max();
	vector<T> dist;
	bool hasNegativeCycle = false;
	vector<bool> negative;
	vector<int> rec;
	BellmanFord(const int V) :
		V(V),
		G(vector<vector<Edge>>(V, vector<Edge>())),
		negative(vector<bool>(V))
		{}
	void addEdge(const int from, const int to, const T cost) {
		G[from].emplace_back(from, to, cost);
	}
	bool negativeCycle() {
		return hasNegativeCycle;
	}
	void build(const int start) {
		(*this).start = start;
		dist = vector<T>(V, INF);
		rec = vector<int>(V, -1);
		dist[start] = 0;
		for(int i = 0; i < V; ++i) {
			bool update = false;
			for(int from = 0; from < V; ++from) {
				if(dist[from] == INF) continue;
				for(Edge e : G[from]) {
					if(dist[e.from] + e.cost < dist[e.to]) {
						dist[e.to] = dist[e.from] + e.cost;
						rec[e.to] = e.from;
						update = true;
					}
				}
			}
			if(not update) break;
			if(i == V - 1) hasNegativeCycle = true;
		}
		for(int i = 0; i < V; ++i) {
			bool update = false;
			for(int from = 0; from < V; ++from) {
				if(dist[from] == INF) continue;
				for(Edge e : G[from]) {
					if(dist[e.from] + e.cost < dist[e.to]) {
						dist[e.to] = dist[e.from] + e.cost;
						negative[e.to] = true;
						update = true;
					}
					if(negative[e.from]) {
						negative[e.to] = true;
					}
				}
			}
			if(not update) break;
		}
	}
	T distance(const int to) {
		if(negative[to]) throw "INVALID";
		if(dist[to] == INF) throw "INVALID";
		return dist[to];
	}
	vector<int> route(int to) {
		distance(to);
		vector<int> ret;
		while(to != start) {
			ret.push_back(to);
			to = rec[to];
		}
		ret.push_back(start);
		reverse(ret.begin(), ret.end());
		return ret;
	}
};

int main() {
	int n, m; cin >> n >> m;
	BellmanFord<int64_t> bf(n);
	for(int i = 0; i < m; ++i) {
		int a, b, c; cin >> a >> b >> c;
		bf.addEdge(--a, --b, -c);
	}
	bf.build(0);
	try {
		cout << -bf.distance(n - 1) << '\n';
	}
	catch(...) {
		cout << "inf" << '\n';
	}
	return 0;
}

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

#define rep(i,n) for(i=0;i<(n);i++)
#define For(i,a,b) for(i=(a);i<(b);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const double PI=acos(-1.0);
#define inf 10000000

int main(){
	int i,j,k;
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	int min=inf,max=-1*inf;
	rep(i,n){
		if(min>a[i]){
			min=a[i];
			j=i;
		}
		if(max<a[i]){
			max=a[i];
			k=i;
		}
	}
	if(min==max){
	  cout << 0 << endl;
	  return 0;
	}
	cout << 2*n-1 << endl;
	j++;
	k++;
	if(abs(max)>=abs(min)){
		rep(i,n) cout << k << " " << i+1 << endl;
		For(i,1,n) cout << i << " " << i+1 << endl;
	}else{
		rep(i,n) cout << j << " " << i+1 << endl;
		for(i=n;i>1;i--){
			cout << i << " " << i-1 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

pair<int, int> lr[500000];

int main()
{
    long long n, m;
    cin >> n >> m;
    int max_beg = 0, min_end = 9999999;
    for (int i = 0; i < m; i++)
    {
        cin >> lr[i].first >> lr[i].second;
        max_beg = max(max_beg, lr[i].first);
        min_end = min(min_end, lr[i].second);
    }
    cout << max(0, min_end - max_beg + 1) << endl;
}


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

int main(){
   long long int A, B, C, X, Y;
   std::cin >> A >> B >> C >> X >> Y;
   long long int c;
   if (A+B >= 2*C){
      if (X >= Y){
         c = std::min(2*X*C, 2*C*Y+(X-Y)*A);
      } else{
         c = std::min(2*Y*C, 2*C*X+(Y-X)*B);
      }
   } else{
      c = A*X+B*Y;
   }
   std::cout << c << std::endl;

}


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

int main(){
  long long int N; 
  long long int b;
  long long int r;
  scanf("%ld%ld%ld",&N,&b,&r);
  
  long int C;
  long int E = b + r;
  
  C = N / E;
  
  long int d;
  d = N - C * E;
  if(b == 0){
    printf("%d",0);
  }else{
    if (d < b){
      printf("%ld", d + C * b );
    }else{
      printf("%ld", (C+1) * b );
    }
  }
  
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}



signed main(){
    int a[3];
    FOR(i,3) cin >>a[i];
    sort(a,a+3);
    cout << (a[2]-a[1]) + (a[1]-a[0]) fin;
  
  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
 
fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a = read::<i64>();
    let s = read::<String>();

    match a >= 3200 {
        true => println!("{}",s),
        false => println!("red"),
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
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);
}

//combination(Nが小さい時はこれを使う)
const int MAX = 330000;
int 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;
	}
}
int COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 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;
}

//繰り返し二乗法（Nが大きい時の場合のcombination)
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= (i % mod); res %= mod;
	}
	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;
}
//UnionFind
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
signed main() {
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (i % 3 != 0 && i % 5 != 0)ans += i;
	}
	cout << ans << endl;
	ggr
}


Measured memory_bytes: 3684
#include <stdio.h>
int main(){
    int N, X;
    scanf("%d %d", &N, &X);
    int min = 100000;
    int used = 0;
    for(int i=0;i<N;i++){
        int m;
        scanf("%d", &m);
        min = (m < min ? m : min);
        used += m;
    }
    printf("%d\n", (X - used) / min + N);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;

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

	vector<int> p(N);

	for (int i = 0; i < N; i++) 
	{
		cin >> p[i];
	}

	int counter = 0;

	for (int i = 1; i < N - 1; i++) 
	{
		if (p[i - 1] < p[i] && p[i] < p[i + 1]) counter++;
		else if (p[i + 1] < p[i] && p[i] < p[i - 1]) counter++;
	}

	cout << counter << endl;
	return 0;
}


Measured memory_bytes: 256
#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 N; cin >> N;
    int A[2] = {};
    rep(i, N) {
        int s;
        cin >> s;
        A[s%2]++;
    }
    int a = 1;
    int b = 1;
    rep(i, N){
        a *= 3;
    }
    rep(i, A[0]) {
        b *= 2;
    }
    cout << a - b << endl;



    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define ll long long
using namespace std;
const int MOD = 1000000007;

inline int lgput(int a, int x) {
  int ret = 1;
  while (x > 0) {
    if (x % 2 == 1) {
      ret = (1LL * ret * a) % MOD;
    }
    a = (1LL * a * a) % MOD;
    x /= 2;
  }
  return ret;
}

inline int inv(int a) { return lgput(a, MOD - 2); }

int factorial(int n) {
  int ret = 1;
  for (int i = 1; i <= n; i++) {
    ret = (1LL * ret * i) % MOD;
  }
  return ret;
}

int main() {
  int N;
  cin >> N;
  int A[N + 5];
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
  }
  int invsum[N + 5];
  invsum[0] = 0;
  for (int i = 1; i <= N; i++) {
    invsum[i] = (invsum[i - 1] + inv(i)) % MOD;
  }

  int ans = 0;
  for (int i = 1; i <= N; i++) {
    ans = (ans + 1LL * A[i] * (invsum[i] + invsum[N - i + 1] - 1) % MOD) % MOD;
  }

  ans = (1LL * ans * factorial(N)) % MOD;
  cout << ans << endl;
  return 0;
}

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

#define ll long long
#define deb(x) cerr << #x << ":" << x << "\n"

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

void solve()
{
    map<string,int> mp;
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        mp[s]++;
    }
    cout<<"AC"<<" x "<<mp["AC"]<<"\n";
    cout<<"WA x "<<mp["WA"]<<"\n";
    cout<<"TLE x "<<mp["TLE"]<<"\n";
    cout<<"RE x "<<mp["RE"]<<"\n";
}

int main()
{
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

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

int main()
{
    int N;
    cin >> N;
    string S;
    cin >> S;
    int cntO=0, cntC=0;
    for(int i=0; i<S.length(); i++) {
        if(S[i] == '(') {
            cntO++;
        }
        else if(S[i]==')') {
            if(cntO>0) { cntO--; }
            else { cntC++; }
        }
    }
    for(int i=0; i<cntO; i++) { S = S+')'; }
    for(int i=0; i<cntC; i++) { S = '('+S; }
   
    cout << S << endl;
    return 0;
}

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

using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using f64 = double;
using f80 = long double;

#define FOR(v, a, b) for(i64 v = (a); v < (b); ++v)
#define FORE(v, a, b) for(i64 v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(i64 v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...) ((void)0)
#endif

using namespace std;

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T> void pout(const T &value){std::cout << value << "\n";}
template <typename T, typename ...Args> void pout(const T &value, const Args&... args){std::cout << value << " ";pout(args...);}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}
template <typename T> auto make_vector(int n, int m, const T &value){return vector<vector<T>>(n, vector<T>(m, value));}


struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;



int main(){
  int x,y,z;
  while(cin >> x >> y >> z){
    swap(x, y);
    swap(x, z);
    pout(x, y, z);
  }

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  i64 A, B, C;
  std::cin >> A >> B >> C;
  std::cout << ((C - A) * (C - B) <= 0 ? "Yes" : "No") << std::endl;
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  string s;
  cin >> s;
  if (s == "AAA" || s == "BBB") {
    no();
  }
  yes();
}


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

#define fast ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define int long long
#define endl '\n'

using namespace std;

const int N = 77;
char A[N][N] , B[N][N];
void sol(){
    int n , m ; cin >> n >> m ;
    for(int i = 0 ; i < n ; ++i) for(int j = 0 ; j < n ; ++j) cin >> A[i][j];
    for(int i = 0 ; i < m ; ++i) for(int j = 0 ; j < m ; ++j) cin >> B[i][j];
    for(int i = 0 ; i < n-m+1; ++i){
        for(int j = 0 ; j < n-m+1 ; ++j){
            int c = 0;
            for(int a = 0 ;a < m ; ++a){
                for(int b = 0 ; b < m ; ++b){
                    // cout << A[i+a][j+b];
                    if(B[a][b]==A[i+a][j+b]) c++;
                }
                // cout << endl;
            }
            if(c==m*m){
                cout << "Yes" << endl;
                return;
            }
        }
    }
    cout << "No" << endl;
}

int32_t main(){
    fast;
    int t =1; 
    // cin >> t; 
    while(t--) sol();    
    return 0;
}

Measured memory_bytes: 3644
let solve a s =
  let len = String.length s in
  if s.[a] <> '-' then "No"
  else
    let rec aux i =
      if i >= len then "Yes"
      else if (s.[i] <> '-') || i = a then aux (i + 1)
      else "No"
    in
    aux 0


let () = Scanf.scanf "%d %d\n%s" (fun a _ s -> solve a s) |> print_endline

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

#define LEN 14
#define LIM 2000000

char H[LIM][LEN];

int toInt(char c) {
  if ( c == 'A' ) return 1;
  else if ( c == 'C' ) return 2;
  else if ( c == 'G' ) return 3;
  else if ( c == 'T' ) return 4;
  else return 0;
}

int getKey(char str[]) {
  int sum = 0, p = 1;
  for ( int i = 0; i < strlen(str); i++ ) {
    int v = toInt(str[i]);
    sum += v * p;
    p *= 5;
  }
  return sum;
}

int h1(int key) { return key % LIM; }
int h2(int key) { return 1 + key % (LIM - 1); }
int hashValue(int key, int i) { return (h1(key) + i * h2(key)) % LIM; }

int insert(char str[]) {
  int key = getKey(str);
  for ( int i = 0; i < LIM; i++ ) {
    int h = hashValue(key, i);
    if ( strcmp(H[h], str) == 0 ) {
      return 1;
    } else if ( strlen(H[h]) == 0 ) {
      strcpy(H[h], str);
      return 1;
    }
  }
  return 0;
}

int find(char str[]) {
  int key = getKey(str);
  for ( int i = 0; i < LIM; i++ ) {
    int h = hashValue(key, i);
    if ( strcmp(H[h], str) == 0 ) {
      return 1;
    } else if ( strlen(H[h]) == 0 ) {
      return 0;
    }
  }
  return 0;
}

int main() {
  int n;
  char com[7], str[LEN];
  scanf("%d", &n);

  while( scanf("%s %s", com, str) != EOF ) {
    if ( com[0] == 'i' ) {
      insert(str);
    } else if (com[0] == 'f' ) {
      if (find(str)) {
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }

  return 0;
}



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

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

    string s;
    cin >> s;
    int n = s.size();
    for(int i = 0; i < n; ++i){

        if((i + 1) & 1){
            if(!(s[i] == 'R' || s[i] == 'U' || s[i] == 'D')){
                cout << "No\n";
                return 0;
            }
        }
        else if(!(s[i] == 'L' || s[i] == 'U' || s[i] == 'D')){
                cout << "No\n";
                return 0;
            }
        }

    cout << "Yes\n";

return 0;}


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

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

    int n, a = 0, b = 0, ba = 0, ans = 0;
    cin >> n;

    while (n--) {
        string s;
        cin >> s;
        for (int i = 0; i < s.size() - 1; i++)
            ans += (s[i] == 'A' && s[i + 1] == 'B');

        if (s[0] == 'B' && s.back() == 'A')
            ba++;
        else
            b += (s[0] == 'B'), a += (s.back() == 'A');
    }

    if (ba)
        ans += ba - 1 + (a > 0) + (b > 0), a--, b--;
    ans += max(0, min(a, b));

    cout << ans << '\n';
}


Measured memory_bytes: 3600
def main():
    h, w, target = map(int, input().split())
    inlis = []
    for _ in range(h):
        clis = input()
        inlis.append(clis)
    ans = 0
    #print(inlis[0][2])
    for i in range(2 ** h):
            for k in range(2 ** w):
                tmp = 0
                for l in range(w):
                    for j in range(h):   
                        if ((i >> j) & 1) and ((k >> l) & 1) and inlis[j][l] == "#":
                            tmp += 1
                if tmp == target:
                    ans += 1
                    #print(i,j,k,l)
    print(ans)
if __name__ == "__main__":
    main()


Measured memory_bytes: 67920
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ff first
#define ss second
#define INF (ll) 1e9
#define tt ll testcase; cin>>testcase; while(testcase--)
 
int main(){
	fast;
	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0; i<n; i++){
		cin>>a[i];
	}
	ll dp[n][n]={};
	for(ll l=n-1; l>=0; l--){
		for(ll r=l; r<n; r++){
			if(l==r){
				dp[l][r] = a[l];
			}
			else{
				dp[l][r] = max( a[l] - dp[l+1][r], a[r] - dp[l][r-1]);
			}
		}
	}
	cout<<dp[0][n-1];
}

Measured memory_bytes: 70656
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x;
    cin >> x;
    ll n = (x / 11) * 2;
    ll r = x % 11;
    ll ans = n;
    if(r == 0){
    }else if(r <= 6){
        ans++;
    }else{
        ans += 2;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<bitset>
#include<utility>
#include<sstream>
#include<iomanip>
#include<ctime>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>

using namespace std;
typedef long long ll;
#define MP make_pair

int main(void) {
    int n,t,m[500000]={};
    cin>>n;
    for (int i = 0; i < n-1; i++) {
        cin>>t;
        m[t-1]=m[t-1]+1;
    }

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


    
    return 0;
}

Measured memory_bytes: 5584
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

int main()
{
    vector<int> v;
    int a, b, c, k; cin >> a >> b >> c >> k;
    v.push_back(a);
    v.push_back(b);
    v.push_back(c);
    sort(v.begin(), v.end(), greater<char>());
    
    cout << pow(2, k) * v[0] + v[1] + v[2] << endl;        
    return 0;
}

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

#define int long long
const int mod = 1000000007;
const int max_n = 100005;

int32_t main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    string str;
    cin>>str;
    string temp = "";
    temp += str[0];
    int ans = 1;
    for(int i=1; i<str.length(); i++)
    {
        if(temp.length() == 2)
        {
            ans++;
            temp = str[i];
        }
        else
        {
            if(str[i] == temp[0])
            {
                if(i!=str.length()-1)
                {
                    ans++;
                    temp = str[i];
                    temp+=str[i+1];
                    i++;
                }
            }
            else
            {
                ans++;
                temp = str[i];
            }
            
        }
        
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define repr(i, n) for (int i=n; i > 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x);
using namespace std;
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; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b / gcd(a,b);}

int main() {
    string s;
    cin >> s;
    s.insert(4, " ");
    cout << s << "\n";
}


Measured memory_bytes: 256
package main

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

var sc *bufio.Scanner

const BufferSize = 1024

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

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

var production bool

func debugf(format string, v ...interface{}) {
	if !production {
		//fmt.Printf(format, v...)
	}
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, 1e+6)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	s := make([]int, n)
	for i := range s {
		s[i] = nextInt()
	}

	// 16
	// (4,1) 4,3,7,6,10,9,13,12,16 (4,12)
	// (7,4) 7,3,10,6,13,9,16 (7, 9)
	// (10,7) 10,3,13,6,16 (10,6)
	// (13,10) 13,3,16 (13,3)
	// (16,13) 16
	//
	// n-1 = (a-b)*x+a -> n-a-1 = (a-b) * x
	// a!=2(a-b) -> a != 2b
	// a!=3(a-b) -> 2a != 3b

	// 0 -4 0 -99 31 14 -15 -39 43 18 0`
	// (6,4) 6,2,8,4,10
	// -15+0+43+31+0
	// (10,8) 10
	// (8,6) 8,2,10 (8,2)
	// (6,4) 6,2,8,4,10 (6,4)
	ans := 0
	//dp := make([]int, n)
	u := make([]bool, n)
	for c := 1; c < n; c++ {
		a := n - 1
		debugf("a: %d, c: %d\n", a, c)
		sc := s[a]
		//ans = max(ans, sc)
		//dp[0] = s[a]
		//ans = max(ans, dp[0])
		//debugf("i: %d, a: %d, score: %d\n", 0, a, dp[0])
		debugf("i: %d, a: %d, score: %d\n", 0, a, sc)
		i := 1
		a -= c
		for a > c {
			u[i*c] = true
			if u[n-1-i*c] {
				break
			}
			/*if a%c == 0 && i*c >= a {
				debugf("skip. a: %d, c: %d\n", a, c)
				//a -= c
				break
			}*/
			sc += s[n-1-c*i] + s[c*i]
			ans = max(ans, sc)
			debugf("i: %d, a: %d, score: %d\n", i, a, sc)
			//dp[i] = dp[i-1] + s[n-1-c*i] + s[c*i]
			//ans = max(ans, dp[i])
			//debugf("i: %d, a: %d, score: %d\n", i, a, dp[i])
			i++
			a -= c
		}
		for k := 0; k*c < n-1; k++ {
			u[k*c] = false
		}
	}
	_, _ = fmt.Fprintf(writer, "%d", ans)
}

func main() {
	production = true
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 3072
#pragma GCC optimize("Ofast")
#include  "bits/stdc++.h"
using namespace std;
#define I_AM_SPEED  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define printclock  cerr <<"Time : "<<(double)clock()/(double)CLOCKS_PER_SEC<<" sec\n";
#define mp(a , b)   make_pair(a , b)
#define eb(a)       emplace_back(a)
#define SZ(n)       ((int)(n).size())
#define all(n)      (n).begin(), (n).end()
#define anal           '\n'
#define mod         1000000007
#define fst         first
#define sec         second
#define pr(n)       cerr << n  << " ";
#define pfor(a)       for(auto (w) : (a)) pr(w)
//const double PI = acos(-1.0);
typedef long long ll;
typedef unsigned long long ull;

//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-



//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
int main(){
I_AM_SPEED;
#ifndef ONLINE_JUDGE  
        freopen("input.in", "r", stdin);
        freopen("output.in", "w", stdout);
#endif 
//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
     
        ll x, k, d;
        cin >> x >> k >> d;
        ll rem = abs(x)%d, t = abs(x)/d;
        if(t == k){
            cout << rem << anal;
            return 0;
        }
        else if(k < t){
            if(x > 0) x -= (k*d);
            else x += (k*d);
            cout << abs(x) << anal;
            return 0;
        }
        k -= t;
        if(k&1){
            cout << d - rem << anal;
        }
        else{
            cout << rem << anal;
        }
        



     
//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
//printclock; 
return  0 ;      
}        



      

Measured memory_bytes: 3636
/*Author - Shubham Gupta (@shubham107)*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<ll> vl;		typedef vector<int> vi;
typedef vector<vl> vvl;	  	typedef vector<vi> vvi;
typedef pair<ll, ll> pll;	typedef pair<int, int> pii;
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define INF	ll(1e18)
#ifdef SHUBHAM107
#include "../code-pieces/trace.h"
#else
#define trace(args...)
#endif

ll modpow(ll a, ll b, ll m = MOD) {
	a %= m; ll res = 1; while (b) {if (b & 1)res = res * a % m; a = a * a % m; b >>= 1;}
	return res;
}
ll bpow(ll a, ll b) {ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a) {return modpow(a, MOD - 2, MOD);}
void graph(vvi &adj, int m) {int x, y; forn(i, m) {cin >> x >> y; adj[x - 1].pb(y - 1); adj[y - 1].pb(x - 1);}}

vi vec;
int n, m, q, ans, cur, temp;
vector<pair<pii,pii>> Queries;
void dfs(){
	if(sz(vec) == n){
		int maxm = 0;
		trav(query, Queries){
			if((vec[query.F.S] - vec[query.F.F]) == query.S.F) maxm += query.S.S;
		}
		ans = max(ans, maxm);
	}else{
		forse(i, cur, m+1){
			vec.pb(i);
			temp = cur;cur = i;
			dfs();
			cur = temp;
			vec.pop_back();
		}
	}
}
void solve() {
	cin >> n >> m >> q;
	Queries.resize(q);
	trav(query, Queries) 
	cin >> query.F.F >> query.F.S >> query.S.F >> query.S.S, query.F.F--, query.F.S--;
	cur = 1;
	dfs();
	cout << ans;
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef SHUBHAM107
	freopen("inp.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	freopen("err.txt", "w", stderr);
#endif
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
}


Measured memory_bytes: 3664
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int result = Math.min(n * a, b);

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 23124
n = int(input())
max_count = 0
max_count_number = 1
for i in range(1, n + 1):
    count = 0
    current = i
    while(current % 2 == 0 and current > 0):
        count += 1
        current /= 2
    if max_count < count:
        max_count = count
        max_count_number = i
        
print(max_count_number)

Measured memory_bytes: 3060
N,X,Y=map(int,input().split())
# X,Yが接続されていないとすると，距離kの頂点の数は(i,i+k)(0<=i<=N-k-1)となる．
# そこにX,Yを接続すると，(i,x+k-1) or (i,x-k+1)(0<=i<=N-k-1)を追加する
# 最短距離かぁ．．．
dis_list = [0 for k in range(N-1)]
for i in range(N-1):
    for j in range(i+1,N):
        simple_dis = j-i
        shortcut_dis = abs(X-i-1)+1+abs(Y-1-j)
        dis = min(simple_dis,shortcut_dis)
        dis_list[dis-1]+=1
for d in dis_list:
    print(d)


Measured memory_bytes: 3444
import numpy as np

mat = list()
for _ in range(3):
    for k in [int(i) for i in input().split()]:
        mat.append(k)

n = int(input())
nums = [int(input()) for _ in range(n)]

for num in nums:
    if num in mat:
        mat[mat.index(num)] = 'bingo'

new_mat = np.array([mat[:3], mat[3:6], mat[6:]])


def solve(mat):
    for i in range(3):
        if all(num == 'bingo' for num in mat[i]):
            return 'Yes'
    for j in range(3):
        if all(num == 'bingo' for num in mat[:, j]):
            return 'Yes'
    if all([mat[0][0] == 'bingo', mat[1][1] == 'bingo', mat[2][2] == 'bingo']):
        return 'Yes'
    if all([mat[0][2] == 'bingo', mat[1][1] == 'bingo', mat[2][0] == 'bingo']):
        return 'Yes'

    return 'No'


print(solve(new_mat))


Measured memory_bytes: 14288
#!/usr/bin/env python3
import sys

N = int(input())

list = [1] * (N+1)
ans = 1
for i in range(2,N+1):
    ans += i * (list[i] + 1)
    j = i
    if i != 1:
        while j <= N:
            list[j] = list[j] + 1
            j = j + i

print(ans)


Measured memory_bytes: 145736
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i,a,b) for(int i= a; i < b; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int n;
vector<int> vec;

int main()
{
  cin >> n;
  vec.resize(n, 0);
  int ans = 0;
  rep(i, n) cin >> vec[i];
  while(*max_element(vec.begin(), vec.end()) > 0) {
    int l = 0;
    while(vec[l] == 0) l++;
    ans++;
    while(l < n) {
      if (vec[l] != 0) {
        vec[l]--;
        l++;
      }
      if(vec[l] == 0) break;
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3584
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(read())


def ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from functools import reduce

A, B, C = ints()
K = a_int()

# 全部試してもいいかな
for a in range(K + 1):
    for b in range(a, K + 1):
        if a + b > K:
            break
        c = K - a - b
        if A * pow(2, a) < B * pow(2, b) < C * pow(2, c):
            exit('Yes')
print('No')


Measured memory_bytes: 68020