akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;

int main() {
   double q,x;
   while(cin >> q) {
	   if (q==-1) break;
	   x=1;
	   while (true) {
		   x-=(x*x*x-q)/(3*x*x);
		   if ((x*x*x-q)<0.000001*q && (x*x*x-q)>-0.000001*q) break;
	   }
   printf("%lf\n",x);
   }
  return 0;
}

Measured memory_bytes: 1232
import sys
input=sys.stdin.readline

grid = []
for i in range(3):
	aa = list(map(int,input().split()))
	grid.append(aa)

flag = True
for i in range(2):
	for j in range(i+1,3):
		c = grid[i][0] - grid[j][0]
		for k in range(1,3):
			if(c!=(grid[i][1] - grid[j][1]) or c!=(grid[i][2] - grid[j][2]) ):
				flag = False

for i in range(2):
	for j in range(i+1,3):
		c = grid[0][i] - grid[0][j]
		for k in range(1,3):
			if(c!=(grid[1][i] - grid[1][j]) or c!=(grid[2][i] - grid[2][j]) ):
				flag = False

if(flag):print("Yes")
else:print("No")



Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;
long long  f(long long x,long long y)
{   
	if(x%y==0)
	return(y);
	else
	return f(y,x%y);
}
int main()
{
	long long a,b,n,m,i,c,d;;
	while(~scanf("%lld%lld%lld%lld",&a,&b,&c,&d))
	{  
	    if(c>d)
	    {
	    	long long g;
	    	g=c;
	    	c=d;
	    	d=g;
		}
		long long s=0,l=0,k=0,gcd,lcm;
     	s=b/d-(a-1)/d;
	 	l=b/c-(a-1)/c;
	 	gcd=f(c,d);
	 	lcm=c*d/gcd;
	 	k=b/lcm-(a-1)/lcm;
	 printf("%lld\n",b-a+1-(s+l-k)); 
	}
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;

struct Coord {
    Int x;
    Int y;
};
double CalcDist(Coord first, Coord second) {
    return sqrt((first.x - second.x) * (first.x - second.x) + (first.y - second.y) * (first.y - second.y));
}
double CalcDistSum(vector<Coord>& coords, vector<Int>& coordId) {
    Int size = (Int)coordId.size();
    double ret = 0;
    for (Int i = 0; i < size - 1; ++i) {
        ret += CalcDist(coords[coordId[i]], coords[coordId[i + 1]]);
    }
    return ret;
}
Int Factorial(Int n) {
    if (n == 1) {
        return 1;
    } else {
        return n * Factorial(n - 1);
    }
}

int main(void) {
    Int n;
    cin >> n;
    VI cityId(n);
    vector<Coord> coords(n);
    for (Int i = 0; i < n; ++i) {
        cityId[i] = i;
        cin >> coords[i].x >> coords[i].y;
    }
    double sum = 0;
    do {
        sum += CalcDistSum(coords, cityId);
    } while (std::next_permutation(cityId.begin(), cityId.end()));
    cout << fixed << setprecision(10) << sum / (double)Factorial(n) << endl;
    return 0;
}


Measured memory_bytes: 3788
/*
  Vishal Shrivastava
  i_am_kirito

  look up to the sky,keep up(don't let go)
  I'll look towards the sky, without any doubt...
  
  never let you go,never let you go.
  till the light shines stronger, I go.
*/
#include <bits/stdc++.h>
using namespace std;
#define minpq priority_queue <int, vector<int>, greater<int> >
#define maxpq  priority_queue <int>
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define ll long long
#define int ll
#define pll pair<ll,ll>
#define pii pair<int,int>
const int maxn=3e3+10,mod=1e9+7;
 
ll n,m,dp[maxn][maxn][2];
inline void add(ll&x,ll y){x+=y;if(x>=mod)x-=mod;}

void solve()
{
	cin>>n>>m;
	dp[0][0][1]=1;
	for(int i=1;i<=n;++i)
		dp[0][i][0]=1;
	for(int i=0;i<m;++i)
		for(int j=0;j<=n;++j)for(int k=0;k<2;++k)
		{
			if(!dp[i][j][k]) 
				continue;
			if(j)
				add(dp[i+1][j-1][k|(j==1)],dp[i][j][k]),add(dp[i+1][j][k|(j==1)],dp[i][j][k]);
			if(n-j)
				add(dp[i+1][j][k],dp[i][j][k]),add(dp[i+1][j+1][k],dp[i][j][k]);
		}
	ll ans=0;

	for(int i=0;i<=n;++i)
		add(ans,dp[m][i][1]);

	cout<<ans<<"\n";

    return;
}
 
int32_t main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int test=1;
  //cin>>test;
  while(test--)
  {
    solve();
  }
}

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

int main() {
  int a, b, d = 0;
  cin >> a;
  string c;
  cin >> c;
  
  for(int i = 0; i < a; i++){
    if(c.at(i) == 'I'){
      b++;
    }else{
      b--;
    }
  
      d = max(d,b);
    
  }
    cout << d << endl;
  }


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

char dn[2400000], * di = dn;
const int MAX = 200000;
class shuturyoku_unko {
public:
	char C[MAX * 6 + 10];
	int K[MAX + 10];
	constexpr shuturyoku_unko() : C(), K() {
		auto di = C + 1;
		C[0] = '0';
		K[1] = 1;
		rep1(i, MAX) {
			int X = i;
			int keta = 0;
			char c[10] = {};
			while (X) {
				*(c + keta) = '0' + X % 10;
				X /= 10;
				keta++;
			}
			for (int j = keta - 1; j >= 0; j--)* di++ = (*(c + j));
			K[i + 1] = K[i] + keta;
		}
	}
} f;
inline void putint(ll X) {
	int ue = X / 100000;
	if (ue) {
		for (int i = f.K[ue]; i < f.K[ue + 1]; i++)* di++ = f.C[i];
		int sita = X - ue * 100000ll;
		rep(i, 5 - f.K[sita + 1] + f.K[sita]) *di++ = '0';
		for (int i = f.K[sita]; i < f.K[sita + 1]; i++)* di++ = f.C[i];
	}
	else for (int i = f.K[X]; i < f.K[X + 1]; i++)* di++ = f.C[i];
	*di++ = '\n';
}

int A[200000];
int B[200010];

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

	int N = getint();
	ll kotae = 0;
	rep(i, N) kotae += B[(A[i] = getint())]++;
	rep(i, N) putint(kotae - B[A[i]] + 1);
	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=1;i<n;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) REP(i,v.size())cout<<#v<<"["<<i<<"]: "<<v[i]<<endl
#define ALL(a) (a).begin(),(a).end()

int main(){
  string S;
  cin >> S;
  int len = S.size();
  sort(ALL(S));
  int abc[26];
  REP(i,26)abc[i]=0;
  int nums[10];
  REP(i,10)nums[i]=0;

  REP(i,len){
    char c = S[i];
    if('a'<=c && c<='z') ++abc[c-'a'];
    if('0'<=c && c<='9') ++nums[c-'0'];
  }

  int result = 0;
  REP(i,26){
    int cnt = abc[i];
    if(cnt == 0) continue;
    while(cnt){
      int iter = i+1;
      while(iter<26){
        int next = abc[iter];
        if(next == 0) break;
        --abc[iter];
        ++iter;
      }
      if(iter-i<=2)result += (iter-i);
      else result += 3;
      --cnt;
    }
  }
  REP(i,10){
    int cnt = nums[i];
    if(cnt == 0) continue;
    while(cnt){
      int iter = i+1;
      while(iter<10){
        int next = nums[iter];
        if(next == 0) break;
        --nums[iter];
        ++iter;
      }
      if(iter-i<=2)result += (iter-i);
      else result += 3;
      --cnt;
    }
  }

  cout << result << endl;
  return 0;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define hell 1000000007  
#define hell2 998244353 
#define pi 3.14159265358979323846

int solve(){   
    int a;
    cin>>a;
    cout<<(a+a*a+a*a*a);
    return 0;   
}
 
signed main(){
    IOS;
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>
#include<string.h>
 
int main()
{
  char s[3];
  char a[]= "AAA";
  char b[]= "BBB";
  
  scanf("%s",s);
  
  if( (strcmp(s,a)==0)||(strcmp(s,b)==0) )
  {
    printf("No\n");
  }
  else
  {
    printf("Yes\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>

int atcg(char *a,int i);

int main() {
	char a[10];
	scanf("%s\n", a);
	const int len = strlen(a);
	int count[len];
	int num[len];
	for (int i = 0; i < len; i++) {
		num[i] = 0;
	}
	for (int i = 0; i < len; i++) {
		if(a[i] == 'A' || a[i] == 'T' || a[i] == 'C' || a[i] == 'G') num[i] = atcg(a, i);
		else num[i] = 0;
	}
	int ans = 0;
	for (int i = 0; i < len; i++) {
		if (num[i] > ans) ans = num[i];
	}
	printf("%d\n", ans);
	return 0;
}

int atcg(char *a,int i) {
	int count = 1;
	for (int j = i + 1; j < strlen(a); j++) {
		if (a[j] == 'A' || a[j] == 'T' || a[j] == 'C' || a[j] == 'G')count++;
		else return count;
	}
	return count;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void){
char ch;
int counter[26],i;
	for(i=0;i<=25;i++){
        counter[i]=0;
	}
	while(scanf("%c",&ch)!=EOF){
	  if('A'<=ch && ch<='Z'){
	    ch=ch+('a'-'A');
	  }
	  if('a'<=ch && ch<='z'){
	    counter[ch-'a']++;
	}
	}
for(i=0;i<=25;i++){
	printf("%c : %d\n",'a'+i,counter[i]);
}

return(0);
}


Measured memory_bytes: 2048
s = gets.chomp.chars
k = gets.to_i
n = s.size
z = "z".ord

s.map! do |c|
    if c == "a"
        c
    elsif (x = z - c.ord) < k
        k -= x + 1
        "a"
    else
        c
    end
end

k %= 26
s[-1] = (s[-1].ord + k).chr
puts s.join


Measured memory_bytes: 11516
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public static void Main(string[] args)
	{
		var s = Console.ReadLine();
		var t = Console.ReadLine();
		int min = int.MaxValue;
		for(int i = 0; i < s.Length; i++)
		{
			if(i + t.Length > s.Length)
			{
				break;
			}
			
			string str = s.Substring(i, t.Length);
			min = Math.Min(min, CntReplace(str, t));
		}
		Console.WriteLine(min);
	}
	
	static int CntReplace(string a, string b)
	{
		int wa = 0;
		for(int i = 0; i < a.Length; i++)
		{
			if(a[i] != b[i])
				wa++;
		}
		return wa;
	}

	
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}


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

using namespace std;
const int maxn = 20;

int n;
int p[maxn], q[maxn];
int s[maxn];

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", p+i);
    for (int i = 0; i < n; i++)
        scanf("%d", q+i);

    for (int i = 1; i <= n; i++)
        s[i - 1] = i;

    int a, b;
    int cnt = 0;
    do {
        bool flag = true;
        for (int i = 0; i < n; i++) {
            if (s[i] != p[i]) flag = false;
        }
        if (flag) a = cnt;

        flag = true;
        for (int i = 0; i < n; i++) {
            if (s[i] != q[i]) flag = false;
        }
        if (flag) b = cnt;
        cnt++;
    } while (next_permutation(s, s+n));
    printf("%d", abs(a - b));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

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

  vll x(n);
  for (ll i = 0; i < n; i++) cin >> x[i];
  sort(all(x));

  ll ans = inf;
  for (ll i = x[0]; i <= x[n - 1]; i++) {
    ll y = 0;
    for (ll j = 0; j < n; j++) {
      y += (x[j] - i) * (x[j] - i);
    }
    ans = min(ans, y);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define MOD 1000000007
using namespace std;

long long gcd(long long x, long long y){
	if(x<y){
    	long long temp=x;
    	x=y;y=temp;
	}
	if(x%y==0)return y;
	else return gcd(y,x%y);
}
int main(void){
    long long a,ans=1,n;
	cin >> n;
	for(int i=0; i<n; i++){
    cin >> a;
		if(i==0)ans=a;
		else ans=gcd(ans,a);
	}
	cout << ans << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define N 2000100
int n, m;
ll a[N];
ll s[N];
ll f[N];

int main() {
	cin >> n;
	for (int i = 0; i < n-1; i ++) cin >> a[i];
	for (int i = 0; i < n-1; i ++) s[i+1] = s[i] + a[i];
	
	for (int i = 0; i <= s[2]; i++)
		f[i] = s[1]*2-i;
	
	for (int i = 3; i <= n-1; i ++) {
		for (int j = s[i-1]+1; j <= s[i]; j ++) {
			ll mi = 2*s[i-1]-j;
			if (mi < 0) f[j] = s[1]*2-mi;
			else f[j] = f[mi];
		}
	}
	cin >> m;
	while (m--) {
		int x; cin >> x;
		s[n] = s[n-1] + x;
		ll mi = 2*s[n-1] - s[n];
		if (mi < 0) cout << s[1]*2-mi << endl;
		else cout << f[mi]<< endl;
	}
	return 0;
}

Measured memory_bytes: 13056
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
a = na()
a.sort(reverse=True)

done = [False] * (1<<n)
b = [a[0]]
done[0] = True
for d in range(n):
    j = 0
    for i in range(1<<d):
        while j < 1<<n and (done[j] or b[i] <= a[j]):
            j += 1
        if j == 1<<n:
            print("No")
            sys.exit(0)
        b.append(a[j])
        done[j] = True
    b.sort(reverse=True)
print("Yes")


Measured memory_bytes: 105804
#include<stdio.h>
int min2(int a, int b){return a>b?b:a;}
char i;
int a;
int sum, min;
int main(void){
  min = 10;
  for(i=0; i<5; i++){
    scanf("%d", &a);
    sum += (a+9)/10;
    if(a%10){min = min2(min, a%10);}
  }
  printf("%d\n", 10*(sum-1)+min);
}


Measured memory_bytes: 128
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int ll;
static const int MAX_N = 100000;

int n, q;
vector<int> G[MAX_N];

int id[MAX_N];
int es[2 * (MAX_N - 1)];

ll bit[MAX_N + 1];

void dfs(int v, int p, int &k){
	id[v] = k;
	k++;
	for(int i = 0; i < G[v].size(); i++){
		int to = G[v][i];
		if(to != p){
			es[2 * to] = k;
			dfs(to, v, k);
			es[2 * to + 1] = k;
		}
	}
}
void init(){
	int k = 0;
	dfs(0, -1, k);
}

ll sum(int i){
	ll s = 0;
	while(i > 0){
		s += bit[i];
		i -= i & -i;
	}
	return s;
}
void add(int i, ll x){
	while(i <= n){
		bit[i] += x;
		i += i & -i;
	}
}
int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		int k;
		scanf("%d", &k);
		for(int j = 0; j < k; j++){
			int c;
			scanf("%d", &c);
			G[i].push_back(c);
		}
	}
	init();
	scanf("%d", &q);
	for(int i = 0; i < q; i++){
		int op;
		scanf("%d", &op);
		if(op == 0){
			int v;
			ll w;
			scanf("%d %lld", &v, &w);
			add(es[2 * v], w);
			add(es[2 * v + 1], -w);
		}else{
			int u;
			scanf("%d", &u);
			printf("%lld\n", sum(id[u]));
		}
	}
	return 0;
}



Measured memory_bytes: 16364
from math import sin,cos,radians,sqrt
a,b,h,m = map(int,input().split())

theta_a = (60*h+m)/720 * 360
theta_b = m/60 * 360

p1 = (a*cos(radians(theta_a)) - b*cos(radians(theta_b))) **2
p2 = (a*sin(radians(theta_a)) - b*sin(radians(theta_b))) **2

print(sqrt(p1+p2))

Measured memory_bytes: 9576
#include <iostream>
#include <cstdlib>
#include <queue>
#include <math.h>
#include <vector>
#include <algorithm>
#include <string>
#include <bitset>
using namespace std;

int main()
{
    int ans = 2000000;
    int d;
    bool b = false;
    int g, score, q;
    cin >> d >> g;
    vector<int> p(d+1, 0);
    vector<int> c(d+1, 0);
    for(int i=1; i<=d; ++i){
        cin >> p[i] >> c[i];
    }
    for(int i=0; i<(int)(pow(2, d)); ++i){
        bitset<10> complete = static_cast<bitset<10>>(i);
        score = 0;
        q = 0;
        b = false;
        // cout << complete << endl;
        // complete bonus
        for(int j=d-1; j>=0; --j){
            if(complete[j] == 1){
                score += 100 * (j+1) * p[j+1] + c[j+1];
                q += p[j+1];
            }
            if(score >= g){
                ans = min(ans, q);
                b = true;
            }
        }
        if(b){
            // cout << q << endl;
            continue;
        }
        // normal
        for(int j=d-1; j>=0; --j){
            if(complete[j] == 0){
                for(int k=1; k<p[j+1]; ++k){
                    score += 100 * (j+1);
                    q++;
                    if(score >= g){
                        ans = min(ans, q);
                        b = true;
                        break;
                    }
                }
            }
            if(b){
                // cout << q << endl;
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict as dd
S = input()
T = input()

Ds = dd(int)
Dt = dd(int)
Cs = dd(int)
Ct = dd(int)

for i in range(len(S)):
  Ds[S[i]] += 1
  Dt[T[i]] += 1  
  
for v in Ds.values():
  Cs[v] += 1
for v in Dt.values():
  Ct[v] += 1
if Cs == Ct:
  print ("Yes")
else:
  print ("No")

Measured memory_bytes: 4016
def f(n):
    s=""
    while n>0:
        s=str(n%2)+s
        n//=2
        if n==0:
            break
        if n%2==1:
            n+=2
            s="1"+s
        else:
            s="0"+s
        n//=2
    return s

n=int(input())
if n==0:
    print(0)
elif n<0:
    print(f(n*(-2))[:-1])
else:
    print(f(n))


Measured memory_bytes: 38512
#include <iostream>
#include <random>

using namespace std;
struct Timer {
    static const unsigned long TICKS_PER_MSEC=2.8e6;
    unsigned long t1;
    Timer() { reset(); }
    unsigned long elapsed() { return gettime()-t1; }
    double elapsedMsec() { return 1.0*elapsed()/TICKS_PER_MSEC; }
    void reset() { t1=gettime(); }
    unsigned long gettime()
    {
        unsigned long lo, hi;
        asm volatile ("rdtsc" : "=a" (lo), "=d" (hi));
        return (hi<<32)|lo;
    }
};

int c[27], s[366][27], t[366], last[27];
int main()
{
    Timer timer;
    int D; cin>>D;
    for(int i=1; i<=26; ++i) cin>>c[i];
    for(int i=1; i<=D; ++i)
        for(int j=1; j<=26; ++j)
            cin>>s[i][j];

    auto calc_score=[&](){
        long score=0;
        for(int i=1; i<=26; ++i) last[i]=0;
        for(int d=1; d<=D; ++d) {
            score+=s[d][t[d]];
            last[t[d]]=d;
            for(int i=1; i<=26; ++i) score-=c[i]*(d-last[i]);
        }
        return score;
    };

    for(int i=1; i<=D; ++i) {
        long bestscore=-(1L<<60), typ=1;
        for(int j=1; j<=26; ++j) {
            t[i]=j;
            auto score=calc_score();
            t[i]=0;
            if (bestscore<score) {
                bestscore=score;
                typ=j;
            }
        }
        t[i]=typ;
    }

    mt19937 engine;
    uniform_int_distribution<> rndT(1, 26), rndD(1, 365), rndR(0, 2);
    auto bestscore=calc_score();

    while (timer.elapsedMsec()<1950) {
        if (!rndR(engine)) {
            int d=rndD(engine);
            int q=rndT(engine);
            int x=t[d];
            t[d]=q;
            auto score=calc_score();
            if (bestscore<score) {
                bestscore=score;
            }
            else {
                t[d]=x;
            }
        }
        else {
            int a=rndD(engine);
            int b=rndD(engine);
            swap(t[a], t[b]);
            auto score=calc_score();
            if (bestscore<score) {
                bestscore=score;
            }
            else {
                swap(t[a], t[b]);
            }
        }
    }
    for(int i=1; i<=D; ++i) cout<<t[i]<<endl;
    //cout<<bestscore<<endl;
}


Measured memory_bytes: 3680
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>
#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define pb          push_back
#define mp          make_pair
#define mt          make_tuple
#define get0(x)     (get<0>(x))
#define get1(x)     (get<1>(x))
#define get2(x)     (get<2>(x))
#define ALL(X)      (X).begin(),(X).end()
#define LLMAX       9223372036854775807LL
#define LLMIN       -9223372036854775808LL
#define IMAX        2147483647
#define IMIN        -2147483648
typedef long long LL;
using namespace std;

class RangeAddRangeSum {
    public:
        int N;
        vector<int> dat, sum_dat;
        RangeAddRangeSum(int n) {
            N = 1;
            while(N < n) N <<= 1;
            dat.assign(2*N-1, 0);
            sum_dat.assign(2*N-1, 0);
        }

        void add(int a, int b, int x) { add(a,b,x,0,0,N); }
        int add(int a, int b, int x, int k, int l, int r) {
            if(b <= l or r <= a) return dat[k];
            if(a <= l and r <= b) {
                sum_dat[k] += x;
                return dat[k] += x*(r-l);
            }
            const int m = (l+r)/2;
            return dat[k] = add(a,b,x,2*k+1,l,m)+add(a,b,x,2*k+2,m,r)+sum_dat[k]*(min(r,b)-max(l,a));
        }

        int sum(int a, int b) { return sum(a,b,0,0,N); }
        int sum(int a, int b, int k, int l, int r) {
            if(b <= l or r <= a) return 0;
            if(a <= l and r <= b) return dat[k];
            const int m = (l+r)/2;
            return sum(a,b,2*k+1,l,m)+sum(a,b,2*k+2,m,r)+sum_dat[k]*(min(r,b)-max(l,a));
        }
};

int main(void){
    int N;
    // cin>>N;
    scanf("%d",&N);
    vector<LL> ABC[3];
    REP(i,3){
        REP(j,N){
            LL x;
            // cin>>x;
            scanf("%lld",&x);
            ABC[i].pb(x);
        }
        sort(ALL(ABC[i]));
    }
    LL ans=0;
    // RangeAddRangeSum rsq(N);
    vector<LL> dat(N);
    REP(i,N){
        // rsq.add(i,i+1,ABC[2].end()-upper_bound(ALL(ABC[2]),ABC[1][i]));
        dat[i]=ABC[2].end()-upper_bound(ALL(ABC[2]),ABC[1][i]);
    }
    LL sum=0;
    LL index=N-1;
    // REP(i,N){
    for(int i=N-1;0<=i;i--){
        // ans+=rsq.sum(upper_bound(ALL(ABC[1]),ABC[0][i])-ABC[1].begin(),N);
        int j=upper_bound(ALL(ABC[1]),ABC[0][i])-ABC[1].begin();
        while(j<=index){
            sum+=dat[index];
            index--;
        }
        ans+=sum;
    }
    cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define INF 99999999
#define INF_LL 1LL << 60
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}
 
int H,W;
vector<string> s;
 
int main()
{
    cin >> H >> W;
 
    rep(i,H)
    {
        string tmp;
        cin >> tmp;
        s.push_back(tmp);
    }
 
    vector<vector<int> >dp(H, vector<int>(W, INF));
    dp[0][0] = 0;
    if( s[0][0] == '#' ) dp[0][0]++;
 
    rep(i,H)
    {
        rep(j,W)
        {
            if( i == 0 && j == 0 ) continue;
            else if( i == 0 )
            {
                if( s[i][j] == '#' )
                {
                    if( s[i][j-1] == '#' ) chmin(dp[i][j], dp[i][j-1]);
                    else chmin(dp[i][j], dp[i][j-1]+1);
                }
                else chmin( dp[i][j], dp[i][j-1] );
            }
            else if( j == 0 )
            {
                if( s[i][j] == '#' )
                {
                    if( s[i-1][j] == '#' ) chmin(dp[i][j], dp[i-1][j]);
                    else chmin(dp[i][j], dp[i-1][j]+1);
                }
                else chmin( dp[i][j], dp[i-1][j] );
            }
            else
            {
                if( s[i][j] == '#' )
                {
                    if( s[i][j-1] == '#' )
                    {
                        chmin(dp[i][j], dp[i][j-1]);
                    }
                    else chmin(dp[i][j], dp[i][j-1]+1);
 
                    if( s[i-1][j] == '#' )
                    {
                        chmin(dp[i][j], dp[i-1][j]);
                    }
                    else chmin(dp[i][j], dp[i-1][j]+1);
                    
                    //if( i == 2 && j == 2 ) cout << dp[i][j] << endl;
                }
                else
                {
                    chmin( dp[i][j], min(dp[i][j-1], dp[i-1][j]) );
                }
            }
        }
    }
    /*
    rep(i,dp.size())
    {
        rep(j,dp[i].size()) cout << dp[i][j] << " ";
        cout << endl;
    }
    */
    cout << dp[H-1][W-1] << endl;
}


Measured memory_bytes: 256
package main

import "fmt"

func solve() {
	var N int
	fmt.Scan(&N)

	fmt.Printf("ABC%d\n", N)
}

func main() {
	solve()
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

void prime_factorization(ll N, map<ll, int>& res) {
  if(N == 1 || N == 0) return;
  ll n = N;
  ll i = 2;
  while(n >= i * i) {
    while(n % i == 0) {
      if(res.count(i)) res[i]++;
      else res[i] = 1;
      n /= i;
    }
    if(i == 2) i++;
    else i += 2;
  }
  if(n != 1) res[n]++;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n; cin >> n;
  ll ans = 0;
  map<ll, int> res;
  for(int i=1; i<=n; i++) {
    prime_factorization(i, res);
  }
  map<int, int> cnt;
  for(auto ele: res) {
    cnt[ele.second]++;
  }
  int prev = 0;
  for(auto itr=cnt.rbegin(); itr!=cnt.rend(); itr++) {
    itr->second += prev;
    prev = itr->second;
  }
  cnt[inf] = 0;
  ans += cnt.lower_bound(4)->second * (cnt.lower_bound(4)->second-1) / 2 * (cnt.lower_bound(2)->second-2);
  ans += cnt.lower_bound(24)->second * (cnt.lower_bound(2)->second-1);
  ans += cnt.lower_bound(14)->second * (cnt.lower_bound(4)->second-1);
  ans += cnt.lower_bound(74)->second;
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3688
N, A, B = map(int, input().split())
S = input()

cnt = 0
fcnt = 0
for i in range(N):
    s = S[i]
    if s == "c":
        print("No")
        continue
    if cnt < A + B:
        if s == "a":
            cnt += 1
            print("Yes")
        elif s == "b":
            fcnt += 1
            if fcnt <= B:
                cnt += 1
                print("Yes")
            else:
                print("No")
    else:
        print("No")


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

using namespace std;
const int MAXN=110100;
int N, M;
vector<int> grafo[MAXN];
int sol[MAXN];
int dfs(int nodo){
	if(grafo[nodo].size()==0)
		sol[nodo]=0;
	if(sol[nodo]!=-1)
		return sol[nodo];
	int massimo=-1;
	for(auto adj : grafo[nodo])
		massimo=max(massimo,dfs(adj));
	sol[nodo]=massimo+1;
	return sol[nodo];
}

int main(){
	int da, a;
	cin>>N>>M;
	for(int i=0;i<M;i++){
		cin>>da>>a;
		da--;
		a--;
		grafo[da].push_back(a);
	}
	for(int i=0;i<N;i++)
		sol[i]=-1;
	for(int i=0;i<N;i++)
		if(sol[i]==-1)
			dfs(i);
	int massimo=0;
	for(int i=0;i<N;i++)
		massimo = max(massimo,sol[i]);
	cout<<massimo;
}

Measured memory_bytes: 8448
#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;

int main() {
    long long int n,k;
    cin >> n >> k;
    n = n%k;
    while(n > abs(n-k)){
        n = abs(n-k);
    }
    cout<<n<<endl;
    return 0;
}

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

bool check(int a)
{
	bool flag = true;
	
	if (a % 2 == 0){
		return false;
	}

	for (int i = 3; i <= (int)sqrt(a); i += 2)
	{
		if (a%i == 0){
			flag = false;
			break;
		}
	}

	if (flag == true){
		return true;
	}
	else{
		return false;
	}
}

int main()
{
	int n, m;
	int count = 0;

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> m;
		if (m == 2){
			count++;
			continue;
		}
		if (check(m) == true){
			count++;
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 1160
n = input()
a = map(int, raw_input().split())
ans = 10**20
for p in range(2):
    s = 0
    x = [1, -1][p]
    c = 0
    for i in range(n):
        s += a[i]
        if x>0 and s<=0:
            c += 1-s
            s = 1
        elif x<0 and s>=0:
            c += s+1
            s = -1
        x = -x
    ans = min(ans, c)
print ans


Measured memory_bytes: 11272
#ifdef Prateek
  #include "Prateek.h"
#else
  #include <bits/stdc++.h>
  using namespace std;
  #define debug(...) 42
#endif
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int h,w,K;
   cin >> h >> w >> K;
   vector<vector<char>> A(h,vector<char>(w));
   f(i,0,h){
      f(j,0,w){
         cin >> A[i][j];
      }
   }
   int ans = 0;
   f(i,0,(1<<h)){
      f(j,0,(1<<w)){
         vector<vector<char>> B = A;
         f(k,0,h){
            if((1<<k) & i){
               f(l,0,w){
                  B[k][l] = '?';
               }
            }
         }
         f(k,0,w){
            if((1<<k) & j){
               f(l,0,h){
                  B[l][k] = '?';
               }
            }
         }
         int c = 0;
         f(i,0,h){
            f(j,0,w){
               c += (B[i][j] == '#');
            }
         }
         ans += (c == K);
      }
   }
   cout << ans << '\n';
   return 0;
}


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

using namespace std;

int main(void) {
  cout.precision(12);

  long P, Q, R;
  cin >> P >> Q >> R;

  cout << min(min(P+Q, Q+R), R+P) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define reg register
typedef long long ll;
using namespace std;
const int MN=3005;
int to[MN<<1],nxt[MN<<1],h[MN],cnt;
inline void ins(int s,int t){
	to[++cnt]=t;nxt[cnt]=h[s];h[s]=cnt;
	to[++cnt]=s;nxt[cnt]=h[t];h[t]=cnt;
}
int n,a[MN],f[MN];
void dfs(int st){
	f[st]=0;
	for(reg int i=h[st];i;i=nxt[i])
		if(a[st]>a[to[i]]){
			if(f[to[i]]<0)dfs(to[i]);
			f[st]|=!f[to[i]];
		}
}
int main(){
	scanf("%d",&n);memset(f,-1,sizeof(f));
	for(reg int i=1;i<=n;i++)scanf("%d",a+i);
	for(reg int i=1,s,t;i<n;i++)
		scanf("%d%d",&s,&t),ins(s,t);
	for(reg int i=1;i<=n;i++)if(f[i]<0)dfs(i);
	for(reg int i=1;i<=n;i++)if(f[i])printf("%d ",i);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define rt return 0
#define endln "\n"
#define all(v) v.begin(), v.end()
#define for1(i, a, b) for (long long int i = a; i < b; i++)
#define for2(i, a, b) for (long long int i = a; i > b; i--)
//  cout << fixed << setprecision(0) << pi <<" "<<npi<<endl;typedef long long int i;
typedef long long int lli;
typedef pair<lli, lli> pll;
lli power(lli x, lli y, lli m)
{
    lli a = 1;
    x %= m;
    while (y > 0)
    {
        if (y & 1)
        {
            a *= x;
            a %= m;
        }
        y /= 2;
        x *= x;
        x %= m;
    }
    return a;
    //log y
}
lli modInverse(lli b, lli m)
{
    return power(b, m - 2, m);
}
lli modDivide(lli a, lli b, lli m)
{
    a %= m;
    lli inv = modInverse(b, m);
    a *= inv;
    a %= m;
    return a;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli n;
    cin >> n;
    lli mod = 1e9 + 7;
    lli s = 0;
    vector<lli> v;
    for1(i, 0, n)
    {
        lli a;
        cin >> a;
        v.pb(a);
        s += a;
        s %= mod;
    }
    lli ans = 0;
    for1(i, 0, n)
    {
        lli x = s + mod;
        x -= v[i];
        x %= mod;
        x *= v[i];
        x %= mod;
        ans += x;
        ans %= mod;
    }
    ans = modDivide(ans, 2, mod);
    cout << ans << endl;
}

Measured memory_bytes: 5332
#include <iostream>

int main() {
    int a, b, k;
    std::cin >> a >> b >> k;

    // a <= b にする
    if (a > b) {
        int tmp = b;
        b = a;
        a = tmp;
    }

    for (int i = a; true; i--) {
        if (a % i == 0 && b % i ==0) {
            k -= 1;
        }
        if (k == 0) {
            std::cout << i << std::endl;
            break;
        }
    }
}

Measured memory_bytes: 256
N = int(input())
a = [int(x) for x in input().split()]

# all 2 then ok 
# if a == [2 for x in range(N)] :
#     print("Yes")
    
# else count numbers divisable by four
#else :
div4 = 0
is2 = 0
    
for i in a :
    if i % 4 == 0 :
        div4 += 1
    elif i % 2 == 0 :
        is2 += 1
   
if len(a) % 2 == 0 :
    if div4 + is2 // 2 >= N / 2 :
        print("Yes")
    else :
        print("No")
else :
    if div4 + is2 // 2 >= (N - 1) / 2 :
        print("Yes")
    else :
        print("No")

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

int main() {
	char x, y;
	cin >> x >> y;
	if (x < y) {
		printf("<");
	}
	else {
		if (x == y) {
			printf("=");
		}
		else {
			printf(">");
		}
	}
}

Measured memory_bytes: 256
(defun counting (n)
  (if (eq n 0)
      0
      (+ (rem n 10) (counting (floor n 10)))))

(defun some-sums (n a b)
  (cond
    ((eq n 0) 0)
    
    ((and
      (<= a (counting n))
      (>= b (counting n)))
     (+ n (some-sums (1- n) a b)))
    
    ((some-sums (1- n) a b))))

(format t "~A~%" (some-sums (read) (read) (read)))


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

const ll MOD = 1e9+7;

int main() {
  int n, k;
  cin >> n >> k;
  ll ans = 0;
  for (ll i = k; i <= n+1; ++i) {
    ans = (ans + i*n - i*(i-1) + 1) % MOD;
  }
  cout << ans << endl;
  return 0; 
}

Measured memory_bytes: 3588
import sys
import math
N = int(input())
A = list(map(int, input().split()))

NUM = 10**6

gcd = A[0]
for i in range(1, N):
    gcd = math.gcd(gcd, A[i])
if gcd != 1:
    print("not coprime")
    sys.exit()


def osa_k(num):
    S = list(i for i in range(num+1))
    for i in range(2, int(num**0.5)+1):
        if S[i] < i:
            continue
        j = i**2
        while j <= num:
            if S[j] == j:
                S[j] = i
            j += i
    return S


prime = osa_k(NUM)
S = [False]*(NUM+1)
for num in A:
    tmp = prime[num]
    while num > 1:
        num //= tmp
        if tmp == prime[num]:
            # S[tmp] = True
            continue
        if S[tmp]:
            print("setwise coprime")
            sys.exit()
        S[tmp] = True
        tmp = prime[num]
print("pairwise coprime")


        



Measured memory_bytes: 216688
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

int main() {
  int w, h, n; cin >> w >> h >> n;
  vector<int> X(n), Y(n), A(n);
  loop(i,0,n) cin >> X[i] >> Y[i] >> A[i];
  int xMin = 0, xMax = w, yMin = 0, yMax = h;
  loop(i,0,n) {
    int a = A[i];
    if (a == 1) {
      xMin = max(xMin, X[i]);
      continue;
    }
    if (a == 2) {
      xMax = min(xMax, X[i]);
      continue;
    }
    if (a == 3) {
      yMin = max(yMin, Y[i]);
      continue;
    }
    if (a == 4) {
      yMax = min(yMax, Y[i]);
      continue;
    }
  }
  if (xMax<=xMin or yMax<=yMin) cout << 0 << endl;
  else cout << (xMax-xMin)*(yMax-yMin) << endl;
  return 0;
}


Measured memory_bytes: 3632
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ms(a,b) memset(a,b,sizeof(a))
#define msn(a,n,b) for(int i=0;i<=n;i++)a[i]=b
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define fi first
#define se second
using namespace std;
mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef double db;
const int mod=1e9+7;
const int seed=233;
const double PI=acos(-1.0);
const double eps=1e-7;
const int inf=0x3f3f3f3f;
const int max_n=200005;
ll ceil(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?(x+y-1)/y:-x/y;}
ll floor(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?x/y:-(x+y-1)/y;}
namespace {
    inline int Add(int x,int y){return (x+=y)>=mod?x-mod:x;}
    inline int Sub(int x,int y){return (x-=y)<0?x+mod:x;}
    inline int Mul(int x,int y) {return 1ll*x*y%mod;}
    inline int Pow(int x,int y=mod-2){if(y==0)return 1;int res=1;while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod;y>>=1;}return res;}
}
/**********************head************************/
int n,x,y;
int ans[max_n];
int dis(int u,int v){
    return min(abs(u-v),abs(u-x)+abs(v-y)+1);
}
int main(){
    scanf("%d%d%d",&n,&x,&y);
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            ans[dis(i,j)]++;
        }
    }
    for(int i=1;i<n;i++)printf("%d\n",ans[i]);
    return 0;
}

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

using namespace std;

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

    vector<int> R;
    for (int i = 0; i < n; ++i) {
        int r;
        cin >> r;
        R.push_back(r);
    }

    int profit = numeric_limits<int>::min();
    int minv = R[0];
    for (int j = 1; j < n; ++j) {
        profit = max(profit, R[j] - minv);
        minv = min(minv, R[j]);
    }
    cout << profit << endl;

    return 0;
}

Measured memory_bytes: 3868
#include<bits/stdc++.h>
#define int long long
using namespace std;
int a1[200001],a2[200001] ;
int32_t main()
{
    int n,m,k ;
    cin>>n>>m>>k ;
    for(int i = 0 ; i < n ; i++) cin>>a1[i] ;
    for(int i = 0 ; i < m ; i++) cin>>a2[i] ;
    int cr=0 , ans=0 , mx=0 , t=0 ;
    while(cr<n && t+a1[cr]<=k)
    {
        //cout<<cr<<endl ;
        ans++ ; t+=a1[cr] ;
        cr++ ;
    }
    mx=ans ;
    for(int i = 0 ; i < m ;)
    {
        //cout<<i<<" "<<t<<endl ;
        if(t+a2[i]<=k)
        {
            t+=a2[i++] ;
            ans++ ;
            mx=max(mx,ans) ;
        }
        else
        {
            if(cr>=1) t=max(0ll,t-a1[--cr]) ;
            else break ;
            ans-- ;
        }
    }
    cout<<mx<<endl ;
}


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

int main() {
    vector<string> divide = {"maerd", "remaerd", "esare", "resare"};

    string S;
    cin >> S;

    reverse(S.begin(), S.end());

    bool X = true;
    for (int i = 0; i < S.size();){
        bool Y = false;
        for (int j = 0; j < 4; j++){
            string D = divide.at(j);
            if (S.substr(i, D.size()) == D){
                i += D.size();
                Y = true;
                break;
            }
        }
        if (!Y) {
            X = false;
            break;
        }
    }
    if(X) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
int a , b , c ;
cin >> a >> b >> c;
//c聞いたら満足する
int can = b/a ;
if(c > can){
    cout << can <<endl;
}
else if ( c <= can){
    cout << c << endl;
}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll      long long
#define pii     pair<int, int>
#define f       first
#define s       second
#define sf(a) scanf("%d", &a)
#define sfl(a) scanf("%lld", &a)
#define pf(a) printf("%d ", a)
#define pfl(a) printf("%lld\n", a)
#define Case(a) printf("Case %d: ", a)
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

using namespace std;
int main()
{
    FASTIO;

    int n;
    cin>>n;

    while(n){
        if(n%10 == 7){
            cout<<"Yes";
            return 0;
        }
        n /= 10;
    }
    cout<<"No";
}



Measured memory_bytes: 3640
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
void times(alias fun)(int n) {
    foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(int n) {
    T[] res = new T[n];
    foreach(ref e; res) e = fun();
    return res;
}
// fold was added in D 2.071.0.
template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
        static if (S.length < 2) {
            return reduce!fun(seed, r);
        } else {
            return reduce!fun(tuple(seed), r);
        }
    }
}

void main() {
    long N, A;
    readf("%d %d\n", &N, &A);

    (log2(N).to!int+1).iota.map!((k) {
        
        long m = (long l, long r){
            while(r-l > 1) {
                long m = (l+r)/2;
                if (m^^(k+1) >= N) {
                    r = m;
                } else {
                    l = m;
                }
            }
            return r;
        }(0, (N^^(1.0/(k+1))).to!long + 1);

        return (k+1).iota.filter!(i =>
            (m-1)^^i * m^^(k+1-i) >= N
        ).map!(i =>
            A*k + i*(m-1) + (k+1-i)*m
        ).fold!min;
        
    }).fold!min.writeln;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
 
int main(){
 int N,M;
  cin >> N >> M;
  if(N==M){cout << "Yes" << endl;}
  else{
    cout << "No" << endl;
  }
}

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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct Edge{int from, to; ll cost;};

const ll MOD = 1000000007;
const long double EPS = 10e-10;

int main(){
    std::ios::sync_with_stdio(0); cin.tie(0);
    int N,NC;
    cin >> N >> NC;
    vector< vector<int> > d(NC, vector<int>(NC));
    vector< vector<int> > c(N, vector<int>(N));
    rep(NC) repp(j, NC) cin >> d[i][j];
    rep(N) repp(j, N){
        cin >> c[i][j];
        c[i][j]--;
    }

    vector< vector<int> > cost(3, vector<int>(NC, 0));
    rep(N){
        repp(j, N){
            repp(color, NC){
                cost[(i+j)%3][color] += d[c[i][j]][color];
            }
        }
    }

    int ans = INT_MAX;
    rep(NC){
        repp(j, NC){
            if(i == j) continue;
            repp(k, NC){
                if(i == k || j == k) continue;
                ans = min(ans, cost[0][i]+cost[1][j]+cost[2][k]);
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 1280
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"
using namespace std;
int main()
{
  int n;
  cin>>n;
  set< string > ss;
  while(n--)
  {
    string s;
    cin>>s;
    ss.insert(s);
    }
  cout<<ss.size();
}

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

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

  vector<ll> b(n);
  ll x   = 0;
  ll y   = n - 1;
  bool k = true;
  for (int i = n - 1; i >= 0; i--) {
    if (k) {
      b[x] = a[i];
      x++;
    } else {
      b[y] = a[i];
      y--;
    }
    k = !k;
  }

  for (int i = 0; i < n; i++) {
    cout << b[i];
    if (i != n - 1) { cout << " "; }
  }
  cout << endl;
}

Measured memory_bytes: 5248
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int[]x=new int[N];
		int max=0; int sum=0;
		for(int i=0;i<N;i++) {
			int L=sc.nextInt();
            x[i]=L;
            sum+=x[i];
		}
		max=x[0];
for(int j=1;j<N;j++) {
	if(max<x[j]) {
		max=x[j];
	}
	
}
if(max<sum-max) {
	System.out.print("Yes");
}
else if(max>=sum-max) {
	System.out.print("No");
}
		sc.close();
	}

}


Measured memory_bytes: 22100
n = int(input())
xi = list(map(int, input().split()))
yi = list(map(int, input().split()))
for i in [1,2,3,0]:
	a = 0
	for j in range(0,n):
		if i == 0 :
			if a <= abs(yi[j]-xi[j]):
				a = abs(yi[j]-xi[j])
		else:
			a = a + abs(yi[j]-xi[j])**i
	if i == 0:
		print(a)
	else:
		print(a**(1/i))



Measured memory_bytes: 5640
MOD = 998244353
N, K = map(int, input().split())
kukan = [None] * K
sums = [0] * (N+2)
path = [0] * (N+1)

for i in range(K):
  l, r = map(int, input().split())
  kukan[i] = [l, r]


path[1] = 1
sums[0] = 0
sums[1] = 1
for i in range(2, N+1):
  total = 0
  for j in range(K):
    l, r = kukan[j]
    if l >= i:
      continue
    if r >= i:
      r = i-1
    total = (total + sums[i - l] - sums[i - r - 1] + MOD) % MOD
  path[i] = total
  sums[i] = (sums[i-1] + total) % MOD

print(path[N])

Measured memory_bytes: 71136
#include<bits/stdc++.h>
using namespace std;
int const p=998244353;
int pw(int x,int y)
{
    int res=1;
    while(y)
    {
        if(y&1)res=1ll*res*x%p;
        x=1ll*x*x%p;
        y>>=1;
    }
    return res;
}
int fac[4005],inv[4005];
int c(int n,int m){if(m>n||n<0||m<0)return 0;return 1ll*fac[n]*inv[m]%p*inv[n-m]%p;}
int main()
{
    int k,n;
    scanf("%d%d",&k,&n);
    fac[0]=inv[0]=1;
    for(int i=1;i<=4000;i++)fac[i]=1ll*fac[i-1]*i%p,inv[i]=1ll*inv[i-1]*pw(i,p-2)%p;
    for(int i=2;i<=2*k;i++)
    {
        int a=0,b=0;
        for(int j=1;j<=k;j++)
            if(i-j>=1&&i-j<=k&&(i!=(j<<1))){if(j>i-j)a++,b++;}
            else if(i!=(j<<1))b++;
            else a++;
        int res=0;
        for(int j=0;j<=n;j++)
            res=(res+1ll*c(a,j)*c(n-j+b-1,b-1))%p;
        printf("%d\n",res);
    }
    return 0;
}

Measured memory_bytes: 3844