akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;

#define A first
#define B second

string s;
int ct[3];

int main() {
	cin >> s;
	for (int i = 0; i < s.length(); ++i)
		ct[s[i] - 'a']++;
	if (abs(ct[0] - ct[1]) > 1) {
		cout << "NO\n";
		return 0;
	} if (abs(ct[1] - ct[2]) > 1) {
		cout << "NO\n";
		return 0;
	} if (abs(ct[0] - ct[2]) > 1) {
		cout << "NO\n";
		return 0;
	}

	cout << "YES\n";
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
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;}

int main() {
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll tmp1 = a*c;
    ll tmp2 = a*d;
    ll tmp3 = b*c;
    ll tmp4 = b*d;
    ll ans = max({tmp1,tmp2,tmp3,tmp4});
    cout << ans << endl;
}

Measured memory_bytes: 3636
struct Scanner {
    handle: std::io::Stdin,
    buffer: std::collections::VecDeque<String>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner {
            handle: std::io::stdin(),
            buffer: std::collections::VecDeque::new(),
        }
    }
    fn next<T: std::str::FromStr>(&mut self) -> Result<T, T::Err> {
        if self.buffer.len() == 0 {
            loop {
                let mut available = String::new();
                self.handle.read_line(&mut available).unwrap();
                self.buffer = available.split_whitespace().map(String::from).collect();
                if self.buffer.len() > 0 {
                    break;
                }
            }
        }
        T::from_str(&self.buffer.pop_front().unwrap())
    }
}

fn main() {
    let mut scanner = Scanner::new();
    let n: usize = scanner.next().unwrap();
    let mut av = Vec::<i32>::new();
    let mut bv = Vec::<i32>::new();
    for _ in 0..n {
        av.push(scanner.next().unwrap());
        bv.push(scanner.next().unwrap());
    }
    av.sort();
	bv.sort();
	#[cfg(debug_assertions)] dbg!(&av, &bv);
    let total = if n % 2 == 1 {
        let min = av[(n - 1) / 2];
        let max = bv[(n - 1) / 2];
        max - (min - 1)
    } else {
        let min = av[(n - 1) / 2] + av[n / 2];
        let max = bv[(n - 1) / 2] + bv[n / 2];
        max - (min - 1)
    };
    println!("{}", total);
}


Measured memory_bytes: 4040
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define ARRAY_LENGTH(array) sizeof(array)/sizeof(*array)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1000100100;

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

    cout << S;
    if(S[S.length() - 1] != 's') {
        cout << 's';
    } else {
        cout << "es";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll COM(ll n, ll k){
    ll res = 1;
    Rep(i, n-k+1, n+1) res = res * i % MOD;
    res = res * finv[k] % MOD;
    return res;
}

ll binarypow(ll a, ll n, ll mod) {
  ll res = 1;
  while(n > 0) {
    if(n & 1) {
      res *= a;
      res %= mod;
    }
    a *= a;
    a %= mod;
    n >>= 1;
  }
  return res;
}

int main() {
    COMinit();
    ll n, a, b; cin >> n >> a >> b;
    ll ans = binarypow(2, n, MOD) - 1;
    if(ans < 0) ans += MOD;
    (ans -= COM(n, a)) %= MOD;
    if(ans < 0) ans += MOD;
    (ans -= COM(n, b)) %= MOD;
    if(ans < 0) ans += MOD;
    cout << ans << endl;
}

Measured memory_bytes: 15552
#include<cstdio>
#include<algorithm>
#include<functional>

using namespace std;
int main(void)
{
	long long int a[100000],i,n,w,x,y;
	scanf("%lld",&n);
	for(i=0;i<n;i++) scanf("%lld",&a[i]);
	sort(a,a+n,greater<int>());
	x=0; y=0;
	for(i=0;i<n;i++){
		if(x==0){
			if(a[i]==a[i+1]){
				x=a[i]; i++;
			}
		}
		else{
			if(a[i]==a[i+1]){
				y=a[i]; break;
			}
		}
	}
	if(y==0) printf("0\n");
	else printf("%lld\n",x*y);	
	return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  
  int c;
  c = a + b;
  if(c%2 == 0){
    cout << c/2 << endl;
  }else{
    cout << (c+1)/2 << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    string S, T;
    cin >> S;

    int N = S.size();

    bool f = true;

    T = S;
    reverse(T.begin(), T.end());
    if (S != T) f = false;

    string S2, T2;
    S2 = string(S.begin(), S.begin() + (N - 1) / 2);
    T2 = S2;
    reverse(T2.begin(), T2.end());
    if (S2 != T2) f = false;

    string S3 = string(S.begin() + (N + 3) / 2 - 1, S.end());
    string T3 = S3;
    reverse(T3.begin(), T3.end());
    if (S3 != T3) f = false;

    debug(S, T, S2, T2, S3, T3)

    if (f) cout << "Yes" << endl;
    else cout << "No" << endl;
    
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        int N = s.nextInt();
        int K = s.nextInt();

        int counter = 0;

        while (--N >= 0) {
            int height = s.nextInt();

            if (height >= K)
                counter++;
        }

        System.out.println(counter);
    }
}

Measured memory_bytes: 48344
#include <bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
    if(a<b){swap(a,b);}
    if(a%b==0){return b;}
    return gcd(b,a%b);
}
int main(){
    int N;
    cin>>N;
    vector<int>A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    int sub=A[0];
    vector<int>kouho{0};
    int a;
    for(int i=1;i<N;i++){
        a=gcd(sub,A[i]);
        if(a!=sub){kouho.push_back(i);}
        sub=a;
    }
    int m;
    for(int i=0;i<kouho.size();i++){
        if(kouho[i]!=0){m=A[0];}
        else{m=A[1];}
        for(int j=0;j<N;j++){
            if(j==kouho[i]){continue;}
            m=gcd(m,A[j]);
        }
        sub=max(m,sub);
    }
    cout<<sub<<endl;
}

Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10**9)
N,M=map(int,input().split())

def find_negative_loop(n,w,es):
  dist=[float("inf")]*n
  #この始点はどこでもよい
  dist[1]=0
  
  for i in range(n):
    for j in range(w):
      e=es[j]
      if dist[e[1]]>dist[e[0]]+e[2]:
        dist[e[1]]=dist[e[0]]+e[2]
        if i==n-1:
          return True
  return False

def shortest_path(s,n,w,es):
  #s→iの最短距離
  #s:始点, n:頂点数, w:辺の数, es[i]:[辺の始点,辺の終点,辺のコスト]
  dist=[float("inf")]*n
  #d[i]: s→iの最短距離
  dist[s]=0

  while True:
    update=False
    for p,q,r in es:
      # e: 辺iについて [from,to,cost]
      if dist[p]!=float("inf") and dist[q]>dist[p]+r:
        dist[q]=dist[p]+r
        update=True
    if not update:
      break
      
  return dist

graph=[[] for _ in range(N+1)]
elist=[]
for _ in range(M):
  a,b,c=map(int,input().split())
  graph[a].append(b)
  elist.append((a,b,-c))
  
#remove unnecessary vertex and edge
visited=[None]*(N+1)
def check_reachable(u):
  if u==N:
    reachable[u]=True
    return True
  
  visited[u]=True
  cnt=0
  for v in graph[u]:
    if not visited[v]:
      ret=check_reachable(v)
      if ret:
        cnt+=1
        
  if cnt>0:
    reachable[u]=True
    return True
  else:
    return False

reachable=[None]*(N+1)
for i in range(1,N+1):
  if reachable[i]==None:
    visited=[False]*(N+1)
    check_reachable(i)
#print(reachable)
  
elist2=[]
for a,b,nc in elist:
  if reachable[b]:
    elist2.append((a,b,nc))
  
M2=len(elist2)
res1=find_negative_loop(N+1,M2,elist2)

if res1:
  print("inf")
else:
  res2=shortest_path(1,N+1,M2,elist2)
  print(-res2[N])

Measured memory_bytes: 4340
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    D = int(input())
    c = [0] + list(map(int, input().split()))
    s = [[0]*27]
    for _ in range(D):
        s.append([0] + list(map(int, input().split())))
    for i in range(1, D+1):
        print(s[i].index(max(s[i])))

if __name__ == '__main__':
    main()

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

typedef pair<int,int> P;

vector<P> ans;
int main() {
  int n;
  cin >> n;
  int t;
  if(n & 1) t = n - 1;
  else t = n;

  for(int i = 1; i <= t; i++) {
    for(int j = i + 1; j <= t; j++) {
      if(j == t - i + 1) continue;
      ans.push_back(P(i,j));
    }
  }

  if(n & 1) {
    for(int i = 1; i < n; i++) {
      ans.push_back(P(i,n));
    }
  }

  cout << ans.size() << endl;
  for(int i = 0; i < ans.size(); i++) {
    cout << ans[i].first <<" "<<ans[i].second << endl;
  }
}


Measured memory_bytes: 384
import java.util.Scanner;
public class Main{
    public static void main(String[]args){
        Scanner scan = new Scanner(System.in);
        int x,y;
        x=scan.nextInt();
        y=scan.nextInt();
        if(x>=4) x=0;
        if(y>=4) y=0;
        int[] arr = {0,300000,200000,100000};
        if(x==1&&y==1) System.out.println(arr[x]+arr[y]+400000);
        else System.out.println(arr[x]+arr[y]);
    }
}

Measured memory_bytes: 25172
import java.util.*;
public class Main {

	public static void main(String[] args) {
//		list = new ArrayList<>();
//		int m = 4;
//		for(int i = 0; i < m; i++){
//			list.add(i); list.add(i);
//		}
//		counter = 0;
//		curr = new ArrayList<>();
//		use = new boolean[2*m];
//		printall(2*m, 2*m);
		
		Scanner seer = new Scanner(System.in);
		int m = seer.nextInt();
		int k = seer.nextInt();
		if(m == 0){
			if(k == 0){
				System.out.println("0 0");
			}
			else{
				System.out.println(-1);
			}
		}
		else if(m == 1){
			if(k == 0){
				System.out.println("1 0 0 1");
			}
			else{
				System.out.println(-1);
			}
		}
		else{
			int p = (int)Math.pow(2, m);
			if(k == 0){
				StringBuilder sb = new StringBuilder();
				for(int i = 0; i < p; i++){
					sb.append(i+" "+i+" ");
				}
				System.out.println(sb.toString().trim());
			}
			else if(k < p){
				StringBuilder sb = new StringBuilder();
				sb.append("0 "); sb.append(k+" "); sb.append("0 ");
				for(int i = 1; i < p; i++){
					if(i != k){
						sb.append(i+" ");
					}
				}
				sb.append(k+" ");
				for(int i = p-1; i >= 1; i--){
					if(i != k){
						sb.append(i+" ");
					}
				}
				System.out.println(sb.toString().trim());
			}
			else{
				System.out.println(-1);
			}
		}
	}
//	static int target = 2;
//	static int counter;
//	static ArrayList<Integer> curr;
//	static boolean[] use;
//	static ArrayList<Integer> list;
//	static void printall(int iter, int n){
//		if(iter == 0) {
//			counter++;
//			HashSet<Integer> set = ks(curr, n);
//			if(set.size() == 1 && set.contains((Integer) target)){
//				System.out.println(counter);
//				System.out.println(curr);
//				System.out.println(ks(curr, n));	
//			}
//		}
//		else{
//			for(int i = 0; i < n; i++){
//				if(!use[i]){
//					curr.add(list.get(i));
//					use[i] = true;
//					printall(iter-1, n);
//					curr.remove(curr.size()-1);
//					use[i] = false;
//				}
//			}
//		}
//	}
//	static HashSet<Integer> ks(ArrayList<Integer> list, int n){
//		HashSet<Integer> res = new HashSet<>();
//		for(int i = 0; i < n; i++){
//			for(int j = i+1; j < n; j++){
//				if(list.get(i) == list.get(j)){
//					int s = 0;
//					for(int k = i; k <= j; k++){
//						s ^= list.get(k);
//					}
//					res.add(s);
//				}
//			}
//		}
//		return res;
//	}

}


Measured memory_bytes: 51856
#include <cstdio>
#include <algorithm>
using namespace std;
const int M=100000;
int parent[M],a[M],b[M],i,s,n,m;
pair<int,int>node[M];
int root(int a){return parent[a]==a?a:parent[a]=root(parent[a]);}
int unite(int a,int b){
  int x=root(a),y=root(b);
  if(x==y)return 0;
  parent[x]=y;
  return 1;
}
int main(){
  for(;scanf("%d%d",&n,&m)>1;printf("%d\n",s)){
    for(i=0;i<m;i++)scanf("%d%d%d",a+i,b+i,&node[i].first),node[i].second=i;
    sort(node,node+m);
    for(i=0;i<n;i++)parent[i]=i;
    for(s=i=0;i<m;i++)if(unite(a[node[i].second],b[node[i].second]))s+=node[i].first;
  }
}



Measured memory_bytes: 4304
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b;
  
  cin >> a >> b;

  cout << max(max(a + a - 1, b + b - 1), a + b) << endl;
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
using namespace std;
using ll = long long;
const ll mod = 1e9+7;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  cout << min(b/a,c);
}


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

int main(){
 UL N,T; cin>>N>>T;
 vector<ULL> O={0ull};
 rep(i,N){
  char c; cin>>c;
  if(c=='o') ++O.back();
  if(c=='x'){ O.push_back(1); O.push_back(0); }
 }

 UL X=0;
 
 ULL ans=0;
 for(ULL o:O){
  if(o<2){ ans+=o; continue; }
  if(o==2){ ans+=(1ull<<(T+1))+(1ull<<T)-1; continue; }
  ans+=(1ull<<T)*3;
  ans+=(o-3);
  X+=o-2;
 }
 T--;
 ans+=X*(((1ull<<T)-1)*6+3);
 cout<<ans<<endl;
 return 0;
}



Measured memory_bytes: 3148
#include <iostream>

using namespace std;

int main(){
    int w,h,x,y,r;
    cin>>w>>h>>x>>y>>r;
    int left=x-r,right=x+r,up=y+r,down=y-r;
    if((left>=0 && right<=w) && (up<=h && down >=0))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

using graph = vector<vector<ll>>;

vector<ll> ans;

//UnionFind実装
struct UnionFind{
    vector<int>d;
    UnionFind(int n=0):d(n,-1){}
    int root(int x){
        if(d[x] < 0) return x; // 根は-サイズでここだけが負の値
        return d[x] = root(d[x]);// 親を根に移す、経路縮約
    }
    bool unite(int x,int y){
        x = root(x),y = root(y);
        if(x == y) return false;
        if(d[x] > d[y]) swap(x,y); // 小さい方を大きい方につける
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x,int y){return root(x) == root(y);}
    int size(int x) {return -d[root(x)];}
};

int deg[100005];
vector<int> to[100005];
int main(){
    ll n,m,k;
    cin >> n >> m >> k;
    UnionFind uf(n);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--;b--;
        deg[a]++;
        deg[b]++;
        uf.unite(a,b);
    }
    rep(i,k){
        int a,b;
        cin >> a >> b;
        a--;b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    rep(i,n){
        int ans = uf.size(i) - 1 - deg[i];
        for(auto u : to[i]){
            if(uf.same(i,u)) ans--;
        }
        printf("%d%c",ans,i==n-1?'\n':' ');
    }
    return 0;

    
}

Measured memory_bytes: 9216
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <utility>
#include <tuple>
#include <algorithm>
#include <cmath>
#include <queue>

using namespace std;

int main(){

    int N,M, a,b;
    cin >> N >> M;


    vector<vector<int>> paths(N, vector<int>() );
    for(int i=0;i<M;++i){
        cin >> a >> b;
        paths[a-1].push_back(b-1);
        paths[b-1].push_back(a-1);
    }

    vector<int> ans(N,-1);
    queue<int> que;
    que.push(0);
    ans[0] = 0;

    int now;
    int cnt(1);

    while(!que.empty()){
        now = que.front();
        que.pop();
        for(auto e: paths[now]){
            if(ans[e] != -1) continue;
            ans[e] = now;
            que.push(e);
            ++cnt;
        }
    }

    if(cnt!=N){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
        for(int i=1;i<N;++i){
            cout << ans[i] + 1 << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 10160
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int N2=sc.nextInt();
		int count=N*N2;
		if(count%2==0) {
			System.out.println("Even");
		}else {
			System.out.println("Odd");
		}
	}
}

Measured memory_bytes: 35608
// https://atcoder.jp/contests/abc133/tasks/abc133_b

#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define FORR(i, m, n) for (int(i) = (n); (i) >= (m); i--)
#define rep(...) _overload3(__VA_ARGS__, FOR, REP, )(__VA_ARGS__)
#define repr(...) _overload3(__VA_ARGS__, FORR, REPR, )(__VA_ARGS__)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

double distance(vector<int> a, vector<int> b)
{
  double pow_sum = 0;
  rep(i, a.size())
  {
    pow_sum += pow(a[i] - b[i], 2);
  }
  return sqrt(pow_sum);
}

int main()
{
  int N, D, x, result = 0;
  cin >> N >> D;

  vector<vector<int>> X(N);
  rep(i, N)
  {
    rep(j, D)
    {
      cin >> x;
      X[i].pb(x);
    }
  }

  rep(i, N)
  {
    rep(j, i + 1, N)
    {
      double d = distance(X[i], X[j]);
      if (ceil(d) == floor(d))
        result++;
    }
  }

  cout << result << '\n';

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define M1 					1000000007
#define M2 					998244353
#define ll 					long long int
#define pll 				pair<ll,ll>
#define mll 				map<ll,ll>
#define F 					first
#define S 					second
#define PB 					push_back
#define mp 					make_pair
#define lb 					lower_bound
#define ub 					upper_bound
#define V(a) 				vector<a>
#define endl 				'\n'
#define test(t) 			while(t--)
#define PI 					acos(-1.0)
#define rep(i,a,b) 			for(ll i=a;i<b;i++)
#define repp(i,b,a) 		for(ll i=b-1;i>=a;i--)
#define clr(ar, val)		memset(ar, val, sizeof(ar))
#define setbits(x) 			__builtin_popcountll(x)
#define zrobits(x) 			__builtin_ctzll(x)
#define ps(y) 				fixed << setprecision(y)
#define all(x) 				begin(x),end(x)
#define allr(x) 			rbegin(x),rend(x)
const int inf= 				0x3f3f3f3f;
const ll INF= 				0x3f3f3f3f3f3f3f3f;
const int dx[4]= 			{ 0, -1, 0, 1 };
const int dy[4]= 			{ -1, 0, 1, 0 };

unsigned  int  randInt (){ 
    static  unsigned  int  tx  =  123456789 ,  ty = 362436069 ,  tz = 521288629 ,  tw = 88675123 ; 
    unsigned  int  tt  =  ( tx ^ ( tx << 11 )); 
    tx  =  ty ;  ty  =  tz ;  tz  =  tw ; 
    return  (  tw = ( tw^ ( tw >> 19 )) ^ ( tt ^ ( tt >> 8 ))  ); 
}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>
#define o_set(T) tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

ll floor_div(ll a, ll b) {
	return a / b - (((a ^ b) < 0) and a % b);
}
ll ceil_div(ll a, ll b){
    return a / b + (((a ^ b) >= 0) and a % b);
}

inline void INP()
{
	#ifndef ONLINE_JUDGE
	    freopen("input.txt","r",stdin);   
	    freopen("output.txt","w",stdout);
	#endif 
}

void solve()
{
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    while(1){
        c -= b;
        if (c <= 0){
            cout << "Yes" << endl;
            return;
        }
        a -= d;
        if(a <= 0){
            cout << "No" << endl;
            return;
        }
    }
}

int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    test(t){
        solve();
    }
    return 0;
}

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

template<typename T>
T powMod(T a, T b, T mod) {
    T c = 1;
    while (b) {
        if (b & 1) c = 1LL * c * a % mod;
        a = 1LL * a * a % mod;
        b >>= 1;
    }
    
    return c % mod;
}

int main() {
    int n;
    cin >> n;
    
    vector<double> v(n);
    for (double &x : v) cin >> x;
    
    priority_queue<double, vector<double>, greater<double> > q;
    for (double x : v) q.push(x);
    
    for (int i = 1; i < n; ++i) {
        double a = q.top(); q.pop();
        double b = q.top(); q.pop();
        q.push((a + b) / 2.0);
    }
    
    cout << q.top() << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define re          return
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)  for (__typeof(b) i=(a)-((a)>(b));i!=(b)-((a)>(b));i+=1-2*((a)>(b)))
#define PI            3.141592653589793l
#define fill(c,val) memset(c,val,sizeof(c))
#define LB lower_bound
#define UB upper_bound
#define inf 1e16
using namespace std;
typedef long long ll;
const ll INF=(1LL<<60)-1;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--){
  	 ll a,b,c,k;
  	 cin>>a>>b>>c>>k;
  	 //int K=1;
//  	    if(k==0){
//  	    	cout<<a-b;
//  	    	re 0;
//		  }
  	    if(k%2==0){
  	    	ll ta=(k)*1LL*a+(k-1)*1LL*b+(k-1)*1LL*c;
  	    	ll tb=(k-1)*1LL*a+(k)*1LL*b+(k-1)*1LL*c;
  	       	ll tc=(k-1)*1LL*a+(k-1)*1LL*b+(k)*1LL*c;
  	   if(abs(ta-tb)>1e18)
	    cout<<"Unfiar";
	   else
	   cout<<ta-tb;
	   return 0;
		  }
		if(k%2!=0){
  	    	ll tta=(k-1)*1LL*a+(k)*1LL*b+(k)*1LL*c;
  	    	ll ttb=(k)*1LL*a+(k-1)*1LL*b+(k)*1LL*c;
  	       	ll ttc=(k)*1LL*a+(k)*1LL*b+(k-1)*1LL*c;
  	   if(abs(tta-ttb)>1e18)
	    cout<<"Unfiar";
	   else
	   cout<<tta-ttb;
	   return 0;
		  }
   cout<<endl;
 }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long n;
long long a[200003];
long long dp[200003];
long long sumb[200003];
long long ans=-2e18;
long long sum;
long long su; 
int main(){
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	dp[1]=a[1];
	dp[2]=a[2];
	sumb[n]=a[n];
	sumb[n-1]=a[n-1];
	for(int i=3;i<=n;i++) dp[i]=dp[i-2]+a[i];
	for(int i=n-2;i>=1;i--) sumb[i]=sumb[i+2]+a[i];
	sum=dp[n];
	if(n%2==0){
		ans=max(dp[n-1],dp[n]);
		for(int i=1;i<=n;i+=2) ans=max(ans,dp[i]+sumb[i+3]);
		cout<<ans<<endl;
		return 0;
	}
	for(int i=1;i<=n;i++){
		if(i%2==0) su+=a[i];
		else{
			su=max(su-a[i],-a[i]);
			ans=max(ans,sum+su);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 8312
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

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

    LL a,b,c,d;
    cin>>a>>b>>c>>d;

    while(a > 0 && c > 0){
        c -= b;
        if(c <= 0){
            PUTS("Yes");
            return 0;
        }
        a -= d;
    }
    PUTS("No");
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int A,B;
    cin >> A >> B;
    if (A <= 9 && B <= 9) cout << A * B << endl;
    else cout << -1 << endl;
}


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

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,b) FOR(i, 0, b)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

void vprint(vector<ll> A){
    ll L = A.size();
    FOR(i, 0, L){
        if(i) cout << ' ';
        cout << A[i];
    }
    cout << endl;
}

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

    // input
    string s; cin >> s;
    ll L = s.size();

    set<ll> se;
    // RLなるi
    FOR(i, 0, L-1){
        if(s[i]=='R' && s[i+1]=='L'){
            se.insert(i);
        }
    }

    vector<ll> C(L, 0);
    vector<ll> Ans;
    FOR(i, 0, L){
        if(s[i]=='R'){
            auto it = se.lower_bound(i);
            // p(*it);
            ll index = *it;
            ll diff = abs(index - i);
            if(diff%2==0){
                C[index]++;
            }else{
                C[index+1]++;
            }
        }
        else{
            auto it = se.lower_bound(i);
            it--; // 左のR
            ll index = *it;
            ll diff = abs(index - i);
            // p(*it);
            if(diff%2==0){
                C[index]++;
            }else{
                C[index+1]++;
            }
        }
    }
    vprint(C);

    return 0;
}

Measured memory_bytes: 4432
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M = 30000 + 5;
int main(){
    int a,b,c,k,cnt=0;
    cin>>a>>b>>c>>k;
    while(a>=b){
        b*=2;
        cnt++;
    }
    while(b>=c){
        c*=2;
        cnt++;
    }
    if(cnt>k) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}


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

const int64_t MAX_ANS = 1000000000000000000;

int main(){
  int n;
  cin >> n;
  vector<int64_t> a(n, 0);
  bool hasZero = false;
  for (int i =0; i < n; ++i) {
    cin >> a[i];
    if (a[i] == 0) {
      hasZero = true;
    }
  }
  if (hasZero) {
      cout << 0 << endl;
      return 0;
  }

  int64_t total = 1;
  for (int i =0; i < n; ++i) {
    if (MAX_ANS / total < a[i]) {
      cout << "-1" << endl;
      return 0;
    }
    total *= a[i];
  }

  cout << total << endl;
  return 0;
}


Measured memory_bytes: 4052
import java.util.Scanner;
public class Main{
public static void main(String[] args){
  Scanner sc = new Scanner(System.in);
  String str1 = sc.next();
  String str2 = sc.next();
  
  String str = str2.concat(str1);
  System.out.println(str);
    sc.close();
}
}
  

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

pair<ll, ll> visit(int v, int p, vector<vector<ll>> &E) {
  pair<ll, ll> r = make_pair(0, v);
  for (ll u : E[v]) if (u != p) {
    pair<ll, ll> t = visit(u, v, E);
    t.first++;
    if (r.first < t.first) r = t;
  }
  return r;
}

ll diameter(vector<vector<ll>> &E) {
  pair<ll, ll> r = visit(0, -1, E);
  pair<ll, ll> t = visit(r.second, -1, E);
  return t.first;
}

int main(void) {
  ll N;
  cin >> N;
  vector<vector<ll>> E(N);
  REP(i, 0, N - 1) {
    ll a, b;
    cin >> a >> b, a--, b--;
    E[a].push_back(b);
    E[b].push_back(a);
  }

  ll r = diameter(E);
  cout << (r % 3 != 1 ? "First" : "Second") << endl;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

//-------------------------------------------------
//--Union Find tree
//-------------------------------------------------
class UnionFind
{
private:
    ::std::vector<int> par;
    ::std::vector<int> rank;
public:
    UnionFind(int n):par(n), rank(n){
        for(int i=0; i<n; i++){
            par[i] = i;
            rank[i] = 0;
        }
    }
    int root(int x){
        if (par[x]==x) return x;
        return par[x] = root(par[x]);
    }
    bool same(int x, int y){
        return root(x)==root(y);
    }
    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if (rx==ry) return;
        if (rank[rx]>rank[ry]){
            par[ry] = rx;
        }else{
            par[rx] = ry;
            if (rx==ry) rank[ry]++;
        }
    }
};

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k,l; cin>>n>>k>>l;
    UnionFind uf1(n), uf2(n);
    vi p(k),q(k);
    rep(i,k){
        cin>>p[i]>>q[i]; p[i]--; q[i]--;
        uf1.unite(p[i],q[i]);
    }
    vi r(l),s(l);
    rep(i,l){
        cin>>r[i]>>s[i]; r[i]--; s[i]--;
        uf2.unite(r[i],s[i]);
    }
    map<pi,int> cnt;
    rep(i,n){
        int r1 = uf1.root(i);
        int r2=  uf2.root(i);
        cnt[mp(r1,r2)]++;
    }
    rep(i,n){
        if (i>0) cout<<" ";
        int r1 = uf1.root(i);
        int r2=  uf2.root(i);
        cout<<cnt[mp(r1,r2)];
    }cout<<"\n";
    return 0;
}


Measured memory_bytes: 16640
from collections import deque
n=int(input())
a=list(map(int,input().split()))
a.sort()
a=a[::-1]
ans=0
x=deque([a[0]])
nn=n//2
for i in range(1,nn+1):
  ans+=min(x[0],x[-1])
  x.append(a[i])
  x.appendleft(a[i])
x=ans-a[0]
if n%2==0:
  ans+=x
  print(ans)
else:
  ans+=x+a[nn]
  print(ans)

Measured memory_bytes: 32512
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repq(i,a,n) for(int i=a; i<=n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

signed main() {
    int a, b, x; cin >> a >> b >> x;
    int lo = a / x;
    int hi = b / x;
    if(a % x == 0) cout << hi - lo + 1 << endl;
    else cout << hi - lo << endl;
    return 0;
}

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

using namespace std;

int main() {
	string a, b;
	cin >> a >> b;
	
	int n = a.length();
	int m = b.length();
	
	vector< vector<int> > dp(n+1, vector<int> (m+1, 0));
	int i, j;
	for (i=1; i<=n; i++) {
		for (j=1; j<=m; j++) {
			if (a[i-1]==b[j-1])
				dp[i][j] = dp[i-1][j-1] + 1;
			else
				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
		}
	}
	i=n;
	j=m;
	string lcs = "";
	while(i>0 && j>0) {
		if (a[i-1]==b[j-1]) {
			lcs+=a[i-1];
			i--;
			j--;
		}
		else if (dp[i-1][j]>dp[i][j-1])
			i--;
		else
			j--;
	}
	reverse(lcs.begin(), lcs.end());
	cout << lcs << endl;
}

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

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n;
	map<int, int> mp;
	cin >> n;
	long long answer = 0;
	for (int i = 1; i <= n; ++i) {
		int ai;
		cin >> ai;
		answer += mp[i - ai];
		++mp[i + ai];
	}
	cout << answer;
}

Measured memory_bytes: 20580
n,m = map(int,input().split())
a = list(map(int,input().split()))

sum_s =[0]*n
sum_s[0]=(a[0])%m
for i in range(1,n):
  sum_s[i] = (a[i]+ sum_s [i-1])%m

#print(sum_s)
dict = {}
for i in range(n):
  if sum_s[i] not in dict:
    dict[sum_s[i]] = 1
  else:
    dict[sum_s[i]] += 1

#print(sum_s)

def combination(n,r):
    r = min(r,n-r)
    result = 1
    for i in range(n-r+1,n+1):
        result *= i
    for i in range(1,r+1):
        result //= i
    return result

ans=0
for i in dict:
  if i == 0:
    if dict[i]>=2:
      ans +=combination(dict[i],2)
    ans +=dict[i] 
  else:
    if dict[i]>=2:
      ans += combination(dict[i],2)
      #print(i,dict[i],combination(dict[i],2))
print(ans)

Measured memory_bytes: 16300
#include <stdio.h>

int main(){
   int i, n;
   int arr[100];
   scanf("%d", &n);
   for(i=0;i<n;i++){
       scanf(" %d", &arr[i]);
   }
   for(i=0;i<n;i++){
       if(i)printf(" ");
       printf("%d", arr[n-i-1]);
   }
   printf("\n");
   return 0;
}


Measured memory_bytes: 2124
// template {{{

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

#define loop(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) loop(i, 0, n)
#define rloop(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define rrep(i, n) rloop(i, 0, n)
#define eb emplace_back
#define ef emplace_front
#define pb pop_back
#define pf pop_front
#define all(c) std::begin(c), std::end(c)
#define mp std::make_pair
#define mt std::make_tuple
#define fi first
#define se second
#define popcnt __builtin_popcountll

using uint = unsigned;
using ll = long long;
using ull = unsigned long long;
using ld = long double;

template<typename T>
using max_pq = priority_queue<T, vector<T>, less<T>>;

template<typename T>
using min_pq = priority_queue<T, vector<T>, greater<T>>;

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

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

template<typename T>
inline T sq(T x){ return x * x; }

template<typename T, typename U>
inline bool chmax(T &x, U y){ if (x >= y) return false; x = y; return true; }

template<typename T, typename U>
inline bool chmin(T &x, U y){ if (x <= y) return false; x = y; return true; }

template<typename T>
inline void sort(T &c){ std::sort(std::begin(c), std::end(c)); }

template<typename T>
inline void reverse(T &c){ std::reverse(std::begin(c), std::end(c)); }

template<typename T>
inline void unique(T &c){ std::sort(std::begin(c), std::end(c)); c.erase(std::unique(all(c)), std::end(c)); }

// }}}

using vi = vector<int>;

const string T[] = {
	"ABIGD",
	"BCAHE",
	"CDBIF",
	"DECAG",
	"EFDBH",
	"FGECI",
	"GHFDA",
	"HIGEB",
	"IAHFC"
};

int H[9][2], V[9][2];
int ch, cv;
vi s(9), g(9);
unordered_map<int, int> dist;

int pack(const vi &v){
	int r = 0;
	rep(i, 9) r = r * 9 + v[i];
	return r;
}

vi unpack(int v){
	vi r(9);
	rrep(i, 9){
		r[i] = v % 9;
		v /= 9;
	}
	return r;
}

int main()
{
	for (auto s : T){
		rep(i, 2){
			H[s[0] - 'A'][i] = s[i + 1] - 'A';
			V[s[0] - 'A'][i] = s[i + 3] - 'A';
		}
	}

	/*{
		vi v(9);
		iota(all(v), 0);
		do {
			int t = conv1.size();
			conv1[v] = t;
			conv2[t] = v;
		} while (next_permutation(all(v)));
	}*/
	
	while (cin >> ch >> cv, ch){
		rep(i, 9) cin >> s[i];
		rep(i, 9) cin >> g[i];
		min_pq<pair<int, int>> pq;
		dist.clear();
		dist[pack(s)] = 0;
		pq.emplace(0, pack(s));
		while (pq.size()){
			int sum; int v_;
			tie(sum, v_) = pq.top(); pq.pop();
			vi v = unpack(v_);
			if (v == g) break;
			if (dist[v_] < sum) continue;
			int p = find(all(v), 0) - begin(v);
			rep(i, 2){
				vi nv = v;
				swap(nv[p], nv[H[p][i]]);
				if (!dist.count(pack(nv))) dist[pack(nv)] = INF;
				if (chmin(dist[pack(nv)], sum + ch)){
					pq.emplace(sum + ch, pack(nv));
				}
				nv = v;
				swap(nv[p], nv[V[p][i]]);
				if (!dist.count(pack(nv))) dist[pack(nv)] = INF;
				if (chmin(dist[pack(nv)], sum + cv)){
					pq.emplace(sum + cv, pack(nv));
				}
			}
		}
		cout << dist[pack(g)] << endl;
	}
}

Measured memory_bytes: 19464
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int N,L;
    cin >> N >> L;

    vector<int> arr;
    for (int i { 0 }; i < N; ++i) {
        arr.push_back(L+i);
    }


    sort(arr.begin(), arr.end(), [](int x, int y){
        return abs(x) < abs(y);
    });

    int result { 0 };
    for (int i { 1 }; i < N; i++) {
        result += arr.at(i);
    }

    cout << result << endl;

    return 0;
}

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

int main() {
  int i = 0;
  int N;
  string S;
  string X;
  
  cin >> N ;
  
  while(i < N){
    cin >> S;
    if(S == "Y"){
      X = "Four";
      break;
    }else{
      X = "Three";
    }
    i++;
  }
  cout << X << endl;
}


Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    static int n;
    static double[,,] dp;

    static double solve(int x, int y, int z)
    {
	if (dp[x,y,z] != -1.0) return dp[x,y,z];

	double r = 0.0;

	if(x > 0)
	    r += (solve(x-1,y+1,z) + 1.0 * n / (x+y+z)) * x/(x+y+z);

	if (y > 0)
	    r += (solve(x,y-1,z+1) + 1.0 * n / (x+y+z)) * y/(x+y+z);

	if (z > 0)
	    r += (solve(x,y,z-1) + 1.0 * n / (x+y+z)) * z/(x+y+z); 

	return dp[x,y,z] = r;
    }

    /*
    static double solve(int x, int y, int z)
    {
	WriteLine($"dp[{x},{y},{z}] = ...");
	double r = solve2(x, y, z);
	WriteLine($"dp[{x},{y},{z}] = {r}");
	return dp[x,y,z] = r;
    } // */
    
    public static void Main()
    {
	n = int.Parse(ReadLine());
	int[] a = ReadIntArray();
	int[] c = new int[4];
	for (int i = 0; i < n; i++) c[a[i]]++;

	dp = new double[301,301,301];
	for (int i = 0; i < 301; i++)
	    for (int j = 0; j < 301; j++)
		for (int k = 0; k < 301; k++)
		    dp[i,j,k] = -1.0;

	dp[0,0,0] = 0;
	WriteLine(solve(c[3],c[2],c[1]));
    }
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
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; }
const ll MOD = 1e9+7;

int main(){
    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    A--, B--, C--, D--;
    string S;
    cin >> S;

    if(C < D){
        bool ac = true;
        for(int i = A+1; i < C; i++){
            char c1 = S[i];
            char c2 = S[i+1];
            if(c1 == '#' && c2 == '#'){
                ac = false;
            }
        }

        bool cd = true;
        for(int i = B+1; i < D; i++){
            char c1 = S[i];
            char c2 = S[i+1];
            if(c1 == '#' && c2 == '#'){
                cd = false;
            }
        }

        if(cd && ac){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
    else{
        bool ac = true;
        for(int i = A+1; i < C; i++){
            char c1 = S[i];
            char c2 = S[i+1];
            if(c1 == '#' && c2 == '#'){
                ac = false;
            }
        }

        bool cd = false;
        for(int i = B-1; i < D; i++){
            char c1 = S[i];
            char c2 = S[i+1];
            char c3 = S[i+2];
            if(c1 == '.' && c2 == '.' && c3 == '.'){
                cd = true;
            }
        }

        if(cd && ac){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
        
    }



    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	string s,t;

	scan(N>>s>>t);
	int ans=2*N;
	rep(i,N){
		int flag=1;
		rep(j,N-i){
			if(s[i+j]!=t[j]) flag=0;
		}
		if(flag) ans=min(ans,N+i);
	}
	prin(ans);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int x, y, z, a, b;
	int t=0;
	
	while(scanf("%d", &x)!=EOF){
	t=0;
	for(y=0; y<10; y++){
		for(z=0; z<10; z++){
			for(a=0; a<10; a++){
				for(b=0; b<10; b++){
					if(y+z+a+b==x)
						t++;
					}
				}
			}
		}
	printf("%d\n", t);
	}
	return 0;
}

Measured memory_bytes: 596
n,x = map(int,input().split())
a = [int(x) for x in input().split()]
a.sort()
for i in range(len(a)):
    if x>=a[i]:
        x-=a[i]
    else:
        i-=1
        break
else:
    if x>0:
         i-=1
print(i+1)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <cmath>
#include <tuple>
#include <algorithm>
#include <ctime>
#include <map>
using namespace std;


const long long MOD = static_cast<long long>(1e9+7);
const long long INFINITE = static_cast<long long>(1e16);
const bool IS_DEBUG = true;


#undef int
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int R,C,K;
    cin>>R>>C>>K;
    vector<vector<long long > > items(R,vector<long long >(C,0));
    for(int c=0;c<K;c++) {
        long long int x,y,v;
        cin>>x>>y>>v;
        items[x-1][y-1]=v;
    }
    vector<vector<vector<long long > > > dp(R,vector<vector<long long>> (C,vector<long long>(4,0)));
    long long res = 0;

    for(int x=0;x<R;x++) {
        for(int y=0;y<C;y++) {
            for(int c2=0;c2<4;c2++) {
                if(c2>0) dp[x][y][c2]=max(dp[x][y][c2-1],dp[x][y][c2]);
                if(x>0){
                    dp[x][y][c2]=max(dp[x][y][c2],dp[x-1][y][3]);
                    if(c2 != 0) {
                        dp[x][y][c2] = max(dp[x][y][c2], dp[x-1][y][3] + items[x][y]);
                    }
                }
                if(y>0){
                    dp[x][y][c2]=max(dp[x][y][c2],dp[x][y-1][c2]);
                    if(c2 > 0) {
                        dp[x][y][c2]=max(dp[x][y][c2],dp[x][y-1][c2-1]+items[x][y]);
                    }
                }
                if(x == 0 && y == 0 && c2 > 0) {
                    dp[x][y][c2] = max(dp[x][y][c2], items[x][y]);
                }
                res=max(res,dp[x][y][c2]);
               // cout<<x<<" "<<y<<" "<<c2<<" "<<dp[x][y][c2]<<endl;
            }
        }
    }
    cout<<res;
}


Measured memory_bytes: 706020
n = int(input())
b_list = list(map(int,input().split()))
c_list = []
sum_num = 0
for i in range(n):
    sum_num += b_list[i] * (-1)**i
c_list.append(sum_num)
for i in range(1,n):
    c_list.append(-c_list[i-1]+2*b_list[i-1])
print(" ".join(map(str,c_list)))

Measured memory_bytes: 19148
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int sum=0;
    for(int i = 0; i <n; i++){
        int t;
        cin>>t;
        if(t<abs(t-k))
            sum+=t*2;
        else
            sum+=abs(t-k)*2;
    }
    cout<<sum;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
const int INF = 1<<29;
using namespace std;

int main(){
    string S;
    cin >> S;
    int n = S.size();
    vector<int> a(n + 1);
   
    for (int i = 1; i <= n; i++){
        a.at(i) = S.at(i - 1) - 48;
    }
    vector<int64_t> T(n + 1);
    vector<int64_t> U(n + 1, 1);
    for(int i = n - 1; i > 0; i--){
        U.at(i) = (U.at(i + 1)*10) % 2019;
    }
    
    T.at(n) = a.at(n);
    for(int i = n - 1; i >= 1; i--){
        T.at(i) = (T.at(i + 1) + a.at(i) * U.at(i)) % 2019;
    }
    
    
    vector<int> b(2020, 0);
    for(int i = 1; i <= n; i++){
        b.at(T.at(i))++;
    }
    b.at(0)++;
    int64_t ans = 0;
    for(int i = 0; i<=2018; i++){
        int x = b.at(i);
        ans += x * (x - 1) / 2;
    }
   
    cout << ans << endl;
}

Measured memory_bytes: 7496