akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h> 
int primes[1000000]; 
void Sieve(){ 
    for(int i= 2; i < 1000000; i++){ 
        primes[i] = 1; 
        
    } 
    
    primes[1] = 0; 
    for(int i = 2; i < 1000; i++){ 
        if(primes[i] == 1) 
        for(int j=i; j*i < 1000000;j++){ 
            primes[j*i] = 0; 
            
        } 
        
    } 
    
} 
int IsPrime(int x){ 
    return primes[x]; 
    

} 
int main(void){ 
    Sieve(); 
    int n, c; 
    while(scanf("%d", &n)!= EOF){ 
        c = 0; 
        for(int i = 2; i <= n; i++){ 
            if(IsPrime(i)==1) c++; 
            
        } 
        printf("%d\n", c); 
        
    }
    return 0; 
    
} 



Measured memory_bytes: 5604
import java.util.*;

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

	while(sc.hasNext()){

	    double a = sc.nextDouble();

	    double sum = 0;

	    for(int i=2; i<=10; i++){
		sum+=a;
		if(i%2==0){a = a*2;}
		else {a = a/3;}
	    }
	    sum+=a;
	    System.out.println(sum);
	}
    }
}

Measured memory_bytes: 11000
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    N,K = LMIIS()
    R,S,P = LMIIS()
    T = input()
    A = [False]*N
    ans = 0
    # hand = {
    #     'r':
    # }
    score = {
        'r':P,
        's':R,
        'p':S
    }
    for i in range(K):
        # print(T[i],score[T[i]])
        ans += score[T[i]]
        A[i] = True
    for i in range(K,N):
        if T[i] != T[i-K]:
            # print(T[i],score[T[i]])
            ans += score[T[i]]
            A[i] = True
        else:
            if A[i-K] != True:
                ans += score[T[i]]
                A[i] = True
            # print(T[i],0)
    print(ans)
    # for i in range(K):
    #     if T[i] == 'r':
    #         A += 'p'
    #         ans += P
    #     elif T[i] == 's':
    #         A += 'r'
    #         ans += R
    #     else:
    #         A += 's'
    #         ans += S
    # for i in range(K,N):
    #     if T[i] == 'r':
    #         if A[i-K] != 'p':
    #             A += 'p'
    #             ans += P
    #         else:
    #             A += '-'
    #     elif T[i] == 's':
    #         if A[i-K] != 'r':
    #             A += 'r'
    #             ans += R
    #         else:
    #             A += '-'
    #     else:
    #         if A[i-K] != 's':
    #             A += 's'
    #             ans += S
    #         else:
    #             A += '-'





if __name__ == '__main__':
    main()

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

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007


signed main(){
    int N;
    string s;
    cin>>N;
    cin>>s;
    if(N%2==0&&s.substr(0,N/2)==s.substr(N/2,N/2)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

int main()
{
    int N;
    int T[101] = {0};
    int M;
    int P[101] = {0}, X[101] = {0};
    int sum = 0;

    cin >> N;
    for (int i = 1; i <= N; i++)
    {
        cin >> T[i];
        sum += T[i];
    }
    cin >> M;
    for (int i = 0; i < M; i++)
    {
        cin >> P[i] >> X[i];
    }

    for (int i = 0; i < M; i++)
    {
        cout << sum - T[P[i]] + X[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
signed main()
{
int x=0,y=0,z=0,w=0,n=0,m=0,a=0,b=0;
std::cin >> x;
std::vector<int> v(3);
v[0]=x/100;
v[1]=x%100/10;
v[2] = x%10;
if(v[0]<v[1]||v[0]<v[2]){
  rep(i,3){
    std::cout << v[0]+1 ;
  }
}else{
  rep(i,3){
    std::cout << v[0] ;
  }
}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp make_pair
#define sz(x) ((int)(x).size())
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define all(x) x.begin(),x.end()
#define y1 omg
#define INF 1000000010
#define FOR(x, n) for(int x=0; x<n; x++)
#define ini(x, n) memset(x, n, sizeof(x));
#define MOD ((int)1e9 + 7)
#define atoi(x) ((x)-'0')
#define int ll
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;

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

int ans = INF;
string a, b;

int f(int x) {
	int ret = 0;
	FOR(i, sz(b)) {
		if (b[i] != a[i + x]) ret++;
	}
	return ret;
}

signed main() {
	cin >> a >> b;
	FOR(i, sz(a) - sz(b) + 1) {
		ans = min(ans, f(i));
	}
	cout << ans;
}

Measured memory_bytes: 3636
#define _USE_MATH_DEFINES
#include <iostream>
#include <math.h>
#include <iomanip>

using namespace std;

int main () {
    double a, b, x;
    cin >> a >> b >> x;
    cout << fixed << setprecision(9);
    if (a*a*b == x) {
        cout << 0 << endl;
    } else if (a*a*b/2 < x) {
        cout << 90 - atan(a*a*a/(a*a*b - x)/2)*180/M_PI << endl;
    } else {
        cout << 90 - atan((2*x/a/b)/b)*180/M_PI << endl;
    }
}

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

int main(){
  int N,K;cin>>N>>K;
  string S;cin>>S;

  for(int i=1; i<=N; i++){
    if(i==K){
      cout<<(char)(S[i-1]-'A'+'a');
    }else{
      cout<<S[i-1];
    }
  }
  cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rbf(a, x) for (auto& a : x)
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define drep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define Maxe(x) *max_element(all(x))
#define Mine(x) *min_element(all(x))
#define Size(x) ((ll)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
#define Fi first
#define Se second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

    template<typename Num>
        constexpr Num mypow(Num a, long long b) {
            if(b==0)return 1;
            if (a==0)return 0;
            Num x = 1;
              while (b > 0) {
                if(b & 1)x*=a;
                a*=a;
                b >>= 1;
              }
              return x;
        }

    template<class T> inline bool chmin(T& a, T b) {
        if (a > b) {
            a = b;
            return true;
        }
        return false;
    }
    template<class T> inline bool chmax(T& a, T b) {
        if (a < b) {
            a = b;
            return true;
        }
        return false;
    }

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo
//mint,dijkstra,gyakugen

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll n;
        cin>>n;
        vector<pll> BA(n);
        rep(i,n)cin>>BA[i].Se>>BA[i].Fi;
        sort(all(BA));
        ll now=0;
        rep(i,n){
            now+=BA[i].Se;
            if(now>BA[i].Fi){
                cout<<"No"<<endl;
                return 0;
            }
        }
        cout<<"Yes"<<endl;
    }

Measured memory_bytes: 6372
# coding=utf-8

if __name__ == '__main__':
    N, M = map(int, input().split())
    li = list(map(int, input().split()))
    lisum = sum(li)

    cnt = 0
    for i in range(N):
        if lisum / (M * 4) <= li[i]:
            cnt += 1

    if M <= cnt:
        print('Yes')

    else:
        print('No')


Measured memory_bytes: 9172
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>

#define REP(n) for(int i = 0;i < n;i++)
#define LLREP(n) for(long long int  i = 0;i < n;i++)
typedef long long int ll;
using namespace std;
#define MAX_A 1000000007

int main(){

    int a,b,c;
    cin >> a >> b >> c;

    if(a+b >= c){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <map>

using namespace std;

map<int,int> v;

int main()
{
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    int n,sol=0,x;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&x);
        v[x-1]++;
        v[x]++;
        v[x+1]++;
    }
    for(map<int,int>::iterator it=v.begin();it!=v.end();it++)
        sol=max(sol,it->second);
    printf("%d",sol);
    return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define int long long
#define MAXK 110
#define MAXN 55
#define inf 1000000007
using namespace std;

int A[MAXN];
int dp[MAXN][MAXN][MAXK];

int solve(int l,int r,int k){
	if(dp[l][r][k]!=-inf)return dp[l][r][k];
	if(k==0)return dp[l][r][k]=0;
	if(k<0)return dp[l][r][k]=-inf-12;
	if(l==r){
		return dp[l][r][k]=max(0LL,A[r]);
	}
	int op1=-inf+1,op2=-inf,op3=-inf,op4=-inf;
	if(l+1<=r)op1 = solve(l+1,r,k-1)+A[l];
	if(l<=r-1)op2 = solve(l,r-1,k-1)+A[r];
	if(k>1)op3 = solve(l+1,r,k-2);
	if(k>1)op4 = solve(l,r-1,k-2);
//	cout<<l<<" "<<r<<" "<<max(max(max(op1,op2),max(op3,op4)),0LL)<<endl;
	return dp[l][r][k]=max(max(max(op1,op2),max(op3,op4)),0LL);
}

int32_t main(){
	int n,k;
	cin>>n>>k;
	
	for(int i=0;i<MAXN;i++)
		for(int j=0;j<MAXN;j++)
			for(int l=0;l<MAXK;l++)
				dp[i][j][l]=-inf;
	
	for(int i=0;i<n;i++)cin>>A[i];
	
	cout<<solve(0,n-1,k)<<endl;
}

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

int main() {
    string stra;
    int x;
    cin >> stra;
    x= stra.length();
    x=x-1;
    for(int i=x-1;i>=0;i--){
        if(i%2==1 && stra.substr(0,i/2+1)==stra.substr(i/2+1,i/2+1)){
            cout << i+1 << endl;
            break;
        }
    }
}

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

int main() {

  string S;
  cin >> S;
  
  if(S.at(2) == S.at(3) && S.at(4) == S.at(5)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
    
}


Measured memory_bytes: 256
/*
	Copyright: razouq (c)
	Author: Anass BENDARSI
	Date: 29/07/2017 13:00:43
	flamers will **** you
*/
#include<bits/stdc++.h>
//#include<flamers.h>
#define ll long long
#define ull unsigned long long
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define POB pop_back
#define dist(a, b) sqrt(a*a + b*b)
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pair<int, int>> vipi;
bool compare(pi p1, pi p2){
	 if(1) return true;
	 return false;
}

int main(){
//	freopen("input.in", "r", stdin);
//	freopen("output.out", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie();
	int n;
	cin>>n;
	cout<<"ABC"<<n<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 100000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;

vi s;
vi t;

int solve(int x) {
    int ans=INF;
    auto s_pointer = lower_bound(all(s), x);
    auto t_pointer = lower_bound(all(t), x);
    rep (i, 2) {
        rep (j, 2) {
            rep (k, 2) {
                if (k == 0) ans = min(abs(*(s_pointer - i) - x) + abs(*(t_pointer - j) - *(s_pointer - i)), ans);
                else ans = min(abs(*(t_pointer - i) - x) + abs(*(s_pointer - j) - *(t_pointer - i)), ans);
            }
        }
    }
    return ans;
}

signed main(void) {
    int A, B, Q;
    cin >> A >> B >> Q;
    rep(i, A) {
        int tmp; cin >> tmp;
        s.pb(tmp);
    }
    rep(i, B) {
        int tmp; cin >> tmp;
        t.pb(tmp);
    }

    s.insert(s.begin(), -INF);
    s.pb(INF);
    t.insert(t.begin(), -INF);
    t.pb(INF);

    rep(i, Q) {
        int x; cin >> x;
        cout << solve(x) << endl;
    }
    return 0;
}


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
static const int MAX = 10000;
static const int INFTY = (1<<20);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;
vector<pair<int, int> >adj[MAX];

void dijkstra(){
	priority_queue<pair<int, int> > PQ;
	int color[MAX];
	int d[MAX];
	for(int i=0;i<n;i++){
		d[i] = INFTY;
		color[i] = WHITE;
	}

	d[0] = 0;
	PQ.push(make_pair(0, 0));
	color[0] = GRAY;

	while(!PQ.empty()){
		pair<int, int> f = PQ.top(); PQ.pop();
		int u = f.second;
		color[u] = BLACK;

		if(d[u] < f.first * (-1)) continue;

		for(int j=0;j<adj[u].size();j++){
			int v = adj[u][j].first;
			if(color[v] == BLACK) continue;
			if(d[v] > d[u] + adj[u][j].second){
				d[v] = d[u] + adj[u][j].second;
				PQ.push(make_pair(d[v] * (-1),v));
				color[v] = GRAY;
			}
		}
	}

	for(int i=0;i<n;i++){
		cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
	}
}

int main(){
	int k, u, v, c;

	cin >> n;
	for(int i=0;i<n;i++){
		cin >> u >> k;
		for(int j=0;j<k;j++){
			cin >> v >> c;
			adj[u].push_back(make_pair(v,c));
		}
	}
	dijkstra();

	return 0;
}

Measured memory_bytes: 8076
N,K = map(int,input().split())
L = 998244353
LR = [0] * K
# 累積和をとっていく。累積和の表を予め作っておき、どんどん足しておく
for i in range(K):
    l,r = map(int,input().split())
    LR[i] = [l,r]

AS = [0] * (N+2)
#for l,r in LR:
#    AS[l] += 1
#    AS[r+1] -= 1

A = [0] * (N+2)
A[1] = 1
A[2] = -1
for i in range(1,N+1):
    AS[i] = (AS[i-1] + A[i])%L
    rest = AS[i]
    for l,r in LR:
        if i+l>N:
            continue
        right = min(N+1,i+r+1)
        A[i+l] += rest
        A[right] += -rest

print(sum(A[1:N+1])%L)






Measured memory_bytes: 26676
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

struct Edge {
    int to, id;
};

vector<vector<Edge>> G;
vector<int> ans;

void dfs(int v, int color = -1, int p = -1) {

    int k = 1;
    rep(i, G[v].size()) {

        int u = G[v][i].to;
        int ei = G[v][i].id;

        if(u == p) {
            continue;
        }

        if(k == color) {
            k++;
        }

        ans[ei] = k;
        k++;

        dfs(u, ans[ei], v);
    }

}

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

    G.resize(n);
    ans = vector<int>(n-1);

    rep(i, n-1) {
        int a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].push_back((Edge){b,i});
        G[b].push_back((Edge){a,i});
    } 

    dfs(0);

    int K = 0;
    rep(i, n) {
        K = max(K, (int)G[i].size());
    }

    cout << K << "\n";

    rep(i, n-1) {
        cout << ans[i] << "\n";
    }

    return 0;
}

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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

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

int ruiseki[505][505];
int main()
{
    int n,m,Q;cin >> n >> m >> Q;
    vector<int> l(m);
    vector<int> r(m);
    rep(i,m)
    {
        cin >> l[i] >> r[i];
        ruiseki[l[i]][r[i]]++;
    }
    vector<int> p(Q);
    vector<int> q(Q);
    rep(i, Q)
    {
        cin >> p[i] >> q[i];
    }
    rep(i, 505)
    {
        int temp = 0;
        rep(j,505)
        {
            ruiseki[i][j] = temp+ruiseki[i][j];
            temp = ruiseki[i][j];
        }
    }
    
    rep(i,Q)
    {
        int ans = 0;
        for (int j = p[i]; j <= q[i]; j++)
        {
            ans += ruiseki[j][q[i]]-ruiseki[j][p[i]-1];
        }
        cout << ans << endl;
        
    }



}

Measured memory_bytes: 4224
#include <cstdio>
#include <algorithm>
using namespace std;
int n,k;
int main()
{
	scanf("%d",&n);
	scanf("%d",&k);
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		int tmp;
		scanf("%d",&tmp);
		ans+=min(tmp,abs(tmp-k))*2;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#pragma warning(disable : 4996)
int N, Q, M, D, R[100];
int main() {
	while (true) {
		scanf("%d%d", &N, &Q);
		if (N == 0 && Q == 0) break;
		for (int i = 0; i < 100; i++) R[i] = 0;
		for (int i = 0; i < N; i++) {
			scanf("%d", &M);
			for (int j = 0; j < M; j++) {
				scanf("%d", &D); R[--D]++;
			}
		}
		int ptr = 0;
		for (int i = 0; i < 100; i++) {
			if (R[i] >= Q) {
				if (ptr == 0) {
					ptr = i + 1;
				}
				else if (R[i] > R[ptr - 1]) {
					ptr = i + 1;
				}
			}
		}
		printf("%d\n", ptr);
	}
	return 0;
}

Measured memory_bytes: 2724
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] firstLine = scanner.nextLine().split("\\s+");
        int N = Integer.parseInt(firstLine[0]), K = Integer.parseInt(firstLine[1]), Q = Integer.parseInt(firstLine[2]);
        int[] players = new int[N];

        for (int i = 0; i < Q; i++)
            players[scanner.nextInt() - 1]++;

        for (Integer p : players) {
            System.out.println(p + K - Q <= 0 ? "No" : "Yes");
        }
    }
}


Measured memory_bytes: 56040
#include <cstdio>
#include <cstring>

int main () {

    char num[1001];

    for ( ;; ) {
        scanf("%s", num);

        if (num[0] == '0') break;

        int sum = 0;
        int len = strlen(num);
        for ( int i = 0; i < len; i++ ) {
            //printf("%c %d\n", num[i], sum);
            sum += num[i] - '0';
        }
        printf("%d\n", sum);
    }

    return 0;
}

Measured memory_bytes: 2640
from collections import Counter

n = int(input())
s = input()
c = Counter(s)
if not ('R' in c and 'G' in c and 'B' in c):
    print(0)
else:
    ans = 1
    for key in c:
        ans *= c[key]
    for i in range(1, n - 1):
        l = i - 1
        r = i + 1
        while l >= 0 and r < n:
            if s[l] != s[i] and s[l] != s[r] and s[i] != s[r]:
                ans -= 1
            l -= 1
            r += 1
    print(ans)


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

#define ll       long long
#define ull      unsigned ll
#define pii      pair<int, int>
#define pll      pair<ll, ll>
#define mp       make_pair
#define ff       first
#define ss       second
#define sz(x)    (int) x.size()
#define all(v)   v.begin(), v.end()

template <typename T> inline void smin(T &a, T b) {a = a < b ? a : b;}
template <typename T> inline void smax(T &a, T b) {a = a > b ? a : b;}

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ", ";
    err(++it, args...);
}

template <typename T> inline void Int(T &n) {
    n = 0; int f = 1; register int ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
    n = n * f;
}

template <typename T, typename TT> inline void Int(T &n, TT &m) { Int(n); Int(m); }
template <typename T, typename TT, typename TTT> inline void Int(T &n, TT &m, TTT &l) { Int(n, m); Int(l); }

const int mod = (int) 1e9 + 7;

inline int add(int a, int b) {a += b; return a >= mod ? a - mod : a;}
inline int sub(int a, int b) {a -= b; return a < 0 ? a + mod : a;}
inline int mul(int a, int b) {return (ll) a * b % mod;}

const int inf = (int) 2e9 + 5;
const ll  Inf = (ll) 2e18 + 5;
const int N   = (int) 2e5 + 5;



int solve() {
    int n, m; Int(n, m);
    std::vector<int> cnt(n + 1, 1), a(n + 1);
    for(int i = 1; i <= n; i++) {
        Int(a[i]);
    }
    for(int i = 1; i <= m;  i++) {
        int u, v; Int(u, v);
        if(a[u] >= a[v]) cnt[v] = 0;
        if(a[v] >= a[u]) cnt[u] = 0;
    }
    int ans = 0;
    for(int i = 1; i <= n; i++) {
        ans += cnt[i];
    }
    printf("%d\n", ans);
    return 0;
}

int main() {
    //ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int test = 1, tc = 0;
    //Int(test);
    //cin >> test;
    while (test--) {
        //printf("Case %d: ", ++tc);
        solve();
    }
    return 0;
}


Measured memory_bytes: 3964
n = int(input())
p = list(map(int, input().split()))
ans = 0;
for i in range(n):
  if p[i] == i+1:
    if i == n-1:
      p[n-2], p[n-1] = p[n-1], p[n-2]
      ans += 1
    else:
      p[i], p[i+1] = p[i+1], p[i]
      ans += 1
print(ans)

Measured memory_bytes: 14008
#include <stdio.h>

int main(void) {
	int a,b,x;
	scanf("%d",&a);
    scanf("%d",&b);
	scanf("%d",&x);
	   if(a<=x && a+b>x){
	   	 printf("YES");
	   }else{
	   	 printf("NO");
	   }
	   	 
	   
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll a,b,x;
    ll i,j;
    bool flag=false;
    cin>>x;
    for(i=-1000;i<=1000;i++)
    {
        for(j=-1000;j<=1000;j++)
        {
            if((i*i*i*i*i)-(j*j*j*j*j)==x)
            {
                cout<<i<<" "<<j<<endl;
                flag=true;
                break;
            }
        }
        if(flag)
            break;
    }
    return 0;
}


Measured memory_bytes: 3592
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

template<class T>
bool UpdateMax(T &a, const T &b){
  if(a<b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template<class T>
bool UpdateMin(T &a, const T &b){
  if(a>b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  lint h,n;
  cin>>h>>n;
  vector<lint> a(n),b(n);
  for(int i=0;i<n;i++){
    cin>>a[i]>>b[i];
  }
  lint INF=INT64_MAX/2;
  vector2d<lint> dp(20001,vector<lint>(1000,INF));
  for(int i=0;i<n;i++){
    dp[0][i]=0;
  }
  for(int d=1;d<=20000;d++){
    for(int i=0;i<n;i++){
      if(i-1>=0){
        UpdateMin(dp[d][i],dp[d][i-1]);
      }
      if(d-a[i]>=0){
        UpdateMin(dp[d][i],dp[d-a[i]][i]+b[i]);
      }
    }
  }
  lint result=INF;
  for(int d=h;d<=20000;d++){
    for(int i=0;i<n;i++){
      UpdateMin(result,dp[d][i]);
    }
  }
  cout<<result<<endl;
  return 0;
}




Measured memory_bytes: 159360
package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

func main() {
	sc := NewScanner()
	N := 1 << uint(sc.NextInt())
	A := make([]int, N)
	for i := 0; i < N; i ++ {
		A[i] = sc.NextInt()
	}
	for i := 1; i < N; i *= 2 {
		for j := 0; j < N; j += 2 * i {
			if A[j] == A[j + i] {
				A[j + i] = 0
			} else {
				A[j] = abs(A[j] - A[j + i])
			}
		}
	}
	fmt.Println(A[0])
}

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

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r:rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}




Measured memory_bytes: 6528
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>

using namespace std;

int main(){
    long long n , m , k, sum = 0, ans = 0;

    cin >> n >> m >> k;
    vector<long long> a(n+1),b(m+1);

    for(int i = 1; i <= n; i++){
        long long s;
        cin >> s;
        a[i] = a[i-1] + s;
    }

    for(int i = 1; i <= m; i++){
        long long s;
        cin >> s;
        b[i] = b[i - 1] + s;
    }

    long long maxBooks = 0;
    for(int i = 0; i <= n; i++){
        if(a[i] > k) break;
        long long bb = upper_bound(b.begin(), b.end(), k - a[i]) - b.begin();
        if(maxBooks < i + bb - 1) maxBooks = i + bb - 1;
    }

    cout << maxBooks << endl;

}


Measured memory_bytes: 6424
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#include<queue>
#include <sstream>
#include <set>

const long long INF = 1000000007;
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//c_str()変換
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

//queueクラス
//find()次に取り出す値の表示をする。
//pop()値を取り出す。戻り値はなし
//push()キューに値をプッシュする

//priority_queueクラス

//切り上げ
//ceil
//floor

vector<pair<llong, llong> > Enumdivisor(llong N){
    vector<pair<llong, llong> > A;
    pair<llong, llong> X;

    for(int i=1; i<sqrt(N)+1; i++){
        if(N%i==0){
            X.first = i;
            X.second = N/i;
            A.push_back(X);
        }
    }
    return A;
}

int main(){
    llong N;
    cin >> N;
    llong ans=10000000000000;
    vector<pair<llong, llong> > divisor_list;
    divisor_list = Enumdivisor(N);
    for(auto x:divisor_list){
        ans = min(ans, x.first-2+x.second);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3268
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
char S[MAXN];

int main()
{
    int n,m,k,a,b,c,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>a>>b>>c;

    swap(a,b);
    swap(a,c);

    cout<<a<<" "<<b<<" "<<c<<"\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define test(t) int t; cin>>t; while(t--)
#define p1(x) { cout << " [" << #x << ": " << x << "]\n"; }
#define p2(x) { cout << " [" << #x << ": "; for(auto it:x) cout << it << " "; cout << "]\n"; }
 
void solve()
{
	int x, n, minm=101, diff, closest;
	// priority_queue<pair<int, int>> a;
	vector<int> a(200, -1);
	cin>>x>>n;
	for(int i=0; i<n; i++) {
		int t;
		cin>>t;
		// diff=abs(x-t);
		// a.push(make_pair(diff, t));
		// p1(t);
		a[t] = 0;
	}
	// p2(a);
	int i=0;
	while(1) {
		// p1(x-i);
		// p1(x+i);
		// p1(a[x-i]);
		// p1(a[x+i]);
		if(a[x-i]==-1) {
			cout<<x-i<<endl;
			return;
		}
		else if(a[x+i]==-1) {
			cout<<x+i<<endl;
			return;
		}
		i++;
	}
}
 
int main() {
	// your code goes here
	// test(t)
		solve();
	return 0;
}
 

Measured memory_bytes: 3640
X=int(input())
a=0
while a>-1:
  c=-1#b=a+c
  while c<0:
    if a**5-(a+c)**5==X:
      print(str(a)+" "+str(a+c))
      exit()
    elif a**5-(a+c)**5>X:
      break
    c-=1
  a+=1

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll N, M, T[2][3], ans;
ll DP1[int(3e7 + 5)], DP2[int(3e7 + 5)];

int main(){
  cin >> N; ans = N;
  for (int i = 0; i < 2; i++){
    for (int j = 0; j < 3; j++){
      cin >> T[i][j];
    }
  }

  for (ll i = 0; i <= N; i++){
    for (int j = 0; j < 3; j++){
      if (i + T[0][j] <= N){
        DP1[i+T[0][j]] = max(DP1[i+T[0][j]], DP1[i] + T[1][j] - T[0][j]);
      }
    }
    M = max(M, DP1[i] + i);
  }

  for (ll i = 0; i <= M; i++){
    for (int j = 0; j < 3; j++){
      if (i + T[1][j] <= M){
        DP2[i+T[1][j]] = max(DP2[i+T[1][j]], DP2[i] + T[0][j] - T[1][j]);
      }
    }
    ans = max(ans, DP2[i] + i);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 198884
// Created by arvybhatt

#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define p_b push_back
#define m_p make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)

using namespace std;
using ll = long long;

int main()
{
    fast;
	string s;cin>>s;
	if(s=="ABC")
		cout<<"ARC";
	else
	cout<<"ABC";    
    return 0;
}


Measured memory_bytes: 3612
#include<stdio.h>

int main(void){

  int length = 0;

  int height = 0;

  int area = 0;

  int cir = 0;

  scanf("%d %d",&length,&height);

  area = length * height;

  cir = length*2 + height*2;

  printf("%d %d\n",area,cir);

  return 0;

}

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

int main() {
	
	int x, count = 1;
	
	while (1)
	{
		cin >> x;
		
		if (x != 0) cout << "Case " << count << ": " << x << endl;
		else break;
		
		count++;
	}
	
	return 0;
}


Measured memory_bytes: 2992
import java.util.*;
public class Main{   
    static int n;//頂点数
    static boolean[][] side;//辺があるかどうか
    static int[] visit;//訪問済みかどうか
    static int[] start;
    static int[] end;
    static int time=1;    
    static void dfs(int x) {
        visit[x]=1;
        start[x]=time++;
        for(int i=1; i<=n; i++) {
            if(visit[i]!=1 && side[x][i]) {
                dfs(i);
            }
        }
        end[x]=time++;
    }   
    public static void main(String[] args) {
        try(Scanner sc = new Scanner(System.in)){
            n=sc.nextInt();
            side=new boolean[n+1][n+1];
            start = new int[n+1];
            end = new int[n+1];
            visit=new int[n+1];
            for(int i=0; i<n; i++) {
                int u=sc.nextInt();
                int k=sc.nextInt();
                for(int j=0; j<k; j++) {
                    int v=sc.nextInt();
                    side[u][v]=true;
                }
            }
            for(int i=1; i<=n; i++) {
                if(visit[i]==0) {
                    dfs(i);
                }
            }
            for(int i=1; i<=n; i++) {
                System.out.println(i+" "+start[i]+" "+end[i]);
            }

        }
    }
}


Measured memory_bytes: 28408
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

struct TWO{
    long long int a,b;
};

bool cmp(TWO x,TWO y){
    if(x.a!=y.a){
        return x.a<y.a;
    }else{
        return x.b<y.b;
    }
}

int main() {
    const long long int mod = 1000000007,INF=50000000000000;
    typedef pair<long long int,long long int>P;
	map<long long int, long long int>mp;
    priority_queue<P,vector<P>,greater<P> >mazuisushi;
    
    priority_queue<P>umaisushi;
	cout << fixed << setprecision(10);
    string str;
    long long int y,m,d;

    while(1){
      int n, m;
      cin >> n >> m;
      if (n == 0) return 0;
      vector<int> a(n), b(n);
      for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
      map<int, priority_queue<int> > mp;
      for (int i = 0; i < n; i++) {
          mp[a[i]].push(b[i]);
      }
      int res = 0;
      for (int i = 1; i <= m; i++) {
          res += mp[i].top();
      }
      cout << res << endl;
    }
} 



Measured memory_bytes: 3164
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 9999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define p(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
//#define int long long


using namespace std;


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




ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

ll pow2(ll a, ll n) {//aのn乗を計算します。
	ll x = 1;
	while (n > 0) {//全てのbitが捨てられるまで。
		if (n & 1) {//1番右のbitが1のとき。
			x = x * a;
		}
		a = a * a;
		n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
	}
	return x;
}

long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}


const int MOD = 1000000007;

bool arr[1050000];
int sosuu[100010];
void Eratosthenes() {
	ll N = 1050000;
	int c = 0;
	for (int i = 0; i < N; i++) {
		arr[i] = 1;
	}
	for (int i = 2; i < sqrt(N); i++) {
		if (arr[i]) {
			for (int j = 0; i * (j + 2) < N; j++) {
				arr[i *(j + 2)] = 0;
			}
		}
	}

	for (int i = 2; i < N; i++) {
		if (arr[i]) {
			sosuu[c] = i;
			//cout << sosuu[c] << " ";
			c++;
		}
	}
	//cout << endl;
	//cout << c << endl;
}


int dp[2][110];
int A[2][110];
int main() {
	int N; cin >> N;
	REP(i, 2) {
		REP(j, N) {
			cin >> A[i][j];
		}
	}
	m0(dp);
	dp[0][0] = A[0][0];
	dp[1][0] = A[1][0];
	REP(j, N) {
		dp[0][j + 1] = max(dp[0][j + 1], dp[0][j] + A[0][j + 1]);
		if (j != 0)dp[1][j] = max(dp[0][j] + A[1][j], dp[1][j - 1] + A[1][j]);
		else dp[1][j] = dp[0][j] + A[1][j];
	}
	dp[1][N] = max(dp[0][N] + A[1][N], dp[1][N - 1] + A[1][N]);
	p(dp[1][N]);
}

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

int main() {
  string S;
  cin >> S;
  int A,B,C,D;
  A = S.at(0) - '0' ; B = S.at(1)- '0'; C = S.at(2)- '0'; D = S.at(3)- '0';
  char op1,op2,op3;
  if(A + B + C + D == 7){
    op1 = '+';op2 = '+'; op3 = '+';
  }
  else if(A + B + C - D == 7){
    op1 = '+';op2 = '+'; op3 = '-';
  }
  else if(A + B - C + D == 7){
    op1 = '+';op2 = '-'; op3 = '+';
  }
  else if(A - B +C + D == 7){
    op1 = '-';op2 = '+'; op3 = '+';
  }
  else if(A + B - C - D == 7){
    op1 = '+';op2 = '-'; op3 = '-';
  }
  else if(A - B - C + D == 7){
    op1 = '-';op2 = '-'; op3 = '+';
  }
  else if(A - B + C - D == 7){
    op1 = '-';op2 = '+'; op3 = '-';
  }
  else if(A - B - C - D == 7){
    op1 = '-';op2 = '-'; op3 = '-';
  }
  cout << A << op1 << B << op2 << C << op3 << D << "=7" << endl;
  
}



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

using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (b + c > a) {
    int x = a - b;
    cout << c - x << '\n';
  } else {
    cout << 0 << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
n=int(input())
ls=list(map(int,input().split()))
dic={}
for i in ls:
    dic.setdefault(i,0)
    dic[i]+=1
org=0
for v in dic.values():
    org += v*(v-1)//2

for i in ls:
    v = dic[i]
    print(org-(v*(v-1)//2)+((v-1)*(v-2)//2))

Measured memory_bytes: 87788
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
int main( void )
{
	int qi;
	while ( cin >> qi && qi != -1 )
	{
		long double q = (long double)qi;
		long double x = q/2.0;
		while ( fabs( x*x*x - q ) >= 0.00001 * q )
		{
			long double next_x = x - (x*x*x-q) / (3 * x * x);
			x = next_x;
		}
		cout.setf( ios::fixed, ios::floatfield );
		cout << setprecision( 6 );
		cout << x << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	string s;
	int k;
	cin >> s >> k;
	for(int i = 0;i < k;i++){
		if(s[i] != '1'){
			cout << s[i] << endl;
			return 0;
		}
	}
	cout << '1' << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace d
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var As = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var Q = int.Parse(Console.ReadLine());
            
            var arr = new long[100001];
            foreach(var A in As)
            {
                arr[A] ++;
            }
            var sum = As.Sum();


            for (int i = 0; i < Q; i++)
            {
                var input = Console.ReadLine().Split().Select(long.Parse).ToArray();
                sum += (input[1] - input[0]) * arr[input[0]];
                arr[input[1]] += arr[input[0]];
                arr[input[0]] = 0;
                Console.WriteLine(sum);
            }
        }
    }
}


Measured memory_bytes: 45240
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let _n: i64 = s.trim().parse().unwrap();

    s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    
    let mut v: Vec<i64> = Vec::new();;
    
    let ws = s.trim().split_whitespace();

    let mut cnt=0;

    for i in ws {
        let a = i.parse().unwrap();
        v.push(a);
    }

    for i in 0..(v.len()-1) {
        for j in (i+1)..(v.len()) {
            cnt += v[i]*v[j];
        }
    }
    println!("{}",cnt);
}

Measured memory_bytes: 4352
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N;
    string S;
    cin >> N >> S;
    string T = S;
    reverse(all(T));

    vector<pair<string, string>> Sss(1 << N);
    Sss[0] = { "", S.substr(0, N) };
    rep(bit, 1, 1 << N) {
        string s;

        int lsb = bit ^ (bit & (bit - 1));
        for (int i = N - 1; i >= 0; --i) {
            if (lsb >> i) {
                s = S[i] + Sss[bit ^ lsb].first;
                break;
            }
        }

        Sss[bit].first = s;
    }
    rep(bit, 1, 1 << N) {
        Sss[bit].second = Sss[~bit & ((1 << N) - 1)].first;
    }
    sort(all(Sss));

    vector<pair<string, string>> Tss(1 << N);
    Tss[0] = { "", T.substr(0, N) };
    rep(bit, 1, 1 << N) {
        string t;

        int lsb = bit ^ (bit & (bit - 1));
        for (int i = N - 1; i >= 0; --i) {
            if (lsb >> i) {
                t = T[i] + Tss[bit ^ lsb].first;
                break;
            }
        }

        Tss[bit].first = t;
    }

    ll ans = 0;
    rep(bit, 0, 1 << N) {
        string s = Tss[~bit & ((1 << N) - 1)].first;

        int k = upper_bound(all(Sss), pair<string, string>(Tss[bit].first, s))
            - lower_bound(all(Sss), pair<string, string>(Tss[bit].first, s));
        ans += k;
    }

    write(ans);
}

Measured memory_bytes: 33024
# -*- coding: utf-8 -*-

"""
参考：https://img.atcoder.jp/abc100/editorial.pdf
　　　http://drken1215.hatenablog.com/entry/2018/06/16/234000
・3項目をそれぞれ+するか-するか2^3通り試す。
・合計の絶対値は合計*-1なので、(値*-1)+(値*-1)..とやっても同じ結果になるのが分かる。
・DPっぽいと思ってしまったけど、各値の制約が10**10と大きいからそれはない
　っていう判断ができるようになること。
"""

N, M = map(int, input().split())
xyzN = [None] * N
for i in range(N):
    x, y, z = map(int, input().split())
    xyzN[i] = (x, y, z)

ans = 0
# 3項目を+か-にする2^3通りループ
for i in range(1 << 3):
    S = []
    for j in range(N):
        sm = 0
        # 3項目を個別に確認して+か-か決める
        for k in range(3):
            if i >> k & 1:
                sm += xyzN[j][k]
            else:
                sm -= xyzN[j][k]
        # 各ケーキ毎に今回のパターンでの合計を格納していく
        S.append(sm)
    # 降順ソートしてMまでの合計
    S.sort(reverse=True)
    ans = max(sum(S[:M]), ans)
print(ans)


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

int n;
long long int A[10000];
int sum=0;


int main(){

    cin>>n;

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

for(int i=0;i<n;i++){
    while(A[i]%2==0){
        sum+=1;
        A[i]/=2;
    }
}

cout<<sum<<endl;

return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <iomanip>

using namespace std;

#define FOR(i,n) for(int i = 0; i < n; i++)
#define FORa(i,a,b) for(int i = a; i < b; i++)
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
#define SORT(a,n) sort(begin(a), begin(a) + n)
#define VSORT(v) sort(v.begin(), v.end())
#define MAX 1000000
#define ll long long
#define LOW(s) transform(s.begin(),s.end(),s.begin(),::tolower)
#define UP(s) transform(s.begin(),s.end(),s.begin(),::toupper)

const double PI = acos(-1.0);

//-------------------------------------------------------//

int main() {
	double a,b,h,m;		
	cin >> a >> b >> h >> m;
	
	double degH = (h*60 + m)/720 * (PI*2);
	double degM = m/60 * (PI*2);
	
	double angle = degH - degM; // cos(-a) = cos(a) so no need absolute
	double ans = sqrt(a*a + b*b - 2.0*a*b*cos(angle));
	cout << fixed << setprecision(10) << ans << endl;
	
	return 0;
}

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

char word[100100];

main()
{
    int st=-2,ed=-2;
    scanf("%s",word);
    for(int i=1;word[i];i++)
    {
        if(i==1)
        {
            if(word[i]==word[i-1])
            {
                st=i-1;
                ed=i;
                break;
            }
        }
        else
        {
            if(word[i]==word[i-1]||word[i]==word[i-2]||word[i-1]==word[i-2])
            {
                st=i-2;
                ed=i;
                break;
            }
        }
    }
    printf("%d %d",st+1,ed+1);
}


Measured memory_bytes: 384
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
ans = 0

for i in range(1,n+1):
    ans += (n-1)//i

print(ans)

Measured memory_bytes: 62892