akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,x,j,k,cnt=0,key=0;
    cin>>n;
    vector<int>v;
    for(i=0;i<n;i++)
    {
        cin>>x;
        v.push_back(x);
    }
    for(k=0;k<v.size();k++)
    {
        cout<<v[k];
        if(k!=v.size()-1)
        {
            cout<<" ";
        }
    }
    cout<<endl;
    for(i=1;i<v.size();i++)
    {
        key = v[i];
        j=i-1;
        while(j>=0&&v[j]>key)
        {

            v[j+1]=v[j];
            j--;

        }

        v[j+1]=key;
        for(k=0;k<v.size();k++)
    {
        cout<<v[k];
        if(k!=v.size()-1)
        {
            cout<<" ";
        }
    }
    cout<<endl;
    }

    return 0;

}





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

using namespace std;

int main(){

    int a[3];

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

    int temp;

    for (int c = 0; c < sizeof(a)/4; ++c) {
        for (int b = 0; b < sizeof(a)/4; ++b) {
            if(a[c] < a[b]){
                temp = a[c];
                a[c] = a[b];
                a[b] = temp;
            }
        }
    }

    cout << a[0] << " " << a[1] << " " << a[2] <<endl;

    return 0;

}

Measured memory_bytes: 3096
#include<iostream>
#include<string>
#include<vector>
#include<array> 
#include<algorithm>
#include <sstream>
using namespace std;


std::vector<std::string> split(const std::string& input, char delimiter)
{
    std::istringstream stream(input);

    std::string field;
    std::vector<std::string> result;
    while (std::getline(stream, field, delimiter)) {
        result.push_back(field);
    }
    return result;
}

int main()
{
    // 判定配列
    vector<int> vecCheck{ 5, 7, 5 };

    // 入力
    //string input;
    //cin >> input;

    string input1, input2, input3;
    cin >> input1 >> input2 >> input3;

    std::vector<int> vecInput;
    vecInput.push_back(atoi(input1.c_str()));
    vecInput.push_back(atoi(input2.c_str()));
    vecInput.push_back(atoi(input3.c_str()));

    // 入力を分解
    // 入力をintにキャスト

    //for (const std::string& s : split(input, ','))
    //{
    //    std::cout << s << std::endl;
    //}

    // 配列長さチェック
    if(vecInput.size() != vecCheck.size())
    {
        std::cout << "NO" << std::endl;
    }

    // 入力配列でループ
    for(int i : vecInput)
    {
       auto resultFind = find( vecCheck.begin(), vecCheck.end(), i );
       if( resultFind != vecCheck.end() )
       {
           vecCheck.erase(resultFind);
       }
       else
       {
           std::cout << "NO" << std::endl;
           return 0;
       }
    }

    std::cout << "YES" << std::endl;

    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int         long long
#define mod         1000000007
#define FAST        ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f(i,n)      for(int i=0;i<n;i++)
#define fp(i,k,n)   for(int i=k;i<=n;i++)
#define fr(i,k,n)   for(int i=k;i>=n;i--)
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define dbg(x)      cout << (#x) << " is " << (x) << '\n' 
#define F           first
#define S           second
#define sz(x)       (int)(x).size()
#define lb          lower_bound
#define ub          upper_bound
#define mems(x)     memset(x,0,sizeof(x))
#define all(a)      a.begin(),a.end()
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
/*---------------------------------------------------------------------------------------------------*/

const int MX=10e3+5;
int mat[MX][MX];
int vis[MX];
int dx[2]={0,1};
int dy[2]={1,0};
int h,w;
int dp[MX][MX];

bool isValid(int x,int y)
{
    if(x<1 || y<1 || mat[x][y]==0)
        return false;
    return true;
}

int bfs(int x,int y)
{
    if(!isValid(x,y))
        return 0;
    if(x==1 && y==1)
        {
            return 1;
        }
    if(dp[x][y]!=-1)
        return dp[x][y];
    dp[x][y]=0;
    dp[x][y]=bfs(x,y-1)%mod + bfs(x-1,y)%mod;
    dp[x][y]%=mod;
    return dp[x][y];
}

void solve()
{
  cin >> h >> w;
  fp(i,1,h)
  {
      string s;
      cin >> s;
      fp(j,1,w)
      {
          dp[i][j]=-1;
          if(s[j-1]=='.')
            mat[i][j]=1;
           else
            mat[i][j]=0;
      }
  }
  cout << bfs(h,w) << '\n';
   
} 

signed main()
{
  FAST
  int T=1;
//   cin >> T;
  while(T--)
  {
    solve();
  }
  return 0;
}


Measured memory_bytes: 27360
def solve():
    n, k = map(int, input().split())
    if n % k == 0:
        print(0)
    else:
        if n - k > 0:
            r = n % k
            d = abs(r - k)
            print(min(r, d))
        else:
            d = abs(n - k)
            print(min(n, d))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3060
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C - Attack Survival
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;

/* typedef */

/* global variables */

int cs[MAX_N];

/* subroutines */

/* main */

int main() {
  int n, k, q;
  scanf("%d%d%d", &n, &k, &q);

  for (int i = 0; i < q; i++) {
    int ai;
    scanf("%d", &ai);
    cs[--ai]++;
  }

  for (int i = 0; i < n; i++) {
    if (q - cs[i] < k) puts("Yes");
    else puts("No");
  }
  return 0;
}


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

int func(int,int);
int A[2000],n;

int main(){
  int i,j,q,M;

  scanf("%d",&n);
  if(n>20) exit(2);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  scanf("%d",&q);
  if(q>200)exit(2);
  for(i=0;i<q;i++){
    scanf("%d",&M);
    if(func(0,M)==1) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

int func(int i,int m){
  int num;
  if(m==0) return 1;
  else if(m<0) return 0;
  if(n<=i) return 0; // 見つからなかった
  num = func(i+1,m-A[i]);
  if(num == 1)return 1;
  num = func(i+1,m);
  if(num == 1)return 1;
  return num;
}



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

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

  std::string hon[] = {
    "pon",
    "pon",
    "hon",
    "bon",
    "hon",
    "hon",
    "pon",
    "hon",
    "pon",
    "hon",
  };
  std::cout << hon[n%10] << std::endl;
  return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int n;
struct edge { int to,id; };
vector<edge> G[1 << 17];
bool used[1 << 17];
ll num[1 << 17];
int c[1 << 17];
ll ans[1 << 17];

ll s[1 << 17];

bool used2[1 << 17];
ll dfs(ll v) {
	used2[v] = true;
	ll res = 0;
	rep(j, G[v].size()) {
		int to = G[v][j].to, id = G[v][j].id;
		if (used2[to])continue;
		res += dfs(to);
		res += ans[id] * num[to];
	}
	return res;
}
ll calc(int fr,int to) {
	used2[fr] = true; used2[to] = true;
	ll sum = dfs(fr) + dfs(to);
	return (s[fr] - sum) / (n / 2);
}
int main() {
	cin >> n;
	rep(i, n - 1) {
		int a, b; cin >> a >> b; a--; b--;
		G[a].push_back({ b,i });
		G[b].push_back({ a,i });
	}
	rep(i, n) {
		cin >> s[i];
		c[i] = G[i].size();
		num[i] = 1;
	}
	queue<int> q;
	rep(i, n) {
		if (c[i] == 1) {
			q.push(i);
		}
	}
	bool rest = false;
	int mid, mx, mto;
	while (!q.empty()) {
		int x = q.front(); q.pop();
		used[x] = true;
		if (n - 2 * num[x] == 0) {
			mx = x;
			rest = true;
			rep(j, G[x].size()) {
				int to = G[x][j].to;
				int id = G[x][j].id;
				if (used[to])continue;
				mto = to; mid = id;
			}
			continue;
		}
		rep(j, G[x].size()) {
			int to = G[x][j].to;
			int id = G[x][j].id;
			if (used[to])continue;
			c[to]--;
			if (c[to] == 1) {
				q.push(to); c[to] = -1;
			}
			num[to] += num[x];
			ans[id] = (s[x] - s[to]) / (n - 2 * num[x]);
		}
	}
	if (rest) {
		ans[mid]=calc(mx, mto);
	}
	rep(i, n - 1) {
		cout << ans[i] << endl;
	}
	//stop
	return 0;
}


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

int main(){
  int n,l;
  cin >> n >> l;
  int moto = 0;
  for(int i = 1;i <= n;i++){
    moto += l+i-1;
  }
  int sa = 100000000;
  int result;
  for(int i = 1;i <= n;i++){
    int azi = moto - (l+i-1);
    if(sa > abs(moto - azi)){
      result = i;
      sa = abs(moto - azi);
    }
  }
  int kekka = 0;
  for(int i = 1;i <= n;i++){
    if(i == result){
      continue;
    }
    else{
      kekka += l+i-1;
    }
  }
  cout << kekka << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
 
int main(){
  ll N, D, X;
  cin >> N >> D >> X;
  vector<ll> as(N, 0);
  for (int i = 0; i < N; i++){
    cin >> as.at(i);
  }
  ll count = 0;
  for (int i = 0; i < N; i++){
    int j = 0;
    while (j < D){
      count++;
      j += as.at(i);
    }
  }
  cout << count + X << endl;
}

Measured memory_bytes: 256
#include <stdio.h> 
    #include <stdlib.h>    
    	int main(void){
    	int x;
    	char a;
    	scanf("%d",&x);
    	scanf(" %c", &a);
    		if(1<= x || 3000>= x){
    			if(x < 1200){
    			printf("ABC\n");
    			return 0;
      		}else{
      		printf("ARC\n");
      		return 0;
      		}	
      	}else{
      		exit(1);
      	}
    	}

Measured memory_bytes: 128
N = gets.to_i
S = gets.chomp
def fill(r)
	(2 .. N - 1).each{|i|
		if S[i - 1] == "o" and r[i - 1] == "S"
			r[i] = r[i - 2]
		elsif S[i - 1] == "x" and r[i - 1] == "S"
			r[i] = r[i - 2] =="S" ? "W" : "S"
		elsif S[i - 1] == "o" and r[i - 1] == "W"
			r[i] = r[i - 2] == "S" ? "W" : "S"
		else
			r[i] = r[i - 2]
		end
	}
end

def check(r)
	if S[0] == "o" and r[0] == "S"
		return false if r[N - 1] != r[1]
	elsif S[0] == "x" and r[0] == "S"
		return false if r[N - 1] == r[1]
	elsif S[0] == "o" and r[0] == "W"
		return false if r[N - 1] == r[1]
	else
		return false if r[N - 1] != r[1]
	end
	if S[N - 1] == "o" and r[N - 1] == "S"
		return false if r[0] != r[N - 2]
	elsif S[N - 1] == "x" and r[N - 1] == "S"
		return false if r[0] == r[N - 2]
	elsif S[N - 1] == "o" and r[N - 1] == "W"
		return false if r[0] == r[N - 2]
	else
		return false if r[0] != r[N - 2]
	end
	true
end

r = Array.new(N)
r[0] = "S"
r[1] = "S"
fill(r)
if check(r)
	puts r.join
	exit
end
r = Array.new(N)
r[0] = "S"
r[1] = "W"
fill(r)
if check(r)
	puts r.join
	exit
end
r = Array.new(N)
r[0] = "W"
r[1] = "S"
fill(r)
if check(r)
	puts r.join
	exit
end
r = Array.new(N)
r[0] = "W"
r[1] = "W"
fill(r)
if check(r)
	puts r.join
	exit
end
puts -1


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


int main()
{
  int N, D;
  string X, Y;

  cin >> N;
  cin >> X;
  cin >> D;

  Y = X;
  for(int i = 0; i < N; i++) {
    if(D > 0 && X[i] == '0') {
      --D;
      Y[i] = '1';
    }
  }
  for(int i = X.size() - 1; i >= 0; i--) {
    if(D > 0 && X[i] == '1') {
      --D;
      Y[i] = '0';
    }
  }
  cout << Y << endl;
}

Measured memory_bytes: 1208
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <cstring>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define vi vector < int >
#define vll vector < long long >
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))
#define fname "searching"

const int inf = (int)1e9;
const ll INF = (ll)1e18;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int mod = (int)1e9 + 7;

int n;
int a[5][110];
int dp[5][110];

int solve(){
    cin >> n;
    for(int i = 0; i < 2; ++i){
        for(int j = 0; j < n; ++j){
            cin >> a[i][j];
        }
    }
    dp[0][0] = a[0][0];
    for(int i = 1; i < n; ++i){
        dp[0][i] = dp[0][i - 1] + a[0][i];
    }
    dp[1][0] = a[0][0] + a[1][0];
    for(int j = 1; j < n; ++j){
        dp[1][j] = max(dp[1][j - 1], dp[0][j]) + a[1][j];
    }
    return dp[1][n - 1];
}

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

    cout << solve() << "\n";
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
//const long long MOD = 998244353;
const long long INF_LL = 1e18+11; const int INF_int = 1e9+11;
#define ll long long
#define mp std::make_pair
#define rep(i,n) for(int i = 0;i<n;i++)
#define lrep(i,n) for(long long i = 0;i<n;i++)
#define All(a) a.begin(),a.end()
#define Debug_Output_ALL(a) for(auto x:a) cout << x << " ";cout << endl;
int main(){
    int n,x,t;
    cin >> n >> x >> t;
    int a = (n+x-1)/x;
    cout << a*t << endl;
}

Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {

		int  n, a, b, i, count = 0, x, sum, mod = 0;

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

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

		x = i;
		sum = 0;

		while (x > 0) {
			
			mod = x % 10;
			sum += mod;
			x -= mod;
			x /= 10;
			
		}

		if (a <= sum && b >= sum) {
			count += i;
		}
	}
	printf("%d", count); 

	return 0;
}

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

typedef long long ll;
const int N = 254000;

namespace hasher {
	typedef std::array <int, 6> num;
	const int mod[6] = {900000011, 998244353, 1000000007, 1000000009, 1004535809, 1100000009};

	inline void add(int &x, const int y, const int mod) {x += y - mod, x += x >> 31 & mod;}
	inline void sub(int &x, const int y, const int mod) {x -= y, x += x >> 31 & mod;}
	inline void mul(int &x, const int y, const int mod) {x = (ll)x * y % mod;}
	#define DEF_OPERATOR(op, func) inline num operator op (const num &A, const num &B) {num C(A); return func(C[0], B[0], mod[0]), func(C[1], B[1], mod[1]), func(C[2], B[2], mod[2]), func(C[3], B[3], mod[3]), func(C[4], B[4], mod[4]), func(C[5], B[5], mod[5]), C;}
	DEF_OPERATOR(+, add)
	DEF_OPERATOR(-, sub)
	DEF_OPERATOR(*, mul)

	struct _hash_ {inline size_t operator () (const num &x) const {return x[0] + 20030731ull * x[1] + 401230184394361ull * x[2] + 12600220620188154931ull * x[3] + 12293446969008436529ull * x[4] + 17407636028038340123ull * x[5];}};

	num X, Xi, _0, _1, in;
	std::mt19937 gen;

	ll PowerMod(ll a, int n, ll mod, ll c = 1) {for (; n; n >>= 1, a = a * a % mod) if (n & 1) c = c * a % mod; return c;}

	inline int uniform(int l, int r) {return std::uniform_int_distribution <int> (l, r) (gen);}

	inline void init() {
		char *_ = new char; gen.seed(time(NULL) + (size_t)_),delete _;
		_0.fill(0), _1.fill(1);
		for (int i = 0, S; i < 6; ++i)
			S = sqrt(mod[i]), X[i] = uniform(S, mod[i] - S),
			Xi[i] = PowerMod(X[i], mod[i] - 2, mod[i]);
	}
}
using namespace hasher;

typedef std::unordered_map <num, int, _hash_> map;

struct linear {
	num k, b;
	linear () {}
	linear (const num &_k, const num &_b) : k(_k), b(_b) {}
	inline linear operator * (const linear &B) const {return linear(k * B.k, k * B.b + b);}
	inline num operator () (const num &x) const {return k * x + b;}
};

int n;
char s[N];
linear f[N];
map M;

int query(const num &x) {
	map::iterator it = M.find(x);
	return it == M.end() ? 0 : it->second;
}

int main() {
	int i; ll ans = 0; num in(_0);
	init(), scanf("%d%s", &n, s + 1);
	for (i = 1; i <= n; ++i)
		switch (s[i]) {
			case 43: f[i] = linear(_1, _1); break;
			case 45: f[i] = linear(_1, _0 - _1); break;
			case 60: f[i] = linear(Xi, _0); break;
			case 62: f[i] = linear(X, _0); break;
		}
	for (in = _0, i = n; i; --i) in = f[i](in);
	linear t(_1, _0); M.reserve(n + 1), M.rehash(20030731);
	for (i = 0; i <= n; t = t * f[++i]) ans += query(t(_0)), ++M[t(in)];
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 192044
#include<bits/stdc++.h>
#define st first
#define nd second
#define PQ priority_queue

using ll = long long ;
using namespace std;
using pii = pair<int,int>;
const int N = 0;
const int mod = 0;
char c[1020];
int main(){
	scanf("%s", c);
	int n = strlen(c);
	if(c[n - 1] == 's') c[n] = 'e', c[n + 1] = 's', c[n + 2] = '\0';
	else c[n] = 's', c[n + 1] = '\0';
	printf("%s", c);

}

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

#define fastread std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define pb push_back
#define mp make_pair
#define print(a) for(auto x:a) cout<<x<<' ';cout<<endl;
#define printM(b) for(auto y:b) {print(y);}
#define printP(p) cout<<p.first<<' '<<p.second<<endl;

using namespace std;

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

int main()
{
	fastread;
	
	ll n, m, i, j;

    cin>>n>>m;

    string ar[n];

    for(i=0 ; i<n ; ++i)
        cin>>ar[i];
    
    ll dp[n+1][m+1];

    for(j=0 ; j<=m ; ++j)
        dp[0][j] = 0;
    for(i=0 ; i<=n ; ++i)
        dp[i][0] = 0;
    
    dp[0][1] = 1;

    for(i=1 ; i<=n ; ++i)
        for(j=1 ; j<=m ; ++j)
        {
            if(ar[i-1][j-1] == '.')
                dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % 1000000007;
            else
                dp[i][j] = 0;
        }
    
    cout<<dp[n][m];
    
    return 0;
}

Measured memory_bytes: 9088
import sys
import math
import fractions
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

N, K = map(int, input().split())
A = list(map(int, input().split()))

for i in range(N):
    A[i] -= 1

visited = set()
visited.add(0)
trace = []
cur = 0
while True:
    trace.append(cur)
    if A[cur] in visited:
        cur = A[cur]
        break
    visited.add(A[cur])
    cur = A[cur]

pre = 0
for i, a in enumerate(trace):
    if a == cur:
        pre = i

loop = len(trace) - pre

if K <= pre:
    ans = trace[K]
else:
    if loop == 0:
        ans = trace[pre::][0]
    else:
        r = (K - pre) % loop
        ans = trace[pre::][r]

print(ans + 1)


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

using namespace std;

typedef long long ll;

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;
}

int main(void) {
    int A, B, T;
    cin >> A >> B >> T;

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

    return 0;
}


Measured memory_bytes: 384
// E - Multiplication 4
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
int vpop(vector<int>& v){int x=v.back();v.pop_back();return x;}

int main(){
	int N, K; cin>>N>>K;
	vector<int> P, M;
	rep(i, N){
		int a; cin>>a;
		if(a < 0) M.push_back(a);
		else P.push_back(a);
	}

	sort(P.begin(), P.end());
	sort(M.rbegin(), M.rend());

	vector<int> p, m;
	while(int(p.size() + m.size()) < K){
		if(P.size() > 0 && M.size() <= 0) p.push_back(vpop(P));
		else if(P.size() <= 0 && M.size() > 0) m.push_back(vpop(M));
		else if(P.back() < -M.back()) m.push_back(vpop(M));
		else p.push_back(vpop(P));
	}

	if(m.size()%2){
		int pM = p.size() * M.size() > 0, mP = m.size() * P.size() > 0;
		if(pM && mP){
			if(abs((ll)p.back() * P.back()) < abs((ll)m.back() * M.back())){ p.pop_back(); m.push_back(vpop(M)); }
			else{ m.pop_back(); p.push_back(vpop(P)); }
		}
		else if (pM){ p.pop_back(); m.push_back(vpop(M)); }
		else if (mP){ m.pop_back(); p.push_back(vpop(P)); }
		else{
			while(m.size() > 0) p.push_back(vpop(m));
			while(P.size() > 0) p.push_back(vpop(P));
			while(M.size() > 0) p.push_back(vpop(M));
			sort(p.begin(), p.end(), [](int x, int y){ return abs(x) < abs(y); });
			while((int)p.size() > K) p.pop_back();
		}
	}

	ll ans = 1;
	int mod = 1'000'000'007;
	for(int a:p) ans = ans * a % mod;
	for(int a:m) ans = ans * a % mod;
	cout<< (ans+mod)%mod <<endl;
}


Measured memory_bytes: 5700
#include<iostream>
#include <string>
using namespace std;
int main(){
  int N;
  int A;
  int B;
  string S;
  string S1;
  cin>>N>>A>>B;
  cin>>S;
  int i;
  int foreignrank=1;
  int passpeople=0;
  for(i=0;i<=N-1;i++){
  S1=S[i];
  if(S1=="a"){
  	if(passpeople<A+B){
  		cout<<"Yes"<<endl;
  		passpeople++;
  	}
    else{
        cout<<"No"<<endl;
    }
  }
  else if(S1=="b"){
    if(passpeople<A+B){
    	if(foreignrank<=B){
    		cout<<"Yes"<<endl;
            passpeople++;
    	}
    	else{
    		cout<<"No"<<endl;
    	}
    }
    else{
    	cout<<"No"<<endl;
    }
    foreignrank++;
  }
  else if(S1=="c"){
  cout<<"No"<<endl;
  }
  }
}

Measured memory_bytes: 3732
#include <cstdio>

int main (){
    int k,x;
    scanf("%d %d",&k,&x);
    if(-1000000>x-k+1){
        for (int i = -1000000; i <= x+k-1; i++){
            printf("%d",i);
        }
    }
    else if(1000000<x+k-1){
        for (int i = x-k+1; i <= 1000000; i++){
            printf("%d",i);
        }
    }
    else for (int i = x-k+1; i <= x+k-1; i++){
        printf("%d%s",i," ");
    }
}

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

int main(void) {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	
	int a,b,c,x;
	cin >> a >> b >> c >> x;
	
	int ans = 0;
	
	for (int i = 0 ; i <=a ; i++) {
		for (int j = 0 ; j <=b ; j++) {
			for (int k = 0 ; k <=c ; k++) {
				if (x == 500*i + 100 *j + 50*k) {
					ans = ans + 1;
				}
			}
		}
	}
	
	cout << ans << "\n";
	return 0;
}

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

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


int main()
{
    int N;
    cin >> N;
    vector<long long> A(N);
    REP(i, N) cin >> A[i];

    sort(A.begin(), A.end(), greater<long long>());

    int i = 1;
    long long ans = 0;
    REP(j, N-1){
        ans += A[i/2];
        ++i;
    }
    cout << ans << endl;

    return 0;
}

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

long map[200000][2][3];
long a[200000];

bool possible[200000][2][3];

long saidai(int x, bool on, int drift){
  long y,z;
  long ret;
  bool pos;

  if(!on && drift == 0){
    ret = map[x-1][1][0];
    pos = possible[x-1][1][0];
  } else if(on && drift == 0){
    ret = map[x-1][0][0]+a[x];
    pos = possible[x-1][0][0];
  }
  else if(!on && drift > 0){
    y = map[x-1][1][drift];
    z = map[x-1][0][drift-1];
    if(possible[x-1][1][drift] && possible[x-1][0][drift-1]){
      ret = (y >= z)? y:z;
      //cout << ret << endl;
    } else if(possible[x-1][1][drift]) ret = y;
    else ret = z;
    pos = possible[x-1][1][drift] || possible[x-1][0][drift-1];
  }else{
    ret = map[x-1][0][drift]+a[x];
    pos = possible[x-1][0][drift];
  }
  map[x][(on)?1:0][drift] = ret;
  possible[x][(on)?1:0][drift] = pos;
  return ret;
}

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

  long x,y,ret;
  for(int i=0;i<N;i++) cin >> a[i];
  
  //for(int i=0;i<N;i++) map[0][i] = -1;
  //for(int i=0;i<N;i++) map[1][i] = -1;
  //for(int i=0;i<N;i++) map[2][i] = -1;
  map[0][0][1] = 0;
  map[0][1][0] = a[0];
  possible[0][0][0] = false;
  possible[0][0][1] = true;
  possible[0][0][2] = false;
  possible[0][1][0] = true;
  possible[0][1][1] = false;
  possible[0][1][2] = false;
   

  for(int i=1;i<N;i++) for(int j=0;j<2;j++) for(int k=0;k<3;k++){	
	saidai(i,(j==1)? true:false,k);
	//cout << i << " " << j << " " << k << " " << map[i][j][k] << " " << possible[i][j][k]<< endl;
      }  
  if(N % 2 == 0){
    x = map[N-1][0][0];
    y = map[N-1][1][1];
  }else{
    x = map[N-1][0][1];
    y = map[N-1][1][2];
  }
  ret = (x>=y)? x:y;
  cout << ret << endl;
}


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

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

const ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// head

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

    const int nax = 1e6 + 2;
    int n;
    cin >> n;
    vector<int> s(nax);
    int g;
    bool hasOne = false;
    for (int i = 0; i < n; i++) {
        int u;
        cin >> u;
        if(s[u] && u != 1) hasOne = true;
        s[u]++;
        if(i == 0) g = u;
        else g = __gcd(u, g);
    }
    bool pairWise = true;
    if(!hasOne) {
        vector<bool> p(nax, true);
        for(int i = 2; i < nax; i++) {
            int cnt = 0;
            if(p[i]) {
                cnt += s[i];
                for(int j = 2 * i; j < nax; j += i) {
                    p[j] = false;
                    cnt += s[j];
                }
            }
            if(cnt > 1) {
                pairWise = false;
            }
        }
    } else {
        pairWise = false;
    }

    if(pairWise) {
        cout << "pairwise coprime" << endl;
    } else if(g == 1) {
        cout << "setwise coprime" << endl;
    } else {
        cout << "not coprime" << endl;
    }

    return 0;
}


Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
int n, m, k, ans;
ll a[200005], b, c;
int main(){
	scanf("%d%d%d", &n, &m, &k);
	rep(i,n){
		scanf("%d", a+i+1);
		a[i+1] += a[i];
	}
	rep(i,m+1){
		if(i) scanf("%d", &c);
		b += c;
		if(b > k) break;
		for(; n>0 && a[n]+b>k; n--);
		ans = max(ans,n+i);
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 5380
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

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

    if(s == "Sunny"){
        cout << "Cloudy" << endl;
    }else if(s == "Cloudy"){
        cout << "Rainy" << endl;
    }else if(s == "Rainy"){
        cout << "Sunny" << endl;
    }

    return 0;
}



Measured memory_bytes: 256
import sys

input = sys.stdin.readline


class AtCoder:

    def gcd(self, a, b):
        if b == 0:
            return a
        else:
            return self.gcd(b, a % b)

    def factorize(self, n):
        p = 2
        res = 1
        while p * p < n:
            if n % p == 0:
                res += 1
                while n % p == 0:
                    n /= p
            p += 1
        if n != 1:
            res += 1
        return res

    def main(self):
        A, B = map(int, input().split())

        _gcd = self.gcd(A, B)
        print(self.factorize(_gcd))


# Run main
if __name__ == '__main__':
    AtCoder().main()


Measured memory_bytes: 38832
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
using namespace std;
typedef long long ll;

void Main()
{
    int n;
    cin >> n;
    vector<int> l(n);
    REP(i, n)
    cin >> l[i];
    int ans = 0;
    sort(ALL(l));
    for (int i = 1; i < n - 1; i++)
    {
        for (int q = 0; q < i; q++)
        {
            for (int k = i + 1; k < n; k++)
            {
                if (l[i] < l[q] + l[k] && l[k] < l[i] + l[q] && l[q] < l[k] + l[i])
                {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}

int main()
{
    std::cout << std::fixed << std::setprecision(15);
    Main();
}

Measured memory_bytes: 256
K = int(input())
A , B = [int(x) for x in input().split()]

if A >= K:
    tmp = A // K
    if A % K == 0 or B >= ( tmp + 1 ) * K:
        print('OK')
    else:
        print('NG')
else:
    if B // K > 0:
        print('OK')
    else:
        print('NG')        


Measured memory_bytes: 8868
#include<stdio.h>

int so(int a){
	int i;
	for(i=2;i*i<=a;i++){
		if(a%i==0)return -1;
	}
	return 1;
}

int main(){
	int n,i,e=0;
	scanf("%d",&n);
	for(i=11;i<55555;i+=10){
		if(so(i)==1){
			printf("%d ",i);
			e++;
		}
		if(e==n)break;;
	}
	puts("");
	return 0;
}

Measured memory_bytes: 128
#include <inttypes.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
    intmax_t R;
    long double ans = 0;

    scanf("%jd", &R);

    ans = 2 * R * 3.14159;

    printf("%Lf\n", ans);

    return 0;
}


Measured memory_bytes: 2116
#include<bits/stdc++.h>
#define f first
#define s second
using namespace std;
long long  mod=1e9+7,n,m,dp[100005][31],wynik;
pair<int,int>t[1000005];
int makslicznosc,j,ind;
int main()
{
ios_base::sync_with_stdio(0);
cin>>n>>m;
j=2;
while(j<=sqrt(m))
    {
    if(m%j==0)
        {
        if(t[ind].f==j)t[ind].s++;
        else
            {
            ind++;
            t[ind].f=j;
            t[ind].s=1;
            }
        makslicznosc=max(makslicznosc,t[ind].s);
        m/=j;
        }
    else j++;
    }
if(m!=1)
    {
    if(t[ind].f==m)t[ind].s++;
    else
        {
        ind++;
        t[ind].f=m;
        t[ind].s=1;
        }
    makslicznosc=max(makslicznosc,t[ind].s);
    m/=j;
    }
//for(int j=1;j<=ind;j++)cout<<t[j].f<<' '<<t[j].s<<'\n';
for(int i=1;i<=n;i++)dp[i][1]=i;
for(int i=1;i<=makslicznosc;i++)dp[1][i]=1;
for(int i=2;i<=n;i++)
    {
    for(int j=2;j<=makslicznosc;j++)
        {
        dp[i][j]=dp[i-1][j]+dp[i][j-1];
        dp[i][j]=dp[i][j]%mod;
        }
    }
wynik=1;
for(int i=1;i<=ind;i++)
    {
    wynik*=dp[n][t[i].s];
    wynik=wynik%mod;
    }
cout<<wynik;
}

Measured memory_bytes: 26112
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a, n, m;
  int x;
  int A=0, y=0, dig;
  cin >> a >> n >> m ;
  int ans=0;
  for (int i=1; i<=122; i++) {
    x=pow(i,n);
    if(x>m){
      break;
    }
    A=x;
    while(x>0){
      dig=x%10;
      y=y+dig;
      x=x/10;
    }
    if(y+a==i){
      ans++;
    }
    A=0;
    y=0;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3284
#include<bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (ll)(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; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
const ll mod = 1000000007;
// const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"
#define TO_STRING(VariableName) # VariableName

template <typename T>ostream &operator<<(ostream &out,const vector<T> &v) {rep(i,(int)v.size()-1)cout<<v[i]<<" ";cout<<v[(int)v.size()-1];return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const map<T1, T2> &p) {out << "(" << p.first << ", " << p.second << ")";return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const pair<T1, T2> &p){out << "(" << p.first << ", " << p.second << ")";return out;}
template<class T>void debag(const T &obj){cout<<obj<<endl;}

bool solve(){
    ll n;cin>>n;
    n%=10;
    string ans;
    if(n==3){ ans="bon";
    }else if(n==0 or n==1 or n==6 or n==8)ans="pon";
    else ans="hon";
    cout<<ans<<endl;
    return false;   
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout<<fixed<<setprecision(30);
    solve();
}


Measured memory_bytes: 3656
#include <cstdio>
const int XRATE = 3.8e5;
char denom[10];
double val;
int N;

int main() {
  scanf("%d", &N);
  double ret = 0;
  for (int i = 0; i < N; ++i) {
    scanf(" %lf%s", &val, denom);
    if (denom[0] == 'B') {
      val *= XRATE;
    }
    ret += val;
  }
  printf("%.6f\n", ret);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n,k;
  cin >> n >> k;
  vec a(n,0);
  for(ll i=0;i<k;i++) {
    ll d;
    cin >> d;
    for(ll j=0;j<d;j++) {
      ll tmp;
      cin >> tmp;
      tmp--;
      a[tmp]+=1;
    }
  }
  ll ans=0;
  for(ll i=0;i<n;i++) ans+=a[i]==0;
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
 
using namespace std;
using namespace __gnu_pbds;
 
#define debug(s) cout << #s << " = " << s << endl
#define all(v) (v).begin(), (v).end()
#define mem(a,val) memset(a, val, sizeof a)
 
#define maxn 300010
#define INF 1e15
#define ff first
#define ss second
#define endl '\n'
typedef long long ll;
 
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

int wl[maxn];
int wr[maxn];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  for (int i = 1; i <= n; ++i) {
    if (s[i - 1] == 'W') wl[i] = wl[i - 1] + 1;
    else wl[i] = wl[i - 1];
  }
  for (int i = n; i >= 1; --i) {
    if (s[i - 1] == 'E') wr[i] = wr[i + 1] + 1;
    else wr[i] = wr[i + 1];
  }
  int ans = INT_MAX;
  for (int i = 1; i <= n; ++i) {
    ans = min(ans, wl[i - 1] + wr[i + 1]);
  }
  cout << ans << endl;
}





Measured memory_bytes: 2964
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    ll n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e;
    ll ans = 4;
    ll min_t = min({a, b, c, d, e});
    cout << ans +  (n + min_t - 1) / min_t << endl;
}


Measured memory_bytes: 256
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]

N = ri()
A = sorted(ri_(), reverse=True)
ans = sum(A[:N // 2]) * 2 - A[0]
if N % 2 == 1:
    ans += A[N // 2]
print(ans)

Measured memory_bytes: 31688
# abc161_b.py
# https://atcoder.jp/contests/abc161/tasks/abc161_b

# B - Popular Vote /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 200点

# 問題文
# N種類の商品に対して人気投票を行いました。商品 i は Ai票を得ています。
# この中から人気商品 M個を選びます。ただし、得票数が総投票数の 14M未満であるような商品は選べません。
# 人気商品 M個を選べるなら Yes、選べないなら No を出力してください。

# 制約
#     1≤M≤N≤100
#     1≤Ai≤1000
#     Aiは相異なる
#     入力は全て整数

# 入力
# 入力は以下の形式で標準入力から与えられる。
# N M
# A1 ... AN

# 出力
# 人気商品 M個を選べるなら Yes、選べないなら No を出力せよ。

# 入力例 1
# 4 1
# 5 4 2 1

# 出力例 1
# Yes

# 総投票数は 12です。1 位の得票数は 5なので、これを選ぶことができます。

# 入力例 2
# 3 2
# 380 19 1

# 出力例 2
# No

# 総投票数は 400です。
# 2,3 位の得票数は総得票数の 14×2 未満なので、これらを選ぶことはできず、人気商品 2個を選べません。

# 入力例 3
# 12 3
# 4 56 78 901 2 345 67 890 123 45 6 789

# 出力例 3
# Yes


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # S = lines[0]
    # N = int(lines[0])
    N, M = list(map(int, lines[0].split()))
    values = list(map(int, lines[1].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())))

    values.sort()
    values = values[::-1]

    log(f'values[M-1]=[{values[M-1]}]')
    log(f'1/(4*M)=[{1/(4*M)}]')

    if values[M-1]/sum(values) < 1/(4*M):
        result = 'No'
    else:
        result = 'Yes'

    return [result]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['4 1', '5 4 2 1']
        lines_export = ['Yes']
    if pattern == 2:
        lines_input = ['3 2', '380 19 1']
        lines_export = ['No']
    if pattern == 3:
        lines_input = ['12 3', '4 56 78 901 2 345 67 890 123 45 6 789']
        lines_export = ['Yes']
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(2)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


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


Measured memory_bytes: 9292
(let ((s (concatenate 'list (read-line))))

  (defun solve (s &optional flag ans)
    (cond
      ((null s) (concatenate 'string (reverse ans)))
      ((null flag) (solve (cdr s) t (cons (car s) ans)))
      (t           (solve (cdr s) nil ans))))

  (format t "~A~%"
          (solve s)))


Measured memory_bytes: 29036
#include <iostream>
using namespace std;
typedef long long ll;

int main(void) {
  ll H, W;
  cin >> H >> W;
  if (H==1||W==1) {
    cout << 1 << endl;
  }
  else {
    cout << (H*W+1)/2 << endl;
  }
  return 0;
}


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

int main() {

    int n; cin >> n;
    vector<vector<int>> c(n, vector<int>(n, -1));
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        for (int j = 0; j < a; j++) {
            int x, y; cin >> x >> y;
            c[i][--x] = y;
        }

    }
    int ans = 0;  
    for (int bit = 0; bit < (1 << n); ++bit) {
        int cnt = 0;
        vector<bool> honest(n, false);
        for (int i = 0; i < n; ++i) {
            if (bit & (1 << i)) {
                honest[i] = true;
                cnt++;
            }

        }
        // 矛盾をチェック
        bool can = true;
        for (int i = 0; i < n; i++) {
            if (honest[i]) {
                for (int j = 0; j < n; j++) {
                    if ((c[i][j] == 1 && !honest[j]) || (c[i][j] == 0 && honest[j])) {
                        can = false;
                    }
                }
            }
        }
        if (can) ans = max(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
  int N;scanf("%d",&N);
  int a[N];int count=0;
  for(int i=0;i<N;i++)scanf("%d ",&a[i]);
  for(int i=0;i<N;i++)if(a[i]==count+1)count++;
  if(count==0)printf("-1");
  else printf("%d",N-count);
}

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

#include <unordered_map>

//#include <iostream>//POJ
//#include <vector>
//#include <string>
//#include <iomanip>
//#include <math.h>
//#include <algorithm>
//#include <cstring>
using namespace std;
#define setc cin.tie(0);ios::sync_with_stdio(0)
#define dd(n) cout<<fixed<<setprecision(n)
#define inp(x) (cin>>x,x)
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define repi_(i,a,b) for(int i=(a), i##_len=(b); i<=i##_len; ++i)
#define rep_(i,n) repi_(i,0,n)
#define repir(i,a,b) for(int i=(a)-1, i##_first=(b); i>=i##_first; --i)
#define repr(i,n) repir(i,n,0)
#define repir_(i,a,b) for(int i=(a), i##_first=(b); i>=i##_first; --i)
#define repr_(i,n) repir_(i,n,0)
#define all(x) (x).begin(),(x).end()
#define vsort(v) sort((v).begin(), (v).end())
#define gsort(v) tsort(v); reverse((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
//template<typename T> T vpop(vector<T> *v) {
//	T res = v->back();
//	v->pop_back();
//	return res;
//}
//char vpop(string *v) {
//	char res = v->back();
//	v->pop_back();
//	return res;
//}
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define contain(q) !q.empty()
#define cont(q) !q.empty()
//#define qpop(q, a, b) a=q.back().first;b=q.back().second;q.pop()
//#define pqpop(p, a, b) a=q.top().first;b=q.top().second;q.pop()
#define el "\n"
#define sp " "
#define pi 3.14159265358979
#define co(x) cout<<x<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define cosp(x) cout<<(x)<<' '
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#define POSSIBLE(c) coc(c, "POSSIBLE", "IMPOSSIBLE")
#define Possible(c) coc(c, "Possible", "Impossible")
#define possible(c) coc(c, "possible", "impossible")
#define inf INT_MAX
#define wildcard(T) numeric_limits<T>::min()

#define pb push_back
#define pq priority_queue
#define np next_permutation

#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
const unsigned int bf0 = (1 << 0);
const unsigned int bf1 = (1 << 1);
const unsigned int bf2 = (1 << 2);
const unsigned int bf3 = (1 << 3);
const unsigned int bf4 = (1 << 4);
const unsigned int bf5 = (1 << 5);
const unsigned int bf6 = (1 << 6);
const unsigned int bf7 = (1 << 7);

//#define lint long long
typedef long long lint;
typedef vector<int> ivec; typedef vector<string> svec;
typedef vector<lint> lvec;
typedef vector<vector<int>> ivvec;
typedef pair<int, int> P;

const int
dx8[8] ={ 0,1,1,1,0,-1,-1,-1 },
dy8[8] ={ 1,1,0,-1,-1,-1,0,1 },
dx9[9] ={ 0,1,1,1,0,0,-1,-1,-1 },
dy9[9] ={ 1,1,0,-1,0,-1,-1,0,1 },
dx4[4] ={ 0,1,0,-1 },
dy4[4] ={ 1,0,-1,0 };

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

int main(){
	setc;

	lint a,b,c;cin>>a>>b>>c;
	Yes(a+b==c||b+c==a||c+a==b); https://beta.atcoder.jp/contests/abc047/tasks/abc047_a
	gc();
}


Measured memory_bytes: 256
n = int(input())

check = False
num = 0
for _ in range(n):
    a, b = map(int, input().split())
    if a == b:
        num += 1
    else:
        num = 0
    if num == 3:
        check = True

if check:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9164
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ones(x) (ll) __builtin_popcount(x);1
#define fs first
#define sc second
#define pb push_back
#define po pop_back
#define mp make_pair	
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
using namespace std;
typedef long long ll;
typedef long double ld;	
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
 
const ll MAX = 10000000;
const ll inf = 5e18-1;


int main() {
	fastio;
	ll n,i;
    cin>>n;
    ll a;
    map<ll,ll> f;
    f(i,0,n)
    {
        cin>>a;
        f[a]++;
    }
    ll ans=0;
    for (auto e: f)
    {
        if (e.fs<e.sc)
            ans+=e.sc-e.fs;
        else if (e.fs>e.sc)
            ans+=e.sc;
    }
    cout<<ans<<endl;
	return 0;
	}

Measured memory_bytes: 6272
#include <iostream>

using namespace std;

int solve(int n) {
    switch (n) {
        case 0:
            return 1;
        case 1:
            return 2;
        case 2:
            return 1;
        default:
            return 0;
    }
}
int main() {
    int n;
    cin >> n;
    cout << solve(n) << endl;
    return 0;
}

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

int main(){
	int a,b,x;
	scanf("%d%d%d",&a,&b,&x);
	if(x*2>a*a*b){
		double h=1.0*(a*a*b-x)/(a*a)*2;
		double sita=atan(h/a)*180/acos(-1);
		printf("%.10f\n",sita);
	}
	else{
		double h=1.0*x/(a*b)*2;
		double sita=atan(b/h)*180/acos(-1);
		printf("%.10f\n",sita);
	}

	return 0;
}

Measured memory_bytes: 256
def main():

    X = int(input())
    n1 = X // 105
    n2 = X // 100

    for j in range(n1, n2+1):
        v = X - 100 * j
        if 0 <= v <= 5*j:
            return '1'
    return '0' 

if __name__ == '__main__':
    print(main())


Measured memory_bytes: 2940
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 4
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}

	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	ll := make(lbr, 0)
	rr := make(rbr, 0)
	for i := 0; i < n; i++ {
		s := getNextString(scanner)
		b := newbr(s)
		if b.r >= 0 {
			ll = append(ll, b)
			continue
		}
		rr = append(rr, b)
	}
	sort.Sort(ll)
	sort.Sort(rr)
	dd := 0
	for _, l := range ll {
		if dd+l.l < 0 {
			fmt.Fprintln(writer, "No")
			return
		}
		dd += l.r
	}
	for _, r := range rr {
		if dd+r.l < 0 {
			fmt.Fprintln(writer, "No")
			return
		}
		dd += r.r
	}
	if dd == 0 {
		fmt.Fprintln(writer, "Yes")
		return
	}
	fmt.Fprintln(writer, "No")
}

func newbr(s string) br {
	min := 0
	dif := 0
	for i := 0; i < len(s); i++ {
		if s[i] == '(' {
			dif++
		} else {
			dif--
		}
		if min > dif {
			min = dif
		}
	}

	return br{
		l: min,
		r: dif,
	}
}

type br struct {
	l, r int
}

type lbr []br

func (a lbr) Len() int      { return len(a) }
func (a lbr) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a lbr) Less(i, j int) bool {
	return a[i].l > a[j].l
}

type rbr []br

func (a rbr) Len() int           { return len(a) }
func (a rbr) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a rbr) Less(i, j int) bool { return a[i].l-a[i].r < a[j].l-a[j].r }


Measured memory_bytes: 38996