akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <stdio.h>
#include <stdlib.h>

#include <algorithm>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define rep(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
// #define iter(a) __typeof(a.begin())
#define FOR(it, a) for (auto it = a.begin(); it != a.end(); ++it)
#define F first
#define S second
#define SZ(a) static_cast<int>((a).size())
#define sz(a) SZ(a)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).begin(), (a).end()
using namespace std;

typedef int64_t ll;
typedef pair<int, int> PI;
typedef pair<ll, ll> PL;
typedef uint64_t ull;

#ifdef ONLINE_JUDGE
#define PR(...) (void(0))
#else
#define PR(...) \
  do { cerr << "line : " << __LINE__ << ", " << endl;  \
    pr(#__VA_ARGS__, __VA_ARGS__); } while (0)

template<class T>
void pr(const string& name, T t) {
  cerr << name << ": " << t << endl;
}
template<typename T, typename ... Types>
void pr(const string& names, T t, Types ... rest) {
  auto p = names.find(',');
  cerr << names.substr(0, p) << ": " << t << ", ";
  pr(string(names, p + 1), rest ...);
}
#endif

template<class T, class U> ostream& operator<<(
    ostream& o, const pair<T, U>& v) {
  return o << "(" << v.F << ", " << v.S << ")";
}
template<class T> ostream& operator<<(
    ostream& o, const vector<T>& v) {
  o << "{"; rep(i, SZ(v)) o << (i?", ":"") << v[i]; return o << "}"; }
template<class T, class U> ostream& operator<<(
    ostream& o, const map<T, U>& v) {
  o << "{"; for (const auto& e : v) o << e << ", "; return o << "}"; }
template<class T, class U> ostream& operator<<(
    ostream& o, const unordered_map<T, U>& v) {
  o << "{"; for (const auto& e : v) o << e << ", "; return o << "}"; }
template<class T> ostream& operator<<(ostream& o, const set<T>& v) {
  o << "{"; for (const auto& e : v) o << e << ", "; return o << "}"; }
template<class T> string to_s(const T& v) {
  ostringstream is; is << v; return is.str(); }

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

#define endl '\n'

vector<int> G[100000+100];
vector<int> rG[100000+100];
bool vis[100000 + 100];
int depth[100000 + 100];

void dfs(int v, int d){
  depth[v] = d;
  for(auto e : rG[v])
    dfs(e, d + 1);
}

int main(int argc, char *argv[])
{
  ios::sync_with_stdio(0);
  cin.tie(0);

  int n, k;
  cin >> n >> k;
  int ans = 0;

  rep(i, n){
    int a;
    cin >> a;
    if(i == 0){
      ans += a != 1;
      continue;
    }
    G[i + 1].pb(a);
    rG[a].pb(i + 1);
  }
  vis[1] = true;
  dfs(1, 0);

  priority_queue<pair<int, PI> > q;

  for(int i = 2; i <= n; ++i){
    if(SZ(rG[i]) == 0)
      q.push(mp(depth[i], mp(0, i)));
  }


  while(!q.empty()){
    int cv = q.top().S.S;
    int cp = q.top().S.F;
    q.pop();
    if(vis[cv]) continue;
    vis[cv] = 1;
    if(cp == k - 1){
      ans += G[cv][0] != 1;
      cp = -1;
    }
    for(auto e : G[cv]){
      if(vis[e]) continue;
      q.push(mp(depth[e],mp(cp + 1, e)));
    }
  }

  cout << ans << endl;
}


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

int main(){
  vector<int> x(5);
  for(int i = 0; i < 5; i++) cin >> x[i];
  
  for(int i = 0; i < 5; i++){
    if(x[i] == 0){
      cout << i+1 << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
#define ll long long
#define mk make_pair
#define pb push_back
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);
#define INF 1e18
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
using namespace std;
const int MAX=1e5+1;
ll dp[101][MAX];
int main()
{
    ll n,W;
    cin>>n>>W;
    int wt[n+1];ll cost[n+1];
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=n;i++)
        cin>>wt[i]>>cost[i];
    for(int i=1;i<=n;i++){
        for(int j=0;j<=W;j++)
         if(wt[i]<=j)
            dp[i][j]=max(dp[i-1][j],dp[i-1][j-wt[i]]+cost[i]);
        else
            dp[i][j]=dp[i-1][j];
    }
     cout<<dp[n][W];


}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second


void solve()
{
    int n;cin>>n;
    int l[n];REP(i,n)cin>>l[i];
    sort(l,l+n);
    int ans=0;
    REP(i,n)rep(j,i+1,n)
    {
        int sum=l[i]+l[j];
        int mar=abs(l[i]-l[j]);
        int U=distance(l,upper_bound(l+j+1,l+n,mar));
        int L=distance(l,lower_bound(l+j+1,l+n,sum));
        ans+=L-U;
    }
    cout<<ans<<endl;
}

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

Measured memory_bytes: 256
#include <stdio.h>
#define N 3
#define swap(a,b) {a^=b;b^=a;a^=b;}

int main(){

  int n[N], i, j;

  for(i = 0; i < N; i++) scanf("%d", &n[i]);

  for(i = 0; i <= N+2; i++){
    for(j = N-1;j > i; j--){
      if(n[j-1] > n[j])	swap(n[j-1], n[j]);
    }
  }

  for(i = 0;i < N ; i++){
    printf("%d",n[i]);
    if(i != N-1) printf(" ");
    else printf("\n");
  }

  return 0;
}

Measured memory_bytes: 600
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int a,b,c;

int main()
{
	cin>>a>>b>>c;
	int tmp=max(a,max(b,c))*2-(a+b+c-max(a,max(b,c)));
	if(tmp%2==0) cout<<tmp/2<<endl;
	else cout<<(tmp+3)/2<<endl;
	rt0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 2000000000;
constexpr ll mod = 1000000007;

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



int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int n, k; cin >> n >> k;
	int r, s, p; cin >> r >> s >> p;
	string t; cin >> t;
	int ans = 0;
	rep(i, k) {
		int rsp[] = { 1,1,1 };
		for (int j = i;j < n;j += k) {
			if ((j + k) > n) {
				if (t[j] == 'r')ans += ((rsp[2] + 1) / 2) * p;
				if (t[j] == 's')ans += ((rsp[0] + 1) / 2) * r;
				if (t[j] == 'p')ans += ((rsp[1] + 1) / 2) * s;
				continue;
			}
			if (t[j] == t[j + k]) {
				if (t[j] == 'r')++rsp[2];
				if (t[j] == 's')++rsp[0];
				if (t[j] == 'p')++rsp[1];
			}
			else {
				if (t[j] == 'r') {
					ans += ((rsp[2] + 1) / 2) * p;
					rsp[2] = 1;
				}
				if (t[j] == 's') {
					ans += ((rsp[0] + 1) / 2) * r;
					rsp[0] = 1;
				}
				if (t[j] == 'p') {
					ans += ((rsp[1] + 1) / 2) * s;
					rsp[1] = 1;
				}
			}
		}
	}
	cout << ans << "\n";

	return 0;
}


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

def readInts():
  return [int(s) for s in input().split(" ")]

def max_val(V, n):
  count = n
  ret = 0
  for v in sorted(V):
    if v < 0 and count > 0:
      count -= 1
    else:
      ret += v
  return ret

def main():
  N, K = readInts()
  V = readInts()

  ans = 0

  for KL in range(K+1):
    KR = K - KL
    for L in range(min(KL, N)+1):
      for R in range(min(KR, N-L)+1):
        left = V[:L]
        right = V[-1 * R:] if R > 0 else []
        s = max_val(left, KL - L) + max_val(right, KR - R)
        ans = max(ans, s)

  print(ans)

if __name__ == "__main__":
  main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
int main(){
  int n,q;
  cin>>n>>q;
  dsu s(n);
  for(int _=0;_<q;_++){
    int t,u,v;
    cin>>t>>u>>v;
    if(t==0)
      s.merge(u,v);
    if(t==1)
      cout<<s.same(u,v)<<endl;
  }
}

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

int main(){
  int K;
  cin >> K;
  string S;
  cin >> S;
  /*
  int U = S.length();
  cout << U << endl;
  */
  
  if(K>=S.length()){
    cout << S << endl;
  }else{
    for(int i=0;i<K;i++){
      cout << S.at(i);
    }
    cout << "...";
  }
  
  cout << endl;
  
}

Measured memory_bytes: 3604
object Main extends App {

  /**
    *
    * @param n num of balls
    * @param k num of colours
    * @return
    */
  def solve(n: Int, k: Int): Int = {
    k * math.pow(k - 1, n - 1).toInt
  }

  val scanner = new java.util.Scanner(Console.in)
  val n = scanner.nextInt()
  val k = scanner.nextInt()
  val ans = solve(n, k)
  println(ans)
}

Measured memory_bytes: 25676
#include <bits/stdc++.h>
using namespace std;
#define fori(i,n) for(int i =0;i<n;i++)
#define pb push_back
#define ll long long
#define int long long
#define F first
#define S second
#define mp make_pair
#define rev(a) reverse(a.begin(),a.end())
#define srt(a) sort(a.begin(),a.end())
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout.precision(15);
 
 
int mod = 1e9+7;
 
int pow(int a, int b) {
    int ans = 1;
    a %= mod;
    while(b) {
        if(b%2) {
            ans *= a;
            ans %= mod;
        }
        b /= 2;
        a *= a;
        a %= mod;
    }
    return ans;
}

int inv(int a) {
    return pow(a,mod-2);
}

int mul (int a,int b) {
    return ((a%mod)*(b%mod))% mod;
}

struct cmp {
    bool operator() (pair<int,int> a, pair<int,int> b) const {
        int x = a.F;
        int y = b.F;
        return x>=y;
    }
};


int32_t main() {
    FAST;
    int t;
    // cin>>t;
    t = 1;
    while(t--) {
        int n;
        cin>>n;
        int cnt[100001];
        memset(cnt, 0, sizeof cnt);
        int x;
        int ans = 0;
        fori(i,n) {
            cin>>x;
            cnt[x]++;
            ans += x;
        }
        int q;
        cin>>q;
        while(q--) {
            int a,b;
            cin>>a>>b;
            ans = ans - cnt[a]*a + cnt[a]*b;
            cnt[b] += cnt[a];
            cnt[a] = 0;
            cout<<ans<<endl;
        }

    }
    
    return 0;
}

Measured memory_bytes: 4476
import sys
import collections
input = sys.stdin.readline


def main():
    N, M = map(int, input().split())
    H = list(map(int, input().split()))
    Bridge = [list(map(int, input().split())) for _ in range(M)]
    Good_Bridge = [1]*N
    for i in Bridge:
        if H[i[0]-1] < H[i[1]-1]:
            Good_Bridge[i[0]-1] = 0
        elif H[i[0]-1] > H[i[1]-1]:
            Good_Bridge[i[1]-1] = 0
        else:
            Good_Bridge[i[0]-1], Good_Bridge[i[1]-1] = 0, 0
    answer = collections.Counter(Good_Bridge)

    print(answer[1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 33100
#include <bits/stdc++.h>
#define int long long
#define INF 1ll<<60
using namespace std;
int mdc(int a,int b){
  int aux=1;
  if(b%a==0)
    return a;
  while(b%a!=0){
    aux=b%a;
    b=a;
    a=aux;
  }
  return aux;
}
int divisores(int a,int b,int c){
  int aux1=a/c;
  int aux2=b/c;
  int aux=aux2-aux1;
  return aux;
}
signed main(){
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int C,D,aux;
  if(a%c==0)
    C=divisores(a-1,b,c);
  else
    C=divisores(a,b,c);
  if(a%d==0)
    D=divisores(a-1,b,d);
  else
    D=divisores(a,b,d);
  int med=mdc(c,d);
  if(a%((c*d)/med)==0)
    aux=divisores(a-1,b,(c*d)/med);
  else
    aux=divisores(a,b,(c*d)/med);
  int fim=C+D-aux;
  cout<<b-a+1-fim<<endl;
  return 0;
}


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


int main() {

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(min(b,d) - max(a,c), 0) << endl;
    return 0;
}

Measured memory_bytes: 256
from  collections import deque,Counter
N,M,K=list(map(int,input().split()))
AB=[list(map(int,input().split())) for i in range(M)]
CD=[list(map(int,input().split())) for i in range(K)]

user=[0 for i in range(N+1)]
graph_ab=[[] for i in range(N+1)]
graph_cd=[[] for i in range(N+1)]
visited=[0 for i in range(N+1)]
for i in range(M):
    a,b=AB[i]
    graph_ab[a].append(b)
    graph_ab[b].append(a)
time=0
for j in range(1,N+1):
    if visited[j]==0:
        stack=deque([j])
        time+=1
        visited[j]=time
        while stack:
            x=stack.popleft()
            for i in graph_ab[x]:
                if visited[i]==0:
                    visited[i]=time
                    stack.append(i)
#     visit_list[j]=visited
counter=Counter(visited) 
for i in range(K):
    c,d=CD[i]
    if visited[c]==visited[d]:
        graph_cd[c].append(d)
        graph_cd[d].append(c)

for i in range(1,N+1):
    user[i]=counter[visited[i]]-len(graph_ab[i])-len(graph_cd[i])-1

del user[0]
print(*user)

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

ll gcd(int x,int y){
  if (y==0){
    return x;
  }
  else{
    return gcd(y,x%y);
  }
}

int main(){
  ll n,x;
  cin>>n>>x;
  vector<ll> v(n);
  rep(i,n){
    cin>>v.at(i);
  }
  rep(i,n){
    v.at(i) = abs(x-v.at(i));
  }
  sort(v.begin(),v.end());
  ll sum = 0;
  rep(i,n-1){
    v.at(i+1) = gcd(v.at(i),v.at(i+1));
  }
  sum = v.at(n-1);
  cout << sum << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x;
    string s;
    cin>>n>>s;
    for(int i=0 ; i<s.size(); i++)
    {

        x=s[i]+n;
        if(x>90)
        s[i]=65-(91-x);
        else
            s[i]=s[i]+n;
    }
    cout<<s;
   return 0;
}



Measured memory_bytes: 3640
import java.util.Scanner;

public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int A[] = new int[N];
    long num[] = new long[N];
    for(int i = 0; i < N; i++){
      A[i] = sc.nextInt()-1;
      num[A[i]]++;
    }
    long com[] = new long[N];
    long max = 0;
    for(int i = 0; i < N; i++){
      com[i] = (num[i]*(num[i]-1))/2;
      max += com[i];
    }
    for(int i = 0; i < N; i++){
      System.out.println(max - com[A[i]] + ((num[A[i]]-1)*(num[A[i]]-2))/2);
    }
  }
}

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

using namespace std;
#define INFS (1LL<<28)
#define INF (1LL<<60)
#define DEKAI 1000000007
#define lp(i,n) for(int i=0;i<n;i++)
#define int long long
int x[200001],cnt[200001];
int befit[200001];
vector<int> v,rev;
vector<vector<vector<int>>> ans2;
int mod=0;

void solve(int st,int end){
	vector<vector<int>> ans;
	ans.push_back({-1});
	while(1){
		vector<int> s;
		s.push_back(-1);
		for(int i=st;i<=end;i++){
			if(x[i]==-1){
				s.push_back(v[i]);
				//cout<<v[i]<<" ";
			}
			else{
				i=x[i];
			}
		}
		//cout<<endl;
		//cout<<"END"<<endl;
		if(s.size()==1)break;
		s.erase(s.begin());
		ans.push_back(s);
		st=befit[s[0]]+1;
	}
	//cout<<"OUT"<<endl;
	ans2.push_back(ans);
	return;
}

signed main(){
	int n,k;
	cin>>n>>k;
	lp(i,n){
		int a;
		cin>>a;
		v.push_back(a);
		rev.push_back(a);
	}
	lp(i,200001)befit[i]=-1;
	reverse(rev.begin(),rev.end());

	lp(i,n){
		int now=rev[i];
		cnt[now]++;
		x[n-i-1]=befit[now];
		befit[now]=n-i-1;
	}
	vector<pair<int,int>> ans;
	lp(i,n){
		if(cnt[v[i]]==1){
			ans.push_back({-1,v[i]});
		}
		else{
			int bef=i;
			int maxi=x[i];
			while(i<=maxi){
				maxi=max(x[i],maxi);
				i++;
			}
			ans.push_back({bef,i-1});
			i--;
		}
	}
	int cnc=0;
	lp(i,ans.size()){
		if(ans[i].first!=-1){
			solve(ans[i].first,ans[i].second);

			mod+=ans2[cnc].size()-1;
			/*
			lp(j,ans2[cnc].size()){
				lp(k,ans2[cnc][j].size()){
					cout<<ans2[cnc][j][k]<<" ";
				}
				cout<<endl;
			}
			cnc++;
	*/
		}
		else{
			mod++;
		}
	}
	/*
	lp(i,ans.size()){
		cout<<ans[i].first<<" "<<ans[i].second<<endl;
	}
	
	
	lp(i,n){
		cout<<i<<" "<<x[i]<<endl;
	}
	
	cout<<endl<<"UNDER"<<endl;
	*/

	k%=mod+1;
	//cout<<mod+1<<endl;
	if(k==0){
		return 0;
	}
	int itpair=0,ans2it=0,selc=1;
	lp(i,k-1){
		if(ans[i].first==-1){
			itpair++;
		}
		else{
			int huga=ans2[ans2it].size();
			//cout<<huga<<" "<<selc<<endl;
			if(huga>selc)selc++;
			else{
				selc=1;
				ans2it++;
				itpair++;
				//cout<<huga<<endl;
				if(huga==1){
					k++;
				}
			}
		}
		//cout<<i<<endl;
	}
	//cout<<selc<<endl;
	//cout<<"DIWB"<<endl;
	int toge=0;
	for(int i=itpair;i<ans.size();i++){
		if(i!=itpair&&toge==0)cout<<" ";
		toge=0;
		if(ans[i].first==-1){
			cout<<ans[i].second;
		}
		else{
			int check=0;
			//cout<<selc<<" "<<ans2it<<endl;
			if(selc>=ans2[ans2it].size()){
				//cout<<"$#$#"<<endl;
				selc=1;
				ans2it++;
				toge=1;
				continue;
			}
			lp(j,ans2[ans2it][selc].size()){
				cout<<ans2[ans2it][selc][j];
				if(j!=ans2[ans2it][selc].size()) cout<<" ";
				check=1;
			}
			selc=1;
			ans2it++;
		}
	}
	return 0;
}

Measured memory_bytes: 878944
#include <cstdio>

int main(void){
	int n;
	long a, max=-1000000, min=1000000, sum=0;

	scanf(" %d", &n);
	for(int i=0; i<n; ++i){
		scanf(" %ld", &a);
		if(a>max) max = a;
		if(a<min) min = a;
		sum+=a;
	}

	printf("%ld %ld %ld\n", min, max, sum);

	return 0;
}


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

int main() {
  int N;

  cin >> N;

  vector<int> a(N);

  for(int i=0; i<N; i++) {
      cin >> a.at(i);
  }

  vector<int> sort(N,0);

  for(int i=0; i<N; i++) {
      for(int j=0; j<N; j++) {
          if(sort.at(i) <= a.at(j)) sort.at(i)=a.at(j);
      }
      for(int j=0; j<N; j++) {
          if(sort.at(i) == a.at(j)) {
              a.at(j)=0;
              break;
          }
      }
  }

  int Alice=0;
  int Bob=0;

  for(int i=0; i<N; i++) {
      if(i%2==0) {
          Alice += sort.at(i);
      } else {
          Bob += sort.at(i);
      }
  }

  cout << Alice - Bob << endl;
}

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

int main() {
  int N;

  cin >> N;

  vector<int> a(N);

  for(int i=0; i<N; i++) {
      cin >> a.at(i);
  }

  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());

  int Alice=0;
  int Bob=0;

  for(int i=0; i<N; i++) {
      if(i%2==0) {
          Alice += a.at(i);
      } else {
          Bob += a.at(i);
      }
  }

  cout << Alice - Bob << endl;
}*/

Measured memory_bytes: 256
// https://atcoder.jp/contests/

#include <bits/stdc++.h>
#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 INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

int x[3];

int main()
{
  cin >> x[0] >> x[1] >> x[2];

  sort(x, x + 3);

  int bc = x[2] - x[1],
      ab = x[1] - x[0],
      r = ab % 2 ? bc + ab / 2 + 2 : bc + ab / 2;

  cout << r << '\n';

  return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

void solve()
{
   int n;cin>>n;
   int c=0;
   while(n--)
   {
       int h,g;
       cin>>h>>g;
       if(h==g)
       {
           c++;
       }
       else
       {
           c=0;
       }
       if(c==3)
       {
           cout<<"Yes";
           return;
       }
       
   }
   cout<<"No";
   
}

int main()
{
    ll S=1;
    //cin >> S;
    while(S--)
    {
        solve();
    }
    return 0;
}


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

using namespace std;

#define int long long
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF (1 << 30)

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;
typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int n, a[300000];
priority_queue<int> bigger;
priority_queue<int, vector<int>, greater<int> > smaller;

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

    cin >> n;
    rep(i, 3 * n) cin >> a[i];
    int left = 0, right = 0;
    rep(i, n) {
        smaller.push(a[i]);
        bigger.push(a[2 * n + i]);
        left += a[i]; right += a[2 * n + i];
    }
    int res = -LLONG_MAX;
    vector<int> vl, vr;
    vl.push_back(left); vr.push_back(right);
    rep(i, n) {
        smaller.push(a[n + i]);
        bigger.push(a[2 * n - i - 1]);
        left = left - smaller.top() + a[n + i];
        right = right - bigger.top() + a[2 * n - i - 1];
        smaller.pop(); bigger.pop();
        vl.push_back(left); vr.push_back(right);
    }
    rep(i, vl.size()) chmax(res, vl[i] - vr[n - i]);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 6636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
int main(){
  string S;
  cin >> S;
  int maxn = 0;
  int cnt = 0;
  rep(i,S.size()){
    if(S.at(i)=='A'||S.at(i)=='C'||S.at(i)=='G'||S.at(i)=='T'){
      ++cnt;
      maxn = max(maxn,cnt);
    }else
      cnt = 0;
  }
  cout << maxn;
}

Measured memory_bytes: 256
from itertools import permutations


N = int(input())

XY = []
for i in range(N):
    x, y = map(int, input().split())
    XY.append((x, y))

routes = list(permutations(range(N)))

tmp = 0
cnt = 0
for route in routes:
    for i in range(1, N):
        FROM = route[i-1]
        TO = route[i]
        tmp += ((XY[FROM][0]-XY[TO][0])**2 + (XY[FROM][1]-XY[TO][1])**2)**0.5
    cnt+=1

print(tmp/cnt)


Measured memory_bytes: 45808
#include <stdio.h>
#include <math.h>

int main(){
  long long int X;
  long long int A=100LL;
  scanf("%lld",&X);
  int c=0;
  while(A<X){
    A+=A/100L;
    c++;
  }
  printf("%d\n",c);
  return 0;
}

Measured memory_bytes: 1728
#include <iostream>

using namespace std;

int main(){
    int a, b;
    string c;
    cin >> a >> b;
    if (a>b)
        c = ">";
    else if (a<b)
        c= "<";
    else
        c= "==";
    cout << "a" << " " <<  c  << " " << "b" <<endl;
}

Measured memory_bytes: 3188
cnt = {"1":0,"2":0,"3":0,"4":0}
for i in range(3) :
    (j,k)=input().split()
    cnt[j]+=1
    cnt[k]+=1

if cnt["1"] == 3 or cnt["2"] == 3 or cnt["3"] == 3 or cnt["4"] == 3 :
    print("NO")
else :
    print("YES")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std ; 
int main(){
    int n,m; 
    cin>>n>>m ; 
    int arr[m] ; 
    for(int i =0 ; i<m ; i++){
    cin>>arr[i] ; 
    }
    int sum = accumulate(arr,arr+m,0) ; 
  
    if(sum>n){
        cout<<"-1";  return 0 ; 
    }
    cout<<n-sum<<"\n" ; 
}

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

typedef long long ll;
#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define REPM(i,n) for(ll i=(n-1); 0=<i; i--)
#define VI vector<int>
#define VL vector<ll>
#define VD vector<double>
#define VS vector<string>
#define V_SORT_U(x) sort(x.begin(), x.end());
#define V_SORT_D(x) sort(x.begin(), x.end(),greater<int>());
#define V_SUM(x) accumulate(x.begin(), x.end(), 0)
#define STR_TRANS_UP(x) transform(x.begin(), x.end(), x.begin(), ::toupper);
#define STR_TRANS_LOW(x) transform(x.begin(), x.end(), x.begin(), ::tolower);

int main(void){
    double R;

    cin >> R;

    cout << (R*2)*M_PI << endl;

    return 0;
}

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

struct mystack{
	int v[1000],top=0;
	bool isEmpty(){return top==0;}
	void push(int a){v[++top]=a;}
	int pop(){
		if(isEmpty()){
			cout<<"error\n"s;
			return 0;
		}
		else return v[top--];
	}
};

int main(){
	mystack a;
	string s;
	while(cin>>s){
		if(s.at(0)=='+')a.push(a.pop()+a.pop());
		else if(s.at(0)=='-'){
			int tmp=a.pop();
			a.push(a.pop()-tmp);
		}
		else if(s.at(0)=='*')a.push(a.pop()*a.pop());
		else a.push(stoi(s));
	}
	cout<<a.pop();
	for(;!a.isEmpty();)cout<<" "s<<a.pop();
	cout<<"\n"s;
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;  
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define Rep(i, a, b) for(ll i = a; i <= b; i++)
#define repr(i, a, b) for(ll i = b-1; i >= a; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
// const ll INF = 1LL << 60;
const ll INF = 1000000000;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

// rep(i, 0, sz(v)) cout << v[i] << " \n"[i==sz(v)-1];

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

// dijkstra
ll H, W;
ll sh, sw, gh, gw;
Vs s;

ll d[1005][1005], color[1005][1005];
ll dy[] = {0, 1, 0, -1};
ll dx[] = {1, 0, -1, 0};

void dijkstra(){
    priority_queue<pair<ll, pair<ll, ll>>, vector<pair<ll, pair<ll, ll>>>, greater<pair<ll, pair<ll, ll>>>> pq;
    rep(i, 0, 1000) rep(j, 0, 1000) d[i][j] = INF;
    d[sh][sw] = 0;
    pq.push({0, {sh, sw}});
    while(!pq.empty()){
        ll cost = pq.top().first;
        pair<ll, ll> u = pq.top().second;
        pq.pop();
        color[u.first][u.second] = 1;
        if(d[u.first][u.second] < cost) continue;
        rep(i, 0, 4){
            ll y = u.first + dy[i], x = u.second + dx[i];
            if(y < 0 || y >= H || x < 0 || x >= W) continue;
            if(color[y][x]) continue;
            if(s[y][x] == '#') continue;
            if(d[y][x] > cost){
                d[y][x]  = cost;
                pq.push({cost, {y, x}});
            } 
        }
        Rep(i, -2, 2){
            Rep(j, -2, 2){
                ll y = u.first + i, x = u.second + j;
                if(y < 0 || y >= H || x < 0 || x >= W) continue;
                if(s[y][x] == '#') continue;
                if(color[y][x]) continue;
                if(d[y][x] > cost+1){
                    d[y][x] = cost+1;
                    pq.push({cost+1, {y, x}});
                } 
            }
        }
    }
    // rep(i, 0, H) rep(j, 0, W) cout << d[i][j] << " \n"[j == W-1];
    ll ans = d[gh][gw];
    if(ans == INF) ans = -1;
    co(ans);
}

int main() {
    cin >> H >> W;
    cin >> sh >> sw >> gh >> gw;
    sh--, sw--, gh--, gw--;
    s.resize(H);
    rep(i, 0, H) cin >> s[i];

    dijkstra();

    return 0;
}
 
 


Measured memory_bytes: 21352
#include<iostream>
using namespace std;
 
int main()
{
        int N,A,B;
 
        cin >> N;
        cin >> A;
        cin >> B;
 
        int limit = A+B;
        int Yes = 0;
        int BN = 0;
 
        char S[N+1];
        cin >> S;
 
        for (int i =0; i < N; i++)
        {
                if (S[i] == 'a' && Yes < limit)
                {
                        cout << "Yes" <<endl;
                        Yes++;
                }
                else if(S[i] == 'b')
                {
                        if (Yes < limit && BN < B)
                        {
                                cout << "Yes" <<endl;
                                BN++;
                                Yes++;
                        }
                        else
                                cout << "No" <<endl;
                }
                else
                        cout << "No" <<endl;
        }
        return 0;
}

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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;

int main() {
    string s, t;
    cin >> s >> t;
    cout << t << s << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
typedef long long int ll;
typedef long double ld;
using namespace std;

struct edge{ll to, cost;};
vector<vector<edge>> G(100001, vector<edge>());
vll p(100001, -1000000000000000000);

vll check(100001, 0);
void dfs(ll now, ll from, ll d){
  if(p[now]==-1000000000000000000) p[now] = d;
  else if(p[now]!=d){
    std::cout << "No" << '\n';
    exit(0);
  }
  if(check[now]==1) return;
  check[now] = 1;
  for(int i=0;i<G[now].size();i++){
    if(G[now][i].to==from) continue;
    dfs(G[now][i].to, now, d+G[now][i].cost);
  }
}
int main(int argc, char const *argv[]) {
  ll l, r, d, n, m;std::cin >> n >> m;
  re(i, m){
    std::cin >> l >> r >> d;
    G[l].push_back(edge{r, d});
    G[r].push_back(edge{l, -d});
  }
  rep(i, 1, n){
    if(G[i].size()==0||check[i]==1) continue;
    dfs(i, -1, 0);
  }
  std::cout << "Yes" << '\n';
  return 0;
}


Measured memory_bytes: 18176
#include <bits/stdc++.h>
using namespace std;
#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 fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int n,l;
    cin >> n >> l;
    int su =  (2 * l+ n-1) * n / 2;
    if(l >0){
        cout << su - l << endl;
    }

    if( l <= 0){
        if(l + n - 1 >= 0){
            cout << su << endl;
        }
        else{
            cout << su - (l + n - 1 ) << endl;
        }
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

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

   
   int a = stdIn.nextInt();
   int b = stdIn.nextInt();
   int c = stdIn.nextInt();
   int i;
   
   if (a < b){
   
   } else {
   i=a;
   a=b;
   b=i;
   }
   if (b > c){
   i=b;
   b=c;
   c=i;
     if (a > b){
     i=a;
     a=b;
    b=i;
     }
   }
   
   System.out.println(a+ " " + b + " "+ c);
 }
}


Measured memory_bytes: 26308
// In The Namw Of Allah
#include <bits/stdc++.h>
using namespace std;

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

const int N = 0 + 10, mod = 1e9 + 7;

double dist[N][N], x[N], y[N];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cout << fixed << setprecision(6);
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
	}
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++) {
			if(i == j)	dist[i][j] = 0;
			else
				dist[i][j] = sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
		}
	vector <int> a(n, 0);
	double av = 0;
	double f = 1;
	for (int i = 2; i <= n; i++)
		f *= i;
	for (int i = 0; i < n; i++)	a[i] = i + 1;
	do {
		double ans = 0;
		for (int i = 0; i < n - 1; i++)
			ans += dist[a[i] - 1][a[i + 1] - 1];
		av += ans;
	}while(next_permutation(a.begin(), a.end()));
	av /= f;
	cout << av << "\n";
}

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

using namespace std;

//void C_115()
int main()
{
  int N, K;
  cin >> N >> K;

  vector<int> h(N);
  for (int i = 0; i < N; ++i) cin >> h[i];
  sort(h.begin(), h.end());

  int min_diff = h[N - 1] - h[0];
  for (int i = 0; i+K-1< N; ++i)
  {
    min_diff = min(h[i + (K - 1)] - h[i], min_diff);
  }
  cout << min_diff << endl;
}

Measured memory_bytes: 640
#![allow(unused_imports)]
#[macro_use]
mod reader {
    // mod calc;

    // use calc::*;


    #![allow(dead_code)]
    use std;
    macro_rules! read_line((  ) => {
                           {
                           let mut input = String :: new (  ) ; std :: io ::
                           stdin (  ) . read_line ( & mut input ) . unwrap (
                           ) ; input } } ;);
    pub fn read_to_vec<T: std::str::FromStr>() -> Vec<T> {
        read_line!().split_whitespace().map(|e|
                                                e.parse().ok().unwrap()).collect()
    }
}
#[macro_use]
mod misc {
    #![allow(dead_code)]
    use std;
    #[macro_export]
    macro_rules! bind_from_vec((
                               $ ( $ variable : ident ) , + = $ vector : expr
                               ) => {
                               let mut v = $ vector . clone (  ) . into_iter (
                                ) ; $ (
                               let $ variable = v . next (  ) . unwrap (  ) ;
                               ) + } ;);
}
use reader::*;
use misc::*;
fn main() {
    bind_from_vec!(r , d , x = read_to_vec :: < i32 > (  ));
    let mut x = x;
    for _ in 0..10 { x = r * x - d; println!("{}" , x); }
}


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

using namespace std;

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

    int n, k; cin >> n >> k;
    string s; cin >> s;

    vector<int> consec(1);
    char prev = '1';

    for(char &c : s)
    {
        if(c == prev) ++consec.back();
        else{prev = c; consec.push_back(1);}
    }
    if(s.back() == '0') consec.push_back(0);

    int cSize = consec.size();
    int sum[cSize + 1]; sum[0] = 0;
    for(int i = 1; i <= cSize; ++i)
        sum[i] = sum[i - 1] + consec[i - 1];

    if(2 * k + 1 >= cSize)
    {
        cout << sum[cSize];
        return 0;
    }

    int ans = -1;
    for(int i = 2 * k + 1; i <= cSize; i += 2)
    {
        if(ans < sum[i] - sum[i - 2*k - 1])
            ans = sum[i] - sum[i - 2*k - 1];
    }

    cout << ans;
    return 0;
}

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

int w[100], v[100];
int n;
long long dp[100][100001];

long long solve(int i, int cap) {
    if(i==n) return 0;

    if(dp[i][cap] != -1) {
        return dp[i][cap];
    }

    if(cap>=w[i]) {
        dp[i][cap] = v[i] + solve(i+1, cap-w[i]);
    }
    dp[i][cap] = max(dp[i][cap], solve(i+1, cap));

    return dp[i][cap];
}

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

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

    memset(dp, -1, sizeof(dp));

    cout<<solve(0, W)<<'\n';
}

Measured memory_bytes: 78336
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#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 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;

// 約数列挙：nの約数を昇順に返す。
vector<long long> enumDivisors(long long n){
    vector<long long> ret;
    for(long long i=1; i*i<=n; i++){
        if(n%i == 0){
            ret.push_back(i);
            if(n/i != i) ret.push_back(n/i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}

int main(){
    Init();
    ll n, sum = 0; cin >> n;
    auto eDiv = enumDivisors(n);
    for(auto d: eDiv){
        ll num = d-1;
        if(num == 0) continue;
        if(n/num == n%num) sum += num;
    }
    cout << sum << endl;
}

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

using namespace std;
int main(void)
{
    int n;
    cin >> n;
    vector<int> p(n);
    int ngcount = 0;
    for (size_t i = 0; i < n; i++)
    {
        cin >> p[i];
    }

    for (size_t i = 0; i < n; i++)
    {
        if (p[i] != i+1)
        {
            ngcount++;
        }
    }

    if (ngcount > 2)
    {
        cout << "NO" << endl;
    }
    else
    {
        cout << "YES" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
	"strconv"
)

func main() {
	var line string
	fmt.Scan(&line)
	x := math.MaxInt32
	for i := 0; i < len(line) - 2; i++ {
		tmp := line[i:i + 3]
		tmpInt, _ := strconv.Atoi(tmp)
		if abs(753 - tmpInt) < x {
			x = abs(753 - tmpInt)
		}
	}
	fmt.Println(x)
}

func abs(x int) int {
	return int(math.Abs(float64(x)))
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
   int64_t N,P;
  cin>>N>>P; 
  int c=0;
  vector<int64_t>arr(N);
  for(int i=0;i<N;i++){
    int64_t a; 
    cin>>a;
    a%=2;
    if(a==1)
      c++;
    arr.at(i)=a;
  }if(c==0){
  if(P==1)
    cout<<0;
    else{
      int64_t result=pow(2,N);
      cout<<result;
    }
  
  }else
  {int64_t result=pow(2,N-1); 
   cout<<result;
  }
  return 0;
}


Measured memory_bytes: 3928
#include <iostream>
#include <string>
#include <vector>
typedef unsigned int UINT;
using namespace std;
int main(void) {
    int A, B,X;
    cin >> A >> B>>X;
    bool is = true;
    if (A > X)
        is = false;
    if (A + B < X)
        is = false;
    
    if(is )
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;

}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
class E { static void Main() { new K(); } }
class K
{
	public K()
	{
		var N = int.Parse(Console.ReadLine());
		var ps = GetPrimes(101000);
		var p2 = new Dictionary<long, int>();
		foreach (var p in ps) p2.Add(p * (long)p, p);
		var z = new long[N];
		var cnt = new Dictionary<long, int>();
		var w = new Dictionary<long, long>();
		for (var i = 0; i < N; i++)
		{
			var num = long.Parse(Console.ReadLine());
			var fact = new List<int>();
			var t = 1L;
			for (var j = 0; j < ps.Count; j++)
			{
				var x = ps[j];
				var cube = x * (long)x * x;
				if (cube > num) break;
				if (num % x == 0)
				{
					fact.Add(x);
					while (num % cube == 0) num /= cube;
					if (num % (x * (long)x) == 0) t *= x;
					else if (num % x == 0) t *= x * (long)x;
				}
			}
			z[i] = num;
			if (!w.ContainsKey(z[i]))
			{
				foreach (var p in fact) while (num % p == 0) num /= p;
				var lim = 10000000100L / t;
				var lim2 = (int)(Math.Sqrt(lim) + 10);
				if (p2.ContainsKey(num)) { if (p2[num] < lim) t *= p2[num]; else t = -1; }
				else { if (num < lim2) t *= num * num; else t = -1; }
				w[z[i]] = t;
				cnt[z[i]] = 0;
			}
			cnt[z[i]]++;
		}
		var sum = 0;
		var set = new HashSet<long>(z);
		var done = new HashSet<long>();
		if (set.Contains(1)) { sum++; set.Remove(1); }
		foreach (var x in set)
		{
			if (done.Contains(x)) continue;
			var y = w[x];
			if (cnt.ContainsKey(y)) sum += Math.Max(cnt[x], cnt[y]);
			else sum += cnt[x];
			done.Add(x);
			done.Add(y);
		}
		Console.WriteLine(sum);
	}
	List<int> GetPrimes(int n)
	{
		var m = (n - 1) >> 1;
		var primes = new List<int>((int)(n / Math.Log(n)));
		primes.Add(2);
		var composites = new bool[m];
		composites[0] = false;
		for (var p = 0; p < m; p++)
			if (!composites[p])
			{
				var pnum = 2 * p + 3;
				primes.Add(pnum);
				for (var k = 3 * p + 3; k < m; k += pnum) composites[k] = true;
			}
		return primes;
	}
}

Measured memory_bytes: 28288
#include <iostream>
#include <cstring>
#include <string>
#include <functional>

const int MAX_N = 3000;

char s[MAX_N + 3], t[MAX_N + 3];

int f[MAX_N + 1][MAX_N + 1];

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
  std::cin >> s + 1 >> t + 1;
  const int n = strlen(s + 1), m = strlen(t + 1);
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (s[i] == t[j]) {
        f[i][j] = f[i - 1][j - 1] + 1;
      } else {
        f[i][j] = std::max(f[i - 1][j], f[i][j - 1]);
      }
    }
  }
  std::string ret;
  std::function<void(int, int)> dfs = [&](int i, int j) {
    if (i == 0 || j == 0) return "";
    if (s[i] == t[j]) {
      ret += s[i];
      dfs(i - 1, j - 1);
    } else if (f[i][j] == f[i - 1][j]) {
      dfs(i - 1, j);
    } else if (f[i][j] == f[i][j - 1]) {
      dfs(i, j - 1);
    }
  };
  dfs(n, m);
  for (int i = ret.length() - 1; i >= 0; --i) std::cout << ret[i];
}

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

typedef long long int ll;
typedef long double ld;

#define rep(i,a,b) for(ll i=a;i<=b;++i)
#define rev(i,a,b) for(ll i=a;i>=b;i--)
#define pll pair<ll,ll>
#define vll vector<ll>
#define sll set<ll>
#define vpll vector<pll>
#define F first
#define S second
#define pb push_back
#define mp make_pair
char ans[300][300];
int main()
{
    ll h,w;cin>>h>>w;
    rep(i,1,h) rep(j,1,w) cin>>ans[i][j];
    rep(i,1,2*h) {
        rep(j,1,w){cout<<ans[(i+1)/2][j];
        }
        cout<<endl;
    }
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <tuple>
using namespace std;

vector<int> Xs[22];
vector<bool> Ys[22];

bool HasBit(int x,int pos) {
    return ((x>>pos)&1);
}

int main() {
    int N;
    cin>>N;
    for(int i=0;i<N;i++) {
        int A;
        cin>>A;
        for(int j=0;j<A;j++) {
            int x,y;
            cin>>x>>y;
            Xs[i].push_back(x-1);
            Ys[i].push_back(y);
        }
    }
    int ans=0;
    for(int mask=0;mask<(1<<N);mask++) {
        bool ok=true;
        for(int i=0;i<N;i++) {
            if (!HasBit(mask,i))
                continue;
            int A=Xs[i].size();
            for(int j=0;j<A;j++) {
                if (HasBit(mask,Xs[i][j])!=Ys[i][j])
                    ok=false;
            }
            
        }
        if (ok)
            ans=max(ans,__builtin_popcount(mask));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define irep(i, n) for(int i = n-1; i >= (int)0; i--)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
bool IsPrime(ll num)//素数
{
    if (num < 2ll) return false;
    else if (num == 2ll) return true;
    else if (num % 2ll == 0ll) return false; // 偶数はあらかじめ除く

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

    // 素数である
    return true;
}

int main(){
    int h,w;
    std::cin >> h>>w;
    vvector(a,string,h,w,"a");
    reprep(i,j,h,w)std::cin >> a[i][j];
    reprep(i,j,h,w){
        if(a[i][j]=="snuke"){
            std::cout << char(j+'A')<<i+1 << std::endl;
            exit(0);
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<deque>
#include<algorithm>
using namespace std;
int main() {
	deque<long long>d;
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		long long a; cin >> a;
		if ((i % 2 + n % 2) % 2 == 0)d.push_back(a);
		else d.push_front(a);
	}
	for (auto i = 0; i < n; i++) {
		if (i)cout << ' ';
		cout << d[i];
	}cout << endl;
}

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

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

  vector<vector<int>> a(2, vector<int>(n));

  for(int i = 0; i < 2; i++){
    for(int j = 0; j < n; j++){
      cin >> a.at(i).at(j);
    }
  }

  vector<int> b(n, 0);

  for(int i = 0; i < n; i++){
    b.at(i) = a.at(0).at(i) - a.at(1).at(i);
  }

  int ans = 0;

  for(int i = 0; i < n; i++){
    if(b.at(i) > 0){
      ans += b.at(i);
    }
  }

  cout << ans << endl;
}

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

using ll = long long;

const ll MXLL = 1e18;

struct T {
   ll a,b,c;

   T(){}
   T(ll x) : a(x), b(x), c(x) {}
   T(ll a, ll b, ll c) : a(a), b(b), c(c) {}
};

int n, k;
vector<T> dp;
vector<T> arr;

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

   cin >> n;
   dp = arr = vector<T>(n+1, T(MXLL));
   for(size_t i=1;i<=n;i++)
      cin >> arr[i].a >> arr[i].b >> arr[i].c;

   dp[1] = arr[1];
   for(size_t i=2;i<=n;i++) {
      dp[i].a = arr[i].a + max(dp[i-1].b, dp[i-1].c);
      dp[i].b = arr[i].b + max(dp[i-1].a, dp[i-1].c);
      dp[i].c = arr[i].c + max(dp[i-1].a, dp[i-1].b);
   }

   cout << max({dp[n].a, dp[n].b, dp[n].c});
   return 0;
}



Measured memory_bytes: 4992