akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

#define MaxNUM 100

int main( void )
{
    char tmp;
    char i,j,k = 0;
    unsigned char Num = 0;
    
    unsigned short Array[MaxNUM];
    unsigned short v = 0;

    // ??\??? 1?????????????????°?????????
    // ????????????????????\????????§??£?¶???????
    while( (tmp = getchar()) != '\n' )
    {
        Num = (Num * 10) + (tmp - '0'); // ??????????????°???????????????????¶?????????????
    };
    
    // ??\??? 2??????????????????????????????????????????
    for(k=0; k<Num; k++ )
    {
        // ??????????????????
        Array[k]=0;
    
        do{
            tmp = getchar();
            printf("%c",tmp);
            
            if(tmp == '\n') //???????????????????????????
            {
                break;
            }
            
            if( tmp != ' ' )
            {
                Array[k] = Array[k] * 10 + (tmp - '0');
            }
        }while(tmp != ' ' && tmp != '\n'); // ???????????£???????¬???????????????????
    }

    // ?????????
    for( i=1; i<Num; i++ )
    {
        v = Array[i];
        j = i - 1;
    
        // ??????????????????????????§????????¨??????1??????????????¨??\????????????
        while( j >= 0 && Array[j] > v )
        {
            Array[j+1] = Array[j];
            Array[j] = v;
            j--;
        }
    
        // ???????????????????????????????????????????????????????????????
        for(k=0; k<Num; k++ )
        {
            printf("%d",Array[k]);
            if( k == Num-1 )
            {
               printf("\n");    // ???????????????
            }
            else
            {
               printf(" ");
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 1860
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
using ll = long long;
using P = pair<int, int>;
/* ------------------------------------------------ */
ll fact(int i) {       //階乗(i <= 20 まで)
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ------------------------------------------------ */

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    rep(i, c - a) cout << 'R';
    rep(i, d - b) cout << 'U';
    rep(i, c-a) cout << 'L';
    rep(i, d - b) cout << 'D';
    cout << 'D';
    rep(i, c-a+1) cout << 'R';
    rep(i, d-b+1)cout << 'U';
    cout << 'L';
    cout << 'U';
    rep(i, c-a+1)cout << 'L';
    rep(i, d-b+1)cout << 'D';
    cout << 'R';
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  double ans=0;
  for(int i=1;i<=n;i++)
  {
    int now=i;
    double p=1.0/n;
    while(now<k)
    {
      now*=2;
      p/=2;
    }
    ans+=p;
  }
  printf("%.12f\n",ans);
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.math.*;

public class Main{
    Main(){
	Scanner sc = new Scanner(System.in);
	BigInteger bi;

	while(sc.hasNext()){
	    int cnt = 0;
	    for(int i = sc.nextInt(); i >= 1; --i){
		bi = new BigInteger(sc.next());
		if(bi.isProbablePrime(10)) ++cnt;
	    }
	    System.out.printf("%d\n", cnt);
	}
    }

    public static void main(String[] args){
	new Main();
    }
}

Measured memory_bytes: 13000
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <ll,ll> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

ll fast_pow(ll x, ll n) {
  ll res = 1;
  while(n > 0) {
    if (n & 1) res = res * x;
    x = x * x;
    n >>= 1;
  }
  return res;
}

ll GCD(ll a ,ll b){
  return b > 0 ? GCD(b,a%b) : a;
}

P compute_dir(ll lhs_numerator,ll lhs_denominator,
              ll rhs_numerator,ll rhs_denominator){

  ll numerator = lhs_numerator * rhs_denominator + rhs_numerator * lhs_denominator;
  ll denominator = lhs_denominator * rhs_denominator;
  ll div = GCD(numerator,denominator);
  return P(numerator / div,denominator / div);

}

int main(){
  string str;
  while(cin >> str){
    if(str == "#") break;

    int west_count = 0;
    int north_count = 0;
    ll numerator = -1;
    ll denominator = -1;
    for(int i = str.size() -1; i >= 0; i--){
      if(str[i] == 'n'){
        if(numerator == -1){
          numerator = 0;
          denominator = 1;
        }
        else{
          P next = compute_dir(numerator,denominator,
                               -90,fast_pow(2,north_count + west_count));
          numerator = next.first;
          denominator = next.second;
        }
        north_count++;
      }
      else if(str[i] == 'w'){
        if(numerator == -1){
          numerator = 90;
          denominator = 1;
        }
        else{
          P next = compute_dir(numerator,denominator,
                               90,fast_pow(2,north_count + west_count));
          numerator = next.first;
          denominator = next.second;
        }
        west_count++;
      }
    }

    ll div = GCD(numerator,denominator);
    numerator /= div;
    denominator /= div;
    if(denominator <= 1){
      printf("%lld\n",numerator);
    }
    else{
      printf("%lld/%lld\n",numerator,denominator);
    }
  }
}

Measured memory_bytes: 1196
#include<stdio.h>
main()
{
	int n,a,b,c,d,cnt;
	while(scanf("%d",&n)!=EOF){
		cnt=0;
		for(a=0;a<10;a++){
			for(b=0;b<10;b++){
				for(c=0;c<10;c++){
					for(d=0;d<10;d++){
						if(a+b+c+d==n){
							cnt=cnt+1;
						}
					}
				}
			}
		}
		printf("%d\n",cnt);
	}
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

int main() {
    int x, y, z;
    cin >> x >> y >> z;

    cout << z << " " << x << " " << y << " " << endl;
}

Measured memory_bytes: 3584
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc084_a.cpp
 * time   : Thu Apr 30 00:37:45 2020
 * quest  : A - New Year
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int m;
  cin >> m;
  cout << 48 - m << "\n";
  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N = inp()
S = list(input())

dp = [0]*(2*N)

cnt = 0
ans = 1
for i in range(2*N):
    s = S[i]
    if s == 'B':
        if cnt%2 == 0:
            cnt += 1
            ans *= cnt
        else:
            cnt -= 1
    elif s == 'W':
        if cnt%2 == 0:
            cnt -= 1
        else:
            cnt += 1
            ans *= cnt
    ans %= mod


for i in range(1,N+1):
    ans *= i
    ans %= mod

if cnt != 0 or S[0]=='W' or S[-1]=='W':
    print(0)
else:
    print(ans%mod)


Measured memory_bytes: 60012
#include <bits/stdc++.h>
using namespace std;
int main(){
  int K;
  string S;
  cin >> K >> S;
  
  if(S.size()<=K){
    cout << S <<endl;
  }
  else{
    for(int i=0;i<K;i++){
      cout << S.at(i);
    }
    cout << "..." <<endl;
  }
    
}



Measured memory_bytes: 3628
import java.util.*;
import java.lang.*;

public class Main {
    public static int cnt = 0;
    public static int n, s;

    public static void main(String[] args) {
        Scanner num = new Scanner(System.in);
        for(;;) {
            cnt = 0;
            n = num.nextInt();
            s = num.nextInt();

            if(n == 0 && s == 0) break;

            calc(0, 0, 0);
            System.out.println(cnt);
        }
    }

    public static void calc(int i, int sum, int N) {
        if(sum == s && N == n){
			cnt++;
			return;
        }
        
        if(i>=10||sum>s) return;
        
		calc(i + 1, sum, N);
		calc(i + 1, sum + i, N + 1);
    }
}


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

typedef unsigned long long ll;

ll md = 1000000007;

int main(int, char**)
{
	ll l, r, ans = 2020;
	cin >> l >> r;

	if (r - l >= 2019) {
		ans = 0;
	} else {
		for (ll i = l; i < r; ++i) {
			for (ll j = i + 1; j <= r; ++j) {
				ll x = (i * j)% 2019;
//				cerr << i << "*" << j << "=" << x << endl;
				ans = min(ans, x);
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
	int n;
	cin >> n;
	if(n % 2){
		cout << 0 << endl;
		return 0;
	}
	int ans = 0;
	n /= 2;
	while(n){
		ans += n / 5;
		n /= 5;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld=long double;
 
int main(){
    int t;
    cin>>t;
    int n=2*t;
    int a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    sort(a,a+n);
    
    int p=0,sum=0;
    for(int i=0;i<n;i++){
        if(i%2==0)
        sum+=a[i];
        
    }
    cout<<sum;
    
    return 0;
}

Measured memory_bytes: 256
N,M,X,Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
ans = 'War'
for z in range(X+1,Y+1):
    if max(x) < z and min(y) >= z:
        ans = 'No War'
        break
print(ans)

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

int main(){
  int n,k;
  cin >> n >> k;
  int x;
  int dif;
  int sum=0;
  
  rep(i,n){
    cin >> x;
    dif = abs(x-k);
    if(x >= dif) sum += dif;
    else sum += x;
  }
  sum *= 2;
  cout << sum << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string n;
    cin>>n;
    bool ans=true;
    for(int i=0;i<n.size();i++)
        if(n[i]=='7') ans=false;
    if(ans) cout<<"No";
    else cout<<"Yes";
    cout<<"\n";
}


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

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

const ll MOD = 1000000007;
const ll INF = 9999999999;

int main() {
  int n; cin >>n;
  vector<ll> a(n),b(n),c(n);
  rep(i,n) cin >>a[i] >>b[i] >>c[i];

  vector<vector<ll>> dp(n+10, vector<ll>(3,0));
  // dp[i][j]: i日目に活動jを行う
  //dp[0][0] = 0, dp[0][1] = 0, dp[0][2] = 0;

  for (int i=1; i<=n; i++){
    chmax(dp[i][0], a[i-1] + dp[i-1][1]);
    chmax(dp[i][0], a[i-1] + dp[i-1][2]);
    chmax(dp[i][1], b[i-1] + dp[i-1][0]);
    chmax(dp[i][1], b[i-1] + dp[i-1][2]);
    chmax(dp[i][2], c[i-1] + dp[i-1][0]);
    chmax(dp[i][2], c[i-1] + dp[i-1][1]);
  }
  cout <<max(dp[n][0], max(dp[n][1], dp[n][2])) <<endl;
  
}

Measured memory_bytes: 8064
#include <cstdio>
#include <cctype>
#include <utility>
#include <stack>
#include <functional>
#include <unordered_map>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;while(isspace(c)){c=gcu();}if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m?-n:n;}
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

using D = double;

int main() {
	stack<D> S;
	unordered_map<char, function<D(D, D)>> m = {{'+', plus<D>()}, {'-', minus<D>()}, {'*', multiplies<D>()}, {'/', divides<D>()}};
	int c;
	for (;;) {
		string s;
		while (c = gcu(), c != EOF && !isspace(c))
			s += c;
		if (c == EOF)
			return 0;
		if (s.size() == 1 && !isdigit(s[0])) {
			D b = S.top(); S.pop();
			D a = S.top(); S.pop();
			S.push(m[s[0]](a, b));
		} else
			S.push(stoi(s));
		if (c == '\n') {
			printf("%lf\n", S.top());
			S.pop();
		}
	}
}


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

int64_t MOD = 1000000007;
int64_t MAX = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    int N;
    cin >> N;
    vector<int> B(N - 1), A(N);

    for (int i = 0; i < N - 1; i++)
        cin >> B[i];

    for (int i = 1; i < N - 1; i++)
        A[i] = min(B[i - 1], B[i]);

    A[0] = B[0], A[N - 1] = B[N - 2];
    int ans = 0;
    for (auto x : A)
        ans += x;
    cout << ans;
}

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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}

typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

// 最小値yを固定して最大値を最小化する
// 最小値をa[i]にすると決めると、y未満の数を含む区間は選べない
// そういう区間を消すといくつか列が残る
// ある長さmの列からはmax(0,m-k+1)個まで好きに取れる
// これらの候補がq個以上あればq番目に小さいものがxになる

int n, k, q, a[2020], res = inf;

int main() {
	cin >> n >> k >> q;
	rep(i,n) cin >> a[i];
	rep(i,n) {
		int y = a[i], b[2020] = {};
		rep(j,n) if (a[j]<y) b[j]++;
		vector<int> mn;
		rep(l,n) if (!b[l]) {
			int r = l;
			vector<int> t;
			while (r<n && !b[r]) t.push_back(a[r++]);
			sort(all(t));
			rep(j,(int)t.size()-k+1) mn.push_back(t[j]);
			l = r-1;
		}
		sort(all(mn));
		if (mn.size()>=q) chmin(res, mn[q-1]-y);
	}
	cout << res;
}

Measured memory_bytes: 256
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N, K = map(int, input().split())
    A = [0] * (N+1)
    for _ in range(K):
        d = int(input())
        B = list(map(int, input().split()))
        for b in B:
            A[b] = 1
    print(N - sum(A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 66932
#include <bits/stdc++.h>
using namespace std;
int main(){
    int H,N;
    cin >> H >> N;
    int X=0;
    int A[N];
    for(int j=0;j<N;j++){
        cin >> A[j];
        X+=A[j];
    }
    if(X>=H){
        cout << "Yes" <<endl;
    }
    else if(X<H){
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define PRINT(x) cout<<(x)<<endl
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
#define PB push_back
#define MP make_pair

int main() {
    string S, T; cin >> S >> T;
    int ans = 0;
    REP(i, S.size()) {
        if (S[i] != T[i]) ans++;
    }
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 3912
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define error(x) cerr << #x << " = " << x << endl


int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t,n,m,i,j,k,sum=0;
	string a;
	cin>>a;
	cin>>t;
	int r = 0;
	string one="",two="";
	while(t--){
		int x;
		cin>>x;
		if(x==1){
			r++;
		}
		else {
			int f;
			char c;
			cin>>f>>c;
			if(r%2==0){
				if(f==2){
					two+=c;
				}
				else one+=c;
			}
			else {
				if(f==2){
					one+=c;
				}
				else two+=c;
			}
		}
	}
	if(r%2==0){
		reverse(one.begin(),one.end());
		cout<<one+a+two<<'\n';
	}
	else{
		reverse(a.begin(),a.end());
		reverse(two.begin(),two.end());
		cout<<two+a+one<<'\n';
	}
	
	return 0;
}

Measured memory_bytes: 1300
n,m = map(int,input().split())
dp = [2**63]*4096
dp[0] = 0
for i in range(m):
  a,b = map(int,input().split())
  mask = 0
  c = list(map(int,input().split()))
  for i in c:
    mask |= ( 1 << i-1 )
  nxtdp = dp[:]
  for j in range(1 << n):
    if dp[j] < 2 ** 63:
      nxtdp[j | mask] = min(nxtdp[j | mask], dp[j] + a)
  dp = nxtdp
print(dp[(1<<n)-1] if dp[(1<<n)-1] < 2**63 else -1)


Measured memory_bytes: 3316
using System;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] StringArray = Console.ReadLine().Split(' ');
            int[] IntArray = new int[n];

            for(int i = 0; i< n-1; i++)
            {
                IntArray[int.Parse(StringArray[i])-1]++;
                //Console.WriteLine(int.Parse(StringArray[i])-1);
                
            }
            foreach(int i in IntArray)
            {
                Console.WriteLine(i);
            }
            
        }
    }
}


Measured memory_bytes: 42052
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try (Scanner scanner = new Scanner(System.in)) {
			 final String str = scanner.nextLine();
			 final String[] s = str.split("");
			 final int N = s.length;
			 System.out.println(s[0] + String.valueOf(N - 2) + s[N - 1]);
		}
	}
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
using ll = long long;
using Edge = pair<int,int>;
using Graph = vector<vector<Edge>>;

int n; 
Graph G;

vector<int> res;

void dfs(int v, int p, int c){
    res[v] = c;
    for(auto e:G[v]){
        if(e.first==p)
            continue;
        if(e.second & 1)//偶奇判定
            dfs(e.first, v, 1-c);
        else
            dfs(e.first, v, c);
    }
}

int main(){
    cin >> n;
    G.assign(n, vector<Edge>());
    for (int i = 0; i < n - 1;i++){
        int u, v, w;
        cin >> u >> v >> w;
        --u, --v;
        G[u].push_back(Edge(v, w));
        G[v].push_back(Edge(u, w));
    }
    res.assign(n, 0);
    dfs(0, -1, 1);
    for (auto v:res)
        cout << v << endl;
    return 0;
}


Measured memory_bytes: 8960
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pi pair<int,int>
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define sz(x) ((int)x.size())
#define ln(x) ((int)x.length())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define dbg(x) cout<<#x<<": "<<x<<endl
#define clr(x,v) memset(x, v, sizeof(x))
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const double eps = 1e-9;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
const int MAXN = 2e5 + 5;

int parent[MAXN], sz[MAXN];

void make_set()
{
    iota(parent, parent + MAXN, 0);
    fill(sz, sz + MAXN, 1);
}

int find_set(int v)
{
    if(v == parent[v])
        return v;
    else
        return parent[v] = find_set(parent[v]);
}

bool union_set(int a, int b)
{
    a = find_set(a), b = find_set(b);
    if(sz[a] < sz[b])
        swap(a, b);
    if(a != b)
        parent[b] = a, sz[a] += sz[b];
    return a != b;
}

void cp()
{
    int n, m;
    cin >> n >> m;
    make_set();
    for(int i = 0; i < m; i++)
    {
        int u, v;
        cin >> u >> v;
        u--, v--;
        union_set(u, v);
    }
    int mx = 1;
    for(int i = 0; i < n; i++)
        if(i == find_set(i))
            mx = max(mx, sz[i]);
    cout << mx;
}

int main()
{
    FASTIO;
    int t;
    t = 1;
    // cin >> t;
    while(t--)
    {
        cp();
    }
    return 0;
}

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

void fnInput(int& rnTrkSiz, vector<int>& rvnLod)
{
  int nLodSiz;
  cin >> nLodSiz >> rnTrkSiz;

  rvnLod.resize(nLodSiz);
  for (int i = 0; i < nLodSiz; i++)
    cin >> rvnLod[i];
}

int fnSimuAlloc(const vector<int>& cnrvnLod, int nTrkSiz, int nLimLod)
{
  int nCurLod;
  int nCntTrk = 0;

  for (int i = 0; i < cnrvnLod.size(); )
  {
    if (cnrvnLod[i] > nLimLod)  return 0;

    nCntTrk++;
    nCurLod = 0;
    while (i < cnrvnLod.size())
    {
      nCurLod += cnrvnLod[i];
      if (nCurLod > nLimLod)  break;

      i++;
    }
  }
  return (nCntTrk <= nTrkSiz);
}

void fnAlloc(const vector<int>& cnrvnLod, int nTrkSiz, int& rnMinLod)
{
  int nLow  = 0;
  int nHigh = 1000000000;

  while (nLow < nHigh)
  {
    int nLimLod = (nLow + nHigh) / 2;
    if (fnSimuAlloc(cnrvnLod, nTrkSiz, nLimLod))
    {
      rnMinLod = nLimLod;
      nHigh = nLimLod;
    }
    else
      nLow = nLimLod + 1;
  }
}

void fnReSult(int nMinLod)
{
  cout << nMinLod << endl;
}

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

  int nTrkSiz, nMinLod = 0;
  vector<int> vnLod;

  fnInput(nTrkSiz, vnLod);
  fnAlloc(vnLod, nTrkSiz, nMinLod);
  fnReSult(nMinLod);

  return 0;
}



Measured memory_bytes: 3344
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cfloat>
using namespace std;
set <int> edges[200000];
bool used[200000];
int dfs(int cur){
  used[cur] = true;
  int ret = 1;
  for(auto it = edges[cur].begin(); it != edges[cur].end(); it++){
    int next = *it;
    if(!used[next]){
      ret += dfs(next);
    }
  }
  return ret;
}

int main(){
  int N;
  int M;
  cin >> N >> M;
  for(int i = 0; i < M; i++){
    int A;
    int B;
    cin >> A >> B;
    edges[A - 1].insert(B - 1);
    edges[B - 1].insert(A - 1);
  }

  int ans = 0;
  for(int i = 0; i < N; i++){
    if(!used[i]){
      ans = max(ans, dfs(i));
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 41232
#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.at(i);
  }
  
  int now = 0;
  int count = 0;
  while(count++ < N && a.at(now) != 2){
    int mow;
    mow = a.at(now);
    now = mow-1;
  }
  if(count == N+1 && now !=2)
    cout << -1 << endl;
  else
	cout << count << endl;
}


Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int64_t MOD;

int64_t dpow(int64_t x, int64_t y) {
  if (y == 0) {
    return 1;
  }
  if (y % 2 == 0) {
    return dpow(x * x % MOD, y / 2);
  } else {
    return x * dpow(x, y - 1) % MOD;
  }
}

int64_t inv(int64_t x) { return dpow(x, MOD - 2); }

int main() {
  int N;
  cin >> N >> MOD;
  string s;
  cin >> s;

  int64_t result = 0;
  int d = 0;
  vector<int64_t> dp(MOD, 0);
  dp[0] = 1;
  rep(i, N) {
    d = 10 * d + (s[i] - '0');
    d %= MOD;

    if (MOD == 2 || MOD == 5) {
      result += (d % MOD == 0 ? i + 1 : 0);
    } else {
      int shift = dpow(10, i + 1);
      int key = d * inv(shift) % MOD;

      result += dp[key];
      dp[key]++;
    }
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <string>
#include <bitset>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define INF10 1001001001 
#define INF5 100000
#define EPS 1e-10


int main() {
	ll N; cin >> N;
	ll cnt = 1001001001;
	while (N >= 100) {
		cnt = min(cnt, abs(753 - N % 1000));
		N /= 10;
	}
	print(cnt);


	return 0;
}


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

int main() {
  int ld, lt, rd, rt;
  cin >> ld >> lt >> rd >> rt;
  if (ld + lt > rd + rt) {
    cout << "Left" << endl;
  }
  else if (ld + lt < rd + rt) {
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
}

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

int main(void){
    int n,k,q;
    cin >> n >> k >> q;
    vector<int> tasu(n,0);
    int i;
    int a_num;

    for(i=0;i<q;i++){
        cin >> a_num; a_num--;
        tasu[a_num]++;
    }

    for(i=0;i<n;i++){
        if(k-q+tasu[i]>0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,m,i,j;
  cin>>n>>m;
  vector<ll> a(m),b(m);
  for(i=0;i<m;i++){
	cin>>a[i]>>b[i];
  }
  
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  
  cout<<max((ll)0,b[0]-a[m-1]+1)<<endl;
  
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	long long i,n,a,b,x[100010],ans=0;
	cin >> n >> a >> b;
	for(i=0;i<n;i++){
		cin >> x[i];
	}
	
	for(i=0;i<n-1;i++){
		ans += min(a*(x[i+1]-x[i]),b);
	}
	
	cout << ans << endl;
}
		

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

int main() {
    int N;
    int A;
    cin >> N;
    vector<int> ans(N,0);
    for(int i=0;i < N - 1;i++){
        cin >> A;
        ans.at(A - 1)++;
    }
    for(int i = 0;i < N;i++){
        cout << ans.at(i) << endl;
    }
}

Measured memory_bytes: 4052
#include <stdio.h>

int main(){
    char s[3], i, a=0, b=0, c=0;

    scanf("%s", s);

    for(i=0; i<3; i++){
        if(s[i] == 'a')
            a++;
        if(s[i] == 'b')
            b++;
        if(s[i] == 'c')
            c++;
    }

    if(a==1 && b==1 && c==1)
        printf("Yes\n");
    else
        printf("No\n");
    
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int n, k;
    cin >> n >> k;

    vs32 a(n); rep (i, n) cin >> a[i];

    sort(a.begin(), a.end());
    int ans = 0;
    rep (i, k) ans += a[i];

    cout << ans << "\n";

    return 0;
}



Measured memory_bytes: 3660
use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let mut dp = vec![0f64; n + 1];
    dp[0] = 1.0;
    for s in it {
        let p: f64 = s.parse().unwrap();
        for i in (1..(n + 1)).rev() {
            dp[i] = dp[i - 1] * p + dp[i] * (1.0 - p);
        }
        dp[0] *= 1.0 - p;
    }
    let mut ans = 0.0;
    for i in (n / 2 + 1)..(n + 1) {
        ans += dp[i];
    }
    println!("{:.10}", ans);
}

fn main() {
    run();
}

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

void solve(int price) {
    int dif = 1000 - price;
    int all = 0;
    while (0 < dif) {
        int count = 0;
        int d = 0;
        if (500 <= dif) {
            d = 500;
        } else if (100 <= dif) {
            d = 100;
        } else if (50 <= dif) {
            d = 50;
        } else if ( 10 <= dif ) {
            d = 10;
        } else if (5 <= dif) {
            d = 5;
        } else {
            d = 1;
        }
        count = dif / d;
        dif -= count * d;
        all += count;
    }
    cout << all << endl;
}

int main() {
    int price;
    while(true) {
        cin >> price;
        if (price == 0) break;
        else solve(price);
    }
    return 0;
}



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

int main() {
 int A, B;
 cin >> A >> B;
 int x = 1;
 int y = 0;
  
 while (true) {
   if (x < B) {
     y++;
   }
   
   else {
     break;
   }
   x += A - 1;
 }
  
  cout << y <<endl;
}

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

int main() {
  int N, S, Sum=0;
  vector<int> A(9);
  cin >> N;
  rep(i, N){
    cin >> S;
    if(S<400) A.at(0)++;
    else if(S<800) A.at(1)++;
    else if(S<1200) A.at(2)++;
    else if(S<1600) A.at(3)++;
    else if(S<2000) A.at(4)++;
    else if(S<2400) A.at(5)++;
    else if(S<2800) A.at(6)++;
    else if(S<3200) A.at(7)++;
    else A.at(8)++;
  }
  rep(i, 8) if(A.at(i)>0) Sum++;
  cout << max(1,Sum) << " " << Sum+A.at(8) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <numeric>
#include <string>
#include <map>
#include <set>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1145141919
typedef long long int ll;
using namespace std;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
    for (T &x : vec)
        is >> x;
    return is;
}

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

    if(n==1){
        cout << "Hello World" << endl;
    }else{
        int a,b;
        cin >> a >> b;

        cout << a+b << endl;
    }

    return 0;
}

Measured memory_bytes: 764
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define ford(i, n) for (int i = ((int)(n) - 1); i >= 0; --i)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef pair<int, int> pii;
typedef vector<pii> vii;
#define sz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()

#define left left___
#define right right__

void solve (string s)
{
    cout << s.substr(0, sz(s) - strlen("FESTIVAL")) << endl;
}

int main()
{
#ifdef LOCAL
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    string n;
    while (cin >> n)
        solve(n);
}


Measured memory_bytes: 256
/*
 * main.cpp
 *
 *  Created on: 2020/04/09
 *      Author: SkAaO
 */

#include <iostream>

using namespace std;

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

	int min = 1;

	for(int i = 0; i < N; i++){
		if(min + K <= min * 2){
			min += K;
		}else{
			min *= 2;
		}
	}

	cout << min << endl;

	return 0;
}




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

typedef long long ll;

int main()
{
	ll a, b, n;
	cin >> a >> b >> n;

	if (n < b) {
		cout << a * n / b << endl;
	}
	else {
		cout << a * (b-1) / b << endl;
	}

	return 0;
}

Measured memory_bytes: 3624
/**
  * @brief atcoder
  * @author yao
  */
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <climits>
#include <cmath>
#define ft first
#define sd second
#ifdef DBG
#   define dbg_pri(x...) fprintf(stderr,x)
#else
#   define dbg_pri(x...) 0
#   define NDEBUG
#endif //DBG
#include <cassert>

typedef unsigned int uint;
typedef long long int lli;
typedef unsigned long long int ulli;

#define N 512
#define M 32
#define K (1048576*32)
#define T (256*5)

int c[M];
int s[N][M];
int t[N], max_t[N];
std::pair<int,int> lu[M][N];

constexpr int n = 365, m = 26;

int count()
{
    int last[M];
    memset(last,-1,sizeof(last));
    int res = 0;
    for(int i=0;i<n;++i)
    {
        int l = last[t[i]], d = i-l;
        last[t[i]] = i;
        res += s[i][t[i]];
        res -= c[t[i]]*d*(d-1)/2;
    }
    for(int i=0;i<m;++i)
    {
        int l = last[i], d = n-l;
        res -= c[i]*d*(d-1)/2;
    }
    for(int i=0;i<m;++i)
        for(int j=0;j<n;++j)
            lu[i][j].ft = j-1<0||t[j-1]==i ? j-1 : lu[i][j-1].ft;

    for(int i=0;i<m;++i)
        for(int j=n-1;j>=0;--j)
            lu[i][j].sd = j+1>=n||t[j+1]==i ? j+1 : lu[i][j+1].sd;

    return res;
}

int pos, ot, nt;

int update_dryrun(int x, int k)
{
    int res;
    pos = x, ot = t[x], nt = k;
    res = s[x][nt] + c[nt] * (x-lu[nt][x].ft) * (lu[nt][x].sd-x)
        - s[x][ot] - c[ot] * (x-lu[ot][x].ft) * (lu[ot][x].sd-x);
    return res;
}

void patch()
{
    const int &x = pos;

    for(int i=x+1, k=lu[ot][x].ft; i<n  && lu[ot][i].ft==x; ++i) lu[ot][i].ft=k;
    for(int i=x-1, k=lu[ot][x].sd; i>=0 && lu[ot][i].sd==x; --i) lu[ot][i].sd=k;

    for(int i=x+1, k=lu[nt][x].ft; i<n  && lu[nt][i].ft==k; ++i) lu[nt][i].ft=x;
    for(int i=x-1, k=lu[nt][x].sd; i>=0 && lu[nt][i].sd==k; --i) lu[nt][i].sd=x;

    t[x] = nt;
}

int main()
{
    int d;
    scanf("%d", &d);
    assert(d == n);
    for(int i=0;i<m;++i) scanf("%d", &c[i]);
    for(int i=0;i<n;++i)for(int j=0;j<m;++j) scanf("%d", &s[i][j]);
    for(int i=0;i<n;++i) t[i] = rand() % m;
    memcpy(max_t,t,sizeof(max_t));
    int val = count(), max_val = val;
#ifdef DBG
    int init_val = val;
    int ca=0, cb=0;
#endif //DBG
    for(int i=0;i<K;++i)
    {
        int x = rand()%n, k = rand()%(m-1);
        if(k>=t[x]) ++k;
        int nxt_v = val + update_dryrun(x,k);
        if(nxt_v >= val || rand() <= (int)(exp((double)(nxt_v-val)/T)*((lli)RAND_MAX+1)))
        {
#ifdef DBG
            (nxt_v < val ? ca : cb) ++;
#endif //DBG
            val = nxt_v;
            patch();
            if(max_val < val) 
            {
                max_val = val;
                memcpy(max_t,t,sizeof(max_t));
            }
        }
    }
    for(int i=0;i<n;++i) printf("%d\n", max_t[i]+1);
    dbg_pri("poi 3: init=%d max=%d val=%d %d %d\n", init_val, max_val, val, ca, cb);
    return 0;
}


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

vector<int> v;
int n, m, q, ans = 0;
int a[55], b[55], c[55], d[55];

int check() {
	int val = 0;
	for (int i = 0; i < q; i++) {
		if (v[b[i]] - v[a[i]] == c[i])
			val += d[i];
	}
	return val;
}

void dfs(int i, int cur) {
	if (i >= n) {
		ans = max(ans, check());
		return;
	}

	for (int j = cur; j <= m; j++) {
		v.push_back(j);
		dfs(i + 1, j);
		v.pop_back();
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> m >> q;
	for (int i = 0; i < q; i++) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
		a[i]--; b[i]--;
	}

	dfs(0, 1);

	cout << ans << "\n";
}

Measured memory_bytes: 3668
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int Get(int x)
{  int sum=0;
   while(x)
   {  sum+=x%10;
      x/=10;
   }
   return sum;
}
int main() 
{ int n,a,b,ans=0;
  scanf("%d%d%d",&n,&a,&b);
  for(int i=1;i<=n;i++)
    if(Get(i)>=a&&Get(i)<=b)ans+=i;
  printf("%d\n",ans); 
  return 0;
}

Measured memory_bytes: 256
h,w = map(int,input().split())
ch = []
for i in range(h):
    a = str(input())
    if "#" in a:
        ch.append(a)
h = len(ch)
bit = [0]*w
for i in range(h):
    for j in range(w):
        if ch[i][j] == "#":
            bit[j] = 1

for i in range(h):
    ans = ""
    for j in range(w):
        ans += ch[i][j]*bit[j]
    print(ans)

Measured memory_bytes: 9156
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define endl '\n'
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9 + 7 ;
const ll N = 1e5 + 10 ;

int main(){
    fastio
int x;
cin>>x;

for (int i = 1; i <=9; i++)
{
    for (int j = i; j <=9; j++)
    {
        if(i*j==x)
        return cout<<"Yes",0;
    }
    
}
cout<<"No"<<endl;

    return 0 ;
}

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

int main()
{
    int a,b;
    cin>>a>>b;
    if(a==b){cout<< "Draw" ;}
    else if(a==1){cout<< "Alice";}
    else if(b==1){cout<< "Bob" ;}
    else if(a>b){cout<< "Alice" ;}
    else if(b>a){cout<< "Bob";}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <typename T>
inline void readin(T &x) {
    x = 0;
    T fh = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
    for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);
    x *= fh;
}
inline void d_read(double &x) {
    x = 0.0;
    int fh = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
    for (; isdigit(ch); ch = getchar()) x = x * 10 + (ch ^ 48);
    if (ch == '.') {
        double num = 1.0;
        ch = getchar();
        for (; isdigit(ch); ch = getchar()) x = x + (num /= 10) * (ch ^ 48);
    }
    x *= fh;
}
template <typename T>
inline void wt(T x) {
    if (x > 9) wt(x / 10);
    putchar(x % 10 + 48);
}
template <typename T>
inline void writeln(T x, char c) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    wt(x);
    putchar(c);
}
const int N = 2e5 + 5;
int f[N], siz[N];
inline int g(int x) {
    if (f[x] == x) return x;
    return f[x] = g(f[x]);
}
int main() {
    int n, m;
    readin(n); readin(m);
    for (int i = 1; i <= n; i ++) {
        f[i] = i;
        siz[i] = 1;
    }
    int xi, yi, x, y;
    for (int i = 1; i <= m; i ++) {
        readin(x); readin(y);
        xi = g(x); yi = g(y);
        if (xi != yi) {
            f[xi] = yi;
            siz[yi] += siz[xi];
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i ++) {
        if (g(i) == i) {
            ans = max(ans, siz[i]);
        }
    }
    writeln(ans, '\n');
    return 0;
}

Measured memory_bytes: 11328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int gcd(int a, int b){
  return b ? gcd(b, a%b) : a;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,d,e,f; cin>>a>>b>>c>>d>>e>>f;
    // 到達可能な水の量
    set<int> wat;
    for(int x=0; x<=f; x++){
        for(int y=0; y<=f; y++){
            if(a*100*x+b*100*y <= f) wat.insert(a*100*x+b*100*y);
        }
    }
    // それぞれに対して砂糖を溶かせるだけ溶かし、最濃をつくる
    double deg = -1;
    pair<int, int> ans;
    for(auto w : wat){
        // 砂糖の限界量
        int cap = min(w*e / 100, f-w);
        // 作れる砂糖量が一番多いやつを全探索する
        int sugar = 0;
        for(int x=0; x<=f; x++){
            for(int y=0; y<=f; y++){
                if(c*x + d*y <= cap){
                    sugar = max(sugar, c*x + d*y);
                }
            }
        }
        // このときの濃度
        double deg2 = (double)100*sugar/(double)(w+sugar);
        // cerr<<w<<" "<<cap<<" "<<sugar<<" "<<deg2<<endl;
        if(deg<deg2){
            deg = deg2;
            ans = make_pair(sugar+w, sugar);
        }
    }
    cout<<ans.first<<" "<<ans.second<<endl;
}
// arc083_a.exe

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    int score = n + 1;
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        int p;
        cin >> p;
        if (score > p)
        {
            ans++;
            score = p;
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
d, g = map(int, input().split())
o, c = zip(*[map(int, input().split()) for _ in range(d)])

comp = [(i+1)*o[i]+c[i]//100 for i in range(d)]

G = g//100

# 大きい数（全問解く)
ans = sum(o)

for j in range(2**d):
    tmp = bin(j)
    ope = tmp[2:len(tmp)].zfill(d)

    now = 0  # 得点
    f = 1
    num = 0  # 問題数
    re = [[0, 0]]  # とかなかった問題の配列

    for i in range(d):
        if ope[i] == '1':
            now += comp[i]
            num += o[i]
        else:
            re.append([(i+1)*(o[i]-1), i+1])

        re.sort()
        re.reverse()

    if now < G:
        if now+re[0][0] < G:
            # 答えにならない
            now = sum(o)
            f = -1
        else:
            # 中途半端に解く問題数
            K = (G - now)//re[0][1]

            # 中途半端に解くときに、%==0ならちょうどgoalになるけど、それ以外の時は、ちょっとだけ点数が足りないから問題をもう一問解く
            if ((G-now) % re[0][1] > 0):
                K = K+1
            num += K
    if num < ans and f > 0:
        ans = num
print(ans)


Measured memory_bytes: 3064
/*
我的心脏怦怦跳，监管者就在附近
*/
#include<bits/stdc++.h>
#include<string>
#include<iostream>
#include<cmath>
#include<set>
#include<stack>
#include<queue>
#include<unistd.h>
#include<stdio.h>
#include<cstring>
#define random(a,b) (rand()%(b-a+1)+a)
using namespace std;

int main()
{
	int a,b;
	cin>>a>>b;
	b+=a*3;
	cout<<b/2;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string.h>
#include <algorithm>
#include <math.h>
using namespace std;
#define maxn 105
#define maxx 1000000007
long long dp[maxn][maxn][256];
int a[maxn];

int main()
{
	memset(dp, 0, sizeof(dp));
	int n, kk;
	cin >> n >> kk;
	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	for (int i = 0; i <= n; i++)
		dp[i][0][0] = 1;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= i; j++)
		{
			dp[i][1][a[j]] = 1;
		}
	}
	for (int i = 2; i <= n; i++)
	{
		for (int j = 2; j <= i; j++)
		{
			for (int k = 0; k <= 255; k++)
			{
				dp[i][j][k] += dp[i - 1][j - 1][a[i]^k];
				dp[i][j][k] %= maxx;
				dp[i][j][k] += dp[i - 1][j][k];
				dp[i][j][k] %= maxx;
			}
		}
	}
	long long anss = 1;
	long long ans = 0;
	for (int i = 0; i <= n; i++)
	{
		anss = 1;
		if (dp[n][i][kk]>0)
		{
			for (int j = 1; j <= i; j++)
			{
				anss *= j;
				anss %= maxx;
			}
			anss *= dp[n][i][kk];
			anss %= maxx;
			ans += anss;
			ans %= maxx;
		}
	}
	cout << ans << endl;
	

	return 0;
}

Measured memory_bytes: 22272