akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	private class Node {
		int parent;
		private Node(int x) {
			parent = x;
		}
	}
	
	private class DisjointSet {

		private Node[] p;
		private int[] rank;
		
		public DisjointSet(int size) {
			p = new Node[size];
			rank = new int[size];
			for (int i = 0; i < size; i++) {
				makeSet(i);
			}
		}

		private void makeSet(int x) {
			p[x] = new Node(x);
			rank[x] = 0;
		}
		
		public boolean same(int x, int y) {
			return findSet(x).parent == findSet(y).parent;
		}

		private Node findSet(int x) {
			while (x != p[x].parent) {
				x = p[x].parent;
			}
			return p[x];
		}
		
		public void unite(int x, int y) {
			link(findSet(x).parent, findSet(y).parent);
		}

		private void link(int x, int y) {
			if (rank[x] < rank[y]) {
				p[x].parent = y; 
			} else {
				p[y].parent = x;
				if (rank[x] == rank[y]) {
					rank[y]++;
				}
			}
		}
	}
	
	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	
	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(reader.readLine());
		int n = Integer.parseInt(st.nextToken());
		DisjointSet ds = new DisjointSet(n);
		int q = Integer.parseInt(st.nextToken());
		for (int i = 0; i < q; i++) {
			st = new StringTokenizer(reader.readLine());
			int c = Integer.parseInt(st.nextToken());
			int x = Integer.parseInt(st.nextToken());
			int y = Integer.parseInt(st.nextToken());
			if (c == 0) {
				ds.unite(x, y);
			} else {
				System.out.println(ds.same(x, y)?"1":"0");
			}
		}
		reader.close();
	}
}


Measured memory_bytes: 61180
#include<iostream> 
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <sstream>
#include <vector>

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)



int main() {
	int n;
	cin >> n; 
		rep(i, n+1) {
			if ((i * 108)/100  == n) {
				cout << i << endl;
				return 0;
			}
		}
		cout << ":(" << endl;
	
	return 0;
}

Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

import static java.lang.System.in;

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        int N = Integer.parseInt(reader.readLine());
        double[] heads = new double[N+1];
        double[] tails = new double[N+1];
        String[] lo =reader.readLine().split(" ");
        for (int i = 1; i <=N ; i++) {
            double p = Double.parseDouble(lo[i-1]);
            heads[i] = p;
            tails[i] = 1.0-p;
        }
        double[][] dp = new double[N+1][N+1];
        dp[0][0] = 1.0;
        for (int i = 1; i <=N ; i++) {
            for (int j = 0; j <=i ; j++) {
                if(j-1>=0) dp[i][j] = heads[i]*dp[i-1][j-1]+tails[i]*dp[i-1][j];
                else dp[i][j] = tails[i]*dp[i-1][j];
            }
        }
        //System.out.println(Arrays.deepToString(dp));
        double res= 0.000000000;
        for (int i = N; i > (N/2); i--) {
            res=res+dp[N][i];
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 132412
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <cmath>
#include <queue>
using namespace std;
using i64 = int64_t;
#define rep(i, j, n) for(int i = j; i < n; ++i)
#define rrep(i, j, n) for(int i = n - 1; j <= i; --i)
constexpr i64 MOD = 1000000007;
constexpr i64 INF = 1LL << 60;



int main() {
	string s, t;
	cin >> s >> t;
	int n = (int)s.size();
	int m = (int)t.size();
	rrep(i, 0, n - m + 1) {
		bool ok = true;
		rep(j, 0, m) {
			if (s[i + j] != '?' && s[i + j] != t[j]) {
				ok = false;
				break;
			}
		}
		if (ok) {
			rep(j, 0, m) {
				if (s[i + j] == '?') s[i + j] = t[j];
			}
			rep(i, 0, n) if (s[i] == '?') s[i] = 'a';
			cout << s;
			return 0;
		}
	}
	cout << "UNRESTORABLE";
	return 0;
}

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

int main() {
  long long n;
  cin >> n;
  
  if(n==1){
    cout << 0 << endl;
    return 0;
  }
  
  map<long long, int> factors;
  
  long long a = 2;
  while(n >= a*a){
    if(n%a==0){
      factors[a]++;
      n/=a;
    } else {
      a++;
    }
  }
  
  factors[n]++;
  
  int times = 0;
  
  for (const auto& [key, value] : factors){
    int init = 1;
    int map_value = value;
    while(map_value-init>=0){
      times++;
      map_value-=init;
      init++;
    }
  }
  
  cout << times << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define DEBUG2(x, y) cerr << #x << ": " << x << " " << #y << ": " << y << "\n"
#define DEBUG3(x, y, z)                                                        \
  cerr << #x << ": " << x << " " << #y << ": " << y << " " << #z << ": " << z  \
       << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V)) {                                                         \
    cerr << v << " ";                                                          \
  }                                                                            \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
#define pint pair< int, int >
#define ld long double
using namespace std;
template < class T > bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567, INF2 = INF * INF;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int H, W;
  cin >> H >> W;
  if (H % 3 == 0 || W % 3 == 0) {
    print(0);

  } else {
    int ans = INF;
    // int wp = W / 2 + 1;
    // int wm = W / 2 - 1;
    REP(i, 2) {
      //(wm * H) / (W + wm)
      // 1 + (wp * H) / (W + wp)
      FORS(j, 1, H - 1) {
        if (j <= 0 || j >= H)
          continue;
        int v[3] = {W * j, (W - W / 2) * (H - j), W / 2 * (H - j)};
        sort(v, v + 3);
        // assert(v[0] + v[1] + v[2] == 1 + W * H);
        // DEBUG3(v[0], v[1], v[2]);
        chmin(ans, v[2] - v[0]);
      }
      swap(H, W);
    }
    print(min({H, W, ans}));
  }
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func min(m, n int) int {
  if n < m {
    return n
  }
  return m
}

func main () {
	var p, q, r int
	fmt.Scan(&p, &q, &r)
  	a := p + q
  	b := q + r
	c := r + p
  	fmt.Println(min(min(a, b), c))
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#pragma warning(disable:4996)
#define SIZE 100001
using namespace std;

int main() {
    /*    scanf("%lld", &N);
        for (int i = 1; i <= N; i++) {
            scanf("%lld", &A[i]);
            if (A[i] <= 100) cnt[A[i]]++;
        }

        long long Answer = 0;
        for (int i = 1; i <= 50; i++) Answer += cnt[i] * cnt[101 - i];
        cout << Answer << endl;
    */
    int N, M;
    scanf("%d %d", &N, &M);
    int H[SIZE];
    int flag[SIZE];
    int A[SIZE];
    int B[SIZE];
    //H = (int*)malloc(sizeof(int));
    //flag = (int*)malloc(sizeof(int));
    //A = (int*)malloc(sizeof(int));
    //B = (int*)malloc(sizeof(int));
    int count = 0;
    for (int i = 1; i <= N; i++) {
        scanf("%d", &H[i]);
        flag[i] = 0;
    }
    for (int i = 1; i <= M; i++) {
        scanf("%d %d", &A[i], &B[i]);
    }
    for (int i = 1; i <= M; i++) {
        if (H[A[i]] < H[B[i]]) {
            flag[A[i]] = 1;
        }
        else if (H[A[i]] == H[B[i]]) {
            flag[A[i]] = 1; flag[B[i]] = 1;
        }
        else flag[B[i]] = 1;
    }
    for (int i = 1; i <= N; i++) {
        if (flag[i] == 0) count++;
    }
    printf("%d\n", count);

    return 0;
}

Measured memory_bytes: 5400
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

int A[3010];
ll mod=998244353, dp[3010][3010]={};

int main() {
	int N, S;
	cin >> N >> S;
	for(int i=0; i<N; ++i) cin >> A[i];
	for(int i=0; i<=S; ++i) dp[0][i]=0;
	ll ans=0;
	for(int i=0; i<N; ++i){
		for(int j=0; j<=S; ++j){
			if(j<S) dp[i+1][j]=dp[i][j];
			if(j==A[i]) (dp[i+1][j] += i+1) %= mod;
			if(j>A[i]) (dp[i+1][j] += dp[i][j-A[i]]) %= mod;
		}
		(ans += (dp[i+1][S]*(N-i))%mod) %= mod;
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
  int a[200],b[200],c[200],sum1=0,sum2=0,ans=0; 
  for(int i=0;i<5;i++){
    cin>>a[i];
  }
  for(int i=0;i<5;i++){
    b[i]=a[i]%10;
    c[i]=(10-b[i])%10;
  }
  sort(c,c+5);
  for(int i=0;i<5;i++){
    sum1+=a[i];
    sum2+=c[i];
  }
  ans=sum1+sum2-c[4];
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V)) {                                                         \
    cerr << v << " ";                                                          \
  }                                                                            \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template < class T > bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;
  vec< bool > W(31, false);
  W[A] = true;
  W[B] = true;
  FORS(i, 0, 30) {
    if (W[i]) {
      if (i + A <= 30)
        W[i + A] = true;
      if (i + B <= 30)
        W[i + B] = true;
    }
  }
  vec< bool > S(3001, false);
  S[0] = true;
  vec< int > Slis;
  FORS(i, 0, 3000) {
    if (S[i]) {
      if (i + C <= 3000)
        S[i + C] = true;
      if (i + D <= 3000)
        S[i + D] = true;
    }
  }
  FORS(i, 0, 3000) {
    if (S[i])
      Slis.pb(i);
  }
  int ans[2] = {100 * A, 0};
  double maxE = 0;

  FORS(i, 1, F / 100) {
    if (!W[i])
      continue;
    int val = E * i;
    // int sug;
    // REPR(j, min(F - i * 100, val)) {
    //   if (S[j]) {
    //     sug = j;
    //     break;
    //   }
    // }
    auto itr = upper_bound(ALL(Slis), min(F - i * 100, val));
    int sug = *(itr - 1);
    double nodo = 100.0 * sug / (sug + 100.0 * i);

    bool f = chmax(maxE, nodo);
    if (f) {
      ans[0] = i * 100 + sug;
      ans[1] = sug;
    }
  }
  cout << ans[0] << " " << ans[1] << "\n";
}


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

using namespace std;

int gcd(int a,int b);

int main(){
	int n,x;
	cin >> n >> x;
	int ans = 0;
	for(int i = 0;i < n;i++){
		int tx;
		cin >> tx;
		if(i == 0){
			ans = abs(tx - x);
		}else{
			ans = gcd(ans,abs(tx - x));
		}
	}
	
	cout << ans << endl;
	return 0;
}

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

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

namespace ConsoleApp6
{
    class Program
    {
        static void Main(string[] args)
        {for (int i = 1; i <= 9; i++)
            {
                for (int j = 1; j <= 9; j++)
                    Console.WriteLine(i + "x" + j + "=" + i * j);
            }
    
        }
    }
}

Measured memory_bytes: 9036
#include<stdio.h>

int main(void){
   char name[100];
   scanf("%s",name);
   int cnt=0;
   for(int i=0;name[i]!='\0';i++){
      cnt++;
   }
   for(int i=0;i<cnt;i++){
      printf("x");
   }
   return 0;
}

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

using namespace std;

int main(){

int n;
cin>>n;
map<string,int>judge;
string qtr[4]={"AC","WA","TLE","RE"};
for(int i = 0 ; i < n ; i++ ){
    string str;
    cin>>str;
    judge[str]++;

}
for(int i = 0;i<4;i++){
     cout<<qtr[i]<<" x "<<judge[qtr[i]]<<endl;
}



return 0;
}


Measured memory_bytes: 3640
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a = read::<i64>();
    let b = read::<i64>();
    println!("{}", if a < 10 && b < 10 { a * b } else { -1 });
}


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

#define X first
#define Y second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()
#define rep(i, st, n) for (int i = (st); i < (n); ++i)
#define repinv(i, st, n) for (int i = ((n)-1); i >= (st); --i)
#define MEM(a, b) memset(a, b, sizeof(a));
#ifdef LOCAL
#define debug(x) std::cerr << #x << ": " << x << endl
#else
#define debug(x) 860111
#endif
#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileIO(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;

//mt19937 mrand(random_device{}());
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll mod=1e9+7;
//int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
pii operator+(const pii&x, const pii&y) { return mp(x.X+y.X, x.Y+y.Y);}
pii operator-(const pii&x, const pii&y) { return mp(x.X-y.X, x.Y-y.Y);}
//INT_MAX, ULLONG_MAX, LLONG_MAX or numeric_limits<int>::min()

inline ll read(){
	char ch=getchar();ll x=0,f=0;
	while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return f?-x:x;
}

//------------------------------------------------------------------------//
int T;
const int maxn = 2e5+7;
int n;
//ll a[maxn];

//check T
void solve()
{
  string s;
  map<string, int> votes;
	cin >> n; rep(i, 0, n) cin >> s, votes[s]++;
  int maxv = 0;
  vector<string> mvp;
  for(auto it = votes.begin(); it != votes.end(); it++)
  {
    if(it->Y > maxv)  mvp.clear(), mvp.pb(it->X), maxv = it->Y;
    else if(it->Y == maxv) mvp.pb(it->X);
    else continue;
  }
  sort(all(mvp));
  rep(i, 0, mvp.size()) cout << mvp[i] << endl;
  return;
}


signed main()
{
  fastIO();
  T = 1;
  //cin >> T; //this
  while(T--) solve();
  return 0;
}


Measured memory_bytes: 25584
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {
	a := readf()
	b := readf()
	h := readf()
	m := readf()
	fmt.Println(math.Sqrt(a*a + b*b - 2*a*b*math.Cos(diff(360*(h/12)+30*(m/60), 360*(m/60))*math.Pi/180)))
}

func diff(a, b float64) float64 {
	if a > b {
		return a - b
	}
	return b - a
}

// IO---------------------------------------------------

func readi() (n int) {
	fmt.Scan(&n)
	return
}

func readf() (n float64) {
	fmt.Scan(&n)
	return
}

func reads() (n string) {
	fmt.Scan(&n)
	return
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func readSlice() []string {
	return strings.Split(readLine(), " ")
}

func atoi(a []string) (b []int) {
	b = make([]int, len(a))
	for i := range a {
		b[i], _ = strconv.Atoi(a[i])
	}
	return
}

func atof(a []string) (b []float64) {
	b = make([]float64, len(a))
	for i := range a {
		b[i], _ = strconv.ParseFloat(a[i], 64)
	}
	return
}

func readSlice2(n int) (a []int, b []int) {
	a = make([]int, n)
	b = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func readFloatSlice2(n int) (a []float64, b []float64) {
	a = make([]float64, n)
	b = make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func yesOrNo(b bool) {
	if b {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}

func yesorNO(b bool) {
	if b {
		fmt.Println("YES")
		return
	}
	fmt.Println("NO")
}

func yesorno(b bool) {
	if b {
		fmt.Println("yes")
		return
	}
	fmt.Println("no")
}

// calc---------------------------------------------------

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

func ave(a []int) (ave int) {
	for i := 0; i < len(a); i++ {
		ave += a[i]
	}
	ave /= len(a)
	return
}

func eq(a []string, b []string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] != b[i] {
			return false
		}
	}
	return true
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func max(a ...int) int {
	max := a[0]
	for i := 1; i < len(a); i++ {
		if max < a[i] {
			max = a[i]
		}
	}
	return max
}

func min(a ...int) int {
	min := a[0]
	for i := 1; i < len(a); i++ {
		if min > a[i] {
			min = a[i]
		}
	}
	return min
}

func mid(a []int) int {
	sort.Ints(a)
	return a[len(a)/2]
}

func sum(a []int) (ans int) {
	for i := range a {
		ans += a[i]
	}
	return
}


Measured memory_bytes: 1860
a, b = map(int, input().split())
if a == 1 and b != 1:
	print('Alice')
	exit()
if  b == 1 and a != 1:
	print('Bob')
	exit()
if a == 1 and b == 1:
	print('Draw')
	exit()

if a > b:
	print('Alice')
elif b > a:
	print('Bob')
else:
	print('Draw')

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

int main()
{
    int n;
    std::cin >> n;
    std::vector<int> a(n),b(n),c(n);
    for(int i = 0; i < n; i++)std::cin >> a[i];
    for(int i = 0; i < n; i++)std::cin >> b[i];
    for(int i = 0; i < n; i++)std::cin >> c[i];
    std::sort(a.begin(), a.end());
    std::sort(b.begin(), b.end());
    std::sort(c.begin(), c.end());
    long long cnt = 0;
    //Bの決め打ち
    for(int i = 0; i < n; i++){
        auto itr1 = std::lower_bound(a.begin(), a.end(), b[i]);
        //if(*itr1 == b[i])itr1--;
        int itr = itr1 - a.begin(); 
        int itr2 = c.end() - std::upper_bound(c.begin(), c.end(),b[i]);
        cnt += (long long)itr * itr2;
    }
    std::cout << cnt << std::endl;

}

Measured memory_bytes: 1536
import sys

buildings = [[[0 for i in xrange(10)] for j in xrange(3)] for k in xrange(4)]

n = input()

for i in xrange(n):
	b, f, r, v = map(int, raw_input().split())
	buildings[b-1][f-1][r-1] += v

for i in xrange(4):
	if i != 0:
		print "####################"
	for j in xrange(3):
		for k in xrange(10):
			sys.stdout.write(" "+str(buildings[i][j][k]))
		print

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

int main() {
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    double res = 0;
    while(n--) {
        double a;
        string str;
        cin >> a >> str;

        if (str == "JPY") res += a;
        else res += 380000.0 * a;
    }

    cout << fixed << setprecision(4);
    cout << res << endl;
    return 0;
}


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

struct Problem {

    void Solve() {
        UL N, L; scanf("%d%d", &N, &L);
        vector<UL> A(N); rep(i, N) scanf("%d", &A[i]);
        deque<UL> Q;
        rep(i, N) {
            while (Q.size()) {
                if (A[Q.back()] < A[i]) break;
                Q.pop_back();
            }
            Q.push_back(i);
            if (i > L - 1) printf(" ");
            if (i >= L - 1) printf("%d", A[Q.front()]);
            if (Q.front() + L - 1 == i) Q.pop_front();
        }
        printf("\n");
    }
};
int main() {
    unique_ptr<Problem> p(new Problem());
    //cout << fixed << setprecision(10);
    p->Solve();
    return 0;
}




Measured memory_bytes: 6792
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n, t = LI()
ab = [LI() for _ in range(n)]
ab.sort(key = itemgetter(0))

dp = [[0] * (t+3001) for _ in range(n+1)]
for i in range(1, n+1):
    a, b = ab[i-1]
    for j in range(t + 3001):
        dp[i][j] = dp[i-1][j]
    for j in range(t):
        dp[i][j+a] = max(dp[i-1][j+a], dp[i-1][j] + b)

ans = 0
for i in range(t-1, t + 3001):
    ans = max(ans, dp[n][i])
print(ans)

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

const int maxn = 1e5 + 10;

int n;
int a[maxn];
map<int,int>q;

int main()
{
    scanf("%d", &n);
    for(int i = 1; i <= n; i++)
    {
        scanf("%d", &a[i]);
        q[a[i]]++;
    }
    sort(a+1, a+n+1);
    int cnt = 0;
    int ans;
    for(int i = 2; i < 1e5 ;i++)
    {
        ans = q[i] + q[i-1] + q[i-2];
        cnt = max( ans ,cnt );
    }
    printf("%d\n", cnt);
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll a,b,c,n;
vl x,y,z;

int main(){
	cin>>a>>b>>c>>n;
	ll res=2*(a*b+b*c+c*a)+6*n;
	x=y=z=vl(n);
	for(int i=0;i<n;i++){
		cin>>x[i]>>y[i]>>z[i];
		if(x[i]==0) res-=2;
		if(y[i]==0) res-=2;
		if(z[i]==0) res-=2;
		if(x[i]==a-1) res-=2;
		if(y[i]==b-1) res-=2;
		if(z[i]==c-1) res-=2;
	}
	for(int i=0;i<n;i++) for(int j=0;j<n;j++){
		int d=abs(x[i]-x[j])+abs(y[i]-y[j])+abs(z[i]-z[j]);
		if(d==1){
			res--;
//			cout<<i<<' '<<j<<endl;
		}
	}
	cout<<res<<endl;
}


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

int a;
int s[4];
bool ch;
char op[3];

void solve(int now,int n,char opt[]){
  if(ch ==0){
    if(n!=3){
      char a[3],b[3];
      for(int i =0;i<3;i++){
	a[i] = opt[i];
	b[i] = opt[i];
      }
      a[n] = '+';
      b[n] = '-';
      solve(now+s[n+1],n+1,a);
      solve(now-s[n+1],n+1,b);
    }
    else {
      if(now == 7){
	ch++;
	for(int i =0;i<3;i++)op[i] = opt[i];
      }
    }
  
  }
  
}

int main(){
  int i;
  char opti[3];
  cin >> a;
  for(i=0;i<4;i++){
    s[3-i] = a%10;
    a /=10;
  }
  solve(s[0],0,opti);
  cout << s[0] << op[0] << s[1] << op[1] << s[2] << op[2] << s[3] <<"=7" << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

struct data{
    int a,b,c;
    bool operator < (data obj) const{
        return ((this->a)-(this->b)) > obj.a-obj.b;
    }
};

signed main(){
    int x,y,z;
    cin>>x>>y>>z;
    int n = x+y+z;
    vector<data> v(n);
    rep(i,n){
        int a,b,c;
        cin>>a>>b>>c;
        v[i] = data{a,b,c};
    }
    
    sort(all(v));
    
    
    rep(i,n){
        v[i].a -= v[i].c;
        v[i].b -= v[i].c;
    }
    
    vector<int> dax(n+1,0), daz(n+1,0), dby(n+1,0), dbz(n+1,0);
    
    priority_queue<pii,vector<pii>,greater<pii>> pq;
    rep(i,n){
        if(i<x){
            pq.push(pii(v[i].a,v[i].c));
            dax[i+1] = dax[i] + v[i].a+v[i].c;
        }else{
            pq.push(pii(v[i].a,v[i].c));
            dax[i+1] = dax[i] + (v[i].a+v[i].c);
            
            dax[i+1] -= pq.top().first+pq.top().second;
            daz[i+1] = daz[i] + pq.top().second;
            pq.pop();
        }
    }
    
    while(pq.size())pq.pop();
    reverse(all(v));
    rep(i,n)swap(v[i].a,v[i].b);
    swap(x,y);
    
    rep(i,n){
        if(i<x){
            pq.push(pii(v[i].a,v[i].c));
            dby[i+1] = dby[i] + v[i].a+v[i].c;
        }else{
            pq.push(pii(v[i].a,v[i].c));
            dby[i+1] = dby[i] + (v[i].a+v[i].c);
            
            dby[i+1] -= pq.top().first+pq.top().second;
            dbz[i+1] = dbz[i] + pq.top().second;
            pq.pop();
        }
    }

    swap(x,y);
    int ans = 0;
    for(int i=x;i<=n-y;i++){
//        cout<<i<<" : "<<dax[i]<<" "<<daz[i]<<" "<<dby[n-i]<<" "<<dbz[n-i]<<endl;
        ans = max(ans,dax[i]+daz[i]+dby[n-i]+dbz[n-i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 7924
#encoding: utf-8

n,k=map(int,input().split())

a=[int(i) for i in input().split()]

for i in range(len(a)):
    if a[i]==1:
        num=i
count=0
num0=num
num1=num
#up
while(1):
    num+=(k-1)
    count+=1
    if num>=n:
        num0-=num-n
        break

while(1):
    if num0<=1:
        break
    num0-=(k-1)
    count+=1
count2=0
num01=num1
while(1):
    num01-=(k-1)
    count2+=1
    if num01<=1:
        num1+=1-num01
        break
while(1):
    if num1>=n:
        break
    num1+=(k-1)
    count2+=1
print(min(count,count2))


Measured memory_bytes: 13880
n=int(input())
a=list(map(int,input().split()))
sumFrontHalf=0
halfIndex=0
sumA=sum(a)
for i in range(n):
  sumFrontHalf+=a[i]
  if sumFrontHalf>=sumA/2:
    halfIndex=i
    break
sumBackHalf=sumA-sumFrontHalf+a[halfIndex]
if sumFrontHalf<sumBackHalf:
  print(sumFrontHalf-sumBackHalf+a[halfIndex])
else:
  print(sumBackHalf-sumFrontHalf+a[halfIndex])

Measured memory_bytes: 26396
n = int(input())

if n % 10 == 2 or n % 10 == 4 or n % 10 == 5 or n % 10 == 7 or n % 10 == 9:
    print('hon')
elif n % 10 == 0 or n % 10 == 1 or n % 10 == 6 or n % 10 == 8:
    print('pon')
elif n % 10 == 3:
    print('bon')

Measured memory_bytes: 9120
#include <stdio.h>

int main(void)

{
    int a, b;

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

    if (a < b)
    {
        puts("a < b");
    }
    else if (a > b)
    {
        puts("a > b");
    }
    else
    {
        puts("a == b");
    }

    return 0;
}


Measured memory_bytes: 2600
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

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

int i,j,k,n,m,cases[50][150],wid,www;

int main(){
	while(scanf("%d %d",&m,&n)*m*n){
	for(i=1;i<=n;i++){
		scanf("%d",&cases[1][i]);
		cases[1][i]+=cases[1][i-1];
	}

	for(i=2;i<=m;i++){
		for(j=1;j<=n;j++){
			wid=9999999;
			for(k=1;k<=j;k++){
				www=MAX(cases[i-1][k],cases[1][j]-cases[1][k]);
				if(www<wid)wid=www;
			}
			cases[i][j]=wid;
		}
	}

	printf("%d\n",cases[m][n]);

	}
	return 0;
}

Measured memory_bytes: 616
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>

using namespace std;

int main(){
  int A, B, C; cin >> A >> B >> C;

  if (A <= C && C <= B) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <istream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <set>
#include <cstring>
#include <string.h>
#include <iomanip>
#include <queue>
#include <stack>
#include <list>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vi lnum;
typedef long double ld;

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define pb push_back
#define mp make_pair
#define pi 3.14159265358979
#define fopen freopen("input.txt", "r", stdin); freopen("output.txt","w", stdout)
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, N) FOR(i, 0, N)
#define REPR(i, N) RFOR(i, N, 0)
#define FILL(A,value) memset(A,value,sizeof(A))
#define f first
#define s second

const int MOD9 = 1e9 + 7;
const int MOD91 = 1e9 + 9;
const ll MOD12 = 1e12 + 39LL;
const ll MOD15 = 1e15 + 37LL;
const ll INF = 1000LL * 1000* 1000* 1000* 1000* 1000;
const int base = 330;
const int MAXN = 2e5 + 6;
const double EPS = 1e-12;

using namespace std;
int Sum = 0;
const ll mod = 1000 * 1000 * 1000 + 7;
int n;
string s , t;
string ans ;
int main()
{
	cin >> n >> s >> t;
	for(int i = 0; i < n; i++)
	{
		bool bad = false;
		for(int j = 0; j < n - i; j++)
			if(s[i + j] != t[j])
				bad = true;
		if(bad == false)
		{
			ans = s;
			for(int j = n - i; j < n; j++)
				ans += t[j];
			cout << ans.size();
			return 0;
		}
	}
	s += t;
	cout << s.size();
	//freopen("input.txt" , "r" , stdin);

	//system("pause");
}







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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
#define vvp vector<vector<pair<int,int>>>

const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<int>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

#define all(v) v.begin(),v.end()
#define output_s(a) printf("%s\n",(a).c_str())

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i--)
#define RepA(x) for(auto &item:(x))

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template<typename TypeInt> //最大公約数
TypeInt GCD(TypeInt a,TypeInt b){
    if(a%b==0) return b;
    else return GCD(b,a%b);
}
template<typename TypeInt> //最小公倍数
TypeInt LCM(TypeInt a,TypeInt b){
    return a*b/GCD(a,b);
}

int IN_int(){
    int x;
    scanf("%d",&x);
    return x;
}

//library----------------------------------------------

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

const int NMAX = 100;
bool flag;


int main(){
    CIN(N,K);
    vi l(N);
    rep(i,N)cin>>l[i];
    sort(all(l),greater<int>());
    int ans=0;
    rep(i,K) ans+=l[i];
    printf("%d\n",ans);

    return 0;
}

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

#define DEBUG 0

#if DEBUG
  #define DLOG(...) fprintf(stderr, __VA_ARGS__)
#else
  #define DLOG(...)
#endif

void debug(auto f) {
#if DEBUG
  f();
#endif
}

ll H, W, N;
ll sr, sc;
string S, T;

ll dirX(char c) {
  if (c == 'L')  return -1;
  if (c == 'R')  return 1;
  return 0;
}

ll dirY(char c) {
  if (c == 'D')  return 1;
  if (c == 'U')  return -1;
  return 0;
}

bool myout(ll y, ll x)  {
  return y > H || y < 1 || x > W || x < 1;
}

bool game(char cT, char cA) {
  ll y = sr;
  ll x = sc;
  ll mvTy = dirY(cT);
  ll mvTx = dirX(cT);
  ll mvAy = dirY(cA);
  ll mvAx = dirX(cA);
  for (ll i = 0; i < N; i++) {
    if (S.at(i) == cT) {
      y += mvTy;
      x += mvTx;
      if (myout(y, x))  return true;
    }
    if (T.at(i) == cA)  {
      ll y1 = y + mvAy;
      ll x1 = x + mvAx;
      if (!myout(y1, x1)) {
	y = y1;
	x = x1;
      }
    }
  }
  return false;
}

int main() {
#if !DEBUG
  ios_base::sync_with_stdio(false);
#endif

  cin >> H >> W >> N >> sr >> sc >> S >> T;

  bool result = false;
  result = result || game('R', 'L');
  result = result || game('L', 'R');
  result = result || game('D', 'U');
  result = result || game('U', 'D');
  if (result) {
    cout << "NO" << endl;
  }else {
    cout << "YES" << endl;
  }

  return 0;
}



Measured memory_bytes: 920
#include<bits/stdc++.h>
using namespace std;
#define N 4
#define N2 16
#define LIM 100
int dx[4]={0,-1,0,1};
int dy[4]={1,0,-1,0};
char dir[4]={'r','u','l','d'};
int MDT[N2][N2];
struct puzzle{int f[N2],space,MD;};
puzzle state;
int lim;
int path[LIM];
int getallMD(puzzle pz){
  int sum=0;
  for(int i=0;i<N2;i++){
    if(pz.f[i]==N2)continue;
    sum+=MDT[i][pz.f[i]-1];
  }
  return sum;
}
bool solved(){
  for(int i=0;i<N2;i++)if(state.f[i]!=i+1)return false;
  return true;
}
bool dfs(int de,int pr){
  if(state.MD==0)return true;
  if(de+state.MD>lim)return false;
  int sx=state.space/N;
  int sy=state.space%N;
  puzzle tmp;
  for(int r=0;r<4;r++){
    int tx=sx+dx[r];
    int ty=sy+dy[r];
    if(tx<0||ty<0||tx>=N||ty>=N)continue;
    if(max(pr,r)-min(pr,r)==2)continue;
    tmp=state;
    state.MD-=MDT[tx*N+ty][state.f[tx*N+ty]-1];
    state.MD+=MDT[sx*N+sy][state.f[tx*N+ty]-1];
    swap(state.f[tx*N+ty],state.f[sx*N+sy]);
    state.space=tx*N+ty;
    if(dfs(de+1,r)){
      path[de]=r;
      return true;
    }
    state=tmp;
  }
  return false;
}
string iterative(puzzle in){
  in.MD = getallMD(in);
  for(lim=in.MD;lim<=LIM;lim++){
    state=in;
    if(dfs(0,-100)){
      string ans="";
      for(int i=0;i<lim;i++)ans+=dir[path[i]];
      return ans;
    }
  }
  return "unsolvable";
}
int main(){
  for(int i=0;i<N2;i++)
    for(int j=0;j<N2;j++)
      MDT[i][j]=abs(i/N-j/N)+abs(i%N-j%N);
  puzzle in;
  for(int i=0;i<N2;i++){
    cin >> in.f[i];
    if(in.f[i]==0){
      in.f[i]=N2;
      in.space=i;
    }
  }
  string ans = iterative(in);
  cout << ans.size() << endl;
  return 0;
}

Measured memory_bytes: 3228
#include <stdio.h>
#define N 6
int main(void)
{
    int n,i;
    scanf("%d",&n);
    for(i=0;i<3;i++){
        if(n%10 == 7){
            printf("Yes");
            return 0;
        }
        n=n/10;
    }
    printf("No");
}


Measured memory_bytes: 1732
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
using namespace std;

int memo[110];
int N;

int main()
{
    cin >> N;
    int cou = 0;
    int d;
    for(int i = 0;i < N;i++)
    {
        cin >> d;
        if(memo[d] == 0)
        {
            cou++;
            memo[d] = 1;
        }
    }

    cout << cou << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
}
// ----------------------------------------------------------------------------

int main(){
  vector<vector<vector<int>>> G(4,vector<vector<int>> (3,vector<int> (10,0)));
  int N;
  cin >> N;
  for(int i=0; i<N; i++){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    a--;
    b--;
    c--;
    G[a][b][c] += d;
  }
  for(int i=0; i<4; i++){
    for(int j=0; j<3; j++){
      for(int k=0; k<10; k++){
        cout << " " << G[i][j][k];
      }
      cout << endl;
    }
    if(i == 3){
      break;
    }
    for(int j=0; j<20; j++){
      cout << "#";
    }
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3172
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
#define pb emplace_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos(-1))
#define MAXN (300006)
#define MAXK 26
#define MAXX 15000006
#define ll long long int 
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < ee; ++ii)
#define space " "
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define ph emplace
#define btinpct(x) __builtin_popcountll(x)
#define p2(x) (1LL<<(x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
ll n;
int main()
{
	FAST
	ll n,k;string s;
	cin>>n>>k>>s;
	s[k-1]=tolower(s[k-1]);
	cout<<s<<'\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <utility>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))

const int inf = 999999999;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main(){
	ll n, m; cin >> n >> m;
	ll a = 0, b = 0, x[n], y[m];
	Rep(i, n){
		cin >> x[i];
		if(i > 0){
			ll s = x[i] - x[i - 1]; s %= mod;
			s *= (n - i) * i; s %= mod;
			a += s; a %= mod;
		}
	}
	Rep(i, m){
		cin >> y[i];
		if(i > 0){
			ll s = y[i] - y[i - 1]; s %= mod;
			s *= (m - i) * i; s %= mod;
			ll t = (a * s) % mod;
			b += t; b %= mod;
		}
	}
	cout << b << endl;
	return 0;
}

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

using namespace std;

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

#include "cpp-pyprint/pyprint.h"

#endif


ll dp[100005][13];

void Main() {
    string S;
    cin >> S;

    dp[0][0] = 1;
    for (int i = 0; i < S.length(); ++i) {
        if (S[i] == '?') {
            for (int j = 0; j < 10; ++j) {
                for (int k = 0; k < 13; ++k) {
                    dp[i + 1][(k * 10 + j) % 13] += dp[i][k];
                    dp[i + 1][(k * 10 + j) % 13] %= MOD;
                }
            }
        } else {
            int j = S[i] - '0';
            for (int k = 0; k < 13; ++k) {
                dp[i + 1][(k * 10 + j) % 13] += dp[i][k];
                dp[i + 1][(k * 10 + j) % 13] %= MOD;
            }
        }
    }
    cout << dp[S.length()][5] % MOD << endl;
}

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


Measured memory_bytes: 10704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll n, k;
    cin >> n >> k;
    const ll mod = 1000000007;
    ll mn = 0, mx = 0;
    rep(i, 0, k) mn += i;
    rep(i, 0, k) mx += n-i;  
    ll ans = 0;
    rep(i, k, n+2){
        //cerr << mn << " " << mx << endl;
        ans += mx - mn + 1;
        ans %= mod;
        mn += i;
        mx += n-i;
        mn %= mod;
        mx %= mod;
    }
    ans = (ans + mod) % mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <cstdio>
#include <climits>
#include <algorithm>
static const int MAX_N = 1 << 17;
using namespace std;
int n, dat[2 * MAX_N -1];

void init(int n_) {
    n = 1;
    while (n < n_) n *= 2;
    for (int i = 0; i < 2 * n - 1; i++) dat[i] = INT_MAX;
}

void update(int k, int a) {
    k += n - 1;
    dat[k] = a;
    while (k > 0) {
        k = (k-1) / 2;
        dat[k] = min(dat[k*2+1], dat[k*2+2]);
    }
}

int query(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) return INT_MAX;
    if (a <= l && r <= b) return dat[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 min(vl, vr);
    }
}



int main()
{
    int n_, q, com, x, y;
    scanf("%d %d", &n_, &q);
    init(n_);
    for (int i = 0; i < q; i++) {
        scanf("%d %d %d", &com, &x, &y);
        if (com == 0) update(x, y);
        else printf("%d\n", query(x, y+1, 0, 0, n));
    }

    return 0;
}



Measured memory_bytes: 3784
#include <bits/stdc++.h>
// #include <iostream>
// #include <vector>
// #include <map>
// #include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    return a * b / gcd(a,b);
}

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){
    int x;
    int ans = 0, tmp = 0, m = 0;
    for (int i = 0; i < 5; i++) {
        cin >> x;
        tmp = ((x + 9) / 10) * 10;
        m = max(m, tmp - x);
        ans += tmp;
    }

    cout << ans - m << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 256
S = int(input())
MOD = 10**9+7
t = S//3
if t == 0:
    print(0)
    exit()
elif t == 1:
    print(1)
    exit()
dp = [[0 for _ in range(S+1)] for _ in range(t-1)]
for i in range(3, S-2):
    dp[0][i] = 1
dp[0][S] = 1
for i in range(1, t-1):
    cnt=0
    for j in range(3*i, S-5):
        cnt+=dp[i-1][j]
        dp[i][j+3] = cnt
    dp[i][S] = sum(dp[i-1]) % MOD
print(sum(dp[-1]) % MOD)


Measured memory_bytes: 89296
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= 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;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
ll N, M;
ll x[1010], y[1010], z[1010];
ll total[1010];

int main() {
  cin >> N >> M;
  rep(i, 0, N) { cin >> x[i] >> y[i] >> z[i]; }
  ll ans = 0;
  for (int bit = 0; bit < (1 << 3); ++bit) {
    rep(i, 0, N) {
      ll xx = x[i];
      ll yy = y[i];
      ll zz = z[i];
      if (bit & 1) {
        xx = -xx;
      }
      if (bit & (1 << 1)) {
        yy = -yy;
      }
      if (bit & (1 << 2)) {
        zz = -zz;
      }
      total[i] = xx + yy + zz;
    }

    sort(total, total + N, greater<ll>());
    ll sum = 0;
    rep(i, 0, M) { sum += total[i]; }
    chmax(ans, sum);
  }
  cout << ans << endl;
}


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

const int INF = 0x3f3f3f3f;

int n;
vector<ll> arr;

void solve() {
  vector<int> idx(n);
  for (int i=0; i<n; ++i) {
    idx[i] = i;
  }
  sort(idx.begin(), idx.end(), [](int i, int j) {
    return arr[i] > arr[j];
  });
  vector<vector<ll> > dp(n, vector<ll>(n, 0));
  int last = idx[n-1];
  for (int i=0; i<n; ++i) {
    dp[i][i] = arr[last]*abs(last-i);
  }
  for (int l=1; l<n; ++l) {
    for (int i=0; i+l<arr.size(); ++i) {
      int j = i+l;
      int ind = idx[n-l-1];
      dp[i][j] = max(dp[i+1][j]+arr[ind]*abs(ind-i), dp[i][j-1]+arr[ind]*abs(ind-j));
    }
  }
  cout << dp[0][n-1] << endl;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  arr = vector<ll>(n);
  for (int i=0; i<arr.size(); ++i) {
    cin >> arr[i];
  }
  solve();
  return 0;
}

Measured memory_bytes: 34596
for _ in range(int(input())):
    c, a, n = map(int, input().split())
    t = min(c, a, n)
    c, a = c - t, a - t
    t += min(a, c // 2)
    c -= 2 * a
    t += max(0, c // 3)
    print(t)


Measured memory_bytes: 5600
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,-1,0,0,1,1,-1,-1 }, dy[9] = { 0,0,0,1,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222


ll a[MAX], bit[50];


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


  cin >> n >> m;
  rep(i, n) cin >> a[i];
  rep(i, n) ans += a[i];
  rep(i, 48) {
    tmp = 0;
    rep(j, n) {
      if (a[j] & (1LL << i)) tmp -= 1LL << i;
      else tmp += 1LL << i;
    }
    if (tmp < 0) tmp = 0;
    bit[i] = tmp;
  }
  ll cur1 = 0, cur2 = -inf;
  rrep(i, 48) {
    if (1LL << i > m) continue;
    if (m >> i & 1) {
      cur2 = max(cur1, cur2 + bit[i]);
      cur1 += bit[i];
    }
    else {
      cur2 += bit[i];
    }
    mi = min(mi, bit[i]);
  }
  cout << ans + max(cur1, cur2) << endl;

  return 0;
}

Measured memory_bytes: 1024