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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
typedef vector < vector<ll> > Mat;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, M, S;
vector <Pli> Graph[250000];
ll Dist[250000];
bool visited[250000];

int Input1(){
  int U, V, A, B;
  scanf("%d%d%d%d", &U, &V, &A, &B);
  for (int i = A; i <= 2500; i++){
    int now = 2501 * U + i;
    int next = 2501 * V + i - A;
    Graph[now].push_back({B, next});
  }
  for (int i = A; i <= 2500; i++){
    int now = 2501 * V + i;
    int next = 2501 * U + i - A;
    Graph[now].push_back({B, next});
  }
  return 0;
}

int Input2(int i){
  int C, D; scanf("%d%d", &C, &D);
  for (int j = 0; j <= 2500; j++){
    int now = 2501 * i + j;
    int next = 2501 * i + min(j + C, 2500);
    Graph[now].push_back({D, next});
  }
  return 0;
}

int Solve(int i){
  ll ans = 1e18;
  for (int j = 0; j <= 2500; j++){
    int now = 2501 * i + j;
    if (!visited[now]) continue;
    ans = min(ans, Dist[now]);
  }
  printf("%lld\n", ans);
  return 0;
}

int main(){
  scanf("%d%d%d", &N, &M, &S);
  for (int i = 0; i < M; i++) Input1();
  for (int i = 1; i <= N; i++) Input2(i);

  priority_queue <Pli, vector<Pli>, greater<Pli> > que;
  que.push({0, 2501 + min(S, 2500)});

  while (!que.empty()){
    Pli Q = que.top(); que.pop();
    if (visited[Q.se]) continue;
    visited[Q.se] = true;
    Dist[Q.se] = Q.fi;

    for (Pli next : Graph[Q.se]){
      if (visited[next.se]) continue;
      que.push({Q.fi + next.fi, next.se});
    }
  }

  for (int i = 2; i <= N; i++) Solve(i);

  return 0;
}


Measured memory_bytes: 28704
def calculate(arr):

    largest,second = findLargetAndSecond(arr)

    for i in range(len(arr)):
        value = arr[i]
        if largest != value:
            print(largest)
        else:
            print(second)


def findLargetAndSecond(arr):
    largest = 0
    second = 0

    for i in range(0,len(arr)):
        if arr[i] > largest:
            second = largest
            largest = arr[i]
        else:
            if arr[i] >= second:
                second = arr[i]

    return largest,second



N = int(input())
arr = []
for i in range(N):
    arr.append(int(input()))

calculate(arr)



Measured memory_bytes: 12532
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cstring>
using namespace std;
long long int mod = 1e9 + 7;
int inf = 1e9;

int num[10] = {0,2,5,5,4,5,6,3,7,6};

int main() {
  int n, m; cin >> n >> m;
  vector<int> a(m);
  for(int i=0; i<m; i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  // for(int i=0; i<m; i++) cerr << p[i].first << " " << p[i].second << endl;

  vector<int> dp(n+1, -inf);
  dp[0] = 0;
  for(int i=1; i<=n; i++) {
    for(int j=0; j<m; j++) {
      if(i-num[a[j]] >= 0) {
        dp[i] = max(dp[i], dp[i-num[a[j]]] + 1);
      }
    }
  }

  // for(int i=0; i<=n; i++) cerr << i << " " << dp[i] << endl;

  string ans = "";
  for(int i=dp[n]; i>0; i--) {
    for(int j=m-1; j>=0; j--) {
      int p = num[a[j]];
      if(n - p >= 0 && dp[n - p] == i-1) {
        ans += to_string(a[j]);
        n -= p;
        break;
      }
    }
  }
  cout << ans << endl;

  return 0;
}


//EOF


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define int         long long
#define endl        "\n"
#define pii         pair<int, int>
#define vi          vector<int>
#define sz(x)       (int)x.size()
#define dint        long double


//////////////////////////////////////////////////////////////////////

const int mod = 998244353;
const int MX = 5e5+5;
int modpow(int a, int b);

inline int mul(int a, int b) {
    long long res = ((long long)a % mod * b % mod) % mod;
    return (int)res;
}

inline int add(int a, int b) {
    long long res = a + b;
    if(res >= mod) res -= mod;
    return (int)res;
}

inline int sub(int a, int b) {
    long long res = a - b;
    if(res < 0) res += mod;
    return (int)res;
}

long long pw(int a, int b) {
    long long res = 1;
    if(a < 2) return a;
    long long _a = a;
    while(b) {
        if(b % 2) res = res * _a;
        b /= 2;
        _a = _a * _a;
    }
    return res;
}

int modpow(int a, int b) {
    long long res = 1;
    if(a < 2) return a;
    while(b) {
        if(b % 2) res = mul(res, a);
        b /= 2;
        a = mul(a, a);
    }
    return res;
}

int MI(int a) {
    return modpow(a, mod - 2);
}

int fac[MX];
int ifac[MX];

void pre() {
    fac[0] = fac[1] = 1;
    ifac[0] = ifac[1] = 1;
    for(int i=2; i<MX; i++) fac[i] = mul(fac[i-1], i);
    for(int i=2; i<MX; i++) ifac[i] = MI(fac[i]);
}

long long C(int n, int k) {
    long long res = 1;
    res = mul(res, fac[n]);
    res = mul(res, ifac[k]);
    res = mul(res, ifac[n-k]);
    return res;
}

long long P(int n, int k) {
    long long res = 1;
    res = mul(res, fac[n]);
    res = mul(res, ifac[n-k]);
    return res;
}

//////////////////////////////////////////////////////////////////////


void solve(int TC) { 
    int n, m, k; cin >> n >> m >> k;
    int ans = 0;
    int totalPairs = n - 1;
    for(int i=0; i<=k; i++) {
        int diffColor = totalPairs - i;
        int partitions = diffColor + 1;
        int cur = C(totalPairs, diffColor);
        cur = mul(cur, m);
        if(partitions > 1) cur = mul(cur, modpow(m - 1, partitions - 1));
        ans = add(ans, cur);
    }
    cout << ans << endl;
}
 
signed main() {
 
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(12);
    
    pre();

    int T = 1;
    //cin >> T;
    for(int i=1; i<=T; i++) {
        solve(i);
    }
    return 0;
 
}

Measured memory_bytes: 11440
#include<iostream>
#include<vector>
#include<string>
#include<map>
using namespace std;

int s = 0;
int x[] = { -1,0,0,1 }; int y[] = { 0,-1,1,0 };
bool p[20][20]{};
void shima(int a, int b) {
	s++;
	p[a][b] = false;
	for (int c = 0; c < 4; c++) {
		int d = a + x[c]; int e = b + y[c];
		if (d >= 0 && d < 20 && e>=0 && e < 20 && p[d][e])shima(d, e);
	}
}
int main() {
	int a, b;
	while (cin >>b>>a, a | b) {
		s = 0;
		for (int n = 0; n < 20; n++) {
			for (int m = 0; m < 20; m++) {
				p[n][m] = false;
			}
		}
		int l = 0, r = 0;
		for (int c = 0; c < a; c++) {
			for (int d = 0; d<b; d++) {
				char e;
				cin >> e;
				if (e == '.')p[c][d] = true;
				else if (e == '@') { l = c; r = d; }
			}
		}
		shima(l, r);
		cout << s << endl;
	}
}

Measured memory_bytes: 3100
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <iomanip>
#include <list>
#include <deque>
#include <stack>
#define ull unsigned long long
#define ll long long
#define mod 90001
#define INF 0x3f3f3f3f
#define maxn 10010
#define cle(a) memset(a,0,sizeof(a))
const ull inf = 1LL << 61;
const double eps=1e-5;
using namespace std;
priority_queue<int,vector<int>,greater<int> >pq;
struct Node{
    int x,y;
};
struct cmp{
    bool operator()(Node a,Node b){
        if(a.x==b.x) return a.y> b.y;
        return a.x>b.x;
    }
};

bool cmp(int a,int b){
    return a>b;
}
int a[300];
int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("in.txt","r",stdin);
    #endif
    //freopen("out.txt","w",stdout);
    int n;
    while(cin>>n){
        for(int i=1;i<=n*2;i++)cin>>a[i];
        sort(a+1,a+1+2*n);
        int sum=0;
        for(int i=2*n;i>=1;i-=2){
            sum+=a[i-1];
        }
        cout<<sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, n) for(int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=pow(10,18);
const double inf=pow(10,10);
const ld pi=acosl(1);
const ll mod = 1000000007;
const ll dx[4]={0,0,1,-1};
const ll dy[4]={-1,1,0,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};

ld f(ld R,ld i,ld n){
  if(i<=0)return 0;
  if(i>=n)return 0;
  ld ret=pow(R,(ld)2)-pow((ld)((ld)2*R/n*i-R),(ld)2);
  return 2*sqrtl(ret);
}


bool solve(){
  ll n;cin>>n;
  ll maA=0,maB;
  rep(i,n) {
    ll a,b;cin>>a>>b;
    if(maA<a){
      maA=a;
      maB=b;
    }
  }
  cout<<maA+maB<<endl;
  return false;
}

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout<<fixed;
  cout<<setprecision(30);
  return solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
 
  for (int i = 0; i < N+1; i++) {
    int A;
    cin>>A;
    if (A%2==0 && A%6!=0 && A%10!=0){
      cout << "DENIED" << endl ;
      break ;
    }
    else if (i==N) {
      cout << "APPROVED" << endl ;
    }
    
    
  }
}


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

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

 int a[100][100],b[100];
 for(int i=0;i<n;i++){
  for(int j=0;j<m;j++){
   cin >> a[i][j] ;
  }
 }
 for(int i=0;i<m;i++){
  cin >> b[i] ;
 }
 
 for(int i=0;i<n;i++){
  int c=0;
  for(int j=0;j<m;j++){
   c+=a[i][j]*b[j];
  }
 cout << c << endl ;
 }
 
 return 0;
}

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

class Main {

    public static void main(String[] args) {

	Scanner stdin = new Scanner(System.in);

	int count = 0;
	while ( stdin.hasNext() ) {

	    final String input = stdin.nextLine();
	    final String reverse = new StringBuilder( input ).reverse().toString();
	    if ( input.equals( reverse ) ) {
		count++;
	    }	    
	}
	System.out.println( count );
    }
    
}

Measured memory_bytes: 15304
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) throws java.lang.Exception
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		ArrayList<Integer> h = new ArrayList<Integer>();
		ArrayList<Integer> w = new ArrayList<Integer>();
		ArrayList<String> strArray = new ArrayList<String>();
		String data;
		int count = 0;
		while(true) {
			strArray.add(br.readLine());
			data = strArray.get(strArray.size() - 1);
			if(data.equals("0 0")) {
				break;
			}
			count++;
		}
		
		for(int i = 0; i < strArray.size(); i++) {
			String s = strArray.get(i);
			String [] ary = s.split(" ", 0);
			h.add(Integer.parseInt(ary[0]));
			w.add(Integer.parseInt(ary[1]));
		}
		
		for(int k = 0; k < count; k++) {
			for(int i = 0; i < h.get(k); i++) {
				for(int j = 0; j < w.get(k); j++) {
					System.out.print('#');
				}
				System.out.println();
			}
			System.out.println();
		}
	}

}

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

vector<vector<P>> edges(100010);
vector<int> color(100010,0);

void dfs(int i,int p = -1,int c = -1) {
    int d = 1;
    for (P& j : edges[i]) if (j.first != p) {
        if (d == c) d++;
        color[j.second] = d;
        dfs(j.first,i,d);
        d++;
    }
}

int main() {
    int n;
    cin >> n;
    for (int i = 0;i < n-1;++i) {
        int u,v;
        cin >> u >> v;
        u--;v--;
        edges[u].push_back(P(v,i));
        edges[v].push_back(P(u,i));
    }
    dfs(0);
    int ans = 0;
    for (int i = 0;i < n;++i) ans = max(ans,(int)edges[i].size());
    cout << ans << endl;
    for (int i = 0;i < n-1;++i) cout << color[i] << "\n";
}

Measured memory_bytes: 9472
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int s, k;
	cin >> k >> s;
	int ans = 0;
	for (int i = 0; i <= k; ++i) {
		for (int j = 0; j <= k; ++j) {
			int q = s-i-j;
			if(0 <= q && q <= k) {
				++ans;
			}
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define inf 1000000000
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
#define meM(y,a) memset(y,a,sizeof y)
#define sC(a) scanf("%d",&a)
#define alL(a) a.begin(),a.end()
#define prinT(a,sz)  cout<<a[0];for(int i=1;i<sz;i++)cout<<" "<<a[i];cout<<endl
#define ranD srand(chrono::steady_clock::now().time_since_epoch().count());
typedef pair<int,int>pi;
typedef pair<ll,ll>pll;
//int fx[]={0,0,1,-1};
//int fy[]={1,-1,0,0};
//int gx[]={0,0,1,1,1,-1,-1,-1};
//int gy[]={1,-1,0,1,-1,0,1,-1};
const int N=100010;
vector<pi>v;
map<pi,int>mp;
int main()
{
    IOS;
    int n;cin>>n;
    for(int i=0;i<n;i++)
    {
        int a,b;cin>>a>>b;
        v.pb({a,b});
    }
    sort(alL(v));
    for(int i=1;i<n;i++)
    {
        for(int j=0;j<i;j++)
        {
            int x=v[i].ff-v[j].ff;
            int y=v[i].ss-v[j].ss;
            mp[{x,y}]++;
        }
    }
    int mx=0;
    for(auto it=mp.begin();it!=mp.end();it++)
    {
        mx=max(mx,it->second);
    }
    cout<<n-mx<<endl;
}








Measured memory_bytes: 3652
#include <stdio.h>
#include <math.h>
#include <algorithm>

using namespace std;



int main(){
	int a,b,c,tyou = 0,hishi = 0;

	while(scanf("%d,%d,%d",&a,&b,&c)!=EOF){
		if(a*a+b*b==c*c)tyou++;
		else{
			if(a == b)hishi++;
		}
	}

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

	return 0;
}

Measured memory_bytes: 2580
s = int(input())


def f(v):
    return v // 2 if not v % 2 else 3 * v + 1


V = set([s])
prev = s
for i in range(1, 1000000 + 1):
    a = f(prev)
    if a in V:
        print(i + 1)
        exit()
    else:
        V.add(a)
        prev = a
print(V)


Measured memory_bytes: 3060
/*
Author: Deep Chaklasiya
*/

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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update> data_set;
#define fbo find_by_order
#define ook order_of_key

#define int        long long int
#define double      long double
#define pb          push_back
#define pf          push_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define piiii       pair<pii,pii>
#define viiii       vector<pair<pii,pii>>
#define mi          map<int,int>
#define mii         map<pii,int>
#define piii           pair<int,pair<int,int> >
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        998244353
#define PI          3.141592653589
#define bs(v,n)     binary_search(all((v)),(n))
#define lb(v,n)     lower_bound(all((v)),(n))
#define ub(v,n)     upper_bound(all((v)),(n))
#define fo(i,l,u)   for(i=l;i<u;i++)
#define rfo(i,l,u)  for(i=l;i>=u;i--)
#define allfo(s)    for(auto it=(s).begin();it!=(s).end();it++)
#define _init(b)     memset(b,-1,sizeof(b))
#define _init0(b)     memset(b,0,sizeof(b))
#define MOD         1000000007
#define ef else if





int gcd(int a, int b) {  if (a == 0)  return b; return gcd(b % a, a); }
bool mod(double a,double b) {return a/b - floor(a/b);}

int occurs(vi v,int n){
auto it=lb(v,n);auto it1=ub(v,n);int x=it1-it;return x;}

int logb(int base, int x) {
    return (log(x) / log(base));
}


template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}

void set_min(int &m,int a){
    if(m==-1||m>a)m=a;
}


signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int i,j,x,n,m,k,t;
    cin>>n;
    int flag=0;
    mi mp;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		if(mp[x]==0) mp[x]=1;
		else
		{
			flag=1;
		}
	}
	if(flag) cout<<"NO";
	else cout<<"YES";
    return 0;
}


Measured memory_bytes: 12928
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
int a[100002][2];
int main()
{

    int i,j,n,m;
    cin>>n;
    for(i=0; i<n+1; i++)
        cin>>a[i][0];
    for(i=0; i<n; i++)
        cin>>a[i][1];
    long long int sum=0;
    for(i=0; i<n; i++)
    {
        if(a[i][1]<=a[i][0])
            sum+=a[i][1];
        else
        {
            a[i][1]-=a[i][0];
            sum+=a[i][0];
            if(a[i+1][0]>=a[i][1])
            {
                a[i+1][0]-=a[i][1];
                sum+=a[i][1];
            }
            else
            {
                sum+=a[i+1][0];
                a[i+1][0]=0;
            }
        }
    }
    cout<<sum;
    }


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
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; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll a,b,c,k;
  cin>>a>>b>>c>>k;
  if(a+b>=k){
    COUT(min(k,a));
  }
  else{
    COUT(a-(k-a-b));
  }
}

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

#define pb push_back
#define fi first
#define se second
#define ll long long
#define pq priority_queue
#define mp make_pair
#define pii pair<int,int>
const int mod=1e9+7;

int lowbit(int x) {return x&(-x);}

int n,k;
int a[111];
int f[111][111111];
int sum[111111];
int tmp[111111];

int main(){
	scanf("%d%d",&n,&k);
	for (int i=0;i<n;i++) scanf("%d",&a[i]);
	for (int i=0;i<=a[0];i++) f[0][i]=1;
	for (int i=0;i<=k;i++) {
		if (i==0) sum[i]=f[0][i];
		else sum[i]=sum[i-1]+f[0][i];
	}
	for (int i=1;i<n;i++) {
		for (int j=0;j<=k;j++) {
			int l=max(0,j-a[i]),r=j;
			f[i][j]=sum[r];
			if (l>0) f[i][j]-=sum[l-1];
			if (f[i][j]<0) f[i][j]+=mod;
			if (j==0) tmp[j]=f[i][j];
			else tmp[j]=(tmp[j-1]+f[i][j])%mod;
		}
		for (int j=0;j<=k;j++) sum[j]=tmp[j];
	}
	cout<<f[n-1][k];
	return 0;
}


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

using namespace std;

int main()
{
    long long n, a, b; cin >> n >> a >> b;
    long long ans = b - a;
    if(ans % 2 == 0 ){
        cout << ans / 2 << endl;
    }else{
        cout << min(a - 1,n - b) + 1 + (b - a - 1) / 2 << endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>

main(){
  int i,n;
  int st[100];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&st[i]);
  }
  for(i=1;i<=n;i++){
    printf("%d",st[n-i]);
    if(i==n){
      printf("\n");
    }else{
      printf(" ");
    }
  }
}



Measured memory_bytes: 2052
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int size = 0, time = 0, b = 0;
        boolean flag = true;
        size = sc.nextInt();
        int[] a = new int[size];
        for (int i = 0; i < size; i++) {
            a[i] = sc.nextInt();
        }
        while (flag) {
            flag = false;
            for (int j = size - 1; j > 0; j--) {
                if (a[j] < a[j - 1]) {
                    b = a[j];
                    a[j] = a[j - 1];
                    a[j - 1] = b;
                    time++;
                    flag = true;
                }
            }
        }
        for (int k = 0; k < size; k++) {
            System.out.print(a[k]);
            if(k != (size-1))System.out.print(" ");
        }
        System.out.print("\n");
        System.out.println(time);


    }
}



Measured memory_bytes: 26256
#include <stdio.h>

int main(){
	char a;
	scanf("%c", &a);
	
	if(a >= 'A' && a <= 'Z'){
		printf("A\n");
	}
	else if(a >= 'a' && a <= 'z'){
		printf ("a\n");
	}
	
	return 0;
}

Measured memory_bytes: 1588
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N;
	cin >> N;
	cout << 48 - N << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;

#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())

using namespace std;
bool cmpcost(const pair<ll,int> left,const pair<ll,int> right){
    return left.first < right.first;
}


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

    int N,M;
    cin >> N >> M;
    vector<pair<ll,int> > costCount;
    pair<ll,int> tmpCostCount;
    ll sumCost = 0;
    REP(i,N){
        cin >> tmpCostCount.first >> tmpCostCount.second;
        costCount.push_back(tmpCostCount);
    }
  
    sort(costCount.begin(),costCount.end(),cmpcost);

    REP(i,N){
        if(costCount[i].second >= M){
            sumCost += costCount[i].first * M;
            cout << sumCost << endl;
            return 0;
        }
        sumCost += costCount[i].first * costCount[i].second;
        M -= costCount[i].second;
    }
}

Measured memory_bytes: 2420
#include <stdio.h>
#include <math.h>
long long int min(long long int a, long long int b)
{
    if (a > b) return b;
    else return a;
}

int main(void)
{
    long long int a, b, dist, f = 0;
    scanf("%ld", &a);
    dist=a-1;
    for (long long int i=2; i<sqrt(a)*10; i++){
        if (a % i == 0){
          b = a/i;
          dist = min(dist, i+b-2);
        }
    }
    printf("%ld", dist);
    return 0;
}   

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

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 555;
int n, k;
int a[N][N];

void print() {
	printf("%d\n", n);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++)
			printf("%d ", 1 + a[i][j]);
		printf("\n");
	}
}

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d", &k);

	if (k == 1) {
		n = 1;
		a[0][0] = 0;
		print();
		return 0;
	}
	if (k == 2) {
		n = 2;
		for (int i = 0; i < 2; i++)
			for (int j = 0; j < 2; j++)
				a[i][j] = i;
		print();
		return 0;
	}
	while(2 * n < k) n++;
	while(n & 1) n++;
	int z = 2 * n - k;
	for (int i = 0; i < z; i++)
		for (int j = 0; j < n; j++) {
			int p = (i + j) % n;
			a[j][p] = i;
		}
	for (int i = z; i < n; i++) {
		for (int j = 0; j < n; j++) {
			int p = (i + j) % n;
			int c = 2 * i - z + (j & 1);
			a[j][p] = c;
		}
	}
	print();

	return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    int n;cin >> n;
    vector<int> a(n);
    vector<int> pre(n+1),suf(n+1);
    rep(i,n)cin >> a[i];
    rep(i,n)pre[i+1] = max(pre[i],a[i]);
    for(int i = n-1;i >= 0;i--)suf[i] = max(suf[i+1],a[i]);
    rep(i,n)cout << max(pre[i],suf[i+1]) << "\n";
    return 0;
}

Measured memory_bytes: 7984
# S - Digit Sum
k = input()
d = int(input())
n = len(k)
MOD = 10**9+7

# dp[i][j][l]
# i桁目までみたとき、
# j=0:k未満であることが確定していない。j=1:k未満であることが確定している。
# l:桁和のmod dがlである数の個数。

dp = [[[0 for _ in range(d)] for _ in range(2)] for _ in range(n+1)]
dp[0][0][0] = 1

for i in range(n):
  for j in range(d):
    # k未満であることが確定していれば、i桁目は0～9の数字がとれる。
    for l in range(10):
      dp[i+1][1][(j+l)%d] += dp[i][1][j]
      dp[i+1][1][(j+l)%d] %= MOD
    # k未満であることが確定していない場合、i桁目を0～k[i]-1にすればk未満であることが確定する。
    for l in range(int(k[i])):
      dp[i+1][1][(j+l)%d] += dp[i][0][j]
      dp[i+1][1][(j+l)%d] %= MOD
    # k未満であることが確定していない場合、i桁目をk[i]にすればk未満であることは確定しない。
    dp[i+1][0][(j+int(k[i]))%d] += dp[i][0][j]
    dp[i+1][0][(j+int(k[i]))%d] %= MOD
# 0が解答にカウントされているので、0の分を除くため-1する。
print((dp[n][0][0]+dp[n][1][0]-1)%MOD)
# print(dp)

Measured memory_bytes: 93968
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = (1e5)+1;
const ll INF = (1e18)+10, MOD = (1e9)+7;

int n;
ll c[MAX], a[MAX], dp[MAX][2], sum[MAX][2];
vector<ll> t[MAX];
ll query(int l, int r) {// [)
	if(l == r) return 0;
	int lg = log2(r-l);
	assert(lg < t[l].size());
	assert(lg < t[r-(1<<lg)].size());
	return min(t[l][lg], t[r-(1<<lg)][lg]);
}
int find_left(int i, int tp) {
	int l = 0, r = i-1;
	while(l < r) {
		int mid = l+r >> 1;
		if(query(mid+1, i) >= c[tp]) r = mid;
		else l = mid+1;
	}
	assert(l+1 == i || query(l+1, i) >= c[tp]);
	return l;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> c[0] >> c[1];
	a[0] = -INF;
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 0; i < n; i++) t[i].push_back(a[i+1] - a[i]);
	for(int j = 0; 1 << j+1 <= n; j++) {
		for(int i = 0; i+(1 << j+1) <= n; i++) t[i].push_back(min(t[i][j], t[i+(1<<j)][j]));
	}
	dp[0][0] = dp[0][1] = 1;
	sum[0][0] = sum[0][1] = 1;
	for(int i = 1; i < n; i++) for(int tp = 0; tp <= 1; tp++) {
		int l = find_left(i, tp);
		int r = upper_bound(a, a+i, a[i+1] - c[tp^1])-a-1;
		if(l <= r) dp[i][tp] = (sum[r][tp^1] - (l > 0 ? sum[l-1][tp^1] : 0) + MOD) % MOD;
		sum[i][tp] = (sum[i-1][tp] + dp[i][tp]) % MOD;
	}
	for(int tp = 0; tp <= 1; tp++) {
		int l = find_left(n, tp);
		dp[n][tp] = (sum[n-1][tp^1] - (l > 0 ? sum[l-1][tp^1] : 0) + MOD) % MOD;
	}
	cout << (dp[n][0] + dp[n][1]) % MOD;
}


Measured memory_bytes: 25344
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	n := readInt()
	h := make([]int, n)
	for i := range h {
		h[i] = readInt()
	}
	dp := make([]int64, n)
	calc := func(i, j int) int64 {
		return dp[i] + abs(int64(h[i]-h[j]))
	}
	dp[1] = calc(0, 1)
	for i := 2; i < n; i++ {
		dp[i] = min(calc(i-2, i), calc(i-1, i))
	}
	println(dp[n-1])
}

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

func min(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

// -----------------------------------------------------------------------------


Measured memory_bytes: 2688
# -*- coding: utf-8 -*-
s = input()
li = []
r_cnt = 0
l_cnt = 0
for n, a in enumerate(s):
  if a == 'R':
    if l_cnt > 0:
      li.append([r_cnt, l_cnt])
      r_cnt = 1
      l_cnt = 0
    else:
      r_cnt += 1
  else:
    l_cnt += 1
    if n + 1 == len(s):
      li.append([r_cnt, l_cnt])

ans = ''
for l in li:
  b = int(l[0] / 2) + (l[0] % 2) + int(l[1] / 2)
  c = int(l[1] / 2) + (l[1] % 2) + int(l[0] / 2)
  ans += '0 ' * (l[0]- 1) + str(b) + ' ' + str(c) + ' ' + '0 ' * (l[1]- 1)
  
ans = ans[:-1]
print(ans)

Measured memory_bytes: 8728
/* ----------------------- reclone_rk -------------------------*/ 
#include<bits/stdc++.h>
using namespace std;
#define int long long int
const int mod=1e9+7;

int gcd(int a, int b){ if(a == 0) return b; return gcd(b%a, a);}
int MOD(int n){ return ((n%mod)+mod)%mod;}
int power(int a,int b){ if(b==0)return 1LL;int s=power(a,b/2LL);s*=s;s%=mod;if(b&1LL)return (s*a)%mod;return s;}
int inv(int a){return power(a,mod-2);}
int nCr(int n,int r){if(r>n)return 0LL;if(n-r<r)r=n-r;int ans=1;for(int i=0;i<r;i++){ans*=(n-i);ans=MOD(ans);ans*=inv(i+1);ans=MOD(ans);}return ans;}
 
signed main()
{
	int a, b, c;
	cin>>a>>b>>c;
	swap(a,b);
	swap(a,c);
	cout<<a<<" "<<b<<" "<<c<<endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
import bisect
def main():
    N = int(input())
    L = list(map(int, input().split()))
    L.sort()
    MAX = 2000
    C = [0] * MAX
    S = [0] * (MAX+1)
    for val in L:
        C[val] += 1
    for i in range(MAX):
        S[i+1] = C[i] + S[i]
    ans = 0
    for i in range(N):
        for j in range(N):
            if i == j:continue
            left = abs(L[i]-L[j])+1
            right = L[i]+L[j]
            ans += S[right]-S[left]
            if left <= L[i] < right:ans -= 1
            if left <= L[j] < right:ans -= 1
    print(ans//6)
if __name__ == "__main__":
    main()

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

int main(){
  int N;
  cin >> N;
  vector<int> d(N);
  for (int i = 0; i < N; i++){
    cin >> d[i];
  }
  
  int sum = 0, ans = 0;
  for (int i = 0; i < N; i++){
    sum += d[i];
  }
  
  for (int i = 0; i < N; i++){
    ans += (sum - d[i]) * d[i];
  }
  
  cout << ans / 2 << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
            #define ll long long
            #define MOD 1000000007
            #define maxx ((ll)1e6+5)
            #define zuciso ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
            #define test ll t; cin>>t; while(t--)
            #define int long long
            #define INF 1000000000000000005
            #define pb push_back
            #define pi 3.1415926
            #define MAX 300006
            #define MAX_N 1000000
            #define N 15000005
            #define fori(i,a,b) for(int i=a;i<b;i++)
            ll fpow(ll x,ll y,ll p=MOD){x=x%p;ll sum=1;while(y){if(y&1)sum=sum*x;sum%=p;y=y>>1;x=x*x;x%=p;}return sum;}
            ll fact[1000007]={0};
            void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%MOD;}
            ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(fpow(fact[r],MOD-2)))%MOD; res=(res*(fpow(fact[n-r],MOD-2)))%MOD; return res;}
            ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(fpow(fact[n-r],MOD-2)))%MOD; return res;}
            ll modmul(ll x, ll y){return (x*y)%MOD;}
            ll modadd(ll x, ll y){return (x+y)%MOD;}
            ll modsub(ll x, ll y){return (x-y+MOD)%MOD;}
            ll xx[4]={1,0,-1,0};
            ll yy[4]={0,1,0,-1};
           using namespace std;



            signed main(){
                zuciso;
                int n=5;
                int a[5];
                for(int i=0;i<n;i++){
                    cin>>a[i];
                    if(a[i]==0){
                        cout<<i+1<<endl;
                    }
                }


            }


Measured memory_bytes: 3572
// Code by ajcxsu
// Problem: A


#include<bits/stdc++.h>
#define MOD (1000000007)
using namespace std;

int cnt[500];

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    int n; cin>>n;
    string str; cin>>str;
    for(char x:str) cnt[x-'a']++;
    int ans=1;
    for(int i=0; i<27; i++) ans=1ll*ans*(cnt[i]+1)%MOD;
    printf("%d\n", (ans-1+MOD)%MOD);
    return 0;
}

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

using namespace std;

int h[200200], n, k;

int main() {
    scanf("%d%d", &n, &k);
    for (int i = 0; i < n; i++) {
        scanf("%d", &h[i]);
    }
    sort(h, h + n);
    long long sm = 0;
    for (int i = 0; i < n - k; i++) sm += 1ll * h[i];
    cout << sm << '\n';
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define fi first
#define se second
#define show(x) cerr<<#x<<"="<<x<<"\n"
typedef long long ll;
template<typename T>
void print_to(std::ostream &os,const char *,const char *tail,const T &fst){
  os<<fst<<tail;
}
template<typename Fst,typename... Rst>
void print_to(std::ostream &os,const char *del,const char *tail,const Fst &fst,const Rst &... rst){
  os<<fst<<del;
  print_to(os,del,tail,rst...);
}
template<typename Iter>
void print_to_(std::ostream &os,const char *del,const char *tail,Iter bgn,Iter end){
  for(Iter it=bgn;it!=end;){
    os<<*it;
    if(++it!=end)os<<del;
    else os<<tail;
  }
}
template<typename Fst,typename... Rst>
void println(const Fst &fst,const Rst &... rst){
  print_to(std::cout,"\n","\n",fst,rst...);
}
template<typename Fst,typename... Rst>
void print(const Fst &fst,const Rst &... rst){
  print_to(std::cout," ","\n",fst,rst...);
}
template<typename Iter>
void println_(Iter bgn,Iter end){
  print_to_(std::cout," ","\n",bgn,end);
}
using namespace std;
//const ll MOD=(ll)1e9+7;
//const ll inf=(ll)1e14;
const int dy[]={1,0,-1};
const int dx[]={1,0,-1};
ll n,m,h,w;
string s;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  //FILE *stream2;
  stream1=freopen("in","r",stdin);
  //stream2=freopen("out","w",stdout);
  if(stream1==NULL)return 0;
  //if(stream2==NULL)return 0;
#endif
  cin>>n>>m;
  if(abs(n-m)<=1)print("Brown");
  else print("Alice");
#ifdef LOCAL_DEFINE
  cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
  fclose(stream1);
  //fclose(stream2);
#endif
  return 0;
}






Measured memory_bytes: 256
N = int(input())
if N==1:
    print(0)
else:
    l1 = []
    for i in range(N):
        a = int(input())
        l1.append(a)
    l2 = sorted(l1)
    d1 = {j:i for i,j in enumerate(l1)}
    d2 = {j:i for i,j in enumerate(l2)}
    ans = 0
    for i in d1.keys():
        ans += (d1[i]%2!=d2[i]%2)
    ans //= 2
    print(ans)

Measured memory_bytes: 71252
#include <iostream>
#include <algorithm>

using namespace std;

void showArray(int a[], int n) {
    for (int i=0; i<n; i++) {
        cout << a[i] << ' ';
    } cout << endl;
}

int minCost(int a[], int n) {
    int mc = a[0];
    for (int i=1; i<n; i++) {
        if (mc > a[i]) {
            mc = a[i];
        }
    }

    return mc;
}

int main() {
    int N, T, c[114514], t[114514], tleFlg, tmpC[114514], tmpT[114514], ctr=0, mc;

    cin >> N >> T;

    for (int i=0; i<N; i++) {
        cin >> tmpC[i] >> tmpT[i];
        if (tmpT[i] <= T) {
            c[ctr] = tmpC[i];
            t[ctr] = tmpT[i];
            ctr++;
        }
    }

    if (ctr == 0) {
        cout << "TLE" << endl;
        return 0;
    }
    mc = minCost(c, ctr);

    cout << mc << endl;
    return 0;
}

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

const int Nmax = 100010;
int N, cnt[Nmax];

int main() {
	cin >> N;
	memset(cnt, 0, sizeof(cnt));
	for (int i = 0; i < N; i++) {
		int a;  cin >> a;
		if (a > N) cnt[N + 1]++;
		else cnt[a]++;
	}

	int ans = cnt[N + 1];
	for (int i = 1; i <= N; i++) {
		if (cnt[i] > i) ans += cnt[i] - i;
		if (cnt[i] < i) ans += cnt[i];
	}

	cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<pair<int, pair<int, bool> > > li;
    for(int i = 0; i<n; i++){
        int x, y;
        cin >> x >> y;
        li.push_back(make_pair(x,make_pair(y,true)));
    }
    for(int i = 0; i<n; i++){
        int x, y;
        cin >> x >> y;
        li.push_back(make_pair(x,make_pair(y,false)));
    }
    sort(li.begin(),li.end());
    set<int> s;
    int ans = 0;
    for(int i = 0; i<2*n; i++){
        if(li[i].second.second){
            //red
            s.insert(li[i].second.first);
        }
        else{
            //blue
            if(s.size()==0){
                continue;
            }
            auto it = s.lower_bound(li[i].second.first);
            if(it==s.begin()){
                continue;
            }
            it--;
            s.erase(it);
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,i,x,ara[100005];
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&x);
        ara[x]=i;
    }
    for(i=1;i<=n;i++)
    {
        printf("%d ",ara[i]);
    }
    return 0;
}

Measured memory_bytes: 1536
n=int(input())
k=int(n**0.5)+1
num=[0 for i in range(n+1)]
for x in range(1,k):
  for y in range(1,k):
    for z in range(1,k): 
      w=x**2+y**2+z**2+x*y+y*z+z*x
      if w<=n:
        num[w]+=1
for i in range(1,n+1):
  print(num[i])

Measured memory_bytes: 9376
s = gets.chomp
n = s.length
s1 = s[0...((n - 1)/2)]
s2 = s[((n + 1)/2)..-1]

puts (s1 == s2.reverse && s1 == s1.reverse && s2 == s2.reverse) ? :Yes : :No

load __FILE__ unless $stdin.eof?


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

using namespace std;

int r = 0, d = 0, x2000 = 0;

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

    cin >> r >> d >> x2000;

    for(int i=0;i<10;i++)
    {
        x2000 = r * x2000 - d;
        (i == 9)?cout << x2000:cout << x2000 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    int ans=0;
    while(N>0){
        ans+=N%10;
        N/=10;
    }
    if(ans==1) ans+=9;
    cout<<ans<<endl;
}


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

public class Main implements Runnable {
	public static void main (String[] args) {new Thread(null, new Main(), "_cf", 1 << 28).start();}

	public void run() {
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		System.err.println("");

		int A = fs.nextInt();
		int B = fs.nextInt();
		if(A <= 5) out.println(0);
		else if(A <= 12) out.println(B/2);
		else out.println(B);
		
		out.close();
	}

	class FastScanner {
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public FastScanner() {
			in = new BufferedInputStream(System.in, BS);
		}

		public FastScanner(String s) {
			try {
				in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
			}
			catch (Exception e) {
				in = new BufferedInputStream(System.in, BS);
			}
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}                
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for(int i = 0; i < n; i++) res[i] = nextInt();
			return res;
		}

	}

}

Measured memory_bytes: 23380
from sys import stdin
input = stdin.readline

A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

if B > A:
    if (V - W) * T + A >= B:
        print("YES")
    else:
        print("NO")
else:
    if (W - V) * T + A <= B:
        print("YES")
    else:
        print("NO")


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

int main(int argc, const char * argv[]) {
    long long N,x;
    long long sum,ans=100100100100100;
    cin>>N>>x;
    long long a[N],dp[N];
    for(long i=0;i<N;i++) {
        cin>>a[i];
        dp[i]=a[i];
    }
    
    for(long k=0;k<N;k++){
        
        for(long i=0;i<N;i++) dp[i]=min(dp[i],(((i-k)<0)? a[N+i-k]:a[i-k]));
        sum=0;
        for(long i=0;i<N;i++) sum+=dp[i];
        
        sum+=k*x;
        ans=min(ans,sum);
    }
    cout<<ans<<endl;
    
        return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int a, b, t;
    cin >> a >> b >> t;
    cout << t/a*b << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n;
	scanf("%d",&n);
	if( n<=90 && n>=65){
		printf("1\n");
	}
	else if( n<=122 && n>=97){
		printf("2\n");
	}
	else{
		printf("0\n");
	}
	return 0;
}


Measured memory_bytes: 2120
#include<stdio.h>
#define N 10000
#define Q 500

int main(){

  int s[N],t[Q],c=0;
  int i,a,b,key,x;

  scanf("%d",&a);
 for( i=0 ; i<a ; i++){
   scanf("%d",&s[i]);
 }

  scanf("%d",&b);
    for( i=0 ; i<b ; i++){
      scanf("%d",&t[i]);
    }


    for( i=0 ; i<b ; i++ ){
      key = t[i];
      s[a] = key;
      x = 0;
      while(s[x] != key){
	x++;
      }
      if(x != a){
	c++;
      }
    }
    
    printf("%d\n",c);
    return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define d(x) cerr<<#x<<"="<<x<<endl;
#define p(x) cout<<setprecision(7)<<x<<endl
vector<int> vec;

int n,m,a[100],k,t,ans;
int main(void){
    cin>>n>>m;
    rep(i,n){
        cin>>k;
        rep(j,k){
            cin>>t;
            a[t]++;
        }
    }
    rep(i,100){
        if(a[i]==n)ans++;
    }
    p(ans);
}


Measured memory_bytes: 256