akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#define repd(i,x,y) for (int i=x; i>=y; --i)
using namespace std;

typedef long long LL;
LL l,r;

int main()
{
    scanf("%lld%lld",&l,&r);
    if (l==r)
    {
        puts("1");
        return 0;
    }
    for (LL x=1LL<<60; x; x>>=1)
        if (l>=x && r>=x)
            l-=x,r-=x;
        else
            if (l<x && r>=x)
            {
                int i=0;
                for (; r-x>=1LL<<i; ++i);
                printf("%lld\n",x-l+min(x,x-l+(1LL<<i)));
                return 0;
            }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rp(i,n) for(int i=1;i<=(int)n;i++)
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a%d==0)a/=d;
    else a=a/d+1;
    if(c%b==0)c=c/b;
    else c=c/b+1;
    if(a>=c)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
   
}

Measured memory_bytes: 3612
//Compete against Yourself.
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 25;

//625

int n, m;
char a[N][N];
int dist[3000][3000];

const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dxb[4] = {-1, 1, 1, -1};
const int dyb[4] = {-1, 1, -1, 1};
const int DX[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int DY[8] = {-1, 0, 1, 1, 1, 0, -1, -1};

bool valid(int x, int y){
   return x >= 0 and y >= 0 and x < n and y < m;
}

inline int getEncode(int x, int y){
   return x * m + y;
}

void bfs(int sourcex, int sourcey){
   queue<vector<int>> q;
   q.push({sourcex, sourcey});
   int vals = getEncode(sourcex, sourcey);
   dist[getEncode(sourcex, sourcey)][getEncode(sourcex, sourcey)] = 0;

   map<int, bool> seen;
   while(!q.empty()){
      vector<int> v = q.front();
      int x = v[0], y = v[1];
      q.pop();
      int encodexy = x*m + y;
      if(seen.count(encodexy))
         continue;
      seen[encodexy] = 1;
      for (int i = 0; i < 4; ++i)
      {
         int nx = x + dx[i];
         int ny = y + dy[i];
         if(!valid(nx, ny))continue;
         if(a[nx][ny] == '#')continue;
         int encodenxy = getEncode(nx, ny);
         if(dist[vals][encodenxy] > dist[vals][encodexy]){
            dist[vals][encodenxy] = dist[vals][encodexy] + 1; 
            q.push({nx, ny});
         }
      }
   }
}

int32_t main(){_
   
   cin>>n>>m;
   
   for (int i = 0; i < n; ++i)
   {
      for (int j = 0; j < m; ++j)
      {
         cin >> a[i][j];
      }
   }

   memset(dist, 63, sizeof dist);

   for (int i = 0; i < n; ++i)
   {
      for (int j = 0; j < m; ++j)
      {
         if(a[i][j] == '#')continue;
         bfs(i, j);  
      }
   }

   int ans = -inf;
   for (int i = 0; i < n; ++i)
   {
      for (int j = 0; j < m; ++j)
      {  

         if(a[i][j] == '#')continue;
         for (int l = 0; l < n; ++l)
         {
            for (int k = 0; k < m; ++k)
            {
               if(a[l][k] == '#')continue;
               tr(i, j, l, k, a[i][j], a[l][k], dist[getEncode(i, j)][getEncode(l, k)]);
               smax(ans, dist[getEncode(i, j)][getEncode(l, k)]);
            }
         }

      }
   }

   cout<<ans;
   // cout<<ans;

   return 0;
}

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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    int lim = 3*N;
    int A[lim]; rep(i, lim) cin >> A[i];
    sort(A, A+lim);
    int cnt = 0;
    ll ans = 0;
    for(int i = lim-2; cnt < N; i -= 2){
        ans += A[i];
        cnt++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, n) ;for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) ;for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007

int main() {
  int N,sum=0,maxi=-1,have;
  cin >> N;
  
  rep(i, N){
  cin>>have;
    maxi=max(maxi,have);
    sum+=have;
  }
  if(sum>2*maxi)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;

public class Program
{
    public static void Main()
    {
        new Program().Solve();
    }


    void Solve()
    {
        int[] nm = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        int n = nm[0];
        var coins = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        var dp = new int[n + 1];

        for (int x = 1; x <= n; x++)
        {
            dp[x] = 1000000;
        }

        for (int i = 0; i < coins.Length; i++)
        {
            for (int x = coins[i]; x <= n; x++)
            {
                dp[x] = Math.Min(dp[x], dp[x - coins[i]] + 1);
            }
        }

        Console.WriteLine(dp[n]);
    }
}



Measured memory_bytes: 9780
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;

string a(string t){
  string s = t;
  REP(i,10)REP2(j,i+1,10){
   if(s[i] > s[j]) swap(s[i],s[j]);
  }
  return s;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N; cin >> N;
  string s;
  map<string,ll> mp;
  REP(i,N){
    cin >> s;
    s = a(s);
    mp[s]++;
  }
  ll ans = 0;
  for(auto itr = mp.begin(); itr != mp.end(); ++itr){
    ans += itr->second*(itr->second-1)/2;
  }
   cout << ans;

  return 0;
}

Measured memory_bytes: 11264
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	cout<<(a+b)*c/2<<endl;
}






Measured memory_bytes: 256
n, a, b = map(int, input().split())
mod = 10**9+7
def comb(n, r, mod):
    if r == 0 or r == n:
        return 1
    r = min([r, n-r])
    x, y = 1, 1
    for i in range(1, r+1):
        x *= n+1-i
        x %= mod
        y *= i
        y %= mod
    return x*pow(y, mod-2, mod)%mod

ans = (pow(2, n, mod)+3*mod-1-comb(n, a, mod)-comb(n, b, mod))%mod
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
using namespace std;
 //Compiler version g++ 6.3.0

 int main()
 {
 	int N,ans=0;
 	cin >> N;
 	int x[N];
 	for (int i = 0; i < N; i++){
 		cin >> x[i];
 	}
 	sort(x,x+N);
 	for (int i = 0; i < N-1; i++)
 	if(x[i]<x[i+1]){
 		ans++;
 	}
 	cout << ans+1 << endl;
 }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n,k,x,y;
  cin >> n >> k >> x >> y;
  ll ans=0;
  if(n<=k) {
    ans+=n*x;
  }
  else {
    ans+=k*x;
    ans+=(n-k)*y;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int, input().split()))
b=list(map(abs, a))
cnt = 0
for i in range(n):
    if a[i]<0:
        cnt+=1
if cnt%2==0:
    print(sum(b))
else:
    print(sum(b)-2*min(b))

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

using namespace std;

const int N = 1e5 + 10;
const int mod = 1e9 + 7;
#define ll long long

int n;
int a[N];
int cnt[N];
ll ans = 0;

ll power(int a, int b)
{
    ll ans = 1, base = a;
    while (b) {
        if (b & 1)
            ans = ans * base % mod;
        base = base * base % mod;
        b >>= 1;
    }
    return ans;
}

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d", &a[i]), cnt[a[i]]++;
    for (int i = 0; i < n; i++) {
        if (cnt[i] > 2)
            return puts("0"), 0;
    }
    if (n & 1 && cnt[0] != 1)
        return puts("0"), 0;
    if (!(n & 1) && cnt[0])
        return puts("0"), 0;
    printf("%lld\n", power(2, n / 2));
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <array>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <cctype>
#include <map>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <queue>


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)


using namespace std;

bool is_integer( float x ){
    return floor(x)==x;
}

bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

//yakusuu rekkyo
vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // push its partner
            if (N/i != i) res.push_back(N/i);
        }
    }

    sort(res.begin(), res.end());
    return res;
}


vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // exponential

        // divide as much as you can
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // push the result
        res.push_back({a, ex});
    }

    // last num (if the lasting n is prime number and not 1)
    if (N != 1) res.push_back({N, 1});
    return res;
}



int main() {
    int n,k; cin >> n >> k;
    int e = 0;
    long long Min = 10000000000000;
    vector<long long> vc(n);
    rep(i,n) cin >> vc[i];
    sort(vc.begin(),vc.end());
    e = vc.size();
    int i = 0;
    while(i + k -1< vc.size()){
        Min = min(Min,vc[i+k-1] - vc[i]);
        i ++;
    }
    cout << Min;

    return 0;
}











Measured memory_bytes: 3992
import java.util.Scanner;


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

		String S = sc.next();
		char a[] = new char[4];

		for(int i=0;i<S.length();i++) {
			a[i] = S.charAt(i);
		}
		for(int k=0;k<3;k++) {
			if(a[k+1]==a[k]) {System.out.println("Bad");
			return;}
		}
		System.out.println("Good");
	}
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<double> vf;
typedef vector<vf> vvf;

double pow(double a, ll i) {
  double ret = 1;
  for (ll j = 0; j < i; j++) ret *= a;
  return ret;
}

double dist(pii a, pii b) {
  double x = pow(a.first - b.first, 2) + pow(a.second - b.second, 2);
  return sqrt(x);
}

int main() {
  pii s, t; cin >> s.first >> s.second >> t.first >> t.second;
  ll N; cin >> N;
  vvi A(N, vi(3));
  for (ll i = 0; i < N; i++) {
    for (ll j = 0; j < 3; j++) {
      cin >> A[i][j];
    }
  }

  vvf D(N + 2, vf(N + 2));
  for (ll i = 0; i < N; i++) {
    for(ll j = 0; j < N; j++) {
      D[i][j] = max<double>(0, dist({A[i][0], A[i][1]}, {A[j][0], A[j][1]}) - (A[i][2] + A[j][2]));
    }
  }

  for (ll i = 0; i < N; i++) {
    D[i][N] = D[N][i] = max<double>(0, dist(s, {A[i][0], A[i][1]}) - A[i][2]);
    D[i][N + 1] = D[N + 1][i] = max<double>(0, dist(t, {A[i][0], A[i][1]}) - A[i][2]);
  }
  D[N][N + 1] = D[N + 1][N] = max<double>(0, dist(s, t));

  vf E(N + 2, (1ll << 60));
  priority_queue<pii, vpii, greater<pii>> pq;
  E[N] = 0;
  pq.push({0, N});
  while (pq.size()) {
    ll fr; tie(ignore, fr) = pq.top();
    pq.pop();
    for (ll to = 0; to < N + 2; to++) {
      if (E[to] > E[fr] + D[fr][to]) {
        E[to] = E[fr] + D[fr][to];
        pq.push({E[to], to});
      }
    }
  }

  cout << fixed << setprecision(10);

  cout << E[N + 1] << endl;
}

Measured memory_bytes: 14064
#include <bits/stdc++.h>
using namespace std;
#define INF 2000000000
typedef long long int ll;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1<<(i))))
#define setbit1(n,i) ((n)|(1<<(i)))
#define togglebit(n,i) ((n)^(1<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define fi first
#define se second
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d%d",&a,&b)
#define PI (acos(-1))
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod (1000000007)
#define asz 500005
#define pb push_back
#define ppf pop_front
#define ppb pop_back
#define pf push_front

int main() {
    fastread;
    ll n,i,j,k,l;
    cin>>n;
    set<string>s;
    for(i=1;i<=n;i++){
        string s1;
        cin>>s1;
        s.insert(s1);
    }
    cout<<s.size();
}

Measured memory_bytes: 19216
n=int(input())
a=list(map(int,input().split()))
c4=0
c2=0
for i in range(n):
  if a[i]%4==0:
    c4+=1
  elif a[i]%2==0:
    c2+=1
    
if c2==0:
  print("Yes" if 2*c4+1>=n else "No")
else:
  x=c4*2+c2
  if x>=n:
    print("Yes")
  else:
    print("No")

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

string S, T;

int main(){
  cin >> S >> T;
  vector<char> r(26, '?');
  vector<char> q(26, '?');
  int n = S.size();
  
  bool clr = true;
  for(int i = 0; i < n; i++){
    int s = S[i] - 'a';
    if(r[s] == '?') r[s] = T[i];
    else {
      if(r[s] != T[i]) {clr = false; break;}
    }
    
    int t = T[i] - 'a';
    if(q[t] == '?') q[t] = S[i];
    else {
      if(q[t] != S[i]) {clr = false; break;}
    }
  }
  
  if(clr) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 776
// Sakhiya07 - Yagnik Sakhiya
 
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
 
#define mp make_pair
#define bp __builtin_popcountll
#define MOD  1000000007
const int N = 62;
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));
ll cnt = 0;

void solve()
{
    ll n,k;
    cin >> n >> k;
    ll ans = n%k;
    ans = min(ans,k-ans);
    cout<<ans;
}

int main()
{
     FAST;
     ll t = 1;
    // cin >> t;
     while(t--)
     {
         
          solve();
     }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1, (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    ios();
    int n, k;
    cin >> n >> k;

    vector<pair<ll,ll>> v(n);
    for(auto& i : v){
        ll a, b;
        cin >> a >> b;
        i.first = a - 1;
        i.second = b;
    }

    sort(all(v), [](auto a, auto b){return a.second > b.second;});

    vector<bool> appear(n, false);
    ll sum = 0;
    ll type = 0;
    vector<ll> rmv, add;

    REP(i, k){
        sum += v[i].second;
        if(!appear[v[i].first]){
            appear[v[i].first] = true;
            type++;
        }else{
            rmv.push_back(v[i].second);
        }
    }

    for(int i=k; i<n; i++){
        if(!appear[v[i].first]){
            appear[v[i].first] = true;
            add.push_back(v[i].second);
        }
    }

    sum += type*type;

    sort(all(rmv));
    sort(add.rbegin(), add.rend());

    for(int i=1; i<rmv.size(); i++){
        rmv[i] += rmv[i-1];
    }
    for(int i=1; i<add.size(); i++){
        add[i] += add[i-1];
    }

    ll ans = sum;

    for(int i=0; i<min(rmv.size(), add.size()); i++){
        ll d = (type+i+1)*(type+i+1) - (type*type);
        ans = max(ans, sum - rmv[i] + add[i] + d);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2624
n = int(input())
t = list(map(int,input().split()))
m = int(input())
arr = []
ans = []
for i in range(m):
    p,x = map(int,input().split())
    arr.append([p,x])
for i in arr:
    ans.append(sum(t) - t[i[0] - 1] + i[1])
for i in ans:
    print(i)

Measured memory_bytes: 3064
import math

A, B = map(int, input().split(' '))


def calc():
    global A, B

    for x in range(1, 1001):
        a = math.floor(x * 0.08)
        b = math.floor(x * 0.1)

        if a == A and b == B:
            return x

    return -1


res = calc()
print(res)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define bitCount(num)  __builtin_popcount(num)
#define pb push_back
#define ll long long
#define bye return 0;
#define f(i,a,b) for( long long i=a;i<b;i++)
#define testCases long long t;cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define newLine <<"\n"
#define all(x) (x).begin(), (x).end()
#define vll vector<long long>

int main()
{
    fast
    int n,k;
    cin>>n>>k;
    vector<int> arr(n,0);
    f(i,0,n)cin>>arr[i];

    vector<int> dp(n,INT_MAX);

    dp[0]=0;

    for(int i=0;i<n-1;i++)
    {
    	for(int j=i+1;j<i+1+k && j<n ;j++ )
    		{
    			dp[j]=min(dp[j],abs(arr[i]-arr[j])+dp[i]);
    			// cout<<dp[j]<<" ";
    		}
    	// 	cout<<endl;
    	// cout<<dp[i]<<endl;

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

Measured memory_bytes: 3960
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

using namespace std;

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

  return 0;
}


Measured memory_bytes: 1792
#include <sstream>
#include <fstream>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <string>
#include <queue>
#include <bitset>
using namespace std;

#define int long long
#define FOR(i, a, b) for (int i = (a), _##i = (b); i <= _##i; ++i)
#define FORD(i, a, b) for (int i = (a), _##i = (b); i >= _##i; --i)
#define REP(i, a) for (int i = 0, _##i = (a); i < _##i; ++i)
#define REPD(i,n) for(int i = (n)-1; i >= 0; --i)

#define DEBUG(X) { cerr << #X << " = " << (X) << endl; }
#define PR(A, n) { cerr << #A << " = "; FOR(_, 1, n) cerr << A[_] << ' '; cerr << endl; }
#define PR0(A, n) { cerr << #A << " = "; REP(_, n) cerr << A[_] << ' '; cerr << endl; }

#define sqr(x) ((x) * (x))
#define ll long long
#define double long double
typedef pair<int, int> II;
#define PI (2 * acos((double)0))
#define __builtin_popcount __builtin_popcountll
#define SZ(x) ((int)(x).size())
#define ALL(a) (a).begin(), (a).end()
#define MS(a,x) memset(a, x, sizeof(a))
#define next ackjalscjaowjico
#define prev ajcsoua0wucckjsl
#define y1 alkscj9u20cjeijc
#define left lajcljascjljl
#define right aucouasocjolkjl
#define y0 u9cqu3jioajc

#define TWO(X) (1LL<<(X))
#define CONTAIN(S,X) ((S) & TWO(X))

double safe_sqrt(double x) { return sqrt(max((double)0.0, x)); }
int GI(int& x) { return scanf("%lld", &x); }

int n, a[300111];

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout << (fixed) << setprecision(9) << boolalpha;
    while (cin >> n) {
        n *= 3;
        FOR(i,1,n) cin >> a[i];
        sort(a+1, a+n+1);
        int res = 0;
        int i = n-1;
        REP(turn,n/3) {
            res += a[i];
            i -= 2;
        }
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define acc(v) accumulate(v.begin(), v.end(), 0)

using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;

int main()
{
	string s;
	cin >> s;
	deque<char> dq(s.size());
	rep(i,s.size()){
		dq[i] = s[i];
	}
	int n;
	cin >> n;
	//count%2==0なら正順
	int count = 0;
	rep(i,n){
		int q;
		cin >> q;
		if(q==1){
			count++;
			continue;
		}
		int f;
		cin >> f;
		char c;
		cin >> c;
		int nf = f == 1 ? 1 : -1;
		nf *= count % 2 ? -1 : 1;
		if(nf==1){
			dq.push_front(c);
		}
		else
		{
			dq.push_back(c);
		}
	}
	if(count%2)
		reverse(all(dq));
	rep(i,dq.size()){
		cout << dq[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
#define rep(i,a,b) for(ll i=a;i<=(b);++i)
#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define pi pair<int, int>
#define mk make_pair
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const int N=2e2+10;
ll dp[N][N][N],a[5];
ll run()
{
//    for(int i=1;i<=3;++i){
//        for(int j=1;j<=3;++j){
//            for(int k=1;k<=3;++k){
//                if(i==j||i==k||j==k) continue;
//                if(dp[a[i]][a[j]][a[k]]) return dp[a[i]][a[j]][a[k]];
//            }
//        }
//    }
    ll gc=gcd(a[1],a[2]);
    gc=gcd(gc,a[3]);
    dp[a[1]][a[2]][a[3]]=gc;
    return gc;
}
int main()
{
    ll k;
    cin>>k;
    ll ans=0;
    for(ll i=1;i<=k;++i){
        for(ll j=1;j<=k;++j){
            rep(l,1,k){
                a[1]=i;
                a[2]=j;
                a[3]=l;
                ans+=run();
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 70032
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] strings = br.readLine().split(" ");
        int[] xs = new int[strings.length];
        for (int i = 0; i < xs.length; i++) {
            xs[i] = Integer.parseInt(strings[i]);
        }
        System.out.println(problem170a(xs));
    }

    private static int problem170a(int[] xs) {
        for (int i = 0; i < xs.length; i++) {
            if (xs[i] == 0) return (i + 1);
        }
        return 0;
    }
}

Measured memory_bytes: 25244
N = int(input())
data = [0 for i in range(N+1)]
A = [[[int(j) for j in input().split()] for i in range(int(input()))] for k in range(N)]
#print(A)
count = 0



while data[-1] != 1:
    g = 0
    #print(data)
    for i,j in enumerate(data):
        #print(i)
        if j == 1:
            for k in A[i]:
                if k[1] != data[k[0]-1]:
                    g = 1
                    #print(k[1],data[k[0]-1])
    if g == 0:
        count = max(sum(data),count)
    data[0]+=1
    for i,j in enumerate(data):
        if j == 2:
            data[i],data[i+1]=0,data[i+1]+1
            
print(count)

Measured memory_bytes: 43868
#include<stdio.h>

int main(void)
{
   int i,n;
   char s[4];

   n=0;

   scanf("%s",s);
   for(i=0;i<4;i++){
     if(s[i]=='+')
       n++;
     else if(s[i]=='-')
       n--;
   }
   printf("%d\n",n);
   return 0;

}


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

using namespace std;

string s, t;
int dp[3010][3010];

int main() {
    cin >> s >> t;

    int n = s.length(), m = t.length();

    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= m; j++) {
            if (i == 0 || j == 0) dp[i][j] = 0;
            else if (s[i - 1] == t[j - 1]) {
                dp[i][j] = dp[i - 1][j - 1] + 1;
            }
            else {
                dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]);
            }
        }
    }

    string ans;
    int i = n, j = m;
    while (i > 0 && j > 0) {
        if (s[i - 1] == t[j - 1]) {
            ans.push_back(s[i - 1]);
            i--, j--;
        }
        else if (dp[i - 1][j] > dp[i][j - 1]) i--;
        else j--;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << '\n';
}

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


int main(){
  int N;
  cin >> N;
  
  vector<int64_t> vec(N+1);
  vec.at(0)=2;
  vec.at(1)=1;
  
  for(int i=2;i<=N;i++){
    vec.at(i)=vec.at(i-1)+vec.at(i-2);
  }
  cout << vec.at(N) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	int n,m;
	
	while(cin >> n >> m , n){
		vector<int> data(n);
		int ret = 0;
		rep(i,n)cin >> data[i];
		sort(data.begin(),data.end(),greater<int>());
		
		rep(i,n){
			if((i+1)%m==0)continue;
			ret += data[i];
		}
		cout << ret << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
const int mod = 1e9 + 7;
ll fp(ll base, ll exp)
{
    if (exp == 0)
        return 1;
    ll ans = fp(base, exp / 2);
    if (exp % 2 == 0)
        return (ans * ans) % mod;
    else
        return (((ans * ans)% mod) * base)% mod;
}
long long ncr(int n, int r)
{
    long long ans = 1, k = 1;
    for (int i = n; i > n - r; i--)
    {
        ans = (ans * i)%mod;
        ans = (ans * fp(k, mod - 2))%mod;
        k++;
    }
    return ans;
}
int main()
{
    Hello
    int n, a, b;
    cin >> n >> a >> b;
    ll ans = (fp(2, n) - 1)%mod;
    ans = (ans - ncr(n, a) + mod)%mod;
    ans = (ans - ncr(n, b) + mod)%mod;
    cout << ans;
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#define PAI 3.141592

int main(void)
{ 
 int a,b;

 scanf("%d%d",&a,&b);
 if(a < b){ 
    printf("a < b\n");
  } else if(a > b){
    printf("a > b\n");
 } else {
   printf("a == b\n");
 }
  return 0; 
  
}

Measured memory_bytes: 580
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    for(int i=0; i<n; ++i)
        cin >> p[i];

    int sum = accumulate(p.begin(), p.end(), 0);
    sum -= *max_element(p.begin(), p.end()) / 2;
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG //test only

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int k;
  cin >> k;
  int x,y;
  cin >> x >> y;
  if((abs(x)+abs(y))%2 == 1 && k%2 == 0)
  {
    cout << -1 << endl;
  }
  else
  {
    vector<pair<int,int>> ans(0);
    ans.emplace_back(make_pair(x,y));
    while(abs(x)+abs(y) > k*2)
    {
      if(x > k) x = x-k;
      else if(x < -k) x = x+k;
      else if(y > k) y = y-k;
      else if(y < -k) y = y+k;
      ans.emplace_back(make_pair(x,y));
    }
    int dis = abs(x)+abs(y);
    if(dis%2 == 1 && dis != k)
    {
      if(abs(x) >= abs(y))
      {
        if(x >= 0) x -= k;
        else x += k;
      }
      else
      {
        if(y >= 0) y -= k;
        else y += k;
      }
      ans.emplace_back(make_pair(x,y));
    }
    dis = abs(x)+abs(y);
    if(dis != k)
    {
      int dec = dis/2;
      int inc = k-dec;
      if(abs(x) >= abs(y))
      {
        if(x >= 0) x -= dec;
        else x += dec;
        if(y >= 0) y += inc;
        else y -= inc;
      }
      else
      {
        if(y >= 0) y -= dec;
        else y += dec;
        if(x >= 0) x += inc;
        else x -= inc;
      }
      ans.emplace_back(make_pair(x,y));
    }
    int n = ans.size();
    cout << n << endl;
    for(int i=n-1;i>=0;i--)
    {
      cout << ans[i].first << ' ' << ans[i].second << endl;
    }
  }
}


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

// int/long:            -2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:      -9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define MOD 1000000007

#define Rep0(i, n)      for (auto i=0; i<n; i++)
#define Rep1(i, n)      for (auto i=1; i<=n; i++)
#define Sort(P) sort(P.begin(), P.end())
#define Rev(P)  reverse(P.begin(), P.end())

int     main() {
        ll a, b, c, d;
        cin >>a >>b >>c >>d;
        ll ANS=a*c;
        ANS=max(ANS, a*d);
        ANS=max(ANS, b*c);
        ANS=max(ANS, b*d);
        cout <<ANS <<endl;
        return 0;
}

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

int main() {
    int n,x;
    cin >> n >> x;
    vector<int> l(n);
    for(int i = 0; i < n; i++) cin >> l[i];
    int ans = 0, last = 0;
    for(int i = 0; i < n; i++){
        if(last <= x) ans++;
        last += l[i];
    }
    if(last <= x) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<set>
#include<map>
#include<queue>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);++i)
#define rrep(i,n) for(int (i)=(n)-1;(i)>=0;--i)
#define rep1(i,n) for(int (i)=1;(i)<=(n);++i)
#define rrep1(i,n) for(int (i)=(n);(i)>=1;--i)
#define pb push_back
#define fr first
#define sc second
typedef long long ll;
typedef pair<int,int> P;
typedef pair<long long,long long> LP;
typedef double db;
using namespace std;

ll W,H;
LP p[200000];
ll ans = 0;
ll cnt[2] = {0,0};
ll C = 0;
priority_queue<LP,vector<LP>,greater<LP> > q;

int main()
{
  cin>>W>>H;
  ll E[2];
  E[0] = W;
  E[1] = H;
  rep(i,W){
    cin>>p[i].fr;
    p[i].sc = 0;
    q.push(p[i]);
  }
  rep(i,H){
    cin>>p[W+i].fr;
    p[W+i].sc = 1;
    q.push(p[W+i]);
  }
  while(C<(W+1)*(H+1)-1){
    LP e = q.top();
    q.pop();
    ll s = E[!e.sc] + 1LL - cnt[!e.sc];
    ans += s*e.fr;
    C += s;
    cnt[e.sc]++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 8560
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll L;
//ワーシャルフロイド
//頂点数（と隣接行列）を引いて全点間最短距離を返す
//O(V^3)
ll cost[310][310];
ll dddd[310][310];
ll cccc[310][310];
void waasharuhuroido(ll n){
	rep(i,0,n)rep(j,0,n)if(i!=j){
		if(cost[i][j]&&cost[i][j]<=L){
			dddd[i][j]=cost[i][j];
		}else{
			dddd[i][j]=cccc[i][j]=INF;
		}
	}
	rep(_,0,3)rep(k,0,n)rep(i,0,n)rep(j,0,n){
		ll tempc=cccc[i][k]+cccc[k][j];
		ll tempd=dddd[i][k]+dddd[k][j];
		if(!(tempc==0&&tempd<=L)){
			tempc++;
			tempd=dddd[k][j];
		}
		
		if(cccc[i][j]>tempc||(cccc[i][j]==tempc&&dddd[i][j]>tempd)){
			cccc[i][j]=tempc;
			dddd[i][j]=tempd;
		}
//		rep(i,0,n){rep(j,0,n)printf("(%2d,%2d) ",cccc[i][j]==INF?99:cccc[i][j],dddd[i][j]==INF?99:dddd[i][j]);puts("");}puts("");
	}
}

int main(){
	ll n,m;
	scanf("%lld%lld%lld",&n,&m,&L);
	rep(i,0,m){
		ll x,y,z;
		scanf("%lld%lld%lld",&x,&y,&z);
		x--,y--;
		cost[x][y]=cost[y][x]=z;
	}
	waasharuhuroido(n);
	ll q;
	scanf("%lld",&q);
	while(q--){
		ll x,y;
		scanf("%lld%lld",&x,&y);
		x--,y--;
		ll ans=cccc[x][y];
		printf("%lld\n",ans==INF?-1:ans);
	}
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                    \
  ifstream in("abc147/abc147_b.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  string s;
  cin >> s;

  int cnt = 0;
  rep(i, s.size() / 2) {
    if (s[i] != s[s.size() - i - 1]) cnt++;
  }

  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
double D[80]; int d;

double pop_n(){
  return (D[--d]);}
void push_n(double a) {
  D[d]=a; d++;
}

int main() {
  char inbuf[99];
  while (gets(inbuf)) {
    char *tp = strtok(inbuf, " \n");
    while (tp != NULL) {
      double a,b;
      if ((tp[0] == '+') && (tp[1]==0)) {
        D[d-2]+=D[--d];
      }
      else if (tp[0] == '*') {
        D[d-2]*=D[--d];
      }
      else if ((tp[0] == '-') && (tp[1]==0)) {
        D[d-2]-=D[--d];
      }
      else if (tp[0] == '/') {
        D[d-2]/=D[--d];
      }
      else {
        D[d++]=atof(tp);
      }
      tp = strtok(NULL, " \n");
    }
    printf("%.6lf\n",pop_n());
  }
  return 0;
}

Measured memory_bytes: 580
#line 1 "main.cpp"

#include <iostream>
#include <algorithm>
#include <utility>
#include <numeric>
#include <vector>
#include <array>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) { lhs = rhs; return true; }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) { lhs = rhs; return true; }
  return false;
}

struct range {
  using itr = int64_t;
  struct iterator {
    itr i;
    constexpr iterator(itr i_) noexcept : i(i_) { }
    constexpr void operator ++ () noexcept { ++i; }
    constexpr itr operator * () const noexcept { return i; }
    constexpr bool operator != (iterator x) const noexcept { return i != x.i; }
  };
  const iterator l, r;
  constexpr range(itr l_, itr r_) noexcept : l(l_), r(std::max(l_, r_)) { }
  constexpr iterator begin() const noexcept { return l; }
  constexpr iterator end() const noexcept { return r; }
};

struct revrange {
  using itr = int64_t;
  struct iterator {
    itr i;
    constexpr iterator(itr i_) noexcept : i(i_) { }
    constexpr void operator ++ () noexcept { --i; }
    constexpr itr operator * () const noexcept { return i; }
    constexpr bool operator != (iterator x) const noexcept { return i != x.i; }
  };
  const iterator l, r;
  constexpr revrange(itr l_, itr r_) noexcept : l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr iterator begin() const noexcept { return r; }
  constexpr iterator end() const noexcept { return l; }
};

using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;

constexpr i32 inf32 = (i32(1) << 30) - 1;
constexpr i64 inf64 = (i64(1) << 62) - 1;

int main() {
  size_t N;
  std::cin >> N;
  std::string S;
  std::cin >> S;
  std::vector<i32> A(N);
  for (auto i: range(0, N)) {
    A[i] = S[i] - '0';
  }
  std::reverse(A.begin(), A.end());
  i32 popcount = std::count(A.begin(), A.end(), 1);
  std::array<i32, 2> mod = { popcount + 1, popcount - 1 }; 
  std::array<std::vector<i32>, 2> rem{};
  rem.fill(std::vector<i32>(N));
  std::array<i32, 2> initial{};
  {
    for (auto k: range(0, 2)) {
      if (mod[k] <= 0) continue;
      i32 cur = 1;
      for (auto i: range(0, N)) {
        rem[k][i] = cur;
        cur *= 2;
        cur %= mod[k];
        initial[k] += A[i] * rem[k][i];
        initial[k] %= mod[k];
      }
    }
  }
  for (auto i: revrange(0, N)) {
    if (mod[A[i]] == 0) {
      std::cout << "0\n";
      continue;
    }
    i32 ans = 1;
    i32 cur = initial[A[i]];
    cur -= rem[A[i]][i] * A[i];
    cur += rem[A[i]][i] * (1 - A[i]);
    cur %= mod[A[i]];
    if (cur < 0) {
      cur += mod[A[i]];
    }
    while (cur > 0) {
      cur = cur % __builtin_popcount(cur);
      ++ans;
    }
    std::cout << ans << '\n';
  }
}

/**
 * @title Template
 */


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

signed main() {
    string S;
    cin >> S;

    stack<char> st;
    int cnt = 0;
    for (char c : S) {
        if (st.empty()) {
            st.push(c);
        }
        else if (st.top() != c) {
            st.pop();
            cnt++;
        }
        else {
            st.push(c);
        }
    }
    cout << cnt * 2 << endl;

    return 0;
}


Measured memory_bytes: 512
N, M = gets.chomp.split(" ").map{|str| str.to_i}
num = Array.new(N, 1)
possible = Array.new(N, false)
possible[0] = true
for i in 1..M
	x, y = gets.chomp.split(" ").map{|str| str.to_i}
	num[x-1] -= 1
	num[y-1] += 1
	possible[y-1] = true if possible[x-1]
	possible[x-1] = false if num[x-1] == 0
end
puts possible.count(true)

Measured memory_bytes: 3324
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

s = read().decode("utf-8").rstrip()
l = 0
r = len(s) - 1

cnt = 0
while len(s) != 0:
    if s[0] == s[-1]:
        s = s[1:-1]
    elif s[0] == 'x':
        s += 'x'
        cnt += 1
    elif s[-1] == 'x':
        s = 'x' + s
        cnt += 1
    else:
        print(-1)
        sys.exit()

print(cnt)


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

int main() {
  int h, w;
  string s;
  cin >> h >> w;
  vector<vector<char>> v(h, vector<char>(w));
  vector<vector<int>> vv(h+2, vector<int>(w+2));
  for(int i=0; i<h; i++) {
    cin >> s;
    for(int j=0; j<w; j++) {
      v[i][j] = s[j];
      if(s[j]=='#') {
        vv[i][j] += 1;
        vv[i][j+1] += 1;
        vv[i][j+2] += 1;
        vv[i+1][j] += 1;
        vv[i+1][j+2] += 1;
        vv[i+2][j] += 1;
        vv[i+2][j+1] += 1;
        vv[i+2][j+2] += 1;
      }
    }
  }
  
  for(int i=1; i<h+1; i++) {
    for(int j=1; j<w+1; j++) {
      if(v[i-1][j-1]=='#') cout << v[i-1][j-1];
      else cout << vv[i][j];
      if(j==w) cout << endl;
    }
  }
  return 0;
}

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

#define N 100
#define INT(X) \
  ( *( (const int *)(X) ) )

static int
compare (
  const void  * a,
  const void  * b
  )
{
  return ( INT( b ) - INT( a ) );
}

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  int a, b, c;
  int d[ N ];
  int n;
  int i;

  scanf ( "%d%d%d%d", &n, &a, &b, &c );
  for ( i = 0; i < n; ++i )
  {
    scanf ( "%d", d + i );
  }

  qsort ( d, n, sizeof ( int ), compare );
  for ( i = 0; i < n; ++i )
  {
    if ( ( c + d[ i ] ) * a <= c * ( a + b ) )  break ;

    a += b;
    c += d[ i ];
  }

  printf ( "%d\n", c / a );

  return ( 0 );
}

Measured memory_bytes: 0
import math
a, b, x = map(int, input().split())
if x < a * a * b / 2:
    c = 2 * x / (a * b)
    print(90 - math.degrees(math.atan(c / b)))
else:
    c = 2 * b - 2 * x / (a * a)
    print(math.degrees(math.atan(c / a)))

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

using namespace std;

#define rep(i, n) for(int i = 0; i < static_cast<int>(n); ++i)
#define per(i, n) for(int i = static_cast<int>(n)-1; i >= 0; --i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);
#define ppp(a) (cout << (a) << endl); 
#define cop(a) for(auto x:(a)){cout << x << endl;}

using ll = long long;

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

constexpr char sp = ' ';
constexpr ll MOD = 1e9+7;
constexpr ll Mod = 998244353;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr double phi = (1+sqrt(5))/2;
constexpr double pi = 3.14159265358979323846264338327950288;
inline ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
inline ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
inline ll inverse(ll n, ll m=MOD){ll a=n,b=m,x=1,y=0;while(b){ll t=a/b;a-=t*b;swap(a,b);x-=t*y;swap(x,y);}return (a%m+m)%m;}
inline void Yes(){puts("Yes");}
inline void No(){puts("No");}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){puts("YES");}
inline void NO(){puts("NO");}
inline void JUDGE(bool b){b?YES():NO();}
inline ll powmod(ll b, ll e, ll m=MOD){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
inline double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}
inline double d2r(double d){return d*pi/180;}
inline double r2d(double r){return r*180/pi;}

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; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    s<<'[';for(size_t i=0;i<v.size();++i){s << v[i];if(i < v.size()-1) s << ", ";}s<<']';return s;
}
struct __{ __(){  cout<<fixed<<setprecision(15); } };



int dp[10101];

int main(){
    cin.tie(0); ios::sync_with_stdio(0);
    int h, n;
    cin >> h >> n;
    vector<int> a(n), b(n);

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

    fill_n(dp, 10101, INF);
    dp[0] = 0;

    for(int i = 0; i < n; ++i){
        for(int j = 0; j <= h; ++j){
            int x = 0;
            if(j-a[i] >= 0) x = dp[j-a[i]];
            dp[j] = min(dp[j], x+b[i]);
        }
    }
    cout << dp[h] << '\n';
    return 0;
}


Measured memory_bytes: 256
//
//  lunlun.cpp
//  learningCplusplus
//
//  Created by Tran Duc Chinh on 2020/04/04.
//  Copyright © 2020 Tran Duc Chinh. All rights reserved.
//

#include <iostream>

int main(int argc, const char* argv[]) {
  int k;
  std::cin >> k;
  long long a[100000];
  int i=0;
  for (i=0; i<9; i++) {
    a[i] = i+1;
  }
  int index = 0;
  while(i<k) {
    // if (a[index]%10 == 9) {
    //   a[i] = a[index]*10 + (a[index]%10 - 1);
    //   a[i+1] = a[index]*10 + (a[index]%10);
    //   i=i+2;
    // }
    // else if (a[index]%10 == 0) {
    //   a[i] = a[index]*10 + (a[index]%10);
    //   a[i+1] = a[index]*10 + (a[index]%10 + 1);
    //   i=i+2;
    // }
    // else {
    //   a[i] = a[index]*10 + (a[index]%10 - 1);
    //   a[i+1] = a[index]*10 + (a[index]%10);
    //   a[i+2] = a[index]*10 + (a[index]%10 + 1);
    //   i=i+3;
    // }
    if (a[index]%10 != 0) {
      a[i] = a[index]*10 + (a[index]%10 - 1);
      i++;
    }
    a[i] = a[index]*10 + (a[index]%10);
    i++;
    if (a[index]%10 != 9) {
      a[i] = a[index]*10 + (a[index]%10 + 1);
      i++;
    }
    index++;
  }

  // for (int i=0; i<k; i++) {
  //   std::cout << a[i] << " ";
  // }
  // std::cout << std::endl;
  // std::cout << "index " << index << std::endl;
  std::cout << a[k-1] << std::endl;
}

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

typedef long long ll;
#define pa pair<int, int> 
#define pal pair<long long, long long>
#define pad pair<double, double>
#define pb push_back
#define mp make_pair
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}

typedef vector<bool> bvec;
typedef vector<int> ivec;
typedef vector<long long> lvec;
typedef vector<double> dvec;
typedef vector<pa> pvec;

typedef vector< vector<bool> > bmat;
typedef vector< vector<int> > imat;
typedef vector<string> svec;
typedef vector< vector<string> > smat;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    lvec a(n+1), b(n);
    ll sum=0;
    for (int i=0; i<n+1; i++) cin >> a[i];
    for (int i=0; i<n; i++) cin >> b[i];
    b.push_back(0);
    sum += fmin(a[0], b[0]);
    b[0] = fmax(b[0] - a[0], 0);
    int i;

    for (i=1; i<n+1; i++) {
        sum += fmin(a[i], b[i-1]);
        ll aa = fmax(a[i]-b[i-1], 0);
        sum += fmin(aa, b[i]);
        b[i] = fmax(b[i]-aa, 0);
    }
    cout << sum << endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;cin>>a>>b>>c;
  	multiset<int> m;m.insert({a,b,c});
  	if(m.count(5)==2&&m.count(7)==1) cout<<"YES";
  	else cout<<"NO";
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, intmax_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, intmax_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}} End

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

    size_t H, W; cin >> H >> W;

    auto c = make_v(0, 10, 10);
    for (size_t i = 0; i < 10; ++i) {
        for (size_t j = 0; j < 10; ++j) {
            cin >> c[i][j];
        }
    }

    for (size_t via = 0; via < 10; ++via) {
        for (size_t s = 0; s < 10; ++s) {
            for (size_t g = 0; g < 10; ++g) {
                chmin(c[s][g], c[s][via] + c[via][g]);
            }
        }
    }

    size_t res = 0;
    for (size_t i = 0; i < H; ++i) {
        for (size_t j = 0; j < W; ++j) {
            int a; cin >> a;
            if (a != -1) {
                res += c[a][1];
            }
        }
    }

    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=110,p=1e9+7;
void update(int &x,int v){x+=v;if (x>=p) x-=p;}
int n,m,a[N],dp[N][N][N];
//dp[i][j][k]表示填了i个,上一次所填的值左右分别还能选j,k个的方案数 
int main()
{
	scanf("%d",&n);
	for (int i=1;i<n+n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+n);
	dp[1][0][0]=1;
	for (int i=1;i<n;i++)
	for (int j=0;j<n+n;j++)
	for (int k=0;k<n+n;k++){
		int v=dp[i][j][k];
		if (!v) continue;
		int x=j,y=k;
		if (a[n-i]!=a[n-i+1]) x++;
		if (a[n+i]!=a[n+i-1]) y++;
		for (int l=1;l<=x;l++) update(dp[i+1][l-1][y+1],v);
		update(dp[i+1][x][y],v);
		for (int l=1;l<=y;l++) update(dp[i+1][x+1][l-1],v);
	}
	int ans=0;
	for (int i=0;i<n+n;i++)
	for (int j=0;j<n+n;j++)
		update(ans,dp[n][i][j]);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3200
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
	int N;
	cin >> N;
    vector<int> h(N);

    for (int i = 0; i < N; i++)
    {
        cin >> h[i];
    }
    int res = 0;
    while(true){
        if(*max_element(h.begin(), h.end())==0)break;
      	int it = 0;
        while(it<N){
            if(h[it]==0)it++;
            else{
                res++;
                while(it<N&&h[it]>0){
                    h[it]--;
                    it++;
                }
            }
        }
    }
    
    cout << res << endl;
    
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
long long ans , n ;
int main() {
	cin >> n ;
	ans = 1;
	for (int i = 1 ; i <= n ; i ++){
		long long x;
		cin >> x ;
		ans =ans/__gcd(ans,x)*x;
	}
	cout << ans <<endl;
	return 0;
}

Measured memory_bytes: 3592