akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<int,int> P;
typedef tuple<ll,int,int> T;
#define fi first
#define se second
#define all(v) (v).begin(),v.end()
set<string> c;
const ll mod=1000000007;
const ll mod2=998244353;
const ll inf=100000000000000000;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
vector<int> dy={-1,0,1,0},dx={0,-1,0,1};
int main(){
string s,t={},u={};
cin>>s;
int n=s.size();
for(int i=0;i<n;i++){
    if(i+1<n&&s[i]=='B'&&s[i+1]=='C'){
    t.push_back('D');
    i++;
  }
    else t.push_back(s[i]);
}
n=t.size();
ll ans=0;
string tmp={};
int cnt=0;
//cout<<t<<endl;
for(int i=0;i<n;i++){
     if(t[i]=='A'){
         cnt++;
         int now=i;
             while(i+1<n&&t[i+1]=='D'){ans+=cnt;i++;}
         }
      else cnt=0;
}
cout<<ans<<endl;
}

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

int main() {
  int n, y;
  cin >> n >> y;
  
  int a = -1;
  int b = -1;
  int c = -1;
  
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n-i; j++) {
      if (10000*i + 5000*j + 1000*(n-i-j) == y) {
        a = i;
        b = j;
        c = n-i-j;
      }
    }
  }
  
  cout << a << " " << b << " " << c << endl;
}

Measured memory_bytes: 256
def main():
    N, M, *A = map(int, open(0).read().split())

    C = [0, 1, 4, 4, 3, 4, 5, 2, 6, 5]

    dp = [0] * N + [-1] * 9
    for i in range(N):
        dp[i + 1] = max(a + 10 * dp[i - C[a]] for a in A)

    print(dp[N])

if __name__ == '__main__':
    main()


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

using namespace std;

using int64 = long long;

vector< bool > get_prime(int n) {
  vector< bool > prime(n + 1, true);

  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;

  for(int i = 2; i * i <= n; i++) {
    if(prime[i]) {
      for(int j = i + i; j <= n; j += i) prime[j] = false;
    }
  }
  return (prime);
}

int main() {
  auto p = get_prime(55555);
  vector< int > ans;
  for(int i = 1; i < p.size(); i += 10) {
    if(p[i]) {
      ans.push_back(i);
    }
  }
  int N;
  cin >> N;
  for(int i = 0; i < N; i++) cout << ans[i] << " ";
  cout << endl;
}

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

typedef long long ll;
typedef long long ll; 
typedef vector<ll> vi; 
typedef pair<int, int> ii; 
typedef vector<ii> vii; 
typedef vector<vi> vvi;
#define sz(a) int((a).size())
#define F first
#define S second
#define pb emplace_back
#define int long long
#define M 1000000007
#define watch(x) cout << (#x) << " is " << (x) << endl
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr(i,a,b) for(int i = a; i<= b; i++)
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())

main() {
    IOS;
  
    int n;
    cin >> n;

    int ar[n+1], dp[n+1];
  	dp[1] = 0;
  	fr (i,1,n) {
  		cin >> ar[i];
  	}
  	dp[2] = abs(ar[2]-ar[1]);

  	for (int i = 3; i <= n; i++) {
  		dp[i] = min(dp[i-1] + abs(ar[i]-ar[i-1]), dp[i-2] + abs(ar[i] - ar[i-2]));
  	}

  	cout << dp[n];
}

Measured memory_bytes: 1792
IDENTIFICATION                   DIVISION.
PROGRAM-ID.                      PRACTIVE-B.
ENVIRONMENT                      DIVISION.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.

01 NAGASA                        PIC 9(3).
01 I-DATA                        PIC X(100).
01 TUIKA-DATA                    PIC X(3) VALUE '...'.
01 IDX                           PIC 9(3).
01 END-FLAG                      PIC 9(1).
01 CHK-NAGASA                    PIC 9(3).

PROCEDURE DIVISION.
ACCEPT    NAGASA.
ACCEPT    I-DATA.
MOVE      1  TO IDX.
MOVE      0  TO END-FLAG.
COMPUTE CHK-NAGASA = NAGASA + 1.
PERFORM  
  UNTIL  IDX  >  NAGASA 
           OR
         END-FLAG = 1
  IF I-DATA(IDX:1) NOT = SPACE
  THEN
      CONTINUE
  ELSE
      DISPLAY I-DATA(1:IDX)
      MOVE  1  TO  END-FLAG
  END-IF
  COMPUTE  IDX = IDX + 1
END-PERFORM.

IF  IDX = 101
THEN
    DISPLAY I-DATA(1:NAGASA)
ELSE
    IF  END-FLAG NOT = 1
    THEN
        IF  I-DATA(CHK-NAGASA:1) = SPACE
        THEN
            DISPLAY I-DATA(1:NAGASA)
        ELSE
            DISPLAY I-DATA(1:NAGASA)TUIKA-DATA
    END-IF
END-IF.
STOP RUN.

Measured memory_bytes: 3876
l = input()

ans = 1
mod = 10**9+7
strict = 1
# st_m = 0
easy = 0
# ea_m = 0
for i in range(len(l)):
    if l[i] == "1":
        easy *= 3
        easy %= mod

        easy = easy + strict
        # ea_m += st_m
        strict *= 2
        # st_m *= 2
        # st_m += strict//mod
        strict %= mod

    else:
        easy *= 3
        # ea_m *= 3
        # ea_m += easy//mod
        easy %= mod
    # print(easy,strict)

# print(easy,strict)

print((easy+strict)%mod)

Measured memory_bytes: 40432
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int fun(int arr[][3],int dp[][3],int i,int j)
{
     if(dp[i][j]!=-1)
        return dp[i][j];
    else
    {
        int x,y,z;
        x=y=z=INT_MIN;
      if(j==0)
      {
          dp[i][j] = arr[i][j] + max(fun(arr,dp,i+1,1), fun(arr,dp,i+1,2));
          return dp[i][j];
      }
      else if(j==1)
      {
          dp[i][j] = arr[i][j] +  max(fun(arr,dp,i+1,0), fun(arr,dp,i+1,2));
            return dp[i][j];
      }
      else
      {
          dp[i][j] = arr[i][j] + max(fun(arr,dp,i+1,0), fun(arr,dp,i+1,1));
            return dp[i][j];
      }
    }
}

int main()
{
   int n;
   cin>>n;
   int arr[n][3];
   int dp[n+1][3];
   for(int i=0;i<n;i++)
   {
       for(int j=0;j<3;j++)
        {
            cin>>arr[i][j];

        }
   }
   for(int i=0;i<n+1;i++)
   {
       for(int j=0;j<3;j++)
        dp[i][j]=-1;
   }
   dp[n][0]=dp[n][1]=dp[n][2]=0;

   int x,y,z;
   x=y=z=INT_MIN;
     x = arr[0][0] + max(fun(arr,dp,1,1), fun(arr,dp,1,2));
     y = arr[0][1] + max(fun(arr,dp,1,0), fun(arr,dp,1,2));
     z = arr[0][2] + max(fun(arr,dp,1,0), fun(arr,dp,1,1));
    cout<<max(x,max(y,z));
}


Measured memory_bytes: 8832
<?php
  list($n,$m)=explode(" ",trim(fgets(STDIN)));

  $ans=array_fill(1,$m,0);
  for($i=0;$i<$n;$i++){
    $a=explode(" ",trim(fgets(STDIN)));
    for($j=1;$j<=$a[0];$j++){
      $ans[$a[$j]]++;
    }
  }

  $cnt=0;
  for($i=1;$i<=$m;$i++){
    if($ans[$i]==$n){
      $cnt++;
    }
  }
  echo $cnt;

Measured memory_bytes: 15572
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int t = sc.nextInt();

        System.out.println(t < a ? 0 : b * (t / a));
    }
}

Measured memory_bytes: 23124
import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int x = sc.nextInt();
    int a[] = new int [m];
    for(int i = 0;i < m;i++){
      a[i] = sc.nextInt();
    }
    int count1 = 0;
    int count2 = 0;
    for(int i = x;i < n+1;i++){
      for(int j = 0;j < m;j++){
        if(i == a[j]){
          count1++;
        }
      }
    }
    for(int i = x;i != n;i--){
      for(int j = 0;j < m;j++){
        if(i == a[j]){
          count2++;
        }
        if(i == 0){
          i = n + 1;
        }
      }
    }
    if(count1 < count2){
      System.out.println(count1);
    }else{
      System.out.println(count2);
    }
  }
}

Measured memory_bytes: 21844
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/tag_and_trait.hpp>
// using namespace __gnu_pbds;
// #include<boost/multiprecision/cpp_int.hpp>
// namespace multiprecisioninteger = boost::multiprecision;
// using cint=multiprecisioninteger::cpp_int;
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
// using llset=tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;
#define For(i,a,b) for(i=a;i<(ll)b;++i)
#define bFor(i,b,a) for(i=b,--i;i>=(ll)a;--i)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N,0)
#define brep1(i,N) bFor(i,N,1)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define eb emplace_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
#define matoutput(v) do{for(auto outimat:v)output(outimat);}while(0)
const ll mod=1000000007;
// const ll mod=998244353;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

bool solve(ll N){
  cout<<"? "<<N<<endl;
  string s;
  cin>>s;
  return s[0]=='Y';
}
int main(){
  ll ok,ng=10;
  while(solve(ng)&&ng<mod)ng*=10;
  if(ng==10000000000){
    ok=10;
    while(!solve(ok-1))ok*=10;
    print("! "<<ok/10);
    return 0;
  }
  ok=ng/10;
  while(ng-ok>1){
    ll mid=(ok+ng)>>1;
    (solve(mid*10)?ng:ok)=mid;
  }
  print("! "<<ng);
}

Measured memory_bytes: 596
package main

import (
	"fmt"
)

func main() {
	var K int
	var S int
	fmt.Scan(&K)
	fmt.Scan(&S)

	var counter int
	counter = 0
	for i := 0; i <= K; i++ {
		for j := 0; j <= K; j++ {
			k := S - i - j
			if k <= K && k >= 0 {
				counter++
			}
		}
	}
	fmt.Println(counter)
}


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

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

  vector<string> vs;
  string dummy(w + 2, 'd');
  vs.push_back(dummy);
  for (int i = 0; i < h; i++) {
    string s;
    cin >> s;
    s = 'd' + s + 'd';
    vs.push_back(s);
  }
  vs.push_back(dummy);

  int ans[h + 2][w + 2];
  for (int i = 0; i < h + 2; i++) {
    for (int j = 0; j < w + 2; j++) {
      ans[i][j] = 0;
    }
  }

  int move_x[] = {-1, -1, 0, 1, 1, 1, 0, -1};
  int move_y[] = {0, 1, 1, 1, 0, -1, -1, -1, 0};
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      if (vs[i][j] == '#') {
        ans[i][j] = -1e9;
        for (int k = 0; k < 8; k++) {
          ans[i + move_x[k]][j + move_y[k]]++;
        }
      }
    }
  }

  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      if (ans[i][j] < 0) {
        cout << '#';
      } else {
        cout << ans[i][j];
      }
    }
    cout << '\n';
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
typedef long long int ll; 
typedef long double ld; 
 
vector<pair<ll,ll>> vec[20];
ll n;
ll temp[20];
ll solve(ll id)
{
	if(id==n)return 0;
	ll c= 0;
	ll t[n];
	for(ll i=0;i<n;i++)
	{
		t[i] = temp[i];
	}
	
	if(temp[id]==0)
	{
		// if taking i as right
		
		ll flg = 1;
		
		for(ll i=0;i<vec[id].size();++i)
		{
			if(temp[vec[id][i].first]!=0 and temp[vec[id][i].first]!=vec[id][i].second)
			{
				flg = 0;
				break;
			} 
		}
		
		if(flg)
		{
			temp[id] = 2;
			for(ll i=0;i<vec[id].size();++i)
			{
				temp[vec[id][i].first] = vec[id][i].second;
			}
			c = 1+solve(id+1);
			for(ll i=0;i<n;i++)temp[i] = t[i];
		
		
			temp[id] = 1;
			c = max(c,solve(id+1));
		}
		else{
			temp[id] = 1;
			c = solve(id+1);
		
		}
		
		for(ll i=0;i<n;i++)temp[i] = t[i];
		
		
	}
	else{
		if(temp[id]==1)
		{
			c = solve(id+1);
		}
		else{
			ll flg = 1;
		
			for(ll i=0;i<vec[id].size();++i)
			{
				if(temp[vec[id][i].first]!=0 and temp[vec[id][i].first]!=vec[id][i].second)
				{
					flg = 0;
					break;
				} 
			}
		
			if(flg)
			{
				temp[id] = 2;
				for(ll i=0;i<vec[id].size();++i)
				{
					temp[vec[id][i].first] = vec[id][i].second;
				}
				c = 1+solve(id+1);
			}
		
			for(ll i=0;i<n;i++)temp[i] = t[i];
			
			if(flg==0)return -10000;
		
		}
	}
	
	
	return c;
}

int main()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n;
	memset(temp,0,sizeof(temp));
	
	for(ll i=0;i<n;i++)
	{
		ll ai;
		cin>>ai;
		
		for(ll j=0;j<ai;j++)
		{
			ll x,y;
			cin>>x>>y;
			vec[i].push_back({x-1,y+1});
		}
	}
	
	cout<<max(0LL,solve(0));
	
	return 0;
}


Measured memory_bytes: 256
N = int(input())
L = [2,1,3]
if N >= 3:
  for i in range(N-2):
    L[0] = L[1]
    L[1] = L[2]
    L[2] = L[0] + L[1]
  print(L[2])
else:
  print(L[N])

Measured memory_bytes: 9108
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>

using namespace std;

string data[10] = {"", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};

main(){
  int n;
  cin >> n;
  getchar();
  while(n--){
    char in;
    string out;
    char pre = '0';
    char c = 0;
    int p = 0;
    while(1){
      scanf("%c", &in);
      if(in == '\n') break;
      if(in == '0'){
        if(c != 0) out += c;
        c = 0;
      }else{
        if(pre != in) p = 0;
        else p = (p+1)%((int)data[in-'0'].size());
        c = data[in-'0'][p];
      }
      pre = in;
    }
    cout << out << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<62;
const LL INF=1<<17;



int main(){
    int N;
    cin >> N;
    for (int i = 1; i < 11; i++) {
        if(N<=111*i){
            cout << 111*i << endl;
            return 0;
        }
    }
    return 0;
}



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

using namespace std;


#define PI 3.14159265
#define int long long



main(){


	int n; cin >> n;

	vector <int> a(n + 1), b(n);


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


	for(int i = 0; i < n; i++){
		cin >> b[i];
	}


	int ans = 0;

	for(int i = 0; i < n; i++){
		int t1 = min(a[i], b[i]);
		ans += t1;
		b[i] -= t1;
		a[i] -= t1;
		int t2 = min(a[i + 1], b[i]);
		ans += t2;
		b[i] -= t2;
		a[i + 1] -= t2;
	}

	cout << ans << endl;
	


	// vector < pair <int, int> > d(n);

	// d[0].first = min(a[0], b[0]);
	// d[0].second = min(a[1], b[0]);

	// for(int i = 1; i < n; i++){
	// 	d[i].first = min(b[i], max(a[i] - b[i - 1], 0LL)) + d[i - 1].second;
	// 	d[i].first = max(d[i].first, d[i - 1].first + min(b[i], a[i]));
	// 	d[i].second = min(b[i], a[i + 1]) + max(d[i - 1].first, d[i - 1].second);
	// }


	// cout << max(d[n - 1].first, d[n - 1].second) << endl;



	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll N=310;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll a,b;cin>>a>>b;
    if(a<=0 && 0<=b)return cout<<"Zero" , 0;
    if(a>0)return cout<<"Positive" , 0;

    ll cnt = b-a+1;
    if(cnt&1)cout<<"Negative";
    else cout<<"Positive";
}



Measured memory_bytes: 256
let rec _solve n i j = if i * j == n then print_string "Yes" else match (i, j) with
   (1, 1) -> print_string "No"
 | (i, 1) -> _solve n (i-1) 9
 | (i, j) -> _solve n i (j-1)

let solve n = _solve n 9 9

let () = Scanf.scanf "%d" solve

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i > n; --i)
typedef long long ll;
#define mod 1000000007

int main() {
  int N; cin >> N;
  cout << (N/10 == 9 || N%10 == 9 ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

def main():

    s = input()
    listS = list(s)
    n = len(listS)

    aIndex = 0
    zIndex = 0

    for i in range(n):
        if listS[i] == 'A':
            aIndex = i
            break

    for i in range(n):
        if listS[-(i + 1)] == 'Z':
            zIndex = n - i
            break

    ans = zIndex - aIndex

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 10524
n=gets.to_i
dp=Array.new(n){gets.split.map &:to_i}
1.upto(n-1) do |i|
  0.upto(2) do |j|
    dp[i][j] += [dp[i-1][j-1],dp[i-1][j-2]].max
  end
end
puts dp.last.max


Measured memory_bytes: 9596
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <algorithm>
#define ii pair<int, int>
#define iii pair<ii, int>
#define pq priority_queue

using namespace std;

bool bfs(vector<vector<int>> adj_list, int goal_island) {
    queue<ii> possible;
    set<int> visited;
    possible.push(make_pair(0, 0));
    while (!possible.empty()) {
        int island = possible.front().first;
        int dist_from_start = possible.front().second;
        possible.pop();
        if (visited.find(island) == visited.end() && dist_from_start <= 2) {
            if (island == goal_island) {
                return true;
            }
            for (int adj_node : adj_list[island]) {
                possible.push(make_pair(adj_node, dist_from_start + 1));
            }
            visited.insert(island);
        }
    }
    return false;
}

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

    int n, m;
    cin >> n >> m;
    vector<vector<int>> adj_list(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        adj_list[a - 1].push_back(b - 1);
        adj_list[b - 1].push_back(a - 1);
    }
    cout << (bfs(adj_list, n - 1) ? "POSSIBLE" : "IMPOSSIBLE");
}

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

int main() {

    string s, t;

    cin >> s;
    cin >> t;

    int n = s.size();

    map<char, int> usedMapS;
    vector<int> sNum(n);
    int count = 0;

    for(int i = 0; i < n; ++i) {

        if(usedMapS.find(s[i]) == usedMapS.end()) {
            usedMapS[s[i]] = count++;
        }
        sNum[i] = usedMapS[s[i]];

    }

    usedMapS.clear();

    vector<int> tNum(n);
    count = 0;

    for(int i = 0; i < n; ++i) {

        if(usedMapS.find(t[i]) == usedMapS.end())
            usedMapS[t[i]] = count++;
        
        tNum[i] = usedMapS[t[i]];
    }

    if(tNum == sNum)
        cout << "Yes" << endl;
    else 
        cout << "No" << endl;

    return 0;

}

Measured memory_bytes: 5400
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a=n%10;
    if(a==2 || a==4 || a==5 || a==7 || a==9){
		cout<<"hon";
		return 0;
	}
	else if(a==0 || a==6 || a==1 || a==8){
		cout<<"pon";
		return 0;
	}
	else{
		cout<<"bon";
		return 0;
	}
} 


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
const int N=1005;
const int mod=1e9+7;
int main()
{
    int n;
    scanf("%d",&n);
    printf("ABC%d\n",n);
    return 0;
}






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

int main(int argc, char* argv[]) {
	int S;
	int h, m, s;
	cin >> S;

	h = S / 3600;
	m = (S - 3600 * h) / 60;
	s = S - 3600 * h - 60 * m;

	cout << h << ":" << m << ":" << s << endl;

	return 0;

}

Measured memory_bytes: 1168
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <cassert>
#include <random>
#include <stack>
#include <ctime>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;

int main() {
    long a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    long ans = 1e18;
    REP(i,1010101) {
        long na, nb;
        na = i / 2;
        nb = i / 2;
        na = max(0l, x - na);
        nb = max(0l, y - nb);
        ans = min(ans, i * c + na * a + nb * b);
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using LL=long long;
int main(){
  int N,K;cin>>N>>K;
  vector< pair<LL,vector<LL>> >T(N+1,{0,{}});
  for(int i=0;i<N;i++){
    int t;LL d;cin>>t>>d;
    T[t].second.push_back(d);
    T[t].first=max(T[t].first,d);
  }
  sort(T.begin(),T.end(),greater<>());
  for(int i=0;i<N;i++)
    sort(T[i].second.begin(),T[i].second.end(),greater<>());
  LL ans=0;
  LL now=0,nowsum=0;
  priority_queue<LL, vector<LL>, greater<LL>>que;
  for(int i=0;i<K&&T[i].second.size()>0;i++){
    now+=T[i].first+LL((i+1)*(i+1)-i*i);
    for(int j=1;j<T[i].second.size();j++){
      nowsum+=T[i].second[j];
      que.push(T[i].second[j]);
    }
    while(i+1+que.size()>K){
      nowsum-=que.top();que.pop();
    }
    if(i+1+que.size()==K){
      ans=max(ans,now+nowsum);
    }
  }
  cout<<ans<<endl;
}

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

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

    bool flg = true;
    for(int i=0; i<s.size()-1; i++){
        if(s[i]==s[i+1]) flg = false;
    }

    if(flg){
        cout << "Good" << endl;
    }else{
        cout << "Bad" << endl;
    }

}


Measured memory_bytes: 3548
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<vector>
#define N 500010
#define P pair<int,int>
#define MP make_pair
#define fi first
#define se second
using namespace std;
P tree[N<<2];
void change(int u,int l,int r,P x)
{
	tree[u]=max(tree[u],x);
	if(l==r) return;
	int mid=(l+r)>>1;
	if(x.se<=mid) change(u<<1,l,mid,x);
	else change(u<<1|1,mid+1,r,x);
}
P answer(int u,int l,int r,int L,int R)
{
	if(L<=l && r<=R) return tree[u];
	if(R<L) return MP(0,0);
	int mid=(l+r)>>1;
	P ans=MP(0,0);
	if(L<=mid) ans=max(ans,answer(u<<1,l,mid,L,R));
	if(R>mid) ans=max(ans,answer(u<<1|1,mid+1,r,L,R));
	return ans;
}
int nxt[N<<1],to[N<<1],head[N],in[N],cnt;
int p[N];
void add(int u,int v)
{
	nxt[++cnt]=head[u];
	to[cnt]=v;
	in[v]++;
	head[u]=cnt;
}
priority_queue<int,vector<int>,greater<int> > q;
int ans[N];
int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		int a;
		scanf("%d",&a);
		p[a]=i;
	}
	for(int i=1;i<=n;i++)
	{
		change(1,1,n,MP(i,p[i]));
		P l=answer(1,1,n,max(1,p[i]-k+1),p[i]-1),r=answer(1,1,n,p[i]+1,min(p[i]+k-1,n));
		if(l.fi>0) add(l.se,p[i]);
		if(r.fi>0) add(r.se,p[i]);
	}
	for(int i=1;i<=n;i++) if(!in[i]) q.push(i);
	int tot=0;
	while(!q.empty())
	{
		int u=q.top();
		q.pop();
		ans[u]=++tot;
		for(int i=head[u];i;i=nxt[i])
		{
			int v=to[i];
			in[v]--;
			if(!in[v]) q.push(v);
		}
	}
	for(int i=1;i<=tot;i++) printf("%d\n",ans[i]);
	return 0;
}


Measured memory_bytes: 28916
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
int main(void)
{
    int k,n;
    cin >> k >> n;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
    }
    int len = 0;
    for(int i=1; i<n; i++){
        len = max(len, a[i] - a[i-1]);
    }
    cout << k - max(len, (k-a[n-1]+a[0])) << endl;
    return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

ll cnt[20][20];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	ll ans = 0;
	rep(i,n){
		string s;
		cin >> s;
		ll a = 0;
		int p = 0;
		rep(j,s.size()){
			if(s[j] == '.'){
				p = s.size() - 1 - j;
				continue;
			}
			a = (a * 10 + (s[j] - '0'));
		}
		int two = 0, five = 0;
		while(a%2 == 0){
			++two;
			a /= 2;
		}
		while(a%5 == 0){
			++five;
			a /= 5;
		}
		two += 9 - p;
		five += 9 - p;
		chmin(two, 19);
		chmin(five, 19);
		rep(i,20)rep(j,20){
			if(two+i >= 18 && five+j >= 18) ans += cnt[i][j];
		}
		++cnt[two][five];
		//cout << s << " " << two << " " << five << endl;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <iomanip>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
#define int ll

using namespace std;
using Graph = vector<vector<int> >;


signed main() {
  int a, b, c; cin >> a >> b >> c;
  if ( c - (a - b) >= 0) {
    cout <<  c - (a - b) << endl;
  } else {
    cout << 0 << endl;
  }
}


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

using ll = long long;
#define repi(n) for (int i = 0; i < (n); i++)
#define repj(n) for (int j = 0; j < (n); j++)
#define repk(n) for (int k = 0; k < (n); k++)
#define rep(i, n) for (int i = 0; (i) < (n); i++)
#define repr(i, a, b) for (auto i = (a); i < (b); i++)
#define repv(itr) for (auto&& v : (itr))
#define updatemax(t, v) (t = max((t), (v)))
#define updatemin(t, v) (t = min((t), (v)))
const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
template <typename T>
T minptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i < *re) re = i;
  }
  return re;
}
template <typename T>
T maxptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i > *re) re = i;
  }
  return re;
}
int __vmax(int x) {
  return INT_MAX;
}
double __vmax(double x) {
  return 1e+300;
}
ll __vmax(ll x) {
  return LLONG_MAX;
}
int __vmin(int x) {
  return INT_MIN;
}
double __vmin(double x) {
  return -1e+300;
}
ll __vmin(ll x) {
  return LLONG_MIN;
}
template <typename T>
vector<T> lis(T begin, T end, bool allowequal = false, bool lds = false) {
  using V = typename iterator_traits<T>::value_type;
  int n = end - begin;
  vector<V> a(n, lds ? __vmin(*begin) : __vmax(*begin));
  vector<int> id(n);
  if (lds && allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (lower_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (lds) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (upper_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = upper_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  } else {
    for (int i = 0; i < n; i++) {
      id[i] = lower_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  }
  int m = *maxptr(id.begin(), id.end());
  vector<T> re(m + 1);
  for (int i = n - 1; i >= 0; i--) {
    if (id[i] == m) re[m--] = begin + i;
  }
  return re;
}
template <typename T>
class segtree {
 private:
  int n;
  vector<T> data, lazy;

 public:
  segtree(int n_) {
    n = pow(2, ceil(log2(n_)));
    data.resize(n);
    lazy.resize(n);
    auto __x = data[0];
    repi(n) {
      data[i] = __vmin(__x);
      lazy[i] = 0;
    }
  }
};

int main() {
  string s;
  cin >> s;
  int l = s.length();
  int result = INT_MAX;
  repi(l - 2) updatemin(result, abs((s[i] - '0') * 100 + (s[i + 1] - '0') * 10 +
                                    (s[i + 2] - '0') - 753));
  cout << result << endl;
}


Measured memory_bytes: 256
import math

def isPrime(x):
	for i in range(2,int(math.sqrt(x))+1):
		if x%i == 0:
			return 0
	return 1

n=int(input())
ans=0
for i in range(n):
	x=int(input())
	if isPrime(x):
		ans+=1
print(ans)


Measured memory_bytes: 5680
#include <stdio.h>

#define N 100 
#define INF 10000000

void matrixChainOrder(int *);
int min(int , int);

int n;

int main()
{

  int i, j;
  int p[N];

  scanf("%d", &n);

  for(i=0; i<n; i++){
    scanf("%d%d", &p[i], &p[i+1]);

    //   p[i] = P[i];
    //Node->int?????§????????????????§???????????????????
    //2?¬????????????§?????????->??±??????????????????????????¢??°???????????????
  }

  matrixChainOrder(p);

  return 0;

}

void matrixChainOrder(int *p)
{

  int i, j, l, k, q, f;
  int m[N][N];

  f = n;

  for(i=1; i<=f; i++){
    m[i][i] = 0;
  }

  for(l=2; l<=f; l++){
    for(i=1; i<=(f-l+1); i++){
      j = i+l-1;
      m[i][j] = INF;
      for(k=i; k<=(j-1); k++){
	q = m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j];
	m[i][j] = min(m[i][j], q);
      }
    }
  }

  printf("%d\n", m[1][n]);

}

int min(int m, int q) //??????????????£?????????
{

  if(m > q) return q;
  else return m; 

}

Measured memory_bytes: 632
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>

    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    using ll = long long;
	  
    int main(){
      string s;
      ll k;
      cin>>s>>k;
      ll ans;
      for(ll i=0;i<k;i++){
        if(i == k-1)ans = 1;
        if(s[i] == '1')continue;
        else {
          ans = s[i]-'0';
          break;
        }
      }
      cout<<ans;
    }

Measured memory_bytes: 256
fn main() {
    proconio::input! {
        n: usize,
        a_s: [i64; n],
        q: usize,
        bcs: [(i64, i64); q],
    }
    let mut a_s_sum = a_s.iter().sum::<i64>();
    let mut hm = std::collections::HashMap::new();
    for a in &a_s {
        *hm.entry(*a).or_insert(0) += 1;
    }
    for (b, c) in bcs {
        let b_num = *hm.get(&b).or(Some(&0)).unwrap();
        let diff = c - b;
        let ans = a_s_sum + b_num * diff;
        println!("{}", ans);
        a_s_sum = ans;
        hm.remove(&b);
        *hm.entry(c).or_insert(0) += b_num;
    }
}


Measured memory_bytes: 9500
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}
ll Mid(ll(a), ll(b), ll(c)) {
	return a+b+c-Max(a,b,c)-Min(a,b,c);
}

int gcd(ll(a), ll(b)) {
	ll c = a;
	while (a % b != 0) {
		c = a % b;
		a = b;
		b = c;
	}
	return b;
}



int main() {
	ll A, B, C,an;
	cin >> A >> B >> C;
	if ((A%2 * B%2 * C%2) == 0) {
		an = 0;
	}
	else {
		an =  ll(Min(A, B, C))* ll(Mid(A, B, C));
	}

	cout << an << endl;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
ans=-1
for i in range(max(a)):
    for j in range(len(a)):
        if a[j]%2==1:
            ans=i
            break
        else:
            a[j]=a[j]//2
    if ans!=-1:
        break
print(ans)


Measured memory_bytes: 2940
n, m = map(int, input().split())
cakes = [list(map(int, input().split())) for i in range(n)]

ans = 0
for bit in range(1<<3):
    flip = [(-1)**((bit>>i)&1) for i in range(3)]
    cakes.sort(key=lambda x: sum([x[i] * flip[i] for i in range(3)]), reverse=True)
    v = [sum([cakes[i][j] for i in range(m)]) for j in range(3)]
    ans = max(ans, sum(map(abs, v)))

print(ans)


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

using namespace std;
const int MAX = 100005;
long w[101];
int v[101];
long dp[MAX];
long n, W;
int sum;
int main()
{
	cin >> n >> W;
	for (int i = 1; i <= n; i++)
	{
		cin >> w[i] >> v[i];
		sum += v[i];
	}
	for (int i = 1; i <= sum; i++)
		dp[i] = -1;
	dp[0] = 0;
	int last = 0, check;
	for (int i = 1; i <= n; i++)
	{
		check = 1;
		for (int j = last; j >= 0; j--)
		{
			if (dp[j] >= 0)
			{
				if (check)
				{
					last = j + v[i];
					check = 0;
				}
				if (dp[j + v[i]] > -1)
					dp[j + v[i]] = min(dp[j + v[i]], w[i] + dp[j]);
				else
					dp[j + v[i]] = w[i] + dp[j];
			}
		}
	}
	
	for (int i = sum; i >= 0; i--)
	{

		if (dp[i] <= W && dp[i]>=0)
		{
			cout << i;
			break;
		}
	}
	return 0;
}


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

int main()
{
  vector<int> a(26);
  string s;
  cin>>s;
  for(auto i:s) a[i-'a']++;
  for(auto i:a) if(i>1) {cout<<"no\n";return 0;}
  cout<<"yes\n";
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
int main(void) {
  int n;
  cin >> n;
  int ans = 0;
  ans += min(9, n);
  ans += min(900, max(n - 99, 0));
  ans += min(90000, max(n - 9999, 0));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
// D - Squirrel Merchant
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	int n;
	cin >> n;
	vector<int> a(3), b(3), v(3);
	for (int i = 0; i < 3; i++) cin >> a[i];
	for (int i = 0; i < 3; i++) cin >> b[i];

	vector<long long> dp(n + 1);
	for (int i = 0; i < 3; i++) v[i] = b[i] - a[i];
	for (int i = 0; i <= n; i++)
		for (int j = 0; j < 3; j++)
			if (a[j] <= i) dp[i] = max(dp[i], dp[i - a[j]] + v[j]);

	int m = dp[n] + n;
	dp.assign(m + 1, 0);
	for (int i = 0; i < 3; i++) v[i] = a[i] - b[i];
	for (int i = 0; i <= m; i++)
		for (int j = 0; j < 3; j++)
			if (b[j] <= i) dp[i] = max(dp[i], dp[i - b[j]] + v[j]);

	cout << (dp[m] + m) << endl;
	return 0;
}


Measured memory_bytes: 195584
#include<stdio.h>

int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    if((a==1 && b==2) || (a==2 && b==1)){
        printf("3");
    }
    if((a==1 && b==3) || (a==3 && b==1)){
        printf("2");
    }
    if((a==3 && b==2) || (a==2 && b==3)){
        printf("1");
    }


	return 0;
}


Measured memory_bytes: 128
//============================================================================
// Name        : At_coder.cpp
// Author      : Ty
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#define LL long long
#include<iostream>
using namespace std;

int main(){
	LL N;
	LL num;
	LL a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,p=0;
	cin>>N;
	auto fix= [](int num){if(num==0){return 1;}else{return 0;}};
	for(int i=N;i>0;i--){
		cin>>num;
		if(num<400){
			a +=fix(a);
		}else if(400<=num && num<800){
			b+=fix(b);
		}else if(800<=num && num<1200){
			c+=fix(c);
		}else if(1200<=num && num<1600){
			d+=fix(d);
		}else if(1600<=num && num<2000){
			e+=fix(e);
		}else if(2000<=num && num<2400){
			f+=fix(f);
		}else if(2400<=num && num<2800){
			g+=fix(g);
		}else if(2800<=num && num<3200){
			h+=fix(h);
		}else {
			p++;
		}
	}
	if(a==0&&b==0&&c==0&&d==0&&e==0&&f==0&&g==0&&h==0){
		cout<<1<<" "<<p<<endl;
	}else{
	cout<<a+b+c+d+e+f+g+h<<" "<<a+b+c+d+e+f+g+h+p<<endl;
	}
	return 0;
}


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

int main()
{
    int X,A,B;
    scanf("%d %d %d",&X,&A,&B);
    if(B<=A)
        printf("delicious\n");
    if(B>A&&B<=(A+X))
        printf("safe\n");
    if(B>(A+X))
        printf("dangerous\n");
    return 0;
}


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

int main(){
    ll n;cin>>n;
    vector<ll> summ,diff;
    for(int i=0;i<n;++i){
        int x,y;cin>>x>>y;
        summ.push_back(x+y);
        diff.push_back(x-y);
    }
    sort(summ.begin(),summ.end());
    sort(diff.begin(),diff.end());
    ll ans1 = abs(summ[0] - summ[summ.size()-1]);
    ll ans2 = abs(diff[0] - diff[diff.size()-1]);
    cout<<max(ans1,ans2);

}

Measured memory_bytes: 6624
#include"bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long INT;
double PI = 3.14159265;
using namespace std;
using Graph = vector<vector<int>>;
using Field = vector<string>;
using DGraph = vector<vector<pair<int, int>>>;

const long long INF = 1LL << 60;
//---//
bool col[100010];
bool seen[100010];

void dfs(DGraph &g, int i) {
    seen[i] = 1;

    for (auto v : g[i]) {
        int fi = v.first, se = v.second;
  
        if (seen[fi]==1)continue;
        if (se % 2 == 0) {
            col[fi] = col[i];
        }
        else {
            col[fi] = !col[i];
        }
        dfs(g, fi);
    }
}

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

    DGraph g(N+1);
    
    rep(i, N - 1) {
        int a, b, c;
        cin >> a >> b >> c;
        g[a].push_back(make_pair(b, c));
        g[b].push_back(make_pair(a, c));
    }

    memset(seen, false, sizeof(seen));
    col[1] = 0;
    dfs(g,1);

    for (int i = 1; i <= N;i++)cout << col[i] << endl;

    return 0;
}

Measured memory_bytes: 8064
#!/usr/bin/python3
# -*- coding: utf-8 -*-
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
b_c_hash = {}
c_list = []
for i in range(0,m):
    b, c = map(int, input().split())
    if c in b_c_hash:
        b_c_hash[c] += b
    else:
        b_c_hash[c] = b
        c_list.append(c)
c_list.sort(reverse=True)
k = 0
flag = 0
for c in c_list:
    for i in range(0, b_c_hash[c]):
        if k == n:
            flag = 1
            break
        if a[k] < c:
            a[k] = c
            k += 1
        else:
            flag = 1
            break
    if flag == 1:
        break
print(sum(a))

Measured memory_bytes: 23412
a, b, c, k = map(int, input().split())
sum = 0
if a + b + c == k:
    sum = a - c
elif a + b <= k and a+b+c > k:
    sum = a-(k-(a+b))
elif a + b > k and a < k:
    sum = a
else:
    sum = k

print(sum)


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

using namespace std;

int W, H;
char room[20][20];

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

int sx, sy;

int dfs(int x, int y)
{
  room[y][x] = '#';
  int cnt = 1;
  for(int i = 0; i < 4; i++){
    int nx = x + dx[i], ny = y + dy[i];
    if(0 <= nx && nx < W && 0 <= ny && ny < H && room[ny][nx] != '#'){
      cnt += dfs(nx, ny);
    }
  }
  return cnt;
}

int main()
{
  while(cin >> W >> H, W || H){
    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
	cin >> room[i][j];
	if(room[i][j] == '@') sx = j, sy = i;
      }
    }
    cout << dfs(sx, sy) << endl;
  }
  return 0;
}

Measured memory_bytes: 1176
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)
#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())

#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7:合同式の法
 
int main(){
    ll n;
    double d;
    cin >> n >> d;

    vector<ll> x,y;
    REP(i,n){
        ll tmp1, tmp2;
        cin >> tmp1 >> tmp2;
        x.push_back(tmp1);
        y.push_back(tmp2);
    }
    ll count=0;
    REP(i,n){
        double tmp = sqrt(x[i]*x[i] + y[i]*y[i]);
        if(tmp<=d){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ll> point;
#define F first
#define S second



int main()
{
	#ifdef DGC
		//freopen("a.txt", "r", stdin);
		//freopen("b.txt", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int n;
	cin >> n;
	vector<int> a(n);
	for (auto &i : a) cin >> i;

	auto b = a;
	sort(b.begin(), b.end());

	for (int i = 0; i < n; ++i)
		for (int j = i; j < n; ++j)
		{
			auto c = a;
			swap(c[i], c[j]);
			if (c == b)
			{
				cout << "YES\n";
				return 0;
			}
		}

	cout << "NO\n";

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
void main(){
    char st[15], tr[15], ru[15];
    scanf("%s %s %s", st, tr, ru);
    st[0] = toupper( st[0] );
    tr[0] = toupper( tr[0] );
    ru[0] = toupper( ru[0] );

    printf("%c%c%c", st[0], tr[0], ru[0]);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <stack>
#include <queue>
#include <math.h>
#include <bitset>
#include <set>

using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;

#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
#define rep_r(i,s,n)for(int i = n-1;i>=s;i--)
#define repe_r(i,s,n)for(int i = n;i>=s;i--)

int main() {
	string s; cin >> s;
	ll b = 0;
	ll r = 0;
	ll ans = 0;
	rep(i, 0, s.size()) {
		if (s[i] == '0') {
			if (b > 0) {
				ans++;
				b--;
			}
			else {
				r++;
			}
		}
		else if (s[i] == '1') {
			if (r > 0) {
				ans++;
				r--;
			}
			else {
				b++;
			}
		}
	}

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

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

int32_t main()
{
    int a, b;
    cin >> a >> b;
    int  x1, x2;
    for(int i = 1; i < 1000;i++){
        x1 = (i * (i + 1)) / 2 - a;
        x2 = ((i+2) * (i + 1)) / 2 - b;
        if(x1 >= 1 && x1 == x2) {
            cout << x1  << endl;
            break;
        }

    }
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAXN 100001
#define w 1000000007
 
long long r[MAXN];
int main() {
    int N, M;
    cin >> N >> M;
    vector<int> a(M+1);
    vector<int> d(M+1);
    for (int i = 0; i < M; i++){
        cin >> a[i];
    }
    int maxv;
    if(M!=0){
        maxv = a[0];
        d[0] = a[0] - 1;
        maxv = max(maxv, d[M]);
        d[M] = N - a[M-1] - 1;
    }else{
        a[0] = N;
        d[0] = N;
        maxv = N;
    }
    for (int i = 1; i < M; i++){
        d[i] = a[i] - a[i-1] - 2;
        if(d[i] == -1){
            cout << 0 << endl;
            return 0;
        }
        maxv = max(maxv, d[i]);
        // cout << i << ","<<d[i] << "!"<<endl;
    }
    
    r[0] = 1;
    r[1] = 1;
    // cout << "max:"<< maxv<<endl;
    for (int i = 2; i < maxv+2; i++)
    {
        r[i] = (r[i-1] +  r[i-2]) % w;
        // cout<< r[i] <<"r"<<endl; 
    }

    long long ans = 1;
    for (int i = 0; i < M+1; i++){
            //cout <<(int)d[i]<<":  "<< r[(int)d[i]+1] <<"_"<<endl;
            ans =(ans * r[d[i]]) % w;
    }
    cout  << ans % w << endl;
    return 0;
}

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

public class Main {

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tok;

        public InputReader(InputStream inputStream) {
            reader = new BufferedReader(new InputStreamReader(inputStream));
            tok = null;
        }

        public InputReader(String inputFile) throws FileNotFoundException {
            reader = new BufferedReader(new FileReader(inputFile));
            tok = null;
        }

        public String nextLine() {
            String c = "";
            try {
                c = reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }

            return c;
        }

        public String next() {
            while (tok == null || !tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(nextLine());
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }

            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

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

    public static void main(String args[]) {
        InputStream inputstream = System.in;
        OutputStream outputstream = System.out;
        InputReader in = new InputReader(inputstream);
        PrintWriter out = new PrintWriter(outputstream);
        Task solver = new Task();
        solver.solve(in, out);
        out.flush();
    }

    static class Task {
        public void solve(InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = in.nextInt();
            int b[] = a.clone(); 
            for (int i = 0; i < n - 1; i++) {
                if (a[i] - a[i + 1] > 0)
                    a[i + 1] = a[i];
            }
            long stools=0;
            for(int i=0;i<n;i++){
                stools+=a[i]-b[i];
            }
            out.println(stools);
        }
    }
}

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

int main() {
    int n, m, c, ans = 0;
    cin >> n >> m >> c;
    vector<int> b(m);
    rep(i, m) cin >> b.at(i);
    rep(i, n) {
        int a, temp = c;
        rep(j, m) {
            cin >> a;
            temp += a * b.at(j);
        }
        if(temp > 0) ans++;
    }
    cout << ans << endl;
}

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

int main()
{
    string s;
    cin >> s;
    string t;
    vector<int> a(4);
    for(int i = 0; i < 4; ++i){
        t.push_back(s[i]);
        a[i] = stoi(t);
        t.clear();
    }
    if(a[0] + a[1] + a[2] + a[3] == 7){
        cout << a[0] << '+' << a[1] << '+' << a[2] << '+' << a[3] << '=' << '7' << endl;
        return 0;
    }
    if(a[0] + a[1] + a[2] - a[3] == 7){
        cout << a[0] << '+' << a[1] << '+' << a[2] << '-' << a[3] << '=' << '7' << endl;
        return 0;
    }
    if(a[0] + a[1] - a[2] - a[3] == 7){
        cout << a[0] << '+' << a[1] << '-' << a[2] << '-' << a[3] << '=' << '7' << endl;
        return 0;
    }
    if(a[0] - a[1] + a[2] + a[3] == 7){
        cout << a[0] << '-' << a[1] << '+' << a[2] << '+' << a[3] << '=' << '7' << endl;
        return 0;
    }
    if(a[0] - a[1] - a[2] + a[3] == 7){
        cout << a[0] << '-' << a[1] << '-' << a[2] << '+' << a[3] << '=' << '7' << endl;
        return 0;
    }
    if(a[0] - a[1] + a[2] - a[3] == 7){
        cout << a[0] << '-' << a[1] << '+' << a[2] << '-' << a[3] << '=' << '7' << endl;
        return 0;
    }
    if(a[0] + a[1] - a[2] + a[3] == 7){
        cout << a[0] << '+' << a[1] << '-' << a[2] << '+' << a[3] << '=' << '7' << endl;
        return 0;
    }
    
    
    return 0;
}

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

int main()
{
    string s;
    getline(cin, s);

    stack<int> stk1;
    stack<pair<int, int>> stk2;
    int total = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '\\') {
            stk1.push(i);
        } else if (s[i] == '/' && !stk1.empty()) {
            int j = stk1.top();
            stk1.pop();
            total += i - j;
            int local_sum = i - j;
            while (!stk2.empty() && j < stk2.top().first) {
                local_sum += stk2.top().second;
                stk2.pop();
            }
            stk2.push(make_pair(j, local_sum));
        }
    }
    cout << total << endl;

    vector<int> ans;
    while (!stk2.empty()) {
        ans.push_back(stk2.top().second);
        stk2.pop();
    }
    reverse(ans.begin(), ans.end());
    cout << ans.size();
    for (auto a : ans) {
        cout << " " << a;
    }
    cout << endl;
}


Measured memory_bytes: 3256