akhauriyash/Code-Regression huggingface dataset:
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
 
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 200105
#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 vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
//ll MOD = 1000000007;
ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
int N;
ll W;
ll dp[101][104514]={0};
int main(){
	cin>>N>>W;
	rep(i, 100)rep(j, 104514)dp[i][j]=1e11+1;
	dp[0][0]=0;
	rep(i,N){
		ll w;
		int v;
		cin>>w>>v;
		rep(value, 104514){
			dp[i+1][value] = dp[i][value];
			if(v <= value){
				dp[i+1][value] = min(dp[i+1][value], dp[i][value-v] + w);
			}
		}
	}
	int ans=0;
	rep(i,104514){
		if(dp[N][i]<=W)ans=i;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 82688
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    string s;
    cin >> s;
    int n = s.size();
    if (n != 26) {
        vector<bool> flg(26, false);
        rep(i, n) flg[s[i]-'a'] = true; 
        cout << s;
        rep(i, 26) {
            if (!flg[i]) {
                cout << (char)(i + 'a') << endl;
                return 0;
            }
        }
    }
    else {
        string t = s;
        if (!next_permutation(t.begin(), t.end())) {
            cout << -1 << endl;
            return 0;
        }
        rep(i, n) {
            cout << t[i];
            if (t[i] != s[i]) {
                cout << endl;
                break;
            } 
        }
    }
    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) {
        cin >> a[i];
        a[i]--;
    }
    vector<ll> dp(n + 1, 0);
    rep(i, n) dp[i + 1] = (dp[i] + a[i]) % k;
    map<ll, vector<ll>> idx;
    rep(i, n) idx[dp[i + 1]].push_back(i);
    ll ans = 0;
    rep(i, n) {
        ll st = lower_bound(all(idx[dp[i]]), i) - idx[dp[i]].begin();
        ll en = lower_bound(all(idx[dp[i]]), i + k - 1) - idx[dp[i]].begin();
        ans += en - st;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 25216
/*

*/
#include<iostream>
#include<iomanip>
#include<ios>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<cstdlib>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)
#define MAX_N 10000

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;
const ll MOD = ll(1e9+7);

int main(){
  int a, b, c;
  cin>>a>>b>>c;
  if((a-b)*(b-c)*(c-a)==0 && !(a==b && b==c))cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  // system("read -n 1 -s -p \"Press any key to continue...\"");
}


Measured memory_bytes: 3632
N=int(input())
p=list(map(int,input().split()))

ans=0
for i in range(N-1):
    if p[i]==i+1:
        p[i],p[i+1]=p[i+1],p[i]
        ans+=1

if p[N-1]==N:
    ans+=1
print(ans)

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

int main() {
    int64_t N;
    std::cin >> N;

    std::ostringstream oss;
    while (N != 0) {
        --N;
        const int64_t r = N % 26;
        N /= 26;

        oss << (char)(r + 'a');
    }

    std::string str = oss.str();
    std::reverse(str.begin(), str.end());
    std::cout << str << std::endl;

    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
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; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};

int main(){
    LL n,k;cin >> n >> k;
    vector<LL> a(n+1,0);
    vector<LL> L(n+2,0), R(n+2,0);
    for (int i = 0; i <= n; i++) {
        a[i] = i;
    }
    for (int i = 0; i < n + 1; i++) {
        L[i + 1] = (L[i] + a[i])%mod;
    }
    for (int i = 0; i < n + 1; i++) {
        R[n - i] = (R[n - i + 1] + a[n - i])%mod;
    }
    LL ans = 0;
    for (int i = k; i <= n + 1; i++) {
        ans = (ans + R[n - i + 1] - L[i] + 1 + mod)%mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8012
#define R register
#include <bits/stdc++.h>

using namespace std;

const int maxn = 10005;

int n, val, ans;
bitset<maxn> f;
int main()
{	
	scanf("%d", &n);
	f[0] = 1;
	for (R int i = 1; i <= n; ++i) scanf("%d", &val), f |= (f << val);
	for (R int i = 1; i <= 10000; ++i) if(i % 10 != 0 && f[i]) ans = max(ans, i);
	printf("%d", ans);
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int a, b, c, asyigfayicgfayfigiaygfciihlogouahefafhalefhlaegfsdgtiagsidgaifdaiyfdygawtyfdqtyfdtywfuastxdugafghsfghxfvaghvsghcdhatsfdta;
    
    scanf("%d %d %d", &a, &b, &c);
    
    if(a > b){
        asyigfayicgfayfigiaygfciihlogouahefafhalefhlaegfsdgtiagsidgaifdaiyfdygawtyfdqtyfdtywfuastxdugafghsfghxfvaghvsghcdhatsfdta = a;
        a = b;
        b = asyigfayicgfayfigiaygfciihlogouahefafhalefhlaegfsdgtiagsidgaifdaiyfdygawtyfdqtyfdtywfuastxdugafghsfghxfvaghvsghcdhatsfdta;
    }
    
    if(b > c){
        asyigfayicgfayfigiaygfciihlogouahefafhalefhlaegfsdgtiagsidgaifdaiyfdygawtyfdqtyfdtywfuastxdugafghsfghxfvaghvsghcdhatsfdta = b;
        b = c;
        c = asyigfayicgfayfigiaygfciihlogouahefafhalefhlaegfsdgtiagsidgaifdaiyfdygawtyfdqtyfdtywfuastxdugafghsfghxfvaghvsghcdhatsfdta;
    }
    
    if(a > b){
        asyigfayicgfayfigiaygfciihlogouahefafhalefhlaegfsdgtiagsidgaifdaiyfdygawtyfdqtyfdtywfuastxdugafghsfghxfvaghvsghcdhatsfdta = a;
        a = b;
        b = asyigfayicgfayfigiaygfciihlogouahefafhalefhlaegfsdgtiagsidgaifdaiyfdygawtyfdqtyfdtywfuastxdugafghsfghxfvaghvsghcdhatsfdta;
    }
    
    printf("%d %d %d\n", a, b, c);
    
    return 0;
}

Measured memory_bytes: 596
//#include "bits/stdc++.h"

#include <iostream>
#include <vector>
// #include <map>
// #include <string>
// #include <algorithm>
// #include <numeric>
// #include <limits>

using namespace std;

int main() {
	int num, h, m, s;
	cin >> num;
	s = num % 60;
	m = num / 60 % 60;
	h = num / 60 / 60;
	cout << h << ":" << m << ":" << s << endl;
	return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define MAX 1000005
#define ll long long
#define upperlimit 1000100
#define INF 1e18
#define eps 1e-8
#define endl '\n'
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define MOD 1000000007LL
#define slld(t) scanf("%lld",&t)
#define sd(t) scanf("%d",&t)
#define pd(t) printf("%d\n",t)
#define plld(t) printf("%lld\n",t)
#define mp(a,b) make_pair(a,b)
#define FF first
#define SS second
#define pb(x) push_back(x)
#define vi vector<int>
#define vll vector<ll>
#define clr(a) memset(a,0,sizeof(a))
#define debug(a) printf("check%d\n",a)
#define csl ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
 
ll gcd(ll n1,ll n2){
	if(n2==0)
		return n1;
	if(n1%n2==0)return n2;
	return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent)
{
	if(exponent<0) exponent+=MOD-1;
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%MOD;
		base=(base*base)%MOD;
		exponent/=2;
	}
	return ans;
}
vi v1,v2;
int dp1[2][17000],dp2[2][17000];
int main()
{
	string s;
	cin>>s;
	int x,y;
	cin>>x>>y;
	bool flag1=false,flag2=false;
	int now=0,cnt=0,i=0;
	while(s[i]=='F')
	{
		x--;
		i++;
	}
	for(;i<s.length();i++)
	{
		if(s[i]=='F')
		{
			now++;
		}
		else
		{
			if(cnt%2==0)
			{
				v1.pb(now);
			}
			else
			{
				v2.pb(now);
			}
			cnt++;
			now=0;
		}
	}
	if(now!=0&&cnt%2==0)
	{
		v1.pb(now);
	}
	else if(now!=0)
	{
		v2.pb(now);
	}
	if(v1.size())
	{
		dp1[0][v1[0]+8000]=1;
		dp1[0][8000-v1[0]]=1;
		for(int i=1;i<v1.size();i++)
		{
			int now=i&1;
			int prev=1-now;
			for(int j=0;j<=16000;j++)
				dp1[now][j]=0;
			for(int j=0;v1[i]+j<=16000;j++)
			{
				if(dp1[prev][j])
					dp1[now][v1[i]+j]=1;
			}
			for(int j=v1[i];j<=16000;j++)
			{
				if(dp1[prev][j])
					dp1[now][j-v1[i]]=1;
			}
		}
		int last=v1.size()-1;
		last&=1;
		if(dp1[last][8000+x]) flag1=true;
	}
	else if(x==0)
		flag1=true;
	if(v2.size())
	{
		dp2[0][v2[0]+8000]=1;
		dp2[0][8000-v2[0]]=1;
		for(int i=1;i<v2.size();i++)
		{
			int now=i&1;
			int prev=1-now;
			for(int j=0;j<=16000;j++)
				dp2[now][j]=0;
			for(int j=0;j<=16000-v2[i];j++)
			{
				if(dp2[prev][j])
					dp2[now][v2[i]+j]=1;
			}
			for(int j=v2[i];j<=16000;j++)
			{
				if(dp2[prev][j])
					dp2[now][j-v2[i]]=1;
			}
		}
		int last=v2.size()-1;
		last&=1;
		if(dp2[last][8000+y]) flag2=true;
	}
	else if(y==0)
		flag2=true;
	if(flag1&&flag2)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL);

int main() {
  FAST;
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  string result = "APPROVED";
  for (int i = 0; i < N; i++) {
    if (A.at(i) % 2 == 0 && !(A.at(i) % 3 == 0 || A.at(i) % 5 == 0)) {
      result = "DENIED";
      break;
    }
  }
  cout << result << endl;
}

Measured memory_bytes: 256
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#define NDEBUG
#endif
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

int main()
{
	ios_init();
	int n, k;
	while(cin >> n >> k) {
		if(k == 1) {
			cout << 0 << endl;
		} else {
			cout << (n - k + 1) - 1 << endl; 

		}
	}
	return 0;
}


Measured memory_bytes: 256
module mod_binary_indexed_tree
  implicit none
  type fenwick_tree
    integer :: n
    integer, pointer :: arr(:) => null()
  end type fenwick_tree
  private
  public :: fenwick_tree, init_bit
  public :: add, summate, update, maximum
contains
  subroutine init_bit(bit,n)
    implicit none
    type(fenwick_tree) :: bit
    integer, intent(in) :: n
    bit%n = n
    allocate(bit%arr(n))
    bit%arr = 0
    return
  end subroutine init_bit
  subroutine add(bit,i,v)
    implicit none
    type(fenwick_tree) :: bit
    integer, intent(in) :: i, v
    integer :: x
    x = i
    do while (x <= bit%n)
      bit%arr(x) = bit%arr(x)+v
      x = x+and(x,-x)
    end do
    return
  end subroutine add
  function summate(bit,i) result(s)
    implicit none
    type(fenwick_tree) :: bit
    integer, intent(in) :: i
    integer :: x, s
    x = i
    s = 0
    do while (x > 0)
      s = s+bit%arr(x)
      x = x-and(x,-x)
    end do
    return
  end function summate
  subroutine update(bit,i,v)
    implicit none
    type(fenwick_tree) :: bit
    integer, intent(in) :: i, v
    integer :: x
    x = i
    do while (x <= bit%n)
      if (bit%arr(x) < v) bit%arr(x) = v
      x = x+and(x,-x)
    end do
    return
  end subroutine update
  function maximum(bit,i) result(m)
    implicit none
    type(fenwick_tree) :: bit
    integer, intent(in) :: i
    integer :: x, m
    x = i
    m = 0
    do while (x > 0)
      m = max(m,bit%arr(x))
      x = x-and(x,-x)
    end do
    return
  end function maximum
end module mod_binary_indexed_tree
program sequence_decomposing
  use mod_binary_indexed_tree
  implicit none
  type(fenwick_tree) :: bit
  integer :: n, a(100000) = 0, t, m = 0, i
  read(*,*) n
  do i = 1, n
    read(*,*) a(i)
    a(i) = -a(i)
  end do
  call compress(a(1:n))
  call init_bit(bit,n)
  do i = 1, n
    t = maximum(bit,a(i))+1
    m = max(m,t)
    call update(bit,a(i),t)
  end do
  write(*,'(i0)') m
  stop
contains
  subroutine compress(x)
    implicit none
    integer, intent(inout) :: x(:)
    integer :: y(size(x),2), i, n, k
    n = size(x)
    y(:,1) = x
    do i = 1, n
      y(i,2) = i
    end do
    call quick_sort(y,1)
    k = 0
    x(y(1,2)) = 1
    do i = 2, n
      if (y(i,1) == y(i-1,1)) k = k+1
      x(y(i,2)) = i-k
    end do
    return
  end subroutine compress
  recursive subroutine quick_sort(a,i)
    implicit none
    integer, intent(inout) :: a(:,:)
    integer, intent(in) :: i
    integer :: p, c(size(a(1,:)))
    integer :: n, l, r, m
    n = size(a(:,1))
    l = 1
    r = n
    m = (l+r)/2
    p = a(l,i)+a(m,i)+a(r,i)-max(a(l,i),a(m,i),a(r,i))-min(a(l,i),a(m,i),a(r,i))
    do
      do while (a(l,i) < p)
        l = l+1
      end do
      do while (a(r,i) > p)
        r = r-1
      end do
      if (l >= r) exit
      c = a(l,:)
      a(l,:) = a(r,:)
      a(r,:) = c
      l = l+1
      r = r-1
    end do
    if (l > 2) call quick_sort(a(1:l-1,:),i)
    if (n > r+1) call quick_sort(a(r+1:n,:),i)
    return
  end subroutine quick_sort
end program sequence_decomposing

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

UL N,K; ULL M;
ULL All;
ULL dp[10][1<<19]={};
ULL ans=0;

UL popcount(UL x){
 x = (x&0x55555555) + ((x>>1)&0x55555555);
 x = (x&0x33333333) + ((x>>2)&0x33333333);
 x = (x&0x0f0f0f0f) + ((x>>4)&0x0f0f0f0f);
 x = (x&0x00ff00ff) + ((x>>8)&0x00ff00ff);
 x = (x&0x0000ffff) + ((x>>16)&0x0000ffff);
 return x;
}

int main(){
 cin>>N>>K>>M;
 All=1; rep(i,N) All=All*K%M;
 if(N>K+K){ cout<<All<<endl; return 0; }
 rep(i,K) dp[i][0]=1;
 rep(m,1<<(K+K-1)){
  rep(p,K){
   dp[p][m] %= M;
   if(popcount(m)==N-1) ans+=dp[p][m];
   rep(j,K){
    UL d=j+K-1-p;
    if(m&(1<<d)) continue;
    dp[j][m|(1<<d)] += dp[p][m];
   }
  }
 }
 ans %= M;
 ans = All+M-ans;
 ans %= M;
 cout<<ans<<endl;
 return 0;
}



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

int N, dp[100005];

int main(){
    cin >> N;
    dp[1] = 1;
    for (int i=2; i<=N; i++) {
        dp[i] = dp[i-1] + 1;
        for (int j=1; j<=N; j++) {
            int p6 = pow(6, j);
            int p9 = pow(9, j);
            if (p6 > i) break;
            dp[i] = min(dp[i], dp[i-p6] + 1);
            if (p9 <= i) {
                dp[i] = min(dp[i], dp[i-p9] + 1);
            }
        }
    }
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
 
int main(){
  ll A,B,C,K;
  cin>>A>>B>>C>>K;
  if(K%2==0){
    cout<<A-B<<endl;
  }
  if(K%2!=0){
    cout<<B-A<<endl;
  }
}   

Measured memory_bytes: 3596
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		int n = Integer.parseInt(str[0]);
		int k = Integer.parseInt(str[1]);
		long s = Long.parseLong(str[2]);

		for (int i = 0; i < k; i++) {
			if (i == 0)
				System.out.print(s);
			else
				System.out.print(" " + s);
		}

		for (int i = 0; i < n - k; i++) {
			if (s == 1000000000)
				System.out.print(" " + (1));
			else
				System.out.print(" " + (s + 1));
		}
		System.out.println();

	}
}

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

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = m - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
using Real = long double;
using Point = complex< Real >;
const Real EPS = 1e-9, PI = acos(-1);

inline bool eq(Real a, Real b) { return fabs(b - a) < EPS; }

Point operator*(const Point &p, const Real &d) {
  return Point(real(p) * d, imag(p) * d);
}

istream &operator>>(istream &is, Point &p) {
  Real a, b;
  is >> a >> b;
  p = Point(a, b);
  return is;
}

ostream &operator<<(ostream &os, Point &p) {
  return os << fixed << setprecision(10) << p.real() << " " << p.imag();
}

// 点 p を反時計回りに theta 回転
Point rotate(Real theta, const Point &p) {
  return Point(cos(theta) * p.real() - sin(theta) * p.imag(), sin(theta) * p.real() + cos(theta) * p.imag());
}

Real radian_to_degree(Real r) {
  return (r * 180.0 / PI);
}
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(10);
  ll res=0,buf=0;
  bool judge = true;
  ld a,b,x;cin>>a>>b>>x;
  ld l=0,r=PI/2;
  while(r-l>=1e-10){
    ld mid=(l+r)/2;
    ld k=b*tan(PI/2-mid);
    ld v;
    if(k<a)v=a*b*b*tan(PI/2-mid)/2;
    else v=a*(a*b-a*a*tan(mid)/2);
    if(v>x)l=mid;
    else r=mid;
  }
  cout<<radian_to_degree(r)<<endl;
  return 0;
}

Measured memory_bytes: 256
///
// File:  a.go
// Author: ymiyamoto
//
// Created on Sun Jun 10 21:01:20 2018
//
package main

import "fmt"

var s int

func main() {
	fmt.Scan(&s)
	if s < 1000 {
		fmt.Println("ABC")
	} else {
		fmt.Println("ABD")
	}

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define END return 0
typedef int64_t ll;
const int mod7 = 1e9 + 7;
const int mod9 = 1e9 + 9;
const int inf = 1 << 30;
const ll INF = 1LL << 60;
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a%b) : abs(a);}
template<typename T> T lcm(T a, T b) {return a / gcd(a, b) * b;}
template<typename T> bool chmax(T &a, T b) {if (a < b) {a = b; return true;} return false;}
template<typename T> bool chmin(T &a, T b) {if (a > b) {a = b; return true;} return false;}
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) {fill((T*)array, (T*)(array+N), val);}

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> s(m);
    rep(i, m) {
        int k;
        cin >> k;
        rep(j, k) {
            int c;
            cin >> c;
            s[i].push_back(c);
        }
    }
    vector<int> p(m);
    rep(i, m) cin >> p[i];
    int ans = 0;
    rep(i, (1 << n)) {
        bool ok = true;
        rep(j, m) {
            int count = 0;
            for(auto ss : s[j])
                if(i & (1 << (ss - 1))) count++;
            if(count % 2 != p[j]) ok = false;
        }
        if(ok) ans++; 
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n, x, y;
    cin >> n >> x >> y;
    vector<int> k(n - 1);
    // 2点の距離を求める
    for(int i = 1; i < n; i++){
        for(int j = i + 1; j <= n; j++){
            // 直接の距離
            int dist1 = j - i;
            // i -> x -> y -> jの距離
            int dist2 = abs(x - i) + 1 + abs(j - y);
            k[min(dist1, dist2) - 1]++;
        }
    }
    for(int i = 0; i < n - 1; i++) cout << k[i] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
#include <cstdio>
#include <tuple>
#include <string>
#include <vector> 
#include <set>
#include <string.h>
#include <map>
using Graph = vector<vector<int>>;
using Graph_Wei = vector<vector<pair<int,int>>>;
using ll = long long;



int main() {

    int s;
    cin >> s;
    bool ans= false;
    for(int i=1;i <=9;i++){
        int p= s % i;
        if(p != 0) continue;
        int q = s/i;
        if(1 <= q && q <= 9) {
            ans = true;
            break;
        }
        
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;

}

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

int main() {
	int n,m,x,y;
	cin >> n >> m >> x >> y;
	int xmax=x;
	int ymin=y;
	int xcity[n] , ycity[m];
	for(int i=0;i<n;i++){
		cin >> xcity[i];
		if(xcity[i]>xmax) xmax = xcity[i];
	}

	for(int i=0;i<m;i++){
		cin >> ycity[i];
		if(ycity[i]<ymin) ymin = ycity[i];
	}

	if(ymin>xmax) cout << "No War" << endl;
	else cout << "War" << endl;

	return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let s = read::<String>();
    if n < 3200 {
        println!("red");
    } else {
        println!("{}", s);
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2100
# 点数は必ずdの組み合わせになる
# 点数を決め売ったときに数列が妥当か決定できる？
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30
from itertools import combinations_with_replacement

def main():
    n, m, q = list(map(int, input().strip().split()))
    a = [0] * q
    b = [0] * q
    c = [0] * q
    d = [0] * q
    for i in range(q):
        a[i], b[i], c[i], d[i] = list(map(int, input().strip().split()))
        a[i] -= 1
        b[i] -= 1
    ans = 0
    for v in combinations_with_replacement(range(1, m+1), n):
        s = 0
        for i in range(q):
            if v[b[i]] - v[a[i]] == c[i]:
                s += d[i]
        ans = max(ans, s)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 68288
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var nm = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var p = (long)Math.Pow(10, 9) + 7;
            var ng = new bool[nm[0] + 1];
            for (var i = 0; i < nm[1]; i++)
            {
                var a = int.Parse(Console.ReadLine());
                ng[a] = true;
            }

            var dp = new long[nm[0] + 1];
            dp[0] = 1;
            for (var i = 0; i < nm[0]; i++)
            {
                for (var j = i + 1; j <= Math.Min(nm[0], i + 2); j++)
                {
                    if (!ng[j])
                    {
                        dp[j] += dp[i];
                        dp[j] %= p;
                    }
                }
            }
            Console.WriteLine(dp[dp.Length - 1]);
        }
    }
}


Measured memory_bytes: 14048
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


class BinaryIndexedTree:
    # 1-indexed
    def __init__(self, n):
        self.n = n
        self.data = [0] * (n + 1)
    
    def add(self, i, x):
        # Accessed by 0-indexed
        i += 1
        while i <= self.n:
            self.data[i] += x
            i += i & -i
    
    def sum(self, i):
        # [0, i)
        res = 0
        while i:
            res += self.data[i]
            i -= i & -i
        return res
    
    def bisect_left(self, w):
        if w <= 0:
            return 0
        i = 0
        k = 1 << (self.n.bit_length() - 1)
        while 0 < k:
            if i + k <= self.n and self.data[i + k] < w:
                w -= self.data[i + k]
                i += k
            k >>= 1
        return i + 1


def solve():
    Q = int(rl())
    queries = [tuple(map(int, rl().split())) for _ in range(Q)]
    
    a = []
    for query in queries:
        if query[0] == 1:
            a.append(query[1])
    sorted_a = sorted(set(a))
    a_to_idx = {val: idx for idx, val in enumerate(sorted_a)}
    idx_to_a = {val: key for key, val in a_to_idx.items()}
    
    N = len(sorted_a)
    bit0 = BinaryIndexedTree(N)
    bit1 = BinaryIndexedTree(N)
    
    b_sm = 0
    cnt = 0
    for query in queries:
        if query[0] == 1:
            _, a, b = query
            bit0.add(a_to_idx[a], a)
            bit1.add(a_to_idx[a], 1)
            b_sm += b
            cnt += 1
        else:
            med_x = idx_to_a[bit1.bisect_left((cnt + 1) // 2) - 1]
            under_sm = bit0.sum(a_to_idx[med_x])
            under_n = bit1.sum(a_to_idx[med_x])
            over_sm = bit0.sum(N) - under_sm
            over_n = bit1.sum(N) - under_n
            print(med_x, abs(under_n * med_x - under_sm) + abs(over_n * med_x - over_sm) + b_sm)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 103764
import sys

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

if 0 in A:
	print(0)
	sys.exit()

tmp = 1
for i in range(N):
	tmp = tmp * A[i]
	if tmp > 1000000000000000000:
		print(-1)
		sys.exit()

print(tmp)

Measured memory_bytes: 21696
#include<bits/stdc++.h>
#define ll         long long
#define fl(i,n)    for(i=0;i<n;i++)
#define fld(i,a,b) for(i=a;i>b;i--)
#define fli(i,a,n) for(i=a;i<n;i++)
#define inp(i,a,n) for(i=0;i<n;i++) {cin>>a[i];}
#define op(i,a,n)  for(i=0;i<n;i++) {cout<<a[i]<<" ";}
#define pb         push_back
#define mp         make_pair
#define F          first 
#define S          second
#define mod        998244353
#define all(x)     x.begin(),x.end()    
#define speedup    ios_base::sync_with_stdio(false),cin.tie(0)
using namespace std;
void comp() {
	ll i,j,k,l,r,n,m;
	cin>>k>>n>>m;
	ll temp=m/k;
	ll temp1=n/k;
	if(temp==temp1 && n%k && m%k) cout<<"NG\n";
	else cout<<"OK\n";
}

int main() {
    speedup;
    ll i=0,t;
    t=1;
    //cin>>t;
    while(t--) {
        comp();
    }
    return 0;
}

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

int main(void){
    int N;
    cin >> N;
    int dp[110000];
    dp[0] = 0;
    for(int i=1; i<=N ;i++){
        dp[i] = min(N, (dp[i-1]+1));
        for(int j=1; pow(6, j)<=i; j++){
            dp[i] = min(dp[i], (dp[i-static_cast<int>(pow(6, j))]+1));
        }
        for(int k=1; pow(9, k)<=i; k++){
            dp[i] = min(dp[i], (dp[i-static_cast<int>(pow(9, k))]+1));
        }
    }
    cout << dp[N] <<endl;
    return 0;
}

Measured memory_bytes: 768
/** Author : Parth Prajapati
 * 	Institute : Pandit Deendayal Petroleum University
**/
#include<bits/stdc++.h>

using namespace std;

#define l long // -2^31 to +2^31-1 (upper limit ~ 2*(10^9))
#define ul unsigned long // 0 to +2^32-1
#define ll long long // -2^63 to +2^63-1 (upper limit ~ 9*(10^18))
#define ull unsigned long long // 0 to +2^64-1
#define mod(x, m) ((((x)%(m))+(m))%(m))
#define vi vector<int>
#define pi pair<int,int>
#define vl vector<ll int>
#define pl pair<ll int,ll int>
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const ll MOD = 1e9 + 7;
const double pie = 3.141592653589793;
const ll int MD = 998244353 ;

#define setcount(x) __builtin_popcount(x) // counts set bits
#define parity(x) __builtin_parity(x) // checks parity of the number
#define lzcount(x) __builtin_clz(x) // count leading zeros in binary representation of number
#define tzcount(x) __builtin_ctz(x) // count trailing zeros in binary representation of number

template<typename T> T inf() { return (T)__builtin_inf();} // syntax for use inf<datatype>();
template<typename T> T gcd(T a,T b){ if(b>a) return gcd(b,a);return b==0?a:gcd(b,a%b); }
template<typename T> T lcm(T a, T b) { return (a*b)/gcd(a,b); }
template<typename T> T fast_power(T x,T y,ll m=MOD){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

string IntToString(ll a){ ostringstream temp; temp << a; return temp.str();}
ll findMMI_fermat(ll n,ll M) {ll ans= fast_power(n,M-2,M);return ans;}//i.e In (a/b)%M..it calculates MMI of b wrt M,only if M is prime
ll add(ll a,ll b,ll M) { return ( mod(a,M ) + mod(b,M ))%M; }
ll sub(ll a, ll b,ll M) { return (mod(a,M ) + M - mod(b,M ))%M; }
ll mult(ll a,ll b,ll M) { return  ( mod(a,M)*mod(b,M) ) %M ; }
bool isprime(ll a){ if(a==2) {return 1;}if(!(a&1) ) {return 0;}for(ll i=3;i*i<=a;i+=2){if(a%i==0) {return 0;} } return 1;} 

/************************** main program **************************/

int main()
{
	FASTIO
	//code
	int i,n;
	string s;
	cin>>n;
	cin>>s;
	for(i=0;i<s.length();++i)
	{
		if(int(s[i])+n > 90)
		{
			cout<<char(int(s[i])+n-90+64);
		}
		else
		cout<<char(int(s[i])+n);
	}
	return 0;
}

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

using namespace std;

template <typename T>
int pow(int x, T n, int mod = std::numeric_limits<int>::max()) {
  int res = 1;
  while (n > 0) {
    if (n & 1) res = static_cast<int64_t>(res) * static_cast<int64_t>(x) % mod;
    x = static_cast<int64_t>(x) * static_cast<int64_t>(x) % mod;
    n >>= 1;
  }
  return res;
}

template <typename T>
int64_t pow(int64_t x, T n, int64_t mod = std::numeric_limits<int64_t>::max()) {
  int64_t res = 1;
  while (n > 0) {
    if (n & 1) res = static_cast<__int128>(res) * static_cast<__int128>(x) % mod;
    x = static_cast<__int128>(x) * static_cast<__int128>(x) % mod;
    n >>= 1;
  }
  return res;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  string S;
  cin >> S;
  int b = 0;
  for (auto s : S) {
    if (s == '1') b++;
  }
  reverse(S.begin(), S.end());
  int x = 0, y = 0;
  for (int i = 0; i < N; i++) {
    if (b - 1 > 0) {
      x += (S[i] - '0') * pow(2, i, b - 1);
      x %= b - 1;
    }
    y += (S[i] - '0') * pow(2, i, b + 1);
    y %= b + 1;
  }
  function<int(int)> rec = [&](int x) {
    if (x == 0) return 0;
    return rec(x % __builtin_popcount(x)) + 1;
  };
  for (int i = N - 1; i > -1; i--) {
    if (S[i] == '1') {
      if (b == 1) {
        cout << 0 << '\n';
      } else {
        cout << rec((x - pow(2, i, b - 1) + (b - 1)) % (b - 1)) + 1 << '\n';
      }
    } else {
      cout << rec((y + pow(2, i, b + 1)) % (b + 1)) + 1 << '\n';
    }
  }
  return 0;
}


Measured memory_bytes: 3744
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <queue>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int IMAX=((1<<30)-1)*2+1;
const double EPS=1e-10;
//int mod=1000000007;




int main(){
	int n;
	vector<pii> v;
	cin>>n;
	for(int i=0; i<n; i++){
		int a,b;
		cin>>a>>b;
		v.pb(mp(b*-1,a));
	}
	sort(all(v));
	cout<<v[0].se<<" "<<v[0].fi*(-1)<<endl;
}

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

bool isvalid1(string s){
    int ano = stoi(s.substr(0, 2));
    int mes = stoi(s.substr(2, 2));
    if(mes >= 1 and mes <= 12) return true;
    else return false;
}

bool isvalid2(string s){
    int mes = stoi(s.substr(0, 2));
    int ano = stoi(s.substr(2, 2));
    if(mes >= 1 and mes <= 12) return true;
    else return false;
}

int main(){
    string s; cin >> s;
    if(isvalid1(s) and isvalid2(s)) cout << "AMBIGUOUS" << endl;
    else if(isvalid1(s)) cout << "YYMM" << endl;
    else if(isvalid2(s)) cout << "MMYY" << endl;
    else cout << "NA" << endl;
	return 0;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
s = gets.chomp.split("")

i = 0
count = 0
while(i < s.length)
    s[i] == '(' ? count += 1 : count -= 1

    if count < 0
        s.unshift('(')
        i += 1
        count = 0
    end
    i += 1
end

puts s.join + ')' * count

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

using namespace std;

int main() {
  int k;
  cin>>k;
  if(k%2==0||k%5==0){
    cout<<-1<<endl;
    return 0;
  }
  int suji=0;
  for(int i=1;i<k+5;i++){
    suji*=10;
    suji+=7;
    suji=suji%k;
    if(suji==0){
      cout<<i<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
  
  
}

Measured memory_bytes: 3636
import math
n,d = map(int, input().split())

X = []
ans = 0

for i in range(n):
    x = list(map(int, input().split()))
    X.append(x)

for i in range(n):
    for j in range(i+1,n):
        d1 = 0
        for k in range(d):
            d1 += (abs(X[i][k] - X[j][k]))**2
        d2 = math.sqrt(d1)
        if d2%1 == 0:
            ans += 1

print(ans)



Measured memory_bytes: 3064
#include <stdio.h>
typedef long long ll;
int main(void)
{
    int e;
    while (scanf("%d", &e), e) {
        int res=(1<<29), x, y, z, m;
        ll tz, ty;
        for(z=0;(tz=(ll)z*z*z)<=e;++z) for(y=0;tz+(ty=(ll)y*y)<=e;++y) {
            x=e-ty-tz;
            m=x+y+z;
            if (m<res) res=m;
        }
        printf("%d\n", res);
    }
    return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

#define PI 3.141592653589793238
#define INF 1050000000

using namespace std;



//cout << fixed << setprecision(15) << << endl;
//cout << << endl;

int main() {

	int a, b, c;

	cin >> a >> b >> c;

	if (a == b && a == c) {
		cout << 1 << endl;
	}
	else if (a == b || a == c || b == c) {
		cout << 2 << endl;
	}
	else {
		cout << 3 << endl;
	}



	return 0;
}

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

int main() {
    int64_t N, A, B; cin >> N >> A >> B;
    int64_t ans, remainder;
    ans = N / (A + B);
    remainder = N % (A + B);
    if (remainder <= A) {
        cout << ans * A + remainder << endl;
    } else {
        cout << ans * A + A << endl;
    }
}

Measured memory_bytes: 256
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <iostream>
using namespace std;
    
void Main()
{
    int n;
    string st;
    cin >> n >> st;
    
    long c = 0;
    char s[n];
    int rgb[3][n];
    int n_rgb[3] = {0};
    for (int i = 0; i < n; i++){
        s[i] = st[i];
        if(s[i]=='R'){
            rgb[0][n_rgb[0]]=i;
            n_rgb[0]++;
        }else if(s[i]=='G'){
            rgb[1][n_rgb[1]]=i;
            n_rgb[1]++;
        }else{
            rgb[2][n_rgb[2]]=i;
            n_rgb[2]++;
        }
    }
    for (int q = 0; q < 3; q++)
    {
        int ni = n_rgb[q%3];
        int nj = n_rgb[(1+q)%3];
        int nk = n_rgb[(2+q)%3];
        int *rgbi = rgb[q%3];
        int *rgbj = rgb[(1+q)%3];
        int *rgbk = rgb[(2+q)%3];
        int sj = 0, sk = 0;
        for (int i = 0; i < ni; ++i)
        {
            sk = 0;
            for (int j = sj; j < nj; ++j)
            {
                int ji = rgbj[j] - rgbi[i];
                if(ji <= 0){
                    sj = j;
                    continue;
                }
                for (int k = nk-1; k >= 0; --k)
                {
                    int kj = rgbk[k]-rgbj[j];
                    if(kj <= 0){
                        break;
                    }
                    if(ji != kj){
                        // cerr << rgbi[i]+1 << " " << rgbj[j]+1 << " " << rgbk[k]+1 << endl;
                        c += 1;               
                    } 
                }
            }
        }
    }
    
    for (int q = 0; q < 3; q++)
    {
        int ni = n_rgb[q%3];
        int nj = n_rgb[(2+q)%3];
        int nk = n_rgb[(1+q)%3];
        int *rgbi = rgb[q%3];
        int *rgbj = rgb[(2+q)%3];
        int *rgbk = rgb[(1+q)%3];
        int sj = 0, sk = 0;
        for (int i = 0; i < ni; ++i)
        {
            sk = 0;
            for (int j = sj; j < nj; ++j)
            {
                int ji = rgbj[j] - rgbi[i];
                if(ji <= 0){
                    sj = j;
                    continue;
                }
                for (int k = nk-1; k >= 0; --k)
                {
                    int kj = rgbk[k]-rgbj[j];
                    if(kj <= 0){
                        break;
                    }
                    if(ji != kj){
                        // cerr << rgbi[i]+1 << " " << rgbj[j]+1 << " " << rgbk[k]+1 << endl;
                        c += 1;               
                    } 
                }
            }
        }
    }
    
    cout << c << endl;
}
    
int main(int argc, char **argv)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    Main();
    return 0;
}

Measured memory_bytes: 3668
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n)
	fmt.Scan(&m)

	arr := make([]int, n)

	var a int
	var total int
	for i := 0; i < n; i++ {
		fmt.Scan(&a)
		arr[i] = a
		total = total + a
	}
	var cnt int

	for i := 0; i < len(arr); i++ {
		if arr[i] * 4 * m >= total {
			cnt = cnt + 1
		}
	}

	if cnt >= m {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
#include<map>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll p, ll n, ll m) {
	if (n == 0) return 1;
	else if (n == 1) return p % m;
	else if (n % 2 == 1) return p * pow_mod(p, n - 1, m) % m;
	else {
		ll tmp = pow_mod(p, n / 2, m);
		return (tmp * tmp) % m;
	}
}

ll gcd(ll x, ll y) {
	if (y == 0) {
		return x;
	}
	return gcd(y, x % y);
}

ll com_mod(ll n, ll k, ll m) {
	if (k == 0) return 1;
	else {
		ll x = 1;
		ll y = 1;
		for (ll i = 0; i < k; i++) {
			x = (x * (n - i)) % m;
			y = (y * (i + 1)) % m;
		}
		ll res = (x * pow_mod(y, m - 2, m)) % m;
		return res;
	}
}

int main() {
	int n; cin >> n;
	if (n == 22) cout << "Christmas Eve Eve Eve";
	else if (n == 23) cout << "Christmas Eve Eve";
	else if (n == 24) cout << "Christmas Eve";
	else if (n == 25) cout << "Christmas";
	return 0;
}

Measured memory_bytes: 3408
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <numeric>
#include <iomanip>

using namespace std;
long long x_s[2000];
long long x_e[2000];
long long y_s[2000];
long long y_e[2000];
int grid[4000][4000];
map <long long, int> x_to_ind;
map <long long, int> y_to_ind;
vector <long long> xs;
vector <long long> ys;
int main(void){
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> x_s[i] >> y_s[i] >> x_e[i] >> y_e[i];
    }

    for(int i = 0; i < N; i++){
        xs.push_back(x_s[i]);
        xs.push_back(x_e[i]);
        ys.push_back(y_s[i]);
        ys.push_back(y_e[i]);
    }
    sort(xs.begin(), xs.end());
    xs.erase(unique(xs.begin(), xs.end()), xs.end());
    sort(ys.begin(), ys.end());
    ys.erase(unique(ys.begin(), ys.end()), ys.end());

    for(int i = 0; i < N; i++){
        for(int j = 0; j < xs.size(); j++){
            if(xs[j] == x_s[i]){
                x_to_ind[x_s[i]] = j;
            }
            if(xs[j] == x_e[i]){
                x_to_ind[x_e[i]] = j;
            }
        }

        for(int j = 0; j < ys.size(); j++){
            if(ys[j] == y_s[i]){
                y_to_ind[y_s[i]] = j;
            }
            if(ys[j] == y_e[i]){
                y_to_ind[y_e[i]] = j;
            }
        }
    }

    for(int i = 0; i < N; i++){
        int x1_ind = x_to_ind[x_s[i]];
        int x2_ind = x_to_ind[x_e[i]];
        int y1_ind = y_to_ind[y_s[i]];
        int y2_ind = y_to_ind[y_e[i]];
        grid[x1_ind][y1_ind] ++;
        grid[x1_ind][y2_ind] --;
        grid[x2_ind][y1_ind] --;
        grid[x2_ind][y2_ind] ++;
    }    

    for(int i = 0; i < xs.size() - 1; i++){
        for(int j = 1; j < ys.size() - 1; j++){
            grid[i][j] += grid[i][j - 1];
        }
    }
    for(int j = 0; j < ys.size() - 1; j++){
        for(int i = 1; i < xs.size() - 1; i++){
            grid[i][j] += grid[i - 1][j];
        }
    }

    long long ans = 0;
    for(int i = 0; i < xs.size() - 1; i++){
        for(int j = 0; j < ys.size() - 1; j++){
            if(grid[i][j] > 0){
                ans += (xs[i + 1] - xs[i]) * (ys[j + 1] - ys[j]);
            }
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 66280
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<int(n);i++)
#define FOR(i,n,m) for(int i=n;i<int(m);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
using namespace std;
 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
 
int vx[]={0,0,-1,1};
int vy[]={1,-1,0,0};
int dx[]={1,0,-1,1,-1,1,0,-1};
int dy[]={1,1,1,0,0,-1,-1,-1};
 
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}	
 
const ll mod=1e9+7;
const int INF=INT_MAX/2;

int main(){
	ll x,k;
	cin>>x>>k;
	ll ans;
	if(k==1){
		cout<<0<<endl;
	}else{
		ans=min(x,k);
		if(x%k<ans)ans=x%k;
		if(abs(ans-k)<ans)ans=abs(ans-k);
		cout<<ans<<endl;
	}
}
 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[60],b[60],c[60],d[60];
int main(){
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)cin>>a[i]>>b[i];
    for(int i=1;i<=m;i++)cin>>c[i]>>d[i];
    for(int i=1;i<=n;i++){
        int ans=1000000000;
        int k;
        for(int j=1;j<=m;j++){
            int t=abs(a[i]-c[j])+abs(b[i]-d[j]);
            if(t<ans){ans=t;k=j;}
        }
        cout<<k<<endl;
    }
    return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;

const ll INF = 1ll<<60;

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

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

    vector<ll> dp(n+1, INF);
    dp[0] = 0;
    for(int pi = 1; pi <= n; pi++){
        int i = pi - 1;
        int low = 1<<30, high = -1;
        for(int j = 0; j < min(m, pi); j++){
            low = min(low, a[i-j]);
            high = max(high, a[i-j]);
            dp[pi] = min(dp[pi], dp[pi-j-1] + k + (ll)(high-low)*(j+1));
        }
    }

    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 3184
#include <iostream>

using namespace std;

int main()
{
	int n, x;

	while (cin >> n >> x, n != 0 || x != 0) {
		int c = 0;
		for (int i = 1; i <= n - 2; i++)
			for (int j = i + 1; j <= n - 1; j++) {
				int k = x - i - j;
				if (j < k)
					k <= n ? c++ : 0;
				else
					break;
			}	
		cout << c << endl;
	}
}

Measured memory_bytes: 3096