akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		long[] a = new long[n];
		for(int i = 0; i < n; i++){
		    a[i] = sc.nextLong();
		}
		
		// 計算
		long result = 0;
		long max = a[0];
		for(int i = 1; i < n; i++){
		    if(max - a[i] > 0){
		        result += max - a[i];
		    }else{
		        max = a[i];
		    }
		}
		
		
		// 出力
		System.out.println(result);
	}
	
	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}


Measured memory_bytes: 56460
#include <stdio.h>

int main()
{
    long x, y;
    int count = 1;
    scanf("%ld %ld", &x, &y);

    for( ; ; )
    {
        x = x * 2;
        if(x > y)
        {
            break;
        }
        count++;
    }

    printf("%d\n", count);

    return 0;

}

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

#define INF (1 << 30)
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define out(x) cout << x << endl;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;

int main(){
    int a;
    string s;
    cin >> a >> s;
    if(a >= 3200){
        out(s);
    }else{
        out("red");
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
#define pi 3.141592653589793
#define mod 1000000007
#define pb push_back
#define all(v) v.begin(),v.end()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, greater_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;

int main() {
	fast_io;
	ll n, k;
	cin >> n >> k;
	ll ans = 0;
	for (ll i = k;i <= n + 1;i++) {
		ll low = (i * (i - 1) / 2) % mod;
		ll high = (low + (n + 1 - i) * i) % mod;
		ans = (ans + high - low + 1 + mod) % mod;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 3656
a = [0,0,0,0,0,0]

a[0] = int(input())
a[1] = int(input())
a[2] = int(input())
a[3] = int(input())
a[4] = int(input())
a[5] = int(input())

for x in range(5):
	for y in range(5):
		if x != y:
			if abs(a[x]-a[y])>a[5]:
				print(":(")
				exit()
print("Yay!")

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

bool data[15];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;
    
    for(int i = 0; i <= 9; ++i){
        data[i] = true;
    }

    for(int i = 0; i < k; ++i){
        int d;
        cin >> d;
        data[d] = false;
    }

    while(1){
        int m = n;
        bool check = true;
        while(m >= 10){
            int a = m % 10;
            m -= a;
            m /= 10;
            if(!data[a]){
                check = false;
                break;
            }
        }
        if(check && data[m]){
            cout << n << endl;
            break;
        }
        ++n;
    }

    return 0;
}

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

const int N = 55;
int vet[N];

int main(){
	int n;
	scanf("%d", &n);
	int sum = 0;	
	for (int i=0; i<n; i++){
		scanf("%d", &vet[i]);
		sum += vet[i];
	}
	int ans = 0;
	for (int i=0; i<n; i++){
		ans += ((sum - vet[i]) * vet[i]);
	}
	printf("%d\n", ans/2);
}


Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 23.09.2017 15:44:27       
**/
#include <bits/stdc++.h>

using namespace std;

const int md = 998244353;

inline void add(int &a, int b) {
  a += b;
  if (a >= md) a -= md;
}

inline void sub(int &a, int b) {
  a -= b;
  if (a < 0) a += md;
}

inline int mul(int a, int b) {
  return (long long) a * b % md;
}

inline int power(int a, int b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}

inline int inv(int a) {
  a %= md;
  if (a < 0) a += md;
  int b = md, u = 0, v = 1;
  while (a) {
    int t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}

const int N = 800010;

char sa[N], sb[N], sc[N], sd[N];
int fact[N], inv_fact[N];
int ways_up[N], ways_down[N];

inline int C(int n, int k) {
  if (k < 0 || k > n) return 0;
  return mul(fact[n], mul(inv_fact[k], inv_fact[n - k]));
}

int main() {
  fact[0] = inv_fact[0] = 1;
  for (int i = 1; i < N; i++) {
    fact[i] = mul(fact[i - 1], i);
    inv_fact[i] = inv(fact[i]);
  }
  int n, m;
  scanf("%d %d", &n, &m);
  scanf("%s", sa);
  scanf("%s", sb);
  scanf("%s", sc);
  scanf("%s", sd);
  vector<int> a(n), b(n), c(m), d(m);
  for (int i = 0; i < n; i++) {
    a[i] = sa[i] - '0';
    b[i] = sb[i] - '0';
  }
  for (int i = 0; i < m; i++) {
    c[i] = sc[i] - '0';
    d[i] = sd[i] - '0';
  }
  int ans = 0;
  for (int rot = 0; rot < 2; rot++) {
    int sum_c = 0, sum_d = 0;
    for (int p = 0; p < m; p++) {
      sum_c += c[p];
      sum_d += d[p];
    }
    int sum_up = 0;
    for (int i = 0; i < n; i++) {
      if (a[i] + b[i] == 0) {
        ways_up[i] = 0;
      } else {
        if (sum_c == 0 && sum_up > 0) {
          ways_up[i] = 0;
        } else {
          ways_up[i] = (sum_c == 0 ? 1 : C(sum_c + sum_up - 1, sum_c - 1));
        }
        sum_up += a[i] + b[i];
      }
    }
    int sum_down = 0;
    for (int j = n - 1; j >= 0; j--) {
      if (a[j] + b[j] == 0) {
        ways_down[j] = 0;
      } else {
        if (sum_d == 0 && sum_down > 0) {
          ways_down[j] = 0;
        } else {
          ways_down[j] = (sum_d == 0 ? 1 : C(sum_d + sum_down - 1, sum_d - 1));
        }
        sum_down += a[j] + b[j];
      }
    }
    int sum_i = 0;
    for (int j = 0; j < n; j++) {
      add(sum_i, ways_up[j]);
      sum_i = mul(sum_i, max(1, a[j] + b[j]));
      add(ans, mul(sum_i, ways_down[j]));
    }
    swap(n, m);
    swap(a, c);
    swap(b, d);
  }
  int cnt_1 = 0;
  for (int i = 0; i < n; i++) {
    cnt_1 += a[i] + b[i];
  }
  for (int i = 0; i < m; i++) {
    cnt_1 += c[i] + d[i];
  }
  if (cnt_1 == 0) {
    ans = 1;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 12672
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> // include pb_ds

using namespace std;
using namespace __gnu_pbds; // namespace for pb_ds

/* short forms */
#define Accelerate                    \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define mt make_tuple
#define cld(x, y) (((x) / (y)) + ((x) % (y) != 0)) //integer ceil division
#define tc(tt) \
    int tt;    \
    cin >> tt; \
    for (int _tt = 0; _tt < tt; _tt++) // testcase
#define all(cont) (cont).begin(), (cont).end()
#define sz(cont) (int)(cont).size()
#define endl '\n'
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl //print with precision
#define dbg(x) cerr << #x << "is" << (x) << endl
#define leadzero(a) __builtin_clz(a)      // count leading zeroes
#define trailzero(a) __builtin_ctz(a)     // count trailing zeroes
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)

/* constants */
const double PI = 3.1415926535897932384626433832795;
const double EPS = 1e-9;

/* typedefs */
typedef pair<int,int> pii;
typedef priority_queue<int, vector<int>, greater<int> > min_heap;
typedef priority_queue<int, vector<int> > max_heap;
typedef tree<int,null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> 
    indexed_set; // integer set with indexing / pb_ds



/* main program */
int main() {
    Accelerate;
    int a,b,c;
    cin >> a >> b >> c;

    cout << c-min(a-b,c) << endl;
    return 0;
}

Measured memory_bytes: 256
N,M,Q=list(map(int,input().split()))
from itertools import combinations_with_replacement as comb
l=comb(range(1,M+1),N)
q=[list(map(int,input().split())) for i in range(Q)]
ans=0
for i in l:
   tmp=0
   for a,b,c,d in q:
      if i[b-1]-i[a-1]==c:
         tmp+=d
   ans=max(tmp,ans)
print(ans)

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

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b&&b==c) {
    cout<<"1"<<endl;
  }
  if((a==b&&b!=c)||(b==c&&c!=a)||(a==c&&c!=b)) {
    cout<<"2"<<endl;
  }
  if(a!=b&&b!=c&&a!=c) {
    cout<<"3"<<endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
        char rank[] = {'A', 'B', 'C', 'D', 'F'};
        while(1){
                int m, f, r;
                scanf("%d %d %d", &m, &f, &r);
                if(m<0 && f<0 && r<0) break;
                int sm = m+f;

                int x = (sm<80) + (sm<65) + (sm<50) + (sm<30);
                if(x==3 && r>=50) x = 2;
                if(m<0 || f<0) x = 4;
                printf("%c\n", rank[x]);
        }
        return 0;
}


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

int main() {
  int n;
  scanf("%d", &n);
  
  bool succ = false;
  for (int a = 1; a <= 9; a++)
    if (n % a == 0) {
      int t = n / a;
      if (t >= 1 && t <= 9) {
        succ = true;
        break;
      }
    }

  if (succ)
    printf("Yes\n");
  else
    printf("No\n");

  return 0;
}

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

int divu(int x, int y){
    if( x % y == 0)
        return x / y;
    else
        return x / y + 1;
}

int main(){
    int l, a, b, c, d;
    cin >> l >> a >> b >> c >> d;
    cout << l - max( divu(a, c), divu(b, d) ) << endl;
    return 0;
}

Measured memory_bytes: 1164
package main

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

func main() {
	S := oneStr()
	T := oneStr()
	A := oneInt()
	B := oneInt()
	U := oneStr()

	if S == U {
		fmt.Printf("%v %v", A-1, B)
	} else if T == U {
		fmt.Printf("%v %v", A, B-1)
	} else {
		fmt.Printf("%s %s %s", S, T, U)
	}

}

func searchAbove(slice []int, target int, index int) int {
	for i := index + 1; i < len(slice); i++ {
		v := slice[i]
		if v >= target {
			return i
		}
	}
	return -1
}

var sc = bufio.NewScanner(os.Stdin)

func oneInt() int {
	var a int
	fmt.Scan(&a)
	return a
}
func oneStr() string {
	var a string
	fmt.Scan(&a)
	return a
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func scanNums() (nums []int) {
	s := nextLine()
	numStr := strings.Split(s, " ")

	for _, n := range numStr {
		i, _ := strconv.Atoi(n)
		nums = append(nums, i)
	}
	return nums
}

func scanStrings() (strs []string) {
	s := nextLine()
	list := strings.Split(s, " ")
	strs = append(strs, list...)
	return strs
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

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

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

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

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}


Measured memory_bytes: 640
a=int(input())
b=list(input())
count=0
if a%2==1:
    print("No")
else:
    for i in range(0,a//2,1):
        if b[i]!=b[i+a//2]:
            count+=1
    if count==0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3060
N=int(input())
A=list(map(int,input().split()))
B=[]
C=[]

for i in range(N):
    if i%2==0:
        B.append(A[i])
    else:
        C.append(A[i])

anseven=C[::-1]+B
ansodd=B[::-1]+C

if N%2==1:
    print(*ansodd)
else:
    print(*anseven)

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SP << " " 
#define LLi long long int

using namespace std;

int imax=2147483647;
long long int llimax=9223372036854775807;

//int型vectorを出力
void PV(vector<int> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

//LLi型vectorを出力
void PVL(vector<LLi> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

int main(){

	int n;
	LLi ans=0;
	vector<int> v;

	cin>> n;
	v.resize(n);

	rep(i, n) cin >> v[i];

	for(int i=1;i<n;i++) {
		if (v[i]<v[i-1]) ans+=v[i-1]-v[i];
		v[i]=max(v[i], v[i-1]);
	}

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

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

// int/long:            -2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:      -9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define MOD 1000000007

#define Rep0(i, n)      for (auto i=0; i<n; i++)
#define Rep1(i, n)      for (auto i=1; i<=n; i++)
#define Sort(P) sort(P.begin(), P.end())
#define Rev(P)  reverse(P.begin(), P.end())

int     main() {
        string S;
        cin >>S;
        cout <<S.substr(0, 3) <<endl;
        return 0;
}


Measured memory_bytes: 3628
import logging
import math

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)
            
def main():
    S = int(input())
    logging.info("Hello!")

    if S < 10 ** 9:
        print("0 0 1 0 1 " + str(S))
    else:
        X_3 =  10 ** 9 - (S % (10 ** 9))

        if X_3 == 10 ** 9:
            Y_3 = int(S / (10 ** 9))
            X_3 = 0
        else:
            Y_3 = int(S / (10 ** 9)) + 1
        
        
        print("0 0 1000000000 1 " + str(X_3) + " " + str(Y_3))
        
        
if __name__ == "__main__":
    main()


Measured memory_bytes: 4596
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef long long ll;
typedef char keytype;

int gcd(int a, int b){ return (a % b) ? gcd(b, a % b) : b;}
int lcm(int a, int b){ return (a / gcd(a, b)) * b;}

/* a[0], ..., a[n-1] の数の最大公約数 */
int ngcd(int n, int a[])
{
    int i, d;

    d = a[0];
    for (i = 1; i < n && d != 1; i++)
        d = gcd(a[i], d);
    return d;
}

void quicksort(keytype a[], int first, int last)
{
    int i, j;
    keytype x, t;

    x = a[(first + last) / 2];
    i = first;  j = last;
    for ( ; ; ) {
        while (a[i] < x) i++;
        while (x < a[j]) j--;
        if (i >= j) break;
        t = a[i];  a[i] = a[j];  a[j] = t;
        i++;  j--;
    }
    if (first  < i - 1) quicksort(a, first , i - 1);
    if (j + 1 < last) quicksort(a, j + 1, last);
}

int is_prime(int x){
    if(x <= 1) return 0;
    for(int i = 2; i * i <= x; i++){
        if(x % i == 0) return 0;
    }
    return 1;
}

int is_substr(char s[], char t[], int i){
    int flag = 1;

    if(s[i] == '\0') flag = 0;

    for(int j = 0; j < strlen(t); ++j, ++i){
        if(s[i] != t[j]){
            flag = 0;
            break;
        }
    }
    return flag;
}

// factor list, number of factors, natural number
void factorize(int ftr[], int *num, int n){
    int a = 2, cnt = 0;

    while(n >= a){
        if(n % a == 0){
            n = n / a;
            ftr[cnt++] = a;
        }else{
            a++;
        }
    }
    *num = cnt;
}

//#define N 5
//int p[N + 1];
int nextperm(int p[], int N)  /* 辞書式順序で次の順列 */
{
    int i, j, t;

    i = N - 1;
    p[0] = 0;  /* 番人 */
    while (p[i] >= p[i + 1]) i--;
    if (i == 0) return 0;  /* 完了 */
    j = N;
    while (p[i] >= p[j]) j--;
    t = p[i];  p[i] = p[j];  p[j] = t;
    i++;  j = N;
    while (i < j) {
        t = p[i];  p[i] = p[j];  p[j] = t;  i++;  j--;
    }
    return 1;  /* 未了 */
}

void comb(int size1, int size2, int v[size1][size2]){
  for(int i = 0; i < size1; i++){
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for(int k = 1; k < size1; k++){
    for(int j = 1; j < k; j++){
      v[k][j] = (v[k-1][j-1] + v[k-1][j]);
    }
  }
}

int abs_val(int a, int b){
    if(a > b) return a - b;
    else return b - a;
}

int min(int a, int b){
    if(a > b) return b;
    else return a;
}

const int inf = 1012345678;
int main(){
    int n;
    int a[100], b[100], c[100];

    scanf("%d", &n);
    for(int i = 0; i < n; ++i){
        scanf("%d", &a[i]);
    }
    int sum = 0;
    for(int i = 0; i < n; ++i){
        scanf("%d", &b[i]);
        sum += b[i];
    }
    for(int i = 0; i < (n - 1); ++i){
        scanf("%d", &c[i]);
    }

    for(int i = 0; i < (n - 1); ++i){
        if((a[i] + 1) == a[i+1]){
            sum += c[a[i]-1];
        }
    }

    printf("%d\n", sum);

    return 0;
}


Measured memory_bytes: 1708
#include<cstdio>
#include<cstring>
char c[233][233];
inline int read()
{
	register char ch;register bool aa=1;
	while(ch=getchar(),ch>57||ch<48)ch=='-'?aa=0:0;register int x=ch^48;
	while(ch=getchar(),ch>47&&ch<58)x=x*10+(ch^48);
	return aa?x:-x;
}
int main()
{
	register int n=read(),k,l,m;
	for(int i=1;i<=n;i++)scanf("%s",c[i]);
	for(int i=2;i<=n;i++)
	{
		l=strlen(c[i]);
		for(int j=1;j<i;j++)
		{
			m=strlen(c[j]);
			if(l==m)
			{
				bool aa=1;
				for(int p=0;p<l;p++)
				  if(c[j][p]!=c[i][p])
				  {
				  	aa=0;break;
				  }
				if(aa)return!puts("No");
			}
		}
		k=strlen(c[i-1]);
		if(c[i][0]!=c[i-1][k-1])return!puts("No");
	}
	return!puts("Yes");
}

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

using namespace std;

int main()
{
    int A,B;
    scanf("%d%d",&A,&B);
    string s;
    cin >> s;
    int len=s.size();
    int flag=1;
    for(int i=0;i<len;i++)
    {
        if(i==A)
        {
            if(s[i]!='-')
                flag=0;
        }
        else
        {
            if(s[i]<'0'||s[i]>'9')
                flag=0;
        }
    }
    if(flag)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
const int dy[]={0,-1,0,1,1,-1,-1,1};
const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int h, w, K; cin >> h >> w >> K;
	int sy, sx, gy, gx; cin >> sy >> sx >> gy >> gx;
	--sx, --sy;
	--gx, --gy;
	char c[h][w]; rep(i,h)rep(j,w) cin >> c[i][j];
	int64_t dist[h][w][4]; rep(i,h)rep(j,w)rep(k,4) dist[i][j][k] = LINF;
	deque<tuple<int, int, int64_t, int, int>> deq;
	for(int d = 0; d < 4; ++d) {
		deq.emplace_back(sy, sx, 0, d, 0);
		dist[sy][sx][d] = 0;
	}
	while(not deq.empty()) {
		auto [y, x, cos, dir, fo] = deq.front();
		// cerr << y << " " << x << " " << cos << " " << dir << " " << fo << '\n';
		deq.pop_front();
		// if(cos > dist[y][x][dir]) continue;
		for(int d = 0; d < 4; ++d) {
			if(d == dir) {
				int ny = y + dy[d];
				int nx = x + dx[d];
				if(ny < 0 or h <= ny) continue;
				if(nx < 0 or w <= nx) continue;
				if(c[ny][nx] == '@') continue;
				if(fo == 0) {
					deq.emplace_front(y, x, cos, d, K);
					continue;
				}
				int nc = cos;
				if(fo == K) {
					++nc;
				}
				if(nc <= dist[ny][nx][d]) {
					dist[ny][nx][d] = nc;
					if(nc == cos) {
						deq.emplace_front(ny, nx, cos, d, fo - 1);
					} else {
						deq.emplace_front(ny, nx, nc, d, fo - 1);
					}
				}
			} else {
				if(cos < dist[y][x][d]) {
					dist[y][x][d] = cos;
					deq.emplace_back(y, x, cos, d, K);
				}
			}
		}
	}
	// for(int d = 0; d < 4; ++d) {
	// 	for(int y = 0; y < h; ++y) {
	// 		for(int x = 0; x < w; ++x) {
	// 			cout << dist[y][x][d] << " ";
	// 		}
	// 		cout << '\n';
	// 	}
	// 	cout << '\n';
	// }
	int64_t ans = LINF;
	for(int i = 0; i < 4; ++i) {
		ans = min(ans, dist[gy][gx][i]);
	}
	cout << (ans == LINF ? -1 : ans) << '\n';
	return 0;
}

Measured memory_bytes: 78864
import java.util.OptionalLong;
import java.util.Scanner;
import java.util.stream.LongStream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        OptionalLong result = LongStream.iterate(1, l -> l + 1).limit(n).reduce((l, l2) -> l * l2);
        Long r = result.getAsLong();
        System.out.println(r);
    }
}

Measured memory_bytes: 31796
using namespace std;
#include <bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
void solve()
{
int n;
cin>>n;
int ans=0;
for (int i = 1; i <=n; i++)
{
    int va;
    cin>>va;
    if(va%2&&i%2)
    ans++;
}
cout<<ans<<endl;
}
int main()
{

FASTIO
 long long int t;
 t=1;
 while(t--)
  solve();
  return 0;
}


Measured memory_bytes: 3604
#include<stdio.h>
int main(void){
  int yasu,m,i,sum=0;
  scanf("%d %d",&yasu,&m);
  int kadai[m];
  for(i=0;i<m;i++){
    scanf("%d",&kadai[i]);
    sum+=kadai[i];
  }
  yasu-=sum;
  if(yasu>=0){
    printf("%d",yasu);
  }else{
    printf("-1");
  }
  return 0;
}

Measured memory_bytes: 1732
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextInt();
		long A = sc.nextInt();
		long B = sc.nextInt();
		sc.close();
		if(N == 1) {
			if(A != B) {
				System.out.println(0);
			}else {
				System.out.println(1);
			}
			System.exit(0);
		}
		if(B < A) {
			System.out.println(0);
			System.exit(0);
		}
		long min = A + B + A * (N - 2);
		long max = A + B + B * (N - 2);
		System.out.println(max - min + 1);
	}
}


Measured memory_bytes: 23124
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)

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

	char cr = 'a';
	int a = 0, b = 0, c = 0;
	while (1) {
		if (cr == 'a') {
			if (a == A.size()) {
				cout << "A" << endl;
				return 0;
			}
			cr = A[a];
			a++;
		}
		else if (cr == 'b') {
			if (b == B.size()) {
				cout << "B" << endl;
				return 0;
			}
			cr = B[b];
			b++;
		}
		else if (cr == 'c') {
			if (c == C.size()) {
				cout << "C" << endl;
				return 0;
			}
			cr = C[c];
			c++;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	double n,k,a,b,sum=0;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>a>>b;
		if(sqrt(a*a+b*b)<=k) sum++;
	}
	cout<<sum<<endl;
	return 0;
} 

Measured memory_bytes: 3840
#include<algorithm>
#include<chrono>
#include<ctime>  
#include<climits>
#include<functional>
#include<numeric>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<cassert>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
// #include<bits/stdc++.h>
using namespace std;
 
struct Debug{
    int cnt = 0;
    bool on = false;
    char debug[10] = "debug";
    template<class T>
    Debug & operator<<(const T & v) {
        if(on && cnt++ == 0) cerr << "debug: ";
        if(on) cerr << v << ' ';
        return *this;
    }
    Debug & operator<<(ostream&(*pManip)(ostream&)) {
        if(on) cerr << (*pManip);
        cnt = 0;
        return *this;
    }
} debug;
#define rep(i, a, b) for(auto i = (a); i < (b); i++)
#define rrep(i, a, b) for(auto i = (a); i > (b); i--)
#define all(v) (v).begin(), (v).end()
#define print(v) {if(debug.on){for(auto x : v) debug << x; debug << endl;}}
#define printn(v, n) {if(debug.on){for(int _i = 0; _i < n; _i++) debug << *(v + _i); debug << endl;}}
#define mini(a, b) a = min(a, b)
#define maxi(a, b) a = max(a, b)

typedef unsigned long long ull;
typedef long long ll;
 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

const int MAXN = 5e5 + 10;

int n;
int a[MAXN];

int main(int argc, char * argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    // cout.tie(nullptr);
    if(argc > 1 && !strcmp(argv[1], debug.debug)) debug.on = true;


    int n;
    cin >> n;
    cout << (n - 1) / 2 << endl;




    return 0;
 
}














Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#define ll long long
#define endl "\n"
#define __ ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
using namespace std;

string a,b;
int n,t;

int main(){

	cin >> a >> b;
	a+=b;
	n = stoi(a);
	t = sqrt(n);
	if(t*t==n) cout << "Yes\n";
	else cout << "No\n";

}

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

class JoisinoPaper extends HashSet<Long>{
    public JoisinoPaper(){
        super();
    }
    public void call(long x){
        if(this.contains(x)) this.remove(x);
        else this.add(x);
    }
    public int count(){
        return this.size();
    }
}

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        JoisinoPaper paper = new JoisinoPaper();
        for(int n=0; n<N; n++) paper.call(sc.nextLong());
        System.out.println(paper.count());
    }
}


Measured memory_bytes: 65348
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define INF 120000000

using namespace std;

typedef pair<int, int> P;
typedef long long int LL;

int main() {
    LL a, b;
    cin >> a >> b;
    cout << (a * b % 2 == 0 ? "Even" : "Odd") << endl;

    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
const ll inf = 1e6+5;
typedef pair<int, bool> pib;

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



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

using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    cin >> n;
    map<string,ll> mp;
    ll ret = 0;
    for(i=0;i<n;i++){
        string s;
        ll x;
        cin >> s;
        cin >> x;
        ret+=x;
        mp[s] = ret;
    }
    string s;
    cin >> s;
    cout << ret - mp[s] << endl;
    return 0;
}

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

int main()
{
    ll a,b;
    scanf("%lld%lld",&a,&b);
    ll t1=a-a%8;
    ll t2=b-b%8;
    ll ans=0;
    for(ll i=t1;i<a;i++)ans^=i;
    for(ll i=t2;i<=b;i++)ans^=i;
    printf("%lld\n",ans);
    return 0;
}
/*
struct node
{
    ll a,b;
}p[maxn];
ll n,m;
ll cmp(node x,node y)
{
    return x.a<y.a;
}
int main()
{
    ll n,m;
    scanf("%lld%lld",&n,&m);
    for(int i=1;i<=n;i++)scanf("%lld%lld",&p[i].a,&p[i].b);
    sort(p+1,p+n+1,cmp);
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        if(m>=p[i].b){m-=p[i].b;ans+=p[i].b*p[i].a;}
        else {ans+=m*p[i].a;break;}
    }
    printf("%lld\n",ans);
    return 0;
}
/*
int b[maxn];
int a[maxn][maxn];
int main()
{
    int n,m,c;
    scanf("%d%d%d",&n,&m,&c);
    for(int i=1;i<=m;i++)scanf("%d",&b[i]);
    for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)scanf("%d",&a[i][j]);
    int cnt=0;
    for(int i=1;i<=n;i++)
    {
        int ans=0;
        for(int j=1;j<=m;j++)
        {
            ans+=a[i][j]*b[j];
        }
        if(ans+c>0)cnt++;
    }
    printf("%d\n",cnt);
    return 0;
}
/*
int a[maxn];
int main()
{
    int H,W;
    int h,w;
    scanf("%d%d",&H,&W);
    scanf("%d%d",&h,&w);
    int ans=(H-h)*(W-w);
    printf("%d\n",ans);
    return 0;
}
*/


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


bool check(string s){
    for(int i=0; i<s.size(); i++)
        if(s[i]!='A' && s[i]!='C' && s[i]!='G' && s[i]!='T') return false;
    return true;
}


int main (){
    string S; cin >> S;
    int ans = 0;
    for(int i=0; i<S.size(); i++){
        for(int j=0; j<=S.size()-i; j++){
            string r = S.substr(i, j);
            if(check(r)) ans = max(ans, (int)r.size());
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
	int n,m,a,h,p,q,maxh;
	while(1){
		maxh = 0;
		int b[1002][1002] = {};
		cin >> n >> m >> a;
		if(n == 0)break;
		for(int i = 0;i < m;i++){
			cin >> h >> p >> q;
			b[h][p] = q;
			b[h][q] = p;
			maxh = max(maxh,h);
		}
		for(int i = maxh;i > 0;i--){
			if(b[i][a] > 0){
				a = b[i][a];
			}
		}
		cout << a << endl;
	}
	return 0;
}

Measured memory_bytes: 5088
#include<iostream>
#include<algorithm>
#include<cmath>
 
using namespace std;
 
struct DATA{
  int x, y;
  double r;
  DATA(){}
  DATA(int x_, int y_){ x=x_; y=y_; r=(double)x/(double)y; }
  void set(int x_, int y_){ x=x_; y=y_; r=(double)x/(double)y; }
};
 
int main(){
  int n;
  double p, k;
  DATA a, b;
 
  while(1){
    cin >> p >> n;
    if(p == 0 && n == 0) break;
 
    p = sqrt(p);
    a.set((int)p, 1);
    b.set((int)p+1, 1);
 
    for(int i=b.x+1; i<=n; ++i){
      for(int j=2; j<i; ++j){
	k = (double)i/(double)j;
	if(k < a.r) break;
	if(k > b.r) continue;
	if(a.r < k && k <= p) a.set(i, j);
	else if(p < k && k < b.r) b.set(i, j);
      }
    }
    cout << b.x << "/" << b.y << " " << a.x << "/" << a.y << endl;
  }
  return 0;
}

Measured memory_bytes: 1228
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int tate[31],yoko;
	int tates;
	char neko;
	scanf("%d%d",&tates,&yoko);
	for(int i = 1;i<=tates;i++)//縦に０からtates番まで入る
	{
		tate[i] = i;
	}
	int amida1,amida2;
	int a = 0;
	for(int j = 0;j<yoko;j++)
	{
		scanf("%d%c%d",&amida1,&neko,&amida2);
		a = tate[amida1];
		tate[amida1] = tate[amida2];
		tate[amida2] = a;
	}
	for(int i = 1;i <=tates;i++)
	{
		printf("%d\n",tate[i]);
	}
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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 (b<a) { a=b; return 1; } return 0; }
template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
    auto val = table(args...);
    return vector<decltype(val)>(n, move(val));
}
const ll INF = 1e16;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200005;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,c;
    cin >> a >> b >> c;
    if (a+b > c) PRINT("No");
    else if (4*a*b < (c-a-b)*(c-a-b)) PRINT("Yes");
    else PRINT("No");

}


Measured memory_bytes: 256
S=input()
flag = 1
# 1
for i in range(len(S)//2):
  if S[i] != S[len(S)-i-1]:
    flag = 0
    break
    
# 2
part_S = S[0:(len(S)-1)//2]
for i in range(len(part_S)//2):
  if part_S[i] != part_S[len(part_S)-i-1]:
    flag = 0
    break
    
# 3
part_S_2 = S[((len(S)+3)//2)-1:]
for i in range(len(part_S_2)//2):
  if part_S_2[i] != part_S_2[len(part_S_2)-i-1]:
    flag = 0
    break
    
if flag:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll K, N;
    cin >> K >> N;
    int A[N];
    ll max = 0, ans = 0;
    REP(i, N)
    {
        cin >> A[i];
    }
    REP(j, N - 1)
    {
        ll tmp = A[j + 1] - A[j];
        if (tmp > max)
            max = tmp;
        ans += tmp;
        //       cout << ans << endl;
    }

    ll tmp = A[0] + (K - A[N - 1]);
    ans += tmp;
    if (tmp > max)
        max = tmp;
    //    cout << ans << endl;

    ans -= max;
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
  io;
  ll n,x,t;
  cin>>n>>x>>t;
  n=(n / x) + ((n % x) != 0);
  // cout<<n<<endl;
  cout<<n*t<<endl;
  return 0;
}


Measured memory_bytes: 3636
package main

import "fmt"

func main() {
	var k int
	var x int
	fmt.Scan(&k)
	fmt.Scan(&x)
	flag := true

	for i := -(k - 1); i <= (k - 1); i++ {
		ans := x + i
		if ans >= -1000000 && ans <= 1000000 {
			if flag {
				flag = false
			} else {
				fmt.Printf(" ")
			}
			fmt.Printf("%d", ans)
		}
	}
	fmt.Printf("\n")
}


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

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

using namespace std;

typedef int Weight;
Weight INF = 1000000000;
struct Edge{
  int src, dest; Weight weight;
  bool operator < (const Edge &rhs) const {return weight > rhs.weight;}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

void add_edge(Graph &g, int src, int dest, Weight weight) {
  g[src].push_back((Edge){src, dest, weight});
}

// Dijkstra (Verified: AOJ2005)
void dijkstra(Graph &g, Array &d, int s) {
  d.assign(g.size(), INF);
  d[s] = 0;
  typedef pair<Weight,int> P;
  priority_queue<P, vector<P>, greater<P> > que;
  que.push(P(0, s));
  while (!que.empty()) {
    Weight dist = que.top().first;
    int v = que.top().second;
    que.pop();
    if (d[v] < dist) continue;
    REP(i, g[v].size()) {
      Edge e = g[v][i];
      if (d[e.dest] > d[v] + e.weight) {
        d[e.dest] = d[v] + e.weight;
        que.push(P(d[e.dest], e.dest));
      }
    }
  }
}
// The costs of edges must be 0 or 1 (Verified: TCO 2014 Round 2C Medium)
void bfs(Graph &g, vector<int> &d, int s) {
  d.assign(g.size(), INF);
  d[s] = 0;
  typedef pair<Weight,int> P;
  queue<P> que;
  que.push(P(0, s));
  while (!que.empty()) {
    P top = que.front(); que.pop();
    Weight dist = top.first; int v = top.second;
    if (d[v] < dist) continue;
    REP(i, g[v].size()) {
      Edge e = g[v][i];
      if (d[e.dest] > d[v] + e.weight) {
        d[e.dest] = d[v] + e.weight;
        que.push(P(d[e.dest], e.dest));
      }
    }
  }
}

int main() {
  int n,k;
  cin>>n>>k;
  Graph g1(n);
  vector<pair<int,int>> tx;
  REP(i,n) {
    int c,r;
    cin>>c>>r;
    tx.emplace_back(c,r);
  }
  REP(i,k) {
    int a,b;
    cin>>a>>b;
    --a;--b;
    add_edge(g1,a,b,1);
    add_edge(g1,b,a,1);
  }
  Graph g(n);
  REP(i,n){
    Array dst(n);
    bfs(g1,dst,i);
    REP(j,n) {
      if (dst[j] <= tx[i].second) {
        add_edge(g,i,j,tx[i].first);
      }
    }
  }
  Array ans(n);
  dijkstra(g,ans,0);
  cout<<ans[n-1]<<endl;
  return 0;
}

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

struct student
{
	int num;
	double weight;
	double hight;
	double bmi;
};

int main()
{
	student seito;

	while (scanf("%d,%lf,%lf",&seito.num,&seito.weight,&seito.hight)!=EOF)
	{
		seito.bmi = seito.weight / (seito.hight*seito.hight);
		if (seito.bmi >= 25)
		{
			cout << seito.num << endl;
		}
	}
	return 0;
}

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

#define ll long long
#define F(i,m,n) for(ll i=m;i<n;i++)
#define Fr(j,n,m) for(ll j=n;j>=m;j--)
#define vll vector<ll>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vpll vector< pll >
#define tlll tuple < ll ,ll,ll >
/*-------------------------------------*---------------------------------------*/

#define godspeed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout << #x << "=" << x << endl
#define cout_array(a) cout<<#a<<"=";for(auto x: a){ cout<<x<<" ";}cout<<endl

ll gcd(ll a,ll b){
    return (b?gcd(b,a%b):a);
}
const ll MAX_PRIME = 1e9+7;
const ll INF = 1e18;


/*I NEED YOU TO WORK FOR TWO HOURS ON THIS NO MATTER WHAT....THE RESULT DOESN'T MATTER.....ITS ALL ABOUT YOUR EFFORTS.
---------------------------------------------------------------------------------------------------------------------*/

ll fast_pow(ll x,ll y,ll z){
    if(y==0)return 1%z;
    else if(y==1)return x%z;
    if(y%2==0){
        ll res = fast_pow(x,y/2,z);
        return (res*res)%z;
    }
    else{
        ll res = fast_pow(x,y/2,z);
        ll temp = (res*res)%z;
        return ((x%z)*temp)%z;
    }
}
//---------------method for calculating general mod inverse-------uses extended euclid algo
ll gcdExtended(ll a, ll b, ll &x, ll &y){
    // ax+by = m
    if (a==0)         //gcd = b & ax+by = gcd(a,b)---x and y can be negative;
    {
        x = 0;
        y = 1;
        return b;
    }

    ll x1, y1;
    ll d = gcdExtended(b%a, a, x1, y1);
    x = y1-b/a*x1;           //use floor for negative values
    y = x1;
    return d;
}

ll modInverse(ll a, ll mod=MAX_PRIME){
    ll x, y;
    ll d = gcdExtended(a, mod, x, y);
    if (d!=1)        //gcd must be 1 for inverse to exist
    {
        return -1;
    }

    return (x%mod+mod)%mod;
}
int main() {
    godspeed
    ll special = modInverse(2);
    ll n;
    cin>>n;
    vll a(n);
    ll sum1 = 0;
    ll sum2 = 0;
    F(i,0,n){
        cin>>a[i];
        sum1+=a[i];
        sum1%=MAX_PRIME;
        sum2+=fast_pow(a[i],2,MAX_PRIME);
        sum2%=MAX_PRIME;
    }
    ll val = fast_pow(sum1,2,MAX_PRIME) - sum2;
    val = (val + MAX_PRIME)%MAX_PRIME;
    ll ans = (val*special)%MAX_PRIME;
    cout<<ans<<endl;
}


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

int main(){
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    if((A + B) > (C + D)) {
        cout << "Left" << endl;
    } else if ((A + B) < (C + D)) {
        cout << "Right" << endl;
    } else {
        cout << "Balanced" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <utility>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <iomanip>
using namespace std;
typedef long long ll;


const ll mod = 1e9+7;

int main() {
  int N;
  cin >> N;
  vector<vector<int>> a(N, vector<int>(N));
  vector<int> dp(1<<N);

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      cin >> a[i][j];
    }
  }

  dp[0] = 1;
  for (int s = 1; s < (1<<N); s++) {
    int i = __builtin_popcount(s);
    for (int j = 0; j < N; j++) {
      if ((s>>j)&1 == 1 & a[i-1][j] == 1) {
        dp[s] = (dp[s] + dp[s^(1<<j)]) %mod;
      }
    }
    // cout << "s: " << s << endl;
    // cout << "dp: " << dp[s] << endl;
  }
  cout << dp[(1<<N)-1] << endl;
}


Measured memory_bytes: 8448
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;
typedef pair<int,int> pii;

int main() {
    int n, m;
    cin >> n >> m;
    vector<pii> v(n);
    REP (i, 0, n) v[i].first = v[i].second = i;
    vector<pii> p(m);
    REP (i, 0, m) {
        cin >> p[i].first >> p[i].second;
    }
    sort(begin(p), end(p));
    REP (i, 0, m) {
        int y = p[i].second - 1;
        v[y + 1].first = v[y].first;
        v[y].second = v[y + 1].second;
    }
    REP (i, 0, n) {
        cout << v[i].second - v[i].first + 1 << " \n"[i == n - 1];
    }
    return 0;
}


Measured memory_bytes: 5200
#![allow(non_snake_case)]
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;

#[fastout]
fn main() {
    input!{
        x: usize,
    }

    let contest = if x < 1200 {"ABC"} else {"ARC"};

    println!("{}", contest);
}


Measured memory_bytes: 2160
#include <cmath>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

int N;
int A[200010];
long B[200010];

long calc(int b) {

	long res = 0;
	for (int i = 0; i < N; i++) {
		res += abs(A[i] - (b + i+1));
	}

	return res;
}

int main() {
	
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		B[i] = A[i] - (i+1);
	}

	sort(B, B + N, greater<>());

	int b = N % 2 == 0 ? (B[N / 2] + B[N / 2 - 1])/ 2 : B[N / 2];
	long res[2] = {calc(b), calc(b+1)};

	cout << min(res[0], res[1]) << endl;

	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define FORR(x,arr) for(auto& x:arr)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long,long>> vpll;
typedef vector<pair<int,int>> vpii;

vi adj[320000];
vi mod[3];
vi x[2];
void dfs(int x_,int visit,int x1){
	x[x1].push_back(x_);
	FORR(tmp,adj[x_]){
		if(tmp!=visit)dfs(tmp,x_,x1^1);
	}

}
int main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	ini(n);
	int tmp1[320000];
	FOR(i,1,n+1){
		mod[i%3].push_back(i);
	}
	FOR(i,0,n-1){
		ini(x4);
		ini(x4_);
		x4--;
		x4_--;
		adj[x4].push_back(x4_);
		adj[x4_].push_back(x4);
	}
	dfs(0,0,0);
	if(x[0].size()>x[1].size())swap(x[0],x[1]);
	if(x[0].size()<=mod[0].size()){
		while(x[0].size() and mod[0].size()){
			int pos = x[0].back();
			x[0].pop_back();
			int pos1 = mod[0].back();
			mod[0].pop_back();
			tmp1[pos] = pos1;
		}
		FORR(tmp,x[1]){
			FOR(i,0,3){
				if(mod[i].size()){
					int pos = mod[i].back();
					mod[i].pop_back();
					tmp1[tmp] = pos;
					break;
				}
			}
		}
	}
	else{
		while(x[0].size() and mod[2].size()){
			int pos = x[0].back();
			x[0].pop_back();
			int pos1 = mod[2].back();
			mod[2].pop_back();
			tmp1[pos] = pos1;
		}
		while(x[1].size() and mod[1].size()){
			int pos = x[1].back();
			x[1].pop_back();
			int pos1 = mod[1].back();
			mod[1].pop_back();
			tmp1[pos] = pos1;
		}
		FORR(tmp14,x[0]){
			FOR(i,0,3){
				if(mod[i].size()){
					int pos = mod[i].back();
					mod[i].pop_back();
					tmp1[tmp14] = pos;
					break;
				}
			}
		}
		FORR(tmp,x[1]) {
			FOR(i, 0, 3) {
				if (mod[i].size()) {
					int pos = mod[i].back();
					mod[i].pop_back();
					tmp1[tmp] = pos;
					break;
				}
			}
		}
	}
	FOR(i,0,n){
		cout<<tmp1[i]<<" ";
	}
	return 0;
}

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

int main()
{
    int n,k;
    cin >> n >> k;
    long long int arr[n+1];
    arr[0]=0;
    for(int i=0;i<n;i++) cin >> arr[i+1];
    long long int dp[n+1];
    for(int i=0;i<=n;i++) dp[i]=10000000000;
    dp[0]=10000000000;
    dp[1]=arr[0];
    for(int i=2;i<=n;i++)
    {
        for(int j=1;j<=k;j++)
        {
            if(i-j>0)
            dp[i]=min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
        }
    }
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

template<class T>
bool UpdateMax(T &a, const T &b){
  if(a<b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template<class T>
bool UpdateMin(T &a, const T &b){
  if(a>b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int n;
  cin>>n;
  vector<lint> a(n);
  vector<lint> count(n+1);

  for(int i=0;i<n;i++){
    cin>>a[i];
    count[a[i]]++;
  }
  lint pattern=0;
  for(auto v:count){
    pattern+=v*(v-1)/2;
  }
  for(auto v:a){
    lint result=pattern;
    lint recalc=count[v]*(count[v]-1)/2;
    result-=recalc;
    result+=(count[v]-1)*(count[v]-2)/2;
    cout<<result<<endl;
  }


  return 0;
}




Measured memory_bytes: 5760
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

int IN[200005];

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

    vector<int> v;
    rep(i,m) cin >> IN[i];
    for(int i = m - 1; i >= 0; i--){
        if(find(all(v),IN[i]) == v.end()) v.emplace_back(IN[i]);
    }
    static bool used[200005] = {0};
    rep(i,v.size()){
        used[ v[i] ] = true;
        cout << v[i] << endl;
    }
    range(i,1,n + 1){
        if(not used[i]) cout << i << endl;
    }
}

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

int main()
{
	long long int x;
	scanf("%lld", &x);
	long long int y, z;
	y = x / 500;
	z = (x - y * 500) / 5;
	printf("%lld", y * 1000 + z * 5);
	
}

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;
#include <cstring>

int main() {
  int n, k, cnt;
  double l = 0.0, r = 1000000000, mid;
  cin >> n >> k;
  vector<double> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < 100; i++) {
    mid = (l + r) / 2.0;
    cnt = 0;
    for (int j = 0; j < n; j++) {
      cnt += (int)floor(a[j] / mid);
    }
    if (cnt <= k) {
      r = mid;
    } else {
      l = mid;
    }
  }
  cout << (int)ceil(mid) << endl;
}

Measured memory_bytes: 4840