akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
const double inf = 1e10;

struct D {
	vector<double> l, r;
	D():l(3,inf),r(3,-inf) {}
		void add(double x , int v){
			++v;
			mins(l[v],x);
			maxs(r[v],x);
		}
		double get(double t){
			double nl = inf , nr = -inf;
			for(int i = 0 ;  i < 3 ; i++){
				mins(nl,l[i]+i*t);
				maxs(nr,r[i]+i*t);
			}
			return nr-nl;
		}
		vector<double> events(){
			vector<double> ts;
			for(int i = 0 ; i < 3 ; i++){
				for(int j = 0 ; j < i ; j++){
				{
					double t = (l[j] - l[i])/(i-j);
					if( t > 0)
						ts.push_back(t);
				}
				{
					double t = (r[j] - r[i])/(i-j);
					if( t > 0)
						ts.push_back(t);
				}
			}
		}
		return ts;
	}
};

void test_case(){
	int n; cin >> n;
	D xd , yd;
	for(int i = 0 ; i < n ; i++){
		int x,y;
		char d;
		cin >> x>> y >> d;
		if(d == 'L') xd.add(x,-1),yd.add(y,0);
		if(d == 'R') xd.add(x,1),yd.add(y,0);
		if(d == 'U') xd.add(x,0),yd.add(y,1);
		if(d == 'D') xd.add(x,0),yd.add(y,-1);
	}
	vector<double> ts;
	ts.push_back(0);
	ts.push_back(inf);
	{
		auto nts = xd.events();
		ts.insert(ts.end(),nts.begin(),nts.end());
	}
	{
		auto nts = yd.events();
		ts.insert(ts.end(),nts.begin(),nts.end());
	}
	sort(ts.begin(),ts.end());
	double ans = 1e18;
	for(double t : ts){
		double now = xd.get(t)*yd.get(t);
		mins(ans,now);
	}
	cout<<ans<<"\n";
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(10);
	int T=1;
	//~ cin >> T;
	while(T--){
		test_case();
	}
	return 0;
}


Measured memory_bytes: 3852
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define IOS                       \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);
#define mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x, y) memset(x, y, sizeof(x))
#define pb push_back
#define mk make_pair
#define pi pair<int, int>
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = a; i >= (b); --i)
using namespace std;
int dt[][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}, {0, 0}};
//typedef pair<int, int> P;
//priority_queue<int, vector<int>, greater<int> > q;

int main()
{
    IOS;
    //a*a=b*b+c*c-2bc*cosA
    double a, b, h, m;
    double pai = acos(-1);
    cin >> a >> b >> h >> m;
    h += m / 60;
    double rad = abs(h / 12 - m / 60) * 2 * pai;
    double ans = sqrt(a * a + b * b - 2 * a * b * cos(rad));
    //cout << ans << endl;
    printf("%.20f", ans);
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using  namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
 
int main() {
	string s;
	cin>>s;
	string t = "CODEFESTIVAL2016";
	int cnt = 0;
	REP(i,s.size())if(s[i]!=t[i])cnt++;
	cout<<cnt<<endl;
}

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

using namespace std;


int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	int n;
	cin >> n;
	bool is_prime;
	for (int i = n; ; ++i) {
		is_prime = true;
		for (int j = 2; j * j <= i; ++j) {
			if (i % j == 0) {
				is_prime = false;
				break;
			}
		}
		if (is_prime) {
			cout << i << '\n';
			break;
		}
	}
	return 0;
}

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

#define FIO ios_base::sync_with_stdio(0); cin.tie(0);
#define T() int tt; cin >> tt; rep1(qq,1,tt)
#define rep(i,start,lim) for(int i=start;i<lim;i++)
#define rep1(i,start,lim) for(int i=start; i<=lim; ++i)
#define repd(i,start,lim) for(int i=start;i>=lim;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define br cout<<"\n"
#define MOD (1000000007LL)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define eps (1e-6)
#define what_is(x) cerr << #x << " is " << x << "\n";
#define int long long int
#define infll 9e18
#define inf 1e12

#define lnode (2 * node + 1)
#define rnode (2 * node + 2)

using namespace std;

typedef pair<int, int> pii;

const int N = 1 * 1e5 + 2;

int n, m, x;
int c[12];
int a[12][12];

int32_t main(){

  FIO
  //cout << fixed << setprecision(10);
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);

  cin >> n >> m >> x;
  vector<vector<int>> v;
  rep(i,0,n){
    cin >> c[i];
    rep(j,0,m) cin >> a[i][j];
  }
  int res = inf;
  rep(mask,0,1<<n){
    vector<int> temp(m,0);
    int cost = 0;
    rep(i,0,n){
      if(mask & (1ll << i)){
        cost += c[i];
        rep(j,0,m) temp[j] += a[i][j];
      }
    }
    bool ok = 1;
    rep(i,0,m) ok &= (temp[i] >= x);
    if(ok) res = min(res, cost);
  }
  if(res == inf) res = -1;
  cout << res << '\n';

	return 0;
}


Measured memory_bytes: 3652
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.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
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);
        BTrained solver = new BTrained();
        solver.solve(1, in, out);
        out.close();
    }

    static class BTrained {
        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            int n = in.ints();
            int[] a = in.ints(n);
            boolean[] walked = new boolean[n + 1];
            int c = 1;
            int ans = 0;
            while (!walked[c]) {
                ans++;
                walked[c] = true;
                c = a[c - 1];
                if (c == 2) {
                    out.println(ans);
                    return;
                }
            }
            out.println(-1);
        }

    }

    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: 38228
#include <bits/stdc++.h>
using namespace std;

int main (){

    string s;
    cin >> s;
    
    for(int i = 0; i < s.size(); i++) {
        if((i+1) % 2 == 1) {
            cout << s[i];
        }
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < b; i++)
#define int long long
using namespace std;

bool cmp(pair<int, int> x, pair<int, int> y) {
    return x.second < y.second;
}

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

    vector<int> x(n), l(n);
    rep(i, 0, n) cin >> x[i] >> l[i];

    vector<pair<int, int>> vp(n);
    rep(i, 0, n) {
        vp[i].first = x[i] - l[i];
        vp[i].second = x[i] + l[i];
    }

    sort(vp.begin(), vp.end(), cmp);
    
    int cur = -1e10, ans = 0;
    rep(i, 0, n) {
        if (cur <= vp[i].first) {
            cur = vp[i].second;
            ans++;
        }
    }

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

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

int main() {
	int a, b;
	cin >> a >> b;
	if (a == b) cout << "a == b" << endl;
	else if (a < b) cout << "a < b" << endl;
	else if (a > b) cout << "a > b" << endl;
	return 0;
}


Measured memory_bytes: 3080
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
#from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
#from math import floor, ceil
#from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [LI()for i in range(n)]
#inf = 10**17
#mod = 10**9 + 7

n,q=MI()
relation=[[] for i in range(n)]
for i in range(n-1):
    a,b=MI()
    a-=1
    b-=1
    relation[a].append(b)
    relation[b].append(a)
#print(relation)

nodes=[0]*n
for i in range(q):
    p,r=MI()
    p-=1
    nodes[p]+=r

Q=deque()
Q.append([-1,0])
#print(Q.popleft())

while Q:
    s,t=Q.popleft()
    for um in relation[t]:
        if um ==s:
            continue
        nodes[um]+=nodes[t]
        Q.append([t,um])
        
print(" ".join(map(str,nodes)))
    

Measured memory_bytes: 65652
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
 
#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second
 
int main(int argc, char **argv) {
	int a, b;
	cin >> a >> b;
	cout << (a >= 13 ? b : a >= 6 ? b / 2 : 0) << endl;
	return 0;
}
 

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

void Main() {
  int H, W;
  int h, w;
  cin >> H >> W >> h >> w;
  
  cout << (H - h) * (W - w) << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;
class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int[] counter = new int[26];
        while (input.hasNext()){
            String S = input.nextLine();
            for (int i = 0; i < S.length(); i++){
                char c = S.charAt(i);
                if (Character.isUpperCase(c)){
                    c += 32;
                    counter[(int)c-97] += 1;
                } else if (Character.isLowerCase(c)){
                    counter[(int)c-97] += 1;
                }
            }
        }
        for (int i = 0; i < 26; i++){
            char c = (char)(97+i);
            System.out.printf("%s : %d\n",c,counter[i]);
        }
    }
}


Measured memory_bytes: 26236
X,Y,Z,K = map(int,input().split())
AList = list(map(int,input().split()))
BList = list(map(int,input().split()))
CList = list(map(int,input().split()))
AList.sort(reverse=True)
BList.sort(reverse=True)
CList.sort(reverse=True)
ans = []
for x in range(X):
    for y in range(Y):
        if (x+1)*(y+1) > min(K,X*Y):
            break
        for z in range(Z):
            if (x+1)*(y+1)*(z+1) > min(K,X*Y*Z):
                break
            ans.append( AList[x] + BList[y] + CList[z])

ans.sort(reverse=True)
for i in range(K):
    print(ans[i])


Measured memory_bytes: 8708
N,R,T = gets.split.map(&:to_i)

ns  = (1..N).to_a
res = (0...R).map{ f,t = gets.split.map(&:to_i); [f,t] }
tes = (0...T).map{ f,t = gets.split.map(&:to_i); [f,t] }

class UnionFind_PathCompression
  attr_reader :rank, :parent, :value
  attr_writer :rank, :parent

  def initialize(x)
    @value = x
    @rank = 0
    @parent = self
  end

  def ==(obj)
    @value == obj.value
  end

  def find
    return self if self.parent == self
    root = self.parent.find
    self.parent = root
    root
  end

  def union(y)
    xr = find; yr = y.find
    return if xr == yr
    if xr.rank >= yr.rank
      yr.parent = xr
      xr.rank += 1
    else
      y.union(self)
    end
  end
end

def minimum_spanning_tree_kruskal(nodes, edges)
  # edges: [[node_from, node_to, weight]]
  edges.sort_by!{ |e| e[2] }
  th = Hash[nodes.map{ |x| [x, UnionFind_PathCompression.new(x)] }]
  i = 0
  while i < edges.size
    e = edges[i]
    i += 1
    f,t,w = *e
    tf = th[f]; tt = th[t]
    next if (tf.find == tt.find)
    tf.union(tt)
  end
  th
end

th = Hash[ns.map{ |n| [n,{ }] }]
minimum_spanning_tree_kruskal(ns, res).each{ |x,uf| th[x][:road] = uf.find.value }
minimum_spanning_tree_kruskal(ns, tes).each{ |x,uf| th[x][:train] = uf.find.value }

ch = {}
th.each{ |x,h| t = h[:road]*N+h[:train]; ch[t] = (ch[t] || 0) + 1 }
th.keys.sort.each{ |n| h = th[n]; puts ch[h[:road]*N+h[:train]] }

Measured memory_bytes: 138720
import java.util.Scanner
import scala.util.control.Breaks

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)

    val N, K = sc.nextInt
    var h = Array.ofDim[Int](N)
    (0 until N).foreach(i => {
      h(i) = sc.nextInt
    })

    h = h.sorted
    var ans = Int.MaxValue
    (0 until N).foreach(i => {
      if (i+K-1 < N) {
        ans = Math.min(ans, h(i+K-1) - h(i))
      }
    })

    println(ans)
  }
}

Measured memory_bytes: 55348
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    int max_a;
    foreach (a; readln.split.to!(int[])) {
        if (a == max_a + 1) {
            max_a = a;
        }
    }
    writeln(max_a == 0 ? -1 : (N - max_a));
}

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

mat e(1e5+10);
ll n;
vec f(1e5+10);

ll dfs(ll u) {
  for(ll&t:e[u]) {
    dfs(t);
    t=f[t];
  }
  sort(e[u].begin(),e[u].end());
  ll i=0;
  for(ll v:e[u]) {
    f[u]=max(f[u],(ll)(e[u].size()-i+v));
    i++;
  }
}

int main() {
  cin >> n;
  vec a(n);
  for(ll i=2;i<=n;i++) {
    ll tmp;
    cin >> tmp;
    e[tmp].push_back(i);
  }
  dfs(1);
  cout << f[1] << endl;
}

Measured memory_bytes: 11904
// AOJ 2824: Coastline
// 2017.9.23 bal4u@uu
// 2017.11.24

#include <stdio.h>

int a[100000], size;

char buf[30], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int main()
{
	int t, d, l;
	int x, i, ans;

	while (fgets(p=buf, 30, stdin) && *p != '0') {
		t = getint(), p++, d = getint(), p++, l = getint();
		size = 0;
		for (i = 0; i < t; i++) {
			fgets(p=buf, 30, stdin);
			x = getint();
			if (x >= l) a[size++] = i;
		}
		t--, ans = 0;
		for (i = 1; i < size; i++) {
			x = d;
			if (a[i-1] + d > t) x = t - a[i-1];
			if (a[i] < a[i-1] + x) ans += a[i] - a[i-1];
			else ans += x;
		}
		if (size > 0) {
			ans += (a[size-1] + d > t) ? t - a[size-1] : d;
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 2052
#include <iostream>

using namespace std;

int main(){
	int p, q, r;
	cin >> p >> q >> r;

	int sum_pq = p+q;
	int sum_qr = q+r;
	int sum_rp = r+p;

	int min = 300;
	if(min > sum_pq){
		min = sum_pq;
	}
	if(min > sum_qr){
		min = sum_qr;
	}
	if(min > sum_rp){
		min = sum_rp;
	}

	cout << min << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define mod 1000000007
#define F first
#define S second
#define eb emplace_back
int main()
{
   // freopen("input.txt","r",stdin);
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    lli n,m,i,j,k;
    cin>>n>>k;
    lli dp[k+1]={},ar[k+1]={};
    for(i=0;i<n;i++)
    {
        cin>>ar[i];
        dp[ar[i]]=1;
    }
    for(i=0;i<=k;i++)
    {
        for(j=0;j<n;j++)
        if(i>=ar[j])
            if(dp[i-ar[j]]==0)
            {
                dp[i]=1;
                break;
            }
    }
    //for(i=0;i<=k;i++)
    //    cout<<dp[i]<<" ";cout<<"\n";
    if(dp[k]==1)
        cout<<"First";
    else
        cout<<"Second";
    return 0;
}


Measured memory_bytes: 1792
-- https://github.com/minoki/my-atcoder-solutions
import Data.Char (isSpace)
import Data.List (unfoldr)
import qualified Data.Vector.Unboxed as U
import qualified Data.ByteString.Char8 as BS

main = do
  [n,k] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  s <- BS.getLine
  let xs = U.generate (BS.length s) (BS.index s)
  let m = U.length $ U.filter id $ U.zipWith (==) xs (U.tail xs)
  print $ min (m + 2 * k) (n - 1)


Measured memory_bytes: 1020
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class D {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.nextInt();
            int M = in.nextInt();

            if (N == 1) {
                out.println(M);
                return;
            }

            for (int i = (M / N); i >= 1; i--) {
                if (M % i == 0) {
                    out.println(i);
                    return;
                }
            }
            out.println(1);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21588
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    h, w, n = int(input()), int(input()), int(input())
    print((n + max(h, w) - 1) // max(h, w))


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
//2017-05-06 16:50
//2017-05-06 15:04
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

const int MaxN = 2e5;
int n, pred[MaxN + 5], succ[MaxN + 5];
struct ARR {
	int x, y;
}a[MaxN + 5];

bool cmp(ARR A, ARR B) {return A.x < B.x;}
int main()
{
	while (~scanf("%d", &n)) {
		int MiN = 1 << 30;
		for (int i = 1; i <= n; i++) {
			scanf("%d%d", &a[i].x, &a[i].y);
			if (a[i].x > a[i].y) swap(a[i].x, a[i].y);
			MiN = min(MiN, a[i].y);
		}
		sort(a + 1, a + n + 1, cmp);
		pred[0] = succ[n + 1] = 0;
		for (int i = 1; i <= n; i++) pred[i] = max(pred[i - 1], a[i].y);
		for (int i = n; i >= 1; i--) succ[i] = max(succ[i + 1], a[i].y);
		long long ans = ((long long)succ[1] - MiN) * ((long long)a[n].x - a[1].x);
		int pM = 1 << 30, MaX = 0;
		for (int i = 1; i <= n - 1; i++) {
			pM = min(pM, a[i].y);
			MiN = min(a[i + 1].x, pM);
			MaX = max(a[n].x, pred[i]);
			ans = min(ans, ((long long)MaX - MiN) * ((long long)succ[i + 1] - a[1].x));
		}
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define N 200010
ll n,k,a[N];
void upd(){
	ll d[N];
	rep(i,n)d[i]=0;
	rep(i,n){
		d[max(0LL,i-a[i])]++;
		d[min(n,i+a[i]+1)]--;
	}
	ll s=0;
	rep(i,n){
		s+=d[i];
		a[i]=s;
	}
}
int main(){
	cin>>n>>k;
	rep(i,n){
		cin>>a[i];
	}
	rep(i,min(k,(ll)100)){
		upd();
	}
	rep(i,n){
		if(i)cout<<" ";
		cout<<a[i];
	}
	cout<<endl;
}


Measured memory_bytes: 6752
import sys
sys.setrecursionlimit(10**5+10)
input = sys.stdin.readline
def dfs(v,G,visit):
    visit[v-1]=1    
    for next in G[v-1]:        
        if visit[next-1]:
            continue
        _ = dfs(next,G,visit) 
 
N, M =map(int, input().split())
G  = [[] for _ in range(N)]
for i in range(M):
    a,b ,_= map(int, input().split())
    G[a-1].append(b)
    G[b-1].append(a)
    
count = 0

visit = [0]*N
for i in range(1,N+1):
  if visit[i-1]:
    continue
  if G[i-1]:  
    _ = dfs(i,G,visit)
  else:
    visit[i-1] = 1
  count += 1

print(count)

Measured memory_bytes: 110204
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF LLONG_MAX/10
#define rep(i,n) for(int i=0;i<n;i++)
#define krep(i,k,n,m) for(int i=k;i<n;i+=m)
#define erep(i,k,n) for(int i=k;i<n;i++)
#define mod 1000000007
//最大公約数
int gcd(int s,int t){
    if(t==0)return s;
    return gcd(t,s%t);
}
signed main(){
    int n;
    cin>>n;
    int a[n];
    rep(i,n){
        cin>>a[i];
    }
    sort(a,a+n);
    reverse(a,a+n);
    int ans=0;
    if(n==2){
        cout<<a[0]<<endl;
        return 0;
    }
    int m=n;
    rep(i,m){
        ans+=a[i];
        n--;
        if(n==1){
            cout<<ans<<endl;
            return 0;
        }
        if(i!=0){
            ans+=a[i];
            n--;
            if(n==1){
                cout<<ans<<endl;
                return 0;
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 5200
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.next()

  println(abc168a(n))
}

private fun abc168a(n: String): String {
  val last = n.last();

  if (last == '3') return "bon"

  if (last == '0' || last == '1' || last == '6' || last == '8') return "pon"

  return "hon"
}


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

#define fi first
#define se second
#define pb push_back
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define FOR(i, a, b) for (int i = a; i <= (b); i++)
#define ROF(i, a, b) for (int i = a; i >= (b); i--)

using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using vll = vector<ll>; using vvll = vector<vll>;

int main() {
    int a, b, c; cin >> a >> b >> c;
    int k; cin >> k;
    int x = 0;
    while (a >= b) b *= 2, x++;
    while (b >= c) c *= 2, x++;
    if (x <= k) cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j;
    int arr[5];
    for(i=0; i<5; i++)
    {
        cin >> arr[i];
    }
    for(j=0; j<5; j++)
    {
        if(arr[j]== 0)
        {
            j=j+1;
            cout << j;
            break;
        }
        else
            continue;
    }
    return 0;
}


Measured memory_bytes: 3564
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; i++ )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
const int inf=1e9+7;
const ll longinf=1LL<<62 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;

int main(){
    int n;
    while(cin>>n,n!=0){
    int t[n][n+1];
    rep(i,n)rep(j,n+1)cin>>t[i][j];
    int m=1<<n;
    int dp[m];
    dp[0]=0;
    rep(i,m){
        if(i==0)continue;
        int ret=inf;
        rep(j,n){
            if(i&1<<j){
                int res=t[j][0],pos=i^(1<<j);
                rep(k,n)if(pos&(1<<k))res=min(res,t[j][k+1]);
                ret=min(ret,dp[pos]+res);
            }
        }
        dp[i]=ret;
    }
    cout<<dp[m-1]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3312
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define N 100010
int cnt[N];

int main(){
	int a, b, c;
	cin>>a>>b>>c;
	cout<<(abs(a-b)<abs(a-c)?'A':'B')<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    #define mp make_pair
    #define f1 first
    #define f2 second
    #define pb push_back
    #define pii pair<int ,int>
    #define ios  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #define int long long
    using namespace std;
    const int mox=1e5+9;
    int na[mox];
    int ma[mox];
    vector<pii> g;
    int tree[mox];
    int n;
    void add(int id)
    {
     for(int i=id ; i<=n ; i+=(i&(-i)))
            tree[i]+=1;
    }
    int get(int id)
    {
        int ans=0;
        for(int i=id ; i>0 ; i-=(i&(-i)))
            ans+=tree[i];
        return ans;
    }
    main()
    {
        ios
        cin>>n;
        for(int i=0 ; i<n ; i++)
            cin>>na[i];
        int low=1;
        int hi=1e9+1;
        int u=((((n*(n+1))/2)+1)/2);
        while(low<hi-1)
        {
            int mid=(low+hi)/2;
            int x=0;
            int ans=0;
            for(int i=1 ; i<=n ; i++)
            {
                if(na[i-1]>=mid)
                    x++;
                ma[i]=((2*x)-i);
                g.pb({ma[i],i});
                if(ma[i]>=0)
                    ans++;
            }
            sort(g.begin(),g.end());
            for(int i=0 ; i<n  ; i++)
            {
                 ans+=get(g[i].f2);
                 add(g[i].f2);
            }
           g.clear();
           memset(tree,0,sizeof(tree));
            if(ans>=u)
            {
                low=mid;
            }
            else
                hi=mid;
        }
        cout<<low;


    }


Measured memory_bytes: 4336
#include <iostream>

using lint = long long;

int main() {
    int m;
    std::cin >> m;

    lint sum = 0, dig = 0;
    for (int i = 0; i < m; ++i) {
        int d;
        lint c;
        std::cin >> d >> c;
        sum += d * c;
        dig += c;
    }

    std::cout << (dig - 1) + ((sum - 1) / 9) << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
};



int main(){
  lint N,A[100005];
  cin>>N;
  for(int t=0;t<N;t++)cin>>A[t];

  sort(A,A+N);

  int ptr=0,check=0;
  while(ptr<N){
    int cont=1;
    while(A[ptr]==A[ptr+1]){
      cont++;
      ptr++;
    }
    ptr++;
    if(cont%2==1)check++;
  }

  cout<<check<<endl;
  return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll A, B;
	cin >> A >> B;
	if(B%A==0){
		cout << A + B << endl;
	}else{
		cout << B - A << endl;
	}
    return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
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; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


signed main(void) 
{
    ll n;
    cin >>n;
    ll x;
    cin >>x;
    vll a(n);
    ll r = 0;
    rep(i, n) {
        cin >>a[i];
    }
    Sort(a);
    
    rep(i, n) {
        x -= a[i];
        if (x < 0) break;
        r++;
    }
    if (x > 0) r--;
    
    mes(r);

    
    

}


Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using P=pair<int,int>;
using lint=long long;
using ll=long long;
const lint inf=1e18+7;
const int MOD=1000000007;
struct Nums{
    long long n;
    vector<long long> kaijo;
    Nums(int N){
        n=N;
        kaijo.push_back(1);
        for(long long i=1;i<=n;i++){
            kaijo.push_back((kaijo[i-1]*i)%MOD);
        }
    }
    long myPow(long x, long n, long m){
        if(n == 0)
            return 1;
        if(n % 2 == 0)
            return myPow(x * x % m, n / 2, m);
        else
            return x * myPow(x, n - 1, m) % m;
    }
    long long modinv(long long a, long long m) {
        long long b = m, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        u %= m;
        if (u < 0) u += m;
        return u;
    }
    long long comb(long long N,long long K,long long rest){
        long long res=kaijo[N]*modinv(kaijo[K],rest)%rest;
        res*=modinv(kaijo[N-K],rest);
        res%=rest;
        return res;
    }
};

signed main(){
  int s;cin>>s;
  Nums lib(s+5);
  lint res=0;
  rep1(n,s){
    if(n*3>s)break;
    lint buf=s-n*3;
    lint add=lib.comb(buf+n-1,n-1,MOD);
    res+=add;
    res%=MOD;
  }
  cout<<res<<"\n";
  return 0;
}


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

int main() {
  int N,K;
  cin >> N>>K;
  vector<int> h(N);
  for (int i = 0; i < N; i++) {
    cin >> h.at(i);
  }
  sort(h.begin(),h.end());

  int g=h.at(K-1)-h.at(0);
  int ans=g;
  
  for (int i = K; i < N; i++) { 
    g=h.at(i)-h.at(i-K+1);
    ans=min(ans,g);
  }
    cout<<ans<<endl;
}



Measured memory_bytes: 640
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR((I),0,(N))
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP((I),(N)) cin>>(V[I])
#define INS2(I,N,V1,V2) REP((I),(N)) cin>>(V1[I])>>(V2[I]);
#define INS3(I,N,V1,V2,V3) REP((I),(N)) cin>>(V1[I])>>(V2[I])>>(V3[I]);
#define OUT(P) cout<<(P)<<endl
#define OUT2(P1,P2) cout<<(P1)<<" "<<(P2)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUTS(I,N,V) REP((I),(N)) cout<<(V[i])<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

int A,B,i,cnt;
string S,T;
inline void solve(){
  IN2(A,B);
  UP(i,A,B){
    S=to_string(i);
    T=S;
    reverse(ALL(T));
    if(S==T)cnt++;
  }
  OUT(cnt);
}

int main(int argc,char**argv){
  BEGIN
  solve();
  END
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define endl '\n'
#define M 1000000007
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define f first
#define s second
#define b begin
#define e end
#define pb push_back
#define mp make_pair
#define FOR(i,a,b) for(i=a;i<b;i++)
#define RFOR(i,a,b) for(i=a;i>=b;i--)
#define all(x) x.begin(),x.end()
#define itfr(it,x) for(it=x.begin();it!=x.end();it++)
#define flash ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;

int main()
{
    flash;
    int a,b,c;
    cin>>a>>b>>c;
    set<int> ss;
    ss.insert(a);
    ss.insert(b);
    ss.insert(c);
    cout<<ss.size()<<endl;
}

Measured memory_bytes: 3628
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(a: int, b: int, c: int, d: int):
    chk_dis = lambda x,y: abs(x-y) <= d

    if chk_dis(a,c) or (chk_dis(a,b) and chk_dis(b,c)):
        print(YES)
    else:
        print(NO)

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    c = int(next(tokens))  # type: int
    d = int(next(tokens))  # type: int
    solve(a, b, c, d)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define gcd(a,b) __gcd(a,b)
#define ll long long int
#define ld unsigned long long int
#define pi pair<ll,ll>
#define pb push_back
#define pf push_front
#define pu push
#define po pop
#define fi first
#define se second
#define mk make_pair
#define ve vector
#define lr(n) for(ll i=0;i<n;i++)
#define all(x) x.begin(),x.end()

	int main(){
		ios_base::sync_with_stdio(0);
		cin.tie(0);
		cout.tie(0);
		ll n,W;
		cin>>n>>W;
		ll v[n],w[n];
		ll m=0;
		lr(n){
			cin>>w[i]>>v[i];
			m+=v[i];
		}
		ve<ll>p(1e6),c(1e6,1e10);
		p[0]=1;
		c[0]=0;
		for(ll i=0;i<n;i++){
			for(ll j=m;j>=0;j--){
				if(p[j]){
					p[j+v[i]]=1;
					c[j+v[i]]=min(c[j+v[i]],c[j]+w[i]);
				}
			}
		}
		for(ll i=m;i>=0;i--){
			if(p[i] && c[i]<=W){
				cout << i << "\n";
				return 0;
			}
		}
	}

Measured memory_bytes: 15872
#include<stdio.h>
int main(){

  int x;
  int i,j;
  int n,m;
  int sum=0;
  int A[100][100]={};
  int B[100][100]={};
  int Sum[100][100]={};

  scanf("%d %d",&n,&m);

  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      scanf("%d",&x);
      A[i][j]=x;
    }
                
  }

  for(i=0;i<m;i++){
    scanf("%d",&x);
    B[i][1]=x;
  }

  for(i=0;i<n;i++){
    sum=0;
    for(j=0;j<m;j++){
      sum+=A[i][j]*B[j][1];
    }
    Sum[i][1]=sum;
  }

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


  return 0;
}



Measured memory_bytes: 2116
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
template<class S, class T> inline S max_L(S a,T b){
  return a>=b?a:b;
}
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(char &c){
  int i;
  for(;;){
    i = my_getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = my_getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = my_getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S chmin(S &a, T b){
  if(a>b){
    a=b;
  }
  return a;
}
int N;
char S[200000+2];
int main(){
  int i;
  int res = 1073709056;
  int R = 0;
  int W = 0;
  rd(N);
  rd(S);
  for(i=(0);i<(N);i++){
    if(S[i]=='R'){
      R++;
    }
  }
  for(i=(0);i<(N+1);i++){
    chmin(res, max_L(W, R));
    if(i < N){
      if(S[i]=='R'){
        R--;
      }
      else{
        W++;
      }
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200509-1

// --- original code ---
// int N;
// char S[2d5+2];
// {
//   int res = int_inf, R = 0, W = 0;
//   rd(N,S);
//   rep(i,N) if(S[i]=='R') R++;
//   rep(i,N+1){
//     res <?= max(W, R);
//     if(i < N) if[S[i]=='R', R--, W++];
//   }
//   wt(res);
// }


Measured memory_bytes: 3984
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define X first
#define Y second
#define pb push_back
#define max_el(x) max_element(x.begin(),x.end())-x.begin()
#define min_el(x) min_element(x.begin(),x.end())-x.begin()
#define mp make_pair
#define endl '\n'
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
// DONT USE MEMSET, USE VECTORS

void solve(){
	int n;
	cin>>n;
	int x = 800*n;
	int y = 200*(n/15);
	cout<<x-y<<endl;
}

int main(){
	fastread;
	int t = 1;
	// cin>>t;
	for(int i=1;i<=t;i++){
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}


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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define vi vector<int>
typedef long long ll;

using namespace std;


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(0); 

	int n;
	cin >> n;
	
	int ans = 0;
	
	set<int> s;
	
	rep(i , n){
		int x;
		cin >> x;
		if(s.find(x) != s.end()){
			s.erase(x);
		}else{
			s.insert(x);
		}
	}
	
	cout << s.size();

	return 0;
}

Measured memory_bytes: 4992
N = int(input())
ans = 0
dict_word = {}
for i in range(N):
  sorted_word = str(''.join(sorted(list(input()))))
  try:
    ans += dict_word[sorted_word]
    dict_word[sorted_word] += 1
  except:
    dict_word[sorted_word] = 1
print(ans)

Measured memory_bytes: 17936
#include <iostream>
#include <vector>
#include <string>
#include <queue>
using namespace std;

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

struct hw
{
    int h, w;
};

int h, w;
vector<string> maze;
vector<vector<int>> visited;

int bfs(int cnt)
{
    queue<hw> q;
    hw start = {0, 0};
    hw goal = {h - 1, w - 1};
    q.push(start);
    visited[start.h][start.w] = 1;

    while (q.size() > 0)
    {
        hw now = q.front();
        q.pop();
        if (now.h == goal.h && now.w == goal.w)
        {
            return cnt - visited[now.h][now.w];
        }

        for (int i = -1; i <= 1; i++)
        {
            for (int j = -1; j <= 1; j++)
            {
                if ((i == 0 && j == 0) || (i != 0 && j != 0))
                {
                    continue;
                }
                hw nxt = {now.h + i, now.w + j};
                if (nxt.h < 0 || nxt.h == h || nxt.w < 0 || nxt.w == w)
                {
                }
                else if (maze[nxt.h][nxt.w] == '#')
                {
                }
                else if (visited[nxt.h][nxt.w] == 0)
                {
                    q.push(nxt);
                    visited[nxt.h][nxt.w] = visited[now.h][now.w] + 1;
                }
            }
        }
    }
    return -1;
}

int main()
{
    int cnt = 0;
    cin >> h >> w;
    maze.resize(h);
    visited.resize(h);
    rep(j, h)
    {
        cin >> maze[j];
        rep(i, w)
        {
            cnt += maze[j][i] == '.' ? 1 : 0;
        }
        visited[j].resize(w);
    }
    cnt = bfs(cnt);
    cout << cnt << endl;
}

Measured memory_bytes: 256