akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) { return std::vector<T>(n, std::forward<T>(val)); }
template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}
template<class Cond> struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  template<class T> bool operator()(T& a, const T& b) const { if(cond(a, b)) { a = b; return true; } return false; }
};
template<class Cond> chain<Cond> make_chain(Cond cond) { return chain<Cond>(cond); }

#include <vector>
#include <queue>
using i64 = long long;

/*
 * delta(V v, fn (V t))
 * index(V v) -> int
 */
template<class V, class Delta, class Index>
std::vector<i64> bfs(std::size_t N, V s, Delta delta, Index index) {
  std::vector<i64> dist(N, -1);
  std::queue<V> que;
  dist[index(s)] = 0;
  que.push(s);
  while(!que.empty()) {
    V v = que.front();
    que.pop();
    delta(v, [&](V t) {
        if(dist[index(t)] == -1) {
          dist[index(t)] = dist[index(v)] + 1;
          que.push(t);
        }
    });
  }
  return dist;
}
int main() {
  i64 N;
  cin >> N;
  vector<vector<int>> G(N);
  rep(i,0,N - 1) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  auto res = bfs(N, 0, [&](int v, auto func) { for(auto t: G[v]) func(t); }, [&](int v) { return v; });
  vector<vector<int>> vs(2);
  rep(i,0,N) {
    vs[res[i] % 2].push_back(i);
  }

  if(vs[0].size() > vs[1].size()) {
    std::swap(vs[0], vs[1]);
  }

  vector<vector<int>> nums(3);
  rep(i,1,N + 1) nums[i % 3].push_back(i);
  vector<int> ans(N);
  if(vs[0].size() <= nums[0].size()) {
    int ni = 0;
    for(auto v: vs[0]) {
      ans[v] = nums[0][ni++];
    }
    int vi = 0;
    for(int i = ni; i < nums[0].size(); i++) {
      ans[vs[1][vi++]] = nums[0][i];
    }
    for(int i = 0; i < nums[1].size(); i++) {
      ans[vs[1][vi++]] = nums[1][i];
    }
    for(int i = 0; i < nums[2].size(); i++) {
      ans[vs[1][vi++]] = nums[2][i];
    }
  }
  else {
    int vi = 0;
    for(auto n: nums[2]) {
      ans[vs[0][vi++]] = n;
    }
    int ni = 0;
    while(vi < vs[0].size()) {
      ans[vs[0][vi++]] = nums[0][ni++];
    }
    vi = 0;
    for(int i = ni; i < nums[0].size(); i++) {
      ans[vs[1][vi++]] = nums[0][i];
    }
    for(int i = 0; i < nums[1].size(); i++) {
      ans[vs[1][vi++]] = nums[1][i];
    }
  }
  rep(i,0,N) {
    cout << ans[i] << " \n"[i + 1 == N];
  }
}


Measured memory_bytes: 18036
#include <stdio.h>
int main(){
    int n;
    scanf("%d",&n);
    int h[n];
    for(int a=0;a<n;a++){
    scanf("%d",&h[a]);}
    int count,count2;
    count=0;count2=0;
    for(int b=0;b<n-1;b++){
        if(h[b]>=h[b+1]){count++;if(b==n-2){if(count>count2){count2=count;}}}
        else{if(count>count2){count2=count;}
             count=0;}
    }
    printf("%d\n",count2);
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9) + 7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	int n; cin >> n; n *= 2;
	int l[200];
	rep(i, n) {
		cin >> l[i];
	}
	sort(l, l + n);
	int sum = 0;
	for (int i = 0; i < n; i += 2) {
		sum += l[i];
	}
	cout << sum << endl;
	return 0;
}

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

int main()
{
    long long n;
    cin >> n;

    int ans = INT_MAX;
    for(long long a=1; a*a<=n; ++a){
        if(n % a != 0)
            continue;
        long long b = n / a;
        int len = max(to_string(a).length(), to_string(b).length());
        ans = min(ans, len);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int main(){
	int n,m;
	int i,j,k;
	LL a,b,c;
	int s=0;
	cin>>a;
	for(b=2;b<1e6;b++){
		if(a==1)break;
		if(a%b)continue;
		c=0;
		while(a%b==0)a/=b,c++;
		for(j=1;c>=j;j++)c-=j;
		s+=j-1;
	}
	if(a!=1)s++;
	cout<<s<<endl;
}

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

#define MAX_N (200)

int main(int argc, char *argv[]) {
  int N, ans;
  int A[MAX_N];
  scanf("%d", &N);
  for (int i = 0; i < N; i++)
    scanf("%d", &A[i]);
  for (ans = 0; ; ans++) {
    for (int i = 0; i < N; i++) {
      if (A[i] % 2 == 0) {
        A[i] /= 2;
      } else {
        printf("%d\n", ans);
        return 0;
      }
    }
  }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int N=(1<<18)+5;
int n, a[N];
pair<int, int> f[N];
void update(pair<int, int> &a, pair<int, int> b){
    if (b.second>=a.first){
        a=b;
    }
    else if (b.first>=a.first){
        a.second=a.first;
        a.first=b.first;
    }
    else if (b.first<a.first&&b.first>=a.second){
        a.second=b.first;
    }
}
int main(){
    cin>>n;
    for (int i=0;i<(1<<n);i++) {
        scanf("%d", &a[i]);
        f[i].first=a[i];
    }
    for (int i=0;i<n;i++){
        for (int j=0;j<(1<<n);j++) {
            if (j&(1<<i)) update(f[j], f[j^(1<<i)]);
        }
    }
    int ans=0;
    for (int i=1;i<(1<<n);i++) {
        ans=max(ans, f[i].first+f[i].second);
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
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; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;


int main(){

int a,b;
cin >> a >> b;

if(a==1 and b!=1)cout << "Alice" << endl;
else if(b==1 and a!=1)cout << "Bob" << endl;
else{
if(a<b)cout << "Bob"<< endl;
else if(b<a)cout << "Alice" << endl;
else cout << "Draw" << endl;
}
return 0;

}




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


int main()
{
	int n;
	cin >> n;
	for (int i = 0; ; i++) {
		if (i*i > n) {
			cout << (i - 1)*(i - 1) << endl;
			return 0;
		}
	}
	return 0;
}

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

int main() {
    int H, W, K; cin >> H >> W >> K;
    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;

    vector<set<int>> row(H + 1), column(W + 1);
    vector<set<int>> rowb(H + 1), columnb(W + 1);
    for(int i=1; i<=H; ++i) {
       rowb[i].insert(0);
       rowb[i].insert(W + 1);
    }
    for(int j=1; j<=W; ++j) {
        columnb[j].insert(0);
        columnb[j].insert(H + 1);
    }

    for(int i=1; i<=H; ++i) {
        for(int j=1; j<=W; ++j) {
            char c; cin >> c;
            if(i == x1 && j == y1) continue;
            
            if(c == '.') {
                row[i].insert(j);
                column[j].insert(i);
            } else {
                rowb[i].insert(j);
                columnb[j].insert(i);
            }
        }
    }

    vector<vector<int>> dist(H + 1, vector<int>(W + 1, 1001001001));
    dist[x1][y1] = 0;
    queue<pair<int, int>> Q;
    Q.emplace(x1, y1);

    while(!Q.empty()) {
        auto [x, y] = Q.front();
        Q.pop();

        int ymin = *prev(rowb[x].lower_bound(y)) + 1;
        ymin = max(ymin, y - K);
        int ymax = *(rowb[x].lower_bound(y));
        ymax = min(ymax, y + K + 1);

        for(auto it = row[x].lower_bound(ymin), itend = row[x].lower_bound(ymax); it != itend; ) {
            int ny = *it;
            dist[x][ny] = dist[x][y] + 1;
            Q.emplace(x, ny);
            
            row[x].erase(ny);
            column[ny].erase(x);
            
            it = row[x].lower_bound(ymin);
            itend = row[x].lower_bound(ymax);
        }
        
        int xmin = *prev(columnb[y].lower_bound(x)) + 1;
        xmin = max(xmin, x - K);
        int xmax = *(columnb[y].lower_bound(x));
        xmax = min(xmax, x + K + 1);
        
        for(auto it = column[y].lower_bound(xmin), itend = column[y].lower_bound(xmax); it != itend; ) {
            int nx = *it;
            dist[nx][y] = dist[x][y] + 1;
            Q.emplace(nx, y);
            
            row[nx].erase(y);
            column[y].erase(nx);
            
            it = column[y].lower_bound(xmin);
            itend = column[y].lower_bound(xmax);
        }
    }

    cout << (dist[x2][y2] == 1001001001 ? -1 : dist[x2][y2]) << '\n';
}


Measured memory_bytes: 296312
#include<iostream>
#include<vector>
#define ll long long
using namespace std;
ll qpow(ll m,ll n)
{
    ll r=1;
    while(n)
    {
        if(n&1)
            r=r*m;
        m=m*m;
        n/=2;
    }
    return r;
}
int main()
{

    ll i=1,m,n;
    vector<ll>ss;
    int j=1,h=0;
    ss.push_back(1);
    cin>>m;
    while(1)
    {
        n=2*ss[h]+1;
        ss.push_back(n);
        if(i>=m)break;
        h++;
        if(i<4)i=i+qpow(2,j)+1;
        else i=i+qpow(2,j);
        j++;
    }
    if(i>m)cout<<ss[h]<<endl;
    else if(i!=1)cout<<ss[h+1]<<endl;
    else cout<<'1'<<endl;
    return 0;
}

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

int main() {
    vector<int> a(3);
    for (int i = 0; i < 3 ; i++) {
        scanf("%d", &a.at(i));
    }
    sort(a.begin(),a.end());
    for (int i = 0; i < 3 ; i++) {
        if (i != 2) {
            printf("%d ", a.at(i));
        } else {
            printf("%d\n", a.at(i));
        }
    }
}


Measured memory_bytes: 3220
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}

char f(int n){
    if(n<10)return '0'+n;
    else return 'A'+n-10;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    while(1){
        int n,m,q; cin >> n >> m >> q;
        if(n==0&&m==0&&q==0)break;
        ll sta=0;
        vector<ll> l(m,(1LL<<n)-1);
        while(q--){
            string s,t; cin >> s >> t;
            ll ss=0;
            for(int i=0;i<n;i++){
                ss|=(ll)(s[i]=='1')<<i;
            }
            sta^=ss;
            for(int i=0;i<m;i++){
                if(t[i]=='1'){
                    l[i]&=sta;
                }
                else{
                    l[i]&=(~sta);
                }
            }
        }
        for(int i=0;i<m;i++){
            if(__builtin_popcountll(l[i])==1){
                int res=0;
                while((1LL<<res)<l[i])res++;
                printf("%c",f(res));
            }
            else{
                printf("?");
            }
        }
        printf("\n");
    }
}


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

int main() {
    int a,b; cin >> a >> b;
    if(a > 0) cout << "Positive" << endl;
    else if(a<=0 && b>=0) cout << "Zero" << endl;
    else {
        if((a-b+1)%2==0) cout << "Positive" << endl;
        else cout << "Negative" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
typedef long long lint;
typedef unsigned int uint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef unsigned long long ulint;
#define endl '\n'
#define fst first
#define sed second
#define pb push_back
#define mp make_pair
#define rint register int
#define newline putchar('\n')
#define leave_space putchar(' ')
#define all(x) (x).begin(), (x).end()
#define reveal(x) cerr << #x << " = " << (x) << endl
#define rep(it, f, e) for (rint it = (f); it <= (e); ++it)
#define per(it, f, e) for (rint it = (f); it >= (e); --it)
int ary[2048];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	int n, a, b;
	cin >> n >> a >> b;
	rep (i, 1, n) {
		cin >> ary[i];
	}
	int ans = abs(b - ary[n]);
	if (n > 1) ans = max(ans, abs(ary[n] - ary[n - 1]));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include<math.h>


int main()
{
	std::string  n;
	
	int a;
	std::cin >> a;
	std::cin >> n;
	for (int i = 0; i < a / 2; i++) {
		int b = (i + a / 2);
		if (n[i]==n[(b)])
		{

		}
		else
		{
			std::cout << "No" << std::endl;
			return 0;
		}
		
	}
	if (a%2 == 0)
	{
		std::cout << "Yes" << std::endl;
	}
	else
	{
		std::cout << "No" << std::endl;
	}
	

	
}

Measured memory_bytes: 256
def main():
  N=int(input())
  h=list(map(int,input().split()))
  DP=[0]*N
  DP[1]=abs(h[1]-h[0])
  for i in range(2,N):
    # from 2step before
    pre_2=DP[i-2] + abs(h[i]-h[i-2])
    pre_1=DP[i-1] + abs(h[i]-h[i-1])
    DP[i]=min(pre_1,pre_2)
    pass
  print(DP[-1])

if __name__ == '__main__':
  main()



Measured memory_bytes: 20280
#include <iostream>
using namespace std;
static int ans_arr[30] = {0};
int main()
{
  int N, M;
  cin >> N >> M;
  for(int n=0; n<N; ++n)
  {
    int K;
    cin >> K;
    for(int i=0; i<K; ++i)
    {
      int A;
      cin >> A;
      ++ans_arr[A];
    }
  }
  int ans = 0;
  for(int i=1; i<=M; ++i)
  {
    if(ans_arr[i] == N) ++ans;
  }
  cout << ans << endl;
  return 0;
}


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

const int MAX = 40010;
int dp[MAX];

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

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

  int ms = 0;
  memset(dp, 0, sizeof(dp));
  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    int v = arr[i];
    for (int u = ms; u >= 0; u--) {
      if (dp[u]) {
        dp[u+v] = true;
        ms = max(ms, u+v);
      }
    }
  }

  int q; cin >> q;
  while(q--) {
    int m; cin >> m;
    cout << (dp[m]?"yes":"no") << endl;
  }

  return EXIT_SUCCESS;
}




Measured memory_bytes: 3252
import sys

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
LIST = lambda: list(map(int, INPUT().split()))

sys.setrecursionlimit(10 ** 9)


def main():
    N = INT()
    H = LIST()

    ans = 0
    border = 0
    for i in range(N-1):
        if H[i] > H[i+1]:
            ans += H[i] - border
            border = H[i+1]

    ans += H[-1] - border
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/*
 * AtCoder Beginner Contest 085 A "Already 2018"
 *   https://abc085.contest.atcoder.jp/tasks/abc085_a/
 */
public class Main {

	public static void main(String[] args) {

		InputScanner in = new InputScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		String S = in.next();

		out.println("2018" + S.substring(4, S.length()));

		in.close();
		out.close();
	}

	/*
	 * extends java.util.Scanner
	 */
	static class InputScanner {

		Scanner scanner;

		public InputScanner(InputStream inputStream) {
			this.scanner = new Scanner(inputStream);
		}

		public int nextInt() {
			return scanner.nextInt();
		}

		public long nextLong() {
			return scanner.nextLong();
		}

		public double nextDouble() {
			return scanner.nextDouble();
		}
		public String next() {
			return scanner.next();
		}

		public int[] nextIntArray(int n) {
			int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextInt();
			}
			return ret;
		}

		public int[][] nextIntArray(int h, int w) {
			int[][] ret = new int[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextInt();
				}
			}
			return ret;
		}

		public long[] nextLongArray(int n) {
			long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextLong();
			}
			return ret;
		}

		public long[][] nextlongArray(int h, int w) {
			long[][] ret = new long[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextLong();
				}
			}
			return ret;
		}

		public double[] nextDoubleArray(int n) {
			double[] ret = new double[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextDouble();
			}
			return ret;
		}

		public double[][] nextDoubleArray(int h, int w) {
			double[][] ret = new double[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextLong();
				}
			}
			return ret;
		}

		public String[] nextStringArray(int n) {
			String[] ret = new String[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.next();
			}
			return ret;
		}

		public String[] nextStringArray(String split) {
			String[] ret = scanner.next().split(split);
			return ret;
		}

		public String[][] nextStringArray(int h, int w) {
			String[][] ret = new String[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.next();
				}
			}
			return ret;
		}

		public String[][] nextStringArray(int h, String split) {
			String[][] ret = new String[h][];
			for (int i = 0; i < h; i++) {
				ret[i] = scanner.next().split(split);
			}
			return ret;
		}

		public void close() {
			scanner.close();
		}

	}

}


Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <functional>
#include <queue>
#include <complex>
using namespace std;


typedef double W;

const double EPoS = 1e-8;
const W INF = 1e10;

struct edge {
	int to;
	W cost;
};
typedef pair<W, int> P;
typedef vector<vector <edge > > Graph;

void dijkstra(int s, const Graph G, vector<W>& d) {
	priority_queue< P, vector<P>, greater<P> > que;
	fill(d.begin(), d.end(), INF);
	d[s] = 0;
	que.push(P(0, s));
	while(!que.empty()) {
		P p = que.top();
		que.pop();
		int v = p.second;
		if(d[v] < p.first) continue;
		for(int i = 0; i < G[v].size(); i++) {
			edge e = G[v][i];
			if(d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

typedef complex<double> Po;
namespace std {
	bool operator < (const Po& a, const Po& b) {
		return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
	}
}
double cross(const Po& a, const Po& b) {
	return imag(conj(a)*b);
}
double dot(const Po& a, const Po& b) {
	return real(conj(a)*b);
}

struct L : public vector<Po> {
	L(const Po &a, const Po &b) {
		push_back(a); push_back(b);
	}
};

int ccw(Po a, Po b, Po c) {
	b -= a; c -= a;
	if(cross(b, c) > 0)   return +1;       // counter clockwise
	if(cross(b, c) < 0)   return -1;       // clockwise
	if(dot(b, c) < 0)     return +2;       // c--a--b on line
	if(norm(b) < norm(c)) return -2;       // a--b--c on line
	return 0;
}

bool intersectSS(const L &s, const L &t) {
	return ccw(s[0], s[1], t[0])*ccw(s[0], s[1], t[1]) <= 0 &&
		ccw(t[0], t[1], s[0])*ccw(t[0], t[1], s[1]) <= 0;
}

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

	int na, nb;
	cin >> na >> nb;

	vector<Po> ps[2];
	for(int i = 0; i < na; i++) {
		double x, y;
		cin >> x >> y;
		ps[0].push_back(Po(x, y));
	}
	for(int i = 0; i < nb; i++) {
		double x, y;
		cin >> x >> y;
		ps[1].push_back(Po(x, y));
	}

	double ans = INF;
	for(int loop = 0; loop < 2; loop++) {
		Graph G(na);
		double sum = 0;
		sum += abs(ps[1][0] - ps[1][1]);
		L line(ps[1][0], ps[1][1]);

		for(int i = 0; i < na; i++) {
			for(int j = i + 1; j < na; j++) {
				L l1(ps[0][i], ps[0][j]);
				if(intersectSS(line, l1)) continue;
				G[i].push_back(edge{ j, abs(ps[0][i] - ps[0][j]) });
				G[j].push_back(edge{ i, abs(ps[0][i] - ps[0][j]) });
			}
		}

		vector<W> d(na);
		dijkstra(0, G, d);
		sum += d[1];
		ans = min(ans, sum);
		swap(na, nb);
		swap(ps[0], ps[1]);
	}
	if(ans == INF) {
		cout << -1 << endl;
	}
	else {
		cout << setprecision(15) << ans << endl;
	}
}

Measured memory_bytes: 33932
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
using namespace std;
int main(){
	string str;
	stack<int> s;
	while( cin >> str ){
		if( str == "+" ){
			int x = s.top();
					s.pop();
			int y = s.top();
					s.pop();
			s.push(x+y);
			//cout <<x <<" "<<y << endl;
			//cout << s.top() << endl;
		}
		else if( str=="-" ){
			int x = s.top();
					s.pop();
			int y = s.top();
					s.pop();
			s.push(y-x);
			//cout << x <<" "<< y << endl;
			//cout << s.top() << endl;
		}
		else if( str=="*" ){
			int x= s.top();
					s.pop();
			int y= s.top();
					s.pop();
			s.push(y*x);
			//cout << x <<"  " << y<< endl;
			//cout << s.top() << endl;
		}
		else if( str=="/" ){
			int x=s.top();
					s.pop();
			int y=s.top();
					s.pop();
			s.push(y/x);
			//cout <<x << " "<<y<<endl;
			//cout << s.top() << endl;
		}
		else{
			istringstream ss(str);
			int x;
			ss >> x;
			s.push(x);
		}
	}
	cout << s.top() << endl;
	return 0;
}

Measured memory_bytes: 3160
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let a=read::<i32>();
    println!("AB{}",if a>999{"D"}else{"C"})
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main(void){
    int n;
    double num=0;
    double x;
    vector<double> v;
    
    cin >> n;
    rep(i,n){
        cin >> x;
        v.push_back(x);
    }
    sort(v.begin(),v.end());
    for(int i=0;i<n-1;i++){
        if(i==0){
            num = (v[0]+v[1])/2;
        }
        else{
            num = (num+v[i+1])/2;
        }
    }
    
    cout << num <<endl;
    
    return 0;
}


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


using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 1010;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}



// Main Code
map<int, int> mps, mpt;
int main()
{
	string s, t;
	cin>>s>>t;
	rep(i, 0, s.length())
	{
		int currs = s[i];
		int currt = t[i];
		if(mps[currs] == 0 || mps[currs] == currt)
		{
			mps[currs] = currt;
		}
		else
		{
			cout<<"No"<<endl;
			return 0;
		}
		if(mpt[currt] == 0 || mpt[currt] == currs)
		{
			mpt[currt] = currs;
		}
		else 
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
}


Measured memory_bytes: 776
A,B,C=map(int,input().split())
K=int(input())
count=0
if B<=A:    
    while B<=A:
        B*=2
        count+=1
if count>K:
    print('No')
else:
    C*=2**(K-count)
    if C>B:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 9064
N  = int(input())
dict = {}
dict_shop = {}
for i in range(N):
  buf1,buf2 = input().split()
  buf3 = i+1
  dict.setdefault(buf1,[]).append(int(buf2))
  dict_shop[int(buf2)] = buf3
#print(dict)
list = sorted(dict.keys())
for str in list:
  list_buf =dict[str]
  list_buf.sort()
  list_buf.reverse()
  for i in list_buf:
    print(dict_shop[i])

Measured memory_bytes: 3060
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,w = inpl()
wei = [0] * n
val = [0] * n
for i in range(n):
    wei[i],val[i] = inpl()

dp = [[0]*(w+5) for i in range(n+5)]
for i in range(n):
    for j in range(w+1):
        if wei[i] > j:
            dp[i+1][j] = dp[i][j]
            continue
        dp[i+1][j] = max(dp[i+1][j], dp[i][j-wei[i]]+val[i], dp[i][j])
print(dp[n][w])

Measured memory_bytes: 128260
import java.util.Arrays;
import java.util.Scanner;

//冒泡排序：从最后一项到第二项，与前一项作比较，举例小于，当前项小于前一项前移
public class Main {
	public static int bubbleSort(int[] a) {
		boolean flag = true;//判断何时结束，遍历一次后没有交换，即每两个相邻元素都是前者小于后者
		int cnt = 0;
		int j = 1;//需要排序的是j的前一项
		//return 1;
		while (flag) {
			flag = false;//不交换，结束循环
			//从最后一项向第一项没排序的冒泡
			//确定顺序的数字不用排序
			for (int i = a.length - 1; i >= j; --i) {//最后一项开始，相邻的两个元素判断
				//满足条件交换
				if (a[i] < a[i - 1]) {//没有交换时结束循环
					int t = a[i];
					a[i] = a[i - 1];
					a[i - 1] = t;
					flag = true;
					cnt++;
				}
			}
			j++;
		}
		return cnt;
	}
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; ++i)
			a[i] = scan.nextInt();
		int cnt = bubbleSort(a);
		for (int i = 0; i < a.length; ++i) {
			System.out.print(a[i]);
			if (i != a.length - 1)
			System.out.print(" ");
		}
		System.out.println();
		System.out.println(cnt);
	}
}



Measured memory_bytes: 26448
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <numeric>
#include <cmath>

#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};
const int MOD = 1000000007;



int main(){
    string s,t;
    cin >> s >> t;
    int n,m;
    n = s.size();
    m = t.size();

    int ans = 10000;
    rep(i,n-m+1){
        int cnt = 0;
        rep(j,m){
            if(s[i+j] != t[j]) cnt++;
        }
        ans = min(ans,cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
typedef pair<int, pi> pii;
#define f first
#define s second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define INF (int) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int n, a[200005], b[200005], x, y;

int main() {
	fastio; cin >> n;
	FOR(i, 1, n) cin >> a[i] >> b[i];
	sort(a+1, a+n+1);
	sort(b+1, b+n+1);
	if (n % 2) x = a[(n+1)/2], y = b[(n+1)/2];
	else x = a[n/2] + a[n/2+1], y = b[n/2] + b[n/2+1];
	cout << y - x + 1;
}


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

int main(){
  string s;
  cin>>s;
  int n;
  cin>>n;

  int pu=0;
  int ka=0;

  vector<int> x(17,-1);
  vector<int> f(17,-1);
  int b=0;
  int c=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='+'){
      pu++;
      f[c]=0;
      b++;
      c++;
    }else if(s[i]=='*'){
      ka++;
      f[c]=1;
      b++;
      c++;
    }else{
      if(x[b]==-1)x[b]=0;
      x[b]*=10;
      x[b]+=s[i]-'0';
    }
  }
  int lans=x[0];
  for(int i=1;x[i]!=-1;i++){
    if(f[i-1]==0)lans+=x[i];
    if(f[i-1]==1)lans*=x[i];
  }
  //cout<<lans<<endl;

  b=0;
  c=0;
  int tmp=1;
  vector<int> tas;
  //tmp=x[0];
  for(int i=0;x[i]!=-1;i++){
    if(f[c]==0){
      tmp*=x[i];
      tas.push_back(tmp);
      //cout<<tmp<<"aaa"<<endl;
      tmp=1;
    }else{
      tmp*=x[i];
    }
    b++;
    c++;
  }
  tas.push_back(tmp);

  int mans=0;
  for(int i=0;i<tas.size();i++){
    mans+=tas[i];
    //cout<<tas[i]<<endl;
  }

  //cout<<lans<<" "<<mans<<endl;

  if(n!=lans&&n!=mans){
    cout<<"I"<<endl;
    return 0;
  }

  if(lans==mans){
    cout<<"U"<<endl;
    return 0;
  }

  if(n==mans){
    cout<<"M"<<endl;
    return 0;
  }

  if(n==lans){
    cout<<"L"<<endl;
    return 0;
  }

  return 0;

}

Measured memory_bytes: 3172
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>
#include <cstdint>
#include <cctype>
#include  <cstdio>
#include  <sstream>
#include  <bitset>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using ld = long double;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vd = vector<double>;
using Vld = vector<long double>;
using Vll = vector<vector<ll> >;
using Vldd = vector<vector<ld> >;
using Vs = vector<string>;
using Vb = vector<bool>;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Pli = pair<ll, int>;
using VPi = vector<Pi>;
using VPl = vector<Pl>;
using VPli = vector<Pli>;
using Ti = tuple<int, int, int>;
using Tl = tuple<ll, ll, ll>;

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; }

const int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };


int main()
{
	string s;
	cin >> s;
	if (s[0] == 'R' && s[1] == 'R' && s[2] == 'R') cout << 3 << endl;
	else if (s[0] == 'R' && s[1] == 'R') cout << 2 << endl;
	else if (s[1] == 'R' && s[2] == 'R') cout << 2 << endl;
	else if (s[0] == 'S' && s[1] == 'S' && s[2] == 'S') cout << 0 << endl;
	else cout << 1 << endl;
	return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
// #pragma GCC optimization ("O3,unroll-loops")
// #pragma GCC target ("avx,avx2,fma")
using namespace std;

int32_t main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int64_t a; cin >> a;
    cout << a + a*a + a*a*a;


    return 0;
}

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

#define ll long long

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a, b;
	cin >> a >> b;
 	if (a*b%2==0){cout << "Even" << endl;}
  	else {cout << "Odd" << endl;}
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N, T = map(int, input().split())
min = 1000
flag = False
for i in range(N):
    c, t = map(int, input().split())
    if t <= T and c <= min:
        min = c
        flag = True
if flag:
    print(min)
else:
    print("TLE")

Measured memory_bytes: 38256
#include<stdio.h>

#define INF (1<<21)

int N =100;

int main(){
    int n,i,j,k,l,p[N+1],m[N+1][N+1];
    scanf("%d",&n);
    for(i = 1;i<=n;i++){
        scanf("%d %d",&p[i-1],&p[i]);
    }

    for(i = 1;i <= n;i++) m[i][i]=0;
    for(l=2;l<=n;l++){
        for(i=1;i<=n-l+1;i++){
            j=i+l-1;
            m[i][j] = INF;
            for(k = i;k <= j - 1;k++){
                if(m[i][j] < m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j]){
                m[i][j] = m[i][j];
                }
                else if(m[i][j] > m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j]){
                m[i][j] = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];
                }

            }
        }
    }
    printf("%d\n",m[1][n]);
    return 0;
}




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

template<class T> void chmax(T &a, T b) {
    if (a < b) a = b;
}

int main() {
    int N, W;
    cin >> N >> W;
    vector<int> weight(N), value(N);
    for (int i = 0; i < N; ++i) cin >> weight[i] >> value[i];

    vector<vector<long long>> dp(N+1, vector<long long>(W+1, 0));
    for (int i = 0; i < N; ++i) {
        for (int w = 0; w <= W; ++w) {
            chmax(dp[i+1][w], dp[i][w]);
            if (w - weight[i] >= 0) {
                chmax(dp[i+1][w], dp[i][w - weight[i]] + value[i]);
            }
        }
    }
    cout << dp[N][W] << endl;
}


Measured memory_bytes: 80256
{-# LANGUAGE BangPatterns, ForeignFunctionInterface #-}
import Control.Arrow
import Control.Monad.Fix
import Data.Char (ord, isDigit)
import Data.Bits
import Data.Int
import Data.List
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import System.IO (stdin)

foreign import ccall "getchar_unlocked" cGetChar :: IO Char

-- Assume that input has non-digit symbol at the end.
readIONat :: (Bits a, Integral a) => IO a
readIONat = do
  let reader ch = fromIntegral $ ord ch - ord '0'

  !digit0 <- fix
    (\(!f) (!_) -> do
      !ch <- cGetChar
      if isDigit ch then return ch else f ch
    )
    ' '
  flip fix (return $ reader digit0) $ \(!f) (!acc) -> do
    !s <- cGetChar
    if not (isDigit s)
      then acc
      else do
        !a <- acc
        let !a' = shiftL a 1 + shiftL a 3 + reader s
        f (return a')

solve :: Int -> VU.Vector Int16 -> Int32
solve !n !hs = fst dp
 where
  -- dp[i]: minimal cost of moving from 1st to i-th place
  dp :: (Int32, Int32)
  dp = VU.foldl'
    (\(!dp1, !dp2) (!i, !v) -> if i == 0
      then (0, dp1)
      else if i == 1
        then (dp1 + abs (fromIntegral $ v - hs VU.! 0), dp1)
        else
          ( min (dp1 + abs (fromIntegral $ v - hs VU.! (i - 1)))
                (dp2 + abs (fromIntegral $ v - hs VU.! (i - 2)))
          , dp1
          )
    )
    (-1, -1)
    (VU.indexed hs)

main = do
  n  <- readIONat
  hs <- VU.replicateM n readIONat
  print $ solve n hs


Measured memory_bytes: 1148
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	int N;
	List<Integer> list;
	int result = 0;

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		N = Integer.parseInt(in.readLine());
		this.list = new ArrayList<>();
		list.add(1);
		for (int i = 6; i <= N; i *= 6) {
			list.add(i);
		}
		for (int i = 9; i <= N; i *= 9) {
			list.add(i);
		}
		Collections.sort(list, new Comparator<Integer>() {
			@Override
			public int compare(Integer o1, Integer o2) {
				return -1 * Integer.compare(o1, o2);
			}
		});
	}

	void calc() {
		result = N;
		for (int i = 0; i < 6; ++i) {
			result = Math.min(result, i + getTimes(N - i, list));
		}
	}

	int getTimes(int val, List<Integer> list) {
		if (list.size() == 1) {
			// 最後の要素は1のはず
			return val;
		}
		int top = list.get(0);
		if (top > val) {
			return getTimes(val, list.subList(1, list.size()));
		}
		int result = val / top + getTimes(val % top, list.subList(1, list.size()));
		if (val >= top * 2) {
			result = Math.min(result, val / top - 1 + getTimes(val % top + top, list.subList(1, list.size())));
		}
		result = Math.min(result, getTimes(val, list.subList(1, list.size())));
		return result;
	}

	void showResult() {
		System.out.println(result);
	}
}


Measured memory_bytes: 27476
'use strict'

function main(s) {
  s = s.split('\n')[0].split(' ').map(n => Number(n));
  
  const K = s[0];
  const S = s[1];
  let counter = 0;

  for (let x = 0; x <= K; x++) {
    for (let y = 0; y <= K; y++) {
      const z = S - x - y;
      if (z < 0 || z > K) continue;
      
      if ((x + y + z) === S) {
        counter += 1;
      }
    }
  }

  console.log(counter);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include<stdio.h>

int main ()
{
  int a[101][101];
  int num;
  int n, k, v;
  int i, j;
  
  scanf("%d", &n);
  
  for(i = 0; i < n; i++)
    {      
      scanf("%d%d", &num, &k);
      
      for(j = 0; j <= n; j++)
	{
	  a[num][j] = 0;
	}
      
      
      for(j = 0; j < k; j++)
	{
	  scanf("%d", &v);
	  a[num][v] = 1;
	}
    }

  for(i = 1; i <= n; i++)
    {
      for(j = 1; j < n; j++)
	{
	  printf("%d ", a[i][j]);
	}
      printf("%d\n", a[i][j]);
    }
    
  return 0;
}



Measured memory_bytes: 2128
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <limits>
#include <string>
#include <bitset>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n); i > 0; i--)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define mp(x, y) make_pair((x), (y))
using namespace std;
using lint = long long;
using P = pair<int, int>;
using V = vector<int>;
constexpr int MOD = 1e9 + 7;

int A, B, C, F, H, I, J, K, L, M, N, S, T, U, W, X, Y;
// lint A, B, F, H, I, J, K, L, M, N, S, T, U, W, X, Y;
// string A, B;
// int ans;
// string ans;

int gcd(int a, int b) {
    if (max(a,b) % min(a,b) == 0) {
        return min(a,b);
    } else {
        return gcd(min(a,b), max(a,b) % min(a,b));
    }
}

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

	cin >> N;
    V nums(N);
	rep(i, N) {
        cin >> nums[i];
    }

    A = nums[0];
    rep1(i, N - 1) {
        A = gcd(A, nums[i]);
    }

    rep1(i, A) {
        if (A % i == 0) {
            cout << i << endl;
        }
    }

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


Measured memory_bytes: 3148
s = 0   # プールの合計面積

# a は a[i] に i 番目の \ の初期位置からの距離を入れるためのスタック
# b は b[i] に i 番目のプールの左岸（\）の初期位置からの距離を入れるためのスタック
# d は d[i] に i 番目のプールの面積を入れるためのスタック
a = []
b = []
d = []

for i, x in enumerate(input()):
    if x == '\\':
        a.append(i)
    elif x == '/' and a:
        j = a.pop()
        c = i - j
        s += c
        while b and b[-1] > j:
            b.pop()
            c += d.pop()
        b.append(j)
        d.append(c)
print(s)
print(len(b), *d)


Measured memory_bytes: 6380
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
using namespace std;
#define INF 1010101010
#define MOD 1000000007
#define LL long long

LL f(LL x, LL d) {
    if (x == -1) return 0;
    return x / d + 1;
}
int main() {
    LL a, b, x;
    cin >> a >> b >> x;
    cout << f(b, x) - f(a-1, x) << endl;
}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-

N = int(input())

A = list(map(int, input().split()))

A_sort = sorted(A)
sum_num = A_sort.pop(-1)

i = 2
while i + 2 <= N:
    sum_num += A_sort.pop(-1) * 2
    i += 2

if i + 1 <= N:
    sum_num += A_sort.pop(-1)

print(sum_num)



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

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll n, k;
    cin >> n >> k;
    vector<pair<ll, ll> > v(n);
    for(int i = 0; i < n; i++)
        cin >> v[i].first >> v[i].second;
    sort(v.begin(), v.end());
    vector<ll> cnt(n);
    for(int i = 0; i < n; i++)
        cnt[i] = (i == 0 ? 0 : cnt[i - 1]) + v[i].second;
    for(int i = 0; i < n; i++){
        if(cnt[i] >= k){
            cout << v[i].first << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char const *argv[]) {
  int a,b;
  cin>>a>>b;
  string s;
  cin>>s;
  bool flag=1;
  for(int i=0;i<s.size();i++){
    if(i<a||i>a){
      if(s[i]=='-'){
        flag=0;
        break;
      }
    }else{
      if(s[i]!='-'){
        flag=0;
        break;
      }
    }
  }
  if(flag){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
N, M = input().split()
N = int(N)
M = int(M)
x = []
for i in range(N):
    a, b = input().split()
    x.append((float(a), float(b)))
x = sorted(x)
ans = float(0)
for i in x:
    if M >= i[1]:
        ans += i[1] * i[0]
        M -= int(i[1])
    else:
        ans += M * i[0]
        break
print(int(ans))

Measured memory_bytes: 16164
# -*- coding: utf-8 -*-
N = int(input())

X = int(N // 1.08)
a = N*100 % 108
x = X+1
 
if a == 0:
    print(x)

elif x*1.08 >= N and x*1.08 < N+1:
    print(x)

elif X*1.08 >= N and X*1.08 < N+1:
    print(X)

else:
    print(":(")

Measured memory_bytes: 3060
#include <cstdio>
#include <bitset>

using namespace std;

char map[84];
bitset<33554432> list;

int hashit(char string[12]) {
	int key = 1;
	for (int i = 0; string[i] != '\0'; i++) {
		key = key << 2;
		key += map[string[i]];
	}
	return key;
}

int main() {
	map['A'] = 0;
	map['C'] = 1;
	map['G'] = 2;
	map['T'] = 3;

	int size = 0;
	char string[12];
	char command = '\0';

	scanf("%d%*c", &size);
	for (int i = 0; i < size; i++) {
		scanf("%c%*s", &command);
		scanf("%s%*c", &string);
		int num = hashit(string);
		if (command == 'i') {
			list[num] = true;
		} else {
			if (list[num]) {
				printf("yes\n");
			} else {
				printf("no\n");
			}
		}
	}
	return 0;
}


Measured memory_bytes: 2776
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

const long long mod = 1e9 + 7;
long long X[3] = {123, 456, 789};

vector<long long> summary(string s) {
  vector<long long> h(3);
  for (char c : s) {
    for (int i = 0; i < 3; i++) {
      h[i] = (h[i] * X[i] + c) % mod;
    }
  }
  return h;
}

vector<long long> shift(vector<long long> a, int k) {
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < k; j++) {
      a[i] = a[i] * X[i] % mod;
    }
  }
  return a;
}

vector<long long> sub(vector<long long> a, vector<long long> b) {
  for (int i = 0; i < 3; i++) {
    a[i] = (a[i] - b[i] + mod) % mod;
  }
  return a;
}

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  map<vector<long long>, int> cnt;
  for (int i = 0; i < 1 << n; i++) {
    string a, b;
    for (int j = 0; j < n; j++) {
      if (i >> j & 1) {
        a += s[j];
      } else {
        b += s[j];
      }
    }
    reverse(b.begin(), b.end());
    auto A = shift(summary(a), n - a.length());
    auto B = summary(b);
    cnt[sub(A, B)]++;
  }
  long long ans = 0;
  for (int i = 0; i < 1 << n; i++) {
    string a, b;
    for (int j = 0; j < n; j++) {
      if (i >> j & 1) {
        a += s[j + n];
      } else {
        b += s[j + n];
      }
    }
    reverse(b.begin(), b.end());
    auto A = summary(a);
    auto B = shift(summary(b), n - b.length());
    ans += cnt[sub(B, A)];
  }
  cout << ans << endl;
}

Measured memory_bytes: 57600
#include<bits/stdc++.h>
#define me(a,x) memset(a,x,sizeof(a))
#define sc scanf 
#define itn int
using namespace std;
const int N=1e6;
const long long mod=1e9+7;
const int oo=0x7fffffff;
const int sup=0x80000000;
typedef long long ll;
typedef unsigned long long ull;
template <typename it>
string to_str(it n){string s="";while(n)s+=n%10+'0',n/=10;reverse(s.begin(),s.end());return s;}
template <typename it>int o(it a){cout<<a<<endl;return 0;}
int n;
int w[N];
int sum[N]={0};
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>w[i],sum[i]=sum[i-1]+w[i];
	int ans=abs(sum[n]-2*w[1]);
	for(int t=1;t<n;t++){
		int x=abs(sum[n]-2*sum[t]);
		if(ans>x)ans=x;
	}
	o(ans);
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b; cin>>a>>b;
	int ret=0,cur=1;
	while (cur<b) cur+=a-1,ret++;
	cout<<ret<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <climits>
#include <set>
#include <deque>
#include <bitset>

#define mod 1000000007
#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOREACH(i, v) for(auto i = v.begin(); i != v.end(); i++)
#define PRINT(n) cout << n << endl

using namespace std;
using ll = long long;

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

void solve(){
    int n, a;
    cin >> n >> a;
    if( (n%500)-a <= 0 ){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

vector<P> uft;
P par(int n)
{
    if (uft[n].first == n)
    {
        return uft[n];
    }

    return uft[n] = par(uft[n].first);
}

bool unite(int x, int y)
{
    P rx = par(x);
    P ry = par(y);
    if (rx.first == ry.first)
        return false;
    uft[rx.first].first = ry.first;
    uft[rx.first].second += ry.second;
    uft[ry.first].second += rx.second;
    return true;
}

int main()
{
    int v, e, k;
    cin >> v >> e >> k;
    uft = vector<P>(v);

    vector<vector<int>> g(v, vector<int>());
    queue<P> eg;
    rep(i, e)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
        eg.push(P(a, b));
    }
    vector<vector<int>> block(v, vector<int>());
    rep(i, k)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        block[a].emplace_back(b);
        block[b].emplace_back(a);
    }

    rep(i, v) uft[i] = P(i, 1);
    while (eg.size())
    {
        P n = eg.front();
        eg.pop();
        unite(n.first, n.second);
    }

    rep(i, v)
    {
        P t = par(i);
        int cand = t.second;
        cand -= g[i].size() + 1;
        rep(j, block[i].size())
        {
            int b = block[i][j];

            if (par(b).first == par(i).first)
            {
                cand--;
            }
        }
        cout << max(0, cand) << " ";
    }

    cout << endl;

    return 0;
}

Measured memory_bytes: 14072
#include<cstdio>

int main(void){
	int n, v[20], c, ans=0, i;
	scanf("%d", &n);
	for(i=0; i<n; ++i){scanf("%d", v+i);}
	for(i=0; i<n; ++i){scanf("%d", &c); v[i]-=c; ans+=(v[i]>0)?v[i]:0;}
	printf("%d\n", ans);
	return(0);
}

Measured memory_bytes: 128