akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    vector<ll> s(n);
    rep(i, n) {
        if (i == 0) {
            s[i] = a[i];
            continue;
        }
        s[i] = s[i - 1] + a[i];
    }
    vector<ll> sc(n, 0);
    rep(i, n) {
        if (i == 0) {
            sc[i] = a[i] - 1;
            continue;
        }
        sc[i] = sc[i - 1] + (a[i] - 1);
    }
    ll ans = LONG_LONG_MAX;
    rep(i, n - 1) {
        ll ls = s[i];
        ll rs = s[n - 1] - s[i];
        ll lsc = sc[i];
        ll rsc = sc[n - 1] - sc[i];
        ll plus = LONG_LONG_MAX, minus = LONG_LONG_MAX;
        plus = abs(ls - rs);
        // if (ls > rs) {
        //     if (lsc >= plus) {
        //         minus = ls - rs;
        //     }
        // }
        ans = min(ans, plus);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4992
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program {
    static void Main(string[] args) {
        //入力
        int N = int.Parse(Console.ReadLine());

        //string s = Console.ReadLine();

        //List<int> list = new List<int> { };
        //for (int i = 0; i < N; i++) {
        //    list.Add(int.Parse(s.Split(' ')[i]));
        //}

        List<int> list = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();

        //リストのソート
        list.Sort();

        //B - Aの値
        int ans = 0;
        //検証
        ans = list[N / 2] - list[(N / 2) - 1];

        //出力
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 19680
import java.util.*

fun main(args: Array<String>) {
  val (a, b) = readLine()!!.split(' ').map(String::toInt)
  for (n in 1..1000) {
    val x = Math.floor(n * 0.08).toInt()
    if (x != a) continue
    val y = Math.floor(n * 0.10).toInt()
    if (y != b) continue
    println(n)
    return
  }
  println(-1)
}


Measured memory_bytes: 38464
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		
		while (input.hasNext()) {
			int N = input.nextInt();
			int M = input.nextInt();
			PriorityQueue<Integer> pq = new PriorityQueue<Integer>(Collections.reverseOrder());
			
			for (int i = 0; i < N; ++i) {
				pq.add(input.nextInt());
			}
			
			while (M-- > 0) {
				int a = pq.poll();
				pq.add(a >> 1);
			}
			
			long cost = 0;
			while (pq.isEmpty() == false) {
				cost += pq.poll();
			}
			
			System.out.println(cost);
		}

	}

}


Measured memory_bytes: 51428
N, K =map(int, input().split())
a = list(map(int, input().split()))
cumsum = [0]
for i in range(N):
    cumsum.append( a[i] + cumsum[i] )
#print("{}".format(cumsum))

beauty = []
for l in range(N + 1):
    for r in range(l + 1, N + 1):
        beauty.append(cumsum[r] - cumsum[l])
beauty.sort()
#print("{}".format(beauty))

max = 0
for shift in range(60, -1, -1):
    mask = 1 << shift
    count = 0
#    print("{} {}".format(shift,beauty))
    for i in range(len(beauty)-1,-1,-1):
#        print("{} {}".format(i,beauty[i]))
        if (beauty[i] & mask) == 0:
            continue
        count+=1
    if count >= K:
#        print("{} {} {}".format(shift,max,mask))
        max |= mask;
#        print("{} {} {}".format(shift,max,mask))
        tmp = []
        for i in range(len(beauty) - 1, -1, -1):
            if ((beauty[i] & mask) == 0):
                continue
            tmp.append(beauty[i])
        beauty.clear()
        for i in range(len(tmp)):
            beauty.append(tmp[i])
print(max)


Measured memory_bytes: 24812
import sys


sys.setrecursionlimit(10 ** 6)


def input():
    return sys.stdin.readline().strip()


def solve():
    def dfs(v):
        for nv in g[v]:
            if visited[nv]:
                continue
            visited[nv] = True
            counter[nv] += counter[v]
            dfs(nv)

    N, Q = map(int, input().split())
    g = [set() for _ in range(N)]
    for _ in range(N - 1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        g[a].add(b)
        g[b].add(a)
    counter = [0] * N
    for _ in range(Q):
        p, x = map(int, input().split())
        p -= 1
        counter[p] += x

    visited = [False] * N
    visited[0] = True
    dfs(0)
    return counter


print(" ".join(map(str, solve())))


Measured memory_bytes: 296768
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define MIN(a,b) ((a) <= (b) ? (a) : (b))
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort( ALL(v) )

using namespace std;
using ll = long long;
using P = pair<int,int>;

int main()
{
    ll x;
    cin>>x;
    ll ans = 0 ;


    ll first = x/500;
    ll second = x/5;
    ans += 1000*(first);
    x-=500*(first);
    ans+= 5*(x/5);

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


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

using namespace std;

typedef long long ll;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);
#define MOD 1000000007
#define all(a) (a).begin(), (a).end()
#define testcase ll tc;cin>>tc;while(tc--)
#define inp(a) vector<ll> a(n); for(ll i=0;i<n;i++) cin>>a[i];
#define out(a) for(ll i=0;i<n;i++) cout<<a[i]<<" ";
#define OF(i,n) for(ll i=n-1;i>=0;i--)
#define FO(i,n) for(ll i=0;i<n;i++)
#define FOR(i,l,n) for(ll i=l;i<n;i++)
#define ca cout<<ans;en;
#define cint ll temp;cin>>temp;
#define en cout<<"\n";
#define pb push_back
#define mp make_pair
#define S second
#define F first
#define pi 3.14159265
#include <fstream>

// void filereadwrite(){
// 	std::ifstream infile("input.txt");
// 	if (!infile.is_open()) {
// 	    return 0;
// 	}
// 	int n;
// 	infile>>n;
// 	int a[n];
// 	int i=0;
// 	while(infile >>a[i] && i<n)
// 		i++;
// 	sort(a,a+n);
// 	freopen("output.txt", "w", stdout);
// }

int main(){
	fastIO;
	int n;
	cin>>n;
	vector<int> v(4,0);
	FO(i,n){
		string s;
		cin>>s;
		if(s=="AC")
			v[0]++;
		if(s=="WA")
			v[1]++;
		if(s=="TLE")
			v[2]++;
		if(s=="RE")
			v[3]++;
	}
	cout<<"AC x "<<v[0]<<endl;
	cout<<"WA x "<<v[1]<<endl;
	cout<<"TLE x "<<v[2]<<endl;
	cout<<"RE x "<<v[3]<<endl;
}

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
struct Edge{ll from, to, cost;};
struct node{ll cost, to;
  bool friend operator>(node a, node b){
    return a.cost>b.cost;
  }
};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N, K;
  cin >> N >> K;
  llvec q(N);
  rep(i, N)cin >> q[i];
  ll ans = 0;
  for(ll pull = 1;pull<=min(K, N);pull++){
    for(ll a = 1;a<=pull;a++){
      llvec que;
      ll b = pull - a;
      rep(i, a){
        que.push_back(q[i]);
      }
      rep(j, b){
        que.push_back(q[N-1-j]);
      }

      ll tmp = accumulate(ALL(que), 0LL);
      if(K-pull>0){
        sort(ALL(que));
        rep(i, K-pull){
          if(que[i]>0){break;}
          else{tmp -=que[i];}
        }
      }
      //cout << pull << " " << a << " "<< tmp << endl;
        ans = max(ans, tmp);
    }
  }

  cout << ans;
  return 0;
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define intarr(arr, n)  ll arr[n];  for (ll i = 0; i < n; i++)  cin >> arr[i]
#define inpvec(vec,n) for(ll i=0;i<n;i++){ll var;cin>>var;vec.push_back(var);}
#define ff first
#define ss second
#define pb push_back
#define mkp make_pair
#define vec vector<ll>
#define pi pair<ll,ll>
#define changeline cout<<endl
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,a,b) for(ll i=a;i>=b;i--)
#define all(v) v.begin(),v.end()
#define mod2 998244353
#define NO cout << "NO" <<endl
#define YES cout << "YES" <<endl
#define mem(arr,val) memset(arr,val,sizeof(arr));
const ll mod=1e9+7;
#define piii 3.14159265358979323846264338327950
#define print(a, n, m)     for (ll i = n; i < m; i++) {  cout << a[i] << " "; }  cout << endl
#define con continue

bool prime(ll n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
bool isPerfectSquare(ll x) {   
  long double sr = sqrt(x); 
  return ((sr - floor(sr)) == 0); 
} 
bool subsequence_checker(string str1, string str2, ll m, ll n) 
{ 
    if (m == 0) return true; 
    if (n == 0) return false; 
    if (str1[m-1] == str2[n-1]) 
        return subsequence_checker(str1, str2, m-1, n-1); 
    return subsequence_checker(str1, str2, m, n-1); 
}
bool cmp(const pair<int,int> &a,  const pair<int,int> &b) 
{ 
    if(a.ff == b.ff)
        return a.ss < b.ss;
    return (a.ff > b.ff); 
}
//////////////////////////////////////////////////// Lets Do It ////////////////////////////////////////////////////////
int gcd(int p, int q){
if(p % q == 0)return q;
return gcd(q, p % q);
}

void solve()
{

    string s;

    cin>>s;

    ll n = s.length();

    ll ans =0 ;
    for(ll i = 0 ; i<n; i++)
    {
        ll d = s[i] - '0';
        ans+=d;
    }     

    if(ans%9==0)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }   

    return;
}
 
int main()
{
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
    IOS;
    ll t;
    //cin>>t;
    t=1;

    while(t--){
        solve();
        cout<<endl;
    }

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
} 



Measured memory_bytes: 3804
#pragma region
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define VPII vector<PII>
#define VPLL vector<PLL>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
#pragma endregion
//-------------------
int n, m;
const size_t MX = 55;
vector<bool> visited(MX,false);
bool a[MX][MX];

void dfs(int start) {
    visited[start] = true;
    FOR(i, 0, n-1) {
        if(a[start][i] and !visited[i]) dfs(i);
    }
}
vector<pair<int, int>> v;

int main(){
    cin.tie(0); ios::sync_with_stdio(false); //cout << fixed << setprecision(15);
    cin >> n >> m;
    FOR(i,1,m) {
        int A,B; cin >> A >> B; --A;--B;
        a[A][B] = true;
        a[B][A] = true;
        v.emplace_back(A,B);
    }

    int cnt = 0;

    FOR(i,0,m-1) {
        auto &[A, B] = v[i];
        a[A][B] = false; a[B][A] = false;

        fill(ALL(visited), false);
        dfs(0);
        FOR(i,0,n-1) {
            if(!visited[i]) {
                cnt++;
                break;
            }
        }
        a[A][B] = true; a[B][A] = true;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3568
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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; }

#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  cin>>n;
  
  ll A[n];
  ll x;
  rep(i,n){
    cin>>x;
    if(x==0){
      cout<<0<<endl;
      return 0;
    }
    A[i]=x;
  }
  
  ll sum=A[0];
  for(int i=1;i<n;i++){
    if(A[i]>1000000000000000000/sum){
      cout<<-1<<endl;
      return 0;
    }
    sum=sum*A[i];
  }
  
  cout<<sum<<endl;

  
  return 0;
}

Measured memory_bytes: 4412
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()


def pf(s):
    print(s, flush=True)

def main():
    a,b = LI()
    if a <= b:
        return 'Impossible'

    l = []
    for i in range(a+b):
        if not l:
            l.append(i)
            continue
        pf('? {} {}'.format(i,l[-1]))
        if S() == 'Y':
            l.append(i)
        else:
            l = l[:-1]

    r = []
    ai = l[0]
    for i in range(a+b):
        if i == ai:
            r.append('1')
            continue
        pf('? {} {}'.format(ai,i))
        if S() == 'Y':
            r.append('1')
        else:
            r.append('0')

    return '! {}'.format(''.join(r))


print(main(), flush=True)


Measured memory_bytes: 6008
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define Cout(s) cout << s << endl;
using ll = long long;
using P = pair<int, int>;

const ll INF = 1ll << 60;
ll MOD = 1e9 + 7;

int main()
{

    int a, b;
    cin >> a >> b;
    int ans = 0;
    if (a > b)
    {
        ans = a + a - 1;
    }
    else if (b > a)
    {
        ans = b + b - 1;
    }
    else
    {
        ans = a + b;
    }
    Cout(ans);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <math.h>

#undef DEBUG

int
fact(int n)
{
    int i;
    int r=1;
    for (i=1; i<n+1; i++)
        r *= i;
    return r;
}

void
solver(int n, int *x, int *y)
{
    int i, j, k;
    int l[8], o[8], p[9];
    int route[8];
    int m = fact(n);
    double d;

    for (i=0; i<n; i++) {
        l[i] = n - i;
        o[i] = 0;
    }
    d = 0;
    for (i=0; i<m; i++) {
        for(j=0; j<n; j++) {
            p[j] = j;
        }
        p[j] = -1;
        for(j=0; j<n; j++) {
            route[j] = p[o[j]];
            bcopy(p+o[j]+1, p+o[j], (8-o[j])*sizeof(int));
        }
        for(j=0; j<n-1; j++) {
            d += sqrt((x[route[j+1]]-x[route[j]])*(x[route[j+1]]-x[route[j]])+(y[route[j+1]]-y[route[j]])*(y[route[j+1]]-y[route[j]]));
        }
        o[0]++;
        for (j=0; j<n; j++) {
            if (o[j]>=l[j]) {
                o[j+1]++;
                o[j]=0;
            }
        }
    }
    d /= m;
    printf("%8.20g\n", d);

    return;
}

int
main(int argc, char *argv[])
{
    int i;
    int N;
    int X[8], Y[8];

#ifdef DEBUG
#else
    scanf("%d", &N);
    for (i=0; i<N; i++) {
        scanf("%d %d", X+i, Y+i);
    }
#endif
    solver(N, X, Y);

    return 0;
}

Measured memory_bytes: 128
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W;
typedef long long ll;
typedef pair<ll, ll> Pa;

vector<int> d;
bool iroha_check(int n) {
	string s = to_string(n);
	rep(i, s.size()) {
		rep(j, d.size()) {
			if ((s[i] - '0') == d[j]) return false;
		}
	}
	return true;
}

int main() {
	cin >> N >> K;
	rep(i, K) {
		cin >> A;
		d.push_back(A);
	}
	ll ans = N;
	while (!iroha_check(ans)) {
		ans++;
	}
	cout << ans;
}


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

typedef long long ll;
ll MOD = 1000000007;

int main() {
    int n, m;
    cin >> n >> m;
    vector <int>  ok(n + 1, 1);
    
    for (int i = 0; i < m; i++) {
        int a;
        cin >> a;
        ok[a] = 0;
    }
    
    vector <ll> dp(n + 2);
    dp[0] = 1;
    for (int i = 0; i < n; i++) {
        if (!ok[i]) dp[i] = 0;
        (dp[i + 1] += dp[i]) %= MOD;
        (dp[i + 2] += dp[i]) %= MOD;
    }
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++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(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n;
    cin >> n;
    ll sum = 0, cnt = 0;
    REP(i,n){
        ll d = lin(), c = lin();
        cnt += c;
        sum += d * c;
    }
    ll ans = (sum - 1) / 9 + cnt - 1;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>
#include <queue>
#define _USE_MATH_DEFINES
#include <math.h>

typedef long long ll;

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(x) : x;
}

//最大・最小
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;
}

//xのn乗
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//xの逆元
ll mod_inv(ll x, ll mod) {//O(log(mod))
    return mod_pow(x, mod - 2, mod);
}

//nCr
ll ncr(ll n, ll r, ll mod){
	ll res=1;
	ll num=1,den=1;
	for(ll i=n;i>=n-r+1;i--){
		(den*=i)%=mod;
	}
	for(ll i=1;i<=r;i++){
		(num*=i)%=mod;
	}
	
	res=den*mod_inv(num,mod);

	return res%mod;
}


//二分探索
bool isOk(ll index, ll key,vector<ll> &a){
	
	if(a[index]>key){
		return true;
	}
	
	return false;
}

ll bin_search(ll key, vector<ll> &a){
	
	ll l=-1;
	ll r=a.size();

	while(abs(r-l)>1){
		ll mid = (l+r)/2;
		if(isOk(mid, key, a)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	return r;
}

/*
//深さ優先探索
void dfs(vector<vector<ll>> &gra,vector<bool> &seen, ll v){

	seen[v]=true;

	for(auto next : gra[v]){
		if(seen[next]){
			continue;
		}

		dfs(gra,seen,next);
	}
	
}
*/
const ll MOD=1000000007;

void solve(){
	ll a,b,c,k;
	cin>>a>>b>>c>>k;

	if(a>=k){
		cout<<k<<endl;
	}
	else if((a+b)>=k){
		cout<<a<<endl;
	}
	else{
		cout<<a-(k-(a+b))<<endl;
	}

}


int main(){
	
	solve();
	
    return 0;
}


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

int n;
long long t1, t2;

long long gcd(long long a, long long b){
	while(a!=0){
		if(b>a){
			long long temp = a;
			a = b;
			b = temp;
		}
		a %= b;
	}
	return b;
}
		
long long lcm(long long p, long long q){
	long long g = gcd(p, q);
	p /= g;
	return p*q;
}

int main(void){
	cin >> n;
	cin >> t1;
	for(int i=1; i<n; i++){
		cin >> t2;
		t1 = lcm(t1, t2);
	}
	cout << t1 << endl;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <limits>
#include <map>
#include <vector>
#include <queue> 
#define P pair<int ,int >
#define pb push_back
#define LL long long
#define ft first
#define sd second
#define mp(x,y) make_pair(x,y)
#define db double
#define int LL
using namespace std;
const int N   = 1e5+233;
//const int mod = ;
const int INF =numeric_limits<int >::max();

#define rep(i,x,y) for (int i=x;i<=y;++i)
void read(int &x)
{
	x=0;
	char ch=getchar();
	int f=1;
	while (!isdigit(ch)) (ch=='-'?f=-1:0),ch=getchar();
	while ( isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	x*=f;
}

void write(int x)
{
	if (x<0) putchar('-'),x=-x;
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
int gcd(int a,int b)
{
	return b ?gcd( b,a%b) :a;
}

int n,m;
char s[N],t[N];
signed main()
{
	read(n);read(m);
	scanf("%s%s",s,t);
	int tmp=gcd(n,m);
	/*if (s[1]!=t[1])
	{
		printf("-1");
		return 0;
	}*/
	if (tmp==n)
	{
		int ok=1;
		rep(i,0,m-1) if (s[i]!=t[i%n]) ok=0;
		printf("%lld",ok?m:-1);
		return 0;
	}
	if (tmp==m)
	{
		int ok=1;
		rep(i,0,n-1) if (s[i%m]!=t[i]) ok=0;
		printf("%lld",ok?n:-1);
		return 0;
	}
	int x=n/tmp,y=m/tmp;
	int ok=1;
	for (int i=0,j=0;i<n&&j<m&&ok;i+=x,j+=y) 
	  if (s[i]!=t[j]) 
	    ok=0;
	printf("%lld",ok? n*m/tmp :-1);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

    int ans = numeric_limits<int>::max();
    for (int i = 0; i < S.size()-2; ++i) {
        string tmp = S;
        tmp = tmp.substr(i, 3);

        int num = stoi(tmp);
        ans = min(ans, abs(num - 753));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define ld          long double

const ll mod=1e9+7;

void solve()  
{
	ll n, k; cin>>n>>k; 
	ll a[n];
	for(ll i=0; i<n; i++) cin>>a[i];
	if(n==k) { cout<<1<<endl; return; }
	vector<ll>go(n, 0);
	ll ans=0;
	for(ll i=1; i<n; i++)
	{
		if(a[i]>a[i-1]) go[i]=go[i-1]+1;
		else { go[i]=0; }
		if(go[i] >= k-1) ans=1;
	}
	set<ll>v;
	for(ll i=0; i<k; i++) v.insert(a[i]);
	if(go[k-1]!=k-1) ans++;
	for(ll i=k; i<n; i++)
	{
		v.insert(a[i]);
		ll st=*v.begin();
		ll en=*v.rbegin();
		if(st != a[i-k] or en != a[i])
		{
			if(go[i] < k-1) ans++;
		}
		v.erase(a[i-k]);
	}
	cout<<ans<<endl;
}
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);  
	ll T = 1;
	//cin>>T; 
	while(T--)
	    solve();
	return 0;
}


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

int main(){
    string S; cin>>S;
    if(S[0]==S[1]||S[1]==S[2]||S[2]==S[3]){
        cout<<"Bad"<<endl;
        return 0;
    }
    cout<<"Good"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
using namespace std;
int main(){
  int N,key,temp;
  cin >> N;
  temp = N;
  key = 0;
  while(N>0){
      key += N%10;
      N = N/10;
  }
  if(temp%key == 0)
    cout << "Yes" << "\n";
  else 
    cout << "No" << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

//#define int long long

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

class SquareDivision{
    private:
        const int BUCKET_SIZE=256;
        int N, B;
        vector<int> data, bucket_sum;

    public:
        void prepare(int n){
            B=(n+BUCKET_SIZE-1)/BUCKET_SIZE;
            N=B*BUCKET_SIZE;
            data.assign(N, 0);
            bucket_sum.assign(B, 0);
        }

        void add(int x, int y){
            int k=x/BUCKET_SIZE;
            data[x]+=y;
            int sum=0;
            for(int i=k*BUCKET_SIZE; i<(k+1)*BUCKET_SIZE; i++){
                sum+=data[i];
            }
            bucket_sum[k]=sum;
        }

        // [x, y)
        int getsum(int x, int y){
            int sum=0;
            for(int i=0; i<B; i++){
                int l=i*BUCKET_SIZE, r=(i+1)*BUCKET_SIZE;
                
                if(r<=x || y<=l) continue;

                if(x<=l && r<=y) sum+=bucket_sum[i];
                else{
                    for(int j=max(x, l); j<min(y, r); j++){
                        sum+=data[j];
                    }
                }
            }
            return sum;
        }
};

signed main(){
    int n, q; cin>>n>>q;
    SquareDivision ans;
    ans.prepare(n);

    while(q--){
        int c, x, y; cin>>c>>x>>y;
        if(c==0){
            ans.add(x, y);
        }
        else{
            cout << ans.getsum(x, y+1) << endl;
        }
    }
}


Measured memory_bytes: 3084
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set>
using namespace std;
typedef unsigned long long LL;
set<LL> ans;
LL S(LL x)
{
	LL ret=0;
	while(x)
	{
		ret+=x%10LL;
		x/=10LL;
	}
	return ret;
}
int main()
{
	LL k;
	scanf("%lld",&k);
	LL bas=1LL;
	for(LL i=1;i<=9;i++)
		ans.insert(i);
	for(LL len=2;len<=16;len++)
	{
		bas*=10LL;
		LL val9=0;
		for(LL num9=0;num9<len;num9++)
		{
			LL nownum=bas+val9;
			if(1.0*nownum/S(nownum)<=1.0*(nownum+1LL+val9)/S(nownum+1LL+val9))
			{
				for(LL i=bas/(val9+1LL);i<10LL*bas/(val9+1LL);i+=1LL)
				{
					LL num2=i*(val9+1LL)+val9;
					if(1.0*num2/S(num2)<=1.0*(num2+1LL+val9)/S(num2+1LL+val9))
					ans.insert(i*(val9+1LL)+val9);
					if(ans.size()>=k)
						break;
				}
			}
			if(ans.size()>=k)
				break;
			val9=val9*10LL+9LL;
		}
		if(ans.size()>=k)
			break;
		ans.insert(val9);
	}
	set<LL>::iterator it;
	LL cnt=0;
	for(it=ans.begin();cnt<k;it++)
	{
		printf("%lld\n",*it);
		cnt++;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include<string.h>

int main() {
   char s[20], t[20];
   
   scanf("%s %s", s, t);

   int i;
   for(i = 0; s[i] != '\0'; i++){
       if(s[i] != t[i]){
          printf("No\n");
          return 0;
       }
   }
   if(t[i+1] != '\0'){
      printf("No\n");
   }else{
      printf("Yes\n");
   }
   return 0;
}


Measured memory_bytes: 1620
import java.util.Scanner;
 
class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] a = new int[n];
        for(int i = 0; i < n; i++){
            int input = scanner.nextInt();
            a[i] = input;
        }
        for (int b = n-1; b >= 0; b--) {
            System.out.print(a[b]);
            if (b != 0) {
                System.out.print(" ");
            }
        }
        System.out.println("");
    }
}



Measured memory_bytes: 26344
n = gets.to_i
a = []
n.times do |i|
  a << gets.to_i
end

b = a.sort_by{|x| x}
if b[-1] == b[-2]
  n.times do
    p b[-1]
  end
else
  a.each do |x|
    if x != b[-1]
      p b[-1]
    else
      p b[-2]
    end
  end
end

Measured memory_bytes: 11824
import collections
N = int(input())
s_dict = {}
count = 0
for i in range(N):
    s=sorted(input())
    s = ''.join(s)
    if s in s_dict:
        s_dict[s] += 1
        count += s_dict[s]
    else:
        s_dict[s] = 0
print(count)

Measured memory_bytes: 18236
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

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; }

template<class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
    t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v){
    for (auto &e : t) fill(e, v);
}

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }

#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



int H, W;
vector<string> fi;

int main() {
	while (cin >> H >> W) {
		fi.resize(H);
		for (int i = 0; i < H; ++i) cin >> fi[i];

		vector<vector<int> > left(H, vector<int>(W, 0));
		auto right = left;
		auto up = left;
		auto down = left;
		for (int i = 0; i < H; ++i) {
			int cur = 0;
			for (int j = 0; j < W; ++j) {
				if (fi[i][j] == '#') cur = 0;
				else ++cur;
				left[i][j] = cur;
			}
		}
		for (int i = 0; i < H; ++i) {
			int cur = 0;
			for (int j = W-1; j >= 0; --j) {
				if (fi[i][j] == '#') cur = 0;
				else ++cur;
				right[i][j] = cur;
			}
		}
		for (int j = 0; j < W; ++j) {
			int cur = 0;
			for (int i = 0; i < H; ++i) {
				if (fi[i][j] == '#') cur = 0;
				else ++cur;
				up[i][j] = cur;
			}
		}
		for (int j = 0; j < W; ++j) {
			int cur = 0;
			for (int i = H-1; i >= 0; --i) {
				if (fi[i][j] == '#') cur = 0;
				else ++cur;
				down[i][j] = cur;
			}
		}

		int res = 0;
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				if (fi[i][j] == '#') continue;
				chmax(res, left[i][j] + right[i][j] + up[i][j] + down[i][j] - 3);
			}
		}
		cout << res << endl;
	}
}

Measured memory_bytes: 67200
import * as fs from "fs";

const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
const n = +input[0];
const s = input[1];

const rsw_r = { R: new Array(n + 1), G: new Array(n + 1), B: new Array(n + 1) };
rsw_r["R"][n] = rsw_r["G"][n] = rsw_r["B"][n] = 0;
for (let i = n - 1; i >= 0; i--) {
	rsw_r["R"][i] = rsw_r["R"][i + 1];
	rsw_r["G"][i] = rsw_r["G"][i + 1];
	rsw_r["B"][i] = rsw_r["B"][i + 1];
	rsw_r[s[i] as "R" | "G" | "B"][i]++;
}

const patterns = ["RGB", "RBG", "GBR", "GRB", "BRG", "BGR"];

let result = 0;
for (const pt of patterns) {
	for (let i = 0; i < n; i++) {
		if (s[i] !== pt[0]) continue;
		for (let d = 1; i + d < n; d++) {
			if (s[i + d] !== pt[1]) continue;
			result += rsw_r[pt[2] as "R" | "G" | "B"][i + d];
			if (i + d + d < n && s[i + d + d] === pt[2]) result--;
		}
	}
}
console.log(result)

Measured memory_bytes: 37084
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n+1;i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int n,k;
  cin >>n>>k;
  vector<int> V(n);
  rep(i,n) cin >>V[i];
  int ans = 0;
  rep(l,k+1){
    rep(r,k-l+1){
      if(l+r > n) break;
      int tmp = 0;
      vector<int> S(0);
      rep(i,l){
        tmp += V[i];
        S.push_back(V[i]);
      }
      rep(i,r){
        int j = n-1-i;
        tmp += V[j];
        S.push_back(V[j]);
      }
      sort(S);
      int d = k-l-r;
      rep(i,d){
        if(i >= S.size()) break;
        if(S[i] >= 0) break;
        tmp -= S[i];
      }
      ans = max(tmp,ans);
    }
  }
  cout << ans << endl;
}


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

int main() {
    int n, t, ret = 1001;
    std::cin >> n >> t;
    for (int i = 0; i < n; i++) {
        int c, tt;
        std::cin >> c >> tt;
        if (t >= tt) ret = std::min(ret, c);
    }
    std::cout << (ret == 1001 ? "TLE" : std::to_string(ret)) << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int a, b, c, x, y;
	scanf("%d %d %d %d %d", &a, &b, &c, &x, &y);
	int sum = 0;

	int z;//xとyの共通部分
	if (x < y) z = x;
	else z = y;

	//共通部分までの最適解を見つける
	if ((a + b) > (c * 2)) {//c*2の方がお得
		sum += z * 2 * c;
	}
	else {//単純に買うのがお得
		sum += a*z + b*z;
	}

	if (x == z) {//yが残っている場合
		if (c * 2 < b) {//cで買う方がお得
			sum += c * 2 * (y - z);
		}
		else {//単純がお得
			sum += b*(y - z);
		}
	}
	else {//xが残っている場合
			if (c * 2 < a) {//cで買う方がお得
				sum += c * 2 * (x - z);
			}
			else {//単純がお得
				sum += a*(x - z);
			}
	}
	printf("%d\n", sum);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << endl;
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
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;}

// 0 false, 1 true 
// string to int : -48
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    ll a, b;
    cin >> a >> b;
    ll ans = 0;
    if(a == 1){
        ans += 300000;
    }
    if(a == 2){
        ans += 200000;
    }
    if(a == 3){
        ans += 100000;
    }
    if(b == 1){
        ans += 300000;
    }
    if(b == 2){
        ans += 200000;
    }
    if(b == 3){
        ans += 100000;
    }
    if(a== 1 && b == 1){
        ans+= 400000;
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
/**
*    created: 10.05.2020 21:06:57
**/

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int inf =1000000000;

int main() {
    ll a, b, c, k,ans;
    cin >> a >> b >> c >> k;
    if(a>=k){
        cout << k << endl;
    }else if(a+b>=k){
        cout << a << endl;
    }else{
        cout << a-(k-a-b) << endl;
    }
    
}

Measured memory_bytes: 3596
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;

class Main {

	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

	void run() throws Exception {
		Scanner sc = new Scanner();
		int N = sc.nextInt();
		long[] x = new long[N];
		long[] sum = new long[N];
		long X = sc.nextLong();
		for (int i = 0; i < N; ++i) {
			x[i] = sc.nextLong();
		}
		for (int i = 0; i < N; ++i) {
			sum[i] = (i - 1 >= 0 ? sum[i - 1] : 0) + x[i];
		}
		long ans = Long.MAX_VALUE;
		out: for (int i = 0; i < N; ++i) {
			int len = N - i;
			long cur = 0;
			cur += X * len;// 捨てる時のコスト
			cur += 2 * (sum[N - 1] - (i - 1 >= 0 ? sum[i - 1] : 0));
			int cntK = 0;
			for (int j = N - 1; j >= 0; j -= len) {
				long range = sum[j] - (j - len >= 0 ? sum[j - len] : 0);
				cur += (2 * (cntK + 1) + 1) * range;
				++cntK;
				if (cur - X * len > 1e15)
					continue out;
				if (cur > ans)
					continue out;
			}
			ans = Math.min(ans, cur);
		}
		System.out.println(ans + X * N);// ゴミを拾うときのコストをカウント
	}

	class Scanner {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[ptr++];
			else
				return -1;
		}

		private boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		public boolean hasNext() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr]))
				ptr++;
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		public int nextInt() {
			long nl = nextLong();
			if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
				throw new NumberFormatException();
			return (int) nl;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}
	}
}


Measured memory_bytes: 24784
#include <stdio.h>
 
int main(void)
{
    int p, min_p = 2000;
    int j, min_j = 2000;
    int i;
     
    for (i = 0; i < 3; i++){
        scanf("%d", &p);
        if (min_p > p){
            min_p = p;
        }
    }
    for (i = 0; i < 2; i++){
        scanf("%d", &j);
        if (min_j > j){
            min_j = j;
        }
    }
     
    printf("%d\n", min_p + min_j - 50);
     
    return (0);
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
struct point{int x;int y;};
int i,j,k,count1=0,count2=0;

int main(){
    string s;
    cin>>s;
    if(s.length()==2)cout<<s<<endl;
    else{
        rep(i,s.length()){
            cout<<s[s.length()-1-i];
        }
        cout<<endl;
    }
}

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


int main() {

  int N,A,B,C,D;
  cin >> N >> A >> B >> C >> D;

  string S;
  cin >> S;

  S = '#' + S + '#';
  for(int i = A;i < C;i++) {
    if(S.at(i) == '#' && S.at(i+1) == '#') {
      cout << "No" << endl;
      return 0;
    }
  }

  bool jump = false;
  for(int i = B-1;i < D;i++) {
    if(S.at(i) == '#' && S.at(i+1) == '#') {
      cout << "No" << endl;
      return 0;
    }
    if(S.at(i) == '.' && S.at(i+1) == '.' && S.at(i+2) == '.') jump = true;
  }

  if(C < D) {
    cout << "Yes" << endl;
  }else {
    if(jump) {
      cout << "Yes" << endl;
    }else {
      cout << "No" << endl;
    }
  }

}



Measured memory_bytes: 772
program main
  implicit none
  integer(8) :: n, i, a, b,  res, keta, kotae
  read(*,*) n

  if(mod(n,2)==1) then
    write(*,*) 0
    stop
  end if
  n = n/10

  kotae = 0
  do i = 1, int(log(dble(n))/log(5d0))+1
    kotae = kotae + n/(5**(i-1))
  end do
  write(*,*) kotae
end program main

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using f80 = __float80;
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define pb push_back
#define rng(a) a.begin(),a.end()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define sz(x) (i64)(x).size()
#define bit(n) (1LL<<(n))
#define fi first
#define se second
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

i64 pow_mod(i64 n, i64 k, i64 m){
  i64 r = 1;
  for(;k;k>>=1){
    if(k&1) r=(r*n)%m;
    n=(n*n)%m;
  }
  return r;
}

i64 calc_c(i64 n,i64 a){
  i64 res = 1;
  rep(i,a){
    res *= (n-i);
    res %= MOD;
    res *= pow_mod(i+1,MOD-2,MOD);
    res %= MOD;
  }
  return res;
}

void Main()
{
  i64 n,a,b;
  cin >> n >> a >> b;

  i64 ans = pow_mod(2,n,MOD);
  ans += MOD - 1;
  ans %= MOD;

  ans += MOD - calc_c(n,a);
  ans %= MOD;

  ans += MOD - calc_c(n,b);
  ans %= MOD;

  cout << ans << endl;
}


int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}


Measured memory_bytes: 256
#include<stdio.h>
 #include<string.h>
 int main(){
 int n;
 char s[10010];
 scanf("%d%s",&n,s);
 int len=strlen(s);
 for(int i=0;i<len;i++){
 int x=s[i]-'A';
 x=(x+n)%26;
 putchar('A'+x);
 }
 
 }

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    
    ll ans = 0;
    if(k%2){
        ans +=(n/k)*(n/k)*(n/k);
    }
    else {
        ans += (n / k) * (n / k) * (n / k);
        ans += ((n + k / 2) / k) * ((n + k / 2) / k) * ((n + k / 2) / k) ;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
s = list(input())
t = list(input())

if len(s) < len(t):
	print("UNRESTORABLE")
else:
	ikeru = False
	for i in range(len(s) - len(t), -1, -1):
		num_ok = 0
		for j in range(len(t)):
			if s[i + j] == "?" or s[i + j] == t[j]:
				num_ok += 1
		if num_ok == len(t):
			ikeru = True
			break

	if ikeru:
		for k in range(len(s)):
			if i <= k < i + len(t):
				s[k] = t[k - i]
			elif s[k] == "?":
				s[k] = "a"
		print("".join(s))
	else:
		print("UNRESTORABLE")

Measured memory_bytes: 3064
module Main where

import Data.Bool
import Data.Functor
import Data.List
import Data.Ord

main :: IO ()
main = do
  { [n] <- getInts
  ; cs <- getCards
  ; let ds = bubbleSortBy (comparing (!!1)) cs
  ; let es = selectionSortBy (comparing (!!1)) cs
  ; putCards ds
  ; putStrLn "Stable"
  ; putCards es
  ; putStrLn $ bool "Not stable" "Stable" (ds == es)
  }

bubbleSortBy :: (a -> a -> Ordering) -> [a] -> [a]
bubbleSortBy cmp = step []
  where
    step xs [] = xs
    step xs ys = case bubbleBy cmp ys of
      (z,zs) -> step (z:xs) zs

bubbleBy :: (a -> a -> Ordering) -> [a] -> (a, [a])
bubbleBy cmp (x:xs) = mapAccumL (swapBy cmp) x xs

swapBy :: (a -> a -> Ordering) -> a -> a -> (a, a)
swapBy cmp x y = case x `cmp` y of
  GT -> (x,y)
  _  -> (y,x)

selectionSortBy :: Eq a => (a -> a -> Ordering) -> [a] -> [a]
selectionSortBy cmp xs = unfoldr phi xs
  where
    phi [] = Nothing
    phi xxs@(x : xs) = case break (minx ==) xxs of
      ([], _) -> Just (x, xs)
      (y : ys, z : zs) -> Just (z, ys ++ y : zs)
      where
        minx = minimumBy cmp xxs
        
type Card = [Char]

getCards :: IO [Card]
getCards = words <$> getLine

putCards :: [Card] -> IO ()
putCards = putStrLn . unwords

getInts :: IO [Int]
getInts = map read . words <$> getLine

Measured memory_bytes: 3964
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::max;

fn main() {
    input! {
        n: usize,
        h: [(i32, i32, i32); n],
    }

    // initialize
    let mut dp: Vec<(i32, i32, i32)> = vec![(0, 0, 0); n];
    let before_a = max(h[n - 1].1, h[n - 1].2);
    let before_b = max(h[n - 1].2, h[n - 1].0);
    let before_c = max(h[n - 1].0, h[n - 1].1);
    dp[n - 1] = (before_a, before_b, before_c);

    for i in (0..n - 1).rev() {
        let choose_a = h[i].0 + dp[i + 1].0;
        let choose_b = h[i].1 + dp[i + 1].1;
        let choose_c = h[i].2 + dp[i + 1].2;
        dp[i] = if i == 0 {
            (choose_a, choose_b, choose_c)
        } else {
            let before_a = max(choose_b, choose_c);
            let before_b = max(choose_c, choose_a);
            let before_c = max(choose_a, choose_b);
            (before_a, before_b, before_c)
        };
    }
    println!("{}", max(max(dp[0].0, dp[0].1), dp[0].2));

} 


Measured memory_bytes: 6396
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main() {
	int i,len,index,alpha, count[26];
	static char s[10000];
	for (i = 0; i < 26; i++) {
		count[i] = 0;
	}
	while (NULL != fgets(s, sizeof(s), stdin)) {
		len = strlen(s);
		for (i = 0; i < len; i++) {
			char t = s[i];
			if (isalpha(t)) {
				if (isupper(t)) {
					t = tolower(t);
				}
				index = t - 'a';
				count[index] = count[index] + 1;
			}
		}
	}
	for (i = 0; i < 26; i++) {
		alpha = 'a' + i;
		printf("%c : %d\n", alpha, count[i]);
	}
}

Measured memory_bytes: 952
import itertools
N = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(range(1,N+1,1))
a_cnt = 0
b_cnt = 0
for i in itertools.permutations(c,N):
  a_cnt += 1
  for j in range(len(c)):
    if a[j] == i[j]:
      if j == N-1:
        a_ans = a_cnt
        break
    else:
      break
for i in itertools.permutations(c,N):
  b_cnt += 1
  for j in range(len(c)):
    if b[j] == i[j]:
      if j == N-1:
        b_ans = b_cnt
        break
    else:
      break
print(abs(a_ans - b_ans))


Measured memory_bytes: 3064