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

typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PDD;

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define dbl(k, x) fixed << setprecision(k) << (x)

template <typename _T>
inline void _DBG(const char *s, _T x) {
  cerr << s << " = " << x << "\n";
}
template <typename _T, typename... args>
void _DBG(const char *s, _T x, args... a) {
  while (*s != ',') cerr << *s++;
  cerr << " = " << x << ',';
  _DBG(s + 1, a...);
}

#define _upgrade                \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)

// ********************** CODE ********************** //

LL costs[50];
LL values[50][50];

LL best_res = 1e18;
LL cur_res;
LL skill[50];
int n, m;
LL x;

void go(int i) {
  if (i == n) {
    bool ok = true;

    for (int j = 0; j < m; j++) {
      if (skill[j] < x) {
        ok = false;
      }
    }

    if (ok) {
      best_res = min(best_res, cur_res);
    }
    return;
  }

  go(i + 1);
  cur_res += costs[i];
  for (int j = 0; j < m; j++) {
    skill[j] += values[i][j];
  }
  go(i + 1);
  cur_res -= costs[i];
  for (int j = 0; j < m; j++) {
    skill[j] -= values[i][j];
  }
}

int main() {
  _upgrade;
  cin >> n >> m >> x;

  for (int i = 0; i < n; i++) {
    cin >> costs[i];
    for (int j = 0; j < m; j++) {
      cin >> values[i][j];
    }
  }

  go(0);

  if (best_res == 1e18) {
    cout << -1 << "\n";
  } else {
    cout << best_res << "\n";
  }
  return 0;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define endl "\n"
#define pi 3.14159265358979323846264338327950288
#define MOD 1000000007
#define INF -100000000000000
#define ordered_set tree<pair< ll int ,ll  int>, null_type,less<pair<ll int, ll int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
using namespace std;
#define lld long double
using namespace __gnu_pbds;
int main()
{
    fast;
    int x;
    cin>>x;
    int w=x^1;
    cout<<w<<endl;
}


Measured memory_bytes: 3608
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int A, B;
	
	cin>>A>>B;
	
	cout<<max(max(A+B,A-B),A*B)<<endl;
	
	
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <unordered_set>
#include <string>

using namespace std;

int main()
{
    int n;
    string s;

    cin >> n >> s;
    
    int m = 0, mx = 0;
    for (int i = 1; i < n; i++) {
        string x = s.substr(0, i);
        string y = s.substr(i, s.size()-x.size());

        unordered_set<char> s1, s2;
        for (unsigned int i = 0; i < x.size(); i++)
            s1.insert(x[i]);

        for (unsigned int j = 0; j < y.size(); j++)
            s2.insert(y[j]);

        if(s1.size() < s2.size()) {
            for (char c : s1) 
                if (s2.find(c) != s2.end())
                    m++;
        } else {
            for (char c : s2) 
                if (s1.find(c) != s1.end())
                    m++;
        }

        if (m > mx)
            mx = m;

        m = 0;
    }

    cout << mx << endl;

    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++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

ll p(ll N){
    if (N == 0){
        return 1;
    }
    ll pN = p(N - 1) * 2 + 1;
    return pN;
}

ll b(ll N){
    if (N == 0){
        return 1;
    }
    ll pN = b(N - 1) * 2 + 3;
    return pN;
}

ll levelN(ll N, ll K){
    if (N == 0){
        return 1;
    }
    
    if (N != 0 && K == 1){
        return 0;
    }
    
    if (K <= b(N - 1)){
        return levelN(N - 1, K - 1);
    }
    
    if (K == b(N - 1) + 1){
        return p(N - 1);
    }
    
    if (K == b(N - 1) + 2){
        return 1 + p(N - 1);
    }
    
    if (K <= 2 * b(N - 1) + 1){
        return 1 + p(N - 1) + levelN(N - 1, K - 2 - b(N - 1));
    }
    
    if (K == 2 * b(N - 1) + 2){
        return 1 + 2 * p(N - 1);
    }
    
    return 1 + 2 * p(N - 1);
}

int main(){
    ll N,X;
    cin >> N >> X;
    cout << levelN(N,X) << endl;
}

Measured memory_bytes: 3644
# -*- coding: utf-8 -*-
s = input()
slist = list(s)
n = len(slist)
ans = 'Yes'

for i in range(int((n-1)/2)):
  if slist[i] != slist[n-1-i] or slist[i] != slist[int((n-1)/2-1-i)] or slist[int((n+3)/2-1+i)] != slist[n-1-i]:
    ans = 'No'
print(ans)

Measured memory_bytes: 3060
#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
#define rep2(i, N, s) for(int (i) = (s); (i) < (N) + (s); (i) ++)
#define rrep(i, N) for(int (i) = (N) - 1; (i) >= (0); (i) --)
#define rrep2(i, N, s) for(int (i) = (s); (i) >= (s) - (N) + 1; (i) --)
#define INF 1e9

#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;

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

int main(){
    int H, W;
    cin >> H >> W;
    char mas[100][100];
    rep(i, H){
        rep(j, W){
            cin >> mas[i][j];
        }
    }
    vector<int> rows;
    rep(i, H){
        bool flag = false;
        rep(j, W){
            if(mas[i][j] == '#'){
                flag = true;
                break;
            }
        }
        if(flag){
            rows.push_back(i);
        }
    }

    vector<int> clms;
    rep(i, W){
        bool flag = false;
        rep(j, H){
            if(mas[j][i] == '#'){
                flag = true;
                break;
            }
        }
        if(flag){
            clms.push_back(i);
        }
    }

    rep(i, rows.size()){
        rep(j, clms.size()){
            int row = rows[i];
            int clm = clms[j];
            cout << mas[row][clm];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import itertools
 
def func(n):
    for op in itertools.product(operators, repeat=3):
        for form in forms:
            formula = form.format(op[0], op[1], op[2], n[0], n[1], n[2], n[3])
            if eval(formula) == 10:
                print(formula)
                return True
    return False
 
operators = ("+", "-", "*")
 
forms = (
  "(({3}{0}{4}){1}{5}){2}{6}",
  "({3}{0}{4}){1}({5}{2}{6})",
  "({3}{0}({4}{1}{5})){2}{6}",
  "{3}{0}(({4}{1}{5}){2}{6})",
  "{3}{0}({4}{1}({5}{2}{6}))",
)
 
while (True):
    nums = tuple(map(int, input().split()))
    if nums == (0,0,0,0):
        break
    for n in itertools.permutations(nums):
        if func(n):
            break
    else:
        print(0)


Measured memory_bytes: 5644
n = int(input())
D = list(map(int, input().split()))


if D[0] != 0 or 0 in D[1:]:
    ans = 0
else:
    num = [0 for i in range(max(D)+1)]
    ans = 1
    cnt = 1
    for i in range(n):
        num[D[i]] += 1
    for i in range(len(num)):
        ans = ans * (cnt ** num[i]) % 998244353
        cnt = num[i]

print(ans)


Measured memory_bytes: 13892
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();

        Queue<Integer[]> a_num = new ArrayDeque<Integer[]>();
        Queue<Integer[]> b_num = new ArrayDeque<Integer[]>();

        int a_counter = 0;
        int b_counter = 0;
        long answer = 1;

        for(int i=2; i<3200; i++) {
            a_counter=0;
            b_counter=0;

            while(A%i==0) {
                A/=i;
                a_counter++;
            }
            if(a_counter!=0) {
                Integer[] nums = {i,a_counter};
                a_num.add(nums);
            }
            while(B%i==0) {
                B/=i;
                b_counter++;
            }
            if(b_counter!=0) {
                Integer[] nums = {i,b_counter};
                b_num.add(nums);
            }
        }
        if(a_num.isEmpty()) {
            Integer[] nums = {A,1};
            a_num.add(nums);
        }else if(A!=1) {
           Integer[] nums = {A,1};
           a_num.add(nums);
        }
        if(b_num.isEmpty()) {
            Integer[] nums = {B,1};
            b_num.add(nums);
        }else if(B!=1) {
           Integer[] nums = {B,1};
           b_num.add(nums);
        }

        Integer[] a_max= {100001,1};
        a_num.add(a_max);
        Integer[] b_max= {100001,1};
        b_num.add(b_max);
        Integer[] a_tmp=a_num.poll();
        Integer[] b_tmp=b_num.poll();


        while(a_tmp[0]!=100001 || b_tmp[0]!=100001) {
            if(a_tmp[0]<b_tmp[0]) {
                for(int i=0;i<a_tmp[1]; i++) {
                    answer*=a_tmp[0];
                }
                a_tmp=a_num.poll();
            }else if(a_tmp[0]>b_tmp[0]) {
                for(int i=0;i<b_tmp[1]; i++) {
                    answer*=b_tmp[0];
                }
                b_tmp=b_num.poll();
            }else {
                if(a_tmp[1]>=b_tmp[1]) {
                    for(int i=0;i<a_tmp[1]; i++) {
                        answer*=a_tmp[0];
                    }
                }else {
                    for(int i=0;i<b_tmp[1]; i++) {
                        answer*=b_tmp[0];
                    }
                }
                a_tmp=a_num.poll();
                b_tmp=b_num.poll();
            }
        }

        System.out.println(answer);


    }

}


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

int main()
{
    string s;
    cin >> s;
    string ans = "No";
    if((s[2]==s[3])&&(s[4]==s[5])) ans = "Yes";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import fractions

def calcA(a, b):
    ans = a / b
    if ans.is_integer():
        return a // b
    else:
        return a // b + 1 


a, b, c, d = map(int, input().split())

a1 = calcA(a,c)

a2 = b // c
a3 = a2 - a1 + 1

b1 = calcA(a,d)

b2 = b // d
b3 = b2 - b1 + 1

x = c * d // fractions.gcd(c, d)

x1 = calcA(a,x)
x2 = b // x
x3 = x2 - x1 + 1

p = b - a + 1
q = a3 + b3 - x3

print(p - q)

Measured memory_bytes: 63980
#include <bits/stdc++.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INF = 1e18;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
int main(){
  int n;
  cin>>n;
  vi l(n);
  rep(i,n){
    cin>>l[i];
  }
  sort(l.begin(),l.end());
  ll ans =0;
  rep(i,n){
    for(int j=i+1;j<n;j++){
      auto itr_max=lower_bound(l.begin(),l.end(),l[i]+l[j]);
      int sum = itr_max-(l.begin()+j+1);
      ans+=max(0,sum);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const int INF = 2000000000;
    ll ans=0,id;
    //int N,M;
    ll A,B,C,D;
    ll sum=0;
    string S;

int main(){
    ios_base::sync_with_stdio(false);
    cin>>A>>B>>C>>D;
     std::min(B,D)-std::max(A,C)>0?cout<<std::min(B,D)-std::max(A,C):cout<<"0";

    return 0;
}


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

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

int len[10];
int n, A, B, C;

int dfs(int ind, int a, int b, int c){
	if(ind == n){
		if(a && b && c)return abs(a - A) + abs(b - B) + abs(c - C);
		return 1e9;
	}
	int ans = dfs(ind + 1, a, b, c);
	ans = min(ans, dfs(ind + 1, a + len[ind], b, c) + 10);
	ans = min(ans, dfs(ind + 1, a, b + len[ind], c) + 10);
	ans = min(ans, dfs(ind + 1, a, b, c + len[ind]) + 10);
	return ans;
}

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

	cin>>n>>A>>B>>C;
	for(int i = 0; i < n; i++){
		cin>>len[i];
	}
	cout<<dfs(0, 0, 0, 0) - 30<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

typedef long long ll;

const int INF = 2e9 + 5;
const int alength=100100;

int main() {
	int h,w,a,b;
	cin>>h>>w>>a>>b;
	cout<<h*w-a*w-b*h+a*b;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    struct Point
    {
        public int X;
        public int Y;
        public Point(int x, int y)
        {
            X = x;
            Y = y;
        }
    }

    enum Direction
    {
        None,
        North,
        East,
        South,
        West
    }

    class Abc170F
    {
        public static void Main()
        {
            var hwk = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

            var height = hwk[0];
            var width = hwk[1];
            var k = hwk[2];

            var xy = Console.ReadLine().Split(' ').Select(i => int.Parse(i) - 1).ToArray();

            var y0 = xy[0];
            var x0 = xy[1];
            var y1 = xy[2];
            var x1 = xy[3];
            var map = new long[height][];
            for (int i = 0; i < height; i++)
                map[i] = Console.ReadLine().Select(c => c == '@' ? long.MinValue : long.MaxValue).ToArray();
            var points = new HashSet<Point>(new[] { new Point(x0, y0) });
            map[y0][x0] = 0;

            while (points.Any())
            {
                var nextPoints = new HashSet<Point>();
                foreach (var p in points)
                {
                    var cost = map[p.Y][p.X] + 1;
                    void MoveTo(Direction direction)
                    {
                        int dx = 0, dy = 0;
                        switch (direction)
                        {
                            case Direction.North:
                                dy--;
                                break;
                            case Direction.South:
                                dy++;
                                break;
                            case Direction.East:
                                dx++;
                                break;
                            case Direction.West:
                                dx--;
                                break;
                        }

                        var next = p;
                        for (int i = 0; i < k; i++)
                        {
                            next.X += dx;
                            next.Y += dy;
                            if (next.X < 0 || width <= next.X ||
                                next.Y < 0 || height <= next.Y || map[next.Y][next.X] < cost)
                                return;
                            map[next.Y][next.X] = cost;
                            nextPoints.Add(next);
                        }
                    }
                    MoveTo(Direction.North);
                    MoveTo(Direction.South);
                    MoveTo(Direction.East);
                    MoveTo(Direction.West);
                }
                points = nextPoints;
            }

            Console.WriteLine(map[y1][x1] != long.MaxValue ? map[y1][x1] : -1);
        }
    }
}


Measured memory_bytes: 58560
N = int(input())
cities = []
for n in range(N):
  cities.append(tuple(map(int, input().split())))

import math
def distance(i, j):
  xi,yi = cities[i]
  xj,yj = cities[j]
  xd,yd = xi - xj, yi - yj
  return math.sqrt(xd * xd + yd * yd)

# path: これまでに通過した街の番号
def search(path):
  total = 0
  count = 0
  for i in range(N):
    if i not in path:
      count += 1
      path.append(i)
      total += (0 if len(path) == 1 else distance(i, path[-2])) + search(path)
      path.remove(i)
  if count == 0:
    return 0
  else:
    return total / count

print(search([]))

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

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner (System.in);
		int t = sc.nextInt();
		int n = sc.nextInt();
		sc.close();

		System.out.println(t-2*n>0 ? t-2*n : "0");
	}
}


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

struct Chainber{
	int color, size;
};

const int INF = 1 << 24;

int main(){
	int n;
	while(std::cin >> n, n){

		std::vector<Chainber> v;

		int prev_color = 0, size = 0;
		for(int i=0;i<n;i++){
			int color;
			std::cin >> color;
			if(prev_color != color && prev_color){
				v.push_back({prev_color, size});
				size = 0;
			}
			size++;
			prev_color = color;
		}
		v.push_back({prev_color, size});

		// for(auto c : v){
		// 	std::cout << "color: " << c.color << " size: " << c.size << std::endl;
		// }
						
		int minChara = n;

		for(int i=0;i<v.size();i++){
			if(v[i].size >= 3){
				minChara = std::min(minChara, n - (v[i].size + 1));
			}
		}

		if(v.size() >= 3){
			for(int i=1;i<v.size()-1;i++){
				int destroyChara = 0,
					upperChara = i-1, lowerChara = i+1;
				//v[i]が両辺一個を変える
				if(v[i].size >= 3){
					destroyChara = v[i].size + 1;
					v[i-1].size--;
					if(!v[i-1].size){
						if(i-2 >= 0 && v[i].color == v[i-2].color){
							destroyChara += v[i-2].size;
							upperChara = i-3;
						}else{
							upperChara = i-2;
						}
					}

					for(;upperChara>=0&&lowerChara<v.size();upperChara--,lowerChara++){
						if((v[upperChara].color == v[lowerChara].color) && (v[upperChara].size + v[lowerChara].size >= 4)){
							destroyChara += v[upperChara].size + v[lowerChara].size;
						}
						else{
							break;
						}
					}

					minChara = std::min(minChara, n - destroyChara);
					v[i-1].size++;
					
					upperChara = i-1, lowerChara = i+1;
					destroyChara = v[i].size + 1;
					v[i+1].size--;
					if(!v[i+1].size){
						if(i+2 < v.size() && v[i].color == v[i+2].color){
							destroyChara += v[i+2].size;
							lowerChara = i+3;
						}else{
							lowerChara = i+2;
						}
					}
					
					for(;upperChara>=0&&lowerChara<v.size();upperChara--,lowerChara++){
						if((v[upperChara].color == v[lowerChara].color) && (v[upperChara].size + v[lowerChara].size >= 4)){
							destroyChara += v[upperChara].size + v[lowerChara].size;
						}
						else{
							break;
						}
					}

					minChara = std::min(minChara, n - destroyChara);
					v[i+1].size++;					
				}
			}
			
		}
		std::cout << minChara << std::endl;
	}
}

Measured memory_bytes: 1328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int,int>;


const long long INFLL = 1LL << 60;
const int INFI = 1000000000;


int main() {
    int N,M; cin >> N >> M;
    int T = 1900*M+(N-M)*100;
    int ans = T*pow(2,M);
    cout << ans << endl;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int n,m,ans;
char s[25][25];
bool vis[25][25];
struct node{
    int x,y,dis;
};
int direction[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
void bfs(int x,int y){
    if(s[x][y]=='#'){
    	return ;
	}
    memset(vis,0,sizeof(vis));
    queue<node>q;
    q.push((node){x,y,0});
    vis[x][y]=1;
    while(!q.empty()){
        node now=q.front();
        q.pop();
        ans=max(ans,now.dis);
        for(int i=0;i<4;++i){
            int temp_x=now.x+direction[i][0],temp_y=now.y+direction[i][1];
            if(temp_x<=0||temp_x>n||temp_y<=0||temp_y>m||s[temp_x][temp_y]=='#'||vis[temp_x][temp_y]){
            	continue;
			}
            q.push((node){temp_x,temp_y,now.dis+1});
            vis[temp_x][temp_y]=1;
        }
    }
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>m;
    for(int i=1;i<=n;++i){
    	cin>>s[i]+1;
	} 
    for(int i=1;i<=n;++i){
    	for(int j=1;j<=m;++j){
    		bfs(i,j);
		}
	}
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
n, d = map(int, input().split())
x = [list(map(int,input().split())) for _ in range(n)]
count = 0

for i in range(n):
  for j in range(i+1, n):
    dist = 0
    for k in range(d):
      dist += (x[i][k] - x[j][k]) ** 2
    if dist ** 0.5 % 1 == 0:
      count += 1
print(count)
      


Measured memory_bytes: 3060
import java.util.*;
import java.util.Arrays;
import java.util.Comparator;
public class Main {    
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();        
		int m = sc.nextInt();
        int [] A = new int [n];
        for(int i=0;i<n;i++){A[i] = sc.nextInt();}
        Arrays.sort(A);               
        Data [] d = new Data [m];
        for(int i=0;i<m;i++){int B = sc.nextInt();
                             int C = sc.nextInt();
                             d[i] = new Data(B,C);                            
                            }
        Arrays.sort(d, new Comparator<Data>() {
            public int compare(Data d1, Data d2) {
                return d1.getB() - d2.getB();
            }
        }); 
        int point = m-1;
        int count = 0;
        for(int i=0;i<n;i++){if(point>=0 && d[point].getB()>A[i])
                            {A[i]=d[point].getB();
                             count++;                                                 
                             if(count==d[point].getA())
                            {point--;count=0;}
                            }else{break;}
                            }
        long ans = 0;
		for(int i=0;i<n;i++){ans+=A[i];}
        System.out.println(ans);
	}
}
class Data{
    private int a;
    private int b;
    public Data(int a, int b) {
        this.a = a;
        this.b = b;
    }
    public int getA() {
        return a;
    }
    public int getB() {
        return b;
    }
}


Measured memory_bytes: 91208
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define PI acos(-1.0)
typedef long long ll;
const int INF=0x3f3f3f3f;
int d[8][2]={{-1,0},{0,-1},{0,1},{1,0},{1,1},{-1,-1},{-1,1},{1,-1}};
int main()
{
    char a,b,c;
    scanf("%c%c%c",&a,&c,&b);
    if(a>b)cout<<">"<<endl;
    if(a<b)cout<<"<"<<endl;
    if(a==b)cout<<"="<<endl;
    return 0;
}


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

long long int solve(deque<long long int> d,int k, int l,int r){
	long long int sum=0;
	priority_queue<long long int,vector<long long int>,greater<long long int>> pq;
	for (int i = 0; i < l; i++) {
		sum+=d.front();
		pq.push(d.front());
		d.pop_front();
	}
	for (int i = 0; i < r; i++) {
		sum+=d.back();
		pq.push(d.back());
		d.pop_back();
	}
	k-=l+r;
	while (pq.size()>0&&k>0&&pq.top()<0) {
		sum-=pq.top();
		pq.pop();
		k--;
	}
	return sum;
}

int main(){
	int n,k;
	cin>>n>>k;
	deque<long long int> d;
	int temp;
	for (int i = 0; i < n; i++) {
		cin>>temp;
		d.push_back(temp);
	}
	long long int ans=0;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j < n; j++) {
			if(i+j<=min(n,k)){
				ans=max(ans,solve(d,k,i,j));
			}	
		}
	}
	cout<<ans<<endl;
}


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

int main() {
	int s, c;
	
	cin >> s;
	
	c = c + s % 10;
	s = s / 10;
	c = c + s % 10;
	s = s / 10;
	c = c + s % 10;
	s = s / 10;
	
	cout << c << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}

int main(){
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  int sum;
  sort(a,a+3);
  sum = a[2] * 10 + a[1] + a[0];
  
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cstdio>

using namespace std;
int n,sz[5][105], f[5][105];
int main(){
  scanf ("%d",&n);
  for (int i=1;i<=2;i++)
    for(int j=1;j<=n;j++)
      scanf("%d",&sz[i][j]);
    for (int i=1;i<=2;i++)
      for(int j=1;j<=n;j++)
        f[i][j]=max(f[i-1][j],f[i][j-1])+sz[i][j];
  printf("%d",f[2][n]);
  return 0;
 }

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n;
    cin >> n;
    vec d(n);
    rep(i, n) cin >> d[i];

    sort(all(d));

    if (n % 2) {
        cout << "0" << endl;
        exit(0);
    }

    cout << d[n/2] - d[n/2-1] << endl;
    return 0;
}

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

typedef long long int lli;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<lli> vli;
typedef priority_queue <int, vector <int>, greater <int> > min_pq;

const int MOD	= 1e9 + 7;

#define fastio			ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define init(a)         memset(a,0,sizeof(a))    
#define pb              push_back  
#define all(a)          a.begin(),a.end()  
#define loop(i,n)       for(int i=0;i<n;i++)  
#define loops(i,s,n)    for(int i=s;i<n;i++)
#define rloop(i,n)      for(int i=n-1;i>=0;i--)
#define rloops(i,s,n)   for(int i=n-1;i>=s;i--)

template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template <typename T> T lcm(T a, T b){return (a*b)/gcd(a,b); }


double tick(){static clock_t oldt,newt=clock();double diff=1.0*(newt-oldt)/CLOCKS_PER_SEC;oldt=newt;return diff;}
//---------------------------------------------------------------------------------------------


int main(){
    fastio;


    int h, a;
    cin>>h>>a;

    int ans = ceil((float)(h)/(float)a);
    cout<<ans<<endl;
    // cout<<"Execution time : "<<tick()<<"\n";

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        ArrayList<String> str = new ArrayList<>();
        String target = sc.next().toLowerCase();
        while(true) {
            String tmp = sc.next();
            if(tmp.equals("END_OF_TEXT")) {
                break;
            }
            str.add(tmp.toLowerCase());
        }
        sc.close();

        System.out.println(Collections.frequency(str, target));
    }
}



Measured memory_bytes: 26192
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    int ar[5];
    ar[3]=100000;
    ar[2]=200000;
    ar[1]=300000;
    ar[4]=0;
    int sum=0;
    sum=ar[min(a,4)]+ar[min(b,4)];
    if(a+b==2)
        sum+=400000;
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000000)
import math
from fractions import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    vn = vk = vn_k = 1
    for i in range(1, n+1):
        vn = vn * i % modp
        if i == k:
            vk = vn
        if i == n-k:
            vn_k = vn
    return vn * get_inv(vk, modp) * get_inv(vn_k, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

def main():
    input()
    A = lmis()
    if len(A) == len(set(A)):
        print('YES')
    else:
        print('NO')



main()


Measured memory_bytes: 28832
#include<algorithm>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<deque>
#include<functional>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<string>
#include<vector>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
typedef long long ll;

using namespace std;

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

	int N, M, X;
	int sum, ans = 0;
	int min = 1000;
	cin >> N >> X;
	sum = X;
	for (int i = 0; i < N; i++) {
		cin >> M;
		sum -= M;
		ans++;
		if (min > M)min = M;
	}
	while (1) {
		sum -= min;
		if (sum < 0)break;
		ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define sync ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main(){
	sync
	long long k,a,b,num=1;
	cin >> k >> a >> b;
	if(a-1<=k){
		k-=(a-1);
		num=a;
		if(k>=2&&b>a+1) num+=(b-a)*(k/2)+(k%2);
		else num+=k;
	}
	else num+=k;
	cout << num << "\n";
	return 0;
}

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

int main() {

  int N;
  cin >> N;

  vector<int> H(N);
  for(int i = 0;i < N;i++) {
    cin >> H.at(i);
  }

  int num = 0,maxi = 0;
  for(int i = 0;i < N-1;i++) {
    if(H.at(i) >= H.at(i+1)) {
      num++;
    }else {
      maxi = max(maxi,num);
      num = 0;
    }
  }

  maxi = max(maxi,num);

  cout << maxi << endl;
}




Measured memory_bytes: 640
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, W;
	cin >> n >> W;
	vi w(n), v(n);
	REP(i, n)cin >> w[i] >> v[i];
	vector<vvi> dp(n + 1, vvi(n+1,vi(3*n+1,-INF)));
	REP(i,3*n+1)dp[0][0][i] = 0;
	REP(i, n) {
		REP(j, n+1) {
			REP(k, 3 * n+1) {
				int c = w[i] - w[0];
				if (c > k||j==0||j>i+1)dp[i + 1][j][k] = dp[i][j][k];
				else {
					dp[i + 1][j][k] = max(dp[i][j][k], dp[i][j - 1][k - c] + v[i]);
				}
			}
		}
	}
	int ans = 0;
	REP(i, n+1) {
		REP(j, 3 * n+1) {
			if (W >= i*w[0] + j )ans = max(ans, dp[n][i][j]);
		}
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

#define long long long
#define INF 1e18
#define MOD (long) (998244353)

long solve(auto &a, long h, long w, long k, long i, bool row)
{
    if (not row and i == w) {
        long count = 0;
        for (long i = 0; i < h; i++) {
            for (long j = 0; j < w; j++) {
                if (a[i][j] == '#') count++;
            }
        }
        return count == k;
    }
    long total = 0;
    auto b = a;
    if (row) {
        long next = (i + 1) % h;
        bool r = true;
        if (next == 0) r = false;
        total += solve(a, h, w, k, next, r);
        for (long j = 0; j < w; j++) {
            b[i][j] = '@';
        }
        total += solve(b, h, w, k, next, r);
    } else {
        long next = i + 1;
        total += solve(a, h, w, k, next, false);
        for (long j = 0; j < h; j++) {
            b[j][i] = '@';
        }
        total += solve(b, h, w, k, next, false);
    }
    return total;
}

int main()
{
    long h, w, k;
    cin >> h >> w >> k;

    vector<string> a(h);
    for (auto &x : a) cin >> x;

    long ans = solve(a, h, w, k, 0, true);
    printf("%lld\n", ans);
}


Measured memory_bytes: 3664
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 55

int H,W;
int diff_row[4] = {-1,0,0,1},diff_col[4] = {0,-1,1,0};
char buf[SIZE][SIZE];


bool rangeCheck(int row,int col){

	return row >= 0 && row <= H-1 && col >= 0 && col <= W-1;
}

int main(){

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

	for(int row = 0; row < H; row++){

		scanf("%s",buf[row]);
	}

	for(int row = 0; row < H; row++){
		for(int col = 0; col < W; col++){
			if(buf[row][col] == '.')continue;

			int count = 0;

			for(int i = 0; i < 4; i++){

				int adj_row = row+diff_row[i];
				int adj_col = col+diff_col[i];

				if(!rangeCheck(adj_row,adj_col))continue;

				if(buf[adj_row][adj_col] == '#'){
					count++;
					break;
				}
			}
			if(count == 0){

				printf("No\n");
				return 0;
			}
		}
	}

	printf("Yes\n");

	return 0;
}


Measured memory_bytes: 3740
#include <map>
#include <list>
#include <cmath>
#include <cstring>
#include <iostream>
#include <algorithm>
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
char n[50]; 
int main()
{
	fast;
	cin>>n;
	for (int i=0;i<=strlen(n);i++)
	   if (n[i]=='9')
	   {
	   	  cout<<"Yes"<<endl;
	   	  return 0;
	   }
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

class mountain {
public:
  i64 left;
  i64 right;
  mountain(const i64& left, const i64& right) :
    left(left), right(right) {
  }
  i64 sum() const {
    return this->left * (this->left - 1) / 2 + this->right * (this->right - 1) / 2 + std::max(this->left, this->right);
  }
};

int main() {
  std::string S;
  std::cin >> S;

  std::vector<mountain> mountains;
  switch (S.front()) {
  case '<':
    mountains.emplace_back(1, 0);
    break;
  case '>':
    mountains.emplace_back(0, 1);
    break;
  }
  for (auto it = ++S.begin(), prev_it = S.begin(); it != S.end(); prev_it = it, ++it) {
    switch (*it) {
    case '<':
      switch (*prev_it) {
      case '<':
        ++mountains.back().left;
        break;
      case '>':
        mountains.emplace_back(1, 0);
        break;
      }
      break;
    case '>':
      ++mountains.back().right;
      break;
    }
  }

  std::cout << std::accumulate(mountains.begin(), mountains.end(), static_cast<i64>(0), [](const i64& sum, const mountain& mountain) {
    return sum + mountain.sum();
  }) << std::endl;
  return 0;
}

Measured memory_bytes: 3068
import sys;sys.setrecursionlimit(10**9)
class UnionFind:
  def __init__(self,n):
    self.n=[-1]*n
    self.r=[0]*n
    self.siz=n
  def find_root(self,x):
    if self.n[x]<0:
      return x
    else:
      self.n[x]=self.find_root(self.n[x])
      return self.n[x]
  def unite(self,x,y):
    x=self.find_root(x)
    y=self.find_root(y)
    if x==y:return
    elif self.r[x]>self.r[y]:
      self.n[x]+=self.n[y]
      self.n[y]=x
    else:
      self.n[y]+=self.n[x]
      self.n[x]=y
      if self.r[x]==self.r[y]:
        self.r[y]+=1
    self.siz-=1
  def root_same(self,x,y):
    return self.find_root(x)==self.find_root(y)
  def count(self,x):
    return -self.n[self.find_root(x)]
  def size(self):
    return self.siz
n,m=map(int,input().split())
u=UnionFind(m+1)
ll=set()
for i in range(n):
  k,*l=map(int,input().split())
  if i==0:root=l[0]
  for j in range(len(l)-1):u.unite(l[j],l[j+1])
  ll|=set(l)
if len(ll)==u.count(root):print('YES')
else:print('NO')

Measured memory_bytes: 10800
#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;

struct Path {
  int from_pos, from_time;
  int to_pos, to_time;
  int cost;
  Path(int a, int b, int c, int d, int e) {
    from_pos  = a;
    from_time = b;
    to_pos    = c;
    to_time   = d;
    cost      = e;
  }
  Path() {
  }
};

struct State {
  int pos, time, cost;
  State(int a, int b, int c) {
    pos  = a;
    time = b;
    cost = c;
  }
  bool operator>(const State& another) const {
    return cost > another.cost;
  }
  bool operator<(const State& another) const {
    return cost < another.cost;
  }
};

int Solve(int n) {
  int m, l, k, a, h;
  cin >> m >> l >> k >> a >> h;
  std::vector<Path> node[101][101];
  int mincost[101][101];
  for (int i = 0; i <= 100; i++) {
    for (int j = 0; j <= 100; j++) {
      mincost[i][j] = INT32_MAX / 3;
    }
  }
  mincost[a][m] = 0;

  for (int i = 0; i < l; i++) {
    int m1;
    cin >> m1;
    //冷凍についてを入れる
    for (int begin_time = 0; begin_time < m; begin_time++) {
      for (int fridge_time = 1; fridge_time + begin_time <= m; fridge_time++) {
        node[m1][begin_time].push_back(
            Path(m1, begin_time, m1, begin_time + fridge_time, fridge_time));
      }
    }
  }
  for (int i = 0; i < k; i++) {
    int from, to, cost;
    cin >> from >> to >> cost;
    for (int begin_time = m; begin_time - cost >= 0; begin_time--) {
      node[from][begin_time].push_back(
          Path(from, begin_time, to, begin_time - cost, cost));
      node[to][begin_time].push_back(
          Path(to, begin_time, from, begin_time - cost, cost));
    }
  }

  std::priority_queue<State, std::vector<State>, std::greater<State>> pq;
  pq.push(State(a, m, 0));

  while (!pq.empty()) {
    State curr = pq.top();
    pq.pop();
    for (auto e : node[curr.pos][curr.time]) {
      int fridge_time = curr.time - e.cost;
      if(curr.pos==e.to_pos){
        fridge_time=curr.time+e.cost;
      }

      if (fridge_time < 0) continue;
      int cum_time = curr.cost + e.cost;
      if (cum_time < mincost[e.to_pos][fridge_time]) {
        mincost[e.to_pos][fridge_time] = cum_time;
        pq.push(State(e.to_pos, fridge_time, cum_time));
      }
    }
  }

  int result = INT32_MAX / 3;
  bool found = false;
  for (int i = 0; i <= m; i++) {
    if (result > mincost[h][i]) {
      found  = true;
      result = mincost[h][i];
    }
  }
  if (!found) {
    return -1;
  } else {
    return result;
  }
}

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

  while (1) {
    int n;
    cin >> n;
    if (n == 0) break;

    int result = Solve(n);
    if (result == -1) {
      cout << "Help!" << endl;
    } else {
      cout << result << endl;
    }
  }

  return 0;
}



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

int main() {
	int n;
	int64_t a[200000];
	cin >> n >> a[0];
	for (int i = 1; i < n; i++) {
		cin >> a[i];
		a[i] += a[i - 1];
	}
	int64_t r = abs(a[n - 1] - 2 * a[0]);
	for (int i = 1; i < n - 1; i++) {
		r = min(r, abs(a[n - 1] - 2 * a[i]));

	}
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
using namespace std;
const int N=1e6+10,mod=1e9+7;
int n,a[N],f[N],g[N],E[N],inv[N],Ans;
int main()
{
	cin>>n;inv[1]=1;
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=2;i<=n;i++) inv[i]=mod-1ll*mod/i*inv[mod%i]%mod;
	for(int i=1;i<=n;i++) f[i]=1ll*g[i-1]*inv[i]%mod+1,g[i]=(g[i-1]+f[i])%mod;
	for(int i=1;i<=n;i++) E[i]=(f[i]+f[n-i+1]-1)%mod;
	for(int i=1;i<=n;i++) (Ans+=1ll*E[i]*a[i]%mod)%=mod;
	for(int i=1;i<=n;i++) Ans=1ll*Ans*i%mod;
	cout<<(Ans+mod)%mod<<endl;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define inf 2e9
#define MOD 1000000007

using namespace std;
typedef long long ll;


int main(){
  string s; cin >> s;

  int n = s.size();

  int ans = 0;
  rep(i,n/2){
    if(s[i] != s[n-i-1]) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var r, g, b, n int
	fmt.Scan(&r, &g, &b, &n)
	ans := 0
	for i := 0; i <= n/r; i++ {
		for j := 0; j <= (n-(r*i))/g; j++ {
			if (n-(r*i)-(g*j))%b == 0 {
				ans++
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <stdio.h>
int main(void){
  int n,i,max=0,ans=0;
  scanf("%d",&n);
  int p[n+1];
  for(i=0;i<n;i++){
    scanf("%d",&p[i]);
    max=(p[i]>max?p[i]:max);
    ans+=p[i];
  }
  ans-=(max/2);
  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 128
def calc(E,A):
  if len(A) >= 2:
    a2 = int(A.pop())
    a1 = int(A.pop())
    if E == '*' :
      a3 = a1 * a2
    elif E == '+':
      a3 = a1 + a2
    elif E == '-':
      a3 = a1 - a2
    A.append(a3)
    

E = list(input().split())
a = []
for e in E:
  if (e == '+' or e == '-' or e == '*') :
    calc(e,a)
  else:
    a.append(e)

print(a[0])


Measured memory_bytes: 5600
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	lli n;
	bool ans = true;
	cin >> n;
	vector<pair<lli, lli>> c(n);
	rep(i,n){
		cin >> c[i].second >> c[i].first;
	}
	sort(all(c));
	lli sum =0;
	for(const auto& x : c){
		sum += x.second;
		if(sum > x.first){
			ans = false;
			break;
		}
	}
	if(ans) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3456
const input = require("fs").readFileSync("/dev/stdin", "utf8")
;(input => {
  
    const lines = input.split('\n')
    const N = lines[0] - 0

    const T = []
    for (let i = 1; i <= N; i++) {
         T.push(lines[i].split(' ').map(Number))
    }
  
    const f = (a, b) => {
      const dist = Math.abs(a[1] + a[2] - b[1] - b[2])
      const t = b[0] - a[0]
      if (t < dist) {
        return false
      } else if ((t - dist) % 2) {
        return false
      }
      return true
    }
    
    let ans = 'Yes'
    let t = null
    let p = [0, 0, 0]
    for (let i = 0; i < N; i++) {
        const t = T[i]
	    if (f(p, t)) {
            p = t
        } else {
            ans = 'No'
            break
        }
    }

    console.log(ans)
  
})(input)


Measured memory_bytes: 63012
#pragma GCC optimize("O3")
#pragma GCC optimize("Os")
#pragma GCC target("avx2")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(int i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
using namespace std;
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
void vok()
{
    FAST
    FO
    FI
}
int main()
{
    vok();
    ll n,k;
    IN n>>k;
    vll a(n);
    bitset<50> b[n];
    loop(i,0,n)
    {
        IN a[i];
        bitset<50> temp(a[i]);
        b[i]=temp;
    }
    bitset<50> ans(0);
    rloop(i,49,0)
    {
        int countt=0;
        loop(j,0,n)
        {
            if(b[j][i])
            {
                countt++;
            }
          	cout<<"";
        }
        ans[i]=1;
        if((countt*2)<n && ans.to_ullong()<=k)
        {
            //Do Nothing
        }
        else
        {
            ans[i]=0;
        }
    }
    ll fans=0LL;
    ll X=ans.to_ullong();
    loop(i,0,n)
    {
      	cout<<"";
        fans+=(X^a[i]);
    }
    OUT fans<<endl
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int dist[100010];
deque<int> dq;
int n;
int main()
{
	cin >>n;
	fill(dist,dist+n,1e9);
	dist[1]=1;
	dq.push_back(1),dq.push_back(1);
	while (1)
	{
		int x=dq.front(); dq.pop_front();
		int y=dq.front(); dq.pop_front();
		//cout <<x<<" "<<y<<" ###########\n"; 
		if (!x)
		{
			cout <<y;
			return 0;
		}
		if (dist[(x*10)%n]>y)
		{
			dist[(x*10)%n]=y;
			dq.push_front(y);
			dq.push_front((x*10)%n);
		}
		if (dist[(x+1)%n]>y+1)
		{
			dist[(x+1)%n]=y+1;
			dq.push_back((x+1)%n);
			dq.push_back(y+1);
		}
	}
	return 0;
} 

Measured memory_bytes: 1024