akhauriyash/Code-Regression huggingface dataset:
#include <cstring>
#include <cfloat>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
const int MAX_N = 10;
int n;
string f[MAX_N];
int w[MAX_N];
int s[MAX_N];

double ming;
vector<int> minindeies;

vector<int> selected;
bool used[MAX_N];
void permutation(int r, int limit) {
	if (r == 0) {
		double a = 0., b = 0.;
		for (int i = 0; i < n; i++) {
			a += w[selected[i]] * (i + 1);
			b += w[selected[i]];
		}
		double g = a / b;
		if (g < ming) {
			ming = g;
			minindeies = selected;
		}
	}
	else {
		for (int i = 0; i < n; i++) {
			if (used[i]) continue;
			if (w[i] > limit) continue;
			used[i] = true;
			selected.push_back(i);
			permutation(r - 1, min(limit - w[i], s[i]));
			selected.pop_back();
			used[i] = false;
		}
	}
}

int main () {
	while (cin >> n, n) {
		for (int i = 0; i < n; i++) {
			cin >> f[i] >> w[i] >> s[i];
		}
		memset(used, 0, sizeof(used));
		ming = DBL_MAX;
		permutation(n, 0x7ffffff);
		for (int i = 0; i < n; i++) {
			cout << f[minindeies[i]] << endl;
		}
	}
	return 0;
}

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

typedef long long ll;
ll solve(ll h[],ll n,ll i)
{
    if(n==0)
        return 0;
    if(i==n-1)
    {
        return 0;;
    }
    if(i==n-2)
        return abs(h[n-1]-h[n-2]);
    return min( (abs(h[i+1]-h[i])+solve(h,n,i+1)),(abs(h[i+2]-h[i])+solve(h,n,i+2)));
}
ll solve_dp(ll h[],ll n)
{
    ll ans[n]={INT_MAX};
    ans[0]=0;
    ll temp,i;
    ans[1]=abs(h[1]-h[0]);
    ans[2]=min(abs(h[2]-h[1])+ans[1],abs(h[2]-h[0]));
    for(i=3;i<n;i++)
    {
        temp=min(abs(h[i]-h[i-1])+ans[i-1],abs(h[i]-h[i-2])+ans[i-2]);
        ans[i]=temp;
    }
    return ans[n-1];
}


int main()
{
    ll n,i;;
    cin>>n;
    ll h[n];
    for(i=0;i<n;i++)
    {
        cin>>h[i];
    }
    ll ans=solve_dp(h,n);
    cout<<ans<<endl;

}


Measured memory_bytes: 1792
from collections import defaultdict
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    Q = int(input())
    Query = list()

    for q in range(Q):
        B, C = map(int, input().split())
        Query.append([B, C])

    elem = defaultdict(int)
    s = 0

    for a in A:
        elem[a] += 1
        s += a

    for q in Query:
        B, C =  q

        if B in elem.keys():
            # Bの数
            nB = elem[B]

            # Cが存在するならBの数分、Cを増やす
            if C in elem.keys():
                elem[B] = 0
                elem[C] += nB
              
                s = s - B * nB + C * nB
                print(s) 
            else:
                elem[B] = 0
                elem[C] = nB
                
                s = s - B * nB + C * nB
                print(s)
            
        else:
            print(s)
           
if __name__ == "__main__":
    main()

Measured memory_bytes: 33292
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[N][N];
int color[N], d[N], f[N], tt;

// 再帰関数による深さ優先探索
void dfs_visit(int u) {
  int v;
  color[u] = GRAY;
  d[u] = ++tt;  // 最初の訪問
  for ( v = 0; v < n; v++ ) {
    if ( M[u][v] == 0) continue;
    if ( color[v] == WHITE )
      dfs_visit(v);
  }
  color[u] = BLACK;
  f[u] = ++tt;  // 訪問の完了
}

void dfs() {
  int u;
  // 初期化
  for ( u = 0; u < n; u++ ) color[u] = WHITE;
  tt = 0;

  for ( u = 0; u < n; u++ )
    // 未訪問の u を始点として深さ優先探索
    if ( color[u] == WHITE ) dfs_visit(u);
  for ( u = 0; u < n; u++ )
    printf("%d %d %d\n", u + 1, d[u], f[u]);
}

int main() {
  int u, v, k, i, j;

  scanf("%d", &n);
  for ( i = 0; i < n; i++ )
    for ( j = 0; j < n; j++ ) M[i][j] = 0;

  for ( i = 0; i < n; i++ ) {
    scanf("%d %d", &u, &k);
    u--;
    for ( j = 0; j < k; j++ ) {
      scanf("%d", &v);
      v--;
      M[u][v] = 1;
    }
  }

  dfs();

  return 0;
}


Measured memory_bytes: 2676
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n,m;
  cin>>n>>m;
  if(n>m) swap(n,m);
  if(n==1&&m==1) cout<<1<<endl;
  else if(n==1) cout<<m-2<<endl;
  else cout<<(n-2)*(m-2)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll N, M; cin >> N >> M;
    vector<ll> H(N,0);
    vector<bool> good(N,true);
    REP(i,N) cin >> H[i];
    ll ans = 0;
    REP(i,M){
      ll a, b;
      cin >> a >> b;
      a--;b--;
      if(H[a] > H[b]){
        good[b] = false;
      }else if(H[b] > H[a]){
        good[a] = false;
      }else{
        good[a] = false; good[b] = false;
      }
    }
    REP(i,N) if(good[i]) ans++;
    cout << ans;
    
  	return 0;
}

Measured memory_bytes: 3992
import math
import itertools


# 与えられた数値の桁数と桁値の総和を計算する.
def calc_digit_sum(num):
    digits = sums = 0
    while num > 0:
        digits += 1
        sums += num % 10
        num //= 10
    return digits, sums


a, b, c, d = map(int, input().split())
answer = float('-inf')
for x in [a,b]:
    for y in [c, d]:
        answer = max(answer, x * y)

print(answer)

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

const ll MOD = 1e9+7;

template<int MOD> struct Fp {
  long long val;
  constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
    if (val < 0) v += MOD;
  }
  constexpr int getmod() { return MOD; }
  constexpr Fp operator - () const noexcept {
    return val ? MOD - val : 0;
  }
  constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
  constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
  constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
  constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
  constexpr Fp& operator += (const Fp& r) noexcept {
    val += r.val;
    if (val >= MOD) val -= MOD;
    return *this;
  }
  constexpr Fp& operator -= (const Fp& r) noexcept {
    val -= r.val;
    if (val < 0) val += MOD;
    return *this;
  }
  constexpr Fp& operator *= (const Fp& r) noexcept {
    val = val * r.val % MOD;
    return *this;
  }
  constexpr Fp& operator /= (const Fp& r) noexcept {
    long long a = r.val, b = MOD, u = 1, v = 0;
    while (b) {
      long long t = a / b;
      a -= t * b; swap(a, b);
      u -= t * v; swap(u, v);
    }
    val = val * u % MOD;
    if (val < 0) val += MOD;
    return *this;
  }
  constexpr bool operator == (const Fp& r) const noexcept {
    return this->val == r.val;
  }
  constexpr bool operator != (const Fp& r) const noexcept {
    return this->val != r.val;
  }
  friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
    return os << x.val;
  }
  friend constexpr istream& operator >> (istream &is, Fp<MOD>& x) noexcept {
    return is >> x.val;
  }
  friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
    if (n == 0) return 1;
    auto t = modpow(a, n / 2);
    t = t * t;
    if (n & 1) t = t * a;
    return t;
  }
};

using mint = Fp<MOD>;

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

  int K = N + 40;
  vector<mint> fact(K+1, 1), ifact(K+1, 1);
  for(int i = 1; i <= K; i++) {
    fact[i] = fact[i-1] * i;
    ifact[i] = modpow(fact[i], MOD - 2);
  }

  mint ans = 1;
  int m = M;
  for(int i = 2; i*i <= m; i++) {
    if(M % i) continue;
    int c = 0;
    while(m % i == 0) {
      c++;
      m /= i;
    }

    ans *= fact[c+N-1] * ifact[N-1] * ifact[c]; // comb(c+N-1, c);
  }
  if(m != 1) ans *= N;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
n, a, b = map(int, raw_input().split())
l = map(int, raw_input().split())
init = l[0] - 1
for i in xrange(0,len(l)):
    l[i] = l[i] - init
ans = 0
for i in xrange(1,n):
    ans = ans + min((l[i] - l[i-1]) * a, b)
print ans


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

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

    int ans = 0;
    for (int i = 0; i < S.size(); i++) {
        for (int j = 0; i + j <= S.size(); j++) {
            string sub = S.substr(i, j);
            bool flag = true;

            for(auto e : sub) {
                if(e != 'A' && e != 'G' && e != 'C' && e != 'T') flag = false;
            }

            if (flag) ans = max(ans, (int)sub.size());
        } 
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};
int main() {
	init();

	int N, M; cin >> N >> M;
    vector<int>a(N + 1, 0);
    rep(i, M) {
        int x; cin >> x;
        a[x]++;
    }

    vector<ll>dp(N + 1, 0);
    dp[0] = 1;
    rep(i, N) {
        REP(j,1,3) {
            if (i+j > N)continue;
            if (a[i + j] > 0)continue;
            dp[i + j] = (dp[i + j] + dp[i]) % mod;
        }
    }
    cout << dp[N] << "\n";

	return 0;
}

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

string s;
int a[100009];
int main()
{
	cin>>s;
	int len=s.length() ;
	int sum=0;
	for(int i=0;i<len;i++)
	{
		if(s[i]=='L')
		{
			a[i-1]+=(sum+1)/2;
			a[i]+=sum/2;
			sum=0;
		}
		else sum++;
	}
	sum=0;
	for(int i=len-1;i>=0;i--)
	{
		if(s[i]=='R')
		{
			a[i+1]+=(sum+1)/2;
			a[i]+=sum/2;
			sum=0;
		}
		else sum++;
	}
	for(int i=0;i<len;i++)
	{
		cout<<a[i]<<" "; 
	}
	return 0;
} 
/*
RRRLLRRRRLRRRRLL
0 0 2 3 0 0 0 0 2 3 0 0 0 3 3 0
0 0 3 2 0 0 0 0 2 3 0 0 0 3 3 0
*/

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

using namespace std;
typedef long long int LL;
typedef long long int LLint;

//Faster Coding
#define ED return 0
#define GET(a) LL a;cin >> a
#define PRINT(a) cout << a << endl
#define ANS(a,b) LL a;cin >> a;cout << b << endl
#define SORT(vec) sort(vec.begin(),vec.end())
#define REV(vec) reverse(vec.begin(),vec.end())

//Difficult Syntax
#define DOUBLECHANGE(count) cout << setprecision(count)

//As Function
#define UP(a,b) ((a+(b-1))/b)
#define ipow(x,y) LL(pow(x,y))

//Debug
#define TEST cout << "OK" << endl

const long long INF = 999999999;
const long long mod = 1000000007;

int main(){
      cin.tie(0);
      ios::sync_with_stdio(false);
      ANS(a,pow(a,2)*3);
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")

//インクルード
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

int main() {
  // 高速化
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int a;
    cin >> a;

    int yen500 = a/500 ;
    int yen5 = (a%500)/5;

    cout << (yen500*1000 + yen5*5)  << "\n"; 

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>  
#include <cmath>  
#include <ctime>  
#include <string>  
#include <cstring>  
#include <cstdlib>  
#include <iostream>  
#include <algorithm>  
#include <set> 
#include <queue>  
#include <vector>  
#include <map>
#include <complex>
#include <list>
#define pb push_back 
#define lb lower_bound 
#define lowbit(x) (x)&(-x)   
#define forup(i,a,b) for(int i=(a);i<=(b);i++)  
#define fordown(i,a,b) for(int i=(a);i>=(b);i--)  
#define maxn 400005 
#define INF 1070000000  
#define pa   pair<double,int>
#define  mp  make_pair
#define pi  acos(-1);
#define int ll
using namespace std;  
typedef long long ll;  
typedef unsigned long long ull;  
  
template<class T> inline  void read(T& num){   num = 0; bool f = true;char ch = getchar();   while(ch < '0' || ch > '9') { if(ch == '-') f = false;ch = getchar();}   while(ch >= '0' && ch <= '9') {num = num * 10 + ch - '0';ch = getchar();}   num = f ? num: -num;  } 
int out[100]; 
template<class T> inline 
void write(T x,char ch){  if (x==0) {putchar('0'); putchar(ch); return;}  if (x<0) {putchar('-'); x=-x;} int num=0; while (x){ out[num++]=(x%10); x=x/10;} fordown(i,num-1,0) putchar(out[i]+'0'); putchar(ch); } 
/*========================================================*/
int n,c,k;
int t[maxn];
struct per
{  int siz,col;}p[maxn];
bool cmp(per x,per y)
{return   x.siz<y.siz;}
bool  vis[maxn];
bool check(int x)
{  int sz=p[x].siz;
    forup(i,1,n)
       { if(i==x)  continue;
          if(p[i].siz<=sz*2)
             {  sz+=p[i].siz;}
          else {return 0;} 
       } 
   return 1;
}
signed main()
{  cin>>n; 
forup(i,1,n)
    {  read(p[i].siz);
       p[i].col=i; 
    }
   sort(p+1,p+1+n,cmp); 
    //forup(i,1,n)
    //sum[i]=sum[i-1]+p[i].siz;
  int l=1,r=n;
  while(l+1<r)
  { int mid=(l+r)>>1;
      if(check(mid))   r=mid;
       else  l=mid;
  } 
  int sta;
  if(check(l)) sta=l;
  else sta=r;
 // cout<<sta<<endl;
   forup(i,sta,n)
    {  vis[p[i].col]=1; }
   int cnt=0;
  forup(i,1,n)
    if(vis[i]) cnt++;
    cout<<cnt;
 return 0;
}

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

template <class T>
using V = vector<T>;

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

	int a, b;

	cin >> a >> b;

	int x = a + b;
	int y = a - b;
	int z = a * b;

	cout << max(x, max(y, z)) << "\n";

	return 0;
}

Measured memory_bytes: 256
import itertools
def op(x,y,i):
    if i=="+": return x+y
    elif i=="-": return x-y
    elif i=="*": return x*y

e0 = "((({} {} {}) {} {}) {} {})"
e1 = "(({} {} {}) {} ({} {} {}))"
def check(A, n):
    w,x,y,z = A
    S="+-*"
    for i in S:
        a = op(w,x,i)
        for j in S:
            b1,b2 = op(a,y,j),op(y,z,j)
            for k in S:
                if op(b1,z,k)==n: return e0.format(w,i,x,j,y,k,z)
                if op(a,b2,k)==n: return e1.format(w,i,x,k,y,j,z)
    return 0

n = 10
while 1:
    x = map(int,raw_input().split())
    if x==[0,0,0,0]: break
    for e in itertools.permutations(x):
        s = check(e,n)
        if s: break
    print s

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

using namespace std;

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;

    int counter = 0;
    int x;
    int minn = 1e9;
    for(int i=0;i<n;++i){
        cin >> x;
        if(x <= minn)
            counter++;
        
        minn = min(minn, x);
    }

    cout << counter << '\n';

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
          Scanner sc = new Scanner(System.in);
          int num = sc.nextInt();
          String str = sc.next();
          if(num >= 3200) {
            System.out.println(str);
          } else {
            System.out.println("red");
          }
          }
  }


Measured memory_bytes: 21844
#include <stdio.h>

int main(void){
	
	int i, n;
	
	scanf("%d", &n);
	
	for(i = 1; i <= 9; i++){
		if(n <= i * 111){
			printf("%d", i * 111);
          	break;
		}
	}
	
	return 0;
}

Measured memory_bytes: 128
use proconio::input;

fn main() {
  input! {
    n: usize,
    bs: [usize;n-1]
  }
  
  let mut sum = bs[0];
  for i in 0..bs.len() - 1 {
    sum += std::cmp::min(bs[i], bs[i+1]);
  }
  sum += bs[bs.len()-1];
  
  println!("{}", sum);
}

Measured memory_bytes: 2152
import sys

N = int(sys.stdin.readline())
ABC = [[None]*3 for i in range(N)]

for i in range(N):
    ABC[i][0], ABC[i][1], ABC[i][2] = map(int, sys.stdin.readline().split())

happiness = [[0] *3 for i in range(N+1)]

for i in range(N):
    for j in range(3):
        happiness[i+1][j] = max(happiness[i][j-1] + ABC[i][j], happiness[i][j-2] + ABC[i][j])

print(max(happiness[N]))

Measured memory_bytes: 69996
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define REP(i,x,n) for (int i=x; i<n; i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;

ll combination(int n,int k){//組み合わせ
  ll ans = 1;
  if (k == 1){
    return n / k;
  }
  ans = n * combination(n-1, k-1) / k;
  return ans;
}

int main(){
  int n;
  cin >> n;
  vector<string> vec(n+1);
  vec.at(n) = "zzzzzzzzzzz";
  rep(i,n){
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    vec.at(i) = s;
  }
  sort(vec.begin(), vec.end());
  /*rep(i,n){
    cout << vec.at(i) << endl;
  }*/
  int cnt = 1;
  ll ans = 0;
  rep(i,n){
    if (vec.at(i) == vec.at(i+1)) cnt++;
    else if (cnt == 1) continue;
    else {
      ans += combination(cnt, 2);
      cnt = 1;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6388
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;
typedef long long ll;
int mod(ll a){
    int c=a%1000000007;
    if(c>=0)return c;
    else return c+1000000007;
}
typedef pair<int,int> i_i;


int main(){
    priority_queue<int> q;
    char s[10];
    int n;
    while(1){
        cin>>s;
        if(s[0]=='i'){
            cin>>n;
            q.push(n);
        }else if(s[1]=='x'){
            cout<<q.top()<<endl;q.pop();
        }else{
            break;
        }
    }
    
    return 0;
}




Measured memory_bytes: 6952
ans = []
loop do
    input = gets.split(" ")
    if input[0] == "0" && input[1] == "0"; break; end
    n = input[0].to_i
    x = input[1].to_i
    sum = 0
    1.upto(n) do |a|
        (a+1).upto(n) do |b|
            (b+1).upto(n) do |c|
                if a != b && b != c && a != c && (a + b + c == x)
                    sum += 1
                end
            end
        end
    end
    ans << sum
end
puts ans


Measured memory_bytes: 6844
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int ar[][] = new int[n][3];
		int dp[][] = new int[n][3];

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

			ar[i][0] = sc.nextInt();
			ar[i][1] = sc.nextInt();
			ar[i][2] = sc.nextInt();

			for (int j = 0; j < 3; j++)
				dp[i][j] = -1;
		}

		int a = func(0, 0, dp, ar);
		int b = func(0, 1, dp, ar);
		int c = func(0, 2, dp, ar);
		System.out.println(Math.max(a, Math.max(b, c)));
		sc.close();
	}

	private static int func(int i, int j, int dp[][], int[][] ar) {

		if (i == ar.length - 1)
			return dp[i][j] = ar[i][j];

		if (dp[i][j] != -1)
			return dp[i][j];

		int max = Integer.MIN_VALUE;

		for (int x = 0; x < 3; x++) {

			if (x != j) {
				max = Math.max(max, (ar[i][j] + func(i + 1, x, dp, ar)));
				// System.out.println(max);
			}
		}
		return dp[i][j] = max;
	}

}

Measured memory_bytes: 114584
#include <stdio.h>

int main(){
    int n,m,l;
    scanf("%d %d %d",&n,&m,&l);
    long A[n][m];
    long B[m][l];
    long C[n][l];

    for(int i=0;i<n;i++){
        for(int f=0;f<l;f++){
            C[i][f] = 0;
        }
    }
    
    for(int i=0;i<n;i++){
        for(int f=0;f<m;f++){
            scanf("%ld",&A[i][f]);
        }
    }

    for(int i=0;i<m;i++){
        for(int f=0;f<l;f++){
            scanf("%ld",&B[i][f]);
        }
    }

    for(int i=0;i<n;i++){
        for(int f=0;f<l;f++){
            for(int k=0;k<m;k++){
                C[i][f] += A[i][k]*B[k][f];
            }
        }
    }  

    for(int i=0;i<n;i++){
        for(int f=0;f<l;f++){
            if(f==0)
                printf("%ld",C[i][f]);
            else
                printf(" %ld",C[i][f]);
        }
        printf("\n");
    }   

}


Measured memory_bytes: 2112
from collections import deque


class UnionFind:
    def __init__(self, v):
        self.v = v
        self._tree = list(range(v + 1))

    def _root(self, a):
        queue = deque()
        while self._tree[a] != a:
            queue.append(a)
            a = self._tree[a]
        while queue:
            index = queue.popleft()
            self._tree[index] = a
        return a

    def union(self, a, b):
        root_a = self._root(a)
        root_b = self._root(b)
        self._tree[root_b] = root_a

    def find(self, a, b):
        return self._root(a) == self._root(b)


N, Q = map(int, input().split(' '))
queries = [tuple(map(int, input().split(' '))) for _ in range(Q)]
union_find = UnionFind(N - 1)
for p, a, b in queries:
    if p == 0:
        union_find.union(a, b)
    else:
        if union_find.find(a, b):
            print(1)
        else:
            print(0)



Measured memory_bytes: 21152
x=int(input())

if x <= 599:
    print(8)
elif x <= 799:
    print(7)
elif x <= 999:
    print(6)
elif x <= 1199:
    print(5)
elif x <= 1399:
    print(4)
elif x <= 1599:
    print(3)
elif x <= 1799:
    print(2)
else:
    print(1)

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




int main()
{
    string s;
    cin>>s;
    ll n = s.length();
    ll* a = new ll [n+1]();
    ll* b = new ll [n+1]();

    for(ll i=1;i<=n;i++)
    {
        if( s[i-1] =='<')
            a[i] = a[i-1] +1;
    }
    for(ll i = n-1;i>=0;i--)
    {
        if( s[i] =='>')
            b[i] = 1 +b[i+1];
    }
    ll ans =0;
    for(ll i=0;i<=n;i++)
    {
        ans += max( a[i] , b[i] );
    }
    cout<<ans;
}


Measured memory_bytes: 11604
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
map<string, int> used;
int n;
int calc(const string &s) {
	int res = 0;
	queue<string>q;
	used[s] = true; q.push(s); res++;
	while (!q.empty()) {
		string x = q.front(); q.pop();
		rep(i, n - 1) {
			if (x[i] != x[i + 1]) {
				string y = x;
				char t = 'a' + (3 - (x[i] - 'a') - (x[i+1] - 'a'));
				y[i] = y[i + 1] = t;
				if (used[y])continue;
				//cout << y << endl;
				used[y] = true; res++; q.push(y);
			}
		}
	}
	return res;
}
//何文字目、同じとこあったか、総和のmod3、前回
ll dp[1 << 18][2][3][3];
int main() {
	string s; cin >> s; n = s.length();
	if (s.length() <= 4) {
		cout << calc(s) << endl;
	}
	else {
		ll ans = 0;
		int sum = 0;
		bool f = true; bool g = true;
		rep(i, n - 1) {
			if (s[i] == s[i + 1])f = false;
			if (s[i] != s[i + 1])g = false;
		}
		if (g) {
			cout << 1 << endl; return 0;
		}
		if (f)ans++;
		rep(i, n) {
			sum += s[i] - 'a'; sum %= 3;
		}
		dp[0][0][0][0] = dp[0][0][1][1] = dp[0][0][2][2] = 1;
		rep(i, n - 1) {
			rep(j, 3) {
				rep(k, 3) {
					rep(l, 3) {
						(dp[i + 1][1][(j + l) % 3][l] += dp[i][1][j][k]) %= mod;
						if (k == l) {
							(dp[i + 1][1][(j + l) % 3][l] += dp[i][0][j][k]) %= mod;
						}
						else {
							(dp[i + 1][0][(j + l) % 3][l] += dp[i][0][j][k]) %= mod;
						}
					}
				}
			}
		}
		rep(j, 3) {
			ans += dp[n - 1][1][sum][j]; ans %= mod;
		}
		cout << ans << endl;
	}
	//stop
	return 0;
}


Measured memory_bytes: 29188
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

// 再帰
ll solve(string s, int k) {
    ll n = s.size();
    if (n < k) return 0;
    if (s[0] == '0') return solve(s.substr(1, n - 1), k);

    ll ans = 0;
    if (k == 1) {
        ans += s[0] - '0';
        ans += (n - 1) * 9;
    } else if (k == 2) {
        ans += (s[0] - '0' - 1) * 9 * (n - 1);
        ans += 81 * (n - 1) * (n - 2) / 2;
        ans += solve(s.substr(1, n - 1), 1);
    } else if (k == 3) {
        ans += (s[0] - '0' - 1) * 81 * (n - 1) * (n - 2) / 2;
        ans += 729 * (n - 1) * (n - 2) * (n - 3) / 6;
        ans += solve(s.substr(1, n - 1), 2);
    }

    return ans;
}

// 桁DP
int dp[105][2][5];
ll solve2(string s, int k) {
    int n = s.size();
    dp[0][0][0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 2; j++) {
            for (int l = 0; l <= k; l++) {
                for (int d = 0; d < 10; d++) {
                    int num = s[i] - '0';
                    if (j == 0 && d > num) continue;
                    dp[i + 1][j || d < num][d == 0 ? l : l + 1] += dp[i][j][l];
                }
            }
        }
    }
    return dp[n][0][k] + dp[n][1][k];
}

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

    string s;
    int k;
    cin >> s >> k;

    // cout << solve(s, k) << "\n";
    cout << solve2(s, k) << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (1<<30)
struct NODE{
	int cost,x,y,l,r,o;
	NODE(int C,int a,int b,int c,int d,int e){cost = C,x=a,y=b,l=c,r=d,o=e;}
};
bool operator<(const NODE& a,const NODE& b){
	return a.cost > b.cost;
}

// «ÝpÏO,CÆA_fîñ,}XÌf[^,_f§À(=m)ðwè·éÆAY¦Ég¤_fÆÁZ·éRXgð»ê¼êãüµÄ­êéB
int get(int &O,int &C,int s,int d,int lim){
	if(d<0){
		O = s;
		C = -d;
	}else{
		O = min(lim,s + d);
		C = 0;
	}
}

int solve(int W,int H,int m,int o,vector<vector<int> >data){
	if(o<2)return INF;
	int O,C;
	bool done[10][10][10][10][51] = {0}; // [x][y][l][r][o]
	priority_queue<NODE> Q;
	rep(i,W){
		get(O,C,o-1,data[0][i],m);
		Q.push(NODE(C,i,0,i,i,O));
	}
	while(Q.size()){
		NODE q = Q.top(); Q.pop();
		if(q.o == 0) continue;
		if(q.y == H-1) return q.cost;
		
		if(done[q.x][q.y][q.l][q.r][q.o])continue;
		else done[q.x][q.y][q.l][q.r][q.o] = true;
		
		// cè_fª1ÈçÎÚ®Å«È¢ÌÅcontinue
		if(q.o == 1) continue;
		
		//¡Ú®
		static const int dx[] = {-1,1};
		rep(i,2){
			int tx = q.x+dx[i];
			int l = min(q.l,tx) , r = max(q.r,tx);
			if(tx < 0 || tx >= W) continue;
			
			if(l == q.l && r == q.r) C = 0 , O = q.o-1 ;
			else get(O,C,q.o-1,data[q.y][tx],m);
			
			Q.push(NODE(q.cost+C,tx,q.y,l,r,O));
		}
		
		//cÚ®
		if(q.y < H-1){
			get(O,C,q.o-1,data[q.y+1][q.x],m);
			Q.push(NODE(q.cost+C,q.x,q.y+1,q.x,q.x,O));
		}
	}
	return INF;
}
int main(){
	int W,H,f,m,o;
	while(cin >> W >> H , W){
		cin >> f >> m >> o;
		vector< vector<int> > data(H,vector<int>(W));
		rep(i,H)rep(j,W)cin >> data[i][j];
		int ans = solve(W,H,m,o,data);
		if(ans <= f) cout << ans << endl;
		else cout << "NA" << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

string s;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> s;
  int l = 0, r = s.size()-1;
  REP(i,s.size()) {
    if (s[i] == 'A') {
      l = i;
      break;
    }
  }
  for (int i = s.size()-1; i >= 0; i--) {
    if (s[i] == 'Z') {
      r = i;
      break;
    }
  }
  cout << r-l+1 << endl;

  return 0;
}

Measured memory_bytes: 720
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VB> VVB;

// conversion
#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<decltype((c).front())>())
#define SZ(x) (INT((x).size()))
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// constant
// const ll MOD = 1e9 + 7;
// const int INF = 1e9;
// const ll INF = 1e15;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;

#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


// --------------------------------------------------------


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

  int N, M;
  cin >> N >> M;
  VI num(N + 1, 0);
  REP(i, M) {
    int a, b;
    cin >> a >> b;
    num[a]++;
    num[b]++;
  }

  NREP(i, N) {
    cout << num[i] << endl;
  }
  return 0;
}

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

char wall = '#';
//=============dfs============================
tuple<ll, ll, ll> dfs(vector<vector<char>> maze, pair<ll, ll> start)
{
  tuple<ll, ll, ll> res;
  queue<tuple<ll, ll, ll>> q;
  ll M = -1;
  vector<vector<ll>> already_went(maze.size(), vector<ll>(maze.at(0).size(), 0));
  tuple<ll, ll, ll> temp;
  get<0>(temp) = start.first;get<1>(temp) = start.second;get<2>(temp) = 0;
  q.push(temp);
  while (!q.empty())
  {
    tuple<ll, ll, ll> check = q.front();
    q.pop();
    if (already_went.at(get<0>(check)).at(get<1>(check)) == 1)
    {
      continue;
    }
    already_went.at(get<0>(check)).at(get<1>(check)) = 1;
    if (get<2>(check) > M)
    {
      M = get<2>(check);
      res = make_tuple(get<0>(check), get<1>(check), M);
    }
    if (maze.at(get<0>(check) + 1).at(get<1>(check)) != wall)
    {
      get<0>(temp) = get<0>(check) + 1;get<1>(temp) = get<1>(check);get<2>(temp) = get<2>(check) + 1;
      q.push(temp);
    }
    if (maze.at(get<0>(check)).at(get<1>(check) + 1) != wall)
    {
      get<0>(temp) = get<0>(check);get<1>(temp) = get<1>(check) + 1;get<2>(temp) = get<2>(check) + 1;
      q.push(temp);
    }
    if (maze.at(get<0>(check) - 1).at(get<1>(check)) != wall)
    {
      get<0>(temp) = get<0>(check) - 1;get<1>(temp) = get<1>(check);get<2>(temp) = get<2>(check) + 1;
      q.push(temp);
    }
    if (maze.at(get<0>(check)).at(get<1>(check) - 1) != wall)
    {
      get<0>(temp) = get<0>(check);get<1>(temp) = get<1>(check) - 1;get<2>(temp) = get<2>(check) + 1;
      q.push(temp);
    }
  }
  return res;
}
//=================================================


int main()
{
  ll H, W;
  cin >> H >> W;
  vector<vector<char>> maze(H + 2, vector<char>(W + 2, '#'));
  vector<pair<ll, ll>> start;
  ll ans = 0;
  for (ll i = 1; i < H + 1; ++i)
  {
    for (ll j = 1; j < W + 1; ++j)
    {
      cin >> maze.at(i).at(j);
      if (maze.at(i).at(j) == '.')
      {
        start.push_back({i, j});
      }
    }
  }
  for (ll i = 0; i < start.size(); ++i)
  {
    ans = max(ans, get<2>(dfs(maze, start.at(i))));
  }
  cout << ans << endl;

  // for (ll i = 0; i < H + 2; ++i)
  // {
  //   for (ll j = 0; j < W + 2; ++j)
  //   {
  //     cout << maze.at(i).at(j);
  //   }
  //   cout << endl;
  // }
  // vector<pair<ll, ll>> before = {start, {-1, -1}};
  // queue<vector<pair<ll, ll>>> q;
  //
  // while (true)
  // {
  //   vector<tuple<ll, ll, ll>> next = dfs(maze, before.at(0));
  //   if (next.size() == 1 && (get<0>(next.at(0)) == before.at(1).first) && (get<1>(next.at(0)) == before.at(1).second))
  //   {
  //     cout << get<2>(next.at(0)) << endl;
  //     break;
  //   }
  //   before.at(1) = before.at(0);
  //   before.at(0) = {get<0>(next), get<1>(next)};
  // }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  int D;
  cin >> D;
  vector<int> c(26);
  REP(i, 26) cin >> c[i];
  vector<vector<int>> s(D, vector<int>(26));
  REP(i, D) { REP(j, 26) cin >> s[i][j]; }
  ll score = 0;
  vector<pair<ll, int>> ans(0);
  unordered_map<int, int> lastday{};
  /*REP(i, D) {
    vector<pair<ll, int>> tmp(26);
    REP(j, 26) {
      //貪欲に選ぶ
      tmp[j].first = score + s[i][j];
      tmp[j].second = j;
      REP(k, 26) {
        if (j == k) continue;
        tmp[j].first -= c[k] * (i + 1 - lastday[k]);
      }
    }
    sort(tmp.begin(), tmp.end());
    ans.push_back(tmp[25]);
  }
  REP(i, D) { cout << ans[i].first << " " << ans[i].second + 1 << endl; }*/
  int a = 1;
  REP(i, D) {
    cout << a << endl;
    a %= 26;
    a += 1;
  }
}


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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int n, m;
	cin >> n >> m;
	vector<P> lr(m);
	rep(i, m)
		cin >> lr[i].first >> lr[i].second;

	int lmax = 0;
	int rmin = INF;
	rep(i, m){
		lmax = max(lmax, lr[i].first);
		rmin = min(rmin, lr[i].second);
	}
	int ans = rmin - lmax + 1;
	ans = min(n, max(ans, 0));

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
string S;
  cin >> S;
  int N, ans;
  N = S.size();
    ans = 0;
for(int i = 0; i < N; i++){
  if (S[i] != S[N-1-i]) ans++;
}
  cout << ans/2 << endl;
}


Measured memory_bytes: 256
s = input()
t = "AKIHABARA"
idx = 0
ng = 0
for i in range(len(t)):
    if t[i] == s[idx]:
        idx += 1
    elif t[i] != "A":
        ng = 1
        break
    if idx == len(s):
        if i < len(t) - 2:
            ng = 1

        break

if idx != len(s):
    ng = 1

if ng:
    print("NO")
else:
    print("YES")


Measured memory_bytes: 9124
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#include<functional>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define INF 200000000

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

#define VMAX 100

vector<int> G[VMAX + VMAX];
bool checked[VMAX + VMAX];
int mate[VMAX + VMAX];

bool augment(int x)
{
	if (checked[x])
	{
		return false;
	}
	checked[x] = true;
	for (auto y : G[x])
	{
		if (mate[y] == -1 || augment(mate[y]))
		{
			mate[x] = y;
			mate[y] = x;
			return true;
		}
	}
	return false;
}

int max_matching(int X)
{
	int match = 0;
	fill(mate, mate + VMAX + VMAX, -1);
	for (int i = 0; i < X; i++)
	{
		fill(checked, checked + VMAX + VMAX, false);
		if (augment(i))
		{
			match++;
		}
	}
	return match;
}

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

	int X,Y,E;
	cin >> X >> Y >> E;

	for (int i = 0; i < E; i++)
	{
		int x, y;
		cin >> x >> y;

		G[x].push_back(X + y);
		G[X + y].push_back(x);
	}

	cout << max_matching(X) << endl;

	return 0;
}


Measured memory_bytes: 3236
n = gets.to_i
a = gets.chomp.split(" ").map(&:to_i)

count = 0

for i in 1..a.length-2 do
tmp = [a[i-1], a[i], a[i+1]]
if tmp.sort[1] == a[i]
count += 1
end
end
print(count)

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
#define int long long int

signed main(){
    string s;
    cin >> s;
    int r=0;
    if(s[0]=='o')r++;
    if(s[1]=='o')r++;
    if(s[2]=='o')r++;
    cout << 700 + 100*r << endl;
}

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

int main(){
    /*---------*/
    /*  input  */
    /*---------*/
    long long int N, M, K;
    cin >> N >> M >> K;

    vector<long long int> A(N+1);
    vector<long long int> B(M+1);
    int i,j;
    int in;
    for( i = 1; i <= N; i++ ){
        cin >> in;
        A[i] = A[i-1] + in;
    }
    for( i = 1; i <= M; i++ ){
        cin >> in;
        B[i] = B[i-1] + in;
    }

    /*--------*/
    /*  calc  */
    /*--------*/
    int ans = 0;
    j = M;
    for( i = 0; i <= N; i++ ){
        if( A[i] > K ) break;
        while( A[i] + B[j] > K ){
            //cout << i << " " << j << endl;
            j--;
        }
        //cout << "max" << ans << " " << i+j << endl;
        ans = max( ans, i+j );
    }

    cout << ans << endl;

}


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

int main(){
	int n;	cin >> n;
  	map<string,int>	dc;
  	int mx = 0;
	vector<string> st(n), st2;
  	
  	for(int i = 0; i < n; i++){
    	cin >> st.at(i);
      	if(dc.find(st.at(i)) == dc.end()){
        	dc[st.at(i)] = 1;
        }
      	else dc[st.at(i)]++;
		
      	if(dc[st.at(i)] > mx)	mx = dc[st.at(i)];
    }
  	
  	
  	for(auto p : dc) {
    	if(p.second == mx) {
      	st2.push_back(p.first);
    	}
  	}
  	
  	
  	sort(st2.begin(),st2.end());
  	
  	for(int i = 0; i < st2.size(); i++){
    	cout << st2.at(i) << endl;
    }
  	
//  	cout << st2.size() <<endl;
  	
}   

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if(A + B > C + D ){
  cout << "Left" << endl;
  }else if(A + B < C + D){
  cout << "Right" << endl;
  }else{
  cout << "Balanced" << endl;
  }
}

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

int a,b,c,d,e,k;
cin >>a >>b >>c >>d >>e >>k;

if((b-a)<=k && (c-a)<=k && (d-a)<=k && (e-a)<=k && (c-b)<=k
&& (d-b)<=k && (e-b)<=k && (d-c)<=k && (e-c)<=k && (e-d)<=k){
  cout << "Yay!" << endl;
}else{
  cout << ":(" ;
}
}


Measured memory_bytes: 256
K, N = map(int, input().split())
A = input().split()
for i in range(0, len(A)):
    A[i] = int(A[i])

dist = []
for i in range(0, len(A)-1):
    dist.append(A[i+1]-A[i])
dist.append((K - A[len(A)-1]) + A[0])

print(K - max(dist))


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

vector<int> edge[10005];
int n;
vector<int>ans;
vector<int> c;
 
int main(void){ 
    cin>>n;
    rep(i, n-1){
        int a, b;
        cin>>a>>b;
        --a;--b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    c.resize(n);
    ans.resize(n);
    rep(i, n) cin>>c[i];
    sort(c.begin(), c.end(), greater<int>());
    priority_queue<int> que;
    que.push(0);
    rep(i, n) ans[i] = -1;
    int idx = 0;
    ans[0] = c[0];
    while(!que.empty()){
        int u = que.top();que.pop();
        //cout<<u<<" "<<idx<<endl;
        for(auto v : edge[u]){
            if(ans[v] != -1) continue;
            idx++;
            ans[v] = c[idx];
            que.push(v);
        }
    }
    int res = accumulate(c.begin(), c.end(), 0);
    res -= c[0];
    cout<<res<<endl;
    rep(i, n) cout<<ans[i]<<" ";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    Scanner sc = new Scanner(System.in);

    void solve() {
        // Input
        int n = sc.nextInt();
        int[] R = new int[n];
        for (int i = 0; i < n; i++) {
            R[i] = sc.nextInt();
        }

        // Solve
        int[] max = new int[n - 1];
        max[n - 2] = R[n - 2 + 1];
        for (int i = n - 3; i >= 0; i--) {
            max[i] = Math.max(max[i + 1], R[i + 1]);
        }
        int maximum = Integer.MIN_VALUE;
        for (int i = 0; i < n - 1; i++) {
            maximum = Math.max(maximum, max[i] - R[i]);
        }

        // Output
        System.out.println(maximum);

    }

    public static void main(String[] args) {
        new Main().solve();
    }
}



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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair

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

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;

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

  vl x(n);
  rep(i, n) cin >> x[i];

  ll ans = 0;
  rep(i, n-1){
    if((x[i+1]-x[i])*a < b){
      ans += (x[i+1]-x[i])*a;
    }else{
      ans += b;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
"""
    こんにちは。これはクシャルです
    
    Author : thekushalghosh (クシャル)
    Team   : CodeDiggers
 
    I prefer Python language over the C++ language :p :D
        
    Visit my website : thekushalghosh.github.io
"""
import sys,math,cmath,time
start_time = time.time()
##########################################################################
################# ---- THE ACTUAL CODE STARTS BELOW ---- #################
    
def solve():
    n = inp()
    if n >= 30:
        print("Yes")
    else:
        print("No")
    
################## ---- THE ACTUAL CODE ENDS ABOVE ---- ##################
##########################################################################
 
def main():
    global tt
    if not ONLINE_JUDGE:
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")
    t = 1
    for tt in range(t):
        solve()
    if not ONLINE_JUDGE:
        print("Time Elapsed :",time.time() - start_time,"seconds")
        sys.stdout.close()
    
#---------------------- USER DEFINED INPUT FUNCTIONS ----------------------#
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    return(input().strip())
def invr():
    return(map(int,input().split()))
 
#------------------ USER DEFINED PROGRAMMING FUNCTIONS ------------------#
def counter(a):
    q = [0] * max(a)
    for i in range(len(a)):
        q[a[i] - 1] = q[a[i] - 1] + 1
    return(q)

def counter_elements(a):
    q = dict()
    for i in range(len(a)):
        if a[i] not in q:
            q[a[i]] = 0
        q[a[i]] = q[a[i]] + 1
    return(q)

def string_counter(a):
    q = [0] * 26
    for i in range(len(a)):
        q[ord(a[i]) - 97] = q[ord(a[i]) - 97],1
    return(q)
 
def factors(n):
    q = []
    for i in range(1,int(n ** 0.5) + 1):
        if n % i == 0: q.append(i); q.append(n // i)
    return(list(sorted(list(set(q)))))
 
def prime_factors(n):
    q = []
    while n % 2 == 0: q.append(2); n = n // 2
    for i in range(3,int(n ** 0.5) + 1,2):
        while n % i == 0: q.append(i); n = n // i
    if n > 2: q.append(n)
    return(list(sorted(q)))

def transpose(a):
    n,m = len(a),len(a[0])
    b = [[0] * n for i in range(m)]
    for i in range(m): 
        for j in range(n): 
            b[i][j] = a[j][i]
    return(b)

#-----------------------------------------------------------------------#
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
    input = sys.stdin.readline
main()

Measured memory_bytes: 62812
#include <stdio.h>
typedef long long ll;

int main(void) {
    ll H, N;
    scanf("%lld%lld", &H, &N);

    ll ASum = 0;
    for(ll i = 0; i < N; ++i) {
        ll tmp;
        scanf("%lld", &tmp);
        ASum += tmp;
    }
    
    if(ASum >= H) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 1636