akhauriyash/Code-Regression huggingface dataset:
n, k, c = map(int, input().split())
s = list(input())

c += 1
forward = []
backward = []
i = 0
while i < len(s) and len(forward) < k:
    if s[i] == 'x':
        i += 1
        continue
    forward.append(i)
    i += c
j = len(s)-1
while j > -1 and len(backward) < k:
    if s[j] == 'x':
        j -= 1
        continue
    backward.append(j)
    j -= c

backward.reverse()
for i in range(len(forward)):
    if forward[i] == backward[i]:
        print(forward[i]+1)

Measured memory_bytes: 21988
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const [a, b, c] = stdin
  .split('\n')[0]
  .split(' ')
  .map(Number)

const s = [a, b, c].sort((a, b) => a - b)

console.log(s[0] + s[1] === s[2] ? 'Yes' : 'No')


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


int main() {
    string S;
    cin >> S;
    Int N;
    N = S.size();

    vector<Int> v(N, 0), sum(N, 0), m(N, 0);
    Int Z = 0;

    rep(i,N) {
        if (S[i] == '1') v[i] = 1;
        else v[i] = -1;
    }
    sum[0] = v[0];
    Z = max(Z, v[0]);
    rep1(i,N-1) {
        sum[i] = sum[i-1] + v[i];
        Z = max(Z, sum[i]);
    }

    //cout << Z << endl;

    m[N-1] = sum[N-1];
    Int tmp = sum[N-1];
    rep(i,N-1) {
        if (tmp >= sum[N-2-i]) m[N-2-i] = tmp;
        else {
            tmp = sum[N-2-i];
            m[N-2-i] = tmp;
        }
    }

    Int tmp1 = 0, min1 = 0, max1 = 0, tmp2 = 0, min2 = 0, max2 = 0;

    rep(i,N) {
        if (S[i] == '?') {
            if (tmp1 + 1 + m[i] - sum[i] <= Z) {
                tmp1++;
            }
            else tmp1--;
        }
        else {
            tmp1 += v[i];
        }
        min1 = min(min1, tmp1);
        max1 = max(max1, tmp1);
    }

    rep(i,N) {
        if (S[i] == '?') {
            if (tmp2 + 1 + m[i] - sum[i] <= Z+1) {
                tmp2++;
            }
            else tmp2--;
        }
        else {
            tmp2 += v[i];
        }
        min2 = min(min2, tmp2);
        max2 = max(max2, tmp2);
    }

    Int ans = 0;
    ans = min(max1-min1, max2-min2);

    cout << ans << endl;
}


Measured memory_bytes: 27740
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#define MP make_pair
using ll = long long;
using namespace std;

int main()
{
  int r,g;
  cin >> r >> g;
  cout << 2*g - r << endl;
  return 0;
}


Measured memory_bytes: 256
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000

typedef long long ll;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const int MAXN = 1010;

int dp[MAXN][MAXN];

int main(void) {
    string s1, s2;
    cin >> s1;
    cin >> s2;
    for (int i = 0; i <= s1.size(); i++) {
        dp[i][0] = i;
    }
    for (int i = 0; i <= s2.size(); i++) {
        dp[0][i] = i;
    }
    for (int i = 1; i <= s1.size(); i++) {
        for (int j = 1; j <= s2.size(); j++) {
            int cost;
            if (s1[i-1] == s2[j-1]) cost = 0;
            else cost = 1;
            dp[i][j] = dp[i-1][j-1] + cost;
            dp[i][j] = min(dp[i][j], dp[i][j-1] + 1);
            dp[i][j] = min(dp[i][j], dp[i-1][j] + 1);
//            cout << dp[i][j] << "  ";
        }
//        cout << endl;
    }
    cout << dp[s1.size()][s2.size()] << endl;
    return 0;
}

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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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;}

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    int n; cin >> n;
    vector<int> lis(n);
    REP(i, 0, n){cin >> lis[i];}
    ll sum = 0;
    REP(i, 0, n-1){
        REP(l, i+1, n){
            sum += lis[i] * lis[l];
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
const int INF = 1e9;

int N, Y;
vector<int> solve() {
    vector<int> ret(3, -1);
    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= N; j++) {
            if (9 * i + 4 * j == Y - N && i + j <= N) {
                ret[0] = i;
                ret[1] = j;
                ret[2] = N - i - j;
                return ret;
            }
        }
    }
    return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> Y;
    Y /= 1000;
    vector<int> ans = solve();
    for (auto& i : ans) cout << i << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,n,x,ans,t;
int main(){
    cin>>n>>x;
    cin>>a;
    
    for(int i=2;i<=n;i++)
    {
    	cin>>b;
    	if(a+b>x)t=a+b-x,ans+=t,
    	b=b-t;if(b<0)b=0;
    	a=b;
    	
    }
    cout<<ans;

	return 0;
}


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

using namespace std;

int main() {
	int N, X;
	cin >> N >> X;
	vector<int> L(N);
	for (int i = 0; i < N; ++i) {
		cin >> L[i];
	}

	int D      = 0;
	int answer = 1;
	for (int i = 0; i < N; ++i) {
		D = D + L[i];
		if (D <= X) {
			answer++;
		}
	}

	cout << answer << endl;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
ll M;
ll S;
ll ret;
map<ll,ll> mp;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	mp[0]=1;
	FOR(i,N) {
		cin>>x;
		S+=x;
		ret+=mp[S%M];
		mp[S%M]++;
	}
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 4224
/*
Keep clam  Believe youself
*/
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<stack>
#include<set>
#include<cmath>
#define Xiaobo main
using namespace std;
const int maxn=1e6+7;
const int mod=1e9+7;
const double eps=1e-15;
const double pi=acos(-1);
const int INF=0x3f3f3f3f;
typedef long long ll;
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();if(c == '-')Nig = -1,c = getchar();while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();return Nig*x;}
ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b);}
//别急 dp找状态 问题看看本身的规律 贪心找方法
ll a[maxn];
int n;
ll qmi(ll a,ll b) {
	ll res=1;
	while(b) {
		if(b&1) res=res*a%mod;
		b>>=1;
		a=a*a%mod;
	}
	return res;
}
ll inv(ll x) {
	return qmi(x,mod-2);
}
map<int,int>fj(ll x){
	map<int,int>res;
	for(int i=2;i*i<=x;i++) {
		if(x%i==0) {
			while(x%i==0) res[i]++,x/=i;
		}
	}
	if(x!=1) res[x]++;
	return res;
}
int Xiaobo()
{
	cin>>n;
	for(int i=1;i<=n;i++) {
		scanf("%lld",&a[i]);
	}	
	map<int,int>mp; 
	for(int i=1;i<=n;i++) {
		map<int,int>tmp;
		tmp=fj(a[i]);
		for(auto item:tmp) {
			mp[item.first]=max(mp[item.first],item.second);
		}
	}
	ll g=1;
	for(auto item:mp) {
		g*=qmi(item.first,item.second);
		g%=mod;
	}
	//cout<<g<<'\n';
	ll sum=0;
	for(int i=1;i<=n;i++) {
		ll tmp=g*inv(a[i]);
		tmp%=mod;
		sum+=tmp;
		sum%=mod;
	}
	cout<<sum<<'\n';
	return 0;
}

Measured memory_bytes: 768
n, a, b = gets.chomp.split(" ").map(&:to_i)
ans = 0

def digest(n)
  sum = 0
  while n > 0
    sum += n % 10
    n /= 10
  end
  return sum
end

(1..n).each do |m|
  res = digest(m)
  if res >= a && res <= b
    ans += m
  end
end

p ans

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
using ll = long long;
using P = pair<ll, ll>;
template<class T> inline bool chmax(T& a, T b) {if (a < b){a = b;return 1;}return 0;}
template<class T> inline bool chmin(T& a, T b) {if (a > b){a = b;return 1;}return 0;}
const long long LLINF = 1LL << 60;
using namespace std;

ll dp[101010];

int main()
{
    int N, K;
    cin >> N >> K;
    vector<ll> h(N);
    rep(i, N) cin >> h[i];

    rep(i, N) dp[i] = LLINF;
    dp[0] = 0;
    rep(i, N)
    {
        for (int k=1; k<=K; ++k)
        {
            if (i-k>=0)
            {
                dp[i] = min(dp[i], dp[i-k] + abs(h[i] - h[i-k]));
            }
        }
    }

    cout << dp[N-1] << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		 //sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;
int main() {
    int N;
    cin>>N;
    vector<ll> T(N),A(N);
    ll maxT = 0, maxA = 0;
    rep(i,N){cin>>T[i];maxT = max(maxT, T[i]);}
    rep(i,N){cin>>A[i];maxA  = max(maxA, A[i]);}
    /*if(maxT!=maxA){
        cout<<0<<endl;
        return 0;
    }*/
    if(A[0]!=T[N-1]){
        cout<<0<<endl;
        return 0;
    }
    //自由度があるかないか
    vector<int> GL(N),GR(N);
    GL[0] = 0;
    GR[N-1] = 0;
    rep1(i,N){
        if(T[i-1]==T[i]){
            GL[i] = 1;
        }
        else{
            GL[i] = 0;
        }
    }
    for (int i = N-2; i >= 0; --i){
        if(A[i]==A[i+1]){
            GR[i] = 1;
        }
        else{
            GR[i] = 0;
        }
    }
    //print(GL);
    //print(GR);
    ll ans = 1;
    rep(i,N){
        //cerr<<GR[i]<<" "<<GL[i]<<endl;
        //cerr<<T[i]<<" "<<A[i]<<endl;
        if(GR[i]==1&&GL[i]==1){
            ans*=min(T[i],A[i]);
            ans%=MOD;
        }
        else if(GL[i]==1&&GR[i]==0){
            if(T[i]>=A[i]){
                continue;
            }
            else{
                ans*=0;
            }
        }
        else if(GL[i]==0&&GR[i]==1){
            if(T[i]<=A[i]){
                continue;
            }
            else{
                ans*=0;
            }
        }
        //cerr<<ans<<endl;
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
using namespace std;


int main() {
    int a,b,c,d,e,k;
    cin>>a>>b>>c>>d>>e>>k;
    if(k<e-a)cout<<":("<<endl;
    else cout<<"Yay!"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
#include <iomanip>
#include <limits>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;

#define ALL(a) (a).begin(),(a).end()
#define INF 1e+9
#define MAX_V 300

struct edge {
    int to;
    int cost;
};
using P = pair<ll, ll>;

int main(){
  int h,w;cin>>h>>w;int k;cin>>k;
  vector<vector<int>> a(h,vector<int>(w,0));
  REP(i,h){
    REP(j,w){
      char tmp;cin>>tmp;
      if(tmp=='#'){
        a[i][j]=1;
      }
    }
  }
  int ans=0;
  for(int i=0;i<(1<<h);i++){
    for(int j=0;j<(1<<w);j++){
      int count=0;
      for(int r=0;r<h;r++){
        int er=pow(2,r);
        if((er&i)==er){

        }else{
          for(int e=0;e<w;e++){
            int tmp=pow(2,e);
            if((tmp&j)==tmp){
              continue;
            }else{
              if(a[r][e]==1){
                count++;
              }
            }
          }
        }
      }
      if(count==k){
        ans++;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3204
def main():
  from math import gcd
  k = int(input())
  
  total = 0
  for a in range(1,k+1):
    for b in range(1,k+1):
      temp = gcd(a, b)
      for c in range(1,k+1):
        total+= gcd(temp, c)
  print(total)
main()

Measured memory_bytes: 9044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
int D;
vector<int> c(26);
int main()
{
    cin >> D;
    int s[366][28];
    int last[28];

    rep(i, 1, 27)
    {
        cin >> c[i];
    }
    rep(i, 1, D + 1)
    {
        rep(j, 1, 27)
        {
            cin >> s[i][j];
            last[j] = 0;
        }
    }
    vector<int> t(D + 1);
    vector<ll> tmp(D + 1);

    ll score = 0;
    ll maxi = -100000;
    int dcon;
    rep(i, 1, D + 1)
    {
        // }
        maxi = 0;
        rep(j, 1, 27)
        {
            //i日目の満足度の最大値を求める
            score = s[i][j];
            rep(k, 1, 27)
            {
                score -= c[k] * (i - last[k]);
            }
            if (maxi < score)
            {
                maxi = score;
                dcon = j;
            }
        }
        t[i] = dcon;
        last[dcon] = i;
    }

    rep(i, 1, D + 1)
    {
        cout << t[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3664
#include <iostream>
using namespace std;
int main(){
    int count [4][3][10];
    for (int i =0 ; i<4; i++) {
        for (int j = 0; j<3; j++) {
            for (int k = 0; k<10; k++) {
                count [i][j][k] = 0;
            }
        }
    }
    int n;
    cin >> n;
    int a,b,c,d;
    for (int l=0; l<n; l++) {
        cin >> a >> b >> c >> d;
        count [a-1][b-1][c-1] += d;
    }
    
    for (int q=0;q<4;q++) {
        for (int x=0; x<3; x++) {
            for (int y=0; y<10; y++) {
                cout <<" "<< count [q][x][y];
            }
            cout  << endl;
        }
        if (q==3) {
            break;
        }
        for (int z= 0; z<20; z++){
            cout << "#";
        }
        cout << endl;
    }
    
}




Measured memory_bytes: 3032
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#define SIZE 100005

using namespace std;
typedef long long int ll;

struct edge
{
	int to,id;
	edge(int to=0,int id=0):to(to),id(id){}
};
vector <edge> vec[SIZE];
int nd[SIZE];
int A[SIZE],B[SIZE];
ll C[SIZE];
ll sum[SIZE];
ll all;

void dfs(int v=0,int p=-1)
{
	nd[v]=1;
	for(int i=0;i<vec[v].size();i++)
	{
		int to=vec[v][i].to;
		if(to!=p)
		{
			dfs(to,v);
			nd[v]+=nd[to];
		}
	}
}
void dfs2(int v=0,int p=-1,ll d=0)
{
	all+=d;
	for(int i=0;i<vec[v].size();i++)
	{
		edge e=vec[v][i];
		if(e.to!=p)
		{
			dfs2(e.to,v,d+C[e.id]);
		}
	}
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n-1;i++)
	{
		scanf("%d %d",&A[i],&B[i]);
		A[i]--,B[i]--;
		vec[A[i]].push_back(edge(B[i],i));
		vec[B[i]].push_back(edge(A[i],i));
		C[i]=-1;
	}
	for(int i=0;i<n;i++) scanf("%lld",&sum[i]);
	dfs();
	int a=-1,b=-1;
	for(int i=0;i<n-1;i++)
	{
		if(nd[A[i]]<nd[B[i]]) swap(A[i],B[i]);
		//A[i] : parent of B[i]
		if(sum[A[i]]!=sum[B[i]])
		{
			//A[i]=a+b+nd[b]*C[i]
			//B[i]=a+b+(n-nd[b])*C[i]
			C[i]=(sum[A[i]]-sum[B[i]])/(ll) (2*nd[B[i]]-n);
		}
		else
		{
			a=A[i];
			b=B[i];
		}
	}
	if(a!=-1)
	{
		all=0;
		dfs2(b,a,0);
		dfs2(a,b,0);
		for(int i=0;i<n-1;i++)
		{
			if(C[i]==-1)
			{
				C[i]=(sum[A[i]]-all)/(ll) nd[B[i]];
			}
		}
	}
	for(int i=0;i<n-1;i++) printf("%lld\n",C[i]);
	return 0;
}


Measured memory_bytes: 16896
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

struct Edge{
  int to, id;
};

int N; 
vector<vector<Edge>> G;
vi color;

// 深さ優先探索
void dfs(int v, int c = -1, int p = -1) {
    int k = 1;
    rep(i,G[v].size()){
    	int u = G[v][i].to, ei = G[v][i].id;
      	if(u==p) continue;
      	if(k==c) ++k;
      	color[ei] = k; ++k;
      	dfs(u,color[ei],v);
    }
}

void Main() {
    // 頂点数 N, 辺数 M
    cin >> N;
	int M = N-1;
    // グラフ
    G.resize(N);
  	color.resize(M);
    rep(i,M) {
        int a, b;
        cin >> a >> b;
      	a--, b--;
        G[a].push_back((Edge){b,i});
      	G[b].push_back((Edge){a,i});
    }
	dfs(0);
  	int mx = 0;
  	rep(i,M) mx = max(mx, color[i]);
  	cout << mx << endl;
  	rep(i,M) cout << color[i] << endl;
  	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 8320
def resolve():
    A, B, C = map(int, input().split())
    cnt = 0
    while True:
        if A%2 == 1 or B%2 == 1 or C%2 == 1:
            break
        elif A==B and B==C:
            cnt = -1
            break
        Atmp = A
        Btmp = B
        Ctmp = C
        A = (Btmp+Ctmp)/2
        B = (Atmp+Ctmp)/2
        C = (Atmp+Btmp)/2
        cnt += 1
    print(cnt)
resolve()


Measured memory_bytes: 38256
#include<iostream>
using namespace std;
int main(){
	int H,W;
	while(cin>>H>>W){
		if(H==0&&W==0) break;
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				cout<<"#";
			}
			cout<<"\n";
		}
	cout<<endl;
	}
	
	return 0;
}


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

int main(){
  int N;
  cin>>N;
  int a,cnt=0;
  for(int i=0;i<N;i++){
    cin>>a;
    if(a%2)
      cnt++;
  }
  if(cnt%2)
    cout<<"NO"<<endl;
  else
    cout<<"YES"<<endl;
}

Measured memory_bytes: 256
#include <map>
#include <algorithm>
#include <cassert>
#include <climits>
#include <complex>
#include <cstdio>
#include <string>
#include <iostream>
#include <queue>
#include <string>
#include <tuple>
#include <vector>
#include <bitset>
using namespace std;
using ll = long long;
using ld = long double;

template<class T> bool chmin(T &a, T b) { return a>b?(a=b,true):false; }
template<class T> bool chmax(T &a, T b) { return a<b?(a=b,true):false; }
#define FOR(i,x,y) for(int i=(x);i<(int)(y);i++)
#define REP(i,y) for(int i=0;i<(int)(y);i++)
#define repp(i,y) for(int i=1;i<=(int)(y);i++)
#define REPB(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
#define bs2int(bs) ((bs).to_ullong())
#define debug(X) cerr<<" "<<#X<<" = "<<X<<endl;


template<class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) os << " ";
    os << *it;
  }
  return os;
}

// 要整形
// 1. rightmostはいらない
// 2. bitsetを使わないように書き換える

ll n,k;
ll a[100100], b[100100];

int main() {
  cin>>n>>k;
  vector<int> v;
  v.push_back(k);
  for(int i=0; (k>>i)>0; i++) {
    int cand = k;
    REP(j,i) cand |= (1<<j);
    if ((cand>>i) & 1) cand -= (1<<i);

    if (cand < k) v.push_back(cand);
  }
  REP(i,n) {
    cin>>a[i]>>b[i];
  }
  ll mxans = 0;
  for (int k : v) {
    ll ans = 0;
    REP(i,n) {
      if (k==(k | a[i])) ans+=b[i];
    }
    chmax(mxans, ans);
  }
  cout << mxans << endl;
}


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

#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll=long long;

int main(){
	int N,x;
	cin >> N >> x;
	int d=0;
	int ans=1;
	rep(i,N){
		int l;
		cin >> l;
		d +=l;
		if(d<=x)ans++;
	}
	cout << ans;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int m = scanner.nextInt();
		int l = scanner.nextInt();
		int[][] A = new int[n][m];
		int[][] B = new int[m][l];
		long[][] C = new long[n][l];

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				A[i][j] = scanner.nextInt();
			}
		}
		for (int i = 0; i < m; i++) {
			for (int j = 0; j < l; j++) {
				B[i][j] = scanner.nextInt();
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < l; j++) {
				for (int k = 0; k < m; k++) {
					C[i][j] += A[i][k] * B[k][j];
				}
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < l; j++) {
				System.out.print(C[i][j]);
				if(j < l-1)
					System.out.print(" ");
			}
			System.out.println();
		}
 	}
}



Measured memory_bytes: 53944
#!/usr/bin/env python3
# スペース区切りの整数の入力
n, d = map(int, input().split())
#配列の入力
data = [list(map(int, input().split())) for _ in range(n)]


d2 = d**2
count = 0
for i in range(n):
    if d2 >= data[i][0]**2 + data[i][1]**2:
        count += 1

print(count)


Measured memory_bytes: 45484
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define mod 1000000007
using namespace std;
typedef long long ll;

int main()
{
	string S;	cin >> S;
	vector<int> num(26, 0);
	if (S.size() < 26) {
		rep(i, S.size()) {
			num[S[i] - 'a'] = 1;
		}
		rep(i, 26) {
			if (num[i] == 0) {
				char c = 'a' + i;
				cout << S << c << endl;
				cin >> S;
				return 0;
			}
		}
	}
	else {
		rep(i, 25) {
			num[S[25 - i] - 'a'] = 1;
			if (S[24 - i] < S[25 - i]) {
				rep(j, 26) {
					if (num[j] == 1 && j > S[24 - i] - 'a') {
						char c = 'a' + j;
						cout << S.substr(0, 24 - i) << c << endl;
						cin >> S;
						return 0;
					}
				}
			}
		}
	}
	cout << -1 << endl;
	cin >> S;
}

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

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

	vector<bool> t1(10);
	vector<bool> t2(100);
	vector<bool> t3(1000);

	for (int i=0;i<s.size();++i)
	{
		int d=s[i]-'0';
		for (int j=0;j<t2.size();++j)
		{
			if (t2[j]!=false)
			{
				t3[j*10+d]=true;
			}
		}
		for (int j=0;j<t1.size();++j)
		{
			if (t1[j]!=false)
			{
				t2[j*10+d]=true;
			}
		}
		t1[d]=true;
	}

	int count=0;
	for (int i=0;i<t3.size();++i)
	{
		if (t3[i]!=false)
		{
			++count;
		}
	}
	cout << count << endl;
}







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

bool slove(string s)
{
  if(s[0]=='x' && s[s.size()-1]=='x')
    return false;
  else
    return true;

}
int main()
{
  string s;
  for(;cin>>s;)
    {
      if(slove(s))
	cout<<"o"<<endl;
      else
	cout<<"x"<<endl;
    }
}

Measured memory_bytes: 1180
#include<bits/stdc++.h>
#define ll          long long
#define dl          double
#define pb          push_back
#define eb          emplace_back
#define mp          make_pair
#define F           first
#define S           second
#define endl        "\n"
#define rep(i,a,b)  for(i=a;i<b;i++)
#define all(v)      v.begin(),v.end()
#define allr(v)     v.rbegin(),v.rend()
#define mod         998244353
#define CIN(V,s,n)  for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n) for(int i=s;i<n;i++){cout <<  V[i] << " ";}
#define fast        ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define CLEAR(V);   for(ll i=0;i<V.size();i++) V[i] = 0;
using namespace std;

bool SbS(const pair<int,int> &a,const pair<int,int> &b)
{return (a.second < b.second);}

ll SUMD(ll n)
{   ll sum=0;
    while(n>0){sum += n%10;n = n/10;}
    return sum;
}

ll BS(vector<ll> &PS,ll s,ll e,ll ser)
{
    if(s>e)
        return s;
    ll mid = (s+e)/2;
    if(PS[mid]==ser)
    {
        return mid;
    }
    else if(PS[mid] > ser)
    {
        return BS(PS,s,mid-1,ser);
    }
    else
        return BS(PS,mid+1,e,ser);
}
ll MI(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;
    return x;
}
/*
void Sieve(int n)
{
    memset(P,true,sizeof(P));
    P[0] = false;
    P[1]= false;
    for(ll i=2;i*i<=n;i++)
    {
        if(P[i])
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                P[j]=false;
            }
        }
    }

}
*/
int nCrModp(int n, int r, int p)
{
    int C[r+1];
    memset(C, 0, sizeof(C));

    C[0] = 1;
    for (int i = 1; i <= n; i++)
    {
        for (int j = min(i, r); j > 0; j--)

            C[j] = (C[j] + C[j-1])%p;
    }
    return C[r];
}

int main()
{
ll t=1;
//cin >> t;
while(t--)
{
    string st="abcdefghijklmnopqrstuvwxyz";
    ll n,m,p,k,i,j,l,t1,r,u,v,x,y,a,b,c,d,q,flag=1,x1,x2,y1,y2;
    cin >> x >> y ;

    if((y-x)/2019 > 0 || x%2019==0 || y%2019 == 0)
        {cout << 0;
    return 0;}

    x = x%2019;
    y = y%2019;


    x1 = x;
    y1 = y;
    ll Imin = (x1*(x1+1))%(2019);

    for(i=x;i<=y;i++)for(j=i+1;j<=y;j++)
    {
        if(((i*(j))%2019 < Imin))
        {
            Imin = (i*(j))%2019;
        }
    }

    cout << Imin;

}
    return 0;
}


Measured memory_bytes: 256
import math
import collections
import sys

#input = sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]

a,b=MI()
if a==2 or b==2:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3316
#include<bitset>
#include<iostream>
using namespace std;
int main(){
	int N,M,X;
	cin >> N >> M >> X;
	int a[12][12];
	int money[12];
	for(int i=0;i<N;i++){
		cin >> money[i];
		for(int j=0;j<M;j++){
			cin >> a[i][j];
		}
	}
	int min=-1;
	for(int i=0;i<(1<<N);i++){
		int tmp[12]={};
		for(int j=0;j<N;j++){
			if(i&(1<<j)){
				for(int k=0;k<M;k++){
					tmp[k]+=a[j][k];
				}
 
			}
		}
		bool flag = true;
		for(int k=0;k<M;k++){
			if(tmp[k]<X){
				flag=false;
			}
		}
			if(flag){
				int mo=0;
				for(int j=0;j<N;j++){
					if(i&(1<<j)){
						mo +=money[j];
					}
				}
				if(min==-1||mo<min)min=mo;
			}
	}
	cout << min;
}

Measured memory_bytes: 3632
s = input()
lens = len(s)
ans = [1]*len(s)
for i in range(lens-2):
  if s[i] == 'R' and s[i+1] == 'R':
    ans[i+2] += ans[i]
    ans[i] = 0
for i in range(1,lens-1):
  if s[-i] == 'L' and s[-(i+1)] == 'L':
    ans[-(i+2)] += ans[-i]
    ans[-i] = 0
print(*ans)

Measured memory_bytes: 6400
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	ll h = in(), w = in();
	REP(i, h) {
		string s; cin >> s;
		cout << s << endl << s << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define ld long double
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007

int n, m;

int main(){
     int s, w;
     cin >> s >> w;
     if(s <= w)cout<<"unsafe\n";
     else cout<<"safe\n";
return 0;
}

Measured memory_bytes: 3632
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e9+7;
ll INF=1e10;

ll RepeatSquaring(ll a, ll n, ll p){
    if(n==0) return 1;
    if(n%2==0){
        ll t = RepeatSquaring(a, n/2, p);
        return t*t % p;
    }
    return (a*RepeatSquaring(a, n-1, p))%p;
}

ll nCr(ll n, ll r, ll mod){
    ll mul = 1, div = 1;
    for(ll i = 0; i < r; i++){
        mul *= n - i;
        div *= i + 1;
        mul %= mod;
        div %= mod;
    }   
    return mul * RepeatSquaring(div, mod - 2, mod) % mod;
}

int main(){
    ll n,a,b; cin>>n>>a>>b;
    a=min(a,n-a);
    b=min(b,n-b);
    ll ans=RepeatSquaring(2,n,mod)-1;
    ll A=nCr(n,a,mod),B=nCr(n,b,mod);
    ans-=(A+B);
    ans%=mod;
    if(ans<0)ans+=mod;
    cout<<ans<<endl;


}



























































































Measured memory_bytes: 3596
#include "bits/stdc++.h"
using namespace std;


int main() {
  int N;
  char S;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> S;
    if(S == 'Y'){
      cout << "Four" << endl;
      break;
    }
    if(i == N-1){
      cout << "Three" << endl;
    }
  }
}


Measured memory_bytes: 256
import std.algorithm;
import std.stdio;

void main ()
{
	int n;
	while (readf (" %s", &n) > 0)
	{
		auto a = new int [] [n];
		foreach (i; 0..n - 1)
		{
			int u, v;
			readf (" %s %s", &u, &v);
			u -= 1;
			v -= 1;
			a[u] ~= v;
			a[v] ~= u;
		}

		int recur (int v, int p)
		{
			int res = 0;
			foreach (u; a[v])
			{
				if (u != p)
				{
					res ^= recur (u, v) + 1;
				}
			}
			return res;
		}

		writeln (recur (0, -1) ? "Alice" : "Bob");
	}
}


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

typedef std::pair<int, int> ipair;
#define pb push_back
#define ff first
#define ss second
#define fr(i, j, k) for (int i = j; i < k; i++)
#define int long long
#define ld long double
#define cnt_ones(x) __builtin_popcount(x)
#define all(x) x.begin(), x.end()
#define mp make_pair
#define mod 1000000007

template<class T> ostream& operator <<(ostream &out,vector<T> &A){for(auto x:A) out<<x<<" ";return out;}
template <class T1,class T2>T1 powr(T1 a,T2 b){T1 res = 1;fr(i,1,b+1)res = res*a;return res;}
#define IOS  std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int dp[101][100001];

int32_t main(){
  int n,w;  cin>>n>>w;
  int val[n],wt[n];
  for(int i=0;i<n;i++)
  cin>>wt[i]>>val[i];

  for(int i=0;i<=n;i++)
  for(int j=0;j<=w;j++){
    //cout<<dp[i][j]<<endl;
    if(i==0 or j==0)  dp[i][j]=0;
    else if(wt[i-1] <= j)   dp[i][j] = max(dp[i-1][j], val[i-1] + dp[i-1][j-wt[i-1]]);
    else  dp[i][j] = dp[i-1][j];
  }

  cout<<dp[n][w]<<endl;

}


Measured memory_bytes: 79104
#include <stdio.h>
#include <math.h>
int main(){
  int A,B;
  double C,S,L,H;
  scanf("%d %d %lf",&A,&B,&C);
  C=C*M_PI/180;
  S=0.5*A*B*sin(C);
  L=A+B+sqrt((A*A)+(B*B)-2*A*B*cos(C));
  H=2*S/A;
  printf("%f %f %f\n",S,L,H);
  return 0;
}

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

typedef long long ll;
typedef unsigned long long llu;

int main(int argc, char *argv[]) {
  ll x, y, z;
  cin >> x >> y >> z;

  ll n = x / y;
  while (1) {
    ll m = (n*y) + ((n-1)*z) + (2*z);
    if (x >= m) {
      break;
    }
    n--;
  }
  cout << n << endl;

  return 0;
}

Measured memory_bytes: 256
# input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
import copy
N,M=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(M)]
data=[[] for i in range(N+1)]
for a,b in AB:
    data[a].append(b)
    data[b].append(a)

count=0
stack=[[1,set([1])]]
while stack:
    point,visited=stack.pop()
    for p in data[point]:
        if not p in visited:
            if len(visited)+1==N:
                count+=1

            else:
                a=copy.copy(visited)
                a.add(p)
                stack.append([p,a])
print(count)


Measured memory_bytes: 40176
N = int(input())
N_list = [0]* 100000

for z in range(1,101):
    for y in range(1,101):
        for x in range(1,101):
            ans = x**2 + y**2 + z**2 + x*y + y*z + z*x
            N_list[ans-1] += 1

for i in range(N):
    print(N_list[i])

Measured memory_bytes: 9584
#!/usr/bin/env python3.4
# -*- coding: utf-8 -*-

# abc124_d

# input
n, k = [int(s) for s in input().split()]
S = input()
# get ans
node = [len(s) for s in S.split('0')]
node = [s for i, s in enumerate(node) if not (s==0 and i!=0 and i!=len(node)-1)]
arch = [len(s) for s in S.split('1')]
arch = list(filter(int, arch))
from itertools import chain
flatten = chain.from_iterable
xs = list(flatten(zip(node, arch))) + node[-1:]
l = len(xs)
sumlist = [None]*(l+2)
sumlist[-1] = 0
for i in range(l):
    sumlist[i] = sumlist[i-1] + xs[i]
def get_sum(f, n):
    f = min(f, l)
    t = f+n
    t = min(t, l)
    return sumlist[t-1] - sumlist[f-1]
def get_ans():
    for i in range(l//2+1):
        yield get_sum(i*2, k*2+1)
ans = max(get_ans())
# output
# print(node)
# print(arch)
# print(xs)
# print(sumlist)
# print(get_sum(0, 2))
# print(list(get_ans()))
print(ans)


Measured memory_bytes: 8668
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		long n = Long.parseLong(sc.next());
		long a = Long.parseLong(sc.next());
		long b = Long.parseLong(sc.next());
		if (a == 0) {
			System.out.println(0);
			return;
		}

		if (b == 0) {
			System.out.println(n);
			return;
		}

		long q = n / (a + b);
		long r = n % (a + b);
		long ans = (r == 0) ? a * q : (r < a) ? a * q + r : a * q + a;
		System.out.println(ans);
	}

}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define For(i,n,k) for(int i=(n);i<(k);i++)
// ローリングハッシュ
// 二分探索で LCP を求める機能つき
struct RollingHash {
    static const int base1 = 1007, base2 = 2009;
    static const int mod1 = 1000000007, mod2 = 1000000009;
    vector<long long> hash1, hash2, power1, power2;

    // construct
    RollingHash(const string &S) {
        int n = (int)S.size();
        hash1.assign(n+1, 0);
        hash2.assign(n+1, 0);
        power1.assign(n+1, 1);
        power2.assign(n+1, 1);
        for (int i = 0; i < n; ++i) {
            hash1[i+1] = (hash1[i] * base1 + S[i]) % mod1;
            hash2[i+1] = (hash2[i] * base2 + S[i]) % mod2;
            power1[i+1] = (power1[i] * base1) % mod1;
            power2[i+1] = (power2[i] * base2) % mod2;
        }
    }
    
    // get hash of S[left:right]
    inline pair<long long, long long> get(int l, int r) const {
        long long res1 = hash1[r] - hash1[l] * power1[r-l] % mod1;
        if (res1 < 0) res1 += mod1;
        long long res2 = hash2[r] - hash2[l] * power2[r-l] % mod2;
        if (res2 < 0) res2 += mod2;
        return {res1, res2};
    }

    // get lcp(最長共通接頭辞) of S[a:] and T[b:]
    inline int getLCP(int a, int b) const {
        int len = min((int)hash1.size()-a, (int)hash1.size()-b);
        int low = 0, high = len;
        while (high - low > 1) {
            int mid = (low + high) >> 1;
            if (get(a, a+mid) != get(b, b+mid)) high = mid;
            else low = mid;
        }
        return low;
    }
};

void Main(){    
    int n,ans=0;string s;
    cin>>n>>s;
    RollingHash roriha(s);
    int ok=0,ng=n;
    while(ok+1<ng){
        int mid=(ok+ng)/2;
        map<pair<long long,long long>,int> mp;
        bool flag=false;
        For(i,0,n-mid+1){
            pair<long long,long long> lh=roriha.get(i,i+mid);
            if(mp.count(lh)){
                if(mp[lh]+mid-1<i){
                    flag=true;
                    break;
                }
                else continue;
            }
            else{
                mp[lh]=i;
            }
        }
        (flag?ok:ng)=mid;
    }
    cout<<ok<<endl;
}
int main(){
    Main();
    return 0;
}


Measured memory_bytes: 768
#include <stdio.h>
int main()
{
  int a, b, c;
  scanf("%d %d", &a, &b);
  if(a < b){
    c = a;
    a = b;
    b = c;
  }
  while(1){
    c = a % b;
    if(c == 0){
      printf("%d\n", b);
      break;
    } else{
      a = b;
      b = c;
    }
  }
  return 0;
}

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

int main() {
    string s;
    cin >> s;
    int ct = 0;
    while(s[ct] != '\0') {
        if(ct%2 == 0) {
            if(s[ct] == 'L') {
                cout << "No" << endl;
                return 0;
            }
        } else {
            if(s[ct] == 'R') {
                cout << "No" << endl;
                return 0;
            }
        }
        ct ++;
    }
    cout << "Yes" << endl;
    return 0;
}

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

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/

  int t[4];
  int n[4];

  for(int i=0;i<4;i++){
    cin>>t[i]>>n[i];

    if(t[i]==1){
      cout<<6000*n[i]<<endl;
    }
    else if(t[i]==2){
      cout<<4000*n[i]<<endl;
    }

    else if(t[i]==3){
      cout<<3000*n[i]<<endl;
    }

    else if(t[i]==4){
      cout<<2000*n[i]<<endl;
    }
  }

  return 0;

}



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

signed main(){
	lint N; cin >> N;
	vector<lint> a(N);
	for(int i = 0; i < N; i++) cin >> a[i];
	lint right = 0, ans = 0, num = 0;
	for(lint left = 0; left < N; left++){
		while(right < N && num + a[right] == (num ^ a[right])){
			num += a[right];
			right++;
		}
		ans += right - left;
		if(left == right) right++;
		else num -= a[left];
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
N, A, B = [int(i) for i in input().split()]
S = input()

tuuka = 0
kaigai = 0

for s in S:
    if s == "b":
        kaigai += 1
        if tuuka < A + B and kaigai <= B:
            ans = "Yes"
            tuuka += 1
        else:
            ans = "No"
    elif s == "a":
        if tuuka < A + B:
            ans = "Yes"
            tuuka += 1
        else:
            ans = "No"
    else:
        ans = "No"
    print(ans)


Measured memory_bytes: 4016
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
	const int mod=1000000007;
	static void Main(){
		int n=int.Parse(Console.ReadLine());
		double d=1,a=4.0/n;
		int i,b=0;
		for(i=1;d!=0;i++){
			d=1.0/i;
			if(d<a){
				b=i*n;
				if(4*i-n==1){
					Console.WriteLine("{0} {0} {1}",i*2,b);
					break;
				}
				else if(b%(4*i-n)==0){
					Console.WriteLine("{0} {0} {1}",i*2,b/(4.0*i-n));
					break;
				}
				double m=Math.Sqrt(4*i-n);
				for(int j=1;j<=m;j++){
					if(b%(4*i-n-j)==0&&b%j==0){
						Console.WriteLine("{0} {1} {2}",i,b/j,b/(4.0*i-n-j));
						d=0;
						break;
					}
				}
			}
		}
	}
}

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

int main()
{
    int testcase;

    string s;
    cin >> s ;
    int r=0;
    if(s[0]=='R')
        r++;
    for(int i=1; i<3; i++)
    {
        if(s[i]=='R')
        {
            if(s[i-1]=='R')
                r++;
            else
                r=1;
        }
    }
    cout << r ;
    return 0;
}

Measured memory_bytes: 3596
s = input()

i = len(s)

while i > 0:
    if s[i-5:i] == 'dream':
        i -= 5
        continue
    elif s[i - 7:i] == 'dreamer':
        i -= 7
        continue
    elif s[i-5: i] == 'erase':
        i -= 5
        continue
    elif s[i-6: i] == 'eraser':
        i -= 6
        continue
    else:
        print('NO')
        exit(0)

print('YES')

Measured memory_bytes: 3188
N = int(input())

if N == 1:
    print(1)
    exit()

count_dic = {}
for i in range(N+1):
    i_tmp = i
    count = 0
    while True:
        if i == 0:
            break
        elif i_tmp % 2 == 0:
            i_tmp = i_tmp / 2
            count += 1
        else:
            break
    count_dic[i] = count
print(max(count_dic, key=count_dic.get))


Measured memory_bytes: 3064
#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>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define mt make_tuple
#define popb pop_back
#define popf pop_front
#define int long long int
#define vi         vector<int>
#define vll        vector<ll>
#define vpii       vector<pair<int,int>>
#define vpll       vector<pair<ll,ll>>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(container) int((container).size())
#define rep(i,a,b) for(i=a;i<b;i++)
#define tr(container,it)   for(auto it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())      //set,map etc.
#define cpresent(container, element) (find(all(container),element) != container.end())    //vector
#define hell 1000000007
#define PI 3.14159265
#define mod 998244353
#define fs first
#define sc second
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
int maxi(int a, int b, int c)
{return max(a,max(b,c));}
void solve()
{
 int n,i,j,k;
 cin>>n;
 int a[n],b[n],c[n];
 rep(i,0,n)cin>>a[i]>>b[i]>>c[i];
 int dp[n][3];
 if(n==1){cout<<max(a[0],max(b[0],c[0]));return;}
 dp[0][0]=a[0];
 dp[0][1]=b[0];
 dp[0][2]=c[0];
 dp[1][0]=a[1]+maxi(a[0],b[0],c[0]);
 dp[1][1]=b[1]+maxi(a[0],b[0],c[0]);
 dp[1][2]=c[1]+maxi(a[0],b[0],c[0]);
 for(i=2;i<n;i++)
 {
  dp[i][0]=max(dp[i-1][1]+a[i],dp[i-1][2]+a[i]);
  dp[i][1]=max(dp[i-1][0]+b[i],dp[i-1][2]+b[i]);
  dp[i][2]=max(dp[i-1][0]+c[i],dp[i-1][1]+c[i]);
 }
 cout<<maxi(dp[n-1][0],dp[n-1][1],dp[n-1][2]);
}
signed main()
{
  fastio
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  int t;
  t=1;
  //cin>>t;
  while(t--)
  solve();
  TIME
  return 0;
}

Measured memory_bytes: 4992
import sys
sys.setrecursionlimit(10**9)
n, m = map(int, input().split())

root = [-1]*n

def find(n):
    if root[n] < 0:
        return n
    else:
        root[n] = find(root[n])
        return root[n]

def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return
    else:
        root[x] += root[y]
        root[y] = x

def size(n):
    return -root[find(n)]

for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    unite(a, b)

print(-min(root))

Measured memory_bytes: 82200
#include <stdio.h>

int main (int argc,char **argv)
{
	int a,b,c;

	scanf("%d%d%d",&a,&b,&c);

	if (b - a == c - b)
	{
		printf("YES\n");
	}

	else 
	{
		printf("NO\n");
	}

	return 0;
}

Measured memory_bytes: 128
import sys

x = int(input())

a = [i**5 for i in range(0, 300)]

for i in range(300):
    for j in range(300):
        if a[i] - a[j] == x:
            print(i,j)
            sys.exit()
            
        if a[i] + a[j] == x:
            print(i,-j)
            sys.exit()

Measured memory_bytes: 9188
#include <cstdio>
#include <cstring>
int main (){
	int n, len, cnt[50][26] = {0}, low;
	char s[51];
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%s", s);
		len = strlen(s);
		for (int j = 0; j < len; j++)
			cnt[i][s[j] - 'a']++;
	}
	for (int i = 0; i < 26; i++){
		low = cnt[0][i];
		for (int j = 1; j < n; j++){
			if (low > cnt[j][i])
				low = cnt[j][i];
		}
		for (int j = 0; j < low; j++)
			printf("%c", i + 'a');
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
#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;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

const int n = 1000000;
void eratosthenes(vector<int> &prime)
{
    rep(0, i, n) prime.at(i) = 1;
    prime.at(0) = prime.at(1) = 0;
    rep(0, i, n)
    {
        if (prime.at(i))
        {
            for (int j = i + i; j < n; j += i)
            {
                prime.at(j) = 0;
            }
        }
    }
}

bool IsPrime(ll num)
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (ll i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return b;
    }
    return gcd(b, a % b);
}

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(0, i, N)
    {
        cin >> A.at(i);
    }
    sort(all(A));

    vector<int> prime(1000000);
    eratosthenes(prime);
    vector<ll> value;

    rep(0, i, 1000000)
    {
        if (prime.at(i) == 1)
        {
            value.push_back(i);
        }
    }

    vector<ll> memo(1000010, 0);

    ll flag1 = 1;
    ll flag2 = 0;
    ll a_gcd = A.at(0);
    rep(0, i, N)
    {
        ll a = A.at(i);
        if (IsPrime(a))
        {
            memo.at(a) = 1;
            a = 1;
        }
        for (auto v : value)
        {
            if (a < v)
            {
                break;
            }
            if (a % v == 0)
            {
                if (memo.at(v) != 0)
                {
                    flag1 = 0;
                }
                memo.at(v) = 1;
                a /= v;
            }
            if (flag1 == 0)
            {
                break;
            }
        }
        a_gcd = gcd(a_gcd, A.at(i));
    }
    if (a_gcd == 1)
    {
        flag2 = 1;
    }

    if (flag1 == 1)
    {
        cout << "pairwise coprime" << endl;
    }
    else if (flag2 == 1)
    {
        cout << "setwise coprime" << endl;
    }
    else
    {
        cout << "not coprime" << endl;
    }
}

Measured memory_bytes: 23232