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

using namespace std;
#define mod 1000000007
typedef vector< vector<long long> > vv;
vv mul(vv a,vv b)
{
    vv rez(a.size(),vector<long long>(b.size(),0));
    for(long long i=0;i<a.size();i++)
    {
        for(long long j=0;j<a.size();j++)
        {
            for(long long k=0;k<a.size();k++)
            {
                rez[i][j]+=a[i][k]*b[k][j];
                rez[i][j]%=mod;
            }
        }
    }
    return rez;
}
vv power(vv a,long long k)
{
    vv rez(a.size(),vector<long long>(a.size(),0));
    for(long long i=0;i<a.size();i++)
    {
        for(long long j=0;j<a.size();j++)
        {
            if(i==j)rez[i][j]=1;
        }
    }
    while(k)
    {
        if(k&1)
        {
            rez=mul(rez,a);
        }
        a=mul(a,a);
        k>>=1;
    }
   return rez;
}
int main()
{
    long long n,k;
    cin >> n >> k;
    vv a(n,vector<long long>(n));
    for(long long i=0;i<n;i++)
    {
        for(long long j=0;j<n;j++)
        {
            cin >> a[i][j];
        }
    }

    a=power(a,k);
    long long rez=0;
    for(long long i=0;i<n;i++)
    {
        for(long long j=0;j<n;j++)
        {
            rez+=a[i][j];
            rez%=mod;
        }
    }
    cout << rez;
    return 0;
}


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

int main() {
	int n;
	cin>>n;
	int k;
	cin>>k;
	int arr[n];
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	sort(arr,arr+n);
	int sum=0;
	for(int i=0;i<k;i++)
	{
		sum+=arr[i];
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 3632
s = gets.chomp
n = s.length
ans = 0
MOD = 2019

cnt = Array.new(MOD, 0)

cnt[0]+=1
pow = 1
now = 0

s.reverse.each_char do |i|
  now = (now+i.to_i*pow)%MOD
  # p now
  cnt[now]+=1 
  pow=pow*10%MOD
end

MOD.times do |i|
  ans += cnt[i]*(cnt[i]-1)/2
end

# p cnt
puts ans

Measured memory_bytes: 14844
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int p1 = sc.nextInt();
		int p2 = sc.nextInt();
		int p3 = sc.nextInt();
		int j1 = sc.nextInt();
		int j2 = sc.nextInt();
		int p = p1, j = j1, r;

		if(p<=p2){
			if(p3<p) p = p3;
		}else if(p>p2){
			if(p2<=p3) p = p2;
			else if(p3<p2)p = p3;
		}
		if(j2<j)j = j2;
		r = p+j-50;
		System.out.println(r);
	}

}

Measured memory_bytes: 26068
x,y,z = input()
if x == 'R':
    if y == 'R':
        if z == 'R':
            print('3')
        else:
            print('2')
    else:
        print('1')
elif x == 'S':
    if y == 'R':
        if z == 'R':
            print('2')
        else:
            print('1')
    elif z == 'R':
        print('1')
    else:
        print('0')

Measured memory_bytes: 9012
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  int i;
  
  for (i=1 ; i<=N ; i++){
    string x;
    cin >> x;
    
    if(x == "Y"){
      cout << "Four" << endl;
      break;
    }
    if(i==N){
    cout << "Three" << endl;
    }
  }
}

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

void max_self(ll &a,ll b)
{
    a = max(a,b);
}

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    ll n,W;
    cin>>n>>W;
    vector<ll> dp(W+1);
    //dp[i] = the maxiume total value of items with total weights exactly i

    for(int items = 0 ; items<n ; ++items)
    {
        ll weight,value;
        cin>>weight>>value;

        for(ll weight_already = W-weight ; weight_already >=0 ; --weight_already)
        {
            max_self(dp[weight_already + weight] , dp[weight_already] + value);
        }
    }
    ll ans=0;
    for(int i=0 ; i<=W ; ++i)
        max_self(ans,dp[i]);
    cout<<ans;
}


Measured memory_bytes: 1024
import sys
s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

# 約数リスト
def divisors(n):
    d = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            d.append(i)
            if i != n // i:
                d.append(n//i)
    #d.sort()
    return d

def main():
    N = i2n()
    A = i2nn()
    X = [0] * N
    Y = [0] * N
    for i in range(N, 0, -1):
        t = (A[i-1] + X[i-1]) % 2
        if t > 0:
            Y[i-1] = 1
            dd = divisors(i)
            for d in dd:
                X[d-1] += t
    B = []
    for i, y in enumerate(Y):
        if y > 0:
            B.append(i+1)
    M = len(B)
    print(M)
    for i, b in enumerate(B):
        print(b, end=' ')
    print()

main()


Measured memory_bytes: 67664
x,n=map(int,input().split())

p=set(map(int,input().split()))

n=set(n for n in range(-100,102))

pd=list(n-p)

min1=1000

for i in range(len(pd)):
    if abs(pd[i]-x)<abs(min1-x):
        min1=pd[i]
    elif abs(pd[i]-x)==abs(min1-x):
        min1=min(pd[i],min1)
print(min1)


Measured memory_bytes: 9020
n = gets.to_i
cnt = 10.times.map{[0]*10}
(1..n).each{|x|
  s = x.to_s
  cnt[s[0].to_i][s[-1].to_i] += 1
}

ans = 0
9.times{|i|
  9.times{|j|
    ans += cnt[i+1][j+1] * cnt[j+1][i+1]
  }
}

p ans

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

int main() {
    long long X;
    cin >> X;
    long long A, B;
    bool found = false;
    for (long long i = -200; i <= 200; i++) {
        for (long long j = -200; j <= 200; j++) {
            if (pow(i, 5) - pow(j, 5) == X) {
                A = i;
                B = j;
                found = true;
                break;
            }
        }
        if (found) {
            break;
        }
    }
    cout << A << " " << B << endl;
}

Measured memory_bytes: 4096
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001; // > 10^9
const int MOD = (int)1e9 + 7;
const ll INFLL = 1001001001001001001;  // > 10^18
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

const int MAX_V = 1001;

vector<vector<int> > d(MAX_V, vector<int>(MAX_V, INF)); //距離と隣接行列を兼ねる（ただし対角=0とする）
vector<vector<int> > pre(MAX_V, vector<int>(MAX_V, 0)); //iからjへの最短経路でjの前の点
int n; 
void warshall_floyd(bool rep_pre = true) {
    if(rep_pre) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                pre[i][j] = i;
            }
        }
    }
    for (int k = 0; k < n; k++) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                int a = d[i][j];
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
                if(rep_pre && a != d[i][j]) {
                    pre[i][j] = pre[k][j]; //iからjへの最短経路でjの前の点
                }
            }
        }
    }
}

void get_path(int s, int t) {
    while (t != s) {
        cout << t;
        t = pre[s][t];
    }
    cout << s << endl;
}

int main () {

    cin >> n;
    int m; cin >>m;
    rep (i,n) d[i][i] = 0;
    vector<vector<bool> > check(n, vector<bool>(n, false));
    vector<vector<int> > record(n, vector<int>(n, INF));
    for (int i = 0; i < m; i++) {
        int f,t,c; cin >>f>>t>>c;
        f--;
        t--;
        d[f][t] = c;
        d[t][f] = c;  //無向グラフのときはこれもする
        check[t][f] = true;
        check[f][t] = true;
        record[f][t] = c;
        record[t][f] = c;
    }

    warshall_floyd(false);

    for (int k = 0; k < n; k++) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (d[i][j] == d[i][k] + record[k][j]) {
                    check[k][j] = false;
                    check[j][k] = false;
                } 
            }
        }
    }

    int count = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (check[i][j] == true) {
                count++;
            } 
        }
    }

    cout << count/2 << endl;
    return 0;
}


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

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

    int yyyy = stoi(s.substr(0,4));
    int mm = stoi(s.substr(5,2));
    int dd = stoi(s.substr(8,2));

    if (yyyy <= 2019 && mm <= 4 && dd <= 30) {
        cout << "Heisei" << endl;
    } else {
        cout << "TBD" << endl;
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>
#include <time.h>

//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<vector<int>>())

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple

using namespace std;
using ll = long long;
typedef std::pair<int, int> pii;
typedef std::pair<int, double> pid;
typedef std::vector<int> vi;
typedef std::vector<pii> vii;

#define PI 3.14159265358979323846264338327950L
const int mod = 1e9+7;



void solve(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    
    vector<ll> cursum;
    
    cursum.push_back(a[n-1]);
    for(int i = n-2; i > 0; i--){
        ll add = cursum.back()+a[i];
        add %= mod;
        cursum.pb(add);
    }
    
    //for(auto e:cursum) cout << e << " ";
    ll ans = 0;
    
    for(int i = 0; i < n-1; i++){
        ll add = a[i]*cursum[n-2-i];
        add %= mod;
        ans += add;
        ans %= mod;
    }
    cout << ans;
    
};



int main() {
    int T;
    //cin >> T;
    T = 1;
    while (T--) {
        solve();
        cout << endl;
    }
}




Measured memory_bytes: 6932
S=input()
LS=len(S)
T=input()
LT=len(T)

ans=LT
for i in range(LS-LT+1):
  tmp=0
  for j in range(LT):
    if S[i+j]!=T[j]:
      tmp+=1
  #print(tmp)
  ans=min(tmp,ans)
  #tmp=0
print(ans)

Measured memory_bytes: 9064
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(readline())
    for i in range(0,N+1,7):
        if (N-i)%4==0:
            print('Yes')
            break
    else:
        print('No')


if __name__ == '__main__':
    main()


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

using namespace std;

template <class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')
    cerr<<*sdbg++;
  cerr<<"="<<h<<","; 
  _dbg(sdbg+1, a...);
}

template<class T> ostream & operator<<(ostream & os, vector<T> V){
  os<<"[";
  for(auto vv: V) os << vv <<",";
  return os << "]";
}
template<class L, class R> ostream & operator <<(ostream & os, pair<L,R> P){
  return os <<"("<<P.first <<","<<P.second <<")";
}

#ifdef DEBUG
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int N = 55;
const long long INF = 1e18;

int n, m, a, b, c, d, coins;
vector<pair<int, pair<long long, long long> > > V[N];
long long dist[N][N * N];
bool done[N][N * N];
long long exRate[N];
long long waitTime[N];

void dijkstra(int v, int initCoins) {
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= 50 * n; j++) {
            dist[i][j] = INF;
        }
    }
    dist[v][initCoins] = 0;
    priority_queue<pair<long long, pair<int, int>>> Q;
    Q.push({0, {v, initCoins}});
    while (!Q.empty()) {
        int w = Q.top().second.first;
        long long co = Q.top().second.second;
        Q.pop();
        if (done[w][co]) {
            continue;
        }
        done[w][co] = true;
        
        long long timeWait = 1;
        while (true) {
            long long moreCoins = min(50LL * n, co + timeWait * exRate[w]);
            long long totalWait = (long long)timeWait * waitTime[w];
            if (dist[w][moreCoins] > dist[w][co] + totalWait) {
                dist[w][moreCoins] = dist[w][co] + totalWait;
                Q.push({-dist[w][moreCoins], {w, moreCoins}});
            }
            timeWait++;
            if (moreCoins == 50 * n) {
                break;
            }
        }
        
        for (auto p : V[w]) {
            int u = p.first;
            long long cost = p.second.first;
            long long length = p.second.second;
            if (co < cost) {
                continue;
            }
            if (dist[u][co - cost] > dist[w][co] + length) {
                dist[u][co - cost] = dist[w][co] + length;
                Q.push({-dist[u][co - cost], {u, co - cost}});
            }
        }
    }
}

int main() {
    
    scanf("%d %d %d", &n, &m, &coins);
    coins = min(coins, 50 * n);
    for (int i = 1; i <= m; i++) {
        scanf("%d %d %d %d", &a, &b, &c, &d);
        V[a].push_back({b, {c, d}});
        V[b].push_back({a, {c, d}});
    }
    
    for (int i = 1; i <= n; i++) {
        scanf("%lld %lld", &exRate[i], &waitTime[i]);
    }
    
    dijkstra(1, coins);
    
    for (int i = 2; i <= n; i++) {
        long long best = dist[i][0];
        for (int j = 0; j <= 50 * n; j++) {
            best = min(best, dist[i][j]);
        }
        printf("%lld\n", best);
    }
    return 0;
}


Measured memory_bytes: 37524
// http://www.igaris.com/math/c.pdf

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define NEXTP(x) next_permutation(x.begin(),x.end())
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
const ll INF=1e18+7;
const ll MOD=1e9+7;

class comb{
	public:
	vector<ll> f,fr;
	ll MOD;
	//a^(p-1) = 1 (mod p)(p->Prime numbers)
	//a^(p-2) = a^(-1)
	ll calc(ll a,ll b,ll p){//a^(b) mod p   
		if(b==0)return 1;
		ll y = calc(a,b/2,p);y=(y*y)%p;
		if(b & 1) y = (y * a) % p;
		return y;
	}
	void init(ll n,ll mod){//input max_n
		MOD = mod;
		f.resize(n+1);
		fr.resize(n+1);
		f[0]=fr[0]=1;
		for(ll i=1;i<n+1;i++){
			f[i] = (f[i-1] * i) % mod;
			fr[i] = calc(f[i],mod-2,mod);
		}
	}
	ll nCr(ll n,ll r){
		return f[n] * fr[r] % MOD * fr[n-r] % MOD;
	}
};


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,k;
	cin >> n >> k;
	comb co;
	if(n<k){
		cout << 0 << endl;
		return 0;
	}
	co.init(n+k,MOD);
	ll ans = 0;
	FOR(i,1,k+1){
		ans += co.calc(-1,k-i,MOD)*co.nCr(k,i)%MOD*co.calc(i,n,MOD);
		ans %= MOD;
	}
	ans *= co.fr[k];
	ans %= MOD;
	if(ans<0)ans += MOD;
	cout << ans << endl;
}


Measured memory_bytes: 3184
#include <iostream>
#include <string>


using namespace std;

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

	bool flag = true;
	for (int i = 1; i < 3; i++)
	{
		if (s[i] != s[i - 1])
		{
			flag = false;
		}
	}

	if (!flag) cout << "Yes" << endl;
	else  cout << "No" << endl;

}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#include<cmath>
#include<deque>
#include<set>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define INF 1LL << 60
#define MAX 1000000000

const double PI = 3.14159265358979323846;
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
int main() {
	int N, K, S;
	scanf("%d%d%d", &N, &K, &S);
	rep(i, 0, K)printf(i == N - 1 ? "%d\n" : "%d ", S);
	rep(i, 0, N - K)printf(i == N - K - 1 ? "%d\n" : "%d ", S == 1000000000 ? 1 : S + 1);
	return 0;
}

Measured memory_bytes: 1280
#include <cstdio>

#define min(a, b) ((a) < (b) ? (a) : (b))

int main()
{
  long long n, m;
  scanf("%lld %lld", &n, &m);
  long long s = min(n, m / 2);
  printf("%lld\n", s + (m - 2 * s) / 4);
  return 0;
}


Measured memory_bytes: 128
n = gets.to_i
a = gets.split.map(&:to_i)
b = []
f = true
a.each do |x|
  if f
    b.unshift(x)
    f = false
  else
    b << x
    f = true
  end
end
if f
  b.reverse!
end
puts b.join(' ')

Measured memory_bytes: 25696
N=int(input())
ans = []
for i in range(1,N+1):
    if i % 3 == 0 and i % 5 == 0:
        continue
    elif i % 3 == 0 and i % 5 != 0:
        continue
    elif i % 5 == 0 and i % 3 != 0:
        continue
    else:
        ans.append(i)
print(sum(ans))


Measured memory_bytes: 103600
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

int main() {
    int n; cin >> n;
    int ans = 1;
    vector<int> h;
    for(int i = 0; i < n; ++i){
        int x; cin >> x;
        h.push_back(x);
    }
    int y = h[0];
    for(int i = 1; i < n; ++i){
        if(h[i] >= y){
            ans++;
            y = h[i];
        }
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
#define pb push_back
#define mp make_pair 
#define fi first
#define se second
typedef long long ll;
using namespace std;
const ll mod =1e9+7;

void solve()
{  ll n;
   cin>>n;
   ll x,y,sum;
   x=n/500;
   y=n%500/5;
   sum=x*1000+y*5;
   cout<<sum;
}
int main()
{
// #ifndef ONLINE_JUDGE
 //  freopen("ques.txt","r",stdin);
 //  freopen("ans.txt","w",stdout);
// #endif 
 // int t;
 // cin>>t;
 // while(t--)
  { solve();
    cout<<"\n";
  }
  return 0;
}

Measured memory_bytes: 256
a,v = map(int, input().split())
b,w = map(int, input().split())
t = int(input())

if a <= b:
    if a + v * t >= b + w * t:
        print('YES')
    else:
        print('NO')
else:
    if a - v * t <= b - w * t:
        print('YES')
    else:
        print('NO')


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

int main() {
    int a, b;
    cin >> a >> b;
    string ans;
    if (a*b % 2 == 0) {
        ans = "Even";
    }
    else {
        ans = "Odd";
    }

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

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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; }

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

// ------------------------------------------------------------------------------------------

signed main() {
  int a, b, t;
  cin >> a >> b >> t;

  int ans = 0;
  for (int i = 1; ; i++) {
    if (i*a <= t+0.5) {
      ans += b;
    } else break;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class C
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var (N, M) = Scanner.Scan<int, int>();
            var num = new int[N].Select(x => -1).ToArray();
            var ok = true;
            for (var i = 0; i < M && ok; i++)
            {
                var (s, c) = Scanner.Scan<int, int>();
                s--;
                if (num[s] == -1 || num[s] == c) num[s] = c;
                else ok = false;
            }
            if (num[0] == 0 && N > 1) ok = false;
            for (var i = 0; i < N; i++)
            {
                if (num[i] == -1) num[i] = 0;
            }
            if (num[0] == 0 && N > 1) num[0] = 1;
            Console.WriteLine(ok ? string.Join("", num) : "-1");
        }

        public static class Scanner
        {
            private static Queue<string> queue = new Queue<string>();
            public static T Next<T>()
            {
                if (!queue.Any()) foreach (var item in Console.ReadLine().Trim().Split(" ")) queue.Enqueue(item);
                return (T)Convert.ChangeType(queue.Dequeue(), typeof(T));
            }
            public static T Scan<T>() => Next<T>();
            public static (T1, T2) Scan<T1, T2>() => (Next<T1>(), Next<T2>());
            public static (T1, T2, T3) Scan<T1, T2, T3>() => (Next<T1>(), Next<T2>(), Next<T3>());
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>());
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>(), Next<T5>());
            public static IEnumerable<T> ScanEnumerable<T>() => Console.ReadLine().Trim().Split(" ").Select(x => (T)Convert.ChangeType(x, typeof(T)));
        }
    }
}


Measured memory_bytes: 28484
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<pair<int,int> > p(2*n);
	map<int,bool> s;
	for(int i=0;i<n;i++){
		cin>>p[i].first>>p[i].second;
		s[p[i].first]=1;
	}
	for(int i=n;i<2*n;i++)
	cin>>p[i].first>>p[i].second;
	sort(p.begin(),p.end());
	set<int> t;
	int m=0;
	for(int i=0;i<2*n;i++){
		if(s[p[i].first])
		t.insert(p[i].second);
		else{
			int f=-1;
			for(int x : t){
				if(p[i].second>x)
				f=x;
				else
				break;
			}
			if(f!=-1){
				t.erase(f);
				m++;
			}
		}
	}
	cout<<m;
} 

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

    llint N, A, B;
    cin >> N >> A >> B;

    llint ans = 0;
    llint x1, x2;
    cin >> x1;
    REP(i, N-1){
        cin >> x2;
        ans += min(A*(x2-x1), B);
        x1 = x2;
    }

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
void range3(int a, int b, int c)
{
    if (a < b && b < c)
    {
        puts("Yes");
    }
    else
    {
        puts("No");
    }
}
int main(void)
{
    int a, b, c;

    scanf("%d %d %d", &a, &b, &c);
    range3(a, b, c);
    return 0;
}


Measured memory_bytes: 2592
#include<bits/stdc++.h>
#define pb push_back

using namespace std;
typedef long long LL;
const LL MOD = 998244353;
LL fak[200001];

LL pangkat(LL a, LL b) {
	if (b == 0) return 1;
	LL tmp = pangkat(a, b / 2) % MOD;
	tmp = (tmp * tmp) % MOD;
	if (b % 2) tmp *= a, tmp %= MOD;
	return tmp;
}

LL C(int n, int r) {
	if (r == 0) return 1;
	if (n < r) return 0;
	LL tmp = fak[n];
	tmp *= pangkat(fak[r], MOD - 2);
	tmp %= MOD;
	tmp *= pangkat(fak[n - r], MOD - 2);
	tmp %= MOD;
	//printf("%lld\n", tmp);
	return tmp;
}

int main() {
	int N, M, K;
	scanf("%d%d%d", &N, &M, &K);
	fak[0] = 1;
	for (int i = 1; i <= N; i++) {
		fak[i] = fak[i - 1] * i;
		fak[i] %= MOD;
	}
	LL ans = 0;
	int x = N;
	for (int i = 0; i <= K; i++) {
		ans += (((M * pangkat((M - 1), N - 1)) % MOD) * C(x - 1, i)) % MOD;
		ans %= MOD;
		N--;
		//printf("%lld\n", ans);
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 5320
#include<iostream>
using namespace std;
int main(){
  bool num[1000000]={true,true};
  for(int i=2; i<1000; i++)
    if(!num[i])
      for(int j=i*i; j<1000000; j+=i)
	num[j] = true;
  int n;
  while(cin >>n,n){
    int ans = 0;
    for(int i=2; i<=n/2; i++) if(!num[i] && !num[n-i]) ans++;
    cout <<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 2144
h, w, k = gets.split.map(&:to_i)
rows = Array.new(h){gets.chomp.bytes.map{|c| (c == '#'.ord) ? 1 : 0}}
cnt = 0
[0, 1].repeated_permutation(h) do |x|
  m = []
  x.each_with_index do |y, i|
    if y.zero?
      m << rows[i]
    else
      m << [0] * w
    end
  end
  [0, 1].repeated_permutation(w) do |u|
    mc = []
    u.each_with_index do |v, l|
      mc << m.transpose[l] if v.zero?
    end
    cnt += 1 if mc.flatten.sum == k
  end
end
puts cnt

Measured memory_bytes: 14428
N,K=map(int,input().split())
*h,=map(int,input().split())

dp = [0]*N

for i in range(1,N):
  if i <= K:
    dp[i] = min([dp[i-j]+abs(h[i]-h[i-j]) for j in range(1,i+1)])
  else:
    dp[i] = min([dp[i-j]+abs(h[i]-h[i-j]) for j in range(1,K+1)])
    
print(dp[-1])

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

const int N=1e5+10;

int head[N],to[N],nxt[N],cnt;
int c[N],st=0,val[N];

inline void addedge(int x, int y){
	to[++cnt]=y,nxt[cnt]=head[x],head[x]=cnt;
	to[++cnt]=x,nxt[cnt]=head[y],head[y]=cnt;
}

inline void dfs(int x, int fa){
	for (int i=head[x];i;i=nxt[i])
		if (to[i]!=fa) dfs(to[i],x);
	val[x]=c[++st];
}

int main(){
	int n; scanf("%d",&n);
	for (int i=1;i<n;i++){
		int x,y; scanf("%d%d",&x,&y);
		addedge(x,y);
	}
	for (int i=1;i<=n;i++)
		scanf("%d",&c[i]);
	sort(c+1,c+n+1);
	dfs(1,0);
	int ans=0;
	for (int i=1;i<n;i++)
		ans+=c[i];
	printf("%d\n",ans);
	for (int i=1;i<=n;i++)
		printf("%d ",val[i]);
	return 0;
}


Measured memory_bytes: 768
#include <iostream>
using namespace std;
int main() {
    string s;
    cin >> s;
    //前にブロックがないときはprev='2'とする
    char prev = '2', now;
    int cnt = 0;
    for (int i=0; i<s.size(); i++) {
        now = s[i];
        if (now == prev || prev == '2') {
            cnt++;
            prev = now;
        } else {
            cnt--;
            if (cnt == 0) {
                prev = '2';
            }
        }
    }
    cout << s.size() - cnt << endl;
}

Measured memory_bytes: 3716
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt();
    vector <ll> v(n);
    generate(all(v),nxtl);
    ll test=0;
    bool pos=0;
    ll sum=v[0];
    if(v[0]<=0){
        test+=abs(v[0])+1;
        sum=1;
    }
    
    for(int i=1;i<n;i++)
    {
        ll temp=sum+v[i];
        if(pos&&temp<=0)
        {
            test+=abs(temp)+1;
            sum=1;
        }
        else if(pos==0&&temp>=0)
        {
            test+=temp+1;
            sum=-1;
        }
        else
        {
            sum=temp;
        }
        if(pos)
            pos=0;
        else
            pos=1;
    }

    ll test2=0;
    pos=1;
    sum=v[0];
    if(v[0]>=0){
        test2+=abs(v[0])+1;
        sum=-1;
    }
    for(int i=1;i<n;i++)
    {
        ll temp=sum+v[i];
        if(pos&&temp<=0)
        {
            test2+=abs(temp)+1;
            sum=1;
        }
        else if(pos==0&&temp>=0)
        {
            test2+=temp+1;
            sum=-1;
        }
        else
        {
            sum=temp;
        }
        if(pos)
            pos=0;
        else
            pos=1;
    }

    cout<<min(test,test2)<<endl;



    
    
    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 X = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();
    
    if (B-A <= 0) {
      System.out.println("delicious");
    } else if (B-A <= X) {
      System.out.println("safe");
    } else {
      System.out.println("dangerous");
    }
  }
}

Measured memory_bytes: 21716
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
)

type Item struct {
	value    int // The value of the item; arbitrary.
	priority int // The priority of the item in the queue.
	// The index is needed by update and is maintained by the heap.Interface methods.
	index int // The index of the item in the heap.
}
type PriorityQueue []*Item

func (pq PriorityQueue) Len() int { return len(pq) }
func (pq PriorityQueue) Less(i, j int) bool {
	return pq[i].priority < pq[j].priority
}
func (pq PriorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}
func (pq *PriorityQueue) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Item)
	item.index = n
	*pq = append(*pq, item)
}
func (pq *PriorityQueue) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

type Q struct {
	pq *PriorityQueue
	ds map[int]int // It has always same value as pq. For random access.
}

func newQ() *Q {
	pq := new(PriorityQueue)
	heap.Init(pq)
	return &Q{
		pq: pq,
		ds: make(map[int]int),
	}
}
func (q *Q) pop() (u, d int) {
	item := heap.Pop(q.pq).(*Item)
	delete(q.ds, item.value)
	return item.value, item.priority
}
func (q *Q) get(u int) (int, bool) { // returns d
	d, ok := q.ds[u]
	return d, ok
}
func (q *Q) set(u, d int) {
	q.ds[u] = d
	for _, item := range *q.pq {
		if item.value != u {
			continue
		}

		item.priority = d
		heap.Fix(q.pq, item.index)
		return
	}
	heap.Push(q.pq, &Item{
		priority: d,
		value:    u,
	})
}
func (q *Q) len() int {
	return len(q.ds)
}

func main() {
	r := bufio.NewReader(os.Stdin)

	var n int
	fmt.Fscan(r, &n)
	cs := make([]map[int]int, n) // []v_i -> c_i
	for h := 0; h < n; h++ {
		var u, k int
		fmt.Fscan(r, &u, &k)
		m := make(map[int]int)
		for i := 0; i < k; i++ {
			var v, c int
			fmt.Fscan(r, &v, &c)
			m[v] = c
		}

		cs[u] = m
	}

	q := newQ()
	q.set(0, 0)
	visited := make(map[int]struct{})
	out := make([]int, n)

	for q.len() > 0 {
		u, d := q.pop()
		for uu, c := range cs[u] {
			// Consider the connection between u and uu.
			if _, ok := visited[uu]; ok {
				continue
			}
			dd := d + c
			if d, ok := q.get(uu); !ok || d > dd {
				q.set(uu, dd)
			}
		}

		out[u] = d
		visited[u] = struct{}{}
	}

	for u, d := range out {
		fmt.Println(u, d)
	}
}



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

const int N = 2e6;
int a[N+1],b[N+1],c[N+1];

signed main(){

  int n; cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    c[a[i]]++;
  }

  for(int i = 0; i < N; i++) c[i+1] += c[i];
  for(int i = 0; i < n; i++){
    b[c[a[i]]] = a[i];
    c[a[i]]--;
  }

  for(int i = 1; i <= n; i++){
    if(i == n) cout << b[i] << endl;
    else cout << b[i] << " ";
  }

  return 0;
}



Measured memory_bytes: 49928
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <deque>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
int tr[2005];
int main ()
{
    int n;
    int ans=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&tr[i]);
    }
    sort(tr+1,tr+n+1);
    for(int i=1;i<=n-2;i++)
        for(int j=i+1;j<=n-1;j++)
    {
        int sum=tr[i]+tr[j];
        int l=j+1;
        int r=n;
        if(tr[l]>=sum)
            continue;
        while(l<r)
        {
            int mid=(l+r+1)/2;
            if(tr[mid]<sum)
                l=mid;
            else
                r=mid-1;
        }
        if(l>j)
            ans+=l-j;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 3844
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		
		Scanner sc=new Scanner(System.in);
		
		int  W=sc.nextInt();
		int  H=sc.nextInt();
	    int  x=sc.nextInt();
		int  y=sc.nextInt();
		int  r=sc.nextInt();
		
		if((r<=x&&x<=W-r)&&(r<=y&&y<=H-r)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		
	}
}



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

int gcd( int x, int y ){
	if( y==0 )	return x;
	return gcd(y,x%y);
}

int main(){
	int x, y;
	cin >> x >> y;
	cout << gcd((x>y?x:y),(x>y?y:x)) << endl;
	return 0;
}

Measured memory_bytes: 1160
flag=True
S=input()
for i in range(len(S)//2):
  if S[i]!=S[len(S)-1-i]:
    flag=False
if flag:
  for i in range(((len(S)-1)//2)//2):
    if S[i]!=S[(len(S)-1)//2-i-1]:
      flag=False
if flag:
  if S[:(len(S)-1)//2]!=S[(len(S)+3)//2-1:]:
    flag=False
if flag:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>


using namespace std;


int main()
{
	string s;
	long long n;
	cin>>s>>n;
	string s1,s2;
	s1=s+s;
	s2=s1+s;
	int sum=1,summ=1;
	long long ans1=0,ans2=0,ans3=0,ans=0;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]==s[i+1])
		{
			summ++;
		}
		else
		{
			ans1+=summ/2;
			summ=1;
			
		}
	}
	for(int i=0;i<s1.size();i++)
	{
		if(s1[i]==s1[i+1])
		{
			sum++;
		}
		else
		{
			ans2+=sum/2;
			sum=1;
			
		}
	}
	int num=1;
	for(int i=0;i<s2.size();i++)
	{
		if(s2[i]==s2[i+1])num++;
		else
		{
			ans3+=num/2;
			num=1;
		}
	}
	if(s[0]!=s[s.size()-1])ans=ans1*n;
	else{
		if(n%2==0)
		{
			ans=ans1+(n/2)*(ans2-ans1)+(n/2-1)*(ans3-ans2);
		}
		else
		{
			ans=ans1+(n/2)*(ans2-ans1)+(n/2)*(ans3-ans2);
		}
	}
	printf("%lld",ans);
}

Measured memory_bytes: 3656
#include <cstdio>
#include <iostream>
using namespace std;
typedef long long ll;
ll m, a, r, c, h;
ll num[5];

int main()
{
   int n;
   scanf("%d", &n);
   string s;

   for (int i=0; i<n; i++) {
      cin >> s;
      if (s[0] == 'M') m++;
      if (s[0] == 'A') a++;
      if (s[0] == 'R') r++;
      if (s[0] == 'C') c++;
      if (s[0] == 'H') h++;
   }

   num[0] = m;
   num[1] = a;
   num[2] = r;
   num[3] = c;
   num[4] = h;

   ll res = 0;
   int x[10] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2};
   int y[10] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3};
   int z[10] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4};
   for (int i=0; i<10; i++) {
      res += num[x[i]] * num[y[i]] * num[z[i]];
   }
   printf("%lld\n", res);

   return 0;

}



Measured memory_bytes: 256
fn main(){
    let mut n =  String::new();
    let mut a =  String::new();
    std::io::stdin().read_line(&mut n).expect("Failed read line");
    std::io::stdin().read_line(&mut a).expect("Failed read line");

    let n: u32 = match n.trim().parse() {
        Ok(num) => num,
        Err(_) => 1,
    };

    let a: u32 = match a.trim().parse() {
        Ok(num) => num,
        Err(_) => 1,
    };

    if n % 500 <= a {
        println!("Yes");
    } else {
        println!("No");
    }

}

Measured memory_bytes: 4352
# !/usr/bin/python3

"""
https://atcoder.jp/contests/abc152/tasks/abc152_c
Low Elements.
"""
def solve(a, n):
    ans = 1
    mi = a[0]

    for i in range(1, n):
        mi = min(mi, a[i])
        if mi == a[i]: ans += 1

    return ans

if __name__ == "__main__":
    n = int(input())
    a = [(lambda x: int(x))(x) for x in input().split()]

    print(solve(a, n))


Measured memory_bytes: 32300
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
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()
{
    int h, w; cin >> h >> w;
    unordered_map<char, int> a;
    rep(i, h*w){
        char c; cin >> c;
        a[c]++;
    }

    vint v;
    for(auto p: a) v.push_back(p.second);
    sort(v.rbegin(), v.rend());
    // prvec(v);

    if(h==1 && w==1) {pr("Yes"); return 0;}
    if(h==1 || w==1){
        if(w==1) swap(h, w);
        int odd=0, even=0;
        rep(i, v.size()){
            if(v[i]%2==1)  even++;
            else odd++;
        }

        if(w%2==0){
            if(even==0) pr("Yes");
            else pr("No");
            return 0;
        }else{
            if(even==1) pr("Yes");
            else pr("No");
            return 0;
        }
    }

    int odd=0, even=0, four=0;
    rep(i, v.size()){
        four += v[i]/4;
        v[i] %= 4;
        even += v[i]/2;
        v[i] %= 2;
        if(v[i]==1) odd++;
    }

    // cout << four << " " << even << " " << odd << endl;

    // 両方とも2の倍数のとき
    if(h%2==0 && w%2==0){
        if(odd==0 && even==0) pr("Yes");
        else pr("No");
        return 0;
    }

    if(h%2==1 && w%2==1){
        int fp = (h/2) * (w/2);
        four -= fp;
        if(four<0 || odd!=1) pr("No");
        else pr("Yes");
        return 0;
    }

    int fp = (h/2) * (w/2);
    four -= fp;
    // cout << four << " " << even << endl;
    if(four<0 || odd>0) pr("No");
    else pr("Yes");

    return 0;}

Measured memory_bytes: 3624
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;
const long p = 1_000_000_000 + 7;

void main(){
    auto N = readInt();
    auto T = readLongs();
    auto A = readLongs();
    T = 0 ~ T ~ T.back;
    A = A[0] ~ A ~ 0;
    long ans = 1;
    foreach(i; iota(1,N+1)) {
        long hMinT = 1;
        long hMaxT = T[i];
        if(T[i-1] < T[i]) {
            hMinT = T[i];
        }
        long hMinA = 1;
        long hMaxA = A[i];
        if(A[i] > A[i+1]) {
            hMinA = A[i];
        }
        ans *= max(0, (min(hMaxT, hMaxA) - max(hMinT, hMinA) + 1));
        ans %= p;
    }
    writeln(ans);
}



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

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

    int n,k;
    double res = 0;

    cin >> n >> k;

    double prob = (1.0/n);
    double prob2 = 0.5;

    for(int i=1;i<=n;i++)
    {
        if(i>=k)
        {
            res += (prob);
        }
        else
        {
            int val = i;
            double p = prob;
            while(val<k)
            {
                val*=2;
                p*=prob2;
            }
            res += p;
        }
    }

    cout << fixed;
    cout.precision(15);

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 508
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INF 1e9
#define MAX_N 10001
#define MAX_H 101
#define MAX_W 101

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

int main() {
    int H, W, N, a[MAX_N];
    int grid[MAX_H][MAX_W];
    cin >> H >> W >> N;
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
    }
    
    int cur_c = 0;
    for (int i = 0; i < H; ++i) {
        if (i % 2 == 0) {
            for (int j = 0; j < W; ++j) {
                if (a[cur_c]-- == 0) {
                    cur_c++;
                    a[cur_c]--;
                }
                grid[i][j] = cur_c;
            }
        } else {
            for (int j = W - 1; j >= 0; --j) {
                if (a[cur_c]-- == 0) {
                    cur_c++;
                    a[cur_c]--;
                }
                grid[i][j] = cur_c;
            }
        }
    }
    
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            printf("%d ", grid[i][j] + 1);
        }
        printf("\n");
    }
    
    return 0;
}


Measured memory_bytes: 384
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

int N;
vector<int> e[200000];

signed main(){
    cin >> N;
    rep(i, N-1){
        int u, v;
        cin >> u >> v;
        u--; v--;
        if(u > v) swap(u, v);
        e[u].pb(v);
    }

    ll ans = 0;
    ll tmp = 0;
    for(int L=N-1; L>=0; L--){
        tmp += N-L;
        rep(j, e[L].size()){
            tmp -= N-e[L][j];
        }
        ans += tmp;
    }
    cout << ans << endl;
}

Measured memory_bytes: 14544
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
using namespace std;

#define ll int64_t
const long MOD = 1e9 + 7;

vector<vector<int>> v;
vector<bool> d;
int ans = 0;



int main()
{
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;

  //sx,sy にたいしてtx,tyは必ず右下:   原点左上のとき

  cerr << sx << "," << sy <<"   " << tx <<","  << ty <<endl;

  int dx = tx-sx;
  int dy = ty-sy;
  string ans = "";
  //一回目行き
  // ans += "R";
  for (int i = 0; i < dy  ; ++i){
    ans += "U";
  }
  for (int i = 0; i < dx ; ++i){
    ans += "R";
  }
  // ans += "D";
  //一回目帰り
  for (int i = 0; i < dy ; ++i){
    ans += "D";
  }

  for (int i = 0; i < dx ; ++i){
    ans += "L";
  }



  // ans +="|||";

  //二回目行き　下から
  ans += "L";

  for (int i = 0; i < dy + 1 ; ++i){
    ans += "U";
  }

  for (int i = 0; i < dx + 1; ++i){
    ans += "R";
  }

  ans += "D";

  //二回目帰り
  ans += "R";
  for (int i = 0; i < dy + 1; ++i){
    ans += "D";
  }

  for (int i = 0; i < dx + 1; ++i){
    ans += "L";
  }
  ans += "U";


  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include<iostream>
#include<stdio.h>
#include <algorithm>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#include<iomanip>
#include<queue>
#include<functional>
#include<cmath>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
using namespace std;
using ll = long long;
using P = pair<int, int>;
using graph = vector<vector<int>>;

int main() {
	int N, M; long long int  ans = 0; cin >> N >> M;
	priority_queue<ll,vector<ll>, less<ll>>q;
	rep(i, N) {
		long long int a; cin >> a;
		q.push(a);
	}
	rep(i, M) {
		long long int a = q.top(); q.pop();
		q.push(a / 2);

	}
	rep(i, N) {
		int a = q.top();
		ans += a; q.pop();
	}
	
	cout << ans << endl;
}


Measured memory_bytes: 1400
#!usr/bin/env python3

import sys
from math import pi


def area_of_circle(radius):
    return pi * radius**2


def circumference_of_circle(radius):
    return 2*pi*radius


def main():
    r = float(sys.stdin.readline())
    print('%f %f' % (area_of_circle(r), circumference_of_circle(r)))


if __name__ == '__main__':
    main()

Measured memory_bytes: 7604