akhauriyash/Code-Regression huggingface dataset:
N, T = map(int, input().split())
dic = {}
for i in range(0,N):
    cost, time = map(int, input().split())
    dic[cost] = time
result = 1001
for cost, time in dic.items():
    if time <=T :
        if result >= cost:
            result = cost
if result == 1001:
    print("TLE")
else:
    print(result)


Measured memory_bytes: 3060
def A():
    A, B, C = map(int, input().split())
    if A == B or B == C or A == C:
        if (A+B+C) != A*3:
            print('Yes')
            return
    print('No')

def B():
    N = int(input())
    A = [int(i) for i in input().split()]
    for i in A:
        if i%2==0 and not (i%3==0 or i%5==0):
            print('DENIED')
            return
    print('APPROVED')
A()

Measured memory_bytes: 3060
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
using namespace std;



int main(){
    int n;
    cin >> n;
    long long costs[n+1][2];
    for(int i = 1;i <= n;i++){
        cin >> costs[i][0];
    }
    costs[1][1] = 0;
    costs[2][1] = abs(costs[1][0] - costs[2][0]);
    for(int i = 3;i <= n;i++){
        costs[i][1] = min(
            costs[i-2][1] + abs(costs[i-2][0] - costs[i][0]),
            costs[i-1][1] + abs(costs[i-1][0] - costs[i][0])
        );
    }
    cout << costs[n][1] << endl;
    //--------------
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
#define pb push_back
#define rsz resize
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
using pi = pair<int,int>;
#define f first
#define s second
#define mp make_pair
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
void setIO(string name = "a") {
    ios_base::sync_with_stdio(0); cin.tie(0);
    freopen((name+".in").c_str(), "r", stdin);
    freopen((name+".out").c_str(), "w", stdout);
}

int main() {
    //setIO();
    int n, k, x, y; cin >> n >> k >> x >> y;
    if (n >= k) {
        cout << k * x + (n - k) * y << "\n";
    } else {
        cout << n * x << "\n";
    }
}

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

#define rap(i,n) for(int i=0;i<(n);++i)
using namespace std;

int a[100][100];

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> d(k);
    vector<int> judge(n);
    rap(i,n){
        judge[i] = 0;
    } 
    rap(p,k) {
        cin >> d[p];
        rap(j,d[p]){
            cin >> a[p][j];
            judge[a[p][j]-1] = 1;
        }
    }
    int count = 0;
    rap(i,n) {
        if(judge[i] == 0) count++;
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3668
#include<stdio.h>

int main(void){
    int W,H,x,y,r;
    scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
    int a,b;
    a = x + r;
    b = y + r;
    if(a <= 0){
        printf("No\n");
    }else{if(b <= 0){
        printf("No\n");
    }else{if(W >= a && H >= b){
        printf("Yes\n");
    }else{
        printf("No\n");
        }
        }
    }
    
    return 0;
}



Measured memory_bytes: 2112
#include <iostream>

using namespace std;

int main()
{
   
    long long n,k;
    cin>>n>>k;
    if (n>k){
        long long res=n;
        long long x=n/k;
        res-=x*k;
        if (res<=k/2) {cout<<res; exit(0);} else {cout<<k-res; exit(0);}
    }
    else
    {
        if (n<=k/2) {cout<<n; exit(0);} else cout<<k-n;
    }
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>
#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,c,ans=0;
    cin >> n >> m >> c;
    vector<int> b(m);
    vector<vector<int>> a(n,vector<int>(m));
    rep(i,m) cin >> b[i];
    rep(i,n){
        rep(j,m){
            cin >> a[i][j];
        }
    }
    rep(i,n){
        int sum=0;
        rep(j,m){
            sum+=a[i][j]*b[j];
        }
        if(sum+c>0){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

bool func(int distance) {
	for (int i = 0; i < 1000; i++) {
		if ((i+1) * (i+1) == distance) {
			return true;
		}
	}
	return false;
}

int main() {
	int N, D;
	int distance;
	int ans = 0;
	cin >> N >> D;
	vector <vector<int>> X(N, vector<int>(D));

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < D; j++) {
			cin >> X.at(i).at(j);
		}
	}

	for (int i = 0; i < N - 1; i++) {
		for (int j = i + 1; j < N; j++) {
			distance = 0;
			for (int k = 0; k < D; k++) {
				distance += (X.at(i).at(k) - X.at(j).at(k)) * (X.at(i).at(k) - X.at(j).at(k));
			}
			if (func(distance)) {
				ans++;
			}
		}
	}

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

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public Main() {
    }

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

    private Scanner sc;
    long cnt;

    private void solve() {
        sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }
        cnt = 0;
        shellSort(A, N);

        System.out.println(cnt);

        for (int num : A) {
            System.out.println(num);
        }

    }

    void insertionSort(int[] A, int n, int g) {
        for (int i = g; i < n; i++) {
            int v = A[i];
            int j = i - g;
            while (j >= 0 && A[j] > v) {
                A[j + g] = A[j];
                j = j - g;
                cnt++;
            }
            A[j + g] = v;
        }
    }

    void shellSort(int[] A, int n) {
        int h = 1;
        List<Integer> G = new ArrayList<Integer>();
        while (true) {
            if (h > n) {
                break;
            }
            G.add(h);
            h = 3 * h + 1;
        }
        System.out.println(G.size());
        String ans = "";
        for (int i = G.size() - 1; i >= 0; i--) {
            ans += G.get(i);
            ans += " ";
        }

        System.out.println(ans.trim());

        for (int i = G.size() - 1; i >= 0; i--) {
            insertionSort(A, n, G.get(i));
        }
    }
}

Measured memory_bytes: 298408
n, m = map(int, input().split())

ok1 = [False] * n
ok2 = [False] * n

for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if a == 0:
        ok1[b] = True
    if b == n - 1:
        ok2[a] = True

for m in range(n):
    if ok1[m] and ok2[m]:
        print("POSSIBLE")
        exit(0)
print("IMPOSSIBLE")


Measured memory_bytes: 6132
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<malloc.h>
#include<math.h>
#include<x86intrin.h>


int my_gets(char *buf,int nBuf,FILE *fp){
    int ch;

    while(--nBuf >0){
        ch=getc(fp);
        if(ch==EOF || ch=='\n')
            break;
        *(buf++)=(char)ch;
    }
    *(buf)='\0';

    return nBuf;
}

void InputIntAry(int *a,int nDigit,int N){      //nDigitは想定される最大桁数
    char *buf,*ptr;

    buf=(char*)malloc( (N*(nDigit+2)) * sizeof(char) );
    my_gets(buf,N*(nDigit+2),stdin);

    ptr=strtok(buf," ");
    while(ptr!=NULL && N-->0){
        *(a++)=atoi(ptr);
        ptr=strtok(NULL," ");
    }
    free(buf);
}

int CmpInt(const void *a, const void *b){        //b-aを返す(qsortなら降順)
    return *((int*)b)- *((int*)a);
}

#define MAXOF(a,b)  ( ((a)>(b)) ? (a) : (b) )
#define MINOF(a,b)  ( ((a)<(b)) ? (a) : (b) )

#define ISDBG 0

int main(){
    int N,H[100000];
    int bCanOperate=1;

    scanf("%d%*c",&N);
    InputIntAry(H,10,N);

    for(int i=N-2; i>=0; i--){
        if(H[i] > H[i+1]){
            H[i]--;
            if(ISDBG)
                printf("i:%d\n",i);
            if(H[i] > H[i+1]){
                bCanOperate = 0;
                break;
            }
        }
    }
    printf("%s\n", (bCanOperate)?("Yes"):("No") );
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define int long long
using namespace std;
main(){
    string s;
    cin >> s;
    int n = s.size();
    int a[n];
    for (int i = 0; i < n; i++) a[i] = s[i]-'0';
    int ans = 0;
    for (int mask = 0; mask < (1<<(n-1)); mask++){
        int cur = a[0];
        int sum = 0;
        for (int i = 1; i < n; i++){
            if (mask & (1<<(i-1))){
                sum += cur;
                cur = 0;
            }
            else{
                cur *= 10;
            }
            cur += a[i];
        }
        sum += cur;
        ans += sum;
    }
    printf("%lld",ans);
}


Measured memory_bytes: 256
H,W,K = gets.split.map(&:to_i)
C = readlines.map {|s| s.chomp.chars.map {|c| c == "#" } }

ans = 0
(1<<H).times do |hi|
  (1<<W).times do |wi|
    cnt = 0
    H.times do |hj|
      next if (hi>>hj)&1 == 1
      W.times do |wj|
        next if (wi>>wj)&1 == 1
        cnt += 1 if C[hj][wj]
      end
    end
    ans += 1 if cnt == K
  end
end
puts ans

Measured memory_bytes: 14324
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.TreeMap;

class Main {

	public static void main(String[] args) {

		Scanner sc = null;
		Map<Integer, Integer> nums = new TreeMap<Integer, Integer>();
		try {
			sc = new Scanner(System.in);
			int maxValue = 0;
			while (sc.hasNextInt()) {
				int num = sc.nextInt();
				nums.put(num, nums.containsKey(num) ? nums.get(num) + 1 : 1);
				if (maxValue < nums.get(num)) {
					maxValue = nums.get(num);
				}
			}
			for (Entry<Integer, Integer> entry : nums.entrySet()) {
				if (maxValue == entry.getValue()) {
					System.out.println(entry.getKey());
				}
			}

		} finally {
			sc.close();
		}
	}
}

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

int main() {
    int a,b,k;
    cin>>a>>b>>k;
    set<int> st;
    for (int i=a;i<min(b+1,a+k);i++)
        st.insert(i);
    for (int i=max(a,b-k+1);i<=b;i++)
        st.insert(i);
    for (int x:st)
        cout<<x<<endl;
    return 0;
}

Measured memory_bytes: 256
#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	S = input()
	judge = "No"
	for i in range(1, 6):
		if S == "hi" * i:
			judge = "Yes"

	print(judge)


if __name__ == '__main__':
	main()

Measured memory_bytes: 38384
import sys
import math
from fractions import Fraction
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict

MOD = 10**9+7
N = int(input())
dic = defaultdict(int)
gp = []
zero = 0
left_zero = 0
right_zero = 0
for i in range(N):
    a,b = map(int, input().split())
    if b < 0:
        a = -a
        b = -b
    if a == 0 and b != 0:
        left_zero += 1
    elif a != 0 and b == 0:
        right_zero += 1
    elif a == 0 and b == 0:
        zero += 1
    else:
        g = math.gcd(a, b)
        a //= g
        b //= g
        dic[str(Fraction(a, b))] += 1
        gp.append((a, b))
done = defaultdict(bool)
ans = 1
for a,b in gp:
    k = str(Fraction(a, b))
    if done[k]: continue
    rk = str(Fraction(-b, a))
    done[k] = True
    done[rk] = True
    cnt1 = pow(2, dic[k], MOD)-1
    cnt2 = pow(2, dic[rk], MOD)-1
    c = cnt1+cnt2+1
    ans *= c
    ans %= MOD
c1 = pow(2, left_zero, MOD)-1
c2 = pow(2, right_zero, MOD)-1
c = c1+c2+1
ans *= c
ans += zero
ans %= MOD
print((ans-1)%MOD)


Measured memory_bytes: 271064
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#pragma endregion

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
  int n;
  cin >> n;
  int p[100010];
  rep(i, n)
  {
    cin >> p[i];
    p[i]--;
  }
  int cnt = 0;
  rep(i, n)
  {
    if(p[i] == i){
      swap(p[i],p[i+1]);
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


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

using namespace std;
//using namespace __gnu_pbds;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) for (int i=0; i<a; i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

const int MOD = 1000000007;
double PI = 4*atan(1);

ll fac[100001];

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	fac[0] = 1;
	FOR(i,1,100001) fac[i] = (i*fac[i-1]) % MOD;
	int N,M; cin >> N >> M;
	if (N<M) swap(N,M);
	if (N > M+1) {
	    cout << 0;
	} else if (N == M+1) {
	    cout << (fac[N]*fac[M]) % MOD;
	} else if (N == M) {
	    cout << (2*fac[N]*fac[N]) % MOD;
	}
}

Measured memory_bytes: 1664
package main

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

func main() {
	var n, k int
	s := wordScanner(100)
	scanInts(s, &n, &k)
	x := scanIntSlice(s, n)

	ans := 1 << 30
	for l := 0; l < n-k+1; l++ {
		r := l + k - 1
		ans = min(ans, min(abs(x[r]), abs(x[l]))+abs(x[r]-x[l]))
	}
	fmt.Println(ans)
}

func min(l ...int) int {
	r := l[0]
	for _, n := range l {
		if n < r {
			r = n
		}
	}
	return r
}

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

func wordScanner(n int) *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	b := make([]byte, n)
	s.Buffer(b, n)
	return s
}

func scanInts(s *bufio.Scanner, vals ...*int) {
	for i := range vals {
		s.Scan()
		n, _ := strconv.Atoi(s.Text())
		*vals[i] = n
	}
}

func scanIntSlice(s *bufio.Scanner, n int) []int {
	vals := make([]int, n)
	for i := range vals {
		s.Scan()
		m, _ := strconv.Atoi(s.Text())
		vals[i] = m
	}
	return vals
}


Measured memory_bytes: 2944
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;

public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var res = (n / 500) * 1000;
        res += (n % 500) / 5 * 5;
        Console.WriteLine(res);
    }
}


class SegmentTree<T>
{
    public int Size { get; private set; }
    T Identity;
    T[] Data;
    Func<T, T, T> Merge;
    int LeafCount;

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public SegmentTree(int size, T identity, Func<T, T, T> merge)
    {
        Init(size, identity, merge);
        for (int i = 1; i < Data.Length; i++) Data[i] = identity;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public SegmentTree(T[] elems, T identity, Func<T, T, T> merge)
    {
        Init(elems.Length, identity, merge);
        elems.CopyTo(Data, LeafCount);
        for (int i = elems.Length + LeafCount; i < Data.Length; i++) Data[i] = identity;
        for (int i = LeafCount - 1; i >= 1; i--) Data[i] = Merge(Data[i << 1], Data[(i << 1) | 1]);
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    private void Init(int size, T identity, Func<T, T, T> merge)
    {
        Size = size;
        Identity = identity;
        Merge = merge;
        LeafCount = 1;
        while (LeafCount < size) LeafCount <<= 1;
        Data = new T[LeafCount << 1];
    }

    public T this[int index]
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get { return Data[LeafCount + index]; }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        set { Update(index, value); }
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public void Update(int i, T x) { Data[i += LeafCount] = x; while (0 < (i >>= 1)) Data[i] = Merge(Data[i << 1], Data[(i << 1) | 1]); }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public void Operate(int i, T x) { Data[i += LeafCount] = Merge(Data[i], x); while (0 < (i >>= 1)) Data[i] = Merge(Data[i << 1], Data[(i << 1) | 1]); }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public T Query(int l, int r)
    {
        T lRes = Identity, rRes = Identity;
        for (l += LeafCount, r += LeafCount; l <= r; l = (l + 1) >> 1, r = (r - 1) >> 1)
        {
            if ((l & 1) == 1) lRes = Merge(lRes, Data[l]); if ((r & 1) == 0) rRes = Merge(Data[r], rRes);
        }
        return Merge(lRes, rRes);
    }
}


Measured memory_bytes: 13140
N,M = map(int,input().split())
X = list(map(int,input().split()))
X.sort()
if N >= M: #設置できるコマが座標よりも大きければ終了
    print(0)
    exit()
diff = []
for i in range(1,len(X)):           #座標の差の最大可
    diff.append(X[i]-X[i-1])
diff.sort(reverse=True)
total = sum(diff)
for i in range(N-1):                #移動範囲が広い座標間をショートカット
    total -= diff[i]
print(total)


Measured memory_bytes: 13968
#include <stdio.h>

int main(){
  int A;
  int B;
  int C;

  scanf("%d %d %d",&A,&B,&C);
  if (A+B==C){
    printf("Yes\n");
  }
  else if(B+C==A){
    printf("Yes\n");
  }
  else if(A+C==B){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a;
  string b;
  string c;
  cin >>a;
  cin >>b;
  cin >>c;
  char d=a.at(0);
  char e=b.at(0);
  char f=c.at(0);
  
  cout << d<<e<<f << endl;
}
  

Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define dme cout<<"IMPOSSIBLE"<<endl;return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
//12:15~
const int mod=1e9+7;
const llint big=1e16+100;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
int main(void){
	int n;cin>>n;
	int a,b,c,d;
	a=n/1000;n%=1000;
	b=n/100;n%=100;
	c=n/10;n%=10;
	d=n;
	if(a+b+c+d==7){cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;}
	else if(a+b+c-d==7){cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;}
	else if(a+b-c+d==7){cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;}
	else if(a+b-c-d==7){cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;}
	else if(a-b+c+d==7){cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;}
	else if(a-b+c-d==7){cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;}
	else if(a-b-c+d==7){cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;}
	else if(a-b-c-d==7){cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll A,B,C;
  cin>>A>>B>>C;
  if(A==B) {
cout<<C<<endl;
  }
  else if(B==C) {
cout<<A<<endl;
  }
  else {
cout<<B<<endl;
  }
}

Measured memory_bytes: 3592
/**
 * THIS IS CFMASTER'S CODE !
 * HACK IT IF YOU CAN !
**/
#include <bits/stdc++.h>
 
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  long long ans = 0;
  ans += (n / 500) * 1000;
  n %= 500;
  ans += (n / 5) * 5;
  cout << ans << '\n';
  return 0;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  int kaunt = 0;
  for (int i = A; i <= B; i++){
    if ((i / 10000 == i % 10 ) && (i % 10000 / 1000 == i % 10000 % 1000 % 100 / 10)){
      kaunt += 1;
    }
  }
  cout << kaunt << endl;
}


Measured memory_bytes: 256
/**
 *   author: Shubham Srivastava
 *   created: 25 January 2020  23:53:45
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define MOD 1000000007
#define INF 0x7fffffff
#define sorti(v) sort(v.begin(),v.end())
#define sortd(v) sort(v.rbegin(),v.rend())
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
ll parent[2000005];

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll n,k;cin>>n>>k;
    vector <ll> arr(n);
    for(int i=0;i<n;i++)cin>>arr[i];
    vector <ll> dp(n,0);
	for(int i=1;i<=n;i++){
		dp[i] = INT_MAX;
		for(int j=1;j<=k;j++){
			if(i-j>=0)
				dp[i] = min(dp[i],dp[i-j] + abs(arr[i]-arr[i-j]));
			else
				break;
		}
	}
	cout<<dp[n-1];
return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   if(_a % _b == 0){
      return _b;
   }
   else{
      return GCD(_b, _a % _b);
   }
}

int LCM(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   return (_a*_b)/(GCD(_a, _b));
}

int main(){

   string s;
   cin >> s;
   int ans=0;
   for(int i = 0; i < s.size(); i++){
      if(s[i] == '+'){
         ans++;
      }
      else if(s[i] == '-'){
         ans--;
      }
   }
   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 256
#include <stdio.h>


int main()
{
	int box[100];
	int N;
	int count;
	int i, j;


	scanf("%d", &N);

	for(i = 0; i < N; i++)
		scanf("%d", &box[i]);

	count = 0;
	for(i = 0; i < N; i++){
		for(j = N - 1; j > i; j--){
			if(box[j - 1] > box[j]){
				box[j] ^= box[j - 1];
				box[j - 1] ^= box[j];
				box[j] ^= box[j - 1];
				count++;
			}
		}
	}

	for(i = 0; i < N; i++){
		printf("%d", box[i]);
		if(i != N - 1)
			printf(" ");
	}
	printf("\n%d\n", count);;;

	return 0;
}


Measured memory_bytes: 2108
#include <stdio.h>

int N, M;
char A[100][100];
char B[100][100];

int main(void) {
	int i, j, i2, j2;
	if (scanf("%d%d", &N, &M) != 2) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%s", A[i]) != 1) return 1;
	}
	for (i = 0; i < M; i++) {
		if (scanf("%s", B[i]) != 1) return 1;
	}
	for (i = 0; i < N; i++) {
		for (j = 0; j < N; j++) {
			int ok = 1;
			for (i2 = 0; i2 < M; i2++) {
				for (j2 = 0; j2 < M; j2++) {
					if (i + i2 >= N || j + j2 >= N || A[i + i2][j + j2] != B[i2][j2]) {
						ok = 0;
						i2 = M;
						break;
					}
				}
			}
			if (ok) {
				puts("Yes");
				return 0;
			}
		}
	}
	puts("No");
	return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <cstring>
#include <map>
#include <iostream>

using namespace std;

bool maps[12][10002];
bool row[12];
int ans=0x7fffffff;
int r,c;
int r_c;
map<string,bool>prow;

int dfs(int st)
{
    for(int i=st;i<r;++i)
    {
        if(row[i])continue;
        else
        {
            row[i]=true;
            string str1="0000000000",str2="0000000000";
            for(int j=0;j<r;++j)
            {
                str1[j]=row[j]+'0';
                str2[j]=!row[j]+'0';
            }
            if(prow.count(str1)||prow.count(str2));
            else
            {
                prow[str1]=true;
                prow[str2]=true;
                int sun=0;
                for(int j=0;j<c;++j)
                {
                    int s=0;
                    for(int k=0;k<r;++k)
                        s+=(maps[k][j]^row[k]);
                    sun+=min(s,r-s);
                    if(sun>ans)break;
                }
                ans=min(ans,sun);
            }
            dfs(st+1);
            row[i]=false;
        }
    }
    return 0;
}

int main()
{
    while(scanf("%d%d",&r,&c),r+c)
    {
        r_c=r*c;
        prow.clear();
        memset(maps,0,sizeof(maps));
        memset(row,0,sizeof(row));
        ans=0x7fffffff;
        for(int i=0;i<r;++i)
            for(int j=0;j<c;++j)
                scanf("%d",&maps[i][j]);
        dfs(0);
        printf("%d\n",r_c-ans);
    }
    return 0;
}


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

int main()
{
	long long X, Y;

	cin >> X >> Y;

	if( abs( X - Y ) <= 1 ) {
		cout << "Brown" << endl;
	}
	else {
		cout << "Alice" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)

int pt[4000000];

int main() {
    vector<int> ps(1, 2);
    for(int i=3; i<4000000; i+=2) if(pt[i]==0) {
        ps.push_back(i);
        if(i<10000) for(int j=i*i; j<4000000; j+=i) pt[j] = i;
    }
    for(;;) {
        int n;
        scanf("%d", &n);
        if(n==0) return 0;
        const int a1 = upper_bound(ps.begin(), ps.end(), 2*n)-ps.begin();
        const int a2 = upper_bound(ps.begin(), ps.end(), n)-ps.begin();
        printf("%d\n", a1 - a2);
    }
}

Measured memory_bytes: 0
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    String s=sc.next();
  	String[] str=s.split("");
  
    int c=0;
  for(int b=0;b<n-1;b++){
   if(str[b].equals(str[b+1])){
   c++;
   }
  }
  
    System.out.println(n-c);
    
}

}

Measured memory_bytes: 31504
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
long long  mod = 1000000007;
long long a[300000];
int main()
{
	int N;
	long long sum = 0;
	scanf("%d", &N);
	for (int i = 0; i < N * 3; i++) {
		scanf("%lld", &a[i]);
	}
	sort(a, a + N * 3, greater<long long>());
	int i = 1;
	while (N > 0) {
		sum += a[i];
		i += 2;
		N--;
	}
	printf("%lld", sum);
	return 0;
}

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

int main()
{
	int a[3];
	for(int i=0;i<3;i++)
	cin>>a[i];
	sort(a,a+3);
	cout<<((a[2]*10)+a[0]+a[1]);
}


// }
// #include<stdio.h>
// #include<math.h>
// int main()
// {
// 	int n;
// 	scanf("%d",&n);
// 	int c=0;

// 	for (int i = 1; i<=(n) ; ++i)
// 	{
// 		if(n%i==0)
// 		{
// 		//printf("%d ",i);
// 		c++;
		
// 	}
// }
// 	if(c>8)
// 	{
// 		int h=(c-8)/4;
// 		printf("%d ",((h*8)+12));
// 	}
	
	

// }

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

  if( (A+B) >= 24 ){
    ans = A+B - 24;
  }
  else{
    ans = A+B;
  }

  cout << ans;

  return 0;

  

  
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;

public class Main {

	public static void main(String[] args) {


        try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
            String inputData = reader.readLine();

            BigDecimal r = new BigDecimal(inputData);
			BigDecimal bdPI = new BigDecimal(3.14159265358979323846d);

			BigDecimal area = r.pow(2).multiply(bdPI).setScale(6, BigDecimal.ROUND_HALF_UP);
			BigDecimal round = bdPI.multiply(r).multiply(new BigDecimal(2)).setScale(6, BigDecimal.ROUND_HALF_UP);

            System.out.println(area.toPlainString() + " " + round.toPlainString());

        } catch (IOException e) {
            e.printStackTrace();
        }

	}

}

Measured memory_bytes: 24372
a=0;v=-1;
gets.to_i.times do
    line=gets
    x,y=line.split.map(&:to_i)
    if y>v then
        a=x;v=y
    elsif y==v then
        if x<a then
            a=x
        end
    end
end
print a," ",v,"\n"

Measured memory_bytes: 6104
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2005;

int n, k, q;

int a[maxn];
int b[maxn];

bool check(int lb, int ub){
    int len = 0;
    int cnt = 0;
    int key = 0;
    for(int i = 1;i <= n + 1;i++){
        if(a[i] < lb){
            int tmp = min(len + 1 - k, key);
            cnt += max(0, tmp);
            len = 0, key = 0;
        }else if(a[i] >= lb and a[i] <= ub){
            key++;
            len++;
        }else{
            len++;
        }
    } 
    return cnt >= q;
}

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> k >> q;
    for(int i = 1;i <= n;i++){
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b + 1, b + 1 + n);
    int ans = 1e9;
    for(int i = 1;i <= n;i++){
        int l = i, r = n + 1;
        while(l < r){
            int mid = (l + r) / 2;
            if(check(b[i], b[mid]))
                r = mid;
            else
                l = mid + 1;
        }
        if(r != n + 1){
            ans = min(ans, b[l] - b[i]);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define LL long long
#define inf 1000000007
using namespace std;
LL quick_mod(LL a, LL b)
{
    LL ans = 1;
    a %= inf;
    while(b)
    {
        if(b & 1)
        {
            ans = ans * a % inf;
            b--;
        }
        b >>= 1;
        a = a * a % inf;
    }
    return ans;
}

LL C(LL n, LL m)
{
    if(m > n)
        return 0;
    LL ans = 1;
    for(int i=1; i<=m; i++)
    {
        LL a = (n + i - m) % inf;
        LL b = i % inf;
        ans = ans * (a * quick_mod(b, inf-2) % inf) % inf;
    }
    return ans;
}

LL Lucas(LL n, LL m)
{
    if(m == 0)
        return 1;
    return C(n % inf, m % inf) * Lucas(n / inf, m / inf) % inf;
}

ll pow1(ll a,ll b)
{
    ll res=1;
    while(b)
    {
        if(b%2)
            (res*=a)%=inf;
        (a*=a)%=inf;
        b/=2;
    }
    return res;
}
int main()
{
    ll n,a,b;
    scanf("%lld%lld%lld",&n,&a,&b);
    printf("%lld",((pow1(2,n)-(Lucas(n,a)+Lucas(n,b)+1)%inf)+inf)%inf);
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_abc097() {
	ll H, W;
	cin >> H >> W;

	char s[51][51] = { { "." } };
	string tmp;
	rep(i, H) {
		cin >> tmp;
		rep(j, W) {
			s[i][j] = tmp[j];
		}
	}

	string ans = "Yes";

	rep(i, H) {
		rep(j, W) {
			if (s[i][j] == '#') {
				//up
				if (i > 0 && s[i - 1][j] == '#') {
					continue;
				}
				//down
				if (i < H - 1 && s[i + 1][j] == '#') {
					continue;
				}
				//left
				if (j > 0 && s[i][j - 1] == '#') {
					continue;
				}
				//right
				if (j < W - 1 && s[i][j + 1] == '#') {
					continue;
				}
				ans = "No";
				cout << ans << "\n";
				return;
			}
		}
	}

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

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

	solve_abc097();

	return 0;
}


Measured memory_bytes: 256
n,k=gets.split.map(&:to_i)
m=998244353
dp=[0,1]
l,r=[],[]
k.times do |i|
  ll,rr=gets.split.map(&:to_i)
  l << ll
  r << rr
end
s=[0]*10
2.upto(n) do |i|
  k.times do |j|
    if l[j]<=i-1
#      p [1,i,j]
      s[j]+=dp[i-l[j]]
      s[j]%=m
    end
    if r[j]<=i-2
#      p [2,i,j]
      s[j]-=dp[i-r[j]-1]
      s[j]%=m
    end
  end
  dp[i]=s.sum%m
end
puts dp[-1]


Measured memory_bytes: 16148
using System.Collections.Generic;
using System.Linq;
using System;

public class Player
{
    public int ppoint { get; set; }
    public int p1 { get; set; }
    public int p2 { get; set; }
    public int p3 { get; set; }
}

public class hello
{
    public static void Main()
    {
        var players = new List<Player>();
        var n = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < n; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            players.Add(new Player {  p1 = int.Parse(line[0]), p2 = int.Parse(line[1]),p3 = int.Parse(line[2]) });
        }
        for (int i = 0; i < n; i++)
        {
            if (players.Count(x => x.p1 == players[i].p1) == 1) players[i].ppoint += players[i].p1;
            if (players.Count(x => x.p2 == players[i].p2) == 1) players[i].ppoint += players[i].p2;
            if (players.Count(x => x.p3 == players[i].p3) == 1) players[i].ppoint += players[i].p3;
        }
        foreach (var x in players)
            Console.WriteLine(x.ppoint);
    }
}

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

int main(){
    int n;
    string s;
    cin >> n>>s;
    int r=n;
    for(int i=0;i<n-1;i++){
        if(s.at(i)==s.at(i+1)){
            r--;
        }
    }
    cout<<r<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int arr[1005];
int main(int argc, char* args[])
{
    int n;
    cin >> n;
    for(int i = 1;i <= n;i++)
        cin >> arr[i];
    int ans = 0;
    for(int i = 1;i <= n;i++)
    {
        if(arr[i] == arr[i+1] && arr[i+1] == arr[i+2])
        {
            ans++;
            arr[i+1] = arr[i]+1;
            continue;
        }
        if(arr[i] == arr[i+1])
            ans++;
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int no;
	double weight, height;
	
	while(scanf("%d,%lf,%lf", &no, &weight, &height)!=EOF) {
		double BMI;
		BMI=weight/(height*height);
		if(BMI>=25.0) printf("%d\n", no);
	}
	
	return 0;
}


Measured memory_bytes: 628
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [A, B, C] = input[0].map(Number);

  return A + B >= C ? "Yes" : "No";
};

console.log(main(read()));


Measured memory_bytes: 29592
fun main(args: Array<String>) {
  val (x, a) = listOfInt()
  println(if (x < a) "0" else "10")
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { it.toInt() }

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

int main(){
  int n,m;
  while(cin>>n>>m){
    if(n==0&&m==0)break;
    int data[11][10010];
    rep(i,n)rep(j,m)cin>>data[i][j];
    
    int ans=0;
    rep(i,1<<n){
      int t=0;
      rep(j,m){
        int a=0;
        rep(k,n)
          if((i&(1<<k))!=0)a+=!data[k][j];
          else a+=data[k][j];
        t+=max(a,n-a);
      }
      ans=max(ans,t);
    }
    cout<<ans<<endl;
  }
}

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

typedef long long ll;
typedef pair<int, int> ii;

int main()
{
    int a, b;
    scanf("%d %d", &a, &b);
    /*
    for (double i = 1; i <= 1251; i++)
        if ((int)(i * 0.08) == a && b == (int)(i * 0.1)) {
            printf("%d\n", (int)i);
            return 0;
        }
    printf("-1\n");
    */

    int left = (int)ceil(max(1.0 * a / 0.08, 1.0 * b / 0.1));
    int right = (int)floor(min(1.0 * (a + 1) / 0.08, 1.0 * (b + 1) / 0.1));

    // printf("%d %d\n", left, right);
    if (left < right)
        printf("%d\n", left);
    else
        printf("-1\n");

    return 0;
}


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

#define loop(i, n) for(int i = 0; i < n; i++)
#define sloop(i, s, n) for (int i = s; i < n; i++)
#define rloop(i, n) for (int i = n - 1; i >= 0; i--)

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    vector<int> l(s.size()+1, 0), r(s.size()+1, 0);
    int count = 0;
    sloop(i, 1, s.size()+1) {
        if(s[i-1] == '<') ++count;
        else count = 0;
        l[i] = count;
    }
    count = 0;
    rloop(i, s.size()) {
        if(s[i] == '>') ++count;
        else count = 0;
        r[i] = count;
    }
    long long int ans = 0;
    loop(i, s.size()+1) {
        // cout << l[i] << ' ' << r[i] << endl;
        ans += max(l[i], r[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7708
# https://atcoder.jp/contests/abc083/tasks/abc083_b

n, a, b = map(int, input().split())

def check(num):
    s = str(num)
    t = 0
    for i in s:
        t += int(i)
    if a <= t <= b:
        return True
    return False

ans = 0
for i in range(1, n + 1):
    if check(i):
        ans += i

print(ans)

Measured memory_bytes: 41964
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    a,b=INTM()
    ct=0
    for i in range(a,b+1):
        s=str(i)
        if s[0]==s[4] and s[1]==s[3]:
            ct+=1
    print(ct)
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064
a=1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
print(a[int(input()) - 1])


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    int ans=0;
    for(int i=0; i<s.size(); i++){
        int cnt=0;
        if(s.at(i)=='A'||s.at(i)=='C'||s.at(i)=='G'||s.at(i)=='T'){
            cnt++;
            for(int j=i+1; j<s.size(); j++){
                if(s.at(j)=='A'||s.at(j)=='C'||s.at(j)=='G'||s.at(j)=='T')cnt++;
                else break;
            }
        }
        ans=max(ans,cnt);
    }
    cout<<ans<<endl;
}


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

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

	int ans = -INT_MAX;

	for (int i = 1; i < n; i++) {
		int Ri; cin >> Ri;

		ans = max(ans, Ri - m);
		m = min(m, Ri);
	}

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



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

int main()
{
	int N, M;

	cin >> N >> M;

	int Nn2 = 1;
	int Mm2 = 1;

	for (int i = N - 1; i <= N; i++)
	{
		Nn2 *= i;
	}

	for (int i = M - 1; i <= M; i++)
	{
		Mm2 *= i;
	}

	int ans = Nn2 / 2 + Mm2 / 2;

	cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))

int n;
int x,y,z;
lli dp[45][1<<5][1<<7][1<<5]={};

void inline isk(int k,int abc,int xyz,int sk,int& kr,int& to){
	if(abc&(1<<(xyz-k)))kr=1;
	else kr=0;
	to=((abc<<k)|sk)&((1<<xyz)-1);
}

#define MOD (1000000007LL)

#define add(a,b) a=(a+b)%MOD;

lli nas[45];

int main(void){
	scanf("%d%d%d%d",&n,&x,&y,&z);
	nas[n-1]=1;
	irep(i,n-1){
		nas[i]=(nas[i+1]*10)%MOD;
	}
	
	dp[0][1][0][0]=1;
	lli ans=0;
	rep(i,n){
		reg(k,1,10){
			rep(a,1<<x){
				int ta,ka;
				isk(k,a,x,1 | (1<<k),ka,ta);
				rep(b,1<<y){
					int tb,kb;
					isk(k,b,y,ka,kb,tb);
					rep(c,1<<z){
						int tc,kc;
						isk(k,c,z,kb,kc,tc);
						
						/*
						printf("i %d, a %d,b %d,c %d\n",i,a,b,c);
						printf("dp %lld\n",dp[i][a][b][c]);
						printf("k %d,ta %d,tb %d,tc %d\n",k,ta,tb,tc);
						printf("ka %d,kb %d,kc %d\n\n",ka,kb,kc);
						
						printf("%d %d %d %d %d ",i,k,a,b,c);
						printf("dp %lld ",dp[i][a][b][c]);
						printf("   %d %d %d    ",ta,tb,tc);
						printf("%d %d %d\n",ka,kb,kc);
						*/
						
						if(kc){
							add(ans,(dp[i][a][b][c]*nas[i])%MOD);
						}
						else{
							add(dp[i+1][ta][tb][tc],dp[i][a][b][c]);
						}
					}
				}
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}






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

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

  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  int sum = 0;
  for(int i = 0; i < N; i++){
    sum += A[i];
  }
  int s = 0;
  for(int i = 0; i < N; i++){
    if((double)sum / (4 * M) <= A[i]){s += 1;}
  }
  if(s >= M)
  cout << "Yes";
  else 
  cout << "No";
  return 0;
}

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

using namespace std;
typedef vector<int> VI;
typedef long long LL;
typedef pair<int,int> PI; 
typedef pair<LL,LL> PLL;
typedef unsigned long long ULL;
typedef pair<double,double> PD;

#define FOR(x, b, e) for(int x = b; x<= (e); x++)
#define FORD(x, b, e) for(int x = b; x>= (e); x--)
#define REP(x, n) for(int x = 0; x<(n); ++x)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(x) ((int)(x).size())

#define PB push_back
#define IN insert
#define ST first
#define ND second
#define INF 2000000011
#define MOD 1000000007

#define MAXSIZE 100010

int n;
LL wyn=1;
VI graf[MAXSIZE];
LL dp[MAXSIZE][2]; //[nr wierz][kolor ->0=bialy,1=czarny]

int P[MAXSIZE];

void dfs(int v){
	for(auto x:graf[v]){
		if(x!=P[v]){
			P[x]=v;
			dfs(x);
			dp[v][0]=(dp[v][0]*(dp[x][0]+dp[x][1])%MOD)%MOD;
			dp[v][1]=(dp[v][1]*dp[x][0])%MOD;
		}
	}
}

int main(){
	
	ios::sync_with_stdio(0); cin.tie(0);
	cin>>n;
	
	REP(i,n-1){
		int t1,t2;
		cin>>t1>>t2;
		graf[t1].PB(t2);
		graf[t2].PB(t1);
	}
	
	FOR(i,1,n)
		dp[i][0]=dp[i][1]=1;
	
	P[1]=1;
	dfs(1);
	
	cout<<(dp[1][0]+dp[1][1])%MOD;
	
	return 0;
}


Measured memory_bytes: 14592
#include<stdio.h>
int main(void)
{
	int n,a,c,x,y,z;
	scanf("%d",&n);
	x=n/1000000000; c=x; 
	y=n%1000000000; x=y/100000000; c=c+x;
	y=y%100000000; x=y/10000000; c=c+x;
	y=y%10000000; x=y/1000000; c=c+x;
	y=y%1000000; x=y/100000	; c=c+x;
	y=y%100000; x=y/10000; c=c+x;
	y=y%10000; x=y/1000; c=c+x;
	y=y%1000; x=y/100; c=c+x;
	y=y%100; x=y/10; c=c+x;
	y=y%10;  x=y; c=c+x;
	z=n%c;
	if(0<z) printf("No\n");	
	else printf("Yes\n");
	return 0;
}


Measured memory_bytes: 1640
import sys

input = sys.stdin.readline


def solve(S, n, k):
    S = [1 if s == 'R' else -1 for s in S]

    num_hapiness = 0
    for i in range(n):
        next_idx = i + S[i]
        if next_idx < 0 or next_idx >= n:
            continue
        if S[next_idx] == S[i]:
            num_hapiness += 1
    num_unhapiness = n - num_hapiness
    num_can_change_to_hapiness = num_unhapiness - 1
    max_can_change_to_hapiness = k * 2
    actually_change_to_hapiness = min(num_can_change_to_hapiness, max_can_change_to_hapiness)

    return num_hapiness + actually_change_to_hapiness


if __name__ == '__main__':
    n, k = map(int, input().split())
    S = input().strip()

    answer = solve(S, n, k)
    print(answer)


Measured memory_bytes: 4084
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main ()
{
    ll i,j,k,n,c=0;
    vector<ll> v;
    cin>>n>>k;
    for(i=0;i<n;i++)
    {ll q; cin>>q; v.push_back(q);}
    if(k>=n)
    {
        cout<<0;
    }
    else
    {
        sort(v.begin(),v.end());
        reverse(v.begin(),v.end());
        for(i=k;i<n;i++)
        {
            c=c+v[i];
        }
        cout<<c;
    }
    return 0;
}

Measured memory_bytes: 5272
N, M = map(int, input().split())
D = [[] for i in range(N)]
 
for i in range(M):
  p, y = map(int, input().split())
  D[p-1].append((y, i)) 

ans = [None]*M
 
for i, d in enumerate(D): 
  d.sort()
  for k, (y, j) in enumerate(d): 
    ans[j] = str(i+1).zfill(6) + str(k+1).zfill(6)
print(*ans, sep = '\n') 

Measured memory_bytes: 37480
def main():
    from collections import Counter as ct
    n = int(input())
    word_list = [""]
    for i in range(n):
        word_list2 = []
        for i in word_list:
            c = len(ct(i))
            for j in range(c+1):
                word_list2.append(i+"abcdefghij"[j])
        word_list = word_list2
    word_list.sort()
    for i in word_list:
        print(i)


main()

Measured memory_bytes: 13280
#include<iostream>
#include<vector>
#include<math.h>
using namespace std;

int main() {

	vector<int>numbers;
	int N;
	cin >> N;

	for (int i = 0; i < N; i++) {
		int W;
		cin >> W;
		numbers.push_back(W);
	}

	int min = 1000000000;
	int difference;
	for (int i = 0; i < N; i++) {
		int sum1 = 0;
		int sum2 = 0;
		for (int j = 0; j < N; j++) {
			if (j <= i) {
				sum1 += numbers[j];
			}
			else {
				sum2 += numbers[j];
			}
		}
		difference = abs(sum1 - sum2);
		if (difference < min) {
			min = difference;
		}
	}

	cout << min << endl;

	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
using namespace std;

#define DIR_X (0)
#define DIR_Y (1)


int main(void)
{
	string s;
	int dst[2];
	cin >> s >> dst[0] >> dst[1];

	unsigned int pos = 0;
	int xst = 0;
	int dir = 0;
	for (pos = 0; pos < s.length(); pos++) {
		if (s[pos]=='F') xst++;
		else break;
	}
	dir = DIR_Y;
	vector <int> mov[2];
	int mv_len = 0;
	for (pos+=1; pos < s.length(); pos++) {
		if (s[pos]=='F') mv_len++;
		else {
			if (mv_len > 0) {
				mov[dir].push_back(mv_len);
			}
			dir = dir ^ 1;
			mv_len = 0;
		}
	}
	if (mv_len > 0) {
		mov[dir].push_back(mv_len);
	}

	set <int> val;
	int vec_size;
	bool ans = true;
	// x 方向
	val.insert(xst);
	vec_size = mov[0].size();
	for (int i = 0; i < vec_size; i++) {
		int v1 = mov[0].at(i);
		set <int> val2;
		val2.clear();
		for(auto itr = val.begin(); itr != val.end(); itr++) {
			int v2 = *itr;
			val2.insert(v2+v1);
			val2.insert(v2-v1);
		}
		val = val2;
	}
	if (val.find(dst[0]) == val.end()) ans = false;

	// y 方向
	val.clear();
	val.insert(0);
	vec_size = mov[1].size();
	for (int i = 0; i < vec_size; i++) {
		int v1 = mov[1].at(i);
		set <int> val2;
		val2.clear();
		for(auto itr = val.begin(); itr != val.end(); itr++) {
			int v2 = *itr;
			val2.insert(v2+v1);
			val2.insert(v2-v1);
		}
		val = val2;
	}
	if (val.find(dst[1]) == val.end()) ans = false;

	if (ans) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 640
s = input()

num_cases = 2 ** 3
patterns = [0] * num_cases
for i in range(num_cases):
    patterns[i] = [0] * 3
    for j in range(3):
        if ((i>>j) & 1):
            patterns[i][j] = '+'
        else:
            patterns[i][j] = '-'
for pattern in patterns:
    res = int(s[0])
    for i in range(3):
        op = pattern[i]
        if op == '+':
            res += int(s[i+1])
        else:
            res -= int(s[i+1])
    if res == 7:
        ans_p = pattern
        break

ans = s[0] + ans_p[0] + s[1] + ans_p[1] + s[2] + ans_p[2] + s[3] + '=7'

print(ans)


Measured memory_bytes: 3064