akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String args[]){
		BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));

		try{
			String[] strA = insBR.readLine().split(" ");
			int[] intA = new int[strA.length];
			String strMessage = "";
			for(int i = 0;i < strA.length ;i++){
				intA[i] = Integer.parseInt(strA[i]);
			}
			for(int i = 0;i < intA.length - 1;i++){
				for(int j = intA.length -1;i < j;j--){
					if(intA[j] < intA[i]){
						int intAct = intA[i];
						intA[i] = intA[j];
						intA[j] = intAct;
					}
				}
			}
			System.out.println(intA[0] + " " + intA[1] + " " + intA[2]);
		}catch(IOException e){
			System.out.println("入力が無効です。");
		}catch(NumberFormatException e){
			System.out.println("数値を入力してください。");
		}
	}
}



Measured memory_bytes: 24420
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	int ans = 0;
	for (int t = 0; t < 100; ++t) {
		if (A <= t && t < B && C <= t && t < D) {
			++ans;
		}
	}
	cout << ans << endl;
}


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

class Main{
    public static void main(String[] args){
    Scanner scan = new Scanner(System.in);

    int a = scan.nextInt();
    int b = scan.nextInt();
    int c = scan.nextInt();

    if(a < b && b < c){
    System.out.println("Yes");
    }else{
    System.out.println("No");
    }
}
}

Measured memory_bytes: 26180
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const ll INFS=1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int main(){
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  int ans = 0;
  rep(is,1<<h)rep(js,1<<w) {
    int cnt = 0;
    rep(i,h)rep(j,w) {
      if (is>>i&1) continue;
      if (js>>j&1) continue;
      if (s[i][j] == '#') cnt++;
    }
    if (cnt == k) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
    int a,b;
    string s;
    cin >> a >> b;
    cin >> s;
    bool flag=true;

    for(int i=0;i<a;i++){
        if(s[i]=='-'){
            flag=false;
        }
    }
    //cout << flag << endl;

    if (s[a]!='-'){
        flag=false;
    }
    //cout << flag << endl;

    for(int i=a+1;i<b+a+1;i++){
        if(s[i]=='-'){
            flag=false;
        }
    }
    //cout << flag << endl;
    if (flag==true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define MAX 250
 
int Parent(int i){
  return i/2;
}
 
int Left(int i){
  return 2*i;
}
 
int Right(int i){
  return (2*i)+1;
}
 
int main(){
  int heap[MAX],id,n,left,right;
   
  scanf("%d",&n);
  for(id=1 ; id<=n; id++){
    scanf("%d",&heap[id]);
  }
 
  for(id=1 ; id<=n ; id++){
    printf("node %d: key = %d, ",id,heap[id]);
    if(id>=2) printf("parent key = %d, ",heap[Parent(id)]);
 
    left = Left(id);
    right = Right(id);
    if(left<=n) printf("left key = %d, ",heap[left]);
    if(right<=n) printf("right key = %d, ",heap[right]);
 
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
 
#define ll long long
#define ii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pi 3.14159265
#define oo 1000000007
#define loo 100000000000000007

using namespace std;
#define prime 1000000007
#define mod 1000000007

#define W(x) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << "\n";
ll powmod(ll a,ll b) {ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res%mod;}

ll fac(ll a){
	ll ret = 1;
	for (ll i = 2; i <= a; ++i){
		ret*=i;
		ret%=mod;
	}
	return ret;
}

ll comb(ll n, ll k){
	if(k == 1) return n;
	ll ret = 1;
	for (ll i = n-k+1; i <= n; ++i){
		ret*=i;
		ret%=mod;
	}	
	return (ret*powmod(fac(k), mod-2))%mod;
}

ll a, b, n;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> n >> a >> b;

	ll aux1 = powmod(2, n)-1;
	ll aux2 = comb(n, a);
	ll aux3 = comb(n, b);

	ll ans = aux1 + mod - aux2;
	ans%=mod;
	ans += mod - aux3;
	ans%=mod;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n) + 1; i++)
#define all(vecto) vecto.begin(), vecto.end()
#define max3(a,b,c) max(a,max(b,c))
typedef long long ll;

int main()
{
    int a, b;
    cin >> a>> b;
    cout << max3((a + b), (a - b), (a * b)) << endl;
}

Measured memory_bytes: 256
// *_*
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
 
#define int long long
#define read(a) int a; cin >> a;
#define readarr(a, n) int a[(n) + 1] = {}; fori(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; fori(i, 1, n) {fori(j, 1, m) cin >> a[i][j];}
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for(int i = a; i <= b; i++)
#define ford(i, a, b) for(int i = a; i >= b; i--)
#define  sort1(v) sort(v.begin(), v.end()) 
#define endl '\n'
 
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;
 
const long long inf2 = (long long)1e18;
const long long mod = (long long)(1e9+7);
const long long inf1 =(long long)(1e6+1);
 
 
signed main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int n, m, ans = 0;
    cin >> n >> m;

    char a[n+1][m+1];
 
    fori(i, 1, n) fori(j, 1, m) cin >> a[i][j];
    
    fori(i, 1, n)
    {
        fori(j, 1, m)
        {
            if(a[i][j] == '.')
            {
                int vis[n+1][m+1] = {}, d[n+1][m+1] = {};
                vis[i][j] = 1;
                queue < pair <int, int>> q;
                q.push({i, j});
             
                while(!q.empty())
                {
                    int ii = q.front().fi;
                    int jj = q.front().se;
                    
                    q.pop();
             
                    if(ii < n)
                    {
                        if(a[ii+1][jj] == '.' && vis[ii+1][jj] == 0) {q.push({ii+1, jj}); vis[ii+1][jj] = 1; d[ii+1][jj] = d[ii][jj]+1;}
                    }
                    
                    if(ii > 0)
                    {
                        if(a[ii-1][jj] == '.' && vis[ii-1][jj] == 0) {q.push({ii-1, jj}); vis[ii-1][jj] = 1; d[ii-1][jj] = d[ii][jj] + 1;}
                    }
             
                    if(jj < m)
                    {
                        if(a[ii][jj+1] == '.' && vis[ii][jj+1] == 0) {q.push({ii, jj+1}); vis[ii][jj+1] = 1; d[ii][jj+1] = d[ii][jj] + 1; }
                    }
                    
                    if(jj > 0)
                    {
                        if(a[ii][jj-1] == '.' && vis[ii][jj-1] == 0) {q.push({ii, jj-1}); vis[ii][jj-1] = 1; d[ii][jj-1] = d[ii][jj] + 1;}
                    }
                }

                fori(k, 1, n) fori(l, 1, m) ans = max(ans, d[k][l]);
            }
        }
    }
 
    cout << ans;
 
    return 0;
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    auto xy = readints;
    int x = xy[0], y = xy[1];
    writeln(x + y / 2);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  map<int, int> mp;
  for(int i = 0; i < n; i++){
    int a;
    cin >> a;
    mp[a]++;
  }
  
  int ans = 0;
  for(auto x: mp){
    if(x.second & 1) ans++;
  }
  cout << ans << endl;
}

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


string Reverse(string s){

  string work="";
  for(int i=s.size()-1; i>=0; i--)
    work += s[i];

  return work;

}


bool Check(string s , vector<string> list){


  for(int i=0; i<(int)list.size(); i++){
    if(list[i] == s) return false;
  }

  return true;

}

int main(){


  int m;
  string in;
  string head,tail;
  int size;

  vector<string> list(0);

  cin >> m;

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

    cin >> in;
    size = in.size();

    list.clear();
    list.push_back(in);

    for(int j=1; j<size; j++){
      int k;      
      head = tail = "";
      for(k=0; k<j; k++){
	head+=in[k];
      }
      for(; k<size; k++){
	tail+=in[k];
      }
      //split

      if( Check( head+tail , list) ){
	list.push_back(head+tail);
      }
      if( Check( Reverse(head)+tail , list) ){
	list.push_back(Reverse(head)+tail);
      }
      if( Check( head+Reverse(tail) , list) ){
	list.push_back(head+Reverse(tail));
      }
      if( Check( Reverse(head)+Reverse(tail) , list) ){
	list.push_back(Reverse(head)+Reverse(tail));
      }
      if( Check( tail+head , list) ){
	list.push_back(tail+head);
      }
      if( Check( Reverse(tail)+head , list) ){
	list.push_back(Reverse(tail)+head);
      }
      if( Check( tail+Reverse(head) , list) ){
	list.push_back(tail+Reverse(head));
      }
      if( Check( Reverse(tail)+Reverse(head) , list) ){
	list.push_back(Reverse(tail)+Reverse(head));
      }
      //connect

      /*for(int m=0; m<(int)list.size(); m++){
	cout << list[m] << endl;
      }
      cout << endl;
      */
    }

    cout << list.size() << endl;
      

  }







  return 0;

}

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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int T,P,R;
int pena[52][12];
//解いた問題数,ペナルティ,チーム番号
pair<int,pair<int,int> > p[52];

int main() {
    while(cin>>T>>P>>R) {
        if(T+P+R==0) return 0;
        rep(i,52) {
            rep(j,12) pena[i][j]=0;
            p[i]=make_pair(0,make_pair(0,i));
        }

        rep(i,R) {
            int tID,pID,time;
            string ss;
            cin>>tID>>pID>>time>>ss;
            if(ss == "CORRECT") {
                p[tID].first--;
                p[tID].second.first += (pena[tID][pID]*1200+time);
                p[tID].second.second = tID;
            }
            else {
                pena[tID][pID]++;
            }
        }

        sort(p+1,p+T+1);

        rep(i,T+1) {
            if(!i) continue;
            cout<<p[i].second.second<<" "<<-p[i].first<<" "<<p[i].second.first<<endl;
        }

    }
    return 0;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
long long gcd(long a,long b){
	if(a%b==0)return b;
	else return gcd(b,a%b);
}
long long lcm(long a,long b){
	return a*b/gcd(a,b);
}
int main()
{
	long long a,b;
	cin>>a>>b;
	long long d;
	if(a!=b && a>=1 && b>=1){
			 d=lcm(a,b);
	}

	cout<<d<<endl;
	return 0;
}

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VECINT;
typedef vector<ll> VECLL;

int main() {
  int N;cin>>N;
  VECINT LS(N);
  REP(i,N) cin>>LS[i];
  sort(ALL(LS));

  int ans = 0;
  // 真ん中の長さを見ていく
  for (int i=1;i<N-1;i++) {
    // 短い方を選択
    for (int j=0;j<i;j++) {
      // 一番左辺を知りたい
      int tmp = lower_bound(ALL(LS), LS[i]+LS[j])-LS.begin();
      // upper_boundなので
      // tmp -= 1;
      // 真ん中のやつより上
      tmp = max(0,tmp-i-1);
      ans += tmp;
    }
  }
  OUT(ans);

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>
#include<string.h>
using namespace std;

int main()
{
		string S;
		int n;

		cin >> S;

		n = (int)S.size();
		for (int i = 0; i < n; i++) {
			char c = S[i];
			if (i % 2 == 0) {
				if (c == 'L') {
					cout << "No" << endl;
					return 0;
				}
			}
			else {
				if (c == 'R') {
					cout << "No" << endl;
					return 0;
				}
			}
		}

		cout << "Yes" << endl;
	return 0;


}

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

int main(){

    int n;

    cin>>n;

    vector<int> w(n);

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

        cin>>w[i];
    }

    int ans = 10000000;
    
    for(int i=1; i<n; i++){

        int sum1=0,sum2=0;

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

            sum1 += w[j];
        }

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

            sum2 += w[j];
        }

    
    ans = min(abs(sum2 - sum1),ans);

    }

    cout<<ans<<endl;

    return 0;

}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iterator>
#include<sstream>
#include<iomanip>
#include<map>
#include<queue>
#include<deque>
#include<fstream>
#include<random>

#define rep(i, n) for (ll i = 0; i < n; i++) 
#define rrep(i, n) for(ll i = n-1; i>=0; i--)
#define range(i, n, m) for (ll i = n; i < m; i++) 
#define rrange(i, n, m) for (ll i = n - 1; i => m; i--) 
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vp vector<pair<ll, ll> >
#define vvp vector<vector<pair<ll, ll> > >
#define First first
#define Second second.first
#define Third second.second
#define Sort(X) sort(X.begin(), X.end())
#define RSort(X, T) sort(X.begin(), X.end(), greater<T>())
//#define MOD 998244353
#define MAX 100000

typedef long long int ll;
typedef unsigned long long int ull;

using namespace std;

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

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

	ll A, B;
	cin >> A >> B;


	ll out = (B - 1) / (A - 1);
	if ((B - 1) % (A - 1) != 0) out++;

	cout << out << endl;



	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  int n;
  cin >> n;
  vector<int> p(n),q(n),r(n);
  rep(i,n){
    cin >> p.at(i);
  }
  rep(i,n){
    cin >> q.at(i);
  }
  rep(i,n){
    r.at(i)=i+1;
  }
  int ans=0,x=0,y=0,ct=1;
  do{
    bool is=true,no=true;
    int i=0,j=0;
    for(int a : r){
      if(p.at(i)!=a){
        is=false;
      }
      i++;
    }
    if(is){
      x=ct;
    }
    for(int a : r){
      if(q.at(j)!=a){
        no=false;
      }
      j++;
    }
    if(no){
      y=ct;
    }
    ct++;
  }while (next_permutation(r.begin(),r.end()));
  cout << abs(x-y);
}
  
    
  

Measured memory_bytes: 3560
N=int(input())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
C=list(map(int, input().split()))


s=0

for i in range(0,N):
  s=s+B[i]

extra=0
for i in range(0,N-1):
  if A[i]+1==A[i+1]:
    extra=extra+C[A[i]-1]

s=s+extra

print(s)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  string s;
  int k;

  cin >> s >> k;

  for(int i=0;i<k;i++){
    if(s[i] != '1') {
      cout << s[i] << endl;
      return 0;
    }
  }

  cout << '1' << endl;

  return 0;
}


Measured memory_bytes: 256
s = input()
if s[0] == s[1] == s[2] == s[3]:
  print('No')
elif s[0] == s[1] and s[2] == s[3]:
  print('Yes')
elif s[0] == s[2] and s[1] == s[3]:
  print('Yes')
elif s[0] == s[3] and s[1] == s[2]:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

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

	int N,M;
	int T[100010]={0};
	
	cin>>N>>M;
	
	for (int i = 0; i < M; i++) {
		int l,r;
		cin>>l>>r;
		T[l]++;
		T[r+1]--;
	}
	
	for (int i = 1; i < 100010; i++) {
		T[i]+=T[i-1];
	}
	int ans=0;
	for (int i = 1; i <= N; i++) {
		
		if(T[i]==M){
			ans++;
		}
	}
	
	cout<<ans<<endl;

	return 0;
}

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

#define MAX 200001
#define INF (1<<30)
#define BLACK 0
#define GRAY 1
#define WHITE 2

int n,m;
vector< pair<int,int> > graph[MAX];

void dijkstra(void);

int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int a,b;	cin>>a>>b;
		graph[a].push_back({b,1});
		graph[b].push_back({a,1});
	}

	dijkstra();

	return 0;
}

void dijkstra(){
	priority_queue< pair<int,int> > PQ;
	int color[MAX], d[MAX];
	for(int i=1;i<=n;i++){
		d[i]=INF;
		color[i]=WHITE;
	}
	d[1]=0;
	PQ.push({1,1});		// (重み、ノード番号)
	color[1]=GRAY;

	while(PQ.empty()==false){
		pair<int,int> x=PQ.top();	PQ.pop();
		int from=x.second;
		color[from]=BLACK;

		if(d[from]<x.first*(-1)) continue;

		for(pair<int,int> next:graph[from]){
			int to=next.first, w=next.second;
			if(color[to]==BLACK)continue;

			if(d[to]>d[from]+w){
				d[to]=d[from]+w;

				PQ.push({d[to]*(-1) , to});
				color[to]=GRAY;
			}
		}
	}
	cout<<(d[n]<=2? "POSSIBLE":"IMPOSSIBLE")<<endl;
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left!=NIL)x=x->left;
  return x;

}

Node treeMaximum(Node x){
  while(x->right!=NIL)x=x->right;
  return x;


}

Node treeSearch(Node u, int k){
  while(u!=NIL&&k!=u->key){
    if(k<u->key)u=u->left;
    else u=u->right;
  }
  return u;
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right!=NIL)return treeMinimum(x->right);

  y=x->parent;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left==NIL||z->right==NIL)y=z;
  else y=treeSuccessor(z);

  if(y->left!=NIL)x=y->left;
  else x=y->right;

  if(x!=NIL)x->parent=y->parent;

  if(y->parent!=NIL)root=x;
  else if(y==y->parent->left)y->parent->left=x;
  else y->parent->right=x;

  if(y!=z)z->key=y->key;
  
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key)
      x=x->left;
    else x=x->right;
  }
  z->parent=y;

  if(y==NIL)
    root=z;
  else if(z->key<y->key)
    y->left=z;
  else
    y->right=z;
    
}

void inorder(Node u){
  if(u==NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;

}



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

int main(){
  
  int n;
  cin >> n;
  long long ans = 0;
  vector<long> l(n);
  //vector<long> check(100000000);
  for(int i=0;i < n;i++){
    cin >> l.at(i);
  }
  for(int i = 0;i < n;i ++){
    for(int j = i+1; j < n; j++){
      for(int k = j+1; k < n;k++){
        if(l.at(i) != l.at(j) && l.at(j) != l.at(k) && l.at(i) != l.at(k)){
       	   if(l.at(i) + l.at(j) > l.at(k) && l.at(j) + l.at(k) > l.at(i) && l.at(k) + l.at(i) > l.at(j)){
              ans++;
         	  //cout << i << j << k << endl;
           }
        }
      }
    }
  }
         
  cout << ans << endl;
}

Measured memory_bytes: 3640
#include<algorithm>
#include<chrono>
#include<climits>
#include<numeric>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<cassert>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
using namespace std;
 
#define rep(i, a, b) for(auto i = (a); i < (b); i++)
#define rrep(i, a, b) for(auto i = (a); i > (b); i--)
#define all(v) (v).begin(), (v).end()
#define print(v) {for(auto x : v) cout << x << ' '; cout << endl;}
#define printn(v, n) {for(int _i = 0; _i < n; _i++) cout << *(v + _i) << ' '; cout << endl;}
 
typedef unsigned long long ull;
typedef long long ll;
 
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
 
const int MAXN = 1e3 + 20;

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

    int n, k;
    string s;
    cin >> n >> k;
    cin >> s;
    int res = 0;
    for(int i = 0; i + 1 < n; i++)
    	if(s[i] == s[i + 1])
    		res++;
    cout << min(res + k * 2, n - 1) << endl;

    return 0;
}











Measured memory_bytes: 512
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;
ll dp[11][110][1010];
void mainmain(){
	rep(i,101){
		dp[1][i][i]=1;
	}
	reep(i,2,10){
		reep(j,0,101){
			reep(k,0,1001){
				reep(l,j+1,101){
					if(k-l<0) break;
					dp[i][l][k]+=dp[i-1][j][k-l];
				}
			}
		}
	}
	int n,s;
	while(cin>>n>>s,n||s){
		ll ans=0;
		rep(i,101){
			ans+=dp[n][i][s];
		}
		cout<<ans<<endl;
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

Measured memory_bytes: 8432
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<map>

#define MOD 1000000007

using namespace std;

long long exp(long long base, long long pw)
{
	vector<long long> bits;

	while (pw)
	{
		bits.push_back(pw % 2);

		pw /= 2;
	}

	long long temp;

	temp = base;

	long long rvalue = 1;

	for (long long i = 0; i < bits.size(); i++)
	{
		if (bits[i])
		{
			rvalue = rvalue*temp%MOD;
		}

		temp = temp*temp%MOD;
	}

	return rvalue;
}

long long divd(long long base, long long pw)
{
	return exp(exp(base, MOD - 2), pw);
}

int main()
{
	vector<long long> prime;

	prime.push_back(2);

	for (long long i = 3; i < 1000; i += 2)
	{
		bool isprime = true;

		for (long long j = 0; j < prime.size() && prime[j] * prime[j] <= i; j++)
		{
			if (!(i%prime[j]))
			{
				isprime = false;

				break;
			}
		}

		if (isprime)
		{
			prime.push_back(i);
		}
	}

	vector<long long> arr;
	long long n;
	map<long long, long long> tot, part[10001];

	scanf("%lld", &n);

	for (long long i = 0; i < n; i++)
	{
		long long input;

		scanf("%lld", &input);

		arr.push_back(input);

		for (long long j = 0; j < prime.size() && input != 1; j++)
		{
			long long cnt = 0;

			if (input % prime[j])
			{
				continue;
			}

			while (input != 1 && !(input % prime[j]))
			{
				input /= prime[j];

				cnt++;
			}

			if (cnt)
			{
				part[i][prime[j]] = cnt;

				map<long long, long long>::iterator ret;

				ret = tot.find(prime[j]);

				if (ret == tot.end() || ret->second < cnt)
				{
					tot[prime[j]] = cnt;
				}
			}
		}

		if (input != 1)
		{
			tot[input] = 1;

			part[i][input] = 1;
		}
	}

	long long base = 1;

	for (map<long long, long long>::iterator it = tot.begin(); it != tot.end(); it++)
	{
		base = base*exp(it->first, it->second) % MOD;
	}

	long long sol = 0;

	for (long long i = 0; i < n; i++)
	{
		map<long long, long long>::iterator it;

		long long mult;

		mult = base;

		for (map<long long, long long>::iterator it = part[i].begin(); it != part[i].end(); it++)
		{
			mult = mult*divd(it->first, it->second) % MOD;
		}

		sol = (sol + mult) % MOD;
	}

	printf("%lld\n", sol);

	return 0;
}

Measured memory_bytes: 3968
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


//FUNCTION
void solve(void)
{
  int K;
  cin>>K;
  int ANS = 0;
  for (int a = 1; a <= K; a++)
  {
    for (int b = 1; b <= K; b++)
    {
      for (int c = 1; c <= K; c++)
      {
         ANS += gcd(gcd(a,b),c);
      }
      
    }
    
  }
  cout<<ANS<<endl;
  
  
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(15);
  solve();

  return 0;
}


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

int N, t, ans;
int a[100001];

int main()
{
    scanf("%d", &N);
    for (int i = 0; i < N; i++)
    {
        scanf("%d", &t);
        if (t > N) ans++;
        else if (a[t] >= t) ans++;
        else a[t]++;
    }
    for (int i = 1; i <= N; i++)
        if (a[i] < i) ans += a[i];
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>

using namespace std; using namespace placeholders;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector< int > VI;
typedef vector< VI > VVI;
typedef vector< string > VS;
typedef stringstream SS;
typedef pair< int, int > PII;
typedef vector< pair< int, int > > VPII;

template < typename T > inline void input_n( vector< T > &out ) { copy_n( istream_iterator< T >( cin ), out.size(), out.begin() ); };
template < typename T > inline T fromString( const string &s ) { T res; istringstream iss( s ); iss >> res; return res; };
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( e, c ) for ( auto &e : c )
#define ALL( c ) (c).begin(), (c).end()
#define AALL( a, t ) (t*)a, (t*)a + sizeof( a ) / sizeof( t )
#define DRANGE( c, p ) (c).begin(), (c).begin() + p, (c).end()

#define PB( n ) push_back( n )
#define EM emplace
#define EB emplace_back
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

LL solve( const int N )
{
	static vector< LL > dp( 31, -1 );
	if ( N <= 0 )
	{
		return N == 0;
	}
	if ( dp[N] != -1 )
	{
		return dp[N];
	}

	LL res = 0;
	REP( i, N - 3, N )
	{
		res += solve( i );
	}
	return dp[N] = res;
}

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

	for ( int n; cin >> n, n; cout << ( solve( n ) + 3650 - 1 ) / 3650 << endl );

	return 0;
}

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

int		main(void)
{
	string a, b, c;
	cin >> a >> b >> c;
	a[0] -= 32;
	b[0] -= 32;
	c[0] -= 32;
	cout << a[0] << b[0] << c[0] << endl;
}


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

using namespace std;
int main()
{
    int N;
    int X;
    int T;
    cin >> N >> X >> T;
    int cnt = 0;
    while(N>0)
    {
        cnt += T;
        N -= X;
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 3636
import sys

ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: [int(x) for x in ns().split()]
nall = lambda: [int(x) for x in sys.stdin.readlines()]

def main():
    _ = ni()
    xs = na()
    for x in xs:
        if x % 2 == 0:
            if x % 3 != 0 and x % 5 != 0:
                print('DENIED')
                return

    print('APPROVED')


main()


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

int main() {
	int n,i,f;
	cin>>n;
	int a[n];
	vector < int >e,o;
	for(i=0;i<n;i++)
	  cin>>a[i];
	for(i=0;i<n;i++)
	  {
	  	  cin>>a[i];
	  	  if(i%2==0)
	  	    {
	  	    	 e.push_back(a[i]);
	  	    }
	  	  else
	  	    o.push_back(a[i]);
	  }
	  //cout<<e.size()<<"  "<<o.size()<<'\n';
	sort(e.begin(),e.end());
	sort(o.begin(),o.end());
	vector <pair <int ,int > >v1,v2;
	for(i=0;i<e.size();)
	  {
	  	  f=upper_bound(e.begin(),e.end(),e[i])-lower_bound(e.begin(),e.end(),e[i]);
	  	  v1.push_back({f,e[i]});
	  	  i=upper_bound(e.begin(),e.end(),e[i])-e.begin();
	  	  //cout<<i<<'\n';
	  }
	for(i=0;i<o.size();)
	  {
	  	 f=upper_bound(o.begin(),o.end(),o[i])-lower_bound(o.begin(),o.end(),o[i]);
	  	 v2.push_back({f,o[i]});
	  	 i=upper_bound(o.begin(),o.end(),o[i])-o.begin();
	  }
	sort(v1.begin(),v1.end());
	sort(v2.begin(),v2.end());
	reverse(v1.begin(),v1.end());
	reverse(v2.begin(),v2.end());
	if(v1[0].second!=v2[0].second)
	  {
	  	 cout<<n-v1[0].first-v2[0].first<<'\n';
	  }
	else if(v1.size()==1)
	  {
	  	  cout<<n-v2[0].first<<'\n';
	  }
	else if(v2.size()==1)
	  cout<<n-v1[0].first<<'\n';
	else 
	  {
	  	 cout<<min(n-v1[1].first-v2[0].first,n-v1[0].first-v2[1].first);
	  }
	return 0;
}

Measured memory_bytes: 2168
n,k = map(int,input().split())

A = [i for i in range(1,n+1)]

ans = []

for i in range(k):
  d = int(input())
  aa = list(map(int,input().split()))
  ans.extend(aa)

import collections

c = collections.Counter(ans)

print(n - len(c.keys()))




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

using namespace std;
using ll = long long;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

void solve(long long S){
  ll ans = 0;
  string s = to_string(S);
  string t = "";
  for(ll i=0; i<(1<<(s.size()-1)); i++) {
    t = "";
    for(ll k=0; k<s.size()*2; k++) {
      if(k%2) {
	if(i & 1<<(k/2)) {
	  t.push_back('+');
	}
      } else {
	t.push_back(s[k/2]);
      }
    }
    string u = "";
    for(auto x : t) {
      if(x=='+') {
	ans+=stoll(u);
	u = "";
      } else {
	u.push_back(x);
      }
    }
    ans+=stoll(u);
  }
  std::cout << ans << std::endl;
}

int main(){
  long long S;
  scanf("%lld",&S);
  solve(S);
  return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

//Save your cat
public class Main{
	
	class UnionFind {
		final int[] tree;
		int num;
		public UnionFind(int n) {
			this.tree = new int[n];
			Arrays.fill(tree, -1);
			num=n;
		}
		void union(int x, int y) {
			x = root(x);
			y = root(y);
			if(x != y) {
				if(tree[x] < tree[y]) {
					x ^= y; y ^= x; x^= y;
				}
				tree[x] += tree[y];
				tree[y] = x;
				num--;
			}
		}
		boolean find(int x, int y) {
			return root(x) == root(y);
		}
		int root(int x) {
			return tree[x] < 0 ? x : (tree[x] = root(tree[x]));
		}
		int size(int x) {
			return -tree[root(x)];
		}
		int getNum() {
			return num;
		}
	}
	
	class E implements Comparable<E>{
		int s, t;
		double d;
		public E(int s, int t, double d) {
			this.s = s;
			this.t = t;
			this.d = d;
		}
		public int compareTo(E o) {
			return (int)Math.signum(o.d-d);
		}
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), m = sc.nextInt();
		int[] x = new int[n+1], y = new int[n+1];
		for(int i=1;i<=n;i++){
			x[i] = sc.nextInt(); y[i] = sc.nextInt();
		}
		E[] es = new E[m];
		double sum = 0;
		for(int i=0;i<m;i++){
			int s = sc.nextInt(), t = sc.nextInt();
			double d = Math.hypot(x[s]-x[t], y[s]-y[t]);
			sum+=d;
			es[i] = new E(s, t, d);
		}
		Arrays.sort(es);
		UnionFind u = new UnionFind(n+1);
		double res = 0;
		for(E e:es){
			if(u.find(e.s, e.t))continue;
			res+=e.d;
			u.union(e.s, e.t);
		}
		System.out.printf("%.8f\n", sum-res);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 14000
#include <iostream>
#include <string>
#define MAX 22
using namespace std;
char map[ MAX ][ MAX ];
int n;
void visit( int i, int j ){
  if( map[ i ][ j ] == '#' ){ return; }
  n++;
  map[ i ][ j ] = '#';
  visit( i - 1, j );
  visit( i, j - 1 );
  visit( i + 1, j );
  visit( i, j + 1 );
}
int main(){
  while( 1 ){
    int w, h;
    int pi, pj;
    n = 0;
    cin >> w >> h;
    if( !w || !h ){ return 0; }
    for( int i = 0; i <= h + 1; i++ ){
      if( i == 0 || i == h + 1 ){
        for( int j = 0; j <= w + 1; j++ ){
          map[ i ][ j ] = '#';
        }
        continue;
      }
      string line;
      cin >> line;
      for( int j = 0; j <= w + 1; j++ ){
        if( j == 0 || j == w + 1 ){
          map[ i ][ j ] = '#';
          continue;
        }
        map[ i ][ j ] = line[ j - 1 ];
        if( map[ i ][ j ] == '@' ){
          pi = i;
          pj = j;
        }
      }
    }
    visit( pi, pj );
    cout << n << endl;
  }
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
using ll=long long;

const ll maxi= 1000*100;
ll DP[maxi+10][3];
ll CurValeur[maxi+10][3];

int main()
{
    ll n;cin >> n;
    for(int i=0;i<n;i++)
     for(int j=0;j<3;j++){
        cin>>CurValeur[i][j];
        DP[i][j]=0;}
    
    for(int j=0;j<3;j++)
        DP[0][j]=CurValeur[0][j];
        
    for(int i=1;i<n;i++)
        for(int j=0;j<3;j++)
            for(int k=0;k<3;k++)
                if(k!=j)
                    if(DP[i-1][k]+CurValeur[i][j]>DP[i][j])
                        DP[i][j]=DP[i-1][k]+CurValeur[i][j];

    ll ans=0;
    for(int j=0;j<3;j++)
        if(ans<DP[n-1][j])
            ans=DP[n-1][j];
    cout<<ans<<'\n';
}

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

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

    int ans = 0;
    int cou = 0;
    if(h >= w){
        for(int i = 0; i < w; i++){
            if(cou >= n){
                break;
            }
            cou += h;
            ans++;
        }
    }else{
        for(int i = 0; i < h; i++){
            if(cou >= n){
                break;
            }
            cou += w;
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;

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

    for (int i = 0; i < s.size(); i = i + 2) {
        cout << s[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    int N,K;
    cin >> N >> K;
    std::vector<long long> H(N);
    for(int i=0;i<N;i++){
        cin >> H[i];
    }
    std::sort(H.begin(), H.end(), std::greater<int>());
    long long ans = 0;
    for(int i=K;i<N;i++){
        ans += H[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <tuple>
#include <climits>
#include <sstream>
using namespace std;

vector<pair<string, int>> r;

int ind[101];

int main()
{
    int a, p;
    cin >> a >> p;
    p += a * 3;
    cout << p / 2;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long  a,b,k ;
    cin>>a>>b>>k;
        if(k<=a)
        {
            cout<<a-k<<" "<<b;
        }
        else if(k<=a+b)
        {
            cout<<"0"<<" "<<b-(k-a);
        }
        else
            cout<<"0"<<" "<<"0";
}


Measured memory_bytes: 256
using System;

class Program
{
    static void Main()
    {
        string[] array = Console.ReadLine().Split(' ');
        int A = int.Parse(array[0]);
        int B = int.Parse(array[1]);
        bool flag = false;

        for (int C = 1; C < 3; C++)
        {
            if (A * B * C % 2 == 1)
            {
                flag = true;
                break;
            }
        }

        if (flag) Console.WriteLine("Yes");
        else Console.WriteLine("No");

    }
}

Measured memory_bytes: 11092
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef long long LL;

#define d(x)  cout<<#x<<" = "<<(x)<<endl;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define REACH(i,c) for(typeof((c).rbegin()) i=(c).rbegin(); i!=(c).rend(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c,n) sort(c,c+n)
#define VSORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define DFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define DREP(i,n) DFOR(i,n,0)
#define INF 2000000000

const double EPS = 1e-10;
const double PI  = acos(-1.0);
////////////////////////////////////////////////
int a[2000010],n;


void maxheapify(int a[],int i)
{
	int l=i*2;
	int r=l+1;
	int lgt;
	if(l<=n&&a[l]>a[i])
	{
		lgt=l;
	}
	else lgt=i;
	if(r<=n&&a[r]>a[lgt])
	{
		lgt=r;
	}
	if(lgt!=i)
	{
		swap(a[i],a[lgt]);
		maxheapify(a,lgt);
	}
}
 
void buildmaxheap(int a[])
{
	DFOR(i,n/2+1,1)maxheapify(a,i);
}

int parent(int i)
{
	return floor(i/2);
}

void heapIncreasekey(int a[],int i,int key)
{
	if(key<a[i])return;
	a[i]=key;
	while(i>1&&a[parent(i)]<a[i])
	{
		swap(a[i],a[parent(i)]);
		i=parent(i);
	}
}

void insert(int key)
{
	n++;
	a[n]=-INF;
	heapIncreasekey(a,n,key);
}

int heapExtractMax(int a[])
{
	if(n<1)return -1;
	
	int max=a[1];
	a[1]=a[n];
	n--;maxheapify(a,1);
	return max;
}

int main()
{
	string com;
	int x;
	for(;;)
	{
		cin>>com;
		if(com=="insert")
		{
			cin>>x;
			insert(x);
		}
		else if(com=="extract")
		{
			cout<<heapExtractMax(a)<<endl;
		}
		else if(com=="end")
		{
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 6924
n, *a = open(0).read().split()
n = int(n)
a = list(map(int, a))
sum = [0] * -~n
o = [0] * -~n
ct = [0] * -~n
b = []
for i in a:
    ct[i] += 1
for i in range(1, n + 1):
    if ct[i]:
        b.append(i)
b.sort(key=lambda x: ct[x])

for i in range(len(b)):
    sum[i] += (sum[i - 1] if i else 0) + ct[b[i]]

j = len(b) - 1
cnt = 0
for i in range(1, n + 1)[::-1]:
    while j >= 0 and ct[b[j]] >= i:
        cnt += 1
        j -= 1
    o[i] = (sum[j] if j >= 0 else 0) // i + cnt

ans = [0]
j = n
for i in range(1, n + 1):
    while j and o[j] < i:
        j -= 1
    ans.append(j)

print(*ans[1:])


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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long long int t{0};
	cin>>t;
	long long int zero{0};
	long long int n=1;
	if(t%2!=0)
	cout<<"0\n";
	else
	{
	while(t/(10*n))
	{
		zero+=t/(10*n);
		n=n*5;
	}
	cout<<zero<<"\n";
	}
	return 0;
}

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

int main(){
  double a,b;
  cin >> a;
  cin >> b;
  
  double m;
  m = (a+b)/2;
  int n;
  n = (a+b) /2;
  double g;
  g = m-n;
  
  cout << m + g<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(i=0;i<n;i++)
#define pb push_back
#define all(a) a.begin(),a.end()
#define fi first
#define se second
int M=1e9+7;
int mm(int x,int y){x%=M,y%=M;return (x*y)%M;}//Modular Multiply
int po(int x,int y){ if(!y)return 1;int a=po(x,y/2)%M;if(y%2)return mm(a,mm(a,x));return mm(a,a);}//(x**y)%M

signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n,s,mx=0;
	cin>>n>>s;
	int w[n],dp[s+1]={},v[n];
	for(int i=0;i<n;i++) cin>>w[i]>>v[i];
	for(int i=0;i<n;i++)
		for(int j=s;j>=w[i];j--) 
			dp[j]=max(dp[j-1],dp[j-w[i]]+v[i]);
	//cout<<dp[s];
	for(int i:dp) mx=max(mx,i);
	cout<<mx;
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    int2(h, w);
    vvi dp(10, vi(10, 0));
    rep(i, 10) rep(j, 10) cin >> dp[i][j];

    rep(k, 10) rep(i, 10) rep(j, 10) {
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
    }

    int ans = 0;
    rep(i, h) rep(j, w) {
        Int(tmp);
        if (tmp != -1) ans += dp[tmp][1];
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.Collections;

class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        List<Integer> prices = new ArrayList<>();

        for(int i=0; i<n; i++){
            prices.add(sc.nextInt());
        }
        sc.close();
        Collections.sort(prices);

        int sum =0;
        for(int i=0; i<k; i++){
            sum += prices.get(i);
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 38980