akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define RFOR(i, b, a) for (ll i = b; i >= a; --i)
#define ALL(x) x.begin(), x.end()
#define DEBUG(args...) { string _s = #args; replace(ALL(_s), ' ', '\0');\
replace(ALL(_s), ',', ' ');\
stringstream _ss(_s); istream_iterator<string> _it(_ss); _debug(_it, args);}
#define endl "\n"
#define F first
#define S second
#define pb(x) push_back(x)a
#define mp(x, y) make_pair(x, y)

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void _debug(istream_iterator<string>) {}
template<typename T, typename... Args>
void _debug(istream_iterator<string> it, T first, Args... args) {
    cerr << ">> " << *it << " : " << first << endl; _debug(++it, args...);
}
template <typename T1, typename T2>
inline ostream& operator << (ostream& out, const pair<T1, T2>& p) {
    return out << "(" << p.F << ", " << p.S << ")";
}
template<typename T>
inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty()) return out << "[]";
    else { out << '['; for (auto& e : v) { out << e << ", "; } return out << "\b\b]"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const set<T>& s) {
    if (s.empty()) return out << "{}";
    else { out << '{'; for (auto& e : s) { out << e << ", "; } return out << "\b\b}"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const unordered_set<T>& s) {
    return out << set<T>(ALL(s));
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const map<T1, T2>& m) {
    if (m.empty()) return out << "{}";
    out << '{'; for (auto& p : m) { out << p << ", "; } return out << "\b\b}";
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const unordered_map<T1, T2>& m) {
    return out << map<T1, T2>(ALL(m));
}
template<typename T>
inline ostream& operator << (ostream& out, const ordered_set<T>& s) {
    return out << set<T>(ALL(s));
}

typedef long long ll;
typedef long double ld;
typedef vector<long long> vll;
typedef pair<ll, ll> pll;
typedef vector<pair<ll, ll>> vpll;
typedef unordered_map<ll, ll> STll;
/************************************** MAIN PROGRAM ********************************************/

int main()
{
    //freopen("input.txt", "r", stdin);
    SPEED
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &e : a) cin >> e;
    ll xorsum = 0;
    for (int i = 0; i + 1 < n; i += 2) {
        xorsum ^= a[i] ^ a[i + 1];
    }
    for (int e : a) {
        cout << (xorsum ^ e) << ' ';
    }
}
/************************************** END OF PROGRAM ******************************************/
/** Stuff you should look for:
 * int overflow, array bounds, over-counting
 * special cases (n=1?), set/unordered_set TLE, multi-set/set error
 * do something instead of nothing and stay organized
 */


Measured memory_bytes: 3988
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#define ll long long
#define rgi register int
#define rgl register long long
#define il inline

using namespace std;

const int oo = 0x3f3f3f3f;

int a, b;

il int read()
{
	rgi x = 0, f = 0, ch;
	while(!isdigit(ch = getchar())) f |= ch == '-';
	while(isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	return f ? -x : x; 
}

int main()
{
	cin >> a >> b;
	cout << ceil((double)(b - 1) / (a - 1));
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
int main(){
long long n,m;cin>>n>>m;


pair<long long,long long> a[n];
long long ans=0;

int i,j;
for(i=0;i<n;i++){
  cin>>a[i].first>>a[i].second;
}

sort(a,a+n);

int tmp=0;
bool reach=false;

for(i=0;i<n;i++){
  for(j=0;j<a[i].second;j++){
    tmp++;
    ans+=a[i].first;
    if(m==tmp) {reach= true;break;}
  }
  if(reach) break;
}
cout << ans << endl;

}


Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string.h>
int main() {
	int C[11] = { 0 };
	int a,cnt,i,sum;
	while (~fscanf(stdin, "%d", &a)) {
		C[a] = 1,sum=20-a;
		fscanf(stdin, "%d", &a), C[a] = 1,sum-=a;
		fscanf(stdin, "%d", &a), C[a] = 1;
		cnt = 0;
		for (i = 1; i < 11; i++) if(C[i]==0&&i<=sum)cnt++;
		if ((double)cnt / 7.0 >= 0.5) fprintf(stdout, "YES\n");
		else fprintf(stdout, "NO\n");
		memset(C, 0, sizeof(C));
	}
	return 0;
}

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

int main() {
    string S;
    cin >> S;
    int n = S.size() - 1;

    if (S.at(n) == 's') {
        cout << S << "es" << endl;
    }
    else {
        cout << S << "s" << endl;
    }
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define RREP(i,s,n) for(lli i=s;i>=n;i--)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)


signed main(){

	lli n;
	cin>>n;

	vector<lli> d(n);

	REP(i,0,n)cin>>d[i];
	sort(d.begin(),d.end());

	cout<<d[n/2]-d[n/2-1]<<endl;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <ctime>
#include <iterator>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;


int main()
{
    int w,n;
    cin>>w>>n;
    vector<int> act(w);
    for(int c=0;c<act.size();c++) act[c]=c+1;
    for(int c=0;c<n;c++)
    {
        string s;
        cin>>s;
        int a=0,b=0;
        int c2;
        for(c2=0;s[c2]!=',';c2++) {a*=10;a+=s[c2]-'0';}
        c2++;
        for(;c2<s.size();c2++) {b*=10;b+=s[c2]-'0';}

        swap(act[a-1],act[b-1]);
    }
    for(int c=0;c<w;c++) cout<<act[c]<<endl;
}

Measured memory_bytes: 1208
N, X = map(int, input().split())

a, p = [1], [1]
for i in range(N):
    a.append(a[i] * 2 + 3)
    p.append(p[i] * 2 + 1)


def f(N, X):
    if N == 0:
        return 1 if X >= 1 else 0

    else:
        if X == 1 or 0:
            return 0
        elif X <= a[N - 1] + 1:
            return f(N - 1, X - 1)
        elif X == a[N - 1] + 2:
            return p[N - 1] + 1
        else:
            return p[N] - f(N, a[N] - X)


print(f(N, X))


Measured memory_bytes: 3064
#include<stdio.h>

int main(){
  int i,j;
  int N,M;
  int A[10000],B[10000],cmp,count=0;
  
  scanf("%d",&N);
  for(i=0;i<N;i++) scanf("%d",&A[i]);

  scanf("%d",&M);
  for(i=0;i<M;i++) scanf("%d",&B[i]);

  for(i=0;i<M;i++){
    cmp=B[i];
    for(j=0;j<N;j++){
      if(cmp==A[j]){
	count++;
	break;
      }
    }
  }

  printf("%d\n",count);




  return 0;
}



Measured memory_bytes: 2052
// https://atcoder.jp/contests/abc161/tasks/abc161_d

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

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DEBUG 1
#if DEBUG
  #define DUMP(a) REP(_i, a.size()) cout << a[_i] << (_i + 1 == a.size() ? "\n" : " ")
  #define DUMP2D(b) REP(_j, b.size()) DUMP(b[_j]); cout << endl
#else
  #define DUMP(a)
  #define DUMP2D(b)
#endif

const int K_MAX = 1e5;
const int S_MAX = 9;

int K;

vector<vector<int>> dp;

int main() {
  cin >> K;

  dp = vector<vector<int>>(S_MAX + 1, vector<int>(10, 0));

  REP(j, 10) dp[0][j] = 1;
  REP(i, S_MAX) {
    REP(j, 10) {
      if (j > 0) dp[i + 1][j] += dp[i][j - 1];
      dp[i + 1][j] += dp[i][j];
      if (j < 9) dp[i + 1][j] += dp[i][j + 1];
    }
  }

  // DUMP2D(dp);

  int sum = 0;
  int i = 0;
  int j = 1;
  while (i <= S_MAX) {
    sum += dp[i][j];
    if (sum >= K) break;
    if (j < 9) {
      j++;
    } else {
      i++;
      j = 1;
    }
  }

  string ans = "";
  while (true) {
    // cout << "i=" << i << ", j=" << j << ", sum=" << sum << endl;
    ans += ('0' + j);
    if (i == 0) break;
    K = dp[i][j] - (sum - K);
    sum = 0;
    int i2 = i - 1;
    int j2;
    for (j2 = max(j - 1, 0); j2 <= min(j + 1, 9); j2++) {
      sum += dp[i2][j2];
      if (sum >= K) break;
    }
    i = i2;
    j = j2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3656
n = int(input())
dic = {}
for i in range(n):
    a = int(input())
    dic[i] = a-1
already = set()
already.add(0)
cur = 0
count = 0
while True:
    cur = dic[cur]
    count += 1
    if cur == 1:
        print(count)
        break
    if cur in already:
        print(-1)
        break
    already.add(cur)    

Measured memory_bytes: 61912
#include <iostream>
#include <cmath>
#define min(A, B) ((A) < (B) ? (A) : (B))
#define ll long long

using namespace std;

void perform() {

}

int main() {
  int t; cin >> t;
  int a[t], dp[t];
  cin >> a[0] >> a[1];
  dp[0] = 0;
  dp[1] = fabs(a[1] - a[0]);
  for (int i = 2; i < t; i++) {
    cin >> a[i];
    dp[i] = min(dp[i-1] + fabs(a[i] - a[i-1]), dp[i-2] + fabs(a[i] - a[i-2]));
  }
  cout << dp[t-1] << endl;
  return 0;
}


Measured memory_bytes: 1024
N,A,B,C=map(int,input().split())

l=[int(input()) for i in range(N)]

inf=3000

def mp(g,a,b,c,):
    if g==N:
        return abs(A-a)+abs(B-b)+abs(C-c)-30 if min(a,b,c)>0 else inf

    l0=mp(g+1,a+l[g],b,c)+10
    l1=mp(g+1,a,b+l[g],c)+10
    l2=mp(g+1,a,b,c+l[g])+10
    l3=mp(g+1,a,b,c)
    
    return min(l0,l1,l2,l3)

print(mp(0,0,0,0))



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
    
int main(){
    vector <int> x(5);
    rep(i,5) cin >> x[i];
    for(int i=0; i<5; i++){
        if(x[i]==0){
            cout << i+1 << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3596
#include<stdio.h>

int b_search(int *S, int n, int key)
{
  if (n == 0) return 0;
  if (S[n/2] > key) { if(b_search(&S[0], n/2, key)) return 1;}
  else if (S[n/2] < key) { if(b_search(&S[n/2+1], n - n/2, key)) return 1; }
  else return 1;
}

int main()
{
  int n, q, i, C;
  int S[100000+1], T[50000+1];

  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &S[i]);
  }

  scanf("%d", &q);
  for (i = 0; i < q; i++) {
    scanf("%d", &T[i]);
    if (b_search(&S[0], n,  T[i])) C++;
  }
  printf("%d\n", C);
  return 0;
}

Measured memory_bytes: 2168
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>

typedef long long ll;

using namespace std;

const ll MAX = 1e18;

int main() {
    ll N;
    cin >> N;
    bool has_zero = false;
    vector<ll> A(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
        if (A[i] == 0 ) {
            has_zero = true;
        }
    }
    if (has_zero) {
        cout << 0 << endl;
        return 0;
    }
    bool over = false;
    ll ans = 1;
    for (ll Ai : A) {
        if (Ai <= MAX / ans) {
            ans *= Ai;
        } else {
            over = true;
            break;
        }
    }
    if (over) {
        cout << -1 << endl;
        return 0;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3972
#include <bits/stdc++.h>
 
const int N = 18, M = (1 << N) + 5,
  P = 998244353, I2 = (P + 1) / 2;
 
inline int fpow(int x, int y) {
  int ret = 1;
  for ( ; y; y >>= 1, x = 1ll * x * x % P)
    if (y & 1) ret = 1ll * ret * x % P;
  return ret;
}
 
int n, f[M], p[M], s;
 
inline void FWT(int A[], int o) {
  for (int i = 1; i < n; i <<= 1)
    for (int j = 0; j < n; j += i << 1)
      for (int k = 0; k < i; ++k) {
        int nx = A[j + k], ny = A[i + j + k];
        A[j + k] = (nx + ny) % P;
        A[i + j + k] = (nx - ny + P) % P;
        if (o == -1) {
          A[j + k] = 1ll * A[j + k] * I2 % P;
          A[i + j + k] = 1ll * A[i + j + k] * I2 % P;
        }
      }
}
 
int main() {
  scanf("%d", &n); n = 1 << n;
  for (int i = 0; i < n; ++i)
    scanf("%d", p + i), s += p[i];
  s = fpow(s, P - 2);
  for (int i = 0; i < n; ++i)
    p[i] = 1ll * p[i] * s % P;
  p[0] = (p[0] - 1 + P) % P;
  for (int i = 0; i < n; ++i)
    f[i] = P - 1;
  f[0] += n;
  FWT(p, 1), FWT(f, 1);
  for (int i = 0; i < n; ++i)
    f[i] = 1ll * f[i] * fpow(p[i], P - 2) % P;
  FWT(f, -1);
  for (int i = 0; i < n; ++i)
    printf("%d\n", (f[i] - f[0] + P) % P);
  return 0;
}

Measured memory_bytes: 4864
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

ll INF = (ll)1e18+10;
int main() {
  ll n,k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i,n){  
    cin >> a[i];
  }
  sort(a.begin(),a.end());

  ll l = -INF, r = INF;
  while(l+1<r){
    ll x = (r+l)/2;
    ll cnt = [&]{
      ll cnt = 0;
      rep(i,n){
        int l = -1, r = n;
        if (a[i]>=0) {
          while(l+1<r) {
            int c = (l+r)/2;
            if (a[i]*a[c]<x) {
              l = c;
            } else {
              r = c;
            }
          }
          cnt += r;
        } else {
          while(l+1<r) {
            int c = (l+r)/2;
            if (a[i]*a[c]<x) {
              r = c;
            } else {
              l = c;
            }
          }
          cnt += n-r;
        }
        if (a[i]*a[i]<x) {
          --cnt;
        }
      }
      return cnt / 2;
    }();

    if (cnt < k) {
      l = x;
    } else {
      r = x;
    }
  }
  cout << l << endl;
}


Measured memory_bytes: 1792
n,x,y=map(int,input().split())
d={}
for i in range(1,n):
  for j in range(i+1,n+1):
    m=min(abs(i-j),abs(x-i)+1+abs(y-j))
    if m in d:
      d[m]+=1
    else:
      d[m]=1
for i in range(1,n):
  if i in d:
    print(d[i])
  else:
    print(0)

Measured memory_bytes: 3572
s=input()
a=0
b=0
if 10*int(s[0])+int(s[1])>=13 or 10*int(s[0])+int(s[1])==0:
    a=1
if 10*int(s[2])+int(s[3])>=13 or 10*int(s[2])+int(s[3])==0:
    b=1
if a==0 and b==0:
    print("AMBIGUOUS")
if a==0 and b==1:
    print("MMYY")
if a==1 and b==0:
    print("YYMM")
if a==1 and b==1:
    print("NA")

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int n, a[1000000];
vector<pair<int, int>>D;
int main() {
	cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; D.push_back(make_pair(a[i], i)); }
	sort(D.begin(), D.end()); for (int i = 0; i < D.size(); i++)a[D[i].second] = i;
	int sum = 0;
	for (int i = 0; i < n; i++)if (a[i] % 2 != i % 2)sum++;
	cout << sum / 2 << endl;
	return 0;
}

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

#define INF 1e9
int times[20][20];

// bit????????¨
inline int getNbit(int n){
    return 1 << n;
}
inline bool isIbitFlag(int bit, int i){
    return (bit & (1 << i)) != 0;
}
inline int makeIbitFlag(int bit, int i){
    return bit | (1 << i);
}

int main(int argc, const char * argv[]) {
    while(1){
        int n; cin >> n;
        if(!n) break;
        
        memset(times, 0, sizeof(times));
        for(int i = 0; i < n; i++){
            for(int j = 0; j <= n; j++){
                cin >> times[i][j];
            }
        }
        
        vector<int> dp(1<<n, INF);
        dp[0] = 0;
        
        // ????????¢??¶???????????????bit??§??¨???
        for(int bit = 0; bit < (1<<n); bit++){
            // ?¬????i?????????????????¢???????????¨?????????
            for(int i = 0; i < n; i++){
                // ?????§???i?????????????????¢???????????????????????????
                if(isIbitFlag(bit, i)) continue;
                
                int cost = times[i][0]; // i??????????????????????????????????£?????????????
                // ???????????????????£????????????????????°??????????????????¢?´¢
                for(int j = 0; j < n; j++){
                    if(isIbitFlag(bit, j)){
                        cost = min(cost, times[i][j+1]);
                    }
                }
                int now = makeIbitFlag(bit, i); // i?????????????????¢????????¶???????¢????
                dp[now] = min(dp[now], dp[bit]+cost); // ????????¢??¶???bit??§???????°????????????§??´??°
            }
            
        }
        
        cout << dp[(1<<n)-1] << endl;
    }
}

Measured memory_bytes: 1452
#include<stdio.h>

int main(void)
{

   int a, b, c, k, max, d, i;

   scanf("%d%d%d", &a, &b, &c);
   scanf("%d", &k);

   max=a;


      if((max<b)&&(c<b)){
        max=b; d=a+c;
        }
      else if((max<c)&&(b<c)){
        max=c; d=a+b;
        }
      else d=b+c;

   for(i=1;i<=k;i++){
      max = max * 2;
      }

   printf("%d\n", max+d);

   return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll (i)=0; i<(n); ++(i))
#define print(a) cout << (a) << endl

vector<vector<ll>> parent;
vector<ll> ans;

void dfs(ll a,ll p=-1) {
  ll b=0;  // x runs 0->n-1
  rep(i,parent[a].size()) {
    b=parent[a][i];
    if(b==p) continue;
    ans[b]+=ans[a];
    dfs(b,a);// if b is parent of a, add b's value to a
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,q,a,b,p,x;cin>>n>>q;
  parent.resize(n);ans.resize(n);
  rep(i,n-1) {
    cin>>a>>b;
    parent[b-1].push_back(a-1);
    parent[a-1].push_back(b-1);
  }
  rep(i,q) {cin>>p>>x;ans[p-1]+=x;}
  dfs(0);
  rep(i,n) cout<<ans[i]<<' ';cout<<endl;
  return 0;
}

Measured memory_bytes: 24320
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.NoSuchElementException;

public class Main {

	int H,W,N;
	int[] a;

	public void solve() {
		H = nextInt();
		W = nextInt();
		N = nextInt();

		a = new int[N];
		for(int i = 0;i < N;i++){
			a[i] = nextInt();
		}

		ArrayList<Integer> list = new ArrayList<>();
		for(int i = 0;i < N;i++){
			for(int j = 0;j < a[i];j++){
				list.add(i + 1);
			}
		}


		int[][] map = new int[H][W];
		int index = 0;

		for(int i = 0;i < H;i++){

			if(i % 2 == 0){
				for(int j = 0;j < W;j++){
					map[i][j] = list.get(index++);
				}
			}else{
				for(int j = W-1;j >= 0;j--){
					map[i][j] = list.get(index++);
				}
			}
		}

		for(int i = 0;i < H;i++){
			for(int j = 0;j < W;j++){
				if(j != 0)out.print(" ");
				out.print(map[i][j]);
			}
			out.println();
		}
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

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

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 22484
/**
 *    SATAR ALLAH
 *
**/
#include <bits/stdc++.h>

using namespace std;
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

int main()
{

    int n;

     string str;

     cin>>str>>n;

     vector<string> ans;

     map<string,int> used;
      for(int i=0;str[i];i++){

          string add="";
          for(int j=i;str[j]&&j<i+n;j++){

              add+=str[j];
              if(!used[add])
              ans.pb(add),used[add]=1;
          }
      }

       sort(all(ans));


      cout<<ans[n-1];

    return 0;
}


Measured memory_bytes: 2048
#include <iostream>
using namespace std;
int main()
{
	int N;
	cin >> N;
	
	int ten = N/1%10;
	
	
	if(ten == 2 || ten == 4 || ten == 5 || ten == 7|| ten == 9){
		cout << "hon" <<endl;
	}
	
	if(ten == 0 || ten == 1 || ten == 6 || ten == 8){
		cout << "pon" <<endl;
	}
	
	if(ten == 3){
		cout << "bon" <<endl;
	}
}


Measured memory_bytes: 3636
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";}

// #define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
typedef long long ll;
typedef double ld;
#define pll pair<ll,ll>
#define pii pair<int, int>
#define pb push_back
#define mp(x, y) make_pair((x), (y))
#define F first
#define S second
#define I insert
#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pll>
#define all(x) (x).begin(), (x).end()
#define sz(x) (ll)(x).size()
   
const ll Mod = 1e9 + 7;

int dp[21][1<<21];
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
    int n; cin >> n;
    int A[n][n];
    for(int i = 0;i < n; i++){
        for(int j = 0 ;j < n;j++)
            cin >> A[i][j];
    }
    

    for(int i = 0 ;i < n; i++)
        if(A[0][i] == 1)
            dp[0][1<<i] = 1;
    
    for(int i = 1;i < n ; i++){
        for(int j = 0 ;j < (1<<n) ; j++){
            if(__builtin_popcount(j) != i)
                continue;
            for(int k = 0 ;k < n ; k++){
                if(!(j&(1<<k)) && A[i][k] == 1 ){
                    dp[i][j^(1<<k)] += dp[i-1][j];
                    if(dp[i][j^(1<<k)] >= Mod)
                        dp[i][j^(1<<k)] -= Mod;
                }
            }
        }
    }
    cout << dp[n-1][(1<<n)-1] << endl;
    return 0;
}

Measured memory_bytes: 160000
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0,(i##_len)=(n);(i)<(i##_len);(i)++)
#define rep2(i,a,b) for(ll (i)=(a),(i##_len)=(b);(i)<=(i##_len);(i++))
#define rrep(i,n) ll(i)=(n);ll now=-1;while((i)--&&(now++||1))
#define Yes(n) cout<<((n)?Yes:No)<<"\n"
#define vll vector<ll>
#define pb push_back
using namespace std;
using ll = long long;

static inline void ignore_ret(int x) {}
template<class T> bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
template<class T> T abs(T x){return max(x,-x);}
template<class T> T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> T lcm(T m,T n) {return m*n/gcd(m,n);}
template<class T> T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm<T>(r,v.at(i));return r;}
template<class T> T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> T nCr(T n,T k){return factorial<T>(n)/(factorial<T>(k)*factorial<T>(n-k));}
template<class T> T dot_product(vector<T>u,vector<T>v){T r=0;for(T i=0;i<u.size();i++)r+=u.at(i)*v.at(i);return r;}
template<class T> T sum(vector<T>v){return reduce(all(v),0LL);}

// Template ends here

void solve(ll N, vector<ll> A){
    ll cnt = LLONG_MAX;
    vector<string> B(N);
    rep(i, N) {
        stringstream ss;
        ss << bitset<30>(A.at(i));
        B.at(i) = ss.str();
    }
    rep(i, N) {
        ll tmp = 0;
        rrep(j, B.at(i).size()) {
            if (B.at(i).at(j) == '0') tmp++;
            else {
                chmin(cnt, tmp);
                break;
            }
        }
    }
    cout << cnt << "\n";
}

int main() {
    ll N;
    ignore_ret(scanf("%lld",&N));
    vector<ll> A(N);
    for(int i = 0 ; i < N ; i++){
        ignore_ret(scanf("%lld",&A[i]));
    }
    solve(N, move(A));
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * Lesson6C Ａ大学は１フロア１０部屋、３階建ての公舎４棟を管理しています。
 * 公舎の入居・退去の情報を読み込み、各部屋の入居者数を出力するプログラム
 * n件の情報が与えられます。各情報では、４つの整数b, f, r, vが与えられます。
 * これは、b棟f階のr番目の部屋にv人が追加で入居したことを示します。
 * vが負の値の場合、v人退去したことを示します。
 * 最初、全ての部屋には誰も入居していないものとします。
 *
 * @author Internship
 *
 */
public class Main{

	/**
	 * プログラムのエントリポイント
	 *
	 * @param args
	 */
	public static void main(String[] args) {

		//棟が4個　階が3個　部屋が10個でそれぞれに最大9人は入れるので　
		//4x3x10の配列に最大9が入る配列を初期化
		int[][][] intRoom = new int[4][3][10];

		//1列目を取得
		try {
			BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));

			String strLine1 = insBR.readLine();

			int intLine1 = Integer.parseInt(strLine1);


			//3
			//1 1 3 8
			//3 2 2 7
			//4 3 8 1

			//2列目以降を取得
			for(int i = 0; i < intLine1; i++) {

				String strLineAll = insBR.readLine();

				//入力値を分解
				String[] strAry = strLineAll.split(" ");

				//棟
				int intBuilding = Integer.parseInt(strAry[0]);

				//階
				int intFloor = Integer.parseInt(strAry[1]);

				//部屋
				int intRoomFirst = Integer.parseInt(strAry[2]);

				//人数
				int intPeople = Integer.parseInt(strAry[3]);

				//入力値を配列に格納
				intRoom[intBuilding -1][intFloor -1][intRoomFirst -1] += intPeople;




			}

			//出力

			for(int l = 0; l < 4; l++) {
				for(int j = 0; j < 3; j++) {
					for(int k = 0; k < 10; k++) {
						System.out.print(" " + intRoom[l][j][k]);
					}
					System.out.println("");						//改行
				}
				if(l != 3) {
					System.out.println("####################");
				}
			}


		} catch (IOException e) {
			System.out.println(e);
		} catch (NumberFormatException e) {
			System.out.println("数字で入力して下さい");
		}
	}
}

Measured memory_bytes: 18220
s = str(input())
t = str(input())

# 文字列sをソート（sortedをすると配列型になるのでjoinして上げる必要あり）
sort_s_list = sorted(s)
sort_s = "".join(sort_s_list)

# 文字列tを逆ソート
t_list = list(t)
t_list.sort(reverse = True)
reverse_sort_t = "".join(t_list)

if sort_s < reverse_sort_t:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9084
#include<iostream>
#include<string.h>

using namespace std;

int main(){

    string odd;
    string even;

    cin >> odd;
    cin >> even;

    int i = 0;
    while(odd[i] && even[i]){
        cout << odd[i] << even[i];
        i++;
    }
    if(odd[i]!='\0')cout << odd[i];
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
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;}
const int P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;

class UnionFind {
public:
    //親の番号を格納する。親だった場合は-(その集合のサイズ)
    vector<int> Parent;
    //作るときはParentの値を全て-1にする
    //こうすると全てバラバラになる
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//親をとってきたい]
    }
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらひっくり返しちゃう。
        if (size(A) < size(B)) swap(A, B);
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        return true;
    }
};

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

    int n,m;
    cin>>n>>m;
    vi p(n);
    rep(i,n)cin>>p[i];

    UnionFind Uni(n);

    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        x--;y--;
        if(Uni.root(x)!=Uni.root(y)){
            Uni.connect(x,y);
        }
    }

    ll ans=0;
    for(int i=0;i<n;i++){
        if(Uni.root(p[i]-1)==Uni.root(i)){
            ans++;
        }
    }
    fin(ans);

    

//////////////////////////////////////////////////////
return 0;}



Measured memory_bytes: 1024
import java.util.*;
import java.math.*;
public class Main{
    public static void main(String[] args){
	Scanner s = new Scanner(System.in);
	while(s.hasNext()){
	    int c = 0;
	    for(int i=s.nextInt();i>0;--i){
		BigInteger b = new BigInteger(s.next());
		if(b.isProbablePrime(5))++c;
	    }
	    System.out.printf("%d\n",c);
	}
    }
}

Measured memory_bytes: 13000
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <functional>

using namespace std;
typedef long long int ll;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)
#define MOD 1000000007

int main(){
  ll N, M;
  cin >> N >> M;
  ll broken[N] = {}, dp[N] = {};
  rep(i, M){
    ll a;
    cin >> a;
    broken[a-1] = 1;
  }
  rep(i, N){
    if(broken[i]) continue;
    if(i == 0) dp[i] = 1;
    else if(i == 1) {
      dp[i] = dp[i-1] + 1;
    }
    else dp[i] = (dp[i-1] + dp[i-2]) % MOD;
  }
  cout << dp[N-1] << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
#include <numeric>

using namespace std;

long long total(const vector<long long> &v)
{
	return accumulate(v.begin(), v.end(), 0LL);
}

int main()
{
	int N, M;
	cin >> N >> M;
	vector<vector<long long>> v(N);

	for (auto &t : v) {
		t.resize(3);
		for (int i = 0; i < 3; ++i) {
			cin >> t[i];
		}
	}

	long long ans = 0;
	for (int m = 0; m < (1 << 3); ++m) {
		auto w = v;
		for (auto &t : w) {
			for (int i = 0; i < 3; ++i) {
				if (m & (1 << i)) {
					t[i] *= -1;
				}
			}
		}
		sort(w.begin(), w.end(), [](const vector<long long> &a, const vector<long long> &b) {
			return total(b) < total(a);
		});
		
		vector<long long> s(3);
		for (int k = 0; k < M; ++k) {
			for (int i = 0; i < 3; ++i) {
				s[i] += w[k][i];
			}
		}
		for (auto &x : s) {
			x = abs(x);
		}
		long long result = 0;
		result = total(s);
		ans = max(ans, result);
	}
	cout << ans << endl;
}


Measured memory_bytes: 384
// Library
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

// TYPEDEFS
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

// CONSTANTS
#define SZA 0
#define SZB 0

// MACRO
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
#define ABS(X) (((X) > 0)? (X) : -(X))
#define YN(X) ((X)? "Yes" : "No")
#define SWAP(T, X, Y) {T t; t = X; X = Y; Y = t;}

#define F first
#define S second
#define PB push_back
#define MP make_pair


// Global Tables

//ull gPreProcess[SZA][SZB];

// Functions

void Print2DVector(vector<vector<int>>& v)
{
    ull i, j; 
    for(i = 0; i < v.size(); i++)
    {
        for(j = 0; j < v[i].size(); j++)
        {
            cout << v[i][j];
            if(j == v[i].size()-1)
            {
                cout << endl;
            }
            else
            {
                cout << " ";
            }
        }
    }
}

void PrintVector(vi& v)
{
    ull i;
    for(i = 0; i < v.size(); i++)
    {
        cout << v[i];
        if(i == v.size()-1)
        {
            cout << endl;
        }
        else
        {
            cout << " ";
        }
    }
}

void PrintArr(int* a, ull N)
{
    ull i;
    for(i = 0; i < N; i++)
    {
        cout << a[i];
        if(i == N-1)
        {
            cout << endl;
        }
        else
        {
            cout << " ";
        }
    }
}

void PreProcessTables()
{
    ull i, j;
    for(i = 0; i < SZA; i++)
    {
        for(j = 0; j < SZB; j++)
        {
            break;
        }
        break;
    }
}

void TC(int t)
{
    long long X, K, D, q, out;
    cin >> X >> K >> D;
    X = ABS(X);
    q = X/D;
    if(q > K)
    {
        out = X - K*D;
    }
    else
    {
        if(K&1)
        {
            q = q - ((q&1)^1);
        }
        else
        {
            q = q - (q&1);
        }
        out = ABS(X-q*D);
        if(q+2 <= K)
        {
            out = MIN(out, ABS(X - (q+2)*D));
        }
    }
    cout << out << endl;
}

// Main

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

    int T = 1, t;
    for(t = 1; t <= T; t++)
    {
        TC(t);
    }
    return 0;
}


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

int main(){
    int m, n, c;
    cin >> n >> m >> c;
    int b[21];
    for(int i=0; i<m; i++){
        cin >> b[i];
    }

    int sum=0;
    int a;
    int ans = 0;
    for(int i=0; i<n; i++){
        sum = 0;
        for(int j=0; j<m; j++){
            cin >> a;
            sum += a * b[j];
        }
        sum += c;
        if(sum > 0) ans++;
    }

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

Measured memory_bytes: 256
unittest
{
	assert( [ "3 1", "1 2", "1 3", "2 3" ].parse.expand.solve == "0\n1\n2" );
	assert( [ "6 3", "2 1", "2 3", "4 1", "4 2", "6 1", "2 6", "4 6", "6 5" ].parse.expand.solve == "6\n4\n2\n0\n6\n2" );
}



import std.container;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nm = input.front.split.to!( long[] );
	auto abs = new long[ 2 ][ nm[ 0 ] - 1 + nm[ 1 ] ];
	foreach( ref ab; abs )
	{
		input.popFront;
		ab = input.front.split.to!( long[] );
		ab[] -= 1;
	}
	return tuple( nm[ 0 ], abs );
}

auto solve( long n, long[ 2 ][] abs )
{
	// 辺配列から隣接リストを作成、頂点ごとに親の数をカウント
	auto nss = new long[][ n ];
	auto ps = new long[ n ];
	foreach( ab; abs )
	{
		nss[ ab[ 0 ] ] ~= ab[ 1 ];
		ps[ ab[ 1 ] ]++;
	}
	
	// 根を検索
	auto queue = DList!long();
	foreach( i, p; ps )
	{
		if( p == 0 )
		{
			queue.insertBack( i );
			break;
		}
	}
	
	// 幅優先探索で最長経路を探す
	auto anss = new long[ n ];
	while( !queue.empty )
	{
		auto f = queue.front;
		queue.removeFront();
		
		foreach( t; nss[ f ] )
		{
			ps[ t ]--;
			if( 0 < ps[ t ] ) continue;		// 親の探索が全部終わるまで保留
			anss[ t ] = f + 1;		// 最後に到達した辺を採用
			queue.insertBack( t );
		}
	}
	return anss.to!( string[] ).join( "\n" );
}


Measured memory_bytes: 16380
// Hack it and have it ;) //
/*author* Priyanshu Shrivastav (from IIT Palakkad) *
 * *_ __ ___  _ ______ ___  _ ____   ___  ___| |_  *
 * | '_ ` _ \| '__/ __/ _ \| '_ \ \ / / |/ __| __| *
 * | | | | | | | | (_| (_) | | | \ V /| | (__| |_  *
 * |_| |_| |_|_|(_)___\___/|_| |_|\_/ |_|\___|\__| *
When I wrote this, only God and I understood what I was doing
 ** * * * * * * * Now, only God knows!* * * * * * */
#include      <bits/stdc++.h>
using namespace std;
#define IOS       ios_base::sync_with_stdio(false); cin.tie (nullptr)
#define PREC      cout.precision (10); cout << fixed
#ifdef CONVICTION
#include "/home/convict/Dropbox/myfiles/sport_coding/cplib/snippets/debug.h"
#else
#define debug(x...)
#endif
//Don’t practice until you get it right. Practice until you can’t get it wrong

void preproc() {
}

void solve() {
   int L, R, d;
   int res = 0;
   cin >> L >> R >> d;
   for (int x = 0; x * d <= R; ++x) {
      if (x * d >= L and x * d <= R)
         ++res;
   }
   cout << res << '\n';
}

signed main() {
  IOS; PREC;
  preproc();

  int tc = 1;
  // cin >> tc;
  for (int Tt = 1; Tt <= tc; ++Tt) {
    // cout << "Case #" << Tt << ": ";
    solve();
  }
  return EXIT_SUCCESS;
}


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

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

    if((abs(a-c) <= d) || (abs(a-b) <= 3 && abs(b-c) <= d)) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
n = int(input())
xyh = []
for i in range(n):
    x, y, h = map(int, input().split())
    xyh.append((x, y, h))

for x in range(101):
    for y in range(101):
        hmax = 0
        for item in xyh:
            if item[2] > 0:
                hmax = item[2] + abs(x - item[0]) + abs(y - item[1])
                break
        is_ok = True
        for item in xyh:
            if max(0, hmax - abs(x - item[0]) - abs(y - item[1])) != item[2]:
                is_ok = False
        if is_ok:
            print(x, y, hmax)
            exit()


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

public class Main {

	public static void main(String[] args) {
		
		Scanner in = new Scanner(System.in);
		int s = in.nextInt();
		ArrayList<Integer> a = new ArrayList<Integer> ();
		a.add(s);
		int n = 0;
		boolean flag = true;
		
		while (flag) {
			if (a.get(n) % 2 == 0)
				a.add(a.get(n) / 2);
			else
				a.add(a.get(n) * 3 + 1);
			for (int i = 0; i <= n; i++) {
				if (a.get(n + 1) == a.get(i))
					flag = false;
			}
			n++;
				
		}
		
		System.out.println(n + 1);

	}

}

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

int main(){
	int a[10000],b[10000];
	char c[10000];
	for(int i=0;c[i-1]!='?';i++) cin>>a[i]>>c[i]>>b[i];
	for(int j=0;c[j-1]!='?';j++){
		if(c[j]=='+') cout<<a[j]+b[j]<<endl;
		else if(c[j]=='-') cout<<a[j]-b[j]<<endl;
		else if(c[j]=='*') cout<<a[j]*b[j]<<endl;
		else if(c[j]=='/') cout<<a[j]/b[j]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;
/* ちゃんと考えてわかって実装 */

int main(void){
    int h, w;
    cin >> h >> w;
    char a[h+1][w+1];
    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            cin >> a[i][j];
        }
    }

    set<int> kara;
    for(int i=1; i<=h; i++){
        int cnt = 0;
        for(int j=1; j<=w; j++){
            if(a[i][j] == '.') cnt++;
        }
        if(cnt == w){
            for(int j=1; j<=w; j++){
                a[i][j] = '!';
                kara.insert(i);
            }
        }
    }


    for(int j=1; j<=w; j++){
        int cnt = 0;
        for(int i=1; i<=h; i++){
            if(a[i][j] == '.' || a[i][j] == '!'){
                cnt++;
            }
        }
        if(cnt == h){
            for(int i=1; i<=h; i++){
                a[i][j] = '!';
            }
        }
    }


    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            if(a[i][j] != '!'){
                cout << a[i][j];
            }
        }
        if(kara.find(i) == kara.end()){
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,big=0,b,sum=0;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		big=max(big,a[i]);
		if(a[i]>=big) b=i;
	}
	for(int i=0;i<n;i++)
	{
		if(i==b) continue;
		else sum+=a[i];
	}
	if(big<sum) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define rep(i,l,r) for(int i=(l);i<(r);i++)
#define rrep(i,l,r) for(int i=(r-1);i>=(l);i--)
#define LINF (ll)1e18
#define INF (int)1e9
#define range(i) i.begin(),i.end()
#define sum(i) accumulate(range(i),0)
#define Yes(i) out(i?"Yes":"No")
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
struct aaa{aaa(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(10);};}aaaaaaa;
inline void in() {}
template <class Head, class... Tail>
inline void in(Head&& head,Tail&&... tail){
    cin>>head;
    in(move(tail)...);
}
template <class T>
inline void out(T t) {
    cout<<t<<'\n';
}
template <class Head, class... Tail>
inline void out(Head head,Tail... tail){
    cout<<head<<' ';
    out(move(tail)...);
}

int main(){
    vector<int>v(201);
    rep(i,1,201)for(int j=i;j<201;j+=i)v[j]++;
    rep(i,1,201)v[i]=v[i]==8&&(i&1);
    INT(n);
    out(accumulate(v.begin(),v.begin()+1+n,0));
}









Measured memory_bytes: 256
import math
from functools import reduce

K = int(input())

def gcd(*numbers):
    return reduce(math.gcd, numbers)

ans = 0
for i in range(1,K+1):
    for j in range(i,K+1):
        for k in range(j,K+1):
            if i==j==k:
                ans += gcd(i,j,k)
            elif j==k or i==j: 
                ans += 3*gcd(i,j,k)
            else: ans += 6*gcd(i,j,k)
print(ans)

Measured memory_bytes: 9604
import java.util.*;

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

	class Problem_B{
		int h,w,ph,pw;
		int[][] a;
		boolean[][] b;
		boolean[][] c;

		int sum(int start_x,int start_y){
			int result = 0;
			for(int s=0;s<ph;s++)for(int i=0;i<pw;i++){
				if(c[s][i]==b[s+start_y][i+start_x]){
					result+=a[s+start_y][i+start_x];
				}else return Integer.MIN_VALUE;
			}
			return result;
		}

		public Problem_B() {
			h = in.nextInt();
			w = in.nextInt();
			a = new int[h][w];
			b = new boolean[h][w];
			for(int i=0;i<h;i++)for(int s=0;s<w;s++)a[i][s] = in.nextInt();
			for(int i=0;i<h;i++)for(int s=0;s<w;s++)b[i][s] = in.nextInt()==1;
			ph = in.nextInt();
			pw = in.nextInt();
			c = new boolean[ph][pw];
			for(int i=0;i<ph;i++)for(int s=0;s<pw;s++)c[i][s] = in.nextInt()==1;
			int result = Integer.MIN_VALUE;
			for(int s=0;s<h-ph+1;s++){
				for(int i=0;i<w-pw+1;i++){
					if(b[s][i]==c[0][0])result=Math.max(result,sum(i,s));
				}
			}
			System.out.println(result!=Integer.MIN_VALUE? result:"NA");
		}
	}
}


Measured memory_bytes: 27740
import java.util.*;

class Main{
    
    int INF=Integer.MAX_VALUE;
    
    char[] in;
    int prime;
    int p;
    
    void solve(){
        Scanner sc = new Scanner(System.in);
        
        while(true){
            String[] line = sc.nextLine().split(":");
            if(line[0].equals("0")) break;
            
            prime = Integer.parseInt(line[0]);
            
            int cnt = 0;
            for(int i=0; i<line[1].length(); i++){
                if(line[1].charAt(i)!=' ') cnt++;
            }
            
            in = new char[cnt];
            p = 0;
            int idx = 0;
            for(int i=0; i<line[1].length(); i++){
                if(line[1].charAt(i)!=' ') in[idx++] = line[1].charAt(i);
            }
            
            int ans = expr();
            if(ans==INF) System.out.println("NG");
            else{
                StringBuffer sb = new StringBuffer();
                for(int i=0; i<in.length; i++) sb.append(in[i]);
                sb.append(" = " + ans + " (mod "+prime+")");
                System.out.println(sb.toString());
            }
        }
    }
    
    int expr(){
        int a = term();
        if(a==INF) return INF;
        while(true){
            if(p>=in.length || (in[p]!='+' && in[p]!='-')) break;
            boolean add = in[p++] == '+';
            
            int b = term();
            if(b==INF) return INF;
            if(add) a = calc(a, b, '+');
            else a = calc(a, b, '-');
        }
        return a;
    }
    
    int term(){
        int a = factor();
        if(a==INF) return INF;
        while(true){
            if(p>=in.length || (in[p]!='*' && in[p]!='/')) break;
            boolean mul = in[p++] == '*';
            
            int b = factor();
            if(b==INF) return INF;
            if(mul) a = calc(a, b, '*');
            else{
                if(b==0) return INF;
                else a = calc(a, b, '/');
            }
        }
        return a;
    }
    
    int factor(){
        if(p<in.length && in[p]=='('){
            p++;
            int res = expr();
            p++;
            return res;
        }else return digit();
    }
 
    int digit(){
        int res = 0;
        while(p<in.length && Character.isDigit(in[p])) res = (res * 10 + in[p++] - '0') % prime;
        return res;
    }
 
    int calc(int a,int b,char op){
        if(op=='/' && b==0){return INF;}
     
        int val=-1;
        switch(op){
        case '+':{val = (a+b) % prime; break;}
        case '-':{val = (a+(prime-b)) % prime;  break;}
        case '*':{val = (a*b) % prime; break;}
        case '/':{val = a * pow(b, prime-2) % prime;}
        }
        
        return val % prime;
    }
 
    int pow(int b, int po){
        if(po==0) return 1;
        if(po==1) return b;
        int a = pow(b, po/2) % prime;
        if(po%2==1) return a * a % prime * b % prime;
        else return a * a % prime;
    }
 
    public static void main(String[] args){
        new Main().solve();
    }
}

Measured memory_bytes: 89872