akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define llong long long
#define pb(a) push_back(a)
#define INF 9999999

using namespace std;

typedef pair<int,int> P;

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

int main(){
	int a[2];
	int ans=0;
	cin>>a[0]>>a[1]>>a[2];
	SORT(a,3);
	int r1=a[0]%2,r2=a[1]%2,r3=a[2]%2;
	if(r1==r3&&r1==r2)ans=(a[2]-a[0])/2+(a[2]-a[1])/2;
	else if(r1!=r3&&r1==r2)ans=(a[2]-a[0])/2+(a[2]-a[1])/2+1;
	else if(r1==r3&&r1!=r2)ans=(a[2]-a[0])/2+(a[2]-a[1])/2+2;
	else if(r1!=r3&&r1!=r2)ans=(a[2]-a[0])/2+(a[2]-a[1])/2+2;
	cout<<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  vector<pair<double,double> > v(N);
  rep(i,N)cin >> v[i].first >> v[i].second;
  vector<int> w(N);
  rep(i,N) w[i] = i;
  double len = 0.0;
  do{
    rep(i,N-1){
      len += sqrt(
          (v[w[i+1]].first - v[w[i]].first)* (v[w[i+1]].first - v[w[i]].first) 
          + (v[w[i+1]].second - v[w[i]].second)* (v[w[i+1]].second - v[w[i]].second) );
    }
  }while(next_permutation(all(w)));
  repp(i,1,N+1) len /= (double) i;
  cout << len << endl;
  return 0;
}


Measured memory_bytes: 256
import sys

n, k = map(int, input().split())
if n <= k:
    print(len(str(n)))
    sys.exit()

def clas(n, k):
    li = []
    while True:
        c = n // k
        li.append(c % k)
        if c < k:
            li.append(c)
            break
        n = c
    return li

print(len(clas(n, k)))


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


 
int main()
{
    int a,b,c,k,i,j;
    cin>>a>>b>>c>>k;
    if(c>b && b>a) cout<<"Yes";
    else
    {
        for(i=0;i<k;++i)
        {
            if(b<=a) b=2*b;
            else break;
        }
        for(j=i;j<k;++j)
        {
           if(c<=b) c=2*c;
           else break;
        }

        if(c>b && b>a) cout<<"Yes";
    else cout<<"No";
    
        
    }
    
    
    
    return 0;
}

Measured memory_bytes: 3536
#include <stdio.h>

int main(){
	int n,r;
	scanf("%d",&n);
	r = n % 10;
	if(r == 3){
		printf("bon");
	}else if(r == 0||r == 1||r == 6||r == 8){
		printf("pon");
	}else{
		printf("hon");
	}
	return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)

#define CHMIN(a, b) (a) = min((a), (b))
#define CHMAX(a, b) (a) = max((a), (b))

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()



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

    vector<long double> bw(21);
    bw[0]=1;
    for(int i=1;i<21;i++){
        bw[i] = bw[i-1] * 2;
    }

    double ans =0;

    FOR(i,1,N+1){ //サイコロのどの面が出たのか
        FOR(j,0,21){
            if(K<=i*bw[j]){
                ans += 1.0/ (bw[j]);
                break;
            }
        }
    }

    cout << fixed << setprecision(10) << (ans)/N << endl;

}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
int x,y,s;
while(cin >> x >> y >> s && x){
int ans=0;
for(int i=1;i<s;i++){
for(int j=1;j<s;j++){
if(i*(100+x)/100+j*(100+x)/100==s){
if(i*(100+y)/100+j*(100+y)/100>ans){
ans=i*(100+y)/100+j*(100+y)/100;
}
}
}
}
cout << ans << endl;
}
}

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

using namespace std;

long long int H, W;

long long int Smax_Smin(long long int h, long long int w) {
    long long int Smax=(w/3+1)*h, Smin=0;
    long long int tmpmax, tmpmin;
    for(int i=0; i<2; i++) {
        vector<long long int> S(3);
        S[0] = (w/3+i)*h;
        if(h%2==0) {
            S[1] = (H*W - S[0])/2;
        } else {
            if(w-w/3>h) {
                S[1] = ((w-w/3-i)/2+1)*h;
            } else {
                S[1] = (h/2+1)*(w-w/3-i);
            }
        }
        S[2] = H*W - S[0] - S[1];
        
        sort(S.begin(), S.end());
        tmpmin = S[0];
        tmpmax = S[2];
        // cout << tmpmin << ", " << tmpmax << endl;
        if(Smax-Smin>tmpmax-tmpmin) {
            Smax = tmpmax;
            Smin = tmpmin;
        }
    }
    return Smax-Smin;
}

long long int f_ans(long long int x, long long int y) {
    if(x%3==0 || y%3==0) {
        return 0;
    }

    long long int h=min(x, y), w=max(x, y);
    
    return min(Smax_Smin(h, w), Smax_Smin(w, h));
}

int main() {
    cin >> H >> W;
    cout << f_ans(H, W) << endl;

    return 0;
    
}

Measured memory_bytes: 256
#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 <bitset>
#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 EACH( v, c ) for ( auto &v : c )

#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) 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 );

	int n, m;
	cin >> n >> m;

	VVI tri( n + 1, VI() );

	REP( i, 0, tri.size() )
	{
		tri[i].resize( i + 1, 0 );
	}

	REP( i, 0, m )
	{
		int a, b, x;
		cin >> a >> b >> x;

		tri[ a - 1 ][ b - 1 ] = x + 1;
	}

	int res = 0;

	REP( i, 0, tri.size() - 1 )
	{
		REP( j, 0, tri[i].size() )
		{
			res += 0 < tri[i][j];

			tri[ i + 1 ][j] = max( tri[ i + 1 ][j], tri[i][j] - 1 );
			tri[ i + 1 ][ j + 1 ] = max( tri[ i + 1 ][ j + 1 ], tri[i][j] - 1 ); 
		}
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 50112
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

const int MAX_N = 1e5 + 5;
const int MAX_L = 20; // ~ Log N
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

#define rep(i,n) for (int i = 0; i < n; ++i)
#define REP(i,k,n) for (i = k; i <= n; ++i)
#define REPR(i,k,n) for (int i = k; i >= n; --i)

#define LSOne(S) (S & (-S))
#define isBitSet(S, i) ((S >> i) & 1)

int p[200000];
int cnt[200000];

int found(int x) {
    if (x == p[x]) {
        return  x;
    }
    p[x] = found(p[x]);
    return p[x];
}

void solve() {
    memset(cnt, 0, sizeof(cnt));
    int N, M;
    cin >> N >> M;
    rep(i, N) {
        p[i] = i;
    }

    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        int r1 = found(a);
        int r2 = found(b);
        p[r1] = r2;
    }


    rep(i, N) {
        cnt[found(i)]++;
    }

    int ans = 0;
    rep(i, N) {
        ans = max(cnt[i], ans);
    }

    cout << ans;
}

//#define LOCAL 1

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

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    solve();

    return 0;
}


Measured memory_bytes: 11300
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <cstring>
#include <list>  
#include <cassert>
#include <climits>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
std::mt19937 rnd((int)std::chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }

const int MAXN = 500;
const int DX[] = { -1,0,+1,0 }, DY[] = { 0,+1,0,-1 };

int n;
int p[MAXN * MAXN];

int d[MAXN][MAXN];
bool isempty[MAXN][MAXN];
deque<pair<int, int>> q;

void upd(int sx, int sy, int sd) {
	q = deque<pair<int, int>>();
	d[sx][sy] = sd, q.PB(MP(sx, sy));
	while (!q.empty()) {
		int x, y; tie(x, y) = q.front(); q.pop_front();
		REP(k, 4) {
			int nx = x + DX[k], ny = y + DY[k], nd = d[x][y] + (isempty[x][y] ? 0 : 1);
			if (nx < 0 || nx >= n || ny < 0 || ny >= n || nd >= d[nx][ny]) continue;
			d[nx][ny] = nd; if (nd == d[x][y]) q.push_front(MP(nx, ny)); else q.PB(MP(nx, ny));
		}
	}
}

ll solve() {
	REP(x, n) REP(y, n) d[x][y] = min(min(x, n - x - 1), min(y, n - y - 1));
	REP(x, n) REP(y, n) isempty[x][y] = false;
	ll ret = 0;
	REP(i, n * n) {
		int x = p[i] / n, y = p[i] % n;
		isempty[x][y] = true;
		ret += d[x][y];
		upd(x, y, d[x][y]);
	}
	return ret;
}

void run() {
	scanf("%d", &n);
	REP(i, n * n) scanf("%d", &p[i]), --p[i];
	printf("%lld\n", solve());
}

int main() {
	run();
	return 0;
}


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

int main() {
  int N;
  string S;
  cin >> N >> S;
  int x = 0, ans = 0;
  for (int i = 0; i < N; i++) {
    if (S[i] == 'I') x++;
    else x--;
    ans = max(ans, x);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func min(a, b int) int {
	if a <= b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}

func yesno(result bool) {
	if result {
		fmt.Fprintln(write, "Yes")
	} else {
		fmt.Fprintln(write, "No")
	}
}

func printansStr(result bool, a, b string) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func printansInt(result bool, a, b int) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func main() {
	defer write.Flush()

	var n int
	fmt.Fscan(read, &n)

	cnt := 0
	for i := 1; i <= n; i++ {
		var a int
		fmt.Fscan(read, &a)
		if a != i {
			cnt++
		}
	}
	printansStr(cnt <= 2, "YES", "NO")
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

// v の連続する部分列の和の mod k が 0 であるものの個数を返す
ll RangeSumModZeroCnt(vector<int>& v, int k) {
    // v の累積和を構築。ただし和は mod k しておく
    vector<ll> cs;
    cs.push_back(0);
    for(int i = 0; i < v.size(); ++i) {
        ll tmp = cs[i] + v[i];
        tmp %= k;
        cs.push_back(tmp);
    }

    // 連続する部分列の和の mod k == 0
    // → [i, j) の累積和 (cs[j] - cs[i]) mod k == 0
    // → cs[j] mod k == cs[i] mod k
    // → i < j で、 mod k した値が同じであるペア (i, j) のパターン数が答え

    map<ll, ll> cnt;  // key が cs 内にいままで何回出てきたか
    ll ret = 0;
    for(int i = 0; i < cs.size(); ++i) {
        // チェックする要素の数が k 以上にならないように調整
        if(i >= k) {
            cnt[cs[i-k]]--;
        }

        if(cnt.count(cs[i]) > 0) {
            ret += cnt[cs[i]];
        }
        cnt[cs[i]]++;
    }

    return ret;
}

ll N, K;
vector<ll> A;

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

    cin >> N >> K;
    A.resize(N);
    REP(i, N) {
        cin >> A[i];
        A[i]--;
    }

    ll ans = RangeSumModZeroCnt(A, K);

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

    return 0;
}


Measured memory_bytes: 15984
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<cstdlib>
#include<cassert>
#include<random>
using namespace std;
int main(){
    string S;
    cin >> S;
    cout << "2018/01/" << S[8] << S[9] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

void swap(int* a,int* b);
void PRINT(int* A, int N);

int main(void){
	int N, i, j, flag=1,n=0;
	
	scanf("%d",&N);
	int bubbleSort[N];
	for(i=0;i<N;i++){
		scanf("%d", &bubbleSort[i]);
	}
	
	i=0;
	while(flag){
		flag=0;
		for(j=N-1;j>i;j--){
			if(bubbleSort[j] < bubbleSort[j-1]){
				swap(&bubbleSort[j],&bubbleSort[j-1]);
				n++;
				flag=1;
			}
		}
		i++;
	}
	PRINT(bubbleSort, N);
	printf("%d\n",n);
	
	return 0;
}

void swap(int* a,int* b){
	int temp;
	temp=*a;
	*a=*b;
	*b=temp;
}

void PRINT(int* A, int N){
	int i;
	printf("%d",A[0]);
	for(i=1;i<N;i++){
		printf(" %d",A[i]);
	}
	printf("\n");
}

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

using namespace std;

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

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

int main() {
  int a,b;cin>>a>>b;
  int total = 0;
  REP(i,b-a) total += i;
  OUT(total-a);

  return 0;
}

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

int main(){
  string n, ans;
  cin >> n;
  n = n.at(n.size() - 1);
  if(n == "3")
    ans = "bon";
  else if(n == "0" || n == "1" || n == "6" || n == "8")
    ans = "pon";
  else 
    ans = "hon";

  cout << ans << endl;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
typedef long long LL;
using namespace std;
LL n;

int main() {
    cin >> n;
    for(LL a = 1; a <= 3500; a++)
        for(LL b = 1; b <= 3500; b++) {
            LL s = 4LL * a * b - n * (a + b);
            LL m = n * a * b;
            if (s <= 0) continue;
            if (m % s == 0) {
                cout << a << " " << b << " " << m / s << endl;
                return 0;
            }
        }
}


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

int main() {
  int N;
  string s[100];
  cin >> N;
  int i;
  int a = 0;
  for (i = 0; i < N; i++) {
    cin >> s[i];
    if(s[i] == "Y"){
      a++;
    }
  }
  if(a >= 1){
    cout << "Four" << endl;
  }else {
    cout << "Three" << endl;
  }
  
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
using namespace std;
#define INF 1LL << 61
#define MAX 1LL << 30
#define MOD 1000000007
typedef long long ll;
//typedef pair<ll,ll> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};


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

    ll N,K,S;
    cin>>N>>K>>S;
    if(S!=1000000000 || N==K){
        for(int i=0;i<K;i++) cout<<S<<endl;
        for(int i=0;i<N-K;i++) cout<<S+1<<endl;
        return 0;
    }
    for(int i=0;i<K;i++) cout<<S<<endl;
    for(int i=0;i<N-K;i++) cout<<1<<endl;

}


Measured memory_bytes: 1280
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> vec(n);
    for(int i=0;i<n;i++){
        cin >> vec[i];
    }
    int ret = 0;
    int count = 0;
    for(int i=1;i<n;i++){
        if(vec[i] <= vec[i-1]){
            count++;
            ret = max(count,ret);
        }
        else{
            count = 0;
        }
    }
    cout << ret << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;


int main() {

	int a, b, c, d, x, y;
	cin >> a >> b >> c >> d;

	if (a < b) {
		x = a;
	}
	else {
		x = b;
	}

	if (c < d) {
		y = c;
	}
	else {
		y = d;
	}

	cout << x + y << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
 
  int S,s,h,m;
  cin >> S ;
  h=S/3600;
  m=S%3600/60;
  s=S%3600%60;
 
  cout << h << ":" << m << ":" << s << endl;
     
  return 0;
  }

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

int main(){
  string N;
  int inf=1001001001;
  cin >> N;
  reverse(N.begin(),N.end());
  int M = N.size();
  
  vector<int> V(M+10,0);
  for(int i=0;i<M;i++){
    V[i+1] = N[i]-'0';
  }
  
  vector<vector<int>> dp(M+1,vector<int>(2,inf));
  dp[0][0] = 0;
  for(int i=1;i<=M;i++){
    for(int j=0;j<=1;j++){
      if(V[i]+j==0){
        dp[i][0] = min(dp[i][0],dp[i-1][j]);
        continue;
      }
      if(V[i]+j==10){
        dp[i][1] = min(dp[i][1],dp[i-1][j]);
        continue;
      }
      dp[i][0] = min(dp[i][0],V[i]+j+dp[i-1][j]);
      dp[i][1] = min(dp[i][1],10-(V[i]+j)+dp[i-1][j]);
    }
  }
  
  cout << min(dp[M][0],dp[M][1]+1) << endl;
  return 0;
}


Measured memory_bytes: 59780
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void){
int n,dou,cak;
scanf("%d",&n);
for(dou=0;dou<15;dou++){
    for(cak=0;cak<26;cak++){
        if(n==(cak*4+dou*7)){printf("Yes"); return 0;}
    }
}
printf("No");
}


Measured memory_bytes: 128
n = int(input())
a = list(map(int, input().split()))
a = list(reversed(sorted(a)))

result = a[0]
n -= 2

i = 1

while n > 0:
	result += a[i]
	n -= 1
	if n > 0:
		result += a[i]
		n -= 1

	i += 1

print(result)

Measured memory_bytes: 104616
n = int(input())
L = [[0, 0] for _ in range(n)]
for i in range(n):
  x, l = map(int, input().split())
  L[i][1] = x -l
  L[i][0] = x + l
  
L.sort()

ans = 0
for i in range(n):
  if i == 0:
    temp = L[i][0]
    ans += 1
  else:
    if L[i][1] >= temp:
      ans += 1
      temp = L[i][0]
    else:
      continue
print(ans)

Measured memory_bytes: 20016
readline = open(0).readline
ans = []
while 1:
    N, X = map(int, readline().split())
    if not N:
        break
    res = 0
    for x in range(1, N+1):
        for y in range(x+1, N+1):
            z = X - x - y
            if y < z <= N:
                res += 1
    ans.append("%d\n" % res)
open(1, 'w').writelines(ans)


Measured memory_bytes: 5612
#include <iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<array>
#include<functional>
#include<iomanip>
#include<ios>
using namespace std;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)

typedef int value_type; /* ソートするキーの型 */

value_type med3(value_type x, value_type y, value_type z)
/* x, y, z の中間値を返す */
{
    if (x < y)
        if (y < z) return y; else if (z < x) return x; else return z; else
        if (z < y) return y; else if (x < z) return x; else return z;
}

void quicksort(value_type a[], int left, int right,value_type index[])
/* クイックソート
 * a     : ソートする配列 
 * left  : ソートするデータの開始位置
 * right : ソートするデータの終了位置
 * index: index配列
 */
{
    if (left < right) {
        int i = left, j = right;
        value_type tmp, pivot = med3(a[i], a[i + (j - i) / 2], a[j]); /* (i+j)/2ではオーバーフローしてしまう */
        while (1) { /* a[] を pivot 以上と以下の集まりに分割する */
            while (a[i] < pivot) i++; /* a[i] >= pivot となる位置を検索 */
            while (pivot < a[j]) j--; /* a[j] <= pivot となる位置を検索 */
            if (i >= j) break;
            tmp = a[i]; a[i] = a[j]; a[j] = tmp; /* a[i],a[j] を交換 */
            tmp = index[i]; index[i] = index[j]; index[j] = tmp;
            i++; j--;
        }
        quicksort(a, left, i - 1,index);  /* 分割した左を再帰的にソート */
        quicksort(a, j + 1, right,index); /* 分割した右を再帰的にソート */
    }
}


int dfs(int n,int N){
    if (n>N){
        return 0;
    }
    

    int ret;
    
    return ret;
}

int main(){
    int A,B,T;
    cin >>A>>B>>T;

    int ans=0;

    for(int i=1;i*A<=T;i++){
        ans+=B;
    }

    cout <<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

int a[100010],b[100000];

class UF{
	vector<int> rnk,par,num;
	public:
	UF(int n) : rnk(n),par(n),num(n){
		init();
	}
	void init(){
		for(int i = 0;i < rnk.size();i++){
			rnk[i] = 0;
			par[i] = i;
			num[i] = 1;
		}
	}
	int find(int x){
		if(par[x] == x) return x;
		return par[x] = find(par[x]);
	}
	void unite(int x,int y){
		x = find(x);
		y = find(y);
		if(x == y) return;
		if(rnk[x] < rnk[y]){
			par[x] = y;
			num[y] += num[x];
		}
		else{
			par[y] = x;
			num[x] += num[y];
			if(rnk[x] == rnk[y]) rnk[x]++;
		}
	}
	bool same(int x,int y){
		return (find(x) == find(y));
	}
	int number(int x){
		return num[find(x)];
	}
};

signed main(){
	int n,m,ans,an[100010];
	cin >> n >> m;
	ans = n * (n - 1) / 2;
	UF uf(n);
	for(int i = 0;i < m;i++){
		cin >> a[i] >> b[i];
		a[i]--;
		b[i]--;
	}
	for(int i = m - 1;i >= 0;i--){
		an[i] = ans;
		if(!uf.same(a[i],b[i])) ans -= uf.number(a[i]) * uf.number(b[i]);
		uf.unite(a[i],b[i]);
	}
	for(int i = 0;i < m;i++) cout << an[i] << endl;
}

Measured memory_bytes: 6016
def get_ans(x1,y1,x2,y2):
    def_x = abs(x2-x1)
    def_y = abs(y2-y1)

    if x2 < x1 and y2 <= y1:
        x3 = x2+def_y
        y3 = y2-def_x
        x4 = x1+def_y
        y4 = y1-def_x 
    elif y2 < y1 and x1 <= x2:
        x3 = x2+def_y
        y3 = y2+def_x
        x4 = x1+def_y
        y4 = y1+def_x     
    elif x2 > x1 and y1 <= y2:
        x3 = x2-def_y
        y3 = y2+def_x
        x4 = x1-def_y
        y4 = y1+def_x 
    elif y2 > y1 and x1 >= x2:
        x3 = x2-def_y
        y3 = y2-def_x
        x4 = x1-def_y
        y4 = y1-def_x

    print(x3,y3,x4,y4)
    #return x3,y3,x4,y4

x1,y1,x2,y2 = map(int, input().split())
get_ans(x1,y1,x2,y2)

Measured memory_bytes: 8932
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>

using namespace std;


int main(){

  int n;
  cin>>n;
  string s,t;
  cin>>s;
  cin>>t;
  int tmp = -1;
  for(int i = 0;i<t.size();i++){
    if(s.substr(i,s.size()-i)==t.substr(0,t.size()-i)){
      tmp = i;
      break;
    }
  }
  if(tmp ==-1){
    cout<<s.size()+t.size()<<endl;
  }else{
    cout<<s.size()+tmp<<endl;
  }
  return 0;
}


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

static const unsigned long long int MOD = 1000000007LL;

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

    if (x < a)
    {
        cout << 0;
    }
    else
    {
        cout << 10;
    }

    return 0;
}

Measured memory_bytes: 256
import math

N = int(input())
P = input().split()
Q = input().split()
a = 1
b = 1
la = list(range(1,N+1))
lb = list(range(1,N+1))
#print(la)
#print(lb)
for i in range(N-1):
  a += (la.index(int(P[i]))-1)*math.factorial(N-1-i)
  la.remove(int(P[i]))
  b += (lb.index(int(Q[i]))-1)*math.factorial(N-1-i)
  lb.remove(int(Q[i]))
  #print(la)
  #print(lb)
#a = a - int(P[-1])+1
#b = b - int(Q[-1])+1
print(abs(b-a))

Measured memory_bytes: 3064
a,b,m = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
#print(A,B)

X = []
Y = []
C = []
total = 2*10**5
for i in range(m):
    x,y,c = map(int,input().split())
    X.append(x)
    Y.append(y)
    C.append(c)
for i in range(m):
    result = int(A[int(X[int(i)])-1])+int(B[int(Y[int(i)])-1])-int(C[int(i)])
    if (total > result):
        total = result
#print(int(min(A))+int(min(B)))
if(int(min(A))+int(min(B))>total):
    print(total)
else:
    print(int(min(A))+int(min(B)))

Measured memory_bytes: 24972
def greedy_sche(read_dir=1):
    res = []
    i = 1 if read_dir == 1 else n 
    cnt = 1
    while cnt <= k:
        if s[i - 1]:
            res.append(i)
            cnt += 1
            i += read_dir * (c + 1)
        else:
            i += read_dir
    return res


n, k, c = map(int, input().split())
s = [c == 'o' for c in input()]

for f, b in zip(greedy_sche(1), greedy_sche(-1)[::-1]):
    if f == b:
        print(f)


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
typedef long long ll;

const int INF = 1e9;
ll n;
unordered_map<string, ll> mp;

int main() {
  cin >> n;
  string s;
  ll ans = 0;
  rep(i, n) {
    cin >> s;
    //   auto itr = mp.find(s);
    //   if (itr != mp.end()) {
    //     mp[s] = 0;
    //   } else {
    //     mp[s] = itr->second + 1;
    //   }
    // }
    // for (auto itr = mp.begin(); itr != mp.end(); ++itr)
    //   ans = max(ans, itr->second);
    sort(s.begin(), s.end());
    ans += mp[s];
    mp[s]++;
  }

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


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

int main(void){
    int H,W;
    cin >> H >> W;
    string S[H+10];
    for(int i=0;i<H;i++){
        cin >> S[i];
    }
    const int dx[4] = {0,1,-1,0};
    const int dy[4] = {1,0,0,-1};
    bool can = true;
    //上下左右に黒いマスがない黒いマスを探索
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            int count = 0;
            if(S[i][j] == '.') continue;
            for(int k=0;k<4;k++){
                int ni = i + dy[k];
                int nj = j + dx[k];
                if(S[ni][nj] == '.'){
                    count++;
                }
            }
            if(count == 4){
                can = false;
            }

        }
    }
    if(can) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const LL MOD = (LL)1e9 + 7;
const int MAXN = 234567;
LL pw2[MAXN], pw4[MAXN];

LL mul(LL a, LL b) {
    return (a * b) % MOD;
}

LL add(LL a, LL b) {
    LL ans = (a + b);
    if (ans >= MOD) ans -= MOD;
    return ans;
}

int main() {
    int N;
    scanf("%d", &N);

    pw4[0] = pw2[0] = 1;
    for (int i = 1; i < MAXN; i++) {
        pw2[i] = (pw2[i - 1] * 2) % MOD;
        pw4[i] = (pw4[i - 1] * 4) % MOD;
    }

    vector<int> C;
    for (int i = 0; i < N; i++) {
        int tmp;
        scanf("%d", &tmp);
        C.push_back(tmp);
    }
    sort(C.begin(), C.end());
    LL ans = 0;
    for (int i = 0; i < N; i++) {
        int c = C[i];
        int X = (N - i - 1);
        LL sum = pw2[X];
        if (X > 0) {
            LL tmp = mul(X, pw2[X - 1]);
            sum = add(sum, tmp);
        }
        sum = mul(sum, mul(pw4[i], 2));
        sum = mul(sum, pw2[X]);
        sum = mul(sum, c);
        ans = add(ans, sum);
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 5112
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define ub upper_bound
#define lb lower_bound
#define bit __builtin_popcount
#define memset(x) memset(x,0,sizeof(x))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vector<int>> matrix;

inline void boost(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

const ll maxn=2e5+123;
const ll inf=1e9+123;
const ll linf=1e18+123;
const ll mod=1e9+7;
const double eps=1e-9;
const double pi=acos(-1);
int dx[8]={0,1,-1,0,1,-1,1,-1};
int dy[8]={1,0,0,-1,1,1,-1,-1};

int main(){
    boost();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n;
    cin>>n;
    cout<<n*n;
	exit(0);
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Set;

//Long Distance Taxi
public class Main{

	class E{
		int t, c;
		public E(int t, int c) {
			this.t = t;
			this.c = c;
		}
	}
	
	Map<String, Integer> ref;
	int ID, INF = 1<<29, M = 2001;
	int reg(String s){
		if(ref.containsKey(s))return ref.get(s);
		ref.put(s, ID);
		return ID++;
	}

	Set<E>[] adj;
	int[] d;
	boolean[] gas;
	
	@SuppressWarnings("unchecked")
	void run(){
		Scanner sc = new Scanner(System.in);
		d = new int[6000*2001];
		adj = new Set[6000];
		gas = new boolean[6000];
		for(;;){
			int n = sc.nextInt(), m = sc.nextInt(), cap = sc.nextInt();
			if((n|m|cap)==0)break;
			ref = new HashMap<String, Integer>();
			ID = 0;
			int S = reg(sc.next()), T = reg(sc.next());
			for(int i=0;i<6000;i++)adj[i]=new HashSet<E>();
			while(n--!=0){
				int s = reg(sc.next()), t = reg(sc.next()), D = sc.nextInt();
				adj[s].add(new E(t, D)); adj[t].add(new E(s, D));
			}
			Arrays.fill(gas, false);
			while(m--!=0)gas[reg(sc.next())]=true;
			for(int i=0;i<ID;i++)for(int j=0;j<=10*cap;j++)d[i*M+j]=INF;
			PriorityQueue<Integer> q = new PriorityQueue<Integer>(ID, new Comparator<Integer>() {
				public int compare(Integer o1, Integer o2) {
					return d[o1]-d[o2];
				}
			});
			d[S*M+10*cap] = 0;
			q.add(S*M+10*cap);
			int res = INF;
			while(!q.isEmpty()){
				int v = q.poll();
				int p = v/M, c = v%M;
				if(p==T){
					res = Math.min(res, d[v]); break;
				}
				for(E e:adj[p]){
					if(c-e.c<0)continue;
					int w = d[v]+e.c;
					if(gas[e.t]){
						if(w < d[e.t*M+10*cap]){
							d[e.t*M+10*cap] = w; q.add(e.t*M+10*cap);
						}
					}
					else{
						if(w < d[e.t*M+c-e.c]){
							d[e.t*M+c-e.c] = w; q.add(e.t*M+c-e.c);
						}
					}
				}
			}
			System.out.println(res==INF?-1:res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 0
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
                    int a = sc.nextInt();
            int b = sc.nextInt();
            int x = sc.nextInt();
        double zero = (double)a * a * b / 2;
        if (x < zero) {

            
            double c = (double)2 * x / a / b;   // 2x = a * b * c
            
            
            double tai = Math.sqrt(Math.pow(b, 2)+ Math.pow(c, 2));
            
            double d = c / tai;
            
            System.out.println(Math.toDegrees(Math.acos(d)));
            
        } else {
            int z = a*a*b - x;
            
            double c = (double) 2 * z / a / a;
            
            // a *a *c = 2z
            
            double tai = Math.sqrt(Math.pow(a, 2)+ Math.pow(c, 2));
            
            double d = a / tai;
            System.out.println(Math.toDegrees(Math.acos(d)));
        }
    }
}


Measured memory_bytes: 23124
def main():
    N, M = map(int, input().split())
    X = list(map(int, input().split()))
    X.sort()
    
    h = [0]*M
    for i in range(1, M):
        h[i] = X[i]-X[i-1]
    
    h.sort(reverse=True)
    print(X[M-1]-X[0]-sum(h[:(N-1)]))
main()

Measured memory_bytes: 13960
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int[] nums=new int[n];
    for(int i=0;i<n;i++){
      nums[i]=sc.nextInt();
    }
    boolean[] turned=new boolean[n];
    turned[0]=true;
    int now=1;
    int turns=0;
    while(true){
      turns++;
      now=nums[now-1];
      if(turned[now-1]){
        System.out.println(-1);
        return;
      }else if(now==2){
        System.out.println(turns);
        return;
      }
      turned[now-1]=true;
    }
  }
}

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

int main(){
  ll N;
  cin>>N;
  N--;
  vector<char>ch;
  while(true){
    char CH='a'+(N%26);
    ch.push_back(CH);
    if(N/26==0){
      break;
    }else{
      N=N/26-1;
    }
  }
  reverse(ch.begin(),ch.end());
  for(ll i=0;i<ch.size();i++)cout<<ch.at(i);
  cout<<endl;
}

Measured memory_bytes: 3632
/*
 * atcoder/abc101_2nd/c.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

int N, K;
vector<ll> A;
void solve() {
  cin >> N >> K;
  ll a;
  int min_n = -1;
  loop(n,0,N) {
    cin >> a;
    A.push_back(a);
    if (a == 1) min_n = n;
  }

  // N = 10
  //            l   r
  // 0 1 2 3 4 [5 6 7] 8 9
  // 0 1 2 3 4 [5 6 7] 8 9
  int min_ = 200000;
  for (int l=0; l+K-1<N; l++) {
    int r = l+K-1;
    if (min_n < l or r < min_n) continue;
    int cost = 1;
    if (l > 0) cost += (int)(ceil(l/(double)(K-1)));
    cost += (int)(ceil((N-l-K)/(double)(K-1)));
    chmin(min_, cost);
  }
  cout << min_ << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;

#define A first
#define B second

const ll p = 1e9+7;

ll n, k;
ll dp[105][205*205];

int main() {
	cin >> n >> k;
	for (int i = n; i >= 1; --i) {
		if (i == n) {
			if (k == n)
				dp[n][1] = 1;
			else
				dp[n][1] = 0;
			dp[n][0] = k+1 - dp[n][1];
			continue;
		}

		for (int j = 0; j <= k; ++j)
			for (int m = 0; m <= n*n; ++m) {
				if (j > i) {
					dp[i][m] = (dp[i][m] + dp[i+1][m])%p;
				} else {
					int y = j/i*i;
					if (y == 0)
						y += i;
					if (y < j)
						y += i;
					int z = (j+m)/i*i;
					int s = (z-y)/i + 1;
					if (s < 0)
						s = 0;

					dp[i][m + s] = (dp[i][m + s] + dp[i+1][m])%p;
				}
			}

		/* for (int m = 0; m <= n*n; ++m)
			cout << dp[i][m] << ' ';
		cout << endl; */

		//how to do exactly j things
	}

	ll ans = 1;
	for (int i = 0; i < n; ++i)
		ans = (ans*(k+1))%p;
	ans = ans*n%p*k%p*(p+1)/2%p;

	for (int i = 0; i <= n*n; ++i) {
		ans = (ans + p - dp[1][i]*i%p)%p;
	}

	cout << ans << endl;
}

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

void main_()
{
    ll R, G, B, N;
    cin >> R >> G >> B >> N;

    ll ans = 0;
    for (ll r = 0; r <= N; ++r) {
        for (ll g = 0; g <= N; ++g) {
            auto remain = (N - R * r - G * g);
            if (remain >= 0 && remain % B == 0) {
                ans++;
            }
        }
    }
    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,i,need = 0;string beh;stack<char> v;cin >> n >> beh;
  for(i=0;i<n;i++){
    if(beh[i]==')' && v.empty()) need++;
    else if(beh[i]==')') v.pop();
    else v.push(beh[i]);
  }
  cout << string(need,'(') << beh << string(v.size(),')') << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
int main()
{
	int n;
	string s;
	cin >> n;
	cin >> s;
	int cnt = 0;
	for (int i = 0; i < n-2; i++) {
		if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') {
			cnt++;
		}
	}
	cout << cnt << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
#define mod 1000000007
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define setA0(a) for(ull i =0;i<n;i++){a[i] = 0;}
#define aout(a) for(auto x : a){cout<<x<<' ';} // array output macro 
#define ain(a) for(ull i =0;i<n;i++){cin>>a[i];} //array input macro
#define NofSetBits(x) __builtin_popcount(x);
#define InpGrph(g,e) while(e--){ll x;ll y;cin>>x>>y ;g[x].pub(y);g[y].pub(x);}
#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll N =1000007;
vector<bool>primes(1000007,1);


int main(){
  FastIO;
  string s;
  cin>>s;
  ll sum =0;
  for(char c : s){
    sum+=(c-'0');
  }
  if(sum%9==0){
    cout<<"Yes";
  }else{
    cout<<"No";
  }
  return 0;
}


Measured memory_bytes: 3804
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
   ll n,k,x,y,i,j;
   vector<ll>v;
   ll sum=0;
   cin>>n>>k;
   for(i=0;i<n;i++)
   {
       cin>>x;
       v.push_back(x);
   }
   sort(v.begin(),v.end());
   for(i=0;i<k;i++)
   {
       sum+=v[i];
   }
   cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= 9; i++) {
        if ((i - 1) * 111 < n && n <= i * 111) {
            cout << i * 111 << endl;
            return 0;
        }
    }
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
#define v(i) vector<i>
#define vv(i) vector<vector<i>>
#define Yes cout<<"Yes"<<endl; 
#define No cout<<"No"<<endl;
#define YES cout<<"YES"<<endl; 
#define NO cout<<"NO"<<endl;
#define yes cout<<"yes"<<endl; 
#define no cout<<"no"<<endl;

// cin.eof() 入力個数の問題
// int num = atoi(string.c_str()); 文字列の整数変換
int keta(ll n){int ans=0;while(n>0){n /= 10; ans++;}return ans;}
ll _pow(ll a,ll b){ll ans = 1;rep(i,b){ ans *= a;}return ans;}

int main() {
  int n;cin>>n;
  ll a[n];
  rep(i,n){
      cin>>a[i];
  }
ll ans = 0;
rep(i,n-1){
    if(a[i]>a[i+1]){
        ans += a[i] - a[i+1];
        a[i+1] = a[i];
    }
}
cout<<ans<<endl;
    return 0;
}


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

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

  vector<int> a(N + 1), b(N + 1);
  for (int i = 1; i < a.size(); i++)
  {
    cin >> a.at(i);
  }

  int count = 0, now = 1;
  while (true)
  {
    if (b.at(now) == 1)
    {
      count = -1;
      break;
    }
    else
    {
      count++;
      if (a.at(now) == 2)
      {
        break;
      }
      b.at(now) = 1;
      now = a.at(now);
    }
  }

  cout << count << endl;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main(){
    int sx,sy,tx,ty,i;
    int dx,dy;

    scanf("%d %d %d %d",&sx,&sy,&tx,&ty);
    dx = tx-sx; dy=ty - sy;

    for(i=0;i<dy;i++){
        printf("U");
    }
    for(i=0;i<dx;i++){
        printf("R");
    }
    for(i=0;i<dy;i++){
        printf("D");
    }
    for(i=0;i<dx+1;i++){
        printf("L");
    }
    for(i=0;i<dy+1;i++){
        printf("U");
    }
    for(i=0;i<dx+1;i++){
        printf("R");
    }
    printf("D");printf("R");
    for(i=0;i<dy+1;i++){
        printf("D");
    }
    for(i=0;i<dx+1;i++){
        printf("L");
    }
    printf("U");

    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#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()
#define ll long long
#define INF 1000000000000000000

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

ll LCM(ll a, ll b) {
    ll g = GCD(a, b);
    return a / g * b;
}

int main() {
    ll N;
    cin >> N;
    ll g, sum, lcm;
    cin >> g;
    lcm = g;
    rep(i, N - 1) {
        ll a;
        cin >> a;
        lcm = LCM(lcm, a);
    }
    cout << lcm << endl;
}

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

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

#define INF (1<<(4*4-1))
#define MOD 1000000007

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

   int A,B,C;
   cin>>A>>B>>C;
   ll ans = B+min(A+B+1,C);
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 100

int F[N];

int fib(int n){
  int i;
  F[0] = 1;
  F[1] = 1;
  for( i = 2 ; i <= n ; i++){
    F[i] = F[i-2] + F[i-1];
  }
  
  return F[n];

}

int main(){
  int n, i, j, k;
  int ans;

  scanf("%d", &n);
  ans = fib(n);

  printf("%d\n" ,ans);
  return 0; // Don't forget return 0
}

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

using namespace std;

int main(){
	double r;
	double a, b;

	cin >> r;

	a = r * r * 3.14159265358979;
	b = r * 2 * 3.14159265358979;

	printf("%.6lf %.6lf\n", a, b);

	return 0;
}

Measured memory_bytes: 1240
# coding: utf-8
s = input()
ans = 0
for bit in range(2**(len(s)-1)):
    tmp = ""
    for j in range(len(s)):
        if (bit >> j) & 1 == 1:
            tmp += s[j]
            tmp += "+"
        else:
            tmp += s[j]
    ans += eval(tmp)
print(ans)

Measured memory_bytes: 3060
#include <iostream>

// using
using namespace std;

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

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}

// main
int main() {
    const int MAX_N = 100000;
    int N, K, A[MAX_N];
    cin >> N >> K;
    REP(i, N) {
        cin >> A[i];
    }
    cout << 1 + ceil(N - K, K - 1) << endl;
    return 0;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
    	var sc = new Scanner();
    	var c = new string[] { "dream", "dreamer", "erase", "eraser" };
    	
    	string s = sc.NextString();
    	int l = s.Length;
    	while (l > 0)
    	{
    		bool find = false;
    		for (int j = 0; j < c.Length; j++)
    		{
    			int b = l - c[j].Length;
    			if (b >= 0 && s.Substring(b, c[j].Length) == c[j])
    			{
    				l -= c[j].Length;
    				find = true;
    				break;
    			}
    		}
    		if (find) continue;
    		Console.WriteLine("NO");
    		return;
    	}
    	Console.WriteLine("YES");
    }
    
    static long Gcd(long a, long b)
    {
        if (a < b) return Gcd(b, a);
        if (b == 0) return a;
        return Gcd(b, a % b);
    }
}

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }
        
    public long NextLong()
    {
    	CheckNext();
    	return long.Parse(buf[index++]);
    }
    
    public double NextDouble()
    {
    	CheckNext();
    	return double.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}

Measured memory_bytes: 13112
import sys
import itertools
# import numpy as np
import time

sys.setrecursionlimit(10 ** 7)

from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

class UnionFind(object):
    def __init__(self, n = 1):
        self.link = [i for i in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        if self.link[x] == x:
            return x

        # re-connect union find to make the height of tree lower
        # you can use while, but recursion makes it easier to reconnect
        self.link[x] = self.find(self.link[x])
        return self.link[x]

    def is_same(self, x, y):
        return self.link[x] == self.link[y]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return

        if self.size[x] < self.size[y]:
            x, y = y, x
        self.link[y] = x
        self.size[x] += self.size[y]
    
    def get_size(self, x):
        x = self.find(x)
        return self.size[x]

# from union_find import *

n, k, l = map(int, readline().split())

u1 = UnionFind(n)
u2 = UnionFind(n)


for i in range(k):
    p, q = map(lambda x: int(x) - 1, readline().split())
    u1.unite(p, q)

for i in range(l):
    r, s = map(lambda x: int(x) - 1, readline().split())
    u2.unite(r, s)

c = defaultdict(int)

for i in range(n):
    c[(u1.find(i), u2.find(i))] += 1

for i in range(n):
    print(c[u1.find(i), u2.find(i)])


Measured memory_bytes: 56044