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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    double a, b, h, m; std::cin >> a >> b >> h >> m;
    double s = abs(m/60*30+h*30-m*6);
    std::cout << sqrt(a*a+b*b-2*a*b*cos(s*acos(-1)/180)) << "\n";
}


Measured memory_bytes: 4168
#define _CRT_SECURE_CPP_OVERLOAD_SECURE_NAMES 1

#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <random>

const long long INF = 10000000000000000;

using namespace std;

int main(){

	int N;
	cin>>N;
	
	long long tmp=0;
	int index=1;
	for(int i=1;i<=N;i++){
		tmp+=i;
		if(tmp>N){
			index=i;
			break;
		}
	}
	//cout<<tmp<<endl;
	long long del=tmp-N;
	for(int i=1;i<=index;i++){
		if(i==del) continue;
		else cout<<i<<endl;
	}
	return 0;	
}


Measured memory_bytes: 256
#include <stdio.h>
  
int main(void){
    int n, m, t;
    int f[101] = {}, tar[101] = {}, score[101] = {};
    int i, j;
      
    scanf("%d", &n);
      
    scanf("%d", &m);
      
    for (i = 0; i < m; i++){
        scanf("%d", &t);
        tar[i] = t;
    }
      
    for (i = 0; i < m; i++){
        for (j = 0; j < n; j++){
            scanf("%d", &f[j]);
              
            if (f[j] == tar[i]) score[j]++;
            else score[tar[i]-1]++;
        }
    }
      
    for (i = 0; i < n; i++)  printf("%d\n", score[i]);
      
    return 0;
}

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

using namespace std;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

int a, b, c, d;

int main()
{
	a = gi(), b = gi(), c = gi(), d = gi();
	if (d == 1) puts("1");
	else puts("0");
	return 0;
}

Measured memory_bytes: 256
def main():
    a, b, c, k = input().split()
    a = int(a)
    b =int(b)
    c =int(c)
    k = int(k)
    
    if k == 0:
        print(a - b)
        return
    elif k == 1:
        print(b - a)
        return
    elif k == 2:
        print(a - b)
        return
    
    t = 1
    if k % 2 == 0:
        t = -1
    
    ans = t * (b - a)
    if abs(ans) > 10**18:
        print(Unfair)
    else:
        print(ans)
    
main()

Measured memory_bytes: 3064
N = gets.to_i
A = gets.chomp.split(" ").map(&:to_i)

a_o = A.select.with_index{|a, i| i.odd?}
a_e = A.select.with_index{|a, i| i.even?}

puts N.even? ? (a_o.reverse + a_e).join(' ') : (a_e.reverse + a_o).join(' ')


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL a, b;
LL d[2], c;

int main() {
	cin >> a >> b;
	
	LL mm = b, ap = a, bp = b;
	bool flag = false;
	dec(i, 61) {
		if(! flag) {
			if((a^b) & (1LL << i)) {
				flag = true;
				ap += (1LL << i);
			}
		}
		if(flag) {
			if(   b & (1LL << i)) { c++; }
			if(! (b & (1LL << i))) { mm += (1LL << i); }
			if(! (b & (1LL << i)) && c >= 2) { bp += (1LL << i); }
		}
	}
	bp++;
	
	LL ans = (mm - a + 1) - max(0LL, ap - bp);
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
n = int(input())
ans = []
if n == 0:
  ans.append('0')
while n != 0:
  r = n % 2
  r = r if r >= 0 else 1 # 1 or 0になる
  n = (n-r)//-2
  ans.append(str(r))
ans = reversed(ans)
print(''.join(ans))

Measured memory_bytes: 3060
N=int(input())
*A,=map(int,input().split())
ra=A[::-1]
S=[0]*(N+1)
for i in range(N):
    S[i+1]=S[i]+ra[i]
M=10**9+7

S=S[::-1]
i=0
ans=0
while i<N:
    ans+=A[i]*S[i+1]
    ans%=M
    i+=1
print(ans)

Measured memory_bytes: 31624
a,b,v=map(int,input().split())

import math
pi=math.acos(-1)
if v*2<a*a*b:
	h = v*2/a/b
	ans = math.atan2(b,h) * 180/pi
else:
	h=(a*a*b-v)*2/a/a
	ans = 90-math.atan2(a,h)*180/pi
print(ans)


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

int main(){

    int r,g,b,n;
    cin >> r >> g >> b >> n;
    int ans=0;
    for(int i=0;i<=n;i+=r){
        for(int j=0;j+i<=n;j+=g){
            if((n-i-j)%b==0){
                ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int m,f,r;
	scanf("%d %d %d",&m,&f,&r);
	while(!(m==-1 && f==-1 && r==-1)){
	if((m==-1)||(f==-1)){
		printf("%c\n",'F');
	}else if(m+f>=80){
		printf("%c\n",'A');
	}else if(m+f>=65){
		printf("%c\n",'B');
	}else if(m+f>=50){
		printf("%c\n",'C');
	}else if(m+f>=30){
		if(r>=50){
			printf("%c\n",'C');
		}else{
			printf("%c\n",'D');
		}
	}else if(m+f<30){
		printf("%c\n",'F');
	}scanf("%d %d %d",&m,&f,&r);
	}
	return 0;
}

Measured memory_bytes: 600
def koch(d, p1, p2)
  return if d.zero?

  s = calc_s(p1, p2)
  t = calc_t(p1, p2)
  u = calc_u(s, t)

  koch(d - 1, p1, s)
  puts s
  koch(d - 1, s, u)
  puts u
  koch(d - 1, u, t)
  puts t
  koch(d - 1, t, p2)
end

def calc_s(p1, p2)
  x = (2 * p1.x + 1 * p2.x) / 3
  y = (2 * p1.y + 1 * p2.y) / 3
  Point.new(x, y)
end

def calc_u(s, t)
  radian_60 = 60 * Math::PI / 180
  x = (t.x - s.x) * Math.cos(radian_60) - (t.y - s.y) * Math.sin(radian_60) + s.x
  y = (t.x - s.x) * Math.sin(radian_60) + (t.y - s.y) * Math.cos(radian_60) + s.y
  Point.new(x, y)
end

def calc_t(p1, p2)
  x = (1 * p1.x + 2 * p2.x) / 3
  y = (1 * p1.y + 2 * p2.y) / 3
  Point.new(x, y)
end

Point = Struct.new(:x, :y) do
  def to_s
    format('%10.8f %10.8f', x, y)
  end
end

n = gets.to_i
p1 = Point.new(0.0, 0.0)
p2 = Point.new(100.0, 0.0)
puts p1
koch(n, p1, p2)
puts p2


Measured memory_bytes: 6948
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int[] arr = new int[5];
		for(int i = 0; i < 6; i++) {
			arr[sc.nextInt()]++;
		}
		System.out.println(valid(arr[1]) && valid(arr[2]) && valid(arr[3]) && valid(arr[4]) ? "YES" : "NO");
	}
	
	public static boolean valid(int num) {
		return num > 0 && num < 3;
	}
}

Measured memory_bytes: 22612
#include <stdio.h>

int main(){
	
	int N;
	scanf("%d", &N);
	
	if(N % 10 == 2 || N % 10 == 4 || N % 10 == 5 || N % 10 == 7 || N % 10 == 9){
		printf("hon");
	}
	
	else if(N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8 ){
		printf("pon");
	}
	
	else if(N % 10 == 3){
		printf("bon");
	}
	
	return 0;
	
}

Measured memory_bytes: 1712
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
  int a,b;
  cin >> a >> b;
  int ans = 0;
  if (a>b) swap(a,b);
  ans += b--;
  if (a>b) swap(a,b);
  ans += b;

  cout << ans << endl;
}


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

int main(){
    vector<long long int> block(3);
    for(int i=0; i<3; i++){
        cin >> block.at(i);
    }
    sort(block.begin(),block.end());
    if(block.at(0)%2==0 || block.at(1)%2==0 || block.at(2)%2==0){
        cout << 0 << endl;
    }
    else{
        cout << block.at(0)*block.at(1) << endl;
    }
    
}

Measured memory_bytes: 3576
#include<stdio.h>
int main()
{
    char s[101];

    scanf("%s",s);

    int len=0;

    for(int i=0; s[i]!=0;i++)
    len++;

    int count=0;
    for(int i=0,j=(len-1);i<=j;i++,j--)
    {
        if(s[i]!=s[j])
        count++;
    }

    printf("%d",count);
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int n, m, a, b, ans = 0;

struct edge {
  int to, cost;
};
typedef pair<int, int> P;
vector<edge> G[200005];
int d[200005];
int from[200005];

void dijkstra(int s) {
  priority_queue<P, vector<P>, greater<P>> q;
  fill(d, d + n, INF);
  d[s] = 0;
  q.push(P(0, s));

  while (q.size()) {
    P p = q.top();
    q.pop();
    int v = p.second;
    if (d[v] < p.first) continue;
    rep(i, G[v].size()) {
      edge e = G[v][i];
      if (d[e.to] > d[v] + e.cost) {
        d[e.to] = d[v] + e.cost;
        from[e.to] = v;
        q.push(P(d[e.to], e.to));
      }
    }
  }
}

int main() {
  cin >> n >> m;
  rep(i, m) {
    cin >> a >> b, a--, b--;
    G[a].push_back({b, 1});
    G[b].push_back({a, 1});
  }

  dijkstra(0);
    cout << "Yes" << endl;
    for (int i = 1; i < n; ++i) cout << from[i] + 1 << endl;
  return 0;
}


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

using namespace std;

long long n;
int ans = 0;

void dfs(long long x, int a, int b, int c) {
    if (x > n) return;
    if (a != 0 && b != 0 && c != 0) ans++;

    dfs(x * 10 + 3, a + 1, b, c);
    dfs(x * 10 + 5, a, b + 1, c);
    dfs(x * 10 + 7, a, b, c + 1);
}

int main() {
    cin >> n;
    dfs(0, 0, 0, 0);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int count(int *a, int num, int b) {
    int count = 0;
    for (int i=0; i<num; i++) {
        if (a[i]%b != 0) count++;
        if (count > 1) return 0;
    }
    return 1;
}

int main() {
    int num = 0;
    scanf("%d\n", &num);
    int a[num];
    for (int i=0; i<num; i++) {
        scanf("%d", a+i);
    }
    int min = 0, min2 = 0;
    if (a[0] > a[1]) min = a[1], min2 = a[0];
    else min = a[0], min2 = a[1];
    for (int i=2; i<num; i++) {
        if (a[i] < min) min = a[i];
        else if (a[i] < min2) min2 = a[i];
    }
    int max = 0;
    if (num == 2) printf("%d\n", min2);
    else {
        for (int i=min; i>0; i--) {
            if (min%i == 0) {
                if (count(a, num, i)) {
                    max = i;
                    break;
                }
            }
        }
        for (int i=min2; i>max; i--) {
            if (min2%i == 0) {
                if (count(a, num, i)) {
                    if (i > max) max = i;
                    break;
                }
            }
        }
        printf("%d\n", max);
    }
    return 0;
}


Measured memory_bytes: 512
from bisect import bisect_right, bisect_left
from collections import Counter, deque
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import groupby, permutations, combinations, product
from sys import stdin, stderr


# 最大公約数（ユークリッドの互除法）
# Python3.5 で math.gcd()が追加され、
# AtCoder環境と最新環境でパッケージが分かれてしまったので、自分で書いておく
def gcd(x, y):
    return x if y == 0 else gcd(y, x % y)


# 拡張ユークリッド互除法
# 正整数x, y について、a*x + b*y == gcd(x,y)なるa,bを返す。
# 特に、互いに素なるx, yについては a*x + b*y == 1 となる a, b。
def exgcd(x, y):
    if y == 0:
        return 1, 0
    a, b = exgcd(y, x % y)
    return b, a - (x // y) * b


# 最小公倍数
def lcm(x, y):
    m = gcd(x, y)
    return (x // m) * (y // m)


def main():
    s, t = input().split()
    a, b = [int(x) for x in input().split()]
    u = input()
    if u == s:
        a -= 1
    else:
        b -= 1
    return " ".join([str(x) for x in [a, b]])


if __name__ == "__main__":
    print(main())

Measured memory_bytes: 3812
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  string s;
  cin >> s;
  rep(i, 1 << 3) {
    ll n = s[0] - '0';
    rep(j, 3) {
      if(i >> j & 1)
        n += s[j + 1] - '0';
      else
        n -= s[j + 1] - '0';
    }
    if(n != 7) continue;
    cout << s[0];
    rep(j, 3) cout << (i >> j & 1 ? '+' : '-') << s[j + 1];
    cout << "=7" << endl;
    return 0;
  }
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int i=0,n,d;
    cin >> d >> n;
    if(d==0 && n==100)
    {
        cout << n+1 << endl;
        return 0;
    }
    if(d==1 && n==100)
    {
        cout << 100*(n+1) << endl;
        return 0;
    }
    if(d==2 && n==100)
    {
        cout << 10000*(n+1) << endl;
        return 0;
    }    
    if(d==0)
    {
        cout << n << endl;
        return 0;
    }
    else if(d==1)
    {
        cout << 100*n << endl;
        return 0;
    }
    else if(d==2)
    {
        cout << 10000*n << endl;
        return 0;
    }
            
        
    return 0;
}


Measured memory_bytes: 3568
#include<stdio.h>
int F(int, int [],int);
int main()
{
  int sum=0,i,mid,l,r,n,k,w[1000000];
  scanf("%d%d",&n,&k);
  for(i=0;i<n;i++){
    scanf("%d",&w[i]);
  }
  w[n]=-1;
  l=0;
  r=2000000000;
  while(l<r){
    mid=(l+r)/2;
    sum=F(mid,w,k);
    if(sum==n && F(mid-1,w,k)!=sum)break;   
    if(sum<n){
      l=mid+1;
    }
    else if(sum==n &&F(mid-1,w,k)==sum){
      r=mid;
    }
  }
 
  printf("%d\n",mid);
  return 0;
}
 
int F(int P,int w[],int k){
  int i,sum=0,a=0;
  for(i=0;i<k;i++){
    if(w[a]<=P){
      while(sum+w[a]<=P && w[a]!=-1){
    sum+=w[a];
    a++;
      }
    }
    sum=0;
  }
  return a;
}


Measured memory_bytes: 2188
#include <cstdio>
#define N_MAX 100000
#define V_MAX 2000000000

int n;

struct Card {
	char mark;
	int value;
};

Card A[N_MAX], T[N_MAX], A1[(N_MAX/2)+1], A2[(N_MAX/2)+1];

void swapCard(int ia, int ib) {
	Card temp;
	temp = A[ia];
	A[ia] = A[ib];
	A[ib] = temp;
}

void printCard() {
	for (int i = 0; i < n; i++) printf("%s %d\n", &A[i].mark, A[i].value);
}

int partition(int l, int r) {
	int j = l;
	int x = A[r].value;
	for (int i = l; i < r; i++) {
		if (A[i].value <= x) {
			swapCard(i, j);
			j++;
		}
	}
	swapCard(j, r);
	return j;
}

void quickSort(int l, int r) {
	if (l < r) {
		int m = partition(l, r);
		quickSort(l, m - 1);
		quickSort(m + 1, r);
	}
}

void merge(int l, int m, int r) {
	int n1 = m - l;
	int n2 = r - m;
	for (int i = 0; i < n1; i++) A1[i] = T[l + i];
	for (int i = 0; i < n2; i++) A2[i] = T[m + i];
	A1[n1].value = A2[n2].value = V_MAX;
	int j1 = 0, j2 = 0;
	for (int i = l; i < r; i++) {
		if (A1[j1].value <= A2[j2].value) {
			T[i] = A1[j1++];
		}
		else {
			T[i] = A2[j2++];
		}
	}
}

void mergeSort(int l, int r) {
	int m;
	if (l + 1 < r) {
		m = (l + r) / 2;
		mergeSort(l, m);
		mergeSort(m, r);
		merge(l, m, r);
	}
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s %d", &A[i].mark, &A[i].value);
		T[i] = A[i];
	}

	quickSort(0, n - 1);
	mergeSort(0, n);

	bool stable = true;
	for (int i = 0; i < n; i++) {
		if ((A[i].mark != T[i].mark) || (A[i].value != T[i].value)) stable = false;
	}

	if (stable) printf("Stable\n");
	else printf("Not stable\n");

	printCard();

	return 0;
}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
typedef double DOUBLE;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const ll LL_INF = 1e17 + 10;
const int INF = 1e9 + 10;
const ll MOD = 998244353;

const int MAXN = 3e2 + 2;

ll dp[MAXN * MAXN], dp1[MAXN * MAXN];
int v[MAXN];
ll st2[MAXN], st3[MAXN];

void solve(){
	int n;
	scanf("%d", &n);
	int sum = 0;
	REPN(i, 1, n) {
		scanf("%d", &v[i]);
		sum += v[i];
	}
	st2[0] = st3[0] = 1;
	REPN(i, 1, n) {
		st2[i] = (st2[i - 1] * 2) % MOD;
		st3[i] = (st3[i - 1] * 3) % MOD;
	}
	dp[0] = 1;
	dp1[0] = 1;
	REPN(i, 1, n) {
		for(int j = sum; j >= 0; j--) {
			dp[j] = (2 * dp[j]) % MOD;
			if (j >= v[i]) {
				dp[j] = (dp[j] + dp[j - v[i]]) % MOD;
			}
			if (i < n) {
				dp1[j] = dp1[j];
				if (j >= v[i]) {
					dp1[j] = (dp1[j] + dp1[j - v[i]]) % MOD;
				}
			}
		}
	}
	ll ans = st3[n];
	REPN(i, (sum + 1) / 2, sum) {
		ans = (ans + 3 * (MOD - dp[i])) % MOD;
	}
	if (sum % 2 == 0) {
		ans = (ans + 6 * dp1[sum / 2]) % MOD;
	}
	cout << ans << endl;
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 1664
#define MOD_TYPE 1

#pragma region Macros
#include <bits/stdc++.h>
using namespace std;

#if 0
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using Int = boost::multiprecision::cpp_int;
using lld = boost::multiprecision::cpp_dec_float_100;
#endif

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
//constexpr ll MOD = 1;
constexpr int INF = (int)1e9 + 10;
constexpr ll LINF = (ll)4e18;
constexpr double PI = acos(-1.0);
constexpr double EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define REPI(i, m, n) for (int i = m; i < (int)(n); ++i)
#define repi(i, n) REPI(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

struct init_main
{
  init_main()
  {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(30) << setiosflags(ios::fixed);
  };
} init_main_;
template <typename T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
inline ll CEIL(ll a, ll b)
{
  return (a + b - 1) / b;
}
template <typename A, size_t N, typename T>
inline void Fill(A (&array)[N], const T &val)
{
  fill((T *)array, (T *)(array + N), val);
}
template <typename T, typename U>
constexpr istream &operator>>(istream &is, pair<T, U> &p) noexcept
{
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename U>
constexpr ostream &operator<<(ostream &os, pair<T, U> &p) noexcept
{
  os << p.first << " " << p.second;
  return os;
}
#pragma endregion

void solve()
{
  ll d, t, s;
  cin >> d >> t >> s;
  Yes(d <= t * s);
}

int main()
{
  solve();
}


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

int main()
{
    char c;
    cin >> c;
    if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
    {
        cout << "vowel" << endl;
    }
    else
    {
        cout << "consonant" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<climits>

#define ll long long
#define deb(x) cout<<#x <<x<<" "
using namespace std;

ll knapsack(long w,long i,vector<long> &weight,vector<long> &values,vector<vector<ll>> &dp)
{
    if(i<0 || w<=0)
        return 0;
    
    if(dp[i][w] == -1)
    {
        if(weight[i] > w)
            dp[i][w] = knapsack(w,i-1,weight,values,dp);
    
        else 
        {
            dp[i][w] = max(values[i] + knapsack(w-weight[i],i-1,weight,values,dp),knapsack(w,i-1,weight,values,dp));
        } 
    }
    return dp[i][w];
}

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long n{},w{};
    cin>>n>>w;
    vector<long> wi(n),vi(n);
    for(int i=0;i<n;i++)
    {
        cin>>wi[i]>>vi[i];
    }
    
    vector<vector<ll>> dp(n,vector<ll>(w+1,-1));
    ll ans = knapsack(w,n-1,wi,vi,dp);
    cout<<ans;

    return 0;
}

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

def f(n):
    return ((1 + n) * n) // 2
 
s = 0
for x in range(1, n+1):
    if f(x) > n:
        s = f(x)
        break

dif = s - n

for ans in range(1, x+1):
    if ans != dif:
        print(ans)

Measured memory_bytes: 9148
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
 
#define CHMIN(a, b) (a) = min((a), (b))
#define CHMAX(a, b) (a) = max((a), (b))
 
#define DEBUG(x) cout << #x << ": " << (x) << endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()
 
 
int main() {
 
    string s;
    cin >> s;
 
    string prev = "A";
 
    for(int i=0;i<4;i++){
        if(prev[0]==s[i]){
            cout << "Bad" << endl;
            return 0;
        }
        prev[0] = s[i];
    }
 
    cout<< "Good" << endl;
    return 0;
 
}

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






int main()
{
    cout<<setprecision(9);
    int n;
    cin>>n;
    double dp[n+1][n+1];
    //memset(dp, 0.0, sizeof(dp));
    for(int i=0; i<=n; ++i)
    {
        for(int j=0; j<=n; ++j)
        {
            dp[i][j] = 0.0;
        }
    }

    double arr[n+1];
    arr[0] = 0;
    for(int i=1; i<=n; ++i)
    {
        cin>>arr[i];
    }
    dp[0][0] = 1.0;
    for(int i=1; i<=n; ++i)
    {
        for(int j=0; j<=i; ++j)
        {
            if(j == 0)
            {
                dp[i][j] = (1.0 - arr[i])*dp[i-1][j];
                continue;
            }
            else
            {
                dp[i][j] = (1.0 - arr[i])*dp[i-1][j] + dp[i-1][j-1]*arr[i];
            }
        }
    }





   /* for(int i=0; i<=n; ++i)
    {
        for(int j=0; j<=n; ++j)
        {
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }*/










    double ans = 0;

    for(int i=n; i>n/2; --i)
    {
        ans+=dp[n][i];
    }

    cout<<ans<<endl;
    return 0;

}


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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) { ll d = euclid(b, a % b, y, x);
        return y -= a/b * x, d; }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1) ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1); return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this ^ (e / 2); r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int cnt[4000][3];

int toint(char c) {
    if (c == 'R') return 0;
    if (c == 'G') return 1;
    if (c == 'B') return 2;
    exit(1);
}

int docount(int c, int l, int r) {
    return cnt[r][c] - (l - 1 >= 0 ? cnt[l - 1][c] : 0);
}

int main() {
    cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit);

    int n; cin >> n;
    string s; cin >> s;

    rep(i, 0, n) cnt[i][toint(s[i])]++;
    rep(i, 1, n) rep(j, 0, 3) cnt[i][j] += cnt[i - 1][j];

    ll ans = 0;

    rep(i, 1, n - 1) {
        rep(j, 0, 3) rep(k, 0, 3) if (toint(s[i]) != j && toint(s[i]) != k && j != k)
            ans += docount(j, 0, i - 1) * docount(k, i + 1, n - 1);
        for (int j = i - 1, k = i + 1; j >= 0 && k < n; j--, k++) {
            if (s[i] != s[j] && s[i] != s[k] && s[j] != s[k]) ans--;
        }
    }
    cout << ans << endl;

}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/23  Problem: 090_arc_b / Link: https://abc087.contest.atcoder.jp/tasks/arc090_b?lang=en  ----- */
/* ------問題------

x 軸上に N 人の人が立っています。 人 i の位置を xi とします。 任意の i に対して、xi は 0 以上 109 以下の整数です。 同じ位置に複数の人が立っていることもありえます。
これらの人の位置に関する情報が M 個与えられます。 このうち i 個めの情報は (Li,Ri,Di) という形をしています。 この情報は、人 Ri は人 Li よりも距離 Di だけ右にいること、 すなわち、xRi−xLi=Di が成り立つことを表します。
これら M 個の情報のうちのいくつかに誤りがある可能性があることがわかりました。 与えられる M 個すべての情報と矛盾しないような値の組 (x1,x2,…,xN) が存在するかどうか判定してください。

-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N, M;

int ans;

void dfs(int v, int p, LL d, VL& dist, VI& visit, vector<vector<PLL>>& G) {
	if (!visit[v])dist[v] = d, visit[v] = 1;
	FOR(i, 0, SZ(G[v])) {
		int nx = G[v][i].first;
		LL cost = G[v][i].second;
		if (nx != p) {
			if (visit[nx]) {
				if (dist[v] + cost != dist[nx])ans = 0;
			}
			else {
				dfs(nx, v, d + cost, dist, visit, G);
			}

		}
	}
}

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

	cin >> N >> M;
	vector<vector<PLL>> G(N);
	FOR(i, 0, M) {
		int a, b, c;
		cin >> a >> b >> c;
		a--, b--;
		G[a].push_back(PLL(b, c));
		G[b].push_back(PLL(a, -c));
	}
	VL dist(N, 0);
	VI visit(N, 0);
	ans = 1;
	FOR(i, 0, N) {
		if (!visit[i])dfs(i, -1, 0, dist, visit, G);
	}

	cout << (ans==1 ? "Yes" : "No") << "\n";

	return 0;
}


Measured memory_bytes: 19712
#pragma GCC optimize("Ofast") // OPTIONAL: for faster execution
#include <bits/stdc++.h> // import everything in one shot
using namespace std;
#define rep(i,a,b) for(int i = a; i <= b; ++i)
typedef long long int ll;
// -------------------------------
const int MAXN = 200000;
ll rw_dist[MAXN];
ll p_dist[MAXN];
int N, Q;
enum Type { Start, End, Person };
struct Event {
    Type type;
    ll score;
    int id;
    Event(Type _type, int _id, ll t, ll x) : type(_type), id(_id) {
        score = t - x;
    }
    bool operator<(const Event& rhs) const {
        if (score == rhs.score) return type < rhs.type;
        return score < rhs.score;
    }
};

int main() {
    ios::sync_with_stdio(false); 
    cin.tie(0); cout.tie(0);
    cin >> N >> Q;
    vector<Event> events;
    rep(i,0,N-1) {
        ll s, t, x; cin >> s >> t >> x;
        rw_dist[i] = x;
        events.emplace_back(Start, i, 2*s-1, 2*x);
        events.emplace_back(End, i, 2*t-1, 2*x);
    }
    rep(i,0,Q-1) {
        ll d; cin >> d;
        events.emplace_back(Person, i, 2*d, 0);
    }
    sort(events.begin(), events.end());
    auto cmp = [](int i, int j) {
        if (rw_dist[i] == rw_dist[j]) return i < j;
        return rw_dist[i] < rw_dist[j];
    };
    set<int, decltype(cmp)> active_roadworks(cmp);
    for (Event& e : events) {
        if (e.type == Start) {
            active_roadworks.insert(e.id);
        } else if (e.type == End) {
            active_roadworks.erase(e.id);
        } else { // Person
            if (active_roadworks.empty()) {
                p_dist[e.id] = -1;
            } else {
                p_dist[e.id] = rw_dist[*active_roadworks.begin()];
            }
        }
    }
    rep (i, 0, Q-1) cout << p_dist[i] << '\n';
    return 0;
}

Measured memory_bytes: 28520
#include <stdio.h>

int main(){
  int A,B;
  scanf("%d %d",&A,&B);
  if(A>9){
    printf("-1\n");
  }else if(B>9){
    printf("-1\n");
  }else{
    printf("%d\n",A*B);
  }
  return 0;
} 

Measured memory_bytes: 1716
n = gets.chomp.to_i
h = gets.chomp.split(' ').map(&:to_i)
result = true
if n >= 3
  1.upto(n - 2) do |i|
    break unless result
    h0, h1, h2 = h[i - 1], h[i], h[i + 1]
    h1 = h1 - 1 if h1 >= 2 && h0 < h1
    result = false if h1 - h2 >= 1 || h0 - h1 >= 1
    h[i] = h1
    h[i + 1] = h2
  end
elsif n == 2
  h1, h2 = h[0], h[1]
  h1 = h1 - 1 if h1 >= 2
  result = false if h1 - h2 >= 1
end
puts result ? 'Yes' : 'No'

Measured memory_bytes: 9612
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <unordered_map>
#include <unordered_set>
using namespace std;
    
#define ABS(a) (((a) >= 0) ? (a) : -(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define POW_10_9 1000000000
#define INF (numeric_limits<int>::max()/2)
#define int long long
    
typedef long long ll;
typedef pair<int,int> Pair;
string S;

    
signed main(){
    cin >> S;
    if (S>"2019/04/30") cout<<"TBD"<<endl;
    else cout<<"Heisei"<<endl;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using LayoutKind = System.Runtime.InteropServices.LayoutKind;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;


static class P
{
    static void Main()
    {
        var nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int n = nm[0];
        int m = nm[1];
        int[][] queries = Enumerable.Repeat(0, m).Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).OrderBy(x => x[1]).ToArray();
        int res = 0;
        int resolvedTail = 0;
        for (int i = 0; i < queries.Length; i++)
        {
            if (queries[i][0] < resolvedTail) continue;
            resolvedTail = queries[i][1];
            res++;
        }
        Console.WriteLine(res);
    }
}


Measured memory_bytes: 28604
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (ll i=0; i<(n); ++i)
#define rep1(i,n) for (ll i=1; i<=(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";
const ll mod = 998244353;

int main(){
  ll H,W,h,w; cin >> H >> W >> h >> w;
  cout << H*W-(H*w+W*h-h*w);
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void)
{
	int n,a,s=0,i,j;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a);
		if(a==1)continue;
		for(j=2;j<=(int)sqrt(a);j++)if(a%j==0)break;
		if(j==(int)sqrt(a)+1)s++;
	}
	printf("%d\n",s);
	return 0;
}


Measured memory_bytes: 2056
// ░█████╗░░░░░░░░░░░░░░░
// ██╔══██╗░░██╗░░░░██╗░░
// ██║░░╚═╝██████╗██████╗
// ██║░░██╗╚═██╔═╝╚═██╔═╝
// ╚█████╔╝░░╚═╝░░░░╚═╝░░
// ░╚════╝░░░░░░░░░░░░░░░
#include <bits/stdc++.h>
#include <iostream>
#include <string.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define f(ii,n) for(ii=0;ii<n;ii++)
#define F(ii,a,n) for(ii=a;ii<n;ii++)
#define read0(array,n) for(ll i=0;i<n;i++) cin>>array[i];
#define read1(array,n) for(ll i=1;i<=n;i++) cin>>array[i];
#define inf 1000000007;
// function to transform string to lowercase --> transform(s.begin(),s.end(),s.begin(),::tolower)
//(a + b ) % m = (a % m + b % m ) %m
//(a - b ) % m = ( (a % m - b % m ) + m ) %m
//(a * b ) % m = (a % m * b % m ) %m
//(a / b ) % m = (a % m * inv(b) ) %m where inv(b) = pow(b,m,m-2)



ll power(ll i,ll j){
	ll prod=1;
	while(j>0){
		if(j&1){
			prod=prod*i;
		}
		j=j>>1;
		i=i*i;
	}
	return prod;
}

void solve(){
	ll i,j,n,m,k;
	cin>>k;
	string s;
	cin>>s;
	if(s.size()>k){
		for(i=0;i<k;i++){
			cout<<s[i];
		}
		cout<<"...\n";
	}
	else{
		cout<<s<<endl;
	}

}
int main(){
	// freopen("filename.txt","r",stdin);
	solve();
	// ll t;
	// cin>>t;
	// while(t--){
	// 	solve();
	// }
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    vector<string> board(H);
    for (int i = 0; i < H; ++i) {
        cin >> board[i];
    }
    vector<vector<int>> R(H,vector<int>(W,0)), L(H, vector<int>(W, 0)), U(H, vector<int>(W, 0)), D(H, vector<int>(W, 0));
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (board[i][j] == '#')L[i][j] = 0;
            else {
                if(j==0)L[i][j] = 1;
                else L[i][j] = L[i][j-1]+1;
            }
        }
    }
    for (int i = 0; i < H; ++i) {
        for (int j = W-1; j >=0; --j) {
            if (board[i][j] == '#')R[i][j] = 0;
            else {
                if (j == W-1)R[i][j] = 1;
                else R[i][j] = R[i][j + 1] + 1;
            }
        }
    }
    for (int i = H-1; i >=0; --i) {
        for (int j = 0; j < W; ++j) {
            if (board[i][j] == '#')U[i][j] = 0;
            else {
                if (i == H-1)U[i][j] = 1;
                else U[i][j] = U[i+1][j] + 1;
            }
        }
    }
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (board[i][j] == '#')D[i][j] = 0;
            else {
                if (i == 0)D[i][j] = 1;
                else D[i][j] = D[i-1][j] + 1;
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (board[i][j] == '#')continue;
            
            ans = max(ans, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 67328
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;
using plli=pair<ll,int>;
using vplli=vector<pair<ll,int>>;
using pllll=pair<ll,ll>;
using vpllll=vector<pair<ll,ll>>;

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;}

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    int N,M;
    cin>>N>>M;
    int R;
    cin>>R;
    vi r;
    ll wf[N][N];
    rep(i,0,N){
        rep(j,0,N){
            if(i==j)wf[i][j]=0;
            else wf[i][j]=INF;
        }
    }
    rep(i,0,R){
        int t;
        cin>>t;
        t--;
        r.push_back(t);
    }
    vpii conne[N];
    rep(i,0,M){
        int a,b;
        cin>>a>>b;
        a--,b--;
        int c;
        cin>>c;
        wf[a][b]=c;
        wf[b][a]=c;
    }
    rep(i,0,N){
        rep(j,0,N){
            rep(k,0,N){
                chmin(wf[j][k],wf[j][i]+wf[i][k]);
            }
        }
    }
    sort(r.begin(),r.end());
    ll ans=INF;
    do{
        ll res=0;
        rep(i,0,r.size()-1){
            res+=wf[r[i]][r[i+1]];
        }
        chmin(ans,res);
    }while(next_permutation(r.begin(),r.end()));
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ts cout<<"ok"<<endl
#define ll long long
#define hh puts("")
using namespace std;
int n,m,d;
char s[]={'R','Y','G','B'};
inline int read(){
    int ret=0,ff=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-') ff=-ff;ch=getchar();}
    while(isdigit(ch)){ret=ret*10+(ch^48);ch=getchar();}
    return ret*ff;
}
signed main(){
	n=read(),m=read(),d=read();
	for(int i=1;i<=n;i++,hh)
		for(int j=1;j<=m;j++){
			int tx=i+j+1e5,ty=i-j+1e5;
			printf("%c",s[((tx/d)&1)*2+((ty/d)&1)]);
		}
    return 0;
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair

int main() {
  string s;
  cin >> s;
  while (s.size() < 15) {
    s += 'o';
  }
  int cnt = 0;
  rep (i, s.size()) {
    if (s[i] == 'x') cnt++;
  }
  if (cnt >= 8) {
    cout << "NO" << endl;
  }
  else {
    cout << "YES" << endl;
  }
}


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

int main(){
    // 制約見て！！！デカかったらlong longにすること！
    int n;
    cin >> n;
    int a[n];
    int max,min;
    max = -1;
    min = INT32_MAX;
    int p=0;
    rep(i,n){
        scanf("%d",&a[i]);
        if(a[i]>max){
            max = a[i];
        }

        if(a[i]<min){
            min = a[i];
        }

    }

    int sum_min=INT32_MAX;
    rep(i,101){
        int sum = 0;
        rep(j,n){
            int tmp = (a[j]-i);
            sum += tmp*tmp;
        }
        sum_min = std::min(sum,sum_min);
    }
    cout << sum_min<<endl;
}

Measured memory_bytes: 764
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner scanner = new Scanner(System.in);

		//入力表示
		int A = scanner.nextInt();
		int B = scanner.nextInt();
		
		int S = 6 - A - B; 
			

		System.out.println(S);

		scanner.close();
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n, m;
    cin >> n >> m;

    vector<P> p(n);
    rep(i, n) {
        ll a, b;
        cin >> a >> b;
        p[i] = make_pair(a, b);
    }
    sort(all(p));

    ll cnt = 0;
    ll ans = 0;
    rep(i, n) {
        if(cnt + p[i].second < m) {
            cnt += p[i].second;
            ans += p[i].first * p[i].second;
        }
        else {
            ans += (m - cnt)*p[i].first;
            break;
        }
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 1792
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        sc.nextLine();
        ArrayList<String> list = new ArrayList<>();
        
        for(int i = 0; i < n; i++){
            char[]c = sc.nextLine().toCharArray();
            Arrays.sort(c);
            list.add(new String(c));
        }
        
        Collections.sort(list);
        
        long anagram = 0;
        long answer = 0;
        String s = list.get(0);
        for(int i = 1; i < n; i++){
            if(s.equals(list.get(i))){
                anagram += 1;
            }else{
                long a = 0;
                for(long j = 0; j < anagram; j++){
                    a += j+1;
                }
                answer += a;
                anagram = 0;
                s = list.get(i);
            }
        }
        if(list.get(n-1).equals(list.get(n-2))){
            long a = 0;
            for(long i = 0; i < anagram; i++){
                a += i+1;
            }
            answer += a;
        }
        
        System.out.println(answer);
    }
}

Measured memory_bytes: 99612
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;

const int maxn = 1e5 + 5;
LL a[maxn],pre[maxn];

int main(){
	int n; cin >> n;
	for(int i = 1;i <= n;i++) cin >> a[i];
	for(int i = 1;i <= n + 1;i++) pre[i] = abs(a[i - 1] - a[i]) + pre[i - 1];
	for(int i = 1;i <= n;i++){
		LL sum = 0;
		sum += pre[i - 1] + abs(a[i - 1] - a[i + 1]) + pre[n + 1] - pre[i + 1];
		cout << sum << endl;
	}
}

Measured memory_bytes: 2816