akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define sf(xx) scanf("%lld",&xx)
#define fast()              ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define input()             freopen("G:/daily practise/in0.txt","r",stdin)
#define output()            freopen("G:/daily practise/out0.txt","w",stdout)
#define maxn 1000001
#define ll long long
int main() {
	fast();
	ll n,sum=0,q,x,a,b;
	map<ll,ll> mp;
	cin>>n;
	for (int i = 0; i < n; ++i)
	{
		cin>>x;
		sum+=x;
		mp[x]++;
	}
	cin>>q;
	while(q--)
	{
		cin>>a>>b;
		sum-=(a*mp[a]);
		sum+=(b*mp[a]);
		mp[b]+=mp[a];
		mp[a]=0;
		cout<<sum<<endl;
	}
}

Measured memory_bytes: 9500
/*
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd
#define prev asdgSHJsfgsdfhdsh

#define eps 1e-8
#define M_PI 3.141592653589793
#define bsize 512

#define ldouble long double
using namespace std;

#define bs 998244353

const int N = 120031;

int n,m,s,t;
vector<pair<int,int> > g[2][N];
long long  here,ans[N];
long long d[2][N];

set<pair<long long, long long> > S;
set<pair<long long, long long> > ::iterator it;

void dij(int s,int lev){
	for (int i=1;i<=n;i++){
		d[lev][i]=1e18;
	}
	d[lev][s]=0;
	S.clear();
	for (int i=1;i<=n;i++){
		S.insert(make_pair(d[lev][i],i));
	}
	while (S.size()){
		it=S.begin();
		int id=(*it).second;
		S.erase(it);
		for (int i=0;i<g[lev][id].size();i++){
			int to=g[lev][id][i].first;
			long long cost=g[lev][id][i].second+d[lev][id];
			if (d[lev][to]>cost){
				S.erase(make_pair(d[lev][to],to));
				d[lev][to]=cost;
				S.insert(make_pair(d[lev][to],to));
			}
		}
	}
}

int main(){
//	freopen("apache.in","r",stdin);
//	freopen("apache.out","w",stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
//	cin.tie(0);

	cin>>n>>m>>s>>t;
	for (int i=1;i<=m;i++){
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		g[0][a].push_back(make_pair(b,c));
		g[0][b].push_back(make_pair(a,c));
		g[1][a].push_back(make_pair(b,d));
		g[1][b].push_back(make_pair(a,d));
	}

	dij(s,0);
	dij(t,1);
	ans[0]=1e18;
	/*for (int i=1;i<=n;i++){
		cout<<d[0][i]<<" "<<d[1][i]<<endl;
	}*/

	for (int i=1;i<=n;i++){
		here=d[0][i]+d[1][i];
		ans[i]=here;
	}
	for (int i=n-1;i>=1;--i){
		ans[i]=min(ans[i],ans[i+1]);
	}

	for (int i=1;i<=n;i++){
		cout<<1000000000000000ll-ans[i]<<endl;
	}
//	cin.get(); cin.get();
	return 0;
}


Measured memory_bytes: 23424
#include <iostream>
using namespace std;
int main(int argc, char const *argv[]) {
  int n,m;
  cin>>n>>m;
  int a[30]={};
  for(int i=0;i<n;i++){
    int k;
    cin>>k;
    // cout<<"k="<<k<<endl;    //debug
    for(int j=0;j<k;j++){
      int tmp;
      cin>>tmp;
      a[tmp-1]++;

      // for(int l=0;l<m;l++){
      //   cout<<"a["<<l<<"]="<<a[l]<<",";
      //   cout<<endl;
      // }

    }
  }
  int ans=0;
  for(int i=0;i<m;i++){
    if(a[i]==n) ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
using System;

class program
{
public static void Main()
{
int s;
s = int.Parse(Console.ReadLine());
int h = s/3600;
int x = s%3600;
int m = x/60;
int y = x%60;
Console.Write("{0}:{1}:{2}\n",h,m,y);
}
}

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

int main()
{
    int a,b,c;
    cin >> a >> b >> c;

    int avg=0;
    avg = (a+b+c)/2;

    if(avg == a+b || avg == a+c || avg == b+c){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
}




Measured memory_bytes: 256
w, h, n = map(int,input().split())
left = 0
right = w
up = h
down = 0
for i in range(n):
    x, y, a = map(int,input().split())
    if a==1:
        left = max(left, x)
    elif a==2:
        right = min(right, x)
    elif a==3:
        down = max(down, y)
    else:
        up = min(up, y)
if up-down < 0 and right-left < 0:
    print(0)
else:
    print(max(0,(up-down)*(right-left)))


Measured memory_bytes: 62732
//////////////////////////////////////////////
//root@NULLCT$(☝ ՞ਊ ՞)☝  << "Be accept!!"//
//////////////////////////////////////////////
//#define BOOST
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int66_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>   //setfill(char)
#include <ios>       //left,right
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
#ifdef BOOST
#include <boost/multiprecision/cpp_int.hpp> // cpp_int
using namespace boost::multiprecision;
#endif
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;
using namespace std;
int setup(void){ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);return 0;}
int lenght(char *str){int i = 0;while (str[i])i++;return i;}
int gcd(int a, int b){if (a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a * b / gcd(a, b);}
int iinput(void){int a = 0;cin >> a;return a;}
int dinput(void) {double a = 0;cin>> a;return a;}
string sinput(void){string a = "";cin >> a;return a;}
int kuriup(double a) {int b = int(a);if (a != b) {return b + 1;} else {return b;}}
int kuridown(double a){int b = int(a);return b;}
int run(void);
int main(){setup();run();return 0;}
#define SIZE 15
int run(void){

 double n=dinput();
 cout<<kuriup(n/2)<<endl;

  return 0;
}


Measured memory_bytes: 256
n = gets.to_i
t = Array.new(n,0)
n.times do |i|
  t[i] = gets.to_i
end
dp = Array.new(n,0)
def gcd(a,b)
  n = a > b ? b : a
  m = a > b ? a : b
  while n != 0 && m != 1 do
    n,m = m%n,n
  end
  (a / m) * b
end
dp[0] = t[0]
1.upto(n-1) do |i|
  dp[i] = gcd(dp[i-1],t[i])
end
puts dp[n-1]

Measured memory_bytes: 1788
n = int(input())
b = ""
ans = [0 for i in range(n)]
a = list(map(int,input().split()))
for i in range(n):
    ans[a[i]-1] = i+1
for i in range(n):
    b += str(ans[i])
    if i != n-1:
        b += " "
print(b)

Measured memory_bytes: 14708
#include<bits/stdc++.h>
using namespace std;
long long x, cnt, res;
int main()
{
    cin>>x;
    cnt=x/500;
    res+=(1000*cnt);
    x-=(cnt*500);
    cnt=x/5;
    res+=(cnt*5);
    cout<<res;
    return 0;
}


Measured memory_bytes: 256
def dijkstra(graph,src):
    if graph is None:
        return None
    nodes = [i for i in range(len(graph))]
    visited=[]
    if src in nodes:
        visited.append(src)
        nodes.remove(src)
    else:
        return None
    distance={src:0}
    for i in nodes:
        distance[i]=int(graph[src][i])
    path={src:{src:[]}}
    k=pre=src
    while nodes:
        mid_distance=float('inf')
        for v in visited:
            for d in nodes:
                new_distance = int(graph[src][v])+int(graph[v][d])
                if new_distance < mid_distance:
                    mid_distance=new_distance
                    graph[src][d]=str(new_distance)
                    k=d
                    pre=v
        distance[k]=mid_distance
        path[src][k]=[i for i in path[src][pre]]
        path[src][k].append(k)
        visited.append(k)
        nodes.remove(k)
    return distance

if __name__=="__main__":
    sum = 0
    s = input().split(" ")
    x, y = s[0], s[1]
    c = [n for n in range(0,10)]
    d = []
    matrix =[i for i in range(0,int(x))]*int(y)
    c[0] = list(input().split(" "))
    c[1] = list(input().split(" "))
    c[2] = list(input().split(" "))
    c[3] = list(input().split(" "))
    c[4] = list(input().split(" "))
    c[5] = list(input().split(" "))
    c[6] = list(input().split(" "))
    c[7] = list(input().split(" "))
    c[8] = list(input().split(" "))
    c[9] = list(input().split(" "))
    for m in range(0,10):
        d.append(dijkstra(c,m))
    for i in range(0,int(x)):
        matrix[i] = input().split(" ")
        for j in range(0,int(y)):
            n = int(matrix[i][j])
            if n==-1:
                continue
            else:
                sum = sum + int(d[n][1])
    print(sum)





Measured memory_bytes: 5872
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	ull N;
	cin >> N;

	ull sum = 0;
	ull dummy = N;

	while (true) {
		sum += dummy % 10;
		dummy /= 10;
		if (dummy < 1){
			break;
		}
	}

	if (N % sum == 0){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;		
	}

	return 0;
}



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

using namespace std;
typedef long long ll;
#define FOR(i,n) for(int i=0; i<int(n); i++)
#define FOR1(i,m,n) for(int i=int(m); i<int(n); i++)

string s, t;
int q;
vector<int> cumul_s, cumul_t;

int main(int argc, char *argv[])
{
    cin >> s >> t;
    cumul_s.resize(s.length()+1);
    cumul_t.resize(t.length()+1);
    
    FOR(i,s.length()) {
        if (s[i] == 'A')
            cumul_s[i+1] = cumul_s[i]+1;
        else
            cumul_s[i+1] = cumul_s[i]-1;
    }
    FOR(i,t.length()) {
        if (t[i] == 'A')
            cumul_t[i+1] = cumul_t[i]+1;
        else
            cumul_t[i+1] = cumul_t[i]-1;
    }

    cin >> q;
    FOR(i,q) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        if (((cumul_s[b]-cumul_s[a-1]) - (cumul_t[d]-cumul_t[c-1])) % 3 == 0)
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(ll i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll MOD = 1000000007;
const double PI = acos(-1);
//or-> ||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl

signed main(){
	IO_STREAM;
	int H1,H2;
	int M1,M2;
	int K;
	cin>>H1>>M1>>H2>>M2>>K;
	int ans;
	ans=0;
	ans=H2*60+M2-H1*60-M1;
	if(ans<0) ans+=24*60;
	ans-=K;
	ans=max(ans,0);
	DBG("","","","");
	cout<<ans<<endl;
	return 0;
}


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

pair<ll, ll> calc(ll d, ll X) {
    ll x = X / d;
    for (int a = -500; a <= 500; a++) {
        ll result = 5 * a * a * a * a - 10 * d * a * a * a + 10 * d * d * a * a - 5 * d * d * d * a + d * d * d * d;
        if (result == x) {
            return {a, a - d};
        }
    }
    return {1e18, 1e18};
}

int main() {
    int X;
    cin >> X;
    vector<int> divs;
    for (int i = 1; i * i <= X; i++) {
        if (X % i == 0) {
            divs.push_back(i);

            int j = X / i;
            if (j != i) {
                divs.push_back(j);
            }
        }
    }

    for (int d : divs) {
        auto result1 = calc(d, X);
        if (result1.first != 1e18) {
            cout << result1.first << " " << result1.second << endl;
            return 0;
        }

        result1 = calc(-d, X);
        if (result1.first != 1e18) {
            cout << result1.first << " " << result1.second << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ls rt<<1
#define rs rt<<1|1
#define lson rt<<1,l,M
#define rson rt<<1|1,M+1,r
#define PI acos(-1)
#define MM int M=(l+r)>>1;
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define fh(i,be,e) for(int i=head[be];~i;i=e[i].next)
#define fa(i,V) for(auto i:V)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl '\n'
#define lcm(a,b) (a*b)/__gcd(a,b)
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) (x)&(-x)
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) ((x+mo_num)%mo_num)
#define vc vector
#define vct vector<int>
#define out(i) cout<<(i)<<endl;
#define fi first
#define se second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
#define ld long double
#define umap unordered_map
#define P pair<int,int>
#define SET set<int>
#define mp map<int,int>
#define mk make_tuple
#define low lower_bound
#define upp upper_bound
#define yn(key) out(key?"YES":"NO")
#define in(i) i+1,i+1+n
#define im(i) i+1,i+1+m
#define bffs(i) __builtin_ffs(i)
#define bcount(i) __builtin_popcount(i)
#define bone(i) ((1<<i)-1)
#define got(container,num) get<num-1>(container)
using namespace std;
const int INF=LLONG_MAX/2;
const int dx[]={0,0,-1,1},dy[]={-1,1,0,0};//up down left right
const int maxn=1e6+1e5;
const int mo_num=1e9+7;
int n,m,t,a[maxn],b[maxn],ans;

main()
{
    IOS
    cin>>n>>m;
    a[2]=(m-2*n)/2;
    a[1]=n-a[2];
    if(a[1]>=0 && a[2]>=0 && a[1]+a[2]==n && 2*a[1]+a[2]*4==m)out("Yes")
    else out("No")
    return 0;
}


Measured memory_bytes: 3700
from collections import deque


# 数列の点数を計算する関数
def calc(seq):
    score = 0
    for a, b, c, d in req:
        if seq[b - 1] - seq[a - 1] == c:
            score += d

    return score


n, m, q = map(int, input().split())
req = [list(map(int, input().split())) for _ in range(q)]

ans = 0

que = deque()

# 数列の1番目、[1]～[m]までキューに追加しますが、
# 実は、この問題は数列の最初が[1]の場合だけを考えても解けます。
for i in range(1, m + 1):
    que.append([i])

while que:
    seq = que.popleft()

    if len(seq) == n:
        # 長さがnになったので、得点を計算します
        score = calc(seq)
        ans = max(ans, score)
    else:
        # 次に追加する数字は、下限が今の数列の一番後ろの数字、上限がmです
        for i in range(seq[-1], m + 1):
            seq_next = seq + [i]
            que.append(seq_next)

print(ans)


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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

#define pb push_back
#define INF 999999999
#define MOD 1000000007
#define sp ' '


//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef pair<long, long> pll;
typedef map<int, int> mint;
typedef set<int> sint;
typedef vector<int> vint;
typedef vector<char> vchr;
typedef vector<long long> vll;
typedef vector<string> vstr;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll a, ll b, ll c){ll ans=1; rep(i, b){ans=ans*a%c;} return ans;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T>
void dpp(T n){cerr << n << endl;}
template<typename T>
void vpp(T a){rep(i,a.size()){cout << a[i] << endl;}}
template<typename T>
void vdp(T a){rep(i,a.size()){cerr << a[i];}cerr << endl;}

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



int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    bool f[100001];
    fill_n(f, 100001, false);
    int c[100002];
    fill_n(c, 100002, 0);

    for(int i=2; i <= 100000; ++i){
        if(!f[i]){
            for(int j=2*i; j <= 100000; j += i){
                f[j]=true;
            }
        }
    }

    for(int i=3; i <= 100000; i += 2){
        if(!f[i] and !f[(i+1)/2])
            c[i]++;
    }
    for(int i=3; i <= 100000; ++i){
        c[i] += c[i-1];
    }

    int q;
    cin >> q;

    while(q--){
        int l, r;
        cin >> l >> r;
        ppp(c[r]-c[l-1]);
    }






    return 0;
}


Measured memory_bytes: 1152
import Control.Monad

main :: IO ()
main = do
  n <- readLn
  ls <- replicateM n getLine
  mapM_ print $ solve (map (map read . words) ls)

solve :: [[Int]] -> [Int]
solve = map fix
  where
    fix :: [Int] -> Int
    fix [k,p]
      | amari == 0 = p
      | otherwise = amari
      where amari = k `mod` p

Measured memory_bytes: 4116
/*
------------------------------|بسم الله الرحمن الرحيم|------------------------------//
------------"IN THE NAME OF ALLAH, THE MOST GRACIUOS, THE MOST MERCIFUL"-------------//
__________________________________ShahnawazShaikh_____________________________________
*/

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define int int64_t
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);	

int x,n,i;
cin>>x>>n;
vector<int> v(n);
for(i=0;i<n;i++)cin>>v[i];

sort(v.begin(),v.end());

int prev=0,frwd=0;
prev=x;
while(binary_search(v.begin(),v.end(),prev))prev-=1;	
frwd=x;
while(binary_search(v.begin(),v.end(),frwd))frwd+=1;

if((x-prev)<=frwd-x)
    cout<<prev;
else
   cout<<frwd;    	

return 0;	
}


Measured memory_bytes: 3624
n = int(input())
a = list(map(int, input().split()))
f = 1
for i in a:
    if (i%2)==0:
        if (i%3)==0 or (i%5)==0:
            continue
        else:
            f =0
            break
    
if f:
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 3060
#include <stdio.h>

int main(){
	
	int a,b,c,d;
	scanf("%d %d %d",&a,&b,&c);
	if(a>b){
		d=a;
		a=b;
		b=d;
	}
	if(b>c){
		d=b;
		b=c;
		c=d;
	}
	if(a>b){
		d=a;
		a=b;
		b=d;
	}
	printf("%d %d %d\n",a,b,c);
	
	return 0;
}


Measured memory_bytes: 596
import java.util.Scanner;

//Card Game
public class Main{

	int[] a, b;
	boolean[] u;
	int res;
	
	void dfs(int k, int pa, int pb){
		if(k==9){
			res+=pb<pa?1:0;
			return;
		}
		for(int i=0;i<9;i++){
			if(u[i])continue;
			u[i] = true;
			dfs(k+1, pa+(b[k]<a[i]?a[i]+b[k]:0), pb+(b[k]<a[i]?0:a[i]+b[k]));
			u[i] = false;
		}
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		while(T--!=0){
			a = new int[9]; b = new int[9]; u = new boolean[9];
			for(int i=0;i<9;i++)a[i]=sc.nextInt();
			for(int i=0;i<9;i++)b[i]=sc.nextInt();
			res = 0;
			dfs(0, 0, 0);
			double x = res*1.0/362880;
			System.out.printf("%.5f %.5f\n", x, 1-x);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

int n;
double a[222],b[222],d[222];

double calc(int i,double m) {
  double t=d[i-1],ans=0;
  ans+=t*m+m*m/2;
  t+=m;
  if(t>b[i]) ans-=(t-b[i])*(t-b[i]);
  t-=a[i]-m;
  d[i]=t;
  ans+=t*(a[i]-m)+(a[i]-m)*(a[i]-m)/2;
  double sum=0;
  REP(j,i+1,n) {
    if(t-sum>b[j]) return -MAX;
    sum+=a[j];
  }
  return ans;
}
void Main() {
  R n;
  REP(i,1,n+1) R a[i];
  REP(i,1,n+1) R b[i];
  n+=2;
  a[0]=a[n-1]=b[0]=b[n-1]=0;
  double ans=0;
  mem(d);
  REP(i,1,n-1) {
    double l=0,r=a[i];
    rep(tt,300) {
      double m1=(l*2+r)/3,m2=(l+r*2)/3;
      double d1=calc(i,m1),d2=calc(i,m2);
      if(d1>=d2) r=m2;
      else l=m1;
    }
    ans+=calc(i,l);
  }
  printf("%.10f",ans);
}

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


Measured memory_bytes: 384
S = input()
l = ["hi", "ta", "chi"]
ans = "Yes"

n = []
for i in range(len(S)):
  if i not in n:
    if S[i: i + 2] in l:
      n.append(i + 1)
      continue
    elif S[i: i + 3] in l:
      n.append(i + 2)
    else:
      ans = "No"
      break
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e+9;

int main() {
	ll n, tmp = 0;
	ull sum = 0, os = 0;
	cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		sum += a[i];
		if (i % 2 == 1) os += a[i];
	}
	sum /= 2;
	tmp = (sum - os) * 2;
	for (int i = 0; i < n; ++i) {
		if (i == n - 1) cout << tmp << endl;
		else cout << tmp << " ";
		tmp = 2 * a[i] - tmp;
	}
	return 0;
}

Measured memory_bytes: 2048
#include <string>
#include <utility>
#include <iostream>
 
#define MAX 100

#define INF 100000000

int left[MAX];
int right[MAX];

int DP[MAX][MAX];

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

  for(int i = 0; i < n; i++){
    std::cin >> left[i];
    std::cin >> right[i];
  }
  
  for(int i = 0; i < MAX; i++){
    for(int j = 0; j < MAX; j++){
      DP[i][j] = INF;
   }
  }

  for(int k = 0; k < n; k++){
    for(int l = 0; l + k < n; l++){
      int r = l + k;
      
      if(k == 0){
	DP[l][r] = 0;
      }else if(k == 1){
	DP[l][r] = left[l] * right[l] * right[r];
      }else{
	for(int t = l; t < r; t++){
	 
	  DP[l][r] = std::min(DP[l][r], DP[l][t] + DP[t + 1][r] + left[l] * right[t] * right[r]);
	}

	// printf("%d %d %d\n", l, r, DP[l][r]);
      }
    }
  }
  
  std::cout << DP[0][n - 1] << std::endl;
}

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

int N;
string s;
int flag[110];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> s;
  stack<int> st;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '(') {
      st.emplace(i);
    } else if (!st.empty()) {
      flag[i] = flag[st.top()] = 1;
      st.pop();
    } 
  }
  int L = 0, R = 0;
  for (int i = 0; i < s.size(); i++) {
    if (flag[i]) continue;
    L += s[i] == ')';
    R += s[i] == '(';
  }
  cout << string(L, '(') << s << string(R, ')') << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int comp(const void *a, const void *b) {
    return *(int*)a - *(int*)b;
}
int main() {
  int n,c,k,t[100000],x,i,a;
  scanf("%d %d %d",&n,&c,&k);
  for (i=0;i<n;i++) {
    scanf("%d",&t[i]);
  }
  qsort(t, n, sizeof(int), comp);
  for (i=0;i<n;i+=a) {
    a=0;
    while (a<c&&t[i+a]-t[i]<=k) {
      a++;
    }
    x++;
  }
  printf("%d\n",x);
  return 0;
}

Measured memory_bytes: 892
// https://atcoder.jp/contests/abc162/tasks/abc162_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    string s;
    cin >> s;
    vector<int> tr, tg, tb;
    REP(i, N) {
        if (s[i] == 'R') {
            tr.emplace_back(i);
        } else if (s[i] == 'G') {
            tg.emplace_back(i);
        } else {
            tb.emplace_back(i);
        }
    }
    int ans = (int)tr.size() * tg.size() * tb.size();
    REP(i, N - 2) {
        for (int d = 1; i + 2 * d < N; ++d) {
            if (s[i] != s[i + d] && s[i] != s[i + 2 * d] &&
                s[i + d] != s[i + 2 * d]) {
                ans--;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3696
use proconio::input;
fn main() {
    input!{
        n: usize,
        k: usize,
        p: [usize ;n],
    };
    let mut sp = p;
    let mut ans = 0;
    sp.sort();
    for i in 0..k {
        ans += sp[i];
    }
    println!("{}", ans);
}

Measured memory_bytes: 2192
N,Y = map(int,input().split())
res = 0
for i in range(N+1):
	for j in range(N+1-i):
		if 10000*i+5000*j+1000*(N-i-j) == Y:
			if res == 1:
				break
			print(i,j,N-i-j)
			res = 1
if res == 0:
	print(-1,-1,-1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)    \
  for (auto v : (V)) { \
    cerr << v << " ";  \
  }                    \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
#define pint pair<int, int>
using namespace std;
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 (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> using vec = std::vector<T>;
template <class T> void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567, INF2 = INF * INF;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  vec<int> a(N);
  REP(i, N) cin >> a[i];
  vec<int> dp(N, INF);
  reverse(ALL(a));
  REP(i, N) {
    auto itr = upper_bound(ALL(dp), a[i]);
    *itr = a[i];
  }
  int pos = lower_bound(ALL(dp), INF) - dp.begin();
  print(pos);
}

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

int main(){

    lint k,n;
    cin >> k >> n;

    vector<lint> a(n);

    rep(i,n){
        cin >> a[i];
    }

    lint dis = 0;
    lint dsmax = 0;

    for(int i = 1; i < n; ++i){
        dsmax = max(dsmax, a[i]-a[i-1]);
        dis += a[i]-a[i-1];
    }

    dsmax = max(dsmax, a[0]+(k-a[n-1]));
    dis += a[0]+(k-a[n-1]);

    cout << dis-dsmax << endl;

}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define vl vector <long>
#define vll vector < ll >
#define pll pair < ll , ll >
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define MODCONST 1000000007
#define pinf 1e+18L+7
#define ninf 1e-18L+7

using namespace std;

void solve()
{
    ll h,w;
    cin>>h>>w;
    vector<string> vs;
    string k;
    rep(i,0,h){
        cin>>k;
        vs.pb(k);
        // cout<<vs[i]<<endl;
    }
    ll dp[h][w];
    dp[0][0] = 1;
    rep(i,1,h){
        if(vs[i][0]=='#') dp[i][0] = 0;
        else dp[i][0] = dp[i-1][0];
    }
    rep(i,1,w){
        if(vs[0][i]=='#') dp[0][i] = 0;
        else dp[0][i] = dp[0][i-1];
    }
    rep(i,1,h){
        rep(j,1,w){
            if(vs[i][j]=='#'){
                dp[i][j] = 0;
            }
            else{
                dp[i][j] = (dp[i-1][j] + dp[i][j-1])%MODCONST;
            }
        }
    }
    cout<<dp[h-1][w-1]<<endl;
}

int main()
{
    fastio ;
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    ll tc=1;
    //cin>>tc; //for number of testcases
    //ll ts = tc;
    while(tc--){
        //cout<<"Case #"<<ts-tc<<": ";
        solve();
    }
    return 0;
}


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

using namespace std;

int main()
{
    long long n , m ;
    cin >> n >>  m ;
    if(n%3==0 || m%3==0) cout<<0;
    else{
        long long ans = min(n,m);
        for(int i = 1 ; i< n ; i++){
            long long a = i*m ;
            long long b = (n-i)*(m/2);
            long long c = (n-i)*(m/2+(m&1));
            ans = min(ans ,max(a,max(b,c)) - min(a , min(b,c)) );
//            cout << a << ' ' << b << ' ' << c <<endl;
        }

        for(int i = 1 ; i< m ; i++){
            long long a = n*i ;
            long long b = (m-i)*(n/2);
            long long c = (m-i)*(n/2+(n&1));
            ans = min(ans ,max(a,max(b,c)) - min(a , min(b,c)) );
        }
        cout<<ans;
    }
    return 0;
}


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

int main(){
  char str[2000];
  int i, j;
  fgets(str, 2000, stdin);
  for(i = 0;i < strlen(str);i++){
    if(strncmp(&str[i], "apple", 5) == 0)strncpy(&str[i], "peach", 5);
    else if(strncmp(&str[i], "peach", 5) == 0) strncpy(&str[i],"apple", 5);
  }
  printf("%s", str);
  return 0;
}

Measured memory_bytes: 520
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
    long long x;
    cin>>x;
    long double p=100;
    for(int i=1;;i++)
    {
        p=floor(p*1.01);
        if(p>=x)
        {
            cout<<i;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii; 
const int N = 2e5+10;

void solve() {
    char c; cin >> c;
    if (isupper(c)) {
        cout << 'A' << endl;
    } else {
        cout << 'a' << endl;
    }
}

int main(void) {
    int t; t = 1;
    while (t--) solve();
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}




int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll N ; cin >> N;
  map<ll,ll> cnt;
  vector<ll> poss;
  
  rep(i,N){
    ll inp; cin >> inp;
    poss.pb(inp);
    poss.pb(inp+1);
    poss.pb(inp-1);
    cnt[inp]++;
    cnt[inp+1]++;
    cnt[inp-1]++;
  }

  rmsame(poss);

  ll ans = 0;
  rep(i,poss.size()){
    ans = max(ans, cnt[poss[i]]);
  }
  cout << ans << endl;

  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 12144
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
#define REV(i, f, t) for(int i=int(f); i>=int(t); --i)
#define ALL(v) (v).begin(), (v).end()
bool RELAXED = false;
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = (rhs.val > lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = (rhs.val < lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T> inline vector<T> readVector(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> void PRINT(T container, bool withSize) { if(withSize) cout<<container.size()<<endl; for(auto it : container) cout<<it<<" "; cout<<endl; }
template<typename T> void EXIT(T answer) { cout<<answer<<endl; exit(0); }
typedef signed long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

const int MOD = 1e9+7;
const int MAXHW = 2e5 + 5;
int H,W,N;
ll fac[MAXHW];
ll invfac[MAXHW];

ll inverseModulo(ll a, ll b){
    return 1<a ? b - inverseModulo(b % a, a) * b / a : 1;
}
ll binomial(int n, int k) {
    if(k==0 || n-k==0) return 1;
    return fac[n] * invfac[k] % MOD * invfac[n-k] % MOD;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    fac[0] = 1;
    RNG(i, 1, MAXHW) {
        fac[i] = i * fac[i-1] % MOD;
        invfac[i] = inverseModulo(fac[i], MOD);
    }

    cin>>H>>W>>N;
    vpii a;
    FOR(i,N) {
        int r,c; cin>>r>>c;
        a.push_back({r, c});
    }
    a.push_back({H,W});
    sort(ALL(a));

    map<pii, int> dp;

    for(auto pos : a) {
        int r,w;
        tie(r,w) = pos;

        ll comb = binomial(r+w-2, w-1);

        for(auto xy : a) {
            if(xy>=pos)
                break;
            if(xy.second <= w) {
                ll between = binomial(pos.first-xy.first + pos.second-xy.second, pos.second-xy.second);
                comb -= between * dp[xy] % MOD;
            }
        }

        dp[pos] = (comb % MOD + MOD) % MOD;
    }

    cout<<dp[{H,W}]<<endl;

    return 0;
}



Measured memory_bytes: 3584
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static int S(long n)
        {
            int sum = 0;
            while (n > 0)
            {
                sum += (int)(n % 10);
                n /= 10;
            }
            return sum;
        }
        static long Next(long n)
        {
            long n1 = n;
            int d1 = S(n);
            for (long i = 10; i <= n; i *= 10)
            {
                long n2 = n - (n % i) + (i - 1);
                int d2 = S(n2);
                if (n2 * d1 < n1 * d2)
                {
                    n1 = n2;
                    d1 = d2;
                }
            }
            return n1;
        }
        static IEnumerable<long> Solve(int K)
        {
            var list = new List<long>();
            long n = 0;
            for (int i = 0; i < K; ++i)
            {
                n = Next(n + 1);
                list.Add(n);
            }
            return list;
        }
        static void Main(string[] args)
        {
            int K = ReadInt();
            foreach (var ans in Solve(K))
            {
                Console.WriteLine(ans);
            }
        }
    }
}


Measured memory_bytes: 11328
N = int(input())
H = list(map(int, input().split()))
if N == 1:
    print("Yes")
    exit()
top = 0
for i in range(0, N-1):
    top = max(H[i], top)
    if (top-H[i+1]) > 1:
        print("No")
        exit()
print("Yes")


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

int main() {
    int n, k, l, j;
    long long left = 0;
    long long right = 1000000000;
    long long mid = 0;
    long long P;
    cin >> n >> k;
    long long load[100000];
    for (int i=0; i<n; i++) {
        cin >> load[i];
    }
    while (left < right -1) {
        mid = (left + right)/2;
        j = 0;
        for (int i=0; i<k; i++) {
            P=0;
            while(P + load[j] <= mid && j!=n) {
                P += load[j];
                j++;
            }
            if (j==n) {
                l=n;
                break;
            }
        }
        if (j!=n) {
            l=j;
        }
        if (l>=n) {
            right = mid;
        } else {
            left = mid;
        }
    }
    cout << right << endl;
}


Measured memory_bytes: 3876
N,M,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
maxx=max(x)
miny=min(y)

ans=0
for i in range(maxx+1,miny+1):
  if i>X and i<=Y:
    ans=1
    break
print("No War" if ans else "War")

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication7
{
    class SumOf4Integers
    {
        static void Main(string[] args)
        {
            while(true)
            {
                string line = System.Console.ReadLine();
                if(string.IsNullOrEmpty(line))
                {
                    return;
                }
                int n = Int32.Parse(line);
                int count = 0;
                int sum = 0;
                if (n <= 0 || n >= 37)
                {
                    System.Console.WriteLine(0);
                }
                else
                {
                    for (int a = 0; a < 10; a++)
                    {
                        for (int b = 0; b < 10; b++)
                        {
                            for (int c = 0; c < 10; c++)
                            {
                                for (int d = 0; d < 10; d++)
                                {
                                    sum = a + b + c + d;
                                    if (sum == n)
                                    {
                                        count++;
                                    }
                                }
                            }
                        }
                    }
                    System.Console.WriteLine(count);
                }
            }
        }
    }
}

Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
const int MAXN = (int) 1e6 + 10;
const int MOD = (int) 1e9 + 7;

char a[110];
int main(){
	scanf("%s", a + 1);
	int n = strlen(a + 1);
	for (int i=1; i<=n; i++) {
		if (i % 2 == 1) {
			if (a[i] == 'L') {
				puts("No");
				return 0;
			}
		} else {
			if (a[i] == 'R') {
				puts("No");
				return 0;
			}
		}
	}
	puts("Yes");
    return 0;
}


Measured memory_bytes: 256
// :)
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <sstream>
#include <stack>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <utility>
#include <vector>

typedef long long ll;

using namespace std;

std::random_device rd_device;
std::mt19937 rng(rd_device());

int main() {
    ios::sync_with_stdio(false);
    cin.exceptions(ios_base::failbit);
    cin.tie(NULL);
    cout.tie(NULL);
    cout.precision(10);
    cout<<fixed;
    
    double conversion = 380000.0;

    int n;
    cin>>n;
    ll j=0;
    double b=0;

    while (n--) {
        string a;
        string u;
        cin>>a>>u;
        if (u == "BTC") {
            b += stod(a);
        } else {
            j += stoll(a);
        }
    }

    cout<<j+b*conversion<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    int a,b,c,d,e,k;
    int mx,mn;
    cin >> a >> b >> c >> d >> e >> k;
    mx=a,mn=a;
    if(mx<b)mx=b;
    if(mx<c)mx=c;
    if(mx<d)mx=d;
    if(mx<e)mx=e;
    if(mn>b)mn=b;
    if(mn>c)mn=c;
    if(mn>d)mn=d;
    if(mn>e)mn=e;
    if(mx-mn<=k)cout << "Yay!";else cout << ":(";
    return 0;
}


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

int main() {
   int 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;}
}

Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        final String S = sc.next();
        final String T = sc.next();
        
        int diff = 0;
        for (int i = 0; i < S.length(); i++) {
            if (S.charAt(i) != T.charAt(i)) {
                diff++;
            }
        }
        
        System.out.println(diff);
    }
}


Measured memory_bytes: 41200
<?php
/*
    Problem URL : http://abc060.contest.atcoder.jp/tasks/abc060_a

    Score  :
    Result :
    Time   : ms
    Memory : KB
 */

list($A, $B, $C) = explode(" ", trim(fgets(STDIN)));

$Alast = substr($A, -1, 1);
$Bfirst = substr($B, 0, 1);
$Blast = substr($B, -1, 1);
$Cfirst = substr($C, 0, 1);

if (($Alast == $Bfirst) && ($Blast == $Cfirst)) {
    echo "YES\n";
} else {
    echo "NO\n";
}


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

int main(){
  string a, b;
  cin >> a >> b;
  int d = 0;
  for (int i = 0; i < a.size(); i++){
    d = d * 10 + (a[i] - '0');
  }
  for (int i = 0; i < b.size(); i++){
    d = d * 10 + (b[i] - '0');
  }

  for (int i = 0; i <= d; i++){
    if (i * i == d) {
      printf("Yes\n");
      return 0;
    }
  }
  printf("No\n");
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int width,spot;
  cin >> width >> spot;
  for (int i=spot-width+1;i<spot+width;i++){
    cout << i;
    if (i==spot+width-1){
      cout << endl;
    }else{
      cout << " ";
         }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>

using namespace std;
int N;
string s;

int main() {
  cin >> N;
  cin >> s;
  int pos = 0;
  for (int i=0; i<N; i++) {
    char c = s.at(i);
    if (c == '(') {
      pos++;
    } else {
      pos--;
    }
    if (pos < 0) {
      s.insert(s.begin(), '(');
      pos++;
      i++;
      N++;
    }
  }
  while (pos > 0) {
    s.insert(s.end(), ')');
    pos--;
  }
  cout << s << endl;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let n: usize = sc.get();
    let mut fib = vec![0; n+1];
    fib[0] = 1;
    fib[1] = 1;
    for i in 2..n+1 {
        fib[i] = fib[i - 1] + fib[i - 2];
    }
    println!("{}", fib[n]);
}



Measured memory_bytes: 5032
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s,t;cin>>s>>t;
	int ans=INT_MAX;
	int n=s.size();
	int m=t.size();
	int val=0;
	for(int i=0;i<=(n-m);i++)
	{
		val=0;
		for(int j=i;j<(i+m);j++)
		{
			if(s[j]!=t[j-i])
			{
				val++;
			}
		}
		ans=min(ans,val);
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, N, a, b) for(int i = a; i < N; i += b)

int main(){
	int N, M;
	cin >> N >> M;

	vector<int> city(N, 0);
	rep(i, M * 2){
		int a;
		cin >> a;
		city.at(a - 1)++;
	}
	rep(i, N) cout << city.at(i) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    vector<pair<string, pair<int,int> > >v;
    int n;
    cin >> n;
    for(int i = 0;i < n;i++)
    {
        string s;
        int p;
        cin >> s >> p;
        v.push_back(make_pair(s,make_pair((-1)*p,i+1)));
    }

    sort(v.begin(), v.end());

    for(int i = 0;i < n;i++)
    {
        cout << v[i].second.second << endl;
    }

}

Measured memory_bytes: 256
#define MAXN 701
#define INF 0xfffffffffffffff

#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cmath>

using namespace std;

typedef unsigned long long int ull;

int main(int argc,char** argv) {
	string s;
	int n;
	cin >> n;
	map<char,int> k;
	for(int i = 0;i < n;i++) {
		map<char ,int> t;
		cin >> s;
		for(auto e:s) {
			t[e]++;
		}
		if(i == 0) {
			k = t;
		}
		else {
			for(auto& e:k) {
				e.second = min(e.second,t[e.first]);
			}
		}
	}
	for(auto& e:k) {
		for(int i = 0;i < e.second;i++) cout << e.first;
	}
	cout << endl;
}


Measured memory_bytes: 256