akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

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

  if(B <= A){
    cout << "delicious" << endl;
  }else if(B - A <= X){
    cout << "safe" << endl;
  }else{
    cout << "dangerous" << endl;
  }
}


Measured memory_bytes: 888
#include<stdio.h>
int main(void){
  int n,k;
  scanf("%d%d",&n,&k);
  int i;
  int p[n];
  for(i=0;i<n;i++){
    scanf("%d",&p[i]);
  }
  int tmp=0;
  int j=0;
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      if(p[i]>p[j]){
        tmp=p[i];
        p[i]=p[j];
        p[j]=tmp;
      }
    }
  }
  int sum=0;
  for(i=0;i<k;i++){
    sum+=p[i];
  }
  printf("%d\n",sum);
  return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define IOS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <class T>
struct rbtree: tree<T,null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>{};
#define IN freopen("in.txt", "r", stdin);
#define endl '\n'
#define mp make_pair
#define pb push_back
#define lowb lower_bound
#define eb emplace_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define mem0(a) memset((a), 0, sizeof(a))
#define mem(a, b) memset((a), (b), sizeof(a))
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int inf = 0x3f3f3f3f;


int main(){
    IOS;
//    IN;
    int a, b, c; cin>>a>>b>>c;
    int d = a+b+c;
    if(d >= 22)cout<<"bust";
    else cout<<"win";







    return 0;
}

Measured memory_bytes: 256
import sys

s = input()
count = 0

for i in range(len(s)):
    if s[i] == 'o':
        count += 1

if count > 7:
    print('YES')
    sys.exit()

#print(count)
rest = 8 - count

#if count > 7:
if 15 - len(s) >= rest:
    print('YES')
else:
    print('NO')




Measured memory_bytes: 3060
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
int fir[100010],dis[200010],nxt[200010],id;
void link(int a,int b){nxt[++id]=fir[a],fir[a]=id,dis[id]=b;}
bool flg;
bool dfs(int x,int fa=-1){
	int sum=0;
	for(int i=fir[x];i;i=nxt[i]){
		if(dis[i]==fa)continue;
		sum+=dfs(dis[i],x);
	}
	if(sum>1)flg=1;
	return!sum;
}
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n=gi(),a,b;
	for(int i=1;i<n;++i)a=gi(),b=gi(),link(a,b),link(b,a);
	flg|=dfs(1);
	if(flg)puts("First");
	else puts("Second");
	return 0;
}


Measured memory_bytes: 2176
//HOW YOU DOI'N........................JT
//Could this code be more bad..........CB
//I know...............................MG
//Hii..................................RG
//Noooooooo............................RG
//I wish I could but I don't want to...PB

//That's what she said.................MS


#include <bits/stdc++.h>

#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);

#define ll long long
#define ld long double
#define pb push_back
#define mkpr make_pair
#define fi(i,a,b) for (ll i=a;i<b;i++)
#define vll vector<ll>
#define vch vector<char>
#define vst vector<string>
#define vpll vector<pll>
#define vvl vector<vector<ll>>
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(v.rbegin(), v.rend())
#define mxe(v) *max_element(v.begin(),v.end())
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define mll map<ll, ll>
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a)*1ll * (b)) / gcd(a, b)
#define nl "\n"
#define sp " "
#define sz(x)  (int)x.size()

using namespace std;

double PI = (acos(-1));
ll md = 1000000007;
//ll md = 998244353;

ll pw(ll a, ll b){ll c=1,m=a;while (b){if (b&1)c=(c*m);m=(m*m);b/=2;}return c;}
ll pwmd(ll a, ll b){ll c = 1, m = a;while (b){if (b & 1)c = ((c * m)) % md;m = (m * m) % md;b /= 2;}return c;}
ll modinv(ll n){return pwmd(n, md - 2);}
ll min(ll a,ll b){if(a>=b)return b;return a;}
ll nc2(ll n){return (1ll * n * (n - 1)) / 2;}
ll nsum(ll n){return (1ll * n * (n + 1)) / 2;}
bool prime(ll a){for(int i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}

#define MAX_SIZE 100005
void Sieve(vector<int> &primes){bool IsPrime[MAX_SIZE];memset(IsPrime, true, sizeof(IsPrime));
for (int p = 2; p * p < MAX_SIZE; p++){if (IsPrime[p] == true){
			for (int i = p * p; i < MAX_SIZE; i += p)IsPrime[i] = false;}}
	for (int p = 2; p < MAX_SIZE; p++)if (IsPrime[p])primes.push_back(p);}


vector<char> sml={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char> cap={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};





// Lets start ...


void solve(){
    ll n;
    cin>>n;
    ll l[n];
    fi(i,0,n)cin>>l[i];
    vll v(32,0);
    fi(i,0,n){
        fi(j,0,32){
            if(l[i]&(1ll<<j))v[j]++;
        }
    }
    fi(i,0,n){
        ll cur=0;
        fi(j,0,32){
            if(l[i]&1ll<<j){
                if(v[j]%2==0)cur+=pw(2,j);
            }
            else{
                if(v[j]%2)cur+=pw(2,j);
            }
        }
        cout<<cur<<sp;
    }
    
    
}

int main(){
    //vector<int> primes;
    //Sieve(primes);
    
    fast
    ll tests=1,cnt=0;
    //cin>>tests;
    while(tests--){
        solve();
    }
    

    return 0;
    }

// Done:)




Measured memory_bytes: 5192
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long lng;
#define UP(i,a,b) for(int i=(a); i<=(b); ++i)
#define DOWN(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) UP(i,0,n-1)
#define ALL(a) (a).begin(), (a).end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) //NOTE: <a> must be sorted in advance

lng power(lng b, lng n) {lng sol=1; while(n>0) {if(n&1) {sol=sol*b;} n>>=1; b*= b;} return sol;} //calculate b^n

const int MOD = 1000000007; //10^9+7


/*********** variables **********
/**********************************/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin>>a>>b>>c;

    if(a+b==c||b+c==a||c+a==b) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String str = sc.next();

		sc.close();
		String[] array = str.split("");

		String[] ok_Array = new String[n];
		Arrays.fill(ok_Array, "W");

		int tmp=0;
		for(int i=0;i<n;i++) {
			if(array[i].equals("R")) {
				tmp++;
			}
		}

		for(int i=0;i<tmp;i++) {
			ok_Array[i] = "R";
		}

		int ans = 0;
		for(int i=0;i<n;i++) {
			if(!array[i].equals(ok_Array[i])) {
				ans++;
			}
		}

		System.out.println(ans/2);



	}
}

Measured memory_bytes: 65792
a, b = map(int, input().split())
# = list(map(int, input().split()))
# = [int(input()) for _ in range()]
if max(a, b) - min(a, b) > 0:
    print(max(a, b) * 2 - 1)
else:
    print(max(a, b) * 2)


Measured memory_bytes: 2940
fn main() {
    println!("{}", solve(input()));
}

fn input() -> u32 {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.pop();

    let n: u32 = buf.parse().unwrap();
    n
}

fn solve(n: u32) -> u64 {
    let mut ans: u64 = 0;
    for i in 1..n+1 {
        for j in 1..n+1 {
            for k in 1..n+1 {
                let a = gcd(gcd(i, j), k) as u64;
                ans += a;
            }
        }
    }
    ans
}

fn gcd(a: u32, b: u32) -> u32 {
    if a % b == 0 {
        b
    } else {
        gcd(b, a % b)
    }
}


Measured memory_bytes: 2148
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
#include <functional>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int a[3];
    REP(i,3) cin >> a[i];
    sort(a,a+3);
    int ans = 0;
    ans += a[1] - a[0];
    ans += a[2] - a[1];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>

#define endl '\n'

using namespace std;

const int MAXN=1e5+3;
vector<int> graph[MAXN];
int dist[MAXN];
bool visited[MAXN];

void dfs(int curr){
    visited[curr]=true;
    for(int nextp : graph[curr]){
        if(!visited[nextp]){
            dfs(nextp);
        }
        dist[curr]=max(dist[curr],dist[nextp]+1);
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;++i){
        int from,to;
        cin>>from>>to;
        --from;
        --to;
        graph[from].push_back(to);
    }
    for(int i=0;i<n;++i){
        if(!visited[i]){
            dfs(i);
        }
    }
    int res=0;
    for(int i=0;i<n;++i){
        res=max(res,dist[i]);
    }
    cout<<res<<endl;
return 0;
}

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

int main()
{
    int N;
    cin >> N;
    int a[3*N];
    for (int i = 0; i < 3*N; i++) cin >> a[i];

    sort(a, a + 3*N, greater<int>());
    
    long long res = 0;
    int centern = 2 * N;
    for (int i = 1; i < centern; i += 2)
    {
        res += a[i];
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <fstream>
#include <vector>

#define DEBUG 0

using namespace std;
#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;

//https://atcoder.jp/contests/abc044/tasks/arc060_a

int main(){

#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    int n,a;
    cin >> n >> a;
    vector <int> x(n);

    REP(i,n)
    {
        cin >> x[i];
    }

    //dp[j][k][s]: j枚のうちk枚選んだときの合計がsだったときのの選び方
    ll dp[n+1][n+1][2501];
    REP(j,n+1)
    {
        REP(k,n+1)
        {
            REP(s,n*a + 1)
            {
                dp[j][k][s] = 0;
            }
        }
    }

    dp[0][0][0] = 1;

    for(int j = 1; j <= n; ++j)
    {
        for(int k = 0; k <= n; ++k)
        {
            for(ll s = 0; s <= 2500; ++s)
            {
                if(k == 0 || s - x[j-1] < 0)
                {
                    dp[j][k][s] = dp[j-1][k][s];
                }
                else
                {
                    dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-x[j-1]];
                }
            }
        }
    }
    //dp[j][k][s] = dp[j-1][k][s];
    //dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-x[j]];
    ll res = 0;
    for(int k = 1; k <= n; ++k)
    {
        res += dp[n][k][k*a];
    }

    cout << res << endl;
}


Measured memory_bytes: 51072
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var NM = Sarray();
            var N = NM[0];
            var M = NM[1];
            var Ai = Sarray();
            var pq = new priority_queue<long>((l, r) => (int)(l - r));
            foreach (var a in Ai)
                pq.insert(a);
            for(var i=0;i<M;++i)
                pq.insert(pq.extract() >> 1);
            var ans = 0L;
            while (0 < pq.num)
                ans += pq.extract();
            WriteLine(ans);
            //Out.Flush();
        }
        //Priority_queue使用
        class priority_queue<T>
        {
            Comparison<T> cmp;
            T[] A = new T[2000000];
            // var pq = new priority_queue<long>((l, r) => (int)(l - r));
            // とすれば値の大きいものから優先
            public priority_queue(Comparison<T> c)
            {
                cmp = c;
            }
            public int num { get; private set; } = 0;
            public void insert(T v)
            {
                A[num] = v;
                ++num;
                increaseKey(num);
            }
            void increaseKey(int i)
            {
                while (1 < i && 0 < cmp(A[i - 1], A[i / 2 - 1]))
                {
                    var t = A[i - 1];
                    A[i - 1] = A[i / 2 - 1];
                    A[i / 2 - 1] = t;
                    i = i / 2;
                }
            }
            public T extract()
            {
                if (num < 1) return default(T);
                var max = A[0];
                A[0] = A[num - 1];
                --num;
                maxHeapify(1);
                return max;
            }
            void maxHeapify(int i)
            {
                var H = num;
                var l = left(i);
                var r = right(i);
                var largest = 0;
                if (l <= H && 0 < cmp(A[l - 1], A[i - 1]))
                { largest = l; }
                else
                { largest = i; }
                if (r <= H && 0 < cmp(A[r - 1], A[largest - 1]))
                { largest = r; }
                if (largest != i)
                {
                    var t = A[i - 1];
                    A[i - 1] = A[largest - 1];
                    A[largest - 1] = t;
                    maxHeapify(largest);
                }
            }
            int left(int l) => l * 2;
            int right(int r) => r * 2 + 1;
        }
    }
}

Measured memory_bytes: 31452
from collections import deque

N, M = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(M)]
S, T = map(int, input().split())

graph = [[] for _ in range(N + 1)]
for u, v in X:
    graph[u].append(v)

INF = 10 ** 9 + 7
ctr = [[INF] * (N + 1) for _ in range(3)]
ctr[0][S] = 0
stack = deque()
stack.append((0, S))
while stack:
    i, u = stack.popleft()
    j = (i + 1) % 3
    for v in graph[u]:
        if ctr[j][v] > ctr[i][u] + 1:
            ctr[j][v] = ctr[i][u] + 1
            stack.append((j, v))
            
if ctr[0][T] < INF:
    print(ctr[0][T] // 3)
else:
    print(-1)


Measured memory_bytes: 105476
#include <bits/stdc++.h>
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define pb push_back
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(n) ((int)(n).size())
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

const int MAXN = 3005;
ll MOD=1e9+7, dp[MAXN][MAXN];

int main(){FIN;
  ll ans=0,n; string s;
  cin >> n >> s;
  s = "<"+s;
  fore(i,1,n+1) dp[n][i] = 1;
  for(int i = n-1; i >= 0; i--){
    ll tot = 0;
    if(s[i] == '<'){
      for(int j = n-i; j; j--){
        tot = (tot+dp[i+1][j])%MOD;
        dp[i][j] = tot;
      }
    }
    else{
      fore(j,1,n-i+1){
        tot = (tot+dp[i+1][j])%MOD;
        dp[i][j+1] = tot;
      }
    }
  }
  cout << dp[0][1] << "\n";
}

Measured memory_bytes: 70016
#include<cstdio>
#include<algorithm>
using namespace std;
int n,a[100010],even,odd;
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        if (a[i]&1) odd++;else even++;
    }
    if (even&1) return puts("First"),0;else
    if (odd>1) return puts("Second"),0;
    int cnt=0;
    while (1){
        int p=0;
        for (int i=1;i<=n;i++)
        if (a[i]&1) if (p) goto end;else p=i;
        if (a[p]==1) break;
        a[p]--;cnt++;
        int Gcd=0;
        for (int i=1;i<=n;i++) Gcd=gcd(Gcd,a[i]);
        for (int i=1;i<=n;i++) a[i]/=Gcd;
    }
    end:
    even=0;
    for (int i=1;i<=n;i++) even+=((a[i]&1)^1);
    puts((even+cnt)&1?"First":"Second");
    return 0;
}

Measured memory_bytes: 512
package main

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

var sc = bufio.NewScanner((os.Stdin))

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

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

func main() {
	sc.Split(bufio.ScanWords)
	K, S := nextInt(), nextInt()

	fmt.Printf("%d\n", ABC051B(K, S))
}

// ABC051B ...
func ABC051B(K, S int) (res int) {
	for x := 0; x <= K; x++ {
		for y := 0; y <= K; y++ {
			z := S - x - y
			if 0 <= z && z <= K {
				res++
			}
		}
	}

	return
}


Measured memory_bytes: 1800
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aryssoncf
 */



// Taken from: https://github.com/bqi343/USACO/blob/master/Implementations/content/contest/templateShort.cpp

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ull> vul;
typedef vector<ll> vl;
typedef vector<pii> vpii;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i,0,a)
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i, a) ROF(i,0,a)
#define trav(a, x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

#define mp make_pair
#define pb push_back
#define f first
#define s second

const int MOD = 1e9 + 7; // 998244353; // = (119<<23)+1
const int MX = 2e5 + 5;

template<class T>
bool ckmin(T &a, const T &b) {
    return a > b ? a = b, 1 : 0;
}

template<class T>
bool ckmax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

mt19937 rng((uint32_t) chrono::steady_clock::now().time_since_epoch().count());


//
// Created by aryssoncf on 28/10/2019.
//

#include <type_traits>


#include <iterator>
#include <utility>

template<typename T>
constexpr auto hasBegin(int) -> decltype(std::begin(std::declval<T>()), true) {
    return true;
}

constexpr bool hasBegin(...) {
    return false;
}

template<typename T>
using IsContainer = std::integral_constant<bool, hasBegin<T>(0)>;


#ifndef JHELPER_EXAMPLE_PROJECT_IO_HPP
#define JHELPER_EXAMPLE_PROJECT_IO_HPP

#endif //JHELPER_EXAMPLE_PROJECT_IO_HPP

template<typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &vec) {
    for (T &element: vec) {
        is >> element;
    }
    return is;
}

template<typename T, typename U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
    is >> p.first;
    is >> p.second;
    return is;
}

template<class X, class Y>
std::ostream &operator<<(std::ostream &os, std::pair<X, Y> const &p) {
    return os << p.first << " " << p.second;
}

template<class Ch, class Tr, class Container>
std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, Container const &x) {
    bool first = true;
    for (auto &y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

using namespace std;

class ARangeProduct {
public:
    void solve(std::istream &in, std::ostream &out) {
        int a, b;
        in >> a >> b;
        string res;
        if (b < 0 and (b - a + 1) % 2) {
            res = "Negative";
        } else {
            res = "Positive";
        }
        if (a <= 0 and b >= 0) {
            res = "Zero";
        }
        out << res << '\n';
    }

    void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
    ARangeProduct solver;
    solver.setup();
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3568
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647 -> 10桁
// MAX ll 9,223,372,036,854,775,807 -> 19桁
// MAX O(n) 10^8 -> 8回
// double pi = M_PI or acos(-1)
// printf("%.10f\n", ans);

int main() {
    int n;
    cin >> n;
    vector<int> p(n), q(n);
    rep(i, n) cin >> p.at(i);
    rep(i, n) cin >> q.at(i);

    vector<int> oneCase(0);
    rep(i, n) oneCase.push_back(i + 1);

    int a, b, index = 1;
    do {
        if (equal(begin(oneCase), end(oneCase), begin(p), end(p))) {
            a = index;
        }
        if (equal(begin(oneCase), end(oneCase), begin(q), end(q))) {
            b = index;
        }
        index++;
    } while (next_permutation(oneCase.begin(), oneCase.end()));

    int ans = abs(a - b);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define int long long
using namespace std;
deque<int> maxs;
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    int arr[n];
    for(int i = 0; i < n; i++){
        cin >> arr[i];
    }
    sort(arr, arr + n);
    reverse(arr, arr + n);
    maxs.push_back(arr[0]);
    int sum = 0;
    for(int i = 1; i < n; i++){
        if(maxs.front() > arr[i]){
            maxs.push_back(arr[i]);
            maxs.push_back(arr[i]);
            sum += maxs.front();
            maxs.pop_front();
        }else{
            sum += arr[i];
            maxs.push_back(arr[i]);
        }
    }
    cout << sum;
}


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

int main(){
  string s;
  cin >> s;

  int n = s.size();
  int A_pos = -1;
  int Z_pos = -1;
  for(int i=0;i<n;i++){
    if(A_pos < 0){
      if(s[i] == 'A'){
        A_pos = i;
      }
    }else{
      if(s[i] == 'Z'){
        Z_pos = i;
      }
    }
  }

  cout << Z_pos - A_pos + 1 << endl;

  return 0;
}


Measured memory_bytes: 640
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)


function main()
    X = parseInt(readline())
    money = 100
    for i in 1:100000000000000000000
        money *= 1.01
        money = floor(money)
        if money >= X
            println(i)
            break
        end
    end 
end

main()

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

int a,b,c,d,e,f;

bool dp[4011];

int ans1,ans2;
double ans;

int main()
{
    int i,j,k;
    int aa,bb,cc,dd;
    cin>>a>>b>>c>>d>>e>>f;
    
    
    ans=-1.0;
    for(aa=0;aa<=f/(a*100);aa++)
    {
        for(bb=0;bb<=f/(b*100);bb++)
        {
            int tmp=f-a*100*aa-b*100*bb;
            if(tmp>=0)
            {
                //cout<<aa<<' '<<bb<<' '<<tmp<<"  !!!!"<<endl;
                
                memset(dp,0,sizeof(dp));
                dp[0]=1;
                int mm=(a*100*aa+b*100*bb)/100*e;
                int uu=0;
                
                for(i=0;i<=tmp;i++)
                {
                    if(dp[i]==1)
                    {
                        dp[i+c]=1;
                        dp[i+d]=1;
                    }
                    
                    if(dp[i]==1 && i<=mm)
                    {
                        uu=max(uu,i);
                    }
                }
                /*
                cout<<mm<<"   "<<uu<<" uuu"<<endl;
                
                for(i=0;i<=tmp;i++)
                {
                    cout<<dp[i]<<' ';
                }
                cout<<"!!!!!!!!!"<<endl;
                */
                
                int xx,yy;
                xx=a*100*aa+b*100*bb+uu;
                yy=uu;
                
                if((double)yy/(xx)>ans)
                {
                    ans1=xx;
                    ans2=yy;
                    ans=(double)yy/(xx);
                }
                
            }
        }
    }
    
    cout<<ans1<<' '<<ans2<<endl;
    
    return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
py=[]
for i in range(m):
    py.append([i]+list(map(int,input().split())))

py.sort(key=lambda na:(na[1],na[2]))

count=0
m_city=py[0][1]
for i in range(m):
    si=py[i][1]
    if m_city==si:
        count+=1
        py[i].append(count)
    else:
        count=1
        m_city=py[i][1]
        py[i].append(count)
    
py.sort(key=lambda na:na[0])


for i in range(m):
    print('{:0>6}'.format(py[i][1]),end="")
    print('{:0>6}'.format(py[i][3]))
    
     

Measured memory_bytes: 35964
#include <stdio.h>

int main(void) {
  int i, j, k, l, n, now = 0, t, ans = 0;
  scanf("%d%d", &n, &k);
  int dp[n][6], a[k], b[k];
  for(i = 0; i < k; ++i) {
    scanf("%d%d", &a[i], &b[i]);
    a[i]--;
  }
  for(i = 0; i < k; ++i) for(j = i + 1; j < k; ++j) if(a[i] > a[j]) {
    t = a[i], a[i] = a[j], a[j] = t;
    t = b[i], b[i] = b[j], b[j] = t;
  }
  for(i = 0; i < n; ++i) for(j = 0; j < 6; ++j) dp[i][j] = 0;
  if(!a[now]) {
    if(b[now] == 1) dp[0][0] = 1;
    if(b[now] == 2) dp[0][1] = 1;
    if(b[now] == 3) dp[0][2] = 1;
    ++now;
  } else dp[0][0] = dp[0][1] = dp[0][2] = 1;
  for(i = 1; i < n; ++i) {
    if(a[now] != i) {
      for(j = 0; j < 3; ++j) {
        for(l = 0; l < 6; ++l) {
          if(j != l && l != j + 3) {
            dp[i][j] += dp[i - 1][l];
            dp[i][j] %= 10000;
          }
        }
      }
      for(j = 0; j < 3; ++j) dp[i][j + 3] = dp[i - 1][j];
    } else {
      if(b[now] == 1) {
        for(j = 0; j < 6; ++j) if(j != 0 && j != 3) {
          dp[i][0] += dp[i - 1][j];
          dp[i][0] %= 10000;
        }
        dp[i][3] = dp[i - 1][0];
      } else if(b[now] == 2) {
        for(j = 0; j < 6; ++j) if(j != 1 && j != 4) {
          dp[i][1] += dp[i - 1][j];
          dp[i][1] %= 10000;
        }
        dp[i][4] = dp[i - 1][1];
      } else {
        for(j = 0; j < 6; ++j) if(j != 2 && j != 5) {
          dp[i][2] += dp[i - 1][j];
          dp[i][2] %= 10000;
        }
        dp[i][5] = dp[i - 1][2];
      }
      ++now;
    }
  }
  /*for(i = 0; i < n; ++i) {
    for(j = 0; j < 6; ++j) printf("%d ", dp[i][j]);
    printf("\n");
  }*/
  for(i = 0; i < 6; ++i) {
    ans += dp[n - 1][i];
    ans %= 10000;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 2608
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>
using namespace std;

int main(int argc, const char * argv[]) {
    
    string s;
    cin >> s;
    
    int64_t cnt = 0;
    int64_t n_of_A = 0;
    for (int64_t i = 0; i < s.size(); i++) {
        if (s.at(i) == 'A') n_of_A++;
        else if (i < s.size() - 1 && s.at(i) == 'B' && s.at(i + 1) == 'C') {
            cnt += n_of_A;
            i++;
        } else n_of_A = 0;
    }
    
    cout << cnt << endl;
    
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define per(i,n,a) for(ll i=n-1;i>=a;i--)
#define nl "\n"
#define LLMAX 1e18
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define fastread cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
#define online_judge 

const ll MOD=1e9+7;

ll pow(ll n, ll e){
  if(e==0)
    return 1;
  else if(e==1)
    return n;
  else if(e%2==0)
    return pow(n,e/2);
  else
    return pow(n,e/2)*n;
}

bool prime(ll n){
  ll ct=0;
  rep(i,2,sqrt(n)+1){
    if(n%i==0)
      return false;
  }
  return true;
}

int solve(){
  // fastread;
  ll n,m,temp,mi,q,ma=0,t;
  ll w,a,b;
  cin >> n >> w;
  vector<pll> values;
  rep(i,0,n){
    cin >> a >> b;
    values.pb(mp(a,b));
  }
  ll dp[n][w+1];
  memset(dp,-1,sizeof(dp));

  rep(i,0,n)
    dp[i][0]=0;

  rep(i,0,n){
    rep(j,1,w+1){
      if(i==0){
        if(j==values[0].ff)
          dp[i][j] = values[i].ss;
        continue;
      }
      dp[i][j] = dp[i-1][j];
      if(j-values[i].ff>=0 && dp[i-1][j-values[i].ff]!=-1)
        dp[i][j] = max(dp[i][j], values[i].ss+dp[i-1][j-values[i].ff]);
    }
  }

  // rep(i,0,n){
  //   rep(j,0,w+1)
  //     cout << dp[i][j] << " ";
  //   cout << nl;
  // }

  rep(j,0,w+1)
    ma=max(ma,dp[n-1][j]);
  cout << ma;
  return 0;
}

int main(){
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  freopen("error.txt", "w", stderr);
  #endif
  clock_t start, end;
  start = clock();
  solve();
  end=clock();
  double time_taken = double(end - start) / double(CLOCKS_PER_SEC); 
    cerr << "Time taken by program is : " << fixed  
         << time_taken << setprecision(5); 
    cerr << " sec " << endl;
  return 0;
}

Measured memory_bytes: 81748
#include<stdio.h>
int main(void)
{
	char a[11];
	int i,co,max;
	co =max= 0;

	scanf("%s", a);
	for (i = 0; a[i] != '\0'; i++) {
		switch (a[i]) {
		case 'A':
			co++;
			break;
		case 'C':
			co++;
			break;
		case 'T':
			co++;
			break;
		case 'G':
			co++;
			break;
		default:
			co = 0;
		}
		if (max < co) {
			max = co;
		}
	}
	printf("%d\n", max);
	return 0;
}

Measured memory_bytes: 128
q = gets.chomp.to_i

left = []
right = []
min = 0
count = 0

q.times do
  query = gets.chomp
  case query[0]
  when '1'
    _, a, b = query.split.map(&:to_i)
    min += b
    if count == 0
      left[0] = a
    elsif count.odd?
      if a < left[-1]
        min += left[-1] - a
        right.unshift(left.pop)
        pos = left.bsearch_index{ |x| x > a } || -1
        left.insert(pos, a)
      else
        min += a - left[-1]
        pos = right.bsearch_index{ |x| x > a } || -1
        right.insert(pos, a)
      end
    else
      if a < left[-1]
        min += left[-1] - a
        pos = left.bsearch_index{ |x| x > a } || -1
        left.insert(pos, a)
      elsif left[-1] <= a && a <= right[0]
        left.push(a)
      else
        min += a - right[0]
        left.push(right.shift)
        pos = right.bsearch_index{ |x| x > a } || -1
        right.insert(pos, a)
      end
    end
    count += 1
  when '2'
    printf("%d %d\n", left[-1], min)
  end
end

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

int main()
{
    int N;
    cin >> N;
    long long ans = 0;
    rep(i,N){
        if((i % 3) != 0 && (i % 5) != 0){
            ans += i;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long int lli;
typedef long double ld;
const int oo = 1e9;

int n, k;
const int nx = 1e5+5;
ll ac[nx][2];
ll dp[105][nx];
ll go(ll i, ll w){
	if(w>k) return -oo;
	if(i == n) return 0;
	if(dp[i][w] != -1) return dp[i][w];
	ll& ans = dp[i][w];
	ans = max(ans, go(i+1,w));
	if(w+ac[i][0]<=k) ans = max(ans, go(i+1,w+ac[i][0])+ac[i][1]);
	return ans;
}
int main(){
	
	cin>>n>>k;
	memset(dp, -1, sizeof dp);
	for(int i=0; i<n; i++) cin>>ac[i][0]>>ac[i][1];
	cout<<go(0,0)<<"\n";
}

Measured memory_bytes: 82304
#include<stdio.h>
#include<string.h>
int main(void){
    char S[3];
    scanf("%s",S);
    int A=0,B=0,C=0;

    for(int i=0; i<3; i++){
        if(S[i]=='a'){
            A+=1;
        }
        if(S[i]=='b'){
            B+=1;
        }
        if(S[i]=='c'){
            C+=1;
        }
    }
    if(A==1 && B==1 && C==1){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 128
import core.stdc.stdio;
import std.algorithm;

void main(){
 int n,k;
 scanf("%d%d",&n,&k);
 for(int i=0;i<k;i++){
  int a,b;
  scanf("%d%d",&a,&b);
  int m = min(a,n+1-a,b,n+1-b);
  printf("%d\n",(m-1)%3+1);
 }
}

Measured memory_bytes: 2356
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>

const int MAXN = 2e3 + 10, MAXM = 2e3 + 10;

int n, m, top;
int a[MAXN][MAXM], st[MAXM];
char s[MAXN][MAXM];

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; ++i) {
		scanf(" %s", s[i] + 1);
		for (int j = 2; j <= m; ++j) {
			if (i == 1) a[i][j] = 1;
			else if ((s[i][j] == s[i - 1][j]) == (s[i][j - 1] == s[i - 1][j - 1])) a[i][j] = a[i - 1][j] + 1;
			else a[i][j] = 1;
		}
	}
	int ans = n;
	for (int i = 1; i <= n; ++i) {
		st[top = 0] = 1;
		for (int j = 2; j <= m + 1; ++j) {
			while (top && a[i][st[top]] >= a[i][j]) ans = std::max(ans, a[i][st[top]] * (j - st[top - 1])), --top;
			st[++top] = j;
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

using lli = long long int;
using Vint = vector<int>;
using Vlli = vector<lli>;
using Wint = vector<Vint>;
using Wlli = vector<Vlli>;
using pii = pair<int, int>;
using pll = pair<lli, lli>;

const int MOD = 1e9 + 7;
const int INFi = 2e9 + 1;
const lli INFl = (lli)(9e18) + 1;
// const vector<pii> DXDY = {make_pair(1, 0), make_pair(-1, 0), make_pair(0, 1), make_pair(0, -1)};

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define FOReq(i, a, b) for(int (i) = (a); (i) <= (b); (i)++)
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); i--)
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(i, vec) for(auto (i) = (vec).begin(); (i) != (vec).end(); (i)++)
#define vrREP(i, vec) for(auto (i) = (vec).end()-1;(i) != (vec).begin()-1;(i)--)

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


int main(void){
  int n, x, before = 0, after; cin >> n >> x;
  lli res = 0;
  REP(i, n){
    cin >> after;
    if(before + after > x){
      res += (before + after - x);
      before = x - before;
    }
    else before = after;
  }
  cout << res << "\n";
  return 0;
}

Measured memory_bytes: 256
import math

A, B, C, D = map(int, input().split())

b = B - ((B // C) + (B // D) - (B // (C*D // math.gcd(C,D)))) 
a = A-1 - (((A-1) // C) + ((A-1) // D) - ((A-1) // (C*D // math.gcd(C,D))))
res = b - a
print(res)

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

typedef long long LL;

int main() {
    LL A, B, C, D, E, F;
    LL sum_water, sum_sugar, min_sum_water = 3000, min_sum_sugar = 0;

    cin >> A >> B >> C >> D >> E >> F;

    for (int i = 0; i < 101; i++) {
        for (int j = 0; j <= (F - (100 * A * i)) / B; j++) {
            for (int k = 0; k <= (F - (100 * (A * i + B * j))) / C; k++) {
                for (int l = 0; l <= (F - (100 * (A * i + B * j) + C * k)) / D; l++) {
                    sum_sugar = C * k + D * l;
                    sum_water = 100 * (A * i + B * j) + sum_sugar;
                    if (sum_water <= F && sum_sugar <= E * (A * i + B * j)) {
                        if (min_sum_sugar * sum_water <= sum_sugar * min_sum_water) {
                            min_sum_sugar = sum_sugar;
                            min_sum_water = sum_water;
                        }
                    }
                }
            }
        }
    }

    cout << min_sum_water << " " << min_sum_sugar << endl;

    return 0;

}

Measured memory_bytes: 256
N = input()
atc = ["A","T","C","G"]
ans = []
cnt = 0
for i in range(len(N)):
    if N[i] in atc:
        cnt += 1
    else:
        ans.append(cnt)
        cnt = 0
if cnt != 0:
    ans.append(cnt)
if ans == []:
    if N in atc:
        print(1)
    else:
        print(0)
else:
    print(max(ans))

Measured memory_bytes: 3064
strn = input()
n = int(strn)
shichigolist = ["3","5","7"]
shichigo = [[] for _ in range(len(strn))]
for i in range(len(strn)):
	if i == 0:
		for j in shichigolist:
			shichigo[i].append(j)
	else:
		for j in shichigo[i-1]:
			for k in shichigolist:
				shichigo[i].append(j+k)
target = len(strn)-1
for i in range(len(strn)):
	for j in shichigo[i][:]:
		if i == target:
			if int(j) > n:
				shichigo[target].remove(j)
			elif j.count("3")==0 or j.count("5")==0 or j.count("7")==0:
				shichigo[target].remove(j)
		else:
			if j.count("3")==0 or j.count("5")==0 or j.count("7")==0:
				shichigo[i].remove(j)

print(sum([len(shichigo[i]) for i in range(len(strn))]))

Measured memory_bytes: 5356
#include<iostream>
#include<cstdint>

uint64_t getZ() {
  uint64_t v = 0; int c;
  while((c = getchar_unlocked()) >= '0') v=v*10+c-'0';
  return v;
}

int const MAXN = 1e5-1;
int64_t A[MAXN];

int main() {
  int N = getZ();
  for(int i = 0; i < N; ++i) A[i] = getZ();
  int64_t x = 0;
  for(int i = 0; i < N; ++i) x += A[i];
  for(int i = 1; i < N; i += 2) x -= A[i]*2;
  std::cout << x;
  for(int i = 1; i < N; ++i) {
    x = A[i-1]*2 - x;
    std::cout << " " << x;
  }
  std::cout << std::endl;
  return 0;
}


Measured memory_bytes: 2048
S=list(str(input()))
s=set(S)
K=int(input())
num=0
i=0
lst=[]
def dp(i,lst):
  if i==len(S)-1:
    return lst
  if S[i]!=S[i+1]:
    return dp(i+1,lst)
  j=i+1
  while j<=len(S)-1  and S[i]==S[j]:
    j+=1
  lst.append(list(S[i:j]))
  return dp(j-1,lst)

if 2<=len(s):
  L=dp(i,lst)
  for i in range(len(L)):
    num+=(len(L[i])//2)
  if num==0:
    if S[0]!=S[-1]:
      print(0)
    else:
      print(K-1)
  elif L[-1][-1]==S[0] and len(L[-1])%2==len(L[0])%2==1:
    print(num+(K-1)*(num+1))
  else:
    print(num*K)
else:
  print((len(S)*K)//2)

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

using namespace std;

vector<int> ans;
int main(){
	while(1){
		int n;
		cin >> n;
		
		if(n == 0) break;
		
		int a[20];
		for(int i = 0;i < n;i++){
			cin >> a[i];
		}
		
		int tans = 1e9;
		for(int i = 0;i < (1 << n);i++){
			int A=0,B=0;
			for(int j = n-1;j >= 0;j--){
				if((i >> j) % 2 == 0){
					A += a[j];
				}else{
					B += a[j];
				}
			}
			tans = min(tans,abs(A - B));
		}
		
		ans.push_back(tans);
	}
	
	for(int i = 0;i < ans.size();i++) cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 3120
var
  s:string;
  n,i,sum,max:longint;
begin
  readln(n);
  readln(s);
   for i:=1 to length(s) do
    if s[i]='I' then begin inc(sum);if sum>max then max:=sum;end
     else if s[i]='D' then dec(sum);
     write(max);
end.


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define mem(ar,num) memset(ar,num,sizeof(ar))
#define me(ar) memset(ar,0,sizeof(ar))
#define lowbit(x) (x&(-x))
#define Pb push_back
#define  FI first
#define  SE second
#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 IOS ios::sync_with_stdio(false)
#define DEBUG cout<<endl<<"DEBUG"<<endl; 
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int    prime = 999983;
const int    INF = 0x7FFFFFFF;
const LL     INFF =0x7FFFFFFFFFFFFFFF;
const double pi = acos(-1.0);
const double inf = 1e18;
const double eps = 1e-6;
const LL     mod = 1e9 + 7;
LL qpow(LL a,LL b){LL s=1;while(b>0){if(b&1)s=s*a%mod;a=a*a%mod;b>>=1;}return s;}
LL gcd(LL a,LL b) {return b?gcd(b,a%b):a;}
int dr[2][4] = {1,-1,0,0,0,0,-1,1};
typedef pair<int,int> P;
int main(void)
{
    int a,b;cin>>a>>b;
    if((a+b)&1)
    	cout<<"IMPOSSIBLE"<<endl;
    else
    	cout<<(a+b)/2<<endl;

   return 0;
}

Measured memory_bytes: 256
#include <iostream>

 

using namespace std;

 

int main() 
{
    int a, b, c, i, ans;
    cin >> a >> b >> c;
    ans = 0;
    for(i=a; i<=b; i++)
    {
        if(c % i == 0)
         ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3108
//
// Created by Akifumi Ohata on 2017/10/01.
//


#include<iostream>
#include <vector>
#include <numeric>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <iomanip>

using namespace std;

using ll =  long long int;

int main() {
    ios::sync_with_stdio(false);

    int A, B;


    cin >> A >> B;


    int C=A+B;


    string Answer="Impossible";

    vector<int> array={A,B,C};//no zero

    for(const int value : array){

        if(value%3==0){

            Answer="Possible";
        }

    }




    cout  << Answer << endl ;

    return 0;
}

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

int main()
{
	int mansion[4][3][10] = {0};
	int b,f,r,v,count;
	int i = 0;
	cin >> count;

	while(i < count){
		cin >> b >> f >> r >> v;
		mansion[b - 1][f - 1][r - 1] += v;
		i++;
	}

	for(int j = 0; j < 4; j++){
		for(int h = 0; h < 3; h++){
			for(int k = 0; k < 10; k++){
				cout << ' ' << mansion[j][h][k];
			}
			cout << endl;
		}
		if(j != 3){cout << "####################" << endl;}
	}

	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int ans=0;
  map<char,int>m;
  r(i,26)m['a'+i]=i;
  string s;
  cin>>s>>s;
  int x=0;
  r(i,s.size()){
    int y=0;
    x|=(1<<m[s[i]]);
    for(int j=i+1;j<s.size();j++){
      y|=(1<<m[s[j]]);
    }
    ans=max(ans,__builtin_popcount(y&x));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
#define mkp make_pair
typedef pair<ll,ll> P;
int main()
{
	int k[100];
	int n,m;
	cin>>n>>m;
	double sum = 0;
	for(int i=0;i<n;i++)
	{
		cin>>k[i];
		sum+=k[i];
	}
	sum = sum*(1.0/(4*m));
	int ans = 0;
	for(int i=0;i<n;i++)
	{
		if(k[i]>=sum)
			ans++;
	}
	if(ans>=m)
	{
		cout<<"Yes\n";
	 } 
	else
	{
		cout<<"No\n";
	}
	return 0;
 } 

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

class BIT:
    def __init__(self,n,default = 0):
        self.s = [default]*(n+1)
        self.n = n
    
    def add(self,val,idx):
        while idx < self.n+1:
            self.s[idx] = self.s[idx] + val
            idx += idx&(-idx)
        return
    
    def get(self,idx):
        res = 0
        while idx > 0:
            res = res + self.s[idx]
            idx -= idx&(-idx)
        return res


n,k = map(int,input().split())
ans = 0
s = [0]*(n+1)
array = {0}
for i in range(n):
    s[i+1] = s[i] + int(input()) - k
    array.add(s[i+1])
array = sorted(array)
d = {x:i for i,x in enumerate(array)}
bit = BIT(len(array))
for t in s:
    ans += bit.get(d[t]+1)
    bit.add(1,d[t]+1)
print(ans)


Measured memory_bytes: 45020
h, w = map(int,input().split())
a_l = [list(input()) for _ in range(h)]

h_ans = h
del_list_h = []
for i in range(h):
    for j in range(w):
        if a_l[i][j] == '#':
            break
    else:
        del_list_h.append(i)
        h_ans -= 1

for i in del_list_h[::-1]:
    del a_l[i]

del_list_w = []
for j in range(w):
    for i in range(h_ans):
        if a_l[i][j] == '#':
            break
    else:
        del_list_w.append(j)

for j in del_list_w[::-1]:
    for k in range(h_ans):
        del a_l[k][j]

for ans in a_l:
    print(''.join(ans))


Measured memory_bytes: 3188
#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<int> a(n+1);
  rep(i,n) cin >> a[i+1];
  vector<int> b(n+1);
  for (int i = n; i >= 1; --i) {
    int sum = 0;
    for (int j = i+i; j <= n; j += i) {
      sum ^= b[j];
    }
    b[i] = sum^a[i];
  }
  vector<int> ans;
  for (int i = 1; i <= n; i++) {
    if (b[i]) ans.push_back(i);
  }
  cout << ans.size() << endl;
  rep(i,ans.size()) {
    printf("%d%c", ans[i], i+1==ans.size()?'\n':' ');
  }
  return 0;
}


Measured memory_bytes: 5372
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define mod 1000000007
#define INF 1e9+100
#define pii pair<int,int>
#define ppi pair<pii,int>
#define ff first
#define ss second
#define cy cout<<"Yes"<<endl;
#define cn cout<<"No"<<endl;
#define urs(r...)          typename decay<decltype(r)>::type
#define fi(i,n)                for(urs(n) i=0;i<n;i++)
#define re(i,n)               for(urs(n) i=1;i<=n;i++)
#define pb push_back
#define gap ' '
#define mx 10000
vector<int>adj[mx];
vector<int> bfs(int src)
{
	int i;
	vector<int>visited(mx,-1);
    queue<int>q;
    q.emplace(src);
    visited[src]=0;
    while(!q.empty())
	{
		int u=q.front();
		q.pop();
		for(auto v:adj[u])
		{
			if(visited[v]==-1)
			{
				visited[v]=visited[u]+1;
				q.emplace(v);
			}
		}
	}
	return visited;
}
main()
{
	int i,j,n,k;
	int t;
	int x,y;
    cin>>n>>x>>y;
	for(i=1;i<n;i++)
	{
		adj[i].pb(i+1);
		adj[i+1].pb(i);
	}
	adj[x].pb(y);
	adj[y].pb(x);
  vector<vector<int>>a(n+1);
  for(i=1;i<=n;i++)
  {
  	a[i]=bfs(i);
  }
   map<int,int>m;
  for(i=1;i<=n;i++)
  {
    int u=a[i].size();
    for(j=1;j<=n;j++)
	{
		m[a[i][j]]++;
	}
  }
  for(i=1;i<n;i++) cout<<m[i]/2<<endl;
}


Measured memory_bytes: 157056
#include <bits/stdc++.h>                                                                              
using namespace std;                                                                                  
using ll = long long;                                                                                 
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }               
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }               
                                                                                                      
ll rec(ll h) {                                                                                        
  if (h==1) {                                                                                         
    return 1;                                                                                         
  }                                                                                                   
  ll ans = 2 * rec(floor(h/2)) + 1;                                                                   
  return ans;                                                                                         
}                                                                                                     
                                                                                                      
int main() {                                                                                          
  ll h;                                                                                               
  cin >> h;                                                                                           
  ll ans = rec(h);                                                                                    
  cout << ans << endl;                                                                                
  return 0;                                                                                           
}                                                                                                     
                               

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

long dfs(string s,int i,int ope[]){
    if(i == s.size()-1){
        int k = 0;
        long sum = 0;
        for(int j=0;j<s.size();j++)
        if(ope[j] == 0){
            string str(&s[k],&s[j+1]);
            sum += stol(str);
            k = j+1;
        }
        return sum;
    }

    long sum = 0;
    ope[i] = 0;
    sum += dfs(s,i+1,ope);
    ope[i] = 1;
    sum += dfs(s,i+1,ope);

    return sum;
}

int main(void){
    string s;
    int ope[10] = {};
    cin >> s;

    cout << dfs(s,0,ope);
}



Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int A, B, C;
	scanf("%d %d %d", &A, &B, &C);
	if (A >= B && A >= C) printf("%d\n", A * 10 + B + C);
	else if (B >= C && B >= A) printf("%d\n", B * 10 + C + A);
	else  printf("%d\n", C * 10 + A + B);
	fflush(stdout);
	return 0;
}

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

int solve(const string& s1, const string& s2)
{
  int max_idx1 = 0;
  int max_idx2 = 0;
  int max_len = 0;
  for (int i = -int(s1.size()); i <= int(s2.size()); i++) {
    int len = 0;
    for (int j = max(i, 0); j < int(min(s1.size()+i, s2.size())); j++) {
      if (s1[j-i] == s2[j]) {
        len++;
        if (len > max_len) {
          max_idx1 = j-i-len+1;
          max_idx2 = j-len+1;
          max_len = len;
        }
      } else {
        len = 0;
      }

    }
  }
  return max_len;
}

int main()
{
  string s1, s2;
  while (cin >> s1 >> s2) {
    cout << solve(s1, s2) << endl;
  }
  return 0;
}

Measured memory_bytes: 932
// a
#include <iostream>
#include <set>
using namespace std;

int main()
{
   int a;
   set<int>s;
   cin>>a;
   s.insert(a);
   cin>>a;
   s.insert(a);
   cin>>a;
   s.insert(a);
   if(s.size()==2)cout<<"Yes\n";
   else cout<<"No\n";
    return 0;
}


Measured memory_bytes: 384