akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;
#define int long long int
//#define ll long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << " --> " << x << endl;
#define deb1a(v) cout << #v << "--->" << endl; for (auto it : v)  cout << it << " "; cout << endl;
#define deb2a(v) cout << #v << "--->" << endl;for (auto it:v){for(auto it1 : it){cout << it1 << " ";}cout<< endl;}
#define deb3a(v) cout << #v << "-->" << endl; for(auto it:v){cout << it.fi << " " << it.se << endl;}
#define mod 998244353
#define so(v) sort(v.begin(),v.end())
#define fi first
#define se second
#define db1(x) cout<<#x<<"="<<x<<endl
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<endl
int power(int x, unsigned int y, int p){ int res = 1;x = x % p;while (y > 0)  { if (y & 1)res = (res*x) % p;y = y>>1;  x = (x*x)% p;} return res;}
int mI(int a, int m)  {return power(a, m - 2, m);}
// vector<vector<int>> dir = {{1, 0}, {-1, 0}, {0, 1}, {0, -1},{1,1},{1,-1},{-1,1},{-1,-1}};
#define double long double

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    int ans = 1;
    double cc = 1e18;
    int g = 1;
    fo(i,n){
        int x;
        cin >> x;
        double xx = cc / ans;
        if(x*1.0>xx){
            g = 0;
        }
        else{
            ans *= x;
        }
    }
    if(g==1||ans==0)
        cout << ans;
    else{
        cout << -1;
    }
}


Measured memory_bytes: 3696
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
max = -1
for i in range(N):
    sum = 0
    for k in range(i+1):
        sum += A[k]
    for k in range(i,N):
        sum += B[k]
    if sum > max:
        max = sum
print(max)


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

int main(void){
	int a, b;
	scanf("%d %d", &a, &b);
	puts((a % 3 == 0 || b % 3 == 0 || (a+b) % 3 == 0) ? "Possible" : "Impossible");

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,cnt;
int fir[202020],nxt[404040],to[404040],du[202020];
void add(int x,int y)
{
	nxt[++cnt]=fir[x];fir[x]=cnt;
	to[cnt]=y;
}
bool calc(int x,int fa)
{
	int son=0;
	for(int i=fir[x];i;i=nxt[i])
	if(to[i]!=fa)
		son+=calc(to[i],x);
	if(son>1)
	{
		puts("First");
		exit(0);
	}
	return !son;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		add(x,y);add(y,x);
		du[x]++;du[y]++;
	}
	for(int i=1;i<=n;i++)
	if(du[i]>1)
	{
		if(calc(i,0)) puts("First");
		else puts("Second");
		return 0;
	}
	if(n==1) puts("First");
	else puts("Second");
	return 0;
}

Measured memory_bytes: 3712
#include <stdio.h>
#include <limits.h>
 
int main()
{
int array[5000], n, i, j, sum, max;
while (1){
scanf("%d", &n);
if (n == 0){
break;
}
         
max = INT_MIN;
         
for (i = 0; i < n; i++){
scanf("%d", &array[i]);
}
for (i = 0; i < n; i++){
sum = 0;
for (j = i; j < n; j++){
sum += array[j];
if (max < sum){
max = sum;
}
}
}
printf("%d\n", max);
}
return 0;
}

Measured memory_bytes: 620
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <array>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

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

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...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	long long n, x, m; cin >> n >> x >> m;
	map<long long, long long> ind;

	vector<long long> v;
	v.push_back(0);
	ind[0] = 0;
	v.push_back(x);
	ind[x] = 1;
	long long st = -1;

	while (true) {
		long long nxt = ((v.back() % m) * (v.back() % m)) % m;
		if (ind.find(nxt) != ind.end()) {
			debug(nxt);
			st = ind[nxt];
			break;
		}

		ind[nxt] = v.size();
		v.push_back(nxt);
	}
	debug(v.size());
	debug(v);

	debug(st);
	for (long long i = 1; i < v.size(); i++) v[i] += v[i - 1];

	if (st == 0) {
		if (n >= v.size()) cout << v.back();
		else cout << v[n];

		return 0;
	}

	long long pre = v[st - 1];

	long long sze = (long long)v.size() - st;
	long long nn = n - (st - 1);
	long long mid = (nn / sze) * (v.back() - v[st - 1]);
	long long post = 0;
	if (nn % sze > 0) {
		post += v[(nn % sze) + st - 1] - v[st - 1];
	}
	debug(pre, nn / sze, v.back(), v[st - 1], post);
	cout << pre + mid + post;

	return 0;
}

Measured memory_bytes: 6756
#include <stdio.h>

int main(){
  int i,j;
  int M, N, Q;
  int p,q;
  int LR[512][512];
  int acc;
  scanf("%d %d %d", &N, &M, &Q);
  
  for (i=0; i<M; i++){
    scanf("%d %d", &p, &q);
    LR[p-1][q-p] += 1;
  }

  for (i=N-2; 0<=i; i--){
    acc = 0;
    for (j=0; j<N-i; j++){
      acc += LR[i][j];
      LR[i][j] = acc + LR[i+1][j-1];
    }
  }
  
  for (i=0 ; i<Q; i++){
    scanf("%d %d", &p, &q);
    printf("%d\n", LR[p-1][q-p]);
  }
  return 0;
}

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

int main() {
  int k,x; cin >> k >> x;
  //k個が黒、xは黒
  //xが一番右の時：x-(k-1), ... , x
  //xが一番左の時；x, ... , x+(k-1) 
  for (int i=x-(k-1); i<=x+(k-1); i++){
    cout << i;
    if (i != x+k-1) cout << " ";
  }
  cout << endl;
}

Measured memory_bytes: 256
@cache = {}
def c(n)
  return %w[357 375 537 573 735 753] if n == 3
  @cache[n] ||= n.times.map { |i| %w[3 5 7].map { |x| c(n - 1).map { |y| y.dup.insert(i, x) } } }.flatten.uniq
end

N = gets.chomp.to_i
count = 0
(3..(N.to_s.size)).each do |size|
  count += c(size).reject { |x| x.to_i > N }.size
end
puts count

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

int n, h[100001], cost[100001];

int main() {
	cin >> n;
    for (int i=1; i<=n; i++) {
      cin >> h[i];
    }
    cost[1] = 0;
    cost[2] = abs(h[2]-h[1]);
    for (int i=3; i<=n; i++) {
      cost[i] = min(cost[i-2]+abs(h[i]-h[i-2]), cost[i-1]+abs(h[i]-h[i-1]));
    }
    cout << cost[n] << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include<set>
#include<vector>
#include<cstdio>
#include<cassert>
#include<iostream>
#include<algorithm>
using namespace std;
int n;
const int N = 60000;
bool f[N];
vector<int> p;
#define i64 long long int
i64 a[1002][1002];
void init(){
	for(int i=2; i<N; i++){
		if(!f[i])p.push_back(i);
		for(auto y : p){
			int x = y * i;
			if(x>=N)break;
			f[x] = true;
			if(i%y==0)break;
		}
	}
	reverse(p.begin(), p.end());
	p.resize(5002);
}
i64 gen(i64 ff,int t){
	if(ff > 0)
		return ff * p[t];
	else{
		ff = -ff;
		return ff * (ff+1) * p[t] * p[t+1] + 1;
	}
}
bool chk(i64 x,i64 y){
	if(x>y)swap(x,y);
	return y%x==1;
}
set<i64> s;
int main(){
	init();
	scanf("%d",&n);
	for (int i = 2, ff = 1; i <= 2 * n; i++) {
		int mid = labs(ff) + 2501;
		for (int x = 1; x < i; x++) {
			a[x][i - x] = gen(ff, mid);
			mid--;
		}
		if (ff > 0) ff = -ff;else
			ff = -ff + 1;
	}
	ios::sync_with_stdio(false);
	for(int i=1; i<=n; i++)
	for(int j=1; j<=n; j++){
		s.insert(a[i][j]);
		if(i<n)assert(chk(a[i][j], a[i+1][j]));
		if(j<n)assert(chk(a[i][j],a[i][j+1]));
		cout << a[i][j] << (j < n ? ' ' : '\n');
	}
	assert(s.size() == n*n);
	return 0;
}


Measured memory_bytes: 22144
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(V) V.begin(), V.end()
#define PB push_back
using namespace std;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    if(n % 1000 == 0) cout << 0 <<endl;
    else cout << 1000-(n % 1000) <<endl;
}

Measured memory_bytes: 3620
#include <cstdio>

typedef long long ll;
int main()
{
	ll a, b; scanf("%lld%lld", &a, &b);
	if (a == b) return !printf("1\n");
	ll c = a ^ b;
	int r = 63 - __builtin_clzll(c);
	ll T = 1ll << r, A = a & (T - 1), B = b & (T * 2 - 1);
	int k = 63 - __builtin_clzll(B ^ (1ll << r));
	if (B == 1ll << r) k = -1;
//	printf("%d %d\n", r, k);
	
//	printf("%lld %lld %lld\n", A, B, T);
	ll ans = 0;
	ans += T - A;
	ll la = T, ra = T + (1ll << (k + 1)) - 1;
	ll lb = T + A, rb = 2 * T - 1;
	if (lb <= ra) ans -= ra - lb + 1;
	ans += ra - la + 1;
	ans += rb - lb + 1;
	
//	printf("%lld %lld\n%lld %lld\n", la, ra, lb, rb);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define mem(ar,num) memset(ar,num,sizeof(ar))
#define me(ar) memset(ar,0,sizeof(ar))
#define lowbit(x) (x&(-x))
#define Pb push_back
#define  FI first
#define  SE second
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define IOS ios::sync_with_stdio(false)
#define DEBUG cout<<endl<<"DEBUG"<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int    prime = 999983;
const int    INF = 0x7FFFFFFF;
const LL     INFF = 0x7FFFFFFFFFFFFFFF;
const double pi = acos(-1.0);
const double inf = 1e18;
const double eps = 1e-6;
const LL     mod = 1e9 + 7;
LL qpow(LL a, LL b) {LL s = 1; while (b > 0) {if (b & 1)s = s * a % mod; a = a * a % mod; b >>= 1;} return s;}
LL gcd(LL a, LL b) {return b ? gcd(b, a % b) : a;}
int dr[2][4] = {1, -1, 0, 0, 0, 0, -1, 1};
typedef pair<int, int> P;
const int maxn = 1000 + 10;
// int A[maxn];
int A[maxn][maxn];
int num[maxn];

int main(void)
{
	LL n; cin >> n;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j < n; ++j)
			cin >> A[i][j];
		num[i] = 1;
	}
	int ans = 0;
	set<P> s;
	vector<int> vec;
	for (int i = 1; i <= n; ++i)
		vec.Pb(i);
	int cnt = 0, cnt2 = -1;
	while (cnt < n * (n - 1) / 2) {
		ans++;
		if (cnt == cnt2) {
			return 0 * puts("-1");
		}
		cnt2 = cnt;
		vector<int> vec2;
		for (auto i : vec) {
			// cout << i << endl;
			if (num[i] >= n) continue;
			int to = A[i][num[i]];
			if (s.find(P(to, i)) != s.end()) {
				num[i]++;
				num[to]++;
				vec2.Pb(i);
				vec2.Pb(to);
				s.erase(P(to, i));
				cnt++;
			}
			else
				s.insert(P(i, to));
		}
		vec = vec2;
	}
	cout << ans << endl;


	return 0;

}
//*


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

long long ceiling(long long a, long long b) {
    if (a <= 0) {
        return 0;
    }
    return (a - 1) / b + 1;
}

int main() {
    long long n, k;
    cin >> n >> k;
    int a[n], f[n];
    for (long long i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a, a + n);
    for (long long i = 0; i < n; i++) {
        cin >> f[i];
    }
    sort(f, f + n, greater<int>());
    long long begin = 0, end = 0;
    for (long long i = 0; i < n; i++) {
        end = max(end, 1ll * a[i] * f[i]);
    }
    while (begin < end) {
        long long count = 0, mid = (begin + end) / 2;
        for (long long i = 0; i < n; i++) {
            count += ceiling(1ll * a[i] * f[i] - mid, f[i]);
        }
        if (count <= k) {
            end = mid;
        } else {
            begin = mid + 1;
        }
    }
    cout << begin;
    return 0;
}


Measured memory_bytes: 1792
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.io.UncheckedIOException;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.util.OptionalInt;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        LightScanner in = new LightScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BTravelingAtCoDeerProblem solver = new BTravelingAtCoDeerProblem();
        solver.solve(1, in, out);
        out.close();
    }

    static class BTravelingAtCoDeerProblem {
        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            int n = in.ints();
            int[] a = in.ints(n);
            out.println(Arrays.stream(a).max().getAsInt() - Arrays.stream(a).min().getAsInt());
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public String string() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ints() {
            return Integer.parseInt(string());
        }

        public int[] ints(int length) {
            return IntStream.range(0, length).map(x -> ints()).toArray();
        }

    }
}



Measured memory_bytes: 25940
import java.util.Scanner;

public class Main {
    static int ans = Integer.MIN_VALUE, n, m, q, a[][];

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        m = in.nextInt();
        q = in.nextInt();
        a = new int[q][4];
        for (int i = 0; i < q; i++) {
            for (int j = 0; j < 4; j++) {
                a[i][j] = in.nextInt();
            }
        }
        int[] d = new int[n];
        for (int i = 1; i <= m; i++) {
            d[0] = i;
            pl(d, 1);
        }
        System.out.println(ans);
    }

    static void pl(int[] d, int i) {
        if (i == n) {
            int ansx = 0;
            for (int k = 0; k < q; k++) {
                if (d[a[k][1] - 1] - d[a[k][0] - 1] == a[k][2])
                    ansx += a[k][3];
            }
            ans = Math.max(ansx, ans);
        } else {
            for (int k = d[i - 1]; k <= m; k++) {
                d[i] = k;
                pl(d, i + 1);
            }
        }
    }

}


Measured memory_bytes: 27816
(defun f (lst acc)
  (if (and lst (cdr lst))
      (let ((head (car lst))
            (rest (cdr lst)))
        (if (= head (car rest))
            (f (cdr rest) (cons head acc))
            (f rest acc)))
      acc))

(let* ((n (read))
       (a (sort (loop repeat n collect (read)) #'<))
       (b (f a nil)))
  (princ (if (< (length b) 2)
             0
             (* (first b) (second b))))
  (terpri))


Measured memory_bytes: 69224
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut iter = s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; }
macro_rules ! input_inner { ( $ iter : expr ) => { } ; ( $ iter : expr , ) => { } ; ( $ iter : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , mut $ var : ident $ ( $ r : tt ) * ) => { let mut $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident $ ( $ r : tt ) * ) => { let $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ iter : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ iter , $ t ) ) ,* ) } ; ( $ iter : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ iter , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ iter : expr , chars ) => { read_value ! ( $ iter , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ iter : expr , usize1 ) => { read_value ! ( $ iter , usize ) - 1 } ; ( $ iter : expr , $ t : ty ) => { $ iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) } ; }
fn solve(k: usize, d: &Vec<usize>, n: usize, x: usize, m: usize) -> usize {
    let d = d.iter().map(|&a| a % m).collect::<Vec<_>>();
    let c = d.iter().filter(|&a| *a == 0).count();
    let r = (n - 1) % k;
    let s = d.iter().sum::<usize>();
    let s2 = d[0..r].iter().sum::<usize>();
    let acc = (n - 1) / k * s + x % m + s2;
    let c2 = d[0..r].iter().filter(|&a| *a == 0).count();
    n - (acc / m) - (n - 1) / k * c - c2 - 1
}
fn main() {
    input! { k, q, d: [usize; k], nxm: [(usize, usize, usize); q] };
    for i in 0..q {
        println!("{}", solve(k, &d, nxm[i].0, nxm[i].1, nxm[i].2));
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
int N, P, x;
long long ans;
char S[200005];
int m[10005];
void test() {
	std::cin >> S + 1;
	long long ans = 0;
	for (int i = 1; i <= N; ++i) {
		int x = S[i] & 15;
		if (x % P == 0) ans += i;
	}
	std::cout << ans << '\n';
}
int main() {
	std::cin >> N >> P;
	if (P == 2 || P == 5) return test(), 0;
	std::cin >> S + 1;
	m[0] = 1;
	int c = 1;
	std::reverse(S + 1, S + N + 1);
	for (int i = 1; i <= N; ++i) {
		x = x + c * (S[i] & 15), x %= P, c = c * 10 % P;
		ans += m[x]; ++m[x];
	}
	std::cout << ans << '\n';
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<Edge>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,w,h) rep(j,h)rep(i,w)
#define rrep(i,m, n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> a(n);rep(i,n)std::cin >> a[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
int main(){
    int n;
    std::cin >> n;
    int ans=0;
    rep(i,n){
        int ket=int(log10(double(i+1))+1);
        if(ket%2==1)ans++;
    }
    std::cout << ans << std::endl;
}

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

using namespace std;
int main(void)
{
    int p,q,r;
    cin >> p >> q >> r;
    std::vector<int> v;
    v.push_back(p);
    v.push_back(q);
    v.push_back(r);
    std::sort(v.begin(), v.end());

    int sum = v[0] + v[1];
    cout << sum << endl;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/dp/tasks/dp_b
#include <iostream>
#include <vector>
#include <limits>

int main()
{
    int n;
    int k;
    std::cin >> n >> k;
    std::vector<int> heights(n + 1, 0);
    std::vector<int> dp(n + 1, std::numeric_limits<int>::max());
    for (int i = 1; i <= n; ++i)
    {
        std::cin >> heights[i];
    }
    dp[1] = 0;
    dp[2] = std::abs(heights[2] - heights[1]);
    for (int i = 3; i <= n; ++i)
    {
        for (int j = i - 1; j >= 1 && j >= (i - k); --j)
        {
            dp[i] = std::min(dp[i], std::abs(heights[i] - heights[j]) + dp[j]);
        }
    }
    std::cout << dp[n] << '\n';
    return 0;
}

Measured memory_bytes: 4048
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  ll a;
  cin>>a;
  ll b=0;
  for(ll i=0;i<a;i++){
    ll c;
    cin>>c;
    b+=c;
  }
  cout<<b-a<<endl;
  return 0;
}


Measured memory_bytes: 3628
import sys
def drawable(s, i, j):
    if s[i - 1][j] == '#' or s[i + 1][j] == '#' or \
            s[i][j - 1] == '#' or s[i][j + 1] == '#':
        return True
    return False

H, W = map(int, raw_input().split())
s = [['.'] * (W + 2)]
s += [['.'] + list(raw_input()) + ['.'] for _ in range(H)]
s += [['.'] * (W + 2)]
for i in range(1, H + 1):
    for j in range(1, W + 1):
        if s[i][j] == '#' and not drawable(s, i, j):
            print 'No'
            sys.exit()
print 'Yes'


Measured memory_bytes: 7296
#include <bits/stdc++.h>
#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() {
  string s,t;
  cin >> s >>t;
  
  string ans="Yes";
  
  for(int i=0;i<s.size();i++){
    if(s[i]!=t[i]){
      ans="No";
      //break;
    }
  }
  //cout<<s<<endl;

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

Measured memory_bytes: 3628
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#include <random>
using namespace std;

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;

const int MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;
const int INF = INT_MAX / 2;

int main() {
	int x, y, z; cin >> x >> y >> z;
	cout << ((x*100 + y*10 + z) % 4 == 0 ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var s = Console.ReadLine();
            var easy = true;
            var ok = new char[] { 'U', 'D' };
            for (var i = 0; i < s.Length; i++)
            {
                if (s[i] == 'U' || s[i] == 'D') continue;

                if (i % 2 == 0)
                {
                    if (s[i] != 'R') easy = false;
                }
                else
                {
                    if (s[i] != 'L') easy = false;
                }
            }
            Console.WriteLine(easy ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;
//cout << fixed << setprecision(0)

int main() { 
  char a,b,c;cin >>a >>b>>c;
  if(a!=c){
    cout << "No" << endl;
  }else{
    cout << "Yes" <<endl;
  }
}


Measured memory_bytes: 256
//  atcodder.xcode
//  main.cpp
//  Created by conan1024hao on 2019/11/11.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリ
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define PI acos(-1.0)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------
ll L[300000],R[300000],cnt;
vector<ll>a(500000);
void merge(int n,int l,int m,int r){
    int n1=m-l;
    int n2=r-m;
    for(int i=0;i<n1;i++){
        L[i]=a[l+i];
    }
    for(int i=0;i<n2;i++){
        R[i]=a[m+i];
    }
    L[n1]=INF;
    R[n2]=INF;
    int i=0;
    int j=0;
    for(int k=l;k<r;k++){
        cnt++;
        if(L[i]<=R[j]){
            a[k]=L[i++];
        }
        else{
            a[k]=R[j++];
        }
    }
}
void mergesort(int n,int l,int r){
    if(l+1<r){
        int m=(l+r)/2;
        mergesort(n,l,m);
        mergesort(n, m, r);
        merge(n,l,m,r);
    }
}
//---------------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    mergesort(n,0,n);
    for(int i=0;i<n;i++){
        if(i)cout<<" ";
        cout<<a[i];
    }
    cout<<endl;
    cout<<cnt<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------



Measured memory_bytes: 10672
#include <iostream>
    #include <algorithm>
    #include <vector>
    #include <string>
    #include <numeric>
    using namespace std;
     
    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
n = int(input())
a = list(map(int, input().split()))
sunuke = a[0]
arai = sum(a[1:])
result = abs(sunuke-arai)
for el in a[1:-1]:
    sunuke += el
    arai -= el
    if abs(sunuke-arai) < result:
        result = abs(sunuke-arai)
print(result)


Measured memory_bytes: 24832
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.math;
import std.regex;

void main() {
	auto ip = readln.split.to!(int[]), N = ip[0], A = ip[1], B = ip[2];
	int r;
	foreach(i; 1..N+1) {
		auto digits = i.to!(dchar[]);
		int count;
		foreach(a; digits) {
			count += a.to!int - '0';
		}
		if(count >= A && count <= B) {
			r += i;
		}
	}
	writeln(r);
}


Measured memory_bytes: 380
parseInt(x) = parse(Int, x)
isw(x) = ifelse(x=='W', 1, 0)

function main()
	n = parseInt(readline())
	s = readline()
	t = Array{Int}(n)
	t[1] = isw(s[1])
	for i in 2:n
		t[i] = t[i-1]+isw(s[i])
	end
	minim = n-t[n]+t[1]-1
	for i in 2:n
		minim = min(minim, t[i-1]+n-t[n]+t[i]-i)
	end
	print(minim)
end

main()

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

int main(){

  int l, a, b, c, d;
  int p, q;

  cin >> l >> a >> b >> c >> d;
  p = a/c;
  if(a%c) p++;

  q = b/d;
  if(b%d) q++;

  cout << l-max(p,q) << endl;
}

Measured memory_bytes: 1160
import sys
import heapq
import bisect
from collections import deque
stdin=sys.stdin

ns=lambda:input().rstrip()
ni=lambda:int(input().rstrip())
nm=lambda:map(int,input().split())
nl=lambda:list(map(int,input().split()))

s=list(ns())
t=list(ns())
d={'a':0,'b':1,'c':2,'d':3,'e':4,'f':5,'g':6,'h':7,'i':8,'j':9,'k':10,'l':11,'m':12,'n':13,'o':14,'p':15,'q':16,'r':17,'s':18,'t':19,'u':20,'v':21,'w':22,'x':23,'y':24,'z':25}

order=[[] for _ in range(26)]

for i in range(len(s)):
  order[d[s[i]]].append(i)
  
now=0
ans=0
rep=0
for i in range(len(t)):
  inds=d[t[i]]
  if(order[inds]==[]):
    print(-1)
    sys.exit(0)
  index=bisect.bisect_left(order[inds],now)
  if(index==len(order[inds])):
    now=order[inds][0]+1
    rep+=1
  else:
    now=order[inds][index]+1


print(rep*len(s)+now)

Measured memory_bytes: 9308
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  vll l(n+1);
  re(i, n) std::cin >> l[i+1];
  ll p = 0;
  rep(i, 1, n+1) if(l[l[i]]==i) p++;
  std::cout << p/2 << '\n';
}


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

int main(){
	cout.precision(15);
	cout << fixed;

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

	int d = a / b;
	int r = a % b;
	double f = double(a) / double(b);

	cout << d << " " << r << " " << f << endl;
	return 0;
}


Measured memory_bytes: 3240
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

using namespace std;

int main(){
	string s,t;
	cin >>s>>t;
	vector<int> mp[26];
	rep(i,0,s.size()) mp[s[i]-'a'].push_back(i);
	int itr=0;
	ll ans=0;
	for(int i=0;i<t.size();i++){
		if(!mp[t[i]-'a'].size()){
			cout << "-1" << endl;
			return 0;
		}
		bool tmp;
		do{
			if(itr<=mp[t[i]-'a'][mp[t[i]-'a'].size()-1]){
				int idx = *lower_bound(all(mp[t[i]-'a']),itr);
				//cout << idx << endl;
				ans += idx-itr+1;
				itr = idx+1;
				tmp=true;
			}else{
				ans += s.size()-itr;
				itr=0;
				tmp = false;
			}
		}while(!tmp);
	}
	cout << ans << endl;

}


Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int n, s, a, md = 998244353;
long long dp[3005];
int main(){
	scanf("%d%d", &n, &s);
	dp[0] = 1;
	rep(i,n){
		scanf("%d", &a);
		for(int i=s; i>=0; i--) (dp[i] += dp[i] + (i>=a?dp[i-a]:0)) %= md;
	}
	printf("%lld\n", dp[s]);
}

Measured memory_bytes: 3776
/*
  author:@bhaskar_8998
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long i64;
typedef vector<i64> vi;
typedef pair<i64,i64>ii;
typedef vector<ii> vii;
typedef map<i64,i64> mi;
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define MOD 1000000007
#define ff first
#define ss second
#define deb(x) cerr<<#x<<" "<<x<<"\n";
#define fastio() {ios_base::sync_with_stdio(false);cin.tie(NULL);}

int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
    fastio();
    clock_t beg=clock();
    i64 t=1;
    // cin>>t;
    while(t--){
      int n,l;
      cin>>n>>l;
      l-=(2*n);
      if(l<0){
        cout<<"No";
        continue;
      }
      if(l%2==0 && l/2<=n){
        cout<<"Yes";
      }
      else cout<<"No";

    }
    clock_t end=clock(); 
    fprintf(stderr, "\n%lf sec\n", (double)(end-beg)/(CLOCKS_PER_SEC));
    return 0;
}


  

Measured memory_bytes: 3780
using namespace std;
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0);
#define int long long

const int N = (int)1e6+5;
int spf[N];

void sieve()
{
    for (int i=2; i<N; ++i)
        spf[i] = i;
    
    for (int i=4; i<N; i+=2)
        spf[i] = 2;
    
    for (int i=3; i*i<N; ++i)
    {
        if (spf[i]==i)
            for (int j=i*i; j<N; j+=i)
                if (spf[j]==j)
                    spf[j] = i;
    }
}

vector<int>getFacts(int argu)
{
    vector<int>res;
    while(argu!=1)
        res.push_back( spf[argu] ), argu/=spf[argu];
    return res;
}

signed main()
{
    IOS
    sieve();
    int n; cin>>n;
    int ar[n+1];
    unordered_map<int,int>freq;
    for (int i=1; i<=n; ++i)
    {
        cin>>ar[i];
        vector<int>fac = getFacts(ar[i]);
        unordered_map<int,int>temp;
        for (auto it:fac)
            temp[it] = 1;
        for (auto it:temp)
            freq[it.first]+=it.second;
            
    }
    
    bool neither = false;
    bool total = true;

    for (auto it:freq)
    {
        if (it.second==n)
            neither = true;
        if (it.second!=1)
            total = false;
    }

    if (neither)
    {
        cout<<"not coprime"<<endl;
    }

    else
        if (total)
            cout<<"pairwise coprime"<<endl;
        else
            cout<<"setwise coprime"<<endl;

    
}


Measured memory_bytes: 22060
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;

int main() {
    int h,w; cin >> h >> w;
    char a [h + 10][w + 10];
    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= w; ++j) {
            cin >> a[i][j];
        }
    }

    bool flag = true;
    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= w; ++j) {
            if (a[i][j] == '#') {
                    int count = 0;
                    if(a[i + 1][j] == '#')count++;
                    if(a[i - 1][j] == '#')count++;
                    if(a[i][j + 1] == '#')count++;
                    if(a[i][j - 1] == '#')count++;
                    if(count == 0){
                        flag = false;
                        break;
                    }
            }
        }
    }
    if(flag)print("Yes");
    else print("No");
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main{

    public static void main(String[] args) throws IOException {
        Reader.init();
        int N=Reader.nextInt();
      	int A[]=new int[N];
      	read(A, N);
      	int count=1;
      	int res=0;
      	for(int i=0;i<N;i++){
        	if(A[i]==count){
            	count++;
            }
          	else{
            	res++;
            }
        }
      	if(count==1){
        	println("-1");
        }
      	else{
        	println(res);
        }
    }

    static int mod=1000000007;
    public static void read(int arr[], int N) throws IOException{ for(int i=0;i<N;i++){ arr[i]=Reader.nextInt(); } }
    public static void read(long arr[], int N) throws IOException{ for(int i=0;i<N;i++){ arr[i]=Reader.nextLong(); } }
    public static void read(String arr[], int N) throws IOException{ for(int i=0;i<N;i++){ arr[i]=Reader.next(); } }
    public static void print(Object O){ System.out.print(O); }
    public static void println(Object O){ System.out.println(O); }
    public static void display(int arr[]){ System.out.println(Arrays.toString(arr)); }
    public static void display(int arr[][], int N){ for(int i=0;i<N;i++){ System.out.println(Arrays.toString(arr[i])); } }
  	static long gcd(long x, long y) { return y==0 ? x : gcd(y, x % y); }
    static long lcm(long x, long y) { return x*y / gcd(x, y); }
}


class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    static void init() {
        reader=new BufferedReader(new InputStreamReader(System.in));
        tokenizer=new StringTokenizer("");
    }

    static String next() throws IOException {
        while (!tokenizer.hasMoreTokens() ) {
            tokenizer=new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException { return Integer.parseInt(next()); }
    static double nextDouble() throws IOException { return Double.parseDouble(next()); }
    static long nextLong() throws IOException { return Long.parseLong(next()); }
    static String nextLine() throws IOException { return reader.readLine(); }
}

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

using namespace std;

const int MAX_N = 1e5 + 10;

int N;
vector<int> edge[MAX_N], chain, ans;

void no_solution() {
    printf("-1\n");
    exit(0);
}

void init() {
    scanf("%d", &N);
    for (int i = 1; i < N; i++) {
        int a, b; scanf("%d%d", &a, &b);
        edge[a].push_back(b); edge[b].push_back(a);
    }
    if (N == 2) {
        printf("1 2\n");
        exit(0);
    }
    int st = 0;
    for (int i = 1; i <= N; i++) {
        if (edge[i].size() == 1) continue;
        int cnt = 0;
        for (int j : edge[i]) {
            if (edge[j].size() > 1) cnt++;
        }
        if (cnt <= 1) {
            st = i;
            break;
        }
    }
    if (!st) {
        no_solution();
    }
    vector<int> chain_id;
    int x = st, y = 0;
    while (x) {
        chain_id.push_back(x);
        vector<int> candi;
        for (int i : edge[x]) {
            if (edge[i].size() > 1 && i != y) {
                candi.push_back(i);
            }
        }
        if (candi.size() > 1) {
            no_solution();
        }
        y = x;
        if (candi.empty()) x = 0;
        else x = candi[0];
    }
    int cnt = 0;
    for (int i = 1; i <= N; i++) {
        if (edge[i].size() > 1) cnt++;
    }
    if (cnt != chain_id.size())
        no_solution();
    for (int i : chain_id) {
        chain.push_back(edge[i].size() - 1);
    }
    chain.front()++;
    chain.back()++;
    for (int i = N; i; i--) ans.push_back(i);
}

void solve(vector<int> blks) {
    int n = blks.size(), curr = 0;
    vector<int> res;
    for (int i = 0; i < n; i++) {
        int siz = blks[i];
        if (i == 0) {
            res.push_back(1);
            curr = 1;
            siz--;
        }
        for (int j = 2; j <= siz - (i == n - 1); j++) {
            res.push_back(curr + j);
        }
        res.push_back(curr + 1);
        if (i == n - 1 && siz > 1) {
            res.push_back(curr + siz);
        }
        curr += siz;
    }
    ans = min(ans, res);
}

int main() {
    init();
    solve(chain);
    reverse(chain.begin(), chain.end());
    solve(chain);
    for (int i : ans)
        printf("%d ", i);
    printf("\n");
}


Measured memory_bytes: 7792
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
const  int MAX=1e4;
long long int prime[MAX]={1};
long long int pwr(int n ,int m){
	long long int res=1;
	while(n){
		if(n%2)
			res=res*m;
		m=m*m;
		n/=2;
	}
	return  res;
}
int main(){
	 long long int a  ,b ,c ,n ,i ,j ,arr[10] ,cnt[MAX]={0} ,lcm[11][MAX] ,res=1;
	cin>>n;
		for(j=2;j*j<=n;j++){
			long long int p=0 ,q=1;
		while(n%j==0){
			n/=j;
			p=1;
			q=q*j;
		}
		if(p==1)
		res=res*(q/j)*(j-1);
		//lcm[i][arr[i]]++;
	}
	if(n!=1)
		res=res*(n-1);

	cout<<res<<"\n";
}


Measured memory_bytes: 3156
def main():
    N = int(input())
    S = input()
    pre = 0
    post = 0
    for i in range(N):
        if S[i] == '(':
            post += 1
        else:
            if post >= 1:
                post -= 1
            else:
                pre += 1
    print('(' * pre + S + ')' * post)


if __name__ == "__main__":
    main()


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

int main(void) {
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> ss(h);
  for (string &c : ss) {
    cin >> c;
  }

  int result = 0;
  for (int i = 0; i < (1 << h); i++) {
    for (int j = 0; j < (1 << w); j++) {
      int count = 0;
      for (int r = 0; r < h; r++) {
        if (i & (1 << r)) {
          for (int c = 0; c < w; c++) {
            if (j & (1 << c)) {
              count += ss[r][c] == '#' ? 1 : 0; 
            }
          }
        }
      }
      if (count == k) result++;
    }
  }

  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3628
n,q = map(int,input().split())

ans = (n-2)**2
rm = n
um = n
ruse = [-1]*(n+1)
uuse = [-1]*(n+1)

for _ in range(q):
    a,x = map(int,input().split())
    if a == 1:
        if uuse[x] >= 0:
            ans -= uuse[x]-2
        else:
            dif = um - 2
            ans -= dif
            for i in range(x,n+1):
                if uuse[i] >= 0:
                    break
                uuse[i] = um
            rm = min(rm,x)
    else:
        if ruse[x] >= 0:
            ans -= ruse[x]-2
        else:
            dif = rm - 2
            ans -= dif
            for i in range(x,n+1):
                if ruse[i] >= 0:
                    break
                ruse[i] = rm
            um = min(um,x)
print(ans)

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

int main(){
  int n,k;
  cin>>n>>k;
  string s;
  cin>>s;
  
  vector<int> a;
  int res = 1;
  s[n] = (s[n-1]+1)%2;
  if(s[0]=='0') a.pb(0);
  rep(i,n){
    if(s[i]==s[i+1]){
      res++;
    }else{
      a.pb(res);
      res = 1;
    }
  }
   
  int ans = 0;
  int res2 = 0;
  int p = a.size()-2*k+1;

  rep(i,max(p,1)){
    rep(j,2*k){
      if(i+j<a.size()) res2 += a[i+j];
    }
    if(i%2==0&&i+2*k<a.size()) res2 += a[i+2*k];
    ans = max(ans,res2);
    res2 = 0;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1020
// BWOTSHEWCHB

#include <bits/stdc++.h>

using namespace std ;

#define pb push_back
#define in insert
#define X first
#define Y second

const int MAXN = 1e4 + 69 , MOD = 1e9 + 7 ; 

string s , t , ans ;
int n , m , dp[MAXN][MAXN] , path[MAXN][MAXN] ;

int32_t main() {
	ios::sync_with_stdio(false) ;
	cin.tie(0) ; cout.tie(0) ;
	cin >> s >> t ;
	n = s.size() , m = t.size() , s = ' ' + s , t = ' ' + t ;
	for ( int i = 1 ; i <= n ; i ++ )
		for ( int j = 1 ; j <= m ; j ++ ) {
			if ( s[i] == t[j] )
				dp[i][j] = dp[i - 1][j - 1] + 1 , path[i][j] = 1 ;
			else
				if ( dp[i - 1][j] > dp[i][j - 1] )
					dp[i][j] = dp[i - 1][j] , path[i][j] = 2 ;
				else
					dp[i][j] = dp[i][j - 1] , path[i][j] = 3 ;
				
		}
	int x = n , y = m ;
	while ( x > 0 and y > 0 ) {
		if ( path[x][y] == 1 )
			ans.pb(s[x]) , x -- , y -- ;
		if ( path[x][y] == 2 )
			x -- ;
		if ( path[x][y] == 3 )
			y -- ;
	}
	reverse(ans.begin() , ans.end()) ;
	cout << ans << "\n" ;
}


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

#define LL long long
typedef pair<int, int> pii;

template< typename T > inline void read(T &x)
{
    static char _c;
    static bool _f;

    x = 0;
    _f = 0;
    _c = getchar();

    while(_c < '0' || '9' < _c) {if(_c == '-') _f = true; _c = getchar();}
    while('0' <= _c && _c <= '9') {x = (x << 1) + (x << 3) + (_c & 15); _c = getchar();}
    if(_f) x = -x;
}

template < typename T > inline void Min(T &x, T y) {if(y < x) x = y;}
template < typename T > inline void Max(T &x, T y) {if(x < y) x = y;}


#define lowbit(x) ((x) & -(x))
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(l,r) ((l)+(((r)-(l))>>1))
#define fi first
#define se second
#define mk make_pair
#define pb push_back

const int INF = 0x3f3f3f3f;
const double pi = (double) acos(-1.0);
const double eps = (double) 1e-8;
//const int MOD = (int) 1e9 + 7;
const int MOD = (int) 998244353;
const int maxn = (int) 3e5 + 20;
const int maxm = (int) 1e6 + 20;

inline int sig(double x) {return x < -eps ? -1 : eps < x;}
LL fp(LL a, LL n, LL MOD)
{
    if(n < 0) a = fp(a, MOD - 2, MOD), n = -n;
    LL res = 1; for(; n; n >>= 1, a = a * a % MOD) if(n & 1) res = res * a % MOD; return res;
}

void work()
{
    int n;
    set<int> s;
    cin >>n;
    for(int i = 0; i < n; i++)
    {
        int x;
        cin >>x;
        s.insert(x);
    }

    puts(s.size() == n ? "YES" : "NO");
}


int main(int argc, char **argv)
{
#ifdef yukihana0416
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif // yukihana0416
//    get_prime();
    int tc = 1;
//    read(tc);
    for(int ca = 1; ca <= tc; ca++)
    {
//        printf("Case #%d: ", ca);
        work();
    }
    return 0;
}


Measured memory_bytes: 9600
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	a := make([]int, n)
	for i := range a {
		sc.Scan()
		a[i], _ = strconv.Atoi(sc.Text())
	}
	var i, ans, t, jt int
	for {
		if i >= n-1 {
			break
		}
		t = 0
		for j := i; j < n-1; j++ {
			jt = j + 1
			if a[j+1] <= a[j] {
				t++
			} else {
				break
			}
		}
		if t > ans {
			ans = t
		}
		i = jt
	}
	fmt.Println(ans)
}


Measured memory_bytes: 3072
import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

void main() {
    int n, m;
    scan(n, m);

    long t = 100 * (n - m) + 1900 * m;
    long ans = 2L^^m * t;

    writeln(ans);
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    int n,l,ans;
    cin >> n >> l;
    if(l>0){
        ans = (l+2-1 + l+n-1) * (n - 1) / 2;
    } else if(l+n-1<0){
        ans =(l+1-1 + l+n-2) * (n-1) / 2;
    } else {
        ans = (l+1-1 + l+n-1) * n / 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3552
// accepted submission
//

#include <atcoder/all>
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

int main() {
    int n, q;

    cin >> n >> q;

    atcoder::fenwick_tree<ll> t(n);
    for (int i = 0; i < n; i++) {
        ll x;
        cin >> x;
        t.add(i, x);
    }

    while (q--) {
        int op, x, y;
        cin >> op >> x >> y;
        if (op == 0) {
            t.add(x, y);
        } else {
            cout << t.sum(x, y) << "\n";
        }
    }

    return 0;
}

Measured memory_bytes: 8224