akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int N, M, K, X, Y;
struct stores
{
    int t[10];
    int profit[11];
};
vector<stores> st;
//=============================
void input()
{
    cin >> N;
    st.resize(N);
    rep(i, 0, N - 1)
    {
        rep(j, 0, 9)
        {
            cin >> st[i].t[j];
        }
    }
    rep(i, 0, N - 1)
    {
        rep(j, 0, 10)
        {
            cin >> st[i].profit[j];
        }
    }
}
//=============================
void func() {}
/*
 - 樹形図をかく
*/
//=============================
void solve()
{
    int ans = -INF;
    for (int k = 1; k <= 0b1111111111; k++)
    {
        int ans_sub = 0;
        for (int m = 0; m < N; ++m)
        {
            int cnt = 0;
            for (int l = 0; l < 10; ++l)
            { //お姉ちゃんが開く店
                if (((k >> l) & 1) && (st[m].t[l]))
                {
                    cnt++;
                }
            }
            ans_sub += st[m].profit[cnt];
        }
        ans = max(ans, ans_sub);
    }
    cout << ans << endl;
}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}

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

typedef long long LL;
const int N = 100006;

int a[N],b[N],c[N];
int p[N];

LL pre[N],suf[N];

int main ()
{
    int x,y,z;
    scanf("%d %d %d",&x,&y,&z);
    int n=x+y+z;
    LL totc=0;
    for (int i=1;i<=n;++i)
    {
        scanf("%d %d %d",&a[i],&b[i],&c[i]);
        totc += c[i];
        a[i] -= c[i];
        b[i] -= c[i];
        p[i] = i;
    }
    sort(p+1,p+n+1,[](const int &x,const int &y)
    {
        return a[x]-b[x] < a[y]-b[y];
    });
    priority_queue<LL,vector<LL>,greater<LL> > pq;
    LL sum=0;
    for (int ii=1;ii<=n;++ii)
    {
        int i = p[ii];
        if (pq.size() < y)
        {
            sum += b[i];
            pq.push(b[i]);
        }
        else
        {
            int  _=pq.top();
            pq.pop();
            sum -= _;
            pq.push(max(_,b[i]));
            sum += max(_,b[i]);
        }
        pre[ii] = sum;
    }
    sum=0;
    while (!pq.empty()) pq.pop();
    for (int ii=n;ii>=1;--ii)
    {
        int i = p[ii];
        if (pq.size() < x)
        {
            sum += a[i];
            pq.push(a[i]);
        }
        else
        {
            int  _=pq.top();
            pq.pop();
            sum -= _;
            pq.push(max(_,a[i]));
            sum += max(_,a[i]);
        }
        suf[ii] = sum;
    }
    LL mx = -(1LL<<60);
    for (int i=y;n-x>=i;i++)
    {
        mx = max(mx,pre[i]+suf[i+1]);
    }
    printf("%lld\n",mx+totc);
}




Measured memory_bytes: 4216
// Nguyen Anh Tu
#include <bits/stdc++.h>
#define FOR(x,a,b) for(int x=a;x<=b;x++)
#define FORD(x,a,b) for(int x=a;x>=b;x--)
#define maxn 1005
#define maxc 1000000007
#define MOD 1000000007
#define reset(x,y) memset(x,y,sizeof(x))
#define task ""
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define pii pair<int,int>
#define ll long long
#define bit(p,x) ((x>>p) & 1)
#define remain(a,b) (a+b >= MOD) ? (a+b - MOD) : (a+b)

using namespace std;
int n,m;
ll dp[maxn][maxn];
char a[maxn][maxn];
int main()
{
//    #ifndef ONLINE_JUDGE
//    ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL);
//    freopen(task".inp","r",stdin);
//    freopen(task".out","w",stdout);
//    #endif
    cin >> n >> m;
    for(int i=1; i<=n ;++i)
        for(int j=1; j<=m;++j) cin >> a[i][j];
    dp[1][1] = (a[1][1] == '.');
    for(int i=1; i<=n ;++i)
        for(int j=1; j<=m; ++j)
        if(a[i][j] == '.')
        {
            if(a[i-1][j] == '.') (dp[i][j] += dp[i-1][j]) %= maxc;
            if(a[i][j - 1] == '.') (dp[i][j] += dp[i][j-1]) %= maxc;
        }
    cout << dp[n][m];

}


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

struct quer
{
    int a, b, c, d;
};
int n, m, q;
int ans;
quer inp[50 + 1];

void genallp(vector<int> A)
{
    if (A.size() == n+1)
    {
        int fans = 0;
        for (int i = 1; i <= q; i++)
        {
            if (A[inp[i].b] - A[inp[i].a] == inp[i].c)
                fans += inp[i].d;
        }
        ans = max(ans, fans);
        return;
    }
    int g = A.back();
    for (int i = g; i <= m; i++)
    {
        A.push_back(i);
        genallp(A);
        A.pop_back();
    }
    return;
}
int main()
{
    cin >> n >> m >> q;
    for (int i = 1; i <= q; i++)
        cin >> inp[i].a >> inp[i].b >> inp[i].c >> inp[i].d;
    vector<int> A;
    A.push_back(1);
    genallp(A);
    cout<<ans;
}

Measured memory_bytes: 3628
import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;
import std.ascii;
import std.bigint;
import std.container;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

const real eps = 1e-10;

void main(){
	while(true) {
		auto e = readInt();
		if(e == 0) return;

		long m = long.max;
		for(long i; i^^3 <= e; ++i) {
			for(long j; i^^3 + j^^2 <= e; ++j) {
				m = min(m, i+j+(e-i^^3-j^^2));
			}
		}
		writeln(m);
	}
}

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

int read() {
	int f=1,x=0;char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') f=-1;c=getchar();}
	while(c>='0'&&c<='9') {x=(x<<1)+(x<<3)+(c^48);c=getchar();}
	return x*=f;
}

void write(int x) {
	int y=10,len=1;
	if(x<0) { x=-x,putchar('-'); }
	while(y<=x) { y*=10,len++; }
	while(len--) { y/=10,putchar(x/y+48),x%=y; }
	return ;
}

int x,t,n;

int main() {
	n=read(),x=read(),t=read();
	write(((n-1)/x+1)*t);
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int M, K;

void Pat0() {
  int n = 1 << M;
  for (int i = 0; i < n; ++i) {
    if (i != 0) cout << " ";
    cout << i << " " << i;
  }
  cout << endl;
}

bool CheckK() {
  int n = 1 << M;
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    if (i == K) continue;
    sum ^= i;
  }
  return sum == K;
}

void PatK() {
  int n = 1 << M;
  for (int i = 0; i < n; ++i) {
    if (i == K) continue;
    if (i != 0) cout << " ";
    cout << i;
  }
  cout << " " << K;
  for (int i = n-1; i >= 0; --i) {
    if (i == K) continue;
    cout << " " << i;
  }
  cout << " " << K << endl;
}

int main() {
  while (cin >> M >> K) {
    if (K == 0) {
      Pat0();
    } else if (CheckK()) {
      PatK();
    } else {
      cout << -1 << endl;
    }
  }
}


Measured memory_bytes: 1792
String = input();

num0_odd = 0;
num1_odd = 0;
num0_even = 0;
num1_even = 0;

odd_check=1;
num_of_tile=0;

for i in String:
    num_of_tile+=1;
    if(odd_check==0):
        if(i=="0"):
            num0_odd+=1;
        else:
            num1_odd+=1;
    else:
        if(i=="0"):
            num0_even+=1;
        else:
            num1_even+=1;

    odd_check+=1;
    if(odd_check==2):
        odd_check=0;

answer = max(num0_odd+num1_even, num0_even+num1_odd);
print(num_of_tile - answer);


Measured memory_bytes: 3188
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count = 0



a,b=map(int,input().split())
if a>=13:
    print(b)
elif a>=6:
    print(b//2)
else:
    print(0)

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

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(a*c, max(a*d, max(b*c, b*d))) << endl;
}

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

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

	if (b >= 10&&b<100) {
		a = a * 100;
	}
	else if(b>=100){
		a = a * 1000;
	}
	else {
		a = a * 10;
	}

	int c = a + b;

	for (int i = 1; i <= c; i++) {
		if (i*i == c) {
			f = 1;
			break;
		}
	}

	if (f == 1) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
class UnionFind:
  def __init__(self, n):
    self.parent = [i for i in range(n)]
    self.height = [0 for i in range(n)]
        
  def get_root(self, i):
    if self.parent[i] == i:
      return i
    else:
      self.parent[i] = self.get_root(self.parent[i])
      return self.parent[i]
            
  def unite(self, i, j):
    root_i = self.get_root(i)
    root_j = self.get_root(j)
    if root_i != root_j:
      if self.height[root_i] < self.height[root_j]:
        self.parent[root_i] = root_j
      else:
        self.parent[root_j] = root_i
        if self.height[root_i] == self.height[root_j]:
          self.height[root_i] += 1
                
  def is_in_group(self, i, j):
    if self.get_root(i) == self.get_root(j):
      return 1
    else:
      return 0

n, q = map(int, input().split())
uf = UnionFind(n)
for i in range(q):
  a, b, c = map(int, input().split())
  if(a == 0):
    uf.unite(b, c)
  else:
    print(uf.is_in_group(b, c))


Measured memory_bytes: 6040
n=int(input())
la=list(map(int,input().split()))
lb=list(map(int,input().split()))
lc=list(map(int,input().split()))
ans=sum(lb)
for i in range(n-1):
    if la[i]+1==la[i+1]:
        ans+=lc[la[i]-1]
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

int main()
{
    int N, M;
    cin >> N >> M;
    vint a(M), b(M);
    //vector<set<int>> m;
    set<int> s;
    vector<bool> b1(N+1),b2(N+1);
    rep(i, M)
    {
        int A, B;
        cin >> A >> B;
        a[i] = A;
        b[i] = B;
        //       m[A].insert(B);
        //        m[B].insert(A);
        if(A==1)
            b1[b[i]] = true;
        if(B==N)
            b2[a[i]] = true;
    }
    bool flag = false;
    rep(i,N)
    {
        if(b1[i] and b2[i])
            flag = true;
    }
    if (flag)
        cout << "POSSIBLE";
    else
        cout << "IMPOSSIBLE";
    return 0;
}


Measured memory_bytes: 1920
n = int(input())
li = [int(input()) for _ in range(n)]
ma = {}
for i,l in enumerate(li):
    ma[l] = i+1
nu = []
for j in range(n):
    nu.append(ma[j+1])

ans = [0]
tmp = 0
cnt = 0
for k,u in enumerate(nu):
    if k == 0:
        tmp = u
        cnt += 1
        continue
    if u > tmp:
        tmp = u
        cnt += 1
    else:
        ans.append(cnt)
        tmp = u
        cnt = 1
ans.append(cnt)
#print(ans)
#print(n,max(ans))
print(n - max(ans))

Measured memory_bytes: 34976
import java.io.PrintStream;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = null;
		PrintStream out = null;
		try {
			sc = new Scanner(System.in);
			out = System.out;
			exec(sc, out);
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		} finally {
			if(out != null) {
				out.close();
			}
			if(sc != null) {
				sc.close();
			}
		}
		System.exit(0);
	}
	public static void exec(final Scanner sc, final PrintStream out) throws Exception{
		final int N = sc.nextInt();
		final int M = sc.nextInt();

		final int[] A = new int[N];

		for(int i=0;i<N;i++) {
			A[i] = sc.nextInt();
		}

		final PriorityQueue<Integer> queue = new PriorityQueue<>(new Comparator<Integer>() {
			@Override
			public int compare(Integer o1, Integer o2) {
				return o2.intValue() - o1.intValue();
			}
		});

		for(int i=0;i<N;i++) {
			queue.add(A[i]);
		}
		if(N==1) {
			for(int m=0;m<M;m++) {
				A[0] = A[0] / 2;
			}
			out.println(A[0]);
			return;
		}

		int m = M;
		int head = queue.remove();
		int next = queue.element();
		while(m > 0) {
			head = head / 2;
			m--;
			if(head < next) {
				queue.add(head);
				head = queue.remove();
				next = queue.element();
			}
		}
		long sum = head;
		for(int x=0;x<N-1;x++) {
			sum += queue.remove().intValue();
		}
		out.println(sum);
	}

}


Measured memory_bytes: 50468
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
map<int,int > f;
int n,a[444444];
int lb(int x)
{return x&(-x);}
int main()
{
    int as=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]),++f[a[i]];
    sort(a+1,a+n+1);
    for(int i=n;i;--i)
        if(f[a[i]])
        {
            --f[a[i]];
            int now=a[i];
            while(lb(now)!=now)now^=lb(now);
            now<<=1;
            if(f[now-a[i]])++as,--f[now-a[i]];
        }
    return printf("%d",as),0;
}

Measured memory_bytes: 19712
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,l,r) for (int i=l; i<=r; i++)
typedef long long ll;
using namespace std;

const int N=100010;
int n,k,tot,b[N],a[N],ans;
int Abs(int x){ return (x<0) ? -x : x; }

int main(){
	scanf("%d%d",&n,&k); ans=1e9;
	rep(i,1,n) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	rep(i,1,n-k+1){
		int x=i,y=i+k-1;
		if (a[x]<=0 && a[y]>=0) ans=min(ans,min(-2*a[x]+a[y],2*a[y]-a[x]));
		else ans=min(ans,max(Abs(a[x]),Abs(a[y])));
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 640
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

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

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[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),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let (N, K) = read!(usize, i64);
    let H = read![[i64]];

    println!("{}", (0..N).filter(|&i| H[i] >= K).count())
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000;
#define all(v) v.begin(), v.end()

int main(){
  ll N,K,ans=0;
  cin >> N >> K;
  vector<ll> P(N);
  rep(i,N) cin >> P.at(i);
  sort(all(P));
  rep(i,K){
    ans+=P.at(i);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3628
N = gets.to_i
a = gets.split.map(&:to_i)
b = Array.new(N,0)
a.each do |e|
    b[e-1] += 1
end 
c = b.map{|e|(e*e-e)/2}
sum = c.inject(&:+)
N.times do |i|
    puts sum - c[a[i]-1] + ((b[a[i]-1]-1)**2 - (b[a[i]-1]-1))/2
end 

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

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

    string S, T;
    cin >> S >> T;

    string ans = "UNRESTORABLE";
    for (int i = 0; i < S.size()-T.size()+1; i++) {
        string tmp(S);
        for (int j = i; j < T.size()+i; j++) {
            if (S[j] == '?' || S[j] == T[j-i]) {
                tmp[j] = T[j-i];
                if (j == T.size()+i-1) {
                    for (int k = 0; k < S.size(); k++) {
                        if (tmp[k] == '?') {
                            tmp[k] = 'a';
                        }
                    }
                    ans = tmp;
                }
            } else {
                break;
            }
        }
    }

    cout << ans << endl;
    return 0;
}

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

int  main()
{

	int n,k; cin >> n >> k;
	vector<int> a(n);
	int mini = 100001;
	int ite;
	rep(i, n)
	{
		cin >> a[i];
		if (a[i] == 1)
			ite = i;
	}
	if (n <= k)
	{
		cout << 1; return 0;
	}

	int cnt = 0;

	if (ite % (k - 1) == 0)
		cnt += ite / (k - 1);
	else
	{
		cnt += ite / (k - 1) ;
		cnt++;
	}
	n--;
	if (ite+1 >=  k)
	{
		if(ite % (k - 1) == 1)
		{
			if ((n - ite - 1) % (k - 1) == 0)
				cnt += (n - ite) / (k-1);
			else
			{
				cnt += (n - ite) / (k-1);
				cnt++;
			}
		}
		else if ((n - ite) % (k - 1) == 0)
			cnt += (n - ite) / (k-1);
		else
		{
			cnt += (n - ite) / (k-1);
			cnt++;
		}
	}
	else
	{
		if (ite == 0)
			cnt++;
		if ((n - k - 1) % k == 0 )
			cnt += (n - k - 1) / (k-1);
		else
		{
			cnt += (n - k - 1) / (k-1);
			cnt++;
		}
	}
	cout << cnt << endl;
	// cout << ite << endl;
	return (0);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 1e9+7;
const int maxn = 250005;

void go() {
    int n;
    cin >> n;
    vector<int>v(n);
    for (auto &i : v) {
    	cin >> i;
    }
    ll dp[n] = {};
    dp[n - 1] = 0;
    dp[n - 2] = abs(v[n - 1] - v[n - 2]);
    for (int i = n - 3 ; i >= 0 ; i--) {
    	dp[i] = min(dp[i + 2] + abs(v[i + 2] - v[i]), dp[i + 1] + abs(v[i + 1] - v[i]));
    }
    cout << dp[0] << '\n';
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int c = 0;
    int t;
    if (!c) {
        t = 1;
    }
    else {
        cin >> t;
    }
    while (t--) {
        go();
    }
    
}


Measured memory_bytes: 4520
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        k: usize,
        mut h: [i64; n],
    }

    h.sort();

    let ans = if k >= n {
        0
    } else {
        dbg!("HI");
        h.iter().rev().skip(k).sum()
    };

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


Measured memory_bytes: 6252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  string s; cin>>s;
  vector<int> a(4);
  for(int i=0; i<4; i++){
    a[i]=s[i]-'0';
  }
  for(int bit=0; bit<8; bit++){
    int ans=a[0];
    for(int i=0; i<3; i++){
      if((bit>>i)&1) ans+=a[i+1];
      else ans-=a[i+1];
    }
    if(ans==7){
      string str="0-0-0-0=7";
      for(int i=0; i<4; i++) str[i*2]+=a[i];
      for(int i=0; i<3; i++)
        if((bit>>i)&1) str[i*2+1]='+';

      cout << str << endl;
      return 0;
    }
  }
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) { return a * b / GCD(a, b); }

using P = pair<int, int>;

P f(int x) {
    int a = x % 10;
    int b = 0;
    while (x) {
        b = x;
        x /= 10;
    }
    return P(a, b);
}


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

    map<P, int> freq;
    for (int i=1;i<=N;++i) {
        P p = f(i);
        freq[p]++;
    }

    int ans = 0;

    for (int i=1;i<=N;++i) {
        P p = f(i);
        P q(p.second, p.first);
        ans += freq[q];
    }

    cout << ans << endl;
}

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

int main() {
  int r;
  cin >> r;
  cout << (2 * r * 3.141592) << endl;
}


Measured memory_bytes: 3812
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
//typedef __int64 LL;
typedef vector<int> ivec;
typedef vector<string> svec;

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


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>

#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;

const ll mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

struct Vector2 {
  int x;
  int y;
};

using State =  vector<vector<int>>;

const int NONE = 0;
const int STONE = 1;
const int START = 2;
const int GOAL = 3;


bool in_area(Vector2 v, int w, int h) {
  if(0 <= v.x && v.x < w && 0 <= v.y && v.y < h) return true;
  else return false;
}

int dfs(State state, Vector2 curr, int w, int h, int turn) {
  if(turn > 10) return INT_MAX;
  int ret = INT_MAX;
  for(int i = 0; i < 4; i++) {
    if(in_area({curr.x + dx[i], curr.y + dy[i]}, w, h) && state[curr.y + dy[i]][curr.x + dx[i]] == STONE) continue;
    State next_state = state;
    Vector2 next_curr = curr;
    bool is_next = false;
    while(1) {
      next_curr.x += dx[i]; next_curr.y += dy[i];
      // //cerr << next_curr.x << " " << next_curr.y << endl;
      if(!in_area(next_curr, w, h)) break;
      if(next_state[next_curr.y][next_curr.x] == GOAL) return turn;
      else if(next_state[next_curr.y][next_curr.x] == STONE) {
	next_state[next_curr.y][next_curr.x] = NONE;
	next_curr.x -= dx[i]; next_curr.y -= dy[i];
	is_next = true;
	break;
      }
    }
    if(is_next) ret = min(ret, dfs(next_state, next_curr, w, h, turn + 1));
  }

  return ret;
}

int main(){
  int w, h;
  while(cin >> w >> h) {
    if(w == 0 && h == 0) break;
    State state = State(h, vector<int>(w));
    Vector2 start;
    for(int i = 0; i < h; i++) {
      for(int j = 0; j < w; j++) {
	cin >> state[i][j];
	if(state[i][j] == START) {
	  start = {j, i};
	}
      }
    }
    int turn = dfs(state, start, w, h, 1);
    if(turn == INT_MAX) cout << -1 << endl;
    else cout << turn << endl;
  }
}



Measured memory_bytes: 3268
#include<stdio.h>
int main()
{
  char s[101];
  scanf("%s",&s);
  int i,r,n;
  n=strlen(s);
  r=0;
  for(i=0;i<(n/2);i++)
  {
    if(s[i]!=s[n-i-1])r++;
  }
  printf("%d",r);
  return 0;
}
    
    

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


using namespace std;

const int N = 200002;
typedef pair<int, int> pii;

char s[N];
int g[N][26];
int pre[N], dis[N];

int main(void) {
    scanf("%s", s + 1);
    int n = strlen(s + 1);
    for (int i = 1; i <= n; ++i) {
        int o = s[i] - 'a';
        for (int j = i - 1; j >= 0 && !g[j][o]; --j)
            g[j][o] = i;
    }

    string ans; int y = 0, x = -1;
    queue<int> q;
    dis[0] = 1; pre[0] = -1; q.push(0);
    while (!q.empty()) {
        int u = q.front(); q.pop();
        for (int o = 0; o != 26; ++o) {
            int v = g[u][o];
            if (!v) {
                x = u;
                break;
            }
            else {
                if (dis[v]) continue;
                dis[v] = dis[u] + 1;
                pre[v] = u; q.push(v);
            }
        }
        if (x != -1) break;
    }

    while (x != -1) {
        for (int o = 0; o != 26; ++o) {
            if (g[x][o] != y) continue;
            ans.push_back(o + 'a');
            y = x; x = pre[x];
            break;
        }
    }

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

    printf("%s", ans.c_str());
    return 0;
}

Measured memory_bytes: 22272
using System;

namespace ABC070B
{
    class Program
    {
        static void Main(string[] args)
        {
            var target = Console.ReadLine().Split(' ');
            int AS = int.Parse(target[0]);
            int AE = int.Parse(target[1]);
            int BS = int.Parse(target[2]);
            int BE = int.Parse(target[3]);

            int count = 0;
            int time = 0;
            while(time < 100){
                if(time >= AS && time < AE && time >= BS && time < BE)
                count++;
                time++;
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13140
#include<cmath>
#include<cstdio>
#include<vector>
using namespace std;

struct vertex {
    int par;
    vector<int> to;
};

int n, u, v;
vertex ver[100000];
int d[2][100000];

void dfs(int x, bool y) {
    for (auto &i : ver[x].to) {
        if (i == ver[x].par) continue;
        ver[i].par = x;
        d[y][i] = d[y][x] + 1;
        dfs(i, y);
    }
}

int main() {
    scanf("%d %d %d", &n, &u, &v);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        scanf("%d %d", &a, &b);
        ver[a - 1].to.push_back(b - 1);
        ver[b - 1].to.push_back(a - 1);
    }
    
    ver[u - 1].par = u - 1; 
    dfs(u - 1, 0);
    ver[v - 1].par = v - 1; 
    dfs(v - 1, 1);
    
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (d[1][i] > d[0][i]) {
            ans = max(ans, d[1][i] - 1);
        }
    }
    printf("%d\n", ans);
    return 0;
}
        


Measured memory_bytes: 13696
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	H, W := sc.nextInt(), sc.nextInt()
	T := make([][]rune, H+2)
	for i := 0; i < H+2; i++ {
		col := make([]rune, W+2)
		col[0], col[W+1] = '#', '#'
		if i == 0 || i == H+1 {
			for j := 1; j <= W; j++ {
				col[j] = '#'
			}
		} else {
			runes := sc.nextRuneSlice()
			for j := 1; j <= W; j++ {
				col[j] = runes[j-1]
			}
		}
		T[i] = col
	}

	for _, col := range T {
		fmt.Fprintln(wtr, string(col))
	}
	wtr.Flush()
}


Measured memory_bytes: 768
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long ll;

const int MAXN = 2E5 + 10, MAXL = 1 << 19;
const ll MOD = 924844033;

int n;
vector<int> E[MAXN];
int size[MAXN];
ll cnt[MAXN], c[MAXN];
ll A[MAXL], B[MAXL];

ll modExp(ll e, ll n, ll m = MOD){
	ll ret = 1;
	for (; n; n >>= 1, e = e * e % m)
		if (n & 1)
			ret = ret * e % m;
	return ret;
}

void DFS(int u, int pre){
	size[u] = 1;
	for (int v, i = 0; i < E[u].size(); ++i){
		if ((v = E[u][i]) == pre)
			continue;
		DFS(v, u);
		++cnt[size[v]];
		++cnt[n - size[v]];
		size[u] += size[v];
	}
}

typedef long long LL;
LL pm(LL a,LL n,LL m){
    LL r=1;
    for(;n;n>>=1,a=a*a%m)
        if(n&1)r=r*a%m;
    return r;
}

const LL P=924844033,g=5;
void ntt(LL *a,size_t n,bool inv=false){
    LL w=1,d=pm(g,(P-1)/n,P),t;
    size_t i,j,c,s;
    if(inv){
        for(i=1,j=n-1;i<j;swap(a[i++],a[j--]));
        for(t=pm(n,P-2,P),i=0;i<n;++i)a[i]=a[i]*t%P;
    }
    for(s=n>>1;s;s>>=w=1,d=d*d%P)
    for(c=0;c<s;++c,w=w*d%P)
    for(i=c;i<n;i+=s<<1){
        a[i|s]=(a[i]+P-(t=a[i|s]))*w%P;
        a[i]=(a[i]+t)%P;
    }
    for(i=1;i<n;++i){
        for(j=0,s=i,c=n>>1;c;c>>=1,s>>=1)j=j<<1|s&1;
        if(i<j)swap(a[i],a[j]);
    }
}

int main(){
	scanf("%d", &n);
	for (int u, v, i = 1; i < n; ++i){
		scanf("%d%d", &u, &v);
		E[u].push_back(v);
		E[v].push_back(u);
	}
	DFS(1, 0);
	cnt[n] = MOD - n;
	ll e = 1;
	for (int i = 1; i <= n; ++i){
		e = e * i % MOD;
		A[i] = (MOD - cnt[i]) * e % MOD;
	}
	e = modExp(e, MOD - 2, MOD);
	for (int i = 0; i <= n; ++i){
		B[i] = c[n - i] = e;
		e = e * (n - i) % MOD;
	}

	int len = 1;
	for (; len < n * 2 + 2; len <<= 1);
	ntt(A, len), ntt(B, len);
	for (int i = 0; i < len; ++i)
		A[i] = A[i] * B[i] % MOD;
	ntt(A, len, true);
	for (int i = 1; i <= n; ++i)
		printf("%d\n", (int)(c[i] * A[n + i] % MOD));
	return 0;
}


Measured memory_bytes: 38400
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pi 3.141592653589793116
#define mod 1e9+7
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int main() {
  off;
  
  int t;
  //cin>>t;
  t=1;
  while(t--){  
    string s;int n,k;
    cin>>n>>k>>s;
    vector <int> l,r;
    vector <pair <int,int> > v;
    int pre=0,z=0;
    //cout<<s.size()<<" ";
    if(s[0]=='0')
        l.push_back({0});
    for(int i=0;i<n;i++)
        {
           if(s[i]=='1')
              {
                ++pre;
                if(z!=0)
                    {  
                       v.push_back({i-z,i-1});
                       z=0;
                    }
              }
           else
              {  ++z;
                  if(pre!=0)
                    {
                        l.push_back(pre);
                        pre=0;
                    }
              }   
        }
      if(z!=0)
        {  //cout<<'\n';
            //cout<<z<<'\n';
            v.push_back({n-z,n-1});
        }  
     int ans=0;
      sort(v.begin(),v.end());
      if(v.size()==0 || v.size()<=k)
        ans=n;
      else
         ans=0;
      for(int i=0;i+k-1<v.size();i++)
        {   int temp=0;
            if(i==0)
                {   temp=v[0].first-0;
                    //ans=max(ans,)
                }
             else
                 temp=v[i].first-v[i-1].second-1;
             if(i+k-1==v.size()-1)
                {
                   temp+=(n-v[i+k-1].second-1);
                }
             else
                {
                    temp+=(v[i+k+1-1].first-v[i+k-1].second-1);
                }
              temp+=(v[i+k-1].second-v[i].first+1);     
              ans=max(temp,ans);

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

Measured memory_bytes: 1244
#include <bits/stdc++.h>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
#define cin(a) scanf("%d",&a)
#define pii pair<int,int>
#define ll long long
#define gcd __gcd
const int inf = 0x3f3f3f3f;
const int maxn = 201110;
const int M = 1e9;
int n,m,s;

int main()
{
    cin>>n>>m>>s;
    int i = 1;
    for(i = 1; i <= m; i++) 
    {
        printf("%d ",s);
    }
    s = (s+1);
    if(s > 1e9) s -= 1e9;
    for(i = m+1; i <= n; i++) 
    {
        printf("%d ",s);
    }
    puts("");
    return 0;
}

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

int main() {
  int n;
  int s1, s2, s3;
  int count = 0;
  cin >> n;
  
  s1 = n / 100;
  n %= 100;
  s2 = n / 10;
  n %= 10;
  s3 = n;
  
  if (s1 == 1)
    count++;
  if (s2 == 1)
    count++;
  if (s3 == 1)
    count++;
  
  cout << count << endl;
}

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
	ll n,x,d;cin>>n>>x>>d;
	map<ll,vector<P>>mp;
	ll smin=0,smax=0;
	ll sum=(n-1)*n/2;
	set<ll>se;
	for(ll i=0;i<=n;i++){
		ll s=i,t=n-i;
		if(i){
			smin+=i-1;
			smax+=n-i;
		}
		ll L=(s-t)*x+(smin*2-sum)*d,R=(s-t)*x+(smax*2-sum)*d;
		if(d==0){
			se.insert(L);
		}
		else mp[(L%(2*d)+2*d)%(2*d)].push_back(P(L,R));
	}
	if(d==0){
		cout<<se.size()<<endl;
		return 0;
	}
	ll ans=0;
	for(auto v:mp){
		ll m=v.first;
		for(auto&p:v.second){
			p.first-=m;p.second-=m;
			p.first/=(2*d);
			p.second/=(2*d);
		}
		vector<P>u;
		sort(v.second.begin(),v.second.end());
		for(auto&p:v.second){
			if(u.empty()||u.back().second+1<p.first)u.push_back(p);
			else u.back().second=max(u.back().second,p.second);
		}
		for(auto&p:u){
			ans+=p.second-p.first+1;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 22144
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fi first
#define se second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>
#define LEAD (lead && !i)
#define LIM (lim && i == buc[pos])
#define ABS(x) (x) < 0 ? (-x) : (x)
#define RG register
 
using std::cin;
using std::cout;
using std::endl;
 
typedef long long ll;
typedef unsigned long long ull;
 
const int N = 300000 + 5;
const int M = 1000 + 5;
const int K = 1e7 + 5;
const int MOD = 1e9 + 7;
const int inv2 = 500000004;
const int LOG = 40;
const ull BASE = 19260817;
const int INF = 0x3f3f3f3f;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };
// const double PI = acos(-1);
const double PI = 3.14159;

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
 
template<class T>
inline T readT() {
    T res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}
#define read readT<ll>

namespace Comb{
const int N = 10 + 5;
inline void exgcd(ll a, ll b, ll &g, ll &x, ll &y) {
    if (!b) g = a, x = 1, y = 0;
    else exgcd(b, a % b, g, y, x), y -= x * (a / b);
}
 
inline ll inv(ll a) {
    ll g, res, tmp;
    exgcd(a, MOD, g, res, tmp);
    return ((res % MOD) + MOD) % MOD;
}
 
ll f[N], invFact[N];
 
inline void prepare() {
    f[0] = 1;
    int n = 200000;
    for (int i = 1; i <= n; i++) f[i] = f[i - 1] * i % MOD;
    invFact[n] = inv(f[n]);
    for (int i = n - 1; i >= 1; i--) invFact[i] = invFact[i + 1] * (i + 1) % MOD;
}
 
inline ll C(int n, int m) {
    if (!m) return 1;
    if (n == m) return 1;
    if (m > n) return 0;
    if (m < 0) return 0;
    return f[n] * invFact[m] % MOD * invFact[n - m] % MOD;
}
}

int n, ans;
String s, t;

int main() {
    cin >> n;
    ans = n * 2;
    cin >> s >> t;
    for (int len = 1; len <= n; len++) {
        if (s.substr(n - len, len) == t.substr(0, len)) {
            chkmin(ans, n * 2 - len);
        }
    }
    printf("%d\n", ans);
    return 0;
}

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

using namespace std;

int n;
string str;

int main(){
    cin >> n;
    cin >> str;
    set<string> first, second, third;
    for(int i = 0; i < n; i++){
        for(auto&& j : second){
            third.insert(j + str[i]);
        }
        for(auto&& j : first){
            second.insert(j + str[i]);
        }
        first.insert(string(1, str[i]));
    }
    cout << third.size() << "\n";
}

Measured memory_bytes: 384
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

  	string s; cin >> s;
    int res = 700;
  
    rep(i, 0, s.size()) {
        if(s[i] == 'o') res += 100;
    }
  
    cout << res << endl;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n
#define endl '\n'

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const ll mod=1000000007;
const ll mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

template<class T>
inline bool chmax(T& a, T b){if(a<b){a=b;return true;} return false;}

template<class T>
inline bool chmin(T& a, T b){if(a>b){a=b;return true;} return false;}

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

void out(){cout << "\n";}
template<class T,class... Args>
void out(const T &x,const Args &... args){
	cout << x << " ";
	out(args...);
}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll k,a,b;
	cin >> k >> a >> b;
	for(ll i=a;i<=b;i++){
		if(i%k==0){
			cout << "OK\n";
			return 0;
		}
	}
	cout << "NG\n";
	return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
using namespace std;


int main()
{
	int a, b, k;
	cin >> a >> b >> k;
	vector<int>n;
	for (int i = 0; i < k; i++) {
		if (count(n.begin(), n.end(), max(a,b-i)) == 0 && count(n.begin(), n.end(), min(a+i, b)) == 0) {
			n.push_back(min(a + i, b));
			if (a+i != b-i)n.push_back(max(a, b - i));
		}
	}
	sort(n.begin(),n.end());
	for (int& x : n)cout << x << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

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

    void run() {

        char[] arr = sc.next().toCharArray();
        int cnt = 0;

        for (int i=0; i<arr.length; i++) {
            if (arr[i]=='7') cnt++;
        }

        if (cnt==0) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }


    }
}


Measured memory_bytes: 26888
#include <bits/stdc++.h>
#define INF 1000000000
using namespace std;

int ary[60][60],dp[3][60];
int main(){
	int N,M;
	cin>>N>>M;
	char ch;
	for(int i=1;i<=N;i++){
		for(int j=1;j<=M;j++){
			cin>>ch;
			switch(ch){
				case 'W':
					ary[i][j]=0;
					break;
				case 'B':
					ary[i][j]=1;
					break;
				case 'R':
					ary[i][j]=2;
					break;
			}
			dp[ary[i][j]][i]++;
		}
	}

	int tmp,res=INF;
	for(int i=2;i<=N-1;i++){
		for(int j=i+1;j<=N;j++){
			tmp=0;
			for(int k=1;k<=N;k++){
				if(k<i) tmp+=(dp[1][k]+dp[2][k]);
				else if(k<j) tmp+=(dp[0][k]+dp[2][k]);
				else tmp+=(dp[0][k]+dp[1][k]);
			}
			res=min(res,tmp);
		}
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <list>
#include <cmath>
#include <limits>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

int main() {
    char c;
    cin >> c;
    if(c == 'a' or c == 'i' or c == 'u' or c == 'e' or c == 'o') cout << "vowel" << endl;
    else cout << "consonant" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long solve(string s)
{
	long long sum = 0;
	int rsq[3][s.size()+1];
	int n = s.size();
	rsq[0][0] = rsq[1][0] = rsq[2][0] = 0;
	for(int i=0;i<n;++i)
	{
		rsq[0][i+1] = rsq[0][i];
		rsq[1][i+1] = rsq[1][i];
		rsq[2][i+1] = rsq[2][i];
		
		if(s[i]=='R')
			rsq[0][i+1]++;
		else if(s[i]=='G')
			rsq[1][i+1]++;
		else
			rsq[2][i+1]++;
	}
	set<char> st;
	for(int i=0;i<n;++i)
	{
		for(int j=i+1;j<n;++j)
		{
			st.insert('R');
			st.insert('G');
			st.insert('B');
			if(s[i]!=s[j])
			{
				st.erase(s[i]);
				st.erase(s[j]);
				char c = *(st.begin()); 
				if(c=='R')
				{
					sum += 1LL*(rsq[0][n]-rsq[0][j]);
					if(2*j-i<n)
						sum -= 1LL*(rsq[0][2*j+1-i]-rsq[0][2*j-i]);
				}
				else if(c=='G')
				{
					sum += 1LL*(rsq[1][n]-rsq[1][j]);
					if(2*j-i<n)
						sum -=1LL*(rsq[1][2*j+1-i]-rsq[1][2*j-i]);
				}
				else
				{
					sum += 1LL*(rsq[2][n]-rsq[2][j]);
					if(2*j-i<n)
						sum -=1LL*(rsq[2][2*j+1-i]-rsq[2][2*j-i]);
				}
			}
		}
	}
	return sum;	
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	string s;
	cin>>n>>s;
	cout<<solve(s);
	return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define M 1000000007
using namespace std;
int dp[3001][3001];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  int n,k;
  cin>>n>>k;
  vector<int>a(n);
  for(int& x:a)
  cin>>x;
 vector<bool>dp(k+1);
 for(int i=0;i<=k;i++)
 {
     for(int x:a)
     
     {
         if(i>=x && !dp[i-x])
         dp[i]=true;
     }
 }
 if(dp[k])
 cout<<"First";
 else
 cout<<"Second";
}

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


//TEMPLATE
#define pb                push_back
#define mp                make_pair
#define ll                long long
#define ld                long double
#define pii               pair <ll, ll>
#define piii              pair <ll, pii>
#define F                 first
#define S                 second

#define newline           printf("\n")
#define minusone          printf("-1\n")
#define zeroo             printf("0\n")
#define scl1(a)           scanf("%lld", &a)
#define scl2(a, b)        scanf("%lld %lld", &a, &b)
#define scl3(a, b, c)     scanf("%lld %lld %lld", &a, &b, &c)
#define prl1(a)           printf("%lld\n", a)
#define prl2(a, b)        printf("%lld %lld\n", a, b)
#define ssl1(s)           scanf(" %[^\n]", s)
#define scd1(a)           scanf("%lf", &a)
#define scd2(a, b)        scanf("%lf %lf", &a, &b)
#define prd(a)            printf("%lf\n", a)
#define prld(a)           printf("%Lf\n", a)
#define prcase(cs)        printf("Case %lld: ", cs)
#define cin1(a)           cin >> a
#define cin2(a, b)        cin >> a >> b
#define cin3(a, b, c)     cin >> a >> b >> c
#define cin4(a, b, c, d)  cin >> a >> b >> c >> d
#define cot1(a)           cout << a << "\n"
#define cot2(a, b)        cout << a << " " << b << "\n"
#define cot3(a, b, c)     cout << a << " " << b << " " << c << "\n"
#define cot4(a, b, c, d)  cout << a << " " << b << " " << c << " " << d << "\n"
#define cotline           cout << "\n"
#define cotminus          cout << "-1\n"
#define cot0              cout << "0\n"
#define cotyes            cout << "YES\n"
#define cotno             cout << "NO\n"
#define cotcase(cs)       cout << "Case " << cs << ": "

#define reversed(s)       reverse(s.begin(), s.end())
#define asort(s)          sort(s.begin(), s.end())
#define dsort(s)          sort(s.rbegin(), s.rend())
#define all(s)            s.begin(), s.end()
#define uniq(s)           s.resize(distance(s.begin(),unique(s.begin(), s.end())))
#define found(s, x)       (s.find(x) != s.end())

#define for0(i, n)        for (i = 0; i < n; i++)
#define for1(i, n)        for (i = 1; i <= n; i++)
#define fora(i, a, b)     for (i = a; i <= b; i++)
#define forb(i, b, a)     for (i = b; i >= a; i--)
#define fori(it, s)       for(auto it = s.begin(); it != s.end(); it++)

#define FR                ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ms(a, x)          memset(a, x, sizeof a)
#define bitcount(n)       __builtin_popcountll(n)

//#define pi              3.1415926536
#define pi                acos(-1)

const ll INF = LLONG_MAX;
const ll SZ = 4e5+5;
const ll mod = 1e9+7;


ll n;
ll a[SZ];
//ll b[SZ];



int main() {
    ll cs = 0, tc = 1, x, y, z, i, j, k, g, p, q, ans = 0, sum = 0, c = 0, t = 0;
//    ll a, b, d;
    string s, s1, s2;

    cin1(n);
    for1(i, n) cin1(a[i]);

    sort(a+1, a+n+1);

    for1(i, n) {
        fora(j, i+1, n) {
            fora(k, j+1, n) {
                if(a[i]+a[j] > a[k] && a[i] != a[j] && a[j] != a[k] && a[i] != a[k]) {
                    ans++;
//                    cot3(i, j, k);
                }
            }
        }
    }

    cot1(ans);

    return 0;
}



Measured memory_bytes: 3632