akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e6+10;

vector<ll> fact(n_max+1,0);
void build(){
    // vector<ll> temp(n_max);
    for(ll i = 2; i < n_max; i *= 2){
        for(ll j = 1; i * j < n_max; j++){
            fact[i * j]++;
        }
    }
    rep(i,n_max)fact[i+1] += fact[i];
}
void print(vector<ll> vec, int n){
    rep(i,n)cout << vec[i] << " ";
    cout << endl;
}
bool is_odd(int n, int k){
    return (fact[n] - fact[k] - fact[n-k]) == 0;
};
int main(){
    ll n; cin >> n;
    string s;cin >> s;
    build();
    // print(fact, 10);
    bool two = false;
    ll ans = 0;
    rep(i,n){
        ll t = s[i] - '0';
        if(t == 2)two = true;
        ans += (t & 1) * is_odd(n-1,i);
        ans &= 1;
        // debug(i);debug(ans);
    }

    if(ans == 1){
        cout << ans << endl;
        return 0;
    }
    if(two){
        cout << 0 << endl;
        return 0;
    }

    ans = 0;
    vector<ll> vec(n-1);
    rep(i,n-1){
        vec[i] = abs(s[i] - s[i+1]);
        vec[i] /= 2;
    }
    rep(i,n-1){
        ans += vec[i] * is_odd(n-2, i);
        ans &= 1;
    }

    cout << ans * 2 << endl;
}

Measured memory_bytes: 17028
import sys
def input():
    return sys.stdin.readline()[:-1]
N,Q=map(int,input().split())
a=list(map(int,input().split()))
class BIT:
    def __init__(self,len_A):
        self.N = len_A + 10
        self.bit = [0]*(len_A+10)
    # sum(A0 ~ Ai)
    # O(log N)
    def query(self,i):
        res = 0
        idx = i+1
        while idx:
            res += self.bit[idx]
            idx -= idx&(-idx)
        return res
    # Ai += x
    # O(log N)
    def update(self,i,x):
        idx = i+1
        while idx < self.N:
            self.bit[idx] += x
            idx += idx&(-idx)
    def __str__(self):
        return f"{self.bit}"
b=BIT(N)
for i in range(N):
    b.update(i,a[i])
for i in range(Q):
    p,q,r=map(int,input().split())
    if p:
        print(b.query(r-1)-b.query(q-1))
    else:
        b.update(q,r)

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

int main() {
  int N,K;
  cin >> N >> K;
  vector<int> l(N);
  rep(i,N) cin >> l[i];
  sort(l.rbegin(), l.rend());
  int sum=0;
  for(int i=0; i<K; i++) {
    sum += l[i];
  }
  cout << sum << endl;
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl

int main(){
  int a, b, t;
  cin >> a >> b >> t;
  
  int quo = t/a;
  int ans = quo*b;
  cout << ans << endl;
}

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

int main()
{

	int A = 0, B = 0, point;

	for(int i = 0; i < 2; i++) {
		for(int j = 0; j < 4; j++) {
			cin >> point;
			!i ? A += point : B += point;
		}
	}

	cout << (A > B ? A : B) << endl;

	return 0;

}

Measured memory_bytes: 3040
n=int(input())
ans=1
travel=[list(map(int,input().split())) for i in range(n)]

travel.sort()

if travel[0][0]<(travel[0][1]+travel[0][2]) or travel[0][0]%2!=(travel[0][1]+travel[0][2])%2:
    ans=0
else:
    for k in range(n-1):
     a=travel[k+1][0]-travel[k][0]
     b=travel[k+1][1]-travel[k][1]
     c=travel[k+1][2]-travel[k][2]
     if a<abs(b)+abs(c) or a%2!=(b+c)%2:
         ans=0
         break

if ans==1:
    print("Yes")
else:
    print("No")



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

int main() {
  int N,Z=0;
  cin>>N;
  vector<int> p(N);
for (int i=0;i<N;i++) {
  cin>>p.at(i);
}
  for(int i=1;i<N-1;i++){
    if(p.at(i)>p.at(i-1)&&p.at(i)<p.at(i+1)){
      Z++;
    }
    if(p.at(i)<p.at(i-1)&&p.at(i)>p.at(i+1)){
      Z++;
    }
  }
  cout<<Z<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lloop(i, a, b) for(ll i=a;i<(ll)b; i++)
#define loop(i, a, b) for(int i=a;i<b;i++)

int main(){
	ll sum=0;
	ll n;
	cin>>n;
	lloop(i, 1, n+1){
		if(i%3&&i%5)
			sum+=i;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3636
N=int(input())
A=list(map(int,input().split()))


for i in range(1,N):
    v = A[i]
    j = i - 1
    for k in range(N-1):
        print(A[k], end=" ")
    print(A[N-1])
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j=j-1
    A[j+1] = v
for j in range(N-1):
    print(A[j], end=" ")
print(A[N-1])




Measured memory_bytes: 5976
N = int(input())
N = 2**32 + N
#print(N)
buf = [0]*35
for i,s in enumerate(bin(N)[2:][::-1]):
    if s == "1":
        buf[i] = 1
#print(buf)

ans = [0]*35

for i in range(33):
    if buf[i]==1:
        if i%2==0:
            ans[i]+=1
        else:
            ans[i]+=1
            ans[i+1]+=1
    while ans[i]>=2:
        ans[i]-=2
        ans[i+1]+=1
        ans[i+2]+=1
    #print(ans)
first = True
ans[33]-=1

a = ""
for i in ans[:32][::-1]:
    if first:
        if i==1:
            first=False
    if not first:
        a += str(i)
if a!="":
    print(a)
else:
    print(0)
"""
s = a
a = 0
b = 1
for i in s[::-1]:
    if i=="1":
        a+=b
    b *= -2
print(a)
"""



Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pl;
#define all(a) (a).begin(),(a).end()
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,n) for(ll (i)=(n)-1;(i)>=0;i--)
#define SHOW(x) cout << #x << ": " << x << endl;
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;

main(){
    int n,cmp;
    map<int,int>mp;
    bool flag = false;
    cin>>n;
    rep(i,n){
        cin>>cmp;
        if(mp[cmp]++ != 0)flag = true;
    }
    if(!flag)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

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

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

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

int main()
{
    int a,b; cin >> a >> b;
    if(a <= b){
        cout << "unsafe";
    }else{
        cout << "safe";
    }
}

Measured memory_bytes: 3636
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;
const int MAXN = 220000;

int n;
int b[MAXN];
int a[MAXN];
char s[MAXN];
set<pair<int, int> > ss0;
set<pair<int, int> > ss1;
set<pair<int, int> > ms0;
set<pair<int, int> > ms1;

int check(int x) {
	for (int i = 0; i < n; ++i)
		a[i] = (b[i] >= x ? 1 : 0);
	int c0 = 0;
	int c1 = 0;
	ss0.clear();
	ss1.clear();
	ms0.clear();
	ms1.clear();
	int l = 0;
	for (int i = 0; i < n; ++i) {
		if (i == n - 1 || a[i] != a[i + 1]) {
			if (a[i] == 0) {
				ss0.insert(make_pair(i - l + 1, l));
				ms0.insert(make_pair(l, i - l + 1));
			}
			else {
				ss1.insert(make_pair(i - l + 1, l));
				ms1.insert(make_pair(l, i - l + 1));
			}
			l = i + 1;
		}
	}
	for (int i = 0; i < n - 1; ++i) {
		if (s[i] == 'M') {
			++c1;
			while (!ss0.empty() && ss0.begin()->first + c0 - c1 <= 0) {
				int len = ss0.begin()->first;
				int p = ss0.begin()->second;
				ss0.erase(make_pair(len, p));
				ms0.erase(make_pair(p, len));
				auto itr = ms1.lower_bound(make_pair(p, 0));
				if (itr == ms1.end() || itr == ms1.begin())
					continue;
				auto itl = itr;
				--itl;
				pair<int, int> pl = *itl;
				pair<int, int> pr = *itr;
				pair<int, int> nw = make_pair(pl.first, (pl.second - c0 + c1) + (pr.second - c0 + c1) - c1 + c0);
				ms1.erase(itl);
				ms1.erase(itr);
				ss1.erase(make_pair(pl.second, pl.first));
				ss1.erase(make_pair(pr.second, pr.first));
				ms1.insert(nw);
				ss1.insert(make_pair(nw.second, nw.first));
			}
		}
		else {
			++c0;
			while (!ss1.empty() && ss1.begin()->first + c1 - c0 <= 0) {
				int len = ss1.begin()->first;
				int p = ss1.begin()->second;
				ss1.erase(make_pair(len, p));
				ms1.erase(make_pair(p, len));
				auto itr = ms0.lower_bound(make_pair(p, 0));
				if (itr == ms0.end() || itr == ms0.begin())
					continue;
				auto itl = itr;
				--itl;
				pair<int, int> pl = *itl;
				pair<int, int> pr = *itr;
				pair<int, int> nw = make_pair(pl.first, (pl.second - c1 + c0) + (pr.second - c1 + c0) - c0 + c1);
				ms0.erase(itl);
				ms0.erase(itr);
				ss0.erase(make_pair(pl.second, pl.first));
				ss0.erase(make_pair(pr.second, pr.first));
				ms0.insert(nw);
				ss0.insert(make_pair(nw.second, nw.first));
			}
		}
	}
	for (auto it: ms1) {
		int p = it.first;
		int l = it.second;
		p -= c1;
		l += c1 - c0;
		if (p <= 0 && p + l > 0)
			return 1;
	}
	return 0;
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
		scanf("%d", b + i);
	scanf(" %s", s);
	int lb = 0;
	int rb = 120000;
	while (rb - lb > 1) {
		int mid = (lb + rb) >> 1;
		if (check(mid))
			lb = mid;
		else
			rb = mid;
	}
	cout << lb << "\n";
	return 0;
}




Measured memory_bytes: 5760
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

typedef long long ll;

int main() {

	string s;
	cin >> s;
	char pre = s[0];
	bool flag = true;
	for (int i = 0; i < 3; i++)
	{
		if (s[i] == s[i + 1]) {
			flag = false;
			break;
		}
	}
	if (flag) {
		cout << "Good" << endl;
	}
	else {
		cout << "Bad" << endl;
	}

	return 0;
}

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

int main() {
    int N; cin >> N;
    set<char> s;
    for (int i = 0; i < N; i++)
    {
        char c; cin >> c;
        s.insert(c);
    }
    if(s.size()==3) cout << "Three" << endl;
    else cout << "Four" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  string s, t; cin >> s >> t;
  LL Ls = s.size();

  map<char, vector<LL>> pos;
  for (int i = 0; i < Ls; ++i) {
    pos[s[i]].push_back(i);
  }
  for (char c : t) {
    if (pos.find(c) == pos.end()) {
      cout << -1 << endl;
      return 0;
    }
  }

  LL i = 0, loop = 0;
  for (char c : t) {
    if (i > pos[c].back()) {
      ++loop;
      i = 0LL;
    }

    auto it = lower_bound(pos[c].begin(), pos[c].end(), i);
    i = *it + 1LL;
  }
  cout << Ls * loop + i << endl;
}


Measured memory_bytes: 4608
#include<stdio.h>
long long check(long long x)
{
	if(x%4==0)return x;
	if(x%4==1)return 1;
	if(x%4==2)return x+1;
	if(x%4==3)return 0;
}
int main()
{
	long long a,b;
	scanf("%lld%lld",&a,&b);
	printf("%lld\n",check(a-1)^check(b));
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define pp pair<ll,ll>
#define all(v) (v).begin(),(v).end()
#define sz(v) (ll)(v).size()
#define F first 
#define S second 
#define lc "\n"
ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll ncr(ll n,ll k){if(k==0)return 1;if(k>n-k)k=n-k;ll a=1,b=1,d;while(k){a*=n;b*=k;d=__gcd(a,b);a/=d;b/=d;n--;k--;}return a;} 
ll MAX=1e18 , MIN=-1e18 , MOD=1000000007;
void YJ()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
}
int main() 
{
    YJ(); fastio
    ll n,i,ans=0,mx; cin>>n; ll a[n];
    for(i=0;i<n;i++) cin>>a[i];
    mx=a[0];
    for(i=1;i<n;i++)
    {
        mx=max(mx,a[i]);
        ans+=mx-a[i];
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 5208
#include <iostream>
#include <algorithm>
#define FOR(i,a,b) for(int i=a;i<b;i++)
int main(){
long int a[100001],n,m=-1,i;
std::cin>>n;
for(i=0;i<n;i++)std::cin>>a[i];
std::sort(a,a+n);
for(i=0;i<n-1;i++){a[i+1]+=a[i];if(3*a[i]<a[i+1])m=i;}
std::cout<<n-m-1;
}

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

using namespace std;

typedef long long ll;

const int maxn = 100000 + 50;
const int mod = 1e9 + 7;

vector<int> t[maxn];
int maxmatch;

bool dfs(int v, int par = -1){
	bool flag = 0;
	for (auto u : t[v]){
		if (u == par)
			continue;
		bool me = dfs(u, v);
		if (me == 1)
			continue;
		if (flag == 0){
			flag = 1;
			maxmatch += 2;
		}
	}
	return flag;
}

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	for (int i = 0; i < n - 1; i++){
		int v, u;
		cin >> v >> u;
		v --, u --;
		t[v].push_back(u);
		t[u].push_back(v);
	}
	dfs(0);
	if (maxmatch == n)
		cout << "Second\n";
	else
		cout << "First\n";
}


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

bool prime(int x) {
	for (int i = 2; i * i <= x; i++)
		if(x % i == 0)
			return false;
	return x > 1;
}

int n;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	for (int i = 6; n; i += 5)
		if(prime(i))
			cout << i << ' ', n--;
	return 0;
}

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

using ll = long long;

using namespace std;

#define MAX 6401
#define OFF 80

using B = bitset<MAX>;
B dp[81][81];

B rshift(B &bs, int n) {
    string s =bs.to_string().substr(MAX-n, n);
    reverse(s.begin(), s.end());
    return (bs >> n) | B(s + '0');
}

int main() {
    int h, w;
    cin >> h >> w;
    int dif[h][w];
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            cin >> dif[i][j];
        }
    }
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            int b;
            cin >> b;
            dif[i][j] = abs(dif[i][j] - b);
        }
    }
    dp[0][1][0] = dp[1][0][0] = true;
    for (int i=0; i<=h; i++) {
        for (int j=0; j<=w; j++) {
            // cerr << i << ' ' << j <<  ' ' << dp[i][j].to_string().substr(MAX-10, 10) << '\n';
            if (i < h && j > 0) dp[i+1][j] |= rshift(dp[i][j], dif[i][j-1]) | (dp[i][j] << dif[i][j-1]);
            if (j < w && i > 0) dp[i][j+1] |= rshift(dp[i][j], dif[i-1][j]) | (dp[i][j] << dif[i-1][j]);
        }
    }
    for (int i=0; i<MAX; i++) {
        if (dp[h][w][i]) {
            cout << i << '\n';
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

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

    }
    int ans=0;
    bool  f = false;
    for(int i=0;i<n-1;i++){
        ll k=himo[i]+himo[i+1];
        if(k>=l){
            ans=i+1;
            f=true;
        }
    }

    if(f) {
        cout<<"Possible"<<endl;
        for (int i = 1; i < ans; i++) {

                cout << i << endl;

        }
        for(int i=n-1;i>ans;i--){
            cout<<i<<endl;
        }
        cout << ans << endl;
    }else{

        cout<<"Impossible"<<endl;
    }

    return 0;
}


Measured memory_bytes: 1664
#include<stdio.h>
#include <iostream>
#include <string.h>
#include <cstdlib>

using namespace std;

#define BUF_SIZE 1024

struct Node{
	int data;
	Node* prev;
	Node* next;
};

class ConnectedList{
public:
	ConnectedList(){
		motherNode = new Node();
		motherNode->data = -1;
		motherNode->prev = motherNode;	
		motherNode->next = motherNode;
	};
	~ConnectedList(){
		Node* tmpNode = motherNode->next;
		Node* nextNode;
		while(tmpNode != motherNode){
			nextNode = tmpNode->next;
			delete tmpNode;
			tmpNode = nextNode;
		}
		delete motherNode;
	};
	void insertNode(int x){
		Node* tmpNode = motherNode->next;
		motherNode->next = new Node();
		motherNode->next->data = x;
		motherNode->next->next = tmpNode;
		motherNode->next->prev = motherNode;
		tmpNode->prev = motherNode->next;
	};
	void deleteNode(int x){
		Node* tmpNode = motherNode->next;
		while(tmpNode != motherNode && tmpNode->data != x){
			tmpNode = tmpNode->next;
		}
		if(tmpNode != motherNode){	
			tmpNode->prev->next = tmpNode->next;
			tmpNode->next->prev = tmpNode->prev;
			delete tmpNode;
		}
	};

	void deleteFirst(){
		Node* tmpNode = motherNode->next;
		motherNode->next = motherNode->next->next;
		motherNode->next->prev = motherNode;
		delete tmpNode;	
	};

	void deleteLast(){
		Node* tmpNode = motherNode->prev;
		motherNode->prev = motherNode->prev->prev;
		motherNode->prev->next = motherNode;
		delete tmpNode; 
	};

	void showList(){
		Node* tmpNode = motherNode->next;
		printf("%d",tmpNode->data);
		tmpNode = tmpNode->next;
		while(tmpNode != motherNode){
			printf(" %d",tmpNode->data);
			tmpNode = tmpNode->next;
		}
		printf("\n");
	}

private:
	Node* motherNode;
};


int main(){

	char buf[BUF_SIZE];
	int n = atoi(fgets(buf,BUF_SIZE,stdin));

	ConnectedList list;

	for(int i = 0; i < n; i++){

		fgets(buf,BUF_SIZE,stdin);

		if(buf[6] == 'F'){
			list.deleteFirst();
		}else if(buf[6] == 'L'){
			list.deleteLast();
		}else{
			int S = 0;
			
			if(buf[0] == 'i'){	//insert x

				for(int i = 0; buf[i] != '\0';i++){
					if(buf[i] >= '0' && buf[i] <= '9'){
						S = 10*S + (buf[i] - '0');
					}
				}
				list.insertNode(S);
			}else{	
				for(int i = 0;buf[i] != '\0';i++){
					if(buf[i] >= '0' && buf[i] <= '9'){
						S = 10*S + (buf[i] - '0');
					}
				}
				list.deleteNode(S);
			}

		}

	}

	list.showList();

}



Measured memory_bytes: 34456
from collections import defaultdict

N,K = map(int,input().split())
A = list(map(int,input().split()))

S = [0]
for i in range(N):
    S.append((S[-1]+A[i]-1)%K)

D = defaultdict(int)

count = 0

for i in range(N+1):
    count += D[S[i]]
    D[S[i]] += 1
    if i-K+1 >= 0:
        D[S[i-K+1]] -= 1

print(count)

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

int H[25],n;
int sum=0;

int main(){
	cin>>n;
	for(int i=0;i<n;i++) cin>>H[i];
	for(int i=0;i<n;i++){
		bool f=true;
		for(int j=0;j<i;j++)
			if(H[j]>H[i]) f=false;
		if(f) sum++;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
MODINT = 1000000007
n = int(input())
A = list(map(int,input().split()))
prodsum = [0]*n
prodsum[0] = A[0]
for i in range(1,n):
    prodsum[i] = prodsum[i-1]+A[i]
# print(prodsum)
ans = 0
for i in range(n-1):
    ans += A[i]*(prodsum[-1]-prodsum[i])
print(ans%MODINT)


Measured memory_bytes: 31400
S=list(input())
K="Yes"
for i in range (0,len(S)):
	if i%2==0:
		if S[i]=="L" :
			K="No"
			break
		else:
			continue
	else :
		if S[i]=="R" :
			K="No"
			break
		else:
			continue
print(K)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
#define dup(x,y) (((x)+(y)-1)/(y))
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const int INTMAX = 2147483647;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

struct mint {
    long long x;
    mint(long long x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
    friend ostream& operator<<(ostream& os, const mint& oj);
};

ostream& operator<<(ostream& os, const mint& oj){
    os << oj.x;
    return os;
}

mint factorial(int n){
    mint res = 1;
for(int i=1;i<=n;++i){
        res *= i;
    }
    return res;
}

mint nCr(int n,int r){
    mint numerator = 1;
    if(r > n - r) r = n - r;
    for(int i=n;i>n-r;--i){
        numerator *= i;
    }
    mint denominator = 1;
    for(int i=1;i<=r;++i){
        denominator *= i;
    }
    return numerator/denominator;
}

int main(){
    int n;cin >> n;
    vl a(n);
    rep(i,n) cin >> a[i];

    vector<pair<mint,mint>> v(60,{0,0});
    rep(i,n){
        rep(j,60){
            if(1 & (a[i]>>j)){
                v[j].first += 1;
            }else{
                v[j].second += 1;
            }
        }
    }
    mint ans = 0;
    rep(i,60){
        ans += mint(2).pow(i) * (v[i].first * v[i].second);
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // int64_t
#include <math.h>

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

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

int get_int2(int64_t *a1, int64_t *a2) {
  scanf("%lld %lld", a1, a2);
  return 0;
}

void swap(int64_t *a1, int64_t *a2) {
    int64_t tmp = *a1;
    *a1 = *a2;
    *a2 = tmp;
}

#define QUERY_MAX 100

int main(int argc, char const *argv[]){
  int queries = get_int();
  static int64_t ans[QUERY_MAX];
  int aidx = 0;
  int i;
  for(i = 0;i < queries;i++){
      int64_t res;
      int64_t a, b;
      get_int2(&a, &b);
      if(a > b) swap(&a, &b);
      int64_t t=a*b;
      int64_t s=sqrt(0.5 + t);
      if(a+1>=b) {
          res = 2*(s-1);
      // e.g) a1=1, a2=9
      } else if(s*s==t) {
          res = 2*(s-1)-1;
      } else if(s*(s+1)>=t) {
          res=2*(s-1);
      } else { 
          res=2*s-1;
      }
      printf("%lld\n",res);
  }
  for(i = 0; i < aidx; i++) {
      printf("%lld\n", ans[i]);
  }
  return 0;
}

Measured memory_bytes: 128
#include <map>
#include <set>
#include <unordered_set>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <climits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstring>
#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#define _USE_MATH_DEFINES
#include <math.h>
#include <complex>
#include <atomic>
#include <thread>

using namespace std;
typedef long long ll;
#define ln '\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define drep(i,n) int i = 0;for(;i<(n);++i)
#define FOR(i,s,e) for(int i=s;i<=(e);++i)
#define DFOR(i,s,e) int i = s;for(;i<=(e);++i)
#define FORR(i,s,e) for(int i=s;i>=(e);--i)
#define DFORR(i,s,e) int i = s;for(;i>=(e);--i)
#define fore(a, x) for(auto& a : x)
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define ft first
#define sd second
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(),a.end()
#define Fill(a,b) memset(a,b,sizeof(a))
template<typename T1, typename T2> bool Max(T1& a, T2 b) { return a<b ? a = b, 1 : 0; }
template<typename T1, typename T2> bool Min(T1& a, T2 b) { return a>b ? a = b, 1 : 0; }


const int N = 100001, inf=1e9;
int a[N];

void solve() {
  int n;
  cin >> n;
  int mn = 0, mx = 0;
  rep(i, n) {
    cin >> a[i];
    if (a[i] < a[mn]) mn = i;
    if (a[i] > a[mx]) mx = i;
  }
  cout << 2 * n << ln;
  if (abs(a[mn]) < abs(a[mx])) {
    rep(it,2)cout << mx + 1 << ' ' << 1 << ln;
    FOR(i, 1, n - 1)rep(it,2)cout << i << ' ' << i + 1 << ln;
  }
  else {
    rep(it, 2)cout << mn + 1 << ' ' << n << ln;
    FORR(i, n, 2)rep(it, 2)cout << i << ' ' << i - 1 << ln;
  }
  
  
}


void init() {
}

int main(void) {
  ios::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20);
  //freopen("C:\\Users\\LENOVO\\Documents\\Visual Studio 2015\\Projects\\Test\\Input\\in.in", "r", stdin);

  init();
  int TC = 1;
#if 0
  cin >> TC; cin.get();
#endif
  FOR(TI, 1, TC) {
    //cout << "Case #" << TI << ": ";
    solve();
  }


  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

bool same_vector(vector<ll> &a, vector<ll> &b) {
    for (int i = 0; i < a.size(); ++i) {
        if (a[i] != b[i]) return false;
    }
    return true;
}

int main() {
    ll N; cin >> N;
    vector<ll> p(N); for (int i = 0; i < N; ++i) cin >> p[i];
    vector<ll> q(N); for (int i = 0; i < N; ++i) cin >> q[i];

    // 順列の準備
    vector<ll> v(N);
    for (int i = 0; i < N; ++i) v[i] = i + 1;
    ll a, b;
    ll count = 0;

    do {
        count++;
        if (same_vector(p, v)) a = count;
        if (same_vector(q, v)) b = count;
    } while (next_permutation(v.begin(), v.end()));

    cout << abs(a - b) << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
	while(kbd.hasNext()){
	    int a = kbd.nextInt();
	    int b = kbd.nextInt();
	    int c = a+b;
	    int k = 1;
	    //System.out.println(c);
	    while(c >= 10){
		k++;
		c = c/10;
		//System.out.println(c);
  	    }
	    System.out.println(k);
	}
    }
}

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

class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int taro_n = 0;
		int hanako_n = 0;

		for(int i = 0; i < n; i++){
			String taro = scanner.next();
			String hanako = scanner.next();

			if(taro.compareTo(hanako) > 0){
				taro_n += 3;
			}else if(taro.compareTo(hanako) < 0){
				hanako_n += 3;
			}else{
				taro_n ++;
				hanako_n ++;
			}

		}

			System.out.println(taro_n + " " + hanako_n);
		}
}

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FORD(i, a, b) for (int i = b - 1; i >= int(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

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

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };

int main()
{
    int N, K;
    cin >> N >> K;
    set<int> si;
    REP(i, K)
    {
        int D;
        cin >> D;
        REP(j, D)
        {
            int a;
            cin >> a;
            si.insert(a);
        }
    }
    cout<<N-si.size()<<endl;
}

Measured memory_bytes: 3604
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <unordered_map>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)

int main() {
  int n;
  cin >> n;
  vector<ll> a(n), b(n);
  rep(i, 0, n) cin >> a[i];
  rep(i, 0, n) cin >> b[i];

  ll s = accumulate(a.begin(), a.end(), 0ll);
  ll t = accumulate(b.begin(), b.end(), 0ll);
  if (s < t)
    cout << "-1" << endl;
  else {
    vector<ll> enough;
    ll need = 0;
    ll ans = 0;
    rep(i, 0, n) {
      if (a[i] < b[i]) {
        need += b[i] - a[i];
        ans++;
      } else
        enough.push_back(a[i] - b[i]);
    }
    sort(enough.rbegin(), enough.rend());
    rep(i, 0, enough.size()) {
      if (need <= 0) break;
      need -= enough[i];
      ans++;
    }
    cout << ans << endl;
  }
  return 0;
}

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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define us unordered_set
#define um unordered_map
#define ms multiset
#define mm multimap
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)
#define pi 3.1415926535897932384626433832
const int pinf=((int)2e18);
const int ninf=((int)-2e18);
const int mod=1000000007;

using namespace std;

int power(int x,int n,int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return power((x*x)%M,n/2,M);
    else
        return (x*power((x*x)%M,(n-1)/2,M))%M;
}

bool vowel(char c)
{
    return(c=='a' or c=='e' or c=='i' or c=='o' or c=='u' or c=='A' or c=='E' or c=='I' or c=='U' or c=='O');
}

int ans=pinf;
int s=0;

void solve(int s1,int i,vector <int> a,int n)
{
    if(max(s1,s-s1)<ans)
    {
        ans=max(s1,s-s1);
    }
    if(i==n)
        return;
    solve(s1+a[i],i+1,a,n);
    solve(s1,i+1,a,n);
}

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","r",stdin);
    //FILE *fptr2=freopen("out.txt","w",stdout);


    int n,k,r,s,p;
    cin>>n>>k>>r>>s>>p;

    string a;
    cin>>a;

    int c=0;

    map <int,int> mp;

    loop(i,0,n)
    {
        if(i-k>=0)
        {
            if(a[i]==a[i-k] and mp[i-k]>0)
            {

            }
            else
            {
                mp[i]++;
                if(a[i]=='r')
                c+=p;
            else if(a[i]=='s')
                c+=r;
            else
                c+=s;
            }
        }
        else
        {
            mp[i]++;
            if(a[i]=='r')
                c+=p;
            else if(a[i]=='s')
                c+=r;
            else
                c+=s;
        }
    }

    cout<<c;




    return 0;
}


Measured memory_bytes: 9916
#include <stdio.h>
#include <stdlib.h>
 
void solve(long **G, int n, int u, long *d, int t) {
  int i;
  char *flag;
  flag = (char*)malloc(sizeof(char) * n);
  for (i = 0; i < n; i++) {
    if(G[u][i] != -1 && (d[i] == -1 || d[i] > t+G[u][i])) {
      flag[i] = 1;
      d[i] = t+G[u][i];
    }
    else flag[i] = 0;
  }
  for (i = 0; i < n; i++) {
    if(flag[i] == 1) {
      solve(G,n,i,d,t+G[u][i]);
    }
  }
  free(flag);
}
 
int main()
{
  int n;
  int i,j,u,k,v;
  long **G,c;
  long *d;
  scanf("%d",&n);
  G = (long**)malloc(sizeof(long*) * n);
  for (i = 0; i < n; i++) {
    G[i] = (long*)malloc(sizeof(long) * n);
    for(j = 0; j < n; j++) G[i][j] = -1;
  }
  for (i = 0; i < n; i++) {
    scanf("%d %d", &u, &k);
    for (j = 0; j < k; j++) {
      scanf("%d %ld", &v, &c);
      G[u][v] = c;
    }
  }
  d = (long*)malloc(sizeof(long) * n);
  d[0] = 0;
  for (i = 1; i < n; i++) {
    d[i] = -1;
  }
  solve(G,n,0,d,0);
  for (i = 0; i < n; i++) {
    printf("%d %ld\n", i, d[i]);
  }
  return 0;
}



Measured memory_bytes: 2108
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
int ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second < secondElof.second;
}
ll nod(ll F) { return log10(F) + 1; }
//**定義場所**//
//gcd, isPrime, eratos, modinv, bitSearch, dfs, bfs, dijkstra, UnionFind//
ll i, j, k, l, m, n; ll N, M, K, H, W, L; string S;
ll MOD = 1000000007; ll ans = 0; ll INF = 9999999999999;
vl flag, color; vll path;
//***********//
int main() {
	cin >> S;
	if (S == "AAA" || S == "BBB") {
		cout << "No";
	}
	else {
		cout << "Yes";
	}
}


Measured memory_bytes: 256
N = int(input())
S = input()

r = S.count("R")
g = S.count("G")
b = S.count("B")

cnt = 0
for i in range(N):
    for j in range(i+1, N):
        k = j + j - i
        if 0 <= k < N:
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                cnt += 1

print(r*g*b - cnt)

Measured memory_bytes: 68076
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
using namespace std;
#define fi first
#define se second
typedef long long lli;
typedef pair<int, int> pii;
const int maxn = 3005;
int n;
double p[maxn];

double dp[maxn][maxn];

void ReadInput()
{
    cin >> n;
    for(int i = 1; i <= n; ++i)
        cin >> p[i];
}

void Solve()
{
    fill_n(&dp[0][0], sizeof(dp) / sizeof(dp[0][0]), 0.0);
    dp[1][1] = p[1];
    dp[1][0] = 1.0 - p[1];
    for(int i = 2; i <= n; ++i)
        for(int j = 0; j <= i; ++j)
        {
            if(j < i) dp[i][j] += dp[i - 1][j] * (1.0 - p[i]);
            if(j > 0) dp[i][j] += dp[i - 1][j - 1] * p[i];
        }
    double ans = 0.0;
    for(int j = n / 2 + 1; j <= n; ++j)
        ans += dp[n][j];
    cout << fixed << setprecision(10);
    cout << ans << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ReadInput();
    Solve();
}


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

int main(){
    int n,t;
    int key=0;
    float a;
    float ans=1000000;
    cin>>n;
    cin>>t>>a;
    float h;
    float jud;
    for(int i=0;i<n;i++){
        cin>>h;
        jud=a-(t-h*0.006);
        if(jud<0)jud=-jud;
        if(ans>jud){
            ans=jud;
            key=i+1;


        }

    }
    cout<<key<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
	int main()
	{

	int N, R;
	cin >> N >> R;

	if (N >= 10) {
		cout << R << endl;
	}
	else {
		int XX = R + 100 * (10 - N);
		cout << XX << endl;
	}

	return 0;
}

Measured memory_bytes: 256
A, B, H, M = map(int, input().split())

import math
x, y = min(A, B), max(A, B)

h = 30*H + (0.5*M)
m = 6*M

x = A*math.cos(math.radians(h))
y = A*math.sin(math.radians(h))
X = B*math.cos(math.radians(m))
Y = B*math.sin(math.radians(m))

ans = ((X-x)**2 + (Y-y)**2)**(1/2)

print(ans)


Measured memory_bytes: 9528
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
using ll = long long;

ll A, B, C, D;


int main(void){

    cin >> A >> B >> C >> D;

    ll ans = A * C;

    if (ans < A * D) ans = A * D;
    if (ans < B * C) ans = B * C;
    if (ans < B * D) ans = B * D;

    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define all(x) (x).begin(),(x).end()

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

typedef long long ll;

using namespace std;

const int MAX_N = 100000;
int N, A, B;
int X[MAX_N];

ll solve() {
    ll ans = 0;
    REP(i,N-1){
        ll distance = X[i+1] - X[i];
        if(distance * A > B) ans += B;
        else ans += distance * A;
    }
    return ans;
}

int main() {
    // to shorten execution time for iostream
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> N >> A >> B;
    REP(i,N) cin >> X[i];
    cout << solve() << "\n";
    return 0;
}



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

using LL = long long;

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); ++(i))
#define RFOR(i, a, b) for (int(i) = (a); (i) > (b); --(i))
#define SORT(x) sort(ALL((x)))
#define RSORT(x) sort(RALL((x)))
#define SZ(x) (int)(x).size()
#define debug(x) cerr << #x << " : " << x << '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const LL LINF = 1e18;

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

  int ans = 0;
  vector<int> A(3);
  FOR(i, 0, 3) { cin >> A[i]; }

  SORT(A);

  FOR(i, 0, 2) { ans += A[i + 1] - A[i]; }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(void){
  string S;
  cin >> S;
  int count = 0;
  for (int i=0;i<S.size();i++){
    int num = 0;
    for (int j=0;j<S.size()-i;j++){
      char c = S.at(i+j);
      if (c == 'A' or c == 'C' or c == 'G' or c == 'T') num++;
      else break;
    }
    count = (num > count) ? num : count;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll a, b, c, d; cin >> a >> b >> c >> d;
    if((abs(a-b)<=d && abs(b-c)<=d) || abs(a-c)<=d) Yes();
    else No();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,f[100009],dp[100009][4],k,z[4],zx,i,j,xc,pas;
long long g[100009];
vector <long long> v[100009];
map <char, long long> m;
string s;
int main(){
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>a>>k;
    //cin>>r>>s>>p;
    cin>>z[1]>>z[2]>>z[3];
    m['r']=1;m['s']=2;m['p']=3;
    cin>>s;
    for(b=0; b<a; b++){
        if(s[b]=='r'){
            g[b+1]=m['p'];
        }
        if(s[b]=='s'){
            g[b+1]=m['r'];
        }
        if(s[b]=='p') g[b+1]=m['s'];
    }
    for(b=1; b<=a; b++){
        v[b%k].push_back(b);
    }
    for(b=0; b<k; b++){
        if(v[b].size()==0) continue;
        zx=v[b][0];
        for(d=1; d<=3; d++){
            if(d==g[zx]){
                dp[zx][d]=z[d];
            }else{
                dp[zx][d]=0;
            }
        }
        for(c=1; c<v[b].size(); c++){
            zx=v[b][c];
            xc=v[b][c-1];
            for(d=1; d<=3; d++){
                if(d==g[zx]) i=z[d]; else i=0;
                for(e=1; e<=3; e++){
                    if(d==e) continue;
                    if(dp[zx][d]<dp[xc][e]+i) dp[zx][d]=dp[xc][e]+i;
                }
            }
        }
        i=0;
        for(d=1; d<=3; d++){
            if(i<dp[v[b][v[b].size()-1]][d]) i=dp[v[b][v[b].size()-1]][d];
        }
//        cout<<i<<endl;
        pas+=i;
    }
    cout<<pas;
    return 0;
}

Measured memory_bytes: 9324
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  s[5] = ' ';
  s[13] = ' ';
  cout << s << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pb push_back
int main()
{
    ll n ,h,i,j;
    cin>>n;
    ll dp[n+1][2];
    vector<ll > cost;
    for(i=0;i<n;i++)
    {
        cin>>h;
        cost.pb(h);
    }
    dp[0][0]=0;
    dp[0][1]=0;
    dp[1][0]=abs(cost[0]-cost[1]);
    dp[1][1]=1000000;
    for(i=2;i<=n;i++)
    {
        dp[i][0]=min(dp[i-1][0],dp[i-1][1])+abs(cost[i]-cost[i-1]);
        dp[i][1]=min(dp[i-2][0],dp[i-2][1])+abs(cost[i]-cost[i-2]);
    }
    cout<<min(dp[n-1][0],dp[n-1][1]);
    
}

Measured memory_bytes: 2676
#include<stdio.h>
#include<cstdio>
#include<algorithm>
using namespace std;

int main() {
  int N;
  scanf("%d", &N);
  int A[2][N+1];
  int sum[2][N+1];
  sum[0][0] = 0;
  sum[1][0] = 0;
  for (int i=0 ; i<2 ; i++ ) {
    for (int j=1 ; j<N+1 ; j++ ) {
      scanf("%d", &A[i][j]);
      sum[i][j] = sum[i][j-1] + A[i][j];
    }
  }
  int res = 0;
  for (int j=1 ; j<N+1 ; j++) {
    res = max(res, sum[0][j] + sum[1][N] - sum[1][j-1]);
  }
  printf("%d\n", res);
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
#define ed cout<<"\n";
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define All(obj) (obj).begin(),(obj).end()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;


int main() {
	speed;
	int n, a, b;
	cin >> n >> a >> b;
	if (a*n > b)cout << b ;
	else cout << a * n;

	ed;
	return 0; 
}


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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

int main(){
    ll n, m;
    cin >> n >> m;
    vector<ll> a(m);
    REP(i, m) cin >> a[i];
    vector<ll> dp(n+1, 0);
    vector<bool> oks(n, true);
    REP(i, m) oks[a[i]] = false;
    dp[0] = 1;
    dp[1] = 1;
    if(oks[1] == false) dp[1] = 0;
    REP(i, n-1){
        dp[i+2] = dp[i+1] + dp[i];
        dp[i+2] %= MOD;
        if(oks[i+2] == false) dp[i+2] = 0;
    }
    cout << dp[n];
    return 0;
}

Measured memory_bytes: 4688
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n) ; ++i)
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define emb emplace_back
#define fcout cout << fixed << setprecision(15)

using namespace std;
using ll = long long;
using P = pair<int,int>;

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

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

  if(s[2] == s[3] and s[4] == s[5]) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

const int INF = 1 << 24;
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

typedef unsigned long long ull;
typedef std::pair<int,int> P;

ull pow(ull a, int n){
    ull res = 1;
    while(n > 0){
        if(n & 1){res *= a;}
        a *= a;
        n >>= 1;
    }
    return res;
}

ull pow_sum(int a, int n){
    ull res = 0;
    REP(i, n+1){
        res += pow(a, i);
    }
    return res;
}

int main(){
    ull N;
    while(std::cin >> N, N){
        std::map<int,int> m;
        int _n = N;
        for(int i=2;i*i<=_n;i++){
            while(N % i == 0){
                N /= i;
                m[i]++;
            }
        }
        if(N > 1){m[N]++;}

        ull sum = 1;
        auto it = m.begin();
        while(it != m.end()){
        //std::cout << it->first << "," << it->second << std::endl;
            sum *= pow_sum(it->first, it->second);
            it++;
        }
        sum -= _n;
        
        //std::cout << sum << std::endl;
        if(_n == sum){puts("perfect number");}
        else if(_n > sum){puts("deficient number");}
        else{puts("abundant number");}
    }

    return 0;
}

Measured memory_bytes: 1140
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5; 
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}

ll raise(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}


ll n; set <ll> s; vector <pair<ll,ll>> adj[N]; ll a, b, w, /*in[N],*/ vis[N];

void dfs(ll k) {
    if (vis[k]) return;
    vis[k]=1;
    for (auto u : adj[k]) {
        if (u.second%2==0) {
            if (s.count(k)) s.insert(u.first);
        }else{
            if (!s.count(k)) s.insert(u.first);
        }
        dfs(u.first);
    }
}

void solve()
{
    cin >> n;
    for (int i=0; i<n-1; ++i) {
        cin >> a >>  b >> w;
        adj[a].pb({b,w}); adj[b].pb({a,w});
        //in[b]++;
    }
    //vector <ll> nodes;
    //for (int i=1; i<=n; i++) if (in[i]==0) nodes.pb(i);
    dfs(1);
    for (int i=1; i<=n; ++i) nout(s.count(i));
}

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

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

int main(){
    ll a[9];
    for(ll i=0;i<9;++i){
        cin>>a[i];
    }
    ll n;
    cin>>n;
    ll b[n];
    for(ll i=0;i<n;++i){
        cin>>b[i];
        for(ll j=0;j<9;++j){
            if(a[j]==b[i]){
                a[j]=0;
            }
        }
    }
    string ans="No";
    if(a[0]==0 and a[1]==0 and a[2]==0){
        ans="Yes";
    }else if(a[3]==0 and a[4]==0 and a[5]==0){
        ans="Yes";
    }else if(a[6]==0 and a[7]==0 and a[8]==0){
        ans="Yes";
    }else if(a[0]==0 and a[3]==0 and a[6]==0){
        ans="Yes";
    }else if(a[1]==0 and a[4]==0 and a[7]==0){
        ans="Yes";
    }else if(a[2]==0 and a[5]==0 and a[8]==0){
        ans="Yes";
    }else if(a[0]==0 and a[4]==0 and a[8]==0){
        ans="Yes";
    }else if(a[2]==0 and a[4]==0 and a[6]==0){
        ans="Yes";
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256