akhauriyash/Code-Regression huggingface dataset:
// "header" {{{
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <tuple>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int>
#define int int64_t
#define Fixed fixed << setprecision(10)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;

inline double Sqrt( const double &x)
{
        double         xHalf = 0.5 * x;
        int64_t  tmp   = 0x5FE6EB50C7B537AAl - ( *(int64_t*)&x >> 1);
        double         xRes  = * (double*)&tmp;

        xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
        xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
        xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
        xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
        return xRes * x;
}
// }}}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,q;
    cin >> n >> m >> q;
    vector<vector<int>  > pos(n+1,vector<int>(n+1));
    rep(i,m){
        int l,r;
        cin >> l >> r;
        pos[l][r]++;
    }
    reps(i,n){
        reps(j,n-1){
            pos[i][j+1] += pos[i][j];
        }
    }
    rep(loop,q){
        int a,b;
        int cnt = 0;
        cin >> a >> b;
        for(int i = a;i <= b;++i){
            cnt += pos[i][b];
        }
        cout << cnt << '\n';
    }


    return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

  vector<vector<int> > X(200000, vector<int>(20,0));
  vector<vector<int> > S(200002, vector<int>(20,1145141919));

bool solve(int r,int l){
  REP(j,20){
    if (S[r][j] - S[l][j] >= 2)
    {
      return false;
    }
  }
  return true;
}

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

  REP(i,N){
    int A;
    cin >> A;
    REP(j,20){
      X[i][j] = A % 2;
      A /= 2;
    }
  }

  REP(j,20){
    S[0][j] = 0;
  }

  REP(i,N){
    REP(j,20){
      S[i + 1][j] = S[i][j] + X[i][j];
    }
  }



  LL sum = 0;

  REP(i, N)
  {
    int ok =i;
    int ng = 200001;
    while (abs(ok - ng) > 1)
    {
      int mid = abs(ok + ng) / 2;
      if (solve(mid, i))
      {
        ok = mid;
      }else{
        ng = mid;
      }
    }
    sum += ok - i;
  }

  cout << sum << endl;
}


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  int k;
  while (cin >> n >> k) {
    vector<lli> h(n);
    cin >> h;
    const int N = 1e5 + 5;
    lli dp[N];
    const lli inf = 1LL << 60;
    fill(dp, dp + N, inf);
    dp[0] = 0;
    for (int i = 0; i < n; ++i) {
      for (int j = 1; j <= k; ++j) {
        if (i + j < n) setmin(dp[i + j], dp[i] + abs(h[i] - h[i + j])); 
      }
    }
    cout << dp[n - 1] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 1792
# AOJ 0155 Spider Jin
# Python3 2018.6.23 bal4u
# 最短経路問題

MAXLEN = 50
MAX = 100
INF = 0x7ffffffffffffff
x = [0]*(MAX+2)
y = [0]*(MAX+2)
dist = [INF]*(MAX+2)
pre = [0]*(MAX+2)
	
import heapq
def dijkstra(V, to, start, goal):
	global dist
	dist = [INF]*V
	Q = []
	dist[start] = 0
	heapq.heappush(Q, (0, start))
	while Q:
		t, s = heapq.heappop(Q)
		if s == goal: break
		if dist[s] < t: continue
		for e, cost in to[s]:
			nt = t + cost
			if dist[e] > nt:
				dist[e] = nt
				heapq.heappush(Q, (nt, e))
				pre[e] = s
while 1:
	n = int(input())
	if n == 0: break
	for i in range(n):
		j, x_, y_ = map(int, input().split())
		x[j], y[j] = x_, y_
	n += 1
	to = [[] for i in range(n)]
	for i in range(1, n):
		for j in range(i+1, n):
			dx, dy = x[i]-x[j], y[i]-y[j]
			cost = (dx**2 + dy**2)**0.5
			if cost <= MAXLEN:
				to[i].append((j, cost))
				to[j].append((i, cost))
	m = int(input())
	for i in range(m):
		s, g = map(int, input().split())
		if s == g: print(s)
		else:
			dijkstra(n, to, s, g)
			if dist[g] == INF: print("NA")
			else:
				ans = []
				ans.append(g)
				while g != s:
					g = pre[g]
					ans.append(g)
				print(*ans[::-1])
	


Measured memory_bytes: 5772
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int a[100001];
int ans,n;
bool flag;

int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++) 
		cin >> a[i];
    for(int i = 1; a[i] != i; i = a[i])
	{
        ans++;
        if(a[i] == 2)
		{
            flag = true;
            break;
        }
        if(ans > n)
			break;
    }
    if(flag) 
		cout<< ans << endl;
    else 
		cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 640
#!/usr/bin/env pypy3
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]

s=input()
if s[2]==s[3] and s[4]==s[5]:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 5036
#include <cstdio>
#include <iostream>


int main()
{
    long long int A, B;
    int N;
    scanf("%d %lld %lld", &N, &A, &B);
    long long ans = 0;
    /*
    int a;
    int b;
    scanf("%d", &a);

    for (int i = 1; i < N; i++) {
        scanf("%d", &b);
        if ((b - a) * A < B) {
            ans += (b - a) * A;
        } else {
            ans += B;
        }
        a = b;
    }
	*/
    int s[100000];
    for (int i = 0; i < N; i++) {
        scanf("%d", &s[i]);
    }
    for (int i = 0; i < N - 1; i++) {
        ans += std::min((s[i + 1] - s[i]) * A, B);
    }

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

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
template<class T> inline int chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline int chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1<<30;
const ll LINF = 1LL<<58;

void solve() {
    int n;
    map<string, bool> mp;
    cin >> n;
    rep(i, n) {
        string s;
        cin >> s;
        mp[s] = 1;
    }
    int ans = 0;
    for(auto x : mp)ans++;
    cout << ans << endl;
    return;
}

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


Measured memory_bytes: 19256
#!/usr/bin/env python3
import sys
import itertools

def solve(N: int, K: int, x: "List[int]", y: "List[int]"):
    answer = 10**19

    x_set = sorted(list(set(x)))
    y_set = sorted(list(set(y)))
    x_combination = list(itertools.combinations(x_set,2))
    y_combination = list(itertools.combinations(y_set,2))

    
    for x_l, x_u in x_combination:
        for y_l, y_u in y_combination:
            count = 0
            for i in range(N):
                if y_l <= y[i] <= y_u and x_l <= x[i] <= x_u:
                    count +=1
            if count >= K:
                answer = min(answer,(y_u-y_l)*(x_u-x_l))

    print(answer)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]"
    y = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    solve(N, K, x, y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 42860
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n;
  cin >> n;

  cout << 3*n*n << endl;

  return 0;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

string smap[2010];

pair<int, int> L[2010][2010];

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

	int H, W;
	cin >> H >> W;

	rep(i, 0, H)
	{
		cin >> smap[i];
		int c = 0;
		rep(j, 0, W)
		{
			if (smap[i][j] == '.')
			{
				c++;
			}
			if (smap[i][j] == '#')
			{
				rep(k, 0, c)
				{
					L[i][j - k - 1].first = c;
				}
				c = 0;
			}
			if (j == W - 1)
			{
				rep(k, 0, c)
				{
					L[i][j - k].first = c;
				}
			}
		}
	}

	rep(j, 0, W)
	{
		int c = 0;
		rep(i, 0, H)
		{
			if (smap[i][j] == '.')
			{
				c++;
			}
			if (smap[i][j] == '#')
			{
				rep(k, 0, c)
				{
					L[i - k - 1][j].second = c;
				}
				c = 0;
			}
			if (i == H - 1)
			{
				rep(k, 0, c)
				{
					L[i - k][j].second = c;
				}
			}
		}
	}

	int ans = 1;

	rep(i, 0, H)rep(j, 0, W)
	{
		chmax(ans, L[i][j].first + L[i][j].second - 1);
	}

	cout << ans << endl;

	return 0;
}

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

#define MAX_NUM (1000000000 + 7)

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

u64 dec_dig(u64 num) {
  u64 res = 0;
  while (num > 0) {
    num /= 10;
    ++res;
  }
  return res;
}

u64 gcd(u64 a, u64 b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

  return b ? gcd(b, a % b) : a;
}

int main() {
  cout << setprecision(18);
  u64 N, K;
  cin >> N >> K;
  N %= K;
  u64 tmp = K - N;
  if (tmp > N) {
    cout << N << endl;
  } else {
    cout << tmp << endl;
  }
}


Measured memory_bytes: 256
import math

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

A_min = math.ceil(A/0.08)
A_max = math.ceil((A+1)/0.08)-1
B_min = math.ceil(B/0.1)
B_max = math.ceil((B+1)/0.1)-1

MIN = max([A_min, B_min])
MAX = min([A_max, B_max])

if MIN > MAX:
    print(-1)
    print('\n')
else:
    print(MIN)
    print('\n')

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
 
typedef vector<int> vi;;
typedef vector<ll> vll;

#define l() length()
#define sz() size()
 
#define b() begin()
#define e() end()
#define all(x) x.begin(), x.end()
 
#define pb(i) push_back(i)
#define PB() pop_back()
 
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
#define mp make_pair
#define Fi first
#define Se second
 
const int maxx=1e6+9;
 
// Happy Coding!

ll a,b,ab;
// a->     cost of 1A pizza
// b->     cost of 1B pizza
// ab->    cost of 1A+1B pizza(combined)

ll _find(ll x,ll y){
   
   // buying zero pizzas of size AB
   ll ans=a*x + b*y;
   for(int i=1;i<=max(x,y);i++){
       ll cost=i*ab;
       if(x>i){
           cost += (x-i)*a;
       }
       if(y>i){
           cost += (y-i)*b;
       }
       ans=min(ans,cost);
   }
   return ans;
}

void solve(){
    ll n,m;
    cin>>a>>b>>ab>>n>>m;
    ab*=2;
    
    cout<<_find(n,m);
}





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

Measured memory_bytes: 3644
//c++ テンプレ
#include<bits/stdc++.h>
using namespace std;

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

llint calc(llint x){
    return x*(x+1)/2;
}
void solve(){
    llint n;
    cin >> n;
    llint ans=0;
    for(int i=1;i<=n;i++){
        ans+=calc(n/i)*i;
    }
    cout << ans << endl;
}

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




Measured memory_bytes: 3516
H,W = map(int,input().split())
A = []
for i in range(H):
    a = list(input())
    if a.count('.') == W:
        H -= 1
        continue
    A.append(a)

skipcol = []
for i in range(W):
    t = 0
    for j in range(H):
        if A[j][i] == '.':
            t += 1
    if t == H: skipcol.append(i)

for i in range(H):
    for j in range(W):
        if j in skipcol: continue
        print(A[i][j],end='')
    print()

Measured memory_bytes: 4596
import sys
sys.setrecursionlimit(500000)

N = int(input())
E = [[] for _ in range(N+1)]
for n in range(N-1):
    a,b = map(int, input().split())
    E[a].append((b,n))
    E[b].append((a,n))

K = max(len(e) for e in E)
print(K)

res = [-1 for _ in range(N-1)]
def dfs(v=1, p=0, p_col=-1):
    col = 1
    for child, idx in E[v]:
        if(child != p):
            if(col == p_col):
                col += 1
            res[idx] = col
            dfs(child,v,col)
            col += 1
dfs()
print("\n".join(map(str, res)))


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

using namespace std;

int h, w, c;
int p[8][8];
int cnt, ans;

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

bool done[8][8];

void cntclr(int x, int y, int f, int t)
{
  if(p[y][x] != f) return;
  done[y][x] = true;
  p[y][x] = t; cnt++;
  for(int i = 0; i < 4; i++) {
    int nx = x + dx[i], ny = y + dy[i];
    if(0 <= nx && nx < w && 0 <= ny && ny < h && !done[ny][nx]) cntclr(nx, ny, f, t);
  }
}

void solve(int lim)
{
  if(lim <= 0) {
    memset(done, false, sizeof(done));
    cnt = 0; cntclr(0, 0, c, -1);
    ans = max(cnt, ans);
    return;
  }
  int q[8][8];
  for(int d = 1; d <= 6; d++) {
    for(int i = 0; i < h; i++) {
      for(int j = 0; j < w; j++) q[i][j] = p[i][j], done[i][j] = false;
    }
    cnt = 0; cntclr(0, 0, p[0][0], d); solve(lim-1);
    for(int i = 0; i < h; i++) {
      for(int j = 0; j < w; j++) p[i][j] = q[i][j], done[i][j] = false;
    }
  }
}

int main()
{
  while(cin >> h >> w >> c, h) {
    for(int i = 0; i < h; i++) {
      for(int j = 0; j < w; j++) cin >> p[i][j];
    }
    ans = 0; solve(5);
    cout << ans << endl;
  } 
  return 0;
}

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

int main() {
	int A,B;
	cin >> A >> B;
	if(A<=5){
		cout << "0" <<endl;
	}else if(A<=12){
		cout << B/2 << endl;
	}else{
		cout << B << endl;
	}
	return 0;
}

Measured memory_bytes: 256
fn main() {
  let stdin = std::io::stdin();
  let mut buf = String::new();
  stdin.read_line(&mut buf).unwrap();

  let mut ite = buf.trim().split_whitespace()
    .map(|x| x.parse::<f64>().unwrap());

  let x1 = ite.next().unwrap();
  let y1 = ite.next().unwrap();
  let x2 = ite.next().unwrap();
  let y2 = ite.next().unwrap();

  println!("{}", (x1 - x2).hypot(y1 - y2));
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max<R>(x,0.0));}

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

// Problem Specific Parameter:

int a[100010];

int main(void){
	int n;
	cin >> n;
	rep(i,n) cin >> a[i],a[i]--;

	int ans=0;
	rep(i,n){
		if(a[i]==-1) continue;
		int tar=a[i];
		if(a[tar]==i){
			a[tar]=-1;
			ans++;
		}
		a[i]=-1;
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i,n) for(int i=1;i<=n;++i)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  if (a+b<10) cout << a+b << endl;
  else cout << "error" << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const ll INF = 1LL<<60;
//int INF = numeric_limits<int>::max();
void getZarr(string str, int Z[]) 
{ 
    int n = str.length(); 
    int L, R, k; 
  
    // [L,R] make a window which matches with prefix of s 
    L = R = 0; 
    for (int i = 1; i < n; ++i) 
    { 
        // if i>R nothing matches so we will calculate. 
        // Z[i] using naive way. 
        if (i > R) 
        { 
            L = R = i; 
  
            // R-L = 0 in starting, so it will start 
            // checking from 0'th index. For example, 
            // for "ababab" and i = 1, the value of R 
            // remains 0 and Z[i] becomes 0. For string 
            // "aaaaaa" and i = 1, Z[i] and R become 5 
            while (R<n && str[R-L] == str[R]) 
                R++; 
            Z[i] = R-L; 
            R--; 
        } 
        else
        { 
            // k = i-L so k corresponds to number which 
            // matches in [L,R] interval. 
            k = i-L; 
  
            // if Z[k] is less than remaining interval 
            // then Z[i] will be equal to Z[k]. 
            // For example, str = "ababab", i = 3, R = 5 
            // and L = 2 
            if (Z[k] < R-i+1) 
                Z[i] = Z[k]; 
  
            // For example str = "aaaaaa" and i = 2, R is 5, 
            // L is 0 
            else
            { 
                // else start from R and check manually 
                L = i; 
                while (R<n && str[R-L] == str[R]) 
                    R++; 
                Z[i] = R-L; 
                R--; 
            } 
        } 
    } 
} 
int main(int, char**) {
	int n; cin >> n;
	string s; cin >> s;
	int ret = 0;
	for (int i=0; i<n; i++) {
		string s1 = s.substr(i, n-i);
		int Z[n - i];
		getZarr(s1, Z);
		for (int j=1; j<n-i; j++) ret = max(ret, min(j, Z[j]));
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 3704
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define int ll
#define endl "\n"
#define all(c) (c).begin(),(c).end()
#define loopinc(i, a, b, inc) for(int i = a; i < (b); i += inc)
#define loop(i, a, b) for(int i = a; i < (b); i++)
#define rep(i, n) loop(i, 0, n)
//#define lloopinc(i, a, b, inc) for(ll i = a; i < (b); i += inc)
//#define lloop(i, a, b) for(ll i = a; i < (b); i++)
//#define lrep(i, n) lloop(i, 0, n)
typedef pair<int, int> pii;
//typedef pair<ll, ll> pll;
typedef vector<int> vi;
//typedef vector<ll> vll;
typedef tuple<int, int, int> tiii;
//void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

int dist(int x, int y) { return abs(x-y); }

int n;
vi arr;
vector<pii> pref;
vector<pii> suff;

void solve() {
	pref.resize(n+1);
	suff.resize(n+1);

	int mid = 1;
	int l = arr[0];
	int r = arr[1];
	pref[2] = {l, r};
	loop(rb, 3, n+1) {
		r += arr[rb-1];
		int m = arr[mid];
		while (dist(l+m, r-m) < dist(l, r)) {
			l += m;
			r -= m;
			mid++;
			m = arr[mid];
		}
		pref[rb] = {l, r};
	}
	
	l = arr[n-2];
	r = arr[n-1];
	mid = n-1;
	suff[n-2] = {l, r};
	for (int lb = n-3; lb >= 0; lb--) {
		l += arr[lb];
		int m = arr[mid-1];
		while (dist(l-m, r+m) < dist(l, r)) {
			l -= m;
			r += m;
			mid--;
			m = arr[mid-1];
		}
		suff[lb] = {l, r};
	}
	
	int best = LLONG_MAX;
	loop(i, 2, n-1) {
		best = min(best,
			max(max(pref[i].first, pref[i].second), max(suff[i].first, suff[i].second)) -
			min(min(pref[i].first, pref[i].second), min(suff[i].first, suff[i].second))
		);
	}
	cout << best << endl;
}

signed main() {
	// freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> n;
	arr.resize(n);
	rep(i, n) cin >> arr[i];
	solve();
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N;
  cin >> N;
  vector<int> v;
  rep(i,N){
    int a;
    cin >> a;
    a--;
    v.push_back(a);
  }

  int ret = 100000000;
  {
    int tmp = 0;
    vector<int> w = v;
    rep(i,N){
      if(i==N-1 && i==w[i]){
        tmp++;
      }else{
        if(i==w[i]){
          swap(w[i],w[i+1]);
          tmp++;
        }
      }
    }
    ret = min(ret, tmp);
  }
  {
    int tmp = 0;
    vector<int> w = v;
    for(int i=N-1; i>=0; i--){
      if(i==0 && i==w[i]){
        tmp++;
      }else{
        if(i==w[i]){
          swap(w[i],w[i-1]);
          tmp++;
        }
      }
    }
    ret = min(ret, tmp);
  }

  cout << ret << endl;
    
  return 0;
}


Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int dp[9];
    int n,a,F =0;
    for(int i=0; i<9; i++) cin>>dp[i];
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>a;
        for(int j=0; j<9; j++)
            if(dp[j]==a) dp[j]=0;
    }
    if(dp[0]==0&&dp[4]==0&&dp[8]==0) F=1;
    else if(dp[2]==0&&dp[4]==0&&dp[6]==0)F=1;
    for(int i=0; i<3; i++)
        if(dp[i]==0&&dp[i+3]==0&&dp[i+6]==0) F=1;
    for(int i=0; i<7; i+=3)
        if(dp[i]==0&&dp[i+1]==0&&dp[i+2]==0) F=1;
    F?cout<<"Yes"<<endl:cout<<"No"<<endl;
}


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

int main() {
  string s;
  cin >> s;
  for (int i = 0; i < (int) s.length(); ++i) {
    if (s[i] == '?') s[i] = 'D';
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3756
n,k = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]


t = [0] * (n+k+1)
for i in range(n):
    t[i+1] = t[i] + p[i]

ans = 0
for i in range(n):
    ans = max(ans, t[i+k]-t[i])
print((ans+k)/2)

Measured memory_bytes: 25188
S = input()

length = len(S) - 1
ans = 0

for i in range(2 ** length):
    bit = bin(i)[2:].zfill(length)
    T = ""
    for j in range(len(S)):
        if j == 0:
            T += S[j]
            continue
        else:
            b = bit[j-1]
            if b == "1":
                T += "+"
            else:
                T += "-"
            T += S[j]
    if eval(T) == 7:
        print(T+"=7")
        exit()



Measured memory_bytes: 3060
inputs=input().split()
N=int(inputs[0])
T=int(inputs[1])
q=[]

for i in range (N):
    inputs=input().split()
    q.append((int(inputs[0]),int(inputs[1])))
q.sort()
f=True
for i in range (N):
    v=q[i][0]
    b=q[i][1]
    if b <= T:
        T=b
        f=True
        break
    else :
        f= False
        



if f== True :   
     print (v)
else :
     print("TLE")

Measured memory_bytes: 3064
#include <iostream>
#include <string.h>
#include <algorithm>
#include <set>
#include <vector>
#include <climits>
#include <map>
#include <queue>
#include <math.h>
#include <iomanip>

#define sqr(A) ((A) * (A))
#define F first
#define S second
#define MP make_pair
#define bsz  __builtin_popcount
#define all(A) A.begin(), A.end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
const int MOD2 = 1e9 + 9;
const int PR = 727;
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;

const int N = 1e2 + 20;
ll a[N], n, x, ans;

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> x;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a + n);
	for (int i = 0; i < n - 1; i++)
		if (a[i] <= x)
			x -= a[i], ans++;
	if (a[n - 1] == x)
		ans++;
	cout << ans << endl;
}




































Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <stack>
#include <queue>
#include <cmath>
 
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define repp(i,j,k) for(int i=j;i>=k;i--)
#define Sort(x) sort(x.begin(),x.end()); 
#define ll long long
int mod=1e9+7;
const int INF = 1e9;
 
using namespace std;
 
int main(void) {
	int n,m;
	cin>>n>>m;
	vector<int> tar(m),score(n,0);
	rep(i,0,m)cin>>tar[i];
	
	rep(i,0,m){
	    int count =0;
	    rep(j,0,n){
	        int x;
	        cin>>x;
	        if(x==tar[i]){
	           score[j]++;
	           count++;
	        }
	    }
	    score[tar[i]-1]+=n-count;
	}
	
	rep(i,0,n){
	 cout<<score[i]<<endl;   
	}
	
	
	
 
 
	return 0;
}

Measured memory_bytes: 3108
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
using namespace std;
int main(){
// Seiranchan!
    int N;
    cin >> N;
    string S;
    cin >> S;
    int cnt,cnt_ans=0;
    
   

    for(int i=1;i<N;i++){
        cnt =0;
        map <char,int> mp;
        for(int j=0;j<i;j++){
        for(int k=i;k<N;k++){
            if(S[j]==S[k]&&mp[S[j]]!=1){
                cnt++;

                mp[S[j]] = 1;
            }
        }
        }
        if(cnt>cnt_ans) cnt_ans=cnt;
    }
    cout << cnt_ans <<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

const ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a) {
	long long b = M, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= M;
	if (u < 0) u += M;
	return u;
}
int main() {
	ll n, a[333333], i, suml[111111], sumr[111111], ans=0, ma = 0;
	cin >> n;
	for (i = 0; i < 3 * n; i++)
		cin >> a[i];
	multiset<ll> l;
	multiset<ll> r;
	for (i = 0; i < n; i++) {
		l.insert(a[i]);
		ans += a[i];
	}
	for (i = 2 * n; i < 3 * n; i++) {
		r.insert(-a[i]);
		ans -= a[i];
	}
	suml[0] = 0;
	sumr[n] = 0;
	for (i = n; i < 2 * n; i++) {
		suml[i - n + 1] = suml[i - n];
		if (a[i] > *l.begin()) {
			suml[i - n + 1] += a[i] - *l.begin();
			l.erase(l.begin());
			l.insert(a[i]);
		}
	}
	for (i = 2*n-1; i >= n; i--) {
		sumr[i - n] = sumr[i - n+1];
		if (-a[i] > *r.begin()) {
			sumr[i - n] -= a[i]+*r.begin();
			r.erase(r.begin());
			r.insert(-a[i]);
		}
	}
	for (i = 0; i <= n; i++)
		ma = max(suml[i] + sumr[i],ma);
	ans += ma;
	cout << ans << endl;
}

Measured memory_bytes: 18688
n = gets.chomp.to_i
s = gets.chomp.split('')
a = ''

for i in 0..(s.length - 1)
  if s[i].ord + n > 'Z'.ord
    s[i] = ('A'.ord + (s[i].ord + n) - 'Z'.ord - 1).chr
  else
    s[i] = (s[i].ord + n).chr
  end
end

for i in 0..(s.length - 1)
  a += s[i]
end

puts a

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

#ifndef ONLINE_JUDGE
	#define W(x, y) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << y;
#else
	#define W(x, y)
#endif

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vii vector<pii>
#define vl vector<ll>
#define vll vector<pll>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pi acosl(-1)
#define ld long double
#define prime (1000000000 + 7)
#define INF 1000000000

using namespace std;

vl kmp(string &&s, string &r){
	vl vet(s.size() + 1, -1);
	ll t = -1;
	for(int i = 0; i < s.size(); ++i){
		while (t > -1 && s[i] != s[t]){
			t = vet[t];
		}
		vet[i+1] = ++t;
	}
	vl res;
	res.insert(res.begin(), vet.begin() + r.size() + 1, vet.end());
	res[0] = -1;
	return res;
}

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

	string s;
	cin >> s;
	ll a = stoll(s.substr(0, 2));
	ll b = stoll(s.substr(2, 2));
	if(1 <= a && a <= 12 && 1 <= b && b <= 12){
		cout << "AMBIGUOUS\n";
	} else if(1 <= a && a <= 12 && !(1 <= b && b <= 12)){
		cout << "MMYY\n";
	} else if(!(1 <= a && a <= 12) && 1 <= b && b <= 12){
		cout << "YYMM\n";
	} else {
		cout << "NA\n";
	}

	return 0;
}

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

int main() {
	int cnt = 0;
	string s1, s2 = "CODEFESTIVAL2016";
	cin >> s1;
	for (int i = 0; i < 16; i++) {
		if (s1.substr(i, 1) != s2.substr(i, 1))
			cnt++;
	}
	cout << cnt << endl;

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tii;
#define rep(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

ll mod = 1e9+7;
ll calc(ll a,ll p,ll m){
  if(p==0) return 1;
  if(p%2==0){
    ll d = calc(a,p/2,m);
    return d*d%m;
  }else{
    return a*calc(a,p-1,m)%m;
  }
}

ll comb(ll n,ll k){
  if(n<k||k<0) return 0;
  ll sum = 1;
  ll a = 1;
  for(int i=0;i<k;i++){
    sum *= n-i;
    sum %= mod;
    a *= i+1;
    a %= mod;
  }
  ll res = sum*calc(a,mod-2,mod)%mod;
  return res;
}
int main(){
  ll x,y; cin >> x >> y;
  ll r = (x+y)%3;
  if(r!=0){
    cout << 0 << endl;
    return 0;
  }
  ll n = (x+y)/3;
  ll k = x - n;
  ll ans = comb(n,k)%mod;
  cout << ans << endl;
}

Measured memory_bytes: 3668
N = int(input())

pos = []
for _ in range(N):
    tmp = tuple(map(int, input().split()))
    pos.append(tmp)

pos.sort()

dic = dict()
for i in range(N):
    for j in range(i+1,N):
        distance = (pos[j][0]-pos[i][0], pos[j][1]-pos[i][1])
        #print(f'{distance=}')
        if distance in dic:
            dic[distance] += 1
        else:
            dic[distance] = 1
if dic :
    max_frenquency = max(dic.values())

    print(N-max_frenquency)
else:
    print(N)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
const int maxn = 1e6 + 5;
const long long mod = 1e9 + 7;
using namespace std;

char s[maxn];
int k,n,a[maxn];

int main(){
	scanf("%d %d", &k, &n);
	for(int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
	}
	int ans = 0;
	for(int i = 1; i < n; i++){
		ans = max(ans,a[i + 1] - a[i]);
	}
	ans = max(ans,k - a[n] + a[1]);
	printf("%d\n", k - ans);
	return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <algorithm>
#include <string>
#include <math.h>
using namespace std;

#define loop(i,n) for(int i=0;i<n;++i)
typedef long long ll;
typedef string str;

int main ()
{
	int t,n,a,b,k;
cin >> t >>  n;
	if (t > n)
	{
		cout << "safe";
		
	}
	else
	cout << "unsafe";
	return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

using namespace std;

ll dp[200005];

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,K;
	cin >> N >> K;
	vector<ll> A(N),F(N);
	rep(i,N)cin >> A[i];
	rep(i,N)cin >> F[i];
	sort(ALL(A));
	sort(ALL(F),greater<ll>());
	ll cnt = K;
	ll ok = 1e12+1;//各自がok以下なればok
	ll ng = -1;
	while(abs(ok-ng)>1){
		ll mid = (ok+ng)/2;
		cnt = K;
		//各自がmid以下になればok
		bool f = 1;
		for(int i=0;i<N;i++){
			if(A[i]*F[i]<=mid)continue;
			else if(A[i]*F[i]>mid){
				ll t = mid/F[i];
				cnt -=(A[i]-t);
				// x * y <= mid だから x <= mid/y;
			}
			if(cnt<0){
				f = 0;
				break;
			}
		}
		if(f)ok = mid;
		else ng = mid;
	}
	cout << ok << endl;
}

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

#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)

int main(){
  char x,y;
  cin>>x>>y;
  int a,b;
  a=x-'A';
  b=y-'A';
  if(a>b){
    cout<<'>'<<endl;
  }else if(a==b){
    cout<<'='<<endl;
  }else{
    cout<<'<'<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
a,b,c,x,y = map(int, input().split())
m = min(x,y)


# パターン1 Aを買いきってBを買う
ans1 = a*x + b*y
# パターン2 Aを買いきってABを買う
ans2 = a*x + 2*y*c
# パターン3 Bを買いきってABを買う
ans3 = b*y + 2*x*c
# パターン4 ABですべて買い切る
ans4 = max(x,y) * 2 * c
# パターン5 埋め合わせ
if x < y:
    ans5 = x * 2 * c + (y-x) * b 
else:
    ans5 = y * 2 * c + (x-y) * a

print(min(ans1,ans2,ans3,ans4,ans5))

Measured memory_bytes: 3064
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int N;
    scanf("%d", &N);
    vector<long long> members;
    for (int i = 0; i < 3 * N; i++) {
        long long a_i;
        scanf("%lld", &a_i);
        members.push_back(a_i);
    }
    sort(members.begin(), members.end());
    long long maxsum = 0;
    for (int i = 1; i <= N; i++) {
        maxsum += members[(3 * N) - (2 * i)];
    }

    printf("%lld\n", maxsum);   
}


Measured memory_bytes: 6000
N = int(input())
s = []
Sum = 0
for i in range(N):
    s.append(int(input()))
    Sum += s[i]
s.sort()

if Sum % 10 != 0:
    print(Sum)
else:
    for i in range(N):
        if s[i] % 10 != 0:
            print(Sum - s[i])
            break
        if i == N - 1:
            print(0) 

Measured memory_bytes: 9128
#include<iostream>
#include<math.h>
#include<string>
#include<map>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<time.h>
#include<random>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main() {
	int x;
	cin >> x;
	while (true) {
		bool fig = true;
		for (int i = 2; i <= sqrt(x); i++) {
			if (x % i == 0)fig = false;
		}
		if (fig) {
			cout << x << endl;
			return 0;
		}
		x++;
	}
	return 0;
}


Measured memory_bytes: 256
l=[]
for _ in range(int(input())):
  t=[*map(int,input().split())]
  l+=[t]
  if t[2]: x,y,h=t
for X in range(101):
  for Y in range(101):
    H=h+abs(x-X)+abs(y-Y)
    if all(h==max(H-abs(x-X)-abs(y-Y),0) for x,y,h in l): print(X,Y,H)

Measured memory_bytes: 9092
h, w, k = map(int, input().split())
c = []
b = 0
ans = 0
count = [[0] * w for i in range(h)]
for i in range(h):
    ci = input()
    c.append(ci)
    b += ci.count("#")
    for j in range(w):
        count[i][j] += (ci[j] == "#")

for i in range(2**(h + w)):
    x, y = [], []
    for j in range(h + w):
        if (i >> j) & 1:
            if j <= h - 1:
                y.append(j)
            else:
                x.append(j - (h - 1) - 1)
    n = 0
    for xi in x:
        n += sum([ci[xi] for ci in count])
    for yi in y:
        n += sum(count[yi])
    for yi in y:
        for xi in x:
            if count[yi][xi]:
                n -= 1
    ans += (b - n == k)
print(ans)


Measured memory_bytes: 9220
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        int max = 0;
        int count = 0;
        for(int i = 0; i < s.length(); i++){
            if(s.charAt(i)=='A'||s.charAt(i)=='T'||s.charAt(i)=='G'||s.charAt(i)=='C'){count++;}
            else{
                max = Math.max(max,count);
                count=0;
            }
        }
        System.out.println(Math.max(max,count));
    }
}



Measured memory_bytes: 23764
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

typedef pair<int, int> P;
 
char mapd[2000][2000];
int N, M;
int sx, sy;
int gx, gy;
 
int d[2000][2000];
 
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
 
int bfs() {
    queue<P> que;
    
    rep(i, N) rep(j, M) d[i][j] = INF;
    que.push(P(sx, sy));
    d[sx][sy] = 0;
 
    while(que.size()) {
        P p = que.front(); que.pop();
        if (p.first == gx && p.second == gy) break;
        rep(i, 4) {
            int nx = p.first + dx[i], ny = p.second + dy[i];
 
            if (0 <= nx && nx < N && 0 <= ny && ny < M && mapd[nx][ny] != '#' && d[nx][ny] == INF) {
                que.push(P(nx, ny));
                d[nx][ny] = d[p.first][p.second] + 1;
                //cout << "d[" << nx << "][" << ny << "] = " << d[nx][ny] << endl;
            }
        }
    }
    return d[gx][gy];
}

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

    cin >> N >> M;
    rep(i, N) rep(j, M) cin >> mapd[i][j];
    sx = 0, sy = 0;
    gx = N-1, gy = M-1;
    int cnt = 0;
    rep(i, N) rep(j, M) if (mapd[i][j] == '#') cnt++;

    if (bfs() == INF) {
        cout << -1 << endl;
        return 0;
    }
    cout << N * M - bfs() - cnt - 1 << endl; 

    


    return 0;
}


Measured memory_bytes: 2560
import math
n = int(input())
if n == 1:
    print(1)
    exit()
minx = int(math.sqrt(n)//1)
ans = 0
for i in range(2,minx+1):
    f = 1
    while True:
        if i**f > n:
            ans = max(ans,i**(f-1))
            break
        f+=1
print(ans)


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    ll ans = min(A*X+B*Y, min(2*C*max(X,Y), 2*C*min(X,Y)+A*max(0,X-Y)+B*max(0,Y-X)));

    cout << ans << "\n";
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#include <chrono>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9
#define f first
#define s second

typedef long long ll;

using namespace std;

const int N = 1e5;
int a[N+5];

int main()

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

    int d;

    cin >> d;

    if (d == 25) cout << "Christmas";
    else if (d == 24) cout << "Christmas Eve";
    else if (d == 23) cout << "Christmas Eve Eve";
    else cout << "Christmas Eve Eve Eve";

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define INF 1000000000000000
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
struct edge{int to,cost;};
typedef pair<int,int> P;
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
int kaijo(int n){
	int ans=1;
	for(int i=2;i<=n;i++){
		ans*=i;
		ans%=MOD;
	}
	return ans;
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	return modpow(a,b/2)*modpow(a,b/2)%MOD;
}
int comb(int a,int b){
	return kaijo(a)*modpow(kaijo(a-b),MOD-2)%MOD*modpow(kaijo(b),MOD-2)%MOD;
}
int n,m,l,r;
signed main(){
	cin>>n>>m;
	l=-1,r=1145141919;
	rep(i,m){
		int a,b;
		cin>>a>>b;
		l=max(l,a);
		r=min(r,b);
	}
	cout<<max(0ll,r-l+1)<<endl;
	return 0;
}


Measured memory_bytes: 256