akhauriyash/Code-Regression huggingface dataset:
#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 M 1000000007
#define ll long long
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define REPI(i,a,b) for(ll i=b-1;i>=a;i--)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define G(a,b) get<a>(b)
#define VI vector<int>
#define VLL vector<long long>
 
#define o_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define o_setll tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
 
ll modI(ll a, ll m);
ll gcd(ll a, ll b);
ll powM(ll x, unsigned ll y, unsigned ll m);
void pairsort(int a[], int b[], int n);
void pairsortll(ll a[],ll b[],ll n);
ll logint(ll x,ll y);
 
 
ll gcd(ll x,ll y)
{
    if(x==0) return y;
    return gcd(y%x,x);
}
 
ll powM(ll x,ll y,ll m)
{
    if(y==0) return 1;
    ll p=powM(x,y/2,m)%m;
    p=(p*p)%m;
    return (y%2==0)?p:(x*p)%m;
}
 
ll modI(ll a, ll m)
{
    ll m0=m,y=0,x=1;
    if(m==1) return 0;
    while(a>1)
    {
        ll q=a/m;
        ll t=m;
        m=a%m;
        a=t;
        t=y;
        y=x-q*y;
        x=t;
    }
    if(x<0) x+=m0;
    return x;
}
 
void pairsort(int a[],int b[],int n)
{
    pair<int,int> v[n];
    REP(i,0,n)
    {
        v[i].F=a[i];
        v[i].S=b[i];
    }
    sort(v,v+n);
    REP(i,0,n)
    {
        a[i]=v[i].F;
        b[i]=v[i].S;
    }
}
 
void pairsortll(ll a[],ll b[],ll n)
{
    pair<ll,ll> v[n];
    REP(i,0,n)
    {
        v[i].F=a[i];
        v[i].S=b[i];
    }
    sort(v,v+n);
    REP(i,0,n)
    {
        a[i]=v[i].F;
        b[i]=v[i].S;
    }
}
 
ll logint(ll x,ll y)
{
    ll ans=0;
    ll a=1;
    for(ll i=0;i<=x;i++)
    {
        if(x<a)
        {
            return ans;
        }
        ans++;
        a*=y;
    }
    return -1;
}
 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 
    /*
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    */
 
    ll q=1;
    //cin>>q;
    while(q--)
    {
        ll n,w;
        cin>>n>>w;
        ll dp[w+1];
        REP(i,0,w+1) dp[i]=-1;
        dp[0]=0;
        REP(i,0,n)
        {
            ll t1,t2;
            cin>>t1>>t2;
            REPI(j,0,w+1)
            {
                if(dp[j]!=-1)
                {
                    if(j+t1<=w)
                    {
                        dp[j+t1]=max(dp[j+t1],dp[j]+t2);
                    }
                }
            }
        }
        ll ans=0;
        REP(i,0,w+1) ans=max(ans,dp[i]);
        cout<<ans;
    }
 
    return 0;
}

Measured memory_bytes: 1024
a, b, k = map(int, input().split())

for i, j in enumerate(range(k)):
    if i % 2 == 0:
        if a % 2 == 1:
            a = a - 1
        b = b + a // 2
        a = a // 2
    elif i % 2 == 1:
        if b % 2 == 1:
            b = b - 1
        a = a + b // 2
        b = b // 2

print(a, b)


Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define debug(x) cerr << #x << ": " << x << "\n"

using ll = long long;
using P = pair<int, int>;

const long long MOD = 1e9+7;

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

int main() {
    int n;
    cin >> n;
    vector<int> x(n), y(n), h(n);
    int rx = -1, ry = -1, rh = -1;
    rep(i, n) {
        cin >> x[i] >> y[i] >> h[i];
        if (1 <= h[i]) {
            rx = x[i];
            ry = y[i];
            rh = h[i];
        }
    }

    rep(cx, 101) rep(cy, 101) {
        int ch = rh + abs(cx - rx) + abs(cy - ry);
        bool ok = true;
        rep(i, n) {
            int nh = max(0, ch - (abs(cx - x[i]) + abs(cy - y[i])));
            if (nh != h[i]) ok = false;
        }
        if (ok) printf("%d %d %d\n", cx, cy, ch);
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 200005;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin >> n >> m;
    vector<bool> ac(n,0);
    vector<ll> p(n,0);
    ll a;
    string s;
    rep(i,m){
        cin >> a >> s;
        if (s == "AC") ac[a-1] = 1;
        else{
            if (!ac[a-1]) p[a-1]++;
        }
    }
    ll b = 0,c = 0;
    rep(i,n){
        if (ac[i]){
            b++;
            c += p[i];
        }
    }
    cout << b << " " << c << endl;
}


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

using namespace std;

typedef long long ll;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll q, h, s, d, n;
    cin >> q >> h >> s >> d >> n;
    n <<= 2;
    h = min(h, q * 2);
    s = min(s, h * 2);
    d = min(d, s * 2);
    ll ans = 0;
    ans += d * (n / 8);
    n %= 8;
    ans += s * (n / 4);
    n %= 4;
    ans += h * (n / 2);
    n %= 2;
    ans += q * n;
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;

signed main(){
    int d,n;
    cin>>d>>n;
    int m;
    if(d==0)m = 1;
    else if(d==1)m = 100;
    else m = 10000;
    if(n!=100)cout<<m*n<<endl;
    else cout<<m*n+m<<endl;
}

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

int main()
{
	long long h, w;
	cin >> h >> w;
	
	if (h == 1 or w == 1)
	{
		cout << 1 << endl;
		return 0;
	}
	
	cout << (w*h)/2 + (w*h)%2 << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,-1,0,1},dy={1,0,-1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;cin >> n;
	ll l=0,r=1e9+1;
	while(r-l>1){
		ll mid=(r+l)/2;
		if(mid*mid<=n) l=mid;
		else r=mid;
	}
	if(l*l!=n) l++;
	ll k=l*l-n,t=1;
	for(ll i=2;i*i<=k;i++){
		if(k%i==0) t=i;
	}
	cout << 0 << " " << 0 << " " << l << " " << t << " " << k/t << " " << l << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int N,A,B,C,D[100],a,b,c[100],d,i,j;
	
	scanf("%d",&N);
	scanf("%d %d",&A,&B);
	scanf("%d",&D[0]);
	for(i=1;i<=N;i++){
		scanf("%d",&D[i]);
	}
	for(i=0;i<100;i++){
		for(j=1;j<N;j++){
			if(D[j]<=D[j+1]){
			a=D[j];
			D[j]=D[j+1];
			D[j+1]=a;
			}
		}
	}
	b=0;
	d=0;
	for(i=0;i<=N;i++){
		b+=D[i];
		d=A+B*i;
		c[i]=b/d;
	}
	for(i=0;i<100;i++){
		for(j=0;j<N;j++){
			if(c[j]<=c[j+1]){
				a=c[j];
				c[j]=c[j+1];
				c[j+1]=a;
			}
		}
	}
	printf("%d\n",c[0]);
	return 0;
}
		

Measured memory_bytes: 596
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>

using namespace std;

#define TRACE(x) cerr << #x << " " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<

#define fst first
#define snd second

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

const int B = 27397, MOD = 1e9 + 7;
const int B1 = 33941, MOD1 = 1e9 + 9;

llint a, b;

int main(void) {
  scanf("%lld%lld", &a, &b);
  if (abs(a - b) <= 1)
    printf("Brown\n");
  else
    printf("Alice\n");
  return 0;
}


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

int main() {

	char a, b;

	cin >> a >> b;

	if (a>b) {
		puts(">");
	}

	else if (a<b) {
		puts("<");
	}

	else {
		puts("=");
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 105;
bool vis[N] = {};
int main() {
    int x, n;
    cin >> x >> n;
    for (int i = 1, p; i <= n; i++) {
        cin >> p;
        vis[p] = true;
    }
    for (int i = 0; i <= N; i++) {
        if (!vis[x - i]) {
            cout << x - i << '\n';
            break;
        }
        if (!vis[x + i]) {
            cout << x + i << '\n';
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;

int main() {
    ll x; cin >> x;
    for(ll i=-200; i<=200; i++) {
        for(ll j=-200; j<=200; j++) {
            if(i*i*i*i*i - j*j*j*j*j == x) {
                cout << i << ' ' << j << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

ll dp[110000][2];
vi edge[110000];
int n, u, v;

void dfs(int x, int last = -1) {
  dp[x][0] = dp[x][1] = 1;
  for(auto to : edge[x]) {
    if(to==last) continue;
    dfs(to,x);
    dp[x][0] = dp[x][0] * ((dp[to][0] + dp[to][1]) % mod) % mod;
    dp[x][1] = dp[x][1] * dp[to][0] % mod; 
  }
}

int main() {
  cin >> n;
  for(int i = 0; i<n-1; i++) {
    cin >> u >> v;
    edge[u].push_back(v);
    edge[v].push_back(u);
  }
  dfs(1);
  cout << (dp[1][0] + dp[1][1]) % mod << endl;
  return 0;
}

Measured memory_bytes: 14464
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0
for i in range(n):
    a[i] -= 1
    ans += b[a[i]]
    if i > 0 and a[i - 1] + 1 == a[i]:
        ans += c[a[i - 1]]

print(ans)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] ave = new int[N];
		for (int i = 0; i < M; i++) {
			ave[sc.nextInt() - 1]++;
			ave[sc.nextInt() - 1]++;
		}
		for (int i = 0; i < ave.length; i++) {
			System.out.println(ave[i]);
		}
		sc.close();
	}
}

Measured memory_bytes: 22100
#include<stdio.h>

int main() {
  int n, p, i;
  int a[110];
  int num_even = 0;
  int num_odd = 0;
  long long combi_odd[50];
  scanf("%d %d", &n, &p);
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    if (a[i] % 2 == 0) {
      num_even += 1;
    } else {
      num_odd += 1;
    }
  }
  combi_odd[0] = 1;
  combi_odd[1] = num_odd;
  for (i = 2; i < num_odd+1; i++) {
    combi_odd[i] = (combi_odd[i-1] * (num_odd+1-i)) / i;
  }
  long long ans = 0;
  if (p == 1) {
    for (i = 1; i <= num_odd; i = i+2) {
      ans += combi_odd[i];
    }
    for (i = 0; i < num_even; i++) {
      ans = ans * 2;
    }
    printf("%lld\n", ans);
  } else {
    for (i = 0; i <= num_odd; i = i+2) {
      ans += combi_odd[i];
    }
    for (i = 0; i < num_even; i++) {
      ans = ans * 2;
    }
    printf("%lld\n", ans);
  }
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

const int Mod = 1000000007;

typedef struct List {
	struct List *next;
	int v, cost;
} list;

typedef struct {
	long long key;
	int id;
} data;
 
typedef struct {
	data obj[400001];
	int size;
} min_heap;
 
void push(data x, min_heap* h)
{
	int i = ++(h->size), j = i >> 1;
	data tmp;
	h->obj[i] = x;
	while (j > 0) {
		if (h->obj[i].key < h->obj[j].key) {
			tmp = h->obj[j];
			h->obj[j] = h->obj[i];
			h->obj[i] = tmp;
			i = j;
			j >>= 1;
		} else break;
	}
}

data pop(min_heap* h)
{
	int i = 1, j = 2;
	data output = h->obj[1], tmp;
	h->obj[1] = h->obj[(h->size)--];
	while (j <= h->size) {
		if (j < h->size && h->obj[j^1].key < h->obj[j].key) j ^= 1;
		if (h->obj[j].key < h->obj[i].key) {
			tmp = h->obj[j];
			h->obj[j] = h->obj[i];
			h->obj[i] = tmp;
			i = j;
			j = i << 1;
		} else break;
	}
	return output;
}

int main()
{
	int i, N, M, S, T, u, w;
	long long c;
	list *adj[100001] = {}, e[400001], *p;
	scanf("%d %d", &N, &M);
	scanf("%d %d", &S, &T);
	for (i = 0; i < M; i++) {
		scanf("%d %d %lld", &u, &w, &c);
		e[i*2].v = w;
		e[i*2+1].v = u;
		e[i*2].cost = c;
		e[i*2+1].cost = c;
		e[i*2].next = adj[u];
		e[i*2+1].next = adj[w];
		adj[u] = &(e[i*2]);
		adj[w] = &(e[i*2+1]);
	}
	
	int flag[100001] = {};
	const long long sup = (long long)1 << 60;
	long long dist[100001], count[3][100001] = {};
	data d;
	min_heap h[2];
	h[0].size = 0;
	h[1].size = 0;
	for (i = 1; i <= N; i++) dist[i] = sup;
	dist[S] = 0;
	count[0][S] = 1;
	d.key = 0;
	d.id = S;
	push(d, &(h[0]));
	while (h[0].size > 0) {
		d = pop(&(h[0]));
		u = d.id;
		if (flag[u] != 0) continue;
		flag[u] = 1;
		d.key *= -1;
		push(d, &(h[1]));
		for (p = adj[u]; p != NULL; p = p->next) {
			w = p->v;
			c = dist[u] + p->cost;
			if (c < dist[w]) {
				dist[w] = c;
				count[0][w] = count[0][u];
				d.key = dist[w];
				d.id = w;
				push(d, &(h[0]));
			} else if (c == dist[w]) count[0][w] = (count[0][w] + count[0][u]) % Mod;
		}
	}

	count[1][T] = 1;
	count[2][T] = count[0][T];
	while (h[1].size > 0) {
		d = pop(&(h[1]));
		u = d.id;
		if (dist[u] * 2 == dist[T]) count[2][u] = (count[2][u] - count[0][u] * count[1][u] % Mod * count[1][u] % Mod + Mod) % Mod;
		for (p = adj[u]; p != NULL; p = p->next) {
			w = p->v;
			c = dist[u] - p->cost;
			if (c != dist[w]) continue;
			count[1][w] = (count[1][w] + count[1][u]) % Mod;
			if (dist[u] * 2 <= dist[T] || dist[w] * 2 >= dist[T]) count[2][w] = (count[2][w] + count[2][u]) % Mod;
			else count[2][w] = (count[2][w] + count[2][u] - count[0][w] * count[1][u] % Mod * count[1][u] % Mod + Mod) % Mod;
		}
	}
	
	printf("%lld\n", count[2][S]);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 15284
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long a=sc.nextLong();
		long b = sc.nextLong();
		long ans=0;
		if(a==b){
			System.out.println(a);
			return;
		}
		if(a%2==1){
			ans=a;
			a++;
		}
		if(b%2==0){
			ans^=b;
			b--;
		}
		if((((b-a+1)/2)%2)==1){
			ans^=1;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 22608
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
template<class T> using vv=vector<vector< T > >;

int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  vll orig(n, 0);
  vll altered(n, 0);
  ll sum_all = 0;
  rep (i, n) {
    scanf("%lld", &orig[i]);
    if (orig[i] > 0) {
      altered[i] = orig[i];
      sum_all += orig[i];
    }
  }
  vll sumk_orig(n-k+1, 0);
  vll sumk_altered(n-k+1, 0);
  rep (i, k) {
    sumk_orig[0] += orig[i];
    sumk_altered[0] += altered[i];
  }
  FOR (i, 1, n-k+1) {
    sumk_orig[i] = sumk_orig[i-1] - orig[i-1] + orig[i-1+k];
    sumk_altered[i] = sumk_altered[i-1] - altered[i-1] + altered[i-1+k];
  }
  ll ans = 0;

  rep (i, n-k+1) {
    ans = max(ans, sum_all - sumk_altered[i] + max(0LL, sumk_orig[i]));
  }
  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize ("Ofast")
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace __gnu_pbds;
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long,long long> ii; 	
typedef complex<long double> com;

const ll mod = 1e9+7;

int main(){
	ios_base::sync_with_stdio(false);
	ld a,b;
	cin >> a >> b;
	cout << ll(trunc(a*b)) << endl;
}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
#define rep(i, k, n) for(int i = (int)(k);i < (int)(n);i++)
#define repd(i, k, n) for(int i = (int)(n-1);i >= (int)(k);i--)
#define ll long long
int main() {
  int N, W, s = 10e5+3, m = 0;cin >> N >> W;
  ll inf = 10e16;
  vector<ll> dp(s, inf);
  dp[0] = 0;
  vector<int> w(N+1), v(N+1);
  rep(i, 1, N+1) cin >> w[i] >> v[i];
  rep(i, 1, N+1) repd(j, 1, s) {
    if(j >= v[i]) dp[j] = min(dp[j], dp[j-v[i]]+w[i]);
  }
  rep(i, 1, s) if(dp[i] <= W) m = i;
  cout << m << endl;
}

Measured memory_bytes: 11176
def inverse(a, mod):
    a %= mod # 除数が正なら正になる
    p = mod
    x, y = 0, 1
    while a > 0:
        n = p // a
        p, a = a, p % a, 
        x, y = y, x - n * y
    return x % mod # 除数が正なら正になる
mod = 10 ** 9 + 7
n = int(input())
a = list(map(int, input().split()))
s = sum(a)

ans = 0
for x in a:
    ans = (ans + x * (s - x)) % mod
print (ans * inverse(2, mod) % mod)



Measured memory_bytes: 94116
import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int,input().split()))
Ac = list(range(1,N+1))
Alis = [[i,j]  for i,j in zip(A,Ac)]
As = sorted(Alis)
for a in As:
    print(a[1],end = " ")

Measured memory_bytes: 26800
import java.util.Scanner;

public class Main {

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

		String S = sc.next();
		long K = sc.nextLong();

		for (int i = 0; i < K; i++) {
			if (S.charAt(i) - '0' != 1) {
				System.out.println(S.charAt(i) - '0');
				return;
			}
		}

		System.out.println(1);
	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const int inf = INT_MAX-100;
vector<vector<int>> d(101010, vector<int>(3, inf));
vector<int> adj[101010];

void bfs(int s){
    queue<pair<int, int>> q;
    q.push(make_pair(s, 0));
    d[s][0] = 0;

    while(!q.empty()){
        auto node = q.front(); q.pop();
        int now = node.first;
        int r = node.second;

        for(auto to:adj[now]){
            if(d[now][r]+1 < d[to][(r+1)%3]){
                d[to][(r+1)%3] = d[now][r]+1;
                q.push(make_pair(to, (r+1)%3));
            }
        }
    }
}

int main(){
    int N, M; cin >> N >> M;
    for(int i=0; i<M; ++i){
        int u, v; cin >> u >> v;
        adj[u].push_back(v);
    }
    int s, t; cin >> s >> t;
    bfs(s);

    if(d[t][0] == inf) cout << -1 << endl;
    else cout << d[t][0]/3 << endl;

    return 0;
}

Measured memory_bytes: 11264
from collections import deque


k = int(input())
queue = deque([i for i in range(1, 10)])

ans = 1
for _ in range(k):
    ans = queue.popleft()
    right_digit = ans % 10
    if right_digit == 0:
        queue.append(ans * 10 + right_digit)
        queue.append(ans * 10 + right_digit + 1)
    elif right_digit == 9:
        queue.append(ans * 10 + right_digit - 1)
        queue.append(ans * 10 + right_digit)
    else:
        queue.append(ans * 10 + right_digit - 1)
        queue.append(ans * 10 + right_digit)
        queue.append(ans * 10 + right_digit + 1)
print(ans)


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3
#define mod 1000000007

int h,w;
int dp[55][55][55][55];
string s[55];
vector<P> nxt[55][55];

int dfs(int i1,int j1,int i2,int j2){

  if(s[i1][j1]=='#')return -INF;
  if(i1==i2&&j1==j2)return 0;
  if(dp[i1][j1][i2][j2]!=-1)return dp[i1][j1][i2][j2];

  if((i1+1==i2&&j1==j2)||(i1==i2&&j1+1==j2)){
    if('a'<=s[i1][j1]&&s[i1][j1]<='z'&&s[i1][j1]-'a'==s[i2][j2]-'A')return 1;
    else{
      if(s[i2][j2]=='#')return -INF;
      else return 0;
    }
  }

  int res=-INF;
  if(i1<i2)maxch(res,dfs(i1+1,j1,i2,j2));
  if(j1<j2)maxch(res,dfs(i1,j1+1,i2,j2));

  if('a'<=s[i1][j1]&&s[i1][j1]<='z'){
    if('A'<=s[i2][j2]&&s[i2][j2]<='Z'&&s[i2][j2]-'A'==s[i1][j1]-'a'){
      rep(d1,2){
        rep(d2,2){
          int ni1,nj1,ni2,nj2;
          if(d1==0){
            ni1=i1; nj1=j1+1;
          }else{
            ni1=i1+1; nj1=j1;
          }
          if(d2==0){
            ni2=i2; nj2=j2-1;
          }else{
            ni2=i2-1; nj2=j2;
          }
          if(ni1<=ni2&&nj1<=nj2){
            int v1=dfs(ni1,nj1,ni2,nj2);
            if(v1!=-INF)maxch(res,v1+1);
          }
        }
      }
    }
    for(P p : nxt[i1][j1]){
      if(!(p.fi<=i2&&p.se<=j2))continue;
      if(p.fi==i2&&p.se==j2)continue;
      int v1=dfs(i1,j1,p.fi,p.se);
      int v2=dfs(p.fi,p.se,i2,j2);
      if(v1!=-INF&&v2!=-INF)maxch(res,v1+v2);
    }
  }

  return dp[i1][j1][i2][j2]=res;
}

int main(){
  while(1){
    cin>>h>>w;
    if(h==0)break;
    rep(i,h)cin>>s[i];

    rep(i,h)rep(j,w){
      nxt[i][j].clear();
      if('a'<=s[i][j]&&s[i][j]<='z'){
        repl(k,i,h)repl(l,j,w){
          if('A'<=s[k][l]&&s[k][l]<='Z'&&s[k][l]-'A'==s[i][j]-'a'){
            nxt[i][j].push_back(P(k,l));
          }
        }
      }
    }

    rep(i,h)rep(j,w)rep(k,h)rep(l,w)dp[i][j][k][l]=-1;

    int res=dfs(0,0,h-1,w-1);
    if(res==-INF)cout<<-1<<endl;
    else cout<<res<<endl;
  }
  return 0;
}



Measured memory_bytes: 32916
#include <iostream>

constexpr int ALPH_NUM = 26;

int main()
{
    int alph_cnt[ALPH_NUM] = {};

    char in_char;
    while ((in_char = std::cin.get()) != EOF) {
        if ('a' <= in_char && in_char <= 'z') {
            alph_cnt[in_char - 'a']++;
        }
        if ('A' <= in_char && in_char <= 'Z') {
            alph_cnt[in_char - 'A']++;
        }
    }

    for (int i = 0; i < ALPH_NUM; i++) {
        std::cout << static_cast<char>('a' + i)
                  << " : " << alph_cnt[i] << std::endl;
    }

    return 0;
}

Measured memory_bytes: 1128
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#define int long 
using namespace std;

signed main() {
	int N,M;
	cin >> N >> M;
	vector<int> graph[10];
	for(int i = 0;i < M;i++) {
		int A,B;
		cin >> A >> B;
		graph[A].push_back(B);
		graph[B].push_back(A);
	}
	if(N == 2) {
		cout << 1 << endl;
	}
	else {
		int count[N];
		for(int i = 0;i < N;i++) {
			count[i] = i + 1;
		}
		int answer = 0;
		do {
			if(count[0] != 1) {
				break;
			}
			else {
				bool A = true;
				for(int i = 1;i < N;i++) {
					bool B = false;
					for(int j = 0;j < graph[count[i - 1]].size();j++) {
						if(count[i] == graph[count[i - 1]].at(j)) {
							B = true;
						}
					}
					if(B == false) {
						A = false;
					}
				}
				if(A == true) {
					answer++;
				}
			}
		} while(next_permutation(count,count + N));
		cout << answer << endl;
	}
}

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

using namespace std;

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

    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<int>());
    if (s < t) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI                acos(-1)
#define pb                emplace_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define F first
#define S second

using namespace std;

typedef int       ll;
typedef pair<ll, ll>  ii;
typedef vector<ll>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
const ll INF = ll(1e9 + 7);

const ll tam = 330;

ll dp[330][330][330];
vector< ii > rangs[330];

bool OK(ll i, ll j, ll k, ll l, ll r, ll x)
{
	ll diff = 0;
	if ( l <= i && i <= r ) diff++;
	if ( l <= j && j <= r ) diff++;
	if ( l <= k && k <= r ) diff++;
	return diff == x;
}

ll mod = 1e9+7;

int main()
{
    std::ios::sync_with_stdio(false); cin.tie(0);
    //freopen("","r",stdin);
    //freopen("","w",stdout);
    ll n, m;
    cin >> n >> m;
    for (ll i = 0; i < m; i++)
    {
    	ll l, r, x;
    	cin >> l >> r >> x;
    	rangs[r].pb( mp(l, x) );
    }
    clr(dp, 0);
    dp[0][0][0] = 1;
    for (ll i = 0; i <= n; i++)
    {
    	for (ll j = 0; j <= n; j++)
    	{
    		if (i > 0 && i == j) continue;
    		for (ll k = 0; k <= n; k++)
    		{
    			if (k > 0 && (i == k || j == k)) continue;
    			ll nxt = max(i, max(j, k)) + 1;

    			//cout << "Para " << i << ", " << j << ", " << k << ": ";

    			dp[nxt][j][k] = (dp[nxt][j][k] + dp[i][j][k]) % mod;
    			dp[i][nxt][k] = (dp[i][nxt][k] + dp[i][j][k]) % mod;
    			dp[i][j][nxt] = (dp[i][j][nxt] + dp[i][j][k]) % mod;

    			for (ii seg : rangs[nxt])
    			{
    				ll l = seg.F;
    				ll r = nxt;
    				ll x = seg.S;
    				if ( !OK(nxt, j, k, l, r, x) ) dp[nxt][j][k] = 0;
    				if ( !OK(i, nxt, k, l, r, x) ) dp[i][nxt][k] = 0;
    				if ( !OK(i, j, nxt, l, r, x) ) dp[i][j][nxt] = 0;
    			}
    			//cout << dp[i][j][k] << endl;
    		}
    	}
    }
    int res = 0;
    for (ll i = 0; i < n; i++)
    {
    	for (ll j = 0; j < n; j++)
    	{
    		if (i > 0 && i == j) continue;
    		res = ( res + dp[i][j][n] ) % mod;
    		res = ( res + dp[i][n][j] ) % mod;
    		res = ( res + dp[n][i][j] ) % mod;
    	}
    }
    cout << res << '\n';
    return 0;
}
// PLUS ULTRA!

Measured memory_bytes: 140672
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		double r = sc.nextDouble();
		double pi = 3.141592653589;
		
		double cir = 2 * r * pi;
		double area = r * r * pi;
		
		System.out.printf("%.6f" + " ", area);
		System.out.printf("%.6f", cir);
	}
}


Measured memory_bytes: 28288
//https://codeforces.com/contest/1293/problem/C
//BROWNIE TK

#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define pb push_back
#define popb pop_back()
#define pf push_front
#define popf pop_front()

#define si size()
#define be begin()
#define en end()
#define all(v) v.be, v.en

#define le length()
#define mp make_pair
#define mt make_tuple
#define acc(v) accumulate(all(v), 0)
#define F first
#define S second

#define pll pair<lli, lli>
#define pii pair<int, int>
#define pil pair<int, lli>

#define forz(i, n) for (int i = 0; i < n; i++)
#define fore(i, m, n) for (int i = m; i <= n; i++)
#define rforz(i, n) for (int i = n - 1; i >= 0; i--)
#define rfore(i, m, n) for (int i = n; i >= m; i--)

#define deci(n) fixed << setprecision(n)
#define high(n) __builtin_popcount(n)
#define highll(n) __builtin_popcountll(n)
#define parity(n) __builtin_parity(n)
#define ctz(n) __builtin_ctz(n)

#define bset(a, p) ((a) | (1ll << (p)))
#define bchk(a, p) ((a) & (1ll << (p)))
#define bxor(a, p) ((a) ^ (1ll << (p)));
#define brem(a, p) (bchk(a, p) ? (bxor(a, p)) : (a))
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/

#define lb lower_bound
#define ub upper_bound
#define er equal_range

#define findnot find_first_not_of

#define maxe *max_element
#define mine *min_element

#define mod 1000000007
#define mod2 998244353
#define gcd __gcd
#define kira ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl

#define oset tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define osetlli tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements sbtriectly lesser than k
//2. find_by_order(k) : k-th element in the set
#define ofk order_of_key
#define fbo find_by_order
using namespace std;

/*STD funcions*/
lli power(lli x, lli y, lli p)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
lli modi(lli a, lli m) { return power(a, m - 2, m); }
/*CODE BEGINS*/
int main()
{
    kira;
    lli k,n;
    cin>>k>>n;
    lli s=0;
    lli x;
    forz(i,n)
    {
        cin>>x;
        s+=x;
    }
    if(s>=k)p1("Yes");
    else p1("No");
    return 0;
}

Measured memory_bytes: 256
#include <deque>
#include <iostream>
#include <string>

using namespace std;

long long power(int k) {
    long long base = -2, ret = 1;
    while (k) {
        ret *= base;
        k--;
    }
    return ret;
}

int main(void) {
    int M, N;
    long long k;
    deque<int> str, E;
    cin >> N;
    k = 0LL;
    k = 33 - __builtin_clz(abs(N));
    // if (__builtin_popcount(abs(N)) == 1) k++;
    while (k>=0 && N != 0) {
        M = N - power(k);
        int l1 = k/2, l2 = (k-1)/2;
        if (k%2) l2--; else l1--;
        if (M <= ((power(2*(l1+1)) - 1)/3) && M >= (-2)*(power(2*(l2+1))-1)/3) {
            E.push_front(k);
            N = M;
        }
        k--;
    }
    for (auto& itr : E) {
        if (itr == str.size()) str.push_front(1);
        else {
            while (itr != str.size()) str.push_front(0);
            str.push_front(1);
        }
    }
    if (str.empty()) str.push_front(0);
    for (auto& itr : str) {
        cout << itr;
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict

def main():
    n, m = [int(e) for e in input().split()]
    PY = [[int(e) for e in input().split()] for i in range(m)]

    Ds = defaultdict(set)
    for p, y in PY:
        Ds[p].add(y)

    Dd = defaultdict(dict)
    for p, s in Ds.items():
        for i, y in enumerate(sorted(s)):
            Dd[p][y] = i + 1

    for p, y in PY:
        print('{:06}{:06}'.format(p, Dd[p][y]))

if __name__ == "__main__":
    main()


Measured memory_bytes: 119384
#include <bits/stdc++.h>
#define REP(i, a, n) for (ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

struct node {
  string A;
  ll B, C;
  vector<string> D;
};

ll N;
node P[40];

ll adjust[40];
ll used, ans, sum;

void dfs(ll v) {
  if (v == N) {
    ans = max(ans, sum);
    return;
  }

  ll former = used & adjust[v] & ((1LL << v) - 1);
  ll latter = adjust[v] & (((1LL << N) - 1) - ((1LL << v) - 1) - (1LL << v));

  if (former) {
    dfs(v + 1);
  } else if (!former && !latter) {
    used += 1LL << v;
    sum += P[v].B;
    dfs(v + 1);
    used -= 1LL << v;
    sum -= P[v].B;
  } else {
    dfs(v + 1);
    used += 1LL << v;
    sum += P[v].B;
    dfs(v + 1);
    used -= 1LL << v;
    sum -= P[v].B;
  }
}

int main(void) {
  while (cin >> N, N != 0) {
    REP(i, 0, N) {
      cin >> P[i].A >> P[i].B >> P[i].C;
      P[i].D.clear();
      REP(j, 0, P[i].C) {
        string S;
        cin >> S;
        P[i].D.push_back(S);
      }
    }
    sort(P + 1, P + N, [](const node x, const node y) { return x.C > y.C; });

    map<string, ll> mp;
    REP(i, 0, N) mp[P[i].A] = i;

    REP(i, 0, N) adjust[i] = 0;
    REP(i, 0, N) {
      REP(j, 0, P[i].C) {
        ll v = mp[P[i].D[j]];
        adjust[i] += 1LL << v;
      }
    }

    used = 1;
    ans = P[0].B;
    sum = P[0].B;
    dfs(1);

    cout << ans << endl;
  }
}


Measured memory_bytes: 3376
#include <bits/stdc++.h>
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
using namespace std;
int D;
int c[27], s[400][27];
int L[27];
int last[27];
long long ANS = 0;
long long ans = 0;
int main(){
    scanf("%d",&D);
    for (int i = 1; i <= 26; i++) scanf("%d",&c[i]);
    for (int i = 1; i <= D; i++){
        for (int j = 1; j <= 26; j++) scanf("%d",&s[i][j]);
    }
    for (int i = 1; i <= D; i++){
        int b1 = -1;
        long long ok = 0;
        for (int t = 1; t <= 26; t++){
            /*long long MINUS = 0;
            long long SUM = 0;
            for (int j = 1; j <= 26; j++){
                MINUS -= c[j]*(i-last[j]);
                SUM += c[j];
            }*/
            for (int x = 1; x <= 26; x++){
                for (int y = 1; y <= 26; y++){
                    ans = ANS;
                    for (int j = 1; j <= 26; j++){
                        last[j] = L[j];
                    }

                        ans += s[i][t];
                        last[t] = i;

                        for (int j = 1; j <= 26; j++){
                            ans -= c[j]*(i-last[j]);
                        }

                    if (i != D){
                        ans += s[i+1][x];
                        last[x] = i+1;
                        for (int j = 1; j <= 26; j++){
                            ans -= c[j]*(i+1-last[j]);
                        }
                    }

                    if (i < D-1){
                        ans += s[i+2][y];
                        last[y] = i+2;
                        for (int j = 1; j <= 26; j++){
                            ans -= c[j]*(i+2-last[j]);
                        }
                    }

                    if (b1 == -1 || ans > ok){
                        b1 = t;
                        ok = ans;
                    }
                }
            }
            //printf("for %d: %lld\n",t,ans);
        }
        ANS += s[i][b1];
        L[b1] = i;
        for (int j = 1; j <= 26; j++){
            ANS -= c[j]*(i-L[j]);
        }
        printf("%d\n",b1);
        //printf("score %lld\n",ANS);
    }
}


Measured memory_bytes: 3848
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
ll evaluate(VV &S,ll d,V &prev,V &C,ll j){
    
    ll temp = 0;
    temp+=S[d][j];
    rep(k, 26) {
        if (j == k) {
            continue;
        }
        temp -= C[k] * (d - prev[k]);
    }
    return temp;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll d;
    cin >> d;
    V C(26);
    rep(i, 26) cin >> C[i];
    VV S(d, V(26));
    rep(i, d) { rep(j, 26) cin >> S[i][j]; }
    ll width=26;
    vector<tuple<ll,V,V>> vec;
    V temp;
    rep(i,26)temp.push_back(-1);
    V temp2;
    vec.push_back({0,temp,temp2});
    rep3(i,0,d){
        priority_queue<tuple<ll, V, V>> q;
        ll reg=-INF;
        ll res=0;
        for(auto j:vec){
            ll score=get<0>(j);
            V prev=get<1>(j);
            V history=get<2>(j);
            rep(k,26){
                ll value=evaluate(S,i,prev,C,k);
                V prev2=prev;
                prev2[k]=i;
                V history2=history;
                history2.push_back(k);
                q.push({score+value,prev2,history2});
            }
        }
        vec={};
        rep(j,width){
            vec.push_back(q.top());
            q.pop();
        }
    }
    for(auto i:get<2>(vec[0])){
        cout<<i+1<<endl;
    }
}


Measured memory_bytes: 6156
# Digital Gifts
N = int(input().strip())

sum = 0
for n in range(N):
	S = input().strip().split()
	xn = float(S[0])
	un = S[1]
	if un == 'JPY':
		sum += xn
	elif un == 'BTC':
		sum += 380000*xn

print(sum)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();
        long X = sc.nextLong();

        long cnt = B/X - A/X;
        if (A%X==0) cnt++;

        System.out.println(cnt);

        sc.close();

    }

}


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

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var m = int.Parse(line[1]);
        if (m == 1) { Console.WriteLine(0); goto exit; }
        if (n >= m) { Console.WriteLine(0); goto exit; }
        line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        Array.Sort(a);
        var b = new int[m - 1];
        for (int i = 0; i <m-1; i++)
            b[i] = a[i + 1] - a[i];
        Array.Sort(b);
        Array.Reverse(b);
        var bsum = b.Sum();
        var t = 0;
        for (int i = 0; i < n - 1; i++) t += b[i];
        var ans = bsum - t;
        Console.WriteLine(ans);
        exit:;
    }
}

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

int main(void)
{
	std::vector<int> incar;

	int n;

	while(std::cin >> n)
	{
		size_t isize=incar.size(); 
		if(n==0)
		{
			//outcar.push_back(incar[isize-1]);
			std::cout << incar[isize-1] << '\n';

			incar.pop_back();
		}
		else
		{
			incar.push_back(n);
		}
	}
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
// Welcome to my source code!

int main() {
    int x, y, z;
    cin >> x >> y >> z;
    cout << (x - z) / (y + z) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int n;
int q,x;
vector<int>v;
int main(){
    cin>>n;
    while(n--){
        cin>>q;
        if(q==2)v.pop_back();
        if(q==0){
            cin>>x;
            v.push_back(x);
        }
        if(q==1){
            cin>>x;
            cout<<v[x]<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3828
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (int i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": ";
    printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  string s;
  cin >> s;
  ll N = s.size() + 1;
  vector<ll> a(N, -1);

  if (s[0] == '<') { a[0] = 0; }
  if (s[N-2] == '>') { a[N-1] = 0; }

  // Set 0 to > <
  for (int i = 1; i < N-1; ++i) {
    if (s[i-1] == '>' && s[i] == '<') {
      a[i] = 0;
    }
  }
  // Set number from left
  for (int i = 1; i <= N-2; ++i) {
    if (s[i-1] == '<' && s[i] == '<') {
      a[i] = a[i-1] + 1;
    }
  }
  // Set number from right
  for (int i = N-2; i >= 1; --i) {
    if (s[i-1] == '>' && s[i] == '>') {
      a[i] = a[i+1] + 1;
    }
  }
  // Set to < >
  for (int i = 1; i < N-1; ++i) {
    if (s[i-1] == '<' && s[i] == '>') {
      a[i] = max(a[i-1], a[i+1]) + 1;
    }
  }
  if (s[0] == '>') { a[0] = a[1] + 1; }
  if (s[N-2] == '<') { a[N-1] = a[N-2] + 1; }

  ll ans = 0;
  rep(i, N) {
    ans += a[i];
  }

  cout << ans << endl;
}


Measured memory_bytes: 4740
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
   int n;
   cin>>n;
   int k;
   cin>>k;
   long long ans=0;
   vector<int>arr(n);
   int temp;
   for(int i=0;i<n;i++)
   {
   	   cin>>temp;
   	   arr[i]=temp;
   }
   sort(arr.begin(),arr.end());
   for(int i=0;i<k;i++)
   {
   	ans+=arr[i];
   }
   cout<<ans;
 
 
}


Measured memory_bytes: 3648
import Data.List

ints :: String -> [Int]
ints s = map read $ words s

getLines :: IO [[Int]]
getLines = do
  s <- getLine
  let [a, b] = ints s
  if a == 0 && b == 0
    then return []
    else do
      rest <- getLines
      return ([a, b] : rest)

calc :: Int -> Int -> String
calc w h = intercalate "\n" $ [t] ++ replicate (h-2) m ++ [t]
  where
    t = replicate w '#'
    m = "#" ++ replicate (w-2) '.' ++ "#"

main :: IO ()
main = do
  xs <- getLines
  putStrLn $ intercalate "\n\n" [calc w h | ys <- xs, let [h, w] = ys]
  putStrLn ""

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

using namespace std;

namespace {

    typedef double real;
    typedef long long ll;

    template<class T> ostream& operator<<(ostream& os, const vector<T>& vs) {
        if (vs.empty()) return os << "[]";
        os << "[" << vs[0];
        for (int i = 1; i < vs.size(); i++) os << " " << vs[i];
        return os << "]";
    }
    template<class T> istream& operator>>(istream& is, vector<T>& vs) {
        for (auto it = vs.begin(); it != vs.end(); it++) is >> *it;
        return is;
    }

    int N, C;
    vector<ll> A, B;
    void input() {
        cin >> N >> C;
        A.resize(N); cin >> A;
        B.resize(N); cin >> B;
    }

    ll mod = ll(1e9+7);

    ll modpow(ll x, ll n) {
        if (n == 0) return 1LL;
        if (n % 2 == 1) {
            return (modpow(x, n - 1) * x) % mod;
        } else {
            return modpow(x * x % mod, n / 2);
        }
    }

    const int MAX_N = 405;
    const int MAX_C = 405;

    ll X[MAX_N][MAX_C];
    ll dp[MAX_N][MAX_C];

    ll M[MAX_N][MAX_C];
    void solve() {
        //assert(A == B);
        memset(X, 0, sizeof(X));
        memset(M, 0, sizeof(M));
        for (int n = 0; n <= C; n++) {
            for (ll j = 0; j <= 400; j++) {
                M[n][j] = modpow(j, n);
            }
        }
        for (int i = 0; i < N; i++) {
            for (int n = 0; n <= C; n++) {
                for (ll j = A[i]; j <= B[i]; j++) {
                    X[i][n] = (X[i][n] + M[n][j]) % mod;
                }
            }
        }
        memset(dp, 0, sizeof(dp));
        dp[N][C] = 1;
        for (int i = N - 1; i >= 0; i--) {
            for (int k = 0; k <= C; k++) {
                for (int j = k; j <= C; j++) {
                    dp[i][k] = (dp[i][k] + dp[i + 1][j] * X[i][j - k] % mod) % mod;
                }
            }
        }
        cout << dp[0][0] << endl;
    }
}

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



Measured memory_bytes: 4096
q,w = [4,6,9,11], [1,3,5,7,8,10,12]
x, y = map(int, input().split())
if x in q and y in q:
    print('Yes')
elif x in w and y in w:
    print('Yes')
elif x == 2 and y == 2:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3188
import sys, collections

input=sys.stdin.readline

def main():
    n=int(input())
    a = [int(i) for i in input().split()]
    ac = collections.Counter(a)
    k = ac.keys()
    ans = 0
    for i in k:
        if i <= ac[i]:
            ans += ac[i] - i
        else:
            ans += ac[i]

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 64424