akhauriyash/Code-Regression huggingface dataset:
fun main(args: Array<String>) {

    val (n, m) = readLine()!!.split(" ").map{it.toInt()}

    val k = (1..n).map{ readLine()!!.split(" ").map { it.toInt() }.drop(1)}

    var list = k.first()
    for(i in k){
        list = i.intersect(list).toList()
    }

    println(list.size)
}


Measured memory_bytes: 37616
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+10;
struct node{
	int id,pos;
}e[N];
bool cmp(node a,node b){
	return a.id<b.id;
}
int n;
int ans[N];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&e[i].id);e[i].pos=i;
	}
	sort(e+1,e+1+n,cmp);
	for(int i=1;i<=n;i++)ans[i]=e[i].pos;
	for(int i=1;i<=n;i++){
		printf("%d%c",ans[i],i==n?'\n':' ');
	}
}


Measured memory_bytes: 2048
#include<iostream>
using namespace std;
int main(){
  int n,m,com[1010],mas[1010],bell;
  while(1){
    cin >> n >> m;
    if(n==0 && m==0){
      break;
    }
    for(int i=0;i<n;i++){
      cin >> mas[i];
    }
    for(int t=0;t<m;t++){
      cin >> com[t];
    }
    bell=0;
    int t;
    for(t=0;t<m;t++){
      bell+=com[t];
      bell+=mas[bell];
      //cout << endl << endl << bell << endl << endl;
      if(bell>=n-1){
	break;
      }
    }
    t++;
    cout << t << endl;
  }
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define va first
#define vb second
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int N, K, cnt;
string S;
int main() {
	cin >> N >> K >> S;

	for (int i=0; i<N-1; i++)
		if (S[i] == S[i+1]) ++cnt;

	cout << min(N-1, cnt+2*K);
}

Measured memory_bytes: 512
#!/usr/bin/python3.7
# -*- coding: utf-8 -*-

#ABC157C

b = False
n, m = list(map(int, input().split()))
sc = {}
for i in range(m):
	s, c = list(map(int, input().split()))
	if s not in sc:
		sc[s] = str(c)
	elif sc[s] != str(c):
		b = True

if b:
	print(-1)
elif n == 1 and m == 0:
	print(0)
else:
	ans = ''
	for i in range(1, n+1):
		if i not in sc:
			if i == 1:
				sc[i] = str(1)
			else:
				sc[i] = str(0)
		ans += sc[i]
	ans = str(int(ans))
	if len(ans) == n:
		print(ans)
	else:
		print(-1)
















Measured memory_bytes: 3064
N = int(input())
a = list(map(int, input().split()))
A = [0] + a + [0]

total_fee = 0
for i in range(N+1):
    total_fee += abs(A[i+1]-A[i])

ans_lst = [total_fee] * N
for j in range(N):
    ans_lst[j] -= abs(A[j+1]-A[j])
    ans_lst[j] -= abs(A[j+2]-A[j+1])
    ans_lst[j] += abs(A[j+2]-A[j])
    print(ans_lst[j])

Measured memory_bytes: 20620
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
typedef long long ll;
using namespace std;

int main(void)
{
	vector<int> a(3);
	cin >> a[0] >> a[1] >> a[2];
	sort(a.begin(), a.end());
	cout << a[0] + a[1] << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int ans=0;
	while(n)
	{
		ans+=n%10;
		n/=10;
	}
	if(ans==1) ans*=10;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

struct Info{
	Info(){
		team_id = num_ans = sum_time = 0;
	}
	int team_id,num_ans,sum_time;
};

void func(int TOTAL_TIME,int num_team,int num_problem,int num_log){
	Info info[num_team+1];
	int penaTable [num_team+1][num_problem+1];
	for(int i = 1; i <= num_team; i++){
		for(int k = 1; k <= num_problem; k++)penaTable[i][k] = 0;
	}

	for(int i = 1; i <= num_team; i++){
		info[i].team_id = i;
	}

	int m,t,p,j;

	for(int i = 0; i < num_log; i++){
		scanf("%d %d %d %d",&m,&t,&p,&j);

		if(j == 0){
			info[t].num_ans += 1;
			info[t].sum_time += (m + penaTable[t][p]);
		}else{
			penaTable[t][p] += 20;
		}
	}

	for(int i = 2; i <= num_team; i++){
		for(int k = num_team; k >= i; k--){
			if(info[k].num_ans > info[k-1].num_ans)swap(info[k],info[k-1]);
			else if(info[k].num_ans == info[k-1].num_ans && info[k].sum_time < info[k-1].sum_time)swap(info[k],info[k-1]);
			else if(info[k].num_ans == info[k-1].num_ans && info[k].sum_time == info[k-1].sum_time &&
					info[k].team_id > info[k-1].team_id)swap(info[k],info[k-1]);
		}
	}

	printf("%d",info[1].team_id);

	for(int i = 2; i <= num_team; i++){
		if((info[i].num_ans < info[i-1].num_ans) || (info[i].num_ans == info[i-1].num_ans && info[i].sum_time > info[i-1].sum_time)){
			printf(",%d",info[i].team_id);
		}else{
			printf("=%d",info[i].team_id);
		}
	}
	printf("\n");

}


int main(){

	int M,T,P,R;

	while(true){
		scanf("%d %d %d %d",&M,&T,&P,&R);
		if(M == 0 && T == 0 && P == 0 && R == 0)break;

		func(M,T,P,R);

	}

	return 0;
}

Measured memory_bytes: 2568
s = raw_input()

length = len(s)

for i in reversed(range(length)):
    s = s[:-1]
    l = len(s)
    tempa = l / 2
    temp = s
    s1 = temp[:tempa]
    s2 = temp[tempa:]
    
    if s1 == s2:
        print l
        break

Measured memory_bytes: 2568
let () =
    let split s =
        let rec loop i cur flag acc =
            if i = String.length s then ( if flag then cur :: acc else acc) else (
                match flag, s.[i] with
                | true,  ' ' -> loop (i + 1) "" false (cur :: acc)
                | false, ' ' -> loop (i + 1) "" false acc
                | true,  v   -> loop (i + 1) (Printf.sprintf "%s%c" cur v) true acc
                | false, v   -> loop (i + 1) (Printf.sprintf "%s%c" cur v) true acc
            )
        in
        List.map int_of_string (List.rev (loop 0 "" false []))
    in
    let main () =
        let n = int_of_string (read_line ()) in
        let p = Array.of_list (split (read_line ())) in
        let q = Array.copy p in
        let () = Array.sort compare q in
        let rec loop i acc =
            if i = n then acc else loop (i + 1) (if p.(i) <> q.(i) then acc + 1 else acc)
        in
        print_endline (if loop 0 0 <= 2 then "YES" else "NO")
    in
    main ()

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

#define ll long long
#define ull long long unsigned
#define vii vector<int>
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pdd pair<double,double>
#define pldld pair<long long double, long long double>
#define ff first
#define ss second
#define pb push_back
#define read freopen("alu.txt","r",stdin);
#define write freopen("vorta.txt","w",stdout);
#define fastio ios::sync_with_stdio(false); cin.tie(NULL);
#define PI 2*acos(0.0)

const int MAX=100005, MOD=1000000007;
const ll inf=1e9;

int arr[MAX];
bool vis[3001];
int a,b,c,d,e,f;
double mx=0;
int g_pani=0;
int g_chini=0;
double percent(int pani, int chini){
    double ret=100*chini;
    ret/=(pani+chini);
    return ret;
}

void solve(int pani){
    if(vis[pani]) return;
    vis[pani]=true;
    int max_chini=min(e*(pani/100), f-pani);
    int koto=max_chini/d;
    int chini=0, temp;
    for(int i=0;i<=koto;i++){
        temp=max_chini - i*d;
        temp/=c;
        temp*=c;
        chini=max(chini, temp+i*d);
    }
    double p=percent(pani,chini);
    if(mx<p){
        mx=p;
        g_pani=pani;
        g_chini=chini;
    }

    if(pani+(100*a)<=f) solve(pani+(100*a));
    if(pani+(100*b)<=f) solve(pani+(100*b));
}

int main(){

    fastio;
    cin>>a>>b>>c>>d>>e>>f;
    solve(100*a);
    if(100*b<=f) solve(100*b);
    if(!mx){
        g_pani=100*a;
        g_chini=0;
    }
    cout<<g_pani+g_chini<<" "<<g_chini<<"\n";

}











Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long i,j,n,m,p,k,l,Max,ans,t,ans2,B,r,b,d,ind,x,y,dp[200001],a[200001];
int main () {
    cin>>n>>k;
    for (i=1;i<=n;i++) {
        cin>>a[i];
        dp[i]=1000000000000;
    }
    dp[1]=0;
    dp[2]=abs(a[1]-a[2]);
    for (i=3;i<=n;i++) {
        for (j=1;j<=k;j++) {
            if (i-j<=0) continue;
            dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
        }
    }
    cout<<dp[n]<<endl;
    return 0;
}

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

int ary[110];
int main(){
	int n;
	while(cin>>n){
		ary[n]++;
	}
	vector<pair<int,int> > ve;
	for(int i=1;i<=100;i++){
		ve.push_back(make_pair(-ary[i],i));
	}
	sort(ve.begin(),ve.end());
	cout<<ve[0].second<<endl;
	for(int i=1;i<100;i++){
		if(ve[i-1].first!=ve[i].first)break;
		cout<<ve[i].second<<endl;
	}
	return 0;
}

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

signed main()
{
    int N,K; cin>>N>>K;
    vint a(N);
    REP(i,N) cin>>a[i];

    vint cnt(40);
    REP(i,40){
        REP(j,N){
            if(a[j]>>i&1) cnt[i]++;
        }
    }

    K++;

    int ans=0;
    int cur=0;
    for(int i=39;i>=0;i--){
        if(~K>>i&1){
            cur+=(1LL<<i)*cnt[i];
        }
        else{
            int sum=cur+(1LL<<i)*cnt[i];
            for(int j=i-1;j>=0;j--){
                sum+=(1LL<<j)*max(cnt[j],N-cnt[j]);
            }
            ans=max(ans,sum);
            cur+=(1LL<<i)*(N-cnt[i]);
        }
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 1024
h,w,k = map(int, input().split())
c = [list(input()) for _ in range(h)]
ans = 0
for pattern_h in range(2**h):
  for pattern_w in range(2**w):
    count = 0
    for i in range(h):
      for j in range(w):
        if (pattern_h>>i)&1==0 and (pattern_w>>j)&1==0:
          if c[i][j]=='#':
            count += 1
    if count == k:
      ans += 1
print(ans)


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

int main() {
  string a,b,c;int n,m;cin>>a>>b>>n>>m>>c;
  if (a==c) cout<<n-1<<" "<<m;
  else cout<<n<<" "<<m-1;
  return 0;
}

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

int main(){
  long n , q ;
  cin >> n >> q;
  long ans = 0;
  string str;
  cin >> str;
  vector<long> v;
  long t = 0;
  for(long i = 0 ; i < n ; i++){
      if(i > 0){
          if(str[i-1] == 'A' && str[i] == 'C'){
              t += 1;
          }
      }
      v.push_back(t);
  }

  long l , r;
  for(long j = 0; j < q ; j++){
      cin >> l >> r;
      cout << v[r-1] - v[l-1] << endl;
  }
  
  //cout << ans << endl;
  return 0;
}

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

int main(){
    string str, ans;
    cin >> str;

    for(int i=0; i<str.size(); i++){
        if(str[i]=='B'){
            if(ans.empty()){
            }else{
                ans.pop_back();
            }
        }else{
            ans.push_back(str[i]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <vector>
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;
const int mod=998244353;
const int maxn=100+5;
const int maxs=50000;
char S[maxn];
int all;
int dp[maxs];
map<vector<int>,int> mp;
inline int add(int x) {return x>=mod?x-mod:x;}
int DP(vector<int> v)
{
	if(v.size()==0) return 1;
	if(mp.count(v)) return dp[mp[v]];
	int s=mp[v]=++all;
	int n=v.size();
	vector<int> t;
	for(int i=1;i<n;++i) t.push_back(v[i]);
	dp[s]=add(DP(t)*(v[0]+1));
	for(int d=1;d*2<=n;++d)
	{
		vector<int> a;
		for(int i=0;i<d;++i) a.push_back(v[i]);
		for(int K=2;d*K<=n;++K)
		{
			int p=(K-1)*d;
			for(int i=0;i<d;++i) a[i]&=v[p+i];
			t.clear();
			for(int i=p+d;i<n;++i) t.push_back(v[i]);
			dp[s]=(dp[s]+(ll)DP(a)*DP(t))%mod;
		}
	}
//	debug("---\n");
//	for(int i=0;i<n;++i) debug("%d",v[i]); debug("\n");
//	debug("%d\n",dp[s]);
	return dp[s];
}
int main()
{
	scanf("%s",S);
	int len=strlen(S);
	vector<int> b;
	for(int i=0;i<len;++i) b.push_back(S[i]-'0');
	printf("%d\n",DP(b));
	return 0;
}

Measured memory_bytes: 7936
#include<cstdio>
const int mo=1e9+7;
int f[3050],pre[3050],suf[3050],n;
char s[3050];
int main(){
	scanf("%d%s",&n,s);
	f[1]=pre[1]=suf[1]=1;
	for (int i=2;i<=n;i++){
		if (s[i-2]=='<')for (int j=1;j<=i;j++)f[j]=pre[j-1];
		else for (int j=1;j<i;j++)f[j]=suf[j];
		for (int j=1;j<=i;j++)pre[j]=(pre[j-1]+f[j])%mo;
		for (int j=i;j>=1;j--)suf[j]=(suf[j+1]+f[j])%mo;
	}
	printf("%d",pre[n]);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){

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

temp=a[0];
a[0]=a[1];
a[1]=temp;

temp=a[0];
a[0]=a[2];
a[2]=temp;

for(int i=0;i<3;i++){
    
    
    cout<<a[i]<<" ";
}
return 0;
}


Measured memory_bytes: 3620
m=10**9+7

h,n=map(int,input().split())
a=[0]*n
b=[0]*n
for i in range(n):
    a[i],b[i]=map(int,input().split())

dp=[m]*(h+max(a)+1)
dp[0]=0
for i in range(1,h+max(a)+1):
    k=0
    for j in range(n):
        if i< a[j]:
            k=b[j]
        else:
            k=b[j]+dp[i-a[j]]
        dp[i]=min(k,dp[i])

ans=min(dp[h:h+max(a)+1])

print(ans)

Measured memory_bytes: 42220
#include <iostream>
#include <vector>
#include <set>
//#include <fstream>	// require freopen

using namespace std;

int main()
{
//	cut here before submit 
//	freopen ("testcase.cardgame0523", "r", stdin );
	int n;

	while (cin >> n && n ) {
		set <int> taro, hanako;
		vector <bool> used (2*n + 1, false );

		for (int i = 1; i <= n; ++i ) {
			int m;
			cin >> m;
			taro.insert (m );
			used[m] = true;
		} // end for

		for (int i = 1; i <= 2*n; ++i ) {
			if (!used[i] ){
				hanako.insert (i );
			} // end if
		} // end for
		
		int curr = 0;
		set<int>::iterator taroi, hanakoi;
 
		while (1) {

			taroi = taro.lower_bound (curr );
			if (taroi != taro.end() ) {
				curr = (*taroi );
				taro.erase (taroi++ );
			}else{
				curr = 0;
			} // end if
			
			if (taro.empty() ) {
				break;
			} // end if
			
			hanakoi = hanako.lower_bound (curr );			
			if (hanakoi != hanako.end() ) {
				curr = (*hanakoi );
				hanako.erase (hanakoi++ );
			}else{
				curr = 0;
			} // end if

			if (hanako.empty() ) {
				break;
			} // end if
		} // end while

		int taro_score = 0;
		int hanako_score = 0;

		if (taro.empty() ) {
			taro_score = hanako.size();
		}else if (hanako.empty() ) {
			hanako_score = taro.size();
		} // end if
		cout << taro_score << endl;
		cout << hanako_score << endl;

	} // end loop
		
	return 0;
}

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

using namespace std;
typedef long long ll;

const int MAX_N = 50000;
vector<int> prime;
int cnt[MAX_N + 10] = {};
bool is_prime[MAX_N + 1];

void sieve(int n) {
    for (int i = 0; i <= n; i++) is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;
    for (ll i = 2; i <= n; i++) {
        if (!is_prime[i]) continue;
        prime.push_back(i);
        for (ll j = i * i; j <= n; j += i) is_prime[j] = false;
    }
}

int main() {
    sieve(MAX_N);

    int sz = prime.size();
    for (int i = 0; i < sz; i++)
        for (int j = i; prime[i] + prime[j] <= MAX_N; j++)
            cnt[prime[i] + prime[j]]++;

    int n;
    while (scanf("%d", &n), n)
        cout << cnt[n] << endl;

    return 0;
}


Measured memory_bytes: 3444
def resolve():
    import sys
    input = sys.stdin.readline
    # 整数 1 つ
    #n, m = int(input())
    # 整数複数個
    n, m = map(int, input().split())
    # 整数 N 個 (改行区切り)
    A = [int(input()) for i in range(m)]
    # 整数 N 個 (スペース区切り)
    #A = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    Route = [0] * (n+1)
    Route[0] = 1
    MOD = 10**9 + 7

    is_safe = [True] * (n+1)
    for a in A:
        is_safe[a] = False

    if is_safe[1] == True:
       Route[1] = 1

    for i in range(2, n+1):
        if is_safe[i] == True:
            Route[i] = (Route[i-1] + Route[i-2]) % MOD
#            Route[i] %= MOD

    print(Route[n])
#    print(Route)
resolve()

Measured memory_bytes: 44892
import java.util.*;

class Main{

	public static ArrayList<String> nameM = new ArrayList<>();
	public static ArrayList<String> nameA = new ArrayList<>();
	public static ArrayList<String> nameR = new ArrayList<>();
	public static ArrayList<String> nameC = new ArrayList<>();
	public static ArrayList<String> nameH = new ArrayList<>();
	
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();



		for(int n=0;n<N;n++){
			String st = sc.next();
			switch(st.charAt(0)){
				case 'M':
				 nameM.add(st);
				break;
				case 'A':
				 nameA.add(st);
				break;
				case 'R':
				 nameR.add(st);
				break;
				case 'C':
				 nameC.add(st);
				break;
				case 'H':
				 nameH.add(st);
				break;
				default:
				break;
			}
		}

		long ns[] = new long[5];
		ns[0] = nameM.size();
		ns[1] = nameA.size();
		ns[2] = nameR.size();
		ns[3] = nameC.size();
		ns[4] = nameH.size();

		long count = 0;
		count += ns[0]*ns[1]*ns[2];
		count += ns[0]*ns[1]*ns[3];
		count += ns[0]*ns[1]*ns[4];
		count += ns[0]*ns[2]*ns[3];
		count += ns[0]*ns[2]*ns[4];
		count += ns[0]*ns[3]*ns[4];
		count += ns[1]*ns[2]*ns[3];
		count += ns[1]*ns[2]*ns[4];
		count += ns[1]*ns[3]*ns[4];
		count += ns[2]*ns[3]*ns[4];

		System.out.println(count);

	}
}

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

#define ll long long int

using namespace std;

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  if (abs(a-c) <= d || (abs(a-b) <= d && abs(b-c) <= d)) {                                                 cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

int main(){
  int n;
  cin >> n;
  int ans = 0;
  string s;
  for(int i = 1;i <= n;i++){
    s = to_string(i);
    if(s.size() % 2 == 1){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


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

const double coeff = 180 / 3.1415926535897932;
int main() {
  double a, b, x;
  cin >> a >> b >> x;
  x /= a;
  
  double area = a * b;
  double ans;
  if (x < area / 2) {
    double d = x / b * 2;
    double rad = atan(b / d);
    ans = rad * coeff;
  } else {
    double d = (area - x) / a * 2;
    double rad = atan(d / a);
    ans = rad * coeff;
  }
  cout << fixed << setprecision(16) << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long int i64;
#define SZ(v) int((v).size())
#define ALL(vec) (vec).begin(),(vec).end()
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string>) {}
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << a << endl; err(++it, args...); }
template<typename T1,typename T2> ostream& operator<<(ostream& os, pair<T1,T2>& buf) {
  return os << "(" << buf.first << ": " << buf.second << ")"; }
#define DefOut(Con) template<typename T>ostream&operator<<(ostream&os,Con<T>&A){ bool f = false; os << "{"; \
  for (auto &e: A) { if (f) os << ", "; os << e; f = true; } return os << "}"; }
#define DefOut2(Con) template<typename K,typename V>ostream&operator<<(ostream&os,Con<K,V>&A) \
{ bool f = false; os << "{"; for (auto &e: A) { if (f) os << ", "; os << e; f = true; } return os << "}"; }
template<typename T>ostream &operator << (ostream &os,vector<vector<T>>& A) {
  for (auto &B: A) os << '\n' << B; return os; }
DefOut(vector) DefOut(set) DefOut(multiset) DefOut2(map) 
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1000000007;
long long const INF = 1e18;
#define PI 3.14159265358979323846
/***********************************************************************/

int32_t main() {

  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int a, p;
  cin >> a >> p;
  p += a * 3;
  cout << p / 2 << '\n';
  
  return 0;
}


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

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(s...)  fprintf(stderr, s)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }

int N, A[444];

int main() {
    scanf("%d", &N);
    REP (i, 2 * N) scanf("%d", A+i);
    sort(A, A+ 2 * N);
    LL ans = 0;
    REP (i, N) ans += A[2 * i];
    printf("%lld\n", ans);


    return 0;
}



Measured memory_bytes: 764
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;

int main(){
  int n;
  cin >> n;
  bool ans  = false;
  int cn = 0;
  vector<int> inv(100);
  vector<int> vec(n);
  REP(i, n){
    cin >> vec[i];
    if (i + 1 != vec[i]){
      inv[cn] = vec[i];
      cn++;
    }
  }

  if (cn == 2 && vec[inv[0]-1] == inv[1] && vec[inv[1]-1] == inv[0]){
    ans = true;
  }else if (cn == 0){
    ans = true;
  }

  if (ans) cout << "YES\n";
  else cout << "NO\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
#define ll long long
int main(){
    int w,a,b;
    cin>>w>>a>>b;
    if(!(a+w<b)&&!(b+w<a))cout<<0<<endl;
    else if(a+w<b)cout<<b-a-w<<endl;
    else cout<<a-b-w<<endl;
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <cstring>

using namespace std;

long long gcd(long long a,long long b)
{
    if(a==0)return b;
    else return gcd(b%a,a);
}
int main()
{
    long long n,a[100],g,d;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    d=a[0];
    for(int i=1;i<n;i++)
    {
        g=gcd(d,a[i]);
        d*=(a[i]/g);
    }
    cout<<d;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
typedef long long ll;
using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(a+b,min(b+c,a+c)) << endl;

    return 0;
}

Measured memory_bytes: 256
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debugg cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
ll n,t;

typedef struct node{
    ll xx,yy,hh;
}node;
void solve()
{
    cin>>n;
    vector<node> ar(n),ans;
    node nn;
    for(int i=0;i<n;i++)
    {
        cin>>ar[i].xx>>ar[i].yy>>ar[i].hh;
        if(ar[i].hh>=1)
            nn=ar[i];
    }
    for(int x=0;x<=100;x++)
    {
        for(int y=0;y<=100;y++)
        {
            ll H=max(0ll,nn.hh+abs(nn.xx-x)+abs(nn.yy-y));
            bool flag=0;
            for(int i=0;i<n;i++)
            {
                if(max(0ll,H-abs(ar[i].xx-x)-abs(ar[i].yy-y))!=ar[i].hh)
                    {flag=1;break;}
            }
            if(!flag)
            {
                node aaa;
                aaa.xx=x;aaa.yy=y;aaa.hh=H;
                ans.pb(aaa);
            }
        }
    }
    if(ans.size()==1)
        cout<<ans[0].xx<<" "<<ans[0].yy<<" "<<ans[0].hh<<endl;
}
int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
    //int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var N = long.Parse(ReadLine());

        static IEnumerable<long> GetSemi753Num()
        {
            var _357 = new long[] { 3, 5, 7 };
            var q = new Queue<long>(_357);

            while(true)
            {
                var n = q.Dequeue();

                yield return n;

                foreach (var m in _357)
                    q.Enqueue(n * 10 + m);
            }
        }

        static bool Is753Num(long n) => (n.ToString().Select(c => c - '0').Select(x => 1 << x).Aggregate((s, e) => s | e) & 0xA8) == 0xA8;

        var ans = 0;

        foreach(var n in GetSemi753Num().TakeWhile(x => x <= N).Where(x => Is753Num(x)))
            ans++;

        WriteLine(ans);
    }
}


Measured memory_bytes: 37792
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define clr clear()
#define ins insert
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define rep(i,n) for(__typeof(n) i=0; i<(n); i++)
#define mem(x,val) memset((x),(val),sizeof(x));
#define cusmem(x,val) for(auto &i:x) i=val;
#define all(x) x.begin(),x.end()
#define fastio ios_base::sync_with_stdio(false);\
            cin.tie(NULL);\
            cout.tie(NULL);
using namespace std;
typedef pair<int,int> pii;
typedef pair<ll,ll>pll;
typedef pair<ll,int>pli;
typedef vector<ll> vl;
typedef vector<pll> vpll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<pii> vpii;
string impossible;

mt19937 mt_rand(chrono::high_resolution_clock::now().time_since_epoch().count());

// const int N=6;
const int N=5e2+5;
const int M=1e4+5;
const int L=41;
int MOD=1e9+7;
ll n,m,k,i,j,d;
bool f0,f1,f2;
const int MAXN=2e3;
int main(){
    #ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin); 
            freopen("output.txt","w",stdout);
    #endif
    fastio
    cout<<fixed<<setprecision(11);
    int tests=1;    
    // cin>>tests;
    for(int te=1;te<=tests;te++){
        int n;  cin>>n;
        int l[n],ans=0;
        for(int i=0;i<n;i++)    cin>>l[i];
        sort(l,l+n);
        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[i]==l[j]||l[j]==l[k]||l[k]==l[i])  continue;
                    if(l[k]<l[i]+l[j])  ans++;
                }
            }
        }
        cout<<ans;

    }
    return 0;
}





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

int main()
{
    int h,w;
    cin >> h >> w;
    char c[h][w] = {};
    for(int i = 0; i<h; i++){
        for(int j = 0; j<w; j++){
            cin >> c[i][j];
        }
    }
    for(int i = 0; i<2*h; i++){
        for(int j = 0; j<w; j++){
            cout << c[i/2][j];
        }
        cout << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<ll> vc;
typedef unordered_map<ll,ll> umap;
#define pb emplace_back
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
const ll mod = 1e9+7;

typedef long long number;
typedef vector<number> arr;
typedef vector<arr> matrix;

// O( n )
matrix identity(int n) {
    matrix A(n, arr(n));
    for (int i = 0; i < n; ++i) A[i][i] = 1;
    return A;
}
// O( n )
number inner_product(const arr &a, const arr &b) {
    number ans = 0;
    for (int i = 0; i < a.size(); ++i)
        ans += a[i] * b[i];
    return ans;
}
// O( n^2 )
arr mul(const matrix &A, const arr &x) {
    arr y(A.size());
    for (int i = 0; i < A.size(); ++i)
        for (int j = 0; j < A[0].size(); ++j)
            y[i] += A[i][j] * x[j];
    return y;
}
// O( n^3 )
matrix mul(const matrix &A, const matrix &B) {
    matrix C(A.size(), arr(B[0].size()));
    for (int i = 0; i < C.size(); ++i)
        for (int j = 0; j < C[i].size(); ++j)
            for (int k = 0; k < A[i].size(); ++k)
                C[i][j] = (C[i][j] + A[i][k] * B[k][j] % mod) % mod;
    return C;
}
// O( n^3 log e )
matrix mpow(const matrix &A, long long e) {
    return e == 0 ? identity(A.size()) :
    e % 2 == 0 ? mpow(mul(A, A), e/2) : mul(A, mpow(A, e-1));
}

int main() {
    // your code goes here
    ll n, k, in, ot=0;
    matrix ans;
    cin >> n >> k;
    rep(i,0,n-1){
    	arr inp;
    	rep(j,0,n-1) {
    		cin >> in;
    		inp.pb(in);
    	}
    	ans.pb(inp);
    }
    ans = mpow(ans, k);
    rep(i,0,n-1){
    	rep(j,0,n-1) {
    		ot = (ot + ans[i][j]) % mod;
    	}
    }
    cout << ot << endl;
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int dx=c-a, dy=d-b;
    cout<<c-dy<<" "<<d+dx<<" "<<a-dy<<" "<<b+dx<<endl;
}

Measured memory_bytes: 256
/**
 *    author:  FromDihPout
 *    created: 2020-08-03
**/

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


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vector<int> twos(3);
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (x % 4 == 0) {
            twos[2]++;
        }
        else if (x % 2 == 0) {
            twos[1]++;
        }
        else {
            twos[0]++;
        }
    }
    
    if (twos[2] + 1 < twos[0]) {
        cout << "No" << '\n';
    }
    else if (twos[2] < twos[0] && twos[1] > 0) {
        cout << "No" << '\n';
    }
    else if (twos[2] == 0 && twos[0] > 0) {
        cout << "No" << '\n';
    }
    else {
        cout << "Yes" << '\n';
    }
    return 0;
}

Measured memory_bytes: 3656
N, K, Q = gets.split.map(&:to_i)
A = Q.times.map { gets.to_i }
member_points = Array.new(N, K - Q)

A.each do |a|
  member_points[a-1] += 1
end

member_points.each do |mp|
  if mp > 0
    puts "Yes"
  else
    puts "No"
  end
end


Measured memory_bytes: 4148
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define REP(i, N) for(int i = 0; i < N; ++i)
#define REEP(i, N) for(int i = N - 1; i >= 0; --i)
#define ALL(a) (a).begin(),(a).end()
#define FOR(i,m,n) for(int i = m; i < n; ++i)
#define RFOR(i,m,n) for(int i = n - 1; i >= m; --i)
#define CIN(a) cin >> a
#define CIN2(a, b) cin >> a >> b
#define CIN3(a, b, c) cin >> a >> b >> c
#define COUT(a) cout << a << endl
#define COUT2(a, b) cout << a << " " << b << endl
#define COUT3(a, b, c) cout << a << " " << b << " " << c << endl
#define pb push_back
#define PB push_back
#define VINT(v, n) vector<int> v(n); REP(i, n) { v[i] = 0 }
#define VINT2(v, n, m) vector<vector<int> > v(n, vector<int>(m)); REP(i, n) { REP(j, m) { v[i][j] = 0 } }
#define VCHAR(v, n) vector<char>v(n)
#define KIRIAGE(a, b) a += (b - a % b) % b
#define CEIL(c, a, b) if(a % b == 0) { c = a / b;} else { c = a / b + 1;}
#define sp(n) setprecision(n)
#define INF 1000000000
#define MOD 1000000007

using namespace std;
typedef pair<int, int> P;
typedef long long ll;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
	int N, x = 0, ans = 0;
	string S;
	CIN2(N, S);
	REP(i, N) {
		if(S[i] == 'I') ++x;
		else --x;
		ans = max(ans, x);
	}
	COUT(ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int ans=0;
    while(true){
        bool flag=true;
        for(int i=0;i<n;i++){
            if(a[i]%2==0)a[i]/=2;
            else flag=false;
        }
        if(!flag)break;
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    string s,x;
  cin>>s;
ll a,n,c,i,j,k=999999999,l,b;
for(i=0;i+3<=s.size();i++)
{
 x+=s[i];x+=s[i+1];x+=s[i+2];
stringstream ab(x);
        ab>>b;
    c=abs(753-b);
    k=min(k,c);
x="";
}
cout<<k<<endl;
  }

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

import static java.lang.Integer.parseInt;

/**
 * Lottery Checker
 */
public class Main {

	static final int LEN = 8;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int n, m;
			n = parseInt(line.substring(0, line.indexOf(' ')));
			m = parseInt(line.substring(line.indexOf(' ') + 1));
			if ((n | m) == 0) break;

			Map<String, Integer> hits = new HashMap<>();

			for (int i = 0; i < n; i++) {
				words = br.readLine().split(" ");
				hits.put(words[0].replace("*", ""), parseInt(words[1]));
			}

			int sum = 0;

			for (int i = 0; i < m; i++) {
				String lott = br.readLine();
				int max = 0;
				for (int j = 0; j <= LEN; j++) {
					String _lott = lott.substring(j, LEN);
					if (hits.get(_lott) != null) {
						max = Math.max(max, hits.get(_lott));
					}
				}
				sum += max;
			}

			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 39796
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;
struct Edge{ll from, to, cost;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N, M;
  cin >> N >> M;
  vector<llvec>s(N);
  rep(i, M){
    ll tmp;
    cin >> tmp;
    rep(j, tmp){
      ll a;
      cin >> a;
      a--;
      s[a].push_back(i);
    }
  }
  llvec p(M);
  rep(i, M){
    cin >> p[i];
  }
  ll cnt = 0;
  rep(i, pow(2, N)){
    vector<ll> ans(M, 0);
    //llvec dig(N);
    rep(j, N){
      //dig[j]=i>>j&1;
      if(i>>j&1){
        rep(ii, s[j].size()){
          ans[ s[j][ii] ] += 1;
        }
      }
    }
    //DUMP(k, dig);
    //DUMP(k, ans);cout << endl;
    bool tmp = true;
    rep(j, M){
      tmp = tmp and (ans[j]%2==p[j]);
    }
    
    if(tmp)cnt++;
  }

  cout << cnt;
  return 0;
}


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

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            string str, ops;
            while ((str = Console.ReadLine()) != null)
            {
                ops = "";
                foreach (var v in str)
                {
                    ops = v + ops;
                }
                Console.WriteLine(ops);
            }
        }
    }
}

Measured memory_bytes: 17480
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    if(b == 1) {
        cout << 0 << endl;
        return 0;
    }

    if(a >= b) {
        cout << 1 << endl;
        return 0;
    }

    int ans = 0;
    for(int num = 1; ; num += a-1) {
        if(num >= b) {
            cout << ans << endl;
            return 0;
        }
        ans++;
    }

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        var s = Console.ReadLine();
        var ans = 1145141919;

        for (var c = 'a'; c <= 'z'; c++)
        {
            var cnt = Count(s, c);
            ans = cnt < ans ? cnt : ans;
        }

        Console.WriteLine(ans);
        return;
    }

    static int Count(string s, char c)
    {
        for (var i = 0; ; i++)
        {
            if (s.GroupBy(x => x).Count() == 1) return i;

            var t = new char[s.Length - 1];

            for (var j = 0; j < s.Length - 1; j++)
            {
                if (s[j] == c) t[j] = s[j];
                else t[j] = s[j + 1];
            }

            s = new string(t);
        }
    }
}

Measured memory_bytes: 15444
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <math.h>
#include <queue>
#include <list>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <ctime>
#include <iomanip>
#include <fstream>
using namespace std;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define IN(x,c) (find(c.begin(),c.end(),x) != (c).end())
#define REP(i,n) for (int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for (int i=(a);i<=(b);i++)
#define INIT(a,v) memset(a,v,sizeof(a))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
template<class A, class B> A cvt(B x) { stringstream ss; ss<<x; A y; ss>>y; return y; }

#define SPC << " " <<
#define DEBUG(x) cerr << #x << " = "; cerr << x << endl;
#define DEBUG_ITER(x) cerr << #x << " = "; for (auto _ : x) cerr << _ << ' '; cerr << endl;

typedef pair<int,int> PII;
typedef long long int64;
typedef vector<int> VI;

int main() {
	//freopen("test.in","r",stdin);
	int n;
	string s,t;
	cin >> n >> s;
	t=s;
	sort(ALL(t));
	int d=0;
	REP (i,n) {
		if (s[i]!=t[i]) d++;
	}
	printf("%d\n",d/2);
	return 0;
}


Measured memory_bytes: 3920
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
   long long a;
    cin >> a;
    long long f=0,g=1;
    while(f !=1){
        if(a ==1){
            cout << 1<<endl;
            f=1;
            break;
        }
        if(g*g <= a){
            g++;
        }else{
            cout << (g-1)*(g-1) << endl;
            f=1;
        }
    }
    
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
#include<ext/pb_ds/priority_queue.hpp>
using namespace std;

const int maxn = 2E5 + 5;

int n,A[maxn],T[maxn],f[maxn],pos[maxn];

inline bool Check(int x,int y,int z)
{
	if (pos[x] < pos[y] && pos[y] < pos[z]) return 1;
	if (pos[z] < pos[x] && pos[x] < pos[y]) return 1;
	if (pos[y] < pos[z] && pos[z] < pos[x]) return 1;
	return 0;
}

int main()
{
	#ifdef DMC
		freopen("DMC.txt","r",stdin);
	#endif
	
	cin >> n;
	for (int i = 1; i <= n; i++) scanf("%d",&A[i]),pos[A[i]] = i;
	for (int i = n - 1; i; i--)
	{
		if (!T[i + 1])
		{
			if (pos[i + 1] < pos[i])
			{
				T[i] = 1; f[i] = i + 1;
			}
		}
		else
		{
			if (Check(f[i + 1],i,i + 1))
			{
				T[i] = T[i + 1]; f[i] = f[i + 1];
			}
			else
			{
				T[i] = T[i + 1] + 1; f[i] = i + 1;
			}
		}
	}
	cout << T[1] << endl;
	return 0;
}

Measured memory_bytes: 3328
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

void solve();

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

void solve(){
    double n,m,d;cin>>n>>m>>d;
    double ans=(m-1)*(d==0?n:2*(n-d))/(n*n);
    cout<<fixed<<setprecision(8)<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

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

	int odd = 0, even = 0;
	rep(i, n) {
		int a;
		cin >> a;
		if (a % 2)
			odd++;
		else
			even++;
	}

	if (odd == 0 or even == 0)
		cout << 0 << endl;
	else {
		odd--;
		int ans = odd / 2;
		even += odd / 2;
		ans += even;
		cout << ans << endl;
	}
}



Measured memory_bytes: 3108
#include "bits/stdc++.h"
/*#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>
*/
#define int long long
#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define REV(i,a,n) for(int i=n;i>=a;--i)
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define show(n) cerr<<#n<<" = "<<n<<endl
#define showp(n) cerr<<n.fs<<", "<<n.sc<<endl
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl
#define showsp(n) for(auto z:n){cerr<<z.fs<<" "<<z.sc<<", "}cerr<<endl

#define yes puts("Yes")
#define no puts("No")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

inline void io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}
inline int   in(){int n;scanf("%lld",&n);return n;}
inline void out(int n){printf("%lld\n",n);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

int digit;
string num;
vi results;
int sml,bg,res;

void solve(){
    int cnt=0;
    int st;
    while(++cnt){
        sort(all(num));
        sscanf(num.c_str(),"%lld",&sml);
        sort(rall(num));
        sscanf(num.c_str(),"%lld",&bg);
        res=bg-sml;
        bool f=false;
        rep(i,results.size()){
            if(results[i]==res){
                st=i;
                f=true;break;
            }
        }
        if(f) break;
        else{
            results.pb(res);
            num=to_string(res);
            while(num.size() < digit) num.append("0");
        }
    }
    cout<<st<<" "<<res<<" "<<cnt-st<<endl;
}

signed main() {
    io();

    while(cin>>num>>digit,digit){
        results.clear();
        sscanf(num.c_str(),"%lld",&res);
        results.pb(res);
        while(num.size() < digit) num.append("0");
        solve();
    }
    
    return 0;
}



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

using namespace std;

class DisjointSet {
    public:
        vector<int> rank, p;
        
        DisjointSet(){}
        DisjointSet(int size) {
            rank.resize(size, 0);
            p.resize(size, 0);
            for(int i = 0; i < size; i++) makeSet(i);
        }
        
        void makeSet(int x) {
            p[x] = x;
            rank[x] = 0;
        }
        
        bool same(int x, int y) {
            return findSet(x) == findSet(y);
        }
        
        void unite(int x, int y) {
            link(findSet(x), findSet(y));
        }
        
        void link(int x, int y) {
            if(rank[x] > rank[y]) {
                p[y] = x;
            }else {
                p[x] = y;
                if(rank[x] == rank[y]) {
                    rank[y]++;
                }
            }
        }
        
        int findSet(int x) {
            if(x != p[x]) {
                p[x] = findSet(p[x]);
            }
            return p[x];
        }
};

int main() {
    int n, a, b, q;
    int t;
    
    cin >> n >> q;
    DisjointSet ds = DisjointSet(n);
    
    for(int i = 0; i < q; i++) {
        cin >> t >> a >> b;
        if(t == 0) ds.unite(a, b);
        else if(t == 1) {
            if(ds.same(a, b)) cout << 1 << endl;
            else cout << 0 << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3184
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <climits>
#include <cassert>

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 ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e) != (s).end())
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
#define REP(i,n) FOR(i,0,n)

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

int main()
{
	int N;
	while(cin >> N, N) {
		vvi pos(N, vi(2, 0));
		pos[0][0] = pos[0][1] = 0;
		
		int n, d;
		FOR(i, 1, N) {
			cin >> n >> d;
			pos[i][0] = pos[n][0] + dx[d];
			pos[i][1] = pos[n][1] + dy[d];
		}

		int maxx = 0, minx = 0, maxy = 0, miny = 0;
		REP(i, N) {
			maxx = max(maxx, pos[i][0]);
			minx = min(minx, pos[i][0]);
			maxy = max(maxy, pos[i][1]);
			miny = min(miny, pos[i][1]);
		}

		int width = maxx-minx+1;
		int height = maxy-miny+1;

		cout << width << " " << height << endl;
	}
}

Measured memory_bytes: 1224
#include <iostream>
  #include <string>
  #include <vector>
  #include <algorithm>
  #include <utility>
  using namespace std;
  typedef long long ll;
  #define rep(i,n) for (int i=0;i < (int)(n);i++)

  int main(){
   int n;
   cin >> n;
   vector<int> v(n);
   int mn= 1 << 30;
   rep(i,n){
     cin >> v[i];
     mn=min(mn,v[i]);
   }
   while(1){
     int tmp = 1 << 30;
     rep(i,n){
         if (v[i]%mn > 0) v[i] = v[i]%mn;
         tmp=min(tmp,v[i]);
     }
     if (tmp == mn) break;
     else mn=min(mn,tmp);
   }
   cout << mn << endl;
    
    


    return 0;
  }



Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    int n;
    cin >> n;
    int a[n];
    vector<int> v;
    for (int i=0; i<n; i++) {
        cin >> a[i];
        v.push_back(a[i]);
    }
    sort(v.begin(), v.end(), greater<>());
    for (int i=0; i<n; i++) {
        if (a[i] == v[0]) {
            cout << v[1] << endl;
        } else {
            cout << v[0] << endl;
        }
    }
}

Measured memory_bytes: 3316