akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;

public class Main {
	static final int mod = (int) 1e9 + 7;
	static final int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };
	static final int[] DX8 = { -1, -1, -1, 0, 0, 1, 1, 1 }, DY8 = { -1, 0, 1, -1, 1, -1, 0, 1 };
	static final int INF = Integer.MAX_VALUE / 3;
	static final long LINF = Long.MAX_VALUE / 3;
	static final String nextLine = "\n";

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt(), k = fs.nextInt();
		String s = fs.next();
		int a[] = new int[n];
		for(int i=0;i<n;i++)a[i] = s.charAt(i) - '0';
		int now = 1;
		int cnt = 0;
		ArrayList<Integer> ls = new ArrayList<>();
		for(int i=0;i<n;i++) {
			if(a[i] == now) {
				cnt ++;
			}
			else {
				ls.add(cnt);
				cnt = 1;
				now = a[i];
			}
		}
		ls.add(cnt);
		
		//lsは先頭が０なら、１の数が０個で入ってる
		
		//1のK+1区間（0のk区間含む）の人数の最大値が答え

		//全ての0をひっくり返せる時
		if(ls.size()<=2*k+1) {
			System.out.println(n);
			return;
		}
		
		//尺取り法で調べる
		int r = 0;
		int ans = 0;
		int res = ls.get(0);
		for(int l=0;l<ls.size();l+=2) {
			while(r+1<ls.size()&&(r+1)-l<2*k+1) {
				r++;
				res+=ls.get(r);
				ans = Math.max(ans, res);
			}
			if(l+1<ls.size()) {
				res -= (ls.get(l) + ls.get(l+1));				
			}
		}
		
		System.out.println(ans);
		
	}

	//MOD culculations
	static long plus(long x, long y) {
		long res = (x + y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long sub(long x, long y) {
		long res = (x - y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long mul(long x, long y) {
		long res = (x * y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long div(long x, long y) {
		long res = x * pow(y, mod - 2) % mod;
		return res < 0 ? res + mod : res;
	}

	static long pow(long x, long y) {
		if (y < 0)
			return 0;
		if (y == 0)
			return 1;
		if (y % 2 == 1)
			return (x * pow(x, y - 1)) % mod;
		long root = pow(x, y / 2);
		return root * root % mod;
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 25812
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
typedef long long ll;
using std::min;
using std::max;
const int MAXN=2e5+5;

int n;
int A[MAXN],B[MAXN];

int main()
{
	int i,k;scanf("%d",&n);
	for(i=1;i<=n;i++) scanf("%d",A+i);
	for(i=1;i<=n;i++) scanf("%d",B+i);
	int ans=0;
	for(k=0;k<29;k++)
	{
		static int a[MAXN],b[MAXN];
		for(i=1;i<=n;i++) a[i]=A[i]%(1<<k+1),b[i]=B[i]%(1<<k+1);
		std::sort(b+1,b+n+1);
		bool res=false;
		for(int i=1;i<=n;i++)
			res^=(std::lower_bound(b+1,b+n+1,(1<<k)*2-a[i])-std::lower_bound(b+1,b+n+1,(1<<k)-a[i]))&1,
			res^=(std::lower_bound(b+1,b+n+1,(1<<k)*4-a[i])-std::lower_bound(b+1,b+n+1,(1<<k)*3-a[i]))&1;
		ans|=res<<k;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int INF = 1000000;
int main(){
  int V, E;
  cin >> V >> E;
  vector<vector<int>> dist(V, vector<int>(V, INF));
  for (int i = 0; i < E; i++){
    int s, t, d;
    cin >> s >> t >> d;
    dist[s][t] = d;
  }
  vector<vector<int>> dp(1 << V, vector<int>(V, INF));
  dp[0][0] = 0;
  dp[1][0] = 0;
  for (int i = 0; i < (1 << V); i++){
    for (int j = 0; j < V; j++){
      for (int k = 0; k < V; k++){
        if ((i >> j) & 1){
          dp[i][j] = min(dp[i][j], dp[i - (1 << j)][k] + dist[k][j]);
        }
      }
    }
  }
  if (dp[(1 << V) - 1][0] == INF){
    cout << -1 << endl;
  } else {
    cout << dp[(1 << V) - 1][0] << endl;
  }
}


Measured memory_bytes: 6340
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>

using namespace std;

bool comp(int h1, int w1, int h2, int w2){
	if(h1 * h1 + w1 * w1 > h2 * h2 + w2 * w2){
		return true;
	}
	if(h1 * h1 + w1 * w1 < h2 * h2 + w2 * w2){
		return false;
	}
	if(h1 > h2){
		return true;
	}
	return false;
}

int main(){
	
	int h, w;
	
	while(true){
		cin >> h >> w;
		if(h == 0 && w == 0){
			break;
		}
		int ans_h = 1000;
		int ans_w = 1000;
		for(int i = 160; i > 0; i--){
			for(int j = 160; j > i; j--){
				if(comp(i, j, h, w)){
					if(comp(ans_h, ans_w, i, j)){
						ans_h = i;
						ans_w = j;
					}
				}
			}
		}
		
		cout << ans_h << " " << ans_w << endl;
		
	}
	
	return 0;
}

Measured memory_bytes: 2972
#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>

using namespace std;

int main() {
    string s;

    cin >> s;

    s[5]  = ' ';
    s[13] = ' ';

    cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
import itertools

N, M = map(int, input().split())
cakes = [list(map(int, input().split())) for _ in range(N)]
signs = [1, -1]
ans = 0
for axis in itertools.product(signs, repeat = 3):
    cakes_proj = [sum([cake[i] * axis[i] for i in range(3)]) for cake in cakes]
    cakes_proj.sort(reverse = True)
    ans = max(ans, sum(cakes_proj[:M]))
print(ans)

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

int main(){
    int n,ans=0;
    cin>>n;
    char c[n];
    for(int k=0;k<n;k++){
        cin>>c[k];
    }
    int i=0,j=n-1;
    while(i<j){
        while(c[i]=='R'){
            i++;
        }
        while(c[j]=='W'){
            j--;
        }
        if(i<j){
            ans++;
            i++;
            j--;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3828
while True:
    a,b=map(int,input().split())
    if a==0 and b==0:break
     
    f=[[0 for i in range(b)]for j in range(a)]
     
    for i in range(a):
        for j in range(b):
            if i==0 or i==a-1 or j==0 or j==b-1:
                f[i][j]=1
     
    for i in range(a):
        for j in range(b):
            if f[i][j]==1:
                print('#',end='')
            else :
                print('.',end='')
        print()
    print()




Measured memory_bytes: 7256
#include<iostream>
#include<cstring>
#include<cctype>
#include<algorithm>
using namespace std;
typedef long long ll;
const int HWmax = 30;
int H,W,K;
char C[HWmax][HWmax+1];
char d[HWmax][HWmax+1];

void p(){
	for(int i=0; i<H; i++){
		cout << d[i] << endl;
	}
	cout << endl;
}

ll removable(){
	ll ret = 0;
	char x;
	int k;
	for(int i=0; i<H; i++){
		x = isdigit(d[i][0]) ? d[i][0] : '+';
		k = 1;
		for(int j=1; j<W; j++){
			if(d[i][j] == x) k++;
			else{
				if(k >= K){
					ret += (x-'0')*k;
					//cout << i << " " << j << " " << k << " " << x << endl;
					for(int l=j-k; l<j; l++) d[i][l] = '-';
				}
				k = 1;
				x = isdigit(d[i][j]) ? d[i][j] : '+';
			}
		}
		if(k >= K){
			ret += (x-'0')*k;
			//cout << i << " " << W << " " << k << " " << x << endl;
			for(int l=W-k; l<W; l++) d[i][l] = '-';
		}
	}
	return ret;
}

void remove(){
	for(int i=0; i<H; i++){
		for(int j=0; j<W; j++){
			if(d[i][j]=='-'){
				for(int k=i; k>0; k--){
					d[k][j] = d[k-1][j];
				}
				d[0][j] = ' ';
			}
		}
	}
}


int main(){
	cin >> H >> W >> K;
	for(int i=0; i<H; i++){
			cin >> C[i];
	}

	ll ans = 0;
	for(int i=0; i<H; i++){
		for(int j=0; j<W; j++){
			memcpy(d,C,sizeof(C));
			d[i][j] = '-';
			remove();
			int k=0;
			ll s=0,t=0;
			while((s = removable()) > 0){
				//cout << k << " " << s << endl;
				t += s*(1<<k++);
				remove();
			}
			ans = max(ans, t);
		}
	}

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////
 
 
int main(){
    
    ll n;cin>>n;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    sort(a,a+n);
    ll ans=0;
    rep(i,0,n-1){
        rep(j,i+1,n-1){
            ll c=lower_bound(a,a+n,a[i]+a[j])-a-j-1;
            ans+=max(c,0);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
using namespace std;


int main() {
    string s;
    cin>>s;
    char m[5]="ACGT";
    int cur=0;
    int ans=0;
    for(int i=0;i<s.size();++i){
        int ok=0;
        for(int j=0;j<4;++j){
            if(s[i]==m[j])ok=1;
        }
        if(!ok)cur=0;
        else cur++;
        ans=max(cur,ans);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <cstring>
#include <cassert>
#include <list>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <limits>
using namespace std;
typedef long long          ll;
typedef unsigned long long ull;
typedef long double        ld;
typedef pair<int,int>      pii;
typedef pair<ll,ll>        pll;
typedef vector<int>        vi;
typedef vector<long long>  vll;
#define left(x)		   (x << 1)
#define right(x) 	   (x << 1) + 1
#define mid(l, r) 	   ((l + r) >> 1)
#define mp                 make_pair
#define pb                 push_back
#define all(a)             a.begin(),a.end()
#define debug(x)	   {cerr <<#x<<" = " <<x<<"\n"; }
#define debug2(x, y)       {cerr <<#x<<" = " <<x<<", "<<#y <<" = " <<y <<"\n";}
#define debug3(x, y, z)    {cerr <<#x<<" = " <<x<<", "<<#y <<" = " <<y <<", "<<#z<<" = "<<z<<"\n";}
#define debug4(x, y, z, w) {cerr <<#x<<" = " <<x<<", "<<#y <<" = " <<y <<", "<<#z<<" = "<<z<<", "<<#w << " = " <<w <<"\n";}
#define ss                 second
#define ff                 first
#define m0(x) 		   memset(x,0,sizeof(x))

template<typename T >T min_ ( T a , T b ) { return a > b ? b : a ; }
template < typename T ,  typename... Ts > T min_( T first , Ts... last ){ return  min_(first, min_(last...)); }
template<typename T >T max_ ( T a , T b ) { return a > b ? a : b ; }
template < typename T ,  typename... Ts > T max_( T first , Ts... last ){ return  max_(first, min_(last...)); }

template<class T, class S> std::ostream& operator<<(std::ostream &os, const std::pair<T, S> &t) {
	os<<"("<<t.first<<", "<<t.second<<")";
	return os;
}
template<typename T> ostream& operator<< (ostream& out, const vector<T>& v) {
    out << "["; size_t last = v.size() - 1; for(size_t i = 0; i < v.size(); ++i) {
    out << v[i]; if (i != last) out << ", "; } out << "]"; return out;
}

ll pwr(ll base, ll p, ll mod){
ll ans = 1; while(p) { if(p&1) ans=(ans*base)%mod; base=(base*base)%mod; p/=2; } return ans;
}
ll gcd(ll a, ll b) {  return b == 0 ? a : gcd(b,a%b); }
ll lcm(ll a, ll b) {  return a*(b/gcd(a,b)); }

const long double PI = (long double)(3.1415926535897932384626433832795);
const ll  mx_ll   = numeric_limits<ll> :: max();
const int mx_int  = numeric_limits<int> :: max();
const int mod = 1e9+7;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
  //  freopen("text.in", "rb", stdin);
    //freopen("  .out", "wb", stdout);

    int n; cin >> n;
   
    ull fans = 0;
    for(int i = 1; i <= n; ++i) {
    for(int j = 1; j <= n; ++j) {
    for(int k = 1; k <= n; ++k) {
            fans += gcd(i,gcd(j,k));
    }
    }
    }
    cout << fans << endl;
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define N 1000005
using namespace std;

typedef long long ll;

int n, x, dp[N], son[N];

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%d",&n);
	dp[1]=1;
	for(int i = 1; i <= n; i++){
		scanf("%d",&x);
		dp[i] += (1ll*dp[i - 1] + 1ll*(son[x] != i - 1)*dp[son[x]])%mod;
		son[x] = i;
	}
	printf("%d\n", dp[n]);
	return 0;
}

Measured memory_bytes: 5120
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class Main {
	public static void main(String[] args)throws IOException {
		FastReader sc = new FastReader();
		PrintWriter pw = new PrintWriter(System.out);
		String s = sc.next();
		String t = sc.next();
		int count = 0;
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) != t.charAt(i))
				count++;
		}
		System.out.println(count);

	}
}





class FastReader {
	BufferedReader br;
	StringTokenizer st;

	public FastReader() {
		br = new BufferedReader(new
		                        InputStreamReader(System.in));
	}

	String next() {
		while (st == null || !st.hasMoreElements()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException  e) {
				e.printStackTrace();
			}
		}
		return st.nextToken();
	}

	int nextInt() {
		return Integer.parseInt(next());
	}

	long nextLong() {
		return Long.parseLong(next());
	}

	double nextDouble() {
		return Double.parseDouble(next());
	}

	String nextLine() {
		String str = "";
		try {
			str = br.readLine();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return str;
	}
}

Measured memory_bytes: 37452
n = int(input())
values = []
for i in range(n):

	values.append(input().split())

total = 0
for value in values:
	if value[1] == "JPY":
		total += int(value[0])
	if value[1] == "BTC":
		total += float(value[0]) * 380000.0

print(total)

Measured memory_bytes: 3060
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author toshibablack
 */

#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define ll long long int
#define FOR(i, a, b) for(int i=(a);i<=(b);++i)
#define REP(i, n) for(int i=0;i<n;++i)
#define FOREACH(x, a) for(auto& (x) : (a))
#define ALL(a) (a).begin(),(a).end()
#define OUT(x) out << (x) << endl;
#define M0(x) memset(x,0,sizeof(x))
#define MINF(x) memset(x,0x3f,sizeof(x))
#define MMINUS(a) memset(a,0xff,sizeof(a))
#define ten(n) ((int)1e##n)

const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double EPS = 1.0/LINF;
const char ENDL = '\n'; // for JetBrains IDE only supports yen

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

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

using namespace std;

class CSwitches {
public:
    vector<int> sw[11];
    int p[11];
    int N, M;

    void solve(std::istream& in, std::ostream& out) {
        in >> N >> M;
        FOR(i, 1, M) {
            int k; in >> k;
            FOR(j, 1, k) {
                int l; in >> l;
                sw[i].push_back(l);
            }
        }
        FOR(i, 1, M) {
            in >> p[i];
        }

        int ans = 0;

        FOR(bit, 0, (1 << N) - 1) {
            bool ok = true;
            FOR(l, 1, M) {
                int pika = 0;
                FOREACH(s, sw[l]) {
                    pika ^= bit >> (s-1) & 1;
                }
                if (pika != p[l]) {
                    ok = false; break;
                }
            }
            if (ok) ans++;
            ok = true;
        }

        OUT(ans);
    }
};


int main() {
    CSwitches solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


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

int main() {
  string S;
  cin >> S;
  if(S == "SUN") cout << 7 << endl;
  else if(S == "MON") cout << 6 << endl;
  else if(S == "TUE") cout << 5 << endl;
  else if(S == "WED") cout << 4 << endl;
  else if(S == "THU") cout << 3 << endl;
  else if(S == "FRI") cout << 2 << endl;
  else if(S == "SAT") cout << 1 << endl;
}

Measured memory_bytes: 256
public class Main {
	
	public void run(java.util.Scanner sc, java.io.PrintStream out) {
		final int[] d = new int[1001];
		for (int i = 1; i <= 1000; ++i)
			d[i] = d[i - 1] + i;
		
		for (;;) {
			final int N = sc.nextInt();
			if (N == 0) break ;
			
			int res = 0;
			for (int i = 0; i <= 1000; ++i)
			for (int j = i + 2; j <= 1000; ++j) {
				if (d[j] - d[i] == N)
					++res;
			}
			out.println(res);
		}
	}

	public static void main(String[] args) {
		(new Main()).run(new java.util.Scanner(System.in), System.out);
	}

}

Measured memory_bytes: 26864
/*"You can do anything you set your mind to,man" - Eminem*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define llpow(a,b) (ll)(pow(a,b)+0.5)
#define l_b(a,val) min((int)a.size()-1, (int)(lower_bound(a.begin(),a.end(),val)-a.begin()))
#define f first
#define up(a,b) max(a,b)
#define s second
#define INF 9223372036854775807
const  int mod = 1000000007;
template <typename T> T add(T& a, T b){a+=b;while(a>=mod)a-=mod;while(a<0)a+=mod;}
template <typename T> T mul(T& a, T b){ a = a*b%mod;}
template <typename T> T up_self(T& a, T b){a = up(a,b);}
template <typename T> T min_self(T& a, T b){a = min(a,b);}
ll binexpomodulo(ll x, ll y){ll res =1;x%=mod;if(!x)return 0;while(y){if(y&1){mul(res, x);}mul(x,x);y>>=1;}return res;}
ll nCrInOr(ll n, ll r){ll res = 1;if(r>n-r)r = n-r;ll rin = 1;for(ll i = 1; i <=r ; i++)rin = (rin*i)%mod;rin = binexpomodulo(rin,mod-2);for(ll i = 1; i <= r; i++)res = (res*(n-i+1))%mod;res = (res*rin)%mod;return res;}
int msb(ll n){int ans;for(int i = 0 ; i < 64;  i++)if(n&(1LL<<i))ans = i+1;return ans;}
/*All the macros below are copied from nik_y(OG)*/
#define test() int t; cin>>t; while(t--)
#define fl(i,a,b) for(int i = a ; i <b ;i++)
#define Shazam ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define all(c) c.begin(),c.end()
#define endl "\n"
#define get(a,n) fl(i,0,n)  cin>>a[i];
#define pr(a,n) fl(i,0,n) cout<<a[i]<<" ";	cout<<endl;
int main()
{
	Shazam;
	string k; cin>>k;
	int d; cin>>d;

	vector<vector<int>> dp(d,vector<int>(2));
	dp[0][0] = 1;
	for(int i = 0 ; i < k.length(); i++){
		vector<vector<int>> new_dp(d,vector<int>(2));
		for(int sum = 0 ; sum<d; sum++){
			for(bool smaller_already : {false,true}){
				for(int digit = 0; digit<10 ; digit++){
					if(digit>k[i]-'0'&&!smaller_already)
						break;
					add(new_dp[(sum+digit)%d][smaller_already||k[i]-'0'>digit], dp[sum][smaller_already]);
				}
			}
		}
		dp = new_dp;
	}
	ll ans = (dp[0][0]+dp[0][1])%mod;
	ans--;
	if(ans==-1)
		ans = mod-1;
	cout<<ans<<endl;
  	return 0;
}

Measured memory_bytes: 256
#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>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const ll MOD = (ll) (1e9 + 7);
//const ll MOD = 998244353;
const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const double PI = acos(-1.0);

#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") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

void finish() {
    cout << -1 << endl;
    exit(0);
}

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

ll div_down(ll a, ll d) {
    if (a < 0) return -(CEIL(-a, d));
    else return (a / d);
}

ll div_up(ll a, ll d) {
    if (a < 0) return -((-a) / d);
    else return CEIL(a, d);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20) << setiosflags(ios::fixed);

    ll n, k;
    cin >> n >> k;
    ll a[500];
    rep(i, n) cin >> a[i];
    ll sum = 0;
    rep(i, n) sum += a[i];
    set<int> st;
    for (ll i = 1; i <= (ll) sqrt(sum); ++i) {
        if (sum % i == 0) {
            st.insert(i);
            st.insert(sum / i);
        }
    }

    ll ans = 1;

    for (auto g : st) {
        ll dist[500];
        cerr << g << endl;

        rep(i, n) {
            dist[i] = a[i] - (div_down(a[i], g) * g);
        }
        sort(dist, dist + n);
        deque<ll> que;
        rep(i, n) que.push_back(dist[i]);
        ll pos = 0, neg = 0;
        ll cnt = 0;
        while (!que.empty()) {
            if (pos + que.front() <= k) {
                cnt += que.front();
                pos += que.front();
                que.pop_front();

            } else {
                cnt += (que.front() == 0 ? 0 : g - que.front());
                neg += (que.front() == 0 ? 0 : g - que.front());
                que.pop_front();
            }

            if (que.empty()) break;

            if (neg + (que.back() == 0 ? 0 : g - que.back()) <= k) {
                cnt += (que.back() == 0 ? 0 : g - que.back());
                neg += (que.back() == 0 ? 0 : g - que.back());
                que.pop_back();
            } else {
                cnt += que.back();
                pos += que.back();
                que.pop_back();
            }

        }

        if (pos <= k && neg <= k) ans = g;
    }


    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 384
#include <stdio.h>

void f(int x, int y, int z)
{
	 x = x * x;
	 y = y * y;
	 z = z * z;
	 if (x + y == z || y + z == x || z + x == y) {
		printf("YES\n");
	}
	else {
		printf("NO\n");
	}
}

int main(void)
{
	int i;
	scanf("%d", &i);
	int j;
	for (j = 0; j < i; j++) {
		int x, y, z;
		scanf("%d %d %d", &x, &y, &z);
		f(x, y, z);
	}
	return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll k;
  cin >> k;
  if (k < 10) cout << k << endl;
  else {
    queue <ll> q;
    rep(i, 9) q.push(i+1);
    ll count = 9;
    ll res1, res2, res3;
    while (count < k) {
      ll num = q.front(); q.pop();
      if (num%10 == 0) {
        q.push(num*10); q.push(num*10+1);
        res2 = num*10, res3 = num*10+1;
        count += 2;
      } else if (num%10 == 9) {
        q.push(num*10+8); q.push(num*10+9);
        res2 = num*10+8, res3 = num*10+9;
        count += 2;
      } else {
        for (ll i = -1; i <= 1; i++) {
          q.push(num*10 + num%10 + i);
          if (i < 0) res1 = num*10 + num%10 + i;
          if (i == 0) res2 = num*10 + num%10 + i;
          if (i > 0) res3 = num*10 + num%10 + i;
          count++;
        }
      }
    }
    if (count == k) cout << res3 << endl;
    else if (count-1 == k) cout << res2 << endl;
    else cout << res1 << endl;
  }
}

Measured memory_bytes: 4064
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

typedef pair<int,int> pii;

int main() {
  int N, M;
  while(cin >> N >> M,N+M) {
    int r;
    cin >> r;
    vector<pii> v[M+1];
    int p[N+1];
    REP(i,r) {
      int t,n,m,s;
      cin >> t >> n >> m >> s;
      if (s) {
        p[n] = t;
      } else {
        v[m].push_back(pii(p[n],t));
      }
    }
    int q;
    cin >> q;
    REP(i,q) {
      int ts, te, m;
      cin >> ts >> te >> m;
      int aa[1261] = {0};
      FOR(j,v[m]) {
        for(int k=(*j).first; k<(*j).second; k++)
          aa[k] = 1;
      }
      cout << count(aa+ts, aa+te, 1) << endl;
    }
  }
}

Measured memory_bytes: 0
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Abhijeetkns
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AWhiteCells solver = new AWhiteCells();
        solver.solve(1, in, out);
        out.close();
    }

    static class AWhiteCells {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int H = in.nextInt();
            int W = in.nextInt();
            int h = in.nextInt();
            int w = in.nextInt();
            out.println((H - h) * (W - w));
        }

    }
}



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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(auto i=(a);i<(b);++i)
#define RFOR(i,a,b) for(auto i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<bool> VB;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VB > VB2;
typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;

int N;
std::vector< PII > d(1000);
VI2 dp(1003, VI(1003));

int main() {
    while(std::cin >> N, N != 0) {
        REP(i, N) {
            std::cin >> d[i].fst >> d[i].snd;
        }
        std::sort(d.begin(), d.begin() + N);

        int sum = 0;
        REP(i, N-1) {
            //1~N-1までの和
            sum += d[i].fst;
        }
        if(sum >= d[N-1].fst) {
            int ans = 0;
            REP(i, N) {
                ans += (d[i].fst + d[i].snd);
            }
            std::cout  << ans << std::endl;
        } else {
            REP(i, 1003) { 
                REP(j, 1003) { 
                    dp[i][j] = 0;
                }
            }
            dp[0][0] = 1;

            REP(i, N-1) {
                REP(j, d[N-1].fst - sum + 1) {
                    dp[i+1][j] |= dp[i][j];
                    dp[i+1][j + d[i].snd] |= dp[i][j];
                }
            }

            int maxi = 0;
            REP(i, d[N-1].fst - sum + 1) {
                if(dp[N-1][i]) {
                    maxi = std::max(maxi, (int)i);
                }
            }

            int t = d[N-1].fst - sum;
            t -= maxi;

            REP(i, N) {
                t += d[i].snd;
            }
            std::cout << d[N-1].fst + sum + t << std::endl;
        }
    }
}


Measured memory_bytes: 6684
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

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

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    string s;
    cin >> s;
    int n = s.length();

    vector<ll> a;
    if(s[0] == '<') a.push_back(0);
    a.push_back(1);
    for(int i=1;i<n;++i) {
        if(s[i-1] == s[i]) {
            ++a.back();
        } else {
            a.push_back(1);
        }
    }
    
    ll ans = a[0] * (a[0]+1) / 2;
    int m = a.size();
    for(int i=1;i<m;++i) {
        if(i & 1) {
            ans += a[i] * (a[i]+1) / 2;
        } else {
            if(a[i-1] < a[i]) {
                ans -= a[i-1];
                ans += a[i] * (a[i]+1) / 2;
            } else {
                ans += (a[i]-1) * a[i] / 2;
            }
        }
    }

    cout << ans << endl;
}


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

#define ll long long
#define endl "\n"
#define M 1000000007

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll N;
  	cin>>N;
  	cout<<(N+(N*N)+(N*N*N))<<endl;
}

Measured memory_bytes: 3652
n = int(input())
st = []
for i in range(n):
    st.append(list(map(str, input().split())))

x = input()

ans = 0
isSleep = False

for _st in st:
    # print(_st[0])
    if _st[0] == x:
        isSleep = True
        continue
    
    if isSleep==True:
        ans += int(_st[1])

print(ans)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;



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

	string s;
	cin>>s;
	sort(s.begin(),s.end());
	cout<< ((s[0]==s[1] && s[2]==s[3] && s[1]!=s[2]) ? "Yes\n" : "No\n");
}


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

def solve():
    N, A, B, C = list(map(int, input().split()))
    L = []
    for i in range(N):
        L.append(int(input()))

    INF = 10**10

    def dfs(depth, a, b, c):
        """ 各竹を、
        ・Aの合成魔法に使う
        ・Bの合成魔法に使う
        ・Cの合成魔法に使う
        ・使わない

        a:= 現在のAの長さ
        b:= 現在のBの長さ
        c:= 現在のCの長さ

        返り値は、MP
        """
        if depth == N:
            if min(a, b, c) > 0:
                return abs(a-A)+abs(b-B)+abs(c-C) - 30 # 必ず1つは選ばないといけないが、1つ選んだときは合成魔法のMPは必要ないので30引く
            else:
                return INF
        
        ans1 = dfs(depth+1, a, b, c)
        ans2 = dfs(depth+1, a+L[depth], b, c) + 10
        ans3 = dfs(depth+1, a, b+L[depth], c) + 10
        ans4 = dfs(depth+1, a, b, c+L[depth]) + 10

        return min(ans1, ans2, ans3, ans4)

    ans = dfs(0, 0, 0, 0)
    print(ans)

if __name__ == "__main__":
    solve()


Measured memory_bytes: 3064
#include <iostream>

int main(){
	int a, b ,i ,n ;
	while(std::cin>>a>>b){
	i=1;
	for(n=1;a+b>=i*10;n++){
	if(a+b>=i*10){
	i=i*10;
	}
	}
	std::cout<<n<<std::endl;
}
return 0;
}

Measured memory_bytes: 1160
import numpy as np
N = int(input())
C = [6 ** x for x in range(8) if 6 ** x <= N]
C += [9 ** x for x in range(8) if 9 ** x <= N]

dp = np.zeros(N + 1, np.int64)
dp += 10 ** 10

for c in C:
    dp[c] = 1
for c in C:
    for _ in range(9):
        dp[c:] = np.minimum(dp[c:], dp[:-c] + 1)
print(dp[N])

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

using namespace std; 
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>; 

#define INF 1000000000000000000
#define MOD 10007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

int main(){
  int X,Y,Z,K;
  cin>>X>>Y>>Z>>K;
  vector<ll>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];
  sort(rrng(A));
  sort(rrng(B));
  sort(rrng(C));

  vector<ll>AB;
  for(int i=0;i<X;i++){
    for(int j=0;j<Y;j++){
      AB.push_back(A[i]+B[j]);
    }
  }
  sort(rrng(AB));
  vector<ll>ABC;
  for(int i=0;i<Z;i++){
    for(int j=0;j<K&&j<AB.size();j++){
      ABC.push_back(AB[j]+C[i]);
    }
  }
  sort(rrng(ABC));
  for(int i=0;i<K;i++)cout<<ABC[i]<<endl;
  return 0;
}



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

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int Q = sc.nextInt();
		int[] cumulativeSum = new int[999999];
		for (int i = 1; i < cumulativeSum.length; i++) {
			if (isPrime(i) && isPrime((i + 1) / 2)) {
				cumulativeSum[i]++;
			}
			cumulativeSum[i] += cumulativeSum[i - 1];
		}
		StringBuilder ans = new StringBuilder();
		for (int i = 0; i < Q; i++) {
			int l = sc.nextInt();
			int r = sc.nextInt();
			int count = cumulativeSum[r] - cumulativeSum[l - 1];
			ans.append(count);
			if (i < Q - 1) {
				ans.append("\n");
			}
		}
		System.out.println(ans.toString());
	}

	static boolean isPrime(int n) {
		if (n == 1)
			return false;
		for (int i = 2; i * i <= n; ++i) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

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

int main() {
	string	s;
	cin >> s;
	while (s.at(0) != '0')
	{
		int64_t	sum;
		sum = 0;
		rep(i, s.size())
			sum += s.at(i) - '0';
		cout << sum << endl;
		cin >> s;
	}
}



Measured memory_bytes: 3220
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdarg.h>
#include<malloc.h>

int main()
{
	int i, n;
	double x[20], y[20], d[37], s[18], z, S;

	n=0;
	while(scanf("%lf,%lf", &x[n], &y[n]) != EOF)
		n++;

	for(i=0; i<2*n-3; i++){
		if(i % 2 == 0)
			d[i] = sqrt(pow(x[0]-x[i/2+1],2) + pow(y[0]-y[i/2+1],2));
		else
			d[i] = sqrt(pow(x[i/2+1]-x[i/2+2],2) + pow(y[i/2+1]-y[i/2+2],2));
	}

	for(i=0; i<n-2; i++){
		z = (d[2*i] + d[2*i+1] + d[2*i+2]) / 2;
		s[i] = sqrt(z * (z-d[2*i]) * (z-d[2*i+1]) * (z-d[2*i+2]));
	}

	S=0;
	for(i=0; i<n-2; i++)
		S += s[i];

	printf("%f\n", S);

	return 0;
}

Measured memory_bytes: 652
<?php
  fscanf(STDIN,"%d %d %d",$a[0],$a[1],$a[2]);
  sort($a);
  if($a[0] == 5 && $a[1] == 5 && $a[2] == 7){
    echo "YES\n";
  }else{
    echo "NO\n";
  }

Measured memory_bytes: 4728
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		String O = sc.nextLine();
		String G = sc.nextLine();
		String ans = "";
		
		for (int i = 1; i <= O.length(); i++) {
			ans = ans + O.substring(i-1, i);
			if (i > G.length()) {
				break;
			}
			ans = ans + G.substring(i-1, i);
		}
		
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 22996
import collections

N, q = [int(item) for item in input().split()]
input_list = [[item for item in input().split()] for _ in range(N)]

que = collections.deque()
for p, time in input_list:
    que.append([p, int(time)])

finish_time = 0
while que:
    temp = que.popleft()

    if temp[1] - q <= 0:
        finish_time += temp[1]
        print(temp[0], finish_time)

    else:
        finish_time += q
        temp[1] -= q
        que.append(temp)



Measured memory_bytes: 18592
// -----------------------------------
// Author     : MatsuTaku
// Affiliation: Tokushima University
// Country    : Japan
// Date       : 04/04/2020
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n,m; cin>>n>>m;
  vector<int> A(n);
  int sum = 0;
  for (int i = 0; i < n; i++) {
    cin>>A[i];
    sum += A[i];
  }
  int cnt = 0;
  for (auto a : A) {
    if (sum <= 4*m*a)
      cnt++;
  }
  cout << (cnt >= m ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
using namespace std;
int a[200005],v[200005];
int main()
{
	int n,m,i;
	scanf("%d%d",&n,&m);
	for (i=1;i<=m;i++) scanf("%d",&a[i]),v[a[i]]=1;
	for (i=m;i>=1;i--) if (v[a[i]]==1) printf("%d\n",a[i]),v[a[i]]=2;
	for (i=1;i<=n;i++) if (v[i]==0) printf("%d\n",i);
	return 0;
}

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

int main(void){
    int x = 0, y = 0, z = 0; 

    scanf("%d%d%d", &x, &y, &z);

    printf("%d %d %d\n", z, x, y);

    return 0;

} 


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

#define tm tm228
#define hash hash228
#define matr vector < vector < int > >
#define int long long
#define pii pair < int, int >
#define tri pair < pair < int, int >, int >
#define all(v) v.begin(), v.end()
#define endl "\n"

using namespace std;

void solve(){
    string s, tmp;
    cin >> s;
    tmp = s;
    reverse(all(s));
    if (s == tmp)
    {
        int n = s.size();
        string tmp2 = tmp.substr(0, (n - 1) / 2), tmp3 = tmp2;
        reverse(all(tmp3));
        //cout << tmp2 << ' ' << tmp3 << ' ';
        string tmp5 = tmp.substr((n + 3) / 2 - 1, n), tmp6 = tmp5;
        reverse(all(tmp6));
        //cout << tmp5 << ' ' << tmp6 << ' ' ;
        if (tmp2 == tmp3 && tmp6 == tmp5)
        {
            cout << "Yes";
            return;
        }
        else
        {
            cout << "No";
            return;
        }
    }
    else
    {
        cout << "No";
        return;
    }
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int m = 1;
    //cin >> m;
    while (m--)
    {
        solve();
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>

using namespace std;

#define QUEEN 8
#define PUT 1
#define FREE 0

int canput[QUEEN][QUEEN];
bool row[QUEEN];
bool column[QUEEN];
bool diagonal1[2*QUEEN-1];  //??????????????????
bool diagonal2[2*QUEEN-1];  //??????????????????

void initialize(){
    
    for (int i = 0; i < QUEEN; i++) {
        for (int j = 0; j < QUEEN; j++) {
            canput[i][j] = FREE;
        }
    }
    for (int i=0; i < QUEEN; i++) {
        row[i] = column[i] = true;
    }
    
    for (int i=0; i < 2*QUEEN-1; i++) {
        diagonal1[i] = diagonal2[i] = true;
    }
    
}

void print(){
    
    for (int i = 0; i < QUEEN; i++) {
        for (int j = 0; j < QUEEN; j++) {
            if (canput[i][j] == PUT) {
                cout << "Q";
            }
            else{
                cout << ".";
            }
        }
        cout << endl;
    }
    return;
}

void backtrack(int y){
    
    if(y == QUEEN){
        print();
        return;
    }
    
    if (column[y] == false) {
        backtrack(y+1);
        return;
    }
    
    for (int x = 0; x < QUEEN; x++) {
        if (
            canput[y][x] != PUT
            &&
            row[x] == true
            &&
            diagonal1[QUEEN - 1 + x - y] == true
            &&
            diagonal2[x + y] == true
            )
        {
            row[x] = column[y] = diagonal1[QUEEN - 1 + x - y] = diagonal2[x + y] = false;
            canput[y][x] = PUT;
            backtrack(y+1);
            row[x] = column[y] = diagonal1[QUEEN - 1 + x - y] = diagonal2[x + y] = true;
            canput[y][x] = FREE;
        }
    }
    return;
    
}


int main(){
    
    int n, x, y;
    
    initialize();
    
    cin >> n;
    
    for (int i = 0; i < n; i++) {
        cin >> y >> x;
        canput[y][x] = PUT;
        row[x] = false;
        column[y] = false;
        diagonal1[QUEEN - 1 + x - y] = false;
        diagonal2[x + y] = false;
    }
    
    backtrack(0);
    
    return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long

signed main(){
    string S,T,U;
    int A,B;
    cin >> S >> T >>A >> B >>U;
    if(S==U){
        cout <<A-1 <<" "<<B<<endl;
    }
    else{
        cout <<A <<" "<<B-1<<endl;
    }
}

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

#[fastout]
fn main() {
    input! {
        s: String,
    };

    let mut ans = 0;

    for merge in 0..2usize.pow(s.len().saturating_sub(1) as u32) {
        let mut num_string = String::new();
        for i in 0..s.len() {
            num_string.push(s.chars().nth(i).unwrap());
            if merge & (1usize << i)  == 0 {
                // println!("{} {:?}", merge, num_string);
                ans += num_string.parse::<u64>().unwrap_or(0);
                num_string = "".to_string();
            }
        }
        ans += num_string.parse::<u64>().unwrap_or(0);
    }

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


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

const long long int DENOMI = 1000000007;

int main()
{
	int n;
	cin >> n;
	int p = 0, w = 0;
	auto c = vector<int>();
	auto dp = vector<long long int>(n + 1);
	auto next = vector<int>(n + 1);
	auto memo = vector<int>(200001);
	for(auto i = 1; i <= n; ++i){
		int t;
		cin >> t;
		if(t == p) continue;
		++w;
		c.push_back(t);
		next[memo[t]] = w;
		memo[t] = w;
		p = t;
	}
	dp[1] = 1;
	for(auto i = 1; i <= w; ++i){
		dp[i] = (dp[i] + dp[i - 1]) % DENOMI;
		dp[next[i]] = dp[i];
	}
	cout << dp[w] << endl;
	return 0;
}

Measured memory_bytes: 4472
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <iostream>
#include <set>
using namespace std;
#define LL long long
#define mp make_pair
#define pb push_back
#define fi first
#define se second

int n;
int a[200005];

int main(){

	scanf("%d",&n);
	for ( int i = 0; i < n; i++ ) scanf("%d",&a[i]);
	sort(a,a+n);
	for ( int i = 1; i < n; i++ ){
		if ( a[i] == a[i-1] ){
			printf("NO\n");
			return 0;
		} 
	}

	printf("YES\n");
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(void){
    int a,b;
    
    scanf("%d", &a);
    scanf("%d", &b);
    
    -1000<=a,b<=1000;
    
    if (a > b )
        printf("a > b\n");
    
    else if (a < b)
        printf("a < b\n");
    
    else
        printf ("a == b\n");
    
    return 0;
}



Measured memory_bytes: 2140
#include <iostream>
#include <vector>

using namespace std;

int main(){

    int N;
    cin >> N;
    vector<int> B(N - 1);
    for(int i = 0; i < N - 1; i++) cin >> B.at(i);

    int ans = B.front() + B.back();
    for(int i = 0; i < B.size() - 1; i++) ans += min(B.at(i), B.at(i + 1));

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int n , m;
    long long int sum = 0;
    cin >> n >> m;
    for(int i = 0 ; i < m ; i++){
        int x;
        cin >> x;
        sum += x;
    }
    if(sum >= n)
        cout<< "Yes";
    else cout << "No" ;
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) = println(run {
    val n = readLine()!!.toInt()

    val l = LongArray(n+1)
    l[0] = 2
    l[1] = 1
    for (i in 2..n) {
        l[i] = l[i-1] + l[i-2]
    }
    l[n]

})


Measured memory_bytes: 31740