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

// # DEFINES # //
#define ll long long
#define M (ll)1e9+7
#define EPS 1e-9

using namespace std;

int gcd(int a, int b) {
    if(b == 0)
        return a;
    return gcd(b, a % b);
}

int gcdArray(vector<int> arr) {
    int result = arr[0];
    size_t n = arr.size();

    for(int i = 1; i < n; i++) {
        result = gcd(result, arr[i]);
        if(result == 1)
            return 1;
        
    }
    return result;
}

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

    int n;

    cin >> n;

    vector<int> value(n);
    vector<int> cost(n);
    for(int i = 0; i < n; i++)
        cin >> value[i];
    for(int i = 0; i < n; i++)
        cin >> cost[i];
    
    int soma = 0;
    for(int i = 0; i < n; i++)
        if(value[i] > cost[i])
            soma = soma + value[i] - cost[i];
    cout << soma << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD ((int)(1e9+7))
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define float long double

int ans=0,c=0;

int32_t main()
{
	IOS
	int n;cin>>n;
	vector<int>H(n+1),dp(n+1);
	for(int i=1;i<=n;i++)cin>>H[i];
	dp[0]=1e17;
	dp[1]=0;
	for(int i=2;i<=n;i++)
	{
		dp[i]=min(dp[i-1]+abs(H[i]-H[i-1]),dp[i-2]+abs(H[i]-H[i-2]));
	}
	cout<<dp[n]<<endl;
		
}
			
	
	
	
	
	

	

	

	
		


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
const int N=100005;
using namespace std;
ll n,a[4005],s[4][4005],ans;
string t;
int main(){
	cin>>n>>t;
	for(int i=1;i<=n;i++)
	{
		if(t[i-1]=='R') a[i]=0;
		if(t[i-1]=='G') a[i]=1;
		if(t[i-1]=='B') a[i]=2;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<3;j++) s[j][i]=s[j][i-1];
		s[a[i]][i]=s[a[i]][i-1]+1;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			if(a[i]==a[j]) continue;
			ans+=s[3-a[i]-a[j]][n]-s[3-a[i]-a[j]][j];
			if(2*j-i<=n&&a[j*2-i]==3-a[i]-a[j]) ans--;
		}
	}
	cout<<ans;
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
 
#define vi vector<int>
#define tests int t; cin>>t; while(t--)
#define ll long long
#define vll vector<long long>
#define srt(v) sort(v.begin(), v.end())
#define srtg(v) sort(v.begin(), v.end(), greater<int> ())
#define FOR(k, n) for(int k=0; k<n; k++)
#define pb push_back
 
 
using namespace std;
using namespace std::chrono;
 
char nums[10] = { '0','1','2','3','4','5','6','7','8','9' };
char alphsl[26] = { 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z' };
const ll MOD = 1000000007;
char alphs[26] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
 

 
 
void solve() {
 
    int x, n;
    cin>>x>>n;
    vi v(n);
    for(auto& x : v) cin>>x;
    srt(v);
    set<int> s;
    for(int i=0; i<n; i++) s.insert(v[i]);
    int curr=0, p=1;
    while(p==1){
        if(s.count(x-curr)==0){
            cout<<x-curr<<endl;
            return;
        }
        if(s.count(x+curr)==0){
            cout<<x+curr<<endl;
            return;
        }
        curr++;
    }
    
}
   
   

 
 
int main() {
 
    ios_base::sync_with_stdio(false);
    cin.tie(0);
 
        
        solve();
 
 
    return 0;
}

Measured memory_bytes: 3628
n, q = map(int, input().split())
s = input()
start = [0]
count = 0
for i in range(len(s)-1):
    if s[i]+s[i+1] == "AC":
        count += 1

    start.append(count)


for _ in range(q):
    l,r = map(int, input().split())
    print(start[r-1]-start[l-1])


Measured memory_bytes: 6228
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;

#define int long long int
#define pb push_back
// #define M 1000000007
#define inf 10000000000
#define ff first
#define ss second
#define deb(x) cout< #x< " "< x< endl;
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;i<=n;i++)
#define FORR(a,b,c) for(int a= b;a>=c;a--)
#define fa(arrr) for(auto x:arrr)
#define iPair pair<int, pair<int,int>>
#define sz size()
// #define mp make_pair
#define mxm3(a,b,c) max(a, max(b,c))
#define mi3(a,b,c) min(a, min(b,c))
#define mxn 500005
#define PII pair<int,int>
#define all(v) v.begin(), v.end()
#define endl "\n"
// #define N 1000
#define C 4
#define nfs ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
// Ordered Set Tree
// typedef tree<PII, null_type, less<PII>,
//         rb_tree_tag,
//         tree_order_statistics_node_update>
//         oset;
#define db(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << '\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

void computeLPSArray(string pat, int M, int* lps);

int dp[3003][3003][2];

int recurr(int *arr, int i, int j, bool turn) {
    if (i > j) return 0;
    if (dp[i][j][turn] != -1) return dp[i][j][turn];

    if (turn == 1) {
        dp[i][j][turn] = max(arr[i] + recurr(arr, i + 1, j, !turn), arr[j] + recurr(arr, i, j - 1, !turn));
        return dp[i][j][turn];
    }
    else {
        return dp[i][j][turn] = min(recurr(arr, i + 1, j, !turn), recurr(arr, i, j - 1, !turn));
    }
}

void solve() {
    int n;
    cin >> n;
    int arr[n];
    int sum = 0;
    memset(dp, -1, sizeof(dp));
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
        sum += arr[i];
    }
    int scrx = recurr(arr, 0, n - 1, 1);
    int scry = sum - scrx;
    cout << scrx - scry << endl;
}


int32_t main()
{


    nfs;
    int t;
    // facto();
    // cin >> t;
    t = 1;
    while (t--) {
        solve();
    }

    return 0;
}

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

vector<vector<int>> dirs = {{0,1},{0,-1},{1,0},{-1,0}};

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

	int R, C;
	int sr, sc, tr, tc;
	cin >> R >> C;
	cin >> sr >> sc >> tr >> tc;
	vector<string> G(R);
	for (auto& s : G) cin >> s;

	--sr;--sc;--tr;--tc;

	vector<vector<int>> dist(R, vector<int>(C, 1e9));
	set<tuple<int,int,int>> pq;
	dist[sr][sc] = 0;
	pq.emplace(0, sr, sc);
	while (pq.size()) {
		int atd, atr, atc;
		tie(atd, atr, atc) = *pq.begin();
		if (atr == tr && atc == tc) {
			cout << dist[tr][tc] << endl;
			return 0;
		}
		pq.erase(pq.begin());
		// cout << atr << " " << atc << endl;
		for (auto& dir : dirs) {
			int cr = atr+dir[0], cc = atc+dir[1];
			if (cr < 0 || cr >= R || cc < 0 || cc >= C) continue;
			if (G[cr][cc] == '#') continue;
			int cd = atd;
			if (dist[cr][cc] <= cd) continue;
			dist[cr][cc] = cd;
			pq.emplace(cd, cr, cc);
		}
		for (int i = -2; i <= 2; ++i) {
			for (int j = -2; j <= 2; ++j) {
				int cr = atr+i, cc = atc+j;
				if (cr < 0 || cr >= R || cc < 0 || cc >= C) continue;
				if (G[cr][cc] == '#') continue;
				int cd = atd+1;
				if (dist[cr][cc] <= cd) continue;
				dist[cr][cc] = cd;
				pq.emplace(cd, cr, cc);
			}
		}
	}
	cout << -1 << endl;
}

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

int N, M;
vector<vector<bool>> Graph(10, vector<bool>(10, false));

int main() {
    cin >> N >> M;
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        Graph[a][b] = true;
        Graph[b][a] = true;
    }

    ll ans = 0;

    vector<int> v;
    rep(i, N - 1) v.push_back(i + 1);
    do {
        bool ok = true;
        if (!Graph[0][v[0]]) continue;
        rep(i, N - 2) if (!Graph[v[i]][v[i + 1]]) ok = false;
        if (ok) ++ans;
    } while (next_permutation(v.begin(), v.end()));

    cout << ans << endl;
}

Measured memory_bytes: 3604
#include<stdio.h>
int main(void)
{
	int a,b,c,d,e,w,x,z,y;
	scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
	w=a*e;
	z=(e-c)*d;
	if(e<=c){
		x=b;
	}
	else{
		x=z+b;
	}
	if(w<x){
		printf("%d\n",w);
	}
	else{
		printf("%d\n",x);
	}
	return 0;
}


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

int main() {
  int N;
  string S;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> S;
    if(S == "Y"){
      cout << "Four" << endl;
    break;
    }
      if(i == N - 1)
        cout << "Three" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long d,t,s;
  cin>>d>>t>>s;
  if(d%s==0&&d/s<=t){
    cout<<"Yes";
  } else  if(d%s!=0&&d/s<=t-1){
    cout<<"Yes";
  } else {
    cout<<"No"<<endl;
  }
}
    
  
   

Measured memory_bytes: 3672
#include <iostream>
#include <utility>
#include <vector>
#include <cmath>
using namespace std;
typedef vector< pair<double, double> > VP;

vector<int> pw;
const double rt3 = sqrt(3.0);

void rec(VP::iterator l, int n){
  VP::iterator r = l + pw[n];
  if(n > 0){
    double Xd = (*r).first - (*l).first;
    double Yd = (*r).second - (*l).second;
    *(l+pw[n-1]) = make_pair((*l).first + Xd/3, (*l).second + Yd/3);
    *(l+3*pw[n-1]) = make_pair((*l).first + Xd*2/3, (*l).second + Yd*2/3);
    *(l+2*pw[n-1]) =  make_pair((*(l+pw[n-1])).first + (Xd-rt3*Yd)/6, (*(l+pw[n-1])).second + (rt3*Xd+Yd)/6);
    for(int i=0;i<4;i++)
      rec(l+i*pw[n-1], n-1);
  }
}

int main(){
  int n;
  cin >> n;
  for(int i=0;i<=n;i++){
    pw.push_back((int)pow(4.0, i));
  }
  VP p(1 + pw[n]);
  p[0] = make_pair(0.0, 0.0);
  p[pw[n]] = make_pair(100.0, 0.0);
  rec(p.begin(), n);
  for(auto i=p.begin();i<p.end();i++){
    cout << (*i).first << " " << (*i).second << endl;
  }
}



Measured memory_bytes: 3416
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;
const int mod = 1000000007;
int N;
string str[2];
int ans, len;
int vis[100];

int main() {
    long long ans = 1;
    cin >> N;
    cin >> str[0] >> str[1];
    len = str[0].length();
    if(len == 1) {
        cout << 3 << endl;
        return 0;
    }
    for(int i = 0; i < len; i++) {
        int flag = 0;
        if(i == 0) {
            if(str[0][i] == str[0][i + 1]) {
                ans = (ans * 3 * 2) % mod;
                i++;
            }
            else {
                ans = ans * 3 % mod;
            }
        }
        else {
            if(str[0][i] == str[0][i + 1]) {
                if(str[0][i - 1] == str[1][i - 1]) {
                    ans = ans * 2 % mod;
                }
                else {
                    ans = ans * 3 % mod;
                }
            }
            else {
                if(str[0][i - 1] == str[1][i - 1]) {
                    ans = ans * 2 % mod;
                }
                else {
                    ans = ans * 1 % mod;
                }
            }
        }
        //cout << str[0][i] << " " << ans << " " << flag << endl;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/*input
7
500 600
*/
#include<bits/stdc++.h>
using namespace std;

#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test int t;cin>>t;while(t--)
#define X first
#define Y second
#define pb push_back
#define all(s) s.begin(),s.end()

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

const int MOD = 1e9+7;

void solve(){
	int k,a,b;
	cin >> k >> a >> b;
	bool flag = false;
	for(int i=a;i<=b;i++){
		if(i%k==0)
			flag = true;
	}
	if(flag)
		cout << "OK\n";
	else
		cout << "NG\n";
}

int main(){
    FIN;   
    // test
    solve();
}

Measured memory_bytes: 3652
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * Combination of Number Sequences
 */
public class Main {

	static int[][] counts = new int[11][331];

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		for (int i = 1; i < 11; i++) {
			solve(0, i, i, 0);
		}

		StringBuilder sb = new StringBuilder();
		while ((line = br.readLine()) != null && !line.isEmpty()) {
			int n = Integer.parseInt(line.substring(0, line.indexOf(' ')));
			int s = Integer.parseInt(line.substring(line.indexOf(' ') + 1));
			if (s > 330) {
				sb.append(0).append('\n');
			} else {
				sb.append(counts[n][s]).append('\n');
			}
		}
		System.out.print(sb.toString());
	}

	static void solve(int n, int i, int m, int s) {
		if (i == 0) {
			counts[m][s]++;
			return;
		}
		for (int j = 0; j < 10; j++) {
			if ((n & 1 << j) == 0) {
				solve(n | 1 << j, i - 1, m, s + i * j);
			}
		}
	}
}

Measured memory_bytes: 18848
H, W = map(int, input().split())
Sij = []
for _ in range(H):
    Sij.append(input())
result = []
for a in range(H):
    for b in range(W):
        check = []    
        if Sij[a][b] == '#':
            if a-1 >= 0:
                H_up = a - 1
                S_H_up = Sij[H_up][b]
                check.append(S_H_up)
            if a+1 <= H-1:
                H_down = a + 1
                S_H_down = Sij[H_down][b]
                check.append(S_H_down)
            if b-1 >= 0:
                W_right = b - 1
                S_W_right = Sij[a][W_right]
                check.append(S_W_right)
            if b+1 <= W-1: 
                W_left = b + 1
                S_W_left = Sij[a][W_left]
                check.append(S_W_left)
            if '#' in check:
                result.append('good')
            else:
                result.append('bad')
                
if 'bad' in result:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3064
#include<stdio.h>
int main(void)
{
	int i,n,m,a[1000],b[1000],x,y,z;
	z=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		z+=a[i];
	}
	scanf("%d",&m);
	for(i=0;i<m;i++){
		scanf("%d %d",&x,&y);
		b[i]=z-a[x-1]+y;
	}
	for(i=0;i<m;i++){
		printf("%d\n",b[i]);
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a,b,c;cin>>a>>b>>c;
  swap(a,b);swap(a,c);
  printf("%lld %lld %lld\n",a,b,c);
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,fast-math,unroll-loops,inline,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,avx,avx2,abm,mmx,popcnt")

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>

using namespace std;
#define pb push_back
#define int long long

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, a, b;
    cin >> n >> a >> b;
    int d = a - b;
    vector<int> H(n);
    for (int i = 0; i < n; i++) cin >> H[i];
    int left = 0;
    int right = 1e10;
    while (right - left > 1) {
        int mid = (left + right) / 2;
        int cnt = 0;
        for (auto x : H) {
            int y = x - mid * b;
            if (y > 0) {
                cnt += (y + d - 1) / d;
            }
        }
        if (cnt > mid) {
            left = mid;
        } else {
            right = mid;
        }
    }
    cout << left + 1;

}

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

using namespace std;

int main(){
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
#endif     
	int a,b,c,d;
	int f = 1;
	cin >> a >> b >> c >> d;
	while(a > 0 && c > 0){
		if(f == 1) c-=b;
		else a-=d;
		f = 1 - f;
	}
	if(a <= 0) cout << "No";
	else cout << "Yes";
	return 0;
}

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

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	ll n, T; cin >> n >> T;
	ll ttl = 0;

	vector<pair<ll, int>> v;
	v.reserve(2 * n);

	rep(i, 0, n) {
		int t; cin >> t;
		v.push_back({t, 1});
		v.push_back({t + T, -1});
	}

	sort(all(v));

	ll prevon = v[0].first;
	ll acc = 0;

	trav(p, v) {
		if (!acc) {
			acc += p.second;
			prevon = p.first;
		} else {
			acc += p.second;
			if (!acc) {
				ttl += p.first - prevon;
			}
		}
	}

	cout << ttl << endl;
}


Measured memory_bytes: 6528
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] arr = sc.next().toCharArray();
        int left;
        int right;
        if (arr.length % 2 == 0) {
            left = arr.length / 2 - 1;
            right = arr.length / 2;
        } else {
            left = arr.length / 2;
            right = arr.length / 2;
        }
        int count = 0;
        while (left >= 0) {
            if (arr[left] != arr[right]) {
                count++;
            }
            left--;
            right++;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 21844
import java.util.*;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int data[] = new int[3];

    for (int i = 0 ; i < 3 ; i++ ) {
      data[i] = sc.nextInt();
    }

    Arrays.sort(data);

    int x = Math.abs(data[0] - data[1]);
    int y = Math.abs(data[1] - data[2]);
    System.out.println(x + y);
  }
}


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

void Main()
{
    vector<int> a(9);
    for (int i = 0; i < 9; i++)
    {
        cin >> a[i];
    }
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int b;
        cin >> b;
        for (int j = 0; j < 9; j++)
        {
            if(a[j] == b){
                a[j] = 0;
            }
        }
    }
    int bingo = 0;
    bingo += ((a[0] | a[1] | a[2]) == 0);   
    bingo += ((a[3] | a[4] | a[5]) == 0);   
    bingo += ((a[6] | a[7] | a[8]) == 0);
    bingo += ((a[0] | a[3] | a[6]) == 0);   
    bingo += ((a[1] | a[4] | a[7]) == 0);   
    bingo += ((a[2] | a[5] | a[8]) == 0);
    bingo += ((a[0] | a[4] | a[8]) == 0);   
    bingo += ((a[2] | a[4] | a[6]) == 0);
    if (bingo > 0){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 3608
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<map>
#include<numeric>
#include<queue>
#include<functional>
#include<cassert>
#define rep(i,n) for(int i=0;i<n;++i)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define mod 1000000007
using namespace std;
using ll = long long;
using p_i = pair<int, int>;
int main() {
	int N, ans; cin >> N;
	vector<char> S(N);
	vector<int> Wnum(N), Enum(N);
	rep(i, N) {
		cin >> S[i];
		if (i == 0 && S[i] == 'W') Wnum[0] = 1;
		else if (S[i] == 'W')Wnum[i] = Wnum[i - 1] + 1;
		else if (S[i] == 'E')Wnum[i] = Wnum[i - 1];
		Enum[i] = (i + 1) - Wnum[i];
	}
	if (S[0] == 'W')ans = Enum[N - 1];
	else ans = Enum[N - 1] - 1;
	for (int i = 1; i < N - 1; ++i) {
		if (S[i+1] == 'E') ans = min(ans, (int)(Wnum[i - 1] + Enum[N - 1] + 1 - Enum[i + 1]));
		else ans = min(ans, (int)(Wnum[i - 1] + Enum[N - 1] - Enum[i + 1]));
	}
	ans = min(ans, Wnum[N - 1]);
	cout << ans << endl;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d,e,f;
    cin>>a>>b;
    c=a+b;
    d=a-b;
    e=a*b;
    if(c>=d && c>=e){
        cout<<c<<'\n';
    }else if(d>=c && d>=e){
        cout<<d<<'\n';
    }else if(e>=c && e>=d){
        cout<<e<<'\n';
    }
    return(0);
}

Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseArray(x::Array{SubString{String}, 1}) = map(parseInt, x)

function main()
  x, n = readline() |> split |> parseArray
  p = readline() |> split |> parseArray

  a = collect(1:100)
  for pp in p
    a[pp] = -1
  end
  ans = 0
  for i in 0:100
    j = x-i
    if (j >= 1 && a[j] != -1) || j <= 0
      ans = j
      break
    end
    j = x+i
    if (j <= 100 && a[j] != -1) || j > 100
      ans = j
      break
    end
  end
  println(ans)
end

main()


Measured memory_bytes: 168652
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
using namespace std;
const constexpr int INF = 1e9;
//typedef std::pair<std::string,double> P;

#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;
const constexpr ll MOD = 1e9 + 7;

struct Less {
	bool operator()(const pair<int, int>& x, const pair<int, int>& y) const {
		return x.first > y.first;
	}
};
//グラフの隣接リスト
//VI g[200010];
//頂点の入次数を管理
int h[100010];

bool g[101][101];

int N, M;
//int dxy[5] = { -1, 0, 1, 0, -1 };

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

	REP(i, N) REP(j, N) g[i][j] = false;

	REP(i, M) {
		int a, b; cin >> a >> b;
		g[a - 1][b - 1] = true;
		g[b - 1][a - 1] = true;
	}
	vector<int> v;
	for (int i = 0; i < N; ++i) {
		v.push_back(i);
	}
	int cnt = 0;
	bool t[101][101];
	do{
		REP(i, N) REP(j, N) t[i][j] = g[i][j];
        if(v[0]!=0) continue;
		bool ok = true;
		int tmp = v[0];
		for (int i = 1; i < (int)v.size(); ++i) {
			if (t[tmp][v[i]]) {
                t[tmp][v[i]] = false;
                t[v[i]][tmp] = false;
				tmp = v[i];
			}
			else {
				ok = false;
				break;
			}
			
		}
		if (ok) cnt++;
	} while (next_permutation(v.begin(), v.end()));
    
    cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');

process.stdin.on("data",function(chunk){
   var nums=chunk.trim().split("\n");
   function digit (e){
       var a=e.split(" ");
       var wa = parseInt(a[0]) + parseInt(a[1]);
       return  wa.toString().length;
       }
   console.log(nums.map(digit).join("\n"));
   
});

Measured memory_bytes: 15760
#include<iostream>
using namespace std;
int main(){
  double W,H,x,y;
  cin >> W >> H >> x >> y;
  double ans = W * H / 2;
    cout << ans <<endl;
 
  if((W == 2 * x) && (H == 2 * y)){
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }
 
}
 

Measured memory_bytes: 256
cat<<EOF>Source.cpp
#include <iostream>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;

int max(int a,int b){
	return a>b?a:b;
}
int x[100000],y[100000],x_mod_k[100000],x_div_k[100000];
char s[100000][2];
int n,k;

void add(int*cnt,int x,int t){
	if((x_div_k[x]&1)==0){
		if(t==0){
			cnt[0]++;
			cnt[k-x_mod_k[x]]--;
		}
		else{
			cnt[k-x_mod_k[x]]++;
		}
	}
	else{
		if(t==0){
			cnt[k-x_mod_k[x]]++;
		}
		else{
			cnt[0]++;
			cnt[k-x_mod_k[x]]--;
		}
	}
}
int ans[2000];
int main(){
	scanf("%d%d",&n,&k);
	rep(i,n){
		scanf("%d%d%s",&x[i],&y[i],s[i]);
		x_mod_k[i]=y[i]%k;
		x_div_k[i]=y[i]/k;
	}
	int Max=0;
	#pragma omp parallel for schedule(static, 1) num_threads(20)
	rep(i,k){
		int cnt[max(n,k)];
		rep(j,max(n,k))cnt[j]=0;
		rep(j,n){
			if(s[j][0]=='B'){
				if(((x[j]+i)/k)%2==0){
					add(cnt,j,0);
				}
				else{
					add(cnt,j,1);
				}
			}
			else{
				if(((x[j]+i)/k)%2==0){
					add(cnt,j,1);
				}
				else{
					add(cnt,j,0);
				}
			}
		}
		rep(j,k){
			if(j)cnt[j]+=cnt[j-1];
			ans[i]=max(ans[i],max(cnt[j],n-cnt[j]));
		}
	}
	rep(i,k)Max=max(Max,ans[i]);
	cout<<Max<<endl;
}
EOF
g++ -O3 Source.cpp -o Source -fopenmp -std=c++11
./Source

Measured memory_bytes: 32152
import numpy as np
n, a, b = map(int, input().split()) 
numbers = np.arange(1, n+1)
collect = []
for i in numbers:
    if i < 10:
        if (i >= a) and (i <= b):
            collect.append(i)
    else:
        divide_number_str = list(str(i))
        divide_number = list(map(int, divide_number_str))
        sum_num = sum(divide_number)
        if (sum_num >= a) and (sum_num <= b):
            collect.append(i)
        
print(sum(collect))

Measured memory_bytes: 27300
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long MOD = 1e9 + 7;
using namespace std;
typedef long long ll;

map<ll, int> mp;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	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, 0);
	dp[0] = 1;
	if (ok[1]) dp[1] = 1;
	for (int i = 2; i <= n; i++) {
		if (ok[i - 1]) dp[i] += dp[i - 1];
		if (ok[i - 2]) dp[i] += dp[i - 2];
		dp[i] %= MOD;
	}
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
#define pll              pair <long long,long long>
#define pb               push_back
#define ll               long long
#define ff               first
#define ss               second
#define D(x)             cerr<<#x " = "<<(x)<<endl
#define vll              vector <ll>
#define IOS              ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl             '\n'   
using namespace std;
int main()
{
    IOS
 	// freopen("input.txt","r",stdin);
 	// freopen("output.txt","w",stdout);
 	// freopen("error.txt","w",stderr);
 	ll n;
 	cin>>n;
 	map<string,ll>mp;
 	ll sum=0;
 	for(ll i=0;i<n;i++)
 	{
 		string s;
 		ll t;
 		cin>>s>>t;
 		sum+=t;
 		mp[s]+=sum;
 	}	
 	string x;
 	cin>>x;
 	cout<<sum-mp[x]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
using namespace std;

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

int N, W;
int v[100], w[100];
int dp[101][10001];


int main() {
  cin >> N >> W;
  for(int i = 0; i < N; i++) {
    cin >> v[i] >> w[i];
  }

  for(int i = 0; i <= W; i++) {
    dp[0][i] = 0;
  }
  for(int i = 0; i < N; i++) {
    for(int j = 0; j <= W; j++) {
      dp[i+1][j] = dp[i][j];
      if(j >= w[i]) {
        dp[i+1][j] = max(dp[i][j], dp[i+1][j-w[i]] + v[i]);
      }
    }
  }
  
  cout << dp[N][W] << endl; 
  return 0;
}


Measured memory_bytes: 7044
from collections import deque

H, W = map(int, input().split())
Ch, Cw = map(lambda s: int(s) - 1, input().split())
Dh, Dw = map(lambda s: int(s) - 1, input().split())
S = [input() for i in range(H)]

N = [[1000000007] * W for i in range(H)]
visited = [[False] * W for i in range(H)]
q = deque([(Ch, Cw)])
N[Ch][Cw] = 0
while len(q) > 0:
    Ph, Pw = q.popleft()
    if visited[Ph][Pw]:
        continue
    visited[Ph][Pw] = True
    for dh, dw in [(1, 0), (-1, 0), (0, 1), (0, -1)]:
        nh = Ph + dh
        nw = Pw + dw
        if not 0 <= nh < H or not 0 <= nw < W or S[nh][nw] == '#':
            continue
        N[nh][nw] = min(N[nh][nw], N[Ph][Pw])
        if not visited[nh][nw]:
            q.appendleft((nh, nw))
    for dh in range(-2, 3):
        nh = Ph + dh
        if not 0 <= nh < H:
            continue
        for dw in range(-2, 3):
            nw = Pw + dw
            if not 0 <= nw < W or S[nh][nw] == '#':
                continue
            N[nh][nw] = min(N[nh][nw], N[Ph][Pw] + 1)
            if not visited[nh][nw]:
                q.append((nh, nw))

print(N[Dh][Dw] if visited[Dh][Dw] else -1)


Measured memory_bytes: 140556
### global variables

$rlts = []
$brds = []

$ecache = []

### subroutines

def exp_money(pos, money)
  return money if pos >= $brds.length
  return $ecache[pos][money] if ! $ecache[pos][money].nil?

  e, a = $brds[pos]
  npos = pos
  nmoney = money

  case e
  when 1
    npos += a
    return ($ecache[pos][money] = nmoney) if npos >= $brds.length
  when 2
    nmoney += a
  when 3
    nmoney = (nmoney >= a) ? nmoney - a : 0
  end

  msum = 0.0

  for v in $rlts
    msum += exp_money(npos + v, nmoney)
  end

  $ecache[pos][money] = msum / $rlts.length
end

### main

while true
  x, y, z = gets.strip.split(' ').map{|s| s.to_i}
  break if x == 0 && y == 0 && z == 0

  $rlts = gets.strip.split(' ').map{|s| s.to_i}

  $brds = (0...y).map{[0, 0]}
  z.times do
    n, e, a = gets.strip.split(' ').map{|s| s.to_i}
    $brds[n] = [e, a]
  end
  #p $rlts
  #p $brds

  $ecache = (0...y).map{{}}
  #p $ecache

  puts exp_money(0, 0).to_i
end

Measured memory_bytes: 15768
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }
//V,P(大文字)使用不可

const ll INF=1000000000000000000;

signed main(){
    int n;
    cin>>n;
    cout<<n/3<<endl;
}

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

using namespace std;

int main()
{
  int i,j;
  vector <int> v;
  set <int> s;
  
  for(i=1;i<=3;i++){
    cin >> j;
    v.push_back(j);
  }
  
  for(i=0;i<3;i++){
    if(s.find(v[i]) == s.end()) s.insert(v[i]);
  }
  
  if((int)s.size() == 2) cout << "Yes";
  else cout << "No";
  
  return 0;
}

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

using namespace std;

const int MAXN = 3E5 + 100;
typedef long long ll;
int n, m, a[MAXN];
ll p[MAXN];

int main()
{
    ll all = 0;
    scanf("%d%d", &n, &m);
    for(int i=0; i<n; ++i) scanf("%d", a+i);
    for(int i=1; i<n; ++i)
    {
        int l = a[i-1], r = a[i];
        if(l>r) r += m;
        all += r-l;
        if(r-l>1)
        {
            p[l+2] += 1;
            p[r+1] -= (r-(l+2)+1) + 1;
            p[r+2] += (r-(l+2)+1);
        }
    }
    for(int i=1; i<=2*m; ++i) p[i] += p[i-1];
    for(int i=1; i<=2*m; ++i) p[i] += p[i-1];

    ll ans = -1;
    for(int i=1; i<=m; ++i)
    {
        ans = max(ans, p[i]+p[i+m]);
    }
    cout << all - ans << endl;

    return 0;
}
//
//
//E869120
//33 hours ago, # ^ |  Add to favourites ← Rev. 3     Vote: I like it 0 Vote: I do not like it
//In problem E:
//
//Let p[i] be the benefit of favorite brightness is i.
//p[i] can calculate for following method:
//Doing following thing for each i (1≤i < n)
//Add the benefit for change brightness from a[i] to a[i + 1], for each favorite brightness, to p.
//If a[i]=1 and a[i+1]=5, you should do p[3] += 1, p[4] += 2, p[5] += 3. In example of p[4], You can operate 1 -> 4 -> 5 in 2 times. (Initially, you can operate 1 -> 2 -> 3 -> 4 -> 5, 4 times. 2 times shorter.)
//
//So, you should imprementate following query:
//Query (l, r): p[l] += 1, p[l+1] += 2, p[l+2] += 3,... , p[r-1] += (r-l).
//If l > r, you should operate query(l, r+m).
//Calculate the value of all p[i], at last.
//
//This can be imprementate in following method:
//For each query (l, r): p[l] += 1, p[r] -= (r-l+1), p[r+1] += (r-l).
//At last, you should accumlate two times in the array p. The final value of p is after two times accumlate.
//
//This is example of query (3, 6):
//
//
//Let r be the cost if there were no favorite number.
//The answer is r — max(p[1] + p[m+1], p[2] + p[m+2], p[3] + p[m+3], p[4] + p[m+4], ..., p[m] + p[m+m]).
//
//Thank you for reading. Sorry for poor English.


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

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

    int n, q, t, u, v;
    cin >> n >> q;
    dsu d(n);
    rep(i, q) {
        cin >> t >> u >> v;
        if (t==0) {
            d.merge(u, v);
        } else if (d.same(u, v)) {
            cout << 1 << endl;
        } else {
            cout << 0 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3992
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N;
	while(cin>>N) {
		VI A(N);
		map<ll, ll> h;
		REP(i, N) {
			cin>>A[i];
			h[A[i]]++;
		}
		ll base = 0;
		for(auto kv: h) {
			base += kv.SE*(kv.SE-1)/2;
		}
		REP(i, N) {
			ll v = base - h[A[i]]*(h[A[i]]-1)/2 + (h[A[i]]-1)*(h[A[i]]-2)/2;
			cout<<v<<endl;
		}
	}
	
	return 0;
}


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

char tab[21];
ll P[21];

ll calc(int l);

 int main()
 {
	char S[21];
	scanf("%s",S);

	int n=strlen(S);

	ll p,mask,i;
	p=1;

	P[0]=1;
	for(i=1;i<=20;i++)
	{
		P[i]=P[i-1]*10;
	}

	for(i=1;i<n;i++)
	{
		p*=2;
	}

	ll sum=0;
	int tp,z;

	for(mask=0;mask<p;mask++)
	{
		tp=mask;
		z=0;

		for(i=1;i<n;i++)
		{
			tab[z]=S[i-1];
			z++;

			if(tp%2==1)
			{
				tab[z]='+';
				z++;
			}

			tp/=2;
		}
		tab[z]=S[n-1];

		sum+=calc(z);
		//printf("%lld\n",calc(z));
	}

	printf("%lld\n",sum);
 }
//
ll calc(int l)
{

	int i,z;
	z=0;
	ll wn;
	wn=0;

	/*for(i=0;i<=l;i++)
	{
		printf("%c",tab[i]);
	}
	printf("\n");*/

	for(i=l;i>=0;i--)
	{
		if(tab[i]=='+')
		{
			z=0;
		}

		else
		{
			wn+=((int)(tab[i]-'0')*P[z]);
			z++;
		}
	}

	return wn;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

typedef pair<ll,ll> pll;

bool cmp(const pll &a, const pll &b) {
  return (ll)b.first*a.second < (ll)a.first*b.second;
}
int main() {
  ll n;
  cin >> n;
  vector<pll> v;
  ll h0,a0,d0,s0;
  cin >> h0 >> a0 >> d0 >> s0;
  ll hp = h0;
  ll sum = 0;
  REP(i,n) {
    ll h,a,d,s;
    cin >> h >> a >> d >> s;
    ll damage = max(a-d0, 0LL);
    ll attack = max(a0-d, 0LL);
    if (attack == 0) {
      if (damage) {
        cout << -1 << endl;
        return 0;
      }
      continue;
    }
    ll turn = (h + attack - 1) / attack;
    if (s0 < s) hp -= damage;
    v.push_back(pll(damage, turn));
    sum += damage;
  }
  sort(ALL(v), cmp);
  REP(i,v.size()) {
    if (hp < 0) break;
    sum -= v[i].first;
    if (sum > hp/v[i].second) {
      hp = -1;
      break;
    }
    hp -= sum * v[i].second;
    hp -= v[i].first * (v[i].second - 1);
  }
  if (hp <= 0) cout << -1 << endl;
  else cout << h0-hp << endl;
}

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

string a = "DEFGHIJKLMNOPQRSTUVWXYZABC";

int main() {
    string str;
    cin >> str;
    for (auto c : str) cout << (char)('A' + a.find(c));
    cout << endl;

    return 0;
}

Measured memory_bytes: 3168
#include <inttypes.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
    char S[100];
    size_t N;
    intmax_t ans = 0;

    gets(S);

    N = strlen(S);

    for (size_t i = 0; i < (N / 2); i++) {
        if (S[i] != S[N - i - 1]) {
            puts("No");
            return 0;
        }
    }

    for (size_t i = 0; i < ((N - 1) / 2 / 2); i++) {
        if (S[i] != S[(N - 1) / 2 - i - 1]) {
            puts("No");
            return 0;
        }
        if (S[i + ((N + 3) / 2) - 1] != S[N - i - 1]) {
            puts("No");
            return 0;
        }
    }

    puts("Yes");

    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include <string>
using namespace std;
int main()
{
	int a, b, x;
	cin >> a >> b >> x;
	if (a <= x &&x <= a + b){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
package main

import(
    "fmt"
)



func main() {
    var a [5]int
    mi := 10
    sum := 0
    for i:=0; i<5; i++{
        fmt.Scan(&a[i])
        if a[i]%10==0{
            sum+=a[i]
        } else {
            sum+=a[i]+(10-a[i]%10)
            mi = min32(mi,a[i]%10)
        }
    }
    fmt.Println(sum-10+mi)
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}


Measured memory_bytes: 512
#pragma comment(linker, "/STACK:102400000,102400000")
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 1000000007
#define x first
#define y second
#define pi acos(-1.0)
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
//#define dprintf(...) 
#define hash _hash
#define next _next
//#define dprintf(...) fprintf(outFile,__VA_ARGS__)
 
#define FOREACH(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define ull unsigned long long
#define ll long long
#define N 50010
 
template <class T,class U>inline void Max(T &a,U b){if(a<b)a=b;}
template <class T,class U>inline void Min(T &a,U b){if(a>b)a=b;}
 
//FILE* outFile;
inline void add(int &a,int b){a+=b;while(a>=mod)a-=mod;}


int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=ans*(ll)a%mod;
        a=(ll)a*a%mod;b>>=1;
    }
    return ans;
}

int cnt[10010];
char s[20];
int main(){
    int T,i,j,k,ca=0,m,n,K;
    //cout<<setprecision(10)<<fixed;
    scanf("%d%d",&n,&K);
    int v[26]={0};
    rep(i,0,n){
    	scanf("%s",s);
    	v[s[0]-'A']++;
    }
    if(K==1){
    	printf("%d\n",n);return 0;
    }
    rep(i,0,26)if(v[i])cnt[v[i]]++;
    int x=n,ans=0;
    vector<pii>q;
    while(cnt[x]==0)x--;
    while(x){
    	while(x&&cnt[x]==0)x--;
    	if(x==0)break;
    	k=K;int y=x;
    	while(k&&y){
    		j=min(k,cnt[y]);
    		k-=j;cnt[y]-=j;if(j)q.pb({j,y-1});
    		y--;
    	}
    	FOREACH(it,q)cnt[it->y]+=it->x;q.clear();
    	if(k==0)ans++;
    }
    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#define FOR(n) for(int i=0;i<n;i++)
int main(void){
    int sx,sy,tx,ty;
    scanf("%d %d %d %d",&sx,&sy,&tx,&ty);
    int dx=tx-sx;
    int dy=ty-sy;
    FOR(dx) putchar('R');
    FOR(dy) putchar('U');
    FOR(dx) putchar('L');
    FOR(dy) putchar('D');
    putchar('D');
    FOR(dx+1) putchar('R');
    FOR(dy+1) putchar('U');
    putchar('L');
    putchar('U');
    FOR(dx+1) putchar('L');
    FOR(dy+1) putchar('D');
    putchar('R');
    return 0;
}

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

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

int main() {
    string s; cin >> s;
    
    int v[26] = {0};
    rep(i,s.size()){
        v[s[i] - 'a']++;
    }
    rep(i,26){
        if(v[i] == 0){
            char c = 'a' + i;
            cout << c << endl;
            return 0;
        }
    }
    cout << "None" << endl;
}

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

int main() {
	int a[3][3];
	for (int i = 0; i < 3; i++) for(int j = 0; j < 3; j++) {
	    std::cin >> a[i][j];
	}
	
	int n;
	std::cin >> n;
	
	int c[3][3];
	for (int i = 0; i < 3; i++) for(int j = 0; j < 3; j++) {
	    c[i][j] = 0;
	}
	
	int b[n];
	for (int i = 0; i < n; i++) {
	    std::cin >> b[i];
        
        for (int j = 0; j < 3; j++) for(int k = 0; k < 3; k++) {
	        if(a[j][k]==b[i]) c[j][k] = 1;
	    }
	    
	}
	
	bool isBingo = false;
	for (int i = 0; i < 3; i++) {
	    if(c[i][0] == 1 and c[i][1] == 1 and c[i][2] == 1) isBingo = true;
	    //横
	}
	for (int i = 0; i < 3; i++) {
	    if(c[0][i] == 1 and c[1][i] == 1 and c[2][i] == 1) isBingo = true;
	    //縦
	}
	if(c[0][0] == 1 and c[1][1] == 1 and c[2][2] == 1) isBingo = true;
	if(c[0][2] == 1 and c[1][1] == 1 and c[2][0] == 1) isBingo = true;
	//斜め
	
	if(isBingo==true) std::cout << "Yes" << std::endl;
	else std::cout << "No" << std::endl;
	
	return 0;
}

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


int c1, c2,c3,c4,c5,c6,c7,c8,c9;
int sum_1,sum_2,sum_3;
int main(){
  cin>>c1>>c2>>c3;
  cin>>c4>>c5>>c6;
  cin>>c7>>c8>>c9;
  sum_1 = c1+c5+c9;
  sum_2 = c2+c6+c7;
  sum_3 = c3+c4+c8;
  if((sum_1 == sum_2)&&(sum_2 == sum_3)&&(sum_3 == sum_1)){
    cout<< "Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 3552
#include<bits/stdc++.h>
#define fo(i, x, y) for(int i = x, B = y; i <= B; i ++)
#define ff(i, x, y) for(int i = x, B = y; i <  B; i ++)
#define fd(i, x, y) for(int i = x, B = y; i >= B; i --)
#define ll long long
#define pp printf
#define hh pp("\n")
using namespace std;

const int N = 1e5 + 5;

int n, m, x, y;
int a[N], b[N];
int f[N], d[N], nd[N];
int F(int x) {
	return f[x] == x ? x : (f[x] = F(f[x]));
}

#define V vector<int>
#define pb push_back
#define si size()
V e[N];

int cmp(int x, int y) {
	return a[x] < a[y];
}

ll sumb[N], g[N];

int main() {
	scanf("%d %d", &n, &m);
	fo(i, 1, n) scanf("%d %d", &a[i], &b[i]), a[i] = max(0, a[i] - b[i]);
	fo(i, 1, m) {
		scanf("%d %d", &x, &y);
		e[x].pb(y); e[y].pb(x);
	}
	fo(i, 1, n) f[i] = i, sumb[i] = b[i], g[i] = a[i];
	fo(i, 1, n) d[i] = i;
	sort(d + 1, d + n + 1, cmp);
	fo(i, 1, n) nd[d[i]] = i;
	fo(i, 1, n) {
		int x = d[i];
		ff(j, 0, e[x].si) {
			int y = e[x][j];
			if(nd[y] > nd[x]) continue;
			if(F(x) != F(y)) {
				int u = f[x], v = f[y];
				f[v] = u;
				sumb[u] += sumb[v];
				g[u] = min(g[u], max(g[v], a[u] - sumb[v]));
			} 
		}
	}
	int x = F(d[n]);
	pp("%lld\n", g[x] + sumb[x]);
}


Measured memory_bytes: 9468
import math


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


n = int(input())
divisors = make_divisors(n)

ans = 10**13
for i in range(math.ceil(len(divisors)/2)):
    #print(divisors[i], divisors[len(divisors)-i-1])
    #print(divisors[i]+divisors[len(divisors)-i-1])
    ans = min(ans, divisors[i]+divisors[len(divisors)-i-1]-2)
print(ans)


Measured memory_bytes: 3288