akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/algorithm_ext.hpp>
#include <boost/math/common_factor_rt.hpp>
using namespace std;
using namespace boost::range;
using boost::irange;
using boost::math::gcd;
using boost::math::lcm;

using ll = int64_t;
constexpr char LN = '\n';
template<class T> bool chmax(T& a, const T& b) {if(a<b){a=b;return true;}else{return false;}}
template<class T> bool chmin(T& a, const T& b) {if(b<a){a=b;return true;}else{return false;}}

#ifdef LOCAL
template<class H> void dump_(const char* s, H h) {cout<<s<<"="<<h<<LN; }
template<class H, class... T> void dump_(const char* s, H h, T... t) {for(;*s!=',';++s){cout<<*s;}cout<<"="<<h<<",";dump_(++s,t...);}
#define dump(...) dump_(#__VA_ARGS__, __VA_ARGS__)
#else
#define dump(...)
#endif

struct init_ {init_(){cin.tie(nullptr);ios::sync_with_stdio(false);}} init_;

template<class C> C scan(size_t n) {C c(n);for(auto& v:c){cin>>v;}return c;}
template<class C> C scan(size_t n, size_t m) {C vss(n);for(auto& vs:vss){vs.resize(m);for(auto& v:vs){cin>>v;}}return vss;}

template<class R> struct Joined { const R& r; const char* s; };
template<class R> Joined<R> joined(const R& r, const char* s = " ") {return{r,s};}
template<class R> ostream& operator<<(ostream& out, Joined<R> j) {bool f=true;for(const auto& v:j.r){if(f){f=false;}else{out<<j.s;}out<<v;}return out;}

template<class T> using matrix = vector<vector<T>>;
template<class T> matrix<T> make_matrix(size_t n, size_t m, const T& init = T()) {matrix<T> vss(n);for(auto& vs:vss){vs.resize(m,init);}return vss;}
template<class T> ostream& operator<<(ostream& out, Joined<matrix<T>> j) {bool a=true;for(const auto& vs:j.r){if(a){a=false;}else{out<<LN;}bool f=true;for(const auto& v:vs){if(f){f=false;}else{out<<j.s;}out << v;}}return out;}

template<class T> void show(const T& t) {cout<<t<<LN;}
template<class T> void show(const vector<T>& v) {cout<<joined(v)<<LN;}
void show(bool b) {cout<<(b?"Yes":"No")<<LN;}
void show(double d) {cout<<fixed<<setprecision(12)<<d<<LN;}

int main() {
    ll A, B, K;
    cin >> A >> B >> K;
    cout << max(0l, A - K) << " " << max(0l, B - max(0l, K - A)) << LN;
}


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

#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;

LL gcd(LL a,LL b){return b?gcd(b,a%b):a;}
LL lcm(LL a,LL b){return a/gcd(a,b)*b;}
LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
const int N = 2e5 +11;
int n,k;
vector<pair<int,int> >ans,mid;
vector<int>v[444];
int d[N],cnt,b[N];
int main(){
	ios::sync_with_stdio(false);
	cin>>n>>k;
	if(k>(n-1)*(n-2)/2)return cout<<-1,0;
	for(int i=2;i<=n;i++){
		ans.pb({1,i});
	}
	k-=(n-1)*(n-2)/2;
	for(int i=2;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			if(k)ans.pb({i,j}),k++;
		}
	}
	cout<<ans.size()<<endl;
	for(auto k:ans)cout<<k.fi<<' '<<k.se<<endl;
	return 0;
}

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

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

Node root;

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

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

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

Node treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left==NIL || z->right==NIL){ y=z;}
  else {y= treeSuccessor(z);}
  if(y->left!=NIL){ x=y->left;}
  else {x=y->right;}
  if(x!=NIL){ x->parent=y->parent;}
  if(y->parent==NIL){ root=x;}
  else if(y==y->parent->left){ y->parent->left=x;}
  else {y->parent->right=x;}
  if(y!=z){
    z->key=y->key;
  }
    return y;
}


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

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x!=NIL){
    y=x;
    if(z->key < x->key){ x=x->left;}
    else{x=x->right;}
  }
  z->parent=y;
  if(y==NIL){ root = z;}
  else if(z->key < y->key){y->left=z;}
  else y->right=z;
}

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


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

  return 0;
}

Measured memory_bytes: 24040
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;


int count_less_or_equal_primes(int num) {
  vector<bool> is_primes(num + 1, true);

  is_primes[1] = false;

  double num_sqrt = sqrt(num);
  for(int i = 2; i <= num_sqrt; i++) {
    if(!is_primes[i]) {
      continue;
    }

    // Sift numbers
    for(int j = i + i; j <= num; j += i) {
      is_primes[j] = false;
    }
  }

  // Count left primes
  int prime_count = 0;
  for(int i = 1; i <= num; i++) {
    if(is_primes[i]) {
      prime_count++;
    }
  }
  return prime_count;
}

int main() {
  int num;

  while(cin >> num) {
    cout << count_less_or_equal_primes(num) << endl;
  }
}



Measured memory_bytes: 3196
#!/usr/bin/env python3

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

N = int(input())
MOD = 10**9+7

d = {}

for i in range(2, N+1):
    D = factorization(i)
    for n in D:
        if n[0] in d: d[n[0]] += n[1]
        else: d[n[0]] = n[1]

ret = 1

for k, v in d.items():
    ret *= v + 1

print(ret%MOD)



Measured memory_bytes: 9368
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int N = 55 , M = 1010 , P = 1e9 + 7;
int Pow(int x,int t){int r=1;for(;t;t>>=1,x=1ll*x*x%P)if(t&1)r=1ll*r*x%P;return r;}
int n , m , K , f[M] = {1}, rf[M];
vector<pii> g[N];
int Cir(int n){
    int ret = 0;
    rep(i,0,n) (ret += Pow(K , __gcd(i,n))) %= P;
    return 1ll * ret * Pow(n , P - 2) % P;
}
int Cirs(int n){
    return 1ll * f[n + K - 1] * rf[n] % P * rf[K - 1] % P;
}

int fa[M],pre[M],uv[M],u[M],v[M],dfn[M],_;
int F(int x){return fa[x]==x?x:fa[x]=F(fa[x]);}
void Merge(int a,int b){fa[F(b)]=F(a);}
void dfs(int c,int fa){
    dfn[c] = ++_;
    for(auto e : g[c]) if(e.fi != fa){
        if(!dfn[e.fi]) pre[e.fi]=e.se , dfs(e.fi , c);
        else if(dfn[e.fi] < dfn[c]){
            for(int i=c;i!=e.fi;i=uv[pre[i]]^i) Merge(e.se , pre[i]);
        }
    }
}

int main(){
    rep(i,1,M) f[i] = 1ll * f[i-1] * i % P;
    rep(i,0,M) rf[i] = Pow(f[i] , P - 2);
    scanf("%d%d%d",&n,&m,&K);
    rep(i,0,m){
        int a,b;scanf("%d%d",&a,&b);--a;--b;
        u[i] = a , v[i] = b;
        uv[i]=a^b;
        g[a].pb(mp(b,i));
        g[b].pb(mp(a,i));
    }
    rep(i,0,m) fa[i] = i;
    rep(i,0,n) if(!dfn[i]) dfs(i,0);
    int ans = 1;
    rep(i,0,m) if(F(i) == i){
        int edge = 0;
        set<int> S;
        rep(j,0,m) if(F(j) == i) edge++ , S.insert(u[j]) , S.insert(v[j]);
        if(edge == sz(S)) ans = 1ll * ans * Cir(edge) % P;
        else ans = 1ll * ans * Cirs(edge) % P;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
# D - Banned K
from collections import Counter


def main():
    N, *A = map(int, open(0).read().split())
    cnt = Counter(A)
    total = sum(v * (v - 1) // 2 for k, v in cnt.items())
    ans = [total - (cnt[a] - 1) for a in A]
    print("\n".join(map(str, ans)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 40332
import java.util.Scanner;
//import java.util.Arrays;
public class Main {
	public static void main(String[] args) throws java.io.IOException {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		while(n != 0){
			int a[] = new int[n];
			for(int i = 0; i < n ; i++){
				a[i] = scan.nextInt();
			}
			int b[] = {0,0,0,0,0,0,0};
			for(int i = 0; i < n ; i++){
				if(a[i] < 10){
					b[0]++;
				}else if(a[i] < 20){
					b[1]++;
				}else if(a[i] <30){
					b[2]++;
				}else if(a[i] < 40){
					b[3]++;
				}else if(a[i] < 50){
					b[4]++;
				}else if(a[i] < 60){
					b[5]++;
				}else{
					b[6]++;
				}
			}
			for(int i = 0 ; i < 7 ; i++){
				System.out.println(b[i]);
			}
			n = scan.nextInt();
		}
	}
}

Measured memory_bytes: 254348
N,M=map(int, input().split())
#均等に配分したい
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

D=make_divisors(M)
D=sorted(D)
ans=0
for d in D:
    if M//d>=N:
        ans=d
print(ans)


Measured memory_bytes: 3188
//Daniel Grzegorzewski
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second
#define int long long

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
     ios_base::sync_with_stdio(0);
     cin.tie(0);
}

const int MOD = 998244353;
const int N = 4*(int)1e5 + 3;

int n, k, l[11], r[11], dp[N];

signed main() {
  init_ios();
  cin >> n >> k;
  for (int i = 1; i <= k; ++i)
    cin >> l[i] >> r[i];
  dp[n] = 1;
  int sum = 0;
  for (int i = n-1; i >= 1; --i) {
    for (int j = 1; j <= k; ++j) {
      sum += dp[i+l[j]]-dp[i+r[j]+1];
      sum %= MOD;
      if (sum < 0)
        sum += MOD;
    }
    dp[i] = sum;
  }
  cout<<dp[1]<<"\n";
}

Measured memory_bytes: 5212
// AtCoder Beginners Selection
// ABC176C Step
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  long height = 0;
  long max = 0;
  long sum = 0;
  
  for (int i = 0; i < N; i++){
    cin >>  height;
    if (height > max){
      max = height;
    }
    sum += max - height;
  }
  cout << sum << endl;
  return 0;
}

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

int main()
{
    int n;
    cin>>n;
    cin.ignore();//?
    while(n--){
        string s;
        getline(cin,s);
        while((s.find("Hoshino")!= -1)){
            s.replace(s.find("Hoshino"),7,"Hoshina");
            //replace(??????,??????????????°,???????????????)
        }
        cout<<s<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 1212
//#pragma GCC optimize ("O3")
//#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint(), W = getint();

	ll dp[100001] = {};
	rep(i, N) {
		int w = getint();
		int v = getint();
		for (int j = W - w; j >= 0; j--) {
			chmax(dp[j + w], dp[j] + v);
		}
	}

	printf("%lld", dp[W]);

	Would you please return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>
#include <queue>
#include <stack>

typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
#define rep_r(i,s,n)for(ll i = n;i>s;i--)
#define rep_re(i,s,n)for(ll i = n;i>=s;i--)
using namespace std;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const ll MAX_N = 100001;

ll N, K;
ll a[1111];
vector<ll> cand;

// 渡されたbitを含む部分列の個数をカウントする
ll countMask(ll a) {
	ll ret = 0;
	for (ll x : cand) {
		if ((x & a) == a) { // これ頭良い
			ret++;
		}
	}
	return ret;
}

int main() {
	// 入力
	cin >> N >> K;
	for (ll i = 0; i < N; i++) {
		cin >> a[i];
	}

	// 部分列全列挙
	for (ll i = 0; i < N; i++) {
		ll sum = 0;
		for (ll j = i; j < N; j++) {
			sum += a[j];
			cand.push_back(sum);
		}
	}

	sort(cand.begin(), cand.end());
	reverse(cand.begin(), cand.end());

	ll mask = 0; // これが答えになる。条件を満たすbitをここに付け加えてく
	for (ll i = 40; i >= 0; i--) {
		if (countMask(mask | (1LL << i)) >= K) {
			mask |= (1LL << i);
		}
	}

	cout << mask << endl;

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>


template <class T> void chmin(T&a, const T&b) { a = min(a,b); }
template <class T> void chmax(T&a, const T&b) { a = max(a,b); }

const double EPS =1e-9;
const long INF =999999999;
const long MOD =1000000007; //10^9+7
#define PI 3.14159265258979

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

int main(void){
	int X,t;
	cin>>X>>t;

	cout<<max(X-t,0)<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;
const int mod = 1e9+7;
const int nax = 2005;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint dp0[nax][nax];
mint dp1[nax][nax];

void test_case(){
	int n,m; cin >> n >>m;
	vector<int> s(n+1),t(m+1);
	for(int i = 0 ; i < n ; i++)
		cin >> s[i];
	for(int j = 0 ; j < m ; j++)
		cin >> t[j];
	dp0[0][0] = 1;
	for(int i = 0 ; i <= n ; i++){
		for(int j = 0 ; j <= m ; j++){
			dp0[i+1][j] += dp0[i][j];
			dp1[i][j] += dp0[i][j];
			dp1[i][j+1] += dp1[i][j];
			if(s[i] == t[j]){
				dp0[i+1][j+1] += dp1[i][j];
			}
		}
	}
	mint ans = dp1[n][m];
	cout<<ans.x<<"\n";
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T=1;
	//~ cin >> T;
	while(T--){
		test_case();
	}
	return 0;
}


Measured memory_bytes: 66456
n = int(input())
A = list(map(int, input().split()))
AS = sorted(list(set(A)))
n = AS[-1]
checkAS = len(AS)-1
nHalf = n/2
min = 10**10


for i in range(checkAS):
    temp = abs(AS[i]-nHalf)
    if min > temp:
        r = AS[i]
        min = temp

print(str(n) + ' ' + str(r))

Measured memory_bytes: 66348
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;
//cout << fixed << setprecision(0)

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


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        int d = Integer.parseInt(sc.next());
        int left = a + b;
        int right = c + d;
        
        if(left > right){
            System.out.println("Left");
        }else if(left == right){
            System.out.println("Balanced");
        }else if(left < right){
            System.out.println("Right");
        }
    }
}


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

int main(){
    int n,i,j;
    int count=1;
    cin >> n;

    vector<string> vec(n);

    for(i=0; i<n; i++){
        cin >> vec.at(i);
    }
    sort(vec.begin(), vec.end());
     vec.erase( unique(vec.begin(), vec.end()), vec.end() );

   
    cout << vec.size() << endl;
    return 0;
}

Measured memory_bytes: 9492
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
int main()
{
  int a, b, c, d, X, Y;
  int D, G;
  //char s[101][101]={};
  char sv[101]={};
  char ss[101]={};
//  char s_temp[101]={};
  char t[101]={};
//  char s[10000000000000000001]={};
  char s[2][100001]={};
  int len=0;
  int N, M;
//  int A[1000000001]={};
  int A[10001]={};
//  long int A[1001]={};
  int B[20000]={};
  int C[20000]={};
  int i,j,k;
  int flag=0;
  int tmp=0;
  int min=0;
  int cnt=0;
  int max=0;
//  int ans=0;
  int str_len=0;
//  char alp[26]={'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'};
  int ans[2][26]={};


  scanf("%d", &a);
  
  printf("%d\n", 1110-a);
  
  
//  printf("%d\n", (max*10)+tmp+min);
   
//   printf("%d\n",a-b+1);
  
return 0;
}


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

int main() {
	int setID = 0;
	while (true) {
		int W, N;
		if(!(cin>>W>>N)) break;
		cout << "Case " << ++setID  << ':' << endl;
		vector<int> v(N), w(N);
		for (auto i = 0; i < N; i++)
			scanf("%d,%d", &v[i], &w[i]);
		vector<vector<int>> dp(N+1, vector<int>(W+1, 0));
		for (auto i = N-1; i >= 0; i--) {
			for (auto j = W; j >= 0; j--) {
				dp[i][j] = j < w[i]
					? dp[i+1][j]
					: max(dp[i+1][j], dp[i+1][j-w[i]]+v[i]);
			}
		}
		int weight;
		for (weight = W; weight >= 0; weight--)
			if (dp[0][weight] != dp[0][W]) break;
		cout << dp[0][W] << endl << ++weight << endl;
	}
	return 0;
}

Measured memory_bytes: 5064
#include <iostream>
#include <cmath>
#include <string>

using namespace std;

#define ll long long

ll ans = 0;
string Str;

void solve(){
    int N = Str.size();
	for(int i = 0; i < (1 << (N - 1)); i++) {
		ll sm = 0;
		ll buff = Str[0] - '0';
		for( int j = 0; j < N - 1; j++) {
			if (i & (1 << j)) {
				sm += buff;
				buff = 0;
			}
			buff = buff * 10 + Str[j + 1] - '0';
		}
		sm += buff;
		ans += sm;
	}
    cout << ans << endl;
}

int main(){
    cin >> Str;
    solve();
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, m = map(int, readline().split())
h = [0] + list(map(int, readline().split()))
ab = [list(map(int, readline().split())) for _ in range(m)]
check = [True] * (n + 1)
for a, b in ab:
    if h[a] > h[b]:
        check[b] = False
    elif h[a] < h[b]:
        check[a] = False
    else:
        check[a] = False
        check[b] = False
print(check.count(True) - 1)


Measured memory_bytes: 90296
# -*- coding: utf-8 -*-

n,p = map(int,input().split())

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

def array_count(arr):
    arr_target = [[]]
    cnt = 1
    for i in range(1,len(arr)):
        if arr[i] == arr[i-1]:
            cnt += 1
        else:
            arr_target.append([arr[i-1],cnt])
            cnt = 1
    arr_target.append([arr[len(arr)-1],cnt])
    del arr_target[0]
    return arr_target

fac = factorize(p)

if len(fac) >= 1:
    arr = array_count(fac)

    ans = 1
    for i in range(len(arr)):
        if arr[i][1] >= n:
            ans *= arr[i][0] ** (arr[i][1] // n)

    print(ans)
else:
    print(1)


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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  
  for( int i = 0; i < N; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  
  int A = 0, B = 0;
  for( int j = 0; j < N; j++){
    if(j%2 == 0){
      A += vec.at(j);
    }
    else{
      B += vec.at(j);
    }
  }
  cout << A-B << endl;
  
      

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

const int INF = 1e9+5;
//素因数分解
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

const int MAX = 210000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

int main() {
    int N, M;
    COMinit();
    cin >> N >> M;
    auto vec = prime_factorize(M);
    long long res = 1;
    for (auto pa : vec) {
        int num = pa.second;
        long long tmp = COM(num+N-1, N-1);
        res = (res * tmp) % MOD;
    }
    cout << res << endl;
}

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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define per(i, b) per2(i, 0, b)
#define per2(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define ALL(c) (c).begin(), (c).end()
#define SZ(x) ((int)(x).size())

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

const double EPS = 1e-9;
const double INF = 1e10;

int main() {
    ll xs, ys, xt, yt;
    cin >> xs >> ys >> xt >> yt;
    int N;
    cin >> N;
    V<pair<pii, int>> pts(N);

    rep(i, N) {
        int x, y, r;
        cin >> x >> y >> r;
        pts[i] = mp(mp(x, y), r);
    }

    pts.eb(mp(xs, ys), 0);
    pts.eb(mp(xt, yt), 0);
    N += 2;

    auto ds = [](pii& a, pii& b) {
        return ll(a.fi - b.fi) * (a.fi - b.fi) +
               ll(a.se - b.se) * (a.se - b.se);
    };

    VV<double> mt(N, V<double>(N));
    rep(i, N) {
        rep(j, N) {
            ll d = ds(pts[i].fi, pts[j].fi);
            ll r1 = pts[i].se, r2 = pts[j].se;
            if (d > (r1 + r2) * (r1 + r2)) {
                mt[i][j] = sqrt(d + 1e-18) - r1 - r2;
            }
        }
    }

    debug(mt);

    V<double> d(N, INF);
    int s = N - 2, t = N - 1;
    d[s] = 0.0;
    using Data = pair<double, int>;
    priority_queue<Data, V<Data>, greater<Data>> que;
    que.push(mp(0.0, s));
    V<bool> used(N);

    while (!que.empty()) {
        auto t = que.top();
        que.pop();
        int v = t.se;
        if (used[v]) continue;
        used[v] = true;
        debug(v, d[v]);
        rep(i, N) {
            if (d[i] > d[v] + mt[v][i] + EPS) {
                d[i] = d[v] + mt[v][i];
                que.push(mp(d[i], i));
            }
        }
    }
    printf("%.10f\n", d[t]);
    return 0;
}

Measured memory_bytes: 13936
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args){
		FastScanner sc = new FastScanner();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		if(b <= c || a >= d){
			System.out.println(0);
		}else{
			System.out.println(Math.min(b, d) -  Math.max(a, c));
		}

	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
}

Measured memory_bytes: 21076
b = input()
ans = ""

for i in range(len(b)):
    if b[i] == "A" or b[i] == "T" or b[i] == "C" or b[i] == "G":
        ans += "1"
    else:
        ans += "0"
#print(ans)

ls = ans.split("0")
#print(ls)
print(len(max(ls)))


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

int main(){
    int k, t;
    cin >> k >> t;

    int a[t];
    priority_queue<pair<int, int> > q;
    for(int i = 0; i < t; i++){
        cin >> a[i];
        q.push(make_pair(a[i], i));
    }

    int cou = 0;
    int flag = -1;
    while(!q.empty()){
        pair<int, int> l = q.top();
        q.pop();
        if(flag != l.second){
            flag = l.second;
            l.first--;
            if(l.first != 0){
                q.push(l);
            }
        }else{
            if(q.empty()){
                cou += l.first;
            }else{
                pair<int, int> m = q.top();
                q.pop();
                flag = m.second;
                m.first--;
                q.push(l);
                if(m.first != 0){
                    q.push(m);
                }
            }
        }
    }

    cout << cou << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
#include <complex>
using namespace std;

const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef pair<int,int> P;
struct edge{int to,cost;};

int N;
vector<vector<edge> > g;
vector<bool> is_leaf;

int dfs(int v, int prev){
    int cost = 0;
    for(int i=0;i<g[v].size();i++){
        int to = g[v][i].to;
        if(is_leaf[to] || to==prev) continue;
        cost = max(cost, g[v][i].cost + dfs(to, v));
    }
    return cost;
}

int main(){
    while(1){
        scanf("%d",&N);
        if(!N)break;

        g.assign(N, vector<edge>());
        for(int i=0;i<N-1;i++){
            int a, b, t;
            scanf("%d%d%d",&a,&b,&t);
            a--;b--;
            g[a].push_back((edge){b,t});
            g[b].push_back((edge){a,t});
        }

        is_leaf.assign(N, false);
        for(int i=0;i<N;i++){
            if(g[i].size()==1) is_leaf[i] = true;
        }
        is_leaf[0] = false;

        int all_path_twice = 0;
        for(int i=0;i<N;i++){
            if(is_leaf[i]) continue;
            for(int j=0;j<g[i].size();j++){
                if(is_leaf[g[i][j].to]) continue;
                all_path_twice += g[i][j].cost;
            }
        }
        int longest_path = dfs(0, -1);

        cout << all_path_twice-longest_path << endl;
    }

    return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
#define N_MAX 100000
using namespace std;

int ran[N_MAX], parent[N_MAX];

void initialize(int n) {
    for (int i = 0; i < n; i++) {
        ran[i] = 0;
        parent[i] = i;
    }
}

int find(int x) {
    if (x == parent[x])
        return x;
    return parent[x] = find(parent[x]);
}

void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y)
        return;
    if (ran[x] > ran[y]) {
        parent[y] = x;
    } else {
        parent[x] = y;
        if (ran[x] == ran[y])
            ran[y]++;
    }
}

int main() {
    int n, m;
    cin >> n >> m;
    initialize(n);
    for (int i = 0; i < m; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        unite(x - 1, y - 1);
    }
    unordered_set<int> st;
    for (int i = 0; i < n; i++) {
        st.insert(find(i));
    }
    cout << st.size() << endl;
    return 0;
}


Measured memory_bytes: 5156
/*
this problem is a piece of garbage
*/
#include<bits/stdc++.h>

using namespace std;

int N, a[100009];

void Fail ()
{
    printf ("-1\n");
    exit (0);
}

bool check (long long val)
{
    for (int i=N; i>=1; i--)
        val -= val % a[i];
    return (val == 2);
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d", &N);
for (int i=N; i>=1; i--)
    scanf ("%d", &a[i]);
long long sml = 2, bg = 2;
for (int i=1; i<N; i++)
{
    if (sml % a[i] != 0 || bg % a[i] != 0 || sml > bg) Fail ();
    ///sml + at most a[i] - 1 divisible by a[i]
    long long st = (sml / a[i + 1]) * a[i + 1], dr = ((bg + a[i] - 1) / a[i + 1]) * a[i + 1];
    if (dr < sml) Fail ();
    if (st < sml) st += a[i + 1];
    //st = min (st, bg);
    sml = st, bg = dr;
}
if (sml > bg) Fail ();
if (!check (sml)) Fail ();
printf ("%lld %lld\n", sml, bg + a[N] - 1);

return 0;
}


Measured memory_bytes: 640
#!/usr/bin/env python3

import sys
# import math
# from string import ascii_lowercase, ascii_upper_case, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)


def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1               # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    n, k = mi()
    dislike = input().split()

    start = n
    while True:
        # print(start)
        for digit in str(start):
            if digit in dislike:
                start += 1
                break
        else:
            print(start)
            exit()


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {
    ll K;
    cin >> K;
    ll k = K / 50;
    ll l = K % 50;
    vector<ll> v(50, 100 - l + k);
    REP(i, 50 - l){
        v[i] -= 51;
    }
    cout << 50 << endl;
    REP(i, 50) cout << v[i] << " ";
    cout << endl;

    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;


int main()
{
  int N,K;
  cin >> N >> K;
  string S;
  cin >> S;
  vector<int> v;
  if(S[0]=='1')
    v.push_back(1);
  else
    v.push_back(-1);

  for( int i=1;i<N;i++ )
    {
    if(S[i]=='1')
      {
	if(*(v.end()-1)>0)
	  *(v.end()-1) = *(v.end()-1)+1;
	else
	  v.push_back(1);
      }
    else
      {
	if(*(v.end()-1)<0)
	  *(v.end()-1) = *(v.end()-1)-1;	  
	else
	  v.push_back(-1);	  
      }
    }

  if(v[0] < 0)
    v.insert(v.begin(), 0);

  
  for( int i=0;i<v.size();i++)
    {
      v[i] = abs(v[i]);
    }

  int acc = 0;
  vector<int>f;
  for( int i=0;i<v.size();i++)
    {
      f.push_back(acc);      
      acc += v[i];
    }
  f.push_back(acc);
  int ans = 0;
  for( int i=0;i<v.size();i+=2 )
    {
      //      cout << min(i+2*K+1,(int)v.size()) << " " << f[i] << endl;
      ans = max(ans, f[min(i+2*K+1,(int)v.size())]-f[i]);
    }
  
  cout << ans << endl;
}
  


Measured memory_bytes: 1528
#include<stdio.h>

int main(){
  int i,n,v[32],c[32],ans=0;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&v[i]);
  }
  for(i=1;i<=n;i++){
    scanf("%d",&c[i]);
  }
  for(i=1;i<=n;i++){
    if(v[i]-c[i]>0){
      ans+=(v[i]-c[i]);
    }
  }
  printf("%d\n",ans);
  return 0;
}

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

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

 int n,m,a[200],sum=0;
 cin >> n >> m;
 for(int i=1; i<=n; i++){
 	cin >> a[i];
 	sum += a[i];
 }

 sort(a+1, a+n+1, greater<int>());

 bool ok = true;
 for(int i=1; i<=m; i++){
 	if(a[i]*4*m < sum){
 		ok = false;
 		break;
 	}
 }

 cout << (ok ? "Yes\n" : "No\n");

}


Measured memory_bytes: 256
s = input()
a, b, c, d = int(s[0]), int(s[1]), int(s[2]), int(s[3])
if a+b+c+d == 7:
  print(str(a)+'+'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
elif a+b+c-d == 7:
  print(str(a)+'+'+str(b)+'+'+str(c)+'-'+str(d)+'=7')
elif a+b-c+d == 7:
  print(str(a)+'+'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
elif a+b-c-d == 7:
  print(str(a)+'+'+str(b)+'-'+str(c)+'-'+str(d)+'=7')
elif a-b+c+d == 7:
  print(str(a)+'-'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
elif a-b+c-d == 7:
  print(str(a)+'-'+str(b)+'+'+str(c)+'-'+str(d)+'=7')
elif a-b-c+d == 7:
  print(str(a)+'-'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
elif a-b-c-d == 7:
  print(str(a)+'-'+str(b)+'-'+str(c)+'-'+str(d)+'=7')


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

template<typename integer>
integer __lcm(integer a, integer b) {
  return (a * b) / __gcd(a, b);
}

int main() {
  int n, a, b, c, d;
  cin >> n;

  a = n / 1000;
  n -= a * 1000;

  b = n / 100;
  n -= b * 100;

  c = n / 10;
  n -= c * 10;

  d = n;

  rep (i, 2) {
    rep (j, 2) {
      rep (k, 2) {
        int ans = a;
        if (i == 0) {
          ans += b;
        } else {
          ans -= b;
        }

        if (j == 0) {
          ans += c;
        } else {
          ans -= c;
        }

        if (k == 0) {
          ans += d;
        } else {
          ans -= d;
        }

        if (ans == 7) {
          string op1, op2, op3;
          if (i == 0) op1 = "+";
          else op1 = "-";

          if (j == 0) op2 = "+";
          else op2 = "-";

          if (k == 0) op3 = "+";
          else op3 = "-";

          cout << a << op1 << b << op2 << c << op3 << d << "=7";
          return 0;
        }
      }
    }
  }

  return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main{
	
	int [] vx = {0,0,1,0,-1, 1, 1, -1, -1};
	int [] vy = {0,1,0,-1,0, 1, -1, -1, 1};
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		int dataset = sc.nextInt();
		int n = 9;
		boolean first = true;
		while(dataset-- > 0){
			if(first){
				first = false;
			}
			else{
				System.out.println();
			}
			int [][] data = new int[n][n];
			for(int i = 0; i < n; i++){
				for(int j = 0; j < n; j++){
					data[i][j] = sc.nextInt();
				}
			}
			boolean [][] illegal = new boolean[n][n];
			//よこ
			for(int i = 0; i < n; i++){
				int [] freq = new int[10];
				for(int j = 0; j < n; j++){
					int nownum = data[i][j];
					freq[nownum]++; 
				}
				for(int j = 1; j <= 9; j++){
					if(freq[j] >= 2){
						for(int k = 0; k < n; k++){
							if(data[i][k] == j){
								illegal[i][k] = true;
							}
						}
					}
				}
			}
			
			
			//たて
			for(int w = 0; w < n; w++){
				int [] freq = new int[10];
				for(int h = 0; h < n; h++){
					freq[data[h][w]]++;
				}
				for(int j = 1; j <= 9; j++){
					if(freq[j] >= 2){
						for(int hh = 0; hh < n; hh++){
							if(data[hh][w] == j){
								illegal[hh][w] = true;
							}
						}
					}
				}
			}
			
			
			//エリア
			for(int y = 1; y < n; y += 3){
				for(int x = 1; x < n; x+= 3){
					int [] freq = new int[10];
					for(int i = 0; i < vx.length; i++){
						int xx = x + vx[i];
						int yy = y + vy[i];
						freq[data[yy][xx]]++;
					}
					
					for(int j = 1; j <= 9; j++){
						if(freq[j] >= 2){
							for(int k = 0; k < vx.length; k++){
								int xx = x + vx[k];
								int yy = y + vy[k];
								if(data[yy][xx] == j){
									illegal[yy][xx] = true;
								}
							}
						}
					}
				}
			}
			
			
			//print
			StringBuilder ans = new StringBuilder();
			for(int i = 0; i < n; i++){
				for(int j = 0; j < n; j++){
					if(illegal[i][j]){
						ans.append("*");
					}
					else{
						ans.append(" ");
					}
					ans.append(data[i][j]);
				}
				ans.append("\n");
			}
			System.out.print(ans.toString());
		}
	}
	private void debug(Object... o) { System.out.println("debug = " + Arrays.deepToString(o)); }

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

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

using namespace std;

int main(void){
  
  int p1,p2,p3,j1,j2,P;
  
  cin >> p1 >> p2 >> p3 >> j1 >> j2;

  if( p1 >= p2 && p2 >= p3 ) P = p3; 
  else if( p1 >= p3 && p3 >= p2 ) P = p2; 
  else if( p2 >= p1 && p1 >= p3 ) P = p3; 
  else if( p2 >= p3 && p3 >= p1 ) P = p1;
  else if( p3 >= p1 && p1 >= p2 ) P = p2;
  else if( p3 >= p2 && p2 >= p1 ) P = p1;


  int J = min(j1,j2);

  cout << P + J - 50 << endl;

  return 0;
}

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

bool try_sw(bool t0, bool t1, int N, const vector<bool> &ox){
    vector<bool> sws(N + 1, false);
    string SW = "SW";
    sws[0] = t0;
    sws[1] = t1;
    for (int i = 1; i < N; ++i) sws[i + 1] = ox[i] xor (sws[i] xor sws[i - 1]);
    if ((sws[0] == sws[N]) and (sws[N - 1] == ox[0] xor (t0 xor t1))){
        for (int i = 0; i != N; ++i) cout << SW[int(sws[i])];
        cout << endl;
        return true;
    }
    return false;
}

int main() {
    int N;
    string S;
    cin >> N;
    cin >> S;
    vector<bool> ox(N, false);
    for (int i = 0; i < N; ++i) ox[i] = (S[i] == 'x');
    for (int i = 0; i != 4; ++i){
        bool t0 = i / 2 > 0;
        bool t1 = i % 2 > 0;
        if (try_sw(t0, t1, N, ox)) return 0;
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 512
size = int(input())
l = []

for i in map(int, input().split()):
    l.append(i)

sort_cnt = 0
reversed_cnt = 0

for j in range(size - 1,0,-1):
    for i in range(size - 1,sort_cnt,-1):
        tmp = l[i-1]
        if l[i] < l[i-1]:
            l[i-1] = l[i]
            l[i] = tmp
            reversed_cnt += 1
    sort_cnt += 1

print(' '.join(map(str,l)))
print(reversed_cnt)


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  rep(i, N) cin >> A.at(i);
  for(int i=K; i<N; i++){
    if(A.at(i-K)<A.at(i)) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 4048
c = []

3.times do
    c << gets.chomp.split(" ").map(&:to_i)
end

(0..100).each do |a1|
    (0..100).each do |a2|
        (0..100).each do |a3|
            flags = []
            3.times do |i|
                flag1 = c[i][0] - a1
                flag2 = c[i][1] - a2
                flag3 = c[i][2] - a3
                if flag1 == flag2 && flag2 == flag3 && flag3 == flag1 then
                    flags << true
                else
                    flags << false
                end
            end
            if flags.all?{|v| v} then
                puts "Yes"
                exit
            end
        end
    end
end

puts "No"

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


int main() {
	int n;
	cin >> n;
	vector<string>blue(n);
	for (int i = 0;i < n;++i) {
		cin >> blue[i];
	}
	int m;
	cin >> m;
	vector<string>red(m);
	for (int i = 0;i < m;++i) {
		cin >> red[i];
	}
	int ans = 0;
	auto calc = [&](string s) {
		int buf = 0;
		for (string t : blue) {
			if (t == s)buf++;
		}
		for (string t : red) {
			if (t == s)buf--;
		}
		return buf;
	};
	for (string t : blue) {
		ans = max(ans, calc(t));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256