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

 int main(){
   int a, b;
   cin >> a >> b;
   string s;
   cin >> s;

   bool ans = true;

   for(int i = 0; i < a; i++){
     if(s.at(i) == '-'){
       ans = false;
       break;
     }
   }
   if(s.at(a) != '-'){
     ans = false;
   }
   for(int i = a + 1; i < s.size(); i++){
     if(s.at(i) == '-'){
       ans = false;
       break;
     }
   }

   if(ans == true){
     cout << "Yes" << endl;
   }
   else{
     cout << "No" << endl;
   }
 }


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};
use std::collections::HashSet;


fn main() {
  let n = read::<i64>();
  let m = read::<i64>();
  const MOD: i64 = 1000000007;
  let mut ans: i64 = 1;

  if 1 < (n - m).abs() {
    ans = 0;
  } else {
    for i in 1..n + 1 {
      ans *= i;
      ans %= MOD;
    }
    for i in 1..m + 1 {
      ans *= i;
      ans %= MOD;
    }

    if n == m {
      ans *= 2;
      ans %= MOD;
    }
  }

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


Measured memory_bytes: 4352
#include<iostream>
using namespace std;
#define h (360/12)
#define m ((double)360/(12*60))
int main()
{
  int a;
  cin>>a;
  double hunn=a/m;
  int jikan=hunn/60;
  cout<<jikan<<" "<<(int)hunn%60<<endl;
}

Measured memory_bytes: 3112
#include <stdio.h>

int main(){
  int a, b, c, k;
  scanf("%d %d %d %d", &a, &b, &c, &k);
  
  if (a>=k){
    printf("%d\n", k);
    return 0;
  }
  if ((a+b)>=k){
    printf("%d\n", a);
    return 0;
  }
  
  printf("%d\n", a-(k-a-b));
  return 0;
}

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

march = [0 for i in range(5)]
for i in range(N):
    first = input()[0]
    if first == "M":
        march[0] += 1
    elif first == "A":
        march[1] += 1
    elif first == "R":
        march[2] += 1
    elif first == "C":
        march[3] += 1
    elif first == "H":
        march[4] += 1
        
count = 0
for i in range(5):
    for j in range(i + 1, 5):
        for k in range(j + 1, 5):
            count += march[i] * march[j] * march[k]
            
print(count)

Measured memory_bytes: 3064
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn readu() -> usize {
    read::<usize>()
}

#[allow(dead_code)]
fn readi() -> i32 {
    read::<i32>()
}

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }

    let mut b = vec![0; n];

    for i in (1..n + 1).rev() {
        let mut sum: i32 = a[i - 1] as i32;
        let mut j = i * 2;
        loop {
            if j > n {
                break;
            }
            sum -= b[j - 1];
            j += i;
        }
        b[i - 1] = sum % 2;
        if b[i - 1] < 0 {
            b[i - 1] += 2;
        }
    }
    let m: Vec<usize> = b
        .into_iter()
        .enumerate()
        .filter(|&(_, bi)| bi > 0)
        .map(|(i, _)| i + 1)
        .collect();
    println!("{}", m.len());
    for &i in &m {
        println!("{}", i);
    }
}


Measured memory_bytes: 9084
#include <stdio.h>

int min(int a, int b) {
  return a < b ? a : b;
}

int main(void) {
  int n, d, i, j, k, inf = 10e8, l;
  while( 1 ) {
    scanf("%d%d", &d, &n);
    if(!d) break;
    int a[n], e[n], r[n], dp[d + 1][200];
    for(i = 0; i < n; ++i) scanf("%d%d%d", &a[i], &e[i], &r[i]);
    for(i = 0; i <= d; ++i) for(j = 0; j < 200; ++j) dp[i][j] = inf;
    dp[0][0] = 0;
    for(i = 0; i <= 100; ++i) {//経験値
      for(j = 0; j < n; ++j) if(i >= r[j]){//道具
        for(k = 0; k <= d; ++k) {
          if(dp[min(d, k + a[j])][min(100, i + e[j])] > dp[k][i] + 1) dp[min(d, k + a[j])][min(100, i + e[j])] = dp[k][i] + 1;
        }
      }
    }
    /*for(i = 0; i <= d; ++i) {
      for(j = 0; j < 20; ++j) printf("%d ", dp[i][j]);
      printf("\n");
    }*/
    int ans = inf;
    for(i = 0; i <= 100; ++i) if(ans > dp[d][i]) ans = dp[d][i];
    if(ans != inf) printf("%d\n", ans);
    else printf("NA\n");
  }
  return 0;
}


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

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define seq vector
signed main(){
    
    string S;
    cin >> S;

    for (auto i : S){
        if (i==','){
            cout << ' ';
        }else{
            cout << i;
        }

    }

}

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

    #define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
    #define mod 1000000007
    #define qmod 998244353
    #define M 10000001
    #define endl "\n"
    #define all(a) (a).begin(),(a).end()
    #define rep(i,a,b) for(int i=a;i<b;++i)
    #define repr(i,a,b) for(int i=a;i>=b;--i)
    #define F first
    #define S second
    #define pb push_back
    #define mp make_pair

    typedef long long ll;
    typedef pair<int,int> pii;
    typedef vector<int> vi;
    typedef vector<string> vs;  
    typedef vector<pii> vii;
    typedef vector<vi> vvi;

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

        fast;   
        int t=1;
        // cin>>t; 
        while(t--){ 
            int n;
            cin>>n;
            int ans=0;
            rep(i,0,n){
                int x;
                cin>>x;
                if(x&1 && (i+1)&1) ans++;
            }
            cout<<ans;
        }  
        return 0;       
    }       


    // First, solve the problem. Then, write the code. 
    

Measured memory_bytes: 3604
#include <iostream>
#include<string>
#include<algorithm>

using namespace std;

int main() {
	int year, yen;
	cin >>year >> yen;
	int cost=0;
	
	if (year >= 13)cost = yen;
	else {
		if (year > 5)cost = yen / 2;
	}

	cout << cost << endl;

	
}



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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

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

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

    if (M % 2 != 0) {
        cout << -1 << endl;
        return 0;
    }

    vector<pair<int, int>> edges(M);
    vvi adj(N);
    vi outdeg(N, 0);

    for(int i=0;i<M;i++) {
        int A, B;
        cin >> A >> B;
        A--; B--;
        
        adj[A].push_back(B);
        adj[B].push_back(A);
        outdeg[A]++;
        edges[i] = {A, B};
    }

    queue<int> bfs;
    vi parents(N, -1);
    parents[0] = 0;
    bfs.push(0);
    vi postorder;

    while(!bfs.empty()) {
        int cur = bfs.front();
        bfs.pop();
        
        postorder.push_back(cur);

        for (int nbr : adj[cur]) {
            if (parents[nbr] == -1) {
                parents[nbr] = cur;
                bfs.push(nbr);
            }
        }
    }

    reverse(postorder.begin(), postorder.end());

    vi flip(N, 0);
    for(int i=0;i<N;i++) {
        if(outdeg[i] % 2 == 1) flip[i] = 1;
    }

    for(int v : postorder) {
        flip[parents[v]] ^= flip[v];
    }

    for (auto edge : edges) {
        int a = edge.first;
        int b = edge.second;

        if(parents[a] == b && flip[a] == 1) {
            cout << b+1 << " " << a+1 << endl;
        } else if(parents[b] == a && flip[b] == 1) {
            cout << b+1 << " " << a+1 << endl;
        } else {
            cout << a+1 << " " << b+1 << endl;
        }
    }

    return 0;
}


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

// begin fast read template by CYJian (source: https://www.luogu.com.cn/paste/i11c3ppx)

namespace io {
	const int __SIZE = (1 << 21) + 1;
	char ibuf[__SIZE], *iS, *iT, obuf[__SIZE], *oS = obuf, *oT = oS + __SIZE - 1, __c, qu[55]; int __f, qr, _eof;
	#define Gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	inline void flush () { fwrite (obuf, 1, oS - obuf, stdout), oS = obuf; }
	inline void gc (char &x) { x = Gc(); }
	inline void pc (char x) { *oS ++ = x; if (oS == oT) flush (); }
	inline void pstr (const char *s) { int __len = strlen(s); for (__f = 0; __f < __len; ++__f) pc (s[__f]); }
	inline void gstr (char *s) { for(__c = Gc(); __c < 32 || __c > 126 || __c == ' ';)  __c = Gc();
		for(; __c > 31 && __c < 127 && __c != ' '; ++s, __c = Gc()) *s = __c; *s = 0; }
	template <class I> inline bool gi (I &x) { _eof = 0;
		for (__f = 1, __c = Gc(); (__c < '0' || __c > '9') && !_eof; __c = Gc()) { if (__c == '-') __f = -1; _eof |= __c == EOF; }
		for (x = 0; __c <= '9' && __c >= '0' && !_eof; __c = Gc()) x = x * 10 + (__c & 15), _eof |= __c == EOF; x *= __f; return !_eof; }
	template <class I> inline void print (I x) { if (!x) pc ('0'); if (x < 0) pc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10; while (qr) pc (qu[qr --]); }
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} using io::pc; using io::gc; using io::pstr; using io::gstr; using io::gi; using io::print;

// end fast read template by CYJian

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    ll k; gi(k);
	__int128_t c = 100; int t = 0;
	while(c < k) {
		c = (c * 101) / 100;
		t++;
	}
	print(t);
}


Measured memory_bytes: 3640
#include<cstdio>
#include<iostream>
#include<string>

using namespace std;

int main(void){
	
	string s;
	
	cin>>s;
	
	if(s[5]=='0'&&s[6]=='1')
		cout<<"Heisei"<<endl;
	else if(s[5]=='0'&&s[6]=='2')
		cout<<"Heisei"<<endl;
	else if(s[5]=='0'&&s[6]=='3')
		cout<<"Heisei"<<endl;
	else if(s[5]=='0'&&s[6]=='4')
		cout<<"Heisei"<<endl;
	else
		cout<<"TBD"<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
int N;
vector<ll> x, y;
vector<char> d;

double F(double t)
{
    double minX = 1000000000.0;
    double maxX = -1000000000.0;
    double minY = 1000000000.0;
    double maxY = -1000000000.0;
    double nx, ny;
    rep(i, 0, N)
    {
        switch (d[i])
        {
            case 'R': nx = x[i] + t; ny = y[i]; break;
            case 'L': nx = x[i] - t; ny = y[i]; break;
            case 'U': nx = x[i]; ny = y[i] + t; break;
            case 'D': nx = x[i]; ny = y[i] - t; break;
        }
        chmin(minX, nx);
        chmax(maxX, nx);
        chmin(minY, ny);
        chmax(maxY, ny);
    }
    return (maxX - minX) * (maxY - minY);
}

void _main()
{
    cin >> N;
    x.resize(N);
    y.resize(N);
    d.resize(N);
    rep(i, 0, N) cin >> x[i] >> y[i] >> d[i];

    double x0 = 0.0, x3 = 1000000000.0;
    rep(i, 0, 1000)
    {
        const double x1 = x0 + ((x3 - x0) / 3.0) * 1.0;
        const double x2 = x0 + ((x3 - x0) / 3.0) * 2.0;

        const double x1Value = F(x1);
        const double x2Value = F(x2);

        if (x1Value < x2Value)
        {
            x3 = x2;
        }
        else
        {
            x0 = x1;
        }
    }

    printf("%.12f\n", F(x0 + (x3 - x0) * 0.5));
}


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


int main(){
	int X;cin >> X;
	int a = 0, b = 0;
	a = X / 500;
	X -= a * 500;
	b = X / 5;
	cout << a * 1000 + b * 5 << endl;
}












Measured memory_bytes: 3596
#include <iostream>
#include <cmath>
#include <complex>
#include <vector>
#include <set>
#include <iomanip>


using namespace std;
typedef long double ld;
typedef long long ll;
const int MAX = 60;
typedef complex<long double> Point;


namespace std {
    bool operator<(const Point &lhs, const Point &rhs) {
        return lhs.real() == rhs.real() ? lhs.imag() < rhs.imag() : lhs.real() < rhs.real();
    }
}

struct Circle {
    Point c;
    ld r;

    vector<Point> cross(const Circle &other) {
        vector<Point> ret;
        ld dist = abs(c - other.c);
        ld rc = (dist * dist + r * r - other.r * other.r) / (2 * dist);
        ld dfr = r * r - rc * rc;
        if (abs(dfr) < 1e-6) dfr = 0.0;
        if (dfr < 0.0) {
            return ret;
        }
        ld rs = sqrt(dfr);
        Point diff = (other.c - c) / dist;
        ret.push_back(c + diff * Point{rc, rs});
        if (dfr != 0.0) {
            ret.push_back(c + diff * Point{rc, -rs});
        }
        return ret;
    }
};

const ld eps = 1e-9;
int n, k;
Circle m[MAX + 1];
int c[MAX + 1];


int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    cin >> n >> k;

    vector<Point> centers;
    for (int i = 0; i < n; ++i) {
        ld xc, yc;
        cin >> xc >> yc >> c[i];
        m[i] = {Point{xc, yc}};
        centers.push_back(m[i].c);
    }

    ld hi = 1e6;
    ld lo = 0;
    for (int ii = 0; ii < 100; ++ii) {
        ld t = lo + (hi - lo) / 2;
        vector<Point> candidate(centers);

        for (int i = 0; i < n; ++i) {
            m[i].r = (ld) t / (ld) c[i];
            for (int j = 0; j < n; ++j) {
                if (i == j) continue;
                m[j].r = (ld) t / (ld) c[j];
                auto ret = m[i].cross(m[j]);
                for (auto pt : ret) {
                    candidate.push_back(pt);
                }
            }
        }

        int mc = 0;
        for (auto pt : candidate) {
            int count = 0;
            for (int i = 0; i < n; ++i) {
                ld diff = abs(m[i].c - pt);
                if (diff < m[i].r + eps) {
                    ++count;
                }
            }
            mc = max(mc, count);
        }

        if (mc < k) {
            lo = t + eps;
        } else {
            hi = t;
        }
    }

    cout << lo;

    return 0;
}


Measured memory_bytes: 688
use std::collections::HashMap;
fn main() {
    let v = read_vec::<usize>();
    let _n = v[0];
    let m = v[1];

    let py = read_vec2::<u32>(m as u32);
    let mut py2 = py.clone();
    py2.sort_by_key(|p| p[1]);
    let mut hm = HashMap::new();
    let mut names = HashMap::new();

    for p in py2 {
        let c = hm.entry(p[0]).or_insert(0);
        *c += 1;
        names.insert((p[0],p[1]), format!("{:>06}{:>06}", p[0], *c));
    }

    for x in py {
        if let Some(t) = names.get(&(x[0], x[1])) {
            println!("{}", t);
        }
    }
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 27900
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           node(a,b,c)                 mp(mp(a,b),c)
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;
vector<int>prime;
bool sv[M+10];
void sieve()
{
     int i,j;
     for(i=4;i<=M;i=i+2)
    {
           sv[i]=1;
    }
    for(i=3;i*i<=M;i=i+2)
    {
        if(sv[i]==0)
        {
              for(j=i*i;j<=M;j=j+2*i)
              {
                  sv[j]=1;
              }
        }
    }
    for(i=3;i<M;i=i+2)
    {
        if(sv[i]==0 && i%5==1)
        {
            prime.push_back(i);
        }
    }
}
 main()

{
    fast
    int n;
    cin>>n;
    sieve();
    for(int i=0;i<n;i++)
    {
        cout<<prime[i]<<" ";
    }
    cout<<endl;
    return 0;

}





































Measured memory_bytes: 3804
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define int long long
#define INF 1000000000000000000
using namespace std;

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
template<typename T>
void debug(vector<vector<T>> m){ REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;} }



signed main(){

    int N, A, B, C; cin >> N >> A >> B >> C;
    vec l(N); readv(l);

    vec v(N, 0);
    int ans = INF;
    while(true){

        vec L(3, 0);
        int tmp = -30;
        REP(i, N) if(v[i] != 3){
            tmp += 10;
            L[v[i]] += l[i];
        }
        if(L[0] > 0 && L[1] > 0 && L[2] > 0){
            tmp += llabs(L[0] - A) + llabs(L[1] - B) + llabs(L[2] - C);
            Min(ans, tmp);
        }

        int n = N - 1;
        v[n]++;
        while(v[n] >= 4){
            v[n] = 0;
            n--;
            if(n == -1){
                cout << ans << endl;
                return 0;
            }
            v[n]++;
        }
    }

    return 0;
}


Measured memory_bytes: 256
int main(){
  int N,i,max,sum;
  scanf("%d\n",&N);
  int x[N];
  for(i=0;i<N-1;i++){
    scanf("%d ",&x[i]);
  }
  scanf("%d\n",&x[N-1]);
  max=0;
  sum=0;
  for(i=0;i<N;i++){
    if(x[max]<=x[i]) max=i;
    sum+=x[i];
  }
  sum-=x[max];
  if(sum>x[max]){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }
  return 0;
}

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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll N,A,B;
    string S;
    cin >> N >> A >> B;
    cin >> S;
    ll a=0,b=0;
    for (int i = 0; i < N; i++) {
        if(S[i] == 'a'){
            if(a+b < A+B){
                a++;
                cout << "Yes" << endl;
            } else {
                cout << "No" << endl;
            }
        } else if(S[i] == 'b'){
            if(a+b < A+B && b < B){
                b++;
                cout << "Yes" << endl;
            } else {
                cout << "No" << endl;
            }
        } else {
            cout << "No" << endl;
        }
    }
}

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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll k;
  cin >> k;
  
  ll ans = 0;
  for (ll i = 1; i <= k; i++) {
    for (ll j = 1; j <= k; j++) {
      for (ll ii = 1; ii <= k; ii++) {
        ans += gcd(gcd(i, j), ii);
      }
    }
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 3652
public class Main {
	public static void main(String[] args) {
		int i,k;
		for(i=1;i<=9;i++){
			for(k=1;k<=9;k++){
				int ans;
				ans=i*k;
				System.out.println(i+"x"+k+"="+ans);
				
			}
		}
	}

}

Measured memory_bytes: 16852
n = int(input())
s = input()
t = input()
pointer = 0
ans = [1,0]
mod = 1000000007
while pointer < n:
	if s[pointer] == t[pointer]:

		pointer += 1
		if ans[1] == 0:
			ans[0] = ans[0] *3
		elif ans[1] == 1:
			ans[0] = ans[0] *2
		#ans[0] = ans[0] % mod
		ans[1] = 1

	else:

		pointer += 2
		if ans[1] == 0:
			ans[0] = ans[0] *6
		elif ans[1] == 1:
			ans[0] = ans[0] *2
		elif ans[1] == 2:
			ans[0] = ans[0] *3
		#ans[0] = ans[0] % mod
		ans[1] = 2

print(ans[0] % mod)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

int H, N;
int a[1005], b[1005];
i64 memo[1005][20010];

i64 dp(int i, int dmg) {
    if (i >= N) {
        return (dmg >= H ? 0 : INF);
    }
    auto &ret = memo[i][dmg];
    if (~ret) return ret;

    ret = INF;
    chmin(ret, dp(i + 1, dmg));
    if (dmg < H) chmin(ret, dp(i, dmg + a[i]) + b[i]);

    return ret;
}

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

    read(H, N);
    rep(i, 0, N) { read(a[i], b[i]); }

    memset(memo, -1, sizeof(memo));

    print(dp(0, 0));

    return 0;
}


Measured memory_bytes: 157952
#include<iostream>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string.h>
#include<queue>
#include<stack>
#include<climits>
#include<cmath>
using namespace std;


int main(){
    string s;
    int x=0,y=0;
    cin>>s;
    for(int i=0;i<s.length();i++){
        if(s[i]=='S'){
            if(y==0)y=1;
            else if(y==-1){
                y=2;
            }
        }
        if(s[i]=='W'){
            if(x==0)x=-1;
            else if(x==1){
                x=2;
            }
        }
        if(s[i]=='E'){
            if(x==0)x=1;
            else if(x==-1){
                x=2;
            }
        }
        if(s[i]=='N'){
            if(y==0)y=-1;
            else if(y==1){
                y=2;
            }
        }
        
    }
    if(x%2==0&&y%2==0){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using vs=vector<string>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF    	((ll)1ll<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.141592653589793

template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<p.first<<" "<<p.second;return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}

vector<pii> memo;
vvi city;
int t,s;

constexpr int getBitCoor(int y, int x){
	return (y<<5)+x;
}

pii solve(int ty, int tx, int by, int bx){
	int c=(getBitCoor(ty,tx)<<10)+getBitCoor(by,bx);
	if(memo[c].first!=0) {
		return memo[c];
	}
	pii ans(1,city[ty][tx]-city[ty][bx+1]-city[by+1][tx]+city[by+1][bx+1]);
	if(t-ans.sc>s)ans={-1,0};
	//cout<<"default: "<<pii(ty,tx)<<","<<pii(by,bx)<<":"<<ans<<endl;
	
	range(x,tx,bx){
		auto a=solve(ty,tx,by,x);
		auto b=solve(ty,x+1,by,bx);
		if(a.fs==-1 or b.fs==-1) continue;
		a.fs+=b.fs;
		a.sc=min(a.sc,b.sc);
		if(t-a.sc>s) continue;
		if(ans.fs<a.fs or (ans.fs==a.fs and ans.sc<a.sc)){
			ans=a;
		}
	}
	range(y,ty,by){
		auto a=solve(ty,tx,y,bx);
		auto b=solve(y+1,tx,by,bx);
		if(a.fs==-1 or b.fs==-1) continue;
		a.fs+=b.fs;
		a.sc=min(a.sc,b.sc);
		if(t-a.sc>s) continue;
		if(ans.fs<a.fs or (ans.fs==a.fs and ans.sc<a.sc)){
			ans=a;
		}
	}
	//cout<<pii(ty,tx)<<","<<pii(by,bx)<<" = "<<ans<<endl;
	return memo[c]=ans;
}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	int h,w;
	while(cin>>h>>w>>s,h){
		t=0;
		memo=vector<pii>((int)(1<<20),pii(0,0));
		city=vvi(h+1,vi(w+1,0));
		rep(i,h)rep(j,w){
			cin>>city[i+1][j+1];
			t+=city[i+1][j+1];
		}
		rep(i,h)rep(j,w){
			int lt=getBitCoor(i,j)<<10;
			int rb=getBitCoor(i,j);
			if(t-city[i+1][j+1]<=s){
				memo[lt+rb]=pii(1,city[i+1][j+1]);
			}else{
				memo[lt+rb]=pii(-1,0);				
			}
		}
		rep(i,h+1)range(j,1,w+1) city[i][j]+=city[i][j-1];
		range(i,1,h+1)rep(j,w+1) city[i][j]+=city[i-1][j];
		auto ans=solve(0,0,h-1,w-1);
		ans.sc=s-(t-ans.sc);
		cout<<ans<<endl;
	}
	return 0;
}
 



Measured memory_bytes: 27600
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,mn,cnt,mx,i,j,t,A[200005];
    while(cin>>n)
    {
        cnt=0;
        for(i=1;i<=n;i++)
        {
            cin>>A[i];
        }
        mn=INT_MAX;
        for(i=1;i<=n;i++)
        {
            if(A[i]<mn)
            {
                mn=A[i];
                cnt++;
            }
        }
        cout<<cnt<<endl;

    }


    return 0;
}


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

int main(){
  int r, g, b;
  cin >> r >> g >> b;
  if((10 * g + b) % 4 == 0){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
///Astalavista Code........~CodeSlayer007
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define double long double
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define PT(x) cout << (#x) << " is " << (x) << endl;
#define SPD_emergency ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int M = 1e9 + 7;
int IM = 1e17;
void PV(vi v) { for (int i = 0 ; i < v.size() ; i++) cout << v[i] << " "; cout << endl;}
void PA(int v[], int n) {for (int i = 0 ; i < n ; i++)cout << v[i] << " " ; cout << endl;}
void IN(int a[], int n) {for (int i = 0; i < n; i++)cin >> a[i];}
inline void PTN(int n = 1, int a = 0, int b = 0, int c = 0) { if (n--)cout << a << " "; if (n--)cout << b << " "; if (n--)cout << c << " "; cout << endl; }
inline void open() {
#ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
#endif
}
// <-------------------------------------------------------------------------------------------------------------------------------------------------------------------------> Ignore This-->  tuple first second push_back  continue make_pair break deque stack queue sort reverse accumulate  count lower_bound upper_bound next_permutation copy_n __builtin_popcount make_tuple
// <========================================================================================================================================================================

signed  main() {
   SPD_emergency

   //int t; cin >> t; int tt = 1; while (t--)
   {
      int n;
      cin >> n;
      int x = 100;
      int ans = 0;
      while(x<n){
       ans++;
       x = x + floor((x*0.01));
      }
      cout<<ans;


   }
   return 0;
}

Measured memory_bytes: 3608
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define cpresent(c,x) ((c).find(x) != (c).end()) 
#define vpresent(c,x) (find(all(c),x) != (c).end())
#define endl '\n'
#define ff first
#define ss second
#ifdef LOCAL
#include "/home/iggaboi/Desktop/CP/debug.h"
#else
#define debug(Args...)
#endif
// using pii = pair<int, int>;
using ll = long long;
using namespace __gnu_pbds;
using namespace std;
template<class T>
using indexed_set = tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>;

void shit() {
	int n; cin >> n;
    cout << (1000 - n%1000)%1000 << endl;
}

int32_t main() {
	ios_base::sync_with_stdio(false),cin.tie(nullptr);
	// int t; cin >> t;
	// while(t--)
		shit();
	return 0;
}



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

int main (){
   long int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a>=0 ){
    if(c>=0) cout <<b*d<<endl;
    else if(c<=0 and d>=0) cout << b*d<<endl;
    else if(d<=0) cout <<a*d<<endl;
  }
  else if(a<=0 and b>=0 ){
    if(d<=0) cout <<a*c<<endl;
    else if(d>=0 and c<=0) cout << max(a*c,b*d)<<endl;
    else if(c>=0) cout <<d*b<<endl;
  }
  else if(b<=0){
    if(c>=0) cout <<b*c<<endl;
    else if(c<=0 and d>=0) cout << a*c<<endl;
    else if(d<=0) cout << a*c<<endl;
  }
      
}

    
    
    
    
    
    

Measured memory_bytes: 3604
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<cstdio>
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
const long long INF = 1LL<<60;

typedef pair<ll,ll> Pair;

int main(){

ll D,N;
cin >> N >> D;
vector<ll> X(N);
vector<ll> Y(N);

ll ans=0;

for(ll i = 0;i < N;++i){

    cin >> X[i] >> Y[i];

    if(sqrt(X[i]*X[i]+Y[i]*Y[i]) <= D) ++ans;

}

cout << ans << endl;

return 0;

}


Measured memory_bytes: 6420
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
 
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;
 
int N;
int M;
int A[114514];
vector<int> ms[2];
vector<int> ans;
 
int main() {
  scanf("%d%d", &N, &M);
  rep(i, M) {
    scanf("%d", &A[i]);
    ms[A[i]%2].eb(A[i]);
  }
 
  if (ms[1].size() > 2) {
    puts("Impossible");
    return 0;
  }
 
  if (M < 2) {
    printf("%d\n", A[0]);
    if (A[0] == 1) puts("1\n1");
    else printf("2\n%d %d\n", 1, A[0]-1);
    return 0;
  }
 
  while (ms[1].size() < 2) {
    assert(!ms[0].empty());
    ms[1].eb(ms[0].back());
    ms[0].pop_back();
  }
 
  ans.eb(ms[1][0]+1);
  for (int v : ms[0]) {
    ans.eb(v);
  }
  if (ms[1][1] > 1) {
    ans.eb(ms[1][1]-1);
  }
 
  printf("%d", ms[1][0]);
  for (int v : ms[0]) {
    printf(" %d", v);
  }
  printf(" %d\n", ms[1][1]);
 
  printf("%d\n", (int)ans.size());
  int K = ans.size();
  rep(i, K) {
    printf("%d%c", ans[i], " \n"[i == K-1]);
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <math.h>
#include <algorithm>
#include <map>
#include <vector>
#include <queue>
#include <set>
#include <list>
#include <string>
#include <memory.h>
#include <bitset>
#include <stack>
#include <assert.h>
using namespace std;
#define ll  long long
#define ld long double
#define ppi pair<ll, ll>
#define mp make_pair
const int N = 2e5 + 11, K = 20;
const int mod = 1e9 + 7;
int arr[N];
ll dp[3011][3011];
int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		scanf("%d", arr + i);
	for (int i = 0; i < n; i++)
		dp[i][i] = (n % 2 ? 1 : -1) * arr[i];

	for (int i = n - 1; i >= 0; i--)
		for (int j = 0; j < n; j++)
			if (j < i)
			{
				ll lhs = dp[j + 1][n - i + j];
				ll rhs = dp[j][n - i + j - 1];
				if (i % 2) dp[j][n - i + j] = max(lhs + arr[j], rhs + arr[n - i + j]);
				else dp[j][n - i + j] = min(lhs - arr[j],rhs  - arr[n - i + j]);
			}
	cout << dp[0][n - 1];
}


Measured memory_bytes: 70144
#include<bits/stdc++.h>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
const ll INF=1000000000000001;
const double PI=3.141592653589;


int main(){
  string s; cin>>s;
  // cout<<s[0]-'a'<<endl;
  //  rep(i,s.size())
  // cout<<s[i]-'a'<<endl;
  bool c=1;
  if(s[0]!='A')
  c=0;
  int index;
  int count=0;
  rep(i,s.size()){
    if(2<=i&&i<=(s.size()-2)){
      if(s[i]=='C'){
        count++;
        index=i;
      }
    }
  }
  if(count!=1){
    c=0;
    // cout<<"count"<<endl;
  }else{
    rep(i,s.size()){
      if(i!=0&&i!=index){
        // cout<<s[i]-'A'<<endl;
        if(s[i]-'a'<0){
          c=0;
          // cout<<"omojji"<<endl;
        }
      }
    }
  }
  if(c)
  cout<<"AC"<<endl;
  else
  cout<<"WA"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>//s1.erase(n)=文字列s1の、n文字目以降削除
#include<algorithm>//辞書順=next_permutation
#include<set>
#include<string>//char 小文字のほうが32大きい
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap=数値交換
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define str string
#define please return
#define AC 0
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
#define Pi 3.1415926535897932384626
#define nine 1000000000

using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */


int main(void) {

	string a, b;
	cin >> a >> b;

	a += b;
	istringstream ss;
	ss = istringstream(a);
	int c=0;
	ss >> c;
	Yes((int)sqrt(c)*(int)sqrt(c)==c)

	please AC;
}

Measured memory_bytes: 256
from collections import Counter

N, M = [int(_) for _ in input().split()]

wa = Counter()

ac = set()

for i in range(M):
    p, s = input().split()
    p = int(p)
    if p in ac: continue
    if s == 'WA':
        wa[p] += 1
    else:
        ac.add(p)
wa_cnt = 0
for v in ac:
    wa_cnt += wa[v]

print(len(ac), wa_cnt)


Measured memory_bytes: 17756
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
void fast()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
int main()
{
	fast();
	string x;
	cin >> x;
	ll sum = 0;
	for (int i = 0; i < x.length(); i++)
	{
		sum += x[i] - '0';
	}
	if (sum % 9 == 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
int main () {
    set<int> s;
    for (int i = 0; i < 3; i++) {
        int a;
        cin >> a;
        s.insert(a);
    }
    if (s.size() == 1) {
        puts("Yes");
    }
    else {
        puts("No");
    }
}

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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; --i)
#define INF (1 << 30)
#define MOD 1e9 + 7

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

int dp[4020][4020];

int main() {
	string s1, s2;
	while(cin >> s1 >> s2) {
		memset(dp, 0, sizeof(dp));
		int ans = 0;
		FOR(i, 0, s1.size()) {
			FOR(j, 0, s2.size()) {
				if(s1[i] == s2[j]) {
					dp[i + 1][j + 1] = dp[i][j] + 1;
					ans = max(ans, dp[i + 1][j + 1]);
				}
				else dp[i + 1][j + 1] = 0;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 66252
/*
 	author:: tamajit banerjee
*/

#include<iostream>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include <iomanip>
using namespace std;
#define pb push_back
#define ll long long int
# define pll pair<ll,ll>
  
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  	int n;
  	cin>>n;
  	string s;
  	cin>>s;
  	int cntr=0,ans=0;
  	for(int i=0;i<n;i++){
  		if(s[i]=='R')++cntr;
	}
	for(int i=cntr;i<n;i++){
		if(s[i]=='R')++ans;
	}
	cout<<ans;
	return 0;
}
    

Measured memory_bytes: 3776
import sys
input = lambda: sys.stdin.readline().rstrip('\r\n')

class DSU(object):
    
    def __init__(self, n):
        self.parent = [i for i in range(n)]
        self.rank = [1] * n
        self.cycle = False

    def find(self, key):
        if self.parent[key] != key:
            self.parent[key] = self.find(self.parent[key])
        return self.parent[key]

    def union(self, a, b):
        s1, s2 = self.find(a), self.find(b)
        if s1 != s2:
            if self.rank[s1] < self.rank[s2]:
                self.parent[s1] = s2
                self.rank[s2] += self.rank[s1]
            else:
                self.parent[s2] = s1
                self.rank[s1] += self.rank[s2]
        else:
            self.cycle = True
        
    def has_cycle(self):
        return self.cycle
    
    def show_parent(self):
        return self.parent

    def show_rank(self):
        return self.rank

def solve():
    n, m = map(int, input().split())
    d = DSU(n + 1)
    if m > 0:
        for _ in range(m):
            a, b = map(int, input().split())
            d.union(a, b)
        # print(d.show_parent())
        print(max(d.show_rank()))
    else:
        print(1)

solve()

Measured memory_bytes: 18668
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int M1,D1,M2,D2;
    cin >> M1 >> D1;
    cin >> M2 >> D2;
    
    if (M1==M2)
        cout << '0' << endl;
    else
        cout << '1' << endl;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> top(n);
    vector<int> mid(n);
    vector<int> under(n);

    rep(i,n) cin >> top[i];
    rep(i,n) cin >> mid[i];
    rep(i,n) cin >> under[i];

    sort(top.begin(),top.end());
    sort(mid.begin(),mid.end());
    sort(under.begin(),under.end());

    ll ans = 0;
    for (int i = 0;i < n;i++){
        ans += (ll(lower_bound(top.begin(),top.end(),mid[i])-top.begin()))*
                  ll(under.end()-upper_bound(under.begin(),under.end(),mid[i]));

        //cout << int(lower_bound(top.begin(),top.end(),mid[i])-top.begin()) << endl;
        //cout << int(under.end()-upper_bound(under.begin(),under.end(),mid[i])) << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int n) { return n & 1; }
constexpr bool even(const int n) { return ~n & 1; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

template<typename T> std::vector<T> LIS(const std::vector<T> &v) {
  int n = v.size();
  const int inf = std::numeric_limits<T>::max();
  std::vector<T> dp(n, inf);
  rep(i, n) * std::lower_bound(dp.begin(), dp.end(), v[i]) = v[i];
  return std::vector<T>(dp.begin(), std::lower_bound(dp.begin(), dp.end(), inf));
}

main {
  int n;
  cin >> n;
  vi a(n);
  cin >> a;
  cout << LIS(a).size() << endl;
}

Measured memory_bytes: 5144