akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}

#[allow(unused_macros)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn main() {
    let (a, b) = read!(i32, i32);

    let mut west = 1;
    let mut east = 3;
    let mut diff = 2;

    loop {
        if west - a == east - b {
            println!("{}", west - a);
            return;
        }
        west = east;
        east = east + diff + 1;
        diff += 1;
    }
}


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

int main() {
    for (int i=0; i<4; i++) {
        int ti, ni; cin >> ti >> ni;
        
        if (ti==1) {
            cout << 6000*ni << endl;
        }
        else if (ti==2) {
            cout << 4000*ni << endl;
        }
        else if (ti==3) {
            cout << 3000*ni << endl;
        }
        else {
            cout << 2000*ni << endl;
        }
    }
}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

pii pp[MAXN];
ll sum[MAXN];

void solve(){
	int n;
	scanf("%d", &n);
	REP(i, 0, n){
		scanf("%d", &pp[i]._1);
		pp[i]._2 = i;
	}
	sort(pp, pp + n);
	sum[0] = pp[0]._1;
	int bad_ind = 0;
	REP(i, 1, n){
		if (pp[i]._1 > 2 * sum[i - 1]){
			bad_ind = i;
		}
		sum[i] = sum[i - 1] + pp[i]._1;
	}
	printf("%d\n", n - bad_ind);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 1792
using System;
using System.IO;
using System.Linq;

namespace Contest
{
    class Program
    {
        private Scanner sc;
        public void Solve()
        {
            sc = new Scanner();
            int N = sc.NextInt();
            int M = sc.NextInt();
            bool[] d = new bool[N + 1];
            for (int i = 0; i < M; i++)
            {
                d[sc.NextInt()] = true;
            }

            var dp = new int[N + 1];
            dp[0] = 1;
            for (int i = 0; i < N; i++)
            {
                if (d[i]) continue;
                dp[i + 1] += dp[i];
                dp[i + 1] %= 1000000007;
                if (i + 2 <= N)
                {
                    dp[i + 2] += dp[i];
                    dp[i + 2] %= 1000000007;
                }
            }
            Console.WriteLine(dp[N]);
        }


        static void Main() => new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _stream = new StreamReader(Console.OpenStandardInput());
        _pos = 0;
        _line = new string[0];
        _separator = ' ';
    }
    private char _separator;
    private StreamReader _stream;
    private int _pos;
    private string[] _line;
    #region get a element
    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = _stream.ReadLine().Split(_separator);
            _pos = 0;
        }
        return _line[_pos++];
    }
    public int NextInt()
    {
        return int.Parse(Next());
    }
    public long NextLong()
    {
        return long.Parse(Next());
    }
    public double NextDouble()
    {
        return double.Parse(Next());
    }
    #endregion
    #region convert array
    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }
    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }
    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }
    #endregion
    #region get array
    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = _stream.ReadLine().Split(_separator);
        _pos = _line.Length;
        return _line;
    }
    public int[] IntArray()
    {
        return ToIntArray(Array());
    }
    public long[] LongArray()
    {
        return ToLongArray(Array());
    }
    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }
    #endregion
}

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


Measured memory_bytes: 2552
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

void main()
{
    long N = lread();
    writeln((N * 800) - ((N/15) * 200));
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;
using System.Runtime.InteropServices.ComTypes;
using System.Xml.Schema;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var S = ReadLine();
            var ren = 0L;
            var cnt = 0L;
            foreach (var s in S)
                if ("ACGT".Contains(s)) { ++cnt;ren = Max(ren, cnt); }
                else cnt = 0;
            WriteLine(ren);
        }

        static long Mod = 998244353;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static public (T a, T b, T c, T d) Slice4<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)),
            (T)Convert.ChangeType(t[3], typeof(T)));
        }
    }
}

Measured memory_bytes: 25888
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    let n = io.read::<usize>();
    let a = io.readn::<usize>(n);
    let mut sowa = 0f64;

    for &x in a.iter() {
        sowa += 1.0f64 / x as f64;
    }
    io.writeln(1f64 / sowa);
}

static MX: usize = 1010101;
static MOD: i64 = 1000000007;
static INF: i64 = std::i64::MAX >> 1;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn chari(&mut self) -> Vec<i64> {
        self.chars()
            .iter()
            .map(|&c| (c as u8 - b'0') as i64)
            .collect::<Vec<i64>>()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


Measured memory_bytes: 2164
N,M = map(int,input().split())
a = [0]*N
b = [None]*N
for i in range(M):
  s,c = map(int,input().split())
  if b[s-1] == c:
    continue
  else:
    a[s-1] +=1
    b[s-1] =c
    
count = 0
for i in range(N):
  if a[i]>=2:
    count=-1
  elif b[0]==0 and N>1:
    count =-1
  elif i==0:
    if b[i] is None:
      if N==1:
        b[i] =0
      else:
        b[i]=1
  elif i>0:
    if b[i] is None:
      b[i]=0
b.reverse()
if count == 0:
  for i in range(N):
    count+=b[i]*10**i
print(count)

Measured memory_bytes: 9184
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

const ll mod = 1000000007;
const ll INF = 1000000000000000000;
struct edge { int to, cost; };

int n, m, s, t;
vector<edge> vec[100010];
ll d1[100010], d2[100010];
ll cnt1[100010], cnt2[100010];
ll ans;

void dijkstra(int x, ll *d, ll *cnt) {
	fill(d, d + n + 1, INF);
	d[x] = 0;
	cnt[x] = 1;
	priority_queue<pair<ll,int>, vector<pair<ll, int>>, greater<pair<ll, int>>> que;
	que.push(make_pair(0, x));
	while (!que.empty()) {
		int v = que.top().second; ll k = que.top().first; que.pop();
		if (d[v] < k)continue;
		for (int i = 0; i < (int)vec[v].size(); i++) {
			edge e = vec[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				cnt[e.to] = cnt[v];
				que.push(make_pair(d[e.to], e.to));
			}
			else if (d[e.to] == d[v] + e.cost) cnt[e.to] = (cnt[e.to] + cnt[v]) % mod;
		}
	}
}

signed main() {
	cin >> n >> m >> s >> t;
	for (int i = 0; i < m; i++) {
		int u, v, c; cin >> u >> v >> c;
		vec[u].push_back(edge{ v,c });
		vec[v].push_back(edge{ u,c });
	}
	dijkstra(s, d1, cnt1);
	dijkstra(t, d2, cnt2);
	ans = cnt1[t] * cnt1[t] % mod;
	for (int i = 1; i <= n; i++) {
		if (d1[t] == d1[i] * 2) ans = (ans - cnt1[i] * cnt1[i] % mod*cnt2[i] % mod * cnt2[i] % mod + mod) % mod;
		if (d1[t] <= d1[i] * 2)continue;
		for (int j = 0; j < (int)vec[i].size(); j++) {
			edge e = vec[i][j];
			if (d1[e.to] * 2 <= d1[t])continue;
			if (d1[t] < d1[i] + d2[e.to] + e.cost)continue;
			ans = (ans - cnt1[i] * cnt1[i] % mod*cnt2[e.to] % mod * cnt2[e.to] % mod + mod) % mod;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 15060
#include<stdio.h>
#include<math.h>
int main()
{
long a,b,c,i,min;
scanf("%ld",&a);
min=a;
for(i=1;i<=sqrt(a);i++){
if((a%i)==0){
b=a/i;
c=i+b-2;
if(min>c){
min=c;
}
}
}
printf("%ld\n",min);
return 0;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")


int main()
{
	
	int N,K;
	cin >> K >> N;
	vec(A);
	fx(N) {
		vecp(A);
	}
	int maxi = 0;
	fx(N-1) {
		maxi = max(maxi, abs(A[x] - A[x + 1]));
	}
	maxi = max(maxi, K - A[N - 1] + A[0]);
	ce(K-maxi)

    return 0;
}



Measured memory_bytes: 1528
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  V<> a(n); for (auto&& e : a) cin >> e;
  int c = 0;
  for (int i = 0; i < n; ++i) c += a[i] < 0;
  lint res = 0;
  if (c & 1) {
    int mn = 2e9;
    for (int i = 0; i < n; ++i) mn = min(mn, abs(a[i]));
    for (int i = 0; i < n; ++i) res += abs(a[i]);
    res -= 2 * mn;
  } else {
    for (int i = 0; i < n; ++i) res += abs(a[i]);
  }
  cout << res << '\n';
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int D;
  cin >> D;
  
  vector<int> c(26);
  for (int i = 0; i < 26; i++) {
    cin >> c.at(i);
  }
  
  vector<vector<int>> s(D, vector<int>(26));

  // 入力 (2重ループを用いる)
  for (int i = 0; i < D; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> s.at(i).at(j);
    }
  }
  
  vector<int> t(D);
  for (int i = 0; i < D; i++) {
    cin >> t.at(i);
  }
  
  int man = 0;
  vector<int> last(26,0);
  for(int i=0; i<D; i++){
    int kaisai = t.at(i) - 1;
    man += s.at(i).at(kaisai);
    
    last.at(kaisai) = i+1;
    
    for(int j=0; j<26; j++){
      man -= c.at(j)*(1 + i - last.at(j));
	}
    
    cout << man << endl;
  }
  
  return 0; 
}

Measured memory_bytes: 3596
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
      int r = sc.nextInt();
      int nr = 0;
      if(n>=10){
         nr = r;
         System.out.println(nr);
      }else{
         nr = r+100*(10-n);
         System.out.println(nr);
      }
	}
}


Measured memory_bytes: 35580
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main() {
	string S;
	string dance;
	int len=0;

	cin >> S;
	len = S.size();
	for (int i = 0; i < len;i++) {
		dance= S.substr(i,1);

		if((i+1)%2==0){//偶数
			if (dance == "R")
			{
				cout << "No";
				return 0;
			}
		}
		else {
			if (dance == "L")
			{
				cout << "No";
				return 0;
			}

		}
	}
	cout << "Yes";

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    String word = sc.next();

    if("ABC".equals(word)) {
    	System.out.println("ARC");
    } else {
    	System.out.println("ABC");
    }

  }
}

Measured memory_bytes: 26924
package main

import "fmt"

func main() {
	// Code for A - One Card Poker
	var A, B int
	fmt.Scanf("%d %d", &A, &B)

	if A == 1 {
		A += 13
	}
	if B == 1 {
		B += 13
	}

	if A > B {
		fmt.Println("Alice")
	} else if A < B {
		fmt.Println("Bob")
	} else {
		fmt.Println("Draw")
	}
}


Measured memory_bytes: 1832
import sys
  
def toBin(n):
    l = []
    i = 0
    a,b = n,n
    while True:
        b = a % 2
        a = a // 2
        if b == 1:
            l.append(b*(2**i))
        i += 1
        if a == 0:
            break
    return l


for line in sys.stdin:
    n = int(line)
    print(*toBin(n),sep=' ')


Measured memory_bytes: 5620
#include <stdio.h>
#include <iostream>
//#include <string>
//#include <cmath>
#include <vector>
#include <algorithm>
// #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(n); ++i)

const int INF = 1001001001;
int a[12][12];

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

  vector<int> c(n);
  rep(i, n) {
    cin >> c[i];
    rep(j,m) cin >> a[i][j];
  }

  int ans = INF;
  rep(s, 1<<n) {
    int cost = 0;
    vector<int> d(m);
    rep(i, n) {
      if (s>>i&1) {
	cost += c[i];
	rep(j,m) d[j] += a[i][j];
      }
    }
    bool ok = true;
    rep(j,m) if (d[j] < x) ok = false;
    if (ok) ans = min(ans, cost);
  }

  if(ans == INF) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

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

struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

bool isPalindrome(string s){
    string t = s;
    reverse(all(t));
    return s==t;
}

constexpr ll LNF = __LONG_LONG_MAX__;

constexpr int INF = 1e9+7;

const double PI=3.14159265358979323846;


vector<int> dx = {-1,0,1,0,-1,1,-1,1};
vector<int> dy = {0,-1,0,1,1,-1,-1,1};

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,a; cin >> n >> a;
    vector<int> x(n);
    int mid = 0;
    rep(i,0,n){
        cin >> x[i];
        x[i] -= a;
        chmax(mid,abs(x[i]));
    }
    mid *= n;
    vector<vector<ll>> dp(n+1,vector<ll>(2*mid+1,0));
    dp[0][mid] = 1ll;
    rep(i,0,n){
        rep(j,0,2*mid+1){
            if(j+x[i]>=0 && j+x[i]<=2*mid){
                dp[i+1][j+x[i]] += dp[i][j];
            }
            dp[i+1][j] += dp[i][j];
        }
    }
    cout << dp[n][mid]-1 << endl;
}

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

using namespace std;

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

    if ( A%2 == B%2 )
    {
        cout << (A+B)/2 << endl;
    }
    else
    {
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 1001
using namespace std;
/*
  ??????????¨?????????????????????????
  ??°???????¨?????????????????????????
*/

int n,x[N],y[N];
double mem[N][N];
int used[N][N];

double calc(int i,int j){
  double a = x[i]-x[j];
  double b = y[i]-y[j];
  return sqrt(a*a+b*b);

}

double dfs(int a,int b,int idx){
  if(idx == n) return calc(a,n-1)+calc(b,n-1);
  if(used[a][b]++) return mem[a][b];
  double res = 1e9;
  res = min(res,calc(a,idx)+dfs(idx,b,idx+1));
  res = min(res,calc(b,idx)+dfs(a,idx,idx+1));
  return mem[a][b] = res;  
}


int main(){
  cin>>n;
  for(int i=0;i<n;i++) cin>>x[i]>>y[i];
  printf("%lf\n",dfs(0,0,1));
  return 0;
}

Measured memory_bytes: 14908
#include <bits/stdc++.h>
#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++)
 
 

using namespace std;

int main() {
  string s;
  cin>>s; 
  
  rep(j,s.size()){
    if(j%2==0){
      cout<<s.at(j);
    }
  }
  
}

Measured memory_bytes: 512
#include<stdio.h>   
 
int main(void)     
 
{     
 
int a,b;     
 
scanf("%d",&a);     
 
scanf("%d",&b);     
 
printf("%d %d\n",a*b,2*a+2*b);     
 
return 0;     
 
}
 

 

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

int main()
{
    int n;
    cin >> n;

    vector<string> s(n);
    rep (i, n)
        cin >> s[i];

    bool ok = true;
    rep (i, n - 1)
        if (s[i][s[i].size() - 1] != s[i + 1][0])
            ok = false;

    sort(s.begin(), s.end());
    rep (i, n - 1)
        if (s[i] == s[i + 1])
            ok = false;

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

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

int main() {
  int a, b, tmp = 0;
  cin >> a >> b;

  for (int i = a; i <= b; i++) {
    if (i / 10000 == i % 10 && i / 1000 % 10 == i / 10 % 10) tmp++;
  }
  cout << tmp << endl;
  return 0;
}


Measured memory_bytes: 256
import sys

n=int(input())

w=[]
for i in range(n):
    w.append(input())

prev=[]
for i in range(n):
    x=w[i]
    if x in prev:
        print('No')
        sys.exit()
    elif i>0 and x[0]!=w[i-1][-1]:
        print('No')
        sys.exit()
    else:
        prev.append(x)
print('Yes')   

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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

int al[30], aal[30];

int main()
{
    int n;
    cin >> n;

    for(int i = 0; i < n; i++){
        string s;
        cin >> s;

        int L = s.size();
        for(int j = 0; j < L; j++)
            al[s[j] - 'a']++, aal[s[j] - 'a'] += (i == 0);

        if(i)
            for(int j = 0; j < 26; j++)
                aal[j] = min(aal[j], al[j]);

        mem(al, 0);
    }

    string s;
    for(int i = 0; i < 26; i++){
        while(aal[i])
            s.Pb((char)(i + 'a')), aal[i]--;
    }

    cout << s << '\n';
    return 0;
}


Measured memory_bytes: 3636
import java.text.DecimalFormat;
import java.util.Scanner;

class Main {
    private static final Scanner sc = new Scanner(System.in);
    private static final DecimalFormat df = new DecimalFormat("0.########");
    public static void main(String[] Args) {
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        System.out.println(a/b+" "+a%b+" "+df.format((double) a/b));
    }
}

Measured memory_bytes: 26444
#include <iostream>
#include <stdio.h>

using namespace std;

#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


int main()
{
	string w;
	cin >> w;
	int a[100] = {};
//	printf("%d\n", w[0] - 96);

	for (int i = 0; i < w.size(); i++) {
		a[w[i]-96]++;
	}

	string ans = "Yes";
	for (int i = 0; i < 100; i++) {
		if ((a[i] % 2) == 1) {
			ans = "No";
			break;
		}
	}

	cout << ans << "\n";
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  int t,T,i;
  int base[3]={0};
  int point=0,out;
  char action[100];
  scanf("%d",&t);

  for(T=0;T<t;T++){


    out=0;
    for(i=0;i<3;i++){
      base[i]=0;
    }
    point=0;


    while(1){
      scanf("%s",action);
      if(strcmp(action,"HIT")==0){
	if(base[0]==0){
	  base[0]++;
	}
	else{
	  if(base[1]==0){
	    base[1]++;
	  }
	  else{
	    if(base[2]==0){
	      base[2]++;
	    }
	    else{
	      point++;
	    }
	  }
	}
      }
      else if(strcmp(action,"OUT")==0){
	out++;
	if(out==3){
	  break;
	}
      }
      else if(strcmp(action,"HOMERUN")==0){
	point++;
	for(i=0;i<3;i++){
	  if(base[i]==1){
	    point++;
	    base[i]=0;
	  }
	}
      }
    }
    printf("%d\n",point);
  }
  return (0);
}

Measured memory_bytes: 592
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=3010;
int p,n,S[N][N],C[N][N],H[N][N];
int qpow(int a,int b,int p)
{int ret=1;while(b){if(b&1)ret=1ll*ret*a%p;a=1ll*a*a%p;b>>=1;}return ret;}
int main()
{
    scanf("%d%d",&n,&p);
    C[0][0]=S[0][0]=1;
    for(int i=1;i<=n+1;i++)
    {
        C[i][0]=1,S[i][0]=0;
        for(int j=1;j<=n+1;j++)
            C[i][j]=(C[i-1][j]+C[i-1][j-1])%p,S[i][j]=(S[i-1][j-1]+1ll*S[i-1][j]*j)%p;
    }
    int ans=0;
    for(int i=0;i<=n;i++)
    {
        int sum=0;
        for(int j=0;j<=i;j++)sum=(sum+1ll*S[i+1][j+1]*qpow(2,(n-i)*j,p))%p;
        ans=(ans+1ll*sum*C[n][i]%p*qpow(2,qpow(2,n-i,p-1),p)%p*(i&1?p-1:1))%p;
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 71680
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

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

int main()
{
        //input->compute->output//

        int A, B;
        cin >> A >> B;
        if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0)
        {
                cout << "Possible" << endl;
        }
        else
        {
                cout << "Impossible" << endl;
        }

        return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

#define endl "\n"

const ll INF = 1e15;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

const int N = 2005;

ll n, k, a[N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);

    cin >> n >> k;

    for (int i = 0; i < n; ++i) 
        cin >> a[i];

    ll ans = 0, sum = 0;
    for (int i = 0; i < n; ++i) {
        ll g = 0;
        for (int j = 0; j < n; ++j)
            if (a[j] < a[i]) ++g;

        (ans += max(((k * (k - 1) / 2) % MOD) * g, 0ll)) %= MOD;

        for (int j = i + 1; j < n; ++j)
            if (a[j] < a[i]) (ans += k) %= MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef double db;
//mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
//int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
int main() {
	string s,t;
	cin>>s>>t;
	
	
    int lenS=s.length();
    int lenT=t.length();
    
	int maxx=0,cnt=0;
	for(int i=0;i+lenT<=lenS;i++){
		cnt=0;
		rep(j,0,t.size() ){
			if(s[i+j]==t[j]){
				cnt++;
		 }
			maxx=max(cnt,maxx);
		}
	}
	printf("%d",t.size()-maxx);
} 

Measured memory_bytes: 3724
k, n = map(int, input().split())
A = list(map(int, input().split()))

delta_list = []

for a, b in zip(A[:-1], A[1:]):
    delta = b - a
    delta_list.append(delta)

delta_list.append(k - A[-1] + A[0])

candidates = [k-delta for delta in delta_list]
print(min(candidates))

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

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define endl '\n'
#define FASTIO std::ios::sync_with_stdio(false)

#define PRIME (1000000007)
#define oo (1 << 30)

#define debug(x) cerr << #x << " = " << x << endl
#define all(x) x.begin(), x.end()

#define loop(i, begin, end)                            \
  for (__typeof(end) i = (begin) - ((begin) > (end)); \
       i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

template <class T>
std::vector<T> ReadVec(int n) {
    std::vector<T> answer(n);

    loop(i, 0, n) {
        std::cin >> answer[i];
    }
    return answer;
}

template <class T>
void PrintVec(std::vector<T> v) {
    loop(i, 0, v.size()) {
        std::cout << v[i] << " ";
    }
    std::cout << endl;
}

using namespace std;

int main() {
    FASTIO;

    string s, ans;
    cin >> s;

    bool easy = true;
    loop(i, 0, s.size()) {
        if((i + 1) % 2 == 1 && s[i] == 'L') {
            easy &= false;
        }  
        else if((i + 1) % 2 == 0 && s[i] == 'R') {
            easy &= false;
        }
    }
    cout << (easy ? "Yes" : "No") << endl;
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left!=NIL)x=x->left;
  return x;

}

Node treeMaximum(Node x){
  while(x->right!=NIL)x=x->right;
  return x;


}

Node treeSearch(Node u, int k){
  while(u!=NIL&&k!=u->key){
    if(k<u->key)u=u->left;
    else u=u->right;
  }
  return u;
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right!=NIL)return treeMinimum(x->right);

  y=x->parent;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left==NIL||z->right==NIL)y=z;
  else y=treeSuccessor(z);

  if(y->left!=NIL)x=y->left;
  else x=y->right;

  if(x!=NIL)x->parent=y->parent;

  if(y->parent==NIL)root=x;
  else if(y==y->parent->left)y->parent->left=x;
  else y->parent->right=x;

  if(y!=z)z->key=y->key;
  
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key)
      x=x->left;
    else x=x->right;
  }
  z->parent=y;

  if(y==NIL)
    root=z;
  else if(z->key<y->key)
    y->left=z;
  else
    y->right=z;
    
}

void inorder(Node u){
  if(u==NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



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

#define ll long long
#define mod 1000000007

ll bigmod(ll a, ll p)
{
	if(p==0) return 1;
	ll mul= bigmod(a,p/2);

	if(p&1) return ((mul*mul)%mod * a)%mod;
	return (mul*mul)%mod;
}

ll inv(ll x)
{
	return bigmod(x,mod-2);
}

ll f[2000007];

int main()
{
	f[0]=1;
	for(int i=1;i<2000007;i++)
	{
		f[i]=(f[i-1]%mod) * (i%mod);
		f[i]%=mod;
	}

	ll x,y;
	cin >> x >> y;

	ll r=0;
	for(int i=1;i<=1000000;i++, r++)
	{
		if(y<0 || x<0 || y<r) break;

		if(2*y == x)
		{
			ll k=y;

			cout << ((f[k]%mod*inv(f[r])%mod)%mod * (inv(f[k-r])%mod))%mod << endl;
			return 0;
		}

		x++,y--;
	}

	cout << 0 << endl;

	return 0;
}


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

using namespace std;
int main()
{
  string s;
  cin >> s;
  if (s[0] == 'S') cout << "Cloudy";
  if (s[0] == 'R') cout << "Sunny";
  if (s[0] == 'C') cout << "Rainy";
  return 0;
}

Measured memory_bytes: 256
from itertools import accumulate

n = int(input())
s = input()

t01 = ""
t10 = ""

for x in s:
    if x == "E":
        t01 += "0"
        t10 += "1"
    else:
        t01 += "1"
        t10 += "0"

l1 = [int(a) for a in t01]
l2 = [int(a) for a in t10]
left = [0] + list(accumulate(l1))[:-1]
right = list(accumulate(l2[::-1]))[-2::-1] + [0]
print(min(w + e for (w, e) in zip(left, right)))

Measured memory_bytes: 40616
#include <bits/stdc++.h>
#define rep0(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<string, int, int> TU;
typedef tuple<int, int, int> TI;

int main()
{
    int n;
    cin >> n;
    int input[n],clo[n];
    rep0(i,n){
        cin >> input[i];
        clo[i] = input[i];
    }
    sort(clo,clo+n);
    int left = clo[n/2-1];
    int right = clo[n/2];
    rep0(i,n){
        if(input[i]<=left){
            cout << right << endl;
        }else{
            cout << left << endl;
        }
    }
}


Measured memory_bytes: 5176
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
 
int main(){
 
  int N , ans=0;
  int L[101]={0};
  vector<int> v;
  
  cin >> N;

  for(int i=1 ; i<=N; i++){
   cin >> L[i];
  }
  
  for(int i=1 ; i<=N; i++){
      for(int j=i+1 ; j<=N; j++){
          for(int k=j+1 ; k<=N; k++){ 
           
            v.push_back(L[i]);
            v.push_back(L[j]);
            v.push_back(L[k]);
            sort(v.begin(), v.end());
            
            if(L[i]!=L[j] && L[j]!=L[k] && L[k]!=L[i] && v[0]+v[1]>v[2]){
              ans++;
            }
            
            v.clear();
   
  }
  }
  }

  
  cout << ans;
  
  return 0;
}

Measured memory_bytes: 3628
import sys

prime = [2,3,5,7,11,13,17,19,23,29,31]

shieve1 = [1]*1001
for i in prime:
    itr = i-1
    while(itr<1000):
        shieve1[itr] = 0
        itr += i

for i in range(32,1000):
    if shieve1[i]:
        prime.append(i+1)

shieve2 = [1]*(10**6+1)

for i in prime:
    itr = i-1
    while(itr<10**6):
        shieve2[itr] = 0
        itr += i

for i in range(1001,10**6+1):
    if shieve2[i]:
        prime.append(i+1)

for line in sys.stdin:
    n = int(line)
    cont = 0
    for i in prime:
        if i<=n:
            cont += 1
        else:
            break
    print(cont)

Measured memory_bytes: 18308
#include <iostream>
using namespace std;
int main(void)
{
    int num,x;
    
    cin >> num;
    x = num;
    
    while(1)
    {
        if(x % 2 == 0 && x % num == 0)
        {
                break;
        }
        else
        {
            x = x + 1;
            continue;
        }
    }
    cout << x << endl;
}

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

bool solve() {
    string S;
    cin >> S;
    vector<int> num(3);
    for ( char c : S ) {
        num[c-'a']++;
    }
    sort(num.begin(), num.end());
    int n = S.size();
    if ( num[0] > n/3 ) return false;
    if ( num[1] > (n+1)/3 ) return false;
    if ( num[2] > (n+2)/3 ) return false;
    return true;
}

int main() {
    string ans = solve() ? "YES" : "NO";
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 512
N = input()
A = list(map(int, input().split()))
flag = 0

for val in A:
  if val % 2 == 0:
    if val % 3 != 0 and val % 5 != 0:
      flag = 1 
    
if flag == 0:
  print("APPROVED")
elif flag == 1:
  print("DENIED")

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

int main()
{
    int x,y;
    cin >> x >> y;
    string ans = "No";
    for (int i = 0; i <= x; i++) {
        if (i*2+(x-i)*4 == y) {
            ans = "Yes";
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <algorithm>

#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

int n;
int x[10000];

int main(){
	while(true){
		scanf("%d", &n);
		if(n == 0){
			break;
		}
		rep(i, n){
			scanf("%d", &x[i]);
		}
		int ans = n;
		rep(i, n){
			int c = x[i];
			for(int j = -1; j <= 1; j += 2){
				if(i + j < 0 || i + j >= n){
					continue;
				}
				x[i] = x[i + j];
				int k = 0;
				int s = i, t = i;
				while(s >= 0){
					int d = x[s];
					while(s >= 0 && x[s] == d){
						--s;
					}
					while(t < n && x[t] == d){
						++t;
					}
					if((t - s - 1) - k < 4){
						break;
					}
					k = t - s - 1;
					ans = min(n - k, ans);
				}
			}
			x[i] = c;
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1064
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <climits>

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

#define YesNo(b) ((b) ? "Yes" : "No")
#define YESNO(b) ((b) ? "YES" : "NO")

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;



int main()
{
    int N, M;
    cin >> N >> M;

    vector<bool> A(N, false);

    if (N % 2 == 0)
    {
        int hN = N/2;
        for (int d = 1; d <= M; ++d)
        {
            int l = hN + 1 - d;
            int r = (2*d-1 >= hN) ? hN+1+d : hN + d;
            if (r - l == hN) continue;
            cout << l << " " << r << endl;
        }
    }
    else
    {
        int hN = N/2;
        for (int d = 1; d <= M; ++d)
        {
            int l = hN + 1 - d;
            int r = hN + d;
            cout << l << " " << r << endl;
        }
    }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K;
    cin >> N >> K;
    vec<int> X(N);
    for(auto& x:X) cin >> x;
    int ans = 2e9;
    for(int i=0;i+K<=N;i++){
        int l = i,r = i+K-1;
        if(X[l]<=0 && X[r]<=0) ans = min(ans,abs(X[l]));
        else if(X[l]>=0 && X[r]>=0) ans = min(ans,abs(X[r]));
        else ans = min(ans,min(2*abs(X[l])+abs(X[r]),abs(X[l])+2*abs(X[r])));
    }
    cout << ans << "\n";
}

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

int main(){
    int  N, K, ans=0, tmp, tmp2;
    priority_queue<int, vector<int>, greater<int>> desc;
    cin >> N >> K;
    vector<int> V(N);
    for(int i=0; i<N; i++){
	cin >> V[i];
    }

    // for(int i=0; i<=K && i<N; i++){	
    // 	for(int j=0; j<=K&& j<N; j++){
    for(int i=0;i<=K&&i<=N;i++){
        for(int j=0;i+j<=K&&i+j<=N;j++){
	    tmp=0;
	    tmp2=i+j;
	    // if(tmp2>K)
	    // 	continue;	    
	    for(int k=0; k<i; k++){
		desc.push(V[k]);
	    }
	    for(int k=0; k<j; k++){
		desc.push(V[N-1-k]);
	    }
	    while(!desc.empty()){
		    // cout << desc.top()<< endl;
		
		if(desc.top()<0 && tmp2<K)
		    tmp2++;
		else
		    tmp+=desc.top();
		desc.pop();
	    }

	    // if (tmp == 6)
	    // 	cout << i<< " " << j<< endl;
	    // if (i == 2 && j==1)
	    // 	cout << tmp<< endl;

	    ans = max(ans, tmp);
	}	
    }
    cout << ans << endl;
}



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

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int MAX_N = 100000;
int N;
char s[MAX_N+1];
int ani[MAX_N+1];

bool judge(int x, int y, int z, char c) {
  if (c == 'o' && y == 1 && x == z) return true;
  if (c == 'o' && y == -1 && x != z) return true;
  if (c == 'x' && y == 1 && x != z) return true;
  if (c == 'x' && y == -1 && x == z) return true;
  return false;
}

int main() {
  scanf("%d %s", &N, s+1);

  for (int i = -1; i <= 1; i+=2) {
    for (int j = -1; j <= 1; j+=2) {
      ani[1] = i; ani[2] = j;
      for (int k = 3; k <= N; ++k) {
        if (s[k-1] == 'o' && ani[k-1] == 1) {
          ani[k] = ani[k-2];
        } else if (s[k-1] == 'o' && ani[k-1] == -1) {
          ani[k] = -ani[k-2];
        } else if (s[k-1] == 'x' && ani[k-1] == 1) {
          ani[k] = -ani[k-2];
        } else if (s[k-1] == 'x' && ani[k-1] == -1) {
          ani[k] = ani[k-2];
        }
      }
      if (judge(ani[N-1], ani[N], ani[1], s[N]) && judge(ani[N], ani[1], ani[2], s[1])) {
        for (int l = 1; l <= N; ++l) {
          if (ani[l] == 1) printf("%c", 'S');
          else printf("%c", 'W');
        }
        putchar('\n');
        return 0;
      } 
    }
  }

  printf("%d\n", -1);

  return 0;
}


Measured memory_bytes: 768
package main

import "fmt"

func main() {
	var (
		a int
		b string
		c int
	)
	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&c)
	if b == "+" {
		fmt.Println(a + c)
	}
	if b == "-" {
		fmt.Println(a - c)
	}
}

Measured memory_bytes: 1768
#include <iostream>
#include <string>
#include <map>
#include <set>
using namespace std;

int main(){
  string phrase;
  int page;
  map<string, set<int> > dictionary;

  while(cin >> phrase >> page){
    //cin >> phrase >> page;
    // if(phrase == "end") break;
    dictionary[phrase].insert(page);
  }

  map<string, set<int> >::iterator p1;
  set<int>::iterator p2;

  for(p1 = dictionary.begin(); p1 != dictionary.end(); p1++){
    cout << (*p1).first << endl;

    p2 = dictionary[(*p1).first].begin();
    cout << *p2;
    for( p2++; p2 != dictionary[(*p1).first].end(); p2++){
      cout << " " << *p2;
    }
    cout << endl;

  } 

  return 0;
}

Measured memory_bytes: 1232
#include <iostream>
#include <vector>
#include <algorithm>
#include <ios>
#include <iomanip>
#include <cmath>
#include <regex>
using namespace std;

int main(){
  int N, A;
  cin >> N >> A;
  cout << (N%500<=A ? "Yes": "No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <math.h>
#include <algorithm>
#include<queue>
#include<map>
//#include <bits/stdc++.h>


using namespace std;

#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)

main(){
    string s;
    cin >> s;
    if(s[0]==s[1]&&s[1]==s[2]&&s[2]==s[3]){cout << "No" << endl;}
    else if(s[0]==s[1]&&s[2]==s[3]&&s[1]!=s[2] ){cout << "Yes" << endl;}
    else if(s[0]==s[2]&&s[1]==s[3]){cout << "Yes" << endl;}
    else if(s[0]==s[3]&&s[1]==s[2]){cout << "Yes" << endl;}

    else{cout << "No" << endl;}
    
}

Measured memory_bytes: 256