akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
using namespace std;

typedef pair<double,double> pdd;
#define x first
#define y second

double lagrange(double x, int deg, vector<pdd> pt, int skip) {
	double y = 0;
	for(int i = 0; i < deg+2; i++) {
		if(i == skip) continue;
		double t = 1;
		for(int j = 0; j < deg+2; j++) {
			if(j == i || j == skip) continue;
			t *= (x - pt[j].x) / (pt[i].x - pt[j].x);
		}
		t *= pt[i].y;
		y += t;
	}
	return y;
}

int main() {
	int d;
	while(cin >> d, d) {
		vector<pdd> pt(d+3);
		for(int i = 0; i < d+3; i++) {
			cin >> pt[i].y;
			pt[i].x = i;
		}

		int res = d+2;
		for(int i = 0; i < d+2; i++) {
			double y;
			y = lagrange(d+2, d, pt, i);
			if(fabs(y - pt.back().y) < 0.5) {
				res = i;
				break;
			}
		}
		cout << res << endl;
	}
}

Measured memory_bytes: 3056
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  int n,k,q; cin >> n >> k >> q;
  vector<int> a(q);
  for(int i = 0; i < q; i++){
    cin >> a[i];
    a[i]--;
  }

  vector<int> v(n,0);
  for(int i = 0; i < q; i++){
    v[a[i]]++;
  }
  for(int i = 0; i < n; i++){
    if(k - (q-v[i]) > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 2176
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    s = [SS() for _ in range(N)]

    ans = sum([i.count('AB') for i in s])

    # .*AとB.*をいくつくっつけられるか
    # .*AにB.*をくっつけた後、間にB.*Aを挟む方針 挟み方はどうでもいい
    tA = 0
    fB = 0
    fBtA = 0
    for i in s:
        if i[-1] == 'A' and i[0] == 'B':
            fBtA += 1
        elif i[-1] == 'A':
            tA += 1
        elif i[0] == 'B':
            fB += 1

    if tA == fB == 0:
        ans += max(fBtA - 1, 0)
    else:
        ans += min(tA, fB) + fBtA

    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10784
n,q=map(int,input().split())
s=" "+input()+" "
td=[input().split()for _ in[0]*q]
def test(x):
	for t,d in td:
		if s[x]==t:x+=1 if d=="R"else -1
	return x
def bs(b,g,t):
	while abs(b-g)>1:
		k=(b+g)//2
		if test(k)==t:g=k
		else:b=k
	return g
l=bs(n+1,0,0)
r=bs(0,n+1,n+1)
print(r-l-1)

Measured memory_bytes: 44468
import sys
import collections


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    s = str(readline().rstrip().decode('utf-8'))
    s = collections.Counter(s)
    t = 1
    for k, v in s.items():
        t *= (v + 1)
        t %= mod
    print(t - 1)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 39408
ABCD = input()

for i in range(2**3):
    ans = ABCD[0]
    num = int(ABCD[0])
    for j in range(3):
        if (i >>j & 1):
            ans = ans + '+' + ABCD[j+1]
            num = num + int(ABCD[j+1])
        else:
            ans = ans + '-' + ABCD[j+1]
            num = num - int(ABCD[j+1])
    if num == 7:
        print(ans + '=7')
        break

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define N (int)2e5
int n,k,a[N];
bool memo[N],vis[N];

bool dp(int rem) {
    if (rem == 0) return false;
    bool &sol = memo[rem];
    if (vis[rem]) return sol;
    vis[rem] = true;
    bool win = false;
    for (int i = 1 ; i <= n ; i++)
        if (rem >= a[i]) {
            bool DP = dp(rem - a[i]);
            if (!DP) win = true;
        }
    return sol = win;
}

int main() {
    scanf("%d%d" , &n , &k);
    for (int i = 1 ; i <= n ; i++)
        scanf("%d" , &a[i]);
    bool DP = dp(k);
    printf(DP ? "First\n" : "Second\n");
}


Measured memory_bytes: 6656
#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) a.begin(),a.end()
#define mp make_pair
#define mt make_tuple
#define INF 2000000000
#define INFL 1000000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<P> vP;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<P> > vvP;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<P, vector<P>, greater<P> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};

int N, M;
vvi G;

bool check(int s, int t, bool first = true) {
	if (!first) {
		rep(i, G[s].size()) {
			if (G[s][i] == t) {
				return true;
			}
		}
		return false;
	}
	bool ret = false;
	rep(i, G[s].size()) {
		if (check(G[s][i], t, false)) {
			ret = true;
		}
	}
	return ret;
}


int main() {
	cin >> N >> M;
	G = vvi(N);
	rep(i, M) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	if (check(0, N - 1)) {
		cout << "POSSIBLE" << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}

	return 0;
}

Measured memory_bytes: 12016
#include<stdio.h>
main()
{
	char i,s[2];
	int su=700;
	gets(s);	
	for (i=0;s[i]!='\0';i++)
	{
	if (s[i]=='o')
	su=su+100;	
	}
printf("%d", su);
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
	public static void main (String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int h = sc.nextInt();
    	int w = sc.nextInt();
    	int ch = sc.nextInt() - 1;
    	int cw = sc.nextInt() - 1;
    	int dh = sc.nextInt() - 1;
    	int dw = sc.nextInt() - 1;
    	char[][] field = new char[h][];
    	int[][] costs = new int[h][w];
    	for (int i = 0; i < h; i++) {
    	    field[i] = sc.next().toCharArray();
    	    Arrays.fill(costs[i], Integer.MAX_VALUE);
    	}
    	PriorityQueue<Path> queue = new PriorityQueue<>();
    	queue.add(new Path(ch, cw, 0));
    	while (queue.size() > 0) {
    	    Path p = queue.poll();
    	    if (costs[p.h][p.w] <= p.value) {
    	        continue;
    	    }
    	    costs[p.h][p.w] = p.value;
    	    for (int i = Math.max(p.h - 2, 0); i <= p.h + 2 && i < h; i++) {
    	        for (int j = Math.max(p.w - 2, 0); j <= p.w + 2 && j < w; j++) {
    	            if (field[i][j] == '#' || costs[i][j] != Integer.MAX_VALUE) {
    	                continue;
    	            }
    	            int next = p.value;
    	            if (Math.abs(p.h - i) + Math.abs(p.w - j) > 1) {
    	                next++;
    	            }
    	            Path np = new Path(i, j, next);
    	            queue.add(np);
    	        }
    	    }
    	}
    	if (costs[dh][dw] == Integer.MAX_VALUE) {
    	    System.out.println(-1);
    	} else {
    	    System.out.println(costs[dh][dw]);
    	}
    }
    
    static class Path implements Comparable<Path> {
        int h;
        int w;
        int value;
        
        public Path(int h, int w, int value) {
            this.h = h;
            this.w = w;
            this.value = value;
        }
        
        public int compareTo(Path another) {
            return value - another.value;
        }
        
        public String toString() {
            return h + ":" + w + ":" + value;
        }
    }
}



Measured memory_bytes: 66720
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

//macro
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define each(i, ctn) for (auto &&i : (ctn))
#define all(a) (a).begin(),(a).end()
#define EPS (1e-8)
#define equals(a,b)(fabs((a)-(b))<EPS)

using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;
//func
template<typename A, typename T>void assign2d(A&arr, ll H, ll W, T t) { arr.resize(H); REP(i, H) arr[i].assign(W, t); }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); REP(i, n)os << v[i] << (i == n - 1 ? "" : " "); return os; }
template <class T = int> inline T IN() { T x; cin >> x; return x; }
template<class T> inline void OUT(const T &x) { cout << x << "\n"; }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); /*cout << fixed << setprecision(12);*/ } } pre__;

int main(void) {
	int N;
	N = IN();
	set<int> s;
	REP(i, N) {
		int x;
		x = IN();
		s.insert(x);
	}
	OUT(s.size());

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	
	if(x>=r && x<=W-r && y>=r && y<=H-r){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	
	return 0;
}

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

typedef complex<double> C;

int solve(int N, vector<double>& x, vector<double>& y) {
    vector<C> point(N);

    for (int j = 0; j < N; ++j) {
        point[j] = C(x[j], y[j]);
    }

    int ret = 1;

    for (int j = 0; j < N; ++j) {
        for (int k = j+1; k < N; ++k) {
            C mid = (point[j] + point[k]) * 0.5;

            C normal = (point[j] - point[k]) * C(0, 1);
            normal /= abs(point[j] - point[k]);

            double a = sqrt(1 - norm(mid - point[j]));

            C centre1 = mid + a * normal;
            int count = 0;
            for (int l = 0; l < N; ++l) {
                if (abs(centre1 - point[l]) < 1.0 + 1e-9) {
                    ++count;
                }
            }
            ret = max(ret, count);

            C centre2 = mid - a * normal;
            count = 0;
            for (int l = 0; l < N; ++l) {
                if (abs(centre2 - point[l]) < 1.0 + 1e-9) {
                    ++count;
                }
            }
            ret = max(ret, count);

        }
    }

    return ret;
}

int main () {
    int N;
    vector<double> x, y;

    while (true) {
        cin >> N;
        if (N == 0) break;

        x.resize(N);
        y.resize(N);

        for (int j = 0; j < N; ++j) {
            cin >> x[j] >> y[j];
        }

        cout << solve(N, x, y) << endl;
    }

    return 0;
}

Measured memory_bytes: 1296
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long x = sc.nextLong();
    long a = (x/11)*2;
    if (x%11>6) a+=2;
    else if (x%11>0) a+=1;
    System.out.println(a);
  }
}

Measured memory_bytes: 21972
# coding: utf-8
N = int(input())
li = list(map(int, input().split()))
dp = [0, abs(li[0]-li[1])]

for i in range(N-2):
    dp.append(min(abs(li[i+1]-li[i+2])+dp[i+1], abs(li[i]-li[i+2])+dp[i]))

print(dp[-1])

Measured memory_bytes: 55528
#include<bits/stdc++.h>
using namespace std;
#define M 998244353
#define F first
#define S second
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
#define pb push_back
#define M6 6000009
#define M5 300009
#define pi 3.14159265
ll power(ll x,ll n){
    ll ret=1;
    x%=M;
    while(n>0){
        if(n&1) ret=(ret*x)%M;
        x=(x*x)%M;
        n/=2;
    }
    return ret;
}
struct my_data{
    int x,y,z;
};
ll prime[M6],sp[M6];
void sieve(){
    for(int i=1;i<M6;i++) prime[i]=1;
    for(ll i=2;i*i<M6;i++){
        if(!prime[i]) continue;
        for(ll j=i*2;j<M6;j+=i) {
            prime[j]=0;
            if(sp[j]==0) sp[j]=i;
        }
    }
    for(int i=1;i<M6;i++) if(!sp[i]) sp[i]=i;
}
ll n,m,ar[M5];
int  main()
{   //ios_base::sync_with_stdio (0), cin.tie (0);
    sieve();
    //init();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll tc=1,t=1,flag,i,j,k,l,p,q,ans,x,y,r,a,b,c;
    //cin>>tc;
    while(t<=tc){
        cin>>x>>y;
        cout<<(x+y/2);
        t++;
    }   
    return 0;
} 


Measured memory_bytes: 94464
//Longest Common Subsequence
#include <iostream>
#include <string>

using namespace std;

static const int N = 1000;

int lcs(string X, string Y) {
    int c[N + 1][N + 1] = {};
    int maxl = 0, m = int(X.size()), n = int(Y.size());
    X = X;
    Y = Y;
    for(int i = 0; i < m + 1; i++) c[i][m] = 0;
    for(int j = 0; j < n + 1; j++) c[n][j] = 0;
    for(int i = m - 1; i >= 0; i--) {
        for(int j = n - 1; j >= 0; j--) {
            if(X[i] == Y[j]) c[i][j] = 1 + c[i + 1][j + 1];
            else c[i][j] = max(c[i][j + 1], c[i + 1][j]);
        }
    }
    return c[0][0];

}

int main() {
    string s1, s2;
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> s1 >> s2;
        cout << lcs(s1, s2) << endl;
    }
}


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

void solve()
{
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    while(k>0&&b<=a)
    {
        b*=2;
        k--;
    }
    while(k>0&&c<=b)
    {
        c*=2;
        k--;
    }
    if(c>b && b>a)
        cout << "Yes\n";
    else cout << "No\n";
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    /*
    int t;
    cin >> t;
    while(t--)*/
       solve();
    
}


Measured memory_bytes: 3540
package main

import (
	"fmt"
)

func min(a int, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}

func main() {
	var A, B, C int
	fmt.Scan(&A, &B, &C)
	ans := B + min(A+B, C-1) + 1
	//fmt.Println(A, B, C)
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const ll INF=1e18;
const ll MOD=1e9+7;
const double pi=acos(-1);
ll modpow(ll a, ll n){
  if(n==0) return 1;
  if(n%2==0){
    ll t=modpow(a,n/2);
    return t*t%MOD;
  }
  return a*modpow(a,n-1)%MOD;
}
ll modinv(ll a){
  return modpow(a,MOD-2);
}
vector<pair<ll,ll>>prime_factorize(ll n){
  vector<pair<ll,ll>>res;
  for(ll p=2;p*p<=n;p++){
    if(n%p!=0)continue;
    ll num=0;
    while(n%p==0){
      num++;
      n/=p;
    }
    res.push_back(make_pair(p,num));
  }
  if(n!=1)res.push_back(make_pair(n,1));
  return res;
}
int main(){
  int n;
  cin >> n;
  vector<ll>a(n);
  map<ll,ll>mp;
  rep(i,n){
    cin >> a[i];
    auto pf=prime_factorize(a[i]);
    for(auto p:pf){
      mp[p.first]=max(mp[p.first],p.second);
    }
  }
  ll lcm=1;
  for(auto p:mp){
    rep(j,p.second){
      lcm*=p.first;
      lcm%=MOD;
    }
  }
  ll ans=0;
  rep(i,n){
    ans+=lcm*modinv(a[i]);
    ans%=MOD;
  }
  cout << ans%MOD << endl;
}

Measured memory_bytes: 896
#include <iostream>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int H, W;
    while (cin >> H >> W) {
        if (H == 0 && W == 0) {
            break;
        }
        for (int i=0; i<H; ++i) {
            for (int j=0; j<W; ++j) {
                cout << (i%2 == j%2 ? "#" : ".");
            }
            cout << "\n";
        }
        cout << "\n";
    }

    return 0;
}

Measured memory_bytes: 1176
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

typedef unsigned long long ull;
const int MAX_N = 50;
int N, K;

int x1[MAX_N], y1[MAX_N], d1[MAX_N], x2[MAX_N], y2[MAX_N], d2[MAX_N];

int countKind(int x, int y, int d){
	int ans = 0;
	x++; y++; d++;
	for(int i=0; i<N; i++){
		if(x1[i]<=x && x<=x2[i] && y1[i]<=y && y<=y2[i] && d1[i]<=d && d<=d2[i]) ans ++;
	}
	return ans;
}

using namespace std;

int main(){
	ull v = 0;
	cin >> N >> K;

	vector<int> X(2*N), Y(2*N), D(2*N);

	for(int i=0; i<N; i++){
		cin >> x1[i] >> y1[i] >> d1[i] >> x2[i] >> y2[i] >> d2[i];
		X[i]   = x1[i];
		X[i+N] = x2[i];
		Y[i]   = y1[i];
		Y[i+N] = y2[i];
		D[i]   = d1[i];
		D[i+N] = d2[i];
	}

	sort(X.begin(), X.end());
	sort(Y.begin(), Y.end());
	sort(D.begin(), D.end());

	for(int i=0; i<2*N-1; i++){
	for(int j=0; j<2*N-1; j++){
	for(int k=0; k<2*N-1; k++){
		v += (countKind(X[i], Y[j], D[k]) >= K ? (ull)(X[i+1]-X[i]) * (Y[j+1]-Y[j]) * (D[k+1]-D[k]) : 0);
	}}}

	printf("%llu\n", v);
	return 0;
}

Measured memory_bytes: 1204
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()
a = abs(int(S[0])*100 + int(S[1])*10 + int(S[2]) - 753)

for i in range(1, len(S)-2):
	b = abs(int(S[i])*100 + int(S[i+1])*10 + int(S[i+2]) - 753)
	a = min(a, b)

print(a)

Measured memory_bytes: 5196
/*
 * @Author: clorf 
 * @Date: 2020-08-29 17:07:51 
 * @Last Modified by: clorf
 * @Last Modified time: 2020-08-29 17:31:41
 */
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<ctime>
#define INF 1e9
using namespace std;
const int maxn=100010;
const double Pi=acos(-1.0);
template<class T>void read(T &x)
{
    x=0;int f=0;char ch=getchar();
    while(ch<'0'||ch>'9') {f|=(ch=='-');ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
    x=f?-x:x;
    return;
}
int n,ans,fa[maxn],cnt;
struct city
{
    int x;
    int y;
    int id;
}e[maxn];
struct edge
{
    int x;
    int y;
    int z;
}s[maxn];
bool cmp(edge a,edge b)
{
    return a.z<b.z;
}
inline int dis(int a,int b,int c,int d)
{
    return min(abs(a-c),abs(b-d));
} 
inline bool cmp1(city a,city b)
{
    return a.x<b.x;
}
inline bool cmp2(city a,city b)
{
    return a.y<b.y;
}
int getfa(int x)
{
    if(fa[x]==x)
        return x;
    return fa[x]=getfa(fa[x]);

}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d",&e[i].x,&e[i].y);
        e[i].id=i;
    }
    for(int i=1;i<=n;i++)
        fa[i]=i;
    sort(e+1,e+n+1,cmp1);
    for(int i=2;i<=n;i++)
        s[++cnt]=(edge){e[i].id,e[i-1].id,abs(e[i].x-e[i-1].x)};
    sort(e+1,e+n+1,cmp2);
    for(int i=2;i<=n;i++)
        s[++cnt]=(edge){e[i].id,e[i-1].id,abs(e[i].y-e[i-1].y)};
    sort(s+1,s+cnt+1,cmp);
    for(int i=1;i<=cnt;i++)
    {
        int x=getfa(s[i].x);
        int y=getfa(s[i].y);
        if(x!=y)
        {
            fa[x]=y;
            ans+=s[i].z;
        }
    }
    printf("%d",ans);
    return 0;
}

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

#define ll          long long
#define pb          push_back
#define endl        '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define INF         (1ll<<60)
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N=100005;
bool check(string s){
    ll i=0,j=sz(s)-1;
    while(i<=j && s[i]==s[j]){
        i++;
        j--;
    }
    if(i>j) return 1;
    return 0;
}
void solve(){
    string s;
    cin>>s;
    ll n=sz(s);
    ll poss=1;
    if(!check(s)) poss=0;
    if(!check(s.substr(0,(n-1)/2))) poss=0;
    if(!check(s.substr((n+3)/2-1,n))) poss=0;
    if(poss) cout<<"Yes";
    else cout<<"No";
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    time
    return 0;
}

Measured memory_bytes: 256
// 未解決

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

#define EACH(i, a) for (auto &&i : a)
#define FOR(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RFOR(i, a, b) for (int i = (int)b - 1; i >= (int)a; --i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREPS(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(x) (x).begin(), (x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define debug(x) cout << #x << ": " << x << endl

#define pb push_back
#define mp make_pair
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define INF (1L << 30)
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

template <class T>
void pv(T a, T b) {
  for (T i = a; i != b; ++i) cout << *i << " ";
  cout << endl;
}
template <class T>
void pvp(T a, T b) {
  for (T i = a; i != b; ++i)
    cout << "(" << i->first << ", " << i->second << ") ";
  cout << endl;
}
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;
}
int in() {
  int x;
  scanf("%d", &x);
  return x;
}

using ll = long long;
#define int ll

//**********

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

  int n;
  cin >> n;
  cout << pow(n, 2) << endl;

  return 0;
};


Measured memory_bytes: 256
/**
 * Created by karayuu on 2018/10/06
 */
fun main(args: Array<String>) {
    val checkList = listOf('a', 'e', 'i', 'o', 'u')

    val c = readLine()!!.toCharArray().first()
    
    if (checkList.contains(c)) {
        println("vowel")
    } else {
        println("consonant")
    }
}


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


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

  long G;
  cin >> G;
  int ans = 0;
  int p[D], c[D];
  for(int i=0;i<D;i++){
    cin >> p[i] >> c[i];
    ans += p[i];
  }

  // cout << D << endl;

  for(int i=0;i<(1<<D);i++){
    int sum = 0;
    int count = 0;
    // cout << "i " << i << endl;
    for(int j=0;j<D;j++){
      sum += (100*(j+1)*p[j]+c[j])*((i>>(D-1-j))&1);
      count += p[j]*((i>>(D-1-j))&1);
      // cout << "count" << count << endl;
      // cout << "j " << j << endl;
      // cout << "pj " << p[j] << endl;
    }
    // cout << sum << endl;

    // cout << "count" << count << endl;

    if(sum >= G){
      ans = min(ans, count);
      continue;
    }

    int temp = i;
    int na = -1;
    for(int j=0;j<D;j++){
      if(!(temp&0b1)){
        na = j;
        break;
      }
      // cout << " temp " << temp << endl ;
      temp >>= 1;
    }

    // cout << "na " << na << endl;

    if(na < 0) continue;

    for(int j=0;j<p[D-1-na]-1;j++){
      sum += (100*(D-na));
      count++;
      // cout << "j " << j << endl;
      // cout << "sum " << sum << endl;
      if(sum >= G){
        // cout << "counthoge" << count << endl;
        ans = min(ans,count);
        break;
      }
    }

  }


  cout << ans << endl;

}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    void solve() {
        Int N, K;
        cin >> N >> K;
        vector<Int> A(N);
        for (int i = 0; i < N; ++i) {
            cin >> A[i];
        }
        vector<Int> B;
        B.push_back(0);
        for (int i = 0; i < N; ++i) {
            B.push_back(B.back() + A[i]);
        }
        for (int i = 0; i <= N; ++i) {
            B[i] -= i;
            B[i] %= K;
            if (B[i] < 0) B[i] += K;
        }

        Int ans = 0;
        map<Int, Int> mp;
        queue<Int> que;
        for (int i = N; i >= 0; --i) {
//            Int tmp = mp[B[i]];
//            cerr << tmp << endl;

            ans += mp[B[i]];
            mp[B[i]]++;
            que.push(B[i]);

            while (que.size() >= K) {
                mp[que.front()]--;
                que.pop();
            }
        }

        cout << ans << endl;

    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 17520
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9; //1(1倍)e(指数)9(10^9)
int main()
{
    string s;
    cin >> s;
    int n = s.size();
    int ans = inf;
    for(int i = 0; i < n - 2; i++) {
        int temp = abs((s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + (s[i + 2] - '0') - 753);
        ans = min(ans, temp);
    }
    printf("%d\n", ans);
    return 0;
}

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

#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define pf push_front
#define pof pop_front
#define pob pop_back
#define ull unsigned long long
#define ll long long
#define sz(a) a.size()
#define all(s) s.begin(), s.end()
#define rall(s, n) s, s + n
#define x first
#define y second
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define pii pair <int, int>
#define pll pair <ll, ll>
#define INF 1000000000
#define mod 1000000007
#define reset(a, nilai) memset(a, nilai, sizeof(a))
using namespace std;

int a, b, c;
int main () {
	IOS;

	cin >> a >> b >> c;
	swap(a, b);
	swap(a, c);
	cout << a << ' ' << b << ' ' << c << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
#define mod 1000000007
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int row, col;
	cin >> row >> col;
	char mat[row][col];
	for (int r = 0; r < row; r++)
	{
		for (int c = 0; c < col; c++)
		{
			cin >> mat[r][c];
		}
	}
	int dp[row][col];
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;

	for (int c = 1; c < col; c++)
	{
		if (mat[0][c] == '#')break;

		dp[0][c] = 1;
	}

	for (int r = 1; r < row; r++)
	{
		if (mat[r][0] == '#')break;

		dp[r][0] = 1;
	}

	for (int r = 1; r < row; r++)
	{
		for (int c = 1; c < col; c++)
		{
			if (mat[r][c] == '#')continue;

			if (mat[r - 1][c] != '#')
			{
				dp[r][c] = dp[r - 1][c];
			}
			if (mat[r][c - 1] != '#')
			{
				dp[r][c] = (dp[r][c]%mod + dp[r][c - 1]%mod)%mod;
			}
		}
	}

	cout << dp[row-1][col-1];
	return 0;
}

Measured memory_bytes: 9088
#include <stdio.h>
int main(void){
    // Here your code !
    int i,n;
    int a,b,c;
    int work;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d %d %d",&a,&b,&c);
        if(a > b){
            work = b;
            b = a;
            a = work;
        }
        if(b > c){
            work = c;
            c = b;
            b = work;
        }
        if(a*a+b*b == c*c)  printf("YES\n");
        else                printf("NO\n");
    }
    return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
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());
    int l = a[0];
    int h = a[n-1];
    int num = h-l;
    if(num > 1)
    {
        cout << "No" << endl;
    }
    else if(num == 1)
    {
        int lc = 0;
        for(int i = 0; i < n; i++)
        {
            if(a[i] == l) lc++;
        }
        int hc = n - lc;
        if(l < lc || l > lc - 1 + hc / 2 || h > hc/2 + l || h < lc)
        {
            cout << "No" << endl;
        }
        else cout << "Yes" << endl;
    }
    else
    {
        int cand = n / 2;
        if(l <= cand || l == n-1)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 640
import copy
K = int(input())
# N, K = [int(_) for _ in input().split()]
L = [str(i) for i in range(1, 10)]
a = [str(i) for i in range(1, 10)]
for i in range(10):
    new_l = []
    for l in L:
        if l[-1] == '0':
            new_l.append(l + l[-1])
            new_l.append(l + str(int(l[-1]) + 1))
        elif l[-1] == '9':
            new_l.append(l + l[-1])
            new_l.append(l + str(int(l[-1]) - 1))
        else:
            new_l.append(l + l[-1])
            new_l.append(l + str(int(l[-1]) + 1))
            new_l.append(l + str(int(l[-1]) - 1))
    a.extend(new_l)
    L = copy.deepcopy(new_l)

a_int = [int(x) for x in a]
a_int.sort()
print(a_int[K-1])


Measured memory_bytes: 81852
#include <bits/stdc++.h>
#define REP(i, n) for (int i=0, i##_len=(n); i<i##_len; ++i)
#define FOR(i, a, b) for (int i=(a); i<(b); ++i)
using ll = long long;
using namespace std;

#define IS_OK(s) ((s) == '1')

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

    vector<pair<bool, int>> reps;
    pair<bool, int> rep = make_pair(IS_OK(S[0]), 1);
    FOR(i, 1, N)
    {
        if (IS_OK(S[i]) == rep.first) ++rep.second;
        else
        {
            reps.push_back(rep);
            rep = make_pair(IS_OK(S[i]), 1);
        }
    }
    reps.push_back(rep);
    if (reps[0].first) reps.insert(reps.begin(), make_pair(false, 0));
    if (!reps.back().first) reps.push_back(make_pair(true, 0));

    int n = reps.size();
    int sums[n];
    sums[0] = reps[0].second;
    FOR(i, 1, n) sums[i] = sums[i-1] + reps[i].second;

    int ret = 0;
    for (int i=0; i<n; i+=2)
    {
        int sum = sums[min(n-1, i+K*2-1)] - (i < 2 ? 0 : sums[i-2]);
        ret = max(ret, sum);
    }

    cout << ret << endl;
    return 0;
}


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

int main() {
	int n,x;
	cin >> n >> x;
	vector<int> dist;
	for (int i = 0; i < n; ++i) {
		int xi;
		cin >> xi;
		dist.push_back(abs(xi-x));
	}
	sort(dist.begin(), dist.end());
	int div = dist[0];
	while (div > 1) {
		bool flag = true;
		for (int val : dist) {
			if (val % div != 0) {
				flag = false;
				break;
			}
		}
		if (flag)break;
		else div--;
	}
	cout << div;
	return 0;
}


Measured memory_bytes: 892
#include<iostream>
#include<map>
using namespace std;
     
int main(){
  while(true){
    int n = 0;
    cin >> n;
    if(n == 0){
      break;
    }
    map<char, char> convert;
    for(int i = 0; i < n; i++){
      char key, value;
      cin >> key; cin >> value;
      convert[key] = value;
    }
    int m = 0;
    cin >> m;
    for(int i = 0; i < m; i++){
      char val;
      cin >> val;
      if(convert.find(val) != convert.end()){
        cout << convert[val];
      }else{
        cout << val;
      }
    }
    cout << '\n';
  }
  return 0;
}

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

int main(void){
    int a = 0, b = 0; 

    scanf("%d%d", &a, &b);

    if(a * b % 2 == 0){
        printf("Even\n");
    }else{
        printf("Odd\n");
    }

    return 0;

} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define divceil(A, B) ((A + (B - 1)) / B)
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

using namespace std;

int main(){

    int n;
    cin >> n;
    vector<double> p;

    rep(i,n){
        double tmp;
        cin >> tmp;
        p.pback(tmp);
    }

    vector<vector<double>> dp(3000, vector<double>(5999));

    dp[0][2999] = 1.0;

    for(int i = 0; i < n; i++){
        for(int j = 1; j <= 5997; j++){
            dp[i + 1][j - 1] += dp[i][j] * p[i];
            dp[i + 1][j + 1] += dp[i][j] * (1.0 - p[i]);
        }
    }

    double ans = 0.0;

    for(int i = 0; i <= 2998; i++){
        ans += dp[n][i];
    }

    cout << setprecision(12) << ans << endl;

    return 0;
}

Measured memory_bytes: 141056
N = int(input())
rateBtcYen =  380000.0 
totalYen = 0
for i in range(0, N):
    amountString, currency = input().split()
    amount = float(amountString)
    if currency == "BTC":
        totalYen += amount*rateBtcYen
    else:
        totalYen += amount
print(totalYen)

Measured memory_bytes: 2940
L=int(input())
A=[int(input()) for _ in range(L)]
dp=[0 for _ in range(5)]

for a in A:
    back = a%2 if a>0 else 2
    through = (a+1)%2

    dp[4] = min(dp[0:5]) + a
    dp[3] = min(dp[0:4]) + back
    dp[2] = min(dp[0:3]) + through
    dp[1] = min(dp[0:2]) + back
    dp[0] = dp[0]+a

print(min(dp))

Measured memory_bytes: 11040
// myfirstatcoder.cpp : アプリケーションのエントリ ポイントを定義します。

#include "bits/stdc++.h"
#define rep(i,cc,n) for(int i=cc;i<(n);++i)
#define drep(i,cc,n) for(int i=cc;i>(n);--i)
#define llrep(i,cc,n) for(long long i=cc;i<(n);++i)
using namespace std;
using ll = long long;

int main()
{
	int a, b, c, k,count=0;
	cin >> a >> b >> c >> k;
	int f = 0,i;
	if (k > a)
	{
		count += a;
		k -= a;
	}
	else
	{
		count = k;
		cout << count << endl;
		return 0;
	}
	k -= b;
	if (k > c)
	{
		count -= c;
	}
	else
	{
		count -= k;
		cout << count << endl;
		return 0;
	}
	cout << count << endl;
}

/*
ライブラリ
・string -- string.length()
・vector<int>
::::vector<vector<int>> A(N,vector<int>(M));
::::A[i][j] = i;
・map<string,int>

関数
・gcd(int, int) … 最大公約数 int
・find_string(str, str) … 文字列検索 bool
*/

Measured memory_bytes: 3636
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
//#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
//const long long MOD = 1000000007;
const long long MOD = 998244353;

using namespace std;

char str[1000005];

void solve()
{
    int n;
    scanf("%d", &n);
    vector<pair<int, int> > z[2];
    ll sa = 0;
    int i,j;
    for (i = 0; i < n; i++) {
        scanf("%s", str);
        int len = strlen(str);
        int cnt = 0;
        int min = 0;
        for (j = 0; j < len; j++) {
            if (str[j] == '(') {
                cnt++;
            }
            else {
                cnt--;
            }
            min = MIN(min, cnt);
        }
        sa += cnt;
        if (cnt >= 0) z[0].push_back(make_pair(min, cnt));
        else          z[1].push_back(make_pair(min - cnt, -cnt));
    }
    if (sa != 0) {
        printf("No\n"); return;
    }
    sort(z[0].rbegin(), z[0].rend());
    sort(z[1].rbegin(), z[1].rend());

    int k;
    for (k = 0; k < 2; k++) {
        int saa = 0;
        for (i = 0; i <(int)z[k].size(); i++) {
            int bb = z[k][i].first;
            int aa = z[k][i].second;
            if (aa < 0) {
                break;
            }
            if (saa + bb < 0) {
                printf("No\n"); return;
            }
            saa += aa;
        }
    }
    printf("Yes\n");

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 10676
/*
   AUTHOR :- Gaurang_Kothiya
   
   Quote:-" Great things never come from comfort zones."                                                                                                                
*/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>  
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
#include <bitset>
#include <cstdint>
#include <initializer_list>
 
using namespace std;
using namespace __gnu_pbds;  

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> data_set; 
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long  
#define ld long double
#define f(i,x,n) for(int i=x;i<=n;++i)
#define fe(x,v)   for(auto &x :v)
#define nf(i,x,n) for(int i=n;i>=x;--i)
#define all(a)   a.begin(),a.end()
#define rall(a)  a.rbegin(),a.rend()
#define b_s(a,b)   binary_search( all(a),b)
#define lb(v,n)  lower_bound(all(v) ,n )
#define ub(v,n)  upper_bound( all(v) , n)
#define gcd(a,b) __gcd(a,b)
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define RE rend()
#define RB rbegin()
#define B begin()
#define E end()
#define acc(v, x) accumulate(all(v), x)
#define p(a,b) pair<a,b>
#define F first
#define S second
#define sz size()
#define v(x) vector<x>
#define m(a,b) map<a,b>
#define u_m(a,b) unordered_map<a,b>
#define mm(a,b) multimap<a,b>
#define s(a) set<a>
#define us(a) unordered_set<a>
#define ms(a) multiset<a>
#define maxy __LONG_LONG_MAX__
#define miny INT_MIN
#define PI 3.14159265358979323846
#define MOD 998244353




void Solve()
{	
	ll a,b;
	cin>>a>>b;
	
	if(b>=a)cout<<"unsafe";
	else cout<<"safe";
			
}

signed main() 
{
	speed		
	
	int q=1;
	//cin>>q;
	
	while(q--)
	Solve();
	
	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}

 
 

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

const int MAX_N = 1000000;
const int INF = 1000000000;

int dp_nat[MAX_N]; // dp_nat[i]: 数字iを作るための最小の正四面体の個数
int dp_odd[MAX_N]; // dp_odd[i]: 数字iを作るための最小の奇数の正四面体の個数

int tetras[10000]; // tetras[i]: i番目の正四面体数(添え字は1から始まる)
int num_tetras = 0;

int main() {
  // 正四面体数を事前に計算しておく
  for(int i = 1; 1; i++) {
    int m = i*(i+1)*(i+2)/6;
    if (m > MAX_N) break;
    num_tetras++; // 配列は1始まりなので先にインクリメント
    tetras[num_tetras] = m;
  }

  // 入力のnによらずdp_natとdp_oddの中身は同じになるので、入力を読む前に計算しておく

  // 全ての正四面体数を使ったパターン
  dp_nat[0] = 0;
  for (int i = 1; i < MAX_N; i++) {
    dp_nat[i] = INF;
    for (int j = 1; j <= num_tetras; j++) {
//    cout << "dbg" << i << "," << dp_nat[i] << endl;
      if (i - tetras[j] < 0) break;
      dp_nat[i] = min(dp_nat[i], dp_nat[i - tetras[j]] + 1);
    }
  }

  // 奇数のみのパターン
  dp_odd[0] = 0;
  for (int i = 1; i < MAX_N; i++) {
    dp_odd[i] = INF;
    for (int j = 1; j <= num_tetras; j++) {
      if (i - tetras[j] < 0) break;
      if (tetras[j] % 2 != 0)
        dp_odd[i] = min(dp_odd[i], dp_odd[i - tetras[j]] + 1);
    }
  }

  int n;
  while(cin >> n, n != 0) {
    cout << dp_nat[n] << " " << dp_odd[n] << endl;
  }
  return 0;
}

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

int a, b, c, d;
string res = "No";

int main(){
  cin >> a >> b >> c >> d;
  if(abs(c - a) <= d){
    res = "Yes";
  }
  if(abs(b - a) <= d && abs(c - b) <= d){
    res = "Yes";
  }
  cout << res << endl;
  return 0;
}


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

int main(){
  int n, x, y;
  cin >> n >> x >> y;
  vector<vector<int>> M(n);
  for(int i = 0; i < n; i++){
    if(i < n-1) M.at(i).push_back(i+1);
    if(i > 0) M.at(i).push_back(i-1);
  }
  M.at(x-1).push_back(y-1); M.at(y-1).push_back(x-1);
  
  vector<int> ans(n,0);
  for(int i = 0; i < n; i++){
    vector<int> dist(n,-1);
    queue<int> que;
  
    dist.at(i) = 0;
    que.push(i);
  
    while(!que.empty()){
      int v = que.front(); que.pop();
      for(int nv : M.at(v)){
        if(dist.at(nv) != -1) continue;
        dist.at(nv) = dist.at(v) + 1;
        que.push(nv);
      }
    }
    for(int i = 0; i < n; i++) ans.at(dist.at(i))++;
  }
  
  for(int i = 1; i < n; i++) cout << ans.at(i)/2 << endl;
  return 0;
}

Measured memory_bytes: 3712
n = int(input())
a = list(map(str, input().split()))

d = {}
t = 0
for i in a:
    if not i in d.keys():
        d[i] = 1
    else:
        d[i] += 1
    t += int(i)

q = int(input())

for _ in range(q):
    b, c = map(str, input().split())
    diff = 0
    if b in d.keys() and c in d.keys():
        diff = (int(c) - int(b)) * d[b]
        d[c] += d[b]
        d.pop(b)
    elif b in d.keys():
        diff = int(c) * d[b] - int(b) * d[b]
        d[c] = d[b]
        d.pop(b)
    t += diff
    print(t)
    

Measured memory_bytes: 22824
#include <iostream>

#include <algorithm>
#include <cmath>
#include<string>
#include<array>
#include<vector>
#include<functional>
#include<unordered_map>
#include<map>
#include<numeric>
#include<limits>
#include<utility>
#include<queue>
#include<random>

using namespace std;
typedef long long LL;

int main() {
	int a;
	string O, E,str;
	LL N,ans=0;

	cin >> O >> E;

	int size = 0;

    //size= max(O.size(), E.size());

	for (int i = 0; i < O.size(); i++) {
		
			str.push_back(O[i]);

			if (i < E.size()) {
				str.push_back(E[i]);
			}
		}

	

	cout << str << endl;
	//cin >> a;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#define ll long long

using namespace std;
typedef pair<int, int> P;

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int red = 0;
    for (auto i : s)
    {
        if (i == 'R')
        {
            red++;
        }
    }
    int w = 0;
    int r = 0;
    for (int i = 0; i < red; i++)
    {
        if (s[i] == 'W')
        {
            w++;
        }
    }
    for (int i = red; i < s.length(); i++)
    {
        if (s[i] == 'R')
        {
            r++;
        }
    }
    cout << max(r, w) << endl;
    return 0;
}

Measured memory_bytes: 3744
#include<iostream>
#include<iomanip>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i, a, b) for(int i = (a);i < (b);++i)
#define FORR(i, b, a) for (int i = (b) - 1;i >= 0;--i)
#define REP(i, n) for(int i = 0;i < (n);++i)
#define REPR(i, n) for(int i = (n) - 1;i >= 0;--i)
#define ITER(itr, v) for(auto itr = v.begin();itr != v.end();++itr)
#define SORT(v) sort(v.begin(), v.end())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


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

	ll N;
	cin >> N;
	ll res = 0;
	if (N % 2 == 0) {
		for (ll i = 10;i <= N;i *= 5) {
			res += N / i;
		}
	}
	
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int mod = 1000000007;

long long dp[101][5][5][5];

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

  dp[0][0][0][0] = 1;

  for (int p = 0; p < n; p++) {
    for (int i = 0; i < 5; i++) {
      for (int j = 0; j < 5; j++) {
        for (int k = 0; k < 5; k++) {
          if (dp[p][i][j][k] == 0) continue;
          for (int q = 1; q < 5; q++) {
            if (j == 1 && k == 3 && q == 2) continue;
            if (j == 3 && k == 1 && q == 2) continue;
            if (j == 1 && k == 2 && q == 3) continue;
            if (i == 1 && k == 3 && q == 2) continue;
            if (i == 1 && j == 3 && q == 2) continue;
            dp[p + 1][j][k][q] += dp[p][i][j][k];
            dp[p + 1][j][k][q] %= mod;
          }
        }
      }
    }
  }

  long long ans = 0;

  for (int i = 0; i < 5; i++) {
    for (int j = 0; j < 5; j++) {
      for (int k = 0; k < 5; k++) {
        ans += dp[n][i][j][k];
        ans %= mod;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <algorithm>

#define SIZE 3*100000

using namespace std;

int digitSum(int);

int main(int argc, char const *argv[])
{
    string s;
    cin >> s;
    int dic[26] = {};
    for(int i=0; i<s.length(); i++){
        int idx = s[i] - 'a';
        dic[idx] = 1;
    }
    for(int i=0; i<26; i++){
        if(!dic[i]){
            cout << (char)(i+'a');
            return 0;
        }
    }
    cout << "None";
    return 0;
}

int digitSum(int a){
    if(a==0){
        return 0;
    }
    return a%10 +digitSum(a/10);
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
const long double eps = 1e-10;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n; cin >> n;
    VL a(n); cin >> a;
    VI bit(60);
    FOR(i, 0, n)FOR(j, 0, 60) {
        if (a[i] & (1LL << j))++bit[j];
    }

    ll ans = 0;
    FOR(i, 0, n)FOR(j, 0, 60) {
        if (a[i] & (1LL << j)) {
            (ans += ((1LL << j) % mod) *ll(n - bit[j])) %= mod;
        }
    }

    cout << ans << "\n";
}


Measured memory_bytes: 2560