akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N,cnt=0;cin>>N;
    int H[100];
    for(int i = 0; i < N; i++)
    {
        cin>>H[i];
    }

    for(int i = 1; i < N; i++)
    { int hoge=0;
        for(int j = 0; j < i; j++)
        {   
            hoge=max(H[j],hoge);}
            
           if (H[i]>=hoge) {
               cnt++;
           }
           
           
            }
            
            
            
        
        cout<<cnt+1<<endl;
        
    }
    
    

Measured memory_bytes: 256
N,K=map(int,input().split())
S=list(input())

if S[K-1]=='A':
  S[K-1]='a'
elif S[K-1]=='B':
  S[K-1]='b'
elif S[K-1]=='C':
  S[K-1]='c'

S=''.join(S)
print(S)

Measured memory_bytes: 2940
#include <iostream>
#include <string>

using namespace std;

// 二分探索　バイナリーサーチ
// バイナリーサーチは、データがソートされている必要がある。しかしO(n)で検索できる。

const int N_MAX = 100000;
const int Q_MAX = 50000;


// 見つかったらtrue
bool binarySearch(int *A, int N, int key)
{
    int left = 0;
    int right = N; // rightは末尾の次を指す。
    while (left < right)
    {
        int mid = (left + right) / 2;
        if (key == A[mid])
//            return A[mid];
            return true;
        else if (key < A[mid])
            right = mid;
        else
            left = mid + 1;
    }
    return false;
}

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


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

    int q;
    cin >> q;
    int T[Q_MAX] = { 0 };
    for (int i = 0; i < q; i++)
        cin >> T[i];

    int inCount = 0;
    for (int i = 0; i < q; i++)
    {
        if (binarySearch(S, n, T[i]))
            inCount++;
    }

    cout << inCount << endl;

    return 0;
}


Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define sortr(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define max 100005
#define nil -1

struct node
{
   int p,l,r;
};

node t[max];
int n,d[max];

void print(int u){
    int c;
    cout<<"node "<<u<<": ";
    cout<<"parent = "<<t[u].p<<", ";
    cout<<"depth = "<<d[u]<<", ";

    if(t[u].p==nil){
        cout<<"root, ";
    }
    else if(t[u].l==nil){
        cout<<"leaf, ";
    }
    else{
        cout<<"internal node, ";
    }

    cout<<"[";

    for(int i=0,c=t[u].l;c!=nil;i++,c=t[c].r){
        if(i){
            cout<<", ";
        }
        cout<<c;
    }
    cout<<"]"<<endl;
}

void rec(int u,int p){
    d[u]=p;
    if(t[u].r!=nil){
        rec(t[u].r,p);
    }
    if(t[u].l!=nil){
        rec(t[u].l,p+1);
    }
}

int main() {
   int d,v,c,l,root;
   cin>>n;
   for(int i=0;i<n;i++){
       t[i].p=t[i].l=t[i].r=nil;
   }
   for(int i=0;i<n;i++){
       cin>>v>>d;
       for(int j=0;j<d;j++){
           cin>>c;
           if(j==0){
               t[v].l=c;
           }
           else{
               t[l].r=c;
           }
           l=c;
           t[c].p=v;
       }
   }
   for(int i=0;i<n;i++){
       if(t[i].p==nil){
           root=i;
       }
   }

   rec(root,0);

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



Measured memory_bytes: 7768
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include <cstdio>
#include <cmath>
#include <algorithm>

using namespace std;

/**
 * amazingly fast input
 */
const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
  if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
  return *ci++;
}
inline int getint() {
  int A = 0;
  if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
  else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
  return A;
}
inline void flus() {
  while (getcha() != ' ');
}

/**
 * main
 */
int main () {
  double A = getint();
  double B = getint();
  double C = getint();
  double X = getint();

  int ans = 0;
  int a_max = min(floor(X / 500), A);
  for (int a = 0; a <= a_max; a++) {
    int b_min = max( ceil(X / 100 - 5 * a - C / 2), 0.0);
    int b_max = min(floor(X / 100 - 5 * a), B);
    ans += (b_max >= b_min) ? b_max - b_min + 1 : 0;
  }

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


Measured memory_bytes: 128
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();

      int h = sc.nextInt();
      int m = sc.nextInt();

      long mins = h * 60 + m;

      double fen = mins * 6 % 360;
      double shi = mins * 0.5 % 360;
      double diff = ((shi - fen + 360) % 360);

      double res = 0.0;
      if(diff == 0) {
        System.out.println(Math.abs(a - b));
        return;
      }
      else if(diff == 180) {
        System.out.println(a + b);
        return;
      } else if(diff > 180) {
        diff = 360 - diff;
      }
      
      double res2 = a * a + b * b - 2.0 * a * b * Math.cos(Math.toRadians(diff));
      System.out.println(Math.sqrt(res2));
  }
}

Measured memory_bytes: 27200
a=input()
ans=0
k=0
t=1
n=0
for i in range(len(a)):
  if t:
    if a[i]=="<":
      ans+=k
      k+=1
    else:
      n+=1
      t=0
  else:
    if a[i]==">":
      n+=1
    else:
      ans+=n*(n-1)//2
      ans+=max(k,n)
      n=0
      k=1
      t=1
if a[-1]=="<":
  ans+=k
else:
  ans+=n*(n-1)//2
  ans+=max(k,n)
print(ans)
      
    

Measured memory_bytes: 43628
use proconio::input;

fn main() {
    input! {
        n: String
    }
    let mut ans: u64 = 0;
    for c in n.chars() {
        let num = c as u64 - 48;
        ans += num;
    }
    if ans % 9 == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}


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


const int mod = 1000000007;

// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};


const int MOD = 1000000007;
using mint = Fp<MOD>;

long myPow(long x, long n, long m ){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

int main(){
    int N , a , b ;
    cin >> N >> a >> b  ;
    mint ansa = 1 ;
    mint ansb = 1 ;
    for(int i = 0 ; i < a ; i++ ){
        ansa *= (mint) N - i ;
        ansa /= (mint) a - i ;
    }
    for(int i = 0 ; i < b ; i++ ){
        ansb *= (mint) N - i ;
        ansb /= (mint) b - i ;
    }
    int answer =  myPow(2,N,mod) ;
    mint ans = answer ;
    cout << ans - ansa - ansb - 1 << endl; 
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long a, b, k;
  cin>>a>>b>>k;
  if(k <= a){
    a -= k;
    k = 0;
  }
  else{
    k -= a;
    a = 0;
  }
  if(k <= b){
    b -= k;
    k = 0;
  }
  else{
    k -= b;
    b = 0;
  }
  cout<<a<<" "<<b<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct edge{
    ll to, cost;
};


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

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    char a;
    cin>>a;
    for(ll i='a';i<='z';++i){
        if(a == i){
            cout<<'a'<<endl;
            return 0;
        }
    }
    cout<<'A'<<endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
double INF = 1000000000000000;
double dist(pair<double, double> P, pair<double, double> Q){
  return sqrt(pow(Q.first - P.first, 2) + pow(Q.second - P.second, 2));
}
int main(){
  cout << fixed << setprecision(20);
  double xs, ys, xt, yt;
  cin >> xs >> ys >> xt >> yt;
  int N;
  cin >> N;
  vector<double> x(N), y(N), r(N);
  for (int i = 0; i < N; i++){
    cin >> x[i] >> y[i] >> r[i];
  }
  x.push_back(xs);
  y.push_back(ys);
  r.push_back(0);
  x.push_back(xt);
  y.push_back(yt);
  r.push_back(0);
  N += 2;
  vector<vector<pair<double, int>>> E(N);
  for (int i = 0; i < N; i++){
    for (int j = i + 1; j < N; j++){
      pair<double, double> P = make_pair(x[i], y[i]);
      pair<double, double> Q = make_pair(x[j], y[j]);
      double d = dist(P, Q);
      if (d <= r[i] + r[j]){
        E[i].push_back(make_pair(0, j));
        E[j].push_back(make_pair(0, i));
      } else {
        double d2 = d - r[i] - r[j];
        E[i].push_back(make_pair(d2, j));
        E[j].push_back(make_pair(d2, i));
      }
    }
  }
  vector<double> d(N, INF);
  priority_queue<pair<double, int>, vector<pair<double, int>>, greater<pair<double, int>>> Q;
  Q.push(make_pair(0, N - 2));
  while (!Q.empty()){
    double c = Q.top().first;
    int v = Q.top().second;
    Q.pop();
    if (d[v] == INF){
      d[v] = c;
      for (auto P : E[v]){
        Q.push(make_pair(d[v] + P.first, P.second));
      }
    }
  }
  cout << d[N - 1] << endl;
}

Measured memory_bytes: 36212
#include <stdio.h>
 
int N, A[112345];
int cou;
 
int main(void)
{
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) { scanf("%d", &A[i]); }
 
	for (int i = 0; i < N; ++i)
	{
		if (A[i] % 2 == 1)
		{
			++cou;
		}
	}
 
	if (cou % 2 == 0)
	{
		printf("YES\n");
	}
	else
	{
		printf("NO\n");
	}
	return 0;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	ll N; cin >> N;
	vll A(N+1); cin >> A;
	ll sum = accumulate(begin(A), end(A), 0ll);
	
	ll num = 1;

	ll ans = 1;
	for (int i = 0; i <= N; i++) {
		num -= A[i];
		if (num < 0) {
			cout << -1 << endl;
			return;
		}
		sum -= A[i];

		num = min(sum, num * 2);
		ans += num;
	}
	
	cout << ans << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 3988
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <cmath>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)

#define debug(x) cerr<<#x<<": "<<x<<'\n'

#define fi first
#define se second

#define vi vector<int>
#define pb push_back
#define mp make_pair

#define pcnt __builtin_popcount

typedef long long ll;

const int inf = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

struct Edge{
    int to;
    int cost;
};
vector<vector<Edge> > G(110);
int d[110] = {};
int main(){
    int n;
    cin >> n;
    rep(i,n){
        int t,m;
        cin >> t >> m;
        rep(j,m){
            int a,b;
            cin >> a >> b;
            Edge ee;
            ee.to = a;ee.cost = b;
            G[t].push_back(ee);
        }
    }

    rep(i,n) d[i] = 900010000;
    d[0] = 0;
    while(true){
        bool update = false;
        rep(i,n){
            for(const auto& e: G[i]){
                if(d[i] + e.cost < d[e.to]){
                    d[e.to] = d[i]+e.cost;
                    update = true;
                }
            }
        }
        if(!update) break;
    }

    rep(i,n){
        cout << i << " " << d[i] << endl;
    }

    return 0;
}



Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std ;
#define ll long long
inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;

}
//##################################################################
int main(){
    int n=D(),m=D();
    int a[n];
    int sum=0;
    for(int i=0;i<n;i++){
        a[i]=D();
        sum+=a[i];
    }
    int cnt=0;
    int x=sum/(4*m);
    if(sum%(4*m)!=0)x++;
    for(int i=0;i<n;i++){

        if(a[i]>=x)cnt++;

    }
    if(cnt>=m)cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
using namespace std;
int s[200][200];

int di[5] = {0, 0, 2, 2};
int dj[5] = {0, 2, 0, 2};

int main() {
    int a, b, k = 0;
    cin >> a >> b;
    if (a > b) {
	swap(a, b);
	k = 1;
    }
    // int tmp = a / 50;
    // for (int i = 1; i <= tmp; ++i) {
    // 	for (int j = 1; j <= 100; ++j) {
    // 	    s[i][j] = (i + j) % 2;
    // 	}
    // }
    // a %= 50;
    // for (int i = 1; i <= 100; ++i) {
    // 	if ((tmp + i) % 2 == 1 && a) {
    // 	    a--;
    // 	} else { 
    // 	    s[tmp + 1][i] = 1;
    // 	}
    // }
    a--;
    int tmp = a / 25;
    for (int i = 1; i <= tmp; ++i) {
	for (int j = 1; j <= 25; ++j) {
	    int fj = (j - 1) * 4 + 1;
	    int fi = (i - 1) * 4 + 1;
	    s[fi][fj + 1] = 1;
	    s[fi][fj] = 1;
	    s[fi + 1][fj] = 1;
	    s[fi + 1][fj + 2] = 1;
	    s[fi + 2][fj + 1] = 1;
	}
    }
    int hvb = a * 3;
    //cout << hvb << endl;
    for (int i = 1; i <= a % 25; ++i) {
	int fi = tmp * 4 + 1;
	int fj = (i - 1) * 4 + 1; 
	    s[fi][fj + 1] = 1;
	    s[fi][fj] = 1;
	    s[fi + 1][fj] = 1;
	    s[fi + 1][fj + 2] = 1;
	    s[fi + 2][fj + 1] = 1;
    }
    if (hvb > b) {
	int nd = (hvb - b) / a;
	int rsnd =  (hvb - b) % a;
	//cout << rsnd << endl;
	for (int i = 1; i <= a; ++i) {
	    int fi = (i - 1) / 25 * 4 + 1;
	    int fj = (i - 1) % 25 * 4 + 1;
	    int tmp = nd;
	    if (i <= rsnd) tmp++;
	    for (int j = 1; j <= tmp; ++j) {
		s[fi + di[j]][fj + dj[j]] = 1;
	    }
	}
    } else if (hvb < b) {
	int tmp = b - hvb;
	int sti = (a - 1) / 25 * 4 + 5;
	int stj = 1;
	while (tmp--) {
	    s[sti][stj] = 1;
	    stj += 2;
	    if (stj > 100) {
		stj -= 100;
		sti += 2;
	    }
	}
    }
    puts("100 100");
    // for (int i = a % 50 * 2 + 1; i <= 100; ++i) {
    // 	s[tmp + 1][i] = 1;
    // }
    // for (int i = 1; i <= 100; ++i) {
    // 	s[tmp + 2][i] = 1;
    // }
    // b -= tmp * 50 ;
    for (int i = 1; i <= 100; ++i) {
	for (int j = 1; j <= 100; ++j) {
		if (s[i][j] ^ k) {
			printf("#");
		} else {
			printf(".");
		}
	    //printf("%d",s[i][j]);
	}
	puts("");
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
using namespace std;
#define df 0
#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
typedef long int li;

void Zalg(const string& S,vector<int>& A){
  for(int& x: A)x=0;
  A[0] = S.size();
  int i = 1, j = 0;
  while (i < S.size()) {

    while (i+j < S.size() && S[j] == S[i+j]){
      ++j;
    }

    A[i] = j;
    if (j == 0) { ++i; continue;}
    int k = 1;
    while (i+k < S.size() && k+A[k] < j){
      A[i+k] = A[k], ++k;
    }
    i += k; j -= k;
  }
}


int main(){
  if(df) printf("*debug mode*\n");
  int n,ans=0; cin >>n;
  string s; cin >>s;
  vector<int> v(s.size(),0);
  for(int i=0;i<n;i++){
    Zalg(s.substr(i),v);
    if(df){
      cout << s.substr(i)<<"\n";
    }
    for(int j=1;j<n-i;j++){
      if(v.at(j)>j)v.at(j)=j;
      if(df)printf(" %d",v.at(j));
      if(v.at(j)>ans)ans=v.at(j);
    }
    if(df)printf("\n");
  }
  printf("%d",ans);
}

/// confirm df==0 ///


Measured memory_bytes: 256
#include <stdio.h>
#define True = 1;
#define False = 0;


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

    int l[N], i;
    for(i=0; i<N; i++) {
        scanf("%d", &l[i]);
    }

    int j, max, mc;
    for(i=0; i<N-1; i++) {
        max = l[i];
        mc = i;
        for(j=i+1; j<N; j++) {
            if(max<l[j]) {
                max = l[j];
                mc = j;
            }
        }
        l[mc] = l[i];
        l[i] = max;
    }


    int ans=0;
    for(i=0; i<K; i++) {
        ans += l[i];
    }

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

    return 0;

}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>
#include<set>
#include<vector>
#include<cmath>
#define lmid l,m,rt<<1
#define rmid m+1,r,rt<<1|1
#define LL long long
#define rl r-l+1
using namespace std;
double p=0;
int sum=0,ans=0;
int E,F;
int s[5],t[5];
int vis[3005][3005];
void dfs(int x,int y)
{
     if(x*100+y>F) return ;
     if(x*E<y) return ;
     //cout<<x<<" "<<y<<endl;
     if(y*(sum+ans)>=ans*(x+y))
     {
          sum=x,ans=y;
     }
     for(int i=0;i<=2;i++)
          for(int j=0;j<=2;j++)
          {
               if(!vis[x+s[i]][y+t[j]])
               {
                    vis[x+s[i]][y+t[j]]=1;
                    dfs(x+s[i],y+t[j]);
               }

          }
     return ;
}
int main()
{
     scanf("%d%d%d%d%d%d",&s[0],&s[1],&t[0],&t[1],&E,&F);
     s[2]=0,t[2]=0;
     vis[0][0]=1;
     dfs(0,0);
     cout<<sum*100+ans<<" "<<ans<<endl;
}


Measured memory_bytes: 512
n, k = map(int, input().split())

A = [0] * n

for i in range(k):
    d = input()
    A_okashi = map(int, input().split())

    for j in A_okashi:
        if A[j-1] == 0:
            A[j-1] = 1

print (A.count(0))

Measured memory_bytes: 9180
import sys
input = sys.stdin.readline
n,y=map(int,input().split())

c=0
for i in range(0,n+1):
    for j in range(0,n+1):
        k=n-i-j
        if 10000*i+5000*j+1000*k==y and k>=0 and c==0:
            print(i, j, k)
            c=1
            break
if c==0:
    print(-1,-1,-1)


Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>

using namespace std;

int main() {
  // vector<int> X(5);
  // int x1, x2, x3, x4, x5;
  string S, T;
  cin >> S >> T;

  long long count = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S[i] != T[i]) {
      count++;
    }
  }

  cout << count << endl;

  return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> road(N);
  for (int i = 0; i < M; ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    ++road.at(a);
    ++road.at(b);
  }
  for (int i = 0; i < N; ++i) {
    cout << road.at(i) << endl;
  }
}


Measured memory_bytes: 256
<?php

$s = trim(fgets(STDIN));
$a = str_split($s);

$num = array_count_values($a);
$count = count($num);

if($count % 2 == 1){
echo "No";
}elseif($count == 4){
echo "Yes";
}else{
if(isset($num["N"]) == true && isset($num["S"]) == true){
echo "Yes";
}elseif(isset($num["E"]) == true && isset($num["W"]) == true){
echo "Yes";
}else{
echo "No";
}
}

Measured memory_bytes: 3832
#include <bits/stdc++.h>
#define ms(x, n) memset(x,n,sizeof(x));
#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define rep1(i, n) for(int i = 1; i <= (int)n; ++i)
#define pb push_back
#define PI acos(-1.0)
#define LONG_LONG_MAX 9223372036854775807
#define LONG_LONG_MIN -9223372036854775808
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;

const int maxn = 200000 + 10;
int n, q, a, b, p, x, fa[maxn], ans[maxn], val[maxn];

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ms(fa, 0); ms(ans, 0); ms(val, 0);
    cin >> n >> q;
    rep(i, n-1) {
        cin >> a >> b;
        fa[b] = a;
    }
    rep(i, q) {
        cin >> p >> x;
        val[p] += x;
    }
    ans[1] = val[1];
    for (int i = 2; i <= n; ++i) {
        ans[i] = val[i] + ans[fa[i]];
    }
    for (int i = 1; i <= n; ++i) {
        if (i != n) cout << ans[i] << " ";
        else cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
string S;
set<string> st;

void query(char now) {
    //cerr << S << " " << now << endl;
    if(now == ('a' - 1)) {
        st.insert(S);
        return;
    }
    for(int i = 0; i < S.size(); i++) {
        if(S[i] == now + 1) {
            return;
        }
        if(S[i] == now) {
            S[i]++;
            query(now - 1);
            S[i]--;
        }
    }
    query(now - 1);
}

int main() {
    while(true) {
        cin >> S;
        st.clear();
        if(S == "#") break;
        query('y');
        cout << st.size() << endl;
        if(st.size() <= 10) {
            for(auto itr = st.begin(); itr != st.end(); itr++) {
                cout << *itr << endl;
            }
        } else {
            auto itr = st.begin();
            for(int i = 1; i <= 5; i++) {
                cout << *itr << endl;
                itr++;
            }
            itr = st.end();
            for(int i = 1; i <= 5; i++) itr--;
            for(int i = 1; i <= 5; i++) {
                cout << *itr << endl;
                itr++;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 5088
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

ll power(int x) {
  if(x==0) return 1;
  ll p=power(x/2);
  if(x%2==0) return p*p%INF;
  return p*p%INF*4%INF;
}

int main() {
  ll N,s=0;
  cin >> N;
  vector<ll> C(N);
  rep(i,N) cin >> C[i];
  sort(C.begin(),C.end());
  rep(i,N) {
    s+=(N-i+1)*C[i]%INF;
    s%=INF;
  }
  cout << power(N-1)*s%INF << endl;
}

Measured memory_bytes: 1792
package main

import "fmt"

func main() {
	var s, t string
	fmt.Scan(&s, &t)
	ar := make([][]int, 26)
	for i, v := range s {
		ar[v-'a'] = append(ar[v-'a'], i+1)
	}
	for _, v := range t {
		if len(ar[v-'a']) == 0 {
			fmt.Println(-1)
			return
		}
	}
	dp := make([][]int, len(s)+1)
	dp[len(s)] = make([]int, 26)
	for i := 0; i < 26; i++ {
		dp[len(s)][i] = -1
	}
	for i := len(s) - 1; i >= 0; i-- {
		dp[i] = make([]int, 26)
		for j := 0; j < 26; j++ {
			if s[i]-'a' == byte(j) {
				dp[i][j] = i
			} else {
				dp[i][j] = dp[i+1][j]
			}
		}
	}
	sum := 0
	now := -1
	for _, v := range t {
		if now = dp[now+1][v-'a']; now != -1 {
			continue
		}
		sum++
		now = dp[0][v-'a']
	}
	fmt.Println(sum*len(s) + now + 1)
}


Measured memory_bytes: 25728
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int N = cin.nextInt();
        int K = cin.nextInt();
        Integer[] L = new Integer[N];
        for (int i = 0; i < N; i++) {
            L[i] = cin.nextInt();
        }

        Arrays.sort(L, Collections.reverseOrder());

        int sum = 0;
        for (int i = 0; i < K; i++) {
            sum += L[i];
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 21844
a=input()
op=['+','-']
 
for i in op:
    for j in op:
        for k in op:
            if eval(a[0]+i+a[1]+j+a[2]+k+a[3])==7:
                print(a[0]+i+a[1]+j+a[2]+k+a[3]+"=7")
                exit()

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

int main() {
    long long x;
    cin >> x;

    long long ans = x / 11;
    
    if (x % 11 == 0) cout << ans * 2 << endl;
    else if (x % 11 <= 6) cout << ans * 2 + 1 << endl;
    else if (x % 11 <= 10) cout << ans * 2 + 2 << endl;

    return 0;
}

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

void reader(int *x) {
	int k = getchar_unlocked(); *x = k - '0';
	while (1) {
		k = getchar_unlocked();
		if (k < '0' || k > '9') break;
		*x = ((*x) << 1) + ((*x) << 3) + k - '0';
	}
}
deque<int>E[100000];
int u[200000], v[200000], r[200000], ans[200000], d[100000], cnt = 1;
char b[200000], ok[100000]{ 1 };
queue<int>que;

void bfs(int u, int t) {
	que.push(u);
	while (!que.empty()) {
		int p = que.front(); que.pop(); for (int v : E[p]) {
			if (t) {
				if (d[v] > d[p] && !ok[v]) {
					ok[v] = 1; cnt++; que.push(v);
				}
			}
			else if (!~d[v]) {
				d[v] = d[p] + 1; que.push(v);
			}
		}
	}
}
int main() {
	int n, m, q; reader(&n); reader(&m); reader(&q);
	rep(i, m) {
		reader(&u[i]); reader(&v[i]);
		u[i]--; v[i]--;
		E[u[i]].emplace_back(v[i]); E[v[i]].emplace_back(u[i]);
	}
	memset(d, -1, sizeof(d));
	d[0] = 0; bfs(0, 0);
	rep(i, m) {
		if (d[u[i]] > d[v[i]])swap(u[i], v[i]);
	}
	rep(i, n)E[i].clear();
	rep(i, q) {
		reader(&r[i]); r[i]--;
		b[r[i]] = 1;
	}
	rep(i, m) {
		if (!b[i]) {
			if (d[v[i]] > d[u[i]]) {
				E[u[i]].emplace_back(v[i]);
			}
		}
	}
	bfs(0, 1);
	for (int i = q - 1; i >= 0; i--) {
		ans[i] = n - cnt;
		if (d[v[r[i]]] > d[u[r[i]]] && !ok[v[r[i]]]) {
			E[u[r[i]]].emplace_back(v[r[i]]);
			if (ok[u[r[i]]]) {
				cnt++; ok[v[r[i]]] = 1;
				bfs(v[r[i]], 1);
			}
		}
	}
	rep(i, q)printf("%d\n", ans[i]);
}

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

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

    int minv = INT_MAX, mini = -1;
    vi a(5);
    rep(i, 0, 5) {
        cin >> a[i];
        if (minv > (a[i] - 1) % 10 + 1) {
            minv = min(minv, (a[i] - 1) % 10 + 1);
            mini = i;
        }
    }

    int ans = 0;
    rep(i, 0, 5) {
        if (i == mini) {
            ans += a[i];
        } else {
            ans += (a[i] + 9) / 10 * 10;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    Scanner in = new Scanner(System.in);

    public void run() {
        int a = in.nextInt(), b = in.nextInt();
        String s = in.next();

        boolean ok = true;
        for (int i = 0; i <= a + b; i++) {
            if (i == a) {
                ok &= s.charAt(i) == '-';
            } else {
                ok &= Character.isDigit(s.charAt(i));
            }
        }
        System.out.println(ok ? "Yes" : "No");
    }


    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;

#define rep(i,m,n) for(int i=m;i<n;i++)
#define ll long long
#define MOD 1000000007

int main(int argc, char *argv[]) {

  char s[5];
  rep(i,0,4) cin >> s[i];

  rep(i,0,3) {
    if(s[i] == s[i+1]) {
      cout << "Bad" << endl;
      return 0;
    }
  }

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


Measured memory_bytes: 256
def inp():
    return input()
def iinp():
    return int(input())
def inps():
    return input().split()
def miinps():
    return map(int,input().split())
def linps():
    return list(input().split())
def lmiinps():
    return list(map(int,input().split()))


n = iinp()
a = lmiinps()

for i in a:
  if i%2 == 0:
    if (i%3 == 0) or (i%5 == 0):
      continue
    else:
      print("DENIED")
      exit()

print("APPROVED")

Measured memory_bytes: 3064
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
4 5
0 1 2
0 2 1
1 2 1
1 3 1
2 3 2

output:
3
"""

import sys
from collections import deque


def graph_bfs(source, target, parent):
    visited = [False] * v_num
    queue = deque()
    queue.appendleft(source)
    visited[source] = True

    while queue:
        current = queue.popleft()
        for adj, cp in adj_table[current].items():
            if cp and not visited[adj]:
                queue.append(adj)
                visited[adj] = True
                parent[adj] = current

    return True if visited[target] else False


def graphFordFulkerson(source, sink):
    parent = [-1] * v_num
    max_flow = 0

    while graph_bfs(source, sink, parent):
        path_flow = float('inf')

        bk_1 = sink
        while bk_1 is not source:
            path_flow = min(path_flow, adj_table[parent[bk_1]][bk_1])
            bk_1 = parent[bk_1]

        max_flow += path_flow

        bk_2 = sink
        while bk_2 is not source:
            parent_bk_2 = parent[bk_2]
            assert parent_bk_2 != -1
            # adj_table[parent_bk_2].setdefault(bk_2, 0)
            adj_table[bk_2].setdefault(parent_bk_2, 0)

            # print(bk_2, parent_bk_2, path_flow, bk_1, parent[bk_1], parent, adj_table)
            adj_table[parent_bk_2][bk_2] -= path_flow
            adj_table[bk_2][parent_bk_2] += path_flow
            bk_2 = parent[bk_2]

    return max_flow


def generate_adj_table(_edges):
    for edge in _edges:
        source, target, cp = map(int, edge)
        init_adj_table[source][target] = cp

    return init_adj_table


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    v_num, e_num = map(int, _input[0].split())
    edges = map(lambda x: x.split(), _input[1:])

    init_adj_table = [dict() for _ in range(v_num)]
    adj_table = generate_adj_table(edges)
    ans = graphFordFulkerson(source=0, sink=v_num - 1)
    print(ans)

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

int main(){
    int N;
    cin >> N;
    double inverse = 0.0;
    for(int i =0; i < N; i++){
        double a;
        cin >> a;
        inverse += 1.0/a;
    }
    cout << 1.0/inverse << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<vector>
#include<iomanip>
#include<map>

using namespace std;
using ll = long long;

int main() {
	double D, T, S;
	cin >> D >> T >> S;

	double A = double(D / S);

	if (A <= T)cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

int main(){
    int r,g,b,n;
    cin >> r >> g >> b >> n;
    int a;
    if(b>g){
        a=b;
        b=g;
        g=a;
    }
    if(g>r){
        a=g;
        g=r;
        r=a;
    }
    if(b>g){
        a=b;
        b=g;
        g=a;
    }
    int count=0;
    for(int i=0;i<=(n+r-1)/r;i++){
        for(int j=0;j<=(n-r*i+g-1)/g;j++){
            if((n-r*i-g*j)%b==0&&(n-r*i-g*j)/b>=0)count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
using System;
class Program
{
    static void Main(string[] args)
    {
        string s = Console.ReadLine();
        string p = Console.ReadLine();
        int plength = p.Length;
        s += s.Substring(0,plength);
        if (s.IndexOf(p) < 0)
        {
            Console.WriteLine("No");
        }
        else
        {
            Console.WriteLine("Yes");
        }
    }
}

Measured memory_bytes: 6204
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto M = s[1];
    auto A = readln.split.map!(to!int).array;
    
    auto numbers = new int[](N + 1);
    auto segment = new int[](N);

    foreach (a; A) numbers[a] += 1;
    foreach (i; 1..N+1) {
        if (numbers[i] == 0) continue;
        foreach (j; 0..numbers[i]) {
            if (i - j - 1 < 0) break;
            segment[i - j- 1] += 1;
        }
    }

    int ans = segment.map!(x => x == 0).sum;

    while (M--) {
        s = readln.split.map!(to!int);
        auto X = s[0] - 1;
        auto Y = s[1];
        if (A[X] != Y) {
            int a = A[X] - (numbers[A[X]]);
            int b = Y - (numbers[Y] + 1);
            if (a != b && a >= 0 && segment[a] == 1) ans += 1;
            if (a != b && b >= 0 && segment[b] == 0) ans -= 1;
            numbers[A[X]] -= 1;
            numbers[Y] += 1;
            A[X] = Y;
            if (a >= 0) segment[a] -= 1;
            if (b >= 0) segment[b] += 1;
        }
        ans.writeln;
    }
}


Measured memory_bytes: 13712
import java.util.Scanner;
 
public class Main {
    private static int n;
    private static int q;
    private static int[] p;
    private static int[] rank;
 
    private static boolean same(int x, int y) {
        return findSet(x) == findSet(y);
    }
 
    private static void unite(int x, int y) {
        int i = findSet(x);
        int j = findSet(y);
 
        if (i == j)
            return;
        if (rank[i] > rank[j]){
            p[j] = p[i];
            rank[i] += rank[j];
            rank[j] = 0;
        }
        else {
            p[i] = p[j];
            rank[j] += rank[i];
            rank[i] = 0;
        }
    }
 
    private static int findSet(int i) {
        while (i != p[i]){
            p[i] = p[p[i]];
            i = p[i];
        }
        return i;
    }
 
    private static void DisjointSet() {
        p = new int[n];
        rank = new int[n];
 
        for (int i = 0; i < n; i++) {
            p[i] = i;
            rank[i] = 1;
        }
    }
 
 
    public static void main (String[] args){
        Scanner scanner = new Scanner(System.in);
        n = scanner.nextInt();
        q = scanner.nextInt();
 
        DisjointSet();
        for (int i = 0; i < q; i++) {
            int com = scanner.nextInt();
            int x = scanner.nextInt();
            int y = scanner.nextInt();
 
            if (com == 0){
                unite(x, y);
            }
            if (com == 1){
                if (same(x, y))
                    System.out.println(1);
                else
                    System.out.println(0);
            }
 
        }
 
    }
}

Measured memory_bytes: 102412
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
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 (b<a) { a=b; return 1; } return 0; }

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);
int N;

void dfs(string s, int mx){
    if(s.length() == N) {
        cout << s << endl;
    }else{
        for(char c = 'a'; c <= mx; c++){
            dfs(s+c, ((c == mx) ? char(mx+1): mx));
        }
        
    }
}

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    cin >> N;
    dfs("",'a');

}


Measured memory_bytes: 1536
a, b, c = map(int, input().split())
if a == b == c:
    ans = 0
else:
    ans = 1 << 31
    for x in [a - b, b - c, c - a]:
        if x != 0:
            tmp = 0
            while x % 2 == 0:
                tmp += 1
                x >>= 1
            ans = min(tmp, ans)

if a == b == c and b % 2 == 0:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 9108
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>
#include <cassert>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>
#include <functional>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

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

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int D, T, S;
    cin >> D >> T >> S;
    if (S * T >= D) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3608
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define per(i, a, b) for (int i = a; i >= b; i--)
using namespace std;
 
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef long long ll;
 
template <typename _T>
inline void read(_T &f) {
    f = 0; _T fu = 1; char c = getchar();
    while (c < '0' || c > '9') { if (c == '-') { fu = -1; } c = getchar(); }
    while (c >= '0' && c <= '9') { f = (f << 3) + (f << 1) + (c & 15); c = getchar(); }
    f *= fu;
}
 
template <typename T>
void print(T x) {
    if (x < 0) putchar('-'), x = -x;
    if (x < 10) putchar(x + 48);
    else print(x / 10), putchar(x % 10 + 48);
}
 
template <typename T>
void print(T x, char t) {
    print(x); putchar(t);
}

const int N = 605;
const int vx[4] = {1, 1, -1, -1};
const int vy[4] = {1, -1, 1, -1};

queue <pii> q;
bitset <N * N> a, b, c, d;
int x[N], y[N], col[N][N];
int n, len, d1, d2;

void check(bitset <N * N> a, bitset <N * N> b) {
	bitset <N * N> res = a & b;
	if (res.count() < n * n) return;
	for (int i = 0, cnt = 0; i < n * n * 4; i++) {
		if (res[i]) {
			print(i / n / 2, ' '); print(i % (n * 2), '\n');
			++cnt;
			if (cnt == n * n) exit(0);
		}
	}
}

int main() {
	read(n); read(d1); read(d2);
	for (int i = 0; i * i <= d1; i++) {
		int j = floor(sqrt(d1 - i * i + 0.5));
		if (i * i + j * j == d1) {
			++len;
			x[len] = i; y[len] = j;
		}
	}
	for (int i = 0; i < n * 2; i++) {
		for (int j = 0; j < n * 2; j++) {
			if (!col[i][j]) {
				col[i][j] = 1;
				q.push(make_pair(i, j));
				while (!q.empty()) {
					pii u = q.front(); q.pop();
					for (int k = 0; k < 4; k++) {
						for (int t = 1; t <= len; t++) {
							int _x = u.first + x[t] * vx[k];
							int _y = u.second + y[t] * vy[k];
							if (_x < 0 || _y < 0 || _x >= n * 2 || _y >= n * 2) continue;
							if (!col[_x][_y]) col[_x][_y] = 3 - col[u.first][u.second], q.push(make_pair(_x, _y));
						}
					}
				}
			}
		}
	}
	for (int i = 0; i < n * 2; i++) {
		for (int j = 0; j < n * 2; j++) {
			if (col[i][j] == 1) a[i * n * 2 + j] = 1;
			else b[i * n * 2 + j] = 1;
		}
	}
	len = 0; memset(col, 0, sizeof(col));
	for (int i = 0; i * i <= d2; i++) {
		int j = floor(sqrt(d2 - i * i + 0.5));
		if (i * i + j * j == d2) {
			++len;
			x[len] = i; y[len] = j;
		}
	}
	for (int i = 0; i < n * 2; i++) {
		for (int j = 0; j < n * 2; j++) {
			if (!col[i][j]) {
				col[i][j] = 1;
				q.push(make_pair(i, j));
				while (!q.empty()) {
					pii u = q.front(); q.pop();
					for (int k = 0; k < 4; k++) {
						for (int t = 1; t <= len; t++) {
							int _x = u.first + x[t] * vx[k];
							int _y = u.second + y[t] * vy[k];
							if (_x < 0 || _y < 0 || _x >= n * 2 || _y >= n * 2) continue;
							if (!col[_x][_y]) col[_x][_y] = 3 - col[u.first][u.second], q.push(make_pair(_x, _y));
						}
					}
				}
			}
		}
	}
	for (int i = 0; i < n * 2; i++) {
		for (int j = 0; j < n * 2; j++) {
			if (col[i][j] == 1) c[i * n * 2 + j] = 1;
			else d[i * n * 2 + j] = 1;
		}
	}
	check(a, c); check(a, d); check(b, c); check(b, d);
    return 0;
}

Measured memory_bytes: 3456
//(n-2)(n-1)/2^{place}-->(n-2)(n-1)/2^{place}-->(n-2)(n-1)/2^{place}

#include <iostream>
#include <vector>
#include <math.h>
using namespace std;
int main() {
  string t;
  cin>>t;
vector<char> v(t.begin(), t.end());
if (v[2]==v[3]&&v[4]==v[5]){
  cout<<"Yes";
}
else {
  cout<<"No";

}

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main()
{
	int a[5],b[5],c=0;
  for(int i=0;i<3;i++){
    cin>>a[i];
    c+=a[i];
  }
  b[0]=max(a[0],max(a[1],a[2]));
  b[2]=min(a[0],min(a[1],a[2]));
  b[1]=c-b[0]-b[2];
  if(b[0]==b[1]+b[2]){
    cout<<"Yes\n";
  }else{
    cout<<"No\n";
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN=100005;
int n;
int main(){
    cin >>n;
    int a,b,c,d;
    a =  b = c = d = 0;
    while(n--){
        string s;
        cin>>s;
        if(s=="AC")
            a++;
        if(s=="WA")
            b++;
        if(s=="TLE")
            c++;
        if(s=="RE")
            d++;
    }
    printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d",a,b,c,d);
    // system("pause");
    return 0;
}

Measured memory_bytes: 3724
#include <iostream>
#include <algorithm>
using namespace std;
long long int gcm(long long int a,long long int b)
{
	if(b == 0)
	{
		return a;
	}
	return gcm(b,a%b);
}
int main(){
  int n;
  long int a, g;
  cin >> n;
  cin >> a;
  g = a;
  for(int i = 1;i < n;i++){
    cin >> a;
    g = gcm(max(g, a), min(g, a));
  }
  cout << g << endl;
  return 0;
}

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


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
  
	int N,K;
	cin>>N>>K;

	vector<int>V;

	int d;

	while(K--)
	{
		cin>>d;

		int inp;

		for(int i = 0;i<d;i++)
		{
			cin>>inp;
			V.pb(inp);
		}
	}

	unordered_map<int,int>mp;

	for(int i = 0;i<V.size();i++)
		mp[V[i]]++;

	int count = 0;

	for(int i = 1;i<=N;i++)
	{
		if(mp[i] == 0)
			count++;
	}

	cout<<count<<endl;

	return 0;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin >>N;
  vector<int>h(N);
  for(int i=0;i<N;i++)
    cin>>h.at(i);
  vector<int>dp(N);
  dp[N-1]=0;
  dp[N-2]=abs(h.at(N-1)-h.at(N-2));
  for(int i=N-3;0<=i;i--)
    dp[i]=min(abs(h[i]-h[i+1])+dp[i+1],abs(h[i]-h[i+2])+dp[i+2]);
  cout<<dp[0]<<endl;
   return 0;
}

Measured memory_bytes: 1024
//
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define speed ios::sync_with_stdio(false)
using namespace std;

string gs(char x){
    string s(1,x);
    return s;
}

ll funn(ll a)
{
	ll sum=0;
	while(a)
	{
		sum+=(a%10);
		a/=10;
	}
	return sum;
}

int main()
{
	speed;
	
	ll n;
	cin>>n;
	cout<<((n%funn(n))?"No":"Yes");
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);

		String S=sc.next();
		String T=sc.next();
		boolean same = true;

		char s[]=S.toCharArray();
		char t[]=T.toCharArray();

		for (int i=0;i<S.length()&&same==true;++i){
			if(S.indexOf(s[i],i+1)==T.indexOf(t[i],i+1));
			else same=false;
		}

		if (same== true)System.out.println("Yes");
		else System.out.println("No");


//		System.out.println(S.indexOf(s[2], 3));
	}
}

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

int main() {
    int h,w;
    cin>>h>>w;

    char s[h][w];
    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
            cin>>s[i][j];
        }
    }

    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
            if(s[i][j] == '.') s[i][j] = '0';
        }
    }

    const int dx[8] = {-1,-1,-1,0,0,1,1,1};
    const int dy[8] = {-1,0,1,-1,1,-1,0,1};
    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
            if(s[i][j] == '#'){
                for(int k=0;k<8;++k){
                    if(i+dy[k]<0 or j+dx[k]<0)
                        continue;
                    if(i+dy[k]>=h or j+dx[k]>=w)
                        continue;
                    if(s[i+dy[k]][j+dx[k]] == '#')
                        continue;
                    ++s[i+dy[k]][j+dx[k]];
                }
            }
        }
    }

    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
            cout<<s[i][j]; 
        }
        cout<<endl;
    }
}





Measured memory_bytes: 256