akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
 
int main(){
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    int x=tx-sx;
    int y=ty-sy;
    vector<string> ans={};
    for (int i=0; i<y; i++){
        ans.push_back("U");
    }
    for (int i=0; i<x; i++){
        ans.push_back("R");
    }
    for (int i=0; i<y; i++){
        ans.push_back("D");
    }
    for (int i=0; i<x+1; i++){
        ans.push_back("L");
    }
    for (int i=0; i<y+1; i++){
        ans.push_back("U");
    }
    for (int i=0; i<x+1; i++){
        ans.push_back("R");
    }
    ans.push_back("D");
    ans.push_back("R");
    for (int i=0; i<y+1; i++){
        ans.push_back("D");
    }
    for (int i=0; i<x+1; i++){
        ans.push_back("L");
    }
    ans.push_back("U");
    for (int i=0; i<ans.size(); i++){
        cout<<ans[i];
    }
    return 0;
}

Measured memory_bytes: 1152
import java.util.*;

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

     int N=sc.nextInt();
		int[]a=new int[N];
		for(int i=0;i<N;i++){
			a[i]=sc.nextInt();
		}
		
		Deque<Integer> ad=new ArrayDeque<Integer>();
		
		for(int i=0;i<N;i++){
			if(i%2==N%2){
				ad.offerLast(a[i]);
			}else{
				ad.offerFirst(a[i]);
			}
		}
		for(Integer num : ad){
			System.out.print(num+" ");
		}
		System.out.println();
     
  }   
}




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

int main() {
    int n, m, l;
    cin >> n >> m >> l;

    vector<vector<long long int>> A(n, vector<long long int>(m));
    vector<vector<long long int>> B(m, vector<long long int>(l));

    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            cin >> A.at(i).at(j);
        }
    }

    for(int i = 0; i < m; i++) {
        for(int j = 0; j < l; j++) {
            cin >> B.at(i).at(j);
        }
    }

    vector<vector<long long int>> ans(n, vector<long long int>(l, 0));

    for(int i = 0; i < n; i++) {
        for(int j = 0; j < l; j++) {
            for(int k = 0; k < m; k++) {
                ans.at(i).at(j) += A.at(i).at(k)*B.at(k).at(j);
            }
        }
    }
 
  	for(int i = 0; i < n; i++) {
        for(int j = 0; j < l; j++) {
                printf("%ld", ans.at(i).at(j));
          	j == l-1 ? cout << endl : cout << ' ';
        }
    }
}


Measured memory_bytes: 3272
S=input()
T=input()
m=2000
for i in range(len(S)-len(T)+1):
    U=S[i:i+len(T)]
    c=0
    for j in range(len(T)):
        if U[j]!=T[j]:
            c+=1
    m=min(c,m)
print(m)

Measured memory_bytes: 9040
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    string S, T;
    cin >> S;
    cin >> T;
    //cout << S << T << endl;
    string ans;
    ans = S.at(0);
    ans += T.at(0);
    for( int i=1; i<N; i++){
        ans += S.at(i);
        ans += T.at(i);
    }
    cout << ans << endl;
}




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

typedef long long int ll; 
ll rbinary[10],cbinary[10];

void rToBin(ll n,ll size)
{
	for(ll kk=0;kk<size;kk++)
		rbinary[kk] = 0;

	ll ridx = 0;
	while(n>0) 
	{
		rbinary[ridx++] = n%2;
		n = n/2;
	}
	/// now reverse the array
	for(ll i=0;i<size/2;i++)
	{
		ll tt = rbinary[i];
		rbinary[i]=rbinary[size-1-i];
		rbinary[size-1-i]=tt;
	}
}
void cToBin(ll n,ll size)
{
	for(ll kk=0;kk<size;kk++)
		cbinary[kk] = 0;

	ll cidx = 0;
	while(n>0) 	
	{
		cbinary[cidx++] = n%2;
		n = n/2;
	}
	/// now reverse the array
	for(ll i=0;i<size/2;i++)
	{
		ll tt = cbinary[i];
		cbinary[i]=cbinary[size-1-i];
		cbinary[size-1-i]=tt;
	}
}
int main(void)
{
	ll h,w,k;
	cin >> h >> w >> k;

	char mat[10][10];

	for(ll i=0;i<h;i++)
		for(ll j=0;j<w;j++)
			cin >> mat[i][j];


	ll rpos=1,cpos=1;
	for(ll i=0;i<h;i++)
		rpos *= 2;
	for(ll i=0;i<w;i++)
		cpos *= 2;

	ll ans=0;
	for(ll i=0;i<rpos;i++)
	{
		rToBin(i,h);
		for(ll j=0;j<cpos;j++)
		{
			cToBin(j,w);
			char ttmat[10][10];
			for(ll row=0;row<h;row++)
			{
				for(ll col=0;col<w;col++)
					ttmat[row][col] = mat[row][col];
			}
			for(ll row=0;row<h;row++)
			{
				if(rbinary[row] == 1)
				{
					for(ll col=0;col<w;col++)
						ttmat[row][col] = '$';
				}
			}
			for(ll col=0;col<w;col++)
			{
				if(cbinary[col] == 1)
				{
					for(ll row=0;row<h;row++)
						ttmat[row][col] = '$';
				}
			}
			// now cnt no of '#' in ttmat
			ll cnt=0;
			for(ll row=0;row<h;row++)
			{
				for(ll col=0;col<w;col++)
				{
					if(ttmat[row][col] == '#')
					cnt++;
				}

			}
			if(cnt == k)
				ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3608
#if defined(__GNUC__)
#include <bits/stdc++.h>
#define __int32 __int32_t
// __GNUC__
#else
#include "bits/stdc++.h"
#endif
using namespace std;

#define int long long

#define itn __int32
#define REP(i, n) for(itn (i) = 0; (i) < (n); ++(i))
#define REP2(i, x, n) for(itn (i) = x; (i) < (n); ++(i))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define SORT(x) std::sort(ALL(x))
#define RSORT(x, T) std::sort(ALL(x), greater<T>())
#define REVERCE(x) std::reverce(ALL(x))
#define ACM(x, y) std::accumulate(ALL(x), y)

#define INT_POW(x, y) [](int a, int b) -> int {int c = a; REP(i, b - 1){c *= a;} return c;}(x, y)
#define INT_POWM(x, y, m) [](int a, int b, int m) -> int {int c = a; REP(i, b - 1){c *= a; c %= m;} return c;}(x, y, m)

itn main() {
	std::ios::sync_with_stdio(false);

	string s, t;

	cin >> s >> t;

	int a, b;

	cin >> a >> b;

	string u;

	cin >> u;

	if (u == s) {
		--a;
	}
	else {
		--b;
	}

	cout << a << ' ' << b << '\n';

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define loop(i, a, b) for(int i = a; i < b; i++) 
#define rep(i, a) loop(i, 0, a)
using namespace std;
const int MOD = 1000000007;
const int inf = 1e8;
using vi = vector <int>;
using vvi = vector <vi>;
using vc = vector <char>;
using vvc = vector <vc>;
using vs = vector <string>;
using vvs = vector <vs>;
//g++ -std==c++14
//setprecision(10)
long long int n, a;
set <int> st;

int main(){
    cin >> n;
    rep(i, n){
        cin >> a;
        if(st.find(a) != st.end())
            st.erase(st.find(a));
        else
            st.insert(a);
    }
    cout << st.size() << endl;
}

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

int main(){
  int a,b;
  cin>>a>>b;
  if(a<=0&&0<=b)cout<<"Zero"<<endl;
  else{
    if(a<0){
      if(b<0&&(b-a+1)%2)cout<<"Negative"<<endl;
      else cout<<"Positive"<<endl;
    }else cout<<"Positive"<<endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
using namespace std;

int main(){
  int a, b, c, d;
  scanf("%d %d %d %d", &a, &b, &c, &d);
  bool t = false;
  if(d >= abs(a-c)){
    t = true;
  }
  if ( d >= abs(a-b) && d >= abs(c-b)){
    t = true;
  }
  if(t){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
typedef unsigned long long int ull;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> o_set; 

#define     int                 ll
#define     pb                  push_back
#define     mp                  make_pair
#define     xx                  first
#define     yy                  second    
#define     all(a)              a.begin(),a.end()
#define     vi                  vector<int>
#define     vpi                 vector<pii>
#define     pii                 pair<int, int>
#define     present(DT, val)    (DT.find(val) != DT.end()) //for set and map
#define     cpresent(DT, val)   (find(all(DT),val) != DT.end()) //vectors
#define     input               "/home/pollution/Desktop/WorkSpace/C++/Files/input.txt"
#define     output              "/home/pollution/Desktop/WorkSpace/C++/Files/output1.txt"
#define     error               "/home/pollution/Desktop/WorkSpace/C++/Files/error.txt"
#define     IO()                ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     INF                 2e18
#define     MOD                 1000000007
#define     clr(x)              memset(x, 0, sizeof(x))
#define     init(x, a)          memset(x, a, sizeof(x))
#define     out(a)              for (auto i: a) cout<<i<<' '; cout<<'\n'
#define     cpy(a,b)            memcpy(a,b,sizeof(b))
#define     is(a)               to_string(a)
#define     ci(a,c)             a-c
#define     db(i)               cout<<"point :"<<i<<'\n';
#define     setd(val,n)         cout<<fixed<<setprecision(n)<<val<<'\n'

void solve(){
    int n; cin>>n;
    vi a(n);
    unordered_map<int, int> hmap;
    for(int i = 0; i < n; ++i){
    	cin>>a[i];
    	hmap[i-a[i]]++;
    	a[i]+=i;
    }
    int ans = 0;
    for(int i = 0; i < n; ++i){
    	if(present(hmap,a[i])){
    		ans+=hmap[a[i]];
    	}
    }
    cout<<ans<<'\n';
}

signed main() { 
    IO();
    
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0; 
}

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

vector<int> perm(8);
vector<bool> used(9);
vector<int> p(8),q(8);
int a,b;
int cnt;

void permutation(int pos, int n){
    if(pos == n){
        cnt++;
        if(p == perm) a = cnt;
        if(q == perm) b = cnt;
    }
    for(int i = 1;i <= n;i++){
        if(used[i]) continue;
        perm[pos] = i;
        used[i] = true;
        permutation(pos+1,n);
        used[i] = false;
    }
}

int main() {
    int n;
    cin >> n;
    rep(i,n) cin >> p[i];
    rep(i,n) cin >> q[i];
    permutation(0,n);
    cout << abs(a-b) << endl;
 }

Measured memory_bytes: 3596
def solve():
    N = int(raw_input())
    X = [0] * N
    Y = [0] * N
    for i in range(N):
        X[i], Y[i] = (int(_) for _ in raw_input().split())
    ##
    m = 31
    d = [0] * m
    tmp = 1
    for i in range(m - 1, -1, -1):
        d[i] = tmp
        tmp *= 2
    ##
    quo = (X[0] + Y[0]) % 2
    if quo == 0:
        d.append(1)
        m += 1
    modes = [''] * N
    for i in range(0, N):
        tmp_x = X[i]
        tmp_y = Y[i]
        if (tmp_x + tmp_y) % 2 != quo:
            print '-1'
            return 0
        for j in range(m):
            leng = d[j]
            if abs(tmp_x - leng) + abs(tmp_y) <= leng:
                modes[i] += 'R'
                tmp_x -= leng
            elif abs(tmp_x + leng) + abs(tmp_y) <= leng:
                modes[i] += 'L'
                tmp_x += leng
            elif abs(tmp_x) + abs(tmp_y - leng) <= leng:
                modes[i] += 'U'
                tmp_y -= leng
            else:
                modes[i] += 'D'
                tmp_y += leng

    print str(m)
    for i in range(m):
        print d[i],
    print
    for i in range(N):
        print modes[i]

if __name__ == '__main__':
    solve()


Measured memory_bytes: 2820
input = raw_input

N, K, Q = map(int, input().split(" "))

points = [K-Q for i in range(N)] 

for i in range(Q):
    A = int(input()) - 1
    points[A] += 1

for point in points:
    if point > 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 34920
#include<math.h>
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include <array>
#include<tuple>
#include<queue>
#include<stack>
#include<iomanip>
#include<bitset>
//AtCoderC++.cpp

using namespace std;

vector<long long> comb = vector<long long>(100 * 100,-1);

long long combination(long long n, long long r) {
	if (n == 1 || n == 0)return 1;
	if (n == r)	return 1;
	else if (r == 0)return 1;
	else if (r == 1)return n;
	else if (comb[100 * (n - 1) + (r - 1)] != -1) return comb[100 * (n - 1) + (r - 1)];
	else {
		auto res = combination(n - 1, r - 1) + combination(n - 1, r);
		comb[100 * (n - 1) + (r - 1)] = res;
		return res;
	}
}


int solveC() {
	long long L, R;
	cin >> L >> R;
	if (L % 2019 == 0 || R & 2019 == 0 || R - L >= 2018) {
		cout << 0 << endl;
		return 0;
	}
	int ans = 2019;
	for (int i = L; i < R; i++) {
		for (int j = i + 1; j <= R; j++) {
			ans = min((i*j) % 2019, ans);
		}
	}
	cout << ans << endl;
}



int distance(vector<int>& a, vector<int>& b) {
	auto sum = 0;
	for (size_t i = 0; i < a.size(); i++) {
		sum += (a[i] - b[i])* (a[i] - b[i]);
	}
	return sum;
}

bool is_square(int n) {
	for (size_t i = 0; i < 200; i++) {
		if (n == i * i) {
//			cout << i << endl;
			return true;
		}
	}
	return false;
}

int main() {
	int N, D; cin >> N >> D;
	auto vvs = vector<vector<int>>(N);
	for (size_t i = 0; i < N; i++) {
		vvs[i] = vector<int>(D);
		for (size_t j = 0; j < D; j++) {
			cin >> vvs[i][j];
		}
	}
	int count = 0;
	for (size_t i = 0; i < N; i++) {
		for (size_t j = i + 1; j < N; j++) {
//			cout << distance(vvs[i], vvs[j]) << endl;
			if (is_square(distance(vvs[i], vvs[j])))count++;
		}
	}
	cout << count << endl;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  int ans = 1e9;
  for (int i = -100; i <= 100; i++) {
    int sum = 0;
    for (int j = 0; j < N; j++) sum += (i - A.at(j)) * (i - A.at(j));
    ans = min(ans, sum);
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <list>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(d) string(1,d)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
  ll n;
  cin>>n;
  cout << n*(n+1)/2 << endl;
  return 0;
}

Measured memory_bytes: 256
import Data.List
 
substrings :: [a] -> [[a]]
substrings = ([]:) . concatMap (tail . inits) . tails

acgt :: [Char] -> Bool
acgt [] = True
acgt (x:xs)
        | x `elem` "ACGT" = acgt xs
        | otherwise = False
 
main = do
        s <- getLine
        print.maximum.map length $ filter acgt $ substrings s

Measured memory_bytes: 3740
#include<iostream>
#include<vector>
#include<deque>
using namespace std;

int K;
vector<pair<int,int> > G[100000];
int d[100000];

void bfs(int v){
    fill(d,d+K,-1);
    deque<pair<int,int> > deq;
    deq.push_back(make_pair(v,0));
    pair<int,int> pa;
    int from,to,cost,zeroone;
    int i;
    while(!deq.empty()){
        pa= deq.front();
        deq.pop_front();
        from=pa.first;
        cost=pa.second;
        if(d[from]>=0) continue;
        d[from]=cost;
        for(i=0; i<G[from].size(); i++){
            pa=G[from][i];
            to=pa.first;
            zeroone=pa.second;
            if(d[to]<0){
                if(zeroone==0){
                    deq.push_front(make_pair(to,cost));
                }else{
                    deq.push_back(make_pair(to,cost+1));
                }
            }
        }
    }

}

int main(){
    cin >> K;
    int i;
    for(i=0; i<K-1; i++){
        G[i].push_back(make_pair((10*i)%K,0));
        G[i].push_back(make_pair(i+1,1));
    }
    G[K-1].push_back(make_pair((10*(K-1))%K,0));
    G[K-1].push_back(make_pair(0,1));
    bfs(1);
    cout << d[0]+1 << endl;
    system("pause");
    return 0;
}

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

int x;

int main(int argc, const char * argv[]) {
    int i = 1;
    while(1){
        cin >> x;
        if(x == 0) break;
        cout << "Case " << i << ": " << x << endl;
        i++;
    }


    return 0;
}


Measured memory_bytes: 2992
s = input()
t = input()

cor = 0
for i in range(0, len(s) - len(t) + 1):
    sum = 0
    for j in range(len(t)):
        if s[i + j] == t[j]:
            sum += 1
    cor = max(cor, sum)

print(len(t) - cor)        

Measured memory_bytes: 9084
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    long long n;
    long long ans = 0;
    int itr;
    cin >> n;
    vector<long long> a(3 * n);
    for (int i=0; i< 3 * n; ++i){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    for (int i=1; i<=n; ++i){
        itr = 3 * n - 2 * i;
        ans += a[itr];
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
import java.util.*;
import java.math.*;

public class Main {
    static final int MOD = 1_000_000_007; // 10^9+7
    // static final int MAX = 2_147_483_646; // intの最大値
    static final int INF = 1_000_000_000; // 10^9
    static final int MAX = 10_000_000;
    static long[] fact = new long[100];
        public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            int d = sc.nextInt();
            for(int i = 0;i < 100;i++){
                c-=b;
                if(c<=0){
                    System.out.println("Yes");
                    return;
                }
                a-=d;
                if(a<=0){
                    System.out.println("No");
                    return;
                }
            }
    }
    
}


Measured memory_bytes: 35768
import java.util.*;
public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] = new int[n];
        for(int i=0;i<n;i++){
            a[i]=sc.nextInt();
        }
        int mx[] = new int[n];
        mx[0]=a[0];
        for(int i=1;i<n;i++){
            if(a[i]>mx[i-1]){
                mx[i]=a[i];
            }
            else{
                mx[i]=mx[i-1];
            }
        }
        long sum=0;
        for(int i=0;i<n;i++){
            if(a[i]<mx[i])
                sum+=(long)(mx[i]-a[i]);
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 60200
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n,m,q;
  cin>>n>>m>>q;
  vector<int> a(q),b(q),c(q),d(q);
  for(int i=0;i<q;++i){
    cin>>a[i]>>b[i]>>c[i]>>d[i];
    a[i]--;b[i]--;
  }
  int ans = 0;
  auto calc = [&](vector<int>& v){
    int res = 0;
    for(int i=0;i<q;++i){
      if(v[b[i]]-v[a[i]]==c[i])res+=d[i];
    }
    if(ans<res)ans=res;
  };
  auto dfs = [&](auto&& dfs,vector<int>& v)->void{
    if(size(v)==n){
      calc(v);
      return ;
    }
    int s = v.back();
    for(int i=s;i<=m;++i){
      v.emplace_back(i);
      dfs(dfs,v);
      v.pop_back();
    }
  };
  for(int i=1;i<=m;++i){
    vector<int> v = {i};
    dfs(dfs,v);
  }
  cout<<ans<<endl;
  
}

Measured memory_bytes: 3588
/*
ID: espr1t
TASK: 
KEYWORDS: 
*/

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>

using namespace std;
FILE* in = stdin; FILE* out = stdout;

const int MAX = 200002;

struct Cell {
    int row, col;
    Cell(int row_ = 0, int col_ = 0) : row(row_), col(col_) {}
    bool operator < (const Cell& r) const {
        return row != r.row ? row < r.row : col < r.col;
    }
};

int n, m, k;
Cell a[MAX];
queue <int> q[MAX];
set < pair <int, int> > occupied;

int main(void) {
	// in = fopen("D.in", "rt");
	
	fscanf(in, "%d %d %d", &n, &m, &k);
	for (int i = 0; i < k; i++)
	    fscanf(in, "%d %d", &a[i].row, &a[i].col);
	sort(a, a + k);
	for (int i = 0; i < k; i++) {
	    q[a[i].col].push(a[i].row);
	    occupied.insert(make_pair(a[i].row, a[i].col));
    }
	
	int ans = n;
	int row = 1, col = 1, move = 0;
	while (row < n) {
	    if (occupied.find(make_pair(row + 1, col)) != occupied.end()) {
	        ans = min(ans, move + 1);
	        break;
        }
	    row++, move++;
	    
	    while (!q[col].empty() && q[col].front() <= row)
	        q[col].pop();
	    int limit = q[col].empty() ? n + 1 : q[col].front();
	    ans = min(ans, move + limit - row);
	    if (col + 1 < m && occupied.find(make_pair(row, col + 1)) == occupied.end()) {
	        col++;
        }
    }
    fprintf(out, "%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 145536
'''
ITP-1_10-A
 ?????¢
?????? P1(x1, y1), P2(x2, y2) ????????¢????±???????????????°????????????????????????
???Input
x1, y1, x2, y2 ????????°???????????????????????§?????????????????????
???Output
P1??¨P2????????¢????????°??§?????????????????????????????????0.0001??\????????????????????£????????????????????¨????????????
'''
# # import
# import numpy
# 
# # inputData
# Data = input().split()
# x1 = int(Data[0])
# y1 = int(Data[1])
# x2 = int(Data[2])
# y2 = int(Data[3])
# 
# P1 = numpy.array([x1, y1])
# P2 = numpy.array([x2, y2])
# print(numpy.linalg.norm(P2 - P1))

import math

def get_distance(x1, y1, x2, y2):
    d = math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
    return d

if __name__ == '__main__':
    # inputData
    Data = input().split()
    x1 = float(Data[0])
    y1 = float(Data[1])
    x2 = float(Data[2])
    y2 = float(Data[3])

    d = get_distance(x1, y1, x2, y2)
    print(d)

Measured memory_bytes: 7700
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        static void Main(string[] args)
        {
            SolveA(args);
            //SolveB(args);
            //SolveC(args);
            //SolveD(args);


        }

        static void SolveA(string[] args)
        {
            var ab = ReadAndParseIntArr();
            int a = ab[0];
            int b = ab[1];
            string ans;
            if((a * b) % 2 == 0)
            {
                Console.WriteLine("No");
            }
            else
            {
                Console.WriteLine("Yes");
            }
        }
    }
}

Measured memory_bytes: 13140
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
using namespace std;
#define N 2002
bitset<N*N> bs;
int main(){
	ios::sync_with_stdio(false);
	int n, i, sum=0, a;
	scanf("%d", &n);
	bs[0] = 1;
	for(i=0; i<n; i++){
		scanf("%d", &a);
		sum += a;
		bs |= bs<<a;
	}
	for(i=(sum+1)/2; ; i++){  // 不要忘记加1 
		if(bs[i]){
			cout<<i<<endl;
			return 0;
		}
	}	
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int n, w;
	pair<string, pair<int, int>> p[101];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> p[i].first >> w;
		p[i].second.first = w * (-1);
		p[i].second.second = i + 1;
	}
	sort(p, p + n);
	for (int i = 0; i < n; i++) {
		cout << p[i].second.second << endl;
	}

	return 0;
}



Measured memory_bytes: 256
//Author: Lixiang
#include<stdio.h>
#include<algorithm>
#include<iostream>
using namespace std;
const int maxn=100001;
struct C{
	long long a[maxn],cnt[maxn];
	int N;
	void init(){
		scanf("%d",&N);
		for(int i=1;i<=N;i++)
			cin>>a[i];
		sort(a+1,a+N+1);
	}
	void work(){
		int n=0;
		for(int i=N;i>=2;i--){
			if(a[i]==a[i-1]){
				cnt[++n]=a[i];
				i--;
			}
		}
		cout<<cnt[1]*cnt[2]<<endl;
	}
}sol;
int main(){
	sol.init();
	sol.work();
	return 0;
}

Measured memory_bytes: 1408
#include<iostream>
using namespace std;
int fun(int x,int y)
{
    if ((x%500)<=y)
    {
        return 1;
    }
    else
    {
        return 2;
    }
}
int main()
{
    int a=0,b=0,c=0;
    cin>>a>>b;
    c=fun(a,b);
    if(c==1)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n, h;
  cin >> n >> h;
  vector<int> b(n);
  int amax = 0;
  int a;
  for (int i = 0; i < n; i++) {
    cin >> a;
    amax = max(amax, a);
    cin >> b[i];
  }
  sort(b.begin(), b.end(), greater<int>());
  int ans = 0;
  for (auto e : b) {
    if (amax < e) {
      h -= e;
      ans++;
      if (h <= 0) break;
    }
  }
  if (h > 0) ans += (h + amax - 1) / amax;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define double long double
#define MAXN 305
using namespace std;

double dp[MAXN][MAXN][MAXN];

double n;

double solve(int i,int j,int k){
	if(dp[i][j][k]!=-1){
	return dp[i][j][k];
	}
	double num = (i+j+k);
	double exp = (double)n/(i+j+k);
	double op1=0,op2=0,op3=0;
	if(i>=1)op1=(i/num)*(solve(i-1,j,k));
	if(j>=1)op2=(j/num)*solve(i+1,j-1,k);
	if(k>=1)op3=(k/num)*solve(i,j+1,k-1);
//	cout<<i<<" "<<j<<" "<<k<<" "<<exp<<" "<<op1<<" "<<op2<<" "<<op3<<" "<<endl;
	return dp[i][j][k]=(op1+op2+op3+exp);
}

int main(){
	cin>>n;
	
	int x,a1=0,a2=0,a3=0;
	for(int i=0;i<(int)n;i++){
		cin>>x;
		if(x==1)a1++;
		if(x==2)a2++;
		if(x==3)a3++;
	}

	for(int i=0;i<MAXN;i++)
		for(int j=0;j<MAXN;j++)
			for(int k=0;k<MAXN;k++)
				dp[i][j][k]=-1;
			
		dp[0][0][0]=0;
	//	cout<<a1<<" "<<a2<<" "<<a3<<endl;
		cout<<setprecision(14)<<fixed;		
	   cout<<solve(a1,a2,a3)<<endl;	
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll mod = 1e9+7;

int main(){
    
    int n;
    cin >> n;
    V<string> s(2);
    rep(i,2) cin >> s[i];

    ll ans = 1;
    int idx;
    if(s[0][0] == s[1][0]) ans = 3, idx = 1;
    else ans = 6, idx = 2;

    while(idx < n) {
        if(s[0][idx] == s[1][idx]) {
            if(s[0][idx-1] == s[1][idx-1]) ans *= 2, ans %= mod;
            else ans *= 1, ans %= mod;
            idx++;
        }
        else {
            if(s[0][idx-1] == s[1][idx-1]) ans *= 2, ans %= mod;
            else ans *= 3, ans %= mod;
            idx += 2;
        }
    }

    cout << ans << endl; 
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main{

	public static void main(String args[]){

		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		int[] x = new int[n];
		for(int i=0; i<n; i++)x[i]=s.nextInt();

		long[][] dp = new long[n-1][21];

		dp[0][x[0]] = 1;

		for (int i=1; i < n-1; ++i) {
            for (int j=0; j <= 20; ++j) {
                if (j + x[i] <= 20) {
                    dp[i][j+x[i]] += dp[i-1][j];
                }
                if (j - x[i] >= 0) {
                    dp[i][j-x[i]] += dp[i-1][j];
                }
            }
        }
        System.out.println(dp[n-2][x[n-1]]);

	}

}



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

struct Dice {
  vector<int> num;
  void roll_north() {
    int t = num.at(0);
    num.at(0) = num.at(1);
    num.at(1) = num.at(5);
    num.at(5) = num.at(4);
    num.at(4) = t;
  }
  void roll_south() {
    int t = num.at(0);
    num.at(0) = num.at(4);
    num.at(4) = num.at(5);
    num.at(5) = num.at(1);
    num.at(1) = t;
  }
  void roll_east() {
    int t = num.at(0);
    num.at(0) = num.at(3);
    num.at(3) = num.at(5);
    num.at(5) = num.at(2);
    num.at(2) = t;
  }
  void roll_west() {
    int t = num.at(0);
    num.at(0) = num.at(2);
    num.at(2) = num.at(5);
    num.at(5) = num.at(3);
    num.at(3) = t;
  }
  void spin() {
    int t = num.at(1);
    num.at(1) = num.at(2);
    num.at(2) = num.at(4);
    num.at(4) = num.at(3);
    num.at(3) = t;
  }
};

int main() {
  Dice d;
  rep(i, 6) {
    int n; cin >> n;
    d.num.push_back(n);
  }
  int q;
  cin >> q;
  rep(i, q) {
    int top, front;
    cin >> top >> front;
    
    bool find = false;
    rep(j, 2) {
      rep(k, 4) {
        if (d.num.at(0) == top) {
          find = true;
          break;
        }
        d.roll_north();
      }
      if (find) {
        break;
      }
      d.roll_west();
    }
    rep(j, 4) {
      if (d.num.at(1) == front) {
        cout << d.num.at(2) << endl;
        break;
      }
      d.spin();
    }

    // bool find = false;
    // rep(j, 4) {
    //   rep(k, 4) {
    //     if (t.num.at(0) == top && t.num.at(1) == front) {
    //       find = true;
    //       break;
    //     }
    //     t.roll_north();
    //   }
    //   t.roll_west();
    //   if (find) {
    //     cout << t.num.at(0) << endl;
    //     break;
    //   }
    // }
  }
}


Measured memory_bytes: 3108
import itertools


def main():
    # 入力
    n = int(input())

    p = list(map(int, input().split()))
    q = list(map(int, input().split()))

    lis = [x for x in range(1, n+1)]
    permutations_lis = itertools.permutations(lis)

    ap = -1
    aq = -1
    count = 0
    for perlist in permutations_lis:
        count += 1
        is_p = True
        is_q = True
        for i in range(n):
            pi = perlist[i]
            if is_p and pi != p[i]:
                is_p = False
            if is_q and pi != q[i]:
                is_q = False
            if not is_p and not is_q:
                break

        if is_p:
            ap = count
        if is_q:
            aq = count

        if ap != -1 and aq != -1:
            break

    print(abs(ap-aq))


main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N, K;
    cin >> N >> K;
    vi a(N);
    cin >> a;
    int ans = 1;
    int sum = K;
    while (1) {
        if (sum >= N) break;
        sum += K - 1;
        ans++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1024
N,M = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
sumA = sum(A)
pop_cnt = 0
for a in A:
    if a >= (sumA/(4*M)):
        pop_cnt += 1
if pop_cnt >= M:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <iostream>
#include <cstdlib>
#include <cstdlib>
using namespace std;
int n,a[20];
void dfs(int lc,int up)
{
	if (lc==n+1) 
	{
		for (int i=1;i<=n;i++) printf("%c",a[i]-1+'a');
		printf("\n"); return;
	}
	if (up>n) return;
	for (int i=1;i<=up;i++) a[lc]=i,dfs(lc+1,max(up,i+1));
}
int main()
{
	//freopen("1.out","w",stdout);
	scanf("%d",&n); a[1]=1; dfs(2,2);
return 0;
}

Measured memory_bytes: 1536
/*
                       _oo0oo_
                      o8888888o
                      88" . "88
                      (| -_- |)
                      0\  =  /0
                    ___/`---'\___
                  .' \\|     |// '.
                 / \\|||  :  |||// \
                / _||||| -:- |||||- \
               |   | \\\  -  /// |   |
               | \_|  ''\---/''  |_/ |
               \  .-\__  '-'  ___/-. /
             ___'. .'  /--.--\  `. .'___
          ."" '<  `.___\_<|>_/___.' >' "".
         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
         \  \ `_.   \_ __\ /__ _/   .-` /  /
     =====`-.____`.___ \_____/___.-`___.-'=====
                       `=---='
                   JAY KHODIYAR MAA
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 JENISH MONPARA S.      IIT PATNA      ADITI GOEL IS LOVE
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
// while(scanf("%d",&n)!=EOF)

#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define ii int64_t
#define lli long long int
#define li long int
#define deb(x) cout<<"\nhi"<<x<<"\n"
#define mod 1000000007
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

int main()
{
    fio;
    int n,m;
    cin>>n>>m;
    cout<<((n)*(n-1))/2+((m)*(m-1))/2;
    
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cstdio>
#include<iostream>
#include<map>
#include<string>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<cstring>
using namespace std;
typedef long long ll;
ll n,x,y;
ll len[2004][2004]={0};
ll le[2004]={0};
int main()
{
	scanf("%lld%lld%lld",&n,&x,&y);
	for(ll i=1;i<n;i++)
	{
		for(ll j=i+1;j<=n;j++)
		{
			len[i][j]=j-i;
		}
	}
	len[x][y]=1;
	for(ll i=1;i<n;i++)
	{
		for(ll j=i+1;j<=n;j++)
		{
			len[i][j]=min(len[i][j],len[min(i,x)][max(i,x)]+len[min(y,j)][max(y,j)]+1);
			len[i][j]=min(len[i][j],len[min(i,y)][max(y,i)]+len[min(x,j)][max(x,j)]+1);
		}
	}
	for(ll i=1;i<=n;i++)
	{
		for(ll j=1;j<=n;j++)
		{
			le[len[i][j]]++;
		}
	}
	len[x][y]=1;
	for(ll i=1;i<n;i++)
	{
		printf("%lld\n",le[i]);
	}
}

Measured memory_bytes: 31104
N, K = map(int, input().split())
d = []
A = []
for _ in range(K):
    d.append(int(input()))
    A.append(list(map(int, input().split())))
flag = [False]*N
for i in A:
    for j in i:
        flag[j-1] = True
print(N - sum(flag))

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

using namespace std;


int main() {

    int a, b, x;
    string res1 = "YES";
    string res2 = "NO";

    cin >> a;
    cin >> b;
    cin >> x;

    if (x>a+b || x<a) {

         cout << res2 << endl;        
    } 

    else if(x>=a && x<=a+b) {

        cout << res1 << endl;
    }   

    return 0;
}



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

int cnt=0;

int insertionSort(int A[],int n,int g){
	for(int i=g;i<=n-1;i++){
		int v=A[i];
		int j=i-g;
		while(j>=0&&A[j]>v){
			A[j+g]=A[j];
			j=j-g;
			cnt++;
		}
		A[j+g]=v;
	}
}

int main(){
	int i,n;
	int m=0;
	int G[13]={1,4,13,40,121,364,1093,3280,9841,29524,88573,265720,797161};
	cin >> n;
	while(n>G[m] || (n==1&&m==0)) m++;
	int A[n];
	for(i=0;i<n;i++) cin >>A[i];
	for(i=m-1;i>=0;i--){
		insertionSort(A,n,G[i]);
	}
	cout << m << endl;
	for(i=m-1;i>=0;i--){
		if(i!=0) cout << G[i] << " ";
		else cout << G[i] << endl;
	}
	cout << cnt << endl;
	for(i=0;i<n;i++){
		cout << A[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 5064
def run(N, K, V):
    ret = 0
    for L_get in range(K+1):
        for R_get in range(K-L_get+1):
            if L_get + R_get > N:
                break
            for Leave in range(K-L_get-R_get+1):
                if Leave > L_get + R_get:
                    break
                if L_get == 0:
                    L_lists = []
                else:
                    L_lists = V[:L_get]
                if R_get == 0:
                    R_lists = []
                else:
                    R_lists = V[-R_get:]
                lists = L_lists + R_lists
                sorted_lists = sorted(lists)
                ret = max(ret, sum(lists) - sum(sorted_lists[:Leave]))
    return ret


def main():
    N, K = map(int, input().split())
    V = list(map(int, input().split()))
    print(run(N, K, V))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static int[][] fishingData;
	static int n;
	public static void main(String[] args) {
		while(read()){
			solve();
		}
	}
	
	static boolean read(){
		if( !sc.hasNext() )return false;
		n = sc.nextInt();
		fishingData = new int[n][2];
		for(int i = 0; i < fishingData.length; i++){
			fishingData[i][0] = sc.nextInt();
			fishingData[i][1] = sc.nextInt();
		}
		return true;
	}
	
	static void solve(){
		int max = -1;
		for(int i = 0; i < fishingData.length; i++){
			max = Math.max(max, fishingData[i][1]);
		}
		int res = 1<<29;
		for(int i = 0; i < fishingData.length; i++){
			if( fishingData[i][1] == max ){
				res = Math.min(res, fishingData[i][0]);
			}
		}
		System.out.println(res + " " + max);
	}
}

Measured memory_bytes: 17392
#include <bits/stdc++.h>
#include<queue>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef pair<string,string> Pstring;
typedef pair<double,double> Pdouble;

#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define Precision13 cout << fixed << setprecision(13)
ll MOD = 1e9+7;

int main() {

  ll L;
  cin >> L;
  long double x = L/3.0;
  long double answer = x*x*x;
  Precision13;
  cout << answer << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    while(true) {
      int m = in.nextInt();
      int f = in.nextInt();
      int r = in.nextInt();

      if (m == -1 && f == -1 && r == -1) {
        break;
      }
      else if (m == -1 || f == -1) {
        System.out.println("F");
      }
      else if (m + f >= 65) {
        if (m + f >= 80) {
          System.out.println("A");
        }
        else {
          System.out.println("B");
        }
      }
      else {
        if (m + f < 50) {
          if (m + f < 30) {
            System.out.println("F");
          }
          else if (m + f >= 30 && r >= 50) {
            System.out.println("C");
          }
          else {
            System.out.println("D");
          }
        }
        else {
          System.out.println("C");
        }
      }
    }
  }
}

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

//#define int long long
using ll = long long;
using ld = long double;
using intpair = pair<int, int>;
const int MOD = 1e9 + 7;
inline int mod (ll a, int m = MOD) { return (a % m + m) % m; }
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((ll)((a) + (b) - 1)/(ll)(b))

signed main(){
    int n; cin >> n;
    int xorsum = 0;
    
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
        xorsum ^= a[i];
    }
    
    rep(i,n){
        cout << (xorsum ^ a[i]) << (i + 1 == n ? '\n' : ' ');
    }
}

Measured memory_bytes: 3980
#include <iostream>
#include <bits/stdc++.h>
#include <deque>
#include <vector>
#include<cstdio>
#include<string>
using namespace std;
int main()
{
    long long h,w,c=0,q=0;
    cin>>h>>w;
    char a[h][w];
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++)
            cin>>a[i][j];
    for(int i=0;i<h;i++)
    {
        c=0;
        for(int j=0;j<w;j++)
        {
            if(a[i][j]=='.') c++;
        }
        if(c!=w)
        {
           for(int j=0;j<w;j++)
            {
                q=0;
                if(a[i][j]=='.')
                {
                    for(int k=0;k<h;k++)
                    {
                        if(a[k][j]=='.') q++;
                    }
                    if(q!=h) cout<<a[i][j];
                }
                else cout<<a[i][j];
            }
            cout<<endl;

        }
    }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int N, M;
    cin >> N >> M;
    for (int i = 0; i < M; i++)
    {
        int a;
        cin >> a;
        N -= a;
    }

    cout << (N < 0 ? -1 : N) << endl;
}

Measured memory_bytes: 3644
n,i;
ea[2<<17],eb[2<<17],next[2<<17],first[1<<17];
long M,dp1[1<<17],dp2[1<<17],L[2<<17],R[2<<17];
dfs1(u,p,id)
{
	dp1[u]=1;
	for(id=first[u];id;id=next[id])eb[id]-p?dfs1(eb[id],u),dp1[u]=dp1[u]*-~dp1[eb[id]]%M:0;
}
dfs2(u,p,x,id)
{
	id=first[u];
	dp2[u]=dp1[u]*x%M;
	make(id,p,x);
	for(;id;id=next[id])
	{
		if(eb[id]!=p)dfs2(eb[id],u,L[id]*R[next[id]]%M+1);
	}
}
make(i,p,x,t)
{
	if(i)
	{
		L[i]=x;
		t=eb[i]-p?-~dp1[eb[i]]:1;
		make(x=next[i],p,t%M*x%M);
		R[i]=R[x]*t%M;
	}
}
main(u,v)
{
	/*for(scanf("%d%d",&n,&M);~scanf("%d%d",&u,&v);)
	{
		i++;
		ea[i]=u;
		eb[i]=v;
		i++;
		ea[i]=v;
		eb[i]=u;
	}*/
	//for(;~scanf("%d%d",&u,&v);)i++?ea[i]=eb[i+1]=u,ea[i+1]=eb[i]=v,i++:(n=u,M=v);
	for(;~scanf("%d%d",&u,&v);i++)i++?ea[i-1]=eb[i]=u,ea[i]=eb[i-1]=v:(n=u,M=v);
	for(;i--;)
	{
		next[i]=first[ea[i]];
		first[ea[i]]=i;
	}
	dfs1(*R=1,0);
	dfs2(1,0,1);
	for(i=1;i<=n;i++)printf("%d\n",dp2[i]);
}

Measured memory_bytes: 13568
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;

int main()
{
	long long int data[256];
	for (size_t i = 0; i < 256; i++)
	{
		data[i] = i*i;
	}
	int a;

	while (1)
	{
		cin >> a;
		if (a == 0)
		{
			break;
		}
		int count = 0;
		for (size_t i = 0; i < 256; i++)
		{
			for (size_t j = i; j < 256; j++)
			{
				for (size_t k = j; k < 256; k++)
				{
					for (size_t l = k; l < 256; l++)
					{
						if (data[i] + data[j] + data[k] + data[l] == a)
						{
							count++;
						} else if (data[i] + data[j] + data[k] + data[l] > a)
						{
							break;
						}
					}
					if (data[i] + data[j] + data[k] > a)
					{
						break;
					}
				}
				if (data[i] + data[j] > a)
				{
					break;
				}
			}
			if (data[i] > a)
			{
				break;
			}
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 1156
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>

#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long

const int INF = 1e18;
const int MOD = 998244353;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順
//cout << fixed << setprecision(10) << ans << endl;
//int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dp[4000][4000];
int a[4000];
signed main(){
    int n;
    cin >> n;
    int s;
    cin >> s;
    dp[0][0] = 1;
    REP(i,n){
        cin >> a[i+1];
    }
    REP(i,n+1){
        if(i==0) continue;
        REP(j,s+1){
            dp[i][j] = dp[i-1][j] *2;
            dp[i][j] %= MOD;
            if(j-a[i]>=0){
                dp[i][j] += dp[i-1][j-a[i]];
                dp[i][j] %= MOD;
            }
        }
    }
    cout << dp[n][s] << endl;
    return 0;
}

Measured memory_bytes: 86124
N = int(input())
XYs = [list(map(int, input().split())) for _ in range(N)]

dic = {}
tmp = 0

for i in range(N):
  for j in range(N):
    if i == j:
      continue
    p = XYs[j][0] - XYs[i][0]
    q = XYs[j][1] - XYs[i][1]

    if "{}_{}".format(p,q) not in dic:
      dic["{}_{}".format(p,q)] = 1
    else:
      dic["{}_{}".format(p,q)] += 1
      
for k in dic:
  if tmp < dic[k]:
    tmp = dic[k]

print(N-tmp)

Measured memory_bytes: 39664
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct _Node {
  int key;
  struct _Node *next, *prev;
} Node;

Node *nil;

Node* listSearch(int key) {
  Node *cur = nil->next;
  while(cur != nil && cur->key != key) {
    cur = cur->next;
  }
  return cur;
}

void init(void) {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(void) {
  Node *cur = nil->next;
  int isf = 0;
  while(1) {
    if(cur == nil) break;
    if(isf++>0) printf(" ");
    printf("%d",cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t) {
  if(t==nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(void) {
  deleteNode(nil->next);
}

void deleteLast(void) {
  deleteNode(nil->prev);
}

void deleteKey(int key) {
  deleteNode(listSearch(key));
}

void insert(int key) {
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(void) {
  int key, n, i;
  int size = 0;
  int np = 0, nd = 0;
  char com[20];
  scanf("%d", &n);
  init();
  for(i=0;i<n;i++) {
    scanf("%s%d",com, &key);
    if (com[0] == 'i') {
      insert(key);
      np++;
      size++;
    } else if(com[0] == 'd') {
      if(strlen(com) > 6) {
        if(com[6] == 'F')
          deleteFirst();
        else if(com[6] == 'L')
          deleteLast();
      } else {
        deleteKey(key);
        nd++;
      }
      size--;
    }
  }
  printList();
  return 0;
}






Measured memory_bytes: 33100