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

const int INF  = 1e9;
const long long INFLL = 1e18;
const int NMAX = 100005;
const int MMAX = 100005;
const int KMAX = 1005;
const int MOD  = 1e9 + 7;
using namespace std;

// comment to disable debug functions
#define DEBUG

// frequently used macros

#if __cplusplus >= 201103L
#define ALL(v) begin(v),end(v)
#define SORT(v) sort(begin(v), end(v))
#define FIND(v,x) find(begin(v), end(v), (x))
#else
#define ALL(v) (v).begin(),(v).end()
#define SORT(v) sort(v.begin(), v.end())
#define FIND(v,x) find(v.begin(), v.end(), (x))
#endif

#define fi first
#define se second

#define MEMNEXT(from, to) do{ memmove((to), (from), sizeof(from)); \
memset((from), 0, sizeof(from)); } while(0)
#ifdef DEBUG
#define DUMP(x) do{ std::cerr << (#x) << ": " << x << std::endl; }while(0)
#else
#define DUMP(x) do{}while(0)
#endif

// frequent used aliases
typedef long long ll;
typedef pair<int, int> p;
typedef pair<ll, int> lp;
typedef pair<ll, ll> llp;
typedef vector<int> vec;
typedef vector<ll> vecll;
typedef vector<vec> mat;
typedef vector<vecll> matll;

// frequently used constants
static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

// frequently used structs
struct edge{
  int to,cost;
};

// printf for debug
#ifndef DEBUG
void debug(const char* format, ...){}
#else
void debug(const char* format, ...){
  va_list arg;
  va_start(arg, format);
  vprintf(format, arg);
  va_end(arg);
}
#endif

// dump vector
#ifdef DEBUG
#define DUMPV(v, c) do{       \
  printf("%s: ", #v);         \
  for (int i = 0; i < (c); ++i) \
  {                           \
  cout << (v)[i] << " ";      \
  }                           \
  cout << endl;               \
} while(0)
#else
#define DUMPV(v,c)
#endif

// std::fill of multi dimensions
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
  std::fill( (T*)array, (T*)(array+N), val );
}

// binary search
ll BSearch(ll _begin, ll _end, bool (*f)(ll)){
  ll mid;
  while(_end - _begin > 1LL) {
  mid = _begin + (_end - _begin) / 2LL;
  if(f(mid)) {
    debug("BSearch: f(%d) == true\n", mid);
    _end = mid;
  }
  else
  {
    debug("BSearch: f(%d) == false\n", mid);
    _begin = mid;
  }
  }
  return _end;
}


ll N,M,K,A,B,C,D,E;
int dp[NMAX] = {};

string S;
vec v;

ll ans = {};

ll solve(){
  // main algorithm
  if (N == 1 && M == 1)
  {
    return 1;
  }else if(N == 1 || M == 1){
    return (N == 1 ? M - 2 : N - 2);
  }else{
    return (N - 2) * (M - 2);
  }
}
void debug(){
  // output debug information

}
void answer(){
  // output answer
  cout << ans << endl;
}
int main(int argc, char const *argv[])
{
  // operate inputs

  // Fill(dp, -1);
  cin >> N >> M;
  ans = solve();
  #ifdef DEBUG
  debug();
  #endif
  answer();

  return 0;
}

Measured memory_bytes: 256
using System;


public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = int.Parse(line[0]);
        var b = int.Parse(line[1]);
        var c = int.Parse(line[2]);
        if (a < b && b < c) Console.WriteLine("Yes");
        else Console.WriteLine("No");
    }
}

Measured memory_bytes: 8836
#include <stdio.h>
#include <string.h>
#include <algorithm>


int main(void) {
    unsigned long input1 = 0;
    unsigned long input2 = 0;
    scanf("%ld", &input1);
    scanf("%ld", &input2);
    // printf("%d\n", inputN);
    // printf("%d\n", inputM);

    unsigned long remain = 0;
    if (input1 < input2)
        remain = 0;
    else 
        remain = input1 - input2;
    if (remain == 0) {
        printf("%ld\n", remain);
        return 0;
    }
    unsigned long inputHN[200001];
    for(int i=0; i<input1; ++i) {
        // unsigned long temp = 0;
        scanf("%ld", &inputHN[i]);

    }
    std::sort(inputHN, inputHN+input1);
    int result = 0;
    unsigned long sum = 0;
    for(int i=0; i<remain; ++i) {
        // printf("%ld, ", inputHN[i]);
        sum += inputHN[i];
    }

    printf("%ld\n", sum);
    return 0;
}

Measured memory_bytes: 1664
class Dice:
    def __init__(self, ary): # [top, front, right, left, back, bottom]
        self.__top = ary[0]
        self.__fro = ary[1]
        self.__rit = ary[2]
        self.__lft = ary[3]
        self.__bak = ary[4]
        self.__btm = ary[5]

    def turn_e(self): # 右に転がる
        self.__top, self.__lft, self.__btm, self.__rit = \
        self.__lft, self.__btm, self.__rit, self.__top

    def turn_s(self): # 手前に転がる
        self.__top, self.__fro, self.__btm, self.__bak = \
        self.__bak, self.__top, self.__fro, self.__btm

    def turn_w(self): # 左に転がる
        self.__top, self.__lft, self.__btm, self.__rit = \
        self.__rit, self.__top, self.__lft, self.__btm

    def turn_n(self): # 奥に転がる
        self.__top, self.__fro, self.__btm, self.__bak = \
        self.__fro, self.__btm, self.__bak, self.__top

    def spin_r(self): # 右回転 
        self.__rit, self.__fro, self.__lft, self.__bak = \
        self.__bak, self.__rit, self.__fro, self.__lft

    def spin_l(self): # 左回転
        self.__rit, self.__fro, self.__lft, self.__bak = \
        self.__fro, self.__lft, self.__bak, self.__rit

    def is_same_setting(self, ary): # 同じように置いているか
        if self.__top == ary[0] and self.__fro == ary[1] and self.__rit == ary[2] and \
            self.__lft == ary[3] and self.__bak == ary[4] and self.__btm == ary[5]:
            return True

    def is_same_dice(self, ary): # 回転させて同じダイスになるか
        is_same = False
        for _ in range(2):
            for _ in range(3):
                for _ in range(4):
                    if self.is_same_setting(ary):
                        is_same = True
                    self.spin_r()
                self.turn_n()
            self.spin_r()
            self.turn_s()
        return is_same

    def show_top(self): # 上面の値を表示
        return self.__top


surfaces1 = list(map(int,input().split()))
surfaces2 = list(map(int,input().split()))

dice = Dice(surfaces1)

if dice.is_same_dice(surfaces2):
    print('Yes')
else:
    print('No')


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

ans = float('inf')
for a in range(1, n):
    num = 0
    b = n - a
    if b < a:
        break
    while a:
        num += a % 10
        a = a // 10
    while b:
        num += b % 10
        b = b // 10
    ans = min(ans, num)

print(ans)




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

int main(){
  int n, a, b, c;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a >> b >> c;
    if(a > c) swap(a, c);
    if(b > c) swap(b, c);
    if(a * a + b * b == c * c)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  string s;
  cin >> s;

  int w;
  cin >> w;

  string ans = "";
  for (int i = 0; i < s.size(); i += w) {
    ans += s[i];
  }

  cout << ans << ln;

  return 0;
}

Measured memory_bytes: 256
#解説、答え参照済み
class UnionFind():
    def __init__(self, n):
        self.n=n
        self.parents=[-1]*n #各要素の親要素の番号を格納するリスト

    def find(self, x): #要素xが属するグループの根を返す
        if self.parents[x]<0:
            return x
        else:
            self.parents[x]=self.find(self.parents[x])
            return self.parents[x]

    def union(self,x,y): #要素xが属するグループと要素yが属するグループとを併合する
        x=self.find(x)
        y=self.find(y)

        if x==y:
            return

        if self.parents[x]>self.parents[y]:
            x,y=y,x

        self.parents[x]+=self.parents[y]
        self.parents[y]=x

    def size(self,x): #要素xが属するグループのサイズ（要素数）を返す
        return -self.parents[self.find(x)]

    def same(self,x,y): #要素x, yが同じグループに属するかどうかを返す
        return self.find(x)==self.find(y)

    def members(self,x): #要素xが属するグループに属する要素をリストで返す
        root=self.find(x)
        return [i for i in range(self.n) if self.find(i)==root]

    def roots(self): #すべての根の要素をリストで返す
        return [i for i, x in enumerate(self.parents) if x<0]

    def group_count(self): #グループの数を返す
        return len(self.roots())

    def all_group_members(self): #{ルート要素: [そのグループに含まれる要素のリスト], ...}の辞書を返す
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

#print(list(uf.all_group_members().values())) #グループ一覧を表示

def main():
    n,k,l=map(int,input().split())
    ufr=UnionFind(n)
    uft=UnionFind(n)
    for i in range(k):
        x,y=map(int,input().split())
        ufr.union(x-1,y-1)
    for i in range(l):
        x,y=map(int,input().split())
        uft.union(x-1,y-1)
    
    pairs = [(ufr.find(i), uft.find(i)) for i in range(n)]
    from collections import Counter
    pairs_counter = Counter(pairs)
    ans = [pairs_counter[pair] for pair in pairs]
    print(*ans)

if __name__=="__main__" :
    main()


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


int pref[4005][4];
int suf[4005][4];


int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	cin >> n;
	string s;
	
	cin >> s;
	s = '*' + s;

	for (int i = 1; i <= n; ++i){
		pref[i][1] = pref[i-1][1];
		pref[i][2] = pref[i-1][2];
		pref[i][3] = pref[i-1][3];
		if (s[i] == 'R')
			pref[i][1]++;
		if (s[i] == 'G')
			pref[i][2]++;
		if (s[i] == 'B')
			pref[i][3]++;
	}
	for (int i = n; i >= 1; --i){
		suf[i][1] = suf[i+1][1];
		suf[i][2] = suf[i+1][2];
		suf[i][3] = suf[i+1][3];
		if (s[i] == 'R')
			suf[i][1]++;
		if (s[i] == 'G')
			suf[i][2]++;
		if (s[i] == 'B')
			suf[i][3]++;
	}  
	long long odp = 0;
	for (int i = 1; i <= n; ++i){

		if (s[i] == 'R')
			odp += pref[i][2]*suf[i][3] + pref[i][3]*suf[i][2];

		if (s[i] == 'G')
			odp += pref[i][1]*suf[i][3] + pref[i][3]*suf[i][1];

		if (s[i] == 'B')
			odp += pref[i][1]*suf[i][2] + pref[i][2]*suf[i][1];

		int x = i-1, y = i+1;

		while (x >= 1 && y <= n){
			if (s[i] != s[x] && s[i] != s[y] && s[x] != s[y])
				odp--;
			x--;
			y++;
		}
	}
	cout << odp << "\n";
}

Measured memory_bytes: 3772
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	int dp[n];
	for(int i=0;i<n;i++)
	{
		dp[i]=1e9;
	}
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	for(int i=2;i<n;i++)
	{
		int j=max(0,i-k);
		while(j<i)
		{
			//cout<<j<<endl;
			dp[i]=min(abs(a[j]-a[i])+dp[j],dp[i]);
			j++;
		}
		
	
	}
	cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

namespace A_ABC157
{
    class MainClass
    {

        static int[] s;

        public static void Main(string[] args)
        {
            s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            WriteLine((s[0]+1)/2);
        }
    }
}


Measured memory_bytes: 11220
using System;
using System.Linq;

class ABC070A
{
	static public void Main(string[] args)
	{
		string s = Console.ReadLine();
		string t = string.Join("", s.Reverse());

		if(s == t)
		{
			Console.WriteLine("Yes");
		}
		else
		{
			Console.WriteLine("No");
		}
	}
}


Measured memory_bytes: 13268
n = int(input())
str_list = [chr(ord('a') + i) for i in range(26)]


def dfs(str_cace):
    if len(str_cace) == n:
        print(str_cace)
        return
    else:
        max_index = 0
        for i in range(len(str_cace)):
            max_index = max(max_index, str_list.index(str_cace[i]))
        max_index += 1

        for cad_str in str_list:
            if str_list.index(cad_str) <= max_index:
                dfs(str_cace+cad_str)


dfs("a")

Measured memory_bytes: 4340
while True:
	n = int(input())
	if n == 0:
		break
	workers = {}
	workernames = []
	greatworkers = 0
	for i in range(n):
		person, price, number = map(int, input().split())
		if person in workers:
			workers[person] += price * number
		else:
			workers[person] = price * number
			workernames.append(person)
	for worker in workernames:
		if workers[worker] >= 1000000:
			print(worker)
			greatworkers += 1	
	if greatworkers == 0:
		print('NA')

Measured memory_bytes: 7760
#include<bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
const int M = 1000000007;

int main() {
    while (1) {
        int n, m, l, k, a, h;
        cin >> n >> m >> l >> k >> a >> h;
        if (!n) return 0;
        vector<int> fr(l + 2);
        for (int i = 0; i < l; ++i) {
            cin >> fr[i];
        }
        fr[l] = a;
        fr[l + 1] = h;

        vector<vector<int>> d(n, vector<int>(n, M));
        for (int i = 0; i < k; ++i) {
            int x, y, t;
            cin >> x >> y >> t;
            d[x][y] = t;
            d[y][x] = t;
        }
        for (int i = 0; i < n; ++i)
            for (int j = 0; j < n; ++j)
                for (int k = 0; k < n; ++k)
                    d[j][k] = min(d[j][k], d[j][i] + d[i][k]);

        vector<vector<int>> dist(n, vector<int>(n, M));
        for (int i : fr)
            for (int j : fr)
                if (d[i][j] <= m)
                    dist[i][j] = d[i][j];

        for (int i = 0; i < n; ++i)
            for (int j = 0; j < n; ++j)
                for (int k = 0; k < n; ++k)
                    dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);

        if (dist[a][h] >= M) cout << "Help!\n";
        else cout << dist[a][h] + max(dist[a][h] - m, 0) << "\n";
    }
}



Measured memory_bytes: 3224
import sys
def check(x, y):
    for i in range(6):
        order = [0, 0, 0]
        for j in range(3):
            k = a[i][j]
            if {x[j], x[-j-1]} != {y[k], y[-k-1]}:
                break
            if x[j] == y[k]:
                order[j] = 1
                if x[j] == x[-j-1]:
                    order[j] = 2
        else:
            if 2 in order or (i < 3) == sum(order) % 2:
                return True
    return False

a = [[0, 1, 2], [2, 0, 1], [1, 2, 0], [0, 2, 1], [2, 1, 0], [1, 0, 2]]
n = int(sys.stdin.readline())
x = [sys.stdin.readline().split() for i in range(n)]
for i in range(n):
    for j in range(i+1, n):
        if check(x[i], x[j]):
            break
    else:
        continue
    print('No')
    break
else:
    print('Yes')

Measured memory_bytes: 7804
# include <iostream>
# include <string>
using namespace std;
int main()
{
	string s,t;
	cin>>s>>t;
	long long int c=0;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]!=t[i])
		{
			c++;
		}
	}
	cout<<c<<endl;
	return 0;
}


Measured memory_bytes: 3920
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;
#define MOD 1000000007LL

int main(){
  ll N, K;
  cin >> N >> K;
  vector<Pll> td(N);
  for(int i = 0; i < N; i++){
    cin >> td.at(i).first >> td.at(i).second;
  }
  sort(ALL(td));
  set<int> se;
  for(int i = 0; i < N; i++){
    if(!se.count(td.at(i).first)){
      se.insert(td.at(i).first);
      td.at(i).first = se.size()-1;
    }
    else td.at(i).first = se.size()-1;
  }
  ll type = se.size();
  priority_queue<Pll> unused;
  priority_queue<Pll, vector<Pll>, greater<Pll>> used;
  for(int i = 0; i < N; i++){
    unused.push(Pll(td.at(i).second, td.at(i).first));
  }
  vll counter(type, 0);
  ll typenum = 0;
  ll sum = 0;
  ll ans = 0;
  for(int i = 0; i < K; i++){
    Pll n = unused.top(); unused.pop();
    used.push(n);
    if(counter.at(n.second) == 0) typenum++;
    counter.at(n.second)++;
    sum += n.first;
  }
  ans = sum + typenum * typenum;
  while(!used.empty()){
    ll t = used.top().second;
    ll x = used.top().first;
    used.pop();
    if(counter.at(t) == 1) continue;
    counter.at(t)--;
    sum -= x;
    while(!unused.empty()){
      ll tt = unused.top().second;
      ll xx = unused.top().first;
      unused.pop();
      if(counter.at(tt) > 0) continue;
      used.push(Pll(xx, tt));
      counter.at(tt)++;
      typenum++;
      sum += xx;
      break;
    }
    chmax(ans, sum + typenum * typenum);
  }

  cout << ans << endl;
}

Measured memory_bytes: 10736
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let (n, m) = get!(usize, usize);
    let mut v = Vec::with_capacity(m);
    for _ in 0..m {
        let mut tmp = get!(usize, usize);
        tmp.0 -= 1;
        tmp.1 -= 1;
        v.push(tmp);
    }
    let mut boxes = vec![1; n];
    let mut red = vec![false; n];
    red[0] = true;
    for i in 0..m {
        boxes[v[i].0] -= 1;
        boxes[v[i].1] += 1;
        if red[v[i].0] == true {
            red[v[i].1] = true;
        }
        if boxes[v[i].0] == 0 {
            red[v[i].0] = false;
        }
        //eprintln!(
        //    "boxes[v[i].0]: {} boxes[v[i].1]: {}",
        //    boxes[v[i].0], boxes[v[i].1]
        //);
        //eprintln!("{:?}", red);
    }
    let mut ans = 0;
    for i in 0..n {
        if red[i] {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = 3;
		for (int i = 0; i < 3; i++) {
			sb.append(sc.next().toCharArray()[0]);
		}
		System.out.println(sb);
		sc.close();
	}
}


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

#define pb push_back
#define mp make_pair
#define taskname "A"

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef tree <int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

const int maxn = 2e5 + 5;

ll basis[60];
ll all = 0;

int n;
void add(ll x){
    for(int i = 59 ; i >= 0 ; --i){
        if((all >> i) & 1)continue;
        if((x >> i) & 1){
            if(basis[i])x ^= basis[i];
            else {
                basis[i] = x;
                return;
            }
        }
    }
}
ll a[maxn];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP","r")){
		freopen(taskname".INP", "r",stdin);
		freopen(taskname".OUT", "w",stdout);
    }
    cin >> n;
    for(int i = 1 ; i <= n ; ++i){
        ll x;cin >> x;
        a[i] = x;
        all ^= x;
    }
    for(int i = 1 ; i <= n ; ++i){
        add(a[i]);
    }
    ll res = 0;
    for(int i = 59 ; i >= 0 ; --i){
        if(!((all >> i) & 1) && !((res >> i) & 1)){
            if(basis[i]){
                res ^= basis[i];
            }
        }
    }
    cout << res + (all ^ res);
}


Measured memory_bytes: 1024
a,b,ab,x,y = gets.to_s.split.map{|t|t.to_i}

ans = Float::INFINITY

0.upto([x,y].max) do |ab_n|
  
  cost = ab * ab_n * 2
  
  need_x = [0, x - ab_n].max
  need_y = [0, y - ab_n].max
  
  cost += a * need_x
  cost += b * need_y
  
  ans = cost if ans > cost
end

puts ans

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

int main() {
	ll N;
	cin >> N;
  ll ans = (1+N)*N/2 - N;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 2000

int solve(int, int);
int n,A[N];

int main(){

  int i,j=0,q,m;

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
scanf("%d",&q);
 for(i=0;i<q;i++) {
   scanf("%d",&m);
   if(solve(j,m)==1) printf("yes\n");
   else printf("no\n");
 }

 return 0;
}

int solve(int i,int m){

  int res=0;
  
  if (m == 0) return 1;
  if (i >= n) return 0;
  res = solve(i + 1, m) || solve(i + 1, m - A[i]);
  return res;
}



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

int main(){
    string s;
    cin >> s;
    int length = s.length() - 1;
    int i = 0;
    int count = 0;
    while(i < length){
        if(s.at(i) != s.at(length)){
            i++;
            length--;
            count++;
        }else{
            i++;
            length--;
        }
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;
using IEInt32 = System.Collections.Generic.IEnumerable<int>;

static class PokerHand
{
    static void Main()
    {
        Func<IEnumerable<IEInt32>, int[], string>[] comb =
        {
            (g, h) => g
                .Any( x => x.Skip( 3 ).Any() )
                ? "four card" : string.Empty,
            (g, h) => g
                .All( x => x.Skip( 1 ).Any() )
                ? "full house" : string.Empty,
            (g, h) => new[] { 10, 11, 12, 13, 1 }
                .Except( h )
                .All( _ => false )
                ? "straight" : string.Empty,
            (g, h) => E.Range( h.Min(), 5 )
                .Except( h )
                .All( _ => false )
                ? "straight" : string.Empty,
            (g, h) => g
                .Any( x => x.Skip( 2 ).Any() )
                ? "three card" : string.Empty,
            (g, h) => g
                .Where( x => x.Skip( 1 ).Any() )
                .Skip( 1 )
                .Any()
                ? "two pair" : string.Empty,
            (g, h) => g
                .Any( x => x.Skip( 1 ).Any() )
                ? "one pair" : string.Empty,
            (g, h) => "null",
        };

        var indata = Console.In.ReadToEnd()
            .Split( 
                new[] { '\r', '\n' },
                StringSplitOptions.RemoveEmptyEntries );
        var q =
            from hand in indata
            let h = Array.ConvertAll( hand.Split( ',' ), int.Parse )
            let g = h.GroupBy( x => x ).Cast<IEInt32>()
            select comb
                .Select( x => x( g, h ) )
                .First( x => x != string.Empty );
        foreach( var c in q )
            Console.WriteLine( c );
    }
}

Measured memory_bytes: 6656
#include <iostream>
#include <vector>
#include <set>
using namespace std;


int n,m,k;

int in[100005];
vector<int> bl[100005];
vector<int> g[100005];
bool use[100005];
int ans[100005];
set<int> t;

void dfs(int v) {
  use[v] = true;
  t.insert(v);
  for(int i = 0; i < g[v].size(); i++) {
    int e = g[v][i];
    if(use[e]) continue;
    dfs(e);
  }
  return;
}
  


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

  for(int i = 0; i < m; i++) {
    int a,b;
    cin >> a >> b;
    a--;b--;
    in[a]++;
    in[b]++;
    g[a].push_back(b);
    g[b].push_back(a);
  }


  for(int i = 0; i < k; i++) {
    int c,d;
    cin >> c >> d;
    c--;d--;
    bl[c].push_back(d);
    bl[d].push_back(c);
  }

  for(int i = 0; i < n; i++) {
    if(use[i]) continue;
    t.clear();
    dfs(i);
    for(auto itr = t.begin(); itr != t.end(); ++itr) {
      int T = *itr;
      int tmp = 0;
      for(int j = 0; j < bl[T].size(); j++) {
	if(t.find(bl[T][j]) != t.end()) tmp++;
      }
      ans[T] = t.size() - 1 - in[T] - tmp;
    }
  }

  for(int i = 0; i < n; i++) cout << ans[i] << endl;

  /*  for(int i = 0; i < n; i++) {
    int tmp = 0;
    for(int j = 0; j < bl[i].size(); j++) {
      if(u(bl[i][j],i)) tmp++;
    }
    cout << s[i] - in[i] - tmp << endl;
    }*/
}

    

    


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

using namespace std;

#define X first
#define Y second
#define eps  1e-5
#define gcd __gcd
#define pb push_back
#define PI acos(-1.0)
#define lowbit(x) (x)&(-x)
#define bug printf("!!!!!\n");
#define mem(x,y) memset(x,y,sizeof(x))

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef unsigned long long uLL;

const int maxn = 1e5+7;
const int INF  = 1<<30;
const int mod  = 1e9+7;

pii s[maxn];

void solve(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>s[i].X;
        s[i].Y = i;
    }
    sort(s+1,s+1+n);
    for(int i=1;i<=n;i++){
        printf("%d%c",s[i].Y," \n"[i==n] );
    }
    return;
}

int main()
{
#ifndef ONLINE_JUDGE
   // freopen("in.txt","r",stdin);
#endif
//    freopen("out.txt","w",stdout);
    ios::sync_with_stdio(false);
    int t = 1;
    //scanf("%d",&t);
    while(t--){
    //    printf("Case %d: ",cas++);
        solve();
    }
#ifndef ONLINE_JUDGE
   // printf("%.10f\n",1.0*clock()/CLOCKS_PER_SEC);
#endif
    return 0;
}

Measured memory_bytes: 1664
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int n;

void f(int x)
{
    if(x==0)
        return ;
    int a=x%(-2);
    if(a<0)
        x+=a;
    f(x/(-2));
    cout<<abs(a);
}
int main()
{
    cin>>n;
    if(n==0)
        puts("0");
    else
        f(n);
    return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    int N, D;
    cin >> N >> D;
    int cnt = 0;
    rep(i, N){
        double X, Y;
        cin >> X >> Y;
        double ans = X*X + Y*Y;
        ans = sqrt(ans);
        if(ans <= D) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

struct UnionFind
{
	vector<int> par;
	UnionFind(int n) :par(n, -1) {}
	int find(int x) { return par[x] < 0 ? x : par[x] = find(par[x]); }
	void unite(int x, int y)
	{
		x = find(x); y = find(y);
		if (x == y) return;
		if (par[y] < par[x]) swap(x, y);
		if (par[x] == par[y]) par[x]--;
		par[y] = x;
		if (find(x) != find(y)) par[find(y)] = x;
	}
	int count()
	{
		int cnt = 0;
		REP(i, par.size()) if (par[i] < 0) cnt++;
		return cnt;
	}
	bool same(int x, int y)
	{
		return find(x) == find(y);
	}
};

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int ans = 0;
	REP(i, d + 1)REP(j, d + 1)REP(k, d + 1)
	{
		if (i + j + k != d) continue;
		chmax(ans, a * (1 << i) + b * (1 << j) + c * (1 << k));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		final int N = scan.nextInt();
		scan.close();

		int count = 0;
		for (int i = 1; i <= N; i++) {
			if (String.valueOf(i).length() % 2 == 1) {
				count++;
			}
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 28372
#include <bits/stdc++.h>
#define MOD 1000000007
#define MAX 2010
using namespace std;

int arr[MAX];

int add(int a, int b)
{
	return (a + b) % MOD;
}

int prod(int a, int b)
{
	return 1LL * a * b % MOD;
}

int main(void)
{
	int N, K;
	cin >> N >> K;
	int half = (MOD + 1) / 2;
	for (int i = 0; i < N; i++) cin >> arr[i];
	int ans = 0;
	for (int i = 0; i < N; i++)
	{
		for (int j = i + 1; j < N; j++)
		{
			if (arr[i] == arr[j]) continue;
			if (arr[i] < arr[j]) ans = add(ans, prod(prod(K, K - 1), half));
			else ans = add(ans, prod(prod(K, K + 1), half));
		}
	}
	cout << ans << endl;
	return 0;
}


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

int prz(int a) {
  if (a == 3)
    return 100000;
  else if (a == 2)
    return 200000;
  else if (a == 1)
    return 300000;
  return 0;
}

int main() {
  int X, Y;
  cin >> X >> Y;

  int ans = 0;
  ans += prz(X);
  ans += prz(Y);

  if (X == 1 & Y == 1) ans += 400000;

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

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+300;
long long dp[105][N],a[105],w[105],v[105],mark[N];



int main(){
    int n,k;
    cin >> n >> k;
    for (int i=1 ; i<=n ; i++){
        cin >> w[i] >> v[i];
    }
    long long ma=0;
    mark[0]=1;
    for (int i=1 ; i<=k ; i++){
        for (int j=1 ; j<=n ; j++){
            dp[j][i]=dp[j-1][i];
            ma=max(ma,dp[j][i]);
            if (i>=w[j] && mark[i-w[j]]> 0){
                dp[j][i]=max(dp[j][i] , dp[j-1][i-w[j]]+v[j]);
                ma=max(ma,dp[j][i]);
                mark[i]=1;
            }

        }
    }
    cout << ma;




}


Measured memory_bytes: 81408
n = int(input())
max_1 = 0
max_2 = 0
a = []
id_1 = 0
for i in range(n):
  a.append(int(input()))
  if a[i] > max_1:
    id_1 = i
    max_1 = a[i]
  elif a[i] > max_2:
    max_2 = a[i]
for i in range(n):
  if id_1 == i:
    print(max_2)
  else:
    print(max_1)


Measured memory_bytes: 68696
import java.util.Scanner;

public class Main {
    static int n;
    static Circle circle[] = new Circle[24];
    static int[] state = new int[20000000];
    static int[] two = new int[25];
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        powTwo();

        while (true){
            n = sc.nextInt();
            if (n==0) break;

            for (int i = 0; i < 20000000; i++) {
                state[i] = 0;
            }
            for (int i = 0; i < n; i++) {
                circle[i] = new Circle(sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt());
                overCircle(i);
            }

            System.out.println(remove(0, 0));
        }
    }

    static void powTwo() {
        two[0] = 1;
        for (int i = 1; i < 25; i++) {
            two[i] = two[i-1]*2;
        }
    }

    static void overCircle(int i) {
        for (int j = 0; j < i; j++) {
            int l = (int)(Math.pow(circle[j].x-circle[i].x,2)+Math.pow(circle[j].y-circle[i].y,2));
            if (Math.pow(circle[j].r+circle[i].r,2)>l){
                circle[i].over[j] = 1;
                circle[i].cnt++;
            }
        }
    }

    static int remove(int cnt, int s) {
        state[s] = 1;
        int ans = cnt;

        for (int i = 0; i < n; i++) {
            if (circle[i].flag==1 || circle[i].cnt>0) continue;

            for (int j = i+1; j < n; j++) {
                if (circle[j].flag==0&&circle[j].cnt==0&&circle[i].c==circle[j].c){
                    if (state[s+two[i]+two[j]]==1) continue;
                    circle[i].flag = circle[j].flag = 1;
                    for (int k = 0; k < n; k++) {
                        if (circle[k].over[i]==1) circle[k].cnt--;
                        if (circle[k].over[j]==1) circle[k].cnt--;
                    }
                    ans = Math.max(remove(cnt+2, s+two[i]+two[j]), ans);
                    circle[i].flag = circle[j].flag = 0;
                    for (int k = 0; k < n; k++) {
                        if (circle[k].over[i]==1) circle[k].cnt++;
                        if (circle[k].over[j]==1) circle[k].cnt++;
                    }
                }
            }
        }
        return ans;
    }

    static class Circle{
        int x, y, r, c;
        int[] over = new int[24];
        int cnt = 0, flag = 0;
        Circle(int s, int t, int u, int v){
            x = s; y = t; r = u; c = v;
        }
    }
}

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

using namespace std;

using ll = long long;

constexpr char newl = '\n';
constexpr ll INF = 1e18;

ll solve(ll n, ll a, ll b, ll c, ll d, map<ll, ll>& memo) {
    if (n == 0) return 0;
    if (memo.find(n) != memo.end()) return memo[n];

    ll res = solve(n / 2, a, b, c, d, memo) + n % 2 * d + (ll)min((__int128_t)a, (__int128_t)n / 2 * d);


    ll tar = (n + 2 - n % 2) / 2;
    if (tar < n) {
        res = min(res, solve(tar, a, b, c, d, memo) + (2 - n % 2) * d + (ll)min((__int128_t)a, (__int128_t)tar * d));
    }
    
    res = min(res, solve(n / 3, a, b, c, d, memo) + n % 3 * d + (ll)min((__int128_t)b, (__int128_t)n / 3 * 2 * d));

    tar = (n + 3 - n % 3) / 3;
    if (tar < n) {
        res = min(res, solve(tar, a, b, c, d, memo) + (3 - n % 3) * d + (ll)min((__int128_t)b, (__int128_t)tar * 2 * d));
    }

    res = min(res, solve(n / 5, a, b, c, d, memo) + n % 5 * d + (ll)min((__int128_t)c, (__int128_t)n / 5 * 4 * d));

    tar = (n + 5 - n % 5) / 5;
    if (tar < n) {
        res = min(res, solve(tar, a, b, c, d, memo) + (5 - n % 5) * d + (ll)min((__int128_t)c, (__int128_t)tar * 4 * d));
    }

    __int128_t tmp = n;
    tmp *= d;
    if (tmp < INF) {
        res = min(res, n * d);
    }
    return memo[n] = res;
}

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

    int t;
    cin >> t;

    for (int i = 0; i < t; i++) {
        ll n, a, b, c, d;
        cin >> n >> a >> b >> c >> d;

        map<ll, ll> memo;
        ll ans = solve(n, a, b, c, d, memo);
        cout << ans << newl;
    }

    return 0;
}

Measured memory_bytes: 4796
#include<iostream>
#include<cmath>
#include<cctype>
#include<algorithm>
#include<cstring>
using namespace std;
int main(){
	int a[3];
	for(int i=0;i<3;i++){
		cin>>a[i];
	}
	sort(a,a+3);
	int sum=a[0]+a[1];
	cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
typedef vector<int> vi;
typedef long long lint;
typedef unsigned int uint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef unsigned long long ulint;
#define endl '\n'
#define fst first
#define sed second
#define pb push_back
#define mp make_pair
#define rint register int
#define SZ(x) (int((x).size()))
#define all(x) (x).begin(), (x).end()
#define reveal(x) cerr << #x << " = " << (x) << endl
#define rep(it, f, e) for (rint it = (f); it <= (e); ++it)
#define per(it, f, e) for (rint it = (f); it >= (e); --it)
#define repe(it, x) for (auto it = (x).begin(); it != (x).end(); ++it)
const int MAXN = 2e5 + 20;
const int INF = 0x3f3f3f3f;
int dp[30];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	int n, T;
	cin >> n >> T;
	vector<pll> vec; 
	vector<int> a_0;
	rep (i, 1, n) {
		int a, b;
		cin >> a >> b;
		if (a == 0) {
			a_0.emplace_back(b + 1);
		} else {
			vec.emplace_back(a, b);
		}
	}
	sort(all(a_0));
	rep (i, 1, SZ(a_0) - 1) {
		a_0[i] += a_0[i - 1];
		if (a_0[i] >= INF) a_0[i] = INF;
	}
	sort(all(vec), [&] (pll a, pll b) {
		return b.fst * (a.sed + 1) < a.fst * (b.sed + 1);
	});
	memset(dp, 0x3f, sizeof(dp));
	dp[0] = 0;
	rep (i, 1, SZ(vec)) {
		lint a = vec[i - 1].fst;
		lint b = vec[i - 1].sed;
		per (j, 28, 0) if (dp[j] != INF) {
			lint nt = dp[j] + 1 + (dp[j] + 1) * a + b;
			if (nt <= T) dp[j + 1] = min(dp[j + 1], (int) nt);
		}
	}
	int res = 0;
	vector<int> hhh;
	rep (i, 0, 28) if (dp[i] != INF) {
		res = max(res, i + (int) (upper_bound(all(a_0), T - dp[i]) - a_0.begin()));
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 6512
import sys

def solve():
    input = sys.stdin.readline
    L, R = map(int, input().split())
    if R - L >= 2019: print(0)
    else:
        minMod = 2019
        for i in range(L, R):
            for j in range(i + 1, R + 1):
                minMod = min((i * j) % 2019, minMod)
        print(minMod)

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3060
#include <iostream>
#include <boost/date_time/gregorian/gregorian.hpp>

using namespace boost::gregorian;
using namespace std;

int main() {
	while (true) {
		int y1, m1, d1, y2, m2, d2;
		cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2;
		if (y1 == -1 && m1 == -1 && d1 == -1 && y2 == -1 && m2 == -1 && d2 == -1)break;
		date da1(y1, m1, d1), da2(y2, m2, d2);
		cout << da2 - da1 << endl;
	}
}


Measured memory_bytes: 3280
class _Node {
  constructor(key, parent = null, left = null, right = null) {
    this.key = key;
    this.parent = parent;
    this.left = left;
    this.right = right;
  }
}

class BinaryTree {
  constructor() {
    this.root = null;
  }

  static get Node() { return _Node; }

  insert(key) {
    this.root = new BinaryTree.Node(key, null, null, null);
    this.insert = (key) => {
      let x = this.root, y;
      let newNode = new BinaryTree.Node(key, null, null, null);
      while (x !== null) {
        y = x;
        x = x[key < x.key ? 'left' : 'right'];
      }
      newNode.parent = y;
      y[key < y.key ? 'left' : 'right'] = newNode;
    }
  }

  printByIneorder() {
    let str = '';
    const innerFunc = (n) => {
      if (n === null) return;
      innerFunc(n.left);
      str += ` ${n.key}`;
      innerFunc(n.right);
    }
    innerFunc(this.root);
    console.log(str);
  }

  printByPreorder() {
    let str = '';
    const innerFunc = (n) => {
      if (n === null) return;
      str += ` ${n.key}`;
      innerFunc(n.left);
      innerFunc(n.right);
    }
    innerFunc(this.root);
    console.log(str);
  }

  print() {
    this.printByIneorder();
    this.printByPreorder();
  }
}

(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());

  const tree = new BinaryTree();
  lines.map((line) => line.split(' ')).forEach(function(cmd) {
    switch(cmd[0].charAt(0)) {
    case 'i': tree.insert(Number(cmd[1])); break;
    default: tree.print();
    }
  });
})();



Measured memory_bytes: 270724
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n,y,s;
    cin >> n >> y;
    for(int f=0;f<=n;f++)
        for(int h=0;h<=n;h++){
            s = (y-f*10000-h*5000)/1000;
            if(s>=0&&n==s+f+h){
                cout << f << " " << h << " " << s << endl;
                goto OUT;
            }
        }
    cout << "-1 -1 -1" << endl;
    OUT:;
}

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


int main(){
	int A, B;
	cin >> A >> B;
	int res = 0;
	for (int i = A;i <= B;i++) {
		string s;
		int n = i;
		for (int j = 0;j < 5;j++) {
			s += to_string(n % 10);
			n /= 10;
		}
		string temp = s;
		reverse(temp.begin(), temp.end());
		if (s == temp) res++;
	}
	cout << res << endl;
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  bool ans = false;
  for (int i=1; i <= 9; i++) {
    if (N%i == 0 && N/i <= 9)  ans = true;
  }
  cout << ((ans) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int n;
std::vector<int> node[10001];

int result[10001];
int itr = 0;

struct State {
  int pos;
  int prev;
  State(int a, int b) {
    pos  = a;
    prev = b;
  }
};

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

  cin >> n;

  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    node[a].push_back(b);
    node[b].push_back(a);
  }

  std::vector<int> num(n);

  for (int i = 0; i < n; i++) {
    cin >> num[i];
  }

  std::sort(num.begin(), num.end(), std::greater<int>());

  int sum = 0;
  for (int i = 1; i < n; i++) {
    sum += num[i];
  }

  std::queue<State> bfs;
  bfs.push(State(1, 0));
  while (!bfs.empty()) {
    State curr = bfs.front();
    bfs.pop();
    result[curr.pos] = num[itr];
    itr++;
    for (auto next : node[curr.pos]) {
      if (next == curr.prev) continue;

      bfs.push(State(next, curr.pos));
    }
  }

  cout << sum << endl;
  for (int i = 1; i < n; i++) {
    cout << result[i] << " ";
  }
  cout << result[n] << endl;

  return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		int[] pos = new int[N+2];
		long ans = 0;
		for(int i = 1;i < N+1;i++) {
			pos[i] = scn.nextInt();
		}
		for(int i = 1;i < N+2;i++) {
			ans += Math.abs(pos[i]- pos[i-1]);
		}
		for(int i = 1;i < N+1;i++) {
			System.out.println(ans - Math.abs(pos[i]- pos[i-1]) - Math.abs(pos[i+1]- pos[i]) + Math.abs(pos[i+1]- pos[i-1]));
		}

	}

}


Measured memory_bytes: 61168
#include <cstdio>

using namespace std;

int main(void)
{
	int a, b, c, d, p;
	int A = 0, B = 0;
	
	scanf("%d%d%d%d%d", &a, &b, &c, &d, &p);
	
	A = a*p;
	if (c >= p){
		B = b;
	}
	else {
		B = b + d * (p - c);
	}
	
	if (A < B){
		printf("%d\n", A);
	}
	else {
		printf("%d\n", B);
	}
}

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

using namespace std;

const int MAXN = 1e5+100;
const int INF = 1e9;
int dist[MAXN];

int main(){
  int k;
  cin >> k;
  for(int i = 0; i < k; i++) dist[i] = INF;
  dist[k] = 0;  
  
  deque<int> dq;
  dq.push_front(k);
  while(!dq.empty()){
    int u = dq.front();
    dq.pop_front();
    int nxt0 = u == k ? k : (10 * u) % k;
    int nxt1 = (u + 1) % k;
    if(dist[u] < dist[nxt0]){
      dist[nxt0] = dist[u];
      dq.push_front(nxt0);
    }
    if(dist[u] + 1 < dist[nxt1]){
      dist[nxt1] = dist[u] + 1;
      dq.push_back(nxt1);
    }
  }
  cout<<dist[0]<<endl;
  return 0;
}

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

int main()
{
    //A
    /*
    int N, R, x;
    cin >> N >> R;

    if (N >= 10)
    {
        x = R;
    }
    else
        x = R + 100 * (10 - N);
    cout << x << endl;
    */
    //B
    int N, K, a = 0;
    cin >> N >> K;

    while (N >= K)
    {
        N /= K;
        a++;
    }
    cout << a + 1 << endl;
}

Measured memory_bytes: 256
// https://qiita.com/_rdtr/items/c49aa20f8d48fbea8bd2

#include <iostream>
#include <bits/stdc++.h>

using namespace std;

using namespace std;
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; }
const long long INF = 1LL<<60;

// 入力
string s, t;

// DPテーブル
int dp[3100][3100] = {0}; // 初期値も初期条件も 0



int main(void){
    cin >> s >> t;

    // DPループ
    for (int i = 0; i < s.size(); ++i) {
        for (int j = 0; j < t.size(); ++j) {
            if (s[i] == t[j]) chmax(dp[i+1][j+1], dp[i][j] + 1);
            chmax(dp[i+1][j+1], dp[i+1][j]);
            chmax(dp[i+1][j+1], dp[i][j+1]);
        }
    }
    
    
    // 解の復元
    
    // ジャンプしてきた地点においては, S1[i] == S2[j] が満たされているはず
    // この点を見つけるまで, セルの上か右に移動
    // 見つけたら文字を保存して斜め左上に飛んでLCSの長さも１減る
    // この手順をテーブルの左か上端に到達するまで続ければ良い
    
    string res = "";
    
    int i = (int)s.size(), j = (int)t.size();
    
    while (i > 0 && j > 0){
        
        
        // (i-1, j) -> (i, j)と更新されている場合
        if (dp[i][j] == dp[i-1][j]) i--;
        else if (dp[i][j] == dp[i][j-1]) j--;
        else{
            
            res = s[i-1] + res;
            i--, j--;
        }
    }
    
    cout << res << endl;
    
}


Measured memory_bytes: 37120
/*
      author : Nishikawa
      created: 04.08.2020 00:01:21
*/

#include <bits/stdc++.h>

using namespace std;

int main(){
    int N;
    cin >> N;
    int max_cont=0;

    while(N--){
        int A;
        cin >> A;
        int cont=0;
        while(A==1){
            cont++;
            if(!N) break;
            cin >> A;
            N--;
        }
        max_cont=max(max_cont,cont);
    }
    cout << max_cont+1 << endl;
    
    return 0;
}


Measured memory_bytes: 3108
#include <stdio.h>
int main (int argc, char * argv[])
{
    int n,b,f,v,a;
    int count[4][3][10]={0};
    int c[4][3][10]={0};
    scanf("%d",&n);
    for(int l=0;l<n;l++){
        scanf("%d %d %d %d",&b,&f,&v,&a);
        c[b-1][f-1][v-1]+=a;
        if(c[b-1][f-1][v-1]<0){
            c[b-1][f-1][v-1]=0;
        }
    }
    
    for(int j=0;j<4;j++){
        for(int i=0;i<3;i++){
            for(int k=0;k<10;k++){
                    if(c[j][i][k]==0){
                        printf(" 0");
                    }else {
                        printf(" %d",c[j][i][k]);
                    }
                }
            printf("\n");
            }
        if(j!=3){
            printf("####################\n");
        }
    }
    
    return 0;
}



Measured memory_bytes: 2040