akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
 
public class Main {
  static InputReader in;
  static PrintWriter out;
 
  static class Solution {
    void solve() throws IOException {
        int r = in.nextInt();
        int c = in.nextInt();
        int sum = 0;
        int[][] sheet = new int[r][c]; 
        int[] sumofrow = new int[r];
        int[] sumofcolumn = new int[c];
         
        for (int i = 0; i < r; i++) {
          for (int j = 0; j < c; j++) {
            sheet[i][j] = in.nextInt();
            sum += sheet[i][j];
          }
        }
         
        for (int i = 0; i < r; i++) {
          for (int j = 0; j < c; j++) {
            sumofrow[i] += sheet[i][j];
            sumofcolumn[j] += sheet[i][j];
          }
        }
         
        for (int i = 0; i < r; i++) {
          for (int j = 0; j < c; j++) {
            out.print(sheet[i][j] + " ");
          }
          out.println(sumofrow[i]);
        }
         
        for (int i = 0; i < c; i++) {
          out.print(sumofcolumn[i] + " ");
        }
         
        out.println(sum);
         
//      End solve()
    }
//    End Solution
}
 
  public static void main(String[] args) throws IOException {
    in = new InputReader(System.in);
    out = new PrintWriter(System.out);
    Solution solver = new Solution();
    solver.solve();
    out.close();
}
 
  static class InputReader {
    public BufferedReader br;
    public StringTokenizer st;
 
    public InputReader(InputStream stream) {
      br = new BufferedReader(new InputStreamReader(stream));
    }
 
    public int nextInt() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Integer.parseInt(st.nextToken());
    }
 
    public long nextLong() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Long.parseLong(st.nextToken());
    }
 
    public String next() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return st.nextToken();
    }
 
    public double nextDouble() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Double.parseDouble(st.nextToken());
    }
 
 
  }
 
}

Measured memory_bytes: 29504
A, B = map(int, input().split())

mark = ['.', '#']

def print_ans(ans):
  for a in ans:
    print(''.join(a))

def change(num, mark_id):
  global ans
  idx = 0
  while num > 1:
    if idx <= 99:
      ans[-1][idx] = mark[mark_id]
      idx += 2
      num -= 1
    else:
      ans.extend([list(mark[mark_id-1]*100) for i in range(2)])
      idx = 0

  
ans = [list(mark[0] * 100)]
change(B, 1)
ans.append(list(mark[0] * 100))
ans.extend([list(mark[1]*100) for i in range(2)])
change(A, 0)

print(len(ans), 100)
print_ans(ans)

Measured memory_bytes: 3064
# coding: utf-8
# Your code here!
H,W=map(int,input().split())

meizu=[]
for _ in range(H):
    meizu.append(list(input()))

dp=[[10**9 for w in range(W)] for h in range(H)]
dp[0][0]=1 if meizu[0][0]=="#" else 0

for h in range(H):
    for w in range(W):
        if h!=H-1:
            dp[h+1][w]=min(dp[h+1][w],dp[h][w]+1 if meizu[h+1][w]=="#" and meizu[h][w]=="." else dp[h][w])
        if w!=W-1:
            dp[h][w+1]=min(dp[h][w+1],dp[h][w]+1 if meizu[h][w+1]=="#" and meizu[h][w]=="." else dp[h][w])
    
print(dp[-1][-1])


Measured memory_bytes: 3188
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
 
int N,M,x,y;
char S[10];

int main()
{
  scanf("%s",S);
  
  if(S[0]=='S')
  {
    printf("Cloudy");
  }
  else if(S[0]=='C')
  {
    printf("Rainy");
  }
  else if(S[0]=='R')
  {
    printf("Sunny");
  }
  
 return 0; 
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long 

// fact(n)
int fact(int n){
	if(n == 1)	return 1;
	else return (n * fact(n - 1));
}

// combination(n,r)
int combination(int n, int r){
	if(r == 0 || r == n)	return 1;
	else if(r == 1)	return n;
	return (combination(n - 1, r - 1) + combination(n - 1, r));
}

// gcd(a,b)
int gcd(int a,int b){
	int ret;
	ret = (b == 0) ? a : gcd(b, a % b);
	return ret;
}

// lcm(a.b)
int lcm(int a,int b){
	return (a * b) / gcd(a,b);
}

// qsort(array, size, sizeof(int),comp);
int comp(const int *a,const int *b){
	return (*a - *b);
}

// append(array,*size,addNum)
void append(int *array,int *size,int num){
	realloc(array, sizeof(int) * (*size + 1));
	array[(*size)] = num;
	++(*size);
}

// pop(array,*size) & nongetpop(array,*size)
int pop(int *array,int *size){
	int temp = array[(*size - 1)];
	realloc(array,sizeof(int) * (*size - 1));
	--(*size);
	return temp;
}

void nongetpop(int *array,int *size){
	realloc(array,sizeof(int) * (*size - 1));
	--(*size);
}

int main(int argc, char const *argv[])
{
	int cnt_1 = 0;
	char ch;
	while((ch = getchar()) != EOF){
		if(ch == '1')	++cnt_1;
	}
	printf("%d\n", cnt_1);
	return 0;
}



Measured memory_bytes: 128
import java.util.*;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		int M = scn.nextInt();
		int max = Math.max(N, M);
		int min = Math.min(N, M);
		String s = "";
		for (int i = 0; i < max; i++) {
			s = s + min;
		}
		System.out.println(s);
	}

}

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

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;

const int mod = 998244353;
const ll inf = 3e18 + 5;

int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }  

int main(){
    int n, m;
    cin >> n >> m;
    vi c(n);
    for(int i = 0; i < n; i++){
        c[i] = -1;
    }
    bool check = false;

    for(int i = 0; i < m; i++){
        int si, ci;
        cin >> si >> ci;
        if(c[si-1] != -1){
            if(ci != c[si-1])
                check = true;
        }
        else
            c[si-1] = ci;
    }
    
    if((c[0] == 0 && n > 1) || check)
        cout << -1;
    else{
        for(int i = 0; i < n; i++){
            if(c[i] == -1){
                if(i == 0 && n > 1){
                    cout << 1;
                }
                else
                    cout << 0;
            }
            else
                cout << c[i];
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[200100];
int n;
bool check(int mid){
	if(a[n+1]<=mid&&a[n]<=mid||a[n]<=mid&&a[n-1]<=mid)
		return 1;
	if(a[n+1]> mid&&a[n]> mid||a[n]> mid&&a[n-1]> mid)
		return 0;
	for(int i=1;i<n-1;i++){
		if(a[n+i+1]<=mid&&a[n+i]<=mid||a[n-i]<=mid&&a[n-i-1]<=mid)
			return 1;
		if(a[n+i+1]> mid&&a[n+i]> mid||a[n-i]> mid&&a[n-i-1]> mid)
			return 0;
	}
	return a[1]<=mid;
}
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=2*n-1;i++){
		cin>>a[i];
	}
	int le=0;
	int ri=2*n-1;
	while(le!=ri){
		int mi=(le+ri)/2;
		if(check(mi))
			ri=mi;
		else
			le=mi+1;
	}
	cout<<le<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
int main(){double a,s;while(std::cin>>a){if(std::cin.eof())break;s=a;for(int i=2;i<=10;i++){if(i%2)a/=3.0;else a*=2.0;s+=a;}printf("%.8f\n",s);}}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int A,B,C,K;
    cin>>A>>B>>C>>K;
    if(A>=K){cout<<K<<endl;}
    else if(K<=B){cout<<A<<endl;}
    else {cout<<A-(K-(A+B))<<endl;}
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char op;
  int A, B, X;

  cin >> A >> op >> B;
  
  if(op == '+'){
    X = A + B;
  }
  else if(op == '-'){
    X = A - B;
  }

  cout << X << endl;

}

Measured memory_bytes: 256
#include <stdio.h>

class Dice{
public:
	Dice(){
		number = new int[6];
		work = new int[6];
	};
	~Dice(){
		delete[] number;
		delete[] work;
	};

	void setLabel(int index,int num){
		number[index] = num;
	};

	void roll(char dst){
		for(int i = 0; i < 6; i++) work[i] = number[i];
		switch(dst){
		case 'E':
			setNumber(work[3],work[1],work[0],work[5],work[4],work[2]);
			break;
		case 'N':
			setNumber(work[1],work[5],work[2],work[3],work[0],work[4]);
			break;
		case 'S':
			setNumber(work[4],work[0],work[2],work[3],work[5],work[1]);
			break;
		case 'W':
			setNumber(work[2],work[1],work[5],work[0],work[4],work[3]);
			break;
		}
	};

	int returnPeek(){
		return number[0];
	}

private:
	void setNumber(int n0,int n1,int n2,int n3,int n4,int n5){
		number[0] = n0;
		number[1] = n1;
		number[2] = n2;
		number[3] = n3;
		number[4] = n4;
		number[5] = n5;
	}

private:
	int* number;
	int* work;
};

int main(){
	Dice dice;
	int label;
	char ch;
	for(int i = 0; i < 6; i++){
		scanf("%d",&label);
		dice.setLabel(i,label);
	}
	getchar(); 
	while((ch = getchar()) != '\n'){
		dice.roll(ch);
	}
	printf("%d\n",dice.returnPeek());
}





Measured memory_bytes: 2764
def main():
    A, B, C, K = map(int, input().split())

    res = K
    ans = 0
    ans += min([A, K])
    res -= min([A, K])
    if res == 0:
        print(ans)
        exit()
    res -= min([res, B])
    if res == 0:
        print(ans)
        exit()
    ans -= min([res, C])
    print(ans)


if __name__ == "__main__":
    main()


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

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int n;
	cin >> n;
	long long tot = 1LL*n*(n+1)/2;
	long long other = 1LL*3*(n/3)*(n/3+1)/2 + 1LL*5*(n/5+1)*(n/5)/2 - 1LL*15*(n/15+1)*(n/15)/2;
//	cerr << tot << '\n' << other << '\n';
	cout << (tot - other) << '\n';
				
	return 0;
}


Measured memory_bytes: 3652
#include<stdio.h>

int main(){
   int A,B,K;
   int cnt=0;
   scanf("%d",&K);
   scanf("%d%d",&A,&B);
   if(A>=1&&A<=B&&B<=1000&&1<=K&&K<=1000){
      for(int i=A;i<=B;i++){
         if(i%K==0){
            printf("OK");
            cnt++;
            break;
         }
      }
      if(cnt==0){
         printf("NG");
      }
   }
   return 0;
}

Measured memory_bytes: 1692
#include <bits/stdc++.h>
using namespace std;
const int INF=999999999;
char a[10][10];
int main() {
    string S;
    cin>>S;
    if(S=="Sunny"){cout<<"Cloudy"<<endl;}
    if(S=="Cloudy"){cout<<"Rainy"<<endl;}
    if(S=="Rainy"){cout<<"Sunny"<<endl;}
 return 0;}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int a,b;
    while(scanf("%d %d",&a,&b)==2){
        int c=a+b;
        int i=1;
        while(1){
            c/=10;
            i++;
            if(c<10) break;
        }
        printf("%d\n",i);
    }
    return 0;
}



Measured memory_bytes: 1984
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1000000007;
const ll N=998244353;
ll power(ll x,ll n){ll res=1;while(n>0){if(n&1) res=res*x%MOD;x=x*x%MOD;n>>=1;}return res;}
ll modinverse(ll a){return power(a, MOD-2);}
void solve()
{
    ll n;
    cin>>n;
    ll x=(power(10, n)-(2*(power(9, n)))+power(8, n));
    x%=MOD;
    if(x<0)
    	x+=MOD;
    cout<<x<<endl;
}
int main()
{
	#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll test=1;
    //cin>>test;
    while(test--)
    {
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 3804
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,a[105]={},ans=inf,cnt;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> a[i];
  }
  for(int i=-100; i<=100; i++) {
    cnt=0;
    for(int j=0; j<n; j++) {
      cnt+=(i-a[j])*(i-a[j]);
    }
    ans=min(ans,cnt);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <bitset>
#include <sstream>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <climits>
#include <ctype.h>
using namespace std;

#define PI acos(-1.0)
#define EPS 1e-8
#define MOD 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define fi first
#define se second

typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

struct Matrix {
    vvi data;
    int r, c;
    Matrix(int row, int col, bool identity = false) : r(row), c(col) {
        data.assign(row, vector<int>(col, 0));
        if (identity) {
            for (int i = 0; i < r; ++i) {
                data[i][i] = 1;
            }
        }
    }
    Matrix operator * (Matrix& other) {
        int m = r, n = c, p = other.c;
        Matrix res(m, p);
        for (int i = 0; i < m; ++i) {
            for (int j = 0; j < p; ++j) {
                for (int k = 0; k < n; ++k) {
                    res.data[i][j] += data[i][k] * other.data[k][j];
                }
            }
        }
        return res;
    }
};

// 扩展欧几里得算法 res[1] * a + res[2] * b = res[0] = gcd(a, b)
vector<int> extendGcd(int a, int b) {
    if (b == 0) {
        return {a, 1, 0};
    } else {
        vector<int> tmp = extendGcd(b, a % b);
        return {tmp[0], tmp[2], tmp[1] - (a / b) * tmp[2]};
    }
}

// 矩阵快速幂
Matrix matrix_power(Matrix base, ll exp) {
    int n = base.r;
    Matrix res(n, n, true);
    while (exp) {
        if (exp & 1) {
            res = res * base;
        }
        base = base * base;
        exp >>= 1;
    }
    return res;
}

// 带模快速幂
template <typename T>
T power_mod(T base, int exp, int mod = MOD) {
    T res = 1;
    while (exp) {
        if (exp & 1) res = res * base % mod;
        base = base * base % mod;
        exp >>= 1;
    }
    return res;
}

// 快速幂
template <typename T>
T power(T base, int exp) {
    T res = 1;
    while (exp) {
        if (exp & 1) res *= base;
        base *= base;
        exp >>= 1;
    }
    return res;
}

// 求逆元
ll inv(ll a) {
    return power_mod(a, MOD - 2);
}

/******************************** template ********************************/
#define N 110


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

    int cnt = 0;
    for (char ch : s) {
        if (ch != 'A') ++cnt;
    }
    if (cnt != 5) {
        cout << "NO";
        return 0;
    }

    if (s[0] != 'A') {
        s = "A" + s;
    }
    if (s[4] != 'A') {
        s = s.substr(0, 4) + "A" + s.substr(4);
    }
    if (s[6] != 'A') {
        s = s.substr(0, 6) + "A" + s.substr(6);
    }
    if (s.length() > 9) {
        cout << "NO";
        return 0;
    }

    if (s.length() < 9) {
        s.push_back('A');
    } else {
        if (s[8] != 'A') {
            s = s.substr(0, 8) + "A" + s.substr(8);
        }
    }

    if (s == "AKIHABARA") {
        cout << "YES";
    } else {
        cout << "NO";
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
double pi = 3.14159265359;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int main() {
    ll a, b, x;
    cin >> a >> b >> x;
    if (a == 0) {
        ll ans = b / x + 1;
        cout << ans << "\n";
    } else {
        ll ans = b / x - (a - 1) / x;
        cout << ans << "\n";
    }
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;
typedef long long lint;

int main()
{
	int n, s;
	lint dp[10][1000] = {0};
	
	dp[0][0] = 1;
	
	for (int i = 0; i <= 100; i++){
		for (int j = 1000; j >= 0; j--){
			for (int k = 9; k >= 1; k--){
				if (j - i >= 0) dp[k][j] += dp[k - 1][j - i];
			}
		}
	}
	
	while (scanf("%d %d", &n, &s) && n){
		printf("%lld\n", dp[n][s]);
	}
	
	return (0);
}

Measured memory_bytes: 1116
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <typeinfo>

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> C(N);
  vector<int> S(N);
  vector<int> F(N);
  for(int i=0;i<N-1;i++)  cin >> C.at(i) >> S.at(i) >> F.at(i);

  for(int i=0;i<N;i++){
    int ans=S.at(i);
    for(int j=i;j<N-1;j++){
      if(ans<S.at(j)) ans=S.at(j);
      else if(ans%F.at(j)==0);
      else  ans=ans+F.at(j)-ans%F.at(j);
      ans+=C.at(j);
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int swap(int *a,int *b);

int main(void)
{
	int value[10],i,i2,D;
	for (i=0;i<10;i++){
		scanf("%d",&value[i]);
	}


	for (i=0;i<10;i++){
		for (i2=0;i2<9;i2++){
			if (value[i2]<value[i2+1]) {swap(&value[i2],&value[i2+1]);}	
		}
	}
	
	for(i=0;i<3;i++){
		printf("%d\n",value[i]);}

	return 0;
}

int swap(int *a,int *b){

	int buf;
		buf = *a;
		*a = *b;
		*b = buf;
	return 0;
}

Measured memory_bytes: 600
using System;
public class Class1
{
	public static void Main()
	{
		string dataSet = Console.ReadLine();
		string[] data = dataSet.Split();
		int n = int.Parse(data[0]);
		int m = int.Parse(data[1]);
		int l = int.Parse(data[2]);
		int[,] anm = new int[n, m];
		int[,] bml = new int[m, l];
	
		matrixReader(n, m, anm);
		matrixReader(m, l, bml);
		for (int k = 0; k < n; k++) {
			
			for (int i = 0; i < l; i++) {
				long cnl=0;
				for (int j = 0; j < m; j++) {
					cnl += anm[k, j] * bml[j, i];
				}
				Console.Write(cnl);
				if (i == l-1) {
					Console.Write("\r\n");
				}
				else
				{
					Console.Write(" ");
				}
				
			}
		}
	}
	public static void matrixReader(int row, int column, int[,] matrix)
	{
		for (int i = 0; i < row; i++) {
			string matrixSet = Console.ReadLine();
			string[] number = matrixSet.Split();
			
			for (int j = 0; j < column; j++) {
				matrix[i, j] = int.Parse(number[j]);
			}				
		}
	}
	
		
}

Measured memory_bytes: 9300
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


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

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

vector<ll> h(110);
bool search(){
    for(ll i=0;i<h.size();++i){
        if(h[i] != 0){
            return true;
        }
    }
    return false;
}

int main(){
    ll n;
    cin>>n;
    for(ll i=0;i<n;++i){
        cin>>h[i];
    }
    ll ans = 0;
    bool flag = true;
    while(flag){
        ll count = 0;
        ll sum = 0;
        for(ll i=0;i<n;++i){
            if(h[i] > 0){
                count++;
                h[i]--;
            }else{
                count = 0;
                sum++;
            }
            if(count == 1){
                ans++;
            }
        }
        if(sum == n){
            flag = false;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
from sys import setrecursionlimit as SRL, stdin

SRL(10 ** 7)
rd = stdin.readline
rrd = lambda: map(int, rd().strip().split())

n, k = rrd()

s = list(map(str, rd().strip()))

cnt = 0
pre = 'i'
for x in s:
    if x != pre:
        cnt += 1
    pre = x

print(n - max(1, cnt - 2 * k))


Measured memory_bytes: 48496
import java.util.Scanner;
//import java.util.Random;

class Main{
	public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);
		
		int n=stdIn.nextInt();
		int m=stdIn.nextInt();
		
		int[] a=new int[m];
		int[] b=new int[m];
		for(int i=0;i<m;++i){
			a[i]=stdIn.nextInt();
			b[i]=stdIn.nextInt();
			a[i]--;
			b[i]--;
		}
		
		int ans=0;
		for(int i=0;i<m;++i){
			UnionFind uf=new UnionFind(n);
			for(int j=0;j<m;++j){
				if(i==j){}
				else uf.unite(a[j],b[j]);
			}
			if(uf.num>1) ans++;
		}
		
		System.out.println(ans);
	}
}

class UnionFind{
	int[] par;
	int num;
	
	UnionFind(int n){//constructor.
		par=new int[n];
		for(int i=0;i<n;++i) par[i]=-1;
		num=n;
	}
	
	void init(int n){
		par=new int[n];
		for(int i=0;i<n;++i) par[i]=-1;
		num=n;
	}
	
	int root(int x){
		if(par[x]<0) return x;
		par[x]=root(par[x]);
		return par[x];
	}
	
	int size(int x){
		return -par[root(x)];
	}
	
	boolean same(int x,int y){
		return root(x)==root(y);
	}
	
	boolean unite(int x,int y){
		x=root(x);
		y=root(y);
		if(x==y) return false;
		par[x]+=par[y];
		par[y]=x;
		num--;
		return true;
	}
}

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

int main(){
    int64_t N;
    int K;
    cin >> N >> K;
    int ans = 1;
    while(1){
        if(pow(K,ans-1)<=N&&N<pow(K,ans)) break;
        ans++;
    }
    cout << ans << endl;
}

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

vector<int> prime;
bool is_prime[1000010];
int min_factor[1000010];
int sieve(int n) {
  fill(is_prime + 2, is_prime + 1000010, true);
  min_factor[1] = 1;
  for (int i = 2; i <= n; i++) {
    if (is_prime[i]) {
      prime.emplace_back(i);
      for (int j = 2 * i; j <= n; j += i) {
        is_prime[j] = false;
        if (min_factor[j] == 0) min_factor[j] = i;
      }
    }
  }
  return prime.size();
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  sieve(200000);
  int n;
  while (cin >> n, n) {
    int ans = 0;
    for (int i = 0; i < n; i++) {
      ans += prime[i];
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 5044
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>

#define MAX(a,b) ((a)>(b) ? (a) : (b))
#define MIN(a,b) ((a)<(b) ? (a) : (b))
#define ABS(a) ((a)>0 ? (a) : (a * -1))

using namespace std;
int main(){
	long long n, m, buf, buf1, ans;
	buf1 = 0;
	cin >> n >> m;
	buf = MIN(n, m/2);
	if ((m - buf * 2) > 0) buf1 = (m - buf * 2);
	ans = buf + buf1/4;

	cout << ans << endl;
}


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

using namespace std;
typedef long long ll;

int main(){
    string s;
    int k;
    cin>>s>>k;
    map<string,int> maps;
    for(int i=1;i<=k;i++){
        for(int j=0;i+j<=s.length();j++){
            string str=s.substr(j,i);
            maps[str]++;
        }        
    }
    int index=0;
    for(const auto& item:maps){
        index++;
        if(index==k){
            cout<<item.first<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 4788
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=3e5+10;
typedef struct node
{
    ll r,type;
    bool operator<(const node &t)const
    {
        return r>t.r;
    }
}node;
node a[N];
int main()
{
    ll x,y,A,B,C,tot=0,m;
    cin>>x>>y>>A>>B>>C;
    for(ll i=0;i<A;i++) scanf("%lld",&m),a[tot].r=m,a[tot].type=0,tot++;
    for(ll i=0;i<B;i++) scanf("%lld",&m),a[tot].r=m,a[tot].type=1,tot++;
    for(ll i=0;i<C;i++) scanf("%lld",&m),a[tot].r=m,a[tot].type=2,tot++;
    sort(a,a+tot);
    ll aa=0,bb=0,cc=0,ans=0;
    for(ll i=0;i<tot;i++){
        if(a[i].type==2) cc++,ans+=a[i].r;
        else if(a[i].type==0&&aa<x) aa++,ans+=a[i].r;
        else if(a[i].type==1&&bb<y) bb++,ans+=a[i].r;
        if(aa+bb+cc==x+y) break;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4992
/* ex 9_1
   Stuartyg */

#include <stdio.h>
#include <stdlib.h>
//スタックに格納するデータの数(余分に取る)
#define SIZE 20
//プロトタイプ宣言
typedef struct stack stack;
void initialize_stack(stack *stk);
void push(stack *stk, char elem);
void pop(stack *stk);
void print_stuck(stack *stk);

//スタックの定義
typedef struct stack{
    int size;
    int count;
    char data[SIZE];
    char *top;
} stack;

int main(void){
    stack stk;
    char mojiretu[20];
    char *str;

    //スタックを初期化（ポインタ渡しで関数にわたすこと）
    initialize_stack(&stk);

    scanf("%s",mojiretu);
    str = mojiretu;

    //キーボード操作
    while(*str){
        
        if(*str != 'B'){
            //スタックにデータを追加
            push(&stk, *str);
        }
        else{
                if (stk.count >= 1){
                    //スタックからデータを取り出す
                    pop(&stk);
            }
        }
        str++;
    }
    print_stuck(&stk);
    return 0;
}

//スタックの初期化
void initialize_stack(stack *stk){
    stk->count = 0;
    stk->size = SIZE;
    stk->top = &(stk->data[SIZE]);
}

//データの追加
void push(stack *stk, char elem){
    if(stk->count >= stk->size){ //error
        fprintf(stderr, "Error: stack overflow. (x=%c)\n", elem);
        exit(1);
    }
    else{
        stk->top--;
        *(stk->top) = elem; //append
        stk->count++; //要素数を1増やす
    }
}

//データの削除
void pop(stack *stk){
    if(stk->count <= 0){ //error
        fprintf(stdout, "Error: stack underflow.\n");
        exit(1);
    }
    else{
        stk->top++; //一個前のものにする
        stk->count--; //要素数を1減らす
    }
}

//出力
void print_stuck(stack *stk){
    int i = 0;
    for (;i < stk->count;i++){
        printf("%c",stk->data[SIZE-1-i]); //data[SIZE-1],data[SIZE-2],…と格納されていくので
    }
    printf("\n");
}


Measured memory_bytes: 1564
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

import numpy as np

N = int(input())
S = np.array([ord(x) for x in input().rstrip()],dtype=np.int64)

MOD = 10**9 + 7
base = 1234

def cumprod(arr):
    L = len(arr); Lsq = int(L**.5+1)
    arr = np.resize(arr,Lsq**2).reshape(Lsq,Lsq)
    for n in range(1,Lsq):
        arr[:,n] *= arr[:,n-1]; arr[:,n] %= MOD
    for n in range(1,Lsq):
        arr[n] *= arr[n-1,-1]; arr[n] %= MOD
    return arr.ravel()[:L]

x = np.full(N,base,np.int64); x[0] = 1
power = cumprod(x)
x = np.full(N,pow(base,MOD-2,MOD),np.int64); x[0] = 1
power_inv = cumprod(x)

H = S * power % MOD
Hcum = H.cumsum() % MOD

def test(n):
    x = (Hcum[n-1:N] - Hcum[:N-n+1] + H[:N-n+1]) % MOD
    x *= power_inv[:N-n+1]
    x %= MOD
    ind = np.lexsort((np.arange(N-n+1),x))
    x = x[ind]
    is_left_end = np.zeros(N-n+1,np.bool)
    is_left_end[1:] = (x[1:] != x[:-1])
    is_left_end[0] = 1
    is_right_end = np.zeros(N-n+1,np.bool)
    is_right_end[:-1] = (x[:-1] != x[1:])
    is_right_end[-1] = 1
    gap = ind[is_right_end] - ind[is_left_end]
    return gap.max() >= n

left = 0 
right = N+1 
while left + 1 < right:
    mid = (left + right)//2
    if test(mid):
        left = mid
    else:
        right = mid

answer = left
print(answer)



Measured memory_bytes: 20056
#include<stdio.h>
int main(){
   int num, rem, reverse_num, temp, start, end,cnt=0;
   scanf("%d %d",&start,&end);
   for(num=start;num<=end;num++){
      temp=num;
      reverse_num=0;
      while(temp){
         rem=temp%10;
         temp=temp/10;
         reverse_num=reverse_num*10+rem;
      }
      if(num==reverse_num)
         cnt++;
   }
   printf("%d\n",cnt);
   return 0;
}


Measured memory_bytes: 128
from fractions import gcd
# from datetime import date, timedelta
# from heapq import *
import heapq
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import fractions
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
# input = sys.stdin.readline


def lcm(a, b):
    return a * b / fractions.gcd(a, b)


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors


def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def is_prime(n):
    if n == 1:
        return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True


def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

def modpow(a, n, mod):
    res = 1
    while n > 0:
        if n & 1:
            res = res * a % mod
        a = a * a % mod
        n >>= 1
    return res


def modinv(a, mod):
    return modpow(a, mod - 2, mod)


def cnk(a, b):
    MOD = 10**9+7
    ret = 1
    for i in range(b):
        ret *= (a-i)
        ret %= MOD
        ret = ret * modinv(i+1, MOD) % MOD
    return ret




def main():
    x = int(input())
    ans = x
    l = []
    for b in range(1, 1001):
        for p in range(2,10):
            v = b ** p
            if v > x:
                break

            if x >= v:
                l.append(v)
    l.sort()
    if len(l) != 0:
        print(l[-1])
    else:
        print(1)



            


    




    


if __name__ == '__main__':
    main()


Measured memory_bytes: 5172
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define pi pair<ll,ll>
int main(){
	int n;
	cin >> n;
	cout << n*800-(n/15)*200;
	// freopen("in.txt","r",stdin);
	return 0;
}


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

vector<int> PonVec = {'0', '1', '6', '8'};

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

    char lastNum = n.at(n.size() - 1);

    if (lastNum == '3')
    {
        cout << "bon" << endl;
    }
    else if (count(PonVec.begin(), PonVec.end(), lastNum))
    {
        cout << "pon" << endl;
    }
    else
    {
        cout << "hon" << endl;
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

int main() {
    int n;
    cin >> n;
    vi p(n);
    rep(i, n) {
        cin >> p[i];
        p[i]--;
    }

    int cnt = 0;
    int streak = 0;
    rep(i, n) {
        if(i == p[i]) {
            streak++;
            if(streak == 2) {
                cnt++;
                streak = 0;
            }
        } else {
            if(streak == 1) {
                cnt++;
                streak = 0;
            }
        }
    }
    if(streak == 1) cnt++;

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<vector>
#include<queue>
//aoj0009
using namespace std;
int n,gs;
vector<int> cun;
char ip[1000003];
void prime()
{
	cun.clear();
	gs=0;
	memset(ip,1,sizeof(ip));
	ip[0]=0;
	ip[1]=0;
	for(int i=2;i<=n;i++)
	{
		if(ip[i]==1)
		{
			gs++;
			cun.push_back(i);
			for(int j=2*i;j<=n;j+=i)
			{
				ip[j]=0;
			}
		}
	}
}
int main()
{
	while(scanf("%d",&n)!=EOF)
	{
		prime();
		printf("%d\n",gs);
	}
	return 0;
}











Measured memory_bytes: 3944
#include <stdio.h>

int n,dice[6],sum,i;
int rot[6][6] = {{2,6,3,4,1,5},
		 {4,2,1,6,5,3},
		 {3,2,6,1,5,4},
		 {5,1,3,4,6,2},
		 {1,3,5,2,4,6},
		 {1,4,2,5,3,6}};

void rotate(int dir)
{
  int dice2[6];
  for(i=0;i<6;i++)
    dice2[i] = dice[i];
  for(i=0;i<6;i++)
    dice[i] = dice2[rot[dir][i]-1];
}

int main()
{
  char dir[10];
  while(1){
    scanf("%d",&n);
    if(n==0) break;

    sum=1;
    for(i=0;i<6;i++)
      dice[i] = i+1;

    while(n--){
      scanf("%s",&dir);
      switch(dir[0]){
      case 'N':
	rotate(0);
	break;
      case 'E':
	rotate(1);
	break;
      case 'W':
	rotate(2);
	break;
      case 'S':
	rotate(3);
	break;
      case 'R':
	rotate(4);
	break;
      case 'L':
	rotate(5);
      }
      sum += dice[0];
    }
    printf("%d\n",sum);
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

int main() {
    string s;
    cin >> s;
    bool isGood = true;
    for (int i = 1; i < s.length(); i++) {
        if (s[i - 1] == s[i]) {
            isGood = false;
        }
    }
    if (isGood) {
        cout << "Good" << endl;
    } else {
        cout << "Bad" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
package main

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

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt() int {
  n, _ := strconv.Atoi(NextLine())
  return n
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func Output() {
  _ = writer.Flush()
}

func BFS(G *[][]int, V *[]int, s, t int) int {
  N := len((*V))
  D := make([]int, N)
  for i := range D {
    if 0 < (*V)[i] { D[i] = N }
  }
  D[s] = 1
  Q := make([]int, 0)
  Q = append(Q, s)
  for 0 < len(Q) {
    q := Q[0]
    Q = Q[1:]
    for _, adj := range (*G)[q] {
      if D[adj] < N { continue }
      D[adj] = D[q] + 1
      Q = append(Q, adj)
    }
  }
  if D[t] == N { return N }
  for v := t; v != s; {
    for _, adj := range (*G)[v] {
      if D[adj] == D[v] - 1 {
        v = adj
        if v != s { (*V)[v] = -1 }
        break
      }
    }
  }
  return D[t]
}

func Solve() {
  HW := NextIntVec()
  H, W := HW[0], HW[1]
  G := make([][]int, H * W)
  V := make([]int, H * W)
  for i := range G {
    G[i] = make([]int, 0)
  }
  s, t := 0, 0
  for i := 0; i < H; i++ {
    A := NextLine()
    for j, a := range A {
      if a == 'S' { s = i * W + j }
      if a == 'T' { t = i * W + j }
      if a != '.' {
        V[i * W + j]++
        for k := 0; k < j; k++ {
          if 0 < V[i * W + k] {
            G[i * W + k] = append(G[i * W + k], i * W + j)
            G[i * W + j] = append(G[i * W + j], i * W + k)
          }
        }
        for k := 0; k < i; k++ {
          if 0 < V[k * W + j] {
            G[k * W + j] = append(G[k * W + j], i * W + j)
            G[i * W + j] = append(G[i * W + j], k * W + j)
          }
        }
      }
    }
  }
  for _, adj := range G[s] {
    if adj == t {
      Write(-1)
      return
    }
  }
  cnt := 0
  for BFS(&G, &V, s, t) < H * W { cnt++ }
  Write(cnt)
  return
}

func main() {
  Solve()
  Output()
}

Measured memory_bytes: 45056
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }


typedef unsigned long long ull;
ull B = 1e8 + 7;
const int maxn = 4001;
vector<ull> v(maxn);
vector<ull> v2(maxn);
string ss, tt;
ull t[maxn];

void init() {
    t[0] = 1;
    rep(i, maxn - 1) t[i + 1] = t[i] * B;
}
void build(string a) {
    int al = (int)a.length();
    
    rep(i, al) {
        v[i + 1] = v[i] + t[al - 1 - i] * a[i];
    }
}


void build2(string a) {
    int al = (int)a.length();
    
    rep(i, al) {
        v2[i + 1] = v2[i] + t[al - 1 - i] * a[i];
    }
    // rep(i, al) cout << v2[i] << endl;
}

bool check(int x) { // 長さxの文字列ありますか
    set<ull> s; // 文字列管理
    
    for (int i = 0; i + x <= sz(ss); ++i) {
        ull tmp = (v2[i + x] - v2[i]) * t[i];
        // cout << tmp << endl;
        s.insert(tmp);
    }
    
    for (int i = 0; i + x <= sz(tt); ++i) {
        ull tmp = (v[i + x] - v[i]) * t[i];
        // cout << i << " " << x << " " << tmp << endl;
        if (s.find(tmp) != s.end()) {
            // cout << x << " " << i << " " << tmp << endl;
            return 1;
        }
    }
    
    return 0;
}

int binary_search(int ok, int ng) {
    // assert(check(ok) == true);
    // assert(check(ng) == false);
    while (abs(ng - ok) > 1) {
        int mid = (ng + ok) / 2;
        (check(mid) ? ok : ng) = mid;
        // cout << "ok " << ok << " " << ng << endl;
    }
    return ok;
}


int main() {
    init();
    while (cin >> ss >> tt) {
        // cout << sz(ss) << " " << sz(tt) << endl;
        int nn = abs(sz(ss) - sz(tt));
        // cout << nn << endl;
        if (sz(ss) > sz(tt)) { // ここ間違えてた!!
            rep(i, nn) tt += '1';
        } else {
            rep(i, nn) ss += '1';
        }
        // cout << sz(ss) << " " << sz(tt) << endl;
        
        build(tt);
        build2(ss);
        // cout << v[1] << " " << v2[1] << endl;
        // cout << v2[1] << " " << (v[3] - v[2]) * t[2] << endl;
        cout << binary_search(0, sz(ss) + 1) << endl;
        
        ss = ""; tt = "";
    }
}



Measured memory_bytes: 3464
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <cstdlib>

using namespace std;
typedef long long ll;

int main(){
    ll n,tmp;
    cin >> n;
    ll *a;
    a = new ll[n];
    for(ll i = 0; i < n; i++){
        a[i] = 0;
    }
    for(ll i = 0; i < n-1; i++){
        cin >> tmp;
        a[tmp-1]++;
    }
    for(ll i = 0; i < n; i++){
        cout << a[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 5200
#include<bits/stdc++.h>          
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define mk_p(a,b)	make_pair((a),(b))
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr long long MOD = 1000000007;

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

string mas[105];
vector<int> x;
signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h,w;
	cin >> h >> w;
	rep(i,h){
		cin >> mas[i];
	}
	rep(i,h){
		bool flg = true;
		rep(j,w){
			if(mas[i][j] == '#'){
				flg = false;
				break;
			}
		}
		if(flg){
			x.emplace_back(i);
		}
	}
	vector<int> y;
	rep(i,w){
		bool flg = true;
		rep(j,h){
			if(mas[j][i] == '#'){
				flg = false;
				break;
			}
		}
		if(flg){
			y.emplace_back(i);
		}
	}
	rep(i,h){
		if(binary_search(all(x),i)) continue;
		rep(j,w){
			if(binary_search(all(y),j)) continue;
			else cout << mas[i][j];
		}
		cout << '\n';
	}
	return 0;
}


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

int main(){
    int N; cin >> N;
    string S; cin >> S;
    vector<char>Alphabet={'A','B','C',
    'D','E','F','G','H','I','J','K','L','M',
    'N','O','P','Q','R','S','T','U','V','W',
    'X','Y','Z'};
    vector<int>cnt(26);
    for(int i=1;i<26;i++){
        cnt.at(i)=cnt.at(i-1)+1;
    }
    for(int i=0;i<S.size();i++){
        for(int j=0;j<26;j++){
            if(S.at(i)==Alphabet.at(j)){
                int digit=(j+N)%26;
                S.at(i)=Alphabet.at(digit);
                cout << S.at(i);
                break;
            }
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <set>
#include <map>

using namespace std;

set<int> s;
map<int,int> mp;

int main(){
    s.clear();
    mp.clear();
    int n,a;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a);
        s.insert(a);
        s.insert(a-1);
        s.insert(a+1);
        mp[a]++;
        mp[a-1]++;
        mp[a+1]++;
    }
    int Max=0;
    for(auto x:s){
        if(mp[x]>Max){
            Max=mp[x];
        }
    }
    printf("%d\n",Max);
    return 0;
}


Measured memory_bytes: 9216
n,q=map(int,input().split())
l=[]
for i in range(n-1):
  l.append(list(map(int,input().split())))
l2=[]
for i in range(q):
  l2.append(list(map(int,input().split())))
connection=[[] for i in range(n)]
for i in range(n-1):
  connection[l[i][0]-1].append(l[i][1]-1)
 
L4=[]
for i in range(n):
  L4.append(0)
for i in range(q):
  L4[l2[i][0]-1]+=l2[i][1]
distance=[0 for i in range(n)]
distance[0]=L4[0]
ans=[0 for i in range(n)]
ans[0]=L4[0]
L=[0]
L2=[]
L3=[]
while len(L2)!=n and len(L)!=0:
  for j in range(len(L)):
    for k in range(len(connection[L[j]])):
      distance[connection[L[j]][k]]=distance[L[j]]+L4[connection[L[j]][k]]
      L3.append(connection[L[j]][k])
    L2.append(L[j])
  L=L3
  L3=[]
for i in range(len(distance)):
  distance[i]=str(distance[i])
print(' '.join(distance))

Measured memory_bytes: 157320
#include<stdio.h>


int gcd(int x,int y){
  int t;
  if(x<y) {
    t=y;
    y=x;
    x=t;
  }
  if(y==0) return x;
  return gcd(x%y,y);
}

int main(){
  int n;
  scanf("%d",&n);
  long long a[n],i,l[n],r[n],max=0;
  for(i=0;i<n;i++){
    scanf("%lld",&a[i]);
  }
  l[0]=0;
  r[0]=0;
  
  for(i=0;i<n;i++){
    l[i+1]=gcd(l[i],a[i]);
    r[i+1]=gcd(r[i],a[n-i-1]);
  }
  
  for(i=0;i<n;i++){
    int x;
    x=gcd(l[i],r[n-1-i]);
//    printf("%d %d\n",l[i],r[n-1-i]);
    max=max>x?max:x;
  }
  printf("%d",max);
return 0;
}



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

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;

#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 

#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
#define len length
#define ret0 return 0
#define ret return 

#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound

#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>

// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;

#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN 100001

ll gcd(ll a, ll b){
    if (a == 0)   return b;
    if(b==0)      return a;
    if (a == b)   return a;
    if (a > b)    return gcd(a%b, b);
    return gcd(a, b%a);
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    

    ll a, b, c, d;
    cin>>a>>b>>c>>d;
    ll g = gcd(c, d);
    ll l = (c/g)*d;

    ll ans = b/c - (a-1)/c  + b/d - (a-1)/d - (b/l - (a-1)/l);
    print(b-a+1-ans);
        
    
}



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

#define MOD 10000007
#define f first
#define s second
#define es " "
#define pb push_back
#define endl "\n"
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define ll long long int
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

ll fastexp(ll x, ll y){
    ll resp=1;
    while(y>0){
        if(y%2!=0){
            resp*=x;
        }
        y/=2;
        x*=x;
    }
    return resp;
}

int main(){
    fastio;
    ll h;
    cin >> h;
    cout << fastexp(2, (ll)log2(h)+1)-1 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	/**
	 * @param args
	 */
	static Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		while(true) {
			int n = sc.nextInt();
			if(n == 0) break;
			int[] a = new int[n+1];
			int[] dp = new int[n+1];
			for(int i = 1; i <= n; i++) {
				a[i] = sc.nextInt();
			}
			int max = Integer.MIN_VALUE;
			for(int i = 1; i <= n; i++) {
				dp[i] = Math.max(a[i], a[i] + dp[i-1]);
				max = Math.max(dp[i], max);
			}
			System.out.println(max);
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <string>
#include <vector>

char getInitial(const std::string& word);
 
int main() {
    std::vector<std::string> words;
    std::string word;
    while(std::cin >> word) {
        words.push_back(word);
    }
    
    std::string abbreviation;
    for(std::string word : words) {
        abbreviation += getInitial(word);
    }
    
    std::cout << abbreviation << std::endl;
}

char getInitial(const std::string& word) {
    return word.at(0);
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    unordered_map<string,int> mp;
    string s;
    ll ans = 0;
    for (int i = 0;i < n;i ++)
    {
        cin>>s;
        sort(s.begin(),s.end());
        if (!mp[s]) mp[s] = 1;
        else mp[s] ++;
    }
    unordered_map<string,int> :: iterator it;
    for (it = mp.begin();it != mp.end();it ++)
    {
        int n = it->second;
        ans += 1LL* n*(n-1)/2;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 10660