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

namespace Atcoder {
    class Program {
        static void Main(string[] args) {
            //var N = int.Parse(Console.ReadLine());
            //var inputList = new List<int>();
            //foreach (var i in Enumerable.Range(0, N))
            //    inputList.Add(int.Parse(Console.ReadLine()));

            //var first = Console.ReadLine().ToCharArray();
            //var second = Console.ReadLine().ToCharArray();
            //var third = Console.ReadLine().ToCharArray();

            //Console.WriteLine("{0}{1}{2}",first[0],second[1],third[2]);

            var input = Console.ReadLine().Split(' ').Select(i => int.Parse(i));
            var min = input.First();
            var max = input.Last();

            var counter = 0;
            for(int i = min;i<= max; i++) {
                var str = i.ToString();
                if (str.Substring(0, 1) == str.Substring(4, 1) && str.Substring(1, 1) == str.Substring(3, 1))
                    counter++;
            }
            Console.WriteLine(counter);

            return;
        }
    }
}


Measured memory_bytes: 15440
#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    while(1){
        int x,y;
        scanf("%d %d",&x,&y);
        
        if(x==0 && y==0){
            break;
        }
        
        if(y<x){
            int t = x;
            x = y;
            y = t;
        }
        
        printf("%d %d\n",x,y);
    }
    return 0;
}

Measured memory_bytes: 600
#ifdef loc
    #include "loc_debug.h"
#else
    #include <bits/stdc++.h>
    #define pr(...)
    #define pra(a,n)
    #define praa(a,n,m)
    #define prl()
#endif
using namespace std;

typedef long long ll;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define sz(a) int(a.size())
const int N = 1005;

bool a[N][N];
bool vis[N][N];

int h, w;

bool legit(int x, int y) {
    return x >= 0 && x < h && y >= 0 && y < w;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> h >> w;
    rep(i, 0, h) {
        string s;
        s.reserve(N);
        cin >> s;
        rep(j, 0, w) {
            if(s[j] == '.') {
                a[i][j] = 1;
            }
        }
    }
    int steps = 0;
    vector<pair<int, int>> nx;
    int dirx[] = {0, 1, 0, -1};
    int diry[] = {1, 0, -1, 0};
    rep(i, 0, h) {
        rep(j, 0, w) {
            if(!a[i][j]) {
                rep(k, 0, 4) {
                    int ni = i + dirx[k];
                    int nj = j + diry[k];
                    if(legit(ni, nj) && a[ni][nj] && (!vis[ni][nj])) {
                        vis[ni][nj] = 1;
                        nx.emplace_back(make_pair(ni, nj));
                    }
                }
            }
        }
    }
    while(nx.size() > 0) {
        steps++;
        vector<pair<int, int>> cur;
        for(auto&& it : nx) {
            a[it.first][it.second] = 0;
        }
        for(auto&& it : nx) {
            rep(k, 0, 4) {
                int ni = it.first + dirx[k];
                int nj = it.second + diry[k];
                if(legit(ni, nj) && a[ni][nj] && (!vis[ni][nj])) {
                    vis[ni][nj] = 1;
                    cur.emplace_back(make_pair(ni, nj));
                }
            }
        }
        swap(nx, cur);
    }
    cout << steps << endl;
}

Measured memory_bytes: 12140
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll computeXOR(const ll n) 
{   
    switch(n % 4)  
    { 
      case 0: return n;     // if n is multiple of 4 
      case 1: return 1;     // If n % 4 gives remainder 1   
      case 2: return n + 1; // If n % 4 gives remainder 2     
      case 3: return 0;     // If n % 4 gives remainder 3   
    } 
} 

int main()
{
	ll A,B;
    cin >> A >> B;
    if(!A){
    	if(!B) cout << 0 << endl;
      	else cout << computeXOR(B) << endl;
    }else{
    	cout << (ll)(computeXOR(B)^computeXOR(A-1)) << endl;
    }
  	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
//#include <tuple>

//#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

int main() {
  int N, t, h, cnt = 0;
  cin >> N >> t;

  for (int i = 0; i < N; i++) {
    cin >> h;
    if (t <= h) cnt++;
  }
  
  cout << cnt << endl;

}


Measured memory_bytes: 256
N = int(input())
D = [[0, 0, 0]] + [list(map(int, input().split())) for _ in range(N)]
for i in range(1, N + 1):
  t = D[i][0] - D[i - 1][0]
  d = D[i][1] - D[i - 1][1] + D[i][2] - D[i - 1][2]
  if (t < d) or (t % 2 != d % 2):
    print('No')
    break
else:
  print('Yes')

Measured memory_bytes: 28068
#include <iostream>
#include <string>
#include <utility>
#include <math.h>
#include <algorithm>
using namespace std;
using ll=long long;
ll gcd(ll a,ll b){return (b==0?a:gcd(b,a%b));}
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,n) for(int i=a;i<n;i++)


int main (){
    string s;
    int cnt;
    cin >> s;
    rep(i,6){
        if(s[i] == '1'){
            cnt++;
        }
    }

    cout << cnt << endl;

}

Measured memory_bytes: 256
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,ssse3,popcnt,sse4.1,sse4.2,sse4a,sse4,tune=native")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
//using arr = array;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vpi = vector<pi>;
using ld = long double;
const int maxn = 3*2069;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int dp[maxn][2*maxn], n, mod, ans = 0;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> mod;
	dp[0][maxn] = 1;
	for(int i = 0; i <= 3*n; i++) {
		for(int j = maxn-3*n; j <= maxn+3*n; j++) {
			dp[i+1][j+1] += dp[i][j];
			if(dp[i+1][j+1] >= mod) dp[i+1][j+1] -= mod;
			
			dp[i+2][j-1] += dp[i][j]*1ll*(i+1)%mod;
			if(dp[i+2][j-1] >= mod) dp[i+2][j-1] -= mod;
			
			dp[i+3][j] += (dp[i][j]*1ll*(i+1)%mod)*1ll*(i+2)%mod;
			if(dp[i+3][j] >= mod) dp[i+3][j] -= mod;
		}
	}
	int ans = 0;
	for(int i = maxn; i <= maxn+3*n; i++) {
		ans += dp[3*n][i];
		if(ans >= mod) ans -= mod;
	}
	cout << ans;
}


Measured memory_bytes: 293120
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main
{
    public static void process(int test_number)throws IOException
    {
        int k = ni();

        long res = 0l, num = 0l;

        if(k % 2 == 0 || k % 5 == 0){
            pn(-1);
        }
        else{
            boolean flag = true;

            for(res = 1l ; flag; res++){
                num = (num * 10l + 7l) % k;

                if(num == 0)
                    flag = false;
            }

            pn(res - 1);
        }
    }
 
    static final long mod = (long)1e9+7l;
    
    static FastReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc = new FastReader();
 
        long s = System.currentTimeMillis();
        int t = 1;
        //t = ni();
        for(int i = 1; i <= t; i++)
            process(i);
 
        out.flush();
        System.err.println(System.currentTimeMillis()-s+"ms");
    }

    static void trace(Object... o){ System.err.println(Arrays.deepToString(o)); };
    static void pn(Object o){ out.println(o); }
    static void p(Object o){ out.print(o); }
    static int ni()throws IOException{ return Integer.parseInt(sc.next()); }
    static long nl()throws IOException{ return Long.parseLong(sc.next()); }
    static double nd()throws IOException{ return Double.parseDouble(sc.next()); }
    static String nln()throws IOException{ return sc.nextLine(); }
    static long gcd(long a, long b)throws IOException{ return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{ return (b==0)?a:gcd(b,a%b); }
    static int bit(long n)throws IOException{ return (n==0)?0:(1+bit(n&(n-1))); }
    
    static class FastReader{ 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader(){ 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next(){ 
            while (st == null || !st.hasMoreElements()){ 
                try{ st = new StringTokenizer(br.readLine()); } catch (IOException  e){ e.printStackTrace(); } 
            } 
            return st.nextToken(); 
        } 
  
        String nextLine(){ 
            String str = ""; 
            try{ str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } 
            return str; 
        } 
    } 
}


Measured memory_bytes: 36692
using System;

    namespace b
    {
        class Program
        {
            static void Main(string[] args)
            {
                var n = int.Parse(Console.ReadLine());

                var f = false;
                for(var i = 0; i <= n / 4; i++){
                    for(var j = 0; j <= n / 7; j++){
                        if(4 * i + 7 * j == n){
                            f = true;
                        }
                    }
                }

                Console.WriteLine(f ? "Yes" : "No");
            }
        }
    }


Measured memory_bytes: 13140
#include <iostream>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
int main(void){
   long N;
   cin>>N;
   
   long num[N+1]; long count[N+1];
   for(int i=1;i<=N;i++){
       num[i]=i; count[i]=1;
   }
   long divis=0;
   for(int i=2;i<=N;i++){
      divis=num[i];
      if(divis!=1){
      for(int j=2;j<=N;j++){
         if(num[j]%divis==0) {num[j]=num[j]/divis; count[divis]++;}
      }
      }
   }
   long sum=1;
   for(int i=1;i<=N;i++){
       sum=sum*count[i]%1000000007;
   }
   cout<<sum;
   return 0;
}


Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
const ll MAX = 3100;
ll d[MAX][MAX][4]={};
ll g[MAX][MAX]={};
signed main(){
  init_io();
  ll R,C,K;
  cin >> R>> C >> K;
  vector<ll> r(K),c(K),v(K);
  priority_queue<TP> que;
  for(int i=0;i<K;i++){
    cin >> r[i] >> c[i] >> v[i];
    r[i]--;
    c[i]--;
    g[r[i]][c[i]] = v[i];
  }
  for(int i=0;i<MAX;i++){
    for(int j=0;j<MAX;j++){
      for(int l=0;l<4;l++){
        d[i][j][l] = -1e5;
      }
    }
  }
  ll ans = 0;
  d[0][0][0] = 0;
  d[0][0][1] = g[0][0];
  for(int i=0;i<R;i++){
    for(int j=0;j<C;j++){
      if(i!=0){
        for(int l=0;l<4;l++){
          d[i][j][0] = max(d[i][j][0],d[i-1][j][l]);
          d[i][j][1] = max(d[i][j][0],d[i-1][j][l]+g[i][j]);
        }
      }
      if(j!=0){
        for(int l=0;l<4;l++){
          d[i][j][l] = max(d[i][j][l],d[i][j-1][l]);
          if(l!=3){
            d[i][j][l+1] = max(d[i][j][l+1],d[i][j-1][l]+g[i][j]);
          }
        }
      }
      for(int l=0;l<4;l++){
        if(l!=0){
          d[i][j][l] = max(d[i][j][l],d[i][j][l-1]);
        }
      }
    }
  }
  for(int i=0;i<4;i++){
    ans = max(d[R-1][C-1][i],ans);
  }
  cout << ans << endl;
}


Measured memory_bytes: 380920
#include<stdio.h>

int partition_d(int a[], int l, int r){
	int i, j, pivot, t;

	i = l-1;
	j = r;
	pivot = a[(l+r)/2];
	t = a[r];
	a[r] = a[(l+r)/2];
	a[(l+r)/2] = t;


	for(;;){
		while(a[++i] > pivot){
			;
		}
		while(i < --j && pivot > a[j]){
			;
		}
		if(i >= j){
			break;
		}
		t = a[i];
		a[i] = a[j];
		a[j] = t;
	}
	t = a[i];
	a[i] = a[r];
	a[r] = t;

	return i;
}

void quick_sort_d(int a[], int l, int r){
	int v;

	if(l >= r){
		return;
	}

	v = partition_d(a, l, r);
	quick_sort_d(a, l, v-1);
	quick_sort_d(a, v+1, r);
}

int main(){
	int x, y, a, b, c;
	int r[100005] = {0}, g[100005] = {0}, n[100005] = {0};
	int i, cnt;
	long long ans = 0;

	scanf("%d %d %d %d %d", &x, &y, &a, &b, &c);
	for(i=0; i<a; i++){
		scanf("%d", r+i);
	}
	for(i=0; i<b; i++){
		scanf("%d", g+i);
	}
	for(i=0; i<c; i++){
		scanf("%d", n+i);
	}

	quick_sort_d(r, 0, a-1);
	quick_sort_d(g, 0, b-1);
	quick_sort_d(n, 0, c-1);

	int r_j = 0, g_j = 0, n_j = 0;
	r[x] = -1;
	g[y] = -1;
	n[c] = -1;
	for(cnt=0; cnt<x+y; cnt++){
		if(r[r_j] > g[g_j]){
			if(r[r_j] > n[n_j]){
				ans += r[r_j];
				r_j++;
			}else{
				ans += n[n_j];
				n_j++;
			}
		}else{
			if(g[g_j] > n[n_j]){
				ans += g[g_j];
				g_j++;
			}else{
				ans += n[n_j];
				n_j++;
			}
		}
	}

	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 1280
import sys
e=list(map(int,sys.stdin))
m=max(e)+1;a=[1]*m;a[0:2]=0,0
for i in range(2,int(m**.5)+1):
 if a[i]>0:
  for j in range(i*2,m,i):a[j]=0
for i in range(m):a[i]+=a[i-1]
for x in e:print(a[x])


Measured memory_bytes: 45124
#include <stdio.h>

#define M 10000

int main(){
  int n,q,i,j,S[M],T,res = 0;
  scanf("%d",&n);
  for(i = 0 ; i < n ; i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i = 0 ; i < q ; i++){
    scanf("%d",&T);
    for(j = 0 ; j < n ; j++){
      if(T == S[j]){
        ++res;
        break;
      }
    }
  }
  printf("%d\n",res);
  return 0;
}


Measured memory_bytes: 2080
#include <iostream>
#include <string>
using namespace std;
 
int main () {
    string a,b,c;
    cin >> a >> b >> c;
    if (a[a.size()-1] == b[0] && b[b.size()-1] == c[0]){
    	cout << "YES" << endl;
    }else{
    	cout << "NO" << endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	unsigned long long A, B, C;
	cin >> A >> B >> C;
	if(C > A+B && C*C + A*A + B*B > 2*A*C + 2*B*C + 2*A*B)
		cout << "Yes\n";
	else
		cout << "No\n";
}
	


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s: String = read();
    let u: String = s.chars().map(|_| 'x').collect();
    println!("{}", u);
}


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

using namespace std;
const int INF = 1e9;


int main(){
  int N, M;
  vector<int> as(3);
  cin >> N >> M >> as[0] >> as[1] >> as[2];
  vector<vector<int>> G(N);
  for(int i=0;i<M;++i){
	int u, v; cin >> u >> v;
	--u, --v;
	G[u].push_back(v);
  }

  vector<set<int>> memo[3];
  for(int k=0;k<3;++k)
	for(int i=0;i<N;++i){
	  set<int> buf[2];
	  int crt = 0, nxt = 1;
	  buf[crt].insert(i);
	  for(int n=0;n<as[k];++n){
		buf[nxt].clear();
		for(int x: buf[crt])
		  for(int to: G[x])
			buf[nxt].insert(to);
		swap(crt, nxt);
	  }
	  memo[k].push_back(buf[crt]);
	}

  vector<int> dist(N, INF);
  dist[N-1] = 0;
  for(int i=0;i<N;++i){
	for(int j=0;j<N;++j){
	  int prv = dist[j];
	  dist[j] = 0;
	  for(int k=0;k<3;++k){
		int tmp = INF;
		for(int x: memo[k][j])
		  if(x != j)
			tmp = min(tmp, dist[x]+1);
		dist[j] = max(dist[j], tmp);
	  }
	  dist[j] = min(dist[j], prv);
	}
  }

  //for(int i=0;i<N;++i) cout << i << " " << dist[i] << endl;
  if(dist[0] >= INF || dist[0] < 0)
	cout << "IMPOSSIBLE" << endl;
  else
	cout << dist[0] << endl;

  return 0;
}

Measured memory_bytes: 3520
#include <stdio.h>
#include <iostream>
#include <vector>
#include <set>
#include <string>
 
using namespace std;
 
int main(int argc, char** argv) {
  int a, b;
  cin >> a >> b;
  set<int> s;
  s.insert(a);
  s.insert(b);
  for (int i = 1; i <= 3; ++i) {
    if (s.find(i) == s.end()) {
      cout << i << endl;
    }
  }
  
  return 0;
}

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

int main(){
    ll D;
    cin >> D;
    vector<ll> c(26), t(D), last(26, -1);
    vector< vector<ll> > s(365, vector<ll> (26));
    rep(i, 0, 26) cin >> c[i];
    rep(i, 0, D){
        rep(j, 0, 26) cin >> s[i][j];
    }
    srand((unsigned int)time(NULL));
    rep(i, 0, D){
        t[i] = (ll) (rand() % 26);
    }
    ll M = 1e6;
    vector<ll> rec(26, 0);
    /*
    vector<ll> d(M), q(M), rec(26, 0);
    rep(i, 0, M){
        d[i] = (ll) (rand() % D);
        q[i] = (ll) (rand() % 26);
    }
    */
    ll res = 0;
    rep(d, 0, D){
        res += s[d][t[d]];
        last[t[d]] = d;
        rep(j, 0, 26) {
            res -= c[j] * (d - last[j]);
            rec[j] += c[j] * (d - last[j]);
        }
    }
    vector<ll> median(D);
    rep(i, 0, D){
        auto cp = s[i];
        sort(cp.begin(), cp.end());
        median[i] = cp[20];
    }
    ll rec_sum = 0;
    rep(i, 0, 26) rec_sum += rec[i]; 
    // t[d[m]] := 0 - 25
    rep(m, 0, M){
        ll prev_res = res;
        // ll d = (ll) (rand() % D);
        ll d = m % D;
        ll q = (ll) (rand() % 26);
        // ll q = m % 26;
        if(rec[q] < c[q] * 100) continue; 
        if(s[d][q] < median[min(23LL, 13 * m / M + 13)]) continue;
        res -= s[d][t[d]];
        res += s[d][q];
        res += rec[t[d]];
        res += rec[q];
        ll tdrec = 0, qrec = 0;
        ll lst = -1;
        rep(i, 0, D){
            if(i != d && t[i] == t[d]){
                lst = i;
            }
            res -= c[t[d]] * (i - lst);
            // rec[t[d[m]]] +=  c[t[d[m]]] * (i - lst);
            tdrec +=  c[t[d]] * (i - lst);
        }
        lst = -1;
        rep(i, 0, D){
            if(i == d || t[i] == q){
                lst = i;
            }
            res -= c[q] * (i - lst);
            // rec[q[m]] += c[q[m]] * (i - lst);
            qrec += c[q] * (i - lst);
        }
        if(res > prev_res){
            rec_sum -= rec[t[d]];
            rec_sum += tdrec;
            rec_sum -= rec[q];
            rec_sum += qrec;
            rec[t[d]] = tdrec;
            rec[q] = qrec;
            t[d] = q;
        }else{
            res = prev_res;
        }
        // cout << res << endl;
    }
    rep(i, 0, D) cout << t[i]+1 << endl;
    return 0;
}

Measured memory_bytes: 3724
#include<iostream> 
#include<string>
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
int main(){	
    int n,m;
	cin>>n>>m;
	int a[n][m];
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			a[i][j]=-1;
		}
	}
	char s[n][m];
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>s[i][j];
		}
	}
	queue<pair<int,int> > q;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(s[i][j]=='#'){
				q.push(mp(i,j));
				a[i][j]=0;
			}
		}
	}
	while(!q.empty()){
		int x=q.front().first,y=q.front().second;
		q.pop();
		if(x+1<n&&a[x+1][y]==-1){
			q.push(mp(x+1,y));
		   	a[x+1][y]=a[x][y]+1;
		}
		if(x-1>=0&&a[x-1][y]==-1){
			q.push(mp(x-1,y));
		   	a[x-1][y]=a[x][y]+1;
		}
		if(y+1<m&&a[x][y+1]==-1){
			q.push(mp(x,y+1));
		   	a[x][y+1]=a[x][y]+1;
		}
		if(y-1>=0&&a[x][y-1]==-1){
			q.push(mp(x,y-1));
		   	a[x][y-1]=a[x][y]+1;
		}
	}
	int ans=-1;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			ans=max(ans,a[i][j]);
		}
	}
	cout<<ans<<endl;
    return 0;
} 

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n; cin >> n;
  vector<int> x(n);
  vector<int> y(n);
  for (int i = 0; i < n; i++) cin >> x[i] >> y[i];
  double s = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      s += sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2));
    }
  }
  cout << setprecision(7) << s / n << '\n';
  return 0;
}

Measured memory_bytes: 256
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func reverse(s string) string {
	b := []byte(s)
	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
		b[i], b[j] = b[j], b[i]
	}
	return string(b)
}

func main() {
	defer stdout.Flush()

	s := readString()
	t := readString()

	rsb := []byte(reverse(s))
	rtb := []byte(reverse(t))

	var ans []string
	for i := 0; i+len(rtb) <= len(rsb); i++ {
		matched := true
		for j := 0; j < len(rtb); j++ {
			if rsb[i+j] != '?' && rsb[i+j] != rtb[j] {
				matched = false
				break
			}
		}
		if matched {
			b := append(rsb[0:i], rtb...)
			b = append(b, rsb[i+len(rtb):]...)
			ans = append(ans, strings.Replace(reverse(string(b)), "?", "a", -1))
		}
	}
	if len(ans) == 0 {
		println("UNRESTORABLE")
		return
	}
	sort.Strings(ans)
	println(ans[0])

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string S;
  int i, j, k;
  int I, J, K;
  cin >> S;


  for(k=0; k<S.length() - 1; k++){
    K = S.length() - 1 - k;
    if(S.at(k) != S.at(K)){
      cout << "No" << endl;
      return 0;
    }
  }

  
  for(i=0; i<((S.length() - 1) / 2); i++){
    I = (S.length() - 1) / 2 - 1 - i;
    if(S.at(i) == S.at(I)){
    }else{
      cout << "No" << endl;
      return 0;
    }
  }

  J = 0;
  for(j=((S.length() + 3) / 2 - 1); j<(((S.length() + 3) / 2 - 1) + S.length()) /2 ; j++){
    J += 1;
    if(S.at(j) != S.at(S.length() - J)){
      cout << "No" << endl;
      return 0;
    }
  }
  
  
  cout << "Yes" << endl;
}

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

public class Main {

	public static void main(String[] args) throws Exception{
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		String str[] = r.readLine().split(" ");
		int max = Integer.parseInt(str[0]);
		Queue q = new Queue(max);
		int qtime = Integer.parseInt(str[1]);

		for(int i = 0 ; i < max ; i++ ){
			str = r.readLine().split(" ");
			q.enqueue(new Process(str[0], Integer.parseInt(str[1])));
		}

		int elapsedTime = 0;

		int count = 0;
		//?????\?????¬????????§???
		while(true){
			if(max <= count) break;
			Process p = q.dequeue();
			int time = p.getTime();

			if(time <= qtime){
				elapsedTime+= time;
				count++;
				System.out.println(p.getName() +" "+elapsedTime);
			}else{
				p.setTime(time - qtime);
				elapsedTime += qtime;
				q.enqueue(p);
			}

		}
	}

}

class Queue{

	Process[] processAry;
	int top;
	int tail;
	int max;

	public Queue(int max){
		top = tail = 0;
		processAry = new Process[max];
		this.max = max;
	}

	public void enqueue(Process process) throws Exception{
			processAry[top] = process;
			top = (top + 1) % max;
	}

	public Process dequeue() throws Exception{

			Process p = processAry[tail];
			tail = (tail + 1) % max;
			return p;

	}

}

class Process{
	private String name;
	private int time;

	public Process(String name,int time) {
		this.name = name;
		this.time = time;
	}

	public String getName() {
		return name;
	}

	public int getTime() {
		return time;
	}

	public void setTime(int time) {
		this.time = time;
	}

}

Measured memory_bytes: 59296
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

class CGreenBin {
public:
void solve(std::istream& cin, std::ostream& cout) {
    int n;
    cin >> n;
    vector<string> S(n);
    for (auto &s: S) cin >> s;

    map<string, int> count;

    for (auto &s: S){
        sort(s.begin(), s.end());
        count[s]++;
    }

    int64_t ans = 0;
    for (const auto &c: count)
        ans += c.second * (c.second - 1LL) / 2;

    cout << ans << endl;
}
};

int main() {
	CGreenBin solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 18176
#include<stdio.h> 
  
int main(){ 
  int tab[101][3]; 
  int n,a,b,c,d,e,i,j,k,m,t,max,mx,cnt,cn; 
  for(i=0;i<101;i++){ 
    tab[i][0]=0; 
    tab[i][1]=i; 
    tab[i][2]=0; 
  } 
  scanf("%d",&n); 
  m=n*(n-1)/2; 
  for(k=0;k<m;k++){ 
    scanf("%d %d %d %d",&a,&b,&c,&d); 
    if(c>d){ 
      tab[a][0]+=3; 
    }else if(c<d){ 
      tab[b][0]+=3; 
    }else if(c==d){ 
      tab[a][0]++; 
      tab[b][0]++; 
    } 
  } 
  //for(i=1;i<=n;i++)printf("%d\n",tab[i][0]); 
  for(i=n;i>0;i--){ 
    for(j=1;j<i;j++){ 
      if(tab[j][0]<tab[j+1][0]){ 
    t=tab[j][0]; 
    tab[j][0]=tab[j+1][0]; 
    tab[j+1][0]=t; 
  
    t=tab[j][1]; 
    tab[j][1]=tab[j+1][1]; 
    tab[j+1][1]=t; 
      } 
    } 
  } 
  cnt=1; 
  cn=1; 
  //for(i=1;i<=n;i++)printf("%d %d\n",tab[i][0],tab[i][1]); 
  t=tab[1][0]; 
  tab[1][2]=cnt; 
  for(i=2;i<=n;i++){ 
    if(tab[i][0]==t){ 
      tab[i][2]=cnt; 
      cn++; 
    }else{ 
      cnt+=cn; 
      cn=1; 
      t=tab[i][0]; 
      tab[i][2]=cnt; 
    } 
      
  } 
  
  //for(i=1;i<=n;i++)printf("%d %d\n",tab[i][0],tab[i][2]); 
  
  for(i=n;i>0;i--){ 
    for(j=1;j<i;j++){ 
      if(tab[j][1]>tab[j+1][1]){ 
    t=tab[j][2]; 
    tab[j][2]=tab[j+1][2]; 
    tab[j+1][2]=t; 
      
    t=tab[j][1]; 
    tab[j][1]=tab[j+1][1]; 
    tab[j+1][1]=t; 
      } 
    } 
  } 
  for(i=1;i<=n;i++)printf("%d\n",tab[i][2]); 
  return 0; 
} 

Measured memory_bytes: 1028
N = int(input())
P = [[0 for _ in range(N)] for _ in range(N)] 
for i in range(N):
    u,k,*varray = map(int,input().split()) # u,k は数, varray は配列
    for v in varray:
        P[u-1][v-1] = 1
for j in P:
    print(" ".join(map(str,j)))        


Measured memory_bytes: 5676
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(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 ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    ll a[3];
    REP(i,3) cin >> a[i];
    ll k;
    cin >> k;
    sort(a, a+3);
    a[2] <<= k;
    cout << a[0] + a[1] + a[2] << endl;
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
X = list(map(int, input().split()))

X.sort()

d_X = [X[i+1] - X[i] for i in range(M-1)]
d_X.sort()

if N >= M:
  ans = 0
else:
  ans = sum(d_X[0:M-N])

print(ans)

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

using namespace std;

int main() {
  
  while(1) {
    string name; int a, b;
    if(!(cin >> name >> a >> b)) break;
    cout << name << ' ' << a+b << ' ' << a*200 + b*300 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
#if 1
#define int long long
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define stoi stoll
#else
#define MAX INT_MAX
#define MIN INT_MIN
#endif
#define INF MAX/2
#define ALL(obj) (obj).begin(), (obj).end()
#define fi first
#define se second
const int NIL = -1;
const int MOD = 1000000007;
#define REP(i,n) for (int (i)=0; (i) < (n); ++(i))
#define FOR(i,a,b) for (int (i)=(a); (i) < (b); ++(i))
using namespace std;

int pow(int x, int n) {int res=1; while(n){if(n&1)res*=x;x*=x;n>>=1;} return res;}
int get_gcd(int a, int b) {while(1){if (a < b) swap(a, b); if (b == 0) return a; a %= b;}}
int get_lcm(int a, int b) {return a * b / get_gcd(a, b);}
bool chmin(int &a, int b) {if(a>b){a=b; return true;} else return false;}
bool chmax(int &a, int b) {if(a<b){a=b; return true;} else return false;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//-------------------------テンプレここまで-------------------------//

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

  int r;
  cin >> r;
  cout << r*r << endl;

  return 0;
}


Measured memory_bytes: 256
a = int(input())
sum = a*(a+1)/2
b = a//3
c = a//5
d = a//15

sum3 = 3*b*(b+1)/2
sum5 = 5*c*(c+1)/2
sum15 = 15*d*(d+1)/2

sum = sum - sum3 - sum5 + sum15
print(int(sum))

Measured memory_bytes: 9060
n = int(input())
a = list(map(int, input().split()))
x = max(a)
r = 0
num = x//2
diff = float("inf")
for i in range(n):
    dif = abs(num - a[i])
    if dif < diff and a[i] != x:
        diff = dif
        r = a[i]
print(x, r)

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

public class Main {
    public static void main(String[] args) {
        FastScanner fs = new FastScanner();

        int x = (int)fs.nextLong();
        int n = (int)fs.nextLong();
        int ans=x;

        // int[] p=new int[n];
        // p=Arrays.fill(p, (int)fs.next());

        ArrayList<Integer> p = new ArrayList<Integer> ();
        for (int i = 0; i < n; i++) p.add((int) fs.nextLong());

        for (int i = 0;; i++) {
            if(!p.contains(ans-i) || !p.contains(ans+i)) {
                System.out.println((!p.contains(ans-i)) ? ans-i : ans+i);
                break;
            }
        }
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

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

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(final int c) {
        return 33 <= c && c <= 126;
    }

    private void skipUnprintable() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
    }

    public boolean hasNext() {
        skipUnprintable();
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        final StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b)
            throw new NumberFormatException();
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b))
                return minus ? -n : n;
            else
                throw new NumberFormatException();
            b = readByte();
        }
    }
}

Measured memory_bytes: 32512
#include<stdio.h>

#define MAX 100
#define INFTY 100000
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[MAX][MAX];

int prim()
{
  int i, u, v, minv, sum;
  int d[MAX], p[MAX], color[MAX];

  for( i=0; i<n; i++ )
    {
      d[i] = INFTY;
      p[i] = -1;
      color[i] = WHITE;
    }

  d[0] = 0;

  while(1)
    {
      minv = INFTY;
      u = -1;
      for( i=0; i<n; i++ )
	{
	  if( minv > d[i] && color[i] != BLACK )
	    {
	      u = i;
	      minv = d[i];
	    }
	}
      if( u == -1 ) break;
      color[u] = BLACK;
      for( v=0; v<n; v++ )
	{
	  if( color[v] != BLACK && M[u][v] != INFTY )
	    {
	      if( d[v] > M[u][v] )
		{
		  d[v] = M[u][v];
		  p[v] = u;
		  color[v] = GRAY;
		}
	    }
	}
    }

  sum = 0;
  for( i=0; i<n; i++ )
    {
      if( p[i] != -1 ) sum += M[i][p[i]];
    }

  return sum;
}


int main()
{
  int i, j, x;
  
  scanf("%d", &n);

  for( i=0; i<n; i++ )
    {
      for( j=0; j<n; j++ )
	{
	  scanf("%d", &x);
	  if( x == -1 )
	    {
	      M[i][j] = INFTY;
	      continue;
	    }
	  M[i][j] = x;
	}
    }

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

  return 0;
}



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

using namespace std;

int main(){
   int N,K;
   cin >> N >> K;
   long count = 0;
   long H[N];
   for(int i = 0;i < N;i++)cin >> H[i];

   sort(H,H+N);
   reverse(H,H+N);

   for(int j = 0;j < K;j++){
     if(N > j)
      H[j] = 0;
   }

   for(int x = 0;x < N;x++){
     count += H[x];
   }

   cout << count;

  return 0;
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] l = Console.ReadLine().Split();
            int[] b = new int[3];
            for (int i = 0; i < 3; i++) { b[i] = int.Parse(l[i]); }
            int an = b.Max() - b.Min();
            Console.Write(an);
        }
    }
}

Measured memory_bytes: 11220
import sys
input = sys.stdin.readline
M = 10**5

n = int(input())
G = [[] for _ in range(2*M+1)]
for _ in range(n):
  x, y = map(int, input().split())
  G[x].append(y+M)
  G[y+M].append(x)
seen = [False]*(2*M+1)
def dfs(v):
  stack = [v]
  seen[v] = True
  cnt_x, cnt_y = 0, 0
  while stack:
    v = stack.pop()
    if v <= M:
      cnt_x += 1
    else:
      cnt_y += 1
    for nv in G[v]:
      if seen[nv]:
        continue
      seen[nv] = True
      stack.append(nv)
  return cnt_x*cnt_y
ans = 0
for i in range(2*M+1):
  if not seen[i]:
    ans += dfs(i)
ans -= n
print(ans)

Measured memory_bytes: 94940
#include <bits/stdc++.h>
using namespace std;
int N,T,c,t;
int ans = 1000000;
int main(){
    cin >> N >> T;
    for(int i = 0; i < N; i++){
           cin >> c >> t;
           if(t <= T){
               ans = min(ans,c);
           }
    }
    if(ans == 1000000){
        cout << "TLE" << endl;
    }else{
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define MAX_N 100000
#define INF 100000000
#define MOD 1000000007
#define RANK 1000000000
#define EPS 1e-10
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> IP;

ll x, y;

int main(){
    cin >> x >> y;
    if(x == y){
        cout << 0 << endl;
        return 0;
    }
    if(x == 0){
        if(y > 0) cout << y << endl;
        else cout << abs(y)+1 << endl;
        return 0;
    }
    if(y == 0){
        if(x > 0) cout << x+1 << endl;
        else cout << abs(x) << endl;
        return 0;
    }
    ll ans = 0;
    if(x > 0 && y > 0){
        if(x > y){
            cout << x-y+2 << endl;
        } else{
            cout << y-x << endl;
        }
    } else if(x > 0 && y < 0){
        if(x == -1*y){
            cout << 1 << endl;
        } else if(x > -1*y){
            cout << x-(-1)*y+1 << endl;
        } else{
            cout << -1*y-x+1 << endl;
        }
    } else if(x < 0 && y > 0){
        if(-1*x == y){
            cout << 1 << endl;
        } else if(-1*x > y){
            cout << -1*x-y+1 << endl;
        } else{
            cout << y-(-1)*x+1 << endl;
        }
    } else{
        if(y > x){
            cout << y-x << endl;
        } else{
            cout << x-y+2 << endl;
        }
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int A,B,C,D;
    bool win = 0;
    cin >> A >> B >> C >> D;
    while(1){
        C -= B;
        if(C <= 0){
            win = 1;
            break;
        }
        A -= D;
        if(A <= 0){
            win = 0;
            break;
        }
    }
    cout << (win ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int main() {
    int n;
    cin >> n;
    long long ans = 0;
    map<long long, long long> f;
    long long st[10]{1};
    for (int i = 1; i < 10; ++i)
        st[i] = st[i - 1] * 30;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        long long h = 0;
        sort(s.begin(), s.end());
        for (int i = 0; i < s.size(); ++i) {
            h += (s[i] - 'a') * st[i];
        }
        ++f[h];
    }
    for (auto x : f)
        ans += x.second * (x.second - 1) / 2;
    cout << ans << '\n';
    return 0;
    return 0;
}


Measured memory_bytes: 6528
//============================================================================
// Name        : ATcoder.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cctype>
#include <string>
#include<algorithm>
using namespace std;
typedef long long ll;
int main() {

	int a,b,c;
	cin>>a>>b>>c;

	if((b-a)==(c-b)){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}

	return 0;
}


Measured memory_bytes: 256
/*
 * Click `Run` to execute the snippet below!
 */

import java.io.*;
import java.util.*;

/*
 * To execute Java, please define "static void main" on a class
 * named Solution.
 *
 * If you need more classes, simply define them inline.
 */

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int L[] = new int[N];
    for(int i = 0; i<N; i++){
      L[i] = sc.nextInt(); 
    }
    Arrays.sort(L);
    int S = 0;
    for(int i = 0; i<N-1; i++){
       S += L[i];
    }
    if(L[N-1] >= S){
      System.out.println("No"); 
    }
    else{
      System.out.println("Yes");
    }
  }
}





































Measured memory_bytes: 35672
n,m=map(int,input().split())
l=set([int(input()) for _ in range(m)])
mod=10**9+7
dp=[0]*(n+2)
dp[0]=1
if 1 not in l:
    dp[1]=1
else:
    dp[1]=0
for i in range(n-1):
    if i+2 in l:
        dp[i+2]=0
    elif i not in l and i+1 not in l:
        dp[i+2]=(dp[i+1]+dp[i])%mod
    elif i+1 not in l:
        dp[i+2]=dp[i+1]
    elif i not in l:
        dp[i+2]=dp[i]
    else:
        dp[i+2]=0
print(dp[n])
        
        
    



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

int main(){
  int h,w;
  cin >> h >> w;
  vector<string> a(h);
  for(int i=0;i<h;++i){
    cin >> a[i];
  }
  vector<bool> y(h,false),t(w,false);
  for(int i=0;i<h;++i){
    for(int j=0;j<w;++j){
      if(a[i][j]=='#'){
        y[i]=true;
        t[j]=true;
      }
    }
  }

  for(int i=0;i<h;++i){
    if(y[i]==true){
      for(int j=0;j<w;++j){
        if(t[j]==true) cout << a[i][j];
      }
      cout << endl;
    }
  }
  return 0;
}


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

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

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


void calc_primefactorization(long long in, vector<vector<long long> >& out){
	
	long long N = in, Ntmp;
	long long p,e,p_init = 2;
	vector<long long> out_tmp(2);
	
	if( in == 1 ){
		out_tmp[0] = 1;
		out_tmp[1] = 1;
	}
	else{
		while( 1 ){

			Ntmp = N;
				
			p = N;
			e = 1;

			for(long long i = p_init;i * i <= N;i++){
						
				if( Ntmp % i == 0 ){
					e = 0;
					while( 1 ){
						if( Ntmp % i != 0 ){
							break;
						}
						else{
							Ntmp = Ntmp / i;
							e++;
						}
					}
					p = i;
					break;
				}
				
			}
			
			out_tmp[0] = p;
			out_tmp[1] = e;
			out.push_back(out_tmp);
			
			for(int i = 0;i < e;i++){
				N = N / p;
			}
			
			if( N == 1 ){
				break;
			}
			
		}
	}
	
}

int bitmask(int n){
	
	int a = 1;
	
	return ( a << (n - 1) );
	
}


int main(){
	
	int A, B, C, K;
	
	cin >> A >> B >> C;
	cin >> K;
	
	//A : red
	//B : green
	//C : blue
	
	bool judge = false;
	
	for(int k = 0;k < K;k++){
		
		if( (C > B) && (B > A) ){
			judge = true;
			break;
		}
		
		if( C <= B ){
			C = C * 2;
		}
		else if( B <= A ){
			B = B * 2;
		}
		
		if( (C > B) && (B > A) ){
			judge = true;
			break;
		}
		
		//cout << k << " " << A << " " << B << " " << C << endl;
		
	}
	
	if( judge ){
		cout << "Yes";
	}
	else{
		cout << "No";
	}
	
	return 0;
	
}


Measured memory_bytes: 3628
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;



public class Main{
	
	//最大公約数・最小公倍数（セットで使う）
	public static long gcm(long a, long b) {
		long result = a;
		long k = 0;
		long n = b;
		do {
			k = result % n;
			result = n;
			n = k;
		} while(k != 0);
		return result;
	}
	
	public static long lcm(long a, long b) {
		long g;
		g = gcm(a, b);
		return a/g*b;
	}
	
	static long gcd (long a, long b) {
		long temp;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return b;
	}
	
	//等差数列
	static long tousasum(int n) {
		return (long)n*((long)n+1)/2;
	}



	//素数判定
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
		return true;
	}


	//倍数判定（10進数以外のときに有用）
	static boolean isMultiple (String s, int base, int m) {
		int temp = 0;
		for (int i=0; i<s.length(); i++) {
			temp = (temp*base+Character.getNumericValue(s.charAt(i)))%m;
		}
		if (temp==0) {return true;}
		return false;
	}


	//階乗
	static long factorial (int i) {
		if (i==1) {return 1;}
		else {return i*factorial(i-1);}
	}


	//進数変換
	static String toNbase (String sm, int m, int n) {
		return Long.toString(Long.parseLong(sm,m),n);
	}
	
	public static final long gcd_n(long[] param) {
	    final int len = param.length;
	    long g = gcd(param[0], param[1]);    //gcd(a, b) は以前作ったもの
	    for (int i = 1; i < len - 1; i++) {
	        g = gcd(g, param[i + 1]);       //gcd(a, b) は以前作ったもの
	    }
	    return g;
	}
	
	public static long lcm_n(long[] numbers) {
		long l;
		l = numbers[0];
		for (int i = 1; i < numbers.length; i++) {
			l = lcm(l, numbers[i]);
		}
		return l;
	}
	
	
 public static void main(String[] args) {
	 Scanner sc=new Scanner(System.in);
	 int N=sc.nextInt();
	 String[] s=new String[N];
	 Map<String,Integer> mp=new HashMap();
	 for(int i=0;i<N;i++) {
		 String temp=sc.next();
		 char[] tmp=temp.toCharArray();
		 Arrays.sort(tmp);
		 s[i]=String.valueOf(tmp);
		 if(mp.containsKey(s[i])) {
			 mp.put(s[i],mp.get(s[i])+1);
		 }else {
			 mp.put(s[i],0);
		 }
		 
		 
	 }
	 long result = 0;
	 
	 for(Integer val : mp.values()){
	     result+=tousasum(val);
	 }
	 
	 System.out.println(result);
	 
	 
	 
	
	 

	 
	 
	 
	 
	 
	 
	
	 
	 
	 
 }
	


}


Measured memory_bytes: 55688
#include<bits/stdc++.h>
using namespace std;
int main() {
    int A,B,T,a,b,t;
    cin >> A >> B >> T;
    t=0;
    b=0;
    while(1){
        a+=A;
        t+=a;
        if(t<=T){ b++;
                }else{
                break;
                }
    }
    cout << b*B << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
const int dy[] = {-1, 0, 0, 1}, dx[] = {0, -1, 1, 0};
 
int H, W;
string S[1000];
short dp[1000][1000][1 << 7];
 
bool isOver(int x, int y)
{
  return(x < 0 || y < 0 || x >= W || y >= H);
}
 
bool isPoyo(int x, int y)
{
  return(!isOver(x, y) && isdigit(S[y][x]));
}
 
inline int MvR(int used) // ???????§????
{
  return(28 | ((used >> 4) & 1)| (((used >> 2) & 3) << 5));
}
 
inline int MvD(int used)
{
  return(76 | (((used >> 6) & 1) << 1) | (((used >> 2) & 3) << 4));
}
 
int rec(int x, int y, int used)
{
  if(~dp[x][y][used]) return(dp[x][y][used]);
  if(x == W - 1 && y == H - 1) return(0);
  int bit = 0, cost = 0;
  for(int i = 0; i < 4; i++) {
    if(isPoyo(x + dx[i], y + dy[i]) & (used >> i)) {
      cost += S[y + dy[i]][x + dx[i]] - '0';
      bit |= 1 << i;
    }
  }
  int ret = INF, base = (isdigit(S[y][x]) & (used >> 5) ? S[y][x] - '0' : 0); 
  if(bit == 0) {
    if(x + 1 < W) ret = min(ret, rec(x + 1, y, MvR(used)) + cost);
    if(y + 1 < H) ret = min(ret, rec(x, y + 1, MvD(used)) + cost);
  } else {
    for(int i = 0; i < 4; i++) {
      if((bit >> i) & 1) {
        bit &= ~(1 << i);
        cost -= S[y + dy[i]][x + dx[i]] - '0';
        if(x + 1 < W) ret = min(ret, rec(x + 1, y, MvR(used & ~bit)) + cost);
        if(y + 1 < H) ret = min(ret, rec(x, y + 1, MvD(used & ~bit)) + cost);
        cost += S[y + dy[i]][x + dx[i]] - '0';
        bit |= (1 << i);
      }
    }
  }
  return(dp[x][y][used] = ret + base);
}
 
int main()
{
  memset(dp, -1, sizeof(dp));
 
  cin >> H >> W;
  for(int i = 0; i < H; i++) cin >> S[i];
  cout << rec(0, 0, (1 << 7) - 1) << endl;
}

Measured memory_bytes: 252544