akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;


public class Main{

    public static boolean like(int n, List<Integer> d_lst){
        while(n > 0){
            int mod = n % 10;
            int q = n / 10;
            if(d_lst.contains(mod)){
                return false;
            }

            if(q == 0){
                break;
            }
            else{
                n = q;
            }
        }
        return true;
    }
    
    public static void main(String[] args) throws IOException{
        PrintWriter out = new PrintWriter(System.out);
        
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());

        List<Integer> d_lst = new ArrayList<>();
        
        for(int i = 0; i < k; i++){
            d_lst.add(Integer.parseInt(sc.next()));
        }

        int cand_n = n;
        while(true){
            if(like(cand_n, d_lst)){
                out.println(cand_n);
                break;
            }
            cand_n++;
        }



        
        out.flush();
        sc.close();

    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDigit(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  lol n;
  cin >> n;
  cout << n + n * n + n * n * n << '\n';
  return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>
#include <exception>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

void solve() {
    VLL t(2), a(2), b(2);
    REP(i,0,2) cin >> t[i];
    REP(i,0,2) cin >> a[i];
    REP(i,0,2) cin >> b[i];
    if (t[0] * a[0] + t[1] * a[1] == t[0] * b[0] + t[1] * b[1]) {
        cout << "infinity" << endl;
        return;
    }
    if (a[0] > b[0] == a[1] > b[1]) {
        cout << 0 << endl;
        return;
    }
    LL diff = (t[0] * a[0] + t[1] * a[1]) - (t[0] * b[0] + t[1] * b[1]);
    if (diff < 0) {
        diff *= -1;
        swap(a,b);
    }
    // a > b
    if (a[0] < b[0]) {
        /*
        dump("---");
        dump(b[0]);
        dump(a[0]);
        dump(t[0]);
        dump(diff);
        dump((b[0] - a[0]) * t[0]);
        */
        LL x = ((b[0] - a[0]) * t[0] + diff) / diff;
        cout << x * 2 - 1 - ((b[0] - a[0]) * t[0] % diff == 0) << endl;
        //dump(x * 2 - 1);
    } else {
        cout << 0 << endl;
    }
}

signed main() {
    solve();
    
    return 0;
}

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

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<int> H(N);
	for(int i = 0; i < N; i++)
	{
		cin >> H.at(i);
	}
	int answer = 0;
	bool can_view;

	for(int i = 0; i < N; i++)
	{
		can_view = true;

		for(int j = 0; j < i; j++)
		{
			if(H.at(i) < H.at(j))
			{
				can_view = false;
				break;
			}
		}

		if(can_view)
		{
			answer++;
		}
	}

	cout << answer << endl;

	return 0;
}

Measured memory_bytes: 256
n, W = gets.chomp.split.map(&:to_i)

dp = Array.new(W+1,0)

n.times do |i|
  w, v = gets.chomp.split.map(&:to_i)
  W.downto(0).each do |weight|
    if w <= weight
      dp[weight] = dp[weight-w] + v if dp[weight] < dp[weight-w] + v
    end
  end
end

# dp.each{|line| p line}
# p dp
puts dp[W]

Measured memory_bytes: 2556
// A.cpp
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 5e5 + 200;

int n, ans[MAX_N], deg[MAX_N];
char str[MAX_N];

int main()
{
    scanf("%s", str + 1), n = strlen(str + 1) + 1;
    for (int i = 1; i < n; i++)
        if (str[i] == '<')
            deg[i + 1]++;
        else
            deg[i]++;
    queue<int> q;
    for (int i = 1; i <= n; i++)
        if (deg[i] == 0)
            q.push(i);
    while (!q.empty())
    {
        int u = q.front();
        q.pop();
        if (u > 1 && str[u - 1] == '<')
            ans[u] = max(ans[u - 1] + 1, ans[u]);
        if (u < n && str[u] == '>')
            ans[u] = max(ans[u + 1] + 1, ans[u]);
        if (u > 1 && str[u - 1] == '>' && --deg[u - 1] == 0)
            q.push(u - 1);
        if (u < n && str[u] == '<' && --deg[u + 1] == 0)
            q.push(u + 1);
    }
    long long answer = 0;
    for (int i = 1; i <= n; i++)
        answer += ans[i];
    printf("%lld\n", answer);
    return 0;
}

Measured memory_bytes: 8784
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long H, W;
  cin >> H >> W;
  rep (h, H) rep(w, W) {
    string tmp;
    cin >> tmp;
    if (tmp == "snuke") {
      cout << ((char)('A' + w)) << h+1 << endl;
      return;
    }
  }
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


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

using namespace std;
int A[5];

int solve(int k) {
    if (k == 31) {
        return 0;
    }
    int res = 100000;
    for (int i = 0; i < 5; i++) {
        if ((k & (1 << i)) == 0) {
            int a = solve(k + (1 << i)) + A[i];
            if ((k + (1 << i)) != 31) {
                a += (10 - (A[i] % 10)) % 10;
            }
            res = min(res, a);
        }
    }
    return res;
}

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

Measured memory_bytes: 256
import sys
if sys.argv[-1] != 'ONLINE_JUDGE': import solve
else:
    import os, zlib, base64
    open('solve.pyx', 'wb').write(zlib.decompress(base64.b85decode("c${TY%Wi`(5WFMt58Fc(Xq*VD9x7D&BPj>l7_bTkIj*Ai>${5yulNExGoBr<UD>{aRttH)I;%|$Qg=gd9dxR@Di;P73FNP9dUGDQ<!!6lSu|K~YBh-_ms0mLUn?gYZW#)-aa9<|QdNMzm)C?=0Ye!0PSL>Nlrr!HyueleslJL(9LLK>v^G%;rmuCIg#qB2DZxNO4vB|vjcygBlZci;a!M4%3#=<-KH%*=17Q{aUKnzd7$r^Mh?)~>JZY8tu?FNSSF3obEX4)B&4>QOg%{W&$?iM3r$#)#@1-i<G$3Tv!!YO=a7HK93>>2bH|?5DKSQZ$O1|v2Wz}2I=r-M5)Wxd_@vZhgv>n8k$Q*}~?$i?{b`*|*!&44o)o(qXPyC2tN78cW$sb`#As%5$;I{B+f6Pb!JtGS5K99vu#l*|yora61crqIw#8`%bf6>w5x%@H*ya+t$KlVq{`2")))
    os.system('cythonize -i -3 -b solve.pyx')

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

main() {
    int a,b,c; cin >> a >> b >> c;
    if(b-a==c-b) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
def crivo(n):
    primos = [True] * n
    primos[0] = primos[1] = False

    i = 2
    while i * i < n:
        if primos[i] == True:
            for j in range(2*i, n, i):
                primos[j] = False
        i += 1
    return primos

def main():
    primos = crivo(100004)
    x = int(input())
    for i in range(x, 100004):
        if primos[i]:
            print(i)
            break

main()

Measured memory_bytes: 63968
#include <iomanip>
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int K;
  cin >> K;
  int A, B;
  cin >> A >> B;
  int KK = K;
  while (KK <= B) {
    if (A <= KK) {
      cout << "OK" << endl;
      return 0;
    }
    KK += K;
  }
  cout << "NG" << endl;
  return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std;

int main() {
  
  int a,b,c,d,x;
  double da,db;
  string s,ss,sss;
  
  int ans = 0;
  string anss = "";
  
  cin >> x;
  
  int ab [] = {0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1};
  int result3 = std::max({a, b, c});
//--------------------------------------------------------------------------------

//  if(x <= a) anss = "Yes";
//  else anss = "No";

  cout << x/3 << endl;

}

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

int main(){
    int64_t N,K,x=0;
    cin >> N >> K;
    
    for(int64_t i=K;i<=N+1;i++){
        x+= i * ( N + N - i + 1 ) / 2 - i * ( i - 1 ) /2 + 1;
        x%=1000000007;
    }
    cout <<x <<endl;

    
}


Measured memory_bytes: 3676
v, e, r = map(int, input().split())
a = []
for i in range(e):
    A = list(map(int, input().split()))
    a.append(A)

costs = [None] * v
costs[r] = 0
count = 0
while True:
    count += 1
    update = False
    for s, t, d in a:
        if costs[s] is None:
            continue
        cost = costs[s] + d
        if costs[t] is None or costs[t] > cost:
            costs[t] = cost
            update = True
    if not update:
        for cost in costs:
            print("INF" if cost is None else cost)
        break
    if count == v:
        print("NEGATIVE CYCLE")
        break


Measured memory_bytes: 6116
from collections import defaultdict

N, M = map(int, input().split())

import sys

teiki = defaultdict(set)
for i in range(M):
    a, b = map(int, input().split())
    teiki[a].add(b)


if 1 not in teiki:
    print('IMPOSSIBLE')
    sys.exit()

for i in teiki[1]:
    if i in teiki and N in teiki[i]:
        print('POSSIBLE')
        sys.exit()

print('IMPOSSIBLE')

Measured memory_bytes: 45360
#include<stdio.h>

int main(){

int n,x,y;
for(n =1;;n++){
	scanf("%d",&x);
	scanf("%d",&y);
	if(x==0 && y==0) break;
	
	if(x < y) printf("%d %d\n",x,y);
    else if(x > y) printf("%d %d\n",y,x);
    else printf("%d %d\n",x,y);
}


return 0;
	}




Measured memory_bytes: 2044
#include<bits/stdc++.h>
#define ll long long
using namespace std;
vector<ll> v;
void seive()
{
    bool ar[1000008];
    ll i,j;
    memset(ar,true,sizeof(ar));
    for( i=3;i*i<=1000007;i=i+2)
    {
        if(ar[i]==true)
        {
        for( j=i*i;j<=1000007;j=j+i)
        {
            ar[j]=false;
        }
        }
    }
    v.push_back(2);
    for( i=3;i<=1000007;i=i+2)
    {
        if(ar[i]==true)
            v.push_back(i);
    }
}
int main()
{
    seive();
    ll a,b,i,j,x,y;
    scanf("%lld%lld",&a,&b);
    x=__gcd(a%b,b);
    set<int> s;
    s.insert(1);
    for(i=0;v[i]*v[i]<=x;i++)
    {
        while(x%v[i]==0)
        {
            s.insert(v[i]);
            x=x/v[i];
        }
    }
    if(x>1)
    {
        s.insert(x);
    }
    printf("%d",s.size());
    return 0;

}


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

int main(){
	int W , H , x , y , r;
	bool ans=true;
	cin >> W >> H >> x >> y >> r;
	if ((x+r)<0 || (x+r)>W) {
		ans=false;
	} 
	if ((y+r)<0 || (y+r)>H) {
		ans=false;
	}
	if (x<0 || y<0) ans=false;
	cout << (ans ? "Yes"  : "No");
	cout << endl;
	return 0;
	
}

Measured memory_bytes: 1156
#include<stdio.h>
#include<cstdio>
#include<cstdlib>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<string.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#include <iomanip>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;

int N;
bool X[10001];

int main(){
	cin.tie(0);
	cout.tie(0);

	ios::sync_with_stdio(false);
	cin >> N;
	
	X[1] = true;
	FOR(i, 2, 1000) {
		int cur = i*i;

		while (cur <= 1000) {
			X[cur] = true;
			cur *= i;
		}
	}

	while (X[N] != true)N--;
	cout << N << endl;
	
	return 0;
}


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

namespace AC
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var A = ReadArrayLong();
            var cnt = new long[60];
            var mod = 1000000007L;
            var ans = 0L;
            for (int i = 0; i < 60; i++)
            {
                for (int j = 0; j < N; j++)
                {
                    if ((A[j] & 1L << i) == 1L << i) cnt[i]++;
                }
                ans += cnt[i] * (N - cnt[i]) % mod * ((1L << i) % mod) % mod;
                ans %= mod;
            }

            Console.WriteLine(ans);
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 57864
//“Make it work, make it right, make it fast.” – Kent Beck
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
const int siz = 1e6 + 5;
const int MOD = 1e9 + 7;
#define endl '\n'
#define deb(x) cout << #x << " = " << x << endl;
void solve(){
	int a, b;
	cin >> a >> b;
	if(a <= 9 && b <= 9)
		cout << a*b << endl;
	else 
	cout << -1 << endl;
}

int main(){
	#ifndef RAY
		//freopen("input.txt", "r", stdin);
	#endif
		ios::sync_with_stdio(false);
		cin.tie(nullptr);
		int t = 1;
		//cin >> t;
		while(t--){
			solve();
		}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <stack>
#include <queue>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int h, w;
    scanf("%d %d", &h, &w);
    vector<string> s(h);
    for (int i = 0; i < h; ++i) cin >> s[i];
    vector<bool> rmrow(h, false), rmcol(w, false);
    for (int i = 0; i < h; ++i)
    {
        bool ok = true;
        for (int j = 0; j < w; ++j)
        {
            if(s[i][j] != '.')
            {
                ok = false;
                break;
            }
        }
        if (ok)
        {
            rmrow[i] = true;
        }
    }

    for (int j = 0; j < w; ++j)
    {
        bool ok = true;
        for (int i = 0; i < h; ++i)
        {
            if(s[i][j] != '.')
            {
                ok = false;
                break;
            }
        }
        if (ok)
        {
            rmcol[j] = true;
        }
    }

    for (int i = 0; i < h; ++i)
    {
        bool skip = false;
        for (int j = 0; j < w; ++j)
        {
            if (rmrow[i] || rmcol[j])
            {
                if (rmrow[i]) skip = true;
                continue;
            }
            else
            {
                cout << s[i][j];
            }
        }
        if (skip) continue;
        cout << '\n';
    }
    return 0;
}


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

using namespace std;

int main(){
	int n;
	cin >> n;
	
	for(int i = 0; i < 50500; i++){
		if(floor(i+(i*0.08)) == n){
			cout << i << endl;
			return 0;
		}
	}

	cout << ":(" << endl;

	return 0;
}


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

int main(int argc, char *argv[])
{
    int a, b;
    cin >> a >> b;

    cout << (a / b) << " ";
    cout << (a % b) << " ";
    cout << fixed << setprecision(5) << (static_cast<double>(a) / static_cast<double>(b)) << endl;

    return 0;
}

Measured memory_bytes: 3236
#include <iostream>
#include <math.h>
using namespace std;
int main(void){
    int A,B,C,X;
    cin>>A;
    cin>>B;
    cin>>C;
    cin>>X;
    int count=0;
    for(int i=0;i<A+1;i++){
        for(int j=0;j<B+1;j++){
            for(int k=0;k<C+1;k++){
                if(X==i*500+j*100+k*50){
                    count++;
                }
            }
        }
    }
    cout<<count<<endl;
}


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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

const double PI = 3.1415926535897932;
const int INF = (int)1e9;
const ll LINF = 1e18;
const int IMOD = 1000000007;
const int dr[4] = {1, 0, -1, 0};
const int dc[4] = {0, 1, 0, -1};

using namespace std; 

static int memo[1000001];

map<ll, ll> PrimeFactorial(ll n) 
{
    map<ll,ll> ret;
    
    for(ll i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            while (n % i == 0) {
                ret[i]++;
                n /= i;
            }
        }
    }

    if(n > 1) { ret[n]++; }

    return ret;
}

int main(void)
{
    ll n, p;
    cin >> n >> p;
    
    map<ll, ll> f = PrimeFactorial(p);
    
    ll ans = 1;
    for(auto fact : f) {
        irep(i, fact.second/n) {
            ans *= fact.first;
        }
    }
    cout << ans << endl;
    return 0;
}
/** atcoder **/



Measured memory_bytes: 256
import java.io.*
import java.util.*
import kotlin.math.*

fun main(){
	val f = BufferedReader(InputStreamReader(System.`in`))

	val n = f.readLine().toInt()
	val array = f.readLine().split(" ").map{it.toLong()}

	var zero = false
	for(i in array){
		if(i == 0L) zero = true
	}

	if(zero){
		println(0)
	} else {
		var prod = 1L
		for(i in array){
			prod *= i
			if(prod > 1000000000000000000 || prod <= 0){
				prod = -1
				break
			}
		}
		println(prod)
	}
}


Measured memory_bytes: 60652
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
ll dfs(string S, string now) {
  ll s = stoll(S), num;
  if (now == "") {
    num = 0;
  } else {
    num = stoll(now);
  }
  if (s < num) {
    return 0;
    /*bool ok3 = false, ok5 = false, ok7 = false;
    REP(i, now.size() - 1) {
      if (now[i] == '3') ok3 = true;
      if (now[i] == '5') ok5 = true;
      if (now[i] == '7') ok7 = true;
    }
    if (ok3 && ok5 && ok7) {
      REP(i, now.size() - 1) {
        // cout << now[i];
        // if (i == now.size() - 2) cout << endl;
      }
      return 1;
    }
    return 0;*/
  }
  ll ans = dfs(S, now + '3') + dfs(S, now + '5') + dfs(S, now + '7');
  bool ok3 = false, ok5 = false, ok7 = false;
  REP(i, now.size()) {
    if (now[i] == '3') ok3 = true;
    if (now[i] == '5') ok5 = true;
    if (now[i] == '7') ok7 = true;
  }
  if (ok3 && ok5 && ok7) {
    ans += 1;
  }
  return ans;
}
int main() {
  ll N;
  cin >> N;
  string S = to_string(N);
  ll ans = dfs(S, "");
  cout << ans << endl;
}

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

int main() {
  int h, w;
  while (true) {
    cin >> h >> w;
    if (h == 0 && w == 0) break;

    for (int i = 0; i < h; i++) {
      for (int j =0; j < w; j++) {
        cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>
int main()
{
	int a,b,m,n,p;
	scanf("%d %d",&a,&b);
	m=b-a+1;
	n=b+a-1;
	p=m;
	while(p<=n)
	{
		printf("%d ",p);
		p++;
	}
	return 0;
}


Measured memory_bytes: 128
def main():
    while True:
        N = int(input())
        if N == 0:
            break

        A = [
            list(map(int, input().split(" ")))
            for _ in range(N)
        ]
        tot = [sum(col[r] for col in A) for r in range(N)]
        A.append(tot)
        for col in A:
            col.append(sum(col))

        for col in A:
            print("".join("{:5}".format(x) for x in col))


if __name__ == "__main__":
    main()

Measured memory_bytes: 7624
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define ALL(x) x.begin(), x.end() 
int main(){
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<long long> A(X), B(Y), C(Z);
    for(int i = 0; i < X; i++) cin >> A[i];
    for(int i = 0; i < Y; i++) cin >> B[i];
    for(int i = 0; i < Z; i++) cin >> C[i];
    vector<long long> sumab;
    for(int i = 0; i < X; i++){
        for(int j = 0; j < Y; j++){
            long long temp = A[i] + B[j];
            sumab.push_back(temp);
        }
    }
    sort(ALL(sumab));
    sort(ALL(C));
    long long ub = 1e18, lb = 0;
    long long iki;
    while(ub - lb > 1){
        long long ko = 0;
        long long mid = (ub + lb) / 2;
        for(int i = 0; i < Z; i++){
            long long cnt = sumab.end() - lower_bound(ALL(sumab), mid - C[i]);
            ko += cnt;
        }
        if(ko > K) lb = mid;
        else ub = mid;
    }
    vector<long long> ans; 
    long long kosu = X * Y;
    int flag = 0;
    for(int i = Z - 1; i >= 0; i--){
        for(int j = X * Y - 1; j >= 0; j--){
            long long temp = C[i] + sumab[j];
            if(temp < ub){
                if(j == X * Y - 1) flag = 1;
                break;
            }
            ans.push_back(temp);
        }
        if(flag == 1) break;
    }
    sort(ALL(ans));
    for(int i = 0; i < K; i++){
        if(i < ans.size()) cout << ans[(int)ans.size() - 1 - i] << endl;
        else cout << lb << endl;
    }
}

Measured memory_bytes: 11656
/*
*/

//#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd

#define eps 1e-8
#define M_PI 3.141592653589793
#define bsize 512

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 300031;

int A,B,C,X,Y;
int ans;

int main(){
//	freopen("apache.in","r",stdin);
//	freopen("apache.out","w",stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
//	cin.tie(0);

	ans=2e9;

	cin>>A>>B>>C>>X>>Y;
	for (int doubles=0;doubles<=200000;doubles+=2){
		int pay=C*doubles;
		int rem_X=max(0,X-doubles/2);
		int rem_Y=max(0,Y-doubles/2);
		pay+=rem_X*A+rem_Y*B;
		ans=min(ans,pay);
	}
	cout<<ans<<endl;

//	cin.get(); cin.get();
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

const string IMPOSSIBLE = "Impossible";
const string POSSIBLE = "Possible";

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, n) cin >> v[i];

    int ma = *max_element(v.begin(), v.end());
    int ma_count = count(v.begin(), v.end(), ma);
    if (ma_count < 2) {
        cout << IMPOSSIBLE << endl;
        ret();
    }

    vector<int> t(ma + 1, 0);
    for (int i : v) t[i]++;

    set<int> enable;
    for (int i = 0; i <= ma; i++) {
        int l = max(i, ma - i);
        t[l]--;
        enable.insert(l + 1);
    }

    rep(i, ma + 1) {
        if (t[i] < 0) {
            cout << IMPOSSIBLE << endl;
            ret();
        }
        if (t[i] == 0) continue;
        if (contain(enable, i)) continue;
        cout << IMPOSSIBLE << endl;
        ret();
    }

    cout << POSSIBLE << endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong N, W;
llong dp[105][100005];
llong w[105], v[105];

int main() {
    for (int i = 0; i < 105; i++) {
        for (int j = 0; j < 100005; j++) {
            dp[i][j] = 1ll << 50ll;
            if (j == 0) dp[i][j] = 0;
        }
    }
    
    cin >> N >> W;
    for (int i = 1; i <= N; i++) {
        cin >> w[i] >> v[i];
    }

    for (int i = 1; i <= N; i++) {
        for (int j = 0; j <= 100000; j++) {
            if (j >= v[i]) {
                dp[i][j] = min(dp[i - 1][j],
                               dp[i - 1][j - v[i]] + w[i]);
            }
            else {
                dp[i][j] = dp[i - 1][j];
            }
        }
    }

    llong ans = 0;
    for (int i = 0; i <= 100000; i++) {
        if (dp[N][i] <= W) ans = i;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 82304
#include<bits/stdc++.h>
using namespace std;
int main(){
	int p;
	cin>>p;
	if(p/1000==p/100%10||p/100%10==p/10%10||p/10%10==p%10)
		cout<<"Bad"<<endl;
	else cout<<"Good"<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD = 1000000007;
const ll INF = 1061109567;
const double EPS = 1e-10;
int main(){
    int a[5];
    string s;
    for(int i=0;i<5;i++){
        cin>>a[i];
        if(a[i]==0){
            cout<<i+1<<endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3620
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val (d,x) = readLine()!!.split(" ").map(String::toInt)
    val b = (0 until n).map{(d - 1) / readLine()!!.toInt()}
    println(b.sum() + x + n)
}

Measured memory_bytes: 36068
"use strict";
const Main = (input) =>{
   let xs = input.trim().split(' ').map(v=>parseInt(v,10));
   let num = xs.sort((a,b)=>(b-a));
                     
   if(num[0]==num[1]+num[2]){
      console.log('Yes');
   }else{
      console.log('No');
   }
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

int a[MAX_N];
int n,S;

int main()
{
	scanf("%d%d",&n,&S);
	rep(i,n){
		scanf("%d",&a[i]);
	}
	int l=0,r=0;
	int win=0;
	int ans = INF;
	while(r<=n){
		if(win>=S){
			ans = min(ans,r-l);
			win -= a[l];
			l++;
		}else{
			win += a[r];
			r++;
		}
	}
	if(ans==INF){
		ans = 0;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3608
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int> > Matrix;

int gcd(int a, int b){
  if (min(a, b) == 0) return max(a, b);
  if(a % b == 0) return b;
  else return gcd(b, a%b);
}

int main(){
  int n;
  cin >> n;
  vector<int> a(n+1);
  for (int i = 1; i <= n; i++) cin >> a[i];
  vector<int> L(n+2), R(n+2);
  for (int i = 1; i <= n; i++) L[i] = gcd(a[i], L[i-1]);
  for (int i = n; i >= 1; i--) R[i] = gcd(a[i], R[i+1]);
  int ans = 1;
  for (int i = 1; i <= n; i++){
    int c = gcd(L[i-1], R[i+1]);
    ans = max(ans, c);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
const ll MOD = 1000000007;
const int MAX = 1000000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int main(){
    int N,K;
    cin >> N >> K;
    int R,S,P; cin >> R >> S >> P;
    string T; cin >> T;
    ll sum=0;
    vector<bool> f(N);
    for(int i=0;i<N;i++){
        int h=0;
        f[i] = false;
        if(T[i]=='r') h = P;
        if(T[i]=='s') h = R;
        if(T[i]=='p') h = S;
        if(i<K){
            sum+=h;
            f[i] = true;
        }else if(T[i]!=T[i-K] || !f[i-K]){
            sum += h;
            f[i] = true;
            cerr << h ;
        }
        cerr << "\t" << sum << "\n";
    }
    cout << sum << endl;
    return 0;
}


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

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

    if (s.size() <= k)
    {
        cout << s << endl;
        return 0;
    }
    else
    {
        cout << s.substr(0, k) + "..." << endl;
    }
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
#define fi first
#define se second
#define upb upper_bound
#define lwb lower_bound
#define show(x) cout << #x << " is " << x << "\n";
const ll inf = 2e18;
const ll mod = 1e9 + 7;
const ld pi = 3.141592653589793238462643383279502884;

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

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y){
    if(y<=0) return 1;
    ll ans = 1;
    x %= mod;
    while(y){
        if(y&1)
            ans = (x * ans) % mod;
        x = (x * x) % mod;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = (a - b); if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = (a + b); if(c >= mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

//------------------------------------------------------------------------------------------

//const ll N = 2e5 + 1;
//vector<ll> adj[N];
//bool visited[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cout<<fixed<<setprecision(10);


	ll x;
	cin>>x;
	if(400<=x && x<=599) cout<<8;
	if(600<=x && x<=799) cout<<7;
	if(800<=x && x<=999) cout<<6;
	if(1000<=x && x<=1199) cout<<5;
	if(1200<=x && x<=1399) cout<<4;
	if(1400<=x && x<=1599) cout<<3;
	if(1600<=x && x<=1799) cout<<2;
	if(1800<=x && x<=1999) cout<<1;
	


    return 0;
}


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

int main(){
    string s;
    cin >> s;
    int n = s.length();
    int ans = 0;
    for(int i = 0; i < n/2; i++){
        if (s[i] != s[n-1-i])ans++;
    }

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

Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define maxn 100005
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
#define mp make_pair
#define ff first
#define ss second

int n,m,cnt,tot;
int now[maxn],deg[maxn],pre[maxn*2],son[maxn*2],val[maxn*2];
pii ans[maxn];

inline int read(){
    int x=0,f=1; char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
    for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
    return x*f;
}

struct union_find_set{
	int fa[maxn];
	void init(){for (int i=1;i<=n;i++) fa[i]=i;}
	int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
	bool merge(int x,int y){
		x=find(x),y=find(y); if (x==y) return 0;
		return fa[x]=y,1;
	}
}u;

void add(int a,int b,int c){son[++tot]=b,pre[tot]=now[a],now[a]=tot,val[tot]=c;}
void link(int a,int b){add(a,b,b),add(b,a,b);}

void dfs(int x,int fa){
	for (int p=now[x];p;p=pre[p])
		if (son[p]!=fa){
			dfs(son[p],x);
			if (!deg[son[p]]) ans[++cnt]=mp(x+son[p]-val[p],val[p]);
			else ans[++cnt]=mp(val[p],x+son[p]-val[p]);
			deg[x]^=deg[son[p]];
		}
}

int main(){
	n=read(),m=read();
	if (m&1){puts("-1"); return 0;}
	u.init();
	for (int i=1;i<=m;i++){
		int x=read(),y=read(); deg[x]^=1;
		if (u.merge(x,y)) link(x,y);
		else ans[++cnt]=mp(x,y);
	}
	dfs(1,0);
	for (int i=1;i<=m;i++) printf("%d %d\n",ans[i].ff,ans[i].ss);
    return 0;
}


Measured memory_bytes: 9600
n = int(input())
d_list = list(map(int, input().split()))
sorted_d_list = sorted(d_list)
half_n = n // 2

if sorted_d_list[half_n-1] == sorted_d_list[half_n]:
    print(0)
else:
    print(sorted_d_list[half_n]-sorted_d_list[half_n-1])

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

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if(a > b && a > c){
		cout << b + c << endl;
		}
	else if(b > a && b > c){
			cout << a + c << endl;
		}
else{
		cout << a + b << endl;
	}
	return 0;
}

Measured memory_bytes: 256
// Template {{{
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
using namespace std;
typedef long long LL;

#ifdef LOCAL
#include "contest.h"
#else
#define dump(x) 
#endif

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool valid(int x, int w) { return 0 <= x && x < w; }

void iostream_init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    cout.precision(12);
}
//}}}

int main(){
    iostream_init();
    int P, R, K;
    while(cin >> P >> R >> K) {
        vector<int> all(R);
        vector<vector<int>> need_(P, vector<int>(R, 0));

        REP(i, R) cin >> all[i];
        REP(i, P) REP(j, R) cin >> need_[i][j];

        vector<int> X(K);
        vector<int> Y(K);
        REP(i, K) cin >> X[i] >> Y[i];
        REP(i, K) X[i]--;
        REP(i, K) Y[i]--;

        auto zero = [&]() {
            REP(i, P) {
                REP(j, R) if(need_[i][j] > all[j]) return true;
            }
            return false;
        };
        assert(!zero());

        auto check = [&](int T) {
            vector<int> cur = all;
            vector<vector<int>> need = need_;
            vector<vector<int>> take(P, vector<int>(R, 0));
            vector<int> have(P);
            vector<int> rest(P);
            REP(i, P) REP(j, R) rest[i] += need[i][j];

            REP(i, T) {
                cur[ Y[i] ]--;
                need[ X[i] ][ Y[i] ]--;
                take[ X[i] ][ Y[i] ]++;
                have[ X[i] ]++;
                if(--rest[X[i]] == 0) {
                    have[X[i]] = 0;
                    REP(j, R) {
                        cur[j] += take[ X[i] ][j];
                    }
                }
            }

            while(true) {
                bool updated = false;
                REP(i, P) if(have[i] > 0) {
                    bool ok = true;
                    REP(j, R) if(need[i][j] > cur[j]){ ok = false; break; }
                    if(ok) {
                        updated = true;
                        have[i] = 0;
                        REP(j, R) cur[j] += take[i][j];
                    }
                }
                if(!updated) break;
            }

            REP(i, P) if(have[i]) return false;
            return true;
        };

        if(check(K)) {
            cout << -1 << endl;
            continue;
        }

        int lb = 0, ub = K + 1;
        // [lb, ub)
        while(ub - lb > 1) {
            int T = (lb + ub) / 2;
            if(check(T)) {
                lb = T;
            } else {
                ub = T;
            }
        }

        assert(lb != K);

        cout << ub << endl;
    }
    return 0;
}

Measured memory_bytes: 5548
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;
public static class P
{
    public static void Main()
    {
        var hw = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var h = hw[0];
        var w = hw[1];
        var magic = Enumerable.Repeat(0, 10).Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();
        for (int i = 0; i < 10; i++)
            for (int j = 0; j < 10; j++)
                for (int k = 0; k < 10; k++)
                    magic[j][k] = Min(magic[j][k], magic[j][i] + magic[i][k]);
        var wall = Enumerable.Repeat(0, h).Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();
        Console.WriteLine(wall.SelectMany(x => x).Where(x => x != -1).Sum(x => magic[x][1]));
    }
}

Measured memory_bytes: 13652
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#include <queue>
#include <string.h>
#include <bitset>
#define ll long long int
#define ld long double
#define rep(i,n) for(int i = 0;i < n;i++)
#define rep1(i,n) for(int i = 1;i < n;i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "
#define all(x) x.begin(),x.end()
#define allr(x) x.begin(),x.end(),greater<int>()
#define P pair<ll,ll>
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1ll << 60
#define PI 3.14159265359

using namespace std;

int main(){
	int l,n;
	cin >> n >> l;
	vector<string> s(n);
	rep(i,n) cin >> s[i];
	sort(all(s));
	string ans;
	rep(i,n){
		ans += s[i];
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

brave_num = int(input())
monster_list = [int(i) for i in input().split(" ")]
brave_list = [int(i) for i in input().split(" ")]
ans = 0
for i in range(brave_num):
    if monster_list[i] < brave_list[i]:
        ans += monster_list[i]
        brave_list[i] -= monster_list[i]
        monster_list[i] = 0
        if monster_list[i + 1] < brave_list[i]:
            ans += monster_list[i + 1]
            monster_list[i + 1] = 0
        else:
            ans += brave_list[i]
            monster_list[i + 1] -= brave_list[i]
    else:
        monster_list[i] -= brave_list[i]
        ans += brave_list[i]
print(ans)


Measured memory_bytes: 18624
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct Node{
  int k;
  struct Node *right;
  struct Node *left;
  struct Node *parent;
};

struct Node *root, *NIL;

void insert(int);
void inorder(struct Node *);
void preorder(struct Node *);
struct Node * find(struct Node *, int);

int main(){
  int i,n,value,findnum;
  char A[10];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",A);

    if(strcmp(A,"insert")==0){
     scanf("%d",&value);
      insert(value);
    }
    else if(strcmp(A,"print") == 0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if(strcmp(A,"find") == 0){
      scanf("%d",&findnum);
      struct Node *F = find(root,findnum);
      if(F != NIL) printf("yes\n");
      else printf("no\n");
    }
  }

    return 0;
}

void insert(int n){
struct  Node *p = root;
struct  Node *q = NIL;
struct  Node *r;

r = (struct Node *)malloc(sizeof(struct Node));
r -> k = n;
r -> left = NIL;
r -> right = NIL;

while(p != NIL){
   q = p;
   if(r->k < p->k){
     p = p -> left;
   }
   else{
     p = p -> right;
   }
}

r -> parent = q;
  if(q == NIL){
    root = r;
  }
  else{
    if(r->k < q->k){
      q -> left = r;
    }
    else{
      q -> right = r;
    }
  }
}

void inorder(struct Node *x){
  if(x == NIL) return;
  inorder(x -> left);
  printf(" %d",x -> k);
  inorder(x -> right);
}

void preorder(struct Node *x){
  if(x == NIL) return;
  printf(" %d",x -> k);
  preorder(x -> left);
  preorder(x -> right);
}

struct Node * find(struct Node *x, int n){
  while(x != NIL && n != x -> k){
    if(n < x -> k ) x = x -> left;
    else x = x -> right;
  }
  return x;
}



Measured memory_bytes: 20456
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

int main() {
   int A,B,C;
   cin>>A>>B>>C;
   swap(A,B);
   swap(A,C);
   cout<<A<<" "<<B<<" "<<C<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int a[10],i;
	for(i=0;i<10;i++)cin>>a[i];
	sort(a,a+10);
	for(i=9;i>6;i--)cout<<a[i]<<endl;
	return 0;
}

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

int main()
{
    int n,a,b ;
    int hold, ans ;
    //int A[MAX], B[MAX], C[MAX] ;
    int A, B, C ;
    while(cin>>n>>a>>b)
    {
        A=0, B=0, C=0 ;
        for(int i=0; i<n; i++)
        {
            cin>>hold ;
            if(hold<=a) A++ ;
            else if(hold>b) C++ ;
            else B++ ;
        }
        ans = min(A,B) ;
        ans = min(ans,C) ;
        cout<<ans<<endl ;
    }

    return 0 ;
}


Measured memory_bytes: 256
CP = 4
DP = 7

N = gets.strip.to_i

def dfs(c, d, p)
  return c + d if p == 0
  return 0 if p < 0 

  res = 0
  res += dfs(c + 1, d, p - CP)
  res += dfs(c, d + 1, p - DP) if res == 0
  return res
end

res = dfs(0, 0, N)
puts res > 0 ? 'Yes' : 'No'


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int main(){
	int k,n; cin>>k>>n;
	vector<int>h(n);
	for(int i=0;i<n;i++){
		cin>>h[i];
	}
	h.push_back(k);
	int mx=-1;
	long long tot=0;
	for(int i=0;i<n;i++){
		int diff=h[i+1]-h[i];
		if(i==n-1){
			diff+=h[0];
		}
		tot+=diff;
		mx=max(diff, mx);
	}
	tot-=mx;
	cout<<tot<<'\n';
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  vector<vector<int> > a(n, vector<int>(n, 0));
  for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) cin >> a[i][j];
  vector<long long> S(1<<n, 0);
  for(int i = 0; i < 1<<n; i++) 
    for(int j = 0; j < n; j++) 
      for(int k = j; k < n; k++)
        if((i&(1<<j)) && (i&(1<<k))){
          S[i] += a[j][k];
        }
  vector<long long> f(1<<n, 0);
  for(int i = 1; i < 1<<n; i++){
    f[i] = S[i];
    for(int msk = i; msk; msk = i & (msk - 1))
      f[i] = max(f[i], f[msk] + S[i ^ msk]);
  }
  cout << f[(1<<n) - 1] << endl;
  return 0;
}

Measured memory_bytes: 1280
#include <stdio.h> 
  
  
 int main(){ 
     char number[1001]; 
     int i, sum; 
     while(1){ 
         scanf("%s", number); 
         if(number[0]=='0')break; 
         sum=0; 
         for(i=0;number[i]!='\0';i++){ 
             sum+=number[i]-'0'; 
         } 
         printf("%d\n", sum); 
     } 
  
  
     return 0; 
 }


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

using namespace std;

#define int long long

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

signed main()
{
    int d, n, m;
    
    while (cin >> d >> n >> m, d) {
        vector<int> D(n);
        D.push_back(0);
        D.push_back(d);

        rep(i, n - 1) {
            int tmp; cin >> tmp;
            D.push_back(tmp);
            D.push_back(tmp+d);
        }

        sort(all(D));

        int ans = 0;

        rep(_, m) {
            int k; cin >> k;
            int mi = abs(k - *(lower_bound(all(D), k + 1) - 1));
            mi = min(mi, abs(k - *(lower_bound(all(D), k))));

            ans += mi;
        }

        cout << ans << endl;
    }
}

Measured memory_bytes: 5920
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

int main() {
	int A[3];
	cin >> A[0] >> A[1] >> A[2];
	sort(A, A + 3);
	if (A[0] == A[1] && A[1] != A[2]) cout << "Yes" << endl;
	else if (A[0] != A[1] && A[1] == A[2]) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <bitset>
#include <iostream>
#include <deque>
#include <functional>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

#define int long long

#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

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

#define debug(x) cerr << #x << ": " << x << endl;

const int MOD = 1e9 + 7;

template <typename T> T gcd(T m, T n) { return n == 0 ? m : gcd(n, m % n); }
template <typename T> T lcm(T m, T n) { return n * m / gcd(n, m); }

signed main(void)
{
  int num = 0;
  int n; cin >> n;
  // vector<string> s(n);
  // string t;
  string s;
  map<string, int> mem;
  for (int i = 0; i < n; ++i) {
    cin >> s;
    sort(begin(s), end(s));
    ++mem[s];
  }

  for (auto it = begin(mem); it != end(mem); ++it) {
    int val = (*it).second;
    if (val > 1) num += val * (val - 1) / 2;
  }

  cout << num << endl;
  
}


Measured memory_bytes: 11136
N = int(input())
tasks = [list(map(int, input().split())) for _ in range(N)]
sorted_tasks = sorted(tasks, key=lambda x: x[1] )

def solve():
  sum_cost = 0
  for task in sorted_tasks:
    sum_cost+=task[0]
    if(task[1]<sum_cost):
      return False
  return True

print('Yes' if solve() else 'No')

Measured memory_bytes: 55260