akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i) = 0; (i) < (n); (i)++)

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(a*b, c*d) << endl;
}


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

long long a[100009];

int main(){
  int n,m;
  cin >> n >> m;
  a[0] = 0;
  for(int i=1;i<=n;i++) cin >> a[i];
  for(int i=1;i<=n;i++) a[i] = (a[i]+a[i-1])%m;

  unordered_map<int,int> hash;
  hash[0]++;
  for(int i=1;i<=n;i++){
    hash[a[i]] ++;
  }

  long long ans = 0;
  for(auto& it : hash){
    ans += (long long)(it.second) * (long long)(it.second-1) / 2;
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
	int dp[3][50001] = {}, n, memo[50000];
	bool prime[50000] = {};
	for (int i = 2; i < 50000; i++){
		if (prime[i]) continue;
		for (int j = 2; i*j < 50000; j++){
			if (prime[i * j]) continue;
			prime[i * j] = true;
		}
	}
	dp[0][0] = 1;
	for (int i = 0; i < 2; i++){
		for (int j = 0; j <= 50000; j++){
			if (dp[i][j] == 0) continue;
			int k = 2;
			if (k < j) k = j;
			for (; k < 50000; k++){
				if (prime[k]) continue;
				if (j + k > 50000) break;
				dp[i + 1][j + k] += dp[i][j];
			}
		}
	}
	while (cin >> n, n){
		printf("%d\n", dp[2][n]);
	}
	return 0;
}

Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define si(X) scanf("%d", &(X))
#define sll(X) scanf("%lld",&(X))
#define INFL 0x3f3f3f3f3f3f3f3fLL
const ll mod = 1e9 + 7;
const int M = 2e6 + 5;
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll expo(ll base,ll pow){ll ans = 1;
   if(pow < 0) return 0;
   while(pow!=0){if(pow&1==1){ans = ans*base;ans = ans%mod;}
   base *= base;base%=mod;pow/=2;}return ans;}
ll inv(ll x){return expo(x,mod-2);}
ll mult_mod(ll a , ll b){a = a%mod; b = b%mod;ll c = (a * b)%mod;return c;}
ll add_mod(ll a , ll b){a = (a + mod)%mod;b = (b + mod)%mod;ll c = (a + b)%mod;return c;}
ll fac[(int)(2e6 + 7)] , inv_fac[(int)(2e6 + 7)];
void precomp_factorial(){fac[0] = 1;for(ll i = 1 ; i <= M ; i++) fac[i] = mult_mod(i , fac[i - 1]);
    inv_fac[M] = inv(fac[M]);for(ll i = M - 1 ; i >= 0 ; i--) inv_fac[i] = mult_mod(i + 1 , inv_fac[i + 1]);}
ll nCk(ll n , ll k){ll ans = fac[n];ans = mult_mod(ans , inv_fac[n - k]);ans = mult_mod(ans , inv_fac[k]);return ans;}
int dx[8] = {1 , 0 , -1 , 0 , 1 , -1 , -1 , 1};    // last 4 diagonal
int dy[8] = {0 , 1 , 0 , -1 , 1 , 1 , -1 , -1};

map <pair<int,int>,int> mp;
int main(void)
{
    string s;
    cin >> s;
    for(int i = 1; i < 4; i++){
        if(s[i] == s[i-1]){
            cout << "Bad";
            return 0;
        }
    }
    cout << "Good";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define  vi vector<long long int>
#define  set1 set<long long int>
#define  pb push_back
#define  map1 map<long long int,long long int>
#define  ll  long long int
#define  inf INT_MAX
#define  minf INT_MIN
#define setbits(x) __builtin_popcountll(x)
#define pres(x,y) fixed<<setprecision(y)<<x
#define pair1 pair<long long int,long long int>
#define mk(arr,n,type) type *arr=new type[n];
#define mod 1000000007
#define w(t) long long int t;t=1; while(t--)

ll func(ll a[], ll n) {


	ll dp[n + 1];
	dp[1] = 0;

	for (ll i = 2; i <= n; i++) {

		ll op1 = dp[i - 1] + abs(a[i - 1] - a[i]);
		ll op2 = dp[i - 2] + abs(a[i - 2] - a[i]);
		if (i == 2) {
			op2 = inf;
		}
		dp[i] = min(op1, op2);
	}

	return dp[n];

}

void solve() {

	ll n;
	cin >> n;
	ll a[n + 1];
	for (ll i = 1; i <= n; i++) {
		cin >> a[i];
	}

	cout << func(a, n);

}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	w(t) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 5096
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	string s1, s2, s3, ans;
	cin >> s1 >> s2 >> s3;
	ans = s1[0];
	ans = ans + s2[1];
	ans = ans + s3[2];
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  int n = in();
  vi a(n);
  rep(i,n) cin >> a[i];
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i+1; j < n; ++j) {
      chmax(ans, abs(a[i]-a[j]));
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int a,b;
    
    scanf("%d %d",&a,&b);
    
    if(a%3==0||b%3==0||(a+b)%3==0){
        printf("Possible\n");
    }else{
        printf("Impossible\n");
    }
    
    return 0;
}

Measured memory_bytes: 128
N = int(input())
A = list(int(input()) for _ in range(N))

S = [A[0]]
for i in range(1, N):
    if A[i] <= S[0]:
        S.insert(0, A[i])
        continue
    ok = 0
    ng = len(S)
    tmp = (ok+ng)
    while ok+1 < ng:
        tmp = (ok+ng)//2
        if A[i] > S[tmp]:
            ok = tmp
        else:
            ng = tmp
    S[ok] = A[i]
print(len(S))


Measured memory_bytes: 86548
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define rep(i, b) for(int i = 0; i < b; i++)
#define repr(i, b) for(int i = b - 1 ;i >= 0; i--)
#define It(m) for(auto it = m.begin(); it != m.end(); it++)
#define N 500500
#define PI 3.14159265358979323846264338327950L
#define speed ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
const ll mod = (ll)1e9 + 7;
    
int main(){
    speed;
    ll n, d; cin >> n >> d;
    int cnt = 0;
    d *= d;
    while(n--) {
        ll l, r; cin >> l >> r;
        if(d >= (l * l) + (r * r)) cnt++;
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 3652
n,m=map(int,input().split())
l=[[]for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  l[a-1]+=[[i,a,b]]
for a in range(n):
  l[a].sort(key=lambda x:x[2])
  for i in range(len(l[a])):
    l[a][i][2]=i+1
ll=[]
for i in range(n):
  ll+=l[i]
ll.sort(key=lambda x:x[0])
for i,a,b in ll:
  print("0"*(6-len(str(a)))+str(a)+"0"*(6-len(str(b)))+str(b))
  

Measured memory_bytes: 36124
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int, int>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 1e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<"\n";
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;
	VAR(string, s, t);
	int T = t.size(), S = s.size();
	RREP(i, S - T + 1) {
		bool ok = true;
		REP(j, T) {
			// debug(i);
			// debug(j);
			// debug(s[i + j]);
			// debug(t[j]);
			ok &= (s[i + j] == '?' || s[i + j] == t[j]);
		}
		if (!ok) continue;

		REP(j, T) {
			s[i + j] = t[j];
		}
		REP(i, S) {
			if (s[i] == '?') s[i] = 'a';
		}
		OUT(s)BR;
		return 0;
	}

	OUT("UNRESTORABLE")BR;




	
	
  return 0;
}


Measured memory_bytes: 256
/* Your prologue will be the story. */
/* Copyright by HenryLi */
#include<iostream>
#include<algorithm>
#include<queue>
#include<string>
#include<map>
#include<vector>
#include<set>
#include<sstream>
#include<stack>
#include<ctime>
#include<cmath>
#include<cctype>
#include<climits>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<iomanip>
#include<bitset>
#include<complex>
using namespace std;
template <class _T> inline void read(_T &_x) {
	int _t; bool _flag=false;
	while((_t=getchar())!='-'&&(_t<'0'||_t>'9')) ;
	if(_t=='-') _flag=true,_t=getchar(); _x=_t-'0';
	while((_t=getchar())>='0'&&_t<='9') _x=_x*10+_t-'0';
	if(_flag) _x=-_x;
}
typedef long long LL;
LL gcd(LL a, LL b) {return b ? gcd(b, a % b) : a; }
LL n, x;
int main() {
	//freopen("B.in","r",stdin);
	//freopen("B.out","w",stdout);
	read(n), read(x);
	cout << 3 * (n - gcd(n, x)) << endl;
	return 0;
}



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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	ll n; cin>>n;
	int ret=INT_MAX;
	for (ll x=1; x*x<=n; x++)
		if(n%x==0)
			ret=min(ret,(int) max(to_string(x).size(),to_string(n/x).size()));
	cout<<ret<<"\n";
	return 0;
}

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

using namespace std;
typedef int64_t ll;
typedef uint64_t ull;
typedef long double ld;

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

	ll n;
	cin >> n;
	if(n & 1) {
		cout << 0;
		return 0;
	}

	ll res = 0;
	for(ll i = 10; n/i >= 1; i *= 5)
		res += n/i;

	cout << res;

	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << " ms.\n";
}

// g++ o .cpp -O2 -std=c++11 -D cute -Wall -Wno-unused-result



Measured memory_bytes: 256
import java.io.*;
import java.util.*;

class Main
{
	public static void main(String[] args) throws IOException
	{
		Scan in = new Scan();
		Print out = new Print();
		int n = in.scanInt();
		long total = (n*1l*(n+1))/2;
		int n3 = n/3;
		long mul3 = 3*(n3*1l*(n3+1))/2;
		int n5 = n/5;
		long mul5 = 5*(n5*1l*(n5+1))/2;
		int n15 = n/15;
		long mul15 = 15*(n15*1l*(n15+1))/2;
		out.println(total - mul3 - mul5 + mul15);
		out.close();
	}
}

class Scan
{
	private byte[] buf=new byte[1024];
	private int index;
	private InputStream in;
	private int total;
	public Scan()
	{
		in=System.in;
	}
	public int scan()throws IOException
	{
		if(total<0)
			throw new InputMismatchException();
		if(index>=total)
		{
			index=0;
			total=in.read(buf);
			if(total<=0)
				return -1;
		}
		return buf[index++];
	}
	public int scanInt()throws IOException
	{
		int integer=0;
		int n=scan();
		while(isWhiteSpace(n))
			n=scan();
		int neg=1;
		if(n=='-')
		{
			neg=-1;
			n=scan();
		}
		while(!isWhiteSpace(n))
		{
			if(n>='0'&&n<='9')
			{
				integer*=10;
				integer+=n-'0';
				n=scan();
			}
			else throw new InputMismatchException();
		}
		return neg*integer;
	}
	public double scanDouble()throws IOException
	{
		double doub=0;
		int n=scan();
		while(isWhiteSpace(n))
			n=scan();
		int neg=1;
		if(n=='-')
		{
			neg=-1;
			n=scan();
		}
		while(!isWhiteSpace(n)&&n!='.')
		{
			if(n>='0'&&n<='9')
			{
				doub*=10;
				doub+=n-'0';
				n=scan();
			}
			else throw new InputMismatchException();
		}
		if(n=='.')
		{
			n=scan();
			double temp=1;
			while(!isWhiteSpace(n))
			{
				if(n>='0'&&n<='9')
				{
					temp/=10;
					doub+=(n-'0')*temp;
					n=scan();
				}
				else throw new InputMismatchException();
			}
		}
		return doub*neg;
	}
	public String scanString()throws IOException
	{
		StringBuilder sb=new StringBuilder();
		int n=scan();
		while(isWhiteSpace(n))
			n=scan();
		while(!isWhiteSpace(n))
		{
			sb.append((char)n);
			n=scan();
		}
		return sb.toString();
	}
	private boolean isWhiteSpace(int n)
	{
		if(n==' '||n=='\n'||n=='\r'||n=='\t'||n==-1)
			return true;
		return false;
	}
}

class Print
{
	private final BufferedWriter bw;
	public Print()
	{
		this.bw=new BufferedWriter(new OutputStreamWriter(System.out));
	}
	public void print(Object object)throws IOException
	{
		bw.append(""+object);
	}
	public void println(Object object)throws IOException
	{
		print(object);
		bw.append("\n");
	}
	public void close()throws IOException
	{
		bw.close();
	}
}

Measured memory_bytes: 36540
#include <stdio.h>

int digit_sum(n){
	int Sum = 0;
	while(n > 0){
		Sum += n % 10;
		n /= 10;
	}
	return Sum;
}

int main(){
	int N;
	scanf("%d", &N);
	int S_N;
	S_N = digit_sum(N);
	if(N % S_N) printf("No");
	else printf("Yes");
	
	return 0;
}

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

int d[110][110] = {};
int n, m, inf = 1e9 + 7, a[1010], b[1010], c[1010], ans;
bool used[1010];

void warshall_floyd(int n)
{
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            for (int k = 0; k < n; k++)
            {
                d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
            }
        }
    }
}

int main()
{
    cin >> n >> m;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            d[i][j] = (i == j ? 0 : inf);
        }
    }
    for (int i = 0; i < m; i++)
    {
        scanf("%d%d%d", &a[i], &b[i], &c[i]);
        a[i]--, b[i]--, d[a[i]][b[i]] = c[i], d[b[i]][a[i]] = c[i];
    }
    warshall_floyd(n);
    for (int i = 0; i < n; i++)
    {
        for (int k = 0; k < m; k++)
        {
            used[k] = used[k] || d[i][a[k]] + c[k] == d[i][b[k]] || d[i][a[k]] + c[k] == d[i][b[k]];
        }
    }
    for (int i = 0; i < m; i++)
        ans += !used[i];
    printf("%d\n", ans);
}

Measured memory_bytes: 256
program main
    implicit none
    integer(8):: n, a, b, ans=0
    integer(8):: i,j,k
    integer(8),parameter:: md=1000000007
    integer(8),allocatable:: fn, ifa, ifb, ifna, ifnb, cb, ca

    read*, n, a, b
    fn=1; ifa=1; ifb=1; ifna=1; ifnb=1

    ans = 1
    block;integer(8):: p,ta
        p=n
        ta=2
        do while(p>0)
            if (mod(p,2) == 1) ans=mod(ans*ta,md)
            p=p/2
            ta=mod(ta*ta,md)
        end do
        end block



    ! print*, ans-1, ca, cb
    print*, mod(ans-1 - comb(n,a) - comb(n,b) + 2*md, md)
contains

function comb (a,b) result(ret)
    integer(8):: a,b,ret
    integer(8):: i, x,y
    x=1
    y=1

    do i=0,b-1
        x=mod(x*(a-i),md)
    end do

    do i=1,b
        y=mod(y*i,md)
    end do

    ret = mod(x*inverse(y,md),md)
    
end function


function inverse(x, md) result(inv)
    integer(8),value:: x
    integer(8):: md, inv
    integer(8):: p
    inv=1
    p = md-2

    do while(p > 0)
        if (mod(p,2) == 1) inv = mod(inv*x, md)
        p = rshift(p,1)
        x=mod(x*x,md)
    end do
    
end function


end program


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

int main()
{
	int n;
	cin >> n;
	vector<int> S( n );
	for( int i = 0; i < n; i++ ) {
		cin >> S[i];
	}

	int ans = 0;
	int q;
	cin >> q;
	for( int i = 0; i < q; i++ ) {
		int T;
		cin >> T;
		if( binary_search( S.begin(), S.end(), T ) ) {
			ans++;
		}
	}

	cout << ans << endl;
}



Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
int n;
int a[100005];
int b[100005];
int c[100005];
int vis[100005];
int ind1 = 0,ind2 = 0;
struct node{
    int tmp,num;
}node1[100005],node2[100005];
bool cmp(node a,node b){
    return a.num>b.num;
}
int id1=0,id2=0;
int main(){
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int i=1;i<=n;i+=2){
        b[ind1++]=a[i];
    }
    for(int i=2;i<=n;i+=2){
        c[ind2++] = a[i];
    }
    memset(vis,0, sizeof(vis));
    for(int i=0;i<ind1;i++){
        int num = 0;
        if(!vis[i]){
            num++;
            vis[i]=1;
            for(int j=i+1;j<ind1;j++){
                if(b[j]==b[i]){
                    vis[j]=1;
                    num++;
                }
            }
        }
        node1[id1++]=node{b[i],num};
    }
    memset(vis,0, sizeof(vis));
    for(int i=0;i<ind2;i++){
        int num = 0;
        if(!vis[i]){
            num++;
            vis[i]=1;
            for(int j=i+1;j<ind2;j++){
                if(c[j]==c[i]){
                    vis[j]=1;
                    num++;
                }
            }
        }
        node2[id2++]=node{c[i],num};
    }
    sort(node1,node1+id1,cmp);
    sort(node2,node2+id2,cmp);
    int maxx = 0;
    if(node1[0].tmp!=node2[0].tmp){
        maxx = node1[0].num+node2[0].num;
    } else{
        maxx = max(node1[0].num+node2[1].num,node2[0].num+node1[1].num);
    }
    cout<<n-maxx<<endl;
}



Measured memory_bytes: 2176
#include <iostream>
#include <vector>
using namespace std;
int main() {
    int n, m;
    cin >> n >> m;

    int sum = 0;
    vector <int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }

    int popular = 0;
    for (int i = 0; i < n; i++) {
        if (a[i]*4*m>=sum) {
            popular++;
        }
    }

    cout << (popular >= m ? "Yes" : "No") << endl;
    return 0;
}

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

using namespace std;

int main(int argc, char* argv[])
{
    if(argc == 2 or argc == 3) freopen(argv[1], "r", stdin);
    if(argc == 3) freopen(argv[2], "w", stdout);
    ios::sync_with_stdio(false);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(min(b, d) - max(a, c), 0) << endl;
    return 0;
}


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

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

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

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

signed main() {
  int n, m;
  cin >> n >> m;
  int min = 0, max = 100000;
  REP(i, m) {
    chmax(min, read());
    chmin(max, read());
  }
  if (min > max)
    print(0);
  else
    print(max - min + 1);
}


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

int main(){
  int n, l;
  cin >> n >> l;
  int sum = (n + l + l - 1) * n / 2;
  int mn = 0x7fffffff, ans;
  for (int i = l; i <= n + l - 1; ++i){
    if (abs(i) < mn){
      mn = abs(i);
      ans = sum - i;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  string s;std::cin >> s;
  ll r=0, g=0, b=0, ans = 0;
  re(i, n){
    if(s[i]=='R') r++;
    if(s[i]=='G') g++;
    if(s[i]=='B') b++;
  }
  ans = r*g*b;
  for(ll d=1;d<n;d++){
    for(ll st=0;st<n;st++){
      if(st+2*d>=n) continue;
      char a = s[st];
      char b = s[st+d];
      char c = s[st+2*d];
      if(a!=b&&a!=c&&b!=c) ans--;
    }
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3196
#include<stdio.h>

int main(void){
  int N,X;
  int i;
  scanf("%d%d",&N,&X);
  
  int L[N];
  
  for(i=0;i<N;i++){
    scanf("%d",&L[i]);
  }
  
  int base = 0;
  int count = 0;
  
  while(base<=X&&count<=N+1){
    base+=L[count];
    count++;
  }
  
  printf("%d",count);
  
  return 0;
}
    
    


Measured memory_bytes: 128
// Problem : C - Skolem XOR Tree
// Contest : AtCoder Grand Contest 035
// URL : https://atcoder.jp/contests/agc035/tasks/agc035_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cp-editor)

#include <iostream>
using namespace std;
int main()
{
 int n;
 cin>>n;
 if((n&(n-1))==0)cout<<"No"<<endl;
 else
 {
  cout<<"Yes"<<endl;
  cout<<"1 2"<<endl;
  cout<<"2 3"<<endl;
  cout<<"3 "<<n+1<<endl;
  cout<<n+1<<" "<<n+2<<endl;
  cout<<n+2<<" "<<n+3<<endl;
  for(int i=2;2*i+1<=n;i++)
  {
   cout<<1<<" "<<2*i<<endl;
   cout<<1<<" "<<2*i+1<<endl;
   cout<<2*i<<" "<<2*i+n+1<<endl;
   cout<<2*i+1<<" "<<2*i+n<<endl;
  }
  if(n%2==0)
  {
   for(int i=2;i<=n;i++)
   {
    int p=i^n^1;
    if(p>1&&p<n&&i!=3&&p!=3)
    {
     cout<<i<<" "<<n<<endl;
     cout<<p<<" "<<2*n<<endl;
     break;
    }
   }
  }
 }
 return 0;
}

Measured memory_bytes: 2304
def contains_digit(n: int, d: set):
    flag = False
    while n > 0:
        flag = flag or (n % 10 in d)
        n //= 10
    return flag

N, K = map(int, input().split())
D = set(list(map(int, input().split())))

for i in range(N, N*10):
    if not contains_digit(i, D):
        print(i)
        break

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

vector<ll> v(601);
void init() {
	v[0] = 1;
	rep1(i, 600) {
		if (i % 2)continue;
		v[i] = v[i - 2] * (i - 1) % mod;
	}
}
int s[600];

int n;
ll num[600][600];
void calcsegm() {
	rep(i, 2 * n) {
		rep(j, 2 * n) {
			int c = 0; bool f = true;
			int l = i, r = j; if (r < l)r += 2 * n;
			Rep1(k, l, r) {
				int id = k; if (id >= 2 * n)id -= 2 * n;
				if (s[id] >= 0) {
					int loc = s[id];
					if (loc < l)loc += 2 * n;
					if (loc > r) {
						f = false; break;
					}
				}
				else c++;
			}
			if (f)num[i][j] = v[c];
		}
	}
}
void solve() {
	init();
	int k; cin >> n >> k;
	fill(s, s + 2 * n, -1);
	rep(i, k) {
		int a, b; cin >> a >> b; a--; b--;
		s[a] = b, s[b] = a;
	}
	calcsegm();
	ll ans = v[2*n-2*k];
	rep1(i, 2 * n-1) {
		//cout << ans << endl;
		vector<ll> dp;
		rep(j, n) {
			int l = i + 1 + 2 * j;
			if (l >= 2 * n)break;
			ll cnum = num[i][l];

			rep(x, dp.size()) {
				int le = i + 1 + 2 * x;
				cnum += mod - dp[x] * num[le + 1][l] % mod;
				if (cnum >= mod)cnum -= mod;
			}
			dp.push_back(cnum);
			/*rep(aa, j) {
				int le = i + 1 + 2 * aa;
				cnum += mod - num[i][le] * num[le+1][l] % mod;
				if (cnum >= mod)cnum -= mod;
			}*/
			ll csum = cnum * num[(l + 1)%(2*n)][i - 1] % mod;
			ans += csum; if (ans >= mod)ans -= mod;
			/*Rep(t, j, n) {
				int r = i + 2 + 2 * t;
				if (r > 2 * n)break;
				else if (r == 2 * n)r = 0;
				ll csum = num[i][l];
				csum = csum * num[r][i - 1] % mod;
				if ((l+1)%(2*n)!=r) {
					csum = csum * num[(l + 1)%(2*n)][(r - 1+2*n)%(2*n)] % mod;
				}
				ans += csum; if (ans >= mod)ans -= mod;
			}*/
		}
	}
	cout << ans << endl;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
		return 0;
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int h,w;
    cin>>h>>w;
    char a;
    long long int ans[h+1][w+1];
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            cin>>a;
            if(i==1 && j==1)
                ans[i][j]=1;
            else if(a=='#')
                ans[i][j]=0;
            else if(i==1)
                ans[i][j]=ans[i][j-1];
            else if(j==1)
                ans[i][j]=ans[i-1][j];
            else   
                ans[i][j]=(ans[i-1][j]+ans[i][j-1])%1000000007LL;
        } 
    }   
    cout<<ans[h][w];
}

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
typedef tuple<int, int, int> T;

void solve() {
  int h, w;
  cin >> h >> w;
  vvi m(h, vi(w));
  rep(i, h) {
    string s;
    cin >> s;
    rep(j, w) if (s[j] == '#') m[i][j] = 1;
  }
  dumpv(m, h, w);
  deque<T> q;
  vvi used(h, vi(w, -1));
  if (m[0][0]) {
    q.push_back(T(0, 0, 1));
  } else {
    q.push_back(T(0, 0, 0));
  }
  while (!q.empty()) {
    int i, j, c;
    tie(i, j, c) = q.front();
    q.pop_front();
    if (used[i][j] != -1 && used[i][j] <= c) continue;
    used[i][j] = c;
    if (i < h - 1) {
      if (m[i + 1][j] == m[i][j]) {
        q.push_back(T(i + 1, j, c));
      } else {
        q.push_back(T(i + 1, j, c + 1));
      }
    }
    if (j < w - 1) {
      if (m[i][j + 1] == m[i][j]) {
        q.push_back(T(i, j + 1, c));
      } else {
        q.push_back(T(i, j + 1, c + 1));
      }
    }
    // dumpv(used, h, w);
  }
  cout << (used[h - 1][w - 1] + 1) / 2 << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>

using namespace std;

int r,g,b;
int ans;

int main()
{
	cin >> r >> g >> b;
	ans += (g * 10 )+ b;
	
	if(ans % 4 == 0)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	
	
	
	return 0;
}

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


Measured memory_bytes: 2940
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <signal.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); bool s=false; if(c=='-'){s=true;c=getchar();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); int s=0; if(c=='-'){s=1;c=getchar();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar(); while(c==' '||c=='\n') c=getchar(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar(); } *s='\0'; return len; }

void rsorta_d32(void *base, const int count, const int size, const int index){
	typedef int32_t rsort_t;
	rsort_t (*a)[size] = (rsort_t(*)[size])base;
	rsort_t (*b)[size] = (rsort_t(*)[size])malloc(count*size*sizeof(rsort_t));
	int c[0x100];
	for(int k=0; k<4; k++){
		memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i][index]>>(k<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ int to=--c[(a[i][index]>>(k<<3))&0xFF]; for(int j=0; j<size; j++){ b[to][j]=a[i][j]; } }{rsort_t(*t)[size]=a; a=b; b=t;}
	}
	free(b);
}

int f[100001];
int main(void){
	int n=nextint();
	int q=sqrt(n);
	for(int x=1; x<=q; x++){
		for(int y=1; y<=q; y++){
			for(int z=1; z<=q; z++){
				int now = x*x+y*y+z*z+x*y+y*z+z*x;
				if(now<=n) f[now]++;
			}
		}
	}
	for(int i=1; i<=n; i++){
		printf("%d\n", f[i]);
	}
}


Measured memory_bytes: 2024
#include <stdio.h>


int main(void) {

	int count[4][3][10] = {0};

	int N, i, j, k;


	fscanf(stdin, "%d", &N);

	for (i = 0; i < N; i++) {

		int b, f, r, v;

		fscanf(stdin, "%d %d %d %d", &b, &f, &r, &v);

		count[b - 1][f - 1][r - 1] += v;

	}

	for (i = 0; i < 4; i++) {

		if (i > 0) printf("####################\n");

		for (j = 0; j < 3; j++) {

			for (k = 0; k < 10; k++) {

				printf(" %d", count[i][j][k]);

			}

			printf("\n");

		}

	}

	return 0;
}


Measured memory_bytes: 2108
#include<stdio.h>

int main(){
    int a[4][13];
    char ch;
    int x,y;
    
    for(int b=0;b<4;b++){
        for(int c=0;c<13;c++){
            a[b][c] = 0;
        }
    }
    scanf("%d",&y);
    for(int i=0;i<y;i++){
        scanf("%c",&ch);
        scanf("%c %d",&ch,&x);
        if(ch == 'S'){
            a[0][x-1] = 1;
        } else if(ch == 'H'){
            a[1][x-1] = 1;
        }else if(ch == 'C'){
            a[2][x-1] = 1;
        }else if(ch == 'D'){
            a[3][x-1] = 1;
        }
    }
    for(int j=0;j<13;j++){
            if(a[0][j] == 0) printf("S %d\n",j+1);
    }
    for(int j=0;j<13;j++){
            if(a[1][j] == 0) printf("H %d\n",j+1);
    }
    for(int j=0;j<13;j++){
            if(a[2][j] == 0) printf("C %d\n",j+1);
    }
    for(int j=0;j<13;j++){
            if(a[3][j] == 0) printf("D %d\n",j+1);
    }
    return 0;
}


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

using namespace std;

int main()
{
    int N, i;
    int cnt = 0, idx = 0;
    int result = 0;
    cin >> N;
    vector<int> height(N);
    for (i=0; i<N; i++) {
        cin >> height[i];
    }
    
    while(idx < N) {
        if (idx == N-1) {
            result = max(result, cnt);
            break;
        }
        if (height[idx] >= height[idx+1]) {
            cnt++;
        }
        else {
            result = max(result, cnt);
            cnt = 0;
        }
        idx++;
    }
    
    cout << result << endl;
    return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x, a, b;
  cin >> x >> a >> b;
  if(abs(x - a) < abs(x - b))
    cout << 'A' << endl;
  else
    cout << 'B' << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>
 
#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000
 
using namespace std;
 
 
int main(void) {
	string s;
 
	cin >> s;
 
	if (s.find("AC") != -1) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
 
 
	return 0;
}

Measured memory_bytes: 764
N = int(input())
S = input()
cnt = 0
for i in range(0,1000):
  if i >= 100:
    i = str(i)
  elif i >= 10:
    i = "0" + str(i)
  else:
    i = "00" + str(i)
  checker = 0
  for j in range(N):
    if S[j] == i[checker]:
      checker += 1
    if checker == 3:
      cnt += 1
      break
print(cnt)
      

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

using namespace std;

int main(){

    string s;
    cin >> s;

    int cnt[26] = {0};
    for(int i = 0; i < s.size(); i++){
        cnt[s[i] - 'a'] ++;
    }

    for(int i = 0; i < 26; i++){
        if(cnt[i] >= 2){
            std::cout << "no" << std::endl;
            return 0;
        }
    }

            std::cout << "yes" << std::endl;


}


Measured memory_bytes: 256
N, M = gets.chomp.split.map(&:to_i)
L = []
R = []
M.times do |i|
  l, r = gets.chomp.split.map(&:to_i)
  L.push(l)
  R.push(r)
end
p((R.min < L.max) ? 0 : R.min - L.max + 1)


Measured memory_bytes: 3460
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
#include <stack>
#include <set>
#include <cstdio>
using namespace std;

typedef long long ll;
typedef pair<int,int> P1;
typedef pair<int,P1> P2;
const int inf=1000000000;


int main() {
	int n,t;
	cin>>n>>t;
	int a[100002]={};
	int ma[100002]={};

	for(int i=1;i<n+1;i++)cin>>a[i];
	for(int i=n;i>0;--i){
		ma[i]=max(ma[i+1],a[i]);
	}
	int s=0;
	int d=0;
	for(int i=1;i<n+1;++i){
		if(d<(ma[i]-a[i])){
			s=1;
			d=ma[i]-a[i];
		}else if(d==(ma[i]-a[i])){
			s++;
		}
//		cout<<s<<endl;
	}
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int x,y;
    String ans = "No";

    x = scan.nextInt();
    y = scan.nextInt();

    if(y%2 == 0) {
        if((x * 2) <= y && y <= (x * 4)) {
            ans = "Yes";
        }
    }

    System.out.println(ans);
    scan.close();

}

};


Measured memory_bytes: 35816
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using ll = long long;
int main(){
    ll a,b,k;
    ll ans1,ans2;
    cin>>a>>b>>k;
    if(k>=a+b){
        ans1=0;
        ans2=0;
    }else if(a<=k&&k<a+b){
        ans1=0;
        ans2=b-(k-a);
    }else{
        ans1=a-k;
        ans2=b;
    }
    cout <<ans1<<" "<<ans2<<endl;
}

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

namespace ITP1_2D
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] StringArray = Console.ReadLine().Split(' ');
            int number_W = int.Parse(StringArray[0]);
            int number_H = int.Parse(StringArray[1]);
            int number_x = int.Parse(StringArray[2]);
            int number_y = int.Parse(StringArray[3]);
            int number_r = int.Parse(StringArray[4]);
            Boolean CircleIn = true;

            if ((number_x - number_r) < 0) CircleIn = false;
            else if ((number_x + number_r) > number_W) CircleIn = false;
            else if ((number_y - number_r) < 0) CircleIn = false;
            else if ((number_y + number_r) > number_H) CircleIn = false;

            if (CircleIn == true) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 8996
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long int ll;
#define forn(i,p,n); for(long long i=p;i<n;++i)

void solve(){
	int n;
	cin >> n;
	n>=30?cout<<"Yes":cout<<"No";
	return ;
}
int main()
{
	fast;
	// int test;
	// cin >> test;
	// while(test--){
		solve();
	// 	cout<<"\n";
	// }
}

Measured memory_bytes: 3648
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){
    for(;;){
	int l;
	int m[12];
	int n[12];
	int c=0;
	int ans=0;
	cin>>l;
	if(l==0)break;
	for(int i=0;i<12;i++){
        cin>>m[i]>>n[i];
	}
	for(int i=0;i<12;i++){
        c+=m[i]-n[i];
        if(c>=l){
            ans=i+1;
            break;
        }
	}
	if(ans==0)cout<<"NA"<<endl;
	else cout<<ans<<endl;

    }
	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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


  deque<char> ds;
  string s;
  cin >> s;
  int n = s.size();
  rep(i,n) ds.pb(s[i]);
  int q;
  cin >> q;
  bool rev = false;
  rep(i,q){
    int ty;
    cin >> ty;
    if(ty==1){
      rev = !rev;
    }
    else{
      int f;
      char c;
      cin >> f >> c;
      bool frt;
      if(f==1) frt = true;
      else frt = false;
      frt = frt^rev;
      if(frt) ds.push_front(c);
      else ds.pb(c);
     
    }
  }
  if(!rev){
    rep(i,ds.size()){
      cout << ds[i];
    }
  }
  else{
    rep(i,ds.size()){
      cout << ds[ds.size()-1-i];
    }
  }
  cout << endl;
  return 0;
    

}


Measured memory_bytes: 976
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            List<int> nums = new List<int>();
            for(int i = 0; i < input.Length; i++)
            {
                nums.Add(int.Parse(input[i]));
            }
            int W = nums[0];
            int H = nums[1];
            int x = nums[2];
            int y = nums[3];
            int r = nums[4];
            if (x - r >= 0 && y - r >= 0 && W >= x + r && H >= y + r)
            {
                Console.WriteLine("Yes");
            } else
            {
                Console.WriteLine("No");
            }
           
        }
    }
}



Measured memory_bytes: 15968
#include <iostream>
#include <string>
using namespace std;
int main(){
	int m,d;
	while(true){
	cin>>m>>d;
	if(m==0&&d==0)
		break;
	for(int i=m-1;i>0;i--){
		if(i==1)
			d+=31;
		if(i==2)
			d+=29;
		if(i==3)
			d+=31;
		if(i==4)
			d+=30;
		if(i==5)
			d+=31;
		if(i==6)
			d+=30;
		if(i==7)
			d+=31;
		if(i==8)
			d+=31;
		if(i==9)
			d+=30;
		if(i==10)
			d+=31;
		if(i==11)
			d+=30;
		if(i==12)
			d+=31;
	}
	d=d%7;
	switch(d){
	    case 0:
		cout<<"Wednesday"<<endl;
		break;
		case 1:
		cout<<"Thursday"<<endl;
		break;
		case 2:
		cout<<"Friday"<<endl;
		break;
		case 3:
		cout<<"Saturday"<<endl;
		break;
		case 4:
		cout<<"Sunday"<<endl;
		break;
		case 5:
		cout<<"Monday"<<endl;
		break;
		case 6:
		cout<<"Tuesday"<<endl;
		break;
	}
	}
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// 

int main() {
    int H, W; cin >> H >> W;
    char S[H][W]; REP(i, H) cin >> S[i];

    for (int i = 0; i < H; i++) {
        bool removable = true;
        for (int j = 0; j < W; j++) {
            if (S[i][j] == '#') removable = false;
        }
        if (removable) {
            for (int j = 0; j < W; j++) {
                S[i][j] = '@';
            }
        }
    }

    for (int j = 0; j < W; j++) {
        bool removable = true;
        for (int i = 0; i < H; i++) {
            if (S[i][j] == '#') removable = false;
        }
        if (removable) {
            for (int i = 0; i < H; i++) {
                S[i][j] = '@';
            }
        }
    }


    for (int i = 0; i < H; i++) {
        bool p = false;
        for (int j = 0; j < W; j++) {
            if (S[i][j] != '@') {
                p = true;
                cout << S[i][j];
            }
        }
        if (p) cout << "\n";
    }


    return 0;
}

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

using namespace std;

int count(vector<int> &h){
  int ret = 0;
  int n = h.size();
  bool ever = true;
  while(ever){
    int zero = 0;
    int last = -1;
    for(int i = 0; i < n; i++){
      if(h[i] != 0){
        h[i]--;
        if(i == n - 1){
          ret++;
        }
      }else if(i != last + 1){
        ret++;
        last = i;
        zero++;
      }else{
        last = i;
        zero++;
      }
    }
    if(zero == n){
      ever = false;
    }
  }
  
  return ret;
}

int main(){
  int n;
  cin >> n;
  vector<int> h(n);
  for(int i = 0; i < n; i++) cin >> h[i];
  
  cout << count(h) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int p,n,m,i,k,l,sum=0,o=0;
    scanf("%d",&n);
    int a[n];
    for(p=0;p<n;p++){
        scanf("%d",&a[p]);
    }
    m=n*(n-1)/2;
    int b[m];
    for(i=0;i+1<=n-1;i++){
        k=i+1;
        for(k;k+1<=n;k++){
            b[o]=a[i]*a[k];
            o++;
        }
    }
    for(l=0;l+1<=m;l++){
        sum=sum+b[l];
    }
    printf("%d",sum);
    return 0;
}

Measured memory_bytes: 128
var input = require('fs').readFileSync('/dev/stdin', 'utf8')
var S = Number(input)

var h = Math.floor(S / (60 * 60))
var m = Math.floor((S - h * 60 * 60) / 60)
var s = S % 60

console.log(h + ':' + m + ':' + s)

Measured memory_bytes: 15500
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << ", "
template <typename T> ostream& operator<<(ostream& _o_, const vector<T>& _v_){ \
 if(!_v_.empty()){_o_<<'[';copy(_v_.begin(),_v_.end(),ostream_iterator<T>(_o_,", "));_o_<<"\b\b]";}return _o_;}
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
typedef unsigned int uint;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef unsigned char uchar;
struct secure_hash {
 static uint64_t splitmix64(uint64_t x) {
  x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); }
 size_t operator()(uint64_t x) const {
  static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); } };
template<typename T> using V = vector<T>;
template<typename T, typename U> using umap = unordered_map<T,U,secure_hash>;
template<typename T> using uset = unordered_set<T,secure_hash>;
template<typename T> using min_heap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using max_heap = priority_queue<T>;

int n;
ll k;
const ll M = 1e9+7;

struct Mat {
    V<V<ll>> v;
    Mat() {
        v.assign(n, V<ll>(n));
    }
    Mat operator*(const Mat& m) {
        Mat r;
        rep(i,0,n) rep(j,0,n) rep(k,0,n) {
            r.v[i][k] += v[i][j] * m.v[j][k] % M;
            r.v[i][k] %= M;
        }
        return r;
    }
};

Mat mpow(Mat x, ll y)
{
    if (y == 1) return x;
    if (y % 2 == 0) return mpow(x*x, y/2);
    return x * mpow(x*x, (y-1)/2);
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> k;
    Mat a;
    rep(i,0,n) rep(j,0,n) cin >> a.v[i][j];
    a = mpow(a, k);
    ll ans = 0;
    rep(i,0,n) rep(j,0,n) ans += a.v[i][j];
    cout << ans % M << endl;
}


Measured memory_bytes: 1664
#include<stdio.h>
int main ()
{
    char s[7];
    int i;
    scanf("%s",s);


    if (s[2]==s[3] && s[4]==s[5])
    {
        printf ("Yes\n");
    }
    else
    {
        printf ("No\n");
    }

    return 0;

}


Measured memory_bytes: 128
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();

        char[] C = S.toCharArray();
        for(char c1 : C) {
            int code = (int)c1;
            int code1 = code + N;
            int code2 = 0;
            if (code1 >= 91) {
                code2 = 65 + ((code1 - 65) % 26);
            }
            else {
                code2 = code1;
            }
            char c2 = (char)code2;
            System.out.print(c2);
        }
    }
}

Measured memory_bytes: 25300
#include <bits/stdc++.h>
#define ll long long int
#define endl "\n"
#define mod 1000000007
#define mem(a,val) memset(a,val,sizeof(a))
#define ps(x,noOfDecimal) fixed<<setprecision(noOfDecimal)<<x

using namespace std;
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	std::ios::sync_with_stdio(false);
	int t = 1;
	// cin>>t;
	while (t--) {
		ll n;
		cin >> n;
		n--;
		string ans = "";
		while (n >= 0) {
			int rem = n % 26;
			char ch = (char)('a' + rem);
			ans += ch;
			n /= 26;
			n--;
		}
		reverse(ans.begin(), ans.end());
		cout << ans << endl;

	}
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
inline void IO() {
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
}

int main(int argc, char const *argv[])
{
	//IO();
	
	int x, n; cin >> x >> n;
	unordered_set<int> a;
	for(int i=0 ; i<n ; i++) {
		int m; cin >> m; a.insert(m);
	}

	if(n == 0) cout << x << endl;
	else {
		int curr_diff = INT_MAX, ans = -101;

		for(int i=-101 ; i <= 101 ; i++) {
			if(a.count(i) == 1) continue;
			if(abs(x-i) < curr_diff) {
				curr_diff = abs(x-i); ans = i;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3628