akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
const int MAX=5100;
const int modn=1e9+7;
typedef long long ll ;
#define endl '\n'
#define cwk     freopen("D:\\workplace\\CLion\\in.in","r",stdin),freopen("D:\\workplace\\CLion\\out.out","w",stdout)
using namespace std;
ll n,k,now_maxn,all_maxn;
ll p[MAX],c[MAX];
vector<ll>v[MAX];
int main() {
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>p[i];
    }
    for(int i=1;i<=n;i++){
        cin>>c[i];
    }
    all_maxn=-INT_MAX;
    for(int i=1;i<=n;i++) {
        now_maxn=-INT_MAX;
        ll ans = 0;
        for (int j = p[i]; j != i; j = p[j]) {
            ans += c[j];
            v[i].push_back(ans);
            now_maxn=max(now_maxn,ans);
        }
        ans+=c[i];
        v[i].push_back(ans);
        now_maxn=max(now_maxn,ans);
        /*for(int j=0;j<v[i].size();j++)
            cout<<v[i][j]<<" ";
        cout<<"\n";*/
        ll all=v[i][v[i].size()-1];
        ll now=-INT_MAX;
        if(all<=0){
            now=now_maxn;
        }else{
            for(int j=0;j<k%v[i].size();j++){
                now=max(now,v[i][j]);
            }
            if(k>=v[i].size()) {
                if (all - now_maxn + now < 0) {
                    now = now_maxn + (k / v[i].size() - 1) * all;
                } else {
                    now += k / v[i].size() * all;
                }
            }
        }
        all_maxn=max(all_maxn,now);
    }
    cout<<all_maxn;
    return 0;
}


Measured memory_bytes: 218772
s=list(map(int, input().split()))
import math
a=s[0]
b=s[1]
x=s[2]
if x==a*a*b:
  print(0)
elif x>=a*a*b/2:
  print(90-math.degrees(math.atan((a**3)/(a*a*b-x)/2)))
else:
  print(90-math.degrees(math.atan(2*x/(a*b**2))))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  string S;cin>>S;
  
  int ans=0;
  
  for(int i=0;i<3;i++){
    if(S[i]=='1'){
      ans++;
    }
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int n,m,x;
    cin >> n >> m >> x;
    vi c(n);
    vvi a(n,vi(m));
    rep(i,n){
        cin >> c[i];
        rep(j,m)cin >> a[i][j];
    }
    int ans = INF;
    rep(bit, 1<<n){
        vi t(m,0);
        int sum = 0;
        rep(i,n)if(bit&(1<<i)){
            rep(j,m)t[j] += a[i][j];
            sum += c[i];
        }
        bool c = true;
        rep(i,m)if(t[i] < x)c = false;
        if(c)ans = min(ans, sum);
    }
    if(ans == INF)cout << -1 << endl;
    else cout << ans << endl;
}


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

using namespace std;

#define forsn(i, s, n) for(int i=s;i<int(n);i++)
#define forn(i, n) forsn(i, 0, n)
#define all(v) v.begin(), v.end()

typedef long long tint;

int main(){
	int n; cin >> n;
	vector<string> a (n);
	forn(i, n){
		cin >> a[i]; sort(all(a[i]));
	}
	sort(all(a));
	tint tot = 0, cont = 1;
	string prev = a[0];
	forsn(i, 1, n){
		if(a[i] == prev) cont++;
		else{ tot+=(cont*(cont-1))/2; cont = 1; prev = a[i];}
	}
	tot+=(cont*(cont-1))/2;
	cout << tot << endl;
}


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

using namespace std;

int main()
{
    int n;
    
    while (scanf("%d", &n) && n){
        int blk[16][8];
        int ch[16][8];
        for (int i = 0; i < n; i++){
            for (int j = 0; j < 5; j++){
                scanf("%d", &blk[i][j]);
            }
        }
        
        int tot = 0;
        bool upd;
        
        do {
            upd = 0;
            memset(ch, 0, sizeof(ch));
            for (int i = 0; i < n; i++){
                for (int j = 0; j < 3; j++){
                    if (!blk[i][j]) continue;
                    if (blk[i][j] == blk[i][j + 1] && blk[i][j] == blk[i][j + 2]){
                        ch[i][j] = ch[i][j + 1] = ch[i][j + 2] = 1;
                        upd = true;
                    }
                }
            }
            int btm[8] = {0};
            for (int i = n - 1; i >= 0; i--){
                for (int j = 0; j < 5; j++){
                    tot += blk[i][j] * ch[i][j];
                    if (!ch[i][j]) blk[n - ++btm[j]][j] = blk[i][j];
                }
            }
            for (int i = 0; i < 5; i++){
                for (int j = 0; j < n - btm[i]; j++) blk[j][i] = 0;
            }
        } while (upd);
        
        printf("%d\n", tot);
    }
    
    return (0);
}

Measured memory_bytes: 1188
#include <stdio.h>
#include <string.h>
int main()
{
    char a[10], b[10], c[10];
    scanf("%s", a);
    scanf("%s", b);
    scanf("%s", c);
    int lena = strlen(a);
    int lenb = strlen(b);
    if (a[lena - 1] != b[0])
        printf("NO");
    else
    {
        if (b[lenb - 1] != c[0])
        {
            printf("NO");
        }
        else
        {
            printf("YES");
        }
    }
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;
const int Maxn = 1e9 + 10;
const int N = 1e5 + 10;
const int INF=(0x7fffffff)/2;
const int MOD = 1000000007;
const int MaxN = 1e5;

int a[160], b[160], c[160], d[160];
bool used[160];
int girl[160], line[160][160];

int n;

bool find(int x){
	for(int j = 1; j <= n; j++){
		if(line[x][j] && !used[j]){
			used[j] = 1;
			if(girl[j] == 0 || find(girl[j])){
				girl[j] = x;
				return true;
			}
		}
	}
	return false;
}


int main(){
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i] >> b[i];
	for(int i = 1; i <= n; i++) cin >> c[i] >> d[i];
	memset(line, 0, sizeof(line));
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			if(a[i] < c[j] && b[i] < d[j]) line[i][j] = 1;

		}
	}
	memset(girl, 0, sizeof(girl));
	int ans = 0;
	for(int i = 1; i <= n; i++){
		memset(used, 0, sizeof(used));
		if(find(i))
			ans++;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

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

    int dx = tx-sx;
    int dy = ty-sy;

    for(int i=0;i<dy;i++){
        cout << "U";
    }
    for(int i=0;i<dx;i++){
        cout << "R";
    }
    for(int i=0;i<dy;i++){
        cout << "D";
    }
    for(int i=0;i<dx;i++){
        cout << "L";
    }
    cout << "LU";
    for(int i=0;i<dy;i++){
        cout << "U";
    }
    for(int i=0;i<dx;i++){
        cout << "R";
    }
    cout << "RDR";
    for(int i=0;i<dy;i++){
        cout << "D";
    }
    cout << "DL";
    for(int i=0;i<dx;i++){
        cout << "L";
    }
    cout << "U" << endl;

    return 0;
}


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

class DisjointSet {
  vector<int> p;
  vector<int> r;

public:
  DisjointSet(int n) {
    for (int i = 0; i < n; i++) {
      p.push_back(i);
      r.push_back(0);
    }
  }

  int findRoot(int u) {
    while (u != p[u]) {
      p[u] = p[p[u]];
      u = p[u];
    }
    return p[u];
  }

  bool isSame(int u, int v) {
    return (findRoot(u) == findRoot(v));
  }

  void link(int u, int v) {
    int u_root = findRoot(u);
    int v_root = findRoot(v);

    if (r[u_root] < r[v_root]) {
      p[u_root] = v_root;
    } else {
      p[v_root] = u_root;
      if (r[u_root] == r[v_root]) r[u_root]++;
    }
  }
};
  
class Edge {
public:
  int s, t, w;
  Edge(int s, int t, int w): s(s), t(t), w(w) {}
  bool operator < (const Edge &e) const {
    return w < e.w;
  }
};

vector<Edge> Es;

void kruskal() {
  DisjointSet ds(Es.size());
  int cost = 0;

  sort(Es.begin(), Es.end());

  for (int i = 0; i < Es.size(); i++) {
    Edge e = Es[i];
    if (!ds.isSame(e.s, e.t)) {
      ds.link(e.s, e.t);
      cost += e.w;
    }
  }

  cout << cost << endl;
}

int main() {
  int v, e; cin >> v >> e;

  Es.resize(v, Edge(0, 0, 0));

  for (int i = 0; i < e; i++) {
    int s, t, w; cin >> s >> t >> w;
    Es.push_back(Edge(s, t, w));
  }

  kruskal();

  return 0;
}

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

    using namespace std;

    const int MOD=1e9+7;
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        int n;
        cin>>n;
        cout<<fixed;
        cout<<setprecision(10);
        vector<double>a(n);
        for(int i=0;i<n;i++)
            cin>>a[i];
        vector<vector<double>>dp(n+1,vector<double>(n+1,0.0));
        dp[0][0]=1;
        for(int i=1;i<=n;i++){
            for(int j=0;j<=i;j++){
                if(j==0)
                    dp[i][j]=dp[i-1][j]*(1-a[i-1]);
                else
                    dp[i][j]=dp[i-1][j]*(1-a[i-1]) + dp[i-1][j-1]*(a[i-1]);
            }
        }
//        for(int i=0;i<=n;i++){
//            for(int j=0;j<=i;j++)
//                cout<<dp[i][j]<<" ";
//            cout<<"\n";
//        }
        double ans=0.0;
        for(int i=n;i>(n/2);i--)
            ans+=dp[n][i];
        cout<<ans;
        return 0;
    }


Measured memory_bytes: 70784
#include <stdio.h>

int main(){
    int N, x=0, i, max=0;
    char S[101];

    scanf("%d", &N);
    scanf("%s", S);

    for(i=0; i<N; i++){
        if(S[i] == 'I')
            x++;
        else
            x--;
        
        if(max < x)
            max = x;
    }

    printf("%d\n", max);

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;


int main(void){
    char c;
    cin >> c;
    if(isupper(c))
        printf("A\n");
    else printf("a\n");
    return 0;
}

Measured memory_bytes: 3600
N=int(input())

R=[]
for i in range(N):
    x,l=map(int,input().split())
    s=x-l
    t=x+l
    R.append([s,t])
R.sort(key=lambda x:x[1])
cur=-10**9
ans=0
for i in range(N):
    if cur<=R[i][0]:
        ans+=1
        cur=R[i][1]
print(ans)

Measured memory_bytes: 69080
#include <bits/stdc++.h>
#define FIN         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii          pair<int,int>
#define F           first
#define S           second
#define pb          push_back
#define all(x)      (x).begin(),(x).end()
#define rall(x)     (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a)   for(int i = a; i >= 0; i--)
#define fori(i,m)   for(auto i = m.begin(); i != m.end(); i++) 
#define w(t)        while(t--)
#define sz(s)       int(s.size())
#define cls(a,car)  memset(a,car,sizeof (a))
#define db(x)       cerr << #x << " is " << x << '\n'
#define FL          freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout);
#define EjecuteTime cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
#define angle(x)    double(x * acos(-1) / 180.0)
using namespace std;
typedef long long   ll;
typedef vector<int> vi;
typedef vector<ii>  vii;
const int N = 1 * 1e5 + 5;
const ll mod = 1e9 + 7;
const double E = 1e-9;
//int dx[] = {1, 0}, dy[] = {0, 1};
//int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//int dx[] = {2, 1, -1, -2, -2, -1, 1, 2}, dy[] = {1, 2, 2, 1, -1, -2, -2, -1};
//int dx[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy[] = {0 ,1, 1, 1, 0, -1, -1, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)
int n, W;
int w[101], v[101];
ll dp[101][N];
ll f(int i, int cost){
    if(cost < 0)
        return -1e18;
    if(i == n)
        return 0;
    ll &ans = dp[i][cost];
    if(ans == -1){
        ans = max(f(i + 1, cost), f(i + 1, cost - w[i]) + v[i]);
    }return ans;
}
int main(){
    //FL;
    FIN;
    cin >> n >> W;
    for(int i = 0; i < n; i++)
        cin >> w[i] >> v[i];
    cls(dp, -1);
    cout << f(0, W) << '\n';
    EjecuteTime;
    return 0;
}       

Measured memory_bytes: 82692
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		boolean can = false;

		for (int i = 1; i <= 9; i++) {
			for (int j = 1; j <= 9; j++) {
				if (N == i * j) can = true;
			}
		}

		if (can) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll ar[300005],br[300004],cr[2000003];
ll i,k,j,sum,a,b,cnt,maxii,l;
map<ll,ll>mp;
vector<ll>vc;
string s,s1,s2;
int main()
{
    ll n,x=0,t,y=0;
    j=0;
    cin>>s;
    x=s.size();
    y=x;
    x=(x-1)/2;
    y=(y+3)/2;
   for(i=0;i<x;i++)
   {
     s1+=s[i];

   }
   for(i=y-1;i<s.size();i++)
   {
       s2+=s[i];
   }

if(s1==s2)
{
    for(i=0;i<s1.size()/2;i++)
    {
        if(s1[i]==s1[s1.size()-i-1])
        {

        }
        else
            sum=1;
    }
    if(sum)
        cout<<"No"<<endl;
    else
    cout<<"Yes"<<endl;
}
else
    cout<<"No"<<endl;
    sum=a*(a+1)/2+b*(b+1)/2;

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int a[100005];
int main()
{
	int i,n,m,t,ans=0;
	cin>>n>>m;
	for(i=1;i<=n;i++)
		cin>>a[i];
	for(i=1;i<=n;i++)
		if(a[i]==1) t=i;
	for(i=t;i>1;i-=m-1)
		ans++;
	for(i=t-i+1;i<n;i+=m-1)
		ans++;
	cout<<ans;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios_base::sync_with_stdio(0);
    int l, r, d; cin >> l >> r >> d;
    cout << r/d - (l-1)/d << endl;
}


Measured memory_bytes: 3616
//============================================================================
// Name        : JOI.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cctype>
#include <string>
#include<algorithm>

using namespace std;
typedef long long ll;

int main() {

	int a;
	int b;

	cin>>a>>b;

	if((a+b)%2>0){
		cout<<(a+b)/2+1<<endl;
	}else{
		cout<<(a+b)/2<<endl;
	}





}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
using ld = long double;
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
const long double pi = (acos(-1));
#define pb push_back
#define vs vector<string>

//最大最小の入れ替え
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (ll i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

//切り上げの割り算は(a + b - 1) / bでできる

//ここから
int main(){
    ll N,M,K;
    cin>>N>>M>>K;
    rep(i,M+1){
        rep(j,N+1){
            if(i*(N-j)+j*(M-i)==K){
                cY;
                return 0;
            }
        }
    }
    cN;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define inf 999999999
#define loop(i, a, b) for (int i = (a), i##len = (b); i < i##len; ++i)
#define rep(i, n) loop(i, 0, n)
#define lin long long

lin n, m;
lin p[100001];
vector<vector<int>> link;
bool b[100001];
unordered_set<int> gr;

void make_group(int seed)
{
    gr.emplace(seed);

    if(b[seed])
        return;

    b[seed] = true;
    
    rep(i, link[seed].size())
    {
        int l = link[seed][i];
        if(b[l])
            continue;

        make_group(l);
    }
}

int main(void)
{
    cin >> n >> m;
    rep(i, n)
    {
        cin >> p[i];
        p[i]--;
    }

    rep(i, n)
    {
        vector<int> nv;
        link.push_back(nv);
    }

    rep(i, m)
    {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        link[x].push_back(y);
        link[y].push_back(x);
    }

    int res = 0;

    rep(i, n)
    {
        if(b[i])
            continue;

        gr.clear();
        make_group(i);
        for(int idx : gr)
        {
            if(gr.find(p[idx]) != gr.end())
                res++;
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 12784
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k,sept;
    int i,tmp;
    cin>>k;
    switch(k%10){
        case 0:
        case 2:
        case 4:
        case 5:
        case 6:
        case 8:
            printf("-1");
            return 0;
        default:
        sept=7;
        i=1;
        while(1){
            if(sept%k==0){
                printf("%d",i);
                return 0;
            }
            sept=sept*10%k+7%k;
            i++;
        }
    }
    return 0;
}


Measured memory_bytes: 3740
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    if(n == 1) out("Hello World");
    else{
        int a, b;
        cin >> a >> b;
        out(a+b);
    }
}

Measured memory_bytes: 256
// atcoder/abc145/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  string s;
  while (cin >> n >> s) {
    bool f = false;
    string t;
    for (int i = 0; i < s.size(); ++i) {
      t += s[i];
      f = f || (t + t == s);
    }
    cout << (f ? "Yes" : "No") << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    unsigned long long n, m;
    unsigned long long ans;
    cin >> n >> m;

    if (n == 1 || m == 1) {
        unsigned long long a = n == 1 ? m : n;
        ans = a == 1 ? 1: a - 2;
    }
    else {
        ans = (n - 2) * (m - 2);
    }

    cout << ans << endl;
}


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

int main() {
	long int n,k;
	cin>>n>>k;
	long int a[n];
	for(long int i=0;i<n;i++)
	  {cin>>a[i];
	   a[i]%=k;	
	  }
	long int pre[n+1];
	long int sum=0;
	pre[0]=0;
	for(long int i=0;i<n;i++)
	  {
	  	pre[i+1]=(pre[i]+a[i])%k;
	  }
	 map <long int ,long int >hash;
	 hash[0]=1;
	 long long int count=0;
	for(long int i=1;i<n+1;i++)
	  {
	  	 hash[pre[i]]=hash[pre[i]]+1;
	  	 count+=(hash[pre[i]]-1);
	  }
	cout<<count<<'\n';  
	return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,n) for(int i=1; i<=(n); i++)

int main() {
	int n,m,ans;
    cin>>n>>m;
    ans=n*(n-1)/2+m*(m-1)/2;
    cout<<ans;
	return 0;
}

Measured memory_bytes: 256
def print_side(W):
    for j in range(W):
        print("#",end="")
    print("")

def print_body(W):
    for j in range(W):
        if j==0 or j==W-1: 
            print("#",end="")
        else:
            print(".",end="")
    print("")

while True:
    H,W = [int(x) for x in input().split()]
    if (H,W)==(0,0): break
    for i in range(H):
        if i==0 or i==H-1:
            print_side(W)
        else:
            print_body(W)
    print("")

Measured memory_bytes: 9160
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

int main() {
  ll N;

  cin >> N;

  unordered_map<ll, ll> um;

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

  ll ans = 0;
  for (auto& p : um) {
    ll key = p.first;
    ll value = p.second;
    if (value < key)
      ans += value;
    else
      ans += value - key;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4260
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
using ll=long long;

const ll INF = pow(10,18)+1;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

template<typename T> bool chmin(T& a, T b) {return a > b ? a = b, true : false;}
template<typename T> bool chmax(T& a, T b) {return a < b ? a = b, true : false;}
 
int main(){
    ll N;
    vector<ll> H;
    cin >> N;
    REP(i,N){
        ll tmp;
        cin >> tmp;
        H.push_back(tmp);
    }
    int ans = 0;
    int count = 0;
    REP(i,N-1){
        if(H[i] >= H[i+1]) count++;
        else {
            if(count > ans) ans = count;
            count = 0;
        }
        if(i == N - 2){
            if(count > ans) ans = count;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1400
use proconio::input;

#[allow(non_snake_case)]
fn main() {
    use std::f64::consts::PI;
    input! {
        A: f64,
        B: f64,
        H: f64,
        M: f64,
    }

    let mut t = (M / 60.0 - (H * 60.0 + M) / (12.0 * 60.0)) * 2.0 * PI;
    if t > PI {
        t = 2.0 * PI - t;
    }
    let ans = (A * A + B * B - 2.0 * A * B * t.cos()).sqrt();

    println!("{}", ans);
}


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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

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

int func(long long n, long long k, std::vector<long long> h) {
    // cout << fixed << setprecision(8);
    sort(all(h));

    ll ans = INF;
    for (int i = 0; i + k - 1 < n; i++) {
        ans = min(ans, h[i + k - 1] - h[i]);
    }

    cout << ans << endl;

    return 0;
}

int main() {
    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    std::vector<long long> h(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &h[i]);
    }

    func(N, K, std::move(h));

    return 0;
}


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

int main() {
  int k, a, b;
  cin >> k >> a >> b;
  int f;
  f = a % k;
  if(f == 0)  cout << "OK" << endl;
  else if((f + b - a)/k != 0) cout << "OK" << endl;
  else cout << "NG" << endl;
}

Measured memory_bytes: 3640
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e10;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }
inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

signed main() {
  double t, x;
  cin >> t >> x;
  printf("%lf\n", t / x);
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	var s string
	fmt.Scan(&n, &s)
	r := 0
	g := 0
	b := 0
	for _, c := range s {
		if c == 'R' {
			r++
		}
		if c == 'G' {
			g++
		}
		if c == 'B' {
			b++
		}
	}
	ans := r * g * b

	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			if (i+j)%2 == 0 && s[i] != s[j] && s[i] != s[(i+j)/2] && s[j] != s[(i+j)/2] {
				ans--
			}
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 1820
// 基本テンプレート
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int X; cin >> X;
    if(X == 3 or X == 5 or X == 7) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
#include <queue>
#include <set>
#include <cassert>
using namespace std;
using ll = long long;
using plong = pair<ll,ll>;

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

const long MOD = 1000000007;

int main(){
    ll N,H;cin>>N>>H;
    vector<ll>a(N),b(N);
    for(ll i=0;i<N;i++){
        cin>>a[i]>>b[i];
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    ll max_a = a[N-1];
    ll res=0;
    for(ll i=0;i<N;i++){
        ll damage = b[N-1-i];
        if(damage>max_a){
            res++;
            H-=damage;
        }else{
            break;
        }
        if(H<=0)goto exit;
    }
    res+=(H+max_a-1)/max_a;
exit:
    cout<<res<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>

#define rep(i,n) for (int i=0; i < (n); ++i)
using ll = long long ;
using namespace std;
const int INF = 1001001001;


int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}


int main() {

    string s ;
    cin >> s ;
    int ans = 0 ;

    rep(i,s.size()){
        ans+= ctoi(s[i]) ;
    }

    if(ans%9==0){
        cout << "Yes" << endl ;
    }else{
        cout << "No" << endl ;
    }

    return 0 ;
}

Measured memory_bytes: 3752
def inpl(): return input().split()

n = int(input())
M = [list(map(int, inpl())) for _ in range(n)]
for i in range(n - 1):
    v = max(((M[i][1] - 1) // M[i+1][1] + 1), ((M[i][0] - 1) // M[i+1][0] + 1))
    M[i+1][0] *= v
    M[i+1][1] *= v     
print(M[n - 1][0] + M[n - 1][1])

Measured memory_bytes: 3188
#include<iostream>
#include<iomanip>
#include<algorithm>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
    int N;
    string S;
    cin >> N >> S;
    int x=0;
    int max=0;
    REP(i,N){
        if(S[i]=='I'){
            x+=1;
        }else{
            x-=1;
        }
        if(max<x){
            max = x;
        }
    }
    cout << max;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i,0,n)
#define BFOR(bit,a,b) for(int bit = (a); bit < (1<<(b)); ++bit)
#define BREP(bit,n) BFOR(bit,0,n)
using namespace std;
using ll = long long;

int main() {
  ll x;
  cin >> x;
  ll ans = (x/11) * 2;
  
  if(x%11 > 0 && x%11 <= 6) ans += 1;
  if(x%11 >= 7) ans += 2;
  
  cout << ans << endl;
    
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --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 equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

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

  int n = s.size();
  map<char, bool> c;
  rep(i, n) {
    if (c[s[i]]) {
      cout << "no" << endl;
      return 0;
    }
    else c[s[i]] = true;
  }
  cout << "yes" << endl;


  
  return 0;
}

Measured memory_bytes: 256
N = int(input())

st = []
for i in range(N):
    a, b = input().split()
    st.append([a, int(b)])
X = input()

r = 0
flag = False
for i, sti in enumerate(st):
    s = sti[0]
    t = sti[1]
    if s == X:
        flag = True
    else:
        if flag:
            r += t
print(r)

Measured memory_bytes: 3064
import java.io.*;
import java.util.Scanner;
import java.util.ArrayList;


public class Main {
    public static void main(String[] args)throws Exception{
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        ArrayList<String> cards = new ArrayList<String>();
        trumpAdd(cards, "S");
        trumpAdd(cards, "H");
        trumpAdd(cards, "C");
        trumpAdd(cards, "D");
        for(int I = 0;I <= n - 1;I++){
            trumpRemove(cards, scan.next(),scan.nextInt());
        }
        for(int j = 0;j <= 51 - n;j++){
            System.out.println(cards.get(j));
        }
    }
    
    public static void trumpAdd(ArrayList<String> sample, String mark){
        for(int i = 0;i <= 12;i++){
            sample.add(mark + " " + (i + 1));
        }
    }
    
    public static void trumpRemove(ArrayList<String> sample, String marks, int number){
        sample.remove(marks + " " + number);
    }
}


Measured memory_bytes: 26236
n = int(input())
s = input()

res = 0
i,j = 0, 1
while j<n:
    if s[i:j] in s[j:]:
        res = max(res, j-i)
        j += 1
    else:
        i += 1
    if i==j:
        i += 1
        j += 2
print(res)

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

const int LIM=1000000000;
signed main(){
	int S;cin>>S;

	int x1,y1,x2,y2;
	x2=1;
	
	int T=(S+LIM-1)/LIM*LIM;
	y1=T-S;
	x1=LIM;
	y2=T/LIM;

	cout<<0<<" "<<0<<" "<<" "<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

bool cmp(pii a, pii b){ return a.second < b.second; }

int main(){
  int n,m; cin >> n >> m;
  vector<pii> a(m);
  rep(i,m) cin >> a[i].first >> a[i].second;
  sort(all(a),cmp);

  int ans = 0;
  int right = 0;
  rep(i,m) {
    if(right <= a[i].first){
      ans++;
      right = a[i].second;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions
ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a%b);
}
#endif


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

    int N; cin >> N;

    if (N == 0) {
        cout << 0 << endl;
        return 0;
    }

    string ans = "";
    int n = N;
    while(abs(n) > 0) {
        if (n%2 != 0) {
            n--;
            ans = "1" + ans;
        } else {
            ans = "0" + ans;
        }

        n /= -2;
    }

    cout << ans << endl;

    return 0;
}

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

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

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

int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, X;
	cin >> N >> X;

	vector<int> city(N);
	for (int i = 0; i < N; i++) cin >> city[i];
	for (int i = 0; i < N; i++) city[i] -= X;

	int ans = 0;
	for (int i = 0; i < N; i++) ans = gcd(ans, abs(city[i]));

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
const int MOD=1e9+7;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef HOME
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define me(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin>>n>>m;
    vector<int>k[m];
    vector<int>check;
    for(int i=0;i<m;i++){
        int kk;
        cin>>kk;
        check.push_back(kk);
        while(kk--){
            int num;
            cin>>num;
            num--;
            k[i].push_back(num);
        }
    }
    vector<int>p;
    for(int i=0;i<m;i++){
        int num;
        cin>>num;
        p.push_back(num);
    }
    int count=0;
    for(int i=0;i<(1LL<<n);i++){
        map<int,int>map;
        for(int j=0;j<n;j++){
            if(i&(1LL<<j)){
                map[j]++;
            }
        }
        int mk=0;
        for(int l=0;l<m;l++){
            int c=0;
            for(int o=0;o<check[l];o++){
                if(map[k[l][o]]){
                    c++;
                }
                
            }
            int t=p[l];
            if(c%2==t){
                mk++;
            }
            c=0;
        }
        if(mk==m){
            count++;
        }
    }
    cout<<count<<endl;
    
    return 0;
    
}



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

int main(){
  int N; cin >> N;
  int b1 = 0, b2 = 0, b4 = 0;
  for(int i = 0; i < N; i++){
    int a; cin >> a;
    if(a % 4 == 0) b4++;
    else if(a % 2 == 0) b2++;
    else b1++;
  }
  if(b2 == 0) cout << ((b4 + 1 >= b1)?"Yes":"No");
  else cout << ((b4 >= b1)?"Yes":"No");
}

Measured memory_bytes: 256
import math

a, b, h, m = list(map(int, input().split()))
rh = (h + m/60) * 30 
rm = m * 6
rd = abs(rh -rm)
print(math.sqrt((a**2) + (b**2) - (2 * a * b * math.cos(math.radians(rd)))))


Measured memory_bytes: 9316
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
vector<pair<int,int> >H,W;
int n,h,w;
main()
{
	cin>>n>>h>>w;
	for(int i=0;i<n;i++)
	{
		int a,b,c;cin>>a>>b>>c;
		H.push_back(make_pair(a-c,a+c));
		W.push_back(make_pair(b-c,b+c));
	}
	sort(H.begin(),H.end());
	sort(W.begin(),W.end());
	bool flag=1;int now=0;
	for(int i=0;i<H.size();i++)
	{
		if(now>=H[i].first)now=max(now,H[i].second);
		else flag=0;
	}
	flag&=now>=h;
	now=0;
	bool flag2=1;
	for(int i=0;i<W.size();i++)
	{
		if(now>=W[i].first)now=max(now,W[i].second);
		else flag2=0;
	}
	flag2&=now>=w;
	cout<<(flag||flag2?"Yes":"No")<<endl;
}



Measured memory_bytes: 4740
n, m, x = map(int, input().split())
C = []
A = []
ans = float("inf")
for _ in range(n):
    tmp = list(map(int, input().split()))
    C.append(tmp[0])
    A.append(tmp[1:])

for i in range(2**n):
    now = [0] * m
    ns = 0

    for j in range(n):
        if i&(2**j):
            ns += C[j]

            for k in range(m):
                now[k] += A[j][k]

    if min(now) >= x:
        ans = min(ans, ns)

if ans == float("inf"):
    print(-1)
else:
    print(ans)

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

int main() {
    int n;
    cin>>n;
    int tot = 0;
    int cnt = 0;
    int temp = n;
    while (temp!=0) {
        cnt++;
        temp/=10;
    }
    //cout << cnt << endl;
    if (cnt&1) {
        if (cnt==1) {
            tot = n;
        } else if (cnt==3) {
            //cout << "here" << endl;
            tot = 9+n-100+1;
        } else {
            tot = 9+900+n-10000+1;
        }
    } else {
        if (cnt==2) tot = 9;
        else if (cnt==4) tot = 909;
        else tot = 9+900+90000;
    }
    cout << tot << endl;
}

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


int32_t main()
{
    
    int n;
    cin >> n;
    vector<pair<int,int>> v;
    int a,b;
    for(int i=0;i<n;++i)
    {
      cin >> a >> b;
      v.push_back({b,a});
    }

    sort(v.begin(),v.end());
    
    int timer =0;

    for(auto i : v)
    {
      if(i.first >= timer && i.first >= timer + i.second)
      {
          timer += i.second;
      }
      else
      {
        cout<<"No"<<endl;
        return 0;
      }

    }

    cout<<"Yes"<<endl;

    return 0;
}

Measured memory_bytes: 6384
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
#define pi  acos(-1)
const int w=5e5+5;
const ll mod=1e9+7;
int main()
{
    int i,j;
    ll n,m;
    cin>>n>>m;
    if(n==1||m==1)
    {
        cout<<"1"<<endl;
        return 0;
    }
    ll ans=n*m;
    if(ans%2==0)
        cout<<ans/2<<endl;
    else
        cout<<ans/2+1<<endl;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import math
n = int(input())
capa = [int(input()) for _ in range(5)]
print(4+math.ceil(n/min(capa)))

"""
ans = 4 #１セキで行けた時のタイム
real_pas = 10*15+1 # i に来るまでの一隻あたりの乗客数
ship_num = 1 #　合計で何回輸送するか？= 時間
for i in range(5):
    if capa[i] > real_pas:
        pass
    else:
        ship_num = math.ceil(n/capa[i])
        real_pas = capa[i]
        #print(i,ship_num,real_pas)
print(ans+ship_num)"""

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
using namespace std;
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e6+100;
const int mod = 1e9+7;
int main() {
//	freopen(".in","r",stdin);freopen(".out","w",stdout);
	string s,t;
	int ans=0;
	cin >> s >> t;
	for(int i = 0; i < s.size(); i++) ans+=(s[i]!=t[i]);
	cout << ans;
	return 0;
}

Measured memory_bytes: 3912
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll n, k;
    cin >> n >> k;
    vector<bool> have(n, false);
    loop(i, k)
    {
        ll d;
        cin >> d;
        loop(j, d)
        {
            ll x;
            cin >> x;
            x--;
            have[x] = true;
        }
    }
    ll ans = 0;
    loop(i, n) if (!have[i]) ans++;
    putout(ans);
    return 0;
}


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

int N;
vector<vector<int> > adj;
vector<int> dep;
vector<int> par;
vector<int> sz;

void dfs(int u, int p) {
    sz[u] = 1;
    for(int i = 0; i < adj[u].size(); i++) {
        int v = adj[u][i];
        if(v == p) continue;
        dep[v] = dep[u] + 1;
        par[v] = u;
        dfs(v, u);
        sz[u] += sz[v];
    }
}

int main() {
    scanf("%d", &N);
    adj.resize(N);
    for(int i = 0; i < N - 1; i++) {
        int a, b; scanf("%d %d", &a, &b);
        a--; b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    dep = vector<int>(N, 0);
    par = vector<int>(N, -1);
    sz = vector<int>(N, 0);
    dfs(0, -1);

    int x = N - 1;
    while(dep[x] != dep[N - 1] / 2 + 1) {
        x = par[x];
    }

    if(N - sz[x] <= sz[x]) printf("Snuke");
    else printf("Fennec");
}


Measured memory_bytes: 13184
#include <iostream>
#include <cstdint>

std::int_fast64_t cube(const std::int_fast64_t x) {
  return x * x * x;
}

int main() {
  std::int_fast64_t n, k;
  std::cin >> n >> k;
  std::cout << cube(n / k) + (k % 2 == 0 ? cube((n + k / 2)/ k) : 0) << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    vector<int> a(n);
    int total=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        total+=a[i];
    }
    double ans=(double)total/(4*m);
    int ans2=0;
    for(int i=0;i<a.size();i++){
        if((double)a[i]>=ans){ans2++;}
    }
    if(ans2>=m){cout<<"Yes";}
    else{
        cout<<"No";
    }
}

Measured memory_bytes: 256