akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

const ll INF = 1000000000;

ll dp[2005][2005], dp2[4005][2005], dp3[4005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(2 * n), b(n), w(n);
    vector<char> c(2 * n);
    for (int i = 0; i < 2 * n; i++) {
        cin >> c[i] >> a[i];
        a[i]--;
        if (c[i] == 'B') b[a[i]] = i;
        else w[a[i]] = i;
    }

    for (int i = 0; i < 2 * n; i++) {
        for (int j = i + 1; j < 2 * n; j++) {
            if (c[j] == c[i]) continue;
            dp2[j][a[i]]++;
        }
    }

    for (int i = 0; i < 2 * n; i++) {
        for (int j = n - 1; j >= 0; j--) {
            dp2[i][j] += dp2[i][j + 1];
        }
    }

    for (int i = 0; i < 2 * n; i++) {
        for (int j = 0; j < i; j++) {
            if (c[i] == c[j]) {
                dp3[i] += (a[j] > a[i]);
            }
        }
    }

    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;

    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            if (j != n) dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + (dp2[w[j]][i] + dp3[w[j]]));
            if (i != n) dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + (dp2[b[i]][j] + dp3[b[i]]));
        }
    }

    /*
    ll ans = 0;
    for (int i = 0, j = 0, k = 0; k < 2 * n; k++) {
        int tar = -1;
        if (i == n) {
            tar = w[j];
            j++;
        } else if (j == n) {
            tar = b[i];
            i++;
        } else {
            if (abs(b[i] - k) < abs(w[j] - k)) {
                tar = b[i];
                i++;
            } else {
                tar = w[j];
                j++;
            }
        }

        for (int x = tar; x > k; x--) {
            if (c[x - 1] == 'B') b[a[x - 1]] = x;
            else w[a[x - 1]] = x;
            if (c[x] == 'B') b[a[x]] = x - 1;
            else w[a[x]] = x - 1; 
            swap(c[x - 1], c[x]);
            swap(a[x - 1], a[x]);    
            ans++;
        }
    }*/

    cout << dp[n][n] << endl;
    return 0;
}

Measured memory_bytes: 94464
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;

int main() {
    int N; cin >> N;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    sort(A.begin(), A.end());

    ll sum = A[N - 1];

    for (int i = N - 2; i >= N / 2; i--) {
        sum += A[i] * 2;
    }
    
    if (N % 2 == 1) {
        sum -= A[N / 2];
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 4840
a, b = map(int, input().split(" "))
count = 0
for v in range(a, b + 1):
    v1 = v % 10
    v2 = v // 10 % 10
    v3 = v // 100 % 10
    v4 = v // 1000 % 10
    v5 = v // 10000 % 10
    if v1 == v5 and v2 == v4:
        count += 1
print(count)


Measured memory_bytes: 9028
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

bool ok1(int src, int a, int b, string s) {
    if (src + 1 >= s.length) return false;
    if (src + 1 == a || src + 1 == b) return false;
    if (s[src + 1] == '#') return false;
    return true;
}

bool ok2(int src, int a, int b, string s) {
    if (src + 2 >= s.length) return false;
    if (src + 2 == a || src + 2 == b) return false;
    if (s[src + 2] == '#') return false;
    return true;
}

bool calc_ba(string s, int n, int a, int b, int c, int d) {
    assert(c > d);
    // a を先に進ませる

    while (a != c || b != d) {
        if (a > c || b > d) break;

        // a を先に進ませて、b を超えさせる
        if (a < b) {
            if (ok1(a, a, b, s)) {
                a++;
                continue;
            }
            else if (ok2(a, a, b, s)) {
                a += 2;
                continue;
            }
            else if (ok1(b, a, b, s)) {
                b++;
                continue;
            }
            else if (ok2(b, a, b, s)) {
                b += 2;
                continue;
            }
            else break; // a, b いずれも移動できない
        }

        assert(a > b);
        if (a != c) {
            if (ok1(a, a, b, s)) {
                a++;
                continue;
            }
            else if (ok2(a, a, b, s)) {
                a += 2;
                continue;
            }
            else break;
        }

        if (b != d) {
            if (ok1(b, a, b, s)) {
                b++;
                continue;
            }
            else if (ok2(b, a, b, s)) {
                b += 2;
                continue;
            }
            else break;
        }
    }

    return a == c && b == d;
}

bool calc(string s, int n, int a, int b, int c, int d) {
    if (c > d) return calc_ba(s, n, a, b, c, d);

    assert(c < d);
    while (a != c || b != d) {
        if (b != d) {
            if (ok1(b, a, b, s)) {
                b++;
                continue;
            }
            else if (ok2(b, a, b, s)) {
                b += 2;
                continue;
            }
            else break;
        }

        if (a != c) {
            if (ok1(a, a, b, s)) {
                a++;
                continue;
            }
            else if (ok2(a, a, b, s)) {
                a += 2;
                continue;
            }
            else break;
        }
    }

    return a == c && b == d;
}

void main() {
    int n, a, b, c, d; scan(n, a, b, c, d);
    string s = read!string;
    writeln(calc(s, n, a-1, b-1, c-1, d-1) ? "Yes" : "No");
}


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

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            SolveA();
            //SolveB();
            //SolveC();
            //SolveD();
        }
        private const long MOD = 1000000007;

        static void SolveA()
        {
            var o = ReadAndParseIntArr();
            int n = o[0];
            int k = o[1];
            var l = ReadAndParseIntArr();
            var list = new List<int>(l);
            list.Sort();
            list.Reverse();
            int ans = 0;
            for(int i=0;i<k;++i)
            {
                ans += list[i];
            }
            Console.WriteLine(ans);
        }

        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int mod = 1000000007;
int n, k;
int node[100005]={0};
vector< vector<int> > to(100005);
void dfs(int cur, int level, int prev = -1) {
    int tmp = (level==0?1:2);
    int cnt = 0;
    for(int next : to[cur]) {
        if(next != prev) {
            node[next] = k - tmp -cnt++;
            dfs(next, level+1, cur);
        }
    }
}
int main() {
    cin >> n >> k;
    rep(i, n-1) {
        int a, b; cin >> a >> b;
        to[a-1].push_back(b-1);
        to[b-1].push_back(a-1);
    }
    node[0] = k;
    dfs(0,0);
    /*rep(i, n) {
        printf("%d ",node[i]);
    }puts("");*/
    ll ans = 1;
    rep(i, n) {
        ans = (ans*node[i])%mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 11904
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
a = [int(input()) for _ in range(N)]
class SegTree:
  def segfunc(self, x, y):
    return max(x, y)
  def __init__(self, n, ide_ele, init_val):
    #####単位元######
    self.ide_ele = ide_ele
    #num:n以上の最小の2のべき乗
    self.num = 2 ** (n - 1).bit_length()
    self.seg = [self.ide_ele] * 2 * self.num
    #set_val
    for i in range(n):
      self.seg[i + self.num - 1] = init_val[i]    
    #built
    for i in range(self.num - 2, -1, -1) :
      self.seg[i] = self.segfunc(self.seg[2 * i + 1], self.seg[2 * i + 2]) 
  def update(self, k, x):
    k += self.num - 1
    self.seg[k] = x
    while k + 1:
      k = (k - 1) // 2
      self.seg[k] = self.segfunc(self.seg[k * 2 + 1], self.seg[k * 2 + 2]) 
  def query(self, p, q):
    if q <= p:
      return self.ide_ele
    p += self.num - 1
    q += self.num - 2
    res = self.ide_ele
    while q - p > 1:
      if p & 1 == 0:
        res = self.segfunc(res, self.seg[p])
      if q & 1 == 1:
        res = self.segfunc(res, self.seg[q])
        q -= 1
      p = p // 2
      q = (q - 1) // 2
    if p == q:
      res = self.segfunc(res, self.seg[p])
    else:
      res = self.segfunc(self.segfunc(res, self.seg[p]), self.seg[q])
    return res

mx = max(a)
seg = SegTree(mx + 1, 0, [0] * (mx + 1))
for x in a:
  q = seg.query(max(0, x - K), min(mx, x + K) + 1)
  seg.update(x, q + 1)
print(seg.query(0, mx + 1))

Measured memory_bytes: 124472
#include <iostream>
#include <map>
using namespace std;
 
int main(int argc, char const* argv[])
{
  int i, n, m;
  char dest, target;
 
  while (true) {
    cin >> n;
    map<char, char> table;
 
    if (n == 0) { break; }
 
    for (i = 0; i < n; i++) {
      cin >> dest;
      cin >> target;
      table[dest] = target;
    }
 
    cin >> m;
 
    for (i = 0; i < m; i++) {
      cin >> target;
 
      if (table.find(target) != table.end()) {
        cout << table[target];
      } else {
        cout << target;
      }
    }
    cout << endl;
  }
 
  return 0;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    string s;
    cin>>s;
    cout<<s.substr(0,3)<<endl;
    
    
    return 0;
}


Measured memory_bytes: 3628
package main

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

type sign int

const (
	minus sign = -1 + iota
	undefined
	plus
)

type state struct {
	totalOps, currentSum int
	preSign              sign
}

func main() {
	var n int
	fmt.Scan(&n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	var stateStartsPlus, stateStartsMinus state
	stateStartsPlus.preSign = minus
	stateStartsMinus.preSign = plus
	for i := 0; i < n; i++ {
		sc.Scan()
		a, _ := strconv.Atoi(sc.Text())
		stateStartsPlus = nextState(stateStartsPlus, a)
		stateStartsMinus = nextState(stateStartsMinus, a)
	}
	var minOps int
	if stateStartsPlus.totalOps < stateStartsMinus.totalOps {
		minOps = stateStartsPlus.totalOps
	} else {
		minOps = stateStartsMinus.totalOps
	}
	fmt.Printf("%d\n", minOps)
}

func nextState(s state, val int) state {
	s.currentSum += val
	var ops int
	ops, s.currentSum, s.preSign = adjust(s.currentSum, s.preSign)
	s.totalOps += ops
	return s
}

func adjust(sum int, preSign sign) (ops, fixedSum int, nextSign sign) {
	switch preSign {
	case plus:
		nextSign = minus
		if sum < 0 {
			fixedSum = sum
			return
		}
		ops = sum + 1
		fixedSum = -1
	case minus:
		nextSign = plus
		if sum > 0 {
			fixedSum = sum
			return
		}
		ops = -sum + 1
		fixedSum = 1
	}
	return
}


Measured memory_bytes: 2176
input()
a = list(map(int, input().split()))

dp = 1
for x in a:
  dp |= dp << x

s = sum(a)
dp >>= (s + 1) // 2
dp <<= (s + 1) // 2
dp = bin(dp)

print(len(dp) - len(dp.rstrip('0')))


Measured memory_bytes: 9876
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

func rotate(a []int, e, m, b int) {
	ac := make([]int, len(a))
	copy(ac, a)
	for k := 0; k < e-b; k++ {
		ac[b+((k+(e-m))%(e-b))] = a[b+k]
	}
	copy(a, ac)
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt(sc)
	a := make([]int, n)
	for i := range a {
		a[i] = nextInt(sc)
	}
	q := nextInt(sc)
	for i := 0; i < q; i++ {
		b := nextInt(sc)
		m := nextInt(sc)
		e := nextInt(sc)
		rotate(a, e, m, b)
	}
	wtr := bufio.NewWriter(os.Stdout)
	for i := 0; i < n; i++ {
		if i > 0 {
			fmt.Fprint(wtr, " ")
		}
		fmt.Fprint(wtr, a[i])
	}
	fmt.Fprintln(wtr)
	wtr.Flush()
}



Measured memory_bytes: 5896
s = gets.chomp.chars
hs = Hash.new(0)
s.each do |c|
  hs[c] += 1
end
y = (hs["N"] > 0 && hs["S"] > 0) || (hs["N"] == 0 && hs["S"] == 0)
x = (hs["E"] > 0 && hs["W"] > 0) || (hs["E"] == 0 && hs["W"] == 0)
puts (x && y)? "Yes" : "No"

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <cstdlib>
#define MAX 1000

using namespace std;

class selfstack
{
  public:
    int S[MAX] = {};
    int top;

    selfstack()
    {
        initialize();
    }

    void initialize()
    {
        top = 0;
    }

    bool isEmpty()
    {
        return top == 0;
    }

    bool isFull()
    {
        return top >= MAX - 1;
        //cout << "error" << endl;
    }

    void push(int x)
    {
        if (isFull())
        {
            cout << "overflow error" << endl;
            return;
        }
        top++;
        S[top] = x;
    }
    int pop()
    {
        if (isEmpty())
        {
            cout << "underflow error" << endl;
        }
        top--;
        return S[top + 1];
    }
};

int main()
{
    selfstack A;
    int a, b;
    string s;

    while (cin >> s)
    {
        int a, b;
        if (s[0] == '+')
        {
            a = A.pop();
            b = A.pop();
            A.push(a + b);
        }
        else if (s[0] == '-')
        {
            b = A.pop();
            a = A.pop();
            A.push(a - b);
        }
        else if (s[0] == '*')
        {
            a = A.pop();
            b = A.pop();
            A.push(a * b);
        }
        else
        {
            A.push(atoi(s.c_str()));
        }
    }

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

    return 0;
}


Measured memory_bytes: 3180
#include<bits/stdc++.h>
using namespace std;
//      std macros
typedef long long ll;
typedef pair<int ,int> pii;
typedef pair<ll ,ll> pll;
//      dereference
#define F first
#define S second
#define pb push_back
#define mp make_pair
//      loops
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,a,b) for(int i=a;i<=b;++i)
#define PER(i,b,a) for(int i=b;i>=a;--i)
#define all(X) (X).begin(), (X).end()
//      I/O
#define sd(n) scanf("%d",&n)
#define sd2(x,y) scanf("%d%d",&x,&y)
#define sd3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define sll(n) scanf("%lld",&n)
#define sll2(x,y) scanf("%lld%lld",&x,&y)
#define sll3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
//      debug
#define debug(x) cerr<<"debug->"<<#x<<"::"<<x<<endl
#define debug2(x,y) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n"
#define debug3(x,y,z) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n"
#define debug4(x,y,z,w) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<"\n"
//      set values
#define mset(n,k) memset(n,k,sizeof(n))
#define MOD 1000000007
ll INV2=500000004;
ll INV6=166666668;
//modular expo
ll power(ll a,ll b, ll c){
    ll x=1,y=a;
    while(b>0){
        if(b&1)
            x=(x*y)%c;
        y=(y*y)%c;
        b/=2;
    }
    return x%c;
}
//perfect numbers till 10^6 6, 28, 496, 8128
int dx[]={0,-1,0,1};
int dy[]={-1,0,1,0};//clockwise from left
int dr[]={1,1,0,-1,-1,-1, 0, 1};
int dc[]={0,1,1, 1, 0,-1,-1,-1};//anticlockwise from down
const int N = 1e5+5;
int a[N],has[N];
ll ans[N];
ll fac[N],ifac[N];
int main()
{
  fac[0]=ifac[0]=1;
  REP(i,1,N-1) {
    fac[i] = (i*fac[i-1])%MOD;
    ifac[i] = power(fac[i],MOD-2,MOD);
  }
  int n,last,fir;
  sd(n);
  REP(i,1,n+1) {
    sd(a[i]);
    has[a[i]]++;
    //debug2(a[i],has[a[i]]);
    if(has[a[i]]==2){
      //  debug2(i,a[i]);
      last=n+1-i;
    }
  }
  REP(i,1,n+1) {
    if(has[a[i]]==2) {
      fir=i-1;
      break;
    }
  }
  ans[1] = n;
  REP(i,2,n+1) {
    ll fi = fac[n+1];
    fi=(fi*ifac[i])%MOD;
    fi=(fi*ifac[n-i+1])%MOD;
    ll se=0;
    if(fir+last>=(i-1)) {
      se=fac[fir+last];
      se=(se*ifac[i-1])%MOD;
      se=(se*ifac[fir+last-i+1])%MOD;
    }
    ll fin=(fi-se+MOD)%MOD;
    //debug3(fi,se,idx);
    ans[i]=fin;
  }
  REP(i,1,n+1) {
    printf("%lld\n",ans[i]);
  }


            


return 0;
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int px[90000];
int py[90000];
vector<int> ret[90000];
int mp( int a, int b ){ return abs( px[a] - px[b] ) + abs( py[a] - py[b] ); }
int main( void )
{
  ios::sync_with_stdio(false);
  int H, W, D, Q;
  cin >> H >> W >> D;
  for( int y=0; y<H; y++ ){
    for( int x=0; x<W; x++ ){
      int a;
      cin >> a;
      a--;
      px[a] = x;
      py[a] = y;
    }
  }
  for( int i=0; i<D; i++ ){
    int j = i;
    ret[i].push_back( 0 );
    while( j + D < H*W ){
      ret[i].push_back( ret[i][j/D] + mp( j, j+D ) );
      j += D;
    }
  }
  cin >> Q;
  for( int i=0; i<Q; i++ ){
    int l, r;
    cin >> l >> r;
    l--; r--;
    int rem = l%D;
    cout << ret[rem][r/D] - ret[rem][l/D] << endl;
  }
}

Measured memory_bytes: 6144
A, B, C, D, E, F = map(int, input().split())

mc, mw, ms = 0, 0, 0
for a in range(F // (A * 100) + 1):
    for b in range((F - a * A * 100) // (B * 100) + 1):
        if a == 0 and b == 0:
            continue
        for c in range((F - (a * A + b * B) * 100) // C + 1):
            for d in range((F - (a * A + b * B) * 100 - c * C) // D + 1):
                w, s = (a * A + b * B) * 100, c * C + d * D
                if w + s <= F and w * E >= s * 100 and mc <= s / (w + s):
                    mc, mw, ms = s / (w + s), w, s
print(mw + ms, ms)


Measured memory_bytes: 3064
import collections
n=int(input())
a=list(map(int,input().split()))
if a[0]==0 and a.count(0)==1:
  ans=1
else:
  ans=0
a=collections.Counter(a)
for i in range(max(a)):
  ans*=a[i]**a[i+1]
  ans%=998244353
print(ans)

Measured memory_bytes: 24296
import heapq
n,m,s,t = map(int,input().split())
edgeY = [[] for _ in range(n)]
edgeS = [[] for _ in range(n)]
for i in range(m):
    u,v,a,b = map(int,input().split())
    edgeY[u-1].append((a, v-1))
    edgeY[v-1].append((a, u-1))
    edgeS[u-1].append((b, v-1))
    edgeS[v-1].append((b, u-1))
costY = [float('inf')]*n
costS = [float('inf')]*n
costY[s-1] = 0
costS[t-1] = 0

# 円の時
q = []
for i in edgeY[s-1]:
    heapq.heappush(q, i)
while len(q):
    nowEdge = heapq.heappop(q)
    if costY[nowEdge[1]] == float('inf'):
        costY[nowEdge[1]] = nowEdge[0]
        for i in edgeY[nowEdge[1]]:
            heapq.heappush(q , (i[0]+costY[nowEdge[1]], i[1]))

# スヌークの時
q = []
for i in edgeS[t-1]:
    heapq.heappush(q, i)        
while len(q):
    nowEdge = heapq.heappop(q)
    if costS[nowEdge[1]] == float('inf'):
        costS[nowEdge[1]] = nowEdge[0]
        for i in edgeS[nowEdge[1]]:
            heapq.heappush(q , (i[0]+costS[nowEdge[1]], i[1]))
cost = []
ans = []
first = 10**15
minCost = 10**15
for i in range(n-1,-1,-1):
    nowCost = costY[i]+costS[i]
    if minCost > nowCost:
        minCost = nowCost
    ans.append(minCost)
for i in range(n-1,-1,-1):
    print(first- ans[i])

Measured memory_bytes: 126400
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <queue>
using namespace std;
string s;
int len;
int main()
{
	cin>>s;
	len=s.length();
	int f=0;
	for(int i=0;i<len;i++)
	{
		if(s[i]!=s[len-i-1])
		{
			f=1;
			break;
		}
	}
	for(int i=0;i<(len-1)/2;i++)
	{
		if(s[i]!=s[(len-1)/2-i-1])
		{
			f=1;
			break;
		}
	}
	for(int i=(len+3)/2;i<len;i++)
	{
		if(s[i]!=s[len-i-1])
		{
			f=1;
			break;
		}
	}
	if(f)
	{
		cout<<"No";
	}
	else
	{
		cout<<"Yes";
	}
    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++)

int main() {
  int N, K;
  double A, Sum=0, Max=0;
  cin >> N >> K;
  vector<double> P(N);
  rep(i, N){
    cin >> A;
    P.at(i)=(A+1)/2;
  }
  rep(i, K) Sum+=P.at(i);
  Max=Sum;
  for(int i=1; i<N-K+1; i++){
    Sum=Sum-P.at(i-1)+P.at(i+K-1);
    if(Max<=Sum) Max=Sum;
  }
  cout << setprecision(20) << Max << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i;
    cin>>n;

    int a[n];
    int sum=0,avg;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    avg=(sum)/n;
    int avg1=(sum+n-1)/n;
    long long ans=0,ans1=0;
    for(i=0;i<n;i++){
        ans+=(avg-a[i])*(avg-a[i]);
        ans1+=(avg1-a[i])*(avg1-a[i]);
    }
    cout<<min(ans,ans1)<<endl;
    return 0;
}


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

using namespace std;

using ll = long long;
using ull = unsigned long long;
using db = double;
using ii = pair <int, int>;

#define FOR(a, b, c) for(int a = b, _c = c; a <= _c; ++a)
#define ROF(a, b, c) for(int a = b, _c = c; a >= _c; --a)
#define ALL(a, b) for(auto &a : b)
#define fi first
#define se second
#define pb push_back
#define all(a) a.begin(), a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define bit(x, i) (x >> (i - 1) & 1ll)
#define onbit(x, i) (x | (1ll << (i - 1)))
#define offbit(x, i) (x & ~(1ll << (i - 1)))

template <class T> void Max(T &x, T y) { x = (x > y) ? x : y;}
template <class T> void Min(T &x, T y) { x = (x < y) ? x : y;}

const int N = 2e5 + 5;
const ll mod = 1e9 + 7;

int n;
vector <int> ad[N];
ll gt[N], inv[N], f[N], sz[N];

ll pw(ll x, ll i) {
  ll b = 1;
  for(; i; i >>= 1, x = x * x % mod) if(i & 1) b = b * x % mod;
  return b;
}
void dfs(int u, int par) {
  sz[u] = 1;
  for(auto &v : ad[u]) {
    if(v != par) {
      dfs(v, u);
      sz[u] += sz[v];
    }
  }
}
void dfs2(int u, int par) {
  for(auto &v : ad[u]) {
    if(v != par) {
      f[v] = f[u] * sz[v]  % mod;
      sz[u] = n - sz[v];
      sz[v] = n;
      f[v] = f[v] * pw(sz[u], mod - 2) % mod;
      dfs2(v, u);
      sz[v] = n - sz[u];
      sz[u] = n;
    }
  }
}
main() {
  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cin >> n;
  FOR(i, 1, n - 1) {
    int u, v;
    cin >> u >> v;
    ad[u].push_back(v);
    ad[v].push_back(u);
  }
  gt[0] = 1;
  FOR(i, 1, n) gt[i] = gt[i - 1] * i % mod;
  dfs(1, 0);
  f[1] = gt[n];
  FOR(i, 1, n) f[1] = f[1] * pw(sz[i], mod - 2) % mod;
  dfs2(1, 0);
  FOR(i, 1, n) {
    cout << f[i] << '\n';
  }
}


Measured memory_bytes: 20212
r,c = map(int, raw_input().split())

col_sum = [0] * (c+1)
for i in range(r):
    row = map(int, raw_input().split())
    row.append(sum(row))
    col_sum = [a + b for a, b in zip(row, col_sum)]
    
    print " ".join(map(str, row))
    
print " ".join(map(str, col_sum))

Measured memory_bytes: 6408
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    LLONG N;
    cin >> N;
    cout << N * (N - 1) / 2 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <map>
#include <algorithm>
#include <vector>
#include <queue>

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

typedef pair<int,int> s;
typedef long long int ll;

int abs(int x){
  return x > 0 ? x : -x;
}

int length(char c[]){
  int cnt=0;
  for(cnt=0;c[cnt]!='\0';cnt++){
  }
  return cnt;
}

char S[1000000];
int main(){
  scanf("%s",S);
  for(int i=0;S[i]!='\0';i++){
    if(i%2==0)
      printf("%c", S[i]);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast","unroll-loops")
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define MP make_pair
#define F first
#define S second
#define MEM(a,b) memset(a,b,sizeof a)
#define Tie ios::sync_with_stdio(0),cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll; 

int tmp,n,a[4];
double dp[910][610][310],l;

int main()
{Tie
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>tmp,a[tmp]++;
	for(int k=0;k<=a[3];k++)
		for(int j=0;j<=a[2]+a[3]-k;j++)
			for(int i=0;i<=a[1]+a[3]-k+a[2]-j;i++)
			{
				if(!(i+j+k))
					continue;
				l=n-i-j-k;
				if(i)
					dp[i][j][k]+=(dp[i-1][j][k]+1)*i;
				if(j)
					dp[i][j][k]+=(dp[i+1][j-1][k]+1)*j;
				if(k)
					dp[i][j][k]+=(dp[i][j+1][k-1]+1)*k;
				dp[i][j][k]=(dp[i][j][k]+l)/(n-l);
			}
	cout <<fixed << setprecision(10)<< dp[a[1]][a[2]][a[3]]<<'\n';
}

Measured memory_bytes: 443904
#include<iostream>
#include<cmath>

using namespace std;

int main(){
 long a,b,c;
  cin >> a >> b >> c;
  
  if(a%2==0||b%2==0||c%2==0) cout << 0 << endl;
  else cout << min(a*b,min(b*c,c*a)) << endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//登録しよう！→ https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define gre greater //sortを降順にする
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示

void solve(long long X){
  int ans;
  for (int i = 1; i <= X; i++) {
    if((i*(i+1))/2 >= X){
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    scanf("%lld",&X);
    solve(X);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <numeric> // accumulate(begin,end,初期値)
#include <string>
#include <cstdio>
#include <queue>
#include <stack>
#include <set>
#include <cmath>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<x<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<#a<<':'<<a<<endl

const ll INF = 1e9+7;

// 各桁の和
template<typename T>inline T digit(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;}
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}

//17 14 0 16 20 19 22 4 7 21 20 15
int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int x1,y1,x2,y2;cin>>x2>>y2>>x1>>y1;
  int x = x2 - x1;
  int y = y2 - y1;
  cout<<x2+y-x<<" "<<y2-x-y<<" ";
  cout<<x2 + y<<" "<<y2 - x<<endl;

  return 0;
} 

Measured memory_bytes: 896
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(), v.end()
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define um unordered_multiset
#define us unordered_set
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define cc continue
#define bb break
#define rem 1000000007
//fflush(stdin);
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    string s,t;
    cin>>s>>t;
    ll a=0;
    rep (i,0,3)
    {
        if (s[i]==t[i])
        a++;
    }
    cout<<a<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define msg(x) debug() << x
#define int long long
const int xx = 2e5;
const int mod = 1e9 + 7;
double distance(int a , int b , int x , int y){
  int xx = a - x;
  int yy = b - y;
  double v = (double)sqrt(xx*xx + yy*yy);
  return v;
}
signed main(){
 // ios::sync_with_stdio(false);cin.tie(0);

  int n;
  cin >> n;
  vector<int>v;
  for(int i=0;i<n;i++){
    v.push_back(i);
  }
  vector<pair<int,int>>vp;
  for(int i=0;i<n;i++){
    int x, y;
    cin >> x >> y;
    vp.emplace_back(x,y);
  }
  int cnt = 0;
  double av = 0.0;
  do{
    for(int i=0;i<n-1;i++){
      av += distance(vp[v[i]].first , vp[v[i]].second , vp[v[i+1]].first , vp[v[i+1]].second);
    }
    cnt++;
  }
  while(next_permutation(v.begin() , v.end()));
  dg1(cnt);

  av = av / (double)cnt;

  printf("%0.10lf\n",av);

}

Measured memory_bytes: 256
n, x = map(int, input().split())
a = list(map(int, input().split()))

a.sort()
total = 0
if x-sum(a) == 0:
  print(n)
elif x >= sum(a) and x-sum(a) != 0:
  print(n-1)
else:
  for i in range(n):
    total += a[i]
    if total > x:
      print(i)
      break

Measured memory_bytes: 3064
import sys
input=sys.stdin.readline
H,W,K=map(int,input().split())
G=[[0]*W for i in range(H)]

for i in range(K):
    r,c,v=map(int,input().split())
    r,c=r-1,c-1
    G[r][c]=v


dp0=[[-1 for i in range(W)] for i in range(H)]
dp1=[[-1 for i in range(W)] for i in range(H)]
dp2=[[-1 for i in range(W)] for i in range(H)]
dp3=[[-1 for i in range(W)] for i in range(H)]

dp0[0][0]=0
if G[0][0]!=0:
    dp1[0][0]=G[0][0]

for i in range(H):
    for j in range(W):
        m=max(dp0[i][j],dp1[i][j],dp2[i][j],dp3[i][j])
        if i+1<H:
            dp1[i+1][j]=max(dp1[i+1][j],m+G[i+1][j])
            dp0[i+1][j]=max(dp0[i+1][j],m)
        if j+1<W:
                dp0[i][j+1]=0
                dp1[i][j+1]=max(dp1[i][j+1],dp1[i][j],dp0[i][j]+G[i][j+1])
                dp2[i][j+1]=max(dp2[i][j+1],dp2[i][j],dp1[i][j]+G[i][j+1])
                dp3[i][j+1]=max(dp3[i][j+1],dp3[i][j],dp2[i][j]+G[i][j+1])
print(max(dp0[H-1][W-1],dp1[H-1][W-1],dp2[H-1][W-1],dp3[H-1][W-1]))

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

if n<10:
  result=n
elif n>=10 and n<100:
  result=n%10
elif n>=100:
  n=n%100
  result=n%10

if result==3:
  print('bon')
elif result==0 or result==1 or result==6 or result==8:
  print('pon')
else :
  print('hon')

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
	vector<long> a(5);
	ll k;
	cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4]>>k;
	cout<<(a[4]-a[0]<=k?"Yay!":":(")<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define int long long int
#define vi vector<int>
#define vvi vector < vi >
#define pii pair<int,int>
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second
#define tr(k,st,en) for(int k = st; k <= en ; ++k)
#define trb(k,en,st) for(int k = en; k >= st ; --k)

using namespace std;

vector<vector<int>> G(100005);
vector<bool> visited(100005, false);
pair<int, int> dfs(int x)
{
    visited[x]=true;
    int w=1,b=1;
    for(auto& i : G[x])
    {
        if(visited[i]==false)
        {
            auto p = dfs(i);
            w = (w * (p.first + p.second)) % mod;
            b = (b * p.first) % mod;
        }
    }
    return make_pair(w, b);
}


int32_t main()
{
    std::ios::sync_with_stdio(false);
    int n,u,v;
    cin>>n;
    for (int i = 1 ; i < n; i++) {
        cin>>u>>v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    auto p = dfs(1);
    cout<<(p.first + p.second)%mod<<endl;
}




Measured memory_bytes: 12948
/* ITP1_3_C */

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

public class Main {
  public static void main (String[] args) throws java.lang.Exception {
    // 入力された値をゲット
   Scanner sc = new Scanner(System.in);

   // 入力データがなくなるまで繰り返す
   while (sc.hasNext()) {
     int x = sc.nextInt();  // 1個目をxにセット
     int y = sc.nextInt();  // 1個目をyにセット

     if((x==0)&&(y==0)) {
        // 処理をぬける
        break;
     } else {
       if(x < y) {
           System.out.println(x + " " + y);
       } else {
           System.out.println(y + " " + x);
       }
     }
   }
 }
}



Measured memory_bytes: 35452
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    string S;
    cin >> S;
    bool flag = true;
    REP(i, S.size()){
        if((i+1)&1){
            if(S[i] == 'R' || S[i] == 'U' || S[i] == 'D'){

            }else{
                flag = false;
            }
        }else{
            if(S[i] == 'L' || S[i] == 'U' || S[i] == 'D'){

            }else{
                flag = false;
            }
        }
    }

    Yes(flag);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
  int a, b, c;

  cin >> a >> b >> c;

if(a + b >= c)
    cout << "Yes" <<endl;
  else
    cout << "No" <<endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())

memo = [[0] * 10 for _ in range(10)]
for i in range(1, N + 1):
    S = str(i)
    a, b = int(S[0]), int(S[-1])
    memo[a][b] += 1

ans = 0
for a in range(1, 10):
    for b in range(1, 10):
        ans += memo[a][b] * memo[b][a]

print(ans)

Measured memory_bytes: 3064
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N, K int
	fmt.Scan(&N, &K)

	p := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&p[i])
	}

	fmt.Println(exec(p, K))
}

func exec(p []int, K int) int {
	sort.Ints(p)

	var sum int

	for i := 0; i < K; i++ {
		sum += p[i]
	}
	return sum
}


Measured memory_bytes: 1884
#include<bits/stdc++.h>
#include<cmath>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
const ll MOD = 1e9+7;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
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<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
#define fs first
#define sc second


const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
template<typename T>
T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T>
T ngcd(vector<T> a){
    T res;
    res = a[0];
    for(int i = 1; i < a.size() && res != 1; i++) {
        res = gcd(a[i], res);
    }
    return res;
}
 
template<typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

template<typename T>
T nlcm(vector<T> numbers) {
    T res;
    res = numbers[0];
    for (int i = 1; i < numbers.size(); i++) {
        res = lcm(res, numbers[i]);
    }
    return res;
}

// 割り算の切り上げ処理
template<typename T>
T round_up(T a, T b) {
  return (a + b - 1) / b;
}

// 約数列挙
template<typename T>
vector<T> calc_divisor(T n) {
   vector<T> res;
   for (T i = 1LL; i*i <= n; ++i) {
       if (n % i == 0) {
           res.push_back(i);
           T j = n / i;
           if (j != i) res.push_back(j);
       }
   }
   sort(res.begin(), res.end());
   return res;
}

// 素数判定
template<typename T>
bool isPrime(T x){
    T i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


using pint = pair<int, int>;
using pll = pair<ll, ll>;

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



int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    int a,b;
    cin >> a >> b;
    rep(i, 1000000){
        int a1 = (int)(i * 0.08);
        int b1 = (int)(i * 0.1);
        if(a1 == a && b1 == b){
            print(i);
            return 0;
        }
    }
    print(-1);
}


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

int main() {
	int n, a;
	double ave = 0;
	cin >> n;
	set<int>st;
	map<int, int>mp;
	for (int i = 0; i < n; i++) {
		cin >> a;
		ave += a;
		if (st.find(a) == st.end()) {
			mp[a] = i;
		}
		st.insert(a);
	}
	ave /= n;
	double min = 99999999;
	int num1, num2;
	bool flag = true;
	for (auto itr = st.begin(); itr != st.end(); itr++) {
		double temp = abs(*itr - ave);
		if (temp < min) {
			num1 = *itr;
			min = temp;
		}
		if (temp == min) {
			num2 = *itr;
			flag = false;
		}
	}
	if (flag) {
		cout << mp[num1] << endl;
	} else {
		int a = mp[num1];
		int b = mp[num2];
		if (a > b)a = b;
		cout << a << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

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

    int B[N-1];
    REP(i, N-1){
        cin >> B[i];
    }

    int A[N];
    A[0] = B[0];
    A[N-1] = B[N-2];
    FOR(i, 1, N-2){
        A[i] = min(B[i-1], B[i]);
    }

    int ans = 0;
    REP(i, N){
        ans += A[i];
    }

    cout << ans << endl;
}


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n, k;
	cin>>n>>k;
	ld ans = 0.0;
	for(int i = 1; i <= n; i++){
		int x = 1;
		while(i*x < k)x <<= 1;
		ans += 1.0/ld(x);
	}
	ans /= n;
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=924844033;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c<=32)c=_buff.get();return c;}
int n,k;
ll fac[2011];
bool pre[2011],nxt[2011];
ll dp0[2011],dp1[2011],ans[2011];
int anssz;
//dp0=dp0'(1+x)+dp1'
//dp1=(dp0'+dp1')x
ll mul_a[2011];
int mul(ll a[],int na,ll b[],int nb,ll c[])
{
	for(int i=0;i<=na+nb;i++)mul_a[i]=0;
	for(int i=0;i<=na;i++)
	{
		for(int j=0;j<=nb;j++)
		{
			mul_a[i+j]=(mul_a[i+j]+a[i]*b[j])%mod;
		}
	}
	for(int i=0;i<=na+nb;i++)c[i]=mul_a[i];
	return na+nb;
}
ll ndp0[2011],ndp1[2011];
void solve(int tn)
{
	memset(dp0,0,sizeof(dp0));
	memset(dp1,0,sizeof(dp1));
	dp0[0]=1;
	for(int i=1;i<=tn;i++)
	{
		memset(ndp0,0,sizeof(ndp0));
		memset(ndp1,0,sizeof(ndp1));
		for(int j=0;j<=i;j++)ndp0[j]=(dp0[j]+dp1[j])%mod;
		if(pre[i])for(int j=1;j<=i;j++)ndp0[j]=(ndp0[j]+dp0[j-1])%mod;
		if(nxt[i])for(int j=1;j<=i;j++)ndp1[j]=(dp0[j-1]+dp1[j-1])%mod;
		swap(dp0,ndp0);
		swap(dp1,ndp1);
	}
	for(int i=0;i<=tn;i++)dp0[i]=(dp0[i]+dp1[i])%mod;
	anssz=mul(dp0,tn,ans,anssz,ans);
}
int main()
{
	fac[0]=1;
	for(int i=1;i<=2005;i++)fac[i]=fac[i-1]*i%mod;
	cin>>n>>k;
	ans[0]=1;
	for(int i=1;i<=min(n,2*k);i++)
	{
		int tn=0;
		for(int j=i;j<=n;j+=2*k)
		{
			pre[++tn]=j-k>=1;
			nxt[tn]=j+k<=n;
		}
		solve(tn);
	}
	ll res=0;
	for(int i=0;i<=n;i++)
	{
		ll cur=ans[i]*fac[n-i]%mod;
		if(i&1)res-=cur;
		else res+=cur;
	}
	res=(res%mod+mod)%mod;
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<iomanip>
using namespace std;
#define SORT(A) std::sort(A.begin(), A.end())
#define RSORT(A) std::sort(A.begin(), A.end(), std::greater<>())
#define FR(A, e) for (auto& e : A)
#define SHOW(A) for (auto& e : A) {cout << e << " ";}; cout << endl;
#define within(x,_left,_right) (_left <= x && x <= _right)
#define ALL(A) A.begin(),A.end()
#define pb push_back
#define sz(x) ((int)x.size())
#define fi first
#define se second
using LL = long long;
using db = double;
using VI = vector<int>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
using VL = vector<LL>;
using VVL = vector<VL>;
const LL MOD = 1e9 + 7;
typedef std::pair<int, int> PII;
typedef std::pair<LL, LL> PLL;
typedef std::pair<int, char> PIC;
using std::cin;
using std::vector;
using std::cout;
using std::endl;
// int dx[4] = {1, -1, 0, 0}; // 冯诺依曼型邻居
// int dy[4] = {0, 0, 1, -1};
// int dx[8] = {-1, -1, 0, 1, 1, 1, 0, -1}; // 摩尔型邻居
// int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
// 字符串类:模拟规律 -> Greedy -> dp -> kmp || Automation (注意数据量， 先数学后暴力)
// #include<iomanip> cout << fixed <<  setprecision(k) 输出k位精度
constexpr int N = 4e4 + 5;
int n;
int v[N][3];

int main() {
	cin >> n;
	string ss;
	cin >> ss;
	for (int i = n - 1; i >= 0; --i) {
		if (ss[i] == 'R') ++v[i][0];
		if (ss[i] == 'G') ++v[i][1];
		if (ss[i] == 'B') ++v[i][2];
		v[i][0] += v[i + 1][0];
		v[i][1] += v[i + 1][1];
		v[i][2] += v[i + 1][2];
	}
	LL ans = 0;
	for (int i = 0; i < n - 2; ++i) {
		for (int j = i + 1; j < n - 1; ++j) {
			if (ss[i] != ss[j]) {
				if (2 * j - i < n && ss[i] != ss[2 * j - i] && ss[j] != ss[2 * j - i]) --ans;
				
				int is0 = 1, is1 = 1, is2 = 1;
				if (ss[i] == 'R' || ss[j] == 'R') is0 = 0;
				if (ss[i] == 'G' || ss[j] == 'G') is1 = 0;
				if (ss[i] == 'B' || ss[j] == 'B') is2 = 0;
				if (is0) {
					ans += v[j + 1][0];
				}
				if (is1) {
					ans += v[j + 1][1];
				}
				if (is2) {
					ans += v[j + 1][2];
				}
			}
		}
	}

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

Measured memory_bytes: 3632
#include<stdio.h>
int main(){
  int a,b,c,d,i,j;
  while(scanf("%d %d",&a,&b) != EOF){
  c=a+b;
  d=0;
  for(i=c;i>0;i=i/10){
    d=1+d;
  }
 printf("%d\n",d);
 

  } return 0;
}

Measured memory_bytes: 0