akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;

const int N = 1000;
long long a[N+2], b[N+2], c[N+2];

bool isOdd(long long a, long long b, long long c){
    if(a%2 == 1 || b%2 == 1 || c%2 == 1){
        return true;
    }
    else{
        return false;
    }
}

int main(){

    long long a0, b0, c0;
    cin >> a0 >> b0 >> c0;

    if(isOdd(a0, b0, c0)){
        cout << 0 << endl;
    }
    else{
        a[0] = a0; 
        b[0] = b0;
        c[0] = c0;
        a[1] = (b0 + c0)/2;
        b[1] = (a0 + c0)/2;
        c[1] = (b0 + c0)/2;

        vector<long long> va, vb, vc;
        va.push_back(a0); va.push_back(a[1]);
        vb.push_back(b0); vb.push_back(b[1]);
        vc.push_back(c0); vc.push_back(c[1]);

        bool endflag = false;

        if(isOdd(a[1], b[1], c[1])){
            cout << 1 << endl;
        }
        else if(a0 == a[1] && b0 == b[1] && c0 == c[1]){
            cout << -1 << endl;
        }
        else{
            for(int i=2; i<N; i++){
                a[i] = (a[i-1] + a[i-2])/2;
                b[i] = (b[i-1] + b[i-2])/2;
                c[i] = (c[i-1] + c[i-2])/2;
                if(isOdd(a[i], b[i], c[i])){
                    cout << i << endl;
                    break;
                }
                for(int j=0; j<i; j++){
                    if(a[i] == va[j] && b[i] == vb[j] && c[i] == vc[j]){
                        cout << -1 << endl;
                        endflag = true;
                        break;
                    }
                }
                if(endflag){
                    break;
                }
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
s = gets.chomp.chars.sort
t = gets.chomp.chars.sort.reverse

[s.size, t.size].min.times do |i|
  next if s[i] == t[i]
  if s[i] < t[i]
    puts "Yes"
  else
    puts "No"
  end
  exit
end

puts s.size < t.size ? "Yes" : "No"

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589;

string s;

bool judge(string t){
  int u = t.size();
  string p = t.substr(0,u/2);
  string q = t.substr(u/2);
  if(p==q) return true;
  return false;
}

int main(){
  cin >> s;
  while(true){
    int u = s.size();
    s.erase(u-2);
    if(judge(s)) break;
  }
  
  cout << s.size()<<endl;
}
  

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

vector<ll> as;

ll solve(ll X, ll S) {
    ll D = (S - X) / 2; // = a & b

    ll cand = D;
    for (int bit = 41; bit >= 0; bit--) {
        ll x = X & (1LL << bit);
        if (x == 0) continue;
        if ((cand | x) <= as[0]) {
            cand |= x;
        }
    }

    // check answer
    ll a = cand;
    ll b = S - cand;
    // printf("a: %lld, b: %lld\n", a, b);
    if (a > as[0]) {
        return -1;
    }
    if (b < 0) {
        return -1;
    }
    if ((a ^ b) != X) {
        return -1;
    }

    return cand;
}

// ref. https://img.atcoder.jp/abc172/editorial.pdf
int main(void) {
    int N;
    cin >> N;

    as.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> as[i];
    }

    ll X = 0;
    for (int i = 2; i < N; i++) {
        X ^= as[i];
    }

    ll S = as[0] + as[1];

    ll ans = solve(X, S);

    if (ans <= 0) {
        cout << -1 << endl;
    } else {
        cout << as[0] - ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3604
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line: Vec<u32> = read_as_vec();
    let (n, m) = (line[0], line[1]);

    if n == 1{
        println!("{}", m);
        return;
    }

    for i in (1.. cmp::max((m as f64).sqrt() as u32, m/n)+1).rev(){
        if m/n >= i && m % i == 0{
            println!("{}", i);
            return;
        }
    }


}


Measured memory_bytes: 4352
#include <iostream>

int main()
{
	int x, y;
	std::cin >> x >> y;

	while (x != 0 || y != 0) {
		if (x < y) {
			std::cout << x << " " << y << std::endl;
		}
		else {
			std::cout << y << " " << x << std::endl;
		}
		std::cin >> x >> y;
	}
}

Measured memory_bytes: 1160
# coding: utf-8
# Your code here!
import statistics

N=int(input())
S=list(map(int,input().split()))

S1=[]
for i in range(N):
    S1.append(S[i]-i)
S1.sort()
chuouchi=statistics.median_high(S1)
chuouchi2=statistics.median_low(S1)
chuouchi3=statistics.median(S1)
ans=10**20
ansj=0
A=chuouchi-4
B=chuouchi+4
C=chuouchi2-4
D=chuouchi2+4
E=int(chuouchi3)-4
F=int(chuouchi3)+4
for i in range(A,B):
    goukei=0
    for j in range(N):
        goukei+=abs(S[j]-(i+j+1))
        
    if ans>goukei:
        ans=goukei
        
for i in range(C,D):
    goukei=0
    for j in range(N):
        goukei+=abs(S[j]-(i+j+1))
        
    if ans>goukei:
        ans=goukei

for i in range(E,F):
    goukei=0
    for j in range(N):
        goukei+=abs(S[j]-(i+j+1))
        
    if ans>goukei:
        ans=goukei        
        
print(ans)




Measured memory_bytes: 27248
#include<cstdio>
using namespace std;
const int MAX = 100000, mod = 1e9+7;
int A[MAX];
int main(){
    int n;
    long long sum = 1;
    scanf("%d", &n);
    A[0] = 3;
    
    for (int i = 0; i < n; i++)
    {
        int a;
        scanf("%d", &a);
        sum = (sum * A[a]) % mod;
        A[a]--;
        A[a+1]++;
    }
    printf("%ld", sum);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<55;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;

int main(){
	cin>>n;
	int res=0;
	for(int i=1;i<n-1;i++) if(i<n-i) res++;
	cout<<res<<endl;
} 

Measured memory_bytes: 256
def main():
    K, A, B = map(int, input().split())
    if K <= A: return 1
    if B >= A: return -1
    d = A-B
    K -= A
    if(K % d == 0): return 2 * (K//d) + 1
    return (K // d + 1) * 2 + 1

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3064
fun main(arr:Array<String>) {
    var abc = readLine()!!.split(" ").map { it.toLong() }
    val log = mutableMapOf<Long, MutableMap<Long, MutableMap<Long, Boolean>>>()
    var ans = 0
    while (abc.all { it%2 == 0L }) {
        if(!log.containsKey(abc[0])) {
            log[abc[0]] = mutableMapOf()
        }
        if(!log[abc[0]]!!.containsKey(abc[1])) {
            log[abc[0]]!![abc[1]] = mutableMapOf()
        }
        if(log[abc[0]]!![abc[1]]!!.containsKey(abc[2])) {
            println(-1)
            return
        }
        log[abc[0]]!![abc[1]]!![abc[2]] = true
        val newAbc = (1..3).map { 0L }.toMutableList()
        newAbc[0] = abc[1]/2 + abc[2]/2
        newAbc[1] = abc[0]/2 + abc[2]/2
        newAbc[2] = abc[0]/2 + abc[1]/2
        abc = newAbc
        ans++
    }
    println(ans)
}


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=1e9+7;

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

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

int main(){
    int N, W; cin >> N >> W;
    vi v(N), w(N);
    for(int i=0; i<N; i++){
        cin >> v[i] >> w[i];
    }

    vii dp(N+1, vi(W+1, 0));
    for(int i=0; i<N; i++){
        for(int j=0; j<=W; j++){
            if(w[i] <= j){
                chmax(dp[i+1][j], dp[i][j-w[i]]+v[i]);
            }
            chmax(dp[i+1][j], dp[i][j]);
        }
    }
    cout << dp[N][W] << endl;
    return 0;
}


Measured memory_bytes: 6860
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)
	m := make(map[int]int)
	o := 0
	for i := 0; i < n; i++ {
		var a int
		fmt.Scan(&a)
		r := a / 400
		if a >= 3200 {
			o++
		} else {
			m[r]++
		}
	}

	c := len(m)
	min := 0.0
	if o > 0 {
		min = 1.0
	}
	min = math.Max(min, float64(c))
	fmt.Println(int(min), c+o)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define forn(i,n) for(int i=0;i<n;i++)
#define fore(i,n) for(int i=1;i<=n;i++)
#define forp(i,n) for(int i=n;i>0;i--)
#define fort(i,n) for(int i=n;i>=0;i--)
#define forn2(i,a,n) for(int i=a;i<n;i++)
#define fore2(i,a,n) for(int i=a;i<=n;i++)
#define forp2(i,a,n) for(int i=n;i>a;i--)
#define fort2(i,a,n) for(int i=n;i>=a;i--)
#define ll long long
int main()
{
	ios_base::sync_with_stdio(false);
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll ans=max(max(a*c,b*d),max(a*d,b*c));
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3604
#include<stdio.h>

char map[14][12];

void island(int h,int w){
  int i;
  int x[] = {1,0,-1,0};
  int y[] = {0,1,0,-1};

  map[h][w] = '0';
  for(i=0;i<4;i++){
    if(h+y[i]>=0 && h+y[i]<12 && w+x[i]>=0 && w+x[i]<12){
      if(map[h+y[i]][w+x[i]] == '1')island(h+y[i],w+x[i]);
    }
  }
}

int main(void){
  int i,j;
  int count;

  while(1){
    if(fscanf(stdin," %s ",map[0])==EOF)break;
    for(i=1;i<12;i++){
      fscanf(stdin," %s ",map[i]);
    }  
    
    count = 0;
    for(i=0;i<12;i++){
      for(j=0;j<12;j++){
	if(map[i][j] == '1'){
	  island(i,j);
	  count++;
	}
      }
    }
    
    printf("%d\n",count);
  }

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
map<char, int> gensi;
int NOT[3] = {2, 1, 0};
int AND[3][3] = {{0, 0, 0},
	       {0, 1, 1},
	       {0, 1, 2},};
int OR[3][3]  = {{0, 1, 2},
	       {1, 1, 2},
	       {2, 2, 2},};
int formular(string&, int&);
int factor(string&, int&);
int term(string&, int&);

int formular(string& str, int& p){
  int res = term(str, p);
  while(str[p] == '*' || str[p] == '+'){
    if(str[p] == '*'){
      p++;
      return(AND[res][term(str, p)]);
    }else{
      p++;
      return(OR[res][term(str, p)]);
    }
  }
  return res;
}

int term(string& str, int& p){
  int res;
  while(str[p] == '('){
    while(str[p] != ')'){
      p++;
      res = formular(str, p);
      p++;
      return res;
    }
  }
  while(str[p] == '-'){
    p++;
    return(NOT[term(str, p)]);
  }
  while(isdigit(str[p])){
    res = str[p] - '0';
    p++;
    return res;
  }
  while(str[p] == 'P' || str[p] == 'Q' || str[p] == 'R'){
    res = gensi[str[p]];
    p++;
    return res;
  }
}

int main(void){
  string str;
  while(cin >> str, str != "."){
    int ans = 0;
    for(gensi['P'] = 0; gensi['P'] < 3; gensi['P']++){
      for(gensi['Q'] = 0; gensi['Q'] < 3; gensi['Q']++){
        for(gensi['R'] = 0; gensi['R'] < 3; gensi['R']++){
          int p = 0;
          if(formular(str, p) == 2){
            ans++;
          }
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin() , v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)


int main(){
  string s, t; cin >> s;
  int n = s.size() - 1;
  for(int mask = 0; mask < (1 << n); mask++){
    int sum = s[0] - '0';
    t = s[0];
    int a;
    rep(i, n){
      a = s[i + 1] - '0';
      if(mask & (1<<i)){
        sum += a;
        t = t + '+' + s[i + 1];
      }else{
        sum -= a;
        t = t + '-' + s[i + 1];
      }
    }
    if(sum == 7) break;
  }
  cout << t << "=7" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  const int N_RANK=5;
  const char rank[]="FDCBA";
  const int border[N_RANK+1]={0,30,50,65,80,101};
  int i,m,f,r;
  while(1){
    scanf("%d %d %d",&m,&f,&r);
    if(m==-1&&f==-1&&r==-1)break;
    else if(m==-1||f==-1){
      printf("%c\n",rank[0]);
      continue;
    }
    for(i=0;i<N_RANK;i++){
      if((m+f)>=border[i]&&(m+f)<border[i+1]){
        if(i==1&&r>=50){
          printf("%c\n",rank[i+1]);
          break;
        }
        else printf("%c\n",rank[i]);
      }
    }
  }
  return 0;
}

Measured memory_bytes: 2756
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <climits>
#include <map>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <bits/stdc++.h>

using namespace std;


const int INF=1e9 + 5;
int main(){
	cin.tie(0);
	int n;
	cin>>n;
	int k;
	cin>>k;
	vector<int>h(n);
	for(int i=0;i<n;i++){
		cin>>h[i];
	}
	vector<int>dp(n,INF);
	dp[0]=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<=i+k;j++){
			if(j<n){
				dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
			}
		}
	}
	printf("%d",dp[n-1]);
	return 0;
}


Measured memory_bytes: 3968
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }


int n;
ll c;
vll val, pos;

typedef pair<int, ll> P;
vector<P> toleft, toright;

void init()
{
	cin >> n >> c;

	val.resize(n + 1, 0);
	pos.resize(n + 1, 0);
	REP1C(i, n) { cin >> pos[i] >> val[i]; }

	toleft.resize(n + 1);
	toright.resize(n + 1);
	toright[0] = toleft[0] = P(0, 0);
}

int main()
{
	init();
	ll best, tmp;

	best = tmp = 0;
	REP1C(i, n)
	{
		tmp += val[i];
		if (chmax(best, tmp - pos[i]))
			toright[i] = P(i, best);
		else
			toright[i] = toright[i - 1];
	}

	best = tmp = 0;
	for (int i = n; i >= 1; --i)
	{
		tmp += val[i];
		if (chmax(best, tmp - 2 * (c - pos[i])))
			toleft[i] = P(i, best);
		else
		{
			if (i == n)
				toleft[i] = P(0, 0);
			else
				toleft[i] = toleft[i + 1];
		}
	}

	ll ans = 0;
	for (int i = 1; i <= n; i++)
	{
		chmax(ans, toright[i].second);
		if (toright[i].first != n)
			chmax(ans, toright[i].second + toleft[toright[i].first + 1].second);
	}

	best = tmp = 0;
	REP1C(i, n)
	{
		tmp += val[i];
		if (chmax(best, tmp - 2 * pos[i]))
			toright[i] = P(i, best);
		else
			toright[i] = toright[i - 1];
	}

	best = tmp = 0;
	for (int i = n; i >= 1; --i)
	{
		tmp += val[i];
		if (chmax(best, tmp - (c - pos[i])))
			toleft[i] = P(i, best);
		else
		{
			if (i == n)
				toleft[i] = P(0, 0);
			else
				toleft[i] = toleft[i + 1];
		}
	}

	for (int i = 1; i <= n; i++)
	{
		chmax(ans, toleft[i].second);
		if (toleft[i].first != 0)
			chmax(ans, toleft[i].second + toright[toleft[i].first - 1].second);
	}

	cout << ans << endl;
}


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

#define VIC ios::sync_with_stdio(0);cin.tie(0);ios_base::sync_with_stdio(0);
#define wtf(s) freopen((s), "w", stdout)
#define rff(s) freopen((s), "r", stdin)
#define pi (2 * acos(0))
typedef long double ld;
typedef long long ll;
typedef complex<ld> point;
#define endl '\n'
#define matrix vector<vector<ll>>
#define EPS 1e-9
#define X real()
#define Y imag()
#define vec(a, b) ((b) - (a))
#define dot(a, b) ((conj(a) * (b)).real())
#define cross(a, b) ((conj(a) *(b)).imag())
#define lengthsqr(v) (dot(v, v))
#define length(v) ((ld)hypot((v).Y, (v).X))
#define same(a, b) (lengthsqr(vec(a, b)) < EPS)

const int N = 2e5 + 5, inf = 2e9;
const ll mod = 1e9 + 7;

int a[N];

int main()
{
    VIC
    int n, ans = 0, k, x;
    cin >> n >> k;
    set<int> s;
    for (int i = 0; i < n; i++)
        cin >> x,
        s.insert(x),
        a[x]++;
    sort(a, a + n + 1);
    int c = 0;
    for (int i = 0; i < n && c < (int)s.size() - k; i++)
        ans += a[i],
        c += (a[i] != 0);
    cout << ans;
    return 0;
}


Measured memory_bytes: 10368
#include "bits/stdc++.h"
using namespace std;

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

int h, w, n;
using P = pair<int, int>;

int main() {
    cin >> h >> w >> n;
    
    map<P, int> mp;
    rep(k, n) {
        int x, y;
        scanf("%d%d", &y, &x);
        x--; y--;
        FOR(dy, max(0, y - 2), min(h - 3, y) + 1) {
            FOR(dx, max(0, x - 2), min(w - 3, x) + 1) {
                mp[P(dy, dx)]++;
            }
        }
    }

    long long res[10] = {0};
    for (auto&& p : mp) {
        res[p.second]++;
        res[0]++;
    }

    res[0] = 1LL * (h - 2)*(w - 2) - res[0];
    for (auto&& i : res) {
        cout << i << endl;
    }


    return 0;
}

Measured memory_bytes: 56448
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <limits>
#include <map>

using namespace std;

int main(){
    long N;
    cin>>N;
    vector<int> a(N);
    a[0]=1e5+1;
    for(int i=0 ;i<N-1;i++){
       int B;cin>>B;
       if(a[i]>B) a[i]=B;
       a[i+1]=B;
    }
    long sum=0;
    for(auto & e:a){
        sum+=e;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main() 
{
	int N;
	cin >> N;
	int ans = 0;
	map<int,int> m;
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		m[A]++;
		if (m[A] % 2 == 1) ans++;
		else ans--;
	}
	cout << ans << endl;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int read() {
	int x=0; char ch;
	while(!isdigit(ch)) ch=getchar();
	while(isdigit(ch)) x=(x<<3)+(x<<1)+(ch^48), ch=getchar();
	return x;
}
int main() {
	int a, b;
	cin>>a>>b;
	if(a*500>=b) cout<<"Yes";
	else cout<<"No";
}


Measured memory_bytes: 256
import math
A,B,C,D = map(int,input().split())
f1 = (A-1)-((A-1)//C+(A-1)//D-(A-1)//(C*D//math.gcd(C,D)))
f2 = (B)-((B)//C+(B)//D-(B)//(C*D//math.gcd(C,D)))
print(f2-f1)

Measured memory_bytes: 9120
// C - Candies
// https://atcoder.jp/contests/abc087/tasks/arc090_a
#include <bits/stdc++.h>
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007      //10^9+7
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define rt sqrt
#define pb push_back
#define eb emplace_back
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using P = pair<lli, lli>;
// vector<P> vp;
// vp.emplace_back(a[i], b[i]);
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, k, n, w, count = 0;
  lli ans = 0;
  string s, t;
  cin >> n;
  vlli d(n + 1, 0), e(n + 1, 0), f(2 * n);
  rep(i, 0, n)
  {
    cin >> a;
    d[i + 1] = d[i] + a;
  }
  rep(i, 0, n)
  {
    cin >> b;
    e[i + 1] = e[i] + b;
  }
  repe(i, 1, n)
  {
    ans = max(ans, d[i] + (e[n] - e[i - 1]));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s1=scan.nextLine();
		String t="";
		for(int i=0;i<s1.length()-1;i++) {
			if(s1.charAt(i)==' ') {
				t+=s1.charAt(i+1);
			}
		}
		System.out.println(s1.toUpperCase().charAt(0)+""+t.toUpperCase());
	}

}


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

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n; cin >> n;
	int a[n], answer = 0;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		if (a[i] != i + 1)
		{
			answer++;
		}
	}
	if (answer == 0 || answer == 2)
	{
		cout << "YES" << endl;
		/* code */
	}
	else
	{
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 3644
/*
	##############################
	## Author: Pratyush Gaurav ###
	## College: NIT ROURKELA #####
	##############################
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long/*--------------------*/lli;
typedef long double/*------------------*/ld;
typedef pair<lli, lli >/*--------------*/plli;
typedef vector<lli>/*------------------*/vlli;
typedef vector<plli >/*----------------*/vplli;

#define rep(i,a)/*---------------------*/for(i = 0 ; i < a ; i++)
#define repr(i,a)/*--------------------*/for(i = a ; i >= 0 ; i--)
#define REP(i,a,b)/*-------------------*/for(i = a ; i <= b ; i++)
#define REPR(i,a,b)/*------------------*/for(i = a ; i >= b ; i--)

#define scan(N)/*----------------------*/scanf("%lld",&N)
#define print(N)/*---------------------*/printf("%lld",N)
#define scan2(N1,N2)/*-----------------*/scanf("%lld %lld",&N1,&N2)
#define print2(N1,N2)/*----------------*/printf("%lld %lld",N1,N2)
#define scan3(N1,N2,N3)/*--------------*/scanf("%lld %lld %lld",&N1,&N2,&N3)
#define print3(N1,N2,N3)/*-------------*/printf("%lld %lld %lld",N1,N2,N3)

#define mem(a,b)/*---------------------*/memset(a,b,sizeof(a))
#define opt/*--------------------------*/ios_base::sync_with_stdio(false);cin.tie(NULL);
#define gcd(a, b)/*--------------------*/__gcd(a, b)
#define lcm(a, b)/*--------------------*/((a)*((b)/gcd(a,b)))
#define sqr(x)/*-----------------------*/(x)*(x)
#define all(a)/*-----------------------*/a.begin(),a.end()
#define makepair/*---------------------*/make_pair
#define pushback/*---------------------*/push_back

#define endl/*-------------------------*/'\n'
#define inf/*--------------------------*/(lli)2000000000000
#define MOD/*--------------------------*/(lli)1000000007
#define MAXN/*-------------------------*/100005

template<class T> bool is_prime(T n)
{
	if((n%2 == 0 and n > 2) or n < 2 )
		return false;
	for(T i = 3; i*i <= n ; i += 2)
	{
		if( n % i == 0)
			return false;
	}
	return true;
}
lli power(lli a,lli b)
{
    lli value;
    if(!b)
    	return 1;
    else if(b%2==0)
    {
        value = power(a,b/2)%MOD;
        return (value * value)%MOD;
    }
    else
    {
        value = power(a,b/2)%MOD;
        return ((a*value)%MOD*(value))%MOD;
    }
}

int main()
{
	opt;
	lli n,y,i,j,k;
	cin >> n >> y;
	rep(i,2005)
	{
	    rep(j,2005)
	    {
            k = n - i - j;
            if(10000*i + 5000*j + 1000*k == y and k >= 0)
            {
                cout << i << " " << j << " " << k;
                return 0;
            }
	    }
	}
	cout << "-1 -1 -1";
	return 0;
}










Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
        new Main().run();
    }
	public void run(){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int n = scan.nextInt();
			int m = scan.nextInt();
			int p = scan.nextInt();
			if(n == 0 && m == 0 && p == 0){
				break;
			}
			int sum = 0;
			int a = 0;
			m--;
			int t;
			for(int i = 0;i < n;i++){
				sum += t = scan.nextInt();
				if(i == m){
					a = t;
				}
			}
			System.out.println((a==0)?0:sum*(100-p)/a);
		}
	}
}

Measured memory_bytes: 27792
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
int main(){
    int n,x,ans=0;cin>>n;
    vector<int>a,b,c;
    for(int i=0;i<n;i++){
        cin>>x;
        a.pb(x);
    }
    for(int i=0;i<n;i++){
        cin>>x;
        b.pb(x);
    }
    for(int i=0;i<n-1;i++){
        cin>>x;
        c.pb(x);
    }
     ans=b[a[0]-1];
    for(int i=1;i<n;i++){
       if(a[i]-a[i-1]==1){
           ans+=b[a[i]-1]+c[a[i]-2];
       }
       else ans+=b[a[i]-1];
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
echo '
#include <stdio.h>
long long A[100*1001];
long long limit = 1E18;
int main()
{
 int i, n;
 scanf("%d",&n);
 for(i=0;i<n;i++)
  scanf("%lld",&A[i]);
 for(i=0;i<n;i++){
  if (!A[i]) {
   printf("0\n");
   return 0;
  }
 }
 long long p=1;
 for(i=0;i<n;i++) {
  p *= A[i];
  if (p>limit) {
   printf("-1\n");
   return 0;
  }
 }
 printf("%lld\n", p);
 return 0;
}
' > a.c
gcc -ftrapv -g -o a.out a.c
./a.out || echo '-1'

Measured memory_bytes: 23280
/*
[abc123] B - Five Dishes
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

int A[5];

ll solve() {
    int s = 0;
    for (int i = 0; i < 5; i++) {
        s += (A[i] + 9) / 10 * 10;
    }
    int d = 0;
    for (int i = 0; i < 5; i++) {
        if (A[i] % 10 > 0) {
            d = max(d, 10 - A[i] % 10);
        }
    }
    return s - d;
}

int main() {
    for (int i = 0; i < 5; i++) {
        cin >> A[i];
    }

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 256
/***********************************************************
	When you are inspired by passion 
	and you want to live for the current moment

	When your every thought and action
	has the power to become the story of your future

	When difficulties stand to demolish your Glory
	Just remember that Life is a 'Golden adverse Story'

	Withstand it to acheive your passion and dreams
	more amazingly more easily.

	Why then? When writing the story of your Life
	You want to Let someone else hold your pen

					huzaifa242©

***********************************************************/
#include "bits/stdc++.h"
using namespace std;
#define int int32_t
#define MAX 100005
#define x first 
#define y second

int seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline int rnd(int l = 0, int r = numeric_limits <int>::max())
{return uniform_int_distribution<int> (l, r)(rng);}

template <typename T, typename G>
ostream& operator << (ostream& out, const pair <T, G> &a) 
{return out << "( " << a.x << ", " << a.y << ")";}

template <typename T>
ostream& operator << (ostream& out, const vector <T> &a) 
{out << "[ "; for(const auto &i: a) out << i << ", "; return out << "]" << endl;}

template <typename T>
ostream& operator << (ostream& out, const set <T> &a) 
{out << "{ "; for(const auto &i: a) out << i << ", "; return out << "}" << endl;}

template <typename T, typename G>
ostream& operator << (ostream& out, const map <T, G> &a) 
{out << "< "; for(const auto &i: a) out << i << ", "; return out << ">" << endl;}

template <typename T, size_t N>
typename enable_if<!is_same <typename remove_cv <T>::type, char>::value,
ostream&>::type operator << (ostream& out, T (&a)[N])
{out << "[ "; for(const auto &i: a) out << i << ", "; return out << "]" << endl;}

void debug_out(){cerr << endl;} 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{cerr << (H) << ' '; debug_out(T...);}
 
#ifdef LOCAL
#define debug(...) cerr << '#' << #__VA_ARGS__ << ":\n", debug_out(__VA_ARGS__)
#else
#define debug(...) 24
#endif

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	string s;
	cin >> s;
	if (s.back() == 's')
		s += "es";
	else
		s+= 's';
	cout << s << '\n'; 
	return 0;
}


Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define P pair<int,int>
const LL inf = 0x3f3f3f3f;
const LL mod = 924844033;
const LL N = 1e5+10;
template <typename tp> inline void read(tp &x)
{
	x=0;char c=getchar();int f=0;
	for(;c>'9'||c<'0';f|=(c=='-'),c=getchar());
	for(;c<='9'&&c>='0';x=(x<<3)+(x<<1)+c-'0',c=getchar());
	if(f) x=-x;
}
int n,now;
P x[510];
int ans[250010];
signed main()
{
	read(n);now=n*n;
	for(int i=1;i<=n;i++) x[i].second=i,read(x[i].first),ans[x[i].first]=i;
	sort(x+1,x+n+1);
	for(int i=n;i>=1;i--)
	{
		int zz=x[i].second;
		int flag=n-zz;
		while(flag)
		{
			if(ans[now]==zz) return 0*puts("No");
			if(!ans[now]) ans[now]=zz,flag--;
			now--;if(now<=0) return 0*puts("No");
		}
	}
	now=1;
	for(int i=1;i<=n;i++)
	{
		int zz=x[i].second;
		int flag=zz-1;
		while(flag)
		{
			if(ans[now]==zz) return 0*puts("No");
			if(!ans[now]) ans[now]=zz,flag--;
			now++;if(now>n*n) return 0*puts("No");
		}
	}
	puts("Yes");
	for(int i=1;i<=n*n;i++) printf("%d ",ans[i]);
	puts("");
	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int n,m,bi,ci;
int a[1001],c[1001];
const int INF=1000100010;
int dp[1<<13];
int mn=INF;
int main(){
    cin>>n>>m;
    rep(i,m){
        cin>>a[i]>>bi;
        rep(j,bi){
            cin>>ci;
            --ci;
            c[i]|=1<<ci;
        }
    }
    int comp=(1<<n)-1;
    rep(j,(1<<n)+1) dp[j]=INF;
    dp[0]=0;
    //rep(i,m){
        rep(j,1<<n)if(dp[j]!=INF){
            rep(k,m){
                dp[j|c[k]]=min(dp[j|c[k]],dp[j]+a[k]);
                if((j|c[k])==comp)mn=min(mn,dp[j|c[k]]); 
            }
        }
    //}
    if(mn==INF)cout<<-1<<endl;
    else cout<<mn<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int counterR = 0, counterD = 0;
    while(sc.hasNext()) {
      String str = sc.next();
      String[] strArr = str.split(",");
      int a = Integer.parseInt(strArr[0]);
      int b = Integer.parseInt(strArr[1]);
      int c = Integer.parseInt(strArr[2]);
      if (a*a+b*b == c*c) {
        counterR++;
      }
      else if (a == b) {
        counterD++;
      }
    }
    System.out.println(counterR);
    System.out.println(counterD);
  }
}

Measured memory_bytes: 11000
#include <stdio.h>
int main(void)
{
    int i,N;
    int a,b,c,a2,b2,c2;

    scanf("%d",&N);

    for(i=0;i<N;i++){
        scanf("%d %d %d",&a,&b,&c);

        a2=a*a;
        b2=b*b;
        c2=c*c;

        if(a2==b2+c2 || b2==c2+a2 || c2==a2+b2){
            printf("YES\n");
        }else{
            printf("NO\n");
        }
        
    }

    return 0;
}


Measured memory_bytes: 2032
#include<iostream>
using namespace std;
int main(){
	int n,t[110],m,sum=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>t[i];
		sum+=t[i];
	}
	cin>>m;
	for(int i=0;i<m;i++){
		int p,x;
		cin>>p>>x;p--;
		cout<<sum-t[p]+x<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
package main

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

func exec(stdin *Stdin, stdout *Stdout) {
	_ = stdin.ReadInt()
	s := stdin.Read()
	stdout.Println(strings.Count(s, "ABC"))
}

func main() {
	stdout := NewStdout()
	defer stdout.Flush()
	exec(NewStdin(bufio.ScanWords), stdout)
}

type Stdin struct {
	stdin *bufio.Scanner
}

func NewStdin(split bufio.SplitFunc) *Stdin {
	s := Stdin{bufio.NewScanner(os.Stdin)}
	s.stdin.Split(split)
	s.stdin.Buffer(make([]byte, bufio.MaxScanTokenSize), int(math.MaxInt32))
	return &s
}

func (s *Stdin) Read() string {
	s.stdin.Scan()
	return s.stdin.Text()
}

func (s *Stdin) ReadInt() int {
	n, _ := strconv.Atoi(s.Read())
	return n
}

func (s *Stdin) ReadFloat64() float64 {
	n, _ := strconv.ParseFloat(s.Read(), 64)
	return n
}

type Stdout struct {
	stdout *bufio.Writer
}

func NewStdout() *Stdout {
	return &Stdout{bufio.NewWriter(os.Stdout)}
}

func (s *Stdout) Flush() {
	s.stdout.Flush()
}

func (s *Stdout) Println(a ...interface{}) {
	fmt.Fprintln(s.stdout, a...)
}


Measured memory_bytes: 640
n, k = map(int, input().split())
a_list = [int(input()) for _ in range(n)]

dp = [1] * n

for i in range(n):
    for j in range(max(0, i - 100), i):
        if abs(a_list[i] - a_list[j]) <= k:
            dp[i] = max(dp[i], dp[j] + 1)

ans = max(dp)
print(ans)

Measured memory_bytes: 94756
/*
[agc038] D - Unique Path
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define ALL(c) (c).begin(), (c).end()

const int MAX_N = 1e5;
const int MAX_Q = 1e5;

class UnionFind {
public:
    vector<int> data;
    UnionFind(int size) : data(size, -1) {}
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) {
            return false;
        }
        if (data[y] < data[x]) {
            swap(x, y);
        }
        data[x] += data[y];
        data[y] = x;

        return true;
    }
    bool same(int x, int y) { return root(x) == root(y); }
    int root(int x) { return data[x] < 0 ? x : (data[x] = root(data[x])); }
    int size(int x) { return -data[root(x)]; }
};

ll N, M;
int Q;
int A[MAX_Q], B[MAX_Q], C[MAX_Q];
vector<int> g[MAX_N];
bool visited[MAX_N];

void dfs(int v) {
    if (visited[v]) {
        return;
    }
    visited[v] = true;

    for (int to : g[v]) {
        dfs(to);
    }
}

bool solve() {
    if (M == N - 1) {
        return find(C, C + Q, 1) - C == Q;
    }

    UnionFind uf(N);
    for (int q = 0; q < Q; q++) {
        if (C[q] == 0) {
            g[A[q]].push_back(B[q]);
            g[B[q]].push_back(A[q]);
            uf.unite(A[q], B[q]);
        }
    }

    for (int q = 0; q < Q; q++) {
        if (C[q] == 1 && uf.same(A[q], B[q])) {
            return false;
        }
    }

    ll k = 0;
    for (int i = 0; i < N; i++) {
        if (!visited[i]) {
            k++;
        }
        dfs(i);
    }

    return M <= N + k * (k - 3) / 2;
}

int main() {
    cin >> N >> M >> Q;
    for (int q = 0; q < Q; q++) {
        cin >> A[q] >> B[q] >> C[q];
    }

    cout << (solve() ? "Yes" : "No") << endl;

    return 0;
}


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

int main() {
  vector<int> v;
  for(int i = 0; i < 10; ++i) {
    int a;
    cin >> a;
    v.push_back(a);
  }
  sort(v.begin(), v.end(), greater<int>());
  for(int i = 0; i < 3; ++i) cout << v[i] << endl;
  return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n, m, s, t;
vector<vector<i64>> g;
vector<array<i64, 3>> dist;
int main() {
  cin >> n >> m;
  init_n(g, n + 1);
  for (i64 i = 0; i < m; ++i) {
    i64 u, v;
    cin >> u >> v;
    g[u].push_back(v);
  }
  cin >> s >> t;
  init_n(dist, n + 1);
  for (i64 i = 0; i <= n; ++i) {
    fill(begin(dist[i]), end(dist[i]), 1ll << 60);
  }

  queue<pair<i64, i64>> q;
  dist[s][0] = 0;
  q.emplace(s, 0);
  while (!q.empty()) {
    auto p = q.front();
    q.pop();
    i64 u, s;    
    tie(u, s) = p;
    i64 d = dist[u][s], d_to = d + 1;
    i64 s_to = (s + 1) % 3;
    for (i64 v : g[u]) {
      if (d_to < dist[v][s_to]) {
        dist[v][s_to] = d_to;
        q.emplace(v, s_to);
      }
    }
  }
  i64 ans = dist[t][0];
  if (ans >= 1ll << 60) ans = -1;
  else ans /= 3;
  cout << ans << '\n';
  return 0;
}



Measured memory_bytes: 8064
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N=scan.nextInt();
		int h[]=new int[N];
		int m[]=new int[N];
		for(int i=0;i<N;i++){
			h[i]=scan.nextInt();
			m[i]=scan.nextInt();
		}
		
		int M=scan.nextInt();
		int q[]=new int[N+M];
		
		for(int i=0; i<N; i++){
			q[i] = h[i]*60 + m[i];
		}
		int k[]=new int[M];
		int g[]=new int[M];
		for(int i=0;i<M;i++){
			k[i]=scan.nextInt();
			g[i]=scan.nextInt();
			q[N+i] = k[i]*60 + g[i];
		}
		
		int r = 0;
		for(int i=0; i<N+M; i++){
			for(int j=i+1; j<N+M; j++){
				if(q[i]>q[j]){
					r = q[i];
					q[i] = q[j];
					q[j] = r;
				}
			}
		}
		
		for(int i=0; i<N+M; i++){
			String s = String.valueOf(q[i]%60);
			if(i==M+N-1){
				if(s.length() == 1){
					System.out.println(q[i]/60 + ":0" + q[i]%60);
				}else{
					System.out.println(q[i]/60 + ":" + q[i]%60);
				}
			}else{
				if(q[i+1] != q[i]){
					if(s.length() == 1){
						System.out.print(q[i]/60 + ":0" + q[i]%60 + " ");
					}else{
						System.out.print(q[i]/60 + ":" + q[i]%60 + " ");
					}
				}
			}
		}
	}
}

Measured memory_bytes: 20688
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))


s = list(map(int,list(input())))
li = [1,-1]

for i in range(1<<3):
    ans = s[0]
    for j in range(1,4):
        if i>>(j-1)&1:
            ans += s[j]
        else:
            ans -= s[j]
    #print(bin(i),ans)
    if ans == 7:
        print(s[0],end="")
        for j in range(1,4):
            if i>>(j-1)&1:
                print("+",end="")
                print(s[j],end="")
            else:
                print("-",end="")
                print(s[j],end="")
        print("=7")
        break







Measured memory_bytes: 3064
#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 n, m;
    cin >> n >> m;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    vector<int> path[n];
    rep(i,m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        path[a].push_back(b);
        path[b].push_back(a);
    }
    int ans = 0;
    rep(i,n) {
        int highest = h[i];
        int highob = i;
        for(int x : path[i]) {
            if (h[x] >= highest) {
                highest = h[x];
                highob = x;
            }
        }
        if (highob == i) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8780
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
A_=[0]
B_=[0]
t=0
for i in A:
    t+=i
    A_.append(t)
t=0
for j in B:
    t+=j
    B_.append(t)
for n in range(N+1):
    if A_[n]>K:
        n-=1
        break
#print(n)
ans=n
t=0
for i in range(n,-1,-1):
    for m in range(t,M+1):
#        print(B_[m],K-A_[i])
        if B_[m] > K-A_[i]:
            m-=1
            break
    t=m
#    print(ans,i,t)
    ans=max(ans,i+t)
print(ans)


Measured memory_bytes: 47556
#include <bits/stdc++.h>
using namespace std;
int N,i;
int main() {
	cin>>N;
	int A[N];
	long long sum=0,ans=0,mod=1e9+7;
	for(i=0;i<N;i++) {
		cin>>A[i];
		sum+=A[i];
		sum%=mod;
	}
	for(i=0;i<N;i++) {
		sum-=A[i];
		if(sum<0) {
			sum+=mod;
		}
		ans+=sum*A[i];
		ans%=mod;
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 4364
#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;
int main(){
  int n;
  cin>>n;
  if(n<10)cout<<n<<endl;
  else if(n<100)cout<<9<<endl;
  else if(n<1000)cout<<n-99+9<<endl;
  else if(n<10000)cout<<909<<endl;
  else if(n<100000)cout<<n-9999+909<<endl;
  else cout<<90909<<endl;
}

Measured memory_bytes: 256
var n : longint;
    i,sum : integer;
    e : boolean;
    
procedure sft(p : longint; d : integer; s,f,t : boolean);
begin
  if d = 0 then begin
    if s and f and t then if p <= n then sum := sum + 1 else e := true
  end else begin
    sft(p * 10 + 3, d - 1, s, f, true);
    sft(p * 10 + 5, d - 1, s, true, t);
    sft(p * 10 + 7, d - 1, true, f, t)
  end
end;
    
begin
  readln(n);
  sum := 0;
  e := false;
  for i := 3 to 9 do begin
    sft(0, i, false, false, false);
    if e then break;
  end;
  writeln(sum)
end.

Measured memory_bytes: 128
import heapq
 
n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
bc = [list(map(int, input().split())) for i in range(m)]
bc.sort(key=lambda x: x[1], reverse = True)
heapq.heapify(a)
 
for i in range(m):
  for j in range(bc[i][0]):
    temp = heapq.heappop(a)
    temp2 = bc[i][1]
    if temp2 > temp:
      heapq.heappush(a, temp2)
    else:
      heapq.heappush(a, temp)
      print(sum(a))
      quit()
      
print(sum(a))

Measured memory_bytes: 32976
from math import pi, cos, pow
a, b, h, m = map(int, input().split())

theta_h = (h + m/60) * (2 * pi / 12)
theta_m = m * (2 * pi / 60)

theta = abs(theta_h - theta_m)

dist = pow(a**2 + b**2 - 2*a*b*cos(theta), 1/2)
print(dist)


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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

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 long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(ll i=x;i<y;i++)
#define frr(i,x,y) for(ll i=x-1;i>=y;i--)
#define inf 1e18+1
const ll mod=998244353;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

void solve()
{
    ll n,m;
    cin>>n>>m;
    n=2*m+1;
    ll even=(m+1)/2;
    ll i=n-2*even;
    i+=1;
    ll j=i-1;
    while(i<n)
    {
        cout<<i<<" "<<n<<endl;
        i++;
        n--;
    }
    i=1;
    while(i<j)
    {
        cout<<i<<" "<<j<<endl;
        i++;
        j--;
    }
    return;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll=long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.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);
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<pii> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i].second >> v[i].first;
    }
    SORT(v);
    int sum = 0;
    for (int i = 0; i < n; ++i) {
        sum += v[i].second;
        if (sum > v[i].first) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 1792
from bisect import bisect_left

S = list(input())
T = list(input())
dict_s = {}
for i,val in enumerate(S):
    if val in dict_s:
        dict_s[val].append(i)
    else:
        dict_s[val] = [i]

l_cunt = 0
now_point = -1
for i,val in enumerate(T):
    if val in dict_s:
        tmp_point = bisect_left(dict_s[val],now_point)
        if tmp_point == len(dict_s[val]):
            l_cunt += 1
            tmp_point = 0
        now_point = dict_s[val][tmp_point]+1
    else:
        print(-1)
        exit()

print(l_cunt*len(S)+now_point)

Measured memory_bytes: 87788
N = int(input())
l = []
for i in range(N):
    l.append(int(input()))

idx = 1
stopped = set([idx])
while True:
    idx = l[idx - 1]
    if idx == 2:
        print(len(stopped))
        break
    if idx in stopped:
        print(-1)
        break
    else:
        stopped.add(idx)

Measured memory_bytes: 18992
#include<cstdio>
#include<cstring>
using namespace std;

int main(){
	char str[1001];

	while(1){
		scanf("%s",str);
		if(str[0]=='0')break;
		int sum=0;
		for(int i=0;i<strlen(str);i++){
			sum+=(str[i]-'0');
		}
		printf("%d\n",sum);
	}
	return 0;
}

Measured memory_bytes: 964
#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 fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long 
#define rep(i,n) for(int i=0;i<n;i++)
#define repa(i,arr,n) for(int i=arr;i<=n;i++)
#define repd(i,arr,n) for(int i=arr;i>=n;i--)
#define trav(arr,x) for(auto& arr:x)
#define all(c) c.begin(), c.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(arr) (int)arr.size()
#define pi 3.14159265358979323846
#define MAX 500003
#define vi vector<int>
#define pii pair<int,int>
#define pqueue priority_queue<int>
#define pdqueue priority_queue<int,vi,greater<int> >
//#define endl "\n"
 
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
const int mod=1e9+7;
int power(int a,int b)
{
    int ans=1;
    while(b)
    {
        if(b&1)
        {
            ans=(ans*a);
        }
        a=(a*a);
        b>>=1;
    }
    return ans;
}

int32_t main()
{
    fast;
    int n,ans=0,val;
    cin>>n;

    rep(i,n)
    {
        val=((n-i)*(n+1-i))/2;
        ans+=val;
    }

    rep(i,n-1)
    {
        int x,y;
        cin>>x>>y;

        if(x>y) swap(x,y);

        val=x*(n-y+1);
        ans-=val;
    }
    cout<<ans<<endl;
}   


Measured memory_bytes: 3648
import heapq

nv,ne,r = map(int, input().split())

nodes = [[] for _ in range(nv)]

for _ in range(ne):
    s,t,d = map(int, input().split())
    nodes[s].append((d, t))


costs = [-1] * nv
costs[r] = 0
hq = nodes[r]

while hq:
    cost, index = heapq.heappop(hq)
    if costs[index] > -1:
        continue
    costs[index] = cost
    for weight, next_index in nodes[index]:
        if costs[next_index] == -1:
            heapq.heappush(hq, (cost + weight, next_index))

for cost in costs:
    if cost == -1:
        print('INF')
        continue
    print(cost)


Measured memory_bytes: 96224