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

const ll MOD = 1000000007;

ll extgcd(ll a, ll b, ll &x, ll &y){
  ll d = a;
  if(b!=0){
    d = extgcd(b,a%b,y,x);
    y -= (a/b)*x;
  }else{
    x = 1; y = 0;
  }
  return d;
}

ll mod_inverse(ll a, ll m){
  ll x, y;
  extgcd(a, m, x, y);
  return (m+x%m)%m;
}

#define MX 200005
ll fact[MX];
ll invfact[MX];

ll mod_pow(ll x, ll n, ll mod){
  if(n==0) return 1;
  ll res = mod_pow(x * x % mod, n / 2, mod);
  if(n & 1) res = res * x % mod;
  return res;
}
ll mod_comb(ll n, ll k, ll p){
  if(n<0 || k<0 || n<k) return 0;
  return (((fact[n] * invfact[k]) % MOD) * invfact[n-k]) % MOD;
}
void comb_init(){
  fact[0] = fact[1] = 1;
  for(ll i=2; i<MX; i++) fact[i] = (fact[i-1] * i) % MOD;
  invfact[0] = invfact[1] = 1;
  for(ll i=2; i<MX; i++) invfact[i] = mod_pow(fact[i], MOD-2, MOD);
}

int N;
int A, B, C;
ll X, Y, Z;

int main(){
  comb_init();
  
  cin >> N >> A >> B >> C;

  ll ret = 0;
  REP(M,N,2*N){
    ll X = mod_inverse(A+B, MOD);
    ll pM = (mod_pow((A*X)%MOD,N,MOD) * mod_pow((B*X)%MOD,M-N,MOD))%MOD;
    pM += (mod_pow((A*X)%MOD,M-N,MOD) * mod_pow((B*X)%MOD,N,MOD))%MOD;
    pM %= MOD;
    pM *= mod_comb(M-1,N-1,MOD);
    pM %= MOD;

    ll EM = ((M * 100)%MOD) * mod_inverse(100-C, MOD);
    EM %= MOD;

    ret += pM * EM;
    ret %= MOD;
  }

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



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

vector<int> a1(2e5), a2(2e5), r1(2e5, 0), r2(2e5, 0);
void init(int n) {
  for (int i = 0; i < n; i++) a1[i] = a2[i] = i;
}
int find1(int x) {
  if (a1[x] == x) return x;
  return a1[x] = find1(a1[x]);
}
int find2(int x) {
  if (a2[x] == x) return x;
  return a2[x] = find2(a2[x]);
}
void unite1(int x, int y) {
  x = find1(x), y = find1(y);
  if (x == y) return;
  if (r1[x] < r1[y]) {
    a1[x] = y;
  } else {
    a1[y] = x;
    if (r1[x] == r1[x]) r1[x]++;
  }
}
void unite2(int x, int y) {
  x = find2(x), y = find2(y);
  if (x == y) return;
  if (r2[x] < r2[y]) {
    a2[x] = y;
  } else {
    a2[y] = x;
    if (r2[x] == r2[y]) r2[x]++;
  }
}
signed main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n, k, l; cin >> n >> k >> l;
  init(n);
  for (int i = 0; i < k; i++) {
    int p, q; cin >> p >> q;
    p--; q--;
    unite1(p, q);
  } 
  for (int i = 0; i < l; i++) {
    int r, s; cin >> r >> s;
    r--; s--;
    unite2(r, s);
  }
  for (int i = 0; i < n; i++) a1[i] = find1(i), a2[i] = find2(i);
  map<pair<int, int>, int> mp;
  for (int i = 0; i < n; i++) mp[pair<int, int>(a1[i], a2[i])]++;
  for (int i = 0; i < n; i++) cout << mp[pair<int, int>(a1[i], a2[i])] << ' ';
  cout << '\n';
  return 0;
}

Measured memory_bytes: 15232
#include <cstdio>
#include <cstring>
#define MAXN 410
#define MAXM 100010

int n,m;
int e[MAXM][2];
bool visit[MAXN],flag[MAXN],a[MAXN][MAXN];

bool gao(int x){
	memset(visit,0,sizeof visit);
	visit[x]=1;
	for(int i=m;i>=1;i--){
		if(visit[e[i][0]] && visit[e[i][1]]) return 0;
		else if(visit[e[i][0]]) visit[e[i][1]]=1;
		else if(visit[e[i][1]]) visit[e[i][0]]=1;
	}
	for(int i=1;i<=n;i++) a[x][i]=visit[i];
	return 1;
}

bool query(int x,int y){
	if(flag[x] || flag[y]) return 0;
	for(int i=1;i<=n;i++)
		if(a[x][i] && a[y][i]) return 0;
	return 1;
}

int main(){
#ifdef DEBUG
	freopen("E.in","r",stdin);
#endif
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++) scanf("%d%d",&e[i][0],&e[i][1]);
	for(int i=1;i<=n;i++) if(!gao(i)) flag[i]=1;
	int ans=0;
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			if(query(i,j)) ans++;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int A[] = new int[N+1];
    // diff[i] = | A[i] - A[i-1] |
    int diff[] = new int[N+2];
    // diff2[i] = | A[i+1] - A[i-1] |
    int diff2[] = new int[N+1];
    long sum = 0;
    A[0] = 0;
    for (int i=1;i<=N; i++) {
      A[i] = sc.nextInt();
      diff[i] = Math.abs(A[i] - A[i-1]);
      sum += diff[i];
      if (i>1) {
        diff2[i-1] = Math.abs(A[i] - A[i-2]);
      }
    }
    diff[N+1] = Math.abs(A[N]);
    sum += diff[N+1];
    diff2[N] = Math.abs(A[N-1]);

    for (int i=1; i<=N; i++) {
      long tmp = sum;
      tmp -= diff[i];
      tmp -= diff[i+1];
      tmp += diff2[i];
      System.out.println(tmp);
    }
  }
}

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

int main(){
    string s; cin >> s;
    char start;
    int count=0;
    for (int i=0; i<s.size(); i++){
        if (i==0){
            start=s.at(i);
            count++;
        } else {
            if (start!=s.at(i)){
                start=s.at(i);
                count++;
            }
        }
    }
    cout << count-1 << endl;
    return 0;
}

Measured memory_bytes: 512
const main = (input) => {
  const lines = input.split("\n").map(str => parseInt(str));
  let sum = 0;
  let maxLoss = 0;
  lines.forEach(time => {
    virtualTime = Math.ceil(time / 10) * 10;
    sum += virtualTime
    maxLoss = Math.max(maxLoss, virtualTime - time);
  });
  console.log(sum - maxLoss);
};

main(require('fs').readFileSync('/dev/stdin', 'utf8').trim());


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

using namespace std;

int main(void)
{
        string s;
        string sx;
        cin >> s;
        for(int i = 0; i < s.size(); i++){
                if(s[i] == 'x') continue;
                sx += s[i];
        }
        int xsize = sx.size();
        for(int i = 0; i < xsize/2; i++){
                if(sx[i] != sx[xsize - i - 1]){
                        cout << -1 << endl;
                        return 0;
                }
        }

        int ans = 0;
        for(int i = 0; i < s.size() / 2; i++){
                if(s[i] != s[s.size()-i-1]){
                        ans++;
                        if(s[i] == 'x'){
                                s.insert(s.begin()+s.size()-i, 'x');
                        }else{
                                s.insert(s.begin()+i, 'x');
                        }
                        i--;
                }
        }
        cout << ans << endl;

        return 0;
}

Measured memory_bytes: 640
def isPacked(numcar, maxweight, packs):
	weight = 0  # 一台当たりの積載量
	k = 1  # トラック台数

	for j in range(len(packs)):
		if packs[j] > maxweight:
			return False
		if weight + packs[j] > maxweight:
			k = k + 1
			weight = packs[j]
		else:
			weight = weight + packs[j]
		if k > numcar:
			return False

	return True


n, k = map(int, input().split())  # 5,3
W = []  # 8, 1, 7, 3, 9
PMAX = 0

for i in range(n):
	W.append(int(input()))
for i in W:
	PMAX = PMAX + i

#print(W)
#print(PMAX)

#print(isPacked(k, 5, W))
left = 0
right = PMAX + 1

while left < right:
	mid = (left + right) // 2
#	print('{0} {1} {2}'.format(left, mid, right))
	booleanPacked = isPacked(k, mid, W)
	if booleanPacked == True and isPacked(k, mid - 1, W) == False:
		print(mid)
		exit(0)
	elif booleanPacked == True:
		right = mid
	elif booleanPacked == False:
		left = mid + 1



Measured memory_bytes: 9512
import sys
N = int(input())
L = list(map(int,input().split()))
if(0 in L):
    print(0)
    sys.exit()
    
sum_l = 1
for x in L:
    sum_l *= x
    if(sum_l > 10 **18):
        print(-1)
        sys.exit()

print(sum_l)
    

Measured memory_bytes: 21656
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int k, n;
    cin >> k >> n;
    vector<int> a(n);
    rep(i, 0, n){
        cin >> a[i];
    }
    vector<int> b(n);
    int mx = 0;
    rep(i, 0, n-1){
        b[i] = a[i+1] - a[i];
        //cout << b[i] << endl;
        mx = max(mx, b[i]);
    }
    //cout <<mx;
    b[n-1] = a[0] + (k - a[n-1]);
    mx = max(mx, b[n-1]);
    cout << k - mx << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>

int n,m;
int visa[12],visb[12],a[12],b[12];
int main()
{
    while(~scanf("%d%d",&n,&m),n+m)
    {
        int t;
        memset(visa,0,sizeof(visa));
        memset(visb,0,sizeof(visb));
        for(int i=0; i<n; i++)
        {
            scanf("%d",&a[i]);
        }
        for(int i=0; i<m; i++)
        {
            scanf("%d",&b[i]);
        }

        int sum = 0;
        for(int i=0; i<n; i++)
        {
            for(int j=0; j<m; j++)
            {
                if(!visa[i] && !visb[j])
                {
                    if(a[i] == b[j])
                    {
                        sum += a[i];
                        visa[i] = 1;
                        visb[j] = 1;
                        break;
                    }
                }
            }
        }
        for(int i=0; i<n; i++) if(!visa[i]) sum += a[i];
        for(int j=0; j<m; j++) if(!visb[j]) sum += b[j];
        printf("%d\n",sum);
    }
    return 0;
}

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

int main() {
  int N,K;
  cin>>N>>K;
  vector<int> A(N);
  rep(i,N) cin>>A.at(i);
  sort(A.begin(),A.end());
  int64_t ans=0;
  rep(i,K) ans+=A.at(i);
  cout<<ans;
}

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

int n, m;
class Edge{
public:
	long long cost;
	int from, to;
	Edge(long long c, int f, int t){
		cost = c;
		from = f;
		to = t;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void readGraph(Graph &g, int E, bool D, bool C){ // E:NumofEdges, D:Directed, C:Costed
	for(int i=0; i<E; ++i){
		Edge e(0, 0, 0);
		if(!C) cin >> e.from >> e.to;
		else cin >> e.from >> e.to >> e.cost;
		--e.from;
		--e.to;
		g[e.from].push_back(e);
		if(!D){
			swap(e.from, e.to);
			g[e.from].push_back(e);
		}
	}
}
int f[100010];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n >> m;
	Graph g(n);
	readGraph(g, m, false, false);
	memset(f, -1, sizeof(f));
	int p = 0, q = g[0][0].to;
	f[p] = q;
	f[q] = n;
	while(1){
		bool t = true;
		for(int i=0; i<g[p].size(); ++i){
			if(f[g[p][i].to] == -1){
				f[g[p][i].to] = p;
				p = g[p][i].to;
				t = false;
				break;
			}
		}
		if(t) break;
	}
	while(1){
		bool t = true;
		for(int i=0; i<g[q].size(); ++i){
			if(f[g[q][i].to] == -1){
				f[q] = g[q][i].to;
				f[g[q][i].to] = n;
				q = g[q][i].to;
				t = false;
				break;
			}
		}
		if(t) break;
	}
//	for(int i=0; i<n; ++i) cout << i << " " << f[i] << "\n";
//	cout << p << " " << q << "\n";
	int cnt = 0;
	for(int i=0; i<n; ++i)
		if(f[i] != -1)
			++cnt;
	cout << cnt << "\n";
	for(int i=p; i!=n; i=f[i]) cout << i+1 << " \n"[f[i]==n];
}

Measured memory_bytes: 8832
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int result = 0;
        for (int i = n; i >= 1; i--) {
            if (Integer.toString(i).length() % 2 == 1) {
                result++;
            }
        }

        System.out.println(result);
    }
}


Measured memory_bytes: 28244
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const double pi=acos(-1);





int main() 
{
  ll N,K; cin>>N>>K;
  ll R,S,P; cin>>R>>S>>P;
  string T; cin>>T;
  vector<string> vec(K,"");
  rep(i,N)
  {
    vec.at(i%K).push_back(T.at(i));
  }
  ll ans=0;
  for(auto str:vec)
  {
    rep(i,str.size())
    {
      if(str.at(i)=='s') {ans+=R;}
      if(str.at(i)=='p') {ans+=S;}
      if(str.at(i)=='r') {ans+=P;}
      if(i==str.size()-1) {break;}
      if(str.at(i)==str.at(i+1)) {i++;}
    } 
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 5120
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define REP(i,j) for(int i=0;i<j;i++)
#define FORN(i,j,k) for(int i=j;i<k;i++)
#define vi vector<int>
#define vvi vector<vi >
#define pii pair<int,int>
#define vpii vector<pii >
using namespace std;
const int co[33]={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main(void){
	int k;
	cin>>k;
	cout<<co[k];
	return 0;
}

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

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
using namespace std;
void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }

//---------------------------------------------------------------------------------------------------
void _main() {
    ll N, M;
    cin >> N >> M;

    if (M == 1) {
        cout << "1 2" << endl;
        return;
    }

    ll i1 = 1, i2 = M + 2;

    repd(diff, M, 1) {
        cout << i1 << " " << i1 + diff << endl;
        i1++;
        swap(i1, i2);
    }
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;


int main() {
int A, B, C, D; cin >> A >> B >> C >> D;

if (A <= C){
    if (C < B) {
        if (D <= B) {cout << D - C << "\n"; return 0;}
        else {cout << B - C << "\n"; return 0;}
    }
    else {cout << 0 << "\n"; return 0;}
}
else {
    if (A <= D) {
        if (D >= B) {cout << B - A << "\n"; return 0;}
        else {cout << D - A << "\n"; return 0;}
    }
    else {cout << 0 << "\n"; return 0;}
}

return 0;
}

// 境界，出力文字列 チェック
// int は ± 2*10⁹.
// map[]は対数時間．unordered_map[]は一定時間．


Measured memory_bytes: 256
n = int(input())
a = [0] + list(map(int, input().split())) + [0]

total = 0
for i in range(1, len(a)):
    total += abs(a[i] - a[i-1])

for i in range(1, n+1):
    print(total - abs(a[i] - a[i-1]) - abs(a[i+1] - a[i]) + abs(a[i+1] - a[i-1]))


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

using namespace std;
using ll = long long;
using v1 = vector<int>;
using vl = vector<long long>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

int main(){
	int n;
	cin >> n;
	bool b = true;
	map<ll, int> a;
	rep(i, n){
		ll x;
		cin >> x;
		if(a.find(x) != a.end()){
			cout << "NO" << endl;
			b = false;
			break;
		}else{
			a[x] = 1;
		}
	}
	if(b) cout << "YES" << endl;
}


Measured memory_bytes: 15948
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))
#define PRECISION(x) std::fixed << std::setprecision(x)

using namespace std;

using ll = long long;
using VI = std::vector<int>;
using VI2D = std::vector<vector<int>>;
using VLL = std::vector<long long>;
using VLL2D = std::vector<vector<long long>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T, std::size_t N>
struct make_vector_type {
	using type =
		typename std::vector<typename make_vector_type<T, (N - 1)>::type>;
};

template <typename T>
struct make_vector_type<T, 0> {
	using type = typename std::vector<T>;
};

template <typename T, size_t N>
auto make_vector_impl(const std::vector<std::size_t>& ls, T init_value) {
	if constexpr(N == 0) {
		return std::vector<T>(ls[N], init_value);
	} else {
		return typename make_vector_type<T, N>::type(
			ls[N], make_vector_impl<T, (N - 1)>(ls, init_value));
	}
}

template <typename T, std::size_t N>
auto make_vector(const std::size_t (&ls)[N], T init_value) {
	std::vector<std::size_t> dimensions(N);
	for(int i = 0; i < N; i++) {
		dimensions[N - i - 1] = ls[i];
	}
	return make_vector_impl<T, N - 1>(dimensions, init_value);
}

template <typename T>
std::vector<T> make_vector(std::size_t size, T init_value) {
	return std::vector<T>(size, init_value);
}

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max<T>(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min<T>(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

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

	int n = s.size();
	REP(i, n - 1) {
		if(s[i] == s[i + 1]) {
			cout << i + 1 << " " << i + 2 << endl;
			return 0;
		}
	}
	REP(i, n - 2) {
		if(s[i] == s[i + 2]) {
			cout << i + 1 << " " << i + 3 << endl;
			return 0;
		}
	}
	cout << "-1 -1" << endl;
	return 0;
}


Measured memory_bytes: 3704
var lineList = require('fs').readFileSync('/dev/stdin','utf8').trim().split('\n')
var n = parseInt(lineList[0])
var s = lineList[1]

var answer = 'No'

if(s.slice(0, n/2) === s.slice(n/2, s.length)) {
  answer = 'Yes'
}

console.log(answer)


Measured memory_bytes: 7372
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int H = scanner.nextInt();
        int[] a = new int[H];
        for (int i = 0; i < H; i++) {
            a[i] = scanner.nextInt();
        }
        builMaxHeap(a);
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < H; i++) {
            sb.append(" " + String.valueOf(a[i]));
        }
        System.out.println(sb.toString());
    }

    private static void maxHeapify(int[] a, int i) {
        int l = (i + 1) * 2 - 1;
        int r = (i + 1) * 2;
        int largest = i;
        if (l < a.length && a[l] > a[i]) {
            largest = l;
        }
        if (r < a.length && a[r] > a[largest]) {
            largest = r;
        }
        if (largest != i) {
            int t = a[i];
            a[i] = a[largest];
            a[largest] = t;
            maxHeapify(a, largest);
        }
    }

    private static void builMaxHeap(int[] a) {
        for (int i = a.length / 2; i >= 0; i--) {
            maxHeapify(a, i);
        }
    }
}

Measured memory_bytes: 167892
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=1000005,md=998244353;
int n,m,ans;
int nyc[N],fac[N],facn[N];
inline int exgcd(int a,int b,int &x,int &y)
{
	if(b==0)
	{
		x=1;
		y=0;
		return a;
	}
	int t=exgcd(b,a%b,y,x);
	y-=a/b*x;
	return t;
}
inline int inv(int a)
{
	int x=0,y=0;
	exgcd(a,md,x,y);
	return (x+md)%md;
}
inline int C(int n,int m)
{
	return (ll)fac[n]*facn[m]%md*facn[n-m]%md;
}
inline int Cn(int n,int m)
{
	return (ll)facn[n]*fac[m]%md*fac[n-m]%md;
}
int main()
{
	scanf("%d%d",&n,&m);
	inv(1);
	nyc[1]=1;
	fac[0]=facn[0]=fac[1]=facn[1]=1;
	for(int i=2;i<=n+m;i++)
	{
		nyc[i]=(ll)(md-md/i)*nyc[md%i]%md;
		fac[i]=(ll)fac[i-1]*i%md;
		facn[i]=(ll)facn[i-1]*nyc[i]%md;
	}
	for(int i=1;i<=n&&i<=m;i++)
		ans=(ans+(ll)C(n+m-2*i,n-i)*C(2*i,i)%md)%md;
	ans=(ll)ans*nyc[2]%md*Cn(n+m,n)%md;
	ans=(ans+max(n,m))%md;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 11904
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pb push_back
#define f first
#define s second
#define MOD 1000000007
 #define PI 3.141592653
using namespace std;

void solve(){
	int a,b,h,m;
	cin>>a>>b>>h>>m;
	int tt = h*60+m;
	int ah = tt%720;
	int mh = tt%60;
	long double xh,yh,xm,ym;
	xh = a*sin(ah*PI/360.0);
	yh = a*cos(ah*PI/360.0);
	xm = b*sin(mh*PI/30.0);
	ym = b*cos(mh*PI/30.0);

	cout<<sqrt((xh-xm)*(xh-xm) + (yh-ym)*(yh-ym));

}


int main()
{ 
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout<<fixed<<setprecision(12);
	int t =1; //cin>>t;
	for(int i=1; i<=t; i++){
		solve();
		cout<<"\n";
	}
	return 0;

}

Measured memory_bytes: 4112
while True:
    a,b=map(int,input().split())
    if a==0 and b==0:
        break
    for i in range(a):
        for k in range(b):
            if i%2==0 and k%2==0 or i%2==1 and k%2==1:
                print("#", end="")
            else:
                print(".",end="")
        print()
    print()


Measured memory_bytes: 7000
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

class UnionFind {
public:
	UnionFind(int n) {
		depth.resize(n, 0);
		for (int j = 0; j < n; j++)
			parent.push_back(j);
		num.resize(n, 1);
	}

	void unite(int a, int b) {
		int ra = find(a);
		int rb = find(b);
		int da = depth[ra];
		int db = depth[rb];

		if (ra == rb)
			return;

		if (da > db) {
			parent[rb] = ra;
			num[ra] += num[rb];
		}
		else {
			parent[ra] = rb;
			num[rb] += num[ra];
			if (da == db)
				depth[rb] += 1;
		}

	}
	int getNum(int i) {
		int r = find(i);
		return num[r];
	}

	bool same(int a, int b) {
		return find(a) == find(b);
	}

	int find(int x) {
		int r = parent[x];
		if (x == r)
			return x;

		return parent[x] = find(r);
	}
private:
	int n;
	vector<int> parent;
	vector<int> depth;
	vector<int> num;
};



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

	vector<vector<int>> langs(m);
	FOR(i, 0, n) {
		int k;
		cin >> k;
		FOR(j, 0, k) {
			int l;
			cin >> l;
			l--;
			langs[l].push_back(i);
		}
	}

	UnionFind uf(n);
	FOR(i, 0, m) {
		FOR(j, 1, langs[i].size()) {
			uf.unite(langs[i][j], langs[i][j - 1]);
		}
	}
	if (uf.getNum(0) == n) {
		cout << "YES" << endl;
	}
	else
		cout << "NO" << endl;




	return 0;
}

Measured memory_bytes: 4736
#include<iostream>
#include<cstring>

using namespace std;
char word[1000];
char sent[100000];
int main() {
	//freopen("in","r",stdin);
	cin>>word; int cnt = 0;
	while(1) {
		cin>>sent;
		if(strcmp(sent,"END_OF_TEXT")==0) break;
		for(int i=0;i<strlen(sent);i++) {
			if('A'<=sent[i]&&sent[i]<='Z') sent[i] += 32;
		}

		if(strcmp(sent,word)==0) cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  int a=0,b=0;
  for(int i=0; i<n; ++i){
    if(s[i]=='I'){
      a+=1;
    } else {
      a-=1;
    }
    if(a>b) b=a;
  }
  cout<<b<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

// vector<p> cut(M);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// sort(cut.begin(),cut.end());

int main(void)
{
    int A,B,K;cin>>A>>B>>K;
    int a = min(A,B);
    int cnt=0;
    for(int i=a; i>0;i--){
      if(A%i==0 && B%i==0) cnt++;
      if(K==cnt){
        cout<<i<<endl;
        return 0;
      }
    }
    return 0;

}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define FOR(i,a,n) for(i=(a);i<(n);i++)
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
void fill(int a[],int b,int c){
	int i;
	FOR(i,0,b) a[i]=c;
	return;
}
int a[2000];
int b[2000];
int main(void)
{
	int i,j;
	ll n,x,k,ans=0;
	scanf("%lld%lld",&n,&x);
	FOR(i,0,n){
		scanf("%d",&a[i]);
		b[i]=a[i];
		ans+=a[i];
	}
	FOR(i,1,n){
		k=x*i;
		FOR(j,0,n){
			b[j]=MIN(b[j],a[(j-i+n)%n]);
			k+=b[j];
		}
		ans=MIN(ans,k);
	}
	printf("%lld\n",ans);
	return 0;
}
    
    


Measured memory_bytes: 128
#include <stdio.h>

int c[10][10];
int A[205][205];

int min(int a,int b){
	if(a<=b){return a;}
	else{return b;}
}

void warshall_floyd(){

	int i,j,k;

	for(k=0;k<=9;k++){
		for(i=0;i<=9;i++){
			for(j=0;j<=9;j++){
				c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
			}
		}
	}

}

int main(){

	int H,W;

	scanf("%d %d",&H,&W);

	int i,j;


	for(i=0;i<=9;i++){
		for(j=0;j<=9;j++){
			scanf(" %d",&c[i][j]);
		}
	}

	warshall_floyd();

	int ans=0;

	for(i=0;i<H;i++){
		for(j=0;j<W;j++){
			scanf(" %d",&A[i][j]);
			if(A[i][j]!=1&&A[i][j]!=1){
			ans+=c[A[i][j]][1];
			}
		}
	}
	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 512
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		for(int t = 0; t < T; t++) {
			int N = sc.nextInt();
			long ans = 0;
			List<Integer>[] X = new ArrayList[N+1];
			List<Integer>[] Y = new ArrayList[N+1];
			for(int i = 0; i <= N; i++) {
				X[i] = new ArrayList<>();
				Y[i] = new ArrayList<>();
			}
			for(int i = 0; i < N; i++) {
				int K = sc.nextInt()-1;
				int L = sc.nextInt();
				int R = sc.nextInt();
				if(L - R > 0) {
					ans += L;
					X[K].add(L - R);
				}
				else {
					if(K == N - 1)
						ans += L;
					else {
						ans += R;
						Y[K+1].add(R - L);
					}
				}
			}
			PriorityQueue<Integer> pq1 = new PriorityQueue<>();
			PriorityQueue<Integer> pq2 = new PriorityQueue<>();
			for(int i = 0; i < N; i++) {
				for(int x : X[i])
					pq1.offer(x);
				while(pq1.size() > i + 1)
					ans -= pq1.poll();
				for(int y : Y[N-1-i])
					pq2.offer(y);
				while(pq2.size() > i + 1)
					ans -= pq2.poll();
			}
			System.out.println(ans);
		}
	}

}

Measured memory_bytes: 88164
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;

int main(){
	int n;
	string s;
	cin>>n>>s;
	int num1[26];
	int num2[26];
	int num3[26];
	memset(num1,0,sizeof(num1));
	memset(num2,0,sizeof(num2));
	memset(num3,0,sizeof(num3));
	int x = 0;
	for(int i=0;i<n;i++){
		x = s[i] - 'a' + 0;
		num1[x]++;
	}
	int m = 0;
	int res = 0;
	for(int j=1;j<n;j++){
		for(int i=0;i<j;i++){
			x = s[i] - 'a' + 0;
			num2[x]++;
		}
		for(int i=0;i<26;i++){
			num3[i] = num1[i] - num2[i];
			if(num3[i]!=0&&num2[i]!=0) 
				m++;
		}
		if(m>res) res = m;
		m = 0;
		memset(num2,0,sizeof(num2));
		memset(num3,0,sizeof(num3));
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 256
l = int(input())
ll = float(l)
a=0
b=0
c=0

if(ll%3 == 0):
	a=ll/3
	b=ll/3
	c=ll/3
else:
	a=ll/3
	b=a
	c=ll-a-b

    
print(a*b*c)

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

int main(){
  int K;
  string S;
  cin >> K;
  cin >> S;
  if(S.size() <= K){
    cout << S;
  }else{
    rep(i,K){
      cout << S.at(i);
    }
    cout << "...";
  }
  return 0;
}

Measured memory_bytes: 3628
// unolight {{{
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(c) begin(c),end(c)
#define REP(i,n) for ( int i=0; i<(int)(n); i++ )
#define REP1(i,a,b) for ( int i=(int)(a); i<=(int)(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;

void RI() {}

template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}

template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);
template <typename A, typename B>
ostream &operator<<(ostream &s, const pair<A, B> &p)
{
    return s << "(" << p.first << "," << p.second << ")";
}

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}

template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }
// }}}

// const int MAX_N = 100005;
int n;
LL a, d;
void input()
{
    RI(n);
    scanf("%lld %lld", &a, &d);
}

void solve() {
    if(d == 0) {
        if(a==0)
            printf("1\n");
        else
            printf("%d\n", n+1);
        return;
    }

    if(d < 0) {
        d = -1LL*d;
        a = -1LL*a;
    }
    // i * a + k * d
    // sum(0..i-1) <= k <= sum(n-i..n-1)
    unordered_map<LL, vector<pair<LL, LL>>> dic;
    REP(i, n+1)
    {
        LL ai = i * a;
        LL l = ai/d + 1LL*(i - 1)*i/2;
        LL r = ai/d + 1LL*(n-1+n-i)*i/2;
        dic[(ai%d + d)%d].emplace_back(l, r+1);
    }

    LL ans = 0;

    for (auto t:dic) {
        auto v = t.second;
        sort(v.begin(), v.end());
        #ifdef DEBUG
            cout << v << endl;
        #endif
        LL end = -1e18;
        for (auto p : v)
        {
            LL s = p.first, e = p.second;
            if(end < s) {
                ans += e - s;
                end = e;
            } else if(e > end) {
                ans += e - end;
                end = e;
            }
        }
    }
    printf("%lld\n", ans);
}

int main( int argc, char *argv[] ) {
    input();
    solve();
    return 0;
}


Measured memory_bytes: 17864
import collections

def solve(n, points):
    if n == 1:
        return 1
    a = []
    for i in range(n-1):
        for j in range(i + 1, n):
            x = points[i][0] - points[j][0]
            y = points[i][1] - points[j][1]
            if x > 0:
                a.append((x, y))
            elif x < 0:
                a.append((-x, -y))
            else:
                a.append((0, abs(y)))

    c = collections.Counter(a).most_common()[0][1]
    return n - c

n = int(input())
points = [list(map(int, input().split(' '))) for _ in range(n)]
print(solve(n, points))



Measured memory_bytes: 3700
#include <iostream>
#include <cctype>
#include <cstdio>
#include <cstring>
#include <typeinfo>
#include <queue>
#include <math.h>
using namespace std;



int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if (a+b==c || b+c==a || c+a==b){
		cout<<"Yes"<<endl;
	}
	else cout<<"No"<<endl;


return 0;
}

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

const int maxn = 200005;

map<pair<int, int>, int> mp;

struct DSU {
  int par[maxn], sz[maxn];
  void init(int N){
    for(int i = 1; i <= N; ++i){
      par[i] = i; sz[i] = 1;
    }
  }
  int get(int x){
    if(par[x] == x)return x;
    else {
      return par[x] = get(par[x]);
    }
  }
  void unite(int x, int y){
    x = get(x); y = get(y);
    if(x == y)return;
    if(sz[x] < sz[y])swap(x, y);
    par[y] = x;
    sz[x] += sz[y];
  }
};

int main(int argc, char const *argv[])
{
	int n, m, k; 
  scanf("%d %d %d", &n, &m, &k);
  DSU t, t1;
  t.init(n); t1.init(n);
  for(int i = 0; i < m; ++i){
    int x, y;
    scanf("%d %d", &x, &y); 
    t.unite(x, y);
  }
  for(int i = 0; i < k; ++i){
    int x, y;
    scanf("%d %d", &x, &y);
    t1.unite(x, y);
  }
  for(int i = 1; i <= n; ++i){
    mp[{t.get(i), t1.get(i)}]++;
  }
  for(int i = 1; i <= n; ++i){
    printf("%d ", mp[{t.get(i), t1.get(i)}]);
  }

	return 0;
}

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

typedef long long ll;
typedef long double ld;
//#define int ll
//#define endl '\n'

// use unique(x) - removec consecutive items, returns vec.begin() + number of items
// for vector: sort(all(vec)); vec.erase(unique(all(vec)), vec.end());
// use iota(all(vec), 0) for filling a vector with 0,1,2...
// use fill(all(vec), 1) for filling a vector with 1,1,1...
// use rotate(vec.begin(), vec.begin() + 1, vec.end()) to rotate a vector | middle arg becomes first
// print number in binary -> cout << bitset<20>(n);

main(){
	cin.tie(0);cin.sync_with_stdio(0);
	ll x,k,d;cin>>x>>k>>d;
	ll need=abs(x/d);
	if(need>=k){
		cout<<abs(abs(x)-d*k)<<endl;
		return 0;
	}
	if(x>0)x-=d*need;
	else x+=d*need;
	k-=need;
	if(k%2==0){
		cout<<abs(x)<<endl;
		return 0;
	}
	if(x>0)cout<<abs(x-d)<<endl;
	else cout<<abs(x+d)<<endl;
}


Measured memory_bytes: 3648
/*
          Author: Prokash
                       CSE48, JU
*/

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,t,in;
    vector<ll>v;
    cin>>t;
    for(int i=0;i<t;i++)
    {
        cin>>in;
        v.push_back(in);
    }
    sort(v.begin(),v.end());
    cout<<v[v.size()-1]-v[0]<<endl;
    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  int m; cin >> m;
  vector<int> d(m), c(m);
  int ans = 0;
  for(int i = 0; i < m; i++){
    cin >> d[i] >> c[i];
    ans += c[i];
  }
  ans--;

  vector<int> v;
  int sum = 0;
  for(int i = 0; i < m; i++){
    if(sum > (1LL << 60) - c[i] * d[i]){
      v.push_back(sum);
      sum = 0;
    }
    sum += c[i] * d[i];
    if(i == m-1) v.push_back(sum);
  }

  int res = 0, cnt = 0;
  for(int p : v){
    while(p > 10){
      cnt += p/10;
      p = p/10 + p%10;
    }
    res += p;
  }
  ans += cnt + res / 10;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3328
# -*- coding: utf-8 -*-
from operator import add


import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


class SegmentTree:
    def __init__(self, array, operator, identity_element):
        _len = len(array)
        self.__op = operator
        self.__size = 1 << (_len - 1).bit_length()
        self.__tree = [identity_element] * self.__size + \
            array + [identity_element] * (self.__size - _len)
        self.__ie = identity_element

        for i in range(self.__size - 1, 0, -1):
            self.__tree[i] = self.__tree[i * 2] + self.__tree[i * 2 + 1]

    def update(self, i, v):
        i += self.__size
        self.__tree[i] = v
        while i:
            i //= 2
            self.__tree[i] = self.__tree[i * 2] + self.__tree[i * 2 + 1]

    def query(self, l, r):
        """[l, r)
        """
        l += self.__size
        r += self.__size
        ret = self.__ie
        while l < r:
            if l & 1:
                ret += self.__tree[l]
                l += 1
            if r & 1:
                r -= 1
                ret += self.__tree[r]
            l //= 2
            r //= 2
        return ret

    def __getitem__(self, key):
        return self.__tree[key + self.__size]


@mt
def slv(N, Q, C, LR):
    LR.sort(key=lambda x: x[2])
    ans = [-1] * Q

    st = SegmentTree([0]*(N+1), add, 0)
    la = [-1] * (N+1)
    p = 0
    for i, l, r in LR:
        l -= 1
        r -= 1
        for j in range(p, r+1):
            c = C[j]
            if la[c] != -1:
                st.update(la[c], st[la[c]]-1)
            la[c] = j
            st.update(j, st[j]+1)
        p = r+1
        ans[i] = st.query(l, r+1)
    return ans

def main():
    N, Q = read_int_n()
    C = read_int_n()
    LR = [[_, *read_int_n()] for _ in range(Q)]
    print(*slv(N, Q, C, LR), sep='\n')

    # N = 5 * 10**5
    # Q = N
    # C = [i for i in range(1, N+1)]
    # LR = []
    # from random import randint
    # for _ in range(Q):
    #     l = randint(1, N-1)
    #     r = randint(l, N-1)
    #     LR.append([_, l, r])
    # print(*slv(N, Q, C, LR), sep='\n')



if __name__ == '__main__':
    main()


Measured memory_bytes: 218036
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
#define N_MAX 1000
using namespace std;

int main() {
	int N, M; cin >> N >> M;
	vector<int> p(M);
	vector<string> S(M);
	for (int i = 0; i < M; i++) cin >> p[i] >> S[i];
	vector<bool> b(N+1);
	int wanum[N + 1] = {};

	int ac = 0, wa = 0;
	for (int i = 0; i < M; i++) {
		if (b[p[i]] == 1) continue;

		if (S[i] == "WA")wanum[p[i]]++;
		if (S[i] == "AC") {
			b[p[i]] = 1;
			ac++;
			wa += wanum[p[i]];
		}
	}

	cout << ac << ' ' << wa << endl;
}

Measured memory_bytes: 6528
#!/usr/bin/env perl

use strict;
use warnings;
use utf8;
use autodie;
use v5.18;
use Carp qw/ croak /;

my $S = <>;
chomp $S;
croak "invalid value of \$S = '$S'"
    if ( $S !~ m{ \A Sunny | Cloudy | Rainy \z }x );

if ( $S eq 'Sunny' ) {
    say 'Cloudy';
}
elsif ( $S eq 'Cloudy' ) {
    say 'Rainy';
}
else {
    say 'Sunny';
}


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

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] SP; } cout BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout BR;

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

  vector<ll> a(N);
  ll x1, x2, x3, x4;
  x1 = x2 = x3 = x4 = 0;
  ll c1, c2, c3, c4;
  c1 = c2 = c3 = c4 = 0;

  for (int i = 0; i < N; i++) {
    cin >> a[i];
    if (a[i] > 0) {

      if (x1 == 0) {
        x1 = a[i];
      } else if (x2 == 0 && x1 != a[i]) {
        x2 = a[i];
      } else if (x3 == 0 && x1 != a[i] && x2 != a[i]) {
        x3 = a[i];
      } else if (x1 != a[i] && x2 != a[i] && x3 != a[i]) {
        x4 = a[i];
      }

      if (x1 == a[i]) c1++;
      if (x2 == a[i]) c2++;
      if (x3 == a[i]) c3++;
    }
  }

  if ( x1 == 0 ) {
    cout << "Yes\n";
  } else if (x2 == 0 && (N - c1) * 3 == N) {
    cout << "Yes\n";
  } else if (x4 == 0 && c1 == c2 && c2 == c3 && (x1^x2^x3) == 0) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }

  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

ll stoi9(string s) {
    // 10 ^ 9倍した整数を返す
    int digit = 0;
    for (int i = sz(s)-1; i >= 0; i--) {
        if (s[i] == '.') {
            s.replace(i, 1, "");
            break;
        }
        digit++;
        if (i == 0) digit = 0;
    }
    ll x = stoll(s);
    rep(i, 9-digit) x *= 10;
    return x;
}

int table[20][20];
ll cum[20][20];

int main() {
    int N;
    cin >> N;
    ll ans = 0;
    rep(i, N) {
        string S;
        cin >> S;
        ll x = stoi9(S);
        int two = 0, five = 0; // 2と5で何回割れるか
        while (x%2 == 0 && two < 18) {
            two++;
            x /= 2;
        }
        while (x%5 == 0 && five < 18) {
            five++;
            x /= 5;
        }
        table[two][five]++;
        if (two >= 9 && five >= 9) ans--;
    }
    for (int i = 18; i >= 0; i--) {
        for (int j = 18; j >= 0; j--) {
            cum[i][j] = table[i][j] + cum[i+1][j] + cum[i][j+1] - cum[i+1][j+1];
        }
    }
    for (int i = 0; i < 19; i++) {
        for (int j = 0; j < 19; j++) {
            ans += table[i][j] * cum[18-i][18-j];
        }
    }
    ans /= 2;
    cout << ans << '\n';
    return 0;
}


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

int main() {
  long long N,A,B,Ans=0;
  cin>>N>>A>>B;
  Ans=N/(A+B)*A;
  if(N%(A+B)<A){Ans=Ans+N%(A+B);}else{Ans=Ans+A;}
  cout<<Ans<<endl;
}

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

int main()
{
	int n,x,i;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&x);
		if(x%2==0&&x%3!=0&&x%5!=0){
			printf("DENIED");
			return 0;
		}
	}
	printf("APPROVED");
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::collections::VecDeque;
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::HashMap;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_variables)]
        #[allow(unused_mut)]
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("parse error")
    };
}

fn main() {
    input!{
        a: i32,
        b: i32,
    }
    println!("{}", a * b);
}


Measured memory_bytes: 2124
#include <bits/stdc++.h>
#define pb push_back
#define A first
#define B second
using namespace std;

typedef long long ll;
typedef pair <int, int> pi;
constexpr double PI = atan(1) * 4;
constexpr int inf = 0x3f3f3f3f;
inline int LSB(int i) {return (i & -i);}

int n, c, w[105];
ll v[105], dp[100005], ans;

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

    cin >> n >> c;
    for(int i = 0; i < n; i++){
    	cin >> w[i] >> v[i];
    }
    fill(dp, dp + c + 1, -1);
    dp[0] = 0;
    for(int i = 0; i < n; i++){
    	for(int j = c - w[i]; j >= 0; j--){
    		if(dp[j] != -1){
    			dp[j+w[i]] = max(dp[j+w[i]], dp[j] + v[i]);
    			ans = max(ans, dp[j+w[i]]);
    		}
    	}
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 4396
n,m,c=map(int,input().split())
B=[int(_) for _ in input().split()]
count=0
for i in range(n):
    A=[int(_) for _ in input().split()]
    D=c
    for j in range(m):
        D+=A[j]*B[j]
    if D>0:
        count+=1
print(count)

Measured memory_bytes: 3060
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
int main() {
  int n;
  cin>>n;
  double a,b,c,d,e,f,x,y,r,x1,x2,x3,y1,y2,y3;
  for(int i=0;i<n;i++) {
    cin>>x1>>y1>>x2>>y2>>x3>>y3;
    a = sqrt((x3 - x2) * (x3 - x2) + (y3 - y2) * (y3 - y2));
    b = sqrt((x1 - x3) * (x1 - x3) + (y1 - y3) * (y1 - y3));
    c = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
    d = acos((b * b + c * c - a * a) / (2 * b * c));
    e = acos((a * a + c * c - b * b) / (2 * a * c));
    f = acos((b * b + a * a - c * c) / (2 * b * a));
    x = (x1 * sin(d * 2) + x2 * sin(e * 2) + x3 * sin(f * 2)) / (sin(d * 2) + sin(e * 2) + sin(f * 2));
    y = (y1 * sin(d * 2) + y2 * sin(e * 2) + y3 * sin(f * 2)) / (sin(d * 2) + sin(e * 2) + sin(f * 2));
    r = a / (2 * sin(d));
    cout<<fixed<<setprecision(3)<<x<<" "<<y<<" "<<r<<endl;
  }
  return 0;
}



Measured memory_bytes: 3624
def readInt():
    return list(map(int,input().split()))

n,x,y = readInt()
x -= 1
y -= 1
D = dict()
for i in range(n-1):
    for j in range(i+1,n):
        d = min(j-i, abs(x-i)+1+abs(y-j))
        if d not in D:
            D[d] = 1
        else:
            D[d] += 1
        
# print(D)
for k in range(1,n):
    if k in D:
        print(D[k])
    else:
        print(0)

Measured memory_bytes: 3572