akhauriyash/Code-Regression huggingface dataset:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# 符号の反転は最初と最後以外にない

x,y = map(int,read().split())

cand = []
if x <= y:
    cand.append(y-x)
if (-x) <= y:
    cand.append(1 + x + y)
if x <= (-y):
    cand.append(1 - x - y)
if (-x) <= (-y):
    cand.append(2 - y + x)

answer = min(cand)
print(answer)

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

const int N = 2e5 + 10;

int n, a[N], b[N], c[N];
map<int,int> MP;

int cal(int n){
    int ret = 0;
    MP.clear();
    int s, x;
    bool flag = 0;
    for(int i=n-1; i>=0; i--){
        s = 1 << 30;
        flag = 0;
        while(s > c[i]){
            x = s - c[i];
            if(MP.count(x)){
                ret++;
                if(--MP[x] == 0){
                    MP.erase(x);
                }
                flag = 1;
                break;
            }
            s >>= 1;
        }
        if(!flag){
            MP[c[i]]++;
        }
    }
    return ret;
}

int solve(int *a, int n, int *b){
    if(n < 2)   return 0;
    int m = 0;
    int l = 0;
    for(int i=0; i<n; i++){
        if(a[i] & 1){
            c[l++] = a[i];
        } else {
            b[m++] = a[i] >> 1;
        }
    }

    return cal(l) + solve(b, m, a);
}

int main(){
    while(~scanf("%d", &n)){
        for(int i=0; i<n; i++){
            scanf("%d", a+i);
        }
        sort(a, a+n);
        printf("%d\n", solve(a, n, b));
    }
	return 0;
}


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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())

#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
#define LL long long
#define MOD 1000000007

//cout << (c)?"Yay!":":(" << endl;

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
    int n;
    cin >> n;
    map<string, long long int> mp;
    rep(i, n)
    {
        string a;
        cin >> a;
        SORT(a);
        mp[a]++;
    }
    long long int sum = 0;
    //cout << mp.size() << endl;
    for (auto itr = mp.begin(); itr != mp.end(); itr++)
    {
        sum += itr->second * (itr->second - 1) / 2;
    }

    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 11136
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

typedef long long ll;
const int P = 1000000007;
int sum[2001][2001];

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

    vector<int> s(n), t(m);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
        sum[i + 1][0] = 1;
    }
    
    for (int j = 0; j < m; j++) {
        cin >> t[j];
        sum[0][j + 1] = 1;
    }
    
	sum[0][0] = 1;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            int x = sum[i][j + 1] + sum[i + 1][j] - sum[i][j];
            if (x < 0) 
			    x += P;
            if (x >= P) 
			    x -= P;
			    
            if (s[i] == t[j]) {
                x += sum[i][j];
                if (x >= P) 
				    x -= P;
            }
            
            sum[i + 1][j + 1] = x;
        }
    }

    cout << sum[n][m] << endl;

    return 0;
}

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

int main() {
	
	int t,i;
	long long int sum=0;
	int v;
	
	
	
	for(cin>>t,i=t;i--,cin>>v;){
		sum+=v;
	}
	
	cout<<sum/t<<endl;
	
	return 0;
}

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

const unsigned long long LARGE = 1000000000000000000;

int main()
{
  int N;  
  unsigned long long bA;
  unsigned long long A;
  
  cin >> N;
  
  bool ansFlag = false;
 
  unsigned long long ans = 1;
  bA = 1;
  for(int i=0;i<N;i++)
  {
    cin >> A;
       
    if(A == 0)
    {
      cout << 0 << endl;
      return 0;      
    }
    
    ans *= A;    
    
    

    if(ans > LARGE)
      { 
        ansFlag = true;
//        cout << "Marker1" << endl;
      }


    if(!ansFlag){      
      
      if(i>0)
      {
        unsigned long long tmp = ans / A;
//        cout << tmp << endl;
        if(tmp == bA)
        {

        }else{
          ansFlag = true;
//          cout << "Marker2" << endl;
//          cout << ans << " " << tmp << " " << A  << " " << bA  << endl;
        }
      }
    }

    bA = ans;
  }

  if(ansFlag)
  {
    cout << -1 << endl;     
  }else{      
    cout << ans << endl;
  }
    return 0;

}

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

using namespace std;
using ll = long long;

int n;
void dfs(string s,  char mae){
    if((int)s.size() == n){
        cout << s << endl;
        return;
    }

    for(char i = 'a'; i <= mae + 1; i++){
        string S = s;
        S.push_back(i);
        dfs(S, max(mae, i));
    }
}


int main()
{
    cin >> n;
    dfs("a", 'a');


}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;cin>>n;
    vector<ll> a(n);
    rep(i,n){
        ll t;cin>>t;
        a[i]=t-i;
    }
    sort(a.begin(),a.end());
    ll ans=0;
    rep(i,n){
        ans+=abs(a[i]-a[n/2]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<Pll> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define SORT(x) sort(all(x))
#define RSORT(x) sort(all(x),greater<ll>())
#define vec_max(V) *max_element(all(V))
#define vec_min(V) *min_element(all(V))
#define vec_sum(V) accumulate(all(V), 0LL)
#define print(X) cout << (X) << "\n"
#define _ << " " <<
#define Yes print("Yes")
#define No print("No")
static const int INF = 1e+9+7;

int main(){
  ll N;
  cin >> N;
  double tmp = 0.0;
  rep(i,0,N){
    double a;
     cin >> a;
    tmp += 1.0 / a;
  }

  printf("%f\n", 1.0/tmp);
   
 return 0;
}


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

int main(){
  int N;
  double a[1100];
  double sum = 0.0;
  
  cin >> N;
  for(int i = 0; i < N; i++){
  	cin >> a[i];
    sum += 1.0 / a[i];
  }
  
  sum = 1.0 / sum;
  cout << sum << endl;
  
  return 0;
}

Measured memory_bytes: 256
//g++  5.4.0

#include<bits/stdc++.h>
using namespace std;

#define ff first
#define ss second
#define int long long
#define pb push_back
#define pii pair< int,int >
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0) ;

const int mod = 1e9+7;

signed main()
{
    fast;
    int n;
    cin >> n;
    int dp[n+1][n+1];
    memset( dp,0,sizeof(dp));
    dp[1][1] = 1;
    
    for(int len=2 ; len<=n ; len++ )
    {
        int pre[ len ] ;
        pre[0] = 0;
        for(int i=1 ; i<len ; i++ )
            pre[i] = (pre[i-1] + dp[len-1][i])%mod;
        char c;
        cin >> c;
        for(int last=1 ; last<=len ; last++)
        {
            if( c == '<' )
                dp[len][last] = pre[last-1];
            else
                dp[len][last] = (pre[len-1] - pre[last-1] + mod ) %mod;
        }
    }
    /*cout << "\n";
    for(int i=1 ; i<=n ; i++ )
    {
        for(int j=1 ; j<=n ; j++ )
            cout << dp[i][j] << " ";
        cout << "\n";
    }*/
    int ans = 0;
    for(int last=1 ; last <=n ; last++ )
        ans = (ans + dp[n][last] )%mod;
    cout << ans;
}





Measured memory_bytes: 70656
#include<bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define M (L+R)/2
#define N 500009
#define inf 99999999999
#define ll long long
using namespace std;
ll n,dp[N],ind,a[N],sum,k;
string s;
int main(){

	ios::sync_with_stdio(0);
	
	cin>>s;
	n=s.size();
	s+="*";
	k=0;
	for(int i=0;i<n;i++){
		dp[k]++;
		if(s[i]==s[i+1])continue;
		else {
			if(s[i+1]=='*')continue;
			k++;
			s[k]=s[i+1];
		}
	}
	/*for(int i=0;i<=k;i++){
		cout<<s[i]<<" "<<dp[i]<<endl;
	}
	*/
	int i=0;
	if(s[0]=='>'){
		sum+=dp[0]*(dp[0]+1)/2;
		i++;
	}
	for(i;i<=k;i+=2){
		sum+=(dp[i]-1)*(dp[i])/2;
		sum+=(dp[i+1]-1)*(dp[i+1])/2;
		sum+=max(dp[i],dp[i+1]);
	}
	cout<<sum<<endl;
	return 0;
}


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

int f(int b)
{
    int ret = 0;
    while (b)
    {
        ret += b % 10;
        b /= 10;
    }
    return ret;
}

void solve()
{
    int n;
    cin >> n;
    int ans = 1e9;
    for (int a = 1; a < n; a++)
    {
        int b = n - a;
        ans = min(ans, f(b) + f(a));
    }
    cout << ans << endl;
}

int main()
{
    // srand((unsigned)time(NULL));
    // int t = clock();
    solve();
    // double et = 1.0 * (clock() - t) / CLOCKS_PER_SEC;
    // printf("Execution Time: %.4lf sec\n", et);
    return 0;
}

Measured memory_bytes: 3600
from functools import reduce
from collections import Counter


N = int(input())
a = list(map(int, input().split()))
if N % 3 and a != [0] * N:
    print("No")
    exit()

nums = Counter(a)
ks = sorted(nums)
vs = sorted(nums.values())
if (
    (len(nums) == 1 and ks[0] == 0)
    or (len(nums) == 2 and ks[0] == 0 and vs[0] == N // 3)
    or (
        len(nums) == 3
        and all(v == N // 3 for v in vs)
        and reduce(lambda x, y: x ^ y, ks) == 0
    )
):
    print("Yes")
else:
    print("No")


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

#define rep(i, n) REP(i, 0, n)
#define REP(i, k, n) for(auto i = k; i != n; i++)
#define rrep(i, n) RREP(i, n, 0)
#define RREP(i, n, k) for(auto i = n; i != k; i--)
#define ALL(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << " " << x << endl
#define in(x, data) (data).find(x) != (data).end()

typedef long long ll;

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

    int X; cin >> X;
    ll ans = 1, s = 1;
    while(true) {
        if (X <= s) break;
        ans++;
        s += ans;
    }
    cout << ans << endl;;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int N, M;
vector<vector<int>>arr;
vector<queue<int>>dat;

//maxがx以下になるようにできるか？
bool cond(int x, vector<queue<int>>dt)
{
	//引っぺがしの漏れ！！！
	vector<bool>flag(M, false);
	for (;;)
	{
		//数える
		vector<int>cnt(M, 0);
		for (int i = 0; i < N; ++i)
		{
			if (dt[i].empty())return false;//NG
			int match = dt[i].front() - 1;
			cnt[match]++;
		}
		int pill = -1;
		for (int j = 0; j < M; ++j)
		{
			if (cnt[j] > x)
			{
				pill = j;
				break;
			}
		}
		if (pill < 0)break;//OK
		flag[pill] = true;
		for (int i = 0; i < N; ++i)
		{
			while (flag[dt[i].front() - 1])
			{
				dt[i].pop();
				if (dt[i].empty())return false;//NG
			}
		}
	}
	return true;
}

int main(void)
{
	cin >> N >> M;
	for (int i = 0; i < N; ++i)
	{
		arr.push_back(vector<int>());
		dat.push_back(queue<int>());
		for (int j = 0; j < M; ++j)
		{
			int a;
			cin >> a;
			arr[i].push_back(a);
			dat[i].push(a);
		}
	}
	int dn = 0, up = N;
	while (up - dn > 1)
	{
		int mid = (dn + up) / 2;
		if (cond(mid, dat))
		{
			up = mid;
		}
		else
		{
			dn = mid;
		}
	}
	cout << up << endl;
	return 0;
}


Measured memory_bytes: 1956
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;
#define MAX 100
#define WHITE 1
#define GRAY 2
#define BLACK 3

int n;
int graph[MAX][MAX];
stack<int> st;
int *d,*f,*v;
int *color;
int t = 0;

int next(int k){
	for(int i = v[k];i < n;i++){
		v[k]++;
		if(color[i] == WHITE && graph[k][i] == 1) return i;
	}
	return -1;
}

void dfs(int k){
	for(int i = 0;i < n;i++) v[i] = 0;

	st.push(k);
	d[k] = ++t;
	color[k] = GRAY;

	while(!st.empty()){
		int m = next(st.top());
		if(m != -1){
		  if(color[m] == WHITE){
				st.push(m);
				color[m] = GRAY;
				d[m] = ++t;
			}
		}else{
			f[st.top()] = ++t;
			color[st.top()] = BLACK;
			st.pop();
		}
	}
}


int main(){
	cin >> n;
	//?????????
	color = new int[n];
	d = new int[n];
	f = new int[n];
	v = new int[n];
	for(int i = 0;i < n;i++){
		color[i] = WHITE;
		d[i] = 0;
		f[i] = 0;
		for(int j = 0;j < n;j++){
			graph[i][j] = 0;
		}
	}
	//data input
	for(int i = 0;i < n;i++){

		int t,k,p;

		cin >> t >>  k;
		for(int j = 0;j < k;j++){
			cin >> p;
			p--;
			graph[i][p] = 1;
		}
	}
	for(int i = 0;i < n;i++){if(color[i] == WHITE) dfs(i);}
	for(int i = 0;i < n;i++){
		cout << i+1 << " " << d[i] << " " << f[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0; i<=n; i++)
        a[i]=0;

    while(k--)
    {
        int input;
        cin>>input;
        while(input--)
        {
            int check;
            cin>>check;
            a[check]=1;
        }

    }
    int c=0;
    for(int i=1; i<=n; i++)
    {
        if(a[i]==0)
            c++;
    }
    cout<<c<<endl;

}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define N 1111116
#define mod 998244353

int n,m;
long long fac[N],inv[N],ans;

long long C(int x,int y){
	return fac[x]*inv[y]%mod*inv[x-y]%mod;
}

int read(){
	int x=0,f=1;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-f;
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

int main(){
	n=read();m=read();if (n>m) swap(n,m);
	fac[0]=fac[1]=inv[0]=inv[1]=1;
	for (int i=2;i<N;i++) fac[i]=fac[i-1]*i%mod;
	for (int i=2;i<N;i++) inv[i]=-(mod/i)*inv[mod%i]%mod;
	for (int i=2;i<N;i++) inv[i]=inv[i-1]*inv[i]%mod;
	for (int i=1;i<=n;i++)
		ans=(ans+C(2*i,i)*C(n-i+m-i,n-i))%mod;
	printf("%lld\n",(ans*inv[2]%mod*inv[n+m]%mod*fac[n]%mod*fac[m]%mod+m+mod)%mod);
	return 0;
}

Measured memory_bytes: 17664
#include <stdio.h>

int main(){
    long int X, A, B;

    scanf("%ld %ld %d", &X, &A, &B);

    if(A >= B)
        printf("delicious\n");
    else if((B-A) <= X)
        printf("safe\n");
    else
        printf("dangerous\n");

    return 0;
}

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

void solve() {
    int a, b, c;
    cin >> a >>  b >> c;
    cout << min(b/a, c) << "\n";
}

int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); 
    
    int tt;
    tt = 1;
    for(int t=1; t<=tt; t++) {
         solve();
    }
    return 0;
}



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

using namespace std;
 
int main() {
    int n;
    cin >> n;
    long long sum = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 3 == 0 || i % 5 == 0) continue;
        sum += i;
    }
    cout << sum;
    return 0;
}

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

int main(){
    int n;
    double x,ans;
    string s;
    cin>>n;
    
    for(int i=0;i<n;++i){
        cin>>x>>s;
        if(s == "BTC")
        x*= 380000.0;
        
        ans += x;
    }
    
    printf("%.5f",ans);
}

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

using namespace std;
stack<char>st;

int main(){

	string s;
	cin>>s;
	for(int i = 0 ;i<s.size();i++){
		if(st.empty()==true){
			st.push(s[i]);
		}else
		if(s[i]=='S'){
			st.push(s[i]);
		}else if(s[i]=='T'&& st.top()=='S'){
			st.pop();
		}else if(s[i]=='T'&& (st.top()=='T'||st.empty())){
			st.push(s[i]);
		}
	}
	cout<<st.size()<<endl;

}

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

// macro
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  ll h,w;cin>>h>>w;
  if(h==1||w==1)cout<<1<<endl;
  else if(h%2!=0&&w%2!=0)cout<<(h*w)/2+1<<endl;
  else cout<<(h*w)/2<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007
#define MAX 2000005

#define ll long long

//printf("%.10f", );
//cout << fixed << setprecision(10) << heikin << endl;
//vector<vector<int>> data(3, vector<int>(4, -1));
//left + 1 < top

using namespace std;
using P = pair<int, int>;
using Pc = pair<double, int>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };
const double PI = 3.141592653589793;
long long fact[MAX], inv[MAX];
int dx[] = { -1,0,1,0 };
int dy[] = { 0,-1,0,1 };

//////////////////////////////////

vector<vector<int>> bingo(3, vector<int>(3));
vector<vector<int>> tree(100005);
int color[100005];
map<P, int>colorMap;
int m = 0;

struct BridgeInfo {
	int town1;
	int town2;
	int year;
	BridgeInfo(int t1, int t2, int y) {
		town1 = t1;
		town2 = t2;
		year = y;
	}
};

struct People {
	int index;
	int town;
	int year;
	People(int i, int t, int y) {
		index = i;
		town = t;
		year = y;
	}
};

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

struct UnionFind {
	vector<int>uf;

	UnionFind(int size) :uf(size, -1) {};

	int root(int target) {
		if (uf[target] < 0)return target;
		else return uf[target] = root(uf[target]);
	}

	void merge(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b)return;
		if (uf[b] < uf[a])swap(a, b);
		uf[a] += uf[b];
		uf[b] = a;
	}
};

ll CalcPow(ll num, ll power) {
	if (power == 0)return 1;
	if (power % 2 == 0) {
		ll half = CalcPow(num, power / 2);
		return (half * half) % MOD;
	}
	else return (num * CalcPow(num, power - 1)) % MOD;
}

ll combination(ll all, ll select) {
	if (all < select) return 0;
	if (all < 0 || select < 0) return 0;
	return fact[all] * (inv[select] * inv[all - select] % MOD) % MOD;
}

void initCombination(int max) {
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= max; ++i) {
		fact[i] = fact[i - 1] * i % MOD;
	}

	inv[max] = CalcPow(fact[max], MOD - 2);
	for (int i = max - 1; 0 <= i; --i) {
		inv[i] = (inv[i + 1] * (i + 1)) % MOD;
	}
}

struct Connection {
	vector<int>friends;
	vector<int>block;
	vector<int>friendable;
	Connection() {};
};

Connection connection[100005];
int target;

void dfs(int from) {
	int c = 1;
	for (auto t : tree[from]) {
		c = c != color[from] ? c : c + 1;
		color[t] = c;
		colorMap[make_pair(from, t)] = c;
		m = max(c, m);
		dfs(t);
		c++;
	}
}

int main() {

	ll a, b, c;
	std::cin >> a >> b >> c;

	ll left1 = a + b;
	ll right = c;
	right -= left1;

	bool isA = false;
	if (right < 0) {
		std::cout << "No" << endl;
		isA = true;
	}

	if(!isA){
		ll right2 = right * right;
		ll left2 = 4 * a*b;

		string ans = left2 - right2 < 0 ? "Yes" : "No";
		std::cout << ans << endl;
	}
}



Measured memory_bytes: 10880
#include<iostream>
#include<string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {  
  string s;
  cin >> s;
  
  long long int count = 0;
  long long int na = 0;

  for (int i = 0; i <= (int)s.size() - 1; i++) {    
    if (s[i] == 'A') {
      na++;
    }
    else if (s[i] == 'B' && s[i+1] == 'C') {
      count += na;
      i++;
    }
    else {
      na = 0;
    }
  }
  
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 644
#include <iostream>
#include <stdio.h>
#include <vector> 
#include <math.h> 
#include <regex>

using namespace std;
int main(void){
    string S; int K;
    cin >> S >> K;
    smatch match;
    string sub = S.substr(0,K);
    if (regex_search(sub, match, regex("[2-9]"))) {
        cout << match.str() << endl;
    } else {
        cout << 1 << endl;
    }
}


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

using namespace std;

int main() {
  const int t = 8;
  const int n = 15;

  string s;
  cin >> s;
  int v=0;
  for(int i=0; i<s.length(); i++) {
    v = s[i]=='o' ? v+1 : v;
  }

  bool ans = v + n - s.length() >= t;
  string out = ans ? "YES" : "NO";

  cout << out << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

typedef unsigned long long ULLONG;
typedef long long LLONG;

template <class _T> static _T tp_abs(const _T& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}

static const long long MOD_NUM = 1000000007LL;

static void A_task();

int main()
{
	A_task();
	fflush(stdout);
	return 0;
}

static void A_task()
{
	int H, A;
	get2int(H, A);

	int dmg = A;
	int cnt = 1;
	while (dmg < H) {
		cnt++;
		dmg += A;
	}
	printf("%d\n", cnt);
}



Measured memory_bytes: 384
import sys


def input():
    return sys.stdin.readline().strip()


def main():
    N = int(input())
    ans = 0
    for i in range(1, N + 1):
        if i % 3 != 0:
            if i % 5 != 0:
                ans += i

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9168
#include <iostream>
#include <iomanip>
using namespace std;
void solve(){
    double r,l;
    int right[4] = {0,0,0,0};
    int left[4] = {0,0,0,0};
    while(cin >> l >> r){
        if(r >= 1.1){
            right[0]++;
        }else if(r >= 0.6){
            right[1]++;
        }else if(r >= 0.2){
            right[2]++;
        }else{
            right[3]++;
        }
        if(l >= 1.1){
            left[0]++;
        }else if(l >= 0.6){
            left[1]++;
        }else if(l >= 0.2){
            left[2]++;
        }else{
            left[3]++;
        }
    }
    for(int i=0;i<4;i++){
        cout << left[i] << " " << right[i] << endl;
    }
}
int main(){
    solve();
    return 0;
}

Measured memory_bytes: 0
var stdin = require("fs").readFileSync("/dev/stdin", "utf8");
stdin = stdin.trim().split("\n").reverse();
function input(){return stdin.pop()}
var stdout = [];


s = input().split("/")
if (parseInt(s[1], 10) < 5){
    stdout.push("Heisei")
}else{
    stdout.push("TBD")
}


stdout = stdout.join(" ");
console.log(stdout);

Measured memory_bytes: 7372
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define PB emplace_back
#define ALL(x) (x).begin(),(x).end()
#define endl '\n'

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using pi = pair<int,int>;
using pll = pair<ll,ll>;

constexpr int IN = 1000005;
constexpr int INF = 1e9+5;
constexpr int INI = -1;


int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    string s;
    cin >> n >> s;
    if(n>=3200) cout << s;
    else cout << "red";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int H,W; cin>>H>>W;
  vii A(H,vi(W));
  rep(i,0,H){
    rep(j,0,W) cin>>A[i][j];
  }
  int ans=0;
  vi X,Y,x,y;
  rep(i,0,H-1){
    rep(j,0,W-1){
      if(A[i][j]%2==1){
        ans++;
        A[i][j+1]++;
        A[i][j]--;
        X.push_back(i+1);
        Y.push_back(j+1);
        x.push_back(i+1);
        y.push_back(j+2);
      }
    }
    if(A[i][W-1]%2==1){
      ans++;
      A[i][W-1]--;
      A[i+1][W-1]++;
      X.push_back(i+1);
      Y.push_back(W);
      x.push_back(i+2);
      y.push_back(W);
    }
  }
  rep(j,0,W-1){
      if(A[H-1][j]%2==1){
        ans++;
        A[H-1][j+1]++;
        A[H-1][j]--;
        X.push_back(H);
        Y.push_back(j+1);
        x.push_back(H);
        y.push_back(j+2);
      }
    }
  cout<<ans<<endl;
  rep(i,0,X.size()){
    cout<<X[i]<<" "<<Y[i]<<" "<<x[i]<<" "<<y[i]<<endl;
  }
  }



Measured memory_bytes: 8152
#include <bits/stdc++.h>
using namespace std;
/* * * *   * * *   	* * * */
#define ll long long
#define ld long double
#define ms(a,v) memset(a,v,sizeof a)
#define pii pair<int, int>
/* * * *   * * *   	* * * */
 
/* *
 *
 * Author: Hamkor
 *
 * */
int main(){
	int n, t=0; scanf("%d", &n);
	priority_queue<pii, vector<pii>, greater<pii> > q;
	for (int i=0; i<n; ++i){
		int a, b; scanf("%d %d", &a, &b);
		q.push({b, a});
	}
	while (!q.empty()){
		if (t + q.top().second > q.top().first){
			printf("No");
			return 0;
		}
		t+=q.top().second;
		q.pop();
	}
	printf("Yes");
	return 0;
}


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

using namespace std;

template<typename T>
long long modpow(const T n,const T p,const T mod);
template<typename T>
long long modinv(const T n,const T mod);
template<typename T>
bool chmax(T &a,const T &b);
template<typename T>
bool chmin(T &a,const T &b);

long long inf=1000000007;

int main(){
	long long k;
	cin>>k;
	long long ans=0;
	long long hoge=0;
	if(k%2==0){
		cout<<-1<<endl;
		return 0;
	}

	while(true){
		ans++;
		hoge*=10;
		hoge+=7;
		if(hoge%k==0){
			cout<<ans<<endl;
			return 0;
		}
		hoge%=k;

		if(ans>=1000000){
			cout<<-1<<endl;
			return 0;
		}
	}

	return 0;
}

template<typename T>
long long modpow(const T n,const T p,const T mod){
	if(p==0) return 1;
	if(p%2==0){
		long long a=modpow(n,p/2,mod);
		return a*a%mod;
	}
	if(p%2==1) return (modpow(n,p-1,mod)*n)%mod;
	cerr<<"ERROR"<<endl;
	return 1;
}

template<typename T>
long long modinv(const T n,const T mod){
	return modpow(n,mod-2,mod);
}

template<typename T>
bool chmax(T &a,const T &b){
	if(a<b){
		a=b;
		return 1;
	}
	return 0;
}

template<typename T>
bool chmin(T &a,const T &b){
	if(a>b){
		a=b;
		return 1;
	}
	return 0;
}


Measured memory_bytes: 3632
S = input()
sum = 0
for i in range(0, 2**(len(S)-1)):
	m = i
	lst = [S[0]]
	for j in range(1, len(S)):
		if m % 2 == 0:
			lst[-1] = lst[-1]+S[j]
		else:
			lst.append(S[j])
		m //= 2
	for j in range(0, len(lst)):
		sum += int(lst[j])
print(sum)

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

int main() {
  int x;
  cin >> x;
  if(x < 1200) cout << "ABC" << endl;
  else cout << "ARC" << endl;
  return 0;
}


Measured memory_bytes: 3628
//use itertools::Itertools;
use std::cmp;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        n: usize,
        x: usize,
        t:usize
    }

    let mut takoyaki = 0;
    let mut ans = 0;

    while takoyaki < n {
        takoyaki += x;
        ans += t;
    }

    println!("{}", ans);
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 2208
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

int main(){
    int n;
  cin>>n;
  int a[n+1];
  for(int i=1;i<=n;i++){
	cin>>a[i];
  }
  int light=1;
  int ans=0;
  while(1){
    light=a[light];
    if(light==1){
      ans = -1;
      break;
    }else if(light==2){
      ans++;
      break;
    }else if(ans>n){
      ans=-1;
      break;
    }else{
      ans++;
    }
  }
    cout<<ans;
    return 0;
}

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

check = set()
hazimari = -1
owari = 0
y = x

check.add(x)
for i in range(n-1):
    owari = y
    y = y**2 % m
    if y in check:
        hazimari = y
        break
    check.add(y)

if hazimari == -1:#ループするまでもなくnが小さかったとき
    print(sum(check))
    exit()

ans = 0
count = 0
lp = []
y = x
for i in range(n-1):
    ans += y
    y = y**2 % m
    count = i+1
    if y == hazimari:
        lp.append(y)
        for j in range(n):
            y = y**2 % m
            lp.append(y)
            if y == owari:
                break
    else:
        continue
    break

ans += (n-count)//len(lp) * sum(lp)
ans += sum(lp[:(n-count)%len(lp)])
print(ans)

Measured memory_bytes: 14540
//make sure to make new file!
import java.io.*;
import java.util.*;

public class Main{
   
   public static void main(String[] args)throws IOException{
      BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
      PrintWriter out = new PrintWriter(System.out);
      
      int n = Integer.parseInt(f.readLine());
      
      StringTokenizer st = new StringTokenizer(f.readLine());
      
      int[] array = new int[n];
      long[] zfreq = new long[n];
      for(int k = 0; k < n; k++){
         array[k] = Integer.parseInt(st.nextToken());
         if(k-array[k] > 0){
            zfreq[k-array[k]]++;
         }
      }
      
      long answer = 0L;
      
      for(int k = 0; k < n; k++){
         int z = k+array[k];
         if(z < n){
            answer += zfreq[z];
         }
      }
      
      out.println(answer);
      
      
      
      
      
      
      
      
      
      
      out.close();
   }
   
      
}

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

void solve(){
  int n;
  cin>>n;
  vector<ll> arr(n);
  for(int i=0;i<n;i++)
    cin>>arr[i];
  
  char s[n+1];
  cin>>s;
  assert(int(strlen(s)==n));
  vector<ll> base;
  
  for(int i=n-1;i>=0;i--){
    ll ans=arr[i];
    for(ll x: base){
      ans=min(ans,ans^x);
    }
    if(ans==0)
      continue;
    if(s[i]=='0')
      base.push_back(ans);
    else{
      cout<<"1";
      return;
    }
  }
	cout<<"0";
}

int main(){
  int t;
  cin>>t;
  while(t--){
    solve();
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 3540
N=int(input())
A=[int(x) for x in input().split()]
A.sort()

mod = 10**9 + 7
def mulmod(s):
    r = 1
    for i in s:
        r = r*i%mod
    return r


ans = 0
k=1
while A[-1]>0:
    t = 0
    for i in range(N):
        t+=A[i]%2
        A[i]//=2
    r = [N-t, t, pow(2, k-1, mod)]
    ans = (ans + mulmod(r))%mod
    k +=1
print(ans)


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

using namespace std;

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

	vector<int> group(20);
	group[1] = 1;
	group[3] = 1;
	group[5] = 1;
	group[7] = 1;
	group[8] = 1;
	group[10] = 1;
	group[12] = 1;
	group[4] = 2;
	group[6] = 2;
	group[9] = 2;
	group[11] = 2;
	group[2] = 3;

	int x, y;
	cin >> x >> y;
	
	if (group[x] == group[y])
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let a: Vec<i64> = (0..n).map(|_| input()).collect();

    let cnt1 = a.iter().filter(|&a| a % 2 > 0).count();
    let cnt4 = a.iter().filter(|&a| a % 4 == 0).count();
    let cnt2 = n - cnt1 - cnt4;
    println!(
        "{}",
        if cnt1 <= cnt4 || (cnt2 == 0 && cnt1 <= cnt4 + 1) {
            "Yes"
        } else {
            "No"
        }
    );
}


Measured memory_bytes: 4352
import java.util.*;
public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt();
		String s=sc.next();
      	s=s.replace("ABC","");
		System.out.println((a-s.length())/3);
		
		
	}
}


Measured memory_bytes: 35708
from collections import Counter
def solve():
    n = int(input())
    a = list(map(int, input().split()))

    l = Counter(a)
    tw = []
    fo = []
    for i,j in l.items():
        if j >= 2:
            tw.append(i)
        if j >= 4:
            fo.append(i)
    ans = 0
    if len(tw) >= 2:
        tw.sort()
        ans = max(ans, tw[-1]*tw[-2])
    if fo:
        fo.sort()
        ans = max(ans, fo[-1]**2)
    
    return ans
    

print(solve())


Measured memory_bytes: 18600
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int iINF = 1001001001;
const long long llINF = 1LL << 60;
int main()
{
	// AtCoder Petrozavodsk Contest 001-B, 1032, 41:22(UNSOLVED), 解説AC
	int n;
	cin >> n;
	vector<ll> a(n), b(n);
	ll asum, bsum;
	asum = bsum = 0;
	ll diffNumPlus = 0;
	ll diffNumMinus = 0;
	rep(i, n) {
		cin >> a[i];
		asum += a[i];
	}
	rep(i, n) {
		cin >> b[i];
		bsum += b[i];
	}
	rep(i, n) {
		if (a[i] == b[i]) continue;
		if (a[i] > b[i]) diffNumPlus += a[i] - b[i];
		else diffNumMinus += (b[i] + 1 - a[i]) / 2;
	}
	ll diff = bsum - asum;
	if (diff < 0) {
		cout << "No" << endl;
		return 0;
	}
	if (diff < max(diffNumPlus, diffNumMinus)) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 3788
use strict;
use warnings;

my $n;
my $k;

($n, $k) = split /\s/, <>;

my $ans = 0;

my $r = 1 / $n;
foreach my $i (1 .. $n) {
	if ($k <= $i) {
		$ans += $r;
	} else {
		my $a = $i;
		my $cnt = 0;
		while ($a < $k) {
			$a *= 2;
			$cnt++;
		}
		$ans += $r * (0.5 ** $cnt);
	}
}

print $ans, "\n";


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;


int main(void) {
    ll N;
    cin >> N;
    vector<ll> ans;
    ll i;
    
    if(N==3) {
        pt(2<<" "<<5<<" "<<63);
        return 0;
    }else if(N==4) {
        pt(2<<" "<<5<<" "<<20<<" "<<63);
        return 0;
    }else if(N==5) {
        pt(3<<" "<<4<<" "<<9<<" "<<10<<" "<<16);
        return 0;
    }
    
    for(i=3; ans.size()<N-2 && i<=30000; i+=3) {
        ans.pb(i);
    }

    if(ans.size()==N-2) {
        if((N-2)%4==0 || (N-2)%4==3) {
            ans.pb(2);
            ans.pb(4);
        }else if((N-2)%4==1) {
            ans.erase(ans.begin()+N-3);
            ans.pb(4);
            ans.pb(10);
            ans.pb(16);
        }else if((N-2)%4==2) {
            ans.erase(ans.begin()+N-4);
            ans.pb(4);
            ans.pb(10);
            ans.pb(16);
        }
    }else {
        
        if((N-ans.size())%2==0) {
            for(i=2; ans.size()<N; i+=2) {
                if(i%3==0) continue;
                ans.pb(i);
            }
        }else {
            ans.erase(ans.begin()+9999);
            for(i=2; ans.size()<N; i+=2) {
                if(i%3==0) continue;
                ans.pb(i);
            }
        }
    }
    
    //sort(ans.begin(), ans.end());
    for(i=0; i<N; i++)
        cout << ans[i] << " ";
    cout << endl;
}







Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);

		int P=sc.nextInt();
		int Q=sc.nextInt();
		int R=sc.nextInt();

		System.out.println(Math.min(P+Q, Math.min(Q+R, R+P)));

		sc.close();
	}

}


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

int main () {
  int N;
  cin >> N;
  vector<int>b(N);
  vector<int>a(N);
  for (int i = 0; i < N; i++) {
    cin >> b.at(i);
  }
  
  for (int j = 0; j < N; j++) {
    for (int i = N-1-j; i >= 0; i--) {
      if (b.at(i) == i + 1){
        a.at(N-j-1) = b.at(i);
        for (int k = i; k < N-j-1; k++) {
          b.at(k) = b.at(k+1);
        }
        break;
      }
      else if (i == 0){
        cout << -1 << endl;
        return 0;
      }
    }
  }
  
  for (int i = 0; i < N; i++) {
    cout << a.at(i) << endl;
  }
}
    
      

Measured memory_bytes: 3616
using static System.Console;

class Program
{
  static void Main(string[] args)
  {
	string s = ReadLine();
	bool re = true;
	for(int i = 1;i <= s.Length;i++)
	{
		if(i % 2 == 0)
		{
			if (s[i - 1] == 'R')
			{
				re = false;
				break;
			}
		}
		else
		{
			if(s[i - 1] == 'L')
			{
				re = false;
				break;
			}
        }
	}
	if (re) WriteLine("Yes");
	else WriteLine("No");
  }
}

Measured memory_bytes: 11092
N, W = map(int, input().split())
dp = [[1000000001 for i in range(N*1000+1)] for j in range(N+1)]
dp[0][0] = 0
for j in range(N):
    w, v = map(int, input().split())
    for k in range(N*1000+1):
        dp[j+1][k] = min(dp[j][k-v] + w, dp[j][k])


ans = 0
for i in range(N*1000+1):
    if dp[N][i] <= W:
        ans = max(ans, i)
print(ans)


Measured memory_bytes: 173320
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		int n = int.Parse(input[0]);
		int m = int.Parse(input[1]);
		string s = Console.ReadLine();
		List<int> answers = new List<int>();
    int minNumBefore = n;
    int minNum = n;
    int leftNum = n;
    bool answer = true;

    while(true)
    {
      for(int i = leftNum-1; (i >= minNumBefore-m && i >= 0); i--)
      {
        if(s[i] == '0') minNum = i;
        leftNum--;
      }
      //Console.WriteLine(minNum);
      
      if(minNum == minNumBefore)
      {
        answer = false;
        break;
      }else
      {
        answers.Add(minNumBefore -minNum);
        minNumBefore = minNum;
        if(minNum == 0) break;
      }
    }

		if(!answer) Console.WriteLine(-1);
    else
    {
      int answerCount = answers.Count();
      int[] answersSub = new int[answerCount];
      for(int i = 0; i < answerCount; i++)
      {
        answersSub[i] = answers[answerCount-1-i];
      }
      Console.WriteLine(string.Join(" ", answersSub));
    }
	}
}

Measured memory_bytes: 16224
#include<iostream>
using namespace std;
int main()
{
  // Aの入力
  int A;
  cin >> A;
  // Bの入力
  int B;
  cin >> B;
  // Cの入力
  int C;
  cin >> C;

  if (((B - (B % A)) / A) < C) {
    cout << ((B - (B % A)) / A);
  } else {
    cout << C;
  }
  return 0;
}


Measured memory_bytes: 256
import itertools
import numpy as np

n = int(input())
posi_list = []
for _ in range(n):
  posi_list.append(list(map(int, input().split())))

city = [i for i in range(n)]
dist_list = []
for root in itertools.permutations(city):
  dist = 0
  for i in range(1,len(root)):
    now = root[i]-1
    prev = root[i-1]-1
    
    prev_x = posi_list[prev][0]
    prev_y = posi_list[prev][1]
    now_x = posi_list[now][0]
    now_y = posi_list[now][1]
    
    dist += np.sqrt((now_x-prev_x)**2 + (now_y-prev_y)**2)
  dist_list.append(dist)
  
print(np.mean(dist_list))

Measured memory_bytes: 28608
import numpy as np
H, W = map(int, input().split())
s = np.array([list(input()) for _ in range(H)])=="."

R = np.zeros((H,W),dtype = int)
L = np.zeros((H,W),dtype = int)
U = np.zeros((H,W),dtype = int)
D = np.zeros((H,W),dtype = int)

for i in range(H):
    U[i] = (U[i - 1] + 1) *s[i]
    D[- i - 1] = (D[-i] + 1) * s[-i-1]
for i in range(W):
    L[:,i] = (L[:,i-1] + 1) * s[:,i]
    R[:,-1-i] = (R[:,-i] + 1) * s[:,-i-1]
print(np.max(L+R+U+D - 3))

Measured memory_bytes: 219832
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	int MAX = 'Z' - 'A' + 1;
	int n;
	int[] inDeg, outDeg, vis;
	int[][] nei;

	boolean check() {
		for (int i = 0; i < MAX; i++) {
			if (vis[i] != 1) {
				return false;
			}
		}
		int cnt = 0;
		for (int i = 0; i < MAX; i++) {
			if (inDeg[i] != outDeg[i]) {
				return false;
			}
		}

		return true;
	}

	void dfs(int k) {
		if (vis[k] == 1) {
			return;
		}
		vis[k] = 1;
		for (int i = 0; i < MAX; i++) {
			if (0 < nei[k][i]) {
				dfs(i);
			}
		}
	}

	void run() {
		Scanner sc = new Scanner(System.in);

		while (true) {
			n = sc.nextInt();
			if (n == 0) {
				break;
			}

			int s = 0;
			inDeg = new int[MAX];
			outDeg = new int[MAX];
			vis = new int[MAX];
			nei = new int[MAX][MAX];
			Arrays.fill(vis, 1);
			for (int i = 0; i < n; i++) {
				char[] c = sc.next().toCharArray();
				int u = c[0] - 'a';
				int v = c[c.length - 1] - 'a';
				outDeg[u]++;
				inDeg[v]++;
				nei[u][v] = 1;
				vis[u] = vis[v] = -1;
				s = u;
			}

			dfs(s);
			if (check()) {
				System.out.println("OK");
			} else {
				System.out.println("NG");
			}
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 48164
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    int N;

    scanf("%d", &N);

    char S[N+1];

    scanf("%s", S);

    char t[400];

    for(int i = 101; i < 101 + N; i++){
        t[i] = S[i-101];
    }

    int f = 100;
    int l = 0, r = 0;

    for(int i = 0; i < N; i++){
        if(S[i] == '('){
            l++;
        }else{
            if(l == 0){
                t[f] = '(';
                f--;
            }else{
                l--;
            }
        }
    }

    for(int i = f+1; i < 101+N; i++){
        printf("%c", t[i]);
    }
    for(int j = 0; j < l; j++){
        printf(")");
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 1632
#include <bits/stdc++.h>
using namespace std;
int N;
#define rep(i,n) for(int i=0; i<n; i++)
int main(){
    cin >> N;
   	double v[N]; rep(i,N) cin >> v[i];
  	//vector<int> dp(N+1,0);
  	sort(v, v+N);
  	
  	double ans = v[0];
  	rep(i,N){
       ans += v[i];
       ans /= 2;
    }
  	cout << ans;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
import collections
counter=collections.Counter(a)
parts=[]
for item in counter.items():
  key=item[0]
  val=item[1]
  if val<2:
    continue
  loop=val//2
  for i in range(loop):
    parts.append(key)
    
if len(parts)<2:
  print(0)
else:
  parts=sorted(parts)
  print(parts[-1]*parts[-2])

Measured memory_bytes: 18216