akhauriyash/Code-Regression huggingface dataset:
X = int(input())

def eratosthenes(n):
    search = set(range(2,n))
    result = set()
    while search:
        i = search.pop()
        result.add(i)
        mul = 2
        while mul * i < n:
            if mul * i in search:
                search.remove(mul * i)
            mul+=1
    return result

primeSet=eratosthenes(X-1)

while True:
    isPrime=True
    for p in primeSet:
        if X%p==0:
            isPrime=False
            continue
    if isPrime:
        break
    X+=1
    
print(X)

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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C;
  D=0;
  
  for (int i=A;i<=B;i++){
    if(i%C==0){D++;}
  } 
  cout << D << endl;
}

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

int main()
{
    int N, L;

    cin >> N >> L;
    vector<int> T;
    for (int i = 0; i < N; i++)
    {
        T.push_back(L + i);
    }
    int allsum = accumulate(T.begin(), T.end(), 0);
    int mini = 10000000;
    int ans = 0;
    for (int x : T)
    {
        int omini = mini;
        mini = min(mini, abs(x));
        if (omini != mini)
        {
            ans = x;
        }
    }

    cout << allsum - ans;
}


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

const int MAX_TOWN = 9;
const int INF = 1 << 20;

int d[MAX_TOWN + 1][MAX_TOWN + 1];

int main()
{
  while (true) {
    int N; scanf("%d", &N);
    if (N == 0) break;

    for (int i = 0; i <= MAX_TOWN; i++) {
      for (int j = 0; j <= MAX_TOWN; j++) {
        d[i][j] = i == j ? 0 : INF;
      }
    }

    for (int i = 0; i < N; i++) {
      int a, b, c; scanf("%d%d%d", &a, &b, &c);
      d[a][b] = d[b][a] = c;
    }

    for (int k = 0; k <= MAX_TOWN; k++) {
      for (int i = 0; i <= MAX_TOWN; i++) {
        for (int j = 0; j <= MAX_TOWN; j++) {
          d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
        }
      }
    }

    int min_t = -1, min_c = INF;

    for (int i = 0; i <= MAX_TOWN && d[i][0] != INF; i++) {
      int sum = 0;
      for (int j = 0; j <= MAX_TOWN && d[i][j] != INF; j++) {
        sum += d[i][j];
      }

      if (min_c > sum) {
        min_t = i;
        min_c = sum;
      }
    }

    printf("%d %d\n", min_t, min_c);
  }
  return 0;
}


Measured memory_bytes: 2688
def count_bombs(S, h, w):
    count = 0
    for i in range(h-1, h+2):
        for j in range(w-1, w+2):
            if i < 0 or j < 0 or i >= len(S) or j >= len(S[0]):
                continue
            if S[i][j] == "#":
                count += 1
    return count


H, W = map(int, input().split())
S = [input() for _ in range(H)]
for h in range(H):
    for w in range(W):
        if S[h][w] == "#":
            print("#", end="")
            continue
        print(count_bombs(S, h, w), end="")
    print()


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

void testCase(){
    int n, k, a, b;
    cin>>n>>k;
    map<int, int> m;
    for(int i = 0; i < k; i++){
        cin>>a;
        for(int j = 0; j < a; j++){
            cin>>b;
            m[b]++;
        }
    }
    cout<<n-m.size()<<endl;
}

int main(){
    int t;
    t = 1;
    // cin>>t;
    while(t--){
        testCase();
    }
}



Measured memory_bytes: 3616
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{

    public static void Main()
    {
        int N = Cin();
        int[] n = SpRead(' ').Select(a => int.Parse(a)).ToArray();
        int D = n[0];
        int X = n[1];
        int[] A = new int[N];
        int count = 0;
        for (int i = 0; i < N; i++) A[i] = int.Parse(Console.ReadLine());
        for (int i = 1; i <= D; i++)
        {
            for (int j = 0; j < N; j++)
            {
                if ((i - 1) % A[j] == 0) count += 1;

            }
        }
        Console.WriteLine(count + X);
    }

}


public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static int LCM(int a, int b)
    {
        int c = a * b;
        if (a < b) Swap(ref a, ref b);
        int d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string strReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int Cin()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }

}


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

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

const int INF=1e9;
const int MOD=1e9+7;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

// (i,j)を左上とする2x2領域で祭りが開かれている
bool conflict(int c,int i,int j)
{
	return c&0x33<<i*4+j;
}
// 7日間雨が降らなかった地域がある
bool left7days(ull b)
{
	return b+0x1111111111111111ull&0x8888888888888888ull;
}
// (i,j)を左上とする2x2領域に雨を降らせた日の翌日
ull next(ull b,int i,int j)
{
	return b+0x1111111111111111ull&~(0xff00ffull<<(i*4+j)*4);
}

namespace std{
	template<>
	struct hash<tuple<int,int,ull>>{
		size_t operator()(const tuple<int,int,ull>& t)const{
			const char* ptr=(const char*)(&t);
			size_t res=2166136261;
			rep(i,sizeof(t)) (res^=*ptr++)*=16777619;
			return res;
		}
	};
}

int main()
{
	for(int n;cin>>n && n;){
		vector<int> cs(n);
		rep(i,n) rep(j,16){
			int x; cin>>x;
			cs[i]|=x<<j;
		}
		
		queue<tuple<int,int,ull>> q;
		q.emplace(1,1,0);
		rep(d,n){
			decltype(q) q2;
			unordered_set<tuple<int,int,ull>> vis;
			while(q.size()){
				auto cur=q.front(); q.pop();
				int i,j; ull b; tie(i,j,b)=cur;
				if(i<0 || 3<=i || j<0 || 3<=j) continue;
				if(conflict(cs[d],i,j)|| left7days(b)) continue;
				if(vis.count(cur)) continue;
				vis.insert(cur);
				rep(k,4) rep(l,3){
					int ni=i+"\xff\x1\0\0"[k]*l,nj=j+"\0\0\xff\x1"[k]*l;
					q2.emplace(ni,nj,next(b,i,j));
				}
			}
			swap(q,q2);
		}
		
		bool res=false;
		while(q.size()){
			res|=!left7days(get<2>(q.front()));
			q.pop();
		}
		cout<<res<<endl;
	}
}

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;
typedef long long ll;
typedef pair<ll, int> P;
const int MAXN = 1e5+10;

int k, n;
P sushi[MAXN];
vector<int> removable;
vector<ll> v[MAXN];
vector<ll> sumV;

void solve() {
  sort(sushi, sushi + n, greater<P>());
  ll sum = 0;
  ll typeNum = 0;
  for (int i=0;i<k;i++) {
    sum += sushi[i].first;
    if (v[sushi[i].second].size() > 0) {
      removable.push_back(sushi[i].second);
    } else {
      typeNum++;
    }
    v[sushi[i].second].push_back(sushi[i].first);
  }
  sumV.push_back(sum + typeNum * typeNum);
  for (int i=k;i<n && !removable.empty();i++) {
    if (v[sushi[i].second].size() == 0) {
      int removeType = removable.back();
      sum -= v[removeType].back();
      v[removeType].pop_back();
      removable.pop_back();
      typeNum++;
      sum += sushi[i].first;
      v[sushi[i].second].push_back(sushi[i].first);
      sumV.push_back(sum + typeNum * typeNum);
    }
  }
  sort(sumV.begin(), sumV.end(), greater<ll>());
  cout << sumV.front() << endl;
}

int main() {
  cin >> n >> k;
  for (int i=0;i<n;i++) {
    cin >> sushi[i].second >> sushi[i].first;
  }
  solve();
}


Measured memory_bytes: 6400
object Main {

  // 隣り合うタイルの色を異なる色にする
  // 以下の４通りにする タイルの枚数は10^5,
  // S^2回で10^10なので不可,
  // SlogSなら10^6なので間に合う
  // 0101...01|0
  // 1010...10|1
  // 一回舐めて、最初が黒のパターンと最初が白のパターンで何回変更するかを調べる
  // O(2n)

  val Black = '0'
  val White = '1'

  def main(args: Array[String]): Unit = {
    import scala.io.StdIn._
    val S: List[Char] = readLine().toList

    // 最小を調べる
    def solve(): Int = {
      def change(color: Char): Char =
        if (color == Black) White else Black

      // 前が0なら今回は1にして,前が1なら今回は0にする
      @scala.annotation.tailrec
      def count(lst: List[Char], before: Char, acm: Int): Int =
        if (lst.isEmpty) acm
        else if (before == lst.head) count(lst.tail, change(lst.head), acm + 1)
        else count(lst.tail, lst.head, acm)

      Math.min(count(S.tail, S.head, 0), count(S.tail, change(S.head), 1))
    }

    println(solve())
  }

}

Measured memory_bytes: 31492
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath> //abs();
using namespace std;

int main(void)
{
    long long int a,b,c,d,i,j,k,n,x[10];
    string s;
    char C[5];

    cin >> s;
/*
    for(i=0;i<3;i++){
        for(j=i;j<4;j++){
            if(s.at(i)>s.at(j)) swap(s.at(i),s.at(j));
        } 
    }
*/
    if(s.at(1)==s.at(2)){
        if( s.at(1)==s.at(0) || s.at(1)==s.at(3) ) cout << "Yes"; 
        else cout << "No";
    }
    else cout << "No";

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <climits>
#include <memory>
#include <sstream>
#include <iomanip>

using namespace std;


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

	string s;
	cin >> s;

	if (stoi(s.substr(0, 4)) <= 2019 && stoi(s.substr(5, 2)) <= 4 && stoi(s.substr(8, 2)) <= 30) {
		cout << "Heisei" << endl;
	}
	else {
		cout << "TBD" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <stack>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#include <new>
#include <sstream>
#include <complex>
#define BIT(nr) (1ULL << (nr))
#define int long long
#define ll long long
#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	
#define LL_HALFMAX 9223372036854775807 / 2	
#define MIN -(9223372036854775807 / 2)
#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()
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define mp make_pair
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }

using namespace std;

using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;

	// libalgo のものに追加、メンバを追加するだけなので互換性は崩さないはず、逆辺のG[e.dstの]インデックスを保持
	int rev;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
	bool operator<(const Edge& right) const {
		return dst < right.dst;
	}
};

using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph& g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph& g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }

int dx[8] = { 0, 1, 0,-1, 1, 1,-1,-1 }; // x軸方向への変位
int dy[8] = { 1, 0,-1, 0, 1,-1, 1,-1 }; // y軸方向への変位

signed main() {
	int N, Q;
	cin >> N >> Q;

	vector<int> a(N - 1), b(N - 1), p(Q), x(Q);
	Graph G(N + 1);

	rep(i, N - 1) {
		cin >> a[i];
		cin >> b[i];
		add_edge(G, a[i], b[i]);
	}

	vector<int> counter(N + 1, 0);

	rep(i, Q) {
		cin >> p[i];
		cin >> x[i];
		counter[p[i]] += x[i];
	}

	vector<bool> visited(N + 1, false);


	function<void(int, int)> dfs = [&](int node, int val) {
		if (visited[node]) {
			return;
		}
		visited[node] = true;
		counter[node] += val;

		for (Edge e : G[node]) {
			dfs(e.dst, counter[node]);
		}
	};

	dfs(1, 0);

	REPS(i, N) {
		cout << counter[i] << " ";
	}

	return 0;
}

Measured memory_bytes: 50968
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
bool used[3075522];
bool cal()
{
	int n,k;
	cin>>n>>k;
	if(2*k>n+1) return false;
	memset(used,false,sizeof(used));
	int now=k+n*2-1,bo=k+n/2,x=k+n*3-1;
	REP(i,bo,k+n){
		int tar=min(now,x-i);
		while(used[tar]) tar--;
		cout<<i<<' '<<tar<<' '<<x<<endl;
		now=min(now,tar-1);
		used[tar]=true;
		x--;
	}
	now=k+n*2-1;
	REP(i,k,bo){
		int tar=min(now,x-i);
		while(used[tar]) tar--;
		cout<<i<<' '<<tar<<' '<<x<<endl;
		now=min(now,tar-1);
		used[tar]=true;
		x--;
	}
	return true;
}
int main()
{
	if(!cal()) cout<<-1<<endl;
}


Measured memory_bytes: 5248
#include<stdio.h>
#include<map>
using namespace std;
typedef long long ll;
const ll mod=1000000000000000031ll,b=1000000000000000003ll,rb=821428571428571454ll;
ll mul(ll a,ll b){return(__int128)a*b%mod;}
ll ad(ll a,ll b){return(a+b)%mod;}
ll pow(ll a,ll b){
	ll s=1;
	while(b){
		if(b&1)s=mul(s,a);
		a=mul(a,a);
		b>>=1;
	}
	return s;
}
char s[250010];
ll p[250010],st[250010];
map<ll,int>m;
int main(){
	int n,i;
	ll ans;
	scanf("%d%s",&n,s+1);
	p[0]=1;
	for(i=1;i<=n;i++){
		p[i]=p[i-1];
		st[i]=st[i-1];
		switch(s[i]){
			case'+':st[i]=ad(st[i],p[i]);break;
			case'-':st[i]=ad(st[i],mod-p[i]);break;
			case'>':p[i]=mul(p[i],b);break;
			case'<':p[i]=mul(p[i],rb);break;
		}
	}
	ans=0;
	for(i=n;i>0;i--){
		m[st[i]]++;
		ans+=m[ad(mul(st[n],p[i-1]),st[i-1])];
	}
	printf("%lld",ans);
}

Measured memory_bytes: 35584
#include<iostream>
#include<string>
#include<map>
#include<set>
#include<algorithm>
#include<limits.h>
#define foreach(t,p) for(t::iterator it=p.begin();it!=p.end();p++)
using namespace std;

int main()
{
    int n,a,b,c,x;
    while(cin >>n>>a>>b>>c>>x &&(a||b||c||n||x))
    {
        int y[110];
        for(int i=0;i<n;i++)cin >> y[i];
        int leal=0;
        int j;
        for(j =0;j<10001;j++)
        {
            if(y[leal]==x) {leal++;if(leal==n) break;}
            x = (a*x+b)%c;
        }
    cout << ((j==10001) ? -1 :j)  <<endl;
    }
    return 0;
}

Measured memory_bytes: 0
N = int(input())
X = list(map(int, input().split()))
Xmn, Xmx = min(X), max(X)
temp = []
res = Xmx-Xmn
for x in range(Xmn, Xmx+1):
	for n in range(N):
		temp.append(abs(X[n]-x))
	if max(temp)<res:
		res = max(temp)
	temp=[]

print(res)


Measured memory_bytes: 5616
#include <bits/stdc++.h>
#define fi first
#define se second
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define rmin(r, x) r = min(r, x)
#define rmax(r, x) r = max(r, x)
#define ends ' '
#define endl '\n'
#define fastio ios_base::sync_with_stdio(0), cin.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main(void) {
    fastio;
    string s;   cin >> s;
    if(s.back() != 's') s += "s";
    else                s += "es";
    cout << s;
    return 0;
}


Measured memory_bytes: 3660
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
int c1(const void *a, const void *b){return *(char*)a-*(char*)b;}
int c2(const void *a, const void *b){return *(char*)b-*(char*)a;}
signed main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		char str[10];
		scanf("%s", str);
		qsort(str,8,sizeof(char), c1);
		int x1 = atoi(str);
		qsort(str,8,sizeof(char), c2);
		int x2 = atoi(str);
		cout << x2-x1 << endl;
	}
	return 0;
}

Measured memory_bytes: 3060
N,C=map(int,input().split())
IA=[[int(i)for i in input().split()]for _ in range(N)]
MS=[(0,0)]*(N+1)
CS=[0]*(N+1)
for i,[a,v] in enumerate(IA):
  CS[i+1]=CS[i]+v
  MS[i+1]=CS[i+1]-a if(CS[i+1]-a)>MS[i][0]else MS[i][0],CS[i+1]-2*a if(CS[i+1]-2*a)>MS[i][1]else MS[i][1]
RS=0
for i in range(N):
  ob=CS[N]-CS[i]
  RS=max(RS,ob+MS[i][0]-2*(C-IA[i][0]),ob+MS[i][1]-(C-IA[i][0]))
print(max(RS, MS[N][0], 0))


Measured memory_bytes: 39288
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
 
#define NUM 100
 
double Manhattan(double x[NUM], double y[NUM], int n);
double Euclidean(double x[NUM], double y[NUM], int n);
double MinkowskiP3(double x[NUM], double y[NUM], int n);
double Chebyshev(double x[NUM], double y[NUM], int n);
 
int a;
 
int main(void)
{
    int i ;
    int j = 0;
    int  n ;
    double ans1,ans2,ans3,ans4;
    double x[NUM];
    double y[NUM];
 
    scanf("%d", &n);
    for (i = 0; i < n;i++){
        scanf("%lf", &x[i]);
    }
    for (i = 0; i < n; i++){
        scanf("%lf", &y[i]);
    }
 
    ans1 = Manhattan(x, y, n);
    ans2 = Euclidean(x, y, n);
    ans3 = MinkowskiP3(x, y, n);
    ans4 = Chebyshev(x, y, n);
 
    printf("%lf\n%lf\n%lf\n%lf\n", ans1,ans2,ans3,ans4);
 
    return 0;
}
 
double Manhattan(double x[NUM], double y[NUM], int n){
     
    double z[NUM];
    double p1 = 0;
 
    for (a = 0; a < n; a++){
        z[a] = x[a] - y[a];
        p1 += abs(z[a]);
    }
 
    return p1;
}
 
double Euclidean(double x[NUM], double y[NUM], int n){
 
    double z[NUM];
    double s[NUM];
    double p2 = 0;
 
    for (a = 0; a < n; a++){
        z[a] = x[a] - y[a];
        s[a] = abs(z[a])*abs(z[a]);
        p2 += s[a];
    }
 
    return sqrt(p2);
}
 
double MinkowskiP3(double x[NUM], double y[NUM], int n){
    double z[NUM];
    double s[NUM];
    double p3 = 0;
 
    for (a = 0; a < n; a++){
        z[a] = x[a] - y[a];
        s[a] = abs(z[a])*abs(z[a])*abs(z[a]);
        p3 += s[a];
    }
 
    return pow(p3,1.0/3.0);
}
 
double Chebyshev(double x[NUM], double y[NUM], int n){
 
    double z[NUM];
    double s[NUM];
 
    for (a = 0; a < n; a++){
        z[a] = x[a] - y[a];
        s[a] = abs(z[a]);
    }
    double max = s[0];
    for (a = 0; a < n; a++){
        if (max<s[a])
            max = s[a];
    }
 
    return max;
}

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

using namespace std;

typedef long long ll;
ll w, h, x, y;

int main() {

	scanf("%lld%lld%lld%lld", &w, &h, &x, &y);


	double ax = (double) w * h/2.0;
	printf("%.9lf ", ax);
	if (w % 2 == 0 && h % 2 == 0 && w / 2 == x && h / 2 == y) printf("1\n");
	else printf("0\n");

	return 0;
}

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


int main() {
    int N; cin >> N;
    int K; cin >> K;
    int Q; cin >> Q;
    vector<int> scores(N, K - Q);

    for (int i = 0; i < Q; i++) {
        int ans; cin >> ans; ans -= 1;
        scores[ans] += 1;
    }

    for (int i = 0; i < N; i++) {
        if (scores[i] <= 0) {
            cout << "No" << endl;
        } else {
            cout << "Yes" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false) ; cin.tie(NULL) ; cout.tie(NULL);
#define int long long
#define pi pair<int,int>
#define ff first
#define ss second
#define pb push_back
#define mod 1000000007
int solve(int n)
{
    if(n==1)
    return 1;
    else
    {
        return 2*solve(n/2) + 1;
    }
    
}

int32_t main(){
IOS;
int h;
cin>>h;
cout<<solve(h)<<endl;
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){long long n,k;cin>>n>>k;
long long a[n],i,p=-1;
for(i=0;i<n;i++)
cin>>a[i];
sort(a,a+n);
for(i=0;i<n;i++){
    if(a[i]>=k){
        p=i;break;
    }
}if(p!=-1)
cout<<n-p;
else
cout<<0;
    return 0;
}


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

int main(int argc, char const *argv[])
{
	int x; cin >> x;
	int ans = 0;
	while(x >= 500) {
		ans += 1000;
		x -= 500;
	}
	while (x >= 5) {
		ans += 5;
		x -= 5;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
use whiteread::parse_line;

fn func(left: Vec<isize>, right: Vec<isize>, cand: &mut Vec<Vec<isize>>) {
    if right.is_empty() {
        cand.push(left);
        return;
    }
    for i in 0..right.len() {
        let mut lc: Vec<isize> = left.iter().copied().collect();
        let mut rc: Vec<isize> = right.iter().copied().collect();
        lc.push(rc.remove(i));
        func(lc, rc, cand);
    }
}

fn main() {
    let _n: usize = parse_line().unwrap();
    let p: Vec<isize> = parse_line().unwrap();
    let q: Vec<isize> = parse_line().unwrap();
    let mut candidate: Vec<Vec<isize>> = Vec::new();
    let mut first: Vec<isize> = p.iter().copied().collect();
    first.sort();

    func(Vec::new(), first, &mut candidate);
    let pp = candidate.iter().position(|x| x.eq(&p)).unwrap();
    let qp = candidate.iter().position(|x| x.eq(&q)).unwrap();
    println!("{}", pp.max(qp) - pp.min(qp));
}


Measured memory_bytes: 8020
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<list>
#include<cmath>
using namespace std;
using ll = long long;
const int INF = 1e8;
int main() {
	int N;
	int A;
	cin >> N;
	vector<int>B(N,0);
	for (int i = 0; i < N; ++i) {
		cin >> A;
		B[i] += A - (i+1);
	}
	sort(B.begin(), B.end());
	ll ans = 0;
	ll b;
	
	if (N % 2) {
		b = B[N / 2];
		for (int i = 0; i < N; ++i) {
			ans += abs(B[i] - b);
		}
		cout << ans << endl;
	}
	else {
		b = round((B[N / 2] + B[N / 2 - 1]) / 2);
		for (int i = 0; i < N; ++i) {
			ans += abs(B[i] - b);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
n = int(input())
s = input()
r = []
g = []
b = []

ans = s.count("R")*s.count("G")*s.count("B")

for i in range(n):
    for j in range(i+1,n):
        k = 2*j-i
        if k<n and s[k] != s[i] and s[k] != s[j] and s[i] != s[j]:
            ans -= 1

print(ans)

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

using ll = long long;
// #define int long long

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
signed main() {
  string s,t;
  cin >> s >> t;
  cout << t << s;
  
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 768
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
    vector<int> A(3);
    int result = 0;
    cin >> A[0] >> A[1] >> A[2];
    while (true) {
        sort(ALL(A));
        if (A[0] == A[1] && A[0] == A[2]) {
            break;
        }
        if (A[1] == A[2]) {
            if ((A[1] - A[0]) % 2) {
                A[0]++;
                A[1]++;
            } else {
                A[0] += 2;
            }
        } else {
            A[0]++;
            A[1]++;
        };
        result++;
    }
    cout << result << endl;
    return 0;
}

/*
 * 2 5 4
 * 2 4 5
 *
 */

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define ALL(vec) vec.begin(),vec.end()
#define rep(i,n) for(ll i = 0;i<n;++i)
#define repc(bit,k,n) for (ll bit = (1<<k)-1;bit < (1<<n); bit = next_combination(bit))
#define repi(itr,vec) for(auto itr = vec.begin();itr!=vec.end();++itr)
using namespace std;

// Union Find
struct UnionFind {
  //自身が親であれば、その集合に属する頂点数に-1を掛けたもの
  //そうでなければ親のid
  vector<int> r;

  UnionFind(int N) {
    r = vector<int>(N, -1);
  }

  int root(int x) {
    if (r[x] < 0) return x;
    return r[x] = root(r[x]);
  }

  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (r[x] > r[y]) swap(x, y);
    r[x] += r[y];
    r[y] = x;
    return true;
  }
  int size(int x) {
    return -r[root(x)];
  }
};
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,m;cin>>n>>m;
  vector<int>p(n);
  rep(i,n){
    int a;cin>>a;a--;
    p[i] = a;
  }
  UnionFind uf = UnionFind(n);
  rep(i,m){
    int a,b;cin>>a>>b;a--;b--;
    uf.unite(a,b);
  }
  unordered_map<int, vector<int> >um;
  rep(i,n){
    um[uf.root(i)].push_back(i);
  }
  int s = 0;
  repi(itr,um){
    vector<int>temp;
    repi(itr2,(*itr).second){
      temp.push_back(p[*itr2]);
    }
    vector<int>ans;
    sort(ALL(temp));
    sort(ALL((*itr).second));
    set_intersection(ALL((*itr).second),ALL(temp),back_inserter(ans));
    s+=ans.size();
  }
  cout<<s<<endl;


  return 0;
}

Measured memory_bytes: 12912
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
int a[100],b[100],c[100],ans1,ans2;
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=1;i<=n;i++){
		cin>>b[i];
	}
	for(int i=1;i<=n;i++){
		c[i]=i;
	}
	int cnt=1;
	bool f1=false,f2=false;
	do{
		for(int i=1;i<=n&&(!f1);i++){
			if(a[i]!=c[i]) break;
			else if(i==n){
				ans1=cnt;
				f1=true;
				break;
			}
		}
		for(int i=1;i<=n&&(!f2);i++){
			if(b[i]!=c[i]) break;
			else if(i==n){
				ans2=cnt;
				f2=true;
				break;
			}
		}
		cnt++;
	}while(next_permutation(c+1,c+1+n));
	cout<<abs(ans2-ans1)<<endl;
	return 0;
}

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

sp = [400,800,1200,1600,2000,2400,2800,3200]
rank = ["gray","brown","green","cyan","blue","yellow","orange","red","highest"]
cnt = [0]*len(rank)

import bisect as b

for score in S:
  cnt[b.bisect(sp,score)] += 1
  
mid = sum([1 for n in cnt[:-1] if n > 0])
t = cnt[-1]
max_amt = mid + t
min_amt = mid
if t > 0:
  min_amt = max(mid,1)
print(min_amt,max_amt)
#print(cnt)

Measured memory_bytes: 9156
from heapq import*
n,m=map(int,input().split())
*p,=map(int,input().split())
heapify(p)
q=sorted([list(map(int,input().split()))for i in range(m)],key=lambda x:x[1],reverse=1)

for s,t in q:
    for i in range(s):
        tmp=heappop(p)
        if t>tmp:
            heappush(p,t)
        else:
            heappush(p,tmp)
            print(sum(p))
            exit()
print(sum(p))
#    print(p,q)


Measured memory_bytes: 33784
#include <stdio.h>

int main(void){
  int set,i,j,n,flg,count,d;
  int rst[10][10];
  int dir[2][2]={{1,-1},{-1,1}};

  for(set=1;;set++){
    scanf("%d",&n);
    if(!n) break;

    i=j=flg=0;
    rst[0][0]=1;
    for(count=2;i!=n-1 || j!=n-1;count++){
      if(!flg){
	if(i==0 || j==n-1){
	  if(j+1<n) j++;
	  else i++;
	  flg = 1;
	  d = 0;
	}
	else if(j==0 || i==n-1){
	  if(i+1<n) i++;
	  else j++;
	  flg = 1;
	  d = 1;
	}
	else{
	  i += dir[d][0];
	  j += dir[d][1];
	}
      }
      else{
	i += dir[d][0];
	j += dir[d][1];
	flg = 0;
      }
      rst[i][j] = count;
    }

    printf("Case %d:\n",set);
    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
	printf("%3d",rst[i][j]);
      }
      putchar('\n');
    }
  }

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
//↓✟MLE魔、TLE魔✟
#define int long long
//↑✟MLE魔、TLE魔✟
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using namespace boost::multiprecision;
int gcd(int a,int b){
    if(a%b==0)return b;
    else return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,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;
}
    int cnt[100000];
signed main(){
    int n,q;
    string s;
    cin>>n>>q>>s;
    rep(i,n-1){
        if(s[i]=='A'&&s[i+1]=='C')cnt[i+1]++;
        cnt[i+1]+=cnt[i];
    }
    rep(i,q){
        int l,r;
        cin>>l>>r;
        cout<<cnt[r-1]-cnt[l-1]<<endl;
    }
}

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

int main()
{
    int yasumi, shukudai;
    int count = 0;
    cin >> yasumi >> shukudai;

    vector<int> nissuu(shukudai);
    for (int i = 0; i < shukudai; i++){
        cin >> nissuu.at(i);
    }
    for (int i = 0; i < shukudai; i++){
        count += nissuu.at(i);
    }

    if ((yasumi - count) >= 0){
        cout << yasumi - count << endl;
    }else{
        cout << -1 << endl;
    }
}

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


typedef long long ll;
using namespace std;

#define drobucs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int main() {
	drobucs;

	ll n;
	cin >> n;
	
	vector<ll> v(n + 1), sol(n + 1);

	for (int i = 1; i <= n; ++i) {
		ll y = 0;
		cin >> y;
		v[i] = 2 * y;
	}
	ll sum = 0, x;
	for (int i = 1; i <= n; ++i) {
		if (i % 2 == 1) {
			sum += v[i];
		}
		else {
			sum -= v[i];
		}
	}

	sol[1] = sum / 2;

	for (int i = 2; i <= n; ++i) {
		sol[i] = v[i - 1] - sol[i - 1];
	}

	for (int i = 1; i <= n; ++i) {
		cout << sol[i] << " ";
	}

	return 0;
}

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

int main()
{
	string S;
	cin >> S;
	if (S == "Sunny") {
		cout << "Cloudy" << endl;
	}
	else if (S == "Cloudy") {
		cout << "Rainy" << endl;
	}
	else {
		cout << "Sunny" << endl;
	}
}


Measured memory_bytes: 256
from bisect import bisect_left
s, t = [ord(c)-ord('a') for c in input()], [ord(c)-ord('a') for c in input()]
cnt = [[] for i in range(26)]
for i in range(len(s)):
    cnt[s[i]].append(i)
    cnt[s[i]].append(i+len(s))
for i in range(26):
    cnt[i] = sorted(cnt[i])
ans = 0
p = 0
for i in range(len(t)):
    c = t[i]
    if (len(cnt[c]) == 0):
        print('-1')
        exit()
    next = bisect_left(cnt[c], p)
    p = cnt[c][next] + 1
    if (p >= len(s)):
        p -= len(s)
        ans += len(s)
ans += p
print(ans) 



Measured memory_bytes: 57080
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <functional>

using namespace std;
typedef long long int ll;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)

void dye(vector<ll> *edge, int *color, ll idx, bool c){
  color[idx] = c;
  rep(i, (ll) edge[idx].size()){
    ll ch = edge[idx][i];
    if(ch > 0 && color[ch-1] == -1) dye(edge, color, ch-1, c);
    if(ch < 0 && color[-ch-1] == -1) dye(edge, color, -ch-1, 1-c);
  }
}

int main(){
  ll N;
  cin >> N;
  vector<ll> edge[N];
  rep(i, N-1){
    ll u, v, w;
    cin >> u >> v >> w;
    edge[u-1].push_back(v * (1 - w % 2 * 2));
    edge[v-1].push_back(u * (1 - w % 2 * 2));
  }
  int color[N];
  rep(i, N) color[i] = -1;
  rep(i, N) if(color[i] == -1) dye(edge, color, i, 0);
  rep(i, N) cout << color[i] << endl;
  return 0;
}


Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int i,j;
    int N,K;
    int sum=0;
    cin>>N>>K;
    vector<int> num(N);
    for(i=0;i<N;i++){
        cin>>num.at(i);
    }  
    sort(num.rbegin(),num.rend());
    for(j=0;j<K;j++){
        sum+=num.at(j);
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
object Main extends App {
	private val idMap = new Array[Long](100000)

	private def func(lines: Iterator[String]) {
		//TODO scanner?
		val line = lines.zipWithIndex.map { case (e, gi) =>
			val tmp = e.split(' ')
			val p = java.lang.Integer.parseInt(tmp(0))
			val y = java.lang.Integer.parseInt(tmp(1))
			(p, (y, gi))
		}.toList

		/*
				var iii = -1
				val line = lines.map { e =>
					val tmp = e.split(' ')
					val p = java.lang.Integer.parseInt(tmp(0))
					val y = java.lang.Integer.parseInt(tmp(1))
					iii += 1
					(p, (y, iii))
				}.toList
		*/

		line.groupBy(_._1).foreach { case (pgr, ylist) =>
			ylist.toSeq.map(_._2).sortBy(_._1).map(_._2).zipWithIndex.foreach { case (gi, yindex) =>
				//val id = "%06d%06d".format(pgr, (yindex + 1))
				//val id = str(pgr, yindex)
				////println(gi, id)
				////idMap = idMap + (gi -> id)
				//idMap(gi) = id

				idMap(gi) = 1000000L * pgr + (yindex + 1)
			}
		}
		val pw = new java.io.PrintWriter(System.out)
		/*		idMap.foreach { e =>
					val tmp = java.lang.Long.toString(1000000000000L + e).substring(1, 13)
					pw.println(tmp)
				}*/

		var ii = 0
		val end = line.size
		while (ii < end) {
			val tmp = java.lang.Long.toString(1000000000000L + idMap(ii)).substring(1, 13)
			pw.println(tmp)
			ii += 1
		}

		pw.flush()
	}

//	private val start = System.currentTimeMillis()
//	func((0 until 100).map(i => (i % 2) + " " + i).toIterator)
//	//func((0 until 100).map(i => (i % 1) + " " + -i))
//	func((0 until 100000).map(i => (i % 2) + " " + i).toIterator)
//	//func((0 until 100000).map(i => (i % 1) + " " + -i))
//	func((0 until 100000).map(i => i + " " + i).toIterator)
//	println(System.currentTimeMillis() - start)

	//TODO 入力が遅い？
	private val lines: Iterator[String] = scala.io.Source.stdin.getLines
	lines.next()
	func(lines)
}


Measured memory_bytes: 109668
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
#include <bitset>
#include <string>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define ALL(x) (x).begin(),(x).end()
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)

int main() {
  int N, M; cin >> N >> M;
  vector<int> A, D;
  vector<pair<int, int> > V(M);
  rep(i,N){
    int a; cin >> a;
    A.push_back(a);
  }
  sort(ALL(A));
  rep(i,M){
    int b, c; cin >> b >> c;
    V[i] = {c,b};
  }
  sort(V.rbegin(), V.rend());

  int cnt = 0;
  ll ans = 0;
  rep(i,M){
    rep(j,V[i].second){
      ans += max(A[cnt], V[i].first);
      cnt++;
      if(cnt==N){
        j = V[i].second;
        i = M;
        break;
      }
    }
  }

  for(int i=cnt; i < N; i++){
    ans += A[i];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char> cvec;
typedef vector<double> dvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
#define fs first
#define sc second
int main()	{
  ll a; double b;
  cin>>a>>b;
  ll c=b*100+0.5;
  cout<<a*c/100<<endl;
}

Measured memory_bytes: 3708
import java.io.*;
import java.math.*;
import java.util.*;


public class Main	 {
	public static HashMap<Long,Integer> factorize(long n) { 
		HashMap<Long,Integer> map = new HashMap<Long, Integer>();
        int count = 0; 
  
        // count the number of times 2 divides  
        while (!(n % 2 > 0)) { 
            // equivalent to n=n/2;  
            n >>= 1; 
  
            count++; 
        } 
  
        // if 2 divides it  
        if (count > 0) { 
        	map.put((long)2, count);
//            System.out.println("2" + " " + count); 
        } 
  
        // check for all the possible  
        // numbers that can divide it  
        for (long i = 3; i <= (long) Math.sqrt(n); i += 2) { 
            count = 0; 
            while (n % i == 0) { 
                count++; 
                n = n / i; 
            } 
            if (count > 0) { 
            	map.put(i, count);
//                System.out.println(i + " " + count); 
            } 
        } 
  
        // if n at the end is a prime number.  
        if (n > 2) { 
        	map.put(n, 1);
//            System.out.println(n + " " + "1"); 
        } 
        return map;
    } 
    public static void main(String[] args) throws IOException {
        	Scanner sc = new Scanner(System.in);
        	long n  = sc.nextLong();
        	HashMap<Long,Integer> map = new HashMap<Long,Integer>();
        	map = factorize(n);
        	Set<Long> keySet = map.keySet();
        	int res=0;
            List<Long> listKeys = new ArrayList<Long>( keySet );
        	for(int i=0;i<map.size();i++) {
        		Long key = listKeys.get(i);
        		int a = map.get(key);
        		int count =0;
        		for(int j=1;a-j>=0;j++) {
        			a=a-j;
        			count++;
        		}
        		res+=count;
        	}
        	System.out.print(res);
    }
}


Measured memory_bytes: 35820
#include <bits/stdc++.h>
#define abdelrahman001 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define inFile(t) freopen((t),"r",stdin)
#define outFile(t) freopen((t),"w",stdout)
#define pb push_back
#define pf push_front
#define Pb pop_back
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define Pf pop_front
#define sz size
#define MP make_pair
#define Pc __builtin_popcount
#define pi 2*acos(0)
#define BiEdge(v,a,b) (v)[(a)].pb(b),(v)[(b)].pb((a))
#define mod 1000000007
#define point complex<ld>
#define X real()
#define Y imag()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define cross(a,b)(conj(a)*(b)).imag()
#define dot(a,b) (conj(a)*(b)).real()
#define rectangle pair<coordinate,coordinate>
#define line tuple<ll,ll,ll>
#define EPS 1e-7
#define polygon vector<point>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
int const N = 1e3+5,M = 105;
using namespace std;
ll n,m,memo[N][N];
char arr[N][N];
ll solve(ll i,ll j)
{
    if(i == n-1 && j == m-1)
        return 1;
    ll &ans = memo[i][j];
    if(~ans)
        return ans;
    ans = 0;
    if(i < n-1 && arr[i+1][j]!='#')
        ans = (ans + solve(i+1,j))%mod;
    if(j < m-1 && arr[i][j+1]!='#')
        ans = (ans + solve(i,j+1))%mod;
    return ans;
}
int main()
{
    abdelrahman001
    memset(memo,-1,sizeof memo);
    cin >> n >> m;
    for(int i = 0;i<n;i++)
        for(int j = 0;j<m;j++)
            cin >> arr[i][j];
    cout << solve(0,0);
    return 0;
}


Measured memory_bytes: 9216
// When you are hungry for something and you're determined and you're focused 
// and you're committed to something it's hard to surrender, isn't it?

#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define ll long long 
#define int ll
#define mod 1000000007
#define mod1 1000000006
#define modi 998244353
#define setbit(x) __builtin_popcount(x)
#define fff(i,n) for(int i=0;i<n;i++)
#define ff first
#define ss second
#define pb push_back
vector<ll> vi[300005];
int color[100005];
ll pa[500005];
ll si[500005];
#define pb push_back
bool visi[1000005]={false};
bool is[100005];
ll fac[10000001];
ll prime[400005];
ll bit[100005];
const long double eps = 1.0e-14;      // allowable error
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
 
 
void fact(){
    fac[0]=1;
    for(int i=1;i<=10000000;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
    return ;
}
void sieve(){
    prime[0]=0;
    prime[1]=0;
    for(int i=2;i<400005;i++){
        prime[i]=1;
    }
    for(int i=2;i*i<400005;i++){
        if(prime[i]==1){
            for(int j=i*i;j<400005;j+=i){
                prime[j]=0;
            }
        }
    }
    
}
 
ll power(ll n , ll p ){
    if(p==0)
        return 1;
    
    ll res = power((n*n)%mod,p/2);
    if(p%2==1)
        res = (n*res)%mod;
    
    return res;
}
 
 
void upd(ll i,ll val,ll n) {
    for(;i<=n;i+=i&(-i))
        bit[i]+=val;
}
 
ll qry(ll i) {
    ll sum=0;
    for(;i>0;i-=i&(-i))
        sum+=bit[i];
    return sum;
}
 
 
ll fin(ll u) {
    if(pa[u]==u)
        return u;
    return fin(pa[u]);
}
 
void uni(ll u,ll v) {
    ll p1=fin(u);
    ll p2=fin(v);
    if(p1==p2)
        return;
    if(si[p1]<si[p2])
        swap(p1,p2);
    si[p1]+=si[p2];
    pa[p2]=p1;
    return;
}
 
int32_t main() {
    fio
    
    char a1,a2,b1,b2,c2,c1;
    cin >> a1 >> b1 >> c1;
    cin >> a2 >> b2 >> c2;
    int c=0;
    if(a1==a2)
    c++;
    if(b1==b2)
    c++;
    if(c1==c2)
    c++;
    
    cout << c;
    
	return 0;
    
}

Measured memory_bytes: 9468
#include<bits/stdc++.h>
using namespace std;
const int N=2005;
int a[N],vis[N];
vector<int>e[N],g[N]; 
priority_queue<int>pq;
void dfs(int v)
{
	vis[v]=1;
	for(int i=0;i<e[v].size();i++)
	{
		int u=e[v][i];
		if(vis[u])
			continue;
		g[v].push_back(u);
		dfs(u);
	}
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)	
		for(int j=1;j<=n;j++)
			if(__gcd(a[i],a[j])>1)
				e[i].push_back(j);
	for(int i=1;i<=n;i++)
	{
		if(!vis[i])
		{
			dfs(i);
			pq.push(i);
		}
	}
	while(!pq.empty())
	{
		int k=pq.top();
		pq.pop();
		printf("%d ",a[k]);
		for(int i=0;i<g[k].size();i++)
			pq.push(g[k][i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 19556
#include<stdio.h>
int main()
{
int S=6000,A=4000,B=3000,C=2000,a,b,i;
for(i=0;i<4;i++){
scanf("%d %d",&a,&b);
if(a==1){
S=S*b;
printf("%d\n",S);
}else if(a==2){
A=A*b;
printf("%d\n",A);
}else if(a==3){
B=B*b;
printf("%d\n",B);
}else if(a==4){
C=C*b;
printf("%d\n",C);
}
}
return(0);
}


Measured memory_bytes: 2680
#include <bits/stdc++.h>
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
const int N = 2e3+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int n;
int l[N];

int main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> l[i];
	}
	sort(l, l+n);
	int ans = 0;
	for(int i=0; i<n; i++){
		for(int j=i+1; j<n; j++){
			ans += lower_bound(l, l+n, l[i]+l[j])-l - 1 - j;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#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++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin >> n;
  ll a,b;cin >> a >> b;
  cout << min(a,b) << " " << max(a+b-n,0ll) << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define vi vector<int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;



int main(){
    int n; cin >> n;
    vi a(n);
    
    rep(i,n) cin >> a[i];
    
    Reverse(a);
    
    rep(i,n-1){
        cout << a[i] << " ";
    }
    cout <<a[n-1] << endl;
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

  int N = s.size();
  for (int i = 0; i < (int)N; ++i) {
    if (i + 1 < N && s[i] == s[i + 1]) {
      cout << i + 1 << " " << i + 2 << endl;
      return 0;
    }

    if (i + 2 < N && s[i] == s[i + 2]) {
      cout << i + 1 << " " << i + 3 << endl;
      return 0;
    }
  }

  cout << -1 << " " << -1 << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define repi(i,a,b) for (int i = int(a); i < int(b); i++)
#define all(x) (x.begin()), (x.end())
#define sz(x) int((x).size())

using namespace std;

//type
typedef long long ll;
typedef long double ld;
typedef long long unsigned int ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<vll> vvll;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

// constants
const double EPS = 1e-7;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double PI = acos(-1);

// maximum size
const int MAX_N = 0;

/** !codes **/
int N, Y;

void solve(){
    vvi ans(0);
    for (int i = 0; i < N + 1; i++)
    {
        for (int j = 0; j < N + 1 - i; j++){
            // int price = Y - (10000 * i + 5000 * j);
            // if (floor(price / 1000) != N - (i + j)){
            //     continue;
            // }
            // vi res(3);
            // res.at(0) = i;
            // res.at(1) = j;
            // res.at(2) = N - (i + j);
            // ans.push_back(res);
            for (int k = 0; k < N + 1 - i - j; k++)
            {
                if (10000*i + 5000*j + 1000*k == Y and i + j + k == N)
                {
                    vi res(3);
                    res.at(0) = i;
                    res.at(1) = j;
                    res.at(2) = k;
                    ans.push_back(res);
                }
                
            }
            
        }
    }
    if (ans.size() == 0)
    {
        cout << "-1 -1 -1" << '\n';
        return;
    }
    for (auto &&i : ans[0])
    {
        cout << i << ' ';
    }
    cout  << '\n';
    return;
}

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

    cin >> N >> Y;

    solve();
}

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

using namespace std;

typedef long long int ll;
#define inf 0x3f3f3f3f
#define endl '\n'
// #define case(i) "Case #" << i << ": "

vector<vector<ll>> dp;
vector<int> v, w;
int n, tw;

// ll solve(int i, int curw) {
//     if(i == -1) {
//         return 0;
//     }
//     else {
//         if(dp[i][curw] != -1) return dp[i][curw];
//         if(curw < w[i]) return dp[i][curw] = solve(i-1, curw);
//         else return dp[i][curw] = max(v[i] + solve(i-1, curw - w[i]), solve(i-1, curw));
//     }
// }

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

    cin >> n >> tw;
    v.resize(n+1);
    w.resize(n+1);

    for(int i = 1; i <= n; ++i) {
        cin >> w[i] >> v[i];
    }

    dp.resize(n+1, vector<ll>(tw + 1, 0));

    for(int i = 1; i <= n; ++i) {
        for(int j = 1; j <= tw; ++j) {
            if(j - w[i] >= 0) {
                dp[i][j] = max(v[i] + dp[i-1][j-w[i]], dp[i-1][j]);
            }
            else {
                dp[i][j] = dp[i-1][j];
            }
        }
    }

    // for(int i = 1; i <= n; ++i) {
    //     for(int j = 1; j <= tw; ++j) {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }


    cout << dp[n][tw] << endl;
}

Measured memory_bytes: 80256