akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define ALL(x) std::begin(x), std::end(x)
using namespace std;
template <typename T> istream & operator >> (istream & in, vector<T> & xs) { REP (i, xs.size()) { in >> xs[i]; } return in; }

pair<string, vector<int64_t> > solve(int n, int m, const vector<int64_t> & d, const vector<pair<int, int> > & edges) {
    // make the adjacency list
    vector<vector<pair<int, int> > > g(n);
    REP (i, m) {
        int x, y; tie(x, y) = edges[i];
        g[x].emplace_back(y, i);
        g[y].emplace_back(x, i);
    }
    REP (x, n) {
        sort(ALL(g[x]), [&](pair<int, int> edge1, pair<int, int> edge2) {
            return make_pair(d[edge1.first], edge1.first) < make_pair(d[edge2.first], edge2.first);
        });
    }

    //
    string color(n, '\0');
    vector<int64_t> cost(m, 1000000000);

    // find the initial edge
    vector<int> order(n);
    iota(ALL(order), 0);
    sort(ALL(order), [&](int x, int y) { return make_pair(d[x], x) < make_pair(d[y], y); });
    for (int x : order) {
        if (color[x]) continue;
        int y, i; tie(y, i) = g[x][0];
        if (d[y] < d[x]) {
            color[x] = color[y];
            cost[i] = d[x] - d[y];
        } else if (d[x] == d[y]) {
            if (color[y]) {
                color[x] = color[y] ^ 'B' ^ 'W';
            } else {
                color[x] = 'B';
                color[y] = 'W';
            }
            cost[i] = d[x];
        } else {
            const pair<string, vector<int64_t> > FAILURE = {};
            return FAILURE;
        }
    }
    return make_pair(color, cost);
}

int main() {
    int n, m; cin >> n >> m;
    vector<int64_t> d(n); cin >> d;
    vector<pair<int, int> > edges(m);
    REP (i, m) {
        int u, v; cin >> u >> v;
        -- u;
        -- v;
        edges[i] = make_pair(u, v);
    }
    string color; vector<int64_t> cost;
    tie(color, cost) = solve(n, m, d, edges);
    if (color.empty()) {
        cout << -1 << endl;
    } else {
        cout << color << endl;
        REP (i, m) {
            cout << cost[i] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 14336
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        boolean movable = true;
        int t[] = new int[N+1];
        int x[] = new int[N+1];
        int y[] = new int[N+1];
        int dt;
        int dist;
        t[0] = 0;
        x[0] = 0;
        y[0] = 0;
        
        for (int i = 1; i <= N; i++) {

            t[i] = sc.nextInt();
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();

            dt = t[i] - t[i-1];
            dist = Math.abs(x[i] - x[i-1]) + Math.abs(y[i] - y[i-1]);

            if (dt%2 != dist%2) {
                movable = false;
            }

            if(dt < dist) {
                movable = false;
            }
        }
        System.out.println(movable ? "Yes" : "No");
    }
}

Measured memory_bytes: 90592
from collections import deque
import sys
n = int(input())
if n == 1:
    print('a')
    sys.exit()

q = deque([])
q.append((1, 'a', '1'))
cur = 1
while cur != n:
    num = len(q)
    j = 0
    while j < num:
        a, b, c = q.popleft()
        for i in range(1, max(map(int, list(c)))+2):
            q.append((i, b + chr(96+i), c + str(i)))
        j += 1
    cur += 1

for i in range(len(q)):
    a, b, c = q.popleft()
    print(b)



Measured memory_bytes: 31908
using System;
using System.Linq;
using System.Collections.Generic;


namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            MainStream();
        }
        static void MainStream()
        {
            Scan sc = new Scan();
            write wr = new write();

            int X = sc.intarr[0];
            int max = 1;

            for(int i=2; i<Math.Sqrt(X); i++)
            {
                int Sq = 1;
                while(Sq <= X)
                {
                    Sq *= i;
                }
                max = Math.Max(max, Sq/i);
            }

            wr.wri(max);

        }
    }

    class Scan
    {
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
        public char[] chararr => str.ToArray();


    }



    class write
    {
        public void wri<Type>(Type x)
        {
            Console.WriteLine(x);
        }
    }

    class Method
    {
        static public int max(params int[] nums)
        {

            int maxx = nums[0];
            for (int i = 1; i < nums.Length; i++)
            {
                maxx = Math.Max(maxx, nums[i]);
            }
            return maxx;
        }
    }
}


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

const int INF = 80*80*80;

int h,w;

int a[85][85];
int b[85][85];

int memo[85][85][80*80*2 + 5];

int dp(int x, int y, int dif){
	if(x == h && y == w){
		return dif;
	}
	int &ret = memo[x][y][dif];
	if(ret!=-1) return ret;
	ret = INF;
	if(x<h){
		ret = min(ret,dp(x+1,y,abs(dif + a[x+1][y] - b[x+1][y]))); 
		ret = min(ret,dp(x+1,y,abs(dif - a[x+1][y] + b[x+1][y])));
	}
	if(y<w){
		ret = min(ret,dp(x,y+1,abs(dif + a[x][y+1] - b[x][y+1]))); 
		ret = min(ret,dp(x,y+1,abs(dif - a[x][y+1] + b[x][y+1])));
	}
	return ret;
}

int main(){
	memset(memo,-1,sizeof(memo));
	scanf("%d%d",&h,&w);
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			scanf("%d",&a[i][j]);
		}
	}
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			scanf("%d",&b[i][j]);
		}
	}
	int ans = dp(1,1,abs(a[1][1] - b[1][1]));
	printf("%d\n",ans);
	return 0;
}


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

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

    int K, X; 
    cin >> K >> X;

    string ans;
    for (int i = X - K + 1; i < X + K; ++i) {
        ans.append(to_string(i));
        ans.push_back(' ');
    }
    cout << ans.substr(0, ans.size() - 1) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

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

	vector<double> x(N), y(N);
	for (int i = 0; i < N; i++) cin >> x[i] >> y[i];

	vector<int> P(N);
	for (int i = 0; i < N; i++) P[i] = i;

	double sum = 0;
	int c = 0;

	do {
		c++;
		double s = 0;
		for (int i = 1; i < N; i++) {
			double a, b, n;
			a = abs(x[P[i]] - x[P[i - 1]]);
			b = abs(y[P[i]] - y[P[i - 1]]);
			a *= a;
			b *= b;
			n = sqrt(a + b);
			s += n;
		}
		sum += s;
	} while (next_permutation(P.begin(), P.end()));

	cout << fixed << setprecision(10);
	cout << sum / c << endl;
}

Measured memory_bytes: 3848
object Main extends App {
  val in = scala.io.Source.stdin.getLines.toSeq
  val ls = in.map(_.split(' ').map(_.toInt).toIndexedSeq)
  val N = ls(0)(0)
  val M = ls(0)(1)
  val C = ls(0)(2)
  val B = ls.tail.head
  val A = ls.tail.tail
  
  val ret = A.map{ a =>
    val macc = a.indices.map{ i =>
      a(i)*B(i)
    }.foldLeft(0)((a,e) => a+e)
    macc + C
  }.count(_ > 0)

  println(ret)
}


Measured memory_bytes: 25536
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
inline int rnd(int x){
	return rand()%x;
}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=100005;
ll dp[N],tong[N];
vector<ll> a;
int n,q;
int main(){
	n=read(); q=read();
	a.resize(1); a[0]=n;
	for(int i=1;i<=q;i++){
		ll jb=read();
		while(a.size()&&a[a.size()-1]>=jb)a.pop_back(); a.push_back(jb);
	}
	dp[a.size()-1]=1;
	//for(unsigned i=0;i<a.size();i++)cout<<a[i]<<" SZBAKKING"<<endl;
	for(int i=a.size()-1;i;i--){
		ll de=a[i];
		for(int pos=i-1;de&&pos>=0;pos=upper_bound(a.begin(),a.begin()+pos,de)-a.begin()-1){
			//cout<<pos<<" "<<dp[i]<<" "<<i<<endl;
			dp[pos]+=de/a[pos]*dp[i]; de%=a[pos];
		}
		tong[de%a[0]]+=dp[i];
	}
	tong[a[0]]+=dp[0];
	for(int i=n;i;i--)tong[i]+=tong[i+1];
	for(int i=1;i<=n;i++)writeln(tong[i]);
}

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

const int INF = 0x3f3f3f3f;

int l;

void solve() {
  printf("%.6f", pow(double(l) / 3.0, 3.0));
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> l;
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int gcd(int a, int b)
{
	if (a > b) {
		a += b;
		b = a - b;
		a -= b;
	}
	if (b % a == 0) return a;
	else return gcd(b % a, a);
}

int main()
{
	int g, i, j, k, K;
	long long sum = 0;
	scanf("%d", &K);
	for (i = 1; i <= K; i++) {
		for (j = 1; j <= K; j++) {
			g = gcd(i, j);
			for (k = 1; k <= K; k++) sum += gcd(g, k);
		}
	}
	printf("%lld\n", sum);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1712
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#define INF 2147483647
#define REP(i,n) for(int i=0;i<(int)(n);i++)
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
int main()
{
  int K,N,A[100001],one,res,right,left,count;
  scanf("%d %d",&N,&K);
  REP(i,N){
    if(A[i] == 1)
      one = i;
  }
  count = 0;
  right = one;
  left = one;
  if(K == N){
    printf("1\n");
  }else{
  if(one + 1 <= K){
    count++;
    left = 0;
    right = K - 1;
  }
  if(N - one  <= K){
    count++;
    right = N;
    left = N - K;
  }
  
  while(left > 0){
    left -= K-1;
    count++;
  }
  while(right < N-1){
    right += K - 1;
    count++;
  }
  printf("%d\n",count);
  }
  
  return 0;
}


Measured memory_bytes: 128
module Trie = struct
  type 'a t = {mutable is_term : bool;
               next : 'a t option array}

  let to_int c = match c with 'A' -> 0 | 'C' -> 1 | 'G' -> 2 | _ -> 3

  let create () =
    {is_term = false; next = Array.make 4 None}

  let insert t str =
    let len = String.length str in
    let rec loop node = function
        i when i = len -> node.is_term <- true
      | i ->
        let ind = to_int str.[i] in
        match node.next.(ind) with
          None ->
          let new_node = create () in
          node.next.(ind) <- Some new_node;
          loop new_node (i+1)
        | Some e -> loop e (i+1)
    in loop t 0

  let find t str =
    let len = String.length str in
    let rec loop node = function
      i when i = len -> node.is_term
      | i ->
        let ind = to_int str.[i] in
        match node.next.(ind) with
          None -> false
        | Some e -> loop e (i+1)
    in loop t 0
  
end

let () =
  let n = read_int () in
  let t = Trie.create () in
  let rec loop = function
      0 -> ()
    | i ->
      begin match Scanf.scanf "%s %s\n" (fun a b -> a,b) with
          "insert", word -> Trie.insert t word
        | _, word ->
          print_endline (if Trie.find t word then "yes" else "no")
      end;
      loop (i-1)
  in loop n

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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max(a*b, c*d) << endl;

  return 0;
}


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

int main(void) {
	long long int a, b, x; cin >> a >> b >> x;
	long long int sum = 0;

	sum += b / x;
	sum -= a / x;
	if (a%x == 0) { sum += 1; }

	cout << sum << endl;

	return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int A,B,C;
	int M;
	
	cin >> A >> B >> C;
	M=A;
	if(M<B){
		M=B;
	}
	if(M<C){
		M=C;
	}
	
	if((3*M-A-B-C)%2==0){
		cout << (3*M-A-B-C)/2;
	}else{
		cout << (3*M+3-A-B-C)/2;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(obj) (obj).begin(),(obj).end()
//typedef long long long;
long mod=1e9+7;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
 int n;
 cin>>n;
vector<long> a(n);
for(long i=0;i<n;i++)cin>>a.at(i);
long ans=0;
for(int i=0;i<60;i++){
  long x0=0;
  long x1=0;
  for(long k=0;k<n;k++){
    long x=(a.at(k)>>i)&1;
    x==0?x0++:x1++;
  }
  long cnt=x0*x1%mod;
  for(long j=0;j<i;j++)cnt=cnt*2%mod;
  ans+=cnt;
  }
cout<<ans%mod<<endl;
return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
        int N, L;
        string S[100];
        cin >> N >> L;
        for (size_t i = 0; i < N; i++) {
                cin >> S[i];
        }
        sort(S,S+N);
        for (size_t i = 0; i < N; i++) {
                cout << S[i];
        }
        cout << endl;

        return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char a[55][55];
int main()
{
    int h,w;
    scanf("%d%d",&h,&w);
    getchar();
    for(int i=0;i<=h+1;i++)
    {
        for(int j=0;j<=w+1;j++)
        {
            if(i==0||i==h+1||j==0||j==w+1)
                a[i][j]='.';
            else
            {
                scanf("%c",&a[i][j]);
            }
        }
        if(i!=0&&i!=h+1) getchar();
    }
    int flag=1;
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            if(a[i][j]=='.')
                continue;
            //t++;
            if(a[i][j-1]=='.'&&a[i][j+1]=='.'&&a[i-1][j]=='.'&&a[i+1][j]=='.')
            {
                flag=0;
                break;
            }
        }
    }
    if(flag==0) printf("No\n");
    else printf("Yes\n");
    return 0;
}


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

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    int x = 0;
    for (int i = 0; i < n; i++){
        cin >> a[i];
        x ^= a[i];
    }
    if (x == 0){
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

class Main{
    public static void main(String args[]) throws java.lang.Exception{
        Scanner sc = new Scanner(System.in);

        while(true){
            int h = sc.nextInt();
            int w = sc.nextInt();

            if(h == 0 && w == 0){
                break;
            }
            for(int i = 0; i < h; i++){
                for(int j = 0; j < w; j++){
                    System.out.print("#");
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 33292
#include <iostream>
#include <vector>

struct Node{
  Node (int z) : //constracter
    key(z),
    parent(nullptr),
    right(nullptr),
    left(nullptr)
  {}
  int key;
  Node *parent;
  Node *right, *left;
  //right == nullptr && left == nullptr
};

Node *root;

void insert(Node *z){
  Node *y=nullptr;
  Node *x=root;

  while(x!=nullptr){
    y = x;
    x = (z->key < x->key) ? x->left : x->right;
  }
  if(y == nullptr) root = z;
  else (z->key < y->key ? y->left : y->right) = z;
}

bool find(Node *f, int x){
  if(f == nullptr) return false;
  if(x == f->key) return true;
  else if(x < f->key) return find(f->left, x);
  else return find(f->right, x);
}

void inorder(Node *node){
  if(node->left != nullptr) inorder(node->left);
  std::cout << " " << node->key;
  if(node->right != nullptr) inorder(node->right);
}

void preorder(Node *node){
  std::cout << " " << node->key;
  if(node->left != nullptr) preorder(node->left);
  if(node->right != nullptr) preorder(node->right);
}

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

  int v, f;
  std::string s;
  for(int i=0; i<n; i++){
    std::cin >> s;
    if(s == "insert"){
      std::cin >> v;
      insert(new Node(v));
    }
    else if(s == "find"){
      std::cin >> f;
      if(find(root, f)) std::cout << "yes" << std::endl;
      else  std::cout << "no" << std::endl;
    }
    else{
      inorder(root);
      std::cout << std::endl;
      preorder(root);
      std::cout << std::endl;
    }
  }
  return 0;
}



Measured memory_bytes: 21796
# import sys
# input = sys.stdin.readline
# import re
import math
import itertools

def main():
    n = int(input())
    if n >= 30:
        print('Yes')
    else:
        print('No')

# 累積和
def get_camulative(l):
    return [0] + list(itertools.accumulate(l))

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def count(mazes, hc, wc):
    hc = list(hc)
    wc = list(wc)
    r = 0
    for hi, row in enumerate(mazes):
        if hi in hc:
            continue
        for wi, m in enumerate(row):
            if wi in wc:
                continue
            if m == '#':
                r += 1
    return r

def input_list():
    return list(map(int, input().split()))

def input_list_str():
    return list(map(str, input().split()))

if __name__ == '__main__':
    main()



Measured memory_bytes: 62356
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int , int> pi;

void solve()
{
	int n;
	cin>>n;
	int a[n];
	for(int i=0; i<n-1; i++)
		cin>>a[i];
	int answer[n];
	for(int i=0; i<n; i++)
		answer[i] = 0;
	for(int i=0; i<n-1; i++)
	{
		answer[a[i]-1]++;
	}
	for(int i=0; i<n; i++)
	{
		cout<<answer[i]<<"\n";
	}
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t;
	t = 1;
	while(t--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 5180
/*
???????????????????¨??????§??????????????°??????????????????
*/
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
const int LEN=100; //???????????§??????

class stack {
	int data[LEN]; 
	int top;
public:
	stack(): top(0){};
	void push(int);
	int pop();
	bool isEmpty();
	bool isFull();
};
void stack::push(int num){
	if( isFull() )
		return;
	
	data[top]=num;
	top++;
}
int stack::pop(){
	if( isEmpty() )
		return 0;

	top--;
	return data[top];
}
bool stack::isEmpty(){
	return top==0;
}
bool stack::isFull(){
	return	top==LEN;
}




int main(){

	
	stack s;

	char oper[11];

	int a, b; 

	while( scanf("%s", &oper) !=EOF ) {



		
		switch( oper[0] ){
			case '+':
				a=s.pop();
				b=s.pop();
				s.push( b+a );
				break;

			case '-':
				a=s.pop();
				b=s.pop();
				s.push( b-a );
				break;
				
			case '*':
				a=s.pop();
				b=s.pop();
				s.push( b*a );
				break;

			default:
				s.push(atoi(oper));
		}


			

		

	}

	cout<<s.pop()<<endl;



	

}

Measured memory_bytes: 1168
def m():
    n = int(input())
    s = str(input())
    w = 0
    e = 0
    for i in range(n):
        if s[i] == 'W':
            w +=1
        elif s[i] == 'E':
            e +=1

    ans = 99999999999
    lw = 0
    for j in range(n):
        if s[j] == 'W':
            w -= 1
            ans = min(e+lw, ans)
            lw +=1
        if s[j] == 'E':
            e -= 1
            ans = min(e+lw, ans)
    return ans

print(m())

Measured memory_bytes: 3828
main = do
  [a,b] <- (map read . words) <$> getLine
  if a == b then
    putStrLn "Draw"
  else if (a > b && b /= 1) || a == 1 then
    putStrLn "Alice"
  else if (b > a && a /= 1) || b == 1 then
    putStrLn "Bob"
  else
    putStrLn "Draw"



Measured memory_bytes: 508
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <limits>
#include <memory>
#include <queue>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define all(a) (a).begin(), (a).end()
#define sz(a) static_cast<int>((a).size())
#define fillchar(a, x) memset(a, x, sizeof(a))
#define rep(i, a, b) for(int i=int(a); i<=int(b); ++i)
#define irep(i, a, b) for(int i=int(a); i>=int(b); --i)
#define replr(i, a, b) rep(i, a, (b)-1)
#define reprl(i, a, b) irep(i, (b)-1, a)
#define repn(i, n) rep(i, 0, (n)-1)
#define irepn(i, n) irep(i, (n)-1, 0)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
typedef long long LL;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
typedef vector<LL> VL;
typedef vector<int> VI;
typedef vector<PII> VPI;
typedef vector<string> VS;
template<class T, class S> ostream& operator<<(ostream& os, const pair<T, S>& v) { return os<<"("<<v.first<<", "<<v.second<<")"; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& v) { os<<"["; repn(i, sz(v)) { if(i) os<<", "; os<<v[i]; } return os<<"]"; }
template<class T> bool setmax(T &_a, T _b) { if(_b>_a) { _a=_b; return true; } return false; }
template<class T> bool setmin(T &_a, T _b) { if(_b<_a) { _a=_b; return true; } return false; }
template<class T> T gcd(T _a, T _b) { return _b==0?_a:gcd(_b,_a%_b); }

int main() {
    int n, k; scanf("%d%d", &n,&k);
    VI a(n); repn(i, n) scanf("%d", &a[i]);

    VL s(n+1); s[0]=0; repn(i, n) s[i+1]=s[i]+a[i];
    VL l(n+1); l[0]=0; repn(i, n) l[i+1]=l[i]+max(a[i], 0);
    VL r(n+1); r[n]=0; irepn(i, n) r[i]=r[i+1]+max(a[i], 0);

    LL ans=-(1ll<<55);
    rep(i, k, n) {
        LL cur=max(0ll, s[i]-s[i-k]);
        cur+=l[i-k];
        cur+=r[i];
        setmax(ans, cur);
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 2944
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

const int dy[] = {-1, 0, 1, 0}, dx[] = {0, -1, 0, 1};
int h, w, n, sy, sx, gy, gx;
bool tate[60][60], yoko[60][60], v[60][60];

int calc(){
	memset(v, 0, sizeof(v));
	queue<pi> q;
	q.push(mp(sy * w + sx, 0));
	while(!q.empty()){
		int y = q.front().first / w, x = q.front().first % w;
		int c = q.front().second; q.pop();
		
		if(v[y][x]) continue;
		v[y][x] = 1;
		
		if(y == gy && x == gx) return c;
		rep(d, 4){
			int ny = y + dy[d], nx = x + dx[d];
			if(ny < 0 || ny >= h || nx < 0 || nx >= w || v[ny][nx]) continue;
			if(dy[d] && yoko[max(y, ny)][x]) continue;
			if(dx[d] && tate[y][max(x, nx)]) continue;
			q.push(mp(ny * w + nx, c + 1));
		}
	}
	return inf;
}
int main(){
	cin >> w >> h >> n;
	rep(i, n){
		int x, y, X, Y;
		cin >> x >> y >> X >> Y;
		if(x == X){
			if(y > Y) swap(y, Y);
			while(y < Y) tate[y++][x] = 1;
		}
		else{
			if(x > X) swap(x, X);
			while(x < X) yoko[y][x++] = 1;
		}
	}
	cin >> sx >> sy >> gx >> gy;
	int ans = 0, cost = calc();
	rep(i, h + 1) rep(j, w + 1){
		if(!yoko[i][j]){
			yoko[i][j] = 1;
			int tmp = calc();
			if(tmp != inf) ans = max(ans, tmp - cost);
			yoko[i][j] = 0;
		}
		if(!tate[i][j]){
			tate[i][j] = 1;
			int tmp = calc();
			if(tmp != inf) ans = max(ans, tmp - cost);
			tate[i][j] = 0;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1228
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#define pi 3.14159265358979323846264338
using namespace std;

int main() {
	int a, b;
	string op;
	while (cin >> a >> op >> b) {
		if (op == "?") {
			break;
		}
		if (op == "+") {
			cout << a + b << endl;
		}
		if (op == "-") {
			cout << a - b << endl;
		}
		if (op == "*") {
			cout << a * b << endl;
		}
		if (op == "/") {
			cout << a / b << endl;
		}
	}
}

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

const int nmax = 15;
const int amax = nmax - 1;

int main() {
  int n;
  cin >> n;
  int a[nmax];
  int x[nmax][amax], y[nmax][amax];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    for (int j = 0; j < a[i]; j++) {
      cin >> x[i][j] >> y[i][j];
      x[i][j]--;
    }
  }

  int ans = 0;
  for (int bits = 1; bits < (1 << n); bits++) {
    bool flag = true;
    int count = 0;
    for (int i = 0; i < n; i++) {
      if (!(bits >> i & 1)) continue;
      for (int j = 0; j < a[i]; j++) {
        if ((bits >> x[i][j] & 1) ^ y[i][j]) flag = false;
      }
      count++;
    }
    if (flag) ans = max(ans, count);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
   int N;
   cin >> N;
   int A[N];
   int ans=0;
   for(int i=0;i<N;i++){
     cin >> A[i];
     if (A[i]%2 == 0 && A[i]%3 != 0 && A[i]%5 != 0){
       ans = 1;
     }
   }
   if (ans == 1) cout << "DENIED";
   else cout << "APPROVED";
}


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

res = 10 ** 9
for i in range(2 ** N):
    c = 0
    s = [0 for _ in range(M)]
    for j in range(N):
        if i >> j & 1:
            c += C[j]
            for k in range(M):
                s[k] += L[j][k]
    for j in range(M):
        if s[j] < X:
            break
    else:
        res = min(res, c)

if res == 10 ** 9:
    print(-1)
else:
    print(res)


Measured memory_bytes: 68788
#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 {
	    cout << "a == b" << endl;
	}
}


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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	int n;
	vector<int> a;

	cin >> n;
	a.resize(n);
	for(int i = 0; i < n; i++)
		cin >> a[i];
	sort(BE(a));

	int sum = 0;
	for(int i = 1; i < a.size(); i++)
		sum += a[i] - a[i-1];

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
typedef complex<double> com;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }

ll mod = 1000000007;
ll modsize = 1000010;

ll modinv(ll a) {
	ll b = mod, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= mod;
	if (u < 0) u += mod;
	return u;
}

ll modpow(ll a, ll b) {
	ll ans = 1;
	a %= mod;
	while (b) {
		if (b & 1) ans = ans * a%mod;
		a = a * a%mod;
		b >>= 1;
	}
	return ans;
}

vector<ll> fac(modsize + 5);
vector<ll> inv(modsize + 5);
vector<ll> facinv(modsize + 5);

void modcalc() {
	fac[0] = fac[1] = 1; inv[1] = 1;
	facinv[0] = facinv[1] = 1;
	for (int i = 2; i < modsize; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		facinv[i] = facinv[i - 1] * inv[i] % mod;
	}
}

ll modcomb(ll n, ll k) {
	if (n < 0 || k < 0 || n < k) return 0;
	return fac[n] * facinv[k] % mod * facinv[n - k] % mod;
}

ll modperm(ll n, ll k) {
	if (n < 0 || k < 0 || n < k) return 0;
	return fac[n] * facinv[n - k] % mod;
}

ll modhom(ll n, ll k) {
	if (n < 0 || k < 0) return 0;
	if (n == 0 && k == 0) return 1;
	return modcomb(n + k - 1, k);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	modcalc();

	int h, w, a, b;
	cin >> h >> w >> a >> b;
	h--; w--;
	int ans = modcomb(h + w, h);
	rep(i, b - 1) {
		ans -= modcomb(h - a + 1 + i, i)*modcomb(w - i + a - 2, a - 2) % mod;
		if (ans < 0) ans += mod;
	}
	ans -= modcomb(h - a + b, b - 1)*modcomb(w + a - b, a - 1) % mod;
	if (ans < 0) ans += mod;
	cout << ans << endl;
}

Measured memory_bytes: 23680
#include<stdio.h>
int main(){
  int a[6];
  for(int i=0;i<6;i++){
    scanf("%d",&a[i]);
  }
  int h;//judge
  for(int j=0;j<5;j++){
    for(int k=0;k<5;k++){
      h=a[k]-a[j];
      if(h>a[5]){
        printf(":(\n");
        return 0;
      }
    }
  }
  printf("Yay!\n");
}

Measured memory_bytes: 128
N = input()
S = raw_input()

L = [0]*N
if S[0]=="W":
  L[0] = 1
for i in range(1, N):
  L[i] = L[i-1] + (S[i]=="W")

R = [0]*N
if S[-1]=="E":
  R[-1] = 1
for i in range(N-2, -1, -1):
  R[i] = R[i+1] + (S[i]=="E")

ans = N
for i in range(N):
  t = 0
  if i>0:
    t += L[i-1]
  if i<N-1:
    t += R[i+1]
  ans = min(ans, t)
print ans


Measured memory_bytes: 33880
#include <iostream>
typedef long long ll;
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll N, P;
    cin >> N >> P;
    if (N==1){
        cout << P << "\n";
        return 0;
    }
    if (P==1){
        cout << 1 << "\n";
        return 0;
    }
    ll gcd =1, k=2;
    int cont=0;
    while(P>1 && k*k<=P){
        while(P%k==0){
            //cout << k << " " << P << endl;
            P/=k;
            cont++;
            if(cont==N){ 
                gcd*=k;
                cont=0;
            }
        }
        if(k==2)k++;
        else k+=2;
        cont=0;
    }
    cout << gcd << "\n";
    return 0;
}


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

public class Main {
  private static long solve(int n, int k) {
    long v = n / k;
    long answer = v * v * v;
    if (k % 2 == 0) {
      long v2 = n / (k / 2);
      v2 = (v2 + 1) / 2;
      answer += v2 * v2 * v2;
    }
    return answer;
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    int k = reader.nextInt();
    out.println(solve(n, k));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


Measured memory_bytes: 23124
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <cstring>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
static const int INF = 1000010000;
static const int MOD = 100000;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue

int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};

struct edge {
	int u, v;
	ll cost;
};

int main() {
	int h, w;
	char mas[50][50];
	cin >> h >> w;
	int cntw = 0;
	REP(i, h) {
		REP(j, w) {
			cin >> mas[i][j];
			if (mas[i][j] == '.') cntw++;
		}
	}
	int d[50][50];
	REP(i, 50) REP(j, 50) d[i][j] = INF;

	queue<P> que;
	que.push(P(0, 0));
	d[0][0] = 1;

	while (!que.empty()) {
		P p = que.front();
		que.pop();
		if (p.first == h - 1 && p.second == w - 1) break;
		REP(i, 4) {
			int nx = p.first + dx[i]; int ny = p.second + dy[i];
			if (0 <= nx && nx < h && 0 <= ny && ny < w && mas[nx][ny] == '.' && d[nx][ny] == INF) {
				que.push(P(nx, ny));
				d[nx][ny] = d[p.first][p.second] + 1;
			}
		}
	}
	if (d[h - 1][w - 1] == INF) cout << -1 << endl;
	else cout << cntw - d[h - 1][w - 1] << endl;
}

Measured memory_bytes: 256
// #pragma GCC optimize("O3")
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace ::std;
// clang-format off
template<typename T> T nxt() {T res; cin >> res; return res;}
#define tests() for (int _ = nxt<int>(); _ >= 0; _--)
#define nxt1(t,n) t (n); cin >> n
#define nxt2(t,n,m) t (n),(m); cin >> n >> m
#define nxt3(t,n,m,k) t (n),(m),(k); cin >> n >> m >> k
#define rep(i, A) for (int i = 0 ; i < A ; i++)
#define ll long long
typedef pair<int,int> pii;typedef pair<ll, ll> pll;typedef vector<int> vi;typedef vector<vi> vvi;typedef vector<ll> vl;typedef vector<vl> vvl;
#define dbg(vari) cerr<<#vari<<" = "<<(vari)<<endl;
template<typename T,typename TT> ostream& operator<<(ostream &s,pair<T,TT> t) {return s<<"("<<t.first<<","<<t.second<<")";}
template<typename T> ostream& operator<<(ostream &s,vector<T> t){for(T ti : t)s<<ti<<" ";return s; }
#define all(x) (x).begin(), (x).end()
#define last(vec) vec[vec.size()-1]
#define has(c,x) ((c).find(x) != (c).end())
// clang-format on

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

    nxt2(int, N, M);
    vvi edges(N);

    set<int> outcomers;
    rep(i, N) {
        outcomers.emplace(i);
    }

    vi in_degree(N);

    rep(i, M) {
        nxt2(int, x, y);
        x--, y--;
        edges[x].push_back(y);
        outcomers.erase(y);
        in_degree[y]++;
    }

    stack<int> nextq;
    vi longest(N);
    vi visited(N);

    std::function<void(int)> dfs = [&edges, &longest, &in_degree, &dfs](int a) -> void {
        for (int edge : edges[a]) {
            longest[edge] = max(longest[edge], 1 + longest[a]);
            in_degree[edge]--;
            if (in_degree[edge] == 0)
                dfs(edge);
        }
    };

    for (int start : outcomers) {
        dfs(start);
    }

    cout << *max_element(all(longest)) << endl;

    return 0;
}


Measured memory_bytes: 17492
# coding: utf-8

import numpy as np

if __name__ == "__main__":
    
    input_str = input("")
    
    length_str = np.array([int(f) for f in input_str.split(" ")])
    
    if np.sum(length_str == 5) == 2 and np.sum(length_str == 7) == 1:
        print("YES")
    else:
        print("NO")

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



void solve(){
    int N, W;
    cin >> N >> W;
    vector<int> v(N), w(N), m(N);
    for(int i=0; i<N; i++)
        cin >> v[i] >> w[i] >> m[i];
    
    vector<int> dp(W+1,0), deq(W+1,0), deqv(W+1,0);

    for(int i=0; i<N; i++){
        for(int a=0; a<w[i]; a++){
            int s=0, t=0;
            for(int j=0; j*w[i]+a<=W; j++){
                int val = dp[j*w[i]+a] - j*v[i];
                while(s<t && deqv[t-1]<=val) t--;
                deq[t] = j;
                deqv[t++] = val;
                dp[j*w[i]+a] = deqv[s] + j*v[i];
                if(deq[s] == j-m[i]) s++;
            }
        }
    }
    cout << dp[W] << endl;
}


signed main(){
    cout << fixed << setprecision(18);
    cerr << fixed << setprecision(18);
    solve();
}



Measured memory_bytes: 3216
#include "bits/stdc++.h"
using namespace std;
typedef long long lint;
typedef pair<lint,lint> P;
#define rep(i, n) for (lint i = 0; i < (n); i++)
#define INF LLONG_MAX
#define MAX_V 100005
struct edge{lint to,cost;};
lint n;
vector<edge> vec[MAX_V];
lint d[MAX_V];
void dfs(lint v,int i);
void dijkstra(lint k);
void dijkstra2(lint k);
signed main(){
    cin>>n;
    rep(i,n-1){  
        lint a,b,c;
        cin>>a>>b>>c;
        a--;
        b--;
        vec[a].push_back({b,c});
        vec[b].push_back({a,c});
    }          
    lint q,k;
    cin>>q>>k;
    k--;
    dfs(k,0);
    rep(i,q){
        lint x,y;
        cin>>x>>y; 
        x--;
        y--;
         cout<<d[x]+d[y]<<endl;
    }
    return 0;
}
void dijkstra(lint k){
    priority_queue<P, vector<P>,greater<P> >que;
    fill(d,d+n,INF);
    d[k]=0;
    que.push(P(0,k));
    while(!que.empty()){
        P p=que.top();
        que.pop();
        lint v= p.second;
        if(d[v]<p.first)continue;
        for(lint i=0;i<vec[v].size();i++){
            edge temp=vec[v][i];
            if(d[temp.to]>d[v]+temp.cost){
                d[temp.to]=d[v]+temp.cost;
                que.push(P(d[temp.to],temp.to));
            }
        }
    }
}
void dijkstra2(lint k){
    queue<P>que;
    fill(d,d+n,INF);
    d[k]=0;
    que.push(P(0,k));
    while(!que.empty()){
        P p=que.front();
        que.pop();
        lint v= p.second;
        for(lint i=0;i<vec[v].size();i++){
            edge temp=vec[v][i];
            if(d[temp.to]>d[v]+temp.cost){
                d[temp.to]=d[v]+temp.cost;
                que.push(P(d[temp.to],temp.to));
            }
        }
    }
}
void dfs(lint v,int i){
    if(i==0){
        fill(d,d+n,INF);
        d[v]=0;
    }
    for(lint i=0;i<vec[v].size();i++){
            edge temp=vec[v][i];
            if(d[temp.to]>d[v]+temp.cost){
                d[temp.to]=d[v]+temp.cost;
                dfs(temp.to,i+1);
            }
    }
}

Measured memory_bytes: 14336
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

type mat = Vec<Vec<i64>>;

fn mat_zeros(n: usize, m: usize) -> mat {
    vec![vec![0i64; m]; n]
}

const big_int: i64 = 1000_000_000 + 7;

fn matmul(a: &mat, b: &mat) -> mat {
    let mut c = mat_zeros(a.len(), b[0].len());
    for i in 0..a.len() {
        for k in 0..b.len() {
            for j in 0..b[0].len() {
                c[i][j] += a[i][k] * b[k][j];
                c[i][j] %= big_int;
            }
        }
    }
    c
}

fn matpow(a: &mat, n: u64) -> mat {
    let mut b = mat_zeros(a.len(), a.len());
    for i in 0..a.len() {
        b[i][i] = 1;
    }
    let mut n = n;
    let mut a: mat = a.clone();
    while n > 0 {
        if n & 1 == 1 {
            b = matmul(&a, &b);
        }
        a = matmul(&a, &a);
        n >>= 1;
    }
    b
}

fn main() {
    let v = read_vec::<usize>();
    let (n, k) = (v[0], v[1]);
    let mut a = mat_zeros(n, n);
    for i in 0..n {
        a[i] = read_vec();
    }
    a = matpow(&a, k as u64);
    let mut ans = 0;
    for i in 0..n {
        for j in 0..n {
            ans += a[i][j];
            ans %= big_int;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
from bisect import bisect_right
n,m=map(int,input().split())
k=[[] for i in range(n+1)]
p,y=[0]*m,[0]*m
for i in range(m):
    p[i],y[i]=map(int,input().split())
    k[p[i]].append(y[i])
for i in range(n+1):
    k[i].sort()
for i in range(m):
    x=bisect_right(k[p[i]],y[i])
    ans1=str(p[i])
    while len(ans1)<6:
        ans1="0"+ans1
    ans2=str(x)
    while len(ans2)<6:
        ans2="0"+ans2
    print(ans1+ans2)


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N;
    cin >> N;
    vector<string> S(N);
    rep(i, N) cin >> S[i];

    ll ans = 0;

    map<string, ll> counter;
    rep(i, N) {
        string s = S[i];
        sort(s.begin(), s.end());
        counter[s]++;
    }
    for (auto &p : counter) {
        if (p.second > 1) {
            ans += (p.second - 1) * p.second / 2;
        }
    }
    cout << ans << '\n';
}

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


Measured memory_bytes: 16640
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


int N;

int main() {
    while (cin >> N) {
        map<long long, long long > ma;
        for (int i = 0; i < N; ++i) {
            long long a;
            cin >> a;
            ma[a]++;
        }
        
        long long res = 0;
        EACH(it, ma) {
            if (it->second & 1) ++res;
        }
        cout << res << endl;
    }
}















Measured memory_bytes: 6528
x1,y1,x2,y2 = map(int, input().split())
move = [x2 - x1, y2 - y1]
x3, y3 = x2 - move[1], y2 + move[0]
x4, y4 = x3 - move[0], y3 - move[1]
print(x3, y3, x4, y4)

Measured memory_bytes: 9124
import math
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
    
    def reset(self):
        for i in range(len(self.tree)):
            self.tree[i] = 0

get_ints = lambda: [int(st) for st in input().split()]
N=int(input())
inarr=get_ints()
sorted_in = sorted(inarr)
comb = N*(N+1) // 2

bit = Bit(2*N+1)
def binsearch(lft, rgt):
    half = (lft + rgt) // 2
    if lft >= half:
        return half
    summed = 0
    res = 0
    bit.reset()
    bit.add(N, 1)
    for x in inarr:
        value = 1 if x >= sorted_in[half] else -1
        summed += value
        count = bit.sum(N + summed)
        bit.add(N + summed, 1)
        res += count
    return binsearch(half, rgt) if res >= math.ceil(comb/2) else binsearch(lft, half)

res = binsearch(0, N)
print(sorted_in[res])


Measured memory_bytes: 63984
/*
AtCoder Beginner Contest 092 B - Chocolate 結果:
*/

#include<stdio.h>

//#define DEBUG1
//#define DEBUGF

int main() {
	int n,d,x;
	int a[100];
	int ans = 0;
	scanf("%d %d %d", &n, &d, &x);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
#ifdef DEBUG1
	printf("%d\n%d\n%d\n", n, d, x);
	for (int i = 0; i < n; i++) {
		printf("%d", &a[i]);
}
#endif
	for (int i = 0; i < n; i++) {
		ans += 1 + ((d - 1) / a[i]);
	}
	ans += x;
	printf("%d\n", ans);
#ifdef DEBUGF
	getch();
#endif
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
 
 
signed main(){
 
	lli n,m;
	cin>>n>>m;
	vector<vector<lli>> v(n);
	REP(i,0,m){
		lli a,b;
		cin>>a>>b;
		a--,b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
 
	vector<lli> per;
	REP(i,0,n)per.push_back(i);
 
	lli ans=0;
	do{
		if(DEBUG)REP(i,0,per.size())cout<<per[i]<<" ";
 
		bool ok=true;
		lli s = per[0];
		if(s!=0)continue;
		REP(i,1,n){
			lli next = per[i];
 
			if(DEBUG)cout<<"s="<<s<<"next="<<next<<endl;
			bool fOk = false;
			REP(k,0,v[s].size()){
				if(DEBUG)cout<<"v="<<v[s][k]<<endl;
				if(v[s][k]==next){
					fOk = true;
					break;
				}
			}
			if(!fOk){
				ok=false;
				break;
			}
			s = next;
		}
		if(ok){
			ans++;
		}
 
	}while(next_permutation(per.begin(),per.end()));
 
	cout<<ans<<endl;
 
  return 0;
}

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

int main()
{
	long long x;
	cin >> x;
	long long p=100,step=0;
	while(p<x)
	{
		p+=p/100;
		step++;
	}
	
	cout << step << endl;
	return 0;
}

Measured memory_bytes: 3592