akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
#include <map>

using namespace std;

typedef long long ll;

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

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

const int MAX_A = 1000000;
const ll MOD = 1000000007;

vector<ll> A;
vector<map<int, int>> ms;

int modinv(int a, int m) {
    int b = m, u = 1, v = 0;
    while (b) {
        int t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

// ref. YouTube ABC 152 E
class EratosthenesSieve {
    public:
        const int N;

        EratosthenesSieve(const int N): N(N) {
            numbers.resize(N + 1, 0);
            init();
        }

        map<int, int> factors(int n) {
            assert(n > 0 && n <= N); 
            map<int, int> res;
            while (n > 1) {
                res[numbers[n]]++;
                n /= numbers[n];
            }
            return res;
        }

        void primes(vector<int> &p) {
            for (int i = 2; i <= N; i++) {
                if (numbers[i] == i) {
                    p.push_back(i);
                }
            }
        }

    private:
        vector<int> numbers; // numbers[i] means minimum prime factor for i (e.g. numbers[12] = 2)

        void init() {
            // O(N * log(logN)) ???
            int i = 2;
            for (; i * i <= N; i++) {
                if (numbers[i] == 0) {
                    numbers[i] = i;
                    for (int j = i * i; j <= N; j += i) {
                        if (numbers[j] == 0) {
                            numbers[j] = i;
                        }
                    }
                }
            }
            for (; i <= N; i++) {
                if (numbers[i] == 0) {
                    numbers[i] = i;
                }
            }
        }
};

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

    A.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    EratosthenesSieve *sieve = new EratosthenesSieve(MAX_A);

    // {prime, count}
    map<int, int> lcm;
    for (int i = 0; i < N; i++) {
        map<int, int> m = sieve->factors(A[i]);
        for (auto &p : m) {
            int prime = p.first;
            int count = p.second;
            chmax(lcm[prime], count);
        }
    }

    ll lcm_mod = 1;
    for (auto &p : lcm) {
        for (int i = 0; i < p.second; i++) {
            lcm_mod = lcm_mod * p.first % MOD;
        }
    }

    ll acc = 0;
    for (int i = 0; i < N; i++) {
        ll x = lcm_mod * mod_pow(A[i], MOD - 2, MOD) % MOD;
        acc = (acc + x) % MOD;
    }

    cout << acc << endl;

    delete sieve;
    return 0;
}


Measured memory_bytes: 4736
import copy as cp
import itertools as itr
import numpy as np

N,M,X=map(int, input().split())
c=np.array([list(input().split()) for l in range(N)],dtype=int)


v=list(itr.product(range(2),repeat=N))
ans=-1
for i in range(len(v)):
  ans2=0
  l=np.zeros(M,dtype=int)
  for j in range(N):        
    if v[i][j]==1:      
      for k in range(M):
        l[k]+=c[j][k+1]
      ans2+=c[j][0]
  if np.amin(l)>=X:  
    if ans==-1:
      ans=ans2
    else:
      ans=min(ans,ans2)
        
print(ans)

Measured memory_bytes: 27312
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

const int INF = 1e9 + 5;

int main()
 {
	int t;
	cin >> t;
	cout<<2*3.14*t;
	
	
}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define ll long long
constexpr int MOD = 1e9 + 7;
using namespace std;

constexpr static int MAXN = 2002;
#define co(ans) cout<<ans<<endl
#define MAX 5100000

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

  int count_change = 0;
  for(int i=0; i<s.size(); i++) {
    if (s[i] != t[i])
      count_change++;
  }
  cout << count_change;
  return 0;
}

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

using namespace std;

typedef long long ll;

int X;
struct elem {
  ll b, l, u;

  ll key () {
    return u * (X - b) + l * b;
  }
};

bool byopt (elem p, elem q) {
  return p.key() > q.key();
}

const int MAX_N = 1e5 + 5;

elem elems [MAX_N];

int n;
bool can (int rem, ll cur, ll xc) {
  // can we get above 0?
  for (int i = 0; i < n; i++) {
    ll ccur = cur;
    if (i < xc) {
      ccur -= elems[i].key();
      ccur += elems[xc].key();
    }
    ccur += elems[i].l * elems[i].b;
    if (rem - elems[i].b < 0) {
      ccur += elems[i].l * (rem - elems[i].b);
    } else {
      ccur += elems[i].u * (rem - elems[i].b);
    }
    
    if (ccur >= 0) return true;
  }
  return false;
}

int main () {
  ios::sync_with_stdio(false);

  cin >> n >> X;

  for (int i = 0; i < n; i++) {
    cin >> elems[i].b >> elems[i].l >> elems[i].u;
  }

  sort(elems, elems + n, byopt);

  ll cur = 0;
  for (int i = 0; i < n; i++) {
    cur -= elems[i].l * elems[i].b;
  }

  if (cur >= 0) {
    cout << 0 << endl;
    return 0;
  }

  ll xc;
  for (int i = 0; i < n; i++) {
    if (cur + elems[i].key() >= 0) {
      xc = i;
      break;
    } else {
      cur += elems[i].key();
    }
  }

  int rem = 0;
  for (int k = 1 << 20; k != 0; k /= 2) {
    if (rem + k <= X && !can(rem + k, cur, xc)) {
      rem += k;
    }
  }
  rem++;

  cout << X * xc + rem << endl;
}


Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int n=0;
  cin >> s;
  for(int i=0;i<4;i++){
    if(s.at(i)=='+'){
      n++;
    }
    else {
      n--;
    }
  }
  cout << n << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

int main()
{
	int n;
	cin >> n;
	rep(i,n)
	{
		int a;
		cin >> a;
		if(a%2==0)
		{
			if(a%5==0||a%3==0)
			{

			}
			else
			{
				cout<<"DENIED"<<endl;
				return 0;
			}
			
		}
	}
	cout<<"APPROVED"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    long long int n,d,x,y,cnt=0;
    cin >> n >> d;
    d *= d;
    for(int i=0;i<n;i++){
        cin >> x >> y;
        if(d>=x*x+y*y) cnt++;
    }
    cout << cnt;
}

Measured memory_bytes: 3624
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define FOR(i,a,n) for(int i=a; i<n; i++)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;
typedef pair<string, string> pss;

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

	vector<int> x(n), y(n);
	vector<int> xary, yary;

	rep(i, n) {
		cin >> x[i] >> y[i];

		xary.push_back(x[i]);
		yary.push_back(y[i]);
	}

	sort(xary.begin(), xary.end());
	sort(yary.begin(), yary.end());

	ll ans = 1LL * (xary[n - 1] - xary[0]) * (yary[n - 1] - yary[0]);

	for (int xi = 0; xi < n; xi++) {
		for (int xj = xi + 1; xj < n; xj++) {
			for (int yi = 0; yi < n; yi++) {
				for (int yj = yi + 1; yj < n; yj++) {
					int  num = 0;
					ll lx = xary[xi], rx = xary[xj];
					ll by = yary[yi], uy = yary[yj];

					for (int i = 0; i < n; i++) {
						if (lx <= x[i] && x[i] <= rx && by <= y[i] && y[i] <= uy) {
							num++;
						}
					}
					if (num >= k)ans = min(ans, 1LL * (rx - lx) * (uy - by));
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main()
{
  int n;
  cin>>n;
  int A[n];
  int ans = 0;
  for(int i = 0;i < n;i++)
    cin>>A[i];
  for(int i = 0;i < n;i++)
  	for(int j = i+1;j < n;j++)
      for(int k = j+1;k < n;k++)
      {
        if((A[i] != A[j])&&(A[k] != A[j])&&(A[i] != A[k]))
        {
          if((A[i] + A[j] > A[k])&&(A[i] + A[k] > A[j])&&(A[k] + A[j] > A[i]))
            ans++;
        }
      }
  cout<<ans<<"\n";
}
          
          
          
          
          

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
typedef pair<string,int> P;
main(){
  queue<P> proces;
  int n,q;
  string a;
  int b;
  int time=0;
  cin>>n>>q;
  for(int i=0;i<n;i++){
    cin>>a>>b;
    proces.push(P(a,b));
  }
  while(!proces.empty()){
    P p;
    p=proces.front();
    proces.pop();
    if(p.second-q<=0){
      time+=p.second;
      cout<<p.first<<" "<<time<<endl;
    }
    else{
      time+=q;
      proces.push(P(p.first,p.second-q));
    }
  }
}

Measured memory_bytes: 4404
#include<bits/stdc++.h>
using namespace std;
int x[1000];
int main()
{
    int n;
    cin>>n;
    int sum = 0;
    for(int i = 0 ; i < n ; i++)
    {
        cin>>x[i];
    }
    for(int i = 0 ; i < n - 1 ; i++)
    {
        if( x[i] == x[i+1] )
        {
            sum++;
            i++;
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <climits>
#include <fstream>
#include <bitset>
#include <time.h>

#define ll long long
#define VL vector<ll>
#define VI vector<int>
#define FOR(i,b) for(int i= 0; i<((int)b); ++i)
#define FOR_(i,a,b) for(int i= a; i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define COUT(x) cout << x << endl;
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define EPS 1e-14
#define DIM2(R,C,arr) vector<vector<int>> arr(R);FOR(i,R) (arr)[i].resize(C);
#define DIM2INIT(R,C,arr) FOR(i,R)FOR(j,C)arr[i][j]=0;
#define MAPGEN(R,C,visited,map) char map[R][C]; FOR(i,R){string s;cin>>s;FOR(j,C){visited[i][j]=0;map[i][j]=s[j];}}
#define Point pair<int,int>
#define POINT(x,y,arr) arr[y][x]
#define SORT(a)  sort(a.begin(),a.end());
using namespace std;







int main() {
    //*** ---------------------------------------------------------------------------*//
    //
    //                            Variables and Initialize
    //
    //*----------------------------------------------------------------------------- *//
    
    FOR_(i,1,10)FOR_(j,1,10)cout << i <<"x"<< j << "=" << i*j<<endl;
    
   
    
    
    return 0;
}

Measured memory_bytes: 3080
#include <cstdio>

using namespace std;
const int MOD(1000000000 + 7);
typedef long long int LL;

inline int Mult(const int &a, const int &b)
{
	return (a * 1LL) * b % MOD;
}

void exgcd(const int &a, const int &b, int &x, int &y)
{
	if (b == 0)
		x = 1, y = 0;
	else
		exgcd(b, a % b, y, x), y -= x * (a / b);
}

inline int inverse(const int &a)
{
	int invx, invy;
	exgcd(a, MOD, invx, invy);
	return (invx % MOD + MOD) % MOD;
}

inline void update(int &a, const int &b)
{
	((a += b) >= MOD) ? (a -= MOD) : 0;
}

const int Max_V(2000050);

int X[7], Y[7], Fac[Max_V + 5], Inv[Max_V + 5], Ans;

//从(0, 0)到(x, y)的方案数为(x + y, x)，这也是排列x个黑球和y个白球的方案数
//考虑从(0, 0)到在(0, 0) - (a, b)矩形中所有点的方案数之和
//  Sum{C(x + y, x) | 0 <= x <= a, 0 <= y <= b}
//= Sum{C(a + i + 1, i + 1) | 0 <= i <= b}
//在(a + 1) ~ (a + b + 1)个位置中选择a个位置的方案数之和
//我们可以在a + b + 2个位置中选择a + 1个位置，最后一个位置作为结束点，在这之前的就是总位置
//注意到这样转换多加上了在a个位置中选择a个位置的方案
//故原式 = C(a + b + 2, a + 1) - 1
//这样我们就可以容斥计算从(0, 0)到矩形(a, b) - (c, d)中矩形中所有点的方案数之和

inline int C(const int &n, const int &m)
{
	return (n < m) ? 0 : Mult(Fac[n], Mult(Inv[m], Inv[n - m]));
}

inline int G(const int &a, const int &b)
{
	return (a < 0 || b < 0) ? 0 : ((C(a + b + 2, a + 1) - 1) % MOD + MOD) % MOD;
}

inline int G(const int &x1, const int &y1, const int &x2, const int &y2)
{
	return (((G(x2, y2) + G(x1 - 1, y1 - 1)) % MOD - (G(x1 - 1, y2) + G(x2, y1 - 1)) % MOD) % MOD + MOD) % MOD;
}

int main()
{
	Fac[0] = 1;
	for (int i = 1;i <= Max_V;++i)
		Fac[i] = Mult(Fac[i - 1], i);
	Inv[Max_V] = inverse(Fac[Max_V]);
	for (int i = Max_V - 1;i >= 0;--i)
		Inv[i] = Mult(Inv[i + 1], i + 1);
	for (int i = 1;i <= 6;++i)
		scanf("%d", X + i);
	for (int i = 1;i <= 6;++i)
		scanf("%d", Y + i);
	//若我们确定了S和T和行走的方案，那么只有中间休息的点P需要选择
	//若我们在(x1, y1)的位置进入第二个矩形，在(x2, y2)的位置走出第二个矩形，那么我们显然有(x2 - x1) + (y2 - y1) + 1种选择P点的方案
	//那么我们可以枚举第二个矩形的进入点（在左上两条边）和走出点（在右下两条边），分别计算贡献即可
	for (int x1 = X[3], y1 = Y[3];x1 <= X[4];++x1)
		update(Ans, Mult(Mult(G(x1 - X[2], (y1 - 1) - Y[2], x1 - X[1], (y1 - 1) - Y[1]), G(X[5] - x1, Y[5] - y1, X[6] - x1, Y[6] - y1)), ((-x1 - y1) % MOD + MOD) % MOD));
	for (int y1 = Y[3], x1 = X[3];y1 <= Y[4];++y1)
		update(Ans, Mult(Mult(G((x1 - 1) - X[2], y1 - Y[2], (x1 - 1) - X[1], y1 - Y[1]), G(X[5] - x1, Y[5] - y1, X[6] - x1, Y[6] - y1)), ((-x1 - y1) % MOD + MOD) % MOD));
	for (int x2 = X[3], y2 = Y[4];x2 <= X[4];++x2)
		update(Ans, Mult(Mult(G(X[5] - x2, Y[5] - (y2 + 1), X[6] - x2, Y[6] - (y2 + 1)), G(x2 - X[2], y2 - Y[2], x2 - X[1], y2 - Y[1])), (x2 + 1 + y2) % MOD));
	for (int y2 = Y[3], x2 = X[4];y2 <= Y[4];++y2)
		update(Ans, Mult(Mult(G(X[5] - (x2 + 1), Y[5] - y2, X[6] - (x2 + 1), Y[6] - y2), G(x2 - X[2], y2 - Y[2], x2 - X[1], y2 - Y[1])), (x2 + 1 + y2) % MOD));
	printf("%d", Ans);
	return 0;
}

Measured memory_bytes: 15744
#include <bits/stdc++.h>
#define rep2(i,x,y) for (int i = x; i < (y); ++i)
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
int INF = 100100101;
int main()
{
  ios::sync_with_stdio(false);  cin.tie(0); cout.tie(0);
  int x = 1;
  int i = 1;
  while(x != 0){
    cin >> x;
    if(x == 0) break;
    if(x > 10000) break;
    cout << "Case " << i << ": " << x << endl;
    i++; 
  }
return 0;
}


Measured memory_bytes: 3096
import java.util.*;
import java.math.RoundingMode;
import java.math.BigDecimal;
 
 
 
public class Main{
	 public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n];
		for(int i = 0; i < n; i++) {
			a[i]= sc.nextLong();
		}
		Arrays.sort(a);
		long max = 1;
		for(int i = 0; i < 18; i++) {
			max*=10;
		}
		BigDecimal max1 = BigDecimal.valueOf(max);
		BigDecimal ans = BigDecimal.valueOf(1);
		
		for(int i = 0; i < n; i++) {
			BigDecimal a1 = BigDecimal.valueOf(a[i]);
			ans = ans.multiply(a1);
			if(ans.compareTo(max1)>0) {
				ans = BigDecimal.valueOf(-1);
				break;
			}
		}
		if(ans.compareTo(max1)>0) {
			ans = BigDecimal.valueOf(-1);
		}
		System.out.println(ans);
	 }
}


Measured memory_bytes: 61592
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
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;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

// Kruskal algorithm: build minimum spanning tree

template <typename T>
struct Kruskal {
    struct edge {
        int from, to, used;
        T cost;
        edge(int from_, int to_, T cost_) : from(from_), to(to_), cost(cost_), used(0) {}
        bool operator<(const edge &e) const { return cost < e.cost; }
    };

    vector<int> rank, parent;
    vector<edge> es;
    Kruskal(int n) : rank(n + 1, 0), parent(n + 1) { iota(parent.begin(), parent.end(), 0); }
    // union-find methods
    int root(int x) {
        if (x != parent[x]) {
            parent[x] = root(parent[x]);
        }
        return parent[x];
    }
    bool isSame(int x, int y) { return root(x) == root(y); }
    bool unite(int x, int y) { return link(root(x), root(y)); }
    bool link(int x, int y) {
        if (x == y)
            return false;
        if (rank[x] > rank[y]) {
            parent[y] = x;
        } else {
            parent[x] = y;
            if (rank[x] == rank[y]) {
                rank[y]++;
            }
        }
        return true;
    }
    // Kruskal methods
    void addEdge(int f, int t, T c) { es.emplace_back(f, t, c); }
    T build() {
        sort(es.begin(), es.end());
        T res = 0;
        for (auto &e : es) {
            if (!isSame(e.from, e.to)) {
                res += e.cost;
                unite(e.from, e.to);
                e.used = 1;
            }
        }
        return res;
    }
};

int main() {
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    vector<pll> x(n), y(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
        x[i] = {a[i], i};
        y[i] = {b[i], i};
    }
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    Kruskal<ll> kr(n);
    for (int i = 1; i < n; ++i) {
        int fx = x[i - 1].second;
        int tx = x[i].second;
        ll dx  = min(abs(a[fx] - a[tx]), abs(b[fx] - b[tx]));
        int fy = y[i - 1].second;
        int ty = y[i].second;
        ll dy  = min(abs(a[fy] - a[ty]), abs(b[fy] - b[ty]));
        kr.addEdge(fx, tx, dx);
        kr.addEdge(tx, fx, dx);
        kr.addEdge(fy, ty, dy);
        kr.addEdge(ty, fy, dy);
    }
    ll ret = kr.build();
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 20204
import java.io.*;
import java.math.*;
import java.util.*;
import java.lang.*;

// import java.text.DecimalFormat; 
// import java.text.DecimalFormatSymbols; 
/*
 
 
 
 */

public class Main {

    public static void main(String args[] ) throws Exception {
        PrintWriter pw=new PrintWriter(System.out);
        FastScanner sc = new FastScanner();
        
        int t=1;
        //t = sc.ni();
        while(t-->0) {
        	solve(pw,sc);
        }
       
        pw.close();
    }
  
   
    private static void solve(PrintWriter pw, FastScanner sc) {
    	int n = sc.ni(), m =sc.ni();
    	@SuppressWarnings("unchecked")
		List<Integer>[] li = new ArrayList[n];
    	for(int i=0;i<n;i++) li[i] = new ArrayList<>();
    	while(m-->0) {
    		int a = sc.ni()-1;
    		int b = sc.ni()-1;
    		li[a].add(b);
    		li[b].add(a);
    	}
    	int cnt=0;
    	boolean[] vis = new boolean[n];
    	for(int i=0;i<n;i++) {
    		if(!vis[i]) {
    			dfs(li,vis,i);
    			cnt++;
    		}
    	}
    	pw.print(cnt-1);
    	
	}
    static void dfs(List<Integer>[] li,boolean[] vis,int s) {
    	vis[s]=true;
    	for(int i=0;i<li[s].size();i++) {
    		int t = li[s].get(i);
    		if(vis[t]) continue;
    		dfs(li,vis,t);
    	}
    }

	static <T> void deb(T x,int o){
       System.out.print(x);
       if(o==0) {
    	   System.out.println();
    	   
       }
    }
   
   
   static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		public String ne() {
			while (!st.hasMoreElements())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		public String ne(int k) {
			try {
				return br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return "Not able to read";
		}
		
		int ni() {
			return Integer.parseInt(ne());
		}
		
		long nl() {
			return Long.parseLong(ne());
		}
		
		double nd() {
			return Double.parseDouble(ne());
		}
		
	    
	}
   
}

Measured memory_bytes: 71144
import numpy as np
import queue
n,m = map(int,input().split())

V = np.zeros((n+1,n+1),dtype=bool)
E = []
for i in range(m):
    a,b = map(int,input().split())
    V[a][b] = True
    V[b][a] = True
    E.append((a,b))
def BFS(x,y):
    mark = [False]*(n+1)
    q = queue.Queue()
    q.put(x)
    while not q.empty():
        p = q.get()
        if p == y:
            return True
        mark[p] = True
        for i in range(1,n+1):
            if V[p][i] and not mark[i]:
                q.put(i)
    return False
res = 0

for a,b in E:
    V[a][b] = False
    V[b][a] = False
    if not BFS(a,b):
        res+=1

    V[a][b] = True
    V[b][a] = True
print(res)


Measured memory_bytes: 17920
import java.util.*;

public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		boolean b = false;
		
		while(n>0){
		    int r = n%10;
		    if(r==7) b = true;
		    n = n/10;
		}
		
		if(b) System.out.println("Yes");
		else System.out.println("No");
	}
}

Measured memory_bytes: 35920
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  double a,b,c,d; cin>>a>>b>>c>>d;
  int x = ceil(a/d);
  int y = ceil(c/b);
  if(x>=y) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3728
using System;

namespace abc118_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] array = Console.ReadLine().Split(' ');
            int a = int.Parse(array[0]);
            int b = int.Parse(array[1]);
            if (b % a == 0)
            {
                Console.WriteLine(a + b);
            }
            else
            {
                Console.WriteLine(b - a);
            }

        }
    }
}


Measured memory_bytes: 11092
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

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

  std::vector<std::string> sn(n);
  for (auto &s : sn) {
    std::cin >> s;
    std::sort(&s[0], &s[s.length()]);
  }

  std::sort(sn.begin(), sn.end());

  int64_t count = 0;
  int64_t local_count = 0;
  for (int i = 1; i < n; ++i) {
    if (sn[i - 1] == sn[i]) {
      count += (++local_count);
    } else {
      local_count = 0;
    }
  }

  std::cout << count << std::endl;

  return 0;
}

Measured memory_bytes: 7296
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <queue>
#include<iomanip>
#include <cmath>
#include <set>
#include <unordered_set>

#define ABS(x) ((x)>0?(x):-(x))
#define MIN(x,y) ((x)>(y)?(y):(x))
#define MAX(x,y) ((x)<(y)?(y):(x))

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

#define INF 1000000000

using namespace std;
typedef long long ll;

ll newton(long long int a, long long int  b)
{
	if(a==b)
		return a;
	while(a != 0 && b != 0)
	{
		if(a > b)
		{
			b += a;
			a = b-a;
			b -= a;
		}
		b %= a;
	}
	return a;
}

struct UnionFind {
	vector<int> p;
	UnionFind(int N):p(N)
	{
		for(int i=0; i< N; i++)
		{
			p[i] = i;
		}
	}
	int root(int x)
	{
		if(p[x] == x)
			return x;
		return p[x] = root(p[x]);
	}
	void unite(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		if(rx == ry) return;
		p[rx] = ry;
	}
	bool issame(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

//大きな数に対する割り算をするとき、MODを指定することで掛け算の値に変換できる

ll div2mul_calc(ll a, ll b, ll m)
{
	if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll d = div2mul_calc(a, b / 2, m);
        return (d * d) % m;
    } else {
        return (a * div2mul_calc(a, b - 1, m)) % m;
    }
}
ll div2mul(ll n, ll mod)
{
	return div2mul_calc(n, mod-2, mod);
}

ll twoRow(ll a, ll b, ll mod)
{
	ll ret = 1;
	for(ll i = 1 ;i <= a+b;++i)
	{
		ret *= i;
		ret %= mod;
	}
	for(ll i = 1 ;i <= a;++i)
	{
		ret *= div2mul(i,mod);
		ret %= mod;
	}
	for(ll i = 1 ;i <= b;++i)
	{
		ret *= div2mul(i,mod);
		ret %= mod;
	}
	return ret;
}

struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};

vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(ret.begin(), ret.end());
  return (ret);
}
/*
小数の桁数を指定する
	cout << setprecision(8)<< mp[0]-mx << endl;
*/

int main()
{
	ll i,j,k,a,b,ans = 0;
	ll N,M;
	cin >> N;
	ll mR=2000000000, mRI, mL=0, mLI,mI = -1;
	std::vector<pair<ll,ll> > p;
	for(i=0;i<N;++i)
	{
		cin >> k>> j;
		if(j < mR)
		{
			mR = j;
		}
		p.push_back(make_pair(k,j));
	}
	// pat 1
	sort(p.begin(), p.end());
	ans = MAX(0, mR-p[N-1].first+1);
	j = MAX(0, p[0].second-p[0].first+1);
	for(i=0;i<N;++i)
	{
		if(p[i].second == mR)
		{
			if(mI = -1)
				mI = i;
			continue;
		}
		k = p[i].second - p[i].first + 1;
		if(k > j)
			j = k;
	}
	ans += j;
	mRI = p[N-1].second;
	j = 0;
	for(i=N-1;i>mI;--i)
	{
		if(mRI > p[i].second)
			mRI = p[i].second;
		k = MAX(0,mRI-p[N-1].first+1)+MAX(0,mR-p[i-1].first+1);
		if(k > j)
			j = k;
	}

	if(ans < j)
		ans = j;
	cout << ans << endl;
	return 0;
}




















Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef std::pair<int,int> pair2;
typedef std::pair<int,pair2> pair3;
const ll INF = 1LL<<60;
const  ll NUM=10e8+7;


int main(){
  ll N;
  cin>>N;
ll ans=0;
  for(ll i=1;i<N;i++){
  ll num=(N-1)/i;
    ans=ans+num;
  }
  
  cout<<ans<<endl;
 

}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#include <unistd.h>
#define ll long long
#define inf 1000000007
#define inf16 0x3f3f3f3f
#define INF 1000000000000000007LL
#define VI vector<int>
#define VPII vector<pair<int, int> >
#define VLL vector<ll>
#define PII pair<int, int>
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
using namespace std;

#define int ll

int h, w, n, k, ans;

int pot[50*50];

int query(int y1, int y2, int x1, int x2)
{
	cout << "? " << y1 << " " << x1 << " " << y2 << " " << x2 << endl;
	int ans;
	cin >> ans;
	return ans;
}

void solve(int y1, int y2, int x1, int x2, int cnt, int split)
{
	if(cnt==0)
		return;

	if(cnt==(y2-y1+1)*(x2-x1+1))
	{
		for(int i = y1; i <= y2; ++i)
		{
			for(int j = x1; j <= x2; ++j)
			{
				ans += pot[i*w+j];
				ans %= k;
			}
		}

		return;
	}

	if(y1!=y2)//split)
	{
		int m = (y1+y2)/2;
		int h = query(y1, m, x1, x2);
		solve(y1, m, x1, x2, h, split^1);
		solve(m+1, y2, x1, x2, cnt-h, split^1);
	}
	else
	{
		int m = (x1+x2)/2;
		int h = query(y1, y2, x1, m);
		solve(y1, y2, x1, m, h, split^1);
		solve(y1, y2, m+1, x2, cnt-h, split^1);
	}
}

int32_t main()
{
	cin >> h >> w >> n >> k;

	pot[0] = 1;

	for(int i = 1; i < 50*50; ++i)
	{
		pot[i] = pot[i-1]*2%k;
	}

	for(int j = 0; j < w; ++j)
	{
		//solve(0, w-1, j, j, query(0, w-1, j, j), 1);
	}

	/*for(int i = 0; i < h; i += 5)
	{
		for(int j = 0; j < w; j += 5)
		{
			solve(i, i+4, j, j+4, query(i, i+4, j, j+4), 1);
		}
	}*/

	solve(0, h-1, 0, w-1, n, 1);

	cout << "! " << ans << endl;
}

Measured memory_bytes: 724
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数 __builtin_popcount bitの個数

int main() {
  int N;
  ci(N);
  ve<int> L(N);
  rep(i, N){
    ci(L.at(i));
  }
  sort all(L);
  int a = 0;
  rep(i, N - 1){
    a += L.at(i);
  }
  if(a > L.at(N - 1)){
    co("Yes");
  }
  else{
    co("No");
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
map <int, int> minWeight;

int main() {
    int n, w, weight, value, result = 0;
    minWeight[0] = 0;

    cin >> n >> w;
    for (int i = 1; i <= n; i++) {
        cin >> weight >> value;

        for (map <int, int> :: reverse_iterator it = minWeight.rbegin(); it != minWeight.rend(); it++)
            if ((it -> second) + weight <= w) {
                int valueSum = (it -> first) + value;
                int weightSum = (it -> second) + weight;

                if (!minWeight[valueSum])
                    minWeight[valueSum] = weightSum;
                minWeight[valueSum] = min(weightSum, minWeight[valueSum]);

                result = max(result, valueSum);
            }
    }

    cout << result;

    return 0;
}

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

int main(){
	int n,i;
	double ans = 0;
	cin >> n;
	int v[n];
	for(i = 0; i < n; i++){
		cin >> v[i];
	}
	std::sort(v, v+n);
	for(i = 0; i < n; i++){
		if(i != 0){
			ans = (ans + v[i])/2;
		}
		else{
			ans = ans + v[i];
		}
	}

	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> mp;
    rep(i, n)
    {
        cin >> a[i];
        mp[a[i]]++;
    }
    sort(a.begin(),a.end());
    int ans = n;
    for(int i = 1;i <= 100000;i++){
        if(mp[i]>=3){
            ans -= (mp[i] - 1) / 2 * 2;
            mp[i] -= (mp[i] - 1) / 2 * 2;
        }
    }
    int cnt = 0;
    for (int i = 1; i <= 100000; i++)
    {
        if(mp[i] == 2){
            cnt++;
        }
    }
    ans -= (cnt + 1) / 2 * 2;
    cout << ans << endl;
}

Measured memory_bytes: 5376
n = gets.to_i

def ketasum(n)
    ret = 0
    loop{
        if n==0 then
            break
        end
        ret+=n%10
        n/=10
    }
    return ret
end

def is_harshaddo(n)
    return n%ketasum(n)==0
end

puts is_harshaddo(n) ? 'Yes' : 'No'

Measured memory_bytes: 1788
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

a,b,c = inpl()
print(min(c,b//a))

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int dp[20001][256];

void init(int N){
    rep(i, N+1) rep(j, 256) dp[i][j] = mod;
}

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    vector<int> ans;
    while(true){
        int N, M; cin >> N >> M;
        if(N == 0) break;
        vector<int> code(M); rep(i, M) cin >> code[i];
        vector<int> X(N); rep(i, N) cin >> X[i];
        init(N);

        dp[0][128] = 0;
        rep(i, N){
            rep(j, 256){
                if(dp[i][j] != mod){
                    rep(k, M){
                        int to = j + code[k];
                        if(to < 0) to = 0; if(to > 255) to = 255;
                        dp[i+1][to] = min(dp[i+1][to], dp[i][j] + (X[i]-to)*(X[i]-to));
                    }
                }
            }
        }
        int res = mod;
        rep(j, 256) res = min(res, dp[N][j]);
        ans.push_back(res);
    }
    rep(i, ans.size()) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 23204
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
using namespace std;

int main() {
    int i,j,p,q,temp1,temp2;
    int k;
    int n,m;
    int num=1;
    cin>>n>>k;
    string s;
    cin>>s;
    s[k-1]=s[k-1]-'A'+'a';
    cout<<s;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
// #pragma GCC optimize("O2")
typedef long long int ll;
typedef long double ld;
typedef map <ll,ll> mm;
typedef vector <ll> mv;
typedef pair <ll,ll> mp;
typedef set <ll> ms;
typedef multiset <ll> mms;
typedef queue <ll> mq;
typedef deque <ll> mdq;
typedef stack <ll> mst;
typedef priority_queue <ll> mpq;
typedef priority_queue <ll, vector<ll>, greater<ll> > mmh;
typedef complex<double> cd;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_multiset tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define flush cout.flush();
#define all(v) v.begin(),v.end()
#define deb(x) cout << #x << " " << x << endl;
#define ff first
#define ss second
#define pb(v) push_back(v)
#define lb(v) lower_bound(v)
#define ub(v) upper_bound(v)
#define cn continue
#define forl(i,n) for(ll i=0;i<n;i++)
#define forlr(i,n) for(ll i=n-1;i>=0;i--)
#define rev(s) reverse(s.begin(),s.end())
void swap(ll &a,ll &b) {
	ll tmp=a;
	a=b;
	b=tmp;
}
ll atoistring(string s) {
	stringstream lol(s);
	ll x;
	lol>>x;
	return x;
}
void pv(mv v) {
	forl(i,v.size()) cout<<v[i]<<" ";
	cout<<"\n";
}
void pa(ll *v, ll size) {
	forl(i,size) cout<<v[i]<<" ";
	cout<<"\n";
}
void removeDups(mv &v) {
	sort(all(v));
	mv::iterator it = unique(v.begin(), v.end());
	v.resize(distance(v.begin(), it));
}
inline ld kthRoot(ld n, ll k) {
	return pow(k, (1.0 / k) * (log(n) / log(k)));
}
ll power(ll x, ll y, ll p) {
	ll res=1;
	x=x%p;
	while(y>0) {
		if(y&1) res = (res*x)%p;
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}
void checkmod(ll &x, ll mod) {
	if(x>=mod) x%=mod;
}

ll mod = 1e9 + 7;

vector < pair < ll , mp > > v1, v2;
void thisIsMain() {
	ll n;
	cin>>n;
	forl(i,n) {
		ll x, y;
		cin>>x>>y;
		v1.push_back({x + y, {x, y}});
		v2.push_back({x - y, {x, y}});
	}
	ll ans = 0;
	sort(all(v1));
	sort(all(v2));
	ans = max(ans, abs(v1[0].ss.ff - v1.back().ss.ff) + abs(v1[0].ss.ss - v1.back().ss.ss));
	ans = max(ans, abs(v2[0].ss.ff - v2.back().ss.ff) + abs(v2[0].ss.ss - v2.back().ss.ss));
	cout<<ans<<"\n";
}

int main(void)
{
	fastio
	ll t = 1;
	// cin>>t;
	while(t--) thisIsMain();
	return 0;
}

Measured memory_bytes: 12816
N,A,B,C = map(int, input().split())
L = []

for i in range(N):
    L.append(int(input()))

def search(l,a,b,c,d):
    if l == N:
        if a == 0 or b == 0 or c == 0:
            return float('inf')

        return (abs(a-A)+abs(b-B)+abs(c-C)+10*(d))

    if a == 0:
        mp1 = search(l+1,a+L[l],b,c,d)
    else:
        mp1 = search(l+1,a+L[l],b,c,d+1)

    if b == 0:
        mp2 = search(l+1,a,b+L[l],c,d)
    else:
        mp2 = search(l+1,a,b+L[l],c,d+1)

    if c == 0:
        mp3 = search(l+1,a,b,c+L[l],d)
    else:
        mp3 = search(l+1,a,b,c+L[l],d+1)

    mp4 = search(l+1,a,b,c,d)

    return min([mp1,mp2,mp3,mp4])

print(search(0,0,0,0,0))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
map<ll, ll>ins;
void facterize(ll n) {
	ll a = 2;
	while (n >= a * a) {
		if (n % a == 0) {
			ins[a]++;
			ins[a] = ins[a] % 1000000007;
			n /= a;
		}
		else {
			a++;
		}
	}
	ins[n]++;
}

vector<ll>relation[20], money(20, 1);

int main() {
	string s;
	cin >> s;
	bool flag = true;
	for (int i = s.length() - 1;i >= 2;--i) {
		if (i >= 4 && s[i] == 'm' && s[i - 1] == 'a' && s[i - 2] == 'e' && s[i - 3] == 'r' && s[i - 4] == 'd') {
			i -= 4;
		}
		else if (i >= 6 && s[i] == 'r' && s[i - 1] == 'e' && s[i - 2] == 'm' && s[i - 3] == 'a' && s[i - 4] == 'e' && s[i - 5] == 'r' && s[i - 6] == 'd') {
			i -= 6;
		}
		else if (i >= 4 && s[i] == 'e' && s[i - 1] == 's' && s[i - 2] == 'a' && s[i - 3] == 'r' && s[i - 4] == 'e') {
			i -= 4;
		}
		else if (i >= 5 && s[i] == 'r' && s[i - 1] == 'e' && s[i - 2] == 's' && s[i - 3] == 'a' && s[i - 4] == 'r'&&s[i-5]=='e') {
			i -= 5;
		}
		else {
			flag = false;
		}
	}
	if (flag)puts("YES");
	else {
		puts("NO");
	}
	return 0;
}

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

const int N = 1010, MOD = 1e9 + 7;

string G[N];

int dp[N][N];

int main() {
    int n, m; cin >> n >> m;
    for(int i = 1; i <= n; i++) {
            cin >> G[i];
    }
    dp[n + 1][m] = 1;
    for(int i = n; i > 0; i--) {
            for(int j = m; j > 0; j--) {
                    if(G[i][j - 1] == '.') dp[i][j] = (dp[i + 1][j] + dp[i][j + 1]) % MOD;
            }
    }
    cout << dp[1][1] << endl;

}


Measured memory_bytes: 5248
package main

import "fmt"

func main() {
	var s, t int
	fmt.Scan(&s)
	var numList []int
	numList = append(numList, s)

	for i := 1; true; i++ {
		if (numList[i-1])%2 == 0 {
			t = numList[i-1] / 2
		} else {
			t = 3*numList[i-1] + 1
		}
		if Contains(numList, t) {
			fmt.Println(i + 1)
			break
		}
		numList = append(numList, t)
	}
}

func Contains(a []int, x int) bool {
	for _, n := range a {
		if x == n {
			return true
		}
	}
	return false
}


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

using namespace std;

long long inf=1000000007;

int main(){
	int x,y;
	cin>>x>>y;

	for(int i=0;i<=x;i++){
		if(i*2+(x-i)*4==y){
			cout<<"Yes"<<endl;
			return 0;
		}
	}

	cout<<"No"<<endl;

	return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

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

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}


int d[10000005];
int main(){
    int n,k,q;cin>>n>>k>>q;
    rep(i,q){
        int a;cin>>a;
        a--;
        d[a]++;
    }
    vector<int>v(n);
    rep(i,n){
        v[i] = max(k-(q-d[i]),0);
    }
    rep(i,n){
        if(v[i]>0)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}



Measured memory_bytes: 1408
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int q = sc.nextInt();
    int[] a = new int[n+1];

    for (int i = 1; i <= n; i++) {
      a[i] = k - q;
    }

    for (int i = 1; i <= q; i++) {
      int x = sc.nextInt();
      a[x]++;
    }

    for (int i = 1; i <= n; i++) {
      if (a[i] <= 0) {
        System.out.println("No");
      } else {
        System.out.println("Yes");
      }
    }

  }

}


Measured memory_bytes: 58808
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef long long ll;
typedef long long integer;
//////////////////////////////////////////////////
ll llgcd(ll x,ll y){
	if (x<y) return llgcd(y,x);
	if (y==0) return x;
	ll r = x % y;
	return llgcd(y,r);
}

int main(){
    int N;
    ll X;
    SCD(N); SCLLD(X);
    ll D; D = -1;
    
    vector<ll> x;
    REP(i,N){
        ll y; SCLLD(y);
        y = abs(y-X);
        x.PB(y);
    }


    REP(i,N){
        if (x[i] == 0) continue;
        if (D == -1) D = x[i];
        D = llgcd(D,x[i]);
    }

    PRINTLLD(D);
}


Measured memory_bytes: 1400
inputLine=input()
N=int(inputLine.split(" ")[0])
M=int(inputLine.split(" ")[1])
#print(N,M)

inputLine=input()
A=inputLine.split(" ")
for i in range(len(A)):
    A[i]=int(A[i])


popularProductCount = 0
for i in range(len(A)):
    if A[i] >= sum(A) / (4*M):
        popularProductCount += 1


#print(popularProductCount)
if popularProductCount >= M:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
l = []
n=int(input())
for i in range(n):
    l.append(input())
l = list(map(int,l))
result_max = l[1] - l[0]
value_min = l[0]
for i in range(1,n):
    result_max = max(result_max,l[i]-value_min)
    value_min = min(value_min,l[i])                              
print(result_max)  


Measured memory_bytes: 27688
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <algorithm>
#include <cassert>
#define repeat_from(i,m,n) for (int i = (m); (i) < (n); ++(i))
#define repeat(i,n) repeat_from(i,0,n)
#define repeat_from_reverse(i,m,n) for (int i = (n)-1; (i) >= (m); --(i))
#define repeat_reverse(i,n) repeat_from_reverse(i,0,n)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
using namespace std;
struct mobile_t {
    int w; // weight
    double l; // left
    double r; // right
};
const double eps = 0.0001;
double evaluate(vector<int> const & p, double r) {
    stack<mobile_t> stk;
    for (int w : p) {
        if (w == 0) {
            if (stk.size() < 2) return -1;
            mobile_t x = stk.top(); stk.pop();
            mobile_t y = stk.top(); stk.pop();
            mobile_t z;
            z.w = x.w + y.w;
            double dx = y.w /(double) (x.w + y.w);
            double dy = x.w /(double) (x.w + y.w);
            z.l = max(x.l + dx, y.l - dy);
            z.r = max(x.r - dx, y.r + dy);
            if (r + eps < z.r + z.l) return -1;
            stk.push(z);
        } else {
            stk.push((mobile_t){ w, 0.0, 0.0 });
        }
    }
    if (stk.size() != 1) return -1;
    return stk.top().l + stk.top().r;
}
int main() {
    int datasets; cin >> datasets;
    repeat (dataset, datasets) {
        double r; cin >> r;
        int s; cin >> s;
        vector<int> w(s); repeat (i,s) cin >> w[i];
        double result = -1;
        vector<int> p;
        repeat (i,s)   p.push_back(w[i]);
        repeat (i,s-1) p.push_back(0);
        sort(p.begin(), p.end());
        do {
            result = max(result, evaluate(p, r));
        } while (next_permutation(p.begin(), p.end()));
        if (result == -1) {
            cout << -1 << endl;
        } else {
            printf("%.16lf\n", result);
        }
    }
    return 0;
}

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

int main() {
  int64_t a, b, ans = 0;
  cin >> a >> b;
  for (int i = 0; i < b; i++) {
    if (a * (i + 1) % b == 0) {
      ans = a * (i + 1);
      break;
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
const ll ATCODER_AMARI = 1000000007; //10^9 + 7
const ll INF = 10000000000000;
//階乗できるよ
ll kaizyo(ll k){
  ll sum = 1;
  for(int i = 1 ; i < k + 1; i++) {
    sum *= i;
    sum = sum % ATCODER_AMARI;
  }
  return sum;
}

int main() {
  unsigned long long A;
    long double B;
    cin >> A >> B;
    unsigned long long sum = (A * B);
    cout << fixed << setprecision(10) << sum << "\n";
    return 0;
}


Measured memory_bytes: 3712
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<queue>
#define ll long long
using namespace std;
const int MAXN=500010;

ll dp[MAXN];
ll q[MAXN];//队列
ll sum[MAXN];

int head,tail,n;
ll m;
// dp[i]= min{ dp[j]+M+(sum[i]-sum[j])^2 };
ll getDP(int i,int j)
{
    return dp[j]+m+(sum[i]-sum[j])*(sum[i]-sum[j]);
}

ll getUP(int j,int k) //yj-yk部分
{
    return dp[j]+sum[j]*sum[j]-(dp[k]+sum[k]*sum[k]);
}
ll getDOWN(int j,int  k)
{
    return 2*(sum[j]-sum[k]);
}

int main()
{
  //  freopen("in.txt","r",stdin);
  //  freopen("out.txt","w",stdout);
    while(scanf("%d%lld",&n,&m)==2)
    {
        for(int i=1;i<=n;i++)
           scanf("%d",&sum[i]);
        sum[0]=dp[0]=0;
        head=tail=0;
        q[tail++] = 1;
        for(int i=2;i<=n;i++)
        {
            //把斜率转成相乘，注意顺序，否则不等号方向会改变的
            while(head+1<tail &&  getUP(q[head+1],q[head])<=sum[i]*getDOWN(q[head+1],q[head]))
               head++;
            dp[i]=getDP(i,q[head]);
            while(head+1<tail && getUP(i,q[tail-1])*getDOWN(q[tail-1],q[tail-2])<=getUP(q[tail-1],q[tail-2])*getDOWN(i,q[tail-1]))
                    tail--;
            q[tail++]=i;
        }
        printf("%lld\n",dp[n]);
    }
    return 0;
}

Measured memory_bytes: 9984
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,i,j=0,a,b;
  cin>>n;
  for(i=1;i<=n;i++)
  {
    cin>>a>>b;
	b=b-a+1;
	j+=b;	
  }	
  cout<<j<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,L;
  string res;
  cin >> N >> L;
  vector<string> S(N);
  for(int i=0; i<N; i++) cin >> S.at(i);
  sort(S.begin(),S.end());
  for(int i=0; i<N; i++) res += S.at(i);
  cout << res << endl;
}


Measured memory_bytes: 256
import sys
import numpy as np
import itertools
input = sys.stdin.readline

N = int(input())
P = tuple(input().split())
Q = tuple(input().split())
p_all = sorted(list(itertools.permutations(P, N)))
q_all = sorted(list(itertools.permutations(Q, N)))
p_in = p_all.index(P)
q_in = q_all.index(Q)
ans = abs(q_in - p_in)
print(ans)

Measured memory_bytes: 22040