akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

// fold {
#define debug(var)  do{ std::cout << #var << " : "; view(var); }while(0)
using ll = long long;
using ld = long double;
inline int num (const std::string& S, int idx) noexcept { return S.at(idx) - '0'; }
inline int ctoi(char c) noexcept { return c - '0'; }
inline bool isNumber(char c) noexcept { return ('0'<c && c<'9'? true : false); }
inline int safeCtoi(char c) { if(isNumber(c)) { return ctoi(c); } else { throw 1; } }
inline char itoc(int i) noexcept { return i + '0'; }
inline unsigned int bitMask(int i) noexcept { return (1 << i); }
inline bool isTrue(unsigned int bit, int i) noexcept { return bit & bitMask(i); }
inline bool isEven(int num) noexcept { return !num%2; }
inline bool isOdd(int num) noexcept { return num%2; }
template<typename T> inline short sgn(T num) noexcept { return (num==0? 0 : (num>0? 1 : -1) ); }
template<typename T> inline bool isZero(T num) noexcept { return (num==0? true : false); }
template<typename T> inline bool isPositive(T num) noexcept { return (num>0? true : false); }
template<typename T> inline bool isNegative(T num) noexcept { return (num<0? true : false); }
template<typename T> void view(T e) noexcept { cout << e; }
template<typename T> void view(std::vector<T> v) noexcept { for(const auto& e : v) cout << e << " "; }
template<typename T> void view(std::vector<std::vector<T>> vv) noexcept { for(const auto& v : vv) view(v); }
// }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h1, m1, h2, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	int t1 = h1 * 60 + m1;
	int t2 = h2 * 60 + m2;
	int diff_t = t2 - t1;
	if( diff_t < k ){
		cout << 0 << endl;
	}else{
		cout << diff_t - k << endl;
	}
	return 0;
}

Measured memory_bytes: 3652
from sys import stdin
n,k = [int(x) for x in stdin.readline().rstrip().split()]
answer = 0
while k <= n+1:
    min = k*(k-1)//2
    max = n*(n+1)//2
    t = n+1-k
    max -= t*(t-1)//2
    answer += max-min+1
    answer %= 1000000007
    k += 1
print(answer)

Measured memory_bytes: 63844
H,N=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(N)]
x=max(a for a,b in ab)
dp=[0]*(H+x)
for i in range (1,H+x):
    dp[i]=min(dp[i-a]+b for a,b in ab)
print(min(dp[H:]))

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
int n;
int main () {
	scanf("%d",&n);
	for (int i=1;i<=9;i++) {
		for (int j=1;j<=9;j++) {
			if (i*j==n) {
				printf("Yes\n");
				return 0;
			}
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;

static const ll INF = 1001001001;
static const ll LLINF = 1001001001001001001;

#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define RANGE(i, m, n) for(ll i = (m); i <= (n); ++i)

void debug_out() {}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 1
#endif

void dfs(ll num_colors, vector<vector<ll>>& original, vector<ll>& colors, vector<vector<ll>>& g, ll cur, ll next) {
    ll input_color = 0;
    REP(i, g[next].size()) {
        if (g[next][i] == cur) {
            input_color = colors[original[next][i]];
            break;
        }
    }
    ll cnt = input_color;
    REP(i, g[next].size()) {
        if (g[next][i] == cur) {
            continue;
        }
        if (colors[original[next][i]] == -1) {
            colors[original[next][i]] = 1 + cnt % num_colors ;
        }
        dfs(num_colors, original, colors, g, next, g[next][i]);
        cnt++;
    }

}
int run(istream& in, ostream& out) {
    ll N;
    in >> N;
    vector<ll> a(N-1), b(N-1);
    vector<vector<ll>> g(N);
    vector<vector<ll>> original(N);
    REP(i, N-1) {
        in >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        g[a[i]].emplace_back(b[i]);
        g[b[i]].emplace_back(a[i]);
        original[a[i]].emplace_back(i);
        original[b[i]].emplace_back(i);
    }
    ll num_colors = 0;
    for(auto x : g) {
        num_colors = max(num_colors, (ll)x.size());
    }
    vector<ll> colors{};
    colors.resize(N-1, -1);
    dfs(num_colors, original, colors, g, -1, 0);

    out << num_colors << endl;
    for(auto x : colors) {
        out << x << endl;
    }
    return 0;
}

int main() {
    return run(cin, cout);
}


Measured memory_bytes: 14976
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cstdlib>
#include<cstring>
#include<cassert>
#include<sstream>
#include<numeric>
#include<iostream>
#include<algorithm>
#include<functional>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> Vi;
typedef pair<int,int> pii;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=3000+19;

struct Edge{
	int y,nxt;
} E[N*2];
int las[N],f[N],A[N];
int n,cnt;

void Link(int x,int y){
	E[cnt]=(Edge){y,las[x]};las[x]=cnt++;
	E[cnt]=(Edge){x,las[y]};las[y]=cnt++;
}
void dfs(int x,int fa){
	f[x]=0;
	for (int i=las[x],y;~i;i=E[i].nxt)
		if ((y=E[i].y)!=fa){
			dfs(y,x);
			if (A[y]<A[x]&&!f[y]) f[x]=1;
		}
}

int main(){
	memset(las,-1,sizeof(las));
	n=IN();
	For(i,1,n+1) A[i]=IN();
	For(i,1,n) Link(IN(),IN());
	For(i,1,n+1){
		dfs(i,-1);
		if (f[i]) printf("%d ",i);
	}
	puts("");
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int a[100001] = {0};
int visited[100001] = {0};

int canFinishTraining(int x, int ret) {
    if (x == 2) {
        return ret;
    }
    ret++;

    if (visited[x] == 1) {
        ret = -1;
        return ret;
    } else {
        visited[x] = 1;
        // cout << "ret: " << endl;
        // cout << "a: " << a[x] << endl;
        return canFinishTraining(a[x], ret);
    }
}

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

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

    // 判定
    cout << canFinishTraining(1, 0) << endl;

    return 0;
}

Measured memory_bytes: 1024
import itertools
N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

x = [tuple(x) for x in itertools.permutations(range(1, N + 1), N)]
x.sort()
a = x.index(P)
b = x.index(Q)
ans = abs(a - b)
print(ans)

Measured memory_bytes: 13912
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
#define MOD 1000000007

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

int main(){
    ll n;
    cin >> n;
    ll ans=(fast_pow(10,n,MOD)-fast_pow(9,n,MOD)+MOD)%MOD;
    ans-=fast_pow(9,n,MOD);
    ans+=MOD;
    ans%=MOD;
    ans+=fast_pow(8,n,MOD);
    ans%=MOD;
    cout << ans << endl;
}

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

int main() {
	string s, t;
	cin >> s;
	cin >> t;
	ll ans = 0;
	for (int i = 0; i < 3; i++)if (s.at(i) == t.at(i))ans++;
	cout << ans << endl;
}

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

int main(){
	long long W;
	long long N;
	scanf("%lld",&N);
	long long w[N-1+1];
	long long v[N-1+1];
	scanf("%lld",&W);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&w[i]);
		scanf("%lld",&v[i]);
	}
  long long dp[N+1][W+1];
	for(int i = 0 ; i <= N ; i++){
		for(int j = 0 ; j <= W ; j++){
			if (i == 0) {
				dp[i][j] = 0;
			} else {
				if (j-w[i-1] < 0) {
					dp[i][j] = dp[i-1][j];
				} else {
					dp[i][j] = max(dp[i-1][j-w[i-1]]+v[i-1],dp[i-1][j]);
				}
			}
		}
	}
	printf("%lld\n", dp[N][W]);
	return 0;
}


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

vector<int> a={3,5,7};

int encode(int i,int j) {
    int res=0;
    int c=0;
    vector<int> t={0,0,0};
    for (int k=0;k<j;k++) {
        int b=i%3;
        res+=a[b]*pow(10,c);
        t[b]=1;
        i/=3;
        c++;
    }
    if (t[0]>0 && t[1]>0 && t[2]>0) return res;
    else return 0;
}


int main() { 
    int n;
    cin >> n;
    int ans=0;
    int enc=0;
    for (int j=3;j<10;j++) {
        for (int i=0;i<27000;i++) {
            int r=encode(i,j);
            if (r>n) break;
            if (r>0) ans++;
            if (i>pow(3,j)) break;
        }
    }
    cout << ans << endl;
}

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

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<long long,long long> pll;

#define endl '\n'
#define ff first
#define ss second
#define pb push_back
#define int long long
#define sz(v) (int)v.size()
#define inf 2147483647
#define llinf 9223372036854775807
#define all(v) v.begin(),v.end()
#define bp(n) __builtin_popcountll(n)
#define f(i,l,r) for(long long i=l;i<=r;i++)
#define rf(i,r,l) for(long long i=r;i>=l;i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }


const int N=3e3+5,mod=1e9+7,bit=61;

int n;
ld dp[N][N];
ld p[N];

ld solve(int x,int heads)
{
    if( (heads<<1) >=(n+1))
    {
        return 1.0;
    }
    if(x==n+1)
    {
        return 0.0;
    }
    ld &ans=dp[x][heads];
    if(ans!=-1.0)
    {
        return ans;
    }
    ans = p[x]*solve(x+1,heads+1)+(1.0-p[x])*solve(x+1,heads);
    return ans;
}

signed main()
{
    fast;

    int t=1;
    //cin>>t;
    while(t--)
    {
        cin>>n;
        for(int i=1;i<=n;i++)
        {
            cin>>p[i];
        }
        for(int i=0;i<=n;i++)for(int j=0;j<=n;j++)dp[i][j]=-1.00;
        cout<<fixed<<setprecision(10)<<solve(1,0)<<endl;
    }
    return 0;
}


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    vector<int> c(26,0);
    REP(i,s.size()){
        c[s[i]-'a']++;
    }
    bool flg=true;
    REP(i,26){
        if(c[i]%2)flg=false;
    }
    if(flg)YES;
    else NO;
}


Measured memory_bytes: 256
s = input()
n = len(s)

a = s[:(n-1)//2]
b = s[((n+3)//2)-1:]
s_r = "".join(list(reversed(s)))
a_r = "".join(list(reversed(a)))
b_r = "".join(list(reversed(b)))

if s==s_r and a==a_r and b==b_r:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <stdlib.h>

int main(int argc, char const* argv[]){
    using namespace std;
    long n;
    cin >> n;
    vector<long> x(n), y(n), t(n);
    for(long i=0; i<n; i++){
        cin >> t[i] >> x[i] >> y[i];
    }
    long nx=0, ny=0, nt=0;
    for(long i=0; i<n; i++){
        if(abs(x[i]-nx)+abs(y[i]-ny)>t[i]-nt || (abs(x[i]-nx)+abs(y[i]-ny)-(t[i]-nt))%2!=0){
            cout << "No";
            return 0;
        }
        nx = x[i];
        ny = y[i];
        nt = t[i];
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);

int main(){
  while(1){
  ll n; cin>>n;
    if(n==0) break;
    ll ans=0;
    vector<string>v(n);
    rep(i,n) cin>>v[i];
    bool fl=true,ri=true,le=true;
    for(ll i=0;i<n;i++){
    if(v[i]=="lu") le=false;
      if(v[i]=="ru") ri=false;
      if(v[i]=="ld") le=true;
      if(v[i]=="rd") ri=true;
    
      if(fl){
    if(!ri&&!le){
      ans++; fl=false;
    }
    }
    
      else{
      if(ri&&le){
      ans++; fl=true;
      }
      }
      
    }
        
    cout<<ans<<endl;
  }
  
}


Measured memory_bytes: 3056
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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

void add(ll& a, ll b){a = (a+b) % MOD;}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int num[10];
    REP(i,3){
        int n;
        cin>>n;
        num[n]++;
    }
    (num[5]==2&&num[7]==1)?cout<<"YES":cout<<"NO";
    cout<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define rep(i,l,n) for(int (i)=(l);(i)<(n);(i)++)
#define min(a,b) (a)<(b)?(a):(b)
#define max(a,b) (a)>(b)?(a):(b)
#define abs(a) (a)>0?(a):-(a)
#define llong long long

int main(){
	int R; scanf("%d",&R);
	printf("%f",2*R*M_PI);
	return 0;
}


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

using namespace std;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<vector<pair<int, int> > > edges(N+1);
    for (int i = 1; i < N; ++i) {
        edges[i+1].push_back({i, 0});
    }
    for (int i = 0; i < M; ++i) {
        int l, r, c;
        cin >> l >> r >> c;
        edges[l].push_back({r, c});
    }
    vector<long long> shortest(N+1, INT64_MAX);
    priority_queue<pair<long long, int>, vector<pair<long long, int> >, greater< > > pq;
    shortest[1] = 0;
    pq.push({0, 1});
    while (!pq.empty()) {
        auto p = pq.top();
        pq.pop();
        int v = p.second;
        if (shortest[v] < p.first) continue;
        for (int i = 0; i < (int)edges[v].size(); ++i) {
            auto e = edges[v][i];
            if (shortest[e.first] > shortest[v] + e.second) {
                shortest[e.first] = shortest[v] + e.second;
                pq.push({shortest[e.first], e.first});
            }
        }
    }
    printf("%lld\n", shortest[N] == INT64_MAX ? -1 : shortest[N]);
    return 0;
}

Measured memory_bytes: 8568
X, Y = [int(i) for i in input().split()]

score = 0
if X == 3:
    score += 100000
elif X == 2:
    score += 200000
elif X == 1:
    score += 300000

if Y == 3:
    score += 100000
elif Y == 2:
    score += 200000
elif Y == 1:
    score += 300000

if X == 1 and Y == 1:
    score += 400000 

print(score)

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

vector<int> a(20);
int n;

bool searchComb(vector<int> a, int x){
    int size = a.size();
    ll bit_max = 1 << a.size();

    for(int i = 0; i < bit_max; i++){
        int sum = 0;
        for(int j = 0; j < size; j++){
            if((i>>j)%2 == 0){
                sum += a.at(j);
            }
        }
        if(sum == x){
            return true;
        }
    }
    return false;
}

int solve(int i, int m){
    if(m == 0){
        return 1;
    }
    if(i >= n){
        return 0;
    }
    int res = solve(i + 1, m) || solve(i + 1, m - a.at(i));
    return res;
}

int main(){
    // Aの読み込み
    cin >> n;
    rep(i, n){
        scanf("%d", &a.at(i));
    }

    // mの読み込み
    int q; cin >> q;
    vector<int> m(q);
    rep(i, q){
        scanf("%d", &m.at(i));
    }

    for(int i = 0; i < q; i++){
        if(solve(0, m.at(i))){
            cout << "yes" << endl;
        }else{
            cout << "no" << endl;
        }
    }
}


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

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

    int arr[n],p[n];
    
    for(int i=0;i<n;i++)
        cin>>arr[i];
    
    p[0]=0;
    p[1]=abs(arr[1]-arr[0]);

    for(int i=2;i<n;i++)
    {
            p[i]=INT_MAX;
        for(int j=i-1;(j>i-(k+1) && j>=0);j--)
        {
            

        int min_ele=abs(arr[i]-arr[j])+p[j];
        //cout<<min_ele<<" ";
        if(min_ele<p[i])
            p[i]=min_ele;

            
        }
        //cout<<endl;
    }

    cout<<p[n-1];
    

    
    return 0;
}





Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a, b;
    cin >> a >> b;
    int d , r;
    double f;
    d = a/b;
    r = a % b;
    f = 1.0*a/b;
    cout << d << " " << r << " " << fixed << setprecision(7) << f << endl;
    return 0;
}


Measured memory_bytes: 3284
#include <bits/stdc++.h>
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
  int n; scanf("%d", &n); std::vector<int> a(n);
  for(auto& v: a) scanf("%d", &v);

  std::vector<int> deg(1e6 + 1);
  for(auto v: a) deg[v]++;

  for(int i = (int)deg.size() - 1; i > 0; i--) {
    for(int j = 2 * i; j < deg.size(); j += i) deg[j] += deg[i];
  }

  int ans = 0;
  for(auto v: a) {
    if(deg[v] > 1) continue;

    ans++;
  }

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


Measured memory_bytes: 8036
#include <bits/stdc++.h>
using namespace std;
#define testing 1
#define FOR(i,s,e) for(ll i = s; i <= (ll)e; ++i)
#define DEC(i,s,e) for(ll i = s; i >= (ll)e; --i)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << "\n"
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << "\n"
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<"\n"
#define dbv(v) cerr << #v << ":"; for (auto ite : v) cerr << ite << ' '; cerr <<"\n"
#define dbvp(v) cerr << #v << ":"; for (auto ite : v) cerr << "{"  << ite.f << ',' << ite.s << "} "; cerr << "\n"
#define dba(a,ss,ee) cerr << #a << ":"; FOR(ite,ss,ee) cerr << a[ite] << ' '; cerr << "\n"
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "LINE: " << __LINE__ << "\n";
typedef pair <int, int> pi;
typedef tuple<int,int,int> ti3;
string cts(char x) {string t(1,x); return t;}
ll rand(ll a, ll b) { return a + rng() % (b-a+1); }
const int MOD = 1e9 + 7;
const int inf = (int)1e9 + 500;
const long long oo = (ll)1e18 + 500;
template <typename T> void chmax(T& a, T b) { a = max(a, b); }
template <typename T> void chmin(T& a, T b) { a = min(a, b); }
const int MAXN = -1;
#if !testing
#define cerr if(0)cout
#endif

int32_t main() 
{
	IAMSPEED
	int n; cin >> n;
	vector<double> v;
	int cnt = 0;
	int m; cin >> m;
	int sum = 0;
	FOR(i,1,n) {
		int x; cin >> x;
		double tmp = (double)x;
		v.pb(tmp);
		sum += x;
	}
	for(double x:v) {
		if(x>=(double)sum/(4.0*(double)m))++cnt;
	}
	if(cnt>=m)cout<<"Yes\n";
	else cout << "No\n";
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int K;
    cin >> K;
    int even;
    int add;
    if ( K % 2 == 0) {
        even = K / 2;
        add = even;
    } else {
        add = K / 2;
        even = add + 1;
    }
    cout << even * add << endl;
}


Measured memory_bytes: 256
use std::io;
use std::str::FromStr;  

fn main() {
    let ns: Vec<i32> = reads();
    let k = ns[1];
    let hs: Vec<i32> = reads();

    let ok = hs.iter().filter(|&x| *x >= k);
    println!("{}", ok.count());
}

#[allow(dead_code)]
fn getline() -> String {
    let mut ln = String::new();
    io::stdin().read_line(&mut ln).ok();
    ln.trim().to_string()
}

#[allow(dead_code)]
fn read<T>() -> T where T : FromStr {
    let mut ln = String::new();
    io::stdin().read_line(&mut ln).ok();
    ln.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn reads<T>() -> Vec<T> where T : FromStr {
    let mut ln = String::new();
    io::stdin().read_line(&mut ln).ok();
    ln.trim().split_whitespace().map(|x| x.parse().ok().unwrap()).collect()
}


Measured memory_bytes: 4352
import math
# import bisect
# import heapq
# from copy import deepcopy
# from collections import deque
# from collections import Counter
# from itertools import accumulate
# from itertools import permutations
# import numpy as np

n,k = map(int, input().split())
r,s,p = map(int, input().split())
t = input()
# p = list(map(int, input().split()))
score = 0
rev = [True] * k
for i in range(min(k,n)):
    if t[i] == 'r':
        score += p

    elif t[i] == 'p':
        score += s

    elif t[i] == 's':
        score += r

if n>k:

    for i in range(k,n):

        if t[i] == t[i-k] and rev[i%k] :
            rev[i % k] = False

        elif t[i] == t[i-k] and not rev[i%k] :
            if t[i]=='r': score += p
            elif t[i] == 'p': score += s
            elif t[i] == 's': score += r

            rev[i % k] = True

        elif t[i] != t[i-k]:
            if t[i]=='r': score += p
            elif t[i] == 'p': score += s
            elif t[i] == 's': score += r

            rev[i % k] = True

print(score)

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

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int n; cin >> n;
  string s; cin >> s;
  int w = count(s.begin(), s.end(), '.'), b = n - w;
  int ans = 1e9;
  for (int i = 0, B = 0, W = w; i <= n; ++i) {
    ans = min(B + W, ans);
    if (i < n) W -= s[i] == '.', B += s[i] == '#';
  }
  cout << ans << '\n';
}


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

int main(){

	string str;
	cin >> str;

	int q;
	cin >> q;

	string comand, p;
	int a, b;

	for(int i = 0; i < q; i++){
		cin >> comand;
		if(comand == "print"){
			cin >> a >> b;
			cout << str.substr(a, b - a + 1) << endl;
		}else if(comand == "reverse"){
			cin >> a >> b;
			string temp(str.substr(a, b - a + 1));
//			cout << temp << endl;
			for(int j = 0; j < b - a + 1; j++){
				str[a + j] = temp[b - a - j];
			}
		}else if(comand == "replace"){
			cin >> a >> b >> p;
			str.replace(a, b - a + 1, p);
		}
	}

	return 0;
}

Measured memory_bytes: 1220
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yosiiii
 */


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

class CAXBC {
public:
	void solve(std::istream& in, std::ostream& out) {
        ll n;
        in >> n;
        ll cnt=0L;
        for(int a=1;a<=n;a++){
            for(int b=1;a*b<n;b++){
                cnt++;
            }
        }
        out << cnt << endl;
	}
};


int main() {
	CAXBC solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <unordered_map>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int D,G;
int p[100],c[100];

int main(){
    cin>>D>>G;
    rep(i,D) cin>>p[i]>>c[i];

    int ans=1001001001;
    for(int i=0;i<1<<D;i++){
        int g=G;
        int res=0;
        int maximum;
        for(int j=0;j<D;j++){
            if(i>>j&1){
                res+=p[j];
                g-=(100*(j+1)*p[j]+c[j]);
            }else{
                maximum=j;
            }
        }
        
        if(g<=0){
            ans=min(ans,res);
        }else{
            if(g/(100.0*(maximum+1))<=p[maximum]){
                res+=ceil(g/(100.0*(maximum+1)));
                ans=min(ans,res);
            }
        }
    }

    cout<<ans<<endl;
}

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

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

  int l = S.length();
  vector<int> N(l, 0);

  int c;
  // L
  for (int i = 0; i < l; i++) {
    if (S[i] == 'R')
      c = 0;
    if (S[i] == 'L') {
      int d = c % 2 == 0 ? c : c + 1;
      N[i - d] += 1;
      c++;
    }
  }
  // R
  for (int i = l - 1; i >= 0; i--) {
    if (S[i] == 'L')
      c = 0;
    if (S[i] == 'R') {
      int d = c % 2 == 0 ? c : c + 1;
      N[i + d] += 1;
      c++;
    }
  }

  for (int i = 0; i < l; i++) {
    if (i)
      cout << " ";
    cout << N[i];
  }
  cout << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(){
  int x[5], i;

  for(i = 0; i < 5; i++)
    scanf("%d", &x[i]);

  for(i = 0; i < 5; i++){
    if(x[i] == 0){
      printf("%d\n", i+1);
    }
  }
  return 0;
}


Measured memory_bytes: 1656
N=int(input())
s=list(map(lambda c:ord(c)-48,input()))
cnt=0
for x in range(10):
    idx=0
    while idx<N and s[idx]!=x:
        idx+=1
    if idx==N:continue
    for y in range(10):
        idy=idx+1
        while idy<N and s[idy]!=y:
            idy+=1
        if idy==N:continue
        for z in range(10):
            idz=idy+1
            while idz<N and s[idz]!=z:
                idz+=1
            if idz<N:cnt+=1
print(cnt)

Measured memory_bytes: 3444
#include<iostream>
#include<vector>
#include<climits>
using namespace std;


vector<int>memo;
int dp(int curr,int *a,int k,int n)
{
    if(curr == n-1)
    {
        return 0;
    }
    if(memo[curr] != -1)
    {
        return memo[curr];

    }
    int ans = INT_MAX;
    for(int i = 1;i<=k;i++)
    {

        int place = curr+i;
        if(place<n)
        {
            int temp = abs(a[place]-a[curr])+dp(curr+i,a,k,n);
            ans = min(ans,temp);
        }


    }
    return memo[curr] = ans;

}

int main()
{

    int n;
    cin>>n;
    int k;
    cin>>k;
    int a[n];
    memo.resize(n,-1);

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

    cout<<dp(0,a,k,n);


}


Measured memory_bytes: 13388
import java.util.Comparator;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    static class Route {
        int c, t;

        Route(int c, int t) {
            this.c = c;
            this.t = t;
        }
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt(), t = scanner.nextInt();
        Route result = IntStream.range(0, n)
                .mapToObj(i -> new Route(scanner.nextInt(), scanner.nextInt()))
                .filter(route -> route.t <= t)
                .min(Comparator.comparingInt(route -> route.c))
                .orElse(null);
        System.out.println(result == null ? "TLE" : result.c);
    }
}

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


def solve(S: str, T: str):
    count = 0
    for s,t in zip(S,T):
        if s == t:
            count+=1

    print(count)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    solve(S, T)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import math
def extgcd(a, b):
    """
    ax + by = gcd(a,b) = d となる (x,y,d) を返す
    """
    if b == 0:
        return (1, 0, a)
    q, r = a // b, a % b
    x, y, d = extgcd(b, r)
    s, t = y, x - q * y
    return s, t, d

def inv_mod(a, N):
    """
    ax = 1 mod N となる x を返す
    """
    return extgcd(a, N)[0]

def CRT(a_1, a_2, m_1, m_2):
    """
    x = a_1 mod m_1, x = a_2 mod m_2 となる x を返す
    """
    y = (a_2 - a_1) * inv_mod(m_1, m_2) % m_2
    return a_1 + m_1 * y

N = int(input())
N *= 2
K = [[1, N]]
for i in range(2, max(int(N**0.5)+1, 2)):
    if N % i == 0:
        K.append([i, N//i])

ans = float("inf")
for i in range(len(K)):
    a, b = K[i]
    if math.gcd(a, b) == 1:
        P = CRT(0, -1, a, b)
        if P != 0:
            ans = min(P, ans)
        Q = CRT(0, -1, b, a)
        if Q != 0:
            ans = min(Q, ans)

print(ans)

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,x;
    cin >> x >>a;
    if(a>x)
    cout<<"0"<<endl;
    else
    cout<<"10"<<endl;
    return 0;
}

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

int main(){
    string s;
    cin>>s;
    int cnt = 0;

    for(int i=1; i<s.size(); i++){
        if(s[i-1] != s[i]){
            cnt++;
        }
    }

    cout<<cnt<<endl;
}

Measured memory_bytes: 512
X,K,D=map(int,input().split())

if X<0:
    X=-X

if K*D<X:
    print(X-K*D)
else:
    k = K - int(X/D)
    x = X % D
    if k%2:
        print(abs(x-D))
    else:
        print(x)


Measured memory_bytes: 9168
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: n,c,k,i,d_buss,cnt,notteru
    integer(int64), allocatable:: t(:)

    read*, n,c,k
    allocate(t(n))
    do i=1,n
        read*, t(i)
    end do
    call merge_sort(t,1_8,n)
    d_buss=0
    cnt=0
    notteru=0
    do i=1,n
        if (d_buss < t(i)) then
            d_buss=t(i)+k
            cnt=cnt+1
            notteru=0
        else
            if (notteru >= c) then
                d_buss=t(i)+k
                cnt=cnt+1
                notteru=0
            end if
        end if
        notteru=notteru+1
    end do
    print'(i0)', cnt
contains
    recursive subroutine merge_sort(ar, fst, lst)
        integer(8),intent(inout):: ar(:)
        integer(8),intent(in):: fst,lst
        integer(8):: mdl

        if (lst-fst < 2) then
            if (ar(fst) > ar(lst)) call swap(ar(fst),ar(lst))
            return
        end if

        mdl = (fst+lst)/2
        call merge_sort(ar, fst, mdl)
        call merge_sort(ar, mdl+1, lst)
        call merge_(ar, fst, mdl, lst)
    end subroutine

    subroutine merge_(ar, fst, mdl, lst)
        integer(8),intent(inout):: ar(:)
        integer(8),intent(in):: fst, mdl, lst
        integer(8),allocatable:: tmp(:)
        integer(8):: li, ri, ti

        allocate(tmp(lst-fst+1))

        li=fst
        ri=mdl+1   
        ti=1

        do while (li <= mdl .and. ri <= lst)
            if (ar(li) <= ar(ri)) then
                tmp(ti) = ar(li)
                li=li+1
            else
                tmp(ti) = ar(ri)
                ri=ri+1
            end if
            ti=ti+1
        end do

        if (li <= mdl) then
            tmp(ti:) = ar(li:mdl)
        else
            tmp(ti:) = ar(ri:lst)
        end if

        ar(fst:lst) = tmp(:)
        deallocate(tmp)
    end subroutine

    subroutine swap(x,y)
        integer(8),intent(inout):: x,y
        integer(8):: tmp
        tmp = x
        x = y
        y = tmp
    end subroutine

end program name

Measured memory_bytes: 2228
#include<stdio.h>
int main(void){
	int l,s,cnt=0,n,sort[5],i,j;
	while(scanf("%d",&n),n!=0000){
		cnt=0;
		while(n!=6174 && n%1111!=0){
			sort[0]=n/1000;
			sort[1]=n/100-sort[0]*10;
			sort[2]=n/10-(sort[0]*100+sort[1]*10);
			sort[3]=n%10;
			for(i=0;i<4;i++){
				for(j=i+1;j<4;j++){
					if(sort[i]<sort[j]){
					 	sort[4]=sort[i];
					 	sort[i]=sort[j];
					 	sort[j]=sort[4];
					}
				}
			}
			l=sort[0]*1000+sort[1]*100+sort[2]*10+sort[3];
			s=sort[3]*1000+sort[2]*100+sort[1]*10+sort[0];
			n=l-s;
			cnt++;
		}
		if(n%11==0)printf("NA\n");
		else printf("%d\n",cnt);
	}
	return 0;
}

Measured memory_bytes: 608
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++)
#define LL long long
#define pii pair <LL,LL>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

LL n,ans=0;
int par[100010],xx[100010],yy[100010],in[100010][2];
vector <pair <int,pii> > con;

bool cmp1(int x,int y)
{
	return in[x][0]<in[y][0];
}

bool cmp2(int x,int y)
{
	return in[x][1]<in[y][1];
}

inline int getval(int x,int y)
{
	return min(abs(in[x][0]-in[y][0]),abs(in[x][1]-in[y][1]));
}

int FIND(int pos)//dsu
{
	if(par[pos]!=pos) par[pos]=FIND(par[pos]);
	return par[pos];
}

inline void UNION(int pos1,int pos2)
{
	par[FIND(pos1)]=FIND(pos2);
}

int main()
{ 
	cin>>n;
	rep(i,100005) par[i]=i,xx[i]=i,yy[i]=i;
	rep(i,n) scanf("%I64d%I64d",&in[i][0],&in[i][1]);
	sort(xx,xx+n,cmp1);
	sort(yy,yy+n,cmp2);
	repn(i,n-1)
	{
		con.pb({getval(xx[i-1],xx[i]),{xx[i-1],xx[i]}});
		con.pb({getval(yy[i-1],yy[i]),{yy[i-1],yy[i]}});
	}
	sort(con.begin(),con.end());
	rep(i,con.size())
	{
		if(FIND(con[i].se.fi)==FIND(con[i].se.se)) continue;
		UNION(con[i].se.fi,con[i].se.se);
		ans+=con[i].fi;
	}
	cout<<ans<<endl;
	rt0;
}

Measured memory_bytes: 10480
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
#define INF LLONG_MAX
#define mod 1000000007
typedef long long ll;
int main(void)
{
	string N;
	cin >> N;
	bool sev = false;
	rep(i,N.size())	if(N[i]=='7') sev = true;
	if(sev) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3624
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main(){
	int n;
	cin >> n;
	int a[100001];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	multiset<int> s;
	s.insert(-1);
	for(int i = 0; i < n; i++){
		auto itr = s.lower_bound(a[i]);
		itr--;
		while(itr != s.begin() && (*itr) == a[i]) itr--;
		if(itr != s.begin()){
			s.erase(itr);
		}
		s.insert(a[i]);
	}
	cout << s.size() - 1 << endl;
}

Measured memory_bytes: 5376
fun main(args: Array<String>) = yorukatsu14c()

fun yorukatsu14c() {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(' ').map { it.toLong() }

    val answer = aList.fold(0L) { acc, l -> gcd(acc, l) }

    println(answer)
}

private tailrec fun gcd(a: Long, b: Long): Long {
    return if (b == 0L) a else gcd(b, a % b)
}


Measured memory_bytes: 53816
#include"bits/stdc++.h"
using ll=long long; 
using ld=long double; 
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
const int mod1=1e9+7; 
#define MAX 100000
ll fact[MAX+7];
ll powerm1(ll a,ll b){ ll res=1; while(b) { if(b&1) res=(res*a)%mod1; a=(a*a)%mod1; b>>=1; } return res; }
void fac(){ fact[0]=1; fact[1]=1; rep(i,2,MAX-1) fact[i]=(fact[i-1]*i)%mod1; }
ll modInv(int n){ return powerm1(n,mod1-2); }
int ncr(int n,int r){ if (r==0) return 1; return (fact[n]*modInv(fact[r])%mod1*modInv(fact[n-r])%mod1)%mod1; }
int main()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout); 
  #endif
  fac(); 
  int s; cin>>s;  ll ans=0; 
  for(int i=1;i<=10000;i++)
  {
   if(s-2*i-1<i-1) break; 
   ans=(ans+ncr(s-2*i-1,i-1))%mod1;  
  }
  cout<<ans; 
}

Measured memory_bytes: 4416
#include <bits/stdc++.h>
using ll = long long;
#define rep(i,n) for (int i = 0; i < n; ++i)
#define REP(i,s,t) for (int i = s; i < t; ++i)

const ll B = 1e9+7;
const int K = 100000;
int n, k;
ll cnt[K+1];

ll powmod(ll p, ll q) {
	ll r = 1;
	while (q) {
		if (q&1) r = r*p % B;
		p = p*p % B;
		q >>= 1;
	}
	return r;
}

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

	cnt[1] = 1;
	REP(i,2,k+1) {
		cnt[i] = powmod(i,n);
		int ri = sqrt(i), t;
		REP(j,1,ri+1) {
			cnt[i] = (cnt[i] + (i/j-i/(j+1))*(B-cnt[j])%B) % B;
			t = i/(j+1);
		}
		REP(j,2,t+1) cnt[i] = (cnt[i] + B-cnt[i/j]) % B;
	}
	
	ll sum = 0;
	REP(i,2,k+1) sum = (sum + i*cnt[k/i]%B) % B;
	sum = (sum + cnt[k]) % B;

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

Measured memory_bytes: 4544
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {

    int a, b;
    cin >> a >> b;
    cout << (a <= b ? a : a - 1) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#
X, Y = list(map(int, input().split()))

#
if X==Y or Y==1 or X%Y==0:
    print(-1)
    exit()

#
N = X*2
while N<=10**18:
    if N%Y!=0:
        print(N)
        exit()
    N += X

#
print(-1)


Measured memory_bytes: 2940
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, a, n) for (int i = a; i < (n); i++)
#define all(in) in.begin(), in.end()
const int INF = 1e9;
const int MOD = 1e9 + 7;
int main() {
    string S;
    cin >> S;
    if (S.size() < 4 || S.substr(0, 4) != "YAKI") {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    //cout << S.substr(0, 3) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String ans = dfs(0, n) ? "Yes" : "No";
		System.out.println(ans);
		sc.close();
	}
	
	static boolean dfs(int sum, int n) {
		if (sum == n) return true;
		if (sum > n) return false;
		
		return dfs(sum + 4, n) || dfs(sum + 7, n);
	}
}




Measured memory_bytes: 27068
#include <stdio.h>

int main() {
	int trix1[4][4], Zx, Xy;
		for (int u = 0; u < 3; u++) {
			for (int i = 0; i < 3; i++) {
				scanf("%d", &trix1[u][i]);
			}
		}
		int trix2[4][4] = {};
		scanf("%d", &Zx);
		for(int o = 0; o < Zx; o++) {
			scanf("%d", &Xy);
			for (int u = 0; u < 3; u++) {
				for (int i = 0; i < 3; i++) {
					if (Xy == trix1[u][i]) {
						trix2[u][i]++;
					  	if ((trix2[0][0] > 0 && trix2[0][1] > 0 && trix2[0][2] > 0) || (trix2[1][0] > 0 && trix2[1][1] > 0 && trix2[1][2] > 0) || (trix2[2][0] > 0 && trix2[2][1] > 0 && trix2[2][2] > 0) || (trix2[0][0] > 0 && trix2[1][0] > 0 && trix2[2][0] > 0) || (trix2[0][1] > 0 && trix2[1][1] > 0 && trix2[2][1] > 0) || (trix2[0][2] > 0 && trix2[1][2] > 0 && trix2[2][2] > 0) || (trix2[0][2] > 0 && trix2[1][1] > 0 && trix2[2][0] > 0) || (trix2[0][0] > 0 && trix2[1][1] > 0 && trix2[2][2] > 0)) {
					  		printf("Yes\n");
					  		return 0;
					  	}
					}
				}
			}
		}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 1656
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

int main()
{
  int n;
  while (scanf("%d", &n) != EOF)
  {
    char ver[11];
    map<string, int> cnt;
    for (int i = 0; i < n; i++)
    {
      scanf(" %s", ver);
      string s = string(ver);
      if (!cnt.count(s)) cnt[s] = 0;
      cnt[s]++;
    }

    vector<string> v = {"AC", "WA", "TLE", "RE"};
    for (string vv: v)
    {
      if (!cnt.count(vv))
        cnt[vv] = 0;
      printf("%s x %d\n", vv.c_str(), cnt[vv]);
    }
  }
  return 0;
}

Measured memory_bytes: 3800
#include<iostream>
using namespace std;
int main(){
	int ame,num;
	while(cin>>ame){
		num=ame%39;
		if(num==0)num=39;
		if(num<10)cout<<"3C0"<<num<<endl;
		else if(num>10)cout<<"3C"<<num<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
n, m = gets.split.map(&:to_i)
a_ary = Array.new(n){Array.new(m, 0)}
b_ary = Array.new(m, 0)
n.times do |n|
    a_ary[n] = gets.split.map(&:to_i)
end
b_ary = readlines.map(&:chomp).map(&:to_i)
n.times do |n|
    total = 0
    m.times do |m|
        a = a_ary[n][m]
        b = b_ary[m]
        total = total + a*b
    end
    puts total
end


Measured memory_bytes: 7072
//g++ -std=c++14 test.cpp -o test.out
//問題URL
//https://atcoder.jp/contests/dp/tasks/dp_g
//参考：https://qiita.com/drken/items/03c7db44ccd27820ea0d
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const int INF_INT = 2147483647-1e6;
const LL mod = 1000000007ll;

int N,M;
vector<vector<int>> adjacent;//隣接行列

int ans = 0;

//メモ化再帰
//ノードiを始点としたときの、Gの有効パスの長さの最大値をdp[i]とおく
//まだノードiについて見たことかないならdp[i]=-1
vector<int> dp;
//点vを始点としたときの、Gの有効パスの長さの最大値を返す関数
int rec(int v) {
    //ノードvを始点としたときの最大長をもう見たかどうか
    if (dp[v] != -1) return dp[v]; // 既に更新済み

    int res = 0;
    for (auto nv : adjacent[v]) {//隣接行列から点nvを取り出す
        res = max(res,rec(nv)+1);
    }
    return dp[v] = res; // メモしながらリターン
}

void solve(){
    dp = vector<int>(N,-1);
    //全ノードに対し各点への最長距離を求め、最も長いものを答えとする
    for (int v=0;v<N;++v) ans = max(ans,rec(v));
}
 
int main(){
	cin >> N >> M;
    adjacent = vector<vector<int>>(N);
    for(int i=0;i<M;i++){
        int x,y;
        cin >> x >> y;
        x--,y--;
        adjacent[x].push_back(y);
    }
 
	solve();

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

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sqr(x) ((x) * (x))
#define X first
#define Y second
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define MAXN 110

int a[2][MAXN], dp[2][MAXN];

int main()
{
  int n;
  scanf("%d", &n);
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < n; j++) {
      scanf("%d", &a[i][j]);
    }
  }
  dp[0][0] = a[0][0];
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < n; j++) {
      if (!i && !j) continue;
      dp[i][j] = 0;
      if (i) dp[i][j] = max(dp[i][j], a[i][j] + dp[i - 1][j]);
      if (j) dp[i][j] = max(dp[i][j], a[i][j] + dp[i][j - 1]);
    }
  }
  cout << dp[1][n - 1];
  return 0;
}


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

int main()
{
    string s;
    int n;
    cin >> s >> n;
    for(int i=0; i < s.length(); i++){
        cout << s[i];
        i += n-1;
    }
    cout << "" << endl;
    return 0;
}


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

int n,have,use,rest,sum,ok,s=0;
vector<int> lim(4),ans(4);
vector<int> coin={10,50,100,500};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n,n){
        if (s) cout << '\n';
        s=1; have=0;
        for (int i=0;i<4;++i) cin >> lim[i],have+=lim[i];
        use=100;
        for (int i=0;i<=lim[0];++i){
            for (int j=0;j<=lim[1];++j){
                for (int k=0;k<=lim[2];++k){
                    for (int l=0;l<=lim[3];++l){
                        rest=10*i+50*j+100*k+500*l-n;
                        if (rest<0) continue;
                        sum=have-(i+j+k+l),ok=1;
                        for (int m=3;m>=0;--m){
                            if (m==3&&rest/coin[m]&&l) ok=0;
                            if (m==2&&rest/coin[m]&&k) ok=0;
                            if (m==1&&rest/coin[m]&&j) ok=0;
                            if (m==0&&rest/coin[m]&&i) ok=0;
                            sum+=rest/coin[m],rest%=coin[m];
                        }
                        if (!ok) continue;
                        if (sum<use){
                            use=sum;
                            ans[0]=i,ans[1]=j,ans[2]=k,ans[3]=l;
                        }
                    }
                }
            }
        }
        for (int i=0;i<4;++i) if (ans[i]){
            cout << coin[i] << ' ' << ans[i] << '\n';
        }
    }
}



Measured memory_bytes: 3120
n=int(input())
arr=[list(map(int,input().split())) for _ in range(n)]
arr2=[]
ans=0
mb=10**18
for a,b in arr:
  ans+=a
  if a>b:
    mb=min(mb,b)
if mb==10**18:
  print(0)
else:
  print(ans-mb)

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

int main(){
    int n;
    cin>>n;
    int ans = n%1000;

    if(ans!=0){
        ans = 1000-ans;
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 3620
aryTime = []
aryModTime = []
allTime = 0
for i in range(5):
  aryTime.append(int(input()))
  aryModTime.append(aryTime[i] % 10)
  allTime += (int(aryTime[i] / 10) * 10)
  #print(str(aryTime[i]) + "," + str(allTime))
  
flgMinCheck = False
aryModTime.sort()
for j in range(len(aryModTime)):
  if aryModTime[j] == 0:
    pass
  elif aryModTime[j] > 0 and flgMinCheck == False:
    allTime += aryModTime[j]
    flgMinCheck = True
  else:
    allTime += 10
  #print(str(aryModTime[j]) + "," + str(allTime))


print(allTime)

Measured memory_bytes: 3064
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    String s = sc.next();
    String t = sc.next();
    String ans = "No";

    if(t.substring(0, s.length()).equals(s)){
      ans = "Yes";
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 35692
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 5e5 + 10;
pair<ll, double> q[MAXN];
#define dec ruiuiehrrefrf
int n, maxv, t, v, l = 1, r = 0;
ll dec, sum = 0;
double tem = 0;

int main()
{
	scanf("%d%d", &n, &maxv);
	for (int i = 1; i <= n; i++)
	{
		scanf("%d%d", &t, &v);
		while (sum + v > maxv)
		{
			dec = min(q[l].first, sum + v - maxv);
			q[l].first -= dec;
			sum -= dec;
			tem -= q[l].second * dec;
			if (!q[l].first) l++;
		}
		sum += v;
		tem += 1ll * t * v;
		q[++r] = make_pair(v, t);
		for (; l < r && q[r].second < q[r - 1].second; --r)
		{
			q[r - 1].second = (q[r].second * q[r].first + q[r - 1].second * q[r - 1].first) / (q[r].first + q[r - 1].first);
			q[r - 1].first += q[r].first;
		}
		printf("%.7f\n", tem / maxv);
	}
}

Measured memory_bytes: 16896
import os
import sys
import math
import heapq
from decimal import *
from io import BytesIO, IOBase
from collections import defaultdict, deque

def r():
    return int(input())
def rm():
    return map(int,input().split())
def rl():
    return list(map(int,input().split()))


a, b, c, d = rm()
e = [a*c, a*d, b*c, b*d]
print(max(e))

Measured memory_bytes: 77352
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(){
    string s, t;
    cin>>s;
    cin>>t;
    int ls = s.length();
    int lt = t.length();
    int ans = INT32_MAX;
    for (int i = 0; i + lt <= ls; ++i) {
        int tot = 0;
        for (int j = 0; j < lt; ++j) {
            if(t[j] != s[i + j]){
                tot++;
            }
        }
        ans = min(tot, ans);
    }
    cout<<ans;
}

Measured memory_bytes: 3624