akhauriyash/Code-Regression huggingface dataset:
/*
  AUTHOR:SOURABH
  CREATED:19:09:20
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<ll , null_type, less< ll >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define fit(it,s) for(it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mod 998244353
#define MAXN 10000001
#define M 32

using namespace std;
using namespace __gnu_pbds;

vll a(200000),tree1(800001),lazy(800001);

void push(ll node,ll s,ll e)
{
	if(lazy[node]!=0)
    {
        tree1[node]=(tree1[node]+lazy[node]*(e-s+1))%mod;
        if(s!=e)
        {
            lazy[2*node]+=lazy[node];
            lazy[2*node+1]+=lazy[node];
        }
        lazy[node]=0;
    }
}
void rangeupdate(ll node,ll s,ll e,ll l,ll r,ll inc)
{
	push(node,s,e);

    if(s>e || s>r || e<l)
        return;

    if(l<=s && e<=r)
    {
    	lazy[node]+=inc;
        push(node,s,e);
        return;
    }

    ll mid=(s+e)/2;
    rangeupdate(2*node,s,mid,l,r,inc);
    rangeupdate(2*node+1,mid+1,e,l,r,inc);

    tree1[node]=(tree1[2*node]+tree1[2*node+1])%mod;
}
ll rangequery(ll node,ll s,ll e,ll l,ll r)
{
    if(s>e || s>r || e<l)
        return 0;

    push(node,s,e);

    if(l<=s && e<=r)
        return tree1[node];

    ll mid=(s+e)/2;
    ll p1=rangequery(2*node,s,mid,l,r);
    ll p2=rangequery(2*node+1,mid+1,e,l,r);
    return (p1+p2)%mod;
}

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

    //freopen("input.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    ll t,n,k,i,j,q,x,y;
    t=1;
    //cin>>t;
    W(t--)
    {
        cin>>n>>k;
        vector<pll> b(k);
        fn(i,k)
        cin>>b[i].fi>>b[i].se;
        rangeupdate(1,0,n-1,0,0,1);
        fn(i,n-1)
        {
            q=rangequery(1,0,n-1,i,i);
            fn(j,k)
            {
                x=b[j].fi+i,y=b[j].se+i;
                if(x>=n)
                    continue;
                else
                {
                    y=min(y,n-1);
                    rangeupdate(1,0,n-1,x,y,q);
                }
            }
            //cout<<rangequery(1,0,n-1,i,i)<<endl;
        }
        cout<<rangequery(1,0,n-1,n-1,n-1);
    }
}









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

int main(){
    int A,B;
    cin>>A>>B;

    if(A==B){
        cout<<A+B<<endl;
        return 0;
    }
    if(A>B){
        cout<<2*A-1<<endl;
        return 0;
    }
    if(A<B){
        cout<<2*B-1<<endl;
        return 0;
    }
}

Measured memory_bytes: 256
class Node:
    def __init__(self,key,priority,left=None,right=None):
        self.left = left
        self.right = right
        self.key = key
        self.priority = priority

def insert(t,key,priority):
    if t == None :
        return Node(key,priority)
    if key == t.key :
        return t
    if key < t.key :
        t.left = insert(t.left, key, priority)
        if t.priority < t.left.priority :
            t = rightRotate(t)
    else:
        t.right = insert(t.right, key, priority)
        if t.priority < t.right.priority :
            t = leftRotate(t)
    return t


def rightRotate(t):
    s = t.left
    t.left = s.right
    s.right = t
    return s


def leftRotate(t):
    s= t.right
    t.right = s.left
    s.left = t
    return s


def find(t,key):
    if t == None: return None
    elif t.key == key:return t
    elif t.key > key :return find(t.left,key)
    else: return find(t.right,key)

def erase(t, key):
    if t == None : return None
    if key == t.key:
        if t.left == None and t.right == None:return None
        elif t.left == None : t = leftRotate(t)
        elif t.right == None : t = rightRotate(t)
        else:
            if t.left.priority > t.right.priority:t = rightRotate(t)
            else: t = leftRotate(t)
        return erase(t, key)
    elif key < t.key : t.left = erase(t.left, key)
    else : t.right = erase(t.right, key)
    return t

def inorder(t):
    if t.left != None:inorder(t.left)
    print(" "+str(t.key), end='')
    if t.right != None: inorder(t.right)

def preorder(t):
    print(" "+str(t.key), end='')
    if t.left != None :preorder(t.left)
    if t.right != None : preorder(t.right)

if __name__=="__main__":
        m=(int)(input())
        root = None
        for i in range(m):
            order = input().split()
            if order[0] == "insert" :root = insert(root,(int)(order[1]),(int)(order[2]))
            elif order[0] == "delete" :root = erase(root,(int)(order[1]))
            elif order[0] == "find" :
                res = find(root,(int)(order[1]))
                if res == None :print("no")
                else:print("yes")
            else:
                inorder(root)
                print()
                preorder(root)
                print()



Measured memory_bytes: 52020
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

H, W = getNM()
S = [input() for i in range(H)]
score_w = [[0] * W for i in range(H)]
score_h = [[0] * W for i in range(H)]

for i in range(H):
    now = -1
    for j in range(W):
        if now == -1:
            # 初期化
            if S[i][j] == '.':
                now = 1
                score_w[i][j] = now
        else:
            # 次が.の時
            if S[i][j] == '.':
                now += 1
                score_w[i][j] = now
            # 次が#の時
            else:
                now = -1

    for j in range(1, W):
        if score_w[i][-j - 1] > 0:
            score_w[i][-j - 1] = max(score_w[i][-j - 1], score_w[i][-j])

for j in range(W):
    now = -1
    for i in range(H):
        if now == -1:
            # 初期化
            if S[i][j] == '.':
                now = 1
                score_h[i][j] = now
        else:
            # 次が.の時
            if S[i][j] == '.':
                now += 1
                score_h[i][j] = now
            # 次が#の時
            else:
                now = -1

    for i in range(1, H):
        if score_h[-i - 1][j] > 0:
            score_h[-i - 1][j] = max(score_h[-i - 1][j], score_h[-i][j])

ans = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == ".":
            ans = max(ans, score_w[i][j] + score_h[i][j] - 1)
print(ans)

Measured memory_bytes: 152664
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
double f(double x){
    return x * x;
}
int main(void){
    double x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << fixed << setprecision(8) << sqrt(f(x2 - x1) + f(y2 - y1)) << endl;
    
    return 0;
}



Measured memory_bytes: 3244
#include <stdio.h>
const int mod = 1000000007;
int pow(int a, int n);
// aの逆元の計算
int inv(int a) {
    return pow(a, mod - 2);
}
int add(int a, int b) {
    a %= mod;
    b %= mod;
    return (a + b) % mod;
}
int sub(int a, int b) {
    a %= mod;
    b %= mod;
    return (a + mod - b) % mod;
}
int mul(int a, int b) {
    a %= mod;
    b %= mod;
    return (int)((long long)a * (long long)b % mod);
}
int div(int a, int b) {
    //printf("div:b:%d invb:%d\n", b,inv(b));
    int ret = mul(a, inv(b));
    //printf("div:%d %d %d\n", a,b,ret);
    return ret;
}
// a/bの計算 a/b = a*(b^1)
int pow(int a, int n) {
    if (n == 0) {
        return 1;
    }
    //printf("%d %d\n",a,n);
    int h = n / 2;
    int hv = pow(a, h);
    int ret = mul(hv, hv);
    if (n % 2 == 1) {
        ret = mul(ret, a);
    }
    return ret;
}
int combination(int n, int a) {
    int n1 = n;
    int n2 = 1;
    for (int i = n - 1; i >= n - a + 1; --i) {
        n1 = mul(n1, i);
    }
    for (int i = 2; i <= a; ++i) {
        n2 = mul(n2, i);
        //printf("i:%d n2:%d\n", i, n2);
    }
    int comb = div(n1, n2);
    //printf("%d,%d  comb:%d\n", n1, n2, comb);
    return comb;
}

int main()
{
    int n, a, b;
    scanf("%d%d%d",&n,&a,&b);
    int ans = pow(2,n);
    ans = sub(ans, combination(n,a));
    ans = sub(ans, combination(n,b));
    ans = sub(ans, 1);
    printf("%d", ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <deque>
#include <queue>

using namespace std;
typedef long long ll;
using namespace std;

int main(){
    int N;
    cin >> N;
    string s,t;
    cin >> s >> t;
    for(int i = 0; i < N; i++){
        cout << s[i] << t[i];
    }
    cout << endl;
}


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

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


void solve(long long N, std::vector<long long> A){
  ll mask = 0; // 奇数個のビットが立ってる桁のマスク
  for(ll i=0; i<N; i++){
    mask ^= A[i];
  }

  // 偶数個のビットが立ってる桁だけに着目する。
  for(ll i=0; i<N; i++){
    A[i] = A[i] & (~mask);
  }

  ll n=0;
  for(ll m=1ll<<60; m; m>>=1){
    // 立ってるビットを見つける
    ll j;
    for(j=n; j<N; j++){
      if(A[j] & m){ break; }
    }
    if(j==N) continue;
    // ビットが立ってるやつを最初に持ってくる
    swap(A[n], A[j]);

    // 掃き出す。
    for(ll k=0; k<N; k++){
      if(k != n){
        if(A[k] & m){
          A[k] ^= A[n];
        }
      }
    }
    n++;
  }

  // 計算
  ll rst = 0;
  for(ll i=0; i<N; i++){
    rst ^= A[i];
  }
  cout << (rst + rst + mask) << endl;

}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[1000000];
int main(){
dp[0]=0;
int n,k;
cin>>n>>k;
vector<ll>a(n);
for(int i=0;i<n;i++)cin>>a[i];
for(int i=1;i<n;i++){
    ll &x=dp[i];
    dp[i]=1000000000000;
    for(int j=i-1;(j>=i-k)&&(j>=0);j--)
    x=min(dp[j]+abs(a[i]-a[j]),x);
}
cout<<dp[n-1]<<'\n';
return 0;    
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int main(void) {
    int N;
    cin >> N;

    vector<int> V(N), C(N);
    for(int i=0;i<N;i++){
        cin >> V[i];
    }
    for(int i=0;i<N;i++){
        cin >> C[i];
    }

    int ans=0;
    for(int i=0;i<N;i++){
        if( V[i] - C[i] > 0 ) ans += V[i] - C[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
using namespace std;
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;
//必要な宣言

int main() {
  string S;
  cin >> S;
  int flag = 1;

  if(S.find("a") == string::npos)
    flag = 0;

  if(S.find("b") == string::npos)
    flag = 0;

  if(S.find("c") == string::npos)
    flag = 0;

  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(p) p.begin(), p.end()
#define pop_count(p) __builtin_popcountll(p)
#define len(s, e) ((e)-(s)+1)
#define mid(s, e) ((s)+((e)-(s))/2)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
const int MOD = 1e9 + 7;
const int oo = 987654321;
const ll OO = 1e18;
#ifdef ONLINE_JUDGE
#define endl '\n'
#endif
template <typename A, typename B>
std::ostream& operator <<(std::ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
std::ostream& operator <<(std::ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
std::ostream& operator <<(std::ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
std::ostream& operator <<(std::ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
template <typename T>
std::istream& operator >>(std::istream& in, vector<T>& a) {
  for (auto& v : a) in >> v;
  return in;
}
#ifdef ANEEE_LOCAL
template <typename T>
std::ostream& operator <<(std::ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
#else
template <typename T>
std::ostream& operator <<(std::ostream& out, const vector<T>& a) {
  for (const auto& v : a) out << v << ' ';
  return out;
}
#endif
#ifdef ANEEE_LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 7
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " | ";
  __f(comma + 1, args...);
}

class Timer {
	clock_t start;
public:
	Timer() {start = clock();}
	~Timer() {cerr << (double)(clock() - start)/CLOCKS_PER_SEC << "\n";}
};

#ifdef ONLINE_JUDGE
#undef CASE_INFO
#endif

void solve() {
	string s;
	cin >> s;
	int rem = 0;
	for(char i : s) {
		rem = (rem * 10 + i - '0') % 9;
	}
	cout << (rem ? "No\n" : "Yes\n");
}

signed main() {
	Timer ti;
	std::ios_base::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	int T = 1;
	#ifdef TEST_CASES
	cin >> T;
	#endif
	for(int t = 1; t <= T; t++) {
		#ifdef CASE_INFO
		cout << "Case #" << t << ": ";
		#endif
		solve();
	}
	return 0;
}


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

int main() {
	// your code goes here
	double a;
	cin>>a;
	double p=100;
	ll ans=p;
	// double ans=log(a/p)/log(1.01);
	// cout<<ceil(ans);
	ll cnt=0;
	while(ans<a)
	{
		ans=ans*(1.01);
		cnt++;
		
	}
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 3724
N = int(input())
src = list(map(int,input().split()))

cum1 = cum2 = 0
ans1 = ans2 = 0
for i,a in enumerate(src):
    cum1 += a
    cum2 += a
    if i%2:
        if cum1 >= 0:
            ans1 += cum1+1
            cum1 = -1
        if cum2 <= 0:
            ans2 += 1-cum2
            cum2 = 1
    else:
        if cum1 <= 0:
            ans1 += 1-cum1
            cum1 = 1
        if cum2 >= 0:
            ans2 += cum2+1
            cum2 = -1

print(min(ans1,ans2))


Measured memory_bytes: 14332
// Union-Find Tree
// Renketsu
// https://atcoder.jp/contests/abc049/tasks/arc065_b
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 200005

struct UFT{
	int par[MAX_N];
	int depth[MAX_N];
	void init(){
		for(int i=0;i<MAX_N;i++){
			par[i]=i;
			depth[i]=0;
		}
		return;
	}
	UFT(){
		init();
	}

	int get_root(int i){
		if(par[i]==i){
			return i;
		}
		int rt = get_root(par[i]);
		par[i] = rt;
		return rt;
	}
	void merge(int i,int j){
		int x = get_root(i);
		int y = get_root(j);
		if(x==y){
			return;
		}
		if(depth[x]>depth[y]){
			par[y] = x;
		}else{
			par[x] = y;
			if(depth[x]==depth[y]){
				depth[y]++;
			}
		}
		return;
	}
	bool same(int i,int j){
		return get_root(i) == get_root(j);
	}

};


int main() {
	int N,K,L;
	cin >> N >> K >> L;
	UFT uft1;
	UFT uft2;

	for(int i=0;i<K;i++){
		int a,b;
		cin >> a >> b;
		a--;b--;
		uft1.merge(a,b);
	}
	for(int i=0;i<L;i++){
		int a,b;
		cin >> a >> b;
		a--;b--;
		uft2.merge(a,b);
		
	}
	pair<int,int> p[MAX_N];
	map<pair<int,int>,int > cnt;
	for(int i=0;i<N;i++){
		p[i] = make_pair(uft1.get_root(i),uft2.get_root(i));
		if(cnt.find(p[i]) == cnt.end()){
			cnt[p[i]] = 1;
		}else{
			cnt[p[i]] += 1;
		}
	}
	for(int i=0;i<N;i++){
		cout << cnt[p[i]] << " ";
	}
	cout << endl;
    return 0;
}



Measured memory_bytes: 16768
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

int32_t nextint(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); bool s=false; if(c=='-'){s=true;c=getchar_unlocked();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }

int main(void){
	int n=nextint();
	int k=nextint();
	int m=(n-1)*(n-2)/2-k;
	if(m<0){
		puts("-1");
	}else{
		printf("%d\n", n-1+m);
		for(int i=1; i<n; i++){
			printf("%d %d\n", 1, i+1);
		}
		for(int i=1; m>0&&i<n; i++){
			for(int j=i+1; m>0&&j<n; j++){
				printf("%d %d\n", i+1, j+1);
				m--;
			}
		}
	}
}


Measured memory_bytes: 128
#include<stdio.h>
typedef long long ll;
int a[200010],len[200010];
int main(){
	int n,i,j;
	ll ans,x;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d",a+i);
	for(i=n;i>0;i--){
		if(a[i]==0)len[i]=len[i+1]+1;
	}
	ans=0;
	for(i=1;i<=n;i++){
		x=0;
		for(j=i;j<=n;){
			if(a[j]==0){
				ans+=len[j];
				j+=len[j];
			}else{
				if(x&a[j])break;
				x^=a[j];
				ans++;
				j++;
			}
		}
	}
	printf("%lld",ans);
}

Measured memory_bytes: 1664
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define v vector
#define len length()
#define fi first
#define se second
#define mt make_tuple
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define rep(i,n) for(ll i=0;i<n;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int M = 1e9+7;
int ll_max=1e6;
v<ll> fact;
//factorial
void factorial(ll n)
{
    fact[0] = 1;
    for (ll i = 1; i <=n; i++)
    {
        fact[i] = i * fact[i - 1];
        fact[i] %= M;
    }
}
// modular exponentiation 
ll binpow(ll val, ll deg)
{
    if (!deg)
        return 1 % M;
    if (deg & 1)
        return binpow(val, deg - 1) * val % M;
    ll res = binpow(val, deg >> 1);
    return (res * res) % M;
}
//combination
ll combination(ll n, ll i)
{
    ll res = fact[n]; 
    ll div = fact[n - i] * fact[i];
    div %= M;
    // using fermat little theorum
    div = binpow(div, M - 2); // modular inverse  
    return (res * div) % M; 
}

int main() {
	// your code goes here
	IOS;
	ll n,m,i;
	ll j,t,x,y,z,k,d;
	cin>>n;
	cout<<n+n*n+n*n*n;

	
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    sort(A.begin(), A.end(), greater<int>());

    queue<int> q;
    ll res = A[0];
    q.push(A[1]);
    q.push(A[1]);
    for(int i=2;i<N;i++){
        res += q.front(); q.pop();
        q.push(A[i]);
        q.push(A[i]);
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 4828
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };


int main(){cout<<fixed<<setprecision(10);
		   ll n;
           cin>>n;
           ll A=1,B=1,C=1;
           if(n%2==0){
            A=B=n;
             C=n/2;
           }
           else{
             //a,b固定
             /*
             4abc=n(ab+bc+ca)
             (4ab-nb-na)c=nab
             c=nab/(4ab-na-nb);
             */
             for(int a=1;a<=3500;a++){
               for(int b=a;b<=3500;b++){
              // if(a==3&&b==2)cout<<(n*a*b)%(4*a*b-n*a-n*b)<<endl;
                if((4*a*b-n*a-n*b)>0&&(n*a*b)%(4*a*b-n*a-n*b)==0){
                 C= (n*a*b)/(4*a*b-n*a-n*b);
                  A=a;
                  B=b;
                  cout<<A<<" "<<B<<" "<<C<<endl;
                  return 0;
                }
               }
             }
           }
           cout<<A<<" "<<B<<" "<<C<<endl;
           
}



Measured memory_bytes: 3624
K,A,B = map(int,input().split())
if A+1 >= B:
  print(1+K)
else:
  if K <= A:
    print(1+K)
  else:
    if (K-A-1)%2 == 0:
      print((B-A)*((K-A-1)//2)+B)
    else:
      print((B-A)*((K-A-1)//2)+B+1)

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

int main()
{
  string S;
  int a=0;
  cin >> S;
  for(int i=0; i<S.size(); i=i+2){
    if(S.at(i)=='L'){
      a=1;
      break;
    }
    if(i<S.size()-1 && S.at(i+1)=='R'){
      a=1;
      break;
    }
  }
  if(a==1) cout << "No" << endl;
  else cout << "Yes" << endl;
} 

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

int main() {
  string s;
  cin>>s;
  int ans=0;
  for(int i=0;i<s.size()-1;i++){
    if(s.substr(i,2)=="01"||s.substr(i,2)=="10"){
      s.erase(s.begin()+i,s.begin()+i+2);
      ans+=2;
 
      i-=3;
      i=max(-1,i);
      if(s.size()==0){
        break;
      }
    }
  }
  cout <<ans;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
using namespace std;
#define INF (1 << 30)
int table[2][10500][2], n, tmp;

int main(){
  cin >> n;
  for(int i = 0;i < 2;i++)
    for(int j = 0;j < 10500;j++)
      for(int k = 0;k < 2;k++)table[i][j][k] = INF;
  table[1][1][0] = table[1][0][1] = 0;
  for(int i = 0;i < n - 1;i++){
    cin >> tmp;
    for(int j = 0;j < 10400;j++){
      if(j != 0)     
	table[i & 1][j][0] = min(table[(i + 1) & 1][j - 1][0], table[(i + 1) & 1][j - 1][1] + tmp);
      table[i & 1][j][1] = min(table[(i + 1) & 1][j][1], table[(i + 1) & 1][j][0] + tmp);
    }
  }
  cout << table[(n - 1) & 1][n / 2][1] << endl;
  return 0;
}

Measured memory_bytes: 1328
N, M = map(int, input().split())
friends = {i: set([]) for i in range(N)}
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    friends[a].add(b)
    friends[b].add(a)
#print(friends)
from collections import deque

reached = [-1] * N
ans = 1
for i in range(N):
    if reached[i] == -1:
        queue = deque()
        queue.append(i)
        t = 1
        reached[i] = 0
        while len(queue) > 0:
            v = queue.popleft()
            for n in friends.get(v):
                if reached[n] == -1:
                    reached[n] = 0
                    queue.append(n)
                    t += 1
    ans = max(ans, t)
print(ans)


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

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

	bool t = false;

	for (char x : N) {
		if (x == '7') {
			t = true;
			cout << "Yes" << endl;
			break;
		}
	}

	if (!t) cout << "No" << endl;
	return 0;
}

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

int main() {
  int n, q;
  cin >> n;
  int S[n];
  for (int i = 0; i < n; i++) {
    cin >> S[i];
  }
  cin >> q;
  int T[q];
  for (int i = 0; i < q; i++) {
    cin >> T[i];
  }

  int ans = 0;

  for (int i = 0; i < q; i++) {
    for (int j = 0; j < n; j++) {
      if (T[i] == S[j]) {
        ans++;
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
};



Measured memory_bytes: 3092
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End


/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template


signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cini(N);
    vector<int> a(N);
    rep(i,N) cin >> a[i];
    int max = 0,ans =0;
    rep(i,N){
        if(i==0){
            ans++;
            max = a[i];
            continue;
        }
        if(a[i]>=max){
            ans++;
            max=a[i];
        }
    }
    cout << ans << nn;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
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; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;

lint N, M, u, v, c;
lint dist[100][100];
vector<plint> edges;
lint cost[1000];

int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> N >> M;
	REP(i, N) REP(j, N) dist[i][j] = INF;
	REP(i, M) {
		cin >> u >> v >> c; u--; v--;
		dist[u][v] = c;
		dist[v][u] = c;
		edges.push_back({ u, v });
		cost[i] = c;
	}
	REP(i, N) dist[i][i] = 0;
	REP(k, N) {
		REP(i, N) {
			REP(j, N) {
				chmin(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}
	lint cnt = 0;
	REP(k, M) {
		bool flag = false;
		REP(i, N) {
			REP(j, N) {
				if (i == j) continue;
				u = edges[k].first; v = edges[k].second;
				if ((dist[i][u] + cost[k] + dist[v][j] == dist[i][j]) || (dist[i][v] + cost[k] + dist[u][j] == dist[i][j])) flag = true;
			}
		}
		if (flag) cnt++;
	}
	cout << M - cnt << endl;
}


Measured memory_bytes: 3748
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  int h, w;
  cin >> h >> w;
  string s[h];
  REP(i, h) { cin >> s[i]; }

  bool ans = true;
  REP(i, h) {
    REP(j, w) {
      if (s[i][j] == '.')
        continue;
      bool tmp = false;
      if (i > 0) {
        tmp = tmp || s[i - 1][j] == '#';
      }
      if (i < h - 1) {
        tmp = tmp || s[i + 1][j] == '#';
      }
      if (j > 0) {
        tmp = tmp || s[i][j - 1] == '#';
      }
      if (j < w - 1) {
        tmp = tmp || s[i][j + 1] == '#';
      }
      ans = ans && tmp;
    }
  }
  if (ans) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int a, b;
    scanf("%d", &a);
    scanf("%d", &b);
    if(a+b >= a-b && a+b >= a*b){
        printf("%d\n", a+b);
    }else if(a-b >= a+b && a-b >= a*b){
        printf("%d\n", a-b);
    }else if(a*b >= a+b && a*b >= a-b){
        printf("%d\n", a*b);
    }
    return 0;
}

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

using namespace std;

#define llong long long 
typedef pair<long int, int> P;
long int d[10001];
vector<P> edges[10001];
priority_queue<P, vector<P>, greater<P> > q;

void solve(){
	fill_n(d, 10001, 9999999);
	d[0] = 0;
	q.push(P(0,0));

	while(!q.empty()){
		P p = q.top(); q.pop();
		if(d[p.second] < p.first) continue;
		d[p.second] = p.first;

		for(int i = 0; i < edges[p.second].size(); i++){
			P e = edges[p.second][i];
			if(d[e.second] > p.first + e.first){
				d[e.second] = p.first + e.first;
				q.push(P(p.first + e.first, e.second));
			}
		}
	}

	return;
}

int main(){
	int N;
	cin >> N;
	for(int i = 0; i < N; i++){
		int num;
		int howedge;
		cin >> num >> howedge;
		for(int j = 0; j < howedge; j++){
			int to;
			long int cost;
			cin >> to >> cost;
			edges[num].push_back(P(cost, to));
		}
	}

	solve();

	for(int i = 0; i < N; i++){
		cout << i << " " << d[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 12156
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll n;
ll k;
ll h[100005];
ll dp[100005];
ll solve(int idx){
	if(idx == n-1) return 0;
	if(dp[idx]!=-1) return dp[idx];
	ll val = INT_MAX;
	for(int i = 1; i <= k; i++){
		if(idx + i<n){
			val = min(val, abs(h[idx] - h[idx+i]) + solve(idx +i));
		}
	}
	dp[idx] = val;
	return val;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	for(int i = 0; i < 100005; i++) dp[i] = -1;
	cin >> n >> k;
	for(int i = 0; i < n; i++) cin >> h[i];
	cout << solve(0);	
	return 0;
}


Measured memory_bytes: 8064
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <queue>

const int kN = 185 + 5;
int n, m;
char s[kN][kN];
int dp[kN][kN][kN];

int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++ i) {
    scanf("%s", s[i] + 1);
  }
  for (int i = 1; i <= n; ++ i) {
    for (int j = m; j >= 1; -- j) {
      dp[i][j][j] = s[i][j] == s[i - 1][j] ? dp[i - 1][j][j] + 1 : 1;
      for (int k = j + 1; k <= m; ++ k) {
        dp[i][j][k] = s[i][k] == s[i][k - 1] ? std::min(dp[i][j][k - 1], dp[i][j + 1][k]) : 0;
      }
    }
  }
  if (dp[n][1][m] == n) return puts("0"), 0;

  for (int depth = 1; ; ++ depth) {
    for (int i = n; i >= 1; -- i) {
      for (int j = 1; j <= m; ++ j) {
        std::vector<int> tmp(m + 1);
        for (int k = j + 1, p = j; k <= m; ++ k) {
          while (p + 2 < k && dp[i][j][p] > dp[i][p + 1][k] && dp[i][j][p + 1] > dp[i][p + 2][k]) {
            tmp[k] = std::max(tmp[k], dp[i][p + 1][k]);
            ++ p;
          }
          tmp[k] = std::max(tmp[k], std::min(dp[i][j][p], dp[i][p + 1][k]));
          if (p + 2 <= k) {
            tmp[k] = std::max(tmp[k], std::min(dp[i][j][p + 1], dp[i][p + 2][k]));
          }
        }
        for (int k = j; k <= m; ++ k) {
          dp[i][j][k] = std::max(dp[i - dp[i][j][k]][j][k] + dp[i][j][k], tmp[k]);
        }
      }
    }
    if (dp[n][1][m] == n) {
      printf("%d\n", depth);
      break;
    }
  }
}


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

int main() {
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    if (u == s) {
        a -= 1;
    }else {
        b -= 1;
    }
    cout << a << " " << b << endl;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let N: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let A: Vec<i64> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };

    fn bis<P: Fn(i64) -> bool>(ok: i64, ng: i64, p: P) -> i64 {
        let mid = (ok + ng) / 2;
        if (ok - ng).abs() == 1 {
            ok
        } else if p(mid) {
            bis(mid, ng, p)
        } else {
            bis(ok, mid, p)
        }
    }

    let mut acc = vec![0];
    for i in 0..N {
        let a = acc[i] + A[i];
        acc.push(a);
    }
    let ans = (2..(N - 1))
        .map(|i| {
            let (p, q) = {
                let k = bis(0, i as i64, |j| {
                    acc[j as usize] < acc[i as usize] - acc[j as usize]
                }) as usize;
                if std::cmp::max(acc[k], acc[i] - acc[k])
                    < std::cmp::max(acc[k + 1], acc[i] - acc[k + 1])
                {
                    (acc[k], acc[i] - acc[k])
                } else {
                    (acc[k + 1], acc[i] - acc[k + 1])
                }
            };
            let (r, s) = {
                let k = bis(i as i64, N as i64, |j| {
                    acc[j as usize] - acc[i as usize] < acc[N] - acc[j as usize]
                }) as usize;
                if std::cmp::max(acc[k] - acc[i], acc[N] - acc[k])
                    < std::cmp::max(acc[k + 1] - acc[i], acc[N] - acc[k + 1])
                {
                    (acc[k] - acc[i], acc[N] - acc[k])
                } else {
                    (acc[k + 1] - acc[i], acc[N] - acc[k + 1])
                }
            };
            *vec![p, q, r, s].iter().max().unwrap() - *vec![p, q, r, s].iter().min().unwrap()
        })
        .min()
        .unwrap();

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


Measured memory_bytes: 10492
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
A = [0] + readInts() + [0]
pa = 0
for i in range(n+1):
    pa += abs(A[i+1] - A[i])
#print(pa)
for i in range(n):
    print(pa - abs(A[i+1]-A[i]) - abs(A[i+2] - A[i+1]) + abs(A[i+2] - A[i]))


Measured memory_bytes: 22032
N = int(input())
A = list(map(int, input().split()))
A = [0] + A + [0]
all = 0
for i in range(len(A)-1):
    all += abs(A[i] - A[i+1])
for n in range(N):
    print(all - abs(A[n]-A[n+1]) - abs(A[n+1]-A[n+2]) + abs(A[n]-A[n+2]))


Measured memory_bytes: 14040
#include<stdio.h>
const int N = 105;
int main()
{
	int n;
	int a[N];
	
	scanf("%d", &n);
	for(int i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
	}
	for(int i = n - 1; i >= 1; i--)
	{
		printf("%d ", a[i]);
	}
	printf("%d\n", a[0]);
	
	
}


Measured memory_bytes: 2724
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  int a,b,c;cin>>a>>b>>c;
  int m=max(max(a,b),c);
  int d=a+b+c-m;
  string ans="No";
  if(d==m)ans="Yes";
  cout(ans);
  return 0;
}

Measured memory_bytes: 125568
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>
#include <iterator>
#include <regex>
#include <iomanip>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

template <class T, template <class, class> class C, class charT = char>
void vdump(const C<T, allocator<T>> &v, const charT* delimiter = ", ",
           ostream &stream = cout) {
  copy(v.begin(), v.end(), ostream_iterator<T>(stream, delimiter));
  stream << endl;
}

int main() {
  ios::sync_with_stdio(false);
  ll n, m, d;
  cin >> n >> m >> d;
  double x;
  if(d != 0) {
    x = 2.0 * (n - d) / (n * n);
  } else {
    x = 1.0 / n;
  }
  cout << setprecision(20) << x * (m - 1) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = (1LL << 30) - 1;
const ll LINF = (1LL << 60) - 1;
const double eps = 1e-9;
const ll MOD = 998244353LL;
template <typename T>
void chmin(T& a, T b) {
    a = min(a, b);
};
template <typename T>
void chmax(T& a, T b) {
    a = max(a, b);
};
template <typename T>
vector<T> make_v(size_t a) {
    return vector<T>(a);
}
template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) {
    for(auto& e : t) {
        fill_v(e, v);
    }
};
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(a == b && b == c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
// Problem : B - Multiple of 9
// Contest : AtCoder - AtCoder Beginner Contest 176
// URL : https://atcoder.jp/contests/abc176/tasks/abc176_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*ヽ｀、ヽ｀｀、ヽ｀ヽ｀、、ヽ ｀ヽ 、ヽ｀🌙｀ヽヽ｀ヽ、ヽ｀
ヽ｀、ヽ｀｀、ヽ 、｀｀、 ｀、ヽ｀ 、｀ ヽ｀ヽ、ヽ ｀、ヽ｀｀、
ヽ、｀｀、｀、ヽ｀｀、 、ヽヽ｀、｀、、ヽヽ、｀｀、 、 ヽ｀、
ヽ｀｀、 ヽ｀ヽ｀、、ヽ ｀ヽ 、 🚶ヽ｀｀｀｀ヽヽヽ｀、、ヽ｀、、ヽ*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long   ll;
typedef long double ld;
typedef complex< ld > cd;
 
typedef pair<int, int> pi;
typedef pair<ll, ll>   pl;
typedef pair<ld, ld>   pd;
 
typedef vector< int > vi;
typedef vector< ld >  vd;
typedef vector< ll >  vl;
typedef vector< pi >  vpi;
typedef vector< pl >  vpl;
typedef vector< cd >  vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a)    for (int i=0; i<(a); i++)
#define rep1(i, a, b) for (int i = (b)-1; i >= a; i--)
#define rep(i, a)     for (int i = (a)-1; i >= 0; i--)
#define trav(a, x)    for (auto& a : x)
#define uid(a, b)     uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f  first
#define s  second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	string s;
	cin>>s;
	ll sum=0;
	loop(i,sz(s))
	{
		sum+=s[i]-'0';
	}
	if(sum%9==0)
	cout<<"Yes"<<nl;
	else
	cout<<"No"<<nl;
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3788
import sys
# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, w = ns()
    d = []
    for _ in range(n):
        tmp = na()
        d.append(tmp)

    dp = [-1 for _ in range(w + 1)]
    dp[0] = 0

    for vi, wi in d:
        for i in range(w+1):
            if dp[i] > -1 and i + wi < w + 1:
                dp[i + wi] = max(dp[i + wi], dp[i] + vi)

    print(max(dp))


if __name__ == '__main__':
    main()



Measured memory_bytes: 7624
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let N: i32 = read();
    let mut X: Vec<i32> = Vec::new();
    let mut Y: Vec<i32> = Vec::new();
    let mut H: Vec<i32> = Vec::new();
    for _ in 0..N {
        X.push(read());
        Y.push(read());
        H.push(read());
    }

    'cx: for cx in 0..101 {
        'cy: for cy in 0..101 {
            let mut an = 2e9 as i32;
            for idx in 0..X.len() {
                let a = H[idx] + (X[idx]-cx).abs() + (Y[idx]-cy).abs();
                an = std::cmp::min(an, a);
            }
            if an <= 0 { continue; }
            for idx in 0..X.len() {
                let h_i = std::cmp::max(an - (X[idx]-cx).abs() - (Y[idx]-cy).abs(), 0);
                if h_i != H[idx] {
                    continue 'cy;
                }
            }
            println!("{} {} {}", cx, cy, an);
            break 'cx;
        }
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  cin.ignore(numeric_limits<streamsize>::max(), '\n');
  string str;
  cin >> str;
  int res = 0;
  for(int i = 0; i < n - 1; ++i){
    res += str[i] != str[i+1];    
  }
  std::cout << res + 1;
  return 0;
}

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

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);
    string s;
    cin >> s;
    for(char &c : s) {
        if(c == '1') c = '9';
        else if(c == '9') c = '1';
    }
    cout << s << endl;
}


Measured memory_bytes: 256