akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>

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

using namespace std;

typedef long long ll;

template<typename T>
struct BIT {
  vector<T> data;
  BIT() {}
  BIT(int n) : data(n+1, 0) {}
  void init(int n) { data.assign(n+1, 0); }
  T sum(int ed) const {
    for(T res(0); ; ed &= ed-1) if(ed) res += data[ed]; else return res;
  }
  void add(int i, const T& x) {
    for(++i; i < (int)data.size(); i += i&-i) data[i] += x;
  }
};


int vs[100000+10];
ll cs[100000+10];
BIT<ll> bit1;
BIT<ll> bit2;

struct K {
  ll v;
  int idx;
};
bool operator<(const K& a, const K& b) {
  if(a.v != b.v) return a.v < b.v;
  return a.idx > b.idx;
}
priority_queue<K> q;

int main(void) {
  int n;
  scanf("%d", &n);
  REP(i, n) {
    scanf("%d", &vs[i]);
  }

  REP(i, n) {
    q.push((K){vs[i], i});
  }
  bit1.init(n);
  bit2.init(n);
  while(!q.empty()) {
    K cur = q.top(); q.pop();
    ll sum = bit1.sum(n) - bit1.sum(cur.idx+1);
    ll cnt = bit2.sum(n) - bit2.sum(cur.idx+1);
    cs[cur.idx] = sum - cnt * cur.v;
    bit1.add(cur.idx, cur.v);
    bit2.add(cur.idx, 1);
  }

  ll last = -1;
  ll rest = bit1.sum(n);
  REP(i, n) {
    if(vs[i] <= last) {
      puts("0");
      continue;
    }
    ll cur = rest - cs[i];
    printf("%lld\n", cur);
    rest -= cur;
    last = vs[i];
  }
  
  return 0;
}


Measured memory_bytes: 5360
n = int(input())
s = []
for i in range(n):
    s.append(input())
jisyo = []

for moji in s:
    dic = {}
    for i in moji:
        if i not in dic:
            dic[i] = 1
        else:
            dic[i] +=1
    jisyo.append(dic)

moji = "abcdefghijklmnopqrstuvwxyz"
ansdic = {}
for i in range(len(moji)):
    ansdic[moji[i]] = 100
for tmpdic in jisyo:
    for i in range(len(moji)):
        if moji[i] not in tmpdic.keys():
            ansdic[moji[i]] = 0
        else:
            if tmpdic[moji[i]] < ansdic[moji[i]]:
                ansdic[moji[i]] = tmpdic[moji[i]]
ans = ""
for key,value in ansdic.items():
    if value != 0:
        ans +=key*value
print(ans)

Measured memory_bytes: 68436
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<ll, ll> PL;

const ll mod = 1000000007;


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	ll h; cin >> h;
	ll cnt = 0;
	ll tmp = 1;
	while(h >= 1){
		h /= 2;
		cnt += tmp;
		tmp *= 2;
	}
	cout << cnt << endl;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,ans;cin>>N;
  if(N<=99)ans=min(9,N);
  else if(N<=9999)ans=min(909,N-90);
  else ans=min(90909,N-9090);
  cout<<ans<<endl;
}


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

int main()
{
    string s;
    cin>>s;
    int ans;
    if(s=="SUN")ans=7;
    else if(s=="MON")ans=6;
    else if(s=="TUE")ans=5;
    else if(s=="WED")ans=4;
    else if(s=="THU")ans=3;
    else if(s=="FRI")ans=2;
    else if(s=="SAT")ans=1;
    cout<<ans<<endl;

}


Measured memory_bytes: 3560
#include<iostream>
enum{N=100000,M=100000007};long long d[N+1][2],t,i,j,l[2]={3,5};main(){for(;t<2;t++){for(d[1][t]=i=1;i++<l[t];)d[i][t]=d[i-1][t]*2;for(i=l[t];i++<N;)for(d[i][t]=1,j=0;j++<l[t];)d[i][t]=(d[i][t]+d[i-j][t])%M;}for(std::string s;std::cin>>s,s!="#";printf("%d\n",t))for(s+=(t=j=i=1);i<s.size();i++)s[i-1]-s[i]?(t=t*d[j][s[i-1]-56&&s[i-1]-48]%M),j=1:j++;}

Measured memory_bytes: 2712
#include <cassert>
#include <cstdio>
#include <functional>
#include <map>
#include <tuple>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
using ll = long long;
using namespace std;

int main() {
    // input
    int n; scanf("%d", &n);
    vector<pair<int, int> > edges(n - 1);
    vector<vector<int> > g(n);
    repeat (i, n - 1) {
        int a, b; scanf("%d%d", &a, &b); -- a; -- b;
        edges[i] = { a, b };
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<ll> s(n); repeat (i, n) scanf("%lld", &s[i]);
    // solve
    map<pair<int, int>, ll> result;
    vector<int> parent(n, -1);
    vector<int> size(n);
    vector<ll> score(n);
    int center_j = -1;
    function<void (int)> go = [&](int i) {
        size[i] = 1;
        for (int j : g[i]) if (j != parent[i]) {
            parent[j] = i;
            go(j);
            size[i] += size[j];
            score[i] += score[j];
            int size_j_c = n - size[j];
            if (size_j_c == size[j]) {
                center_j = j;
                continue;
            }
            assert ((s[j] - s[i]) % (size_j_c - size[j]) == 0);
            ll w =  (s[j] - s[i]) / (size_j_c - size[j]);
            score[i] += w * size[j];
            result[make_pair(i, j)] = w;
            result[make_pair(j, i)] = w;
        }
    };
    go(0);
    if (center_j != -1) {
        assert ((s[0] - score[0]) % size[center_j] == 0);
        ll w = (s[0] - score[0]) / size[center_j];
        int center_i = parent[center_j];
        result[make_pair(center_i, center_j)] = w;
        result[make_pair(center_j, center_i)] = w;
    }
    // output
    for (auto edge : edges) {
        int a, b; tie(a, b) = edge;
        assert (result.count(make_pair(a, b)));
        printf("%lld\n", result[make_pair(a, b)]);
    }
    return 0;
}


Measured memory_bytes: 39296
#include <stdio.h>
#include <stdlib.h>
#define inf 1e9

double min(double a, double b){
	return a <= b ? a : b;
}

int main(){
	int N, i, j;
	double nowv = 0, ans = 0, x, x1, x2, b;
	scanf("%d", &N);
	double *t = (double *)malloc(sizeof(double) * (N + 1));
	double *t_sum = (double *)malloc(sizeof(double) * (N + 1));
	double *v = (double *)malloc(sizeof(double) * (N + 1));
	t_sum[0] = 0;
	for(i = 0; i < N; i++){
		scanf("%lf", &t[i]);
		t_sum[i + 1] = t_sum[i] + t[i];
	}
	for(i = 0; i < N; i++){
		scanf("%lf", &v[i]);
	}
	t[N] = 0;
	v[N] = 0;
	for(i = 0; i < N; i++){
//		printf("i = %d\n", i);
		b = inf;
		for(j = i + 1; j <= N; j++){
//			printf("j = %d\n", j);
//			printf("(v[j], t_sum[j]) = (%lf, %lf)\n", v[j], t_sum[j]);
//			printf("v[j] + t_sum[j] = %lf\n", v[j] + t_sum[j]);
			b = min(b, v[j] + t_sum[j]);
		}
//		printf("b = %lf\n", b);
		if(v[i] + t_sum[i + 1] < b){
			if(nowv + t[i] <= v[i]){
//				printf("test1\n");
				ans += t[i] * (2 * nowv + t[i]) / 2;
				nowv = nowv + t[i];
			}
			else{
				x = v[i] - nowv + t_sum[i];
//				printf("test2: x = %lf\n", x);
				ans += (v[i] + nowv) * (x - t_sum[i]) / 2 + v[i] * (t_sum[i + 1] - x);
				nowv = v[i];
			}
		}
		else{
			if((nowv - t_sum[i] + b) / 2 <= v[i]){
				x = (t_sum[i] + b - nowv) / 2;
//				printf("test3: x = %lf\n", x);
				if(x <= t_sum[i + 1]){
					ans += (x - t_sum[i]) * (nowv + b - x) / 2 + (t_sum[i + 1] - x) * (b - x + b - t_sum[i + 1]) / 2;
					nowv = b - t_sum[i + 1];
				}
				else{
					ans += t[i] * (2 * nowv + t[i]) / 2;
					nowv = nowv + t[i];
				}
			}
			else{
				x1 = v[i] + t_sum[i] - nowv;
				x2 = b - v[i];
//				printf("test4: (x1, x2) = (%lf, %lf)\n", x1, x2);
				ans += (x1 - t_sum[i]) * (nowv + v[i]) / 2 + v[i] * (x2 - x1) + (t_sum[i + 1] - x2) * (v[i] + b - t_sum[i + 1]) / 2;
				nowv = b - t_sum[i + 1];
			}
		}
	}
	printf("%lf\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
static const int MAX = 100000;
static const int NIL = -1;

class Node {
    public:
        int parent, left, right;
        Node();
};

Node::Node() {
    parent = left = right = NIL;
}
Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d) {
    if (u == NIL) return;
    D[u] = d;
    setDepth(T[u].left, d + 1);
    setDepth(T[u].right, d + 1);
}

int setHeight(int u) {
    int h1 = 0, h2 = 0;
    if (T[u].left != NIL) h1 = setHeight(T[u].left) + 1;
    if (T[u].right != NIL) h2 = setHeight(T[u].right) + 1;
    return H[u] = max(h1, h2);
}

int getSibling(int u) {
    if (T[u].parent == NIL) return NIL;
    if (T[T[u].parent].left != u && T[T[u].parent].left != NIL) return T[T[u].parent].left;
    if (T[T[u].parent].right != u && T[T[u].parent].right != NIL) return T[T[u].parent].right;
    return NIL;
}

void print(int u) {
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].parent << ", ";
    cout << "sibling = " << getSibling(u) << ", ";
    int deg = 0;
    if (T[u].left != NIL) deg++;
    if (T[u].right != NIL) deg++;
    cout << "degree = " << deg << ", ";
    cout << "depth = " << D[u] << ", ";
    cout << "height = " << H[u] << ", ";

    if (T[u].parent == NIL) cout << "root" << endl;
    else if (T[u].left == NIL && T[u].right == NIL) cout << "leaf" << endl;
    else cout << "internal node" << endl; 
}


int main() {
    int v, l, r, root = 0;
    cin >> n;
    
    for (int i = 0; i < n; i++) {
        cin >> v >> l >> r;
        T[v].left = l;
        T[v].right = r;
        if (l != NIL) T[l].parent = v;
        if (r != NIL) T[r].parent = v;
    }

    for (int i = 0; i < n; i++) if (T[i].parent == NIL) root = i;

    setDepth(root, 0);
    setHeight(root);

    for (int i = 0; i < n; i++) print(i);

    return 0;
}


Measured memory_bytes: 4276
from sys import stdin
n = int(stdin.readline().rstrip())
a = [int(x) for x in stdin.readline().rstrip().split()]
ans1 = 0
sum_sec = 0
for ind,i in enumerate(a):
    sum_sec += i
    if ind % 2 == 0:
        if sum_sec <= 0:
            ans1 += (-sum_sec+1)
            sum_sec = 1
    else:
        if sum_sec >= 0:
            ans1 += (sum_sec+1)
            sum_sec = -1

ans2 = 0
sum_sec = 0
for ind,i in enumerate(a):
    sum_sec += i
    
    if ind % 2 == 0:
        if sum_sec >= 0:
            ans2 += (sum_sec+1)
            sum_sec = -1
    else:
        if sum_sec <= 0:
            ans2 += (-sum_sec+1)
            sum_sec = 1
    #print(sum_sec)
print(min(ans1,ans2))

Measured memory_bytes: 14648
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
    int N, P;
    cin >> N >> P;

    vector<pair<int, int>> prs;

    int root = sqrt(P + 1);
    REP(i, 2, root) {
        if (P % i == 0) {
            int cnt = 0;
            while (P % i == 0) {
                cnt ++;
                P /= i;
            }
            prs.push_back(mp(i, cnt));
        }
        if (P < i) break;
    }
    if (P > 1) prs.push_back(mp(P, 1));

    int ret = 1;
    for (auto &pr : prs) {
        if (pr.second >= N) {
            rep(i, pr.second / N) ret *= pr.first;
        }
    }

    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <sstream>

using namespace std;

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

    int ans = 0;
    X = X - A;
    ans = X % B;

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b >= c) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;

int main()
{
    int n,k;
    cin >> n >> k;
    vector <int> vt(n);
    for(int i=0; i<n; i++){
        cin >> vt[i];
    }
    sort(vt.begin(), vt.end(), greater<int>());
    int ans=0;
    for(int i=0; i<k; i++){
        ans+=vt[i];
    }
    cout << ans;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		double a;
		double sum;
		
		while (sc.hasNext()) {
			a = sc.nextDouble();
			sum = a;
			for (int i = 0; i < 9; i++) {
				if (i % 2 == 0) {
					a *= 2.0;
					sum += a;
				} else {
					a /= 3.0;
					sum += a;
				}
			}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 12000
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#define mp make_pair
using namespace std;
map<string,vector<string> > recipe;
map<string,int>items;

int price(string item){
  if(recipe.find(item) != recipe.end()){
    int p=0;
    for(int i=0;i<recipe[item].size();i++)
      p+= price(recipe[item][i]);
    return min(p,items[item]);
  }
  else return items[item];
}

int main(){
  int n,m,k;
  while(true){
    cin>>n;
    if(!n)break;
    string name;
    int pr;
    items.clear();
    recipe.clear();
    for(int i=0;i<n;i++){
      cin>>name>>pr;
      items.insert(mp(name,pr));
    }
    cin>>m;
    for(int j=0;j<m;j++){
      cin>>name>>k;
      vector<string> material;
      string mat_name;
      for(int i=0;i<k;i++){
	cin>>mat_name;
	material.push_back(mat_name);
      }
      recipe.insert(mp(name,material));
    }
    cin>>name;
    cout<<price(name)<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,n)  for(ll i=0;i<n;i++)
#define fb(i,n) for(ll i=n-1;i>=0;i--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef pair<int,int> pii;
int main()
{
	IOS;
	//int t; cin>>t;
	//ll M=pow(10,9)+7;
	int t=1;
	while(t)
	{
		int n,m; cin>>n>>m;
		ll k; cin>>k;
		ll a[n],b[m];
		for(int i=0;i<n;i++) cin>>a[i];
		for(int i=0;i<m;i++) cin>>b[i];
		ll A[n+1],B[m+1]; A[0]=0; B[0]=0;
		for(int i=1;i<=n;i++) A[i]=A[i-1]+a[i-1];
		for(int i=1;i<=m;i++) B[i]=B[i-1]+b[i-1];
		int i=0,j=m;
		vector<int> v;
		int count=0;
		while(1)
		{
			if(A[i]+B[j]>k&&j>=0&&i<=n)
			{
				j--;
			}
			else
			{
				if(j==0)
				{
					if(A[i]<=k)
					{
						v.push_back(i);
						i++;
					}
					else
					{
						count=-1;
					}
				}
				if(i<=n&&j>=0&&A[i]+B[j]<=k)
				{
					v.push_back(i+j);
					//cout<<(i+j)<<" ";
					i++;
				}
			}
			if(j==-1)
			{
				break;
			}
			if(count==-1) break;
			if(i==n+1) break;
		}
		sort(v.begin(),v.end());
		if(v.size()!=0)
		cout<<v[v.size()-1];
		else
		cout<<"0\n";
		t--;
	}
	return 0;
}


Measured memory_bytes: 10488
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <functional>
#include <stack>
#include <utility>
#include <map>
#include <queue>
#include <set>
#include <array>
#include <climits>

using namespace std;

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

const ll MOD = 1000000000 + 7;
const ll INF = 99999999;
const ll MAX_V = 105;
const double EPS = 10e-6;
const double PI = 3.14159265359;

ll dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 };
//int d[] = {0,1,0,-1};
//int nx = x + d[i];
//int ny = y + d[(i+1)%4]




struct edge { ll to, cost; bool used = false; };

vector<edge> G[MAX_V];

bool es[105][105]{};

ll dmin[MAX_V];
ll V, E; 

void dijkstra(ll s) {
	priority_queue<P, vector<P>, greater<P>> que;
	fill(dmin, dmin + V, INF);
	dmin[s] = 0;
	que.push(P(0, s));

	while (!que.empty()) {
		P p = que.top(); que.pop();
		ll v = p.second;
		if (dmin[v] < p.first)continue;
		for (ll i = 0; i<G[v].size(); i++) {
			edge e = G[v][i];
			if (dmin[e.to] > dmin[v] + e.cost) {
				dmin[e.to] = dmin[v] + e.cost;
				que.push(P(dmin[e.to], e.to));
			}
		}
	}

	que.push(P(0, s));
	while (!que.empty()) {
		P p = que.top(); que.pop();
		ll v = p.second;
		if (dmin[v] < p.first)continue;
		for (ll i = 0; i<G[v].size(); i++) {
			edge e = G[v][i];
			if (dmin[e.to] == dmin[v] + e.cost) {
				es[e.to][v] = true;
				es[v][e.to] = true;
				que.push(P(dmin[e.to], e.to));
			}
		}
	}
}



int main() {
	ll cnt = 0;
	cin >> V >> E;
	for (int i = 0; i < E; i++) {
		ll a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		G[a].push_back({ b,c });
		G[b].push_back({ a,c });
	}
	for (int i = 0; i < V; i++) {
		dijkstra(i);
	}
	for (int i = 0; i < V; i++) {
		for (int j = 0; j < V; j++) {
			if (es[i][j]) {
				cnt++;
				es[i][j] = false;
				es[j][i] = false;
			}
		}
	}
	cout << E - cnt << endl;
	return 0;
}

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

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); 
int k,s; cin >> k >> s;
int ans{};

for(int i{}; i<=k; ++i){
	for(int j{}; j<=k; ++j){
		int z = s-i-j;
		if(0<=z && z<=k){
			ans+=1;
		}
	}
}

cout << ans << "\n";





 return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, 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;}

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  string s; cin >> s;
  string t; cin >> t;
  int n = s.length(), m = t.length();
  vector<vector<int>> is(26);
  rep(i, n) is[s[i] - 'a'].push_back(i);
  rep(i, n) is[s[i] - 'a'].push_back(i + n);
  ll ans = 0;
  int p = 0;
  rep(i, m){
    int c = t[i] - 'a';
    if (is[c].size() == 0) {cout << -1 << endl; return 0;}
    p = *lower_bound(is[c].begin(), is[c].end(), p) + 1;
    if (p >= n){
      p -= n;
      ans += n;
    }
  }
  ans += p;
  cout << ans << endl;
}


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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved
char block[10][10];
int main(){
    int h,w,K;
    cin>>h>>w>>K;

    rep(i,h)rep(k,w)cin>>block[i][k];

    long long second[10];   
    second[0]=1;
    rep2(i,9)second[i]=second[i-1]*2;

    long long ans=0;
    for(int i=0;i<(1<<h);i++){
        for(int k=0;k<(1<<w);k++){
            bool tate[10];
            rep(l,h)tate[l]=second[l]&i;

            bool yoko[10];
            rep(u,w)yoko[u]=second[u]&k;

            int now=0;
            rep(l,h)rep(j,w){
                if(tate[l]|yoko[j]){
                    continue;
                }
                if(block[l][j]=='#')now++;
            }

            if(now==K){
                ans++;
                //cout<<i<<" "<<k<<endl;
            }
        }
    }

    cout<<ans<<endl;
    
    return 0;

}
/*


*/


Measured memory_bytes: 3620
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define PII         pair<int, int>
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    string o, e;
    cin >> o >> e;
    int i, j;
    for(i = 0, j = 0; i < SZ(o) && j < SZ(e); i++, j++){
        cout << o[i] << e[j];
    }
    if(i < SZ(o)) cout << o[i];
    return 0;
}


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

int main() {

	string s,t; cin >> s >> t;
	int ns = s.size();
	int nt = t.size();
	int ans = 10000000;
	for (int i = 0; i < ns - nt + 1; i++) {
		string tmp = s.substr(i, nt);
		int tmpAns = 0;
		for (int j = 0; j < nt; j++) {
			if (tmp[j] != t[j]) {
				tmpAns++;
			}
		}
		ans = min(ans, tmpAns);
	}
	cout << ans << endl;
    return 0;
}

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

int main()
{
    int n, i;
    int cnt = 1;
    char s[200000][11];

    scanf("%d", &n);

    for (i = 0; i < n; i++) {
        scanf("%s", s[i]);
    }

    qsort(s, n, sizeof(char[11]), strcmp);

    for (i = 0; i < n-1; i++) {
        if (strcmp(s[i], s[i+1]) != 0)
            cnt++;
    }

    printf("%d\n", cnt);

    return 0;
}

Measured memory_bytes: 5708
#include <stdio.h>

int h,w,a[1000][1000],x[2000000],y[2000000];

int main(){
   int i,j,m,b,bt;
   char s[1001];
    
   scanf("%d %d",&h,&w);
   for (b=i=0;i<h;i++) {
      scanf("%s",s);
      for (j=0;j<w;j++)
         if (s[j]=='#') {
            a[i][j]=1;
            x[b]=i;y[b]=j;
            b++;
         } else
           a[i][j]=0;
   }
   for (bt=m=0;b>bt;) {
      i=x[bt];j=y[bt];bt++;
      if (i>0 && a[i-1][j]==0) {
         a[i-1][j]=a[i][j]+1;
         if (m<a[i-1][j]) m=a[i-1][j];
         x[b]=i-1;y[b]=j;b++;
      }
      if (j>0 && a[i][j-1]==0) {
         a[i][j-1]=a[i][j]+1;
         if (m<a[i][j-1]) m=a[i][j-1];
         x[b]=i;y[b]=j-1;b++;
      }
      if (i<h-1 && a[i+1][j]==0) {
         a[i+1][j]=a[i][j]+1;
         if (m<a[i+1][j]) m=a[i+1][j];
         x[b]=i+1;y[b]=j;b++;
      }
      if (j<w-1 && a[i][j+1]==0) {
         a[i][j+1]=a[i][j]+1;
         if (m<a[i][j+1]) m=a[i][j+1];
         x[b]=i;y[b]=j+1;b++;
      }
   }
   if (m>0) printf("%d\n",m-1);
   else     puts("0");
   return 0;
}


Measured memory_bytes: 14464
#include <stdio.h>
#include <math.h>
int main(){
  int N, count = 0;
  scanf("%d", &N);
  for(int n=1;n<=N;n++){
    count = 0;
    for(int x=1;x<=(int)sqrt(n)+2;x++){
      for(int y=x;y<=(int)sqrt(n)+2;y++){
        for(int z=y;z<=(int)sqrt(n)+2;z++){
      		if(x*x+y*y+z*z+x*y+y*z+z*x==n){
             	if(x==y && y==z){
                  count += 1;
                }else if((x!=y && y==z) || (x==y && y!=z) || (x==z && x!=y)){
                  count += 3;
                }else{
                  count += 6;
                }
            }
    	}
      }
    }
    printf("%d\n", count);
  }
  return 0;
}

Measured memory_bytes: 2144
#include<iostream>
#include<string>
#include <cmath>
#include <ctype.h>
#include<vector>
using namespace std;
string a, b;
int main() {
    cin >> a >> b;
    int n=a.size()+b.size();
    for(int i=0; i<n; ++i){
        if(i%2!=0) cout << b[i/2];
        if(i%2==0) cout << a[i/2];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <iomanip>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cstdlib>

using namespace std;

void roll(int target[], int idx[], int size,  bool rev){
  if(!rev){
    int tmp = target[idx[0]];
    for(int i=0;i<size-1;i++){
      target[idx[i]] = target[idx[i+1]];
    }
    target[idx[size-1]] = tmp;
  }else{
    int tmp = target[idx[size-1]];
    for(int i=size-1;i>0;i--){
      target[idx[i]] = target[idx[i-1]];
    }
    target[idx[0]] = tmp;
  }
}

bool is_match(int x[],int y[],int size){
  for(int i=0;i<size;i++){
    if(x[i] != y[i]) return false;
  }
  return true;
}

void pri(int x[], int size){
  cout << "==" << endl;
  for(int i=1;i<size;i++){
    cout << x[i] << " "; 
  }
  cout << endl;
}

int main(){

  int x[7],y[7];
  memset(x,-1,7*sizeof(int));  
  memset(y,-1,7*sizeof(int));
  for(int i=1;i<7;i++){
    cin >> x[i];
  }
  for(int i=1;i<7;i++){
    cin >> y[i];
  }


  int roll_n[] = {5,1,2,6};
  int roll_e[] = {3,1,4,6};
  int roll_side[] = {3,5,4,2};

  int size = sizeof(x)/sizeof(int);
  int size_roll = sizeof(roll_n)/sizeof(int);

  for(int i=0;i<4;i++){
    roll(x, roll_n,size_roll,false);
    ///pri(x,size);
    for(int j=0;j<4;j++){
      roll(x, roll_side,size_roll,false);
      //pri(x,size);
      if(is_match(x,y,size)){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  for(int i=0;i<4;i++){
    roll(x, roll_e,size_roll, false);
    for(int j=0;j<4;j++){
      roll(x, roll_side,size_roll, false);
      if(is_match(x,y,size)){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << endl;
}





Measured memory_bytes: 3116
#include<bits/stdc++.h>
const int MN=300000+5;
using namespace std;
typedef long long ll;
template<typename T>inline T&IN(T&in){
	in=0;char c=getchar();int f=1;
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c))in=in*10+c-'0',c=getchar();
	return in*=f;
}
int n,V;
int l[20][MN],r[20][MN];
int fr[MN],fl[MN],s[MN];ll x[MN];
void input(){
	IN(n),IN(V);
	for(int i=1;i<=n;++i)IN(x[i]);
	int k;x[0]=LLONG_MIN/10,x[n+1]=LLONG_MAX/10;
	for(k=0;V;++k,V>>=1){
		for(int i=1;i<=n;++i)l[k][i]=x[i]-x[i-1]>V?i:l[k][i-1];
		for(int i=n;i>=1;--i)r[k][i]=x[i+1]-x[i]>V?i:r[k][i+1];
	}
	for(int i=1;i<=n;++i)l[k][i]=x[i]-x[i-1]>V?i:l[k][i-1];
	for(int i=n;i>=1;--i)r[k][i]=x[i+1]-x[i]>V?i:r[k][i+1];
	for(int st=0;st<(1<<k);++st){
		fr[st]=n+1;
		for(int i=0;i<k;++i)if(st>>i&1){
			fl[st]=max(fl[st],r[i+1][fl[st^(1<<i)]+1]);
			fr[st]=min(fr[st],l[i+1][fr[st^(1<<i)]-1]);
		}
	}
	for(int st=0;st<(1<<k);++st){
		int L=l[0][fr[((1<<k)-1)^st]-1],R=r[0][fl[st]+1];
		if(L<=R)s[L]++,s[R+1]--;
	}
	for(int i=1;i<=n;++i){
		s[i]+=s[i-1];
		puts(s[i]?"Possible":"Impossible");
	}
}
int main(){
	input();
	return 0;
}

Measured memory_bytes: 53120
import java.util.Scanner;
class Main
{
    public static void main(String args[])
    {
	Scanner scan=new Scanner(System.in);
	while(true)
	    {
		int sum=0;
		int n=scan.nextInt();
		if(n==0)break;
		for(int i=0;i<n;i++)
		    {
			int x,y,h,w;
			x=scan.nextInt();
			y=scan.nextInt();
			h=scan.nextInt();
			w=scan.nextInt();
			if(x+y+h<=60)
			    {
				if(w<=2)sum+=600;
				else sum+=wcheck(w);
			    }
			else if(60<x+y+h && x+y+h<=80)
				{
				    
				    if(w<=5)sum+=800;
				    else sum+=wcheck(w);
				}
			else if(80<x+y+h && x+y+h<=100)
				    {

					if(w<=10)sum+=1000;
					else sum+=wcheck(w);
				    }
			else if(100<x+y+h && x+y+h<=120)
				    {

					if(w<=15)sum+=1200;
					else sum+=wcheck(w);
				    }
			else if(120<x+y+h && x+y+h<=140)
				    {

					if(w<=20)sum+=1400;
					else sum+=wcheck(w);
				    }
			else if(140<x+y+h && x+y+h<=160)
				    {

					if(w<=25)sum+=1600;
					
				    }
			
			
		    }
		System.out.println(sum);
	    }
    }
	private static int wcheck(int g)
	{
	    if(g<=2)
		{
		    return 600;
		}
	    else if(2<g && g<=5)
		{
		    return 800;
		}
	    else if(5<g && g<=10)
		{
		    return 1000;
		}
	    else if(10<g && g<=15)
		{
		    return 1200;
		}
	    else if(15<g && g<=20)
		{
		    return 1400;
		}
	    else if(20<g && g<=25)
		{
		    return 1600;
		}
	    return 0;
	}
    
}

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

#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define lg long long
#define db double
#define lb(x) ((x)&-(x))
#define ft first
#define sd second

#define HII cerr<<"HI"<<endl
#define LLLINE cerr<<"@@@@@@@@@@@@@@@@@@@@"<<endl

template <class _T_>
void read(_T_& d){
	d=0;int f=1;char c=getchar();
	for(;c<'0'||c>'9';c=getchar())if(c=='-')f*=-1;
	for(;c>='0'&&c<='9';c=getchar())d=d*10+c-'0';
	d*=f;
}

/************************************************/
#define MN 2000005
#define inf 0x3f3f3f3f
int n;
int nex[MN],vi[MN],wi[MN],fr[MN],tot=0;
void _add(int x,int y,int z){
	nex[++tot]=fr[x];fr[x]=tot;vi[tot]=y;wi[tot]=z;
}
void add(int x,int y,int z){
	_add(x,y,z);_add(y,x,0);
}
int c[MN];
int cur[MN],d[MN];
int u[MN];
int s,t;
vector<int> z[MN/20+1];
#define rev(i) (((i-1)^1)+1)
bool init(){
	queue<int> Q;
	memset(d,0,sizeof d);
	d[s]=1;Q.push(s);
	while(!Q.empty()){
		int x=Q.front();Q.pop();
		cur[x]=fr[x];
		for(int i=fr[x];i;i=nex[i])if(wi[i]&&!d[vi[i]]){
			d[vi[i]]=d[x]+1;Q.push(vi[i]);
		}
	}
	return d[t]!=0;
}
int wow(int x,int f){
	if(x==t||f==0)return f;
	int fl=0,ff;
	for(int& i=cur[x];i;i=nex[i]){
		if(d[vi[i]]==d[x]+1&&(ff=wow(vi[i],min(f,wi[i])))>0){
				fl+=ff;wi[i]-=ff;wi[rev(i)]+=ff;f-=ff;
				if(!f)break;
		}
	}return fl;
}
int resl[MN],resr[MN];
int main(){
	read(n);
	s=n+n;t=s+1;
	for(int i=1;i<=n;++i)add(i,t,1);
	for(int i=1,x,t;i<n;++i){
		read(t);add(s,i+n,1);
		while(t--)read(x),add(n+i,x,1),z[x].pb(i);
	}
	int res=0;;
	for(int i=1;i<=t;++i)cur[i]=fr[i];
	while(init())res+=wow(s,inf);
	if(res<n-1)return puts("-1"),0;
	int K=0;
	for(int x=1;x<=n;++x){
		for(int i=fr[x];i;i=nex[i]){
			if(wi[i]==1&&vi[i]>n&&vi[i]<n+n&&!c[vi[i]-n]){
				c[vi[i]-n]=x;goto Ass;
			}
		}K=x;Ass:;
	}res=0;
	queue<pii> Q;
	for(auto x:z[K])Q.push(mp(K,x));
	memset(u,0,sizeof u);
	while(!Q.empty()){
		int x=Q.front().ft,y=Q.front().sd;Q.pop();
		if(x==c[y]||u[y])continue;u[y]=x;y=c[y];++res;
		for(auto b:z[y])Q.push(mp(y,b));
	}
	if(res!=n-1)return puts("-1"),0;
	for(int i=1;i<n;++i)printf("%d %d\n",u[i],c[i]);
	return 0;
}


Measured memory_bytes: 48632
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int value1,value2;
		int i = 0;

		while(true){
			value1 = scan.nextInt();
			value2 = scan.nextInt();

			if (value1 == 0 && value2 == 0)
				break;
			System.out.printf("%d %d\n", value1 < value2? value1 : value2, value1 > value2? value1 : value2);
		}
	}
}

Measured memory_bytes: 40596
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	ll d, t, s;
	cin >> d >> t >> s;
	
	if( d <= t * s ) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
  
int main()
{
  string N;
  cin >> N;
  
  for(int nn=0; nn<N.length(); )
  {
    if(N[nn]=='B')
    {   if(nn==0)
    	{	
      		N = N.substr(1);      		
    	}
     	else
        {	string Na = N.substr(0, nn-1);
         	string Nb = N.substr(nn+1);
      		N = Na + Nb;
            nn--;
        }
    }
    else
    {
      nn++;
    }
  }
  
  cout << N << endl;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<iostream>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define for(i,a,b) for(int i=a;i<b;i++)
#define sort(a,b) sort(a.begin(),b.end())
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
//(string-'0') 文字列を数字に変換
//vector<vector<int>> data(a,vector<b>(b)) a×b行列
//for(int i=0;i<a;i++)
//for(int j=0;j<b;j++)
//cin>>data.at(i).at(j);a×b行列の入力
 
int main() {
  ll a,b;
  ci(a>>b);
  a=pow(100,a);
  if(b!=100)
    co(b*a);
  else
    co((b+1)*a);
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int A, B; cin >> A >> B;
  cout << max({A+B, A-B, A*B}) << endl;
  return 0;
}

Measured memory_bytes: 3168
#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 m0(x) memset(x,0,sizeof(x))
typedef long long ll;
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); 
    int L;
    cin >> L;
    double len = (double)L/3;
    cout << setprecision(12) << (double)(len * len * len);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vpint> vvpint;
typedef vector<vpll> vvpll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<string>> vvstring;
typedef vector<vector<bool>> vvbool;

typedef vector<vector<vector<ll>>> vvvll;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================





int main() {

	////==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	////==================================



	ll a, b;
	cin >> a >> b;

	if (a + b == 15)
	{
		cout << '+' << endl;
	}
	else if (a * b == 15)
	{
		cout << '*' << endl;
	}
	else
	{
		cout << 'x' << endl;
	}


}





Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <bitset>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int N, ans=0;
  std::cin >> N;
  std::vector<int> P(N);
  range(i, N) std::cin >> P[i];
  std::vector<int> count(N+1, 0);
  for(int i=0;i<N;i++){
    if(count[P[i]-1]>0) count[P[i]] = count[P[i]-1]+1;
    else count[P[i]]++;
    //std::cout << count[P[i]] << '\n';
    ans = max(ans, count[P[i]]);
  }
  std::cout << N - ans << '\n';
  return 0;
}


Measured memory_bytes: 2424
#include <stdio.h>

int main(void){
  long long int n, k, a, count, i, ans=0;
  long long int b[100001]={0};

  scanf("%lld %lld", &n, &k);

  while(n--){
    scanf("%lld %lld", &a, &count);
    b[a]+=count;
  }

  for(i=1;i<100001;i++){
    ans+=b[i];
    if(k<=ans){
      printf("%lld\n", i);
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
//#define int ll
#define INF INT_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[100100];

int main() {
  int a, b; cin >> a >> b;
  if (b % a == 0) {
    cout << a + b << endl;
  } else {
    cout << b - a << endl;
  }
}


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

int main(){
  int k,n;
  cin >> k >> n;
  int a[n];
  int d=0;
  for(int i=0;i<n;i++){
   cin >> a[i]; 
    if(i>0&&d<a[i]-a[i-1]){
      d = a[i] - a[i-1];
    }
  }
  if(d<k + a[0] - a[n-1]) d = k + a[0] - a[n-1];
  cout << k-d << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int r, c;
  cin >> r >> c;
  int a[r][c];
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      cin >> a[i][j];
    }
  }
  int sum = 0;
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c + 1; j++) {
      if (j == c) {
        int s = 0;
        for (int k = 0; k < c; k++) {
          s += a[i][k];
          sum += a[i][k];
        }
        cout << s << endl;
      }
      else {
        cout << a[i][j] << ' ';
      }
    }
  }
  for (int i = 0; i < c; i++) {
    int s = 0;
    for (int j = 0; j < r; j++) {
      s += a[j][i];
    }
    cout << s << ' ';
  }
  cout << sum << endl;
}



Measured memory_bytes: 3092
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <complex>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,-1,0,1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
    if(a>b){
        a = b; return true;
    }
    else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
    if(a<b){
        a = b; return true;
    }
    else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
    cout << a << " " << b << " " << c << "\n";
}
const ll mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
    ll n; cin >> n;
    vpl a(n);
    vl b(n);
    ll N = n * n;
    vl ans(N);
    set<ll> se;
    rep(i,N) se.insert(i);
    rep(i,n){
        cin >> a[i].first; a[i].first--;
        a[i].second = i;
        ans[a[i].first] = i+1;
        se.erase(a[i].first);
        b[i] = a[i].first;
    }
    sort(all(a));
    vl rest;
    rep(i,n){
        rep(j,a[i].second){
            auto itr = se.begin();
            if(*itr > a[i].first){
                puts("No");
                return 0;
            }
            ans[*itr] = a[i].second + 1;
            se.erase(itr);
        }
        rep(j,n-1-a[i].second){
            rest.push_back(a[i].second+1);
        }
    }
    for(auto i : rest){
        auto itr = se.upper_bound(b[i-1]);
        if(itr == se.end()){
            puts("No");
            return 0;
        }
        ans[*itr] = i;
        se.erase(itr);
    }
    puts("Yes");
    print(ans);
}

Measured memory_bytes: 17884
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;


int main() {
	int N;
	int P[11];
	cin >>N;
	for (int i = 0; i < N; i++) {
		cin >> P[i];
	}
	int max;
	int out;
	max = P[0];
	out = P[0];
	for (int i = 1; i < N; i++) {
		out = out + P[i];
		if (P[i] > max) {
			max = P[i];
		}
	}
	cout << out - int(max / 2);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a[3],k;
	cin>>a[0]>>a[1]>>a[2]>>k;
	int max=0;
	for(int i=0;i<3;i++){
		if(a[i]>a[max]){
			max=i;
		}
	}
	for(int i=0;i<k;i++){
		a[max]*=2;
	}
	int sum=0;
	for(int i=0;i<3;i++){
		sum+=a[i];
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
let () =
  Scanf.scanf "%d %d\n" @@ fun n k ->
  let hrr = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun d -> d in
  let () = Array.fast_sort (fun x y -> y-x) hrr in
  let all = Array.fold_left (+) 0 hrr in
  let sum = ref 0 in
  if n > k then
    for i = 0 to k - 1 do
      sum := !sum + hrr.(i)
    done;
  Printf.printf "%d\n" (if n <= k then 0 else all - !sum)


Measured memory_bytes: 8248
#include <iostream>
#include <string>

using namespace std;

auto main() -> int {
  int n, h;
  string s;

  for (;;) {
    cin >> s;

    if (s == "-") {
      break;
    }

    cin >> n;

    while (n --> 0) {
      cin >> h;
      s = s.substr(h) + s.substr(0, h);
    }

    cout << s << endl;
  }

  return 0;
}

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

using namespace std;

# define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, int> pdi;
typedef pair<ll, ll> pll;

# define S second
# define F first
# define kill(x) return(cout << x << endl, 0)
# define debug(x) cerr<< #x << " : " << x << endl
# define ddebug(x, y) cerr<< #x << " : " << x  << ", " << #y << " : " << y << endl
# define sz(s) (int)s.size()
# define sq(x) (x) * (x)
# define PB(x) push_back(x)
# define smax(x, y) (x) = max((x), (y))
# define smin(x, y) (x) = min((x), (y))
# define all(x) x.begin(), x.end()
# define SP fixed << setprecision(10)

const int MAXN = 100 * 1000 + 10;
int a[MAXN];

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

	int n;
	cin >> n;
	for (int i = 0; i < n; i ++)
	{
		cin >> a[i];
		if (i && a[i] == a[i - 1])
			i --, n --;
	}

	int i = 0, ans = 0;
	while (i < n)
	{
		i ++;
		if (i == n)
		{
			ans ++;
			break;
		}
		if (a[i - 1] < a[i])
		{
			ans ++;
			while (i < n && a[i - 1] < a[i])
				i ++;
		}
		else
		{
			ans ++;
			while (i < n && a[i - 1] > a[i])
				i ++;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-11;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 11100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	inline long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
char in[210000];
int main(){
	int a;scanf("%d",&a);
	scanf("%s",in);
	int ret=mod;
	int W=0;
	int R=0;
	for(int i=0;i<a;i++)if(in[i]=='R')R++;
	ret=R;
	for(int i=0;i<a;i++){
		if(in[i]=='R')R--;
		if(in[i]=='W')W++;
		ret=min(ret,max(W,R));
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 1912
S = input()
digits = list(map(int,S))
# S = S[::-1]→これが時間かかる

# i~nまでの値をmod2019したときの数
# ls = [0for i in range(2019)]
ls = [0] * 2019

# 0文字の時
ls[0] += 1

x = 0
pow10 = 1
count = 0
for i in reversed(digits):
    x += i*pow10
    x %= 2019
    count += ls[x]
    ls[x] += 1
    pow10 *= 10
    pow10 %= 2019

# for x in ls:
#     count += x*(x-1)/2

print(int(count))



Measured memory_bytes: 75852
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <math.h>
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
const ll mod = 1000000007;
ll n, m, k;
string s;
vector<int> road[2010], vec;
bool flag[2010], res;
map<P, int> mp;

ll pow(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2)
	{
		return pow(x, y - 1) * x % mod;
	}
	else
	{
		ll yyy = pow(x, y / 2);
		return yyy * yyy % mod;
	}
}

ll div(ll x)
{
	return pow(x, mod - 2);
}

int main(void)
{
	cin >> n >> m >> k;
	ll ans = 1;
	for (ll i = 1; i <= k - 2; i++)
	{
		(ans *= (n * m - i - 1)) %= mod;
		(ans *= div(i)) %= mod;
	}
	ll res = 0;
	for (ll i = 1; i < n; i++)
	{
		for (ll j = 1; j < m; j++)
		{
			(res += 2 * (i + j) * (n - i) % mod * (m - j) % mod) %= mod;
		}
	}
	for (ll i = 1; i < n; i++)
	{
		(res += m * (n - i) % mod * i % mod) %= mod;
	}
	for (ll i = 1; i < m; i++)
	{
		(res += n * (m - i) % mod * i % mod) %= mod;
	}
	cout << ans * res % mod << endl;
	int www;
	cin >> www;
}


Measured memory_bytes: 256