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

int main(){
  int k;
  cin >> k;
  int x=0,s=0;
  for(int l=1;l<=k;l++){
    for(int m=1;m<=k;m++){
      for(int n=1;n<=k;n++){
        for(int i=1;i<=min(l,min(m,n));i++){
          if(l%i==0&&m%i==0&&n%i==0){
            x=i;
          }
        }
        s+=x;
        x=0;
      }
    }
  }
  cout << s << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using M = map<int, int>;

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

  int cntR = 0, cntG = 0, cntB = 0;
  rep(i, n) {
    if (s[i] == 'R') cntR++;
    else if (s[i] == 'G') cntG++;
    else if (s[i] == 'B') cntB++;
  }

  ll ans = (ll)cntR * cntG * cntB;


  rep(i, n) {
    repI(j, i+1, n) {
      int k = 2*j - i;
      if (k >= n) break;
      if (s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) ans--;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <map>
#include <algorithm>
#include <utility>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mp make_pair
#define INF (1<<28)
typedef long long Int;

int N, B[64], C[64];
string A[64], D[64][64];
int g[64][64], vis[64];
int m, q[64];

void collect(int at) {
    if (vis[at]) return ;
    vis[at] = 1;
    q[m++] = at;
    rep (i, N) if (g[at][i]) collect(i);
}

int n, a, r[64], p[64], w[4][1024];
Int f[64];

void prepare() {
    n = m;
    a = 0;
    rep (i, n) r[i] = q[i];
    rep (i, n) {
        p[i] = B[r[i]];
        f[i] = 0;
        rep (j, n) if (g[r[i]][r[j]]) f[i] |= 1LL<<j;
    }
    rep (k, 4) rep (b, 1024) {
        int s = 0;
        for (int i = 0; i < 10 && k*10+i < n; i++) if (b&(1<<i)) s += p[k*10+i];
        w[k][b] = s;
    }
}

void rec(int k, Int u) {
    int s = w[0][u&1023] + w[1][(u>>10)&1023]
        + w[2][(u>>20)&1023] + w[3][(u>>30)&1023];
    if (s < a) return ;
    if (k == n) a = s;
    else {
        rep (i, k) if (!(u&(1LL<<i)) && !(f[i]&u)) return ;
        const int mask = (1LL<<n) - 1;
        if (u&(1LL<<k)) rec(k+1, u&(mask-f[k]));
        if (r[k]) rec(k+1, u&(mask-(1LL<<k)));
    }
}

int solve() {
    memset(vis, 0, sizeof(vis));
    int ans = 0;
    rep (i, N) if (!vis[i]) {
        m = 0;
        collect(i);
        prepare();
        rec(0, (1LL<<n)-1);
        ans += a;
    }
    return ans;
}

int main() {
    for (;;) {
        cin >> N;
        if (N == 0) return 0;
        map<string, int> of;
        rep (i, N) {
            cin >> A[i] >> B[i] >> C[i];
            of[A[i]] = i;
            rep (j, C[i]) cin >> D[i][j];
        }
        memset(g, 0, sizeof(g));
        rep (i, N) rep (j, C[i]) g[i][of[D[i][j]]] = 1;
        printf("%d\n", solve());
    }
}

Measured memory_bytes: 1392
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
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; }
const int INF = 1<<29;
using Graph = vector<vector<int>>;
int main() {
    ll res = 0;
    ll N,M; cin >> N >> M;
    vector<ll> H(N);
    for (int i=0;i<N;++i) cin >> H[i];
    vector<bool> A(N);
    for (int i=0;i<N;++i) A[i] = true;
    for (int i=0;i<M;++i){
        int a,b; cin >> a >> b; --a; --b;
        if (H[a]<=H[b]) A[a] = false;
        if (H[b]<=H[a]) A[b] = false; 
    }
    for (int i=0;i<N;++i) {
        if (A[i]==true) res++;
        // if (A[i]==true) cout << i+1 << endl;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4052
#include <stdio.h>

int main(){
	int i,count=0;
	char w[11],m[101];
	scanf("%s",&w);
	while (1){
		scanf("%s",&m);
		if (strcmp("END_OF_TEXT",m)==0) break;
		for (i=0;i<101;i++){
			if (m[i]>='A'&&m[i]<='Z')
				m[i]=m[i]+32;
		}
		if (strcmp(w,m)==0) count++;
	}
	printf("%d\n",count);
	return 0;
}	



Measured memory_bytes: 2044
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>

typedef long long ll;
#define fi first
#define se second


using namespace std;

int main(){
  int A, B;
  
  cin>>A>>B;
  
  int A1, B1;
  int d;
  
  A1 = A;
  B1 = B;
  
  
  int ans = 0;
  
  
  if( A1 < 0 ){
    A1 *= -1;
  }
  
  if( B1 < 0 ){
    B1 *= -1;
  }
  
  d = A1 - B1;
  
  if( d ){
    if( d > 0 ){
      if( A > 0 ) ans++;
      if( B > 0 ) ans++;
      ans += d;
    }
    else{//  d < 0
       if( A < 0 ) ans++;
       if( B < 0 ) ans++;
       ans -= d;
    }
    
    cout<<ans<<endl;
  }
  else{
    if( A+B ) puts("0");
    else{     puts("1");} 
  }
  
  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);
		int a,b;
		a = sc.nextInt();
		b = sc.nextInt();
		
		if(a==b)System.out.println("a == b");
		else if(a>b)System.out.println("a > b");
		else System.out.println("a < b");
	}

}

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

int main(){
    int n;
    cin >>  n ;
    vector <int> x(n);
    rep(i,n){
        cin >> x[i];
    }
    int hp=0;
    int ans=100100100;
    
    
    rep(i,101){
        hp=0;
        rep(j,n){
            //hp+=(x[j]-i)*(x[j]-i);
            hp+=pow(x[j]-i,2);
        }
        
        
        ans=min(hp,ans);
        //cout << i << " " << ans << endl;
        }
    
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
  int N,a[200];
  int dim = 100;
  cin >> N;
  for(int i = 0;i < N; i++){
    cin >> a[i];
    int b = 0;
    while(a[i] % 2 == 0){
      a[i] = a[i] / 2;
      b++;
    }
    dim = min(dim,b);
  }
  cout << dim << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0; i<(n); ++i)
#define rep1(i,n) for(ll i=1; i<=(n); ++i)
#define repi(i,a,b) for(ll i=a; i<=(b); ++i)
#define rrep(i,n) for(ll i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
using Edge = pair<ll,ll>;
using Graph = vector<vector<Edge>>;
typedef pair<ll,ll> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll devc(ll x, ll y){return 1 + (x-1)/y;}

ll solve(ll N, vector<ll> A){
    vector<ll> C(3); ll ans = 1;

    rep(i,N){
        if(A[i] > i) return 0;
        ll ct = 0;
        rep(j,3) if(C[j] == A[i]) ct++;
        ans *= ct;
        ans %= MOD;
        rep(j,3) if(C[j] == A[i]){ C[j]++; break;}
        sort(ALL(C));
    }
    return ans;
}

int main(){
    ll N; cin >> N;
    vector<ll> A(N); rep(i,N) cin >> A[i];
    pr(solve(N,A));
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define f first 
#define s second
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define MAX 1000005
#define pb push_back
int flag[1000006];
ll gcd(ll a, ll b)
{
  if(a == 0)
    return b;
  return gcd(b%a,a);
}
ll power(ll a,ll b)
{
  ll res = 1;
  while(b > 0)
  {
    if(b%2 == 1)
      res = res*a;
    a = a*a;
    b/=2;
  }
  return res;
}
bool cmp(pair<pair<string,int>,int>&a, pair<pair<string,int>,int>&b)
{
  if(a.f.f!=b.f.f)
    return a.f.f < b.f.f;
  return a.f.s > b.f.s;
}
int main(){
  FIO;
  int n,p;
  string s;
  cin >> n;
  vector<pair<pair<string,int>,int>>v;
  v.clear();
  for (int i = 0; i < n; ++i)
  {
    cin >> s >> p;
    v.pb(make_pair(make_pair(s,p),(i+1)));
  }
  sort(v.begin(), v.end(),cmp);
  for (int i = 0; i < n; ++i)
  {
    cout << v[i].s << "\n";
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define vi vector<int>
#define vb vector<bool>
#define pii pair<int,int>
#define mod 1000000007
#define ss second
#define ff first
#define vpii vector<pii>
#define vvi vector<vi>
#define pb push_back
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,i;
    cin>>n;
    string s;
    cin>>s;
    int ans =0;
    for(i=0;i<=n-3;i++){
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
n, k = gets.split.map(&:to_i)
xy = n.times.map {gets.split.map(&:to_i)}.sort_by{|x,y| x}

ans = 10 ** 20
0.upto(n-k) do |i|
    (i+k-1).upto(n-1) do |j|
        a = xy[i..j].map{|x,y| y}.sort
        s = 0.upto(j-i+1-k).map{|w| a[w+k-1] - a[w]}.min * (xy[j][0] - xy[i][0])
        ans = s if ans > s
    end
end

p ans

Measured memory_bytes: 14556
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;


int main(){
	int x;
	cin >> x;
	if (x >= 30) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3588
# 105 = 3 * 5 * 7
# 1, 3, 5, 7, 15, 21, 35, 105
# 3 つの 素数を1回ずつ掛けてできる数(素因数が3つ)
# 3, 5, 7, 11, 13, 17
# 5 * 3 * 3 * 3 = 135
# 3 * 5 * 11 = 165
# 7 * 3 * 3 * 3 = 189
# 3 * 5 * 13 = 195

# 105以下では1つ(105のみ)なら, 200以下の整数なら, そういう奇数は105のみ?

prime = [3, 5, 11, 13, 17]

N = int(input())

if N >= 195:
    print(5)
elif N >= 189:
    print(4)
elif N >= 165:
    print(3)
elif N >= 135:
    print(2)
elif N >= 105:
    print(1)
else:
    print(0)



Measured memory_bytes: 2940
import sys
n = int(input())
A=[int(e)for e in sys.stdin]
cnt = 0
G = [int((3**i-1)/2)for i in range(30,0,-1)]
G = [v for v in G if v <= n]
def insertionSort(A, n, g):
    global cnt
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
for g in G:
    insertionSort(A, n, g)
print(len(G))
print(*G)
print(cnt)
print(*A,sep='\n')


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

#define MOD (1000000000+7)
#define MAX_H 100
#define MAX_W 8

int H, W, K;

long long dp[MAX_H + 1][MAX_W];
int mul[MAX_W][MAX_W];

int main()
{
	cin >> H >> W >> K;

	for( int bit = 0; bit < 1 << (W - 1); bit++ ) {
		int ng = 0;
		for( int j = 0, mask = 3; j < W - 2; j++, mask <<= 1 ) {
			if( (bit & mask) == mask ) {
				ng = 1;
			}
		}
		if( ng ) {
			continue;
		}
		vector<int> v( W );
		for( int j = 0; j < W; j++ ) {
			v[j] = j;
		}
		for( int j = 0; j < W; j++ ) {
			if( bit & (1 << j) ) {
				swap( v[j], v[j + 1] );
			}
		}
		for( int j = 0; j < W; j++ ) {
			mul[j][v[j]]++;
		}
	}

	dp[0][0] = 1;
	for( int i = 0; i < H; i++ ) {
		for( int j = 0; j < W; j++ ) {
			for( int k = 0; k < W; k++ ) {
				dp[i + 1][k] += dp[i][j] * mul[j][k] % MOD;
				dp[i + 1][k] %= MOD;
			}
		}
	}

	cout << dp[H][K - 1] << endl;

	return 0;
}


Measured memory_bytes: 256
//! 尺卂乃卂.卂ﾌ乇乇ㄒ
#include<bits/stdc++.h>
using namespace std;

#define int             long long
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define vii             vector<vector<int>>
#define mii             map<int,int>
#define mip             map<pair<int,int>,int>
#define mic             map<char,int> 
#define all(v)          v.begin(),v.end()  
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define itr(v)          for(auto it:v)
#define show(arr,n)     for(int i=0;i<n;i++) cout<<arr[i]<<" "; cout<<"\n";
#define fi(i,n)         for(int i=0;i<n;i++)
#define fd(i,n)         for(int i=n-1;i>=0;i--)
#define fir(i,a,b)      for(int i=a;i<b;i++)
#define fin(s)          freopen(s,"r",stdin);  
#define fout(s)         freopen(s,"w",stdout);
#define MAXZ            200005
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int expo(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return a;
    int val=(expo(a,b/2,m)*expo(a,b/2,m))%m;
    if(b & 1) return (val*a)%m;
    else return val;
}
int mmi(int a,int m){
    return expo(a,m-2,m);
}
bool cmp(pii a,pii b){
    int c1=a.first-a.second;
    int c2=b.first-b.second;
    if(c1*c2>=0){
        if(c1>=0 && c2>=0){
            return a.second<b.second;
        }
        else{
            return a.first>b.first;
        }

    }
    else{
        if(c1>0){
            return 1;
        }
        else{
            return 0;
        }
    }
}
 string a[2000001];
int32_t main()
{
    FIO
    int n; cin>>n;
    fi(i,n) cin>>a[i];
    vector<pii> v;
    int uop=0,ucp=0;
    fi(i,n) {
        int op=0,cp=0;
        int count=0;
        for(int j=0;j<a[i].length();j++){
            if(a[i][j]=='('){
                count++;
            }
            else{
                if(count<=0) {
                    cp++;
                }
                else count--;
            }
        }
        op+=count;
        pii p1(op,cp);
        if(op==0 || cp==0){
            uop+=op;
            ucp+=cp;
        }
        else v.pb(p1);
        // cout<<a[i]<<" "<<op<<" "<<cp<<"\n";
    }
    sort(v.begin(),v.end(),cmp);
    int ans=1;
    int op=uop;
    for(int i=0;i<v.size();i++){
        // cout<<v[i].first<<" "<<v[i].second<<"\n";
        op=op-v[i].second;
        if(op<0) {
            ans=0;
            break;
        }
        op+=v[i].first;
    }
    op-=ucp;
    if(op==0 && ans){
        cout<<"Yes\n";
    }
    else cout<<"No\n";

}

Measured memory_bytes: 69948
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}


int main(){FIN
    ll n;cin>>n;
    vll a(n+1); REP(i,n) cin>>a[i];
    a[n] = 0;
    ll total =1000;
    ll kabu=0;
    ll id1=0;
    ll id2=0;
    REP(i,n){
        if (a[i] >= a[i+1]) {
            if (id1<id2) {
                kabu = total / a[id1];
                total = total - a[id1] * kabu;
                total = total + a[id2] * kabu;
                kabu = 0;
            }
            id2++;
            id1 = id2;
        }
        else id2++;
    }
    cout<<total<<endl;
    return 0;
}


Measured memory_bytes: 3652
import sys
s = input()

def match(a):
  if a[0:2] == 'hi':
    return a[2:]
  else:
    print('No')
    sys.exit()
if len(s)%2 == 1:
  print('No')
  sys.exit()
else:
  while len(s) > 1:
    s = match(s)
  print('Yes')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

void solve();

int n;

int main(){
    ios::sync_with_stdio(0), cin.tie(0);
    while (cin >> n) {
        solve();
    }
    return 0;
}

void solve() {
    int now, a, b;
    bool bad = true;
    now = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a >> b;
        if (a == b) now++;
        else now = 0;
        if (now >= 3) bad = false;
    }

    if (bad) cout << "No\n";
    else cout << "Yes\n";
}


Measured memory_bytes: 3648
#include <cstdio>
#include <algorithm>

using namespace std;

const int N = 2e5 + 2;

int n, a[N], b[N];
int c[N], d[N];                         // c, d contains index of a and b respectively

int tmp[N];
void Sort(int a[], int v[], int k)      // a: index array, v: value array
{
    int cnt[2] = {};
    for (int i = 0; i < n; ++i) ++cnt[(v[a[i]] >> k) & 1];
    cnt[1] += cnt[0];
    for (int i = n - 1; i >= 0; --i) tmp[--cnt[(v[a[i]] >> k) & 1]] = a[i];
    copy(tmp, tmp + n, a);
}

inline int Get(int mask, int k) { return mask & ((1 << k) - 1); }       // returns first k bit of mask

int Solve(int k, int lo, int hi)
{
    int ret = 0;
    for (int i = n - 1, l = 0, r = 0; i >= 0; --i)
    {
        while (l < n && Get(a[c[i]], k) + Get(b[d[l]], k) < lo) ++l;
        while (r < n && Get(a[c[i]], k) + Get(b[d[r]], k) < hi) ++r;
        ret ^= (r - l) & 1;
    }
    return ret;
}

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) scanf("%d", &a[i]), c[i] = i;
    for (int i = 0; i < n; ++i) scanf("%d", &b[i]), d[i] = i;

    int res = 0;
    for (int k = 0; k < 29; ++k)
    {
        Sort(c, a, k);
        Sort(d, b, k);
        int T = 1 << k;
        if (Solve(k + 1, T, T * 2) ^ Solve(k + 1, T * 3, T * 4))
            res += T;
    }
    printf("%d", res);
    return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
#define ITR(v,c) for(auto v=begin(c);v!=end(c);++v)
#define FORE(x,c) for(auto &x:c)
#define FOR(v,a,n) for(int v=a;v<(int)(n);++v)
#define REP(v,n) FOR(v,0,n)
#define RREP(v,n) for(int v=((int)(n)-1);v>=0;--v)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define SZ(c) ((int)c.size())
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0}, DY[9]={-1,0,1,0,-1,1,1,-1,0};
const int INF=1e9; const long long INFLL=1e18;
template<class T> ostream& operator << (ostream &os, const vector<T> &v) {
    ITR(i,v) os<<*i<<(i==end(v)-1?"":" "); return os; }
template<class T> istream& operator >> (istream &is, vector<T> &v) {
    ITR(i,v) is>>*i; return is; }
//------------------------------------------------------------------------------

signed main() {
    int H,W;
    cin>>H>>W;
    REP(i,H) {
        REP(j,W) {
            string s;
            cin>>s;
            if(s=="snuke") {
                printf("%c%d\n",'A'+j,i+1);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
#define pb push_back

int n, h[100005], dp[100005];

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> h[i];
    dp[2] = abs(h[1] - h[2]);
    for (int i = 3; i <= n; ++i) dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i]));
    cout << dp[n] << '\n';
    return 0;
}



Measured memory_bytes: 1024
'use strict';

const S = "S";

const process = (input) => {
    let finalLength = input.length;
    let currentSCount = 0;

    for (let i=0, length = input.length; i<length; i++) {
        if (input.charCodeAt(i) === 83) {
            currentSCount++;
        } else {
            if (currentSCount > 0) {
                currentSCount--;
                finalLength-=2;
            }
        }
    }

    console.log(finalLength);
}

process(require("fs").readFileSync("/dev/stdin", "utf8").trim().split('\n')[0]);

Measured memory_bytes: 7500
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
const ll MAX_N = 1e5;
ll N;
ll h[MAX_N];
ll dp[MAX_N+1]; // メモ化テーブル
 
// i番目以降の品物から重さの総和がj以下になるように選ぶ
void rec(ll i){
	if (i==0) dp[i] = 0;
	else if (i==1) dp[i] = abs(h[1]-h[0]);
	else dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
	return;
}

int main() {
	// 入力
	ll N;
	cin >> N;
	ll A[N];
	for (ll i = 0; i < N; ++i) cin >> A[i];
	
	// 解法
	ll B[N];
	REP(i,N) B[i] = A[i];
	sort(B, B + N, greater<ll>());
	REP(i,N){
		if (A[i]==B[0]) cout<<B[1]<<endl;
		else cout<<B[0]<<endl;
	}
}


Measured memory_bytes: 4736
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << '\n';
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const T &a) {
    for (auto e : a) cout << e << ' ';
    cout << '\n';
}

//------------------------- Libraries -------------------------//

struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<int> siz;
 
    UnionFind (int n = 1) {
        init(n);
    }
 
    void init(int n = 1) {
        par.resize(n); rank.resize(n); siz.resize(n);
        for (int i = 0; i < n; i++) par[i] = i, rank[i] = 0, siz[i] = 1;
    }
 
    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }
 
    bool same(int x, int y) {
        return root(x) == root(y);
    }
 
    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;
 
        if (rank[x] < rank[y]) {
            par[x] = y;
            siz[y] += siz[x];
        }
        else {
            par[y] = x;
            siz[x] += siz[y];
            if (rank[x] == rank[y]) rank[x]++;
        }
    }
 
    int size(int x) {
        return siz[root(x)];
    }
};

//--------------------------- Solve ---------------------------//

void solve() {
    int N, M; cin >> N >> M;
    UnionFind uf(N);
    for (int i = 0; i < M; i++) {
        int a, b; cin >> a >> b;
        a--; b--;
        uf.unite(a, b);
    }
    int ans = 0;
    set<int> se;
    se.insert(uf.root(0));
    for (int i = 1; i < N; i++) {
        if (se.find(uf.root(i)) == se.end()) ans++;
        se.insert(uf.root(i));
    }
    cout << ans << '\n';
}

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

    solve();

    return 0;
}

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

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

    priority_queue<float, vector<float>, greater<float>> q;
    float v;
    for (int i = 0; i < N; i++)
    {
        cin >> v;
        q.push(v);
    }
    while (q.size() > 1)
    {
        float first = q.top();
        q.pop();
        float second = q.top();
        q.pop();

        q.push((first + second) / 2);
    }
    cout << q.top() << endl;
}


Measured memory_bytes: 256
import sys

n, x, y = map(int, input().split())
x -= 1
y -= 1

def calc(i, j, x, y):
    mindist = abs(j - i)
    mindist = min(mindist, abs(x - i) + 1 + abs(y - j))
    mindist = min(mindist, abs(y - i) + 1 + abs(x - j))
    return mindist

result = [0 for i in range(n)]
for i in range(n):
    for j in range(n):
        if i == j :
            continue
        k = calc(i, j, x, y)       
        result[k] += 1

for i in range(1, n):
    print(result[i] // 2)

Measured memory_bytes: 57436
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++) 
#define all(v) begin(v),end(v)
using ll = long long;

int main() {
  int n,h,w;cin>>n>>h>>w;
  int ans=(n-h+1)*(n-w+1);
  cout<<ans<<endl;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define pi pair<int,int>
#define pii pair<pi,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sortall(x) sort(all(x))
#define lli long long int
#define f(i,a,b) for (lli i = a; i <= b; i++)
#define fr(i,a,b) for (lli i = a; i >= b; i--)
#define sl(x)	scanf("%lld",&x)
#define pl(x)	printf("%lld",x)
#define ss(s)	scanf("%s",s)
#define mod 1000000007
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

void solve()
{
	lli n;
	sl(n);
	if (n % 1000 == 0)
		printf("0\n");
	else
	{
		lli ans = (n / 1000) + 1;
		pl((ans * 1000) - n), printf("\n");
	}
}
int main()
{
	IOS;
	solve();
	return 0;
}





Measured memory_bytes: 3840
n = int(input())
chk = []
for i in range(n):
    s, p = map(str, input().split())
    p = int(p)
    chk.append([s, -p])
s = sorted(chk)
#print(s)
#print(chk)
for i in s:
    print(chk.index(i)+1)

Measured memory_bytes: 9104
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

int cnt[maxn];

int main()
{
	int n=read();
	rep(i,1,n-1)
	{
		int x=read(); cnt[x]++;
	}
	rep(i,1,n) printf("%d\n",cnt[i]);
	return 0;
}

Measured memory_bytes: 4476
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000


int main(){
	long long N;
	cin>>N;
	
	long long sum = 0;
	
	vector<long long> A(N);
	for(int i=0;i<N;i++){
		cin>>A[i];
		sum += A[i];
	}
	
	if(N==1){
		cout<<"YES"<<endl;
		return 0;
	}
	
	
	long long K = N*(N+1)/2;
	
	if(sum%K!=0){
		cout<<"NO"<<endl;
		return 0;
	}
	
	sum /= K;
	
	vector<long long> B(N);
	for(int i=0;i<N;i++){
		if(i==0)B[i] = A[i]-A[N-1];
		else B[i] = A[i]-A[i-1];
		B[i] -= sum;
	}
	long long cnt = 0;
	for(int i=0;i<N;i++){
		if(B[i]>0){
			cout<<"NO"<<endl;
			return 0;
		}
		B[i]*=-1;
		if(B[i]%(N)!=0){
			cout<<"NO"<<endl;
			return 0;
		}
		cnt += B[i]/(N);
	}
	
	if(cnt!=sum){
		cout<<"NO"<<endl;
	}
	else{
		cout<<"YES"<<endl;
	}
	
	
	
	
	
	
	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
	ll N,K,Q;
	cin >> N >> K >> Q;
	ll cnt[N];
	ll i;
	for(i=0;i<N;i++){
		cnt[i]=0;
	}
	ll A;
	for(i=0;i<Q;i++){
		cin >> A;
		cnt[A-1]+=1;
	}
	for(i=0;i<N;i++){
		if(Q-cnt[i]<K)cout << "Yes"<<endl;else cout <<"No"<<endl;
	}
	return 0;
}


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    for (int i = 0; i < 100000; ++i) {
        int t = i * 60 + c;
        if (t % (a + b) <= a) {
            cout << t << "\n";
            return 0;
        }
    }
    cout << -1 << "\n";
    return 0;
}



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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

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

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

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


void solve(long long N, std::vector<long long> a){
    int cnt = 0;
    REP(i, N) {
        if(a[i] == cnt+1) {
            cnt++;
        }
    }

    cout << (cnt == 0 ? -1 : N - cnt) << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 1792
n=int(input())
s=[list(input()) for _ in range(n)]
a=list('')
for i in s:
  a=set(list(a)+list(i))
a=sorted(list(a))
count=[100]*len(a)
for i in range(len(a)):
  for j in s:
    count[i]=min(count[i],j.count(a[i]))
  a[i]=a[i]*count[i]
print(''.join(a))

Measured memory_bytes: 3064
#include<iostream>

using namespace std;

int main() {
	int N, M, a[55] = {}, b[55] = {}, ans[55] = {};

	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> a[i] >> b[i];
	}
	for (int i = 0; i < M; i++) {
		ans[a[i]]++;
		ans[b[i]]++;
	}
	for (int i = 1; i <= N; i++) {
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>
#include<list>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n,ll mod = MOD){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%mod;
        }
        x = (x*x)%mod;
        n >>= 1;
    }
    return ret;
}

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

ll twoPow(ll shiftNum){
    return (1LL << (shiftNum - 1));
}

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

    cout << (n - 1)/2 << endl;

    return 0;
}

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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[][] a = new int[n][2]; // idx,num
        for (int i = 0; i < n; i++) {
            a[i][0] = i;
            a[i][1] = sc.nextInt();
        }
        int lastIdx = -1;
        int curIdx = -1;
        int move = 0;
        int op = 0;
        StringBuilder sb = new StringBuilder();
        OUTER:while(move <= k){
            Arrays.sort(a, (x, y) -> y[1] - x[1]);
            for (int i = 0; i < n; i++) {
                if(a[i][0] != lastIdx){
                    if(a[i][1] > 0){
                        curIdx = a[i][0];
                        a[i][1]--;
                        sb.append(a[i][0]+1).append(" ");
                        op++;
                    }else{
                        break OUTER;
                    }
                }
            }
            move++;
            lastIdx = curIdx;
        }

        if (move > k) {
            System.out.println(op);
            System.out.println(sb.deleteCharAt(sb.length()-1).toString());
        }else{
            System.out.println("-1");
        }

        sc.close();
    }

}


Measured memory_bytes: 28500
n = gets.to_i
a = gets.chomp.split.map(&:to_i)
b2 = a.select { |item| item % 4 == 2 }.count
b4 = a.select { |item| item % 4 == 0 }.count

if b4*2 >= n || (b2/2)+b4 >= n/2
  puts 'Yes'
else
  puts 'No'
end


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

// alias templates
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

// alias declaration
using ll = long long;
using str = string;

using vll = V<ll>;
using vvll = V<vll>;
using vs = V<str>;

// loops
#define FOR(i, a, b)  for (ll i = (a); i <= (ll)(b); i++) // [a,b]
#define rFOR(i, a, b) for (ll i = (b); i >= (ll)(a); i--) // [b,a]
#define REP(i, a) FOR((i), 0, (ll)(a)-1) // [0,a-1]

// for debug
#define dbg(a) cerr << "  " << (#a) << ": " << (a) << "\n";

// procon common constants
const ll MOD_BIG = 1e9 + 7;

int main(void){
    ll r;
    /*
    vll a(n);
    REP(i,n){
        cin >> a[i];
    }
    */
    cin >> r;
    cout << 2*r*M_PI << endl;
}


Measured memory_bytes: 3784
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

int main() {
    int V;

    cin >> V;

    cout << (V^1) << endl;

    return 0;
}

Measured memory_bytes: 3488
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator
#define VL V<LL>::iterator
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define MAX 1e18
#define MIN -1e18
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
V<LL>v,u,w;
int main()
{
    FAST;
    LL n,m,i,j,k,p,q,o,l,s,t,z;
    string a;
    cin>>n>>a;
    for(i=0; a[i]; i++)
    {
        if(a[i]=='R')
        {
            v.PSB(i);
        }
        else if(a[i]=='B')
        {
            u.PSB(i);
        }
        else
        {
            w.PSB(i);
        }
    }
    k=0;
    t=0;
    for(i=0; a[i]; i++)
    {
        for(j=i+1; a[j]; j++)
        {
            if(a[i]!=a[j])
            {
                if((a[i]=='R' && a[j]=='B')||(a[i]=='B' && a[j]=='R'))
                {
                    VL it=upper_bound(w.B,w.E,j);
                    s=it-w.B;
                    s=w.SZ-s;
                }
                else if((a[i]=='R' && a[j]=='G')||(a[i]=='G' && a[j]=='R'))
                {

                    VL it=upper_bound(u.B,u.E,j);
                    s=it-u.B;
                    s=u.SZ-s;
                }
                else
                {
                    VL it=upper_bound(v.B,v.E,j);
                    s=it-v.B;
                    s=v.SZ-s;
                }
                k+=s;
                p=j-i;
                q=j+p;
                if(q<n && a[q]!=a[i] && a[q]!=a[j])
                {
                    t++;
                }
            }
        }
    }
    cout<<k-t<<endl;
    return 0;
}


Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        long answer = 0;
        for (int i = 1; i <= n; i++) {
            answer += calcFizBuzz(i);
        }
        System.out.println(answer);
        sc.close();
    }

    private static int calcFizBuzz(int n) {
        int rtn = n;
        if (((n % 3) == 0) || ((n % 5) == 0)) {
            rtn = 0;
        }
        return rtn;
    }
}


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

int n,K;
int a[200000],b[200000],c[200000];
vector<int>E[200000];
ll add[200000];
ll sum[200000];
ll C[200000];

struct Segtree{
	int N;
	vector<ll>dat;
	Segtree(){}
	Segtree(int n){
		N=1;while(N<n)N<<=1;
		dat=vector<ll>(2*N);
	}
	void update(int k,ll x){
		k+=N;
		dat[k]=x;
		while(k>1){
			k>>=1;
			dat[k]=dat[k*2]+dat[k*2+1];
		}
	}
	ll query(int l,int r){
		ll res=0;
		for(l+=N,r+=N;l<r;l>>=1,r>>=1){
			if(l&1)(res+=dat[l++]);
			if(r&1)(res+=dat[--r]);
		}
		return res;
	}
}seg;

namespace HLD{
int par[200000];
int sz[200000];
int chain[200000];
int vid[200000];
int nx[200000];
int dep[200000];

int cnt;

void dfs(int v,int p,int d){
	par[v]=p;
	sz[v]=1;
	dep[v]=d;
	for(int u:E[v]){
		if(u==p)continue;
		dfs(u,v,d+1);
		sz[v]+=sz[u];
	}
}
void hld(int v,int h){
	chain[v]=h;
	vid[v]=cnt++;
	int Max=0,id=-1;
	for(int u:E[v]){
		if(u==par[v])continue;
		if(Max<sz[u]){
			Max=sz[u];
			id=u;
		}
	}
	if(id!=-1){
		nx[v]=id;
		hld(id,h);
	}
	else nx[v]=-1;
	for(int u:E[v]){
		if(u==par[v]||u==id)continue;
		hld(u,u);
	}
}
ll query(int s,int t){
	ll ans=0;
	while(1){
		if(chain[s]==chain[t]){
			if(vid[s]>vid[t])swap(s,t);
			ans+=seg.query(vid[s]+1,vid[t]+1);
			return ans;
		}
		if(dep[chain[s]]<dep[chain[t]]){
			swap(s,t);
		}
		ans+=seg.query(vid[chain[s]]+1,vid[s]+1);
		ll cost=C[chain[s]]+add[chain[s]]+add[par[chain[s]]];
		ans+=(cost%K?cost:0);
		s=par[chain[s]];
	}
}
};
char cmd[10];

int main(){
	cin>>n>>K;
	rep(i,n-1){
		scanf("%d%d%d",&a[i],&b[i],&c[i]);
		E[a[i]].push_back(b[i]);
		E[b[i]].push_back(a[i]);
	}
	HLD::dfs(0,-1,0);
	HLD::hld(0,0);
	seg=Segtree(n);
	rep(i,n-1){
		if(HLD::par[b[i]]!=a[i])swap(a[i],b[i]);
		sum[b[i]]=c[i];
		C[b[i]]=c[i];
		seg.update(HLD::vid[b[i]],c[i]%K?c[i]:0);
	}
	int q;cin>>q;
	rep(i,q){
		scanf("%s",cmd);
		if(cmd[0]=='a'){
			int x,d;scanf("%d%d",&x,&d);
			add[x]+=d;
			sum[x]+=d;seg.update(HLD::vid[x],sum[x]%K?sum[x]:0);
			int y=HLD::nx[x];
			if(y!=-1){
				sum[y]+=d;seg.update(HLD::vid[y],sum[y]%K?sum[y]:0);
			}
		}
		else{
			int s,t;scanf("%d%d",&s,&t);
			printf("%lld\n",HLD::query(s,t));
		}
	}
}


Measured memory_bytes: 26360
#include <stdio.h>
int main(void)
{
	int i;
	char c;
	char bo[] = { 'a', 'i', 'u', 'e', 'o' };

	c = getchar();

	for (i = 0; i < 5; i++) {
		if (c == bo[i]) {
			printf("vowel");
			return 0;
		}
	}
	    puts("consonant");

	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(){
	int A [3][3] = {0} ;
	int N;
	for(int i = 0; i<3 ; i++){
		for(int j=0 ; j<3 ; j++){
			scanf("%d",&A[i][j]);
		}
	}
	scanf("%d",&N);
	int b [N];
	for(int i=0 ; i<N ; i++ ){
		scanf("%d",&b[i]);
	}
	for(int i=0 ; i<N ; i++ ){
		for(int j=0 ; j<3 ; j++ ){
			for(int k=0 ; k<3 ; k++ ){
				if(b[i] == A[j][k]){
					A[j][k] = 0;
				}
			}
		}
	}
	int sakoshun = 0;
	for(int i=0 ; i<3 ; i++){
			if (A[0][i] == 0 && A[1][i] == 0 && A[2][i] == 0){
				printf("Yes");
				return 0;
			}
			else if (A[i][0] == 0 && A[i][1] == 0 && A[i][2] == 0){
				printf("Yes");
				return 0; 
			}
	}
	if (A[0][0] == 0 && A[2][2] == 0 && A[1][1] == 0 ){
		printf("Yes");
		return 0;
	}
	if(A[0][2] == 0 && A[1][1] == 0 && A[2][0] == 0){
		printf("Yes");
		return 0;
	}
	printf("No");
			
			
		
	
}

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

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

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

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

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

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

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

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

    int N;
    read(N);

    i64 sum = 0;
    vector<i64> d(N);
    rep(i, N) {
        read(d[i]);
    }

    rep(i, N) reps(j, i+1, N-1) {
        sum += d[i] * d[j];
    }

    print(sum);


    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        vector<int> a(n), b(n);
        for(int i=0; i<n; ++i)
            cin >> a[i];
        for(int i=0; i<n; ++i)
            cin >> b[i];
        sort(a.rbegin(), a.rend());
        sort(b.rbegin(), b.rend());

        int j = 0;
        vector<int> win(n);
        for(int i=0; i<n; ++i){
            while(j < n && a[i] <= b[j])
                ++ j;
            win[i] = j;
        }

        bool ok = false;
        for(int i=0; i*2+1<n; ++i){
            if(b[i] < a[i*2]){
                cout << (i*2+1) << endl;
                ok = true;
                break;
            }
        }

        if(!ok)
            cout << "NA" << endl;
    }
}

Measured memory_bytes: 1532
#include <bits/stdc++.h>
using namespace std;
int main(){
  string N;
  cin >> N;
  if ( (N[1]==N[2]) && (N[0]==N[1]||(N[2]==N[3]))){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define be(v) v.begin(), v.end()
typedef long long ll;
typedef vector<int> vint;
#define scout cout << fixed << setprecision(5) 
ll INF = 1e9;
ll mod = 1e9+7;

int n,a[3][3],b[10];
bool ap[3][3];
int main() {
	rep(i,3)rep(j,3) {
		cin >> a[i][j];
	}
	cin >> n;
	rep(i,n) cin >> b[i];
	bool ok = false;
	rep(i,n)rep(j,n){
		ap[i][j]=false;
		rep(k,n) {
		if(a[i][j] == b[k]) ap[i][j] = true;
		}
	}
	rep(i,3) {
		if(ap[i][0]&&ap[i][1]&&ap[i][2]) ok = true;
		if(ap[0][i]&&ap[1][i]&&ap[2][i]) ok = true;
	}
	if(ap[0][0]&&ap[1][1]&&ap[2][2]) ok = true;
	if(ap[2][0]&&ap[1][1]&&ap[0][2]) ok = true;
	if(ok) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

int main(){
  long long A, B, C, K;
  cin >> A >> B >> C >> K;
  long long ans = 0;
  if(K <= A) ans += K;
  else if(K <= A + B) ans += A;
  else ans = A - (K - A - B);
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<math.h>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<iomanip>
using namespace std;
#define INF 1<<20


struct edge{
	int to;
	int cost;
	edge() {};
	edge(int a, int b) {
		to = a;
		cost = b;
	}
};

struct Node {
	int pos;
	int cost;
	Node() {};
	Node(int a, int b) {
		pos = a;
		cost = b;
	}
	bool operator <(const Node& rhs) const {
		return cost > rhs.cost;
	}
};

void dijkistra(int st, int TO,int V,vector<vector<edge> > graph) {
	priority_queue<Node> q;
	vector<int> d(V);
	for (int i = 0;i < V;i++) {
		d[i] = INF;
	}
	d[st] = 0;
	q.push(Node(st, 0));
	while (!q.empty()) {
		Node s = q.top(); q.pop();
		int pos = s.pos;
for (int i = 0;i < graph[pos].size();i++) {
	int to = graph[pos][i].to;
	int cost = graph[pos][i].cost;
	if (d[pos] + cost < d[to]) {
		d[to] = d[pos] + cost;
		q.push(Node(to, d[to]));
	}

}
	}
	cout << d[TO] << endl;
}
int partition(int A[], int p, int r) {
	int x = A[r];
	int i = p - 1;
	for (int j = p;j < r;j++) {
		if (x >= A[j]) {
			i = i + 1;
			swap(A[i], A[j]);
		}
	}
	swap(A[i + 1], A[r]);
	return i + 1;
}
void quicksort(int A[], int p, int r) {
	if (p < r) {
		int q = partition(A, p, r);
		quicksort(A, p, q - 1);
		quicksort(A, q + 1, r);
	}
}

int getNumberOfCoin(int C[], int n, int m) {
	int T[50000];
	for (int j = 0;j <= n;j++) {
		T[j] = INF;
	}
	T[0] = 0;
	for (int i = 0;i < m;i++) {
		for (int j = 0;j <= n;j++) {
			if (j - C[i] >= 0) {
				T[j] = min(T[j], T[j - C[i]] + 1);
			}
		}
	}
	return T[n];
}
int knapsack(int w, int n, int* v, int* ww) {
	int W[101][10001];
	for (int j = 0;j <= w;j++) {
		W[0][j] = 0;
	}
	for (int i = 0;i < n;i++) {
		for (int k = 0;k < n;k++) {
			for (int j = 0;j <= w;j++) {
				if (j - ww[k] < 0) {
					W[i + 1][j] = W[i][j];
				}
				if (j - ww[i] >= 0) {
					W[i + 1][j] = max(W[i][j], W[i][j - ww[k]] + v[k]);

				}
			}
		}
	}
	return W[n][w];
}
int fib(int n) {
	vector<int> v(n + 1);
	v[0] = 1;
	v[1] = 1;
	for (int i = 2;i < n + 1;i++) {
		v[i] = v[i - 2] + v[i - 1];
	}
	return v[n];
}
int isPrime(int x) {
	if (x <= 1) return false;
	if (x > 2 && x % 2 == 0) return false;
	for (int i = 2;i <= sqrt(x);i++) {
		if (x%i == 0) {
			return false;
		}
	}
	if (x == 2) return true;
	return true;
}
int gnc(int a, int b) {
	while (b%a != 0) {
		if (a > b) swap(a, b);
		else {
			b = b%a;
		}
	}
	return a;
}
int calc(int a, long long int b, long long int m) {
	if (b == 0) return 1;
	else if (b % 2 == 0) {
		long long int d = calc(a, b / 2, m);
		return (d*d) % m;
	}
	else {
		long long int d = calc(a, b -1, m);
		return (d*a) % m;
	}
}


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




Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    

int n,l,s;
l=-10000000000;
s=100000000000;
long long sum=0;
cin>>n;
int a[10000];
int i;
 
for(i=0;i<n;i++){
cin>>a[i];
sum+=a[i];
l=max(l,a[i]);
s=min(s,a[i]);
}
 
cout<<s<<" "<<l<<" "<<sum<<endl;
return 0;
}


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

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

    for (string::iterator it = s.begin(); it != s.end(); ++it) {
        if (*it == 'B') {if(!ans.empty()) ans.erase(ans.end()-1);}
        else {ans.push_back(*it);}
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

  long long N,M,ans;

  scanf("%lld", &N);
  scanf("%lld", &M);
  
  if( N == 1 && M == 1){
    ans = 1;
  }else if( M == 1){
    ans = N - 2;
  }else if( N == 1){
    ans = M - 2;
  }else{
    ans = (M-2)*(N-2);
  }

  printf("%lld", ans);

}
  


Measured memory_bytes: 128