akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
template<class T>inline bool CHMIN(T&a,T b){if(a > b){a = b;return true;}return false;}
template<class T>inline bool CHMAX(T&a,T b){if(a < b){a = b;return true;}return false;}
constexpr int INF = 1e18;



signed main(){
	string a, b, c;
	cin >> a >> b >> c;
	int A = a.size(), B = b.size(), C = c.size(), mid = 50000;
	vector<int> ac(100010), ab(100010), bc(100010);
	auto f = [] (char a, char b) {
		return (a == '?' || b == '?' || a == b);
	};
	REP(i, A) {
		REP(j, B) {
			int diff = i - j + mid;
			if(!f(a[i], b[j])) ab[diff] = true;
		}
	}
	REP(i, A) {
		REP(j, C) {
			int diff = i - j + mid;
			if(!f(a[i], c[j])) ac[diff] = true;
		}
	}
	REP(i, B) {
		REP(j, C) {
			int diff = i - j + mid;
			if(!f(b[i], c[j])) bc[diff] = true;
		}
	}
	int ans = INF;
	FOR(posB, -4040, 4040) {
		FOR(posC, -4040, 4040) {
			if(ab[posB + mid] || ac[posC + mid] || bc[posC - posB + mid]) continue;
			int l = min({0ll, posB, posC});
			int r = max({0ll + A, posB + B, posC + C});
			CHMIN(ans, r - l);
		}
	}
	cout << ans << "\n";
}

Measured memory_bytes: 2560
//g++  5.4.0

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll po(ll mean){
   return mean && (-mean & (mean-1));
}
int main()
{
    ll n;
    double sum=0;
    cin>>n;
    ll arr[n];
    for(ll i=0;i<n;i++){
      cin>>arr[i];
      sum+=arr[i];  
    }
    //cout<<sum/n;
   double mean=round( sum/n);
    ll fsum=0;
    for(ll i=0;i<n;i++){
      fsum+=pow(abs(mean-arr[i]),2);
    }
    cout<<fsum;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn main() {
    input!{
        a: u32,
        b: u32,
    };
    for i in 1..10001 {
        if i * 8 / 100 == a && i * 10 / 100 == b {
            println!("{}", i);
            return;
        }
    }
    println!("-1");
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
int a[3][3],n;

int main() {
ll n;
cin >> n;
if(n%10==2||n%10==4||n%10==5||n%10==7||n%10==9) cout << "hon" << endl;
if(n%10==0||n%10==1||n%10==6||n%10==8) cout << "pon" << endl;
if(n%10==3) cout << "bon" << endl;
}


Measured memory_bytes: 3620
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	long long n,m,ans;
	scanf("%lld%lld",&n,&m);
	if(n==1)ans=m-2;else if(m==1)ans=n-2;else ans=(n-2)*(m-2);
	if(n==1&&m==1)ans=1;
	printf("%lld\n",ans);
	return 0;
}

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

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

    int a[3];
    for (int i = 0; i < 3; i++) cin >> a[i];
    sort(a, a + 3);
    if (a[0] == a[1] || a[1] == a[2]) {
        if (a[0] != a[2]) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ "; for(auto v : V) os << v << " "; return os << "]"; }
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ "; for(auto s:S) os<<s<<" ";return os<<"}"; }
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) { return os << "(" << P.first << "," << P.second << ")";}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) { os << "{ "; for(auto m:M) os<<"("<<m.first<<":"<<m.second<<") "; return os<<"}"; }
#ifdef LMAO
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){ const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | "; __f(comma+1, args...); }
#else
    #define trace(...) 42
#endif
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define endl "\n"
#define tcase int tt; cin>>tt; while(tt--)
#define tcase2 int tt; cin>>tt; for(int qq=1;qq<=tt;qq++)
#define all(x) x.begin(), x.end()
typedef long long int ll;
typedef  unsigned long long int ull;
typedef long double ld;
const int MAX = 1000010;
const int MOD2 = 998244353;
const int MOD = 1000000007; 
const int INF = 1e8;    
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ld EPS = 1e-7;
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)   
/*****************start************/

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout<<fixed<<setprecision(25);cerr<<fixed<<setprecision(10);
    int n;
    cin>>n;
    vector<ll> a(n),b(n);
    for(int i=0;i<n;i++)
        cin>>a[i]>>b[i];
    sort(all(a));
    sort(all(b));
    if(n&1)
        cout<<b[n/2]-a[n/2]+1<<endl;
    else
        cout<<b[n/2]+b[-1+n/2]-a[n/2]-a[-1+n/2]+1<<endl;
    return 0;
}


Measured memory_bytes: 6328
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

int N;
int f[100][10];
int p[100][11];

void init()
{
}

void solve()
{
    ll ans = -LINF;
    FOR(i, 1, 1<<10){
        ll op[100];
        REP(j, N) op[j] = 0;
        REP(j, 10){
            if((i>>j) & 1){
                REP(k, N) if(f[k][j] == 1) op[k]++;
            }
        }
        ll profit = 0;
        REP(i, N){
            profit += p[i][op[i]];
        }
        ans = max(ans, profit);
    }
    cout << ans << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    REP(i, N){
        REP(j, 5) REP(k, 2) cin >> f[i][j*2+k];
    }
    REP(i, N) REP(j, 11) cin >> p[i][j];
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 256
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { -1,0,1,0 }, dy[4] = { 0,-1,0,1 };
const char dir[4] = { 'u','l','d','r' };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        (wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)

int n;
string c;
int cnt[101010];

int main() {
	while (cin >> n&&n) {
		cin >> c;
		REP(i, n) {
			cnt[i] = 0;
		}
		int ba = 0;
		REP(i, c.size()) {
			if (c[i] == 'M')cnt[i%n]++;
			if (c[i] == 'S') {
				ba += cnt[i%n] + 1;
				cnt[i%n] = 0;
			}
			if (c[i] == 'L') {
				cnt[i%n] += ba + 1;
				ba = 0;
			}
		}
		sort(cnt, cnt + n);
		cnt[n] = ba;
		n++;
		REP(i, n) {
			if (i)cout << " ";
			cout << cnt[i];
		}
		cout << endl;
	}
}


Measured memory_bytes: 3212
fun main(args: Array<String>) {
  val (n, m) = readLine()!!.split(" ").map { it.toLong() }
  val c = arrayOf(n, m / 2).min()!!
  val r = arrayOf(0L, m - c * 2).max()!!
  val ans = c + r / 4
  println(ans)
}


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

using std::cout;
using std::endl;
using std::cin;
using std::min;

int main() {
	// Input
	int C11, C12, C13;
	int C21, C22, C23;
	int C31, C32, C33;
	cin >> C11 >> C12 >> C13;
	cin >> C21 >> C22 >> C23;
	cin >> C31 >> C32 >> C33;
	// Calculation
	bool satisfiable = false;
	for(int a1 = 0, lim = min(C11, min(C12, C13)); a1 <= lim; ++a1) {
		int b1 = C11 - a1;
		int b2 = C12 - a1;
		int b3 = C13 - a1;

		int a2 = C21 - b1;
		if(a2 != (C22 - b2)) continue;
		if(a2 != (C23 - b3)) continue;

		int a3 = C31 - b1;
		if(a3 != (C32 - b2)) continue;
		if(a3 != (C33 - b3)) continue;

		satisfiable = true;
		break;
	}
	// Output
	if(satisfiable) cout << "Yes" << endl;
	else            cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(void)
{
    long long n, a = 2, b = 1, c;
    cin >> n;
    if (n == 0)
    {
        cout << a << endl;
    }
    else if (n == 1)
    {
        cout << b << endl;
    }
    else
    {
        for (int i = 2; i <= n; i++)
        {
            c = a + b;
            a = b;
            b = c;
        }
        cout << b << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

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

	double EPS=1e-12;

	int n;
	double[] rs;

	void run(){
		n=sc.nextInt();
		rs=new double[n];
		for(int i=0; i<n; i++){
			rs[i]=sc.nextDouble();
		}
		solve();
	}

	void solve(){
		sort(rs);
		double total=3*1e-2, least=0.01*1e-2;
		for(int fix=0; fix<n; fix++){
			double sum=0;
			for(int i=fix; i<n; i++){
				sum+=sqrt(rs[i]);
			}
			double E=0;
			double[] ps=new double[n];
			boolean ok=true;
			for(int i=0; i<n; i++){
				if(i<fix){
					ps[i]=least;
				}else{
					ps[i]=sqrt(rs[i])/sum*(total-least*fix);
				}
				ok&=ps[i]+EPS>least;
				E+=rs[i]/ps[i];
			}
			E*=300;
			if(ok){
				println(String.format("%.15f", E));
				break;
			}
		}
	}

	void println(String s){
		System.out.println(s);
	}

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

Measured memory_bytes: 23548
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

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

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

trait Joinable {
    fn join(self, sep: &str) -> String;
}

impl<U: ToString, T: Iterator<Item = U>> Joinable for T {
    fn join(self, sep: &str) -> String {
        self.map(|x| x.to_string()).collect::<Vec<_>>().join(sep)
    }
}
fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: i64 = sc.get();
    for i in 1..10 {
        for j in 1..10 {
            if N == i * j {
                println!("Yes");
                return;
            }
        }
    }
    println!("No");
}


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

int N;
int A[100010];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }  
  ll ans = 0, sum = 0;
  for (int i = 0; i < N; i++) {
    if (A[i] == 0) {
      ans += sum / 2;
      sum = 0;
    } else {
      sum += A[i];
    }
  }
  ans += sum / 2;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define _GLIBCXX_DEBUG
#define rep(i, a, b) for(int i = a; i < b; i++)
#define ALL(v) v.begin(), v.end()

int main(){
    int a,b; cin>>a>>b;
    int ans = a+b;
    if(ans<a-b) ans = a-b;
    if(ans<a*b) ans = a*b;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
package main

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

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024
var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	n, k := nextInt(), nextInt()
	a := make([]int, n)

	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}

	sort.Sort(sort.Reverse(sort.IntSlice(a)))

	ans := 0
	for i := k; i < n; i++ {
		ans += a[i]
	}

	fmt.Println(ans)
}

Measured memory_bytes: 5248
#include<bits/stdc++.h>
  #include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
  using namespace std;
using namespace __gnu_pbds;
  #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define double long double
  #define all(v) v.begin(),v.end()
  #define rep(i,a,b) for(int i = a; i <=b; i++)
  #define rep2(i,a,b) for(int i = a; i>=b; i--)
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #define db long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const double PI = acos(-1);
  const int N = 200005;
  int mod = 1e9 + 7;
     

    
int32_t main()
{
       

  


      int a,b;
      cin >> a >> b;

      cout << 6 - a - b;



   return 0;
}       

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

using namespace std;

template <class T> void mini(T &l, T r) {l = min(l, r);}
template <class T> void maxi(T &l, T r) {l = max(l, r);}

string to_string(string s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

const int N = 8010;

string s;
int x, y;
vector <int> v;
vector <int> q;
bool okx, oky;
bool fl[N * 2];
bool *vis = fl + N;

void run() {
  cin >> s;
  cin >> x >> y;
  
  v.push_back(0);
  for (int i = 0; i < s.length(); ++i) {
    if (s[i] == 'T') {
      v.push_back(0);
    } else {
      v.back() ++;
    }
  }

  int n = s.length();

  bool first = 1;
  for (int _ = 0; _ < 2; ++_) {
    for (int x = -n; x <= n; ++x) vis[x] = 0;
    vis[0] = 1;
    for (int i = _; i < v.size(); i += 2) {
      q.clear();
      for (int x = -n; x <= n; ++x) if (vis[x]) q.push_back(x), vis[x] = 0;
      debug(q);
      if (first) {
        //right
        for (auto x : q) {
          vis[x + v[i]] = 1;
        }
        first = 0;
      } else {
        for (auto x : q) {
          vis[x + v[i]] = 1;
          vis[x - v[i]] = 1;
        }
      }
    }
    if (_ == 0 && vis[::x] == 1) {
      okx = 1;
    }
    if (_ == 1 && vis[::y] == 1) {
      oky = 1;
    }
  }
  
  puts(okx && oky ? "Yes" : "No");

}

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


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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<vector<int>> ans;

void fill(int cnt,vector<int> v){
    if(v.size()==1) return;
    if(v.empty()) return;
    int n=v.size();
    vector<int> r,l;
    rep(i,n){
        if(i%2) r.push_back(v[i]);
        else    l.push_back(v[i]);
    }

    for(auto rr:r){
        for(auto ll:l){
            ans[rr][ll]=cnt;
            ans[ll][rr]=cnt;
        }
    }
    fill(cnt+1,l);
    fill(cnt+1,r);
}

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

    // group数 = ceil(log2(n))
    cin>>n;
    ans=vector<vector<int>>(n,vector<int>(n));

    vector<int> v(n);
    iota(ALL(v),0);
    fill(1,v);
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            cout<<ans[i][j];
            if(j!=n-1) cout<<' ';
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 1536
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int INF = 2e9;



int main() {
	int n, m; cin >> n >> m;
	vector<int> a(n);
	rep(i, 0, n) a[i] = i;
	int edge[11][11] = {};
	rep(i, 0, m) {
		int x, y; cin >> x >> y;
		x--; y--;
		edge[x][y] = edge[y][x] = 1;
	}
	int ans = 0;
	do
	{
		bool flag = true;
		if (a[0]) break;
		rep(i, 1, n) if (edge[a[i - 1]][a[i]] == 0) flag = false;
		if (flag) ans++;
	} while (next_permutation(a.begin(),a.end()));
	printf("%d", ans);
	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
long long int GCD(long long int a, long long int b)
{
     if(a%b==0)
        return b ;
  else
      return   GCD(b,a%b);

}

int main()
{
   long long int x,y, temp;
   scanf("%lld%lld", &x, &y);
   if(x<y)
   {
    temp=y;
    y=x;
    x=temp;
   }
     printf("%lld\n", (x*y)/GCD(x,y));
    return 0;


}


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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	int n;
	cin >> n;
	long long ans = 0;
	for(int i = 0; i < n; i++) {
		int a;
		cin >> a;
		ans += a - 1;
	}
	cout << ans << endl;
	return 0;	
}


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

int main()
{
  int64_t N, C, ans = 0;
  cin >> N >> C;
  vector<int64_t> X(N), V(N);
  for (int i = 0; i < N; i++)
  {
    cin >> X.at(i) >> V.at(i);
  }
  auto rX = X, rV = V;
  reverse(rX.begin(), rX.end());
  reverse(rV.begin(), rV.end());
  for (int i = 0; i < N; i++)
  {
    rX[i] = C - rX[i];
  }
  for (int i = 1; i < N; i++)
  {
    V[i] += V[i - 1];
    rV[i] += rV[i - 1];
  }
  vector<int64_t> rFirst(N + 1, 0), lSecond(N + 1, 0), rSecond(N + 1, 0), lFirst(N + 1, 0);
  for (int i = 0; i < N; i++)
  {
    rFirst[i + 1] = max(rFirst[i], V[i] - 2 * X[i]);
    rSecond[i + 1] = max(rSecond[i], V[i] - X[i]);
    lFirst[i + 1] = max(lFirst[i], rV[i] - 2 * rX[i]);
    lSecond[i + 1] = max(lSecond[i], rV[i] - rX[i]);
  }
  for (int i = 0; i <= N; i++)
  {
    ans = max(ans, rFirst[i] + lSecond[N - i]);
    ans = max(ans, lFirst[N - i] + rSecond[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 9536
#include  <bits/stdc++.h>
using namespace std; 
int main()
{
	long long n,b,j=0;
	cin>>n;
	long long i=n;
	char a[50]={0};
	do
	{
		b=i%26;
		i/=26;
		a[j]=b+96;
		if(a[j]==96)
		{
			a[j]=122;
			i--;
		}
		j++;
	}while(i!=0);
	for(int c=j-1;c>=0;c--)
	{
		cout<<a[c];
	}
	return 0;
}

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

int main() {
    string S; cin >> S;
    int N=S.size();
    int ans=0;
    int count=0;
    for(int i=0; i<N; i++){
        for(int j=0; j<N-i; j++){
            for(int k=0; k<i+1; k++){
                if(S.at(j+k)!='A'&&S.at(j+k)!='C'&&S.at(j+k)!='G'&&S.at(j+k)!='T'){
                count=1;
                break;
            }
            
            }
            if(count==0){
                ans=i+1;
                break;
            }
            count=0;
        }
        count=0;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
#define FOR(i, n) for(int i = 1; i<=n; i++)
#define F0R(i, n) for(int i = 0; i<n; i++)
#define mp make_pair
#define pb push_back
#define f first
#define s second


//var 
LD D, T, S;

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

	cin >> D >> T >> S;
	cout << (D/S <= T ? "Yes" : "No") << endl; 

	cout.flush();
	return 0;
}

Measured memory_bytes: 3728
#include <cstdio>
#define MAXN 100007
#include <cstring>

char mayRed[MAXN];
int numOfBall[MAXN];

int main(void)
{
    mayRed[1]=1;
    int i,N,M;
    int x,y;
    scanf("%d%d",&N,&M);
    for(i=1;i<=N;i++)
    {
        numOfBall[i]=1;
        mayRed[i]=0;
    }
    mayRed[1]=1;

    for(i = 0;i<M;i++)
    {
        scanf("%d%d",&x,&y);
        if(mayRed[x])
        {
            mayRed[y]=1;
        }
        numOfBall[y]+=1;
        numOfBall[x]-=1;
        if(numOfBall[x]==0)
        {
            mayRed[x]=0;
        }
    }
    int r = 0;
    for(i=1;i<=N;i++)
    {
        r+=mayRed[i];
    }
    printf("%d\n",r);

    return 0;
}

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

using namespace std;

using ll = long long;

int main()
{
    ll A, B;
    cin >> A >> B;
    bool ans[3] = {};
    ans[A-1] = true;
    ans[B-1] = true;
    for(int i = 0; i < 3; ++i){
        if(!ans[i]) cout << i + 1 << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
  int n;
  string s;
  char c;
  map<string, bool> m;
  string ans = "Yes";
  cin >> n >> s;
  m[s] = 1;
  c = s.back();
  n--;
  while(n--) {
    cin >> s;
    if(s[0] != c || m[s]) {
     ans = "No";
    }
 	m[s] = 1;
    c = s.back();
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> P(N);
    for (int i = 0; i < N; i++) {
        cin >> P[i];
    }


    int ans = N - K + 1;
    set<int> S;

    for (int i = 0; i < K; i++) {
        S.insert(P[i]);
    }

    int mi, ma;
    for (int i = K; i < N; i++) {
        S.insert(P[i]);
        mi = *S.begin();
        ma = *S.rbegin();
        if(mi == P[i-K] && ma == P[i]) ans--;
        S.erase(P[i-K]);
    }

    int tmp = 1;
    int pre = P[0];
    vector<int> c;
    for (int i = 1; i < N; i++) {
        if(P[i-1] < P[i]){
            tmp++;
        }
        else{
            c.push_back(tmp);
            tmp = 1;
        }
    }
    c.push_back(tmp);
    tmp = 0;
    for (int i = 0; i < c.size(); i++) {
        if(c[i] >= K) tmp++;
    }
    if(tmp >= 1) tmp--;
    ans -= tmp;

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

}

Measured memory_bytes: 14008
#include <bits/stdc++.h>
 
#define int long long
 
#define pii pair<int, int>
 
#define x1 x1228
#define y1 y1228
 
#define left left228
#define right right228

#define tm tm228
 
#define pb push_back
#define eb emplace_back
 
#define mp make_pair                                                                
                                                                                                                                        
#define ff first                                                                  
#define ss second   
 
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << ": " << x << endl; 
#define TIME (ld)clock()/CLOCKS_PER_SEC
 
using namespace std;
typedef long long ll; 
typedef long double ld; 
                                                                                                   
const int maxn = 3e5 + 7, mod = 1e9 + 7, MAXN = 1e6 + 7;
const double eps = 1e-9;
const ll INF = 1e18, inf = 1e15;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
int n; 
int a[maxn]; 

void solve() {
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> a[i];
    sort(a, a + n);
    reverse(a, a + n);
    int diam = a[0];
    multiset<int> len; 
    for (int i = 0; i < n; ++i) len.insert(a[i]); 
    for (int i = 0; i <= diam; ++i) {
        if (len.find(max(diam - i, i)) == len.end()) {
            cout << "Impossible\n"; 
            return; 
        }
        len.erase(len.find(max(diam - i, i))); 
    } 
    int mn = -inf; 
    if (len.size()) {
        mn = *len.begin();
        if (mn >= (diam + 1) / 2 + 1) cout << "Possible\n"; 
        else cout << "Impossible\n"; 
        return; 
    }
    cout << "Possible\n"; 
}                                
   
signed main() {
#ifdef LOCAL
    freopen("TASK.in", "r", stdin);
    freopen("TASK.out", "w", stdout);
#else 
    
#endif // LOCAL
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20); 
    cout << fixed; 
    int t = 1; 
    for (int i = 0; i < t; ++i) {              
        solve();
    }
    return 0;
} 

Measured memory_bytes: 3612
import sys
input = sys.stdin.readline

MOD = 10**9 + 7
def main():
    S = input()
    N = len(S)-1

    if S[0] == '?':
        dp = [1,1,1,1,1,1,1,1,1,1,0,0,0]
    else:
        dp = [0,0,0,0,0,0,0,0,0,0,0,0,0]
        dp[int(S[0])] = 1

    for i in range(1,N):
        dppre = dp
        dp = [0,0,0,0,0,0,0,0,0,0,0,0,0]

        if S[i] == '?':
            R = range(10)
        else:
            R = [int(S[i])]
        
        for j in range(13):
            for k in R:
                dp[(j * 10 + k) % 13 ] += dppre[j]
        for j in range(13):
            dp[j] %= MOD

    print(dp[5])
if __name__ == '__main__':
    main()

Measured memory_bytes: 43372
#include <stdio.h>

/*[which card][for multiple cards of the same number]*/
int acl[1001][5000];
int acl_num[1001];
int acl_used[1001];

int main(void) {
	int b_cards[5000];
	int num_a,num_b;
	int start;
	int i,j;
	int currentcard;
	int currentpos=-1;
	int currentscore=0;
	int maxscore=0;
	int ok;
	scanf("%d%d",&num_a,&num_b);
	for(i=0;i<num_a;i++) {
		scanf("%d",&currentcard);
		/*record where the cards are*/
		acl[currentcard][acl_num[currentcard]]=i;
		acl_num[currentcard]++;
	}
	for(i=0;i<num_b;i++) {
		scanf("%d",&b_cards[i]);
	}
	for(start=0;start<num_b;start++) {
		for(j=1;j<=1000;j++)acl_used[j]=0;
		currentscore=0;
		currentpos=-1;
		for(i=start;i<num_b;i++) {
			currentcard=b_cards[i];
			ok=0;
			while(acl_num[currentcard]-acl_used[currentcard]>0) {
				if(acl[currentcard][acl_used[currentcard]]>currentpos) {
					ok=1;
					break;
				}
				acl_used[currentcard]++;
			}
			if(ok) {
				currentpos=acl[currentcard][acl_used[currentcard]];
				acl_used[currentcard]++;
				currentscore++;
			} else {
				break;
			}
		}
		if(currentscore>maxscore)maxscore=currentscore;
	}
	printf("%d\n",maxscore);
	return 0;
}

Measured memory_bytes: 0
/**akshaykumar99**/
 
#include<bits/stdc++.h>
using namespace std;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define pu(x) push_back(x)
#define eb(x) emplace_back(x)
#define pp pop_back()
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
#define all(v) v.begin(),v.end()
const int MOD=1e9+7 , INF=INT_MAX;
const long long LINF=LLONG_MAX;
 
typedef long long ll;
typedef long double ld;
typedef vector<int> ivc;
typedef pair<int,int> ipr;
 
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
   // #ifndef ONLINE_JUDGE
  //  	freopen("input.txt", "r", stdin);
  //  	freopen("output.txt","w",stdout);
  //  #endif
    int n,i;
    cin>>n;
    int a[n],b[n];
    f(i,0,n)
    {
    	cin>>a[i];
    	b[i]=a[i];
    }
    int x=0;
 	sort(b,b+n);
 	f(i,0,n)
 	{
 		if(a[i]!=b[i])
 			x++;
 		if(x>=3)
 		{
 			cout<<"NO"<<endl;
 			return 0;
 		}
 	}
 	cout<<"YES"<<endl;
 
}

Measured memory_bytes: 256
lst=[]
lt=[]
for i in range (4):
    n=int(input())
    lst.append(n)
lst.sort()
lst.pop(0)

    
for i in range (2):
    m=int(input())
    lt.append(m)
lt.sort()
lt.pop(0)

    
summ = sum(lst)+sum(lt)
print(f'{summ:.3g}')


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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n;
int a[100000];

int main() {
    scanf("%d", &n);
    forn(i, n) scanf("%d", a + i), --a[i];
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (a[i] == i) {
            if (i == n - 1) {
                swap(a[i], a[i - 1]);
            } else {
                swap(a[i], a[i + 1]);
            }
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<set>
using namespace std;
set<string> st;
map<string, int> mp;
int main()
{
	int n, mx = 0; string tmp;
	cin >> n;
	while (n--)
	{
		cin >> tmp;
		mp[tmp]++; mx = max(mx, mp[tmp]);
	}
	for (auto i : mp)
		if (i.second == mx)
			st.insert(i.first);
	for (auto i : st)
		cout << i << endl;
	return 0;
}

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

int main() {
  int K;
  string S;
  cin >> K >> S;

  if (S.size() <= K) {
    cout << S << endl;
  }
  else {
    for (int i = 0; i < K; i++) {
      cout << S.at(i);
    }
    cout << "..." << endl;
  }
}

Measured memory_bytes: 3604
import java.util.Scanner;
import java.util.Arrays;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] B = new int[N - 1];
    Arrays.setAll(B, i -> sc.nextInt());
    int result = B[0] + B[N - 2];
    for (int i = 0; i < N - 2; i++)
      result += Math.min(B[i], B[i + 1]);
    System.out.print(result);
  }
}

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

using namespace std;

int main() {
  std::string S, T, U;
  int A, B;
  std::cin >> S >> T;
  std::cin >> A >> B;
  std::cin >> U;
  if (S == U) {
    A--;
  } else {
    B--;
  }
  std::cout << A << " " << B << std::endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
//import java.util.stream.Collectors;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		String firstHalf = s.substring(0, (s.length() - 1) / 2);
		String secondHalf = s.substring((s.length() + 3) / 2 - 1, s.length());
		int count = 0;
		if(isPalindrome(s)){
			count++;
		}
		if(isPalindrome(firstHalf)){
			count++;
		}
		if(isPalindrome(secondHalf)){
			count++;
		}
		System.out.println(count == 3 ? "Yes" : "No");
	}
	
	static boolean isPalindrome(String s){
		boolean flg = true;
		for(int i=0; i<s.length() / 2; i++){
			if(s.charAt(i) != s.charAt(s.length()-i-1)){
				flg = false;
				break;
			}
		}
		return flg;
	}
}


Measured memory_bytes: 35616
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
int main() {
  int n;
  while(cin >> n && n) {
	vector<int> v(n, 0);
	for(int i = 0; i < n; ++i) {
	  cin >> v[i];
	}
	*min_element(v.begin(), v.begin() + n) = 0;
	*max_element(v.begin(), v.begin() + n) = 0;
	
	cout << accumulate(&v[0], &v[n], 0) / (n - 2) << endl;
  }

  return 0;
}

Measured memory_bytes: 3088
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		String s = sc.next();

		for(int i=0;i<s.length();i++) {
			System.out.print("x");
		}
		sc.close();
	}

}


Measured memory_bytes: 35576
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;


int main(){
    ll n, k;
    cin >> n >> k;

    ll ans = 0;
    ll minv = 0, maxv = 0;
    for(int i=0; i<=n; i++){
        maxv += n-i;
        minv += i;
        if(i >= k-1) ans = (ans + (maxv - minv + 1)) % MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
 
ll MOD = 1000000007;
ll INF =1<<29;
ll dp[100100];
 
int main() {
     string s;
     cin >> s;
     string r = s;
     reverse(r.begin(),r.end());
     if(r!=s){
         cout << "No" <<endl;
         return 0;
     }
     string t = s.substr(0,s.size()/2);
     string u =t;
     reverse(u.begin(),u.end());
     if(t==u){cout << "Yes" <<endl;
     return 0;}
     else cout << "No" <<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

typedef struct Node {
  int x;
  struct Node *prev;
  struct Node *next;
} Node;

Node *head, *tail;

void dump() {
  int l = 0;
  Node *p = head;
  while (p != NULL) {
    if (l == 0)  printf("%d",  p->x);
    else printf(" %d", p->x);
    ++l;
    p = p->next;
  }
  printf("\n");
}

void insert(int x) {
  Node *nod = malloc(sizeof(Node));;
  nod->x = x;
  nod->prev = NULL;
  nod->next = NULL;

  if (head == NULL) {
    head = nod;
    tail = nod;
  } else {
    nod->next = head;
    head->prev = nod;
    head = nod;
  }
}

void delete(int x) {
  Node *p = head;
  int flg = 0;

  while (flg == 0 && p != NULL) {
    if (p->x == x) {
      Node *c = p;
      if (c->prev != NULL) {
        p->prev->next = c->next;
      } else {
        head = c->next;
      }

      if (c->next != NULL) {
        p->next->prev = c->prev;
      } else {
        tail = c->prev;
      }
      flg = 1;
    } else {
      p = p->next;
    }
  }
}

void deleteFirst() {
  if (head == tail) {
    head = NULL;
    tail = NULL;
  } else if (head != NULL) {
    if (head->next != NULL) head->next->prev = NULL;
    head = head->next;
  }
}

void deleteLast() {
  if (head == tail) {
    head = NULL;
    tail = NULL;
  } else if (tail != NULL) {
    if (tail->prev != NULL) tail->prev->next = NULL;
    tail = tail->prev;
  }
}

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

  int n;
  scanf("%d\n", &n);

  int i;
  int x;
  char buf[256];
  char tmp[256];
  for (i = 0; i < n; ++i) {
    fgets(buf, 256, stdin);

    if (buf[0] == 'i' || buf[6] == ' ') {
      sscanf(buf, "%s %d", tmp, &x);

      if (buf[0] == 'i') insert(x);
      else               delete(x);
    } else if (buf[6] == 'F') {
      deleteFirst();
    } else if (buf[6] == 'L') {
      deleteLast();
    }
  }

  dump();

  return 0;
}



Measured memory_bytes: 36128
#include<cstdio>
int n,k,x,m,ans;
bool b[105];
int main()
{
	scanf("%d%d",&n,&k);
	while(k--)
	  {
	  	scanf("%d",&m);
	  	for(int i=1;i<=m;++i)
	  	  {
	  	  	scanf("%d",&x);
	  	  	b[x]=true;
		  }
	  }
	for(int i=1;i<=n;++i)
	  if(!b[i])++ans;
	printf("%d",ans);
}

Measured memory_bytes: 1732
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  long long int n;
  cin>>n;
  int streak=0;
  int ans=0;
  for(int i=0; i<n; i++){
    int a,b;
    cin>>a>>b;
    if(a==b){
      streak++;
    }else{
      ans=max(ans,streak);
      streak=0;
    }
  }
  ans=max(ans,streak);
  if(ans>=3){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;i++)
#define pb push_back
typedef long long ll;
typedef pair<int,ll> P;
typedef vector<P> vip;

void solve(){
    int n;cin>>n;
    string s=to_string(n);
    int sum=0;
    int a = s.size();
    fol(i,a){
        sum+=s[i]-'0';
    }
    cout <<(n%sum?"No":"Yes")<<endl;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <random>
#include <chrono>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

template<typename T> using maximum_heap = std::priority_queue<T, std::vector<T>, std::less<T>>;
template<typename T> using minimum_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T>
std::istream& operator>>(std::istream &is, std::vector<T> &v)
{
  for (typename std::vector<T>::size_type i = 0; i < v.size(); ++i) {
    is >> v[i];
  }
  return is;
}

using namespace std;

const uint64_t M = 1e+6;

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

  vector<uint64_t> A(N);
  cin >> A;

  vector<uint64_t> sieve(M + 1);
  N_TIMES(m, M + 1) { sieve[m] = m; }
  for (uint64_t m = 2; m <= M; ++m) {
    if (sieve[m] != m) { continue; }

    uint64_t i = m << 1;
    while (i <= M) {
      if (sieve[i] == i) {
        sieve[i] = m;
      }
      i += m;
    }
  }

  bool pairwise_flag = true;
  vector<uint64_t> factor(M + 1, 0);
  N_TIMES(n, N) {
    map<uint64_t, uint64_t> hash;

    uint64_t x = A[n];
    while (x > 1) {
      ++hash[ sieve[x] ];
      x /= sieve[x];
    }

    for (const pair<uint64_t, uint64_t> &p : hash) {
      if (factor[p.first] > 0) {
        pairwise_flag = false;
      }
      factor[p.first] += p.second;
    }
  }

  if (pairwise_flag) {
    cout << "pairwise coprime" << endl;
  } else {
    uint64_t set_gcd = A[0];
    N_TIMES(n, N) { set_gcd = gcd(set_gcd, A[n]); }

    if (set_gcd == 1) {
      cout << "setwise coprime" << endl;
    } else {
      cout << "not coprime" << endl;
    }
  }

  return 0;
}

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

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

    string s;
    getline(cin, s);

    int n = 0;
    for (int i=0; i<3; i++)
    {
        if(s[i] == 'R')
            n++;
    }

    if(n == 2 && s[1] == 'S')
        n--;

    cout << n << "\n";
    return 0;
}

Measured memory_bytes: 3648
// https://atcoder.jp/contests/agc024/tasks/agc024_a
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = (n - 1); i >= 0; i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    if (K & 1) {
        cout << B - A << endl;
    } else {
        cout << A - B << endl;
    }

    return 0;
}


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

int main(){
  
  int N,A,B;
  
  cin >> N >> A >> B;
  
  if (N*A < B){
    
    cout << N*A <<endl;
    
  }
  
  else if(N*A == B){
    
    cout << B << endl;
    
  }
  
  if (N*A > B){
    
    cout << B << endl;
    
  }
}


Measured memory_bytes: 256
import sys
import math
import collections
import bisect
import itertools

# import numpy as np

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: map(int, sys.stdin.readline().rstrip().split())
na = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))


# ===CODE===

def main():
    n = ni()
    l = na()
    r = na()

    res_l = [[0, False] for _ in range(n)]
    res_r = [[0, False] for _ in range(n)]

    checker = True

    tmp = 0
    for i, li in enumerate(l):
        if li > tmp:
            res_l[i] = li, True
        elif li == tmp:
            res_l[i][0] = tmp
        else:
            checker = False
            break
        tmp = li

    tmp = 0
    for i, ri in enumerate(reversed(r)):
        if ri > tmp:
            res_r[-1 - i] = ri, True
        elif ri == tmp:
            res_r[-1 - i][0] = tmp
        else:
            checker = False
            break
        tmp = ri

    res = [[0, False] for _ in range(n)]

    for i in range(n):
        if res_l[i][1] and res_r[i][1]:
            if res_l[i][0] != res_r[i][0]:
                checker = False
                break
            else:
                res[i] = res_l[i][0], True
        elif res_l[i][1] or res_r[i][1]:
            t_num = res_l[i][0] if res_l[i][1] else res_r[i][0]
            f_num = res_l[i][0] if not res_l[i][1] else res_r[i][0]
            if t_num > f_num:
                checker = False
                break
            else:
                res[i] = t_num, True
        else:
            res[i] = min(res_l[i][0], res_r[i][0]), False

    ans = 1
    for num, flg in res:
        if flg:
            continue
        ans *= num
        ans %= MOD

    print(ans if checker else 0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 43544