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

typedef long long   ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,n;
    cin >> a >> b >> n;

    ll mofq;
    if(n<b) mofq=n;
    else    mofq=b-1;

    cout << a*mofq/b << "\n";

    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;


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

    long long N;
    cin >> N;
    long long x;
    long long ans=0;
    long long y=pow(N,0.5);
    for(int i=1;i<=y;i++){
        if(N%i==0) x=i;
    }
    ans=x+N/x-2;
    cout << ans << endl;



}


Measured memory_bytes: 256
// need
#include <iostream>
#include <algorithm>
// data structure
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
//#include <deque>
#include <valarray>
#include <unordered_map>
#include <array>
// stream
//#include <istream>
#include <sstream>
//#include <ostream>
#include <fstream>
// etc
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
//#include <chrono>
#include <random>
#include <numeric>
using namespace std;
 
int main()
{
  long K, A, B;
  long sub;
  long have;
  cin >> K >> A >> B;
  if(A >= B-1){
    cout << (K+1) << endl;
    return 0;
  }
  K -= (A-1);
  sub = B - A;
  have = sub*(K/2) + A;
  if(K % 2 == 1)
    have++;
  cout << have << endl;
  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
all_dish = []

for n in range(N):
    K_n_list = list(map(int, input().split()))
    del K_n_list[0]
#    all_dish = [K_n_list_num for K_n_list_num in K_n_list]

    for K_n_list_num in K_n_list:
        all_dish.append(K_n_list_num)

prefer_dish = []
dish_kind = list(set(all_dish))
prefer_dish = [dish_kind_num for dish_kind_num in dish_kind if all_dish.count(dish_kind_num) == N]
#for dish_kind_num in dish_kind:
#    if all_dish.count(dish_kind_num) == N:
#        prefer_dish.append(dish_kind_num)

print(len(prefer_dish))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define INF 1000000007
#define SEP " "

int     main()
{
	int h, w;
	cin >> h >> w;
	vector<string> m(h);
	for (int i = 0; i < h; i++) {
		cin >> m[i];
	}
	vector<vector<ll>> dp(h+1, vector<ll>(w+1, 0));
	dp[0][0] = 1;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (dp[i][j] > MOD)
				dp[i][j] %= MOD;
			if (m[i][j] == '.')
			{
				dp[i+1][j] += dp[i][j];
				dp[i][j+1] += dp[i][j];
			}
		}
	}
	cout << dp[h-1][w-1] << endl;
}


Measured memory_bytes: 9216
#include <iostream>
#include <vector>

using namespace std;

int main(){
  int N;
  cin>>N;
  vector<vector<int> >v(2,vector<int>(N,0));
  for(int i=0;i<2;i++)for(int j=0;j<N;j++)cin>>v[i][j];

  int max=0,part_sum=0;
  
  part_sum=v[0][0];
  for(int i=0;i<N;i++){part_sum+=v[1][i];}
  
  max=part_sum;
  
  for(int i=1;i<N;i++){
    part_sum=part_sum-v[1][i-1]+v[0][i];
    if(part_sum>=max) max=part_sum;
  }

  cout<<max<<endl;

  return 0;
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,m,a,b,ans=0;cin>>n>>m;
  vector<P> v(m);rep(i,m) {cin>>a>>b;v[i]=P(b,a);}
  sort(ALL(v));
  ll cut=-1;
  for(P p:v) {
    a=p.second,b=p.first;
    if(cut<0) {cut=b-1;ans++;continue;}
    if(a<=cut) continue; 
    cut=b-1,ans++;
  }
  print(ans);
  return 0;
}

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

using namespace std;

int main()
{
	string x;
	cin >> x;
	for (int i = x.size() - 2; 0 <= i; i--)
		if (x.substr(i, 2) == "ST")
			x.erase(i, 2);
	cout << x.size() << endl;

	return 0;
}


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

int main(void) {
  int n, k;
  long ans;

  if(scanf("%d %d", &n, &k) == 1);

  ans = k * (pow(k - 1, n - 1));

  printf("%ld", ans);

  return 0;
}


Measured memory_bytes: 128
//#define TEST
using System;
using System.Collections.Generic;
using System.Linq;
class P{
    private static int[] ps = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97}; //長さ25
    static void Main(){
        int[] pc = new int[25];
        int n = int.Parse(Console.ReadLine()); //入力を受け取る
        for (int i = 2;i <= n;i++){ //n!の素因数分解
            foreach (var p in ps){
                int ic = i;
                while (ic % p == 0){
                    ic /= p;
                    pc[invP(p)]++;
                }
            }
        }
#if TEST
        foreach (var i in pc)
            Console.WriteLine(i);
#endif
        //3,5,15,25,75以上の個数を調べる
        var q5 = from x in pc
                where x + 1 >= 5
                select x;
        int c5 = q5.Count();
        var q3 = from x in pc
                where x + 1 >= 3
                select x;
        int c3 = q3.Count();
        var q15 = from x in pc
                where x + 1 >= 15
                select x;
        int c15 = q15.Count();
        var q25 = from x in pc
                where x + 1 >= 25
                select x;
        int c25 = q25.Count();
        var q75 = from x in pc
                where x + 1 >= 75
                select x;
        int c75 = q75.Count();
        //答えを計算
        int ans = 0;
        { //5 * 5 * 3
            if (c5 > 1)
                ans += (c5 * (c5 - 1) / 2) * (c3 - 2);
        }
        { // 5 * 15
            ans += c15 * (c5 - 1);
        }
        { // 3 * 25
            ans += c25 * (c3 - 1);
        }
        { //75
            ans += c75;
        }
        Console.WriteLine(ans);
    }
    static int invP(int p){
        for (int i = 0;i < 25;i++)
            if (ps[i] == p)
                return i;
        return -1;
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll a[100005][3];
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll N;
    cin>>N;
    ll i,j,a[N][3],a1,b1,c1,a2,b2,c2;
    for(i=0;i<N;i++) for(j=0;j<3;j++) cin>>a[i][j];
    a1=a[0][0]; b1=a[0][1]; c1=a[0][2];
    for(i=1;i<N;i++)
    {
        a2=max(b1,c1)+a[i][0];
        b2=max(a1,c1)+a[i][1];
        c2=max(a1,b1)+a[i][2];
        a1=a2; b1=b2; c1=c2;
    }
    cout<<max(max(a1,b1),c1)<<endl;
	return 0;
}

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

public class Main {
	public static void main(String[] args) {
		InputStreamReader insISR = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(insISR);
		try {
			String strLine = reader.readLine();
			int intNum = Integer.parseInt(strLine);
			double dbNum = (double)intNum;
			Math.pow(dbNum, 3);
			intNum = (int)Math.pow(dbNum, 3);
			System.out.println(intNum);
		}catch(IOException e) {
			System.out.println(e);
		}catch(NumberFormatException e) {
			System.out.println(e);
		}
	}
}

Measured memory_bytes: 24192
;; B - Strings with the Same Length

(defun main ()
  (let* ((N (read))
         (row (read-line))
         (SS (subseq row 0 N))
         (ST (subseq row (1+ N))))
    (princ (interleave SS ST))))

(defun interleave (s1 s2)
  (apply #'concatenate 'string
    (mapcar #'(lambda (ls) (coerce ls 'string))
      (map 'list #'list s1 s2))))

(main)


Measured memory_bytes: 16488
#include <iostream>
#define MAX 50001
using namespace std;

int main(){
  
   bool p[MAX];
   p[0] = p[1] = false;
   for(int i=2;i<MAX;i++)p[i] = true;
   for(int i=2;i<MAX;i++){
      if(p[i]){
	 for(int j=i+i;j<MAX;j=j+i){
	    p[j] = false;
	 }
      }
   }
   
   int cnt[MAX];
   for(int i=0;i<MAX;i++) cnt[i] = 0;
   for(int i=0;i<MAX;i++){
      for(int j=i;i+j<MAX;j++){
	 if(p[i] && p[j]) cnt[i + j]++;
      }
   }  
   
   int n;
   while (cin >> n,n){
      cout << cnt[n] << endl;
   }
   return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; ++i){
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    const ll mv = a.back();
    ll index = lower_bound(a.begin(), a.end(), (mv + 1) / 2) - a.begin();
    if(index != a.size() - 1 && index > 0){
        const ll d1 = a.at(index);
        const ll d2 = a.at(index - 1);
        if(abs(mv - 2 * d1) < abs(mv - 2 * d2)){
            cout << mv << ' ' << d1 << endl;
        }else{
            cout << mv << ' ' << d2 << endl;
        }
    }else if(index == 0){
        cout << mv << ' ' << a.at(index) << endl;
    }else{
        cout << mv << ' ' << a.at(index - 1) << endl;
    }
    return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define SHOW(x) cout << #x << ": " << x << endl;
template<class T> ll sumArr(const T& a){ return accumulate(all(a), 0LL);}
template<class T> auto minArr(const T& a){ return *min_element(all(a));}
template<class T> auto maxArr(const T& a){ return *max_element(all(a));}
template<class T> void DEBUG_PRINT(T tmp){cout<<tmp<<endl;}
template<class T1,class... T2> void DEBUG_PRINT(T1 tmp,T2... tmp2){cout<<tmp<<" ";DEBUG_PRINT(tmp2...);}
ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;


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

    ll n,ans = 0,ptr = 0;
    cin>>n;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    sort(all(a),greater<ll>());
    queue<ll>que;
    que.push(a[0]);
    rep(i,1,n){
        if(que.front() == a[i]){
            if(ptr != 0&&(i - ptr) <= ptr)que.push(a[i]);
            que.push(a[i]);
            ans += a[i];
        }
        else{
            ptr = i;
            ans += que.front();
            que.pop();
            if(ptr != 0&&(i - ptr) <= ptr)que.push(a[i]);
            que.push(a[i]);
        }
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 6712
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stdlib.h>
#include <cmath>
#include <math.h>
#include <fstream>
#include <bitset>
#include <time.h>
#include <queue>
#define int long long
using namespace std;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    for (int i=0; i < s.size() - 1; i++){
        if (s[i] == 'A' && s[i+1] == 'C'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}



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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	int N; cin >> N;
	string S; cin >> S;
	int K; cin >> K;

	char c = S[K-1];
	REP(i,N){
		if(c != S[i]) S[i] = '*';
	}

	cout << S << endl;


	return 0;

}


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

py.sort()

old=py[0][0]
py[0].append(1)
order=1
for i in range(1,m):
    now=py[i][0]
    if now==old:
        order+=1
    else:
        order=1
    py[i].append(order)
    old=now

py.sort(key = lambda x:x[2])

for pypy in py:
    ans = str(pypy[0]).zfill(6) + str(pypy[3]).zfill(6)
    print(ans)

Measured memory_bytes: 70048
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;

namespace AOJ0031
{
    class Program
    {
        static void Main()
        {
            foreach (var weights in from target in ReadInputs()
                                    select (from i in Enumerable.Range(0, 10)
                                            let weight = target & (1 << i)
                                            where weight != 0
                                            orderby weight ascending
                                            select weight.ToString(CultureInfo.InvariantCulture))
                                        .ToArray())
            {
                Console.WriteLine(string.Join(" ", weights));
            }
        }

        public static IEnumerable<int> ReadInputs()
        {
            string line;
            while ((line = Console.ReadLine()) != null)
            {
                yield return int.Parse(line);
            }
        }
    }
}

Measured memory_bytes: 6484
#include <iostream>
using namespace std;
int main(void){
    int len;
    string s;
    bool flg = true;
    cin >> s;
    len = s.length();
    for(int i=0;i<len;i++){
        if(i%2==0){
            if(s[i] == 'L')flg = false;
        }else{
            if(s[i] == 'R')flg = false;
        }
    }
    if(flg)puts("Yes");
    else puts("No");
}


Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();

        int max = (N-1)*(N-2)/2;
        if(K> max) {
            System.out.println(-1);
            return;
        }

        int diff = max - K;
        System.out.println(N-1+diff);
        for(int i = 1; i<N; i++) {
            System.out.println(1 + " " + (i+1));
        }
        for(int i = 2; i<N+1; i++) {
            for(int j = i+1; j<N+1; j++) {
                if(diff <= 0) break;
                diff--;
                System.out.println(i + " " + j);
            }
        }
    }
}

Measured memory_bytes: 24404
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cmath>
#include<string>

using namespace std;

string st = "CODEFESTIVAL2016";

int main() {
	string S;
	cin >> S;
	int answer = 0;
	for (int i = 0; i < st.size(); i++) {
		if (st[i] != S[i])answer++;
	}
	cout << answer << endl;
}

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

double calcDist(double, double);

int main()
{
	int N;
	scanf("%d", &N);
	std::vector<double> r(N);
	int max_i{};
	for (int i{}; i < N; i++)
	{
		scanf("%lf", &r[i]);
		if (r[i] > r[max_i])
			max_i = i;
	}
	std::vector<double> distance(N);
	double max_l{r[max_i]}, max_r{r[max_i]};
	for (int i{max_i - 1}; i >= 0; i--)
	{
		for (int j{max_i}; j > i; j--)
			distance[i] = std::max(distance[i], distance[j] + calcDist(r[i], r[j]));
		max_l = std::max(distance[i] + r[i], max_l);
	}
	for (int i{max_i + 1}; i < N; i++)
	{
		for (int j{max_i}; j < i; j++)
			distance[i] = std::max(distance[i], distance[j] + calcDist(r[i], r[j]));
		max_r = std::max(distance[i] + r[i], max_r);
	}

	std::cout << std::fixed << std::setprecision(10) << max_l + max_r << std::endl;
	return 0;
}

double calcDist(double a, double b)
{
	return sqrt((a + b) * (a + b) - (a - b) * (a - b));
}


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

char tolarge(char c){
  return c + 'A' - 'a';
}

int main() {
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;    
    cout << tolarge(s1[0]) << tolarge(s2[0]) << tolarge(s3[0]) << endl;
}

Measured memory_bytes: 256
import numpy as np

N , M , C = map(int,input().split())
B = np.array(list(map(int,input().split())))
A = [0] * N

for i in range(N) :
    A[i] = list(map(int,input().split()))

A = np.array(A)
AB = A.dot(B)

ans = 0

for i in range(N) :
    if AB[i] + C > 0 :
        ans += 1

print(ans)

Measured memory_bytes: 12488
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;
	int OFS = 100;
	int[] dx = {-1,0,1,0};
	int[] dy = {0,-1,0,1};

	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			int n = sc.nextInt();
			if(n == 0) break;
			int h[][] = new int[OFS*2+1][OFS*2+1];
			int t[][] = new int[OFS*2+1][OFS*2+1];
			for(int i=0;i<n;i++) {
				Dice d = new Dice(sc.nextInt(), sc.nextInt());
				int x = OFS, y = OFS;
				while(true) {
					int[] rot = d.canRoll();
					debug(d.as);
					debug(rot);
					if( h[y+dy[rot[0]]][x+dx[rot[0]]] < h[y][x] ) {
						d.roll(rot[0]);
						x += dx[rot[0]]; y += dy[rot[0]];
						continue;
					}
					if( h[y+dy[rot[1]]][x+dx[rot[1]]] < h[y][x] ) {
						d.roll(rot[1]);
						x += dx[rot[1]]; y += dy[rot[1]];
						continue;
					}
					break;
				}
				h[y][x]++; t[y][x] = d.as[0];
			}
			int ans[] = new int[7]; 
			for(int i=0;i<2*OFS+1;i++) for(int j=0;j<2*OFS+1;j++) {
				ans[ t[i][j] ] ++;
			}
			for(int i=1;i<=6;i++) System.out.print( ans[i] + (i==6? "\n": " "));
		}
	}
	
	class Dice {
		// top, left, back, right, front, botom
		int[] as = {1, 2, 4, 5, 3, 6};
		Dice (int t, int f) {
			for(int i=0;i<4&&t!=as[0];i++) roll(0);
			for(int i=0;i<4&&t!=as[0];i++) roll(1);
			for(int i=0;i<4&&f!=as[4];i++) roll(4);
		}
		
		int[] canRoll() {
			int[] ret = new int[2];
			int c = 0, p=0;
			for(int i=1;i<=4;i++) if(c<as[i]) {
				c = as[i];
				p = i;
			}
			ret[0] = p-1; c=0;
			for(int i=1;i<=4;i++) if(i!=ret[0]+1&&c<as[i]) {
				c = as[i];
				p = i;
			}
			ret[1] = p-1;
			return ret;
		}
		
		void roll(int d) {
			if( d == 0 ) roll( 0, 1, 5, 3 );
			if( d == 1 ) roll( 0, 2, 5, 4 );
			if( d == 2 ) roll( 0, 3, 5, 1 );
			if( d == 3 ) roll( 0, 4, 5, 2 );
			if( d == 4 ) roll( 1, 2, 3, 4 );
		}
		
		void roll(int a, int b, int c, int d) {
			int tmp = as[d];
			as[d] = as[c]; as[c] = as[b]; as[b] = as[a]; as[a] = tmp;
		}
	}

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

	void debug(Object... os) {
//		System.err.println(Arrays.deepToString(os));
	}
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

ll n, x;
vector<ll> a;

void input(){
    cin >> n >> x;
    a.resize(n);
    for(int i=0;i<n;i++) cin >> a[i];
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    ll ans = 0;
    for(int i=0;i<n-1;i++){
        ll s = a[i] + a[i+1];
        if(s > x){
            a[i+1] -= (s - x);
            ans += (s - x);
        }
        if(a[i+1] < 0){
            a[i] += -a[i+1];
            a[i+1] = 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
using namespace std;

int main() {
	const long long int mod = 1000000007;
	map<long long int, long long int>mp;
	long long int  s[200][200],a;
	//cout << fixed << setprecision(10);
	long long int n, m, two=0,res = 0, cou[200005]={}, mi = 999999999, ma = -9999999999;
	long long int max_id, min_id;
	cin >>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a;
		cou[a]++;
		
	}
	for(int i=1;i<=100000;i++)
	{
		
		if(cou[i]>0)
		{
			res++;
		}
		
		if(cou[i]%2==1)
		{
			
		}else if(cou[i]!=0)
		{
			two++;
			two%=2;
		}
		
	}
	cout<<res-two<<endl;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
#define forn(i, x, n) for (int i = x; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
typedef long double ld;
typedef long long ll;
template <typename... Args>
void dbg(Args&&... args) {
  using expander = int[];
  (void)expander {0,(static_cast<void>(void(cout << std::forward<Args>(args) << " ")), 0)...};
  cout << endl;
}
void gen() {exit(0);}

vector<int> a(3);

vector<vector<int>> permutations(vector<int>& v) {
  vector<int> p(v);
  vector<vector<int>> permutations;
  do {
    permutations.push_back(p);
  } while(next_permutation(p.begin(),p.end()));
  return permutations;
}


void input() {
  scanf("%d %d %d", &a[0], &a[1], &a[2]);
}

void solve() {
  int ans = INT_MAX;
  vector<vector<int>> perms = permutations(a);
  for (auto p : perms) {
    int cur = 0;
    for (int i = 1; i < p.size(); i++) {
      cur += abs(p[i] - p[i - 1]);
    }
    ans = min(cur, ans);
  }
  printf("%d\n", ans);
}

int main() {
#ifdef DEBUG
  freopen("input", "r", stdin);
  //  freopen("output", "w", stdout);
  //  gen();
#endif
  input();
  solve();
  return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>

#define MAX_N 100000

using namespace std;
typedef long long ll;

string s, t;
int q;
int bits[MAX_N+10], n1; //Aの個数
int bitt[MAX_N+10], n2;
int table[3][3];

int sum(int i){
  int s = 0;
  while(i > 0){
    s += bits[i];
    i -= i & (-i);
  }
  return s;
}

void add(int i, int x){
  while(i <= n1){
    bits[i] += x;
    i += i & -i;
  }
}
int sum2(int i){
  int s = 0;
  while(i > 0){
    s += bitt[i];
    i -= i & (-i);
  }
  return s;
}

void add2(int i, int x){
  while(i <= n2){
    bitt[i] += x;
    i += i & -i;
  }
}

int main(){
  cin >> s;
  cin >> t;
  cin >> q;
  n1 = s.length();
  n2 = t.length();
  fill(bits, bits+100001, 0);
  fill(bitt, bitt+100001, 0);
  for(int i = 1; i <= s.length(); i++){
    if(s[i-1] == 'A') {
      //cout << "add" << endl;
      add(i, 1);
    }
  }
  for(int i = 1; i <= t.length(); i++){
    if(t[i-1] == 'A') add2(i, 1);
  }
  table[0][0] = table[1][1] = table[2][2] = 1;
  table[1][0] = table[2][1] = table[0][2] = 2;
  table[2][0] = table[0][1] = table[1][2] = 3;

  for(int i = 0; i < q; i++){
    int a, b, c, d; cin >> a >> b >> c >> d;
    int sa = sum(b) - sum(a-1);
    int ta = sum2(d) - sum2(c-1);
    //cout << sa << " " << ta << endl;
    if(table[sa%3][(b-a-sa+1)%3] == table[ta%3][(d-c-ta+1)%3]){
      cout << "YES" << endl;
    }
    else{
      cout << "NO" << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 1664
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;

#define LL long long
inline int read() {
	int x=0,f=1; char ch=getchar();
	while (ch<'0' || ch>'9') {if (ch=='-') f=-1; ch=getchar();}
	while (ch>='0' && ch<='9') {x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}

char s[11];
int len;

LL fac[11],ans;

inline void calc(int st,int l) {
	LL x=0;
	for (int i=st; i<=st+l-1; i++) {
		x=x*10+s[i]-'0';
	}
	LL p=1;
	if (st-1-1<0) p=1;
	else
		p=fac[st-1-1];
	if (len-(st-1)-l-1<0)
		p*=1;
	else p*=fac[len-(st-1)-l-1];
	ans+=x*p;
//	printf("%d  %d\n",x,l==len ? 1 : fac[len-l-1]);
}

int main() {
	scanf("%s",s+1);
	len=strlen(s+1);
	fac[0]=1;
	for (int i=1; i<=10; i++) fac[i]=fac[i-1]*2;
	for (int i=1; i<=len; i++) {
		for (int j=1; j+i-1<=len; j++) {
			calc(j,i);
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define nl "\n"
#define ll long long int
#define MOD 1000000007
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m;
    cin>>n>>m;
    ll a[n],sum=0;
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    ll c=0;
    double item=float(sum*1.0/(4*m));
    for(ll i=0;i<n;i++)
    {
        if(a[i]>=item)
            c++;
    }
    if(c>=m)
        cout<<"Yes"<<nl;
    else
        cout<<"No"<<nl;


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SORT(i) sort((i).begin(),(i).end())
constexpr int INF = 2000000000;
constexpr int mod = 1000000007;

int main() {
	int a, b, c, x, y; cin >> a >> b >> c >> x >> y;
	c *= 2;
	int ans = min(a+b,c)*min(x,y);
	if (x < y) {
		int num = y - x;
		ans += min(b, c) * num;
	}
	else if (x > y) {
		int num = x - y;
		ans += min(a, c) * num;
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
import bisect
import collections
import heapq
import math
import operator as op
from collections import Counter
from functools import reduce

import numpy as np


def get_inputs(cast_func=None):
    if cast_func is None:
        return input().split()
    else:
        return list(map(cast_func, input().split()))


def get_input(cast_func=None):
    if cast_func is None:
        return input()
    else:
        return cast_func(input())


def main():
    N, M, X = get_inputs(int)
    Cs = np.empty(N, dtype=np.int)
    A_mat = np.empty((N, M), dtype=np.int)
    for i in range(N):
        CAs = get_inputs(int)
        Cs[i] = CAs[0]
        for j in range(M):
            A_mat[i, j] = CAs[j+1]
    # print(Cs)
    # print(A_mat)

    # print(np.sum(A_mat, axis=0))
    if (np.sum(A_mat, axis=0) >= X).all():
        def dfs(i, As_cur, C_cur):
            # Buy Ci
            As_buy = As_cur + A_mat[i, :]
            C_buy = C_cur + Cs[i]
            if (As_buy >= X).all():
                # Accomplish
                # return C_buy
                pass
            else:
                if i < N-1:
                    C_buy = dfs(i+1, As_buy, C_buy)
                else:
                    C_buy = float("inf")

            # Don't buy Ci
            if i < N-1:
                C_dontbuy = dfs(i+1, As_cur, C_cur)
            else:
                C_dontbuy = float("inf")

            return min(C_buy, C_dontbuy)

        ans = dfs(0, np.zeros(M, dtype=np.int), 0)
        assert ans != float("inf")
        print(ans)
    else:
        print(-1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 27352
# L 500円　M 100円　S 50円 N 合計
L = int(input())  # 10
M = int(input())  # 2
S = int(input())  # 1
N = int(input())
count = 0


def sum(l=0, m=0, s=0):
    return 500 * l + 100 * m + 50 * s


for l in range(L + 1):
    if N == sum(l):
        count += 1
        break
    else:
        for m in range(M + 1):
            if N == sum(l, m):
                count += 1
                break
            else:
                for s in range(S + 1):
                    if N == sum(l, m, s):
                        count += 1
                        break
print(count)


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

const int N = (int) 1e5 + 5;

int n, q;
int a[N];
int cnt[N];
long long ans[N];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		ans[0] += a[i];
		cnt[a[i]]++;
	}
	scanf("%d", &q);
	for (int i = 1; i <= q; i++) {
		int b, c; scanf("%d %d", &b, &c);
		ans[i] = ans[i - 1];
		ans[i] -= 1LL * cnt[b] * b;
		cnt[c] += cnt[b];
		ans[i] += 1LL * cnt[b] * c;
		cnt[b] = 0;
	}
	for (int i = 1; i <= q; i++) printf("%lld\n", ans[i]);
	return 0;
}

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

int  main(){
    int n; cin >> n;
    vector<int> L(n);
    for(int i=0;i<n;i++){
        cin >> L.at(i);
    }
    sort(L.begin(), L.end());
    int sum = 0;
    for(int i=0;i<n-1;i++){
        sum += L.at(i);
    }
    if(L.at(n-1)<sum) cout << "Yes";
    else cout << "No" << endl;
}

Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    let stdin = std::io::stdin();
    stdin.lock().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let a = iter.next().unwrap().parse::<String>().unwrap();
    let c: Vec<char> = a.chars().collect();
	let mut cnt = 0;
    if c[0] == '1' { cnt += 1; };
    if c[1] == '1' { cnt += 1; };
    if c[2] == '1' { cnt += 1; };
    println!("{}", cnt);
}

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

static class Program
{
    static int Solve(int N, int K, int R, int S, int P, string T)
    {
        int sum = 0;
        for (int i = 0; i < K; ++i)
        {
            int r1 = 0, s1 = 0, p1 = 0;
            for (int j = i; j < N; j += K)
            {
                int r2 = Math.Max(s1, p1);
                int s2 = Math.Max(p1, r1);
                int p2 = Math.Max(r1, s1);
                switch (T[j])
                {
                case 'r': p2 += P; break;
                case 's': r2 += R; break;
                case 'p': s2 += S; break;
                }
                r1 = r2;
                s1 = s2;
                p1 = p2;
            }
            sum += new[] { r1, s1, p1 }.Max();
        }
        return sum;
    }

    static void Main(string[] args)
    {
        var V1 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var V2 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var T = Console.ReadLine();
        Console.WriteLine(Solve(V1[0], V1[1], V2[0], V2[1], V2[2], T));
    }
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long int;
#define show(s)     cout<<s<<endl

int main() {

    int H,W,h,w;
    cin >> H >> W >> h >> w;

    int s = H * W - (h*W) - (w*H) + h*w;

    show(s);

    return 0;
}


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

int main() {
  string s,t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  
  if(s<t){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }  
}


Measured memory_bytes: 256
#define yuki(x, y) for(int i = x, __yuki = y; i < __yuki; ++i)
#define yukj(x, y) for(int j = x, __yukj = y; j < __yukj; ++j)
#define yukii(x, y) for(int i = x; __yukii = y; i <= __yukii; ++i)
#define yukji(x, y) for(int j = x; __yukji = y; j <= __yukji; ++j)
#define yuk(x, y, z) for(int x = y, __yuk = z; x < __yuk; ++x)
#define yui(x, y, z) for(int x = y, __yui = z; x >= __yui; --x)
#define sclr(x) memset(x, 0, sizeof(x))
#define sclr1(x) memset(x, -1, sizeof(x))
#define scl(x, y) memset(x, y, sizeof(x))
#define ft first
#define sc second
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long lol;
int n, a[100100];
bool op[100100];
void sread()
{
    scanf("%d", &n);
    char s[10];
    yuki(0, n-1)
    {
	scanf("%d%s", a+i, s);
	op[i+1] = s[0] == '-';
    }
    scanf("%d", a+n-1);
}
int main(int argc, char **argv)
{
    sread();
    lol maxs = 0, mins = 0, curs = 0, t;
    yui(i, n-1, 1)
	if(op[i])
	{
	    t = maxs;
	    maxs = max(-a[i]+curs+maxs, -(a[i]+curs+mins));
	    mins = min(-(a[i]+curs)+mins, -(a[i]+curs+t));
	    curs = 0;
	}else
	    curs += a[i];
    printf("%lld\n", maxs+curs+a[0]);
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i, n) FOR(i,0,n)
#define WARI 1000000007  

int main(void){
    ll N;
    unsigned long long ans=0,sum = 0,now=0;
    cin >> N;
    vector<unsigned long long> A(N+10);
    REP(i,N){
        cin >> A[i];
    }
    vector<unsigned long long>Now(N+10);
    Now[0]=0;
    FOR(i,1,N) Now[i] = Now[i-1] + A[i-1];
    FOR(i,0,N){
        ans += (Now[i] % WARI)* A[i];
        ans %= WARI;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6436
#include <iostream>
#include <vector>

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

    std::vector<int> counts(5, 0);
    for(int i = 0; i < n; ++i){
        std::string str;
        std::cin >> str;
        switch(str.at(0)){
            case 77 :
                ++counts.at(0);
                break;
            case 65 :
                ++counts.at(1);
                break;
            case 82: 
                ++counts.at(2);
                break;
            case 67:
                ++counts.at(3);
                break;
            case 72:
                ++counts.at(4);
                break;
        }
    }

    long long ans = 0;
    for(int i = 0; i < 5; ++i){
        for(int j = i + 1; j < 5; ++j){
            for(int k = j + 1; k < 5; ++k){
                if(i != j && j != k && k != i){
                    ans += counts.at(i) * counts.at(j) * counts.at(k);
                }
            }
        }
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
	template <class Arg1, class... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args) {
		const char* sep = strchr(names + 1, ',');
		cerr.write(names, sep - names) << " : " << arg1 << "  ";
		__f(sep + 1, args...);
	}
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif
 
typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<int,pii> piii;
typedef pair<char,int> pci;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> plll;
 
 
 
#define pb push_back
 
// #define mp make_pair 
// order_of_key (k), find_by_order(k)
#define fi first
#define se second
#define input_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define debug_arr(a,n) {{for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}cout<<"\n";}}
#define maxheap priority_queue<ll>
#define minheap priority_queue<ll,vector<ll> ,greater<ll>>
#define itt iterator
#define initialise(a, x) memset(a, x, sizeof(a))
#define endl '\n'
#define isvowel(a) (a=='a'||a=='e'||a=='i'||a=='o'||a=='u')
#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_upda
#define MAX 1000001
 
#define maxn 1000005
#define eps 0.0000001




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

	// freopen("input.txt", "r", stdin);
    // freopen("out.txt", "w", stdout); 

	
	char c;
	cin>>c;

	char g=(char)(c+1);

	cout<<g<<'\n';
	
	
}

Measured memory_bytes: 764
#include <iostream>
#include <set>

int main() {
  int arare = 0;
  std::cin >> arare;
  
  char color;

  std::set<char> colors;
 
  for (int i = 0; i < arare; ++i) {
    std::cin >> color;
    colors.insert(color);
  }
  
  if (colors.size() == 3) {
    std::cout << "Three" << std::endl;
  } else {
    std::cout << "Four" << std::endl;
  }
  
}

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

int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
int inf = 10000;
int bfs(vector<vector<int> > &v,int tmp){
    bool flag = 1;
    for(int i=0;i<4;i++){
        for(int j=0;j<4;j++){
            if(v[i][j]!=0){
                flag = 0;
            }
        }
    }
    if(flag)return 0;
    if(tmp>=6)return inf;
    int ans =inf;
    for(int i=0;i<4;i++){
        for(int j=0;j<4;j++){
            vector<vector<int> > u=v;
            if(u[i][j]!=0){
                if(u[i][j]!=4){
                    u[i][j]++;
                    ans = min(ans,1+bfs(u,tmp+1));
                }else{
                    u[i][j] = 0;
                    queue<pair<int,pair<int,int> > > q;
                    q.push(make_pair(0,make_pair(i,j)));
                    q.push(make_pair(1,make_pair(i,j)));
                    q.push(make_pair(2,make_pair(i,j)));
                    q.push(make_pair(3,make_pair(i,j)));
                    while(!q.empty()){
                        auto xxxx = q.front();
                        q.pop();
                        int dir = xxxx.first;
                        int x = xxxx.second.first;
                        int y = xxxx.second.second;
                        if(x+dx[dir]<0||x+dx[dir]>=4)continue;
                        if(y+dy[dir]<0||y+dy[dir]>=4)continue;
                        if(u[x+dx[dir]][y+dy[dir]]==0){
                            q.push(make_pair(dir,make_pair(x+dx[dir],y+dy[dir])));
                        }else if(u[x+dx[dir]][y+dy[dir]]<4){
                            u[x+dx[dir]][y+dy[dir]]++;
                        }else{
                            u[x+dx[dir]][y+dy[dir]] = 0;
                            q.push(make_pair(0,make_pair(x+dx[dir],y+dy[dir])));
                            q.push(make_pair(1,make_pair(x+dx[dir],y+dy[dir])));
                            q.push(make_pair(2,make_pair(x+dx[dir],y+dy[dir])));
                            q.push(make_pair(3,make_pair(x+dx[dir],y+dy[dir])));
                        }
                    }
                    ans = min(ans,1+bfs(u,tmp+1));
                }
            }
        }
    }
    return ans;
}

int main(){
    vector<vector<int> > v(4,vector<int>(4));
    for(int i=0;i<4;i++){
        for(int j=0;j<4;j++){
            cin >> v[i][j];
        }
    }
    int ans = bfs(v,1);
    if(ans==inf){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }

    return 0;
}


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

int main() {
	int N,K;
    cin >> N >> K;
    vector<int> h(N);
    for (int i = 0; i < N; ++i) {
      cin >> h.at(i);
    }
  
    sort(h.begin(), h.end());
  
    if ( K > 0) {
      for (int i = 0; i < K; ++i) {
        if (h.empty()) break;
        h.pop_back();
      }
    }
    long long cnt = 0;
    for (int i = 0; i < N - K; ++i) {
      cnt += h.at(i);
    }
    cout << cnt << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#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<<60;
const int INF=1<<30;

int main(){
	ll n,k;cin>>n>>k;
	ll mod = n % k;
	cout << min(mod,abs(mod - k)) << endl;
	return 0;
}

Measured memory_bytes: 384
package main

import (
	"fmt"
	"sort"
	"strings"
)

func main() {
	var n int
	fmt.Scan(&n)
	list := make([]string, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&list[i])
	}

	result := map[string]int{}
	count := 0
	for i := 0; i < n; i++ {
		sortString := strings.Split(list[i], "")
		sort.Strings(sortString)
		join := strings.Join(sortString, "")
		count += result[join]
		result[join]++

	}
	fmt.Println(count)
}


Measured memory_bytes: 17024
s=str(input())
if int(s) < 100:
    print(0)
else:
    x = int(s[-2:])
    a,b = divmod(x,5)
    k = a + (1 if b else 0)
    if k * 100 <= int(s) - x:
        print(1)
    else:
        print(0)


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,c) for(int i=0;i<(int)c;i++)
const int inf = 1001001001; //10^9


int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll c = a+b;
  ll ans = a*(n/c);
  ans += min(n%c, a);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int isPrime(int);
int main(){
  int i;
  int sum;
 int x;
  int count=0;
  /*数字の合計を入力*/
  scanf("%d",&sum);
 
  for(i=0;i<sum;i++){
    scanf("%d",&x);
      
	count+=isPrime(x);
      
      
	   }
  printf("%d\n",count);
  return 0;}


int isPrime(int x){
  int i;
    if (x == 2)
      return 1;

      if (x < 2 || x%2==0)
	return 0;
      
      i = 3;
      while (i <= sqrt(x)){
	if (x % i ==0)
	  return 0;
	i = i + 2;}

      return 1;}



Measured memory_bytes: 2732
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll, ll>
#define PP pair<P,P>
using namespace std;

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




Measured memory_bytes: 3640
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int n;
	cin >> n;
	
	vector<pair<int, int>> max_min(n);
	int x, l;

	for (int i = 0; i < n; i++) {
		cin >> x >> l;
		
		max_min[i].first = x + l;
		max_min[i].second = x - l;
	}

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

	int current = max_min[0].first;
	int ans = 1;
	for (int i = 1; i < n; i++) {
		if (current <= max_min[i].second) {
			ans++;

			current = max_min[i].first;
		}
	}

	cout << ans << endl;

	return 0;
}

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

int main(){
        char c;
        cin >> c;
        if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
                cout << "vowel" << endl;
        }else{
                cout << "consonant" << endl;
        }
        return 0;
}


Measured memory_bytes: 256
from collections import deque

N = int(input())
G = [[] for _ in range(N)]  # (頂点, コスト)
for _ in range(N-1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    G[u].append((v, w))
    G[v].append((u, w))

ans = [-1 for _ in range(N)]
q = deque()

ans[0] = 0
q.append(0)

while q:
    v = q.popleft()
    for u, w in G[v]:
        if ans[u] != -1:
            continue
        ans[u] = (ans[v] + w) % 2
        q.append(u)

for a in ans:
    print(a)


Measured memory_bytes: 39148
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<iomanip>
#include<algorithm>
using namespace std;

int main() {
  int n;cin >> n;
  if(n<1200){
    cout << "ABC" << endl;
  }else{
    cout << "ARC" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
typedef pair<int,ll> P;
int main(){
	int N,W;
	cin >> N >> W;
	vector<P> items;
	rep(i,N) {
		int w;
		ll v;
		cin >> w >> v;
		items.push_back(make_pair(w,v));
	}

	vector<vector<ll>> knap(N+1,vector<ll>(W+1));
	for(int i=1; i<=N; i++){
		for(int j=1; j<=W; j++){
			if(j < items[i-1].first) knap[i][j] = knap[i-1][j];
			else {
				knap[i][j] = max(knap[i-1][j], knap[i-1][j-items[i-1].first]+items[i-1].second);
			}
		}
	}	

	cout << knap[N][W] << endl;
	return 0;
}



Measured memory_bytes: 83184
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define repc(i, s, t) for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    cin >> __VA_ARGS__;
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

template <class T>
inline istream &operator,(istream &is, T &rhs) {
    return is >> rhs;
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.setf(ios_base::fixed);
    cout.precision(12);

    var(int, d, t, s);
    const auto YesNo = [](bool p) { print(p ? "Yes" : "No"); };
    YesNo(s * t >= d);

    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int p[11][11];
int dp[100010];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, d, x;
    cin >> n >> d >> x;
    for(int i = 1; i <= d; i++) {
        for(int j = 1; j <= n; j++) cin >> p[i][j];
    }
    for(int day = 1; day < d; day++) {
        for(int i = 1; i <= 1e5; i++) dp[i] = i;
        for(int i = 1; i <= x; i++) {
            for(int j = 1; j <= n; j++) {
                if(i < p[day][j]) continue;
                chmax(dp[i], dp[i-p[day][j]] + p[day+1][j]);
            }
            //cerr << day << " " << i << " " << dp[i] << endl;
        }
        x = dp[x];
    }
    cout << x << endl;
    return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N,K;
int A[110][110];
int d[110];
int B[110][110];

signed main(){
	cin>>N>>K;
	REP(i,K){
		cin>>d[i];
		REP(j,d[i]){
			cin>>A[i][j];
			A[i][j]--;
			B[A[i][j]][i]++;
		}
	}
	int ans=0;
	REP(i,N){
		int cnt=0;
		REP(j,K){
			if(B[i][j]!=0){
				cnt++;
			}
		}
		if(cnt==0){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3720