akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  int h,w;
  cin >> h >> w;
  vector<vector<char>> pic(h+2,vector<char>(w+2));
  
  rep(i,0,w+2){
    pic[0][i] = '.';
    pic[h+1][i] = '.';
  }
  
  rep(i,0,h+2){
    pic[i][0] = '.';
    pic[i][w+1] = '.';
  }
  
  rep(i,0,h){
    rep(j,0,w){
      cin >> pic[i+1][j+1];
    }
  }
  
  bool ok = true;
  
  rep(i,0,h){
    rep(j,0,w){
      if(pic[i+1][j+1]=='.') continue;
      if(pic[i+1][j+1]=='#') {
        if(pic[i][j+1]=='#') continue;
        if(pic[i+1][j]=='#') continue;
        if(pic[i+2][j+1]=='#') continue;
        if(pic[i+1][j+2]=='#') continue;
        ok = false;
      }
    }
  }
  
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N,A,B;
    string S;
    cin >> N >> A >> B >> S;
    int cnt = 1;
    int res = 0;
    for(int i = 0; i < N; i++) {
        if(S[i] == 'a') {
            if(res < A+B) {
                res++;
                cout << "Yes" << endl;
            }
            else {
                cout << "No" << endl;
            }
        }
        else if(S[i] == 'c') {
            cout << "No" << endl;
        }
        else {
            if(res < A+B && cnt <= B) {
                cnt++;
                res++;
                cout << "Yes" << endl;
            }
            else {
                cout << "No" << endl;
            }
        }
    }
}


Measured memory_bytes: 3728
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int p[N];
set<int> se;
int tr[N];
int lowbit(int x){
    return x&(-x);
}
void add(int x,int k){
    for(int i=x;i<N;i+=lowbit(i)){
        tr[i]+=k;
    }
}
int sum(int x){
    int ans=0;
    for(int i=x;i;i-=lowbit(i)){
        ans+=tr[i];
    }
    return ans;
}
int main(){
    int n,k;
    scanf("%d %d",&n,&k);
    for(int i=1;i<=n;i++) scanf("%d",&p[i]),p[i]++;
    int nanx=0;
    for(int i=1;i<=k;++i){
        se.insert(p[i]);
        nanx+=sum(n)-sum(p[i]);add(p[i],1);
    }
    bool jud=false; if(nanx==0) jud=true;
    int anx=1;
    for(int i=1;i<=n-k;++i){
        bool f1=true,f2=true;
        if(p[i]==(*se.begin())) f1=false;
        se.erase(p[i]);
        if(p[i+k]>(*se.rbegin())) f2=false;
        se.insert(p[i+k]);
        nanx-=sum(p[i])-1;add(p[i],-1);
        nanx+=sum(n)-sum(p[i+k]);add(p[i+k],1);
        if(nanx==0){
            if(!jud) anx++;
            jud=true;
        }
        else if((f1 || f2) ) anx++;
        /*cout<<i<<" "<<anx<<endl;
        cout<<"pp: "<<p[i]<<" "<<p[i+k]<<" "<<nanx<<endl;*/
    }
    printf("%d\n",anx);
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;


const long long INFLL = 1LL << 60;
const int INFI = 1000000000;


int main(){
    int N; cin >> N;
    vector<int> h(N+1);
    for(int i=0;i<N;i++) cin >> h[i];
    h[N] = 0; 
    int ans=0;
    bool flag=true;
    while(flag){
        int count=0; int zero=0;
        bool before;
        for(int i=0;i<N+1;i++){
            if(h[i] == 0){
                if(i!=0 && before)count++;
                zero++;
                before=false;
            }else{
                h[i]--;
                before=true;
            }
        }
        if(zero == N+1) {flag=false; continue;}
        ans+=count;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int[] ary = new int[n];
        
        for (int i=0; i<n; i++) {
            ary[i] = sc.nextInt();
        }
        
        for (int i=n-1; i>=0; i--) {
            if (i == 0)
                System.out.print(ary[i]);
            else
                System.out.print(ary[i] + " ");
        }
        System.out.println();
    }
}


Measured memory_bytes: 26364
#include <iostream>

int main() {
    long N, M;
    std::cin >> N >> M;

    if (N >= 2 && M >= 2) {
        std::cout << (N - 2) * (M - 2) << std::endl;
    } else if (N == 1) {
        std::cout << std::abs(M - 2) << std::endl;
    } else if (M == 1) {
        std::cout << std::abs(N - 2) << std::endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <bitset>

using ll = long long int;
using ul = unsigned long long int;

namespace lamlib
{
	// Absolute
	template<class T> inline T abs(const T &a){ return (a>0) ? a : -a; }
	// GCD: a > b
	ul gcd(ul a,ul b) { return (!b) ? a : gcd(b,a%b); }
}

int main(int argc,char *argv[])
{
	double l;
	std::cin >> l;

	double ans = l/3 * l/3 * l/3;

	std::cout << std::fixed << std::setprecision(15) << ans << std::endl;

	return 0;
}

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

#define FOR(i, a, b) for (int i = a; i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define fst first
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define INIT                                                                   \
    cin.tie(0);                                                                \
    ios::sync_with_stdio(false)
#define int long long

using namespace std;

template <class T = int> T in() {
    T x;
    cin >> x;
    return (x);
}

template <class T> void print(T &x) { cout << x << '\n'; }

int ceil(int a, int b) { return (a + b - 1) / b; }

signed main() {
    INIT;
    auto n = in();
    int a[200000] = {};
    REP(i, n) a[i] = in();

    int ans = 0;
    auto acc_xor = 0;
    auto acc_sum = 0;
    auto r = 0;
    REP(i, n) {
        while (r < n && (acc_xor ^ a[r]) == (acc_sum + a[r])) {
            acc_xor ^= a[r];
            acc_sum += a[r];
            r++;
        }
        ans += r - i;
        acc_xor ^= a[i];
        acc_sum -= a[i];
    }
    print(ans);
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long double ld;

#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rd3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define rl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define F first
#define S second
#define MP make_pair
#define PB push_back

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define inf 10000000000000
#define mod 1000000007
#define maxn 100009
#define maxr 100009
void solve()
{
	double t;
	cin>>t;
	//rl(t);
	double length=t/3;
	t-=length;
	double b=t/2;
	double h=t-b;
	double ans=h*b*length;
	cout<<fixed<<setprecision(20)<<endl;
	cout<<ans<<endl;
	return;
}
int main()
{
	
	ll t=1;
	//rl(t);

	//cin>>t;
	//scanf()
	while(t--)
	{
		solve();
	}
	
	return 0;
}

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


int main()
{
	int n, m, aa, bb;
	int a[100][100];
	int b[100];
	int c[100];
	for (int i = 0; i < 100; i++){
		c[i] = 0;
	}

	cin >> n >> m;
	
	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			cin >> aa;
			a[i][j] = aa;
		}
	}

	for (int i = 0; i < m; i++){
		cin >> bb;
		b[i] = bb;
	}

	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			c[i] = c[i] + (a[i][j] * b[j]);
		}
		cout << c[i] << endl;
	}

	
	return 0;
}


Measured memory_bytes: 3116
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <cmath>
#define ll long long
#define REP(i, x) for(int (i) = 0; (i) < (x); (i) ++)
#define pi 3.1415926535
using namespace std;

int main() {
	ll a, b;
	cin >> a >> b;
	if (a <= 0 && b >= 0) {
		cout << "Zero" << endl;
		return 0;
	}
	if (a > 0) {
		cout << "Positive" << endl;
		return 0;
	}
	if (b < 0) {
		a = -a;
		b = -b;
		if (a % 2 == 0 && b % 2 == 0) {
			cout << "Negative" << endl;
			return 0;
		}
		else if (a % 2 == 1 && b % 2 == 1) {
			cout << "Negative" << endl;
			return 0;
		}
		else {
			cout << "Positive" << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
n,m=gets.split.map &:to_i
p=[];y=[]
m.times{|i|p[i],y[i]=gets.split.map &:to_i}
ans=p.zip(y,(0..m).to_a).sort_by{|x|[x[0],x[1]]}
z=1
for i in 0...m
  (ans[i][3]=z;next) if i==0
  if ans[i-1][0]==ans[i][0]
    z+=1
    ans[i][3]=z
  else
    z=1
    ans[i][3]=z
  end
end
ans=ans.sort_by{|x|x[2]}
m.times{|y|printf("%06d%06d\n",ans[y][0],ans[y][3])}


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

int main()
{
	int64_t n, d;
	cin >> n >> d;
	vector<int64_t> xs(n), ys(n);
	for (int64_t i = 0; i < n; i++)
	{
		cin >> xs[i] >> ys[i];
	}

	int64_t ans = 0;
	for (int64_t i = 0; i < n; i++)
	{
		if (xs[i] * xs[i] + ys[i] * ys[i] <= d * d)
		{
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

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

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

    // priority_queue<int, vector<int>, greater<int>> pque;
    vector<int> nums;
    map<int, ll> num_cnt;

    rep(i, 0, n)
    {
        int a, b;
        cin >> a >> b;

        if (num_cnt.count(a) == 0)
            nums.push_back(a);

        num_cnt[a] += b;
    }
    sort(nums.begin(), nums.end());

    ll cnt = 0;
    int now;
    for (int i = 0; i < nums.size() and cnt < k; i++)
    {
        now = nums[i];
        cnt += num_cnt[now];
    }
    cout << now << endl;
    return 0;
}

Measured memory_bytes: 4476
#include <bits/stdc++.h>
#define rep(i,n) for ((i)=1;(i)<=(n);(i)++)
#define foreach(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();++itr)
using namespace std;
int t,n,m,i,j,fa1[55],fa2[55],deg[55],ans,isl[55];
vector<int> ga[55],gb[55];
void dfs1(int x,int fa){
	fa1[x]=fa;
	foreach(ga[x],i){
		if(*i!=fa) dfs1(*i,x);
	}
}
void dfs2(int x,int fa){
	fa2[x]=fa;
	foreach(gb[x],i){
		if(*i!=fa) dfs2(*i,x);
	}
}
void solve(int x,int y){
	dfs1(y,0);dfs2(x,0);
	fa1[y]=x;fa1[x]=0;
	memset(deg,0,sizeof(deg));
	int i,j,c=0;
	rep(i,n) if(i!=x) deg[fa1[i]]++;
	rep(i,n) if(i!=x&&fa1[i]!=fa2[i]) c++;
	rep(i,c){
		rep(j,n){
			if(j==x) continue;
			if(fa1[j]==fa2[j]) continue;
			if(deg[j]) continue;
			if(fa1[fa2[j]]!=fa2[fa2[j]]) continue;
			break;
		}
		if(j>n) return;
		deg[fa1[j]]--;
		deg[fa2[j]]++;
		fa1[j]=fa2[j];
	}
	ans=min(ans,c+1);
}
int main(){
//	freopen("1.in","r",stdin); 
	cin>>t;
	while(t--){
		cin>>n;
		rep(i,n){
			isl[i]=0;
			ga[i].clear();
			gb[i].clear();
		}
		rep(i,n-1){
			int x,y;
			cin>>x>>y;
			ga[x].push_back(y);
			ga[y].push_back(x);
			isl[x]++;isl[y]++;
		}
		rep(i,n-1){
			int x,y;
			cin>>x>>y;
			gb[x].push_back(y);
			gb[y].push_back(x);
		}
		int f=1;
		dfs1(1,0);dfs2(1,0);
		rep(i,n)if(fa1[i]!=fa2[i]) f=0;
		if(f){
			puts("0");
			continue; 
		}
		ans=0x3f3f3f3f;
		rep(i,n)if(isl[i]==1)rep(j,n)if(i!=j){
			solve(i,j);
		}
		if(ans==0x3f3f3f3f){
			puts("-1");
		}
		else{
			printf("%d\n",ans);
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
const int MAXSIZE = 2e5+7;
const int INF = 0x3fffffff;
int num[MAXSIZE];
int n;
int main(){
	int minc, maxc;
	while(~scanf("%d",&n)){
		for(int i = 0; i < n; i++){
			scanf("%d",&num[i]);
		}
		maxc = -INF;
		minc = num[0];
		for(int i = 1; i < n; i++){
			maxc = max(maxc, num[i]-minc);
			minc = min(minc, num[i]);
		}
		cout<<maxc<<endl;
	}
	return 0;
}


Measured memory_bytes: 3944
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include<unordered_set>
#include<complex>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 500 + 47;

int A[MAX][MAX];
int B[MAX][MAX];
int C[MAX][MAX];
int h, w;
string s;

void print(int A[MAX][MAX])
{
	FOR(i, 0, h)
	{
		FOR(j, 0, w)
		{
			cout << (A[i][j] ? '#' : '.');
		}

		cout << endl;
	}
}
int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);

	cin >> h >> w;
	FOR(i, 0, h)
	{
		cin >> s;
		FOR(j, 0, SZ(s))
		{
			A[i][j] = s[j] == '#';
		}
	}

	FOR(i, 0, h)
	{
		FOR(j, 0, w)
		{
			if (j == w - 1) continue;
			if (j == 0 || (i & 1) || A[i][j])
			{
				B[i][j] = 1;
			}
		}
	}

	FOR(i, 0, h)
	{
		FOR(j, 0, w)
		{
			if (j == 0) continue;
			if (j == w - 1 || (i & 1) == 0 || A[i][j])
			{
				C[i][j] = 1;
			}
		}
	}

	print(B);
	cout << endl;
	print(C);
}


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int uf[1000];

int find(int a){
  if(uf[a]==a) return a;
  else return uf[a]=find(uf[a]);
}

void uni(int a,int b){
  find(a);
  find(b);
  uf[uf[a]]=uf[b];
  return;
}

struct node{
  int s;
  int t;
  int c;
  bool operator<(const struct node& another) const{
    return c<another.c;
  }
};

int main(){
  int n,m;
  while(1){
    cin >> n >> m;
    if(n==0) return 0;
    vector<struct node> e(m);
    int s,t,c;
    for(int i=0;i<n;i++){
      uf[i]=i;
    }
    for(int i=0;i<m;i++){
      cin >> e[i].s >> e[i].t >> e[i].c;
      e[i].s--;
      e[i].t--;
    }
    sort(e.begin(),e.end());
    int count=0;
    vector<int> cost(n-1);
    for(int i=0;i<m;i++){
      if(find(e[i].s)!=find(e[i].t)){
        uni(e[i].s,e[i].t);
        cost[count]=e[i].c;
        count++;
      }
      if(count==n-1){
        cout << cost[n/2-1] << endl;
        break;
      }
    }
  }
  return 0;
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define mod 1000000007
#define int long long
#define inf (1LL<<60)

int dp[500][500];


int slimes(int i, int j, vector<int> &cs) {
	int n = cs.size() - 1;
	if (i >= n || j >= n || i < 0 || j < 0)return 0;
	if (j <= i)dp[i][j] = 0;
	if (dp[i][j] != -1)return dp[i][j];
	int val = inf;
	int k;
	for (k = i; k < j; k++) {
		val = min(val, slimes(i, k, cs) + slimes(k + 1, j, cs));
	}
	return dp[i][j] = cs[j + 1] - cs[i] + val;
}

void solve() {
	int n;
	cin >> n;
	int a[n];
	int i, j;
	for (i = 0; i < n; i++)cin >> a[i];
	vector<int> cs(n + 1);
	cs[0] = 0;
	for (i = 1; i <= n; i++)cs[i] = cs[i - 1] + a[i - 1];

// 	for (i = 0; i <= n; i++)cout << cs[i] << " ";
// 	cout << endl;

	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++)dp[i][j] = -1;
	}

	cout << slimes(0, n - 1, cs);
	return;
}

int32_t main() {

	std::ios::sync_with_stdio(false);
	cout.tie(0);
	cin.tie(0);
	solve();
	return 0;
}

Measured memory_bytes: 5216
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
  string S;
  cin >> S;
  for( int i = 0; i < S.size(); i++ ){
    if( S.at(i) == 'C' ){
      for( int j = i; j < S.size(); j++ ){
        if( S.at(j) == 'F' ){
          cout << "Yes" << endl;
          return 0;
        }
      }
    }
  }
  cout << "No" << endl;
}



Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

int main()
{
    long long a, b, p;
    std::string bs;
    std::cin >> a >> bs;
    int i = 1;
    b = (bs[0] - '0') * 100ll + (bs[2] - '0') * 10ll + (bs[3] - '0') * 1ll;
    long long ans = (a * b / 100);
    std::cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
#define MAX 100005
using namespace std;
 
pair<int, int> p[2][MAX];

int main(){
  int n, a, b;
  scanf("%d", &n);
  for(int i = 0; i < MAX; i++) p[0][i].second = p[1][i].second = i;
  for(int i = 0; i < n; i++){
    scanf("%d", &a);
    p[i&1][a].first++;
  }
  for(int i = 0; i < 2; i++) sort(p[i], p[i] + MAX, greater<pair<int, int>>());
  if(p[0][0].second == p[1][0].second){
    if(p[0][0].first - p[0][1].first < p[1][0].first - p[1][1].first)
      swap(p[0][0], p[0][1]);
    else swap(p[1][0], p[1][1]);
  }
  printf("%d\n", n - p[0][0].first - p[1][0].first);
}


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

#define ALL(c) (c).begin(),(c).end()

void solve(string S){
	if (S == "zyxwvutsrqponmlkjihgfedcba") {
		cout << -1 << endl;
		return;
	}

	vector<int> a(26);
	for(int i = 0; i < S.size(); ++i) {
		a[S[i] - 'a']++;
	}
	if(S.size() < 26) {
		for(int i = 0; ; ++i) {
			if(a[i] == 0) {
				S = S + string(1, 'a' + i);
				break;
			}
		}
		cout << S << endl;
	} else {
		string T = S;
		next_permutation(ALL(T));
		for(int i = 1; i < 26; ++i) {
			if(T.substr(0, i) != S.substr(0, i)) {
				T = T.substr(0, i);
				break;
			}
		}
		cout << T << endl;
	}
}

int main(){	
	string S;
	cin >> S;
	solve(S);
	return 0;
}



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

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

  if (n == k) {
    cout << 0 << endl;
    return 0;
  }

  if (n < k) {
    cout << min(n, k - n) << endl;
    return 0;
  }

  if (n > k) {
    n %= k;
    if (n == 0) {
      cout << 0 << endl;
      return 0;
    } else {
      cout << min(n, k - n) << endl;
      return 0;
    }
  }

  return 0;
}

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

int main(void){
    int n, k;
    std::cin >> n >> k;
    std::vector<int> p(n);

    for(int i = 0; i < n; i++){
	std::cin >> p[i];
    }
    // std::sort(p.rbegin(), p.rend());

    double tmp = 0.0;
    for(int i = 0; i < k; i++){
        tmp += (p[i] + 1.0) / 2.0;
    }

    double ans = tmp;
    for(int i = 1; i <= n - k; i++){
    	tmp = tmp - p[i - 1] / 2.0 + p[i + k - 1] / 2.0;
	ans = std::max(ans, tmp);
    }
    std::cout << std::fixed << std::setprecision(15) << ans << std::endl;
    return 0;
}



Measured memory_bytes: 4052
from collections import Counter

N = int(input())
S = list(input())
ans = 0
for i in range(N):
    L = list(Counter(S[:i]).keys())
    R = list(Counter(S[i:]).keys())
    c = 0
    for l in L:
        if l in R:
            c += 1
    ans = max(ans, c)
print(ans)

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

int main() {
  int N, ans = 0;
  cin >> N;
  long long int D;
  cin >> D;
  for (int i = 0; i < N; i++) {
    long long int X, Y;
    cin >> X >> Y;
    if (X * X + Y * Y <= D * D) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <functional>

using namespace std;


int main() {
  while (true) {
    int n, m;
    cin >> n >> m;
    if (n + m == 0) {
      break;
    }
    vector<int> h(n);
    vector<int> w(m);
    vector<int> t(1500001);
    vector<int> t2(1500001);
    
    for (int i = 0; i < n; i++) {
      cin >> h[i];
    }

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

    for (int i = 0; i < n; i++) {
      int len = 0;
      for (int j = i; j < n; j++) {
        len += h[j];
        t[len]++;
      }
    }

    for (int i = 0; i < m; i++) {
      int len = 0;
      for (int j = i; j < m; j++) {
        len += w[j];
        t2[len]++;
      }
    }

    int ans = 0;
    for (int i = 0; i < 1500001; i++) {
      ans += t[i] * t2[i];
    }

    cout << ans << endl;

  }

  return 0;
}

Measured memory_bytes: 14484
# -*- coding: utf-8 -*-
import numpy as np

# worst order: 101^6 => 10^8

def check(a, b, c):
    flag = True
    for i in range(3):
        for j in range(3):
           if c[i][j]!=a[i]+b[j]:
               flag = False
               return flag

    return flag

c = []
c.append(list(map(int, input().split())))
c.append(list(map(int, input().split())))
c.append(list(map(int, input().split())))

arr_c = np.array(c)
a_max = np.amax(arr_c, axis=1)
b_max = np.amax(arr_c, axis=0)

a = []
b = []
for i in range(3):
    if len(list(range(0, a_max[i]+1, 1)))==0:
        a.append([0])
    else:
        a.append(list(range(0, a_max[i]+1, 1)))
    
    if len(list(range(0, b_max[i]+1, 1)))==0:
        b.append([0])
    else:
        b.append(list(range(0, b_max[i]+1, 1)))

ans = 'No'
cnt = 0
for a0 in a[0]:
    for b0 in b[0]:
        if c[0][0] != a0 + b0:
            continue
        for a1 in a[1]:
            if c[1][0] != a1 + b0:
                continue
            for b1 in b[1]:
                if c[0][1] != a0 + b1 or c[1][1] != a1 + b1:
                    continue   
                for a2 in a[2]:
                    if c[2][0] != a2 + b0 or c[2][1] != a2 + b1:
                        continue
                    for b2 in b[2]:
                        if c[0][2] != a0 + b2 or c[1][2] != a1 + b2 or c[2][2] != a2 + b2:
                            continue

                        print("Yes")
                        exit(0)

print(ans)

Measured memory_bytes: 27192
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 10000000007; //10^9+7

int main(){
  int n;
  cin>>n;
  ll l[90];
  l[0]=2;
  l[1]=1;
  rep(i,2,n+1){
    l[i]=l[i-1]+l[i-2];
  }
  print(l[n]);
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<iterator>
#include<cmath>
#include<string>
#include<algorithm>
#include<sstream>
#include<queue>
#include<list>
#include<deque>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<chrono>


/*  auto start = high_resolution_clock::now();
auto stop = high_resolution_clock::now();
auto duration = duration_cast<milliseconds>(stop - start);
pr(duration.count());    */


#define FastIO      ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define pb          push_back
#define siz         100009
#define mp          make_pair
#define ll          long long int
#define fileout     freopen("output.txt","w",stdout)
#define filein      freopen("input.txt","r",stdin)
#define pi          acos(-1.0)
#define all(x)      x.begin(),x.end()
#define ull		    unsigned long long int
#define m(a)	    memset(a,0,sizeof(a))
#define f(i,n)	    for(ll i=0;i<n;i++)
#define sc(a)	    scanf("%lld",&a)
#define pr(a)	    printf("%lld\n",a)
const ll inf = 1e15;
using namespace std;

int main()
{
	FastIO;
	ll a, co, b, t, i, j, k, n,d[10006];
	string st;
	multimap<string, pair<ll,ll>>m;
	set<pair<ll,ll>>s;
	vector<ll>v;
	cin >> n;
	f(i, n)
	{
		cin >> st >> a;
		m.insert({ st,{a ,i} });
	}
	auto ii = m.begin();
	ii++;
	for (auto it=m.begin();it!=m.end();it++)
	{
		if (ii != m.end() && it->first == ii->first)
		{
			s.insert({ it->second.first,it->second.second });
		}
		else
		{
			s.insert({ it->second.first,it->second.second });
			for (auto is = s.rbegin(); is != s.rend(); is++)
			{
				v.push_back(is->second+1);
			}
			s.clear();
		}
		if (ii != m.end())
			ii++;
	}
	f(i, v.size())
		cout << v[i] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;
 
 
int main(){
    double R; cin >> R;
 
    cout << setprecision(10);
    cout << 2 * R * 3.141592 << endl;
}

Measured memory_bytes: 3788
N = int(input())
S = [input() for _ in range(N)]
 
# 文字列にABが入ってる数 + 組み合わせて入る数
# 文字列にABが入ってる数 + f(Aで終わる数, Bで始まる数, Bで始まりAで終わる数)
include = 0
sb = 0
fa = 0
sbfa = 0
for s in S:
    include += s.count('AB')
    if s[0] == 'B' and s[-1] == 'A':
        sbfa += 1
    elif s[0] == 'B':
        sb += 1
    elif s[-1] == 'A':
        fa += 1

def calc_comb(sb, fa, sbfa):
    if sbfa == 0:
        return min(sb, fa)
    elif max(sb, fa)==0:
        return sbfa -1
    else:
        return sbfa + min(sb, fa)

print(include + calc_comb(sb, fa, sbfa))


Measured memory_bytes: 9560
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
	int a;
	cin>>a;
	if(a>=195)cout<<5;
	else{
		if(a>=189)cout<<4;
		else{
			if(a>=165)cout<<3;
			else{
				if(a>=135)cout<<2;
				else{
					if(a>=105)cout<<1;
					else cout<<0;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 384
#include <vector>
#include <iostream>
#include <cstdio>
typedef long long ll;
using namespace std;
int main() {
  ll n = 0;
  vector<ll> v(5, 0);
  cin >> n;
  for(int i = 0; i < 5; ++i) {
    cin >> v[i];
  }
  ll m = v[0];
  for(int i = 1; i < 5; ++i) {
    m = min(m, v[i]);
  }
  ll res = 4 + ((n + m - 1) / m);
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
N=10**5
A=[1 for i in range(N+1)]
for i in range(2,N+1):
    if A[i]==0:
        continue
    for j in range(i,N+1,i):
        if i==j:
            continue
        A[j]=0
P=set()
for i in range(2,N+1):
    if A[i]==1:
        P.add(i)
B=[0 for i in range(N+1)]
for i in range(3,N+1,2):
    if i in P and (i+1)//2 in P:
        B[i-1]=1
S=[0 for i in range(N+1)]
for i in range(N):
    S[i+1]=B[i]+S[i]
Q=int(input())
for line in range(Q):
    l,r=map(int,input().split())
    print(S[r]-S[l-1])


Measured memory_bytes: 8884
'use strict';

// PROCESS
function caesar(cipherText) {
    var plainText = '';

    // buf is ASCII code
    var buf;

    for(var i = 0; i < cipherText.length; i++)
    {
        buf = cipherText.charCodeAt(i) - 3;
        if (buf < 65) {
            buf += 26;
        }
        plainText += String.fromCharCode(buf);
    }
    
    return plainText;
}

// IO (RAW)
/*
require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
}).on('line', (line) => console.log(caesar(line.trim())));
*/
require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n').forEach(function (item) {
    console.log(caesar(item));
});

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

#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define watch(x) cout<<(#x)<<" is "<<(x)<<"\n"
#define print(v) for(auto i=v.begin();i!=v.end();i++)cout<<*i<<" ";cout<<"\n";
#define show(a,b) cout<<(#a)<<" is "<<(a)<<" "<<(#b)<<" is "<<(b)<<"\n"
#define M_PI 3.14159265358979323846
#define ll long long int
#define pb push_back
#define mp make_pair
#define f first
#define ss second
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef pair<pi,pi> ppi;
typedef pair<ll,ll> pl;
typedef pair<ll,pl> pll;

void solve()
{
    int n;
    cin>>n;
    vector<vector<int>> a(n,vector<int>(3));
    for(int i=0;i<n;i++)
    cin>>a[i][0]>>a[i][1]>>a[i][2];
    vector<vector<int>> dp(n,vector<int>(3));
    dp[0][0]=a[0][0];
    dp[0][1]=a[0][1];
    dp[0][2]=a[0][2];
    for(int i=1;i<n;i++)
    {
        dp[i][0]=max(a[i][0]+dp[i-1][1],a[i][0]+dp[i-1][2]);
        dp[i][1]=max(a[i][1]+dp[i-1][0],a[i][1]+dp[i-1][2]);
        dp[i][2]=max(a[i][2]+dp[i-1][1],a[i][2]+dp[i-1][0]);
    }
    int ans=max(dp[n-1][0],dp[n-1][1]);
    ans=max(ans,dp[n-1][2]);
    cout<<ans<<"\n";
}

int main()
{
    fast;
    //int test;
    //cin>>test;
    //while(test--)
    //{
        solve();
    //}
    return 0;
}

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

int main() {
  int x;
  cin >> x;

  // ここにプログラムを追記
  if (x >= 30) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int n, m, q;
vector<int> a, b, c, d;
int ans = 0;

void dfs(vector<int> A) {
  if(A.size() == n + 1) {
    int tot = 0;
    rep(i, q) {
      if(A[b[i]] - A[a[i]] == c[i]) {
        tot += d[i];
      }
    }
    ans = max(tot, ans);
    return;
  }
  A.push_back(A.back());
  while(A.back() <= m) {
    dfs(A);
    A.back()++;
  }
}

int main() {
  cin >> n >> m >> q;
  a = b = c = d = vector<int>(q);
  rep(i, q) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  dfs(vector<int>(1,1));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3536
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef pair<ll, ll> P;

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976

ll dp[55][55][2550];

int main()
{
    int n,a; cin >> n >> a;
    int x[n];
    int lim = 0;
    rep(i,n) {
        cin >> x[i];
        lim = max(lim,x[i]*n);
    }
    dp[0][0][0] = 1;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            for(int k = 0; k < lim; k++){
                dp[i+1][j][k] += dp[i][j][k];
                dp[i+1][j+1][k+x[i]] += dp[i][j][k];
            }
        }
    }
    ll ans = 0;
    rep(i,n+1){
        ans += dp[n][i][a*i];
    }
    cout << ans-1 << endl;
}

Measured memory_bytes: 56448
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

int main(){
	int n,m;
	bool f=true;
	char s[51][51];
	int a[51][51]={};
	cin>>n>>m;
	REP(i,n){
		cin>>s[i];
	}
	REP(i,n)REP(j,m){
		if(s[i][j]=='.'){
			a[i][j]=-1;
		}
	}
	for(int i=0;i<n;i++){
		for(int j=1;j<m-1;j++){
			if(s[i][j-1]==s[i][j]&&s[i][j]=='#'){
				a[i][j-1]=1,a[i][j]=1;
			}
			if(s[i][j]==s[i][j+1]&&s[i][j]=='#'){
				a[i][j]=1,a[i][j+1]=1;
			}
		}
	}
	for(int i=1;i<n-1;i++){
		for(int j=0;j<m;j++){
			if(s[i-1][j]==s[i][j]&&s[i][j]=='#'){
				a[i-1][j]=1,a[i][j]=1;
			}
			if(s[i+1][j]==s[i][j]&&s[i][j]=='#'){
				a[i+1][j]=1,a[i][j]=1;
			}
		}
	}
	REP(i,n)REP(j,m){
		if(a[i][j]==0){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

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

int main() {
    int A, B, K, count = 0;
    cin >> A >> B >> K;
    for(int i = min(A,B); i > 0;--i){
        if(A%i==0&&B%i==0)
            count++;
        if(count == K){
            cout << i << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
s = "ABCDE*"
while 1:
    m = 0; n = 5;
    for i in xrange(5):
        s1,s2 = map(int, raw_input().split())
        if i==0 and s1==s2==0: break
        if m<s1+s2:
            m = s1+s2; n = i;
    if m==0: break
    print s[n],m

Measured memory_bytes: 4204
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let (n, x, y) = i.read3::<isize, isize, isize>();

    writeln!(o, "{} {}", min(x, y), max(x + y - n, 0)).unwrap();
}

mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        { $f:ident($($t:ident),*) } => {
            #[allow(dead_code)]
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                ($(read_next::<$t,_>(i)),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        fn_read! { read2(T1, T2) }
        fn_read! { read3(T1, T2, T3) }
        fn_read! { read4(T1, T2, T3, T4) }
        fn_read! { read5(T1, T2, T3, T4, T5) }
    }
    fn read_next<'a, T: FromStr, I: Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }

}


Measured memory_bytes: 4352
n,m = (int(i) for i in input().split())
h = [int(i) for i in input().split()]
maxTower = [1] * n 

for i in range(m):
	a,b = (int(j) for j in input().split())
	if h[a-1] == h[b-1]:
		maxTower[a-1] = 0
		maxTower[b-1] = 0
	elif h[a-1] < h[b-1]:
		maxTower[a-1] = 0
	else:
		maxTower[b-1] = 0

print(maxTower.count(1))

Measured memory_bytes: 85188
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)
#include <numeric>
#include <iomanip>
#include <map>

using namespace std;

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define rep(i,n) for(long long i = 0;i < n;++i)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(nullptr);
#define fix(n) fixed << setprecision(n)
#define ALL(v) v.begin(),v.end()

#define PI 3.14159265358979323846

using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;


int main(void){
    FAST_IO
    
    ll n,m,k;
    cin >> n >> m >> k;
    
    for(ll li = 0;li <= n;li++){
        for(ll ki = 0;ki <= m;ki++){
            if(ki *(n-li) + li*(m-ki) == k){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3092
// Problem : A - Takahashikun, The Strider
// Contest : AtCoder - AtCoder Grand Contest 046
// URL : https://atcoder.jp/contests/agc046/tasks/agc046_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,b,a) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define bug(x) cout<<#x<<"="<<x<<endl; 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 200001; //check the limits, dummy
 
int main() 
{
	// && has higher precedence than ||
	ios_base::sync_with_stdio(0); cin.tie(0);    
	int X;
	cin>>X;
	int ans=(360*X)/__gcd(360,X);
	cout<<ans/X<<nl;
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3568
#include <stdio.h>

int main() {
    int a,b,keta,i;
    scanf("%d %d",&a,&b);
    if(b<=9){keta=10;}
    else if(b<=99){keta=100;}
    else if(b==100){keta=1000;}
    int c=a*keta+b;

    for(i=1;i<=400;i++){
        if(i*i==c){printf("Yes\n");return 0;}
    }
    printf("No\n");
    return 0;
}

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

int main(){
	int n;
	while(cin>>n,n){
		int dp[35][35]={};
		dp[1][1]=1;
		dp[1][2]=1;
		dp[1][3]=1;
		
		for(int i=1;i<30;i++){
			for(int j=1;j<n;j++){
				dp[i+1][j+1]+=dp[i][j];
				dp[i+1][j+2]+=dp[i][j];
				dp[i+1][j+3]+=dp[i][j];
				}
			}
			
			long long a=0;
			for(int i=0;i<=30;i++){
				a+=dp[i][n];
				}
				
				cout<<(((a+9)/10)+364)/365<<endl;
		
		}
		return 0;
	}

Measured memory_bytes: 3040
#include <iostream>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int d;
    cin >> d;
    string a = "Christmas";
    string b = "Eve";
    if (d == 25)
        cout << a;
    if (d == 24)
        cout << a << " " << b;
    if (d == 23)
        cout << a << " " << b << " " << b;
    if (d == 22)
        cout << a << " " << b << " " << b << " " << b;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    LL from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    CIN(a);CIN(b);CIN(c);
    Yes(a+b == c || a+c == b || b+c == a);
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,i;
	cin>>n;
	string s,t,a;
	cin>>s>>t;
	for(i=0;i<n;i++)
	{
		a.push_back(s[i]);
		a.push_back(t[i]);
	}
	cout<<a;
	return 0;
	
	
}


Measured memory_bytes: 256
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


A, B, C, D = map(int, input().split(" "))

lcm_c_d = lcm(C, D)

N = B - A + 1

count_C = (B // C) - ((A - 1) // C)
count_D = (B // D) - ((A - 1) // D)
count_CD = (B // lcm_c_d) - ((A - 1) // lcm_c_d)


ans = N - count_C - count_D + count_CD

print(ans)


Measured memory_bytes: 3060
#include <string>
#include <iostream>

const char atoA = 'A'-'a';

int main()
{
	std::string str;
	getline(std::cin,str);
	for( unsigned i=0; i<str.length(); ++i )
	{
		if( 'a' <= str[i] && str[i] <= 'z' )
		{
			std::cout << char(str[i] + atoA);
		}
		else
		{
			std::cout << str[i];
		}
	}
	std::cout << '\n';
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,m; cin>>n>>m;
	int L=0,R=n;
	for(int i=0;i<m;++i){
		int l,r; cin>>l>>r;
		L=max(L,l);
		R=min(R,r);
	}
	cout<<max(0,R-L+1)<<"\n"s;
}


Measured memory_bytes: 3604
N = int(input())
# N = 15なので全探索
say = []
for i in range(N):
    j = int(input())
    tmp = []
    for _ in range(j):
        tmp.append(list(map(int, input().split())))
    say.append(tmp)

# 15人に対し親切か不親切かをすべて場合分け　O(2**15=30000)
import itertools
all_man = []
for x in itertools.product([0, 1], repeat=N):
    all_man.append(x)
    
ans = []
for man in all_man:
    flag = False
    for i, man_i in enumerate(man):
        if man_i == 0:
            continue
        else:
            # この正直者の証言をとってくる
            for say_i in say[i]:
                x, y = say_i
                if man[x-1] != y:
                    # 矛盾
                    flag = True
    if flag:
        continue
    else:
        ans.append(man)
tmp = []
for i in ans:
    tmp.append(sum(i))
print(max(tmp))

Measured memory_bytes: 48988
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
ll rand_int(ll l, ll r) //[l, r]
{
    static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
    return uniform_int_distribution<ll>(l, r)(gen);
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
const int mod=998244353;
const int maxn=505;
ll quick(ll a,ll b)
{
    ll ret=1;
    while(b)
    {
        if(b&1) ret=ret*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return ret;
}
int dp[2][520][maxn];
int suf[maxn];
int main()
{
    int n,x;
    cin>>n>>x;
    dp[0][0][x]=1;
    int cur=0;
    for(int i=1;i<=n;i++)
    {
        memset(dp[cur^1],0,sizeof(dp[cur^1]));
        for(int j=0;j<=519;j++)
        {
            for(int k=x;k>=0;k--)
            {
                suf[k]=(suf[k+1]+dp[cur][j][k])%mod;
                if((j^k)<=519)
                    dp[cur^1][j^k][k]=(dp[cur^1][j^k][k]+suf[k])%mod;
            }
        }
        cur^=1;
    }
    int ans=0;
    for(int i=0;i<=x;i++)
        ans=(ans+dp[cur][x][i])%mod;
    print(ans);
}


Measured memory_bytes: 5168
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
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; }

const long long INF = 1LL << 60;

// input
int N;
long long h[100010];

// DP table
long long dp[100010];

int main() {
    int N; cin >> N;
    for (int i = 0; i < N; ++i) cin >> h[i];

    // initialize
    for (int i = 0; i < 100010; ++i) dp[i] = INF;

    // initial condition
    dp[0] = 0;

    // loop
    for (int i = 0; i < N; ++i) {
        chmin(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
        chmin(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
    }

    // answer
    cout << dp[N - 1] << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;
#define int long long
#define double long double
int gcd(int x,int y){
    if(y==0)return x;
    x=x%y;
    gcd(y,x);
}
map<int,bool>mp;

bool check(int n){
    while(n>0){
        int k=n%10;
        if(mp[k]==false) return false;
        n/=10;
    }
    return true;
}
main()
{
    int n,k;
    cin>>n>>k;
    rep(i,10)mp[i]=true;
    rep(i,k){
        int x;
        cin>>x;
        mp[x]=false;
    }
    for(int i=n;;i++){
        if(check(i)){
            cout<<i<<endl;
            break;
        }
        
    }
    return 0;
}

Measured memory_bytes: 256
import math

n=int(input())
x=list(map(int,input().split()))

#print(x)

if (max(x)-min(x))%2==0:
    print(
        math.ceil((max(x)-min(x))/2)
        )
    
elif (max(x)-min(x))%2!=0:
    print(
        math.ceil((max(x)-(min(x)-1))/2)
        )




Measured memory_bytes: 5680
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long
#define endl '\n'
using namespace std;
int dy[4] = { 1, 0, -1, 0 }, dx[4] = { 0, 1, 0, -1 };
typedef pair<ll, ll> P;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n);
    ll sum = 0, minus = 0;
    ll mi = 1e9;
    rep(i, n)
    {
        cin >> a[i];
        sum += abs(a[i]);
        if (a[i] < 0) {
            minus++;
        }
        mi = min(mi, abs(a[i]));
    }
    if (minus % 2 == 0) {
        cout << sum << endl;
    } else {
        cout << sum - mi * 2 << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main() 
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    int Sab = A * B;
    int Scd = C * D;

    if (Sab >= Scd) {
        cout << Sab <<endl;
    } else {
        cout << Scd << endl;
    }   
}


Measured memory_bytes: 256
n=int(input())
listl = [int(i) for i in input().split()]

"""listl.sort(reverse=True)

#print(listl)
	ans=0
for i in range(n-2):
	for j in range(i+1,n-1):
		if listl[j]<=(listl[i]/2):
			break
		for k in range(j+1,n):

			if listl[i]<listl[j]+listl[k]:
				ans=ans+1
			else:
				break	

print(ans)"""
from bisect import bisect_right				 
listl.sort()

ans=0

for i in range(n-1,1,-1):
	a=listl[i]
	for j in range(i-1,0,-1):
		b=listl[j]
		c=bisect_right(listl,a-b)
		#print(c)
		num = j-c
		if num>0:
			ans+=num
print(ans)

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

//--------------------------------------------
#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) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

//--------------------------------------------
const double EPS = 1e-14;
const double PI  = acos(-1.0);

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

int main(){
  int n, a;

  scanf("%d %d",&n, &a);

  printf("%d\n", n * n - a);
}


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

using namespace std;

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

int N;
int P[200000];

int main() {
    cin >> N;
    FOR(i, N) cin >> P[i];

    int ans = 0;
    int min = N + 1;

    FOR(i, N) {
        if (min >= P[i]) {
            ans += 1;
            min = P[i];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024