akhauriyash/Code-Regression huggingface dataset:
class Twelvefold(): #n <= 1000程度
    def __init__(self, n, mod):
        self.mod = mod
        self.fct = [0 for _ in range(n + 1)]
        self.inv = [0 for _ in range(n + 1)]
        self.stl = [[0 for j in range(n + 1)] for i in range(n + 1)]
        self.bel = [[0 for j in range(n + 1)] for i in range(n + 1)]
        self.prt = [[0 for j in range(n + 1)] for i in range(n + 1)]
        self.fct[0] = 1
        self.inv[0] = 1
        self.stl[0][0] = 1
        self.bel[0][0] = 1
        for i in range(n):
            self.fct[i + 1] = self.fct[i] * (i + 1) % mod
        self.inv[n] = pow(self.fct[n], mod - 2, mod)
        for i in range(n)[::-1]:
            self.inv[i] = self.inv[i + 1] * (i + 1) % mod
        for i in range(n):
            for j in range(n):
                self.stl[i + 1][j + 1] = self.stl[i][j] + (j + 1) * self.stl[i][j + 1]
                self.stl[i + 1][j + 1] %= mod
        for i in range(n):
            for j in range(n):
                self.bel[i + 1][j + 1] = self.bel[i + 1][j] + self.stl[i + 1][j + 1] % mod
                self.bel[i + 1][j + 1] %= mod
        for j in range(n):
            self.prt[0][j] = 1
        for i in range(n):
            for j in range(n):
                if i - j >= 0:
                    self.prt[i + 1][j + 1] = self.prt[i + 1][j] + self.prt[i - j][j + 1]
                else:
                    self.prt[i + 1][j + 1] = self.prt[i + 1][j]
                self.prt[i + 1][j + 1] %= mod

    def solve(self, element, subset, equate_element=False, equate_subset=False, less_than_1=False, more_than_1=False):
        assert not less_than_1 or not more_than_1
        n = element
        k = subset
        a = equate_element
        b = equate_subset
        c = less_than_1
        d = more_than_1
        id = a * 3 + b * 6 + c + d * 2
        tw = [self.tw1, self.tw2, self.tw3, self.tw4, self.tw5, self.tw6, self.tw7, self.tw8, self.tw9, self.tw10, self.tw11, self.tw12]
        return tw[id](n, k)

    def tw1(self, n, k):
        return pow(k, n, self.mod)

    def tw2(self, n, k):
        if k - n < 0: return 0
        return self.fct[k] * self.inv[k - n] % self.mod

    def tw3(self, n, k):
        return self.stl[n][k] * self.fct[k] % self.mod

    def tw4(self, n, k):
        if k == 0: return 0
        return self.fct[n + k - 1] * self.inv[n] * self.inv[k - 1] % self.mod

    def tw5(self, n, k):
        if k - n < 0: return 0
        return self.fct[k] * self.inv[n] * self.inv[k - n] % self.mod

    def tw6(self, n, k):
        if n - k < 0 or k == 0: return 0
        return self.fct[n - 1] * self.inv[k - 1] * self.inv[n - k]

    def tw7(self, n, k):
        return self.bel[n][k]

    def tw8(self, n, k):
        if k - n < 0: return 0
        return 1

    def tw9(self, n, k):
        return self.stl[n][k]

    def tw10(self, n, k):
        return self.prt[n][k]

    def tw11(self, n, k):
        if k - n < 0: return 0
        return 1

    def tw12(self, n, k):
        if n - k < 0: return 0
        return self.prt[n - k][k]

n, k = map(int, input().split())
t = Twelvefold(1000, 10**9 + 7)
print(t.solve(n, k, 0, 0, 1, 0))


Measured memory_bytes: 110660
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 3
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt64(scanner)
	k := getNextInt64(scanner)

	var ans int64

	ccc := make([]int64, k+1)
	for i := int64(2); i <= k; i++ {
		ccc[i] = pow(k/i, n)
	}

	for i := k; i > 2; i-- {
		x := i
		dd := div(x)
		for di := len(dd) - 1; di >= 0; di-- {
			if di < len(dd)-1 && dd[di] == dd[di+1] {
				continue
			}
			ccc[dd[di]] = mod(ccc[dd[di]] - ccc[i])
		}
	}
	ccc[1] = pow(k, n)
	for i := k; i >= 2; i-- {
		ccc[1] = mod(ccc[1] - ccc[i])
	}
	for i := k; i >= 1; i-- {
		ans = mod(ans + mod(ccc[i]*i))
	}

	fmt.Fprintln(writer, ans)
}

func pow(k, n int64) int64 {
	doubling := make([]int64, 63)
	doubling[0] = k
	for i := 1; i < 63; i++ {
		doubling[i] = mod(doubling[i-1] * doubling[i-1])
	}
	var ans int64
	ans = 1
	for i := 63 - 1; i >= 0; i-- {
		if n>>uint(i)%2 == 1 {
			ans = mod(ans * doubling[i])
		}
	}
	return ans
}

func mod(x int64) int64 {
	m := int64(1e9 + 7)

	return (x%m + m) % m
}

func div(x int64) i64 {
	dd := make(i64, 0)
	for i := int64(2); i*i <= x; i++ {
		if x%i == 0 {
			dd = append(dd, i)
			if i*i < x {
				dd = append(dd, x/i)
			}
		}
	}

	sort.Sort(dd)
	return dd
}

type i64 []int64

func (a i64) Len() int           { return len(a) }
func (a i64) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a i64) Less(i, j int) bool { return a[i] < a[j] }


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

template<int MOD>
class mod_int {
	unsigned x;
public:
	mod_int() : x(0) { }
	mod_int(int sig) { int sigt = sig % MOD; if (sigt < 0) sigt += MOD; x = sigt; }
	mod_int(long long sig) { int sigt = sig % MOD; if (sigt < 0) sigt += MOD; x = sigt; }
	int get() const { return (int)x; }

	mod_int &operator+=(mod_int that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
	mod_int &operator-=(mod_int that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
	mod_int &operator*=(mod_int that) { x = (unsigned long long)x * that.x % MOD; return *this; }
	mod_int &operator/=(mod_int that) { return *this *= that.inverse(); }

	mod_int operator+(mod_int that) const { return mod_int(*this) += that; }
	mod_int operator-(mod_int that) const { return mod_int(*this) -= that; }
	mod_int operator*(mod_int that) const { return mod_int(*this) *= that; }
	mod_int operator/(mod_int that) const { return mod_int(*this) /= that; }

	bool operator==(const mod_int& that) const { return x == that.x; }

	mod_int inverse() const {
		long long a = x, b = MOD, u = 1, v = 0;
		while (b) {
			long long t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		return mod_int(u);
	}
};

template<int MOD>
istream& operator >> (istream& is, mod_int<MOD>& val) {
	long long x;
	is >> x; val = x;
	return is;
}

template<int MOD>
ostream& operator << (ostream& os, const mod_int<MOD>& val) {
	os << val.get();
	return os;
}

const int mod = 1e9 + 7;
using mint = mod_int<mod>;

int main()
{
	string K;
	int D;
	cin >> K >> D;
	int N = K.size();
	vector<vector<vector<mint>>> dp(N + 1, vector<vector<mint>>(D, vector<mint>(2)));
	dp[0][0][0] = 1;
	for (int i = 0; i < N; i++) {
		int x = K[i] - '0';
		for (int j = 0; j < D; j++) {
			for (int b = 0; b < 2; b++) {
				int lim = b ? 9 : x;
				for (int d = 0; d <= lim; d++) {
					dp[i + 1][(j + d) % D][b || d < lim] += dp[i][j][b];
				}
			}
		}
	}
	mint res = dp[N][0][0] + dp[N][0][1] - 1;
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 55296
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <tuple>
#include <vector>
#include <bitset>
#include <stack>
#include <iomanip>
#include <set>
#include <queue>
#include <map>
typedef long long ll;
typedef unsigned long long ull;
#define mk make_pair
#define mkt make_tuple

using namespace std;
const int N = 300005;
const ll MOD = 1e9 + 7;
const int M = 61;
ll a[N], p[M];
int c[M];


int main()
{
    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        ll temp = a[i];
        int k = 0;
        while (temp > 0) {
            c[k++] += temp & 1;
            temp >>= 1;
        }
    }

    p[0] = 1;
    for (int i = 1; i < 61; i++) {
        p[i] = (p[i - 1] * 2) % MOD;
    }

    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ll temp = a[i];
        int k = 0;
        while (k != 61) {
            int dig = temp & 1;
            c[k] -= dig;
            if (dig == 1) ans = (ans + (p[k] * (n - i - 1ll - c[k])) % MOD) % MOD;
            else ans = (ans + (p[k] * c[k]) % MOD) % MOD;
            k++;
            temp >>= 1;
        }
    }
    cout << ans;
}



Measured memory_bytes: 2560
#include<stdio.h>

int main(void){

    int A,B,C;

    scanf("%d %d %d",&A,&B,&C);

    if(A < B){
        if(A < C && B > C){
            printf("Yes");
        }else{
            printf("No");
        }
    }else{
        if(B < C && A > C){
            printf("Yes");
        }else{
            printf("No");
        }
    }

    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.stream.Collectors;

public class Main {
  private static final int IROHA = 17;
  public static void main(String[] args) {
    try (Scanner scan = new Scanner(System.in)) {
      String input = scan.nextLine();
      String[] arr = input.split("\\s");
      
      List<String> list = new ArrayList<>();
      for (int i = 0; i < Integer.parseInt(arr[0]); i++) {
      	input = scan.nextLine();
        list.add(input);
      }
                                               
      String result = list.stream().sorted().collect(Collectors.mapping(s -> s, Collectors.joining()));
      System.out.println(result);
        
    }
  }
}

Measured memory_bytes: 26828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

struct dijkstra{
    vector<long long> min_dst;
    vector<vector<pair<long long, long long>>> G;

    dijkstra(int n){
        min_dst.resize(n);
        G.resize(n);
    }

    void append(int u, int v, long long cost){G[u].push_back(make_pair(v, cost));}
    
    void run(int s){
        priority_queue<pair<long long, long long>, vector<pair<long long, long long>>, greater<pair<long long, long long>>> que;
        fill(min_dst.begin(), min_dst.end(), -1);
        min_dst[s] = 0;
        que.push(make_pair(0, s));
        
        while(!que.empty()){
            auto p = que.top(); que.pop();
            int at = p.second;
            if(min_dst[at] < p.first){continue;}
            for(int i = 0; i < G[at].size(); i++){
                int to = G[at][i].first;
                long long cost = G[at][i].second;
                if(min_dst[to] == -1 || min_dst[at] + cost < min_dst[to]){
                    min_dst[to] = min_dst[at] + cost;
                    que.push(make_pair(min_dst[to], to));
                }
            }
        }	
    }
    
    long long get(int at){return min_dst[at];}
};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    ll n, m, s; cin >> n >> m >> s;
    ll u[m], v[m], a[m], b[m];
    zep(i, 0, m){
        cin >> u[i] >> v[i] >> a[i] >> b[i];
        u[i]--; v[i]--;
    }    
    ll c[n], d[n]; zep(i, 0, n)cin >> c[i] >> d[i];

    ll mo = 50*n;
    dijkstra di(n*(mo+1));
    zep(i, 0, m){
        rep(j, a[i], mo){
            di.append(u[i]*(mo+1)+j, v[i]*(mo+1)+j-a[i], b[i]);
            di.append(v[i]*(mo+1)+j, u[i]*(mo+1)+j-a[i], b[i]);
        }
    }

    zep(i, 0, n){
        rep(j, 0, mo-c[i]){
            di.append(i*(mo+1)+j, i*(mo+1)+j+c[i], d[i]);
        }
    }

    ll st = min(s, mo);
    di.run(st);

    zep(i, 1, n){
        ll ans = INF;
        rep(j, 0, mo){
            ans = min(ans, di.get(i*(mo+1)+j));
        }
        print(ans)
    }
    
    return 0;
}

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

int main(){
  ll n,ans=1,mod=1e9+7; cin>>n;
  for(int i=1; i<=n; i++){
    ans *= i;
    if(ans>mod) ans %= mod;
  }
  cout<<ans;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc128/tasks/abc128_d
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF (1e9)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
// int gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// int lcm(long a, long b) { return a * b / gcd(a, b); }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> v(n), ans(100, -INF);
    REP(i, n) cin >> v[i];
    // 左側から取り出す処理
    int suml = 0;
    multiset<int> que1;
    for (int i = 0; i <= min(k, n); i++) {
        if (i > 0) {
            que1.insert(v[i - 1]);
            suml += v[i - 1];
        }
        int sumr = 0;
        multiset<int> que2 = que1;
        // 右側から取り出す処理
        for (int j = 0; i + j <= min(k, n); j++) {
            if (j > 0) {
                que2.insert(v[n - j]);
                sumr += v[n - j];
            }
            ans[i + j] = max(ans[i + j], suml + sumr);
            int cnt = 0, mi = 0;
            multiset<int> que3 = que2;
            for (auto x : que3) {
                cnt++;
                if (i + j + cnt > k)
                    break;
                mi += x;
                ans[i + j + cnt] = max(ans[i + j + cnt], suml + sumr - mi);
            }
        }
    }
    cout << *max_element(ALL(ans)) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>

using namespace std;

int a,b,c;

int main() {
	scanf("%d %d %d",&a,&b,&c);
	c-=(a-b);
	if(c<0) {
		printf("0");
	} else {
		printf("%d",c);
	}
}

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

void solve(long long A, long long B){
    if (A <= 5) cout << 0 << '\n';
    else if (A >= 6 && A <= 12) cout << B / 2 << '\n';
    else cout << B << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF INT_MAX 
#define mod 1000000007
using namespace std;
int main(){
    int N,A,B;
    cin >> N >> A >> B;
    if(abs(A-B)%2==0){
        cout << "Alice" << endl;
    }else{
        cout << "Borys" << endl;
    }
}

Measured memory_bytes: 256
def dfs(i, f, sum):
    if i == 3:
        if sum == 7:
            # 答えは1つ出力すれば良いので =7 になれば終了
            print(f + "=7")
            exit()

    else:
        # 式 f の末尾に符号と次の数字を追加し、その分 sum に加減する
        dfs(i + 1, f + "-" + s[i + 1], sum - int(s[i + 1]))
        dfs(i + 1, f + "+" + s[i + 1], sum + int(s[i + 1]))


s = input()

dfs(0, s[0], int(s[0]))

Measured memory_bytes: 3064
#include <stdio.h>

int main(void){

  char ki[51], gu[51];
  int i=0;

  scanf("%s", ki); scanf("%s", gu);

  while(ki[i]!='\0'){
    printf("%c", ki[i]);

    if(gu[i]=='\0')
    break;
    
    printf("%c", gu[i]);
    i++;
  }

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define in insert
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++)
    cin>>a[i];
    ll dp[n]={0};
    dp[0]=0,dp[1]=abs(a[0]-a[1]);
    for(ll i=2;i<n;i++)
    dp[i]=min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]));
    cout<<dp[n-1];
    return 0;
}

Measured memory_bytes: 5216
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        int s;
        cin >> s;
        vector<ll> arr;
        arr.push_back(s);
        

        set<ll> appeared;
        appeared.insert(s);

        while (true) {
            ll next = arr.back();
            if (next % 2 == 0) next /= 2;
            else next = 3 * next + 1;

            if (appeared.count(next)) {
                cout << arr.size() + 1 << endl;
                return;
            }

            arr.push_back(next);
            appeared.insert(next);


        }

    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.array;

string mathed(char[] s, char[] t)
{
    for (int i = cast(int)(s.length-t.length); i >= 0; i--) {
	if (s[i] == t[0] || s[i] == '?') {
	    int ii = i;
	    bool flag = true;
	    for (int j = 0; j < t.length;) {
		if (!(s[i] == t[j] || s[i] == '?')) {
		    flag = false;
		    break;
		}
		i++;
		j++;
	    }

	    if (flag) {
		for (int j = 0; j < t.length; j++) {
		    s[ii+j] = t[j];
		}
		return cast(string)s.replace("?", "a");
	    }
	    else {
		i = ii;
	    }
	}
    }
    return "UNRESTORABLE";
}


void main()
{
    char[] s = readln.chomp.dup;
    char[] t = readln.chomp.dup;

    writeln(mathed(s, t));

}


Measured memory_bytes: 256
#include <iostream>
//#include <strings.h>

using namespace std;

#define REP(i,n) for(int i=0; i<(n); i++)
#define debug(x) cout << #x << " : " << (x) <<  endl;

int dp[20][1<<14], n, kaburi[20][20];
string str[20];

bool issubstring(string x, string y){
  // return true when y is a substring of x
  // O(|x|*|y|)
  if (y.length() > x.length()){
    return false;
  }
  int yl = y.length();
  for (int j=0; j+y.length()<=x.length(); j++){
    string subx= x.substr(j, yl);
    if (subx==y){
      return true;
    }
  }
  return false;
}

int func(int a, int bit){
  // 最後に追加した文字列がstr[a], 残っている文字列がbit
  // 残っている文字列を並べたときの最小の長さを返す
  
  if (dp[a][bit]>=0){
//    cout << "dp" << endl;
    return dp[a][bit];
  }
  int ret = 1000000000;
  string now = str[a];
  
  REP(i,n){
    if (i==a || ((bit>>i) & 1)==0){
      continue;
    }
    
    string next = str[i];
//    printf("now: %s, next: %s\n", now.c_str(), next.c_str());
    
    if ((bit^(1<<i))==0) {
      // nextしか残っていなかった場合
      ret = min(ret, (int)next.length() - kaburi[a][i]);
    }else{
      ret = min(ret, func(i, bit^(1<<i)) + (int)next.length() - kaburi[a][i]);
    }
//    debug(next);
//    debug(ret);
  }
  dp[a][bit] = ret;
  return ret;
}

int main(){
  
  while(1) {
    int ans = 1000000000;
    cin >> n;
    if (n==0){
      break;
    }
    
    REP(i, 20){
      REP(j, 1<<14){
        dp[i][j] = -1;
      }
    }
    REP(i,n){
      REP(j,n){
        kaburi[i][j] = 0;
      }
    }
    
    REP(i, n) {
      cin >> str[i];
    }
    
    if (n==1){
      cout << str[0].length() << endl;
      continue;
    }

    REP(j,n){
      REP(k,n){
        if (j!=k && issubstring(str[j], str[k])){
          str[k] = "";
        }
      }
    }
    
    REP(i,n){
      REP(j,n){
        string now = str[i];
        string next = str[j];
        for (int k=1; k<min(now.length(), next.length()); k++){
          // 被っている部分の長さを調べる
          string nowsub = now.substr(now.length()-k);
          string nextsub = next.substr(0, k);
//          debug(nowsub);
//          debug(nextsub);
          if (nowsub==nextsub) {
            kaburi[i][j] = k;
//            debug(k);
          }
        }
      }
      
    }

    REP(i, n) {
//    debug(((1<<n)-1)^(1<<i));
      ans = min(ans, (int)str[i].length() + func(i, ((1 << n) - 1) ^ (1 << i)));
//      cout << "-----------------" << endl;
    }
    cout << ans << endl;
  }
  return 0;
  
}


Measured memory_bytes: 4300
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll dp[3001][3001];
int main()
{
	ll n,i,j;
	cin >> n;
	ll a[n];
	deque<ll>dq;
	for(i=0;i<n;i++)
	{
		cin >> a[i];
		dq.push_back(a[i]);
	}
	ll start,end;
	for(start=n-1;start>=0;start--)
	{
		for(end=start;end<n;end++)
			dp[start][end]=max(a[start]-dp[start+1][end],a[end]-dp[start][end-1]);
			
	}
	cout<<dp[0][n-1]<<"\n";
}

Measured memory_bytes: 70016
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a ;
  cin >> a ;
  int s1 , s2 , s3 ;
  s1 = a / 100 ;
  s2 = (a - s1 * 100) / 10 ;
  s3 = a - s1 * 100 - s2 * 10 ;
    cout << s1 + s2 + s3 ;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct BoolName : numpunct<char> {
  string t, f;
  BoolName (string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const {return t;}
  string do_falsename() const {return f;}
};

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
    cout.imbue(locale(cout.getloc(), new BoolName));
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

void set_bool_name(string t, string f) {
  cout.imbue(locale(cout.getloc(), new BoolName(t, f)));
}

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 << "Balanced" << endl;
  else cout << "Right" << endl;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>

using namespace std;

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

static const double eps = 10e-9;

string getAlert(double h,double m){
	double angleM = m * 6.0;
	double angleH = h * 30.0 + (m*6.0)/12.0;

	double dist = min(abs(angleH-angleM),360-abs(angleH-angleM));
	if(90 <= dist && dist <= 180) return "safe";
	else if(0 <= dist && dist < 30) return "alert";
	else return "warning";
}

int main(){
	int n;
	double h,m;
	while(~scanf("%d",&n)){
		for(int i=0;i<n;i++){
			scanf("%lf:%lf",&h,&m);
			cout << getAlert(h,m) << endl;
		}
	}
}

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

using namespace std;

int main() {
    int k,a,b;
    cin >> k >> a >> b;

    int s  = a/k;
    if ( a%k ) {
        s++;
    }
    if( (k * s) <= b ) {
        cout << "OK";
    }else{
        cout << "NG";
    }
    return 0;
}


Measured memory_bytes: 3636
m = int(raw_input())
n = int(raw_input())
a = [[False] * (m + 1) for _ in range(m + 1)]
b = [0] * (m + 1)
for _ in range(n):
    x, y = map(int, raw_input().split())
    a[y][x] = True
    b[y] += 1
for i in range(m):
    for j in range(m):
        if b[j + 1] == 0:
            print j + 1
            b[j + 1] = -1
            for k in range(m):
                if a[k + 1][j + 1]:
                    b[k + 1] -= 1

Measured memory_bytes: 4252
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int (i) = 0ll; (i) < (n); ++(i))
#define repp(i,n) for(int (i) = 1; (i) <= (n); ++(i))
#define popcnt __builtin_popcount
#define all(v) v.begin(),v.end()
#define _Pi 3.1415926535
#define _MOD = 1e9+7;
using namespace std;
using ll = long long;
using pint = pair<int,int>;
using itn = int;
using vint = vector<int>;
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b; return true;} return false;}
template<class T> T gcd(T a, T b){return b?gcd(b,a%b):a;}
template<class T> T lcm(T a, T b){return a*b/gcd(a,b);}

int main(){
    ll a,b,c,x,y; cin >> a >> b >> c >> x >> y;

    if(a+b<=c*2){
        cout << a*x + b*y << endl;
    }
    else if(a <= c*2 && b <= c*2){
        cout << min(x,y)*c*2 + (x-min(x,y))*a + (y-min(x,y))*b << endl;
    }
    else if(a > c*2 && b > c*2){
        cout << max(x,y)*c*2 << endl;
    }
    else if(a > c*2 && b <= c*2){
        cout << x*c*2 + max(0ll,y-x)*b << endl;
    }
    else if(a <= c*2 && b > c*2){
        cout << y*c*2 + max(0ll,x-y)*a << endl;
    }
    

    return 0ll;
}


Measured memory_bytes: 256
N = int(input())
A = []
for _ in range(N):
    A.append(int(input()))

A.sort()

B = []
for i in range(N):
    if i==0 or i==N-1:
        B.append((-1)**i)
    else:
        B.append(((-1)**i)*2)
B.sort()

print(max(abs(sum([A[i]*B[i] for i in range(N)])),abs(sum([A[i]*B[N-1-i] for i in range(N)]))))

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

struct Edge {
    int to, id;
    Edge(int _to, int _id) : to(_to), id(_id) {}
};

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<Edge>> G(N);
    for(int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].emplace_back(b, i);
        G[b].emplace_back(a, i);
    }
    auto dfs = [&](auto &&dfs, int cur, int ng, vector<bool> &visited) -> void {
        visited[cur] = true;
        for(auto &e : G[cur]) {
            if(!visited[e.to] && e.id != ng) {
                dfs(dfs, e.to, ng, visited);
            }
        }
    };
    int ans = M;
    for(int i = 0; i < N; ++i) {
        for(auto &e : G[i]) {
            if(i < e.to) {
                vector<bool> visited(N);
                dfs(dfs, i, e.id, visited);
                bool all = true;
                for(int j = 0; j < N; ++j) {
                    if(!visited[j]) all = false;
                }
                if(all) ans--;
            }
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif

#include<unistd.h>
struct Buffer{
    int idx;
    enum { chunk = 1 << 16 };
    char buf[chunk];
    Buffer(){ init(); }
    void init(){ idx = 0; read(0, buf, chunk); }
    void check(){ if(idx == chunk){ init(); } }
    int next(){
        static char notDigits[256] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1, 0,0,0,0,0,0,0,0,0,0,};
        int ret = 0, sign = 1;
        while(check(), notDigits[(int)buf[idx]]){ idx++; }
        if(check(), buf[idx] == '-'){ sign = -1; idx++; }
        while(check(), !notDigits[(int)buf[idx]]){ ret = ret * 10 + buf[idx++] - '0'; }
        return sign * ret;
    }
};

string ans;
void out(int num){
    if(!num){
        // putchar('0');
        ans += '0';
        return;
    }
    char buf[16];
    int idx = 0;
    while(num){
        auto ret = div(num, 10);
        buf[idx] = ret.rem + '0';
        num = ret.quot;
        idx++;
    }
    for(int i = idx - 1; i >= 0; i--){
        // putchar(buf[i]);
        ans += buf[i];
    }
}

int main(){
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    Buffer buf;
    const int lim = 1e5;
    vector<char> prime(lim + 1, true);
    prime[0] = prime[1] = false;
    for(int i = 2; i <= lim; i++){
        if(prime[i]){
            for(int j = i + i; j <= lim; j += i){
                prime[j] = false;
            }
        }
    }
    vector<int> accs(lim + 1);
    for(int i = 1; i <= lim; i++){
        accs[i] = accs[i - 1] + (i & 1 && prime[i] && prime[(i + 1) / 2]);
    }
    // printd(accs[lim]);
    // int q; cin >> q;
    int q = buf.next();
    // stringstream ss;
    ans.reserve(4 * q);
    for(int i = 0; i < q; i++){
        // int l, r;
        // cin >> l >> r;
        int l = buf.next(), r = buf.next();
        // cout << accs[r] - accs[l - 1] << '\n';
        // ss << accs[r] - accs[l - 1] << '\n';
        out(accs[r] - accs[l - 1]);
        // putchar('\n');
        ans += '\n';
    }
    // cout << ss.str();
    cout << ans;
    // write(1, ans.data(), ans.size());
}


Measured memory_bytes: 1536
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define INF10 1001001001 
#define INF5 100000
#define EPS 1e-10


int main() {
	int N;
	cin >> N;
	vector<int> p(N);
	for (int i = 0; i < N; i++) {
		cin >> p[i];
	}
	vector<int> ans(p.begin(), p.end());
	sort(ans.begin(), ans.end());
	int in_f = 1;
	for (int i = 0; i < N; i++) {
		if (ans[i] != p[i]) {
			in_f = 0;
			break;
		}
	}
	if (in_f) {
		print("YES");
		return 0;
	}
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			int tmp = p[i];
			p[i] = p[j];
			p[j] = tmp;
			int flag = 1;
			for (int k = 0; k < N; k++) {
				if (ans[k] != p[k]) {
					flag = 0;
					break;
				}
			}
			if (flag) {
				print("YES");
				return 0;
			}
			tmp = p[i];
			p[i] = p[j];
			p[j] = tmp;

		}
	
	}
	print("NO");



	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
const int MAX = 1000000;
const int MOD = 1000000007;

int main(){
	string s;
	cin>>s;
	REP(i,SZ(s)){
		printf("%c",'x');
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    string x,y;
    int k = 1;
    int cnt = 0;
    for (int j = 0; j < n; j++)
    {
        x = "";
        y = "";
        cnt = 0;
        for (int i = 0; i < k; i++)
        {
            x += s[i];
        }

        for (int i = k; i < n; i++)
        {
            y += s[i];
        }

        for (char c = 'a'; c <= 'z'; c++)
        {
            bool flagx = false, flagy = false;
            for (int i = 0; i < k; i++)
            {
                if(x[i] == c) flagx = true;
            }
            for (int i = 0; i < n-k; i++)
            {
                if(y[i] == c) flagy = true;
            }
            if(flagx && flagy) cnt++;
            
        }  
        if(ans < cnt) ans = cnt;
        k++; 

    }

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

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define rf(x) (x)=0;while(*p<48)p++;while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15);
//#define rf(x) (x)=0;while(*p<48)im=*p=='-';while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15);if(im)(x)=-(x);
#define pb push_back
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define befv(V) ((V)[(sz(V)-2)])
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define clv(V) (V).clear()
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define rb(x) ((x)&(-(x)))
#define cb(x) (x)=(!(x))
#define INF (0x3f3f3f3f)
#define INFLL (0x3f3f3f3f3f3f3f3fll)
#define INFST (0x7f7f7f7f)
#define INFLLST (0x7f7f7f7f7f7f7f7fll)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
typedef complex<ld> base;
const ld EPS = (ld)1e-7;
const ld PI = acos(0) * 2;
bool isZero(const ld& x) { return abs(x) <= EPS; }
int sign(const ld& x) { return isZero(x) ? 0 : (0 < x ? 1 : -1); }
ll gcd(ll a, ll b) { for(;b;a%=b,swap(a,b)){} return abs(a); }
pll operator + (const pll& a, const pll& b) { return pll(a.first+b.first, a.second+b.second); }
pll operator - (const pll& a, const pll& b) { return pll(a.first-b.first, a.second-b.second); }
pll operator * (const pll& a, const ll& b) { return pll(a.first*b, a.second*b); }
ll operator * (const pll& a, const pll& b) { return a.first*b.second - b.first*a.second; }
ll ccw(const pll& a, const pll& b, const pll& c) { return a*b + b*c + c*a; }
void fg(vector<int> G[], int a, int b) { G[a].pb(b); G[b].pb(a); }
void fg(vector<pii> G[], int a, int b, int c) { G[a].pb({b, c}); G[b].pb({a, c}); }

bool n, s, e, w;
char A[1005];

int main() {
	scanf(" %s", A);
	for(int i = 0; A[i]; i++) {
		if('N' == A[i]) n = true;
		else if('S' == A[i]) s = true;
		else if('E' == A[i]) e = true;
		else w = true;
	}
	if((n && !s) || (!n && s) || (e && !w) || (!e && w)) puts("No");
	else puts("Yes");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>

using namespace std;

int main (){
  int n,m,bufa,bufb;
  cin >> n >> m;
  map<int, int> parentNum;
  map<int, vector<int>> children;
  for(int i = 0; i < n; i++){
    parentNum[i] = 0;
    children[i] = vector<int> {};
  }
  for(int i = 0 ; i < n-1+m; i++){
    cin >> bufa >> bufb;
    parentNum[bufb-1]++;
    children[bufa-1].push_back(bufb-1);
  }

  int answer[n];
  int parent = 0;
  vector<int> isolated = {};
  for(int i=0; i < n; i++){
    if(parentNum[i] == 0){
      answer[i] = -1;
      isolated.push_back(i);
      break;
    }
  }
  while(isolated.size() > 0){
    int buf;
    parent = isolated[isolated.size() - 1];
    isolated.pop_back();
    vector<int> found={};
    vector<int> bufv = children[parent];
    for(int i=0; i < (int)bufv.size(); i++){
      buf = bufv[i];
      parentNum[buf]--;
      if(parentNum[buf] == 0){
        found.push_back(buf);
      }
    }
    for(int i=0;i < (int)found.size(); i++){
      buf = found[i];
      answer[buf] = parent;
      isolated.push_back(buf);
    }
  }
  for(int i=0;i<n;i++){
    cout << answer[i] + 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 16896
#include<stdio.h>

int BinarySearch(int A[],int n,int k){
	int L,M,R;
	L=0;
	R=n;
	while(L<R){
		M=(L+R)/2;
		if(A[M]==k){
			return 1;
		}
		if(A[M]<k){
			L=M+1;
		}else{
			R=M;
		}
	}
	return 0;
}

int main(){
	int n,q,k;
	int A[100000];
	int i;
	int a,s;
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&A[i]);
	}
	
	scanf("%d",&q);
    s=0;
	for(i=0;i<q;i++){
		scanf("%d",&k);
		a=BinarySearch(A,n,k);
		if(a==1){
			s++;
		}
	}
	
	printf("%d\n",s);
	return 0;
}

Measured memory_bytes: 988
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define ld long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpii vector<pii>
#define gr vector<vpii>
#define str string
#define mask vector<bool>
#define vs vector<str>
#define pq priority_queue
#define ordered_set_of(T) tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define nub(x) x.resize(unique(all(x)) - x.begin())
#define TWO class T1, class T2
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define MOD 998244353LL
#define MAXN (int)2E5
#define GAME_OVER return 0
using namespace std;
using namespace __gnu_pbds;
char _$ = ' ';
struct sep {sep(char c) {_$ = c;}};
ostream& operator<<(ostream& o, sep s) {return o;}
template<TWO> ostream& operator<<(ostream& o, pair<T1, T2> x) {return o << x.fi << ' ' << x.se;}
template<TWO> istream& operator>>(istream& i, pair<T1, T2>& x) {return i >> x.fi >> x.se;}
template<class T> ostream& operator<<(ostream& o, vector<T> x) {for (auto it : x) o << it << _$; return o;}
template<class T> istream& operator>>(istream& i, vector<T>& x) {for (auto& it : x) i >> it; return i;}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int k;
    str s;
    cin >> k >> s;
    if (sz(s) <= k)
        cout << s << endl;
    else
    {
        for (int i = 0; i < k; i++)
            cout << s[i];
        cout << "..." << endl;
    }
    GAME_OVER;
}

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

int main() {

	string S;
	cin >> S;
	long long S_int;
	istringstream iss(S);
	iss >> S_int;

	int s[S.size()];
	for(int i=0; i<S.size(); i++) {
		s[i] = S_int % 10;
		S_int /= 10;
	}	 

	int num_pattern=1;
	for(int i=0; i<S.size()-1; i++) {
		num_pattern *=2;
	}
	long long sum=0;
	long long answer;
	long long temp=0;
	for(int i=0; i<num_pattern; i++) {
		temp = s[S.size()-1];
		answer = 0;
		for(int j=S.size()-2; j>=0; j--) {
			if(i & (1 << j)) { // insert +
				answer += temp;
				temp = s[j];
			}
			else {
				temp = temp*10 + s[j];
			}
		}
		answer += temp;
		sum += answer;
	}
	cout << sum << endl;
	return 0;
}



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

int main() {

int W, H, x, y;

	double S;

	scanf("%d %d %d %d", &W, &H, &x, &y);

	S = ((double)W) / 2.0 * ((double)H);

	if (x * 2 == W && y * 2 == H) {
		printf("%lf 1\n", S);
	}
	else {
		printf("%lf 0\n", S);
	}
	return 0;
}

Measured memory_bytes: 128
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n,m; cin>>n;
    map<int,int> s;
    rep(i,n){
        int d; cin>>d;
        if(!(s.count(d))) s[d]=0;
        s[d]++;
    }
    string ans="YES";
    cin>>m;
    rep(i,m){
        int t; cin>>t;
        if(s.count(t) && s[t]>0) s[t]--;
        else ans="NO";
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 9600
import java.io.*;
import java.util.*;
 
public class Main {
    public static void main(String args[]) throws IOException {
        Scanner sc = new Scanner(System.in);
        Integer num = sc.nextInt();
        List<String> str= new ArrayList<>();
        str.add(sc.next());
        for (int index = 1; index < num; index ++) {
            String tmp = sc.next();
            if(str.contains(tmp) || !tmp.substring(0,1).equals(str.get(index-1).substring(str.get(index-1).length()-1))){
                 System.out.println("No");
                 System.exit(0);
            }
            str.add(tmp);
        }
        System.out.println("Yes");
    }
}

Measured memory_bytes: 22996
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[2]);

        if (input[1] == "+")
        {
            Console.WriteLine(a + b);
        }
        else
        {
            Console.WriteLine(a - b);
        }

        #if DEBUG
                Console.WriteLine("Press any key to continue...");
                Console.ReadKey();
        #endif
    }
}

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

int main(){
  int d;
  int c[27];
  int s[400][27];
  int t[400];
  static int last[27];//最後の開催日
  int ans = 0;

  cin >> d;
  rep(i, 26)cin >> c[i+1];
  rep(i, d){
    rep(j, 26){
      cin >> s[i+1][j+1];
    }
  }

  rep(i, d){
    cin >> t[i+1];
  }
  for(int i=1;i<=d;i++){
    ans += s[i][t[i]];
    last[t[i]]=i;
    for(int j=1;j<=26;j++)ans-=(i-last[j])*c[j];

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


Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;

 
lint fac[MAX], finv[MAX], inv[MAX];

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return 0;
        }
    }

    // 素数である
    return 1;
}

lint g[200005];
  int main(){
     
      lint N;
      cin>>N;
      repp(i,1,N+1){
          lint x=i;
            repp(j,2,i+1){
                    if(x%j==0){g[j]++;
                    x/=j;
                    if(j!=1)j--;
                    }
            }
      }
     lint ans=1;
     
      repp(i,2,200005){
                ans*=(g[i]+1);
                ans%=MOD;
            }
      
    
      cout<<ans;
   
  }

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
int A[10]={0}, N=0, ch[10]={0};
for(int i=0;i<9;i++){
scanf("%d", &A[i]);
}
scanf("%d",&N);
int B[N];
for(int i=0;i<N;i++){
    scanf("%d", &B[i]);
}

for(int i=0;i<9;i++){
    for(int j=0;j<N;j++){
        if(A[i]==B[j]){
            ch[i]=1;
        }
    }
}
if(ch[0] && ch[1] && ch[2] == 1)printf("Yes\n");
else if(ch[3] && ch[4] && ch[5]== 1)printf("Yes\n");
else if(ch[6] && ch[7] && ch[8]== 1)printf("Yes\n");
else if(ch[0] && ch[3] && ch[6]== 1)printf("Yes\n");
else if(ch[1] && ch[4] && ch[7]== 1)printf("Yes\n");
else if(ch[2] && ch[5] && ch[8]== 1)printf("Yes\n");
else if(ch[0] && ch[4] && ch[8]== 1)printf("Yes\n");
else if(ch[2] && ch[4] && ch[6]== 1)printf("Yes\n");
else printf("No\n");
return 0;
}

Measured memory_bytes: 128
N = int(input())
H = [int(_) for _ in input().split()]
count = 0
max_count = 0
for n in range(N - 1):
    if H[n] >= H[n + 1]:
        count += 1
        if max_count <= count:
            max_count = count
    else:
        if max_count <= count:
            max_count = count
        count = 0
        
print(max_count)

Measured memory_bytes: 14252
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"5
3
10000
9000"# => r#"48000"#,
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        n: usize,
        k: usize,
        x: usize,
        y: usize,
    }

    let mut ans = 0;

    for i in 1..n + 1 {
        if i <= k {
            ans += x;
        } else {
            ans += y;
        }
    }

    ans.to_string()
}

Measured memory_bytes: 4352
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();  // input Integer
    int b = sc.nextInt();  // input Integer
    int c = sc.nextInt();  // input Integer
    
    int count=0;
    for (int i = a; i<=b; i++){
      if (i%c==0){
        count++;
      }
    }
    System.out.println(count);

    //    String a = sc.next();  // input String
  }
}

Measured memory_bytes: 35776