akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long int;

int main(void) {
	int a, b, t;
	cin >> a >> b >> t;
	int ret = 0;
	ret = int((t + 0.5) / a) * b;
	cout << ret << endl;
	return 0;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int ans = (h2 * 60 + m2) - (h1 * 60 + m1) - k;
  if (ans < 0) ans = 0;
  cout << ans << endl;
}

Measured memory_bytes: 3648
N, x = map(int, input().split())
a = [int(i) for i in input().split()]

res = 0
if x == sum(a):
  res = N
elif x > sum(a):
  res = N -1
else:
  a.sort()
  while x > 0:
    if x >= a[0]: res += 1
    x -= a.pop(0)

print(res)

Measured memory_bytes: 9092
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
using namespace std;
signed main(){
    int x,y,z;
    cin >> x >> y >> z;
    x -= z;
    y += z;
    cout << x/y << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
const int M=100010;
int INF=1000000007;
using ll=long long;

int main(){
	int n,m;
	ll ans=1;
	cin>>n>>m;
	if(abs(n-m)>1){
		cout<<"0"<<endl;
		return 0;
	}
	else if(n==m){
		ans*=2;
		rep(i,1,n+1)ans=((ans*i)%INF*i)%INF;
	}else{
		rep(i,1,n+1)ans=(ans*i)%INF;
		rep(i,1,m+1)ans=(ans*i)%INF;
	}
	cout<<ans<<endl;

}

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

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

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

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

    int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty; 
    string ans;

    REP(i, tx-sx) ans.pb('R');
    REP(i, ty-sy) ans.pb('U');
    REP(i, tx-sx) ans.pb('L');
    REP(i, ty-sy) ans.pb('D');

    ans.pb('D');
    REP(i, tx-sx+1) ans.pb('R');
    REP(i, ty-sy+1) ans.pb('U');
    ans.pb('L');
    ans.pb('U');
    REP(i, tx-sx+1) ans.pb('L');
    REP(i, ty-sy+1) ans.pb('D');
    ans.pb('R');
    
    cout << ans << endl;
}

Measured memory_bytes: 3648
#include <stdio.h>
int i,j,N;
int count=0;

void Process(int A[ ], int n){
	for(i=0;i<n-1;i++)
		printf("%d ",A[i]);
	printf("%d\n",A[i]);
}



void BubbleSort(int A[ ], int n){
	int j,temp;
		for(i = 0; i < N-1; i++){
			for(j = N-1; j > i; j--)
			if(A[j-1] > A[j]){
				temp = A[j-1];
				A[j-1] = A[j];
				A[j] = temp;
				count++;
			}
			
	}
	

	/*int j,temp,flag;
	j=0;
	do{
		flag=0;
		for(i=0;i<n-1-j;i++)
			if(A[i]>A[i+1]){
				flag=1;
				temp = A[i];
				A[j] = A[i+1];
				A[i+1] = temp;
			}
			j++;
	}while(flag == 1);*/
}



int main(void){
	scanf("%d",&N);
	int A[100];
	for(i=0;i<N;i++)
		scanf("%d",&A[i]);
	
	BubbleSort(A, N);
	Process(A, N);

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


}

Measured memory_bytes: 1812
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    string s;
    cin >> s;
    int n = s.size();
    reverse(s.begin(), s.end());
    vector<ll> ten(n + 1, 1);
    for (int i = 2; i <= n; i++)
    {
        ten[i] = ten[i - 1] * 10 % 13;
    }
    vector<vector<ll>> dp(n + 1, vector<ll>(13, 0));
    dp[0][0] = 1;
    for (int i = 0; i < n; i++)
    {
        if (s[i] != '?')
        {
            int k = s[i] - '0';
            for (int j = 0; j < 13; j++)
            {
                dp[i + 1][(j + k * ten[i + 1]) % 13] += dp[i][j];
                dp[i + 1][(j + k * ten[i + 1]) % 13] %= MOD;
            }
            continue;
        }
        for (int j = 0; j < 13; j++)
        {
            for (int k = 0; k <= 9; k++)
            {
                dp[i + 1][(j + k * ten[i + 1]) % 13] += dp[i][j];
                dp[i + 1][(j + k * ten[i + 1]) % 13] %= MOD;
            }
        }
    }
    cout << dp[n][5] << endl;
}


Measured memory_bytes: 14416
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;


vi binary_exp(ll a){
  vi ans(50);
  for (int i=0;i<50;++i){
    ans[i]=(a>>i)&1;
  }
  return ans;
}

int main(){
  int N;cin>>N;ll K;cin>>K;
  vi counter(50,0);
  vll A;
  for (int i=0;i<N;++i){
    ll a;cin>>a;vi ab=binary_exp(a);A.push_back(a);
    for (int j=0;j<50;++j) counter[j]+=ab[j];
  }

  vi vote(50,0);
  for (int i=0;i<50;++i){
    if((N&1)&&counter[i]==N/2) vote[i]=1;
    if(counter[i]<N/2) vote[i]=1;
  }

  vi Kb=binary_exp(K);

  ll X=0;
  int flag=1;
  for (int i=49;i>=0;--i){
    if(flag==1&&Kb[i]==1&&vote[i]==1) X+=(ll)pow(2,i);
    if(flag==1&&Kb[i]==1&&vote[i]==0) flag=0;
    if(flag==0&&vote[i]==1) X+=(ll)pow(2,i);
  }

  ll ans=0;
  for (int i=0;i<N;++i){
    ans+=X^A[i];
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
///////////////////////////////////////////////////////////////////////////////////////////////////////////
#define endl "\n"
#define ll long long
#define out(x)  cout<<x<<"\n"
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,n) for(i=1;i<=n;i++)
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.1415926535897932384626
typedef pair<int, int>  pii;
typedef pair<long long, long long>  pl;
typedef vector<int>     vi;
typedef vector<long long>       vl;
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////////////////////////////////////////////////////////////////////////////////////
// <<,


int main(){
   /* #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
// <<,

    ll t=1;
    //cin>>t;
    while(t--)
    {   
        ll a;
        ll b;
        cin>>a>>b;
        cout<<a*b<<endl;
    }
    return 0;
}// <<,



Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int N;
string S;
pair<int, pair<string, string>> lef[1 << 18], righ[1 << 18];

signed main() {
    cin >> N >> S;
    for (int i = 0; i < (1 << N); ++i) {
        int num = 0;
        string a, b;
        rep(j, N) {
            if (i & (1 << j)) {
                num++;
                a.push_back(S[j]);
            } else b.push_back(S[j]);
        }
        lef[i] = make_pair(num, make_pair(a, b));
    }

    for (int i = 0; i < (1 << N); ++i) {
        int num = 0;
        string a, b;
        rep(j, N) {
            if (i & (1 << j)) {
                num++;
                a.push_back(S[2 * N - 1 - j]);
            } else b.push_back(S[2 * N - 1 - j]);
        }
        righ[i] = make_pair(num, make_pair(a, b));
    }

    sort(lef, lef + (1 << N));
    sort(righ, righ + (1 << N));

    int ans = 0;
    rep(i, 1 << N) {
        ans += u_b(righ, righ + (1 << N), lef[i]) - l_b(righ, righ + (1 << N), lef[i]);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 73472
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
 
#define print(a) {for(auto xxxxx : (a)) cout << xxxxx << ' '; cout << '\n';}
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
 
ll next(){ll x; cin >> x; return x;}
const int maxn = 50 + 3, intf = 2e9;
const ll inf = 2e18, mod = 998244353;
const ld eps = 1e-6;
 
#define int ll

struct edge{
	int to , a , b;
};
 
int n , m;
vector <edge> g[maxn];
int c[maxn], d[maxn];
const int C = 5000;
ll dp[maxn][C];
 
int F(int x){
	return min(C - 1 , x);
}
 
void solve(){
	int S;
	cin >> n >> m >> S;
 
	for (int i = 0; i < m ; i ++){
		int u , v , a , b;
		cin >> u >> v >> a >> b;
		u-- , v--;
		g[u].pb({v , a , b});
		g[v].pb({u , a , b});
	}
 
	for (int i = 0; i < n; i ++){
		cin >> c[i] >> d[i];
	}
 
	for (int i = 0; i < n; i ++){
		for (int j = 0; j < C; j ++){
			dp[i][j] = inf;
		}
	}
 
	dp[0][F(S)] = 0;
 
	for (int I = 0; I < 2*n; I ++){
 
		for (int i = 0; i < n; i ++){
			for (auto t : g[i]){
				for (int j = 0; j < C; j ++){
					if (t.a > j)
						continue;
 
					dp[t.to][j - t.a] = min(dp[t.to][j - t.a] , dp[i][j] + t.b);
				}
			}
		}
 
		for (int i = 0; i < n; i ++){
			for (int j = 0; j < C; j ++){
				if (j - c[i] < 0)
					continue;
 
				dp[i][j] = min(dp[i][j] , dp[i][j - c[i]] + d[i]);
			}
		}
 
	}
 
	for (int i = 1; i < n; i ++){
		ll ans = inf;
		for (int j = 0; j < C;  j ++){
			ans = min(ans , dp[i][j]);
		}
 
		cout << ans << '\n';
	}
}
 
 
signed main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.precision(20);
    
    for (int t = 1; t--;) {
    	solve();
    }
 
	return 0;
}
/*
 
 
*/

Measured memory_bytes: 5584
input()
A=[0]+list(map(int,input().split()))
H=len(A)
def h(i):
 l=2*i;r,g=l+1,[i,l][l<H and A[i]<A[l]]
 if r<H and A[g]<A[r]:g=r
 if g!=i:A[i],A[g]=A[g],A[i];h(g)
for i in range(H//2,0,-1):h(i)
print(' '+' '.join(map(str,A[1:])))


Measured memory_bytes: 64180
/* ITP1_7_B: How many ways? */

#include <iostream>

int solve(int n, int x) {
    int n_combis = 0;
    for (int a = 1; a <= n; a++) {
        for (int b = a + 1; b <= n; b++) {
            for (int c = b + 1; c <= n; c++) {
                if (a + b + c == x) {
                    n_combis++;
                }
            }
        }
    }
    return n_combis;
}


int main() {
    int n, x;
    while (true) {
        std::cin >> n >> x;
        if (n == 0 && x == 0) {
            break;
        }
        std::cout << solve(n, x) << std::endl;

    }
    return 0;
}

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

const int N = 3 * 1000 + 10;

int n;
int val[N];
vector <int> adj[N];
bool mark[N], isGood[N];

void input() {
    cin >> n;

    for (int i = 0; i < n; i++)
        cin >> val[i];

    for (int i = 0; i < n - 1; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        if (val[v] > val[u])
            adj[v].push_back(u);
        else if (val[v] < val[u])
            adj[u].push_back(v);
    }
    return;
}

void DFS(int v) {
    mark[v] = true;

    bool tmp = true;
    for (auto u : adj[v]) {
        if (!mark[u])
            DFS(u);
        tmp &= isGood[u];
    }

    isGood[v] = !tmp;
    return;
}

void output() {
    for (int i = 0; i < n; i++)
        if (isGood[i])
            cout << i + 1 << " ";
    return;
}

int main() {
    input();

    for (int i = 0; i < n; i++)
        if (!mark[i])
            DFS(i);

    output();
    return 0;
}


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

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const long long mod = 1000000007;
// auto mod int
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

int main(){
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    mint ans = 0;
    rep(i, n) ans += a[i];
    ans *= ans;
    rep(i, n) ans -= (ll)a[i] * a[i];
    ans /= 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3996
#include <cstring>
#include <algorithm>
#include <map>
#include <stack>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <vector>
#include <iostream>
#include <set>
#define MP make_pair
#define F first
#define PB push_back
#define S second
using namespace std;
typedef long long ll;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef unsigned long long ull;
const int maxn = 2e5 + 5;
const int mod = 1e9 + 7;
const ull inf = (1ull << 64) - 1;
const int block = 700;

ull par[maxn], x[maxn], ans[maxn], num[maxn];

ull sq (ull x) { return x * x; }

int main() {
    ios_base::sync_with_stdio (false);
    ull n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> x[i];
        par[i] = par[i - 1] + x[i];
    }

    ull Min = inf;
    for (ll num = 1; num <= n; num++) {
        ull ted = num, last = 1;
        ull ans = (num + n) * k;
        for (int i = n; i >= 1; i -= num, last ++) {
            if (last != 1)
                ans += (sq (last + 1) - sq (last)) * (par[i] - par[max (i - num, 0ll)]);
            else {
                ans += (sq (last + 1) + 1) * (par[i] - par[max (i - num, 0ll)]);;
            }
            if (ans >= Min)
                break;
        }
        Min = min (Min, ans);
    }
    cout << Min << endl;
}

Measured memory_bytes: 4480
#include "bits/stdc++.h"

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define P3(a, b, c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main(){
    ll N,x;
    cin >> N >> x;
    vector<ll> A(N);
    REP(i,0,N){
        cin >> A[i];
    }  

    ll rest,ans=0;
    REP(i,0,N-1){
        if(x<A[i]+A[i+1]){
            rest=A[i]+A[i+1]-x;
            if(rest>A[i+1]){
                rest-=A[i+1];
                ans+=A[i+1];
                A[i+1]=0;
            }else{
                A[i+1]-=rest;
                ans+=rest;
                rest=0;
            }
            ans+=rest;
        }
    }
    P(ans);
}

Measured memory_bytes: 1024
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::Integer;
#[allow(unused_imports)]
use proconio::derive_readable;
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp;

#[fastout]
fn main() {
  input! {
    a: i32,
    b: i32,
  }

  println!("{}", a * b);
}


Measured memory_bytes: 2200
#include<cstdio>
#include<iostream>
#include<cmath>
#include<complex>
#include<string>
#include<map>
using namespace std;
typedef complex<double> xy_t;
double x[4],y[4];

int main(){

  while(true){
    for(int i=0;i<4;i++) cin >> x[i] >> y[i];
    if(!cin) break;
    xy_t a(x[0],y[0]),b(x[1],y[1]),c(x[2],y[2]),p(x[3],y[3]);
    double pab=(conj(a-p)*(b-p)).imag();
    double pbc=(conj(b-p)*(c-p)).imag();
    double pca=(conj(c-p)*(a-p)).imag();
    bool ok= (pab>0 && pbc>0 && pca>0) || (pab<0 && pbc<0 && pca<0);
    cout << (ok ? "YES" : "NO") << endl;
  }


  return 0;

}

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


void solve(long long a, long long b, long long x){
    ll cnt = 0;
    //* first move a to smallest kx>=a
    if(a %x !=0) {
        a = (a/x+1)*x;
        if(a <=b) cnt ++;
    }
    else cnt++;
    cnt += (b-a)/x;
    cout << cnt << endl;
}

int main(){
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    long long x;
    scanf("%lld",&x);
    solve(a, b, x);
    return 0;
}


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

using namespace std;

int calc500(double record){
	if(record < 35.50){
		return 7;
	}else if(record < 37.50){
		return 6;
	}else if(record < 40.0){
		return 5;
	}else if(record < 43.0){
		return 4;
	}else if(record < 50.0){
		return 3;
	}else if(record < 55.0){
		return 2;
	}else if(record < 70.0){
		return 1;
	}else{
		return 0;
	}
}

int calc1000(double record){
	if(record < 71.0){
		return 7;
	}else if(record < 77.0){
		return 6;
	}else if(record < 83.0){
		return 5;
	}else if(record < 89.0){
		return 4;
	}else if(record < 105.0){
		return 3;
	}else if(record < 116.0){
		return 2;
	}else if(record < 148.0){
		return 1;
	}else{
		return 0;
	}
}

int main(){

	double t_500,t_1000;
	int rank500,rank1000,rank;

	while(scanf("%lf %lf",&t_500,&t_1000)!=EOF){
		rank500 = calc500(t_500);
		rank1000 = calc1000(t_1000);
		rank = min(rank500,rank1000);

		switch(rank){
		case 7:
			printf("AAA\n");
			break;
		case 6:
			printf("AA\n");
			break;
		case 5:
			printf("A\n");
			break;
		case 4:
			printf("B\n");
			break;
		case 3:
			printf("C\n");
			break;
		case 2:
			printf("D\n");
			break;
		case 1:
			printf("E\n");
			break;
		case 0:
			printf("NA\n");
			break;
		}
	}

    return 0;
}



Measured memory_bytes: 2664
let n = read_int ()
let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun i -> i))
let m = Array.fold_left (fun i j -> max i j) 0 a
let check = Array.make (m + 1) false

let d = Array.make (m + 1) 0

let rec pre i =
  if i <= m then (
    if d.(i) = 0 then (
      let rec sieve j =
        let k =  i * j in
        if k <= m then (
          d.(k) <- i;
          sieve (j + 1)
        ) in
      sieve 1;
    );
    pre (i + 1)
  )


let rec solve i =
  if i = n then "pairwise coprime"
  else (
    let rec f a =
      if a > 1 then (
        let p = d.(a) in
        if check.(p) then true
        else (
          check.(p) <- true;
          let rec g a p =
            let r = a mod p in
            if r = 0 then g (a / p) p
            else a in
          f (g a p)
        )
      ) else false in
    if f a.(i) then "setwise coprime"
    else solve (i + 1)
  )

let rec gcd a b =
  let r = a mod b in
  if r = 0 then b
  else gcd b r

let gcd a = Array.fold_left (fun i j -> gcd i j) a.(0) a

let () =
  let g = gcd a in
  let ans =
    if g > 1 then "not coprime"
    else (
      pre 2;
      solve 0
    ) in
  Printf.printf "%s\n" ans


Measured memory_bytes: 29576
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define MOD 1000000007
#define endl "\n" 
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;


int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
  
    int n; cin >> n;
    while(n) {
        if(n%10 == 7) {
            cout << "Yes" << endl;
            return 0;
        }
        n /= 10;
    }

    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3608
#!/usr/bin/env python3
import sys
import collections as cl


def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def LI(): return list(map(int, sys.stdin.readline().split()))


def main():
    S = input()
    N  = len(S)
    
    for i in range(N):
        if S[i] != S[N-i-1]:
            print("No")
            exit()
    half = int((N-1)/2)
    for i in range(half):
        if S[i] != S[half-i-1]:
            print("No")
            exit()
            
    for i in range(half+2,N):
        if S[i] != S[N-i-1]:
            print("No")
            exit()
        
    print("Yes")
    


main()


Measured memory_bytes: 64904
#include <algorithm>
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main()
{
    string S;
    cin >> S;
    map<char, bool> charExists;
    for (char ch = 'a'; ch <= 'z'; ++ch)
    {
        charExists[ch] = false;
    }
    for (const char ch : S)
    {
        charExists[ch] = true;
    }
    for (char ch = 'a'; ch <= 'z'; ++ch)
    {
        if (!charExists[ch])
        {
            cout << ch << endl;
            return 0;
        }
    }
    cout << "None" << endl;

    return 0;
}

Measured memory_bytes: 512
MOD = 2019
L,R = list(map(int,input().split()))
R = min(R, L + MOD)
nums = range(L,R+1)
answer = MOD
for i in range(L,R+1):
    for j in range(max(i+1,L), R+1):
        c = (i*j)%MOD
        # if c < answer:
            # print(c,i,j)
        answer = min(c,answer)
print(answer)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define INF 1e9
#define eps 1e-6
typedef long long ll;
using namespace std;

int n, k, a[200010];

int main(){

	cin >> n >> k;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	for(int i = k + 1; i <= n; i++){
		if(a[i] > a[i - k])
			puts("Yes");
		else
			puts("No");
	}	

	return 0;
}


Measured memory_bytes: 4328
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <string>
#include <set>
#include <sstream>
#include <algorithm>
#include <fstream>
#include <deque>
using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int, int>
#define f first
#define s second
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()

const int inf = (int)1e9;
const int mod = inf+7;

ll x, a, b;

int main(){

	cin >> x >> a >> b;
	int t = b-a;
	if(t<=0) {
		printf("delicious\n");
		return 0;
	}
	if(t<=x) {
		printf("safe\n");
		return 0;
	}
	printf("dangerous\n");


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,m,k;
cin>>n>>m>>k;
int rt[n],rt1[m];
int mto(10000000),mto1(10000000);
for(int i=0; i<n; ++i)
{
cin>>rt[i];
mto=min(mto,rt[i]);
}
for(int i=0; i<m; ++i)
{
cin>>rt1[i];
mto1=min(mto1,rt1[i]);
}
int rtu1[k],sumi(mto+mto1);
for(int i=0; i<k; ++i)
{
int o,l,t;
cin>>o>>l>>t;
sumi=min(sumi,rt[o-1]+rt1[l-1]-t);
}
cout<<sumi;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

ll gcd(ll a, ll b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}

const int INF = 1<<30;

int main(){
  int n,m; cin >> n >> m;
  vector<int> dp(1<<n,INF);
  vector<pair<int,int>> key;
  rep(i,m){
    int a,b; cin >> a >> b;
    int s = 0;
    rep(j,b){
      int c; cin >> c;
      c--;
      s |= 1 << c;
    }
    key.push_back({s,a});
  }
  
  dp[0] = 0;
  
  rep(s,1<<n){
    rep(i,m){
      int t = s | key[i].first;
      chmin(dp[t],dp[s]+key[i].second);
    }
  }
  
  int ans = dp[(1<<n)-1];
  
  if(ans == INF) ans = -1;
  cout << ans << endl;
  
  return 0;
}

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

int main() {
  string a, s, c;
  cin >> a >> s >> c;
  cout << a[0] << s[0] << c[0] << endl;
  return 0;
}

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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<ll> a(N), b(N);
  for (int i = 0; i < N; i++)
    cin >> a[i];
  for (int i = 0; i < N; i++)
    cin >> b[i];
  ll cnt1 = 0, cnt2 = 0;
  for (int i = 0; i < N; i++)
  {
    cnt1 += max(0LL, (a[i] - b[i]));
    cnt2 += max(0LL, (b[i] - a[i]) / 2);
  }
  if (cnt1 <= cnt2)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 384
#D問題
N,K=map(int,input().split())
S=str(input())
Slist=list(S)
#偶数が”1”
hu=[]
ima=""
imal=0
for i in range(N):
    if i == 0:
        ima=Slist[0]
        imal=1
        if Slist[0] == "0":
            hu.append(0)
    else:
        if ima==Slist[i]:
            imal+=1
        else:
            hu.append(imal)
            ima=Slist[i]
            imal=1
hu.append(imal)
Ngu=len(hu)
rui=[0]
for i in range(Ngu):
    if i == 0:
        rui.append(hu[0])
    else:
        karui=rui[i]+hu[i]
        rui.append(karui)

        
MAX=0

for i in range(Ngu+1):
    if i%2==0:
        if 2*K+i-1<Ngu+1:
            if i > 0:
                kari=rui[2*K+i-1]-rui[i-1]
            else:
                kari=rui[2*K+i-1]
        else:
            if i > 0:
                kari=rui[-1]-rui[i-1]
            else:
                kari=rui[-1]
    else:
        if 2*K+i<Ngu+1:
            if i > 0:
                kari=rui[2*K+i]-rui[i-1]
            else:
                kari=rui[2*K+i]
        else:
            if i > 0:
                kari=rui[-1]-rui[i-1]
            else:
                kari=rui[-1]
    MAX=max(kari,MAX) 
print(MAX)
            

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

using namespace std;
char str[13];

int main() {
  //   freopen("in.txt", "rt", stdin);
    int n, m;
    scanf("%d %d", &n, &m);
    vector<pair<int, int>> vec;
    int a, b;
    for (int i = 0; i < n; ++i) {
        scanf("%d %d", &a, &b);
        vec.push_back({b, a});
    }
    sort(vec.rbegin(), vec.rend());
    set<int> st;
    for (int i = 1; i <= m; ++i) {
        st.insert(i);
    }
    int ans = 0;
    for (auto j:vec) {
        a = j.second, b = j.first;
        auto it = st.upper_bound(m - a+1);
        if (it == st.begin()) continue;
        --it;
        ans += b;
        st.erase(it);
    }
    printf("%d", ans);
}

Measured memory_bytes: 5748
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int n = in.nextInt();  // Scanner has functions to read ints, longs, strings, chars, etc.
        int k = in.nextInt();
        int answer;
        if (k==1)
        {
            answer = 0;
        } else {
            answer = n-k;
        }
        System.out.println(answer);
    }
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a[12],i,j;bool f=true;
  for(i=0;i<12;i++)cin>>a[i];sort(a,a+12);
  for(i=0;i<3;i++)for(j=0;j<3;j++) f&=(a[i*4+j]==a[i*4+j+1]);
  cout<<(f?"yes":"no")<<endl;
  return 0;
}

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

double T, A;
long N;
int i=0;

double absolute(double a) {
    return a >= 0 ? a : -a;
}

double temperature(long x) {
    return T - 0.006 * (double)x;
}

void solve(long* H) {
    double min_diff = absolute(temperature(H[0] - A));
    int best_pos = 0;

    for (i=0; i<N; i++) {
//        cout << temperature(i, H) << endl;
//        cout << abs(A - temperature(i, H)) << endl;
        if (min_diff > absolute(temperature(H[i]) - A)) {
            min_diff = absolute(temperature(H[i]) - A);
            best_pos = i;
        }
    }
    cout << best_pos + 1 << endl;
}

int main(void) {
    cin >> N;
    long H[N];
    cin >> T >> A;
    for (i=0; i<N; i++) {
        cin >> H[i];
    }
    solve(H);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------
ll N,C;
vector<ll> x(100100),v(100100);
vector<ll> A(100100),B(100100),D(100100),y(100100);


ll solve(){
  A[0] = v[0];
  for(int i=1; i<N; i++){
    A[i] = A[i-1] + v[i];
  }
  for(int i=0; i<N; i++){
    y[i] = C - x[i];
  }  
  B[N-1] = v[N-1];
  for(int i=N-2; i>=0; i--){
    B[i] = B[i+1] + v[i];
  }
  D[N-1] = B[N-1] - y[N-1];
  for(int i=N-2; i>=0; i--){
    D[i] = B[i] - y[i];
    chmax(D[i],D[i+1]);
  }
  ll ans = 0;
  for(int i=0; i<N; i++){
    ll sm = 0;
    sm -= x[i];
    sm += A[i];
    chmax(ans,sm);
    sm -= x[i];
    if(i < N-1){
      sm += D[i+1];
    }
    chmax(ans,sm);
  }
  return ans;
}

int main(){ 
  cin >> N >> C;
  rep(i,N){
    cin >> x[i] >> v[i];
  }
  ll ans = 0;
  chmax(ans,solve());
  reverse(v.begin(),v.begin()+N);
  rep(i,N){
    x[i] = C - x[i];
  }
  reverse(x.begin(),x.begin()+N);
  chmax(ans,solve());
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5120
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) std::memset(arg,n,sizeof(arg))
using std::cin;
using std::cout;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
const int INF=1e+9;
const ll INFLL=1e+17;
int M,K;
int pow2[30];
void make_pow2(){
  pow2[0]=1;
  rep1(i,20){
    pow2[i]=2*pow2[i-1];
  }
}
void solve(){
  make_pow2();
  if(pow2[M]<=K){
    prin(-1);
    return ;
  }
  if(M==1){
    if(K==0){
      cout<<0<<" "<<0<<" "<<1<<" "<<1<<"\n";
    }
    else prin(-1);
    return;
  }
  cout<<K<<" ";
  rep(i,pow2[M]) if(i!=K) cout<<i<<" ";
  cout<<K<<" ";
  rep(i,pow2[M]) if(pow2[M]-1-i!=K) cout<<pow2[M]-1-i<<" ";
  cout<<"\n";
}
int main(){
  cin>>M>>K;
  solve();
  return 0;
}


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

a = input().split()
for i in range(len(a)):
  a[i] = int(a[i])

if x not in a:
  print(x)
else:
  sa = 1
  while True:
    if x-sa not in a:
      print(x-sa)
      break
    if x+sa not in a:
      print(x+sa)
      break
    sa += 1


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

int main() {
  ios::sync_with_stdio(false);
  int X, Y, Z, K;
  cin >> X >> Y >> Z >> K;
  vector<long> A(X), B(Y), C(Z);
  for (auto &a : A) cin >> a;
  for (auto &b : B) cin >> b;
  for (auto &c : C) cin >> c;

  vector<long> AB;
  for (auto a : A) for (auto b : B) AB.push_back(a + b);
  sort(AB.rbegin(), AB.rend());

  vector<long> ABC;
  for (auto c : C) for (int i = 0; i < min(K, (int)AB.size()); i++) ABC.push_back(AB.at(i) + c);
  sort(ABC.rbegin(), ABC.rend());

  for (int i = 0; i < K; i++) cout << ABC.at(i) << "\n";
}

Measured memory_bytes: 43368
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
#define all(v) v.begin(),v.end()


ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}

int main(){
  string s;
  cin >> s;
  if(s=="ABC") cout << "ARC" <<endl;
  else cout << "ABC" <<endl;
  return 0;
}



Measured memory_bytes: 3600
using System;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c;
            string[] str;

            str = Console.ReadLine().Split(' ');
            a = int.Parse(str[0]);
            b = int.Parse(str[1]);
            c = int.Parse(str[2]);

            Console.WriteLine("{0}", func(a, b, c));
        }

        static int func(int a,int b,int c)
        {
            int ans = 0;
            for(int i = a; i <= b; i++)
            {
                if (c % i == 0)
                {
                    ans++;
                }
            }
            return ans;
        }
    }
}

Measured memory_bytes: 9184
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;

int N, R;

int main(void){
	cin >> N >> R;

	int res;
	if(N >= 10) res = R;
	else res = R + 100 * (10 - N);

	cout << res << '\n';

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<cmath>
using namespace std;
using Graph = vector<vector<int>>;
typedef unsigned long long ll;
ll mod = (10e+8)+ 7;

#define For(N,i) for(int i = 0; i < N; i++)
	
int main(){
	int A,B;
	cin>>A>>B;
	int cnt = 1;
	int cntt = 0;
	while(cnt < B){
		cnt+=(A-1);
		cntt++;
	}
	cout<<cntt<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  string s;
  cin >> s;
  bool found_c = false;
  bool found_f = false;
  for (int i = 0; i < s.length(); i++) {
    if (!found_f && s[i] == 'C') {
      found_c = true;
    }
    if (found_c && s[i] == 'F') {
      found_f = true;
    }
  }
  string ans = (found_c && found_f) ? "Yes" : "No";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3640
package main
 
import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)
 
func main() {
	sc.Split(bufio.ScanWords)
	N := nextInt()
	M := nextInt()
	ballCounts := make([]int, N)
	for i := 0; i < N; i++ {
		ballCounts[i] = 1
	}
	redCance := make([]bool, N)
	redCance[0] = true
	for i := 0; i < M; i++ {
		x := nextInt()
		y := nextInt()
		x -= 1
		y -= 1
		ballCounts[x]--
		ballCounts[y]++
		redCance[y] = redCance[x] || redCance[y]
		if ballCounts[x] == 0 {
			redCance[x] = false
		}
	}
 
	ans := 0
	for i := 0; i < N; i++ {
		if redCance[i] {
			ans++
		}
	}
	fmt.Println(ans)
}
 
var sc = bufio.NewScanner(os.Stdin)
 
func nextLine() string {
	sc.Scan()
	return sc.Text()
}
 
func nextInt() int {
	i, _ := strconv.Atoi(nextLine())
	return i
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,n,a) for(int i=n;i>=a;i--)
#define endl '\n'
#define mem(a) memset(a,0,sizeof(a))
#define IO ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
const int INF=0x3f3f3f3f;
const int mod=1e9+7;
const int maxn=2e5+5;
string a[maxn];
vector<string> q;
map<string,ll>mp;
int main()
{
	ll n;cin>>n;ll ans=0;
	for(ll i=1;i<=n;i++){
		cin>>a[i];
		mp[a[i]]++;
		ans=max(ans,mp[a[i]]);
	}
	for(ll i=1;i<=n;i++){
		if(mp[a[i]]==ans){
			q.push_back(a[i]);
			mp[a[i]]=0;	
		}
	}
	sort(q.begin(),q.end());
	for(ll i=0;i<q.size();i++){
		cout<<q[i]<<endl;
	}
}

Measured memory_bytes: 28404
use proconio::input;

fn main() {
    input! {
        n: usize,
        mut a: [i32; n],  // Vec<(i32, i32, i32)>
    }
    let count = a
        .into_iter()
        .enumerate()
        .filter(|b| (b.0 + 1) % 2 != 0 && b.1 % 2 != 0)
        .count();
    println!("{}", count);
}


Measured memory_bytes: 2120
import math
n,d = map(int,input().split())
l = [list(map(int,input().split())) for i in range(n)]
#print(n,d,l)

cnt = 0
for i in range(n):
    for j in range(i+1,n):
        dist = 0
        for k in range(d):
            dist += (l[i][k] - l[j][k])**2
        sqrt = int(dist**.5)
        if sqrt**2 == dist:
            cnt += 1
print(cnt)

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

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

int N;
const int M = 50;

void matmul(int64_t A[M][M], int64_t B[M][M]){
    int64_t result[N][N];
    memset(result, 0, sizeof(result));
    for(int i=0; i<N; i++) for(int j=0; j<N; j++) for(int k=0; k<N; k++) add(result[i][j], A[i][k] * B[k][j] % MOD);
    for(int i=0; i<N; i++) for(int j=0; j<N; j++) A[i][j] = result[i][j];
}

int main(){
    int64_t K;
    cin >> N >> K;
    int64_t A[M][M];
    memset(A, 0, sizeof(A));
    for(int i=0; i<N; i++) for(int j=0; j<N; j++) cin >> A[i][j];

    int64_t result[M][M];
    for(int i=0; i<M; i++) for(int j=0; j<M; j++) result[i][j] = (i==j && i<N);
    while(K>0){
        if(K%2){
            matmul(result, A);
        }
        K /= 2;
        matmul(A, A);
    }
    int64_t ans = 0;
    for(int i=0; i<N; i++) for(int j=0; j<N; j++) add(ans, result[i][j]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        String S = sc.next();
        
        String[] ar = S.split("");

        int maxLength = 0;
        int tmp = 0;

        for (int i = 0; i < ar.length; i++){
            
            if (ar[i].equals("A") || ar[i].equals("T") || ar[i].equals("G") || ar[i].equals("C")) {
                tmp++;
            } else {
                tmp = 0;
            }

            if (tmp > maxLength) {
                maxLength = tmp;
            }

        }

        System.out.println(maxLength);
     }
}


Measured memory_bytes: 23764
/**
 ____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|

**/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N_MAX = 302;

int n;

string s;

int k;

int dp[N_MAX][N_MAX][N_MAX];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> s;
    n = s.size();
    s = " " + s;
    cin >> k;
    for(int l = 0; l <= n; l++)
        for(int r = n + 1; r >= l; r--)
            if(l >= 1 || r <= n)
            {
                for(int c = 0; c <= k; c++)
                {
                    if(l >= 1)
                        dp[l][r][c] = max(dp[l][r][c], dp[l - 1][r][c]);
                    if(r <= n)
                        dp[l][r][c] = max(dp[l][r][c], dp[l][r + 1][c]);
                    if(c >= 1)
                        dp[l][r][c] = max(dp[l][r][c], dp[l][r][c - 1]);
                    if(l >= 1 && r <= n)
                    {
                        if(s[l] == s[r])
                            dp[l][r][c] = max(dp[l][r][c], dp[l - 1][r + 1][c] + 1 + (l < r));
                        else if(c >= 1)
                            dp[l][r][c] = max(dp[l][r][c], dp[l - 1][r + 1][c - 1] + 1 + (l < r));
                    }
                }
            }
    int ans = 0;
    for(int i = 1; i <= n; i++)
        ans = max(ans, dp[i][i][k]);
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 58652
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

  array<int,6> a;
  for(auto& x:a) x=in();
  
  cout << (((a[4]-a[0])<=a[5]) ? "Yay!" : ":(") << endl;
  
  return 0;
}

Measured memory_bytes: 256
import queue
N=int(input())
M=[input().split()[2:]for _ in[0]*N]
q=queue.Queue();q.put(0)
d=[-1]*N;d[0]=0
while not q.empty():
 u=q.get()
 for v in M[u]:
  v=int(v)-1
  if d[v]<0:d[v]=d[u]+1;q.put(v)
for i in range(N):print(i+1,d[i])


Measured memory_bytes: 7004
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M,get=0,los=0;
  cin >> N >> M;
  vector<int> C(N+1,0);
  vector<int> L(N+1,0);
  
  
  for(int i=0; i<M; i++){
    int a;
    string b;
    cin >> a >> b;
    if(C.at(a)==0){
      if(b=="AC"){
        C.at(a)=1;
      }else{
        L.at(a)++;
      } 
    }
  }
  
  for(int j=1; j<=N; j++){
    
    if(C.at(j)==1){
      get++;
      los+=L.at(j);
    }
  }
  
  cout << get << " " << los << endl;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

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

    long long ans = 0;
    for (int j = 1; j < N + 1; j++)
    {
        int i = j;
        while (i <= N)
        {
            ans += i;
            i += j;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3648
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
#define DEBUG
#ifdef DEBUG
	#define debug printf
#else
	#define debug(...)
#endif
const int maxn = 1e3 + 5;
int a[maxn][maxn];
int main(int argc, char const *argv[])
{
	int flag = 0;
	int n,k = 1;
	cin>>n;
	for(int i = 1;i * (i - 1) <= 2 * n && flag == 0; ++i,flag = (2 * n == (i * (i - 1)) ? i : 0));
	if(flag)
	{
		// flag++;
		printf("Yes\n%d\n",flag);
		for(int i = 1;i <= flag && k <= n; ++i)
		{
			for(int j = i;j < flag && k <= n; ++j)
			{
				a[i][j] = a[j + 1][i] = k++;
			}
		}
		for(int i = 1;i <= flag; ++i)
		{
			printf("%d ",flag - 1);
			for(int j = 1;j < flag; ++j)
			{
				printf("%d ",a[i][j]);
			}
			printf("\n");
		}
	}
	else
	{
		printf("No\n");
	}
	return 0;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

    int n; std::cin >> n;
    string s; std::cin >> s;
    string ans(n, '-');
    auto rev = [](char &c) {
        return (c=='S' ? 'W' : 'S');
    };
    rep(i, 1<<2) {
        rep(j, 2) {
            if ((i>>j)&1) ans[j] = 'S';
            else ans[j] = 'W';
        }
        srep(j, 1, n-1) {
            if (ans[j] == 'S')
                ans[j+1] = (s[j]=='o' ? ans[j-1] : rev(ans[j-1]));
            else
                ans[j+1] = (s[j]=='x' ? ans[j-1] : rev(ans[j-1]));
        }
        char c1, c2;
        if (ans[n-1] == 'S')
            c1 = (s[n-1]=='o' ? ans[n-2] : rev(ans[n-2]));
        else
            c1 = (s[n-1]=='x' ? ans[n-2] : rev(ans[n-2]));
        if (ans[0] == 'S')
            c2 = (s[0]=='o' ? ans[1] : rev(ans[1]));
        else
            c2 = (s[0]=='x' ? ans[1] : rev(ans[1]));
        if (c1 == ans[0] && c2 == ans[n-1]) {
            std::cout << ans << "\n";
            return 0;
        }
    }
    std::cout << -1 << "\n";
}


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

const int maxn = 100005;
const int mod = 1000000007;
int n,m;
ll dp[2050][2050];
int a[2050],b[2050];

int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    for(int i=1;i<=m;i++)scanf("%d",&b[i]);
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++){
            if(a[i]==b[j])dp[i][j]=(dp[i-1][j]+dp[i][j-1]+1)%mod;
            else dp[i][j]=(dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1]+mod)%mod;
        }
    cout<<(dp[n][m]+1)%mod<<endl;
}


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

#define ipair pair<int,int>
#define rep(i,n) for(i=0;i<n;i++)
#define repj(i,j,n) for(i=j;i<n;i++)

#define PB(a,i) (a).push_back(i)
#define ALL(a) (a).begin(),(a).end()
#define SIZE(a,n) (a).resize(n)
#define SORT(a) sort(ALL(a))
#define VSORT(a, type) sort(ALL(a),greater<type>())
#define MAPIN(a,i,j) (a).insert(make_pair(i,j))

#define OK(i) cout<<"OK "<<i<<endl
#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl

using namespace std;

typedef unsigned long long lli;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > Matrix;

int main() {
    int n;

    cin>>n;

    if(n%2==0){
        cout<<0.5;
    }
    else{
        cout<<setprecision(10)<<(double)(n/2+1)/n;
    }
	
	return 0;
}


Measured memory_bytes: 256