akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define SZ(a) int((a).size())
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(int i=x;i<y;i++)
#define frr(i,x,y) for(int i=x-1;i>=y;i--)
#define inf 1e18+1
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;}a=a*a;b>>=1;}return ans;}
ll powerm(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;ans%=mod;}a=a*a;a%=mod;b>>=1;}return ans%mod;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
vector<VL> adj;
VL visit2;
void dfs(ll v)
{
    visit2[v]=1;
    for(auto i:adj[v])
    {
        if(visit2[i]==-1)
        {
            dfs(i);
        }
    }
    return;
}
void solve()
{
    
    ll n,m;
    cin>>n>>m;
    vector<PLL> arr(m);
    fr(i,0,m)
    {
        cin>>arr[i].F>>arr[i].S;
        arr[i].F--;
        arr[i].S--;
    }
    ll bridge=0;    
    fr(i,0,m)
    {
        adj.clear();
        visit2.clear();
        adj.assign(n,VL());
        bool fg=false;
        fr(j,0,m)
        {
            if(i!=j)
            {
                adj[arr[j].F].pb(arr[j].S);
                adj[arr[j].S].pb(arr[j].F);
            }
        }
        visit2.assign(n,-1);
        dfs(0);
        fr(k,0,n)
        {
            if(visit2[k]==-1)
            {
                fg=true;
            }
        }
        if(fg)
        {
            bridge++;
        }
    }
    cout<<bridge<<endl;
    return;
}
int main()
{
    IOS;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        //cout<<"Case #"<<pp-t<<":\n";
        solve();
    }
    return 0;
}
/* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
*/
/*
recursion - matrix exponential

*/
// BITMASK:
// 1)When some constrall is of the order of 15-20, think of bitmask DP.
// 2)When some constrall is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algorithm

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

namespace AizuOnlineJudge
{
    class Program
    {
        static void Main(string[] args)
        {
            /*
1 selectionSort(A, N) // N個の要素を含む0-オリジンの配列A
2   for i が 0 から N-1 まで
3     minj = i
4     for j が i から N-1 まで
5       if A[j] < A[minj]
6         minj = j
7     A[i] と A[minj] を交換
             */
            Console.ReadLine();
            var arr = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            
            for(var i = 0; i < arr.Length; ++i)
            {
                var minIndex = i;
                for(var k = i; k < arr.Length; ++k)
                {
                    if (arr[k] < arr[minIndex]) minIndex = k;
                }
                if (minIndex != i) Swap(ref arr[i], ref arr[minIndex]);
            }
            Console.WriteLine(string.Join(" ", arr));
            Console.WriteLine(SwapCount);
        }

        private static int SwapCount { set; get; } = 0;

        private static void Swap<T>(ref T a, ref T b)
        {
            var t = a;
            a = b;
            b = t;
            SwapCount++;
        }
    }
}


Measured memory_bytes: 18352
a=[0]*5
for i in range(5):
  a[i]=int(input())
k=int(input())
ans=True
for i in range(4):
  for j in range(i+1,5):
    if a[j]-a[i]>k:
      ans=False
if ans:
  print("Yay!")
else:
  print(":(")

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

class Program
{
    static void Main(string[] args)
    {
        var inputs = Console.ReadLine().Split(' ');
        var x1 = int.Parse(inputs[0]);
        var y1 = int.Parse(inputs[1]);
        var x2 = int.Parse(inputs[2]);
        var y2 = int.Parse(inputs[3]);

        var dx = x2 - x1;
        var dy = y2 - y1;
        // 正方形になるために(x2, y2) + (-dy, dx)となる
        // (dx, dy)・(-dy, dx) = 0で直交する
        var x3 = x2 - dy;
        var y3 = y2 + dx;
        var x4 = x3 - dx;
        var y4 = y3 - dy;

        var ans = string.Format("{0} {1} {2} {3}", x3, y3, x4, y4);
        Console.WriteLine(ans);
    }


}



Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define MAX_N 100100
using namespace std;

#define ll long long
#define ull unsigned long long
#define ii pair<int,int>
#define iii pair<ii, int>

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ep emplace_back
#define sz(a) (int) a.size()
#define cl(a) a.clear()

#define vi vector<int>
#define vii vector<ii>

#define LOWBIT(x) ( (x) & -(x) )

#define FOR(x,a,b) for (int x=a;x<=b;x++)
#define FOD(x,a,b) for (int x=a;x>=b;x--)
#define REP(x,a,b) for (int x=a;x<b;x++)
#define RED(x,a,b) for (int x=a;x>b;x--)

const int MAX = 1e5 + 10;
const int MAXN = 1e4 + 10;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const double pi = acos(-1.0);
const double eps = 1e-6;

int dx[] = {0 , -1 , 0 , 1};
int dy[] = {1 , 0 , -1 , 0};

int a[MAX_N];
int n;

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

    //freopen("input.txt", "r" , stdin);

    cin >> n;
    n *= 2;

    FOR(i , 1 , n) cin >> a[i];

    sort(a + 1 , a + n + 1);

    int p = 1; int res = 0;

    while (p <= n)
    {
        res += a[p];
        p += 2;
    }

    cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    int cnt1 = 0, cnt2 = 0, cnt4 = 0;
    rep(i, n) {
        int a;
        cin >> a;

        if(a%2 == 1) {
            cnt1++;
        }
        else if(a%4 == 2) {
            cnt2++;
        }
        else {
            cnt4++;
        }
    }

    if(!cnt2) {
        if(cnt4 >= cnt1-1) {
            cout << "Yes";
        }
        else {
            cout << "No";
        }
        
        cout << endl;
        return 0;
    }

    if(cnt4 >= cnt1) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
struct node{
	int l,r;
}a[100000+20];
bool cmp(node a,node b)
{
	if(a.r==b.r)
		return a.l<b.l;//右边相同比较左边
	return a.r<b.r;//对数据右排序
}
int main ()
{
	int n,m,i;
	scanf("%d%d",&n,&m);
	for(i=0;i<m;i++)
		scanf("%d %d",&a[i].l,&a[i].r);
	int mn=a[0].r;
	for(i=0;i<m;i++)
		mn=min(a[i].r,mn);
		
	sort(a,a+m,cmp);//排序
int now=mn,ans=1;//找到最小的
	for(i=1;i<m;i++)
	{
		if(a[i].l>=now)
		{
			now=a[i].r;//如果下一个数据的左边大于切断桥的右边则仍然需要切桥
			ans++;
		}
 
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n;i>=0;i--)
#define Pool(i, m, n) for(ll i=n;i>=m;i--)
#define MAX 999999999ll
#define MIN -999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(x) cout<<x<<endl
#define gcd(x,y) __gcd(x,y) 
#define Gput(a,b) G[a].push_back(b)
ll lcm(ll x,ll y){
  ll z=gcd(x,y);
  return x*(y/z);
}
ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
vector<bool> seen;
void dfs(const Graph &G,ll v){
    seen[v]=true;
    for(auto nextv:G[v]){ 
        if(seen[nextv])continue;
        dfs(G,nextv);
    }
}
int main() {
  cout << fixed << setprecision(16);
  string s,t;
  cin>>s>>t;
  ll x=s.size();
  ll y=t.size();
  bool check=true;
  if(x<y){
  putout("UNRESTORABLE");
  }
  else{
  pool(i,x-y){
     check=true;
      loop(j,y){
       
      if(s[i+j]!='?'&&t[j]!=s[j+i]){
      check= false;
      }
      }
      if(check){
           loop(j,y){
       check=true;
      if(s[i+j]!=t[j]){
      s[i+j]=t[j];
      }
      }
      loop(k,x){
      if(s[k]=='?'){
      s[k]='a';
      }
      }
      putout(s);
      break;
      }
      
      
      
  }
  if(!(check)){
  putout("UNRESTORABLE");
  }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define newl "\n"
using namespace std;
using lli = long long int;
using vvint = vector <vector <int>>;
const int mod = 1e9 + 7;

const int N = 2e5 + 1;

void solve(){
	int count = 0;
	int n;
	cin >> n;
	bool flag = 0;
	for(int i = 0;i < n;++i){
		int a,b;
		cin >> a >> b;
		if(a == b) ++count;
		else count = 0;
		if(count >= 3) flag = 1;
	}
	if(flag) cout << "Yes" << newl;
	else cout << "No" << newl;


	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(10);
	#ifdef EXECUTE_LOCALLY
		   freopen("in.txt","r",stdin);
	#endif
	int t = 1;
	//cin >> t;
	while(t--) solve();
	#ifdef EXECUTE_LOCALLY
    	cout << setprecision(3) << "program time: " << (double)clock() / CLOCKS_PER_SEC << newl;
	#endif
	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using std::cout;
using std::endl;
using std::cin;

int main(){
	std::vector<int> a(3);
	for(int i = 0; i < 3; i++) cin >> a[i];
	sort(begin(a), end(a));
	int k; cin >> k;
	
	cout << a[0] + a[1] + (a[2] << k) << endl;
	return 0;
}


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

#define REP(i,num) for(ll i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){T x; cin >> x; return (x);}
template<typename T=ll,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

class ConnectNodeInfo{
	vector<vector<pair<ll,ll>>> graph;
public:
	ConnectNodeInfo(int node_num){
		graph.resize(node_num);
	}
	void AddNonDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
		graph[v].emplace_back(u,w);
	}
	void AddDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
	}
	vector<pair<ll,ll>>& operator[](ll index){
		return graph[index];
	}
	size_t size(){return graph.size();}
};

vector<int> D,F;

int dfs(int t,int p,int c,ConnectNodeInfo& connect){
	D[c]=t;
	for(auto& x:connect[c]){
		if(x.first!=p && D[x.first]==0){
			t = dfs(t+1,c,x.first,connect);
		}
	}
	t++;
	F[c]=t;
	return t;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int N=in();
	ConnectNodeInfo connect(N);
	vector<int> V(N);
	REP(i,N){
		int x=in()-1,k=in();
		REP(j,k){
			int y=in()-1;
			connect.AddDirectionalConnection(x,y,1);
		}
		V[i]=x+1;
	}
	D.resize(N,0);
	F.resize(N,0);
	int T=1;
	REP(i,N){
		if(D[i]==0) T = dfs(T,-1,i,connect)+1;
	}

	REP(i,N){
		out(V[i],D[i],F[i]);
	}

	return 0;
}



Measured memory_bytes: 3164
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
 
    int n,m;
    cin >> n >> m ;
 
    int a, b;
    int mina=2001;
    int counter = 0;
    for (int i = 0; i < m; i++) {
        cin >> a >> b;
        if (a < n) { counter += n - a; }
        mina = min(a, mina);
    }
 
    cout << counter+mina-n << endl;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define mod 10e9+7

#define rep(i,n) for(int i=1;i<=n;i++)
int main(){
   ll n,x,mini=INF,all=0;
   string s,a;
   cin >> s;
   for(int i=0;i<s.size()-2;i++){
      x=100*(s.at(i)-'0')+10*(s.at(i+1)-'0')+(s.at(i+2)-'0');
      
      mini=min(mini,abs(x-753)) ;
   }
   cout << mini << endl;
  }



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D, L, R;
  cin >> A >> B >> C >> D;
  L = A + B;
  R = C + D;
  if (L > R) {
      cout << "Left" << endl;
  }
  else if (L < R) {
      cout << "Right" << endl;
  }
  else if (L == R) {
      cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	static char[] arr;
	public static void main (String[] args)  {
		Scanner sc = new Scanner(System.in);
		arr = sc.next().toCharArray();
		HashSet<Character> set = new HashSet<>();
		int end = arr.length - 1;
		ArrayList<Suffix> list = new ArrayList<>();
		TreeSet<Integer>[] sets = new TreeSet[26];
		for (int i = 0; i < 26; i++) {
			sets[i] = new TreeSet<Integer>();
		}
		for (int i = arr.length - 1; i >= 0; i--) {
			char c = arr[i];
			set.add(c);
			sets[c - 'a'].add(i);
			if (set.size() == 26) {
				list.add(new Suffix(i, end));
				end = i - 1;
				set.clear();
			}
		}
		list.add(new Suffix(0, end));
		StringBuilder sb = new StringBuilder();
		char last = 'a';
		for (int i = list.size() - 1; i >= 0; i--) {
			int idx = -1;
			Suffix suf = list.get(i);
			if (i != list.size() - 1) {
				idx = sets[last - 'a'].higher(suf.start - 1);
			}
			for (int j = 0; j < 26; j++) {
				Integer next = sets[j].higher(idx);
				if (next == null || next.intValue() > suf.end) {
					last = (char) (j + 'a');
					sb.append(last);
					break;
				}
			}
		}
		System.out.println(sb);
	}
	
	static class Suffix {
		int start;
		int end;
		public Suffix(int start, int end) {
			this.start = start;
			this.end = end;
		}
		
		public String toString() {
			StringBuilder sb = new StringBuilder();
			for (int i = start; i <= end; i++) {
				sb.append(arr[i]);
			}
			return sb.toString();
		}
	}
}


Measured memory_bytes: 53196
/**
 *   @FileName	f.cpp
 *   @Author	kanpurin
 *   @Created	2020.08.02 21:55:15
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;


template< class Monoid >
struct SegmentTree {
private:
    using Func = std::function< Monoid(Monoid, Monoid) >;
    Func F;
    Monoid UNITY;
    int n;
    std::vector< Monoid > node;
public:
    SegmentTree() {}
    
    SegmentTree(int m, const Monoid &val, const Func f, const Monoid &unity) {
        F = f;
        UNITY = unity;
        n = 1; while (n < m) n <<= 1;
        node.resize(n * 2 - 1, UNITY);
        if (val != UNITY) {
            for (int i = 0; i < m; i++) node[i] = val;
            build();
        }
    }
    SegmentTree(const std::vector< Monoid >& v, const Func f, const Monoid &unity) {
        F = f;
        UNITY = unity;
        int sz = v.size();
        n = 1; while (n < sz) n <<= 1;
        node.resize(n * 2 - 1, UNITY);
        for (int i = 0; i < sz; i++) node[i + n - 1] = v[i];
        build();
    }
    
    void set(int k, const Monoid &x) {
        node[n + k - 1] = x;
    }
    void build() {
        for (int i = n - 2; i >= 0; i--) node[i] = F(node[2 * i + 1], node[2 * i + 2]);
    }
    void update_query(int x, const Monoid &val) {
        if (x >= n || x < 0) return;
        x += n - 1;
        node[x] = val;
        while (x > 0) {
            x = (x - 1) >> 1;
            node[x] = F(node[2 * x + 1], node[2 * x + 2]);
        }
    }
    
    Monoid get_query(int a, int b) {
        Monoid L = UNITY, R = UNITY;
        if (a < 0) a = 0;
        if (b < 0) return UNITY;
        if (a >= n) return UNITY;
        if (b >= n) b = n;
        for (a += n, b += n; a < b; a >>= 1, b >>= 1) {
            if (a & 1) L = F(L, node[a++ - 1]);
            if (b & 1) R = F(node[--b - 1], R);
        }
        return F(L, R);
    }
    Monoid operator[](int x)const {
        return node[n + x - 1];
    }
    int size() {
        return n;
    }
    void print() {
        for (int i = 0; i < n; i++) {
            std::cout << i << "\t: " << node[n + i - 1] << std::endl;
        }
    }
};
int main() {
    int n,q;cin >> n >> q;
    SegmentTree<int> seg(n,0,[](int a,int b){return a+b;},0);
    vector<int> c(n);
    vector<tuple<int,int,int>> query(q);
    for (int i = 0; i < n; i++) {
        cin >> c[i];
        c[i]--;
    }
    for (int i = 0; i < q; i++) {
        int l,r;cin >> l >> r;
        query[i] = make_tuple(r-1,l-1,i);
    }
    sort(query.begin(), query.end());
    vector<int> ans(q);
    vector<int> last(n,-1);
    int t = 0;
    for (int i = 0; i < n; i++) {
        if (last[c[i]] != -1) {
            seg.update_query(last[c[i]],0);
            seg.update_query(i,1);
        }
        else {
            seg.update_query(i,1);
        }
        last[c[i]] = i;
        while(t < q && get<0>(query[t]) <= i) {
            ans[get<2>(query[t])] = seg.get_query(get<1>(query[t]),get<0>(query[t])+1);
            t++;
        }
    }
    for (int i = 0; i < q; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 19484
#include<iostream>
#include<string>
using namespace std;
int main(){
	int N;
	string dum;
	cin >> N >> dum;
	if(N >=dum.length()){
		cout << dum ;
	}
	else{
		for(int i=0; i<N; i++){
			cout << dum[i];
		}
		cout << "...";
	}
	return 0;
}

Measured memory_bytes: 3044
import itertools
def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(1, N+1):
        for i in range(1, N+1):
            for j in range(1, N+1):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

N, M, R = map(int, input().split()) 
rs = list(map(int, input().split()))

inf = 10**9
d = [[inf for i in range(N+1)] for i in range(N+1)] 
#d[u][v] : 辺uvのコスト(存在しないときはinf)
for i in range(M):
    a, b, c = map(int, input().split())
    d[a][b] = c
    d[b][a] = c
for i in range(1, N+1):
    d[i][i] = 0 #自身のところに行くコストは０
warshall_floyd(d)
ans = inf
for v in itertools.permutations(rs, R):
    dist = 0
    for i in range(R-1):
        dist += d[v[i]][v[i+1]]
    if dist <= ans:
        ans = dist
print(ans)

Measured memory_bytes: 46568
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int mod = int(1e9)+7;

#define inchar			getchar//_unlocked
#define outchar(x)		putchar(x)//_unlocked(x)

template<typename T> void inpos(T &x) {
	x = 0;
	register T c = inchar();
	while(((c < 48) || (c > 57)) && (c != '-')) c = inchar();
	bool neg = false;
	if (c=='-') neg = true;
	for(; c < 48 || c > 57; c = inchar()) ;
	for(; c > 47 && c < 58; c = inchar()) {
		x = (x<<3) + (x<<1) + (c&15);
	}
	if(neg) x = -x;
}

template<typename T> void outpos(T n) {
	if(n < 0) { outchar('-'); n *= -1; }
	char snum[65];
	int i = 0;
	do {
		snum[i++] = n % 10 + '0';
		n /= 10;
	} while(n);
	i = i - 1;
	while (i >= 0) outchar(snum[i--]);
}
double tick() { 
	static clock_t oldticks;
	clock_t newticks = clock();
	double diff = 1.0 * (newticks - oldticks) / CLOCKS_PER_SEC; 
	oldticks = newticks;
	return diff;
}

int main () {
	int r,c;
	// inpos(x); inpos(y);
	cin >> r; cin >> c;
	vector <string > map(r);
	for (int i = 0;i<r;i++) {
		cin >> map[i];
	}
	int t1,t2;
	int distance[r][c];
	distance[0][0] = 1;
	for (int i = 0;i<r;i++) {
		for (int j = 0;j<c;j++) {
			
			if ((i==0) &&( j== 0)) {
				continue;
			}
			distance[i][j] = 0;
			if (map[i][j]=='#') {
				distance[i][j]=0;
				// continue;
			} else {
				(i-1>=0) ? t1 = distance[i-1][j] : t1= 0;
				(j-1>=0) ? t2 = distance[i][j-1] : t2= 0;
				distance[i][j] = t1 + t2;
			}
			distance[i][j] %= mod;
			}


		}
	
	cout << distance[r-1][c-1];
	// for (int i = 0;i <r;i++) {
	// 	for (int j = 0;j<c;j++) {
	// 		cout << distance[i][j] << " ";
	// 	}
	// 	cout <<endl;
	// }


}

Measured memory_bytes: 5248
#include<iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include <stdlib.h>
#include<string>
#include<queue>
#include<algorithm>
#include<math.h>
using namespace std;

long long int N,M,fi,ans;

int main(){
	cin>>N>>M;
	fi=min(N,M/2);
	N-=min(N,M/2);
	M=M-(2*fi);
	fi=fi+(M/4);
	cout<<fi<<endl;
}

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

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//Declare -> ordered_set NAMA;
//Nth smallest integer -> find_by_order(N-1)
//Number of elements less than N -> order_of_key(N)
//Delete N from the set -> erase(N)

#define endl '\n'
#define MOD 1000000007
#define PI 3.141592653
#define fi first
#define sc second
#define pb push_back
#define pbb pop_back

//#pragma GCC optimize("Ofast")
//#pragma GCC target ("string"...)
//#pragma GCC push_options
//#pragma GCC pop_options
//#pragma GCC reset_options
//#pragma GCC optimize ("O3")

typedef long long ll;
typedef long double ld;
typedef pair<int , int> pii;
typedef pair<long long , long long> pll;

void BOOST(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
}
void fcin(int &x){
	bool neg = false;
	register int c;
	x = 0;
	c = getchar();
	if(c=='-'){
		neg = true;
		c = getchar();
	}
	for(;(c>47 && c<58);c=getchar())x = (x<<1)+(x<<3)+c-48;
	if(neg)x*=-1;
}
ll pmod(ll a , ll b){
	if(b==0)return 1;
	ll temp = pmod(a , b/2);
	if(b%2==0)return(temp*temp)%MOD;
	return (((temp*temp)%MOD)*a)%MOD;
}
int R , C , M , X , Y;
map<pii,bool>Grid;
int Row[300005];
int Col[300005];
vector<int>RM;
vector<int>CM;
int Rmax , Cmax;
int main(){
//	BOOST();
	cin>>R>>C>>M;
	for(int i=1;i<=M;i++){
		cin>>X>>Y;
		Grid[{X,Y}] = true;
		Row[X]++;
		Col[Y]++;
	}

	for(int i=1;i<=R;i++)Rmax = max(Rmax , Row[i]);
	for(int i=1;i<=C;i++)Cmax = max(Cmax , Col[i]);
	
	for(int i=1;i<=R;i++){
		if(Row[i]==Rmax)RM.pb(i);
	}
	for(int i=1;i<=C;i++){
		if(Col[i]==Cmax)CM.pb(i);
	}

	int Ans = Rmax + Cmax;
	for(int i=0;i<RM.size();i++){
		for(int j=0;j<CM.size();j++){
			if(!Grid[{RM[i] , CM[j]}]){
				cout<<Ans<<endl;
				return 0;
			}
		}
	}
	cout<<Ans-1<<endl;
	
}







Measured memory_bytes: 28448
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <cstring>

using namespace std;

#define SIZE 400

int sum[SIZE][SIZE];

int solve() {
  int N;
  int l[SIZE], t[SIZE], r[SIZE], b[SIZE];
  vector<int> vecY, vecX;
  map<int,int> dicX, dicY;

  scanf("%d", &N);

  if (N == 0) return false;

  memset(sum, 0, sizeof(sum));

  for (int i=0; i<N; i++) {
    scanf("%d%d%d%d", l+i, t+i, r+i, b+i);
    vecY.push_back(t[i]);
    vecY.push_back(b[i]);
    vecX.push_back(l[i]);
    vecX.push_back(r[i]);
  }

  sort(vecX.begin(), vecX.end());
  sort(vecY.begin(), vecY.end());

  vecX.erase(unique(vecX.begin(), vecX.end()),vecX.end());
  vecY.erase(unique(vecY.begin(), vecY.end()),vecY.end());

  for (int i=0; i<vecX.size(); i++)
    dicX[vecX[i]] = i;
  for (int i=0; i<vecY.size(); i++)
    dicY[vecY[i]] = i;

  for (int i=0; i<N; i++) {
    int x = (dicX[l[i]] + 3) * 2;
    int y = (dicY[b[i]] + 3) * 2;
    int p = (dicX[r[i]] + 3) * 2;
    int q = (dicY[t[i]] + 3) * 2;

    sum[y][x]++;
    sum[y][p+1]--;
    sum[y+1][x+1]--;
    sum[y+1][p]++;
    sum[q][x+1]++;
    sum[q][p]--;
    sum[q+1][x]--;
    sum[q+1][p+1]++;
  }

  for (int i=0; i<300; i++)
    for (int j=0; j<300; j++)
      sum[i][j+1] += sum[i][j];

  for (int i=0; i<300; i++)
    for (int j=0; j<300; j++)
      sum[i+1][j] += sum[i][j];

  int ans = 0;
  /*
  for (int i=0; i<50; i++) {
    for (int j=0; j<50; j++)
      printf("%d", sum[i][j]);
    puts("");
  }
  */
  for (int i=0; i<300; i++) {
    for (int j=0; j<300; j++) {
      if (sum[i][j]) continue;

      queue<pair<int,int> > que;

      que.push({i, j});

      ans++;

      while(que.size()) {
        auto p = que.front();
        que.pop();

        int y = p.first;
        int x = p.second;

        if (sum[y][x]) continue;
        sum[y][x] = true;

        if (y > 0) que.push({y-1, x});
        if (x > 0) que.push({y, x-1});
        if (y < 300) que.push({y+1, x});
        if (x < 300) que.push({y, x+1});
      }
    }
  }

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

  return true;
}

int main() {
  while(solve());
  return 0;
}



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

#define FOR(n)          for(int i=0; i<(int)(n); ++i)
#define FORI(i, s, n)   for(int i=(int)(s); i<(int)(n); ++i)
#define clr(A)          memset(A, 0, sizeof(A))
#define FORP(x)         for(__typeof__((x).begin()) it=(x).begin(); it!=(x).end(); ++it)

#define all(V)          V.begin(),V.end()
#define FF              first
#define SS              second
#define sz(V)           (int)(V).size()
#define pb              push_back
#define pii             pair<int, int>
#define ll              long long
#define ull             unsigned long long
#define clr(A)          memset(A, 0, sizeof(A))

#define input           freopen("input.txt", "r", stdin);
#define sync            {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define dbg(args...)    {string sss(#args);sss+=',';cout<<"-->";debugger::call(all(sss), args);cout<<"\n";}
#define dbgA(A, n)      {cout<<"-->"<<#A<<"=(";FOR(n)cout<<A[i]<<" ";cout<<")\n";}
#define dbgA2(A, n, m)  {cout<<"-->"<<#A<<"=\n";FOR(n){FORI(j, 0, m){cout<<A[i][j]<<" ";}cout<<"\n";}cout<<"\n";}

struct debugger {
    typedef string::iterator si;
    static void call(si it, si ed) {}
    template<typename T, typename ... aT>
    static void call(si it, si ed, T a, aT... rest) {
        string b;
        for(; *it!=','; ++it) if(*it!=' ')b+=*it;
        cout << b << "=" << a << " ";
        call(++it, ed, rest...);
    }
};
/***********************************************************************/

int main(){
#ifdef home
    input;
#endif

    int n, in, ans = 0;
    scanf("%d", &n);
    FOR(n){
        scanf("%d", &in);
        if(in&1) ans++;
    }
    puts(ans&1 ? "NO" : "YES");
}




Measured memory_bytes: 256
import numpy as np

A,B,H,M = map(int,input().split())

T = H*60+M
r1 = T/(12*60) *2*np.pi
r2 = M/60 * 2*np.pi

P1 = A*np.array([np.cos(r1),np.sin(r1)])
P2 = B*np.array([np.cos(r2),np.sin(r2)])
print(np.linalg.norm(P1-P2))

Measured memory_bytes: 27268
N = int(input())
st = [tuple(map(int, input().split())) for i in range(N-1)]
for i in range(N):
  res = 0  
  for j in range(i, N-1):
    c, s, f = st[j]
    if res < s:
      res = s
    else:
      res = -(-res // f) * f
    res += c
  print(res)

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;


int main(void){
  int n,i,r1,r2;
  string s,k="keyence";
  
  cin >> s;
  n=s.size();
  
  i=0;
  while (i<min(n,7) && s[i]==k[i]) i++;
  r1=i;
  
  i=0;
  while (i<min(n,7) && s[n-i-1]==k[6-i]) i++;
  r2=i;
  
  if (r1+r2>=7) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
num, i = map(int, input().split())
if(i != 0):
  s = set(map(int, input().split()))
else:
  s = set()
m = set(range(102))
o = list(m-s)
o2 = list(map(lambda x: abs(x - num), o))
print(o[o2.index(min(o2))])

Measured memory_bytes: 9200
#include <bits/stdc++.h>
#define lli long long int
#define pb(a) push_back(a)
#define forr(a,n) for(lli i=a;i<n;i++)
#define forrr(j,a,n) for(lli j=a;j<n;j++)
#define all(x) x.begin(),x.end()
#define pi2  1.57079632679489661923
using namespace std;
void print(lli a[],lli n){
forr(0,n){cout<<a[i]<<" ";}
cout<<"\n";
}
lli power(lli x){
lli u=0;
while(x%2==0){
    u++;
    x=x/2;
}
return u;
}

lli powM(lli x,lli y,lli m)
{
    lli ans=1,r=1;
    x%=m;
    while(r>0&&r<=y)
    {
        if(r&y)
        {
            ans*=x;
            ans%=m;
        }
        r<<=1;
        x*=x;
        x%=m;
    }
    return ans;
}
int powm(lli a, lli b) {
	lli res = 1;
	while (b) {
		if (b & 1)
			res = (res * a);
		a = (a * a);
		b >>= 1;
	}
	return res;
}
lli gcd(lli a, lli b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
bool isPrime(int n)
{
    // Corner cases
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;

    // This is checked so that we can skip
    // middle five numbers in below loop
    if (n % 2 == 0 || n % 3 == 0)
        return false;

    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;

    return true;
}
/*
vector <lli> adj[100001];
lli vis[100001]={0};
void dfs(lli a){
    vis[a]=1;
    forr(0,adj[a].size()){
    if(vis[adj[a][i]]){continue;}
    else{
        dfs(adj[a][i]);
    }
    }
}
lli level[100001];
void bfs(lli a){
queue <lli> q;
vis[a]=1;
level[a]=0;
q.push(a);
while(!q.empty()){
    lli p=q.front();
    q.pop();
    forr(0,adj[p].size()){
    if(vis[adj[p][i]]==0){
        level[adj[p][i]]=level[p]+1;
        q.push(adj[p][i]);
        vis[adj[p][i]]=1;
    }
    }

}

}

vector <pair<lli,lli> > dj[100001];
lli dist[100001];
vector<lli> ans[100001];
void dijkstra(lli a){
dist[a]=0;
ans[a].pb(a);
multiset<pair<lli,lli> > s;
s.insert({0,a});
while(s.size()!=0){
    lli x=(*s.begin()).second;
    s.erase(s.begin());
    if(vis[x]){continue;}
    vis[x]=1;
    forr(0,dj[x].size()){
    lli e=dj[x][i].first;
    lli we=dj[x][i].second;
    if(dist[x]+we<dist[e]){
        dist[e]=dist[x]+we;
        ans[e].clear();
        ans[e].pb(x);
        s.insert({dist[e],e});
    }
    }
}

}*/

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
   cout.tie(0);
   // freopen("outpu.txt","w",stdout);
int t1=1;
//cin>>t1;
lli M =1e9+7;
while(t1--){
lli n,m,k;
cin>>n>>m>>k;
lli a[n];
lli b[m];
forr(0,n){cin>>a[i];}
forr(0,m){cin>>b[i];}
lli p[n+1]={0};
lli q[m+1]={0};
p[1]=a[0];
q[1]=b[0];
forr(2,n+1){
p[i]=p[i-1]+a[i-1];
}
forr(2,m+1){q[i]=q[i-1]+b[i-1];}
//forr(0,m+1){cout<<q[i]<<" ";}
lli u=0;
lli r=m;
forr(0,n+1){
    if(p[i]>k){break;}
while(q[r]>k-p[i]){
    r--;
}
//cout<<i<<" "<<r<<"\n";
if(q[r]+p[i]<=k){
u=max(u,i+r);}
}
cout<<u;
}
     return 0;
}


Measured memory_bytes: 9904
def input_n
  gets.to_i               # 単一整数
end

def input_s
  gets.chomp              # 文字列。chompを付けないと改行文字がついてくる
end

def input_a
  gets.split.map(&:to_i)  # スペースで区切られた複数の整数
end

def input_o(num)
  num.times.map { gets.to_i }  # 縦に並んだ複数の整数。たまにある
end

def output_f(num)
  puts sprintf("%.12f", num)
end

n = input_n
a = input_a
sum = 1
cnt = a.count(0)
if cnt > 0
  puts 0
  exit
end
a.each do |num|
  sum = sum * num
  if sum > (10 ** 18)
    puts -1
    exit
  end
end
puts sum


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

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

int main(){
    int n;cin>>n;
    int array[n];
    rep(i,n)array[i]=i+1;
    
    int x[n],y[n];
    rep(i,n)cin>>x[i]>>y[i];

    int cc=0,cc1,cc2;
    double ans=0;
    
    do{
        cc++;
        double tmp=0;
        rep(i,n-1){
            double tmp1 = x[array[i+1]-1]-x[array[i]-1];
            double tmp2 = y[array[i+1]-1]-y[array[i]-1];
            tmp+=sqrt(tmp1*tmp1 + tmp2*tmp2);
        }
        tmp;
        ans+=tmp;
    }while(next_permutation(array,array + n));
    ans/=cc;
    cout<<setprecision(16)<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
// AtCode.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>

using namespace std;



int main() {
	int X = 0;
	cin >> X;
	vector<int> prime_number;
	bool is_candidate[200000];
	for (int i = 0; i < 200000; i++) {
		is_candidate[i] = true;
	}
	is_candidate[0] = false;
	is_candidate[1] = false;

	for (int i = 0; i < 200000; i++) {
		if (is_candidate[i]==false) {
			continue;
		}
		else {
			prime_number.push_back(i);
			int factor = 1;
			while (i * factor < 200000) {
				is_candidate[i * factor] = false;
				factor++;
			}
		}
		if (i >= X && prime_number[prime_number.size() - 1] >= X) {
			cout << i << endl;
			return 0;
		}

	}

	return 0;

}


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

int main(){
    string s,t;
    cin >> s >> t;
    sort(s.begin(),s.end());
    sort(t.rbegin(),t.rend());
    //cout << s << endl << t << endl;
    int i = 0;
    while(i < min((int)s.length(),(int)t.length())){
		if(s[i]<t[i]){cout << "Yes"; return 0;}
		if(s[i]>t[i]){cout << "No"; return 0;}
		i++;
		}
	
	if(i < (int)s.length()) cout << "No";
	else if(i==(int)s.length() && i==(int) t.length()) cout << "No";
	else cout << "Yes";
		
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

void solve(int) {
  int64 n;
  cin >> n;
  int64 a = 100;
  int ans = 0;
  for (; a < n; a += a / 100, ++ans);
  cout << ans << '\n';
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}




Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
typedef long long int ll;
typedef pair<int, int> P;
#define INF 1e9 + 7

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

    int n,m;
    cin >> n >> m;
    int l[m], r[m];
    rep(i,m) cin >> l[i] >> r[i];
    
    int left = 1, right = n;
    
    rep(i, m){
        if(l[i] > left){
            left = l[i];
        }
        if(r[i] < right){
            right = r[i];
        }
    }
    
    cout << max(right - left + 1, 0) << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template <typename T> constexpr bool chmax(T &a, const T b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

char input() {
    string s;
    cin >> s;
    if(s == "-1") exit(0);
    return s[0];
}

string solve(const int &N) {
    string s(2 * N + 1, ' ');
    int l = 1, r = N + 1;
    cout << "?";
    FOR(i, 1, N + 1) cout << " " << i;
    cout << endl;
    char first = input();
    while(l + 1 < r) {
        int mid = l + r >> 1;
        cout << "?";
        FOR(i, mid, mid + N) cout << " " << i;
        cout << endl;
        (input() == first ? l : r) = mid;
    }
    s[l] = first;
    s[l + N] = 'R' + 'B' - first;
    vector<int> x, y;
    FOR(i, 1, l) {
        x.push_back(i);
        y.push_back(i + N);
    }
    FOR(i, r, N + 1) {
        y.push_back(i);
        x.push_back(i + N);
    }
    int sumx = ('R' + 'B') * x.size() / 2;
    int sumy = sumx;
    for(int i : x) {
        if(i == x.back()) {
            s[i] = sumx;
            break;
        }
        cout << "? " << i;
        for(int j : y)
            cout << " " << j;
        cout << endl;
        s[i] = input();
        sumx -= s[i];
    }
    for(int i : y) {
        if(i == y.back()) {
            s[i] = sumy;
            break;
        }
        cout << "? " << i;
        for(int j : x)
            cout << " " << j;
        cout << endl;
        s[i] = input();
        sumy -= s[i];
    }
    return "!" + s;
}

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

    int N;
    cin >> N;

    cout << solve(N) << endl;

    return 0;
}

Measured memory_bytes: 724
n=int(input())
a=[[int(x)-1 for x in input().split()] for _ in range(n)]

cnt=0
id=[[0]*n for _ in range(n)]
for i in range(n):
	for j in range(i+1,n):
		id[i][j] = cnt
		cnt+=1
def toid(x,y):
	return id[x][y] if x<y else id[y][x]

for i in range(n):
	for j in range(n-1):
		a[i][j] = toid(i,a[i][j])

nedge = n*(n-1)//2
g=[[]for _ in range(nedge)]
to = [0]*nedge
for i in range(n):
	for j in range(1,n-1):
		g[a[i][j-1]].append(a[i][j])
		to[a[i][j]]+=1

from collections import deque

dp=[1]*nedge
q=deque([])
cnt = 0
for i in range(nedge):
	if to[i]==0:
		q.append(i)
		cnt+=1

ans = 1
while(q):
	e = q.popleft()
	for ne in g[e]:
		dp[ne] = max(dp[ne],dp[e]+1)
		to[ne]-=1
		if to[ne]==0:
			q.append(ne)
			cnt+=1
	ans = max(ans,dp[e])

if cnt != nedge:
	print(-1)
else:
	print(ans)

Measured memory_bytes: 123696
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
 
  int L = A + B, R = C + D;
  if (L > R) {
    cout << "Left" << endl;
  }
  else if(L == R){
  	cout << "Balanced" << endl;
  }
  else{
  	cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
def gcd(a,b):
    while b:a,b=b,a%b
    return a
def lcm(a,b):
    return a*b//gcd(a,b)

N = int(input())
A = tuple(map(int,input().split(" ")))
ans = 0
mod = 10**9+7
l = 1
for i in range(N):
    l = lcm(l,A[i])
l %= mod

for i in A:
    ans += l*pow(i,mod-2,mod)
    ans %= mod

print(ans)

Measured memory_bytes: 4084
#include <climits>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <set>
#include <map>
#include <deque>
#include <queue>
#define px first
#define py second
#define fi first
#define se second
#define LD long double

//#define DEBUG
#ifdef DEBUG
#include "Debug.h"
#endif // DEBUG

using namespace std;

const int INF = INT_MAX;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> n >> m;
    vector<string> a(n);
    vector<int> x(n, 1);
    vector<int> y(m, 1);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        for (int j = 0; j < m; j++) {
            if (a[i][j] == '#'){
                x[i] = 0;
                y[j] = 0;
            }
        }
    }
    for (int i = 0; i < n; i++) {
        if (x[i]) {
            continue;
        }
        for (int j = 0; j < m; j++) {
            if (y[j]) {
                continue;
            }
            cout << a[i][j];
        }
        cout << endl;
    }
    return 0;
}


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

typedef long long ll;

int main(){
    ll H,W;
    cin >> H >> W;
    if(H%3==0||W%3==0){
        cout << 0 << endl;
        return 0;
    }
    ll ans=10000000000;
    ll s[3];
    for(ll h=1;h<H;h++){
        s[0]=h*W;
        s[1]=(H-h)*(W/2);
        s[2]=(H-h)*(W-W/2);
        sort(s,s+3);
        if(ans>s[2]-s[0]){
            ans=s[2]-s[0];
        }
    }
    //cout << ans << endl;
    for(ll w=1;w<W;w++){
        s[0]=w*H;
        s[1]=(W-w)*(H/2);
        s[2]=(W-w)*(H-H/2);
        sort(s,s+3);
        if(ans>s[2]-s[0]){
            ans=s[2]-s[0];
        }
    }
    for(ll h=1;h<H;h++){
        s[0]=h*W;
        s[1]=((H-h+1)/2)*W;
        s[2]=((H-h)/2)*W;
        sort(s,s+3);
        if(ans>s[2]-s[0]){
            ans=s[2]-s[0];
        }
    }
    for(ll w=1;w<W;w++){
        s[0]=w*H;
        s[1]=((W-w+1)/2)*H;
        s[2]=((W-w)/2)*H;
        sort(s,s+3);
        if(ans>s[2]-s[0]){
            ans=s[2]-s[0];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;

int main() {
	int n;
	cin >> n;
	vector<ll> L(n), R(n);
	rep(i, n) {
		ll a;
		cin >> a;
		L[i] = i + a;
		R[i] = i - a;
	}
	map<ll, int> map;
	ll ans = 0;
	rep(i, n) {
		ans += map[R[i]];
		map[L[i]]++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 29008
#include <cstdio>

int main(void)
{
  int n, l;
  scanf("%d %d", &n, &l);
  if (l > 0)
    printf("%d\n", l * (n - 1) + n * (n - 1) / 2);
  else if (l + n - 1 < 0)
    printf("%d\n", (l - 1) * (n - 1) + n * (n - 1) / 2);
  else
    printf("%d\n", l * n + n * (n - 1) / 2);
  return 0;
}


Measured memory_bytes: 128
# -*- coding: utf-8 -*-
"""
Created on Sun May 17 20:55:35 2020

@author: Kei
"""

N = input().split()

jud = int(str(N)[-3])


if jud == 2 or jud == 4 or jud == 5 or jud == 7 or jud == 9:
    print("hon")
elif jud == 0 or jud == 1 or jud == 6 or jud == 8:
    print("pon")
else:
    print("bon")

Measured memory_bytes: 9116
import Data.List (sortBy)

sortAsc::[Int]->[Int]
sortAsc = sortBy compare

sortDesc::[Int]->[Int]
sortDesc = sortBy $ flip compare

main = do
  [n,m] <- map read . words <$> getLine::IO[Int]
  xn <- map read . words <$> getLine::IO[Int]
  let sortPoints = sortAsc xn
  let overallWidth = last sortPoints - head sortPoints
  let diff = sortDesc . map abs $ zipWith (-) sortPoints $ tail sortPoints
  let result = overallWidth - (sum $ take (n-1) diff)
  print $ result

Measured memory_bytes: 33404
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
    int a[6],b[6],min=10000000;
    for(int i=0;i<3;i++)cin>>a[i];
    for(int i=0;i<2;i++)cin>>b[i];
    for(int i=0;i<3;i++)
    {
        for(int j=0;j<2;j++)
        {
            if(i!=j)
            {
                if(min>=a[i]+b[j])min=a[i]+b[j];
            }
        }
    }
    cout<<min-50<<endl;
    return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main() {
	string roop;
	string letter;
	int count = 0;

	cin >> roop;

	std::size_t n = roop.size();
	
	letter = roop;
	reverse(roop.begin(),roop.end());
	
	for (int i = 0; i < n/2; i++) {
		
			if (roop[i] != letter[i]) {
				
				count += 1;
			}
		
	}
	cout<<count<<endl;
}



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

int main(){
  int n,m,x;
  cin >> n >> m >> x;
  int a[n];
  int plus=0;
  int minus=0;
  for(int i=0;i<m;i++){
    cin >> a[i];
  }
  for(int i=x;i<=n;i++){
    for(int j=0;j<m;j++){
      if(i == a[j]){
        plus++;
      }
    }
  }
  for(int i=x;i>=0;i--){
    for(int j=0;j<m;j++){
      if(i == a[j]){
        minus++;
      }
    }
  }
  if(minus<plus){
    cout << minus << endl;
  }else{
    cout << plus << endl;
  }
  return 0;
}


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

int sum_digits(int num){
  int res = 0;
  while(num > 0) {
    res += num % 10;
    num = num / 10;
  }
  return res;
}

int main(){
  int x;
  cin >> x;
  int sum = sum_digits(x);
  if(x % sum == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
int main()
{
    int n;
    cin>>n;
    int a[2005];
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    ll ans=(ll)n*(n-1)*(n-2)/6;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            int l=j,r=n;
            while(l+1<r)
            {
                int mid=l+(r-l)/2;
                if(a[mid]>=a[i]+a[j])
                    r=mid;
                else l=mid;
            }

            //cout<<ans<<'\n';
            ans=ans-(n-r);
        }
    }
    cout<<ans<<'\n';
}


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

const double PI = 3.14159265358979;

inline double d2r(double d)
{
  return d * PI / 180.0;
}

int main()
{
  const double R = 6378.1;

  double a, b, c, d;
  while (cin >> a >> b >> c >> d) {
    if (a == -1.0 && b == -1.0 && c == -1.0 && d == -1.0)
      break;

    a = d2r(a);
    b = d2r(b);
    c = d2r(c);
    d = d2r(d);

    double thita = acos(cos(a)*cos(c)*cos(b-d) + sin(a)*sin(c));

    cout << static_cast<int>(thita * R + 0.5) << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
int a[10];
int main()
{
  int n,i,j,k,t;
  scanf("%d",&n);
  while(n>0){
    for(i=0;i<10;i++){
      scanf("%d",&a[i]);
    }
    t = 1;
    for(i=0;i<8;i++){
      for(j=i+1;j<9;j++){
	if(a[i]>a[j]){
	  for(k=j+1;k<10;k++){
	    if(a[j]>a[k]) t = 0;
	  }
	}
      }
    }
    if(t) printf("YES\n");
    else printf("NO\n");
    n--;
  }
  return 0;
}

Measured memory_bytes: 0
// ABC061
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>

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

typedef long long ll;

int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    if(A <= C && C <= B) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long ll;
int main(){
  ll n,k,sum=0;
  cin >> n >> k;
  ll x[n];
  for(int i=0;i<n;i++){
    cin >> x[i];
    sum += min(x[i]*2,(k-x[i])*2);
  }
  cout <<sum<<endl;
}


Measured memory_bytes: 256