akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>

#define N 2000001

void maxHeapify(int A[N],int i);
void maxHeapInsert(int A[N], int key);
void heapIncreaseKey(int A[N], int i, int key);
int heapExtractMax(int A[N]);

int heap_size = 0;
//int A[N];

int main(){
  int A[N];
  int i,j,key,max;
  char com[20];
  
  //heap_size = N;

  while(1){
    scanf("%s",com) ;
    
    if ( com[0] == 'i' ){
      scanf("%d", &key);
      maxHeapInsert(A, key);
    } 
    else if ( com[1] == 'x' ){
       max =  heapExtractMax(A);
       printf("%d\n",max);
     }
     else if ( com[1] == 'n' ){
       break;
     }
     
  }   
  
  
  return 0;
}




void maxHeapInsert(int A[],int key){
  
  
  
  heap_size +=1;
  A[heap_size] = (-1000000000);
  heapIncreaseKey(A, heap_size, key);
  
  
}


void heapIncreaseKey(int A[], int i, int key){
  int temp;
  
  
  if(key < A[i]) printf("error\n");
  
  A[i] = key;
  while(i > 1 && A[i/2] < A[i]){
    temp = A[i];
    A[i] = A[i/2];
    A[i/2] = temp;
    i = i/2;
    
    
  } 
}

int heapExtractMax(int A[]){
  int max;

  if(heap_size < 1) printf("heap under \n");
  
  max = A[1];
  A[1] = A[heap_size];
  heap_size -= 1;
  maxHeapify(A, 1);
  return max;
  
}


void maxHeapify(int A[],int i){
  int l,r,largest,temp;
  
  l = 2*i;
  r = 2*i + 1;
  if(l <= heap_size && A[l] > A[i]){
    largest = l;
  }
  else largest = i;
  
  if(r <= heap_size && A[r] > A[largest]){
    largest = r;
  }
  
  if(largest != i){
    temp = A[i];
    A[i] = A[largest];
    A[largest] = temp;
    maxHeapify(A,largest);
  }
  
  
}

Measured memory_bytes: 5664
//2020年4月17日現在

#include<stdio.h>
#include<cmath>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>
#include<queue>
#include<set>
#include<utility>
#include<iomanip>
#include<limits>
#include<thread>
#include<map>
#include<stack>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<tuple>
#include <cstdio>
#include <iterator>

using namespace std;

template <class... A>
void prints() { cout << "\n"; }
template <class... A>
void prints_rest() { cout << "\n"; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }

namespace {
    // printElems(&a[0], &a[n]);　みたいな感じで使う。
    void printElems(const int* begin, const int* end)
    {
        for (const int* p = begin; p != end; ++p) {
            std::cout << *p << ' ';
        }
        std::cout << std::endl;
    }
}

#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n+1; i++)
#define repr(i,n) for(int i=n-1; i>=0; i--)
#define repr1(i,n) for(int i=n; i>0; i--)
#define FOR(i,j,n) for(int i=j; i < n; i++)
#define souatari(i,j,n) rep1(i,n-1)rep(j,i)
#define souatari1(i,j,n) for(int i=2; i<n+1; i++)rep1(j,i-1)
#define mp make_pair
#define F first
#define S second
#define elif else if

typedef long long ll;
typedef vector<int>  vi;
typedef vector<vi>  vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef array<int,3> arr3;
typedef long double D;


const ll llinf =  numeric_limits<ll>::max();
const ll _llinf = numeric_limits<ll>::lowest();
const int inf = numeric_limits<int>::max();
const int _inf = numeric_limits<int>::lowest();
const double dinf = numeric_limits<double>::infinity();
const ll MOD = 1000000007;
const ll BIG = 10000000000000000;


ll a[200005];
bool af[200005];

int main(){
    ll n;
    cin >> n;
    rep(i,n) cin >> a[i];
    map<ll,ll,greater<ll>> m;
    rep(i,n){
        if(m.find(a[i]) != m.end()){
            m[a[i]]++;
        }
        else{
            m.insert(mp(a[i],1));
        }
    }
    int cnt = 0;

    //if(if(m.find(3) != m.end() && m.at(3)>0))


    for(auto i=m.begin(); i!= m.end(); ++i){
        ll tmp = 1;
        ll key = i->first;
        ll val = i->second;

        while(tmp<key) tmp*=2;
        //prints(key,val,tmp);


        if(tmp == key){
            cnt+=val/2;
            m[key] -= val/2;
            continue;
        }
        else{
            if(m.find(tmp-key) != m.end() && m.at(tmp-key)>0){
                cnt+=min(val,m[tmp-key]);
                m[tmp-key]-=min(val,m[tmp-key]);
            }
        }
    }
    prints(cnt);



	return 0;
}



Measured memory_bytes: 14336
import numpy as np

N, M = map(int, input().split())
connect = []
for j in range(M):
    connect.append(list(map(int, input().split())))
plist = list(map(int, input().split()))

count = 0
for n in range(2**N):
  for j in range(M):
    connect_score = sum(2**(np.array(connect[j][1:])-1))
    switch_on = n & connect_score
    num_switch_on = [int(k) for k in str(bin(switch_on))[2:]]
    if (sum(np.array(num_switch_on)) % 2) != plist[j]:
  		 break
    if j == M-1:
        count += 1
  
print(count)

Measured memory_bytes: 12508
n,x=map(int,input().split())
a=list(map(int,input().split()))
a.append(0)
ans=0
for i in range(1,n+1):
  if a[i]+a[i-1]>x:
    ans=ans+a[i]+a[i-1]-x
    a[i]=a[i]-(a[i]+a[i-1]-x)
print(ans)

Measured memory_bytes: 14060
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); (i)--)
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
using namespace std;

int main(){
  int n; long w; cin >> n >> w;
  vector<int> v[4];
  long w0; int v0; cin >> w0 >> v0;
  v[0].push_back(v0);
  rep(i, n-1){
    int wi, vi; cin >> wi >> vi;
    v[wi-w0].push_back(vi);
  }
  int ans = 0;
  rep(i, 4) sort(v[i].begin(), v[i].end(), greater<int>());
  rep(i, (int)v[0].size()+1)rep(j, (int)v[1].size()+1)rep(k, (int)v[2].size()+1)rep(l, (int)v[3].size()+1){
    if(w0*(i+j+k+l)+j+2*k+3*l <= w){
      int vsum = 0;
      rep(m, i) vsum += v[0][m];
      rep(m, j) vsum += v[1][m];
      rep(m, k) vsum += v[2][m];
      rep(m, l) vsum += v[3][m];
      ans = max(ans, vsum);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define all(x) (x).begin(),(x).end()
#define vsort(v) sort((v).begin(), (v).end())
#define gsort(v) tsort(v); reverse((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define cosp(x) cout<<(x)<<' '
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
typedef long long lint;

lint dx[8] = { 0,1,1,1,0,-1,-1,-1 },
dy[8] = { 1,1,0,-1,-1,-1,0,1 };

template<class T>inline bool maxi(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool mini(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

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

	lint x, a, b; cin >> x >> a >> b;
	if (b-a <= 0)co("delicious");
	else if (b-a <= x)co("safe");
	else co("dangerous");
	gc();
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int d=a*b<c?a*b:c;
    cout<<d;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
#include<assert.h>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }



void solve(void)
{
  int N,X;
  cin>>N>>X;
  int res = 0;
  for (int i = 0; i < N; i++)
  {
    int Y ;cin>>Y;
    res = __gcd(res,abs(Y-X));
  }
  cout<<res<<endl;
  
    
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 256
N=int(input())
ans=0
if N==1:
    ans=0
else:
    for i in range(1,int(N**0.5)+1):
        if (N-i)%i==0:
            q=(N-i)//i
            if N%q==i:
                ans+=(N-i)//i
print(ans)

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int mod=1000000007;

int N;

int dp[1111111];
int S[1111111];

signed main(){
    cin>>N;

    dp[0]=1;S[0]=1;
    for(int i=1;i<N;i++){
        dp[i]=dp[i-1];
        if(i>=3)dp[i]=(dp[i]+S[i-3])%mod;
        S[i]=(S[i-1]+dp[i])%mod;
    }

    int ans=0;
    rep(i,N){
        if(i==N-1)ans=(ans+dp[i]*N)%mod;
        else{
            ans=(ans+dp[i]*(N-1)%mod*(N-1))%mod;
            ans=(ans+dp[i]*(i+1+(i!=N-2)))%mod;
        }
    }

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


Measured memory_bytes: 16768
import itertools
import math
#print(3 & (1 << 0))
def main():
    N = int(input())
    items = [i+1 for i in range(N)]

    locations=[]
    for i in range(N):
        locations.append(list(map(int, input().split())))

    paths =list(itertools.permutations(items))

    sum = 0
    for path in paths: # path = [1,2,3,4,5]
        for i in range(len(path)-1):
            from_idx = path[i] -1
            to_idx = path[i+1] -1
            xdiff= locations[from_idx][0] - locations[to_idx][0]
            ydiff= locations[from_idx][1] - locations[to_idx][1]
            sum = sum + math.sqrt(xdiff**2 + ydiff**2)
    print( sum / len(paths))
main()


Measured memory_bytes: 13980
// A.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

int main(int argc, char* argv[]) {
	int a, b;
	cin >> a >> b;
	a = (a + 13) % 15;
	b = (b + 13) % 15;
	cout << (a == b ? "Draw" : (a > b ? "Alice" : "Bob")) << endl;
	return 0;
}


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

using namespace std;

#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>
#define ll long long int
#define mod 1000000007
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define prec(n) fixed << setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int>>
#define PI 3.1415926535897932384626
#define bits(n) __builtin_popcount(n)

void solve()
{
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    ll res = 0;
    for (int i = 1; i < n; i++)
    {
        if (a[i - 1] > a[i])
        {
            res += a[i - 1] - a[i];
            a[i] = a[i - 1];
        }
    }
    cout<<res;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input1.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output1.txt", "w", stdout);
#endif

    int t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 4368
#include "bits/stdc++.h"
using namespace std;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int main() {
	int N, M; cin >> N >> M;
	UnionFind uf(N);
	for (int i = 0; i < M; ++i) {
		int a, b; cin >> a >> b;
		a--; b--;
		uf.unionSet(a, b);
	}
	set<int>aset;
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		int num = uf.size(i);
		int root = uf.root(i);
		if (aset.find(root) == aset.end()) {
			if (num == 1)ans++;
			else ans--;
			aset.emplace(root);
		}
	}
	cout << (abs(ans)) << endl;
	return 0;
}

Measured memory_bytes: 3136
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	int num;
	scanf("%d", &num);
	int a1 = 0, a2 = 0, a4 = 0;
	for (int i = 0; i < num; i++)
	{
		int z;
		scanf("%d", &z);
		if (z % 4 == 0)a4++;
		else if (z % 2 == 0)a2++;
		else a1++;
	}
	if (a2 == 0)
	{
		printf((a1 <= a4 + 1) ? "Yes\n" : "No\n");
	}
	else
	{
		printf((a1 <= a4) ? "Yes\n" : "No\n");
	}
}

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

int main() {
	ll n;
	cin>>n;
	ll a[n][3],dp[n][3];
	for(ll i=0;i<n;i++){
		cin>>a[i][0]>>a[i][1]>>a[i][2];
		dp[i][0]=0;
		dp[i][1]=0;
		dp[i][2]=0;
	}
	dp[0][0]=a[0][0];
	dp[0][1]=a[0][1];
	dp[0][2]=a[0][2];
	for(ll i=0;i<n-1;i++){
		for(ll j=0;j<3;j++){
			for(ll k=0;k<3;k++){
				 if(j==k)continue;
					dp[i+1][k]=max(dp[i+1][k],dp[i][j]+a[i+1][k]);
				
			}
		}
		
	}
	ll maxi=-10000000000000;
	for(ll i=0;i<3;i++)maxi=max(maxi,dp[n-1][i]);
	cout<<maxi;
	return 0;
}

Measured memory_bytes: 4992
(let ((N (read))
      A
      (max 0))
  (dotimes (i N) (push (read) A))
  (format t "~A~%"
          (dotimes (i N max)
            (let* ((x (nth i A))
                   (m (reduce #'max (mapcar #'(lambda (y) (abs (- x y))) A))))
              (setf max (max max m))))))

Measured memory_bytes: 13156
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
    fastIO;

    int n, x;
    while (cin >> n >> x) {
        int sum = 0;
        if (n == 0 && x == 0)
            break;

        for (int i = 1; i <= n; i++) {
            for (int j = i + 1; j <= n; j++) {
                for (int k = j + 1; k <= n; k++) {
                    if (i + j + k == x)
                        sum++;
                }
            }
        }
        cout << sum << endl;
    }
}




Measured memory_bytes: 3144
#include <bits/stdc++.h>
long long r,n,a[500000],b[500000],c[500000],i;
using namespace std;
#define f for(i = 0; i < n; i++)
signed main()
{
cin >> n;
f cin >> a[i];
f cin >> b[i];
f cin >> c[i];
sort(a, a + n);
sort(b, b + n);
sort(c, c + n);
f r += (lower_bound(a, a + n, b[i]) - a) * (c + n - upper_bound(c, c + n, b[i]));
cout << r;
}

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

#define loop(i,n) for(int i=1;i<=n;i++)
int dp[102][102][4];
const int W=0;
const int S=2;
const int E=0;
const int N=1;

signed main() {
  int w,h;
  while(cin>>w>>h,w){
    dp[1][1][W|E]=1;
    dp[1][1][S|N]=1;
    loop(i,w)loop(j,h){
      if(i==1&&j==1)continue;
      dp[i][j][W|N]=dp[i-1][j][W|E];
      dp[i][j][W|E]=dp[i-1][j][W|E]+dp[i-1][j][S|E];
      dp[i][j][S|N]=dp[i][j-1][W|N]+dp[i][j-1][S|N];
      dp[i][j][S|E]=dp[i][j-1][S|N];
      loop(d,4)dp[i][j][d-1]%=100000;
    }
    cout<<(dp[w][h][W|E]+dp[w][h][S|N])%100000<<endl;
  }
  return 0;
}

Measured memory_bytes: 3248
#include<stdio.h>

int main(){
	
	int a,b,c;
	
	scanf("%d %d %d",&a,&b,&c);
	
	int trip =a*b;
	
	if(trip<=c){
		
		printf("%d\n",trip);
		
	}
	
	else{
		
		printf("%d\n",c);
	}
	
	
	return 0;
}

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

main(){
	ios::sync_with_stdio(0);cin.tie(0);
	string s;
	cin >> s;
	int S = 0, T = 0, ans = 0;
	for (int i = 0;  i< s.size(); i++){
		if (s[i] == 'S')
		S++;
		else T++;
		if (S == 0)
		ans += T, T = 0;
		int x = min(S,T);
		S-=x;T-=x;
	}
	ans += S;
	ans += T;
	cout << ans;
		
}

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

int main(){
 
  int n; cin >> n;
  double T, A; cin >> T >> A ;
  double x;
  double y = 0.006;
  double ans = 1000000.0;
  int pos = -1;
  for(int i = 0; i < n; ++i){
     cin >> x;
     double temp = T - (x*y);
     if(ans > abs(temp - A) ){
       ans = abs(temp - A); pos = i + 1;
       //cout << ans << '\n';
     }
  }
  cout << pos << '\n';
}

Measured memory_bytes: 3712
#include<vector>
#include<map>
#include<algorithm>
#include<set>
#include<iostream>
#include<string>
#include<set>
#include<queue>
#include<random>
//#include<unordered_set>
 
using namespace std;
 
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
 
tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> st;*/
 
#pragma GCC optimize("Ofast")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
 
#define pb push_back
#define ld long double
#define int long long
 
mt19937 rnd(51);
 
int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ld n;
	ld b;
	cin >> n >> b;
	cout << (int)(n * b);
	return 0;
}

Measured memory_bytes: 3740
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int a[100000];
int n;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    sort(a, a + n);
    ll sum = a[0];
    int sol = 1;
    for (int i = 1; i < n; ++i)
    {
        if (sum * 2 < a[i])
            sol = 0;
        sum += a[i];
        sol++;
    }
    cout << sol;
}


Measured memory_bytes: 640
def main():
    n = int(input())
    a = [int(i) for i in input().split()]

    aabs = [abs(aa) for aa in a]
    tmp = 0
    minabs = min(aabs)
    for aa in a:
        if aa < 0:
            tmp += 1
    if tmp%2==1:
        print(sum(aabs) - 2* minabs)
    else:
        print(sum(aabs))
    # 3 5 7

if __name__ == '__main__':
    main()


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define LOOP(i) while(i--)
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	vector<int> C(8),J({1,2,1,2,1,4,1,4});
	while(cin>>C[0]){
		REP(i,7) cin>>C[i+1];
		int minV=0,minC=1<<24;
		REP(i,8){
			int sum = 0;
			REP(j,8){
				sum += max(0,C[j]-J[j]);
			}
			if(sum<minC){
				minC = sum;
				int V=0;
				REP(j,8){
					V *= 10;
					V += J[j];
				}
				minV = V;
			}
			else if(sum==minC){
				int V=0;
				REP(j,8){
					V *= 10;
					V += J[j];
				}
				if(V<minV){
					minV = V;
				}
			}
			rotate(J.begin(),J.begin()+1,J.end());
		}
		REP(i,8){
			C[i] = minV%10;
			minV /= 10;
		}
		reverse(ALL(C));
		REP(i,7) cout << C[i] << ' ';
		out(C[7]);
	}
	
	return 0;
}


Measured memory_bytes: 3144
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderD
{
    private static List<Tuple<int, int>>[] to;
    private static int[] answer;


    static void Main()
    {
        int mod = 1000000007;
        int n = int.Parse(Console.ReadLine());

        long[] a = new long[n];
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            for (int i = 0; i < n; i++)
            {
                a[i] = long.Parse(words[i]);
            }
        }

        long answer = 0;
        for (int i = 0; i < 60; i++)
        {
            long one = 0;
            long zero = 0;
            for (int j = 0; j < n; j++)
            {
                long num = a[j];
                if ((1 & (num >> i)) == 1)
                {
                    one++;
                }
                else
                {
                    zero++;
                }
            }
            answer += (one * zero % mod) * ((long)Math.Pow(2, i) % mod);
            answer = answer % mod;
        }

        Console.WriteLine(answer);
    }
}

Measured memory_bytes: 50632
#include<stdio.h>
int main(void)
{
    int n,m,i,a[10000];
    scanf("%d %d",&n,&m);
    for(i=0;i<m;i++){
        scanf("%d",&a[i]);
    }
    for(i=0;i<m;i++){
        n=n-a[i];
    }
    if(n<0){
    printf("-1\n");
    } else {
        printf("%d\n",n);
    }
    return 0;
}

Measured memory_bytes: 1760
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define rep1(i,n) for(int i=1; i<(int)n; i++)
#define repa(i,a,n) for(int i=(a); i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
#define COUT(x) cout<<(x)<<endl
#define YES(x) cout<<(x?"YES":"NO")<<endl
#define Yes(x) cout<<(x?"Yes":"No")<<endl
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
const int mod = 1e9+7;
int gcd(int a, int b){if(a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a / gcd(a, b)*b;}

int N, M, K, H, W, L, R, X;
string S, T;
int cnt(int a, int b, int c){
  int mx = b/c -(a-1)/c;
  return mx;
}

signed main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int ans = 0;
  int cd = lcm(c,d);
  ans = b-a+1 - cnt(a,b,c) - cnt(a,b,d) + cnt(a,b,cd);
  
  COUT(ans);
  return 0;
}


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

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
    }
    if n%2 == 0 {
        puts!("{}\n", n/2-1);
    } else {
        puts!("{}\n", n/2);
    }
}


Measured memory_bytes: 4352
from collections import defaultdict
CH = defaultdict(list)

N, M = map(int, input().split())
P = [[] for _ in range(N)]
ans = [0] * (N-1)

for _ in range(M):
  A, B = map(int, input().split())
  P[A-1].append(B)
  P[B-1].append(A)

#print(P)

def bfs(s):
    d = [-1] * N
    d_pre = [0] * N
    d[s-1] = 0
    p_old = [s]
    cnt = 1
    #print(d, d_pre, p_old)
    while p_old:
      p_new = []
      for i in p_old:
        for j in P[i-1]:
          if d[j-1] == -1:
            d[j-1] = cnt
            d_pre[j-1] = i
            p_new.append(j)
      p_old = p_new
      cnt += 1
      #print(d, d_pre, p_old)
    return d_pre

print("Yes")
for i in bfs(1)[1:]:
  print(i)

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

const int MAX_N = 1e5;
int arr[MAX_N];

int main(void)
{
    cin.sync_with_stdio(false); cin.tie(NULL);
    int N;  cin >> N;
    int res = 0;

    for (int i = 0; i < N; i ++)
        cin >> arr[i];

    sort(arr, arr + N);

    for (int X = 0; X < 1e5; X ++)
    {
        int tmp = upper_bound(arr, arr + N, X + 1) - lower_bound(arr, arr + N, X - 1);
        res = max(res, tmp);
    }

    cout << res << endl;


}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,a[200009];
ll b[200009],num=0;
ll f(ll x)
{
    return x*(x-1)/2;
}
int main()
{
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
        scanf("%d",&a[i]),b[a[i]]++;
    for(int i=1; i<=n; i++)
        num+=f(b[i]);
    for(int i=1; i<=n; i++)
        printf("%lld\n",num-(b[a[i]]-1));
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
typedef double ld;

#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define MOD 1000000007
#define PI 3.14159265


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

    int n;
    cin >> n;
    if (n < 1200) {
        cout << "ABC" << endl;
    }
    else if (n >= 1200 && n < 2800) {
        cout << "ARC" << endl;
    }
    else {
        cout << "AGC" << endl;
    }


    return 0;
}


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


#define M_MAX 20
#define N_MAX 50000
#define INFTY 1 << 29

int main(){
int n;
cin >> n;
int count=0;
for(int i=1;i<=n;i++){
int s=log10(i);
if(s%2==0)count++;
}
cout <<count;

}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <limits>

using namespace std;

long long count_bit(long long n, long long b) {
	return (b / 2) * ((n + 1) / b) + max((n + 1) % b - (b / 2), 0ll);
}

int main (int argc, char* argv[]) {
	long long a, b;
	cin >> a >> b;

	long long res = 0;
	long long base = 2;
	for (int i = 0 ; i < 60; i++) {
		long long a_bits = a > 0 ? count_bit(a - 1, base) : 0;
		long long b_bits = count_bit(b, base);
		long long between_bits = b_bits - a_bits;
		if (between_bits & 1) {
			res = res | (1ll << i);
		}
		base *= 2;
	}
	cout << res << endl;
}


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

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

//そっかー

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint(), M = getint();
	int E[100001], H[100001] = {}, n[100001];
	int k = 1;
	rep(i, N) {
		int a = getint();
		E[k] = getint();
		n[k] = H[a];
		H[a] = k++;
	}
	priority_queue<int> que;

	int kotae = 0;
	int j = 0;
	rep1(i, M) {
		for (int j = H[i]; j; j = n[j]) que.push(E[j]);
		if (que.size()) {
			kotae += que.top();
			que.pop();
		}
	}

	printf("%d", kotae);

	Would you please return 0;
}

Measured memory_bytes: 2172
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanLines)

	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())

	sc.Scan()
	s := strings.Split(sc.Text(), " ")

	A := make([]int, n)
	for i, v := range s {
		A[i], _ = strconv.Atoi(v)
	}

	cnt := 0
	for i := 0; i < n; i++ {
		minj := i
		for j := i; j < n; j++ {
			if A[j] < A[minj] {
				minj = j
			}
		}
		if A[i] != A[minj] {
			A[i], A[minj] = A[minj], A[i]
			cnt++
		}
	}

	for i, v := range A {
		fmt.Print(strconv.Itoa(v))
		if i < n-1 {
			fmt.Print(" ")
		} else {
			fmt.Println()
		}
	}
	fmt.Println(cnt)
}



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

using namespace std;
const string filename = "test";

#define int long long

int n, l, t;
map<int, int> cnt_val;
int x[100011], w[100011], pos[100011];
int ans[100011], p[200011];

int cal(int z) // Numbers of collisions between ant z and the others.
{
	int cnt = 0;
	for (int i = 0; i < n; i++)
		if (i != z && w[i] != w[z])
		{
			int d = 0;
			if (w[z] == 1 && w[i] == 2)
			{
				if (x[z] < x[i]) d = x[i] - x[z];
				else d = l - x[z] + x[i]; 	
			}
			else 
			{
				if (x[z] > x[i]) d = x[z] - x[i];
				else d = l - x[i] + x[z];
			}
			if (2 * t >= d)
				cnt += (1 + (t * 2 - d)/l);
		}
	return cnt;	
}

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

	//freopen( (filename + ".inp").c_str(), "r", stdin);
	//freopen( (filename + ".out").c_str(), "w", stdout);

	cin >> n >> l >> t;
	vector<int> final_pos;
	for (int i = 0; i < n; i++)
	{
		cin >> x[i] >> w[i];
		if (w[i] == 1) 
			pos[i] = (x[i] + t)%l;
		else pos[i] = ((x[i] - t)%l + l)%l;
		cnt_val[pos[i]]++;
		final_pos.push_back(pos[i]);
	}
	sort(final_pos.begin(), final_pos.end());
	if (final_pos.back() == final_pos[0]) // All ants have the same ending
	{
		for (int i = 0; i < n; i++)
			cout << final_pos[0] << '\n';
		return 0;
	}

	for (int i = 0; i < 2*n; i++)
	{
		if (i < n) p[i] = i;
		else p[i] = i - n;
	}
	int s = -1;
	for (int i = 0; i < n; i++)
		if (cnt_val[pos[i]] == 1)
		{
			s = i;
			break;
		}
	//cerr << "S: " << s << '\n';
	int cnt = cal(s);
	int id = (s + cnt) % n;	
	if (w[s] == 2) id = ((s - cnt)%n + n)%n;
	//cerr << '?' << id << ' ' << pos[s] << '\n';
	// I'm so dumb, i just need to find the value of pos that is unique, lul
	// id is the index of the ant that its final pos is equal to pos[s]  
	// since we have the id, the final pos of 1 ant, we create the answer using the previous final_pos array
	for (int i = 0; i < final_pos.size(); i++)
		if (final_pos[i] == pos[s])
		{
			int cur = id;
			ans[cur] = pos[s];
			for (int j = (i + 1) % (int)(final_pos.size()); j != i; j = (j + 1) % (int)(final_pos.size()))
			{
				//cerr << '?' << final_pos[j] << '\n';
				cur++;
				//cerr << '!' << p[cur] << '\n';
				ans[p[cur]] = final_pos[j];
			}
		}
	for (int i = 0; i < n; i++)
		cout << ans[i] << '\n';
}

Measured memory_bytes: 15056
// Bismillahirrahmanirrahim
#include<bits/stdc++.h>
using namespace std;
#define int long long
vector<int> vec;
int n;
int bins(int bas, int son) { // son dan küçük en büyük index ve bas tan büyük en küçük index.
	    int l = 0;
	    int r = n - 1;
	    int leftGreater = n;
	    while (l <= r) {
	        int m = l + (r - l) / 2;
	        if (vec[m] > bas) {
	            leftGreater = m;
	            r = m - 1;
	        }

	        else
	            l = m + 1;
	    }

	 int left = 0;
	 int right = n - 1;

	 while (left <= right) {
			 int mid = (right + left) / 2;

			 // Check if middle element is
			 // less than or equal to key
			 if (vec[mid] < son) {

					 left = mid + 1;
			 }
			 else
					 right = mid - 1;
	 }
	 	//cout <<right <<" " << leftGreater << endl;
	    return right - leftGreater + 1;
	}




signed main() {
		 cin >> n;
		for(int i = 0; i < n; i++) {
			int x; cin >> x; vec.push_back(x);
		}
		sort(vec.begin(), vec.end());
		//cout << bins(2,4) << endl;
		int son_res = 0;
		for(int i = 0; i < n; i++) {
			int res;
			for(int j = i+1; j < n; j++){
				int bas = vec[j] - vec[i];
				int son = vec[j] + vec[i]; // All numbers that satisify bas < vec[k] < son.
				res = bins(bas, son);
				//cout << res << " " << vec[i] << " " << vec[j] <<endl;
				if(bas < vec[i] && vec[i] < son) {res--;}
				if(bas < vec[j] && vec[j] < son) res--;
				//cout << res << endl;cout << "-----------" <<endl;
				son_res += res;
			}
		}
		cout << son_res/3 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
#include<iostream>
#include <string>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int x,y;
	cin >> x>> y;
    string ans;
    if(x+y<10) cout << x+y << endl;
    else cout << "error" << endl;
      
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int m,f,r;
	for(int i=1;;i++)
	{
		scanf("%d %d %d",&m,&f,&r);
		if(m==-1&&f==-1&&r==-1) break;
		else if(m==-1||f==-1) printf("F\n"); 
		else if(m+f>=80) printf("A\n"); 
		else if(m+f<80&&m+f>=65) printf("B\n"); 
		else if((m+f<65&&m+f>=50)||(m+f<50&&m+f>=30&&r>=50) ) printf("C\n"); 
		else if(m+f<50&&m+f>=30) printf("D\n"); 
		else if(m+f<30) printf("F\n"); 
	}
	return 0;
}

Measured memory_bytes: 1012
H, W = list(map(int, input().split(' ')))
import numpy as np
import sys
grid = np.zeros((H, W))
for h in range(H):
  grid[h,:] = [0 if g == '.' else 1 for g in input()]
  
# print(grid)
for h in range(H):
  for w in range(W):
    if grid[h, w] == 0:
      continue
    
    around = []
    if h > 0:
      around.append(grid[h-1, w])
    if w > 0:
      around.append(grid[h, w-1])
    if h < H-1:
      around.append(grid[h+1, w])
    if w < W-1:
      around.append(grid[h, w+1])
    if 1 in around:
      pass
    else:
      # print(h, w, around)
      print('No')
      sys.exit()
print('Yes')


Measured memory_bytes: 12408
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <deque>
#include <queue>//for queue and priority_queue
#include <fstream>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#define endl "\n"
typedef long long ll;
using namespace std;
void Lancer() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
bool isPrime(ll n){
	if (n == 2 || n == 3 || n == 5)
		return true;
	else if (n % 2 == 0 || n % 3 == 0 || n % 5 == 0 || n == 1)
		return false;
	else {
		for (int i = 5; i <= sqrt(n); i += 2){
			if (n%i == 0)
				return false;
		}
		return true;
	}
}

//char arr[57][57];
int main(){
	Lancer();
	ll n,res=1;
	cin >> n;
	vector<int>vec(n);
	for (int i = 0; i < n; i++)cin >> vec[i];
	sort(vec.begin(), vec.end());
	for (int i = 0; i < n - 1; i++){
		if (vec[i + 1] != vec[i])
			res++;
	}
	cout << res;
	cout << endl;
	return 0;
}


Measured memory_bytes: 3624
package main

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

func solve() {
	a, p := getInt(), getInt()
	kakera := a*3 + p

	ans := kakera / 2
	fmt.Fprintln(wr, ans)
}

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

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

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

func getIntSlice(n int) (ret []int) {
	ret = make([]int, n)
	for i := range ret {
		ret[i] = getInt()
	}
	return
}

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

func getRunes() (ret []rune) {
	ret = []rune(getString())
	return
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const double pi = std::acos(-1);
int main()
{
 int a,b,h,m;
 cin>>a>>b>>h>>m;
 if(b<a)
 {
 	int temp=b;
 	b=a;
 	a=temp;
 }
 double ha,ma;
 ha=1.0;
 ma=1.0;
 ma*=m;
 ma/=60;
 ha*=h;
 ha/=12;
 ha*=360;
 ha+=ma*30;
 ma*=360;
 double an;
 if(ma>ha)
 an=ma-ha;
 else
 an=ha-ma;
 //cout<<an<<endl;
 int x=2*a*b;
 an=cos(an*pi/180.0);
 an=-1*x*an;
 double ans=sqrt(a*a+b*b+an);
 std::cout << std::setprecision(10) <<ans<<endl;
 return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int MOD=1e9+7;
ll INF=1e18;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};

int main(){
    string s; cin>>s;
    int n=s.size();
    ll k; cin>>k;
    if(s[0]!='1'){
        cout << s[0] << endl;
    }
    else{
        int cnt=0;
        string t;
        for(int i=0; i<n; i++){
            if(s[i]=='1') cnt++;
            else{
                t=s[i];
                break;
            }
        }
        if(k<=cnt){
            cout << 1 << endl;
        }
        else{
            cout << t << endl;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>

using namespace std;
// for loop
#define F(i, L, R) for(int i = L; i < R; i++)
#define FE(i, L, R) for(int i = L; i <= R; i++)
// for (reversed)
#define FR(i, L, R) for(int i = L; i > R; i--)
#define FRE(i, L, R) for(int i = L; i >= R; i--)

// data types
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned shoft

// vectors
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
#define ALL(c) (c).begin(),(c).end()
#define last(vec) vec.size()-1
#define lastEle(vec) vec[last(vec)]

// debug
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl;
#define printA(a, L, R) FE(i, L, R) cout << a[i] << (i==R?'\n':' ')
#define printAF(a, L) printA(a, 0, L-1)
#define printV(a) printA(a, 0, a.size()-1)

// utils
#define char2int(c) (c-'0')
#define bit(x, i) (x&(1<<i))
#define space ' '

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    int sum = 0;
    FE(i, a, b){
        if(c % i == 0)sum++;
    }

    cout << sum << endl;
    return 0;
}


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

using namespace std;

int main()
{
    string s;
    cin>>s;
    if(s=="AKIHABARA")
        puts("YES");
    else if(s=="KIHABARA")
        puts("YES");
    else if(s=="AKIHBARA")
        puts("YES");
    else if(s=="AKIHABRA")
        puts("YES");
    else if(s=="AKIHABAR")
        puts("YES");
    else if(s=="KIHBARA")
        puts("YES");
    else if(s=="AKIHBRA")
        puts("YES");
    else if(s=="AKIHABR")
        puts("YES");
    else if(s=="KIHABAR")
        puts("YES");
    else if(s=="KIHBRA")
        puts("YES");
    else if(s=="AKIHBR")
        puts("YES");
    else if(s=="KIHABR")
        puts("YES");
     else if(s=="KIHBAR")
        puts("YES");
    else if(s=="KIHBR")
        puts("YES");
    else
        puts("NO");
    return 0;

}


Measured memory_bytes: 256
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <string>


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

  std::string s;
  std::cin >> s;
  std::replace(s.begin(), s.end(), ',', ' ');
  std::cout << s << std::endl;

  return EXIT_SUCCESS;
}


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

int main() {
    string str;
    string tmp = "abcdefghijklmnopqrstuvwxyz";
    int tmpMax = 0;
    int Max = 0;
    int Min = 9999;
    bool chk = false;

    cin >> str;

    for (int i = 0; i < tmp.size()-1; i++){
        tmpMax = 0;
        Max = 0;
        chk = false;

        for (int j = 0; j < str.size(); j++)
        {
            if(tmp.at(i) != str.at(j)){
                tmpMax++;
            }else{
                Max = max(Max, tmpMax);
                tmpMax = 0;
                chk = true;
            }

            if(j == str.size() - 1){
                Max = max(Max, tmpMax);
            }
        }

        if(chk == false) continue;
        Min = min(Min, Max);
    }

    if(Min == 9999) cout << 0;
    else cout << Min;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <tuple>
#include <cmath>
#include <map>

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define F first
#define S second

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )

template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

constexpr ll MOD = 1000000007LL;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

template<typename T = ll> class UnionFind {
public:
	UnionFind( T n ) { rep( i, n ) { par.resize( n ); siz.resize( n ); par[i] = i; siz[i] = 1; } }
	T find( T x ) { if ( x == par[x] ) return ( x ); else return( par[x] = find( par[x] ) ); }
	void unite( T x, T y ) { T xx = find( x ); T yy = find( y ); if ( xx == yy ) return;
		if ( siz[xx] <= siz[yy] ) swap( xx, yy ); par[yy] = xx; siz[xx] += siz[yy]; }
private:
	vector<T> par, siz;
};

template<typename T = ll> T power( T a, T b, T m = MOD ) {
	T res = 1;
	while ( b > 0 ) { if ( b & 1 ) res = res * a % m;
		a = a * a % m; b >>= 1; }
	return ( res );
}

/*
constexpr ll MAX = 500010;
ll fact[MAX];
ll inv[MAX];
ll inv_fact[MAX];

template<typename T> void initComb( T n, T m = MOD )
{
	fact[0] = fact[1] = inv_fact[0] = inv_fact[1] = 1;
	inv[1] = 1;
	for ( int i = 2; i < n; i++ ) {
		fact[i] = ( fact[i - 1] * i ) % m;
		inv[i] = m - inv[m % i] * ( m / i ) % m;
		inv_fact[i] = inv_fact[i - 1] * inv[i] % m;
	}
}

template<typename T> T comb( T n, T r, T m = MOD )
{
	if ( n < r ) return ( 0 );
	if ( n < 0 || r < 0 ) return ( 0 );
	return ( fact[n] * ( inv_fact[r] * inv_fact[n - r] % m ) % m );
}
*/

void replace( string &s, string t, string r ) {
	string::size_type p = 0;
	while ( ( p = s.find( t, p ) ) != string::npos ) {
		s.replace( p, t.length(), r );
		p += r.length();
	}
}


int main()
{
	int N, A, B;
	cin >> N >> A >> B;

	if ( A * N <= B )
	{
		cout << ( A * N ) << endl;
	}
	else
	{
		cout << B << endl;
	}

	return ( 0 );
}


Measured memory_bytes: 256
#include <iostream>

int main(void){
    long long int a(0), b(0);
    
    std::cin >> a >> b;
    
    if(a%2 != b%2){
        std::cout << "IMPOSSIBLE" << std::endl;
    }else{
        const long long int k = (a + b) / 2;
        std::cout << k << std::endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
import           Control.Monad (guard)
import           Data.Bits     (bit, (.&.))
import           Data.List     (inits, mapAccumL, tails, unfoldr)
import           Data.Tuple    (swap)

main :: IO ()
main = do
  [n, k] <- take 2 . map read . words <$> getLine
  as <- take n . map read . words <$> getLine
  print $ f k as

f :: Int -> [Int] -> Int
f k as = sum $ snd $ mapAccumL g beautifulnesses bits
  where
    beautifulnesses = map sum . concatMap (tail . inits) . init . tails $ as
    bits = reverse $ map bit [0 .. bitSize (maximum beautifulnesses)]
    g bs i =
      let
        bs' = filter ((== i) . (.&. i)) bs
      in
        if length bs' >= k then (bs', i) else (bs, 0)

bitSize :: Int -> Int
bitSize = length . toDigits 2

toDigits :: Integral a => a -> a -> [a]
toDigits base = reverse . unfoldr step
  where
    step n = do
      guard $ n /= 0
      return $ swap $ divMod n base


Measured memory_bytes: 43388
import java.util.Objects;
import java.util.Scanner;

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

  		Scanner scanner = null;
		try {
			scanner = new Scanner(System.in);
			 
			int ACookieNum = scanner.nextInt();
			int BCookieNum = scanner.nextInt();
			int CCookieNum = scanner.nextInt();
			 
			int poisonRecovery = ACookieNum + BCookieNum;
			 
			if (poisonRecovery >= CCookieNum){
			  System.out.println( BCookieNum + CCookieNum) ;
			} else {
                int canEatNum = ACookieNum + 1;
				if (canEatNum == CCookieNum) {
                  System.out.println(CCookieNum); 
                } else{
                  int remnantNum = CCookieNum - canEatNum;
                  
                  if (remnantNum >= BCookieNum){
                    System.out.println(canEatNum + (BCookieNum * 2));
                  }  else {
                    System.out.println(canEatNum + remnantNum + BCookieNum -1); 
                  }  
                }
			}
			} finally {
				if (!Objects.isNull(scanner)) {
					scanner.close();
				}
			}
		}
}


Measured memory_bytes: 23760
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int, int> P;
 
int main(){
  long double a, b, h, m;
  cin >> a >> b >> h >> m;
  const long double PI = 3.14159265358979323846264338;
  long double theta=0;
  h = PI*h/6.0f + PI*m/360.0f;
  m = PI*m/30.0f;
  theta = h-m;

  //余弦定理
  long double c = sqrt(a*a+b*b-2.0f*a*b*cos(theta));
  cout << fixed << setprecision(10) << c << endl;
  return 0;
}

Measured memory_bytes: 4164