akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>


int main() {



	int i, j, N, L, ta[200], min=100000, sum=0, min_i=0;


	scanf("%d %d", &N, &L);

	min = 100000;

	for (i = 1; i <= N; i++) {
		ta[i]= L + i - 1;
		sum+= L + i - 1;
		if (min > abs(L+i-1)) {
			min = abs(L+i-1);
			min_i = i;
		}
	}
	
	sum -= L+min_i-1;
	printf("%d\n", sum);


	return 0;

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int x;
    cin>>x;
    long long int count=0;
    if(x>=500)
    {
        count=count+(x/500)*(1000);
        x=x%500;
    }
    if(x>=5)
    {
        count=count+(x/5)*5;
        x=x%5;
    }
    cout<<count<<"\n";

}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define N 100020
#define ll long long
using namespace std;
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(ch>'9'||ch<'0')ch=='-'&&(f=0)||(ch=getchar());
	while(ch<='9'&&ch>='0')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return f?x:-x;
}
ll a[N], b[N], c[N], f[N], g[N];
int main(int argc, char const *argv[]) {
	int n = read();
	for (int i = 1; i <= n; i++)
		a[i] = read();
	for (int i = 1; i <= n; i++)
		b[i] = read();
	for (int i = 1; i <= n; i++)
		c[i] = read();
	sort(a + 1, a + n + 1);
	sort(b + 1, b + n + 1);
	sort(c + 1, c + n + 1);
	for (int i = 1; i <= n; i++)
		f[i] = lower_bound(a + 1, a + n + 1, b[i]) - a - 1 + f[i - 1];
	for (int i = 1; i <= n; i++)
		g[i] = f[lower_bound(b + 1, b + n + 1, c[i]) - b - 1] + g[i - 1];
	printf("%lld\n", g[n]);
	return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n;
    cin>>n;
    ll arr[n+5];
    ll ans[n+5];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    ans[0]=0;
    ans[1]=abs(arr[1]-arr[0]);
    for(int i=2;i<n;i++)
    {
        ans[i]=min(ans[i-1]+abs(arr[i]-arr[i-1]),ans[i-2]+abs(arr[i]-arr[i-2]));
    }
    cout<<ans[n-1];
    cout<<'\n';
    return 0;
}

Measured memory_bytes: 5096
using System;
using System.Collections.Generic;

namespace nineXnine
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split();
            int inputA = int.Parse(input[0]);
            int inputB = int.Parse(input[1]);

            if (inputA > 9 || inputB > 9)
            {
                Console.WriteLine("-1");
            }
            else
            {
                Console.WriteLine(inputA * inputB);
            }
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  cin >> n;
  ll c[n];
  mem(c);
  rep(i,n-1) {
    ll x;
    R x;
    x--;
    c[x]++;
  }
  rep(i,n) pr(c[i]);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 5208
#include <stdio.h>

int main(void)
{
    int i, j, k, a, b, c, x, s, n=0;

    scanf("%d%d%d%d", &a, &b, &c, &x);

    for (i=0; i<=a; i++) {
        for (j=0; j<=b; j++) {
            for (k=0; k<=c; k++) {
                s = i*500 + j*100 + k*50;
                if (s==x)  n++;
            }
        }
    }

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

    return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<algorithm>
const int M=2e6+7;
int a[M],b[M],n,m;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	std::sort(a+1,a+1+n);
	scanf("%d",&m);
	for(int i=1;i<=m;i++) scanf("%d",&b[i]);
	std::sort(b+1,b+1+m);
	int s=1;
	for(int i=1;i<=m;i++){
		while(a[s]!=b[i]&&s<=n) s++;
		if(s>n) return printf("NO\n") ,0;
		s++;
	}printf("YES\n");
	return 0;
}

Measured memory_bytes: 4992
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;

class Main {
	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static Scanner sc = new Scanner(new InputStreamReader(System.in));

	public static void main (String[] args) throws Exception {
		while(true) {
			int n = Integer.parseInt(br.readLine());
			if(n == 0) break;
			System.out.println(n/5+n/25+n/125+n/625+n/3125+n/15625);
		}
	}
}

Measured memory_bytes: 17348
import sys
input = sys.stdin.readline

h, w = map(int, input().split())
a = [tuple(map(int, input().split())) for _ in range(h)]
b = [tuple(map(int, input().split())) for _ in range(h)]
c = [[abs(a[i][j] - b[i][j]) for j in range(w)] for i in range(h)]

CONST = 80 * 80 * 2
dp = [[0] * w for _ in range(h)]
dp[0][0] = 1 << (c[0][0] + CONST)

for i in range(h):
    for j in range(w):
        if i < h - 1:
            dp[i + 1][j] |= (dp[i][j] << c[i + 1][j])
            dp[i + 1][j] |= (dp[i][j] >> c[i + 1][j])
        if j < w - 1:
            dp[i][j + 1] |= (dp[i][j] << c[i][j + 1])
            dp[i][j + 1] |= (dp[i][j] >> c[i][j + 1])

for k in range(CONST):
    if dp[h - 1][w - 1] & (1 << (CONST + k)) != 0 or dp[h - 1][w - 1] & (
            1 << (CONST - k)) != 0:
        ans = k
        break

print(ans)


Measured memory_bytes: 20468
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<bitset>
#define LL long long
#define INF 0x3f3f3f3f
using namespace std;

namespace FastIO {
	template<typename tp> inline void read(tp &x) {
		x=0; register char c=getchar(); register bool f=0;
		for(;c<'0'||c>'9';f|=(c=='-'),c = getchar());
		for(;c>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0',c = getchar());
		if(f) x=-x;
	}
	template<typename tp> inline void write(tp x) {
		if (x==0) return (void) (putchar('0'));
		if (x<0) putchar('-'),x=-x;
		int pr[20]; register int cnt=0;
		for (;x;x/=10) pr[++cnt]=x%10;
		while (cnt) putchar(pr[cnt--]+'0');
	}
	template<typename tp> inline void writeln(tp x) {
		write(x);
		putchar('\n');
	}
}
using namespace FastIO;
const int N=1e5+4;

int n;
int f[N],nnext[2*N],l[N],r[N],v[2*N],num[N],jis=0;
bool vis[N];
int odd[N];
inline void add(int a,int b){
	nnext[++jis]=f[a];
	f[a]=jis;
	v[jis]=b;
}

void dfs1(int a){
	vis[a]=1;
	if(num[a]!=-1&&odd[a]!=(num[a]&1)){
		puts("No");
		exit(0);
	}
	for(int i=f[a];i;i=nnext[i]){
		int d=v[i];
		if(vis[d]) continue;
		odd[d]=!odd[a];
		dfs1(d);
		l[a]=max(l[a],l[d]-1);
		r[a]=min(r[a],r[d]+1);
	}
	if(l[a]>r[a]){
		puts("No");
		exit(0);
	}
}

void dfs2(int a){
	vis[a]=1;
	for(int i=f[a];i;i=nnext[i]){
		int d=v[i];
		if(vis[d]) continue;
		if(num[a]-1>=l[d]&&num[a]-1<=r[d]){
			num[d]=num[a]-1;
		}else{
			num[d]=num[a]+1;
		}
		dfs2(d);
	}
}

int main(){
	read(n);
	memset(num,-1,sizeof num);
	for(int i=0;i<=N;++i) l[i]=-(r[i]=INF);
	for(int i=1;i<n;++i){
		int a,b;
		read(a),read(b);
		add(a,b);
		add(b,a);
	}
	int k;
	read(k);
	int a;
	while(k--){
		read(a);
		read(num[a]);
		r[a]=l[a]=num[a];
	}
	odd[a]=num[a]&1;
	dfs1(a);
	memset(vis,0,sizeof vis);
	dfs2(a);
	puts("Yes");
	for(int i=1;i<=n;++i) writeln(num[i]);
	return 0;
}

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


int main() {
	int n, two[25] = {},num[25]={},kosuu,hen=0,memo;
	two[0] = 1;
	scanf("%d", &n);
	if (n == 1) { printf("2 1\n1 2 0"); }
	for (int i = 1; i <= 20; i++) {
		two[i] = 2 * two[i - 1];
	}
	for (int i = 0; i <= 19; i++) {
		if ((n / two[i]) % 2 == 1) { 
			num[i+1] = 1;
			kosuu = i+1; 
			hen++;
		}
	}
  	
  
	hen += 2 * kosuu-3;
	printf("%d %d\n", kosuu, hen);
	for (int i = 1; i < kosuu; i++) {
		printf("%d %d 0\n%d %d %d\n", i, i + 1, i, i + 1, two[i - 1]);
	}
	memo = two[kosuu-1];
	for (int i = kosuu-1; i >0; i--) {
		if (num[i] == 1) {
			printf("%d %d %d\n", i, kosuu, memo);
			memo += two[i-1];
		}
	}

}

Measured memory_bytes: 128
n,q = map(int,input().split())
s = input()
state = [0]*n
for i in range(1,n):
  state[i] += state[i-1]
  if s[i-1:i+1] == "AC":
    state[i] += 1
for _ in range(q):
  l,r = map(int,input().split())
  print(state[r-1]-state[l-1])
  

Measured memory_bytes: 7700
def main():
    sx,sy,tx,ty = map(int,input().split())
    tx = tx-sx
    ty = ty-sy
    ans = ['R' for i in range(tx)]
    ans += ['U' for i in range(ty)]
    ans += ['L' for i in range(tx)]
    ans += ['D' for i in range(ty)]
    ans += ['D']
    ans += ['R' for i in range(tx+1)]
    ans += ['U' for i in range(ty+1)]
    ans += ['L', 'U']
    ans += ['L' for i in range(tx+1)]
    ans += ['D' for i in range(ty+1)]
    ans += ['R']
    print(''.join(ans))

if __name__ == "__main__":
    main()


Measured memory_bytes: 9164
while True:
    m, f, r = map(int, input().split())
    if m == f == r == -1:
        break
    if m == -1 or f == -1:
        print('F')
    elif (m + f) >= 80:
        print('A')
    elif (m + f) >= 65 and (m + f) < 80:
        print('B')
    elif (m + f) >= 50 and (m + f) < 65:
        print('C')
    elif (m + f) >= 30 and (m + f) < 50:
        if r >= 50:
            print('C')
        else:
            print('D')
    else:
        print('F')


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

int main(){
  string s;
  cin >> s;
  
  if(s[0] == s[1] || s[1] == s[2] || s[2] == s[0]) cout << "No" << endl;
  else cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 100001;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    ll N, K;
    cin >> N >> K;
    vector<ll> cnt(MAX);
    ll a, b;
    for (int i = 0; i < N; i++) {
        cin >> a >> b;
        cnt[a] += b;
    }
    ll sum = 0;
    for (int i = 0; i < MAX; i++) {
        sum += cnt[i];
        if (sum >= K) {
            cout << i << '\n';
            return 0;
        }
    }
}


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


def divisor(M):
    div = set()
    for i in range(1, int(N ** 0.5 + 0.5) + 1):
        if M % i == 0:
            div.add(i)
            div.add(M // i)
    return div


def simu(M, X):
    cnt = 0
    while M >= X:
        if M % X == 0:
            M //= X
        elif M % X == 1:
            return True
        else:
            M -= X
        cnt += 1
        if cnt > 1000:
            return False
    return M == 1


A = divisor(N)
B = divisor(N - 1)

# N%K==1となるやつ
ans = len(B) - 1

for a in (A - B):
    if simu(N, a):
        ans += 1

print(ans)


Measured memory_bytes: 3952
#include <iostream>
#include <vector>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
using ll = long long;
using namespace std;
const ll mod = 1000000007;

int main() {
    ll n,m;
    cin >> n >> m;
 
    ll a = min(n,m/2);
    ll b = (m - 2 * a) / 4;

    cout << a + b << endl;
 
    return 0;
}

Measured memory_bytes: 256
N = int(input())
colors = input().split()
P = 0
W = 0
G = 0
Y = 0
for c in colors:
    if c == 'P':
        P = 1
    elif c == 'W':
        W = 1
    elif c == 'Y':
        Y = 1
    elif c == 'G':
        G = 1
if P + W + Y + G == 3:
    print('Three')
else:
    print('Four')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#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)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    string S;
    cin >> S;
    //int even_flag, odd_flag = 1;
    int flag = 1;

    for(int i = 0; i < S.length(); i++){
        if((i+1) % 2 == 0 && S[i] == 'R'){
            flag = 0;
            break;
        }
        else if((i+1) % 2 != 0 && S[i] == 'L'){
            flag = 0;
            break;
        }
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll int64_t
#define all(v) v.begin(), v.end()
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)


int main() {

int N; cin >> N ;

vector<string> S(N);

rep(i,N) cin>> S[i];

set<string> A;

rep(i,N) A.insert(S[i]);

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

return 0;
}

Measured memory_bytes: 24992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class T>bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(32);
    ll n, m, d;
    cin >> n >> m >> d;
    ld ans = (d == 0 ? 1 : 2);
    ans *= (n-d)*(m-1);
    ans /= n*n;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {

	static int H;
	static int W;
	static char[][] map;

	// この問題の場合、H=100,W=100で最高10000回再帰するが、それをやるとStackOverFlowエラーになる
	// dfsを再帰で書かないプログラムが必要

	static void dfs(int y, int x, char c) { // cと同じ文字のところを塗りつぶし的にDFS

		Stack<Integer> stk = new Stack<Integer>();

		stk.push(y);
		stk.push(x);

		while (stk.size() > 0) {

			x = stk.pop();
			y = stk.pop();

			map[y][x] = '.'; // 現在位置は探索済みとして.に変えておく

			if (y > 0)
				if (map[y - 1][x] == c){
					stk.push(y-1);
					stk.push(x);
				}
			if (x > 0)
				if (map[y][x - 1] == c){
					stk.push(y);
					stk.push(x-1);
				}
			if (x < W - 1)
				if (map[y][x + 1] == c){
					stk.push(y);
					stk.push(x+1);
				}
			if (y < H - 1)
				if (map[y + 1][x] == c){
					stk.push(y+1);
					stk.push(x);
				}

		}

		return;
	}

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		ArrayList<Integer> ans = new ArrayList<Integer>();

		while (true) {

			H = scan.nextInt();
			W = scan.nextInt();

			if (H == 0)
				break;

			map = new char[H][W];

			for (int i = 0; i < H; i++)
				map[i] = (scan.next()).toCharArray();

			int cnt = 0;

			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					if (map[i][j] != '.') {
						dfs(i, j, map[i][j]);
						cnt++;
					}
				}
			}

			ans.add(cnt);
		}

		for (Integer integer : ans) {
			System.out.println(integer);
		}

	}

}

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

using namespace std;

typedef long long ll;

const int max_n = 2020;
const int INF = 10101010;
int n, x, y;

int d[max_n][max_n];

void dfs(int u, int v, int c){
	d[u][v] = c;
	if(v == x){
		if(d[u][y] > c + 1) dfs(u, y, c + 1);
	}

	if(v == y){
		if(d[u][x] > c + 1) dfs(u, x, c + 1);
	}

	if(v > 0){
		if(d[u][v-1] > c + 1) dfs(u, v - 1, c + 1);
	}

	if(v+1 < n){
		if(d[u][v+1] > c + 1) dfs(u, v + 1, c + 1);
	}
}

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

	cin >> n >> x >> y;
	x--;
	y--;

	rep(i, n) rep(j, n) d[i][j] = INF;
	rep(i, n) dfs(i, i, 0);
	vector<int> ans(n-1, 0);
	for(int i = 0; i < n; i++){
		for(int j = i + 1; j < n; j++){
			ans[d[i][j]-1]++;
		}
	}
	rep(i, n - 1) cout << ans[i] << endl;
}


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

int main(void){
  int n, m, i, a, b;
  cin >> n >> m;
  int road[n] = {};
  for(i = 0; i < m; i++){
    cin >> a >> b;
    road[a-1]++;
    road[b-1]++;
  }
  for(i = 0; i < n; i++){
    cout << road[i] << endl;
  }
  return 0;
}


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

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] inputs = Console.ReadLine().Trim().Split(' ').Select(x => int.Parse(x)).ToArray();
            Console.WriteLine(inputs[2] * inputs[0] <= inputs[1] ? inputs[2] : inputs[1] / inputs[0]);

#if DEBUG
            Console.ReadKey();
#endif
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll cub(ll n)
{
    return n*n*n;
}
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    ll n,k,ans;
    cin>>n>>k;
    ll x=n/k;
    ans=cub(x);
    if(k%2==0)
    {
        x=(n+(k/2))/k;
        ans+=cub(x);
    }
    cout<<ans<<endl;





    return 0;
}


Measured memory_bytes: 3612
def solve():
  X = int(input())
  Fin = False
  for a in range(-1000, 1000):
    for b in range(-1000, 1000):
      if a ** 5 - b ** 5 == X:
        Fin = True
        print(a, b)
        break
    if Fin: break
  return 0
if __name__ == "__main__":
  solve()
  


Measured memory_bytes: 9176
#include <bits/stdc++.h>
typedef long long ll;
#define INF 1000000000
#define MOD 1000000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
    int n;
    cin>>n;
    int a[n];
    int maxval=0;
    int ans=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        maxval=max(maxval,a[i]);
        ans+=a[i];
    }
    ans-=maxval/2;
    cout<<ans<<endl;
    return 0;  
}

Measured memory_bytes: 256
N = int(input())
B = [int(v) for v in input().split()]

A = [0] * N
for i in range(N - 1):
    if i == 0:
        A[i] = B[i]
    elif A[i] > B[i]:
        A[i] = B[i]
    A[i + 1] = B[i]
print(sum(A))



Measured memory_bytes: 3060
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
double f(double x)
{
	return 1.0/x;
}
int main()
{
	int n;
	cin >>n;
	double sum=0.0,ans;
	double a[105];
	for(int i=0;i<n;i++)
		cin >>a[i];
	for(int i=0;i<n;i++)
		sum = sum+f(a[i]);
	cout <<f(sum);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define ll long long
#define X first
#define Y second
#define pb push_back
#define mp Maxke_pair
#define pii pair<int, int>
#define ls rt << 1
#define rs rt << 1 | 1
#define mod 1000000007
#define sz(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#define vi vector<int>
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
const int N = 100010;
using namespace std;
bitset<4000010> dp;
int tot, Max, n;
int main()
{
	n = read();
	dp |= 1;
	rep(i, 0, n - 1)
	{
		int a = read();
		Max = max(a, Max);
		tot += a;
		dp = (dp << a) | dp;
	}
	if(Max >= tot - Max) printf("%d\n", Max);
	else
	{
		for(int i = (tot + 1) / 2; ; i ++)
			if(dp.test(i))
			{
				printf("%d\n",i);
				break;
			}
	}
	return 0;
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
#define ll long long
const int N=1000005;
using namespace std;
int n,m,a[N],ans;
int main(){
	cin>>m>>n;
	for(int i=1;i<=n;i++)
	    cin>>a[i],ans+=a[i];
	if(ans<=m) cout<<m-ans;
	else cout<<-1;
    return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
int f(int x){
    int A = x;
    for(int i=x-1;i>1;i--){
        A *= i;
    }
    return A;
}
int main(void){
    int n;
    double ans = 0;
    cin >> n;
    vector<vector<int>> v(n,vector<int>(2));
    for(int i=0;i<n;i++) cin >> v[i][0] >> v[i][1];
    vector<int> w(n);
    for(int i=0;i<n;i++) w[i] = i;
    do{
        double a = 0;
        for(int j=0;j<w.size()-1;j++){
            a += pow(abs(v[w[j]][0]-v[w[j+1]][0])*abs(v[w[j]][0]-v[w[j+1]][0])+abs(v[w[j]][1]-v[w[j+1]][1])*abs(v[w[j]][1]-v[w[j+1]][1]),0.5);
        }
        ans += a;
        a = 0;
    }while(next_permutation(w.begin(), w.end()));
    cout << fixed << setprecision(6) << ans/f(n)<< endl;
}

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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
void debug(vector<vector<ll>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
void debug(vector<ll>v,ll n){cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}
//m.emplace(x,0).fi->se++;

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  string s;cin>>s;
  ll n=(ll)s.size();
  ll countr=0;
  ll countl=0;
  vector<ll>a(n);
  for(ll i=0;i<n;){
    while(s[i]=='R'&&i<n){
      i++;
      countr++;
    }
    ll x=i-1;
    ll y=i;
    a[x]+=countr-countr/2;
    a[y]+=countr/2;
    while(s[i]=='L'&&i<n){
      i++;
      countl++;
    }
    a[x]+=countl/2;
    a[y]+=countl-countl/2;

    countr=0;
    countl=0;
  }
  debug(a,n);


  return 0;
}

Measured memory_bytes: 2256
// abca29c.cpp : Typical Stairs
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007

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

	vector<bool> ok(n+1,true);
	for(int i=0;i<m;i++){
		int a; cin>>a;
		ok[a] = false;
	}

	vector<int> dp(n+1);
	dp[0] = 1;
	if(ok[1]) dp[1] = 1;
	for(int i=2; i<=n; i++)
		if(ok[i]) dp[i] = (dp[i-1] + dp[i-2]) % MOD;

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

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
int main()
{
	int i,m=0,n=0;
	char s[250];
	scanf("%s",s);
	int l=strlen(s);
	for(i=0;i<l;i++){
		if(s[i]=='C'){
			m=1;
			i++;
		}
		if(m){
			if(s[i]=='F'){
				n=1;
				break;
			}
		}
	}
	if(n){
		printf("Yes"); 
	}else{
		printf("No");
	}
	
	return 0;
} 

Measured memory_bytes: 128
#include <stdio.h>          // printf(), putchar(), scanf()
#include <stdbool.h>

#define MAX_N 100

const char NUL = '\0';

void
spiral(int n)
{
	char field[MAX_N][MAX_N + 1];
	int x, y;
	int s;

	for (y = 0; y < n; ++y)
	{
		for (x = 0; x < n; ++x)
			field[y][x] = ' ';

		field[y][n] = NUL;
	}

	int t = 0, b = n;
	int l = 2, r = n;
	x = 0, y = n;
	while (true)
	{
		if (y <= t)
			break;

		s = y - t;
		for (y--; y >= t; --y)
			field[y][x] = '#';

		y = t;
		t += 2;
		if (s <= 1 || x >= r - 1)
			break;

		s = r - 1 - x;
		for (x++; x < r; ++x)
			field[y][x] = '#';

		x = r - 1;
		r -= 2;
		if (s <= 1 || y >= b - 1)
			break;

		s = b - 1 - y;
		for (y++; y < b; ++y)
			field[y][x] = '#';

		y = b - 1;
		b -= 2;
		if (s <= 1 || x <= l)
			break;

		s = x - l;
		for (x--; x >= l; --x)
			field[y][x] = '#';

		x = l;
		l += 2;
		if (s <= 1)
			break;
	}

	for (y = 0; y < n; ++y)
		printf("%s\n", &field[y][0]);
}

int
main(int argc, char **argv)
{
	int d;
	scanf("%d", &d);
	for (int i = 0; i < d; ++i)
	{
		if (i != 0)
			putchar('\n');

		int n;
		scanf("%d", &n);
		spiral(n);
	}

	return 0;
}

Measured memory_bytes: 1744
#include <iostream>
#include <algorithm>
#include <vector>

int main() {
    int N;
    std::cin >> N;
    std::vector<std::pair<int, int>> v(N);
    for (auto& e : v) std::cin >> e.first >> e.second;

    std::sort(v.begin(), v.end());
    for (auto e : v) std::cout << e.first << " " << e.second << std::endl;
}


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


int main(){
	int n,h,w;
	cin>>n>>h>>w;

	int ans=0;
	for (int i = 1; i <= n; ++i){
		for (int j = 1; j <= n; ++j){
			if(i+h-1<=n && j+w-1<=n)
				ans++;
		}
	}

	cout<<ans<<endl;

}



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

class Main{
    public static void main(String[] args){
        solve();
    }

    public static void solve(){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        int x = (int)Math.min(a, b);
        while(true){
        	if(a%x==0 && b%x==0){
        		k--;
        		if(k<1){
        			break;
        		}
        	}
        	x--;
        }
        System.out.println(x);
    }
}

Measured memory_bytes: 23760
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

double DP1[1005];
double DP2[1005];

double doublemax(double a, double b){
  if(a>b) return a;
  else return b;
}

double doublemin(double a, double b){
  if(a>b) return b;
  else return a;
}

int main() {
  double xs, ys, xt, yt;
  cin>>xs>>ys>>xt>>yt;
  int N;
  cin>>N;
  double x[N], y[N], r[N];
  for(int i=0;i<N;++i){
    cin>>x[i]>>y[i]>>r[i];
  }
  priority_queue<pair<double, int>, vector<pair<double, int> >, greater<pair<double, int> > > que1, que2;
  for(int i=0;i<N;++i){
    que1.push(mp(doublemax(0, sqrt(pow(xs-x[i], 2) + pow(ys-y[i], 2))-r[i]), i));
    que2.push(mp(doublemax(0, sqrt(pow(xt-x[i], 2) + pow(yt-y[i], 2))-r[i]), i));
  }
  map<int, int> amap1, amap2;
  int num;
  double dist;
  while(!que1.empty()){
    dist = que1.top().fi;
    num = que1.top().se;
    que1.pop();
    if(amap1[num]>0) continue;
    DP1[num] = dist;
    amap1[num]++;
    for(int i=0;i<N;++i){
      if(amap1[i]>0) continue;
      que1.push(mp(dist+doublemax(0, sqrt(pow(x[num]-x[i], 2)+pow(y[num]-y[i], 2))-r[num]-r[i]), i));
    }
  }
  while(!que2.empty()){
    dist = que2.top().fi;
    num = que2.top().se;
    que2.pop();
    if(amap2[num]>0) continue;
    DP2[num] = dist;
    amap2[num]++;
    for(int i=0;i<N;++i){
      if(amap2[i]>0) continue;
      que2.push(mp(dist+doublemax(0, sqrt(pow(x[num]-x[i], 2)+pow(y[num]-y[i], 2))-r[num]-r[i]), i));
    }
  }
  double ans = DP1[0]+DP2[0];
  for(int i=1;i<N;++i){
    ans = doublemin(ans, DP1[i]+DP2[i]);
  }
  cout<<setprecision(20)<<doublemin(ans, sqrt(pow(xs-xt, 2)+pow(ys-yt, 2)))<<endl;
}



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

A0=list(map(int,input().split()))
A1=list(map(int,input().split()))

s0 = A0[0]
s1 = 0

for i in range(N):
    s1 += A1[i]

smx = s1 + s0

for i in range(1,N):
    s0 = s0 +A0[i]
    s1 = s1 -A1[i-1]
    if s0+s1>smx:
        smx = s0+s1
print(smx)

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

int main(){
    char num[11234];
    scanf("%s", num);
    int numint = atoi(num), digitos = 0;
    for (int i = 0; i < strlen(num); i++){
        digitos += num[i] - '0';
    }
    if (numint % digitos == 0)
        printf("Yes\n");
    else
        printf("No\n");
}

Measured memory_bytes: 128
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;
typedef unsigned long long int ull;


int main()
{
	FAST;
	string str;
	cin >> str;

	bool a[26] = {0};
	for(int i=0 ; i<str.size() ; i++)
		a[str[i]-'a'] = 1;

	for(int i=0 ; i<26 ; i++)
	{
		if(a[i] == 0)
		{
			cout << (char)(i+'a');
			return 0;
		}
	}

	cout << "None";
	return 0;
}

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

using namespace std;

using LL = long long;
using PII = pair<int, int>;
using ll = long long;
using DBL = double;
using VI = vector<int>;
using VD = vector<DBL>;
using VVI = vector<VI>;
using VVD = vector<VD>;

#define FOR(i,a,b) for(int i = a; i < b; i++)
#define REP(i,n) FOR(i,0,n)
#define SZ(a) ((int)((a).size()))
#define ALL(x) (x).begin(), (x).end()
#define SET(a,v) memset((a), (v), sizeof(a))
#define EB emplace_back
#define PB push_back
#define MP make_pair
#define ST first
#define ND second

//#define trace(...) {__f(#__VA_ARGS__, __VA_ARGS__);}
//template<typename Arg> void __f(const char* name, Arg&& arg) {
//  cerr << name << " = " << arg << std::endl;
//} template <typename Arg1, typename... Args>
//void __f(const char* names, Arg1&& arg1, Args&&... args) {
//  const char* comma = strchr(names + 1, ',');
//  cerr.write(names, comma - names) << " = " << arg1<<" | ";__f(comma+1, args...); }
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds; // OST: find_by_order, order_of_key
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//#pragma GCC optimize("Ofast")
//optimize("unroll-loops")
//target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
///*** RNGS ***/
//SEED=chrono::steady_clock::now().time_since_epoch().count();
//// or high_resolution_clock
//mt19937 rng(SEED); /*or*/ random_device rd; mt19937 rng(rd());
//uniform_int_distribution<> dis(MIN, MAX);// usage: dis(rng)
//struct chash {int operator()(int x) const {return x^SEED;}};
//gp_hash_table<int,int,chash>m;//use cc if very less updates
///*** FAST IO ***/
//inline int scan(){ bool y=0; int x=0; char c=getchar_unlocked();
//while(c<'0'||c>'9'){ if(c=='-')y=1; c=getchar_unlocked();}
//while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+c-'0';c=getchar_unlocked();}
//return y?-x:x; }

const int MAX = (1<<16);
int a[32][32];
long long score[MAX], dp[MAX];

long long calc(int mask) {
    long long &y = dp[mask];
    if(y != -1) return y;
    if(mask == 0) return y = 0;
    y = 0;
    for(int sub=mask; sub>0; sub = ((sub-1)&mask)) {
        y = max(y, score[sub] + calc((mask^sub)));
    }
    return y;
}

int main() {
    #ifdef LOCAL_EXEC
//    freopen("sample.in", "r", stdin);
//    freopen("sample.out", "w", stdout);
    #else
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    #endif
    memset(dp, -1, sizeof(dp));
    int n;
    cin >> n;
    for(int i=1; i<=n; ++i) {
        for(int j=1; j<=n; ++j) {
            cin >> a[i][j];
        }
    }
    for(int i=1; i<(1<<n); ++i) {
        int cur;
        for(int j=0; j<n; ++j) {
            if(i & (1<<j)) {
                cur = j;
                break;
            }
        }
        score[i] = score[i - (1<<cur)];
        for(int j=cur+1; j<n; ++j) {
            if(i & (1<<j)) {
                score[i] += a[cur+1][j+1];
            }
        }
    }
    cout << calc((1<<n)-1) << endl;
	return 0;
}


Measured memory_bytes: 4588
#include<cstdio>
using namespace std;
#define maxn 200100
int a[2*maxn];
int main()
{
	int n,x,h=maxn,t=maxn;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		if(i&1) a[t++]=x;
		else a[--h]=x;
	}
	if(n&1)
	{
		for(int i=t-1;i>=h;i--) printf("%d ",a[i]);
		printf("\n");
	}
	else
	{
		for(int i=h;i<t;i++) printf("%d ",a[i]);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 2816
#!/usr/bin/env python3
import sys


def solve(S: int, W: int):
    print('safe' if S > W else 'unsafe')
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    solve(S, W)

if __name__ == '__main__':
    main()


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

using namespace std;
typedef long long ll;
const long long mod=1e9+7; //10^9+7

int main() {
    int n;
    ll h[200000];
    int sw[200000];

    cin >> n;
    for(int i=0; i<n; i++){
        cin >> h[i];
        sw[i] = 0;
    }
    if(n==1){
        cout << "Yes" << endl;
        return 0;
    }
    int flg = 0;
    for(int i=0; i<n-1; i++){
        if(h[i]>h[i+1]+1){
            flg = 1;
        } else if(h[i]==h[i+1]+1){
            h[i]--;
            sw[i] = 1;
            for(int j=i; j>0;j--){
                if( h[j-1] > h[j]+1 ){
                    flg = 1;
                    break;
                }else if(h[j-1]==h[j]+1){
                    if(sw[j-1]==1){
                        flg = 1;
                        break;
                    }else{
                        h[j-1]--;
                        sw[j-1] = 1;
                    }
                }else if(h[j-1]<=h[j]){
                    break;
                }
            }
        }
        if(flg == 1) break;
    }

    if(flg == 1) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 2560
from collections import Counter

MOD = 10 ** 9 + 7


def factorization(n):
    arr = dict()
    temp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr[i] = cnt

    if temp != 1:
        arr[temp] = 1

    if not arr and n != 1:
        arr[n] = 1

    return arr


ct = Counter()
for i in range(2, int(input()) + 1):
    ct.update(factorization(i))

ans = 1
for t in ct.values():
    ans = (ans * (t + 1)) % MOD
print(ans)


Measured memory_bytes: 3316
#include<iostream>
long N,X,p,i;
int main(){
	std::cin>>N>>X;
		for(i=(1LL<<N/2)*(1<<(N+3>>1));i;i>>=1,--X){
		if(X+1>=i){
			p|=i>>1;
			X-=i-2;
		}
	}
	std::cout<<p;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#pragma GCC optimize ("Ofast")
//#pragma GCC target ("avx,avx2")
#define rep(i, n)    for(ll i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define pb push_back
#define X first
#define Y second
typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vii;
const ll INF = 1e18+1;
const ll MOD = 1000000007L;
#ifdef umang99m
    #include "/home/umang/Desktop/folder/home/.templates/header.h"
#else
    #define dbg(args...)
    #define timer()
#endif
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);

    ll n,k;
    cin>>n>>k;
    vi w(n+1), v(n+1);
    repA(i,1,n) cin>>w[i]>>v[i];


    ll dp[n+1][k+1];
    memset(dp, 0, sizeof(dp));
    repA(i,1,n){
        repA(j,1,k){
            dp[i][j] = dp[i-1][j];
            if(j >= w[i]) dp[i][j] = max(dp[i][j] , dp[i-1][j-w[i]] + v[i]);
        }
    }
    cout<<dp[n][k]<<endl;

    timer();
    return 0;
}

Measured memory_bytes: 79232
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
int main(){
    int X,Ureshisa=0;
    cin>>X;
    while(X>=500)
    {
        X=X-500;
        Ureshisa += 1000;
    }
    if(X!=0)
    {
        while(X>=5)
        {
            X=X-5;
            Ureshisa += 5;
        }
    }
    cout<<Ureshisa<<endl;
return 0;
}


Measured memory_bytes: 256
x1,y1,x2,y2 = map(int,input().split())
x3 = x2 + y1 - y2
y3 = y2 + x2 - x1
x4 = x3 + x1 - x2
y4 = y3 + y1 - y2
print(x3,y3,x4,y4)

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

sc_t = sc_h = 0
for i in range(n):
  t,h = input().split(" ")
  if t > h :
    sc_t += 3
  elif t < h :
    sc_h += 3
  else:
    sc_t += 1
    sc_h += 1
    
print("{} {}".format(sc_t,sc_h))



Measured memory_bytes: 5596
#include<iostream>
#include<vector>
#include<string.h>
using namespace std;

int sch(long i,long Min,long Max){
	if(Min <= i && i <= Max){
		return 1;
	}else{
		cout << i << endl;
		exit(1);
		//return 0;
	}
}

int main(){
	
	int a;
	string s,t,u;
	int i,j,k;
	
	cin >> s;
	a=s.length();
	sch(a,1,100);
	
	j=0;
	for(i=0;i<a;i++){
		//cout << "i , a-1-i =  " << i << " " << a-1-i << endl;
			if(s[i] != s[a-1-i]){
				s[a-1-i]=s[i];
				j++;
				//cout << "j =  " << j << endl;
			}
	}	
	cout << j << endl;
	
	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict

N = int(input())
if not N == 1:
    counter = defaultdict(lambda: 0)
    for e in list(map(int, input().split())):
        counter[e] += 1
    answer = 0
    for i in counter:
        ball_count = counter[i]
        if not i == ball_count:
            if i > ball_count:
                answer += ball_count
            elif i < ball_count:
                answer += ball_count - i
    print(answer)
else:
    if not 1 == int(input()):
        print(1)
    else:
        print(0)


Measured memory_bytes: 18672
import sys
sys.setrecursionlimit(10**6)
n,k,q = map(int, input().split())
readline = sys.stdin.readline
A = [int(input()) for i in range(q)]

score = [k-q for i in range(n)]
for a in A:
    score[a-1] += 1
for s in score:
    if s > 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 56664
#include <bits/stdc++.h>
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 REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
const long long MOD = 1e9 + 7;
///////////////////////////////////////////////
// for template
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
int main() {
    int X; cin >> X;
    if (X >= 30){
        puts("Yes");
    }else{
        puts("No");
    }
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

using ll = long long;
using ull = unsigned long long;
using namespace std;

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

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}


// TODO: write
int main() {
  int n;cin>>n;
  vector<int> a(n);rep(i,n)cin>>a[i];
  a[0]--;
  for(int i = 1;i < n-1;++i){
    if(a[i] != a[i-1])a[i]--;
    if(a[i] > a[i+1]){
      print("No");
      return 0;
    }
  }
  print("Yes");
  return 0;
}

Measured memory_bytes: 3744
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
const ll MOD=1e9+7;
int n;
ll f[55][55],c[55][55];
int main()
{
	scanf("%d",&n);
	c[0][0]=1;
	for(int i=0;i<=n;i++)
	for(int j=0;j<=n;j++)
	{
		if(c[i][j]>=MOD)c[i][j]-=MOD;
		c[i+1][j+1]+=c[i][j];
		c[i+1][j]+=c[i][j];
	}
	f[1][0]=f[1][1]=n;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=i;j++)
		{
			if(f[i][j]==0)continue;
			f[i][j]%=MOD;
			for(int k=max(j,1);i+k<=n;k++)
			{
				if((j+k)&1)continue;
				for(int x=0;x<=k;x++)
				{
					f[i+k][abs((j+k)/2-x)]=(f[i+k][abs((j+k)/2-x)]+f[i][j]*c[n-i][k]%MOD*c[k][x])%MOD;
				}
			}
		}
	}
	printf("%lld\n",f[n][0]);
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(vec) (vec).begin(), (vec).end()
#define SUM(...) accumulate(ALL(__VA_ARGS__),0LL)
#define DSUM(...) accumulate(ALL(__VA_ARGS__),0.0)
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 便利関数
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

// 出力
void print() { std::cout << '\n'; }
template <class T>void print(const T &x) {std::cout << x <<'\n';}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}

const int INF = 2002002002;
const string YES = "Yes";
const string NO = "No";

void solve(long long N){
    string s = to_string(N);
    if (s[0] == s[2]) print(YES);
    else print(NO);
}

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


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n,x,t;
    cin >> n >> x >> t;
    int answer = (n/x)*t;
    if(n%x!=0)answer+=t;
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 3592
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
T[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto A = RD;
	auto B = RD;

	auto ans = max(A, B) - min(A, B);
	if (ans % 2 == 1)
		writeln("IMPOSSIBLE");
	else
		writeln(max(A, B) - ans / 2);
	stdout.flush();
	debug readln();
}


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


typedef struct robot {
        int left;
        int right;
    } Robot;

int checker(const void* a0, const void* b0) {
    const Robot* a = (Robot*)a0;
    const Robot* b = (Robot*)b0;

    if(a->right > b->right) return 1;
    else if(a->right < b->right) return -1;

    return 0;
}


int main() {
    int n;
    cin>>n;
    int mao[n][2];

    for(int i=0; i<n; i++) cin>>mao[i][0]>>mao[i][1];

    Robot chanmao[n];
    for(int i=0; i<n; i++) {
        chanmao[i].left = mao[i][0]-mao[i][1];
        chanmao[i].right = mao[i][0]+mao[i][1];
    }

    // for(int i=0; i<n; i++) {
    //     cout<<chanmao[i].left<<'-'<<chanmao[i].right<<endl;
    // }

    qsort(chanmao, n, sizeof(Robot), checker);

    // for(int i=0; i<n; i++) {
    //     cout<<chanmao[i].left<<" - "<<chanmao[i].right<<endl;
    // }

    int ans = 0;
    int max = 0;

    for(int i=0; i<n; i++) {
        if(ans==0 || chanmao[i].left>=max) {
            ans++;
            max = chanmao[i].right;
        }
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 2556
#include <stdio.h>

int main(){
  int N,M;
  scanf("%d %d",&N,&M);
  int H[100002],d[100002];
  for(int i=1;i<=N;i++){
    scanf("%d",H+i);
    d[i]=1;
  }
  int A,B;
  for(int i=1;i<=M;i++){
    scanf("%d %d",&A,&B);
    if(H[A]<H[B]) d[A]=0;
    else if(H[A]>H[B]) d[B]=0;
    else{
      d[A]=0;
      d[B]=0;
    }
  }
  for(int i=2;i<=N;i++)
    d[1]+=d[i];
  printf("%d\n",d[1]);
  return 0;
}

Measured memory_bytes: 2500