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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;

const ll mod=1000000007;
//head

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

    int n,m; cin >> n >> m;
    vector<bool> good(n+1,true);
    vector<int> h(n+1,0);
    for(int i = 0; i < n; i++) cin >> h[i];
    for(int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        if(h[u] > h[v]) {
            good[v] = false;
        } else if(h[v] > h[u]) {
            good[u] = false;
        } else {
            good[u] = good[v] = false;
        }
    }
    int cnt = 0;
    for(int i = 0; i < n; i++) {
        if(good[i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


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

typedef long long ll;

const int N = 60;
const ll mod = 1e9 + 7;

int n;
ll K;
struct mat {
	ll d[N][N];
	mat() {memset(d, 0, sizeof(d));}
	mat operator * (mat &x) {
		mat ans;
		for(int k = 1; k <= n; ++k) {
			for(int i = 1; i <= n; ++i) {
				for(int j = 1; j <= n; ++j) {
					(ans.d[i][j] += d[i][k] * x.d[k][j] % mod) %= mod;
				}
			}
		}
		return ans;
	}
} A[65];

int main() {
	scanf("%d%lld", &n, &K);
	for(int i = 1; i <= n; ++i) for(int j = 1; j <= n; ++j) scanf("%lld", &A[0].d[i][j]);
	for(ll i = 1; (1LL << i) <= K; ++i) {
		A[i] = A[i - 1] * A[i - 1];
	}
	mat ans;
	for(int i = 1; i <= n; ++i) ans.d[i][i] = 1;
	for(ll i = 0; (1LL << i) <= K; ++i) 
		if((K >> i) & 1LL) ans = ans * A[i];
	ll sum = 0;
	for(int i = 1; i <= n; ++i) {
		for(int j = 1; j <= n; ++j) (sum += ans.d[i][j]) %= mod;
	}
	printf("%lld\n", sum);
}

Measured memory_bytes: 2176
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <type_traits>
#include <cmath>
#include <cassert>
#include <cstdio>

using namespace std;
using namespace placeholders;

using LL = long long;
using ULL = unsigned long long;
using VI = vector< int >;
using VVI = vector< vector< int > >;
using VS = vector< string >;
using ISS = istringstream;
using OSS = ostringstream;
using PII = pair< int, int >;
using VPII = vector< pair< int, int > >;
template < typename T = int > using VT = vector< T >;
template < typename T = int > using VVT = vector< vector< T > >;
template < typename T = int > using LIM = numeric_limits< T >;

template < typename T > inline istream& operator>>( istream &s, vector< T > &v ){ for ( T &t : v ) { s >> t; } return s; }
template < typename T > inline ostream& operator<<( ostream &s, const vector< T > &v ){ for ( int i = 0; i < int( v.size() ); ++i ){ s << ( " " + !i ) << v[i]; } return s; }
template < typename T > inline T fromString( const string &s ) { T res; istringstream iss( s ); iss >> res; return res; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

#define NUMBERED( name, number ) NUMBERED2( name, number )
#define NUMBERED2( name, number ) name ## _ ## number
#define REP1( n ) REP2( NUMBERED( REP_COUNTER, __LINE__ ), n )
#define REP2( i, n ) REP3( i, 0, n )
#define REP3( i, m, n ) for ( int i = ( int )( m ); i < ( int )( n ); ++i )
#define GET_REP( a, b, c, F, ... ) F
#define REP( ... ) GET_REP( __VA_ARGS__, REP3, REP2, REP1 )( __VA_ARGS__ )
#define FOR( e, c ) for ( auto &&e : c )
#define ALL( c ) begin( c ), end( c )
#define AALL( a ) ( remove_all_extents< decltype( a ) >::type * )a, ( remove_all_extents< decltype( a ) >::type * )a + sizeof( a ) / sizeof( remove_all_extents< decltype( a ) >::type )
#define DRANGE( c, p ) begin( c ), begin( c ) + ( p ), end( c )

#define SZ( v ) ( (int)( v ).size() )
#define EXIST( c, e ) ( ( c ).find( e ) != ( c ).end() )

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

#define PB push_back
#define EM emplace
#define EB emplace_back
#define BI back_inserter

#define MP make_pair
#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

int main()
{
	cin.tie( 0 );
	ios::sync_with_stdio( false );
	cout << setprecision( 12 ) << fixed;

	VS S( 3 );
	cin >> S;

	int cur = 0;
	VI ps( 3 );

	while ( ps[ cur ] < SZ( S[ cur ] ) )
	{
		const char ch = S[ cur ][ ps[ cur ] ];
		++ps[ cur ];
		cur = ch - 'a';
	}

	cout << char( 'A' + cur ) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int n,k,i,j,yado[100001],b[100001],now=0,ans=0;
	scanf("%d%d",&n,&k);
	for(i=0;i<n-1;i++)scanf("%d",&yado[i]);
	for(i=0;i<k;i++)scanf("%d",&b[i]);
	for(i=0;i<k;i++){
		if(b[i]>0){
			for(j=now;j<now+b[i];j++)ans=ans+yado[j];
		}
		else{
			for(j=now+b[i];j<now;j++)ans=ans+yado[j];
		}
		now=now+b[i];
		ans=ans%100000;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 2584
n,k = map(int,input().split())
A = list(map(int,input().split()))
cums = [0]
for a in A:
    cums.append(cums[-1] + a)
vs = []
for l in range(n):
    for r in range(l+1, n+1):
        vs.append(cums[r] - cums[l])
vs.sort(reverse=True)


for i in range(100, -1, -1):
    tmp = []
    for v in vs:
        if v&(1<<i):
            tmp.append(v)
    if len(tmp) >= k:
        vs = tmp

if len(vs)<k:
    print(0)
else:
    ans = vs[0]
    for v in vs[1:]:
        ans &= v
    print(ans)

Measured memory_bytes: 69756
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int num[2];
int main()
{
	int n,p,a;num[0]=num[1]=0;
	cin>>n>>p;
	rep(i,n){
		cin>>a;num[a%2]++;
	}
	lint out=1;
	if(num[1]<1){
		if(p==1) cout<<0<<endl;
		else cout<<(1LL<<n)<<endl;
		return 0;
	}
	rep(i,n-1) out*=2;cout<<out<<endl;
}


Measured memory_bytes: 256
gets
Z=$<.map{|s|x,y,d=s.split
[x.to_i,y.to_i,"RULD"=~/#{d}/]}
T=*1,0,-1,l=0
f=->n{b=d=-a=c=1e9
Z.map{|x,y,i|x=x*2+n*T[i]
y=y*2+n*T[i^1]
x<a&&a=x
x>b&&b=x
y<c&&c=y
y>d&&d=y}
(b-a).*d-c}
r=10**9
50.times{f[a=(l*2+r)/3]<f[b=(l+r*2)/3]?r=b:l=a}
p f[l+r>>1]/4.0

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

int main(){
	int N, M=2, X, Y;
	cin >> N >> M >> X >> Y;
	int x[N], y[M], i;
	for(i=1; i<=N; i++){
		cin >> x[i];
	}
	for(i=1; i<=M; i++){
		cin >> y[i];
	}
	
	x[0]=X; y[0]=Y;
	int MaxX=X, MinY=Y;
	
	for(i=1; i<=N; i++){
		if(MaxX<x[i])	MaxX=x[i];
	}
	for(i=1; i<=M; i++){
		if(y[i]<MinY)	MinY=y[i];
	}
	
	if(MaxX<MinY)	cout << "No War" << endl;
	else		cout << "War" << endl;
	
	return 0;
}


Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    a = list(map(int, input().split()))
    res = []
    #dp[i]:i番目の箱に入ってるかどうか
    dp = [0]*n

    #iの倍数の箱を調べる
    for i in range(n, 0, -1):
        #調べる箱列挙
        t = 0
        for j in range(i, n+1, i):
            t += dp[j-1]
        if t%2 != a[i-1]:
            res.append(i)
            dp[i-1] = 1

    if not 1 in a:
        print(0)
    else:
        print(len(res))
        print(*res)

if __name__ == '__main__':
    main()


Measured memory_bytes: 65656
#include <iostream>
using namespace std;
int main(){
  long long x,ans,mod;
  cin >> x;
  ans = (x / 11) * 2;
  mod = x % 11;
  if(mod > 6){
    ans += 2;
  }else if(mod == 0){
  }else{
    ans += 1;
  }
  cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define all(x) (x).begin(), (x).end()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end());
const long long INF = 1LL << 60;
// map<int,int> mp;

int main() {
  // in

  int N;
  cin >> N;
  vector<int> R(N);

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

  // pro

  int pp, dif;

  pp = R[0];

  dif = R[1] - R[0];

  for (int i = 1; i < N; i++) {
    dif = max(dif, R[i] - pp);

    pp = min(pp, R[i]);
  }

  // out

  cout << dif << endl;
}


Measured memory_bytes: 3552
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define ff first
#define pii pair<int, int>
#define vii vector< pair<int,int> >
#define vi vector<int>
#define vvi vector< vector< int> >
#define ss second
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define int long long
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define ull unsigned long long
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace4(x, y, z, d)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#d<<": "<<d<<endl

#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define debug1(x) cerr << #x << ": " << x <<'\n'
#define debug2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
int dx[]={1,0,-1, 0};int dy[]={0,1,0, -1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
bool compare(const pair<int,int> &a,
             const pair<int,int> &b)
{
    if(a.ff == b.ff) {
        return (b.ss < a.ss);
    }
    return (a.ff<b.ff);
}
bool prime[1000001];
void SieveOfEratosthenes(int n) 
{
    // 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.

    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}

int a[100001][3];
int dp[100001][3];
int32_t main()
{
    IOS;
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    /********************* From here ***********************/
    int n ;
    cin >> n ;

    rep(i, 0, n){
        rep(j, 0, 3){
            cin >> a[i][j];
        }  
    }

    dp[0][0] = a[0][0];
    dp[0][1] = a[0][1];
    dp[0][2] = a[0][2];
    rep(i, 1, n){
        dp[i][1] = max(dp[i-1][0]+a[i][1], dp[i-1][2]+a[i][1]);
        dp[i][2] = max(dp[i-1][0]+a[i][2], dp[i-1][1]+a[i][2]);
        dp[i][0] = max(dp[i-1][1]+a[i][0], dp[i-1][2]+a[i][0]);
    }
        // rep(i, 1, n+1){
        //     cout << dp[i] << " ";
        // }
        // cout << endl;
    cout << max(dp[n-1][0], max(dp[n-1][1] , dp[n-1][2]));
}



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

using namespace std;

template<typename S, typename T>
ostream& operator<<(ostream& out, const pair<S, T> p) {
    out << "(" << p.first << "," << p.second << ")";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
    for (auto a: v)
        out << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const set<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const multiset<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename S, typename T>
ostream& operator<<(ostream& out, const map<S, T>& M) {
    for (auto m: M)
        cout << "(" << m.first << "->" << m.second << ") ";
    return out;
}

template<typename S, typename T>
pair<S, T> operator+(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first + b.first, a.second + b.second);
}

template<typename S, typename T>
pair<S, T> operator-(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first - b.first, a.second - b.second);
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    if (n >= 30)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef vector<vl> mt;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<string> vs;
typedef vector<vs> table;
typedef vector<vl> v2;
typedef vector<v2> v3;
typedef vector<v3> v4;


const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 50;

vd x,y;
ld cx,cy;
vd l;

int main(){
  x = y = vd(3);
  for(ll i = 0;i < 3;i++) cin >> x[i] >> y[i];
  l = vd(3);
  for(ll i = 0;i < 3;i++){
    l[i] = sqrt((x[(i+1)%3]-x[(i-1+3)%3])*(x[(i+1)%3]-x[(i-1+3)%3])+(y[(i+1)%3]-y[(i-1+3)%3])*(y[(i+1)%3]-y[(i-1+3)%3]));
  }
  for(ll i = 0;i < 3;i++){
    cx += x[i]*l[i];
    cy += y[i]*l[i];
  }
  cx /= accumulate(l.begin(),l.end(),0.);
  cy /= accumulate(l.begin(),l.end(),0.);
  for(ll i = 0;i < 3;i++){
    x[i] -= cx;
    y[i] -= cy;
  }
  ld s = accumulate(l.begin(),l.end(),0.)/2;
  for(ll i = 0;i < 3;i++){
    cerr << l[i] << " ";
  }
  cerr << endl;
  ld area = sqrt(s*(s-l[0])*(s-l[1])*(s-l[2]));
  ld r = 2*area/(accumulate(l.begin(),l.end(),0.));
  ld top = 1.0;
  ld bottom = 0.0;
  for(ll i = 0;i < 100;i++){
    ld middle = (top+bottom)/2;
    if(*max_element(l.begin(),l.end())/2*middle < (1-middle)*r) bottom = middle;
    else top = middle;
  }
  cout << setprecision(1000);
  cout << r*(1-top) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
int main(void){
   int n;
   cin >> n;
   ll ans = 1;
   for(int i = 1; i < n; i++){
       if(i * i <= n){
           ans = i * i;
       }else {
           break;
       }
   }
   cout << ans << endl;
}


Measured memory_bytes: 256
#!/usr/local/bin/ruby
num = Hash.new(0)
max = 0
while (n=gets.to_i)!=0
#while (n=gets.to_i) != true
 num[n] += 1
end
num.to_a.sort{|p,q| -(p[1]<=>q[1]) }.each do |key,value|
 if value >= max
  max = value
  puts key
 else
  break
 end
end

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

    vector<int> change = {0};
    for(int i=0; i<N-1; i++){
        if(vec.at(i) != vec.at(i+1)){
            change.push_back(i+1);
        }
    }
    /*
    for(int i=0; i<change.size(); i++){
        cout << change.at(i) << " ";
    }
    */
    change.push_back(N);
    vector<int> sabun(change.size()-1);
    for(int i=0; i<change.size()-1; i++){
        sabun.at(i) = change.at(i+1) - change.at(i);
    }
    
    /*
    for(int i=0; i<sabun.size(); i++){
        cout << sabun.at(i) << " ";
    }
    */
    sort(sabun.begin(), sabun.end());
    int M = sabun.at(sabun.size()-1);

    for(int i=0; i<change.size()-1; i++){
        if(change.at(i+1) - change.at(i) == M){
            cout << vec.at(change.at(i)) << endl;
        }
    }
    
    
}

Measured memory_bytes: 15992
#include <stdio.h>
#include <stdlib.h>

void print_a (int *, int);

int main (void) {
    int n;
    int *a;

    scanf ("%d", &n);

    a = (int *) malloc (sizeof(int) * n);
    for (int i=0; i<n; i++) scanf ("%d", a+i);

    for (int i=0; i<n; i++) {
        int key = a[i];
        int j = i-1;
        for (; key<a[j] && j>=0; j--) a[j+1] = a[j];
        a[j+1] = key;
        print_a (a, n);
    }

    free (a);
    return 0;
}

void print_a (int *a, int n) {
    for (int j=0; j<n; j++) {
            if (j==n-1) printf ("%d\n", a[j]);
            else printf ("%d ", a[j]);
        }
}


Measured memory_bytes: 2064
#include <bits/stdc++.h>
#define ull uint64_t
#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mx5 100005
#define mx6 1000005
#define mod 1000000007
#define nfs ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

int main() {
    nfs
    int i, j, n, k, dp[mx5] = {}, h[mx5] = {};
    cin >> n >> k;
    cin >> h[0];
    for (i = 1; i < n; i++) {
        cin >> h[i];
        dp[i] = dp[i-1] + abs(h[i] - h[i-1]);
        for (j = 2; j <= min(k, i); j++) {
            dp[i] = min (dp[i], dp[i-j] + abs(h[i] - h[i-j]));
        }
    }
    cout << dp[n-1];
}

Measured memory_bytes: 4332
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<stdbool.h>
#include<tgmath.h>
#include<sys/queue.h>
#include<time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define miin(a, b, c) min((a), min((b), (c)))
#define maax(a, b, c) max((a), max((b), (c)))
#define mod 1000000007

int n;
char s[334];

main(){
    scanf("%d%s", &n, s);
    if(strlen(s)<= n){
        printf("%s\n", s);
    }else {
        for(int i=0; i<n; i++)putchar(s[i]);
        puts("...");
    }
    return 0;
}

Measured memory_bytes: 1648
#include <cstdio>
#include <vector>
using namespace std;

int n;
void counting_sort(vector<int>& A,vector<int>& B,int k) {
  int C[k+1];
  // 0 initialize
  for(int i=0;i<=k;i++) {
    C[i] = 0;
  }
  // counting A_j
  for(int j=1;j<=n;j++) {
    C[A[j]]++;
  }
  // counting less than A_j
  for(int i=1;i<=k;i++) {
    C[i] = C[i] + C[i-1];
  }
  // sorting
  for(int j=n;j>=1;j--) {
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
}

int max(vector<int>& A) {
  int max = A[1];
  for(int i=1;i<=n;i++) {
    if(A[i] > max) max = A[i];
  }
  return max;
}

int main() {
  scanf("%d",&n);
  vector<int> A(n+1);
  vector<int> B(n+1);
  for(int i=1;i<=n;i++) {
    scanf("%d ", &A[i]);
  }

  counting_sort(A,B,max(A));
  for(int i=1;i<n;i++) {
    printf("%d ",B[i]);
  }
  printf("%d\n",B[n]);
}

Measured memory_bytes: 16436
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int used = 0;
    while(b <= a) {
        used += 1;
        b *= 2;
    }
    while (c <= b) {
        used += 1;
        c *= 2;
    }
    if (used <= k) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3568
#include<iostream>
using namespace std;
int main(void){
	int r;
	int g;
	int b;
	
	cin >> r >> g >> b ;
	
	if((r*100 + g*10 + b)% 4 == 0){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	
return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int H, W;
  string m[200];
  int dist[200][200];

  cin >> H >> W;

  queue<pair<int,int> > que, queP;

  for (int i=0; i<H; i++) {
    cin >> m[i];
    for (int j=0; j<W; j++) {
      if (m[i][j] == '$') que.push({i, j});
      if (m[i][j] == '@') queP.push({i, j});
      dist[i][j] = INF;
    }
  }

  for(int i=0; que.size(); i++) {
    queue<pair<int,int> > que2;

    while(que.size()) {
      auto p = que.front();
      que.pop();
      int y = p.first;
      int x = p.second;

      if (m[y][x] == '#') continue;
      if (dist[y][x] < INF) continue;

      dist[y][x] = i;

      if (y > 0)   que2.push({y-1, x});
      if (x > 0)   que2.push({y, x-1});
      if (y+1 < H) que2.push({y+1, x});
      if (x+1 < W) que2.push({y, x+1});
    }

    que = que2;
  }

  for(int i=0; queP.size(); i++) {
    queue<pair<int,int> > que2;

    while(queP.size()) {
      auto p = queP.front();
      queP.pop();
      int y = p.first;
      int x = p.second;

      if (m[y][x] == '#') continue;
      if (dist[y][x] <= i) continue;
      dist[y][x] = -1;

      if (m[y][x] == '%') {
        puts("Yes");
        return 0;
      }

      if (y > 0)   que2.push({y-1, x});
      if (x > 0)   que2.push({y, x-1});
      if (y+1 < H) que2.push({y+1, x});
      if (x+1 < W) que2.push({y, x+1});
    }

    queP = que2;
  }


  puts("No");

  return 0;
}



Measured memory_bytes: 5564
fn main(){
  let nx: Vec<u32> = read_vec();
  let x = nx[1];
  let mut a: Vec<u32> = read_vec();
  
  a.sort();
  let (ct, rm) = a.iter().fold((0,x), |(c, r), &u| if r >= u {(c+1, r-u)} else {(c, 0)});
  let ans = if rm > 0 {ct - 1} else {ct};
  
  println!("{}", ans);
}

fn read_vec<T>() -> Vec<T>
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}


Measured memory_bytes: 4352
/*▄███████▀▀▀▀▀▀███████▄
░▐████▀▒ЗАПУСКАЕМ▒▀██████▄
░███▀▒▒▒▒▒ДЯДЮ▒▒▒▒▒▒▀█████
░▐██▒▒▒▒▒БОГДАНА▒▒▒▒▒████▌
░▐█▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████▌
░░█▒▄▀▀▀▀▀▄▒▒▄▀▀▀▀▀▄▒▐███▌
░░░▐░░░▄▄░░▌▐░░░▄▄░░▌▐███▌
░▄▀▌░░░▀▀░░▌▐░░░▀▀░░▌▒▀▒█▌
░▌▒▀▄░░░░▄▀▒▒▀▄░░░▄▀▒▒▄▀▒▌
░▀▄▐▒▀▀▀▀▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒█
░░░▀▌▒▄██▄▄▄▄████▄▒▒▒▒█▀
░░░░▄█████████████  █▒▒▐▌
░░░▀███▀▀████▀█████▀▒▌
░░░░░▌▒▒▒▄▒▒▒▄▒▒▒▒▒▒▐
░░░░░▌▒▒▒▒▀▀▀▒▒▒▒▒▒▒▐*/
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("O3")
#pragma GCC optimize("fast-math")
#include <iostream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <math.h>
#include <set>
#include <stack>
#include <bitset>
#include <map>
#include <queue>
#include <random>
#include <unordered_set>
#include <unordered_map>
#define DEBUG
#define fi first
#define se second
#define pqueue priority_queue
#define pb(x) push_back(x)
//#define endl '\n'
#define all(x) x.begin(), x.end()
#define int long long
#define mk(a, b) make_pair(a, b)
     
using namespace std;
      
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<ll> > vvi;
typedef vector<ull> vull;
typedef vector<ll> vll;
// typedef tuple<ll, ll, ll> tiii;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector< vector<ll> > vvi;
typedef vector<char> vc;
      
const ll INF = 1e9 + 228;
const ll INFLL = 1e18;
const ll MOD = 1e9 + 7;
//static const int maxn = 2e5 + 228;;
const ld eps = 1e-7;
const ld eps2 = 1e-9;
const ll MOD2 = 998244353;
const ll dosz = 5e5;
const ll SZ = (1<<18);
const ld PI = atan2l(0, -1);
     
void fast_io(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifdef DEBUG
//      freopen("haybales.in", "r", stdin);
//      freopen("haybales.out", "w", stdout);
    #endif
}

void solve(){	
	int a, b, c, d, t;
	cin >> a >> b >> c >> d >> t;
	cout << (c-a)*60 + (d-b)-t << endl;
}

signed main(){
        fast_io();
	srand(time(NULL));
//	cout << fixed << setprecision(12);
	int q = 1;
//	cin >> q;
	while(q--)
		solve();
     
}





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

#define int long long

#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define FORR(i,m,n) for(int i=m;i>=n;i--)
#define pb(x) push_back(x) 
#define SORT(x) sort((x).begin(),(x).end())
#define INF 99999999999
 
using namespace std;

int32_t main(){
    string str;
    cin >> str;

    if(str=="zyxwvutsrqponmlkjihgfedcba"){
        cout << "-1" << endl;
        return 0;
    }

    vector<int> v(26, INF);
    int n=str.length();
    REP(i, n){
        v[str[i]-'a']=i;
    }

    if(n!=26){
        REP(i, 26){
            if(v[i]==INF){
                cout << str << (char)('a'+i) << endl;
                return 0;
            }
        }
    }

    for(int i=n-2; i>=0; i--){
        if(str[i+1]>str[i]){
            for(char j=str[i]+1; j<='z'; j++){
                if(v[j-'a']>i){
                    REP(k, i){
                        cout << str[k];
                    }
                    cout << j << endl;
                    return 0;
                }
            }
        }
    }
}



Measured memory_bytes: 256
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
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; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int N = 5;
    vll A(N);

    rep(i, N) in(A[i]);

    ll ans = INF;
    do {
        ll tmp = 0;
        rep(i, N)
        {
            if (tmp % 10 != 0) tmp += 10 - tmp % 10;

            tmp += A[i];
        }

        chmin(ans, tmp);

    } while (next_permutation(all(A)));

    outl(ans);

    return 0;
}

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

int main(){
  int N, K;
  cin >> N >> K;
  double p;
  if(N > K - 1) p = (N + 1.0 - K) / N;
  else p = 0;
  
  int i, temp;
  double ptemp;
  bool check;
  for(i = 1; i < min(N + 1, K); i++){
    temp = i;
    ptemp = 1.0 / N;
    check = true;
    while(check){
      ptemp *= 1.0 / 2.0;
      temp *= 2.0;
      if(temp > K - 1) check = false;
    }
    p += ptemp;
  }
  
  cout << std::setprecision(12) << p << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <functional>

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
typedef long long ll;

bool sortbysec(const pair<ll,ll> &a, 
              const pair<ll,ll> &b) 
{ 
    return (a.second < b.second); 
} 

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

  int N,M;
  cin>>N>>M;

  vector<ll>A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  vector<pair<ll,ll>> BC(M);
  for(int i=0;i<M;i++){
    ll b,c;
    cin>>b>>c;
    BC[i]=make_pair(b,c);
  }

  sort(A.begin(),A.end());
  sort(BC.rbegin(),BC.rend(),sortbysec);
  BC.push_back(make_pair(100000,0));

  ll ans=0ll;
  int now=0,cnt=0;
  for(int i=0;i<N;i++){
    if(BC[now].second>A[i]){
      ans+=BC[now].second;
    }else{
      ans+=A[i];
    }
    cnt++;
    if(cnt>=BC[now].first){
      now++;
      cnt=0;
    }
  }
  cout<<ans<<endl;
}

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

#define ul unsigned long long
#define ll long long

int main()
{
  string s;
  s.reserve(100000);
  ul q;
  cin>>s>>q;

  int t,f;
  int rev=0;
  string c;

  for (ul i=0;i<q;i++) {
    cin>>t;
    if (t==1) {
      rev=rev?0:1;
    }else if (t==2) {
      cin>>f>>c;
      f--;
      if (f^rev) s+=c;
      else s.insert(0,c);
    }
    //cout<<s<<endl;
  }
  if (rev)
    reverse(s.begin(), s.end());
  cout<<s<<endl;

  return 0;
}


Measured memory_bytes: 952
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;
int main(){
    ll n, k;
    scanf("%lld%lld", &n, &k);
    ll ans = 0;
    if (k%2==0) {
        ans = (n/k)*(n/k)*(n/k);
        if (n%k >= k/2) {
            ans += (n/k+1)*(n/k+1)*(n/k+1);
        }
        else
            ans += (n/k)*(n/k)*(n/k);
    }
    else{
        ans = (n/k)*(n/k)*(n/k);
    }
    printf("%lld\n", ans);
}

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

int main() {
	int n;
	cin >> n;
	int ans = 0;
	if (n % 1000 != 0) {
		int num = n / 1000;
		ans = (num+1) * 1000 - n;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  ll n,a,b;
  cin>>n>>a>>b;
  ll c=(a)*(n/(a+b));
  ll x = n-(a+b)*(n/(a+b));
  cout << c + min(a,x) << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
A.sort()
A.reverse()
ans_lis = []
count = 1
before = A[0]
for i in range(1,N):
  tmp = A[i]
  if tmp == before:
    count += 1
  else:
    if count == 2 or count == 3:
      ans_lis.append(before)
    elif count >= 4 and len(ans_lis) == 0:
      ans_lis.append(before)
      ans_lis.append(before)
    elif count >= 4 and len(ans_lis) != 0:
      ans_lis.append(before)
    count = 1
  if len(ans_lis) == 2:
    break
  before = tmp
if len(ans_lis) == 0:
  if A[N-1] == A[N-2] and A[N-2] == A[N-3] and A[N-3] == A[N-4]:
    ans_lis.append(A[N-1])
    ans_lis.append(A[N-1])
elif len(ans_lis) == 1:
  if A[N-1] == A[N-2]:
    ans_lis.append(A[N-1])
if len(ans_lis) < 2:
  print(0)
else:
  print(ans_lis[0] * ans_lis[1])
  


Measured memory_bytes: 14672
#include <bits/stdc++.h>
#define REP(i, n, s) for (int i = (s); i < (n); i++)
#define SIZE 1
using namespace std;
typedef long long int LL;
typedef long double LD;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int N, A, X[50];
	LL dp[2][51][2501];

	cin >> N >> A;
	REP(i, N, 0) cin >> X[i];

	int idx = 0, _idx;
	memset(dp[idx], 0, sizeof(dp[idx]));
	dp[idx][0][0] = 1;
	REP(i, N, 0) {
		_idx = idx;
		idx = (idx+1)%2;
		memset(dp[idx], 0, sizeof(dp[idx]));
		REP(j, i+2, 0) {
			REP(k, 2501, 0) {
				dp[idx][j][k] = dp[_idx][j][k];
				if (j > 0 && k >= X[i]) dp[idx][j][k] += dp[_idx][j-1][k-X[i]];
			}
		}
	}
	LL res = 0;
	REP(i, N+1, 1) res += dp[idx][i][A*i];
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 2304
S=list(input())
N=len(S)
dp=[[0]*13 for i in range(N+1)]
dp[0][0]=1
mod=10**9+7
for i in range(1,N+1):
  for j in range(13):
    if dp[i-1][j]>0:
      if S[i-1]=="?":
        for k in range(10):
          dp[i][(j*10+k)%13]+=dp[i-1][j]
          dp[i][(j*10+k)%13]%=mod
      else:
        dp[i][(j*10+int(S[i-1]))%13]+=dp[i-1][j]
        dp[i][(j*10+int(S[i-1]))%13]%=mod
print(dp[N][5])


         
        
      
    


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

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

    string s;
    cin >> s;

    int ans = 1;
    char last = s[0];
    for (int i = 1; i < n; i++){
        if (s[i] != last){
            last = s[i];
            ans += 1;
        }
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<pair<ll,ll> > vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
  string s;cin>>s;
  vin a(4);
  rep(i,0,4){
    a[i]=s[i]-'0';
  }
  rep(i,0,1<<3){
    int tmp=a[0];
    rep(j,0,3){
      if(i>>j&1){tmp-=a[j+1];}
      else{tmp+=a[j+1];}
    }
    if(tmp==7){
      cout<<a[0];
      rep(j,0,3){
        if(i>>j&1){cout<<"-"<<a[j+1];}
        else{cout<<"+"<<a[j+1];}
      }
      cout<<"=7"<<endl;
      break;
    }
  }
}



Measured memory_bytes: 256
a, b = map(int, input().split())
ans = 0

for i in range(1270):
  x = i * 8
  y = x / 100
  z = i * 10
  q = z / 100
  if a == int(y) and b == int(q):
    if ans == 0:
      ans = i
    else:
      ans = min(ans, i)

if ans == 0:
  print(-1)
else:
  print(ans)

Measured memory_bytes: 9108
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		String code = sc.next();

		System.out.println(isCorrectPostalCode(code, A, B));

	}

	public static String isCorrectPostalCode(String code, int A, int B) {

		char[] codes = code.toCharArray();
		if (codes[A] != '-') {
			return "No";
		}

		String[] postalCodeList = code.split("-", 0);
		if (postalCodeList.length != 2) {
			return "No";
		}
		if (postalCodeList[0].length() != A || postalCodeList[1].length() != B) {
			return "No";
		}

		return "Yes";
	}
}


Measured memory_bytes: 21972
#include<iostream>
#include<string>
using namespace std;
 
int main(){
	long long int n;
	int mod=1000000007;
	int cnt=0;
	cin>>n;
	long long f[n+1]={};
	for(int i=2;i<=n;i++){
		int a=i;
		for(int j=2;j<=a;j++){
			while(a%j==0){
				f[j]++;
				a/=j;
			}
		}
	}
	long long int ans=1;
	for(int i=2;i<=n;i++){
		ans*=(f[i]+1);
		ans%=mod;
	}
			
	cout<<ans<<endl;
			
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef vector<LL> VLL;
typedef complex<double> P;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define MT(a,b,c) MP(a, MP(b, c))
#define T1 first
#define T2 second.first
#define T3 second.second

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EPS 1.0e-9

typedef VVI mat;

void matmul(mat a, mat b, mat &ret, int m){
	int n=a.size();
	mat r = VVI(n, VI(n,0));
	REP(i,n){
		REP(j,n){
			REP(k,n)r[i][j] += a[i][k]*b[k][j];
			r[i][j]%=m;
		}
	}
	ret = r;
}

void matpow(mat a, mat &r, int p, int m){
	int n=a.size();
	mat tmp = a;
	mat rtmp = mat(n, VI(n,0));
	REP(i,n)rtmp[i][i]=1;
	while(p){
		if(p&1)matmul(tmp, rtmp, rtmp, m);
		p>>=1;
		matmul(tmp, tmp, tmp, m);
	}
	r = rtmp;
}

int main(){
	int n,m,a[3],t, s[55];

	while(cin>>n>>m>>a[0]>>a[1]>>a[2]>>t,n){
		mat _mat(n, VI(n, 0));
		REP(i,n){
			FOR(j, -1, 2){
				if(i+j>=0 && n>i+j){
					_mat[i][i+j]=a[j+1];
				}
			}
		}
		matpow(_mat, _mat, t, m);
		REP(i,n)cin>>s[i];
		REP(i,n){
			int tmp = 0;
			REP(j,n){
				tmp+=_mat[i][j]*s[j];
			}
			if(i!=0)cout << " ";
			cout << tmp%m;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1324
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 998244353;

ll quick_mod(ll a, ll b, ll mod)
{
    ll res = 1;
    while (b) {
        if (b % 2)
            res = res * a % mod;
        b >>= 1;
        a = a * a % mod;
    }
    return res;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	int x;
	cin >> x;
	if (x == 0) {
		a[0]++;
		for (int i = 1; i < n; i++) {
			cin >> x;
			a[x]++;
		}
		int sup;
		for (int i = n - 1; i >= 0; i--) {
			if (a[i]) {
				sup = i;
				break;
			}
		}
		ll ans = 1;
		if (a[0] == 1) {
			for (int i = 1; i < sup; i++) {
				ans *= quick_mod(a[i], a[i + 1], MOD);
				ans %= MOD;
			}
		} else
			ans = 0;
		cout << ans;
	} else 
		cout << 0;
	return 0;
}

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

int main() {
  int N, a, b, c;
  cin >> N;
  a = 0;
  b = 0;
  c = 0;
  vector<int> A(N), C(N);

  for (int i = 0; i < N; i++){
    cin >> C.at(i);
  }
  for (int i = 0; i < N; i++){
    for (int j = 0; j < N; j++){
      if (A.at(i) < C.at(j)){
        A.at(i) = C.at(j);
        c = j;
      }
    }
    C.at(c) = 0;
  }
  for (int i = 0; i < N; i++){
    if (i % 2 == 0){
      a += A.at(i);
    }
    else {
      b += A.at(i);
    }
  }
  cout << a - b << endl;
}


Measured memory_bytes: 764
import copy
H, W = list(map(int, input().split()))
tb = []
for h in range(H+2):
    line = []
    if h == 0 or h == H+2-1:
        for w in range(W+2):
            line.append(0)
    else:
        line = list("." + input() + ".")
        for w in range(W+2):
            if line[w] == ".":
                line[w] = 0
    tb.append(line)
#def xxx(): [print("".join(list(map(str,line)))) for line in tb];print()
#xxx()


for i in range(1,H+1):
    for j in range(1,W+1):
        if tb[i][j] != "#":
            if tb[i-1][j] == "#": tb[i][j] += 1
            if tb[i+1][j] == "#": tb[i][j] += 1
            if tb[i][j-1] == "#": tb[i][j] += 1
            if tb[i][j+1] == "#": tb[i][j] += 1
            if tb[i-1][j-1] == "#": tb[i][j] += 1
            if tb[i-1][j+1] == "#": tb[i][j] += 1
            if tb[i+1][j-1] == "#": tb[i][j] += 1
            if tb[i+1][j+1] == "#": tb[i][j] += 1

#xxx()
[print("".join(list(map(str,line)))[1:-1]) for i,line in enumerate(tb) if 0 < i < H+2-1];print()

Measured memory_bytes: 9364
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = a; i <= b; i++)

#include <iostream>
#include <set>

using namespace std;

int main()
{
    set<int> set;
    rep(i, 0, 3) {
        int in; cin >> in;
        set.insert(in);
    }
    cout << set.size() << endl;
}

Measured memory_bytes: 256
N = int(input())
msg = [[] for _ in range(N)]
for i in range(N):
    ai = int(input())
    for _ in range(ai):
        x, y = map(int, input().split())
        msg[i].append([x - 1, y])

ans = 0
for i in range(1, 2 ** N):
    is_ok = True
    for j in range(N):
        if (i >> j) & 1 == 1:
            for x, y in msg[j]:
                if (i >> x) & 1 != y:
                    is_ok = False
                    break
    if is_ok:
        ans = max(ans, bin(i)[2:].count('1'))
print(ans)

Measured memory_bytes: 44140
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define M_PI acos(-1)
vector<int> cnt[101];
main()
{
   string s;
   int k,t;
   cin>>k>>t;

   for (int i=0;i<t;i++){
        int a;
        cin>>a;
        cnt[a].push_back(i);
   }
   int l = k;
   int ans = 0;
   int last = -1;
   while(l>0){
   bool good = false;
    for (int i=100;i>0;i--){
        for (int j=0;j<cnt[i].size();j++)
            if (cnt[i][j]!=last){
                last = cnt[i][j];
                if (i>0){
                    cnt[i-1].push_back(cnt[i][j]);
                }
                swap(cnt[i][j], cnt[i][cnt[i].size()-1]);
                cnt[i].pop_back();
                good = true;l--;
                break;
            }
        if (good) break;
            }

        if (!good)
    for (int i=100;i>0;i--){
        for (int j=0;j<cnt[i].size();j++)
            {
                last = cnt[i][j];
                if (i>0){
                    cnt[i-1].push_back(cnt[i][j]);
                }
                swap(cnt[i][j], cnt[i][cnt[i].size()-1]);
                cnt[i].pop_back();
                ans++;
                good = true;l--;
                break;
            }
        if (good) break;
        }
   }
   cout<<ans<<endl;;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long n,a,b;
  cin >> n >> a >> b;
  long ans = 0;
  ans += (n/(a+b)) * a;
  n %= (a+b);
  if(n>=a)ans+=a;
  else ans+=n;
  cout<<ans<<endl;
}


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

const int MAXN = 5e5 + 10;
 
int n, k, cnt, arr[MAXN], bit[MAXN], newarr[MAXN];
int answer[MAXN];
pair<int, int> seg[4 * MAXN];
int lazy[4 * MAXN];
 
void bit_upt(int id, int val)
{
	for (; id < MAXN; id += id & (-id))
		bit[id] += val;
	return;
}
 
int bit_get(int id)
{
	int res = 0;
	for (; id; id &= id - 1)
		res += bit[id];
	return res;
}
 
pair<int, int> cmp(pair<int, int> l, pair<int, int> r)
{
	if (l.first < r.first)
		return l;
	return r;
}
 
void build(int l = 1, int r = n + 1, int id = 1)
{
	if ((r - 1) == l)
	{
		seg[id] = {newarr[l], l};
		return;
	}
	int mid = l + r >> 1;
	build(l, mid, id << 1);
	build(mid, r, id << 1 | 1);
	seg[id] = cmp(seg[id << 1], seg[id << 1 | 1]);
	return;
}
 
void assign(int g, int l = 1, int r = n + 1, int id = 1)
{
	if (l == (r - 1))
	{
		seg[id] = {1e9 - lazy[id], l};
		return;
	}
	int mid = l + r >> 1;
	if (g < mid)
		assign(g, l, mid, id << 1);
	else
		assign(g, mid, r, id << 1 | 1);
	seg[id] = cmp(seg[id << 1], seg[id << 1 | 1]);
	seg[id].first -= lazy[id];
	return;
}
 
void upt(int s, int e, int l = 1, int r = n + 1, int id = 1)
{
	if (l >= s && r <= e)
	{
		lazy[id]++;
		seg[id].first--;
		return;
	}
	if (l >= e || r <= s)
		return;
	int mid = l + r >> 1;
	upt(s, e, l, mid, id << 1);
	upt(s, e, mid, r, id << 1 | 1);
	seg[id] = cmp(seg[id << 1], seg[id << 1 | 1]);
	seg[id].first -= lazy[id];
	return;
}
 
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
	{
		cin >> arr[i];
	}
	k--;
	for (int i = 1; i <= k; i++)
	{
		bit_upt(arr[i], 1);
		cnt++;
	}
	for (int i = 1; i <= n; i++)
	{
		if ((i + k) <= n)
		{
			bit_upt(arr[i + k], 1);
			cnt++;
		}
		if ((i - k - 1) >= 1)
		{
			bit_upt(arr[i - k - 1], -1);
			cnt--;
		}
		newarr[i] = cnt - bit_get(arr[i]);
	}
	build();
	for (int i = n; i; i--)
	{
		int id = seg[1].second;
		answer[id] = i;
		assign(id);
		upt(max(1, id - k), min(n, id + k) + 1);
	}
	for (int i = 1; i <= n; i++)
		cout << answer[i] << '\n';
	return 0;
}

Measured memory_bytes: 28672
import math
def prime_numbers(x):
    if x < 2:
        return []
    prime_numbers = [i for i in range(x)]
    prime_numbers[1] = 0
    for prime_number in prime_numbers:
        if prime_number > math.sqrt(x):
            break
        if prime_number == 0:
            continue
        for composite_number in range(2 * prime_number, x, prime_number):
            prime_numbers[composite_number] = 0
    return [prime_number for prime_number in prime_numbers if prime_number != 0]
def soinnsuu(x):
    s = set()
    for i in primes:
        if i > int(math.sqrt(x)):
            break
        elif x % i == 0:
            while x % i == 0:
                x //= i
            s.add(i)
    if not x == 1:
        s.add(x)
    return s
from math import gcd
n = int(input())
a = list(map(int, input().split()))
g = 0
for i in range(n):
    g = gcd(g, a[i])
primes = prime_numbers(2000000)
cur = soinnsuu(a[0])
f = False
for i in range(1, n):
    s2 = soinnsuu(a[i])
    if len(cur & s2) >= 1:
        f = True
        break
    cur |= s2
if not f:
    print("pairwise coprime")
elif g == 1:
    print("setwise coprime")
else:
    print("not coprime")

Measured memory_bytes: 239640