akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

const int N = 200005;

int n;
int a[N];

vector<int> edges[N];

struct SegTree {
  int maxi[N << 2];

  void update(int node, int l, int r, int x, int val) {
    if (l > x || r < x) return;
    if (l == x && r == x) {
      maxi[node] = val;
      return;
    }

    int mid = (l + r) >> 1;

    update(node*2 + 1, l, mid+0, x, val);
    update(node*2 + 2, mid+1, r, x, val);
    maxi[node] = max(maxi[node*2 + 1], maxi[node*2 + 2]);
  }

  int query(int node, int l, int r, int ll, int rr) {
    if (l > rr || r < ll) return 0;
    if (l >= ll && r <= rr) return maxi[node];

    int mid = (l + r) >> 1;

    return max(query(node*2 + 1, l, mid+0, ll, rr),
               query(node*2 + 2, mid+1, r, ll, rr));
  }

  inline void update(int x, int val) {
    update(0, 0, n-1, x, val);
  }

  inline int query(int l, int r) {
    return query(0, 0, n-1, l, r);
  }
} tree;

void compress(int n, int a[]) {
  vector<int> v(a, a + n);
  sort(v.begin(), v.end());
  v.resize(unique(v.begin(), v.end()) - v.begin());
  for (int i = 0; i < n; ++i) {
    a[i] = lower_bound(v.begin(), v.end(), a[i]) - v.begin();
  }
}

int ans[N];
void dfs(int u, int p, int maxi) {
  int tq = tree.query(a[u], a[u]);
  int nq = tree.query(0, a[u] - 1) + 1;
  if (nq > tq) tree.update(a[u], nq);
  maxi = max(maxi, nq);

  ans[u] = maxi;

  for (int v: edges[u]) {
    if (v == p) continue;
    dfs(v, u, maxi);
  }

  if (nq > tq) tree.update(a[u], tq);
}

int solve() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  compress(n, a);

  for (int i = 1; i < n; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    --u, --v;

    edges[u].push_back(v);
    edges[v].push_back(u);
  }

  dfs(0, 0, 0);

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

  return 0;
}

int main() {
  int t = 1;
  // scanf("%d", &t);
  while (t--) solve();
  return 0;
}


Measured memory_bytes: 39204
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define MIN(a, b) (a < b ? a : b)
#define MAX(a, b) (a > b ? a : b)

struct {
	uint32_t remain;
	uint32_t idx;
	uint32_t count;
} queue[10000000];

static wPtr = 0;
static rPtr = 0;

static void enqueueEntry(const uint32_t remain, const uint32_t idx, const uint32_t count) {
	queue[wPtr].remain = remain;
	queue[wPtr].idx = idx;
	queue[wPtr].count = count;
	wPtr = (wPtr + 1) % 10000000;
}

int main(void) {
	const uint32_t opList[12] = { 1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049 };
	uint32_t N;
	uint32_t result = UINT32_MAX;

	scanf("%"PRIu32, &N);

	for (uint32_t idx = 0; idx < 12; idx++){
		if (opList[idx] <= N) {
			enqueueEntry(N, idx, 1);
		}
	}

	while (1) {
		const uint32_t newRemain = queue[rPtr].remain - opList[queue[rPtr].idx];
		if (newRemain > 0) {
			for (uint32_t idx = 0; idx <= queue[rPtr].idx; idx++) {
				if (opList[idx] <= newRemain) {
					enqueueEntry(newRemain, idx, queue[rPtr].count + 1);
				}
			}
		}
		else {
			printf("%"PRIu32, queue[rPtr].count);

			break;
		}
		rPtr = (rPtr + 1) % 10000000;
	}

	return 0;
}


Measured memory_bytes: 117376
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include <vector>
#include <cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;

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

const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n,m;
  	ci(n>>m);
  ll ans=1;
  FOR(i,0,n-1){
    ans*=m-1;
  }
  ans*=m;
  co(ans)
}

Measured memory_bytes: 256
from collections import Counter

if __name__ == '__main__':
    N = int(input())
    A = []
    for i in range(N):
        A.append(int(input()))

    counter_a = Counter(A)

    ans = 0
    for count in counter_a.values():
        if count % 2 != 0:
            ans += 1
    # print(counter_a.values())
    print(ans)


Measured memory_bytes: 16640
import math
n = int(input())
while n:
    nums = list(map(float, input().split()))
    m = sum(nums) / n
    a2 = 0.0
    for i in nums:
        a2 += (i - m)**2
    a = math.sqrt(a2/n)
    print(a)
    n = int(input())


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

using namespace std;

int main() {
	string S;
	cin >> S;
	for (int i = S.size() / 2 - 1; i > 0; i--) {
		if (S.substr(0, i) == S.substr(i, i)) {
			cout << i * 2 << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
import java.io.InputStream
import java.io.PrintStream
import java.util.*

class Abc085B(
    val input: InputStream,
    val output: PrintStream
) {
    fun proc() {
        val sc = Scanner(input)
        val n = sc.nextInt()
        val input = generateSequence { sc.nextInt() }
            .take(n).toList().distinct()
        output.print(input.size)
    }
}

fun main(args: Array<String>) {
    Abc085B(System.`in`, System.out).proc()
}


Measured memory_bytes: 31904
import java.util.*;
import java.io.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int n = Integer.parseInt(sc.next());
        double[] x = new double[n];
        for(int i=0; i<n; i++){
            x[i] = sc.nextDouble();
        }
        double[] y = new double[n];
        for(int i=0; i<n; i++){
            y[i] = sc.nextDouble();
        }
        
        //p=1
        double sum = 0;
        for(int i=0; i<n; i++){
            sum += Math.abs(x[i] - y[i]);
        }
        System.out.println(sum);
        
        //p=2
        sum = 0.0;
        for(int i=0; i<n; i++){
            sum += Math.pow(Math.abs(x[i] - y[i]),2);
        }
        sum = Math.sqrt(sum);
        System.out.println(sum);
        
        //p=3
        sum = 0.0;
        for(int i=0; i<n; i++){
            sum += Math.pow(Math.abs(x[i] - y[i]),3);
        }
        sum = Math.cbrt(sum);
        System.out.println(sum);
        
        //p=無限
        sum=0.0;
        for(int i=0; i<n; i++){
            sum = Math.max(sum,Math.abs(x[i] - y[i]));
        }
        System.out.println(sum);
    }

}



Measured memory_bytes: 29148
#ABC 83, B - two anagrams

from collections import Counter
n = int(input())
S = Counter([input() for i in range(n)])

m = int(input())
T = Counter([input() for i in range(m)])

diff = S - T
if diff:
    print(diff.most_common()[0][1])
else:
    print(0)


Measured memory_bytes: 3316
from collections import Counter
from math import factorial
N=int(input())
A=list(map(int,input().split()))
B=Counter(A)
count=0
def combination(x,y):
    return factorial(x) // (factorial(x - y) * factorial(y))
for key,b in B.items():
    if b>=2:
        count+=combination(b,2)
for a in A:
    ans=count
    ans-=B[a]-1
    print(ans)


Measured memory_bytes: 114508
def BlCannotGo(dt, dx, dy): ## 行けないならTrue
    dist = dx + dy
    if (dt % 2) != (dist % 2) or dist > dt:
        return True
    else:
        return False

def abs(x):
    if x>=0:
        return x
    else:
        return -x

if __name__ == '__main__':
    n = int(input())
    t = list(False for _  in range(n+1))
    x = list(False for _  in range(n+1))
    y = list(False for _  in range(n+1))
    t[0], x[0], y[0] = 0, 0, 0
    for i in range(n):
        t[i+1], x[i+1], y[i+1] = map(int, input().split())

    for i in range(1,n+1):
        dt = t[i] -  t[i-1]
        dx = abs(x[i] -  x[i-1])
        dy = abs(y[i] -  y[i-1])
        if BlCannotGo(dt, dx, dy):
            print('No')    
            exit()

    print('Yes')


Measured memory_bytes: 11828
#define _USE_MATH_DEFINES
#include <cmath>
#include <string>
#include <vector>
#include <utility>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <numeric>
#include <array>
#include <float.h>
#include <memory>
#include <functional>
#include <iomanip>
#include <queue>
#include <random>
#include <map>
#include <set>

#pragma warning(disable:4996)

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  cout << (a + b >= 10 ? "error" : to_string(a + b)) << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import deque
h, w = map(int, input().split())
s = [input() for _ in range(h)]
def bfs():
    dist = {(0,0): 0}
    que = deque([(0,0)])
    while que:
        i, j = que.popleft()
        for k,l in ((0,1),(1,0),(0,-1),(-1,0)):
            k += i
            l += j
            if 0<=k<h and 0<=l<w and s[k][l]=='.' and (k,l) not in dist:
                dist[k,l] = dist[i,j] + 1
                que.append((k,l))
    return dist
dist = bfs()
if (h-1,w-1) in dist:
    black = sum(line.count('#') for line in s)
    print(h*w - black - (dist[h-1,w-1]+1))
else:
    print(-1)

Measured memory_bytes: 3700
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef long long ll;
typedef long double ld;
using namespace std;

const int MOD = 1e9 + 7;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin >> s;
  for(int i = 0; i < s.size(); i++)
  {
    if((i % 2 == 0 && s[i] == 'L') || (i % 2 == 1 && s[i] == 'R'))
    {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int N,X,A[100010];

int main()
{
	scanf ("%d %d",&N,&X);
	long long ans = 0;
	for (int i=0;i<N;i++){
		scanf ("%d",&A[i]);
		if (A[i] > X)
		{
			ans += A[i] - X;
			A[i] = X;
		}
	}

	for (int i=1;i<N;i++){
		if (A[i-1] + A[i] > X){
			long long d = A[i-1] + A[i] - X;
			A[i] -= d;
			ans += d;
		}
	}

	printf ("%lld\n",ans);

	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <climits>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << -1; return;}
#define yes {cout << "Yes"; return;}
#define mkp make_pair
#define mkt make_tuple
#define cerr if(0) cerr

void solve() {
    int n; cin >> n;
    loop1(i, 9)
        loop1(j, 9)
            if (i * j == n) {
                cout << "Yes"; return;
            }
    cout << "No";
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


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


int main(){
	
	long long int x, y, N, D, count = 0;

	std::cin >> N >> D;

	rep(i, N){
		cin >> x >> y;
		if(x*x + y*y <= D*D){
			count++;
		}
	}


	std::cout << count << endl;

	return 0;
}

Measured memory_bytes: 3632
//let input = "15\n13 76 46 15 50 98 93 77 31 43 84 90 6 24 14";

function main(input){
  input = input.trim();
  let list0 = input.split("\n")[0];
  let list1 = input.split("\n")[1];
  let kousu = parseInt(list0);
  let list = list1.split(" ");
  let count = 0;
  for(let i=0; i<list.length; i++){
    list[i] = parseInt(list[i]);
    if( (i+1)%2!==0 && list[i]%2!==0 ){count++;}
  }
  console.log(count);
}
//main(input);
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29660
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;

void main() {
  auto s = readln.strip;
  int t;
  for (size_t i = 0, j = s.length - 1; i < j; i++,j--) {
    if (s[i] != s[j]) ++t;
  }
  writeln (t);
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<string.h>
#include<stdio.h>
#include<algorithm>
using namespace std;
long long a[100010][5];
bool cmp(long long p,long long q)
{
	return p>q;
}

int main()
{
	int n,m,i,j,k;
	scanf("%d%d",&n,&m);
	for (i=1;i<=n;i++)
	{
		for (j=1;j<=3;j++) cin >> a[i][j];
	}
	long long ans=-1;
	for (i=0;i<8;i++)
	{
		long long f[100010];
		for (j=1;j<=n;j++)
		{
			long long sum=0;int tmp=i;
			for (k=1;k<=3;k++)
			{
				if (tmp%2==1) sum+=a[j][k]; else sum-=a[j][k];
				tmp/=2; 
			}
			f[j]=sum;
		}
		sort(f+1,f+1+n,cmp);
		long long s=0;
		for (j=1;j<=m;j++) s+=f[j];
		ans=max(s,ans);
	} 
	cout <<ans;
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
x = [0]*n
y = [0]*n
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if a == 0:
        x[b] = 1
    if b == n-1:
        y[a] = 1

f = 0
for i in range(n):
    if x[i]*y[i] > 0:
        f = 1

if f:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

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

int main() {
  int N; cin >> N;
  int a[N];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  int ans = 0;
  for (int i = 0; i < N-2; i++) {
    if ((a[i] < a[i+1] && a[i+1] < a[i+2]) || (a[i] > a[i+1] && a[i+1] > a[i+2])) {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N;
int A[500001];
int SegTree[1000001];
int ans = 1;
int b = 2;

int gcd (int a, int b) {
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}


void update(int i, int x) {
	i += b - 1;
	SegTree[i] = x;
	
	while (i > 0) {
		i = (i - 1) / 2;
		if (SegTree[i * 2 + 1] > 0 and SegTree[i * 2 + 2] > 0) {
			SegTree[i] = gcd(SegTree[i * 2 + 1], SegTree[i * 2 + 2]);
		} else {
			break;
		}
	}
}

int query(int a, int b, int k, int l, int r) {
	if (r <= a || b <= l) return 0;
	if (a <= l && r <= b) return SegTree[k];
	else {
		int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
		int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
		return gcd(vl, vr);
	}
}

int main() {
	cin >> N;
	while (b < N) {
		b = b << 1;
	}
	for (int i = 0; i < 1000000; i++) SegTree[i] = 0;
	for (int n = 0; n < N; n ++) {
		cin >> A[n];
		update(n, A[n]);
	}
	
	for (int n = 0; n < N; n++) {
		int p;
		p = gcd(query(0, n, 0, 0, b), query(n + 1, N, 0, 0, b));
		ans = max(p, ans);
	}
	cout << ans << endl;
}

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

long long d, score = -1;
const long long t = 26;
vector<long long> c, res;
vector<vector<long long>> s;
vector<set<int>> st;

void solve();
long long calc();
long long change(int day, int id, bool ch = false);

int main() {
  cin >> d;
  c.resize(t);
  res.resize(d);
  for (auto &p : c) cin >> p;
  s.resize(d, vector<long long>(t, 0));
  for (auto &v : s)
    for (auto &p : v) cin >> p;
  for (int i = 0; i < d; ++i) {
    cin >> res[i];
    --res[i];
    // change(i, --res[i]);
  }
  long long m;
  cin >> m;
  for (int i = 0; i < m; ++i) {
    long long p, q;
    cin >> p >> q;
    cout << change(--p, --q, i == 0) << endl;
  }
  //   solve();
  //   calc();
  //   for (auto p : res) cout << p + 1 << endl;
  return 0;
}

void solve() {
  long long lim = 20000;
  vector<long long> memo(t, 0);
  for (int i = 0; i < d; ++i) {
    int id = 0;
    for (int j = 0; j < t; ++j)
      if (s[i][id] < s[i][j]) id = j;
    if (s[i][id] >= lim)
      res[i] = id;
    else {
      int cid = 0;
      long long sum = 0;
      for (int j = 0; j < t; ++j) {
        sum += memo[j] + c[j];
        if (memo[j] + c[j] > memo[cid] + c[cid]) cid = j;
      }
      sum -= memo[cid] + c[cid];
      if (s[i][id] > sum)
        res[i] = id;
      else
        res[i] = cid;
    }
    for (int j = 0; j < t; ++j)
      if (j != res[i])
        memo[j] += c[j];
      else
        memo[j] = 0;
  }
  cerr << calc() << endl;
}

long long calc() {
  long long sum = 0;
  vector<long long> memo(t, 0);
  for (int i = 0; i < d; ++i) {
    int num = res[i];
    sum += s[i][num];
    for (int j = 0; j < t; ++j)
      if (j != num)
        sum -= (memo[j] += c[j]);
      else
        memo[j] = 0;
  }
  return sum;
}

long long change(int day, int id, bool ch) {
  if (ch) {
    res[day] = id;
    score = calc();
    st.resize(t);
    for (int i = 0; i < t; ++i) st[i].insert(0), st[i].insert(d + 1);
    for (int i = 0; i < d; ++i) st[res[i]].insert(i + 1);
    return score;
  }
  int bf = res[day];
  score -= s[day][bf];
  score += s[day][id];
  st[bf].erase(day + 1);
  auto it = st[bf].upper_bound(day + 1);
  int righ = *it, lef;
  --it;
  lef = *it;
  score += ((righ - day - 1) * (righ - day - 2) +
            (day + 1 - lef) * (day - lef) - (righ - lef) * (righ - lef - 1)) *
           c[bf] / 2;
  it = st[id].upper_bound(day + 1);
  righ = *it;
  --it;
  lef = *it;
  score -= ((righ - day - 1) * (righ - day - 2) +
            (day + 1 - lef) * (day - lef) - (righ - lef) * (righ - lef - 1)) *
           c[id] / 2;
  res[day] = id;
  st[id].insert(day + 1);
  return score;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ar array
const int mxN=2e5;
int n, a[mxN];
long long c[mxN], ans;
int main(){
	cin>>n;
	for(int i=0;i<n;++i){
		cin>>a[i];
		--a[i];
		++c[a[i]];
	}
	for(int i=0;i<n;++i)
		ans+=c[i]*(c[i]-1)/2;
	for(int i=0;i<n;++i){
		ans-=c[a[i]]*(c[a[i]]-1)/2;
		--c[a[i]]*(c[a[i]]-1)/2;
		ans+=c[a[i]]*(c[a[i]]-1)/2;
		cout<<ans<<endl;
		ans-=c[a[i]]*(c[a[i]]-1)/2;
		++c[a[i]]*(c[a[i]]-1)/2;
		ans+=c[a[i]]*(c[a[i]]-1)/2;
	}
	return 0;
}

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

#define rep(i, s, t) for(int i = (s), i##E = (t); i <= i##E; ++i)

using namespace std;

int n, m;
map<int, int> Id;

int main()
{
	scanf("%d", &n);
	rep(i, 1, n) 
	{
		static int x;
		scanf("%d", &x);
		Id[x]++;
	}
	scanf("%d", &m);
	rep(i, 1, m)
	{
		static int x;
		scanf("%d", &x);
		if((--Id[x]) < 0) return puts("NO"), 0;
	}puts("YES");
	return 0;
}

Measured memory_bytes: 9600
#include<iostream>
using namespace std;
int main() {
	int a, ans,moku, b, tyokin;
	while (1) {
		cin >> moku;
		if (moku == 0) {
			goto a;
		}
		tyokin = 0;
		ans = 0;
		for (int i = 1; i <= 12; i++) {
			cin >> a >> b;
			tyokin += a - b;
			if (moku <= tyokin) {
				ans = i;
				tyokin = -99999999;
			}
		}
		if (ans == 0) {
			cout << "NA" << endl;
		}
		else {
			cout << ans << endl;
		}
	}
a:;
}


Measured memory_bytes: 3080
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define vi vector <int>
#define vii vector <int>::iterator 
#define vd vector <double>
#define vdd vector <double>::iterator
#define vs vector <string>
#define vss vector <string>::iterator
#define vc vector <char>
#define vcc vector <char>::iterator
#define maxx(a,b,c) max(a,max(b,c))
#define minn(a,b,c) min(a,min(b,c))
#define SORT(x)     sort(x.begin(),x.end())
#define fill(x,y)   memset(x, y, sizeof(x))
#define PI 2*acos(0.0)
#define fio ios::sync_with_stdio(false);cin.tie(0)
using namespace std;
int main(){
   ll n, m;
   cin >> n;
   while(1){
       if(n <= m){
           cout << m-n << endl;
           return 0;
       }
       else
           m+=1000;
   }
}

Measured memory_bytes: 3664
#include<stdio.h>
const int maxn=200000;
const long long big=2000000000;
int L[maxn/2+2],R[maxn/2+2];
int A[maxn+10];
long long zhenghe(int A[],int left,int mid,int right)
{
    long long cnt=0;
    int n1=mid-left;
    int n2=right-mid;
    for (int i=0;i<n1;i++) L[i]=A[left+i];
    for (int i=0;i<n2;i++) R[i]=A[mid+i];
    L[n1]=R[n2]=big;
    int i=0,j=0;
    for (int k=left;k<right;k++)
    {
        if(L[i]<=R[j])
            {
                A[k]=L[i++];
            }
        else
        {
            A[k]=R[j++];
            cnt+=n1-i;
        }
    }
    return cnt;
}
long long guibing(int A[],int left,int right)
{
    int mid;
    long long v1,v2,v3;
    if(left+1<right)
    {
        mid=(left+right)/2;
        v1=guibing(A,left,mid);
        v2=guibing(A,mid,right);
        v3=zhenghe(A,left,mid,right);
        return v1+v2+v3;
    }
    else return 0;
}
int main()
{
    int n;
    scanf("%d",&n);
    for (int i=0;i<n;i++)
        scanf("%d",&A[i]);
    long long ans=guibing(A,0,n);
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 4240
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 998244353;//1e9 + 7;
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> PDL;
typedef pair<LD, LD> PDD;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

template<class T>
void in(T& x) {
	cin >> x;
}

template<class T1, class T2>
void in(pair<T1, T2>& p) {
	in(p.first);
	in(p.second);
}

template<class T>
void in(vector<T>& v, LL st = -1, LL en = -1) {
	if (st == -1) {
		st = 0;
		en = v.size() - 1;
	}
	for (LL n = st; n <= en; n++) {
		in(v[n]);
	}
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	LL a, b, c;
	cin >> a >> b >> c;
	if (c - a - b <= 0)cout << "No\n";
	else if (4 * a * b < (c - a - b) * (c - a - b))cout << "Yes\n";
	else cout << "No\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
const int inf   = 1<<30;
const ll  longinf = 1LL<<60;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

int main(){
  int n;
  cin>>n;
  int a[n],b[10],c=0;
  rep(i,10)
    b[i]=0;
  rep(i,n){
    cin>>a[i];
    a[i]/=400;
    if(a[i]<=7)
      b[a[i]]=1;
    else c++;
    }
  int ans=0;
  rep(i,8)
    ans+=b[i];
  if(ans==0)
    cout<<"1"<<" "<<c<<endl;
  else
    cout<<ans<<" "<<ans+c<<endl;
  return 0;
  }



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

using namespace std;
#define fordebug int hoge;cin>>hoge;
#define DEKAI 1000000007
#define INF (1<<28)
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)
#define floot10 cout<<fixed<<setprecision(10);
#define int long long


signed main(){
	int n;
	cin>>n;
	vector<pair<int,int> > v[10000];
	lp(i,n){
		int u,k;
		cin>>u>>k;
		lp(j,k){
			int a,b;
			cin>>a>>b;
			v[u].push_back(make_pair(a,b));
		}
	}
	queue<pair<int,int> > q;
	q.push(make_pair(0,0));
	int memo[10000];
	lp(i,10000) memo[i]=INF;
	memo[0]=0;
	while(!q.empty()){
		pair<int,int> hoge=q.front();
		q.pop();
		int now=hoge.first;
		int cos=hoge.second;
		if(memo[now]<cos) continue;
		lp(i,v[now].size()){
			int next=v[now][i].first;
			int cost=v[now][i].second;
			if(memo[next]>cos+cost){
				 q.push(make_pair(next,cos+cost));
				 memo[next]=cos+cost;
			}
		}
	}
	lp(i,n){
		cout<<i<<" "<<memo[i]<<endl;
	}
    return 0;
}



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

const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
const int MOD=1000000007;

ll sum[320];
ll dp[320][5][320];

int main(){
	int n,y;cin>>n>>y;
	deque<int>a;
	ll S=0;
	rep(i,n){
		int b;scanf("%d",&b);
		a.push_back(b);
		S+=b;
	}
	ll ans=0;
	rep(i,n){
		memset(dp,0,sizeof(dp));
		memset(sum,0,sizeof(sum));
		rep(j,a.size()){
			sum[j+1]=sum[j]+a[j];
		}
		dp[0][0][0]=1;
		rep(j,a.size())rep(k,5)rep(t,j+1){
			if(dp[j][k][t]==0)continue;
			ll s=sum[j+1]-sum[t];
			if((s+y)*5>=S&&k<4){
				dp[j+1][k+1][j+1]+=dp[j][k][t];
			}
			dp[j+1][k][t]+=dp[j][k][t];
		}
		ll T=0;
		rep(t,a.size()){
			ll s=sum[a.size()]-sum[t];
			if((s+y)*5>=S)(T+=dp[a.size()][4][t]);
		}
		//~ cerr<<T<<endl;
		ans+=T;
		int d=a.front();a.pop_front();
		a.push_back(d);
	}
	cout<<ans/5<<endl;
}
/*
6 100
1 1 1 1 1 1
*/


Measured memory_bytes: 7252
import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
a = na()

ans = 1000000000000

for y in range(-100,101):
    c = 0
    for i in a:
        c += (y-i)**2
    ans = min(c,ans)

print(ans)

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

/*
#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
*/
 
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define rrep(i,r,l) for(ll i=r;i>=l;i--)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"  //インタラクティブで消す！！！！！！！！！！！！！！！！！！！！！
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T,class S>
inline bool chmax(T &a, S b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T,class S>
inline bool chmin(T &a, S b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=50000;
    rep(y,1,P){
        ll x=mod(y*k);
        
        if(abs(x)<=P||x+P>=i_7){
            if(x+P>=i_7){
                x-=i_7;
            }
            cout<<x<<"/"<<y<<endl;
            //cout<<setprecision(5)<<(dd)x/(dd)y;
            return;
        }
    }
    cout<<"nun"<<endl;
}
#define all(c) c.begin(),c.end()
typedef vector<ll> vl;
//////////////////////////



int main(){fastio
    ll n,k;cin>>n>>k;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    rep(i,k,n-1){
        if(a[i]>a[i-k])cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    
    
    return 0;
}



Measured memory_bytes: 5200
#include <stdio.h>

int main() {
    char str[200] = {};

    scanf("%[^\n]%*c", str);

    for (int i=0; i<200; i++) {
        if (str[i] == 0) break;
        if (97 <= str[i] && str[i] <= 122) printf("%c", str[i]-32);
        else printf("%c", str[i]);
    }
    printf("\n");

    return 0;
}


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


int main() {
	int i, j, k, f = 0, n, s, t;
	int mp = 0, a, b, c, d, e, x, y, z;
	int g[50];
	d = 1;

	scanf("%d %d %d", &a, &b, &k);

	for (i = 1;i<101;i++) {
		if (a%i == 0&& b%i == 0) {
				g[d] = i;
				d++;
		}

	}


	e = d;
	x = d - k;

	printf("%d", g[x]);
	return 0;
}

Measured memory_bytes: 128
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)     (x).begin(),(x).end()
# define UNIQ(c)    (c).erase(unique(ALL((c))), end((c)))
# define mp         make_pair
# define eb         emplace_back
# define FOR(i,a,b) for(int i=(a);i<(b);++i)
# define REP(i,n)   FOR(i,0,n)
# define INIT       std::ios::sync_with_stdio(false);std::cin.tie(0);

LL dp[5050][5050];

const int MOD = 1e9 + 7;

int n;
string s;
int main() {
	cin >> n >> s;
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= 5010; j++) {
			if (j == 0) {
				dp[i][j] = (dp[i - 1][j] + dp[i - 1][j + 1]) % MOD;
			}
			else {
				dp[i][j] = (dp[i - 1][j - 1]*2 + dp[i - 1][j + 1]) % MOD;
			}
		}
	}
	LL ans = dp[n][s.size()];
	for (int i = 0; i < s.size(); i++) {
		ans = ans * 500000004 % MOD;
	}
	cout << ans << endl;

}

Measured memory_bytes: 198912
#include<iostream>
#include<algorithm>
#include<vector>
#include <iomanip>
#include <math.h>
 
using namespace std;
 
int main(){

	int n, m;
  	cin >> n >> m;
  
  	vector<vector<int> > A(n,vector<int>(m));
  	for(int j=0; j<n; j++){
    	for(int i=0; i<m; i++){
        	cin >> A.at(j).at(i);
        }
    }

  	vector<int>B(m);
  	for(int k=0; k<m; k++)
      cin >> B.at(k);
  	
  	for(int o=0; o<n; o++){
      int answer=0;
    	for(int l=0; l<m; l++){
          	answer += A.at(o).at(l)*B.at(l);
        }
      cout << answer << endl;
    }	
  
  
  return 0;
}


Measured memory_bytes: 3160
import java.util.*;
public class Main {
	static int answer = 0;
	static int n;
	static int[] set = {3, 5, 7};
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		dfs(0);
		System.out.println(answer);
	}
	public static void dfs(long x) {
		if(x > n) return;
		String s = String.valueOf(x);
		if(s.contains("3") && s.contains("5") && s.contains("7"))
			answer++;
		for(int k : set)
			dfs(x*10 + k);
	}
}

Measured memory_bytes: 25940
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1;
	while (b) {
		if (b & 1) { res = res * a%MOD; }
		a = a * a%MOD;
		b >>= 1;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑

long  long a, b, k[2005], l[2005], ans, mon;
int main() {
	cin >> a >> b;
	for (int i = 0; i < a; ++i) {
		cin >> k[i];
		l[i] = k[i];
		ans += k[i];
	}

	for (int i = 1; i < a; ++i) {
		mon = i * b;
		for (int j = 0; j < a; ++j) {
			l[j] = min(l[j], k[(a + j - i) % a]);
			mon += l[j];
		}
		ans = min(ans, mon);
	}
	cout << ans << endl;
}

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

using namespace std;
using ll = long long;
using v1 = vector<int>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

struct Node{
	int parent = -1;
	int left_child = -1;
	int right_brother = -1;
};

int cal_depth(vector<Node>& a, int d, int n){
	if(a[n].parent == -1) return d;
	d++;
	int depth = cal_depth(a, d, a[n].parent);
	return depth;
}

int main(){
	int n;
	cin >> n;
	vector<Node> a(n);
	rep(i,n){
		int id, k;
		cin >> id >> k;
		int px = -1;
		rep(j, k){
			int x;
			cin >> x;
			if(j == 0) a[id].left_child = x;
			a[x].parent = id;
			if(px != -1) a[px].right_brother = x;
			px = x;
		}
	}
	rep(i, n){
		cout << "node " << i << ": ";
		cout << "parent = " << a[i].parent << ", ";
		int depth = cal_depth(a, 0, i);
		cout << "depth = " << depth << ", ";
		if(a[i].parent == -1){
			cout << "root, ";
		}else if(a[i].left_child == -1){
			cout << "leaf, ";
		}else{
			cout << "internal node, ";
		}
		cout << "[";
		int nowp = a[i].left_child;
		while(nowp != -1){
			cout << nowp;
			nowp = a[nowp].right_brother;
			if(nowp == -1) break;
			cout << ", ";
		}
		cout << "]" << endl;
	}
}



Measured memory_bytes: 3848
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define all(v) v.begin(),v.end()
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int,int>;
  
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin >> s;
    for(int i = 0;i < s.size();i += 2){
      cout << s[i];
    }
    cout << '\n';
    return 0;
}


Measured memory_bytes: 592
import math

n = int(input())
town = [list(map(int, input().split())) for _ in range(n)]
sum = 0
for i in range(n-1):
    for j in range(i + 1, n):
        x1, y1 = town[i]
        x2, y2 = town[j]
        sum += math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)

print(2*sum/n)

Measured memory_bytes: 3064
import sys
from collections import deque, Counter

stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

w = input()
c = Counter(w)
ans = 'Yes'
for i in c.values():
    if i % 2 != 0:
        ans = "No"
print(ans)



Measured memory_bytes: 3316
#include <iostream>
#include <stdio.h>
#include <cctype>
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    int R[200000];
    int n;
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> R[i];
        //cout << R[n] << endl;
    }
    int maxv = -2000000000;
    int minv = R[0];

    for (int j = 1; j < n; j++) {
        maxv = max(maxv, R[j] - minv);
        minv = min(minv, R[j]);
        //cout << maxv << minv << endl;
    }
    //cout << max(1, 3) << endl;
    cout << maxv << endl;

    return 0;
}


Measured memory_bytes: 3872
/*************************************************************************
    > File Name: test.cpp
    > Author: Akira 
    > Mail: qaq.febr2.qaq@gmail.com 
 ************************************************************************/

#include<bits/stdc++.h>
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
#define MST(a,b) memset(a,b,sizeof(a))
#define CLR(a) MST(a,0)
#define Sqr(a) ((a)*(a))
using namespace std;

#define MaxN 100010
#define MaxM MaxN*10
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626
const int mod = 1E9+7;
const double eps = 1e-6;
#define bug cout<<88888888<<endl;
#define debug(x) cout << #x" = " << x << endl;
template<typename T> T abs(T val){return val>0?val:-val;}

int n;
int vis[MaxN],a,b;
const int P = 1000000007;
LL f[1000001], v[1000001];
LL rp(LL now, int k) 
{
    LL will = 1;
    for (; k; k >>= 1, now *= now, now %= P) 
    {
        if (k & 1) will *= now, will %= P;
    }
    return will;
}
LL C(int n, int m) 
{
    if(n < m) return 0;
    return f[n] * rp(f[m], P - 2) % P * rp(f[n - m], P - 2) % P;
}
void init()
{
    f[0] = 1; v[0] = 1;
    for (int i = 1; i <= 100010; i++) //1e6以内的组合数
    {
        f[i] = f[i - 1] * i % P;
    }
}
void solve()
{
    a -= 1;
    b = n+1-b;
    for(int i=1;i<=n+1;i++)
    {
		
        LL x = C(n+1, i);
        x -= C(a+b,i-1);
        printf("%lld\n", (x%P+P)%P );
    }
}
int main()
{
    //std::ios::sync_with_stdio(false);
    init();
    while(~scanf("%d", &n))
    {
        CLR(vis);
        int x;
        for(int i=1;i<=n+1;i++) 
        {
            scanf("%d", &x);
            if(vis[x]==0) vis[x]=i; 
            else 
            {
                a = vis[x];
                b = i;
            }
        }
        solve();
    }
    //system("pause");
}


Measured memory_bytes: 5760
#include <cstdio>
#include <vector>
#include <algorithm>

#define all(v) (v).begin() + 1, (v).end()
using namespace std;

struct info
{
    int start, end;

    int operator<(info &A)
    {
        return(A.end == end ? start < A.start : end < A.end);
    }
};

int main()
{
    int no_of_vertices, no_of_segments;
    scanf("%d %d", &no_of_vertices, &no_of_segments);

    vector <info> segments(no_of_segments + 1);
    for(int i = 1; i <= no_of_segments; i++)
        scanf("%d %d", &segments[i].start, &segments[i].end);

    sort(all(segments));

    int no_of_deleted_bridges = 0, last_deleted = 0;
    for(int i = 1; i <= no_of_segments; i++)
    {
        if(segments[i].start > last_deleted)
        {
            last_deleted = segments[i].end - 1;
            no_of_deleted_bridges++;
        }
    }

    printf("%d\n", no_of_deleted_bridges);
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
 
typedef pair <int, int> pii;
typedef pair <long long, long long> pll;
#define pb push_back
#define ll long long
#define endl "\n"
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
int main() 
{
    fast_io();
    int n; cin >> n;
    for (int x = 0; x <= n; ++x)
    {
    	int a = (int) (x*1.08);
    	if (a == n)
    	{
    		cout << x << endl;
    		return 0;
    	}
    }
    cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
L = []
for i in range(N) :
    L.append(list(map(int,input().split())))
v = []
for i in range(M) :
    v.append(int(input()))

ans = []
for i in range(N) :
    element = 0
    for j in range(M) :
        element += L[i][j]*v[j]
    ans.append(element)
for i in range(len(ans)) :
    print(ans[i])
    


Measured memory_bytes: 6016
<?php
 
function input($func = null) {
    if ($func === null) {
        return trim(fgets(STDIN));
    } else {
        return $func(trim(fgets(STDIN)));
    }
}
function input_array($func = null) {
    if ($func === null) {
        return explode(' ', input());
    } else {
        return array_map(function($v) use ($func) {
            return $func($v);
        }, explode(' ', input()));
    }
}

$sum = 0;
$max = 0;

$n = input('intval');
for ($i = 0; $i < $n; $i++) {
    $p = input('intval');
    $sum += $p;
    $max = max($max, $p);
}
$sum -= intdiv($max, 2);

echo $sum . "\n";

Measured memory_bytes: 4856
function Main(input){
  var N = Number(input);
  if(N==1){
    var record =[1,0];
  }else{
    var record =[0,0];
  }
  for(var i=1;i<=N;i++){
    var count=0;
    count = check(i,count);
    if(record[1]<count){
      record=[i,count];
    }
  }
  function check(i,t){
    if(i%2==0){
      ++t;
      return check(i/2,t);
    }else{
      return t;
    }
  }
  console.log(record[0]);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector <int> a;
    vector <pair <int, int> > b;
    vector <int> otv(n, 0);
    int th;
    for (int i=0; i<n; i++){
        cin >> th;
        a.push_back(th);
        b.push_back(make_pair(th, i));
    }
    sort(b.begin(), b.end());
    for (int i=0; i<n; i++){
        if ((i+1)*2 <= n){
            otv[b[i].second] = b[(n-1) / 2 + 1].first;
        }
        else{
            otv[b[i].second] = b[((n-1)/ 2)].first;
        }
    }
    for (int i=0; i<n; i++){
        cout << otv[i] << ' ';
    }
    return 0;
}

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

using namespace std;

typedef long long ll;

#define INF 100000000
#define FOR(index, init, max) for (int index = (init); index < (max); index++)
#define REP(index, max) for (int index = 0; index < (max); index++)
#define FOREACH(x, array) for (auto&& (x) : array)
#define VECCIN(vec) for (auto&& vec_i : vec) cin >> vec_i
#define VECCOUT(vec) for (const auto& vec_i : vec) cout << vec_i << endl

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

    vector<int> h(n);
    VECCIN(h);

    int dp[100001];
    dp[0] = 0;
    FOR(i, 1, 100001) {
        dp[i] = INF;
    }

    FOR(i, 1, n + 1) {
        if (i == 1) {
            dp[i] = dp[0] + abs(h[i] - h[i - 1]);
        }
        if (i > 1) {
            dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
        }
    }

    cout << dp[n - 1] << endl;

    return 0;
}

Measured memory_bytes: 1152
import sys

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def solve():
    n, l = map(int, input().split())
    S = [input() for i in range(n)]
    S.sort()
    print(''.join(S))


if __name__ == '__main__':
    solve()

Measured memory_bytes: 3060
;; #!/usr/bin/env sbcl --script

(declaim (optimize (speed 3) (safety 0) (debug 0)))

(deftype int32 () '(signed-byte 32))

(defun main ()
  (let* ((n (the int32 (read)))
         (k (the int32 (read)))
         (a (make-array n :element-type 'int32))
         (dp (make-array n :element-type 'int32 :initial-element (+ (expt 10 9) 100))))
    (dotimes (i n)
      (setf (aref a i) (the int32 (read))))
    (setf (aref dp 0) 0)
    (loop for i of-type int32 from 0 below n do
      (loop with from-val of-type int32 = (aref dp i)
         for j of-type int32 from (1+ i) to (+ i k)
         while (< j n)
         do
           (let ((nval (the int32 (+ from-val (abs (- (aref a i) (aref a j)))))))
             (setf (aref dp j) (min (aref dp j) nval)))))
    (format t "~a~%" (aref dp (- n 1)))))

;; (defun main2 ()
;;   (let* ((n (the int32 (read)))
;;          (k (the int32 (read)))
;;          (a (make-array n :element-type 'int32))
;;          (dp (make-array n :element-type 'int32 :initial-element (+ (expt 10 9) 100))))
;;     (let ((stream (make-string-input-stream (read-line))))
;;       (loop for i from 0
;;          for j = (read stream nil) until (null j)
;;          do (setf (aref a i) (the int32 j)))
;;     (setf (aref dp 0) 0)
;;     (loop for i of-type int32 from 0 below n do
;;       (loop with from-val of-type int32 = (aref dp i)
;;          for j of-type int32 from (1+ i) to (+ i k)
;;          while (< j n)
;;          do
;;            (let ((nval (the int32 (+ from-val (abs (- (aref a i) (aref a j)))))))
;;              (setf (aref dp j) (min (aref dp j) nval)))
;;     (format t "~a~%" (aref dp (- n 1)))))

(main)



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

int main(){
  int n = 0;
  cin >> n;
  int sum = 0;
  for (int i = 0;i < n;i++) {
    int a, b;
    cin >> a >> b;
    sum = sum + b - a +1;
  }
  cout << sum << endl;
}


Measured memory_bytes: 3624
N, K = map(int, input().split())

Narr = []
for i in range(0, N + 1):
    Narr.append(i)
S = []
S.append(0)
for i in range(1, N + 2):
    S.insert(i, Narr[i - 1] + S[i - 1])

sum = 0
mod = pow(10, 9) + 7
last = len(S) - 1
for i in range(K, N + 2):
    sum += S[last] - S[last - i] - S[i] + 1

print(sum % mod)

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

int main() {
	int A, B, X;
	cin >> A >> B >> X;
	if (X % 500 == 0) X /= 500;
	else X /= 500, X++;
	if (X % 2 == 0) cout << min(X * B, (X / 2) * A) << endl;
	else cout << min(X * B, (X / 2) * A + min(A, B)) << endl;
}


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

int main()
{
	int s[3] = { 0 };
	int c[3] = { 0 };
	int a[3] = { 0 };
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> s[i] >> c[i];
	}

	bool suc = true;
	
	for (int i = 0; i < m; i++) {
		if (a[n - s[i]] != 0) {
			if (a[n - s[i]] != c[i]) {
				suc = false;
				break;
			}
			else
			{
				a[n - s[i]] = c[i];
			}
		}
		else
		{
			a[n - s[i]] = c[i];
		}
		if ((n != 1) && (s[i] == 1) && (c[i] == 0)) {
			suc = false;
			break;
		}
	}
	if ((n != 1) && (a[n - 1] == 0)) {
		a[n - 1] = 1;
	}
	if (!suc) {
		cout << -1 << endl;
	}
	else
	{
		int ans = 0;
		for (int i = 0; i < n; i++) {
			ans += a[i] * pow(10, i);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#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;
signed main(){
  int a[2],b[2];
  cin>>a[0]>>a[1]>>b[0]>>b[1];
  lint res=-inf;
  rep(i,2){
    rep(j,2){
      lint buf=a[i]*b[j];
      res=max(res,buf);
    }
  }
  cout<<res<<"\n";
  return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
char s[10];
scanf("%s", s);
sort(s, s + 4);
printf((s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) ? "Yes\n" : "No\n");
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

bool Check(string S, int A, int B, int C, int D) {
    while((int)max(C, D) < S.size()) S.pop_back();

    if(S.find("##", A) != string::npos) {
        return false;
    }

    if(C < D) {
        return true;
    } else {
        if(S.substr(B - 2, D - B + 3).find("...") == string::npos) {
            return false;
        }
        return true;
    }
}

int main() {
    int N, A, B, C, D;
    string S;

    cin >> N >> A >> B >> C >> D;
    cin >> S;

    bool ans = Check(S, A, B, C, D);

    if(ans) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

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

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

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

    for (int i = 0; i < n; i++)
    {
        if (p[i] % 2 == 0 && p[i] % 3 != 0 && p[i] % 5 != 0) 
        {
            cout << "DENIED" << endl;
            return 0;
        }
    }

    cout << "APPROVED" << endl;
}

Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]

A.sort()

if N % 2 == 0:
    middle = N // 2
    able = True
    for i in range(0,N,2):
        if A[i] != A[i+1]:
            able = False
            break
    if able:
        ans = 2**middle
    else:
        ans = 0
else:
    middle = N // 2
    able = True
    if A[0] == 0:
        for i in range(1,N,2):
            if A[i] != A[i+1]:
                able = False
                break
        if able:
            ans = 2**middle
        else:
            ans = 0
    else:
        ans = 0
        
print(ans%(10**9 + 7))

Measured memory_bytes: 13880