akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>
#include <cstdlib>
#include <numeric>
#include <queue>
#include <complex>
#include <sstream>
#include <stack>

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef complex<double> Point;

int calculate(const char* str, int begin, int end);
int getNumber(const char* str, int begin, int end)
{
	bool minus = false;
	
	if(str[begin] == '('){
		int depth = 1;
		int index;
		for(index=begin+1; depth; ++index){
			depth += str[index] == '(';
			depth -= str[index] == ')';
		}
		return calculate(str, begin+1, index-1);
	}
	else if(str[begin] == '-'){
		minus = true;
		++begin;
	}else if(str[begin] == '+')
		++begin;
	
	int num = 0;
	for(int i=begin; i<end && isdigit(str[i]); ++i)
		num = num*10 + str[i] - '0';
	if(minus)
		num *= -1;
	return num;
}

int getTerm(const char* str, int begin, int end)
{
	int num = 1;
	int index = begin;
	int depth = 0;
	char operation = '*';
	for(int i=begin; i<=end; ++i){
		if(i<end){
			depth += str[i] == '(';
			depth -= str[i] == ')';
		}
		
		if(depth == 0){
			if(i==end || str[i] == '*' || str[i] == '/'){
				if(operation == '*')
					num *= getNumber(str, index, i);
				if(operation == '/')
					num /= getNumber(str, index, i);
				if(i<end)
					operation = str[i];
				index = i+1;
			}
		}
	}

	return num;
}

int calculate(const char* str, int begin, int end)
{
	int num = 0;
	int index = begin;
	int depth = 0;
	char operation = '+';
	for(int i=begin; i<=end; ++i){
		if(i<end){
			depth += str[i] == '(';
			depth -= str[i] == ')';
		}
		if(depth == 0){
			if(i==end || str[i] == '+' || str[i] == '-'){
				if(operation == '+')
					num += getTerm(str, index, i);
				if(operation == '-')
					num -= getTerm(str, index, i);
				if(i<end)
					operation = str[i];
				index = i+1;
			}
		}
	}
	
	return num;
}

int main()
{
	int n;
	scanf("%d", &n);
	rep(i, n){
		char str[128];
		scanf("%s", str);
		printf("%d\n", calculate(str, 0, strlen(str)-1));
	}

	return 0;
}

Measured memory_bytes: 0
# -*- coding: utf-8 -*-
n, m, x = map(int,input().split())
a = [int(i) for i in input().split()]

ans1 = 0
tmp1 = []
for i in range(x):
    tmp1.append(i)
for j in range(m):
    if a[j] in tmp1:
        ans1 += 1

ans2 = 0
tmp2 = []
for i in range(x, n + 1):
    tmp2.append(i)
for j in range(m):
    if a[j] in tmp2:
        ans2 += 1
print(min(ans1,ans2))


Measured memory_bytes: 3064
x, k, d = map(int, input().split())
maxi = k * d
res = x

if x < 0:
    x = abs(x)

if x - maxi >= 0:
    res = x - maxi
else:
    p = x % d
    m = p - d
    rest = k - (x // d)
    if rest % 2 == 1:
        res = m
    else:
        res = p

print(abs(res))

Measured memory_bytes: 61860
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  int N;
  cin >> N;
  bool answer =false;
  for(int i=1;i<10;i++)
  {
    for(int j=1;j<10;j++)
    {
      if(N==i*j)
      {
        cout << "Yes" << endl;
        answer = true;
        return 0;
      }
    }
  }
  if(answer == false)
  {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
N = int(input())
T,A=map(int, input().split())
H = list(map(int, input().split()))

min_v = 10 ** 10
index = 0
for i in range(N):
    diff = abs((T - H[i] * 0.006) - A)
    if diff < min_v:
        min_v = diff
        index = i + 1


print(index)



Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<float.h>

int main(){
	int n;
	int sum=0;
	int minIndex;
	double ave;
	double dMin= DBL_MAX;
	std::vector<int> aList;

	std::cin>>n;
	aList.resize(n);

	for(int i=0; i<n; i++)
		std::cin>>aList[i];

	for(int i=0; i<n; i++)
		sum+= aList[i];

	ave= double(sum)/double(n);

	for(int i=0; i<n; i++){
		if(dMin> std::fabs(ave-double(aList[i]))){
			dMin= std::fabs(ave-double(aList[i]));
			minIndex= i;
		}
	}

	std::cout<< minIndex<<std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL endl
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;
#define deb(x) cout << #x": " << (x) << endl;
const lli N = 1e7;
const lli INF = 1e14;
const lli mod = 1e9+7;

// ---- コーディングはここから！ ('-')7


int main(){_
	lli a,b,c,k; cin>>a>>b>>c>>k;
	auto can=[&](){
		if(b>a and c>b)return c*=2;
		if(b<=a)return b*=2;
		if(c<=b)return c*=2;
		return 0LL;
	};
	fore(i,0,k)can();
	bool p = b>a and c>b;
	cout<<(p?"Yes":"No")<<ENDL;

}


Measured memory_bytes: 3636
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>

using namespace std;


int main()
{

    int n;scanf("%d",&n);
    vector<long long> a(n+1);
    for (int i=0;i<n;++i)
        scanf("%lld",&a[i]);
    long long money=1000,stock=0;
    for (int i=0;i<n;++i){
        money+= stock*a[i];
        stock=0;
        if (a[i+1]>a[i]){
            stock = money/a[i];
            money -= stock*a[i];
        }
    }
    printf("%lld\n",money);

}

Measured memory_bytes: 3220
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <cfloat>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )

#define ITER( c ) __typeof( (c).begin() )
#define EACH( it, c ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()

#define PB( n ) push_back( n )
#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
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

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

	VVI nums;
	int N;

	{
		vector< queue<int> > ques;
		string buf;
		while ( cin >> buf )
		{
			ques.PB( queue<int>() );
			replace( ALL( buf ), ',', ' ' );

			ISS iss( buf );
			int tmp;
			while ( iss >> tmp )
			{
				ques.back().push( tmp );
			}
		}

		N = ques.size() / 2 + 1;

		REP( i, 0, N )
		{
			while ( ques[0].empty() )
			{
				ques.erase( ques.begin() );
			}

			nums.PB( VI() );
			REP( j, 0, N )
			{
				nums.back().PB( ques[j].front() );
				ques[j].pop();
			}
		}
	}

	VVI dp( nums );
	REP( i, 0, N )
	{
		REP( j, 0, N )
		{
			if ( i )
			{
				dp[i][j] = max( dp[i][j], dp[ i - 1 ][j] + nums[i][j] );
			}

			if ( j )
			{
				dp[i][j] = max( dp[i][j], dp[i][ j - 1 ] + nums[i][j] );
			}
		}
	}

	cout << dp.back().back() << endl;

	return 0;
}

Measured memory_bytes: 1348
#include <iostream>
#include <stdio.h>
#include <cctype>
#include <cstring>
using namespace std;

int main()
{
	char str1[101], str2[101], str3[201];
	cin >> str1 >> str2;
	//scanf("%s%s", str1, str2);

	strcpy(str3, str1);
	strcat(str3, str1);
	
	if(strstr(str3, str2) == NULL)
		puts("No");
	else
		puts("Yes");
	
	return 0;
}



Measured memory_bytes: 3084
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
m = sum(b)
for i in range(n-1):
  if a[i]+1 == a[i+1]:
    m += c[a[i]-1]
    
print(m)

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int d, t, s;
    cin >> d >> t >> s;

    if (d > s * t)
        cout << "No\n";
    else
        cout << "Yes\n";

    return 0;
}


Measured memory_bytes: 3612
#pragma GCC optimize ("O3")
///#include<bits/stdc++.h>
#include <iterator>
#include<algorithm>
#include<vector>
#include<complex>
#include<cmath>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<math.h>
#include<map>
#include<stack>
#include<sstream>
#include<queue>
#include<list>
#include<iomanip>
#include<bitset>
#include<limits.h>
#include <iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<algorithm>
#include<set>
#include<math.h>
#include<map>
#include<stack>
#include<sstream>
#include<queue>
#include<list>
#include<iomanip>
#include<bitset>
#include<limits.h>
#include<map>
#include<sstream>
using namespace std;



/// Info.
///****************************************************************************************************************************************///
/// Coder               : BAHAA El_DEEN OSAMA SAYED.
/// Problem name        : E - String Rotation
/// Method              : IM
/// Date                : 2/3/2020
///****************************************************************************************************************************************///


#define rep0(i,x)         for(int i=0; i<x ;++i)
#define all(v)           ((v.begin()),((v.end())
#define mm(v,d)          memset(v,d,sizeof(v))
#define lp(i,v)          for(int i=0;i<sizeof(v);++i)
#define lpi(i,j,n)       for(int i=(j);i>=(int)n;++i)
#define lpd(i,j,n)       for(int i=(j);i>=(int)n;--i)
#define MP               make_pair
#define SZ(v)            ((int) ( (v).size() ) )
#define ull              unsigned long long
#define ll               long long
#define pi               3.1415926536
#define oo               1e9
#define OO               1e18
#define Fx(n)            fixed<<setprecision(n)
#define FasterIO           std::ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define RE0              return 0
#define RE1              return 1
#define mp(a,b)          make_pair(a,b)
#define X                first
#define Y                second
#define pii              pair(int a, int b)
#define rep1(i,x)        for(int i=1;i<=x;++i)
#define rep2(i,x)        for(int i=2;i<x;++i)
#define RE               return
//#define LD               long double
#define all(v) ((v).begin()),((v).end())


const  int  N   = (int) 1e5+100;
const  int  M   = (int) 1e4+4;
const  int  INF = (int) 0x3f3f3f3f;
///const double ESP = 1e-7;
///const ll MOD=1e8+9;


deque<char>Q;
string s, t;
int cnt=0,cnt2=0;


int GalhO0O0O0O0O0M()
{
    cin >> s >> t;
    rep0(i,s.length()){Q.push_back(t[i]);}


    rep0(i,s.length())
    {

        Q.push_front(Q[s.length()-1]);
        Q.pop_back();

        rep0(j,s.length())
        {
            if (Q[j] != s[j])
            {
                cnt2++;
            }
        }
        if(cnt2==0){
            cout << "Yes" << endl;
            RE0;
        }else{
            cnt2 = 0;
        }
    }
    cout << "No" << endl;


}




int main()
{
FasterIO;
GalhO0O0O0O0O0M();
RE0;}


Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 14.07.2018 15:19:07       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int ans = 0;
  int beg = 0;
  while (beg < n) {
    int end = beg;
    while (end + 1 < n && a[end + 1] == a[beg]) {
      end++;
    }
    int len = end - beg + 1;
    ans += len / 2;
    beg = end + 1;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
# frozen_string_literal: true

n, y = gets.split.map(&:to_i)

0.upto(n) do |i_10000|
  0.upto(n - i_10000) do |i_5000|
    i_1000 = n - (i_10000 + i_5000)
    if y == (i_10000 * 10_000 + i_5000 * 5000 + i_1000 * 1000)
      puts "#{i_10000} #{i_5000} #{i_1000}"
      exit
    end
  end
end

puts '-1 -1 -1'


Measured memory_bytes: 1788
import sys
readline = sys.stdin.buffer.readline

n,k = map(int,readline().split())
vs = list(map(int,readline().split()))

L=18
xid=[0]*(n*L)
xsum=[0]*(n*L)
yid=[0]*(n*L)
ysum=[0]*(n*L)

j=n
for i in reversed(range(n)):
	while i<j and vs[i]+k<=vs[j-1]:
		j-=1
	xid[i*L+0]=j
	xsum[i*L+0]=j
	for lv in range(1,L):
		a=xid[i*L+lv-1]
		if a==n:
			xid[i*L+lv]=n
		else:
			xid[i*L+lv]=xid[a*L+lv-1]
			xsum[i*L+lv]=xsum[i*L+lv-1]+xsum[a*L+lv-1]

j=-1
for i in range(n):
	while j<i and vs[j+1]+k<=vs[i]:
		j+=1
	yid[i*L+0]=j
	ysum[i*L+0]=j
	for lv in range(1,L):
		a=yid[i*L+lv-1]
		if a==-1:
			yid[i*L+lv]=-1
		else:
			yid[i*L+lv]=yid[a*L+lv-1]
			ysum[i*L+lv]=ysum[i*L+lv-1]+ysum[a*L+lv-1]

q=int(readline())
for tmp in range(q):
	l,r=map(int,readline().split())
	l-=1
	r-=1
	ans=0
	
	i=l
	ans-=i
	for lv in reversed(range(L)):
		if xid[i*L+lv]<=r:
			ans-=xsum[i*L+lv]
			i=xid[i*L+lv]
	
	i=r
	ans+=i+1
	for lv in reversed(range(L)):
		if yid[i*L+lv]>=l:
			ans+=ysum[i*L+lv]+(1<<lv)
			i=yid[i*L+lv]
	
	print(ans)
	


Measured memory_bytes: 186580
#include <stdio.h>
#include <iostream>
using namespace std;
using ll = long long;

int main(void) {
	int N, A, B;
	scanf("%d%d%d", &N, &A, &B);
	char S[N];
	scanf("%s", S);
	int passed = 0;
	int passed_abroad = 0;
	for (int i = 0; i < N; i++) {
		char c = S[i];
		if (c == 'a' && passed < A + B) {
			passed++;
			printf("Yes\n");
		} else if (c == 'b' && passed < A + B && passed_abroad < B) {
			passed++;
			passed_abroad++;
			printf("Yes\n");
		} else {
			printf("No\n");
		}
	}
	return 0;
}


Measured memory_bytes: 768
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n;
  while(cin >> n,n){
    int i,j,k;
    string buf;
    int d[50]={};
    for(i=0;i<n;i++){
      cin >> buf;
      d[i]=buf.size();
    }
    for(i=0;i<n;i++){
      int c=0;
      j=i;
      while(c<5) c+=d[j++];
      if(c!=5) continue;
      c=0;
      while(c<7) c+=d[j++];
      if(c!=7) continue;
      c=0;
      while(c<5) c+=d[j++];
      if(c!=5) continue;
      c=0;while(c<7) c+=d[j++];
      if(c!=7) continue;
      c=0;
      while(c<7) c+=d[j++];
      if(c!=7) continue;
      c=0;
      cout << i+1 << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <stdio.h>

using namespace std;

typedef unsigned long long ull;

int main(int argc, char *argv[])
{
    int n, a;
    int min = 1000001, max = -1000001;
    ull sum = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a);
        if (a < min)
        {
            min = a;
        }
        if (a > max)
        {
            max = a;
        }
        sum += a;
    }
    printf("%d %d %lld\n", min, max, sum);
    return 0;
}



Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){

//	vector<int> a(n);

  string s;

  cin >> s;

  if(s[s.length()-1] == 's'){
    for(int i=0;i<s.length();i++){
      cout << s[i];
    }
    cout << "es" << endl;
  }else{
    for(int i=0;i<s.length();i++){
      cout << s[i];
    }
    cout << "s" << endl;
  }

}

Measured memory_bytes: 3584
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#include<random>
#pragma warning(disable:4996)
using namespace std;
using ld= long double;

long long int comb(int a, int b) {
	long long int sum=1;
	for (int i = 0; i < b; ++i) {
		sum*=a-i;
	}
	for (int i = 0; i < b; ++i) {
		sum/=i+1;
	}
	return sum;
}
int main()
{
	string st;cin>>st;
	map<char,int>mp;
	for (auto c : st) {
		mp[c]++;
	}
	long long int ans=1;
	 {
		int num = count_if(mp.begin(), mp.end(), [](const pair<char, int>&p) {
			return p.second%2;
		});
		if (st.size()%2&&num == 1) {

		}
		else if (st.size() % 2 == 0 && num == 0) {

		}
		else {
			cout<<0<<endl;
			return 0;
		}
	}

	long long int rest=st.size()/2;
	for (auto m : mp) {
		int num=m.second/2;
		ans*=comb(rest,num);
		rest-=num;

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

Measured memory_bytes: 3200
a,b,k = map(int,input().split())

if a-k >=0:
  taka = a-k
  aoki = b
else:
  taka = 0
  if b - (k-a) >=0:
  	aoki = b - (k-a)
  else:
    aoki = 0
print(str(taka) + " " + str(aoki))

Measured memory_bytes: 38444
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var S, T string
	fmt.Scan(&S)
	fmt.Scan(&T)

	var A, B int
	fmt.Scan(&A)
	fmt.Scan(&B)

	var U string
	fmt.Scan(&U)

	if S == U {
		A--
	} else {
		B--
	}

	fmt.Println(strconv.Itoa(A) + " " + strconv.Itoa(B))
}


Measured memory_bytes: 512
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mpa make_pair
#define all(a) (a).begin(), (a).end()

int main(){
    int m,d,M,D;
    cin >> m >> d >> M >> D;
    if(m != M){
        cout << 1 << endl;
    }
    else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;

void Main()
{
	int N, M;
  	cin >> N >> M;
  	priority_queue<int> A;
  	rep(i,N) {
    	int a;
    	cin >> a;
        A.push(a);
  	}
    rep(i,M){
		int a = A.top(); A.pop();
        A.push(a/2);
    }
  	ll ans = 0;
  	rep(i,N) {
        ans += A.top(); A.pop();
  	}
    cout << ans << endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}



Measured memory_bytes: 892
#include <cstdio>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>

std::string ToString(int x) {
	std::stringstream buffer;
	std::string result;
	buffer << x;
	buffer >> result;
	return result;
}

const int N = 100000 + 10;

std::string to_string[N];
int elements[N], a, b, MOD;

bool compare(int x, int y) {
	return to_string[x] < to_string[y];
}

int rank[N], order[N], value[N];

int lowbit(int x) {
	return x & -x;
}

void add(int x, int delta) {
	for (; x < N; x += lowbit(x)) {
		(value[x] += delta) %= MOD;
	}
}

int get(int x) {
	int result = 0;
	for (; x > 0; x -= lowbit(x)) {
		(result += value[x]) %= MOD;
	}
	return result;
}

int main() {
	while (scanf("%d%d%d", &a, &b, &MOD) != EOF) {
		if (a == 0 && b == 0 && MOD == 0) {
			break;
		}
		// printf("%d %d %d\n", a, b, MOD);
		int n = b - a + 1;
		for (int i = a; i <= b; ++ i) {
			elements[i - a + 1] = i;
			to_string[i - a + 1] = ToString(i);
			order[i - a + 1] = i - a + 1;
		}
		std::sort(order + 1, order + n + 1, compare);
		for (int i = 1; i <= n; ++ i) {
			rank[order[i]] = i;
		}
		
		memset(value, 0, sizeof(value));
		int answer = 0;
		for (int i = 1; i <= n; ++ i) {
			int temp = get(rank[i]) + 1;
			(answer += temp) %= MOD;
			add(rank[i], temp);
		}
		printf("%d\n", answer);
	}
	return 0;
}

Measured memory_bytes: 8304
#include <stdio.h>

#define INF 1000000000
void dijkstra(int,int*,int);

int g[101][101];

int main(){
  int i,j,n,key1,key2,roop,d[101];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d %d",&key1,&roop);

    for(j=0;j<roop;j++){
      scanf("%d",&key2);
      scanf("%d",&g[key1][key2]);
    }

  }

  dijkstra(0,d,n);

  for(i=0;i<n;i++){
    printf("%d %d\n",i,d[i]);
  }
  
  return 0;
}


void dijkstra(int start,int *d,int n){
  int i,j,u,mincost,color[101];

  for(i=0;i<n;i++){
    color[i]=1;
    d[i]=INF;
  }
  d[start]=0;

  while(1){
    mincost=INF;

    for(i=0;i<n;i++){
      if(color[i] && d[i]<mincost){
	mincost=d[i];
	u=i;
      }
    }

    if(mincost==INF) break;
    
    color[u]=0;

    for(i=0;i<n;i++){
      if(g[u][i]!=0 && color[i] && g[u][i]+d[u]<d[i]){
	d[i]=g[u][i]+d[u];
      }
    }

  }
}



Measured memory_bytes: 2052
n, m = map(int, input().split())

pena = [0]*(10**5 + 1)

wa = 0
ac = 0

for i in range(m):
    p, s = map(str, input().split())
    if s == "WA" and pena[int(p)] != -1:
        pena[int(p)] += 1
    elif s == "WA" and pena[int(p)] == -1:
        continue
    elif s == "AC" and pena[int(p)] == -1:
        continue
    else:
        ac += 1
        wa += pena[int(p)]
        pena[int(p)] = -1

print("{} {}".format(ac, wa))


Measured memory_bytes: 75728
#include<bits/stdc++.h>
using namespace std;
int n,a[2][105],dp[2][105];
int main()
{
	scanf("%d",&n);
	for(int i=0;i<2;i++)
	{
		for(int j=1;j<=n;j++)
		{
			scanf("%d",&a[i][j]);
		}
	}
	dp[0][1]=a[0][1];
	dp[1][1]=a[0][1]+a[1][1];
	for(int i=2;i<=n;i++)
	{
		dp[0][i]=dp[0][i-1]+a[0][i];
	}
	for(int i=2;i<=n;i++)
	{
		dp[1][i]=max(dp[0][i],dp[1][i-1])+a[1][i];
	}
	printf("%d\n",dp[1][n]);
}

Measured memory_bytes: 3820
#include<bits/stdc++.h>
#define int long long
using namespace std;
map<int,vector<pair<int, int> > > nset;
signed main()
{
	int n, x, d;
	cin>>n>>x>>d;
	if(!d) 
	{
		if(!x) cout<<1;
		else cout<<n+1;
		return 0;
	}
	for(int i=0; i<=n; i++)
	{
		if(!i) nset[i*x%d].emplace_back(0, 0);
		else nset[i*x%d].emplace_back(i*x/d+i*(i-1)/2, i*x/d+i*(2*n-i-1)/2);
	}
	long long ans=0;
	for(auto ivt: nset)
	{
		auto vt=ivt.second;
		sort(begin(vt), end(vt));
		int fi=LLONG_MAX/1000LL, se=LLONG_MIN/1000LL;
		for(auto temp: vt)
		{
			if(temp.first>se) 
			{
				ans=ans+max(se-fi+1, 0LL);
				fi=LLONG_MAX/1000LL; se=LLONG_MIN/1000LL;
			}
			fi=min(fi, temp.first); se=max(se, temp.second);
		}
		ans+=max(se-fi+1, 0LL);
	}
	cout<<ans;
}

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

using namespace std;

int main() {
    int N;
    cin >> N;
    if (N % 10 == 2 || N % 10 == 4 || N % 10 == 5 || N % 10 == 7 ||
        N % 10 == 9) {
        cout << "hon" << endl;
    } else if (N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8) {
        cout << "pon" << endl;
    } else {
        cout << "bon" << endl;
    }
    return 0;
}


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

#define ALL(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0, __##i##_length = (n); i < __##i##_length; i++)
#define rep_reverse(i, n) for (ll i = (n)-1; 0 <= i; i--)
#define FOR(i, from, to) for (ll i = (from), __##i##_end = (to); i < __##i##_end; i++)
#define FOR_REVERSE(i, from, to) for (ll i = (to)-1, __##i##_end = (from); __##i##_end <= i; i--)
#define foreach(e, v) for (const auto e : (v))
#define vfree(v) std::vector<int>().swap(v)
#define DEBUG(x) cout << #x << " = " << (x) << endl

using namespace std;
typedef int64_t ll;
typedef vector<ll> llv;
typedef vector<llv> llvv;

ll gcd(ll a, ll b)
{
    return (a < b) ? gcd(b, a) : ((a % b) ? gcd(b, a % b) : b);
}

ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}

int main()
{
    ll N;
    cin >> N;
    rep(a, 3500)
        rep(b, 3500)
    {
        ll A = a + 1;
        ll B = b + 1;
        ll x = N * A * B;
        ll y = 4 * A * B - N * A - N * B;
        if (0 < x && 0 < y && x % y == 0)
        {
            cout << A << " " << B << " " << x / y << endl;
            return 0;
        }
    }
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  unordered_set<int> nums;
  for (int i = 0; i < N; i++) {
    ll A;
    cin >> A;
    if (!nums.count(A)) {
      nums.insert(A);
    }
    else {
      nums.erase(A);
    }
  }
  cout << nums.size() << endl;
}


Measured memory_bytes: 4388
x, k, d = map(int, input().split())

x = abs(x)
a = x % d
b = x % d - d
ans = abs(x - k * d)
if (x - a) // d <= k and ((x - a) // d - k) % 2 == 0:
    ans = min(ans, a)
if (x - b) // d <= k and ((x - b) // d - k) % 2 == 0:
    ans = min(ans, -b)
print(ans)

Measured memory_bytes: 61812
a,b,c=map(int,input().split())
K=int(input())

isCheck = None
for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            x = a*2**(i)
            y = b*2**(j)
            z = c*2**(k)
            if i+j+k <= K and x < y and y < z:
                isCheck = True

if isCheck:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9096
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
#include<utility>
#include<queue>
#include <map>

using namespace std;

int main(){

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

	int flag=0;
	for(int i=0;i<n;i++){
		if(a[i]%2==1)continue;
		if(a[i]%3==0)continue;
		if(a[i]%5==0)continue;
		flag=1;
		break;
	}

	if(flag==0)cout<<"APPROVED";
	else cout<<"DENIED";

	cout<<endl;

	return 0;
}


Measured memory_bytes: 256
import bisect
n,k=map(int,input().split())
l=list(map(int,input().split()))
nl=list(range(10))
for i in l:nl.remove(i)
ch=int(str(nl[-1])*len(str(n)))<n
if ch and nl[0]==0:
    print(int(str(nl[1])+"0"*(len(str(n)))))
elif ch:
    print(int(str(nl[0])*(len(str(n))+1)))
else:
    ans=""
    for i in range(len(str(n))):
        if int(str(n)[i]) in l:
            ans+=str(nl[bisect.bisect_left(nl,int(str(n)[i]))])
            ans+=str(nl[0])*(len(str(n))-i-1)
            break
        else:ans+=str(n)[i]
    print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#include <utility>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;


int main() {
    int N;
    vector <vector <int>> A(3, vector <int>(3));
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++){
        cin >> A[i][j];
      }
    }
    cin >> N;
    vector <int> b(N);
    for (int i = 0; i < N; i++) {
        cin >> b[i];
    }
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < 3; j++) {
        for (int k = 0; k < 3; k++) {
          if (A[j][k] == b[i]) {
            A[j][k] = -1;
          }
        }
      }
    }

    for (int i = 0; i < 3; i++) {
      if (A[i][0] + A[i][1] + A[i][2] == -3) {
        cout << "Yes" << endl;
        return 0;
      }
      if (A[0][i] + A[1][i] + A[2][i] == -3) {
        cout << "Yes" << endl;
        return 0;
      }
    }
    if (A[0][0] + A[1][1] + A[2][2] == -3) {
      cout << "Yes" << endl;
      return 0;
    }
    if (A[2][0] + A[1][1] + A[0][2] == -3) {
      cout << "Yes" << endl;
      return 0;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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


        while(true){
            String moji = sc.next();
            if(moji.equals("-"))    break;
            int m = sc.nextInt();

            for(int i=0;i<m;i++){
                int h = sc.nextInt();
                moji = moji.substring(h,moji.length()) + moji.substring(0,h);

            }
            System.out.println(moji);
        }
        sc.close();
    }
}


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

int main(){
  int N;
  cin >> N;
  long tmpmin;
  long tmpmax;
    
  for(int i = 0; i < N; i++){
    if(i ==0){
      cin >> tmpmin;
	  tmpmax = tmpmin;
      continue;
    }
    int tmp;
    cin >> tmp;
    if(tmp <= tmpmin){
      tmpmin = tmp;
    }
    if(tmp >= tmpmax){
      tmpmax = tmp;
    }
  }
  
  cout << abs(tmpmax - tmpmin) << endl;
}

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

int main(){
    string o, e;
    cin >> o >> e;
    string pass="";
    for(int i=0; i<o.length(); i++){
        pass.push_back(o.at(i));
        if(o.length() == e.length()){
            pass.push_back(e.at(i));
        }else{
            if(i != o.length()-1){
                pass.push_back(e.at(i));
            }
        }
    }
    cout << pass << endl;
    return 0;
}

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

public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] arr = primeArray();
    int[] fin = new int[N];
    for(int i = 0; i < N; i++) {
      fin[i] = arr[i];
    }
    String out = "";
    for(int curr : fin)
      out += curr + " ";
    System.out.println(out.substring(0, out.length()-1));
  }
  
  /*public static boolean checkIf5(int[] n) {
    int sum = 0;
    for(int curr : n) {
      sum += curr;
    }
    return sum % 5 == 0;
  }*/
  
  public static int[] primeArray() {
    int[] primes = new int[10000];
    primes[0] = 2;
    int ind = 1;
    for(int i = 3; i <= 55555; i += 2) {
      if(isPrime(i) && i % 10 == 7) {
        primes[ind] = i;
        ind++;
      }
    }
    return primes;
  }
  
  public static boolean isPrime(int n) {
    for(int i = 2; i < n; i++) {
      if(n % i == 0)
        return false;
    }
    return true;
  }
  
  public static int returnSum(int[] n) {
    int sum = 0;
    for(int i = 0; i < n.length; i++)
      sum += n[i];
    return sum;
  }
}


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

int main(){
    string str;
    int q;
    cin  >> str >> q;

    string order;
    int a, b;
    string p;
    for (int i = 0; i < q; i++)
    {
        cin >> order;
        if(order == "print"){
            cin >> a >> b;
            cout << str.substr(a, b-a+1) << endl;
        }
        else if(order == "reverse"){
            cin >> a >> b;
            reverse(str.begin()+a, str.begin()+b+1);
        }
        else if(order == "replace"){
            cin >> a >> b >> p;
            str.replace(a, b-a+1, p);
        }
    }
    
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
using namespace std;
ll MAXN=1000005; 
   
ll spf[1000005];  
void sieve() 
{ 
    spf[1] = 1; 
    for (ll i=2; i<MAXN; i++) 
   
        spf[i] = i; 
   
    for (ll i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (ll i=3; i*i<MAXN; i++) 
    { 
         
        if (spf[i] == i) 
        { 
        
            for (ll j=i*i; j<MAXN; j+=i) 
   
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
set<ll> getFactorization(ll x) 
{ 
    set<ll> ret; 
    while (x != 1) 
    { 
        ret.insert(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
} 
int main() {
    fast();
    // ll t;
    // cin>>t;
    // while(t--)			
    // {
         
    // }
    sieve();
    ll n;
    cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++)
    cin>>a[i];
    ll g=0;
    for(int i=0;i<n;i++)
    g=__gcd(g,a[i]);
   // cout<<g<<endl;
    if(g!=1)
    {
        cout<<"not coprime"<<endl;
    }
    else
    {
       int flag=1;
       vector<ll>vis(1000005,0);
       for(ll i=0;i<n;i++)
       {
           set<ll>s=getFactorization(a[i]);
           for(auto j:s)
           {
               if(vis[j])
               {
                   flag=0;
                  // cout<<i<<endl;
                   break;
               }
               //cout<<i<<" ";
               vis[j]=1;
           }
          // cout<<endl;
           if(!flag)
           break;
       }
       if(flag)
       cout<<"pairwise coprime";
       else
       cout<<"setwise coprime";
    }
}

Measured memory_bytes: 26652
#include <iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  long long  ave = 0;
  long long  a;
  for(int i = 0 ; i < n ; i++ ){
    cin >> a;
    ave += a;
   }
  cout << (int)(ave/n) << endl;
  return 0;
}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int v[n],mn = INT_MAX, mx = INT_MIN;
	for(int i=0;i<n;++i)
		cin>>v[i], mx = max(mx,v[i]), mn = min(mn,v[i]);
	int ans = INT_MAX;
	while(mn<=mx)
	{
		int sum = 0;
		for(int i=0;i<n;++i)
			sum += (v[i]-mn)*(v[i]-mn);
		ans = min(ans,sum);
		mn++;
	}
	cout<<ans;
	return 0;
}

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

using namespace std;

typedef long long ll;

long long test_cases;
int main()
{
    
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    /* cin >> test_cases; */
    test_cases = 1;

    ll n, a[200123];
    ll acum_xor = 0;
    vector <ll> ans;
    while (test_cases > 0)
    {
        cin >> n;
        for (int i = 0; i < n; i++)
        {
            cin >> a[i];
            acum_xor ^= a[i];
        }

        for (int i = 0; i < n; i++)
        {
            ans.push_back(acum_xor^a[i]);
        }

        for (auto i: ans)
            cout << i << " ";
        cout << endl;

        test_cases--;
    }

    
    return 0;
}

Measured memory_bytes: 6876
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <stack> 
#include <map>
#include <queue>
#include <unordered_map>
#include <cassert>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;

typedef vector<vector<long long> > MAT;
long long MOD = 1e9 + 7;



void print(MAT m){
	for(auto v: m) {
		for(auto vv: v) 
			cout<<vv<<" ";
		cout<<"\n";
	}
	cout<<"\n";
}

MAT matMul(MAT &a, MAT &b) {
	int ar = a.size();
	int ac = a[0].size();
	int br = b.size();
	int bc = b[0].size();
	assert(ac==br);
	MAT c;
	for(int i =0;i<ar;i++ ){
		vector<long long> tc;
		for(int j = 0;j<bc;j++) {
			long long x= 0;
			for(int k =0; k<ac;k++ ){
				x+=a[i][k]*b[k][j];
				x%=MOD;
			}
			tc.push_back(x);
		}
		c.push_back(tc);
	}
	return c;
}

MAT powMod(MAT & a, long long b) {
	auto ca = a;
	if(b==1)
		return ca;
	auto c = powMod(a, b/2);
	// cout<<"c: \n";
	// print(c);
	auto cc = matMul(c, c);
	// cout<<"cc: \n";
	// print(cc);
	if(b%2==1)
		cc = matMul(cc, a);
	return cc;
}

MAT mat;
int main() {
    ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);	
	int n;
	long long k;
	cin >> n >> k;
	for(int i =1 ;i<=n;i++ ){
		vector<long long> v;
		for(int j = 1;j<=n;j++){
			int x;
			cin >> x;
			v.push_back(x);
		}
		mat.push_back(v);
	}
	assert(mat.size()== mat[0].size());
	MAT ans = powMod(mat, k);
	// print(ans);

	long long vans = 0;
	for (auto v : ans) {
		for(auto vv: v) {
			vans +=vv;
			if(vans >MOD)
				vans-=MOD;
		}
		// cout<<"\n";
	}


	cout<<vans<<"\n";

	return 0;
}



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

int main() {
  int h, w, n, ans;
  cin >> h >> w >> n;
  if (h > w) {
    int i = 0;
    while (true) {
      i++;
      if (h * i >= n) {
        ans = i;
        break;
      }
    }
  } else {
    int i = 0;
    while (true) {
      i++;
      if (w * i >= n) {
        ans = i;
        break;
      }
    }
  }
  cout << ans << endl;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  int x, y;
  cin >> x >> y;

  if ((x==1 || x==3 || x==5 || x==7 || x==8 || x==10 || x==12) &&
      (y==1 || y==3 || y==5 || y==7 || y==8 || y==10 || y==12)) cout << "Yes" << "\n";

  else if ((x==4 || x==6 || x==9 || x==11) && (y==4 || y==6 || y==9 || y==11)) cout << "Yes" << "\n";

  else if (x==2 && y==2) cout << "Yes" << "\n";

  else cout << "No" << "\n";

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll      long long int   
#define ld      long double
#define pii     pair<int ,int>
#define pld     pair<ld ,ld>
#define all(v)  v.begin(),v.end()
#define F       first
#define S       second
#define mod     1000000007
#define pb      push_back
#define MP      make_pair
#define mset(x) memset(x, 0, sizeof(x));
#define ios     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define inf     1000000000000000007
const int N=300006;
ll n,i,ans,a[N],b[N],c[N],res;
void run(){
	cin>>n;
    for(i=1;i<=n-1;i++)
        cin>>a[i];
    a[n]=1000000000;
    for(i=1;i<=n;i++)
    {
        res=a[i];
        if(i-1>=1) res=min(res,a[i-1]);
        ans+=res;
    }
    cout<<ans;
 
}
 
 
void setup(){
    ios;
    //cout << setprecision(20);
    // #ifndef ONLINE_JUDGE
    // freopen("input", "r", stdin);
    // freopen("output", "w", stdout);
    // #endif
}
 
signed main(){
    setup();
    int tests = 1;
    //cin >> tests;
    for(int i = 1; i <= tests; i++) run();
    return 0;
}

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

int main() {
  ll n;
  cin >> n;
  ll ans;
  ans = n*(n-1)/2;
  cout << ans <<endl;
}


Measured memory_bytes: 256
// https://qiita.com/e869120/items/eb50fdaece12be418faa

#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
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; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

static const int MAX = 300;

int n;
ll d[MAX][MAX];
bool f[MAX][MAX];

int main()
{
    cin >> n;
    rep(i, n) {
        rep(j, n) {
            cin >> d[i][j];
        }
    }

    rep(i, n) {
        rep(j, n) {
            f[i][j] = true;
        }
    }

    // floyd
    for(int k = 0; k < n; ++k) {
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                if (d[i][k] + d[k][j] < d[i][j]) {
                    cout << -1 << endl;
                    return 0;
                } else if (d[i][k] + d[k][j] == d[i][j] && i != k && k != j) {
                    f[i][j] = false;
                }
            }
        }
    }

    ll res = 0;
    rep(i, n) {
        rep(j, n) {
            if (f[i][j]) res += d[i][j];
        }
    }

    cout << res / 2 << endl;

    return 0;
}

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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int x,y;
    x = 0;
    y = 0;
    for(int i = 0; i < n - 1; i++){
        if(a[i] >= a[i+1]){
            x++;
        }
        else{
            y = max(y,x);
            x = 0;
        }
    }
    y = max(y,x);
    cout << y;
}

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

#define next '\n'
#define sp " "
#define print(x) cout << (x)
#define println(x) cout << (x) << next
#define stop return(0)
#define rep(i, n) for(int (i) = (0); (i) < (n); (++i))
#define FOR(i, start, end) for(int (i) = (start); (i) < (end); (++i))
#define foreach(e, elem) for(auto& (e) : (elem))
#define FAST ios::sync_with_stdio(false); cin.tie(nullptr)
#define size(s) (s).size()
#define all(vec) (vec).begin(), (vec).end()
#define pb(e) push_back(e);
using ll = long long;
using ull = unsigned long long;

vector<int> v;

int main() {
    int n;
    cin >> n;
    n *= 2;
    rep(i, n){
        int l;
        cin >> l;
        v.pb(l);
    }

    sort(all(v));

    int sum = 0;
    for(int i = 0; i < size(v); i += 2){
        sum += min(v[i], v[i + 1]);
    }

    println(sum);
}

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

int main(){
  string n;
  cin >> n;
  int count = 0;
  for(int i=0;i<n.size();i++){
    count += (int)n.at(i)-48;
  }
  if(count%9 == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
int dp[301][300][300];
int INF = 1e6;
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//freopen("1.txt", "r", stdin);
    string s;
    cin >> s;
    int k;
    cin >> k;
    int n = s.size();
	for (int i=0; i < n; i++){
		for (int j=0; j < n; j++){
			for (int p=0; p <= n; p++) dp[p][j][i] = INF;
			dp[1][j][i] = 0;
		}
	}
	for (int it=2; it <= n; it++){
		for (int i=0; i < n; i++){
			for (int j=i+1; j < n; j++){
				int cost=0;
				if (s[i] != s[j]) cost=1;
				int I = i+1;
				int J = j - 1;
				if (I > J){
					if (it==2) dp[it][i][j] = cost;
				}
				else dp[it][i][j] = dp[it-2][I][J] + cost;
			}
		}
		for (int i=0; i < n; i++){
			for (int j=i+1; j < n; j++) dp[it][i][j] = min(dp[it][i][j], dp[it][i][j-1]);
		}
		for (int i=0; i < n; i++){
			for (int j=i-1; j >= 0; j--){
				dp[it][j][i] = min(dp[it][j][i], dp[it][j+1][i]);
			}
		}
	}
	int ans = 0;
	for (int i=1; i <= n; i++){
		for (int j=0; j < n; j++){
			for (int p=0; p < n; p++){
				if (dp[i][j][p] <= k){
					ans = i;
				}
			}
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 106112
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<int,int>
#define poly vector<int>
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define mem(a) memset((a),0,sizeof(a))
#define fi first
#define se second
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
int n,nl[2000010];
int check(int k){
    for(int i=0;i<n-1;i++){//哪对1和0离中间最近，最上面就是什么数 
        if((nl[n+i]>k && nl[n+i+1]>k)
		|| (nl[n-i]>k && nl[n-i-1]>k)){//求是否都大于
        	return 1;
		}
        if((nl[n+i]<=k && nl[n+i+1]<=k)
		|| (nl[n-i]<=k && nl[n-i-1]<=k)){//求是否都小于等于
        	return 0;
		}
    }
    return nl[1]<=k?0:1;
}
int main(){
//	freopen("pyramid.in","r",stdin);
//	freopen("pyramid.out","w",stdout);
    cin>>n;
    int js0=0,js1=0;
    for(int i=1;i<=2*n-1;i++){
    	nl[i]=read();
    	if(nl[i]==0) js0++;
    	if(nl[i]==1) js1++;
	}
    if(js0+js1!=n*2-1){
    	int l=1,r=2*n-1,ans,mid;
	    while(l<r){
	        mid=(l+r)>>1;
	        if(check(mid)==0) r=mid;
	        else l=mid+1;
	    }
	    cout<<l<<endl;
	}
	else{
		for(int i=0;i<n-1;i++){//哪对1和0离中间最近，最上面就是什么数 
	        if((nl[n+i]==1 && nl[n+i+1]==1)
			|| (nl[n-i]==1 && nl[n-i-1]==1)){
				
				cout<<"1"<<endl;
	        	return 0;
			}
	        if((nl[n+i]==0 && nl[n+i+1]==0)
			|| (nl[n-i]==0 && nl[n-i-1]==0)){
				cout<<"0"<<endl;
	        	return 0;
			}
    	}
    	printf("%d\n",nl[1]==0?0:1);
	}
    return 0; 
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(void){

   int H,W;

   while(1){
   
    cin >> H >> W;

    if(H == 0) break;

     for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
           cout << "#";
        }
          cout << endl;
     }
      cout << endl;
   }
  return 0;
}

Measured memory_bytes: 3100
#include "bits/stdc++.h"
using namespace std;

#define int int64_t

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)
#define maxup(ans, x) (ans = (ans < x ? x : ans))
#define minup(ans, x) (ans = (ans > x ? x : ans))

#define breakif(cond) if(cond) break; else

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

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

	string s, t;
	cin >> s;// >> t;

	auto ans = s.substr(0, 4) + " " + s.substr(4, s.size() - 4);
	
	cout << ans << endl;

	system("pause");
}

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

int p[50];
int main(void){
    // Your code here!
    int N;
    cin >> N;
    vector<int> p(N);
    for(int i = 0; i < N; i++) cin >> p[i];
    
    bool flag = true;
    for(int i = 1; i < N; i++){
        if(p[i] <= p[i-1]) {
            flag = false;
            break;
        }
    }
    
    if(flag){
        cout << "YES" << endl;
        return 0;
    }
    
    for(int i = 0; i < N-1; i++){
        for(int j = i+1; j < N; j++){
            vector<int> swap(N);
            copy(p.begin(), p.end(), swap.begin());
            
            int tmp = p[i];
            swap[i] = swap[j];
            swap[j] = tmp;
            bool flag = true;
            for(int k = 1; k < N; k++){
                if(swap[k] <= swap[k-1]){
                    flag = false;
                    break;
                }
            }
            
            if(flag){
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    
    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

#include <bits/stdc++.h>
#include <algorithm>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <numeric>
#include <typeinfo>
#include <vector>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T>
using Tree =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;  // check the limits, dummy

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

ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

void Main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  ll A, B, C, D;
  cin >> A;
  cin >> B;
  cin >> C;
  cin >> D;

  ll a, b, c, d, e, f, g, ans;
  a = B / C;
  b = B / D;
  c = (A - 1) / C;
  d = (A - 1) / D;
  e = lcm(C, D);
  f = B / e;
  g = (A - 1) / e;
  ans = B - (A - 1) - (a - c) - (b - d) + (f - g);
  cout << ans << '\n';
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
}


Measured memory_bytes: 256