akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
#define rsort(n) sort((n).begin(),(n).end(),greater<int>())
#define mp make_pair
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
typedef pair<P,int> COST;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
using Graf=vector<vector<int>>;
#define MAX 1000000007

/*
struct UnionFind
{
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};*/

vector<int> found(100005,false);
Graf g(100005);
queue<int> q,r;

void dfs(int s){
    if(found[s]){
        return;
    }else{
        found[s]=true;
        q.push(s);
        for(int i=0;i<g[s].size();++i){
            dfs(g[s][i]);
        }
        return;
    }
}

int main()
{
    int n;int m;
    cin >> n >> m;
    
    vector<int> p(n+1),x(m),y(m);
    vector<bool> flag(n+1,true);
    vector<bool> flag_(n+1,true);
    int size=0;
    
    rep(i,n)cin >> p[i+1];
    rep(i,m)cin >> x[i] >> y[i];

    rep(i,m){
        g[x[i]].push_back(y[i]);
        g[y[i]].push_back(x[i]);
    }
    FOR(i,n+1,1){
        if(!found[i]){
            dfs(i);
            
            while(!q.empty()){
                int a=q.front();
                
                if(flag[a]==true){
                    //cout << a << endl;
                    flag[a]=false;
                    r.push(a);
                }
                q.pop();
            }
            int b=r.size();
            rep(i,b){
                int a=r.front();
                r.pop();
                q.push(p[a]);
                r.push(a);
            }
            while(!q.empty()){
                int a=q.front();
                q.pop();
                if(flag[a]==true){
                    flag_[a]=false;
                }else if(flag_[a]==true){
                    flag[a]=true;
                }
            }
            while(!r.empty()){
                int a=r.front();
                r.pop();
                if(flag[a]==false){
                    flag_[a]=false;
                }
            }
        }

    }
    FOR(i,n+1,1){
        //cout << flag_[i] << endl;
        if(flag_[i]==true){
            size++;
        }
    }
    cout << size << endl;

    
}

Measured memory_bytes: 13892
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[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'};
char moji2[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'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(200001)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}
int A[MAX];

bool comp(int a,int b){
    return A[a] < A[b];
}

signed main(){
    int n;
    cin >> n;
    REP(i,n) cin >> A[i];
    int ind[n];
    REP(i,n) ind[i] = i;
    sort(ind,ind + n, comp);

    REP(i,n){
        if(i != ind[n-1]){
            cout << A[ind[n-1]] << endl;
        }
        else{
            cout << A[ind[n-2]] << endl;
        }
    }


}

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

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

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


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

int main() {
  int h,w,j;
  cin >>h>>w;

  
vector<int> a(h);
  int b[w*2];
 
  for(int i = 0; i < w*2; i++){
    cin>>b[i];
    while(j<h){
    if(b[i]==j+1) a[j]++;
      j++;
    }
  j=0;
  }
 
for(int k;k<h; k++)cout<<a[k]<<endl;
 

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define INF (2 << 28)
using namespace std;

int n, m;
int p[11111], c[555], e[555];

int main(){
    
    cin >> m >> n;
    for(int i = 0; i < m; i++) cin >> p[i];
    for(int i = 0; i < n; i++) cin >> c[i] >> e[i];
    sort(p, p + m, greater<int>());
    
    int dp[10001];
    fill_n(dp, 10001, INF); dp[0] = 0;
    for(int i  = 0; i < n; i++){
        for(int j = m; j >= 0; j--){
            if(dp[j] != INF) dp[min(m, j + c[i])] = min(dp[min(m, j + c[i])], dp[j] + e[i]);
        }
    }
    
    int sum = 0, maxi = 0;
    for(int i = 0; i < m; i++){
        sum += p[i];
        maxi = max(maxi, sum - dp[i + 1]);
    }
    cout << maxi << endl;
}

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

vector<ll> dp(100005,0);
vector<ll> dp1(100005, 0);
vector<vector<int>> t;
ll mod;

ll dfs(int nd, int parent)
{
  ll black = 1;

  for(auto adj : t[nd])
  {
    if(adj == parent) continue;
    ll ways = dfs(adj, nd);
    black = black*(ways + 1)%mod;
  }
  dp[nd] = black;
  return dp[nd];
}

void dfs1(int nd, int parent)
{
  auto I = find(t[nd].begin(), t[nd].end(), parent);
  if (I != t[nd].end()) t[nd].erase(I);

  if((int)t[nd].size() >= 1)
  {
    int n= t[nd].size();
    vector<ll> L(n, 0) , R(n, 0);
    L[0] = 1;
    R[n-1] = 1;
    for(int i=1; i<n; i++)
      L[i] = L[i-1] * (dp[t[nd][i-1]]+1) %mod;
    for(int i=n-2; i>=0; i--) 
      R[i] = R[i+1] * (dp[t[nd][i+1]]+1) % mod;

    for(int i=0; i<n; i++)
    {
      int y = t[nd][i];
      dp1[y] = (dp1[nd] +1) * L[i]%mod*R[i]%mod;
      dfs1(y, nd);
    }
  }
}

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

   t = vector<vector<int>>(n);
   for(int i=0, x,y; i<n-1; i++)
   {
    cin >> x>>y;
    --x, --y;
    t[x].push_back(y);
    t[y].push_back(x);
   }

   dfs(0,-1);
   dfs1(0,-1);

   for(int i=0; i<n; i++)
   {
    cout<<dp[i]*(dp1[i]+1)%mod<<endl;
   }

  return 0;
}


Measured memory_bytes: 19456
#include <stdio.h>
int main(void){
    unsigned int a=0,b=0,c=0;
    scanf("%d %d %d",&a,&b,&c);
    if(a==b){
        if(b==c)puts("1");
        if(b!=c)puts("2");
    }else if(a!=b){
        if(b==c)puts("2");
        if(b!=c && a!=c){
            puts("3");
        }else if(b!=c && a==c){
            puts("2");
        }
    }
    return 0;
}

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;
}

signed main() {
	ll a, b, c;
	vector<ll> v(3);

	cin >> v[0] >> v[1] >> v[2];

	sort(v.begin(), v.end(), greater<ll>());

	cout << v[0] * 10 + v[1] + v[2] << endl;
}

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

int cal(int r,int D,int x) {
	return r * x - D;
}

int main()
{
	int r, D, x;
	cin >> r >> D>>x;
	int i;
	for (i = 1; i <= 10; i++) {
		x = cal(r, D, x);
		cout << x << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for (int i = 0; i < (n); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x,n;cin >> x >> n;
    vector<int> p(n);
    vector<bool> b(105);
    rep(i,n){
      cin >> p[i];
      b[p[i]]=true;
    }
    int ans;
    int m=inf;
    rep(i,105){
      if(!b[i]){
        if(m>abs(i-x)){
          m=abs(i-x);
          ans=i;
        }
      }
    }
    cout << ans << endl;
}

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

int main()
{
	int N, D; cin >> N >> D;
	int ans = 0;
	ll X, Y;
	for (int i = 0; i < N; i++) {
		cin >> X >> Y;
		if (sqrtl(static_cast<ld>(X * X + Y * Y)) <= static_cast<ld>(D)) {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3672
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#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;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

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

  int A,B,C;
  cin>>A>>B>>C;
  int K;
  cin>>K;

  int ans=0;
  while(A>=B){
    B*=2;
    ans++;
  }
  while(B>=C){
    C*=2;
    ans++;
  }

  if(ans<=K) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 3688
#include <iostream>
#include <cstring>

using namespace std;

int main(){
	char c[105];
	int a = -1, l;
	cin>>c;
	l = strlen(c);
	for (int i = 0; i < l; i++){
		if (c[i] == 'C'){
			a = i;
			break;
		}
	}
	if (a == -1){
		cout<<"No"<<endl;
		return 0;
	}
	for (int i = a; i < l; i++){
		if (c[i] == 'F'){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define LargeNum 1000000007;
int main(){
    int N, a;
    map<int, bool> m;
    map<int, bool>::iterator it;
    cin >> N;
    rep(i, N){
        cin >> a;
        it = m.find(a);
        if (it==m.end()) m.insert(pair<int, bool>(a, true));
        else m.erase(it);
    }
    cout << m.size() << endl;
    return 0;
}


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

using namespace std;


int main(){
    int N=0;
    long ans=0;
    cin>>N;
    vector<long> Avec(N);
    vector<long> Bvec(N);

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

    }

long tmp=0;

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

        if((tmp+Avec[i])%Bvec[i]==0){
            continue;
        }else{
        ans+=Bvec[i]-(tmp+Avec[i])%Bvec[i];
        tmp+=Bvec[i]-(tmp+Avec[i])%Bvec[i];
        }

        
    
    }


    cout<<ans<<endl;

}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPP(i, n) for(int i = 1; i <= n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const ll MOD = 1000000007;

int main() {
    string s,t; cin >> s >> t;
    int n = s.length();
    vector<vector<int>> c1(26, vector<int>(26, -1));
    REP(i,n) {
        if(s[i]!=t[i]) c1[t[i]-97][s[i]-97] = 1;
        else c1[t[i]-97][s[i]-97] = 0;
    }
    vector<vector<int>> c2(26, vector<int>(26, -1));
    REP(i,n) {
        if(s[i]!=t[i]) c2[s[i]-97][t[i]-97] = 1;
        else c2[s[i]-97][t[i]-97] = 0;
    }
    bool ans = true;
    
    REP(i,26) {
        bool change = (find(c1[i].begin(), c1[i].end(), 1) != c1[i].end() ? 1 : 0);
        bool stay = (find(c1[i].begin(), c1[i].end(), 0) != c1[i].end() ? 1 : 0);
        int cnt = count(c1[i].begin(), c1[i].end(), 1);
        if(change&&stay || cnt>1) {
            ans = false;
            break;
        }
    }
    REP(i,26) {
        bool change = (find(c2[i].begin(), c2[i].end(), 1) != c2[i].end() ? 1 : 0);
        bool stay = (find(c2[i].begin(), c2[i].end(), 0) != c2[i].end() ? 1 : 0);
        int cnt = count(c2[i].begin(), c2[i].end(), 1);
        if(change&&stay || cnt>1) {
            ans = false;
            break;
        }
    }
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 776
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
#define mp  std::make_pair
#define ll long long int
#define abs(n) ((n>0)?(n):((n)*(-1)))
#define CEIL(a,b) (((a) + ((b)-1)) / (b))
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define VREP(v) for(std::vector<ll>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VALL(v) ((v).begin(),(v).end())
#define errln(v) cerr << (v) << endl;
#define println(v) cout << (v) << endl;

int main(int argc, const char * argv[]) {
	int N,X;
	cin >> N >> X;
	int min_m=2000,sum=0,m;

	REP(i,N){
		cin >> m;
		min_m = min(min_m,m);
		sum += m;
	}

	println(N + (X-sum)/min_m);

	return 0;

}



Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
using namespace std;
typedef long long ll; 
const int Max = 2e5 + 5;
ll n, k;
int a[Max];
bool cmp(int a, int b){
	return a > b;
}

int main(){
	cin >> n >> k;
	n %= k;
	cout << min(n, abs(n-k)) << endl;
	return 0;
}

Measured memory_bytes: 256
from itertools import permutations
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
a=0
b=0
i=0
for x in permutations(range(1,N+1)):
	i+=1
	if list(x)==A:
		a=i
	if list(x)==B:
		b=i
print(abs(a-b))


Measured memory_bytes: 3188
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		String t = sc.next();
// まずstrArraySubに1文字多い配列を作る
String[] strArray = new String[t.length()];
 String[] strArray2 = new String[t.length()];
            // 変数strの長さ分回す
            for (int i = 0; i < t.length(); i++) {
                // strの先頭から1文字ずつString型にして取り出す
                String str = String.valueOf(t.charAt(i));
                // 配列に順番に格納する
                strArray[i] = str;
            }
               StringBuffer buf = new StringBuffer();
          for (int i = 0; i < strArray.length; i++) {
                                          if(strArray[i].equals("?")){
                                            strArray2[i]="D";
                                          }else{
                                          strArray2[i]=strArray[i];
                                          }


              buf.append(strArray2[i]);
          }
      String str2= buf.toString();
		// 出力
		System.out.println(str2);
	}
}

Measured memory_bytes: 52300
#include <stdio.h>
#include <stdlib.h>

#define INF 1111111111 
#define KI_MAX (1 << 18)

int ki[KI_MAX * 2 - 1];

void ki_set(int idx, int value) {
	int pos = KI_MAX - 1 + idx;
	ki[pos] = value;
	do {
		pos = (pos - 1) / 2;
		ki[pos] = ki[pos * 2 + 1] < ki[pos * 2 + 2] ? ki[pos * 2 + 1] : ki[pos * 2 + 2];
	} while (pos > 0);
}
 
int ki_get_i(int idx, int qstart, int qend, int sstart, int send) {
	if (qend <= sstart || send <= qstart) {
		return INF;
	} else if (qstart <= sstart && send <= qend) {
		return ki[idx];
	} else {
		int smid = sstart + (send - sstart) / 2;
		int left = ki_get_i(idx * 2 + 1, qstart, qend, sstart, smid);
		int right = ki_get_i(idx * 2 + 2, qstart, qend, smid, send);
		return left < right ? left : right;
	}
}
 
int ki_get(int start, int end) {
	return start < end ? ki_get_i(0, start, end, 0, KI_MAX) : INF;
}
 
int N;
int a[271828];
 
int ec[271828];
int* es[271828];
 
void ae(int f, int t) {
	es[f] = realloc(es[f], sizeof(*es[f]) * (ec[f] + 1));
	if (es[f] == NULL) exit(2);
	es[f][ec[f]++] = t;
}
 
int kotae[271828];
 
int mareitaso(int query) {
	int l = 0, r = N + 99;
	while (l + 1 < r) {
		int m = l + (r - l) / 2;
		if (ki_get(m, N + 100) < query) l = m; else r = m;
	}
	return l;
}
 
void dfs(int node, int parent) {
	int neko = mareitaso(a[node]) + 1;
	int bak = ki_get(neko, neko + 1);
	int i;
	if (bak > a[node]) ki_set(neko, a[node]);
	kotae[node] = mareitaso(INF);
	for (i = 0; i < ec[node]; i++) {
		int next = es[node][i];
		if (next != parent) dfs(next, node);
	}
	ki_set(neko, bak);
}
 
int main(void) {
	int i;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 1; i <= N; i++) {
		if (scanf("%d", &a[i]) != 1) return 1;
	}
	for (i = 1; i <= N + 100; i++) ki_set(i, INF);
	for (i = 1; i <= N - 1; i++) {
		int u, v;
		if (scanf("%d%d", &u, &v) != 2) return 1;
		ae(u, v);
		ae(v, u);
	}
	dfs(1, 0);
	for (i = 1; i <= N; i++) {
		printf("%d\n", kotae[i]);
	}
	return 0;
}

Measured memory_bytes: 30664
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

ll cnt_digit(ll N) {
    ll ans = 0;
    while (N > 0) {
        N /= 10;
        ans += 1;
    }
    return ans;
}
int main() {
    ll N;
    cin >> N;
    ll ans = cnt_digit(N);
    for(ll i = 1; i*i <= N; i++) {
        if (N % i == 0)
            ans = min(ans, cnt_digit(N/i));
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <functional>
#include <set>
#define DB cerr<<"D"<<endl
#define pb push_back
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";}
template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";}
template<typename T> void caut(T a){cout<<"("<<a<<") ";}
using P=pair<double,int>;
const ll M = 998244353;
void add(ll& x, ll y) {x+=y; x%=M;}
vector<ll> sm(20005), inv(20005);
ll mod_pow(ll x, ll a) { ll an = 1; while(a > 0) { if (a&1) an = an * x % M; x = x * x % M; a >>= 1;} return an;}
void sm_build() {
	sm[0]=1;for(ll i=1;i<20005;i++) sm[i]=sm[i-1]*i%M;
	inv[20004]=mod_pow(sm[20004],M-2);for(ll i=20003;i>=0;i--) inv[i]=inv[i+1]*(i+1)%M;
}
ll ncr(ll n, ll r) {return sm[n] * inv[n-r] % M * inv[r] % M;}

int main() {
  sm_build();

  ll k,n; cin>>k>>n;
  ll dp[n+1]; fill(dp,dp+n+1,0); dp[0]=1;
  ll an[k+2]={};
  for(ll i=2;i<=k+1;i++) {
    ll lf = k+1-i; // 残ったサイコロの出目の数
    if (i%2==1) {
      // (1,1)や(2,2)が増える？
      ll ad[n+1]={};
      for(int j=0;j<n;j++) {
        add(ad[j+1],2*dp[j]);
      }
      for(int j=0;j<n;j++) {
        add(ad[j+1],ad[j]);
      }
      for(int j=0;j<=n;j++) {
        add(dp[j],ad[j]);
      }
      if (lf-1>=0) 
        for(int j=0;j<n;j++) {
          //cout<<n-j<<" "<<lf<<" "<<endl;
          add(an[i],dp[j]*ncr(n-j+lf-1,lf-1)); // n-j H lf
          //caut(an[i]);
        }
      add(an[i],dp[n]);
      //caut(an[i]);
    } else {
      // (3) % 6 を0つ
      if (lf-1>=0) {
        for(ll j=0;j<n;j++) {
          add(an[i],dp[j]*ncr(n-j+lf-1,lf-1)); // n-j H lf
          //caut(an[i]);
        }
        // 1つ
        for(ll j=0;j+1<n;j++) {
          //cout<<n-j<<" "<<lf<<" "<<endl;
          add(an[i],dp[j]*ncr(n-j-1+lf-1,lf-1));
          //caut(an[i],n-j-1+lf-1,lf-1);
        }
      }
      add(an[i],dp[n-1]+dp[n]);
      //caut(an[i]);
    }
  }
  for(int i=2;i<=k+1;i++) {
    cout<<an[i]<<endl;
  }
  for(int i=k;i>=2;i--) {
    cout<<an[i]<<endl;
  }
}

Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int exp();
int term();
int fact();
string s;
int id;

int main(void){
  int n;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> s;
    id = 0;
    cout << exp() << endl;
  }
}


int exp(){
  int res = term();
  while(1){
    char c = s[id];
    id++;
    if(c == '+') res += term();
    else if(c == '-') res -= term();
    else break;
  }
  return res;
}

int term(){
  int res = fact();
  while(1){
    char c = s[id];
    id++;
    if(c == '*') res *= fact();
    else if(c=='/') res /= fact();
    else break;
  }
  id--;
  return res;
}

int fact(){
  char c = s[id];
  id++;
  if(c == '(') return exp();
  if(c == '+') return fact();
  if(c == '-') return -fact();

  int res = c - '0';
  while(1){
    c = s[id];
    id++;
    if('0' <= c && c <= '9'){
      res *= 10;
      res += c - '0';
    }
    else break;
  }
  id--;
  return res;
}

Measured memory_bytes: 1208
#define _CRT_SECURE_NO_WARNINGS
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>

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

using namespace std;

int main() {
	/*int A, B, K;
	cin >> A >> B >> K;
	REP(i, K) {
		if (i % 2 == 0) {
			if (A % 2 == 1) {
				A -= 1;
				A /= 2;
				B += A;
			}
			else {
				A /= 2;
				B += A;
			}
		}
		else {
			if (B % 2 == 1) {
				B -= 1;
				B /= 2;
				A += B;
			}
			else {
				B /= 2;
				A += B;
			}
		}
	}

	cout << A << " " << B << endl;
	*/

	int N;
	vector<ll> A;
	ll x;
	cin >> N;
	REP(i, N) {
		cin >> x;
		A.push_back(x);
	}
	sort(A.begin(), A.end());

	int r = N / 2, l = r - 1;
	ll ans = 0;
	if (N % 2 == 0) {
		FOR(i, r + 1, N) {
			ans += 2 * A[i];
		}
		REP(i, l) {
			ans += -2 * A[i];
		}
		ans += A[r];
		ans -= A[l];
	}
	else {
		FOR(i, r + 2, N) {
			ans += 2 * A[i];
		}
		REP(i, l) {
			ans += -2 * A[i];
		}
		ans += max(-2 * A[l] + A[r] + A[r + 1], 2 * A[r + 1] - A[r] - A[l]);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1400
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int i = 1;
		do{
			int x = i;
			if(x%3==0){
				System.out.print(" "+i);
			}else{
				do{
					if(x%10==3) {System.out.print(" "+i); break;}
					x /= 10;
				}while(x!=0);
			}
		}while((++i)<=n);
		System.out.println();
	}
}


Measured memory_bytes: 28676
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  int d = a / b;
  int r = a % b;
  double f = 1.0 * a / b;
  cout << d << " " << r << " " << fixed << setprecision(5) << f << endl;
  return 0;
}


Measured memory_bytes: 3300
A,B = map(int,input().split())
ans = 1
if A-B == 0:
    for i in range(1,A+1):
        ans = (ans * i) % (10**9+7)
    for i in range(1,B+1):
        ans = (ans * i) % (10**9+7)
    print(ans*2%1000000007)
elif abs(A-B) == 1:
    for i in range(1,A+1):
        ans = (ans * i) % (10**9+7)
    for i in range(1,B+1):
        ans = (ans * i) % (10**9+7)
    print(ans%1000000007)
else:
    print(0)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a,b;
    int c=0;
    bool f=false;
    while(n--){
        cin>>a>>b;
        if(a==b) c++;
        else c=0;
        if(c>=3) f=true;
    }
    if(f) cout<<"Yes";
    else cout<<"No";


}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define print(x) cerr << (#x) << "is "<< x << "\n"
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10;

ll arr[N],n;

int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	f(i,0,n){
		cin >> arr[i];
	}
	multiset<int> s;
	f(i,0,n){
		auto k = s.lower_bound(arr[i]);
		if(k==s.begin()){
			s.insert(arr[i]);
		}else{
			k--;
			s.erase(k);
			s.insert(arr[i]);
		}
	}
	cout << (int)s.size() << '\n';
	return 0;
}

Measured memory_bytes: 5760
# -*- coding: UTF-8 -*-
import math
import bisect
# f=open("test.txt")
# line=f.readline()
# lists=[]
# while line:
#     lists.append("".join(list(line)[:-1]))
#     line=f.readline()
# 
# f.close()
# 
# s=lists[0]
# t=lists[1]

s=input()
t=input()

alpha=list("abcdefghijklmnopqrstuvwxyz")

dic_s={alpha[i]:0 for i in range(26)}
dic_t={alpha[i]:0 for i in range(26)}

a={alpha[i]:[] for i in range(26)}
b={alpha[i]:[] for i in range(26)}


for i in range(len(s)):
  
    if dic_s[s[i]]==0:
        dic_s[s[i]]=+1
    a[s[i]].append(i+1)


for j in range(len(t)):
    
    if dic_t[t[j]]==0:
        dic_t[t[j]]=+1
    b[t[j]].append(j+1)
for i in range(26):
	a[alpha[i]].append(10**9)
flag=True

for i in range(26):
    if dic_t[alpha[i]]>0 and dic_s[alpha[i]]==0:
        flag=False

place=[0,0]

if flag:
    #文字を構成できる場合
    for i in range(len(t)):
        string=t[i]
        num=bisect.bisect_right(a[string],place[0])  
        if a[string][num]==10**9:
            place[1]+=1
            place[0]=a[string][0]
        else:
            place[0]=a[string][num]
  

    print(place[0]+place[1]*len(s))

else:
    #構成できない場合
    print(-1)



Measured memory_bytes: 11764
import java.util.*;
import java.io.*;

public class Main{

	public static void main(String[] args) throws IOException {
		println(Math.min(readInt(), readInt()) + Math.min(readInt(), readInt()));
		exit();
	}

	final private static int BUFFER_SIZE = 1 << 16;
	private static DataInputStream din = new DataInputStream(System.in);
	private static byte[] buffer = new byte[BUFFER_SIZE];
	private static int bufferPointer = 0, bytesRead = 0;
	static PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

	public static String readLine() throws IOException {
		byte[] buf = new byte[64]; // line length
		int cnt = 0, c;
		while ((c = Read()) != -1) {
			if (c == '\n')
				break;
			buf[cnt++] = (byte) c;
		}
		return new String(buf, 0, cnt);
	}

	public static String read() throws IOException {
		byte[] ret = new byte[1024];
		int idx = 0;
		byte c = Read();
		while (c <= ' ') {
			c = Read();
		}
		do {
			ret[idx++] = c;
			c = Read();
		} while (c != -1 && c != ' ' && c != '\n' && c != '\r');
		return new String(ret, 0, idx);
	}

	public static int readInt() throws IOException {
		int ret = 0;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();
		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');

		if (neg)
			return -ret;
		return ret;
	}

	public static long readLong() throws IOException {
		long ret = 0;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();
		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');
		if (neg)
			return -ret;
		return ret;
	}

	public static double readDouble() throws IOException {
		double ret = 0, div = 1;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();

		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');

		if (c == '.') {
			while ((c = Read()) >= '0' && c <= '9') {
				ret += (c - '0') / (div *= 10);
			}
		}

		if (neg)
			return -ret;
		return ret;
	}

	private static void fillBuffer() throws IOException {
		bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
		if (bytesRead == -1)
			buffer[0] = -1;
	}

	private static byte Read() throws IOException {
		if (bufferPointer == bytesRead)
			fillBuffer();
		return buffer[bufferPointer++];
	}

	public void close() throws IOException {
		if (din == null)
			return;
		din.close();
	}

	static void print(Object o) {
		pr.print(o);
	}

	static void println(Object o) {
		pr.println(o);
	}

	static void flush() {
		pr.flush();
	}

	static void println() {
		pr.println();
	}

	static void exit() throws IOException {
		din.close();
		pr.close();
		System.exit(0);
	}
}


Measured memory_bytes: 22868
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

struct MinimumCostFlow {
	using Flow = int;
	using Cost = double;
	const Cost kInfCost = INF;
	struct Edge {
		int to, rev;
		Flow cap;
		Cost cost;
		Edge() {}
		Edge(int to, int rev, Flow cap, Cost cost) :to(to), rev(rev), cap(cap), cost(cost) {}
	};
	int n;
	vector<vector<Edge>> g;
	vector<Cost> dist;
	vector<int> prevv, preve;
	MinimumCostFlow(int n) :n(n), g(n), dist(n), prevv(n), preve(n) {}
	void addArc(int from, int to, Flow cap, Cost cost) {
		g[from].emplace_back(to, (int)g[to].size(), cap, cost);
		g[to].emplace_back(from, (int)g[from].size() - 1, Flow(), -cost);
	}
	// s??????t????????????f???????°??????¨???
	// ??????????????´?????? kInfCost
	Cost minimumCostFlow(int s, int t, Flow f) {
		Cost total = Cost();
		while (f > 0) {
			// Bellman-Ford
			fill(dist.begin(), dist.end(), kInfCost);
			dist[s] = 0;
			bool update = true;
			while (update) {
				update = false;
				for (int v = 0; v < n; v++) {
					if (dist[v] == kInfCost)continue;
					for (int i = 0; i < g[v].size(); i++) {
						Edge &e = g[v][i];
						if (e.cap > Flow() && dist[e.to] > dist[v] + e.cost) {
							dist[e.to] = dist[v] + e.cost;
							prevv[e.to] = v;
							preve[e.to] = i;
							update = true;
						}
					}
				}
			}
			// ????????\???????????????
			if (dist[t] == kInfCost)
				return kInfCost;
			// ?????????????????£??????????????????
			Flow d = f;
			for (int v = t; v != s; v = prevv[v])
				d = min(d, g[prevv[v]][preve[v]].cap);
			f -= d;
			total += dist[t] * d;
			for (int v = t; v != s; v = prevv[v]) {
				Edge &e = g[prevv[v]][preve[v]];
				e.cap -= d;
				g[v][e.rev].cap += d;
			}
		}
		return total;
	}
};


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	for (int N, K; cin >> N >> K&&N;) {
		vector<int> x(N), y(N), z(N); rep(i, 0, N) {
			cin >> x[i] >> y[i] >> z[i];
		}
		MinimumCostFlow mcf(N + N + 2);
		int s = mcf.n - 2, t = s + 1;
		auto distance = [&](int i, int j) {
			return sqrt((x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j]) + (z[i] - z[j])*(z[i] - z[j]));
		};
		rep(i, 0, N)rep(j, 0, N) {
			if (z[i] >= z[j])continue;
			mcf.addArc(i, j + N, 1, distance(i, j));
		}
		rep(i, 0, N) {
			mcf.addArc(s, i, 1, 0);
			mcf.addArc(i + N, t, 1, 0);
		}
		auto res = mcf.minimumCostFlow(s, t, max(0, N - K));
		cout << (res == mcf.kInfCost ? -1 : res) << endl;
	}
	return 0;
}

Measured memory_bytes: 3520
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef map<int, int> mii;
typedef map<char,int> mci;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vii;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define F first
#define S second
#define in insert
const int INF = 1e9 + 7;
int main(){
    string s; cin>>s;
    if(s=="Sunny") cout<<"Cloudy";    
    if(s=="Cloudy") cout<<"Rainy";
    if(s=="Rainy") cout<<"Sunny";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
#define fir first
#define sec second
typedef long long ll;
////////////////////////////////////////////////////////////

int main(){
	int a , b , c;
	cin >> a >> b >> c;
	if( b / a > c ) cout << c << endl;
	else cout << b / a << endl;
	ret 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>

using namespace std;

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

typedef long long ll;

int w[110];
int v[110];
ll dp[110][100010];

void Main()
{
	int N, W; cin >> N >> W;
	rep(i,N) cin >> w[i] >> v[i];

	memset(dp, 0, sizeof(dp));
	rep(i,N) {
		rep(j,W + 1) {
			dp[i + 1][j] = dp[i][j];
			if (j >= w[i]) {
				dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
			}
		}
	}
	ll res = -1;
	rep(i,W + 1) {
		res = max(res, dp[N][i]);
	}
	cout << res << endl;
}

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


Measured memory_bytes: 86272
h=int(input())
#n,k=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

import math
ans=1
count=1
while h!=1:
    count*=2
    ans+=count
    h=math.floor(h/2)
    
print(ans)



Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <cmath>
#include <bitset>
#include <queue>
#include <set>
#include <numeric>
#include <unordered_set>
#include <iomanip>
#include <string>

using namespace std;

typedef long long ll;
typedef long double ld;

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

	ll n, d, a;
	cin >> n >> d >> a;
	vector<pair<ll, ll>> v(n);
	for (auto &x : v)
	{
		cin >> x.first >> x.second;
		x.second = (x.second + a - 1) / a;
	}
	sort(v.begin(), v.end());

	vector<ll> bit(n+1);
	auto update =[&](ll idx, ll val){
		for (++idx; idx <=n; idx += idx & -idx){
			bit[idx] += val;
		}
	};
	auto query = [&](ll idx){
		ll res = 0;
		for (++idx; idx > 0; idx -= idx & -idx){
			res += bit[idx];
		}
		return res;
	};
	auto range_update = [&](ll l, ll r, ll val){
		update(l, val);
		update(r+1, -val);
	};
	for (ll i =0;i<n;++i){
		range_update(i, i, v[i].second);
	}

	ll tot = 0;
	for (ll i = 0; i < n; ++i)
	{
		ll h = query(i);
		if (h <= 0)
			continue;
		ll lo = 0, hi = n - 1, ans = -1;
		while (lo <= hi)
		{
			ll mid = lo + (hi - lo) / 2;
			if (v[mid].first <= v[i].first + 2 * d)
			{
				ans = mid;
				lo = mid + 1;
			}
			else
			{
				hi = mid - 1;
			}
		}
		range_update(i, ans, -h);
		tot += h;
	}
	cout << tot;
}

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

#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
int main(){
  int n;cin>>n;
  if(n==1){
    cout<<"Yes"<<endl;
    cout<<2<<endl;
    cout<<1<<" "<<1<<endl;
    cout<<1<<" "<<1<<endl;
    return 0;
  }
  bool flag=false;
  int ans[5000][5000]={};
  int a,b;
  n*=2;
  for(int i=2;i<=sqrt(n*2);i++){
    if(n%i==0&&(n/i==i+1)){
      a=n/i;b=i;
      flag=true;
      int num=n/i;
      int now=1;
      for(int j=0;j<i;j++){
	for(int k=j;k<i;k++){
	  ans[j][k]=now;
	  ans[k+1][j]=now;
	  now++;
	}
      }
    }
  }
  if(flag){
    cout<<"Yes"<<endl;
    cout<<a<<endl;
    for(int i=0;i<a;i++){
      cout<<b<<" ";
      for(int j=0;j<b;j++){
	cout<<ans[i][j];
	if(j!=b-1)
	  cout<<" ";
      }
    cout<<endl;
  }

  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


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

long long gcd(long long a,long long b){
	if(a < b) swap(a,b);
	while(b){
		long long tmp = b;
		b = a % b;
		a = tmp;
	}
	return a;
}

int main(){
	long long n,x;
	cin >> n >> x;
	cout << 3 * (n - gcd(n,x)) << endl;
}

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

#define o cout<<"Hello did you expect this?"<<endl;
#define ll long long
#define pb push_back
#define mp make_pair//with Z
#define F first
#define S second

using namespace std;

const int N = 6e6 + 100;
const int mod = 1e9 + 7;

void hey () {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
int a[100][100];
int c[100];
int pref[100];
int main () {
	hey();
	int n, m, x;
	cin >> n >> m >> x;
	for (int i = 1; i <= n; i++) {
		cin >> c[i];
		for (int j = 1; j <= m; j++) {
			cin >> a[i][j];
		}
	}
	int ans = 1e9;
	for (int i = 1; i < (1 << n); i++) {
		int kol = 0;
		memset(pref, 0, sizeof pref);
		for (int k = 1; k <= n; k++) {
			if ((1 << (k - 1)) & i) {
				kol += c[k];
				for (int j = 1; j <= m; j++) {
					pref[j] += a[k][j];
				}
			}
		}
		bool bruh = 0;
		for (int j = 1; j <= m; j++) {
			if (pref[j] < x) {
				bruh = 1;
			}
		}
		if (!bruh) {
			ans = min(ans, kol);
		}
	}
	cout << (ans == 1e9 ? -1 : ans);
}


Measured memory_bytes: 3652
// abc153_a
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(int argc, char *argv[])
{
  int h,a;
  cin>>h>>a;
  if (h%a==0){
    cout<<h/a<<endl;
  }else{
    cout<<h/a+1<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#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;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	map<ll, int> mp;
	vector<ll> x(n + 1);
	x[0] = 0;
  mp[0]++;
	for (int i = 1; i < n + 1; i++) {
		x[i] = x[i-1] + a[i - 1];
		mp[x[i]]++;
	}
	ll ans = 0;
	for (auto i = mp.begin(); i != mp.end(); i++) {
		ans += ((ll)i->second*((ll)i->second - 1))/2;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 15872
n, m = map(int, input().split())
x = list(map(int, input().split()))

ans = 0

if n >= m:
    print("0")
else:
    x.sort()
    sub = []
    for i in range(m-1):
        sub.append(x[i+1]-x[i])

    sub.sort()

    for i in range(m-n):
        ans += sub[i]


    print(ans)

Measured memory_bytes: 13968
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		int N=in.nextInt();
		while(N-->0)
		{
			double xp1=in.nextDouble(),yp1=in.nextDouble();
			double xp2=in.nextDouble(),yp2=in.nextDouble();
			double xp3=in.nextDouble(),yp3=in.nextDouble();
			double xk=in.nextDouble(),yk=in.nextDouble();
			double xs=in.nextDouble(),ys=in.nextDouble();
			int k=0;
			if(judge(xp1,yp1,xp2,yp2,xk,yk,xs,ys))//壁と交差する
				k++;
			if(judge(xp2,yp2,xp3,yp3,xk,yk,xs,ys))
				k++;
			if(judge(xp3,yp3,xp1,yp1,xk,yk,xs,ys))
				k++;
			System.out.println(k==1 ? "OK":"NG");
		}
	}
	
	static boolean judge(double x1,double y1,double x2,double y2,double x3,double y3,double x4,double y4)
	{
		double jc1=(x1-x2)*(y3-y1)+(y1-y2)*(x1-x3);
		double jd1=(x1-x2)*(y4-y1)+(y1-y2)*(x1-x4);
		double jc2=(x3-x4)*(y1-y3)+(y3-y4)*(x3-x1);
		double jd2=(x3-x4)*(y2-y3)+(y3-y4)*(x3-x2);
		return jc1*jd1<0 && jc2*jd2<0;
	}
}

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

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

    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            if (a == i * j) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1e9+7;
using namespace std;
typedef pair<int,int> pii;
int first_(int n){
    int ret;
    while(n>0){
        ret = n%10;
        n/=10;
    }
    return ret;
}
int digit(int n){
    int ret = 0;
    while(n>0){
        n/=10;
        ret++;
    }
    return ret;
}
int main(){
    long long ans = 0;
    int n;
    cin >> n;
    int keta = digit(n);
    int nfirst = first_(n);
    int nlast = n%10;
    int naka = (n/10) - (nfirst*pow(10,keta-2));
    //cout << keta << " " << nfirst << " " << nlast << " " << naka << endl;
    for(int i = 1;i<=n;i++){
        int tmp = i;
        int last = first_(tmp);
        int first = tmp%10;
        if(first == last && first<=n) ans++;
        if(first!=0 && keta!=1){
            for(int j = 2;j<=6;j++){
                if(keta>j) ans+=pow(10,j-2);
                else{
                    if(first<nfirst) ans+=pow(10,j-2);
                    else if(first==nfirst){
                        if(nlast>=last) ans+=(naka+1);
                        else ans+=(naka);
                    }
                    break;
                }
            }            
        }
        //cout << tmp << " " << ans << endl;
    }
    cout << ans << endl;
}

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

string S,T;
int i,j;//count
int N;//length

void imput()
{
  cin>>S>>T;
  N=S.length();
}

void solve()
{
  for(i=0;i<N;i++){
    if(S.at(i)!=T.at(i))
      j++;
  }
  cout<<j<<endl;
}

int main()
{
imput();
solve();
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int ctoi(char c){
    return (int)(c - '0');
}

int main() {
    int D;
    ll G;
    cin >> D >> G;

    vector<vector<int>> data(D, vector<int>(2));
    ll point;
    int solved, ans;
    bool isOK;

    rep(i, D){
        int p, c;
        cin >> p >> c;
        data[i] = {p, c};
    }

    ans = INF;
    for(int i = (1 << D) - 1; i >= 0; i--){
        solved = 0;
        point = 0;
        isOK = false;
        bitset<10> bit(i);
        rep(j, D){
            if(bit.test(j)){
                point += ((D - j) * 100 * data[D - 1 - j][0] + data[D - 1 - j][1]);
                solved += data[D - 1 - j][0];
            }
        }

        rep(j, D){
            if(point >= G){
                isOK = true;
                break;
            }
            if(!bit.test(j)){
                int forpt;
                forpt = (G - point) / (D - j) / 100;
                if(forpt > data[D - 1 - j][0] - 1){
                    break;
                } else {
                    isOK = true;
                    solved += forpt;
                }
            }
        }

        if(isOK){
            ans = min(ans, solved);
        } 

    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <deque>
#include <iostream>
#include <iomanip>
#include <locale>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int INT_MAX_SQRT = sqrt(INT_MAX);
int pwi(int x, int p) {
    if (p == 0) return 1;
    if (p == 1) return x;
    int tmp = pwi(x, p / 2);
    if (tmp > INT_MAX_SQRT) return 0;  // overflow
    if (p % 2 == 0)
        return tmp * tmp;
    else
        return tmp * tmp * x;
}

long LONG_MAX_SQRT = sqrt(LONG_MAX);
long pwl(long x, long p) {
    if (p == 0) return 1;
    if (p == 1) return x;
    long tmp = pwl(x, p / 2);
    if (tmp > LONG_MAX_SQRT) return 0;  // overflow
    if (p % 2 == 0)
        return tmp * tmp;
    else
        return tmp * tmp * x;
}

map<long, long> factorization(long N) {
    map<long, long> res;
    long SQRT_N = ceil(sqrt(N));
    for (long i = 2; i < SQRT_N; i++) {
        while (N % i == 0) {
            if (res.find(i) == res.end()) {
                res[i] = 1;
            } else {
                res[i] += 1;
            }
            N /= i;
        }
    }
    if (N > SQRT_N) res[N] = 1;
    return res;
}

void debug_vec(string name, vector<long> vec) {
    cout << name << endl;
    for (auto e: vec) cout << e << endl;
}

void debug_mat(string name, vector<vector<long>> mat) {
    cout << name << endl;
    for (auto vec: mat) {
        for (auto e: vec) cout << e << "   ";
        cout << endl;
    }
}

int main() {
    const long DIV = 998244353;

    long A, B, C, D;
    cin >> A >> B >> C >> D;

    long X = C - A;
    long Y = D - B;

    vector<vector<long>> dp(X + 1, vector<long>(Y + 1, 1));

    for (long x = 1; x <= X; x++) {
        dp[x][0] = (dp[x - 1][0] * B) % DIV;
    }
    for (long y = 1; y <= Y; y++) {
        dp[0][y] = (dp[0][y - 1] * A) % DIV;
    }

    for (long x = 1; x <= X; x++) {
        for (long y = 1; y <= Y; y++) {
            dp[x][y] = (
                   dp[x - 1][y] * (B + y) % DIV     +
                   dp[x][y - 1] * (A + x) % DIV     -
                   (dp[x - 1][y - 1] * (A + x - 1) % DIV) * (B + y - 1) % DIV
                ) % DIV;
        }
    }

    if (dp[X][Y] < 0) dp[X][Y] += DIV;

    cout << dp[X][Y] << endl;

    return 0;
}


Measured memory_bytes: 73512