akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ALDS_1_3_B
{
    public struct Process
    {
        public string name;
        public int time;
    }

    class Program
    {
        static void Main(string[] args)
        {
            int process_num;
            int quantum;
            Process proc = new Process();
            Queue<Process> proc_queue = new Queue<Process>();

            string inputline = Console.ReadLine();
            string[] sp_inputline = inputline.Split(' ');
            process_num = int.Parse(sp_inputline[0]);
            quantum = int.Parse(sp_inputline[1]);

            /* プロセスキューの作成 */
            for(int i = 0; i < process_num; i++)
            {
                inputline = Console.ReadLine();
                sp_inputline = inputline.Split(' ');

                proc.name = sp_inputline[0];
                proc.time = int.Parse(sp_inputline[1]);
                proc_queue.Enqueue(proc);
            }

            /* スケジューリング */
            int elapsed_time = 0;

            while(proc_queue.Count != 0)
            {
                Process target_proc = proc_queue.Dequeue();
                
                if((target_proc.time - quantum) <= 0)
                {
                    /* クオンタム時間内にプロセスが終了 */
                    elapsed_time += target_proc.time;
                    Console.WriteLine(target_proc.name + " " + elapsed_time);
                }
                else
                {
                    /* クオンタム時間内にプロセスが終了しなかった */
                    elapsed_time += quantum;
                    target_proc.time -= quantum;
                    proc_queue.Enqueue(target_proc);
                }
            }
        }
    }
}



Measured memory_bytes: 21792
s = int(input())
a = [s]
m = 100000
i = 0
while i<= m :
    if a[i] % 2 == 0:
        s = int(s/2)
    else:
        s = s*3+1
    i += 1
    if s in a:
        print(i+1)
        exit()
    else:
        a.append(s)

Measured memory_bytes: 3060
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())
l=[input().split() for i in range(n)]
x=input()

ans=0
c=False
for s,t in l:
  if c:
    ans+=int(t)
  if x==s:
    c=True

print(ans)

Measured memory_bytes: 9156
import sys

N, M = [int(x) for x in sys.stdin.readline().rstrip().split(" ")]

count = [0 for x in range(N + 1)]

ac = 0
pena = 0


for i in range(M):
	p, S = sys.stdin.readline().rstrip().split(" ")
	p = int(p)
	if count[p] >= 0:
		if S == "AC":
			ac += 1
			pena += count[p]
			count[p] = -1
		else:
			count[p] += 1

print("%d %d" % (ac, pena))


Measured memory_bytes: 3928
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) true
#define dump(x) true
#endif

V<int> getMinimalCycleDirected(const VV<int>& G){
	using P = pair<int,int>;
	int N = G.size();
	V<int> vis(N);	//0:yet 1:now 2:done
	V<int> par(N,-1);
	V<int> d(N);

	P U(-1,-1);	// min distance backward edge

	function<void(int)> dfs = [&](int v){
		vis[v] = 1;
		for(int u: G[v]){
			if(vis[u] == 0){	// dfs edge
				par[u] = v;
				d[u] = d[v]+1;
				dfs(u);
			}else if(vis[u] == 1){	// up
				if(U.fs == -1 || d[U.fs] - d[U.sc] > d[v] - d[u]){
					U = P(v,u);
				}
			}else{}	// left, down
		}
		vis[v] = 2;
	};
	rep(v,N) if(vis[v] == 0){
		dfs(v);
	}
	if(U.fs == -1) return {};
	V<bool> in_cycle(N);
	V<int> c;
	{
		int v = U.fs;
		while(true){
			c.pb(v); in_cycle[v] = true;
			if(v == U.sc) break;
			v = par[v];
		}
	}
	reverse(all(c));
	P D(c[0],c[1]);	// max distance down edge between U
	rep(v,N) if(in_cycle[v]){
		for(int u: G[v]) if(in_cycle[u]){
			if(d[D.sc]-d[D.fs] < d[u]-d[v]){
				D = P(v,u);
			}
		}
	}
	V<int> nc;
	bool flag = true;
	for(int v: c){
		if(v == D.sc) flag = true;
		if(flag) nc.pb(v);
		if(v == D.fs) flag = false;
	}
	return nc;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int N,M; cin >> N >> M;
	VV<int> G(N);
	rep(i,M){
		int x,y;
		cin >> x >> y;
		x--,y--;
		G[x].pb({y});
	}
	auto c = getMinimalCycleDirected(G);
	if(c.empty()) cout << -1 << endl;
	else{
		cout << c.size() << endl;
		for(int v: c) cout << v+1 << endl;
	}
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL)
#define int long long
#define ld long double
#define sb __builtin_popcount
#define vi vector<int>
#define vc vector<char>
#define ii pair<int, int>
#define pq priority_queue<ii, vector<ii>, greater<ii>>
#define vii vector<ii>
#define sz(a) int((a).size())
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <=n; i++)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rloop(i,a,b) for(int i=a;i>=b;i--)
#define in(a, b) (b.find(a) != string::npos)
#define minin(a) *min_element(all(a))
#define maxin(a) *max_element(all(a))
#define X first
#define Y second
#define fill(a, x) memset(a, x, sizeof(a))
#define pb push_back
#define pf push_front
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) reverse(v.begin(), v.end())
#define el "\n"
#define mx3(a, b, c) max(max(a, b), c)
#define mn3(a, b, c) min(min(a, b), c)
#define S(v) accumulate(all(v), (ll)0)
#define SP(n) cout.precision(n)
#define PI = atan(1.0) * 4.0;
#define MOD = 1e9 + 7;
void start() {
    fio;
    SP(10);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
int32_t main() {
    start();
    int x;
    for (int i = 1; i <= 5; i++) {
        cin >> x;
        if (x == 0) {
            cout << i;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<P>> Graph;


int main(){

  int a,b,x;
  cin >> x >> a >> b;
  
  if(a-b >= 0) cout << "delicious" << endl;
  else if(b - a <= x) cout << "safe" << endl;
  else cout << "dangerous" << endl;


 return 0;
}

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

using namespace std;

using int64 = long long;

constexpr int DEBUG = 0;

struct Int2D {
  int64 x, y;
};

vector<Int2D> Solve();

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

  vector<Int2D> ans = Solve();
  if (ans.empty()) {
    cout << -1 << endl;
  } else {
    cout << ans.size() << endl;
    for (auto p : ans) {
      cout << p.x << " " << p.y << endl;
    }
  }
}

vector<Int2D> Solve() {
  int64 k;
  int64 x, y;
  cin >> k >> x >> y;
  bool x_inverted = false;
  bool y_inverted = false;
  if (x < 0) {
    x *= -1;
    x_inverted = true;
  }
  if (y < 0) {
    y *= -1;
    y_inverted = true;
  }

  // In the following, x >= 0 and y >= 0.

  auto restore_vector = [&](const vector<Int2D> ps) {
    vector<Int2D> qs;
    for (int i = 0; i < ps.size(); i++) {
      Int2D p = ps[i];
      if (x_inverted) p.x *= -1;
      if (y_inverted) p.y *= -1;
      qs.push_back(p);
    }
    return qs;
  };

  auto solve_normalized = [&]() -> vector<Int2D> {
    // Turn 1
    if (x + y == k) {
      return {{x, y}};
    }

    int ans_turn = (x + y + k - 1) / k;
    if (ans_turn == 1) ans_turn++;

    if (k % 2 == 1) {
      if ((x + y) % 2 == 1) {
        if (ans_turn % 2 == 0) ans_turn++;
      } else {
        if (ans_turn % 2 == 1) ans_turn++;
      }
    } else {
      if ((x + y) % 2 == 1) {
        return {};
      } else {
        // OK
      }
    }

    int64 current_x = 0;
    int64 current_y = 0;
    vector<Int2D> ans;
    if (DEBUG) cout << "x: " << x << " y: " << y << endl;
    if (DEBUG) cout << "ans_turn: " << ans_turn << endl;
    while (true) {
      if (DEBUG) cout << current_x << " " << current_y << endl;

      int remaining_turn = ans_turn - ans.size();
      int64 distance = (x - current_x) + (y - current_y);
      if (remaining_turn == 2) {
        int64 extra = (2 * k - distance) / 2;

        int64 dx = x - current_x;
        int64 dy = y - current_y;
        if (dx >= dy) {
          int64 r = k;
          r -= extra;
          current_y -= extra;
          current_x += r;
          ans.push_back({current_x, current_y});
          ans.push_back({x, y});
          return ans;
        } else {
          int64 r = k;
          r -= extra;
          current_x -= extra;
          current_y += r;
          ans.push_back({current_x, current_y});
          ans.push_back({x, y});
          return ans;
        }
      } else {
        if (distance < k) {
          current_x -= k;
          ans.push_back({current_x, current_y});
        } else {
          int64 r = k;
          if (current_x < x) {
            int64 x_move = min(x - current_x, k);
            r -= x_move;
            current_x += x_move;
          }
          current_y += r;
          ans.push_back({current_x, current_y});
        }
      }
    }
  };

  return restore_vector(solve_normalized());
}


Measured memory_bytes: 9836
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod = 1000000007;

ll go(ll choco[],ll n,ll k)
{
    ll dp[n+1][100005];

    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=k;j++)
        {
            if(i==0)
                dp[i][j] = 0;
                
            if(j==0)
                dp[i][j] = 1;
        }
    }
    
    dp[0][0] = 1;
    for(int i=1;i<=n;i++)
    {
        vector <ll> prefix(k+1);
        
        prefix[0] = dp[i-1][0];
        for(int j=1;j<=k;j++)
            prefix[j] = (dp[i-1][j]%mod + prefix[j-1]%mod)%mod;
            
        for(int j=1;j<=k;j++)
        {
            ll x = choco[i];
            if(j <= x)
                dp[i][j] = prefix[j]%mod;
            else
                dp[i][j] = (prefix[j]%mod - prefix[j-x-1]%mod + mod)%mod;
        }
      	prefix.clear();
    }
  	
    /*
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=k;j++)
        {
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }*/
    
    return dp[n][k]%mod;
}

int main()
{
    int n , k;
    cin >> n >> k;
    
    ll choco[n+1];
    for(int i=1;i<=n;i++)
        cin >> choco[i];
    
    cout << go(choco,n,k) << endl;
    
    return 0;
}


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




int main() {
 int N;
 cin >> N;
 double sum =0;
 vector<int> v(N);
 rep(i,N) {
    cin >> v.at(i);
    sum += v.at(i);
 }
 
 double ave = sum / N;

 ave = round(ave);


 sum = 0;
 rep(i,N){
     int A = (ave - v.at(i));
     sum += A*A;
     
 }
 
 cout << sum;
 
}



Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			int[][] ns = new int[n][2];
			while (n-- > 0) {
				ns[n][0] = scanner.nextInt();
				ns[n][1] = scanner.nextInt();
			}
			int m = scanner.nextInt();
			int[][] ms = new int[m][2];
			while (m-- > 0) {
				ms[m][0] = scanner.nextInt();
				ms[m][1] = scanner.nextInt();
			}
			int len = ns.length + ms.length;
			int[][] num = Arrays.copyOf(ns, len);
			System.arraycopy(ms, 0, num, ns.length, ms.length);
			Arrays.sort(num, new Comparator<int[]>() {
				@Override
				public int compare(int[] a, int[] b) {
					if (a[0] == b[0]) {
						return a[1] - b[1];
					}
					return a[0] - b[0];
				}
			});
			int[] dp = new int[len];
			Arrays.fill(dp, 1);
			for (int i = 0; i < len; i++) {
				for (int j = 0; j < i; j++) {
					if (num[i][0] <= num[j][0] || num[i][1] <= num[j][1])
						continue;
					dp[i] = Math.max(dp[i], dp[j] + 1);
				}
			}
			int ans = 0;
			for(int i=0;i<len;i++){
				ans = Math.max(ans, dp[i]);
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 24696
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
  int a[2][111],n,ans[111]={};
  cin>>n;
  for(int i=0;i<n;i++)
    cin>>a[0][i];
  for(int i=0;i<n;i++)
    cin>>a[1][i];
  for(int i=0;i<n;i++){
    for(int j=0;j<=i;j++)
      ans[i]+=a[0][j];
    for(int j=i;j<n;j++)
      ans[i]+=a[1][j];
  }
  sort(ans,ans+n);
  cout<<ans[n-1];
  return 0;
}

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

int main() {
	int h,w,x,y;
    while(1){
        cin >> h >> w;
        y = h;
        if(h==0 && w==0)
            break;
        while(h > 0){
            x = w;
            while(x > 0){
                if(x==1 || x==w || h==1 || h==y)
                    cout <<"#";
                else
                    cout <<".";
                x--;
            } 
            cout <<endl;
            h--;
        }
        cout <<endl;
    }
    return 0;
}

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

int main() {

	int N,M,min;
	cin>>N>>M;
  min=M;
  vector<int>A(N);
	for(int i=0;i<N;i++){
      cin>>A.at(i);M-=A.at(i);
    if(min>A.at(i)){min=A.at(i);}}
  
  
	cout<<N+(M/min)<<endl;
}


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

int main() {
#ifdef whyqx
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif
    int X, A;
    cin >> X >> A;
    puts(X >= A ? "10" : "0");
    return 0;
}


Measured memory_bytes: 256
import heapq

n, m = map(int,input().split())
li = list(map(lambda x: int(x)*(-1),input().split()))

heapq.heapify(li)

for i in range(m):
    a = heapq.heappop(li)
    a = (-a) // 2
    heapq.heappush(li,-a)

print(-sum(li))

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

typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<ll> vi;

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define nl cout<<'\n'
#define pb push_back
#define all(s) s.begin(),s.end()
#define bs binary_search

#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) (a)*(b)/(__gcd((a),(b)))

const int Mod=1e9+7;
#define sum(a,b) (((a)%Mod)+((b)%Mod))%Mod
#define sub(a,b) (((a)%Mod)-((b)%Mod))%Mod
#define mul(a,b) (((a)%Mod)*((b)%Mod))%Mod
#define digit(x) floor((log10(x))+1)


#define count1(x) __builtin_popcount(x)

#define dbg(x) cout << #x <<":"<<x<<endl;

bool isPowerOfTwo (int x)  
{  
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));  
} 

ll pow(ll x, ll y, ll mod)
{
	int ans=1;
	while(y)
	{
		if(y&1)
			ans=(ans*x)%mod;
		y/=2;
		x=(x*x)%mod;
	}
	return ans;
}

int main()
{
	fast;
	ll n,i;
	string s;
	map<string,int> mp;
	cin >> n;
	for(i=0;i<n;i++)
	{
		cin >> s;
		mp[s]++;
	}
	cout << mp.size() << endl;
}

Measured memory_bytes: 19288
#include<iostream>

using namespace std;

int main() {
	
	int x, y;
	char c;
	bool test = false;
	
	while( cin >> x >> c>> y  ) {
		
		switch(c) {
			
			case '+': cout << x + y << "\n";
			break;
			
			case '-': cout << x - y << "\n";
			break;
			
			case '*': cout << x * y << "\n";
			break;
			
			case '/': cout << x / y << "\n";
			break;
			
			default : test = true;
			break;
		}
		if( test )
		break;
	}
		
	return 0;
}


Measured memory_bytes: 3076
#include <iostream>
#include <algorithm>
#include <numeric>

using namespace std;

int gcd (int a, int b){
    if (a == 0){
        return b;
    }
    if (b == 0){
        return a;
    }
    if (a == b){
        return a;
    }
    if (a > b) {
       return  gcd(a-b, b);
    }
    if (a < b) {
        return gcd(a, b-a);
    }
}


int main(){
    int n, sum;
    cin >> n;
    sum = 0;
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= n; j++){
            for (int k = 1; k <= n; k++){
                sum +=  gcd(i, gcd(j, k));
                
            }
        }
    }
    cout << sum << "\n";
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define rep(I, N) for (int I = 1; I <= (N); ++I)
#define repp(I, N) for (int I = 0; I < (N); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORR(I, A, B) for (int I = (A); I >= (B); I--)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
const int N = 2e5 + 5;
const double eps = 1e-7;
const int mod = 1e9 + 7;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
LL gcd(LL a,LL b){return b>0?gcd(b,a%b):a;}
LL ksm(LL a,LL b){LL ans = 1;while(b){if(b&1) ans = ans * a % mod;a = a * a % mod;b >>= 1;}return ans % mod;}
LL t[N];
int p = 0;
int main() {
    LL l,r;
    cin >> l >> r;
    LL x = l / 2019;
    LL y = r / 2019;
    if(x == y)
    {
        LL ans = 2e9;
        for (LL i = l;i <= r;i++)
        {
            for (LL j = i + 1; j <= r;j++)
            {
                LL _ = i * j;
                ans = min(ans, _ % 2019);
            }
        }
        cout << ans << endl;
    }
    else
        cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  int X, Y;
  cin >> X >> Y;

  ll ans = LINF;
  for (int ab = 0; ab / 2 <= max(X, Y); ab += 2) {
    int a = max(X - ab / 2, 0);
    int b = max(Y - ab / 2, 0);

    int price = a * A + b * B + ab * C;
    chmin(ans, (ll)price);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

def resolve():
    N = int(input())
    S = input()
    cnt0 = S.count("1")

    if cnt0 == 0:
        print("\n".join(map(str, [1]*N)))
        return

    X = int(S, 2)

    def f2():
        cache = [-1] * max(9, cnt0+1)
        cache[0] = 0
        for i in range(4): cache[1<<i] = 1
        def f2(x):
            if cache[x] != -1:
                return cache[x]

            y = bin(x).count("1")
            z = 1 + f2(x % y)
            cache[x] = z

            return z
        f2.cache = cache
        return f2
    f2 = f2()

    dc = []
    for v in [1, -1]:
        x = cnt0 + v
        y = X % x if x else 0
        dc.append((x, v, y, [1, N-1]))

    ans = [0] * N
    for i in reversed(range(N)):
        cnt, v, n, m1 = dc[0 if S[i] == "0" else 1]

        if cnt == 0:
            ans[i] = 0
            continue

        m2 = (m1[0]<<(m1[1]-i)) % cnt
        n = (n + v*m2) % cnt
        m1[0], m1[1] =  m2, i

        ans[i] = 1 + f2(n)

    print("\n".join(map(str, ans)))


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 95376
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    int k = sc.nextInt();
    String ans = "";
    for(int i = 0; i < n; i++) {
      String str = String.valueOf(s.charAt(i));
      if(s.charAt(i) == s.charAt(k - 1)) {
        ans += str;
      } else {
        ans += "*";
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21588
N = int( input())
X = [ list( map( int, input().split())) for _ in range(N)]
for j in range(N):
    if X[j][2] != 0:
        k = j
        break
A = X[j]
for cx in range(101):
    for cy in range(101):
        H = A[2] + abs( A[0] - cx) + abs( A[1] - cy)
        Flag = True
        for i in range(N):
            if max( H - abs(X[i][0]-cx) - abs(X[i][1] - cy), 0) != X[i][2]:
                Flag = False
                break
        if Flag:
            print('{} {} {}'.format(cx, cy, H))
            break
    if Flag:
        break

Measured memory_bytes: 42480
#[allow(unused_imports)]
use std::cmp::*;

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let token: String = std::io::stdin()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

#[allow(non_snake_case)]
fn main() {
    let mut max_res: u32 = 0;
    let mut ans = 0;
    for _ in 0..5 {
        let tmp: u32 = read();
        max_res = max(max_res, (10 - tmp % 10) % 10);
        ans += tmp + (10 - tmp % 10) % 10;
    }
    println!("{}", ans - max_res);
}


Measured memory_bytes: 4352
S = input()
def is_hitachi(S):
    hitachi = [
        'hi',
        'hihi',
        'hihihi',
        'hihihihi',
        'hihihihihi',
    ]
    if S in hitachi:
        return 'Yes'
    else:
        return 'No'

print(is_hitachi(S))


Measured memory_bytes: 9120
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();
		int res = H * W;

		res -= W * h;
		res -= (H-h)*w;

		System.out.println(res);

		sc.close();
	}

}

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

void solve()
{
	int n;
	cin >> n;

	long long lim;

	cin >> lim;
	lim *= lim;

	int cnt = 0;
	for(int i = 0; i < n; i++)
	{
		long long x, y;
		cin >> x >> y;

		if( (x*x + y*y) <= lim)
			cnt++;
	}

	cout << cnt << endl;
}

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

	solve();
	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<ll, ll> pii;
 
#define REP(a,b,c) for(ll (a)=(b);(a)<(c);(a)++)
#define PER(a,b,c) for(ll (a)=(b);(a)>=(c);(a)--)
 
void ii(ll &x){ cin >> x; }
void is(string &x){ cin >> x; }
void oi(ll x){ cout << x << " "; }
void os(string x){ cout << x; }
void oie(ll x){ cout << x << endl; }
void ose(string x){ cout << x << endl; }
void oe(){ cout << endl; }

bool ok(ll l, ll r, string s){
    while(l<r){
        if(s[r]!=s[l]){
            return false;
        }
        r--;
        l++;
    }
    return true;
}

int main(){
    string S;
    is(S);
    ll N = S.length();
    if(ok(0,N-1,S)&&ok(0,(N-1)/2-1,S)&&ok((N+3)/2-1,N-1,S)){
        ose("Yes");
    }else{
        ose("No");
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
	double Ans1=0,Ans2=0,Ans3=0,x[101],y[101],Ans4=0,temp=0;
	int n,i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%lf",&x[i]);
	}
	for(i=0;i<n;i++){
		scanf("%lf",&y[i]);
	}
	for(i=0;i<n;i++){
		Ans1+=abs(x[i]-y[i]);
		Ans2+=(x[i]-y[i])*(x[i]-y[i]);
		Ans3+=(abs(x[i]-y[i]))*(abs(x[i]-y[i]))*(abs(x[i]-y[i]));
	}
	Ans2=sqrt(Ans2);
	Ans3=pow(Ans3,1.0/3.0);
	Ans4=abs(x[0]-y[0]);
	for(i=0;i<n;i++){
		if(Ans4>=abs(x[i]-y[i]))		Ans4=Ans4;
		else if(Ans4<abs(x[i]-y[i])) Ans4=abs(x[i]-y[i]);
	}
	printf("%lf\n",Ans1);
	printf("%lf\n",Ans2);
	printf("%lf\n",Ans3);
	printf("%lf\n",Ans4);
	return 0;
}

Measured memory_bytes: 696
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

struct Point {
    int x;
    int y;
};


int main() {
    
    int H,W,D;
    cin >> H >> W >> D;
    vector< Point > V(H*W+1);
    for ( int y = 0; y < H; y++ ) {
    for ( int x = 0; x < W; x++ ) {
        int a;
        cin >> a;
        Point p;
        p.x = x;
        p.y = y;
        V[a] = p;
    }
    }

    vector< vector<long long> > X(D+1);
    for ( int i = 1; i <= D; i++ ) {
    for ( int j = 0; i+j*D <= H*W; j++ ) {
        if ( j == 0 ) {
            X[i].push_back(0);
        }
        else {
            int d = abs( V[i+j*D].x-V[i+(j-1)*D].x ) + abs( V[i+j*D].y-V[i+(j-1)*D].y );
            X[i].push_back( X[i][j-1] + d );
        }        
    }        
    }

    vector<long long> A;
    int Q;
    cin >> Q;
    for ( int i = 0; i < Q; i++ ) {
        int l,r;
        cin >> l >> r;
        A.push_back( X[ r%D == 0 ? D : r%D ][(r-1)/D] - X[ l%D == 0 ? D : l%D ][(l-1)/D] );
    }
    for ( int i = 0; i < Q; i++ ) {
        cout << A[i] << endl;
    }

    


    return 0;
}

Measured memory_bytes: 7036
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define agewari(a, b) ((ll)a + ((ll)b - 1)) / b
const int MOD = 1000000007;
const long long INF = 1LL << 60;

//因数分解→map<素因数,それぞれいくつか>の形に格納
map<ll, ll> prime; //素因数分解でそれぞれの素数がいくつ出てきたかを保存するmap

//O(√n)
//整列済み(mapはkeyで自動で整列される)
void prime_factorize(ll n)
{
    if (n <= 1)
        return;
    ll l = sqrt(n);
    for (ll i = 2; i <= l; i++)
    {
        if (n % i == 0)
        {
            prime_factorize(i);
            prime_factorize(ll(n / i));
            return;
        }
    }
    //mapでは存在しないkeyの場合も自動で構築される
    prime[n]++;
    return;
}

int main()
{
    ll n;
    cin >> n;
    for (ll i = 1; i <= n; i++)
    {
        prime_factorize(i);
    }

    ll ans = 1;
    for (auto p : prime)
    {
        ans = (ans * (p.second + 1)) % MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3632
// Tue May 26 19:06:02 IST 2020 
#include <bits/stdc++.h>        
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(ii,a,b)        for(int ii = (int)a ; ii < (int)b  ; ii++ )
#define debug(x)           cerr << #x << " " << x << " -- \n"
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define int64              long long    
#define MOD                998244353 
#define pb                 push_back
#define f1                 first 
#define s1                 second    
#define all(x)             (x).begin(),(x).end() 
#define precise(x)         cout << fixed << setprecision(12) << x << '\n'; 
#define tough_nut          numeric_limits<int64>::min()

const double pi = 3.141592653589793238;
using namespace  std ;       
using namespace __gnu_pbds;
 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set ; 
const int N = 3e5+7; 
const int INF = INT_MAX;
struct comp{
    bool operator()(const pair<int,int> A,const pair<int,int>& B )const{
        if(A.first == B.first)
            return A.second < B.second ;
        return A.first > B.first;
    } 
};   
int tests(){ 
    int64 n,m,k;
    cin >> n >> m >> k; 
    vector <int64> a(n),b(m) ;
    for(auto& x: a)
        cin >> x ;
    for(auto& x : b)
        cin >> x ; 
    for (int64 i = 1 ; i < n ;i++ )
        a[i] += a[i-1];
    int64 ans = b[0] <= k ;

    for (int64 i = 1 ; i < m ;i++ ){ 
        b[i] += b[i-1];
        if(b[i] <= k)
            ans = i+1 ; 
    }
    
    
    for(int64& t: b)
        t *= -1 ; 
    sort(all(b)); 
    for(int i = 0 ; i < n ; i++ )
        if(k >= a[i])
            ans = max(ans,(int64)(i+1+int(b.end()-lower_bound(all(b),-(k-a[i])))));
         
    cout << ans << '\n'; 
    return 0 ;
} 
int32_t main(){
    I__O ;     
    int cases = 1 ;  
    // cin >> cases ;  
    while(cases--) 
        tests(); 
     
    return 0 ; 
}
 // g++ -std=c++17 -O2 -Wall test.cpp  

Measured memory_bytes: 6348
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>

#define rep_ui(k,n)      for(ui  i = (k); i < (n); ++i)
#define rep_si(k,n)      for(int i = (k); i < (n); ++i)
#define rep_ul(k,n)      for(ul  i = (k); i < (n); ++i)
#define rep_sl(k,n)      for(ll  i = (k); i < (n); ++i)
#define rep_ui_down(k,n) for(ui  i = (k); i > (n); --i)
#define rep_si_down(k,n) for(int i = (k); i > (n); --i)
#define rep_ul_down(k,n) for(ul  i = (k); i > (n); --i)
#define rep_sl_down(k,n) for(ll  i = (k); i > (n); --i)

#define rep_uj(k,n)      for(ui  j = (k); j < (n); ++j)
#define rep_sj(k,n)      for(int j = (k); j < (n); ++j)
#define rep_uj_down(k,n) for(ui  j = (k); j > (n); --j)
#define rep_sj_down(k,n) for(int j = (k); j > (n); --j)

#define rep(k,n)         rep_ui(k,n)

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

template<class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vc)
{
#ifdef BOOST_RANGE_ALGORITHM_FOR_EACH_HPP_INCLUDED
  boost::for_each(vc, [&os](T value) {
#else
  std::for_each(vc.begin(), vc.end(), [&os](T value) {
#endif
    os << value << '\n';
    });
  return os;
}

template<class T1, class T2>
inline
std::ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& p)
{
  return os << p.first << ' ' << p.second;
}

void solve(void)
{
  using std::string;
  using std::vector;
  using std::map;
  using std::pair;
  using std::cin;
  //string S{}; std::cin >> S;
  //ui N{}; cin >> N;
  
  ui A{}, B{}, C{}; cin >> A >> B >> C;
  
  auto ans = std::min(A, B + C);
  ans = B + C - ans;

  using std::cout;
  cout << ans << '\n';
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()

left = 0
for i in s:
    if i == ")":
        left += 1
    else:
        break

left1 = 0
right1 = 0

for i in range(left, n):
    if s[i] == "(":
        right1 += 1
    elif right1 > 0:
        right1 -= 1
    else:
        left1 += 1

left1 += left
for i in range(right1):
    s += ")"
for i in range(left1):
    s = "(" + s

print(s)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define ii pair<int, int>
#define vii vector<ii>
#define ld long double
#define iii tuple<int, int, int>


int main() {

    int n;
    scanf("%d", &n);

    int ac = 0, wa = 0, tle = 0, re = 0;

    for(int i=1; i<=n; ++i) {

        string s;

        cin>>s;

        if(s == "AC") {
            ac++;
        }
        if(s == "WA") {
            wa++;
        }
        if(s == "TLE") {
            tle++;
        }
        if(s == "RE") {
            re++;
        }
    }

    printf("AC x %d\n", ac);
    printf("WA x %d\n", wa);
    printf("TLE x %d\n", tle);
    printf("RE x %d\n", re);
}


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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    string s;
    int k, n;
    cin >> s >> k;
    n = s.size();
    static int dp[301][301][301];
    for(int r=0;r<=k;++r){
        for(int i=0;i<n;++i) dp[i][i][r] = 0;
        for(int i=0;i<n;++i) dp[i][i+1][r] = 1;
        for(int w=2;w<=n;++w){
            for(int i=0;i+w<=n;++i){
                dp[i][i+w][r] = max(dp[i][i+w-1][r], dp[i+1][i+w][r]);
                if(s[i] == s[i+w-1]) dp[i][i+w][r] = max(dp[i][i+w][r], dp[i+1][i+w-1][r]+2);
                if(r > 0) dp[i][i+w][r] = max(dp[i][i+w][r], dp[i+1][i+w-1][r-1]+2);
            }
        }
    }
    cout << dp[0][n][k] << endl;
    return 0;
}

Measured memory_bytes: 106752
#include <stdbool.h>
#include <stdio.h>
typedef long long ll;
ll gcd(ll x, ll y) {
	ll r;
	while ((r = x % y) != 0) {
		x = y;
		y = r;
	}
	return y;
}
int main() {
	ll a, b;
	int cnt = 0;
	scanf("%lld%lld", &a, &b);
	ll GCD = gcd(a, b);
	ll _GCD = GCD;
	for (ll i = 2; i * i <= _GCD; i++) {
		if (GCD % i == 0)
			cnt++;
		while (GCD % i == 0) {
			GCD /= i;
		}
	}
	if (GCD > 1) {
		cnt++;
	}
	printf("%d\n", cnt + 1);
	return 0;
}

Measured memory_bytes: 128
// #pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define N 1000000007
#define N2 998244353
#define Nmax 1000005
#define INF (ll)1e18
#define pll pair<ll,ll>
#define mp make_pair
#define fi first
#define se second
#define vv vector
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(ll i=m;i<(n);i++)
#define repr(i,n) repr2(i,n,0)
#define repr2(i,m,n) for(ll i=m;i>=(n);i--)
#define get(n) ll (n); scanf("%lld",&(n));
#define get2(n,k) ll (n),(k); scanf("%lld%lld",&(n),&(k));
#define get3(n,m,k) ll (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k));
#define gets(s) string (s); cin >> (s);
#define ALL(c) (c).begin(),(c).end()
#define fill_nums(A,n) vector<ll> A((n)); for(ll i=0;i<n;i++) scanf("%lld",&A[i]);
#define fill_edges(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1); adj[b-1].pb(a-1);}
#define fill_direct(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1);}
#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); //cout.tie(0);
#define pi 3.1415926535897
#define db double
#define noop
#define flu fflush(stdout)
#define imp {cout<<"NO\n"; return 0;}
#define debug_vec(vec,n) {rep(idxi,n) cout<<vec[idxi]<<" "; cout<<"\n";}
#define debug_pvec(vec,n) {rep(idxi,n) cout<<vec[idxi].fi<<"-"<<vec[idxi].se<<"  "; cout<<"\n";}
#define debug_set(seta) {cout<<seta.size()<<"\n"; for(auto idxi:seta) cout<<idxi<<" "; cout<<"\n";}
#define debug_map(mappa) {cout<<mappa.size()<<"\n";for(auto idxi:mappa) cout<<idxi.fi<<"-"<<idxi.se<<"  "; cout<<"\n";}

int main() {

    get2(n,m);
    if(m==n) cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;  
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

main :: IO ()
main = do
    _ <- getLine
    lr <- map ((\[a,b] -> (a,b)) . map (fst . fromJust . BS.readInt) . BS.words) . BS.lines <$> BS.getContents
    let l = maximum $ map fst lr
        r = minimum $ map snd lr
     in print $ max (r - l + 1) 0

Measured memory_bytes: 26876
N, Q = map(int, input().split())
s = input()
X = []
for _ in range(Q):
    t, d = input().split()
    X.append([t, 1 if d == "R" else -1])

def chk(k):
    i = k
    for x in X:
        if s[i] == x[0]:
            i += x[1]
            if i < 0:
                return -1
            if i >= N:
                return 1
    return 0

L, R = -1, N
while R-L>1:
    M = (L+R)//2
    if chk(M) < 0:
        L = M
    else:
        R = M

A = L

L, R = -1, N
while R-L>1:
    M = (L+R)//2
    if chk(M) > 0:
        R = M
    else:
        L = M

B = R
print(B-A-1)


Measured memory_bytes: 25652
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		
		int[][] count = new int[N][100];
		int[][] data = new int[N][3];
		
		for(int i = 0; i < N; i++){
			for(int j = 0; j < 3; j++){
				data[i][j] = sc.nextInt() - 1;
				count[j][data[i][j]]++;
			}
		}
		
		for(int i = 0; i < N; i++){
			int sum = 0;
			for(int j = 0; j < 3; j++){
				if(count[j][data[i][j]] <= 1){
					sum += data[i][j] + 1;
				}
			}
			
			System.out.println(sum);
		}
		
	}

}

Measured memory_bytes: 20880
using System;

class Prob0001
{
    static void Main(string[] args)
    {
        const int INPUT_SIZE = 10;
        const int OUTPUT_SIZE = 3;
        int[] inputs = new int[INPUT_SIZE];

        // inputs
        for(int i = 0; i < INPUT_SIZE; i++)
        {
            inputs[i] = int.Parse(Console.ReadLine());
        }

        // outputs
        int elem, tmp;
        for(int i = 0; i < OUTPUT_SIZE; i++)
        {
            tmp = inputs[0];
            elem = 0;
            
            for(int j = 1; j < INPUT_SIZE; j++)
            {
                if(inputs[j] > tmp)
                {
                    tmp = inputs[j];
                    elem = j;
                }
            }

            Console.WriteLine("{0}", tmp);
            inputs[elem] = -1;
        }
    }
}



Measured memory_bytes: 17936
import java.util.*;
import java.util.stream.*;
class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int H,W;
        while(true){
            H = input.nextInt();
            W = input.nextInt();
            if (H == 0 && W == 0){
                break;
            } else {
                for (int i = 0; i < H; i++){
                    for (int j = 0; j < W; j++){
                        System.out.printf("#");
                    }
                    System.out.printf("\n");
                }
                System.out.printf("\n");
            }
        }
    }
}


Measured memory_bytes: 64092
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string r,s;
    cin>>r>>s;
    int x=0;
    for(auto i=0;i<3;i++)
    {
        if(r[i]==s[i])
        {
            x++;
        }
    }
    cout<<x;
    return 0;
}


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

using namespace std;

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

	int m=s.length(),n=t.length();

	int dp[m+1][n+1];

	memset(dp,0,sizeof(dp));


	for(int i=1;i<=m;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(s[i-1]==t[j-1])
			{
				dp[i][j]=dp[i-1][j-1]+1;
			}
			else
			{
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}

	//cout<<dp[m][n]<<endl;

	vector<char> lcs;

	int i=m,j=n;

	while(i>0 && j>0)
	{
		if(s[i-1]==t[j-1])
		{
			lcs.push_back(s[i-1]);
			i--;
			j--;
		}
		else if(dp[i-1][j]>dp[i][j-1])
			i--;
		else
			j--;



	}

	for(int c=lcs.size()-1;c>=0;c--)
		cout<<lcs[c];



	return 0;


}

Measured memory_bytes: 35456
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<int,int> P;
#define fi first
#define se second
#define all(v) (v).begin(),v.end()
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}

int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n,k;cin>>n>>k;
vector<ll> a(n);
ll sum=0;
for(int i=0;i<n;i++){
  cin>>a[i];
  sum+=a[i];
}
//良い集合を作る
sort(all(a),greater<ll>());
ll res=0;
//組み合わせて作れる数字かの判定
vector<bool> dp(k,false);
dp[0]=true;
for(int i=0;i<n;i++){
  bool ok=false;
  //kを超える、あるjがあるか判定を行う
  for(int j=0;j<k;j++){
    ok=(dp[j]&&sum+j>=k);
    if(ok)break;
  }
  if(!ok)res++;
  else{
    sum-=a[i];
    for(int j=k-a[i]-1;j>=0;j--){
      //j+a[i]が作れるかの判定
      dp[j+a[i]]=(dp[j+a[i]]|dp[j]);
    }
  }
}
cout<<res<<endl;
}


Measured memory_bytes: 384
h,w=map(int,input().split())
a=[input() for _ in range(h)]
sh=set()
sw=set()
for i in range(h):
    ok=True
    for j in range(w):
        if a[i][j]=="#":
            ok=False
    if ok:
        sh.add(i)
for j in range(w):
    ok=True
    for i in range(h):
        if a[i][j]=="#":
            ok=False
    if ok:
        sw.add(j)
#print(sh)
#print(sw)
ans=[]
for i in range(h):
    l=""
    if i in sh:
        continue
    for j in range(w):
        if j in sw:
            continue
        l+=a[i][j]
    ans.append(l)
for c in ans:
    print(c)

Measured memory_bytes: 9236
program main
      
      implicit none
     
      integer :: n
      integer(8), allocatable :: a(:), b(:), c(:)
     
      integer :: i,j
      integer(8) :: sumb
     
      read(*,*) n
      allocate( a(n) )
      allocate( b(n) )
      allocate( c(n) )
      read(*,*) a
     
      b = 0  
      c = 0  
      do i = 1, n
        c(a(i)) =  c(a(i)) + 1
      end do
      sumb = 0
      do i = 1, n
        b(i) =  c(i)*(c(i)-1)/2
        sumb = sumb + b(i)
      end do
     
      do i = 1, n
        print*, sumb - b(a(i)) + (c(a(i))-2)*(c(a(i))-1)/2
      end do
      
      
    end program main


Measured memory_bytes: 9728
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
using namespace std;
typedef long long int llint;
#define rep(i,n) for(int i=0;i<n;i++)

bool check(int a, int b) {
	return a > b;
}

int main() {
	llint n;
	cin >> n;
	vector<llint>a(n + 1);
	llint x;
	rep(i, n + 1) {
		if (i == 0) {
			a[i] = 0;
		}
		else {
			cin >> x;
			a[i] = a[i - 1] + x;
		}
	}
	sort(a.begin(), a.end());
	llint ans = 0;
	llint cnt = 0;
	rep(i, n) {
		if (a[i] == a[i + 1]) {
			if (cnt == 0) {
				cnt = 2;
			}
			else {
				cnt++;
			}
		}
		else {
			ans += cnt*(cnt - 1) / 2;
			cnt = 0;
		}
	}
	ans += cnt*(cnt - 1) / 2;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
using System;
using System.Text;
using System.Collections.Generic;
using static System.Math;
using System.Linq;
using static System.Array;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;

namespace FenceRepair
{
    class Program
    {
        static void Main(string[] args)
        {
            var Q = int.Parse(Console.ReadLine());
            //var L = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();

            for (int i = 0; i < Q; i++)
            {
                var X = Console.ReadLine();
                var Y = Console.ReadLine();
                var Xsize = X.Length;
                var Ysize = Y.Length;

                var dp = new long[Xsize + 1, Ysize + 1];
                for (int k = 0; k < Xsize; k++)
                {
                    for (int j = 0; j < Ysize; j++)
                    {
                        if(X[k] == Y[j])
                        {
                            dp[k + 1, j + 1] = dp[k, j] + 1;
                        }
                        else
                        {
                            dp[k + 1, j + 1] = Max(dp[k+1, j],dp[k,j+1]);
                        }
                    }
                }
                Console.WriteLine(dp[Xsize,Ysize]);
            }
        }
    }
}


Measured memory_bytes: 46692
//cwystc <--> 陈威宇是天才  --by cwy
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
const double PI=acos(-1);
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for (int i=(a);i<=(b);i++)
#define per(i,a,b) for (int i=(a);i>=(b);i--)
#define Rep(i,a,b) for (int i=(a);i<(b);i++)
#define Per(i,a,b) for (int i=(a);i>(b);i--)
#define travel_set(it,a) for (set<int>::iterator (it)=(a).begin();(it)!=(a).end();(it)++)
#define travel_map(it,a) for (map<int>::iterator (it)=(a).begin();(it)!=(a).end();(it)++)
#define travel_vec(it,a) for (vector<int>::iterator (it)=(a).begin();(it)!=(a).end();(it)++)
#define p(x) cout << x << endl;
#define def cout << "find" << endl;
#define what_is(x) cout << #x << " is " << x << endl;
template <class T>T sqr(T x){return x*x;}
template <class T>T alex(T x){return (x>0)?x:-x;}
template <class T>void read(T&x){
	x=0;T f=1;char ch=getchar();
	while ((ch<48||ch>57)&&ch!=45)ch=getchar();
	if (ch==45)f=-1,ch=getchar();
	while (ch>=48&&ch<=57)x=x*10+ch-48,ch=getchar();
	x*=f;
}

//-------------------------------------------------head-------------------------------------------------

#define maxn 262144
int n,N,a[maxn];
pi mx[maxn],ss[maxn];int res[maxn];
int main(){
	read(n);N=1<<n;
	Rep(i,0,N)read(a[i]),mx[i]=mp(a[i],i),ss[i]=mp(-2e9,-1);
	for (int i=1;i<N;i<<=1)
		for (int j=0,del=i<<1;j<N;j+=del)
			Rep(k,0,i){
				if (mx[j+k]>mx[i+j+k]){
					ss[i+j+k]=mx[i+j+k],mx[i+j+k]=mx[j+k];
					if (ss[j+k]>ss[i+j+k])ss[i+j+k]=ss[j+k];
				}
				else if (mx[i+j+k]!=mx[j+k]){
					if (mx[j+k]>ss[i+j+k])ss[i+j+k]=mx[j+k];
				}
				else if (ss[j+k]>ss[i+j+k])ss[i+j+k]=ss[j+k];
			}
	Rep(i,1,N)res[i]=mx[i].fi+ss[i].fi;
	Rep(i,1,N)res[i]=max(res[i],res[i-1]);
	Rep(i,1,N)printf("%d\n",res[i]);puts("");
	return 0;
}

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

int main() {
  double N, K;
  cin >> N >> K;
  
  double p = 0;
  if (N >= K) {
    p = (N-K+1)/N;
  }
  
  for (int i = 1; i < N+1 && i < K; i++) {
    double l = 1;
    for (int j = i; j < K; j *= 2) {
      l *= 0.5;
    }
    p += l/N;
  }
  
  cout << fixed << setprecision(10);
  cout << p << endl;
}



Measured memory_bytes: 256
import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

A, B, M = map(int, readline().split())
a = list(map(int, readline().split()))
b = list(map(int, readline().split()))
XYC = [list(map(int, readline().split())) for _ in range(M)]

ans = min(a) + min(b)

for x, y, c in XYC:
    acc = a[x - 1] + b[y - 1] - c
    ans = min(acc, ans)

print(ans)


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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int x = Integer.parseInt(reader.readLine());
        int a = x;
        int result = -1;
        for (int i = 1; true; i++) {
            if (a % 360 == 0) {
                result = i;
                break;
            }
            a += x;
        }
        System.out.println(result);
        reader.close();
    }
}


Measured memory_bytes: 32572
#include <stdio.h>

int main(void)
{
    int N,max,i,d;
    max = 0;
    int H[100000];
    scanf("%d",&N);
    for(i = 0;i < N;i++){
        scanf("%d",&H[i]);
    }
    d = 0;
    for(i = 1;i < N;i++){
        if(H[i-1] >= H[i]) d++;
        else d = 0;
        if(max < d)max = d;
    }
    printf("%d",max);
	return 0;
}

Measured memory_bytes: 2112