akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Robot = pair<ll, ll>;

void solve() {
    ll N;
    cin >> N;
    vector<Robot> robots(N);
    for (int i = 0; i < N; ++i) {
        ll x, l;
        cin >> x >> l;
        ll min_l = x - l;
        ll max_r = x + l;
        robots[i] = make_pair(max_r, min_l);
    }
    sort(robots.begin(), robots.end());
    int count = 0;
    ll pre_t = -3 * 100100101;
    for (int i = 0; i < N; ++i) {
        Robot robot = robots[i];
        ll t = robot.first;
        ll s = robot.second;
        if (pre_t <= s) {
            count ++;
            pre_t = t;
        }
    }
    cout << count << endl;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
// using namespace atcoder;

struct Edge {
    ll to;
    ll cost;
    Edge(ll t, ll c) {
        to = t;
        cost = c;
    }
};

typedef vector<vector<Edge>> Graph;

Graph G;
vector<int> seen;

// 1 fennec, 2 sunuke
vector<ll> c;

ll searchS(ll node, ll depth) {
    if (c[node] == 2) {
        return depth;
    }
    seen[node] = 1;
    ll res = 0;
    for (Edge e: G[node]) {
        if (seen[e.to] == 0) {
            res = max(res, searchS(e.to, depth + 1));
        }
    }

    if (res > 0) {
        if (depth <= res / 2) {
            c[node] = 1;
        }
        else {
            c[node] = 2;
        }
    }

    return res;
}


ll paint(ll node, ll v) {
    c[node] = v;
    ll res = 0;
    for (Edge e: G[node]) {
        // 未着色
        if (c[e.to] == 0) {
            paint(e.to, v);
        }
    }

    return res;
}

void Main()
{
    ll n;
    cin >> n;

    vector<ll> a(n-1), b(n-1);
    rep(i, n-1) cin >> a[i] >> b[i];
    
    G.assign(n, vector<Edge>());
    seen.assign(n, 0);
    c.assign(n, 0);
    c[0] = 1;
    c[n-1] = 2;
    rep(i, n-1) {
        G[b[i]-1].push_back(Edge{a[i]-1, 1});
        G[a[i]-1].push_back(Edge{b[i]-1, 1});
    }
    
    searchS(0, 0);

    rep(i, n) {
        if (c[i] != 0) {
            paint(i, c[i]);
        }
    }

    ll cf = 0;
    rep(i, n) {
        if (c[i] == 1) {
            cf++;
        }
    }
    ll cs = n - cf;

    if (cf <= cs) {
        put("Snuke")
    }
    else {
        put("Fennec")
    }



}
signed main(){ Main();return 0;}

Measured memory_bytes: 19236
#include<bits/stdc++.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
using namespace std;

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

    int n,m;
    cin>>n>>m;

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

    vector<int> ed[n+1];
    for(int i=1;i<=m;i++){
        int a,b;
        cin>>a>>b;

        ed[a].push_back(b);
        ed[b].push_back(a);
    }

    int ans=0;
    for(int i=1;i<=n;i++){
        if(ed[i].size()==0){
            ans++;
        }

        else{
            bool flag=true;
            for(int j=0;j<ed[i].size();j++){
                if(h[i]<=h[ed[i][j]]){
                    flag=false;
                }
            }

            if(flag){
                ans++;
            }
        }
    }

    cout<<ans<<"\n";

    return 0;
}

Measured memory_bytes: 8764
import sys
sys.setrecursionlimit(250000)

def main():
    a,b,c,d = map(int, input().split())

    a1 = max(a*c, a*d)
    a2 = max(b*c, b*d)
    print(max(a1,a2))
    # if a < 0  and b < 0 and c < 0 and d < 0 :
    #     print(a*c)
    # elif a < 0  and b < 0 and c < 0 and d >= 0 :
    #     print(a * c)
    # elif a < 0  and b < 0 and c >= 0 and d > 0 :
    #     print(b*c)
    # elif a < 0  and b > 0 and c < 0 and d < 0 :
    #     print(a*c)
    # elif a < 0  and b >= 0 and c < 0 and d >= 0 :
    #     print(max(a*c, b*d))
    # elif a < 0 and b > 0 and c > 0 and d > 0:
    #     print(b*d)
    # elif a > 0  and b > 0 and c < 0 and d < 0 :
    #     print(a*d)
    # elif a > 0  and b > 0 and c < 0 and d > 0 :
    #     print(b*d)
    # elif  a > 0  and b >0 and c > 0 and d > 0 :
    #     print(b*d)

    #
    # pairs=[]
    # for i in range(n):
    #     pairs.append(list(map(int, input().split())))
    #
    # dp =  [[0] * 10001 for i in range(101)]
    # for j in range(0, 10001):
    #     for i in range(0,n):
    #         if j >= pairs[i][1]:
    #             dp[i+1][j] = max(dp[i][j-pairs[i][1]] + pairs[i][0], dp[i][j])
    #         else:
    #             dp[i+1][j] = dp[i][j]
    #
    # print(dp[n][w])
main()


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

int main() {
  int a,b;
  cin>>a>>b;
  int ans=-1;
  for(int i=1;i<=100010;i++){
    if(i*8/100==a && i*10/100==b) ans=i;
    if(ans!=-1) break;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<map>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main() {
	int x, y, z;
	cin >> x >> y >> z;
	swap(x, y);
	swap(x, z);
	cout << x << " " << y << " " << z << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <cmath>

int main() {
    int N, M;
    scanf("%d %d", &N, &M);

    std::vector<int> a(N), b(N);
    for (int i=0; i<N; ++i)
        scanf("%d %d", &a[i], &b[i]);

    std::vector<int> c(M), d(M);
    for (int i=0; i<M; ++i)
        scanf("%d %d", &c[i], &d[i]);

    for (int i=0; i<N; ++i) {
        int s=a[i], t=b[i];

        int dist=1e9+7, res=-1;
        for (int j=0; j<M; ++j) {
            int cur=std::abs(s-c[j])+std::abs(t-d[j]);
            if (dist > cur) {
                dist = cur;
                res = j;
            }
        }

        printf("%d\n", res+1);
    }

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {

    // input
    nums := inputLineAsNumArray(3)
    A := nums[0]
    B := nums[1]
    K := nums[2]
    
    // print
    for i:=A; i<=B; i++ {
        if i < A+K || i > B-K {
            fmt.Println(i)
        }
    }
}

func inputLineAsNumArray(length int) []int {

    line := strings.Split(readLine(), " ")
    var nums []int
    for i := 0; i < length; i++ {
        num, _ := strconv.Atoi(line[i])
        nums = append(nums, num)
    }
    return nums
}

func readLine() string {

	sc.Scan()
	return sc.Text()
}

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

const int M=998244353;
const int MAX=1e5*2+5;

long long kai[MAX],kair[MAX],rev[MAX];

void com_p(){
  kai[0]=kai[1]=1;
  kair[0]=kair[1]=1;
  rev[1]=1;
  for(int i=2;i<MAX;i++){
    kai[i]=kai[i-1]*i%M;
    rev[i]=M-rev[M%i]*(M/i)%M;
    kair[i]=kair[i-1]*rev[i]%M;
  }
}
long long ncr(int n,int r){
  if(n<0||r<0) return 0;
  if(n<r) return 0;
  return kai[n]*(kair[r]*kair[n-r]%M)%M;
}

int main(){
  int n,m,k;
  cin>>n>>m>>k;
  com_p();
  long long sum=0,x=m;
  for(int i=0;i<n-k-1;i++){
    x=x*(m-1)%M;
  }
  for(int i=k;i>=0;i--){
    sum+=x*ncr(n-1,i)%M;
    sum%=M;
    x=x*(m-1)%M;
  }
  cout<<sum<<endl;
}



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

int main()
{
    /* ------- 宣言と入力 ------- */

    int N, K;

    cin >> N >> K;

    long long int H[N];

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

    /* ------- 計算 ------- */

    sort(H, H + N);

    if (K > N)
    {
        K = N;
    }

    long long int ans = 0;

    for (int i = 0; i < K; i++)
    {
        int a = N - i - 1;
        H[N - i - 1] = 0;
    }

    for (int i = 0; i < N; i++)
    {
        ans += H[i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <map>
using namespace std;
typedef long long ll;

int N;
string s = "ACGT";
ll inf = 1e9+7;
map<pair<int,string>,ll> dp;
bool ok(string S){
    if(S.size()<3) return true;
    if(S.substr(0,3)=="AGC" || S.substr(0,3)=="ACG" || S.substr(0,3)=="GAC") return false;
    if(S.size()>=4 && S.substr(1,3)=="AGC" || S.substr(1,3)=="ACG" || S.substr(1,3)=="GAC") return false;
    if(S[0]=='A' && S[2]=='G' && S[3]=='C') return false;
    if(S[0]=='A' && S[1]=='G' && S[3]=='C') return false;
    return true;
}

ll rec(int len,string S){
    if(dp.count({len,S})) return dp[{len,S}];
    if(len==N) return 1;
    ll res = 0;
//    cerr << S << endl;
    for(auto c:s){
        if(ok(S+c)){
            string next;
            if(S.size()<=2) next = S+c;
            else next = S.substr(1,2)+c;
            (res += rec(len+1,next))%=inf;
        }
    }
    return dp[{len,S}] = res;
}

int main(){
    cin >> N;
    cout << rec(0,"") << endl;
}

Measured memory_bytes: 896
#include <iostream>
#include <map>
#include <vector>

using namespace std;
int main(void){
    // Your code here!
    int N ,K ,Q;
    cin >> N >> K >> Q;
    vector<int> table(N);

    for(int i =0; i < Q; i++){
        int A;
        cin >> A;
        table[A-1]++;
    }
    
    for(int i =0; i < N; i++){
    //    cout << table[i] - Q << endl;
        if(table[i] - Q + K > 0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    int n,h,ans=0,cnt=0;
    cin >> n;
    rep(i,n){
        cin >> h;
        if(i==0){
            ans=h;
            cnt++;
        }
        else if(ans<=h){
            ans=h;
            cnt++;
        }
    }
    cout << cnt << endl;
	return 0;
}

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

int main(){
    string s;
    cin>>s;
    int l=s.length();
    bool ans=true;
    rep(i,l/2){
        if(s[i]!=s[l-i-1])ans=false;
    }
    int x=(l-1)/2;
    rep(i,x/2){
        if(s[i]!=s[l-i-1])ans=false;
    }
    int j=0;
    rep2(((l+3)/2)-1,i,l){
        if(s[i]!=s[l-1-j])ans=false;
        j++;
    }
    string a =(ans)?"Yes":"No";
    cout<<a<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(std::unique(all(x)), x.end());
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=acos(-1);
using namespace std;
vector<int> dx={1,0,-1,0};
vector<int> dy={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

struct RollingHash {
    int n;
    vector<pair<ll,ll>> vec,pw;
    ll mod1,mod2,base1,base2;
    
    RollingHash(string s) {
        srand(time(NULL));
        n=sz(s);
        vec.resize(n+1);
        pw.resize(n+1);
        pw[0]={1,1};
        
        mod1=1e9+93;
        mod2=1e9+97;
        base1=(ll)rand()%((ll)1e7+9);
        base2=(ll)rand()%((ll)1e7+9);
        rep(i,n) {
            pw[i+1].first=pw[i].first*base1%mod1;
            pw[i+1].second=pw[i].second*base2%mod2;
            vec[i+1].first=(vec[i].first*base1+(ll)s[i])%mod1;
            vec[i+1].second=(vec[i].second*base2+(ll)s[i])%mod2;
        }
    }
    
    //[l,r)
    pair<ll,ll> get(int l,int r) {
        ll fi,se;
        fi=(vec[r].first-vec[l].first*pw[r-l].first%mod1+mod1)%mod1;
        se=(vec[r].second-vec[l].second*pw[r-l].second%mod2+mod2)%mod2;
        return make_pair(fi,se);
    }
};

int main() {
    string t,p;
    cin>>t>>p;
    int n=sz(t),m=sz(p);
    t+=p;
    RollingHash rlh(t);
    rep(i,n-m+1) {
        if(rlh.get(i,i+m)==rlh.get(n,n+m)) cout<<i<<endl;
    }
    //rep(i,n) cout<<rlh.get(i,i+1).first<<" "<<rlh.get(i,i+1).second<<endl;
}



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

int main(){
	int a, b, mul;
  	double rest;
  
  	cin >> a >> b;
  	mul = a * b;
    rest = mul % 2;

	if (rest != 0){
    	cout << "Odd" << endl;
    }
  	else {
    	cout << "Even" << endl;
    }
}



Measured memory_bytes: 256
mod = 998244353
N,A,B,K = map(int,input().split())
def cmb(n,k):
    return fac[n]*inv_fac[n-k]*inv_fac[k] % mod
fac = [1]
for i in range(1,N+1):
    fac.append(fac[-1]*i % mod)
inv_fac = [pow(fac[N],mod-2,mod)]
for i in range(1,N+1)[::-1]:
    inv_fac.append(inv_fac[-1]*i % mod)
inv_fac = inv_fac[::-1]

ans = 0
for i in range(N+1):
    if i*A > K:
        break
    if (K-i*A) % B == 0:
        j = (K-i*A)//B
        if j <= N:
            ans += cmb(N,i)*cmb(N,j)
            ans %= mod
print(ans)

Measured memory_bytes: 97380
#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
const int MOD = (int)1e9 + 7;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()

int main(int argc, char const *argv[]) {
  int N;
  cin >> N;
  string S;
  cin >> S;
  int ans = 0;
  int temp = 0;
  for (size_t i = 0; i < S.size(); i++) {
    if (S[i] == 'I') {
      ans++;
    } else {
      ans--;
    }
    if (ans > temp) {
      temp = ans;
    }
  }
  cout << temp << endl;
  return 0;
}


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

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		int k = stdIn.nextInt();
		
		if(k>= b-a+1) {
			for(int i = a; i<=b;i++) {
				System.out.println(i);	
			}
			System.exit(0);
		}
		if(Math.ceil((b-a+1)/2.0) <= k){
			for(int i = a; i<=b;i++) {
				System.out.println(i);	
			}
			System.exit(0);
		
		}
		
		for(int i = a; i <a+k;i++) {
			System.out.println(i);
		}
		for(int i = b-k+1; i <= b; i++) {
			System.out.println(i);
		}
		
		
		
	}

}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple

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

const int inf = 1e9;
const ll linf = 1LL<<60;
const ll mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

int main()
{
  int n, m, c;
  cin >> n >> m >> c;

  vi b(m);
  rep(i, m) cin >> b[i];

  int ans = 0;
  rep(i, n){
    int t = c;
    rep(j, m){
      int a;
      cin >> a;
      t += a*b[j];
    }
    if(t > 0) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int llint;
typedef long int lint;
typedef vector<char> vchar;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
#define vsort(v) sort((v).begin(), (v).end())
#define vreverse(v) reverse((v).begin(), (v).end())
#define pb(a) push_back(a)
#define INF 1000000007
#define MOD 1e9+7
int main(){
  //input
  int n;cin>>n;
  vint a(n);vint b(n);
  for(int i=0;i<n;i++){
   cin>>a[i];
  }
  for(int i=0;i<n;i++){
   cin>>b[i];
  }
  //caricurate
  for(int i=1;i<n;i++){
   a[i]+=a[i-1];b[i]+=b[i-1];
  }
  int sum;int mi=a[0]+b[n-1];
  for(int i=1;i<n;i++){
    sum=a[i]+b[n-1]-b[i-1];
    mi=max(sum,mi);
  }
  //output
cout<<mi<<endl;
}

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

const int MX = 2097152;
const int HEAD = 1048575;
int A[MX], V[MX];
int n, q;

void init(int n) {
    int l = HEAD + n;
    for (int i=0; i<=l; ++i) {
        A[i] = (i < HEAD ? 1 : i - HEAD);
        V[i] = 0;
    }
    for (int i=l+1; i<MX; ++i) {
        A[i] = INT_MAX;
        V[i] = -INT_MAX;
    }
}

void update(int a, int v) {
    int k = HEAD + a;
    V[k] += v;
    while (k) {
        k = (k - 1) / 2;
        int l = 2*k+1, r = 2*k+2;
        if (V[l] < V[r] || (V[l] == V[r] && A[l] > A[r])) {
            V[k] = V[r];
            A[k] = A[r];
        } else {
            V[k] = V[l];
            A[k] = A[l];
        }
    }
}

int main() {
    cin >> n >> q;
    init(n);
    int a, v;
    for (int i=0; i<q; ++i) {
        cin >> a >> v;
        update(a, v);
        cout << A[0] << " " << V[0] << endl;
    }
    return 0;
}

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

const int N = 1e5 + 2;
int arr[N];

int main()
{
 int n, t, mx = 0;
 cin >> n;
 for (int i = 0 ; i < n; ++i)
 {
   cin >> t;
   t++;
   arr[t - 1]++;
   arr[t]++;
   arr[t + 1]++;
 }
 for(int x : arr)
   mx = max(mx, x);
  cout << mx;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <limits>
#include <string>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n); i > 0; i--)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
using namespace std;
using lint = long long;
using P = pair<int, int>;
using V = vector<int>;
constexpr int MOD = 1e9 + 7;

const V dy = {-1, 0, 1, 0};
const V dx = {0, -1, 0, 1};

int A, B, C, F, H, I, J, K, L, M, N, S, T, U, W;
// lint A, B, F, H, I, J, K, L, M, N, S, T, U, W;
// string A, B;
int ans = 0;
// string ans;

vector<vector<char>> maze;
vector<V> distances;

int search(int sy, int sx) {
	queue<V> que;
	que.push({sy, sx});
	
	while (!que.empty()) {
		int y = que.front().at(0);
		int x = que.front().at(1);
		que.pop();
		
		rep(i, 4) {
			int ny = y + dy.at(i);
			int nx = x + dx.at(i);
		
			if (distances[ny][nx] == -1 && maze[ny][nx] == '.') {
				que.push({ny, nx});
				distances[ny][nx] = distances[y][x] + 1;
				ans = max(ans, distances[ny][nx]);
			}
		}
	}
}

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

	cin >> H >> W;
	
	maze.assign(H + 2, vector<char>(W + 2, '#'));
	rep1(r, H) {
		rep1(c, W) {
		cin >> maze[r][c];
		}
	}
	
	rep1(r, H) {
		rep1(c, W) {
			if (maze[r][c] == '#') continue;
			distances.assign(H + 2, V(W + 2, -1));
			distances[r][c] = 0;
			search(r, c);
		}
	}

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

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

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

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
    INIT;
    ll A, B;
    cin >> A >> B;

    if (A + B >= 24) {
        cout << A + B - 24 << endl;
    } else {
        cout << A + B << endl;
    }

    return 0;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N;
  while (cin >> N) {
    vector<ll> A(N);
    for (auto& x : A) cin >> x;
    set<ll> S(A.begin(), A.end());
    bool res = S.size() == N;
    cout << (res ? "YES" : "NO") << endl;
  }
  return 0;
}


Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
const double inf=1e9;
typedef long long ll;
typedef pair<ll,ll>pr;
const ll mod=1e9+7;
ll _pow(ll  a,ll b) {
    ll ans=1;
    while(b) {
        if(b&1)
            ans=ans*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return ans;
}

int main(){
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ll l,r;
  cin>>l>>r;
  if(r-l>=2019){
    cout<<"0"<<endl;
  }
  else{
    ll ans=0x3f3f3f3f;
    for(ll i=l;i<=r;i++){
      for(ll j=i+1;j<=r;j++){
        ans=min(ans,(ll)((i*j)%2019));
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define PI acos(-1)

int main(void)
{
    double rad,a,b,c,s,l,h;
    
    scanf("%lf %lf %lf",&a,&b,&c);
    rad=c*PI/180;
    
    h=b*sin(rad);
    s=a*h/2;
    l=a+b+sqrt(pow(a,2)+pow(b,2)-2*a*b*cos(rad));
    
    printf("%f\n %f\n %f\n",s,l,h);
    return 0;
}


Measured memory_bytes: 2128
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var array = Console.ReadLine().Split().ToArray();
            var S = array[0];
            var T = array[1];

            var numArray = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var A = numArray[0];
            var B = numArray[1];

            var U = Console.ReadLine();


            if (U == S)
            {
                Console.WriteLine($"{A - 1} {B}");
            }
            else
            {
                Console.WriteLine($"{A} {B - 1}");
            }
        }
    }
}


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

int main()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  bool chk = false;

  if( abs( c - a ) <= d ) {
    chk = true;
  }
  if( abs( b - a ) <= d and abs( c - b ) <= d ) {
    chk = true;
  }

  cout << ( chk ? "Yes" : "No" ) << endl;
  return 0;
}


Measured memory_bytes: 256
s = input()
n = len(s)
ans_li = [0]*n

stock = 0
#R
for i in range(n-1):
  if s[i] == 'R':
    stock += 1
    if s[i+1] == 'L':
      ans_li[i] = (stock+1)//2
      ans_li[i+1] = stock //2
  else:
    stock = 0 #'L'->'RL'だからリセット
stock = 0
#L
rev_s = list(reversed(s))
for i in range(n-1):
  if rev_s[i] == 'L':
    stock += 1
    if rev_s[i+1] == 'R':
      ans_li[(i+1)*-1] += (stock+1)//2
      ans_li[(i+2)*-1] += stock//2
  else:
    stock = 0

print(*ans_li)

Measured memory_bytes: 7168
#include<bits/stdc++.h> 
using namespace std;
 
typedef long long int ll;
typedef pair<int,int> pii;

#define ff first
#define ss second
#define vi vector<int>
#define fo(n) for(int i = 0;i < int(n);i++)
#define foo(a,b) for(int i = int(a);i <= int(b);i++)
#define mk make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define fastio ios_base:: sync_with_stdio(false)


const int MAXN = 1e6;
const int mod = 1e9 + 7;
const int inf = 1e9;



int main(){

	
	fastio;
	string str;

	cin >> str;

	for(int i = 1;i < str.size();i++){
		if(str[i] == str[i-1]){
			cout << "Bad" << endl;
			return 0;
		}
	}

	cout << "Good" << endl;
	return 0;
 }	

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

typedef long double ld;
typedef unsigned long ul;
typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long> vl;
typedef vector<double> vd;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define ALL(a) (a).begin(),(a).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

#define pi 3.14159265358979
#define eps 1e-9
#define inf 1<<30
#define MOD 1000000007 // 1e9+7

int main()
{
  long A, B, C;
  cin >> A >> B >> C;

  cout << B + min(A+B+1, C) << endl;

  return 0;
}



Measured memory_bytes: 764
#include<stdio.h>
int main(){
  int S,h,m,s;
	
	scanf("%d",&S);
	
	h=S/3600;
	m=S%3600/60;
	s=S%60%60;
	
	printf("%d:%d:%d\n",h,m,s);
	
	return 0;


}

Measured memory_bytes: 592
#include<stdio.h>
int main()
{
	int a, b, c, s, p;
	scanf("%d%d%d", &a, &b, &c);
	s = a - b;
	p = c - s;
	if (p < 0)
	{
		printf("0");
	}
		else
		{
			printf("%d\n", p);
		}
		 return 0;
	}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=1e9+7;
inline void read(int &x)
{
	x=0;int p=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')p=-p;ch=getchar();}
	while(ch>='0'&&ch<='9')x=(x<<1)+(x<<3)+(ch-'0'),ch=getchar();
	x=x*p;
}
int n,x[300005],y[300005],dp[4505][4505],fact[20005],inv[20005];
int qpow(int x,int y)
{
	int ans=1;
	while(y)
	{
		if(y&1)ans=ans*x%mod;
		x=x*x%mod;
		y>>=1;
	}
	return ans;
}
int C(int x,int y)
{
	if(x<y)return 0;
	return fact[x]*inv[y]%mod*inv[x-y]%mod;
}
signed main()
{
	fact[0]=1;for(int i=1;i<=20000;++i)fact[i]=fact[i-1]*i%mod;
	inv[20000]=qpow(fact[20000],mod-2);
	for(int i=19999;i>=0;--i)inv[i]=inv[i+1]*(i+1)%mod;
	read(n);
	for(int i=1;i<=n;++i)
	{
		read(x[i]);read(y[i]);
		dp[-x[i]+2002][-y[i]+2002]++;
	}
	for(int i=1;i<=4100;++i)
	{
		for(int j=1;j<=4100;++j)
		{
			dp[i][j]+=dp[i-1][j];
			dp[i][j]+=dp[i][j-1];
			dp[i][j]%=mod;
		}
	}
	int ans=0;
	for(int i=1;i<=n;++i)
	{
		ans+=dp[x[i]+2002][y[i]+2002];
		ans-=C(2*(x[i]+y[i]),2*x[i]);
		ans%=mod;ans+=mod;ans%=mod;
	}
	ans=ans*qpow(2,mod-2)%mod;
	cout<<ans<<endl;
}

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

void print(int A[],int N){
  for(int i=0;i<N;i++) {
    if(i!=0)cout<<" ";
    cout<<A[i];
  }
  cout<<endl;
}

void insertionSort(int A[],int N){
  
  for(int i=1;i<N;i++){
    int v=A[i];
    int j=i-1;
    while(j>=0&&A[j]>v){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;    
    print(A,N);
  }
}

int main(){
  int N;
  int A[1000];
  
  cin>>N;
  
  for(int i=0;i<N;i++) cin>>A[i];
  
  print(A,N);
  insertionSort(A,N);
  
  return 0;
}

Measured memory_bytes: 1164
from collections import deque

inf = float('inf')

N, M = map(int, input().split())

es = [[] for _ in range(N * 3)]
# 有向グラフ

for _ in range(M):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    # 0-indexed
    es[u].append(v + N)
    es[u + N].append(v + N * 2)
    es[u + N * 2].append(v)

S, T = map(int, input().split())
S -= 1
T -= 1

dq = deque([(S, 0)])
dist = [inf] * (N * 3)
dist[S] = 0

while dq:
    v, c = dq.popleft()
    nc = c + 1
    for nv in es[v]:
        if nc < dist[nv]:
            dist[nv] = nc
            if v == T:
                break
            dq.append((nv, nc))

if dist[T] == inf:
    print(-1)
else:
    print(dist[T] // 3)

# print(dist)


Measured memory_bytes: 91812
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
using namespace std;
#define N 11000000
#define INF 0x3f3f3f3f
#define M 7031004
struct node{
	int to,next,res;
}q[M];
int head[22003],ss,prm[N],dep[23104],ct,a[N],S,T,que[20310],h[20310],cir[20104];bool ip[N];
void addedge(int x,int y,int r)
{
	q[++ss]=(node){y,head[x],r};head[x]=ss;
	q[++ss]=(node){x,head[y],0};head[y]=ss;
}
bool bfs()
{
	memset(dep,0,sizeof(dep));
	memcpy(cir,head,4*(T+10));
	dep[S]=1;
	int f=1,e=0;
	que[++e]=S;
	while(f<=e)
	{
		int u=que[f++];
		for (int j=head[u];~j;j=q[j].next)
			if (q[j].res&&!dep[q[j].to])
			{
				int t=q[j].to;
				dep[t]=dep[u]+1;
				que[++e]=t;
			}
	}
	return dep[T]>0;
}
int dfs(int i,int flow)
{
	if (i==T||!flow) return flow;
	int f,dist=0;
	for (int &j=cir[i];~j;j=q[j].next)
		if (dep[q[j].to]==dep[i]+1&&q[j].res&&(f=dfs(q[j].to,min(q[j].res,flow-dist))))
		{
			dist+=f;
			q[j].res-=f;
			q[j^1].res+=f;
		}
	return dist;
}
int dinic()
{
	int ans=0;
	while(bfs()) ans+=dfs(S,INF);
	return ans;
}
int main()
{
	int n,TT=1,c=0,ans=0,odd;
	ip[1]=true;ip[0]=true;
	for (int i=2;i<=10000000;++i)
	{
		if (!ip[i]) prm[++ct]=i;
		for (int j=1,to;j<=ct&&(to=i*prm[j])<=10000000;++j)
		{
			ip[to]=true;
			if (i%prm[j]==0) break;
		}
	}
	ip[2]=true;
	a[0]=-INF;
	while(TT--)
	{
		scanf("%d",&n);c=0;ss=-1;odd=0;
		memset(head,-1,sizeof(head));
		for (int i=1;i<=n;++i)
		{
			scanf("%d",&a[i]);
			if (a[i]!=a[i-1]+1) h[++c]=a[i];
			h[a[i]==a[i-1]+1?c:++c]=a[i]+1;
		}
		T=c+1;
		for (int i=1;i<=c;++i)
			if (h[i]&1)
			{
				addedge(S,i,1);++odd;
				for (int j=1;j<=c;++j)
				{
					int dis=abs(h[j]-h[i]);
					if (!ip[dis]) addedge(i,j,1);
				}
			}else addedge(i,T,1);
		ans=dinic();
		c-=odd;odd-=ans;
		printf("%d\n",ans+(odd/2*2)+(c-ans)/2*2+(odd&1?3:0));
	}
	return 0;
}

//by qlwpc

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 1e9+7;


int main(){
	//ios_base::sync_with_stdio(false);
	ll X, Y, Z;
	ll A[100005], B[100005], C[100005];

	cin >> X >> Y >> Z;
	int N = X+Y+Z;
	rep(i,N){
		cin >> A[i] >> B[i] >> C[i];
	}

	vector<pll> v;
	rep(i,N) v.emplace_back( A[i]-B[i], i );
	sort(all(v));

	// cout << "------" << endl;
	// rep(k,N){
	// 	int i = v[k].Y;
	// 	cout << A[i] << " " << B[i] << " " << C[i] << endl;
	// }
	// cout << "------" << endl;

	ll sum[100005] = {};
	rep(i,N) sum[i+1] = sum[i] + C[v[i].Y];

	ll dp[2][100005]={};
	// Y, Z
	{
		priority_queue<ll, vector<ll>, greater<ll>> que;
		ll sumC = 0, sumB = 0;
		rep(k,N-X){
			int i = v[k].Y;
			que.push( B[i] - C[i] );
			sumB += B[i] - C[i];
			if( k >= Y ){
				sumC += que.top();
				que.pop();
			}
			// cout << "k=" << k << " " << sum[k+1] << "+" << sumB << "-" << sumC << endl;
			chmax(dp[0][k], sum[k+1] + sumB - sumC);
		}
	}
	// X, Z
	{
		priority_queue<ll, vector<ll>, greater<ll>> que;
		ll sumC = 0, sumA = 0;
		rrep(k,N) if( k >= Y ){
			int i = v[k].Y;
			que.push( A[i] - C[i] );
			sumA += A[i] - C[i];
			if( k < N-X ){
				sumC += que.top();
				que.pop();
			}
			chmax(dp[1][k], sum[N] - sum[k] + sumA - sumC);
		}
	}

	// rep(i,N) cout << dp[0][i] << " "; cout << endl;
	// rep(i,N) cout << dp[1][i] << " "; cout << endl;

	ll ans = 0;
	reps(i,Y-1,N-X) chmax(ans, dp[0][i] + dp[1][i+1]);

	cout << ans << endl;

	return 0;
}

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

int main()
{
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;

	if (x - r<0 || x + r>W || y - r<0 || y + r>H)cout << "No" << endl;
	else cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 3096
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n;
  cin>>n;
  
  vector<char> A;
  ll m=n;
  while(m>0){
    if(m%26==0){
      A.push_back('z');
      m-=26;
    }
    else{
      A.push_back((m%26)+'a'-1);
      m-=m%26;
    }
    m/=26;
  }
  reverse(ALL(A));
  rep(i,A.size()) cout<<A[i];
  cout<<endl;
  
  return 0;
}

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

struct node {
  struct node *prev;
  int key;
  struct node *next;
};

typedef struct node *NodePointer;

void insert(int);
void delete(NodePointer);
void listprint(void);
NodePointer make_1node(int, NodePointer,NodePointer);

NodePointer head;
NodePointer tail;

int list_count=0;

int main() {
    NodePointer n;
    char command[12];
    int count,num,time=0,flag=0;
    char command_list[4][12]={{"insert"},{"delete"},{"deleteFirst"},{"deleteLast"}};
    head = make_1node(0,NULL,NULL);
    tail = make_1node(0,head,NULL);
    head->next = tail;
    
    scanf("%d",&count);
    while(count>0){
        count--;
        scanf("%s",command);

        if(strcmp(command,command_list[0]) == 0) { //insert
            scanf("%d",&num);
            insert(num);
            list_count++;
        }

        else if(strcmp(command,command_list[1]) == 0) { // delete
            scanf("%d",&num);
            for(n =head->next; n != tail; n=n->next){
                if(n->key == num){
                    n->prev->next = n->next;
                    n->next->prev = n->prev;
                    delete(n);
                    break;
                }
            }
        }
            
        else if(strcmp(command,command_list[2]) == 0) { //deleteFirst
            n = head->next;
            head->next = n->next;
            head->next->prev = head;
            delete(n);
        }
            
        else if(strcmp(command,command_list[3]) == 0) { // deleteLast
            n = tail->prev;
            tail->prev = n->prev;
            tail->prev->next = tail;
            delete(n);
        }
        
    }
    for(n=head->next; n != tail->prev; n=n->next)printf("%d ",n->key);
    printf("%d\n",n->key);
  
    return 0;
}

void insert(int num) {
    NodePointer newnode = make_1node(num, head, head->next);
    head->next->prev = newnode;
    head->next = newnode;
}

NodePointer make_1node(int num, NodePointer pre,NodePointer nex) {
    NodePointer n;

    if ((n = (NodePointer)malloc(sizeof(struct node))) == NULL) {
    printf("Error in memory allocation\n");
    exit(8);
    }
    
    n->key = num;
    n->next = nex;
    n->prev = pre;
    return n;
}

void delete(NodePointer n) {
    list_count--;
    free(n);
}



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

int main(){
  int a,b;
  cin >> a >> b;
  int x,y;
  if(a%2==0){
    x=(a*25)/2;
    y=(((a+1)*25)/2);
  }else{
    x=((a*25)/2)+1;
    y=(((a+1)*25)/2)-1;
  }
  bool frag=false;
  int ans=0;
  for(int i=x;i<=y;i++){
    if(i/10==b){
      frag=true;
      ans=i;
      break;
    }
  }
  if(frag==false){
    cout << -1 << endl;
  }else{
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<cmath>
#include<map>
typedef long long int ll;
using namespace std;
typedef pair<int64_t,int64_t> P;

int main(){
    string str;
    cin >> str;
    int size=str.size();
    int num_p=0;
    for(int i=0;i<size;i++){
        if(str[i] == 'p'){
            num_p++;
        }
    }
    int p=size/2;
    cout << p - num_p << endl;
    
    return 0;
}


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

using namespace std;

//------------------------------- Libraries --------------------------------//

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//akari : 1D, yukari : 2D, maki : 3D vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//akane : ascending order, aoi : decending order
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    int n;
    cin >> n;
    akari<int> as(n);
    for (int &a : as)
        cin >> a;
    cin >> n;
    akari<int> bs(n), ans;
    for (int &b : bs)
        cin >> b;
    set_symmetric_difference(as.begin(), as.end(), bs.begin(), bs.end(), inserter(ans, ans.end()));
    for (int a : ans)
    {
        cout << a << '\n';
    }
}

int main()
{
    solve();
    return 0;
}



Measured memory_bytes: 6444
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;

int main() {
    int x;
    cin >> x;
    ll ans=0;
    ans+=x/500*1000;
    x-=500*(x/500);
    ans+=x/5*5;
    cout << ans << endl;
}


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

using namespace std;

#define ll long long

int main()
{
    int h,n;
    cin>>h>>n;
    int a[n];
    int sum = 0;
    for(int i = 0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    if(sum>=h)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
}

Measured memory_bytes: 640
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,M;
	int a[100],b[100];
	bool miti[9][9]={};
	scan(N);scan(M);
	rep(i,M){
		scan(a[i]);scan(b[i]);
		miti[a[i]][b[i]]=true;
		miti[b[i]][a[i]]=true;
	}
	vint p;
	int ans=0;
	rep1(i,N) p.push_back(i);
	while(1){
		if(p[0]!=1) break;
		int flag=1;
		rep(i,p.size()-1){
			if(miti[p[i]][p[i+1]]==false){
				flag=0;
			}
		}
		ans+=flag;
		next_permutation(p.begin(),p.end());
	}
	prin(ans);


	return 0;
}


Measured memory_bytes: 256
// Author -> Preeyadarshee Dev
//
// train hard win easy :D
// nik is love
// nik is motivation
//
// do modulo operations very carefully
// try to avoid binary search, use linear search preferrably to make calculations easier
// always make your custom binary search and watch out for overflows
// read the problems carefully
// never rely on floating point calculation
#include<bits/stdc++.h>
#define mp                    make_pair
#define pb                    push_back
#define ll                    long long
#define ss                       second
#define ff                        first
#define fr(i,a,b)   for(ll i=a;i<b;i++)
#define f(i,n)                fr(i,0,n)
#define rf(i,b,a) for(ll i=b-1;i>=a;i--)
#define r(i,n)                rf(i,n,0)
#define inf                   1000000007
#define eps                   0.000000000000001
#define endl                        '\n'
#define sz(a)                int((a).size())
#define all(c)               (c).begin(),(c).end()
#define tr(c,i)              for(typeof(c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x)         ((c).find(x) != (c).end())
#define cpresent(c,x)        (find(all(c),x) != (c).end())
#define pi                   pair<int,int>
#define pll                  pair < ll , ll >
#define PI                   3.141592653589793238462643383279502884197169399375105820974944592307816406286
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef vector< int > vi;
typedef vector< vi > vvi;
int dx[8]={1,-1,0,0,-1,-1,1,1};
int dy[8]={0,0,-1,1,-1,1,-1,1};
vector<int> adj[100010],vis(100010,0),dis(100010,0),par(100010,0);

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //ifstream fin;
    //ofstream fout;
    //fin.open("input.txt");
    //fout.open("output.txt");
    int n;
    cin>>n;
    map<string,ll> mt;
    for(int i=0;i<n;i++)
    {
        string str;
        cin>>str;
        sort(all(str));
        mt[str]++;
    }
    ll cnt=0;
    auto itr=mt.begin();
    while(itr!=mt.end())
    {
        cnt=cnt+(itr->ss*(itr->ss-1))/2;
        itr++;
    }
    cout<<cnt<<endl;
}


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

int main() {

  int w,n;
  cin >> w >> n;

  int num[30];
  for ( int i = 0; i < w; i++ ) {
    num[i] = i;
  }

  for ( int i = 0; i < n; i++ ) {

    int a,b;
    char c;
    cin >> a >> c >> b;
    int k;
    k = num[a-1];
    num[a-1] = num[b-1];
    num[b-1] = k;

  }

  for ( int i = 0; i < w; i++ ) {
    cout << num[i]+1 << endl;
  }

  return 0;

}

Measured memory_bytes: 1160
#include <cstdio>

const int kNLmt = 10000;
const int kQLmt = 500;

int main() {
  int n, ns[kNLmt], q, qs[kQLmt], bag[kQLmt];
  for (int i = 0; i < kQLmt; i++) bag[i] = -1;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &ns[i]);
  scanf("%d", &q);
  for (int i = 0; i < q; i++) scanf("%d", &qs[i]);

  int cnt = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < q; j++) {
      if (ns[i] == qs[j]) {
        bool isNew = false;
        for (int k = 0; k < kQLmt; k++) {
          if (bag[k] == ns[i]) break;
          if (bag[k] == -1) {
            isNew = true;
            break;
          }
        }
        if (isNew) bag[cnt++] = ns[i];
      }
    }
  }
  printf("%d\n", cnt);
  return 0;
}



Measured memory_bytes: 2772
n, m = map(int, input().strip().split())
list = []
count = 0
a = input().split()
for i in range(0, len(a)):
    list.append(int(a[i]))
sum1 = sum(list)
required = (1/(4*m))*sum1
for item in list:
    if item>=required:
        count = count + 1
if count>=m:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3188
#include <stdio.h>
#include <string.h>


int main()
{
	int n,m,i,j,k,l,flag;
	char a[50][50],b[50][50];

	scanf("%d%d",&n,&m);

    for (i = 0; i < n; ++i)
    {
    	scanf("%s",a[i]);
    }
	for (i = 0; i < m; ++i)
    {
    	scanf("%s",b[i]);
    }
    

    for (k = 0; k+m-1 <= n ; ++k)
    {
    	for (l = 0; l+m-1 <= n; ++l)
        {
        	flag = 0;
		    for (i = 0; i < m ; ++i)
		    {
		    	for (j = 0; j < m; ++j)
		    	{
		    		if(a[k+i][l+j] != b[i][j]){
		    			flag = 1;
		                break;
		    		}
		    	}
		    	if(flag == 1){
	                break;
		    	}
		    }
		    if(flag == 0)
		    {
                printf("Yes\n");
                return 0;
		    }
		}
	}
	printf("No\n");
	return 0;
}

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

#define op operator
#define pb push_back

struct poi {
	int x, y, z;
	poi op -(poi p) {
		return {x - p.x, y - p.y, z - p.z};
	}
	poi op +(poi p) {
		return {x + p.x, y + p.y, z + p.z};
	}
	bool op <(poi p) const {
		return tie(x, y, z) < tie(p.x, p.y, p.z);
	}
	vector <poi> rot() {
		int a[3] = {x, y, z};
		vector <poi> v;
		int p[3] = {0, 1, 2};
		do {
			int inv = (p[0] > p[1]) + (p[0] > p[2]) + (p[1] > p[2]);
			int x = a[p[0]], y = a[p[1]], z = a[p[2]];
			if(inv & 1) {
				v.pb({-x, y, z});
				v.pb({x, -y, z});
				v.pb({x, y, -z});
				v.pb({-x, -y, -z});
			} else {
				v.pb({x, y, z});
				v.pb({x, -y, -z});
				v.pb({-x, y, -z});
				v.pb({-x, -y, z});
			}
		}while(next_permutation(p, p + 3));
		return v;
	}
};

const int N = 1001;
bool v[N];
poi save[N];
vector <pair <poi, poi>> segs[2];

vector <pair <poi, poi>> read(int n) {
	poi p = {0, 0, 0};
	memset(v, 0, sizeof v);
	vector <pair <poi, poi>> r;
	for(int i = 0; i < n; i ++) {
		string s; cin >> s;
		if(s[0] == '+' || s[0] == '-') {
			poi q;
			if(s[1] == 'x')
				q = {1, 0, 0};
			else if(s[1] == 'y')
				q = {0, 1, 0};
			else
				q = {0, 0, 1};
			if(s[0] == '+')
				q = p + q;
			else
				q = p - q;
			r.pb({p, q});
			p = q;
		} else {
			int x = stoi(s);
			if(v[x])
				p = save[x];
			else {
				v[x] = 1;
				save[x] = p;
			}
		}
	}
	return r;
}

set <poi> st;
bool check(poi p) {
	bool v[24];
	memset(v, true, sizeof v);
	for(auto seg : segs[1]) {
		auto a = (seg.first - p).rot();
		auto b = (seg.second - p).rot();
		for(int i = 0; i < 24; i ++) {
			if(v[i] && !st.count(a[i] + b[i]))
				v[i] = false;
		}
		if(!count(v, v + 24, true))
			return false;
	}
	return count(v, v + 24, true);
}

int main() {
	ios :: sync_with_stdio(false);
	int n, m;
	while(cin >> n) {
		if(n == 0) break;
		segs[0] = read(n);
		cin >> m;
		segs[1] = read(m);

		st.clear();
		for(auto seg : segs[0]) {
			poi p = seg.first - segs[0][0].first;
			poi q = seg.second - segs[0][0].first;
			st.insert(p + q);
		}

		bool f = false;
		for(auto seg : segs[1])
			f |= check(seg.first) || check(seg.second);
		cout << (f ? "SAME" : "DIFFERENT") << '\n';
	}
	return 0;
}

Measured memory_bytes: 3116
#include<iostream>
#include<cmath>
#include<vector>
int main()
{
	std::vector<bool>is_prime(104728, true);
	const int root = static_cast<int>(floor(sqrt(104729)));
	for (int i = 0; i <= root - 2; i++)
	{
		if (is_prime[i])
		{
			for (int j = i + 2; (i + 2) * j < 104729; j++)
			{
				is_prime[(i + 2) * j - 2] = false;
			}
		}
	}
	for (int n; std::cin >> n;)
	{
		if (n == 0)
		{
			break;
		}
		int sum = 0, cnt = 0;
		for (int i = 0; ; i++)
		{
			if (is_prime[i])
			{
				sum += i + 2;
				if (++cnt == n)
				{
					std::cout << sum << std::endl;
					break;
				}
			}
		}
	}
	return 0;
}


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

int main(){
  string S;
  cin >> S;
  
  if (S == "Sunny"){
    cout << "Cloudy" << endl;
  }
  else if (S == "Cloudy"){
    cout << "Rainy" << endl;
  }
  else{
    cout << "Sunny" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

int main(){
    vector<int> a(5);
    REP(i,5){
        cin>>a[i];
    }
    ll ans = INF;
    do{
        ll time = 0;
        REP(i,4){
            if(a[i]%10 == 0){
                time += a[i];
            }
            else{
                time += (a[i]/10+1) * 10;
            }
        }
        ans = min(time+a[4],ans);

    }while(next_permutation(a.begin(),a.end()));
    cout<<ans<<endl;
}

Measured memory_bytes: 256