akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

//短縮
#define rep(i,n) for(int i=0;i<(n);++i)
//sort()用
#define all(v) v.begin(), v.end()

#define PB(N) push_back(N)

using namespace std;

using Graph = vector<vector<int>>;

int main(){
  long long H; cin >> H;
  long long buffer=1;
  int count=0;
  while(H/2 >= 1){
    H/=2;
    buffer*=2;
  }

  cout << buffer-1 + buffer;

  /*/
  queue<long long> enemy;
  enemy.push(H);
  long long count=0;
  while(!enemy.empty()){
    long buffer = enemy.front();
    enemy.pop();

    if(buffer==1){

    }
    else{
      rep(i,2){
        enemy.push(buffer/2);
      }
    }
    count++;
  }
  cout << count;
  /*/

  return 0;
}


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

int main() {
	int M, N;
	cin >> N >> M;
	vector<vector<int>> data(M, vector<int>(2, 0));
	for (int i = 0; i < M; i++) {
		cin >> data.at(i).at(0) >> data.at(i).at(1);
	}
	int L = 0;
	int R = N;
	for (int i = 0; i < M; i++) {
		L = max(data.at(i).at(0), L);
		R = min(data.at(i).at(1), R);
	}
	if (R - L + 1 > 0) {
		cout << R - L + 1 << endl;
	}
	else {
		cout << 0 << endl;
	}
}


Measured memory_bytes: 5760
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
#define X    first
#define Y    second
//作者:中国江苏南京丁天行
using namespace std;
//数组不要开小了
pair<int,int> p[100005];
pair<int,pair<int,int> >q[200005];
int n,x[100005],y[100005],s,f[100005];
ll ans;
int cty(int x){return x==f[x]?x:f[x]=cty(f[x]);}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d%d",x+i,y+i);
    for(int i=1;i<=n;i++)p[i]=mp(x[i],i);
    sort(p+1,p+n+1);
    for(int i=1;i<n;i++)q[++s]=mp(p[i+1].X-p[i].X,mp(p[i].Y,p[i+1].Y));
    for(int i=1;i<=n;i++)p[i]=mp(y[i],i);
    sort(p+1,p+n+1);
    for(int i=1;i<n;i++)q[++s]=mp(p[i+1].X-p[i].X,mp(p[i].Y,p[i+1].Y));
    sort(q+1,q+s+1);
    for(int i=1;i<=n;i++)f[i]=i;
    for(int i=1;i<=s;i++){
            if(cty(q[i].Y.X)==cty(q[i].Y.Y)) continue;
            ans+=1ll*q[i].X;
            f[f[q[i].Y.X]]=f[q[i].Y.Y];
    }
    cout<<ans<<endl;
//	system("pause");
	return 0;
}


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

int main() {
source:
    ll a, b;
    cin >> a >> b;
    bool ans[100][100] = {};
    rep(i, 50) {
        rep(j, 100) { ans[i][j] = true; }
    }

    ll h = 0, w = 0;
    rep(i, a - 1) {
        if (w == 100) {
            h += 2;
            w = 0;
        }
        ans[h][w] = false;
        w += 2;
    }
    h = 99, w = 0;
    rep(i, b - 1) {
        if (w == 100) {
            h -= 2;
            w = 0;
        }
        ans[h][w] = true;
        w += 2;
    }

    cout << 100 << " " << 100 << endl;
    rep(i, 100) {
        rep(j, 100) {
            if (ans[i][j]) {
                cout << "#";
            } else {
                cout << ".";
            }
        }
        cout << endl;
    }

    return 0;
}



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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= m; i--)
#define ll long long
#define pb push_back
#define popb pop_back
using namespace std;

int main(){
  int ans = 999;
  string s;
  cin >> s;
  string tmp;
  int sub;
  REP(i, (s.size() -2)){
  tmp = s.substr(i, 3);
  sub = stoi(tmp);
  sub = abs(sub - 753);
  if(sub < ans) ans = sub;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  string s;
  cin >> s;
  string ans = "";
  rep(i, s.size()){
    if(s.at(i) == 'B'){
      if(ans.size() > 0) ans.pop_back();
    }else{
      ans.push_back(s.at(i));
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
s = input()
q = int(input())
rev = False
L = ""
R = ""
for _ in range(q):
    query = input()
    if query == "1":
        rev = not rev
    else:
        _, f, c = query.split(" ")
        if f == "1":
            if rev:
                R = R + c
            else:
                L = c + L
        else:
            if rev:
                L = c + L
            else:
                R = R + c

if rev:
    s = s[::-1]
    L = L[::-1]
    R = R[::-1]
    print(R + s + L)
else:
    print(L + s + R)


Measured memory_bytes: 4440
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

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

    int N = scanner.nextInt();
    PriorityQueue<Task> queue = new PriorityQueue<>();
    for (int i = 0; i < N; i++) queue.add(new Task(scanner.nextInt(), scanner.nextInt()));

    if (possible(queue)) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }

  private static boolean possible(Queue<Task> queue) {
    long current = 1_000_000_000_000_000L;
    while (!queue.isEmpty()) {
      Task t = queue.remove();
      if (t.end < current) current = t.end;
      current -= t.duration;
      if (current < 0) return false;
    }
    return true;
  }

  private static class Task implements Comparable<Task> {
    private final int end;
    private final int duration;

    private Task(int duration, int end) {
      this.end = end;
      this.duration = duration;
    }

    @Override public int compareTo(Task task) {
      if (end != task.end) return task.end - end;
      return task.duration - duration;
    }
  }
}


Measured memory_bytes: 107036
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N;
  cin >> N;
  vp pos(N);
  rep(i,N) {
    int x,y;
    cin >> x >> y;
    pos[i] = make_pair(x,y);
  }
  if(N == 1) {
    cout << 1 << endl;
    return 0;
  }
  int ans = INF;
  vp pq;
  rep(i,N) {
    P base = pos[i];
    int bx = base.first;
    int by = base.second;
    rep(j,N) {
      if(i == j) continue;
      pq.emplace_back(bx - pos[j].first,by-pos[j].second);
    }
  }
  rep(i,sz(pq)) {
    int k = 0;
    rep(x,N){
      rep(y,N) {
        if(x == y) continue;
        if(pos[x].first - pos[y].first == pq[i].first && pos[x].second - pos[y].second == pq[i].second) {
          k++;
        }
      }
    }
    ans = min(ans,N-k);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
si = list(map(str, input().split()))

def checkiroha(a):
    a1 = str(a)
    for i in range(len(a1)):
        if (a1[i] in si):
            return 'F'
        elif (i == (len(a1)-1)):
            return 'T'
        else:
            continue

while (checkiroha(n) == 'F'):
    n = n+1
else:
    print(n)

Measured memory_bytes: 3060
def solve(W,H,N):
    B = [[1 for i in range(W)] for j in range(H)]
    for i in range(N):
        x,y,a =[int(j) for j in input().split(' ')]
        i
        if a==1:
            for j in range(x):
                for k in range(H):
                    B[k][j]=0
        if a==2:
            for j in range(x,W):
                for k in range(H):
                    B[k][j]=0
        if a==3:
            for j in range(y):
                B[j] =[0]*W
        if a==4:
            for j in range(y,H):
                B[j] =[0]*W
    #print(B)
    c =0
    for i in range(W):
        for j in range(H):
            if B[j][i] ==1:
                c +=1
    print(c)
W,H,N = [int(i) for i in input().split(' ')]

solve(W,H,N)


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

int main() {
  int n;
  cin>>n;
  int a[n];
  for (int i=0; i<n; i++) cin>>a[i];
  long long y1 = 0;
  for (int i=0; i<n; i++) {
    if (i % 2 == 0) {
      y1 += a[i];
    } else {
      y1 -= a[i];
    }
  }
  cout<<y1;
  for (int i=1; i<n; i++) {
    y1 = 2*a[i-1] - y1;
    cout<<" "<<y1;
  }
  cout<<endl;
}

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

int main() {
  int N, m, l;
  cin >> N;
  bool b = true;
  vector<int> t(N);
  vector<int> x(N);
  vector<int> y(N);
  for(int i = 0; i < N; i++) {
    cin >> t.at(i) >> x.at(i) >> y.at(i);
  }
  m = abs(x.at(0))+abs(y.at(0));
  l = t.at(0);
  if(m <= l && m%2 == l%2) {
  }
  else {
    b = false;
  }
  for(int i = 0; i < N-1; i++) {
    m = abs(x.at(i+1)-x.at(i)) + abs(y.at(i+1)-y.at(i));
    l = t.at(i+1)-t.at(i);
    if(m <= l && m%2 == l%2) {
    }
    else {
      b = false;
      break;
    }
  }
  if(b) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 1408
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[500][500];

int main(){
  cin >> n;
  ll mx = -INF,mn = INF;
  rep(i,0,n){
    cin >> d[i];
    mn = min(d[i],mn);
    mx = max(d[i],mx);
  }
  ll ans = INF;
  lep(i,mn,mx){
    m = 0;
    rep(j,0,n)m += (d[j]-i)*(d[j]-i);
    ans = min(ans,m);
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    while(true){
      int n = sc.nextInt();
      if(n == 0){
        break;
      }
 
      int s[] = new int[n];
      int goukei = 0;
      for(int i = 0; i < n; i++){
        s[i] = sc.nextInt();
        goukei += s[i];
      }
 
      double heikin = (double)goukei/n;
      double hensa, hensa2, a2;
      a2 = (double)0;
      for(int i = 0; i < n; i++){
        hensa = s[i] - heikin;
        hensa2 = Math.pow(hensa,2);
        a2 += hensa2/n;
      }
      double a = Math.sqrt(a2);
      System.out.println(String.format("%4f",a));
    }
  }
}


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

#define whole(f, x, ...)                                 \
  ([&](decltype((x)) whole) {                            \
    return (f)(begin(whole), end(whole), ##__VA_ARGS__); \
  })(x)

using namespace std;
using ll = long long;

void solve() {
  string s;
  cin >> s;
  bool a = false, b = false;

  for (auto t : s) {
    if (t == 'A') a = true;
    if (t == 'B') b = true;
  }
  cout << (a && b ? "Yes" : "No") << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  solve();
  return 0;
}


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

int main(){
    int R, G;
    cin >> R >> G;
    cout << G+G-R << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define ull unsigned long long
#define N 100005
#define mod 1000000007
//#define mod 1e18
#define boost ios_base::sync_with_stdio(false);cin.tie(0)
#define prec(n) fixed<<setprecision(n)

#define mii map<int,int>
#define mll map<ll,ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi  first

#define se second
#define pb push_back
#define mp make_pair
#define pp pop_back
#define vii vector<int>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define all(c) c.begin(),c.end()
#define tr(it,c) for(it = c.begin() ; it!=c.end() ; it++)
int inf = INT_MAX ;
ll modulo(ll num,ll MOD=mod){ return ((num%MOD)+MOD)%MOD;} // for negative integer
ll power(ll b,ll e,ll MOD=mod){ll ans=1; while(e){if(e%2) ans=(ans*b)%MOD; b=(b*b)%MOD; e/=2;} return ans;}
ll inv(ll num,ll MOD=mod){ return power(modulo(num),MOD-2,MOD); }
ll gcd(ll a,ll b){ return ((b==0) ? a:gcd(b,a%b));}

int main(){
	boost;
	
	int a,b;
	cin>>a>>b;
	
	for(int i = 0;i<=a;i++){
		int k = b - 2*i;
		if(k%4==0&&k>=0&&k/4+i==a){
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
	
	//int arr[6];
	//memset(arr,0,sizeof(arr));
	//for(int i = 0;i<5;i++){
		//int a;
		//cin>>a;
		//arr[a]++;
	//}
	
	//for(int i = 1;i<6;i++){
		//if(arr[i]==0){
			//cout<<i;
			//return 0;
		//}
	//}
	//return 0;
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
 
int main(){ 
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if((abs(b-a)<=d&&abs(c-b)<=d)||abs(c-a)<=d)cout<<"Yes";
    else cout<<"No";
 
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int>a(N);
  vector<int>mark(9);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
    int A=a.at(i);
    if(A/400<8){
      if(mark.at(A/400)==0){
        mark.at(A/400)=1;
      }
    }
    else{
      mark.at(8)=mark.at(8)+1;
    }
  }
  int sum=0;
  for(int i=0;i<9;i++){
    sum=sum+mark.at(i);
  }
  cout<<max(1,sum-mark.at(8))<<" "<<sum<<endl;
}


Measured memory_bytes: 256
import itertools

N,M,X = list(map(int,input().split()))
tex=[]
for _ in range(N):
  lst = list(map(int,input().split()))
  tex.append(lst)

p_list = list(itertools.product([0,1], repeat=N))
#print((p_list))
cost_min = 10**9
for p in p_list:
  #p = list(p)
  und=[0]*M
  cost = 0
  for i in range(N):
    if p[i]==1:
      cost += tex[i][0]
      for j in range(M):
        und[j]+=tex[i][j+1]
  #print(und)
  f=True
  for k in range(M):
    if und[k]<X:
      f=False
      break
  if f and cost_min>cost:
    cost_min = cost
    
if cost_min==10**9:
  print(-1)
else:
  print(cost_min)

Measured memory_bytes: 9652
#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios::sync_with_stdio(false);
  int A,B,C;
  cin>>A>>B>>C;
  if(A == 5 && B == 7 & C == 5 || A == 5 && B == 5 & C == 7 || A == 7 && B == 5 & C == 5)
    cout<<"YES";
  else 
    cout<<"NO";
  return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Stack;
import java.util.StringTokenizer;
public class Main{
    static int[] memo;
    static ArrayList<Integer>[] adjlist;
    public static void main(String[] args) throws IOException {
        scanner sc = new scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int n = sc.nextInt();
        int m = sc.nextInt();

        adjlist = new ArrayList[n];
        for (int i = 0; i < n; i++) {
            adjlist[i] = new ArrayList<>();
        }

        for (int i = 0; i < m; i++)
            adjlist[sc.nextInt()-1].add( sc.nextInt()-1);

        memo = new int[n];
        Arrays.fill(memo,-1);
        int max = 0;
        for (int i = 0; i < n; i++) {
            if (memo[i] == -1)
                dp(i);

            max = Math.max(memo[i],max);
        }
        out.println(max);
        out.flush();

    }

    static int dp(int i){

        if (memo[i] != -1)
            return  memo[i];

        int max = 0;
        for (int nxt: adjlist[i]) {
            max = Math.max(max,dp(nxt)+1);
        }
        return memo[i] = max;
    }
}
class scanner{
    StringTokenizer st;
    BufferedReader br;
    public scanner(InputStream s){
        br = new BufferedReader(new InputStreamReader(s));
    }
    public scanner (String s) throws FileNotFoundException { br = new BufferedReader(new FileReader(s));}

    public String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    public long nextLong() throws IOException {
        return  Long.parseLong(next());
    }

    public String nextLine() throws IOException {
        return br.readLine();
    }

    public boolean ready() throws IOException {
        return br.ready();
    }
}

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

public class Main {

	final static long MOD = 1000000007L;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static ArrayList<int[]> list = new ArrayList<>();
	public static void main(String[] args) throws Exception {

		System.out.println((long)Math.pow(nextInt(), 3));

	}

	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static String concatStringArray(String[] s){
		StringBuffer sb = new StringBuffer();
		for(String x:s){
			sb.append(x);
		}
		return sb.toString();
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 24220
import Control.Monad
import Data.Array
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Maybe
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

counts (a : as) i countTable numTable = do
  p <- VUM.read countTable a
  VUM.write countTable a (p + 1)
  VUM.write numTable i a
  when (as /= []) $ counts as (i + 1) countTable numTable

calc i n s countTable = do
  p <- VUM.read countTable i
  let s' = s + p * (p -1) `div` 2
  if i == n
    then return s'
    else calc (i + 1) n s' countTable

sim i n s numTable countTable answerTable = do
  k <- VUM.read numTable i
  a <- VUM.read answerTable k
  if a == 0
    then do
      c <- VUM.read countTable k
      let a' = s - (c - 1)
      print a'
      VUM.write answerTable k a
    else print a
  when (i /= n) $ sim (i + 1) n s numTable countTable answerTable

main = do
  n <- getInt
  as <- getIntList
  answerTable <- VUM.replicate (n + 1) 0 :: IO (VUM.IOVector Int)
  countTable <- VUM.replicate (n + 1) 0 :: IO (VUM.IOVector Int)
  numTable <- VUM.replicate (n + 1) 0 :: IO (VUM.IOVector Int)
  counts as 1 countTable numTable
  s <- calc 1 n 0 countTable
  sim 1 n s numTable countTable answerTable


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

#define repo(i,n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;

int main(){
    double d;
    cin >> d;

    const double PI=3.14159265358979323846;

    cout << 2.0 * d * PI << endl;

    return 0;
}



Measured memory_bytes: 3788
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <math.h>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using pii = pair<Int,Int>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

Int LCM(Int a, Int b){
    return a*b/GCD(a,b);
}


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

    vector<string> endA,startB,both;

    int count = 0;

    rep(i,N){
        string s;
        cin >>s;

        if(s[0]=='B'&&s[s.size()-1]=='A'){
            both.push_back(s);

        }else if (s[0]=='B'){
            startB.push_back(s);
        }else if (s[s.size()-1]=='A'){
            endA.push_back(s);
        }

        rep(i,s.size()-1){
            if(s[i]=='A'&&s[i+1]=='B'){
                count++;
            }
        }
    }

    int a_size = endA.size();
    int b_size = startB.size();
    int both_size = both.size();

    if(both_size>0){
        if(a_size+b_size>0){
            count += both_size+min(a_size,b_size);
        }else{
            count += both_size-1;
        }
    }else{
        count += min(a_size, b_size);
    }


    cout << count << endl;

    return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int x,tot=0;
	for(int i=1;i<=3;i++)
	{
		scanf("%d",&x);
		tot=tot*10+x;
	}
	tot%4==0?printf("YES\n"):printf("NO\n");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int n,sum=0,i,t;
    scanf("%d",&n);
    t=n;
    while(t>0){
        sum+=t%10;
        t/=10;
    }
    if(n%sum)
        printf("No\n");
    else
        printf("Yes\n");
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
/*
#ifndef ONLINE_JUDGE
    #define cin f
    #define cout g
    ifstream cin("a.in");
    ofstream cout("a.out");
#endif
*/
int n,m,x,y,ans;
int visit[1<<17],son[1<<17];
bool viz[1<<17];
vector <int> G[1<<17];
void bfs(int x)
{
    queue <int> Q;
    Q.push(x);
    visit[x]=1;
    while(!Q.empty())
    {
        int cur=Q.front();
        Q.pop();
        ///cerr<<cur<<'\n';
        ans=max(ans,visit[cur]-1);
        for(int i=0;i<(int)G[cur].size();++i)
        {
            son[G[cur][i]]--;
            visit[G[cur][i]]=max(visit[G[cur][i]],visit[cur]+1);
            if(!son[G[cur][i]]) Q.push(G[cur][i]);
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>m;
    for(int i=1;i<=m;++i)
    {
        cin>>x>>y;
        viz[x]=1;
        son[x]++;
        ///G[x].push_back(y);
        G[y].push_back(x);
    }
    for(int i=1;i<=n;++i)
        if(!viz[i]&&!visit[i])
            bfs(i);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 7552
#include <stdio.h>
int o[200010];
int u[200010];
int main() {
    int m;
    int n;
    scanf("%d",&m);
    n = m * 2 - 1;
    for(int i = 0; i < n; i++) scanf("%d", &o[i]);
    int l = 1, r = n;
    while(l <= r) {
        int mid = (l + r) >> 1;
        for(int i = 0; i < n; i++) u[i] = o[i] >= mid;
        
        if(u[n/2] == u[n/2+1] || u[n/2] == u[n/2-1]) {
            if(u[n/2]) l = mid + 1;
            else r = mid - 1;

            continue;
        }

        int left = n / 2;
        int right = n / 2;
        while(left - 1 >= 0 && u[left - 1] != u[left]) left--;
        while(right + 1 < n && u[right + 1] != u[right]) right++;

        int flag = u[n/2];
        while(left < n/2 && n/2 < right) {
            flag = 1 - flag;
            left++;
            right--;
        }
        if(flag) l = mid + 1;
        else r = mid - 1;
    }
    printf("%d\n", l - 1);
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
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; }
const long long INF = 1LL << 60;

// 入力
int N;
long long h[100010][3];

// DP テーブル
long long dp[100010][3] = {};

int main() {
  int N; cin >> N;
  for (int i = 0; i < N; ++i) for (int j = 0; j < 3; j++) cin >> h[i][j];

  // ループ
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < 3; ++j) {
      for (int k = 0; k < 3; ++k) {
        if (j==k) continue;
        chmax(dp[i + 1][k], dp[i][j]+ h[i][k]); //dp[1][]には1日目の結果…
      }
    }
  }
    // 答え
    cout << max(dp[N][0], max(dp[N][1], dp[N][2])) << endl;
}

Measured memory_bytes: 8256
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int x; cin >> x;
    int sum = 0;
    string s = to_string(x); int n = (int)s.size();
    rep(i, n) sum += s[i] - '0';
    if(x % sum == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 3720
#include<stdio.h>

#define REP(i,n) for(int i = 0; i < (n); i++)
#define STRS(i,str) for(int i = 0; str[i]; i++)

int main(void){
	char ch[120];
	int dum;
	int a = 0, b = 0;
	scanf("%d%s", &dum, ch);
	STRS(i, ch)
		if(ch[i] == '(') a++;
		else{
			a--;
			if(a < b) b = a;
		}
	REP(i, -b) putchar('(');
	printf(ch);
	REP(i, a - b) putchar(')');
	putchar('\n');
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <string>

using namespace std;

int n;
char str[9][5];
char fie[3][3][5];
int cnt;
bool used[9];
char data[8]={'g','w','r','b','G','W','R','B'};

void swap(int x,int y){
	char d=fie[x][y][0];
	for(int i=0;i<3;i++){
		fie[x][y][i]=fie[x][y][i+1];
	}
	fie[x][y][3]=d;
}

void dfs(int x,int y){
	if(y==3){
		cnt++;
		return;
	}
	for(int l=0;l<9;l++){
		if(used[l])continue;
		used[l]=true;
		for(int i=0;i<4;i++)fie[x][y][i]=str[l][i];
		for(int i=0;i<4;i++){
			swap(x,y);
			//printf("%d %d %s\n",x,y,fie[x][y]);
			bool flag=true;
			if(y>0){
				for(int j=0;j<8;j++){
					if(fie[x][y][0]==data[j]){
						if(fie[x][y-1][2]!=data[(j+4)%8])flag=false;
					}
				}
			}
			if(x>0){
				for(int j=0;j<8;j++){
					if(fie[x][y][3]==data[j]){
						if(fie[x-1][y][1]!=data[(j+4)%8])flag=false;
					}
				}
			}
			if(flag)dfs((x+1)%3,y+(x+1)/3);
		}
		used[l]=false;
	}
}
int main(void){
	scanf("%d%*c",&n);
	for(int i=0;i<n;i++){
		for(int j=0;j<9;j++){
			scanf("%c%c%c%c%*c",&str[j][0],&str[j][1],&str[j][2],&str[j][3]);
		}
		cnt=0;
		dfs(0,0);
		printf("%d\n",cnt);
	}
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>


int main(){
	
	int a,b,d,r;
	double f;
	
	std::cin>>a>>b;
	d=a/b, r=a%b, f=(double)a/(double)b;
	std::cout << d <<" "<< r <<" ";
	printf("%.8f\n",f);
	
	return 0;	
	
}

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

int main()
{
	int cub[54], tet[96];
	for(int i=0; i<=53; i++)
		cub[i] = i*i*i;

	for(int i=0; i<=95; i++)
		tet[i] = i*(i+1)*(i+2)/6;


	int N;
	while(cin >> N, N) {
		int res = 0;
		for(int i=0; i<=53; i++)
		for(int j=0; j<=95; j++)
		{
			int s = cub[i] + tet[j];
			if(s > N) continue;
			res = max(res, s);
		}

		cout << res << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
mt19937 mrand(random_device{}()); 
const ll mod=998244353;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=3010000;

int n,m;
ll fac[N],fnv[N],inv[N];
ll comb(int a,int b) {
	if (b>a||b<0) return 0;
	return fac[a]*fnv[b]%mod*fnv[a-b]%mod;
}

int main() {
	scanf("%d%d",&n,&m);
	fac[0]=fnv[0]=fac[1]=fnv[1]=1;
	inv[0]=inv[1]=1;
	rep(i,2,3000001) {
		fac[i]=fac[i-1]*i%mod;
		inv[i]=(mod-mod/i)*inv[mod%i]%mod;
		fnv[i]=fnv[i-1]*inv[i]%mod;
	}
	ll ans=0;
	for (int odd=0;odd<=n&&odd<=m;odd++) {
		if (3*m%2!=odd%2) continue;
		ans=(ans+comb(n,odd)*(comb((3*m-odd)/2+n-1,n-1)-n*comb((m-odd)/2+n-1,n-1)%mod))%mod;
	}
	ans=(ans+n*comb(m+n-2,n-2))%mod;
	if (ans<0) ans+=mod;
	printf("%lld\n",ans);
}

Measured memory_bytes: 71292
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int Q;
void input(){
    fast_io();
    cin >> Q;
}

vector< bool > prime_table(int n) {
  vector< bool > prime(n + 1, true);
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if(!prime[i]) continue;
    for(int j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}


int solve(){
    auto Table = prime_table(1e5);
    vector<int> LikeNumber;
    for (int i = 1; i < 1e5; i++)
    {
        if(i%2){
            if(Table[i] && Table[(i+1)/2]) LikeNumber.push_back(i);
        }
    }
    for (int i = 0; i < Q; i++)
    {
        int l,r; cin >> l >> r;
        int out = upper_bound(LikeNumber.begin(),LikeNumber.end(),r)-lower_bound(LikeNumber.begin(),LikeNumber.end(),l);
        cout << out << endl;
    }
    

    return 0;
}   

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

Measured memory_bytes: 640
from sys import stdin, stdout

int_in = lambda: int(stdin.readline())
arr_in = lambda: [int(x) for x in stdin.readline().split()]
mat_in = lambda rows: [arr_in() for y in range(rows)]
str_in = lambda: stdin.readline().strip()
out = lambda o: stdout.write("{}\n".format(o))
arr_out = lambda o: out(" ".join(map(str, o)))
bool_out = lambda o: out("YES" if o else "NO")

from collections import deque

def solve(n, m, passages):
    neighbors = {}
    for passage in passages:
        if passage[0] not in neighbors:
            neighbors[passage[0]] = []
        if passage[1] not in neighbors:
            neighbors[passage[1]] = []
        neighbors[passage[0]].append(passage[1])
        neighbors[passage[1]].append(passage[0])

    parents = {}
    visited = set([1])
    bfs = deque([1])
    while len(bfs) > 0:
        curr = bfs.popleft()
        for item in neighbors[curr]:
            if item not in visited:
                parents[item] = curr
                bfs.append(item)
                visited.add(item)


    if len(visited) != n:
        return None
    result = []
    for i in range(2, n+1):
        result.append(parents[i])
    return result



if __name__ == "__main__":
    n, m = arr_in()
    passages = mat_in(m)
    result = solve(n, m, passages)
    out("Yes" if result is not None else "No")
    if result is not None:
        for item in result:
            out(item)

Measured memory_bytes: 153948
"""

4進法で表す
各桁が
0→0
1→3
2→5
3→7で変換

"""

def change4(x):
    ret = []

    for i in range(10,-1,-1):
        ret.append(x // (4**i))
        x %= (4**i)
    ret.reverse()
    return ret

N = input()
ni = int(N)
ch = [0,3,5,7]
ans = 0

for i in range(4 ** len(N)):

    now = change4(i)

    if 1 not in now or 2 not in now or 3 not in now:
        continue

    zf = False
    flag = True
    nsum = 0
    for j in range(11):
        if now[j] == 0:
            zf = True
        elif zf:
            flag = False
            break
        else:
            nsum += (10**j) * ch[now[j]]
            #print (nsum)

    if flag and nsum <= ni:
        ans += 1
    
    #print (nsum)

print (ans)

Measured memory_bytes: 42604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int main()
{
	int n,k;
	ll a,sum=0;
	vector<ll>v;
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		v.push_back(a);
	}
	sort(v.begin(),v.end(),greater<ll>());
	for(int i=0;i<n;i++)
	{
		if(i>k-1)sum+=v[i];
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 2420
#include <iostream>
#include <cstdlib>

using namespace std;
int main(){
    int P,Q,R, min = 301, tmp;

    cin >> P >> Q >> R;
    tmp = P + Q;
    if(tmp < min) min = tmp;
    tmp = Q + R;
    if(tmp < min) min = tmp;
    tmp = P + R;
    if(tmp < min) min = tmp;
    cout << min << endl;

    return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    n, m, x = LI()
    C = []
    A = [[] for _ in range(n)]
    money = inf
    for i in range(n):
        inp = LI()
        C.append(inp[0])
        A[i] = inp[1:]
    for i in range(1 << n):
        rikai = [0] * m
        flag = True
        kingaku = 0
        for j in range(n):
            if (i >> j) & 1 == 1:
                for k in range(m):
                    rikai[k] += A[j][k]
                kingaku += C[j]
        for r in rikai:
            if r < x:
                flag = False
        if flag:
            money = min(money, kingaku)
    if money != inf:
        print(money)
    else:
        print("-1")
main()



Measured memory_bytes: 10948
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int N, M;
  double ans = 0;

  cin >> N;

  vector<int> v(N);
  for(int i = 0; i < N; i++){
    cin >> v[i];
  }
   sort(v.begin(), v.end());

  ans = ((double)v[0] + (double) v[1])/2.0;
  for(int i = 2; i < N; i++){
    ans = (ans + (double)v[i])/2.0;
  }

  cout << ans << endl;

}


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

int main()
{
    double pi = 3.14159265358979323846264338327950L;
    double A, B, H, M, ans;
    cin >> A >> B >> H >> M;
    if (H == 0 && M == 0)
    {
        ans = abs(A - B);
    }
    double h, m;
    h = 30 * H + 0.5 * M;
    m = 6 * M;
    double Z = abs(h - m);
    ans = (A * A) + (B * B) - 2 * A * B * cos(Z * pi / 180.0);
    cout << fixed << setprecision(30) << sqrt(ans) << endl;
    return 0;
}


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

int main(){
  int H,W;
  cin >> H >> W;
  vector<vector<char>> a(H,vector<char> (W));
  int i,j = 0;
  for(i=0;i<H;i++){
    for(j=0;j<W;j++){
      cin >>a.at(i).at(j);
    }
  }
  
  vector<bool> row(H,false);
  vector<bool> col(W,false);
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(a.at(i).at(j)=='#'){
        row.at(i)=true;
        col.at(j)=true;
      }
    }
  }
  for(int i=0;i<H;i++){
    if(row.at(i)){
      for(int j=0;j<W;j++){
        if(col.at(j)==true)
          cout << a.at(i).at(j);
      }
    }
    cout << endl;
  }
  
  
  
}


Measured memory_bytes: 3628
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int data = scan.nextInt();
		boolean b = true;
		ArrayList<Integer> a = new ArrayList<>();
		for(int i = 0; i<3; i ++){
		int x=data%10;
		a.add(x);
		data=data/10;
		if(a.get(i)==7) {
			b=true;
			break;
		}
		b=false;
		}
		if(b==true) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 27080
#include <algorithm>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <thread>
#include <tuple>
#include <type_traits>
#include <vector>


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

using namespace std;
using ll = long long;

#define M (1'000'000'007)

int main() {
    ios::sync_with_stdio(false);
    int h, w, k;
    cin >> h >> w >> k;
    vector<vector<char>> c(h, vector<char>(w, 0));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> c[i][j];
        }
    }

    int ans = 0;
    // b=h1 h2 h3 ... hx w1 w2 ... wx
    for (int b = 0; b <= pow(2, h + w) - 1; b++) {
        int counter = 0;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                bool wb = b >> j & 1;
                bool hb = b >> (i + w) & 1;

                if (wb == 0 && hb == 0 && c[i][j] == '#') {
                    counter++;
                }
            }
        }
        if (counter == k)
            ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3136
// https://atcoder.jp/contests/abc128/tasks/abc128_f

// https://qiita.com/penguinshunya/items/cd96803b74635aebefd6
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let n = read::<i32>();
    let sis = read_vec::<i64>();
    debug_assert_eq!(n as usize, sis.len());
    let mut max: i64 = 0;
    for c in 1..n {
        let mut i = 0;
        let mut score: i64 = 0;
        loop {
            if (n - 1) % c == 0 && n - 1 - i * c <= i * c {
                break;
            }
            if n - 1 - i * c <= c {
                break;
            }
            score += sis[(i * c) as usize] + sis[(n - 1 - i * c) as usize];
            max = std::cmp::max(max, score);
            i += 1;
        }
    }
    println!("{}", max);
}


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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

ll N;
ll M = 0;
ll R_1 = 0, R1 = 0;
string X;
ll mp[200005];

ll mpow(ll a, ll n, ll MOD){
	if(MOD == 0) return 0;
	if(n == 0) return 1;
	ll r = mpow(a, n/2, MOD);
	r = r * r;
	if(n % 2) r *= a;
	r %= MOD;
	return r;
}

ll caln1(ll a){
	int r = 0;
	while(a > 0){
		r += a % 2;
		a = a >> 1;
	}
	return r;
}

ll solve(){
	reverse(X.begin(), X.end());

	for(int i=0; i<N; i++){
		if(X[i] == '1') M++;
	}

	for(int i=0; i<N; i++){
		if(X[i] == '1'){
			R_1 += mpow(2, i, M - 1);
			R1 += mpow(2, i, M + 1);
		}
	}

	mp[0] = 0;
	for(int a=1; a<=2e5; a++){
		ll b = a;
		ll r = 0;
		while(b > 0){
			r++;
			ll n1 = caln1(b);
			b = b % n1;
		}
		mp[a] = r;
	}


	vector<ll> res;
	for(int i=0; i<N; i++){
		if(X[i] == '0'){
			ll r = (R1 + mpow(2, i, M + 1)) % (M + 1);
			res.push_back(mp[r] + 1);

		}else{
			if(M-1 == 0){
				res.push_back(0);
				continue;
			}
			ll r = ((R_1 - mpow(2, i, M - 1)) % (M - 1) + (M - 1)) % (M - 1);
			res.push_back(mp[r] + 1);
		}
	}

	reverse(res.begin(), res.end());
	for(int r : res){
		cout<<r<<endl;
	}
	return 0;
}

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

	cin>>N>>X;
	solve();
    return 0;
}






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

using namespace std;

#define F 		first
#define S 		second
#define ll 		long long
#define ld 		long double
#define pii		pair<int, int>
#define vi 		vector<int>
#define mii 	map<int, int>
#define umii 	unordered_map<int, int>
#define pb		push_back
#define mk		make_pair
#define ask(x) 	cerr << #x << " = " << x << "\n";
#define INF 	1000000007
#define hell 	998244353

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

	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	string s, t;
	cin >> s >> t;
	for (int i = 0; i < s.size(); ++i)
		if (s[i] != t[i]) {
			cout << "No";
			return 0;
		}
	cout << "Yes";

	return 0;
}

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

int main(){
    ll N, A, B;
    cin >> N >> A >> B;

    ll num = N / (A + B);
    ll amari = N - (A + B) * num;
    ll ans = num * A + min(amari, A);

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

//    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX_N 200001
#define mod 1000000007
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define FOR(i, a, b) for(ll i=a; i<b; i++)
#define REP(i, n) for(ll i=0; i<n; i++)
#define REV(i, n) for(ll i=n-1; i>=0; i--)
#define ALL(v) v.begin(), v.end()
#define pb push_back
const ll INF = 9e18;
ll n;
pair<double, P> rxy[MAX_N];

double deg(ll x, ll y){
    if(x == 0 && y == 0) return 0;
    return atan2(y, x) * 180 / M_PI;
}

signed main(){
    cin >> n;
    REP(i, n) cin >> rxy[i].second.first >> rxy[i].second.second;
    REP(i, n){
        ll x, y;
        x = rxy[i].second.first; y = rxy[i].second.second;
        rxy[i].first = deg(x, y);
        // cout << x << " " << y << " " << rxy[i].first << endl;
    }
    sort(rxy, rxy+n);
    // REP(i, n) cout << rxy[i].first << " " << rxy[i].second.first << " " << rxy[i].second.first << endl;
    P ret_xy = P(0, 0);
    double ret = 0;
    REP(i, n){
        REP(j, n){
            REP(k, n){
                if(i <= k && k <= j){
                    ret_xy.first += rxy[k].second.first;
                    ret_xy.second += rxy[k].second.second;
                }
            }
            ret = max(ret, sqrt(ret_xy.first*ret_xy.first + ret_xy.second*ret_xy.second));
            ret_xy = P(0, 0);

            REP(k, n){
                if(k <= i || j <= k){
                    ret_xy.first += rxy[k].second.first;
                    ret_xy.second += rxy[k].second.second;
                }
            }
            ret = max(ret, sqrt(ret_xy.first*ret_xy.first + ret_xy.second*ret_xy.second));
            ret_xy = P(0, 0);
        }
    }
    cout << setprecision(20) << ret << endl;
    return 0;
}

Measured memory_bytes: 256