akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int mod=998244353;
const int N=410;
void Add(int &x,int y) { x+=y; if(x>=mod) x-=mod; }
int Pow(int x,int y) {
	int res=1;
	while(y) {
		if(y&1) res=res*(ll)x%mod;
		x=x*(ll)x%mod,y>>=1;
	}
	return res;
}
int f[2][N][N];
int a[N],b[N],n,s;
int inv[N],fac[N];
void getfac(int n) {
	fac[0]=1; for(int i=1;i<=n;++i) fac[i]=fac[i-1]*(ll)i%mod;
	inv[n]=Pow(fac[n],mod-2); for(int i=n;i>=1;--i) inv[i-1]=inv[i]*(ll)i%mod;
}
int main() {
	getfac(400);
	rd(n);
	for(int i=1;i<=n;++i) rd(a[i]),rd(b[i]),s+=a[i];
	int cur=0; f[cur][0][0]=mod-1;
	for(int i=1;i<=n;++i) {
		int nxt=cur^1; memcpy(f[nxt],f[cur],sizeof(f[cur]));
		for(int j=0;j<=400;++j)
			for(int k=0;k<=400;++k) if(f[cur][j][k]) {
				for(int x=0,t=1;x<b[i];++x,t=t*(ll)a[i]%mod)
					Add(f[nxt][j+a[i]][k+x],f[cur][j][k]*(ll)inv[x]%mod*t%mod*(ll)(mod-1)%mod);
			}
		cur=nxt;
	}
	int ans=0;
	for(int i=1;i<=400;++i) {
		int ii=Pow(i,mod-2);
		for(int j=0,t=ii;j<=400;++j,t=t*(ll)ii%mod) if(f[cur][i][j])
			Add(ans,f[cur][i][j]*(ll)t%mod*fac[j]%mod);
	}
	ans=ans*(ll)s%mod;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1664
S = input()

buff = []
ans_b = []
buff.append(S[0])
memo = [0 for i in range(len(S))]

for i in range(1, len(S)):
    if S[i] == buff[-1]:
        if i != len(S)-1:
            buff.append(S[i]+S[i+1])
            memo[i+1] = 1
        else:
            buff[-1] += S[i]
    else:
        if memo[i] == 0:
            buff.append(S[i])

# print(buff)
print(len(buff))



Measured memory_bytes: 9832
const main = (input: string) => {
  const hasMoney = Number(input);

  let happyValue = Math.floor(hasMoney / 500) * 1000;
  const modMoney = hasMoney % 500;

  happyValue += Math.floor(modMoney / 5) * 5;

  console.log(happyValue);
}

// *この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll M = 1e9+7;
const ll MN = 100100;
ll mul(ll a, ll b) {return (a*b)%M;}
ll bp(ll b, ll p) {
	ll ac = 1;
	while(p) {
		if(p&1) {ac = mul(ac,b);}
		b = mul(b,b);
		p >>= 1;
	}
	return ac;
}
ll inv(ll b) {
	return bp(b,M-2);
}
ll co[MN];
int main() {
	ll n;
	cin >> n;
	memset(co,0,sizeof(co));
	ll val = 0;
	for(int i=0;i<n;i++) {
		val += inv(i+1);
		if(val >= M) {val -= M;}
		co[i] += val;
		co[n-i-1] += val;
	}
	ll fac = 1;
	for(int i=1;i<=n;i++) {
		fac = mul(fac,i);
	}
	for(int i=0;i<n;i++) {
		co[i]--;
		co[i] %= M;
		co[i] = mul(co[i],fac);
	}
	ll tot = 0;
	for(int i=0;i<n;i++) {
		ll t;
		cin >> t;
		tot += mul(co[i],t);
	}
	tot %= M;
	cout << tot << '\n';
}


Measured memory_bytes: 1024
a,b,c=[input() for _ in range(3)]
a_len=len(a)
b_len=len(b)
c_len=len(c)
a_num=1
b_num=0
c_num=0
p=a[0]
while True:
    if p=="a":
        if a_num>=a_len:
            break
        else:
            p=a[a_num]
            a_num+=1
    elif p=="b":
        if b_num>=b_len:
            break
        else:
            p=b[b_num]
            b_num+=1
    else:
        if c_num>=c_len:
            break
        else:
            p=c[c_num]
            c_num+=1    
print(p.upper())

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N =2e5+6;
const int mod =1e5+3;
char s[N][20];
int hashTable[N];
ll cnt[N];
void init()
{
    for(int i=0;i<mod;i++)
    {
        hashTable[i] =-1;
        cnt[i] =0;
    }
    return ;
}
int Hash(char *t){
    int ha = 5381;
    int c;
    while(c=*t++){
        ha = ((ha<<5)%mod + ha + c)%mod;
    }
    return ha%mod;
}
bool compare(char *s1,char *s2)
{
    while(*s1)
    {
        if(*s1!=*s2)
            return 0;
        s1++,s2++;
    }
    return 1;
}
int getID(int t,int id)
{
    while(hashTable[t]!=-1)
    {
        if(compare(s[hashTable[t]],s[id]))
            return t;
        t++;
        if(t==N)
            t =0;
    }
    return t;
}
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        init();
        for(int i=0;i<n;i++)
        {
            scanf("%s",s[i]);
            sort(s[i],s[i]+10);
            int t =Hash(s[i]);
            int id =getID(t,i);
            cnt[id]++;
            hashTable[id] =i;
        }
        ll ans =0;
        for(int i=0;i<N;i++)
            ans +=(ll)(cnt[i]*(cnt[i]-1))/2;
        printf("%lld\n",ans);
    }
    return 0;
}


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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

LL dx[] = {1, -1, 0, 0, -1, -1, 1, 1};
LL dy[] = {0, 0, 1, -1, -1, 1, -1, 1};

///**************************DONE****************************///

int main()
{
    string s;
    cin >> s;

    map<char, int> mp;
    mp[s[0]]++;
    mp[s[1]]++;
    mp[s[2]]++;
    mp[s[3]]++;

    if(mp.size() == 2 && mp[s[0]] == 2 && mp[s[1]] == 2 && mp[s[2]] == 2 && mp[s[3]] == 2)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}

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

vector<int>vec[700];
double e[700], ee[700];

int n, m;
int l[700];
bool vis[700][700];

double solve(int u, int v)
{
    for(int i = n-1; i > u; --i) e[i] = ee[i];
    double sum = 0;
    for(int i = 0; i < l[u]; ++i)
    {
        if(vec[u][i] == v) continue;
        sum += e[vec[u][i]];
    }
    e[u] = sum/(l[u]-1)+1.0;
    for(int i = u-1; i > 0; --i)
    {
        sum = 0;
        for(int j = 0; j < l[i]; ++j)
            sum += e[vec[i][j]];
        e[i] = sum/l[i]+1.0;
    }
    return e[1];
}

int main()
{

    double ans;
    scanf("%d%d", &n, &m);
    for(int i = 0; i < m; ++i)
    {
        int u, v;
        scanf("%d%d", &u, &v);
        vec[u].push_back(v);
    }
    for(int i = 1; i <= n; ++i)
        l[i] = vec[i].size();
    ee[n] = e[n] = 0;
    for(int i = n-1; i > 0; --i)
    {
        double sum = 0;
        for(int j = 0; j < l[i]; ++j)
            sum += e[vec[i][j]];
        ee[i] = e[i] = sum/l[i]+1.0;
    }
    ans = e[1];
    for(int i = 1; i < n; ++i)
    {
        int x = 0;
        for(int j = 0; j < l[i]; ++j)
        {
            //cout << i << ' ' << j << ' ' << vec[i][j] << ' ' << ee[x] << ' ' << ee[vec[i][j]] << ' ';
            if(ee[vec[i][j]] > ee[vec[i][x]]) x = j;
            //cout << x << endl;
        }
        //cout << "******* " << i << ' ' << vec[i][x] << ' ' << ee[vec[i][x]] << endl;
        ans = min(ans, solve(i, vec[i][x]));
    }
    printf("%.8f\n", ans);
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>

using namespace std;
const int N = 100010;
int h[N], e[N*2], ne[N*2], idx;
int distu[N];
int distv[N];
int n, u, v;
int degree[N];
bool st1[N], st2[N];

void add(int a, int b)
{
    e[idx] = b;
    ne[idx] = h[a];
    h[a] = idx ++;
}

void bfsu(){
    vector<int> q;
    q.push_back(u);
    vector<int> temp;
    int cnt = 0;
    while(!q.empty()){
        temp.clear();
        for(auto i:q){
            if(!st1[i]){
                st1[i] = true;
                distu[i] = cnt;
                for(int j = h[i]; j != -1; j = ne[j])
                {
                    int point = e[j];
                    temp.push_back(point);
                }
            }
        }
        cnt ++;
        q = temp;
    }
}

void bfsv(){
    vector<int> q;
    q.push_back(v);
    vector<int> temp;
    int cnt = 0;
    while(!q.empty()){
        temp.clear();
        for(auto i:q){
            if(!st2[i]){
                st2[i] = true;
                distv[i] = cnt;
                for(int j = h[i]; j != -1; j = ne[j])
                {
                    int point = e[j];
                    temp.push_back(point);
                }
            }
        }
        cnt ++;
        q = temp;
    }
}

int main(){
    cin >> n >> u >> v;
    idx ++;
    memset(h, -1, sizeof h);
    for(int i = 1; i < n; i ++)
    {
        int a, b;
        cin >> a >> b;
        add(a, b);
        add(b, a);
        degree[a] ++;
        degree[b] ++;
    }
    bfsu();
    bfsv();
    int res = 0;
    for(int i = 1; i <= n; i ++){
        if(degree[i] == 1 && distv[i] > distu[i]) res = max(res, distv[i] - 1);
    }
    cout << res << endl;
    return 0;
}


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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

struct RangeSumQuery
{
    using type = ll;
    static type id() { return 0; }
    static type op(const type &l, const type &r) { return (l + r) % MOD; }
};

template <typename M>
class SegmentTree
{
    using T = typename M::type;
    int n;
    std::vector<T> node;

public:
    // v を基に初期化
    SegmentTree(const std::vector<T> &v)
    {
        // n は v.size() 以上の最小の2冪
        n = 1;
        while (n < int(v.size()))
            n *= 2;
        node.resize(2 * n, M::id());

        // i の子 -> 2*i+1, 2*i+2 , 親 -> (i-1)/2
        for (int i = 0; i < int(v.size()); i++)
            node[i + n] = v[i];
        for (int i = n - 1; i >= 0; i--)
            node[i] = M::op(node[2 * i], node[2 * i + 1]);
    }
    // Monoid::id 初期化
    SegmentTree(int _n)
    {
        // n は v.size() 以上の最小の2冪
        n = 1;
        while (n < _n)
            n *= 2;
        node.resize(2 * n, M::id());
    }
    // x 番目を val に更新
    void update(int x, T val)
    {
        x += n;
        node[x] = val;
        while (x >>= 1)
        {
            node[x] = M::op(node[2 * x], node[2 * x + 1]);
        }
    }
    // v[x] を M::op(v[x], val) に更新
    void operation(int x, T val)
    {
        x += n;
        node[x] = M::op(node[x], val);
        while (x >>= 1)
        {
            node[x] = M::op(node[2 * x], node[2 * x + 1]);
        }
    }
    // [a, b) の op
    T query(int l, int r)
    {
        l += n;
        r += n;
        T retl = M::id(), retr = M::id();
        while (l < r)
        {
            if (l & 1)
                retl = M::op(retl, node[l++]);
            if (r & 1)
                retr = M::op(node[--r], retr);
            l >>= 1;
            r >>= 1;
        }
        return M::op(retl, retr);
    }
};

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

    int n, k;
    cin >> n >> k;
    int sq = (int)floor(sqrt(n));
    vector<ll> cnt(2 * sq + 1, 1);
    cnt[0] = 0;
    for (int i = 1; i <= sq; i++)
    {
        cnt[2 * sq - i + 1] = n / i % MOD;
        if (i != 1)
            cnt[2 * sq - i + 2] = (cnt[2 * sq - i + 2] + MOD - n / i) % MOD;
    }
    cnt[sq + 1] = (cnt[sq + 1] + MOD - sq) % MOD;
    // printv(cnt);
    SegmentTree<RangeSumQuery> st(2 * sq + 1);
    vector<SegmentTree<RangeSumQuery>> dp(k, st);
    dp[0] = SegmentTree<RangeSumQuery>(cnt);
    for (int i = 1; i < k; i++)
    {
        for (int j = 1; j <= sq; j++)
        {
            dp[i].update(j, dp[i - 1].query(1, 2 * sq + 2 - j));
        }
        for (int j = sq + 1; j <= 2 * sq; j++)
        {
            dp[i].update(j, cnt[j] * dp[i - 1].query(1, 2 * sq + 2 - j) % MOD);
        }
        /*
        vector<int> deb = {0};
        for (int j = 1; j <= 2 * sq; j++)
            deb.push_back(dp[i].query(j, j + 1));
        printv(deb);
        */
    }
    cout << dp[k - 1].query(1, 2 * sq + 1) << endl;
}


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

int main() {
  ll N, Y; cin>>N>>Y;
  bool ikeru=0;
  ll ansx, ansy, ansz;
  for(ll i=0; i<=N; i++){
    for(ll j=0; j<=N; j++){
      ll z=N-i-j;
      if(z>=0 && 10000*i+5000*j+1000*z==Y){
        ikeru=1;
        ansx=i;
        ansy=j;
        ansz=z;
      }
    }
  }
  if(ikeru) cout<<ansx<<" "<<ansy<<" "<<ansz<<endl;
  else cout<<-1<<" "<<-1<<" "<<-1<<endl;
}

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

#define rep(i,p) for(int i=1;i<=p;i++)
#define ll long long

using namespace std;

int main(){


  map<string,int> A;
  A["SUN"]=0;
  A["MON"]=1;
  A["TUE"]=2;
  A["WED"]=3;
  A["THU"]=4;
  A["FRI"]=5;
  A["SAT"]=6;




   string S;
   cin >> S;
   cout << 7-A[S];





	return 0;

}



Measured memory_bytes: 256
import sys

class UFT: #Union-find tree class
    def __init__(self, N): 
        self.tree = [int(i) for i in range(N)] 
        self.rank = [0 for i in range(N)]

    def find(self, a):
        if self.tree[a] == a: return a
        else:
            self.tree[a] = self.find(self.tree[a])
            return self.tree[a]

    def unite(self, a, b):
        a = self.find(a)
        b = self.find(b)
        if a == b: return
        if self.rank[a] < self.rank[b]: self.tree[a] = b
        else:
            self.tree[b] = a
            if self.rank[a] == self.rank[b]: self.rank[a] += 1

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    parent = UFT(N)
    for i in range(M):
        x, y, z = map(int, input().split())
        parent.unite(x-1, y-1)
    for i in range(N):
        parent.find(i)

    print(len(set(parent.tree)))
    
    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 13984
#include <stdio.h>

int absolute(int k)
	{
		if (k >= 0) return 1*k;
		else		return -1*k;
	}

int main(void) {
	int n, m; //students,points
	int s[50][2], p[50][2];
	int c, d, ans;



	scanf("%d %d", &n,&m);
	for (int i = 0; i < n; i++)
	{
		scanf("%d %d", &s[i][0], &s[i][1]);
	}
	for (int i = 0; i < m; i++)
	{
		scanf("%d %d", &p[i][0], &p[i][1]);
	}

	for (int i = 0; i < n; i++)
	{
		d = absolute(s[i][0] - p[0][0]) + absolute(s[i][1] - p[0][1]);
		ans = 1;
		for (int j = 1; j < m; j++)
		{
			c = absolute(s[i][0] - p[j][0]) + absolute(s[i][1] - p[j][1]);
			if (c < d)
			{
				d = c;
				ans = j + 1;
			}
		}
		printf("%d \n", ans);
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        int[] ch = new int[n];
        long r = 0;
        long g = 0;
        long b = 0;
        for(int i = 0; i < n ;i++){
            ch[i] = s.charAt(i);
            if(ch[i] == 'R'){
              r++;
            }else if(ch[i] == 'G'){
              g++;
            }else{
              b++;
            }
        }
        long ans = r * g * b;
        for(int i = 0; i < n; i++){
            for(int j = i + 1; j < n; j++){
              int k = j + j - i;
              if(k < n && ch[i] != ch[j] && ch[i] != ch[k] && ch[j] != ch[k]){
                ans--;
              }
            }
          }
          System.out.println(ans);
    }
}


Measured memory_bytes: 36004
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <list>
#include <queue>
#include <string>
#include <vector>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long ll;
ll power(ll x,ll y)
{
    if( y == 0)
        return 1;
    else if (y%2 == 0)
        return power(x, y/2)*power(x, y/2);
    else
        return x*power(x, y/2)*power(x, y/2);
 
}
int main()
{
	ll n;
	ll ar[50008];	cin>>n;
	ll i;
	ll t=0;
	for(i=0;i<n;i++)
	{
		cin>>ar[i];
		t+=ar[i];
	}
	ll k1=round(t/n);
	ll k2=k1+1;
	ll k3=k1-1;
	ll ans1=0,ans2=0,ans3=0;
	for(i=0;i<n;i++)
	ans1=ans1+power(k1-ar[i],2);
	for(i=0;i<n;i++)
	ans2=ans2+power(k2-ar[i],2);
	for(i=0;i<n;i++)
	ans3=ans3+power(k3-ar[i],2);
	ll ans=min(ans1,min(ans2,ans3));
	cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstdlib>
#include <vector>
#include <cstdint>

#define _rep_overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _rep_overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define _rrep_overload3(_1,_2,_3,name,...) name
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _rrep_overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)

using namespace std;

// Globals

int main() {
  int n;
  cin >> n;
  vector<int> xs(n);
  rep (i, n) cin >> xs[i];

  int left = 0;
  long ans = 0;
  int state = 0;
  
  rep (right, n) {
    for ( ; (xs[right] & state) != 0; state -= xs[left], ++left);
    state = xs[right] | state;
    ans += right - left + 1;
    // printf("%d, %d : %d\n", left, right, state);
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 1024
#include <stdio.h>
#include <algorithm>
using namespace std;
char txt[12];
int dp[12];
const char * sample = "AGCT";
int main(){
	scanf("%s",txt);
	int Max=-1;
	for(int i=0;txt[i]!='\n'&&txt[i]!=0;i++){
		for(int j=0;j<4;j++){
			if(sample[j]==txt[i]){
				dp[i+1]=dp[i]+1;
				break;
			}
			else if(j==3){
				dp[i+1]=0;
			}
		}
		Max=max(Max,dp[i+1]);
	}
	printf("%d",Max);
}

Measured memory_bytes: 128
import sys

S = input()
c = 0


op = len(S) - 1  # すき間の個数

for i in range(2 ** op):
  T = ""
  for j in range(op):
    T += S[j]
    if ((i >> j) & 1):
      T += "+"
    else:
      T += "-"
  T += S[op]
  if eval(T) == 7:
    print(T+"=7")
    sys.exit()

Measured memory_bytes: 3060
n=map(int,raw_input().split())
if n[0]<=n[1]<=n[2]:
	a=n[0]
	b=n[1]
	c=n[2]
elif n[0]<=n[2]<=n[1]:
	a=n[0]
	b=n[2]
	c=n[1]
elif n[1]<=n[0]<=n[2]:
	a=n[1]
	b=n[0]
	c=n[2]
elif n[1]<=n[2]<=n[0]:
	a=n[1]
	b=n[2]
	c=n[0]
elif n[2]<=n[0]<=n[1]:
	a=n[2]
	b=n[0]
	c=n[1]
else:
	a=n[2]
	b=n[1]
	c=n[0]
print a,b,c

Measured memory_bytes: 4264
#include <stdio.h>

int main(void) {
    int a = 0;
    int b = 0;
    int c = 0;
    int k = 0;
    scanf("%d %d %d", &a,&b,&c);
    scanf("%d", &k);
    if (a >= 1 & a <= 7 & b >= 1 & b <= 7 & c >= 1 & c <= 7 & k <= 7 & k >= 1) {
        while (a >= c) {
            c = c * 2;
            k--;
            if (k == 0)
                break;
        }

        while (a >= b) {

            b = b * 2;
            k--;
            if (k == 0)
                break;
        }


        while (b >= c) {
            c = c * 2;
            k--;
            if (k == 0)
                break;
        }

        if (k < 0) {
            printf("No");
        }
        else
            printf("Yes");
       
        return 0;
    }
    else
        printf("input error\n");
}


Measured memory_bytes: 1728
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

int main() {
	int q;
	cin >> q;
	while(q--) {
		ll a, b;
		cin >> a >> b;
		if(a > b)
			swap(a, b);
		ll ans = 2 * a - 2;
		ll c = (ll) sqrt(a * b);
		if(c * (c + 1) < a * b) {
			ans = max(ans, 2 * c - 1);
		}
		else {
			if(c * c == a * b)
				ans = max(ans, 2 * c - 3);
			else
				ans = max(ans, 2 * c - 2);
		}
		cout << ans << "\n";
	}
}


Measured memory_bytes: 256
N, W = map(int, input().split())
weight = []
value = []
for i in range(N):
    w, v = map(int, input().split())
    weight.append(w)
    value.append(v)

def chmin(a,b):
    if a >= b:
        return b
    else:
        return a
    
V = sum(value)
inf = float('inf')
dp = [[inf]*(V+1) for _ in range(N+1)]
dp[0][0] = 0

for i in range(N):
    for v in range(V+1):
        dp[i+1][v] = dp[i][v]
        
        if v >= value[i]:
            dp[i+1][v] = chmin(dp[i][v - value[i]] + weight[i], dp[i][v])
for v in range(V+1):
    if dp[N][v] <=W:
        res = v
print(res)

Measured memory_bytes: 163344
def is_prime(p):
    if p == 1:
        return False
    for i in range(2, p):
        if p % i == 0:
            return False
    return True

n = int(input())
ans = []
for i in range(55555):
    if is_prime(i) and i % 5 == 1:
        ans.append(str(i))
    if len(ans) == n:
        break
print(" ".join(ans))

Measured memory_bytes: 3060
#include<cstdio>
#include<string.h>
using namespace std;

int main(){
	long long a,b,k;
	scanf("%lld%lld%lld",&a,&b,&k);
	if(k % 2 == 1){
		for(int i = 1;i <=k + 1;i++){
			if(a % 2 == 1){
				a = a - 1;
				b = b + a / 2;
				a = a - a / 2;
			}
			else if(a % 2 == 0) {
				b = b + a / 2;
				a = a - a / 2;
			}
			if(i == k) break;
			if(b % 2 == 1){
				b = b - 1;
				a = a + b / 2;
				b = b - b / 2;
			}
			else if(b % 2 == 0){
				a = a + b / 2;
				b = b - b / 2;
			}
			i++;
		}
	}
	if(k % 2 == 0){
		for(int i = 1;i <=k;i++){
			if(a % 2 == 1){
				a = a - 1;
				b = b + a / 2;
				a = a - a / 2;
			}
			else if(a % 2 == 0) {
				b = b + a / 2;
				a = a - a / 2;
			}
			if(b % 2 == 1){
				b = b - 1;
				a = a + b / 2;
				b = b - b / 2;
			}
			else if(b % 2 == 0){
				a = a + b / 2;
				b = b - b / 2;
			}
			i++;
		}
	}
	printf("%lld %lld\n",a,b);
}

Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)

int main() {
	map<string, int> mp_b;
	map<string, int> mp_r;
	set<string> st;
	int N; cin >> N;

	rep(i, 0, N) {
		string s;
		cin >> s;
		mp_b[s]++;
		st.insert(s);
	}
	int M; cin >> M;
	rep(i, 0, M) {
		string s;
		cin >> s;
		mp_r[s]++;
		st.insert(s);
	}

	int max = 0;
	for (set<string>::iterator it = st.begin(); it != st.end(); it++) {
		if (max < mp_b[*it] - mp_r[*it]) {
			max = mp_b[*it] - mp_r[*it];
		}
	}
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())

heights = list(map(int, input().split()))

tree = [[] for i in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

ans = 0

for i in range(n):
    if len(tree[i]) == 0:
        ans += 1
    else:
        is_max = True
        height = heights[i]
        for child in tree[i]:
            if height <= heights[child]:
                is_max = False
                break
        if is_max:
            ans += 1

print(ans)


Measured memory_bytes: 29568
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,k = inpl()
p = inpl()
c = inpl()
seen = [False] * n
nums = []
for i in range(n):
    if seen[i]: continue
    seen[i] = True
    res = deque([c[i]])
    now = i
    while True:
        nx = p[now]-1
        if nx == i: break
        res.append(c[nx])
        seen[nx] = True
        now = nx
    nums.append(res)
# print(nums)
res = -INF
for num in nums:
    l = len(num)
    su = sum(list(num))
    for _ in range(l): # _番目からスタート
        nu = list(num)
        mx = -INF
        now = 0
        for i,x in enumerate(nu):
            if i+1 > k: break
            now += x
            mx = max(now, mx)
        if su > 0:
            now = (k//l-1)*su+mx
            mx = max(now, mx)
            cnt = k//l * l
            now = k//l*su
            for i,x in enumerate(nu):
                if cnt+i+1 > k: break
                now += x
                mx = max(now, mx)
        res = max(res, mx)
        tmp = num.popleft()
        num.append(tmp)
print(res)
        

Measured memory_bytes: 78812
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int N, K, R, S, P;
	string T, M;
	cin >> N >> K >> R >> S >> P >> T;
	ll ans = 0;
	for (int i = 0; i < K; i++) {
		if (T[i] == 'r') {
			ans += P;
			M.push_back('r');
		}
		else if (T[i] == 's') {
			ans += R;
			M.push_back('s');
		}
		else if (T[i] == 'p') {
			ans += S;
			M.push_back('p');
		}
	}
	for (int i = K; i < N; i++) {
		if (T[i] == M[i - K]) {
			M.push_back('.');
		}
		else {
			if (T[i] == 'r') {
				ans += P;
				M.push_back('r');
			}
			else if (T[i] == 's') {
				ans += R;
				M.push_back('s');
			}
			else if (T[i] == 'p') {
				ans += S;
				M.push_back('p');
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
 
int main(){
    int a,b,c;
    
    cin>>a>>b>>c;
    
    if (a<b && a<c){
        if (b<c){
            cout<<a<<" "<<b<<" "<<c<<endl;
            return 0;
        }else if (c<b){
            cout<<a<<" "<<c<<" "<<b<<endl;
            return 0;
        }
    }else if(b<c && b<a){
        if (a<c){
            cout<<b<<" "<<a<<" "<<c<<endl;
            return 0;
        }else if (c<a){
            cout<<b<<" "<<c<<" "<<a<<endl;
            return 0;
        }
    }else{
        if(a<b){
            cout<<c<<" "<<a<<" "<<b<<endl;
            return 0;
        }else if (b<a){
            cout<<c<<" "<<b<<" "<<a<<endl;
            return 0;
        }
    }
    
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}

    int n,m,a[110],sum,ct;
signed main(){
    cin>>n>>m;
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
    }
    rep(i,n){
        if(4*m*a[i]>=sum)ct++;
    }
    if(ct>=m)puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std ;
using namespace __gnu_pbds;

template <typename T> // *s.find_by_order(0), s.order_of_key(2) ;
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define reMin(a, b) a = min(a, b)
#define reMax(a, b) a = max(a, b)

#define lint long long
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define SET(x, val) memset(x, val, sizeof(x))
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef vector < int > vi ;
typedef pair < int, int > pii ;

const int N = 1e6 + 2 ;
const int MOD = 1e9 + 7 ;
const lint INF = 1e18 ;

int n, m ;
int dp[N] ;
string s  ;

int t[N*4] ;

void update(int v, int i, int j, int x, int y)
{
    if(i == j and j == x) { t[v] = y ; return ; }
    if(x < i or x > j) return ;
    int mid = i+j >> 1 ;
    update(v*2, i, mid, x, y); update(v*2 + 1, mid + 1, j, x, y);
    t[v] = min(t[v*2], t[v*2 + 1]);
}

int get(int v, int i, int j, int l, int r)
{
    if(i > r or j < l) return 1e9;
    if(i >= l and j <= r) return t[v] ;
    int mid = i+j  >> 1 ;
    return min(get(v*2, i, mid, l, r), get(v*2 + 1, mid + 1, j, l, r));
}

int main()
{
    fastio; cin >> n >> m ;
    cin >> s ;
    dp[n+1] = 0 ; for(int i = 1; i < N; i++) t[i] = 1e9 ; // update(1, 1, n+m, i, 1e9);
    update(1, 1, n+m+1, n+1, 0);
    for(int i = n; i > 0; i--)
    {
        if(s[i-1] == '1') dp[i] = 1e9 ;
        else dp[i] = 1 + get(1, 1, n+m+1, i+1, i + m);
        update(1, 1, n+m+1, i, dp[i]);
    }
    if(dp[1] >= N) {
        cout << -1 ;
        return 0 ;
    }
    int cnt = dp[1] - 1 ; int now = 1 ;
    for(int i = 1; i <= n+1; i++)
    {
        if(dp[i] == cnt) {
            cout << i - now << " " ;
            now = i ;
            cnt-- ;
        }
    }
}



Measured memory_bytes: 6864
#include <bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define x             first
#define y             second
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define PI            3.14159265358979
#define N             200005

int solve(){
    int n,k; cin>>n>>k;
    int a[n+1]={};
    while(k--){
        int d; cin>>d;
        for(int i=1; i<=d; i++){
            int t; cin>>t;
            a[t]++;
        }
    }
    int ans=0;
    for(int i=1; i<=n; i++) if(!a[i]) ans++;
        cout<<ans;
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

ll N;
void input(){
    fast_io();
    cin >> N;
}

int solve(){
    ll s6 = 6;
    ll s9 = 9;
    vector<ll> cnt;
    cnt.push_back(1);
    for (int i = 0; i < 20; i++)
    {
        if(N>=s6) cnt.push_back(s6);
        else break;
        if(N>=s9) cnt.push_back(s9);
        s6 *= 6;
        s9 *= 9;
    }
    sort(cnt.begin(),cnt.end());
    vector<int> dp(N+1,INT_INF);
    dp[N] = 0;
    for (int v = N; v >= 0; v--)
    {    
        for (int i = cnt.size()-1; i >= 0; i--)
        {
            if(v-cnt[i]>=0) dp[v-cnt[i]] = min(dp[v-cnt[i]],dp[v]+1);
        }
    }
    

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

int main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 640
[k,s]=list(map(int,input().split()))
counter=0
imax=min(s+1,k+1)
for i in range(imax):
	jmax=min(s-i+1,k+1)
	for j in range(0,jmax):
		if i<=k and j<=k and s-i-j<=k:
			counter+=1
print(counter)

Measured memory_bytes: 3060
from collections import deque
n = int(input())

g = [[] for _ in range(n)]
for i in range(n):
    _, _, *edge = map(lambda x: int(x)-1, input().split())

    g[i] = edge

q = deque()
q.append(0)
dist = [-1 for _ in range(n)]
dist[0] = 0

while(len(q) > 0):
    v = q.popleft()

    for nv in g[v]:
        if(dist[nv] != -1): continue
        
        dist[nv] = dist[v] + 1
        q.append(nv)

for i in range(n):
    print(i+1, dist[i])


Measured memory_bytes: 6040
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#define FPEN freopen("in.txt", "r", stdin);
#else
#define FPEN
#endif
const int maxn = 200009;
typedef long long i64;
typedef pair<i64, i64> pi64;
typedef pair<int, int> pi;
const i64 MOD = 119 << 23 | 1;
class {
 public:
  void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> has(n + 1);
    for (int i = 0; i < k; ++i) {
      int t;
      cin >> t;
      for (int j = 0; j < t; ++j) {
        int T;
        cin >> T;
        has[T] = 1;
      }
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i)
      if (has[i] == 0)
        ans++;
    cout << ans << '\n';
  }
} NSPACE;
int main() {
  FPEN;
  ios_base::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  NSPACE.solve();
}

Measured memory_bytes: 3656
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int A1[MAX];
  int k=VMAX;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);
  for(i=1; i<=n; i++){
      scanf("%hu",&A[i]);
  }

  for(i=0; i<=k; i++){
      C[i]=0;
  }
  for(j=1; j<=n; j++){
      C[A[j]]++;
  }
  for(i=1; i<=k; i++ ){
      C[i]=C[i]+C[i-1];
  }
  for(j=n; j>=1; j--){
      B[C[A[j]]]=A[j];
      C[A[j]]--;
  }
  
  for(i=1; i<=n; i++){
      if(i==n)printf("%u\n",B[i]);
      else printf("%u ",B[i]);
  }
  return 0;
}


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

using namespace std;

#define intt long long

intt n;

bool check (intt x, intt y) {
	while (x % y == 0) {
		x /= y;
	}
	return (x % y == 1);
}

int main() {

	cin >> n;
	int ans = 0;
	intt m = n - 1;
	for (int i = 2; 1LL * i * i <= m; i ++) {
		if (m % i == 0) {
			ans ++;
			if (m != 1LL * i * i) {
				ans ++;
			}
		}
	}
	if (n != 2) ans ++;
	for (int i = 2; 1LL * i * i <= n; i ++) {
		if (n % i == 0) {
			ans += check(n, 1LL * i);
			if (n != 1LL * i * i) {
				ans += check(n, 1LL * (n / i));
			}
		}
	}
	ans ++;
	cout << ans << '\n';
	return 0;
}

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

#define lint long long

#define Pair pair<string, int>;
const int INF = 1E9;

int main(){
    int N, K;
    
    cin >> N >> K;
    
    vector<int> V(N);
    
    for(int i = 0; i < N; ++i){
        cin >> V[i];
    }
    
    lint largest = 0;
    
    for(int i = 0; i <= min(K, N); ++i){
        for(int j = 0; j <= min(K, N) - i; ++j){
            vector<int> nums;
            for(int k = 0; k < i; ++k){
                nums.push_back(V[k]);
            }
            for(int k = N - 1; k >= N - j; --k){
                nums.push_back(V[k]);
            }
            sort(nums.begin(), nums.end());
            
            lint sum = 0;
            
            for(int k = 0; k < (i + j) ; ++k){
                if(nums[k] > 0 || k > (K - (i + j) - 1)){
                    sum += (lint)nums[k];
                }
            }
            largest = max(largest, sum);
        }
    }
    
    cout << largest  << endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int dp[1010][1010];

int main(){
    const int MOD=pow(10,9)+7;
    int H, W;
    cin >> H >> W;
    char a[1010][1010];
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cin >> a[i][j];
        }
    }
    dp[0][0]=1;
    int dx[]={-1,0};
    int dy[]={0,-1};
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            if(i==0 && j== 0) continue;
            if(a[i][j]=='#'){
                dp[i][j]=0;
                continue;
            }
            for(int k=0; k<2; k++){
                int nx= dx[k]+i;
                int ny= dy[k]+j;
                if(nx >=0 && ny >=0){
                    dp[i][j] += dp[nx][ny];
                    dp[i][j] %= MOD;
                }
            }
        }
    }
    cout << dp[H-1][W-1] << endl;

}

Measured memory_bytes: 5120
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int sx[2020][2020];
int sy[2020][2020];
int main(){
  int h,w;
  cin >> h >> w;
  string s[h];
  rep(i,h){
    cin >> s[i];
  }
  rep(i,h){
    rep(j,w) sx[i][j] = 0;
  }
  int cnt = 0;
  int start,end;
  for(int i = 0; i < h; i++){
    start = 0;
    cnt = 0;
    for(int j = 0; j < w; j++){
      if(s[i].substr(j,1) == "."){
        cnt++;
      }else{
        if(cnt != 0){
          end = j - 1;
          for(int k = start; k <= end; k++){
            sx[i][k] = cnt;
          }
          start = j + 1;
          cnt = 0;
        }else{
          start = j + 1;
          cnt = 0;
        }
      }
    }
    if(cnt != 0){
      for(int k = start; k <= w-1; k++){
        sx[i][k] = cnt;
      }
    }
  }

  rep(i,h){
    rep(j,w) sy[i][j] = 0;
  }

  for(int i = 0; i < w; i++){
    start = 0;
    cnt = 0;
    for(int j = 0; j < h; j++){
      if(s[j].substr(i,1) == "."){
        cnt++;
      }else{
        if(cnt != 0){
          end = j - 1;
          for(int k = start; k <= end; k++){
            sy[k][i] = cnt;
          }
          start = j + 1;
          cnt = 0;
        }else{
          start = j + 1;
          cnt = 0;
        }
      }
    }
    if(cnt != 0){
      for(int k = start; k <= w-1; k++){
        sy[k][i] = cnt;
      }
    }
  }

  int ans = 0;
  rep(i,h){
    rep(j,w){
      ans = max(sx[i][j] + sy[i][j] - 1, ans);
    }
  }
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 36096
// これ気づかんかった、もっと冷静になるべきだった
// Xの上限が10^9なのだがこれがヒント
//
// ...らしいんだけど、だからなんでここにたどり着けるのか一切わからん

package main

import (
	"fmt"
	"math"
)

func main() {
	var X int
	fmt.Scan(&X)
	for i := -300; i <= 300; i++ {
		for j := -300; j <= 300; j++ {
			if math.Pow(float64(i), float64(5))-math.Pow(float64(j), float64(5)) == float64(X) {
				fmt.Println(i, j)
				return
			}
		}
	}
}


Measured memory_bytes: 1820
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    string s;cin >> s;
    string q;

    rep(i,s.size()){
        if(s[i] == 'B'){
            if(i+1 < s.size()){
                if(s[i+1] == 'C'){
                    q += 'D';
                    i++;
                }
                else{
                    q += 'B';
                }
            }
            else{
                q += 'B';
            }
        }
        else{
            q += s[i];
        }
    } 

    int lim = q.size();
    bool ok = false;
    LL ans = 0;
    LL ct = 0;
    rep(i,lim){
        if(q[i] == 'A'){
            ct++;
            if(i+1 < lim){
                if(q[i+1] == 'D'){
                    ans += ct;
                    ct--; 
                    q[i+1] = 'A';
                }
            }
        }
        else{
            ct = 0;
        } 
    }

    cout << ans << endl;
}

Measured memory_bytes: 776
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <stack>
using namespace std;
typedef long long int lli;
int main(void)
{
    int N;
    cin >> N;
    cout << 2 * 3.14 * N << endl;
    return 0;
}

Measured memory_bytes: 3780
import java.util.Scanner

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val a = scanner.nextInt()
    val b = scanner.nextInt()
    val s = scanner.next()
    if (s[a] == '-') {
        for (i in 0..(a + b)) {
            if (i != a && s[i] == '-') {
                println("No")
                return
            }
        }
        println("Yes")
    } else {
        println("No")
    }
}

Measured memory_bytes: 31388
# 2020/05/08
# AtCoder Beginner Contest 079 - B

# Input
n = int(input())
l = [0] * (n+1)
l[0] = 2
l[1] = 1

for i in range(2, n+1):
    l[i] = l[i-1] + l[i-2]
    
# Output
print(l[n])


Measured memory_bytes: 2940
#include <iostream>

using namespace std;
typedef long long LL;

LL mpow(LL a, LL b) {
    LL t;
    while (b) {
        t = b;
        b = a % b;
        a = t;
    }
    return t;
}

int main() {
    int n;
    LL a, b;
    cin >> n;
    cin >> a;
    for (int i = 1; i < n; ++i) {
        cin >> b;
        a = mpow(a, b);
    }
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<queue>
#define LL long long
using namespace std;
inline int read( )
{
  int sum=0;char c=getchar( );bool f=0;
  while(c<'0'||c>'9') {if(c=='-') f=1;c=getchar( );}
  while(c>='0'&&c<='9') {sum=sum*10+c-'0';c=getchar( );}
  if(f) return -sum;
  return sum;
}
const int N=200005;
int n,A,B,h[N];
inline LL _div(LL a,LL b) {if(a%b==0) return a/b;else return a/b+1;}
inline bool check(LL x)
{
  int i;LL u=x;
  for(i=1;i<=n;i++)
    if(-x*B+h[i]>0&&(u-=_div(-x*B+h[i],A-B))<0) return 0;
  return 1;
}
int main( )
{
  int i,j;
  n=read( );A=read( );B=read( );
  for(i=1;i<=n;i++) h[i]=read( );
  int l=0,r=1e9,mid;
  while(l<=r)
    {
      mid=(l+r)>>1;
      if(check(mid)) r=mid-1;
      else l=mid+1;
    }
  printf("%d",l);
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

vector<vector<lli>> v;
lli n,d;

lli distance(lli a,lli b){
	lli sum = 0;
	REP(i,0,d){
		lli d = v[a].at(i) - v[b].at(i);
		sum += d*d;
	}
	return sum;
}

signed main(){

	cin>>n>>d;
	v.resize(n);

	set<lli> s;

	REP(i,0,10000){
		s.insert(i*i);
	}

	REP(i,0,n)REP(j,0,d){
		lli tmp;
		cin>>tmp;
		v[i].push_back(tmp);
	}

	lli ans=0;
	for(lli i=0;i<n;i++){
		for(lli j=i+1;j<n;j++){
			lli d = distance(i,j);
			if(s.find(d)!=s.end())ans++;
		}
	}
	cout<<ans<<endl;

	return 0;
}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define LL long long
#define pii pair<int,int>
#define SZ(x)  (int)x.size()
#define all(x) x.begin(),x.end()

using namespace std;

LL gcd(LL a, LL b) {return b ? gcd(b, a % b) : a;}
LL lcm(LL a, LL b) {return a / gcd(a, b) * b;}
LL powmod(LL a, LL b, LL MOD) {LL ans = 1; while (b) {if (b % 2)ans = ans * a % MOD; a = a * a % MOD; b /= 2;} return ans;}
const int N = 5e5 + 3;
const LL mod = 917120411ll,p=13331,q=1331;
int n;
LL R[N],L[N];
char a[N];
int main() {
    ios::sync_with_stdio(false);
    cin>>n>>a+1;
    int l=1,r=n/2,res=0;
    for(int i=1;i<=n;i++)R[i]=(1ll*R[i-1]*p+a[i])%mod,L[i]=(1ll*L[i-1]*q+a[i])%mod;
    while(l<=r){
        int mid=l+r>>1;
        int ok=0;
        map<LL,int>vis,qqq;
        int k=1;
        for(int j=1;j+mid-1<=n&&!ok;j++){
            while(k+mid-1<j){
                vis[(R[k+mid-1]-R[k-1]*powmod(p,mid,mod)%mod+3ll*mod)%mod]++;
                qqq[(L[k+mid-1]-L[k-1]*powmod(q,mid,mod)%mod+3ll*mod)%mod]++;
                k++;
            }
                if(vis[(R[j+mid-1]-R[j-1]*powmod(p,mid,mod)%mod+3ll*mod)%mod]&&qqq[(L[j+mid-1]-L[j-1]*powmod(q,mid,mod)%mod+3ll*mod)%mod]){
                    ok=1;
                    break;

            }
        }
        if(ok)res=mid,l=mid+1;
        else r=mid-1;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 2944
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cmath>

#define REP(i,n) for(int (i) = 0;(i) < (n);(i)++)
using namespace std;
int C[10001];

int partition(int *A,int p,int r){
   int x = A[r];
   int i = p-1;
   for (int j = p ;j < r ;j++){
     if (A[j] <= x){
       i = i+1;
       swap(A[i],A[j]);
     }
   }
   swap(A[i+1],A[r]);
   return i+1;
}

int main(){
	int n,A[100000];
	cin >> n;
	REP(i,n){
		cin >> A[i];
	}
	int part;
	part = partition(A,0,n-1);
	cout << A[0];
	REP(i,n-1){
		cout << " ";
		if(part==i+1) cout << "[";
		cout << A[i+1];
		if(part==i+1) cout << "]";
	}
	cout << endl;
}

Measured memory_bytes: 3436
#include <bits/stdc++.h>
using namespace std;
 
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
 
/* vector<int> A(N); 
    vector<pair<int, int> > tasks; ＃ソートした場合、１つ目でソート
　tie(b, a) = p.at(i); #pairを分割
    tasks.emplace_back(b, a)  ＃配列tasksの最後に(b,a)を追加
　xの二乗:  pow(x, 2.0) 
    小さい順: sort(v.begin(), v.end());
    大きい順: reverse(v.begin(), v.end());
    int: -2,147,483,648 ～ 2,147,483,647
    ll: -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807
    // int型の2次元配列(3×4要素の)の宣言
    vector<vector<int>> data(3, vector<int>(4));
*/
 
/* xとyの最大公約数を求める */
 
int gcd(int x, int y){
  if(x<y)return gcd(y,x);
  else{
    ll r=x%y;
    if(r!=0)return gcd(y,r);
    else return y;
  }
}
 
int main() {
  
  ll A, B, C, count=0, ans=0;
  string D, E;
  cin >> A;
  
  rep(x,A){
  	rep(y,A){
    	rep(z,A){
          	count+= gcd(x+1,gcd(y+1,z+1));
        }
    }
  }
  
  cout << count << endl;
}

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

int main() {
    int64_t X, Y;
    cin >> X >> Y;
    if(Y == 1 || X % Y == 0) {
        cout << -1 << endl;
        return 0;
    }
    cout << X * (Y - 1) << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
cnt = 0
for i in range(2, N):
    if max(a[i - 2], a[i - 1]) == min(a[i - 1], a[i]) or min(a[i - 2], a[i - 1]) == max(a[i - 1], a[i]):
        if a[i-2] != a[i-1] or a[i-1] != a[i]:
            cnt += 1

print(cnt)

Measured memory_bytes: 3064