akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
using namespace std;

typedef long long llint;

int d, g;
int p[10], c[10];

int ans = 114514;

int main() {
    cin >> d >> g;
    for (int i = 0; i < d; i++) {
        cin >> p[i] >> c[i];
    }

    int order[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
    do {
        int point = 0;
        int cnt = 0;
        for (int i = 0; i < d; i++) {
            int j = order[i];
            if (g - point <= 100 * (j + 1) * p[j]) {
                cnt += (g - point) / (100 * (j + 1));
                if ((g - point) % (100 * (j + 1)))
                    cnt += 1;
                break;
            } else if (g - point <= 100 * (j + 1) * p[j] + c[j]) {
                cnt += p[j];
                break;
            } else {
                point += 100 * (j + 1) * p[j] + c[j];
                cnt += p[j];
            }
        }
        ans = min(ans, cnt);
    } while (next_permutation(order, order + d));
    
    cout << ans << endl;

    return 0;
}

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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1)/b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }

int nmax=200000; // 2*(10^5)
vvec g(nmax);



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    map<int,int> mp;
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    rep(i,n){
        mp[(-1)*a[i]]++;
    }
    int ans=0;
    for(auto x:mp){
        if(x.sc>=4&&ans==0){
            cout<<x.fs*x.fs<<endl;
            return 0;
        }
        if(x.sc>=2){
            if(ans==0) ans=x.fs;
            else{
                ans*=x.fs;
                cout<<ans<<endl;
                return 0;
            }
        }
    }
    cout<<0<<endl;
}


Measured memory_bytes: 12032
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())

	var ret float64
	for i := 0; i < n; i++ {
		scanner.Scan()
		buff := scanner.Text()
		strs := strings.Split(buff, " ")
		x, _ := strconv.ParseFloat(strs[0], 64)
		u := strs[1]

		if u == "JPY" {
			ret += x
		} else {
			ret += (380000 * x)
		}
	}
	fmt.Println(ret)
}


Measured memory_bytes: 640
#include<iostream>
#include<set>

using namespace std;

int N;
int main(){
    cin >> N;
    int a;
    set<int > S;
    set<int >::iterator iter;
    for(int i=0; i<N; i++){
        cin >> a;
        iter = S.find(a);
        if(iter==S.end()){
            S.insert(a);
        }else{
            S.erase(a);
        }
    }
    cout << S.size() << endl;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
//#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////

ll cal(string s){
    ll res=0;
    ll n=s.size();
    rep(i,0,n-1){
        res+=(1<<i)*(s[n-1-i]-'0');
    }
    return res;
}

void solve(string s){
    ll n=cal(s);
    ll cnt=0;
    rep(a,0,n){
        rep(b,0,n){
            if(a+b<=n&&(a^b)==(a+b)){
                cout<<a<<" "<<b<<endl;
            }
        }
    }
    cout<<cnt<<endl;
}


int main(){fastio
    
    
    string s;cin>>s;
    //solve(s);
    ll n=s.size();
    ll dp[n][2];memset(dp,0,sizeof(dp));
    dp[0][0]=1;dp[0][1]=2;
    rep(i,1,n-1){
        if(s[i]=='0'){
            Add(dp[i][0],dp[i-1][0]*3);
            Add(dp[i][1],dp[i-1][1]*1);
        }else{
            Add(dp[i][0],dp[i-1][0]*3);
            Add(dp[i][0],dp[i-1][1]);
            Add(dp[i][1],dp[i-1][1]*2);
        }
    }
    /*
    rep(i,0,n-1){
        rep(j,0,1)cout<<dp[i][j]<<" ";cout<<endl;
    }*/
    ll ans=mod(dp[n-1][0]+dp[n-1][1]);
    cout<<ans<<endl;
    
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

const int MAXN = 1e6 + 10;
const int MM = 1e9 + 7;

int n, m;
char s[MAXN], t[MAXN];
int a[555][555];

struct Pt{
    int q, w, e, r;
} f[MAXN];

int main(){
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            scanf("%d", &a[i][j]);
    int ans = 0;
    for (int i = 1; i < n; i++){
        for (int j = 1; j <= m; j++){
            if (a[i][j] & 1){
                ans++;
                f[ans] = (Pt){i, j, i + 1, j};
                a[i][j]--;
                a[i+1][j]++;
            }
        }
    }
    for (int j = 1; j < m; j++){
        if (a[n][j] & 1){
            ans++;
            f[ans] = (Pt){n, j, n, j + 1};
            a[n][j + 1]++;
        }
    }
    printf("%d\n", ans);
    for (int i = 1; i <= ans; i++){
        printf("%d %d %d %d\n", f[i].q, f[i].w, f[i].e, f[i].r);
    }
    return 0;
}


Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
const int N = 998244353;
#define ll long long
int main(){
    ios::sync_with_stdio(false);
    cin.tie();
    int n, k;
    cin>>n>>k;
    set<int> s;
    ll dp[n+1];
    vector<pair<int, int> > vp;
    for(int i = 0; i < k; i++){ 
        int l, r;
        cin>>l>>r;
        vp.push_back(make_pair(l, r));
    }
    sort(vp.begin(), vp.end());
    dp[1] = 1;
    dp[0] = 0;
    ll predp[n+1];
    predp[0] = 0;
    predp[1] = 1;
    for(int i = 2; i <= n; i++){
        // cout<<"i = "<<i<<endl;
        ll ans = 0;
        for(int j = 0; j < k; j++){
            int start = vp[j].first;
            int end = vp[j].second;
            int s = i - end, e = i - start;
            // cout<<"s = "<<s<<" e = "<<e<<" ";
            if(e <= 0)
            break;
            if(s <= 0){
                ans+=predp[e];
                // cout<<"predp[e] = "<<predp[e]<<" ans = "<<ans<<" ";
                ans %= N;
                break;
            }
            ans += (predp[e] - predp[s] + N + dp[s]);
            // cout<<"predp[e] = "<<predp[e]<<" predp[s] = "<<predp[s]<<" ans = "<<ans<<" ";
            ans %=N;
        }
        // cout<<"\ni = "<<i<<" ans = "<<ans<<endl;
        dp[i] = ans;
        predp[i] = predp[i-1]+dp[i];
        predp[i] %= N;
    }
    cout<<dp[n];
    return 0;
}

Measured memory_bytes: 6680
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

template <class T>
inline bool chmax(T& a, T b) {
    return a = (a < b) ? b : a;
}
template <class T>
inline bool chmin(T& a, T b) {
    return a = (a > b) ? b : a;
}

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
    INIT;

    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    ll now = 1000;
    ll st = 0;
    rep(i, N - 1) {
        if (A[i] < A[i + 1]) {
            st = now / A[i];
            now = now - st * A[i];
            now = now + st * A[i + 1];
            st = 0;
        }
        // cout << now << endl;
    }

    cout << now << endl;

    return 0;
}

Measured memory_bytes: 3656
from fractions import gcd
from functools import reduce

N, X = map(int, input().split())
x = list(map(int, input().split()))

x.append(X)
x.sort()
diffs = set()
for i in range(N):
    diffs.add(x[i + 1] - x[i])
if len(diffs) == 1:
    ans = diffs.pop()
else:
    ans = reduce(gcd, diffs)
print(ans)


Measured memory_bytes: 16272
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  
  ll N,K;
  cin>>N>>K;
  
  vector<ll>V(N);
  rep(i,N){
    cin>>V[i];
  }
ll big=0;
  for(ll i=0;i<=min(N,K);i++){
   for(ll j=0;j<=min(N,K)-i;j++){
     vector<ll>date(N);
     ll ans=0;
     ll R=0;
     ll L=0;
     rep(l,i){
       R+=V[l];
       date.push_back(V[l]);
     }
     for(ll l=N-1;l>=N-j;l--){
       L+=V[l];
       date.push_back(V[l]);
     }
     sort(all(date));
     ans=R+L;
     
     rep(l,K-i-j){
       if(date[l]<0){
   ans-=date[l];
       }
 }

     big=max(big,ans);
   }
  }

  cout<<big<<endl;
}


Measured memory_bytes: 256
s = input()		# 文字列の入力  abcdefg...


if s=='SUN': ans=7
if s=='MON': ans=6
if s=='TUE': ans=5
if s=='WED': ans=4
if s=='THU': ans=3
if s=='FRI': ans=2
if s=='SAT': ans=1

print(ans)
 

Measured memory_bytes: 2940
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 200005;
const int mod = 1000000007;

int n;
int a[maxn];
ll f[maxn][2][5];

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  cin>>n;
  for(int i=1;i<=n;i++)cin>>a[i];
  for(int i=0;i<maxn;i++)
    for(int j=0;j<2;j++)
      for(int k=0;k<5;k++)f[i][j][k] = -(1LL<<60);
  f[0][0][1] = 0;
  for(int i=0;i<n;i++)
    for(int j=0;j<2;j++)
      for(int k=0;k<5;k++){
        if(f[i][j][k]==-(1LL<<60))continue;
        if(j){
          if(k+1<5&&f[i+1][0][k+1]<f[i][j][k]){
            f[i+1][0][k+1] = f[i][j][k];
          }
          continue;
        }
        if(k+1<5&&f[i+1][0][k+1]<f[i][j][k]){
          f[i+1][0][k+1] = f[i][j][k];
        }
        if(k-1>=0&&f[i+1][1][k-1]<f[i][j][k]+a[i+1]){
          f[i+1][1][k-1]=f[i][j][k]+a[i+1];
        }
      }
  int tt = n/2;
  int df = (n-tt)-tt;
  cout<<max(f[n][0][df+1], f[n][1][df+1])<<endl;
  return 0;
}

Measured memory_bytes: 20040
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, d=DVSR): return pow(x, d - 2, d)
def DIV(x, y, d=DVSR): return (x * INV(y, d)) % d
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())

A,B=LI()
if A == B:
    print(0)
else:
    if (A+B)%2:
        print("IMPOSSIBLE")
    else:
        print((A+B)//2)



Measured memory_bytes: 3064
import static java.util.Arrays.deepToString;

import java.util.Arrays;
import java.util.Scanner;

import javax.swing.plaf.basic.BasicComboBoxUI.ComboBoxLayoutManager;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	Scanner sc = new Scanner(System.in);
	public void run() {
		for (;sc.hasNext();) {
			P ps[][] = new P[3][8];
			for (int k = 0; k < 3; k++)
			for (int i = 0; i < 8; i++) 
			{
				P p = new P();
				p.id = sc.nextInt();
				p.score = sc.nextDouble();
				ps[k][i] = p;
			}

			P[] rs = new P[6 * 3];
			int rss = 0;
			for (int k = 0; k < 3; k++) {
				Arrays.sort(ps[k]);
				for (int i = 0; i < 2; i++) {
					System.out.printf("%d %.2f\n", ps[k][i].id, ps[k][i].score);
				}
				for (int i = 2; i < 8; i++) {
					rs[rss++] = ps[k][i];
				}
			}
			Arrays.sort(rs);
			for (int i = 0; i < 2; i++) {
				System.out.printf("%d %.2f\n", rs[i].id, rs[i].score);
			}
		}
	}
	
	class P implements Comparable<P> {
		int id;
		double score;
		@Override
		public int compareTo(P o) {
			return Double.compare(score, o.score);
		}
	}
}

Measured memory_bytes: 20336
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
int main() {
    int m1, d1, m2, d2;
	cin >> m1 >> d1 >> m2 >> d2;
    if(m2 != m1)
        cout << 1;
    else
    {
        cout << 0;
    }
    
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int cnt[100005];

int main() {
  int n;
  scanf("%d",&n);
  int maxn=0;
  for(int i=1;i<=n;i++) {
    int x;
	scanf("%d",&x);
	cnt[x]++;
	maxn=max(maxn,x);  	
  }
  int s=0;
  for(int i=1;i<=n;i++) s+=(cnt[i]>0);
  if (s==2&&cnt[maxn-1]>0) {
  	int p=maxn-cnt[maxn-1];
  	if (p>0&&p<=(cnt[maxn]>>1)) {
  		puts("Yes");
  		return 0;
	  }
  }
  else if (s==1) {
  	if (maxn==n-1||maxn<=(n>>1)) {
  		puts("Yes");
  		return 0;
	  }
  }
  puts("No");
  return 0;
}

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

int main(){
    int k;
    cin>>k;
    if(k%2==0){
        k/=2;
        cout<<k*k<<endl;
    }else{
        k=(k-1)/2;
        cout<<k*(k+1)<<endl;
    }
}


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

using namespace std;

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

    int n, cur = 0, max_v = 0;
    string s;

    cin >> n >> s;
    for (auto c : s) {
        if (c == 'I')
            ++cur;
        else
            --cur;

        max_v = max(max_v, cur);
    }

    cout << max_v << endl;


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 100000000000000009
#define MOD 1000000007
#define int long long
using P = pair<int,int>;

vector<P> prime_factorize(int a){
  vector<P> ans;
  for(int i = 2;i*i <= a;i++){
    int num = 0;
    if(a % i == 0){
      while(a % i == 0){
        num++;
        a /= i;
      }
      ans.push_back(make_pair(i,num));
    }
  }
  if(a != 1) ans.push_back(make_pair(a,1));
  return ans;
}
signed main(){
  int n;
  cin >> n;
  int ans = 0;
  for(int i = 2;i <= sqrt(n);i++){
    if(n % i != 0 && (n-1) % i == 0){
      if((n-1)/i==i)ans++;
      else ans+=2;
    }
    else{
      int temp = n;
      while(temp % i == 0){
        temp /= i;
      }
      if(temp == 1)ans++;
      else if((temp - 1) % i == 0)ans++;
    }
  }
  if(n == 2) ans--;
  cout << ans + 2 << endl;
}

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


typedef pair<ll,ll> pll;


ll n, k;
vector< ll > g[100005];
const ll mod = 1e9 + 7;
ll fac[100005], ifac[100005];
ll ans;
ll ME(ll x,ll nn,ll M)
{
    ll result=1;
    while(nn>0)
    {
        if(nn % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        nn=nn/2;
    }
    return result;
}
ll inv(ll x)
{
        return ME(x,mod-2,mod);
}
ll C(ll a, ll b)
{
        if(a == 0) return 1LL;
        if(b > a) return 0;
        ll ret = (fac[a] * ifac[a-b])%mod;
        //cout << a << " --- " << b << " " << ret << endl;
        return ret;
}
void dfs(ll s, ll pr, ll lvl)
{
        ll cc = g[s].size()-1;
        if(s == 1) cc++;
        if(lvl == 0){
                ans = (k * C(k-1, cc))%mod;
                //ans = (ans * (fac[cc]))%mod;
        }else {
                ans = (ans * C(k-2, cc))%mod;
                //ans = (ans * (fac[cc]))%mod;
        }
        //cout << s << " " << ans << endl;
        for(auto &i : g[s]) {
                if(i == pr) continue;
                dfs(i,s,lvl+1);
        }
}
int main()
{
        cin >> n >> k;
        for(ll i=1;i<n;i++){
                ll u,v;
                cin >> u>>v;
                g[u].pb(v);
                g[v].pb(u);
        }
        fac[0] = 1LL;
        ifac[0] = 1LL;
        for(ll i=1;i<=k;i++) {
                fac[i] = (fac[i-1] * i)%mod;
                ifac[i] = (inv(fac[i]))%mod;
        }
        ans = 1LL;
        dfs(1, -1, 0);
        cout<< ans << endl;
        return 0;
}


Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9+7;
//Int mod = 998244353;
Int INF = 1e18;
double EPS = 0.00000001;

Int dp[1 << 16];

Int n, m;
Int a[1005];
Int b[1005];
Int c[1005][20];

string f(Int x) {
    string ret = "";
    for (Int i = 0; i < n; i++) {
        ret += '0';
    }
    for (Int i = n - 1; i >= 0; i--) {
        if (x % 2 == 0) {
            ret[i] = '0';
        }
        else {
            ret[i] = '1';
        }
        x /= 2;
    }
    return ret;
}

void dfs(Int s) {
    //dump(f(s));
    if (s == (1<<n) - 1) return;
    for (Int i = 0; i < m; i++) {
        Int next = s;
        for (Int j = 0; j < b[i]; j++) {
            next |= (1<<(c[i][j] - 1));
        }
        if (dp[next] > dp[s] + a[i]) {
            dp[next] = dp[s] + a[i];
            dfs(next);
        }
    }
}

int main() {
    cin >> n >> m;
    for (Int i = 0; i < m; i++) {
        cin >> a[i] >> b[i];
        for (Int j = 0; j < b[i]; j++) {
            cin >> c[i][j];
        }
    }
    for (Int bit = 0; bit < (1<<n); bit++) {
        dp[bit] = INF;
    }
    dp[0] = 0;
    dfs(0);
    dump(dp[(1<<n) - 1] == INF ? -1 : dp[(1<<n) - 1]);
    return 0;
}


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

#define pii pair<int, int>
#define endl "\n"
#define int long long
#define F first
#define S second
#define B begin
#define E end
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
const int INF = 1e9 + 1;
const double EPS = 1e-10;
const ll P = 1e9 + 7;
const ll Q = 31;
 
using namespace std;
 
void hello()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}
 
void show(vector<int>& arr)
{
    for (auto i : arr)
        cout << i << " ";
    cout << endl;
}
void show(vector<vector<int>>& arr)
{
    for (auto i : arr)
        show(i);
    cout << endl;
}

 
signed main()
{
    hello();

    int a, b, c;
    cin >> a >> b >> c;
    int res = a + b + c;
    if (res >= 22)
        cout << "bust" << endl;
    else
        cout << "win" << endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>
 
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
 
using namespace std;
 
typedef long long ll;

int main(int argc, char const *argv[])
{
  int a[5];
  int min_val = 10;
  int res = 0;
  REP(i,5){
    cin >> a[i];
    if (a[i]%10 != 0) {
      min_val = min(min_val,a[i]%10);
      res+= (10+a[i]-a[i]%10);
    }
    else {
      res+=a[i];
    }
  }
  if (min_val!=10) res -= 10-min_val;
  cout << res << endl;

  return 0;
}


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


public class hello
{
    public static void Main()
    {
        string line;
        for (; (line = Console.ReadLine()) != null;)
        {
            var station = new int[10];
            string[] s = line.Trim().Split(',');
            var v1 = decimal.Parse(s[10]);
            var v10 = decimal.Parse(s[11]);
            for (int i = 0; i < 10; i++) station[i] = int.Parse(s[i]);
            var sum = (decimal)station.Sum();
            var cross = (decimal)v1 * sum / (v1 + v10);
            var stotal = 0m;
            for (int j = 0; j < 10; j++)
            {
                stotal += station[j];
                if (stotal >= cross)
                {
                    Console.WriteLine(j + 1);
                    break;
                }
            }
        }
    }
}

Measured memory_bytes: 9496
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	
	
		ll n,i,j,k,u,vv,a,b=0;
		cin>>n;
		vector<ll> v;
		for(i=0;i<n;i++)
		{
			cin>>a;
			v.push_back(a);
			b=b+v[i];
		}
		u=b/n;
		vv=u+1;
		ll s=0,ss=0;
		for(i=0;i<n;i++)
		{
			s=s+(v[i]-u)*(v[i]-u);
			ss=ss+(v[i]-vv)*(v[i]-vv);
		}
		cout<<min(s,ss)<<endl;
		
	
}

Measured memory_bytes: 256
def read():
    S = str(input().strip())
    K = int(input().strip())
    return S, K

def rle_encode(S):
    S1 = S + '@'
    rle = list()
    head = 0
    for i in range(0, len(S1)):
        if S1[i] != S1[head]:
            rle.append((S1[head], i-head))
            head = i
    return rle

def solve(S, K):
    count = 0
    rle = rle_encode(S)
    if len(rle) == 1:
        return rle[0][1] * K // 2
    else:
        for c, n in rle:
            count += n // 2
        count *= K
        if rle[-1][0] == rle[0][0]:
            if rle[-1][1] % 2 == 1 and rle[0][1] % 2 == 1:
                count += (K-1)
    return count

if __name__ == '__main__':
    inputs = read()
    print("%d" % solve(*inputs))


Measured memory_bytes: 38500
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define mp make_pair
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

const int N=200000+10;

int n,k,l;
struct DSU {
	int f[N];
	int find(int x) { return x==f[x]?x:f[x]=find(f[x]); }
	void merge(int x,int y) {
		x=find(x),y=find(y);
		if (x!=y) f[x]=y;
	}
} A,B;
map<pair<int,int>,int> M;

int main() {
	n=read(),k=read(),l=read();
	for (int i=1;i<=n;++i) A.f[i]=B.f[i]=i;
	for (int i=1;i<=k;++i) A.merge(read(),read());
	for (int i=1;i<=l;++i) B.merge(read(),read());
	for (int i=1;i<=n;++i) ++M[mp(A.find(i),B.find(i))];
	for (int i=1;i<=n;++i) printf("%d ",M[mp(A.find(i),B.find(i))]);
	return 0;
}

Measured memory_bytes: 16512
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'

const int N = 8;

vector<char> aux;
vector<vector<char> > v;
char g[N][N], f[N][N];

void build(int pos, int h, int w){

    if(pos == h+w+1){
        v.push_back(aux);
        return;
    }
    aux.push_back('0');
    build(pos+1, h, w);
    aux.pop_back();

    aux.push_back('1');
    build(pos+1, h, w);
    aux.pop_back();

    return;
}

int main(){

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

    int h, w, k; cin >>h >>w >>k;
    for(int i = 1; i<=h; i++){
        for(int j = 1; j<=w; j++){
            cin >>g[i][j];
        }
    }

    build(1, h, w);

    int ans = 0;
    for(int i = 0; i<v.size(); i++){

        for(int r = 1; r<=h; r++){
            for(int c = 1; c<=w; c++){
                f[r][c] = g[r][c];
            }
        }

        for(int r = 0; r<h; r++){
            if(v[i][r] == '1'){
                for(int x = 1; x<=w; x++){
                    f[r+1][x] = '*';
                }
            }
        }

        for(int c = h; c<h+w; c++){
            if(v[i][c] == '1'){
                for(int x = 1; x<=h; x++){
                    f[x][c-h+1] = '*';
                }
            }
        }

        int cnt = 0;
        for(int r = 1; r<=h; r++){
            for(int c = 1; c<=w; c++){
                cnt += (f[r][c] == '#');
            }
        }
        ans += (cnt == k);
    }

    cout <<ans <<endl;

    return 0;
}


Measured memory_bytes: 3824
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;

int64_t com(int64_t n, int64_t r) {
    if (r < 0 || r > n) return 0;
    if (r == 1) return n;
    else if (r == 2) return n * (n - 1) / 2;
    else return n * (n - 1) * (n - 2) / 6;
}

int64_t pow(int64_t n, int64_t k) {
    int64_t res = 1;
    rep(i, k) res *= n;
    return res;
}
string s;
int n, k;

int64_t rec(int i, int k, bool smaller) {
    if (i == n) {
        if (k == 0) return 1;
        else return 0;
    }
    if (k == 0) return 1;

    if (smaller) return com(n - i, k) * pow(9, k);
    else {
        if (s[i] == '0') return rec(i + 1, k, false);
        else {
            return rec(i + 1, k, true)
                + rec(i + 1, k - 1, true) * (s[i] - '1')
                + rec(i + 1, k - 1, false);
        }
    }
}
int main() {
    cin >> s;
    cin >> k;
    n = s.size();

    cout << rec(0, k, false) << endl;
}


Measured memory_bytes: 512
import java.lang.*;
import java.io.*;
import java.math.*;

public class Main{
    public static void main(String[] args)throws IOException{
	InputStreamReader isr = new InputStreamReader(System.in);
	BufferedReader br=new BufferedReader(isr);
	String str = br.readLine();
	String[] st = str.split(" ");
	int[] num = new int[5];
	for(int i=0;i<5;i++)
	    num[i]=Integer.parseInt(st[i]);
	for(int i=0;i<5;i++)
	    for(int j=0;j<4;j++)
		if(num[j]<num[j+1]){
		    int t=num[j];
		    num[j]=num[j+1];
		    num[j+1]=t;
		}
	for(int i=0;i<4;i++)
	    System.out.print(num[i]+" ");
	System.out.println(num[4]);
    }
}

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

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

    int flag = 0;
    string w[n];
    for(int i = 0; i < n; i++){
        cin >> w[i];
        if(i > 0 && w[i-1][w[i-1].length()-1] != w[i][0]) flag = 1;
    }

    sort(w,w+n);
    for(int i = 1; i < n; i++)
        if(w[i] == w[i-1]) flag = 1;
        
    if(flag == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;
const ll INF=1000000000;
string alp="abcdefghijklmnopqrstuvwxyz";


int main(){
    int N,Ma,Mb;
    cin >> N >> Ma >> Mb;
    vector<int> a(N),b(N),c(N);
    rep(i,N){
        cin >> a[i] >> b[i] >> c[i];
    }
    ll dp[N+1][10*N+1][10*N+1];
    rep(i,N+1){
        rep(j,10*N+1){
            rep(k,10*N+1){
                dp[i][j][k]=INF;
            }
        }
    }
    dp[0][0][0]=0;
    rep(i,N){
        rep(j,10*N+1){
            rep(k,10*N+1){
                dp[i+1][j][k]=dp[i][j][k];
                if (a[i]<=j&&b[i]<=k){
                    dp[i+1][j][k]=min(dp[i+1][j][k],dp[i][j-a[i]][k-b[i]]+c[i]);
                }
            }
        }
    }
    ll ans=INF;
    for (int i=1;Ma*i<=10*N&&Mb*i<=10*N;i++){
        ans=min(ans,dp[N][Ma*i][Mb*i]);
    }
    if (ans!=INF){
        cout << ans << endl;
    }
    else {
        cout << -1 << endl;
    }
}

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

#include <iostream>
using namespace std;
#define rep(i, n)                    \
  for (int i = 0; i < (int)(n); i++) \
    ;

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

int main() {
  int d, t, s;
  cin >> d >> t >> s;

  if ((d + s - 1) / s <= t) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<queue>
using namespace std;

typedef long long ll;

int main() {
  int c[3][3];
  int a[3],b[3];
  for ( int i = 0; i < 3; i++ ) {
    for ( int j = 0; j < 3; j++ ) {
      cin >> c[i][j];
    }
  }
  a[0] = 0;
  for ( int i = 0; i < 3; i++ ) b[i] = c[0][i] - a[0];
  for ( int i = 0; i < 3; i++ ) a[i] = c[i][0] - b[0];
  bool f = true;
  for ( int i = 0; i < 3; i++ ) {
    for ( int j = 0; j < 3; j++ ) {
      if ( a[i] + b[j] != c[i][j] ) f = false;
    }
  }

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


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

using namespace std;

typedef long long ll;
typedef long double ld;

const int M = 100100;
const ll inf = 1e12;

int r, c, n;
bool used[M];
ll s[M];
vector<int> g[M], t[M];
vector<pair<int, int>> h[M];
ll mn[M];
int col[M];
ll clm[M];
bool nice = true;

void read() {
  fill(mn, mn + M, inf);
  fill(clm, clm + M, inf);

  cin >> r >> c >> n;
  for (int i = 0; i < n; ++i) {
    int x, y, a;
    cin >> x >> y >> a;
    --x, --y;

    mn[y] = min<ll>(mn[y], a);
    h[x].emplace_back(y, a);
  }
}

void add(int u, int v, int d) {
  g[u].push_back(v);
  t[u].push_back(d);

  g[v].push_back(u);
  t[v].push_back(-d);
}

void build() {
  for (int i = 0; i < r; ++i) {
    for (int j = 0; j + 1 < (int) h[i].size(); ++j) {
      int a = h[i][j].first;
      int b = h[i][j + 1].first;
      int d = h[i][j + 1].second - h[i][j].second;

      add(a, b, d);
    }
  }
}

void dfs(int v, ll cur, int cl) {
  used[v] = true;
  s[v] = cur;
  col[v] = cl;
  clm[cl] = min<ll>(clm[cl], cur);

  for (int i = 0; i < (int) g[v].size(); ++i) {
    int to = g[v][i];
    int by = t[v][i];

    if (used[to]) {
      nice &= s[to] == s[v] + by;
    } else {
      dfs(to, cur + by, cl);
    }
  }
}

void kill() {
  int cnt = 0;
  for (int i = 0; i < c; ++i)
    if (!used[i]) {
      dfs(i, 0, cnt++);
    }

  if (!nice) {
    cout << "No\n";
    return;
  }

  /*
  for (int i = 0; i < c; ++i) {
    cerr << "i = " << i << ", mn[i] = " << mn[i] << ", col[i] = " << col[i];
    cerr << ", s[i] = " << s[i] << endl;
  }

  cout << clm[0] << endl;
  */

  for (int i = 0; i < c; ++i) {
    ll res = mn[i] + clm[col[i]] - s[i];
    if (res < 0) {
      cout << "No\n";
      return;
    }
  }

  cout << "Yes\n";
}

int main() {
  cout.precision(20);
  cout << fixed;
  ios_base::sync_with_stdio(false);
  read();
  build();
  kill();
}


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

using namespace std;
static const int MMAX=20;
static const int NMAX=50000;
static const int INFTY = (1 << 29);

int main() {
    int n,m;
    int C[21];
    int T[NMAX+1];

    cin>>n>>m;
    for(int i=1;i<=m;i++) cin >>C[i];

    for(int i=0; i<=NMAX; i++) T[i]=INFTY;
    T[0]=0;
    for(int i=1;i<=m; i++){
        for(int j=0; j+C[i]<=n; j++){
            T[j+C[i]]=min(T[j+C[i]],T[j]+1);
        }
    }

    cout<<T[n]<<endl;
}



Measured memory_bytes: 3284
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>

using namespace std;

#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)

using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

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

    int a, b;
    cin >> a;
    cin >> b;

    cout << 6-a-b << "\n";
}

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


using namespace std;



long long int maxcandypossible(long long int *arr,int n,int k){

  long long int DP[n][k+1]; 


  for(int i=0;i<=k;i++)
    DP[0][i]=(arr[0]>=i)?1:0;


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

  for(int j=0;j<=k;j++)
  {

      if(j==0)
     DP[i][j]=DP[i-1][j];

   else
    DP[i][j]=(1000000007+DP[i][j-1]+DP[i-1][j]-((j-1-arr[i])>=0?DP[i-1][j-1-arr[i]]:0))%1000000007;

  }



 }



return DP[n-1][k];

}


int main(){


int n,k;

cin>>n>>k;

long long int arr[n];

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

cout<<maxcandypossible(arr,n,k)<<endl;


  return 0;
}

Measured memory_bytes: 81520
#include<bits/stdc++.h>
using namespace std;
int c(int p,int q){long long s=1;vector<long> d(q,p),e(q,0);
     for(int i=0;i<q;i++)d.at(i)-=i;
  for(int i=2;i<=q;i++){int z=i;for(int j=2;j<=q;){if(z%j==0){e.at(j-1)++;z/=j;}else j++;if(z==1)break;}}
     for(int i=1;i<q;i++){for(int k=0;k<q;){if(e.at(i)==0)break;if(d.at(k)%(i+1)==0){d.at(k)/=(i+1);e.at(i)--;}else k++;}}
    for(int i=0;i<q;i++){s*=d.at(i);
s%=1000000007;}return s;}
int main(){long N;long long a=0;cin>>N;for(int v=0;v<(N/3);v++)
{a+=c(N-2*v-3,v);a%=1000000007;}cout<<a<<endl;}

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

int main() {
  int N,l,r,sum=0;
  cin >> N;
  rep(i,N){
    cin >> l >> r;
    sum += r - l + 1;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define maxn 200005
#define MOD 1000000007
#define INF 10000000000

using namespace std;

#define ll long long
#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

void solve(){

    double n;
    cin >> n;
    n = n/3;
    cout << setprecision(10) << n*n*n;
}

int main()
{
    fast();
    int t= 1;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <time.h>
#include <complex>
#include <cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define INF (1<<21)
#define rep(i,n) for(int (i)=0;(i)<n;(i)++)
#define Rrep(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=a;i<n;i++)
#define SORT(v) sort((v).begin(),(v).end())
#define TEMP(type,x,y) do {temp temp=x,x=y,y=temp}while(0)

int main() {

	int N;
	cin >> N;

	vector<int>height(N);

	for (int i = 0; i < N; i++) {
		cin >> height[i];
	}

	vector<int>counting(N, 0);
	int count = 0;
	int t = height[0];

	for (int i = 1; i < N; i++) {
		if (height[i] <= t) {
			count++;
		}
		else {
			counting[i] = count;
			count = 0;
		}
		t = height[i];
	}
	
	counting[N - 1] = count;

	int maxh = 0;
	for (int i = 0; i < N; i++) {
		if (maxh < counting[i]) {
			maxh = counting[i];
		}
	}

	cout << maxh << endl;
	return 0;

}

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

long long int gcd(long long int a,long long int b){
  long long int x=a*b;
  long long int tmp,r;
  if(a<b){
   tmp = a;
   a = b;
   b = tmp;
 }
 r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  long long int re=x/b;
  return re;
}

int main(){
  long long int a,b,c,d;
  cin>>a>>b>>c>>d;
  long long int g=gcd(c,d);
  long long int ax,ay,bx,by,gx,gy;


 ax=(a-1)/c;
 bx=b/c;
 ay=(a-1)/d;
 by=b/d;
 gx=(a-1)/g;
 gy=b/g;

 long long int ans=(b-a+1)-(bx-ax)-(by-ay)+(gy-gx);

  cout<<ans<<endl;
}


Measured memory_bytes: 256
n,t = map(int, input().split())
m = 1001
index = -1
for i in range(n):
    c1, t1 = map(int, input().split())
    if t1 <= t:
        if m >= c1:
            m = c1
            index = i + 1
if m != 1001:
    print(m)
else:
    print("TLE")

Measured memory_bytes: 3060
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cstdlib>
using namespace std;
const int MaxN = 1e5;
long long a[MaxN + 5], b[MaxN + 5], c[MaxN + 5];
int main()
{
	long long  sum = 0,num = 0;
	long n, d, f;
	scanf("%d", &n);
	for(int i = 0; i < n; i++) scanf("%lld", &a[i]);
	for(int i = 0; i < n; i++) scanf("%lld", &b[i]);
	for(int i = 0; i < n; i++) scanf("%lld", &c[i]);
	sort(a, a + n);
	sort(c, c + n);
	for(int i = 0; i < n; i++) {
		d = lower_bound(a, a + n, b[i]) - a;
		f = upper_bound(c, c + n, b[i]) - c;
		sum = sum + d * (n - f);
	}
	printf("%lld\n", sum);
}

Measured memory_bytes: 2560
using System;
class Program
{
	static void Main(string[] args)
	{
		// カーテン入力
		string[] input = Console.ReadLine().Split(' ');
		int aLength = int.Parse(input[0]);
		int bLength = int.Parse(input[1]);
        int answer = aLength - bLength * 2;
		//出力
		Console.WriteLine(answer > 0 ? answer : 0);
	}
}

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

int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    int ar[n];
    for (int i = 0; i < n; i++) {
        cin >> ar[i];
    }
    int ans = 0;
    for (int i = 1; i < n - 1; i++) {
        if (ar[i -  1] < ar[i] && ar[i] < ar[i + 1]) ans++;
        else if (ar[i - 1] > ar[i] && ar[i] > ar[i + 1]) ans++;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i = n;i >= 0;--i)
#define FOR(i,m,n) for(int i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

int main(void)
{
    int a, b;
    cin >> a >> b;
    if( abs(a - b) % 2 == 0){
        cout << (a + b) / 2;
    }
    else{
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}

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

//x：A本でB円
//y：C本でD円
//xかyを選択
//n本以上を購入

int main()
{
	int n, a, b, c, d;
	scanf("%d %d %d %d %d", &n, &a, &b, &c, &d);

	int a_no = ceil((float)n / (float)a);
	int a_price = a_no * b;

	int c_no = ceil((float)n / (float)c);
	int c_price = c_no * d;

	printf("%d\n", a_price < c_price ? a_price : c_price);
}


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

// Begin {{{
using namespace std;
#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, b, e) for (i64 i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (i64 i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<>>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
inline i64 sigma(i64 n) { return n * (1 + n) >> 1; }
inline i64 updiv(i64 n, i64 d) { return (n + d - 1) / d; }
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;
#ifndef DEBUG
#define dump(...)
#endif

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

inline void outs() { cout << "\n"; }
template <class Head, class... Tail>
inline void outs(Head&& head, Tail&&... tail) {
    cout << head << (sizeof...(tail) ? " " : "");
    outs(forward<Tail>(tail)...);
}

template <class T>
inline void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e == &vec.back()]; }

template <class T>
inline void outs(vector<vector<T>> &df) { for (auto &vec : df) outs(vec); }

inline void outl() { cout << "\n"; }
template <class Head, class... Tail>
inline void outl(Head&& head, Tail&&... tail) {
    cout << head << (sizeof...(tail) ? "\n" : "");
    outl(forward<Tail>(tail)...);
}

template <class T>
inline void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

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

template <class T>
inline void outn(vector<T> &vec) { for (auto &e : vec) cout << e; }

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...));
}
// }}} End

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    var(int, h, w, a, b);
    auto mat = make_v(0, h, w);
    rep(i, b) rep(j, a) mat[i][j] = 1;
    reps(i, b, h - 1) reps(j, a, w - 1) mat[i][j] = 1;
    rep(i, h) {
        outn(mat[i]);
        outl();
    }
    return 0;
}


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

int main(){
    int N;
    cin >> N;
    string s;
    cin >> s;
    char c = '^';
    int ans = 0;
    for(int i =0; i < N; i++){
        if(s.at(i) != c){
            c = s.at(i);
            ans ++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
import math
n,d=map(int,input().split())
x=[list(map(float,input().split())) for _ in range(n)]
ans=0
for i in range(n-1):
  for j in range(i+1,n):
    tmp=0
    for k in range(d):
      tmp+=(x[i][k]-x[j][k])**2
    if math.sqrt(tmp).is_integer():
      ans+=1
print(ans)
  

Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        sc.close();
        Integer a_group[] = {1, 3, 5, 7, 8, 10, 12};
        Integer b_group[] = {4, 6, 9, 11};
        
        if(Arrays.asList(a_group).contains(x) && Arrays.asList(a_group).contains(y)) {
            System.out.println("Yes");
        }else if(Arrays.asList(b_group).contains(x) && Arrays.asList(b_group).contains(y)) {
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };

long long hsum2[1500005],wsum2[1500005];

int main() {
	int n,m;
	long long ans=0;
	int h[1505],w[1505];
	long long hsum1[1505],wsum1[1505];
	while(true){
		cin>>n>>m;
		if(n+m==0) return 0;
		else{
			for(int i=0;i<1505;i++){
				hsum1[i]=0;
				wsum1[i]=0;
			}
			fill(hsum2,hsum2+1500005,0);
			fill(wsum2,wsum2+1500005,0);

			for(int i=0;i<n;i++){
				cin>>h[i];
				if(i==0){
					hsum1[i]+= h[i];
				}
				else{
					hsum1[i]=hsum1[i-1]+h[i];
				}
			}
			for(int i=0;i<m;i++){
				cin>>w[i];
				if(i==0){
					wsum1[i]+= w[i];
				}
				else{
					wsum1[i]+=wsum1[i-1]+w[i];
				}
			}
			for(int i=0;i<n;i++){
				hsum2[hsum1[i]]++;
				for(int j=i+1;j<n;j++){
					hsum2[hsum1[j]-hsum1[i]]++;
				}
			}

			for(int i=0;i<m;i++){
				wsum2[wsum1[i]]++;
				for(int j=i+1;j<m;j++){
					wsum2[wsum1[j]-wsum1[i]]++;
				}
			}
		}
		for(int i=0;i<1500005;i++){
			ans += hsum2[i]*wsum2[i];
		}
		cout<<ans<<endl;
		ans=0;
	}
}

Measured memory_bytes: 26556
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }






        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);


            var n = Read();
            var a = Reads();
            long count = 0;
            for (int i = 0; i < n; i++)
            {
                if (a[i] % 2 == 0) count++;
            }
            Console.WriteLine((long)Math.Pow(3, n) - (long)Math.Pow(2, count));

                Console.Out.Flush();
        }
    }
}




Measured memory_bytes: 13396
#include<stdio.h>

int main(){
	int f=0,i;
	char s[101];
	scanf("%s",s);
	for(i=0;s[i]!=0;i++){
		if(i%2==0){
			if(s[i]=='L')f=1;
		}if(i%2==1){
			if(s[i]=='R')f=1;
		}
	}
	if(f==1)puts("No");
	else puts("Yes");
	return 0;
}

Measured memory_bytes: 128