akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
 
using namespace std;
 
#define eb emplace_back
#define pb push_back
#define MP make_pair
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define rep(i,j,n) for (int i = j; i < n; ++i)
#define repn(i,j,n) for (int i = j; i <= n; ++i)
#define revn(i,j,n) for (int i = j; i >= n; --i)
#define sz(i) i.size()
#define mem(i,v) memset(i,v,sizeof(i))
#define all(v) v.begin(), v.end()
#define endl '\n'
#define int long long
#define INF 1e18
#define ss second
#define ff first

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
 
//const int mod=1e9+7;
const int mod=998244353;
const int up=1e5+10;
const int MAXN=1e6+10;

// int n,m,x,y,res=0,sz[2*up],par[2*up],ans[2*up];

// int get(int x)
// {
//     return x*(x-1)/2;
// }

// int find(int x)
// {
//     if(par[x]==x)
//         return x;
//     else
//         return par[x]=find(par[x]);
// }

// void merge(int u,int v)
// {
//     x=find(u);
//     y=find(v);
//     if(sz[x]<sz[y])
//         swap(x,y);
//     res-=get(sz[x]);
//     res-=get(sz[y]);
//     sz[x]+=sz[y];
//     res+=get(sz[x]);
//     par[v]=u;
// }

// void solve()
// {
//     cin>>n>>m;
//     vector<pii>q(m+1);
//     vector<pair<int,pii>>e(n);
//     repn(i,1,n)
//     {
//         sz[i]=1;
//         par[i]=i;
//     }
//     repn(i,1,n-1)
//     {
//         cin>>e[i].ss.ff>>e[i].ss.ss>>e[i].ff;
//     }
//     repn(i,1,m)
//     {
//         cin>>q[i].ff;
//         q[i].ss=i;
//     }
//     sort(all(e));
//     sort(all(q));
//     int pos=1;
//     repn(i,1,m)
//     {
//         while(pos<n && e[pos].ff<=q[i].ff)
//         {
//             x=e[pos].ss.ff;
//             y=e[pos].ss.ss;
//             merge(x,y);
//             ++pos;
//         }
//         ans[q[i].ss]=res;
//     }
//     repn(i,1,m)
//     {
//         cout<<ans[i]<<" ";
//     }
//     cout<<endl;
// }



void solve()
{
    string s;
    cin>>s;
    repn(i,0,sz(s)-1)
    {
        if(s[i]=='?')
            s[i]='D';
    }
    cout<<s<<endl;
}

int32_t main()
{
    int t;
    // memset(prime, true, sizeof(prime)); 
    // sieve();
    //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
}



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

void solve(){
    
}

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

    int n,k;
    cin>>n>>k;
    int p[n];
    for(int i=0; i<n; i++){
        cin>>p[i];
    }
    int ans=0;
    sort(p, p +n);
    for(int i=0; i<k; i++)
        ans+=p[i];

    cout<<ans<<"\n";

    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <string>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <map>
using namespace std;
#define ms(a, x) memset(a, x, sizeof(a))
#define fore(i, a, n) for (long long i = a; i < n; i++)
#define ford(i, a, n) for (long long i = n - 1; i >= a; i--)
#define si(a) scanf("%d", &a)
#define sl(a) scanf("%lld", &a)
#define sii(a, b) scanf("%d%d", &a, &b)
#define siii(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define sll(a, b) scanf("%lld%lld", &a, &b)
#define slll(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define debug(a) cout << a << endl
#define pr(a) printf("%d ",a)
#define endl '\n'
#define pi acos(-1.0)
#define tr t[root]
#define lson t[root << 1]
#define rson t[root << 1 | 1]
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define ull unsigned long long
const double eps = 1e-8;
inline int sgn(const double &x) { return x < -eps ? -1 : x > eps; }
typedef long long ll;
const int inf=0x3f3f3f3f;
const int MAXN = 3e3 + 10;
string a,b;
int dp[MAXN][MAXN];
int f[MAXN][MAXN];
void Print(int x,int y)
{
	if(x==0||y==0) return;
	if(f[x][y]==1)
	Print(x-1,y-1),cout<<a[x-1];
	else if(f[x][y]==2)
	Print(x-1,y);
	else
	Print(x,y-1);	
}
int main()
{
	IO;
	cin>>a>>b;
	int lena=a.length();
	int lenb=b.length();
	for(int i=1;i<=lena;i++)
        {
            for(int j=1;j<=lenb;j++)
            {
                if(a[i-1]==b[j-1])
                {
                    dp[i][j]=dp[i-1][j-1]+1;
                    f[i][j]=1;
                }
                else
                {
                    if(dp[i][j-1]<dp[i-1][j])
					dp[i][j]=dp[i-1][j],f[i][j]=2;
					else
					dp[i][j]=dp[i][j-1],f[i][j]=3;
                }
            }
        }
		Print(lena,lenb);
		cout<<endl;
 } 


Measured memory_bytes: 71040
MOD = 10**9 + 7
list_size = 200001

f_list = [1] * list_size
f_r_list = [1] * list_size

for i in range(list_size-1):
	f_list[i+1] = (f_list[i] * (i+1)) % MOD

f_r_list[-1] = pow(f_list[-1], MOD - 2, MOD)

for i in range(list_size-2, -1, -1):
	f_r_list[i] = (f_r_list[i+1] * (i+1)) % MOD

def comb(n, r):
	if n < r or r < 0:
		return 0
	elif n == 0 or r == 0 or n == r:
		return 1
	else:
		return (f_list[n] * f_r_list[n-r] * f_r_list[r]) % MOD 

s = int(input())
ans = 0
for i in range(1, s//3+1):
	t = s - 3*i
	ans += comb(t+i-1, i-1)
	ans %= MOD
print(ans)

Measured memory_bytes: 67664
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		String S = sc.next();
		char[] sInfo = new char[N];
		for(int i = 0; i < N; i++) {
			sInfo[i] = S.charAt(i);
		}

		int passingPeople = 0;
		int foreignRank = 1;
		for(int i = 0; i < N; i++) {
			if(sInfo[i] == 'c') {
				System.out.println("No");
			} else if(sInfo[i] == 'a' && passingPeople < A+B) {
				System.out.println("Yes");
				passingPeople++;
			} else if(sInfo[i] == 'b' && passingPeople < A+B && foreignRank <= B) {
				System.out.println("Yes");
				passingPeople++;
				foreignRank++;
			} else {
				System.out.println("No");
			}
		}
	}
}

Measured memory_bytes: 36036
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
if a%10==0:
  A = 0
else:
  A=10-a%10
if b%10==0:
  B=0
else:
  B = 10-b%10
if c%10==0:
  C=0
else:
  C = 10-c%10
if d%10==0:
  D=0
else:
  D = 10-d%10
if e%10==0:
  E=0
else:
  E = 10-e%10
listA = [A,B,C,D,E]
listA.sort()
f = a+b+c+d+e+listA[0]+listA[1]+listA[2]+listA[3]
print(f)



Measured memory_bytes: 3064
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> ipair;
typedef tuple<int, int, int> ituple;

// const ll INF = LLONG_MAX;
// const int MOD = (int)1e9 + 7;
// const double EPS = 1e-10;
#define PI acosl(-1)
#define MAX_N 10000 + 2
#define MAX_H 100 + 2

void exec(){
  int h, w;
  int n;
  int a[MAX_N];
  int ans[MAX_H][MAX_H];
  cin >> h >> w;
  cin >> n;

  int currentI = 0;
  int currentJ = 0;
  int dir = 1;
  for (int i = 0; i < n; i++){
    scanf("%d", &a[i]);

    while (a[i] > 0){
      // printf("i = %d, currentI = %d, currentJ = %d\n", i, currentI, currentJ);
      ans[currentI][currentJ] = i+1;
      currentJ += dir;
      if (currentJ == -1){
        currentI++;
        dir *= -1;
        currentJ++;
      }
      else if (currentJ == w){
        currentI++;
        dir *= -1;
        currentJ--;
      }
      a[i]--;
    }
  }

  for (int i = 0; i < h; i++){
    for (int j = 0; j < w; j++){
      printf("%d%c", ans[i][j], (j == w-1 ? '\n' : ' '));
    }
  }

}

void solve(){
  int t = 1;
  // scanf("%d", &t);
  for (int i = 0; i < t; i++){
    exec();
  }
}

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


Measured memory_bytes: 888
N,M,dp[5001],i,j,a;main(x){scanf("%d%d",&N,&M);dp[0]=1;for(;i<N-1;i++,x=i+1>N-i?N-i:i+1)for(j=x;j<=N;j++)dp[j]=(dp[j]+dp[j-x])%M;for(;i+1;i--)a=(a+(N-i)*(long long)dp[i])%M;printf("%d\n",a);}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(cnt,e) for(ll cnt=0;cnt<e;cnt++ )
#define allsort(X) sort(X.begin(),X.end())

typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = INT64_MAX;





ll i,j,k;


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

    char maze[H][W];
    rep(i,H)rep(j,W)cin>>maze[i][j];
    ll ans=0;
    
    for(ll i=0;i<(1<<H);i++){
        for(ll j=0;j<(1<<W);j++){
            vector<vector<bool>> hant(6,vector<bool>(6,true));
            ll nokori=0;

            for(ll a=0;a<H;a++){
                for(ll b=0;b<W;b++){
                    if((!((i>>a)&1||(j>>b)&1))&&hant[a][b]&&maze[a][b]=='#'){
                        nokori++;
                        hant[a][b]=false;
                    }
                }
            }
            if(nokori==K)ans++;
        }
    }
    cout<<ans<<endl;


}

Measured memory_bytes: 3620
#include <stdio.h>

int main(){
    int i,x;
    for(i=1;i++;){
        scanf("%d",&x);
        if(x!=0)
            printf("Case %d: %d\n",i-1,x);
        else
        break;
        }
        
    
    
    
    
    return 0;
}


Measured memory_bytes: 1976
N = int(input())

# 1 <= N <= 10**5 = 100,000

if N <= 99:
  print(min(N, 9))
elif N <= 9999:
  ans = 9 + (min(N, 999) - 99)
  print(ans)
else:
  ans = 9 + 900 + (min(N, 99999) - 9999)
  print(ans)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
const int maxn = 1e6+10;
int m,n;
int main()
{
	cin>>n;
	int j=n;
	long long ans=0;
	while(n)
	{
		ans+=n%10;
		n/=10;
	}
	if(j%ans==0) cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 632
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
const Int MOD = 998244353;
struct Box {
    map<pair<int, int>, Int> M;
    Box() {
        M[make_pair(0, 0)] = 1;
    }
    void push(bool b) {
        map<pair<int, int>, Int> M2;
        for (auto &p : M) {
            auto pp = make_pair(p.first.first + (b == false), p.first.second + (b == true));
            M2[pp] = p.second;
        }
        M.swap(M2);
    }
    void pop() {
        map<pair<int, int>, Int> M2;
        for (auto &p : M) {
            if (p.first.first > 0) {
                M2[make_pair(p.first.first - 1, p.first.second)] += p.second;
                M2[make_pair(p.first.first - 1, p.first.second)] %= MOD;
            }
            if (p.first.second > 0) {
                M2[make_pair(p.first.first, p.first.second - 1)] += p.second;
                M2[make_pair(p.first.first, p.first.second - 1)] %= MOD;
            }
        }
        M.swap(M2);
    }
    Int number() {
        Int sum = 0;
        for (auto &p : M) sum += p.second;
        return sum % MOD;
    }
};
int main() {
    string S; cin >> S;
    Box B;
    for (int i = 0; i < S.size(); i++) {
        int t = S[i] - '0';
        if (t == 0) B.push(false), B.push(false);
        if (t == 1) B.push(false), B.push(true);
        if (t == 2) B.push(true), B.push(true);
        B.pop();
    }
    for (int i = 0; i < S.size(); i++) {
        B.pop();
    }
    cout << B.number() << '\n';
    return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>
int main(void){
    int A,B,C,X;
    char S[10];
    scanf("%d %d",&A,&B);
    if((A+B)%2!=0){
   printf("%d",(A+B)/2+1);
    }else{
        printf("%d",(A+B)/2);
    }
    return 0;
}

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

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

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define pb push_back

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b); i >= (a); --i)
#define R0F(i, a) ROF(i, 0, a-1)
#define trav(x, a) for (auto& x: a)

const int MX  = 2e5+5;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

namespace factorBasic {
    template<class T> vector<pair<T,int>> factor(T x) {
        vector<pair<T,int>> pri;
        for (T i = 2; i*i <= x; ++i) if (x % i == 0) {
            int t = 0;
            while (x % i == 0) x /= i, t++;
            pri.pb({i,t});
        }
        if (x > 1) pri.pb({x,1});
        return pri;
    }
    ll phi(ll x) {
        trav(a,factor(x)) x -= x/a.f;
        return x;
    }
    template<class T> void tour(vector<pair<T,int>>& v,
        vector<T>& V, int ind, T cur) {
            if (ind == sz(v)) V.pb(cur);
            else {
                T mul = 1;
                F0R(i,v[ind].s+1) {
                    tour(v,V,ind+1,cur*mul);
                    mul *= v[ind].f;
                }
            }
        }
    template<class T> vector<T> getDivi(T x) {
        auto v = factor(x);
        vector<T> V; tour(v,V,0,(T)1); sort(all(V));
        return V;
    }
}

using namespace factorBasic;

int main() {

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

    ll N; cin >> N;

    auto f = factor<ll>(N);

    ll res = 0;
    trav(x,f) {
        ll ini = 1;
        while(x.s-ini >= 0) {
            res++; x.s -= ini; ini++;
        }
    }

    cout << res << "\n";

}


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

using llong = long long;

constexpr int MAX=100000;

int n, k;
llong T[MAX];

bool check(int x){
   llong cost=0; int count=0;
   for(int i=0; i<n; i++){
      cost+=T[i];
      while(cost>x){
         cost=T[i];
         count++;
         if(count==k) return false;
      }
   }
   return true;
}

int main(){
   cin.tie(0);
   ios::sync_with_stdio(false);
   cin >> n >> k;
   for(int i=0; i<n; i++) cin >> T[i];
   llong left=0; llong right=100000*10000;
   while(left<right){
      llong mid=(left+right)/2;
      if(check(mid)) right=mid;
      else left=mid+1;
   }
   cout << left << "\n";
   return 0;
}


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

int n,k;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    cin>>n>>k;
    double dice[n],sum[n+1],maxi=-1e12;
    
    for(int i=0;i<n;i++)
    {
    	cin>>dice[i];
    	sum[i+1]=(1+dice[i])/2.00;
	}
	
	sum[0]=0;
	for(int i=1;i<=n;i++)
	{
		sum[i]+=sum[i-1];
	}
	
	for(int i=1;i<=n-k+1;i++)
	{
	  maxi=max(maxi,sum[i+k-1]-sum[i-1]);	
	}


cout<<fixed<<setprecision(9)<<maxi<<endl;


    
    
    
	return 0;
}

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

int main(){
	string a,b;
  	cin >> a >> b;
  	bool x =true;
  	if (a==b) cout <<"EQUAL" <<endl;
    else if (a.size()>b.size()) cout << "GREATER"<< endl;
  	else if (a.size()<b.size()) cout << "LESS" << endl;
  	else {
    for (int i=0;i<a.size();i++){
    	if (a.at(i)>b.at(i)) break;
      	else if (a.at(i)<b.at(i)) {
        	x=false;
        	break;
        }
    }
    if (x==true) cout << "GREATER" << endl;
    else cout << "LESS" << endl;
    }
}

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

#define rep(i, a) for (int i = 0; i < (int)a; ++i)
#define REP(i, a, b) for (int i = (a); i < (int)b; ++i)

// [debug]

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

int n;
string t = "abcdefghij";
vector<string> S;

void dfs(string s, char c, int k) {
  s.push_back(c);
  if (s.size() == n) {
    cout << s << endl;
  } else {
    rep(i, k+1) dfs(s, t[i], k);
    if (k < n) dfs(s, t[k+1], k+1);
  }
  return;
}

void Main() {
  cin >> n;
  dfs(string(""), 'a', 0);
  sort(S.begin(), S.end());
}

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


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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    int n; cin >> n;
    vector<ll> lis(n);
    REP(i, 0, n){cin >> lis[i];}
    ll ans = 0;
    ll count = 0;
    REP(i, 0, n){
        if(lis[i] == 0){
            ans += count / 2;
            count = 0;
        }else{
            count += lis[i];
        }
    }
    ans += count / 2;
    cout << ans << endl;
}

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

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

Measured memory_bytes: 256
n,k=map(int,input().split())
ans=[]
a=1
b=n
s=set()
for _ in range(k):
  s.add(abs(a-b))
  s.add(abs(n+a-b)%n)
  ans.append([a,b])
  a+=1
  b-=1
  if abs(a-b) in s or abs(n+a-b)%n in s or abs(a-b)==abs(n+a-b):
    b-=1
for i in range(k):
  print(*ans[i])

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

int main(){
  int N;

  cin >> N;

  int *A = new int[N];

  for(int i=0;i<N;++i){
    cin >> A[i];
    
    cout << A[i];
    if(i != N-1) cout << " ";
  }
  cout << endl;

  int j;
  int v;
  for(int i=1;i<N;++i){
    v = A[i];
    for(j = i-1; j>=0; --j){
      if(A[j] > v){
	A[j+1] = A[j];
      }else{
	break;
      }
    }
    A[j+1] = v;
    for(j=0; j<N;++j){
      cout << A[j];
      if(j != N-1) cout << " ";
    }
    cout << endl;
  }


  delete[] A;
}



Measured memory_bytes: 3092
#include <stdio.h>
#include <cmath>
#include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

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



int main(void){

	string S; cin >> S;

	string T = "ATCG";

	int ans = 0;

	int now = 0;
	REP(i,S.length()){
		bool isATCG = false;
		REP(j,T.length()){
			if(S[i] == T[j]) isATCG = true;
		}

		if(!isATCG){
			now = 0;
		}else{
			now++;
			ans = max(now, ans);
		}

	}

	cout << ans << endl;


	return 0;

}


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

#define lld long long
#define pi pair<int, int>
#define pl pair<lld, lld>
#define mem0(x) memset(x, 0, sizeof(x))
#define fillnum(x, n) fill(begin(x), end(x), n)
#define asort(x) sort(x.begin(), x.end())
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>())

int main() {
    lld X;
    cin >> X;
    for(lld i = 0; i < 1000; i++) {
        for(lld j = 0; j < 1000; j++) {
            lld A_5 = (lld)pow((long double)j, 5);
            lld B_5 = (lld)pow((long double)i, 5);
            if(A_5 - B_5 == X) {
                cout << j << " " << i << endl;
                exit(0);
            } else if(A_5 - (-1) * B_5 == X) {
                cout << j << " " << -i << endl;
                exit(0);
            } else if((-1) * A_5 - B_5 == X) {
                cout << -j << " " << i << endl;
                exit(0);
            } else if((-1) * A_5 - (-1) * B_5 == X) {
                cout << -j << " " << -i << endl;
                exit(0);
            }
        }
    }
}

Measured memory_bytes: 3704
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1000100011;
// clang-format on

typedef struct {
  char c;
  int scolar;
} D;

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;

  vector<vector<D>> orders(4);
  // 一往復目
  orders[0] = {{'U', ty - sy}, {'R', tx - sx}};
  orders[1] = {{'D', ty - sy}, {'L', tx - sx}};

  // 二往復目
  orders[2] = {{'D', 1},
               {'R', orders[0][1].scolar + 1},
               {'U', orders[0][0].scolar + 1},
               {'L', 1}};
  orders[3] = {{'U', 1},
               {'L', orders[1][1].scolar + 1},
               {'D', orders[1][0].scolar + 1},
               {'R', 1}};

  for (int i = 0; i < 4; i++) {
    for (auto order : orders[i]) {
      for (int j = 0; j < order.scolar; j++) {
        cout << order.c;
      }
    }
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
using namespace std;

int main(void)
{
	int n; cin >> n;
	map<char, int> count; rep(i, 0, 26)count['a' + i] = 50;
	rep(i, 0, n) {
		string tmp; cin >> tmp;
		map<char, int> tmp_count;
		rep(j, 0, tmp.length())tmp_count[tmp[j]]++;
		rep(j, 0, 26)count['a' + j] = min(count['a' + j], tmp_count['a' + j]);
	}
	rep(i, 0, 26) {
		rep(j, 0, count['a' + i])cout << (char)('a' + i);
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <list>
#include <cstring>

//#define USE_SET

int main(void) {
  int K;

  std::string str;

  std::string s_;
  std::cin >> s_;
  const char* s = s_.c_str();

  std::cin >> str;
  K = std::stoi(str);

  size_t lsize = 0;
  size_t len = s_.length();

#if defined(USE_SET)
  typedef struct s_set {
    int pos;
    int len;

    s_set(int i, int j) : pos(i), len(j) {
    }
  } set;
#endif

#if defined(USE_SET)
  std::list<set> wlist;
  wlist.push_back(set(0, 1));
#else
  std::list<std::string> wlist;
  wlist.push_back(s_.substr(0, 1));
#endif

  for (int a = 'a'; a <= 'z' && lsize < K; ++a) {        /* a to z   */
    //for (int b = 'a'; b <= 'z' && lsize < K; ++b) {      /* a to z   */
      for (int i = 0; i < len; ++i) {                    /* 0 to len */
        //if (s[i] == a && (i+1 >= len || s[i+1] == b)) {
        if (s[i] == a) {
          for (int j = 1; j <= len - i && j <= K; ++j) {           /* length 1 to len - i */
            for (auto itr = wlist.begin(); itr != wlist.end(); ++itr) {
#if defined(USE_SET)
              int cmp = s_.compare(i, j, s_, itr->pos, itr->len);
#else
              int cmp = s_.compare(i, j, *itr);
#endif
              if (cmp == 0) {
                break;
              }
              if (cmp < 0) {
#if defined(USE_SET)
                wlist.insert(itr, set(i, j));
#else
                wlist.insert(itr, s_.substr(i, j));
#endif
                lsize++;
                break;
              }
#if defined(USE_SET)
              if (cmp > 0 && (itr->pos == wlist.rbegin()->pos && itr->len == wlist.rbegin()->len)) {
                wlist.push_back(set(i, j));
#else
              if (cmp > 0 && itr->c_str() == wlist.rbegin()->c_str()) {
                wlist.push_back(s_.substr(i, j));
#endif
                lsize++;
                break;
              }
            }
          }
        }
      }
    //}
  }

  size_t idx = 0;
  for (auto &str : wlist) {
    idx++;
    if (idx == K) {
#if defined(USE_SET)
      //std::cout << str.pos << "," << str.len << std::endl;
      std::cout << s_.substr(str.pos, str.len) << std::endl;
#else
      std::cout << str << std::endl;
#endif
    }
  }

  return 0;
}

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

int main() {
	long n,m,i,j,ans=0;
	cin >> n >> m;
	vector<long> a(m);
	for(i=0; i<m; i++){
		cin >> a[i] >> a[i];
	}
	sort(a.begin(),a.end());
	for(i=0; i<m-1; i++){
		ans+=max(long(0),a[i]-n);
	}
	cout << ans << endl;
}


Measured memory_bytes: 3156
package main

import "fmt"

func main() {
	var W, H, x, y, r int
	fmt.Scan(&W, &H, &x, &y, &r)
	if x >= r && x <= W-r && r <= y && y <= H-r {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}



Measured memory_bytes: 1216
// https://atcoder.jp/contests/abc112/tasks/abc112_b
#include <bits/stdc++.h>
using namespace std;
using P = pair<double, int>;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
const int INF = 1e9;
int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, T;
    cin >> N >> T;
    int minv = INF;
    REP(i, N) {
        int a, b;
        cin >> a >> b;
        if (b <= T) {
            minv = min(minv, a);
        }
    }
    if (minv == INF) {
        cout << "TLE\n";
    } else {
        cout << minv << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <map>

#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
typedef long long ll;

using namespace std;

int main(){
    int N;
    cin >> N;
    // Nは偶数.
    vector<int> xs(N, 0);
    vector<int> ys(N, 0);
    rep(i, N){
        cin >> xs[i];
        ys[i] = xs[i];
    }
    sort(xs.begin(), xs.end());

    rep(i, N){
        // Nは偶数.
        int med = xs[N / 2 - 1];
        if(ys[i] <= med){
            med = xs[ N / 2];
        }
        cout << med << endl;
    }

    return 0;
}


Measured memory_bytes: 3712
#----グローバル変数----
INF = 10**10 #無限大（最小化問題の場合）
dp=[]       #DPテーブル

h=[]   #足場の高さ
#----------------------

#----関数----

#DPテーブル更新関数　最小化用＆最大化用
def chmin(dp, idx, new_val):
    if dp[idx] > new_val:
        dp[idx] = new_val
        return True
    return False

def chmax(dp, idx, new_val):
    if dp[idx] < new_val:
        dp[idx] = new_val
        return True
    return False
#------------


#----実行開始----
# 入力
n = int(input())

s = input()
h = [int(x) for x in s.split()]

# DPテーブル初期化 (最小化問題なので INF に初期化)
for i in range(n):
    dp.append(INF)

# 初期条件
dp[0] = 0;

#ジャンプのループ
for i in range(1,n):
    # 1jp
    jpcost = abs(h[i-1]-h[i])
    chmin(dp,i,dp[i-1]+jpcost)
    # 2jp
    if i > 1:
        jpcost = abs(h[i-2]-h[i])
        chmin(dp,i,dp[i-2]+jpcost)

# 出力
print(dp[n-1])

#---------------


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

using namespace std;

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

	int n;
	cin >> n;
	vector<int> v(n);
	unordered_map<int, int> m;
	for(int i=0; i<n; i++){
        cin >> v[i];
        m[v[i]]++;
	}
    sort(v.begin(), v.end());
    unordered_set<int> s;
    int ans=0;
    for(int i=0; i<n; i++){
        if(m[v[i]]>1){
            s.insert(v[i]);
            continue;
        }
        int flag=0;
        for(int j=1; j*j<=v[i]; j++){
            if(v[i]%j==0){
                if(s.find(j)!=s.end() || s.find(v[i]/j)!=s.end()){
                    flag=1;
                    break;
                }
            }
        }
        if(flag==0)
            ans++;
        s.insert(v[i]);
    }

    cout << ans << endl;

	return 0;
}


Measured memory_bytes: 20636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, ans;
  cin >> N;
  int a[N];
  for(int i=0; i<N; i++){
    cin >> a[i];
  }
  
  ans=0;
  for(int i=0; i<N; i++){
    if((i+1)%2==1 && a[i]%2==1){
      ans++;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3588
X,K,D=map(int,input().split())
Y=X%D
if abs(X)-K*D>0:
    ans=abs(X)-K*D
else:
    Z=(K-abs(Y-X)//D)%2
    if Z==0:
        ans=Y
    else:
        ans=Y-D
print(abs(ans))

Measured memory_bytes: 9180
import Control.Applicative
import Data.Array

bs :: Array Int Int -> Int -> Int -> Bool
bs xs x m = bs' 0 (m-1)
    where
    bs' a b
     |  midVal == x = True
     |  a >= b      = False
     |  midVal < x  = bs' (mid+1) b
     |  midVal > x  = bs' a (mid-1)
        where
            mid    = div (a+b) 2
            midVal = xs ! mid

main = do
    n <- readLn :: IO Int
    s <- (array (0,n-1) . (zip [0..] . map read . words)) <$> getLine :: IO (Array Int Int)
    _ <- readLn :: IO Int
    t <- (map read . words) <$> getLine :: IO [Int]
    putStrLn . show . foldl (\a b -> if bs s b n then a+1 else a) 0 $ t



Measured memory_bytes: 110668
S = input()
ans = False
for bit in range(2**(len(S)-1)):
    s = ""
    for i in range(len(S)):
        s += S[i]
        if i<len(S)-1:
            if (bit>>i) & 1:
                s += "+"
            else:
                s += "-"
    ans = eval(s)==7
    if ans:
        break
print(s+"=7")

Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,K=map(int,input().split())
    A=list(map(int,input().split()))
    SUM=sum(A)
    l=[]
    for i in range(1,int(SUM**0.5)+1):
        if SUM%i==0:
            l.append(i)
            l.append(SUM//i)
    ans=0
    for x in l:
        B=[A[i]%x for i in range(N)]
        B.sort()
        S_m=[0]*(N+1)
        S_p=[0]*(N+1)
        for i in range(N):
            S_m[i+1]=S_m[i]+B[i]
            S_p[i+1]=S_p[i]+x-B[i]
        for i in range(N+1):
            if max(S_m[i],S_p[N]-S_p[i])<=K:
                ans=max(ans,x)
                break
    if SUM==0:
        print(K)
    else:
        print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 42348
#include <stdio.h>

void put_stringn(const int banana, int no)
{
  while(no-- > 0)
      printf("%d", banana);
  
}

int main(void)
{
  int a, b, c, d, banana, no;

  scanf("%d", &a);
  scanf("%d", &b);

 
  if (a < b){
    banana = a;
    no = b;
    put_stringn(banana, no);
    putchar('\n');
  }
  
  else {
    banana = b;
    no = a;
    put_stringn(banana, no);
    putchar('\n');
  }

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>

int64_t calc(const std::vector<int64_t> &ds) noexcept {
  int64_t ret = 0;
  int64_t last_sums = 0;

  for (int8_t i = ds.size() - 2; 0 <= i; --i) {
    last_sums += ds[i + 1];
    ret += ds[i] * last_sums;
  }

  return ret;
}

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

  std::vector<int64_t> ds{};
  ds.reserve(static_cast<std::size_t>(n));

  for (int i = 0; i < n; ++i) {
    int64_t d;
    std::cin >> d;
    ds.push_back(d);
  }

  std::cout << calc(ds) << std::endl;

  return 0;
}


Measured memory_bytes: 256
import java.lang.reflect.Array;
import java.util.*;

/**
 * Created by Santa.
 */
public class Main {

    static int N;
    static int K;
    static int Q;
    static int A;
    static long B;
    static long C;
    //    static int[][] map;
    static int min = 9999999;
    static long ans = 0;


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

        int N = scanner.nextInt();

        boolean ans = false;



        if(N == 1){
            System.out.println("Hello World\n");
        }else{
            int a = scanner.nextInt();
            int b = scanner.nextInt();

            System.out.println(a + b);
        }


    }
}



Measured memory_bytes: 23252
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(Console.ReadLine().Split(' ').Select(num => int.Parse(num)).Distinct().Count() == 1 ? "Yes" : "No");
        }

    }
}

Measured memory_bytes: 28292
import java.util.*;

public class Main{
   public static void main(String[] args) {
	  Scanner sc =new Scanner(System.in);
   for(;;){
   int a=0;
   int turi=1000-sc.nextInt();
   if(turi==1000)break; 
   a+= turi/500;
   a+=turi%500/100;
   a+=turi%500%100/50;
   a+=turi%500%100%50/10;
   a+=turi%500%100%50%10/5;
   a+=turi%500%100%50%10%5;
  System.out.println(a);
   }
   }
}

Measured memory_bytes: 17164
# abc177_b.py
# https://atcoder.jp/contests/abc177_b


# [開発時用] ログ関数
def lg(value):
    flag = False
    flag = True
    if flag:
        print(str(value))


# [開発時用] exit処理
def xt(log):
    lg('★exit() - ' + str(log))
    exit()


# 本体
def get_results():

    # 引数処理部
    lines = list()
    # 仕様でn行と決まっている場合(の例)
    lines_count = 2
    # 先頭行のNで行数が決まる場合(の例)
    # line = input()
    # lines.append(line)
    # N = int(line)
    # lines_count = N
    for _ in range(lines_count):
        lines.append(input())

    # 演算部
    S = lines[0]
    T = lines[1]
    # X = int(lines[0])
    # N, M = list(map(int, lines[0].split()))
    # values = list(map(int, lines[0].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    result = len(T)
    for i in range(len(S) - len(T) + 1):
        cnt = 0
        for j in range(len(T)):
            if S[i+j] != T[j]:
                cnt += 1
        if result > cnt:
            result = cnt

    return [result]


# 主処理
def main():
    results = get_results()

    for result in results:
        print(result)


# 起動処理
if __name__ == '__main__':
    main()


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

int main() {

vector<int> vec(9);
rep(i,9){cin >> vec.at(i);}

  int N;
  int B;
  cin>>N;
  string flg="No";
  rep(j,N){cin>>B;
           rep(i,9){if(vec.at(i)==B){vec.at(i)=0;}
          if((vec.at(0)+vec.at(1)+vec.at(2))*(vec.at(3)+vec.at(4)+vec.at(5))*(vec.at(6)+vec.at(7)+vec.at(8))*
             (vec.at(0)+vec.at(3)+vec.at(6))*(vec.at(1)+vec.at(4)+vec.at(7))*(vec.at(2)+vec.at(5)+vec.at(8))*
             (vec.at(0)+vec.at(4)+vec.at(8))*(vec.at(2)+vec.at(4)+vec.at(6))==0){flg="Yes";break;}
          }
          }
  cout<<flg<<endl;
}


Measured memory_bytes: 3572
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
int main(){
    int h, w;
    cin >> h >> w;
    char c[100][100];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> c[i][j];
        }
    }
    
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout << c[i][j];
        }
        cout << '\n';
       for(int j=0;j<w;j++){
            cout << c[i][j];
        }
        cout << '\n';
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,z=0,k;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>k;
        if(k!=i)
        {
            z++;
        }
    }
    if(z>2)
    {
        cout<<"NO";
    }
    else
        cout<<"YES";

}


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

using namespace std;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1000000007;

using ll = long long;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	int len = v.size();
    cout << '[';
	for (int i = 0; i < len; ++i) {
		s << v[i]; if (i < len-1) s << ", ";
	}
    cout << ']';
	return s;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll x, y;
	cin >> x >> y;

	if(x+y <= 1) ppp("Brown");
	else if(abs(x-y) <= 1) ppp("Brown");
	else ppp("Alice");

    return 0;
}


Measured memory_bytes: 256
N, x = map(int, input().split())
a = list(map(int, input().split()))
p = x
a.sort()
count = 0

for i in a:
  if x - i >= 0:
    x -= i
    count += 1
if x > 0 and count != 0  and p > sum(a):
  count -= 1
print(count)

Measured memory_bytes: 3060
# coding:utf-8

import sys
# from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n = II()
    A = LI()

    # 1: 単調非減少，2: 単調非増加，0: 未定
    state = 0
    prev = A[0]
    res = 1
    for cur in A:
        if state:
            if state == 1 and prev > cur:
                res += 1
                state = 0
            if state == 2 and prev < cur:
                res += 1
                state = 0
        else:
            if prev < cur:
                state = 1
            if prev > cur:
                state = 2
        prev = cur

    return res


print(main())


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

int main()
{
	long long h;
	scanf("%lld", &h);
	long long ans = 0;
	long long n = 1;
	while (h > 0)
	{
		ans += n;
		n *= 2;
		h /= 2;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 128
//بِسْمِ ٱللَّٰهِ ٱلرَّحْمَٰنِ ٱلرَّحِيمِ
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;

#define endl "\n"

const int MOD = 1000000007;


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

    int a, b, c;
    cin >> a >> b  >> c;
    if(b - a == c -b)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;


    return 0;
}


Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc147/tasks/abc147_c>
 問題文============================================================
 C - HonestOrUnkind2
 =================================================================
 解説=============================================================
 
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int N; cin >> N;
    vector<vector<pii>> G(N);
    for(int i = 0; i < N;i++){
        int A; cin >> A;
        for(int j = 0; j < A;j++){
            int x,y; cin >> x >> y;
            x--;
            G[i].push_back(pii(x,y));
        }
    }
    
    for(int b = 0; b < (1<<N);b++){
        bool ok = true;
        
        for(int i = 0; i < N;i++){
            if((b>>i)&1){
                for(auto p:G[i]){
                    if(((b>>p.first)&1) == p.second) continue;
                    ok = false;
                }
            }
        }
        
        if(ok) res = max(res,(ll)__builtin_popcount(b));
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <string>
#include <algorithm>
#include <cmath>
#include <ctype.h>
using namespace std;
#define dump(a) cout << (a) << '\n';
typedef long long Int;
Int mod = 1e9+7;
Int MOD = 998244353;

int main() {
    ios::sync_with_stdio(false);
    vector<Int> a(4);
    cin >> a[0] >> a[1] >> a[2] >> a[3];
    sort(a.begin(), a.end());
    dump(a[0] == 1 && a[1] == 4 && a[2] == 7 && a[3] == 9 ? "YES" : "NO");
    return 0;  
}

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

int main(){
    int n,d,x; cin >> n >> d >> x;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int sum=x;
    for(int i = 0; i < n; i++) {
        for(int j = 1; j < d+1; j+=a[i]) {
            sum+=1;
        }
    }
    cout << sum << endl;
    return 0;
}

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

using namespace std;
typedef pair<int,int> pii;
int H,W;
int sy,sx,gy,gx;
char field[101][101];
int ice;
int iceNumber[101][101];
// iceごとのタイル数
int tileNum[101];
bool used[101][101];
const int dy[]={-1,0,0,1};
const int dx[]={0,-1,1,0};
int predic[101][101];

// 状態に必要なもの
// ここまでのコスト
// どのiceを何度踏んだか(vectorでもつ)
typedef pair<pii,vector<int> > Info;
typedef pair<int,pair<pii,vector<int> > > Sit;

// 氷を踏む回数を無視したときのgoalからの最短距離
void bfs(){
  queue<pii> q;
  memset(predic,-1,sizeof(predic));
  q.push(pii(gy,gx));
  predic[gy][gx]=0;
  while(q.size()){
    pii p=q.front();q.pop();
    int cy=p.first;
    int cx=p.second;
    int ccost=predic[cy][cx];
    for(int i=0;i<4;i++){
      int ny=cy+dy[i];
      int nx=cx+dx[i];
      if(ny>=0&&nx>=0&&ny<H&&nx<W&&predic[ny][nx]==-1
	 &&field[ny][nx]!='#'){
	int ncost=ccost+1;
	predic[ny][nx]=ncost;
	q.push(pii(ny,nx));
      }
    }
  }
}

int astar(){
  priority_queue<Sit,vector<Sit>,greater<Sit> > pq;
  map<Info,int> d;
  vector<int> sv(ice,0);
  d[(make_pair(pii(sy,sx),sv))]=predic[sy][sx];
  pq.push(Sit(predic[sy][sx],make_pair(pii(sy,sx),sv)));
  int res=10000000;
  while(pq.size()){
    Sit p=pq.top();pq.pop();
    int cy=p.second.first.first;
    int cx=p.second.first.second;
    int ccost=p.first;
    vector<int> ctile=p.second.second;
    if(d.count(p.second)>0&&ccost>d[p.second])continue;
    int realCost=ccost-predic[cy][cx];
    if(cy==gy&&cx==gx)return realCost;
    for(int i=0;i<4;i++){
      int ny=cy+dy[i];
      int nx=cx+dx[i];
      if(ny>=0&&nx>=0&&ny<H&&nx<W&&field[ny][nx]!='#'){
	vector<int> ntile=ctile;
	int ncost=(realCost+1)+predic[ny][nx];
	Info ninfo=p.second;
	ninfo.first.first=ny;
	ninfo.first.second=nx;
	if(field[ny][nx]=='X'){
	  int a=iceNumber[ny][nx];
	  ninfo.second[a]++;
	  if(ninfo.second[a]>tileNum[a]/2)continue;
	}
	if(d.count(ninfo)==0||d[ninfo]>ncost){
	  d[ninfo]=ncost;
	  pq.push(make_pair(ncost,ninfo));
	  if(gy==ny&&gx==nx)res=min(res,ncost);
	}
      }
    }
  }
  return res;
}

int labelling(int cy,int cx,int k){
  int cnt=1;
  used[cy][cx]=true;
  iceNumber[cy][cx]=k;
  for(int i=0;i<4;i++){
    int ny=cy+dy[i];
    int nx=cx+dx[i];
    if(ny>=0&&nx>=0&&ny<H&&nx<W&&!used[ny][nx]&&field[ny][nx]=='X')
      cnt+=labelling(ny,nx,k);
  }
  return cnt;
}

int main(){
  while(cin>>W>>H&&(H|W)){
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	cin>>field[i][j];
	if(field[i][j]=='S'){
	  sy=i;sx=j;
	  field[i][j]='.';
	}
	else if(field[i][j]=='G'){
	  gy=i;gx=j;
	  field[i][j]='.';
	}
      }
    }
    ice=0;
    memset(used,0,sizeof(used));
    memset(iceNumber,-1,sizeof(iceNumber));
    for(int i=0;i<H;i++)
      for(int j=0;j<W;j++)
	if(!used[i][j]&&field[i][j]=='X'){
	  tileNum[ice]=labelling(i,j,ice);
	  ice++;
	}
    bfs();
    int res=astar();
    cout<<res<<endl;
  }

  return 0;
}

Measured memory_bytes: 3844
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

priority_queue<ll>Q1;
priority_queue<ll, vector<ll>, greater<ll> >Q2;

ll push(ll x){
    Q1.push(x);
    Q2.push(x);
    ll q1 = Q1.top();
    Q1.pop();
    ll q2 = Q2.top();
    Q2.pop();
    Q1.push(min(q1, q2));
    Q2.push(max(q1, q2));
    return abs(q1 - q2);
}

int main(){
    
    ll Q;
    cin >> Q;
    ll x = 0;
    ll fx = 0;
    for(ll i = 0; i < Q; i++){
        ll q;
        cin >> q;
        if(q == 1){
            ll a, b;
            cin >> a >> b;
            fx += b + push(a);
        }
        else{
            cout << Q1.top() << " " << fx << endl;
        }
    }

    return 0;
}

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



int fact(int n) {
    if(n == 1) {
        return 1;
    }

    return n * fact(n-1);
}

// void print(const std::vector<int>& v)
// {
//   std::for_each(v.begin(), v.end(), [](int x) {
//     std::cout << x << " ";
//   });
//   std::cout << std::endl;
// }


int main() {

	int N;
    cin >> N;

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

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

    double sum = 0;
    do {
        // cout << "------" << endl;
        // print(list);

        for (int i = 0; i < N-1; ++i)
        {

            double a = pow(x[list[i+1]]-x[list[i]] ,2);
            double b = pow(y[list[i+1]]-y[list[i]] ,2);
            double dist = sqrt(a+b);
            sum += dist;
            // cout << dist << endl;
        }
    } while(next_permutation(list.begin(), list.end()));

    printf("%.10lf\n", sum / (double)fact(N));
    // cout << sum / (double)fact(N) << endl;



	return 0;
}

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

A.sort()
F.sort(reverse = True)

M = 0
for i in range(N):
    M=max(F[i]*A[i],M)

def judge(n):
    score = 0
    for i in range(N):
        score += max(A[i] - n//F[i],0)
    return score<=K

def bisect(l,r):
    while r-l>1:
        if judge((l+r)//2):
            r = (l+r)//2
        else:
            l = (l+r)//2
    return r

if judge(0):
    print(0)
else:
    print(bisect(0,M))


Measured memory_bytes: 119884
def main():
  n, k = map(int, input().split())
  h = [int(n) for n in input().split()]
  dp = [0]*n
  for i in range(1, n):
    dp[i] = min([dp[j]+abs(h[i]-h[j]) for j in range(max(0,i-k),i)])  
  print(dp[-1])

if __name__ == "__main__":
  main()

Measured memory_bytes: 13928