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

int ans ( int n, int d[] ){
  int ans = 0;
  bool flag = true;
  char c;
  for ( int i = 0; i < n; i++ ){
    if ( flag ){
      flag = false;
      ans++;
    }
    if ( d[i] == d[i+1] ){
      continue;
    }
    else if ( d[i] < d[i+1] ){
      while ( d[i] < d[i+1] || d[i] == d[i+1] ){
        i++;
      }
      flag = true;
    }
    else{
      while ( d[i] > d[i+1] || d[i] == d[i+1] ){
        i++;
      }
      flag = true;
    }
  }
  return ans;
}

int main (){
  int n;

  cin >> n;

 int d[n];

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

  cout << ans ( n, d ) << endl;

}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <atcoder/all>

using namespace atcoder;

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int t;
    std::cin >> t;
    while (t--) {
        int n, m, a, b;
        std::cin >> n >> m >> a >> b;
        std::cout << floor_sum(n, m, a, b) << "\n";
    }
    
    return 0;
}

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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];

    constexpr int kC = 2600;
    const int64_t kInf = 1'000'000'000'000'000;
    map<tuple<int, int, int, int>, int64_t> dp;

    function<int64_t(int, int, int, int)> Dfs = [&](int x, int y, int l, int r) {
        auto key = make_tuple(x, y, l, r);
        if (dp.find(key) != dp.end()) return dp[key];
        if (r - l == 1) return int64_t(0);
        int64_t res = kInf;
        for (int m = l + 1; m < r; ++m) {
            int64_t add = 1LL * (x + y) * a[m];
            res = min(res, Dfs(x, x + y, l, m) + Dfs(x + y, y, m, r) + add);
        }
        dp[key] = res;
        return res;
    };

    cout << Dfs(1, 1, 0, n - 1) + a[0] + a[n - 1] << "\n";
}


Measured memory_bytes: 16512
#include <stdio.h>

int main()
{
    int x1,x2,y1,y2,k,x3,x4,y3,y4,x,y;
    
    scanf("%d %d %d %d",&x1,&y1,&x2,&y2);

    if(x1==x2&&y1<y2){
        k=1;
    }
    else if(x1>x2&&y2==y1){
        k=2;
    }
    else if(x1<x2&&y1>y2){
        k=3;
    }
    else {
        k=4;
    }

    if(k==1){
        x3=x2-(y2-y1);
        y3=y2;
        x4=x3;
        y4=y1;
    }
    else if(k==2){
        x3=x2;
        y3=y2-(x1-x2);
        x4=x1;
        y4=y3;
    }
    else if(k==3){
        x=y1-y2;
        y=x2-x1;
        x3=x2+x;
        y3=y2+y;
        x4=x3-y;
        y4=y3+x;
    }
    else{
        x=x2-x1;
        y=y2-y1;
        x3=x2-y;
        y3=y2+x;
        x4=x3-x;
        y4=y3-y;
    }

    printf("%d %d %d %d\n",x3,y3,x4,y4);

    return 0;
}

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

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

    std::vector<int> A(N), cnt(N, 0);
    for (auto& a : A) {
        std::cin >> a;
        ++cnt[--a];
    }

    std::vector<int> cover(N, 0);
    for (int a = 0; a < N; ++a) {
        for (int i = 0; i < cnt[a]; ++i) {
            if (a - i < 0) break;
            ++cover[a - i];
        }
    }

    int ans = std::count(cover.begin(), cover.end(), 0);

    for (int q = 0; q < M; ++q) {
        int x, y;
        std::cin >> x >> y;
        --x, --y;

        // 区間縮小
        int a = A[x];
        int l = a - cnt[a] + 1;
        if (l >= 0) {
            --cover[l];
            if (cover[l] == 0) ++ans;
        }
        --cnt[a];

        // 区間拡張
        A[x] = y;
        ++cnt[y];
        int r = y - cnt[y] + 1;
        if (r >= 0) {
            if (cover[r] == 0) --ans;
            ++cover[r];
        }

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


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

int main()
{
    int N;
    cin >> N;
    for (int i = 1;i <= 9;i++){
        if(i*100+i*10+i >= N){
            cout<<i*100+i*10+i<<endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

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

int main(){
    int n;cin>>n;
    VEC(int,d,n);
    sort(ALL(d));
    int res = d[n/2]-d[n/2-1];
    cout<<res;
}



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

int main(){
    int N;
    string S;
    cin >> N >> S;
    int allB = 0, allW = 0, panda = 0;
    int left = 0, right = 0, minPanda = 0;

    int point = 1;
    //First Step
    if(S[0] == '.'){
        allB++;
    }else{
        left++;
        allW++;
    }
    for(int i=1;i<N;i++){
        if(S[i] == '.'){
            right++;
            allB++;
        }else{
            allW++;
        }
    }
    minPanda = left + right;
    panda = minPanda;

    //Second Step
    for(int i=2;i<N;i++){
        if(S[i-1] == '#') panda++;
        if(S[i-1] == '.') panda--;
        if(panda < minPanda) minPanda = panda;
        //cout << panda << endl;
    }

    cout << min({allB, allW, minPanda}) << endl;

    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#define max 100000

int A[max],n;

int partition(int p,int r){
  int x,i,j,t;
  x=A[r];
  i = p-1;
  for(j = p;j<r;j++){
    if(A[j]<=x){
      i++;
      t = A[i];
      A[i] = A[j];
      A[j] = t;
    }
  }

  t = A[i+1];
  A[i+1] = A[r];
  A[r] = t;

  return i+1;
}

int main(){
  int i,q;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  q = partition(0,n-1);

  for(i =0;i<n;i++){
    if(i)printf(" ");
    if(i==q)printf("[" );
    printf("%d",A[i]);
    if(i==q)printf("]" );
  }
  printf("\n");

  return 0;
}



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

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) //vec.size()がnの時等の高速化
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define vint vector<int>
#define vvint vector<vector<int>>

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

int n,q;
string s;
vint l,r;

int main(){
  cin >> n >> q >> s; l.resize(q);r.resize(q);
  rep(i,q) cin >> l[i] >> r[i];
  vint sigma(n,0);
  for(int i=1;i<n;++i){
    if(s[i-1]=='A'&&s[i]=='C') sigma[i]=sigma[i-1]+1;
    else sigma[i]=sigma[i-1];
  }

  rep(i,q){
    cout << sigma[r[i]-1]-sigma[l[i]-1] <<endl;
  }

  return 0;
}


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

int main(int argc, const char * argv[]) {

  int N, M, X, Y, x, y, Xmax, Ymin;
  cin >> N >> M >> X >> Y;
  Xmax = X;
  Ymin = Y;
  for (int i=0; i<N; i++) {
    cin >> x;
    Xmax = max(Xmax, x);
  }
  for (int i=0; i<M; i++) {
    cin >> y;
    Ymin = min(Ymin, y);
  }
  
  if(Xmax >= Ymin)
    cout << "War" << endl;
  else
    cout << "No War" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ii pair<int,int>
using namespace std;

const long double PI = 2*acos(0);

int main(){
	int a,b;
	cin >> a >> b;
	if( a < 10 && b < 10){
		cout<<a*b;
	}
	else{
		cout<<-1;
	}
}

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

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


// std::vector Declaration
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
   return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// std::vector Initialization
template<typename T>
void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U>
void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

// std::vector Debug
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
   os << "[";
   bool a = 1;
   for (auto e : v ) {
      os << (a ? "" : " "); 
      os << e;
      a = 0;
   }
   os << "]";
   return os;
}

// std::pair Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
   os << "(" << p.first << " " << p.second << ")";
   return os;
}

// std::set Debug
template<typename T>
ostream& operator<<(ostream& os, const set<T>& st) {
   os << "{";
   bool a = 1;
   for (auto e : st) {
      os << (a ? "" : " ");
      os << e;
      a = 0;
   }
   os << "}";
   return os;
}

// std::map Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& mp) {
   os << "{";
   bool a = 1;
   for (auto e : mp) {
      os << (a ? "" : " ");
      os << e.first << ":" << e.second;
      a = 0;
   }
   os << "}";
   return os;
}

// std::tuple Debug
template<int N,class Tuple>
void out(ostream &os,const Tuple &t){}
template<int N,class Tuple,class H,class ...Ts>
void out(ostream &os,const Tuple &t){
   if(N)os<<" ";
   os<<get<N>(t);
   out<N+1,Tuple,Ts...>(os,t);
}
template<class ...Ts>
ostream& operator<<(ostream &os, const tuple<Ts...> &t){
   os<<"(";
   out<0,tuple<Ts...>,Ts...>(os,t);
   os<<")";
   return os;
}

// Debug
#define DUMP(x) cout<<#x<<" = "<<(x)<<endl

struct edge { int to, cost; };

const LL LINF = 1LL<<60;
const int IINF = 1<<30;
const LL MOD = 1e9+7;

int main()
{
   int n; cin >> n;
   vector<LL> a(n);
   int neg_cnt = 0;
   LL abs_min = LINF;
   LL sum = 0;
   for (int i = 0; i < n; ++i) {
      cin >> a[i];
      sum += abs(a[i]);
      chmin(abs_min, abs(a[i]));
      if (a[i] < 0) {
         ++neg_cnt;
      }
   }

   if (neg_cnt % 2) {
      sum -= 2*abs_min;
   }

   cout << sum << endl;

   return 0;
}


Measured memory_bytes: 1024
import math
MAX = 10**9 + 7
n,m = map(int,input().split())

ans = 0
if abs(n-m) == 1:
    ans = math.factorial(n)*math.factorial(m) % MAX
elif n == m:
    ans = math.factorial(n)*math.factorial(m)*2 % MAX

print(ans)

Measured memory_bytes: 5176
#include <bits/stdc++.h>
using namespace std;
struct node{int p,l,r;};
node N[30];

void dfs1(int x){
  if(x==-1)return;
  cout <<" "<<x;
  dfs1(N[x].l);
  dfs1(N[x].r);
}

void dfs2(int x){
  if(x==-1)return;
  dfs2(N[x].l);
  cout <<" "<<x;
  dfs2(N[x].r);
}

void dfs3(int x){
  if(x==-1)return;
  dfs3(N[x].l);
  dfs3(N[x].r);
  cout <<" "<<x;
}

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

  for(int i=0;i<n;i++) N[i].p=-1;

  for(int i=0,a;i<n;i++){
    cin>>a;
    cin>>N[a].l>>N[a].r;
    if(N[a].l !=-1) N[N[a].l].p=a;
    if(N[a].r !=-1) N[N[a].r].p=a;
  }

  int root;
  for(int i=0;i<n;i++)if(N[i].p==-1) root=i;

  
  cout <<"Preorder"<<endl;
  dfs1(root);
  cout <<endl<<"Inorder"<<endl;
  dfs2(root);
  cout <<endl<<"Postorder"<<endl;
  dfs3(root);
  cout <<endl;
  return 0;
}

Measured memory_bytes: 1164
N = int(input())
XL = [tuple(map(int, input().split())) for i in range(N)]
XL.sort(key=lambda x: x[0]+x[1])

right = -10**9
removed = 0
for x, l in XL:
    if x-l < right:
        removed += 1
    else:
        right = x+l
print(N-removed)


Measured memory_bytes: 21824
#include <stdio.h>
#include<stdio.h>
#include <math.h>

struct Point{
  double x, y;
};

void Shuto(struct Point, struct Point, int);

int main(){

  struct Point p1, p2;
  int n;

  p1.x = 0;
  p1.y = 0;
  p2.x = 100;
  p2.y = 0;

  scanf("%d",&n);
  if(n > 6)exit(1);

  printf("%.8f %.8f\n",p1.x, p1.y);
  Shuto(p1,p2,n);
  printf("%.8f %.8f\n",p2.x, p2.y);

  return 0;
}

void Shuto(struct Point p1, struct Point p2, int n){

  if(n == 0) return;

  struct Point a, b, c;
  double rad=M_PI/3;

  a.x = (2 * p1.x + p2.x) / 3;
  a.y = (2 * p1.y + p2.y) / 3;
  b.x = (p1.x + 2 * p2.x) / 3;
  b.y = (p1.y + 2 * p2.y) / 3;
  c.x = (b.x - a.x) * cos(rad) - (b.y - a.y) * sin(rad) + a.x;
  c.y = (b.x - a.x) * sin(rad) + (b.y - a.y) * cos(rad) + a.y;

  Shuto(p1,a,n-1);
  printf("%.8f %.8f\n", a.x, a.y);
  Shuto(a,c,n-1);
  printf("%.8f %.8f\n", c.x, c.y);
  Shuto(c,b,n-1);
  printf("%.8f %.8f\n", b.x, b.y);
  Shuto(b,p2,n-1);
}



Measured memory_bytes: 2068
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define fi first
#define se second
const int N = 3e5+6;
const int mod = 1e9+7;
const int inf = 1e8;
int cnt[N];
void solve(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        cnt[x]++;
    }
    int ans = 0;
    for(int i=0;i<N;i++){
        ans+=max(0,cnt[i]-1);
    }
    if(ans%2)ans++;
    cout<<n-ans<<endl;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
//    cin>>t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <limits>
#include <vector>

using namespace std;

int main(){
	int n;
	vector<int> dp(200000),r(200000);
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> r[i];
		dp[i] = r[i];
	}
	for(int i=1;i<n;i++){
		dp[i] = min(dp[i-1],dp[i]);
	}
	int ans = numeric_limits<int>::min();
	for(int i=1;i<n;i++){
		ans = max(ans,r[i] - dp[i-1]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2588
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

int calc(int a, int b, int c, int x, int y) {
    int minCost = int.max;
    // AB ピザを 2*i 個かう
    for (int i = 0; i <= max(x, y); i++) {
        int cost = 2 * c * i + max(x - i, 0) * a + max(y - i, 0) * b;
        minCost = min(minCost, cost);
    }
    return minCost;
}

void main() {
   auto xs = readints;
   int a = xs[0], b = xs[1], c = xs[2], x = xs[3], y = xs[4];

   auto ans = calc(a, b, c, x, y);
   writeln(ans);
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc053/tasks/abc053_b
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int len = s.length(), pos1 = -1, pos2 = -1;
    REP(i, len) {
        if (s[i] == 'A') {
            pos1 = i;
            break;
        }
    }
    REPR(i, len) {
        if (s[i] == 'Z') {
            pos2 = i;
            break;
        }
    }
    cout << pos2 - pos1 + 1 << endl;

    return 0;
}


Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k,i;
  cin>>n>>k;
  char s[n];
  for(i=0;i<n;i++)
  {
  cin>>s[i];
  }
  for(i=0;i<n;i++)
  {
    if(i==k-1)
    {
    s[i]=tolower(s[i]);
    }
  }
  for(i=0;i<n;i++)
  {
  	cout<<s[i];
  }
}
      

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

int main() {

  int N;
  cin >> N;

  //cout << N << endl;
  
  int a[N];
  for(int i=0 ; i<N ; i++){
    cin >> a[i];
  }
  int count = 0;
	       
	      
  //cout << "start" << endl;
  bool loop = true;
  
  while(true){
    //cout<<endl << "count : "<< count << "  ";
    
    bool continuable = true;
    
    for(int i=0 ; i<N ; i++){
      if(a[i]%2 != 0){
	continuable = false;
	break;
      }    
    }

    
    if(continuable){     
      for(int i=0 ; i<N ; i++){
	a[i] /= 2;
      }
      count++;
    }
    else break;
      
  }

  cout << count << endl;
  return 0;
}



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

auto solve1(string s)
{
    int ans = 0;
    for (int i = 0; i < 3; i++)
    {
        if (s[i] == '1')
            ans++;
    }
    return ans;
}

int main(void)
{
    string s;
    cin >> s;
    cout << solve1(s) << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
ab = []
for i in range(N):
    ab.append(tuple(map(int,input().split())))
 
up = sorted(ab,key=lambda a:a[1],reverse=True)
down = sorted(ab,key=lambda a:a[0],reverse=True)
 
if N%2 == 1:
    print(up[N//2][1]-down[N//2][0]+1)
else:
    up2 = sorted(ab,key=lambda a:a[1],reverse=False)
    down2 = sorted(ab,key=lambda a:a[0],reverse=False)
    r = (up[N//2][1]+up2[N//2][1])
    l = (down[N//2][0]+down2[N//2][0])
    print(r-l+1)

Measured memory_bytes: 45300
#include <bits/stdc++.h>
using namespace std;
static const int MOD=1000000007;

int main(){
  int H,W;
  cin>>H>>W;
  string S;
  char D[1010][1010];
  for(int i=0;i<H;i++){
    cin>>S;
    for(int j=0;j<W;j++){
      D[i][j]=S.at(j);
    }
  }
  int dp[1010][1010]={};
  dp[0][0]=1;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(i==0 && j==0) continue;
      if(D[i][j] =='#'){
        dp[i][j]=0;
        continue;
      }
      if(D[i][j]=='.' && i == 0 && j>0){
        dp[i][j]=dp[i][j-1];
      }
      else if(D[i][j]=='.' && i> 0 && j ==0){
        dp[i][j]=dp[i-1][j];
      }
      else if(D[i][j]=='.' && i> 0 && j>0){
        dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD;
      }
    }
  }
  cout<<dp[H-1][W-1]<<endl; 
  /*for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cout<<dp[i][j]<<D[i][j];
    }
    cout<<endl;
  }*/
 
  return 0;
}


Measured memory_bytes: 8624
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

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

bool f(char b) {
    if ((b == 'A') || (b == 'T') || (b == 'C') || (b == 'G')) {
        return true;
    } else {
        return false;
    }
}

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

    int l = 0;
    vector<int> v;
    REP(0, i, S.length()) {
        if (f(S[i])) l++;
        else {
            v.push_back(l);
            l = 0;
        }
    }

    if (l != 0) {
        v.push_back(l);
        l = 0;
    }

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

    cout << v[0] << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int h,w; cin >> h >> w;
    vector<string> a(h);
    rep(i,h) cin >> a[i];
    vector<bool> tate(h,true),yoko(w,true);
    rep(i,h) rep(j,w) if(a[i][j] == '#') tate[i] = false,yoko[j] = false;
    rep(i,h){
        if(tate[i]) continue;
        rep(j,w){
            if(yoko[j]) continue;
            cout << a[i][j];
        }
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> //setprecision

#define lint long long

using namespace std;

int main()
{
  double l;
  cin >> l;
  cout << fixed << setprecision(12);
  cout << (l/3)*(l/3)*(l/3) << endl;
  return 0;
}


Measured memory_bytes: 256
/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.09.08 01:55:26
**/

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

#include "atcoder/all"
using mint = atcoder::modint998244353;
int main() {
    int n,m;cin >> n >> m;
    vector<mint> a(n), b(m);
    for (int i = 0; i < n; i++) {
        int x;cin >> x;
        a[i] = x;
    }
    for (int i = 0; i < m; i++) {
        int x;cin >> x;
        b[i] = x;
    }
    auto c = atcoder::convolution(a,b);
    for (int i = 0; i < c.size(); i++) {
        cout << c[i].val() << " ";
    }
    cout << endl;
    return 0;
}

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

// 上3桁がxであるような5桁の回文数を返す関数
int make_kaibunsu(int x) {
  return x*100 + (x % 100 - x % 10) + (x - x % 100) / 100;
}
int main() {
  int A, B;
  cin >> A >> B;
  int count = 0;
  for (int i = 100; i < 1000; i++) {
    if (A <= make_kaibunsu(i) && make_kaibunsu(i) <= B) {
      count++;
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
 
  while(1){ 
  int n,a,b,c,x;
  cin >> n >> a >> b >> c >> x;
  if(n == 0 && a == 0 && b==0&&c==0&&x==0) break;
 
  int y[101]={};
  for(int i=0;i<n;i++) cin >> y[i];
 
  int ans = 0;
  int ima=0;
  while(1){
    if(x == y[ima]){
      ima++;
      if(ima == n) break;
    }
    x = (a*x+b)%c;
    ans++;
    if(ans > 10000) {
      ans = -1;
      break;
    }
  }  
 
  cout <<ans<<endl;
}
  return 0;
}

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

int main() {
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	vector<int> all{ a, b, c, d, e };
	int last = 10;
	for (int i = 0; i < 5; i++) {
		if (all[i]%10 > 0 && all[i]%10 < last) last = all[i]%10;
		if (all[i] % 10 > 0) {
			all[i] += 10 - (all[i] % 10);
		}
	}
	int ans = accumulate(all.begin(), all.end(), 0);
	cout << ans - (10-last) << endl;
	

	return 0;
}

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

int main(){
    string S;
    cin >> S;
    int zero=0, one=0;
    for(int x : S){
        if(x=='0'){
            zero+=1;
        }else if (x=='1')
        {
            one+=1;
        }
        
    }
    int ans = S.length()-(abs(zero-one));
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main()
{
    string s; cin >> s;
    reverse(all(s));
    vvll dp(s.size(), vll(13));
    // process first line
    if (s[0] == '?') {
        rep(i, 10) {
            dp[0][i] = 1;
        }
    } else {
        ll num = s[0] - '0';
        dp[0][num] = 1;
    }
    //for (auto elem : dp[0]) cout << elem << " "; cout << endl;

    if (s.size() == 1) {
        cout << dp[s.size()-1][5] << endl;
        return 0;
    }

    for (ll i = 1; i < s.size(); i++) {
        set<ll> _candidate;
        if (s[i] == '?') {
            rep(j, 10) _candidate.insert(j * modpow(10, i, 13) % 13);
        } else {
            _candidate.insert((s[i] - '0') * modpow(10, i, 13) % 13);
        }
        vll candidate;
        for (auto elem : _candidate) {
            candidate.push_back(elem);
        }
        rep(j, 13) {
            rep(k, candidate.size()) {
                //cout << "i: " << i << ", j: " << j << ", k: " << k << endl;
                dp[i][(j + candidate[k]) % 13] = (dp[i][(j + candidate[k]) % 13] + dp[i-1][j]) % (ll)(1e9+7);
            }
        }
    }
    //for (auto elem1 : dp) {
    //    for (auto elem : elem1) cout << elem << " "; cout << endl;
    //}
    cout << dp[s.size()-1][5] << endl;
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    ll ans = 0;
    vector<int> d;
    for(int i = 1; i <= N; ++i) {
        int a;
        cin >> a;
        d.push_back(a - i);
    }
    sort(d.begin(), d.end());
    int b = d[(d.size() - 1) / 2];
    for(int i = 0; i < N; ++i)
        ans += abs(d[i] - b);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1400
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

def main():
    N = I()
    S = _S()
    print(S.count("ABC"))

main()



Measured memory_bytes: 27068
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    ll n, c, k;
    cin >> n >> c >> k;
    vector<ll> t(n);
    for (int i = 0; i < n; ++i) {
        cin >> t[i];
    }
    sort(t.begin(), t.end());
    auto it = t.begin();
    int ans = 0;
    do {
        auto it_r = upper_bound(it, t.end(), *it + k);
        int l = it_r - it;
        if (c >= l)
            it = it_r;
        else
            it = it_r - l + c;
        ++ans;
    } while (it != t.end());
    cout << ans << endl;
    return 0;
}

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

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

  vector<int> data(N);
  for(int i=0; i<N; i++){
    cin >> data.at(i);
  }

  int cumgcd= data.at(0);
  for(int i=0; i<N; i++){
    cumgcd= gcd(cumgcd, data.at(i));
  }

  if(cumgcd != 1){
    cout << "not coprime" << endl;
  }
  else{
    constexpr int Pmax= 1000;
    vector<int> primes;
    bitset<Pmax> sieve;
    sieve.set(); sieve.reset(0); sieve.reset(1);
    for(int p=2; p<Pmax; p++){
      if(sieve.test(p)){
        primes.emplace_back(p);
        for(int m= 2*p; m< Pmax; m+=p){
          sieve.reset(m);
        }
      }
    }

    bool pairwise_coprime= true;
    unordered_set<int> factors;
    for(auto num:data){
      for(auto p:primes){
        if(num%p==0){
          if(factors.count(p)){
            pairwise_coprime= false;
            break;
          }
          else{
            factors.insert(p);
            while(num%p==0){
              num/= p;
            }
          }
        }
      }
      if(num > 1){
        if(factors.count(num)){
          pairwise_coprime= false;
        }
        else{
          factors.insert(num);
        }
      }
      
      if(!pairwise_coprime){ break; }
    }

    string ans= pairwise_coprime ? "pairwise coprime"
                                 : "setwise coprime";
    cout << ans << endl;
  }
}

Measured memory_bytes: 7144
#include<iostream>

using namespace std;

typedef long long int ll;

ll calc(ll x){
    ll res;
    res = ((x + 1) / 2) % 2;
    if(x % 2 == 0) res ^= x;
    return res;
}

int main(){
    ll a, b, ans = 0;
    cin >> a >> b;
    ans = calc(b) ^ calc(a - 1);
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	int A, B;
	cin >> A >> B;

	if (A <= B * 2) {
		out(0);
	}
	else {
		out(A - B * 2);
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
#include <iomanip>

using namespace std;

int main(int argc, char* argv[])
{

	int A,B,C,D;

	cin >> A >> B >> C >> D;

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

	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

#define INF_LL (ll)1e18
#define INF (int)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
using ll = long long;
using PII = pair<int, int>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

vector<PII> res;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	int a[51] = {};
	int mabs = 0, mi = 0;
	cin >> N;
	REP(i, N){
		cin >> a[i];
		if(mabs < abs(a[i])){
			mabs = abs(a[i]);
			mi = i;
		}
	}
	if(a[mi] > 0){
		REP(i, N){
			if(a[i] < 0){
				res.push_back({mi, i});
			}
		}
		REP(i, N-1){
			res.push_back({i, i+1});
		}
	}else{
		REP(i, N){
			if(a[i] > 0){
				res.push_back({mi, i});
			}
		}
		for(int i = N-1;i >= 1;i--){
			res.push_back({i, i-1});
		}
	}
	cout << res.size() << endl;
	REP(i, res.size()){
		cout << res[i].first+1 << " " << res[i].second+1 << endl;
	}
}


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

using namespace std;

int main()
{
  int m, n;
  vector<vector<int> > scores;
  
  cin >> m >> n;
  scores.assign(m, vector<int>(n));

  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      cin >> scores[i][j];
    }
  }

  int max_score = 0;
  int score;
  for (int i = 0; i < m; i++) {
    score = 0;
    for (int j = 0; j < n; j++) {
      score += scores[i][j];
    }
    if (score > max_score) max_score = score;
  }
  cout << max_score  << endl;
}
  



Measured memory_bytes: 3164
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	void run(){
		for(;;){
			int n = sc.nextInt();
			if(n == 0){
				break;
			}
			int sum = 0;
			int min = 1000;
			int max = 0;
			for(int i =0 ; i< n ; i++){
				int x = sc.nextInt();
				max = Math.max(x,max);
				min = Math.min(x, min);
				sum += x;
			}
			System.out.println((sum-min-max)/(n-2));
		}
		
	}
	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}
}

Measured memory_bytes: 0
values_nr = int(input())
idx___value = [(int(x) - 1) for x in input().split()]

curr_len = 0
ans = 0
for idx, value in enumerate(idx___value):
    if idx == value:
        curr_len += 1
    else:
        ans += (curr_len + 1) // 2
        curr_len = 0
ans += (curr_len + 1) // 2
print(ans)

Measured memory_bytes: 13880
def binary_search(A,func):
    l = 0
    r = len(A)-1
    if func(0,A):return -1
    if not func(r,A):return r
    while l+1<r:
        i = (l+r)//2
        if func(i,A):
            r = i
        else:
            l = i
    return l

N = int(input())
A = [int(input()) for _ in [0]*N]
B = [A[0]]
ans = 1
for a in A[1:]:
    r = binary_search(B,lambda i,b:b[i]<a)+1
    if r < ans:B[r] = a
    else:
        B.append(a)
        ans+=1
print(ans)

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

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

    ll i,j,k,l,m,n,w,x,y,z,p,q,tmp,sum=0;
    string str;
    cin>>n>>m;
    vector<int> a(m);
    rep(i,m)   cin >> a[i];
    rep(i,m) n-=a[i];
    if(n<0) cout<<"-1"<<endl;
    else cout<<n<<endl;

    return 0;
}

Measured memory_bytes: 3700
/*╔═══╗──╔╗╔╗───────────────────╔╗────────╔═══╦═══╗
  ║║─║╠╗╠╗╔╣╚═╦══╦═╗╔╦╗╔═╗╔══╦══╣╚═╦╦══╦══╣║─║║║─╚╝
  ║╔═╗║╚╝║╚╣║║║╚╝║║─╔╦╗║║║║╚╝║╚╝║╚╝║║║═╬══║╔═╗║╚╩═║
  ╚╝─╚╩══╩═╩╝╚╩══╩╝─╚╩╝╚╝╚╩══╩══╩══╩╩══╩══╩╝─╚╩═══╝*/

#include<bits/stdc++.h>
using namespace std;

#define f(i,k,n) for(i=k;i<n;i++)
#define fd(i,k,n) for(i=k;i>n;i--)
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vvll vector<vll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(c) c.begin(),c.end()
#define sz(c) (int)c.size()
#define lb lower_bound
#define ub upper_bound
#define gi greater<int>
#define rev reverse
#define ff first
#define ss second
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define imp cout << "IMPOSSIBLE" << endl;
#define nl cout << endl
#define hello cout << "hello" << endl;
#define sp(x) fixed << setprecision(x)
#define re return

void dbg_out(){cerr << endl;}
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)

const double pi = 3.14159265359;
const ll mod = 1000000007;
const ll modc = 998244353;

ll inline power(ll a, ll b, ll p){
    a %= p;
    ll ans = 1;
    while(b>0){
        if(b & 1)
            ans = (ans*a)%p;
        a = (a*a)%p;
        b >>= 1;
    }
    return ans;
}

ll mod_inv(ll n, ll p){
    return power(n,p-2, p);
}

bool inline isPrime(ll n) {
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    for (ll i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
    return true;
}
template<typename... T>
void W(T&&... args)
{
	((cout << sp(9) <<  args << " "), ...);
	nl;
}
template<typename... T>
void R(T&&... args)
{
	((cin >> args), ...);
}
ll ston(string s) 
{
	ll a = 0;
	reverse(s.begin(),s.end());
	ll pow = 1;
	for(int i=0;i<s.size();i++)
	{
		a += pow*(s[i]-'0');
		pow*=10;
	}
	return a;
}
template <class T>
string to_binary(T n) 
{
	string binaryNum;
	int i = 0;
	while (n > 0) {
		binaryNum.pb((n % 2)+'0');
		n = n / 2;
		i++;
	}
	reverse(binaryNum.begin(),binaryNum.end());
	return binaryNum;
}
template<class T>
bool perfectSq(T n)
{
	if(sqrt(n) == floor(sqrt(n)))
		return true;
	else
		false;
}
template<class T>
void wv(T &v)
{
	for(auto x : v)
		cout << x << " " ;
	nl;
}
template<class T>
void rv(T &v)
{
	for(int i=0;i<sz(v);i++)
		cin >> v[i];
}
void solve()
{
	int i,j;ll sum = 0,prod = 1;ll maxl = LONG_MIN,minl = LONG_MAX;int maxi = INT_MIN,mini = INT_MAX;
	int x,n;
	R(x,n);
	vi p(n);
	rv(p);
	map<int,int>hash;
	for(auto x : p)
		hash[x] = 1;
	int diff = 1000;
	int snum = 1000;
	for(i=-1000;i<=1000;i++)
	{
		if(hash[i] == 0)
		{
			if(abs(x-i) < diff)
			{
				diff = abs(x-i);
				snum = i;
			}
		}
	}
	W(snum);
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 3696
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var X = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var list = X.OrderByDescending(x => x).ToArray();
            var num = (N / 2) - 1;

            for(var i = 0; i < N; i++)
            {
                if (list[num] > X[i]) Console.WriteLine(list[num]);
                else Console.WriteLine(list[num + 1]);
            }
        }
    }
}

Measured memory_bytes: 41124
#include <iostream>
#include <map>
#include <set>
#include <math.h>
#include <bits/stdc++.h>
using namespace std;

int main()
{
    long long n,k,sum=0;
    cin>>n>>k;
    int arr[n];
    for (int i=0;i<n;i++)
    {

        cin>>arr[i];
    }
    sort (arr,arr+n);
    for (int i=0;i<n-k;i++)
    {
        sum+=arr[i];
    }
    cout<<sum;
    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<class x,class y> x sum(x a,y b){return a+b;}
template<class x,class y> x mul(x a,y b){return a*b;}
template<class x,class y> x sub(x a,y b){return a-b;}
template<class x,class y> x divi(x a,y b){return a/b;}

template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
#define N  1000005

vector<ll> v[20];
ll xx,n,m;

ll check(ll x)
{
    // cout<<x<<endl;
    vi mp(m+1,0);
    for(ll j=0;j<n;j++)
    {
        // cout<<(x>>j)<<" "<<j<<endl;
        if((x>>j)&1)
        {
            // cout<<j<<endl;
            for(ll k=0;k<m;k++)
            {
                mp[k]+=v[j][k];
            }
        }
    }
    // cout<<mp;
    // cout<<x<<endl;
    ll ans=1;
    for(ll i=0;i<m;i++)
    {
        if(mp[i]<xx)return 0;
    }
    return 1;
}

int main()
{
    ios;
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
        ll i,j,k,l;
        cin>>n>>m>>xx;
        vi c(n+1);
        for(i=0;i<n;i++)
        {
            cin>>c[i];
            for(j=0;j<m;j++)
            {
                cin>>l;
                v[i].pb(l);
            }
        }
        ll y=1<<n;
        ll ans=peak;
        // cout<<y<<endl;
        for(i=0;i<=y;i++)
        {
            if(check(i))
            {
                ll tt=0;
                for(j=0;j<n;j++)
                {
                    if((i>>j)&1)tt+=c[j];
                }
                // cout<<i<<" "<<tt<<endl;
                ans=min(ans,tt);
            }
        }
        if(ans==peak)
        {
            cout<<-1;
            return 0;
        }
        cout<<ans;
    }
    return 0;
}

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

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

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

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

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

  string S;
  cin >> S;

  for (int i = 0; i < S.size(); i++) {
    int num = i + 1;
    if (num % 2 == 1) {
      if (!(S[i] == 'R' || S[i] == 'U' || S[i] == 'D')) {
        cout << "No" << endl;
        return 0;
      }
    }
    else {
      if (!(S[i] == 'L' || S[i] == 'U' || S[i] == 'D')) {
        cout << "No" << endl;
        return 0;
      }
    }
  }

  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
X = int(input())
happiness = 0
while X > 0:
    if X >= 500:
        temp = int(X / 500)
        X = X - (500 * temp)
        happiness = 1000 * temp
    else:
        temp = int(X / 5)
        X = X - (500 * temp)
        happiness = happiness + (5 * temp)
        break
print(happiness)


Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>
using namespace std;

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

	return 0;
}



Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
 #define fast() ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll  long long
#define int long long
#define f(i,a,b) for(int i=a; i<b; i++)
#define pb push_back
#define MP make_pair
#define vi vector<int>
#define F     first
#define S    second
#define all(x) x.begin(), x.end()

const int N = 1e9+7;
signed main()
{
    fast();
    int n, x;
    cin >> n;
    vector<pair<int, int>> v;
    for(int i = 1 ; i <= n ; i++)
    {
        cin >> x;
        v.pb({x, i});
    }
    sort(all(v));
    for(auto it: v)
        cout << it.S << ' ';
}   

Measured memory_bytes: 2544
#include <bits/stdc++.h>
#define max(a,b) ((a>b)?(a):(b))
#define min(a,b) ((a<b)?(a):(b))
#define MEM(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long LL;
typedef pair<int,int>pii;
const int mod = 1e9 + 7;
vector<int>v;
int mp[200][200];
int main() {
    int h, w;
    cin >> h >> w;
    int n, x;
    cin >> n;
    for(int i = 1; i <= n; ++ i) {
        cin >> x;
        while(x--) v.push_back(i);
    }
    int idx = 0;
    for(int i = 1; i <= h; ++ i) {
        for(int j = 1; j <= w; ++ j) {
            mp[i][j] = v[idx++];
        }
    }
    for(int i = 1; i <= h; ++ i) {
        if(i & 1) reverse(mp[i]+1,mp[i]+w+1);
    }
    for(int i = 1; i <= h; ++ i) {
        for(int j = 1; j <= w; ++ j) {
            if(j > 1) putchar(' ');
            cout << mp[i][j];
        }
        cout << endl;

    }
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(){
  long long a,b;
  cin>>a>>b;
  long long c,d,e=0,f;
  for(long long i=0;i<b;i++){
    if(i==0){
      cin>>c;
      f=c;
    }
    else{
      cin>>d;
      if(d-c>e){
        e=d-c;
      }
      c=d;
    }
  }
  if(a-c+f>e){
    e=a-c+f;
  }
  cout<<a-e<<endl;
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>
#include <iomanip>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define Imax 2147483647
#define ll long long
#define asort(a) sort(a.begin(),a.end());

using namespace::std;

int jo(ll int jxo, ll int jyo){//累乗
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){//char大文字化
  return (toxbig-0x20);
}
char tolow(char toxlow){//char小文字化
  return (toxlow+0x20);
}
int ctoi(char cctoi){//char->int
  if('0' <= cctoi && cctoi <= '9') return (cctoi-'0');
  return -1;
}
int gcd(int gcad, int gcbd) {//最大公約数
  if(gcad < gcbd) return gcd(gcbd, gcad);
  int gcrd;
  while ((gcrd=gcad%gcbd)) {
    gcad = gcbd;
    gcbd = gcrd;
  }
  return gcbd;
}
int lcm(int lcam, int lcbm){//最小公倍数
 return (lcam*lcbm)/gcd(lcam,lcbm);
}


int main(){
  int n,m;
  cin>>n>>m;
  vector<int> a(m);
  rep(i,0,m) a[i]=0;
  int hoge;
  int hage;
  rep(i,0,n){
    cin>>hoge;
    rep(i,0,hoge){
      cin>>hage;
      a[hage-1]++;
    }
  }
  int count=0;
  rep(i,0,m){
    if(a[i]==n) count++;
  }
  cout<<count;
      
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


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

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;
using ld = long double;
int main(){
    priority_queue<ld,vector<ld>,greater<ld> > pq;
    int n;
    cin >> n;
    long double tmp;
    rep(i,n){
        cin >> tmp;
        pq.push(tmp);
    }

    rep(i,n-1){
        ld e1 = pq.top();
        pq.pop();
        ld e2 = pq.top();
        pq.pop();

        ld e3 = (e1+e2)/2;
        pq.push(e3);
    }

    printf("%.10Lf\n",pq.top());

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <stdio.h>
using namespace std;

int main(){
  int alphabets[128], index;
  char ch;

  for(int i = 0; i < 128; i++){
    alphabets[i] = 0;
  }

  while(cin >> ch){
    if(ch == '\0') break;
    if(!isalpha(ch)) continue;
    if(isupper(ch)) ch = tolower(ch);
    index = ch - 'a';
    alphabets[index]++;
  }

  for(int i = 65; i < 91; i++){
    putchar(i + 32);
    cout << ' ' << ':' << ' ' << alphabets[i - 65]<< endl;
  }

  return 0;
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
typedef long long int ll;
typedef pair<int, int> P;
#define INF 1e9 + 7

int gcd(ll a, ll b){
    if(a % b == 0) return b;
    else return gcd(b, a%b);
}

int many_gcd(vector<ll> v){
    int G = v[0];
    rep(i, v.size()){
        G = gcd(G, v[i]);
    }
    
    return G;
}

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

    string s;
    cin >> s;
    
    char now = s[0];
    int ans = 0;
    rep(i, s.size()){
        if(now != s[i]){
            ans++;
            now = s[i];
        }
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
package main
import (
	"fmt"
)
func main() {
	var a int
	fmt.Scan(&a)
	var b int
	fmt.Scan(&b)
	var c int
	fmt.Scan(&c)
	args := make([]int, 3)
	args[0] = a
	args[1] = b
	args[2] = c
	if len(args) != 3 {
		fmt.Println(len(args))
		fmt.Println("NO")
		return
	}
	m := make(map[int]int)
	for _, v := range args {
		if m[v] == 0 {
			m[v] = 1
		} else {
			m[v] = m[v] + 1
		}
	}
	if m[5] == 2 && m[7] == 1 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

Measured memory_bytes: 512